mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-13 16:45:49 -04:00
Merge pull request #2783 from csoler/v0.6-BugFixing_30
cleaning up webui/jsonapi interaction code
This commit is contained in:
commit
b30b575955
4 changed files with 33 additions and 10 deletions
|
@ -64,9 +64,18 @@ JsonApiPage::JsonApiPage(QWidget */*parent*/, Qt::WindowFlags /*flags*/)
|
||||||
|
|
||||||
mEventHandlerId = 0;
|
mEventHandlerId = 0;
|
||||||
|
|
||||||
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> /* event */)
|
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> e)
|
||||||
{
|
{
|
||||||
std::cerr << "Caught JSONAPI event!" << std::endl;
|
if(e->mType != RsEventType::JSON_API)
|
||||||
|
return;
|
||||||
|
|
||||||
|
auto je = dynamic_cast<const RsJsonApiEvent*>(e.get());
|
||||||
|
|
||||||
|
if(!je)
|
||||||
|
return;
|
||||||
|
|
||||||
|
std::cerr << "Caught JSONAPI event! code=" << static_cast<int>(je->mJsonApiEventCode) << std::endl;
|
||||||
|
|
||||||
RsQThreadUtils::postToObject([=]() { load(); }, this );
|
RsQThreadUtils::postToObject([=]() { load(); }, this );
|
||||||
},
|
},
|
||||||
mEventHandlerId, RsEventType::JSON_API );
|
mEventHandlerId, RsEventType::JSON_API );
|
||||||
|
|
|
@ -142,6 +142,8 @@ void WebuiPage::loadParams()
|
||||||
|
|
||||||
if(it != smap.end())
|
if(it != smap.end())
|
||||||
whileBlocking(ui.password_LE)->setText(QString::fromStdString(it->second));
|
whileBlocking(ui.password_LE)->setText(QString::fromStdString(it->second));
|
||||||
|
else
|
||||||
|
whileBlocking(ui.enableWebUI_CB)->setChecked(false);
|
||||||
|
|
||||||
if(rsWebUi->isRunning())
|
if(rsWebUi->isRunning())
|
||||||
ui.statusLabelLED->setPixmap(FilesDefs::getPixmapFromQtResourcePath(IMAGE_LEDON)) ;
|
ui.statusLabelLED->setPixmap(FilesDefs::getPixmapFromQtResourcePath(IMAGE_LEDON)) ;
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
|
|
||||||
#include "util/stacktrace.h"
|
#include "util/stacktrace.h"
|
||||||
#include "util/argstream.h"
|
#include "util/argstream.h"
|
||||||
|
#include "retroshare/rswebui.h"
|
||||||
|
|
||||||
CrashStackTrace gCrashStackTrace;
|
CrashStackTrace gCrashStackTrace;
|
||||||
|
|
||||||
|
@ -380,7 +381,7 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* recreate global settings object, now with correct path */
|
/* recreate global settings object, now with correct path, specific to the selected node */
|
||||||
RshareSettings::Create(true);
|
RshareSettings::Create(true);
|
||||||
Rshare::resetLanguageAndStyle();
|
Rshare::resetLanguageAndStyle();
|
||||||
|
|
||||||
|
@ -571,13 +572,18 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO);
|
||||||
|
|
||||||
notify->enable() ; // enable notification system after GUI creation, to avoid data races in Qt.
|
notify->enable() ; // enable notification system after GUI creation, to avoid data races in Qt.
|
||||||
|
|
||||||
#ifdef RS_JSONAPI
|
// Read webui params in settings. We cannot save them to some webui.cfg because cfg needs the node id and
|
||||||
JsonApiPage::checkStartJsonApi();
|
// jsonapi is started before node ID selection in retroshare-service.
|
||||||
|
|
||||||
|
#ifdef RS_JSONAPI
|
||||||
#ifdef RS_WEBUI
|
#ifdef RS_WEBUI
|
||||||
WebuiPage::checkStartWebui(); // normally we should rather save the UI flags internally to p3webui
|
conf.enableWebUI = Settings->getWebinterfaceEnabled();
|
||||||
|
|
||||||
|
if(!Settings->getWebinterfaceFilesDirectory().isNull())
|
||||||
|
rsWebUi->setHtmlFilesDirectory(Settings->getWebinterfaceFilesDirectory().toStdString());
|
||||||
|
#endif
|
||||||
|
RsInit::startupWebServices(conf);
|
||||||
#endif
|
#endif
|
||||||
#endif // RS_JSONAPI
|
|
||||||
|
|
||||||
/* dive into the endless loop */
|
/* dive into the endless loop */
|
||||||
int ti = rshare.exec();
|
int ti = rshare.exec();
|
||||||
|
|
|
@ -247,7 +247,7 @@ int main(int argc, char* argv[])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef RS_SERVICE_TERMINAL_WEBUI_PASSWORD
|
#ifdef RS_SERVICE_TERMINAL_WEBUI_PASSWORD
|
||||||
if(!webui_pass1.empty())
|
if(askWebUiPassword && !webui_pass1.empty())
|
||||||
{
|
{
|
||||||
rsWebUi->setHtmlFilesDirectory(webui_base_directory);
|
rsWebUi->setHtmlFilesDirectory(webui_base_directory);
|
||||||
conf.webUIPasswd = webui_pass1; // cannot be set using rsWebUI methods because it calls the still non-existent rsJsonApi
|
conf.webUIPasswd = webui_pass1; // cannot be set using rsWebUI methods because it calls the still non-existent rsJsonApi
|
||||||
|
@ -263,6 +263,11 @@ int main(int argc, char* argv[])
|
||||||
|
|
||||||
int initResult = RsInit::InitRetroShare(conf);
|
int initResult = RsInit::InitRetroShare(conf);
|
||||||
|
|
||||||
|
#ifdef RS_JSONAPI
|
||||||
|
RsInit::startupWebServices(conf);
|
||||||
|
rstime::rs_usleep(1000000); // waits for jas->restart to print stuff
|
||||||
|
#endif
|
||||||
|
|
||||||
if(initResult != RS_INIT_OK)
|
if(initResult != RS_INIT_OK)
|
||||||
{
|
{
|
||||||
RsFatal() << "Retroshare core initalization failed with: " << initResult
|
RsFatal() << "Retroshare core initalization failed with: " << initResult
|
||||||
|
@ -296,10 +301,11 @@ int main(int argc, char* argv[])
|
||||||
<< colored(COLOR_PURPLE,locations[i].mPgpName + " (" + locations[i].mLocationName + ")" )
|
<< colored(COLOR_PURPLE,locations[i].mPgpName + " (" + locations[i].mLocationName + ")" )
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
|
std::cout << std::endl;
|
||||||
uint32_t nacc = 0;
|
uint32_t nacc = 0;
|
||||||
while(keepRunning && (nacc < 1 || nacc >= locations.size()))
|
while(keepRunning && (nacc < 1 || nacc >= locations.size()))
|
||||||
{
|
{
|
||||||
std::cout << colored(COLOR_GREEN,"Please enter account number:\n");
|
std::cout << colored(COLOR_GREEN,"Please enter account number: ");
|
||||||
std::cout.flush();
|
std::cout.flush();
|
||||||
|
|
||||||
std::string inputStr;
|
std::string inputStr;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue