mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-11 23:49:38 -05:00
Merge pull request #2783 from csoler/v0.6-BugFixing_30
cleaning up webui/jsonapi interaction code
This commit is contained in:
commit
b30b575955
@ -64,9 +64,18 @@ JsonApiPage::JsonApiPage(QWidget */*parent*/, Qt::WindowFlags /*flags*/)
|
||||
|
||||
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 );
|
||||
},
|
||||
mEventHandlerId, RsEventType::JSON_API );
|
||||
|
@ -142,6 +142,8 @@ void WebuiPage::loadParams()
|
||||
|
||||
if(it != smap.end())
|
||||
whileBlocking(ui.password_LE)->setText(QString::fromStdString(it->second));
|
||||
else
|
||||
whileBlocking(ui.enableWebUI_CB)->setChecked(false);
|
||||
|
||||
if(rsWebUi->isRunning())
|
||||
ui.statusLabelLED->setPixmap(FilesDefs::getPixmapFromQtResourcePath(IMAGE_LEDON)) ;
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
#include "util/stacktrace.h"
|
||||
#include "util/argstream.h"
|
||||
#include "retroshare/rswebui.h"
|
||||
|
||||
CrashStackTrace gCrashStackTrace;
|
||||
|
||||
@ -380,7 +381,7 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO);
|
||||
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);
|
||||
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.
|
||||
|
||||
#ifdef RS_JSONAPI
|
||||
JsonApiPage::checkStartJsonApi();
|
||||
// Read webui params in settings. We cannot save them to some webui.cfg because cfg needs the node id and
|
||||
// jsonapi is started before node ID selection in retroshare-service.
|
||||
|
||||
#ifdef RS_JSONAPI
|
||||
#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 // RS_JSONAPI
|
||||
|
||||
/* dive into the endless loop */
|
||||
int ti = rshare.exec();
|
||||
|
@ -247,7 +247,7 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
}
|
||||
#ifdef RS_SERVICE_TERMINAL_WEBUI_PASSWORD
|
||||
if(!webui_pass1.empty())
|
||||
if(askWebUiPassword && !webui_pass1.empty())
|
||||
{
|
||||
rsWebUi->setHtmlFilesDirectory(webui_base_directory);
|
||||
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);
|
||||
|
||||
#ifdef RS_JSONAPI
|
||||
RsInit::startupWebServices(conf);
|
||||
rstime::rs_usleep(1000000); // waits for jas->restart to print stuff
|
||||
#endif
|
||||
|
||||
if(initResult != RS_INIT_OK)
|
||||
{
|
||||
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 + ")" )
|
||||
<< std::endl;
|
||||
|
||||
uint32_t nacc = 0;
|
||||
std::cout << std::endl;
|
||||
uint32_t nacc = 0;
|
||||
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::string inputStr;
|
||||
|
Loading…
Reference in New Issue
Block a user