diff --git a/build_scripts/OBS b/build_scripts/OBS index 1de347e99..353596b0e 160000 --- a/build_scripts/OBS +++ b/build_scripts/OBS @@ -1 +1 @@ -Subproject commit 1de347e993ed1147bb84cdaf6c0604ff220eb221 +Subproject commit 353596b0ee5ea76611eb663b90bf3ab1c9f34ad7 diff --git a/build_scripts/Windows-msys2/env/tools/prepare-msys2.bat b/build_scripts/Windows-msys2/env/tools/prepare-msys2.bat index d07c7a058..eaeba1482 100644 --- a/build_scripts/Windows-msys2/env/tools/prepare-msys2.bat +++ b/build_scripts/Windows-msys2/env/tools/prepare-msys2.bat @@ -16,7 +16,13 @@ if "%~1"=="clean" ( goto exit ) -if exist "%EnvMSYS2Path%\msys%MSYS2Base%\usr\bin\pacman.exe" ( +set MSYS2Version=20231026 + +set MSYS2Install=msys2-base-x86_64-%MSYS2Version%.sfx.exe +set MSYS2Url=https://github.com/msys2/msys2-installer/releases/download/%MSYS2Version:~0,4%-%MSYS2Version:~4,2%-%MSYS2Version:~6,2%/%MSYS2Install% +set MSYS2UnpackPath=%EnvMSYS2Path%\msys64 + +if exist "%MSYS2UnpackPath%\usr\bin\pacman.exe" ( if "%~1"=="reinstall" ( choice /M "Found existing MSYS2 version. Do you want to proceed?" if !ERRORLEVEL!==2 goto exit @@ -25,30 +31,26 @@ if exist "%EnvMSYS2Path%\msys%MSYS2Base%\usr\bin\pacman.exe" ( ) ) -if "%MSYS2Architecture%"=="i686" set MSYS2Version=20210705 -if "%MSYS2Architecture%"=="x86_64" set MSYS2Version=20210725 +if exist "%MSYS2UnpackPath%" ( + %cecho% info "Remove previous MSYS2 version" + call "%ToolsPath%\remove-dir.bat" "%MSYS2UnpackPath%" +) -set MSYS2Install=msys2-base-%MSYS2Architecture%-%MSYS2Version%.tar.xz -set MSYS2Url=https://repo.msys2.org/distrib/%MSYS2Architecture%/%MSYS2Install% - -%cecho% info "Remove previous MSYS2 version" -call "%ToolsPath%\remove-dir.bat" "%EnvMSYS2Path%" - -%cecho% info "Download installation files" +%cecho% info "Download MSYS2 installation files" if not exist "%EnvDownloadPath%\%MSYS2Install%" call "%ToolsPath%\download-file.bat" "%MSYS2Url%" "%EnvDownloadPath%\%MSYS2Install%" if not exist "%EnvDownloadPath%\%MSYS2Install%" %cecho% error "Cannot download MSYS" & goto error %cecho% info "Unpack MSYS2" -"%EnvSevenZipExe%" x -so "%EnvDownloadPath%\%MSYS2Install%" | "%EnvSevenZipExe%" x -y -si -ttar -o"%EnvMSYS2Path%" +"%EnvDownloadPath%\%MSYS2Install%" -y -o"%EnvMSYS2Path%" -set MSYS2SH=%EnvMSYS2Path%\msys%MSYS2Base%\usr\bin\sh +set MSYS2SH=%MSYS2UnpackPath%\usr\bin\sh %cecho% info "Initialize MSYS2" "%MSYS2SH%" -lc "yes | pacman --noconfirm -Syuu msys2-keyring" "%MSYS2SH%" -lc "pacman --noconfirm -Sy" "%MSYS2SH%" -lc "pacman --noconfirm -Su" -call "%EnvMSYS2Path%\msys%MSYS2Base%\autorebase.bat" +call "%MSYS2UnpackPath%\autorebase.bat" :exit endlocal diff --git a/build_scripts/Windows-msys2/env/tools/prepare-tools.bat b/build_scripts/Windows-msys2/env/tools/prepare-tools.bat index c6b14a787..66f5f9120 100644 --- a/build_scripts/Windows-msys2/env/tools/prepare-tools.bat +++ b/build_scripts/Windows-msys2/env/tools/prepare-tools.bat @@ -34,7 +34,7 @@ if not exist "%EnvToolsPath%\cecho.exe" ( if not exist "%EnvDownloadPath%\%cCEhoInstall%" echo Cannot download cecho installation& goto error echo Unpack cecho - "%EnvSevenZipExe%" x -o"%EnvTempPath%" "%EnvDownloadPath%\%CEchoInstall%" + "%EnvSevenZipExe%" x -o"%EnvTempPath%" "%EnvDownloadPath%\%CEchoInstall%" -y -bso0 copy "%EnvTempPath%\cecho.exe" "%EnvToolsPath%" call "%ToolsPath%\remove-dir.bat" "%EnvTempPath%" diff --git a/build_scripts/Windows-msys2/env/tools/root/update-msys2.bat b/build_scripts/Windows-msys2/env/tools/root/update-msys2.bat index a3d2398cd..ddd5bdd0f 100644 --- a/build_scripts/Windows-msys2/env/tools/root/update-msys2.bat +++ b/build_scripts/Windows-msys2/env/tools/root/update-msys2.bat @@ -2,18 +2,13 @@ setlocal -if exist "%~dp0msys2\msys32" call :update 32 -if exist "%~dp0msys2\msys64" call :update 64 +if not exist "%~dp0msys2\msys64" goto :EOF -goto :EOF +set MSYS2SH=%~dp0msys2\msys64\usr\bin\sh -:update -set MSYS2SH=%~dp0msys2\msys%~1\usr\bin\sh - -echo Update MSYS2 %~1 +echo Update MSYS2 "%MSYS2SH%" -lc "yes | pacman --noconfirm -Syuu msys2-keyring" "%MSYS2SH%" -lc "pacman --noconfirm -Su" -:exit endlocal goto :EOF diff --git a/build_scripts/Windows/build-libs/Makefile b/build_scripts/Windows/build-libs/Makefile index b7efeaa37..0075770cd 100644 --- a/build_scripts/Windows/build-libs/Makefile +++ b/build_scripts/Windows/build-libs/Makefile @@ -1,7 +1,7 @@ ZLIB_VERSION=1.2.11 BZIP2_VERSION=1.0.8 MINIUPNPC_VERSION=2.2.3 -OPENSSL_VERSION=1.1.1p +OPENSSL_VERSION=1.1.1w SPEEX_VERSION=1.2.0 SPEEXDSP_VERSION=1.2.0 LIBXML2_VERSION=2.9.12 diff --git a/build_scripts/Windows/env/env-msys2.bat b/build_scripts/Windows/env/env-msys2.bat index fee7e46b9..47dd8d96a 100644 --- a/build_scripts/Windows/env/env-msys2.bat +++ b/build_scripts/Windows/env/env-msys2.bat @@ -22,11 +22,12 @@ if "%GCCArchitecture%"=="x64" ( ) set EnvMSYS2Path=%EnvRootPath%\msys2 +set EnvMSYS2BasePath=%EnvMSYS2Path%\msys64 call "%~dp0tools\prepare-msys2.bat" %1 if errorlevel 1 exit /B %ERRORLEVEL% -set EnvMSYS2SH=%EnvMSYS2Path%\msys64\usr\bin\sh.exe +set EnvMSYS2SH=%EnvMSYS2BasePath%\usr\bin\sh.exe if not exist "%EnvMSYS2SH%" if errorlevel 1 goto error_env set EnvMSYS2Cmd="%EnvMSYS2SH%" -lc diff --git a/build_scripts/Windows/env/tools/prepare-msys2.bat b/build_scripts/Windows/env/tools/prepare-msys2.bat index 17fe6c36e..25f00ac30 100644 --- a/build_scripts/Windows/env/tools/prepare-msys2.bat +++ b/build_scripts/Windows/env/tools/prepare-msys2.bat @@ -16,15 +16,15 @@ if "%~1"=="clean" ( goto exit ) -set MSYS2Version=20230318 +set MSYS2Version=20231026 set MSYS2Install=msys2-base-x86_64-%MSYS2Version%.sfx.exe set MSYS2Url=https://github.com/msys2/msys2-installer/releases/download/%MSYS2Version:~0,4%-%MSYS2Version:~4,2%-%MSYS2Version:~6,2%/%MSYS2Install% +set MSYS2UnpackPath=%EnvMSYS2Path%\msys64 set CMakeInstall=cmake-3.19.0-win32-x86.zip set CMakeUrl=https://github.com/Kitware/CMake/releases/download/v3.19.0/%CMakeInstall% -set CMakeUnpackPath=%EnvMSYS2Path%\msys64 -if exist "%CMakeUnpackPath%\usr\bin\pacman.exe" ( +if exist "%MSYS2UnpackPath%\usr\bin\pacman.exe" ( if "%~1"=="reinstall" ( choice /M "Found existing MSYS2 version. Do you want to proceed?" if !ERRORLEVEL!==2 goto exit @@ -33,13 +33,12 @@ if exist "%CMakeUnpackPath%\usr\bin\pacman.exe" ( ) ) - -if exist "%CMakeUnpackPath%" ( +if exist "%MSYS2UnpackPath%" ( %cecho% info "Remove previous MSYS2 version" - call "%ToolsPath%\remove-dir.bat" "%CMakeUnpackPath%" + call "%ToolsPath%\remove-dir.bat" "%MSYS2UnpackPath%" ) -%cecho% info "Download installation files" +%cecho% info "Download MSYS2 installation files" if not exist "%EnvDownloadPath%\%MSYS2Install%" call "%ToolsPath%\download-file.bat" "%MSYS2Url%" "%EnvDownloadPath%\%MSYS2Install%" if not exist "%EnvDownloadPath%\%MSYS2Install%" %cecho% error "Cannot download MSYS" & goto error @@ -50,29 +49,29 @@ if not exist "%EnvDownloadPath%\%CMakeInstall%" %cecho% error "Cannot download C "%EnvDownloadPath%\%MSYS2Install%" -y -o"%EnvMSYS2Path%" %cecho% info "Unpack CMake" -"%EnvSevenZipExe%" x -o"%CMakeUnpackPath%" "%EnvDownloadPath%\%CMakeInstall%" +"%EnvSevenZipExe%" x -o"%MSYS2UnpackPath%" "%EnvDownloadPath%\%CMakeInstall%" -y -bso0 %cecho% info "Install CMake" set CMakeVersion= -for /D %%F in (%CMakeUnpackPath%\cmake*) do set CMakeVersion=%%~nxF +for /D %%F in (%MSYS2UnpackPath%\cmake*) do set CMakeVersion=%%~nxF if "%CMakeVersion%"=="" %cecho% error "CMake version not found." & goto :exit %cecho% info "Found CMake version %CMakeVersion%" set FoundProfile= -for /f "tokens=3" %%F in ('find /c /i "%CMakeVersion%" "%CMakeUnpackPath%\etc\profile"') do set FoundProfile=%%F +for /f "tokens=3" %%F in ('find /c /i "%CMakeVersion%" "%MSYS2UnpackPath%\etc\profile"') do set FoundProfile=%%F if "%FoundProfile%"=="0" ( - echo export PATH="${PATH}:/%CMakeVersion%/bin">>"%CMakeUnpackPath%\etc\profile" + echo export PATH="${PATH}:/%CMakeVersion%/bin">>"%MSYS2UnpackPath%\etc\profile" ) -set MSYS2SH=%CMakeUnpackPath%\usr\bin\sh +set MSYS2SH=%MSYS2UnpackPath%\usr\bin\sh %cecho% info "Initialize MSYS2" "%MSYS2SH%" -lc "yes | pacman --noconfirm -Syuu msys2-keyring" "%MSYS2SH%" -lc "pacman --noconfirm -Sy" "%MSYS2SH%" -lc "pacman --noconfirm -Su" -call "%CMakeUnpackPath%\autorebase.bat" +call "%MSYS2UnpackPath%\autorebase.bat" :exit endlocal diff --git a/build_scripts/Windows/env/tools/prepare-tools.bat b/build_scripts/Windows/env/tools/prepare-tools.bat index c2c1e1bdd..88549faed 100644 --- a/build_scripts/Windows/env/tools/prepare-tools.bat +++ b/build_scripts/Windows/env/tools/prepare-tools.bat @@ -53,7 +53,7 @@ if not exist "%EnvToolsPath%\cecho.exe" ( if not exist "%EnvDownloadPath%\%cCEhoInstall%" echo Cannot download cecho installation& goto error echo Unpack cecho - "%EnvSevenZipExe%" x -o"%EnvTempPath%" "%EnvDownloadPath%\%CEchoInstall%" + "%EnvSevenZipExe%" x -o"%EnvTempPath%" "%EnvDownloadPath%\%CEchoInstall%" -y -bso0 copy "%EnvTempPath%\cecho.exe" "%EnvToolsPath%" call "%ToolsPath%\remove-dir.bat" "%EnvTempPath%" @@ -69,7 +69,7 @@ if not exist "%EnvToolsPath%\depends.exe" ( if not exist "%EnvDownloadPath%\%DependsInstall%" %cecho% error "Cannot download Dependendy Walker installation" & goto error %cecho% info "Unpack Dependency Walker" - "%EnvSevenZipExe%" x -o"%EnvTempPath%" "%EnvDownloadPath%\%DependsInstall%" + "%EnvSevenZipExe%" x -o"%EnvTempPath%" "%EnvDownloadPath%\%DependsInstall%" -y -bso0 copy "%EnvTempPath%\*" "%EnvToolsPath%" call "%ToolsPath%\remove-dir.bat" "%EnvTempPath%" @@ -85,7 +85,7 @@ if not exist "%EnvToolsPath%\cut.exe" ( if not exist "%EnvDownloadPath%\%UnixToolsInstall%" %cecho% error "Cannot download Unix Tools installation" & goto error %cecho% info "Unpack Unix Tools" - "%EnvSevenZipExe%" x -o"%EnvTempPath%" "%EnvDownloadPath%\%UnixToolsInstall%" + "%EnvSevenZipExe%" x -o"%EnvTempPath%" "%EnvDownloadPath%\%UnixToolsInstall%" -y -bso0 copy "%EnvTempPath%\cut.exe" "%EnvToolsPath%" call "%ToolsPath%\remove-dir.bat" "%EnvTempPath%" @@ -101,7 +101,7 @@ if not exist "%EnvToolsPath%\sed.exe" ( if not exist "%EnvDownloadPath%\%UnixToolsInstall%" %cecho% error "Cannot download Unix Tools installation" & goto error %cecho% info "Unpack Unix Tools" - "%EnvSevenZipExe%" x -o"%EnvTempPath%" "%EnvDownloadPath%\%UnixToolsInstall%" + "%EnvSevenZipExe%" x -o"%EnvTempPath%" "%EnvDownloadPath%\%UnixToolsInstall%" -y -bso0 copy "%EnvTempPath%\sed.exe" "%EnvToolsPath%" call "%ToolsPath%\remove-dir.bat" "%EnvTempPath%" @@ -121,7 +121,7 @@ if not exist "%NSISInstallPath%\nsis.exe" ( if not exist "%EnvDownloadPath%\%NSISInstall%" %cecho% error "Cannot download NSIS installation" & goto error %cecho% info "Unpack NSIS" - "%EnvSevenZipExe%" x -o"%EnvTempPath%" "%EnvDownloadPath%\%NSISInstall%" + "%EnvSevenZipExe%" x -o"%EnvTempPath%" "%EnvDownloadPath%\%NSISInstall%" -y -bso0 if not exist "%NSISInstallPath%" mkdir "%NSISInstallPath%" xcopy /s "%EnvTempPath%" "%NSISInstallPath%" @@ -135,7 +135,7 @@ if not exist "%MinGitInstallPath%\cmd\git.exe" ( if not exist "%EnvDownloadPath%\%MinGitInstall%" %cecho% error "Cannot download MinGit installation" & goto error %cecho% info "Unpack MinGit" - "%EnvSevenZipExe%" x -o"%MinGitInstallPath%" "%EnvDownloadPath%\%MinGitInstall%" + "%EnvSevenZipExe%" x -o"%MinGitInstallPath%" "%EnvDownloadPath%\%MinGitInstall%" -y -bso0 ) if not exist "%EnvDownloadPath%\%DoxygenInstall%" call "%ToolsPath%\remove-dir.bat" "%DoxygenInstallPath%" @@ -148,7 +148,7 @@ if not exist "%DoxygenInstallPath%\doxygen.exe" ( if not exist "%EnvDownloadPath%\%DoxygenInstall%" %cecho% error "Cannot download doxygen installation" & goto error %cecho% info "Unpack Doxygen" - "%EnvSevenZipExe%" x -o"%DoxygenInstallPath%" "%EnvDownloadPath%\%DoxygenInstall%" + "%EnvSevenZipExe%" x -o"%DoxygenInstallPath%" "%EnvDownloadPath%\%DoxygenInstall%" -y -bso0 ) if not exist "%EnvDownloadPath%\%CMakeInstall%" call "%ToolsPath%\remove-dir.bat" "%CMakeInstallPath%" @@ -163,7 +163,7 @@ if not exist "%CMakeInstallPath%\bin\cmake.exe" ( if not exist "%EnvDownloadPath%\%CMakeInstall%" %cecho% error "Cannot download CMake installation" & goto error %cecho% info "Unpack CMake" - "%EnvSevenZipExe%" x -o"%EnvTempPath%" "%EnvDownloadPath%\%CMakeInstall%" + "%EnvSevenZipExe%" x -o"%EnvTempPath%" "%EnvDownloadPath%\%CMakeInstall%" -y -bso0 move "%EnvTempPath%\%CMakeVersion%" "%CMakeInstallPath%" @@ -176,7 +176,7 @@ mkdir "%EnvTempPath%" call "%ToolsPath%\download-file.bat" "%TorDownloadIndexUrl%" "%EnvTempPath%\index.html" if not exist "%EnvTempPath%\index.html" %cecho% error "Cannot download Tor installation" & goto error -for /F "tokens=1,2 delims= " %%A in ('%EnvSedExe% -r -n -e"s/.*href=\"^(.*^)^(tor-.*windows-i686\.tar\.gz^)\".*/\2 \1\2/p" "%EnvTempPath%\index.html"') do set TorInstall=%%A& set TorDownloadUrl=%%B +for /F "tokens=1,2 delims= " %%A in ('%EnvSedExe% -r -n -e"s/.*href=\"^(.*^)^(tor-.*windows-i686.*\.tar\.gz^)\".*/\2 \1\2/p" "%EnvTempPath%\index.html"') do set TorInstall=%%A& set TorDownloadUrl=%%B call "%ToolsPath%\remove-dir.bat" "%EnvTempPath%" if "%TorInstall%"=="" %cecho% error "Cannot download Tor installation" & goto error if "%TorDownloadUrl%"=="" %cecho% error "Cannot download Tor installation" & goto error @@ -189,7 +189,7 @@ if not exist "%EnvTorPath%\Tor\tor.exe" ( if not exist "%EnvDownloadPath%\%TorInstall%" %cecho% error "Cannot download Tor installation" & goto error %cecho% info "Unpack Tor" - "%EnvSevenZipExe%" x -so "%EnvDownloadPath%\%TorInstall%" | "%EnvSevenZipExe%" x -si -ttar -o"%EnvTorPath%" + "%EnvSevenZipExe%" x -so "%EnvDownloadPath%\%TorInstall%" | "%EnvSevenZipExe%" x -si -ttar -o"%EnvTorPath%" -y -bso0 ) :exit diff --git a/build_scripts/Windows/installer/retroshare-Qt5.nsi b/build_scripts/Windows/installer/retroshare-Qt5.nsi index 3a7fbf37f..63c81bbcc 100644 --- a/build_scripts/Windows/installer/retroshare-Qt5.nsi +++ b/build_scripts/Windows/installer/retroshare-Qt5.nsi @@ -318,7 +318,7 @@ SectionEnd !ifdef TOR_EXISTS Section /o $(Section_Tor) Section_Tor SetOutPath "$INSTDIR\tor" - File /r "${TORDIR}\*" + File "${TORDIR}\*" SectionEnd !endif diff --git a/libretroshare b/libretroshare index a10087b27..de2b4bd80 160000 --- a/libretroshare +++ b/libretroshare @@ -1 +1 @@ -Subproject commit a10087b27a804d0a43745aa39e7515dd691740f3 +Subproject commit de2b4bd80c57ca757b5f878130f98becf710236d diff --git a/retroshare-gui/src/gui/GenCertDialog.cpp b/retroshare-gui/src/gui/GenCertDialog.cpp index b71e324c7..d3b755f0d 100644 --- a/retroshare-gui/src/gui/GenCertDialog.cpp +++ b/retroshare-gui/src/gui/GenCertDialog.cpp @@ -609,7 +609,9 @@ void GenCertDialog::genPerson() QCoreApplication::processEvents(); QAbstractEventDispatcher* ed = QAbstractEventDispatcher::instance(); - std::cout << "Waiting ed->processEvents()" << std::endl; +#ifdef DEBUG_GENCERTDIALOG + std::cout << "Waiting ed->processEvents()" << std::endl; +#endif time_t waitEnd = time(NULL) + 10;//Wait no more than 10 sec to processEvents if (ed->hasPendingEvents()) while(ed->processEvents(QEventLoop::AllEvents) && (time(NULL) < waitEnd)); diff --git a/retroshare-gui/src/gui/common/NewFriendList.cpp b/retroshare-gui/src/gui/common/NewFriendList.cpp index 893433469..bd6faec41 100644 --- a/retroshare-gui/src/gui/common/NewFriendList.cpp +++ b/retroshare-gui/src/gui/common/NewFriendList.cpp @@ -1619,7 +1619,9 @@ bool NewFriendList::isColumnVisible(int col) const } void NewFriendList::setColumnVisible(int col,bool visible) { +#ifdef DEBUG_NEW_FRIEND_LIST std::cerr << "Setting column " << col << " to be visible: " << visible << std::endl; +#endif ui->peerTreeWidget->setColumnHidden(col, !visible); } void NewFriendList::toggleColumnVisible() diff --git a/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp b/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp index 4a7429f27..7ffdcd687 100755 --- a/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp +++ b/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp @@ -34,6 +34,7 @@ #endif #include "gui/common/FilesDefs.h" +#include "gui/RetroShareLink.h" #include "gui/settings/rsharesettings.h" #include "util/misc.h" #include "ConnectFriendWizard.h" @@ -449,8 +450,9 @@ void ConnectFriendWizard::initializePage(int id) } sockaddr_storage addr ; - +#ifdef DEBUG_FRIENDWIZARD std::cerr << "Cert IP = " << peerDetails.extAddr << std::endl; +#endif if(sockaddr_storage_ipv4_aton(addr,peerDetails.extAddr.c_str()) && sockaddr_storage_isValidNet(addr)) { @@ -870,7 +872,18 @@ void ConnectFriendWizard::cleanFriendCert() bool certValid = false; QString errorMsg ; QString certDetail; - std::string cert = ui->friendCertEdit->toPlainText().toUtf8().constData(); + + std::string cert ; + RetroShareLink rslink(ui->friendCertEdit->toPlainText()); + + if(rslink.valid() && rslink.type() == RetroShareLink::TYPE_CERTIFICATE) + cert = rslink.radix().toStdString(); + else + cert = ui->friendCertEdit->toPlainText().toUtf8().constData(); + +#ifdef DEBUG_FRIENDWIZARD + std::cerr << "Friend cert:\"" << cert << "\"" << std::endl; +#endif if (cert.empty()) { ui->friendCertCleanLabel->setToolTip(""); @@ -936,7 +949,7 @@ void ConnectFriendWizard::cleanFriendCert() void ConnectFriendWizard::pasteCert() { QClipboard *clipboard = QApplication::clipboard(); - ui->friendCertEdit->setPlainText(clipboard->text()); + ui->friendCertEdit->setPlainText(clipboard->text()); } void ConnectFriendWizard::openCert() diff --git a/retroshare-gui/src/gui/feeds/GxsChannelGroupItem.cpp b/retroshare-gui/src/gui/feeds/GxsChannelGroupItem.cpp index e9c38a022..a6213e740 100644 --- a/retroshare-gui/src/gui/feeds/GxsChannelGroupItem.cpp +++ b/retroshare-gui/src/gui/feeds/GxsChannelGroupItem.cpp @@ -37,20 +37,47 @@ GxsChannelGroupItem::GxsChannelGroupItem(FeedHolder *feedHolder, uint32_t feedId GxsGroupFeedItem(feedHolder, feedId, groupId, isHome, rsGxsChannels, autoUpdate) { setup(); - requestGroup(); + addEventHandler(); } GxsChannelGroupItem::GxsChannelGroupItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsChannelGroup &group, bool isHome, bool autoUpdate) : GxsGroupFeedItem(feedHolder, feedId, group.mMeta.mGroupId, isHome, rsGxsChannels, autoUpdate) { - setup(); + setup(); + setGroup(group); + addEventHandler(); +} - setGroup(group); +void GxsChannelGroupItem::addEventHandler() +{ + mEventHandlerId = 0; + rsEvents->registerEventsHandler( [this](std::shared_ptr event) + { + RsQThreadUtils::postToObject([=]() + { + const auto *e = dynamic_cast(event.get()); + + if(!e || e->mChannelGroupId != this->groupId()) + return; + + switch(e->mChannelEventCode) + { + case RsChannelEventCode::SUBSCRIBE_STATUS_CHANGED: + case RsChannelEventCode::UPDATED_CHANNEL: + case RsChannelEventCode::RECEIVED_PUBLISH_KEY: + loadGroup(); + break; + default: + break; + } + }, this ); + }, mEventHandlerId, RsEventType::GXS_CHANNELS ); } GxsChannelGroupItem::~GxsChannelGroupItem() { + rsEvents->unregisterEventsHandler(mEventHandlerId); delete(ui); } diff --git a/retroshare-gui/src/gui/feeds/GxsChannelGroupItem.h b/retroshare-gui/src/gui/feeds/GxsChannelGroupItem.h index cd7f6510b..b0366bc98 100644 --- a/retroshare-gui/src/gui/feeds/GxsChannelGroupItem.h +++ b/retroshare-gui/src/gui/feeds/GxsChannelGroupItem.h @@ -60,12 +60,14 @@ private slots: private: void fill(); void setup(); + void addEventHandler(); private: RsGxsChannelGroup mGroup; /** Qt Designer generated object */ Ui::GxsChannelGroupItem *ui; + RsEventsHandlerId_t mEventHandlerId; }; #endif diff --git a/retroshare-gui/src/gui/feeds/GxsChannelGroupItem.ui b/retroshare-gui/src/gui/feeds/GxsChannelGroupItem.ui index 151e6920b..e17f53c48 100644 --- a/retroshare-gui/src/gui/feeds/GxsChannelGroupItem.ui +++ b/retroshare-gui/src/gui/feeds/GxsChannelGroupItem.ui @@ -251,7 +251,7 @@ Qt::NoFocus - Subscribe to Channel + Subscribe this Channel Subscribe diff --git a/retroshare-gui/src/gui/feeds/GxsForumGroupItem.cpp b/retroshare-gui/src/gui/feeds/GxsForumGroupItem.cpp index 43c94a377..663951a6c 100644 --- a/retroshare-gui/src/gui/feeds/GxsForumGroupItem.cpp +++ b/retroshare-gui/src/gui/feeds/GxsForumGroupItem.cpp @@ -35,8 +35,8 @@ GxsForumGroupItem::GxsForumGroupItem(FeedHolder *feedHolder, uint32_t feedId, co GxsGroupFeedItem(feedHolder, feedId, groupId, isHome, rsGxsForums, autoUpdate) { setup(); - requestGroup(); + addEventHandler(); } GxsForumGroupItem::GxsForumGroupItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId &groupId, const std::list& added_moderators,const std::list& removed_moderators,bool isHome, bool autoUpdate): @@ -45,21 +45,48 @@ GxsForumGroupItem::GxsForumGroupItem(FeedHolder *feedHolder, uint32_t feedId, co mRemovedModerators(removed_moderators) { setup(); - requestGroup(); + addEventHandler(); +} + +void GxsForumGroupItem::addEventHandler() +{ + mEventHandlerId = 0; + rsEvents->registerEventsHandler( [this](std::shared_ptr event) + { + RsQThreadUtils::postToObject([=]() + { + const auto *e = dynamic_cast(event.get()); + + if(!e || e->mForumGroupId != this->groupId()) + return; + + switch(e->mForumEventCode) + { + case RsForumEventCode::SUBSCRIBE_STATUS_CHANGED: + case RsForumEventCode::UPDATED_FORUM: + case RsForumEventCode::MODERATOR_LIST_CHANGED: + loadGroup(); + break; + default: + break; + } + }, this ); + }, mEventHandlerId, RsEventType::GXS_FORUMS ); } GxsForumGroupItem::GxsForumGroupItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsForumGroup &group, bool isHome, bool autoUpdate) : GxsGroupFeedItem(feedHolder, feedId, group.mMeta.mGroupId, isHome, rsGxsForums, autoUpdate) { setup(); - setGroup(group); + addEventHandler(); } GxsForumGroupItem::~GxsForumGroupItem() { - delete(ui); + rsEvents->unregisterEventsHandler(mEventHandlerId); + delete(ui); } void GxsForumGroupItem::setup() diff --git a/retroshare-gui/src/gui/feeds/GxsForumGroupItem.h b/retroshare-gui/src/gui/feeds/GxsForumGroupItem.h index 29b7851f2..d80671e5a 100644 --- a/retroshare-gui/src/gui/feeds/GxsForumGroupItem.h +++ b/retroshare-gui/src/gui/feeds/GxsForumGroupItem.h @@ -22,6 +22,7 @@ #define _GXSFORUMGROUPITEM_H #include +#include #include "gui/gxs/GxsGroupFeedItem.h" namespace Ui { @@ -39,27 +40,28 @@ public: GxsForumGroupItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId &groupId, bool isHome, bool autoUpdate); GxsForumGroupItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId &groupId, const std::list& added_moderators,const std::list& removed_moderators,bool isHome, bool autoUpdate); GxsForumGroupItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsForumGroup &group, bool isHome, bool autoUpdate); - ~GxsForumGroupItem(); + virtual ~GxsForumGroupItem() override; bool setGroup(const RsGxsForumGroup &group); uint64_t uniqueIdentifier() const override { return hash_64bits("GxsForumGroupItem " + groupId().toStdString()) ; } protected: /* FeedItem */ - virtual void doExpand(bool open); - void toggle() override; + virtual void doExpand(bool open) override; /* GxsGroupFeedItem */ - virtual QString groupName(); + virtual QString groupName() override; virtual void loadGroup() override; - virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_FORUM; } + virtual RetroShareLink::enumType getLinkType() override { return RetroShareLink::TYPE_FORUM; } private slots: void subscribeForum(); + void toggle() override; private: void fill(); void setup(); + void addEventHandler(); private: RsGxsForumGroup mGroup; @@ -69,6 +71,8 @@ private: std::list mAddedModerators; std::list mRemovedModerators; + + RsEventsHandlerId_t mEventHandlerId; }; #endif diff --git a/retroshare-gui/src/gui/settings/JsonApiPage.cc b/retroshare-gui/src/gui/settings/JsonApiPage.cc index 67e5f22b8..2b7f25d80 100644 --- a/retroshare-gui/src/gui/settings/JsonApiPage.cc +++ b/retroshare-gui/src/gui/settings/JsonApiPage.cc @@ -64,9 +64,19 @@ JsonApiPage::JsonApiPage(QWidget */*parent*/, Qt::WindowFlags /*flags*/) mEventHandlerId = 0; - rsEvents->registerEventsHandler( [this](std::shared_ptr /* event */) + rsEvents->registerEventsHandler( [this](std::shared_ptr e) { - std::cerr << "Caught JSONAPI event!" << std::endl; + if(e->mType != RsEventType::JSON_API) + return; + + auto je = dynamic_cast(e.get()); + + if(!je) + return; +#ifdef DEBUG + std::cerr << "Caught JSONAPI event! code=" << static_cast(je->mJsonApiEventCode) << std::endl; +#endif + RsQThreadUtils::postToObject([=]() { load(); }, this ); }, mEventHandlerId, RsEventType::JSON_API ); diff --git a/retroshare-gui/src/gui/settings/WebuiPage.cpp b/retroshare-gui/src/gui/settings/WebuiPage.cpp index d7ff0b894..4b36b758c 100644 --- a/retroshare-gui/src/gui/settings/WebuiPage.cpp +++ b/retroshare-gui/src/gui/settings/WebuiPage.cpp @@ -58,7 +58,9 @@ WebuiPage::WebuiPage(QWidget */*parent*/, Qt::WindowFlags /*flags*/) rsEvents->registerEventsHandler( [this](std::shared_ptr /* event */) { +#ifdef DEBUG std::cerr << "Caught JSONAPI event in webui!" << std::endl; +#endif RsQThreadUtils::postToObject([=]() { load(); }, this ); }, mEventsHandlerId, RsEventType::JSON_API ); @@ -132,7 +134,9 @@ bool WebuiPage::restart() void WebuiPage::loadParams() { - std::cerr << "WebuiPage::load()" << std::endl; +#ifdef DEBUG + std::cerr << "WebuiPage::load()" << std::endl; +#endif whileBlocking(ui.enableWebUI_CB)->setChecked(Settings->getWebinterfaceEnabled()); whileBlocking(ui.webInterfaceFiles_LE)->setText(Settings->getWebinterfaceFilesDirectory()); @@ -142,6 +146,8 @@ void WebuiPage::loadParams() if(it != smap.end()) whileBlocking(ui.password_LE)->setText(QString::fromStdString(it->second)); + else + whileBlocking(ui.enableWebUI_CB)->setChecked(false); if(rsWebUi->isRunning()) ui.statusLabelLED->setPixmap(FilesDefs::getPixmapFromQtResourcePath(IMAGE_LEDON)) ; diff --git a/retroshare-gui/src/main.cpp b/retroshare-gui/src/main.cpp index e33fe795d..13710a28b 100644 --- a/retroshare-gui/src/main.cpp +++ b/retroshare-gui/src/main.cpp @@ -22,6 +22,7 @@ #include "util/stacktrace.h" #include "util/argstream.h" +#include "retroshare/rswebui.h" CrashStackTrace gCrashStackTrace; @@ -380,7 +381,7 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO); return 1; } - /* recreate global settings object, now with correct path */ + /* recreate global settings object, now with correct path, specific to the selected node */ RshareSettings::Create(true); Rshare::resetLanguageAndStyle(); @@ -537,8 +538,9 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO); // qRegisterMetaType("RsPeerId") ; - +#ifdef DEBUG std::cerr << "connecting signals and slots" << std::endl ; +#endif QObject::connect(notify,SIGNAL(deferredSignatureHandlingRequested()),notify,SLOT(handleSignatureEvent()),Qt::QueuedConnection) ; QObject::connect(notify,SIGNAL(chatLobbyTimeShift(int)),notify,SLOT(handleChatLobbyTimeShift(int)),Qt::QueuedConnection) ; QObject::connect(notify,SIGNAL(diskFull(int,int)) ,w ,SLOT(displayDiskSpaceWarning(int,int))) ; @@ -571,13 +573,18 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO); notify->enable() ; // enable notification system after GUI creation, to avoid data races in Qt. -#ifdef RS_JSONAPI - JsonApiPage::checkStartJsonApi(); + // Read webui params in settings. We cannot save them to some webui.cfg because cfg needs the node id and + // jsonapi is started before node ID selection in retroshare-service. +#ifdef RS_JSONAPI #ifdef RS_WEBUI - WebuiPage::checkStartWebui(); // normally we should rather save the UI flags internally to p3webui + conf.enableWebUI = Settings->getWebinterfaceEnabled(); + + if(!Settings->getWebinterfaceFilesDirectory().isNull()) + rsWebUi->setHtmlFilesDirectory(Settings->getWebinterfaceFilesDirectory().toStdString()); +#endif + RsInit::startupWebServices(conf,false); #endif -#endif // RS_JSONAPI /* dive into the endless loop */ int ti = rshare.exec(); diff --git a/retroshare-gui/src/rshare.cpp b/retroshare-gui/src/rshare.cpp index 8fb8fdc58..e5f450f57 100644 --- a/retroshare-gui/src/rshare.cpp +++ b/retroshare-gui/src/rshare.cpp @@ -139,17 +139,22 @@ static bool notifyRunningInstance() // that a new process had been started QLocalSocket localSocket; localSocket.connectToServer(QString(TARGET)); - +#ifdef DEBUG std::cerr << "Rshare::Rshare waitForConnected to other instance." << std::endl; +#endif if( localSocket.waitForConnected(100) ) { +#ifdef DEBUG std::cerr << "Rshare::Rshare Connection etablished. Waiting for disconnection." << std::endl; +#endif localSocket.waitForDisconnected(1000); return true; } else { +#ifdef DEBUG std::cerr << "Rshare::Rshare failed to connect to other instance." << std::endl; +#endif return false; } } diff --git a/retroshare-service/src/retroshare-service.cc b/retroshare-service/src/retroshare-service.cc index 040a2012d..ac82593da 100644 --- a/retroshare-service/src/retroshare-service.cc +++ b/retroshare-service/src/retroshare-service.cc @@ -33,6 +33,7 @@ #include "retroshare/rsiface.h" #include "util/stacktrace.h" +#include "util/rsprint.h" #include "util/argstream.h" #include "util/rskbdinput.h" #include "util/rsdir.h" @@ -48,6 +49,28 @@ static CrashStackTrace gCrashStackTrace; +// We should move these functions to rsprint in libretroshare + +#define COLOR_GREEN 0 +#define COLOR_YELLOW 1 +#define COLOR_BLUE 2 +#define COLOR_PURPLE 3 +#define COLOR_RED 4 + +std::string colored(int color,const std::string& s) +{ + switch(color) + { + case COLOR_GREEN : return "\033[0;32m"+s+"\033[0m"; + case COLOR_YELLOW: return "\033[0;33m"+s+"\033[0m"; + case COLOR_BLUE : return "\033[0;36m"+s+"\033[0m"; + case COLOR_PURPLE: return "\033[0;35m"+s+"\033[0m"; + case COLOR_RED : return "\033[0;31m"+s+"\033[0m"; + default: + return s; + } +} + #ifdef RS_SERVICE_TERMINAL_LOGIN class RsServiceNotify: public NotifyClient { @@ -59,9 +82,7 @@ public: const std::string& title, const std::string& question, bool /*prev_is_bad*/, std::string& password, bool& cancel ) { - std::string question1 = title + - "\nPlease enter your PGP password for key:\n " + - question + " :"; + std::string question1 = title + colored(COLOR_GREEN,"Please enter your PGP password for key:\n ") + question + " :"; password = RsUtil::rs_getpass(question1.c_str()) ; cancel = false ; @@ -90,6 +111,33 @@ int main(int argc, char* argv[]) signal(SIGBREAK, signalHandler); #endif // ifdef SIGBREAK +#ifdef WINDOWS_SYS + // Enable ANSI color support in Windows console + { +#ifndef ENABLE_VIRTUAL_TERMINAL_PROCESSING +#define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x4 +#endif + + HANDLE hStdin = GetStdHandle(STD_OUTPUT_HANDLE); + if (hStdin) { + DWORD consoleMode; + if (GetConsoleMode(hStdin, &consoleMode)) { + if ((consoleMode & ENABLE_VIRTUAL_TERMINAL_PROCESSING) == 0) { + if (SetConsoleMode(hStdin, consoleMode | ENABLE_VIRTUAL_TERMINAL_PROCESSING)) { + std::cout << "Enabled ANSI color support in console" << std::endl; + } else { + RsErr() << "Error getting console mode" << std::endl; + } + } + } else { + RsErr() << "Error getting console mode" << std::endl; + } + } else { + RsErr() << "Error getting stdin handle" << std::endl; + } + } +#endif + RsInfo() << "\n" << "+================================================================+\n" "| o---o o |\n" @@ -181,31 +229,45 @@ int main(int argc, char* argv[]) while(keepRunning) { - webui_pass1 = RsUtil::rs_getpass( - "Please register a password for the web interface: " ); - webui_pass2 = RsUtil::rs_getpass( - "Please enter the same password again : " ); + webui_pass1 = RsUtil::rs_getpass( colored(COLOR_GREEN,"Please register a password for the web interface: ")); + webui_pass2 = RsUtil::rs_getpass( colored(COLOR_GREEN,"Please enter the same password again : ")); if(webui_pass1 != webui_pass2) { - std::cout << "Passwords do not match!" << std::endl; + std::cout << colored(COLOR_RED,"Passwords do not match!") << std::endl; continue; } if(webui_pass1.empty()) { - std::cout << "Password cannot be empty!" << std::endl; + std::cout << colored(COLOR_RED,"Password cannot be empty!") << std::endl; continue; } break; } } +#ifdef RS_SERVICE_TERMINAL_WEBUI_PASSWORD + if(askWebUiPassword && !webui_pass1.empty()) + { + rsWebUi->setHtmlFilesDirectory(webui_base_directory); + conf.webUIPasswd = webui_pass1; // cannot be set using rsWebUI methods because it calls the still non-existent rsJsonApi + conf.enableWebUI = true; + + // JsonApi is started below in InitRetroShare(). Not calling restart here avoids multiple restart. + } +#endif #endif /* defined(RS_JSONAPI) && defined(RS_WEBUI) && defined(RS_SERVICE_TERMINAL_WEBUI_PASSWORD) */ conf.main_executable_path = argv[0]; int initResult = RsInit::InitRetroShare(conf); + +#ifdef RS_JSONAPI + RsInit::startupWebServices(conf,true); + rstime::rs_usleep(1000000); // waits for jas->restart to print stuff +#endif + if(initResult != RS_INIT_OK) { RsFatal() << "Retroshare core initalization failed with: " << initResult @@ -223,28 +285,27 @@ int main(int argc, char* argv[]) if(locations.size() == 0) { - RsErr() << "No available accounts. You cannot use option -U list" << std::endl; + RsErr() << colored(COLOR_RED,"No available accounts. You cannot use option -U list") << std::endl; return -RsInit::ERR_NO_AVAILABLE_ACCOUNT; } std::cout << std::endl << std::endl - << "Available accounts:" << std::endl; + << colored(COLOR_GREEN,"Available accounts:") << std::endl<( ceil(log(locations.size())/log(10.0)) ); for( uint32_t i=0; i= locations.size())) { - std::cout << "Please enter account number: "; + std::cout << colored(COLOR_GREEN,"Please enter account number: "); std::cout.flush(); std::string inputStr; @@ -264,7 +325,7 @@ int main(int argc, char* argv[]) RsPeerId ssl_id(prefUserString); if(ssl_id.isNull()) { - RsErr() << "Invalid User location id: a hexadecimal ID is expected." + RsErr() << colored(COLOR_RED,"Invalid User location id: a hexadecimal ID is expected.") << std::endl; return -EINVAL; } @@ -299,7 +360,7 @@ int main(int argc, char* argv[]) if(RsAccounts::isTorAuto()) { - std::cerr << "(II) Hidden service is ready:" << std::endl; + std::cerr << colored(COLOR_GREEN,"(II) Hidden service is ready:") << std::endl; std::string service_id ; std::string onion_address ; @@ -312,13 +373,13 @@ int main(int argc, char* argv[]) RsTor::getHiddenServiceInfo(service_id,onion_address,service_port,service_target_address,service_target_port); RsTor::getProxyServerInfo(proxy_server_address,proxy_server_port) ; - std::cerr << " onion address : " << onion_address << std::endl; - std::cerr << " service_id : " << service_id << std::endl; - std::cerr << " service port : " << service_port << std::endl; - std::cerr << " target port : " << service_target_port << std::endl; - std::cerr << " target address : " << service_target_address << std::endl; + std::cerr << colored(COLOR_GREEN," onion address : ") << onion_address << std::endl; + std::cerr << colored(COLOR_GREEN," service_id : ") << service_id << std::endl; + std::cerr << colored(COLOR_GREEN," service port : ") << service_port << std::endl; + std::cerr << colored(COLOR_GREEN," target port : ") << service_target_port << std::endl; + std::cerr << colored(COLOR_GREEN," target address : ") << service_target_address << std::endl; - std::cerr << "Setting proxy server to " << service_target_address << ":" << service_target_port << std::endl; + std::cerr << colored(COLOR_GREEN,"Setting proxy server to ") << service_target_address << ":" << service_target_port << std::endl; rsPeers->setLocalAddress(rsPeers->getOwnId(), service_target_address, service_target_port); rsPeers->setHiddenNode(rsPeers->getOwnId(), onion_address, service_port); @@ -327,15 +388,6 @@ int main(int argc, char* argv[]) } #endif // def RS_SERVICE_TERMINAL_LOGIN -#if (defined(RS_JSONAPI) && defined(RS_WEBUI)) && defined(RS_SERVICE_TERMINAL_WEBUI_PASSWORD) - if(rsJsonApi && !webui_pass1.empty()) - { - rsWebUi->setHtmlFilesDirectory(webui_base_directory); - rsWebUi->setUserPassword(webui_pass1); - rsWebUi->restart(); - } -#endif - rsControl->setShutdownCallback([&](int){keepRunning = false;}); while(keepRunning) diff --git a/retroshare-webui b/retroshare-webui index 542a8c07b..ddd8b0b24 160000 --- a/retroshare-webui +++ b/retroshare-webui @@ -1 +1 @@ -Subproject commit 542a8c07bd02f9bb9082f7aba5aaaed54e643fc1 +Subproject commit ddd8b0b241c21940c7addc20c3cce774ff8dc021