improved user commandline webui startup user experience

This commit is contained in:
csoler 2023-11-05 16:10:42 +01:00
parent 53313670f5
commit a64fda1fb8
2 changed files with 20 additions and 5 deletions

View File

@ -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 );

View File

@ -220,7 +220,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
@ -236,6 +236,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
@ -269,10 +274,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;