From 8e2d4e05cec7253f55c663ab80b6230a5a5eed91 Mon Sep 17 00:00:00 2001 From: Gio Date: Fri, 1 Jul 2016 10:18:42 +0200 Subject: [PATCH 01/22] Fix typo in libresapi documentation --- libresapi/src/api/ApiServerMHD.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libresapi/src/api/ApiServerMHD.cpp b/libresapi/src/api/ApiServerMHD.cpp index 2ee6af149..9522c66be 100644 --- a/libresapi/src/api/ApiServerMHD.cpp +++ b/libresapi/src/api/ApiServerMHD.cpp @@ -559,7 +559,7 @@ int ApiServerMHD::accessHandlerCallback(MHD_Connection *connection, return ((MHDHandlerBase*)(*con_cls))->handleRequest(connection, url, method, version, upload_data, upload_data_size); } - // these characters are not allowe in the url, raise an error if they occur + // these characters are not allowed in the url, raise an error if they occur // reason: don't want to serve files outside the current document root const char *double_dots = ".."; if(strstr(url, double_dots)) From 47414acb62a46de1f2c4454b454bacefa8c12c83 Mon Sep 17 00:00:00 2001 From: Gio Date: Tue, 5 Jul 2016 16:11:37 +0200 Subject: [PATCH 02/22] Basic support to access libresapi via unix socket / windows named pipes --- libresapi/src/api/ApiServerLocal.cpp | 74 +++++++++++++++++++ libresapi/src/api/ApiServerLocal.h | 58 +++++++++++++++ libresapi/src/api/ApiTypes.h | 27 +++++++ libresapi/src/libresapi.pro | 9 ++- retroshare-gui/src/gui/settings/WebuiPage.cpp | 7 ++ retroshare-gui/src/gui/settings/WebuiPage.h | 2 + 6 files changed, 174 insertions(+), 3 deletions(-) create mode 100644 libresapi/src/api/ApiServerLocal.cpp create mode 100644 libresapi/src/api/ApiServerLocal.h diff --git a/libresapi/src/api/ApiServerLocal.cpp b/libresapi/src/api/ApiServerLocal.cpp new file mode 100644 index 000000000..e951c2425 --- /dev/null +++ b/libresapi/src/api/ApiServerLocal.cpp @@ -0,0 +1,74 @@ +#include "ApiServerLocal.h" +#include "JsonStream.h" + +namespace resource_api{ + +ApiServerLocal::ApiServerLocal(ApiServer* server) : QThread(), + mApiServer(server), mLocalServer(this) +{ + start(); + mLocalServer.removeServer(serverName()); +#if QT_VERSION >= 0x050000 + mLocalServer.setSocketOptions(QLocalServer::UserAccessOption); +#endif + connect(&mLocalServer, SIGNAL(newConnection()), this, SLOT(handleConnection())); + mLocalServer.listen(serverName()); +} + +ApiServerLocal::~ApiServerLocal() +{ + mLocalServer.close(); + quit(); +} + +void ApiServerLocal::handleConnection() +{ + new ApiLocalConnectionHandler(mApiServer, mLocalServer.nextPendingConnection()); +} + +ApiLocalConnectionHandler::ApiLocalConnectionHandler(ApiServer* apiServer, QLocalSocket* sock) : + QThread(), mApiServer(apiServer), mLocalSocket(sock), mState(WAITING_PATH) +{ + sock->moveToThread(this); + connect(mLocalSocket, SIGNAL(disconnected()), this, SLOT(quit())); + connect(this, SIGNAL(finished()), this, SLOT(deleteLater())); + connect(sock, SIGNAL(readyRead()), this, SLOT(handleRequest())); + start(); +} + +void ApiLocalConnectionHandler::handleRequest() +{ + switch(mState) + { + case WAITING_PATH: + { + char path[1024]; + mLocalSocket->readLine(path, 1023); + reqPath = path; + mState = WAITING_DATA; + break; + } + case WAITING_DATA: + { + char jsonData[1024]; + mLocalSocket->read(jsonData, 1023); + resource_api::JsonStream reqJson; + reqJson.setJsonString(std::string(jsonData)); + resource_api::Request req(reqJson); + req.setPath(reqPath); + std::string resultString = mApiServer->handleRequest(req); + mLocalSocket->write(resultString.data(), resultString.length()); + mState = WAITING_PATH; + break; + } + } +} + +ApiLocalConnectionHandler::~ApiLocalConnectionHandler() +{ + mLocalSocket->close(); + delete mLocalSocket; +} + + +} // namespace resource_api diff --git a/libresapi/src/api/ApiServerLocal.h b/libresapi/src/api/ApiServerLocal.h new file mode 100644 index 000000000..3e8100453 --- /dev/null +++ b/libresapi/src/api/ApiServerLocal.h @@ -0,0 +1,58 @@ +#pragma once + +#include +#include +#include +#include +#include +#include + +#include "ApiServer.h" + +namespace resource_api +{ +class ApiServer; + +class ApiServerLocal : public QThread +{ + Q_OBJECT + +public: + ApiServerLocal(ApiServer* server); + ~ApiServerLocal(); + +public slots: + void handleConnection(); + +private: + ApiServer* mApiServer; + QLocalServer mLocalServer; + + const static QString& serverName() + { + const static QString sockPath(RsAccounts::AccountDirectory() + .append("/libresapi.sock").c_str()); + return sockPath; + } +}; + +class ApiLocalConnectionHandler : public QThread +{ + Q_OBJECT + +public: + ApiLocalConnectionHandler(ApiServer* apiServer, QLocalSocket* sock); + ~ApiLocalConnectionHandler(); + enum State {WAITING_PATH, WAITING_DATA}; + +public slots: + void handleRequest(); + +private: + ApiServer* mApiServer; + QLocalSocket* mLocalSocket; + State mState; + std::string reqPath; +}; + +} // namespace resource_api diff --git a/libresapi/src/api/ApiTypes.h b/libresapi/src/api/ApiTypes.h index ab34b4507..f5ab6094b 100644 --- a/libresapi/src/api/ApiTypes.h +++ b/libresapi/src/api/ApiTypes.h @@ -193,6 +193,33 @@ public: // then each handler should pop the top element std::stack mPath; std::string mFullPath; + bool setPath(std::string reqPath) + { + std::string str; + for(std::string::reverse_iterator sit = reqPath.rbegin(); sit != reqPath.rend(); sit++) + { + if((*sit) != '/') + { + // add to front because we are traveling in reverse order + str = *sit + str; + } + else + { + if(str != "") + { + mPath.push(str); + str.clear(); + } + } + } + if(str != "") + { + mPath.push(str); + } + mFullPath = reqPath; + + return true; + } // parameters should be used to influence the result // for example include or exclude some information diff --git a/libresapi/src/libresapi.pro b/libresapi/src/libresapi.pro index f83996ee1..01dd68ffb 100644 --- a/libresapi/src/libresapi.pro +++ b/libresapi/src/libresapi.pro @@ -3,7 +3,8 @@ TEMPLATE = lib CONFIG += staticlib CONFIG += create_prl -CONFIG -= qt +CONFIG += qt +QT += network TARGET = resapi TARGET_PRL = libresapi DESTDIR = lib @@ -146,7 +147,8 @@ SOURCES += \ api/TmpBlobStore.cpp \ util/ContentTypes.cpp \ api/ApiPluginHandler.cpp \ - api/ChannelsHandler.cpp + api/ChannelsHandler.cpp \ + api/ApiServerLocal.cpp HEADERS += \ api/ApiServer.h \ @@ -172,4 +174,5 @@ HEADERS += \ api/TmpBlobStore.h \ util/ContentTypes.h \ api/ApiPluginHandler.h \ - api/ChannelsHandler.h + api/ChannelsHandler.h \ + api/ApiServerLocal.h diff --git a/retroshare-gui/src/gui/settings/WebuiPage.cpp b/retroshare-gui/src/gui/settings/WebuiPage.cpp index b05bf8698..9a9f98a8f 100644 --- a/retroshare-gui/src/gui/settings/WebuiPage.cpp +++ b/retroshare-gui/src/gui/settings/WebuiPage.cpp @@ -7,6 +7,7 @@ #include "api/ApiServer.h" #include "api/ApiServerMHD.h" +#include "api/ApiServerLocal.h" #include "api/RsControlModule.h" #include "api/GetPluginInterfaces.h" @@ -14,6 +15,7 @@ resource_api::ApiServer* WebuiPage::apiServer = 0; resource_api::ApiServerMHD* WebuiPage::apiServerMHD = 0; +resource_api::ApiServerLocal* WebuiPage::apiServerLocal = 0; resource_api::RsControlModule* WebuiPage::controlModule = 0; WebuiPage::WebuiPage(QWidget */*parent*/, Qt::WindowFlags /*flags*/) @@ -92,6 +94,9 @@ QString WebuiPage::helpText() const "", Settings->getWebinterfaceAllowAllIps()); apiServerMHD->start(); + + apiServerLocal = new resource_api::ApiServerLocal(apiServer); + return ok; } @@ -102,6 +107,8 @@ QString WebuiPage::helpText() const apiServerMHD->stop(); delete apiServerMHD; apiServerMHD = 0; + delete apiServerLocal; + apiServerLocal = 0; delete apiServer; apiServer = 0; delete controlModule; diff --git a/retroshare-gui/src/gui/settings/WebuiPage.h b/retroshare-gui/src/gui/settings/WebuiPage.h index 67e9b0e40..879d26ee8 100644 --- a/retroshare-gui/src/gui/settings/WebuiPage.h +++ b/retroshare-gui/src/gui/settings/WebuiPage.h @@ -6,6 +6,7 @@ namespace resource_api{ class ApiServer; class ApiServerMHD; + class ApiServerLocal; class RsControlModule; } @@ -48,5 +49,6 @@ private: static resource_api::ApiServer* apiServer; static resource_api::ApiServerMHD* apiServerMHD; + static resource_api::ApiServerLocal* apiServerLocal; static resource_api::RsControlModule* controlModule; }; From b5f95cb6516baeb1ab442198496faa4f94958d8c Mon Sep 17 00:00:00 2001 From: Gio Date: Thu, 14 Jul 2016 22:48:44 +0200 Subject: [PATCH 03/22] libresapilocal is now optional (enabled by default) --- libresapi/src/libresapi.pro | 16 ++++++++++------ retroshare-gui/src/gui/settings/WebuiPage.cpp | 10 +++++++++- retroshare-gui/src/gui/settings/WebuiPage.h | 2 ++ retroshare.pri | 6 ++++++ 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/libresapi/src/libresapi.pro b/libresapi/src/libresapi.pro index 01dd68ffb..bf51989f8 100644 --- a/libresapi/src/libresapi.pro +++ b/libresapi/src/libresapi.pro @@ -3,8 +3,7 @@ TEMPLATE = lib CONFIG += staticlib CONFIG += create_prl -CONFIG += qt -QT += network +CONFIG -= qt TARGET = resapi TARGET_PRL = libresapi DESTDIR = lib @@ -147,8 +146,7 @@ SOURCES += \ api/TmpBlobStore.cpp \ util/ContentTypes.cpp \ api/ApiPluginHandler.cpp \ - api/ChannelsHandler.cpp \ - api/ApiServerLocal.cpp + api/ChannelsHandler.cpp HEADERS += \ api/ApiServer.h \ @@ -174,5 +172,11 @@ HEADERS += \ api/TmpBlobStore.h \ util/ContentTypes.h \ api/ApiPluginHandler.h \ - api/ChannelsHandler.h \ - api/ApiServerLocal.h + api/ChannelsHandler.h + +libresapilocalserver { + CONFIG *= qt + QT *= network + SOURCES *= api/ApiServerLocal.cpp + HEADERS *= api/ApiServerLocal.h +} diff --git a/retroshare-gui/src/gui/settings/WebuiPage.cpp b/retroshare-gui/src/gui/settings/WebuiPage.cpp index 9a9f98a8f..8e8c3498b 100644 --- a/retroshare-gui/src/gui/settings/WebuiPage.cpp +++ b/retroshare-gui/src/gui/settings/WebuiPage.cpp @@ -15,7 +15,10 @@ resource_api::ApiServer* WebuiPage::apiServer = 0; resource_api::ApiServerMHD* WebuiPage::apiServerMHD = 0; +// TODO: LIBRESAPI_LOCAL_SERVER Move in appropriate place +#ifdef LIBRESAPI_LOCAL_SERVER resource_api::ApiServerLocal* WebuiPage::apiServerLocal = 0; +#endif resource_api::RsControlModule* WebuiPage::controlModule = 0; WebuiPage::WebuiPage(QWidget */*parent*/, Qt::WindowFlags /*flags*/) @@ -95,8 +98,10 @@ QString WebuiPage::helpText() const Settings->getWebinterfaceAllowAllIps()); apiServerMHD->start(); +// TODO: LIBRESAPI_LOCAL_SERVER Move in appropriate place +#ifdef LIBRESAPI_LOCAL_SERVER apiServerLocal = new resource_api::ApiServerLocal(apiServer); - +#endif return ok; } @@ -107,8 +112,11 @@ QString WebuiPage::helpText() const apiServerMHD->stop(); delete apiServerMHD; apiServerMHD = 0; +// TODO: LIBRESAPI_LOCAL_SERVER Move in appropriate place +#ifdef LIBRESAPI_LOCAL_SERVER delete apiServerLocal; apiServerLocal = 0; +#endif delete apiServer; apiServer = 0; delete controlModule; diff --git a/retroshare-gui/src/gui/settings/WebuiPage.h b/retroshare-gui/src/gui/settings/WebuiPage.h index 879d26ee8..7da68c21d 100644 --- a/retroshare-gui/src/gui/settings/WebuiPage.h +++ b/retroshare-gui/src/gui/settings/WebuiPage.h @@ -49,6 +49,8 @@ private: static resource_api::ApiServer* apiServer; static resource_api::ApiServerMHD* apiServerMHD; + #ifdef LIBRESAPI_LOCAL_SERVER static resource_api::ApiServerLocal* apiServerLocal; + #endif static resource_api::RsControlModule* controlModule; }; diff --git a/retroshare.pri b/retroshare.pri index bdedd670a..76f68bbed 100644 --- a/retroshare.pri +++ b/retroshare.pri @@ -1,3 +1,7 @@ +# To {dis,en}able libresapi via local socket (unix domain socket or windows named pipes) +# {,un}comment the following line +CONFIG *= libresapilocalserver + # Gxs is always enabled now. DEFINES *= RS_ENABLE_GXS @@ -62,3 +66,5 @@ unfinished { } wikipoos:DEFINES *= RS_USE_WIKI + +libresapilocalserver:DEFINES *= LIBRESAPI_LOCAL_SERVER From 5e1ecf3ad132b238252e5ac212a831ff805b0c45 Mon Sep 17 00:00:00 2001 From: Gio Date: Mon, 18 Jul 2016 13:49:21 +0200 Subject: [PATCH 04/22] By default disable libresapilocalserver at compile time because it depends on Qt --- retroshare.pri | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/retroshare.pri b/retroshare.pri index 76f68bbed..827aa89fd 100644 --- a/retroshare.pri +++ b/retroshare.pri @@ -1,6 +1,6 @@ # To {dis,en}able libresapi via local socket (unix domain socket or windows named pipes) # {,un}comment the following line -CONFIG *= libresapilocalserver +#CONFIG *= libresapilocalserver # Gxs is always enabled now. DEFINES *= RS_ENABLE_GXS From b4a10749f40a8dc4270c01bf4e98767601c09a2f Mon Sep 17 00:00:00 2001 From: Gio Date: Mon, 18 Jul 2016 18:51:27 +0200 Subject: [PATCH 05/22] Disable stacktrace for android as execinfo.h is not available --- libretroshare/src/util/stacktrace.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libretroshare/src/util/stacktrace.h b/libretroshare/src/util/stacktrace.h index b535e34f9..2df273071 100644 --- a/libretroshare/src/util/stacktrace.h +++ b/libretroshare/src/util/stacktrace.h @@ -25,7 +25,7 @@ #include -#ifndef WINDOWS_SYS +#if !defined(WINDOWS_SYS) && !defined(__ANDROID__) #include #include @@ -110,13 +110,13 @@ static inline void print_stacktrace(FILE *out = stderr, unsigned int max_frames free(symbollist); } -#else // WINDOWS_SYS +#else // !defined(WINDOWS_SYS) && !defined(__ANDROID__) static inline void print_stacktrace(FILE *out = stderr, unsigned int max_frames = 63) { (void) max_frames; - fprintf(out, "TODO: 2016/01/01 print_stacktrace not implemented yet for WINDOWS_SYS\n"); + fprintf(out, "TODO: 2016/01/01 print_stacktrace not implemented yet for WINDOWS_SYS and ANDROID\n"); } -#endif // WINDOWS_SYS +#endif // !defined(WINDOWS_SYS) && !defined(__ANDROID__) #endif // _STACKTRACE_H_ From fe7de8352911f578b85490d0034fae2d23b258f5 Mon Sep 17 00:00:00 2001 From: Gio Date: Thu, 28 Jul 2016 14:08:49 +0200 Subject: [PATCH 06/22] WebUI is now optional but enabled by default at compile time --- libresapi/src/libresapi.pro | 14 +- retroshare-gui/src/gui/AboutDialog.cpp | 5 + retroshare-gui/src/gui/HelpDialog.cpp | 5 + retroshare-gui/src/gui/MainWindow.cpp | 4 + retroshare-gui/src/gui/MainWindow.h | 2 + retroshare-gui/src/gui/settings/WebuiPage.cpp | 2 +- .../src/gui/settings/rsettingswin.cpp | 3 +- retroshare-gui/src/main.cpp | 4 + retroshare-gui/src/retroshare-gui.pro | 12 +- retroshare-nogui/src/retroshare-nogui.pro | 732 +++++++++--------- retroshare.pri | 23 + 11 files changed, 426 insertions(+), 380 deletions(-) diff --git a/libresapi/src/libresapi.pro b/libresapi/src/libresapi.pro index bf51989f8..14faff570 100644 --- a/libresapi/src/libresapi.pro +++ b/libresapi/src/libresapi.pro @@ -8,11 +8,12 @@ TARGET = resapi TARGET_PRL = libresapi DESTDIR = lib -CONFIG += libmicrohttpd - INCLUDEPATH += ../../libretroshare/src -unix { +libresapihttpserver { + CONFIG += libmicrohttpd + + unix { webui_files.path = "$${DATA_DIR}/webui" webui_files.files = webui/app.js webui/app.css webui/index.html @@ -81,9 +82,9 @@ unix { QMAKE_EXTRA_COMPILERS += create_webfiles_html create_webfiles_js create_webfiles_css -} + } -win32{ + win32 { DEFINES *= WINDOWS_SYS INCLUDEPATH += . $$INC_DIR @@ -104,9 +105,8 @@ win32{ # create dummy files system($$MAKE_SRC\\init.bat .) -} + } -libmicrohttpd{ linux { CONFIG += link_pkgconfig PKGCONFIG *= libmicrohttpd diff --git a/retroshare-gui/src/gui/AboutDialog.cpp b/retroshare-gui/src/gui/AboutDialog.cpp index 7d1a047d6..441b78b9e 100644 --- a/retroshare-gui/src/gui/AboutDialog.cpp +++ b/retroshare-gui/src/gui/AboutDialog.cpp @@ -29,7 +29,10 @@ #include #include #include "settings/rsharesettings.h" + +#ifdef ENABLE_WEBUI #include +#endif #include #include @@ -781,11 +784,13 @@ void AboutDialog::on_copy_button_clicked() RsControl::instance()->getLibraries(libraries); verInfo+=addLibraries("libretroshare", libraries); +#ifdef ENABLE_WEBUI /* Add version numbers of RetroShare */ // Add versions here. Find a better place. libraries.clear(); libraries.push_back(RsLibraryInfo("Libmicrohttpd", MHD_get_version())); verInfo+=addLibraries("RetroShare", libraries); +#endif // ENABLE_WEBUI /* Add version numbers of plugins */ if (rsPlugins) { diff --git a/retroshare-gui/src/gui/HelpDialog.cpp b/retroshare-gui/src/gui/HelpDialog.cpp index b0811d74d..c27e404a2 100644 --- a/retroshare-gui/src/gui/HelpDialog.cpp +++ b/retroshare-gui/src/gui/HelpDialog.cpp @@ -24,7 +24,10 @@ #include #include + +#ifdef ENABLE_WEBUI #include +#endif // ENABLE_WEBUI #include #include @@ -94,11 +97,13 @@ HelpDialog::HelpDialog(QWidget *parent) : RsControl::instance()->getLibraries(libraries); addLibraries(ui->libraryLayout, "libretroshare", libraries); +#ifdef ENABLE_WEBUI /* Add version numbers of RetroShare */ // Add versions here. Find a better place. libraries.clear(); libraries.push_back(RsLibraryInfo("Libmicrohttpd", MHD_get_version())); addLibraries(ui->libraryLayout, "RetroShare", libraries); +#endif // ENABLE_WEBUI /* Add version numbers of plugins */ if (rsPlugins) { diff --git a/retroshare-gui/src/gui/MainWindow.cpp b/retroshare-gui/src/gui/MainWindow.cpp index 4fd1bebab..12050615e 100644 --- a/retroshare-gui/src/gui/MainWindow.cpp +++ b/retroshare-gui/src/gui/MainWindow.cpp @@ -562,7 +562,9 @@ void MainWindow::createTrayIcon() trayMenu->addSeparator(); trayMenu->addAction(QIcon(IMAGE_MESSENGER), tr("Open Messenger"), this, SLOT(showMessengerWindow())); trayMenu->addAction(QIcon(IMAGE_MESSAGES), tr("Open Messages"), this, SLOT(showMess())); +#ifdef ENABLE_WEBUI trayMenu->addAction(QIcon(":/images/emblem-web.png"), tr("Show web interface"), this, SLOT(showWebinterface())); +#endif // ENABLE_WEBUI trayMenu->addAction(QIcon(IMAGE_BWGRAPH), tr("Bandwidth Graph"), _bandwidthGraph, SLOT(showWindow())); trayMenu->addAction(QIcon(IMAGE_DHT), tr("Statistics"), this, SLOT(showStatisticsWindow())); @@ -1061,10 +1063,12 @@ void MainWindow::showStatisticsWindow() StatisticsWindow::showYourself(); } +#ifdef ENABLE_WEBUI void MainWindow::showWebinterface() { WebuiPage::showWebui(); } +#endif // ENABLE_WEBUI /** Shows Application window */ #ifdef UNFINISHED diff --git a/retroshare-gui/src/gui/MainWindow.h b/retroshare-gui/src/gui/MainWindow.h index b65d5992b..9bdaeb97b 100644 --- a/retroshare-gui/src/gui/MainWindow.h +++ b/retroshare-gui/src/gui/MainWindow.h @@ -211,7 +211,9 @@ private slots: void newRsCollection(); void showMessengerWindow(); void showStatisticsWindow(); +#ifdef ENABLE_WEBUI void showWebinterface(); +#endif //void servicePermission(); #ifdef UNFINISHED diff --git a/retroshare-gui/src/gui/settings/WebuiPage.cpp b/retroshare-gui/src/gui/settings/WebuiPage.cpp index 8e8c3498b..cb7121746 100644 --- a/retroshare-gui/src/gui/settings/WebuiPage.cpp +++ b/retroshare-gui/src/gui/settings/WebuiPage.cpp @@ -15,7 +15,7 @@ resource_api::ApiServer* WebuiPage::apiServer = 0; resource_api::ApiServerMHD* WebuiPage::apiServerMHD = 0; -// TODO: LIBRESAPI_LOCAL_SERVER Move in appropriate place +// TODO: LIBRESAPI_LOCAL_SERVER Put indipendent option for libresapilocalserver in appropriate place #ifdef LIBRESAPI_LOCAL_SERVER resource_api::ApiServerLocal* WebuiPage::apiServerLocal = 0; #endif diff --git a/retroshare-gui/src/gui/settings/rsettingswin.cpp b/retroshare-gui/src/gui/settings/rsettingswin.cpp index 8a57e148d..0a3e8dbc4 100644 --- a/retroshare-gui/src/gui/settings/rsettingswin.cpp +++ b/retroshare-gui/src/gui/settings/rsettingswin.cpp @@ -152,8 +152,9 @@ RSettingsWin::initStackedWidget() addPage(new AppearancePage()); addPage(new SoundPage() ); addPage(new ServicePermissionsPage() ); +#ifdef ENABLE_WEBUI addPage(new WebuiPage() ); - +#endif // ENABLE_WEBUI // add widgets from plugins for(int i=0;inbPlugins();++i) diff --git a/retroshare-gui/src/main.cpp b/retroshare-gui/src/main.cpp index f7e7c835d..e0ddf3796 100644 --- a/retroshare-gui/src/main.cpp +++ b/retroshare-gui/src/main.cpp @@ -397,13 +397,17 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO); notify->enable() ; // enable notification system after GUI creation, to avoid data races in Qt. +#ifdef ENABLE_WEBUI WebuiPage::checkStartWebui(); +#endif // ENABLE_WEBUI /* dive into the endless loop */ int ti = rshare.exec(); delete w ; +#ifdef ENABLE_WEBUI WebuiPage::checkShutdownWebui(); +#endif // ENABLE_WEBUI /* cleanup */ ChatDialog::cleanupChat(); diff --git a/retroshare-gui/src/retroshare-gui.pro b/retroshare-gui/src/retroshare-gui.pro index 7a6c372a3..b4f28dc0f 100644 --- a/retroshare-gui/src/retroshare-gui.pro +++ b/retroshare-gui/src/retroshare-gui.pro @@ -551,8 +551,7 @@ HEADERS += rshare.h \ gui/connect/ConnectProgressDialog.h \ gui/groups/CreateGroup.h \ gui/GetStartedDialog.h \ - gui/settings/WebuiPage.h \ - gui/statistics/BWGraph.h \ + gui/statistics/BWGraph.h \ util/RsSyntaxHighlighter.h \ util/imageutil.h @@ -671,7 +670,7 @@ FORMS += gui/StartDialog.ui \ gui/statistics/BwCtrlWindow.ui \ gui/statistics/RttStatistics.ui \ gui/GetStartedDialog.ui \ - gui/settings/WebuiPage.ui + # gui/ForumsDialog.ui \ # gui/forums/CreateForum.ui \ @@ -854,7 +853,6 @@ SOURCES += main.cpp \ gui/settings/ServicePermissionsPage.cpp \ gui/settings/AddFileAssociationDialog.cpp \ gui/settings/GroupFrameSettingsWidget.cpp \ - gui/settings/WebuiPage.cpp \ gui/statusbar/peerstatus.cpp \ gui/statusbar/natstatus.cpp \ gui/statusbar/dhtstatus.cpp \ @@ -1390,3 +1388,9 @@ gxsgui { } + +libresapihttpserver { + HEADERS *= gui/settings/WebuiPage.h + SOURCES *= gui/settings/WebuiPage.cpp + FORMS *= gui/settings/WebuiPage.ui +} diff --git a/retroshare-nogui/src/retroshare-nogui.pro b/retroshare-nogui/src/retroshare-nogui.pro index b3c2c0bd6..03482fe6c 100644 --- a/retroshare-nogui/src/retroshare-nogui.pro +++ b/retroshare-nogui/src/retroshare-nogui.pro @@ -1,367 +1,365 @@ -!include("../../retroshare.pri"): error("Could not include file ../../retroshare.pri") - -TEMPLATE = app -TARGET = RetroShare06-nogui -CONFIG += bitdht -#CONFIG += introserver -#CONFIG += sshserver -# webinterface, requires libmicrohttpd -CONFIG += webui -CONFIG -= qt xml gui -CONFIG += link_prl - -#CONFIG += debug -debug { - QMAKE_CFLAGS -= -O2 - QMAKE_CFLAGS += -O0 - QMAKE_CFLAGS += -g - - QMAKE_CXXFLAGS -= -O2 - QMAKE_CXXFLAGS += -O0 - QMAKE_CXXFLAGS += -g -} - -################################# Linux ########################################## -linux-* { - #CONFIG += version_detail_bash_script - QMAKE_CXXFLAGS *= -D_FILE_OFFSET_BITS=64 - - LIBS *= -rdynamic -} - -unix { - target.path = "$${BIN_DIR}" - INSTALLS += target -} - -linux-g++ { - OBJECTS_DIR = temp/linux-g++/obj -} - -linux-g++-64 { - OBJECTS_DIR = temp/linux-g++-64/obj -} - -#################### Cross compilation for windows under Linux ################### - -win32-x-g++ { - OBJECTS_DIR = temp/win32-x-g++/obj - - LIBS += ../../../../lib/win32-x-g++/libssl.a - LIBS += ../../../../lib/win32-x-g++/libcrypto.a - LIBS += ../../../../lib/win32-x-g++/libminiupnpc.a - LIBS += ../../../../lib/win32-x-g++/libz.a - LIBS += -L${HOME}/.wine/drive_c/pthreads/lib -lpthreadGCE2 - LIBS += -lws2_32 -luuid -lole32 -liphlpapi -lcrypt32 -gdi32 - LIBS += -lole32 -lwinmm - - RC_FILE = gui/images/retroshare_win.rc - - DEFINES *= WIN32 -} - -#################################### Windows ##################################### - -win32 { - CONFIG += console - OBJECTS_DIR = temp/obj - RCC_DIR = temp/qrc - UI_DIR = temp/ui - MOC_DIR = temp/moc - - # solve linker warnings because of the order of the libraries - QMAKE_LFLAGS += -Wl,--start-group - - CONFIG(debug, debug|release) { - } else { - # Tell linker to use ASLR protection - QMAKE_LFLAGS += -Wl,-dynamicbase - # Tell linker to use DEP protection - QMAKE_LFLAGS += -Wl,-nxcompat - } - - for(lib, LIB_DIR):LIBS += -L"$$lib" - LIBS += -lssl -lcrypto -lpthread -lminiupnpc -lz - LIBS += -lcrypto -lws2_32 -lgdi32 - LIBS += -luuid -lole32 -liphlpapi -lcrypt32 - LIBS += -lole32 -lwinmm - - PROTOCPATH=$$BIN_DIR - - RC_FILE = resources/retroshare_win.rc - - DEFINES *= WINDOWS_SYS _USE_32BIT_TIME_T - - DEPENDPATH += . $$INC_DIR - INCLUDEPATH += . $$INC_DIR -} - -##################################### MacOS ###################################### - -macx { - # ENABLE THIS OPTION FOR Univeral Binary BUILD. - # CONFIG += ppc x86 - - LIBS += -Wl,-search_paths_first - LIBS += -lssl -lcrypto -lz - for(lib, LIB_DIR):exists($$lib/libminiupnpc.a){ LIBS += $$lib/libminiupnpc.a} - LIBS += -framework CoreFoundation - LIBS += -framework Security - for(lib, LIB_DIR):LIBS += -L"$$lib" - for(bin, BIN_DIR):LIBS += -L"$$bin" - - DEPENDPATH += . $$INC_DIR - INCLUDEPATH += . $$INC_DIR - - sshserver { - LIBS += -L../../../lib - #LIBS += -L../../../lib/libssh-0.6.0 - } - - QMAKE_CXXFLAGS *= -Dfseeko64=fseeko -Dftello64=ftello -Dstat64=stat -Dstatvfs64=statvfs -Dfopen64=fopen - -} - -##################################### FreeBSD ###################################### - -freebsd-* { - INCLUDEPATH *= /usr/local/include/gpgme - LIBS *= -lssl - LIBS *= -lgpgme - LIBS *= -lupnp - LIBS *= -lgnome-keyring -} - -##################################### OpenBSD ###################################### - -openbsd-* { - INCLUDEPATH *= /usr/local/include - QMAKE_CXXFLAGS *= -Dfseeko64=fseeko -Dftello64=ftello -Dstat64=stat -Dstatvfs64=statvfs -Dfopen64=fopen - LIBS *= -lssl -lcrypto - LIBS *= -lgpgme - LIBS *= -lupnp - LIBS *= -lgnome-keyring - LIBS *= -rdynamic -} - -##################################### Haiku ###################################### - -haiku-* { - QMAKE_CXXFLAGS *= -D_BSD_SOURCE - - PRE_TARGETDEPS *= ../../libretroshare/src/lib/libretroshare.a - PRE_TARGETDEPS *= ../../openpgpsdk/src/lib/libops.a - - LIBS *= ../../libretroshare/src/lib/libretroshare.a - LIBS *= ../../openpgpsdk/src/lib/libops.a -lbz2 -lbsd - LIBS *= -lssl -lcrypto -lnetwork - LIBS *= -lgpgme - LIBS *= -lupnp - LIBS *= -lz - LIBS *= -lixml - - LIBS += ../../supportlibs/pegmarkdown/lib/libpegmarkdown.a - LIBS += -lsqlite3 - -} - -############################## Common stuff ###################################### - -DEPENDPATH += . ../../libretroshare/src -INCLUDEPATH += . ../../libretroshare/src - -PRE_TARGETDEPS *= ../../libretroshare/src/lib/libretroshare.a -LIBS *= ../../libretroshare/src/lib/libretroshare.a - -# Input -HEADERS += notifytxt.h -SOURCES += notifytxt.cc \ - retroshare.cc - -introserver { - HEADERS += introserver.h - SOURCES += introserver.cc - DEFINES *= RS_INTRO_SERVER -} - -webui { - DEFINES *= ENABLE_WEBUI - PRE_TARGETDEPS *= ../../libresapi/src/lib/libresapi.a - LIBS += ../../libresapi/src/lib/libresapi.a - DEPENDPATH += ../../libresapi/src - INCLUDEPATH += ../../libresapi/src - HEADERS += \ - TerminalApiClient.h - SOURCES += \ - TerminalApiClient.cpp -} - -sshserver { - - # This Requires libssh-0.5.* to compile. - # Please use this path below. - # (You can modify it locally if required - but dont commit it!) - - #LIBSSH_DIR = ../../../lib/libssh-0.5.2 - LIBSSH_DIR = ../../../libssh-0.6.0rc1 - - # - # Use the following commend to generate a Server RSA Key. - # Key should be in current directory - when run/ - # ssh-keygen -t rsa -f rs_ssh_host_rsa_key - # - # You can connect from a standard ssh, eg: ssh -p 7022 127.0.0.1 - # - # The Menu system is available from the command-line (-T) and SSH (-S) - # if it get covered by debug gunk, just press to refresh. - # - # ./retroshare-nogui -h provides some more instructions. - # - - win32 { - DEFINES *= LIBSSH_STATIC - } - - DEPENDPATH += $$LIBSSH_DIR/include/ - INCLUDEPATH += $$LIBSSH_DIR/include/ - - win32 { - LIBS += -lssh - LIBS += -lssh_threads - } else { - SSH_OK = $$system(pkg-config --atleast-version 0.5.4 libssh && echo yes) - isEmpty(SSH_OK) { - exists($$LIBSSH_DIR/build/src/libssh.a):exists($$LIBSSH_DIR/build/src/threads/libssh_threads.a) { - LIBS += $$LIBSSH_DIR/build/src/libssh.a - LIBS += $$LIBSSH_DIR/build/src/threads/libssh_threads.a - } - else { - ! exists($$LIBSSH_DIR/build/src/libssh.a):message($$LIBSSH_DIR/build/src/libssh.a does not exist) - ! exists($$LIBSSH_DIR/build/src/threads/libssh_threads.a):message($$LIBSSH_DIR/build/src/threads/libssh_threads.a does not exist) - message(You need to download and compile libssh) - message(See http://sourceforge.net/p/retroshare/code/6163/tree/trunk/) - } - } else { - LIBS += -lssh - LIBS += -lssh_threads - } - } - - HEADERS += ssh/rssshd.h - SOURCES += ssh/rssshd.cc - - # For the Menu System - HEADERS += menu/menu.h \ - menu/menus.h \ - menu/stdiocomms.h \ - - SOURCES += menu/menu.cc \ - menu/menus.cc \ - menu/stdiocomms.cc \ - - # For the RPC System - HEADERS += rpc/rpc.h \ - rpc/rpcserver.h \ - rpc/rpcsetup.h \ - rpc/rpcecho.h \ - rpcsystem.h \ - - SOURCES += rpc/rpc.cc \ - rpc/rpcserver.cc \ - rpc/rpcsetup.cc \ - rpc/rpcecho.cc \ - - # Actual protocol files to go here... - #HEADERS += rpc/proto/rpcecho.h \ - - #SOURCES += rpc/proto/rpcecho.cc \ - - DEFINES *= RS_SSH_SERVER - - # Include Protobuf classes. - CONFIG += protorpc -} - -protorpc { - # Proto Services - PROTOS = core.proto peers.proto system.proto chat.proto search.proto files.proto stream.proto - DESTPATH = $$PWD/rpc/proto/gencc - PROTOPATH = $$PWD/../../rsctrl/src/definition - CMD = echo Building protobuf files - for(pf, PROTOS):CMD += && $${PROTOCPATH}protoc --cpp_out=$${DESTPATH} --proto_path=$${PROTOPATH} $${PROTOPATH}/$${pf} - protobuf_gen.commands = $${CMD} - QMAKE_EXTRA_TARGETS += protobuf_gen - PRE_TARGETDEPS += protobuf_gen - - HEADERS += rpc/proto/rpcprotopeers.h \ - rpc/proto/rpcprotosystem.h \ - rpc/proto/rpcprotochat.h \ - rpc/proto/rpcprotosearch.h \ - rpc/proto/rpcprotofiles.h \ - rpc/proto/rpcprotostream.h \ - rpc/proto/rpcprotoutils.h \ - - SOURCES += rpc/proto/rpcprotopeers.cc \ - rpc/proto/rpcprotosystem.cc \ - rpc/proto/rpcprotochat.cc \ - rpc/proto/rpcprotosearch.cc \ - rpc/proto/rpcprotofiles.cc \ - rpc/proto/rpcprotostream.cc \ - rpc/proto/rpcprotoutils.cc \ - - # Offical Generated Code (protobuf 2.4.1) - HEADERS += rpc/proto/gencc/core.pb.h \ - rpc/proto/gencc/peers.pb.h \ - rpc/proto/gencc/system.pb.h \ - rpc/proto/gencc/chat.pb.h \ - rpc/proto/gencc/search.pb.h \ - rpc/proto/gencc/files.pb.h \ - rpc/proto/gencc/stream.pb.h \ - - SOURCES += rpc/proto/gencc/core.pb.cc \ - rpc/proto/gencc/peers.pb.cc \ - rpc/proto/gencc/system.pb.cc \ - rpc/proto/gencc/chat.pb.cc \ - rpc/proto/gencc/search.pb.cc \ - rpc/proto/gencc/files.pb.cc \ - rpc/proto/gencc/stream.pb.cc \ - - # Generated ProtoBuf Code the RPC System - # If you are developing, or have a different version of protobuf - # you can use these ones (run make inside rsctrl/src/ to generate) - #HEADERS += ../../rsctrl/src/gencc/core.pb.h \ - # ../../rsctrl/src/gencc/peers.pb.h \ - # ../../rsctrl/src/gencc/system.pb.h \ - # ../../rsctrl/src/gencc/chat.pb.h \ - # ../../rsctrl/src/gencc/search.pb.h \ - # ../../rsctrl/src/gencc/files.pb.h \ - # ../../rsctrl/src/gencc/stream.pb.h \ - - #SOURCES += ../../rsctrl/src/gencc/core.pb.cc \ - # ../../rsctrl/src/gencc/peers.pb.cc \ - # ../../rsctrl/src/gencc/system.pb.cc \ - # ../../rsctrl/src/gencc/chat.pb.cc \ - # ../../rsctrl/src/gencc/search.pb.cc \ - # ../../rsctrl/src/gencc/files.pb.cc \ - # ../../rsctrl/src/gencc/stream.pb.cc \ - - DEPENDPATH *= rpc/proto/gencc - INCLUDEPATH *= rpc/proto/gencc - - !win32 { - # unrecognized option - QMAKE_CFLAGS += -pthread - QMAKE_CXXFLAGS += -pthread - } - LIBS += -lprotobuf -lpthread - - win32 { - DEPENDPATH += $$LIBS_DIR/include/protobuf - INCLUDEPATH += $$LIBS_DIR/include/protobuf - } - - macx { - PROTOPATH = ../../../protobuf-2.4.1 - INCLUDEPATH += $${PROTOPATH}/src - } -} +!include("../../retroshare.pri"): error("Could not include file ../../retroshare.pri") + +TEMPLATE = app +TARGET = RetroShare06-nogui +CONFIG += bitdht +#CONFIG += introserver +#CONFIG += sshserver +CONFIG -= qt xml gui +CONFIG += link_prl + +#CONFIG += debug +debug { + QMAKE_CFLAGS -= -O2 + QMAKE_CFLAGS += -O0 + QMAKE_CFLAGS += -g + + QMAKE_CXXFLAGS -= -O2 + QMAKE_CXXFLAGS += -O0 + QMAKE_CXXFLAGS += -g +} + +################################# Linux ########################################## +linux-* { + #CONFIG += version_detail_bash_script + QMAKE_CXXFLAGS *= -D_FILE_OFFSET_BITS=64 + + LIBS *= -rdynamic +} + +unix { + target.path = "$${BIN_DIR}" + INSTALLS += target +} + +linux-g++ { + OBJECTS_DIR = temp/linux-g++/obj +} + +linux-g++-64 { + OBJECTS_DIR = temp/linux-g++-64/obj +} + +#################### Cross compilation for windows under Linux ################### + +win32-x-g++ { + OBJECTS_DIR = temp/win32-x-g++/obj + + LIBS += ../../../../lib/win32-x-g++/libssl.a + LIBS += ../../../../lib/win32-x-g++/libcrypto.a + LIBS += ../../../../lib/win32-x-g++/libminiupnpc.a + LIBS += ../../../../lib/win32-x-g++/libz.a + LIBS += -L${HOME}/.wine/drive_c/pthreads/lib -lpthreadGCE2 + LIBS += -lws2_32 -luuid -lole32 -liphlpapi -lcrypt32 -gdi32 + LIBS += -lole32 -lwinmm + + RC_FILE = gui/images/retroshare_win.rc + + DEFINES *= WIN32 +} + +#################################### Windows ##################################### + +win32 { + CONFIG += console + OBJECTS_DIR = temp/obj + RCC_DIR = temp/qrc + UI_DIR = temp/ui + MOC_DIR = temp/moc + + # solve linker warnings because of the order of the libraries + QMAKE_LFLAGS += -Wl,--start-group + + CONFIG(debug, debug|release) { + } else { + # Tell linker to use ASLR protection + QMAKE_LFLAGS += -Wl,-dynamicbase + # Tell linker to use DEP protection + QMAKE_LFLAGS += -Wl,-nxcompat + } + + for(lib, LIB_DIR):LIBS += -L"$$lib" + LIBS += -lssl -lcrypto -lpthread -lminiupnpc -lz + LIBS += -lcrypto -lws2_32 -lgdi32 + LIBS += -luuid -lole32 -liphlpapi -lcrypt32 + LIBS += -lole32 -lwinmm + + PROTOCPATH=$$BIN_DIR + + RC_FILE = resources/retroshare_win.rc + + DEFINES *= WINDOWS_SYS _USE_32BIT_TIME_T + + DEPENDPATH += . $$INC_DIR + INCLUDEPATH += . $$INC_DIR +} + +##################################### MacOS ###################################### + +macx { + # ENABLE THIS OPTION FOR Univeral Binary BUILD. + # CONFIG += ppc x86 + + LIBS += -Wl,-search_paths_first + LIBS += -lssl -lcrypto -lz + for(lib, LIB_DIR):exists($$lib/libminiupnpc.a){ LIBS += $$lib/libminiupnpc.a} + LIBS += -framework CoreFoundation + LIBS += -framework Security + for(lib, LIB_DIR):LIBS += -L"$$lib" + for(bin, BIN_DIR):LIBS += -L"$$bin" + + DEPENDPATH += . $$INC_DIR + INCLUDEPATH += . $$INC_DIR + + sshserver { + LIBS += -L../../../lib + #LIBS += -L../../../lib/libssh-0.6.0 + } + + QMAKE_CXXFLAGS *= -Dfseeko64=fseeko -Dftello64=ftello -Dstat64=stat -Dstatvfs64=statvfs -Dfopen64=fopen + +} + +##################################### FreeBSD ###################################### + +freebsd-* { + INCLUDEPATH *= /usr/local/include/gpgme + LIBS *= -lssl + LIBS *= -lgpgme + LIBS *= -lupnp + LIBS *= -lgnome-keyring +} + +##################################### OpenBSD ###################################### + +openbsd-* { + INCLUDEPATH *= /usr/local/include + QMAKE_CXXFLAGS *= -Dfseeko64=fseeko -Dftello64=ftello -Dstat64=stat -Dstatvfs64=statvfs -Dfopen64=fopen + LIBS *= -lssl -lcrypto + LIBS *= -lgpgme + LIBS *= -lupnp + LIBS *= -lgnome-keyring + LIBS *= -rdynamic +} + +##################################### Haiku ###################################### + +haiku-* { + QMAKE_CXXFLAGS *= -D_BSD_SOURCE + + PRE_TARGETDEPS *= ../../libretroshare/src/lib/libretroshare.a + PRE_TARGETDEPS *= ../../openpgpsdk/src/lib/libops.a + + LIBS *= ../../libretroshare/src/lib/libretroshare.a + LIBS *= ../../openpgpsdk/src/lib/libops.a -lbz2 -lbsd + LIBS *= -lssl -lcrypto -lnetwork + LIBS *= -lgpgme + LIBS *= -lupnp + LIBS *= -lz + LIBS *= -lixml + + LIBS += ../../supportlibs/pegmarkdown/lib/libpegmarkdown.a + LIBS += -lsqlite3 + +} + +############################## Common stuff ###################################### + +DEPENDPATH += . ../../libretroshare/src +INCLUDEPATH += . ../../libretroshare/src + +PRE_TARGETDEPS *= ../../libretroshare/src/lib/libretroshare.a +LIBS *= ../../libretroshare/src/lib/libretroshare.a + +# Input +HEADERS += notifytxt.h +SOURCES += notifytxt.cc \ + retroshare.cc + +introserver { + HEADERS += introserver.h + SOURCES += introserver.cc + DEFINES *= RS_INTRO_SERVER +} + +libresapihttpserver { + DEFINES *= ENABLE_WEBUI + PRE_TARGETDEPS *= ../../libresapi/src/lib/libresapi.a + LIBS += ../../libresapi/src/lib/libresapi.a + DEPENDPATH += ../../libresapi/src + INCLUDEPATH += ../../libresapi/src + HEADERS += \ + TerminalApiClient.h + SOURCES += \ + TerminalApiClient.cpp +} + +sshserver { + + # This Requires libssh-0.5.* to compile. + # Please use this path below. + # (You can modify it locally if required - but dont commit it!) + + #LIBSSH_DIR = ../../../lib/libssh-0.5.2 + LIBSSH_DIR = ../../../libssh-0.6.0rc1 + + # + # Use the following commend to generate a Server RSA Key. + # Key should be in current directory - when run/ + # ssh-keygen -t rsa -f rs_ssh_host_rsa_key + # + # You can connect from a standard ssh, eg: ssh -p 7022 127.0.0.1 + # + # The Menu system is available from the command-line (-T) and SSH (-S) + # if it get covered by debug gunk, just press to refresh. + # + # ./retroshare-nogui -h provides some more instructions. + # + + win32 { + DEFINES *= LIBSSH_STATIC + } + + DEPENDPATH += $$LIBSSH_DIR/include/ + INCLUDEPATH += $$LIBSSH_DIR/include/ + + win32 { + LIBS += -lssh + LIBS += -lssh_threads + } else { + SSH_OK = $$system(pkg-config --atleast-version 0.5.4 libssh && echo yes) + isEmpty(SSH_OK) { + exists($$LIBSSH_DIR/build/src/libssh.a):exists($$LIBSSH_DIR/build/src/threads/libssh_threads.a) { + LIBS += $$LIBSSH_DIR/build/src/libssh.a + LIBS += $$LIBSSH_DIR/build/src/threads/libssh_threads.a + } + else { + ! exists($$LIBSSH_DIR/build/src/libssh.a):message($$LIBSSH_DIR/build/src/libssh.a does not exist) + ! exists($$LIBSSH_DIR/build/src/threads/libssh_threads.a):message($$LIBSSH_DIR/build/src/threads/libssh_threads.a does not exist) + message(You need to download and compile libssh) + message(See http://sourceforge.net/p/retroshare/code/6163/tree/trunk/) + } + } else { + LIBS += -lssh + LIBS += -lssh_threads + } + } + + HEADERS += ssh/rssshd.h + SOURCES += ssh/rssshd.cc + + # For the Menu System + HEADERS += menu/menu.h \ + menu/menus.h \ + menu/stdiocomms.h \ + + SOURCES += menu/menu.cc \ + menu/menus.cc \ + menu/stdiocomms.cc \ + + # For the RPC System + HEADERS += rpc/rpc.h \ + rpc/rpcserver.h \ + rpc/rpcsetup.h \ + rpc/rpcecho.h \ + rpcsystem.h \ + + SOURCES += rpc/rpc.cc \ + rpc/rpcserver.cc \ + rpc/rpcsetup.cc \ + rpc/rpcecho.cc \ + + # Actual protocol files to go here... + #HEADERS += rpc/proto/rpcecho.h \ + + #SOURCES += rpc/proto/rpcecho.cc \ + + DEFINES *= RS_SSH_SERVER + + # Include Protobuf classes. + CONFIG += protorpc +} + +protorpc { + # Proto Services + PROTOS = core.proto peers.proto system.proto chat.proto search.proto files.proto stream.proto + DESTPATH = $$PWD/rpc/proto/gencc + PROTOPATH = $$PWD/../../rsctrl/src/definition + CMD = echo Building protobuf files + for(pf, PROTOS):CMD += && $${PROTOCPATH}protoc --cpp_out=$${DESTPATH} --proto_path=$${PROTOPATH} $${PROTOPATH}/$${pf} + protobuf_gen.commands = $${CMD} + QMAKE_EXTRA_TARGETS += protobuf_gen + PRE_TARGETDEPS += protobuf_gen + + HEADERS += rpc/proto/rpcprotopeers.h \ + rpc/proto/rpcprotosystem.h \ + rpc/proto/rpcprotochat.h \ + rpc/proto/rpcprotosearch.h \ + rpc/proto/rpcprotofiles.h \ + rpc/proto/rpcprotostream.h \ + rpc/proto/rpcprotoutils.h \ + + SOURCES += rpc/proto/rpcprotopeers.cc \ + rpc/proto/rpcprotosystem.cc \ + rpc/proto/rpcprotochat.cc \ + rpc/proto/rpcprotosearch.cc \ + rpc/proto/rpcprotofiles.cc \ + rpc/proto/rpcprotostream.cc \ + rpc/proto/rpcprotoutils.cc \ + + # Offical Generated Code (protobuf 2.4.1) + HEADERS += rpc/proto/gencc/core.pb.h \ + rpc/proto/gencc/peers.pb.h \ + rpc/proto/gencc/system.pb.h \ + rpc/proto/gencc/chat.pb.h \ + rpc/proto/gencc/search.pb.h \ + rpc/proto/gencc/files.pb.h \ + rpc/proto/gencc/stream.pb.h \ + + SOURCES += rpc/proto/gencc/core.pb.cc \ + rpc/proto/gencc/peers.pb.cc \ + rpc/proto/gencc/system.pb.cc \ + rpc/proto/gencc/chat.pb.cc \ + rpc/proto/gencc/search.pb.cc \ + rpc/proto/gencc/files.pb.cc \ + rpc/proto/gencc/stream.pb.cc \ + + # Generated ProtoBuf Code the RPC System + # If you are developing, or have a different version of protobuf + # you can use these ones (run make inside rsctrl/src/ to generate) + #HEADERS += ../../rsctrl/src/gencc/core.pb.h \ + # ../../rsctrl/src/gencc/peers.pb.h \ + # ../../rsctrl/src/gencc/system.pb.h \ + # ../../rsctrl/src/gencc/chat.pb.h \ + # ../../rsctrl/src/gencc/search.pb.h \ + # ../../rsctrl/src/gencc/files.pb.h \ + # ../../rsctrl/src/gencc/stream.pb.h \ + + #SOURCES += ../../rsctrl/src/gencc/core.pb.cc \ + # ../../rsctrl/src/gencc/peers.pb.cc \ + # ../../rsctrl/src/gencc/system.pb.cc \ + # ../../rsctrl/src/gencc/chat.pb.cc \ + # ../../rsctrl/src/gencc/search.pb.cc \ + # ../../rsctrl/src/gencc/files.pb.cc \ + # ../../rsctrl/src/gencc/stream.pb.cc \ + + DEPENDPATH *= rpc/proto/gencc + INCLUDEPATH *= rpc/proto/gencc + + !win32 { + # unrecognized option + QMAKE_CFLAGS += -pthread + QMAKE_CXXFLAGS += -pthread + } + LIBS += -lprotobuf -lpthread + + win32 { + DEPENDPATH += $$LIBS_DIR/include/protobuf + INCLUDEPATH += $$LIBS_DIR/include/protobuf + } + + macx { + PROTOPATH = ../../../protobuf-2.4.1 + INCLUDEPATH += $${PROTOPATH}/src + } +} diff --git a/retroshare.pri b/retroshare.pri index 827aa89fd..f8d57ca78 100644 --- a/retroshare.pri +++ b/retroshare.pri @@ -2,6 +2,9 @@ # {,un}comment the following line #CONFIG *= libresapilocalserver +# To {dis,en}able libresapi via HTTP (libmicrohttpd) {,un}comment the following line +CONFIG *= libresapihttpserver + # Gxs is always enabled now. DEFINES *= RS_ENABLE_GXS @@ -14,6 +17,25 @@ unix { isEmpty(PLUGIN_DIR) { PLUGIN_DIR = "$${LIB_DIR}/retroshare/extensions6" } } +android-g++ { + DEFINES *= NO_SQLCIPHER + DEFINES *= "fopen64=fopen" + DEFINES *= "fseeko64=fseeko" + DEFINES *= "ftello64=ftello" + INCLUDEPATH *= $$NDK_TOOLCHAIN_PATH/sysroot/usr/include/ + LIBS *= -L$$NDK_TOOLCHAIN_PATH/sysroot/usr/lib/ + LIBS *= -lssl -lcrypto -lsqlite3 -lupnp -lixml + ANDROID_EXTRA_LIBS *= $$NDK_TOOLCHAIN_PATH/sysroot/usr/lib/libcrypto.so + ANDROID_EXTRA_LIBS *= $$NDK_TOOLCHAIN_PATH/sysroot/usr/lib/libssl.so + ANDROID_EXTRA_LIBS *= $$NDK_TOOLCHAIN_PATH/sysroot/usr/lib/libbz2.so + ANDROID_EXTRA_LIBS *= $$NDK_TOOLCHAIN_PATH/sysroot/usr/lib/libsqlite3.so + ANDROID_EXTRA_LIBS *= $$NDK_TOOLCHAIN_PATH/sysroot/usr/lib/libupnp.so + ANDROID_EXTRA_LIBS *= $$NDK_TOOLCHAIN_PATH/sysroot/usr/lib/libixml.so + message(NDK_TOOLCHAIN_PATH: $$NDK_TOOLCHAIN_PATH) + message(LIBS: $$LIBS) + message(ANDROID_EXTRA_LIBS: $$ANDROID_EXTRA_LIBS) +} + win32 { message(***retroshare.pri:Win32) exists($$PWD/../libs) { @@ -68,3 +90,4 @@ unfinished { wikipoos:DEFINES *= RS_USE_WIKI libresapilocalserver:DEFINES *= LIBRESAPI_LOCAL_SERVER +libresapihttpserver::DEFINES *= ENABLE_WEBUI From 7c2e2bd503d88f432a9a1fa1d89488e7a17612a4 Mon Sep 17 00:00:00 2001 From: Gio Date: Thu, 28 Jul 2016 17:24:17 +0200 Subject: [PATCH 07/22] take in account that QLocalSocket is of type STREAM so it doesn't emit readyRead event for each write() on the other side --- libresapi/src/api/ApiServerLocal.cpp | 48 +++++++++++++++------------- libresapi/src/api/ApiServerLocal.h | 3 +- 2 files changed, 26 insertions(+), 25 deletions(-) diff --git a/libresapi/src/api/ApiServerLocal.cpp b/libresapi/src/api/ApiServerLocal.cpp index e951c2425..e1d5e2623 100644 --- a/libresapi/src/api/ApiServerLocal.cpp +++ b/libresapi/src/api/ApiServerLocal.cpp @@ -27,48 +27,50 @@ void ApiServerLocal::handleConnection() } ApiLocalConnectionHandler::ApiLocalConnectionHandler(ApiServer* apiServer, QLocalSocket* sock) : - QThread(), mApiServer(apiServer), mLocalSocket(sock), mState(WAITING_PATH) + QThread(), mApiServer(apiServer), mLocalSocket(sock) { sock->moveToThread(this); - connect(mLocalSocket, SIGNAL(disconnected()), this, SLOT(quit())); connect(this, SIGNAL(finished()), this, SLOT(deleteLater())); + connect(mLocalSocket, SIGNAL(disconnected()), this, SLOT(quit())); connect(sock, SIGNAL(readyRead()), this, SLOT(handleRequest())); start(); } void ApiLocalConnectionHandler::handleRequest() { - switch(mState) + char path[1024]; + if(mLocalSocket->readLine(path, 1023) > 0) { - case WAITING_PATH: - { - char path[1024]; - mLocalSocket->readLine(path, 1023); reqPath = path; - mState = WAITING_DATA; - break; + char jsonData[20480]; + if(mLocalSocket->read(jsonData, 20479) > 0) + { + resource_api::JsonStream reqJson; + reqJson.setJsonString(std::string(jsonData)); + resource_api::Request req(reqJson); + req.setPath(reqPath); + std::string resultString = mApiServer->handleRequest(req); + mLocalSocket->write(resultString.c_str(), resultString.length()); + mLocalSocket->write("\n\0"); + } + else + { + mLocalSocket->write("\"{\"data\":null,\"debug_msg\":\"ApiLocalConnectionHandler::handleRequest() Error: timeout waiting for path.\\n\",\"returncode\":\"fail\"}\"\n\0"); + quit(); + } } - case WAITING_DATA: + else { - char jsonData[1024]; - mLocalSocket->read(jsonData, 1023); - resource_api::JsonStream reqJson; - reqJson.setJsonString(std::string(jsonData)); - resource_api::Request req(reqJson); - req.setPath(reqPath); - std::string resultString = mApiServer->handleRequest(req); - mLocalSocket->write(resultString.data(), resultString.length()); - mState = WAITING_PATH; - break; - } + mLocalSocket->write("{\"data\":null,\"debug_msg\":\"ApiLocalConnectionHandler::handleRequest() Error: timeout waiting for JSON data.\\n\",\"returncode\":\"fail\"}\"\n\0"); + quit(); } } ApiLocalConnectionHandler::~ApiLocalConnectionHandler() { + mLocalSocket->flush(); mLocalSocket->close(); - delete mLocalSocket; + mLocalSocket->deleteLater(); } - } // namespace resource_api diff --git a/libresapi/src/api/ApiServerLocal.h b/libresapi/src/api/ApiServerLocal.h index 3e8100453..73f001143 100644 --- a/libresapi/src/api/ApiServerLocal.h +++ b/libresapi/src/api/ApiServerLocal.h @@ -43,7 +43,6 @@ class ApiLocalConnectionHandler : public QThread public: ApiLocalConnectionHandler(ApiServer* apiServer, QLocalSocket* sock); ~ApiLocalConnectionHandler(); - enum State {WAITING_PATH, WAITING_DATA}; public slots: void handleRequest(); @@ -51,8 +50,8 @@ public slots: private: ApiServer* mApiServer; QLocalSocket* mLocalSocket; - State mState; std::string reqPath; + void _die(); }; } // namespace resource_api From ae9ab644a9f8f1938f5d475b6ecb17504d74f94f Mon Sep 17 00:00:00 2001 From: Phenom Date: Sat, 30 Jul 2016 13:27:23 +0200 Subject: [PATCH 08/22] Move Display button's menu to Header context menu on FriendList. --- retroshare-gui/src/gui/common/FriendList.cpp | 13 +++---- retroshare-gui/src/gui/common/FriendList.ui | 36 +------------------- 2 files changed, 8 insertions(+), 41 deletions(-) diff --git a/retroshare-gui/src/gui/common/FriendList.cpp b/retroshare-gui/src/gui/common/FriendList.cpp index 47b5c67ed..a46606acb 100644 --- a/retroshare-gui/src/gui/common/FriendList.cpp +++ b/retroshare-gui/src/gui/common/FriendList.cpp @@ -187,8 +187,9 @@ void FriendList::addToolButton(QToolButton *toolButton) /* Initialize button */ toolButton->setAutoRaise(true); - toolButton->setIconSize(ui->displayButton->iconSize()); - toolButton->setFocusPolicy(ui->displayButton->focusPolicy()); + float S = QFontMetricsF(ui->filterLineEdit->font()).height() ; + toolButton->setIconSize(QSize(S*1.5,S*1.5)); + toolButton->setFocusPolicy(Qt::NoFocus); ui->titleBarFrame->layout()->addWidget(toolButton); } @@ -2283,16 +2284,16 @@ void FriendList::addPeerToExpand(const std::string &gpgId) void FriendList::createDisplayMenu() { - QMenu *displayMenu = new QMenu(this); + QMenu *displayMenu = new QMenu(tr("Show"), this); connect(displayMenu, SIGNAL(aboutToShow()), this, SLOT(updateMenu())); displayMenu->addAction(ui->actionHideOfflineFriends); displayMenu->addAction(ui->actionShowState); displayMenu->addAction(ui->actionShowGroups); - displayMenu->addAction(ui->actionExportFriendlist); - displayMenu->addAction(ui->actionImportFriendlist); - ui->displayButton->setMenu(displayMenu); + ui->peerTreeWidget->addHeaderContextMenuMenu(displayMenu); + ui->peerTreeWidget->addHeaderContextMenuAction(ui->actionExportFriendlist); + ui->peerTreeWidget->addHeaderContextMenuAction(ui->actionImportFriendlist); } void FriendList::updateMenu() diff --git a/retroshare-gui/src/gui/common/FriendList.ui b/retroshare-gui/src/gui/common/FriendList.ui index cc6921319..d1fb3122d 100644 --- a/retroshare-gui/src/gui/common/FriendList.ui +++ b/retroshare-gui/src/gui/common/FriendList.ui @@ -53,38 +53,6 @@ - - - - - 30 - 0 - - - - Qt::NoFocus - - - Display - - - - :/images/looknfeel.png:/images/looknfeel.png - - - - 24 - 24 - - - - QToolButton::InstantPopup - - - true - - - @@ -188,8 +156,6 @@
gui/common/RSTreeWidget.h
- - - + From 46e4b3b4c86ddae043c9c721e84a7fa27e0b088e Mon Sep 17 00:00:00 2001 From: Phenom Date: Sat, 30 Jul 2016 13:58:02 +0200 Subject: [PATCH 09/22] Fix FriendList sorting when expand PGPItem sorted by LastContact or IP --- retroshare-gui/src/gui/common/FriendList.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/retroshare-gui/src/gui/common/FriendList.cpp b/retroshare-gui/src/gui/common/FriendList.cpp index 47b5c67ed..20f134543 100644 --- a/retroshare-gui/src/gui/common/FriendList.cpp +++ b/retroshare-gui/src/gui/common/FriendList.cpp @@ -1176,9 +1176,9 @@ void FriendList::insertPeers() gpgItem->setData(COLUMN_NAME, ROLE_FILTER, gpgName); gpgItem->setData(COLUMN_LAST_CONTACT, Qt::DisplayRole, showInfoAtGpgItem ? QVariant(bestLastContact) : ""); - gpgItem->setData(COLUMN_LAST_CONTACT, ROLE_SORT_NAME, showInfoAtGpgItem ? QVariant(bestLastContact) : ""); + gpgItem->setData(COLUMN_LAST_CONTACT, ROLE_SORT_NAME, QVariant(bestLastContact)); gpgItem->setText(COLUMN_IP, showInfoAtGpgItem ? bestIP : ""); - gpgItem->setData(COLUMN_IP, ROLE_SORT_NAME, showInfoAtGpgItem ? bestIP : ""); + gpgItem->setData(COLUMN_IP, ROLE_SORT_NAME, bestIP); /* Sort data */ gpgItem->setData(COLUMN_NAME, ROLE_SORT_NAME, gpgName); From bef7db4b4df8fe5fa7afdb586acd53befa710318 Mon Sep 17 00:00:00 2001 From: Phenom Date: Sat, 30 Jul 2016 19:14:59 +0200 Subject: [PATCH 10/22] Fix IdChooser in Signed Lobby. So you cannot choose an unsigned Id. --- retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp b/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp index afdfeb8a9..aeb748db8 100644 --- a/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp +++ b/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp @@ -135,8 +135,15 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::Wi RsGxsId current_id; rsMsgs->getIdentityForChatLobby(lobbyId, current_id); + uint32_t idChooserFlag = IDCHOOSER_ID_REQUIRED; + ChatLobbyInfo lobbyInfo ; + if(rsMsgs->getChatLobbyInfo(lobbyId,lobbyInfo)) { + if (lobbyInfo.lobby_flags & RS_CHAT_LOBBY_FLAGS_PGP_SIGNED) { + idChooserFlag |= IDCHOOSER_NON_ANONYMOUS; + } + } ownIdChooser = new GxsIdChooser() ; - ownIdChooser->loadIds(IDCHOOSER_ID_REQUIRED,current_id) ; + ownIdChooser->loadIds(idChooserFlag, current_id) ; QWidgetAction *checkableAction = new QWidgetAction(this); checkableAction->setDefaultWidget(ownIdChooser); @@ -281,8 +288,6 @@ void ChatLobbyDialog::init() QString title; - std::list::const_iterator lobbyIt; - if(rsMsgs->getChatLobbyInfo(lobbyId,linfo)) { title = QString::fromUtf8(linfo.lobby_name.c_str()); From 998fede7e78333a012d21c177b735e86165f83be Mon Sep 17 00:00:00 2001 From: Phenom Date: Sun, 31 Jul 2016 11:15:47 +0200 Subject: [PATCH 11/22] Fix IdDialog ContextMenu shown at startup. --- retroshare-gui/src/gui/Identity/IdDialog.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/retroshare-gui/src/gui/Identity/IdDialog.cpp b/retroshare-gui/src/gui/Identity/IdDialog.cpp index 80a501a97..24b4e33c4 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDialog.cpp @@ -225,7 +225,6 @@ IdDialog::IdDialog(QWidget *parent) : /* Add filter types */ QMenu *idTWHMenu = new QMenu(tr("Show"), this); - idTWHMenu->setVisible(true); ui->idTreeWidget->addHeaderContextMenuMenu(idTWHMenu); QActionGroup *idTWHActionGroup = new QActionGroup(this); From 03179043f17bb7d0408f907538e26733d0af45ca Mon Sep 17 00:00:00 2001 From: Phenom Date: Sun, 31 Jul 2016 16:08:15 +0200 Subject: [PATCH 12/22] Add Remove Duplicate checkbox in RsCollection editor. If unchecked, you can add the same file (same hash) in multiple directories. --- .../src/gui/common/RsCollectionDialog.cpp | 107 +++++++++++++++++- .../src/gui/common/RsCollectionDialog.h | 1 + .../src/gui/common/RsCollectionDialog.ui | 68 +++++++++-- 3 files changed, 161 insertions(+), 15 deletions(-) diff --git a/retroshare-gui/src/gui/common/RsCollectionDialog.cpp b/retroshare-gui/src/gui/common/RsCollectionDialog.cpp index 211d31cc2..9cb5b268f 100644 --- a/retroshare-gui/src/gui/common/RsCollectionDialog.cpp +++ b/retroshare-gui/src/gui/common/RsCollectionDialog.cpp @@ -160,6 +160,7 @@ RsCollectionDialog::RsCollectionDialog(const QString& collectionFileName connect(ui._addRecur_PB, SIGNAL(clicked()), this, SLOT(addRecursive())); connect(ui._remove_PB, SIGNAL(clicked()), this, SLOT(remove())); connect(ui._makeDir_PB, SIGNAL(clicked()), this, SLOT(makeDir())); + connect(ui._removeDuplicate_CB, SIGNAL(clicked(bool)), this, SLOT(updateRemoveDuplicate(bool))); connect(ui._cancel_PB, SIGNAL(clicked()), this, SLOT(cancel())); connect(ui._save_PB, SIGNAL(clicked()), this, SLOT(save())); connect(ui._download_PB, SIGNAL(clicked()), this, SLOT(download())); @@ -190,6 +191,7 @@ RsCollectionDialog::RsCollectionDialog(const QString& collectionFileName // 5 Activate button follow creationMode ui._changeFile->setVisible(_creationMode && !_readOnly); ui._makeDir_PB->setVisible(_creationMode && !_readOnly); + ui._removeDuplicate_CB->setVisible(_creationMode && !_readOnly); ui._save_PB->setVisible(_creationMode && !_readOnly); ui._treeViewFrame->setVisible(_creationMode && !_readOnly); ui._download_PB->setVisible(!_creationMode && !_readOnly); @@ -408,7 +410,10 @@ bool RsCollectionDialog::addChild(QTreeWidgetItem* parent, const std::vectorfindItems(colFileInfo.path + "/" +colFileInfo.name, Qt::MatchExactly | Qt::MatchRecursive, COLUMN_FILEPATH); } else { - founds = ui._fileEntriesTW->findItems(colFileInfo.hash, Qt::MatchExactly | Qt::MatchRecursive, COLUMN_HASH); + founds = ui._fileEntriesTW->findItems(colFileInfo.path + "/" +colFileInfo.name, Qt::MatchExactly | Qt::MatchRecursive, COLUMN_FILEPATH); + if (ui._removeDuplicate_CB->isChecked()) { + founds << ui._fileEntriesTW->findItems(colFileInfo.hash, Qt::MatchExactly | Qt::MatchRecursive, COLUMN_HASH); + } } if (founds.empty()) { QTreeWidgetItem *item = new QTreeWidgetItem; @@ -493,7 +498,8 @@ bool RsCollectionDialog::addChild(QTreeWidgetItem* parent, const std::vectorsetInformativeText(); If text too long, no scroll, so I add an text edit QGridLayout* layout = qobject_cast(msgBox->layout()); if (layout) { - QTextEdit* edit = new QTextEdit(tr("Do you want to remove them and all their children, too?
") + listDir); + int newRow = 1; + for (int row = layout->count()-1; row >= 0; --row) { + for (int col = layout->columnCount()-1; col >= 0; --col) { + QLayoutItem *item = layout->itemAtPosition(row, col); + if (item) { + int index = layout->indexOf(item->widget()); + int r=0, c=0, rSpan=0, cSpan=0; + layout->getItemPosition(index, &r, &c, &rSpan, &cSpan); + if (r>0) { + layout->removeItem(item); + layout->addItem(item, r+3, c, rSpan, cSpan); + } else if (rSpan>1) { + newRow = rSpan + 1; + } + } + } + } + QLabel *label = new QLabel(tr("Do you want to remove them and all their children, too?")); + layout->addWidget(label,newRow, 0, 1, layout->columnCount(), Qt::AlignHCenter ); + QTextEdit *edit = new QTextEdit(listDir); edit->setReadOnly(true); - layout->addWidget(edit,0 ,1); + edit->setWordWrapMode(QTextOption::NoWrap); + layout->addWidget(edit,newRow+1, 0, 1, layout->columnCount(), Qt::AlignHCenter ); } msgBox->setStandardButtons(QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel); @@ -1063,6 +1089,79 @@ void RsCollectionDialog::itemChanged(QTreeWidgetItem *item, int col) } +/** + * @brief RsCollectionDialog::updateRemoveDuplicate Remove all duplicate file when checked. + * @param checked + */ +void RsCollectionDialog::updateRemoveDuplicate(bool checked) +{ + if (checked) { + QTreeWidgetItemIterator it(ui._fileEntriesTW); + QTreeWidgetItem *item; + while ((item = *it) != NULL) { + ++it; + if (item->data(COLUMN_HASH, ROLE_TYPE).toUInt() != DIR_TYPE_DIR) { + QList founds; + founds << ui._fileEntriesTW->findItems(item->text(COLUMN_HASH), Qt::MatchExactly | Qt::MatchRecursive, COLUMN_HASH); + if (founds.count() > 1) { + QMessageBox* msgBox = new QMessageBox(QMessageBox::Information, "", ""); + msgBox->setText("Warning, duplicate file found."); + //msgBox->setInformativeText(); If text too long, no scroll, so I add an text edit + msgBox->setStandardButtons(QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel); + msgBox->setDefaultButton(QMessageBox::Yes); + + QGridLayout* layout = qobject_cast(msgBox->layout()); + if (layout) { + int newRow = 1; + for (int row = layout->count()-1; row >= 0; --row) { + for (int col = layout->columnCount()-1; col >= 0; --col) { + QLayoutItem *item = layout->itemAtPosition(row, col); + if (item) { + int index = layout->indexOf(item->widget()); + int r=0, c=0, rSpan=0, cSpan=0; + layout->getItemPosition(index, &r, &c, &rSpan, &cSpan); + if (r>0) { + layout->removeItem(item); + layout->addItem(item, r+3, c, rSpan, cSpan); + } else if (rSpan>1) { + newRow = rSpan + 1; + } + } + } + } + QLabel *label = new QLabel(tr("Do you want to remove this file from the list?")); + layout->addWidget(label,newRow, 0, 1, layout->columnCount(), Qt::AlignHCenter ); + QTextEdit *edit = new QTextEdit(item->text(COLUMN_FILEPATH)); + edit->setReadOnly(true); + edit->setWordWrapMode(QTextOption::NoWrap); + layout->addWidget(edit,newRow+1, 0, 1, layout->columnCount(), Qt::AlignHCenter ); + } + + int ret = msgBox->exec(); + switch (ret) { + case QMessageBox::Yes: + item->parent()->removeChild(item); + break; + case QMessageBox::No: + break; + case QMessageBox::Cancel: { + delete msgBox; + ui._removeDuplicate_CB->setChecked(true); + return; + } + break; + default: + // should never be reached + break; + } + delete msgBox; + + } + } + } + } +} + /** * @brief RsCollectionDialog::cancel: Cancel RScollection editing or donwloading */ diff --git a/retroshare-gui/src/gui/common/RsCollectionDialog.h b/retroshare-gui/src/gui/common/RsCollectionDialog.h index 4cc174f92..eb9233928 100644 --- a/retroshare-gui/src/gui/common/RsCollectionDialog.h +++ b/retroshare-gui/src/gui/common/RsCollectionDialog.h @@ -56,6 +56,7 @@ private slots: void makeDir() ; void fileHashingFinished(QList hashedFiles) ; void itemChanged(QTreeWidgetItem* item,int col) ; + void updateRemoveDuplicate(bool checked); void cancel() ; void download() ; void save() ; diff --git a/retroshare-gui/src/gui/common/RsCollectionDialog.ui b/retroshare-gui/src/gui/common/RsCollectionDialog.ui index 89a739e42..78e736c24 100644 --- a/retroshare-gui/src/gui/common/RsCollectionDialog.ui +++ b/retroshare-gui/src/gui/common/RsCollectionDialog.ui @@ -21,7 +21,16 @@ true - + + 0 + + + 0 + + + 0 + + 0 @@ -59,7 +68,16 @@ QFrame::Plain - + + 0 + + + 0 + + + 0 + + 0 @@ -83,7 +101,16 @@ 0 - + + 0 + + + 0 + + + 0 + + 0 @@ -197,7 +224,16 @@ 0 - + + 0 + + + 0 + + + 0 + + 0 @@ -207,7 +243,16 @@ - + + 0 + + + 0 + + + 0 + + 0 @@ -359,6 +404,13 @@ + + + + Remove Duplicate + + + @@ -405,12 +457,6 @@ - - - _mainSplitter - _listSplitter - - _mainSplitter From 6935441e4fb059a65f381fb5cf101195e7d009b3 Mon Sep 17 00:00:00 2001 From: Phenom Date: Sun, 31 Jul 2016 16:23:41 +0200 Subject: [PATCH 13/22] Fix other QFileDialog call in misc adding DontUseNativeDialog option. --- retroshare-gui/src/util/misc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/retroshare-gui/src/util/misc.cpp b/retroshare-gui/src/util/misc.cpp index f7566386c..91cd83b2f 100644 --- a/retroshare-gui/src/util/misc.cpp +++ b/retroshare-gui/src/util/misc.cpp @@ -352,7 +352,7 @@ bool misc::getSaveFileName(QWidget *parent, RshareSettings::enumLastDir type { QString lastDir = Settings->getLastDir(type); - file = QFileDialog::getSaveFileName(parent, caption, lastDir, filter, selectedFilter, options); + file = QFileDialog::getSaveFileName(parent, caption, lastDir, filter, selectedFilter, QFileDialog::DontUseNativeDialog | options); if (file.isEmpty()) return false; From d000d75a3880903a351f7a23fce7c26ab4412f2a Mon Sep 17 00:00:00 2001 From: Phenom Date: Sun, 31 Jul 2016 21:03:45 +0200 Subject: [PATCH 14/22] Fix Import and Export Cert file *.asc. --- retroshare-gui/src/gui/GenCertDialog.cpp | 6 +++--- retroshare-gui/src/gui/profile/ProfileManager.cpp | 4 +--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/retroshare-gui/src/gui/GenCertDialog.cpp b/retroshare-gui/src/gui/GenCertDialog.cpp index ab96e434f..3a6e4a349 100644 --- a/retroshare-gui/src/gui/GenCertDialog.cpp +++ b/retroshare-gui/src/gui/GenCertDialog.cpp @@ -402,8 +402,8 @@ void GenCertDialog::exportIdentity() { QString fname = QFileDialog::getSaveFileName(this,tr("Export profile"), "",tr("RetroShare profile files (*.asc)")) ; - if(fname.isNull()) - return ; + if(fname.isNull()) return ; + if(fname.right(4).toUpper() != ".ASC") fname += ".asc"; QVariant data = ui.genPGPuser->itemData(ui.genPGPuser->currentIndex()); RsPgpId gpg_id (data.toString().toStdString()) ; @@ -416,7 +416,7 @@ void GenCertDialog::exportIdentity() void GenCertDialog::importIdentity() { - QString fname = QFileDialog::getOpenFileName(this,tr("Import profile"), "",tr("RetroShare profile files (*.asc)")) ; + QString fname = QFileDialog::getOpenFileName(this,tr("Import profile"), "",tr("RetroShare profile files (*.asc);;All Files (*)")) ; if(fname.isNull()) return ; diff --git a/retroshare-gui/src/gui/profile/ProfileManager.cpp b/retroshare-gui/src/gui/profile/ProfileManager.cpp index 77a6c2b0b..fb5e0f93d 100644 --- a/retroshare-gui/src/gui/profile/ProfileManager.cpp +++ b/retroshare-gui/src/gui/profile/ProfileManager.cpp @@ -135,9 +135,7 @@ void ProfileManager::exportIdentity() if (fname.isNull()) return; - if (QFileInfo(fname).suffix().isEmpty()) { - fname += ".asc"; - } + if (fname.right(4).toUpper() != ".ASC") fname += ".asc"; if (RsAccounts::ExportIdentity(fname.toUtf8().constData(), gpgId)) QMessageBox::information(this, tr("Identity saved"), tr("Your identity was successfully saved\nIt is encrypted\n\nYou can now copy it to another computer\nand use the import button to load it")); From 5fac5a8d760fe06c26874b8c10cb77168f4748ee Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 31 Jul 2016 22:14:23 +0200 Subject: [PATCH 15/22] moved all getOpenFilename to use misc::getOpenFilename --- retroshare-gui/src/gui/GenCertDialog.cpp | 6 +++++- retroshare-gui/src/gui/PluginManagerWidget.cpp | 9 +++------ retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp | 6 +++++- retroshare-gui/src/gui/profile/ProfileManager.cpp | 7 ++++++- retroshare-gui/src/gui/settings/rsharesettings.h | 5 +++-- 5 files changed, 22 insertions(+), 11 deletions(-) diff --git a/retroshare-gui/src/gui/GenCertDialog.cpp b/retroshare-gui/src/gui/GenCertDialog.cpp index 3a6e4a349..555a35f7f 100644 --- a/retroshare-gui/src/gui/GenCertDialog.cpp +++ b/retroshare-gui/src/gui/GenCertDialog.cpp @@ -23,6 +23,8 @@ #include #include #include +#include "gui/settings/rsharesettings.h" +#include "util/misc.h" #include "GenCertDialog.h" #include #include @@ -416,7 +418,9 @@ void GenCertDialog::exportIdentity() void GenCertDialog::importIdentity() { - QString fname = QFileDialog::getOpenFileName(this,tr("Import profile"), "",tr("RetroShare profile files (*.asc);;All Files (*)")) ; + QString fname ; + if(!misc::getOpenFileName(this,RshareSettings::LASTDIR_CERT,tr("Import profile"), tr("RetroShare profile files (*.asc);;All files (*)"),fname)) + return ; if(fname.isNull()) return ; diff --git a/retroshare-gui/src/gui/PluginManagerWidget.cpp b/retroshare-gui/src/gui/PluginManagerWidget.cpp index eda4ec62c..4179dfd45 100644 --- a/retroshare-gui/src/gui/PluginManagerWidget.cpp +++ b/retroshare-gui/src/gui/PluginManagerWidget.cpp @@ -20,6 +20,7 @@ ****************************************************************/ #include "PluginManagerWidget.h" +#include "gui/settings/rsharesettings.h" #include #include @@ -160,14 +161,10 @@ PluginManagerWidget::registerNewPlugin(QString pluginName) void PluginManagerWidget::installPluginButtonClicked() { - QString fileName = QFileDialog::getOpenFileName(this, - tr("Open Plugin to install"), - "./", - tr("Plugins (*.so *.dll)")); + QString fileName = misc::getOpenFileName(this, RshareSettings::LASTDIR_PLUGIN, tr("Open Plugin to install"), "./", tr("Plugins (*.so *.dll)")); + if (!fileName.isNull()) - { emit installPluginRequested(fileName); - } } //============================================================================= diff --git a/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp b/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp index afbcb4422..cb49de349 100755 --- a/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp +++ b/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp @@ -31,6 +31,8 @@ #include #endif +#include "gui/settings/rsharesettings.h" +#include "util/misc.h" #include "ConnectFriendWizard.h" #include "ui_ConnectFriendWizard.h" #include "gui/common/PeerDefs.h" @@ -1040,7 +1042,9 @@ void ConnectFriendWizard::saveCert() void ConnectFriendWizard::loadFriendCert() { - QString fileName = QFileDialog::getOpenFileName(this, tr("Select Certificate"), "", tr("RetroShare Certificate (*.rsc );;All Files (*)")); + QString fileName ; + if(!misc::getOpenFileName(this, RshareSettings::LASTDIR_CERT, tr("Select Certificate"), tr("RetroShare Certificate (*.rsc );;All Files (*)"),fileName)) + return ; if (!fileName.isNull()) { ui->friendFileNameEdit->setText(fileName); diff --git a/retroshare-gui/src/gui/profile/ProfileManager.cpp b/retroshare-gui/src/gui/profile/ProfileManager.cpp index fb5e0f93d..e57602300 100644 --- a/retroshare-gui/src/gui/profile/ProfileManager.cpp +++ b/retroshare-gui/src/gui/profile/ProfileManager.cpp @@ -24,7 +24,9 @@ #include #include #include "ProfileManager.h" +#include "util/misc.h" #include "gui/GenCertDialog.h" +#include "gui/settings/rsharesettings.h" #include "gui/common/RSTreeWidgetItem.h" #include @@ -145,7 +147,10 @@ void ProfileManager::exportIdentity() void ProfileManager::importIdentity() { - QString fname = QFileDialog::getOpenFileName(this,tr("Import Identity"), "",tr("RetroShare Identity files (*.asc)")) ; + QString fname ; + + if(!misc::getOpenFileName(this,RshareSettings::LASTDIR_CERT,tr("Import Identity"), tr("RetroShare Identity files (*.asc)"),fname)) + return ; if(fname.isNull()) return ; diff --git a/retroshare-gui/src/gui/settings/rsharesettings.h b/retroshare-gui/src/gui/settings/rsharesettings.h index b6db98591..a7719c6d0 100644 --- a/retroshare-gui/src/gui/settings/rsharesettings.h +++ b/retroshare-gui/src/gui/settings/rsharesettings.h @@ -75,8 +75,9 @@ public: LASTDIR_IMAGES, LASTDIR_MESSAGES, LASTDIR_BLOGS, - LASTDIR_SOUNDS - }; + LASTDIR_SOUNDS, + LASTDIR_PLUGIN + }; enum enumToasterPosition { From b1288bcb7e6bd6e2df82f0c6071b6c649c7fc045 Mon Sep 17 00:00:00 2001 From: csoler Date: Mon, 1 Aug 2016 14:43:17 +0200 Subject: [PATCH 16/22] added missing time stamp of msgServerUpdateMap when posting a new message --- libretroshare/src/gxs/rsgenexchange.cc | 3 ++ libretroshare/src/gxs/rsgenexchange.h | 8 +++++ libretroshare/src/gxs/rsgxsnetservice.cc | 40 ++++++++++++++++++------ libretroshare/src/gxs/rsgxsnetservice.h | 3 +- libretroshare/src/gxs/rsnxs.h | 9 ++++++ 5 files changed, 53 insertions(+), 10 deletions(-) diff --git a/libretroshare/src/gxs/rsgenexchange.cc b/libretroshare/src/gxs/rsgenexchange.cc index 198954297..ec1b4eff5 100644 --- a/libretroshare/src/gxs/rsgenexchange.cc +++ b/libretroshare/src/gxs/rsgenexchange.cc @@ -2019,6 +2019,9 @@ void RsGenExchange::publishMsgs() delete[] metaDataBuff; + if(mNetService != NULL) + mNetService->stampMsgServerUpdateTS(grpId) ; + // add to published to allow acknowledgement mMsgNotify.insert(std::make_pair(mit->first, std::make_pair(grpId, msgId))); mDataAccess->updatePublicRequestStatus(mit->first, RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE); diff --git a/libretroshare/src/gxs/rsgenexchange.h b/libretroshare/src/gxs/rsgenexchange.h index 6535ef510..2e15016e2 100644 --- a/libretroshare/src/gxs/rsgenexchange.h +++ b/libretroshare/src/gxs/rsgenexchange.h @@ -595,6 +595,14 @@ public: */ void setGroupReputationCutOff(uint32_t& token, const RsGxsGroupId& grpId, int CutOff); + /*! + * + * @param token value set to be redeemed with acknowledgement + * @param grpId group id of the group to update + * @param CutOff The cut off value to set + */ + void updateGroupLastMsgTimeStamp(uint32_t& token, const RsGxsGroupId& grpId); + /*! * @return storage time of messages in months */ diff --git a/libretroshare/src/gxs/rsgxsnetservice.cc b/libretroshare/src/gxs/rsgxsnetservice.cc index 6c20c408f..d36c7fc02 100644 --- a/libretroshare/src/gxs/rsgxsnetservice.cc +++ b/libretroshare/src/gxs/rsgxsnetservice.cc @@ -761,11 +761,11 @@ void RsGxsNetService::syncWithPeers() msg->updateTS = updateTS; if(encrypt_to_this_circle_id.isNull()) - msg->grpId = grpId; + msg->grpId = grpId; else { - msg->grpId = hashGrpId(grpId,mNetMgr->getOwnId()) ; - msg->flag |= RsNxsSyncMsgReqItem::FLAG_USE_HASHED_GROUP_ID ; + msg->grpId = hashGrpId(grpId,mNetMgr->getOwnId()) ; + msg->flag |= RsNxsSyncMsgReqItem::FLAG_USE_HASHED_GROUP_ID ; } #ifdef NXS_NET_DEBUG_7 @@ -2096,14 +2096,16 @@ void RsGxsNetService::updateServerSyncTS() else msui = mapIT->second; - if(grpMeta->mLastPost > msui->msgUpdateTS ) - { - change = true; - msui->msgUpdateTS = grpMeta->mLastPost; + // (cyril) I'm removing this, becuse mLastPost is *never* updated. So this code it not useful at all. + // + // if(grpMeta->mLastPost > msui->msgUpdateTS ) + // { + // change = true; + // msui->msgUpdateTS = grpMeta->mLastPost; #ifdef NXS_NET_DEBUG_0 - GXSNETDEBUG__G(grpId) << " updated msgUpdateTS to last post = " << time(NULL) - grpMeta->mLastPost << " secs ago for group "<< grpId << std::endl; + // GXSNETDEBUG__G(grpId) << " updated msgUpdateTS to last post = " << time(NULL) - grpMeta->mLastPost << " secs ago for group "<< grpId << std::endl; #endif - } + // } // This is needed for group metadata updates to actually propagate: only a new grpUpdateTS will trigger the exchange of groups mPublishTs which // will then be compared and pssibly trigger a MetaData transmission. mRecvTS is upated when creating, receiving for the first time, or receiving @@ -2123,6 +2125,7 @@ void RsGxsNetService::updateServerSyncTS() if(change) IndicateConfigChanged(); } + bool RsGxsNetService::locked_checkTransacTimedOut(NxsTransaction* tr) { return tr->mTimeOut < ((uint32_t) time(NULL)); @@ -4891,3 +4894,22 @@ bool RsGxsNetService::getGroupServerUpdateTS(const RsGxsGroupId& gid,time_t& gro return true ; } + +bool RsGxsNetService::stampMsgServerUpdateTS(const RsGxsGroupId& gid) +{ + RS_STACK_MUTEX(mNxsMutex) ; + + std::map::iterator it = mServerMsgUpdateMap.find(gid) ; + + if(mServerMsgUpdateMap.end() == it) + { + RsGxsServerMsgUpdateItem *item = new RsGxsServerMsgUpdateItem(mServType); + item->grpId = gid ; + item->msgUpdateTS = time(NULL) ; + } + else + it->second->msgUpdateTS = time(NULL) ; + + return true; +} + diff --git a/libretroshare/src/gxs/rsgxsnetservice.h b/libretroshare/src/gxs/rsgxsnetservice.h index 296e17937..7be962ea9 100644 --- a/libretroshare/src/gxs/rsgxsnetservice.h +++ b/libretroshare/src/gxs/rsgxsnetservice.h @@ -155,7 +155,8 @@ public: virtual void rejectMessage(const RsGxsMessageId& msg_id) ; virtual bool getGroupServerUpdateTS(const RsGxsGroupId& gid,time_t& grp_server_update_TS,time_t& msg_server_update_TS) ; - + virtual bool stampMsgServerUpdateTS(const RsGxsGroupId& gid) ; + /* p3Config methods */ public: diff --git a/libretroshare/src/gxs/rsnxs.h b/libretroshare/src/gxs/rsnxs.h index 4a083a0f6..13eb6fedb 100644 --- a/libretroshare/src/gxs/rsnxs.h +++ b/libretroshare/src/gxs/rsnxs.h @@ -144,6 +144,15 @@ public: * \return false if the group is not found, true otherwise */ virtual bool getGroupServerUpdateTS(const RsGxsGroupId& gid,time_t& grp_server_update_TS,time_t& msg_server_update_TS) =0; + + /*! + * \brief stampMsgServerUpdateTS + * Updates the msgServerUpdateMap structure to time(NULL), so as to trigger sending msg lists to friends. + * This is needed when e.g. posting a new message to a group. + * \param gid the group to stamp in msgServerUpdateMap + * \return + */ + virtual bool stampMsgServerUpdateTS(const RsGxsGroupId& gid) =0; }; #endif // RSGNP_H From d6be4404d2cd9615f958d020ca6862b2dc014990 Mon Sep 17 00:00:00 2001 From: csoler Date: Mon, 1 Aug 2016 15:38:51 +0200 Subject: [PATCH 17/22] re-enabled some code previously disabled in last commit --- libretroshare/src/gxs/rsgxsnetservice.cc | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/libretroshare/src/gxs/rsgxsnetservice.cc b/libretroshare/src/gxs/rsgxsnetservice.cc index d36c7fc02..302871bc5 100644 --- a/libretroshare/src/gxs/rsgxsnetservice.cc +++ b/libretroshare/src/gxs/rsgxsnetservice.cc @@ -2096,16 +2096,14 @@ void RsGxsNetService::updateServerSyncTS() else msui = mapIT->second; - // (cyril) I'm removing this, becuse mLastPost is *never* updated. So this code it not useful at all. - // - // if(grpMeta->mLastPost > msui->msgUpdateTS ) - // { - // change = true; - // msui->msgUpdateTS = grpMeta->mLastPost; + if(grpMeta->mLastPost > msui->msgUpdateTS ) + { + change = true; + msui->msgUpdateTS = grpMeta->mLastPost; #ifdef NXS_NET_DEBUG_0 - // GXSNETDEBUG__G(grpId) << " updated msgUpdateTS to last post = " << time(NULL) - grpMeta->mLastPost << " secs ago for group "<< grpId << std::endl; + GXSNETDEBUG__G(grpId) << " updated msgUpdateTS to last post = " << time(NULL) - grpMeta->mLastPost << " secs ago for group "<< grpId << std::endl; #endif - // } + } // This is needed for group metadata updates to actually propagate: only a new grpUpdateTS will trigger the exchange of groups mPublishTs which // will then be compared and pssibly trigger a MetaData transmission. mRecvTS is upated when creating, receiving for the first time, or receiving From 3cd90ae11c27568659583e315eabd4161e478d16 Mon Sep 17 00:00:00 2001 From: csoler Date: Mon, 1 Aug 2016 16:35:19 +0200 Subject: [PATCH 18/22] re-disabled the code to update the server TS to last post as it can severely perturbate the distribution of posts. Added a call to update msgServerUpdateMap when new messages received --- libretroshare/src/gxs/rsgxsnetservice.cc | 22 +++++++++++++++------- libretroshare/src/gxs/rsgxsnetservice.h | 7 +++++++ 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/libretroshare/src/gxs/rsgxsnetservice.cc b/libretroshare/src/gxs/rsgxsnetservice.cc index 302871bc5..61d1bcf38 100644 --- a/libretroshare/src/gxs/rsgxsnetservice.cc +++ b/libretroshare/src/gxs/rsgxsnetservice.cc @@ -2096,14 +2096,16 @@ void RsGxsNetService::updateServerSyncTS() else msui = mapIT->second; - if(grpMeta->mLastPost > msui->msgUpdateTS ) - { - change = true; - msui->msgUpdateTS = grpMeta->mLastPost; + // (cyril) I'm removing this, becuse mLastPost is *never* updated. So this code it not useful at all. + // + // if(grpMeta->mLastPost > msui->msgUpdateTS ) + // { + // change = true; + // msui->msgUpdateTS = grpMeta->mLastPost; #ifdef NXS_NET_DEBUG_0 - GXSNETDEBUG__G(grpId) << " updated msgUpdateTS to last post = " << time(NULL) - grpMeta->mLastPost << " secs ago for group "<< grpId << std::endl; + // GXSNETDEBUG__G(grpId) << " updated msgUpdateTS to last post = " << time(NULL) - grpMeta->mLastPost << " secs ago for group "<< grpId << std::endl; #endif - } + // } // This is needed for group metadata updates to actually propagate: only a new grpUpdateTS will trigger the exchange of groups mPublishTs which // will then be compared and pssibly trigger a MetaData transmission. mRecvTS is upated when creating, receiving for the first time, or receiving @@ -2596,6 +2598,8 @@ void RsGxsNetService::locked_processCompletedIncomingTrans(NxsTransaction* tr) // for the grp id locked_doMsgUpdateWork(tr->mTransaction, grpId); + // also update server sync TS, since we need to send the new message list to friends for comparison + locked_stampMsgServerUpdateTS(grpId); } } else if(tr->mFlag == NxsTransaction::FLAG_STATE_FAILED) @@ -4897,6 +4901,11 @@ bool RsGxsNetService::stampMsgServerUpdateTS(const RsGxsGroupId& gid) { RS_STACK_MUTEX(mNxsMutex) ; + locked_stampMsgServerUpdateTS(gid) ; +} + +bool RsGxsNetService::locked_stampMsgServerUpdateTS(const RsGxsGroupId& gid) +{ std::map::iterator it = mServerMsgUpdateMap.find(gid) ; if(mServerMsgUpdateMap.end() == it) @@ -4910,4 +4919,3 @@ bool RsGxsNetService::stampMsgServerUpdateTS(const RsGxsGroupId& gid) return true; } - diff --git a/libretroshare/src/gxs/rsgxsnetservice.h b/libretroshare/src/gxs/rsgxsnetservice.h index 7be962ea9..455b547d0 100644 --- a/libretroshare/src/gxs/rsgxsnetservice.h +++ b/libretroshare/src/gxs/rsgxsnetservice.h @@ -229,6 +229,13 @@ private: */ void locked_completeTransaction(NxsTransaction* trans); + /*! + * \brief locked_stampMsgServerUpdateTS + * updates the server msg time stamp. This function is the locked method for the one above with similar name + * \param gid group id to stamp. + * \return + */ + bool locked_stampMsgServerUpdateTS(const RsGxsGroupId& gid); /*! * This retrieves a unique transaction id that * can be used in an outgoing transaction From 17003f136b0a4b1363d7b75d0dab27624df613f3 Mon Sep 17 00:00:00 2001 From: csoler Date: Tue, 2 Aug 2016 16:25:00 +0200 Subject: [PATCH 19/22] modified wrong comment in why mLastPost should not be used in rsgxsnetservice.cc, and added a call to clearing GrpMeta cache when new msg in that group are received --- libretroshare/src/gxs/rsdataservice.cc | 42 +++++++++++++----------- libretroshare/src/gxs/rsgxsnetservice.cc | 5 ++- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/libretroshare/src/gxs/rsdataservice.cc b/libretroshare/src/gxs/rsdataservice.cc index d6038f7e7..b2bf71434 100644 --- a/libretroshare/src/gxs/rsdataservice.cc +++ b/libretroshare/src/gxs/rsdataservice.cc @@ -712,25 +712,25 @@ int RsDataService::storeMessage(std::map &msg) // start a transaction mDb->beginTransaction(); - for(; mit != msg.end(); ++mit){ - + for(; mit != msg.end(); ++mit) + { RsNxsMsg* msgPtr = mit->first; RsGxsMsgMetaData* msgMetaPtr = mit->second; #ifdef RS_DATA_SERVICE_DEBUG - std::cerr << "RsDataService::storeMessage() "; - std::cerr << " GroupId: " << msgMetaPtr->mGroupId.toStdString(); - std::cerr << " MessageId: " << msgMetaPtr->mMsgId.toStdString(); - std::cerr << std::endl; + std::cerr << "RsDataService::storeMessage() "; + std::cerr << " GroupId: " << msgMetaPtr->mGroupId.toStdString(); + std::cerr << " MessageId: " << msgMetaPtr->mMsgId.toStdString(); + std::cerr << std::endl; #endif // skip msg item if size if greater than if(!validSize(msgPtr)) - { - std::cerr << "RsDataService::storeMessage() ERROR invalid size"; - std::cerr << std::endl; - continue; - } + { + std::cerr << "RsDataService::storeMessage() ERROR invalid size"; + std::cerr << std::endl; + continue; + } ContentValue cv; @@ -773,14 +773,18 @@ int RsDataService::storeMessage(std::map &msg) cv.put(KEY_CHILD_TS, (int32_t)msgMetaPtr->mChildTs); if (!mDb->sqlInsert(MSG_TABLE_NAME, "", cv)) - { - std::cerr << "RsDataService::storeMessage() sqlInsert Failed"; - std::cerr << std::endl; - std::cerr << "\t For GroupId: " << msgMetaPtr->mGroupId.toStdString(); - std::cerr << std::endl; - std::cerr << "\t & MessageId: " << msgMetaPtr->mMsgId.toStdString(); - std::cerr << std::endl; - } + { + std::cerr << "RsDataService::storeMessage() sqlInsert Failed"; + std::cerr << std::endl; + std::cerr << "\t For GroupId: " << msgMetaPtr->mGroupId.toStdString(); + std::cerr << std::endl; + std::cerr << "\t & MessageId: " << msgMetaPtr->mMsgId.toStdString(); + std::cerr << std::endl; + } + + // This is needed so that mLastPost is correctly updated in the group meta when it is re-loaded. + + locked_clearGrpMetaCache(msgMetaPtr->mGroupId); } // finish transaction diff --git a/libretroshare/src/gxs/rsgxsnetservice.cc b/libretroshare/src/gxs/rsgxsnetservice.cc index 61d1bcf38..8a0b26e0d 100644 --- a/libretroshare/src/gxs/rsgxsnetservice.cc +++ b/libretroshare/src/gxs/rsgxsnetservice.cc @@ -2096,7 +2096,10 @@ void RsGxsNetService::updateServerSyncTS() else msui = mapIT->second; - // (cyril) I'm removing this, becuse mLastPost is *never* updated. So this code it not useful at all. + // (cyril) I'm removing this, because the msgUpdateTS is updated when new messages are received by calling locked_stampMsgServerUpdateTS(). + // mLastPost is actually updated somewhere when loading group meta data. It's not clear yet whether it is set to the latest publish time (wrong) + // or the latest receive time (right). The former would cause problems because it would need to compare times coming from different (potentially async-ed) + // machines. // // if(grpMeta->mLastPost > msui->msgUpdateTS ) // { From e4e29c5adc38d04008757cba9337d460c952027b Mon Sep 17 00:00:00 2001 From: Gio Date: Wed, 3 Aug 2016 00:50:49 +0200 Subject: [PATCH 20/22] quit ApiLocalConnectionHandler after replying API query --- libresapi/src/api/ApiServerLocal.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/libresapi/src/api/ApiServerLocal.cpp b/libresapi/src/api/ApiServerLocal.cpp index e1d5e2623..c130ca5e1 100644 --- a/libresapi/src/api/ApiServerLocal.cpp +++ b/libresapi/src/api/ApiServerLocal.cpp @@ -52,6 +52,7 @@ void ApiLocalConnectionHandler::handleRequest() std::string resultString = mApiServer->handleRequest(req); mLocalSocket->write(resultString.c_str(), resultString.length()); mLocalSocket->write("\n\0"); + quit(); } else { From 353308e2a50e86b9ceb8498d50faff445273768f Mon Sep 17 00:00:00 2001 From: Gio Date: Wed, 3 Aug 2016 14:35:45 +0200 Subject: [PATCH 21/22] ApiLocalConnectionHandler class quit() at the end outside if --- libresapi/src/api/ApiServerLocal.cpp | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/libresapi/src/api/ApiServerLocal.cpp b/libresapi/src/api/ApiServerLocal.cpp index c130ca5e1..b53a356cc 100644 --- a/libresapi/src/api/ApiServerLocal.cpp +++ b/libresapi/src/api/ApiServerLocal.cpp @@ -52,19 +52,12 @@ void ApiLocalConnectionHandler::handleRequest() std::string resultString = mApiServer->handleRequest(req); mLocalSocket->write(resultString.c_str(), resultString.length()); mLocalSocket->write("\n\0"); - quit(); - } - else - { - mLocalSocket->write("\"{\"data\":null,\"debug_msg\":\"ApiLocalConnectionHandler::handleRequest() Error: timeout waiting for path.\\n\",\"returncode\":\"fail\"}\"\n\0"); - quit(); } + else mLocalSocket->write("\"{\"data\":null,\"debug_msg\":\"ApiLocalConnectionHandler::handleRequest() Error: timeout waiting for path.\\n\",\"returncode\":\"fail\"}\"\n\0"); } - else - { - mLocalSocket->write("{\"data\":null,\"debug_msg\":\"ApiLocalConnectionHandler::handleRequest() Error: timeout waiting for JSON data.\\n\",\"returncode\":\"fail\"}\"\n\0"); - quit(); - } + else mLocalSocket->write("{\"data\":null,\"debug_msg\":\"ApiLocalConnectionHandler::handleRequest() Error: timeout waiting for JSON data.\\n\",\"returncode\":\"fail\"}\"\n\0"); + + quit(); } ApiLocalConnectionHandler::~ApiLocalConnectionHandler() From 70228ee40558e2cf21e839aae2f946371b764af9 Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 4 Aug 2016 11:02:12 +0200 Subject: [PATCH 22/22] fixed missign return, probably causing crashes --- libretroshare/src/gxs/rsgxsnetservice.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libretroshare/src/gxs/rsgxsnetservice.cc b/libretroshare/src/gxs/rsgxsnetservice.cc index 8a0b26e0d..3cdc5a5b7 100644 --- a/libretroshare/src/gxs/rsgxsnetservice.cc +++ b/libretroshare/src/gxs/rsgxsnetservice.cc @@ -4904,7 +4904,7 @@ bool RsGxsNetService::stampMsgServerUpdateTS(const RsGxsGroupId& gid) { RS_STACK_MUTEX(mNxsMutex) ; - locked_stampMsgServerUpdateTS(gid) ; + return locked_stampMsgServerUpdateTS(gid) ; } bool RsGxsNetService::locked_stampMsgServerUpdateTS(const RsGxsGroupId& gid)