diff --git a/.gitignore b/.gitignore index 6f9356d05..777ba9433 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: (C) 2004-2019 Retroshare Team +# SPDX-FileCopyrightText: (C) 2004-2022 Retroshare Team # SPDX-License-Identifier: CC0-1.0 *.o @@ -17,3 +17,6 @@ Thumbs.db *.kdev4 !supportlibs/libsam3/Makefile + +# QtCreator cruft +*CMakeLists.txt.user diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8e96b8124..c91f867a5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -67,43 +67,3 @@ test-ubuntu: docker exec retroshare curl --verbose http://127.0.0.1:9092/rsMsgs/getChatLobbyList | jq - docker container stop retroshare - -build-android-arm-apk: - stage: build - script: - - mkdir Dockercontext - - > - docker build -t retroshare:android_arm_latest - $($CI_PROJECT_DIR/build_scripts/GitlabCI/getRepoArgs.sh) - --build-arg RS_SERVICE_QMAKE_EXTRA_OPTS="$RS_SERVICE_QMAKE_EXTRA_OPTS" - --file $CI_PROJECT_DIR/build_scripts/GitlabCI/Android.Dockerfile - Dockercontext -# see https://stackoverflow.com/a/59055906 - - > - docker cp - $(docker create --rm retroshare:android_arm_latest):/retroshare-service-android-build/android-build/build/outputs/apk/debug/android-build-debug.apk - $CI_PROJECT_DIR/RetroShare_Android_Service-arm.apk - artifacts: - paths: - - RetroShare_Android_Service-arm.apk - -# Use separate runner to avoid no space left on device -build-android-arm64-apk: - stage: build - script: - - mkdir Dockercontext - - > - docker build -t retroshare:android_arm64_latest - $($CI_PROJECT_DIR/build_scripts/GitlabCI/getRepoArgs.sh) - --build-arg ANDROID_PLATFORM_VER=21 - --build-arg ANDROID_NDK_ARCH=arm64 - --build-arg RS_SERVICE_QMAKE_EXTRA_OPTS="$RS_SERVICE_QMAKE_EXTRA_OPTS" - --file $CI_PROJECT_DIR/build_scripts/GitlabCI/Android.Dockerfile - Dockercontext - - > - docker cp - $(docker create --rm retroshare:android_arm64_latest):/retroshare-service-android-build/android-build/build/outputs/apk/debug/android-build-debug.apk - $CI_PROJECT_DIR/RetroShare_Android_Service-arm64.apk - artifacts: - paths: - - RetroShare_Android_Service-arm64.apk diff --git a/README.asciidoc b/README.asciidoc index 63890af9e..e1f41e74d 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -9,9 +9,10 @@ RetroShare provides file sharing, chat, messages, forums, channels and more. .Build Status |=============================================================================== -|GNU/Linux, Android (via Gitlab CI) | image:https://gitlab.com/RetroShare/RetroShare/badges/master/pipeline.svg[link="https://gitlab.com/RetroShare/RetroShare/-/commits/master",title="pipeline status"] +|GNU/Linux (via Gitlab CI) | image:https://gitlab.com/RetroShare/RetroShare/badges/master/pipeline.svg[link="https://gitlab.com/RetroShare/RetroShare/-/commits/master",title="pipeline status"] |Windows (via AppVeyor) | image:https://ci.appveyor.com/api/projects/status/github/RetroShare/RetroShare?svg=true[link="https://ci.appveyor.com/project/RetroShare58622/retroshare"] |macOS, (via Travis CI) | image:https://app.travis-ci.com/RetroShare/RetroShare.svg?branch=master[link="https://app.travis-ci.com/github/RetroShare/RetroShare"] +|libretroshare GNU/Linux, Android (via Gitlab CI) | image:https://gitlab.com/RetroShare/libretroshare/badges/master/pipeline.svg[link="https://gitlab.com/RetroShare/libretroshare/-/commits/master",title="pipeline status"] |=============================================================================== == Get the source diff --git a/build_scripts/GitlabCI/base.Dockerfile b/build_scripts/GitlabCI/base.Dockerfile index b65ed1776..60d122a88 100644 --- a/build_scripts/GitlabCI/base.Dockerfile +++ b/build_scripts/GitlabCI/base.Dockerfile @@ -12,16 +12,26 @@ ## To run the container # docker run -it -p 127.0.0.1:9092:9092 "${CI_REGISTRY_IMAGE}" retroshare-service --jsonApiPort 9092 --jsonApiBindAddress 0.0.0.0 -FROM ubuntu +FROM ubuntu:21.10 ENV DEBIAN_FRONTEND=noninteractive +ENV APT_UNAT="--assume-yes --quiet" -RUN apt-get update -y && apt-get upgrade -y -qq && \ - apt-get install -y -qq build-essential cimg-dev libssl-dev libbz2-dev \ - libsqlite3-dev \ - libsqlcipher-dev libupnp-dev pkg-config libz-dev \ - qt5-default libxapian-dev qttools5-dev doxygen rapidjson-dev \ - git cmake curl +RUN apt-get update $APT_UNAT && \ + apt-get upgrade --show-upgraded $APT_UNAT && \ + apt-get clean $APT_UNAT && \ + apt-get install --no-install-recommends $APT_UNAT \ + bash build-essential cimg-dev libssl-dev libbz2-dev \ + libminiupnpc-dev \ + libsqlite3-dev libsqlcipher-dev \ + pkg-config libz-dev \ + libxapian-dev doxygen rapidjson-dev \ + git cmake curl python3 + +## Avoid git cloning spuriously failing with +# server certificate verification failed. CAfile: none CRLfile: none +RUN apt-get install --no-install-recommends $APT_UNAT --reinstall \ + ca-certificates RUN git clone --depth 1 https://github.com/aetilius/pHash.git && \ rm -rf pHash-build && mkdir pHash-build && cd pHash-build && \ @@ -34,11 +44,14 @@ ARG REPO_URL=https://gitlab.com/RetroShare/RetroShare.git ARG REPO_BRANCH=master ARG REPO_DEPTH="--depth 2000" RUN git clone $REPO_DEPTH $REPO_URL -b $REPO_BRANCH && cd RetroShare && \ - git fetch --tags && cd .. -RUN mkdir RetroShare-build && cd RetroShare-build && \ - qmake ../RetroShare \ - CONFIG+=no_retroshare_plugins \ - CONFIG+=retroshare_service CONFIG+=no_retroshare_gui \ - CONFIG+=rs_jsonapi CONFIG+=rs_deep_search && \ - (make -j$(nproc) || make -j$(nproc) || make) && make install && \ + git fetch --tags && \ + git submodule update --init --remote --force \ + libbitdht/ libretroshare/ openpgpsdk/ && \ + cd .. + +RUN \ + mkdir RetroShare-build && cd RetroShare-build && \ + cmake -B. -S../RetroShare/retroshare-service \ + -DRS_FORUM_DEEP_INDEX=ON -DRS_JSON_API=ON && \ + make -j$(nproc) && make install && \ cd .. && rm -rf RetroShare-build diff --git a/build_scripts/GitlabCI/gitlabCI.Dockerfile b/build_scripts/GitlabCI/gitlabCI.Dockerfile index aa9c6cc87..65361ff79 100644 --- a/build_scripts/GitlabCI/gitlabCI.Dockerfile +++ b/build_scripts/GitlabCI/gitlabCI.Dockerfile @@ -8,11 +8,12 @@ RUN \ cd RetroShare && git remote add testing $REPO_URL && \ git fetch --tags testing $REPO_BRANCH && \ git reset --hard testing/$REPO_BRANCH && \ + git submodule update --init --remote --force \ + libbitdht/ libretroshare/ openpgpsdk/ && \ git --no-pager log --max-count 1 RUN \ mkdir RetroShare-build && cd RetroShare-build && \ - qmake ../RetroShare CONFIG+=no_retroshare_gui \ - CONFIG+=retroshare_service \ - CONFIG+=rs_jsonapi CONFIG+=rs_deep_search && \ - (make -j$(nproc) || make -j$(nproc) || make) && make install && \ + cmake -B. -S../RetroShare/retroshare-service \ + -DRS_FORUM_DEEP_INDEX=ON -DRS_JSON_API=ON && \ + make -j$(nproc) && make install && \ cd .. && rm -rf RetroShare-build diff --git a/build_scripts/Windows/build-libs/Makefile b/build_scripts/Windows/build-libs/Makefile index 8bab46b92..cadd5ef18 100644 --- a/build_scripts/Windows/build-libs/Makefile +++ b/build_scripts/Windows/build-libs/Makefile @@ -1,18 +1,18 @@ -ZLIB_VERSION=1.2.3 -BZIP2_VERSION=1.0.6 -MINIUPNPC_VERSION=2.0 -OPENSSL_VERSION=1.1.1h +ZLIB_VERSION=1.2.11 +BZIP2_VERSION=1.0.8 +MINIUPNPC_VERSION=2.2.3 +OPENSSL_VERSION=1.1.1m SPEEX_VERSION=1.2.0 -SPEEXDSP_VERSION=1.2rc3 -LIBXML2_VERSION=2.9.7 -LIBXSLT_VERSION=1.1.32 -CURL_VERSION=7.58.0 +SPEEXDSP_VERSION=1.2.0 +LIBXML2_VERSION=2.9.12 +LIBXSLT_VERSION=1.1.34 +CURL_VERSION=7.81.0 TCL_VERSION=8.6.10 -SQLCIPHER_VERSION=4.4.0 -LIBMICROHTTPD_VERSION=0.9.59 -FFMPEG_VERSION=3.4 +SQLCIPHER_VERSION=4.5.0 +LIBMICROHTTPD_VERSION=0.9.75 +FFMPEG_VERSION=4.4 RAPIDJSON_VERSION=1.1.0 -XAPIAN_VERSION=1.4.7 +XAPIAN_VERSION=1.4.19 DOWNLOAD_PATH?=download BUILD_PATH=build @@ -56,8 +56,7 @@ $(BUILD_PATH)/zlib-$(ZLIB_VERSION): $(DOWNLOAD_PATH)/zlib-$(ZLIB_VERSION).tar.gz rm -r -f $(BUILD_PATH)/zlib-* tar xvf $(DOWNLOAD_PATH)/zlib-$(ZLIB_VERSION).tar.gz # build - cd zlib-$(ZLIB_VERSION) && ./configure - #cd zlib-$(ZLIB_VERSION) && make install prefix="`pwd`/../$(BUILD_PATH)" + cd zlib-$(ZLIB_VERSION) && make -f win32/Makefile.gcc libz.a cd zlib-$(ZLIB_VERSION) && make # copy files mkdir -p $(BUILD_PATH)/zlib-$(ZLIB_VERSION).tmp/include @@ -72,7 +71,7 @@ $(BUILD_PATH)/zlib-$(ZLIB_VERSION): $(DOWNLOAD_PATH)/zlib-$(ZLIB_VERSION).tar.gz bzip2: $(BUILD_PATH)/bzip2-$(BZIP2_VERSION) $(DOWNLOAD_PATH)/bzip2-$(BZIP2_VERSION).tar.gz: - wget https://sourceforge.net/projects/bzip2/files/bzip2-$(BZIP2_VERSION).tar.gz/download -O $(DOWNLOAD_PATH)/bzip2-$(BZIP2_VERSION).tar.gz + wget https://www.sourceware.org/pub/bzip2/bzip2-$(BZIP2_VERSION).tar.gz -O $(DOWNLOAD_PATH)/bzip2-$(BZIP2_VERSION).tar.gz $(BUILD_PATH)/bzip2-$(BZIP2_VERSION): $(DOWNLOAD_PATH)/bzip2-$(BZIP2_VERSION).tar.gz # prepare @@ -100,10 +99,10 @@ $(BUILD_PATH)/miniupnpc-$(MINIUPNPC_VERSION): $(DOWNLOAD_PATH)/miniupnpc-$(MINIU rm -r -f $(BUILD_PATH)/miniupnpc-* tar xvf $(DOWNLOAD_PATH)/miniupnpc-$(MINIUPNPC_VERSION).tar.gz # build - cd miniupnpc-$(MINIUPNPC_VERSION) && export CC=gcc && export PATH=.:$$PATH && make -f Makefile.mingw init libminiupnpc.a miniupnpc.dll + cd miniupnpc-$(MINIUPNPC_VERSION) && export CC=gcc && export PATH=.:$$PATH && make -f Makefile.mingw libminiupnpc.a miniupnpc.dll # copy files mkdir -p $(BUILD_PATH)/miniupnpc-$(MINIUPNPC_VERSION).tmp/include/miniupnpc - cp miniupnpc-$(MINIUPNPC_VERSION)/*.h $(BUILD_PATH)/miniupnpc-$(MINIUPNPC_VERSION).tmp/include/miniupnpc/ + cp miniupnpc-$(MINIUPNPC_VERSION)/include/*.h $(BUILD_PATH)/miniupnpc-$(MINIUPNPC_VERSION).tmp/include/miniupnpc/ mkdir -p $(BUILD_PATH)/miniupnpc-$(MINIUPNPC_VERSION).tmp/lib cp miniupnpc-$(MINIUPNPC_VERSION)/miniupnpc.lib $(BUILD_PATH)/miniupnpc-$(MINIUPNPC_VERSION).tmp/lib/ mkdir -p $(BUILD_PATH)/miniupnpc-$(MINIUPNPC_VERSION).tmp/bin @@ -314,7 +313,7 @@ $(BUILD_PATH)/ffmpeg-$(FFMPEG_VERSION): $(DOWNLOAD_PATH)/ffmpeg-$(FFMPEG_VERSION rm -r -f $(BUILD_PATH)/ffmpeg-* tar xvf $(DOWNLOAD_PATH)/ffmpeg-$(FFMPEG_VERSION).tar.gz # build - cd ffmpeg-$(FFMPEG_VERSION) && ./configure --disable-shared --enable-static --disable-programs --disable-ffmpeg --disable-ffplay --disable-ffprobe --disable-ffserver --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-yasm --disable-everything --enable-encoder=mpeg4 --enable-decoder=mpeg4 --prefix="`pwd`/../$(BUILD_PATH)/ffmpeg-$(FFMPEG_VERSION).tmp" + cd ffmpeg-$(FFMPEG_VERSION) && ./configure --disable-shared --enable-static --disable-programs --disable-ffmpeg --disable-ffplay --disable-ffprobe --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-yasm --disable-everything --enable-encoder=mpeg4 --enable-decoder=mpeg4 --prefix="`pwd`/../$(BUILD_PATH)/ffmpeg-$(FFMPEG_VERSION).tmp" cd ffmpeg-$(FFMPEG_VERSION) && make install # cleanup rm -r -f ffmpeg-$(FFMPEG_VERSION) diff --git a/libbitdht b/libbitdht index 659423769..6abbec950 160000 --- a/libbitdht +++ b/libbitdht @@ -1 +1 @@ -Subproject commit 659423769541169457c41f71c8a038e2d64ba079 +Subproject commit 6abbec95073f3c1eb5059cbf8441111ef4a317a7 diff --git a/libretroshare b/libretroshare index 5a6f09ee1..167589952 160000 --- a/libretroshare +++ b/libretroshare @@ -1 +1 @@ -Subproject commit 5a6f09ee11a34f1c52b5be3f0a440f185b9b2a89 +Subproject commit 16758995237494a1f39fa86f0f04cf37de121a91 diff --git a/plugins/FeedReader/FeedReader.pro b/plugins/FeedReader/FeedReader.pro index b78dda911..b5dbbf43a 100644 --- a/plugins/FeedReader/FeedReader.pro +++ b/plugins/FeedReader/FeedReader.pro @@ -121,6 +121,11 @@ win32 { #Have to reorder libs, else got /libs/lib/libcrypto.a(bio_lib.o):bio_lib.c:(.text+0x0): multiple definition of `BIO_new' LIBS = -lcurl -lxml2 -lz -lxslt -lws2_32 -lwldap32 -lssl -lcrypto -lgdi32 $${LIBS} + isEmpty(QMAKE_SH) { + # MinGW + LIBS += -lcrypt32 + } + # Check for msys2 !isEmpty(PREFIX_MSYS2) { message(Use msys2 xml2.) diff --git a/plugins/VOIP/VOIP.pro b/plugins/VOIP/VOIP.pro index fbc5302d0..72ea621bd 100644 --- a/plugins/VOIP/VOIP.pro +++ b/plugins/VOIP/VOIP.pro @@ -55,6 +55,11 @@ linux-* { PKGCONFIG += speex speexdsp } else { LIBS += -lspeex -lspeexdsp -lavcodec -lavutil + + win32:isEmpty(QMAKE_SH) { + # MinGW + LIBS += -lbcrypt + } } #################################### Windows ##################################### diff --git a/retroshare-gui/src/gui/GetStartedDialog.cpp b/retroshare-gui/src/gui/GetStartedDialog.cpp index 21fe60be0..e3bbd7170 100644 --- a/retroshare-gui/src/gui/GetStartedDialog.cpp +++ b/retroshare-gui/src/gui/GetStartedDialog.cpp @@ -229,7 +229,7 @@ void GetStartedDialog::inviteFriends() { RsAutoUpdatePage::lockAllEvents(); - cert = rsPeers->GetRetroshareInvite(RsPeerId(),RetroshareInviteFlags::DNS | RetroshareInviteFlags::CURRENT_IP | RetroshareInviteFlags::FULL_IP_HISTORY); + cert = rsPeers->GetRetroshareInvite(RsPeerId(),RsPeers::defaultCertificateFlags | RetroshareInviteFlags::FULL_IP_HISTORY); RsAutoUpdatePage::unlockAllEvents() ; } diff --git a/retroshare-gui/src/gui/HomePage.cpp b/retroshare-gui/src/gui/HomePage.cpp index 327c8e44f..b14b68eb9 100644 --- a/retroshare-gui/src/gui/HomePage.cpp +++ b/retroshare-gui/src/gui/HomePage.cpp @@ -50,14 +50,10 @@ HomePage::HomePage(QWidget *parent) : MainPage(parent), - ui(new Ui::HomePage), - mIncludeAllIPs(false), - mUseShortFormat(true) + ui(new Ui::HomePage) { ui->setupUi(this); - updateCertificate(); - connect(ui->addButton, SIGNAL(clicked()), this, SLOT(addFriend())); connect(ui->copyIDButton, SIGNAL(clicked()), this, SLOT(copyId())); @@ -73,29 +69,48 @@ HomePage::HomePage(QWidget *parent) : QAction *CopyIdAction = new QAction(QIcon(),tr("Copy your Retroshare ID to Clipboard"), this); connect(CopyIdAction, SIGNAL(triggered()), this, SLOT(copyId())); - QMenu *menu = new QMenu(); + QMenu *menu = new QMenu(); menu->addAction(CopyIdAction); - if(!RsAccounts::isHiddenNode()) - { - QAction *includeIPsAct = new QAction(QIcon(), tr("Include all your known IPs"),this); - connect(includeIPsAct, SIGNAL(triggered()), this, SLOT(toggleIncludeAllIPs())); - includeIPsAct->setCheckable(true); - includeIPsAct->setChecked(mIncludeAllIPs); - - menu->addAction(includeIPsAct); - } - QAction *useOldFormatAct = new QAction(QIcon(), tr("Use old certificate format"),this); - useOldFormatAct->setToolTip(tr("Displays the certificate format used up to version 0.6.5\nOld Retroshare nodes will not understand the\nnew short format")); - connect(useOldFormatAct, SIGNAL(triggered()), this, SLOT(toggleUseOldFormat())); - useOldFormatAct->setCheckable(true); - useOldFormatAct->setChecked(!mUseShortFormat); - menu->addAction(useOldFormatAct); - menu->addSeparator(); menu->addAction(SendAction); menu->addAction(WebMailAction); menu->addAction(RecAction); + menu->addSeparator(); + + mUseOldFormatact = new QAction(QIcon(), tr("Use old certificate format"),this); + mUseOldFormatact->setToolTip(tr("Displays the certificate format used up to version 0.6.5\nOld Retroshare nodes will not understand the\nnew short format")); + connect(mUseOldFormatact, SIGNAL(triggered()), this, SLOT(updateOwnCert())); + mUseOldFormatact->setCheckable(true); + mUseOldFormatact->setChecked(false); + menu->addAction(mUseOldFormatact); + + if(!RsAccounts::isHiddenNode()) + { + mIncludeLocIPact = new QAction(QIcon(), tr("Include current local IP"),this); + connect(mIncludeLocIPact, SIGNAL(triggered()), this, SLOT(updateOwnCert())); + mIncludeLocIPact->setCheckable(true); + mIncludeLocIPact->setChecked(true); + menu->addAction(mIncludeLocIPact); + + mIncludeExtIPact = new QAction(QIcon(), tr("Include current external IP"),this); + connect(mIncludeExtIPact, SIGNAL(triggered()), this, SLOT(updateOwnCert())); + mIncludeExtIPact->setCheckable(true); + mIncludeExtIPact->setChecked(true); + menu->addAction(mIncludeExtIPact); + + mIncludeDNSact = new QAction(QIcon(), tr("Include my DNS"),this); + connect(mIncludeDNSact, SIGNAL(triggered()), this, SLOT(updateOwnCert())); + mIncludeDNSact->setCheckable(true); + mIncludeDNSact->setChecked(true); + menu->addAction(mIncludeDNSact); + + mIncludeIPHistoryact = new QAction(QIcon(), tr("Include all IPs history"),this); + connect(mIncludeIPHistoryact, SIGNAL(triggered()), this, SLOT(updateOwnCert())); + mIncludeIPHistoryact->setCheckable(true); + mIncludeIPHistoryact->setChecked(false); + menu->addAction(mIncludeIPHistoryact); + } ui->shareButton->setMenu(menu); @@ -118,6 +133,8 @@ HomePage::HomePage(QWidget *parent) : mEventHandlerId = 0; rsEvents->registerEventsHandler( [this](std::shared_ptr event) { handleEvent(event); }, mEventHandlerId, RsEventType::NETWORK ); + + updateOwnCert(); } void HomePage::handleEvent(std::shared_ptr e) @@ -139,13 +156,15 @@ void HomePage::handleEvent(std::shared_ptr e) case RsNetworkEventCode::DNS_UPDATED: // [fallthrough] RsQThreadUtils::postToObject( [=]() { - updateCertificate(); + updateOwnCert(); },this); break; default: break; } } + +#ifdef DEAD_CODE void HomePage::certContextMenu(QPoint /*point*/) { QMenu menu(this) ; @@ -178,17 +197,7 @@ void HomePage::certContextMenu(QPoint /*point*/) menu.exec(QCursor::pos()); } - -void HomePage::toggleUseShortFormat() -{ - mUseShortFormat = !mUseShortFormat; - updateCertificate(); -} -void HomePage::toggleIncludeAllIPs() -{ - mIncludeAllIPs = !mIncludeAllIPs; - updateCertificate(); -} +#endif HomePage::~HomePage() { @@ -196,15 +205,8 @@ HomePage::~HomePage() delete ui; } -void HomePage::updateCertificate() +void HomePage::getOwnCert(QString& invite,QString& description) const { - updateOwnCert(); -} - -void HomePage::updateOwnCert() -{ - bool include_extra_locators = mIncludeAllIPs; - RsPeerDetails detail; if (!rsPeers->getPeerDetails(rsPeers->getOwnId(), detail)) @@ -213,23 +215,46 @@ void HomePage::updateOwnCert() return ; } - QString invite ; - RetroshareInviteFlags invite_flags = RetroshareInviteFlags::CURRENT_IP | RetroshareInviteFlags::DNS; + RetroshareInviteFlags invite_flags = RetroshareInviteFlags::NOTHING; - if(mIncludeAllIPs) + if(mIncludeLocIPact->isChecked()) + invite_flags |= RetroshareInviteFlags::CURRENT_LOCAL_IP; + + if(mIncludeExtIPact->isChecked()) + invite_flags |= RetroshareInviteFlags::CURRENT_EXTERNAL_IP; + + if(mIncludeDNSact->isChecked()) + invite_flags |= RetroshareInviteFlags::DNS; + + if(mIncludeIPHistoryact->isChecked()) invite_flags |= RetroshareInviteFlags::FULL_IP_HISTORY; - if(mUseShortFormat) + if(!mUseOldFormatact->isChecked()) { std::string short_invite; rsPeers->getShortInvite(short_invite,rsPeers->getOwnId(),invite_flags | RetroshareInviteFlags::RADIX_FORMAT); + invite = QString::fromStdString(short_invite); + } + else + invite = QString::fromStdString(rsPeers->GetRetroshareInvite(detail.id,invite_flags)); + description = ConfCertDialog::getCertificateDescription(detail,false,!mUseOldFormatact->isChecked(),invite_flags); +} + +void HomePage::updateOwnCert() +{ + QString certificate, description; + + getOwnCert(certificate,description); + + if(!mUseOldFormatact->isChecked()) // in this case we have to split the cert for a better display + { QString S; QString txt; - for(uint32_t i=0;iGetRetroshareInvite(detail.id,invite_flags)); - - ui->retroshareid->setText("\n"+invite+"\n"); - - QString description = ConfCertDialog::getCertificateDescription(detail,false,mUseShortFormat,include_extra_locators); + ui->retroshareid->setText("\n"+certificate+"\n"); ui->retroshareid->setToolTip(description); } @@ -348,9 +367,3 @@ void HomePage::openWebHelp() { QDesktopServices::openUrl(QUrl(QString("https://retrosharedocs.readthedocs.io/en/latest/"))); } - -void HomePage::toggleUseOldFormat() -{ - mUseShortFormat = !mUseShortFormat; - updateCertificate(); -} diff --git a/retroshare-gui/src/gui/HomePage.h b/retroshare-gui/src/gui/HomePage.h index 2b9e28c18..a20f07863 100644 --- a/retroshare-gui/src/gui/HomePage.h +++ b/retroshare-gui/src/gui/HomePage.h @@ -46,28 +46,32 @@ public: virtual QString pageName() const { return tr("Home") ; } //MainPage virtual QString helpText() const { return ""; } //MainPage + // Returns the certificate along with its description using current options. + + void getOwnCert(QString& invite,QString& description) const; + private slots: - void certContextMenu(QPoint); +#ifdef DEAD_CODE + void certContextMenu(QPoint); +#endif void updateOwnCert(); - void updateCertificate(); void runEmailClient(); void copyCert(); void copyId(); void saveCert(); void addFriend(); void webMail(); - //void loadCert(); void openWebHelp() ; - void toggleUseOldFormat() ; void recommendFriends(); - void toggleIncludeAllIPs(); - void toggleUseShortFormat(); private: Ui::HomePage *ui; - bool mIncludeAllIPs; - bool mUseShortFormat; + QAction *mIncludeDNSact; + QAction *mIncludeIPHistoryact; + QAction *mIncludeExtIPact; + QAction *mIncludeLocIPact; + QAction *mUseOldFormatact; RsEventsHandlerId_t mEventHandlerId; diff --git a/retroshare-gui/src/gui/MainWindow.cpp b/retroshare-gui/src/gui/MainWindow.cpp index 10ce2695b..974715d63 100644 --- a/retroshare-gui/src/gui/MainWindow.cpp +++ b/retroshare-gui/src/gui/MainWindow.cpp @@ -1081,7 +1081,9 @@ void SetForegroundWindowInternal(HWND hWnd) return _instance->gxsforumDialog; case Posted: return _instance->postedDialog; - } + case Home: + return _instance->homePage; + } return NULL; } diff --git a/retroshare-gui/src/gui/MainWindow.h b/retroshare-gui/src/gui/MainWindow.h index b4f3cccd5..23b70e66f 100644 --- a/retroshare-gui/src/gui/MainWindow.h +++ b/retroshare-gui/src/gui/MainWindow.h @@ -100,9 +100,10 @@ public: Channels = 6, /** Channels page. */ Forums = 7, /** Forums page. */ Search = 8, /** Search page. */ - Posted = 11, /** Posted links */ - People = 12, /** People page. */ - Options = 13 /** People page. */ + Posted = 11, /** Posted links */ + People = 12, /** People page. */ + Options = 13, /** People page. */ + Home = 14 /** Home page. */ }; diff --git a/retroshare-gui/src/gui/Posted/PostedItem.cpp b/retroshare-gui/src/gui/Posted/PostedItem.cpp index 90f393dab..d9242c571 100644 --- a/retroshare-gui/src/gui/Posted/PostedItem.cpp +++ b/retroshare-gui/src/gui/Posted/PostedItem.cpp @@ -495,7 +495,7 @@ void PostedItem::fill() ui->voteUpButton->setDisabled(true); ui->voteDownButton->setDisabled(true); - ui->thumbnailLabel->setPixmap( FilesDefs::getPixmapFromQtResourcePath(":/images/thumb-default.png")); + ui->thumbnailLabel->setPicture( FilesDefs::getPixmapFromQtResourcePath(":/images/thumb-default.png")); ui->fromLabel->setId(mPost.mMeta.mAuthorId); ui->titleLabel->setText(tr( "

