mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-02 06:06:10 -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
10 changed files with 143 additions and 44 deletions
|
@ -289,6 +289,7 @@ public:
|
|||
/* Operating Mode */
|
||||
virtual uint32_t getOperatingMode() = 0;
|
||||
virtual bool setOperatingMode(uint32_t opMode) = 0;
|
||||
virtual bool setOperatingMode(const std::string &opModeStr) = 0;
|
||||
|
||||
/* Data Rate Control - to be moved here */
|
||||
virtual int SetMaxDataRates( int downKb, int upKb ) = 0;
|
||||
|
|
|
@ -380,7 +380,7 @@ uint32_t p3ServerConfig::getOperatingMode()
|
|||
{
|
||||
mode = RS_OPMODE_GAMING;
|
||||
}
|
||||
else if (modestr == "MINIMAL_TRANSFER")
|
||||
else if (modestr == "MINIMAL")
|
||||
{
|
||||
mode = RS_OPMODE_MINIMAL;
|
||||
}
|
||||
|
@ -410,7 +410,7 @@ bool p3ServerConfig::setOperatingMode(uint32_t opMode)
|
|||
|
||||
break;
|
||||
case RS_OPMODE_MINIMAL:
|
||||
modestr = "MINIMAL_TRANSFER";
|
||||
modestr = "MINIMAL";
|
||||
break;
|
||||
}
|
||||
mGeneralConfig->setSetting(RS_CONFIG_OPERATING_STRING, modestr);
|
||||
|
@ -423,6 +423,31 @@ bool p3ServerConfig::setOperatingMode(uint32_t 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)
|
||||
{
|
||||
|
|
|
@ -91,6 +91,7 @@ virtual bool setConfigurationOption(uint32_t key, const std::string &opt);
|
|||
/* Operating Mode */
|
||||
virtual uint32_t getOperatingMode();
|
||||
virtual bool setOperatingMode(uint32_t opMode);
|
||||
virtual bool setOperatingMode(const std::string &opModeStr);
|
||||
|
||||
virtual int SetMaxDataRates( int downKb, int upKb );
|
||||
virtual int GetMaxDataRates( int &downKb, int &upKb );
|
||||
|
|
|
@ -138,6 +138,7 @@ class RsInitConfig
|
|||
std::string load_trustedpeer_file;
|
||||
|
||||
bool udpListenerOnly;
|
||||
std::string opModeStr;
|
||||
};
|
||||
|
||||
static RsInitConfig *rsInitConfig = NULL;
|
||||
|
@ -189,6 +190,7 @@ void RsInit::InitRsConfig()
|
|||
rsInitConfig->passwd = "";
|
||||
rsInitConfig->debugLevel = PQL_WARNING;
|
||||
rsInitConfig->udpListenerOnly = false;
|
||||
rsInitConfig->opModeStr = std::string("FULL");
|
||||
|
||||
/* setup the homePath (default save location) */
|
||||
// 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('d',"debug-level" ,rsInitConfig->debugLevel ,"level" ,"Set debug level." ,false)
|
||||
#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)
|
||||
#endif
|
||||
>> 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('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)
|
||||
|
@ -1733,6 +1735,10 @@ int RsServer::StartupRetroShare()
|
|||
mPeerMgr->forceHiddenNode();
|
||||
}
|
||||
|
||||
if (!rsInitConfig->opModeStr.empty())
|
||||
{
|
||||
rsConfig->setOperatingMode(rsInitConfig->opModeStr);
|
||||
}
|
||||
mNetMgr -> checkNetAddress();
|
||||
|
||||
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
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
|
@ -71,8 +71,8 @@ namespace
|
|||
private:
|
||||
std::string shortName_;
|
||||
std::string longName_;
|
||||
std::string valueName_;
|
||||
T* value_;
|
||||
std::string valueName_;
|
||||
T initialValue_;
|
||||
std::string description_;
|
||||
bool mandatory_;
|
||||
|
@ -282,8 +282,8 @@ namespace
|
|||
bool mandatory)
|
||||
: shortName_(1,s),
|
||||
longName_(l),
|
||||
valueName_(valueName),
|
||||
value_(&v),
|
||||
valueName_(valueName),
|
||||
initialValue_(v),
|
||||
description_(desc),
|
||||
mandatory_(mandatory)
|
||||
|
@ -296,8 +296,8 @@ namespace
|
|||
const char* desc,
|
||||
bool mandatory)
|
||||
: longName_(l),
|
||||
valueName_(valueName),
|
||||
value_(&v),
|
||||
valueName_(valueName),
|
||||
initialValue_(v),
|
||||
description_(desc),
|
||||
mandatory_(mandatory)
|
||||
|
@ -310,8 +310,8 @@ namespace
|
|||
const char* desc,
|
||||
bool mandatory)
|
||||
: shortName_(1,s),
|
||||
valueName_(valueName),
|
||||
value_(&v),
|
||||
valueName_(valueName),
|
||||
initialValue_(v),
|
||||
description_(desc),
|
||||
mandatory_(mandatory)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue