mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Merge pull request #386 from PhenomRetroShare/Add_AbilityToChangeOpModeInCmdLine
Add the ability to change OpMode in command line.
This commit is contained in:
commit
e56340e0a1
@ -289,6 +289,7 @@ public:
|
|||||||
/* Operating Mode */
|
/* Operating Mode */
|
||||||
virtual uint32_t getOperatingMode() = 0;
|
virtual uint32_t getOperatingMode() = 0;
|
||||||
virtual bool setOperatingMode(uint32_t opMode) = 0;
|
virtual bool setOperatingMode(uint32_t opMode) = 0;
|
||||||
|
virtual bool setOperatingMode(const std::string &opModeStr) = 0;
|
||||||
|
|
||||||
/* Data Rate Control - to be moved here */
|
/* Data Rate Control - to be moved here */
|
||||||
virtual int SetMaxDataRates( int downKb, int upKb ) = 0;
|
virtual int SetMaxDataRates( int downKb, int upKb ) = 0;
|
||||||
|
@ -380,7 +380,7 @@ uint32_t p3ServerConfig::getOperatingMode()
|
|||||||
{
|
{
|
||||||
mode = RS_OPMODE_GAMING;
|
mode = RS_OPMODE_GAMING;
|
||||||
}
|
}
|
||||||
else if (modestr == "MINIMAL_TRANSFER")
|
else if (modestr == "MINIMAL")
|
||||||
{
|
{
|
||||||
mode = RS_OPMODE_MINIMAL;
|
mode = RS_OPMODE_MINIMAL;
|
||||||
}
|
}
|
||||||
@ -410,7 +410,7 @@ bool p3ServerConfig::setOperatingMode(uint32_t opMode)
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
case RS_OPMODE_MINIMAL:
|
case RS_OPMODE_MINIMAL:
|
||||||
modestr = "MINIMAL_TRANSFER";
|
modestr = "MINIMAL";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
mGeneralConfig->setSetting(RS_CONFIG_OPERATING_STRING, modestr);
|
mGeneralConfig->setSetting(RS_CONFIG_OPERATING_STRING, modestr);
|
||||||
@ -423,6 +423,31 @@ bool p3ServerConfig::setOperatingMode(uint32_t opMode)
|
|||||||
return switchToOperatingMode(opMode);
|
return switchToOperatingMode(opMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool p3ServerConfig::setOperatingMode(const std::string &opModeStr)
|
||||||
|
{
|
||||||
|
uint32_t opMode = RS_OPMODE_FULL;
|
||||||
|
std::string upper;
|
||||||
|
stringToUpperCase(opModeStr, upper);
|
||||||
|
|
||||||
|
if (upper == "NOTURTLE")
|
||||||
|
{
|
||||||
|
opMode = RS_OPMODE_NOTURTLE;
|
||||||
|
}
|
||||||
|
else if (upper == "GAMING")
|
||||||
|
{
|
||||||
|
opMode = RS_OPMODE_GAMING;
|
||||||
|
}
|
||||||
|
else if (upper == "MINIMAL")
|
||||||
|
{
|
||||||
|
opMode = RS_OPMODE_MINIMAL;
|
||||||
|
}
|
||||||
|
else // "FULL" by default
|
||||||
|
{
|
||||||
|
opMode = RS_OPMODE_FULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return setOperatingMode(opMode);
|
||||||
|
}
|
||||||
|
|
||||||
bool p3ServerConfig::switchToOperatingMode(uint32_t opMode)
|
bool p3ServerConfig::switchToOperatingMode(uint32_t opMode)
|
||||||
{
|
{
|
||||||
|
@ -91,6 +91,7 @@ virtual bool setConfigurationOption(uint32_t key, const std::string &opt);
|
|||||||
/* Operating Mode */
|
/* Operating Mode */
|
||||||
virtual uint32_t getOperatingMode();
|
virtual uint32_t getOperatingMode();
|
||||||
virtual bool setOperatingMode(uint32_t opMode);
|
virtual bool setOperatingMode(uint32_t opMode);
|
||||||
|
virtual bool setOperatingMode(const std::string &opModeStr);
|
||||||
|
|
||||||
virtual int SetMaxDataRates( int downKb, int upKb );
|
virtual int SetMaxDataRates( int downKb, int upKb );
|
||||||
virtual int GetMaxDataRates( int &downKb, int &upKb );
|
virtual int GetMaxDataRates( int &downKb, int &upKb );
|
||||||
|
@ -138,6 +138,7 @@ class RsInitConfig
|
|||||||
std::string load_trustedpeer_file;
|
std::string load_trustedpeer_file;
|
||||||
|
|
||||||
bool udpListenerOnly;
|
bool udpListenerOnly;
|
||||||
|
std::string opModeStr;
|
||||||
};
|
};
|
||||||
|
|
||||||
static RsInitConfig *rsInitConfig = NULL;
|
static RsInitConfig *rsInitConfig = NULL;
|
||||||
@ -189,6 +190,7 @@ void RsInit::InitRsConfig()
|
|||||||
rsInitConfig->passwd = "";
|
rsInitConfig->passwd = "";
|
||||||
rsInitConfig->debugLevel = PQL_WARNING;
|
rsInitConfig->debugLevel = PQL_WARNING;
|
||||||
rsInitConfig->udpListenerOnly = false;
|
rsInitConfig->udpListenerOnly = false;
|
||||||
|
rsInitConfig->opModeStr = std::string("FULL");
|
||||||
|
|
||||||
/* setup the homePath (default save location) */
|
/* setup the homePath (default save location) */
|
||||||
// rsInitConfig->homePath = getHomePath();
|
// rsInitConfig->homePath = getHomePath();
|
||||||
@ -363,11 +365,11 @@ int RsInit::InitRetroShare(int _argc, char **_argv, bool /* strictCheck */)
|
|||||||
>> parameter('l',"log-file" ,rsInitConfig->logfname ,"logfile" ,"Set Log filename." ,false)
|
>> parameter('l',"log-file" ,rsInitConfig->logfname ,"logfile" ,"Set Log filename." ,false)
|
||||||
>> parameter('d',"debug-level" ,rsInitConfig->debugLevel ,"level" ,"Set debug level." ,false)
|
>> parameter('d',"debug-level" ,rsInitConfig->debugLevel ,"level" ,"Set debug level." ,false)
|
||||||
#ifdef TO_REMOVE
|
#ifdef TO_REMOVE
|
||||||
// This as removed because it is not used anymore.
|
// This was removed because it is not used anymore.
|
||||||
|
|
||||||
>> parameter('w',"password" ,rsInitConfig->passwd ,"password" ,"Set Login Password." ,false)
|
>> parameter('w',"password" ,rsInitConfig->passwd ,"password" ,"Set Login Password." ,false)
|
||||||
#endif
|
#endif
|
||||||
>> parameter('i',"ip-address" ,rsInitConfig->inet ,"nnn.nnn.nnn.nnn", "Force IP address to use (if cannot be detected)." ,false)
|
>> parameter('i',"ip-address" ,rsInitConfig->inet ,"nnn.nnn.nnn.nnn", "Force IP address to use (if cannot be detected)." ,false)
|
||||||
|
>> parameter('o',"opmode" ,rsInitConfig->opModeStr ,"opmode" ,"Set Operating mode (Full, NoTurtle, Gaming, Minimal)." ,false)
|
||||||
>> parameter('p',"port" ,rsInitConfig->port ,"port", "Set listenning port to use." ,false)
|
>> parameter('p',"port" ,rsInitConfig->port ,"port", "Set listenning port to use." ,false)
|
||||||
>> parameter('c',"base-dir" ,opt_base_dir ,"directory", "Set base directory." ,false)
|
>> parameter('c',"base-dir" ,opt_base_dir ,"directory", "Set base directory." ,false)
|
||||||
>> parameter('U',"user-id" ,prefUserString ,"ID", "[ocation Id] Sets Account to Use, Useful when Autologin is enabled.",false)
|
>> parameter('U',"user-id" ,prefUserString ,"ID", "[ocation Id] Sets Account to Use, Useful when Autologin is enabled.",false)
|
||||||
@ -1733,6 +1735,10 @@ int RsServer::StartupRetroShare()
|
|||||||
mPeerMgr->forceHiddenNode();
|
mPeerMgr->forceHiddenNode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!rsInitConfig->opModeStr.empty())
|
||||||
|
{
|
||||||
|
rsConfig->setOperatingMode(rsInitConfig->opModeStr);
|
||||||
|
}
|
||||||
mNetMgr -> checkNetAddress();
|
mNetMgr -> checkNetAddress();
|
||||||
|
|
||||||
if (rsInitConfig->hiddenNodeSet) {
|
if (rsInitConfig->hiddenNodeSet) {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2004 Xavier Décoret <Xavier.Decoret@imag.fr>
|
/* Copyright (C) 2004 Xavier Decoret <Xavier.Decoret@imag.fr>
|
||||||
*
|
*
|
||||||
* argstream is free software; you can redistribute it and/or
|
* argstream is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Library General Public
|
* modify it under the terms of the GNU Library General Public
|
||||||
@ -71,8 +71,8 @@ namespace
|
|||||||
private:
|
private:
|
||||||
std::string shortName_;
|
std::string shortName_;
|
||||||
std::string longName_;
|
std::string longName_;
|
||||||
std::string valueName_;
|
|
||||||
T* value_;
|
T* value_;
|
||||||
|
std::string valueName_;
|
||||||
T initialValue_;
|
T initialValue_;
|
||||||
std::string description_;
|
std::string description_;
|
||||||
bool mandatory_;
|
bool mandatory_;
|
||||||
@ -282,8 +282,8 @@ namespace
|
|||||||
bool mandatory)
|
bool mandatory)
|
||||||
: shortName_(1,s),
|
: shortName_(1,s),
|
||||||
longName_(l),
|
longName_(l),
|
||||||
valueName_(valueName),
|
|
||||||
value_(&v),
|
value_(&v),
|
||||||
|
valueName_(valueName),
|
||||||
initialValue_(v),
|
initialValue_(v),
|
||||||
description_(desc),
|
description_(desc),
|
||||||
mandatory_(mandatory)
|
mandatory_(mandatory)
|
||||||
@ -296,8 +296,8 @@ namespace
|
|||||||
const char* desc,
|
const char* desc,
|
||||||
bool mandatory)
|
bool mandatory)
|
||||||
: longName_(l),
|
: longName_(l),
|
||||||
valueName_(valueName),
|
|
||||||
value_(&v),
|
value_(&v),
|
||||||
|
valueName_(valueName),
|
||||||
initialValue_(v),
|
initialValue_(v),
|
||||||
description_(desc),
|
description_(desc),
|
||||||
mandatory_(mandatory)
|
mandatory_(mandatory)
|
||||||
@ -310,8 +310,8 @@ namespace
|
|||||||
const char* desc,
|
const char* desc,
|
||||||
bool mandatory)
|
bool mandatory)
|
||||||
: shortName_(1,s),
|
: shortName_(1,s),
|
||||||
valueName_(valueName),
|
|
||||||
value_(&v),
|
value_(&v),
|
||||||
|
valueName_(valueName),
|
||||||
initialValue_(v),
|
initialValue_(v),
|
||||||
description_(desc),
|
description_(desc),
|
||||||
mandatory_(mandatory)
|
mandatory_(mandatory)
|
||||||
|
@ -1492,6 +1492,23 @@ void MainWindow::processLastArgs()
|
|||||||
/* Now use files from the command line, because no RetroShare was running */
|
/* Now use files from the command line, because no RetroShare was running */
|
||||||
openRsCollection(Rshare::files()->takeFirst());
|
openRsCollection(Rshare::files()->takeFirst());
|
||||||
}
|
}
|
||||||
|
/* Handle the -opmode options. */
|
||||||
|
if (opModeStatus) {
|
||||||
|
QString opmode = Rshare::opmode().toLower();
|
||||||
|
if (opmode == "noturtle") {
|
||||||
|
opModeStatus->setCurrentIndex(RS_OPMODE_NOTURTLE - 1);
|
||||||
|
} else if (opmode == "gaming") {
|
||||||
|
opModeStatus->setCurrentIndex(RS_OPMODE_GAMING - 1);
|
||||||
|
} else if (opmode == "minimal") {
|
||||||
|
opModeStatus->setCurrentIndex(RS_OPMODE_MINIMAL - 1);
|
||||||
|
} else {
|
||||||
|
opModeStatus->setCurrentIndex(RS_OPMODE_FULL - 1);
|
||||||
|
}
|
||||||
|
opModeStatus->setOpMode();
|
||||||
|
} else {
|
||||||
|
std::cerr << "ERR: MainWindow::processLastArgs opModeStatus is not initialized.";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::switchVisibilityStatus(StatusElement e,bool b)
|
void MainWindow::switchVisibilityStatus(StatusElement e,bool b)
|
||||||
|
@ -46,7 +46,7 @@ public:
|
|||||||
QColor getOpMode_Minimal_Color() const;
|
QColor getOpMode_Minimal_Color() const;
|
||||||
void setOpMode_Minimal_Color( QColor c );
|
void setOpMode_Minimal_Color( QColor c );
|
||||||
|
|
||||||
private slots:
|
public slots:
|
||||||
void setOpMode();
|
void setOpMode();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -189,6 +189,17 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO);
|
|||||||
Q_INIT_RESOURCE(images);
|
Q_INIT_RESOURCE(images);
|
||||||
Q_INIT_RESOURCE(icons);
|
Q_INIT_RESOURCE(icons);
|
||||||
|
|
||||||
|
// Loop through all command-line args/values to get help wanted before RsInit exit.
|
||||||
|
for (int i = 0; i < args.size(); ++i) {
|
||||||
|
QString arg;
|
||||||
|
/* Get the argument name and set a blank value */
|
||||||
|
arg = args.at(i);
|
||||||
|
if ((arg.toLower() == "-h") || (arg.toLower() == "--help")) {
|
||||||
|
QApplication dummyApp (argc, argv); // needed for QMessageBox
|
||||||
|
Rshare::showUsageMessageBox();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// This is needed to allocate rsNotify, so that it can be used to ask for PGP passphrase
|
// This is needed to allocate rsNotify, so that it can be used to ask for PGP passphrase
|
||||||
//
|
//
|
||||||
RsControl::earlyInitNotificationSystem() ;
|
RsControl::earlyInitNotificationSystem() ;
|
||||||
|
@ -55,23 +55,27 @@
|
|||||||
#include "rshare.h"
|
#include "rshare.h"
|
||||||
|
|
||||||
/* Available command-line arguments. */
|
/* Available command-line arguments. */
|
||||||
#define ARG_LANGUAGE "lang" /**< Argument specifying language. */
|
|
||||||
#define ARG_GUISTYLE "style" /**< Argument specfying GUI style. */
|
|
||||||
#define ARG_GUISTYLESHEET "stylesheet" /**< Argument specfying GUI style. */
|
|
||||||
#define ARG_RESET "reset" /**< Reset Rshare's saved settings. */
|
#define ARG_RESET "reset" /**< Reset Rshare's saved settings. */
|
||||||
#define ARG_DATADIR "datadir" /**< Directory to use for data files. */
|
#define ARG_DATADIR "datadir" /**< Directory to use for data files. */
|
||||||
#define ARG_LOGFILE "logfile" /**< Location of our logfile. */
|
#define ARG_LOGFILE "logfile" /**< Location of our logfile. */
|
||||||
#define ARG_LOGLEVEL "loglevel" /**< Log verbosity. */
|
#define ARG_LOGLEVEL "loglevel" /**< Log verbosity. */
|
||||||
|
#define ARG_GUISTYLE "style" /**< Argument specfying GUI style. */
|
||||||
|
#define ARG_GUISTYLESHEET "stylesheet" /**< Argument specfying GUI style. */
|
||||||
|
#define ARG_LANGUAGE "lang" /**< Argument specifying language. */
|
||||||
|
#define ARG_OPMODE_S "o" /**< OpMode (Full, NoTurtle, Gaming, Minimal) */
|
||||||
|
#define ARG_OPMODE_L "opmode" /**< OpMode (Full, NoTurtle, Gaming, Minimal) */
|
||||||
#define ARG_RSLINK_S "r" /**< Open RsLink with protocol retroshare:// */
|
#define ARG_RSLINK_S "r" /**< Open RsLink with protocol retroshare:// */
|
||||||
#define ARG_RSLINK_L "link" /**< Open RsLink with protocol retroshare:// */
|
#define ARG_RSLINK_L "link" /**< Open RsLink with protocol retroshare:// */
|
||||||
#define ARG_RSFILE_S "f" /**< Open RsFile with or without arg */
|
#define ARG_RSFILE_S "f" /**< Open RsFile with or without arg. */
|
||||||
#define ARG_RSFILE_L "rsfile" /**< Open RsFile with or without arg */
|
#define ARG_RSFILE_L "rsfile" /**< Open RsFile with or without arg. */
|
||||||
//Other defined for server in /libretroshare/src/rsserver/rsinit.cc:351
|
//Other defined for server in /libretroshare/src/rsserver/rsinit.cc:351
|
||||||
|
|
||||||
// The arguments here can be send to a running instance.
|
// The arguments here can be send to a running instance.
|
||||||
// If the command line contains arguments not listed here, we have to start a new instance.
|
// If the command line contains arguments not listed here, we have to start a new instance.
|
||||||
// For exmample, the user wants to start a second instance using --base-dir arg of libretroshare.
|
// For example, the user wants to start a second instance using --base-dir arg of libretroshare.
|
||||||
static const char* const forwardableArgs[] = {
|
static const char* const forwardableArgs[] = {
|
||||||
|
ARG_OPMODE_S,
|
||||||
|
ARG_OPMODE_L,
|
||||||
ARG_RSLINK_S,
|
ARG_RSLINK_S,
|
||||||
ARG_RSLINK_L,
|
ARG_RSLINK_L,
|
||||||
ARG_RSFILE_S,
|
ARG_RSFILE_S,
|
||||||
@ -81,11 +85,12 @@ static const char* const forwardableArgs[] = {
|
|||||||
|
|
||||||
/* Static member variables */
|
/* Static member variables */
|
||||||
QMap<QString, QString> Rshare::_args; /**< List of command-line arguments. */
|
QMap<QString, QString> Rshare::_args; /**< List of command-line arguments. */
|
||||||
|
Log Rshare::_log; /**< Logs debugging messages to file or stdout. */
|
||||||
QString Rshare::_style; /**< The current GUI style. */
|
QString Rshare::_style; /**< The current GUI style. */
|
||||||
QString Rshare::_stylesheet; /**< The current GUI stylesheet. */
|
QString Rshare::_stylesheet; /**< The current GUI stylesheet. */
|
||||||
QString Rshare::_language; /**< The current language. */
|
QString Rshare::_language; /**< The current language. */
|
||||||
QString Rshare::_dateformat; /**< The format of dates in feed items etc. */
|
QString Rshare::_dateformat; /**< The format of dates in feed items etc. */
|
||||||
Log Rshare::_log; /**< Logs debugging messages to file or stdout. */
|
QString Rshare::_opmode; /**< The operating mode passed by args. */
|
||||||
QStringList Rshare::_links; /**< List of links passed by arguments. */
|
QStringList Rshare::_links; /**< List of links passed by arguments. */
|
||||||
QStringList Rshare::_files; /**< List of files passed by arguments. */
|
QStringList Rshare::_files; /**< List of files passed by arguments. */
|
||||||
QDateTime Rshare::mStartupTime;
|
QDateTime Rshare::mStartupTime;
|
||||||
@ -425,35 +430,45 @@ Rshare::showUsageMessageBox()
|
|||||||
tcol(tr("Resets ALL stored RetroShare settings.")));
|
tcol(tr("Resets ALL stored RetroShare settings.")));
|
||||||
out << trow(tcol("-" ARG_DATADIR" <dir>") +
|
out << trow(tcol("-" ARG_DATADIR" <dir>") +
|
||||||
tcol(tr("Sets the directory RetroShare uses for data files.")));
|
tcol(tr("Sets the directory RetroShare uses for data files.")));
|
||||||
out << trow(tcol("-" ARG_LOGFILE" <file>") +
|
out << trow(tcol("-" ARG_LOGFILE" <" + tr("filename") + ">") +
|
||||||
tcol(tr("Sets the name and location of RetroShare's logfile.")));
|
tcol(tr("Sets the name and location of RetroShare's logfile.")));
|
||||||
out << trow(tcol("-" ARG_LOGLEVEL" <level>") +
|
out << trow(tcol("-" ARG_LOGLEVEL" <" + tr("level") + ">") +
|
||||||
tcol(tr("Sets the verbosity of RetroShare's logging.") +
|
tcol(tr("Sets the verbosity of RetroShare's logging.") +
|
||||||
"<br>[" + Log::logLevels().join("|") +"]"));
|
"<br>[" + Log::logLevels().join("|") +"]"));
|
||||||
out << trow(tcol("-" ARG_GUISTYLE" <style>") +
|
out << trow(tcol("-" ARG_GUISTYLE" <" + tr("style") +">") +
|
||||||
tcol(tr("Sets RetroShare's interface style.") +
|
tcol(tr("Sets RetroShare's interface style.") +
|
||||||
"<br>[" + QStyleFactory::keys().join("|") + "]"));
|
"<br>[" + QStyleFactory::keys().join("|") + "]"));
|
||||||
out << trow(tcol("-" ARG_GUISTYLESHEET" <stylesheet>") +
|
out << trow(tcol("-" ARG_GUISTYLESHEET" <" + tr("stylesheet") + ">") +
|
||||||
tcol(tr("Sets RetroShare's interface stylesheets.")));
|
tcol(tr("Sets RetroShare's interface stylesheets.")));
|
||||||
out << trow(tcol("-" ARG_LANGUAGE" <language>") +
|
out << trow(tcol("-" ARG_LANGUAGE" <" + tr("language") + ">") +
|
||||||
tcol(tr("Sets RetroShare's language.") +
|
tcol(tr("Sets RetroShare's language.") +
|
||||||
"<br>[" + LanguageSupport::languageCodes().join("|") + "]"));
|
"<br>[" + LanguageSupport::languageCodes().join("|") + "]"));
|
||||||
|
out << trow(tcol("--" ARG_OPMODE_L" <" + tr("opmode") + ">") +
|
||||||
|
tcol(tr("Sets RetroShare's operating mode.") +
|
||||||
|
"<br>[full|noturtle|gaming|minimal]"));
|
||||||
|
out << trow(tcol("-" ARG_RSLINK_L" <" + tr("RsLinkURL") + ">") +
|
||||||
|
tcol(tr("Open RsLink with protocol retroshare://")));
|
||||||
|
out << trow(tcol("-" ARG_RSFILE_L" <" + tr("filename") + ">") +
|
||||||
|
tcol(tr("Open RsFile with or without arg.")));
|
||||||
out << "</table>";
|
out << "</table>";
|
||||||
|
|
||||||
VMessageBox::information(0,
|
VMessageBox::information(0,
|
||||||
tr("RetroShare Usage Information"), usage, VMessageBox::Ok);
|
tr("RetroShare GUI Usage Information"), usage, VMessageBox::Ok);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns true if the specified argument expects a value. */
|
/** Returns true if the specified argument expects a value. */
|
||||||
bool
|
bool
|
||||||
Rshare::argNeedsValue(QString argName)
|
Rshare::argNeedsValue(QString argName)
|
||||||
{
|
{
|
||||||
return (argName == ARG_GUISTYLE ||
|
return (
|
||||||
argName == ARG_GUISTYLESHEET ||
|
|
||||||
argName == ARG_LANGUAGE ||
|
|
||||||
argName == ARG_DATADIR ||
|
argName == ARG_DATADIR ||
|
||||||
argName == ARG_LOGFILE ||
|
argName == ARG_LOGFILE ||
|
||||||
argName == ARG_LOGLEVEL ||
|
argName == ARG_LOGLEVEL ||
|
||||||
|
argName == ARG_GUISTYLE ||
|
||||||
|
argName == ARG_GUISTYLESHEET ||
|
||||||
|
argName == ARG_LANGUAGE ||
|
||||||
|
argName == ARG_OPMODE_S ||
|
||||||
|
argName == ARG_OPMODE_L ||
|
||||||
argName == ARG_RSLINK_S ||
|
argName == ARG_RSLINK_S ||
|
||||||
argName == ARG_RSLINK_L ||
|
argName == ARG_RSLINK_L ||
|
||||||
argName == ARG_RSFILE_S ||
|
argName == ARG_RSFILE_S ||
|
||||||
@ -494,6 +509,14 @@ Rshare::parseArguments(QStringList args, bool firstRun)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* handle opmode that could be change while running.*/
|
||||||
|
QString omValue = QString(value).prepend(";").append(";").toLower();
|
||||||
|
QString omValues = QString(";full;noturtle;gaming;minimal;");
|
||||||
|
if ((arg == ARG_OPMODE_S || arg == ARG_OPMODE_L ) &&
|
||||||
|
omValues.contains(omValue)) {
|
||||||
|
_opmode = value;
|
||||||
|
}
|
||||||
|
|
||||||
/* Don't send theses argument to _args map to allow multiple. */
|
/* Don't send theses argument to _args map to allow multiple. */
|
||||||
if (arg == ARG_RSLINK_S || arg == ARG_RSLINK_L) {
|
if (arg == ARG_RSLINK_S || arg == ARG_RSLINK_L) {
|
||||||
_links.append(value);
|
_links.append(value);
|
||||||
@ -510,10 +533,17 @@ Rshare::parseArguments(QStringList args, bool firstRun)
|
|||||||
bool
|
bool
|
||||||
Rshare::validateArguments(QString &errmsg)
|
Rshare::validateArguments(QString &errmsg)
|
||||||
{
|
{
|
||||||
/* Check for a language that Retroshare recognizes. */
|
/* Check for a writable log file */
|
||||||
if (_args.contains(ARG_LANGUAGE) &&
|
if (_args.contains(ARG_LOGFILE) && !_log.isOpen()) {
|
||||||
!LanguageSupport::isValidLanguageCode(_args.value(ARG_LANGUAGE))) {
|
errmsg = tr("Unable to open log file '%1': %2")
|
||||||
errmsg = tr("Invalid language code specified:")+" " + _args.value(ARG_LANGUAGE);
|
.arg(_args.value(ARG_LOGFILE))
|
||||||
|
.arg(_log.errorString());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
/* Check for a valid log level */
|
||||||
|
if (_args.contains(ARG_LOGLEVEL) &&
|
||||||
|
!Log::logLevels().contains(_args.value(ARG_LOGLEVEL))) {
|
||||||
|
errmsg = tr("Invalid log level specified:")+" " + _args.value(ARG_LOGLEVEL);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
/* Check for a valid GUI style */
|
/* Check for a valid GUI style */
|
||||||
@ -523,17 +553,22 @@ Rshare::validateArguments(QString &errmsg)
|
|||||||
errmsg = tr("Invalid GUI style specified:")+" " + _args.value(ARG_GUISTYLE);
|
errmsg = tr("Invalid GUI style specified:")+" " + _args.value(ARG_GUISTYLE);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
/* Check for a valid log level */
|
/* Check for a language that Retroshare recognizes. */
|
||||||
if (_args.contains(ARG_LOGLEVEL) &&
|
if (_args.contains(ARG_LANGUAGE) &&
|
||||||
!Log::logLevels().contains(_args.value(ARG_LOGLEVEL))) {
|
!LanguageSupport::isValidLanguageCode(_args.value(ARG_LANGUAGE))) {
|
||||||
errmsg = tr("Invalid log level specified:")+" " + _args.value(ARG_LOGLEVEL);
|
errmsg = tr("Invalid language code specified:")+" " + _args.value(ARG_LANGUAGE);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
/* Check for a writable log file */
|
/* Check for an opmode that Retroshare recognizes. */
|
||||||
if (_args.contains(ARG_LOGFILE) && !_log.isOpen()) {
|
if (_args.contains(ARG_OPMODE_S) &&
|
||||||
errmsg = tr("Unable to open log file '%1': %2")
|
!QString(";full;noturtle;gaming;minimal;").contains(QString(_args.value(ARG_OPMODE_S)).prepend(";").append(";").toLower())) {
|
||||||
.arg(_args.value(ARG_LOGFILE))
|
errmsg = tr("Invalid operating mode specified:")+" " + _args.value(ARG_OPMODE_S);
|
||||||
.arg(_log.errorString());
|
return false;
|
||||||
|
}
|
||||||
|
/* Check for an opmode that Retroshare recognizes. */
|
||||||
|
if (_args.contains(ARG_OPMODE_L) &&
|
||||||
|
!QString(";full;noturtle;gaming;minimal;").contains(QString(_args.value(ARG_OPMODE_L)).prepend(";").append(";").toLower())) {
|
||||||
|
errmsg = tr("Invalid operating mode specified:")+" " + _args.value(ARG_OPMODE_L);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -107,12 +107,14 @@ public:
|
|||||||
/** Initialize plugins. */
|
/** Initialize plugins. */
|
||||||
static void initPlugins();
|
static void initPlugins();
|
||||||
|
|
||||||
/** Returns the current language. */
|
|
||||||
static QString language() { return _language; }
|
|
||||||
/** Returns the current GUI style. */
|
/** Returns the current GUI style. */
|
||||||
static QString style() { return _style; }
|
static QString style() { return _style; }
|
||||||
/** Returns the current GUI stylesheet. */
|
/** Returns the current GUI stylesheet. */
|
||||||
static QString stylesheet() { return _stylesheet; }
|
static QString stylesheet() { return _stylesheet; }
|
||||||
|
/** Returns the current language. */
|
||||||
|
static QString language() { return _language; }
|
||||||
|
/** Returns the operating mode. */
|
||||||
|
static QString opmode() { return _opmode; }
|
||||||
/** Returns links passed by arguments. */
|
/** Returns links passed by arguments. */
|
||||||
static QStringList* links() { return &_links; }
|
static QStringList* links() { return &_links; }
|
||||||
/** Returns files passed by arguments. */
|
/** Returns files passed by arguments. */
|
||||||
@ -181,11 +183,12 @@ private:
|
|||||||
static bool argNeedsValue(QString argName);
|
static bool argNeedsValue(QString argName);
|
||||||
|
|
||||||
static QMap<QString, QString> _args; /**< List of command-line arguments. */
|
static QMap<QString, QString> _args; /**< List of command-line arguments. */
|
||||||
|
static Log _log; /**< Logs debugging messages to file or stdout. */
|
||||||
static QString _style; /**< The current GUI style. */
|
static QString _style; /**< The current GUI style. */
|
||||||
static QString _stylesheet; /**< The current GUI stylesheet. */
|
static QString _stylesheet; /**< The current GUI stylesheet. */
|
||||||
static QString _language; /**< The current language. */
|
static QString _language; /**< The current language. */
|
||||||
static QString _dateformat; /**< The format for dates in feed items etc. */
|
static QString _dateformat; /**< The format for dates in feed items etc. */
|
||||||
static Log _log; /**< Logs debugging messages to file or stdout. */
|
static QString _opmode; /**< The operating mode passed by args. */
|
||||||
static QStringList _links; /**< List of links passed by arguments. */
|
static QStringList _links; /**< List of links passed by arguments. */
|
||||||
static QStringList _files; /**< List of files passed by arguments. */
|
static QStringList _files; /**< List of files passed by arguments. */
|
||||||
static QDateTime mStartupTime; // startup time
|
static QDateTime mStartupTime; // startup time
|
||||||
|
Loading…
Reference in New Issue
Block a user