diff --git a/.gitignore b/.gitignore index b4dfddcac..606e522a3 100644 --- a/.gitignore +++ b/.gitignore @@ -21,7 +21,7 @@ Thumbs.db !supportlibs/libsam3/Makefile # QtCreator cruft -*CMakeLists.txt.user +*CMakeLists.txt.user* # Build artifacts /jsonapi-generator/src/jsonapi-generator diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c91f867a5..45fed1bb2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,7 +1,7 @@ -image: docker:stable +image: docker:latest services: - - docker:stable-dind + - docker:dind stages: - build @@ -18,6 +18,7 @@ variables: build-ubuntu-test-image: stage: build script: + - docker --version - > docker login "$CI_REGISTRY" --username "$CI_REGISTRY_USER" @@ -35,6 +36,7 @@ build-ubuntu-test-image: test-ubuntu: stage: test script: + - docker --version - > docker login "$CI_REGISTRY" --username "$CI_REGISTRY_USER" diff --git a/.gitmodules b/.gitmodules index 3c767cf19..7692f4556 100644 --- a/.gitmodules +++ b/.gitmodules @@ -10,7 +10,8 @@ [submodule "supportlibs/udp-discovery-cpp"] path = supportlibs/udp-discovery-cpp url = https://github.com/truvorskameikin/udp-discovery-cpp.git - branch = develop + branch = master +# develop branch was removed we were using it at commit f3a3103a6c52e5707629e8d0a7e279a7758fe845 [submodule "supportlibs/rapidjson"] path = supportlibs/rapidjson url = https://github.com/Tencent/rapidjson.git @@ -30,8 +31,8 @@ branch = master [submodule "libretroshare"] path = libretroshare - url = ../libretroshare + url = https://github.com/RetroShare/libretroshare.git branch = master [submodule "retroshare-webui"] path = retroshare-webui - url = ../RSNewWebUI + url = https://github.com/RetroShare/RSNewWebUI.git diff --git a/build_scripts/GitlabCI/base.Dockerfile b/build_scripts/GitlabCI/base.Dockerfile index 13097f58d..5fd1bd81d 100644 --- a/build_scripts/GitlabCI/base.Dockerfile +++ b/build_scripts/GitlabCI/base.Dockerfile @@ -40,18 +40,23 @@ RUN git clone --depth 1 https://github.com/aetilius/pHash.git && \ rm -rf pHash-build pHash ARG FRESHCLONE=0 -ARG REPO_URL=https://gitlab.com/RetroShare/RetroShare.git +ARG REPO_URL=https://github.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 && \ +RUN git clone $REPO_DEPTH $REPO_URL -b $REPO_BRANCH && \ + cd RetroShare && \ git fetch --tags && \ - git submodule update --init --remote --force \ - libbitdht/ libretroshare/ openpgpsdk/ && \ - cd .. + git submodule update --init \ + libbitdht/ libretroshare/ openpgpsdk/ retroshare-webui/ \ + supportlibs/restbed/ && \ + cd supportlibs/restbed/ && \ + git submodule update --init \ + dependency/asio/ dependency/kashmir/ && \ + cd ../../../ RUN \ mkdir RetroShare-build && cd RetroShare-build && \ cmake -B. -S../RetroShare/retroshare-service \ - -DRS_FORUM_DEEP_INDEX=ON -DRS_JSON_API=ON && \ + -DRS_FORUM_DEEP_INDEX=ON -DRS_JSON_API=ON -DRS_WEBUI=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 c62c4d198..5ae3f4ed3 100644 --- a/build_scripts/GitlabCI/gitlabCI.Dockerfile +++ b/build_scripts/GitlabCI/gitlabCI.Dockerfile @@ -2,19 +2,19 @@ FROM registry.gitlab.com/retroshare/retroshare:base RUN apt-get update -y && apt-get upgrade -y -ARG REPO_URL=https://gitlab.com/RetroShare/RetroShare.git +ARG REPO_URL=https://github.com/RetroShare/RetroShare.git ARG REPO_BRANCH=master 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 submodule update --init \ + libbitdht/ libretroshare/ openpgpsdk/ retroshare-webui/ && \ git --no-pager log --max-count 1 RUN \ mkdir RetroShare-build && cd RetroShare-build && \ cmake -B. -S../RetroShare/retroshare-service \ - -DRS_FORUM_DEEP_INDEX=ON -DRS_JSON_API=ON \ + -DRS_FORUM_DEEP_INDEX=ON -DRS_JSON_API=ON -DRS_WEBUI=ON \ -DRS_WARN_DEPRECATED=OFF -DRS_WARN_LESS=ON && \ make -j$(nproc) && make install && \ cd .. && rm -rf RetroShare-build diff --git a/build_scripts/OBS b/build_scripts/OBS index df16cb915..97a75f2f0 160000 --- a/build_scripts/OBS +++ b/build_scripts/OBS @@ -1 +1 @@ -Subproject commit df16cb915465d058c75277678799ce4dadeae287 +Subproject commit 97a75f2f098babf2f6498f01ff9119aa35ce9a28 diff --git a/build_scripts/OSX/MacOS_X_InstallGuide.md b/build_scripts/OSX/MacOS_X_InstallGuide.md index 6dafd63c0..b3dc0e88d 100644 --- a/build_scripts/OSX/MacOS_X_InstallGuide.md +++ b/build_scripts/OSX/MacOS_X_InstallGuide.md @@ -30,13 +30,36 @@ In GitHub Desktop -> Clone Repository -> URL Add Repository URL: https://github.com/RetroShare/RetroShare.git and Clone +## ***Get XCode & MacOSX SDK*** + +Install XCode following this guide: [XCode](http://guide.macports.org/#installing.xcode) + +To identify the correct version of Xcode to install, you need to know which OS you are running. Go to the [x] menu -> "About This Mac" and read the macOS version number. + +If you are running the macOS Catalina >= 10.15, you can install Xcode directly from App Store using the instructions below. + +You can find older versions of Xcode at [Apple Developer Downloads](https://developer.apple.com/downloads/). Find the appropriate .xip file for your macOS version + +To install from App Store: + +Select [x] menu - > "App Storeā€¦". +Search for Xcode. Download and install. + +Once Xcode has installed, you must drag the XCode icon into your Applications folder. After you have done this, open Xcode from the Applications folder by double-clicking on the icon and then follow the remaining instructions below. + +Install XCode command line developer tools: + + $xcode-select --install + +Start XCode to get it updated and to able C compiler to create executables. + +Get Your MacOSX SDK if missing: [MacOSX-SDKs](https://github.com/phracker/MacOSX-SDKs) + ## ***Choose if you use MacPort or HomeBrew*** ### MacPort Installation -Install MacPort and XCode following this guide: [MacPort and XCode](http://guide.macports.org/#installing.xcode) - -Start XCode to get it updated and to able C compiler to create executables. +Install MacPort following this guide: [MacPort](http://guide.macports.org/#installing.xcode) #### Install libraries @@ -51,18 +74,11 @@ For VOIP Plugin: $ sudo port install opencv $ sudo port install ffmpeg -Get Your OSX SDK if missing: [MacOSX-SDKs](https://github.com/phracker/MacOSX-SDKs) ### HOMEBREW Installation Install HomeBrew following this guide: [HomeBrew](http://brew.sh/) -Install XCode command line developer tools: - - $xcode-select --install - -Start XCode to get it updated and to able C compiler to create executables. - #### Install libraries $ brew install openssl @@ -86,7 +102,6 @@ For FeedReader Plugin: $ brew install libxslt -Get Your OSX SDK if missing: [MacOSX-SDKs](https://github.com/phracker/MacOSX-SDKs) ## Last Settings @@ -104,11 +119,8 @@ In QtCreator Projects -> Build -> Build Settings -> Build Steps -> Add Additiona ## Set your Mac OS SDK version -Edit RetroShare.pro - CONFIG += c++14 rs_macos11.1 - -and then retroshare.pri +Edit retroshare.pri and set your installed sdk version example for 11.1 -> rs_macos11.1 (line 135:) macx:CONFIG *= rs_macos11.1 rs_macos10.8:CONFIG -= rs_macos11.1 @@ -122,7 +134,7 @@ and then retroshare.pri ## Link Include & Libraries -Edit your retroshare.pri and add to macx-* section +When required edit your retroshare.pri macx-* section, check if the Include and Lib path are correct (macx-* section) INCLUDEPATH += "/usr/local/opt/openssl/include" QMAKE_LIBDIR += "/usr/local/opt/openssl/lib" @@ -131,13 +143,18 @@ Edit your retroshare.pri and add to macx-* section alternative via Terminal - $ qmake INCLUDEPATH+="/usr/local/opt/openssl/include" QMAKE_LIBDIR+="/usr/local/opt/openssl/lib" QMAKE_LIBDIR+="/usr/local/opt/sqlcipher/lib" QMAKE_LIBDIR+="/usr/local/opt/miniupnpc/lib" + $ qmake + INCLUDEPATH+="/usr/local/opt/openssl/include" \ + QMAKE_LIBDIR+="/usr/local/opt/openssl/lib" \ + QMAKE_LIBDIR+="/usr/local/opt/sqlcipher/lib" \ + QMAKE_LIBDIR+="/usr/local/opt/miniupnpc/lib" \ + CONFIG+=rs_autologin \ + CONFIG+=rs_use_native_dialogs \ + CONFIG+=release \ + .. -For FeedReader Plugin: - INCLUDEPATH += "/usr/local/opt/libxml2/include/libxml2" - -For building RetroShare with plugins: +With plugins: $ qmake \ INCLUDEPATH+="/usr/local/opt/openssl/include" QMAKE_LIBDIR+="/usr/local/opt/openssl/lib" \ @@ -159,13 +176,30 @@ For building RetroShare with plugins: You can now compile RetroShare into Qt Creator or with Terminal - cd retroshare - qmake; make + $ cd /path/to/retroshare + $ qmake .. + $ make You can change Target and SDK in *./retroshare.pri:82* changing value of QMAKE_MACOSX_DEPLOYMENT_TARGET and QMAKE_MAC_SDK You can find the compiled application at *./retroshare/retroshare-gui/src/retroshare.app* +## Issues + +If you have issues with openssl (Undefined symbols for architecture x86_64) try to add to *~/.profile* file this or via Terminal + + export PATH="/usr/local/opt/openssl/bin:$PATH" + export LDFLAGS="-L/usr/local/opt/openssl/lib" + export CPPFLAGS="-I/usr/local/opt/openssl/include" + export PKG_CONFIG_PATH="/usr/local/opt/openssl/lib/pkgconfig" + +For Qt Creator -> QtCreator Projects -> Build -> Build Settings -> Build Steps -> Add Additional arguments: + + LDFLAGS="-L/usr/local/opt/openssl/lib" + CPPFLAGS="-I/usr/local/opt/openssl/include" + + + ## Copy Plugins $ cp \ diff --git a/build_scripts/OSX/makeOSXPackage.sh b/build_scripts/OSX/makeOSXPackage.sh new file mode 100644 index 000000000..b599df3c3 --- /dev/null +++ b/build_scripts/OSX/makeOSXPackage.sh @@ -0,0 +1,50 @@ +#!/bin/sh + +APP="RetroShare" +RSVERSION="0.6.7a" +QTVERSION="Qt-5.14.1" + +# Install the 7z to create dmg archives. +#brew list p7zip || brew install p7zip + +# Package your app +echo "Packaging retroshare..." +#cd ${project_dir}/build/macOS/clang/x86_64/release/ +cd retroshare-gui/src/ + +# Remove build directories that you don't want to deploy +rm -rf moc +rm -rf obj +rm -rf qrc + +# This sets the CFBundleVersion & CFBundleShortVersionString string +#/usr/libexec/PlistBuddy -c "Delete :CFBundleGetInfoString" retroshare.app/Contents/Info.plist +/usr/libexec/PlistBuddy -c "Add :CFBundleVersion string $RSVERSION" retroshare.app/Contents/Info.plist +/usr/libexec/PlistBuddy -c "Add :CFBundleShortVersionString string $RSVERSION" retroshare.app/Contents/Info.plist + +# This automatically creates retroshare.dmg + +echo "Creating dmg archive..." +macdeployqt retroshare.app -dmg + +DATE=`date +"%m-%d-%Y"` +MACVERSION=`sw_vers -productVersion` +#RSVERSION=`git describe --abbrev=0 --tags` +GITHEAD=`git rev-parse --short HEAD` + +mv $APP.dmg "$APP-$RSVERSION-$GITHEAD-$DATE-MacOS-$MACVERSION-$QTVERSION.dmg" + +# You can use the appdmg command line app to create your dmg file if +# you want to use a custom background and icon arrangement. I'm still +# working on this for my apps, myself. If you want to do this, you'll +# remove the -dmg option above. +# appdmg json-path YourApp_${TRAVIS_TAG}.dmg + +# Copy other project files +cp "../../libbitdht/src/bitdht/bdboot.txt" "retroshare.app/Contents/Resources/" +cp "../../plugins/FeedReader/lib/libFeedReader.dylib" "retroshare.app/Contents/Resources/" +cp -R "sounds" "retroshare.app/Contents/Resources/sounds" + +# cp "${project_dir}/README.md" "README.md" +# cp "${project_dir}/LICENSE" "LICENSE" +# cp "${project_dir}/Qt License" "Qt License" 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/build/build.bat b/build_scripts/Windows/build/build.bat index 487647568..91ff71382 100644 --- a/build_scripts/Windows/build/build.bat +++ b/build_scripts/Windows/build/build.bat @@ -56,7 +56,7 @@ if "%ParamWebui%"=="1" set RS_QMAKE_CONFIG=%RS_QMAKE_CONFIG% rs_webui if "%ParamPlugins%"=="1" set RS_QMAKE_CONFIG=%RS_QMAKE_CONFIG% retroshare_plugins if "%ParamUseNativeDialogs%"=="1" set RS_QMAKE_CONFIG=%RS_QMAKE_CONFIG% rs_use_native_dialogs if "%ParamService%" NEQ "1" set RS_QMAKE_CONFIG=%RS_QMAKE_CONFIG% no_retroshare_service -if "%ParamFriendServer%" NEQ "1" set RS_QMAKE_CONFIG=%RS_QMAKE_CONFIG% no_rs_friendserver +if "%ParamFriendServer%" NEQ "1" set RS_QMAKE_CONFIG=%RS_QMAKE_CONFIG% no_retroshare_friendserver if "%ParamEmbeddedFriendServer%"=="1" set RS_QMAKE_CONFIG=%RS_QMAKE_CONFIG% rs_efs qmake "%SourcePath%\RetroShare.pro" -r -spec win32-g++ "CONFIG+=%RS_QMAKE_CONFIG%" "EXTERNAL_LIB_DIR=%BuildLibsPath%\libs" 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/build_scripts/git_tag_cleaner.sh b/build_scripts/git_tag_cleaner.sh new file mode 100755 index 000000000..cf7a3ef0c --- /dev/null +++ b/build_scripts/git_tag_cleaner.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +function git_del_tag() +{ + mTag=$1 + + for mRemote in $(git remote); do + echo "Attempting tag $mTag removal from remote $mRemote" + GIT_TERMINAL_PROMPT=0 git push $mRemote :$mTag || true + done + git tag --delete $mTag +} + +for mModule in . build_scripts/OBS/ libbitdht/ libretroshare/ openpgpsdk/ retroshare-webui/ ; do + pushd $mModule + git_del_tag v0.6.7a + git tag --list | grep untagged | while read mTag; do git_del_tag $mTag ; done + popd +done + diff --git a/libbitdht b/libbitdht index 659423769..2ddc86fb5 160000 --- a/libbitdht +++ b/libbitdht @@ -1 +1 @@ -Subproject commit 659423769541169457c41f71c8a038e2d64ba079 +Subproject commit 2ddc86fb575a61170f4c06a00152e3e7dc74c8f4 diff --git a/libretroshare b/libretroshare index 8c02b54e4..78739f1eb 160000 --- a/libretroshare +++ b/libretroshare @@ -1 +1 @@ -Subproject commit 8c02b54e4d16e38b28e77263a0b1570c50df4c99 +Subproject commit 78739f1eb504503b12f107109356624da49e75ef diff --git a/plugins/FeedReader/services/p3FeedReaderThread.cc b/plugins/FeedReader/services/p3FeedReaderThread.cc index 01e449323..845b5c82b 100644 --- a/plugins/FeedReader/services/p3FeedReaderThread.cc +++ b/plugins/FeedReader/services/p3FeedReaderThread.cc @@ -1151,10 +1151,10 @@ RsFeedReaderErrorState p3FeedReaderThread::processMsg(const RsFeedReaderFeed &fe if (isRunning()) { /* process description */ - bool processPostedFirstImage = (feed.flag & RS_FEED_FLAG_POSTED_FIRST_IMAGE) ? TRUE : FALSE; + bool processPostedFirstImage = (feed.flag & RS_FEED_FLAG_POSTED_FIRST_IMAGE) ? true : false; if (!msg->attachmentBinary.empty()) { /* use attachment as image */ - processPostedFirstImage = FALSE; + processPostedFirstImage = false; } //long todo; // encoding 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/Identity/IdDialog.ui b/retroshare-gui/src/gui/Identity/IdDialog.ui index ff3775aee..7687c321d 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.ui +++ b/retroshare-gui/src/gui/Identity/IdDialog.ui @@ -301,8 +301,8 @@ 0 0 - 456 - 731 + 466 + 738 @@ -573,17 +573,68 @@ border-image: url(:/images/closepressed.png) Identity info - - + + - Owner node ID : + Friend votes: - - + + + + Qt::Horizontal + + + + + + + true + + + true + + + + + + + true + + + true + + + + + + + Last used: + + + + + - <html><head/><body><p>Overall reputation score, accounting for yours and your friends'.</p><p>Negative is bad, positive is good. Zero is neutral. If the score is too low,</p><p>the identity is flagged as bad, and will be filtered out in forums, chat lobbies,</p><p>channels, etc.</p></body></html> + Auto-Ban all identities signed by the same node + + + Auto-Ban profile + + + + + + + true + + + + + + + true true @@ -600,61 +651,253 @@ border-image: url(:/images/closepressed.png) - + + + + <html><head/><body><p>Overall reputation score, accounting for yours and your friends'.</p><p>Negative is bad, positive is good. Zero is neutral. If the score is too low,</p><p>the identity is flagged as bad, and will be filtered out in forums, chat lobbies,</p><p>channels, etc.</p></body></html> + + + true + + + + + + + Your opinion: + + + + + + + + 75 + true + + + + Overall: + + + + + + + Created on : + + + + + + + Identity name : + + + + + + + Identity ID : + + + + + + + <html><head/><body><p>Average opinion of neighbor nodes about this identity. Negative is bad,</p><p>positive is good. Zero is neutral.</p></body></html> + + + true + + + + + + + true + + + + + + + Type: + + + + + + + true + + + + + + + Qt::Vertical + + + + 20 + 1 + + + + + + + + Owner node ID : + + + + + + + Owner node name : + + + + + + + Ban-option: + + + + + + + <html><head/><body><p><span style=" font-family:'Sans'; font-size:9pt;">Your own opinion about an identity rules the visibility of that identity for yourself and your friend nodes. Your own opinion is shared among friends and used to compute a reputation score: If your opinion about an identity is neutral, the reputation score is the difference between friend's positive and negative opinions. If not, your own opinion gives the score.</span></p><p><span style=" font-family:'Sans'; font-size:9pt;">The overall score is used in chat lobbies, forums and channels to decide on the actions to take for each specific identity. When the overall score is lower than -1, the identity is banned, which prevents all messages and forums/channels authored by this identity to be forwarded, both ways. Some forums also have special anti-spam flags that require a non negative reputation level, making them more sensitive to bad opinions. Banned identities gradually lose their activity and eventually disappear (after 5 days).</span></p><p><span style=" font-family:'Sans'; font-size:9pt;">You can change the thresholds and the time of inactivity to delete identities in preferences -&gt; people. </span></p></body></html> + + + + 22 + 22 + + + + + Negative + + + + :/icons/png/thumbs-down.png:/icons/png/thumbs-down.png + + + + + Neutral + + + + :/icons/png/thumbs-neutral.png:/icons/png/thumbs-neutral.png + + + + + Positive + + + + :/icons/png/thumbs-up.png:/icons/png/thumbs-up.png + + + + + 0 - - - - 0 - 0 - - - - - 128 - 128 - - - - - 128 - 128 - - - - QFrame::Box - - - QFrame::Sunken - - - Your Avatar - - - true - - - Qt::AlignCenter - - - - - - - Send Invite - - - - - - - Edit Identity - - + + + + + + 0 + 0 + + + + + 128 + 128 + + + + + 128 + 128 + + + + QFrame::Box + + + QFrame::Sunken + + + Your Avatar + + + true + + + Qt::AlignCenter + + + + + + + Edit Identity + + + + + + + Send Invite + + + + + + + Qt::Horizontal + + + QSizePolicy::Minimum + + + + 6 + 128 + + + + + + + + Qt::Horizontal + + + QSizePolicy::Minimum + + + + 6 + 128 + + + + + @@ -756,200 +999,6 @@ border-image: url(:/images/closepressed.png) - - - - true - - - - - - - Type: - - - - - - - - 75 - true - - - - Overall: - - - - - - - Last used: - - - - - - - Identity ID : - - - - - - - Created on : - - - - - - - Owner node name : - - - - - - - Ban-option: - - - - - - - Your opinion: - - - - - - - <html><head/><body><p>Average opinion of neighbor nodes about this identity. Negative is bad,</p><p>positive is good. Zero is neutral.</p></body></html> - - - true - - - - - - - true - - - - - - - <html><head/><body><p><span style=" font-family:'Sans'; font-size:9pt;">Your own opinion about an identity rules the visibility of that identity for yourself and your friend nodes. Your own opinion is shared among friends and used to compute a reputation score: If your opinion about an identity is neutral, the reputation score is the difference between friend's positive and negative opinions. If not, your own opinion gives the score.</span></p><p><span style=" font-family:'Sans'; font-size:9pt;">The overall score is used in chat lobbies, forums and channels to decide on the actions to take for each specific identity. When the overall score is lower than -1, the identity is banned, which prevents all messages and forums/channels authored by this identity to be forwarded, both ways. Some forums also have special anti-spam flags that require a non negative reputation level, making them more sensitive to bad opinions. Banned identities gradually lose their activity and eventually disappear (after 5 days).</span></p><p><span style=" font-family:'Sans'; font-size:9pt;">You can change the thresholds and the time of inactivity to delete identities in preferences -&gt; people. </span></p></body></html> - - - - 22 - 22 - - - - - Negative - - - - :/icons/png/thumbs-down.png:/icons/png/thumbs-down.png - - - - - Neutral - - - - :/icons/png/thumbs-neutral.png:/icons/png/thumbs-neutral.png - - - - - Positive - - - - :/icons/png/thumbs-up.png:/icons/png/thumbs-up.png - - - - - - - - Identity name : - - - - - - - Auto-Ban all identities signed by the same node - - - Auto-Ban profile - - - - - - - true - - - true - - - - - - - true - - - - - - - Friend votes: - - - - - - - true - - - true - - - - - - - Qt::Horizontal - - - - - - - true - - - true - - - diff --git a/retroshare-gui/src/gui/NetworkDialog.cpp b/retroshare-gui/src/gui/NetworkDialog.cpp index 216117f67..7c2b3fd14 100644 --- a/retroshare-gui/src/gui/NetworkDialog.cpp +++ b/retroshare-gui/src/gui/NetworkDialog.cpp @@ -83,7 +83,7 @@ NetworkDialog::NetworkDialog(QWidget */*parent*/) ui.connectTreeWidget->setUpdatesEnabled(true); ui.connectTreeWidget->setSortingEnabled(true); ui.connectTreeWidget->setSelectionBehavior(QAbstractItemView::SelectRows); - ui.connectTreeWidget->setSelectionMode(QAbstractItemView::SingleSelection); + ui.connectTreeWidget->setSelectionMode(QAbstractItemView::ExtendedSelection); connect(ui.connectTreeWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( connectTreeWidgetCostumPopupMenu( QPoint ) ) ); connect(ui.connectTreeWidget, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(peerdetails())); @@ -117,24 +117,12 @@ void NetworkDialog::connectTreeWidgetCostumPopupMenu( QPoint /*point*/ ) { return; } - QMenu *contextMnu = new QMenu; - RsPgpId peer_id(ui.connectTreeWidget->model()->data(ui.connectTreeWidget->model()->index(l.begin()->row(), pgpid_item_model::PGP_ITEM_MODEL_COLUMN_PEERID)).toString().toStdString()) ; - - // That's what context menus are made for - RsPeerDetails detail; - if(!rsPeers->getGPGDetails(peer_id, detail)) // that is not suppose to fail. - return ; - - if(peer_id == rsPeers->getGPGOwnId()) - contextMnu->addAction(QIcon(), tr("Export/create a new node"), this, SLOT(on_actionExportKey_activated())); - contextMnu->addAction(QIcon(IMAGE_PEERDETAILS), tr("Profile details..."), this, SLOT(peerdetails())); contextMnu->addSeparator() ; contextMnu->addAction(QIcon(), tr("Remove unused keys..."), this, SLOT(removeUnusedKeys())); contextMnu->addAction(QIcon(), tr("Remove this key"), this, SLOT(removeSelectedKeys())); - contextMnu->exec(QCursor::pos()); } @@ -177,11 +165,34 @@ void NetworkDialog::removeSelectedKeys() QModelIndexList l = ui.connectTreeWidget->selectionModel()->selection().indexes(); if(l.empty()) return; - std::set selected; - selected.insert(RsPgpId(ui.connectTreeWidget->model()->data(ui.connectTreeWidget->model()->index(l.begin()->row(), pgpid_item_model::PGP_ITEM_MODEL_COLUMN_PEERID)).toString().toStdString())); - removeKeys(selected); + std::set friends; + for (int i = 0; i < l.size(); i++) + { + RsPgpId peer_id = RsPgpId(ui.connectTreeWidget->model()->data(ui.connectTreeWidget->model()->index(l[i].row(), pgpid_item_model::PGP_ITEM_MODEL_COLUMN_PEERID)).toString().toStdString()); + RsPeerDetails details ; + if(rsPeers->getGPGDetails(peer_id,details)) + { + if(details.accept_connection) + friends.insert(peer_id); + else + selected.insert(peer_id); + } + } + if(!friends.empty()) + { + if ((QMessageBox::question(this, "RetroShare", tr("You have selected %1 accepted peers among others,\n Are you sure you want to un-friend them?").arg(friends.size()), QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes)) == QMessageBox::Yes) + { + for(std::set::const_iterator it(friends.begin());it!=friends.end();++it) + rsPeers->removeFriend(*it); + selected.insert(friends.begin(),friends.end()); + } + } + if(!selected.empty()) + removeKeys(selected); + + updateDisplay(); } void NetworkDialog::removeKeys(std::set selected) diff --git a/retroshare-gui/src/gui/NewsFeed.cpp b/retroshare-gui/src/gui/NewsFeed.cpp index c73f834fb..dc0834e71 100644 --- a/retroshare-gui/src/gui/NewsFeed.cpp +++ b/retroshare-gui/src/gui/NewsFeed.cpp @@ -299,7 +299,7 @@ void NewsFeed::handleChannelEvent(std::shared_ptr event) addFeedItem(new GxsChannelPostItem(this, NEWSFEED_CHANNELNEWLIST, pe->mChannelGroupId, pe->mChannelMsgId, false, true)); break; case RsChannelEventCode::NEW_COMMENT: - addFeedItem(new ChannelsCommentsItem(this, NEWSFEED_CHANNELNEWLIST, pe->mChannelGroupId, pe->mChannelMsgId, false, true)); + addFeedItem(new ChannelsCommentsItem(this, NEWSFEED_CHANNELNEWLIST, pe->mChannelGroupId, pe->mChannelMsgId,pe->mChannelThreadId, false, true)); break; case RsChannelEventCode::RECEIVED_PUBLISH_KEY: addFeedItem(new GxsChannelGroupItem(this, NEWSFEED_CHANNELPUBKEYLIST, pe->mChannelGroupId, false, true)); diff --git a/retroshare-gui/src/gui/TheWire/PulseAddDialog.cpp b/retroshare-gui/src/gui/TheWire/PulseAddDialog.cpp index 4dd233b26..9b1000f96 100644 --- a/retroshare-gui/src/gui/TheWire/PulseAddDialog.cpp +++ b/retroshare-gui/src/gui/TheWire/PulseAddDialog.cpp @@ -216,7 +216,7 @@ void PulseAddDialog::setReplyTo(const RsWirePulse &pulse, RsWirePulseSPtr pPulse mReplyToPulse = pulse; mReplyType = replyType; ui.frame_reply->setVisible(true); - ui.pushButton_picture->show(); + ui.pushButton_picture->hide(); ui.topheadshot->hide(); { @@ -245,10 +245,12 @@ void PulseAddDialog::setReplyTo(const RsWirePulse &pulse, RsWirePulseSPtr pPulse if (mReplyType & WIRE_PULSE_TYPE_REPUBLISH) { ui.postButton->setText(tr("Republish Pulse")); ui.pushButton_picture->hide(); + ui.pushButton_Browse->hide(); } else if (mReplyType & WIRE_PULSE_TYPE_LIKE) { ui.postButton->setText(tr("Like Pulse")); ui.pushButton_picture->hide(); + ui.pushButton_Browse->hide(); } } diff --git a/retroshare-gui/src/gui/TheWire/PulseAddDialog.ui b/retroshare-gui/src/gui/TheWire/PulseAddDialog.ui index c09119a40..bdfda3cc5 100644 --- a/retroshare-gui/src/gui/TheWire/PulseAddDialog.ui +++ b/retroshare-gui/src/gui/TheWire/PulseAddDialog.ui @@ -140,7 +140,7 @@ - 20 + 9 0 diff --git a/retroshare-gui/src/gui/TheWire/PulseReplySeperator.ui b/retroshare-gui/src/gui/TheWire/PulseReplySeperator.ui index 4a605a219..6564fe5e3 100644 --- a/retroshare-gui/src/gui/TheWire/PulseReplySeperator.ui +++ b/retroshare-gui/src/gui/TheWire/PulseReplySeperator.ui @@ -40,10 +40,7 @@ - QFrame#frame{border: 2px solid #CCCCCC; -background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, - stop: 0 #EEEEEE, stop: 1 #CCCCCC); -border-radius: 10px} + QFrame::StyledPanel diff --git a/retroshare-gui/src/gui/TheWire/WireDialog.cpp b/retroshare-gui/src/gui/TheWire/WireDialog.cpp index 38ea1b398..6738be68a 100644 --- a/retroshare-gui/src/gui/TheWire/WireDialog.cpp +++ b/retroshare-gui/src/gui/TheWire/WireDialog.cpp @@ -154,9 +154,16 @@ void WireDialog::processSettings(bool load) // state of splitter ui.splitter->restoreState(Settings->value("SplitterWire").toByteArray()); + + // state of filter combobox + int index = Settings->value("ShowGroup", 0).toInt(); + ui.comboBox_groupSet->setCurrentIndex(index); } else { // save settings + // state of filter combobox + Settings->setValue("ShowGroup", ui.comboBox_groupSet->currentIndex()); + // state of splitter Settings->setValue("SplitterWire", ui.splitter->saveState()); } @@ -1064,4 +1071,3 @@ void WireDialog::postGroupsPulses(std::list pulses) } } - diff --git a/retroshare-gui/src/gui/common/FriendListModel.cpp b/retroshare-gui/src/gui/common/FriendListModel.cpp index f8740466d..622ae3930 100644 --- a/retroshare-gui/src/gui/common/FriendListModel.cpp +++ b/retroshare-gui/src/gui/common/FriendListModel.cpp @@ -1145,8 +1145,6 @@ void RsFriendListModel::updateInternalData() mLocations.clear(); mTopLevel.clear(); - endResetModel(); - auto TL = mTopLevel ; // This allows to fill TL without touching mTopLevel outside of [begin/end]InsertRows(). // create a map of profiles and groups @@ -1282,7 +1280,8 @@ void RsFriendListModel::updateInternalData() endInsertRows(); } - postMods(); + endResetModel(); + postMods(); mLastInternalDataUpdate = time(NULL); } 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/ChannelsCommentsItem.cpp b/retroshare-gui/src/gui/feeds/ChannelsCommentsItem.cpp index ecbba96af..5b0e0b264 100644 --- a/retroshare-gui/src/gui/feeds/ChannelsCommentsItem.cpp +++ b/retroshare-gui/src/gui/feeds/ChannelsCommentsItem.cpp @@ -49,46 +49,41 @@ * #define DEBUG_ITEM 1 ****/ -ChannelsCommentsItem::ChannelsCommentsItem(FeedHolder *feedHolder, uint32_t feedId, const RsGroupMetaData& group_meta, const RsGxsMessageId &messageId, bool isHome, bool autoUpdate,const std::set& older_versions) : - GxsFeedItem(feedHolder, feedId, group_meta.mGroupId, messageId, isHome, rsGxsChannels, autoUpdate), - mGroupMeta(group_meta) +// ChannelsCommentsItem::ChannelsCommentsItem(FeedHolder *feedHolder, uint32_t feedId, const RsGroupMetaData& group_meta, const RsGxsMessageId &messageId, bool isHome, bool autoUpdate,const std::set& older_versions) : +// GxsFeedItem(feedHolder, feedId, group_meta.mGroupId, messageId, isHome, rsGxsChannels, autoUpdate), +// mGroupMeta(group_meta) +// { +// mLoadingGroup = false; +// mLoadingMessage = false; +// mLoadingComment = false; +// +// mPost.mMeta.mMsgId = messageId; // useful for uniqueIdentifer() before the post is loaded +// mPost.mMeta.mGroupId = mGroupMeta.mGroupId; +// +// QVector v; +// //bool self = false; +// +// for(std::set::const_iterator it(older_versions.begin());it!=older_versions.end();++it) +// v.push_back(*it) ; +// +// if(older_versions.find(messageId) == older_versions.end()) +// v.push_back(messageId); +// +// setMessageVersions(v) ; +// setup(); +// +// // no call to loadGroup() here because we have it already. +// } + +ChannelsCommentsItem::ChannelsCommentsItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId& groupId, const RsGxsMessageId &commentId, const RsGxsMessageId &threadId, bool isHome, bool autoUpdate) : + GxsFeedItem(feedHolder, feedId, groupId, commentId, isHome, rsGxsChannels, autoUpdate), // this one should be in GxsFeedItem + mThreadId(threadId) { - mPost.mMeta.mMsgId = messageId; // useful for uniqueIdentifer() before the post is loaded - mPost.mMeta.mGroupId = mGroupMeta.mGroupId; + mLoading= false; QVector v; - //bool self = false; - for(std::set::const_iterator it(older_versions.begin());it!=older_versions.end();++it) - v.push_back(*it) ; - - if(older_versions.find(messageId) == older_versions.end()) - v.push_back(messageId); - - setMessageVersions(v) ; setup(); - - // no call to loadGroup() here because we have it already. -} - -ChannelsCommentsItem::ChannelsCommentsItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId& groupId, const RsGxsMessageId &messageId, bool isHome, bool autoUpdate,const std::set& older_versions) : - GxsFeedItem(feedHolder, feedId, groupId, messageId, isHome, rsGxsChannels, autoUpdate) // this one should be in GxsFeedItem -{ - mPost.mMeta.mMsgId = messageId; // useful for uniqueIdentifer() before the post is loaded - - QVector v; - //bool self = false; - - for(std::set::const_iterator it(older_versions.begin());it!=older_versions.end();++it) - v.push_back(*it) ; - - if(older_versions.find(messageId) == older_versions.end()) - v.push_back(messageId); - - setMessageVersions(v) ; - setup(); - - loadGroup(); } void ChannelsCommentsItem::paintEvent(QPaintEvent *e) @@ -99,21 +94,22 @@ void ChannelsCommentsItem::paintEvent(QPaintEvent *e) if(!mLoaded) { mLoaded = true ; - - std::set older_versions; // not so nice. We need to use std::set everywhere - for(auto& m:messageVersions()) - older_versions.insert(m); - - fill(); - requestMessage(); - requestComment(); - } + load(); + } GxsFeedItem::paintEvent(e) ; } ChannelsCommentsItem::~ChannelsCommentsItem() { + auto timeout = std::chrono::steady_clock::now() + std::chrono::milliseconds(300); + + while( mLoading && std::chrono::steady_clock::now() < timeout ) + { + RsDbg() << __PRETTY_FUNCTION__ << " is Waiting for data to load " << std::endl; + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + } + delete(ui); } @@ -182,21 +178,19 @@ void ChannelsCommentsItem::setup() ui->expandFrame->hide(); } -bool ChannelsCommentsItem::setPost(const RsGxsChannelPost &post, bool doFill) +bool ChannelsCommentsItem::setPost(const RsGxsChannelPost& post, bool doFill) { - if (groupId() != post.mMeta.mGroupId || messageId() != post.mMeta.mMsgId) { - std::cerr << "ChannelsCommentsItem::setPost() - Wrong id, cannot set post"; - std::cerr << std::endl; - return false; - } - mPost = post; - if (doFill) { + if (doFill) fill(); - } - return true; + return true; +} +bool ChannelsCommentsItem::setMissingPost() +{ + fill(true); + return true; } QString ChannelsCommentsItem::getTitleLabel() @@ -230,168 +224,148 @@ void ChannelsCommentsItem::loadComments() void ChannelsCommentsItem::loadGroup() { -#ifdef DEBUG_ITEM - std::cerr << "GxsChannelGroupItem::loadGroup()"; - std::cerr << std::endl; -#endif - - RsThread::async([this]() - { - // 1 - get group data - - std::vector groups; - const std::list groupIds = { groupId() }; - - if(!rsGxsChannels->getChannelsInfo(groupIds,groups)) // would be better to call channel Summaries for a single group - { - RsErr() << "GxsGxsChannelGroupItem::loadGroup() ERROR getting data" << std::endl; - return; - } - - if (groups.size() != 1) - { - std::cerr << "GxsGxsChannelGroupItem::loadGroup() Wrong number of Items"; - std::cerr << std::endl; - return; - } - RsGxsChannelGroup group(groups[0]); - - RsQThreadUtils::postToObject( [group,this]() - { - /* Here it goes any code you want to be executed on the Qt Gui - * thread, for example to update the data model with new information - * after a blocking call to RetroShare API complete */ - - mGroupMeta = group.mMeta; - - }, this ); - }); +//#ifdef DEBUG_ITEM +// std::cerr << "GxsChannelGroupItem::loadGroup()"; +// std::cerr << std::endl; +//#endif +// if(mLoading) +// return; +// +// mLoading= true; +// +// std::cerr << "Loading group" << std::endl; +// RsThread::async([this]() +// { +// // 1 - get group data +// +// std::vector groups; +// const std::list groupIds = { groupId() }; +// +// if(!rsGxsChannels->getChannelsInfo(groupIds,groups)) // would be better to call channel Summaries for a single group +// { +// RsErr() << "GxsGxsChannelGroupItem::loadGroup() ERROR getting data" << std::endl; +// return; +// } +// +// if (groups.size() != 1) +// { +// std::cerr << "GxsGxsChannelGroupItem::loadGroup() Wrong number of Items"; +// std::cerr << std::endl; +// return; +// } +// RsGxsChannelGroup group(groups[0]); +// +// RsQThreadUtils::postToObject( [group,this]() +// { +// /* Here it goes any code you want to be executed on the Qt Gui +// * thread, for example to update the data model with new information +// * after a blocking call to RetroShare API complete */ +// +// mGroupMeta = group.mMeta; +// mLoading= false; +// +// std::cerr << "End loading group" << std::endl; +// }, this ); +// }); } -void ChannelsCommentsItem::loadMessage() +void ChannelsCommentsItem::load() { + // This function loads everything that's needed: + // - the comment text + // - the comment parent message + #ifdef DEBUG_ITEM std::cerr << "ChannelsCommentsItem::loadMessage()"; std::cerr << std::endl; #endif - RsThread::async([this]() + if(mLoading) + return; + + mLoading= true; + + RsThread::async([this]() { - // 1 - get group data + // 1 - get group meta data + + std::vector groups; + const std::list groupIds = { groupId() }; + + if(!rsGxsChannels->getChannelsInfo(groupIds,groups)) // would be better to call channel Summaries for a single group + { + RsErr() << "GxsGxsChannelGroupItem::loadGroup() ERROR getting data" << std::endl; + return; + } + + if (groups.size() != 1) + { + std::cerr << "GxsGxsChannelGroupItem::loadGroup() Wrong number of Items" << std::endl; + return; + } + RsGxsChannelGroup group(groups[0]); + + // 2 - get message and comment data std::vector posts; std::vector comments; std::vector votes; - if(! rsGxsChannels->getChannelContent( groupId(), std::set( { messageId() } ),posts,comments,votes)) + if(! rsGxsChannels->getChannelContent( groupId(), std::set( { messageId(),mThreadId } ),posts,comments,votes)) { RsErr() << "GxsGxsChannelGroupItem::loadGroup() ERROR getting data" << std::endl; return; } - if (posts.size() == 1) - { -#ifdef DEBUG_ITEM - std::cerr << (void*)this << ": Obtained post, with msgId = " << posts[0].mMeta.mMsgId << std::endl; -#endif - RsGxsChannelPost post(posts[0]); // no reference to temporary here, because we pass this to a thread + // now that everything is in place, update the UI - RsQThreadUtils::postToObject( [post,this]() { setPost(post); }, this ); - } - else if(comments.size() == 1) - { - RsGxsComment cmt(comments[0]); -#ifdef DEBUG_ITEM - std::cerr << (void*)this << ": Obtained comment, setting messageId to threadID = " << cmt.mMeta.mThreadId << std::endl; -#endif + RsQThreadUtils::postToObject( [group,posts,comments,this]() + { + /* Here it goes any code you want to be executed on the Qt Gui + * thread, for example to update the data model with new information + * after a blocking call to RetroShare API complete */ - RsQThreadUtils::postToObject( [cmt,this]() - { - uint32_t autorized_lines = (int)floor( (ui->avatarLabel->height() - ui->button_HL->sizeHint().height()) - / QFontMetricsF(ui->subjectLabel->font()).height()); + mGroupMeta = group.mMeta; - ui->commLabel->setText(RsHtml().formatText(NULL, RsStringUtil::CopyLines(QString::fromUtf8(cmt.mComment.c_str()), autorized_lines), RSHTML_FORMATTEXT_EMBED_LINKS)); + if(comments.size()==1) + { + RsGxsComment cmt(comments[0]); - ui->nameLabel->setId(cmt.mMeta.mAuthorId); - ui->datetimeLabel->setText(DateTime::formatLongDateTime(cmt.mMeta.mPublishTs)); + uint32_t autorized_lines = (int)floor( (ui->avatarLabel->height() - ui->button_HL->sizeHint().height()) + / QFontMetricsF(ui->subjectLabel->font()).height()); - RsIdentityDetails idDetails ; - rsIdentity->getIdDetails(cmt.mMeta.mAuthorId,idDetails); - QPixmap pixmap ; + ui->commLabel->setText(RsHtml().formatText(NULL, RsStringUtil::CopyLines(QString::fromUtf8(cmt.mComment.c_str()), autorized_lines), RSHTML_FORMATTEXT_EMBED_LINKS)); + ui->nameLabel->setId(cmt.mMeta.mAuthorId); + ui->datetimeLabel->setText(DateTime::formatLongDateTime(cmt.mMeta.mPublishTs)); - if(idDetails.mAvatar.mSize == 0 || !GxsIdDetails::loadPixmapFromData(idDetails.mAvatar.mData, idDetails.mAvatar.mSize, pixmap,GxsIdDetails::SMALL)) - pixmap = GxsIdDetails::makeDefaultIcon(cmt.mMeta.mAuthorId,GxsIdDetails::LARGE); - ui->avatarLabel->setPixmap(pixmap); + RsIdentityDetails idDetails ; + rsIdentity->getIdDetails(cmt.mMeta.mAuthorId,idDetails); + QPixmap pixmap ; - //Change this item to be uploaded with thread element. - setMessageId(cmt.mMeta.mThreadId); - requestMessage(); + if(idDetails.mAvatar.mSize == 0 || !GxsIdDetails::loadPixmapFromData(idDetails.mAvatar.mData, idDetails.mAvatar.mSize, pixmap,GxsIdDetails::SMALL)) + pixmap = GxsIdDetails::makeDefaultIcon(cmt.mMeta.mAuthorId,GxsIdDetails::LARGE); + ui->avatarLabel->setPixmap(pixmap); - }, this ); + //Change this item to be uploaded with thread element. This is really bad practice. + } + else + { + mLoading=false; + removeItem(); + } - } - else - { -#ifdef DEBUG_ITEM - std::cerr << "ChannelsCommentsItem::loadMessage() Wrong number of Items. Remove It."; - std::cerr << std::endl; -#endif + if (posts.size() == 1) + setPost(posts[0]); + else + setMissingPost(); - RsQThreadUtils::postToObject( [this]() { removeItem(); }, this ); - } - }); - - emit sizeChanged(this); + emit sizeChanged(this); + mLoading=false; + + }, this ); + }); } -void ChannelsCommentsItem::loadComment() +void ChannelsCommentsItem::fill(bool missing_post) { -#ifdef DEBUG_ITEM - std::cerr << "ChannelsCommentsItem::loadComment()"; - std::cerr << std::endl; -#endif - - RsThread::async([this]() - { - // 1 - get group data - - std::set msgIds; - - for(auto MsgId: messageVersions()) - msgIds.insert(MsgId); - - std::vector posts; - std::vector comments; - - if(! rsGxsChannels->getChannelComments( groupId(),msgIds,comments)) - { - RsErr() << "GxsGxsChannelGroupItem::loadGroup() ERROR getting data" << std::endl; - return; - } - - int comNb = comments.size(); - - RsQThreadUtils::postToObject( [comNb]() - { - QString sComButText = tr("Comment"); - if (comNb == 1) - sComButText = sComButText.append("(1)"); - else if(comNb > 1) - sComButText = tr("Comments ").append("(%1)").arg(comNb); - - //ui->commentButton->setText(sComButText); - - }, this ); - }); -} - -void ChannelsCommentsItem::fill() -{ - /* fill in */ - -// if (isLoading()) { - // /* Wait for all requests */ - //return; -// } - #ifdef DEBUG_ITEM std::cerr << "ChannelsCommentsItem::fill()"; std::cerr << std::endl; @@ -399,9 +373,6 @@ void ChannelsCommentsItem::fill() mInFill = true; - //QString title; - //float f = QFontMetricsF(font()).height()/14.0 ; - if (!mIsHome) { if (mCloseOnRead && !IS_MSG_NEW(mPost.mMeta.mMsgStatus)) { @@ -412,19 +383,14 @@ void ChannelsCommentsItem::fill() //title += link.toHtml(); //ui->titleLabel->setText(title); - RetroShareLink msgLink = RetroShareLink::createGxsMessageLink(RetroShareLink::TYPE_CHANNEL, mPost.mMeta.mGroupId, mPost.mMeta.mMsgId, messageName()); - ui->subjectLabel->setText(msgLink.toHtml()); + RetroShareLink msgLink = RetroShareLink::createGxsMessageLink(RetroShareLink::TYPE_CHANNEL, mPost.mMeta.mGroupId, mPost.mMeta.mMsgId, messageName()); + + if(missing_post) + ui->subjectLabel->setText("[" + QObject::tr("Missing channel post")+"]"); + else + ui->subjectLabel->setText(msgLink.toHtml()); - if (IS_GROUP_SUBSCRIBED(mGroupMeta.mSubscribeFlags) || IS_GROUP_ADMIN(mGroupMeta.mSubscribeFlags)) - { - //ui->unsubscribeButton->setEnabled(true); - } - else - { - //ui->unsubscribeButton->setEnabled(false); - } ui->readButton->hide(); - //ui->titleLabel->hide(); if (IS_MSG_NEW(mPost.mMeta.mMsgStatus)) { mCloseOnRead = true; @@ -432,19 +398,10 @@ void ChannelsCommentsItem::fill() } else { - /* subject */ - //ui->titleLabel->setText(QString::fromUtf8(mPost.mMeta.mMsgName.c_str())); - - //uint32_t autorized_lines = (int)floor( (ui->avatarLabel->height() - ui->button_HL->sizeHint().height()) - // / QFontMetricsF(ui->subjectLabel->font()).height()); - - // fill first 4 lines of message. (csoler) Disabled the replacement of smileys and links, because the cost is too crazy - //ui->subjectLabel->setText(RsHtml().formatText(NULL, RsStringUtil::CopyLines(QString::fromUtf8(mPost.mMsg.c_str()), autorized_lines), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS)); - - ui->subjectLabel->setText(RsStringUtil::CopyLines(QString::fromUtf8(mPost.mMsg.c_str()), 2)) ; - - //QString score = QString::number(post.mTopScore); - // scoreLabel->setText(score); + if(missing_post) + ui->subjectLabel->setText("[" + QObject::tr("Missing channel post")+"]"); + else + ui->subjectLabel->setText(RsStringUtil::CopyLines(QString::fromUtf8(mPost.mMsg.c_str()), 2)) ; /* disable buttons: deletion facility not enabled with cache services yet */ ui->clearButton->setEnabled(false); @@ -467,50 +424,9 @@ void ChannelsCommentsItem::fill() mCloseOnRead = false; } - // differences between Feed or Top of Comment. - if (mFeedHolder) - { - //ui->commentButton->show(); - - // Not yet functional - /*if (mPost.mCommentCount) - { - QString commentText = QString::number(mPost.mCommentCount); - commentText += " "; - commentText += tr("Comments"); - ui->commentButton->setText(commentText); - } - else - { - ui->commentButton->setText(tr("Comment")); - }*/ - - } - else - { - //ui->commentButton->hide(); - } - - // disable voting buttons - if they have already voted. - /*if (post.mMeta.mMsgStatus & GXS_SERV::GXS_MSG_STATUS_VOTE_MASK) - { - voteUpButton->setEnabled(false); - voteDownButton->setEnabled(false); - }*/ - - if (wasExpanded() || ui->expandFrame->isVisible()) { - fillExpandFrame(); - } - mInFill = false; } -void ChannelsCommentsItem::fillExpandFrame() -{ - //ui->msgLabel->setText(RsHtml().formatText(NULL, QString::fromUtf8(mPost.mMsg.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS)); - -} - QString ChannelsCommentsItem::messageName() { return QString::fromUtf8(mPost.mMeta.mMsgName.c_str()); @@ -574,10 +490,6 @@ void ChannelsCommentsItem::doExpand(bool open) void ChannelsCommentsItem::expandFill(bool first) { GxsFeedItem::expandFill(first); - - if (first) { - fillExpandFrame(); - } } void ChannelsCommentsItem::toggle() diff --git a/retroshare-gui/src/gui/feeds/ChannelsCommentsItem.h b/retroshare-gui/src/gui/feeds/ChannelsCommentsItem.h index 53537d61e..c245cbca7 100644 --- a/retroshare-gui/src/gui/feeds/ChannelsCommentsItem.h +++ b/retroshare-gui/src/gui/feeds/ChannelsCommentsItem.h @@ -42,12 +42,17 @@ public: // It can be used for all apparences of channel posts. But in rder to merge comments from the previous versions of the post, the list of // previous posts should be supplied. It's optional. If not supplied only the comments of the new version will be displayed. - ChannelsCommentsItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId& groupId, const RsGxsMessageId &messageId, bool isHome, bool autoUpdate, const std::set& older_versions = std::set()); + ChannelsCommentsItem(FeedHolder *feedHolder, + uint32_t feedId, + const RsGxsGroupId& groupId, + const RsGxsMessageId& commentId, + const RsGxsMessageId& threadId, + bool isHome, + bool autoUpdate); // This one is used in channel thread widget. We don't want the group data to reload at every post, so we load it in the hosting // GxsChannelsPostsWidget and pass it to created items. - - ChannelsCommentsItem(FeedHolder *feedHolder, uint32_t feedId, const RsGroupMetaData& group, const RsGxsMessageId &messageId, bool isHome, bool autoUpdate, const std::set& older_versions = std::set()); + // ChannelsCommentsItem(FeedHolder *feedHolder, uint32_t feedId, const RsGroupMetaData& group, const RsGxsMessageId &messageId, bool isHome, bool autoUpdate, const std::set& older_versions = std::set()); virtual ~ChannelsCommentsItem(); @@ -55,6 +60,7 @@ public: bool setGroup(const RsGxsChannelGroup& group, bool doFill = true); bool setPost(const RsGxsChannelPost& post, bool doFill = true); + bool setMissingPost(); QString getTitleLabel(); QString getMsgLabel(); @@ -85,8 +91,8 @@ protected: /* GxsFeedItem */ virtual QString messageName(); - virtual void loadMessage(); - virtual void loadComment(); + virtual void loadMessage() override {} + virtual void loadComment() override {} private slots: /* default stuff */ @@ -104,17 +110,20 @@ signals: void vote(const RsGxsGrpMsgIdPair& msgId, bool up); private: - void setup(); - void fill(); - void fillExpandFrame(); + void load(); + void setup(); + void fill(bool missing_post=false); private: bool mInFill; bool mCloseOnRead; bool mLoaded; + bool mLoading; + RsGroupMetaData mGroupMeta; RsGxsChannelPost mPost; + RsGxsMessageId mThreadId; /** Qt Designer generated object */ Ui::ChannelsCommentsItem *ui; 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/GxsChannelPostItem.cpp b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp index 102dfb637..17036a15e 100644 --- a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp +++ b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp @@ -49,6 +49,10 @@ GxsChannelPostItem::GxsChannelPostItem(FeedHolder *feedHolder, uint32_t feedId, GxsFeedItem(feedHolder, feedId, group_meta.mGroupId, messageId, isHome, rsGxsChannels, autoUpdate), mGroupMeta(group_meta) { + mLoadingGroup = false; + mLoadingMessage = false; + mLoadingComment = false; + mPost.mMeta.mMsgId = messageId; // useful for uniqueIdentifer() before the post is loaded mPost.mMeta.mGroupId = mGroupMeta.mGroupId; @@ -136,6 +140,19 @@ void GxsChannelPostItem::paintEvent(QPaintEvent *e) GxsChannelPostItem::~GxsChannelPostItem() { + auto timeout = std::chrono::steady_clock::now() + std::chrono::milliseconds(300); + + while( (mLoadingGroup || mLoadingMessage || mLoadingComment) + && std::chrono::steady_clock::now() < timeout) + { + RsDbg() << __PRETTY_FUNCTION__ << " is Waiting for " + << (mLoadingGroup ? "Group " : "") + << (mLoadingMessage ? "Message " : "") + << (mLoadingComment ? "Comment " : "") + << "loading." << std::endl; + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + } + delete(ui); } @@ -277,6 +294,7 @@ void GxsChannelPostItem::loadGroup() std::cerr << "GxsChannelGroupItem::loadGroup()"; std::cerr << std::endl; #endif + mLoadingGroup = true; RsThread::async([this]() { @@ -306,6 +324,7 @@ void GxsChannelPostItem::loadGroup() * after a blocking call to RetroShare API complete */ mGroupMeta = group.mMeta; + mLoadingGroup = false; }, this ); }); @@ -316,6 +335,8 @@ void GxsChannelPostItem::loadMessage() std::cerr << "GxsChannelPostItem::loadMessage()"; std::cerr << std::endl; #endif + mLoadingMessage = true; + RsThread::async([this]() { // 1 - get group data @@ -337,7 +358,11 @@ void GxsChannelPostItem::loadMessage() #endif const RsGxsChannelPost& post(posts[0]); - RsQThreadUtils::postToObject( [post,this]() { setPost(post); }, this ); + RsQThreadUtils::postToObject( [post,this]() + { + setPost(post); + mLoadingMessage = false; + }, this ); } else if(comments.size() == 1) { @@ -356,7 +381,8 @@ void GxsChannelPostItem::loadMessage() setMessageId(cmt.mMeta.mThreadId); requestMessage(); - }, this ); + mLoadingMessage = false; + }, this ); } else @@ -366,7 +392,11 @@ void GxsChannelPostItem::loadMessage() std::cerr << std::endl; #endif - RsQThreadUtils::postToObject( [this]() { removeItem(); }, this ); + RsQThreadUtils::postToObject( [this]() + { + removeItem(); + mLoadingMessage = false; + }, this ); } }); } @@ -377,6 +407,7 @@ void GxsChannelPostItem::loadComment() std::cerr << "GxsChannelPostItem::loadComment()"; std::cerr << std::endl; #endif + mLoadingComment = true; RsThread::async([this]() { @@ -407,6 +438,7 @@ void GxsChannelPostItem::loadComment() sComButText = tr("Comments ").append("(%1)").arg(comNb); ui->commentButton->setText(sComButText); + mLoadingComment = false; }, this ); }); diff --git a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.h b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.h index 8370b885e..b3e7843c0 100644 --- a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.h +++ b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.h @@ -119,7 +119,12 @@ private: private: bool mInFill; bool mCloseOnRead; - bool mLoaded; + bool mLoaded; + + bool mLoadingMessage; + bool mLoadingGroup; + bool mLoadingComment; + RsGroupMetaData mGroupMeta; RsGxsChannelPost mPost; 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/feeds/GxsForumMsgItem.cpp b/retroshare-gui/src/gui/feeds/GxsForumMsgItem.cpp index 81b026d27..f4d091179 100644 --- a/retroshare-gui/src/gui/feeds/GxsForumMsgItem.cpp +++ b/retroshare-gui/src/gui/feeds/GxsForumMsgItem.cpp @@ -47,7 +47,13 @@ GxsForumMsgItem::GxsForumMsgItem(FeedHolder *feedHolder, uint32_t feedId, const { mMessage.mMeta.mMsgId = messageId; // useful for uniqueIdentifier() before the post is actually loaded mMessage.mMeta.mGroupId = groupId; - setup(); + + mLoadingGroup = false; + mLoadingMessage = false; + mLoadingSetAsRead = false; + mLoadingParentMessage = false; + + setup(); requestGroup(); requestMessage(); diff --git a/retroshare-gui/src/gui/gxs/GxsCommentDialog.cpp b/retroshare-gui/src/gui/gxs/GxsCommentDialog.cpp index 7b9e28131..1233b3100 100644 --- a/retroshare-gui/src/gui/gxs/GxsCommentDialog.cpp +++ b/retroshare-gui/src/gui/gxs/GxsCommentDialog.cpp @@ -29,6 +29,8 @@ #include #include +//#define DEBUG_COMMENT_DIALOG 1 + /** Constructor */ GxsCommentDialog::GxsCommentDialog(QWidget *parent, const RsGxsId &default_author, RsGxsCommentService *comment_service) : QWidget(parent), ui(new Ui::GxsCommentDialog) @@ -95,8 +97,11 @@ void GxsCommentDialog::commentClear() } void GxsCommentDialog::commentLoad(const RsGxsGroupId &grpId, const std::set& msg_versions,const RsGxsMessageId& most_recent_msgId,bool use_cache) { - std::cerr << "GxsCommentDialog::commentLoad(" << grpId << ", most recent msg version: " << most_recent_msgId << ")"; - std::cerr << std::endl; +#ifdef DEBUG_COMMENT_DIALOG + std::cerr << "GxsCommentDialog::commentLoad(" << grpId << ", most recent msg version: " << most_recent_msgId << ")" << std::endl; + for(const auto& mid:msg_versions) + std::cerr << " msg version: " << mid << std::endl; +#endif mGrpId = grpId; mMostRecentMsgId = most_recent_msgId; diff --git a/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.cpp b/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.cpp index 517543b9a..bd230fe9c 100644 --- a/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.cpp +++ b/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.cpp @@ -42,6 +42,8 @@ #include +//#define DEBUG_COMMENT_TREE_WIDGET + #define PCITEM_COLUMN_COMMENT 0 #define PCITEM_COLUMN_AUTHOR 1 #define PCITEM_COLUMN_DATE 2 @@ -73,6 +75,7 @@ std::map > GxsCommentTreeWidget::mComm QMutex GxsCommentTreeWidget::mCacheMutex; //#define USE_NEW_DELEGATE 1 +//#define DEBUG_GXSCOMMENT_TREEWIDGET 1 // This class allows to draw the item using an appropriate size @@ -508,6 +511,8 @@ void GxsCommentTreeWidget::service_requestComments(const RsGxsGroupId& group_id, /* request comments */ #ifdef DEBUG_GXSCOMMENT_TREEWIDGET std::cerr << "GxsCommentTreeWidget::service_requestComments for group " << group_id << std::endl; + for(const auto& mid:msgIds) + std::cerr << " including message " << mid << std::endl; #endif RsThread::async([this,group_id,msgIds]() @@ -765,8 +770,10 @@ void GxsCommentTreeWidget::insertComments(const std::vector& comme new_comments.push_back(comment.mMeta.mMsgId); /* convert to a QTreeWidgetItem */ +#ifdef DEBUG_COMMENT_TREE_WIDGET std::cerr << "GxsCommentTreeWidget::service_loadThread() Got Comment: " << comment.mMeta.mMsgId; std::cerr << std::endl; +#endif GxsIdRSTreeWidgetItem *item = new GxsIdRSTreeWidgetItem(NULL,GxsIdDetails::ICON_TYPE_AVATAR) ; QString text; diff --git a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp index 05ce9bda6..bc2f5d960 100644 --- a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp +++ b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp @@ -35,6 +35,7 @@ #include "util/rsdir.h" #include "util/qtthreadsutils.h" #include "util/RichTextEdit.h" +#include "util/imageutil.h" #include @@ -607,11 +608,13 @@ bool CreateGxsChannelMsg::setThumbNail(const std::string& path, int frame){ if(imageBuffer == NULL) return false; - QImage tNail(imageBuffer, width, height, QImage::Format_RGB32); + QImage tNail(imageBuffer, width, height, QImage::Format_RGBA32); QByteArray ba; QBuffer buffer(&ba); + bool has_transparency = ImageUtil::hasAlphaContent(tNail.toImage()); + buffer.open(QIODevice::WriteOnly); - tNail.save(&buffer, "JPG"); + tNail.save(&buffer, has_transparency?"PNG":"JPG"); QPixmap img; img.loadFromData(ba, "PNG"); img = img.scaled(thumbnail_label->width(), thumbnail_label->height(), Qt::KeepAspectRatio, Qt::SmoothTransformation); @@ -797,15 +800,19 @@ void CreateGxsChannelMsg::sendMessage(const std::string &subject, const std::str QByteArray ba; QBuffer buffer(&ba); - RsGxsImage image; + RsGxsImage image; + QPixmap pixmap; + pixmap = preview_W->getCroppedScaledPicture(); + QImage qimg = pixmap.toImage(); + bool has_transparency = ImageUtil::hasAlphaContent(qimg); if(!picture.isNull()) { // send chan image buffer.open(QIODevice::WriteOnly); - preview_W->getCroppedScaledPicture().save(&buffer, "JPG"); // writes image into ba in PNG format - image.copy((uint8_t *) ba.data(), ba.size()); + preview_W->getCroppedScaledPicture().save(&buffer, has_transparency?"PNG":"JPG"); // writes image into ba in PNG format + image.copy((uint8_t *) ba.data(), ba.size()); } std::string error_string; diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp index e9be3e6ed..a42587d85 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp @@ -176,6 +176,25 @@ int RsGxsChannelPostsModel::rowCount(const QModelIndex& parent) const return 0; } +int RsGxsChannelPostsModel::columnCount(int row) const +{ + if(mTreeMode == TREE_MODE_GRID) + { + if(row+1 == rowCount()) + { + int r = ((int)mFilteredPosts.size() % (int)mColumns); + + if(r > 0) + return r; + else + return columnCount(); + } + else + return columnCount(); + } + else + return 2; +} int RsGxsChannelPostsModel::columnCount(const QModelIndex &/*parent*/) const { if(mTreeMode == TREE_MODE_GRID) @@ -245,7 +264,7 @@ bool RsGxsChannelPostsModel::convertRefPointerToTabEntry(quintptr ref, uint32_t& QModelIndex RsGxsChannelPostsModel::index(int row, int column, const QModelIndex & parent) const { - if(row < 0 || column < 0 || column >= (int)mColumns) + if(row < 0 || column < 0 || row >= rowCount() || column >= columnCount(row)) return QModelIndex(); quintptr ref = getChildRef(parent.internalId(),(mTreeMode == TREE_MODE_GRID)?(column + row*mColumns):row); diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.h b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.h index 42dcbb9f7..c447f11a3 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.h +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.h @@ -105,6 +105,7 @@ public: QModelIndex root() const{ return createIndex(0,0,(void*)NULL) ;} QModelIndex getIndexOfMessage(const RsGxsMessageId& mid) const; + int columnCount(int row) const; // columns in the row of this particular index. std::vector > getPostVersions(const RsGxsMessageId& mid) const; diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp index a6ce946f5..2e292444e 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp @@ -504,6 +504,30 @@ GxsChannelPostsWidgetWithModel::GxsChannelPostsWidgetWithModel(const RsGxsGroupI }, mEventHandlerId, RsEventType::GXS_CHANNELS ); } +void GxsChannelPostsWidgetWithModel::keyPressEvent(QKeyEvent *e) +{ + QModelIndex index = ui->postsTree->selectionModel()->currentIndex(); + + if(index.isValid() && mChannelPostsModel->getMode() == RsGxsChannelPostsModel::TREE_MODE_GRID) + { + int n = mChannelPostsModel->columnCount(index.row())-1; + + if(e->key() == Qt::Key_Left && index.column()==0) + { + ui->postsTree->setCurrentIndex(index.sibling(index.row(),n)); + e->accept(); + return; + } + if(e->key() == Qt::Key_Right && index.column()==n) + { + ui->postsTree->setCurrentIndex(index.sibling(index.row(),0)); + e->accept(); + return; + } + } + + GxsMessageFrameWidget::keyPressEvent(e); +} void GxsChannelPostsWidgetWithModel::resizeEvent(QResizeEvent *e) { GxsMessageFrameWidget::resizeEvent(e); diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h index 9cfcaae21..8891b57dd 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h @@ -139,6 +139,7 @@ protected: /* GxsMessageFrameWidget */ virtual void setAllMessagesReadDo(bool read) override; virtual void resizeEvent(QResizeEvent *e) override; + virtual void keyPressEvent(QKeyEvent *e) override; private slots: void showPostDetails(); diff --git a/retroshare-gui/src/gui/msgs/MessageComposer.h b/retroshare-gui/src/gui/msgs/MessageComposer.h index 0df2dbd8e..040681095 100644 --- a/retroshare-gui/src/gui/msgs/MessageComposer.h +++ b/retroshare-gui/src/gui/msgs/MessageComposer.h @@ -255,7 +255,7 @@ private: QList tagLabels; // needed to send system flags with reply - unsigned msgFlags; + unsigned int msgFlags; RSTreeWidgetItemCompareRole *m_compareRole; QCompleter *m_completer; diff --git a/retroshare-gui/src/gui/msgs/MessageModel.cpp b/retroshare-gui/src/gui/msgs/MessageModel.cpp index 09508cad6..6116e42b4 100644 --- a/retroshare-gui/src/gui/msgs/MessageModel.cpp +++ b/retroshare-gui/src/gui/msgs/MessageModel.cpp @@ -690,6 +690,10 @@ void RsMessageModel::setCurrentBox(Rs::Msgs::BoxName bn) } } +Rs::Msgs::BoxName RsMessageModel::currentBox() const +{ + return mCurrentBox; +} void RsMessageModel::setQuickViewFilter(QuickViewFilter fn) { if(fn != mQuickViewFilter) diff --git a/retroshare-gui/src/gui/msgs/MessageModel.h b/retroshare-gui/src/gui/msgs/MessageModel.h index fb8c6daa5..d23b21f86 100644 --- a/retroshare-gui/src/gui/msgs/MessageModel.h +++ b/retroshare-gui/src/gui/msgs/MessageModel.h @@ -100,6 +100,7 @@ public: // This method will asynchroneously update the data void setCurrentBox(Rs::Msgs::BoxName bn) ; + Rs::Msgs::BoxName currentBox() const ; void setQuickViewFilter(QuickViewFilter fn) ; void setFilter(FilterType filter_type, const QStringList& strings) ; diff --git a/retroshare-gui/src/gui/msgs/MessageWidget.cpp b/retroshare-gui/src/gui/msgs/MessageWidget.cpp index cd06e9805..0d2e934f2 100644 --- a/retroshare-gui/src/gui/msgs/MessageWidget.cpp +++ b/retroshare-gui/src/gui/msgs/MessageWidget.cpp @@ -738,7 +738,8 @@ void MessageWidget::remove() return; } - bool deleteReal = false; +#ifdef TO_REMOVE + bool deleteReal = false; if (msgInfo.msgflags & RS_MSG_TRASH) { deleteReal = true; } else { @@ -763,8 +764,8 @@ void MessageWidget::remove() deleteLater(); } } - - emit messageRemoved(); +#endif + emit messageRemovalRequested(currMsgId); } void MessageWidget::print() diff --git a/retroshare-gui/src/gui/msgs/MessageWidget.h b/retroshare-gui/src/gui/msgs/MessageWidget.h index d6465e5cf..53b043720 100644 --- a/retroshare-gui/src/gui/msgs/MessageWidget.h +++ b/retroshare-gui/src/gui/msgs/MessageWidget.h @@ -61,6 +61,7 @@ public: signals: void messageRemoved(); + void messageRemovalRequested(std::string); private slots: void reply(); diff --git a/retroshare-gui/src/gui/msgs/MessagesDialog.cpp b/retroshare-gui/src/gui/msgs/MessagesDialog.cpp index 1fb55821f..be9eedf6b 100644 --- a/retroshare-gui/src/gui/msgs/MessagesDialog.cpp +++ b/retroshare-gui/src/gui/msgs/MessagesDialog.cpp @@ -95,6 +95,7 @@ #define ROW_SENTBOX 3 #define ROW_TRASHBOX 4 +// #define DEBUG_MESSAGES_DIALOG 1 class MessageSortFilterProxyModel: public QSortFilterProxyModel { @@ -144,7 +145,7 @@ MessagesDialog::MessagesDialog(QWidget *parent) msgWidget = new MessageWidget(true, this); ui.msgLayout->addWidget(msgWidget); - connect(msgWidget, SIGNAL(messageRemoved()), this, SLOT(messageRemoved())); + connect(msgWidget, SIGNAL(messageRemovalRequested(std::string)), this, SLOT(removemessage())); connectActions(); @@ -365,15 +366,18 @@ void MessagesDialog::preModelUpdate() if (m.isValid()) { mTmpSavedCurrentId = m.sibling(m.row(), RsMessageModel::COLUMN_THREAD_MSGID).data(RsMessageModel::MsgIdRole).toString(); } - +#ifdef DEBUG_MESSAGES_DIALOG std::cerr << "Pre-change: saving selection for " << mTmpSavedSelectedIds.size() << " indexes" << std::endl; +#endif } void MessagesDialog::postModelUpdate() { // restore selection +#ifdef DEBUG_MESSAGES_DIALOG std::cerr << "Post-change: restoring selection for " << mTmpSavedSelectedIds.size() << " indexes" << std::endl; +#endif QItemSelection sel; foreach(const QString& s,mTmpSavedSelectedIds) @@ -838,7 +842,7 @@ void MessagesDialog::openAsWindow() } msgWidget->activateWindow(); - connect(msgWidget, SIGNAL(messageRemoved()), this, SLOT(messageRemoved())); + connect(msgWidget, SIGNAL(messageRemovalRequested(std::string)), this, SLOT(removemessage())); /* window will destroy itself! */ } @@ -858,7 +862,7 @@ void MessagesDialog::openAsTab() ui.tabWidget->addTab(msgWidget,FilesDefs::getIconFromQtResourcePath(IMAGE_MAIL), msgWidget->subject(true)); ui.tabWidget->setCurrentWidget(msgWidget); - connect(msgWidget, SIGNAL(messageRemoved()), this, SLOT(messageRemoved())); + connect(msgWidget, SIGNAL(messageRemovalRequested(std::string)), this, SLOT(removemessage())); /* window will destroy itself! */ } @@ -921,9 +925,9 @@ void MessagesDialog::changeBox(int box_row) ui.messageTreeWidget->setPlaceholderText(placeholderText); ui.messageTreeWidget->setColumnHidden(RsMessageModel::COLUMN_THREAD_READ,box_row!=ROW_INBOX); - ui.messageTreeWidget->setColumnHidden(RsMessageModel::COLUMN_THREAD_STAR,box_row==ROW_OUTBOX); - ui.messageTreeWidget->setColumnHidden(RsMessageModel::COLUMN_THREAD_SPAM,box_row==ROW_OUTBOX); - ui.messageTreeWidget->setColumnHidden(RsMessageModel::COLUMN_THREAD_TAGS,box_row==ROW_OUTBOX); + ui.messageTreeWidget->setColumnHidden(RsMessageModel::COLUMN_THREAD_STAR,box_row!=ROW_INBOX); + ui.messageTreeWidget->setColumnHidden(RsMessageModel::COLUMN_THREAD_SPAM,box_row!=ROW_INBOX); + ui.messageTreeWidget->setColumnHidden(RsMessageModel::COLUMN_THREAD_TAGS,box_row!=ROW_INBOX); ui.messageTreeWidget->setColumnHidden(RsMessageModel::COLUMN_THREAD_MSGID,true); ui.messageTreeWidget->setColumnHidden(RsMessageModel::COLUMN_THREAD_CONTENT,true); } @@ -1292,7 +1296,7 @@ void MessagesDialog::updateMessageSummaryList() /* calculating the new messages */ std::list msgList; - rsMail->getMessageSummaries(Rs::Msgs::BoxName::BOX_ALL,msgList); + rsMail->getMessageSummaries(mMessageModel->currentBox(),msgList); QMap tagCount; diff --git a/retroshare-gui/src/gui/qss/stylesheet/Standard_Dark.qss b/retroshare-gui/src/gui/qss/stylesheet/Standard_Dark.qss index 7497440c5..ffea0a4d8 100644 --- a/retroshare-gui/src/gui/qss/stylesheet/Standard_Dark.qss +++ b/retroshare-gui/src/gui/qss/stylesheet/Standard_Dark.qss @@ -2436,7 +2436,7 @@ WireGroupItem QFrame#wire_frame QLabel{ background: transparent; } WireGroupItem QFrame#wire_frame:hover { - background-color: #2e8bab; + background-color: #346792; } PulseTopLevel QFrame#frame, @@ -2446,13 +2446,6 @@ PulseReply QFrame#frame { border-radius: 6px; } -PulseAddDialog QTextEdit#textEdit_Pulse { - border: 2px solid #c4cfd6; - border-radius: 6px; - background: white; - color: black; -} - PulseReply #line_replyLine, PulseMessage #line{ color: #c4cfd6; @@ -2462,6 +2455,16 @@ PulseReply QLabel#label_groupName{ color: #5b7083; } +PulseReplySeperator QFrame#frame { + background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #455364, stop: 0.5 #54687A,stop: 0.6 #44586A, stop:1 #455364); + border-radius: 10px; +} + +QLabel#label_masthead{ + border: 2px solid #CCCCCC; + border-radius: 4px; +} + /**** Color definitions ****/ ForumsDialog, GxsForumThreadWidget @@ -2552,10 +2555,3 @@ OpModeStatus[opMode="Minimal"] { [WrongValue="true"] { background-color: #702020; } - -/**** The Wire ****/ - -QLabel#label_masthead{ - border: 2px solid #CCCCCC; - border-radius: 4px; -} diff --git a/retroshare-gui/src/gui/qss/stylesheet/Standard_Light.qss b/retroshare-gui/src/gui/qss/stylesheet/Standard_Light.qss index 061ca0518..df6b9d51c 100644 --- a/retroshare-gui/src/gui/qss/stylesheet/Standard_Light.qss +++ b/retroshare-gui/src/gui/qss/stylesheet/Standard_Light.qss @@ -2687,6 +2687,12 @@ PulseReply QLabel#label_groupName{ color: #5b7083; } +PulseReplySeperator QFrame#frame { + border: 2px solid #CCCCCC; + background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #EEEEEE, stop: 1 #CCCCCC); + border-radius: 10px} +} + QLabel#label_masthead{ border: 2px solid #CCCCCC; border-radius: 4px; diff --git a/retroshare-gui/src/gui/settings/AppearancePage.cpp b/retroshare-gui/src/gui/settings/AppearancePage.cpp index 2fb86e5a2..8ad086ae9 100755 --- a/retroshare-gui/src/gui/settings/AppearancePage.cpp +++ b/retroshare-gui/src/gui/settings/AppearancePage.cpp @@ -74,8 +74,13 @@ AppearancePage::AppearancePage(QWidget * parent, Qt::WindowFlags flags) foreach (QString code, LanguageSupport::languageCodes()) { ui.cmboLanguage->addItem(FilesDefs::getIconFromQtResourcePath(":/images/flags/" + code + ".png"), LanguageSupport::languageName(code), code); } - foreach (QString style, QStyleFactory::keys()) { - ui.cmboStyle->addItem(style, style.toLower()); + + // Note: apparently, on some linux systems (e.g. Debian 11), the gtk2 style makes Qt libs crash when the environment variable is not set. + // So we first check that it's here before start. + + foreach (QString style, QStyleFactory::keys()) { + if(style.toLower() != "gtk2" || (getenv("QT_QPA_PLATFORMTHEME")!=nullptr && !strcmp(getenv("QT_QPA_PLATFORMTHEME"),"gtk2"))) + ui.cmboStyle->addItem(style, style.toLower()); } QMap styleSheets; @@ -266,9 +271,9 @@ void AppearancePage::load() index = ui.mainPageButtonType_CB->findData(Settings->getPageButtonLoc()); if (index != 0) { - ui.cmboTollButtonsStyle->hide(); - }else { - ui.cmboTollButtonsStyle->show(); + ui.cmboTollButtonsStyle->show(); + }else { + ui.cmboTollButtonsStyle->hide(); } whileBlocking(ui.mainPageButtonType_CB)->setCurrentIndex(!Settings->getPageButtonLoc()); diff --git a/retroshare-gui/src/gui/settings/JsonApiPage.cc b/retroshare-gui/src/gui/settings/JsonApiPage.cc index a824a5fa0..2b7f25d80 100644 --- a/retroshare-gui/src/gui/settings/JsonApiPage.cc +++ b/retroshare-gui/src/gui/settings/JsonApiPage.cc @@ -23,11 +23,14 @@ #include "rsharesettings.h" #include "jsonapi/jsonapi.h" #include "util/misc.h" +#include "util/qtthreadsutils.h" #include #include #include +#define IMAGE_LEDOFF ":/images/ledoff1.png" +#define IMAGE_LEDON ":/images/ledon1.png" JsonApiPage::JsonApiPage(QWidget */*parent*/, Qt::WindowFlags /*flags*/) { @@ -57,9 +60,41 @@ JsonApiPage::JsonApiPage(QWidget */*parent*/, Qt::WindowFlags /*flags*/) QRegExpValidator *ipValidator = new QRegExpValidator(ipRegex, this); ui.listenAddressLineEdit->setValidator(ipValidator); + ui.providersListView->setSelectionMode(QAbstractItemView::NoSelection); // prevents edition. + mEventHandlerId = 0; + + rsEvents->registerEventsHandler( [this](std::shared_ptr e) + { + 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 ); } +JsonApiPage::~JsonApiPage() +{ + rsEvents->unregisterEventsHandler(mEventHandlerId); +} +QString JsonApiPage::helpText() const +{ + return tr("

  Webinterface

