allow RsControlModule to work without control over RsInit (e.g. with rs-gui)

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@8074 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
electron128 2015-03-25 08:31:19 +00:00
parent 74dd9f7b7b
commit cb6860a08d
3 changed files with 9 additions and 4 deletions

View File

@ -14,7 +14,7 @@
namespace resource_api{
RsControlModule::RsControlModule(int argc, char **argv, StateTokenServer* sts, ApiServer *apiserver):
RsControlModule::RsControlModule(int argc, char **argv, StateTokenServer* sts, ApiServer *apiserver, bool full_control):
mStateTokenServer(sts),
mApiServer(apiserver),
mExitFlagMtx("RsControlModule::mExitFlagMtx"),
@ -28,7 +28,10 @@ RsControlModule::RsControlModule(int argc, char **argv, StateTokenServer* sts, A
this->argc = argc;
this->argv = argv;
// start worker thread
start();
if(full_control)
start();
else
mRunState = RUNNING_OK;
addResourceHandler("runstate", this, &RsControlModule::handleRunState);
addResourceHandler("identities", this, &RsControlModule::handleIdentities);

View File

@ -24,7 +24,9 @@ class RsControlModule: public ResourceRouter, NotifyClient,
{
public:
// ApiServer will be called once RS is started, to load additional api modules
RsControlModule(int argc, char **argv, StateTokenServer* sts, ApiServer* apiserver);
// full_control: set to true if this module should handle rsinit and login
// set to false if rsinit is handled by the Qt gui
RsControlModule(int argc, char **argv, StateTokenServer* sts, ApiServer* apiserver, bool full_control);
~RsControlModule();
// returns true if the process should terminate

View File

@ -91,7 +91,7 @@ int main(int argc, char **argv)
{
resource_api::ApiServerMHD httpd(docroot, httpPort);
resource_api::RsControlModule ctrl_mod(argc, argv, httpd.getApiServer().getStateTokenServer(), &httpd.getApiServer());
resource_api::RsControlModule ctrl_mod(argc, argv, httpd.getApiServer().getStateTokenServer(), &httpd.getApiServer(), true);
httpd.getApiServer().addResourceHandler("control", dynamic_cast<resource_api::ResourceRouter*>(&ctrl_mod), &resource_api::RsControlModule::handleRequest);
httpd.start();