The author of this message (with ID %1) is banned.").arg(QString::fromStdString(mPost.mMeta.mAuthorId.toStdString()))) ; QDateTime qtime; @@ -509,8 +509,10 @@ void PostedItem::fill() QPixmap sqpixmap2 = FilesDefs::getPixmapFromQtResourcePath(":/images/thumb-default.png"); mInFill = true; - int desired_height = 1.5*(ui->voteDownButton->height() + ui->voteUpButton->height() + ui->scoreLabel->height()); - int desired_width = sqpixmap2.width()*desired_height/(float)sqpixmap2.height(); + int desired_height = ui->voteDownButton->height() + ui->voteUpButton->height() + ui->scoreLabel->height(); + int desired_width = 16/9.0 * desired_height; //sqpixmap2.width()*desired_height/(float)sqpixmap2.height(); + + ui->thumbnailLabel->setFixedSize(desired_width,desired_height); QDateTime qtime; qtime.setTime_t(mPost.mMeta.mPublishTs); @@ -573,17 +575,17 @@ void PostedItem::fill() GxsIdDetails::loadPixmapFromData(mPost.mImage.mData, mPost.mImage.mSize, pixmap,GxsIdDetails::ORIGINAL); // Wiping data - as its been passed to thumbnail. - QPixmap sqpixmap = pixmap.scaled(desired_width,desired_height, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation); - ui->thumbnailLabel->setPixmap(sqpixmap); +// QPixmap sqpixmap = pixmap.scaled(desired_width,desired_height, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation); + ui->thumbnailLabel->setPicture(pixmap); ui->thumbnailLabel->setToolTip(tr("Click to view Picture")); + ui->thumbnailLabel->setEnableZoom(false); - QPixmap scaledpixmap; - if(pixmap.width() > 800){ - QPixmap scaledpixmap = pixmap.scaledToWidth(800, Qt::SmoothTransformation); - ui->pictureLabel->setPixmap(scaledpixmap); - }else{ - ui->pictureLabel->setPixmap(pixmap); - } + QPixmap scaledpixmap; + if(pixmap.width() > 800){ + QPixmap scaledpixmap = pixmap.scaledToWidth(800, Qt::SmoothTransformation); + ui->pictureLabel->setPixmap(scaledpixmap); + }else + ui->pictureLabel->setPixmap(pixmap); } else if (urlOkay && (mPost.mImage.mData == NULL)) { diff --git a/retroshare-gui/src/gui/Posted/PostedItem.h b/retroshare-gui/src/gui/Posted/PostedItem.h index d726cf830..a2f432dc0 100644 --- a/retroshare-gui/src/gui/Posted/PostedItem.h +++ b/retroshare-gui/src/gui/Posted/PostedItem.h @@ -112,11 +112,11 @@ protected: void setCommentsSize(int comNb) override; private slots: - void doExpand(bool open); - void toggle(); - void makeUpVote(); - void makeDownVote(); - void toggleNotes() ; + void doExpand(bool open) override; + void toggle() override; + void makeUpVote() override; + void makeDownVote() override; + void toggleNotes() override; private: /** Qt Designer generated object */ diff --git a/retroshare-gui/src/gui/Posted/PostedItem.ui b/retroshare-gui/src/gui/Posted/PostedItem.ui index 6c6b290f8..aafc8528c 100644 --- a/retroshare-gui/src/gui/Posted/PostedItem.ui +++ b/retroshare-gui/src/gui/Posted/PostedItem.ui @@ -176,6 +176,12 @@ QSizePolicy::Expanding + + + 0 + 0 + + @@ -190,7 +196,7 @@ 6 - + 0 @@ -732,15 +738,15 @@ 1 - ClickableLabel + ZoomableLabel QLabel -