\ +

Retroshare provides a JSON API allowing other softwares to communicate with its core using token-controlled HTTP requests to http://localhost:[port]. \ + Please refer to the Retroshare documentation for how to use this feature.

\ +

Unless you know what you're doing, you shouldn't need to change anything in this page. \ + The web interface for instance will automatically register its own token to the JSON API which will be visible \ + in the list of authenticated tokens after you enable it.

"); +} void JsonApiPage::enableJsonApi(bool checked) { ui.addTokenPushButton->setEnabled(checked); @@ -93,9 +128,9 @@ bool JsonApiPage::updateParams() void JsonApiPage::load() { - whileBlocking(ui.portSpinBox)->setValue(Settings->getJsonApiPort()); - whileBlocking(ui.listenAddressLineEdit)->setText(Settings->getJsonApiListenAddress()); - whileBlocking(ui.enableCheckBox)->setChecked(Settings->getJsonApiEnabled()); + whileBlocking(ui.portSpinBox)->setValue(rsJsonApi->listeningPort()); + whileBlocking(ui.listenAddressLineEdit)->setText(QString::fromStdString(rsJsonApi->getBindingAddress())); + whileBlocking(ui.enableCheckBox)->setChecked(rsJsonApi->isRunning()); QStringList newTk; @@ -104,10 +139,20 @@ void JsonApiPage::load() QString::fromStdString(it.first) + ":" + QString::fromStdString(it.second) ); - whileBlocking(ui.tokensListView)->setModel(new QStringListModel(newTk)); -} + whileBlocking(ui.tokensListView)->setModel(new QStringListModel(newTk)); -QString JsonApiPage::helpText() const { return ""; } + QStringList newTk2; + + for(const auto& it : rsJsonApi->getResourceProviders()) + newTk2.push_back( QString::fromStdString(it.get().getName())) ; + + whileBlocking(ui.providersListView)->setModel(new QStringListModel(newTk2)); + + if(rsJsonApi->isRunning()) + ui.statusLabelLED->setPixmap(FilesDefs::getPixmapFromQtResourcePath(IMAGE_LEDON)) ; + else + ui.statusLabelLED->setPixmap(FilesDefs::getPixmapFromQtResourcePath(IMAGE_LEDOFF)) ; +} bool JsonApiPage::checkStartJsonApi() { diff --git a/retroshare-gui/src/gui/settings/JsonApiPage.h b/retroshare-gui/src/gui/settings/JsonApiPage.h index 7f69bbd1e..ef28a4294 100644 --- a/retroshare-gui/src/gui/settings/JsonApiPage.h +++ b/retroshare-gui/src/gui/settings/JsonApiPage.h @@ -20,6 +20,8 @@ #pragma once +#include "retroshare/rsevents.h" + #include "retroshare-gui/configpage.h" #include "gui/common/FilesDefs.h" #include "ui_JsonApiPage.h" @@ -31,7 +33,7 @@ class JsonApiPage : public ConfigPage public: JsonApiPage(QWidget * parent = nullptr, Qt::WindowFlags flags = 0); - ~JsonApiPage() override = default; + ~JsonApiPage() override ; virtual QPixmap iconPixmap() const override { @@ -63,4 +65,6 @@ public slots: private: Ui::JsonApiPage ui; /// Qt Designer generated object + RsEventsHandlerId_t mEventHandlerId; }; + diff --git a/retroshare-gui/src/gui/settings/JsonApiPage.ui b/retroshare-gui/src/gui/settings/JsonApiPage.ui index 24b534712..f8d31e38f 100644 --- a/retroshare-gui/src/gui/settings/JsonApiPage.ui +++ b/retroshare-gui/src/gui/settings/JsonApiPage.ui @@ -13,7 +13,7 @@ Form - + @@ -25,13 +25,65 @@ JSON API Server - + - - - Enable RetroShare JSON API Server - - + + + + + Enable RetroShare JSON API Server + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Status: + + + + + + + + + + :/images/ledoff1.png + + + + + + + + + + + Listen Address: + + + + + + + 127.0.0.1 + + + + @@ -57,24 +109,6 @@ - - - - - - Listen Address: - - - - - - - 127.0.0.1 - - - - - @@ -110,13 +144,23 @@ - Authenticated Tokens + Authenticated Tokens: + + + + Registered services: + + + + + +
@@ -142,6 +186,8 @@
- + + + diff --git a/retroshare-gui/src/gui/settings/ServerPage.cpp b/retroshare-gui/src/gui/settings/ServerPage.cpp index 3dfe9069d..adb1d655c 100755 --- a/retroshare-gui/src/gui/settings/ServerPage.cpp +++ b/retroshare-gui/src/gui/settings/ServerPage.cpp @@ -107,6 +107,8 @@ ServerPage::ServerPage(QWidget * parent, Qt::WindowFlags flags) ui.hiddenpage_proxyPort_tor->setEnabled(false) ; ui.hiddenpage_localAddress->setEnabled(false) ; ui.hiddenpage_localPort->setEnabled(false) ; + ui.hiddenpage_serviceAddress->setEnabled(false) ; + ui.hiddenpage_servicePort->setEnabled(false) ; ui.testIncoming_PB->hide() ; ui.l_incomingTestResult->hide() ; ui.iconlabel_service_incoming->hide() ; diff --git a/retroshare-gui/src/gui/settings/ServerPage.ui b/retroshare-gui/src/gui/settings/ServerPage.ui index 60abc5fd8..93eb82637 100755 --- a/retroshare-gui/src/gui/settings/ServerPage.ui +++ b/retroshare-gui/src/gui/settings/ServerPage.ui @@ -256,11 +256,14 @@ - - - 16 - 16 - + + + 0 + 0 + + + + Qt::LeftToRight @@ -272,6 +275,12 @@ + + + 0 + 0 + + <html><head/><body><p>The bullet turns green as soon as Retroshare manages to get your own IP from the websites listed below, if you enabled that action. Retroshare will also use other means to find out your own IP.</p></body></html> @@ -290,13 +299,29 @@ 6 + + + + + 0 + 0 + + + + Local network + + + - - - 16 - 16 - + + + 0 + 0 + + + + Qt::LeftToRight @@ -306,13 +331,6 @@ - - - - Local network - - - @@ -351,13 +369,29 @@ 6 + + + + + 0 + 0 + + + + UPnP + + + - - - 16 - 16 - + + + 0 + 0 + + + + Qt::LeftToRight @@ -367,13 +401,6 @@ - - - - UPnP - - - @@ -386,11 +413,14 @@ - - - 16 - 16 - + + + 0 + 0 + + + + Qt::LeftToRight @@ -402,6 +432,12 @@ + + + 0 + 0 + + 75 @@ -802,12 +838,6 @@ behind a firewall or a VPN. - - - 16 - 16 - - diff --git a/retroshare-gui/src/gui/settings/WebuiPage.cpp b/retroshare-gui/src/gui/settings/WebuiPage.cpp index f0006fec3..4b36b758c 100644 --- a/retroshare-gui/src/gui/settings/WebuiPage.cpp +++ b/retroshare-gui/src/gui/settings/WebuiPage.cpp @@ -27,6 +27,7 @@ #include #include "util/misc.h" +#include "util/qtthreadsutils.h" #include "retroshare/rswebui.h" #include "retroshare/rsjsonapi.h" @@ -40,6 +41,8 @@ resource_api::ApiServerLocal* WebuiPage::apiServerLocal = 0; #endif resource_api::RsControlModule* WebuiPage::controlModule = 0; +#define IMAGE_LEDOFF ":/images/ledoff1.png" +#define IMAGE_LEDON ":/images/ledon1.png" WebuiPage::WebuiPage(QWidget */*parent*/, Qt::WindowFlags /*flags*/) { @@ -50,11 +53,22 @@ WebuiPage::WebuiPage(QWidget */*parent*/, Qt::WindowFlags /*flags*/) connect(ui.password_LE, SIGNAL(textChanged(QString)), this, SLOT(onPasswordValueChanged(QString))); connect(ui.startWebBrowser_PB, SIGNAL(clicked()), this, SLOT(onStartWebBrowserClicked())); connect(ui.webInterfaceFilesDirectory_PB, SIGNAL(clicked()), this, SLOT(selectWebInterfaceDirectory())); + + mEventsHandlerId = 0; + + 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 ); } WebuiPage::~WebuiPage() { - + rsEvents->unregisterEventsHandler(mEventsHandlerId); } void WebuiPage::selectWebInterfaceDirectory() @@ -73,22 +87,12 @@ void WebuiPage::selectWebInterfaceDirectory() bool WebuiPage::updateParams(QString &errmsg) { std::cerr << "WebuiPage::save()" << std::endl; - bool ok = true; - bool changed = false; - if(ui.enableWebUI_CB->isChecked() != Settings->getWebinterfaceEnabled()) - changed = true; - if(ui.webInterfaceFiles_LE->text() != Settings->getWebinterfaceFilesDirectory()) - changed = true; - if(changed) - { - // store config - Settings->setWebinterfaceEnabled(ui.enableWebUI_CB->isChecked()); - Settings->setWebinterfaceFilesDirectory(ui.webInterfaceFiles_LE->text()); + // store config + Settings->setWebinterfaceEnabled(ui.enableWebUI_CB->isChecked()); + Settings->setWebinterfaceFilesDirectory(ui.webInterfaceFiles_LE->text()); - rsWebUi->setHtmlFilesDirectory(ui.webInterfaceFiles_LE->text().toStdString()); - } - return ok; + return true; } void WebuiPage::onPasswordValueChanged(QString password) @@ -112,12 +116,27 @@ void WebuiPage::onPasswordValueChanged(QString password) bool WebuiPage::restart() { - return checkStartWebui(); + if(ui.password_LE->text().isNull()) + { + QMessageBox::critical(nullptr,tr("Missing passphrase"),tr("Please set a passphrase to proect the access to the WEB interface.")); + return false; + } + + rsWebUi->setUserPassword(ui.password_LE->text().toStdString()); + rsWebUi->setHtmlFilesDirectory(ui.webInterfaceFiles_LE->text().toStdString()); + + setCursor(Qt::WaitCursor) ; + rsWebUi->restart(); + setCursor(Qt::ArrowCursor) ; + + return true; } -void WebuiPage::load() +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()); @@ -127,6 +146,15 @@ void WebuiPage::load() 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)) ; + else + ui.statusLabelLED->setPixmap(FilesDefs::getPixmapFromQtResourcePath(IMAGE_LEDOFF)) ; +#else + ui.statusLabelLED->setPixmap(FilesDefs::getPixmapFromQtResourcePath(IMAGE_LEDOFF)) ; #endif } @@ -138,13 +166,11 @@ QString WebuiPage::helpText() const

Warning: don't expose the webinterface to the internet, because there is no access control and no encryption. If you want to use the webinterface over the internet, use a SSH tunnel or a proxy to secure the connection.

"); } -/*static*/ bool WebuiPage::checkStartWebui() +/*static*/ bool WebuiPage::checkStartWebui() // This is supposed to be called from main(). But normally the parameters below (including the paswd + // for the webUI should be saved in p3webui instead. { - if(!Settings->getWebinterfaceEnabled()) - return false; - - rsWebUi->setHtmlFilesDirectory(Settings->getWebinterfaceFilesDirectory().toStdString()); - rsWebUi->restart(); + rsWebUi->setHtmlFilesDirectory(Settings->getWebinterfaceFilesDirectory().toStdString()); + rsWebUi->restart(); return true; } @@ -173,15 +199,21 @@ QString WebuiPage::helpText() const void WebuiPage::onEnableCBClicked(bool checked) { - ui.params_GB->setEnabled(checked); - ui.apply_PB->setEnabled(checked); - ui.startWebBrowser_PB->setEnabled(checked); - QString S; + QString errmsg; + updateParams(errmsg); - Settings->setWebinterfaceEnabled(checked); + ui.params_GB->setEnabled(checked); + ui.startWebBrowser_PB->setEnabled(checked); + ui.apply_PB->setEnabled(checked); if(checked) - checkStartWebui(); + { + if(!restart()) + { + QMessageBox::warning(0, tr("failed to start Webinterface"), "Failed to start the webinterface."); + return; + } + } else checkShutdownWebui(); } @@ -199,18 +231,12 @@ void WebuiPage::onAllIPCBClicked(bool /*checked*/) } void WebuiPage::onApplyClicked() { - rsWebUi->setUserPassword(ui.password_LE->text().toStdString()); - QString errmsg; updateParams(errmsg); - if(!restart()) - { - QMessageBox::warning(0, tr("failed to start Webinterface"), "Failed to start the webinterface."); - return; - } + restart(); - emit passwordChanged(); + load(); } void WebuiPage::onStartWebBrowserClicked() { showWebui(); } diff --git a/retroshare-gui/src/gui/settings/WebuiPage.h b/retroshare-gui/src/gui/settings/WebuiPage.h index 9ba8886ac..391612cf8 100644 --- a/retroshare-gui/src/gui/settings/WebuiPage.h +++ b/retroshare-gui/src/gui/settings/WebuiPage.h @@ -20,6 +20,8 @@ #pragma once +#include "retroshare/rsevents.h" + #include "retroshare-gui/configpage.h" #include "gui/common/FilesDefs.h" #include "ui_WebuiPage.h" @@ -42,11 +44,11 @@ public: ~WebuiPage(); /** Loads the settings for this page */ - virtual void load(); + virtual void load() override { loadParams() ; } - virtual QPixmap iconPixmap() const { return FilesDefs::getPixmapFromQtResourcePath(":/icons/settings/webinterface.svg") ; } - virtual QString pageName() const { return tr("Webinterface") ; } - virtual QString helpText() const; + virtual QPixmap iconPixmap() const override { return FilesDefs::getPixmapFromQtResourcePath(":/icons/settings/webinterface.svg") ; } + virtual QString pageName() const override { return tr("Webinterface") ; } + virtual QString helpText() const override ; // call this after start of libretroshare/Retroshare // checks the settings and starts the webinterface if required @@ -67,10 +69,9 @@ public slots: void onApplyClicked(); void onStartWebBrowserClicked(); -signals: - void passwordChanged(); - private: + virtual void loadParams(); + /** Qt Designer generated object */ Ui::WebuiPage ui; @@ -83,4 +84,6 @@ private: static resource_api::ApiServerLocal* apiServerLocal; #endif static resource_api::RsControlModule* controlModule; + + RsEventsHandlerId_t mEventsHandlerId; }; diff --git a/retroshare-gui/src/gui/settings/WebuiPage.ui b/retroshare-gui/src/gui/settings/WebuiPage.ui index 5ca37e9b6..91d59736f 100644 --- a/retroshare-gui/src/gui/settings/WebuiPage.ui +++ b/retroshare-gui/src/gui/settings/WebuiPage.ui @@ -6,8 +6,8 @@ 0 0 - 960 - 717 + 570 + 646
@@ -15,11 +15,45 @@ - - - Enable Retroshare WEB Interface - - + + + + + Enable Retroshare WEB Interface + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Status: + + + + + + + + + + :/images/ledoff1.png + + + + diff --git a/retroshare-gui/src/gui/settings/rsettingswin.cpp b/retroshare-gui/src/gui/settings/rsettingswin.cpp index 46c85ea8e..1d3d4ecc3 100644 --- a/retroshare-gui/src/gui/settings/rsettingswin.cpp +++ b/retroshare-gui/src/gui/settings/rsettingswin.cpp @@ -178,10 +178,7 @@ SettingsPage::initStackedWidget() JsonApiPage *jsonapi_p = new JsonApiPage() ; addPage(jsonapi_p); #ifdef RS_WEBUI - WebuiPage *webui_p = new WebuiPage() ; - addPage(new WebuiPage() ); - - QObject::connect(webui_p,SIGNAL(passwordChanged()),jsonapi_p,SLOT(load())); + addPage(new WebuiPage()); #endif #endif 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/qss/retroclassic.qss b/retroshare-gui/src/qss/retroclassic.qss index df8802f3a..eea7fdf25 100644 --- a/retroshare-gui/src/qss/retroclassic.qss +++ b/retroshare-gui/src/qss/retroclassic.qss @@ -184,3 +184,9 @@ QLabel#label_masthead{ border: 2px solid #CCCCCC; border-radius: 4px; } + +PulseReplySeperator QFrame#frame { + border: 2px solid #CCCCCC; + background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #EEEEEE, stop: 1 #CCCCCC); + border-radius: 10px} +} 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/CMakeLists.txt b/retroshare-service/CMakeLists.txt index 672644369..c7560728e 100644 --- a/retroshare-service/CMakeLists.txt +++ b/retroshare-service/CMakeLists.txt @@ -95,7 +95,7 @@ if(EXISTS "${LIBRETROSHARE_DEVEL_DIR}/CMakeLists.txt" ) else() FetchContent_Declare( libretroshare - GIT_REPOSITORY "https://gitlab.com/RetroShare/libretroshare.git" + GIT_REPOSITORY "https://github.com/RetroShare/libretroshare.git" GIT_TAG "origin/master" GIT_SHALLOW TRUE GIT_PROGRESS TRUE @@ -116,15 +116,17 @@ if(RS_SERVICE_DESKTOP) install( FILES data/retroshare-service_48x48.png - DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/48x48/apps/retroshare-service.png ) + DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/48x48/apps/ + RENAME retroshare-service.png) install( FILES data/retroshare-service_128x128.png - DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/128x128/apps/retroshare-service.png ) + DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/128x128/apps/ + RENAME retroshare-service.png ) install( FILES data/retroshare-service.desktop - DESTINATION ${CMAKE_INSTALL_PREFIX}/data/retroshare-service.desktop ) + DESTINATION ${CMAKE_INSTALL_PREFIX}/data/ ) endif(UNIX AND NOT APPLE) endif(RS_SERVICE_DESKTOP) @@ -149,7 +151,7 @@ if(RS_WEBUI) else() FetchContent_Declare( webui - GIT_REPOSITORY "https://gitlab.com/RetroShare/RetroShareWebUI.git" + GIT_REPOSITORY "https://github.com/RetroShare/RSNewWebUI.git" GIT_TAG "origin/master" GIT_SHALLOW TRUE GIT_PROGRESS TRUE 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 b0ddb0918..dae0c13ef 160000 --- a/retroshare-webui +++ b/retroshare-webui @@ -1 +1 @@ -Subproject commit b0ddb09184e8fff86bd3325e00c6d4b329ae1790 +Subproject commit dae0c13ef78aee59a4f1f9e1cdb0127b5e27d256 diff --git a/retroshare.pri b/retroshare.pri index 9ed316b9a..7858f67f6 100644 --- a/retroshare.pri +++ b/retroshare.pri @@ -52,9 +52,9 @@ CONFIG *= retroshare_service no_retroshare_service:CONFIG -= retroshare_service # To disable RetroShare FriendServer append the following assignation to -# qmake command line "CONFIG+=no_rs_friendserver" +# qmake command line "CONFIG+=no_retroshare_friendserver" CONFIG *= retroshare_friendserver -no_rs_friendserver:CONFIG -= retroshare_friendserver +no_retroshare_friendserver:CONFIG -= retroshare_friendserver # To disable SQLCipher support append the following assignation to qmake # command line "CONFIG+=no_sqlcipher" @@ -456,13 +456,26 @@ defined in command line") RS_MINOR_VERSION = $$member(RS_GIT_DESCRIBE_SPLIT, 1) RS_GIT_DESCRIBE_SPLIT = $$member(RS_GIT_DESCRIBE_SPLIT, 2) - RS_GIT_DESCRIBE_SPLIT = $$split(RS_GIT_DESCRIBE_SPLIT, -) + RS_GIT_DESCRIBE_SPLIT = $$split(RS_GIT_DESCRIBE_SPLIT, ) - RS_MINI_VERSION = $$member(RS_GIT_DESCRIBE_SPLIT, 0) - - RS_GIT_DESCRIBE_SPLIT = $$member(RS_GIT_DESCRIBE_SPLIT, 1, -1) - - RS_EXTRA_VERSION = $$join(RS_GIT_DESCRIBE_SPLIT,-,-) + # Split string into mini version (leading numbers) and extra version (string after the numbers) + RS_MINI_VERSION = + RS_EXTRA_VERSION = + for(CHAR, RS_GIT_DESCRIBE_SPLIT) { + isEqual(CHAR, 0) | greaterThan(CHAR, 0):lessThan(CHAR, 9) | isEqual(CHAR, 9) { + # Number + isEmpty(RS_EXTRA_VERSION) { + # Add leading numbers to mini version + RS_MINI_VERSION = $${RS_MINI_VERSION}$${CHAR} + } else { + # Add to extra version + RS_EXTRA_VERSION = $${RS_EXTRA_VERSION}$${CHAR} + } + } else { + # Add to extra version + RS_EXTRA_VERSION = $${RS_EXTRA_VERSION}$${CHAR} + } + } message("RetroShare version\ $${RS_MAJOR_VERSION}.$${RS_MINOR_VERSION}.$${RS_MINI_VERSION}$${RS_EXTRA_VERSION}\ diff --git a/supportlibs/libsam3 b/supportlibs/libsam3 index 8623304b6..2226ef0a2 160000 --- a/supportlibs/libsam3 +++ b/supportlibs/libsam3 @@ -1 +1 @@ -Subproject commit 8623304b62294dafbe477573f321a464fef721dd +Subproject commit 2226ef0a20a001ec0942be6abe5e909c15447d8e