mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-01 10:46:23 -04:00
fixes required by review of pr1700
This commit is contained in:
parent
5223ff751a
commit
7aa51423a4
13 changed files with 98 additions and 154 deletions
|
@ -122,35 +122,10 @@ bool JsonApiPage::checkStartJsonApi()
|
|||
|
||||
/*static*/ void JsonApiPage::checkShutdownJsonApi()
|
||||
{
|
||||
if(RsJsonAPI::JSONAPI_STATUS_RUNNING != rsJsonAPI->status())
|
||||
if(!rsJsonAPI->isRunning())
|
||||
return;
|
||||
|
||||
rsJsonAPI->stop(); // this is a blocking call until the thread is terminated.
|
||||
|
||||
#ifdef SUSPENDED_CODE
|
||||
/* It is important to make a copy of +jsonApiServer+ pointer so the old
|
||||
* object can be deleted later, while the original pointer is
|
||||
* reassigned */
|
||||
|
||||
QProgressDialog* pd = new QProgressDialog("Stopping JSON API Server", QString(), 0, 3000);
|
||||
QTimer* prtm = new QTimer;
|
||||
prtm->setInterval(16); // 60 FPS
|
||||
connect( prtm, &QTimer::timeout,
|
||||
pd, [=](){pd->setValue(pd->value()+16);} );
|
||||
pd->show();
|
||||
prtm->start();
|
||||
|
||||
/* Must wait for deletion because stopping of the server is async.
|
||||
* It is important to capture a copy so it "survive" after
|
||||
* safeStopJsonApiServer returns */
|
||||
QTimer::singleShot(3*1000, [=]()
|
||||
{
|
||||
prtm->stop();
|
||||
pd->close();
|
||||
prtm->deleteLater();
|
||||
pd->deleteLater();
|
||||
});
|
||||
#endif
|
||||
}
|
||||
|
||||
void JsonApiPage::onApplyClicked()
|
||||
|
|
|
@ -74,8 +74,6 @@ bool WebuiPage::updateParams(QString &errmsg)
|
|||
bool changed = false;
|
||||
if(ui.enableWebUI_CB->isChecked() != Settings->getWebinterfaceEnabled())
|
||||
changed = true;
|
||||
if(ui.allIp_CB->isChecked() != Settings->getWebinterfaceAllowAllIps())
|
||||
changed = true;
|
||||
if(ui.webInterfaceFiles_LE->text() != Settings->getWebinterfaceFilesDirectory())
|
||||
changed = true;
|
||||
|
||||
|
@ -83,7 +81,6 @@ bool WebuiPage::updateParams(QString &errmsg)
|
|||
{
|
||||
// store config
|
||||
Settings->setWebinterfaceEnabled(ui.enableWebUI_CB->isChecked());
|
||||
Settings->setWebinterfaceAllowAllIps(ui.allIp_CB->isChecked());
|
||||
Settings->setWebinterfaceFilesDirectory(ui.webInterfaceFiles_LE->text());
|
||||
}
|
||||
return ok;
|
||||
|
@ -118,7 +115,6 @@ void WebuiPage::load()
|
|||
std::cerr << "WebuiPage::load()" << std::endl;
|
||||
whileBlocking(ui.enableWebUI_CB)->setChecked(Settings->getWebinterfaceEnabled());
|
||||
whileBlocking(ui.webInterfaceFiles_LE)->setText(Settings->getWebinterfaceFilesDirectory());
|
||||
whileBlocking(ui.allIp_CB)->setChecked(Settings->getWebinterfaceAllowAllIps());
|
||||
|
||||
#ifdef RS_JSONAPI
|
||||
auto smap = rsJsonAPI->getAuthorizedTokens();
|
||||
|
@ -157,7 +153,7 @@ QString WebuiPage::helpText() const
|
|||
{
|
||||
if(Settings->getWebinterfaceEnabled())
|
||||
{
|
||||
QDesktopServices::openUrl(QUrl(QString("http://localhost:")+QString::number(Settings->getWebinterfacePort())));
|
||||
QDesktopServices::openUrl(QUrl(QString("http://localhost:")+QString::number(rsJsonAPI->listeningPort())));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -1167,26 +1167,6 @@ void RshareSettings::setWebinterfaceFilesDirectory(const QString& s)
|
|||
}
|
||||
|
||||
|
||||
uint16_t RshareSettings::getWebinterfacePort()
|
||||
{
|
||||
return valueFromGroup("Webinterface", "port", 1984).toUInt();
|
||||
}
|
||||
|
||||
void RshareSettings::setWebinterfacePort(uint16_t port)
|
||||
{
|
||||
setValueToGroup("Webinterface", "port", port);
|
||||
}
|
||||
|
||||
bool RshareSettings::getWebinterfaceAllowAllIps()
|
||||
{
|
||||
return valueFromGroup("Webinterface", "allowAllIps", false).toBool();
|
||||
}
|
||||
|
||||
void RshareSettings::setWebinterfaceAllowAllIps(bool allow_all)
|
||||
{
|
||||
setValueToGroup("Webinterface", "allowAllIps", allow_all);
|
||||
}
|
||||
|
||||
bool RshareSettings::getPageAlreadyDisplayed(const QString& page_name)
|
||||
{
|
||||
return valueFromGroup("PageAlreadyDisplayed",page_name,false).toBool();
|
||||
|
|
|
@ -331,15 +331,9 @@ public:
|
|||
bool getWebinterfaceEnabled();
|
||||
void setWebinterfaceEnabled(bool enabled);
|
||||
|
||||
uint16_t getWebinterfacePort();
|
||||
void setWebinterfacePort(uint16_t port);
|
||||
|
||||
QString getWebinterfaceFilesDirectory();
|
||||
void setWebinterfaceFilesDirectory(const QString& dirname);
|
||||
|
||||
bool getWebinterfaceAllowAllIps();
|
||||
void setWebinterfaceAllowAllIps(bool allow_all);
|
||||
|
||||
// proxy function that computes the best icon size among sizes passed as array, to match the recommended size on screen.
|
||||
int computeBestIconSize(int n_sizes, int *sizes, int recommended_size);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue