Moved #ifdef RS_WEBUI inside RS_JSONAPI ifdefs so that the webui files cannot be requested unless jsonapi files are compiled

This commit is contained in:
csoler 2019-11-27 21:14:20 +01:00
parent 50529654f8
commit 9a24af87a4
No known key found for this signature in database
GPG Key ID: 7BCA522266C0804C
8 changed files with 32 additions and 17 deletions

View File

@ -61,7 +61,6 @@
#include "gxstunnel/p3gxstunnel.h"
#include "retroshare/rsgxsdistsync.h"
#include "file_sharing/p3filelists.h"
#include "jsonapi/jsonapi.h"
#define ENABLE_GROUTER
@ -97,6 +96,10 @@ RsDht *rsDht = NULL ;
#ifdef RS_JSONAPI
# include "jsonapi/jsonapi.h"
#ifdef RS_WEBUI
#include "jsonapi/jsonapi.h"
#endif
#endif
#ifdef RS_BROADCAST_DISCOVERY

View File

@ -23,7 +23,9 @@
#include "HelpDialog.h"
#include "rshare.h"
#ifdef RS_JSONAPI
#include "restbed"
#endif
#include <retroshare/rsiface.h>
#include <retroshare/rsplugin.h>
@ -970,13 +972,13 @@ void AboutWidget::on_copy_button_clicked()
RsControl::instance()->getLibraries(libraries);
verInfo+=addLibraries("libretroshare", libraries);
// #ifdef RS_WEBUI
// /* Add version numbers of RetroShare */
// // Add versions here. Find a better place.
// libraries.clear();
// libraries.push_back(RsLibraryInfo("RestBed", restbed::get_version()));
// verInfo+=addLibraries("RetroShare", libraries);
// #endif
#ifdef RS_JSONAPI
/* Add version numbers of RetroShare */
// Add versions here. Find a better place.
libraries.clear();
libraries.push_back(RsLibraryInfo("RestBed", restbed::get_version()));
verInfo+=addLibraries("RetroShare", libraries);
#endif
/* Add version numbers of plugins */
if (rsPlugins) {

View File

@ -606,8 +606,10 @@ void MainWindow::createTrayIcon()
trayMenu->addAction(QIcon(IMAGE_MESSENGER), tr("Open Messenger"), this, SLOT(showMessengerWindow()));
#endif
trayMenu->addAction(QIcon(IMAGE_MESSAGES), tr("Open Messages"), this, SLOT(showMess()));
#ifdef RS_JSONAPI
#ifdef RS_WEBUI
trayMenu->addAction(QIcon(":/images/emblem-web.png"), tr("Show web interface"), this, SLOT(showWebinterface()));
#endif
#endif
trayMenu->addAction(QIcon(IMAGE_BWGRAPH), tr("Bandwidth Graph"), this, SLOT(showBandwidthGraph()));
trayMenu->addAction(QIcon(IMAGE_STATS), tr("Statistics"), this, SLOT(showStatisticsWindow()));
@ -1117,12 +1119,14 @@ void MainWindow::showStatisticsWindow()
StatisticsWindow::showYourself();
}
#ifdef RS_JSONAPI
#ifdef RS_WEBUI
void MainWindow::showWebinterface()
{
WebuiPage::showWebui();
}
#endif // ENABLE_WEBUI
#endif
/** Shows Application window */
#ifdef UNFINISHED

View File

@ -230,8 +230,10 @@ private slots:
void showMessengerWindow();
#endif
void showStatisticsWindow();
#ifdef RS_JSONAPI
#ifdef RS_WEBUI
void showWebinterface();
#endif
#endif
//void servicePermission();

View File

@ -30,8 +30,9 @@
#include "rsharesettings.h"
#include "gui/MainWindow.h"
// for this one, we'd rather use a file in retroshare/*h list.
#include <jsonapi/jsonapi.h>
#ifdef RS_JSONAPI
#include <retroshare/rsjsonapi.h>
#endif
#include <retroshare/rsnotify.h>
#include <retroshare/rspeers.h>