util/ClickableLabel.h
+
gui/gxschannels/GxsChannelPostThumbnail.h
- + diff --git a/retroshare-gui/src/gui/RetroShareLink.cpp b/retroshare-gui/src/gui/RetroShareLink.cpp index d34871104..524f3c757 100644 --- a/retroshare-gui/src/gui/RetroShareLink.cpp +++ b/retroshare-gui/src/gui/RetroShareLink.cpp @@ -22,6 +22,7 @@ #include "ChatLobbyWidget.h" #include "MainWindow.h" +#include "HomePage.h" #include "chat/ChatDialog.h" #include "common/PeerDefs.h" #include "common/RsCollection.h" @@ -551,32 +552,41 @@ RetroShareLink RetroShareLink::createMessage(const RsGxsId& peerId, const QStrin RetroShareLink RetroShareLink::createCertificate(const RsPeerId& ssl_id) { - RetroShareLink link; - link.clear(); + RetroShareLink link; + link.clear(); #ifndef RS_NO_WARN_CPP #pragma message("csoler 2012-08-14: This is baaaaaad code") #endif - // - we should not need to parse and re-read a cert in old format. - // - RsPeerDetails detail; - if (rsPeers->getPeerDetails(ssl_id, detail) == false) { - std::cerr << "RetroShareLink::createPerson() Couldn't find peer id " << ssl_id << std::endl; - } else { + // - we should not need to parse and re-read a cert in old format. + // + RsPeerDetails detail; + if (rsPeers->getPeerDetails(ssl_id, detail) == false) + std::cerr << "RetroShareLink::createPerson() Couldn't find peer id " << ssl_id << std::endl; + else + { + link._type = TYPE_CERTIFICATE; - link._type = TYPE_CERTIFICATE; - link._radix = QString::fromUtf8(rsPeers->GetRetroshareInvite(ssl_id).c_str()); - link._name = QString::fromUtf8(detail.name.c_str()); - link._location = QString::fromUtf8(detail.location.c_str()); - link._radix.replace("\n",""); + if(rsPeers->getOwnId() == ssl_id) // in this case, use application-wide parameters set in HomePage + { + QString invite,description; + static_cast(MainWindow::getPage(MainWindow::Home))->getOwnCert(invite,description); + link._radix = invite; + } + else + link._radix = QString::fromUtf8(rsPeers->GetRetroshareInvite(ssl_id).c_str()); - std::cerr << "Found radix = " << link._radix.toStdString() << std::endl; - } + link._name = QString::fromUtf8(detail.name.c_str()); + link._location = QString::fromUtf8(detail.location.c_str()); + link._radix.replace("\n",""); - link.check(); + std::cerr << "Found radix = " << link._radix.toStdString() << std::endl; + } - return link; + link.check(); + + return link; } RetroShareLink RetroShareLink::createUnknownSslCertificate(const RsPeerId& sslId, const RsPgpId& gpgId) { diff --git a/retroshare-gui/src/gui/common/NewFriendList.cpp b/retroshare-gui/src/gui/common/NewFriendList.cpp index 991f5d647..7930b3057 100644 --- a/retroshare-gui/src/gui/common/NewFriendList.cpp +++ b/retroshare-gui/src/gui/common/NewFriendList.cpp @@ -1359,7 +1359,7 @@ bool NewFriendList::exportFriendlist(QString &fileName) if (!rsPeers->getPeerDetails(*list_iter2, detailSSL)) continue; - std::string certificate = rsPeers->GetRetroshareInvite(detailSSL.id, RetroshareInviteFlags::CURRENT_IP | RetroshareInviteFlags::DNS | RetroshareInviteFlags::RADIX_FORMAT); + std::string certificate = rsPeers->GetRetroshareInvite(detailSSL.id, RsPeers::defaultCertificateFlags | RetroshareInviteFlags::RADIX_FORMAT); // remove \n from certificate certificate.erase(std::remove(certificate.begin(), certificate.end(), '\n'), certificate.end()); diff --git a/retroshare-gui/src/gui/connect/ConfCertDialog.cpp b/retroshare-gui/src/gui/connect/ConfCertDialog.cpp index 03f7b4205..6a407cb49 100644 --- a/retroshare-gui/src/gui/connect/ConfCertDialog.cpp +++ b/retroshare-gui/src/gui/connect/ConfCertDialog.cpp @@ -264,7 +264,7 @@ void ConfCertDialog::loadInvitePage() ui._shouldAddSignatures_CB->setEnabled(detail.gpgSigners.size() > 1) ; std::string invite ; - RetroshareInviteFlags flags = RetroshareInviteFlags::DNS | RetroshareInviteFlags::CURRENT_IP | RetroshareInviteFlags::RADIX_FORMAT; + RetroshareInviteFlags flags = RsPeers::defaultCertificateFlags | RetroshareInviteFlags::RADIX_FORMAT; if(!detail.isHiddenNode && ui._includeIPHistory_CB->isChecked()) flags |= RetroshareInviteFlags::FULL_IP_HISTORY; @@ -283,7 +283,7 @@ void ConfCertDialog::loadInvitePage() ui.stabWidget->setTabText(PageCertificate, tr("Retroshare Certificate")); } - QString infotext = getCertificateDescription(detail,ui._shouldAddSignatures_CB->isChecked(),ui._shortFormat_CB->isChecked(), ui._includeIPHistory_CB->isChecked() ); + QString infotext = getCertificateDescription(detail,ui._shouldAddSignatures_CB->isChecked(),ui._shortFormat_CB->isChecked(), flags ); ui.userCertificateText->setToolTip(infotext) ; @@ -297,19 +297,15 @@ void ConfCertDialog::loadInvitePage() ui.userCertificateText->setText(QString::fromUtf8(invite.c_str())); } -QString ConfCertDialog::getCertificateDescription(const RsPeerDetails& detail,bool signatures_included,bool use_short_format,bool include_additional_locators) +QString ConfCertDialog::getCertificateDescription(const RsPeerDetails& detail, bool signatures_included, bool use_short_format,RetroshareInviteFlags invite_flags) { //infotext += tr("