View File

@ -574,11 +574,11 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO);
#ifdef RS_JSONAPI
JsonApiPage::checkStartJsonApi();
#endif // RS_JSONAPI
#ifdef RS_WEBUI
WebuiPage::checkStartWebui(); // normally we should rather save the UI flags internally to p3webui
#endif
#endif // RS_JSONAPI
// This is done using a timer, because the passphrase request from notify is asynchrouneous and therefore clearing the
// passphrase here makes it request for a passphrase when creating the default chat identity.

View File

@ -31,10 +31,12 @@ INCLUDEPATH *= $${PWD} retroshare-gui
!include("../../libretroshare/src/use_libretroshare.pri"):error("Including")
rs_webui {
rs_jsonapi {
HEADERS *= gui/settings/WebuiPage.h
SOURCES *= gui/settings/WebuiPage.cpp
FORMS *= gui/settings/WebuiPage.ui
}
}
rs_jsonapi {
HEADERS *= gui/settings/JsonApiPage.h

View File

@ -23,11 +23,11 @@
#ifdef RS_JSONAPI
#include "retroshare/rsjsonapi.h"
#endif
#ifdef RS_WEBUI
#include "retroshare/rswebui.h"
#endif
#endif
static CrashStackTrace gCrashStackTrace;
@ -124,10 +124,11 @@ int main(int argc, char* argv[])
std::string prefUserString;
RsConfigOptions conf;
std::string webui_base_directory = RsWebUi::DEFAULT_BASE_DIRECTORY;
#ifdef RS_JSONAPI
conf.jsonApiPort = RsJsonApi::DEFAULT_PORT; // enable JSonAPI by default
#ifdef RS_WEBUI
std::string webui_base_directory = RsWebUi::DEFAULT_BASE_DIRECTORY;
#endif
#endif
argstream as(argc,argv);
@ -164,7 +165,7 @@ int main(int argc, char* argv[])
"127.0.0.1.", false );
#endif // def RS_JSONAPI
#if (defined(RS_JSONAPI) || defined(RS_WEBUI)) && defined(RS_SERVICE_TERMINAL_WEBUI_PASSWORD)
#if (defined(RS_JSONAPI) && defined(RS_WEBUI)) && defined(RS_SERVICE_TERMINAL_WEBUI_PASSWORD)
bool askWebUiPassword = false;
as >> parameter( 'B', "webui-directory", webui_base_directory, "Place where to find the html/js files for the webui.",false );
as >> option( 'W', "webui-password", askWebUiPassword, "Ask WebUI password on the console." );
@ -185,7 +186,7 @@ int main(int argc, char* argv[])
as >> help( 'h', "help", "Display this Help" );
as.defaultErrorHandling(true, true);
#if (defined(RS_JSONAPI) || defined(RS_WEBUI)) && defined(RS_SERVICE_TERMINAL_WEBUI_PASSWORD)
#if (defined(RS_JSONAPI) && defined(RS_WEBUI)) && defined(RS_SERVICE_TERMINAL_WEBUI_PASSWORD)
std::string webui_pass1 = "Y";
if(askWebUiPassword)
{
@ -308,7 +309,7 @@ int main(int argc, char* argv[])
}
#endif // def RS_SERVICE_TERMINAL_LOGIN
#if (defined(RS_JSONAPI) || defined(RS_WEBUI)) && defined(RS_SERVICE_TERMINAL_WEBUI_PASSWORD)
#if (defined(RS_JSONAPI) && defined(RS_WEBUI)) && defined(RS_SERVICE_TERMINAL_WEBUI_PASSWORD)
if(rsJsonAPI && !webui_pass1.empty())
{
rsWebUI->setHtmlFilesDirectory(webui_base_directory);