Use this certificate to make new friends. Send it by email, or give it hand to hand.

") ; QString infotext; if(use_short_format) - { infotext += tr("

This Retroshare ID contains:") ; - } else - { infotext += tr("

This certificate contains:") ; - } infotext += "

    " ; @@ -334,25 +330,36 @@ QString ConfCertDialog::getCertificateDescription(const RsPeerDetails& detail,bo if(detail.isHiddenNode) infotext += tr("
  • onion address and port") +" (" + detail.hiddenNodeAddress.c_str() + ":" + QString::number(detail.hiddenNodePort)+ ")
  • "; - else if(!include_additional_locators) + else if(!!(invite_flags & RetroshareInviteFlags::FULL_IP_HISTORY)) + for(auto it(detail.ipAddressList.begin());it!=detail.ipAddressList.end();++it) + { + infotext += "
  • " ; + infotext += tr("IP address and port: ") + QString::fromStdString(*it) ; + infotext += "
  • " ; + } + else { - if(!detail.localAddr.empty()) infotext += tr("
  • IP address and port: ") + detail.localAddr.c_str() + ":" + QString::number(detail.localPort)+ "
  • "; - if(!detail.extAddr.empty()) infotext += tr("
  • IP address and port: ") + detail.extAddr.c_str() + ":" + QString::number(detail.extPort)+ "
  • "; + if(!!(invite_flags & RetroshareInviteFlags::CURRENT_LOCAL_IP) && !detail.localAddr.empty()) + infotext += tr("
  • IP address and port: ") + detail.localAddr.c_str() + ":" + QString::number(detail.localPort)+ "
  • "; + + if(!!(invite_flags & RetroshareInviteFlags::CURRENT_EXTERNAL_IP) && !detail.extAddr.empty()) + infotext += tr("
  • IP address and port: ") + detail.extAddr.c_str() + ":" + QString::number(detail.extPort)+ "
  • "; + } + + if(!!(invite_flags & RetroshareInviteFlags::DNS) && !detail.dyndns.empty()) + { + infotext += "
  • " ; + infotext += tr("DNS: : ") + QString::fromStdString(detail.dyndns); + infotext += "
  • " ; } - else for(auto it(detail.ipAddressList.begin());it!=detail.ipAddressList.end();++it) - { - infotext += "
  • " ; - infotext += tr("IP address and port: ") + QString::fromStdString(*it) ; - infotext += "
  • " ; - } infotext += QString("

    ") ; if(rsPeers->getOwnId() == detail.id) if(use_short_format) - infotext += tr("

    You can use this Retroshare ID to make new friends. Send it by email, or give it hand to hand.

    ") ; - else - infotext += tr("

    You can use this certificate to make new friends. Send it by email, or give it hand to hand.

    ") ; + infotext += tr("

    You can use this Retroshare ID to make new friends. Send it by email, or give it hand to hand.

    ") ; + else + infotext += tr("

    You can use this certificate to make new friends. Send it by email, or give it hand to hand.

    ") ; return infotext; } diff --git a/retroshare-gui/src/gui/connect/ConfCertDialog.h b/retroshare-gui/src/gui/connect/ConfCertDialog.h index a883dfd17..4760835da 100644 --- a/retroshare-gui/src/gui/connect/ConfCertDialog.h +++ b/retroshare-gui/src/gui/connect/ConfCertDialog.h @@ -59,7 +59,7 @@ public: /* window will destroy itself! */ } static void loadAll(); - static QString getCertificateDescription(const RsPeerDetails& det, bool signatures_included, bool use_short_format, bool extra_locators_included); + static QString getCertificateDescription(const RsPeerDetails& det, bool signatures_included, bool use_short_format,RetroshareInviteFlags invite_flags); signals: void configChanged(); diff --git a/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp b/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp index ca56e06aa..81287c6c4 100755 --- a/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp +++ b/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp @@ -891,7 +891,9 @@ void ConnectFriendWizard::cleanFriendCert() whileBlocking(ui->friendCertEdit)->setPlainText(QString::fromUtf8(cleanCert.c_str())); whileBlocking(ui->friendCertEdit)->setTextCursor(textCursor); - certDetail = ConfCertDialog::getCertificateDescription(details,false,mIsShortInvite,!details.ipAddressList.empty()); + // use dummy flags so that the content of the description is driven by what's in the "details" variable. + RetroshareInviteFlags dummy_flags = RetroshareInviteFlags::ALL; + certDetail = ConfCertDialog::getCertificateDescription(details,false,mIsShortInvite,dummy_flags); } if (mIsShortInvite) diff --git a/retroshare-gui/src/gui/settings/CryptoPage.cpp b/retroshare-gui/src/gui/settings/CryptoPage.cpp index 99317c14d..6c171bb1a 100755 --- a/retroshare-gui/src/gui/settings/CryptoPage.cpp +++ b/retroshare-gui/src/gui/settings/CryptoPage.cpp @@ -61,6 +61,10 @@ CryptoPage::CryptoPage(QWidget * parent, Qt::WindowFlags flags) //connect(ui.exportprofile,SIGNAL(clicked()), this, SLOT(profilemanager())); connect(ui.exportprofile,SIGNAL(clicked()), this, SLOT(exportProfile())); + // Remove this because it duplicates functionality of the HomePage. + ui.retroshareId_LB->hide(); + ui.retroshareId_content_LB->hide(); + ui.stackPageCertificate->hide(); ui.onlinesince->setText(DateTime::formatLongDateTime(Rshare::startupTime())); } @@ -103,8 +107,8 @@ void CryptoPage::showEvent ( QShowEvent * /*event*/ ) ui.pgpfingerprint->setText(misc::fingerPrintStyleSplit(QString::fromStdString(detail.fpr.toStdString()))); std::string invite ; - rsPeers->getShortInvite(invite,rsPeers->getOwnId(),RetroshareInviteFlags::RADIX_FORMAT | RetroshareInviteFlags::DNS | RetroshareInviteFlags::CURRENT_IP); - ui.retroshareid->setText(QString::fromUtf8(invite.c_str())); + rsPeers->getShortInvite(invite,rsPeers->getOwnId(),RetroshareInviteFlags::RADIX_FORMAT | RsPeers::defaultCertificateFlags); + ui.retroshareId_content_LB->setText(QString::fromUtf8(invite.c_str())); /* set retroshare version */ ui.version->setText(Rshare::retroshareVersion(true)); @@ -139,7 +143,7 @@ void CryptoPage::load() { std::string cert ; - RetroshareInviteFlags flags = RetroshareInviteFlags::DNS | RetroshareInviteFlags::CURRENT_IP; + RetroshareInviteFlags flags = RetroshareInviteFlags::DNS | RetroshareInviteFlags::CURRENT_LOCAL_IP | RetroshareInviteFlags::CURRENT_EXTERNAL_IP; if(ui._shortFormat_CB->isChecked()) { @@ -161,7 +165,7 @@ CryptoPage::load() RsPeerDetails detail; rsPeers->getPeerDetails(rsPeers->getOwnId(),detail); - ui.certplainTextEdit->setToolTip(ConfCertDialog::getCertificateDescription(detail, ui._includeSignatures_CB->isChecked(), ui._shortFormat_CB->isChecked(), ui._includeAllIPs_CB->isChecked() )); + ui.certplainTextEdit->setToolTip(ConfCertDialog::getCertificateDescription(detail, ui._includeSignatures_CB->isChecked(), ui._shortFormat_CB->isChecked(), flags)); } void diff --git a/retroshare-gui/src/gui/settings/CryptoPage.ui b/retroshare-gui/src/gui/settings/CryptoPage.ui index 86b8e38b9..29a336721 100755 --- a/retroshare-gui/src/gui/settings/CryptoPage.ui +++ b/retroshare-gui/src/gui/settings/CryptoPage.ui @@ -7,25 +7,19 @@ 0 0 869 - 487 + 493 - - - 0 - - - - Node information - + + - + Retroshare ID: @@ -248,7 +242,7 @@ - <html><head/><body><p>Use this to export your profile key. You can then import it in a different computer and make a new node with the same profile. Doing so, existing friends that you also add to the new node will automatically recognise that new node as friend.</p></body></html> + <html><head/><body><p>Use this button to export your profile key. You can then import it in a different computer and make a new node with the same profile. Doing so, existing friends that you also add to the new node will automatically recognise that new node as friend.</p></body></html> Export @@ -474,7 +468,7 @@ - + 75 @@ -539,10 +533,7 @@ - - - Certificate - + diff --git a/retroshare-service/CMakeLists.txt b/retroshare-service/CMakeLists.txt new file mode 100644 index 000000000..2a09602d8 --- /dev/null +++ b/retroshare-service/CMakeLists.txt @@ -0,0 +1,162 @@ +# RetroShare decentralized communication platform +# +# Copyright (C) 2021-2022 Gioacchino Mazzurco +# Copyright (C) 2021-2022 Asociación Civil Altermundi +# +# SPDX-License-Identifier: CC0-1.0 + +cmake_minimum_required (VERSION 3.18.0) +project(retroshare-service) + +include(CMakeDependentOption) + +option( + RS_DEVELOPMENT_BUILD + "Disable optimization to speed up build, enable verbose build log. \ + just for development purposes, not suitable for library usage" + OFF ) + +option( + RS_JSON_API + "Use restbed to expose libretroshare as JSON API via HTTP" + ON ) + +option( + RS_SERVICE_DESKTOP + "Install icons and shortcuts for desktop environements" + OFF ) + +option( + RS_SERVICE_TERMINAL_LOGIN + "Enable RetroShare login via terminal" + ON ) + +cmake_dependent_option( + RS_SERVICE_TERMINAL_WEBUI_PASSWORD + "Enable settin Web UI password via terminal in retroshare-service" + OFF + "RS_WEBUI" + ON ) + +cmake_dependent_option( + RS_WEBUI + "Install RetroShare Web UI" + OFF + "RS_JSON_API" + ON ) + +################################################################################ + +set(FETCHCONTENT_QUIET OFF) +include(FetchContent) + +find_package(Git REQUIRED) + +################################################################################ + +if(RS_DEVELOPMENT_BUILD) + set(CMAKE_VERBOSE_MAKEFILE ON) + set(CMAKE_EXPORT_COMPILE_COMMANDS ON) +endif(RS_DEVELOPMENT_BUILD) + +################################################################################ + +list( + APPEND RS_SERVICE_SOURCES + src/retroshare-service.cc ) + +add_executable(${PROJECT_NAME} ${RS_SERVICE_SOURCES}) + +install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}) + +################################################################################ + +if(RS_DEVELOPMENT_BUILD) + target_compile_options(${PROJECT_NAME} PRIVATE "-O0") +endif(RS_DEVELOPMENT_BUILD) + +################################################################################ + +set(LIBRETROSHARE_DEVEL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../libretroshare/") +if(EXISTS "${LIBRETROSHARE_DEVEL_DIR}/.git" ) + message( + STATUS + "libretroshare submodule found at ${LIBRETROSHARE_DEVEL_DIR} using it" ) + add_subdirectory( + "${LIBRETROSHARE_DEVEL_DIR}" "${CMAKE_BINARY_DIR}/libretroshare" ) +else() + FetchContent_Declare( + libretroshare + GIT_REPOSITORY "https://gitlab.com/RetroShare/libretroshare.git" + GIT_TAG "origin/master" + GIT_SHALLOW TRUE + GIT_PROGRESS TRUE + TIMEOUT 10 + ) + FetchContent_MakeAvailable(libretroshare) +endif() + +target_link_libraries(${PROJECT_NAME} PRIVATE retroshare) + +################################################################################ + +if(RS_SERVICE_DESKTOP) + if(UNIX AND NOT APPLE) + install( + FILES data/retroshare-service.svg + DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/scalable/ ) + + install( + FILES data/retroshare-service_48x48.png + DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/48x48/apps/retroshare-service.png ) + + install( + FILES data/retroshare-service_128x128.png + DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/128x128/apps/retroshare-service.png ) + + install( + FILES data/retroshare-service.desktop + DESTINATION ${CMAKE_INSTALL_PREFIX}/data/retroshare-service.desktop ) + endif(UNIX AND NOT APPLE) +endif(RS_SERVICE_DESKTOP) + +################################################################################ + +if(RS_JSON_API) + target_compile_definitions(${PROJECT_NAME} PUBLIC RS_JSONAPI) +endif(RS_JSON_API) + +if(RS_SERVICE_TERMINAL_LOGIN) + target_compile_definitions(${PROJECT_NAME} PUBLIC RS_SERVICE_TERMINAL_LOGIN) +endif(RS_SERVICE_TERMINAL_LOGIN) + +if(RS_WEBUI) + set(RS_WEBUI_DEVEL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../webui/") + if(EXISTS "${RS_WEBUI_DEVEL_DIR}/.git" ) + message( + STATUS + "RetroShare WebUI repository found at ${RS_WEBUI_DEVEL_DIR} using it" ) + add_subdirectory( + "${RS_WEBUI_DEVEL_DIR}" "${CMAKE_BINARY_DIR}/webui" ) + else() + FetchContent_Declare( + webui + GIT_REPOSITORY "https://gitlab.com/RetroShare/RetroShareWebUI.git" + GIT_TAG "origin/master" + GIT_SHALLOW TRUE + GIT_PROGRESS TRUE + TIMEOUT 10 + ) + FetchContent_MakeAvailable(webui) + endif() + + add_dependencies(${PROJECT_NAME} retroshare-webui) + target_compile_definitions(${PROJECT_NAME} PUBLIC RS_WEBUI) +endif(RS_WEBUI) + +if(RS_SERVICE_TERMINAL_WEBUI_PASSWORD) + target_compile_definitions( + ${PROJECT_NAME} PUBLIC RS_SERVICE_TERMINAL_WEBUI_PASSWORD ) +endif(RS_SERVICE_TERMINAL_WEBUI_PASSWORD) + +################################################################################ diff --git a/retroshare-service/src/retroshare-service.cc b/retroshare-service/src/retroshare-service.cc index 51888d25a..2390739fd 100644 --- a/retroshare-service/src/retroshare-service.cc +++ b/retroshare-service/src/retroshare-service.cc @@ -1,7 +1,7 @@ /* * RetroShare Service - * Copyright (C) 2016-2021 Gioacchino Mazzurco - * Copyright (C) 2021 Asociación Civil Altermundi + * Copyright (C) 2016-2022 Gioacchino Mazzurco + * Copyright (C) 2021-2022 Asociación Civil Altermundi * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as @@ -26,15 +26,16 @@ #include #include -#include "util/stacktrace.h" -#include "util/argstream.h" -#include "util/rskbdinput.h" -#include "util/rsdir.h" #include "retroshare/rsinit.h" #include "retroshare/rstor.h" #include "retroshare/rspeers.h" #include "retroshare/rsinit.h" #include "retroshare/rsiface.h" + +#include "util/stacktrace.h" +#include "util/argstream.h" +#include "util/rskbdinput.h" +#include "util/rsdir.h" #include "util/rsdebug.h" #ifdef RS_JSONAPI @@ -176,7 +177,7 @@ int main(int argc, char* argv[]) as.defaultErrorHandling(true, true); #if (defined(RS_JSONAPI) && defined(RS_WEBUI)) && defined(RS_SERVICE_TERMINAL_WEBUI_PASSWORD) - std::string webui_pass1 = "Y"; + std::string webui_pass1; if(askWebUiPassword) { std::string webui_pass2 = "N"; @@ -210,8 +211,8 @@ int main(int argc, char* argv[]) int initResult = RsInit::InitRetroShare(conf); if(initResult != RS_INIT_OK) { - RsErr() << "Retroshare core initalization failed with: " << initResult - << std::endl; + RsFatal() << "Retroshare core initalization failed with: " << initResult + << std::endl; return -initResult; } @@ -331,11 +332,11 @@ int main(int argc, char* argv[]) #if (defined(RS_JSONAPI) && defined(RS_WEBUI)) && defined(RS_SERVICE_TERMINAL_WEBUI_PASSWORD) if(rsJsonApi && !webui_pass1.empty()) - { + { rsWebUi->setHtmlFilesDirectory(webui_base_directory); rsWebUi->setUserPassword(webui_pass1); rsWebUi->restart(); - } + } #endif rsControl->setShutdownCallback([&](int){keepRunning = false;});