diff --git a/build_scripts/Android/README.asciidoc b/build_scripts/Android/README.asciidoc index 474d2f3ee..3f978cfd1 100644 --- a/build_scripts/Android/README.asciidoc +++ b/build_scripts/Android/README.asciidoc @@ -247,7 +247,7 @@ ${RS_SOURCE_DIR}/build_scripts/Android/pull_sysroot.sh [source,bash] -------------------------------------------------------------------------------- ## Optionally set Qt version variable consistently with your installation -export QT_VERSION="5.12.4" +export QT_VERSION="5.12.7" ## Optionally set Qt architecture variable consistently with Android device export QT_ARCH="arm64_v8a" diff --git a/build_scripts/Android/start_gdbserver.sh b/build_scripts/Android/start_gdbserver.sh index dce913568..af25e3be1 100755 --- a/build_scripts/Android/start_gdbserver.sh +++ b/build_scripts/Android/start_gdbserver.sh @@ -41,41 +41,56 @@ function define_default_value() define_default_value ANDROID_APK_PACKAGE "org.retroshare.service" define_default_value ANDROID_PROCESS_NAME "org.retroshare.service:rs" +define_default_value ANDROID_INSTALL_PATH "" +define_default_value LIB_GDB_SERVER_PATH "" define_default_value ANDROID_SERIAL "$(adb devices | head -n 2 | tail -n 1 | awk '{print $1}')" define_default_value GDB_SERVER_PORT 5039 -adb_shell() +adb_ushell() { adb shell run-as ${ANDROID_APK_PACKAGE} $@ } +[ -z "${ANDROID_INSTALL_PATH}" ] && +{ + ANDROID_INSTALL_PATH="$(adb_ushell pm path "${ANDROID_APK_PACKAGE}")" + ANDROID_INSTALL_PATH="$(dirname ${ANDROID_INSTALL_PATH#"package:"})" + [ -z "${ANDROID_INSTALL_PATH}" ] && + cat < buildinfo.txt echo %RsBuildConfig% >> buildinfo.txt echo %RsArchitecture% >> buildinfo.txt echo Qt %QtVersion% >> buildinfo.txt +echo %RsCompiler% >> buildinfo.txt call "%ToolsPath%\msys2-path.bat" "%SourcePath%" MSYS2SourcePath call "%ToolsPath%\msys2-path.bat" "%EnvMSYS2Path%" MSYS2EnvMSYS2Path -%EnvMSYS2Cmd% "qmake "%MSYS2SourcePath%/RetroShare.pro" -r -spec win32-g++ %RS_QMAKE_CONFIG%" +if "%ParamClang%"=="1" ( + %EnvMSYS2Cmd% "qmake "%MSYS2SourcePath%/RetroShare.pro" -r -spec win32-clang-g++ %RS_QMAKE_CONFIG%" +) else ( + %EnvMSYS2Cmd% "qmake "%MSYS2SourcePath%/RetroShare.pro" -r -spec win32-g++ %RS_QMAKE_CONFIG%" +) if errorlevel 1 goto error echo. @@ -69,7 +83,8 @@ echo. title Build - %SourceName%-%RsBuildConfig% [make] -%EnvMSYS2Cmd% "make -j %NUMBER_OF_PROCESSORS%" +%EnvMSYS2Cmd% "make -j %CoreCount%" +if errorlevel 1 goto error :: Webui if "%ParamWebui%"=="1" ( diff --git a/build_scripts/Windows-msys2/build/env-base.bat b/build_scripts/Windows-msys2/build/env-base.bat index 8f80e8681..9d9fa5379 100644 --- a/build_scripts/Windows-msys2/build/env-base.bat +++ b/build_scripts/Windows-msys2/build/env-base.bat @@ -7,6 +7,10 @@ set ParamAutologin=0 set ParamPlugins=0 set ParamTor=0 set ParamWebui=0 +set ParamClang=0 +set ParamIndexing=0 +set ParamNoupdate=0 +set CoreCount=%NUMBER_OF_PROCESSORS% set RS_QMAKE_CONFIG= :parameter_loop @@ -28,6 +32,14 @@ if "%~1" NEQ "" ( set ParamTor=1 ) else if "%%~a"=="webui" ( set ParamWebui=1 + ) else if "%%~a"=="singlethread" ( + set CoreCount=1 + ) else if "%%~a"=="clang" ( + set ParamClang=1 + ) else if "%%~a"=="indexing" ( + set ParamIndexing=1 + ) else if "%%~a"=="noupdate" ( + set ParamNoupdate=1 ) else if "%%~a"=="CONFIG+" ( set RS_QMAKE_CONFIG=%RS_QMAKE_CONFIG% %1 ) else ( @@ -58,6 +70,12 @@ if "%Param64%"=="1" ( set RsMSYS2Architecture=x86_64 ) +if "%ParamClang%"=="1" ( + set RsCompiler=Clang +) else ( + set RsCompiler=GCC +) + if "%RsBit%"=="" goto :usage if "%ParamRelease%"=="1" ( @@ -82,11 +100,15 @@ if "%ParamWebui%"=="1" ( set RS_QMAKE_CONFIG=%RS_QMAKE_CONFIG% "CONFIG+=rs_jsonapi" "CONFIG+=rs_webui" ) +if "%ParamIndexing%"=="1" ( + set RS_QMAKE_CONFIG=%RS_QMAKE_CONFIG% "CONFIG+=rs_deep_channels_index" "CONFIG+=rs_deep_files_index" "CONFIG+=rs_deep_files_index_ogg" "CONFIG+=rs_deep_files_index_flac" "CONFIG+=rs_deep_files_index_taglib" +) + exit /B 0 :usage echo. -echo Usage: 32^|64 release^|debug [version autologin plugins webui] +echo Usage: 32^|64 release^|debug [autologin plugins webui singlethread clang indexing noupdate] ["CONFIG+=..."] echo. echo Mandatory parameter echo 32^|64 32-bit or 64-bit Version @@ -96,6 +118,11 @@ echo Optional parameter (need clean when changed) echo autologin Build with autologin echo plugins Build plugins echo webui Enable JsonAPI and pack webui files +echo singlethread Use only 1 thread for building +echo clang Use clang compiler instead of GCC +echo indexing Build with deep channel and file indexing support +echo noupdate Skip updating the libraries +echo "CONFIG+=..." Enable some extra features, you can find the almost complete list in retroshare.pri echo. echo Parameter for pack echo tor Pack tor version diff --git a/build_scripts/Windows-msys2/build/env.bat b/build_scripts/Windows-msys2/build/env.bat index 8443d6218..bfe2afeba 100644 --- a/build_scripts/Windows-msys2/build/env.bat +++ b/build_scripts/Windows-msys2/build/env.bat @@ -16,8 +16,8 @@ if "%QtVersion%"=="" %cecho% error "Cannot get Qt version." & exit /B 1 set RsMinGWPath=%EnvMSYS2BasePath%\mingw%RsBit% -set RsBuildPath=%BuildPath%\Qt-%QtVersion%-%RsArchitecture%-%RsBuildConfig% -set RsDeployPath=%DeployPath%\Qt-%QtVersion%%RsType%-%RsArchitecture%-%RsBuildConfig% +set RsBuildPath=%BuildPath%\Qt-%QtVersion%-%RsArchitecture%-%RsCompiler%-%RsBuildConfig% +set RsDeployPath=%DeployPath%\Qt-%QtVersion%%RsType%-%RsArchitecture%-%RsCompiler%-%RsBuildConfig% set RsPackPath=%DeployPath% set RsArchiveAdd= set RsWebuiPath=%RootPath%\%SourceName%-webui diff --git a/build_scripts/Windows-msys2/build/git-log.bat b/build_scripts/Windows-msys2/build/git-log.bat index 010ff190b..f221bc871 100644 --- a/build_scripts/Windows-msys2/build/git-log.bat +++ b/build_scripts/Windows-msys2/build/git-log.bat @@ -1,118 +1,43 @@ @echo off +setlocal enabledelayedexpansion -setlocal - -set NoAsk= -if "%~2"=="no-ask" set NoAsk=1 - -:: Initialize environment -call "%~dp0..\env.bat" -if errorlevel 1 goto error_env -call "%EnvPath%\env.bat" -if errorlevel 1 goto error_env -call "%EnvPath%\env-msys2.bat" -if errorlevel 1 goto error_env - -call "%~dp0env.bat" %* -if errorlevel 2 exit /B 2 -if errorlevel 1 goto error_env - -:: Check git executable -set GitPath= -call "%ToolsPath%\find-in-path.bat" GitPath git.exe -if "%GitPath%"=="" echo Git executable not found in PATH.& exit /B 1 - -:: Get compiled revision -set GetRsVersion=%SourcePath%\build_scripts\Windows-msys2\tools\get-rs-version.bat -if not exist "%GetRsVersion%" ( - echo File not found - echo %GetRsVersion% +if "%~2"=="" ( + echo. + echo Parameter error. + echo Usage git-log sourcepath outputfile exit /B 1 ) -call "%GetRsVersion%" RS_REVISION_STRING RsRevision -if "%RsRevision%"=="" echo Revision not found.& exit /B 1 +set logfile=%~2 +copy nul %logfile% > nul -:: Get compiled version -call "%GetRsVersion%" RS_REVISION_STRING RsRevision -if "%RsRevision%"=="" echo Revision not found.& exit /B 1 +pushd %~1 -call "%GetRsVersion%" RS_MAJOR_VERSION RsMajorVersion -if "%RsMajorVersion%"=="" echo Major version not found.& exit /B 1 - -call "%GetRsVersion%" RS_MINOR_VERSION RsMinorVersion -if "%RsMinorVersion%"=="" echo Minor version not found.& exit /B 1 - -call "%GetRsVersion%" RS_BUILD_NUMBER RsBuildNumber -if "%RsBuildNumber%"=="" echo Build number not found.& exit /B 1 - -call "%GetRsVersion%" RS_BUILD_NUMBER_ADD RsBuildNumberAdd - -set RsVersion=%RsMajorVersion%.%RsMinorVersion%.%RsBuildNumber%%RsBuildNumberAdd% - -:: Check WMIC is available -wmic.exe alias /? >nul 2>&1 || echo WMIC is not available.&& exit /B 1 - -:: Use WMIC to retrieve date in format YYYYMMDD -set RsDate= -for /f "tokens=2 delims==" %%I in ('wmic os get localdatetime /format:list') do set RsDate=%%I -set RsDate=%RsDate:~0,4%%RsDate:~4,2%%RsDate:~6,2% - -:: Get last revision -set RsLastRefFile=%BuildPath%\Qt-%QtVersion%%RsType%-%RsBuildConfig%-LastRef.txt -set RsLastRef= -if exist "%RsLastRefFile%" set /P RsLastRef=<"%RsLastRefFile%" - -if "%NoAsk%"=="1" goto no_ask_for_last_revision -if not "%RsLastRef%"=="" echo Last Revision was %RsLastRef% -set /P RsLastRefInput=Last Revision: -if "%RsLastRefInput%" NEQ "" set RsLastRef=%RsLastRefInput% -:no_ask_for_last_revision - -:: Get current revision -pushd "%SourcePath%" -call "%ToolsPath%\get-git-ref.bat" RsRef -popd - -if errorlevel 1 exit /B 1 -if "%RsRef%"=="" echo Cannot get git revision.& exit /B 1 - -echo. -echo Creating log from %RsLastRef% -echo to %RsRef% - -if "%NoAsk%"=="1" goto no_confirm -choice /M "Do you want to proceed?" -if %errorlevel%==2 exit /B 1 -:no_confirm - -if "%RsBuildConfig%" NEQ "release" ( - set RsGitLog=%DeployPath%\RetroShare-%RsVersion%-Windows-Portable-%RsDate%-%RsRevision%-Qt-%QtVersion%%RsType%-msys2%RsArchiveAdd%-%RsBuildConfig%.txt -) else ( - set RsGitLog=%DeployPath%\RetroShare-%RsVersion%-Windows-Portable-%RsDate%-%RsRevision%-Qt-%QtVersion%%RsType%-msys2%RsArchiveAdd%.txt -) - -title %SourceName%-%RsBuildConfig% [git log] - -pushd "%SourcePath%" -if "%RsLastRef%"=="" ( - git log %RsRef% >"%RsGitLog%" -) else ( - if "%RsLastRef%"=="%RsRef%" ( - git log %RsRef% --max-count=1 >"%RsGitLog%" +set last=HEAD +for /f %%t in ('git tag --sort=-taggerdate --merged ^| findstr v') do ( + echo generating changelog for !last!..%%t + echo ----------------------------------------------- >> %logfile% + if !last! neq HEAD ( + git tag -n !last! >> %logfile% ) else ( - git log %RsLastRef%..%RsRef% >"%RsGitLog%" + echo HEAD >> %logfile% ) + rem echo !last! ---^> %%t >> %logfile% + echo ----------------------------------------------- >> %logfile% + echo. >> %logfile% + git log %%t..!last! --no-merges "--pretty=format:%%h %%ai %%<(10,trunc)%%an %%s" >> %logfile% + echo. >> %logfile% + echo. >> %logfile% + set last=%%t ) + +echo generating changelog for %last% +echo ----------------------------------------------- >> %logfile% +git tag -n %last% >> %logfile% +echo ----------------------------------------------- >> %logfile% +echo. >> %logfile% +git log %last% --no-merges "--pretty=format:%%h %%ai %%<(10,trunc)%%an %%s" >> %logfile% + popd -title %COMSPEC% - -echo %RsRef%>"%RsLastRefFile%" - -exit /B %ERRORLEVEL% - -:error_env -echo Failed to initialize environment. -endlocal -exit /B 1 +endlocal enabledelayedexpansion \ No newline at end of file diff --git a/build_scripts/Windows-msys2/build/pack.bat b/build_scripts/Windows-msys2/build/pack.bat index e759b7980..4c12ed7c0 100644 --- a/build_scripts/Windows-msys2/build/pack.bat +++ b/build_scripts/Windows-msys2/build/pack.bat @@ -17,8 +17,15 @@ call "%~dp0env.bat" %* if errorlevel 2 exit /B 2 if errorlevel 1 goto error_env -:: Install ntldd -%EnvMSYS2Cmd% "pacman --noconfirm --needed -S make git mingw-w64-%RsMSYS2Architecture%-ntldd-git" +if not "%ParamNoupdate%"=="1" ( + :: Install ntldd + %EnvMSYS2Cmd% "pacman --noconfirm --needed -S mingw-w64-%RsMSYS2Architecture%-ntldd-git" + + :: Install tor + if "%ParamTor%"=="1" ( + %EnvMSYS2Cmd% "pacman --noconfirm --needed -S mingw-w64-%RsMSYS2Architecture%-tor" + ) +) :: Remove deploy path if exist "%RsDeployPath%" rmdir /S /Q "%RsDeployPath%" @@ -53,14 +60,6 @@ set RsDate= for /f "tokens=2 delims==" %%I in ('wmic os get localdatetime /format:list') do set RsDate=%%I set RsDate=%RsDate:~0,4%%RsDate:~4,2%%RsDate:~6,2% -if "%ParamTor%"=="1" ( - :: Check for tor executable - if not exist "%EnvDownloadPath%\tor\Tor\tor.exe" ( - %cecho% error "Tor binary not found. Please download Tor Expert Bundle from\nhttps://www.torproject.org/download/download.html.en\nand unpack to\n%EnvDownloadPath:\=\\%\\tor" - goto error - ) -) - set QtMainVersion=%QtVersion:~0,1% set QtSharePath=%RsMinGWPath%\share\qt%QtMainVersion%\ @@ -72,9 +71,9 @@ if "%QtMainVersion%"=="4" set QtMainVersion2=4 if "%QtMainVersion%"=="5" set QtMainVersion1=5 if "%RsBuildConfig%" NEQ "release" ( - set Archive=%RsPackPath%\RetroShare-%RsVersion%-Windows-Portable-%RsDate%-%RsVersion.Extra%-Qt-%QtVersion%-msys2%RsType%%RsArchiveAdd%-%RsBuildConfig%.7z + set Archive=%RsPackPath%\RetroShare-%RsVersion%-Windows-Portable-%RsDate%-%RsVersion.Extra%-%RsArchitecture%-msys2%RsType%%RsArchiveAdd%-%RsBuildConfig%.7z ) else ( - set Archive=%RsPackPath%\RetroShare-%RsVersion%-Windows-Portable-%RsDate%-%RsVersion.Extra%-Qt-%QtVersion%-msys2%RsType%%RsArchiveAdd%.7z + set Archive=%RsPackPath%\RetroShare-%RsVersion%-Windows-Portable-%RsDate%-%RsVersion.Extra%-%RsArchitecture%-msys2%RsType%%RsArchiveAdd%.7z ) if exist "%Archive%" del /Q "%Archive%" @@ -96,6 +95,7 @@ mkdir "%RsDeployPath%\qss" mkdir "%RsDeployPath%\stylesheets" mkdir "%RsDeployPath%\sounds" mkdir "%RsDeployPath%\translations" +mkdir "%RsDeployPath%\license" copy nul "%RsDeployPath%\portable" %Quite% @@ -121,7 +121,7 @@ if "%QtMainVersion%"=="5" ( ) if exist "%QtSharePath%\plugins\styles\qwindowsvistastyle.dll" ( - echo Copy styles + echo copy styles mkdir "%RsDeployPath%\styles" %Quite% copy "%QtSharePath%\plugins\styles\qwindowsvistastyle.dll" "%RsDeployPath%\styles" %Quite% ) @@ -129,6 +129,12 @@ if exist "%QtSharePath%\plugins\styles\qwindowsvistastyle.dll" ( copy "%QtSharePath%\plugins\imageformats\*.dll" "%RsDeployPath%\imageformats" %Quite% del /Q "%RsDeployPath%\imageformats\*d?.dll" %Quite% +if "%ParamTor%"=="1" ( + echo copy tor + copy "%RsMinGWPath%\bin\tor.exe" "%RsDeployPath%" %Quite% + copy "%RsMinGWPath%\bin\tor-gencert.exe" "%RsDeployPath%" %Quite% +) + echo copy dependencies for /R "%RsDeployPath%" %%D in (*.dll, *.exe) do ( call :copy_dependencies "%%D" "%RsDeployPath%" @@ -146,6 +152,9 @@ rmdir /S /Q "%RsDeployPath%\stylesheets\__MACOSX__Bubble" %Quite% echo copy sounds xcopy /S "%SourcePath%\retroshare-gui\src\sounds" "%RsDeployPath%\sounds" %Quite% +echo copy license +xcopy /S "%SourcePath%\retroshare-gui\src\license" "%RsDeployPath%\license" %Quite% + echo copy translation copy "%SourcePath%\retroshare-gui\src\translations\qt_tr.qm" "%RsDeployPath%\translations" %Quite% copy "%QtSharePath%\translations\qt_*.qm" "%RsDeployPath%\translations" %Quite% @@ -160,8 +169,8 @@ if "%QtMainVersion%"=="5" ( echo copy bdboot.txt copy "%SourcePath%\libbitdht\src\bitdht\bdboot.txt" "%RsDeployPath%" %Quite% -echo copy changelog.txt -copy "%SourcePath%\retroshare-gui\src\changelog.txt" "%RsDeployPath%" %Quite% +echo generate changelog.txt +call call "%~dp0\git-log.bat" "%SourcePath%" "%RsDeployPath%\changelog.txt" echo copy buildinfo.txt copy "%RsBuildPath%\buildinfo.txt" "%RsDeployPath%" %Quite% @@ -177,11 +186,6 @@ if "%ParamWebui%"=="1" ( ) ) -if "%ParamTor%"=="1" ( - echo copy tor - echo n | copy /-y "%EnvDownloadPath%\tor\Tor\*.*" "%RsDeployPath%" %Quite% -) - rem pack files title Pack - %SourceName%%RsType%-%RsBuildConfig% [pack files] diff --git a/build_scripts/Windows-msys2/env/tools/prepare-msys2.bat b/build_scripts/Windows-msys2/env/tools/prepare-msys2.bat index ddf8b00a6..2f85c42be 100644 --- a/build_scripts/Windows-msys2/env/tools/prepare-msys2.bat +++ b/build_scripts/Windows-msys2/env/tools/prepare-msys2.bat @@ -25,7 +25,7 @@ if exist "%EnvMSYS2Path%\msys%MSYS2Base%\usr\bin\pacman.exe" ( ) ) -set MSYS2Install=msys2-base-%MSYS2Architecture%-20180531.tar.xz +set MSYS2Install=msys2-base-%MSYS2Architecture%-20200720.tar.xz set MSYS2Url=http://sourceforge.net/projects/msys2/files/Base/%MSYS2Architecture%/%MSYS2Install%/download %cecho% info "Remove previous MSYS2 version" diff --git a/build_scripts/Windows-msys2/installer/HeaderImage.bmp b/build_scripts/Windows-msys2/installer/HeaderImage.bmp new file mode 100644 index 000000000..5c55265cd Binary files /dev/null and b/build_scripts/Windows-msys2/installer/HeaderImage.bmp differ diff --git a/build_scripts/Windows-msys2/installer/HeaderImageEmpty.bmp b/build_scripts/Windows-msys2/installer/HeaderImageEmpty.bmp new file mode 100644 index 000000000..f0f0f1b32 Binary files /dev/null and b/build_scripts/Windows-msys2/installer/HeaderImageEmpty.bmp differ diff --git a/build_scripts/Windows-msys2/installer/ifexist.nsh b/build_scripts/Windows-msys2/installer/ifexist.nsh new file mode 100644 index 000000000..3f391c898 --- /dev/null +++ b/build_scripts/Windows-msys2/installer/ifexist.nsh @@ -0,0 +1,15 @@ +; See http://nsis.sourceforge.net/Check_if_a_file_exists_at_compile_time for documentation +!macro !defineifexist _VAR_NAME _FILE_NAME + !tempfile _TEMPFILE + !ifdef NSIS_WIN32_MAKENSIS + ; Windows - cmd.exe + !system 'if exist "${_FILE_NAME}" echo !define ${_VAR_NAME} > "${_TEMPFILE}"' + !else + ; Posix - sh + !system 'if [ -e "${_FILE_NAME}" ]; then echo "!define ${_VAR_NAME}" > "${_TEMPFILE}"; fi' + !endif + !include '${_TEMPFILE}' + !delfile '${_TEMPFILE}' + !undef _TEMPFILE +!macroend +!define !defineifexist "!insertmacro !defineifexist" \ No newline at end of file diff --git a/build_scripts/Windows-msys2/installer/lang/ca_ES.nsh b/build_scripts/Windows-msys2/installer/lang/ca_ES.nsh new file mode 100644 index 000000000..acb11b5a4 --- /dev/null +++ b/build_scripts/Windows-msys2/installer/lang/ca_ES.nsh @@ -0,0 +1,29 @@ +!insertmacro LANG_STRING Section_Main "${APPNAME}" +!insertmacro LANG_STRING Section_Main_Desc "Instal·la ${APPNAME} i els components necessaris." +!insertmacro LANG_STRING Section_Data "Pells" +!insertmacro LANG_STRING Section_Data_Desc "Instal·la pells." +!insertmacro LANG_STRING Section_Shortcuts "Icones d'accés directe" +!insertmacro LANG_STRING Section_Shortcuts_Desc "Afegir icones d'accés directe." +!insertmacro LANG_STRING Section_StartMenu "Icona del menú d'inici" +!insertmacro LANG_STRING Section_StartMenu_Desc "Afegir icona en el menú d'inici" +!insertmacro LANG_STRING Section_Desktop "Icona d'escriptori" +!insertmacro LANG_STRING Section_Desktop_Desc "Afegir icona a l'escriptori" +!insertmacro LANG_STRING Section_QuickLaunch "Icona de la barra ràpida d'accés" +!insertmacro LANG_STRING Section_QuickLaunch_Desc "Afegir icona a la barra ràpida d'accés" +!insertmacro LANG_STRING Section_Plugins "Complements opcionals" +!insertmacro LANG_STRING Section_Plugins_Desc "Components opcionals per afegir funcionalitat." +!insertmacro LANG_STRING Section_Plugin_FeedReader "LectorFonts" +!insertmacro LANG_STRING Section_Plugin_FeedReader_Desc "Instal·lar complement LectorFonts." +!insertmacro LANG_STRING Section_Plugin_LinksCloud "NúvolEnllaços" +!insertmacro LANG_STRING Section_Plugin_LinksCloud_Desc "Instal·lar complement NúvolEnllaços." +!insertmacro LANG_STRING Section_Plugin_VOIP "VeuIP" +!insertmacro LANG_STRING Section_Plugin_VOIP_Desc "Instal·lar complement VeuIP." +!insertmacro LANG_STRING Section_AutoStart "Posada en marxa automàtica" +!insertmacro LANG_STRING Section_AutoStart_Desc "Autoengegar al arrencar." +!insertmacro LANG_STRING Page_InstallMode "Mode instal·lació" +!insertmacro LANG_STRING Page_InstallMode_Desc "Escull com vols instal·lar ${APPNAME}." +!insertmacro LANG_STRING Page_InstallMode_Standard "Instal·lació e&stàndard" +!insertmacro LANG_STRING Page_InstallMode_Standard_Desc "Instal·la ${APPNAME} per la sessió d'usuari actual." +!insertmacro LANG_STRING Page_InstallMode_Portable "Instal·lació &portable." +!insertmacro LANG_STRING Page_InstallMode_Portable_Desc "En mode portable les dades de configuració s'emmagatzemen a la carpeta d'aplicació i no s'escriu informació al registre del sistema." +!insertmacro LANG_STRING Link_Uninstall "Desinstal·lar." diff --git a/build_scripts/Windows-msys2/installer/lang/de.nsh b/build_scripts/Windows-msys2/installer/lang/de.nsh new file mode 100644 index 000000000..c5323f523 --- /dev/null +++ b/build_scripts/Windows-msys2/installer/lang/de.nsh @@ -0,0 +1,29 @@ +!insertmacro LANG_STRING Section_Main "${APPNAME}" +!insertmacro LANG_STRING Section_Main_Desc "Installiert ${APPNAME} und die benötigten Komponenten." +!insertmacro LANG_STRING Section_Data "Skins" +!insertmacro LANG_STRING Section_Data_Desc "Skins installieren." +!insertmacro LANG_STRING Section_Shortcuts "Verknüpfungssymbole" +!insertmacro LANG_STRING Section_Shortcuts_Desc "Verküpfungssymbole hinzufügen." +!insertmacro LANG_STRING Section_StartMenu "Startmenüsymbol" +!insertmacro LANG_STRING Section_StartMenu_Desc "Fügt Symbol zum Startmenü hinzu." +!insertmacro LANG_STRING Section_Desktop "Desktopsymbol" +!insertmacro LANG_STRING Section_Desktop_Desc "Fügt Symbol zum Desktop hinzu." +!insertmacro LANG_STRING Section_QuickLaunch "Schnellstartsymbol" +!insertmacro LANG_STRING Section_QuickLaunch_Desc "Fügt Symbol zur Schnellstartleiste hinzu." +!insertmacro LANG_STRING Section_Plugins "Optionale Plug-ins" +!insertmacro LANG_STRING Section_Plugins_Desc "Optionale Plug-ins zum Erweitern der Funktionalität." +!insertmacro LANG_STRING Section_Plugin_FeedReader "FeedReader" +!insertmacro LANG_STRING Section_Plugin_FeedReader_Desc "Installiert das Plug-in Feedreader." +!insertmacro LANG_STRING Section_Plugin_LinksCloud "Verknüpfungswolke" +!insertmacro LANG_STRING Section_Plugin_LinksCloud_Desc "Installiert das Plug-in Verknüpfungswolke." +!insertmacro LANG_STRING Section_Plugin_VOIP "VOIP" +!insertmacro LANG_STRING Section_Plugin_VOIP_Desc "Installiert das Plug-in VOIP" +!insertmacro LANG_STRING Section_AutoStart "Automatischer Programmstart" +!insertmacro LANG_STRING Section_AutoStart_Desc "Beim Start automatisch ausführen." +!insertmacro LANG_STRING Page_InstallMode "Installationsmodus" +!insertmacro LANG_STRING Page_InstallMode_Desc "Wähle wie du ${APPNAME} installieren willst." +!insertmacro LANG_STRING Page_InstallMode_Standard "&Standardinstallation" +!insertmacro LANG_STRING Page_InstallMode_Standard_Desc "Installiere ${APPNAME} für den derzeitigen Benutzer dieses Geräts." +!insertmacro LANG_STRING Page_InstallMode_Portable "&Portable Installation" +!insertmacro LANG_STRING Page_InstallMode_Portable_Desc "Im portablen Modus werden alle Konfigurationsdaten im Verzeichnis der Anwendung gespeichert und keine Informationen in der Registry abgelegt." +!insertmacro LANG_STRING Link_Uninstall "Deinstallieren" diff --git a/build_scripts/Windows-msys2/installer/lang/en.nsh b/build_scripts/Windows-msys2/installer/lang/en.nsh new file mode 100644 index 000000000..a1bbc783c --- /dev/null +++ b/build_scripts/Windows-msys2/installer/lang/en.nsh @@ -0,0 +1,29 @@ +!insertmacro LANG_STRING Section_Main "${APPNAME}" +!insertmacro LANG_STRING Section_Main_Desc "Installs ${APPNAME} and required components." +!insertmacro LANG_STRING Section_Data "Skins" +!insertmacro LANG_STRING Section_Data_Desc "Installs skins." +!insertmacro LANG_STRING Section_Shortcuts "Shortcut icons" +!insertmacro LANG_STRING Section_Shortcuts_Desc "Adds shortcut icons." +!insertmacro LANG_STRING Section_StartMenu "Start Menu icon" +!insertmacro LANG_STRING Section_StartMenu_Desc "Adds icon to start menu." +!insertmacro LANG_STRING Section_Desktop "Desktop icon" +!insertmacro LANG_STRING Section_Desktop_Desc "Adds icon to desktop." +!insertmacro LANG_STRING Section_QuickLaunch "Quick Launch icon" +!insertmacro LANG_STRING Section_QuickLaunch_Desc "Adds icon to Quick Launch toolbar." +!insertmacro LANG_STRING Section_Plugins "Optional plugins" +!insertmacro LANG_STRING Section_Plugins_Desc "Optional plugins to extend functionality." +!insertmacro LANG_STRING Section_Plugin_FeedReader "FeedReader" +!insertmacro LANG_STRING Section_Plugin_FeedReader_Desc "Installs plugin FeedReader." +!insertmacro LANG_STRING Section_Plugin_VOIP "VOIP" +!insertmacro LANG_STRING Section_Plugin_VOIP_Desc "Installs plugin VOIP." +;!insertmacro LANG_STRING Section_Link "File Association" +;!insertmacro LANG_STRING Section_Link_Desc "Associate ${APPNAME} with .pqi file extension." +!insertmacro LANG_STRING Section_AutoStart "Auto Startup" +!insertmacro LANG_STRING Section_AutoStart_Desc "Auto-Run at startup." +!insertmacro LANG_STRING Page_InstallMode "Installation Mode" +!insertmacro LANG_STRING Page_InstallMode_Desc "Choose how you want to install ${APPNAME}." +!insertmacro LANG_STRING Page_InstallMode_Standard "&Standard installation" +!insertmacro LANG_STRING Page_InstallMode_Standard_Desc "Install ${APPNAME} for the current user of this machine." +!insertmacro LANG_STRING Page_InstallMode_Portable "&Portable installation" +!insertmacro LANG_STRING Page_InstallMode_Portable_Desc "In portable mode all configuration data is stored in the application folder and no information is written to the registry." +!insertmacro LANG_STRING Link_Uninstall "Uninstall" \ No newline at end of file diff --git a/build_scripts/Windows-msys2/installer/lang/es.nsh b/build_scripts/Windows-msys2/installer/lang/es.nsh new file mode 100644 index 000000000..68900ec62 --- /dev/null +++ b/build_scripts/Windows-msys2/installer/lang/es.nsh @@ -0,0 +1,29 @@ +!insertmacro LANG_STRING Section_Main "${APPNAME}" +!insertmacro LANG_STRING Section_Main_Desc "Instala ${APPNAME} y los componentes requeridos." +!insertmacro LANG_STRING Section_Data "Coberturas (skins)" +!insertmacro LANG_STRING Section_Data_Desc "Instalar coberturas" +!insertmacro LANG_STRING Section_Shortcuts "Iconos de accesos directos" +!insertmacro LANG_STRING Section_Shortcuts_Desc "Añade iconos de accesos directos." +!insertmacro LANG_STRING Section_StartMenu "Icono de menú de inicio" +!insertmacro LANG_STRING Section_StartMenu_Desc "Añade icono al menú de inicio." +!insertmacro LANG_STRING Section_Desktop "Icono del escritorio" +!insertmacro LANG_STRING Section_Desktop_Desc "Añade icono al escritorio" +!insertmacro LANG_STRING Section_QuickLaunch "Icono de inicio rápido" +!insertmacro LANG_STRING Section_QuickLaunch_Desc "Añade icono a la Barra de Inicio Rápido" +!insertmacro LANG_STRING Section_Plugins "Complementos opcionales" +!insertmacro LANG_STRING Section_Plugins_Desc "Complementos opcionales para expandir la funcionalidad." +!insertmacro LANG_STRING Section_Plugin_FeedReader "FeedReader" +!insertmacro LANG_STRING Section_Plugin_FeedReader_Desc "Instala el complemento FeedReader." +!insertmacro LANG_STRING Section_Plugin_LinksCloud "LinksCloud" +!insertmacro LANG_STRING Section_Plugin_LinksCloud_Desc "Instala el complemento LinksCloud." +!insertmacro LANG_STRING Section_Plugin_VOIP "VOIP" +!insertmacro LANG_STRING Section_Plugin_VOIP_Desc "Instala el complemento VOIP" +!insertmacro LANG_STRING Section_AutoStart "Auto iniciar" +!insertmacro LANG_STRING Section_AutoStart_Desc "Auto-ejecutar al incio." +!insertmacro LANG_STRING Page_InstallMode "Modo de instalación" +!insertmacro LANG_STRING Page_InstallMode_Desc "Elija cómo quiere instalar ${APPNAME}." +!insertmacro LANG_STRING Page_InstallMode_Standard "Instalación &Estándar" +!insertmacro LANG_STRING Page_InstallMode_Standard_Desc "Instalar ${APPNAME} para el usuario actual de esta máquina." +!insertmacro LANG_STRING Page_InstallMode_Portable "Instalación &Portable" +!insertmacro LANG_STRING Page_InstallMode_Portable_Desc "En modo portable, todos los datos de configuración se almacenan en la carpeta de la aplicación y no se escribe ninguna información en el registro." +!insertmacro LANG_STRING Link_Uninstall "Desinstalar" diff --git a/build_scripts/Windows-msys2/installer/lang/fr.nsh b/build_scripts/Windows-msys2/installer/lang/fr.nsh new file mode 100644 index 000000000..d4c797833 --- /dev/null +++ b/build_scripts/Windows-msys2/installer/lang/fr.nsh @@ -0,0 +1,29 @@ +!insertmacro LANG_STRING Section_Main "${APPNAME}" +!insertmacro LANG_STRING Section_Main_Desc "Installe ${APPNAME} et les composants requis." +!insertmacro LANG_STRING Section_Data "Habillages" +!insertmacro LANG_STRING Section_Data_Desc "Installe des habillages." +!insertmacro LANG_STRING Section_Shortcuts "Icônes de raccourci" +!insertmacro LANG_STRING Section_Shortcuts_Desc "Ajoute les icônes de raccourci." +!insertmacro LANG_STRING Section_StartMenu "Icône de menu démarrage" +!insertmacro LANG_STRING Section_StartMenu_Desc "Ajoute l'icône au menu démarrer." +!insertmacro LANG_STRING Section_Desktop "Icônes de bureau" +!insertmacro LANG_STRING Section_Desktop_Desc "Ajoute l'icône sur le bureau." +!insertmacro LANG_STRING Section_QuickLaunch "Icône de lancement rapide" +!insertmacro LANG_STRING Section_QuickLaunch_Desc "Ajoute une icône à la barre d'outils de lancement rapide." +!insertmacro LANG_STRING Section_Plugins "Plug-ins optionnels" +!insertmacro LANG_STRING Section_Plugins_Desc "Plug-ins optionnels destinés à étendre les fonctionnalités." +!insertmacro LANG_STRING Section_Plugin_FeedReader "FeedReader" +!insertmacro LANG_STRING Section_Plugin_FeedReader_Desc "Installe le plug-in FeedReader." +!insertmacro LANG_STRING Section_Plugin_LinksCloud "LinksCloud" +!insertmacro LANG_STRING Section_Plugin_LinksCloud_Desc "Installe le plug-in LinksCloud." +!insertmacro LANG_STRING Section_Plugin_VOIP "VOIP" +!insertmacro LANG_STRING Section_Plugin_VOIP_Desc "Installe le plug-in VOIP." +!insertmacro LANG_STRING Section_AutoStart "Démarrage automatique" +!insertmacro LANG_STRING Section_AutoStart_Desc "Démarrage automatique au démarrage." +!insertmacro LANG_STRING Page_InstallMode "Mode d'installation" +!insertmacro LANG_STRING Page_InstallMode_Desc "Choisissez comment vous voulez installer ${APPNAME}." +!insertmacro LANG_STRING Page_InstallMode_Standard "&Installation standard" +!insertmacro LANG_STRING Page_InstallMode_Standard_Desc "Installer ${APPNAME} pour l'utilisateur actuel de cette machine." +!insertmacro LANG_STRING Page_InstallMode_Portable "&Installation portable" +!insertmacro LANG_STRING Page_InstallMode_Portable_Desc "En mode portable toutes les données de configuration sont stockées dans le dossier de l'application et aucune information n'est écrite dans la base de registre." +!insertmacro LANG_STRING Link_Uninstall "Désinstaller" diff --git a/build_scripts/Windows-msys2/installer/lang/pl.nsh b/build_scripts/Windows-msys2/installer/lang/pl.nsh new file mode 100644 index 000000000..9f6d4305e --- /dev/null +++ b/build_scripts/Windows-msys2/installer/lang/pl.nsh @@ -0,0 +1,29 @@ +!insertmacro LANG_STRING Section_Main "${APPNAME}" +!insertmacro LANG_STRING Section_Main_Desc "Instaluje ${APPNAME} oraz wymagane komponenty." +!insertmacro LANG_STRING Section_Data "Skórki" +!insertmacro LANG_STRING Section_Data_Desc "Instaluje skórki." +!insertmacro LANG_STRING Section_Shortcuts "Ikony skrótów" +!insertmacro LANG_STRING Section_Shortcuts_Desc "Dodaje skróty ikon." +!insertmacro LANG_STRING Section_StartMenu "Start Menu icon" +!insertmacro LANG_STRING Section_StartMenu_Desc "Dodaje ikonę do menu start." +!insertmacro LANG_STRING Section_Desktop "Ikona na pulpicie" +!insertmacro LANG_STRING Section_Desktop_Desc "Dodawanie ikony na pulpicie" +!insertmacro LANG_STRING Section_QuickLaunch "Ikona szybkiego uruchamiania" +!insertmacro LANG_STRING Section_QuickLaunch_Desc "Dodaje ikonę do paska Szybkiego Uruchamiania." +!insertmacro LANG_STRING Section_Plugins "Wtyczki opcjonalne" +!insertmacro LANG_STRING Section_Plugins_Desc "Wtyczki opcjonalne rozszerzające funkcjonalność." +!insertmacro LANG_STRING Section_Plugin_FeedReader "FeedReader" +!insertmacro LANG_STRING Section_Plugin_FeedReader_Desc "Instaluje wtyczki FeedReader" +!insertmacro LANG_STRING Section_Plugin_LinksCloud "LinksCloud" +!insertmacro LANG_STRING Section_Plugin_LinksCloud_Desc "Instaluje wtyczki LinksCloud." +!insertmacro LANG_STRING Section_Plugin_VOIP "VOIP" +!insertmacro LANG_STRING Section_Plugin_VOIP_Desc "Instaluje wtyczki VOIP." +!insertmacro LANG_STRING Section_AutoStart "Auto Startup" +!insertmacro LANG_STRING Section_AutoStart_Desc "Automatyczne uruchamianie przy starcie." +!insertmacro LANG_STRING Page_InstallMode "Tryb instalacji" +!insertmacro LANG_STRING Page_InstallMode_Desc "Wybierz jak chcesz zainstalować ${APPNAME}." +!insertmacro LANG_STRING Page_InstallMode_Standard "&Standardowa instalacja" +!insertmacro LANG_STRING Page_InstallMode_Standard_Desc "Zainstaluj ${APPNAME} dla bieżącego użytkownika tej maszyny." +!insertmacro LANG_STRING Page_InstallMode_Portable "&Portable installation" +!insertmacro LANG_STRING Page_InstallMode_Portable_Desc "W trybie przenośnym wszystkie dane konfiguracyjne są przechowywane w folderze aplikacji i nie są zapisywane w rejestrze." +!insertmacro LANG_STRING Link_Uninstall "Odinstaluj" diff --git a/build_scripts/Windows-msys2/installer/lang/ru.nsh b/build_scripts/Windows-msys2/installer/lang/ru.nsh new file mode 100644 index 000000000..09c578cb8 --- /dev/null +++ b/build_scripts/Windows-msys2/installer/lang/ru.nsh @@ -0,0 +1,29 @@ +!insertmacro LANG_STRING Section_Main "${APPNAME}" +!insertmacro LANG_STRING Section_Main_Desc "Установка ${APPNAME} и необходимых компонентов." +!insertmacro LANG_STRING Section_Data "Оболочки" +!insertmacro LANG_STRING Section_Data_Desc "Установка оболочек." +!insertmacro LANG_STRING Section_Shortcuts "Ярлыки" +!insertmacro LANG_STRING Section_Shortcuts_Desc "Добавление ярлыков." +!insertmacro LANG_STRING Section_StartMenu "Ярлык в меню Пуск" +!insertmacro LANG_STRING Section_StartMenu_Desc "Добавление ярлыка в меню Пуск." +!insertmacro LANG_STRING Section_Desktop "Ярлык на рабочем столе" +!insertmacro LANG_STRING Section_Desktop_Desc "Добавление ярлыка на рабочий стол." +!insertmacro LANG_STRING Section_QuickLaunch "Ярлык в панели быстрого запуска" +!insertmacro LANG_STRING Section_QuickLaunch_Desc "Добавление ярлыка на панель быстрого запуска." +!insertmacro LANG_STRING Section_Plugins "Дополнительные плагины" +!insertmacro LANG_STRING Section_Plugins_Desc "Дополнительные плагины для расширения функциональности." +!insertmacro LANG_STRING Section_Plugin_FeedReader "FeedReader – RSS-агрегатор" +!insertmacro LANG_STRING Section_Plugin_FeedReader_Desc "Установка плагина FeedReader." +!insertmacro LANG_STRING Section_Plugin_LinksCloud "LinksCloud – Облако ссылок" +!insertmacro LANG_STRING Section_Plugin_LinksCloud_Desc "Установка плагина LinksCloud." +!insertmacro LANG_STRING Section_Plugin_VOIP "VoIP" +!insertmacro LANG_STRING Section_Plugin_VOIP_Desc "Установка плагина VoIP." +!insertmacro LANG_STRING Section_AutoStart "Автозапуск" +!insertmacro LANG_STRING Section_AutoStart_Desc "Автозапуск при загрузке системы." +!insertmacro LANG_STRING Page_InstallMode "Режим установки" +!insertmacro LANG_STRING Page_InstallMode_Desc "Выберите метод установки ${APPNAME}." +!insertmacro LANG_STRING Page_InstallMode_Standard "Стандартная установка" +!insertmacro LANG_STRING Page_InstallMode_Standard_Desc "Установка ${APPNAME} для текущего пользователя компьютера." +!insertmacro LANG_STRING Page_InstallMode_Portable "Портативная установка" +!insertmacro LANG_STRING Page_InstallMode_Portable_Desc "В режиме портативной установки все конфигурационные файлы сохраняются в папку приложения и в системный реестр не записывается никакой информации." +!insertmacro LANG_STRING Link_Uninstall "Удаление программы" diff --git a/build_scripts/Windows-msys2/installer/lang/tr.nsh b/build_scripts/Windows-msys2/installer/lang/tr.nsh new file mode 100644 index 000000000..f893ac076 --- /dev/null +++ b/build_scripts/Windows-msys2/installer/lang/tr.nsh @@ -0,0 +1,29 @@ +!insertmacro LANG_STRING Section_Main "${APPNAME}" +!insertmacro LANG_STRING Section_Main_Desc "${APPNAME} ve gerekli bileşenleri kurar." +!insertmacro LANG_STRING Section_Data "Temalar" +!insertmacro LANG_STRING Section_Data_Desc "Tema yükleyin." +!insertmacro LANG_STRING Section_Shortcuts "Kısayol simgeleri" +!insertmacro LANG_STRING Section_Shortcuts_Desc "Kısayol simgesi ekleyin." +!insertmacro LANG_STRING Section_StartMenu "Başlat Menüsü simgesi" +!insertmacro LANG_STRING Section_StartMenu_Desc "Başlat menüsüne simge ekleyin." +!insertmacro LANG_STRING Section_Desktop "Masaüstü simgesi" +!insertmacro LANG_STRING Section_Desktop_Desc "Masaüstüne simge ekleyin." +!insertmacro LANG_STRING Section_QuickLaunch "Hızlı Başlat simgesi" +!insertmacro LANG_STRING Section_QuickLaunch_Desc "Hızlı Başlat araç çubuğuna simge ekleyin." +!insertmacro LANG_STRING Section_Plugins "İsteğe bağlı eklentiler" +!insertmacro LANG_STRING Section_Plugins_Desc "İşlevselliği artırmak için isteğe bağlı eklentiler." +!insertmacro LANG_STRING Section_Plugin_FeedReader "AkışOkuyucu" +!insertmacro LANG_STRING Section_Plugin_FeedReader_Desc "AkışOkuyucu eklentisini yükleyin." +!insertmacro LANG_STRING Section_Plugin_LinksCloud "BağlantıBulutu" +!insertmacro LANG_STRING Section_Plugin_LinksCloud_Desc "BağlantıBulutu eklentisini yükleyin." +!insertmacro LANG_STRING Section_Plugin_VOIP "VOIP" +!insertmacro LANG_STRING Section_Plugin_VOIP_Desc "VOIP eklentisini yükleyin." +!insertmacro LANG_STRING Section_AutoStart "Otomatik Başlat" +!insertmacro LANG_STRING Section_AutoStart_Desc "Açılışta otomatik başlatın." +!insertmacro LANG_STRING Page_InstallMode "Kurulum Yöntemi" +!insertmacro LANG_STRING Page_InstallMode_Desc "${APPNAME} kurulum şeklini seçin" +!insertmacro LANG_STRING Page_InstallMode_Standard "&Normal kurulum" +!insertmacro LANG_STRING Page_InstallMode_Standard_Desc "${APPNAME} yalnızca şimdiki kullanıcı için kurulsun." +!insertmacro LANG_STRING Page_InstallMode_Portable "&Taşınabilir kurulum" +!insertmacro LANG_STRING Page_InstallMode_Portable_Desc "Taşınabilir kipte tüm ayarlar uygulama klasörüne depolanır ve kayıt defterine hiçbir bilgi yazılmaz." +!insertmacro LANG_STRING Link_Uninstall "Kaldırın" diff --git a/build_scripts/Windows-msys2/installer/lang/ts/ca_ES.ts b/build_scripts/Windows-msys2/installer/lang/ts/ca_ES.ts new file mode 100644 index 000000000..add40b909 --- /dev/null +++ b/build_scripts/Windows-msys2/installer/lang/ts/ca_ES.ts @@ -0,0 +1,205 @@ + + + Section_Main + + ${APPNAME} + ${APPNAME} + + + + Section_Main_Desc + + Installs ${APPNAME} and required components. + Instal·la ${APPNAME} i els components necessaris. + + + + Section_Data + + Skins + Pells + + + + Section_Data_Desc + + Installs skins. + Instal·la pells. + + + + Section_Shortcuts + + Shortcut icons + Icones d'accés directe + + + + Section_Shortcuts_Desc + + Adds shortcut icons. + Afegir icones d'accés directe. + + + + Section_StartMenu + + Start Menu icon + Icona del menú d'inici + + + + Section_StartMenu_Desc + + Adds icon to start menu. + Afegir icona en el menú d'inici + + + + Section_Desktop + + Desktop icon + Icona d'escriptori + + + + Section_Desktop_Desc + + Adds icon to desktop. + Afegir icona a l'escriptori + + + + Section_QuickLaunch + + Quick Launch icon + Icona de la barra ràpida d'accés + + + + Section_QuickLaunch_Desc + + Adds icon to Quick Launch toolbar. + Afegir icona a la barra ràpida d'accés + + + + Section_Plugins + + Optional plugins + Complements opcionals + + + + Section_Plugins_Desc + + Optional plugins to extend functionality. + Components opcionals per afegir funcionalitat. + + + + Section_Plugin_FeedReader + + FeedReader + LectorFonts + + + + Section_Plugin_FeedReader_Desc + + Installs plugin FeedReader. + Instal·lar complement LectorFonts. + + + + Section_Plugin_LinksCloud + + LinksCloud + NúvolEnllaços + + + + Section_Plugin_LinksCloud_Desc + + Installs plugin LinksCloud. + Instal·lar complement NúvolEnllaços. + + + + Section_Plugin_VOIP + + VOIP + VeuIP + + + + Section_Plugin_VOIP_Desc + + Installs plugin VOIP. + Instal·lar complement VeuIP. + + + + Section_AutoStart + + Auto Startup + Posada en marxa automàtica + + + + Section_AutoStart_Desc + + Auto-Run at startup. + Autoengegar al arrencar. + + + + Page_InstallMode + + Installation Mode + Mode instal·lació + + + + Page_InstallMode_Desc + + Choose how you want to install ${APPNAME}. + Escull com vols instal·lar ${APPNAME}. + + + + Page_InstallMode_Standard + + &Standard installation + Instal·lació e&stàndard + + + + Page_InstallMode_Standard_Desc + + Install ${APPNAME} for the current user of this machine. + Instal·la ${APPNAME} per la sessió d'usuari actual. + + + + Page_InstallMode_Portable + + &Portable installation + Instal·lació &portable. + + + + Page_InstallMode_Portable_Desc + + In portable mode all configuration data is stored in the application folder and no information is written to the registry. + En mode portable les dades de configuració s'emmagatzemen a la carpeta d'aplicació i no s'escriu informació al registre del sistema. + + + + Link_Uninstall + + Uninstall + Desinstal·lar. + + + \ No newline at end of file diff --git a/build_scripts/Windows-msys2/installer/lang/ts/convert_from_ts.bat b/build_scripts/Windows-msys2/installer/lang/ts/convert_from_ts.bat new file mode 100644 index 000000000..d514256e1 --- /dev/null +++ b/build_scripts/Windows-msys2/installer/lang/ts/convert_from_ts.bat @@ -0,0 +1,27 @@ +@echo off + +:: Very simple conversion from *.ts to *.nsh using xslt + +pushd "%~dp0" + +if "%1"=="" ( + for %%F in (*.ts) do if "%%F" NEQ "en.ts" call :convert %%~nF + goto :exit +) + +call :convert %1 + +:exit +popd + +goto :EOF + +:convert +if not exist "%~1.ts" ( + echo File "%~1.ts" not found. + goto :EOF +) + +echo %~1 + +"%~dp0xsltproc.exe" --output "%~dp0..\%~1.nsh" "%~dp0convert_from_ts.xsl" "%~1.ts" diff --git a/build_scripts/Windows-msys2/installer/lang/ts/convert_from_ts.xsl b/build_scripts/Windows-msys2/installer/lang/ts/convert_from_ts.xsl new file mode 100644 index 000000000..a376fe691 --- /dev/null +++ b/build_scripts/Windows-msys2/installer/lang/ts/convert_from_ts.xsl @@ -0,0 +1,20 @@ + + + + + + + + !insertmacro LANG_STRING + + " + + + + + " + + + + \ No newline at end of file diff --git a/build_scripts/Windows-msys2/installer/lang/ts/convert_to_ts.bat b/build_scripts/Windows-msys2/installer/lang/ts/convert_to_ts.bat new file mode 100644 index 000000000..9235d6bab --- /dev/null +++ b/build_scripts/Windows-msys2/installer/lang/ts/convert_to_ts.bat @@ -0,0 +1,50 @@ +@echo off + +:: Very simple conversion from *.nsh to *.ts + +setlocal + +set Language=en +if "%1" NEQ "" set Language=%1 + +set InputFile=%~dp0..\%Language%.nsh +set OutputFile=%~dp0%Language%.ts + +if not exist "%InputFile%" ( + echo File %InputFile% not found. + goto :exit +) + +echo ^ >"%OutputFile%" +echo ^ >>"%OutputFile%" +echo ^ >>"%OutputFile%" + +for /F "tokens=1,2,3,*" %%A in (%InputFile%) do if "%%A"=="!insertmacro" call :context %%C %%D + +echo ^ >>"%OutputFile%" + +:exit +endlocal +goto :EOF + +:context + +setlocal EnableDelayedExpansion + +:: Simple replace of & to & +set Text=%2 +set Text=%Text:&=^&% +set Text=%Text:~1,-1% + +echo !Text! + +echo ^ >>"%OutputFile%" +echo ^%~1^ >>"%OutputFile%" +echo ^ >>"%OutputFile%" +echo ^!Text!^ >>"%OutputFile%" +echo ^^ >>"%OutputFile%" +echo ^ >>"%OutputFile%" +echo ^ >>"%OutputFile%" + +endlocal +goto :EOF diff --git a/build_scripts/Windows-msys2/installer/lang/ts/de.ts b/build_scripts/Windows-msys2/installer/lang/ts/de.ts new file mode 100644 index 000000000..4469c6818 --- /dev/null +++ b/build_scripts/Windows-msys2/installer/lang/ts/de.ts @@ -0,0 +1,205 @@ + + + Section_Main + + ${APPNAME} + ${APPNAME} + + + + Section_Main_Desc + + Installs ${APPNAME} and required components. + Installiert ${APPNAME} und die benötigten Komponenten. + + + + Section_Data + + Skins + Skins + + + + Section_Data_Desc + + Installs skins. + Skins installieren. + + + + Section_Shortcuts + + Shortcut icons + Verknüpfungssymbole + + + + Section_Shortcuts_Desc + + Adds shortcut icons. + Verküpfungssymbole hinzufügen. + + + + Section_StartMenu + + Start Menu icon + Startmenüsymbol + + + + Section_StartMenu_Desc + + Adds icon to start menu. + Fügt Symbol zum Startmenü hinzu. + + + + Section_Desktop + + Desktop icon + Desktopsymbol + + + + Section_Desktop_Desc + + Adds icon to desktop. + Fügt Symbol zum Desktop hinzu. + + + + Section_QuickLaunch + + Quick Launch icon + Schnellstartsymbol + + + + Section_QuickLaunch_Desc + + Adds icon to Quick Launch toolbar. + Fügt Symbol zur Schnellstartleiste hinzu. + + + + Section_Plugins + + Optional plugins + Optionale Plug-ins + + + + Section_Plugins_Desc + + Optional plugins to extend functionality. + Optionale Plug-ins zum Erweitern der Funktionalität. + + + + Section_Plugin_FeedReader + + FeedReader + FeedReader + + + + Section_Plugin_FeedReader_Desc + + Installs plugin FeedReader. + Installiert das Plug-in Feedreader. + + + + Section_Plugin_LinksCloud + + LinksCloud + Verknüpfungswolke + + + + Section_Plugin_LinksCloud_Desc + + Installs plugin LinksCloud. + Installiert das Plug-in Verknüpfungswolke. + + + + Section_Plugin_VOIP + + VOIP + VOIP + + + + Section_Plugin_VOIP_Desc + + Installs plugin VOIP. + Installiert das Plug-in VOIP + + + + Section_AutoStart + + Auto Startup + Automatischer Programmstart + + + + Section_AutoStart_Desc + + Auto-Run at startup. + Beim Start automatisch ausführen. + + + + Page_InstallMode + + Installation Mode + Installationsmodus + + + + Page_InstallMode_Desc + + Choose how you want to install ${APPNAME}. + Wähle wie du ${APPNAME} installieren willst. + + + + Page_InstallMode_Standard + + &Standard installation + &Standardinstallation + + + + Page_InstallMode_Standard_Desc + + Install ${APPNAME} for the current user of this machine. + Installiere ${APPNAME} für den derzeitigen Benutzer dieses Geräts. + + + + Page_InstallMode_Portable + + &Portable installation + &Portable Installation + + + + Page_InstallMode_Portable_Desc + + In portable mode all configuration data is stored in the application folder and no information is written to the registry. + Im portablen Modus werden alle Konfigurationsdaten im Verzeichnis der Anwendung gespeichert und keine Informationen in der Registry abgelegt. + + + + Link_Uninstall + + Uninstall + Deinstallieren + + + \ No newline at end of file diff --git a/build_scripts/Windows-msys2/installer/lang/ts/en.ts b/build_scripts/Windows-msys2/installer/lang/ts/en.ts new file mode 100644 index 000000000..800157426 --- /dev/null +++ b/build_scripts/Windows-msys2/installer/lang/ts/en.ts @@ -0,0 +1,186 @@ + + + + + Section_Main_Desc + + Installs ${APPNAME} and required components. + + + + + Section_Data + + Skins + + + + + Section_Data_Desc + + Installs skins. + + + + + Section_Shortcuts + + Shortcut icons + + + + + Section_Shortcuts_Desc + + Adds shortcut icons. + + + + + Section_StartMenu + + Start Menu icon + + + + + Section_StartMenu_Desc + + Adds icon to start menu. + + + + + Section_Desktop + + Desktop icon + + + + + Section_Desktop_Desc + + Adds icon to desktop. + + + + + Section_QuickLaunch + + Quick Launch icon + + + + + Section_QuickLaunch_Desc + + Adds icon to Quick Launch toolbar. + + + + + Section_Plugins + + Optional plugins + + + + + Section_Plugins_Desc + + Optional plugins to extend functionality. + + + + + Section_Plugin_FeedReader + + FeedReader + + + + + Section_Plugin_FeedReader_Desc + + Installs plugin FeedReader. + + + + + Section_Plugin_VOIP + + VOIP + + + + + Section_Plugin_VOIP_Desc + + Installs plugin VOIP. + + + + + Section_AutoStart + + Auto Startup + + + + + Section_AutoStart_Desc + + Auto-Run at startup. + + + + + Page_InstallMode + + Installation Mode + + + + + Page_InstallMode_Desc + + Choose how you want to install ${APPNAME}. + + + + + Page_InstallMode_Standard + + &Standard installation + + + + + Page_InstallMode_Standard_Desc + + Install ${APPNAME} for the current user of this machine. + + + + + Page_InstallMode_Portable + + &Portable installation + + + + + Page_InstallMode_Portable_Desc + + In portable mode all configuration data is stored in the application folder and no information is written to the registry. + + + + + Link_Uninstall + + Uninstall + + + + diff --git a/build_scripts/Windows-msys2/installer/lang/ts/es.ts b/build_scripts/Windows-msys2/installer/lang/ts/es.ts new file mode 100644 index 000000000..dab920294 --- /dev/null +++ b/build_scripts/Windows-msys2/installer/lang/ts/es.ts @@ -0,0 +1,205 @@ + + + Section_Main + + ${APPNAME} + ${APPNAME} + + + + Section_Main_Desc + + Installs ${APPNAME} and required components. + Instala ${APPNAME} y los componentes requeridos. + + + + Section_Data + + Skins + Coberturas (skins) + + + + Section_Data_Desc + + Installs skins. + Instalar coberturas + + + + Section_Shortcuts + + Shortcut icons + Iconos de accesos directos + + + + Section_Shortcuts_Desc + + Adds shortcut icons. + Añade iconos de accesos directos. + + + + Section_StartMenu + + Start Menu icon + Icono de menú de inicio + + + + Section_StartMenu_Desc + + Adds icon to start menu. + Añade icono al menú de inicio. + + + + Section_Desktop + + Desktop icon + Icono del escritorio + + + + Section_Desktop_Desc + + Adds icon to desktop. + Añade icono al escritorio + + + + Section_QuickLaunch + + Quick Launch icon + Icono de inicio rápido + + + + Section_QuickLaunch_Desc + + Adds icon to Quick Launch toolbar. + Añade icono a la Barra de Inicio Rápido + + + + Section_Plugins + + Optional plugins + Complementos opcionales + + + + Section_Plugins_Desc + + Optional plugins to extend functionality. + Complementos opcionales para expandir la funcionalidad. + + + + Section_Plugin_FeedReader + + FeedReader + FeedReader + + + + Section_Plugin_FeedReader_Desc + + Installs plugin FeedReader. + Instala el complemento FeedReader. + + + + Section_Plugin_LinksCloud + + LinksCloud + LinksCloud + + + + Section_Plugin_LinksCloud_Desc + + Installs plugin LinksCloud. + Instala el complemento LinksCloud. + + + + Section_Plugin_VOIP + + VOIP + VOIP + + + + Section_Plugin_VOIP_Desc + + Installs plugin VOIP. + Instala el complemento VOIP + + + + Section_AutoStart + + Auto Startup + Auto iniciar + + + + Section_AutoStart_Desc + + Auto-Run at startup. + Auto-ejecutar al incio. + + + + Page_InstallMode + + Installation Mode + Modo de instalación + + + + Page_InstallMode_Desc + + Choose how you want to install ${APPNAME}. + Elija cómo quiere instalar ${APPNAME}. + + + + Page_InstallMode_Standard + + &Standard installation + Instalación &Estándar + + + + Page_InstallMode_Standard_Desc + + Install ${APPNAME} for the current user of this machine. + Instalar ${APPNAME} para el usuario actual de esta máquina. + + + + Page_InstallMode_Portable + + &Portable installation + Instalación &Portable + + + + Page_InstallMode_Portable_Desc + + In portable mode all configuration data is stored in the application folder and no information is written to the registry. + En modo portable, todos los datos de configuración se almacenan en la carpeta de la aplicación y no se escribe ninguna información en el registro. + + + + Link_Uninstall + + Uninstall + Desinstalar + + + \ No newline at end of file diff --git a/build_scripts/Windows-msys2/installer/lang/ts/fr.ts b/build_scripts/Windows-msys2/installer/lang/ts/fr.ts new file mode 100644 index 000000000..6ba710f7d --- /dev/null +++ b/build_scripts/Windows-msys2/installer/lang/ts/fr.ts @@ -0,0 +1,205 @@ + + + Section_Main + + ${APPNAME} + ${APPNAME} + + + + Section_Main_Desc + + Installs ${APPNAME} and required components. + Installe ${APPNAME} et les composants requis. + + + + Section_Data + + Skins + Habillages + + + + Section_Data_Desc + + Installs skins. + Installe des habillages. + + + + Section_Shortcuts + + Shortcut icons + Icônes de raccourci + + + + Section_Shortcuts_Desc + + Adds shortcut icons. + Ajoute les icônes de raccourci. + + + + Section_StartMenu + + Start Menu icon + Icône de menu démarrage + + + + Section_StartMenu_Desc + + Adds icon to start menu. + Ajoute l'icône au menu démarrer. + + + + Section_Desktop + + Desktop icon + Icônes de bureau + + + + Section_Desktop_Desc + + Adds icon to desktop. + Ajoute l'icône sur le bureau. + + + + Section_QuickLaunch + + Quick Launch icon + Icône de lancement rapide + + + + Section_QuickLaunch_Desc + + Adds icon to Quick Launch toolbar. + Ajoute une icône à la barre d'outils de lancement rapide. + + + + Section_Plugins + + Optional plugins + Plug-ins optionnels + + + + Section_Plugins_Desc + + Optional plugins to extend functionality. + Plug-ins optionnels destinés à étendre les fonctionnalités. + + + + Section_Plugin_FeedReader + + FeedReader + FeedReader + + + + Section_Plugin_FeedReader_Desc + + Installs plugin FeedReader. + Installe le plug-in FeedReader. + + + + Section_Plugin_LinksCloud + + LinksCloud + LinksCloud + + + + Section_Plugin_LinksCloud_Desc + + Installs plugin LinksCloud. + Installe le plug-in LinksCloud. + + + + Section_Plugin_VOIP + + VOIP + VOIP + + + + Section_Plugin_VOIP_Desc + + Installs plugin VOIP. + Installe le plug-in VOIP. + + + + Section_AutoStart + + Auto Startup + Démarrage automatique + + + + Section_AutoStart_Desc + + Auto-Run at startup. + Démarrage automatique au démarrage. + + + + Page_InstallMode + + Installation Mode + Mode d'installation + + + + Page_InstallMode_Desc + + Choose how you want to install ${APPNAME}. + Choisissez comment vous voulez installer ${APPNAME}. + + + + Page_InstallMode_Standard + + &Standard installation + &Installation standard + + + + Page_InstallMode_Standard_Desc + + Install ${APPNAME} for the current user of this machine. + Installer ${APPNAME} pour l'utilisateur actuel de cette machine. + + + + Page_InstallMode_Portable + + &Portable installation + &Installation portable + + + + Page_InstallMode_Portable_Desc + + In portable mode all configuration data is stored in the application folder and no information is written to the registry. + En mode portable toutes les données de configuration sont stockées dans le dossier de l'application et aucune information n'est écrite dans la base de registre. + + + + Link_Uninstall + + Uninstall + Désinstaller + + + \ No newline at end of file diff --git a/build_scripts/Windows-msys2/installer/lang/ts/pl.ts b/build_scripts/Windows-msys2/installer/lang/ts/pl.ts new file mode 100644 index 000000000..deb56164f --- /dev/null +++ b/build_scripts/Windows-msys2/installer/lang/ts/pl.ts @@ -0,0 +1,205 @@ + + + Section_Main + + ${APPNAME} + ${APPNAME} + + + + Section_Main_Desc + + Installs ${APPNAME} and required components. + Instaluje ${APPNAME} oraz wymagane komponenty. + + + + Section_Data + + Skins + Skórki + + + + Section_Data_Desc + + Installs skins. + Instaluje skórki. + + + + Section_Shortcuts + + Shortcut icons + Ikony skrótów + + + + Section_Shortcuts_Desc + + Adds shortcut icons. + Dodaje skróty ikon. + + + + Section_StartMenu + + Start Menu icon + + + + + Section_StartMenu_Desc + + Adds icon to start menu. + Dodaje ikonę do menu start. + + + + Section_Desktop + + Desktop icon + Ikona na pulpicie + + + + Section_Desktop_Desc + + Adds icon to desktop. + Dodawanie ikony na pulpicie + + + + Section_QuickLaunch + + Quick Launch icon + Ikona szybkiego uruchamiania + + + + Section_QuickLaunch_Desc + + Adds icon to Quick Launch toolbar. + Dodaje ikonę do paska Szybkiego Uruchamiania. + + + + Section_Plugins + + Optional plugins + Wtyczki opcjonalne + + + + Section_Plugins_Desc + + Optional plugins to extend functionality. + Wtyczki opcjonalne rozszerzające funkcjonalność. + + + + Section_Plugin_FeedReader + + FeedReader + FeedReader + + + + Section_Plugin_FeedReader_Desc + + Installs plugin FeedReader. + Instaluje wtyczki FeedReader + + + + Section_Plugin_LinksCloud + + LinksCloud + + + + + Section_Plugin_LinksCloud_Desc + + Installs plugin LinksCloud. + Instaluje wtyczki LinksCloud. + + + + Section_Plugin_VOIP + + VOIP + VOIP + + + + Section_Plugin_VOIP_Desc + + Installs plugin VOIP. + Instaluje wtyczki VOIP. + + + + Section_AutoStart + + Auto Startup + + + + + Section_AutoStart_Desc + + Auto-Run at startup. + Automatyczne uruchamianie przy starcie. + + + + Page_InstallMode + + Installation Mode + Tryb instalacji + + + + Page_InstallMode_Desc + + Choose how you want to install ${APPNAME}. + Wybierz jak chcesz zainstalować ${APPNAME}. + + + + Page_InstallMode_Standard + + &Standard installation + &Standardowa instalacja + + + + Page_InstallMode_Standard_Desc + + Install ${APPNAME} for the current user of this machine. + Zainstaluj ${APPNAME} dla bieżącego użytkownika tej maszyny. + + + + Page_InstallMode_Portable + + &Portable installation + + + + + Page_InstallMode_Portable_Desc + + In portable mode all configuration data is stored in the application folder and no information is written to the registry. + W trybie przenośnym wszystkie dane konfiguracyjne są przechowywane w folderze aplikacji i nie są zapisywane w rejestrze. + + + + Link_Uninstall + + Uninstall + Odinstaluj + + + \ No newline at end of file diff --git a/build_scripts/Windows-msys2/installer/lang/ts/ru.ts b/build_scripts/Windows-msys2/installer/lang/ts/ru.ts new file mode 100644 index 000000000..3c29f3955 --- /dev/null +++ b/build_scripts/Windows-msys2/installer/lang/ts/ru.ts @@ -0,0 +1,205 @@ + + + Section_Main + + ${APPNAME} + ${APPNAME} + + + + Section_Main_Desc + + Installs ${APPNAME} and required components. + Установка ${APPNAME} и необходимых компонентов. + + + + Section_Data + + Skins + Оболочки + + + + Section_Data_Desc + + Installs skins. + Установка оболочек. + + + + Section_Shortcuts + + Shortcut icons + Ярлыки + + + + Section_Shortcuts_Desc + + Adds shortcut icons. + Добавление ярлыков. + + + + Section_StartMenu + + Start Menu icon + Ярлык в меню Пуск + + + + Section_StartMenu_Desc + + Adds icon to start menu. + Добавление ярлыка в меню Пуск. + + + + Section_Desktop + + Desktop icon + Ярлык на рабочем столе + + + + Section_Desktop_Desc + + Adds icon to desktop. + Добавление ярлыка на рабочий стол. + + + + Section_QuickLaunch + + Quick Launch icon + Ярлык в панели быстрого запуска + + + + Section_QuickLaunch_Desc + + Adds icon to Quick Launch toolbar. + Добавление ярлыка на панель быстрого запуска. + + + + Section_Plugins + + Optional plugins + Дополнительные плагины + + + + Section_Plugins_Desc + + Optional plugins to extend functionality. + Дополнительные плагины для расширения функциональности. + + + + Section_Plugin_FeedReader + + FeedReader + FeedReader – RSS-агрегатор + + + + Section_Plugin_FeedReader_Desc + + Installs plugin FeedReader. + Установка плагина FeedReader. + + + + Section_Plugin_LinksCloud + + LinksCloud + LinksCloud – Облако ссылок + + + + Section_Plugin_LinksCloud_Desc + + Installs plugin LinksCloud. + Установка плагина LinksCloud. + + + + Section_Plugin_VOIP + + VOIP + VoIP + + + + Section_Plugin_VOIP_Desc + + Installs plugin VOIP. + Установка плагина VoIP. + + + + Section_AutoStart + + Auto Startup + Автозапуск + + + + Section_AutoStart_Desc + + Auto-Run at startup. + Автозапуск при загрузке системы. + + + + Page_InstallMode + + Installation Mode + Режим установки + + + + Page_InstallMode_Desc + + Choose how you want to install ${APPNAME}. + Выберите метод установки ${APPNAME}. + + + + Page_InstallMode_Standard + + &Standard installation + Стандартная установка + + + + Page_InstallMode_Standard_Desc + + Install ${APPNAME} for the current user of this machine. + Установка ${APPNAME} для текущего пользователя компьютера. + + + + Page_InstallMode_Portable + + &Portable installation + Портативная установка + + + + Page_InstallMode_Portable_Desc + + In portable mode all configuration data is stored in the application folder and no information is written to the registry. + В режиме портативной установки все конфигурационные файлы сохраняются в папку приложения и в системный реестр не записывается никакой информации. + + + + Link_Uninstall + + Uninstall + Удаление программы + + + \ No newline at end of file diff --git a/build_scripts/Windows-msys2/installer/lang/ts/tr.ts b/build_scripts/Windows-msys2/installer/lang/ts/tr.ts new file mode 100644 index 000000000..d67961d59 --- /dev/null +++ b/build_scripts/Windows-msys2/installer/lang/ts/tr.ts @@ -0,0 +1,205 @@ + + + Section_Main + + ${APPNAME} + ${APPNAME} + + + + Section_Main_Desc + + Installs ${APPNAME} and required components. + ${APPNAME} ve gerekli bileşenleri kurar. + + + + Section_Data + + Skins + Temalar + + + + Section_Data_Desc + + Installs skins. + Tema yükleyin. + + + + Section_Shortcuts + + Shortcut icons + Kısayol simgeleri + + + + Section_Shortcuts_Desc + + Adds shortcut icons. + Kısayol simgesi ekleyin. + + + + Section_StartMenu + + Start Menu icon + Başlat Menüsü simgesi + + + + Section_StartMenu_Desc + + Adds icon to start menu. + Başlat menüsüne simge ekleyin. + + + + Section_Desktop + + Desktop icon + Masaüstü simgesi + + + + Section_Desktop_Desc + + Adds icon to desktop. + Masaüstüne simge ekleyin. + + + + Section_QuickLaunch + + Quick Launch icon + Hızlı Başlat simgesi + + + + Section_QuickLaunch_Desc + + Adds icon to Quick Launch toolbar. + Hızlı Başlat araç çubuğuna simge ekleyin. + + + + Section_Plugins + + Optional plugins + İsteğe bağlı eklentiler + + + + Section_Plugins_Desc + + Optional plugins to extend functionality. + İşlevselliği artırmak için isteğe bağlı eklentiler. + + + + Section_Plugin_FeedReader + + FeedReader + AkışOkuyucu + + + + Section_Plugin_FeedReader_Desc + + Installs plugin FeedReader. + AkışOkuyucu eklentisini yükleyin. + + + + Section_Plugin_LinksCloud + + LinksCloud + BağlantıBulutu + + + + Section_Plugin_LinksCloud_Desc + + Installs plugin LinksCloud. + BağlantıBulutu eklentisini yükleyin. + + + + Section_Plugin_VOIP + + VOIP + VOIP + + + + Section_Plugin_VOIP_Desc + + Installs plugin VOIP. + VOIP eklentisini yükleyin. + + + + Section_AutoStart + + Auto Startup + Otomatik Başlat + + + + Section_AutoStart_Desc + + Auto-Run at startup. + Açılışta otomatik başlatın. + + + + Page_InstallMode + + Installation Mode + Kurulum Yöntemi + + + + Page_InstallMode_Desc + + Choose how you want to install ${APPNAME}. + ${APPNAME} kurulum şeklini seçin + + + + Page_InstallMode_Standard + + &Standard installation + &Normal kurulum + + + + Page_InstallMode_Standard_Desc + + Install ${APPNAME} for the current user of this machine. + ${APPNAME} yalnızca şimdiki kullanıcı için kurulsun. + + + + Page_InstallMode_Portable + + &Portable installation + &Taşınabilir kurulum + + + + Page_InstallMode_Portable_Desc + + In portable mode all configuration data is stored in the application folder and no information is written to the registry. + Taşınabilir kipte tüm ayarlar uygulama klasörüne depolanır ve kayıt defterine hiçbir bilgi yazılmaz. + + + + Link_Uninstall + + Uninstall + Kaldırın + + + \ No newline at end of file diff --git a/build_scripts/Windows-msys2/installer/lang/ts/xsltproc.exe b/build_scripts/Windows-msys2/installer/lang/ts/xsltproc.exe new file mode 100644 index 000000000..79c250892 Binary files /dev/null and b/build_scripts/Windows-msys2/installer/lang/ts/xsltproc.exe differ diff --git a/build_scripts/Windows-msys2/installer/lang/ts/zh_CN.ts b/build_scripts/Windows-msys2/installer/lang/ts/zh_CN.ts new file mode 100644 index 000000000..30c992601 --- /dev/null +++ b/build_scripts/Windows-msys2/installer/lang/ts/zh_CN.ts @@ -0,0 +1,205 @@ + + + Section_Main + + ${APPNAME} + + + + + Section_Main_Desc + + Installs ${APPNAME} and required components. + + + + + Section_Data + + Skins + 皮肤 + + + + Section_Data_Desc + + Installs skins. + 安装皮肤 + + + + Section_Shortcuts + + Shortcut icons + 快捷方式图标 + + + + Section_Shortcuts_Desc + + Adds shortcut icons. + 添加快捷方式图标 + + + + Section_StartMenu + + Start Menu icon + 开始菜单图标 + + + + Section_StartMenu_Desc + + Adds icon to start menu. + 添加图标至开始菜单 + + + + Section_Desktop + + Desktop icon + 桌面图标 + + + + Section_Desktop_Desc + + Adds icon to desktop. + 添加图标至桌面 + + + + Section_QuickLaunch + + Quick Launch icon + 快速启动栏图标 + + + + Section_QuickLaunch_Desc + + Adds icon to Quick Launch toolbar. + 添加图标至快速启动栏 + + + + Section_Plugins + + Optional plugins + + + + + Section_Plugins_Desc + + Optional plugins to extend functionality. + + + + + Section_Plugin_FeedReader + + FeedReader + RSS订阅 + + + + Section_Plugin_FeedReader_Desc + + Installs plugin FeedReader. + 安装RSS订阅插件 + + + + Section_Plugin_LinksCloud + + LinksCloud + LinksCloud + + + + Section_Plugin_LinksCloud_Desc + + Installs plugin LinksCloud. + 安装插件LinksCloud + + + + Section_Plugin_VOIP + + VOIP + 语音 + + + + Section_Plugin_VOIP_Desc + + Installs plugin VOIP. + 安装语音插件 + + + + Section_AutoStart + + Auto Startup + + + + + Section_AutoStart_Desc + + Auto-Run at startup. + + + + + Page_InstallMode + + Installation Mode + 安装模式 + + + + Page_InstallMode_Desc + + Choose how you want to install ${APPNAME}. + + + + + Page_InstallMode_Standard + + &Standard installation + + + + + Page_InstallMode_Standard_Desc + + Install ${APPNAME} for the current user of this machine. + + + + + Page_InstallMode_Portable + + &Portable installation + + + + + Page_InstallMode_Portable_Desc + + In portable mode all configuration data is stored in the application folder and no information is written to the registry. + + + + + Link_Uninstall + + Uninstall + 卸载 + + + \ No newline at end of file diff --git a/build_scripts/Windows-msys2/installer/lang/zh_CN.nsh b/build_scripts/Windows-msys2/installer/lang/zh_CN.nsh new file mode 100644 index 000000000..1075f7a1a --- /dev/null +++ b/build_scripts/Windows-msys2/installer/lang/zh_CN.nsh @@ -0,0 +1,29 @@ +!insertmacro LANG_STRING Section_Main "${APPNAME}" +!insertmacro LANG_STRING Section_Main_Desc "Installs ${APPNAME} and required components." +!insertmacro LANG_STRING Section_Data "皮肤" +!insertmacro LANG_STRING Section_Data_Desc "安装皮肤" +!insertmacro LANG_STRING Section_Shortcuts "快捷方式图标" +!insertmacro LANG_STRING Section_Shortcuts_Desc "添加快捷方式图标" +!insertmacro LANG_STRING Section_StartMenu "开始菜单图标" +!insertmacro LANG_STRING Section_StartMenu_Desc "添加图标至开始菜单" +!insertmacro LANG_STRING Section_Desktop "桌面图标" +!insertmacro LANG_STRING Section_Desktop_Desc "添加图标至桌面" +!insertmacro LANG_STRING Section_QuickLaunch "快速启动栏图标" +!insertmacro LANG_STRING Section_QuickLaunch_Desc "添加图标至快速启动栏" +!insertmacro LANG_STRING Section_Plugins "Optional plugins" +!insertmacro LANG_STRING Section_Plugins_Desc "Optional plugins to extend functionality." +!insertmacro LANG_STRING Section_Plugin_FeedReader "RSS订阅" +!insertmacro LANG_STRING Section_Plugin_FeedReader_Desc "安装RSS订阅插件" +!insertmacro LANG_STRING Section_Plugin_LinksCloud "LinksCloud" +!insertmacro LANG_STRING Section_Plugin_LinksCloud_Desc "安装插件LinksCloud" +!insertmacro LANG_STRING Section_Plugin_VOIP "语音" +!insertmacro LANG_STRING Section_Plugin_VOIP_Desc "安装语音插件" +!insertmacro LANG_STRING Section_AutoStart "Auto Startup" +!insertmacro LANG_STRING Section_AutoStart_Desc "Auto-Run at startup." +!insertmacro LANG_STRING Page_InstallMode "安装模式" +!insertmacro LANG_STRING Page_InstallMode_Desc "Choose how you want to install ${APPNAME}." +!insertmacro LANG_STRING Page_InstallMode_Standard "&Standard installation" +!insertmacro LANG_STRING Page_InstallMode_Standard_Desc "Install ${APPNAME} for the current user of this machine." +!insertmacro LANG_STRING Page_InstallMode_Portable "&Portable installation" +!insertmacro LANG_STRING Page_InstallMode_Portable_Desc "In portable mode all configuration data is stored in the application folder and no information is written to the registry." +!insertmacro LANG_STRING Link_Uninstall "卸载" diff --git a/build_scripts/Windows/installer/retroshare-Qt4.nsi b/build_scripts/Windows-msys2/installer/retroshare-Qt5.nsi similarity index 79% rename from build_scripts/Windows/installer/retroshare-Qt4.nsi rename to build_scripts/Windows-msys2/installer/retroshare-Qt5.nsi index cb6f69c74..b30300634 100644 --- a/build_scripts/Windows/installer/retroshare-Qt4.nsi +++ b/build_scripts/Windows-msys2/installer/retroshare-Qt5.nsi @@ -1,481 +1,445 @@ -; Script generated with the Venis Install Wizard & modified by defnax -; Reworked by Thunder - -!include ifexist.nsh - -# Needed defines -;!define REVISION "" -;!define RELEASEDIR "" -;!define QTDIR "" -;!define MINGWDIR "" - -# Optional defines -;!define OUTDIR "" - -# Check needed defines -!ifndef RELEASEDIR -!error "RELEASEDIR is not defined" -!endif -!ifndef QTDIR -!error "QTDIR is not defined" -!endif -!ifndef MINGWDIR -!error "MINGWDIR is not defined" -!endif - -# Check optional defines -!ifdef OUTDIR -!define OUTDIR_ "${OUTDIR}\" -!else -!define OUTDIR "" -!define OUTDIR_ "" -!endif - -!ifndef INSTALLERADD -!define INSTALLERADD "" -!endif - -# Source directory -!define SOURCEDIR "..\..\.." - -# Get version from executable -!GetDllVersion "${RELEASEDIR}\retroshare-gui\src\release\retroshare.exe" VERSION_ -!define VERSION ${VERSION_1}.${VERSION_2}.${VERSION_3} -;!define REVISION ${VERSION_4} - -# Get version of Qt -!GetDllVersion "${QTDIR}\bin\QtCore4.dll" QTVERSION_ -!define QTVERSION ${QTVERSION_1}.${QTVERSION_2}.${QTVERSION_3} - -# Check version -!ifndef REVISION -!error "REVISION is not defined" -!endif - -# Date -!define /date Date "%Y%m%d" - -# Application name and version -!define APPNAME "RetroShare" -!define APPNAMEANDVERSION "${APPNAME} ${VERSION}" -!define PUBLISHER "RetroShare Team" - -# Install path -!define INSTDIR_NORMAL "$ProgramFiles\${APPNAME}" -!define INSTDIR_PORTABLE "$Desktop\${APPNAME}" - -!define DATADIR_NORMAL "$APPDATA\${APPNAME}" -!define DATADIR_PORTABLE "$INSTDIR\Data" - -# Main Install settings -Name "${APPNAMEANDVERSION}" -InstallDirRegKey HKLM "Software\${APPNAME}" "" -OutFile "${OUTDIR_}RetroShare-${VERSION}-${Date}-${REVISION}-Qt-${QTVERSION}${INSTALLERADD}-setup.exe" -BrandingText "${APPNAMEANDVERSION}" -RequestExecutionlevel highest -# Use compression -SetCompressor /SOLID LZMA - -# Global variables -Var PortableMode -Var InstDirNormal -Var InstDirPortable -Var DataDir -Var StyleSheetDir - -# Modern interface settings -!include Sections.nsh -!include nsDialogs.nsh -!include "MUI.nsh" - -# Interface Settings -!define MUI_ABORTWARNING -!define MUI_HEADERIMAGE -!define MUI_HEADERIMAGE_BITMAP "${SOURCEDIR}\build_scripts\Windows\installer\HeaderImage.bmp" -;!define MUI_WELCOMEFINISHPAGE_BITMAP "...bmp" - -# MUI defines -!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\orange-install.ico" -!define MUI_FINISHPAGE_NOAUTOCLOSE -!define MUI_LICENSEPAGE_RADIOBUTTONS -!define MUI_COMPONENTSPAGE_SMALLDESC -!define MUI_FINISHPAGE_LINK "Visit the RetroShare forum for the latest news and support" -!define MUI_FINISHPAGE_LINK_LOCATION "http://retroshare.sourceforge.net/forum/" -!define MUI_FINISHPAGE_RUN "$INSTDIR\retroshare.exe" -!define MUI_FINISHPAGE_SHOWREADME $INSTDIR\changelog.txt -!define MUI_FINISHPAGE_SHOWREADME_TEXT changelog.txt -!define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED -!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\orange-uninstall.ico" -!define MUI_UNFINISHPAGE_NOAUTOCLOSE -;!define MUI_LANGDLL_REGISTRY_ROOT HKLM -;!define MUI_LANGDLL_REGISTRY_KEY ${REGKEY} -;!define MUI_LANGDLL_REGISTRY_VALUENAME InstallerLanguage - -# Defines the un-/installer logo of RetroShare -!insertmacro MUI_DEFAULT MUI_WELCOMEFINISHPAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Wizard\orange.bmp" -!insertmacro MUI_DEFAULT MUI_UNWELCOMEFINISHPAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Wizard\orange-uninstall.bmp" - -# Installer pages -!insertmacro MUI_PAGE_WELCOME -!insertmacro MUI_PAGE_LICENSE "$(myLicenseData)" -Page Custom PortableModePageCreate PortableModePageLeave -!define MUI_PAGE_CUSTOMFUNCTION_LEAVE dir_leave -!insertmacro MUI_PAGE_DIRECTORY -!insertmacro MUI_PAGE_COMPONENTS -!insertmacro MUI_PAGE_INSTFILES -!insertmacro MUI_PAGE_FINISH -!insertmacro MUI_UNPAGE_CONFIRM -!insertmacro MUI_UNPAGE_INSTFILES - -# Set languages (first is default language) -!insertmacro MUI_RESERVEFILE_LANGDLL - -# Installer languages -!define MUI_LANGDLL_ALLLANGUAGES - -# Translations -!macro LANG_LOAD LANGUAGE LANGCODE LANGID LICENCEFILE - !insertmacro MUI_LANGUAGE "${LANGUAGE}" -; !verbose off - !define LANG "${LANGUAGE}" - !include "lang\${LANGCODE}.nsh" - LangString LANGUAGEID "${LANG_${LANG}}" "1031" - LicenseLangString myLicenseData ${LANGCODE} ${LICENCEFILE} -; !verbose on - !undef LANG -!macroend - -!macro LANG_STRING NAME VALUE - LangString "${NAME}" "${LANG_${LANG}}" "${VALUE}" -!macroend - -!insertmacro LANG_LOAD "English" "en" "1033" "${SOURCEDIR}\retroshare-gui\src\license\license.txt" -!insertmacro LANG_LOAD "French" "fr" "1036" "${SOURCEDIR}\retroshare-gui\src\license\license-FR.txt" -!insertmacro LANG_LOAD "German" "de" "1031" "${SOURCEDIR}\retroshare-gui\src\license\license-GER.txt" -!insertmacro LANG_LOAD "Turkish" "tr" "1055" "${SOURCEDIR}\retroshare-gui\src\license\license-TR.txt" -!insertmacro LANG_LOAD "SimpChinese" "zh_CN" "2052" "${SOURCEDIR}\retroshare-gui\src\license\license.txt" -!insertmacro LANG_LOAD "Polish" "pl" "1045" "${SOURCEDIR}\retroshare-gui\src\license\license.txt" -!insertmacro LANG_LOAD "Spanish" "es" "1034" "${SOURCEDIR}\retroshare-gui\src\license\license.txt" -!insertmacro LANG_LOAD "Russian" "ru" "1049" "${SOURCEDIR}\retroshare-gui\src\license\license.txt" -!insertmacro LANG_LOAD "Catalan" "ca_ES" "1027" "${SOURCEDIR}\retroshare-gui\src\license\license.txt" - -LicenseData $(myLicenseData) - -# Main binaries -Section $(Section_Main) Section_Main - ;Set Section required - SectionIn RO - - ; Set Section properties - SetOverwrite on - - ; Clears previous error logs -; Delete "$INSTDIR\*.log" - - ; Main binaries - SetOutPath "$INSTDIR" - File /oname=retroshare.exe "${RELEASEDIR}\retroshare-gui\src\release\retroshare.exe" - File /oname=retroshare-nogui.exe "${RELEASEDIR}\retroshare-nogui\src\release\retroshare-nogui.exe" - - ; Qt binaries - File "${QTDIR}\bin\QtCore4.dll" - File "${QTDIR}\bin\QtGui4.dll" - File "${QTDIR}\bin\QtMultimedia4.dll" - File "${QTDIR}\bin\QtNetwork4.dll" - File "${QTDIR}\bin\QtSvg4.dll" - File "${QTDIR}\bin\QtXml4.dll" - - ; MinGW binaries - File "${MINGWDIR}\bin\libstdc++-6.dll" - File "${MINGWDIR}\bin\libgcc_s_dw2-1.dll" - File "${MINGWDIR}\bin\libwinpthread-1.dll" - - ; External binaries - File "${EXTERNAL_LIB_DIR}\bin\miniupnpc.dll" - File "${EXTERNAL_LIB_DIR}\bin\libeay32.dll" - File "${EXTERNAL_LIB_DIR}\bin\ssleay32.dll" - - ; Other files - File "${SOURCEDIR}\retroshare-gui\src\changelog.txt" - File "${SOURCEDIR}\libbitdht\src\bitdht\bdboot.txt" - - ; Image formats - SetOutPath "$INSTDIR\imageformats" - File /r "${QTDIR}\plugins\imageformats\qgif4.dll" - File /r "${QTDIR}\plugins\imageformats\qico4.dll" - File /r "${QTDIR}\plugins\imageformats\qjpeg4.dll" - File /r "${QTDIR}\plugins\imageformats\qmng4.dll" - File /r "${QTDIR}\plugins\imageformats\qsvg4.dll" - File /r "${QTDIR}\plugins\imageformats\qtga4.dll" - File /r "${QTDIR}\plugins\imageformats\qtiff4.dll" - - ; Sounds - SetOutPath "$INSTDIR\sounds" - File /r "${SOURCEDIR}\retroshare-gui\src\sounds\*.*" - - ; Translations - SetOutPath "$INSTDIR\translations" - File /r "${SOURCEDIR}\retroshare-gui\src\translations\*.qm" - File /r "${QTDIR}\translations\qt_*.qm" - - ; WebUI - SetOutPath "$INSTDIR\webui" - File /r "${SOURCEDIR}\libresapi\src\webui\*.*" - - ; License - SetOutPath "$INSTDIR\license" - File /r "${SOURCEDIR}\retroshare-gui\src\license\*.*" -SectionEnd - -# Plugins -${!defineifexist} PLUGIN_FEEDREADER_EXISTS "${RELEASEDIR}\plugins\FeedReader\release\FeedReader.dll" -${!defineifexist} PLUGIN_VOIP_EXISTS "${RELEASEDIR}\plugins\VOIP\release\VOIP.dll" - -!ifdef PLUGIN_FEEDREADER_EXISTS -!define /ifndef PLUGIN_EXISTS -!endif -!ifdef PLUGIN_VOIP_EXISTS -!define /ifndef PLUGIN_EXISTS -!endif - -!ifdef PLUGIN_EXISTS - SectionGroup $(Section_Plugins) Section_Plugins - !ifdef PLUGIN_FEEDREADER_EXISTS - Section $(Section_Plugin_FeedReader) Section_Plugin_FeedReader - SetOutPath "$DataDir\extensions6" - File "${RELEASEDIR}\plugins\FeedReader\release\FeedReader.dll" - SectionEnd - !endif - - !ifdef PLUGIN_VOIP_EXISTS - Section $(Section_Plugin_VOIP) Section_Plugin_VOIP - SetOutPath "$DataDir\extensions6" - File "${RELEASEDIR}\plugins\VOIP\release\VOIP.dll" - SectionEnd - !endif - SectionGroupEnd -!endif - -# Data (Styles) -Section $(Section_Data) Section_Data - ; Set Section properties - SetOverwrite on - - ; Chat style - SetOutPath "$StyleSheetDir\stylesheets\Bubble" - File /r "${SOURCEDIR}\retroshare-gui\src\gui\qss\chat\Bubble\*.*" - SetOutPath "$StyleSheetDir\stylesheets\Bubble_Compact" - File /r "${SOURCEDIR}\retroshare-gui\src\gui\qss\chat\Bubble_Compact\*.*" - - ; Stylesheets - SetOutPath "$INSTDIR\qss" - File /r "${SOURCEDIR}\retroshare-gui\src\qss\*.*" -SectionEnd - -;Section $(Section_Link) Section_Link - ; Delete any existing keys - - ; Write the file association -; WriteRegStr HKCR .pqi "" retroshare -; WriteRegStr HKCR retroshare "" "PQI File" -; WriteRegBin HKCR retroshare EditFlags 00000100 -; WriteRegStr HKCR "retroshare\shell" "" open -; WriteRegStr HKCR "retroshare\shell\open\command" "" `"$INSTDIR\retroshare.exe" "%1"` -;SectionEnd - -# Shortcuts -SectionGroup $(Section_Shortcuts) Section_Shortcuts -Section $(Section_StartMenu) Section_StartMenu - SetOutPath "$INSTDIR" - CreateDirectory "$SMPROGRAMS\${APPNAME}" - CreateShortCut "$SMPROGRAMS\${APPNAME}\$(Link_Uninstall).lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0 - CreateShortCut "$SMPROGRAMS\${APPNAME}\${APPNAME}.lnk" "$INSTDIR\retroshare.exe" "" "$INSTDIR\retroshare.exe" 0 -SectionEnd - -Section $(Section_Desktop) Section_Desktop - CreateShortCut "$DESKTOP\${APPNAME}.lnk" "$INSTDIR\retroshare.exe" "" "$INSTDIR\retroshare.exe" 0 -SectionEnd - -Section $(Section_QuickLaunch) Section_QuickLaunch - CreateShortCut "$QUICKLAUNCH\${APPNAME}.lnk" "$INSTDIR\retroshare.exe" "" "$INSTDIR\retroshare.exe" 0 -SectionEnd -SectionGroupEnd - -Section $(Section_AutoStart) Section_AutoStart - WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Run" "RetroShare" "$INSTDIR\retroshare.exe -m" -SectionEnd - -;Section $(Section_AutoStart) Section_AutoStart -; CreateShortCut "$SMSTARTUP\${APPNAME}.lnk" "$INSTDIR\retroshare.exe" "" "$INSTDIR\retroshare.exe -m" 0 -;SectionEnd - -Section -FinishSection - ${If} $PortableMode = 0 - WriteRegStr HKLM "Software\${APPNAME}" "" "$INSTDIR" - WriteRegStr HKLM "Software\${APPNAME}" "Version" "${VERSION}" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "DisplayName" "${APPNAME}" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "DisplayVersion" "${VERSION}" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "DisplayIcon" "$INSTDIR\retroshare.exe" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "Publisher" "${PUBLISHER}" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "NoModify" "1" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "NoRepair" "1" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "UninstallString" "$INSTDIR\uninstall.exe" - WriteUninstaller "$INSTDIR\uninstall.exe" - ${Else} - ; Create the file the application uses to detect portable mode - FileOpen $0 "$INSTDIR\portable" w - FileClose $0 - ${EndIf} -SectionEnd - -# Descriptions -!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN - !insertmacro MUI_DESCRIPTION_TEXT ${Section_Main} $(Section_Main_Desc) - !insertmacro MUI_DESCRIPTION_TEXT ${Section_Data} $(Section_Data_Desc) - !insertmacro MUI_DESCRIPTION_TEXT ${Section_Shortcuts} $(Section_Shortcuts_Desc) - !insertmacro MUI_DESCRIPTION_TEXT ${Section_StartMenu} $(Section_StartMenu_Desc) - !insertmacro MUI_DESCRIPTION_TEXT ${Section_Desktop} $(Section_Desktop_Desc) - !insertmacro MUI_DESCRIPTION_TEXT ${Section_QuickLaunch} $(Section_QuickLaunch_Desc) - !insertmacro MUI_DESCRIPTION_TEXT ${Section_Plugins} $(Section_Plugins_Desc) - !insertmacro MUI_DESCRIPTION_TEXT ${Section_Plugin_FeedReader} $(Section_Plugin_FeedReader_Desc) - !insertmacro MUI_DESCRIPTION_TEXT ${Section_Plugin_VOIP} $(Section_Plugin_VOIP_Desc) -; !insertmacro MUI_DESCRIPTION_TEXT ${Section_Link} $(Section_Link_Desc) - !insertmacro MUI_DESCRIPTION_TEXT ${Section_AutoStart} $(Section_AutoStart_Desc) -!insertmacro MUI_FUNCTION_DESCRIPTION_END - -# Uninstall -Section "Uninstall" - ; Remove file association registry keys -; DeleteRegKey HKCR .pqi - DeleteRegKey HKCR RetroShare - - ; Remove program/uninstall regsitry keys - DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" - DeleteRegKey HKLM SOFTWARE\${APPNAME} - - DeleteRegValue HKCU "Software\Microsoft\Windows\CurrentVersion\Run" "RetroShare" - - ; Remove shortcuts, if any - Delete "$SMPROGRAMS\${APPNAME}\*.*" - - ; Remove desktop shortcut - Delete "$DESKTOP\${APPNAME}.lnk" - - ; Remove Quicklaunch shortcut - Delete "$QUICKLAUNCH\${APPNAME}.lnk" - - ; Remove Autstart - Delete "$SMSTARTUP\${APPNAME}.lnk" - - ; Remove directories used - RMDir "$SMPROGRAMS\${APPNAME}" - RMDir /r "$INSTDIR" - - ; Don't remove the directory, otherwise - ; we lose the XPGP keys. - ; Should make this an option though... - RMDir /r "${DATADIR_NORMAL}\extensions6" - RMDir /r "${DATADIR_NORMAL}\stylesheets" -SectionEnd - -Function .onInit - StrCpy $InstDirNormal "${INSTDIR_NORMAL}" - StrCpy $InstDirPortable "${INSTDIR_PORTABLE}" - - StrCpy $PortableMode 0 - StrCpy $INSTDIR "$InstDirNormal" - StrCpy $DataDir "${DATADIR_NORMAL}" - - InitPluginsDir - Push $R1 - File /oname=$PLUGINSDIR\spltmp.bmp "${SOURCEDIR}\retroshare-gui\src\gui\images\logo\logo_splash.png" - advsplash::show 1200 1000 1000 -1 $PLUGINSDIR\spltmp - Pop $R1 - Pop $R1 - !insertmacro MUI_LANGDLL_DISPLAY -FunctionEnd - -# Installation mode - -Function RequireAdmin - UserInfo::GetAccountType - Pop $8 - ${If} $8 != "admin" - MessageBox MB_ICONSTOP "You need administrator rights to install ${APPNAME}" - SetErrorLevel 740 ;ERROR_ELEVATION_REQUIRED - Abort - ${EndIf} -FunctionEnd - -Function SetModeDestinationFromInstdir - ${If} $PortableMode = 0 - StrCpy $InstDirNormal $INSTDIR - ${Else} - StrCpy $InstDirPortable $INSTDIR - ${EndIf} -FunctionEnd - -Function PortableModePageCreate - Call SetModeDestinationFromInstdir ; If the user clicks BACK on the directory page we will remember their mode specific directory - !insertmacro MUI_HEADER_TEXT $(Page_InstallMode) $(Page_InstallMode_Desc) - nsDialogs::Create 1018 - Pop $0 - ${NSD_CreateRadioButton} 5u 25u -10u 8u $(Page_InstallMode_Standard) - Pop $1 - ${NSD_CreateLabel} 18u 40u -10u 24u $(Page_InstallMode_Standard_Desc) - Pop $0 - ${NSD_CreateRadioButton} 5u 75u -10u 8u $(Page_InstallMode_Portable) - Pop $2 - ${NSD_CreateLabel} 18u 90u -10u 24u $(Page_InstallMode_Portable_Desc) - Pop $0 - ${If} $PortableMode = 0 - SendMessage $1 ${BM_SETCHECK} ${BST_CHECKED} 0 - ${Else} - SendMessage $2 ${BM_SETCHECK} ${BST_CHECKED} 0 - ${EndIf} - nsDialogs::Show -FunctionEnd - -Function PortableModePageLeave - ${NSD_GetState} $1 $0 - ${If} $0 <> ${BST_UNCHECKED} - StrCpy $PortableMode 0 - StrCpy $INSTDIR $InstDirNormal - Call RequireAdmin - ; Enable sections - SectionSetText ${Section_Shortcuts} $(Section_Shortcuts) - SectionSetText ${Section_StartMenu} $(Section_StartMenu) - SectionSetText ${Section_Desktop} $(Section_Desktop) - SectionSetText ${Section_QuickLaunch} $(Section_QuickLaunch) - SectionSetText ${Section_AutoStart} $(Section_AutoStart) - !insertmacro SelectSection ${Section_Shortcuts} - !insertmacro SelectSection ${Section_AutoStart} - !insertmacro SelectSection ${Section_StartMenu} - !insertmacro SelectSection ${Section_Desktop} - !insertmacro SelectSection ${Section_QuickLaunch} - ${Else} - StrCpy $PortableMode 1 - StrCpy $INSTDIR $InstDirPortable - ; Disable sections - !insertmacro UnselectSection ${Section_Shortcuts} - !insertmacro UnselectSection ${Section_AutoStart} - !insertmacro UnselectSection ${Section_StartMenu} - !insertmacro UnselectSection ${Section_Desktop} - !insertmacro UnselectSection ${Section_QuickLaunch} - SectionSetText ${Section_Shortcuts} "" - SectionSetText ${Section_StartMenu} "" - SectionSetText ${Section_Desktop} "" - SectionSetText ${Section_QuickLaunch} "" - SectionSetText ${Section_AutoStart} "" - ${EndIf} -FunctionEnd - -Function dir_leave - ${If} $PortableMode = 0 - StrCpy $DataDir "${DATADIR_NORMAL}" - StrCpy $StyleSheetDir $DataDir - ${Else} - StrCpy $DataDir "${DATADIR_PORTABLE}" - StrCpy $StyleSheetDir $INSTDIR - ${EndIf} -FunctionEnd +; Script generated with the Venis Install Wizard & modified by defnax +; Reworked by Thunder +; Adapted to msys2 and 64 bit by anmo + +!include ifexist.nsh +!include x64.nsh + +# Needed defines +;!define REVISION "" +;!define DEPLOYDIR "" +;!define ARCHITECTURE "" + +# Optional defines +;!define OUTDIR "" +;!define INSTALLERADD "" + +# Check needed defines +!ifndef DEPLOYDIR +!error "DEPLOYDIR is not defined" +!endif +!ifndef ARCHITECTURE +!error "ARCHITECTURE is not defined" +!endif + +# Check optional defines +!ifdef OUTDIR +!define OUTDIR_ "${OUTDIR}\" +!else +!define OUTDIR "" +!define OUTDIR_ "" +!endif + +!ifndef INSTALLERADD +!define INSTALLERADD "" +!endif + +# Source directory +!define SOURCEDIR "..\..\.." + +# Get version from executable +!GetDllVersion "${DEPLOYDIR}\retroshare.exe" VERSION_ +!define VERSION ${VERSION_1}.${VERSION_2}.${VERSION_3} +;!define REVISION ${VERSION_4} + +# Check version +!ifndef REVISION +!error "REVISION is not defined" +!endif + +# Date +!define /date Date "%Y%m%d" + +# Detect tor +${!defineifexist} TOR_EXISTS "${DEPLOYDIR}\tor.exe" +!ifdef TOR_EXISTS +!define RSTYPE "-tor" +!else +!define RSTYPE "" +!endif + +# Application name and version +!define APPNAME "RetroShare" +!define APPNAMEANDVERSION "${APPNAME} ${VERSION}" +!define PUBLISHER "RetroShare Team" + +# Install path +!define INSTDIR_PORTABLE "$Desktop\${APPNAME}" + +!define DATADIR_NORMAL "$APPDATA\${APPNAME}" +!define DATADIR_PORTABLE "$INSTDIR\Data" + +# Main Install settings +Name "${APPNAMEANDVERSION}" +InstallDirRegKey HKLM "Software\${APPNAME}" "" +OutFile "${OUTDIR_}RetroShare-${VERSION}-${Date}-${REVISION}-${ARCHITECTURE}${RSTYPE}${INSTALLERADD}-setup.exe" +BrandingText "${APPNAMEANDVERSION}" +RequestExecutionlevel highest +# Use compression +SetCompressor /SOLID LZMA + +# Global variables +Var PortableMode +Var InstDirNormal +Var InstDirPortable +Var DataDir +Var StyleSheetDir + +# Modern interface settings +!include Sections.nsh +!include nsDialogs.nsh +!include "MUI.nsh" + +# Interface Settings +!define MUI_ABORTWARNING +!define MUI_HEADERIMAGE +!define MUI_HEADERIMAGE_BITMAP "${SOURCEDIR}\build_scripts\Windows-msys2\installer\HeaderImage.bmp" +;!define MUI_WELCOMEFINISHPAGE_BITMAP "...bmp" + +# MUI defines +!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\orange-install.ico" +!define MUI_FINISHPAGE_NOAUTOCLOSE +!define MUI_LICENSEPAGE_RADIOBUTTONS +!define MUI_COMPONENTSPAGE_SMALLDESC +!define MUI_FINISHPAGE_LINK "Visit the RetroShare forum for the latest news and support" +!define MUI_FINISHPAGE_LINK_LOCATION "http://retroshare.sourceforge.net/forum/" +!define MUI_FINISHPAGE_RUN "$INSTDIR\retroshare.exe" +!define MUI_FINISHPAGE_SHOWREADME $INSTDIR\changelog.txt +!define MUI_FINISHPAGE_SHOWREADME_TEXT changelog.txt +!define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED +!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\orange-uninstall.ico" +!define MUI_UNFINISHPAGE_NOAUTOCLOSE +;!define MUI_LANGDLL_REGISTRY_ROOT HKLM +;!define MUI_LANGDLL_REGISTRY_KEY ${REGKEY} +;!define MUI_LANGDLL_REGISTRY_VALUENAME InstallerLanguage + +# Defines the un-/installer logo of RetroShare +!insertmacro MUI_DEFAULT MUI_WELCOMEFINISHPAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Wizard\orange.bmp" +!insertmacro MUI_DEFAULT MUI_UNWELCOMEFINISHPAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Wizard\orange-uninstall.bmp" + +# Installer pages +!insertmacro MUI_PAGE_WELCOME +!insertmacro MUI_PAGE_LICENSE "$(myLicenseData)" +Page Custom PortableModePageCreate PortableModePageLeave +!define MUI_PAGE_CUSTOMFUNCTION_LEAVE dir_leave +!insertmacro MUI_PAGE_DIRECTORY +!insertmacro MUI_PAGE_COMPONENTS +!insertmacro MUI_PAGE_INSTFILES +!insertmacro MUI_PAGE_FINISH +!insertmacro MUI_UNPAGE_CONFIRM +!insertmacro MUI_UNPAGE_INSTFILES + +# Set languages (first is default language) +!insertmacro MUI_RESERVEFILE_LANGDLL + +# Installer languages +!define MUI_LANGDLL_ALLLANGUAGES + +# Translations +!macro LANG_LOAD LANGUAGE LANGCODE LANGID LICENCEFILE + !insertmacro MUI_LANGUAGE "${LANGUAGE}" +; !verbose off + !define LANG "${LANGUAGE}" + !include "lang\${LANGCODE}.nsh" + LangString LANGUAGEID "${LANG_${LANG}}" "1031" + LicenseLangString myLicenseData ${LANGCODE} ${LICENCEFILE} +; !verbose on + !undef LANG +!macroend + +!macro LANG_STRING NAME VALUE + LangString "${NAME}" "${LANG_${LANG}}" "${VALUE}" +!macroend + +!insertmacro LANG_LOAD "English" "en" "1033" "${SOURCEDIR}\retroshare-gui\src\license\license.txt" +!insertmacro LANG_LOAD "French" "fr" "1036" "${SOURCEDIR}\retroshare-gui\src\license\license-FR.txt" +!insertmacro LANG_LOAD "German" "de" "1031" "${SOURCEDIR}\retroshare-gui\src\license\license-GER.txt" +!insertmacro LANG_LOAD "Turkish" "tr" "1055" "${SOURCEDIR}\retroshare-gui\src\license\license-TR.txt" +!insertmacro LANG_LOAD "SimpChinese" "zh_CN" "2052" "${SOURCEDIR}\retroshare-gui\src\license\license.txt" +!insertmacro LANG_LOAD "Polish" "pl" "1045" "${SOURCEDIR}\retroshare-gui\src\license\license.txt" +!insertmacro LANG_LOAD "Spanish" "es" "1034" "${SOURCEDIR}\retroshare-gui\src\license\license.txt" +!insertmacro LANG_LOAD "Russian" "ru" "1049" "${SOURCEDIR}\retroshare-gui\src\license\license.txt" +!insertmacro LANG_LOAD "Catalan" "ca_ES" "1027" "${SOURCEDIR}\retroshare-gui\src\license\license.txt" + +LicenseData $(myLicenseData) + +# Main binaries +Section $(Section_Main) Section_Main + ;Set Section required + SectionIn RO + + ; Set Section properties + SetOverwrite on + + ; Clears previous error logs +; Delete "$INSTDIR\*.log" + + SetOutPath "$INSTDIR" + File /r /x Data /x stylesheets /x qss /x portable "${DEPLOYDIR}\*.*" +SectionEnd + +# Plugins +${!defineifexist} PLUGIN_FEEDREADER_EXISTS "${DEPLOYDIR}\Data\extensions6\FeedReader.dll" +${!defineifexist} PLUGIN_VOIP_EXISTS "${DEPLOYDIR}\Data\extensions6\VOIP.dll" + +!ifdef PLUGIN_FEEDREADER_EXISTS +!define /ifndef PLUGIN_EXISTS +!endif +!ifdef PLUGIN_VOIP_EXISTS +!define /ifndef PLUGIN_EXISTS +!endif + +!ifdef PLUGIN_EXISTS + SectionGroup $(Section_Plugins) Section_Plugins + !ifdef PLUGIN_FEEDREADER_EXISTS + Section $(Section_Plugin_FeedReader) Section_Plugin_FeedReader + SetOutPath "$DataDir\extensions6" + File "${DEPLOYDIR}\Data\extensions6\FeedReader.dll" + SectionEnd + !endif + + !ifdef PLUGIN_VOIP_EXISTS + Section $(Section_Plugin_VOIP) Section_Plugin_VOIP + SetOutPath "$DataDir\extensions6" + File "${DEPLOYDIR}\Data\extensions6\VOIP.dll" + SectionEnd + !endif + SectionGroupEnd +!endif + +# Data (Styles) +Section $(Section_Data) Section_Data + ; Set Section properties + SetOverwrite on + + ; Chat style + SetOutPath "$StyleSheetDir\stylesheets" + File /r "${DEPLOYDIR}\stylesheets\*.*" + + ; Stylesheets + SetOutPath "$INSTDIR\qss" + File /r "${DEPLOYDIR}\qss\*.*" +SectionEnd + +;Section $(Section_Link) Section_Link + ; Delete any existing keys + + ; Write the file association +; WriteRegStr HKCR .pqi "" retroshare +; WriteRegStr HKCR retroshare "" "PQI File" +; WriteRegBin HKCR retroshare EditFlags 00000100 +; WriteRegStr HKCR "retroshare\shell" "" open +; WriteRegStr HKCR "retroshare\shell\open\command" "" `"$INSTDIR\retroshare.exe" "%1"` +;SectionEnd + +# Shortcuts +SectionGroup $(Section_Shortcuts) Section_Shortcuts +Section $(Section_StartMenu) Section_StartMenu + SetOutPath "$INSTDIR" + CreateDirectory "$SMPROGRAMS\${APPNAME}" + CreateShortCut "$SMPROGRAMS\${APPNAME}\$(Link_Uninstall).lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0 + CreateShortCut "$SMPROGRAMS\${APPNAME}\${APPNAME}.lnk" "$INSTDIR\retroshare.exe" "" "$INSTDIR\retroshare.exe" 0 +SectionEnd + +Section $(Section_Desktop) Section_Desktop + CreateShortCut "$DESKTOP\${APPNAME}.lnk" "$INSTDIR\retroshare.exe" "" "$INSTDIR\retroshare.exe" 0 +SectionEnd + +Section $(Section_QuickLaunch) Section_QuickLaunch + CreateShortCut "$QUICKLAUNCH\${APPNAME}.lnk" "$INSTDIR\retroshare.exe" "" "$INSTDIR\retroshare.exe" 0 +SectionEnd +SectionGroupEnd + +Section $(Section_AutoStart) Section_AutoStart + WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Run" "RetroShare" "$INSTDIR\retroshare.exe -m" +SectionEnd + +;Section $(Section_AutoStart) Section_AutoStart +; CreateShortCut "$SMSTARTUP\${APPNAME}.lnk" "$INSTDIR\retroshare.exe" "" "$INSTDIR\retroshare.exe -m" 0 +;SectionEnd + +Section -FinishSection + ${If} $PortableMode = 0 + WriteRegStr HKLM "Software\${APPNAME}" "" "$INSTDIR" + WriteRegStr HKLM "Software\${APPNAME}" "Version" "${VERSION}" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "DisplayName" "${APPNAME}" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "DisplayVersion" "${VERSION}" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "DisplayIcon" "$INSTDIR\retroshare.exe" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "Publisher" "${PUBLISHER}" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "NoModify" "1" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "NoRepair" "1" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "UninstallString" "$INSTDIR\uninstall.exe" + WriteUninstaller "$INSTDIR\uninstall.exe" + ${Else} + ; Create the file the application uses to detect portable mode + FileOpen $0 "$INSTDIR\portable" w + FileClose $0 + ${EndIf} +SectionEnd + +# Descriptions +!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN + !insertmacro MUI_DESCRIPTION_TEXT ${Section_Main} $(Section_Main_Desc) + !insertmacro MUI_DESCRIPTION_TEXT ${Section_Data} $(Section_Data_Desc) + !insertmacro MUI_DESCRIPTION_TEXT ${Section_Shortcuts} $(Section_Shortcuts_Desc) + !insertmacro MUI_DESCRIPTION_TEXT ${Section_StartMenu} $(Section_StartMenu_Desc) + !insertmacro MUI_DESCRIPTION_TEXT ${Section_Desktop} $(Section_Desktop_Desc) + !insertmacro MUI_DESCRIPTION_TEXT ${Section_QuickLaunch} $(Section_QuickLaunch_Desc) + !insertmacro MUI_DESCRIPTION_TEXT ${Section_Plugins} $(Section_Plugins_Desc) + !insertmacro MUI_DESCRIPTION_TEXT ${Section_Plugin_FeedReader} $(Section_Plugin_FeedReader_Desc) + !insertmacro MUI_DESCRIPTION_TEXT ${Section_Plugin_VOIP} $(Section_Plugin_VOIP_Desc) +; !insertmacro MUI_DESCRIPTION_TEXT ${Section_Link} $(Section_Link_Desc) + !insertmacro MUI_DESCRIPTION_TEXT ${Section_AutoStart} $(Section_AutoStart_Desc) +!insertmacro MUI_FUNCTION_DESCRIPTION_END + +# Uninstall +Section "Uninstall" + ; Remove file association registry keys +; DeleteRegKey HKCR .pqi + DeleteRegKey HKCR RetroShare + + ; Remove program/uninstall regsitry keys + DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" + DeleteRegKey HKLM SOFTWARE\${APPNAME} + + DeleteRegValue HKCU "Software\Microsoft\Windows\CurrentVersion\Run" "RetroShare" + + ; Remove shortcuts, if any + Delete "$SMPROGRAMS\${APPNAME}\*.*" + + ; Remove desktop shortcut + Delete "$DESKTOP\${APPNAME}.lnk" + + ; Remove Quicklaunch shortcut + Delete "$QUICKLAUNCH\${APPNAME}.lnk" + + ; Remove Autstart + Delete "$SMSTARTUP\${APPNAME}.lnk" + + ; Remove directories used + RMDir "$SMPROGRAMS\${APPNAME}" + RMDir /r "$INSTDIR" + + ; Don't remove the directory, otherwise + ; we lose the XPGP keys. + ; Should make this an option though... + RMDir /r "${DATADIR_NORMAL}\extensions6" + RMDir /r "${DATADIR_NORMAL}\stylesheets" +SectionEnd + +Function .onInit +; source: https://stackoverflow.com/questions/19374453/nsis-installer-define-installer-and-system-x32-x64 + ${If} ${RunningX64} + ${If} ${ARCHITECTURE} == "x64" + StrCpy $InstDirNormal "$PROGRAMFILES64\${APPNAME}" + ${Else} + StrCpy $InstDirNormal "$PROGRAMFILES32\${APPNAME}" + ${Endif} + ${Else} + ${If} ${ARCHITECTURE} == "x64" + MessageBox MB_ICONSTOP "You cannot install the 64 bit version on a 32 bit system!" + Quit + ${Else} + StrCpy $InstDirNormal "$PROGRAMFILES\${APPNAME}" + ${Endif} + ${EndIf} + + StrCpy $InstDirPortable "${INSTDIR_PORTABLE}" + + StrCpy $PortableMode 0 + StrCpy $INSTDIR "$InstDirNormal" + StrCpy $DataDir "${DATADIR_NORMAL}" + + InitPluginsDir + Push $R1 + File /oname=$PLUGINSDIR\spltmp.bmp "${SOURCEDIR}\retroshare-gui\src\gui\images\logo\logo_splash.png" + advsplash::show 1200 1000 1000 -1 $PLUGINSDIR\spltmp + Pop $R1 + Pop $R1 + !insertmacro MUI_LANGDLL_DISPLAY +FunctionEnd + +# Installation mode + +Function RequireAdmin + UserInfo::GetAccountType + Pop $8 + ${If} $8 != "admin" + MessageBox MB_ICONSTOP "You need administrator rights to install ${APPNAME}" + SetErrorLevel 740 ;ERROR_ELEVATION_REQUIRED + Abort + ${EndIf} +FunctionEnd + +Function SetModeDestinationFromInstdir + ${If} $PortableMode = 0 + StrCpy $InstDirNormal $INSTDIR + ${Else} + StrCpy $InstDirPortable $INSTDIR + ${EndIf} +FunctionEnd + +Function PortableModePageCreate + Call SetModeDestinationFromInstdir ; If the user clicks BACK on the directory page we will remember their mode specific directory + !insertmacro MUI_HEADER_TEXT $(Page_InstallMode) $(Page_InstallMode_Desc) + nsDialogs::Create 1018 + Pop $0 + ${NSD_CreateRadioButton} 5u 25u -10u 8u $(Page_InstallMode_Standard) + Pop $1 + ${NSD_CreateLabel} 18u 40u -10u 24u $(Page_InstallMode_Standard_Desc) + Pop $0 + ${NSD_CreateRadioButton} 5u 75u -10u 8u $(Page_InstallMode_Portable) + Pop $2 + ${NSD_CreateLabel} 18u 90u -10u 24u $(Page_InstallMode_Portable_Desc) + Pop $0 + ${If} $PortableMode = 0 + SendMessage $1 ${BM_SETCHECK} ${BST_CHECKED} 0 + ${Else} + SendMessage $2 ${BM_SETCHECK} ${BST_CHECKED} 0 + ${EndIf} + nsDialogs::Show +FunctionEnd + +Function PortableModePageLeave + ${NSD_GetState} $1 $0 + ${If} $0 <> ${BST_UNCHECKED} + StrCpy $PortableMode 0 + StrCpy $INSTDIR $InstDirNormal + Call RequireAdmin + ; Enable sections + SectionSetText ${Section_Shortcuts} $(Section_Shortcuts) + SectionSetText ${Section_StartMenu} $(Section_StartMenu) + SectionSetText ${Section_Desktop} $(Section_Desktop) + SectionSetText ${Section_QuickLaunch} $(Section_QuickLaunch) + SectionSetText ${Section_AutoStart} $(Section_AutoStart) + !insertmacro SelectSection ${Section_Shortcuts} + !insertmacro SelectSection ${Section_AutoStart} + !insertmacro SelectSection ${Section_StartMenu} + !insertmacro SelectSection ${Section_Desktop} + !insertmacro SelectSection ${Section_QuickLaunch} + ${Else} + StrCpy $PortableMode 1 + StrCpy $INSTDIR $InstDirPortable + ; Disable sections + !insertmacro UnselectSection ${Section_Shortcuts} + !insertmacro UnselectSection ${Section_AutoStart} + !insertmacro UnselectSection ${Section_StartMenu} + !insertmacro UnselectSection ${Section_Desktop} + !insertmacro UnselectSection ${Section_QuickLaunch} + SectionSetText ${Section_Shortcuts} "" + SectionSetText ${Section_StartMenu} "" + SectionSetText ${Section_Desktop} "" + SectionSetText ${Section_QuickLaunch} "" + SectionSetText ${Section_AutoStart} "" + ${EndIf} +FunctionEnd + +Function dir_leave + ${If} $PortableMode = 0 + StrCpy $DataDir "${DATADIR_NORMAL}" + StrCpy $StyleSheetDir $DataDir + ${Else} + StrCpy $DataDir "${DATADIR_PORTABLE}" + StrCpy $StyleSheetDir $INSTDIR + ${EndIf} +FunctionEnd diff --git a/build_scripts/Windows-msys2/readme.md b/build_scripts/Windows-msys2/readme.md new file mode 100644 index 000000000..5582ec451 --- /dev/null +++ b/build_scripts/Windows-msys2/readme.md @@ -0,0 +1,91 @@ +# Compilation on Windows + +The preferred build method on Windows is by using MSYS2 which is a collection +of packages providing unix-like tools to build native Windows software. + +This guide contains information about how to setup your build environment in an automated way by scripts. +If you prefer to setup your environment manually, check this guide: +[WindowsMSys2_InstallGuide.md](WindowsMSys2_InstallGuide.md) + +Setting up the build environment automatically on a 32 bit OS is not possible anymore. +You can download an older 32 bit [MSYS2 installer](https://sourceforge.net/projects/msys2/files/Base/i686/msys2-base-i686-20180531.tar.xz/download) and follow the manual setup instructions. +Building 32 bit RetroShare from the 64 bit build environment is still possible. + +You have to clone this repository (with [git for windows](https://gitforwindows.org/)) to a local folder, then start it in a terminal. + + +## Automatic building + +Run the following script: + + \build_scripts\Windows-msys2\build.bat + +It will install all necessary tools to build RetrosShare, and build it with the default configuration. + +After the script is finished, you can find the resulting .7z package here: + + -msys2\deploy\ + +## Advanced building + +You can specify extra build options if you use the scripts under: + + \build_scripts\Windows-msys2\build\ + +You have to specify the build options after each command. + +Run the scripts in this order: +1. build.bat: builds RetroShare +2. pack.bat: makes a .7z archive with all the needed files to run the program +3. build-installer: makes a self extracting installer (optional) + +### Build options + +**Always delete the build artifacts folder if you enable or disable extra features after the build command: <sourcefolder>-msys2\deploy\builds** + +* Mandatory + * 32 or 64: 32 or 64 bit version + * release or debug: normally you would like to use the release option +* Extra features (optional) + * autologin: enable autologin + * plugins: build plugins + * webui: enable remoting features and pack webui files + * indexing: build with deep channel and file indexing support + * tor: include tor in the package + * "CONFIG+=..." enable other extra compile time features, you can find the almost complete list in file *<sourcefolder>\retroshare.pri* +* For fixing compile problems (optional) + * singlethread: use only 1 thread for building, slow but useful if you don't find the error message in the console + * clang: use clang compiler instead of GCC + * noupdate: skip the msys2 update step, sometimes some msys2 packages are broken, you can manually switch back to the older package, and this option will prevent updating to the broken version again + +Example: + +```batch +build.bat 64 release autologin webui "CONFIG+=rs_use_native_dialogs" "CONFIG+=rs_gui_cmark" +pack.bat 64 release autologin webui tor +build-installer.bat 64 release autologin +``` + +## Troubleshooting +* Run the command again, sometimes it works the second time, specially if it complains about *restbed* during building +* Delete the build artifacts: *<sourcefolder>-msys2\deploy\builds* +* Update msys2 manually: + 1. Open the terminal: *<sourcefolder>-msys2\msys2\msys64\msys2.exe* + 2. pacman -Sy + 3. pacman -Su + 4. Close the terminal + 5. Jump to 1. until it doesn't find more updates +* Start with a clean path environment variable, run *<sourcefolder>\build_scripts\Windows-msys2\start-clean-env.bat*, you will get a terminal with cleaned path + +### Errors during MSYS2 update +MSYS2 developers recently introduced some breaking changes. +If you get PGP related errors during updating the system from pacman, then follow [their guide](https://www.msys2.org/news/#2020-06-29-new-packagers) to resolve the problems. + +## Updating webui + +The scripts don't update the webui source code automatically once it is checked out. +You have to do it manually with your favourite git client. + +You can find the webui source code here: + + -webui diff --git a/build_scripts/Windows-msys2/start-clean-env.bat b/build_scripts/Windows-msys2/start-clean-env.bat new file mode 100644 index 000000000..1c6d46295 --- /dev/null +++ b/build_scripts/Windows-msys2/start-clean-env.bat @@ -0,0 +1,7 @@ +setlocal + +set path=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0 +cd build\ +cmd + +endlocal diff --git a/build_scripts/Windows-msys2/tools/webui.bat b/build_scripts/Windows-msys2/tools/webui.bat index f39da666a..b7af01e53 100644 --- a/build_scripts/Windows-msys2/tools/webui.bat +++ b/build_scripts/Windows-msys2/tools/webui.bat @@ -7,7 +7,9 @@ title Build webui if not exist "%RsWebuiPath%" ( echo Checking out webui source into %RsWebuiPath% - %EnvMSYS2Cmd% "pacman --noconfirm --needed -S git" + if not "%ParamNoupdate%"=="1" ( + %EnvMSYS2Cmd% "pacman --noconfirm --needed -S git" + ) git clone https://github.com/RetroShare/RSNewWebUI.git "%RsWebuiPath%" ) else ( echo Webui source found at %RsWebuiPath% diff --git a/build_scripts/Windows/build-libs/Makefile b/build_scripts/Windows/build-libs/Makefile old mode 100755 new mode 100644 index 697d4c286..c76269d1e --- a/build_scripts/Windows/build-libs/Makefile +++ b/build_scripts/Windows/build-libs/Makefile @@ -1,15 +1,15 @@ ZLIB_VERSION=1.2.3 BZIP2_VERSION=1.0.6 MINIUPNPC_VERSION=2.0 -OPENSSL_VERSION=1.0.2n +OPENSSL_VERSION=1.1.1g SPEEX_VERSION=1.2.0 SPEEXDSP_VERSION=1.2rc3 -OPENCV_VERSION=3.4.1 +OPENCV_VERSION=3.4.11 LIBXML2_VERSION=2.9.7 LIBXSLT_VERSION=1.1.32 CURL_VERSION=7.58.0 -TCL_VERSION=8.6.2 -SQLCIPHER_VERSION=2.2.1 +TCL_VERSION=8.6.10 +SQLCIPHER_VERSION=4.4.0 LIBMICROHTTPD_VERSION=0.9.59 FFMPEG_VERSION=3.4 RAPIDJSON_VERSION=1.1.0 @@ -74,7 +74,7 @@ $(BUILD_PATH)/zlib-$(ZLIB_VERSION): $(DOWNLOAD_PATH)/zlib-$(ZLIB_VERSION).tar.gz bzip2: $(BUILD_PATH)/bzip2-$(BZIP2_VERSION) $(DOWNLOAD_PATH)/bzip2-$(BZIP2_VERSION).tar.gz: - wget http://bzip.org/$(BZIP2_VERSION)/bzip2-$(BZIP2_VERSION).tar.gz -O $(DOWNLOAD_PATH)/bzip2-$(BZIP2_VERSION).tar.gz + wget https://sourceforge.net/projects/bzip2/files/bzip2-$(BZIP2_VERSION).tar.gz/download -O $(DOWNLOAD_PATH)/bzip2-$(BZIP2_VERSION).tar.gz $(BUILD_PATH)/bzip2-$(BZIP2_VERSION): $(DOWNLOAD_PATH)/bzip2-$(BZIP2_VERSION).tar.gz # prepare @@ -102,7 +102,7 @@ $(BUILD_PATH)/miniupnpc-$(MINIUPNPC_VERSION): $(DOWNLOAD_PATH)/miniupnpc-$(MINIU rm -r -f $(BUILD_PATH)/miniupnpc-* tar xvf $(DOWNLOAD_PATH)/miniupnpc-$(MINIUPNPC_VERSION).tar.gz # build - cd miniupnpc-$(MINIUPNPC_VERSION) && export CC=gcc && make -f Makefile.mingw init libminiupnpc.a miniupnpc.dll + cd miniupnpc-$(MINIUPNPC_VERSION) && export CC=gcc && export PATH=.:$$PATH && make -f Makefile.mingw init libminiupnpc.a miniupnpc.dll # copy files mkdir -p $(BUILD_PATH)/miniupnpc-$(MINIUPNPC_VERSION).tmp/include/miniupnpc cp miniupnpc-$(MINIUPNPC_VERSION)/*.h $(BUILD_PATH)/miniupnpc-$(MINIUPNPC_VERSION).tmp/include/miniupnpc/ @@ -132,8 +132,11 @@ $(BUILD_PATH)/openssl-$(OPENSSL_VERSION): $(DOWNLOAD_PATH)/openssl-$(OPENSSL_VER mkdir -p $(BUILD_PATH)/openssl-$(OPENSSL_VERSION).tmp/include/openssl cp openssl-$(OPENSSL_VERSION)/include/openssl/*.h $(BUILD_PATH)/openssl-$(OPENSSL_VERSION).tmp/include/openssl/ mkdir -p $(BUILD_PATH)/openssl-$(OPENSSL_VERSION).tmp/bin - cp openssl-$(OPENSSL_VERSION)/libeay32.dll $(BUILD_PATH)/openssl-$(OPENSSL_VERSION).tmp/bin/ - cp openssl-$(OPENSSL_VERSION)/ssleay32.dll $(BUILD_PATH)/openssl-$(OPENSSL_VERSION).tmp/bin/ + if [ $(MSYSTEM) = "MINGW32" ] ; then cp openssl-$(OPENSSL_VERSION)/libcrypto-1_1.dll $(BUILD_PATH)/openssl-$(OPENSSL_VERSION).tmp/bin/ ; fi + if [ $(MSYSTEM) = "MINGW32" ] ; then cp openssl-$(OPENSSL_VERSION)/libcrypto-1_1.dll $(BUILD_PATH)/openssl-$(OPENSSL_VERSION).tmp/bin/ ; fi + if [ $(MSYSTEM) = "MINGW32" ] ; then cp openssl-$(OPENSSL_VERSION)/libssl-1_1.dll $(BUILD_PATH)/openssl-$(OPENSSL_VERSION).tmp/bin/ ; fi + if [ $(MSYSTEM) = "MINGW64" ] ; then cp openssl-$(OPENSSL_VERSION)/libcrypto-1_1-x64.dll $(BUILD_PATH)/openssl-$(OPENSSL_VERSION).tmp/bin/ ; fi + if [ $(MSYSTEM) = "MINGW64" ] ; then cp openssl-$(OPENSSL_VERSION)/libssl-1_1-x64.dll $(BUILD_PATH)/openssl-$(OPENSSL_VERSION).tmp/bin/ ; fi mkdir -p $(BUILD_PATH)/openssl-$(OPENSSL_VERSION).tmp/lib cp openssl-$(OPENSSL_VERSION)/libcrypto.dll.a $(BUILD_PATH)/openssl-$(OPENSSL_VERSION).tmp/lib/ cp openssl-$(OPENSSL_VERSION)/libssl.dll.a $(BUILD_PATH)/openssl-$(OPENSSL_VERSION).tmp/lib/ @@ -202,7 +205,7 @@ $(BUILD_PATH)/opencv-$(OPENCV_VERSION): $(DOWNLOAD_PATH)/opencv-$(OPENCV_VERSION mkdir -p $(BUILD_PATH)/opencv-$(OPENCV_VERSION).tmp/include cp -r opencv-$(OPENCV_VERSION)/build/install/include/* $(BUILD_PATH)/opencv-$(OPENCV_VERSION).tmp/include/ mkdir -p $(BUILD_PATH)/opencv-$(OPENCV_VERSION).tmp/lib/opencv - cp -r opencv-$(OPENCV_VERSION)/build/install/x86/mingw/staticlib/* $(BUILD_PATH)/opencv-$(OPENCV_VERSION).tmp/lib/opencv/ + cp -r opencv-$(OPENCV_VERSION)/build/install/x64/mingw/staticlib/* $(BUILD_PATH)/opencv-$(OPENCV_VERSION).tmp/lib/opencv/ # cleanup rm -r -f opencv-$(OPENCV_VERSION) mv $(BUILD_PATH)/opencv-$(OPENCV_VERSION).tmp $(BUILD_PATH)/opencv-$(OPENCV_VERSION) diff --git a/build_scripts/Windows/build-libs/build-libs.bat b/build_scripts/Windows/build-libs/build-libs.bat index e0c5af09b..b0dc51277 100644 --- a/build_scripts/Windows/build-libs/build-libs.bat +++ b/build_scripts/Windows/build-libs/build-libs.bat @@ -6,7 +6,7 @@ setlocal :: Parameter -set MakeParam="DOWNLOAD_PATH=../download" +set MakeParam="DOWNLOAD_PATH=../../download" set MakeTask= :param_loop @@ -19,25 +19,29 @@ if "%~1" NEQ "" ( :: Initialize environment call "%~dp0..\env.bat" if errorlevel 1 goto error_env -call "%EnvPath%\env-msys.bat" +call "%EnvPath%\env-msys2.bat" if errorlevel 1 goto error_env :: Check MSYS environment -if not exist "%EnvMSYSSH%" %cecho% error "Please install MSYS first." & exit /B 1 +if not exist "%EnvMSYS2SH%" %cecho% error "Please install MSYS2 first." & exit /B 1 :: Initialize environment call "%~dp0env.bat" if errorlevel 1 goto error_env -:: Add tools path to PATH environment -set PATH=%EnvToolsPath%;%PATH% - -call "%ToolsPath%\msys-path.bat" "%~dp0" MSYSCurPath -call "%ToolsPath%\msys-path.bat" "%BuildLibsPath%" MSYSBuildLibsPath +call "%ToolsPath%\msys2-path.bat" "%~dp0" MSYS2CurPath +call "%ToolsPath%\msys2-path.bat" "%BuildLibsPath%" MSYS2BuildLibsPath if not exist "%BuildLibsPath%" mkdir "%BuildLibsPath%" -%EnvMSYSCmd% "cd "%MSYSBuildLibsPath%" && make -f %MSYSCurPath%/makefile %MakeParam% %MakeTask%" +set MSYSTEM=MINGW%MSYS2Base% +set MSYS2_PATH_TYPE=inherit + +%EnvMSYS2Cmd% "pacman --needed --noconfirm -S diffutils perl tar make wget mingw-w64-%MSYS2Architecture%-make" +::mingw-w64-%MSYS2Architecture%-cmake +::%EnvMSYS2Cmd% "pacman --noconfirm -Rd --nodeps mingw-w64-%MSYS2Architecture%-zlib" + +%EnvMSYS2Cmd% "cd "%MSYS2BuildLibsPath%" && make -f %MSYS2CurPath%/makefile %MakeParam% %MakeTask%" exit /B %ERRORLEVEL% diff --git a/build_scripts/Windows/build-libs/env.bat b/build_scripts/Windows/build-libs/env.bat index e340a6f88..48687e7f0 100644 --- a/build_scripts/Windows/build-libs/env.bat +++ b/build_scripts/Windows/build-libs/env.bat @@ -4,9 +4,10 @@ call "%ToolsPath%\find-in-path.bat" MinGWPath gcc.exe if "%MinGWPath%"=="" %cecho% error "Please run command in the Qt Command Prompt or add the path to MinGW bin folder to PATH variable." & exit /B 1 :: Get gcc versions -call "%ToolsPath%\get-gcc-version.bat" GCCVersion +call "%ToolsPath%\get-gcc-version.bat" GCCVersion GCCArchitecture if "%GCCVersion%"=="" %cecho% error "Cannot get gcc version." & exit /B 1 +if "%GCCArchitecture%"=="" %cecho% error "Cannot get gcc architecture." & exit /B 1 -set BuildLibsPath=%EnvRootPath%\build-libs\gcc-%GCCVersion% +set BuildLibsPath=%EnvRootPath%\build-libs\gcc-%GCCVersion%\%GCCArchitecture% exit /B 0 diff --git a/build_scripts/Windows/build-tor.bat b/build_scripts/Windows/build-tor.bat deleted file mode 100644 index a82e63f16..000000000 --- a/build_scripts/Windows/build-tor.bat +++ /dev/null @@ -1,27 +0,0 @@ -@echo off - -setlocal - -:: Initialize environment -call "%~dp0env.bat" -if errorlevel 1 goto error_env -call "%EnvPath%\env.bat" -if errorlevel 1 goto error_env - -%cecho% info "Build libraries" -call "%~dp0build-libs\build-libs.bat" -if errorlevel 1 %cecho% error "Failed to build libraries." & exit /B %ERRORLEVEL% - -%cecho% info "Build %SourceName%" -call "%~dp0build\build.bat" release tor autologin plugins -if errorlevel 1 %cecho% error "Failed to build %SourceName%." & exit /B %ERRORLEVEL% - -%cecho% info "Pack %SourceName%" -call "%~dp0build\pack.bat" release tor -if errorlevel 1 %cecho% error "Failed to pack %SourceName%." & exit /B %ERRORLEVEL% - -exit /B 0 - -:error_env -echo Failed to initialize environment. -exit /B 1 diff --git a/build_scripts/Windows/build.bat b/build_scripts/Windows/build.bat index c91c64753..89179e22c 100644 --- a/build_scripts/Windows/build.bat +++ b/build_scripts/Windows/build.bat @@ -13,7 +13,8 @@ call "%~dp0build-libs\build-libs.bat" if errorlevel 1 %cecho% error "Failed to build libraries." & exit /B %ERRORLEVEL% %cecho% info "Build %SourceName%" -call "%~dp0build\build.bat" release autologin plugins +call "%~dp0build\build.bat" release autologin jsonapi +rem plugins if errorlevel 1 %cecho% error "Failed to build %SourceName%." & exit /B %ERRORLEVEL% %cecho% info "Pack %SourceName%" diff --git a/build_scripts/Windows/build/build-installer.bat b/build_scripts/Windows/build/build-installer.bat index afa01ffe0..b34e76157 100644 --- a/build_scripts/Windows/build/build-installer.bat +++ b/build_scripts/Windows/build/build-installer.bat @@ -21,6 +21,12 @@ if not exist "%BuildLibsPath%\libs\gcc-version" %cecho% error "Cannot get gcc ve set /P LibsGCCVersion=<"%BuildLibsPath%\libs\gcc-version" if "%LibsGCCVersion%" NEQ "%GCCVersion%" %cecho% error "Please use correct version of external libraries. (gcc %GCCVersion% ^<^> libs %LibsGCCVersion%)." & exit /B 1 +:: Get date +call "%ToolsPath%\get-rs-date.bat" "%SourcePath%" RsDate +if errorlevel 1 %cecho% error "Could not get date."& goto error + +if "%RsDate%"=="" %cecho% error "Could not get date."& goto error + :: Build defines for script set NSIS_PARAM= @@ -30,6 +36,10 @@ set NSIS_PARAM=%NSIS_PARAM% /DMINGWDIR="%MinGWPath%\.." set NSIS_PARAM=%NSIS_PARAM% /DOUTDIR="%RsPackPath%" set NSIS_PARAM=%NSIS_PARAM% /DINSTALLERADD="%RsArchiveAdd%" set NSIS_PARAM=%NSIS_PARAM% /DEXTERNAL_LIB_DIR="%BuildLibsPath%\libs" +set NSIS_PARAM=%NSIS_PARAM% /DARCHITECTURE="%GCCArchitecture%" +set NSIS_PARAM=%NSIS_PARAM% /DDATE="%RsDate%" + +if exist "%EnvTorPath%\Tor\tor.exe" set NSIS_PARAM=%NSIS_PARAM% /DTORDIR="%EnvTorPath%\Tor" :: Get compiled version call "%ToolsPath%\get-rs-version.bat" "%RsBuildPath%\retroshare-gui\src\%RsBuildConfig%\retroshare.exe" RsVersion diff --git a/build_scripts/Windows/build/build.bat b/build_scripts/Windows/build/build.bat index 62eb5eca6..a7f02027f 100644 --- a/build_scripts/Windows/build/build.bat +++ b/build_scripts/Windows/build/build.bat @@ -50,8 +50,8 @@ echo. title Build - %SourceName%-%RsBuildConfig% [qmake] set RS_QMAKE_CONFIG=%RsBuildConfig% -if "%ParamVersion%"=="1" set RS_QMAKE_CONFIG=%RS_QMAKE_CONFIG% version_detail_bash_script if "%ParamAutologin%"=="1" set RS_QMAKE_CONFIG=%RS_QMAKE_CONFIG% rs_autologin +if "%ParamJsonApi%"=="1" set RS_QMAKE_CONFIG=%RS_QMAKE_CONFIG% rs_jsonapi if "%ParamPlugins%"=="1" set RS_QMAKE_CONFIG=%RS_QMAKE_CONFIG% retroshare_plugins qmake "%SourcePath%\RetroShare.pro" -r -spec win32-g++ "CONFIG+=%RS_QMAKE_CONFIG%" "EXTERNAL_LIB_DIR=%BuildLibsPath%\libs" @@ -63,11 +63,15 @@ echo. title Build - %SourceName%-%RsBuildConfig% [make] -if exist "%EnvJomExe%" ( - "%EnvJomExe%" -) else ( - mingw32-make -) +mingw32-make -j %CoreCount% +if errorlevel 1 goto error + +echo. +echo === Changelog +echo. + +title Build - %SourceName%-%RsBuildConfig% [changelog] +call "%ToolsPath%\generate-changelog.bat" "%SourcePath%" "%RsBuildPath%\changelog.txt" :error popd diff --git a/build_scripts/Windows/build/env.bat b/build_scripts/Windows/build/env.bat index f10ab2075..100fa32cd 100644 --- a/build_scripts/Windows/build/env.bat +++ b/build_scripts/Windows/build/env.bat @@ -3,7 +3,10 @@ set ParamRelease=0 set ParamDebug=0 set ParamAutologin=0 set ParamPlugins=0 +set ParamJsonApi=0 set ParamTor=0 +set NonInteractive=0 +set CoreCount=%NUMBER_OF_PROCESSORS% :parameter_loop if "%~1" NEQ "" ( @@ -14,10 +17,16 @@ if "%~1" NEQ "" ( set ParamDebug=1 ) else if "%%~a"=="autologin" ( set ParamAutologin=1 + ) else if "%%~a"=="jsonapi" ( + set ParamJsonApi=1 ) else if "%%~a"=="plugins" ( set ParamPlugins=1 ) else if "%%~a"=="tor" ( set ParamTor=1 + ) else if "%%~a"=="non-interactive" ( + set NonInteractive=1 + ) else if "%%~a"=="singlethread" ( + set CoreCount=1 ) else ( echo. echo Unknown parameter %1 @@ -67,13 +76,14 @@ call "%ToolsPath%\get-qt-version.bat" QtVersion if "%QtVersion%"=="" %cecho% error "Cannot get Qt version." & exit /B 1 :: Get gcc versions -call "%ToolsPath%\get-gcc-version.bat" GCCVersion +call "%ToolsPath%\get-gcc-version.bat" GCCVersion GCCArchitecture if "%GCCVersion%"=="" %cecho% error "Cannot get gcc version." & exit /B 1 +if "%GCCArchitecture%"=="" %cecho% error "Cannot get gcc architecture." & exit /B 1 -set BuildLibsPath=%EnvRootPath%\build-libs\gcc-%GCCVersion% +set BuildLibsPath=%EnvRootPath%\build-libs\gcc-%GCCVersion%\%GCCArchitecture% -set RsBuildPath=%BuildPath%\Qt-%QtVersion%-%RsBuildConfig% -set RsDeployPath=%DeployPath%\Qt-%QtVersion%%RsType%-%RsBuildConfig% +set RsBuildPath=%BuildPath%\Qt-%QtVersion%-%GCCArchitecture%-%RsBuildConfig% +set RsDeployPath=%DeployPath%\Qt-%QtVersion%-%GCCArchitecture%%RsType%-%RsBuildConfig% set RsPackPath=%DeployPath% set RsArchiveAdd= @@ -93,9 +103,16 @@ echo release^|debug Build release or debug version echo. echo Optional parameter (need clean when changed) echo autologin Build with autologin +echo jsonapi Build with jsonapi echo plugins Build plugins echo. +echo Optional parameter +echo singlethread Use only 1 thread for building +echo. echo Parameter for pack echo tor Pack tor version echo. +echo Parameter for git-log +echo non-interactive Non-interactive mode +echo. exit /B 2 diff --git a/build_scripts/Windows/build/git-log.bat b/build_scripts/Windows/build/git-log.bat index d711ededb..4d479fc3f 100644 --- a/build_scripts/Windows/build/git-log.bat +++ b/build_scripts/Windows/build/git-log.bat @@ -2,9 +2,6 @@ setlocal -set NoAsk= -if "%~2"=="no-ask" set NoAsk=1 - :: Initialize environment call "%~dp0..\env.bat" if errorlevel 1 goto error_env @@ -20,48 +17,29 @@ set GitPath= call "%ToolsPath%\find-in-path.bat" GitPath git.exe if "%GitPath%"=="" echo Git executable not found in PATH.& exit /B 1 -:: Get compiled revision -set GetRsVersion=%SourcePath%\build_scripts\Windows\tools\get-rs-version.bat -if not exist "%GetRsVersion%" ( - echo File not found - echo %GetRsVersion% - exit /B 1 -) - -call "%GetRsVersion%" RS_REVISION_STRING RsRevision -if "%RsRevision%"=="" echo Revision not found.& exit /B 1 - :: Get compiled version -call "%GetRsVersion%" RS_REVISION_STRING RsRevision -if "%RsRevision%"=="" echo Revision not found.& exit /B 1 +call "%ToolsPath%\get-rs-version.bat" "%RsBuildPath%\retroshare-gui\src\%RsBuildConfig%\retroshare.exe" RsVersion +if errorlevel 1 %cecho% error "Version not found."& goto error -call "%GetRsVersion%" RS_MAJOR_VERSION RsMajorVersion -if "%RsMajorVersion%"=="" echo Major version not found.& exit /B 1 +if "%RsVersion.Major%"=="" %cecho% error "Major version not found."& goto error +if "%RsVersion.Minor%"=="" %cecho% error "Minor version not found."& goto error +if "%RsVersion.Mini%"=="" %cecho% error "Mini number not found".& goto error +if "%RsVersion.Extra%"=="" %cecho% error "Extra number not found".& goto error -call "%GetRsVersion%" RS_MINOR_VERSION RsMinorVersion -if "%RsMinorVersion%"=="" echo Minor version not found.& exit /B 1 +set RsVersion=%RsVersion.Major%.%RsVersion.Minor%.%RsVersion.Mini% -call "%GetRsVersion%" RS_BUILD_NUMBER RsBuildNumber -if "%RsBuildNumber%"=="" echo Build number not found.& exit /B 1 +:: Get date +call "%ToolsPath%\get-rs-date.bat" "%SourcePath%" RsDate +if errorlevel 1 %cecho% error "Could not get date."& goto error -call "%GetRsVersion%" RS_BUILD_NUMBER_ADD RsBuildNumberAdd - -set RsVersion=%RsMajorVersion%.%RsMinorVersion%.%RsBuildNumber%%RsBuildNumberAdd% - -:: Check WMIC is available -wmic.exe alias /? >nul 2>&1 || echo WMIC is not available.&& exit /B 1 - -:: Use WMIC to retrieve date in format YYYYMMDD -set RsDate= -for /f "tokens=2 delims==" %%I in ('wmic os get localdatetime /format:list') do set RsDate=%%I -set RsDate=%RsDate:~0,4%%RsDate:~4,2%%RsDate:~6,2% +if "%RsDate%"=="" %cecho% error "Could not get date."& goto error :: Get last revision -set RsLastRefFile=%BuildPath%\Qt-%QtVersion%%RsType%-%RsBuildConfig%-LastRef.txt +set RsLastRefFile=%BuildPath%\Qt-%QtVersion%-%GCCArchitecture%%RsType%-%RsBuildConfig%-LastRef.txt set RsLastRef= if exist "%RsLastRefFile%" set /P RsLastRef=<"%RsLastRefFile%" -if "%NoAsk%"=="1" goto no_ask_for_last_revision +if "%NonInteractive%"=="1" goto no_ask_for_last_revision if not "%RsLastRef%"=="" echo Last Revision was %RsLastRef% set /P RsLastRefInput=Last Revision: if "%RsLastRefInput%" NEQ "" set RsLastRef=%RsLastRefInput% @@ -79,15 +57,15 @@ echo. echo Creating log from %RsLastRef% echo to %RsRef% -if "%NoAsk%"=="1" goto no_confirm +if "%NonInteractive%"=="1" goto no_confirm choice /M "Do you want to proceed?" if %errorlevel%==2 exit /B 1 :no_confirm if "%RsBuildConfig%" NEQ "release" ( - set RsGitLog=%DeployPath%\RetroShare-%RsVersion%-Windows-Portable-%RsDate%-%RsRevision%-Qt-%QtVersion%%RsType%%RsArchiveAdd%-%RsBuildConfig%.txt + set RsGitLog=%DeployPath%\RetroShare-%RsVersion%-Windows-Portable-%RsDate%-%RsVersion.Extra%-Qt-%QtVersion%-%GCCArchitecture%%RsType%%RsArchiveAdd%-%RsBuildConfig%.txt ) else ( - set RsGitLog=%DeployPath%\RetroShare-%RsVersion%-Windows-Portable-%RsDate%-%RsRevision%-Qt-%QtVersion%%RsType%%RsArchiveAdd%.txt + set RsGitLog=%DeployPath%\RetroShare-%RsVersion%-Windows-Portable-%RsDate%-%RsVersion.Extra%-Qt-%QtVersion%-%GCCArchitecture%%RsType%%RsArchiveAdd%.txt ) title %SourceName%-%RsBuildConfig% [git log] diff --git a/build_scripts/Windows/build/pack.bat b/build_scripts/Windows/build/pack.bat index d97f3ea22..d48d93a65 100644 --- a/build_scripts/Windows/build/pack.bat +++ b/build_scripts/Windows/build/pack.bat @@ -29,16 +29,8 @@ if exist "%RsDeployPath%" rmdir /S /Q "%RsDeployPath%" :: Check compilation if not exist "%RsBuildPath%\Makefile" echo Project is not compiled.& goto error -:: Get compiled revision -set GetRsVersion=%SourcePath%\build_scripts\Windows\tools\get-rs-version.bat -if not exist "%GetRsVersion%" ( - %cecho% error "File not found" - echo %GetRsVersion% - goto error -) - :: Get compiled version -call "%GetRsVersion%" "%RsBuildPath%\retroshare-gui\src\%RsBuildConfig%\retroshare.exe" RsVersion +call "%ToolsPath%\get-rs-version.bat" "%RsBuildPath%\retroshare-gui\src\%RsBuildConfig%\retroshare.exe" RsVersion if errorlevel 1 %cecho% error "Version not found."& goto error if "%RsVersion.Major%"=="" %cecho% error "Major version not found."& goto error @@ -48,18 +40,17 @@ if "%RsVersion.Extra%"=="" %cecho% error "Extra number not found".& goto error set RsVersion=%RsVersion.Major%.%RsVersion.Minor%.%RsVersion.Mini% -:: Check WMIC is available -wmic.exe alias /? >nul 2>&1 || echo WMIC is not available.&& goto error +:: Get date +call "%ToolsPath%\get-rs-date.bat" "%SourcePath%" RsDate +if errorlevel 1 %cecho% error "Could not get date."& goto error -:: Use WMIC to retrieve date in format YYYYMMDD -set RsDate= -for /f "tokens=2 delims==" %%I in ('wmic os get localdatetime /format:list') do set RsDate=%%I -set RsDate=%RsDate:~0,4%%RsDate:~4,2%%RsDate:~6,2% +if "%RsDate%"=="" %cecho% error "Could not get date."& goto error +rem Tor if "%ParamTor%"=="1" ( :: Check for tor executable - if not exist "%EnvDownloadPath%\tor\Tor\tor.exe" ( - %cecho% error "Tor binary not found. Please download Tor Expert Bundle from\nhttps://www.torproject.org/download/download.html.en\nand unpack to\n%EnvDownloadPath:\=\\%\\tor" + if not exist "%EnvTorPath%\Tor\tor.exe" ( + %cecho% error "Tor binary not found. Please download Tor Expert Bundle from\nhttps://www.torproject.org/download/download.html.en\nand unpack to\n%EnvTorPath:\=\\%" goto error ) ) @@ -74,9 +65,9 @@ if "%QtMainVersion%"=="4" set QtMainVersion2=4 if "%QtMainVersion%"=="5" set QtMainVersion1=5 if "%RsBuildConfig%" NEQ "release" ( - set Archive=%RsPackPath%\RetroShare-%RsVersion%-Windows-Portable-%RsDate%-%RsVersion.Extra%-Qt-%QtVersion%%RsType%%RsArchiveAdd%-%RsBuildConfig%.7z + set Archive=%RsPackPath%\RetroShare-%RsVersion%-Windows-Portable-%RsDate%-%RsVersion.Extra%-Qt-%QtVersion%-%GCCArchitecture%%RsType%%RsArchiveAdd%-%RsBuildConfig%.7z ) else ( - set Archive=%RsPackPath%\RetroShare-%RsVersion%-Windows-Portable-%RsDate%-%RsVersion.Extra%-Qt-%QtVersion%%RsType%%RsArchiveAdd%.7z + set Archive=%RsPackPath%\RetroShare-%RsVersion%-Windows-Portable-%RsDate%-%RsVersion.Extra%-Qt-%QtVersion%-%GCCArchitecture%%RsType%%RsArchiveAdd%.7z ) if exist "%Archive%" del /Q "%Archive%" @@ -98,12 +89,13 @@ mkdir "%RsDeployPath%\qss" mkdir "%RsDeployPath%\stylesheets" mkdir "%RsDeployPath%\sounds" mkdir "%RsDeployPath%\translations" +mkdir "%RsDeployPath%\license" copy nul "%RsDeployPath%\portable" %Quite% echo copy binaries -copy "%RsBuildPath%\retroshare-gui\src\%RsBuildConfig%\RetroShare*.exe" "%RsDeployPath%" %Quite% -copy "%RsBuildPath%\retroshare-nogui\src\%RsBuildConfig%\retroshare*-nogui.exe" "%RsDeployPath%" %Quite% +copy "%RsBuildPath%\retroshare-gui\src\%RsBuildConfig%\retroshare*.exe" "%RsDeployPath%" %Quite% +copy "%RsBuildPath%\retroshare-service\src\%RsBuildConfig%\retroshare*-service.exe" "%RsDeployPath%" %Quite% echo copy extensions for /D %%D in ("%RsBuildPath%\plugins\*") do ( @@ -148,13 +140,15 @@ rmdir /S /Q "%RsDeployPath%\stylesheets\__MACOSX__Bubble" %Quite% echo copy sounds xcopy /S "%SourcePath%\retroshare-gui\src\sounds" "%RsDeployPath%\sounds" %Quite% +echo copy license +xcopy /S "%SourcePath%\retroshare-gui\src\license" "%RsDeployPath%\license" %Quite% + echo copy translation copy "%SourcePath%\retroshare-gui\src\translations\qt_tr.qm" "%RsDeployPath%\translations" %Quite% copy "%QtPath%\..\translations\qt_*.qm" "%RsDeployPath%\translations" %Quite% if "%QtMainVersion%"=="5" ( copy "%QtPath%\..\translations\qtbase_*.qm" "%RsDeployPath%\translations" %Quite% copy "%QtPath%\..\translations\qtscript_*.qm" "%RsDeployPath%\translations" %Quite% - copy "%QtPath%\..\translations\qtquick1_*.qm" "%RsDeployPath%\translations" %Quite% copy "%QtPath%\..\translations\qtmultimedia_*.qm" "%RsDeployPath%\translations" %Quite% copy "%QtPath%\..\translations\qtxmlpatterns_*.qm" "%RsDeployPath%\translations" %Quite% ) @@ -163,7 +157,7 @@ echo copy bdboot.txt copy "%SourcePath%\libbitdht\src\bitdht\bdboot.txt" "%RsDeployPath%" %Quite% echo copy changelog.txt -copy "%SourcePath%\retroshare-gui\src\changelog.txt" "%RsDeployPath%" %Quite% +copy "%RsBuildPath%\changelog.txt" "%RsDeployPath%" %Quite% if exist "%SourcePath%\libresapi\src\webui" ( echo copy webui @@ -173,7 +167,7 @@ if exist "%SourcePath%\libresapi\src\webui" ( if "%ParamTor%"=="1" ( echo copy tor - echo n | copy /-y "%EnvDownloadPath%\tor\Tor\*.*" "%RsDeployPath%" %Quite% + echo n | copy /-y "%EnvTorPath%\Tor\*.*" "%RsDeployPath%" %Quite% ) rem pack files diff --git a/build_scripts/Windows/env/env-msys.bat b/build_scripts/Windows/env/env-msys.bat deleted file mode 100644 index 99d988e1e..000000000 --- a/build_scripts/Windows/env/env-msys.bat +++ /dev/null @@ -1,22 +0,0 @@ -:: Usage: -:: call env-msys.bat [reinstall|clean] - -:: Initialize environment -call "%~dp0env.bat" -if errorlevel 1 goto error_env - -set EnvMSYSPath=%EnvRootPath%\msys - -call "%~dp0tools\prepare-msys.bat" %1 -if errorlevel 1 exit /B %ERRORLEVEL% - -set EnvMSYSSH=%EnvMSYSPath%\msys\1.0\bin\sh.exe -if not exist "%EnvMSYSSH%" if errorlevel 1 goto error_env - -set EnvMSYSCmd="%EnvMSYSSH%" --login -i -c - -exit /B 0 - -:error_env -echo Failed to initialize environment. -exit /B 1 diff --git a/build_scripts/Windows/env/env-msys2.bat b/build_scripts/Windows/env/env-msys2.bat new file mode 100644 index 000000000..b99ede679 --- /dev/null +++ b/build_scripts/Windows/env/env-msys2.bat @@ -0,0 +1,39 @@ +:: Usage: +:: call env-msys2.bat [reinstall|clean] + +:: Initialize environment +call "%~dp0env.bat" +if errorlevel 1 goto error_env + +rem openssl x86 doesn't compile with mingw64 x64 +:: Get gcc versions +call "%ToolsPath%\get-gcc-version.bat" GCCVersion GCCArchitecture +if "%GCCVersion%"=="" %cecho% error "Cannot get gcc version." & exit /B 1 +if "%GCCArchitecture%"=="" %cecho% error "Cannot get gcc architecture." & exit /B 1 + +rem IF DEFINED ProgramFiles(x86) ( +if "%GCCArchitecture%"=="x64" ( + :: x64 + set MSYS2Architecture=x86_64 + set MSYS2Base=64 +) else ( + :: x86 + set MSYS2Architecture=i686 + set MSYS2Base=32 +) + +set EnvMSYS2Path=%EnvRootPath%\msys2 + +call "%~dp0tools\prepare-msys2.bat" %1 +if errorlevel 1 exit /B %ERRORLEVEL% + +set EnvMSYS2SH=%EnvMSYS2Path%\msys%MSYS2Base%\usr\bin\sh.exe +if not exist "%EnvMSYS2SH%" if errorlevel 1 goto error_env + +set EnvMSYS2Cmd="%EnvMSYS2SH%" -lc + +exit /B 0 + +:error_env +echo Failed to initialize environment. +exit /B 1 diff --git a/build_scripts/Windows/env/env-qt.bat b/build_scripts/Windows/env/env-qt.bat deleted file mode 100644 index 776e2078c..000000000 --- a/build_scripts/Windows/env/env-qt.bat +++ /dev/null @@ -1,23 +0,0 @@ -:: Usage: -:: call env-qt4.bat version [reinstall|clean] - -:: Initialize environment -call "%~dp0env.bat" -if errorlevel 1 goto error_env - -set EnvQtBasePath=%EnvRootPath%\qt - -:: Create folders -if not exist "%EnvQtBasePath%" mkdir "%EnvQtBasePath%" - -call "%~dp0tools\prepare-qt.bat" %1 %2 -if errorlevel 1 exit /B %ERRORLEVEL% - -if "%MinGWDir%" NEQ "" set PATH=%MinGWDir%\bin;%PATH% -if "%QtDir%" NEQ "" set PATH=%QtDir%\bin;%PATH% - -exit /B 0 - -:error_env -echo Failed to initialize environment. -exit /B 1 diff --git a/build_scripts/Windows/env/env.bat b/build_scripts/Windows/env/env.bat index a640d1612..bc95045b0 100644 --- a/build_scripts/Windows/env/env.bat +++ b/build_scripts/Windows/env/env.bat @@ -6,11 +6,9 @@ set EnvRootPath=%RootPath%\%SourceName%-env set EnvToolsPath=%EnvRootPath%\tools set EnvTempPath=%EnvRootPath%\tmp set EnvDownloadPath=%EnvRootPath%\download +set EnvTorPath=%EnvDownloadPath%\tor -::set EnvCurlExe=%EnvToolsPath%\curl.exe -set EnvWgetExe=%EnvToolsPath%\wget.exe set EnvSevenZipExe=%EnvToolsPath%\7z.exe -set EnvJomExe=%EnvToolsPath%\jom.exe set EnvSedExe=%EnvToolsPath%\sed.exe set EnvCutExe=%EnvToolsPath%\cut.exe set EnvDependsExe=%EnvToolsPath%\depends.exe @@ -27,7 +25,7 @@ call "%~dp0tools\prepare-tools.bat" if errorlevel 1 exit /B %ERRORLEVEL% :: Add MinGit to PATH -set PATH=%EnvToolsPath%\MinGit\cmd;%PATH% +set PATH=%EnvToolsPath%\MinGit\cmd;%EnvToolsPath%\cmake\bin;%PATH% set HOME=%EnvToolsPath%\MinGit\home exit /B 0 diff --git a/build_scripts/Windows/env/tools/prepare-msys.bat b/build_scripts/Windows/env/tools/prepare-msys.bat deleted file mode 100644 index 23dd391f4..000000000 --- a/build_scripts/Windows/env/tools/prepare-msys.bat +++ /dev/null @@ -1,81 +0,0 @@ -:: Usage: -:: call prepare-msys.bat [reinstall|clean] - -setlocal enabledelayedexpansion - -if "%EnvMSYSPath%"=="" exit /B 1 -if not exist "%EnvRootPath%"=="" exit /B 1 - -copy "%~dp0root\update-msys.bat" "%EnvRootPath%" >nul - -if "%~1"=="clean" ( - %cecho% info "Clean MSYS" - call "%ToolsPath%\remove-dir.bat" "%EnvMSYSPath%" - goto exit -) - -if exist "%EnvMSYSPath%\bin\mingw-get.exe" ( - if "%~1"=="reinstall" ( - choice /M "Found existing MSYS version. Do you want to proceed?" - if !ERRORLEVEL!==2 goto exit - ) else ( - goto exit - ) -) - -set MSYSInstall=mingw-get-0.6.2-mingw32-beta-20131004-1-bin.zip -set MSYSUrl=http://sourceforge.net/projects/mingw/files/Installer/mingw-get/mingw-get-0.6.2-beta-20131004-1/%MSYSInstall%/download -set CMakeInstall=cmake-3.1.0-win32-x86.zip -set CMakeUrl=http://www.cmake.org/files/v3.1/%CMakeInstall% -set CMakeUnpackPath=%EnvMSYSPath%\msys\1.0 - -%cecho% info "Remove previous MSYS version" -call "%ToolsPath%\remove-dir.bat" "%EnvMSYSPath%" - -%cecho% info "Download installation files" -if not exist "%EnvDownloadPath%\%MSYSInstall%" call "%ToolsPath%\download-file.bat" "%MSYSUrl%" "%EnvDownloadPath%\%MSYSInstall%" -if not exist "%EnvDownloadPath%\%MSYSInstall%" %cecho% error "Cannot download MSYS" & goto error - -if not exist "%EnvDownloadPath%\%CMakeInstall%" call "%ToolsPath%\download-file.bat" "%CMakeUrl%" "%EnvDownloadPath%\%CMakeInstall%" -if not exist "%EnvDownloadPath%\%CMakeInstall%" %cecho% error "Cannot download CMake" & goto error - -%cecho% info "Unpack MSYS" -"%EnvSevenZipExe%" x -o"%EnvMSYSPath%" "%EnvDownloadPath%\%MSYSInstall%" - -%cecho% info "Install MSYS" -if not exist "%EnvMSYSPath%\var\lib\mingw-get\data\profile.xml" copy "%EnvMSYSPath%\var\lib\mingw-get\data\defaults.xml" "%EnvMSYSPath%\var\lib\mingw-get\data\profile.xml" -pushd "%EnvMSYSPath%\bin" -mingw-get.exe install mingw32-mingw-get -mingw-get.exe install msys-coreutils -mingw-get.exe install msys-base -mingw-get.exe install msys-autoconf -mingw-get.exe install msys-automake -mingw-get.exe install msys-autogen -mingw-get.exe install msys-mktemp -rem Use own wget binary, because MSYS version of wget is to old -rem mingw-get.exe install msys-wget -popd - -%cecho% info "Unpack CMake" -"%EnvSevenZipExe%" x -o"%CMakeUnpackPath%" "%EnvDownloadPath%\%CMakeInstall%" - -%cecho% info "Install CMake" -set CMakeVersion= -for /D %%F in (%CMakeUnpackPath%\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%" "%EnvMSYSPath%\msys\1.0\etc\profile"') do set FoundProfile=%%F - -if "%FoundProfile%"=="0" ( - echo export PATH="${PATH}:/%CMakeVersion%/bin">>"%EnvMSYSPath%\msys\1.0\etc\profile" -) - -:exit -endlocal -exit /B 0 - -:error -endlocal -exit /B 1 diff --git a/build_scripts/Windows/env/tools/prepare-msys2.bat b/build_scripts/Windows/env/tools/prepare-msys2.bat new file mode 100644 index 000000000..80d17521f --- /dev/null +++ b/build_scripts/Windows/env/tools/prepare-msys2.bat @@ -0,0 +1,85 @@ +:: Usage: +:: call prepare-msys2.bat [reinstall|clean] + +setlocal enabledelayedexpansion + +if "%EnvMSYS2Path%"=="" exit /B 1 +if "%MSYS2Architecture%"=="" exit /B 1 +if "%MSYS2Base%"=="" exit /B 1 +if not exist "%EnvRootPath%"=="" exit /B 1 + +copy "%~dp0root\update-msys2.bat" "%EnvRootPath%" >nul + +if "%~1"=="clean" ( + %cecho% info "Clean MSYS2" + call "%ToolsPath%\remove-dir.bat" "%EnvMSYS2Path%" + goto exit +) + +if exist "%EnvMSYS2Path%\msys%MSYS2Base%\usr\bin\pacman.exe" ( + if "%~1"=="reinstall" ( + choice /M "Found existing MSYS2 version. Do you want to proceed?" + if !ERRORLEVEL!==2 goto exit + ) else ( + goto exit + ) +) + +set MSYS2Install=msys2-base-%MSYS2Architecture%-20190524.tar.xz +set MSYS2Url=http://sourceforge.net/projects/msys2/files/Base/%MSYS2Architecture%/%MSYS2Install%/download +set CMakeInstall=cmake-3.1.0-win32-x86.zip +set CMakeUrl=http://www.cmake.org/files/v3.1/%CMakeInstall% +set CMakeUnpackPath=%EnvMSYS2Path%\msys%MSYS2Base% + +if exist "%EnvMSYS2Path%\msys%MSYS2Base%" ( + %cecho% info "Remove previous MSYS2 version" + call "%ToolsPath%\remove-dir.bat" "%EnvMSYS2Path%\msys%MSYS2Base%" +) + +%cecho% info "Download 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 + +if not exist "%EnvDownloadPath%\%CMakeInstall%" call "%ToolsPath%\download-file.bat" "%CMakeUrl%" "%EnvDownloadPath%\%CMakeInstall%" +if not exist "%EnvDownloadPath%\%CMakeInstall%" %cecho% error "Cannot download CMake" & goto error + +%cecho% info "Unpack MSYS2" +"%EnvSevenZipExe%" x -so "%EnvDownloadPath%\%MSYS2Install%" | "%EnvSevenZipExe%" x -y -si -ttar -o"%EnvMSYS2Path%" + +%cecho% info "Unpack CMake" +"%EnvSevenZipExe%" x -o"%CMakeUnpackPath%" "%EnvDownloadPath%\%CMakeInstall%" + +%cecho% info "Install CMake" +set CMakeVersion= +for /D %%F in (%CMakeUnpackPath%\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%" "%EnvMSYS2Path%\msys%MSYS2Base%\etc\profile"') do set FoundProfile=%%F + +if "%FoundProfile%"=="0" ( + echo export PATH="${PATH}:/%CMakeVersion%/bin">>"%EnvMSYS2Path%\msys%MSYS2Base%\etc\profile" +) + +set MSYS2SH=%EnvMSYS2Path%\msys%MSYS2Base%\usr\bin\sh + +%cecho% info "Update keyring" +"%MSYS2SH%" -lc "curl -O http://repo.msys2.org/msys/x86_64/msys2-keyring-r21.b39fb11-1-any.pkg.tar.xz" +"%MSYS2SH%" -lc "pacman --noconfirm -U msys2-keyring-r21.b39fb11-1-any.pkg.tar.xz" + +%cecho% info "Initialize MSYS2" +"%MSYS2SH%" -lc "pacman -Sy" +"%MSYS2SH%" -lc "pacman --noconfirm --needed -S bash pacman pacman-mirrors msys2-runtime" + +call "%EnvMSYS2Path%\msys%MSYS2Base%\autorebase.bat" +call "%EnvRootPath%\update-msys2.bat" +call "%EnvRootPath%\update-msys2.bat" + +:exit +endlocal +exit /B 0 + +:error +endlocal +exit /B 1 diff --git a/build_scripts/Windows/env/tools/prepare-qt.bat b/build_scripts/Windows/env/tools/prepare-qt.bat deleted file mode 100644 index c2593f48d..000000000 --- a/build_scripts/Windows/env/tools/prepare-qt.bat +++ /dev/null @@ -1,204 +0,0 @@ -:: Usage: -:: call prepare-qt.bat version [reinstall|clean] - -setlocal enabledelayedexpansion - -if "%EnvQtBasePath%"=="" exit /B 1 -if not exist "%EnvRootPath%"=="" exit /B 1 - -set EnvQtVersion=%~1 -if "%EnvQtVersion%"=="" ( - %cecho% error "Please specify Qt version" - goto error -) - -for /f "tokens=1,2 delims=." %%A in ("%EnvQtVersion%") do set EnvQtMainVersion=%%A& set EnvQtBaseVersion=%%A.%%B -set EnvQtPath=%EnvQtBasePath%\%EnvQtVersion% - -if "%~2"=="clean" ( - %cecho% info "Clean Qt %EnvQtVersion%" - call "%ToolsPath%\remove-dir.bat" "%EnvQtPath%" - goto exit -) - -set CheckQmakeExe= -if "%EnvQtMainVersion%"=="4" ( - set CheckQmakeExe=%EnvQtPath%\Qt\bin\qmake.exe -) else ( - if "%EnvQtMainVersion%" GEQ "5" ( - call :get_mingw_version EnvQtMinGWVersion "%EnvQtPath%\%EnvQtBaseVersion%" - if "!EnvQtMinGWVersion!" NEQ "" ( - set CheckQmakeExe=%EnvQtPath%\%EnvQtBaseVersion%\!EnvQtMinGWVersion!\bin\qmake.exe - ) - ) -) - -if "%CheckQmakeExe%" NEQ "" ( - if exist "%CheckQmakeExe%" ( - if "%~2"=="reinstall" ( - choice /M "Found existing Qt %EnvQtVersion% version. Do you want to proceed?" - if !ERRORLEVEL!==2 goto exit - ) else ( - goto exit - ) - ) -) - -set QtInstall=qt-opensource-windows-x86-mingw-%EnvQtVersion%.exe -set QtInstallWildcard=qt-opensource-windows-x86-mingw*-%EnvQtVersion%.exe -set QtUrl=http://download.qt.io/official_releases/qt/%EnvQtBaseVersion%/%EnvQtVersion% - -%cecho% info "Remove previous Qt %EnvQtVersion% version" -call "%ToolsPath%\remove-dir.bat" "%EnvQtPath%" - -%cecho% info "Download Qt installation files" -if not exist "%EnvDownloadPath%\%QtInstall%" ( - call "%ToolsPath%\download-file-wildcard.bat" "%QtUrl%" "%QtInstallWildcard%" "%EnvDownloadPath%" QtInstallDownload - if "!QtInstallDownload!"=="" %cecho% error "Cannot download Qt %EnvQtVersion%" & goto error - ren "%EnvDownloadPath%\!QtInstallDownload!" "%QtInstall%" -) -if not exist "%EnvDownloadPath%\%QtInstall%" %cecho% error "Cannot download Qt %EnvQtVersion%" & goto error - -mkdir "%EnvQtPath%" - -if "%EnvQtMainVersion%"=="4" ( - rem Qt 4 - goto install_qt4 -) -if "%EnvQtMainVersion%" GEQ "5" ( - rem Qt >= 5 - goto install_qt5 -) - -%cecho% error "Unknown Qt version %EnvQtVersion%" - -:error -endlocal & set QtDir=& set MinGWDir= -exit /B 1 - -:exit -set QtDir= -set MinGWDir= - -if "%EnvQtMainVersion%"=="4" ( - rem Qt 4 - set QtDir=%EnvQtBasePath%\%EnvQtVersion%\Qt - set MinGWDir=%EnvQtBasePath%\%EnvQtVersion%\mingw32 -) else ( - if "%EnvQtMainVersion%" GEQ "5" ( - call :get_mingw_version EnvQtToolsMinGWVersion "%EnvQtPath%\Tools" - - set QtDir=%EnvQtPath%\%EnvQtBaseVersion%\!EnvQtMinGWVersion! - set MinGWDir=%EnvQtPath%\Tools\!EnvQtToolsMinGWVersion! - ) -) - -endlocal & set QtDir=%QtDir%& set MinGWDir=%MinGWDir% -exit /B 0 - -:get_mingw_version -setlocal enabledelayedexpansion -set Variable=%~1 -set Result= - -for /D %%A in (%~2\*) do set Name=%%~nA& if "!Name:~0,5!"=="mingw" set Result=!Name! -endlocal & set %Variable%=%Result% -goto :EOF - -:replace -set InFile=%~1 -set InFileName=%~nx1 -set OutFile=%~1.tmp -set SearchText=%~2 -set ReplaceText=%~3 - -if exist "%OutFile%" del /Q "%OutFile%" - -for /f "tokens=1* delims=]" %%A in ('find /n /v ""^<%InFile%') do ( - set string=%%B - - if "!string!"=="" ( - echo.>>%OutFile% - ) else ( - set modified=!string:%SearchText%=%ReplaceText%! - echo !modified!>> %OutFile% - ) -) -del "%InFile%" -rename "%OutFile%" "%InFileName%" -goto :EOF - -:install_qt4 -set MinGWInstall=i686-4.8.2-release-posix-dwarf-rt_v3-rev3.7z -set MinGWUrl=http://sourceforge.net/projects/mingw-w64/files/Toolchains targetting Win32/Personal Builds/mingw-builds/4.8.2/threads-posix/dwarf/%MinGWInstall%/download - -%cecho% info "Download MinGW installation files" -if not exist "%EnvDownloadPath%\%MinGWInstall%" call "%ToolsPath%\download-file.bat" "%MinGWUrl%" "%EnvDownloadPath%\%MinGWInstall%" -if not exist "%EnvDownloadPath%\%MinGWInstall%" %cecho% error "Cannot download MinGW" & goto error - -%cecho% info "Unpack Qt %EnvQtVersion%" -call "%ToolsPath%\remove-dir.bat" "%EnvTempPath%" -mkdir "%EnvTempPath%" -"%EnvSevenZipExe%" x -o"%EnvTempPath%" "%EnvDownloadPath%\%QtInstall%" $_14_ -move "%EnvTempPath%\$_14_" "%EnvQtPath%\Qt" -call "%ToolsPath%\remove-dir.bat" "%EnvTempPath%" - -%cecho% info "Unpack MinGW" -"%EnvSevenZipExe%" x -o"%EnvQtPath%" "%EnvDownloadPath%\%MinGWInstall%" - -echo Prepare Qt %EnvQtVersion% -echo [Paths]>"%EnvQtPath%\Qt\bin\qt.conf" -echo Prefix=..>>"%EnvQtPath%\Qt\bin\qt.conf" - -goto exit - -:install_qt5 -set EnvQtInstallerFrameworkVersion=2.0.3 - -set QtInstallerFrameworkInstall=QtInstallerFramework-%EnvQtInstallerFrameworkVersion%-win-x86.exe -set QtInstallerFrameworkUrl=http://download.qt.io/official_releases/qt-installer-framework/%EnvQtInstallerFrameworkVersion%/QtInstallerFramework-win-x86.exe - -%cecho% info "Download QtInstallerFramework installation files" -if not exist "%EnvDownloadPath%\%QtInstallerFrameworkInstall%" call "%ToolsPath%\download-file.bat" "%QtInstallerFrameworkUrl%" "%EnvDownloadPath%\%QtInstallerFrameworkInstall%" -if not exist "%EnvDownloadPath%\%QtInstallerFrameworkInstall%" %cecho% error "Cannot download Qt Installer Framework %EnvQtInstallerFrameworkVersion%" & goto error - -%cecho% info "Unpack Qt Installer Framework" -call "%ToolsPath%\remove-dir.bat" "%EnvTempPath%" -mkdir "%EnvTempPath%" -"%EnvSevenZipExe%" x -o"%EnvTempPath%" "%EnvDownloadPath%\%QtInstallerFrameworkInstall%" bin\devtool.exe -move "%EnvTempPath%\bin\devtool.exe" "%EnvQtPath%" -call "%ToolsPath%\remove-dir.bat" "%EnvTempPath%" - -%cecho% info "Unpack Qt %EnvQtVersion%" -call "%ToolsPath%\remove-dir.bat" "%EnvTempPath%" -mkdir "%EnvTempPath%" -"%EnvQtPath%\devtool.exe" "%EnvDownloadPath%\%QtInstall%" --dump "%EnvTempPath%" - -pushd "%EnvTempPath%" -del /S *vcredist*.7z -del /S *qtcreator*.7z -del /S *1installer-changelog.7z -for /R %%F in (*.7z) do "%EnvSevenZipExe%" x -y -o"%EnvQtPath%" "%%F" -popd - -call "%ToolsPath%\remove-dir.bat" "%EnvTempPath%" - -call :get_mingw_version EnvQtMinGWVersion "%EnvQtPath%\%EnvQtBaseVersion%" - -%cecho% info "Prepare Qt %EnvQtVersion%" -echo [Paths]>"%EnvQtPath%\%EnvQtBaseVersion%\%EnvQtMinGWVersion%\bin\qt.conf" -echo Documentation=../../Docs/Qt-%EnvQtBaseVersion%>>"%EnvQtPath%\%EnvQtBaseVersion%\%EnvQtMinGWVersion%\bin\qt.conf" -echo Examples=../../Examples/Qt-%EnvQtBaseVersion%>>"%EnvQtPath%\%EnvQtBaseVersion%\%EnvQtMinGWVersion%\bin\qt.conf" -echo Prefix=..>>"%EnvQtPath%\%EnvQtBaseVersion%\%EnvQtMinGWVersion%\bin\qt.conf" - -call :replace "%EnvQtPath%\%EnvQtBaseVersion%\%EnvQtMinGWVersion%\mkspecs\qconfig.pri" "Enterprise" "OpenSource" - -for /R "%EnvQtPath%\%EnvQtBaseVersion%\%EnvQtMinGWVersion%\lib" %%A in (*.pc) do ( - call :replace "%%A" "c:/Users/qt/work/install" "%EnvQtPath:\=\\%\%EnvQtBaseVersion%\\%EnvQtMinGWVersion%" - call :replace "%%A" "c:\Users\qt\work\install" "%EnvQtPath:\=/%\%EnvQtBaseVersion%/%EnvQtMinGWVersion%" -) -for /R "%EnvQtPath%\%EnvQtBaseVersion%\%EnvQtMinGWVersion%\lib" %%A in (*.prl) do ( - call :replace "%%A" "c:/Users/qt/work/install" "%EnvQtPath:\=\\%\%EnvQtBaseVersion%\\%EnvQtMinGWVersion%" - call :replace "%%A" "c:\Users\qt\work\install" "%EnvQtPath:\=/%\%EnvQtBaseVersion%/%EnvQtMinGWVersion%" -) -goto exit diff --git a/build_scripts/Windows/env/tools/prepare-tools.bat b/build_scripts/Windows/env/tools/prepare-tools.bat index e8bc7a951..8b48d7c32 100644 --- a/build_scripts/Windows/env/tools/prepare-tools.bat +++ b/build_scripts/Windows/env/tools/prepare-tools.bat @@ -4,36 +4,24 @@ if "%EnvRootPath%"=="" exit /B 1 set CEchoUrl=https://github.com/lordmulder/cecho/releases/download/2015-10-10/cecho.2015-10-10.zip set CEchoInstall=cecho.2015-10-10.zip -set SevenZipUrl=https://sourceforge.net/projects/sevenzip/files/7-Zip/18.05/7z1805.msi/download -set SevenZipInstall=7z1805.msi -::set CurlUrl=https://bintray.com/artifact/download/vszakats/generic/curl-7.50.1-win32-mingw.7z -::set CurlInstall=curl-7.50.1-win32-mingw.7z -set WgetUrl=https://eternallybored.org/misc/wget/1.19.4/32/wget.exe -set WgetInstall=wget.exe -set JomUrl=http://download.qt.io/official_releases/jom/jom.zip -set JomInstall=jom.zip +set SevenZipUrl=https://sourceforge.net/projects/sevenzip/files/7-Zip/19.00/7z1900.msi/download +set SevenZipInstall=7z1900.msi set DependsUrl=http://www.dependencywalker.com/depends22_x86.zip set DependsInstall=depends22_x86.zip set UnixToolsUrl=http://unxutils.sourceforge.net/UnxUpdates.zip set UnixToolsInstall=UnxUpdates.zip -set NSISUrl=http://prdownloads.sourceforge.net/nsis/nsis-3.0-setup.exe?download -set NSISInstall=nsis-3.0-setup.exe +set NSISInstall=nsis-3.05-setup.exe +set NSISUrl=http://prdownloads.sourceforge.net/nsis/%NSISInstall%?download set NSISInstallPath=%EnvToolsPath%\NSIS -set MinGitInstall=MinGit-2.19.1-32-bit.zip -set MinGitUrl=https://github.com/git-for-windows/git/releases/download/v2.19.1.windows.1/%MinGitInstall% +set MinGitInstall=MinGit-2.28.0-32-bit.zip +set MinGitUrl=https://github.com/git-for-windows/git/releases/download/v2.28.0.windows.1/%MinGitInstall% set MinGitInstallPath=%EnvToolsPath%\MinGit -set SigcheckInstall=Sigcheck.zip -set SigcheckUrl=https://download.sysinternals.com/files/%SigcheckInstall% - -if not exist "%EnvToolsPath%\wget.exe" ( - echo Download Wget installation - - if not exist "%EnvDownloadPath%\%WgetInstall%" call "%ToolsPath%\winhttpjs.bat" %WgetUrl% -saveTo "%EnvDownloadPath%\%WgetInstall%" - if not exist "%EnvDownloadPath%\%WgetInstall%" %cecho% error "Cannot download Wget installation" & goto error - - echo Copy Wget - copy "%EnvDownloadPath%\wget.exe" "%EnvToolsPath%" -) +set CMakeVersion=cmake-3.1.0-win32-x86 +set CMakeInstall=%CMakeVersion%.zip +set CMakeUrl=http://www.cmake.org/files/v3.1/%CMakeInstall% +set CMakeInstallPath=%EnvToolsPath%\cmake +set TorProjectUrl=https://www.torproject.org +set TorDownloadIndexUrl=%TorProjectUrl%/download/tor if not exist "%EnvToolsPath%\7z.exe" ( call "%ToolsPath%\remove-dir.bat" "%EnvTempPath%" @@ -68,45 +56,13 @@ if not exist "%EnvToolsPath%\cecho.exe" ( call "%ToolsPath%\remove-dir.bat" "%EnvTempPath%" ) -::if not exist "%EnvToolsPath%\curl.exe" ( -:: call "%ToolsPath%\remove-dir.bat" "%EnvTempPath%" -:: mkdir "%EnvTempPath%" -:: -:: echo Download Curl installation -:: -:: if not exist "%EnvDownloadPath%\%CurlInstall%" call "%ToolsPath%\winhttpjs.bat" %CurlUrl% -saveTo "%EnvDownloadPath%\%CurlInstall%" -:: if not exist "%EnvDownloadPath%\%CurlInstall%" echo Cannot download Curl installation& goto error -:: -:: echo Unpack Curl -:: "%EnvSevenZipExe%" x -o"%EnvTempPath%" "%EnvDownloadPath%\%CurlInstall%" -:: copy "%EnvTempPath%\curl-7.50.1-win32-mingw\bin\curl.exe" "%EnvToolsPath%" -:: -:: call "%ToolsPath%\remove-dir.bat" "%EnvTempPath%" -::) - -if not exist "%EnvToolsPath%\jom.exe" ( - call "%ToolsPath%\remove-dir.bat" "%EnvTempPath%" - mkdir "%EnvTempPath%" - - %cecho% info "Download jom installation" - - if not exist "%EnvDownloadPath%\%JomInstall%" call "%ToolsPath%\winhttpjs.bat" %JomUrl% -saveTo "%EnvDownloadPath%\%JomInstall%" - if not exist "%EnvDownloadPath%\%JomInstall%" %cecho% error "Cannot download jom installation" & goto error - - %cecho% info "Unpack jom" - "%EnvSevenZipExe%" x -o"%EnvTempPath%" "%EnvDownloadPath%\%JomInstall%" - copy "%EnvTempPath%\jom.exe" "%EnvToolsPath%" - - call "%ToolsPath%\remove-dir.bat" "%EnvTempPath%" -) - if not exist "%EnvToolsPath%\depends.exe" ( call "%ToolsPath%\remove-dir.bat" "%EnvTempPath%" mkdir "%EnvTempPath%" %cecho% info "Download Dependency Walker installation" - if not exist "%EnvDownloadPath%\%DependsInstall%" call "%ToolsPath%\winhttpjs.bat" %DependsUrl% -saveTo "%EnvDownloadPath%\%DependsInstall%" + if not exist "%EnvDownloadPath%\%DependsInstall%" call "%ToolsPath%\download-file.bat" %DependsUrl% "%EnvDownloadPath%\%DependsInstall%" if not exist "%EnvDownloadPath%\%DependsInstall%" %cecho% error "Cannot download Dependendy Walker installation" & goto error %cecho% info "Unpack Dependency Walker" @@ -122,7 +78,7 @@ if not exist "%EnvToolsPath%\cut.exe" ( %cecho% info "Download Unix Tools installation" - if not exist "%EnvDownloadPath%\%UnixToolsInstall%" call "%ToolsPath%\winhttpjs.bat" %UnixToolsUrl% -saveTo "%EnvDownloadPath%\%UnixToolsInstall%" + if not exist "%EnvDownloadPath%\%UnixToolsInstall%" call "%ToolsPath%\download-file.bat" %UnixToolsUrl% "%EnvDownloadPath%\%UnixToolsInstall%" if not exist "%EnvDownloadPath%\%UnixToolsInstall%" %cecho% error "Cannot download Unix Tools installation" & goto error %cecho% info "Unpack Unix Tools" @@ -138,7 +94,7 @@ if not exist "%EnvToolsPath%\sed.exe" ( %cecho% info "Download Unix Tools installation" - if not exist "%EnvDownloadPath%\%UnixToolsInstall%" call "%ToolsPath%\winhttpjs.bat" %UnixToolsUrl% -saveTo "%EnvDownloadPath%\%UnixToolsInstall%" + if not exist "%EnvDownloadPath%\%UnixToolsInstall%" call "%ToolsPath%\download-file.bat" %UnixToolsUrl% "%EnvDownloadPath%\%UnixToolsInstall%" if not exist "%EnvDownloadPath%\%UnixToolsInstall%" %cecho% error "Cannot download Unix Tools installation" & goto error %cecho% info "Unpack Unix Tools" @@ -148,8 +104,12 @@ if not exist "%EnvToolsPath%\sed.exe" ( call "%ToolsPath%\remove-dir.bat" "%EnvTempPath%" ) +if not exist "%EnvDownloadPath%\%NSISInstall%" call "%ToolsPath%\remove-dir.bat" "%NSISInstallPath%" if not exist "%NSISInstallPath%\nsis.exe" ( call "%ToolsPath%\remove-dir.bat" "%EnvTempPath%" + + if exist "%NSISInstallPath%" call "%ToolsPath%\remove-dir.bat" "%NSISInstallPath%" + mkdir "%EnvTempPath%" %cecho% info "Download NSIS installation" @@ -175,14 +135,45 @@ if not exist "%MinGitInstallPath%\cmd\git.exe" ( "%EnvSevenZipExe%" x -o"%MinGitInstallPath%" "%EnvDownloadPath%\%MinGitInstall%" ) -if not exist "%EnvToolsPath%\sigcheck.exe" ( - %cecho% info "Download Sigcheck installation" +if not exist "%EnvDownloadPath%\%CMakeInstall%" call "%ToolsPath%\remove-dir.bat" "%CMakeInstallPath%" +if not exist "%CMakeInstallPath%\bin\cmake.exe" ( + %cecho% info "Download CMake installation" - if not exist "%EnvDownloadPath%\%SigcheckInstall%" call "%ToolsPath%\download-file.bat" "%SigcheckUrl%" "%EnvDownloadPath%\%SigcheckInstall%" - if not exist "%EnvDownloadPath%\%SigcheckInstall%" %cecho% error "Cannot download Sigcheck installation" & goto error + if exist "%CMakeInstallPath%" call "%ToolsPath%\remove-dir.bat" "%CMakeInstallPath%" - %cecho% info "Unpack Sigcheck" - "%EnvSevenZipExe%" x -o"%EnvToolsPath%" "%EnvDownloadPath%\%SigcheckInstall%" sigcheck.exe + mkdir "%EnvTempPath%" + + if not exist "%EnvDownloadPath%\%CMakeInstall%" call "%ToolsPath%\download-file.bat" "%CMakeUrl%" "%EnvDownloadPath%\%CMakeInstall%" + if not exist "%EnvDownloadPath%\%CMakeInstall%" %cecho% error "Cannot download CMake installation" & goto error + + %cecho% info "Unpack CMake" + "%EnvSevenZipExe%" x -o"%EnvTempPath%" "%EnvDownloadPath%\%CMakeInstall%" + + move "%EnvTempPath%\%CMakeVersion%" "%CMakeInstallPath%" + + call "%ToolsPath%\remove-dir.bat" "%EnvTempPath%" +) + +rem Tor +rem Get download link and filename from download page +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-win32.*\.zip^)\".*/\2 \1\2/p" "%EnvTempPath%\index.html"') do set TorInstall=%%A& set TorDownloadUrl=%TorProjectUrl%%%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 + +if not exist "%EnvDownloadPath%\%TorInstall%" call "%ToolsPath%\remove-dir.bat" "%EnvTorPath%" +if not exist "%EnvTorPath%\Tor\tor.exe" ( + %cecho% info "Download Tor installation" + + if not exist "%EnvDownloadPath%\%TorInstall%" call "%ToolsPath%\download-file.bat" "%TorDownloadUrl%" "%EnvDownloadPath%\%TorInstall%" + if not exist "%EnvDownloadPath%\%TorInstall%" %cecho% error "Cannot download Tor installation" & goto error + + %cecho% info "Unpack Tor" + "%EnvSevenZipExe%" x -o"%EnvTorPath%" "%EnvDownloadPath%\%TorInstall%" ) :exit @@ -190,5 +181,6 @@ endlocal exit /B 0 :error +call "%ToolsPath%\remove-dir.bat" "%EnvTempPath%" endlocal exit /B 1 diff --git a/build_scripts/Windows/env/tools/root/update-msys.bat b/build_scripts/Windows/env/tools/root/update-msys.bat deleted file mode 100644 index b0a109d01..000000000 --- a/build_scripts/Windows/env/tools/root/update-msys.bat +++ /dev/null @@ -1,15 +0,0 @@ -@echo off - -setlocal - -set MSYSPath=%~dp0msys - -if not exist "%MSYSPath%\bin\mingw-get.exe" echo MSYS is not installed& exit /B 0 - -echo Update MSYS -pushd "%MSYSPath%\bin" -mingw-get.exe update -mingw-get.exe upgrade -popd - -exit /B %ERRORLEVEL% diff --git a/build_scripts/Windows/env/tools/root/update-msys2.bat b/build_scripts/Windows/env/tools/root/update-msys2.bat new file mode 100644 index 000000000..3075e392b --- /dev/null +++ b/build_scripts/Windows/env/tools/root/update-msys2.bat @@ -0,0 +1,19 @@ +@echo off + +setlocal + +if exist "%~dp0msys2\msys32" call :update 32 +if exist "%~dp0msys2\msys64" call :update 64 + +goto :EOF + +:update +set MSYSSH=%~dp0msys2\msys%~1\usr\bin\sh + +echo Update MSYS2 %~1 +"%MSYSSH%" -lc "pacman -Sy" +"%MSYSSH%" -lc "pacman --noconfirm -Su" + +:exit +endlocal +goto :EOF diff --git a/build_scripts/Windows/installer/lang/ca_ES.nsh b/build_scripts/Windows/installer/lang/ca_ES.nsh index acb11b5a4..74f92ffe5 100644 --- a/build_scripts/Windows/installer/lang/ca_ES.nsh +++ b/build_scripts/Windows/installer/lang/ca_ES.nsh @@ -1,5 +1,7 @@ !insertmacro LANG_STRING Section_Main "${APPNAME}" !insertmacro LANG_STRING Section_Main_Desc "Instal·la ${APPNAME} i els components necessaris." +!insertmacro LANG_STRING Section_Tor "Tor" +!insertmacro LANG_STRING Section_Tor_Desc "Installs Tor." !insertmacro LANG_STRING Section_Data "Pells" !insertmacro LANG_STRING Section_Data_Desc "Instal·la pells." !insertmacro LANG_STRING Section_Shortcuts "Icones d'accés directe" diff --git a/build_scripts/Windows/installer/lang/de.nsh b/build_scripts/Windows/installer/lang/de.nsh index c5323f523..663e9e786 100644 --- a/build_scripts/Windows/installer/lang/de.nsh +++ b/build_scripts/Windows/installer/lang/de.nsh @@ -1,5 +1,7 @@ !insertmacro LANG_STRING Section_Main "${APPNAME}" !insertmacro LANG_STRING Section_Main_Desc "Installiert ${APPNAME} und die benötigten Komponenten." +!insertmacro LANG_STRING Section_Tor "Tor" +!insertmacro LANG_STRING Section_Tor_Desc "Installiert Tor." !insertmacro LANG_STRING Section_Data "Skins" !insertmacro LANG_STRING Section_Data_Desc "Skins installieren." !insertmacro LANG_STRING Section_Shortcuts "Verknüpfungssymbole" diff --git a/build_scripts/Windows/installer/lang/en.nsh b/build_scripts/Windows/installer/lang/en.nsh index b01f43baa..a709eec24 100644 --- a/build_scripts/Windows/installer/lang/en.nsh +++ b/build_scripts/Windows/installer/lang/en.nsh @@ -1,5 +1,7 @@ !insertmacro LANG_STRING Section_Main "${APPNAME}" !insertmacro LANG_STRING Section_Main_Desc "Installs ${APPNAME} and required components." +!insertmacro LANG_STRING Section_Tor "Tor" +!insertmacro LANG_STRING Section_Tor_Desc "Installs Tor." !insertmacro LANG_STRING Section_Data "Skins" !insertmacro LANG_STRING Section_Data_Desc "Installs skins." !insertmacro LANG_STRING Section_Shortcuts "Shortcut icons" diff --git a/build_scripts/Windows/installer/lang/es.nsh b/build_scripts/Windows/installer/lang/es.nsh index 68900ec62..66021c14e 100644 --- a/build_scripts/Windows/installer/lang/es.nsh +++ b/build_scripts/Windows/installer/lang/es.nsh @@ -1,5 +1,7 @@ !insertmacro LANG_STRING Section_Main "${APPNAME}" !insertmacro LANG_STRING Section_Main_Desc "Instala ${APPNAME} y los componentes requeridos." +!insertmacro LANG_STRING Section_Tor "Tor" +!insertmacro LANG_STRING Section_Tor_Desc "Installs Tor." !insertmacro LANG_STRING Section_Data "Coberturas (skins)" !insertmacro LANG_STRING Section_Data_Desc "Instalar coberturas" !insertmacro LANG_STRING Section_Shortcuts "Iconos de accesos directos" diff --git a/build_scripts/Windows/installer/lang/fr.nsh b/build_scripts/Windows/installer/lang/fr.nsh index d4c797833..680746da0 100644 --- a/build_scripts/Windows/installer/lang/fr.nsh +++ b/build_scripts/Windows/installer/lang/fr.nsh @@ -1,5 +1,7 @@ !insertmacro LANG_STRING Section_Main "${APPNAME}" !insertmacro LANG_STRING Section_Main_Desc "Installe ${APPNAME} et les composants requis." +!insertmacro LANG_STRING Section_Tor "Tor" +!insertmacro LANG_STRING Section_Tor_Desc "Installs Tor." !insertmacro LANG_STRING Section_Data "Habillages" !insertmacro LANG_STRING Section_Data_Desc "Installe des habillages." !insertmacro LANG_STRING Section_Shortcuts "Icônes de raccourci" diff --git a/build_scripts/Windows/installer/lang/pl.nsh b/build_scripts/Windows/installer/lang/pl.nsh index 9f6d4305e..53fc42934 100644 --- a/build_scripts/Windows/installer/lang/pl.nsh +++ b/build_scripts/Windows/installer/lang/pl.nsh @@ -1,5 +1,7 @@ !insertmacro LANG_STRING Section_Main "${APPNAME}" !insertmacro LANG_STRING Section_Main_Desc "Instaluje ${APPNAME} oraz wymagane komponenty." +!insertmacro LANG_STRING Section_Tor "Tor" +!insertmacro LANG_STRING Section_Tor_Desc "Installs Tor." !insertmacro LANG_STRING Section_Data "Skórki" !insertmacro LANG_STRING Section_Data_Desc "Instaluje skórki." !insertmacro LANG_STRING Section_Shortcuts "Ikony skrótów" diff --git a/build_scripts/Windows/installer/lang/ru.nsh b/build_scripts/Windows/installer/lang/ru.nsh index 09c578cb8..b8ba2df89 100644 --- a/build_scripts/Windows/installer/lang/ru.nsh +++ b/build_scripts/Windows/installer/lang/ru.nsh @@ -1,5 +1,7 @@ !insertmacro LANG_STRING Section_Main "${APPNAME}" !insertmacro LANG_STRING Section_Main_Desc "Установка ${APPNAME} и необходимых компонентов." +!insertmacro LANG_STRING Section_Tor "Tor" +!insertmacro LANG_STRING Section_Tor_Desc "Installs Tor." !insertmacro LANG_STRING Section_Data "Оболочки" !insertmacro LANG_STRING Section_Data_Desc "Установка оболочек." !insertmacro LANG_STRING Section_Shortcuts "Ярлыки" diff --git a/build_scripts/Windows/installer/lang/tr.nsh b/build_scripts/Windows/installer/lang/tr.nsh index f893ac076..85abeaac2 100644 --- a/build_scripts/Windows/installer/lang/tr.nsh +++ b/build_scripts/Windows/installer/lang/tr.nsh @@ -1,5 +1,7 @@ !insertmacro LANG_STRING Section_Main "${APPNAME}" !insertmacro LANG_STRING Section_Main_Desc "${APPNAME} ve gerekli bileşenleri kurar." +!insertmacro LANG_STRING Section_Tor "Tor" +!insertmacro LANG_STRING Section_Tor_Desc "Installs Tor." !insertmacro LANG_STRING Section_Data "Temalar" !insertmacro LANG_STRING Section_Data_Desc "Tema yükleyin." !insertmacro LANG_STRING Section_Shortcuts "Kısayol simgeleri" diff --git a/build_scripts/Windows/installer/lang/ts/en.ts b/build_scripts/Windows/installer/lang/ts/en.ts index 763636d3d..e95f6939f 100644 --- a/build_scripts/Windows/installer/lang/ts/en.ts +++ b/build_scripts/Windows/installer/lang/ts/en.ts @@ -8,6 +8,20 @@ + + Section_Tor + + Tor + + + + + Section_Tor_Desc + + Installs Tor. + + + Section_Data diff --git a/build_scripts/Windows/installer/lang/zh_CN.nsh b/build_scripts/Windows/installer/lang/zh_CN.nsh index 1075f7a1a..330de33ab 100644 --- a/build_scripts/Windows/installer/lang/zh_CN.nsh +++ b/build_scripts/Windows/installer/lang/zh_CN.nsh @@ -1,5 +1,7 @@ !insertmacro LANG_STRING Section_Main "${APPNAME}" !insertmacro LANG_STRING Section_Main_Desc "Installs ${APPNAME} and required components." +!insertmacro LANG_STRING Section_Tor "Tor" +!insertmacro LANG_STRING Section_Tor_Desc "Installs Tor." !insertmacro LANG_STRING Section_Data "皮肤" !insertmacro LANG_STRING Section_Data_Desc "安装皮肤" !insertmacro LANG_STRING Section_Shortcuts "快捷方式图标" diff --git a/build_scripts/Windows/installer/retroshare-Qt5.nsi b/build_scripts/Windows/installer/retroshare-Qt5.nsi index 99a3c7804..ba4f3d0d2 100644 --- a/build_scripts/Windows/installer/retroshare-Qt5.nsi +++ b/build_scripts/Windows/installer/retroshare-Qt5.nsi @@ -22,6 +22,9 @@ !ifndef MINGWDIR !error "MINGWDIR is not defined" !endif +!ifndef ARCHITECTURE +!error "Architecture is not defined" +!endif # Check optional defines !ifdef OUTDIR @@ -53,7 +56,17 @@ !endif # Date -!define /date Date "%Y%m%d" +!ifndef DATE +!define /date DATE "%Y%m%d" +!endif + +# Tor +!ifdef TORDIR +${!defineifexist} TOR_EXISTS "${TORDIR}\tor.exe" +!ifndef TOR_EXISTS +!error "tor.exe not found" +!endif +!endif # Application name and version !define APPNAME "RetroShare" @@ -61,7 +74,12 @@ !define PUBLISHER "RetroShare Team" # Install path -!define INSTDIR_NORMAL "$ProgramFiles\${APPNAME}" +!if ${ARCHITECTURE} == "x86" + !define INSTDIR_NORMAL "$ProgramFiles32\${APPNAME}" +!endif +!if ${ARCHITECTURE} == "x64" + !define INSTDIR_NORMAL "$ProgramFiles64\${APPNAME}" +!endif !define INSTDIR_PORTABLE "$Desktop\${APPNAME}" !define DATADIR_NORMAL "$APPDATA\${APPNAME}" @@ -70,7 +88,7 @@ # Main Install settings Name "${APPNAMEANDVERSION}" InstallDirRegKey HKLM "Software\${APPNAME}" "" -OutFile "${OUTDIR_}RetroShare-${VERSION}-${Date}-${REVISION}-Qt-${QTVERSION}${INSTALLERADD}-setup.exe" +OutFile "${OUTDIR_}RetroShare-${VERSION}-${DATE}-${REVISION}-Qt-${QTVERSION}-${ARCHITECTURE}${INSTALLERADD}-setup.exe" BrandingText "${APPNAMEANDVERSION}" RequestExecutionlevel highest # Use compression @@ -104,7 +122,7 @@ Var StyleSheetDir !define MUI_FINISHPAGE_RUN "$INSTDIR\retroshare.exe" !define MUI_FINISHPAGE_SHOWREADME $INSTDIR\changelog.txt !define MUI_FINISHPAGE_SHOWREADME_TEXT changelog.txt -!define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED +;!define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED !define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\orange-uninstall.ico" !define MUI_UNFINISHPAGE_NOAUTOCLOSE ;!define MUI_LANGDLL_REGISTRY_ROOT HKLM @@ -175,7 +193,7 @@ Section $(Section_Main) Section_Main ; Main binaries SetOutPath "$INSTDIR" File /oname=retroshare.exe "${RELEASEDIR}\retroshare-gui\src\release\retroshare.exe" - File /oname=retroshare-nogui.exe "${RELEASEDIR}\retroshare-nogui\src\release\retroshare-nogui.exe" + File /oname=retroshare-service.exe "${RELEASEDIR}\retroshare-service\src\release\retroshare-service.exe" ; Qt binaries File "${QTDIR}\bin\Qt5Core.dll" @@ -202,18 +220,33 @@ Section $(Section_Main) Section_Main ; MinGW binaries SetOutPath "$INSTDIR" File "${MINGWDIR}\bin\libstdc++-6.dll" - File "${MINGWDIR}\bin\libgcc_s_dw2-1.dll" + !if ${ARCHITECTURE} == "x86" + File "${MINGWDIR}\bin\libgcc_s_dw2-1.dll" + !endif + !if ${ARCHITECTURE} == "x64" + File "${MINGWDIR}\bin\libgcc_s_seh-1.dll" + !endif File "${MINGWDIR}\bin\libwinpthread-1.dll" ; External binaries File "${EXTERNAL_LIB_DIR}\bin\miniupnpc.dll" - File "${EXTERNAL_LIB_DIR}\bin\libeay32.dll" - File "${EXTERNAL_LIB_DIR}\bin\ssleay32.dll" + !if ${ARCHITECTURE} == "x86" + File "${EXTERNAL_LIB_DIR}\bin\libcrypto-1_1.dll" + File "${EXTERNAL_LIB_DIR}\bin\libssl-1_1.dll" + !endif + !if ${ARCHITECTURE} == "x64" + File "${EXTERNAL_LIB_DIR}\bin\libcrypto-1_1-x64.dll" + File "${EXTERNAL_LIB_DIR}\bin\libssl-1_1-x64.dll" + !endif ; Other files - File "${SOURCEDIR}\retroshare-gui\src\changelog.txt" + File "${RELEASEDIR}\changelog.txt" File "${SOURCEDIR}\libbitdht\src\bitdht\bdboot.txt" + ; License + SetOutPath "$INSTDIR\license" + File "${SOURCEDIR}\retroshare-gui\src\license\*.*" + ; Image formats SetOutPath "$INSTDIR\imageformats" File /r "${QTDIR}\plugins\imageformats\qgif.dll" @@ -236,19 +269,26 @@ Section $(Section_Main) Section_Main File /r "${QTDIR}\translations\qt_*.qm" File /r "${QTDIR}\translations\qtbase_*.qm" File /r "${QTDIR}\translations\qtscript_*.qm" - File /r "${QTDIR}\translations\qtquick1_*.qm" File /r "${QTDIR}\translations\qtmultimedia_*.qm" File /r "${QTDIR}\translations\qtxmlpatterns_*.qm" ; WebUI - SetOutPath "$INSTDIR\webui" - File /r "${SOURCEDIR}\libresapi\src\webui\*.*" +; SetOutPath "$INSTDIR\webui" +; File /r "${SOURCEDIR}\libresapi\src\webui\*.*" ; License SetOutPath "$INSTDIR\license" File /r "${SOURCEDIR}\retroshare-gui\src\license\*.*" SectionEnd +# Tor +!ifdef TOR_EXISTS + Section /o $(Section_Tor) Section_Tor + SetOutPath "$INSTDIR" + File /r "${TORDIR}\*" + SectionEnd +!endif + # Plugins ${!defineifexist} PLUGIN_FEEDREADER_EXISTS "${RELEASEDIR}\plugins\FeedReader\release\FeedReader.dll" ${!defineifexist} PLUGIN_VOIP_EXISTS "${RELEASEDIR}\plugins\VOIP\release\VOIP.dll" @@ -363,6 +403,7 @@ SectionEnd !insertmacro MUI_DESCRIPTION_TEXT ${Section_Plugin_VOIP} $(Section_Plugin_VOIP_Desc) ; !insertmacro MUI_DESCRIPTION_TEXT ${Section_Link} $(Section_Link_Desc) !insertmacro MUI_DESCRIPTION_TEXT ${Section_AutoStart} $(Section_AutoStart_Desc) + !insertmacro MUI_DESCRIPTION_TEXT ${Section_Tor} $(Section_Tor_Desc) !insertmacro MUI_FUNCTION_DESCRIPTION_END # Uninstall diff --git a/build_scripts/Windows/qt-cmd.bat b/build_scripts/Windows/qt-cmd.bat deleted file mode 100644 index c0ac6ecbd..000000000 --- a/build_scripts/Windows/qt-cmd.bat +++ /dev/null @@ -1,27 +0,0 @@ -:: Usage: -:: call qt-cmd.bat [command] - -@echo off - -setlocal - -set QtVersion=%~1 - -:: Initialize environment -call "%~dp0env.bat" -if errorlevel 1 goto error_env -call "%EnvPath%\env-qt.bat" %QtVersion% -if errorlevel 1 goto error_env - -if "%~2"=="" ( - "%ComSpec%" -) else ( - "%ComSpec%" /c %2 %3 %4 %5 %6 %7 %8 %9 -) - -exit /B %ERRORLEVEL% - -:error_env -echo Failed to initialize environment. -endlocal -exit /B 1 diff --git a/build_scripts/Windows/tools/download-file-wildcard.bat.bat b/build_scripts/Windows/tools/download-file-wildcard.bat.bat deleted file mode 100644 index 90015baf7..000000000 --- a/build_scripts/Windows/tools/download-file-wildcard.bat.bat +++ /dev/null @@ -1,46 +0,0 @@ -:: Usage: -:: call download-file-wildcard.bat url file-wildcard download-path variable - -if "%~4"=="" ( - echo. - echo Parameter error. - exit /B 1 -) - -if "%EnvTempPath%"=="" ( - echo. - echo Environment error. - exit /B 1 -) - -setlocal - -set Url=%~1 -set FileWildcard=%~2 -set DownloadPath=%~3 -set Var=%~4 -set File= - -call "%~dp0remove-dir.bat" "%EnvTempPath%" -mkdir "%EnvTempPath%" - -"%EnvWgetExe%" --recursive --continue --no-directories --no-parent -A "%FileWildcard%" --directory-prefix="%EnvTempPath%" "%Url%" - -if errorlevel 1 ( - call "%~dp0remove-dir.bat" "%EnvTempPath%" - endlocal & set %Var%= - exit /B %ERRORLEVEL% -) - -for %%A in (%EnvTempPath%\%FileWildcard%) do set File=%%~nxA -if "%File%"=="" ( - call "%~dp0remove-dir.bat" "%EnvTempPath%" - endlocal & set %Var%= - exit /B %ERRORLEVEL% -) - -move "%EnvTempPath%\%File%" "%DownloadPath%" -call "%~dp0remove-dir.bat" "%EnvTempPath%" - -endlocal & set %Var%=%File% -exit /B 0 diff --git a/build_scripts/Windows/tools/download-file.bat b/build_scripts/Windows/tools/download-file.bat index 62720c393..dbcecdcbb 100644 --- a/build_scripts/Windows/tools/download-file.bat +++ b/build_scripts/Windows/tools/download-file.bat @@ -7,7 +7,6 @@ if "%~2"=="" ( exit /B 1 ) -::"%EnvCurlExe%" -L -k "%~1" -o "%~2" -"%EnvWgetExe%" --no-check-certificate --continue "%~1" --output-document="%~2" +powershell -NoLogo -NoProfile -Command (New-Object System.Net.WebClient).DownloadFile(\""%~1\"", \""%~2\"") exit /B %ERRORLEVEL% diff --git a/build_scripts/Windows/tools/generate-changelog.bat b/build_scripts/Windows/tools/generate-changelog.bat new file mode 100644 index 000000000..c38225045 --- /dev/null +++ b/build_scripts/Windows/tools/generate-changelog.bat @@ -0,0 +1,50 @@ +@echo off +setlocal enabledelayedexpansion + +if "%~2"=="" ( + echo. + echo Parameter error. + echo Usage %~n0 sourcepath outputfile + exit /B 1 +) + +:: Check git executable +set GitPath= +call "%~dp0find-in-path.bat" GitPath git.exe +if "%GitPath%"=="" echo Git executable not found in PATH.& exit /B 1 + +set logfile=%~2 +copy nul %logfile% > nul + +pushd %~1 + +set last=HEAD +for /f %%t in ('git tag --sort=-taggerdate --merged ^| findstr v') do ( + echo generating changelog for !last!..%%t + echo ----------------------------------------------- >> %logfile% + if !last! neq HEAD ( + git tag -n !last! >> %logfile% + ) else ( + echo HEAD >> %logfile% + ) + rem echo !last! ---^> %%t >> %logfile% + echo ----------------------------------------------- >> %logfile% + echo. >> %logfile% + git log %%t..!last! --no-merges "--pretty=format:%%h %%ai %%<(10,trunc)%%an %%s" >> %logfile% + echo. >> %logfile% + echo. >> %logfile% + set last=%%t +) + +echo generating changelog for %last% +echo ----------------------------------------------- >> %logfile% +git tag -n %last% >> %logfile% +echo ----------------------------------------------- >> %logfile% +echo. >> %logfile% +git log %last% --no-merges "--pretty=format:%%h %%ai %%<(10,trunc)%%an %%s" >> %logfile% + +popd + +endlocal enabledelayedexpansion + +exit /B 0 diff --git a/build_scripts/Windows/tools/get-gcc-version.bat b/build_scripts/Windows/tools/get-gcc-version.bat index c9998376b..3977477b7 100644 --- a/build_scripts/Windows/tools/get-gcc-version.bat +++ b/build_scripts/Windows/tools/get-gcc-version.bat @@ -1,42 +1,37 @@ :: Usage: -:: call get-gcc-version.bat variable +:: call get-gcc-version.bat version architecture setlocal -set Var=%~1 -if "%Var%"=="" ( +set VarVersion=%~1 +if "%VarVersion%"=="" ( + echo. + echo Parameter error. + exit /B 1 +) + +set VarArchitecture=%~2 +if "%VarArchitecture%"=="" ( echo. echo Parameter error. exit /B 1 ) set GCCVersion= +set GCCArchitecture= +set _Architecture= call "%~dp0find-in-path.bat" GCCPath gcc.exe if "%GCCPath%"=="" ( echo. echo Cannot find gcc.exe in PATH. - goto exit + exit /B 1 ) -gcc --version >"%~dp0gccversion.tmp" -for /F "tokens=1*" %%A in (%~sdp0gccversion.tmp) do ( - if "%%A"=="gcc" ( - call :find_version %%B - goto exit - ) -) +for /F "tokens=1-8* delims= " %%A in ('gcc --version') do if "%%A"=="gcc" set _Architecture=%%B& set GCCVersion=%%G -:exit -if exist "%~dp0gccversion.tmp" del /Q "%~dp0gccversion.tmp" +if "%_Architecture:~1,4%"=="i686" set GCCArchitecture=x86 +if "%_Architecture:~1,6%"=="x86_64" set GCCArchitecture=x64 -endlocal & set %Var%=%GCCVersion% -goto :EOF - -:find_version -:loop -if "%2" NEQ "" ( - shift - goto loop -) -set GCCVersion=%1 +endlocal & set %VarVersion%=%GCCVersion%& set %VarArchitecture%=%GCCArchitecture% +exit /B 0 diff --git a/build_scripts/Windows/tools/get-git-ref.bat b/build_scripts/Windows/tools/get-git-ref.bat index f8f6efdeb..f0047e486 100644 --- a/build_scripts/Windows/tools/get-git-ref.bat +++ b/build_scripts/Windows/tools/get-git-ref.bat @@ -18,7 +18,7 @@ call "%~dp0find-in-path.bat" GitPath git.exe if "%GitPath%"=="" ( echo. echo Git executable not found in PATH. - goto exit + exit /B 1 ) set GitParameter= diff --git a/build_scripts/Windows/tools/get-qt-version.bat b/build_scripts/Windows/tools/get-qt-version.bat index c49939970..73afedcfc 100644 --- a/build_scripts/Windows/tools/get-qt-version.bat +++ b/build_scripts/Windows/tools/get-qt-version.bat @@ -16,19 +16,10 @@ call "%~dp0find-in-path.bat" QMakePath qmake.exe if "%QMakePath%"=="" ( echo. echo Cannot find qmake.exe in PATH. - goto exit + exit /B 1 ) -qmake.exe -version >"%~dp0qtversion.tmp" -for /F "tokens=1,2,3,4" %%A in (%~sdp0qtversion.tmp) do ( - if "%%A"=="Using" ( - set QtVersion=%%D - goto exit - ) -) - -:exit -if exist "%~dp0qtversion.tmp" del /Q "%~dp0qtversion.tmp" +for /F "tokens=1,2,3,4 delims= " %%A in ('qmake.exe -version') do if "%%A"=="Using" set QtVersion=%%D endlocal & set %Var%=%QtVersion% exit /B 0 \ No newline at end of file diff --git a/build_scripts/Windows/tools/get-rs-date.bat b/build_scripts/Windows/tools/get-rs-date.bat new file mode 100644 index 000000000..6fecc48f9 --- /dev/null +++ b/build_scripts/Windows/tools/get-rs-date.bat @@ -0,0 +1,32 @@ +REM Usage: +REM call get-rs-date.bat SourcePath Variable + +setlocal + +set SourcePath=%~1 +set Variable=%~2 +if "%Variable%"=="" ( + echo. + echo Parameter error + exit /B 1 +) + +:: Check git executable +set GitPath= +call "%~dp0find-in-path.bat" GitPath git.exe +if "%GitPath%"=="" ( + echo. + echo Git executable not found in PATH. + exit /B 1 +) + +set Date= + +pushd "%SourcePath%" +rem This doesn't work: git log -1 --date=format:"%Y%m%d" --format="%ad" +for /F "tokens=1,2,3* delims=-" %%A in ('git log -1 --date^=short --format^="%%ad"') do set Date=%%A%%B%%C +popd + +:exit +endlocal & set %Variable%=%Date% +exit /B 0 diff --git a/build_scripts/Windows/tools/get-rs-version.bat b/build_scripts/Windows/tools/get-rs-version.bat index 2398baf93..cc4e53ff8 100644 --- a/build_scripts/Windows/tools/get-rs-version.bat +++ b/build_scripts/Windows/tools/get-rs-version.bat @@ -27,7 +27,7 @@ set VersionMinor= set VersionMini= set VersionExtra= -for /F "tokens=1,2,3,* delims=.-" %%A in ('%EnvToolsPath%\sigcheck.exe -nobanner -n %Executable%') do ( +for /F "USEBACKQ tokens=1,2,3,* delims=.-" %%A in (`powershell -NoLogo -NoProfile -Command ^(Get-Item "%Executable%"^).VersionInfo.FileVersion`) do ( set VersionMajor=%%A set VersionMinor=%%B set VersionMini=%%C diff --git a/build_scripts/Windows/tools/msys-path.bat b/build_scripts/Windows/tools/msys-path.bat deleted file mode 100644 index 3b0c5fd69..000000000 --- a/build_scripts/Windows/tools/msys-path.bat +++ /dev/null @@ -1,20 +0,0 @@ -:: Usage: -:: call msys-path.bat path variable - -setlocal - -set WinPath=%~1 -set MSYSVar=%~2 - -if "%MSYSVar%"=="" ( - echo. - echo Parameter error. - exit /B 1 -) - -set MSYSPath=/%WinPath:~0,1%/%WinPath:~3% -set MSYSPath=%MSYSPath:\=/% - -endlocal & set %MSYSVar%=%MSYSPath% - -exit /B 0 diff --git a/build_scripts/Windows/tools/msys2-path.bat b/build_scripts/Windows/tools/msys2-path.bat new file mode 100644 index 000000000..9904417f6 --- /dev/null +++ b/build_scripts/Windows/tools/msys2-path.bat @@ -0,0 +1,20 @@ +:: Usage: +:: call msys2-path.bat path variable + +setlocal + +set WinPath=%~1 +set MSYS2Var=%~2 + +if "%MSYS2Var%"=="" ( + echo. + echo Parameter error. + exit /B 1 +) + +set MSYS2Path=/%WinPath:~0,1%/%WinPath:~3% +set MSYS2Path=%MSYS2Path:\=/% + +endlocal & set %MSYS2Var%=%MSYS2Path% + +exit /B 0 diff --git a/build_scripts/Windows/tools/winhttpjs.bat b/build_scripts/Windows/tools/winhttpjs.bat deleted file mode 100644 index cdea152eb..000000000 --- a/build_scripts/Windows/tools/winhttpjs.bat +++ /dev/null @@ -1,584 +0,0 @@ -@if (@X) == (@Y) @end /* JScript comment - @echo off - - rem :: the first argument is the script name as it will be used for proper help message - cscript //E:JScript //nologo "%~f0" "%~nx0" %* - - exit /b %errorlevel% - -@if (@X)==(@Y) @end JScript comment */ - -// used resources - -// update 12.10.15 -// osvikvi(https://github.com/osvikvi) has nodited that the -password option is not set , so this is fixed - -//https://msdn.microsoft.com/en-us/library/windows/desktop/aa384058(v=vs.85).aspx -//https://msdn.microsoft.com/en-us/library/windows/desktop/aa384055(v=vs.85).aspx -//https://msdn.microsoft.com/en-us/library/windows/desktop/aa384059(v=vs.85).aspx - -// global variables and constants - - -// ---------------------------------- -// -- asynch requests not included -- -// ---------------------------------- - - -//todo - save responceStream instead of responceBody !! -//todo - set all winthttp options ->//https://msdn.microsoft.com/en-us/library/windows/desktop/aa384108(v=vs.85).aspx -//todo - log all options -//todo - improve help message . eventual verbose option - - -var ARGS = WScript.Arguments; -var scriptName = ARGS.Item(0); - -var url = ""; -var saveTo = ""; - -var user = 0; -var pass = 0; - -var proxy = 0; -var bypass = 0; -var proxy_user = 0; -var proxy_pass = 0; - -var certificate = 0; - -var force = true; - -var body = ""; - -//ActiveX objects -var WinHTTPObj = new ActiveXObject("WinHttp.WinHttpRequest.5.1"); -var FileSystemObj = new ActiveXObject("Scripting.FileSystemObject"); -var AdoDBObj = new ActiveXObject("ADODB.Stream"); - -// HttpRequest SetCredentials flags. -var proxy_settings = 0; - -// -HTTPREQUEST_SETCREDENTIALS_FOR_SERVER = 0; -HTTPREQUEST_SETCREDENTIALS_FOR_PROXY = 1; - -//timeouts and their default values -var RESOLVE_TIMEOUT = 0; -var CONNECT_TIMEOUT = 90000; -var SEND_TIMEOUT = 90000; -var RECEIVE_TIMEOUT = 90000; - -//HttpRequestMethod -var http_method = 'GET'; - -//header -var header_file = ""; - -//report -var reportfile = ""; - -//test-this: -var use_stream = false; - -//autologon policy -var autologon_policy = 1; //0,1,2 - - -//headers will be stored as multi-dimensional array -var headers = []; - -//user-agent -var ua = ""; - -//escape URL -var escape = false; - -function printHelp() { - WScript.Echo(scriptName + " - sends HTTP request and saves the request body as a file and/or a report of the sent request"); - WScript.Echo(scriptName + " url [-force yes|no] [-user username -password password] [-proxy proxyserver:port] [-bypass bypass_list]"); - WScript.Echo(" [-proxyuser proxy_username -proxypassword proxy_password] [-certificate certificateString]"); - WScript.Echo(" [-method GET|POST|PATCH|DELETE|HEAD|OPTIONS|CONNECT]"); - WScript.Echo(" [-saveTo file] - to print response to console use con"); - - WScript.Echo(" [-sendTimeout int(milliseconds)]"); - WScript.Echo(" [-resolveTimeout int(milliseconds)]"); - WScript.Echo(" [-connectTimeout int(milliseconds)]"); - WScript.Echo(" [-receiveTimeout int(milliseconds)]"); - - WScript.Echo(" [-autologonPolicy 1|2|3]"); - WScript.Echo(" [-proxySettings 1|2|3] (https://msdn.microsoft.com/en-us/library/windows/desktop/aa384059(v=vs.85).aspx)"); - - //header - WScript.Echo(" [-headers-file header_file]"); - //reportfile - WScript.Echo(" [-reportfile reportfile]"); - WScript.Echo(" [-ua user-agent]"); - WScript.Echo(" [-ua-file user-agent-file]"); - - WScript.Echo(" [-escape yes|no]"); - - WScript.Echo(" [-body body-string]"); - WScript.Echo(" [-body-file body-file]"); - - WScript.Echo("-force - decide to not or to overwrite if the local files exists"); - - WScript.Echo("proxyserver:port - the proxy server"); - WScript.Echo("bypass- bypass list"); - WScript.Echo("proxy_user , proxy_password - credentials for proxy server"); - WScript.Echo("user , password - credentials for the server"); - WScript.Echo("certificate - location of SSL certificate"); - WScript.Echo("method - what HTTP method will be used.Default is GET"); - WScript.Echo("saveTo - save the responce as binary file"); - WScript.Echo(" "); - WScript.Echo("Header file should contain key:value pairs.Lines starting with \"#\" will be ignored."); - WScript.Echo("value should NOT be enclosed with quotes"); - WScript.Echo(" "); - WScript.Echo("Examples:"); - - WScript.Echo(scriptName + " http://somelink.com/somefile.zip -saveTo c:\\somefile.zip -certificate \"LOCAL_MACHINE\\Personal\\My Middle-Tier Certificate\""); - WScript.Echo(scriptName + " http://somelink.com/something.html -method POST -certificate \"LOCAL_MACHINE\\Personal\\My Middle-Tier Certificate\" -header c:\\header_file -reportfile c:\\reportfile.txt"); - WScript.Echo(scriptName + "\"http://somelink\" -method POST -header hdrs.txt -reportfile reportfile2.txt -saveTo responsefile2 -ua \"Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36\" -body-file some.json"); - -} - -function parseArgs() { - // - if (ARGS.Length < 2) { - WScript.Echo("insufficient arguments"); - printHelp(); - WScript.Quit(43); - } - // !!! - url = ARGS.Item(1); - // !!! - if (ARGS.Length % 2 != 0) { - WScript.Echo("illegal arguments"); - printHelp(); - WScript.Quit(44); - } - - for (var i = 2; i < ARGS.Length - 1; i = i + 2) { - var arg = ARGS.Item(i).toLowerCase(); - var next = ARGS.Item(i + 1); - - - try { - switch (arg) { // the try-catch is set mainly because of the parseInts - case "-force": - if (next == "no") { - force = false; - } - break; - case "-escape": - if (next == "yes") { - escape = true; - } - break; - case "-saveto": - saveTo = next; - break; - case "-user": - case "-u": - user = next; - break; - case "-pass": - case "-password": - case "-p": - pass = next; - break; - case "-proxy": - proxy = next; - break; - case "-bypass": - bypass = next; - break; - case "-proxyuser": - case "-pu": - proxy_user = next; - break; - case "-proxypassword": - case "-pp": - proxy_pass = next; - break; - case "-ua": - ua = next; - break; - case "-ua-file": - ua = readFile(next); - break; - case "-body": - body = next; - break; - case "-usestream": - //WScript.Echo("~~"); - if (next.toLowerCase() === "yes") { - use_stream = true - }; - break; - case "-body-file": - body = readFile(next); - break; - case "-certificate": - certificate = next; - break; - case "-method": - switch (next.toLowerCase()) { - case "post": - http_method = 'POST'; - break; - case "get": - http_method = 'GET'; - break; - case "head": - http_method = 'HEAD'; - break; - case "put": - http_method = 'PUT'; - break; - case "options": - http_method = 'OPTIONS'; - break; - case "connect": - http_method = 'CONNECT'; - break; - case "patch": - http_method = 'PATCH'; - break; - case "delete": - http_method = 'DELETE'; - break; - default: - WScript.Echo("Invalid http method passed " + next); - WScript.Echo("possible values are GET,POST,DELETE,PUT,CONNECT,PATCH,HEAD,OPTIONS"); - WScript.Quit(1326); - break; - } - break; - case "-headers-file": - case "-header": - headers = readPropFile(next); - break; - case "-reportfile": - reportfile = next; - break; - //timeouts - case "-sendtimeout": - SEND_TIMEOUT = parseInt(next); - break; - case "-connecttimeout": - CONNECT_TIMEOUT = parseint(next); - break; - case "-resolvetimeout": - RESOLVE_TIMEOUT = parseInt(next); - break; - case "-receivetimeout": - RECEIVE_TIMEOUT = parseInt(next); - break; - - case "-autologonpolicy": - autologon_policy = parseInt(next); - if (autologon_policy > 2 || autologon_policy < 0) { - WScript.Echo("out of autologon policy range"); - WScript.Quit(87); - }; - break; - case "-proxysettings": - proxy_settings = parseInt(next); - if (proxy_settings > 2 || proxy_settings < 0) { - WScript.Echo("out of proxy settings range"); - WScript.Quit(87); - }; - break; - default: - WScript.Echo("Invalid command line switch: " + arg); - WScript.Quit(1405); - break; - } - } catch (err) { - WScript.Echo(err.message); - WScript.Quit(1348); - } - } -} - -stripTrailingSlash = function(path) { - while (path.substr(path.length - 1, path.length) == '\\') { - path = path.substr(0, path.length - 1); - } - return path; -} - -function existsItem(path) { - return FileSystemObj.FolderExists(path) || FileSystemObj.FileExists(path); -} - -function deleteItem(path) { - if (FileSystemObj.FileExists(path)) { - FileSystemObj.DeleteFile(path); - return true; - } else if (FileSystemObj.FolderExists(path)) { - FileSystemObj.DeleteFolder(stripTrailingSlash(path)); - return true; - } else { - return false; - } -} - -//------------------------------- -//---------------------- -//---------- -//----- -//-- -function request(url) { - - try { - - WinHTTPObj.Open(http_method, url, false); - if (proxy != 0 && bypass != 0) { - WinHTTPObj.SetProxy(proxy_settings, proxy, bypass); - } - - if (proxy != 0) { - WinHTTPObj.SetProxy(proxy_settings, proxy); - } - - if (user != 0 && pass != 0) { - WinHTTPObj.SetCredentials(user, pass, HTTPREQUEST_SETCREDENTIALS_FOR_SERVER); - } - - if (proxy_user != 0 && proxy_pass != 0) { - WinHTTPObj.SetCredentials(proxy_user, proxy_pass, HTTPREQUEST_SETCREDENTIALS_FOR_PROXY); - } - - if (certificate != 0) { - WinHTTPObj.SetClientCertificate(certificate); - } - - //set autologin policy - WinHTTPObj.SetAutoLogonPolicy(autologon_policy); - //set timeouts - WinHTTPObj.SetTimeouts(RESOLVE_TIMEOUT, CONNECT_TIMEOUT, SEND_TIMEOUT, RECEIVE_TIMEOUT); - - if (headers.length !== 0) { - WScript.Echo("Sending with headers:"); - for (var i = 0; i < headers.length; i++) { - WinHTTPObj.SetRequestHeader(headers[i][0], headers[i][1]); - WScript.Echo(headers[i][0] + ":" + headers[i][1]); - } - WScript.Echo(""); - } - - if (ua !== "") { - //user-agent option from: - //WinHttpRequestOption enumeration - // other options can be added like bellow - //https://msdn.microsoft.com/en-us/library/windows/desktop/aa384108(v=vs.85).aspx - WinHTTPObj.Option(0) = ua; - } - if (escape) { - WinHTTPObj.Option(3) = true; - } - if (trim(body) === "") { - WinHTTPObj.Send(); - } else { - WinHTTPObj.Send(body); - } - - var status = WinHTTPObj.Status - } catch (err) { - WScript.Echo(err.message); - WScript.Quit(666); - } - - //////////////////////// - // report // - //////////////////////// - - if (reportfile != "") { - - //var report_string=""; - var n = "\r\n"; - var report_string = "Status:" + n; - report_string = report_string + " " + WinHTTPObj.Status; - report_string = report_string + " " + WinHTTPObj.StatusText + n; - report_string = report_string + " " + n; - report_string = report_string + "Response:" + n; - report_string = report_string + WinHTTPObj.ResponseText + n; - report_string = report_string + " " + n; - report_string = report_string + "Headers:" + n; - report_string = report_string + WinHTTPObj.GetAllResponseHeaders() + n; - - WinHttpRequestOption_UserAgentString = 0; // Name of the user agent - WinHttpRequestOption_URL = 1; // Current URL - WinHttpRequestOption_URLCodePage = 2; // Code page - WinHttpRequestOption_EscapePercentInURL = 3; // Convert percents - // in the URL - // rest of the options can be seen and eventually added using this as reference - // https://msdn.microsoft.com/en-us/library/windows/desktop/aa384108(v=vs.85).aspx - - report_string = report_string + "URL:" + n; - report_string = report_string + WinHTTPObj.Option(WinHttpRequestOption_URL) + n; - - report_string = report_string + "URL Code Page:" + n; - report_string = report_string + WinHTTPObj.Option(WinHttpRequestOption_URLCodePage) + n; - - report_string = report_string + "User Agent:" + n; - report_string = report_string + WinHTTPObj.Option(WinHttpRequestOption_UserAgentString) + n; - - report_string = report_string + "Escapped URL:" + n; - report_string = report_string + WinHTTPObj.Option(WinHttpRequestOption_EscapePercentInURL) + n; - - prepareateFile(force, reportfile); - - WScript.Echo("Writing report to " + reportfile); - - writeFile(reportfile, report_string); - - } - - switch (status) { - case 200: - WScript.Echo("Status: 200 OK"); - break; - default: - WScript.Echo("Status: " + status); - WScript.Echo("Status was not OK. More info -> https://en.wikipedia.org/wiki/List_of_HTTP_status_codes"); - } - - //if as binary - if (saveTo.toLowerCase() === "con") { - WScript.Echo(WinHTTPObj.ResponseText); - } - if (saveTo !== "" && saveTo.toLowerCase() !== "con") { - prepareateFile(force, saveTo); - try { - - if (use_stream) { - writeBinFile(saveTo, WinHTTPObj.ResponseStream); - } else { - writeBinFile(saveTo, WinHTTPObj.ResponseBody); - } - - } catch (err) { - WScript.Echo("Failed to save the file as binary.Attempt to save it as text"); - AdoDBObj.Close(); - prepareateFile(true, saveTo); - writeFile(saveTo, WinHTTPObj.ResponseText); - } - } - WScript.Quit(status); -} - -//-- -//----- -//---------- -//---------------------- -//------------------------------- - -function prepareateFile(force, file) { - if (force && existsItem(file)) { - if (!deleteItem(file)) { - WScript.Echo("Unable to delete " + file); - WScript.Quit(8); - } - } else if (existsItem(file)) { - WScript.Echo("Item " + file + " already exist"); - WScript.Quit(9); - } -} - -function writeBinFile(fileName, data) { - AdoDBObj.Type = 1; - AdoDBObj.Open(); - AdoDBObj.Position = 0; - AdoDBObj.Write(data); - AdoDBObj.SaveToFile(fileName, 2); - AdoDBObj.Close(); -} - -function writeFile(fileName, data) { - AdoDBObj.Type = 2; - AdoDBObj.CharSet = "iso-8859-1"; - AdoDBObj.Open(); - AdoDBObj.Position = 0; - AdoDBObj.WriteText(data); - AdoDBObj.SaveToFile(fileName, 2); - AdoDBObj.Close(); -} - - -function readFile(fileName) { - //check existence - try { - if (!FileSystemObj.FileExists(fileName)) { - WScript.Echo("file " + fileName + " does not exist!"); - WScript.Quit(13); - } - if (FileSystemObj.GetFile(fileName).Size === 0) { - return ""; - } - var fileR = FileSystemObj.OpenTextFile(fileName, 1); - var content = fileR.ReadAll(); - fileR.Close(); - return content; - } catch (err) { - WScript.Echo("Error while reading file: " + fileName); - WScript.Echo(err.message); - WScript.Echo("Will return empty string"); - return ""; - } -} - -function readPropFile(fileName) { - //check existence - resultArray = []; - if (!FileSystemObj.FileExists(fileName)) { - WScript.Echo("(headers)file " + fileName + " does not exist!"); - WScript.Quit(15); - } - if (FileSystemObj.GetFile(fileName).Size === 0) { - return resultArray; - } - var fileR = FileSystemObj.OpenTextFile(fileName, 1); - var line = ""; - var k = ""; - var v = ""; - var lineN = 0; - var index = 0; - try { - WScript.Echo("parsing headers form " + fileName + " property file "); - while (!fileR.AtEndOfStream) { - line = fileR.ReadLine(); - lineN++; - index = line.indexOf(":"); - if (line.indexOf("#") === 0 || trim(line) === "") { - continue; - } - if (index === -1 || index === line.length - 1 || index === 0) { - WScript.Echo("Invalid line " + lineN); - WScript.Quit(93); - } - k = trim(line.substring(0, index)); - v = trim(line.substring(index + 1, line.length)); - resultArray.push([k, v]); - } - fileR.Close(); - return resultArray; - } catch (err) { - WScript.Echo("Error while reading headers file: " + fileName); - WScript.Echo(err.message); - WScript.Echo("Will return empty array"); - return resultArray; - } -} - -function trim(str) { - return str.replace(/^\s+/, '').replace(/\s+$/, ''); -} - -function main() { - parseArgs(); - request(url); -} -main(); diff --git a/libbitdht/src/util/bdnet.cc b/libbitdht/src/util/bdnet.cc index 4c5f681a6..ba8c33553 100644 --- a/libbitdht/src/util/bdnet.cc +++ b/libbitdht/src/util/bdnet.cc @@ -285,12 +285,6 @@ int sleep(unsigned int sec) } #endif -int usleep(unsigned int usec) -{ - Sleep(usec / 1000); - return 0; -} - /********************************** WINDOWS/UNIX SPECIFIC PART ******************/ #else // UNIX diff --git a/libbitdht/src/util/bdnet.h b/libbitdht/src/util/bdnet.h index 639a2ed1a..89ecfa710 100644 --- a/libbitdht/src/util/bdnet.h +++ b/libbitdht/src/util/bdnet.h @@ -159,7 +159,6 @@ int bdnet_w2u_errno(int error); #ifndef __MINGW64_VERSION_MAJOR int sleep(unsigned int sec); #endif -int usleep(unsigned int usec); #endif // END of WINDOWS defines. /********************************** WINDOWS/UNIX SPECIFIC PART ******************/ diff --git a/libretroshare/src/chat/distributedchat.cc b/libretroshare/src/chat/distributedchat.cc index 3f5ecc74e..ca24cac1e 100644 --- a/libretroshare/src/chat/distributedchat.cc +++ b/libretroshare/src/chat/distributedchat.cc @@ -219,7 +219,13 @@ bool DistributedChatService::checkSignature(RsChatLobbyBouncingObject *obj,const // network pre-request key to allow message authentication. - mGixs->requestKey(obj->signature.keyId,peer_list,RsIdentityUsage(RS_SERVICE_TYPE_CHAT,RsIdentityUsage::CHAT_LOBBY_MSG_VALIDATION,RsGxsGroupId(),RsGxsMessageId(),obj->lobby_id)); + mGixs->requestKey(obj->signature.keyId,peer_list,RsIdentityUsage(RsServiceType::CHAT, + RsIdentityUsage::CHAT_LOBBY_MSG_VALIDATION, + RsGxsGroupId(), + RsGxsMessageId(), + RsGxsMessageId(), + RsGxsMessageId(), + obj->lobby_id)); uint32_t size = RsChatSerialiser(RsSerializationFlags::SIGNATURE) .size(dynamic_cast(obj)); @@ -238,7 +244,13 @@ bool DistributedChatService::checkSignature(RsChatLobbyBouncingObject *obj,const } uint32_t error_status ; - RsIdentityUsage use_info(RS_SERVICE_TYPE_CHAT,RsIdentityUsage::CHAT_LOBBY_MSG_VALIDATION,RsGxsGroupId(),RsGxsMessageId(),obj->lobby_id) ; + RsIdentityUsage use_info(RsServiceType::CHAT, + RsIdentityUsage::CHAT_LOBBY_MSG_VALIDATION, + RsGxsGroupId(), + RsGxsMessageId(), + RsGxsMessageId(), + RsGxsMessageId(), + obj->lobby_id) ; if(!mGixs->validateData(memory,size,obj->signature,false,use_info,error_status)) { diff --git a/libretroshare/src/gossipdiscovery/p3gossipdiscovery.cc b/libretroshare/src/gossipdiscovery/p3gossipdiscovery.cc index c4f80436a..fc1c17f85 100644 --- a/libretroshare/src/gossipdiscovery/p3gossipdiscovery.cc +++ b/libretroshare/src/gossipdiscovery/p3gossipdiscovery.cc @@ -450,7 +450,7 @@ void p3discovery2::recvIdentityList(const RsPeerId& pid,const std::list std::cerr << "p3discovery2::recvIdentityList(): from peer " << pid << ": " << ids.size() << " identities" << std::endl; #endif - RsIdentityUsage use_info(RS_SERVICE_TYPE_DISC,RsIdentityUsage::IDENTITY_DATA_UPDATE); + RsIdentityUsage use_info(RsServiceType::GOSSIP_DISCOVERY,RsIdentityUsage::IDENTITY_NEW_FROM_DISCOVERY); for(auto it(ids.begin());it!=ids.end();++it) { diff --git a/libretroshare/src/grouter/p3grouter.cc b/libretroshare/src/grouter/p3grouter.cc index d34a1349f..16148d508 100644 --- a/libretroshare/src/grouter/p3grouter.cc +++ b/libretroshare/src/grouter/p3grouter.cc @@ -2108,7 +2108,7 @@ bool p3GRouter::verifySignedDataItem(const RsGRouterAbstractMsgItem *item,const if(!signature_serializer.serialise(const_cast(item),data,&data_size)) throw std::runtime_error("Cannot serialise signed data."); - RsIdentityUsage use(RS_SERVICE_TYPE_GROUTER,info); + RsIdentityUsage use(RsServiceType::GROUTER,info); if(!mGixs->validateData( data, data_size, item->signature, true, use, error_status )) { diff --git a/libretroshare/src/gxs/rsdataservice.cc b/libretroshare/src/gxs/rsdataservice.cc index bd22a8aa9..5d09fee5d 100644 --- a/libretroshare/src/gxs/rsdataservice.cc +++ b/libretroshare/src/gxs/rsdataservice.cc @@ -502,6 +502,9 @@ RsGxsGrpMetaData* RsDataService::locked_getGrpMeta(RetroCursor &c, int colOffset RsGxsGrpMetaData* grpMeta ; RsGxsGroupId grpId(tempId) ; + if(grpId.isNull()) // not in the DB! + return nullptr; + if(use_cache) grpMeta = mGrpMetaDataCache.getOrCreateMeta(grpId); else @@ -659,8 +662,10 @@ RsGxsMsgMetaData* RsDataService::locked_getMsgMeta(RetroCursor &c, int colOffset std::string temp; c.getString(mColMsgMeta_MsgId + colOffset, temp); msg_id = RsGxsMessageId(temp); + // without these, a msg is meaningless - ok &= (!group_id.isNull()) && (!msg_id.isNull()); + if(group_id.isNull() || msg_id.isNull()) + return nullptr; RsGxsMsgMetaData* msgMeta = nullptr; @@ -1432,7 +1437,7 @@ int RsDataService::retrieveGxsGrpMetaData(RsGxsGrpMetaTemporaryMap& grp) RsGxsGrpMetaData *meta = mGrpMetaDataCache.getMeta(mit->first) ; if(meta) - grp[mit->first] = meta; + mit->second = meta; else { #ifdef RS_DATA_SERVICE_DEBUG_CACHE @@ -1446,7 +1451,7 @@ int RsDataService::retrieveGxsGrpMetaData(RsGxsGrpMetaTemporaryMap& grp) RsGxsGrpMetaData* meta = locked_getGrpMeta(*c, 0,true); if(meta) - grp[mit->first] = meta; + mit->second = meta; #ifdef RS_DATA_SERVICE_DEBUG_TIME ++resultCount; diff --git a/libretroshare/src/gxs/rsdataservice.h b/libretroshare/src/gxs/rsdataservice.h index 56dc8dea6..bf532afae 100644 --- a/libretroshare/src/gxs/rsdataservice.h +++ b/libretroshare/src/gxs/rsdataservice.h @@ -39,6 +39,14 @@ template class t_MetaDataCache { public: t_MetaDataCache() : mCache_ContainsAllMetas(false) {} + virtual ~t_MetaDataCache() + { + for(auto it: mMetas) + delete it.second; + + for(auto it: mOldCachedItems) + delete it.second; + } bool isCacheUpToDate() const { return mCache_ContainsAllMetas ; } void setCacheUpToDate(bool b) { mCache_ContainsAllMetas = b; } diff --git a/libretroshare/src/gxs/rsgenexchange.cc b/libretroshare/src/gxs/rsgenexchange.cc index e3ef41eb9..bd51875c8 100644 --- a/libretroshare/src/gxs/rsgenexchange.cc +++ b/libretroshare/src/gxs/rsgenexchange.cc @@ -512,7 +512,7 @@ int RsGenExchange::createGroupSignatures(RsTlvKeySignatureSet& signSet, RsTlvBin if(GxsSecurity::getSignature((char*)grpData.bin_data, grpData.bin_len, authorKey, sign)) { id_ret = SIGN_SUCCESS; - mGixs->timeStampKey(grpMeta.mAuthorId,RsIdentityUsage(mServType,RsIdentityUsage::GROUP_AUTHOR_SIGNATURE_CREATION,grpMeta.mGroupId)) ; + mGixs->timeStampKey(grpMeta.mAuthorId,RsIdentityUsage(RsServiceType(mServType),RsIdentityUsage::GROUP_AUTHOR_SIGNATURE_CREATION,grpMeta.mGroupId)) ; signSet.keySignSet[INDEX_AUTHEN_IDENTITY] = sign; } else @@ -680,7 +680,7 @@ int RsGenExchange::createMsgSignatures(RsTlvKeySignatureSet& signSet, RsTlvBinar if(GxsSecurity::getSignature((char*)msgData.bin_data, msgData.bin_len, authorKey, sign)) { id_ret = SIGN_SUCCESS; - mGixs->timeStampKey(msgMeta.mAuthorId,RsIdentityUsage(mServType,RsIdentityUsage::MESSAGE_AUTHOR_SIGNATURE_CREATION,msgMeta.mGroupId,msgMeta.mMsgId)) ; + mGixs->timeStampKey(msgMeta.mAuthorId,RsIdentityUsage(RsServiceType(mServType),RsIdentityUsage::MESSAGE_AUTHOR_SIGNATURE_CREATION,msgMeta.mGroupId,msgMeta.mMsgId,msgMeta.mParentId,msgMeta.mThreadId)) ; signSet.keySignSet[INDEX_AUTHEN_IDENTITY] = sign; } else @@ -905,7 +905,11 @@ int RsGenExchange::validateMsg(RsNxsMsg *msg, const uint32_t& grpFlag, const uin { RsTlvKeySignature sign = metaData.signSet.keySignSet[INDEX_AUTHEN_IDENTITY]; idValidate &= GxsSecurity::validateNxsMsg(*msg, sign, authorKey); - mGixs->timeStampKey(metaData.mAuthorId,RsIdentityUsage(mServType,RsIdentityUsage::MESSAGE_AUTHOR_SIGNATURE_VALIDATION,metaData.mGroupId,metaData.mMsgId)) ; + mGixs->timeStampKey(metaData.mAuthorId,RsIdentityUsage(RsServiceType(mServType),RsIdentityUsage::MESSAGE_AUTHOR_SIGNATURE_VALIDATION, + metaData.mGroupId, + metaData.mMsgId, + metaData.mParentId, + metaData.mThreadId)) ; } else { @@ -949,7 +953,12 @@ int RsGenExchange::validateMsg(RsNxsMsg *msg, const uint32_t& grpFlag, const uin { std::list peers; peers.push_back(msg->PeerId()); - mGixs->requestKey(metaData.mAuthorId, peers, RsIdentityUsage(serviceType(),RsIdentityUsage::MESSAGE_AUTHOR_SIGNATURE_VALIDATION,metaData.mGroupId,metaData.mMsgId)); + mGixs->requestKey(metaData.mAuthorId, peers, RsIdentityUsage((RsServiceType)serviceType(), + RsIdentityUsage::MESSAGE_AUTHOR_SIGNATURE_VALIDATION, + metaData.mGroupId, + metaData.mMsgId, + metaData.mParentId, + metaData.mThreadId)); #ifdef GEN_EXCH_DEBUG std::cerr << ", Key missing. Retry later." << std::endl; @@ -1026,7 +1035,7 @@ int RsGenExchange::validateGrp(RsNxsGrp* grp) #ifdef GEN_EXCH_DEBUG std::cerr << " key ID validation result: " << idValidate << std::endl; #endif - mGixs->timeStampKey(metaData.mAuthorId,RsIdentityUsage(mServType,RsIdentityUsage::GROUP_AUTHOR_SIGNATURE_VALIDATION,metaData.mGroupId)); + mGixs->timeStampKey(metaData.mAuthorId,RsIdentityUsage(RsServiceType(mServType),RsIdentityUsage::GROUP_AUTHOR_SIGNATURE_VALIDATION,metaData.mGroupId)); } else { @@ -1044,7 +1053,7 @@ int RsGenExchange::validateGrp(RsNxsGrp* grp) #endif std::list peers; peers.push_back(grp->PeerId()); - mGixs->requestKey(metaData.mAuthorId, peers,RsIdentityUsage(mServType,RsIdentityUsage::GROUP_AUTHOR_SIGNATURE_VALIDATION,metaData.mGroupId)); + mGixs->requestKey(metaData.mAuthorId, peers,RsIdentityUsage(RsServiceType(mServType),RsIdentityUsage::GROUP_AUTHOR_SIGNATURE_VALIDATION,metaData.mGroupId)); return VALIDATE_FAIL_TRY_LATER; } } @@ -3346,7 +3355,7 @@ bool RsGenExchange::updateValid(const RsGxsGrpMetaData& oldGrpMeta, const RsNxsG // also check this is the latest published group bool latest = newGrp.metaData->mPublishTs > oldGrpMeta.mPublishTs; - mGixs->timeStampKey(newGrp.metaData->mAuthorId, RsIdentityUsage(mServType,RsIdentityUsage::GROUP_ADMIN_SIGNATURE_CREATION, oldGrpMeta.mGroupId)) ; + mGixs->timeStampKey(newGrp.metaData->mAuthorId, RsIdentityUsage(RsServiceType(mServType),RsIdentityUsage::GROUP_ADMIN_SIGNATURE_CREATION, oldGrpMeta.mGroupId)) ; return GxsSecurity::validateNxsGrp(newGrp, adminSign, keyMit->second) && latest; } diff --git a/libretroshare/src/gxs/rsgxsdataaccess.cc b/libretroshare/src/gxs/rsgxsdataaccess.cc index a695672f9..bfd2ce3a3 100644 --- a/libretroshare/src/gxs/rsgxsdataaccess.cc +++ b/libretroshare/src/gxs/rsgxsdataaccess.cc @@ -1046,9 +1046,9 @@ bool RsGxsDataAccess::getMsgMetaDataList( const GxsMsgReq& msgIds, const RsTokRe // Now loop once over message Metas and see if they have a parent. If yes, then mark the parent to be discarded. for(uint32_t i=0;imParentId.isNull() && metaV[i]->mParentId != metaV[i]->mMsgId) // this one is a follow up + if(!metaV[i]->mOrigMsgId.isNull() && metaV[i]->mOrigMsgId != metaV[i]->mMsgId) // this one is a follow up { - auto it = index_in_metaV.find(metaV[i]->mParentId); + auto it = index_in_metaV.find(metaV[i]->mOrigMsgId); if(it != index_in_metaV.end()) keep[it->second] = false; @@ -1240,61 +1240,42 @@ bool RsGxsDataAccess::getMsgRelatedInfo(MsgRelatedInfoReq *req) onlyThreadMsgs = true; } - if (onlyAllVersions && onlyChildMsgs) - { -#ifdef DATA_DEBUG - RsDbg() << "RsGxsDataAccess::getMsgRelatedList() ERROR Incompatible FLAGS (VERSIONS & PARENT)" << std::endl; -#endif + if(onlyAllVersions && onlyChildMsgs) + { + RS_ERR("Incompatible FLAGS (VERSIONS & PARENT)"); + return false; + } - return false; - } + if(onlyAllVersions && onlyThreadMsgs) + { + RS_ERR("Incompatible FLAGS (VERSIONS & THREAD)"); + return false; + } - if (onlyAllVersions && onlyThreadMsgs) - { -#ifdef DATA_DEBUG - RsDbg() << "RsGxsDataAccess::getMsgRelatedList() ERROR Incompatible FLAGS (VERSIONS & THREAD)" << std::endl; -#endif + if((!onlyLatestMsgs) && onlyChildMsgs) + { + RS_ERR("Incompatible FLAGS (!LATEST & PARENT)"); + return false; + } - return false; - } + if((!onlyLatestMsgs) && onlyThreadMsgs) + { + RS_ERR("Incompatible FLAGS (!LATEST & THREAD)"); + return false; + } - if ((!onlyLatestMsgs) && onlyChildMsgs) - { -#ifdef DATA_DEBUG - RsDbg() << "RsGxsDataAccess::getMsgRelatedList() ERROR Incompatible FLAGS (!LATEST & PARENT)" << std::endl; -#endif + if(onlyChildMsgs && onlyThreadMsgs) + { + RS_ERR("Incompatible FLAGS (PARENT & THREAD)"); + return false; + } - return false; - } - - if ((!onlyLatestMsgs) && onlyThreadMsgs) - { -#ifdef DATA_DEBUG - RsDbg() << "RsGxsDataAccess::getMsgRelatedList() ERROR Incompatible FLAGS (!LATEST & THREAD)" << std::endl; -#endif - - return false; - } - - if (onlyChildMsgs && onlyThreadMsgs) - { -#ifdef DATA_DEBUG - RsDbg() << "RsGxsDataAccess::getMsgRelatedList() ERROR Incompatible FLAGS (PARENT & THREAD)" << std::endl; -#endif - - return false; - } - - - /* FALL BACK OPTION */ - if ((!onlyLatestMsgs) && (!onlyAllVersions) && (!onlyChildMsgs) && (!onlyThreadMsgs)) - { -#ifdef DATA_DEBUG - RsDbg() << "RsGxsDataAccess::getMsgRelatedList() FALLBACK -> NO FLAGS -> SIMPLY RETURN nothing" << std::endl; -#endif - - return true; - } + if( (!onlyLatestMsgs) && (!onlyAllVersions) && (!onlyChildMsgs) && + (!onlyThreadMsgs) ) + { + RS_WARN("NO FLAGS -> SIMPLY RETURN nothing"); + return true; + } for(auto vit_msgIds(req->mMsgIds.begin()); vit_msgIds != req->mMsgIds.end(); ++vit_msgIds) { @@ -1330,14 +1311,11 @@ bool RsGxsDataAccess::getMsgRelatedInfo(MsgRelatedInfoReq *req) } } - if(!origMeta) - { -#ifdef DATA_DEBUG - RsDbg() << "RsGxsDataAccess::getMsgRelatedInfo(): Cannot find meta of msgId (to relate to)!" - << std::endl; -#endif - return false; - } + if(!origMeta) + { + RS_ERR("Cannot find meta of msgId: ", msgId, " to relate to"); + return false; + } const RsGxsMessageId& origMsgId = origMeta->mOrigMsgId; std::map& metaMap = filterMap[grpId]; diff --git a/libretroshare/src/gxs/rsgxsnetservice.cc b/libretroshare/src/gxs/rsgxsnetservice.cc index 79be6fb95..8ed657bfb 100644 --- a/libretroshare/src/gxs/rsgxsnetservice.cc +++ b/libretroshare/src/gxs/rsgxsnetservice.cc @@ -275,7 +275,7 @@ NXS_NET_DEBUG_9 gxs distant search ***/ -#define NXS_NET_DEBUG_0 1 +//#define NXS_NET_DEBUG_0 1 //#define NXS_NET_DEBUG_1 1 //#define NXS_NET_DEBUG_2 1 //#define NXS_NET_DEBUG_3 1 @@ -324,8 +324,8 @@ static const uint32_t RS_NXS_ITEM_ENCRYPTION_STATUS_GXS_KEY_MISSING = 0x05 ; || defined(NXS_NET_DEBUG_8) || defined(NXS_NET_DEBUG_9) static const RsPeerId peer_to_print = RsPeerId();//std::string("a97fef0e2dc82ddb19200fb30f9ac575")) ; -static const RsGxsGroupId group_id_to_print = RsGxsGroupId(std::string("66052380f5d1d0c5992e2b55dc402ce6")) ; // use this to allow to this group id only, or "" for all IDs -static const uint32_t service_to_print = RS_SERVICE_GXS_TYPE_GXSCIRCLE; // use this to allow to this service id only, or 0 for all services +static const RsGxsGroupId group_id_to_print = RsGxsGroupId();//std::string("66052380f5d1d0c5992e2b55dc402ce6")) ; // use this to allow to this group id only, or "" for all IDs +static const uint32_t service_to_print = RS_SERVICE_GXS_TYPE_GXSID; // use this to allow to this service id only, or 0 for all services // warning. Numbers should be SERVICE IDS (see serialiser/rsserviceids.h. E.g. 0x0215 for forums) class nullstream: public std::ostream {}; @@ -593,32 +593,30 @@ void RsGxsNetService::syncWithPeers() return; } - std::set::iterator sit = peers.begin(); + // for now just grps + for(auto sit = peers.begin(); sit != peers.end(); ++sit) + { - // for now just grps - for(; sit != peers.end(); ++sit) - { + const RsPeerId peerId = *sit; - const RsPeerId peerId = *sit; + ClientGrpMap::const_iterator cit = mClientGrpUpdateMap.find(peerId); + uint32_t updateTS = 0; - ClientGrpMap::const_iterator cit = mClientGrpUpdateMap.find(peerId); - uint32_t updateTS = 0; - - if(cit != mClientGrpUpdateMap.end()) - { - const RsGxsGrpUpdate *gui = &cit->second; - updateTS = gui->grpUpdateTS; - } - RsNxsSyncGrpReqItem *grp = new RsNxsSyncGrpReqItem(mServType); - grp->clear(); - grp->PeerId(*sit); - grp->updateTS = updateTS; + if(cit != mClientGrpUpdateMap.end()) + { + const RsGxsGrpUpdate *gui = &cit->second; + updateTS = gui->grpUpdateTS; + } + RsNxsSyncGrpReqItem *grp = new RsNxsSyncGrpReqItem(mServType); + grp->clear(); + grp->PeerId(*sit); + grp->updateTS = updateTS; #ifdef NXS_NET_DEBUG_5 - GXSNETDEBUG_P_(*sit) << "Service "<< std::hex << ((mServiceInfo.mServiceType >> 8)& 0xffff) << std::dec << " sending global group TS of peer id: " << *sit << " ts=" << nice_time_stamp(time(NULL),updateTS) << " (secs ago) to himself" << std::endl; + GXSNETDEBUG_P_(*sit) << "Service "<< std::hex << ((mServiceInfo.mServiceType >> 8)& 0xffff) << std::dec << " sending global group TS of peer id: " << *sit << " ts=" << nice_time_stamp(time(NULL),updateTS) << " (secs ago) to himself" << std::endl; #endif - generic_sendItem(grp); - } + generic_sendItem(grp); + } if(!mAllowMsgSync) return ; @@ -644,15 +642,13 @@ void RsGxsNetService::syncWithPeers() } } - sit = peers.begin(); - // Synchronise group msg for groups which we're subscribed to // For each peer and each group, we send to the peer the time stamp of the most // recent modification the peer has sent. If the peer has more recent messages he will send them, because its latest // modifications will be more recent. This ensures that we always compare timestamps all taken in the same // computer (the peer's computer in this case) - for(; sit != peers.end(); ++sit) + for(auto sit = peers.begin(); sit != peers.end(); ++sit) { const RsPeerId& peerId = *sit; @@ -3183,7 +3179,8 @@ void RsGxsNetService::locked_genReqGrpTransaction(NxsTransaction* tr) { grpItemL.push_back(item); grpMetaMap[item->grpId] = NULL; - }else + } + else { #ifdef NXS_NET_DEBUG_0 GXSNETDEBUG_PG(tr->mTransaction->PeerId(),item->grpId) << "RsGxsNetService::genReqGrpTransaction(): item failed to caste to RsNxsSyncMsgItem* " << std::endl; @@ -3226,7 +3223,7 @@ void RsGxsNetService::locked_genReqGrpTransaction(NxsTransaction* tr) RsNxsSyncGrpItem*& grpSyncItem = *llit; const RsGxsGroupId& grpId = grpSyncItem->grpId; - std::map::const_iterator metaIter = grpMetaMap.find(grpId); + std::map::const_iterator metaIter = grpMetaMap.find(grpId); bool haveItem = false; bool latestVersion = false; @@ -3237,19 +3234,21 @@ void RsGxsNetService::locked_genReqGrpTransaction(NxsTransaction* tr) } // FIXTESTS global variable rsReputations not available in unittests! -#warning csoler 2016-12-23: Update the code below to correctly send/recv dependign on reputation - if( !grpSyncItem->authorId.isNull() && - mReputations->overallReputationLevel(grpSyncItem->authorId) == - RsReputationLevel::LOCALLY_NEGATIVE ) + if( mReputations->overallReputationLevel(RsGxsId(grpSyncItem->grpId)) == RsReputationLevel::LOCALLY_NEGATIVE ) { #ifdef NXS_NET_DEBUG_0 - GXSNETDEBUG_PG(tr->mTransaction->PeerId(),grpId) << " Identity " << grpSyncItem->authorId << " is banned. Not syncing group." << std::endl; + GXSNETDEBUG_PG(tr->mTransaction->PeerId(),grpId) << " Identity " << grpSyncItem->grpId << " is banned. Not GXS-syncing group." << std::endl; #endif continue ; } if( (mGrpAutoSync && !haveItem) || latestVersion) + { +#ifdef NXS_NET_DEBUG_0 + GXSNETDEBUG_PG(tr->mTransaction->PeerId(),grpId) << " Identity " << grpId << " will be sync-ed using GXS. mGrpAutoSync:" << mGrpAutoSync << " haveItem:" << haveItem << " latest_version: " << latestVersion << std::endl; +#endif addGroupItemToList(tr, grpId, transN, reqList); + } } if(!reqList.empty()) diff --git a/libretroshare/src/gxs/rsgxsutil.cc b/libretroshare/src/gxs/rsgxsutil.cc index 951476403..79ae187bd 100644 --- a/libretroshare/src/gxs/rsgxsutil.cc +++ b/libretroshare/src/gxs/rsgxsutil.cc @@ -215,7 +215,8 @@ bool RsGxsIntegrityCheck::check() rsReputations->overallReputationLevel( grp->metaData->mAuthorId ) > RsReputationLevel::LOCALLY_NEGATIVE ) - used_gxs_ids.insert(std::make_pair(grp->metaData->mAuthorId, RsIdentityUsage(mGenExchangeClient->serviceType(), RsIdentityUsage::GROUP_AUTHOR_KEEP_ALIVE,grp->grpId))); + used_gxs_ids.insert(std::make_pair(grp->metaData->mAuthorId, RsIdentityUsage(RsServiceType(mGenExchangeClient->serviceType()), + RsIdentityUsage::GROUP_AUTHOR_KEEP_ALIVE,grp->grpId))); } } } @@ -404,7 +405,12 @@ bool RsGxsIntegrityCheck::check() rsReputations->overallReputationLevel( msg->metaData->mAuthorId ) > RsReputationLevel::LOCALLY_NEGATIVE ) - used_gxs_ids.insert(std::make_pair(msg->metaData->mAuthorId,RsIdentityUsage(mGenExchangeClient->serviceType(),RsIdentityUsage::MESSAGE_AUTHOR_KEEP_ALIVE,msg->metaData->mGroupId,msg->metaData->mMsgId))) ; + used_gxs_ids.insert(std::make_pair(msg->metaData->mAuthorId,RsIdentityUsage(RsServiceType(mGenExchangeClient->serviceType()), + RsIdentityUsage::MESSAGE_AUTHOR_KEEP_ALIVE, + msg->metaData->mGroupId, + msg->metaData->mMsgId, + msg->metaData->mParentId, + msg->metaData->mThreadId))) ; } } diff --git a/libretroshare/src/gxstunnel/p3gxstunnel.cc b/libretroshare/src/gxstunnel/p3gxstunnel.cc index 543817ffc..2909238ea 100644 --- a/libretroshare/src/gxstunnel/p3gxstunnel.cc +++ b/libretroshare/src/gxstunnel/p3gxstunnel.cc @@ -976,7 +976,7 @@ void p3GxsTunnelService::handleRecvDHPublicKey(RsGxsTunnelDHPublicKeyItem *item) std::cerr << "(SS) Signature was verified and it doesn't check! This is a security issue!" << std::endl; return ; } - mGixs->timeStampKey(item->signature.keyId,RsIdentityUsage(RS_SERVICE_TYPE_GXS_TUNNEL,RsIdentityUsage::GXS_TUNNEL_DH_SIGNATURE_CHECK)); + mGixs->timeStampKey(item->signature.keyId,RsIdentityUsage(RsServiceType::GXS_TUNNEL,RsIdentityUsage::GXS_TUNNEL_DH_SIGNATURE_CHECK)); #ifdef DEBUG_GXS_TUNNEL std::cerr << " Signature checks! Sender's ID = " << senders_id << std::endl; diff --git a/libretroshare/src/libretroshare.pro b/libretroshare/src/libretroshare.pro index 837c1f715..2606e4083 100644 --- a/libretroshare/src/libretroshare.pro +++ b/libretroshare/src/libretroshare.pro @@ -238,7 +238,7 @@ win32-x-g++ { } ################################# Windows ########################################## -win32-g++ { +win32-g++|win32-clang-g++ { QMAKE_CC = $${QMAKE_CXX} OBJECTS_DIR = temp/obj MOC_DIR = temp/moc @@ -852,23 +852,41 @@ rs_jsonapi { no_rs_cross_compiling { DUMMYRESTBEDINPUT = FORCE CMAKE_GENERATOR_OVERRIDE="" - win32-g++:CMAKE_GENERATOR_OVERRIDE="-G \"MSYS Makefiles\"" + win32-g++|win32-clang-g++ { + isEmpty(QMAKE_SH) { + CMAKE_GENERATOR_OVERRIDE="-G \"MinGW Makefiles\"" + } else { + CMAKE_GENERATOR_OVERRIDE="-G \"MSYS Makefiles\"" + } + } genrestbedlib.name = Generating librestbed. genrestbedlib.input = DUMMYRESTBEDINPUT genrestbedlib.output = $$clean_path($${RESTBED_BUILD_PATH}/librestbed.a) genrestbedlib.CONFIG += target_predeps combine genrestbedlib.variable_out = PRE_TARGETDEPS - genrestbedlib.commands = \ - cd $${RS_SRC_PATH} && ( \ - git submodule update --init supportlibs/restbed ; \ - cd $${RESTBED_SRC_PATH} ; \ - git submodule update --init dependency/asio ; \ - git submodule update --init dependency/catch ; \ - git submodule update --init dependency/kashmir ; \ - true ) && \ - mkdir -p $${RESTBED_BUILD_PATH} && cd $${RESTBED_BUILD_PATH} && \ + win32-g++:isEmpty(QMAKE_SH) { + genrestbedlib.commands = \ + cd $$shell_path($${RS_SRC_PATH}) && git submodule update --init supportlibs/restbed || cd . $$escape_expand(\\n\\t) \ + cd $$shell_path($${RESTBED_SRC_PATH}) && git submodule update --init dependency/asio || cd . $$escape_expand(\\n\\t) \ + cd $$shell_path($${RESTBED_SRC_PATH}) && git submodule update --init dependency/catch || cd . $$escape_expand(\\n\\t )\ + cd $$shell_path($${RESTBED_SRC_PATH}) && git submodule update --init dependency/kashmir || cd . $$escape_expand(\\n\\t) \ + $(CHK_DIR_EXISTS) $$shell_path($$UDP_DISCOVERY_BUILD_PATH) $(MKDIR) $$shell_path($${UDP_DISCOVERY_BUILD_PATH}) $$escape_expand(\\n\\t) + } else { + genrestbedlib.commands = \ + cd $${RS_SRC_PATH} && ( \ + git submodule update --init supportlibs/restbed ; \ + cd $${RESTBED_SRC_PATH} ; \ + git submodule update --init dependency/asio ; \ + git submodule update --init dependency/catch ; \ + git submodule update --init dependency/kashmir ; \ + true ) && \ + mkdir -p $${RESTBED_BUILD_PATH} && + } + genrestbedlib.commands += \ + cd $$shell_path($${RESTBED_BUILD_PATH}) && \ cmake \ -DCMAKE_CXX_COMPILER=$$QMAKE_CXX \ + \"-DCMAKE_CXX_FLAGS=$${QMAKE_CXXFLAGS}\" \ $${CMAKE_GENERATOR_OVERRIDE} -DBUILD_SSL=OFF \ -DCMAKE_INSTALL_PREFIX=. -B. \ -H$$shell_path($${RESTBED_SRC_PATH}) && \ @@ -881,7 +899,7 @@ rs_jsonapi { genrestbedheader.output = $${RESTBED_HEADER_FILE} genrestbedheader.CONFIG += target_predeps no_link genrestbedheader.variable_out = HEADERS - genrestbedheader.commands = cd $${RESTBED_BUILD_PATH} && $(MAKE) install + genrestbedheader.commands = cd $$shell_path($${RESTBED_BUILD_PATH}) && $(MAKE) install QMAKE_EXTRA_COMPILERS += genrestbedheader } @@ -897,13 +915,19 @@ rs_jsonapi { genjsonapi.clean = $${WRAPPERS_INCL_FILE} $${WRAPPERS_REG_FILE} genjsonapi.CONFIG += target_predeps combine no_link genjsonapi.variable_out = HEADERS - genjsonapi.commands = \ - mkdir -p $${JSONAPI_GENERATOR_OUT} && \ - cp $${DOXIGEN_CONFIG_SRC} $${DOXIGEN_CONFIG_OUT} && \ - echo OUTPUT_DIRECTORY=$${JSONAPI_GENERATOR_OUT} >> $${DOXIGEN_CONFIG_OUT} && \ - echo INPUT=$${DOXIGEN_INPUT_DIRECTORY} >> $${DOXIGEN_CONFIG_OUT} && \ - doxygen $${DOXIGEN_CONFIG_OUT} && \ - $${JSONAPI_GENERATOR_EXE} $${JSONAPI_GENERATOR_SRC} $${JSONAPI_GENERATOR_OUT}; + win32-g++:isEmpty(QMAKE_SH) { + genjsonapi.commands = \ + $(CHK_DIR_EXISTS) $$shell_path($$JSONAPI_GENERATOR_OUT) $(MKDIR) $$shell_path($${JSONAPI_GENERATOR_OUT}) $$escape_expand(\\n\\t) + } else { + genjsonapi.commands = \ + mkdir -p $${JSONAPI_GENERATOR_OUT} && \ + cp $${DOXIGEN_CONFIG_SRC} $${DOXIGEN_CONFIG_OUT} && \ + echo OUTPUT_DIRECTORY=$${JSONAPI_GENERATOR_OUT} >> $${DOXIGEN_CONFIG_OUT} && \ + echo INPUT=$${DOXIGEN_INPUT_DIRECTORY} >> $${DOXIGEN_CONFIG_OUT} && \ + doxygen $${DOXIGEN_CONFIG_OUT} && + } + genjsonapi.commands += \ + $${JSONAPI_GENERATOR_EXE} $${JSONAPI_GENERATOR_SRC} $${JSONAPI_GENERATOR_OUT} QMAKE_EXTRA_COMPILERS += genjsonapi # Force recalculation of libretroshare dependencies see https://stackoverflow.com/a/47884045 @@ -949,20 +973,34 @@ rs_broadcast_discovery { no_rs_cross_compiling { DUMMYQMAKECOMPILERINPUT = FORCE CMAKE_GENERATOR_OVERRIDE="" - win32-g++:CMAKE_GENERATOR_OVERRIDE="-G \"MSYS Makefiles\"" + win32-g++|win32-clang-g++ { + isEmpty(QMAKE_SH) { + CMAKE_GENERATOR_OVERRIDE="-G \"MinGW Makefiles\"" + } else { + CMAKE_GENERATOR_OVERRIDE="-G \"MSYS Makefiles\"" + } + } udpdiscoverycpplib.name = Generating libudp-discovery.a. udpdiscoverycpplib.input = DUMMYQMAKECOMPILERINPUT udpdiscoverycpplib.output = $$clean_path($${UDP_DISCOVERY_BUILD_PATH}/libudp-discovery.a) udpdiscoverycpplib.CONFIG += target_predeps combine udpdiscoverycpplib.variable_out = PRE_TARGETDEPS - udpdiscoverycpplib.commands = \ - cd $${RS_SRC_PATH} && ( \ - git submodule update --init supportlibs/udp-discovery-cpp || \ - true ) && \ - mkdir -p $${UDP_DISCOVERY_BUILD_PATH} && \ - cd $${UDP_DISCOVERY_BUILD_PATH} && \ + win32-g++:isEmpty(QMAKE_SH) { + udpdiscoverycpplib.commands = \ + cd $$shell_path($${RS_SRC_PATH}) && git submodule update --init supportlibs/udp-discovery-cpp || cd . $$escape_expand(\\n\\t) \ + $(CHK_DIR_EXISTS) $$shell_path($$UDP_DISCOVERY_BUILD_PATH) $(MKDIR) $$shell_path($${UDP_DISCOVERY_BUILD_PATH}) $$escape_expand(\\n\\t) + } else { + udpdiscoverycpplib.commands = \ + cd $${RS_SRC_PATH} && ( \ + git submodule update --init supportlibs/udp-discovery-cpp || \ + true ) && \ + mkdir -p $${UDP_DISCOVERY_BUILD_PATH} && + } + udpdiscoverycpplib.commands += \ + cd $$shell_path($${UDP_DISCOVERY_BUILD_PATH}) && \ cmake -DCMAKE_C_COMPILER=$$fixQmakeCC($$QMAKE_CC) \ -DCMAKE_CXX_COMPILER=$$QMAKE_CXX \ + \"-DCMAKE_CXX_FLAGS=$${QMAKE_CXXFLAGS}\" \ $${CMAKE_GENERATOR_OVERRIDE} \ -DBUILD_EXAMPLE=OFF -DBUILD_TOOL=OFF \ -DCMAKE_INSTALL_PREFIX=. -B. \ diff --git a/libretroshare/src/retroshare/rsgxsforums.h b/libretroshare/src/retroshare/rsgxsforums.h index c033bf3ac..7bec23b6c 100644 --- a/libretroshare/src/retroshare/rsgxsforums.h +++ b/libretroshare/src/retroshare/rsgxsforums.h @@ -4,7 +4,8 @@ * libretroshare: retroshare core library * * * * Copyright (C) 2012-2014 Robert Fernie * - * Copyright (C) 2018-2019 Gioacchino Mazzurco * + * Copyright (C) 2018-2020 Gioacchino Mazzurco * + * Copyright (C) 2019-2020 Asociación Civil Altermundi * * * * This program is free software: you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as * @@ -25,6 +26,7 @@ #include #include #include +#include #include "retroshare/rstokenservice.h" #include "retroshare/rsgxsifacehelper.h" @@ -353,6 +355,19 @@ public: RsGxsGroupId& forumId = RS_DEFAULT_STORAGE_PARAM(RsGxsGroupId), std::string& errMsg = RS_DEFAULT_STORAGE_PARAM(std::string) ) = 0; + /** + * @brief Get posts related to the given post. + * If the set is empty, nothing is returned. + * @jsonapi{development} + * @param[in] forumId id of the forum of which the content is requested + * @param[in] parentId id of the post of which child posts (aka replies) + * are requested. + * @param[out] childPosts storage for the child posts + * @return false if something failed, true otherwhise + */ + virtual std::error_condition getChildPosts( + const RsGxsGroupId& forumId, const RsGxsMessageId& parentId, + std::vector& childPosts ) = 0; /** * @brief Create forum. Blocking API. diff --git a/libretroshare/src/retroshare/rsgxsifacehelper.h b/libretroshare/src/retroshare/rsgxsifacehelper.h index 7db596873..4339f95f0 100644 --- a/libretroshare/src/retroshare/rsgxsifacehelper.h +++ b/libretroshare/src/retroshare/rsgxsifacehelper.h @@ -50,12 +50,13 @@ enum class TokenRequestType: uint8_t __NONE = 0x00, /// Used to detect uninitialized GROUP_DATA = 0x01, GROUP_META = 0x02, - POSTS = 0x03, - ALL_POSTS = 0x04, - MSG_RELATED_INFO = 0x05, - GROUP_STATISTICS = 0x06, - SERVICE_STATISTICS = 0x07, - NO_KILL_TYPE = 0x08, + GROUP_IDS = 0x03, + POSTS = 0x04, + ALL_POSTS = 0x05, + MSG_RELATED_INFO = 0x06, + GROUP_STATISTICS = 0x07, + SERVICE_STATISTICS = 0x08, + NO_KILL_TYPE = 0x09, __MAX /// Used to detect out of range }; @@ -263,6 +264,7 @@ public: { case GXS_REQUEST_TYPE_GROUP_DATA: token_request_type = TokenRequestType::GROUP_DATA; break; case GXS_REQUEST_TYPE_GROUP_META: token_request_type = TokenRequestType::GROUP_META; break; + case GXS_REQUEST_TYPE_GROUP_IDS: token_request_type = TokenRequestType::GROUP_IDS; break; default: RsErr() << __PRETTY_FUNCTION__ << "(EE) Unexpected request type " << opts.mReqType << "!!" << std::endl; return false; @@ -292,6 +294,7 @@ public: { case GXS_REQUEST_TYPE_GROUP_DATA: token_request_type = TokenRequestType::GROUP_DATA; break; case GXS_REQUEST_TYPE_GROUP_META: token_request_type = TokenRequestType::GROUP_META; break; + case GXS_REQUEST_TYPE_GROUP_IDS: token_request_type = TokenRequestType::GROUP_IDS; break; default: RsErr() << __PRETTY_FUNCTION__ << "(EE) Unexpected request type " << opts.mReqType << "!!" << std::endl; return false; diff --git a/libretroshare/src/retroshare/rsidentity.h b/libretroshare/src/retroshare/rsidentity.h index d1345461e..7fa23697a 100644 --- a/libretroshare/src/retroshare/rsidentity.h +++ b/libretroshare/src/retroshare/rsidentity.h @@ -234,31 +234,30 @@ struct RsIdentityUsage : RsSerializable GXS_TUNNEL_DH_SIGNATURE_CHECK = 0x0c, GXS_TUNNEL_DH_SIGNATURE_CREATION = 0x0d, + /// Identity received through GXS sync + IDENTITY_NEW_FROM_GXS_SYNC = 0x0e, /// Group update on that identity data. Can be avatar, name, etc. - IDENTITY_DATA_UPDATE = 0x0e, + IDENTITY_NEW_FROM_DISCOVERY = 0x0f, + /// Explicit request to friend + IDENTITY_NEW_FROM_EXPLICIT_REQUEST = 0x10, /// Any signature verified for that identity - IDENTITY_GENERIC_SIGNATURE_CHECK = 0x0f, + IDENTITY_GENERIC_SIGNATURE_CHECK = 0x11, /// Any signature made by that identity - IDENTITY_GENERIC_SIGNATURE_CREATION = 0x10, + IDENTITY_GENERIC_SIGNATURE_CREATION = 0x12, - IDENTITY_GENERIC_ENCRYPTION = 0x11, - IDENTITY_GENERIC_DECRYPTION = 0x12, - CIRCLE_MEMBERSHIP_CHECK = 0x13 + IDENTITY_GENERIC_ENCRYPTION = 0x13, + IDENTITY_GENERIC_DECRYPTION = 0x14, + CIRCLE_MEMBERSHIP_CHECK = 0x15 } ; - RS_DEPRECATED - RsIdentityUsage( uint16_t service, const RsIdentityUsage::UsageCode& code, - const RsGxsGroupId& gid = RsGxsGroupId(), - const RsGxsMessageId& mid = RsGxsMessageId(), - uint64_t additional_id=0, - const std::string& comment = std::string() ); - RsIdentityUsage( RsServiceType service, RsIdentityUsage::UsageCode code, const RsGxsGroupId& gid = RsGxsGroupId(), - const RsGxsMessageId& mid = RsGxsMessageId(), + const RsGxsMessageId& message_id = RsGxsMessageId(), + const RsGxsMessageId& parent_id = RsGxsMessageId(), + const RsGxsMessageId& thread_id = RsGxsMessageId(), uint64_t additional_id=0, const std::string& comment = std::string() ); @@ -275,6 +274,12 @@ struct RsIdentityUsage : RsSerializable /// Message ID using the identity RsGxsMessageId mMsgId; + /// Reference message ID. Useful for votes/comments + RsGxsMessageId mParentId; + + /// Reference message ID. Useful for votes/comments + RsGxsMessageId mThreadId; + /// Some additional ID. Can be used for e.g. chat lobbies. uint64_t mAdditionalId; diff --git a/libretroshare/src/retroshare/rswire.h b/libretroshare/src/retroshare/rswire.h index 03da21116..34c953cee 100644 --- a/libretroshare/src/retroshare/rswire.h +++ b/libretroshare/src/retroshare/rswire.h @@ -35,11 +35,38 @@ class RsWire; extern RsWire *rsWire; -struct RsWireGroup: RsGxsGenericGroupData +class RsWireGroup; +typedef std::shared_ptr RsWireGroupSPtr; +typedef std::shared_ptr RsWireGroupConstSPtr; + +class RsWireGroup: public RsGxsGenericGroupData { public: - std::string mDescription; - RsGxsImage mIcon; + RsWireGroup(); + + std::string mTagline; + std::string mLocation; + + // Images max size should be enforced. + RsGxsImage mHeadshot; // max size? + RsGxsImage mMasthead; // max size? + + // Unserialised stuff --------------------- + + // These are this groups top-level msgs. + uint32_t mGroupPulses; + uint32_t mGroupRepublishes; + uint32_t mGroupLikes; + uint32_t mGroupReplies; + // how do we handle these. TODO + // uint32_t mGroupFollowing; + // uint32_t mGroupFollowers; + + // These are this groups REF / RESPONSE msgs from others. + uint32_t mRefMentions; // TODO how to handle this? + uint32_t mRefRepublishes; + uint32_t mRefLikes; + uint32_t mRefReplies; }; @@ -60,13 +87,7 @@ struct RsWireGroup: RsGxsGenericGroupData * ***********************************************************************/ -class RsWirePlace -{ - public: - - -}; /************************************************************************ * Pulse comes in three flavours. @@ -82,24 +103,39 @@ class RsWirePlace * This info will be duplicated in two msgs - but allow data to spread easier. * * Reply Msg Pulse, will be Top-Level Msg on Publisher's Group. - * - mPulseMode = WIRE_PULSE_TYPE_REPLY_MSG + * - mPulseMode = WIRE_PULSE_TYPE_RESPONSE | WIRE_PULSE_TYPE_REPLY * - Ref fields refer to Parent (InReplyTo) Msg. * * Reply Reference, is Child Msg of Parent Msg, on Parent Publisher's Group. - * - mPulseMode = WIRE_PULSE_TYPE_REPLY_REFERENCE + * - mPulseMode = WIRE_PULSE_TYPE_REFERENCE | WIRE_PULSE_TYPE_REPLY * - Ref fields refer to Reply Msg. * - NB: This Msg requires Parent Msg for complete info, while other two are self-contained. + * + * Additionally need to sort out additional relationships. + * - Mentions. + * - Followers. + * - Following. ***********************************************************************/ -#define WIRE_PULSE_TYPE_ORIGINAL_MSG (0x0001) -#define WIRE_PULSE_TYPE_REPLY_MSG (0x0002) -#define WIRE_PULSE_TYPE_REPLY_REFERENCE (0x0004) +#define WIRE_PULSE_TYPE_ORIGINAL (0x0001) +#define WIRE_PULSE_TYPE_RESPONSE (0x0002) +#define WIRE_PULSE_TYPE_REFERENCE (0x0004) + +#define WIRE_PULSE_RESPONSE_MASK (0x0f00) +#define WIRE_PULSE_TYPE_REPLY (0x0100) +#define WIRE_PULSE_TYPE_REPUBLISH (0x0200) +#define WIRE_PULSE_TYPE_LIKE (0x0400) #define WIRE_PULSE_SENTIMENT_NO_SENTIMENT (0x0000) #define WIRE_PULSE_SENTIMENT_POSITIVE (0x0001) #define WIRE_PULSE_SENTIMENT_NEUTRAL (0x0002) #define WIRE_PULSE_SENTIMENT_NEGATIVE (0x0003) +class RsWirePulse; + +typedef std::shared_ptr RsWirePulseSPtr; +typedef std::shared_ptr RsWirePulseConstSPtr; + class RsWirePulse { public: @@ -110,23 +146,50 @@ class RsWirePulse std::string mPulseText; uint32_t mPulseType; - uint32_t mReplySentiment; // only relevant if a reply. + uint32_t mSentiment; // sentiment can be asserted at any point. - // These Ref to the related (parent or reply) if reply (MODE_REPLY_MSG set) - // Mode REPLY_MSG only REPLY_REFERENCE - RsGxsGroupId mRefGroupId; // PARENT_GrpId REPLY_GrpId - std::string mRefGroupName; // PARENT_GrpName REPLY_GrpName - RsGxsMessageId mRefOrigMsgId; // PARENT_OrigMsgId REPLY_OrigMsgId - RsGxsId mRefAuthorId; // PARENT_AuthorId REPLY_AuthorId - rstime_t mRefPublishTs; // PARENT_PublishTs REPLY_PublishTs - std::string mRefPulseText; // PARENT_PulseText REPLY_PulseText + // These Ref to the related (parent or reply) if reply (RESPONSE set) + // Mode RESPONSE REFERENCE + RsGxsGroupId mRefGroupId; // PARENT_GrpId REPLY_GrpId + std::string mRefGroupName; // PARENT_GrpName REPLY_GrpName + RsGxsMessageId mRefOrigMsgId; // PARENT_OrigMsgId REPLY_OrigMsgId + RsGxsId mRefAuthorId; // PARENT_AuthorId REPLY_AuthorId + rstime_t mRefPublishTs; // PARENT_PublishTs REPLY_PublishTs + std::string mRefPulseText; // PARENT_PulseText REPLY_PulseText + uint32_t mRefImageCount; // PARENT_#Images REPLY_#Images - // Open Question. Do we want these additional fields? - // These can potentially be added at some point. - // std::list mMentions; - // std::list mHashTags; - // std::list mUrls; - // RsWirePlace mPlace; + // Additional Fields for version 2. + // Images, need to enforce 20k limit? + RsGxsImage mImage1; + RsGxsImage mImage2; + RsGxsImage mImage3; + RsGxsImage mImage4; + + // Below Here is not serialised. + // They are additional fields linking pulses together or parsing elements of msg. + + // functions. + uint32_t ImageCount(); + + // can't have self referencial list, so need to use pointers. + // using SharedPointers to automatically cleanup. + + // Pointer to WireGroups + // mRefGroupPtr is opportunistically filled in, but will often be empty. + RsWireGroupSPtr mRefGroupPtr; // ORIG: N/A, RESP: Parent, REF: Reply Group + RsWireGroupSPtr mGroupPtr; // ORIG: Own, RESP: Own, REF: Parent Group + + // These are the direct children of this message + // split into likes, replies and retweets. + std::list mReplies; + std::list mLikes; + std::list mRepublishes; + + // parsed from msg. + // do we need references..? + std::list mHashTags; + std::list mMentions; + std::list mUrls; }; @@ -158,7 +221,29 @@ virtual bool createPulse(uint32_t &token, RsWirePulse &pulse) = 0; // Blocking Interfaces. virtual bool createGroup(RsWireGroup &group) = 0; virtual bool updateGroup(const RsWireGroup &group) = 0; -virtual bool getGroups(const std::list grpIds, std::vector &groups) = 0; +virtual bool getGroups(const std::list grpIds, + std::vector &groups) = 0; + + // New Blocking Interfaces. + // Plan to migrate all GUI calls to these, and remove old interfaces above. + // These are not single requests, but return data graphs for display. +virtual bool createOriginalPulse(const RsGxsGroupId &grpId, RsWirePulseSPtr pPulse) = 0; +virtual bool createReplyPulse(RsGxsGroupId grpId, RsGxsMessageId msgId, + RsGxsGroupId replyWith, uint32_t reply_type, + RsWirePulseSPtr pPulse) = 0; + + + // Provide Individual Group Details for display. +virtual bool getWireGroup(const RsGxsGroupId &groupId, RsWireGroupSPtr &grp) = 0; +virtual bool getWirePulse(const RsGxsGroupId &groupId, const RsGxsMessageId &msgId, RsWirePulseSPtr &pPulse) = 0; + + // Provide list of pulses associated with groups. +virtual bool getPulsesForGroups(const std::list &groupIds, + std::list &pulsePtrs) = 0; + + // Provide pulse, and associated replies / like etc. +virtual bool getPulseFocus(const RsGxsGroupId &groupId, const RsGxsMessageId &msgId, + int type, RsWirePulseSPtr &pPulse) = 0; }; diff --git a/libretroshare/src/rsitems/rswireitems.cc b/libretroshare/src/rsitems/rswireitems.cc index 69774ffc5..a618336f7 100644 --- a/libretroshare/src/rsitems/rswireitems.cc +++ b/libretroshare/src/rsitems/rswireitems.cc @@ -43,39 +43,55 @@ RsItem *RsGxsWireSerialiser::create_item(uint16_t service,uint8_t item_subtype) void RsGxsWireGroupItem::clear() { - group.mDescription.clear(); - group.mIcon.clear(); + group.mTagline.clear(); + group.mLocation.clear(); + group.mHeadshot.clear(); + group.mMasthead.clear(); } void RsGxsWireGroupItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx) { - RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_DESCR,group.mDescription,"group.mDescription") ; - group.mIcon.serial_process(j, ctx); + RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_DESCR,group.mTagline,"group.mTagline") ; + RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_LOCATION,group.mLocation,"group.mLocation") ; + group.mHeadshot.serial_process(j, ctx); + group.mMasthead.serial_process(j, ctx); } void RsGxsWirePulseItem::clear() { pulse.mPulseText.clear(); pulse.mPulseType = 0; - pulse.mReplySentiment = 0; + pulse.mSentiment = 0; pulse.mRefGroupId.clear(); pulse.mRefGroupName.clear(); pulse.mRefOrigMsgId.clear(); pulse.mRefAuthorId.clear(); + pulse.mRefPublishTs = 0; pulse.mRefPulseText.clear(); + pulse.mRefImageCount = 0; + + pulse.mImage1.clear(); + pulse.mImage2.clear(); + pulse.mImage3.clear(); + pulse.mImage4.clear(); } void RsGxsWirePulseItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx) { RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_MSG,pulse.mPulseText,"pulse.mPulseText") ; RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_UINT32_PARAM,pulse.mPulseType,"pulse.mPulseType") ; - RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_UINT32_PARAM,pulse.mReplySentiment,"pulse.mReplySentiment") ; + RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_UINT32_PARAM,pulse.mSentiment,"pulse.mSentiment") ; RsTypeSerializer::serial_process(j,ctx,pulse.mRefGroupId,"pulse.mRefGroupId") ; RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_NAME,pulse.mRefGroupName,"pulse.mRefGroupName") ; RsTypeSerializer::serial_process(j,ctx,pulse.mRefOrigMsgId,"pulse.mRefOrigMsgId") ; RsTypeSerializer::serial_process(j,ctx,pulse.mRefAuthorId,"pulse.mRefAuthorId") ; RsTypeSerializer::serial_process(j,ctx,pulse.mRefPublishTs,"pulse.mRefPublishTs") ; RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_MSG,pulse.mRefPulseText,"pulse.mRefPulseText") ; + RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_UINT32_PARAM,pulse.mRefImageCount,"pulse.mRefImageCount") ; + pulse.mImage1.serial_process(j, ctx); + pulse.mImage2.serial_process(j, ctx); + pulse.mImage3.serial_process(j, ctx); + pulse.mImage4.serial_process(j, ctx); } diff --git a/libretroshare/src/services/p3gxscircles.cc b/libretroshare/src/services/p3gxscircles.cc index 58da554a1..80f5fa290 100644 --- a/libretroshare/src/services/p3gxscircles.cc +++ b/libretroshare/src/services/p3gxscircles.cc @@ -1463,12 +1463,14 @@ bool p3GxsCircles::locked_processLoadingCacheEntry(RsGxsCircleCache& cache) } else { +#ifdef DEBUG_CIRCLES std::cerr << " (WW) cache entry for circle " << cache.mCircleId << " has empty originator. Asking info for GXS id " << pit->first << " to all connected friends." << std::endl; +#endif rsPeers->getOnlineList(peers) ; } - mIdentities->requestKey(pit->first, peers,RsIdentityUsage(serviceType(),RsIdentityUsage::CIRCLE_MEMBERSHIP_CHECK,RsGxsGroupId(cache.mCircleId))); + mIdentities->requestKey(pit->first, peers,RsIdentityUsage(RsServiceType::GXSCIRCLE,RsIdentityUsage::CIRCLE_MEMBERSHIP_CHECK,RsGxsGroupId(cache.mCircleId))); all_ids_here = false; } diff --git a/libretroshare/src/services/p3gxsforums.cc b/libretroshare/src/services/p3gxsforums.cc index 85806d407..409293831 100644 --- a/libretroshare/src/services/p3gxsforums.cc +++ b/libretroshare/src/services/p3gxsforums.cc @@ -4,7 +4,8 @@ * libretroshare: retroshare core library * * * * Copyright (C) 2012-2014 Robert Fernie * - * Copyright (C) 2018-2019 Gioacchino Mazzurco * + * Copyright (C) 2018-2020 Gioacchino Mazzurco * + * Copyright (C) 2019-2020 Asociación Civil Altermundi * * * * This program is free software: you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as * @@ -20,16 +21,20 @@ * along with this program. If not, see . * * * *******************************************************************************/ + +#include +#include + #include "services/p3gxsforums.h" #include "rsitems/rsgxsforumitems.h" #include "retroshare/rspeers.h" #include "retroshare/rsidentity.h" - +#include "util/rsdebug.h" #include "rsserver/p3face.h" #include "retroshare/rsnotify.h" - +#include "util/rsdebuglevel2.h" #include "retroshare/rsgxsflags.h" -#include + // For Dummy Msgs. #include "util/rsrandom.h" @@ -422,46 +427,6 @@ bool p3GxsForums::getMsgData(const uint32_t &token, std::vector & return ok; } -//Not currently used -/*bool p3GxsForums::getRelatedMessages(const uint32_t &token, std::vector &msgs) -{ - GxsMsgRelatedDataMap msgData; - bool ok = RsGenExchange::getMsgRelatedData(token, msgData); - - if(ok) - { - GxsMsgRelatedDataMap::iterator mit = msgData.begin(); - - for(; mit != msgData.end(); ++mit) - { - std::vector& msgItems = mit->second; - std::vector::iterator vit = msgItems.begin(); - - for(; vit != msgItems.end(); ++vit) - { - RsGxsForumMsgItem* item = dynamic_cast(*vit); - - if(item) - { - RsGxsForumMsg msg = item->mMsg; - msg.mMeta = item->meta; - msgs.push_back(msg); - delete item; - } - else - { - std::cerr << "Not a GxsForumMsgItem, deleting!" << std::endl; - delete *vit; - } - } - } - } - - return ok; -}*/ - -/********************************************************************************************/ - bool p3GxsForums::createForumV2( const std::string& name, const std::string& description, const RsGxsId& authorId, const std::set& moderatorsIds, @@ -826,6 +791,51 @@ bool p3GxsForums::importForumLink( return true; } +std::error_condition p3GxsForums::getChildPosts( + const RsGxsGroupId& forumId, const RsGxsMessageId& parentId, + std::vector& childPosts ) +{ + RS_DBG3("forumId: ", forumId, " parentId: ", parentId); + + if(forumId.isNull() || parentId.isNull()) + return std::errc::invalid_argument; + + std::vector msgIds; + msgIds.push_back(RsGxsGrpMsgIdPair(forumId, parentId)); + + RsTokReqOptions opts; + opts.mReqType = GXS_REQUEST_TYPE_MSG_RELATED_DATA; + opts.mOptions = RS_TOKREQOPT_MSG_PARENT | RS_TOKREQOPT_MSG_LATEST; + + uint32_t token; + if( !requestMsgRelatedInfo(token, opts, msgIds) || + waitToken(token) != RsTokenService::COMPLETE ) + return std::errc::timed_out; + + GxsMsgRelatedDataMap msgData; + if(!getMsgRelatedData(token, msgData)) + return std::errc::no_message_available; + + for(auto& mit: msgData) + { + for(auto& vit: mit.second) + { + auto msgItem = dynamic_cast(vit); + if(msgItem) + { + RsGxsForumMsg post = msgItem->mMsg; + post.mMeta = msgItem->meta; + childPosts.push_back(post); + } + else RS_WARN("Got item of unexpected type: ", vit); + + delete vit; + } + } + + return std::error_condition(); +} + bool p3GxsForums::createGroup(uint32_t &token, RsGxsForumGroup &group) { std::cerr << "p3GxsForums::createGroup()" << std::endl; diff --git a/libretroshare/src/services/p3gxsforums.h b/libretroshare/src/services/p3gxsforums.h index 347714acb..39416b46d 100644 --- a/libretroshare/src/services/p3gxsforums.h +++ b/libretroshare/src/services/p3gxsforums.h @@ -4,7 +4,8 @@ * libretroshare: retroshare core library * * * * Copyright (C) 2012-2014 Robert Fernie * - * Copyright (C) 2018-2019 Gioacchino Mazzurco * + * Copyright (C) 2018-2020 Gioacchino Mazzurco * + * Copyright (C) 2019-2020 Asociación Civil Altermundi * * * * This program is free software: you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as * @@ -131,6 +132,11 @@ public: std::string& errMsg = RS_DEFAULT_STORAGE_PARAM(std::string) ) override; + /// @see RsGxsForums + std::error_condition getChildPosts( + const RsGxsGroupId& forumId, const RsGxsMessageId& parentId, + std::vector& childPosts ) override; + /// implementation of rsGxsGorums /// bool getGroupData(const uint32_t &token, std::vector &groups) override; diff --git a/libretroshare/src/services/p3idservice.cc b/libretroshare/src/services/p3idservice.cc index 3ee089a97..609dd8ad6 100644 --- a/libretroshare/src/services/p3idservice.cc +++ b/libretroshare/src/services/p3idservice.cc @@ -55,7 +55,7 @@ #define ID_REQUEST_REPUTATION 0x0003 #define ID_REQUEST_OPINION 0x0004 -#define GXSID_MAX_CACHE_SIZE 5000 +#define GXSID_MAX_CACHE_SIZE 15000 // unused keys are deleted according to some heuristic that should favor known keys, signed keys etc. @@ -616,11 +616,11 @@ void p3IdService::notifyChanges(std::vector &changes) std::cerr << "p3IdService::notifyChanges() Found Group Change Notification"; std::cerr << std::endl; #endif + const RsGxsGroupId& gid(groupChange->mGroupId); #ifdef DEBUG_IDS - std::cerr << "p3IdService::notifyChanges() Auto Subscribe to Incoming Groups: " << *git; + std::cerr << "p3IdService::notifyChanges() Auto Subscribe to Incoming Groups: " << gid; std::cerr << std::endl; #endif - const RsGxsGroupId& gid(groupChange->mGroupId); if(!rsReputations->isIdentityBanned(RsGxsId(gid))) { @@ -641,7 +641,7 @@ void p3IdService::notifyChanges(std::vector &changes) rsEvents->postEvent(ev); // also time_stamp the key that this group represents - timeStampKey(RsGxsId(gid),RsIdentityUsage(serviceType(),RsIdentityUsage::IDENTITY_DATA_UPDATE)) ; + timeStampKey(RsGxsId(gid),RsIdentityUsage(RsServiceType(serviceType()),RsIdentityUsage::IDENTITY_NEW_FROM_GXS_SYNC)) ; should_subscribe = true; } break; @@ -654,8 +654,10 @@ void p3IdService::notifyChanges(std::vector &changes) rsEvents->postEvent(ev); // also time_stamp the key that this group represents - timeStampKey(RsGxsId(gid),RsIdentityUsage(serviceType(),RsIdentityUsage::IDENTITY_DATA_UPDATE)) ; + timeStampKey(RsGxsId(gid),RsIdentityUsage(RsServiceType(serviceType()),RsIdentityUsage::IDENTITY_NEW_FROM_GXS_SYNC)) ; should_subscribe = true; + + std::cerr << "Received new identity " << gid << " and subscribing to it" << std::endl; } break; @@ -1214,8 +1216,7 @@ bool p3IdService::requestIdentity( return false; } - RsIdentityUsage usageInfo( RsServiceType::GXSID, - RsIdentityUsage::IDENTITY_DATA_UPDATE ); + RsIdentityUsage usageInfo( RsServiceType::GXSID, RsIdentityUsage::IDENTITY_NEW_FROM_EXPLICIT_REQUEST ); return requestKey(id, askPeersList, usageInfo); } @@ -1250,8 +1251,9 @@ bool p3IdService::requestKey(const RsGxsId &id, const std::list& peers if( info.mOverallReputationLevel == RsReputationLevel::LOCALLY_NEGATIVE ) { - RsInfo() << __PRETTY_FUNCTION__ << " not requesting Key " << id - << " because it has been banned." << std::endl; +#ifdef DEBUG_IDS + RsInfo() << __PRETTY_FUNCTION__ << " not requesting Key " << id << " because it has been banned." << std::endl; +#endif RS_STACK_MUTEX(mIdMtx); mIdsNotPresent.erase(id); @@ -1360,7 +1362,7 @@ bool p3IdService::signData(const uint8_t *data,uint32_t data_size,const RsGxsId& return false ; } error_status = RS_GIXS_ERROR_NO_ERROR ; - timeStampKey(own_gxs_id,RsIdentityUsage(serviceType(),RsIdentityUsage::IDENTITY_GENERIC_SIGNATURE_CREATION)) ; + timeStampKey(own_gxs_id,RsIdentityUsage(RsServiceType(serviceType()),RsIdentityUsage::IDENTITY_GENERIC_SIGNATURE_CREATION)) ; return true ; } @@ -1433,7 +1435,7 @@ bool p3IdService::encryptData( const uint8_t *decrypted_data, return false ; } error_status = RS_GIXS_ERROR_NO_ERROR ; - timeStampKey(encryption_key_id,RsIdentityUsage(serviceType(),RsIdentityUsage::IDENTITY_GENERIC_ENCRYPTION)) ; + timeStampKey(encryption_key_id,RsIdentityUsage(RsServiceType::GXSID,RsIdentityUsage::IDENTITY_GENERIC_ENCRYPTION)) ; return true ; } @@ -1522,7 +1524,7 @@ bool p3IdService::encryptData( const uint8_t* decrypted_data, { timeStampKey( *it, RsIdentityUsage( - serviceType(), + RsServiceType::GXSID, RsIdentityUsage::IDENTITY_GENERIC_ENCRYPTION ) ); } @@ -1563,7 +1565,7 @@ bool p3IdService::decryptData( const uint8_t *encrypted_data, error_status = RS_GIXS_ERROR_NO_ERROR; timeStampKey( key_id, RsIdentityUsage( - serviceType(), + RsServiceType::GXSID, RsIdentityUsage::IDENTITY_GENERIC_DECRYPTION) ); return true ; @@ -1656,7 +1658,7 @@ bool p3IdService::decryptData( const uint8_t* encrypted_data, { timeStampKey( *it, RsIdentityUsage( - serviceType(), + RsServiceType::GXSID, RsIdentityUsage::IDENTITY_GENERIC_DECRYPTION ) ); } @@ -2292,7 +2294,7 @@ bool SSGxsIdGroup::load(const std::string &input) char scorestr[RSGXSID_MAX_SERVICE_STRING]; // split into parts. - if (3 != sscanf(input.c_str(), "v2 {P:%[^}]} {T:%[^}]} {R:%[^}]}", pgpstr, recognstr, scorestr)) + if (3 != sscanf(input.c_str(), "v2 {P:%[^}]}{T:%[^}]}{R:%[^}]}", pgpstr, recognstr, scorestr)) { #ifdef DEBUG_IDS std::cerr << "SSGxsIdGroup::load() Failed to extract 4 Parts"; @@ -2954,9 +2956,21 @@ void p3IdService::requestIdsFromNet() for(cit = mIdsNotPresent.begin(); cit != mIdsNotPresent.end();) { #ifdef DEBUG_IDS - Dbg2() << __PRETTY_FUNCTION__ << " Processing missing key RsGxsId: " - << cit->first << std::endl; + Dbg2() << __PRETTY_FUNCTION__ << " Processing missing key RsGxsId: " << cit->first << std::endl; #endif + RsGxsIdCache data; + + if(mKeyCache.fetch(cit->first,data)) + { +#ifdef DEBUG_IDS + std::cerr << __PRETTY_FUNCTION__ << ". Dropping request for ID " << cit->first << " at last minute, because it was found in cache"<< std::endl; +#endif + auto tmp(cit); + ++tmp; + mIdsNotPresent.erase(cit); + cit = tmp; + continue; + } const RsGxsId& gxsId = cit->first; const std::list& peers = cit->second; @@ -3011,8 +3025,7 @@ void p3IdService::requestIdsFromNet() { const RsPeerId& peer = cit2->first; std::list grpIds; - for( std::list::const_iterator gxs_id_it = cit2->second.begin(); - gxs_id_it != cit2->second.end(); ++gxs_id_it ) + for( std::list::const_iterator gxs_id_it = cit2->second.begin(); gxs_id_it != cit2->second.end(); ++gxs_id_it ) { #ifdef DEBUG_IDS Dbg2() << __PRETTY_FUNCTION__ << " passing RsGxsId: " << *gxs_id_it @@ -3223,7 +3236,7 @@ bool p3IdService::cachetest_handlerequest(uint32_t token) if (!haveKey(*vit)) { std::list nullpeers; - requestKey(*vit, nullpeers,RsIdentityUsage(serviceType(),RsIdentityUsage::UNKNOWN_USAGE)); + requestKey(*vit, nullpeers,RsIdentityUsage(RsServiceType::GXSID,RsIdentityUsage::UNKNOWN_USAGE)); #ifdef DEBUG_IDS std::cerr << "p3IdService::cachetest_request() Requested Key Id: " << *vit; @@ -4819,11 +4832,10 @@ void RsGxsIdGroup::serial_process( RS_SERIAL_PROCESS(mReputation); } -RsIdentityUsage::RsIdentityUsage( - RsServiceType service, RsIdentityUsage::UsageCode code, - const RsGxsGroupId& gid, const RsGxsMessageId& mid, +RsIdentityUsage::RsIdentityUsage(RsServiceType service, RsIdentityUsage::UsageCode code, + const RsGxsGroupId& gid, const RsGxsMessageId& mid, const RsGxsMessageId &pid, const RsGxsMessageId &tid, uint64_t additional_id, const std::string& comment ) : - mServiceId(service), mUsageCode(code), mGrpId(gid), mMsgId(mid), + mServiceId(service), mUsageCode(code), mGrpId(gid), mMsgId(mid),mParentId(pid),mThreadId(tid), mAdditionalId(additional_id), mComment(comment) { /* This is a hack, since it will hash also mHash, but because it is @@ -4841,42 +4853,6 @@ RsIdentityUsage::RsIdentityUsage( mHash = hs.hash(); } -RsIdentityUsage::RsIdentityUsage( - uint16_t service, const RsIdentityUsage::UsageCode& code, - const RsGxsGroupId& gid, const RsGxsMessageId& mid, - uint64_t additional_id,const std::string& comment ) : - mServiceId(static_cast(service)), mUsageCode(code), - mGrpId(gid), mMsgId(mid), mAdditionalId(additional_id), mComment(comment) -{ -#ifdef DEBUG_IDS - std::cerr << "New identity usage: " << std::endl; - std::cerr << " service=" << std::hex << service << std::endl; - std::cerr << " code =" << std::hex << code << std::endl; - std::cerr << " grpId =" << std::hex << gid << std::endl; - std::cerr << " msgId =" << std::hex << mid << std::endl; - std::cerr << " add id =" << std::hex << additional_id << std::endl; - std::cerr << " commnt =\"" << std::hex << comment << "\"" << std::endl; -#endif - - /* This is a hack, since it will hash also mHash, but because it is - * initialized to 0, and only computed in the constructor here, it should - * be ok. */ - librs::crypto::HashStream hs(librs::crypto::HashStream::SHA1) ; - - hs << (uint32_t)service ; // G10h4ck: Why uint32 if it's 16 bits? - hs << (uint8_t)code ; - hs << gid ; - hs << mid ; - hs << (uint64_t)additional_id ; - hs << comment ; - - mHash = hs.hash(); - -#ifdef DEBUG_IDS - std::cerr << " hash =\"" << std::hex << mHash << "\"" << std::endl; -#endif -} - RsIdentityUsage::RsIdentityUsage() : mServiceId(RsServiceType::NONE), mUsageCode(UNKNOWN_USAGE), mAdditionalId(0) {} diff --git a/libretroshare/src/services/p3wire.cc b/libretroshare/src/services/p3wire.cc index 434a9b9ca..283e9a804 100644 --- a/libretroshare/src/services/p3wire.cc +++ b/libretroshare/src/services/p3wire.cc @@ -30,6 +30,30 @@ RsWire *rsWire = NULL; +RsWireGroup::RsWireGroup() + :mGroupPulses(0),mGroupRepublishes(0),mGroupLikes(0),mGroupReplies(0) + ,mRefMentions(0),mRefRepublishes(0),mRefLikes(0),mRefReplies(0) +{ + return; +} + +uint32_t RsWirePulse::ImageCount() +{ + uint32_t images = 0; + if (!mImage1.empty()) { + images++; + } + if (!mImage2.empty()) { + images++; + } + if (!mImage3.empty()) { + images++; + } + if (!mImage4.empty()) { + images++; + } + return images; +} p3Wire::p3Wire(RsGeneralDataService* gds, RsNetworkExchangeService* nes, RsGixs *gixs) :RsGenExchange(gds, nes, new RsGxsWireSerialiser(), RS_SERVICE_GXS_TYPE_WIRE, gixs, wireAuthenPolicy()), @@ -47,12 +71,12 @@ const uint16_t WIRE_MIN_MINOR_VERSION = 0; RsServiceInfo p3Wire::getServiceInfo() { - return RsServiceInfo(RS_SERVICE_GXS_TYPE_WIRE, - WIRE_APP_NAME, - WIRE_APP_MAJOR_VERSION, - WIRE_APP_MINOR_VERSION, - WIRE_MIN_MAJOR_VERSION, - WIRE_MIN_MINOR_VERSION); + return RsServiceInfo(RS_SERVICE_GXS_TYPE_WIRE, + WIRE_APP_NAME, + WIRE_APP_MAJOR_VERSION, + WIRE_APP_MINOR_VERSION, + WIRE_MIN_MAJOR_VERSION, + WIRE_MIN_MINOR_VERSION); } @@ -91,13 +115,13 @@ RsTokenService* p3Wire::getTokenService() { return RsGenExchange::getTokenService(); } -void p3Wire::notifyChanges(std::vector& changes) +void p3Wire::notifyChanges(std::vector& /*changes*/) { std::cerr << "p3Wire::notifyChanges() New stuff"; std::cerr << std::endl; } - /* Specific Service Data */ + /* Specific Service Data */ bool p3Wire::getGroupData(const uint32_t &token, std::vector &groups) { std::cerr << "p3Wire::getGroupData()"; @@ -137,6 +161,45 @@ bool p3Wire::getGroupData(const uint32_t &token, std::vector &group return ok; } +bool p3Wire::getGroupPtrData(const uint32_t &token, std::map &groups) +{ + std::cerr << "p3Wire::getGroupPtrData()"; + std::cerr << std::endl; + + std::vector grpData; + bool ok = RsGenExchange::getGroupData(token, grpData); + + if(ok) + { + std::vector::iterator vit = grpData.begin(); + + for(; vit != grpData.end(); ++vit) + { + RsGxsWireGroupItem* item = dynamic_cast(*vit); + + if (item) + { + RsWireGroupSPtr pGroup = std::make_shared(item->group); + pGroup->mMeta = item->meta; + delete item; + + groups[pGroup->mMeta.mGroupId] = pGroup; + + std::cerr << "p3Wire::getGroupPtrData() Adding WireGroup to Vector: "; + std::cerr << pGroup->mMeta.mGroupId.toStdString(); + std::cerr << std::endl; + } + else + { + std::cerr << "Not a WireGroupItem, deleting!" << std::endl; + delete *vit; + } + + } + } + return ok; +} + bool p3Wire::getPulseData(const uint32_t &token, std::vector &pulses) { @@ -149,7 +212,6 @@ bool p3Wire::getPulseData(const uint32_t &token, std::vector &pulse for(; mit != msgData.end(); ++mit) { - RsGxsGroupId grpId = mit->first; std::vector& msgItems = mit->second; std::vector::iterator vit = msgItems.begin(); @@ -166,7 +228,7 @@ bool p3Wire::getPulseData(const uint32_t &token, std::vector &pulse } else { - std::cerr << "Not a WikiPulse Item, deleting!" << std::endl; + std::cerr << "Not a WirePulse Item, deleting!" << std::endl; delete *vit; } } @@ -175,6 +237,88 @@ bool p3Wire::getPulseData(const uint32_t &token, std::vector &pulse return ok; } +bool p3Wire::getPulsePtrData(const uint32_t &token, std::list &pulses) +{ + GxsMsgDataMap msgData; + bool ok = RsGenExchange::getMsgData(token, msgData); + + if(ok) + { + GxsMsgDataMap::iterator mit = msgData.begin(); + + for(; mit != msgData.end(); ++mit) + { + std::vector& msgItems = mit->second; + std::vector::iterator vit = msgItems.begin(); + + for(; vit != msgItems.end(); ++vit) + { + RsGxsWirePulseItem* item = dynamic_cast(*vit); + + if(item) + { + RsWirePulseSPtr pPulse = std::make_shared(item->pulse); + pPulse->mMeta = item->meta; + pulses.push_back(pPulse); + delete item; + } + else + { + std::cerr << "Not a WirePulse Item, deleting!" << std::endl; + delete *vit; + } + } + } + } + return ok; +} + +bool p3Wire::getRelatedPulseData(const uint32_t &token, std::vector &pulses) +{ + GxsMsgRelatedDataMap msgData; + std::cerr << "p3Wire::getRelatedPulseData()"; + std::cerr << std::endl; + bool ok = RsGenExchange::getMsgRelatedData(token, msgData); + + if (ok) + { + std::cerr << "p3Wire::getRelatedPulseData() is OK"; + std::cerr << std::endl; + GxsMsgRelatedDataMap::iterator mit = msgData.begin(); + + for(; mit != msgData.end(); ++mit) + { + std::vector& msgItems = mit->second; + std::vector::iterator vit = msgItems.begin(); + + for(; vit != msgItems.end(); ++vit) + { + RsGxsWirePulseItem* item = dynamic_cast(*vit); + + if(item) + { + RsWirePulse pulse = item->pulse; + pulse.mMeta = item->meta; + pulses.push_back(pulse); + delete item; + } + else + { + std::cerr << "Not a WirePulse Item, deleting!" << std::endl; + delete *vit; + } + } + } + } + else + { + std::cerr << "p3Wire::getRelatedPulseData() is NOT OK"; + std::cerr << std::endl; + } + + return ok; +} + bool p3Wire::createGroup(uint32_t &token, RsWireGroup &group) { @@ -215,7 +359,7 @@ bool p3Wire::createGroup(RsWireGroup &group) return createGroup(token, group) && waitToken(token) == RsTokenService::COMPLETE; } -bool p3Wire::updateGroup(const RsWireGroup &group) +bool p3Wire::updateGroup(const RsWireGroup & /*group*/) { // TODO return false; @@ -230,12 +374,16 @@ bool p3Wire::getGroups(const std::list groupIds, std::vector groupIds, std::vector &set_msgIds = ids[grpId]; + set_msgIds.insert(msgId); + + getTokenService()->requestMsgInfo( + token, RS_TOKREQ_ANSTYPE_DATA, opts, ids); + } + + // wait for pulse request to completed. + std::cerr << "p3Wire::fetchPulse() waiting for token"; + std::cerr << std::endl; + + int result = waitToken(token); + if (result != RsTokenService::COMPLETE) + { + std::cerr << "p3Wire::fetchPulse() token FAILED, result: " << result; + std::cerr << std::endl; + return false; + } + + // retrieve Pulse. + std::cerr << "p3Wire::fetchPulse() retrieving token"; + std::cerr << std::endl; + { + bool okay = true; + std::vector pulses; + if (getPulseData(token, pulses)) { + if (pulses.size() == 1) { + // save to output pulse. + pPulse = std::make_shared(pulses[0]); + std::cerr << "p3Wire::fetchPulse() retrieved token: " << *pPulse; + std::cerr << std::endl; + std::cerr << "p3Wire::fetchPulse() ANS GrpId: " << pPulse->mMeta.mGroupId; + std::cerr << " MsgId: " << pPulse->mMeta.mMsgId; + std::cerr << " OrigMsgId: " << pPulse->mMeta.mOrigMsgId; + std::cerr << std::endl; + } else { + std::cerr << "p3Wire::fetchPulse() ERROR multiple pulses"; + std::cerr << std::endl; + okay = false; + } + } else { + std::cerr << "p3Wire::fetchPulse() ERROR failed to retrieve token"; + std::cerr << std::endl; + okay = false; + } + + if (!okay) { + std::cerr << "p3Wire::fetchPulse() tokenPulse ERROR"; + std::cerr << std::endl; + // TODO cancel other request. + return false; + } + } + return true; +} + +// New Interfaces. +bool p3Wire::createOriginalPulse(const RsGxsGroupId &grpId, RsWirePulseSPtr pPulse) +{ + // request Group. + std::list groupIds = { grpId }; + std::vector groups; + bool groupOkay = getGroups(groupIds, groups); + if (!groupOkay) { + std::cerr << "p3Wire::createOriginalPulse() getGroups failed"; + std::cerr << std::endl; + return false; + } + + if (groups.size() != 1) { + std::cerr << "p3Wire::createOriginalPulse() getGroups invalid size"; + std::cerr << std::endl; + return false; + } + + // ensure Group is suitable. + RsWireGroup group = groups[0]; + if ((group.mMeta.mGroupId != grpId) || + (!(group.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_PUBLISH))) + { + std::cerr << "p3Wire::createOriginalPulse() Group unsuitable"; + std::cerr << std::endl; + return false; + } + + // Create Msg. + // Start fresh, just to be sure nothing dodgy happens in UX world. + RsWirePulse pulse; + + pulse.mMeta.mGroupId = group.mMeta.mGroupId; + pulse.mMeta.mAuthorId = group.mMeta.mAuthorId; + pulse.mMeta.mThreadId.clear(); + pulse.mMeta.mParentId.clear(); + pulse.mMeta.mOrigMsgId.clear(); + + // copy info over + pulse.mPulseType = WIRE_PULSE_TYPE_ORIGINAL; + pulse.mSentiment = pPulse->mSentiment; + pulse.mPulseText = pPulse->mPulseText; + pulse.mImage1 = pPulse->mImage1; + pulse.mImage2 = pPulse->mImage2; + pulse.mImage3 = pPulse->mImage3; + pulse.mImage4 = pPulse->mImage4; + + // all mRefs should empty. + + uint32_t token; + createPulse(token, pulse); + + int result = waitToken(token); + if (result != RsTokenService::COMPLETE) + { + std::cerr << "p3Wire::createOriginalPulse() Failed to create Pulse"; + std::cerr << std::endl; + return false; + } + + return true; +} + +bool p3Wire::createReplyPulse(RsGxsGroupId grpId, RsGxsMessageId msgId, RsGxsGroupId replyWith, uint32_t reply_type, RsWirePulseSPtr pPulse) +{ + // check reply_type. can only be ONE. + if (!((reply_type == WIRE_PULSE_TYPE_REPLY) || + (reply_type == WIRE_PULSE_TYPE_REPUBLISH) || + (reply_type == WIRE_PULSE_TYPE_LIKE))) + { + std::cerr << "p3Wire::createReplyPulse() reply_type is invalid"; + std::cerr << std::endl; + return false; + } + + // request both groups. + std::list groupIds = { grpId, replyWith }; + std::vector groups; + bool groupOkay = getGroups(groupIds, groups); + if (!groupOkay) { + std::cerr << "p3Wire::createReplyPulse() getGroups failed"; + std::cerr << std::endl; + return false; + } + + // extract group info. + RsWireGroup replyToGroup; + RsWireGroup replyWithGroup; + + if (grpId == replyWith) + { + if (groups.size() != 1) { + std::cerr << "p3Wire::createReplyPulse() getGroups != 1"; + std::cerr << std::endl; + return false; + } + + replyToGroup = groups[0]; + replyWithGroup = groups[0]; + } + else + { + if (groups.size() != 2) { + std::cerr << "p3Wire::createReplyPulse() getGroups != 2"; + std::cerr << std::endl; + return false; + } + + if (groups[0].mMeta.mGroupId == grpId) { + replyToGroup = groups[0]; + replyWithGroup = groups[1]; + } else { + replyToGroup = groups[1]; + replyWithGroup = groups[0]; + } + } + + // check groupIds match + if ((replyToGroup.mMeta.mGroupId != grpId) || + (replyWithGroup.mMeta.mGroupId != replyWith)) + { + std::cerr << "p3Wire::createReplyPulse() groupid mismatch"; + std::cerr << std::endl; + return false; + } + + // ensure Group is suitable. + if ((!(replyToGroup.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_SUBSCRIBED)) || + (!(replyWithGroup.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_PUBLISH))) + { + std::cerr << "p3Wire::createReplyPulse() Group unsuitable"; + std::cerr << std::endl; + return false; + } + + // ********************************************************** + RsWirePulseSPtr replyToPulse; + if (!fetchPulse(grpId, msgId, replyToPulse)) + { + std::cerr << "p3Wire::createReplyPulse() fetchPulse FAILED"; + std::cerr << std::endl; + return false; + } + + // create Reply Msg. + RsWirePulse responsePulse; + + responsePulse.mMeta.mGroupId = replyWithGroup.mMeta.mGroupId; + responsePulse.mMeta.mAuthorId = replyWithGroup.mMeta.mAuthorId; + responsePulse.mMeta.mThreadId.clear(); + responsePulse.mMeta.mParentId.clear(); + responsePulse.mMeta.mOrigMsgId.clear(); + + responsePulse.mPulseType = WIRE_PULSE_TYPE_RESPONSE | reply_type; + responsePulse.mSentiment = pPulse->mSentiment; + responsePulse.mPulseText = pPulse->mPulseText; + responsePulse.mImage1 = pPulse->mImage1; + responsePulse.mImage2 = pPulse->mImage2; + responsePulse.mImage3 = pPulse->mImage3; + responsePulse.mImage4 = pPulse->mImage4; + + // mRefs refer to parent post. + responsePulse.mRefGroupId = replyToPulse->mMeta.mGroupId; + responsePulse.mRefGroupName = replyToGroup.mMeta.mGroupName; + responsePulse.mRefOrigMsgId = replyToPulse->mMeta.mOrigMsgId; + responsePulse.mRefAuthorId = replyToPulse->mMeta.mAuthorId; + responsePulse.mRefPublishTs = replyToPulse->mMeta.mPublishTs; + responsePulse.mRefPulseText = replyToPulse->mPulseText; + responsePulse.mRefImageCount = replyToPulse->ImageCount(); + + std::cerr << "p3Wire::createReplyPulse() create Response Pulse"; + std::cerr << std::endl; + + uint32_t token; + if (!createPulse(token, responsePulse)) + { + std::cerr << "p3Wire::createReplyPulse() FAILED to create Response Pulse"; + std::cerr << std::endl; + return false; + } + + int result = waitToken(token); + if (result != RsTokenService::COMPLETE) + { + std::cerr << "p3Wire::createReplyPulse() FAILED(2) to create Response Pulse"; + std::cerr << std::endl; + return false; + } + + // get MsgId. + std::pair responsePair; + if (!acknowledgeMsg(token, responsePair)) + { + std::cerr << "p3Wire::createReplyPulse() FAILED acknowledgeMsg for Response Pulse"; + std::cerr << std::endl; + return false; + } + + std::cerr << "p3Wire::createReplyPulse() Response Pulse ID: ("; + std::cerr << responsePair.first.toStdString() << ", "; + std::cerr << responsePair.second.toStdString() << ")"; + std::cerr << std::endl; + + // retrieve newly generated message. + // ********************************************************** + RsWirePulseSPtr createdResponsePulse; + if (!fetchPulse(responsePair.first, responsePair.second, createdResponsePulse)) + { + std::cerr << "p3Wire::createReplyPulse() fetch createdReponsePulse FAILED"; + std::cerr << std::endl; + return false; + } + + /* Check that pulses is created properly */ + if ((createdResponsePulse->mMeta.mGroupId != responsePulse.mMeta.mGroupId) || + (createdResponsePulse->mPulseText != responsePulse.mPulseText) || + (createdResponsePulse->mRefGroupId != responsePulse.mRefGroupId) || + (createdResponsePulse->mRefOrigMsgId != responsePulse.mRefOrigMsgId)) + { + std::cerr << "p3Wire::createReplyPulse() fetch createdReponsePulse FAILED"; + std::cerr << std::endl; + return false; + } + + // create ReplyTo Ref Msg. + std::cerr << "PulseAddDialog::postRefPulse() create Reference!"; + std::cerr << std::endl; + + // Reference Pulse. posted on Parent's Group. + RsWirePulse refPulse; + + refPulse.mMeta.mGroupId = replyToPulse->mMeta.mGroupId; + refPulse.mMeta.mAuthorId = replyWithGroup.mMeta.mAuthorId; // own author Id. + refPulse.mMeta.mThreadId = replyToPulse->mMeta.mOrigMsgId; + refPulse.mMeta.mParentId = replyToPulse->mMeta.mOrigMsgId; + refPulse.mMeta.mOrigMsgId.clear(); + + refPulse.mPulseType = WIRE_PULSE_TYPE_REFERENCE | reply_type; + refPulse.mSentiment = 0; // should this be =? createdResponsePulse->mSentiment; + + // Dont put parent PulseText into refPulse - it is available on Thread Msg. + // otherwise gives impression it is correctly setup Parent / Reply... + // when in fact the parent PublishTS, and AuthorId are wrong. + refPulse.mPulseText = ""; + + // refs refer back to own Post. + refPulse.mRefGroupId = replyWithGroup.mMeta.mGroupId; + refPulse.mRefGroupName = replyWithGroup.mMeta.mGroupName; + refPulse.mRefOrigMsgId = createdResponsePulse->mMeta.mOrigMsgId; + refPulse.mRefAuthorId = replyWithGroup.mMeta.mAuthorId; + refPulse.mRefPublishTs = createdResponsePulse->mMeta.mPublishTs; + refPulse.mRefPulseText = createdResponsePulse->mPulseText; + refPulse.mRefImageCount = createdResponsePulse->ImageCount(); + + // publish Ref Msg. + if (!createPulse(token, refPulse)) + { + std::cerr << "p3Wire::createReplyPulse() FAILED to create Ref Pulse"; + std::cerr << std::endl; + return false; + } + + result = waitToken(token); + if (result != RsTokenService::COMPLETE) + { + std::cerr << "p3Wire::createReplyPulse() FAILED(2) to create Ref Pulse"; + std::cerr << std::endl; + return false; + } + + // get MsgId. + std::pair refPair; + if (!acknowledgeMsg(token, refPair)) + { + std::cerr << "p3Wire::createReplyPulse() FAILED acknowledgeMsg for Ref Pulse"; + std::cerr << std::endl; + return false; + } + + std::cerr << "p3Wire::createReplyPulse() Success: Ref Pulse ID: ("; + std::cerr << refPair.first.toStdString() << ", "; + std::cerr << refPair.second.toStdString() << ")"; + std::cerr << std::endl; + + return true; +} + + + // Blocking, request structures for display. +#if 0 +bool p3Wire::createReplyPulse(uint32_t &token, RsWirePulse &pulse) +{ + + return true; +} + +bool p3Wire::createRepublishPulse(uint32_t &token, RsWirePulse &pulse) +{ + + return true; +} + +bool p3Wire::createLikePulse(uint32_t &token, RsWirePulse &pulse) +{ + + return true; +} +#endif + + // WireGroup Details. +bool p3Wire::getWireGroup(const RsGxsGroupId &groupId, RsWireGroupSPtr &grp) +{ + std::list groupIds = { groupId }; + std::map groups; + if (!fetchGroupPtrs(groupIds, groups)) + { + std::cerr << "p3Wire::getWireGroup() failed to fetchGroupPtrs"; + std::cerr << std::endl; + return false; + } + + if (groups.size() != 1) + { + std::cerr << "p3Wire::getWireGroup() invalid group size"; + std::cerr << std::endl; + return false; + } + + grp = groups.begin()->second; + + // TODO Should fill in Counters of pulses/likes/republishes/replies + return true; +} + +// TODO Remove duplicate ... +bool p3Wire::getWirePulse(const RsGxsGroupId &groupId, const RsGxsMessageId &msgId, RsWirePulseSPtr &pPulse) +{ + return fetchPulse(groupId, msgId, pPulse); +} + + + + +bool compare_time(const RsWirePulseSPtr& first, const RsWirePulseSPtr &second) +{ + return first->mMeta.mPublishTs > second->mMeta.mPublishTs; +} + + // should this filter them in some way? + // date, or count would be more likely. +bool p3Wire::getPulsesForGroups(const std::list &groupIds, std::list &pulsePtrs) +{ + // request all the pulses (Top-Level Thread Msgs). + std::cerr << "p3Wire::getPulsesForGroups()"; + std::cerr << std::endl; + + uint32_t token; + { + RsTokReqOptions opts; + opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA; + opts.mOptions = RS_TOKREQOPT_MSG_LATEST | RS_TOKREQOPT_MSG_THREAD; + + getTokenService()->requestMsgInfo( + token, RS_TOKREQ_ANSTYPE_DATA, opts, groupIds); + } + + // wait for pulse request to completed. + std::cerr << "p3Wire::getPulsesForGroups() waiting for token"; + std::cerr << std::endl; + + int result = waitToken(token); + if (result != RsTokenService::COMPLETE) + { + std::cerr << "p3Wire::getPulsesForGroups() token FAILED, result: " << result; + std::cerr << std::endl; + return false; + } + + // retrieve Pulses. + std::cerr << "p3Wire::getPulsesForGroups() retrieving token"; + std::cerr << std::endl; + if (!getPulsePtrData(token, pulsePtrs)) + { + std::cerr << "p3Wire::getPulsesForGroups() tokenPulse ERROR"; + std::cerr << std::endl; + return false; + } + + std::cerr << "p3Wire::getPulsesForGroups() size = " << pulsePtrs.size(); + std::cerr << std::endl; + { + std::list::iterator it; + for (it = pulsePtrs.begin(); it != pulsePtrs.end(); it++) + { + std::cerr << "p3Wire::getPulsesForGroups() Flags: "; + std::cerr << (*it)->mPulseType << " Msg: " << (*it)->mPulseText; + std::cerr << std::endl; + } + } + + std::cerr << "p3Wire::getPulsesForGroups() size = " << pulsePtrs.size(); + std::cerr << " sorting and trimming"; + std::cerr << std::endl; + + // sort and filter list. + pulsePtrs.sort(compare_time); + + // trim to N max. + uint32_t N = 10; + if (pulsePtrs.size() > N) { + pulsePtrs.resize(N); + } + + // for each fill in details. + std::list::iterator it; + for (it = pulsePtrs.begin(); it != pulsePtrs.end(); it++) + { + if (!updatePulse(*it, 1)) + { + std::cerr << "p3Wire::getPulsesForGroups() Failed to updatePulse"; + std::cerr << std::endl; + return false; + } + } + + // update GroupPtrs for all pulsePtrs. + if (!updateGroups(pulsePtrs)) + { + std::cerr << "p3Wire::getPulsesForGroups() failed to updateGroups"; + std::cerr << std::endl; + return false; + } + + return true; +} + + +bool p3Wire::getPulseFocus(const RsGxsGroupId &groupId, const RsGxsMessageId &msgId, int /* type */, RsWirePulseSPtr &pPulse) +{ + std::cerr << "p3Wire::getPulseFocus("; + std::cerr << "grpId: " << groupId << " msgId: " << msgId; + std::cerr << " )"; + std::cerr << std::endl; + + if (!fetchPulse(groupId, msgId, pPulse)) + { + std::cerr << "p3Wire::getPulseFocus() failed to fetch Pulse"; + std::cerr << std::endl; + return false; + } + + if (!updatePulse(pPulse, 3)) + { + std::cerr << "p3Wire::getPulseFocus() failed to update Pulse"; + std::cerr << std::endl; + return false; + } + + /* Fill in GroupPtrs */ + std::list pulsePtrs; + pulsePtrs.push_back(pPulse); + + if (!updateGroups(pulsePtrs)) + { + std::cerr << "p3Wire::getPulseFocus() failed to updateGroups"; + std::cerr << std::endl; + return false; + } + + return true; +} + + +// function to update a pulse with the (Ref) child with actual data. +bool p3Wire::updatePulse(RsWirePulseSPtr pPulse, int levels) +{ + bool okay = true; + + // setup logging label. + std::ostringstream out; + out << "pulse[" << (void *) pPulse.get() << "], " << levels; + std::string label = out.str(); + + std::cerr << "p3Wire::updatePulse(" << label << ") starting"; + std::cerr << std::endl; + + // is pPulse is a REF, then request the original. + // if no original available the done. + if (pPulse->mPulseType & WIRE_PULSE_TYPE_REFERENCE) + { + RsWirePulseSPtr fullPulse; + std::cerr << "p3Wire::updatePulse(" << label << ") fetching REF ("; + std::cerr << "grpId: " << pPulse->mRefGroupId << " msgId: " << pPulse->mRefOrigMsgId; + std::cerr << " )"; + std::cerr << std::endl; + if (!fetchPulse(pPulse->mRefGroupId, pPulse->mRefOrigMsgId, fullPulse)) + { + std::cerr << "p3Wire::updatePulse(" << label << ") failed to fetch REF"; + std::cerr << std::endl; + return false; + } + std::cerr << "p3Wire::updatePulse(" << label << ") replacing REF"; + std::cerr << std::endl; + + *pPulse = *fullPulse; + } + + // Request children: (Likes / Retweets / Replies) + std::cerr << "p3Wire::updatePulse(" << label << ") requesting children"; + std::cerr << std::endl; + + uint32_t token; + { + RsTokReqOptions opts; + opts.mReqType = GXS_REQUEST_TYPE_MSG_RELATED_DATA; + // OR opts.mOptions = RS_TOKREQOPT_MSG_LATEST | RS_TOKREQOPT_MSG_PARENT; + opts.mOptions = RS_TOKREQOPT_MSG_LATEST | RS_TOKREQOPT_MSG_THREAD; + + std::vector msgIds = { + std::make_pair(pPulse->mMeta.mGroupId, pPulse->mMeta.mOrigMsgId) + }; + + getTokenService()->requestMsgRelatedInfo( + token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds); + } + + // wait for request to complete + std::cerr << "p3Wire::updatePulse(" << label << ") waiting for token"; + std::cerr << std::endl; + + int result = waitToken(token); + if (result != RsTokenService::COMPLETE) + { + std::cerr << "p3Wire::updatePulse(" << label << ") token FAILED, result: " << result; + std::cerr << std::endl; + return false; + } + + /* load children */ + okay = updatePulseChildren(pPulse, token); + if (!okay) + { + std::cerr << "p3Wire::updatePulse(" << label << ") FAILED to update Children"; + std::cerr << std::endl; + return false; + } + + /* if down to last level, no need to updateChildren */ + if (levels <= 1) + { + std::cerr << "p3Wire::updatePulse(" << label << ") Level <= 1 finished"; + std::cerr << std::endl; + return okay; + } + + /* recursively update children */ + std::cerr << "p3Wire::updatePulse(" << label << ") updating children recursively"; + std::cerr << std::endl; + std::list::iterator it; + for (it = pPulse->mReplies.begin(); it != pPulse->mReplies.end(); it++) + { + bool childOkay = updatePulse(*it, levels - 1); + if (!childOkay) { + std::cerr << "p3Wire::updatePulse(" << label << ") update children (reply) failed"; + std::cerr << std::endl; + } + } + + for (it = pPulse->mRepublishes.begin(); it != pPulse->mRepublishes.end(); it++) + { + bool childOkay = updatePulse(*it, levels - 1); + if (!childOkay) { + std::cerr << "p3Wire::updatePulse(" << label << ") update children (repub) failed"; + std::cerr << std::endl; + } + } + + return okay; +} + + +// function to update the (Ref) child with actual data. +bool p3Wire::updatePulseChildren(RsWirePulseSPtr pParent, uint32_t token) +{ + { + bool okay = true; + std::vector pulses; + if (getRelatedPulseData(token, pulses)) { + std::vector::iterator it; + for (it = pulses.begin(); it != pulses.end(); it++) + { + std::cerr << "p3Wire::updatePulseChildren() retrieved child: " << *it; + std::cerr << std::endl; + + RsWirePulseSPtr pPulse = std::make_shared(*it); + // switch on type. + if (it->mPulseType & WIRE_PULSE_TYPE_LIKE) { + pParent->mLikes.push_back(pPulse); + std::cerr << "p3Wire::updatePulseChildren() adding Like"; + std::cerr << std::endl; + } + else if (it->mPulseType & WIRE_PULSE_TYPE_REPUBLISH) { + pParent->mRepublishes.push_back(pPulse); + std::cerr << "p3Wire::updatePulseChildren() adding Republish"; + std::cerr << std::endl; + } + else if (it->mPulseType & WIRE_PULSE_TYPE_REPLY) { + pParent->mReplies.push_back(pPulse); + std::cerr << "p3Wire::updatePulseChildren() adding Reply"; + std::cerr << std::endl; + } + else { + std::cerr << "p3Wire::updatePulseChildren() unknown child type: " << it->mPulseType; + std::cerr << std::endl; + } + } + } else { + std::cerr << "p3Wire::updatePulseChildren() ERROR failed to retrieve token"; + std::cerr << std::endl; + okay = false; + } + + if (!okay) { + std::cerr << "p3Wire::updatePulseChildren() token ERROR"; + std::cerr << std::endl; + } + return okay; + } +} + +/* High-level utility function to update mGroupPtr / mRefGroupPtr links. + * fetches associated groups and reference them from pulses + * + * extractGroupIds (owner + refs). + * fetch all available GroupIDs. (just IDs - so light). + * do intersection of IDs. + * apply IDs. + */ + +bool p3Wire::updateGroups(std::list &pulsePtrs) +{ + std::set pulseGroupIds; + + std::list::iterator it; + for (it = pulsePtrs.begin(); it != pulsePtrs.end(); it++) + { + if (!extractGroupIds(*it, pulseGroupIds)) + { + std::cerr << "p3Wire::updateGroups() failed to extractGroupIds"; + std::cerr << std::endl; + return false; + } + } + + std::list availGroupIds; + if (!trimToAvailGroupIds(pulseGroupIds, availGroupIds)) + { + std::cerr << "p3Wire::updateGroups() failed to trimToAvailGroupIds"; + std::cerr << std::endl; + return false; + } + + std::map groups; + if (!fetchGroupPtrs(availGroupIds, groups)) + { + std::cerr << "p3Wire::updateGroups() failed to fetchGroupPtrs"; + std::cerr << std::endl; + return false; + } + + for (it = pulsePtrs.begin(); it != pulsePtrs.end(); it++) + { + if (!updateGroupPtrs(*it, groups)) + { + std::cerr << "p3Wire::updateGroups() failed to updateGroupPtrs"; + std::cerr << std::endl; + return false; + } + } + return true; +} + + +// this function doesn't depend on p3Wire, could make static. +bool p3Wire::extractGroupIds(RsWirePulseConstSPtr pPulse, std::set &groupIds) +{ + std::cerr << "p3Wire::extractGroupIds()"; + std::cerr << std::endl; + + if (!pPulse) { + std::cerr << "p3Wire::extractGroupIds() INVALID pPulse"; + std::cerr << std::endl; + return false; + } + + // install own groupId. + groupIds.insert(pPulse->mMeta.mGroupId); + + /* do this recursively */ + if (pPulse->mPulseType & WIRE_PULSE_TYPE_REFERENCE) { + // REPLY: mRefGroupId, PARENT was in mMeta.mGroupId. + groupIds.insert(pPulse->mRefGroupId); + /* skipping */ + return true; + } + + + if (pPulse->mPulseType & WIRE_PULSE_TYPE_RESPONSE) { + // REPLY: meta.mGroupId, PARENT: mRefGroupId + groupIds.insert(pPulse->mRefGroupId); + } + + /* iterate through children, recursively */ + std::list::const_iterator it; + for (it = pPulse->mReplies.begin(); it != pPulse->mReplies.end(); it++) + { + bool childOkay = extractGroupIds(*it, groupIds); + if (!childOkay) { + std::cerr << "p3Wire::extractGroupIds() update children (reply) failed"; + std::cerr << std::endl; + return false; + } + } + + for (it = pPulse->mRepublishes.begin(); it != pPulse->mRepublishes.end(); it++) + { + bool childOkay = extractGroupIds(*it, groupIds); + if (!childOkay) { + std::cerr << "p3Wire::extractGroupIds() update children (repub) failed"; + std::cerr << std::endl; + return false; + } + } + + // not bothering with LIKEs at the moment. TODO. + return true; +} + +bool p3Wire::updateGroupPtrs(RsWirePulseSPtr pPulse, const std::map &groups) +{ + std::map::const_iterator git; + git = groups.find(pPulse->mMeta.mGroupId); + if (git == groups.end()) { + // error + return false; + } + + pPulse->mGroupPtr = git->second; + + // if REF, fill in mRefGroupPtr based on mRefGroupId. + if (pPulse->mPulseType & WIRE_PULSE_TYPE_REFERENCE) { + // if RefGroupId is in list, fill in. No error if its not there. + std::map::const_iterator rgit; + rgit = groups.find(pPulse->mRefGroupId); + if (rgit != groups.end()) { + pPulse->mRefGroupPtr = rgit->second; + } + + // no children for REF pulse, so can return now. + return true; + } + + // if Response, fill in mRefGroupPtr based on mRefGroupId. + if (pPulse->mPulseType & WIRE_PULSE_TYPE_RESPONSE) { + // if RefGroupId is in list, fill in. No error if its not there. + std::map::const_iterator rgit; + rgit = groups.find(pPulse->mRefGroupId); + if (rgit != groups.end()) { + pPulse->mRefGroupPtr = rgit->second; + } + // do children as well. + } + + /* recursively apply to children */ + std::list::iterator it; + for (it = pPulse->mReplies.begin(); it != pPulse->mReplies.end(); it++) + { + bool childOkay = updateGroupPtrs(*it, groups); + if (!childOkay) { + std::cerr << "p3Wire::updateGroupPtrs() update children (reply) failed"; + std::cerr << std::endl; + return false; + } + } + + for (it = pPulse->mRepublishes.begin(); it != pPulse->mRepublishes.end(); it++) + { + bool childOkay = updateGroupPtrs(*it, groups); + if (!childOkay) { + std::cerr << "p3Wire::updateGroupPtrs() update children (repub) failed"; + std::cerr << std::endl; + return false; + } + } + + // not bothering with LIKEs at the moment. TODO. + return true; +} + +bool p3Wire::trimToAvailGroupIds(const std::set &pulseGroupIds, + std::list &availGroupIds) +{ + /* request all groupIds */ + std::cerr << "p3Wire::trimToAvailGroupIds()"; + std::cerr << std::endl; + + uint32_t token; + RsTokReqOptions opts; + opts.mReqType = GXS_REQUEST_TYPE_GROUP_IDS; + + if (!requestGroupInfo(token, opts) || waitToken(token) != RsTokenService::COMPLETE ) + { + std::cerr << "p3Wire::trimToAvailGroupIds() failed to fetch groups"; + std::cerr << std::endl; + return false; + } + + std::list localGroupIds; + if (!RsGenExchange::getGroupList(token, localGroupIds)) + { + std::cerr << "p3Wire::trimToAvailGroupIds() failed to get GroupIds"; + std::cerr << std::endl; + return false; + } + + /* do intersection between result ^ pulseGroups -> availGroupIds */ + std::set_intersection(localGroupIds.begin(), localGroupIds.end(), + pulseGroupIds.begin(), pulseGroupIds.end(), + std::back_inserter(availGroupIds)); + + return true; +} + +bool p3Wire::fetchGroupPtrs(const std::list &groupIds, + std::map &groups) +{ + std::cerr << "p3Wire::fetchGroupPtrs()"; + std::cerr << std::endl; + + uint32_t token; + RsTokReqOptions opts; + opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA; + + if (!requestGroupInfo(token, opts, groupIds) || waitToken(token) != RsTokenService::COMPLETE ) + { + std::cerr << "p3Wire::fetchGroupPtrs() failed to fetch groups"; + std::cerr << std::endl; + return false; + } + return getGroupPtrData(token, groups); +} + diff --git a/libretroshare/src/services/p3wire.h b/libretroshare/src/services/p3wire.h index 4ebb0b407..2e7375578 100644 --- a/libretroshare/src/services/p3wire.h +++ b/libretroshare/src/services/p3wire.h @@ -61,7 +61,55 @@ public: virtual bool updateGroup(const RsWireGroup &group) override; virtual bool getGroups(const std::list grpIds, std::vector &groups) override; + // New Interfaces. + // Blocking, request structures for display. + virtual bool createOriginalPulse(const RsGxsGroupId &grpId, RsWirePulseSPtr pPulse) override; + virtual bool createReplyPulse(RsGxsGroupId grpId, RsGxsMessageId msgId, + RsGxsGroupId replyWith, uint32_t reply_type, + RsWirePulseSPtr pPulse) override; + +#if 0 + virtual bool createReplyPulse(uint32_t &token, RsWirePulse &pulse) override; + virtual bool createRepublishPulse(uint32_t &token, RsWirePulse &pulse) override; + virtual bool createLikePulse(uint32_t &token, RsWirePulse &pulse) override; +#endif + + virtual bool getWireGroup(const RsGxsGroupId &groupId, RsWireGroupSPtr &grp) override; + virtual bool getWirePulse(const RsGxsGroupId &groupId, const RsGxsMessageId &msgId, RsWirePulseSPtr &pPulse) override; + + virtual bool getPulsesForGroups(const std::list &groupIds, std::list &pulsePtrs) override; + + virtual bool getPulseFocus(const RsGxsGroupId &groupId, const RsGxsMessageId &msgId, int type, RsWirePulseSPtr &pPulse) override; + private: + // Internal Service Data. + // They should eventually all be here. + bool getRelatedPulseData(const uint32_t &token, std::vector &pulses); + bool getGroupPtrData(const uint32_t &token, + std::map &groups); + bool getPulsePtrData(const uint32_t &token, std::list &pulses); + + // util functions fetching data. + bool fetchPulse(RsGxsGroupId grpId, RsGxsMessageId msgId, RsWirePulseSPtr &pPulse); + bool updatePulse(RsWirePulseSPtr pPulse, int levels); + bool updatePulseChildren(RsWirePulseSPtr pParent, uint32_t token); + + // update GroupPtrs + bool updateGroups(std::list &pulsePtrs); + + // sub utility functions used by updateGroups. + bool extractGroupIds(RsWirePulseConstSPtr pPulse, std::set &groupIds); + + bool updateGroupPtrs(RsWirePulseSPtr pPulse, + const std::map &groups); + + bool trimToAvailGroupIds(const std::set &pulseGroupIds, + std::list &availGroupIds); + + bool fetchGroupPtrs(const std::list &groupIds, + std::map &groups); + + virtual void generateDummyData(); std::string genRandomId(); diff --git a/libretroshare/src/use_libretroshare.pri b/libretroshare/src/use_libretroshare.pri index eb7a4e470..5f291b29c 100644 --- a/libretroshare/src/use_libretroshare.pri +++ b/libretroshare/src/use_libretroshare.pri @@ -46,7 +46,7 @@ rs_jsonapi { LIBS *= -L$$clean_path($${RESTBED_BUILD_PATH}/) -lrestbed } else:sLibs *= restbed - win32-g++:dLibs *= wsock32 + win32-g++|win32-clang-g++:dLibs *= wsock32 } linux-* { @@ -55,7 +55,7 @@ linux-* { rs_deep_channels_index | rs_deep_files_index { mLibs += xapian - win32-g++:mLibs += rpcrt4 + win32-g++|win32-clang-g++:mLibs += rpcrt4 } rs_deep_files_index_ogg { @@ -81,7 +81,7 @@ rs_broadcast_discovery { LIBS *= -L$$clean_path($${UDP_DISCOVERY_BUILD_PATH}) -ludp-discovery } else:sLibs *= udp-discovery - win32-g++:dLibs *= wsock32 + win32-g++|win32-clang-g++:dLibs *= wsock32 } static { diff --git a/libretroshare/src/util/rsendian.h b/libretroshare/src/util/rsendian.h index 925542f0d..d27c374ff 100644 --- a/libretroshare/src/util/rsendian.h +++ b/libretroshare/src/util/rsendian.h @@ -1,6 +1,6 @@ /******************************************************************************* * * - * libretroshare base64 encoding utilities * + * libretroshare endiannes utilities * * * * Copyright (C) 2020 Gioacchino Mazzurco * * Copyright (C) 2020 Asociación Civil Altermundi * @@ -26,7 +26,7 @@ * This file provide convenient integer endiannes conversion utilities. * Instead of providing them with different names for each type (a la C htonl, * htons, ntohl, ntohs ), which make them uncomfortable to use, expose a - * templated function `rs_endian_fix` to reorder integers representation byets + * templated function `rs_endian_fix` to reorder integers bytes representation * when sending or receiving from the network. */ /* enforce LITTLE_ENDIAN on Windows */ @@ -46,7 +46,7 @@ template inline INTTYPE rs_endian_fix(INTTYPE val) swapped |= (val >> (8*(sizeof(INTTYPE)-i-1)) & 0xFF) << (8*i); return swapped; #else - return hostI; + return val; #endif }; diff --git a/openpgpsdk/src/openpgpsdk.pro b/openpgpsdk/src/openpgpsdk.pro index fa117381a..66341d0a3 100644 --- a/openpgpsdk/src/openpgpsdk.pro +++ b/openpgpsdk/src/openpgpsdk.pro @@ -21,7 +21,7 @@ linux-* { OBJECTS_DIR = temp/linux/obj } -win32-g++ { +win32-g++|win32-clang-g++ { HEADERS += openpgpsdk/opsstring.h SOURCES += openpgpsdk/opsstring.c diff --git a/retroshare-gui/src/gui/ChatLobbyWidget.cpp b/retroshare-gui/src/gui/ChatLobbyWidget.cpp index bd802bae4..475495674 100644 --- a/retroshare-gui/src/gui/ChatLobbyWidget.cpp +++ b/retroshare-gui/src/gui/ChatLobbyWidget.cpp @@ -34,6 +34,7 @@ #include "gui/settings/rsharesettings.h" #include "util/HandleRichText.h" #include "util/QtVersion.h" +#include "gui/common/FilesDefs.h" #include "retroshare/rsmsgs.h" #include "retroshare/rspeers.h" @@ -281,7 +282,7 @@ void ChatLobbyWidget::lobbyTreeWidgetCustomPopupMenu(QPoint) QMenu contextMnu(this); if (item && item->type() == TYPE_FOLDER) { - QAction *action = contextMnu.addAction(QIcon(IMAGE_CREATE), tr("Create chat room"), this, SLOT(createChatLobby())); + QAction *action = contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_CREATE), tr("Create chat room"), this, SLOT(createChatLobby())); action->setData(item->data(COLUMN_DATA, ROLE_PRIVACYLEVEL).toInt()); } @@ -291,7 +292,7 @@ void ChatLobbyWidget::lobbyTreeWidgetCustomPopupMenu(QPoint) rsIdentity->getOwnIds(own_identities) ; if (item->data(COLUMN_DATA, ROLE_SUBSCRIBED).toBool()) - contextMnu.addAction(QIcon(IMAGE_UNSUBSCRIBE), tr("Leave this room"), this, SLOT(unsubscribeItem())); + contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_UNSUBSCRIBE), tr("Leave this room"), this, SLOT(unsubscribeItem())); else { QTreeWidgetItem *item = ui.lobbyTreeWidget->currentItem(); @@ -306,18 +307,18 @@ void ChatLobbyWidget::lobbyTreeWidgetCustomPopupMenu(QPoint) if(own_identities.empty()) { if(removed) - contextMnu.addAction(QIcon(IMAGE_SUBSCRIBE), tr("Create a non anonymous identity and enter this room"), this, SLOT(createIdentityAndSubscribe())); + contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_SUBSCRIBE), tr("Create a non anonymous identity and enter this room"), this, SLOT(createIdentityAndSubscribe())); else - contextMnu.addAction(QIcon(IMAGE_SUBSCRIBE), tr("Create an identity and enter this chat room"), this, SLOT(createIdentityAndSubscribe())); + contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_SUBSCRIBE), tr("Create an identity and enter this chat room"), this, SLOT(createIdentityAndSubscribe())); } else if(own_identities.size() == 1) { - QAction *action = contextMnu.addAction(QIcon(IMAGE_SUBSCRIBE), tr("Enter this chat room"), this, SLOT(subscribeChatLobbyAs())); + QAction *action = contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_SUBSCRIBE), tr("Enter this chat room"), this, SLOT(subscribeChatLobbyAs())); action->setData(QString::fromStdString((own_identities.front()).toStdString())) ; } else { - QMenu *mnu = contextMnu.addMenu(QIcon(IMAGE_SUBSCRIBE),tr("Enter this chat room as...")) ; + QMenu *mnu = contextMnu.addMenu(FilesDefs::getIconFromQtResourcePath(IMAGE_SUBSCRIBE),tr("Enter this chat room as...")) ; for(std::list::const_iterator it=own_identities.begin();it!=own_identities.end();++it) { @@ -344,7 +345,7 @@ void ChatLobbyWidget::lobbyTreeWidgetCustomPopupMenu(QPoint) contextMnu.addAction(QIcon(IMAGE_SUBSCRIBE), tr("Add Auto Subscribe"), this, SLOT(autoSubscribeItem())); #endif - contextMnu.addAction(QIcon(IMAGE_COPYRSLINK), tr("Copy RetroShare Link"), this, SLOT(copyItemLink())); + contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_COPYRSLINK), tr("Copy RetroShare Link"), this, SLOT(copyItemLink())); } contextMnu.addSeparator();//------------------------------------------------------------------- @@ -435,7 +436,7 @@ void ChatLobbyWidget::addChatPage(ChatLobbyDialog *d) ChatLobbyInfo linfo ; if(rsMsgs->getChatLobbyInfo(id,linfo)) - _lobby_infos[id].default_icon = (linfo.lobby_flags & RS_CHAT_LOBBY_FLAGS_PUBLIC) ? QIcon(IMAGE_PUBLIC):QIcon(IMAGE_PRIVATE) ; + _lobby_infos[id].default_icon = (linfo.lobby_flags & RS_CHAT_LOBBY_FLAGS_PUBLIC) ? FilesDefs::getIconFromQtResourcePath(IMAGE_PUBLIC):FilesDefs::getIconFromQtResourcePath(IMAGE_PRIVATE) ; else std::cerr << "(EE) cannot find info for room " << std::hex << id << std::dec << std::endl; } @@ -615,7 +616,7 @@ void ChatLobbyWidget::updateDisplay() if (item == NULL) { item = new RSTreeWidgetItem(compareRole, TYPE_LOBBY); - icon = (lobby.lobby_flags & RS_CHAT_LOBBY_FLAGS_PUBLIC) ? QIcon(IMAGE_PUBLIC) : QIcon(IMAGE_PRIVATE); + icon = (lobby.lobby_flags & RS_CHAT_LOBBY_FLAGS_PUBLIC) ? FilesDefs::getIconFromQtResourcePath(IMAGE_PUBLIC) : FilesDefs::getIconFromQtResourcePath(IMAGE_PRIVATE); lobby_item->addChild(item); } @@ -623,7 +624,7 @@ void ChatLobbyWidget::updateDisplay() { if (item->data(COLUMN_DATA, ROLE_SUBSCRIBED).toBool() != subscribed) { // Replace icon - icon = (lobby.lobby_flags & RS_CHAT_LOBBY_FLAGS_PUBLIC) ? QIcon(IMAGE_PUBLIC) : QIcon(IMAGE_PRIVATE); + icon = (lobby.lobby_flags & RS_CHAT_LOBBY_FLAGS_PUBLIC) ? FilesDefs::getIconFromQtResourcePath(IMAGE_PUBLIC) : FilesDefs::getIconFromQtResourcePath(IMAGE_PRIVATE); } } if (!icon.isNull()) { @@ -683,12 +684,12 @@ void ChatLobbyWidget::updateDisplay() if (item == NULL) { item = new RSTreeWidgetItem(compareRole, TYPE_LOBBY); - icon = (lobby.lobby_flags & RS_CHAT_LOBBY_FLAGS_PUBLIC) ? QIcon(IMAGE_PUBLIC) : QIcon(IMAGE_PRIVATE); + icon = (lobby.lobby_flags & RS_CHAT_LOBBY_FLAGS_PUBLIC) ? FilesDefs::getIconFromQtResourcePath(IMAGE_PUBLIC) : FilesDefs::getIconFromQtResourcePath(IMAGE_PRIVATE); itemParent->addChild(item); } else { if (!item->data(COLUMN_DATA, ROLE_SUBSCRIBED).toBool()) { // Replace icon - icon = (lobby.lobby_flags & RS_CHAT_LOBBY_FLAGS_PUBLIC) ? QIcon(IMAGE_PUBLIC) : QIcon(IMAGE_PRIVATE); + icon = (lobby.lobby_flags & RS_CHAT_LOBBY_FLAGS_PUBLIC) ? FilesDefs::getIconFromQtResourcePath(IMAGE_PUBLIC) : FilesDefs::getIconFromQtResourcePath(IMAGE_PRIVATE); } } if (!icon.isNull()) { @@ -996,7 +997,7 @@ void ChatLobbyWidget::updateTypingStatus(ChatLobbyId id) if(item != NULL) { - item->setIcon(COLUMN_NAME,QIcon(IMAGE_TYPING)) ; + item->setIcon(COLUMN_NAME,FilesDefs::getIconFromQtResourcePath(IMAGE_TYPING)) ; _lobby_infos[id].last_typing_event = time(NULL) ; QTimer::singleShot(5000,this,SLOT(resetLobbyTreeIcons())) ; @@ -1008,7 +1009,7 @@ void ChatLobbyWidget::updatePeerLeaving(ChatLobbyId id) if(item != NULL) { - item->setIcon(COLUMN_NAME,QIcon(IMAGE_PEER_LEAVING)) ; + item->setIcon(COLUMN_NAME,FilesDefs::getIconFromQtResourcePath(IMAGE_PEER_LEAVING)) ; _lobby_infos[id].last_typing_event = time(NULL) ; QTimer::singleShot(5000,this,SLOT(resetLobbyTreeIcons())) ; @@ -1020,7 +1021,7 @@ void ChatLobbyWidget::updatePeerEntering(ChatLobbyId id) if(item != NULL) { - item->setIcon(COLUMN_NAME,QIcon(IMAGE_PEER_ENTERING)) ; + item->setIcon(COLUMN_NAME,FilesDefs::getIconFromQtResourcePath(IMAGE_PEER_ENTERING)) ; _lobby_infos[id].last_typing_event = time(NULL) ; QTimer::singleShot(5000,this,SLOT(resetLobbyTreeIcons())) ; @@ -1105,7 +1106,7 @@ void ChatLobbyWidget::updateCurrentLobby() if(_lobby_infos.find(id) != _lobby_infos.end()) { int iPrivacyLevel= item->parent()->data(COLUMN_DATA, ROLE_PRIVACYLEVEL).toInt(); - QIcon icon = (iPrivacyLevel==CHAT_LOBBY_PRIVACY_LEVEL_PUBLIC) ? QIcon(IMAGE_PUBLIC) : QIcon(IMAGE_PRIVATE); + QIcon icon = (iPrivacyLevel==CHAT_LOBBY_PRIVACY_LEVEL_PUBLIC) ? FilesDefs::getIconFromQtResourcePath(IMAGE_PUBLIC) : FilesDefs::getIconFromQtResourcePath(IMAGE_PRIVATE); _lobby_infos[id].default_icon = icon ; item->setIcon(COLUMN_NAME, icon) ; } @@ -1129,7 +1130,7 @@ void ChatLobbyWidget::updateMessageChanged(bool incoming, ChatLobbyId id, QDateT if(bIsCurrentItem) return ; - _lobby_infos[id].default_icon = QIcon(IMAGE_MESSAGE) ; + _lobby_infos[id].default_icon = FilesDefs::getIconFromQtResourcePath(IMAGE_MESSAGE) ; QTreeWidgetItem *item = getTreeWidgetItem(id) ; diff --git a/retroshare-gui/src/gui/ChatLobbyWidget.h b/retroshare-gui/src/gui/ChatLobbyWidget.h index 415c28bc2..a9bb01895 100644 --- a/retroshare-gui/src/gui/ChatLobbyWidget.h +++ b/retroshare-gui/src/gui/ChatLobbyWidget.h @@ -19,9 +19,10 @@ *******************************************************************************/ #pragma once +#include + #include "ui_ChatLobbyWidget.h" -#include "RsAutoUpdatePage.h" #include "chat/ChatLobbyUserNotify.h" #include "gui/gxs/GxsIdChooser.h" diff --git a/retroshare-gui/src/gui/FileTransfer/BannedFilesDialog.h b/retroshare-gui/src/gui/FileTransfer/BannedFilesDialog.h index 28b8e8df1..a65dac238 100644 --- a/retroshare-gui/src/gui/FileTransfer/BannedFilesDialog.h +++ b/retroshare-gui/src/gui/FileTransfer/BannedFilesDialog.h @@ -20,7 +20,7 @@ #pragma once -#include "RsAutoUpdatePage.h" +#include #include "ui_BannedFilesDialog.h" class BannedFilesDialog: public QDialog diff --git a/retroshare-gui/src/gui/FileTransfer/FileTransferInfoWidget.h b/retroshare-gui/src/gui/FileTransfer/FileTransferInfoWidget.h index a82f08dbc..fdf45f2ff 100644 --- a/retroshare-gui/src/gui/FileTransfer/FileTransferInfoWidget.h +++ b/retroshare-gui/src/gui/FileTransfer/FileTransferInfoWidget.h @@ -24,7 +24,8 @@ #include #include #include -#include "RsAutoUpdatePage.h" + +#include #include struct FileChunksInfo ; diff --git a/retroshare-gui/src/gui/FileTransfer/SearchDialog.h b/retroshare-gui/src/gui/FileTransfer/SearchDialog.h index c911b8084..f14bfb642 100644 --- a/retroshare-gui/src/gui/FileTransfer/SearchDialog.h +++ b/retroshare-gui/src/gui/FileTransfer/SearchDialog.h @@ -23,7 +23,7 @@ #include #include "ui_SearchDialog.h" -#include "mainpage.h" +#include class AdvancedSearchDialog; class RSTreeWidgetItemCompareRole; diff --git a/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp b/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp index 68978c8f2..90860ff2c 100644 --- a/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp +++ b/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp @@ -146,45 +146,50 @@ public: } }; +SharedFilesDialog::~SharedFilesDialog() +{ + delete tree_model; + delete flat_model; + delete tree_proxyModel; +} /** Constructor */ -SharedFilesDialog::SharedFilesDialog(RetroshareDirModel *_tree_model,RetroshareDirModel *_flat_model,QWidget *parent) +SharedFilesDialog::SharedFilesDialog(bool remote_mode, QWidget *parent) : RsAutoUpdatePage(1000,parent), model(NULL) { - /* Invoke the Qt Designer generated object setup routine */ - ui.setupUi(this); + /* Invoke the Qt Designer generated object setup routine */ + ui.setupUi(this); - NotifyQt *notify = NotifyQt::getInstance(); - connect(notify, SIGNAL(filesPreModChanged(bool)), this, SLOT(preModDirectories(bool))); - connect(notify, SIGNAL(filesPostModChanged(bool)), this, SLOT(postModDirectories(bool))); + NotifyQt *notify = NotifyQt::getInstance(); + connect(notify, SIGNAL(filesPreModChanged(bool)), this, SLOT(preModDirectories(bool))); + connect(notify, SIGNAL(filesPostModChanged(bool)), this, SLOT(postModDirectories(bool))); - connect(ui.viewType_CB, SIGNAL(currentIndexChanged(int)), this, SLOT(changeCurrentViewModel(int))); + connect(ui.viewType_CB, SIGNAL(currentIndexChanged(int)), this, SLOT(changeCurrentViewModel(int))); + connect(ui.dirTreeView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT( spawnCustomPopupMenu( QPoint ) ) ); + connect(ui.indicatorCBox, SIGNAL(currentIndexChanged(int)), this, SLOT(indicatorChanged(int))); - connect( ui.dirTreeView, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( spawnCustomPopupMenu( QPoint ) ) ); + tree_model = new TreeStyle_RDM(remote_mode); + flat_model = new FlatStyle_RDM(remote_mode); - connect(ui.indicatorCBox, SIGNAL(currentIndexChanged(int)), this, SLOT(indicatorChanged(int))); + connect(flat_model, SIGNAL(layoutChanged()), this, SLOT(updateDirTreeView()) ); - tree_model = _tree_model ; - flat_model = _flat_model ; - connect(flat_model, SIGNAL(layoutChanged()), this, SLOT(updateDirTreeView()) ); + // For filtering items we use a trick: the underlying model will use this FilterRole role to highlight selected items + // while the filterProxyModel will select them using the pre-chosen string "filtered". - // For filtering items we use a trick: the underlying model will use this FilterRole role to highlight selected items - // while the filterProxyModel will select them using the pre-chosen string "filtered". - - tree_proxyModel = new SFDSortFilterProxyModel(tree_model, this); - tree_proxyModel->setSourceModel(tree_model); - tree_proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive); - tree_proxyModel->setSortRole(RetroshareDirModel::SortRole); - tree_proxyModel->sort(COLUMN_NAME); - tree_proxyModel->setFilterRole(RetroshareDirModel::FilterRole); - tree_proxyModel->setFilterRegExp(QRegExp(QString(RETROSHARE_DIR_MODEL_FILTER_STRING))) ; + tree_proxyModel = new SFDSortFilterProxyModel(tree_model, this); + tree_proxyModel->setSourceModel(tree_model); + tree_proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive); + tree_proxyModel->setSortRole(RetroshareDirModel::SortRole); + tree_proxyModel->sort(COLUMN_NAME); + tree_proxyModel->setFilterRole(RetroshareDirModel::FilterRole); + tree_proxyModel->setFilterRegExp(QRegExp(QString(RETROSHARE_DIR_MODEL_FILTER_STRING))) ; flat_proxyModel = new SFDSortFilterProxyModel(flat_model, this); flat_proxyModel->setSourceModel(flat_model); flat_proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive); flat_proxyModel->setSortRole(RetroshareDirModel::SortRole); flat_proxyModel->sort(COLUMN_NAME); - flat_proxyModel->setFilterRole(RetroshareDirModel::FilterRole); - flat_proxyModel->setFilterRegExp(QRegExp(QString(RETROSHARE_DIR_MODEL_FILTER_STRING))) ; + flat_proxyModel->setFilterRole(RetroshareDirModel::FilterRole); + flat_proxyModel->setFilterRegExp(QRegExp(QString(RETROSHARE_DIR_MODEL_FILTER_STRING))) ; // Mr.Alice: I removed this because it causes a crash for some obscur reason. Apparently when the model is changed, the proxy model cannot // deal with the change by itself. Should I call something specific? I've no idea. Removing this does not seem to cause any harm either. @@ -193,31 +198,31 @@ SharedFilesDialog::SharedFilesDialog(RetroshareDirModel *_tree_model,RetroshareD flat_proxyModel->setDynamicSortFilter(false); connect(ui.filterClearButton, SIGNAL(clicked()), this, SLOT(clearFilter())); - connect(ui.filterStartButton, SIGNAL(clicked()), this, SLOT(startFilter())); - connect(ui.filterPatternLineEdit, SIGNAL(returnPressed()), this, SLOT(startFilter())); - connect(ui.filterPatternLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(onFilterTextEdited())); - //Hidden by default, shown on onFilterTextEdited - ui.filterClearButton->hide(); - ui.filterStartButton->hide(); + connect(ui.filterStartButton, SIGNAL(clicked()), this, SLOT(startFilter())); + connect(ui.filterPatternLineEdit, SIGNAL(returnPressed()), this, SLOT(startFilter())); + connect(ui.filterPatternLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(onFilterTextEdited())); + //Hidden by default, shown on onFilterTextEdited + ui.filterClearButton->hide(); + ui.filterStartButton->hide(); // mFilterTimer = new RsProtectedTimer( this ); // mFilterTimer->setSingleShot( true ); // Ensure the timer will fire only once after it was started // connect(mFilterTimer, SIGNAL(timeout()), this, SLOT(filterRegExpChanged())); - /* Set header resize modes and initial section sizes */ - QHeaderView * header = ui.dirTreeView->header () ; + /* Set header resize modes and initial section sizes */ + QHeaderView * header = ui.dirTreeView->header () ; - header->resizeSection ( COLUMN_NAME, 490 ); - header->resizeSection ( COLUMN_FILENB, 70 ); - header->resizeSection ( COLUMN_SIZE, 70 ); - header->resizeSection ( COLUMN_AGE, 100 ); - header->resizeSection ( COLUMN_FRIEND_ACCESS,100); - header->resizeSection ( COLUMN_WN_VISU_DIR, 100 ); + header->resizeSection ( COLUMN_NAME, 490 ); + header->resizeSection ( COLUMN_FILENB, 70 ); + header->resizeSection ( COLUMN_SIZE, 70 ); + header->resizeSection ( COLUMN_AGE, 100 ); + header->resizeSection ( COLUMN_FRIEND_ACCESS,100); + header->resizeSection ( COLUMN_WN_VISU_DIR, 100 ); - header->setStretchLastSection(false); + header->setStretchLastSection(false); - /* Set Multi Selection */ - ui.dirTreeView->setSelectionMode(QAbstractItemView::ExtendedSelection); + /* Set Multi Selection */ + ui.dirTreeView->setSelectionMode(QAbstractItemView::ExtendedSelection); /* Hide platform specific features */ copylinkAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Copy retroshare Links to Clipboard" ), this ); @@ -230,36 +235,36 @@ SharedFilesDialog::SharedFilesDialog(RetroshareDirModel *_tree_model,RetroshareD removeExtraFileAct = new QAction(QIcon(), tr( "Stop sharing this file" ), this ); connect( removeExtraFileAct , SIGNAL( triggered() ), this, SLOT( removeExtraFile() ) ); - collCreateAct= new QAction(QIcon(IMAGE_COLLCREATE), tr("Create Collection..."), this) ; - connect(collCreateAct,SIGNAL(triggered()),this,SLOT(collCreate())) ; - collModifAct= new QAction(QIcon(IMAGE_COLLMODIF), tr("Modify Collection..."), this) ; - connect(collModifAct,SIGNAL(triggered()),this,SLOT(collModif())) ; - collViewAct= new QAction(QIcon(IMAGE_COLLVIEW), tr("View Collection..."), this) ; - connect(collViewAct,SIGNAL(triggered()),this,SLOT(collView())) ; - collOpenAct = new QAction(QIcon(IMAGE_COLLOPEN), tr( "Download from collection file..." ), this ) ; - connect(collOpenAct, SIGNAL(triggered()), this, SLOT(collOpen())) ; + collCreateAct= new QAction(QIcon(IMAGE_COLLCREATE), tr("Create Collection..."), this) ; + connect(collCreateAct,SIGNAL(triggered()),this,SLOT(collCreate())) ; + collModifAct= new QAction(QIcon(IMAGE_COLLMODIF), tr("Modify Collection..."), this) ; + connect(collModifAct,SIGNAL(triggered()),this,SLOT(collModif())) ; + collViewAct= new QAction(QIcon(IMAGE_COLLVIEW), tr("View Collection..."), this) ; + connect(collViewAct,SIGNAL(triggered()),this,SLOT(collView())) ; + collOpenAct = new QAction(QIcon(IMAGE_COLLOPEN), tr( "Download from collection file..." ), this ) ; + connect(collOpenAct, SIGNAL(triggered()), this, SLOT(collOpen())) ; } LocalSharedFilesDialog::LocalSharedFilesDialog(QWidget *parent) - : SharedFilesDialog(new TreeStyle_RDM(false),new FlatStyle_RDM(false),parent) + : SharedFilesDialog(false,parent) { - // Hide columns after loading the settings - ui.dirTreeView->setColumnHidden(COLUMN_WN_VISU_DIR, false) ; - ui.downloadButton->hide() ; + // Hide columns after loading the settings + ui.dirTreeView->setColumnHidden(COLUMN_WN_VISU_DIR, false) ; + ui.downloadButton->hide() ; - // load settings - processSettings(true); - // Setup the current view model. - // - changeCurrentViewModel(ui.viewType_CB->currentIndex()) ; + // load settings + processSettings(true); + // Setup the current view model. + // + changeCurrentViewModel(ui.viewType_CB->currentIndex()) ; - connect(ui.addShares_PB, SIGNAL(clicked()), this, SLOT(addShares())) ; - connect(ui.checkButton, SIGNAL(clicked()), this, SLOT(forceCheck())) ; + connect(ui.addShares_PB, SIGNAL(clicked()), this, SLOT(addShares())) ; + connect(ui.checkButton, SIGNAL(clicked()), this, SLOT(forceCheck())) ; - openfileAct = new QAction(QIcon(IMAGE_OPENFILE), tr("Open File"), this) ; - connect(openfileAct, SIGNAL(triggered()), this, SLOT(openfile())) ; - openfolderAct = new QAction(QIcon(IMAGE_OPENFOLDER), tr("Open Folder"), this) ; - connect(openfolderAct, SIGNAL(triggered()), this, SLOT(openfolder())) ; + openfileAct = new QAction(QIcon(IMAGE_OPENFILE), tr("Open File"), this) ; + connect(openfileAct, SIGNAL(triggered()), this, SLOT(openfile())) ; + openfolderAct = new QAction(QIcon(IMAGE_OPENFOLDER), tr("Open Folder"), this) ; + connect(openfolderAct, SIGNAL(triggered()), this, SLOT(openfolder())) ; ui.titleBarPixmap->setPixmap(QPixmap(IMAGE_MYFILES)) ; @@ -267,46 +272,46 @@ LocalSharedFilesDialog::LocalSharedFilesDialog(QWidget *parent) } RemoteSharedFilesDialog::RemoteSharedFilesDialog(QWidget *parent) - : SharedFilesDialog(new TreeStyle_RDM(true),new FlatStyle_RDM(true),parent) + : SharedFilesDialog(true,parent) { - ui.dirTreeView->setColumnHidden(COLUMN_FRIEND_ACCESS, false) ; - ui.dirTreeView->setColumnHidden(COLUMN_WN_VISU_DIR, true) ; - ui.checkButton->hide() ; + ui.dirTreeView->setColumnHidden(COLUMN_FRIEND_ACCESS, false) ; + ui.dirTreeView->setColumnHidden(COLUMN_WN_VISU_DIR, true) ; + ui.checkButton->hide() ; - connect(ui.downloadButton, SIGNAL(clicked()), this, SLOT(downloadRemoteSelected())); + connect(ui.downloadButton, SIGNAL(clicked()), this, SLOT(downloadRemoteSelected())); connect(ui.dirTreeView, SIGNAL( expanded(const QModelIndex & ) ), this, SLOT( expanded(const QModelIndex & ) ) ); connect(ui.dirTreeView, SIGNAL( doubleClicked(const QModelIndex & ) ), this, SLOT( expanded(const QModelIndex & ) ) ); - // load settings - processSettings(true); - // Setup the current view model. - // - changeCurrentViewModel(ui.viewType_CB->currentIndex()) ; + // load settings + processSettings(true); + // Setup the current view model. + // + changeCurrentViewModel(ui.viewType_CB->currentIndex()) ; - ui.addShares_PB->hide() ; + ui.addShares_PB->hide() ; } void LocalSharedFilesDialog::addShares() { - ShareManager::showYourself(); + ShareManager::showYourself(); } void SharedFilesDialog::hideEvent(QHideEvent *) { - if(model!=NULL) - model->setVisible(false) ; + if(model!=NULL) + model->setVisible(false) ; } void SharedFilesDialog::showEvent(QShowEvent *) { - if(model!=NULL) - { + if(model!=NULL) + { std::set expanded_indexes,hidden_indexes,selected_indexes ; saveExpandedPathsAndSelection(expanded_indexes,hidden_indexes,selected_indexes); - model->setVisible(true) ; - model->update() ; + model->setVisible(true) ; + model->update() ; restoreExpandedPathsAndSelection(expanded_indexes,hidden_indexes,selected_indexes); } @@ -325,63 +330,63 @@ LocalSharedFilesDialog::~LocalSharedFilesDialog() void LocalSharedFilesDialog::processSettings(bool bLoad) { - Settings->beginGroup("LocalSharedFilesDialog"); + Settings->beginGroup("LocalSharedFilesDialog"); - if (bLoad) { - // load settings + if (bLoad) { + // load settings - // state of the trees - ui.dirTreeView->header()->restoreState(Settings->value("LocalDirTreeView").toByteArray()); + // state of the trees + ui.dirTreeView->header()->restoreState(Settings->value("LocalDirTreeView").toByteArray()); - // state of splitter - ui.splitter->restoreState(Settings->value("LocalSplitter").toByteArray()); + // state of splitter + ui.splitter->restoreState(Settings->value("LocalSplitter").toByteArray()); - // view type - ui.viewType_CB->setCurrentIndex(Settings->value("LocalViewType").toInt()); - } else { - // save settings + // view type + ui.viewType_CB->setCurrentIndex(Settings->value("LocalViewType").toInt()); + } else { + // save settings - // state of trees - Settings->setValue("LocalDirTreeView", ui.dirTreeView->header()->saveState()); + // state of trees + Settings->setValue("LocalDirTreeView", ui.dirTreeView->header()->saveState()); - // state of splitter - Settings->setValue("LocalSplitter", ui.splitter->saveState()); + // state of splitter + Settings->setValue("LocalSplitter", ui.splitter->saveState()); - // view type - Settings->setValue("LocalViewType", ui.viewType_CB->currentIndex()); - } + // view type + Settings->setValue("LocalViewType", ui.viewType_CB->currentIndex()); + } - Settings->endGroup(); + Settings->endGroup(); } void RemoteSharedFilesDialog::processSettings(bool bLoad) { - Settings->beginGroup("RemoteSharedFilesDialog"); + Settings->beginGroup("RemoteSharedFilesDialog"); - if (bLoad) { - // load settings + if (bLoad) { + // load settings - // state of the trees - ui.dirTreeView->header()->restoreState(Settings->value("RemoteDirTreeView").toByteArray()); + // state of the trees + ui.dirTreeView->header()->restoreState(Settings->value("RemoteDirTreeView").toByteArray()); - // state of splitter - ui.splitter->restoreState(Settings->value("RemoteSplitter").toByteArray()); + // state of splitter + ui.splitter->restoreState(Settings->value("RemoteSplitter").toByteArray()); - // view type - ui.viewType_CB->setCurrentIndex(Settings->value("RemoteViewType").toInt()); - } else { - // save settings + // view type + ui.viewType_CB->setCurrentIndex(Settings->value("RemoteViewType").toInt()); + } else { + // save settings - // state of trees - Settings->setValue("RemoteDirTreeView", ui.dirTreeView->header()->saveState()); + // state of trees + Settings->setValue("RemoteDirTreeView", ui.dirTreeView->header()->saveState()); - // state of splitter - Settings->setValue("RemoteSplitter", ui.splitter->saveState()); + // state of splitter + Settings->setValue("RemoteSplitter", ui.splitter->saveState()); - // view type - Settings->setValue("RemoteViewType", ui.viewType_CB->currentIndex()); - } + // view type + Settings->setValue("RemoteViewType", ui.viewType_CB->currentIndex()); + } - Settings->endGroup(); + Settings->endGroup(); } void SharedFilesDialog::changeCurrentViewModel(int viewTypeIndex) @@ -389,195 +394,195 @@ void SharedFilesDialog::changeCurrentViewModel(int viewTypeIndex) // disconnect( ui.dirTreeView, SIGNAL( collapsed(const QModelIndex & ) ), NULL, NULL ); // disconnect( ui.dirTreeView, SIGNAL( expanded(const QModelIndex & ) ), NULL, NULL ); - if(model!=NULL) - model->setVisible(false) ; + if(model!=NULL) + model->setVisible(false) ; - if(viewTypeIndex==VIEW_TYPE_TREE) - { - model = tree_model ; + if(viewTypeIndex==VIEW_TYPE_TREE) + { + model = tree_model ; proxyModel = tree_proxyModel ; - } - else - { - model = flat_model ; + } + else + { + model = flat_model ; proxyModel = flat_proxyModel ; } - showProperColumns() ; + showProperColumns() ; std::set expanded_indexes,hidden_indexes,selected_indexes ; saveExpandedPathsAndSelection(expanded_indexes,hidden_indexes,selected_indexes); if(isVisible()) - { + { model->setVisible(true) ; - model->update() ; - } + model->update() ; + } // connect( ui.dirTreeView, SIGNAL( collapsed(const QModelIndex & ) ), this, SLOT( collapsed(const QModelIndex & ) ) ); - ui.dirTreeView->setModel(proxyModel); - ui.dirTreeView->update(); + ui.dirTreeView->setModel(proxyModel); + ui.dirTreeView->update(); restoreExpandedPathsAndSelection(expanded_indexes,hidden_indexes,selected_indexes); QHeaderView * header = ui.dirTreeView->header () ; - QHeaderView_setSectionResizeModeColumn(header, COLUMN_NAME, QHeaderView::Interactive); + QHeaderView_setSectionResizeModeColumn(header, COLUMN_NAME, QHeaderView::Interactive); - ui.dirTreeView->header()->headerDataChanged(Qt::Horizontal, COLUMN_NAME, COLUMN_WN_VISU_DIR) ; + ui.dirTreeView->header()->headerDataChanged(Qt::Horizontal, COLUMN_NAME, COLUMN_WN_VISU_DIR) ; // recursRestoreExpandedItems(ui.dirTreeView->rootIndex(),expanded_indexes); - FilterItems(); + FilterItems(); } void LocalSharedFilesDialog::showProperColumns() { - if(model == tree_model) - { - ui.dirTreeView->setColumnHidden(COLUMN_FILENB, false) ; - ui.dirTreeView->setColumnHidden(COLUMN_FRIEND_ACCESS, false) ; - ui.dirTreeView->setColumnHidden(COLUMN_WN_VISU_DIR, false) ; + if(model == tree_model) + { + ui.dirTreeView->setColumnHidden(COLUMN_FILENB, false) ; + ui.dirTreeView->setColumnHidden(COLUMN_FRIEND_ACCESS, false) ; + ui.dirTreeView->setColumnHidden(COLUMN_WN_VISU_DIR, false) ; #ifdef DONT_USE_SEARCH_IN_TREE_VIEW - ui.filterLabel->hide(); - ui.filterPatternLineEdit->hide(); - ui.filterStartButton->hide(); - ui.filterClearButton->hide(); + ui.filterLabel->hide(); + ui.filterPatternLineEdit->hide(); + ui.filterStartButton->hide(); + ui.filterClearButton->hide(); #endif - } - else - { - ui.dirTreeView->setColumnHidden(COLUMN_FILENB, true) ; - ui.dirTreeView->setColumnHidden(COLUMN_FRIEND_ACCESS, true) ; - ui.dirTreeView->setColumnHidden(COLUMN_WN_VISU_DIR, false) ; + } + else + { + ui.dirTreeView->setColumnHidden(COLUMN_FILENB, true) ; + ui.dirTreeView->setColumnHidden(COLUMN_FRIEND_ACCESS, true) ; + ui.dirTreeView->setColumnHidden(COLUMN_WN_VISU_DIR, false) ; #ifdef DONT_USE_SEARCH_IN_TREE_VIEW - ui.filterLabel->show(); - ui.filterPatternLineEdit->show(); + ui.filterLabel->show(); + ui.filterPatternLineEdit->show(); #endif - } + } } void RemoteSharedFilesDialog::showProperColumns() { - if(model == tree_model) - { - ui.dirTreeView->setColumnHidden(COLUMN_FILENB, false) ; - ui.dirTreeView->setColumnHidden(COLUMN_FRIEND_ACCESS, true) ; - ui.dirTreeView->setColumnHidden(COLUMN_WN_VISU_DIR, true) ; + if(model == tree_model) + { + ui.dirTreeView->setColumnHidden(COLUMN_FILENB, false) ; + ui.dirTreeView->setColumnHidden(COLUMN_FRIEND_ACCESS, true) ; + ui.dirTreeView->setColumnHidden(COLUMN_WN_VISU_DIR, true) ; #ifdef DONT_USE_SEARCH_IN_TREE_VIEW - ui.filterLabel->hide(); - ui.filterPatternLineEdit->hide(); - ui.filterStartButton->hide(); - ui.filterClearButton->hide(); + ui.filterLabel->hide(); + ui.filterPatternLineEdit->hide(); + ui.filterStartButton->hide(); + ui.filterClearButton->hide(); #endif - } - else - { - ui.dirTreeView->setColumnHidden(COLUMN_FILENB, true) ; - ui.dirTreeView->setColumnHidden(COLUMN_FRIEND_ACCESS, false) ; - ui.dirTreeView->setColumnHidden(COLUMN_WN_VISU_DIR, false) ; + } + else + { + ui.dirTreeView->setColumnHidden(COLUMN_FILENB, true) ; + ui.dirTreeView->setColumnHidden(COLUMN_FRIEND_ACCESS, false) ; + ui.dirTreeView->setColumnHidden(COLUMN_WN_VISU_DIR, false) ; #ifdef DONT_USE_SEARCH_IN_TREE_VIEW - ui.filterLabel->show(); - ui.filterPatternLineEdit->show(); + ui.filterLabel->show(); + ui.filterPatternLineEdit->show(); #endif - } + } } void LocalSharedFilesDialog::checkUpdate() { - /* update */ - if (rsFiles->InDirectoryCheck()) - { - ui.checkButton->setText(tr("Checking...")); - } - else - { - ui.checkButton->setText(tr("Check files")); - ui.hashLabel->setPixmap(QPixmap(IMAGE_HASH_DONE)); - ui.hashLabel->setToolTip("") ; - } + /* update */ + if (rsFiles->InDirectoryCheck()) + { + ui.checkButton->setText(tr("Checking...")); + } + else + { + ui.checkButton->setText(tr("Check files")); + ui.hashLabel->setPixmap(QPixmap(IMAGE_HASH_DONE)); + ui.hashLabel->setToolTip("") ; + } - return; + return; } void LocalSharedFilesDialog::forceCheck() { - rsFiles->ForceDirectoryCheck(); - return; + rsFiles->ForceDirectoryCheck(); + return; } void RemoteSharedFilesDialog::spawnCustomPopupMenu( QPoint point ) { - if (!rsPeers) return; /* not ready yet! */ + if (!rsPeers) return; /* not ready yet! */ - QMenu *contextMenu = new QMenu(this); + QMenu *contextMenu = new QMenu(this); - QModelIndex idx = ui.dirTreeView->indexAt(point) ; - if (idx.isValid()) - { + QModelIndex idx = ui.dirTreeView->indexAt(point) ; + if (idx.isValid()) + { - QModelIndex midx = proxyModel->mapToSource(idx) ; - if (midx.isValid()) - { + QModelIndex midx = proxyModel->mapToSource(idx) ; + if (midx.isValid()) + { - currentFile = model->data(midx, RetroshareDirModel::FileNameRole).toString() ; - int type = model->getType(midx) ; - if ( (type == DIR_TYPE_DIR) || (type == DIR_TYPE_FILE) ) - { - collCreateAct->setEnabled(true); - collOpenAct->setEnabled(true); + currentFile = model->data(midx, RetroshareDirModel::FileNameRole).toString() ; + int type = model->getType(midx) ; + if ( (type == DIR_TYPE_DIR) || (type == DIR_TYPE_FILE) ) + { + collCreateAct->setEnabled(true); + collOpenAct->setEnabled(true); - QModelIndexList list = ui.dirTreeView->selectionModel()->selectedRows() ; + QModelIndexList list = ui.dirTreeView->selectionModel()->selectedRows() ; - if(type == DIR_TYPE_DIR || list.size() > 1) - { - QAction *downloadActI = new QAction(QIcon(IMAGE_DOWNLOAD), tr( "Download..." ), contextMenu ) ; - connect( downloadActI , SIGNAL( triggered() ), this, SLOT( downloadRemoteSelectedInteractive() ) ) ; - contextMenu->addAction( downloadActI) ; - } - else - { - QAction *downloadAct = new QAction(QIcon(IMAGE_DOWNLOAD), tr( "Download" ), contextMenu ) ; - connect( downloadAct , SIGNAL( triggered() ), this, SLOT( downloadRemoteSelected() ) ) ; - contextMenu->addAction( downloadAct) ; - } + if(type == DIR_TYPE_DIR || list.size() > 1) + { + QAction *downloadActI = new QAction(QIcon(IMAGE_DOWNLOAD), tr( "Download..." ), contextMenu ) ; + connect( downloadActI , SIGNAL( triggered() ), this, SLOT( downloadRemoteSelectedInteractive() ) ) ; + contextMenu->addAction( downloadActI) ; + } + else + { + QAction *downloadAct = new QAction(QIcon(IMAGE_DOWNLOAD), tr( "Download" ), contextMenu ) ; + connect( downloadAct , SIGNAL( triggered() ), this, SLOT( downloadRemoteSelected() ) ) ; + contextMenu->addAction( downloadAct) ; + } - contextMenu->addSeparator() ;//------------------------------------ - contextMenu->addAction( copylinkAct) ; - contextMenu->addAction( sendlinkAct) ; - contextMenu->addSeparator() ;//------------------------------------ - contextMenu->addAction(QIcon(IMAGE_MSG), tr("Recommend in a message to..."), this, SLOT(recommendFilesToMsg())) ; + contextMenu->addSeparator() ;//------------------------------------ + contextMenu->addAction( copylinkAct) ; + contextMenu->addAction( sendlinkAct) ; + contextMenu->addSeparator() ;//------------------------------------ + contextMenu->addAction(QIcon(IMAGE_MSG), tr("Recommend in a message to..."), this, SLOT(recommendFilesToMsg())) ; - contextMenu->addSeparator() ;//------------------------------------ + contextMenu->addSeparator() ;//------------------------------------ - QMenu collectionMenu(tr("Collection"), this); - collectionMenu.setIcon(QIcon(IMAGE_LIBRARY)); - collectionMenu.addAction(collCreateAct); - collectionMenu.addAction(collOpenAct); - contextMenu->addMenu(&collectionMenu) ; + QMenu collectionMenu(tr("Collection"), this); + collectionMenu.setIcon(QIcon(IMAGE_LIBRARY)); + collectionMenu.addAction(collCreateAct); + collectionMenu.addAction(collOpenAct); + contextMenu->addMenu(&collectionMenu) ; - } + } - } - } + } + } - contextMenu = model->getContextMenu(contextMenu); + contextMenu = model->getContextMenu(contextMenu); - if (!contextMenu->children().isEmpty()) - contextMenu->exec(QCursor::pos()) ; + if (!contextMenu->children().isEmpty()) + contextMenu->exec(QCursor::pos()) ; - delete contextMenu; + delete contextMenu; } QModelIndexList SharedFilesDialog::getSelected() { - QModelIndexList list = ui.dirTreeView->selectionModel()->selectedIndexes() ; - QModelIndexList proxyList ; - for (QModelIndexList::iterator index = list.begin(); index != list.end(); ++index ) { - proxyList.append(proxyModel->mapToSource(*index)) ; - } + QModelIndexList list = ui.dirTreeView->selectionModel()->selectedIndexes() ; + QModelIndexList proxyList ; + for (QModelIndexList::iterator index = list.begin(); index != list.end(); ++index ) { + proxyList.append(proxyModel->mapToSource(*index)) ; + } - return proxyList ; + return proxyList ; } void RemoteSharedFilesDialog::expanded(const QModelIndex& indx) @@ -590,69 +595,69 @@ void RemoteSharedFilesDialog::expanded(const QModelIndex& indx) } void RemoteSharedFilesDialog::downloadRemoteSelectedInteractive() { - /* call back to the model (which does all the interfacing? */ + /* call back to the model (which does all the interfacing? */ - std::cerr << "Downloading Files" ; - std::cerr << std::endl ; + std::cerr << "Downloading Files" ; + std::cerr << std::endl ; - QModelIndexList lst = getSelected() ; - model -> downloadSelected(lst,true) ; + QModelIndexList lst = getSelected() ; + model -> downloadSelected(lst,true) ; } void RemoteSharedFilesDialog::downloadRemoteSelected() { - /* call back to the model (which does all the interfacing? */ + /* call back to the model (which does all the interfacing? */ - std::cerr << "Downloading Files" ; - std::cerr << std::endl ; + std::cerr << "Downloading Files" ; + std::cerr << std::endl ; - QModelIndexList lst = getSelected() ; - model -> downloadSelected(lst,false) ; + QModelIndexList lst = getSelected() ; + model -> downloadSelected(lst,false) ; } void SharedFilesDialog::copyLinks(const QModelIndexList& lst, bool remote,QList& urls,bool& has_unhashed_files) { - std::vector dirVec; + std::vector dirVec; - model->getDirDetailsFromSelect(lst, dirVec); + model->getDirDetailsFromSelect(lst, dirVec); - has_unhashed_files = false; + has_unhashed_files = false; - for (int i = 0, n = dirVec.size(); i < n; ++i) - { - const DirDetails& details = dirVec[i]; + for (int i = 0, n = dirVec.size(); i < n; ++i) + { + const DirDetails& details = dirVec[i]; - if (details.type == DIR_TYPE_DIR) - { - auto ft = RsFileTree::fromDirDetails(details,remote); + if (details.type == DIR_TYPE_DIR) + { + auto ft = RsFileTree::fromDirDetails(details,remote); - QString dir_name = QDir(QString::fromUtf8(details.name.c_str())).dirName(); + QString dir_name = QDir(QString::fromUtf8(details.name.c_str())).dirName(); - RetroShareLink link = RetroShareLink::createFileTree(dir_name,ft->mTotalSize,ft->mTotalFiles,QString::fromStdString(ft->toRadix64())) ; + RetroShareLink link = RetroShareLink::createFileTree(dir_name,ft->mTotalSize,ft->mTotalFiles,QString::fromStdString(ft->toRadix64())) ; - if(link.valid()) - urls.push_back(link) ; - } - else - { - if(details.hash.isNull()) - { - has_unhashed_files = true; - continue; - } - RetroShareLink link = RetroShareLink::createFile(QString::fromUtf8(details.name.c_str()), details.count, details.hash.toStdString().c_str()); - if (link.valid()) { - urls.push_back(link) ; - } - } - } + if(link.valid()) + urls.push_back(link) ; + } + else + { + if(details.hash.isNull()) + { + has_unhashed_files = true; + continue; + } + RetroShareLink link = RetroShareLink::createFile(QString::fromUtf8(details.name.c_str()), details.count, details.hash.toStdString().c_str()); + if (link.valid()) { + urls.push_back(link) ; + } + } + } } void SharedFilesDialog::copyLink (const QModelIndexList& lst, bool remote) { - QList urls ; - bool has_unhashed_files = false; + QList urls ; + bool has_unhashed_files = false; - copyLinks(lst,remote,urls,has_unhashed_files) ; + copyLinks(lst,remote,urls,has_unhashed_files) ; RSLinkClipboard::copyLinks(urls) ; if(has_unhashed_files) @@ -699,108 +704,108 @@ void SharedFilesDialog::sendLinkTo() void SharedFilesDialog::collCreate() { - QModelIndexList lst = getSelected(); - model->createCollectionFile(this, lst); + QModelIndexList lst = getSelected(); + model->createCollectionFile(this, lst); } void SharedFilesDialog::collModif() { - std::list files_info ; + std::list files_info ; - model->getFileInfoFromIndexList(getSelected(),files_info); + model->getFileInfoFromIndexList(getSelected(),files_info); - if(files_info.size() != 1) return ; + if(files_info.size() != 1) return ; - /* make path for downloaded files */ - std::list::iterator it = files_info.begin(); - DirDetails details = (*it); - FileInfo info; - if (!rsFiles->FileDetails(details.hash, RS_FILE_HINTS_EXTRA | RS_FILE_HINTS_LOCAL - | RS_FILE_HINTS_BROWSABLE | RS_FILE_HINTS_NETWORK_WIDE - | RS_FILE_HINTS_SPEC_ONLY, info)) return; + /* make path for downloaded files */ + std::list::iterator it = files_info.begin(); + DirDetails details = (*it); + FileInfo info; + if (!rsFiles->FileDetails(details.hash, RS_FILE_HINTS_EXTRA | RS_FILE_HINTS_LOCAL + | RS_FILE_HINTS_BROWSABLE | RS_FILE_HINTS_NETWORK_WIDE + | RS_FILE_HINTS_SPEC_ONLY, info)) return; - std::string path; - path = info.path; + std::string path; + path = info.path; - /* open file with a suitable application */ - QFileInfo qinfo; - qinfo.setFile(QString::fromUtf8(path.c_str())); - if (qinfo.exists()) { - if (qinfo.absoluteFilePath().endsWith(RsCollection::ExtensionString)) { - RsCollection collection; - collection.openColl(qinfo.absoluteFilePath()); - } - } + /* open file with a suitable application */ + QFileInfo qinfo; + qinfo.setFile(QString::fromUtf8(path.c_str())); + if (qinfo.exists()) { + if (qinfo.absoluteFilePath().endsWith(RsCollection::ExtensionString)) { + RsCollection collection; + collection.openColl(qinfo.absoluteFilePath()); + } + } } void SharedFilesDialog::collView() { - std::list files_info ; + std::list files_info ; - model->getFileInfoFromIndexList(getSelected(),files_info); + model->getFileInfoFromIndexList(getSelected(),files_info); - if(files_info.size() != 1) return ; + if(files_info.size() != 1) return ; - /* make path for downloaded files */ - std::list::iterator it = files_info.begin(); - DirDetails details = (*it); - FileInfo info; - if (!rsFiles->FileDetails(details.hash, RS_FILE_HINTS_EXTRA | RS_FILE_HINTS_LOCAL - | RS_FILE_HINTS_BROWSABLE | RS_FILE_HINTS_NETWORK_WIDE - | RS_FILE_HINTS_SPEC_ONLY, info)) return; + /* make path for downloaded files */ + std::list::iterator it = files_info.begin(); + DirDetails details = (*it); + FileInfo info; + if (!rsFiles->FileDetails(details.hash, RS_FILE_HINTS_EXTRA | RS_FILE_HINTS_LOCAL + | RS_FILE_HINTS_BROWSABLE | RS_FILE_HINTS_NETWORK_WIDE + | RS_FILE_HINTS_SPEC_ONLY, info)) return; - std::string path; - path = info.path; + std::string path; + path = info.path; - /* open file with a suitable application */ - QFileInfo qinfo; - qinfo.setFile(QString::fromUtf8(path.c_str())); - if (qinfo.exists()) { - if (qinfo.absoluteFilePath().endsWith(RsCollection::ExtensionString)) { - RsCollection collection; - collection.openColl(qinfo.absoluteFilePath(), true); - } - } + /* open file with a suitable application */ + QFileInfo qinfo; + qinfo.setFile(QString::fromUtf8(path.c_str())); + if (qinfo.exists()) { + if (qinfo.absoluteFilePath().endsWith(RsCollection::ExtensionString)) { + RsCollection collection; + collection.openColl(qinfo.absoluteFilePath(), true); + } + } } void SharedFilesDialog::collOpen() { - std::list files_info ; + std::list files_info ; - model->getFileInfoFromIndexList(getSelected(),files_info); + model->getFileInfoFromIndexList(getSelected(),files_info); - if(files_info.size() == 1) { + if(files_info.size() == 1) { - /* make path for downloaded files */ - std::list::iterator it = files_info.begin(); - DirDetails details = (*it); - FileInfo info; - if (rsFiles->FileDetails(details.hash, RS_FILE_HINTS_EXTRA | RS_FILE_HINTS_LOCAL - | RS_FILE_HINTS_BROWSABLE | RS_FILE_HINTS_NETWORK_WIDE - | RS_FILE_HINTS_SPEC_ONLY, info)) { + /* make path for downloaded files */ + std::list::iterator it = files_info.begin(); + DirDetails details = (*it); + FileInfo info; + if (rsFiles->FileDetails(details.hash, RS_FILE_HINTS_EXTRA | RS_FILE_HINTS_LOCAL + | RS_FILE_HINTS_BROWSABLE | RS_FILE_HINTS_NETWORK_WIDE + | RS_FILE_HINTS_SPEC_ONLY, info)) { - std::string path; - path = info.path; + std::string path; + path = info.path; - /* open file with a suitable application */ - QFileInfo qinfo; - qinfo.setFile(QString::fromUtf8(path.c_str())); - if (qinfo.exists()) { - if (qinfo.absoluteFilePath().endsWith(RsCollection::ExtensionString)) { - RsCollection collection; - if (collection.load(qinfo.absoluteFilePath())) { - collection.downloadFiles(); - return; - } - } - } - } - } + /* open file with a suitable application */ + QFileInfo qinfo; + qinfo.setFile(QString::fromUtf8(path.c_str())); + if (qinfo.exists()) { + if (qinfo.absoluteFilePath().endsWith(RsCollection::ExtensionString)) { + RsCollection collection; + if (collection.load(qinfo.absoluteFilePath())) { + collection.downloadFiles(); + return; + } + } + } + } + } - RsCollection collection; - if (collection.load(this)) { - collection.downloadFiles(); - } + RsCollection collection; + if (collection.load(this)) { + collection.downloadFiles(); + } } void LocalSharedFilesDialog::playselectedfiles() @@ -817,12 +822,12 @@ void LocalSharedFilesDialog::playselectedfiles() QStringList fullpaths; for(it = paths.begin(); it != paths.end(); ++it) { - std::string fullpath; - rsFiles->ConvertSharedFilePath(*it, fullpath); - fullpaths.push_back(QString::fromStdString(fullpath)); + std::string fullpath; + rsFiles->ConvertSharedFilePath(*it, fullpath); + fullpaths.push_back(QString::fromStdString(fullpath)); - std::cerr << "Playing: " << fullpath; - std::cerr << std::endl; + std::cerr << "Playing: " << fullpath; + std::cerr << std::endl; } playFiles(fullpaths); @@ -857,27 +862,27 @@ void SharedFilesDialog::recommendFilesToMsg() void LocalSharedFilesDialog::openfile() { - /* call back to the model (which does all the interfacing? */ + /* call back to the model (which does all the interfacing? */ - std::cerr << "SharedFilesDialog::openfile" << std::endl; + std::cerr << "SharedFilesDialog::openfile" << std::endl; - QModelIndexList qmil = getSelected(); - model->openSelected(qmil); + QModelIndexList qmil = getSelected(); + model->openSelected(qmil); } void LocalSharedFilesDialog::openfolder() { - std::cerr << "SharedFilesDialog::openfolder" << std::endl; + std::cerr << "SharedFilesDialog::openfolder" << std::endl; - QModelIndexList qmil = getSelected(); - model->openSelected(qmil); + QModelIndexList qmil = getSelected(); + model->openSelected(qmil); } void SharedFilesDialog::preModDirectories(bool local) { - if (isRemote() == local) - return; + if (isRemote() == local) + return; #ifdef DEBUG_SHARED_FILES_DIALOG std::cerr << "About to modify directories. Local=" << local << ". Temporarily disabling sorting" << std::endl; @@ -888,9 +893,9 @@ void SharedFilesDialog::preModDirectories(bool local) std::set expanded_indexes,hidden_indexes,selected_indexes; saveExpandedPathsAndSelection(expanded_indexes,hidden_indexes,selected_indexes) ; - /* Notify both models, only one is visible */ - tree_model->preMods(); - flat_model->preMods(); + /* Notify both models, only one is visible */ + tree_model->preMods(); + flat_model->preMods(); restoreExpandedPathsAndSelection(expanded_indexes,hidden_indexes,selected_indexes) ; } @@ -959,15 +964,15 @@ void SharedFilesDialog::expandAll() void SharedFilesDialog::recursExpandAll(const QModelIndex& index) { - ui.dirTreeView->setExpanded(index,true) ; + ui.dirTreeView->setExpanded(index,true) ; - for(int row=0;rowmodel()->rowCount(index);++row) - { - QModelIndex idx(index.child(row,0)) ; + for(int row=0;rowmodel()->rowCount(index);++row) + { + QModelIndex idx(index.child(row,0)) ; - if(ui.dirTreeView->model()->rowCount(idx) > 0) - recursExpandAll(idx) ; - } + if(ui.dirTreeView->model()->rowCount(idx) > 0) + recursExpandAll(idx) ; + } } void SharedFilesDialog::recursSaveExpandedItems(const QModelIndex& index,const std::string& path, @@ -976,39 +981,39 @@ void SharedFilesDialog::recursSaveExpandedItems(const QModelIndex& index,const s std::set& sel ) { - std::string local_path = path+"/"+index.data(Qt::DisplayRole).toString().toStdString(); + std::string local_path = path+"/"+index.data(Qt::DisplayRole).toString().toStdString(); #ifdef DEBUG_SHARED_FILES_DIALOG - std::cerr << "at index " << index.row() << ". data[1]=" << local_path << std::endl; + std::cerr << "at index " << index.row() << ". data[1]=" << local_path << std::endl; #endif - if(ui.dirTreeView->selectionModel()->selection().contains(index)) - sel.insert(local_path) ; + if(ui.dirTreeView->selectionModel()->selection().contains(index)) + sel.insert(local_path) ; - // Disable hidden check as we don't use it and Qt bug: https://bugreports.qt.io/browse/QTBUG-11438 - /*if(ui.dirTreeView->isRowHidden(index.row(),index.parent())) - { - hid.insert(local_path) ; - return ; - }*/ + // Disable hidden check as we don't use it and Qt bug: https://bugreports.qt.io/browse/QTBUG-11438 + /*if(ui.dirTreeView->isRowHidden(index.row(),index.parent())) + { + hid.insert(local_path) ; + return ; + }*/ - if(ui.dirTreeView->isExpanded(index)) - { + if(ui.dirTreeView->isExpanded(index)) + { #ifdef DEBUG_SHARED_FILES_DIALOG - std::cerr << "Index " << local_path << " is expanded." << std::endl; + std::cerr << "Index " << local_path << " is expanded." << std::endl; #endif - if(index.isValid()) - exp.insert(local_path) ; + if(index.isValid()) + exp.insert(local_path) ; - for(int row=0;rowmodel()->rowCount(index);++row) + for(int row=0;rowmodel()->rowCount(index);++row) #if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0) - recursSaveExpandedItems(ui.dirTreeView->model()->index(row,0,index),local_path,exp,hid,sel) ; + recursSaveExpandedItems(ui.dirTreeView->model()->index(row,0,index),local_path,exp,hid,sel) ; #else - recursSaveExpandedItems(index.child(row,0),local_path,exp,hid,sel) ; + recursSaveExpandedItems(index.child(row,0),local_path,exp,hid,sel) ; #endif - } + } #ifdef DEBUG_SHARED_FILES_DIALOG - else - std::cerr << "Index is not expanded." << std::endl; + else + std::cerr << "Index is not expanded." << std::endl; #endif } @@ -1017,42 +1022,42 @@ void SharedFilesDialog::recursRestoreExpandedItems(const QModelIndex& index, con const std::set& hid, const std::set &sel) { - std::string local_path = path+"/"+index.data(Qt::DisplayRole).toString().toStdString(); + std::string local_path = path+"/"+index.data(Qt::DisplayRole).toString().toStdString(); #ifdef DEBUG_SHARED_FILES_DIALOG - std::cerr << "at index " << index.row() << ". data[1]=" << local_path << std::endl; + std::cerr << "at index " << index.row() << ". data[1]=" << local_path << std::endl; #endif - if(sel.find(local_path) != sel.end()) - ui.dirTreeView->selectionModel()->select(index, QItemSelectionModel::Select | QItemSelectionModel::Rows); + if(sel.find(local_path) != sel.end()) + ui.dirTreeView->selectionModel()->select(index, QItemSelectionModel::Select | QItemSelectionModel::Rows); - // Disable hidden check as we don't use it and Qt bug: https://bugreports.qt.io/browse/QTBUG-11438 - /*bool invisible = hid.find(local_path) != hid.end(); - ui.dirTreeView->setRowHidden(index.row(),index.parent(),invisible ) ;*/ + // Disable hidden check as we don't use it and Qt bug: https://bugreports.qt.io/browse/QTBUG-11438 + /*bool invisible = hid.find(local_path) != hid.end(); + ui.dirTreeView->setRowHidden(index.row(),index.parent(),invisible ) ;*/ - // if(invisible) - // mHiddenIndexes.push_back(proxyModel->mapToSource(index)); + // if(invisible) + // mHiddenIndexes.push_back(proxyModel->mapToSource(index)); - if(/*!invisible &&*/ exp.find(local_path) != exp.end()) - { + if(/*!invisible &&*/ exp.find(local_path) != exp.end()) + { #ifdef DEBUG_SHARED_FILES_DIALOG - std::cerr << "re expanding index " << local_path << std::endl; + std::cerr << "re expanding index " << local_path << std::endl; #endif - ui.dirTreeView->setExpanded(index,true) ; + ui.dirTreeView->setExpanded(index,true) ; - for(int row=0;rowmodel()->rowCount(index);++row) + for(int row=0;rowmodel()->rowCount(index);++row) #if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0) - recursRestoreExpandedItems(ui.dirTreeView->model()->index(row,0,index),local_path,exp,hid,sel) ; + recursRestoreExpandedItems(ui.dirTreeView->model()->index(row,0,index),local_path,exp,hid,sel) ; #else - recursRestoreExpandedItems(index.child(row,0),local_path,exp,hid,sel) ; + recursRestoreExpandedItems(index.child(row,0),local_path,exp,hid,sel) ; #endif - } + } } void SharedFilesDialog::postModDirectories(bool local) { - if (isRemote() == local) - return; + if (isRemote() == local) + return; std::set expanded_indexes,selected_indexes,hidden_indexes; @@ -1062,183 +1067,183 @@ void SharedFilesDialog::postModDirectories(bool local) #endif /* Notify both models, only one is visible */ - tree_model->postMods(); - flat_model->postMods(); - ui.dirTreeView->update() ; + tree_model->postMods(); + flat_model->postMods(); + ui.dirTreeView->update() ; - if (ui.filterPatternLineEdit->text().isEmpty() == false) - FilterItems(); + if (ui.filterPatternLineEdit->text().isEmpty() == false) + FilterItems(); - ui.dirTreeView->setSortingEnabled(true); + ui.dirTreeView->setSortingEnabled(true); - restoreExpandedPathsAndSelection(expanded_indexes,hidden_indexes,selected_indexes) ; + restoreExpandedPathsAndSelection(expanded_indexes,hidden_indexes,selected_indexes) ; #ifdef DEBUG_SHARED_FILES_DIALOG std::cerr << "****** updated directories! Re-enabling sorting ******" << std::endl; #endif - QCoreApplication::flush(); + QCoreApplication::flush(); } class ChannelCompare { public: - bool operator()(const std::pair& id1,const std::pair& id2) const - { - return id1.first < id2.first ; - } + bool operator()(const std::pair& id1,const std::pair& id2) const + { + return id1.first < id2.first ; + } }; void LocalSharedFilesDialog::spawnCustomPopupMenu( QPoint point ) { - if (!rsPeers) return; /* not ready yet! */ + if (!rsPeers) return; /* not ready yet! */ - QModelIndex idx = ui.dirTreeView->indexAt(point) ; - if (!idx.isValid()) return ; + QModelIndex idx = ui.dirTreeView->indexAt(point) ; + if (!idx.isValid()) return ; - QModelIndex midx = proxyModel->mapToSource(idx) ; - if (!midx.isValid()) return ; + QModelIndex midx = proxyModel->mapToSource(idx) ; + if (!midx.isValid()) return ; - currentFile = model->data(midx, RetroshareDirModel::FileNameRole).toString() ; - int type = model->getType(midx) ; - if (type != DIR_TYPE_DIR && type != DIR_TYPE_FILE && type != DIR_TYPE_EXTRA_FILE) return; + currentFile = model->data(midx, RetroshareDirModel::FileNameRole).toString() ; + int type = model->getType(midx) ; + if (type != DIR_TYPE_DIR && type != DIR_TYPE_FILE && type != DIR_TYPE_EXTRA_FILE) return; - QMenu contextMnu(this) ; + QMenu contextMnu(this) ; - bool bIsRsColl = currentFile.endsWith(RsCollection::ExtensionString); - collCreateAct->setEnabled(true); - collModifAct->setEnabled(bIsRsColl); - collViewAct->setEnabled(bIsRsColl); - collOpenAct->setEnabled(true); + bool bIsRsColl = currentFile.endsWith(RsCollection::ExtensionString); + collCreateAct->setEnabled(true); + collModifAct->setEnabled(bIsRsColl); + collViewAct->setEnabled(bIsRsColl); + collOpenAct->setEnabled(true); - QMenu collectionMenu(tr("Collection"), this); - collectionMenu.setIcon(QIcon(IMAGE_LIBRARY)); - collectionMenu.addAction(collCreateAct); - collectionMenu.addAction(collModifAct); - collectionMenu.addAction(collViewAct); - collectionMenu.addAction(collOpenAct); + QMenu collectionMenu(tr("Collection"), this); + collectionMenu.setIcon(QIcon(IMAGE_LIBRARY)); + collectionMenu.addAction(collCreateAct); + collectionMenu.addAction(collModifAct); + collectionMenu.addAction(collViewAct); + collectionMenu.addAction(collOpenAct); - switch (type) { - case DIR_TYPE_DIR : - contextMnu.addAction(openfolderAct) ; - contextMnu.addAction(copylinkAct) ; - contextMnu.addSeparator() ;//------------------------------------ - contextMnu.addMenu(&collectionMenu) ; - break ; + switch (type) { + case DIR_TYPE_DIR : + contextMnu.addAction(openfolderAct) ; + contextMnu.addAction(copylinkAct) ; + contextMnu.addSeparator() ;//------------------------------------ + contextMnu.addMenu(&collectionMenu) ; + break ; - case DIR_TYPE_FILE : - contextMnu.addAction(openfileAct) ; - contextMnu.addSeparator() ;//------------------------------------ - contextMnu.addAction(copylinkAct) ; - contextMnu.addAction(sendlinkAct) ; - contextMnu.addSeparator() ;//------------------------------------ - contextMnu.addMenu(&collectionMenu) ; - contextMnu.addSeparator() ;//------------------------------------ - contextMnu.addAction(QIcon(IMAGE_MSG), tr("Recommend in a message to..."), this, SLOT(recommendFilesToMsg())) ; + case DIR_TYPE_FILE : + contextMnu.addAction(openfileAct) ; + contextMnu.addSeparator() ;//------------------------------------ + contextMnu.addAction(copylinkAct) ; + contextMnu.addAction(sendlinkAct) ; + contextMnu.addSeparator() ;//------------------------------------ + contextMnu.addMenu(&collectionMenu) ; + contextMnu.addSeparator() ;//------------------------------------ + contextMnu.addAction(QIcon(IMAGE_MSG), tr("Recommend in a message to..."), this, SLOT(recommendFilesToMsg())) ; break; case DIR_TYPE_EXTRA_FILE: - contextMnu.addAction(openfileAct) ; - contextMnu.addSeparator() ;//------------------------------------ - contextMnu.addAction(copylinkAct) ; - contextMnu.addAction(sendlinkAct) ; - contextMnu.addAction(removeExtraFileAct) ; + contextMnu.addAction(openfileAct) ; + contextMnu.addSeparator() ;//------------------------------------ + contextMnu.addAction(copylinkAct) ; + contextMnu.addAction(sendlinkAct) ; + contextMnu.addAction(removeExtraFileAct) ; - break ; + break ; - default : - return ; - } + default : + return ; + } - QMenu shareChannelMenu(tr("Share on channel...")) ; // added here because the shareChannelMenu QMenu object is deleted afterwards - QMenu shareForumMenu(tr("Share on forum...")) ; // added here because the shareChannelMenu QMenu object is deleted afterwards + QMenu shareChannelMenu(tr("Share on channel...")) ; // added here because the shareChannelMenu QMenu object is deleted afterwards + QMenu shareForumMenu(tr("Share on forum...")) ; // added here because the shareChannelMenu QMenu object is deleted afterwards if(type != DIR_TYPE_EXTRA_FILE) - { - GxsChannelDialog *channelDialog = dynamic_cast(MainWindow::getPage(MainWindow::Channels)); + { + GxsChannelDialog *channelDialog = dynamic_cast(MainWindow::getPage(MainWindow::Channels)); - if(channelDialog != NULL) - { - shareChannelMenu.setIcon(QIcon(IMAGE_CHANNEL)); + if(channelDialog != NULL) + { + shareChannelMenu.setIcon(QIcon(IMAGE_CHANNEL)); - std::map grp_metas ; - channelDialog->getGroupList(grp_metas) ; + std::map grp_metas ; + channelDialog->getGroupList(grp_metas) ; - std::vector > grplist ; // I dont use a std::map because two or more channels may have the same name. + std::vector > grplist ; // I dont use a std::map because two or more channels may have the same name. - for(auto it(grp_metas.begin());it!=grp_metas.end();++it) - if(IS_GROUP_PUBLISHER((*it).second.mSubscribeFlags) && IS_GROUP_SUBSCRIBED((*it).second.mSubscribeFlags)) - grplist.push_back(std::make_pair((*it).second.mGroupName, (*it).second.mGroupId)); + for(auto it(grp_metas.begin());it!=grp_metas.end();++it) + if(IS_GROUP_PUBLISHER((*it).second.mSubscribeFlags) && IS_GROUP_SUBSCRIBED((*it).second.mSubscribeFlags)) + grplist.push_back(std::make_pair((*it).second.mGroupName, (*it).second.mGroupId)); - std::sort(grplist.begin(),grplist.end(),ChannelCompare()) ; + std::sort(grplist.begin(),grplist.end(),ChannelCompare()) ; - for(auto it(grplist.begin());it!=grplist.end();++it) - shareChannelMenu.addAction(QString::fromUtf8((*it).first.c_str()), this, SLOT(shareOnChannel()))->setData(QString::fromStdString((*it).second.toStdString())) ; + for(auto it(grplist.begin());it!=grplist.end();++it) + shareChannelMenu.addAction(QString::fromUtf8((*it).first.c_str()), this, SLOT(shareOnChannel()))->setData(QString::fromStdString((*it).second.toStdString())) ; - contextMnu.addMenu(&shareChannelMenu) ; - } + contextMnu.addMenu(&shareChannelMenu) ; + } - GxsForumsDialog *forumsDialog = dynamic_cast(MainWindow::getPage(MainWindow::Forums)); + GxsForumsDialog *forumsDialog = dynamic_cast(MainWindow::getPage(MainWindow::Forums)); - if(forumsDialog != NULL) - { - shareForumMenu.setIcon(QIcon(IMAGE_FORUMS)); + if(forumsDialog != NULL) + { + shareForumMenu.setIcon(QIcon(IMAGE_FORUMS)); - std::map grp_metas ; - forumsDialog->getGroupList(grp_metas) ; + std::map grp_metas ; + forumsDialog->getGroupList(grp_metas) ; - std::vector > grplist ; // I dont use a std::map because two or more channels may have the same name. + std::vector > grplist ; // I dont use a std::map because two or more channels may have the same name. - for(auto it(grp_metas.begin());it!=grp_metas.end();++it) - if(IS_GROUP_SUBSCRIBED((*it).second.mSubscribeFlags)) - grplist.push_back(std::make_pair((*it).second.mGroupName, (*it).second.mGroupId)); + for(auto it(grp_metas.begin());it!=grp_metas.end();++it) + if(IS_GROUP_SUBSCRIBED((*it).second.mSubscribeFlags)) + grplist.push_back(std::make_pair((*it).second.mGroupName, (*it).second.mGroupId)); - std::sort(grplist.begin(),grplist.end(),ChannelCompare()) ; + std::sort(grplist.begin(),grplist.end(),ChannelCompare()) ; - for(auto it(grplist.begin());it!=grplist.end();++it) - shareForumMenu.addAction(QString::fromUtf8((*it).first.c_str()), this, SLOT(shareInForum()))->setData(QString::fromStdString((*it).second.toStdString())) ; + for(auto it(grplist.begin());it!=grplist.end();++it) + shareForumMenu.addAction(QString::fromUtf8((*it).first.c_str()), this, SLOT(shareInForum()))->setData(QString::fromStdString((*it).second.toStdString())) ; - contextMnu.addMenu(&shareForumMenu) ; - } - } + contextMnu.addMenu(&shareForumMenu) ; + } + } - contextMnu.exec(QCursor::pos()) ; + contextMnu.exec(QCursor::pos()) ; } void LocalSharedFilesDialog::shareOnChannel() { - RsGxsGroupId groupId(qobject_cast(sender())->data().toString().toStdString()); + RsGxsGroupId groupId(qobject_cast(sender())->data().toString().toStdString()); - GxsChannelDialog *channelDialog = dynamic_cast(MainWindow::getPage(MainWindow::Channels)); + GxsChannelDialog *channelDialog = dynamic_cast(MainWindow::getPage(MainWindow::Channels)); - if(channelDialog == NULL) - return ; + if(channelDialog == NULL) + return ; - std::list files_info ; + std::list files_info ; - QList file_links_list ; - bool has_unhashed_files ; + QList file_links_list ; + bool has_unhashed_files ; - copyLinks(getSelected(),false,file_links_list,has_unhashed_files) ; + copyLinks(getSelected(),false,file_links_list,has_unhashed_files) ; - channelDialog->shareOnChannel(groupId,file_links_list) ; + channelDialog->shareOnChannel(groupId,file_links_list) ; } void LocalSharedFilesDialog::shareInForum() { - RsGxsGroupId groupId(qobject_cast(sender())->data().toString().toStdString()); + RsGxsGroupId groupId(qobject_cast(sender())->data().toString().toStdString()); - GxsForumsDialog *forumsDialog = dynamic_cast(MainWindow::getPage(MainWindow::Forums)); + GxsForumsDialog *forumsDialog = dynamic_cast(MainWindow::getPage(MainWindow::Forums)); - if(forumsDialog == NULL) - return ; + if(forumsDialog == NULL) + return ; - std::list files_info ; + std::list files_info ; - QList file_links_list ; - bool has_unhashed_files ; + QList file_links_list ; + bool has_unhashed_files ; - copyLinks(getSelected(),false,file_links_list,has_unhashed_files) ; + copyLinks(getSelected(),false,file_links_list,has_unhashed_files) ; - forumsDialog->shareInMessage(groupId,file_links_list) ; + forumsDialog->shareInMessage(groupId,file_links_list) ; } //============================================================================ @@ -1304,90 +1309,90 @@ LocalSharedFilesDialog::tryToAddNewAssotiation() void SharedFilesDialog::indicatorChanged(int index) { - static uint32_t correct_indicator[4] = { IND_ALWAYS,IND_LAST_DAY,IND_LAST_WEEK,IND_LAST_MONTH } ; + static uint32_t correct_indicator[4] = { IND_ALWAYS,IND_LAST_DAY,IND_LAST_WEEK,IND_LAST_MONTH } ; - model->changeAgeIndicator(correct_indicator[index]); + model->changeAgeIndicator(correct_indicator[index]); - ui.dirTreeView->update(ui.dirTreeView->rootIndex()); + ui.dirTreeView->update(ui.dirTreeView->rootIndex()); - if (correct_indicator[index] != IND_ALWAYS) - ui.dirTreeView->sortByColumn(COLUMN_AGE, Qt::AscendingOrder); - else - ui.dirTreeView->sortByColumn(COLUMN_NAME, Qt::AscendingOrder); + if (correct_indicator[index] != IND_ALWAYS) + ui.dirTreeView->sortByColumn(COLUMN_AGE, Qt::AscendingOrder); + else + ui.dirTreeView->sortByColumn(COLUMN_NAME, Qt::AscendingOrder); - updateDisplay() ; + updateDisplay() ; } void SharedFilesDialog::onFilterTextEdited() { - QString text = ui.filterPatternLineEdit->text(); + QString text = ui.filterPatternLineEdit->text(); - if (text.isEmpty()) { - ui.filterClearButton->hide(); - } else { - ui.filterClearButton->show(); - } + if (text.isEmpty()) { + ui.filterClearButton->hide(); + } else { + ui.filterClearButton->show(); + } - if (text == lastFilterString) { - ui.filterStartButton->hide(); - } else { - ui.filterStartButton->show(); - } + if (text == lastFilterString) { + ui.filterStartButton->hide(); + } else { + ui.filterStartButton->show(); + } - if(text.length() > 0 && text.length() < 3) - { - ui.filterStartButton->setEnabled(false) ; - ui.filterPatternFrame->setToolTip(tr("Search string should be at least 3 characters long.")) ; - return ; - } + if(text.length() > 0 && text.length() < 3) + { + ui.filterStartButton->setEnabled(false) ; + ui.filterPatternFrame->setToolTip(tr("Search string should be at least 3 characters long.")) ; + return ; + } - ui.filterStartButton->setEnabled(true) ; - ui.filterPatternFrame->setToolTip(QString()); + ui.filterStartButton->setEnabled(true) ; + ui.filterPatternFrame->setToolTip(QString()); - //FilterItems(); + //FilterItems(); #ifndef DISABLE_SEARCH_WHILE_TYPING - mFilterTimer->start( 500 ); // This will fire filterRegExpChanged after 500 ms. - // If the user types something before it fires, the timer restarts counting + mFilterTimer->start( 500 ); // This will fire filterRegExpChanged after 500 ms. + // If the user types something before it fires, the timer restarts counting #endif } #ifdef DEPRECATED_CODE void SharedFilesDialog::filterRegExpChanged() { - QString text = ui.filterPatternLineEdit->text(); + QString text = ui.filterPatternLineEdit->text(); - if(text.length() > 0 && proxyModel == tree_proxyModel) - { - std::list result_list ; - std::list keywords; + if(text.length() > 0 && proxyModel == tree_proxyModel) + { + std::list result_list ; + std::list keywords; - QStringList lst = text.split(" ",QString::SkipEmptyParts) ; + QStringList lst = text.split(" ",QString::SkipEmptyParts) ; - for(auto it(lst.begin());it!=lst.end();++it) - keywords.push_back((*it).toStdString()); + for(auto it(lst.begin());it!=lst.end();++it) + keywords.push_back((*it).toStdString()); - FileSearchFlags flags = isRemote()?RS_FILE_HINTS_REMOTE:RS_FILE_HINTS_LOCAL; + FileSearchFlags flags = isRemote()?RS_FILE_HINTS_REMOTE:RS_FILE_HINTS_LOCAL; - if(keywords.size() > 1) - { - RsRegularExpression::NameExpression exp(RsRegularExpression::ContainsAllStrings,keywords,true); - rsFiles->SearchBoolExp(&exp,result_list, flags) ; - } - else - rsFiles->SearchKeywords(keywords,result_list, flags) ; + if(keywords.size() > 1) + { + RsRegularExpression::NameExpression exp(RsRegularExpression::ContainsAllStrings,keywords,true); + rsFiles->SearchBoolExp(&exp,result_list, flags) ; + } + else + rsFiles->SearchKeywords(keywords,result_list, flags) ; - uint32_t nb_results = result_list.size(); + uint32_t nb_results = result_list.size(); - if(nb_results > MAX_SEARCH_RESULTS) - { - ui.filterStartButton->setEnabled(false) ; - ui.filterPatternFrame->setToolTip(tr("More than 3000 results. Add more/longer search words to select less.")) ; - return ; - } - } + if(nb_results > MAX_SEARCH_RESULTS) + { + ui.filterStartButton->setEnabled(false) ; + ui.filterPatternFrame->setToolTip(tr("More than 3000 results. Add more/longer search words to select less.")) ; + return ; + } + } - ui.filterStartButton->setEnabled(true) ; - ui.filterPatternFrame->setToolTip(QString()); + ui.filterStartButton->setEnabled(true) ; + ui.filterPatternFrame->setToolTip(QString()); } #endif @@ -1403,25 +1408,25 @@ void SharedFilesDialog::clearFilter() /* clear Filter */ void SharedFilesDialog::startFilter() { - ui.filterStartButton->hide(); - lastFilterString = ui.filterPatternLineEdit->text(); + ui.filterStartButton->hide(); + lastFilterString = ui.filterPatternLineEdit->text(); - FilterItems(); + FilterItems(); } void SharedFilesDialog::updateDirTreeView() { - if (model == flat_model) - { - size_t maxSize = 0; - FlatStyle_RDM* flat = dynamic_cast(flat_model); - if (flat && flat->isMaxRefsTableSize(&maxSize)) - { - ui.dirTreeView->setToolTip(tr("Warning: You reach max (%1) files in flat list. No more will be added.").arg(maxSize)); - return; - } - } - ui.dirTreeView->setToolTip(""); + if (model == flat_model) + { + size_t maxSize = 0; + FlatStyle_RDM* flat = dynamic_cast(flat_model); + if (flat && flat->isMaxRefsTableSize(&maxSize)) + { + ui.dirTreeView->setToolTip(tr("Warning: You reach max (%1) files in flat list. No more will be added.").arg(maxSize)); + return; + } + } + ui.dirTreeView->setToolTip(""); } //#define DEBUG_SHARED_FILES_DIALOG @@ -1435,90 +1440,90 @@ void SharedFilesDialog::updateDirTreeView() void recursMakeVisible(QTreeView *tree,const QSortFilterProxyModel *proxyModel,const QModelIndex& indx,uint32_t depth,const std::vector >& pointers,QList& hidden_list) { #ifdef DEBUG_SHARED_FILES_DIALOG - for(uint32_t i=0;isetRowHidden(indx.row(), indx.parent(), false) ; + tree->setRowHidden(indx.row(), indx.parent(), false) ; #ifdef EXPAND_WHILE_SEARCHING - tree->setExpanded(indx,true) ; + tree->setExpanded(indx,true) ; #endif - bool found = false ; + bool found = false ; for (int row = 0; row < rowCount; ++row) - { - QModelIndex child_index = indx.child(row,0); + { + QModelIndex child_index = indx.child(row,0); - if(ptrs.find(proxyModel->mapToSource(child_index).internalPointer()) != ptrs.end()) - { + if(ptrs.find(proxyModel->mapToSource(child_index).internalPointer()) != ptrs.end()) + { #ifdef DEBUG_SHARED_FILES_DIALOG - for(uint32_t i=0;imapToSource(child_index).internalPointer() << " visible" << std::endl; + for(uint32_t i=0;imapToSource(child_index).internalPointer() << " visible" << std::endl; #endif - recursMakeVisible(tree,proxyModel,child_index,depth+1,pointers,hidden_list) ; - found = true ; - } - else - { - tree->setRowHidden(child_index.row(), indx, true) ; - hidden_list.push_back(proxyModel->mapToSource(child_index)) ; + recursMakeVisible(tree,proxyModel,child_index,depth+1,pointers,hidden_list) ; + found = true ; + } + else + { + tree->setRowHidden(child_index.row(), indx, true) ; + hidden_list.push_back(proxyModel->mapToSource(child_index)) ; #ifdef EXPAND_WHILE_SEARCHING - tree->setExpanded(child_index,false) ; + tree->setExpanded(child_index,false) ; #endif #ifdef DEBUG_SHARED_FILES_DIALOG - for(uint32_t i=0;imapToSource(child_index).internalPointer() << " hidden" << std::endl; + for(uint32_t i=0;imapToSource(child_index).internalPointer() << " hidden" << std::endl; #endif - } - } + } + } - if(!found && depth == 0) - { - tree->setRowHidden(indx.row(), indx.parent(), true) ; - hidden_list.push_back(proxyModel->mapToSource(indx)) ; - } + if(!found && depth == 0) + { + tree->setRowHidden(indx.row(), indx.parent(), true) ; + hidden_list.push_back(proxyModel->mapToSource(indx)) ; + } } void SharedFilesDialog::restoreInvisibleItems() { - std::cerr << "Restoring " << mHiddenIndexes.size() << " invisible indexes" << std::endl; + std::cerr << "Restoring " << mHiddenIndexes.size() << " invisible indexes" << std::endl; - for(QList::const_iterator it(mHiddenIndexes.begin());it!=mHiddenIndexes.end();++it) - { - QModelIndex indx = proxyModel->mapFromSource(*it); + for(QList::const_iterator it(mHiddenIndexes.begin());it!=mHiddenIndexes.end();++it) + { + QModelIndex indx = proxyModel->mapFromSource(*it); - if(indx.isValid()) - ui.dirTreeView->setRowHidden(indx.row(), indx.parent(), false) ; - } + if(indx.isValid()) + ui.dirTreeView->setRowHidden(indx.row(), indx.parent(), false) ; + } - mHiddenIndexes.clear(); + mHiddenIndexes.clear(); } #endif class QCursorContextBlocker { - public: - QCursorContextBlocker(QWidget *w) - : mW(w) - { - mW->setCursor(Qt::WaitCursor); - mW->blockSignals(true) ; - } + public: + QCursorContextBlocker(QWidget *w) + : mW(w) + { + mW->setCursor(Qt::WaitCursor); + mW->blockSignals(true) ; + } - ~QCursorContextBlocker() - { - mW->setCursor(Qt::ArrowCursor); - mW->blockSignals(false) ; - } + ~QCursorContextBlocker() + { + mW->setCursor(Qt::ArrowCursor); + mW->blockSignals(false) ; + } - private: - QWidget *mW ; + private: + QWidget *mW ; }; void SharedFilesDialog::FilterItems() @@ -1528,68 +1533,68 @@ void SharedFilesDialog::FilterItems() return; #endif - QString text = ui.filterPatternLineEdit->text(); + QString text = ui.filterPatternLineEdit->text(); - if(mLastFilterText == text) // do not filter again if we already did. This is an optimization - { + if(mLastFilterText == text) // do not filter again if we already did. This is an optimization + { #ifdef DEBUG_SHARED_FILES_DIALOG - std::cerr << "Last text is equal to text. skipping" << std::endl; + std::cerr << "Last text is equal to text. skipping" << std::endl; #endif - return ; - } + return ; + } #ifdef DEBUG_SHARED_FILES_DIALOG - std::cerr << "New last text. Performing the filter on string \"" << text.toStdString() << "\"" << std::endl; + std::cerr << "New last text. Performing the filter on string \"" << text.toStdString() << "\"" << std::endl; #endif - mLastFilterText = text ; + mLastFilterText = text ; - QCursorContextBlocker q(ui.dirTreeView) ; + QCursorContextBlocker q(ui.dirTreeView) ; - QCoreApplication::processEvents() ; + QCoreApplication::processEvents() ; - std::list result_list ; - uint32_t found = 0 ; + std::list result_list ; + uint32_t found = 0 ; - if(text == "") - { - model->filterItems(std::list(),found) ; - model->update() ; - return ; - } + if(text == "") + { + model->filterItems(std::list(),found) ; + model->update() ; + return ; + } - if(text.length() < 3) - return ; + if(text.length() < 3) + return ; - //FileSearchFlags flags = isRemote()?RS_FILE_HINTS_REMOTE:RS_FILE_HINTS_LOCAL; - QStringList lst = text.split(" ",QString::SkipEmptyParts) ; - std::list keywords ; + //FileSearchFlags flags = isRemote()?RS_FILE_HINTS_REMOTE:RS_FILE_HINTS_LOCAL; + QStringList lst = text.split(" ",QString::SkipEmptyParts) ; + std::list keywords ; - for(auto it(lst.begin());it!=lst.end();++it) - keywords.push_back((*it).toStdString()); + for(auto it(lst.begin());it!=lst.end();++it) + keywords.push_back((*it).toStdString()); - model->filterItems(keywords,found) ; - model->update() ; + model->filterItems(keywords,found) ; + model->update() ; - if(found > 0) - expandAll(); + if(found > 0) + expandAll(); - if(found == 0) - ui.filterPatternFrame->setToolTip(tr("No result.")) ; - else if(found > MAX_SEARCH_RESULTS) - ui.filterPatternFrame->setToolTip(tr("More than %1 results. Add more/longer search words to select less.").arg(MAX_SEARCH_RESULTS)) ; - else - ui.filterPatternFrame->setToolTip(tr("Found %1 results.").arg(found)) ; + if(found == 0) + ui.filterPatternFrame->setToolTip(tr("No result.")) ; + else if(found > MAX_SEARCH_RESULTS) + ui.filterPatternFrame->setToolTip(tr("More than %1 results. Add more/longer search words to select less.").arg(MAX_SEARCH_RESULTS)) ; + else + ui.filterPatternFrame->setToolTip(tr("Found %1 results.").arg(found)) ; #ifdef DEBUG_SHARED_FILES_DIALOG - std::cerr << found << " results found by search." << std::endl; + std::cerr << found << " results found by search." << std::endl; #endif } void SharedFilesDialog::removeExtraFile() { - std::list files_info ; + std::list files_info ; - model->getFileInfoFromIndexList(getSelected(),files_info); + model->getFileInfoFromIndexList(getSelected(),files_info); for(auto it(files_info.begin());it!=files_info.end();++it) { @@ -1602,17 +1607,17 @@ void SharedFilesDialog::removeExtraFile() #ifdef DEPRECATED_CODE bool SharedFilesDialog::flat_FilterItem(const QModelIndex &index, const QString &text, int /*level*/) { - if(index.data(RetroshareDirModel::FileNameRole).toString().contains(text, Qt::CaseInsensitive)) - { - ui.dirTreeView->setRowHidden(index.row(), index.parent(), false); - return false ; - } - else - { - ui.dirTreeView->setRowHidden(index.row(), index.parent(), true); - mHiddenIndexes.push_back(proxyModel->mapToSource(index)); - return true ; - } + if(index.data(RetroshareDirModel::FileNameRole).toString().contains(text, Qt::CaseInsensitive)) + { + ui.dirTreeView->setRowHidden(index.row(), index.parent(), false); + return false ; + } + else + { + ui.dirTreeView->setRowHidden(index.row(), index.parent(), true); + mHiddenIndexes.push_back(proxyModel->mapToSource(index)); + return true ; + } } bool SharedFilesDialog::tree_FilterItem(const QModelIndex &index, const QString &text, int level) @@ -1641,10 +1646,10 @@ bool SharedFilesDialog::tree_FilterItem(const QModelIndex &index, const QString if (visible || visibleChildCount) { ui.dirTreeView->setRowHidden(index.row(), index.parent(), false); } else { - { + { ui.dirTreeView->setRowHidden(index.row(), index.parent(), true); - mHiddenIndexes.push_back(proxyModel->mapToSource(index)); - } + mHiddenIndexes.push_back(proxyModel->mapToSource(index)); + } } return (visible || visibleChildCount); diff --git a/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.h b/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.h index 5206e1d06..c406821c9 100644 --- a/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.h +++ b/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.h @@ -23,7 +23,7 @@ #include "ui_SharedFilesDialog.h" -#include "RsAutoUpdatePage.h" +#include #include "gui/RetroShareLink.h" #include "util/RsProtectedTimer.h" @@ -38,10 +38,10 @@ class SharedFilesDialog : public RsAutoUpdatePage public: /** Default Constructor */ - SharedFilesDialog(RetroshareDirModel *tree_model,RetroshareDirModel *flat_model,QWidget *parent = 0); + SharedFilesDialog(bool remote_mode,QWidget *parent = 0); /** Default Destructor */ - ~SharedFilesDialog() {} + ~SharedFilesDialog() ; virtual void hideEvent(QHideEvent *) ; virtual void showEvent(QShowEvent *) ; diff --git a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.h b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.h index 9c03e830c..e11f6c232 100644 --- a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.h +++ b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.h @@ -25,7 +25,7 @@ #include #include -#include "RsAutoUpdatePage.h" +#include #include "ui_TransfersDialog.h" diff --git a/retroshare-gui/src/gui/GetStartedDialog.h b/retroshare-gui/src/gui/GetStartedDialog.h index 8705d0290..6d943958a 100644 --- a/retroshare-gui/src/gui/GetStartedDialog.h +++ b/retroshare-gui/src/gui/GetStartedDialog.h @@ -21,9 +21,9 @@ #ifndef _GETTING_STARTED_DIALOG_H #define _GETTING_STARTED_DIALOG_H -//#include +#include + #include "ui_GetStartedDialog.h" -#include "mainpage.h" #include diff --git a/retroshare-gui/src/gui/Identity/IdDialog.cpp b/retroshare-gui/src/gui/Identity/IdDialog.cpp index d49e558ec..f66f9d6af 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDialog.cpp @@ -321,10 +321,10 @@ IdDialog::IdDialog(QWidget *parent) : MainPage(parent), ui(new Ui::IdDialog) connect(idTWHAction, SIGNAL(toggled(bool)), this, SLOT(filterToggled(bool))); idTWHMenu->addAction(idTWHAction); - QAction *CreateIDAction = new QAction(QIcon(":/icons/png/person.png"),tr("Create new Identity"), this); + QAction *CreateIDAction = new QAction(FilesDefs::getIconFromQtResourcePath(":/icons/png/person.png"),tr("Create new Identity"), this); connect(CreateIDAction, SIGNAL(triggered()), this, SLOT(addIdentity())); - QAction *CreateCircleAction = new QAction(QIcon(":/icons/png/circles.png"),tr("Create new circle"), this); + QAction *CreateCircleAction = new QAction(FilesDefs::getIconFromQtResourcePath(":/icons/png/circles.png"),tr("Create new circle"), this); connect(CreateCircleAction, SIGNAL(triggered()), this, SLOT(createExternalCircle())); QMenu *menu = new QMenu(); @@ -1017,11 +1017,11 @@ void IdDialog::CircleListCustomPopupMenu( QPoint ) #endif if(group_flags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN) { - contextMnu.addAction(QIcon(IMAGE_EDIT), tr("Edit Circle"), this, SLOT(showEditExistingCircle())); + contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_EDIT), tr("Edit Circle"), this, SLOT(showEditExistingCircle())); am_I_circle_admin = true ; } else - contextMnu.addAction(QIcon(IMAGE_INFO), tr("See details"), this, SLOT(showEditExistingCircle())); + contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_INFO), tr("See details"), this, SLOT(showEditExistingCircle())); #ifdef CIRCLE_MEMBERSHIP_CATEGORIES } #endif @@ -1109,9 +1109,9 @@ void IdDialog::CircleListCustomPopupMenu( QPoint ) QAction *action ; if(is_circle) - action = new QAction(QIcon(image_names[i]), menu_titles[i] + " " + id_name,this) ; + action = new QAction(FilesDefs::getIconFromQtResourcePath(image_names[i]), menu_titles[i] + " " + id_name,this) ; else - action = new QAction(QIcon(image_names[i]), menu_titles[i],this) ; + action = new QAction(FilesDefs::getIconFromQtResourcePath(image_names[i]), menu_titles[i],this) ; if(i <2) QObject::connect(action,SIGNAL(triggered()), this, SLOT(acceptCircleSubscription())); @@ -1134,7 +1134,7 @@ void IdDialog::CircleListCustomPopupMenu( QPoint ) else id_name = tr("for identity ")+QString::fromStdString(ids[i][j].toStdString()) ; - QAction *action = new QAction(QIcon(image_names[i]), id_name,this) ; + QAction *action = new QAction(FilesDefs::getIconFromQtResourcePath(image_names[i]), id_name,this) ; if(i <2) QObject::connect(action,SIGNAL(triggered()), this, SLOT(acceptCircleSubscription())); @@ -1862,10 +1862,17 @@ QString IdDialog::createUsageString(const RsIdentityUsage& u) const { case RsServiceType::CHANNELS: service_name = tr("Channels") ;service_type = RetroShareLink::TYPE_CHANNEL ; break ; case RsServiceType::FORUMS: service_name = tr("Forums") ; service_type = RetroShareLink::TYPE_FORUM ; break ; - case RsServiceType::POSTED: service_name = tr("Posted") ; service_type = RetroShareLink::TYPE_POSTED ; break ; + case RsServiceType::POSTED: service_name = tr("Boards") ; service_type = RetroShareLink::TYPE_POSTED ; break ; case RsServiceType::CHAT: service_name = tr("Chat") ; service_type = RetroShareLink::TYPE_CHAT_ROOM ; break ; + + case RsServiceType::GXS_TRANS: return tr("GxsMail author "); +#ifdef TODO + // We need a RS link for circles if we want to do that. + // + case RsServiceType::GXSCIRCLE: service_name = tr("GxsCircles"); service_type = RetroShareLink::TYPE_CIRCLES; break ; +#endif default: - service_name = tr("Unknown"); service_type = RetroShareLink::TYPE_UNKNOWN ; + service_name = tr("Unknown (service=")+QString::number((int)u.mServiceId,16)+")"; service_type = RetroShareLink::TYPE_UNKNOWN ; } switch(u.mUsageCode) @@ -1885,10 +1892,25 @@ QString IdDialog::createUsageString(const RsIdentityUsage& u) const return tr("Group author for group %1 in service %2").arg(QString::fromStdString(u.mGrpId.toStdString())).arg(service_name); break ; case RsIdentityUsage::MESSAGE_AUTHOR_SIGNATURE_VALIDATION: - case RsIdentityUsage::MESSAGE_AUTHOR_KEEP_ALIVE: // Identities are stamped regularly by crawlign the set of messages for all groups. That helps keepign the useful identities in hand. + case RsIdentityUsage::MESSAGE_AUTHOR_KEEP_ALIVE: // Identities are stamped regularly by crawling the set of messages for all groups. That helps keepign the useful identities in hand. { - RetroShareLink l = RetroShareLink::createGxsMessageLink(service_type,u.mGrpId,u.mMsgId,tr("Message/vote/comment")); - return tr("%1 in %2 tab").arg(l.toHtml()).arg(service_name) ; + RetroShareLink l; + + std::cerr << "Signature validation/keep alive signature:" << std::endl; + std::cerr << " service ID = " << std::hex << (uint16_t)u.mServiceId << std::dec << std::endl; + std::cerr << " u.mGrpId = " << u.mGrpId << std::endl; + std::cerr << " u.mMsgId = " << u.mMsgId << std::endl; + std::cerr << " u.mParentId = " << u.mParentId << std::endl; + std::cerr << " u.mThreadId = " << u.mThreadId << std::endl; + + if(service_type == RetroShareLink::TYPE_CHANNEL && !u.mThreadId.isNull()) + l = RetroShareLink::createGxsMessageLink(service_type,u.mGrpId,u.mThreadId,tr("Vote/comment")); + else if(service_type == RetroShareLink::TYPE_POSTED && !u.mThreadId.isNull()) + l = RetroShareLink::createGxsMessageLink(service_type,u.mGrpId,u.mThreadId,tr("Vote")); + else + l = RetroShareLink::createGxsMessageLink(service_type,u.mGrpId,u.mMsgId,tr("Message")); + + return tr("%1 in %2 service").arg(l.toHtml()).arg(service_name) ; } case RsIdentityUsage::CHAT_LOBBY_MSG_VALIDATION: // Chat lobby msgs are signed, so each time one comes, or a chat lobby event comes, a signature verificaiton happens. { @@ -1914,9 +1936,13 @@ QString IdDialog::createUsageString(const RsIdentityUsage& u) const { return tr("Signature in distant tunnel system."); } - case RsIdentityUsage::IDENTITY_DATA_UPDATE: // Group update on that identity data. Can be avatar, name, etc. + case RsIdentityUsage::IDENTITY_NEW_FROM_GXS_SYNC: // Group update on that identity data. Can be avatar, name, etc. { - return tr("Update of identity data."); + return tr("Received from GXS sync."); + } + case RsIdentityUsage::IDENTITY_NEW_FROM_DISCOVERY: // Own friend sended his own ids + { + return tr("Friend node identity received through discovery."); } case RsIdentityUsage::IDENTITY_GENERIC_SIGNATURE_CHECK: // Any signature verified for that identity { @@ -1924,11 +1950,18 @@ QString IdDialog::createUsageString(const RsIdentityUsage& u) const } case RsIdentityUsage::IDENTITY_GENERIC_SIGNATURE_CREATION: // Any signature made by that identity { - return tr("Generic signature."); + return tr("Generic signature creation (e.g. chat room message, global router,...)."); } case RsIdentityUsage::IDENTITY_GENERIC_ENCRYPTION: return tr("Generic encryption."); case RsIdentityUsage::IDENTITY_GENERIC_DECRYPTION: return tr("Generic decryption."); - case RsIdentityUsage::CIRCLE_MEMBERSHIP_CHECK: return tr("Membership verification in circle %1.").arg(QString::fromStdString(u.mGrpId.toStdString())); + case RsIdentityUsage::CIRCLE_MEMBERSHIP_CHECK: + { + RsGxsCircleDetails det; + if(rsGxsCircles->getCircleDetails(RsGxsCircleId(u.mGrpId),det)) + return tr("Membership verification in circle \"%1\" (%2).").arg(QString::fromUtf8(det.mCircleName.c_str())).arg(QString::fromStdString(u.mGrpId.toStdString())); + else + return tr("Membership verification in circle (ID=%1).").arg(QString::fromStdString(u.mGrpId.toStdString())); + } #warning TODO! csoler 2017-01-03: Add the different strings and translations here. default: @@ -2162,7 +2195,7 @@ void IdDialog::IdListCustomPopupMenu( QPoint ) { if(own_identities.size() <= 1) { - QAction *action = contextMenu->addAction(QIcon(":/icons/png/chats.png"), tr("Chat with this person"), this, SLOT(chatIdentity())); + QAction *action = contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(":/icons/png/chats.png"), tr("Chat with this person"), this, SLOT(chatIdentity())); if(own_identities.empty()) action->setEnabled(false) ; @@ -2171,7 +2204,7 @@ void IdDialog::IdListCustomPopupMenu( QPoint ) } else { - QMenu *mnu = contextMenu->addMenu(QIcon(":/icons/png/chats.png"),tr("Chat with this person as...")) ; + QMenu *mnu = contextMenu->addMenu(FilesDefs::getIconFromQtResourcePath(":/icons/png/chats.png"),tr("Chat with this person as...")) ; for(std::list::const_iterator it=own_identities.begin();it!=own_identities.end();++it) { @@ -2189,7 +2222,7 @@ void IdDialog::IdListCustomPopupMenu( QPoint ) } } // always allow to send messages - contextMenu->addAction(QIcon(":/icons/mail/write-mail.png"), tr("Send message"), this, SLOT(sendMsg())); + contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(":/icons/mail/write-mail.png"), tr("Send message"), this, SLOT(sendMsg())); contextMenu->addSeparator(); @@ -2200,18 +2233,18 @@ void IdDialog::IdListCustomPopupMenu( QPoint ) contextMenu->addAction(QIcon(""),tr("Copy identity to clipboard"),this,SLOT(copyRetroshareLink())) ; if(n_is_not_a_contact == 0) - contextMenu->addAction(QIcon(":/images/cancel.png"), tr("Remove from Contacts"), this, SLOT(removefromContacts())); + contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(":/images/cancel.png"), tr("Remove from Contacts"), this, SLOT(removefromContacts())); contextMenu->addSeparator(); if(n_positive_reputations == 0) // only unban when all items are banned - contextMenu->addAction(QIcon(":/icons/png/thumbs-up.png"), tr("Set positive opinion"), this, SLOT(positivePerson())); + contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(":/icons/png/thumbs-up.png"), tr("Set positive opinion"), this, SLOT(positivePerson())); if(n_neutral_reputations == 0) // only unban when all items are banned - contextMenu->addAction(QIcon(":/icons/png/thumbs-neutral.png"), tr("Set neutral opinion"), this, SLOT(neutralPerson())); + contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(":/icons/png/thumbs-neutral.png"), tr("Set neutral opinion"), this, SLOT(neutralPerson())); if(n_negative_reputations == 0) - contextMenu->addAction(QIcon(":/icons/png/thumbs-down.png"), tr("Set negative opinion"), this, SLOT(negativePerson())); + contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(":/icons/png/thumbs-down.png"), tr("Set negative opinion"), this, SLOT(negativePerson())); } if(one_item_owned_by_you && n_selected_items==1) diff --git a/retroshare-gui/src/gui/NetworkDialog.h b/retroshare-gui/src/gui/NetworkDialog.h index 8391ad476..9561c1db3 100644 --- a/retroshare-gui/src/gui/NetworkDialog.h +++ b/retroshare-gui/src/gui/NetworkDialog.h @@ -21,8 +21,10 @@ #ifndef _CONNECTIONSDIALOG_H #define _CONNECTIONSDIALOG_H +#include + #include "ui_NetworkDialog.h" -#include "RsAutoUpdatePage.h" + #include "gui/NetworkDialog/pgpid_item_model.h" #include "gui/NetworkDialog/pgpid_item_proxy.h" diff --git a/retroshare-gui/src/gui/NetworkView.h b/retroshare-gui/src/gui/NetworkView.h index 274ca020b..f6fcfe0b1 100644 --- a/retroshare-gui/src/gui/NetworkView.h +++ b/retroshare-gui/src/gui/NetworkView.h @@ -25,7 +25,7 @@ #include -#include "RsAutoUpdatePage.h" +#include #include "ui_NetworkView.h" diff --git a/retroshare-gui/src/gui/NewsFeed.h b/retroshare-gui/src/gui/NewsFeed.h index 713bcf96c..869d654fd 100644 --- a/retroshare-gui/src/gui/NewsFeed.h +++ b/retroshare-gui/src/gui/NewsFeed.h @@ -21,7 +21,7 @@ #ifndef _NEWS_FEED_DIALOG_H #define _NEWS_FEED_DIALOG_H -#include "mainpage.h" +#include #include "gui/feeds/FeedHolder.h" #include "util/TokenQueue.h" diff --git a/retroshare-gui/src/gui/PluginsPage.h b/retroshare-gui/src/gui/PluginsPage.h index 4832a1ac6..36d4f9c8a 100644 --- a/retroshare-gui/src/gui/PluginsPage.h +++ b/retroshare-gui/src/gui/PluginsPage.h @@ -21,7 +21,7 @@ #ifndef _PLUGINS_PAGE_H_ #define _PLUGINS_PAGE_H_ -#include "mainpage.h" +#include #include #include diff --git a/retroshare-gui/src/gui/Posted/PostedDialog.cpp b/retroshare-gui/src/gui/Posted/PostedDialog.cpp index 4cac07246..327ecdd12 100644 --- a/retroshare-gui/src/gui/Posted/PostedDialog.cpp +++ b/retroshare-gui/src/gui/Posted/PostedDialog.cpp @@ -255,7 +255,7 @@ void PostedDialog::groupInfoToGroupItemInfo(const RsGxsGenericGroupData *groupDa groupItemInfo.icon = image; } else - groupItemInfo.icon = QIcon(":icons/png/postedlinks.png"); + groupItemInfo.icon = FilesDefs::getIconFromQtResourcePath(":icons/png/postedlinks.png"); groupItemInfo.description = QString::fromUtf8(postedGroupData->mDescription.c_str()); } diff --git a/retroshare-gui/src/gui/RemoteDirModel.cpp b/retroshare-gui/src/gui/RemoteDirModel.cpp index b69929778..ed61cf4f5 100644 --- a/retroshare-gui/src/gui/RemoteDirModel.cpp +++ b/retroshare-gui/src/gui/RemoteDirModel.cpp @@ -20,7 +20,8 @@ #include "RemoteDirModel.h" -#include "RsAutoUpdatePage.h" +#include + #include "gui/common/FilesDefs.h" #include "gui/common/GroupDefs.h" #include "gui/common/RsCollection.h" @@ -1103,15 +1104,9 @@ Qt::ItemFlags RetroshareDirModel::flags( const QModelIndex & index ) const /* Callback from Core*/ void RetroshareDirModel::preMods() { - emit layoutAboutToBeChanged(); mUpdating = true ; -#if QT_VERSION < 0x050000 - reset(); -#else - beginResetModel(); - endResetModel(); -#endif + beginResetModel(); #ifdef RDM_DEBUG std::cerr << "RetroshareDirModel::preMods()" << std::endl; #endif @@ -1120,20 +1115,14 @@ void RetroshareDirModel::preMods() /* Callback from Core*/ void RetroshareDirModel::postMods() { -// emit layoutAboutToBeChanged(); mUpdating = false ; -#if QT_VERSION >= 0x040600 - beginResetModel(); -#endif - #ifdef RDM_DEBUG std::cerr << "RetroshareDirModel::postMods()" << std::endl; #endif -#if QT_VERSION >= 0x040600 endResetModel(); -#endif - emit layoutChanged(); + + emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(rowCount()-1,COLUMN_COUNT-1,(void*)NULL)); } void FlatStyle_RDM::postMods() diff --git a/retroshare-gui/src/gui/RsAutoUpdatePage.cpp b/retroshare-gui/src/gui/RsAutoUpdatePage.cpp index 03d231cf0..4c18d294b 100644 --- a/retroshare-gui/src/gui/RsAutoUpdatePage.cpp +++ b/retroshare-gui/src/gui/RsAutoUpdatePage.cpp @@ -19,7 +19,8 @@ *******************************************************************************/ #include -#include "RsAutoUpdatePage.h" + +#include bool RsAutoUpdatePage::_locked = false ; diff --git a/retroshare-gui/src/gui/TheWire/PulseAddDialog.cpp b/retroshare-gui/src/gui/TheWire/PulseAddDialog.cpp index 9a493b7d0..dc09a11f1 100644 --- a/retroshare-gui/src/gui/TheWire/PulseAddDialog.cpp +++ b/retroshare-gui/src/gui/TheWire/PulseAddDialog.cpp @@ -19,8 +19,9 @@ *******************************************************************************/ #include +#include -#include "PulseDetails.h" +#include "PulseReply.h" #include "PulseAddDialog.h" @@ -28,17 +29,17 @@ const uint32_t PULSE_MAX_SIZE = 1000; // 1k char. /** Constructor */ PulseAddDialog::PulseAddDialog(QWidget *parent) -: QWidget(parent), mIsReply(false), mWaitingRefMsg(false) +: QWidget(parent), mIsReply(false) { ui.setupUi(this); - mWireQueue = new TokenQueue(rsWire->getTokenService(), this); - connect(ui.pushButton_Post, SIGNAL( clicked( void ) ), this, SLOT( postPulse( void ) ) ); connect(ui.pushButton_AddURL, SIGNAL( clicked( void ) ), this, SLOT( addURL( void ) ) ); connect(ui.pushButton_ClearDisplayAs, SIGNAL( clicked( void ) ), this, SLOT( clearDisplayAs( void ) ) ); connect(ui.pushButton_Cancel, SIGNAL( clicked( void ) ), this, SLOT( cancelPulse( void ) ) ); connect(ui.textEdit_Pulse, SIGNAL( textChanged( void ) ), this, SLOT( pulseTextChanged( void ) ) ); + + setAcceptDrops(true); } void PulseAddDialog::setGroup(RsWireGroup &group) @@ -48,12 +49,21 @@ void PulseAddDialog::setGroup(RsWireGroup &group) mGroup = group; } +// set ReplyWith Group. +void PulseAddDialog::setGroup(const RsGxsGroupId &grpId) +{ + /* fetch in the background */ + RsWireGroupSPtr pGroup; + rsWire->getWireGroup(grpId, pGroup); + + setGroup(*pGroup); +} void PulseAddDialog::cleanup() { if (mIsReply) { - std::cerr << "PulseAddDialog::setReplyTo() cleaning up old replyto"; + std::cerr << "PulseAddDialog::cleanup() cleaning up old replyto"; std::cerr << std::endl; QLayout *layout = ui.widget_replyto->layout(); // completely delete layout and sublayouts @@ -63,30 +73,51 @@ void PulseAddDialog::cleanup() { if ((widget = item->widget()) != 0) { - std::cerr << "PulseAddDialog::setReplyTo() removing widget"; + std::cerr << "PulseAddDialog::cleanup() removing widget"; std::cerr << std::endl; widget->hide(); delete widget; } else { - std::cerr << "PulseAddDialog::setReplyTo() removing item"; + std::cerr << "PulseAddDialog::cleanup() removing item"; std::cerr << std::endl; delete item; } } // then finally delete layout; - mIsReply = false; + mIsReply = false; } ui.frame_reply->setVisible(false); ui.comboBox_sentiment->setCurrentIndex(0); ui.lineEdit_URL->setText(""); ui.lineEdit_DisplayAs->setText(""); ui.textEdit_Pulse->setPlainText(""); - ui.pushButton_Post->setEnabled(false); // disable URL until functionality finished. ui.frame_URL->setEnabled(false); + + ui.pushButton_Post->setEnabled(false); + ui.pushButton_Post->setText("Post Pulse to Wire"); + ui.frame_input->setVisible(true); + ui.widget_sentiment->setVisible(true); + + // cleanup images. + mImage1.clear(); + ui.label_image1->clear(); + ui.label_image1->setText("Drag and Drop Image"); + + mImage2.clear(); + ui.label_image2->clear(); + ui.label_image2->setText("Drag and Drop Image"); + + mImage3.clear(); + ui.label_image3->clear(); + ui.label_image3->setText("Drag and Drop Image"); + + mImage4.clear(); + ui.label_image4->clear(); + ui.label_image4->setText("Drag and Drop Image"); } void PulseAddDialog::pulseTextChanged() @@ -96,26 +127,74 @@ void PulseAddDialog::pulseTextChanged() ui.pushButton_Post->setEnabled(enable); } -void PulseAddDialog::setReplyTo(RsWirePulse &pulse, std::string &groupName) +// Old Interface, deprecate / make internal. +// TODO: Convert mReplyToPulse to be an SPtr, and remove &pulse parameter. +void PulseAddDialog::setReplyTo(RsWirePulse &pulse, RsWirePulseSPtr pPulse, std::string &groupName, uint32_t replyType) { mIsReply = true; mReplyToPulse = pulse; - mReplyGroupName = groupName; + mReplyType = replyType; ui.frame_reply->setVisible(true); { - std::map replies; - PulseDetails *details = new PulseDetails(NULL, &pulse, groupName, replies); + PulseReply *reply = new PulseReply(NULL, pPulse); + // add extra widget into layout. QVBoxLayout *vbox = new QVBoxLayout(); - vbox->addWidget(details); + vbox->addWidget(reply); vbox->setSpacing(1); vbox->setContentsMargins(0,0,0,0); ui.widget_replyto->setLayout(vbox); ui.widget_replyto->setVisible(true); } + + if (mReplyType & WIRE_PULSE_TYPE_REPLY) + { + ui.pushButton_Post->setText("Reply to Pulse"); + } + else + { + // cannot add msg for like / republish. + ui.pushButton_Post->setEnabled(true); + ui.frame_input->setVisible(false); + ui.widget_sentiment->setVisible(false); + if (mReplyType & WIRE_PULSE_TYPE_REPUBLISH) { + ui.pushButton_Post->setText("Republish Pulse"); + } + else if (mReplyType & WIRE_PULSE_TYPE_LIKE) { + ui.pushButton_Post->setText("Like Pulse"); + } + } + } +void PulseAddDialog::setReplyTo(const RsGxsGroupId &grpId, const RsGxsMessageId &msgId, uint32_t replyType) +{ + /* fetch in the background */ + RsWireGroupSPtr pGroup; + if (!rsWire->getWireGroup(grpId, pGroup)) + { + std::cerr << "PulseAddDialog::setRplyTo() failed to fetch group"; + std::cerr << std::endl; + return; + } + + RsWirePulseSPtr pPulse; + if (!rsWire->getWirePulse(grpId, msgId, pPulse)) + { + std::cerr << "PulseAddDialog::setRplyTo() failed to fetch pulse"; + std::cerr << std::endl; + return; + } + + // update GroupPtr + // TODO - this should be handled in libretroshare if possible. + if (pPulse->mGroupPtr == NULL) { + pPulse->mGroupPtr = pGroup; + } + + setReplyTo(*pPulse, pPulse, pGroup->mMeta.mGroupName, replyType); +} void PulseAddDialog::addURL() { @@ -164,21 +243,23 @@ void PulseAddDialog::postOriginalPulse() std::cerr << "PulseAddDialog::postOriginalPulse()"; std::cerr << std::endl; - RsWirePulse pulse; + RsWirePulseSPtr pPulse(new RsWirePulse()); - pulse.mMeta.mGroupId = mGroup.mMeta.mGroupId; - pulse.mMeta.mAuthorId = mGroup.mMeta.mAuthorId; - pulse.mMeta.mThreadId.clear(); - pulse.mMeta.mParentId.clear(); - pulse.mMeta.mOrigMsgId.clear(); + pPulse->mSentiment = WIRE_PULSE_SENTIMENT_NO_SENTIMENT; + pPulse->mPulseText = ui.textEdit_Pulse->toPlainText().toStdString(); + // set images here too. + pPulse->mImage1 = mImage1; + pPulse->mImage2 = mImage2; + pPulse->mImage3 = mImage3; + pPulse->mImage4 = mImage4; - pulse.mPulseType = WIRE_PULSE_TYPE_ORIGINAL_MSG; - pulse.mReplySentiment = WIRE_PULSE_SENTIMENT_NO_SENTIMENT; - pulse.mPulseText = ui.textEdit_Pulse->toPlainText().toStdString(); - // all mRefs should empty. - - uint32_t token; - rsWire->createPulse(token, pulse); + // this should be in async thread, so doesn't block UI thread. + if (!rsWire->createOriginalPulse(mGroup.mMeta.mGroupId, pPulse)) + { + std::cerr << "PulseAddDialog::postOriginalPulse() FAILED"; + std::cerr << std::endl; + return; + } clearDialog(); hide(); @@ -211,67 +292,39 @@ void PulseAddDialog::postReplyPulse() std::cerr << "PulseAddDialog::postReplyPulse()"; std::cerr << std::endl; - RsWirePulse pulse; + RsWirePulseSPtr pPulse(new RsWirePulse()); - pulse.mMeta.mGroupId = mGroup.mMeta.mGroupId; - pulse.mMeta.mAuthorId = mGroup.mMeta.mAuthorId; - pulse.mMeta.mThreadId.clear(); - pulse.mMeta.mParentId.clear(); - pulse.mMeta.mOrigMsgId.clear(); + pPulse->mSentiment = toPulseSentiment(ui.comboBox_sentiment->currentIndex()); + pPulse->mPulseText = ui.textEdit_Pulse->toPlainText().toStdString(); + // set images here too. + pPulse->mImage1 = mImage1; + pPulse->mImage2 = mImage2; + pPulse->mImage3 = mImage3; + pPulse->mImage4 = mImage4; - pulse.mPulseType = WIRE_PULSE_TYPE_REPLY_MSG; - pulse.mReplySentiment = toPulseSentiment(ui.comboBox_sentiment->currentIndex()); - pulse.mPulseText = ui.textEdit_Pulse->toPlainText().toStdString(); + if (mReplyType & WIRE_PULSE_TYPE_REPUBLISH) { + // Copy details from parent, and override + pPulse->mSentiment = mReplyToPulse.mSentiment; + pPulse->mPulseText = mReplyToPulse.mPulseText; - // mRefs refer to parent post. - pulse.mRefGroupId = mReplyToPulse.mMeta.mGroupId; - pulse.mRefGroupName = mReplyGroupName; - pulse.mRefOrigMsgId = mReplyToPulse.mMeta.mOrigMsgId; - pulse.mRefAuthorId = mReplyToPulse.mMeta.mAuthorId; - pulse.mRefPublishTs = mReplyToPulse.mMeta.mPublishTs; - pulse.mRefPulseText = mReplyToPulse.mPulseText; + // Copy images. + pPulse->mImage1 = mReplyToPulse.mImage1; + pPulse->mImage2 = mReplyToPulse.mImage2; + pPulse->mImage3 = mReplyToPulse.mImage3; + pPulse->mImage4 = mReplyToPulse.mImage4; + } - // Need Pulse MsgID before we can create associated Reference. - mWaitingRefMsg = true; - - uint32_t token; - rsWire->createPulse(token, pulse); - mWireQueue->queueRequest(token, TOKENREQ_MSGINFO, RS_TOKREQ_ANSTYPE_ACK, 0); -} - - -void PulseAddDialog::postRefPulse(RsWirePulse &pulse) -{ - std::cerr << "PulseAddDialog::postRefPulse() create Reference!"; - std::cerr << std::endl; - - // Reference Pulse. posted on Parent's Group. - RsWirePulse refPulse; - - refPulse.mMeta.mGroupId = mReplyToPulse.mMeta.mGroupId; - refPulse.mMeta.mAuthorId = mGroup.mMeta.mAuthorId; // own author Id. - refPulse.mMeta.mThreadId = mReplyToPulse.mMeta.mOrigMsgId; - refPulse.mMeta.mParentId = mReplyToPulse.mMeta.mOrigMsgId; - refPulse.mMeta.mOrigMsgId.clear(); - - refPulse.mPulseType = WIRE_PULSE_TYPE_REPLY_REFERENCE; - refPulse.mReplySentiment = toPulseSentiment(ui.comboBox_sentiment->currentIndex()); - - // Dont put parent PulseText into refPulse - it is available on Thread Msg. - // otherwise gives impression it is correctly setup Parent / Reply... - // when in fact the parent PublishTS, and AuthorId are wrong. - refPulse.mPulseText = ""; - - // refs refer back to own Post. - refPulse.mRefGroupId = mGroup.mMeta.mGroupId; - refPulse.mRefGroupName = mGroup.mMeta.mGroupName; - refPulse.mRefOrigMsgId = pulse.mMeta.mOrigMsgId; - refPulse.mRefAuthorId = mGroup.mMeta.mAuthorId; - refPulse.mRefPublishTs = pulse.mMeta.mPublishTs; - refPulse.mRefPulseText = pulse.mPulseText; - - uint32_t token; - rsWire->createPulse(token, refPulse); + // this should be in async thread, so doesn't block UI thread. + if (!rsWire->createReplyPulse(mReplyToPulse.mMeta.mGroupId, + mReplyToPulse.mMeta.mOrigMsgId, + mGroup.mMeta.mGroupId, + mReplyType, + pPulse)) + { + std::cerr << "PulseAddDialog::postReplyPulse() FAILED"; + std::cerr << std::endl; + return; + } clearDialog(); hide(); @@ -282,90 +335,131 @@ void PulseAddDialog::clearDialog() ui.textEdit_Pulse->setPlainText(""); } +//--------------------------------------------------------------------- +// Drag and Drop Images. -void PulseAddDialog::acknowledgeMessage(const uint32_t &token) +void PulseAddDialog::dragEnterEvent(QDragEnterEvent *event) { - std::cerr << "PulseAddDialog::acknowledgeMessage()"; + std::cerr << "PulseAddDialog::dragEnterEvent()"; std::cerr << std::endl; - std::pair p; - rsWire->acknowledgeMsg(token, p); - - if (mWaitingRefMsg) + if (event->mimeData()->hasUrls()) { - std::cerr << "PulseAddDialog::acknowledgeMessage() Waiting Ref Msg"; + std::cerr << "PulseAddDialog::dragEnterEvent() Accepting"; std::cerr << std::endl; - mWaitingRefMsg = false; - - // request photo data. - GxsMsgReq req; - std::set msgIds; - msgIds.insert(p.second); - req[p.first] = msgIds; - - RsTokReqOptions opts; - opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA; - uint32_t token; - mWireQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, req, 0); + event->accept(); } else { - std::cerr << "PulseAddDialog::acknowledgeMessage() Not Waiting Ref Msg"; + std::cerr << "PulseAddDialog::dragEnterEvent() Ignoring"; std::cerr << std::endl; + event->ignore(); } } -void PulseAddDialog::loadPulseData(const uint32_t &token) +void PulseAddDialog::dragLeaveEvent(QDragLeaveEvent *event) { - std::cerr << "PulseAddDialog::loadPulseData()"; + std::cerr << "PulseAddDialog::dragLeaveEvent()"; std::cerr << std::endl; - std::vector pulses; - rsWire->getPulseData(token, pulses); - if (pulses.size() != 1) + event->ignore(); +} + +void PulseAddDialog::dragMoveEvent(QDragMoveEvent *event) +{ + std::cerr << "PulseAddDialog::dragMoveEvent()"; + std::cerr << std::endl; + + event->accept(); +} + +void PulseAddDialog::dropEvent(QDropEvent *event) +{ + std::cerr << "PulseAddDialog::dropEvent()"; + std::cerr << std::endl; + + if (event->mimeData()->hasUrls()) { - std::cerr << "PulseAddDialog::loadPulseData() Error Too many pulses"; + std::cerr << "PulseAddDialog::dropEvent() Urls:" << std::endl; + + QList urls = event->mimeData()->urls(); + QList::iterator uit; + for (uit = urls.begin(); uit != urls.end(); ++uit) + { + QString localpath = uit->toLocalFile(); + std::cerr << "Whole URL: " << uit->toString().toStdString() << std::endl; + std::cerr << "or As Local File: " << localpath.toStdString() << std::endl; + + addImage(localpath); + } + event->setDropAction(Qt::CopyAction); + event->accept(); + } + else + { + std::cerr << "PulseAddDialog::dropEvent Ignoring"; + std::cerr << std::endl; + event->ignore(); + } +} + + +void PulseAddDialog::addImage(const QString &path) +{ + std::cerr << "PulseAddDialog::addImage() loading image from: " << path.toStdString(); + std::cerr << std::endl; + + QPixmap qtn = QPixmap(path); + if (qtn.isNull()) { + std::cerr << "PulseAddDialog::addImage() Invalid Image"; std::cerr << std::endl; return; } - std::cerr << "PulseAddDialog::loadPulseData() calling postRefMsg"; - std::cerr << std::endl; + QPixmap image; + if ((qtn.width() <= 512) && (qtn.height() <= 512)) { + image = qtn; + } else { + image = qtn.scaled(512, 512, Qt::KeepAspectRatio, Qt::SmoothTransformation); + } - RsWirePulse& pulse = pulses[0]; - postRefPulse(pulse); -} + // scaled down for display, allow wide images. + QPixmap icon = qtn.scaled(256, 128, Qt::KeepAspectRatio, Qt::SmoothTransformation); + QByteArray ba; + QBuffer buffer(&ba); + buffer.open(QIODevice::WriteOnly); + image.save(&buffer, "JPG"); -/**************************** Request / Response Filling of Data ************************/ - -void PulseAddDialog::loadRequest(const TokenQueue *queue, const TokenRequest &req) -{ - if (queue == mWireQueue) - { - /* now switch on req */ - switch(req.mType) - { - case TOKENREQ_MSGINFO: - switch(req.mAnsType) - { - case RS_TOKREQ_ANSTYPE_ACK: - acknowledgeMessage(req.mToken); - break; - case RS_TOKREQ_ANSTYPE_DATA: - loadPulseData(req.mToken); - break; - default: - std::cerr << "PulseAddDialog::loadRequest() ERROR: MSG: INVALID ANS TYPE"; - std::cerr << std::endl; - break; - } - break; - default: - std::cerr << "PulseAddDialog::loadRequest() ERROR: INVALID TYPE"; - std::cerr << std::endl; - break; - } + if (mImage1.empty()) { + std::cerr << "PulseAddDialog::addImage() Installing in Image1"; + std::cerr << std::endl; + ui.label_image1->setPixmap(icon); + mImage1.copy((uint8_t *) ba.data(), ba.size()); + std::cerr << "PulseAddDialog::addImage() Installing in Image1 Size: " << mImage1.mSize; + std::cerr << std::endl; + } + else if (mImage2.empty()) { + ui.label_image2->setPixmap(icon); + mImage2.copy((uint8_t *) ba.data(), ba.size()); + std::cerr << "PulseAddDialog::addImage() Installing in Image2 Size: " << mImage2.mSize; + std::cerr << std::endl; + } + else if (mImage3.empty()) { + ui.label_image3->setPixmap(icon); + mImage3.copy((uint8_t *) ba.data(), ba.size()); + std::cerr << "PulseAddDialog::addImage() Installing in Image3 Size: " << mImage3.mSize; + std::cerr << std::endl; + } + else if (mImage4.empty()) { + ui.label_image4->setPixmap(icon); + mImage4.copy((uint8_t *) ba.data(), ba.size()); + std::cerr << "PulseAddDialog::addImage() Installing in Image4 Size: " << mImage4.mSize; + std::cerr << std::endl; + } + else { + std::cerr << "PulseAddDialog::addImage() Images all full"; + std::cerr << std::endl; } } - + diff --git a/retroshare-gui/src/gui/TheWire/PulseAddDialog.h b/retroshare-gui/src/gui/TheWire/PulseAddDialog.h index 0ab3c826a..51f92f4e9 100644 --- a/retroshare-gui/src/gui/TheWire/PulseAddDialog.h +++ b/retroshare-gui/src/gui/TheWire/PulseAddDialog.h @@ -24,9 +24,16 @@ #include "ui_PulseAddDialog.h" #include -#include "util/TokenQueue.h" -class PulseAddDialog : public QWidget, public TokenResponse + +QT_BEGIN_NAMESPACE +class QDragEnterEvent; +class QDropEvent; +class QMouseEvent; +QT_END_NAMESPACE + + +class PulseAddDialog : public QWidget { Q_OBJECT @@ -34,8 +41,9 @@ public: PulseAddDialog(QWidget *parent = 0); void cleanup(); - void setGroup(RsWireGroup &group); - void setReplyTo(RsWirePulse &pulse, std::string &groupName); + + void setReplyTo(const RsGxsGroupId &grpId, const RsGxsMessageId &msgId, uint32_t replyType); + void setGroup(const RsGxsGroupId &grpId); private slots: void addURL(); @@ -46,28 +54,37 @@ private slots: void pulseTextChanged(); private: + // OLD VERSIONs, private now. + void setGroup(RsWireGroup &group); + void setReplyTo(RsWirePulse &pulse, RsWirePulseSPtr pPulse, std::string &groupName, uint32_t replyType); + void postOriginalPulse(); void postReplyPulse(); - void postRefPulse(RsWirePulse &pulse); - void acknowledgeMessage(const uint32_t &token); - void loadPulseData(const uint32_t &token); - void loadRequest(const TokenQueue *queue, const TokenRequest &req); uint32_t toPulseSentiment(int index); protected: + void dragEnterEvent(QDragEnterEvent *event); + void dragLeaveEvent(QDragLeaveEvent *event); + void dragMoveEvent(QDragMoveEvent *event); + void dropEvent(QDropEvent *event); - RsWireGroup mGroup; // where we want to post from. + void addImage(const QString &path); + + RsWireGroup mGroup; // replyWith. // if this is a reply bool mIsReply; - std::string mReplyGroupName; RsWirePulse mReplyToPulse; - bool mWaitingRefMsg; + uint32_t mReplyType; + + // images + RsGxsImage mImage1; + RsGxsImage mImage2; + RsGxsImage mImage3; + RsGxsImage mImage4; - TokenQueue* mWireQueue; Ui::PulseAddDialog ui; - }; #endif diff --git a/retroshare-gui/src/gui/TheWire/PulseAddDialog.ui b/retroshare-gui/src/gui/TheWire/PulseAddDialog.ui index b87d02794..0b6c4a70c 100644 --- a/retroshare-gui/src/gui/TheWire/PulseAddDialog.ui +++ b/retroshare-gui/src/gui/TheWire/PulseAddDialog.ui @@ -7,7 +7,7 @@ 0 0 720 - 586 + 633 @@ -150,7 +150,7 @@ - + QFrame::StyledPanel @@ -161,6 +161,88 @@ + + + + + 0 + 100 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + 80 + 80 + + + + Drag and Drop Image + + + Qt::AlignCenter + + + + + + + + 80 + 80 + + + + Drag and Drop Image + + + Qt::AlignCenter + + + + + + + + 80 + 80 + + + + Drag and Drop Image + + + Qt::AlignCenter + + + + + + + + 80 + 80 + + + + Drag and Drop Image + + + Qt::AlignCenter + + + + + + diff --git a/retroshare-gui/src/gui/TheWire/PulseDetails.cpp b/retroshare-gui/src/gui/TheWire/PulseDetails.cpp deleted file mode 100644 index 5cdddad70..000000000 --- a/retroshare-gui/src/gui/TheWire/PulseDetails.cpp +++ /dev/null @@ -1,214 +0,0 @@ -/******************************************************************************* - * gui/TheWire/PulseDetails.cpp * - * * - * Copyright (c) 2020 Robert Fernie * - * * - * This program is free software: you can redistribute it and/or modify * - * it under the terms of the GNU Affero General Public License as * - * published by the Free Software Foundation, either version 3 of the * - * License, or (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU Affero General Public License for more details. * - * * - * You should have received a copy of the GNU Affero General Public License * - * along with this program. If not, see . * - * * - *******************************************************************************/ - -#include -#include -#include -#include - -#include "PulseDetails.h" - -#include "util/DateTime.h" - -#include -#include - -/** Constructor */ -PulseDetails::PulseDetails(PulseHolder *actions, RsWirePulse *pulse, std::string &groupName, - std::map replies) -:QWidget(NULL), mActions(actions), mPulse(*pulse), mGroupName(groupName) -{ - setupUi(this); - setAttribute ( Qt::WA_DeleteOnClose, true ); - setup(); - addReplies(replies); -} - -PulseDetails::PulseDetails(PulseHolder *actions, - RsGxsGroupId &parentGroupId, - std::string &parentGroupName, - RsGxsMessageId &parentOrigMsgId, - RsGxsId &parentAuthorId, - rstime_t &parentPublishTs, - std::string &parentPulseText) -:QWidget(NULL), mActions(actions), mPulse(), mGroupName(parentGroupName) -{ - setupUi(this); - setAttribute ( Qt::WA_DeleteOnClose, true ); - - // reuse Meta data structure. - mPulse.mMeta.mGroupId = parentGroupId; - mPulse.mMeta.mOrigMsgId = parentOrigMsgId; - mPulse.mMeta.mAuthorId = parentAuthorId; - mPulse.mMeta.mPublishTs = parentPublishTs; - mPulse.mPulseText = parentPulseText; - setup(); -} - -void PulseDetails::setBackground(QString color) -{ - QWidget *tocolor = this; - QPalette p = tocolor->palette(); - p.setColor(tocolor->backgroundRole(), QColor(color)); - tocolor->setPalette(p); - tocolor->setAutoFillBackground(true); -} - -void PulseDetails::setup() -{ - connect(toolButton_expand, SIGNAL(clicked()), this, SLOT(toggle())); - - connect(toolButton_follow, SIGNAL(clicked()), this, SLOT(follow())); - connect(toolButton_rate, SIGNAL(clicked()), this, SLOT(rate())); - connect(toolButton_reply, SIGNAL(clicked()), this, SLOT(reply())); - - label_wireName->setText(QString::fromStdString(mGroupName)); - label_idName->setId(mPulse.mMeta.mAuthorId); - - label_date->setText(DateTime::formatDateTime(mPulse.mMeta.mPublishTs)); - label_summary->setText(getSummary()); - - // label_icon->setText(); - textBrowser->setPlainText(QString::fromStdString(mPulse.mPulseText)); - frame_expand->setVisible(false); - - label_replies->setText(""); - frame_replies->setVisible(false); - mHasReplies = false; - - toolButton_follow->setEnabled(false); // TODO - toolButton_rate->setEnabled(false); // TODO - toolButton_reply->setEnabled(mActions != NULL); -} - -void PulseDetails::addReplies(std::map replies) -{ - if (replies.size() == 0) - { - // do nothing. - return; - } - else if (replies.size() == 1) - { - label_replies->setText("1 reply"); - } - else if (replies.size() > 1) - { - label_replies->setText(QString("%1 replies").arg(replies.size())); - } - - // add extra widgets into layout. - QLayout *vbox = frame_replies->layout(); - mHasReplies = true; - - std::map emptyReplies; - std::map::reverse_iterator it; - for (it = replies.rbegin(); it != replies.rend(); it++) - { - // add Ref as child reply. - PulseDetails *pd = new PulseDetails(mActions, - it->second->mRefGroupId, - it->second->mRefGroupName, - it->second->mRefOrigMsgId, - it->second->mRefAuthorId, - it->second->mRefPublishTs, - it->second->mRefPulseText); - pd->setBackground("goldenrod"); - vbox->addWidget(pd); - } -} - - -void PulseDetails::toggle() -{ - if (frame_expand->isVisible()) { - // switch to minimal view. - label_summary->setVisible(true); - frame_expand->setVisible(false); - frame_replies->setVisible(false); - } else { - // switch to expanded view. - label_summary->setVisible(false); - frame_expand->setVisible(true); - if (mHasReplies) { - frame_replies->setVisible(true); - } - } -} - -QString PulseDetails::getSummary() -{ - std::string summary = mPulse.mPulseText; - std::cerr << "PulseDetails::getSummary() orig: " << summary; - std::cerr << std::endl; - int len = summary.size(); - bool in_whitespace = false; - for (int i = 0; i < len; i++) - { - if (isspace(summary[i])) { - if (in_whitespace) { - // trim - summary.erase(i, 1); - // rollback index / len. - --i; - --len; - } else { - // replace whitespace with space. - summary[i] = ' '; - in_whitespace = true; - } - } else { - in_whitespace = false; - } - } - std::cerr << "PulseDetails::getSummary() summary: " << summary; - std::cerr << std::endl; - - return QString::fromStdString(summary); -} - -void PulseDetails::follow() -{ - // follow group. - if (mActions) - { - mActions->follow(mPulse.mMeta.mGroupId); - } -} - -void PulseDetails::rate() -{ - // rate author - if (mActions) - { - mActions->rate(mPulse.mMeta.mAuthorId); - } -} - -void PulseDetails::reply() -{ - // reply - if (mActions) - { - mActions->reply(mPulse, mGroupName); - } -} - - diff --git a/retroshare-gui/src/gui/TheWire/PulseDetails.ui b/retroshare-gui/src/gui/TheWire/PulseDetails.ui deleted file mode 100644 index f5f7f7f31..000000000 --- a/retroshare-gui/src/gui/TheWire/PulseDetails.ui +++ /dev/null @@ -1,243 +0,0 @@ - - - PulseDetails - - - - 0 - 0 - 807 - 231 - - - - Form - - - - - - - - \/ - - - - - - - WireGroupName - - - - - - - Qt::Horizontal - - - QSizePolicy::Preferred - - - - 20 - 20 - - - - - - - - # replies - - - - - - - Qt::Horizontal - - - - 128 - 20 - - - - - - - - Summary Text - - - - - - - Qt::Horizontal - - - QSizePolicy::Preferred - - - - 20 - 20 - - - - - - - - DateTime 02/02/20 - - - - - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - - - - follow - - - - - - - reply - - - - - - - rate - - - - - - - - - - - idLabel - - - - - - - - 80 - 80 - - - - Image - - - - - - - Qt::Vertical - - - QSizePolicy::Expanding - - - - 20 - 5 - - - - - - - - - - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Preferred - - - - 30 - 0 - - - - - - - - - 0 - 0 - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - - - 75 - true - - - - Replies - - - - - - - - - - - - - GxsIdLabel - QLabel -
gui/gxs/GxsIdLabel.h
-
-
- - -
diff --git a/retroshare-gui/src/gui/TheWire/PulseItem.cpp b/retroshare-gui/src/gui/TheWire/PulseItem.cpp deleted file mode 100644 index 1e73b3364..000000000 --- a/retroshare-gui/src/gui/TheWire/PulseItem.cpp +++ /dev/null @@ -1,157 +0,0 @@ -/******************************************************************************* - * gui/TheWire/PulseItem.cpp * - * * - * Copyright (c) 2012-2020 Robert Fernie * - * * - * This program is free software: you can redistribute it and/or modify * - * it under the terms of the GNU Affero General Public License as * - * published by the Free Software Foundation, either version 3 of the * - * License, or (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU Affero General Public License for more details. * - * * - * You should have received a copy of the GNU Affero General Public License * - * along with this program. If not, see . * - * * - *******************************************************************************/ - -#include -#include -#include -#include - -#include "PulseItem.h" - -#include "PulseDetails.h" - -#include -#include - -/**** - * #define DEBUG_ITEM 1 - ****/ - -/** Constructor */ - -PulseItem::PulseItem(PulseHolder *holder, std::string path) -:QWidget(NULL), mHolder(holder), mType(0) -{ - setupUi(this); - setAttribute ( Qt::WA_DeleteOnClose, true ); - -} - -PulseItem::PulseItem(PulseHolder *holder, RsWirePulse *pulse_ptr, RsWireGroup *group_ptr, std::map replies) -:QWidget(NULL), mHolder(holder), mPulse(*pulse_ptr), mType(0) -{ - setupUi(this); - setAttribute ( Qt::WA_DeleteOnClose, true ); - QWidget *pulse_widget = widget_parent; // default msg goes into widget_parent. - - /* if it is a reply */ - if (mPulse.mPulseType & WIRE_PULSE_TYPE_REPLY_MSG) { - - std::cerr << "Installing Reply Msg"; - std::cerr << std::endl; - std::cerr << "GroupID: " << mPulse.mRefGroupId; - std::cerr << std::endl; - std::cerr << "GroupName: " << mPulse.mRefGroupName; - std::cerr << std::endl; - std::cerr << "OrigMsgId: " << mPulse.mRefOrigMsgId; - std::cerr << std::endl; - std::cerr << "AuthorId: " << mPulse.mRefAuthorId; - std::cerr << std::endl; - std::cerr << "PublishTs: " << mPulse.mRefPublishTs; - std::cerr << std::endl; - std::cerr << "PulseText: " << mPulse.mRefPulseText; - std::cerr << std::endl; - - // fill in the parent. - PulseDetails *parent = new PulseDetails( - mHolder, - mPulse.mRefGroupId, - mPulse.mRefGroupName, - mPulse.mRefOrigMsgId, - mPulse.mRefAuthorId, - mPulse.mRefPublishTs, - mPulse.mRefPulseText); - - parent->setBackground("sienna"); - - // add extra widget into layout. - QVBoxLayout *vbox = new QVBoxLayout(); - vbox->addWidget(parent); - vbox->setContentsMargins(0,0,0,0); - widget_parent->setLayout(vbox); - - // if its a reply, the real msg goes into reply slot. - pulse_widget = widget_reply; - } - else - { - // ORIGINAL PULSE. - // hide widget_reply, as it will be empty. - widget_reply->setVisible(false); - } - - { - std::cerr << "Adding Main Message"; - std::cerr << std::endl; - PulseDetails *details = new PulseDetails(mHolder, &mPulse, group_ptr->mMeta.mGroupName, replies); - - // add extra widget into layout. - QVBoxLayout *vbox = new QVBoxLayout(); - vbox->addWidget(details); - vbox->setSpacing(1); - vbox->setContentsMargins(0,0,0,0); - pulse_widget->setLayout(vbox); - pulse_widget->setVisible(true); - } -} - -rstime_t PulseItem::publishTs() -{ - return mPulse.mMeta.mPublishTs; -} - -void PulseItem::removeItem() -{ -} - -void PulseItem::setSelected(bool on) -{ -} - -bool PulseItem::isSelected() -{ - return mSelected; -} - -void PulseItem::mousePressEvent(QMouseEvent *event) -{ - /* We can be very cunning here? - * grab out position. - * flag ourselves as selected. - * then pass the mousePressEvent up for handling by the parent - */ - - QPoint pos = event->pos(); - - std::cerr << "PulseItem::mousePressEvent(" << pos.x() << ", " << pos.y() << ")"; - std::cerr << std::endl; - - setSelected(true); - - QWidget::mousePressEvent(event); - - mHolder->notifyPulseSelection(this); -} - -const QPixmap *PulseItem::getPixmap() -{ - return NULL; -} - diff --git a/retroshare-gui/src/gui/TheWire/PulseItem.ui b/retroshare-gui/src/gui/TheWire/PulseItem.ui deleted file mode 100644 index f12b3bda0..000000000 --- a/retroshare-gui/src/gui/TheWire/PulseItem.ui +++ /dev/null @@ -1,192 +0,0 @@ - - - PulseItem - - - - 0 - 0 - 802 - 322 - - - - - 0 - 0 - - - - - 9 - - - - - - - - 2 - - - 2 - - - 2 - - - 2 - - - - - - 0 - 0 - - - - - 0 - 0 - - - - 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 - - - QFrame::Raised - - - - 1 - - - 5 - - - 2 - - - 5 - - - 2 - - - - - - - - 20 - 0 - - - - - 0 - 0 - - - - QFrame::StyledPanel - - - - - - - Qt::Vertical - - - - 10 - 0 - - - - - - - - Qt::Horizontal - - - - 30 - 0 - - - - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Preferred - - - - 30 - 0 - - - - - - - - Qt::Vertical - - - - 10 - 0 - - - - - - - - - 20 - 0 - - - - - 0 - 0 - - - - QFrame::StyledPanel - - - - - - - - - - - - - - - diff --git a/retroshare-gui/src/gui/TheWire/PulseMessage.cpp b/retroshare-gui/src/gui/TheWire/PulseMessage.cpp new file mode 100644 index 000000000..91af09b3a --- /dev/null +++ b/retroshare-gui/src/gui/TheWire/PulseMessage.cpp @@ -0,0 +1,141 @@ +/******************************************************************************* + * gui/TheWire/PulseMessage.cpp * + * * + * Copyright (c) 2020-2020 Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ + +#include "PulseMessage.h" + +/** Constructor */ + +PulseMessage::PulseMessage(QWidget *parent) +:QWidget(parent) +{ + setupUi(this); +} + +void PulseMessage::setup(RsWirePulseSPtr pulse) +{ + if (!pulse) { + return; + } + + setMessage(QString::fromStdString(pulse->mPulseText)); + + // show indent if republish (both RESPONSE or REF) + bool showIndent = (pulse->mPulseType & WIRE_PULSE_TYPE_REPUBLISH); + widget_indent->setVisible(showIndent); + + // setup images. + int width = 256; + int height = 128; + bool imagesShown = false; + + if (pulse->mImage2.empty()) { + // allow wider space for image 1. + width = 512; + } + + if (!pulse->mImage1.empty()) { + // install image. + QPixmap qtn; + qtn.loadFromData(pulse->mImage1.mData, pulse->mImage1.mSize); + label_image1->setPixmap(qtn.scaled(width, height, + Qt::KeepAspectRatio, Qt::SmoothTransformation)); + imagesShown = true; + } else { + label_image1->setVisible(false); + } + + if (!pulse->mImage2.empty()) { + // install image. + QPixmap qtn; + qtn.loadFromData(pulse->mImage2.mData, pulse->mImage2.mSize); + label_image2->setPixmap(qtn.scaled(width, height, + Qt::KeepAspectRatio, Qt::SmoothTransformation)); + imagesShown = true; + } else { + label_image2->setVisible(false); + } + + width = 256; + if (pulse->mImage4.empty()) { + // allow wider space for image 3. + width = 512; + } + + if (!pulse->mImage3.empty()) { + // install image. + QPixmap qtn; + qtn.loadFromData(pulse->mImage3.mData, pulse->mImage3.mSize); + label_image3->setPixmap(qtn.scaled(width, height, + Qt::KeepAspectRatio, Qt::SmoothTransformation)); + imagesShown = true; + } else { + label_image3->setVisible(false); + } + + if (!pulse->mImage4.empty()) { + // install image. + QPixmap qtn; + qtn.loadFromData(pulse->mImage4.mData, pulse->mImage4.mSize); + label_image4->setPixmap(qtn.scaled(width, height, + Qt::KeepAspectRatio, Qt::SmoothTransformation)); + imagesShown = true; + } else { + label_image4->setVisible(false); + } + + frame_expand->setVisible(imagesShown); +} + +void PulseMessage::setMessage(QString msg) +{ + textBrowser->setPlainText(msg); +} + +void PulseMessage::setRefImageCount(uint32_t count) +{ + QString msg = "Follow to see Image"; + label_image1->setText(msg); + label_image2->setText(msg); + label_image3->setText(msg); + label_image4->setText(msg); + + label_image1->setVisible(false); + label_image2->setVisible(false); + label_image3->setVisible(false); + label_image4->setVisible(false); + + switch(count) { + case 4: + label_image4->setVisible(true); + case 3: + label_image3->setVisible(true); + case 2: + label_image2->setVisible(true); + case 1: + label_image1->setVisible(true); + default: + break; + } + + if (count < 1) { + frame_expand->setVisible(false); + } +} + diff --git a/retroshare-gui/src/gui/TheWire/PulseItem.h b/retroshare-gui/src/gui/TheWire/PulseMessage.h similarity index 57% rename from retroshare-gui/src/gui/TheWire/PulseItem.h rename to retroshare-gui/src/gui/TheWire/PulseMessage.h index 0e7395e0e..7e94a23db 100644 --- a/retroshare-gui/src/gui/TheWire/PulseItem.h +++ b/retroshare-gui/src/gui/TheWire/PulseMessage.h @@ -1,7 +1,7 @@ /******************************************************************************* - * gui/TheWire/PulseItem.h * + * gui/TheWire/PulseMessage.h * * * - * Copyright (c) 2012-2020 Robert Fernie * + * Copyright (c) 2020-2020 Robert Fernie * * * * This program is free software: you can redistribute it and/or modify * * it under the terms of the GNU Affero General Public License as * @@ -18,54 +18,23 @@ * * *******************************************************************************/ -#ifndef MRK_PULSE_ITEM_H -#define MRK_PULSE_ITEM_H +#ifndef MRK_PULSE_MSG_H +#define MRK_PULSE_MSG_H -#include "ui_PulseItem.h" +#include "ui_PulseMessage.h" #include -class PulseItem; - -class PulseHolder -{ -public: - virtual ~PulseHolder() {} - virtual void deletePulseItem(PulseItem *, uint32_t ptype) = 0; - virtual void notifyPulseSelection(PulseItem *item) = 0; - - // Actions. - virtual void follow(RsGxsGroupId &groupId) = 0; - virtual void rate(RsGxsId &authorId) = 0; - virtual void reply(RsWirePulse &pulse, std::string &groupName) = 0; -}; - - -class PulseItem : public QWidget, private Ui::PulseItem +class PulseMessage : public QWidget, private Ui::PulseMessage { Q_OBJECT public: - PulseItem(PulseHolder *holder, std::string url); - PulseItem(PulseHolder *holder, RsWirePulse *pulse_ptr, RsWireGroup *group_ptr, std::map replies); + PulseMessage(QWidget *parent); - rstime_t publishTs(); - void removeItem(); - - void setSelected(bool on); - bool isSelected(); - - const QPixmap *getPixmap(); - -protected: - void mousePressEvent(QMouseEvent *event); - -private: - - PulseHolder *mHolder; - RsWirePulse mPulse; - uint32_t mType; - bool mSelected; + void setup(RsWirePulseSPtr pulse); + void setMessage(QString msg); + void setRefImageCount(uint32_t count); }; #endif diff --git a/retroshare-gui/src/gui/TheWire/PulseMessage.ui b/retroshare-gui/src/gui/TheWire/PulseMessage.ui new file mode 100644 index 000000000..a1ce9831d --- /dev/null +++ b/retroshare-gui/src/gui/TheWire/PulseMessage.ui @@ -0,0 +1,128 @@ + + + PulseMessage + + + + 0 + 0 + 570 + 376 + + + + Form + + + + + + true + + + + + + + 20 + 0 + + + + QFrame::Plain + + + 5 + + + Qt::Vertical + + + + + + + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + 128 + 128 + + + + Image + + + Qt::AlignCenter + + + + + + + + 128 + 128 + + + + Image + + + Qt::AlignCenter + + + + + + + + 128 + 128 + + + + Image + + + Qt::AlignCenter + + + + + + + + 128 + 128 + + + + Image + + + Qt::AlignCenter + + + + + + + + + + + diff --git a/retroshare-gui/src/gui/TheWire/PulseReply.cpp b/retroshare-gui/src/gui/TheWire/PulseReply.cpp new file mode 100644 index 000000000..92dccabf5 --- /dev/null +++ b/retroshare-gui/src/gui/TheWire/PulseReply.cpp @@ -0,0 +1,155 @@ +/******************************************************************************* + * gui/TheWire/PulseReply.cpp * + * * + * Copyright (c) 2020-2020 Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ + +#include +#include +#include +#include + +#include "PulseReply.h" + +#include +#include + +/** Constructor */ + +PulseReply::PulseReply(PulseViewHolder *holder, RsWirePulseSPtr pulse) +:PulseDataItem(holder, pulse) +{ + setupUi(this); + setAttribute ( Qt::WA_DeleteOnClose, true ); + + setup(); + + if (mPulse) { + showPulse(); + } + + widget_prefix->setVisible(false); +} + +void PulseReply::setup() +{ + // connect(pushButton_tmpViewGroup, SIGNAL(clicked()), this, SLOT(actionViewGroup())); + // connect(pushButton_tmpViewParent, SIGNAL(clicked()), this, SLOT(actionViewParent())); + + connect(toolButton_follow, SIGNAL(clicked()), this, SLOT(actionFollow())); + // connect(toolButton_rate, SIGNAL(clicked()), this, SLOT(rate())); + + connect(toolButton_reply, SIGNAL(clicked()), this, SLOT(actionReply())); + connect(toolButton_republish, SIGNAL(clicked()), this, SLOT(actionRepublish())); + connect(toolButton_like, SIGNAL(clicked()), this, SLOT(actionLike())); + connect(toolButton_view, SIGNAL(clicked()), this, SLOT(actionViewPulse())); +} + +void PulseReply::showReplyLine(bool enable) +{ + line_replyLine->setVisible(enable); +} + +// PulseDataInterface =========== + // Group +void PulseReply::setHeadshot(const QPixmap &pixmap) +{ + label_headshot->setPixmap(pixmap); +} + +void PulseReply::setGroupNameString(QString name) +{ + label_groupName->setText("@" + name); +} + +void PulseReply::setAuthorString(QString name) +{ + label_authorName->setText(BoldString(name)); +} + + // Msg +void PulseReply::setRefMessage(QString msg, uint32_t image_count) +{ + widget_message->setMessage(msg); + widget_message->setRefImageCount(image_count); +} + +void PulseReply::setMessage(RsWirePulseSPtr pulse) +{ + widget_message->setup(pulse); +} + +void PulseReply::setDateString(QString date) +{ + label_date->setText(date); +} + + // Refs +void PulseReply::setLikesString(QString likes) +{ + label_likes->setText(likes); +} + +void PulseReply::setRepublishesString(QString repub) +{ + label_republishes->setText(repub); +} + +void PulseReply::setRepliesString(QString reply) +{ + label_replies->setText(reply); +} + +void PulseReply::setPulseStatus(PulseStatus status) +{ + widget_actions->setVisible(status == PulseStatus::FULL); + widget_follow->setVisible(status != PulseStatus::FULL); + toolButton_follow->setEnabled(status == PulseStatus::UNSUBSCRIBED); + + switch(status) + { + case PulseStatus::FULL: + break; + case PulseStatus::UNSUBSCRIBED: + break; + case PulseStatus::NO_GROUP: + label_follow_msg->setText("Group unavailable"); + break; + case PulseStatus::REF_MSG: + label_follow_msg->setText("Full Pulse unavailable"); + break; + } +} + +void PulseReply::setReferenceString(QString ref) +{ + if (ref.size() == 0) + { + widget_reply_header->setVisible(false); + } + else + { + label_reference->setText(ref); + } +} +// PulseDataInterface =========== + +void PulseReply::mousePressEvent(QMouseEvent *event) +{ +} + + diff --git a/retroshare-gui/src/gui/TheWire/PulseReply.h b/retroshare-gui/src/gui/TheWire/PulseReply.h new file mode 100644 index 000000000..c2c9545f5 --- /dev/null +++ b/retroshare-gui/src/gui/TheWire/PulseReply.h @@ -0,0 +1,65 @@ +/******************************************************************************* + * gui/TheWire/PulseReply.h * + * * + * Copyright (c) 2020-2020 Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ + +#ifndef MRK_PULSE_REPLY_H +#define MRK_PULSE_REPLY_H + +#include "ui_PulseReply.h" +#include "PulseViewItem.h" + +#include + +class PulseReply : public PulseDataItem, private Ui::PulseReply +{ + Q_OBJECT + +public: + PulseReply(PulseViewHolder *holder, RsWirePulseSPtr pulse); + + void showReplyLine(bool enable); + +protected: + void setup(); + +// PulseDataInterface =========== + // Group + virtual void setHeadshot(const QPixmap &pixmap) override; + virtual void setGroupNameString(QString name) override; + virtual void setAuthorString(QString name) override; + + // Msg + virtual void setRefMessage(QString msg, uint32_t image_count) override; + virtual void setMessage(RsWirePulseSPtr pulse) override; + virtual void setDateString(QString date) override; + + // Refs + virtual void setLikesString(QString likes) override; + virtual void setRepublishesString(QString repub) override; + virtual void setRepliesString(QString reply) override; + + // + virtual void setReferenceString(QString ref) override; + virtual void setPulseStatus(PulseStatus status) override; +// PulseDataInterface =========== + + void mousePressEvent(QMouseEvent *event); +}; + +#endif diff --git a/retroshare-gui/src/gui/TheWire/PulseReply.ui b/retroshare-gui/src/gui/TheWire/PulseReply.ui new file mode 100644 index 000000000..582ceb269 --- /dev/null +++ b/retroshare-gui/src/gui/TheWire/PulseReply.ui @@ -0,0 +1,616 @@ + + + PulseReply + + + + 0 + 0 + 579 + 478 + + + + + 0 + 0 + + + + + 9 + + + + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + 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 + + + QFrame::Raised + + + + + + + 0 + 0 + + + + + 0 + 40 + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 21 + 18 + + + + + + + + + 0 + 0 + + + + icn + + + + + + + retweeted + + + + + + + Qt::Horizontal + + + + 222 + 20 + + + + + + + + + + + + 0 + 0 + + + + + 0 + 40 + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + REPLY + + + + :/images/reply.png:/images/reply.png + + + Qt::ToolButtonTextBesideIcon + + + + + + + 1 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + REPUBLISH + + + + :/images/retweet.png:/images/retweet.png + + + Qt::ToolButtonTextBesideIcon + + + + + + + 1 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + LIKE + + + + :/images/like.png:/images/like.png + + + Qt::ToolButtonTextBesideIcon + + + + + + + 1 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + SHOW + + + + :/images/external-link.svg:/images/external-link.svg + + + Qt::ToolButtonTextBesideIcon + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + 0 + 0 + + + + + 0 + 40 + + + + + + + Qt::Horizontal + + + + 104 + 20 + + + + + + + + FOLLOW + + + + :/images/invite.png:/images/invite.png + + + + 16 + 16 + + + + Qt::ToolButtonTextBesideIcon + + + + + + + for response statistics + + + + + + + Qt::Horizontal + + + + 104 + 20 + + + + + + + + + + + + 0 + 0 + + + + + 0 + 40 + + + + + + + <html><head/><body><p><span style=" font-weight:600;">Sidler</span></p></body></html> + + + + + + + <html><head/><body><p><span style=" color:#555753;">@sidler_here</span></p></body></html> + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 10 + 19 + + + + + + + + <html><head/><body><p><span style=" color:#2e3436;">· Apr 13 ·</span></p></body></html> + + + + + + + Qt::Horizontal + + + + 64 + 18 + + + + + + + + + + + + + + 0 + 0 + + + + + 50 + 50 + + + + <html><head/><body><p>Head</p><p>Shot</p></body></html> + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Minimum + + + + 5 + 20 + + + + + + + + Qt::Vertical + + + + + + + + 0 + 0 + + + + + 1 + 0 + + + + + + + + Qt::Horizontal + + + QSizePolicy::Minimum + + + + 5 + 20 + + + + + + + + + + + + + 0 + 0 + + + + + 0 + 40 + + + + + + + <html><head/><body><p><span style=" color:#555753;">Replying to @sidler</span></p></body></html> + + + + + + + Qt::Horizontal + + + + 215 + 18 + + + + + + + + + + + + + + + + + + PulseMessage + QWidget +
gui/TheWire/PulseMessage.h
+ 1 +
+
+ + + + +
diff --git a/retroshare-gui/src/gui/TheWire/PulseReplySeperator.cpp b/retroshare-gui/src/gui/TheWire/PulseReplySeperator.cpp new file mode 100644 index 000000000..e9bf0d3e9 --- /dev/null +++ b/retroshare-gui/src/gui/TheWire/PulseReplySeperator.cpp @@ -0,0 +1,32 @@ +/******************************************************************************* + * gui/TheWire/PulseReplySeperator.cpp * + * * + * Copyright (c) 2020-2020 Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ + +#include "PulseReplySeperator.h" + +/** Constructor */ + +PulseReplySeperator::PulseReplySeperator() +:PulseViewItem(NULL) +{ + setupUi(this); + setAttribute ( Qt::WA_DeleteOnClose, true ); +} + + diff --git a/retroshare-gui/src/gui/TheWire/PulseReplySeperator.h b/retroshare-gui/src/gui/TheWire/PulseReplySeperator.h new file mode 100644 index 000000000..08b236a0c --- /dev/null +++ b/retroshare-gui/src/gui/TheWire/PulseReplySeperator.h @@ -0,0 +1,35 @@ +/******************************************************************************* + * gui/TheWire/PulseReplySeperator.h * + * * + * Copyright (c) 2020-2020 Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ + +#ifndef MRK_PULSE_REPLY_SEPERATOR_H +#define MRK_PULSE_REPLY_SEPERATOR_H + +#include "ui_PulseReplySeperator.h" +#include "PulseViewItem.h" + +class PulseReplySeperator : public PulseViewItem, private Ui::PulseReplySeperator +{ + Q_OBJECT + +public: + PulseReplySeperator(); +}; + +#endif diff --git a/retroshare-gui/src/gui/TheWire/PulseReplySeperator.ui b/retroshare-gui/src/gui/TheWire/PulseReplySeperator.ui new file mode 100644 index 000000000..4a605a219 --- /dev/null +++ b/retroshare-gui/src/gui/TheWire/PulseReplySeperator.ui @@ -0,0 +1,102 @@ + + + PulseReplySeperator + + + + 0 + 0 + 781 + 57 + + + + + 0 + 0 + + + + + 9 + + + + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + 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 + + + QFrame::Raised + + + 100 + + + + + + Qt::Vertical + + + + 20 + 3 + + + + + + + + + 0 + 0 + + + + + 0 + 5 + + + + 100 + + + Qt::Horizontal + + + + + + + + + + + + + diff --git a/retroshare-gui/src/gui/TheWire/PulseTopLevel.cpp b/retroshare-gui/src/gui/TheWire/PulseTopLevel.cpp new file mode 100644 index 000000000..859a4d735 --- /dev/null +++ b/retroshare-gui/src/gui/TheWire/PulseTopLevel.cpp @@ -0,0 +1,155 @@ +/******************************************************************************* + * gui/TheWire/PulseTopLevel.cpp * + * * + * Copyright (c) 2020-2020 Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ + +#include +#include +#include +#include + +#include "PulseTopLevel.h" + +#include +#include + +/** Constructor */ + +PulseTopLevel::PulseTopLevel(PulseViewHolder *holder, RsWirePulseSPtr pulse) +:PulseDataItem(holder, pulse) +{ + setupUi(this); + setAttribute ( Qt::WA_DeleteOnClose, true ); + setup(); + + if (mPulse) { + showPulse(); + } + +} + +void PulseTopLevel::setup() +{ + connect(toolButton_viewGroup, SIGNAL(clicked()), this, SLOT(actionViewGroup())); + connect(toolButton_viewParent, SIGNAL(clicked()), this, SLOT(actionViewParent())); + connect(toolButton_follow, SIGNAL(clicked()), this, SLOT(actionFollow())); + connect(toolButton_followParent, SIGNAL(clicked()), this, SLOT(actionFollowParent())); + // connect(toolButton_rate, SIGNAL(clicked()), this, SLOT(rate())); + + connect(toolButton_reply, SIGNAL(clicked()), this, SLOT(actionReply())); + connect(toolButton_republish, SIGNAL(clicked()), this, SLOT(actionRepublish())); + connect(toolButton_like, SIGNAL(clicked()), this, SLOT(actionLike())); + connect(toolButton_view, SIGNAL(clicked()), this, SLOT(actionViewPulse())); +} + +void PulseTopLevel::setRefMessage(QString msg, uint32_t image_count) +{ + // This should never happen. + //widget_message->setRefMessage(msg, image_count); +} + +void PulseTopLevel::setMessage(RsWirePulseSPtr pulse) +{ + widget_message->setup(pulse); +} + +// Set UI elements. +void PulseTopLevel::setHeadshot(const QPixmap &pixmap) +{ + label_headshot->setPixmap(pixmap); +} + +void PulseTopLevel::setGroupNameString(QString name) +{ + label_groupName->setText("@" + name); +} + +void PulseTopLevel::setAuthorString(QString name) +{ + label_authorName->setText(BoldString(name)); +} + +void PulseTopLevel::setDateString(QString date) +{ + label_date->setText(date); +} + +void PulseTopLevel::setLikesString(QString likes) +{ + label_extra_likes->setText(BoldString(likes)); + label_likes->setText(likes); +} + +void PulseTopLevel::setRepublishesString(QString repub) +{ + label_extra_republishes->setText(BoldString(repub)); + label_republishes->setText(repub); +} + +void PulseTopLevel::setRepliesString(QString reply) +{ + label_extra_replies->setText(BoldString(reply)); + label_replies->setText(reply); +} + +void PulseTopLevel::setPulseStatus(PulseStatus status) +{ + widget_replies->setVisible(true); // this is only reachable if we have ORIG so show always. + widget_actions->setVisible(status == PulseStatus::FULL); + widget_actionsFollow->setVisible(status == PulseStatus::UNSUBSCRIBED); +} + +void PulseTopLevel::setReferenceString(QString ref) +{ + if (ref.size() == 0) + { + widget_prefix->setVisible(false); + } + else + { + label_reference->setText(ref); + + // set ref icon + if (mPulse->mPulseType & WIRE_PULSE_TYPE_REPUBLISH) { + label_reficon->setPixmap(QPixmap(":/images/retweet.png")); + } else { + label_reficon->setPixmap(QPixmap(":/images/reply.png")); + } + } + + if (mPulse->mRefGroupPtr) { + if (mPulse->mRefGroupPtr->mMeta.mSubscribeFlags & + (GXS_SERV::GROUP_SUBSCRIBE_ADMIN | + GXS_SERV::GROUP_SUBSCRIBE_SUBSCRIBED)) { + toolButton_viewParent->setVisible(true); + toolButton_followParent->setVisible(false); + } else { + toolButton_viewParent->setVisible(false); + toolButton_followParent->setVisible(true); + } + } else { + toolButton_viewParent->setVisible(false); + toolButton_followParent->setVisible(false); + } +} + +void PulseTopLevel::mousePressEvent(QMouseEvent *event) +{ +} + + diff --git a/retroshare-gui/src/gui/TheWire/PulseTopLevel.h b/retroshare-gui/src/gui/TheWire/PulseTopLevel.h new file mode 100644 index 000000000..c04550023 --- /dev/null +++ b/retroshare-gui/src/gui/TheWire/PulseTopLevel.h @@ -0,0 +1,65 @@ +/******************************************************************************* + * gui/TheWire/PulseTopLevel.h * + * * + * Copyright (c) 2020-2020 Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ + +#ifndef MRK_PULSE_TOP_LEVEL_H +#define MRK_PULSE_TOP_LEVEL_H + +#include "ui_PulseTopLevel.h" + +#include "PulseViewItem.h" +#include + +class PulseTopLevel : public PulseDataItem, private Ui::PulseTopLevel +{ + Q_OBJECT + +public: + PulseTopLevel(PulseViewHolder *holder, RsWirePulseSPtr pulse); + + +protected: + void setup(); + +// PulseDataInterface =========== + // Group + virtual void setHeadshot(const QPixmap &pixmap) override; + virtual void setGroupNameString(QString name) override; + virtual void setAuthorString(QString name) override; + + // Msg + virtual void setRefMessage(QString msg, uint32_t image_count) override; + virtual void setMessage(RsWirePulseSPtr pulse) override; + virtual void setDateString(QString date) override; + + // Refs + virtual void setLikesString(QString likes) override; + virtual void setRepublishesString(QString repub) override; + virtual void setRepliesString(QString reply) override; + + // + virtual void setReferenceString(QString ref) override; + virtual void setPulseStatus(PulseStatus status) override; +// PulseDataInterface =========== + +protected: + void mousePressEvent(QMouseEvent *event); +}; + +#endif diff --git a/retroshare-gui/src/gui/TheWire/PulseTopLevel.ui b/retroshare-gui/src/gui/TheWire/PulseTopLevel.ui new file mode 100644 index 000000000..77d32218a --- /dev/null +++ b/retroshare-gui/src/gui/TheWire/PulseTopLevel.ui @@ -0,0 +1,788 @@ + + + PulseTopLevel + + + + 0 + 0 + 732 + 551 + + + + + 0 + 0 + + + + + 9 + + + + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + 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 + + + QFrame::Raised + + + + + + + 0 + 0 + + + + + 0 + 40 + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 21 + 18 + + + + + + + + + 0 + 0 + + + + + 20 + 20 + + + + + + + :/images/reply.png + + + true + + + + + + + retweeted + + + + + + + open Parent Pulse + + + SHOW PARENT + + + + :/images/external-link.svg:/images/external-link.svg + + + + 24 + 24 + + + + + + + + follow Parent Group + + + ... + + + + :/images/invite.png:/images/invite.png + + + + 24 + 24 + + + + + + + + Qt::Horizontal + + + + 537 + 20 + + + + + + + + + + + + 0 + 0 + + + + + 0 + 60 + + + + + + + Qt::Vertical + + + QSizePolicy::Minimum + + + + 20 + 10 + + + + + + + + + 0 + 0 + + + + + 0 + 20 + + + + <html><head/><body><p><span style=" color:#555753;">@sidler_here</span></p></body></html> + + + + + + + + 0 + 0 + + + + + 0 + 20 + + + + <html><head/><body><p><span style=" font-weight:600;">Sidler</span></p></body></html> + + + + + + + Qt::Horizontal + + + + 518 + 58 + + + + + + + + + 0 + 0 + + + + + 50 + 50 + + + + <html><head/><body><p>Head</p><p>Shot</p></body></html> + + + + + + + + 0 + 25 + + + + open Group + + + SHOW GROUP + + + + :/images/external-link.svg:/images/external-link.svg + + + + 24 + 24 + + + + + + + + + + + + + + + 0 + 0 + + + + + 0 + 40 + + + + + 16777215 + 16777215 + + + + + + + <html><head/><body><p><span style=" color:#2e3436;">3:58 AM · Apr 13, 2020 ·</span></p></body></html> + + + + + + + Qt::Horizontal + + + + 505 + 20 + + + + + + + + + + + Qt::Horizontal + + + + + + + + 0 + 0 + + + + + 0 + 40 + + + + + + + + + <html><head/><body><p><span style=" font-weight:600;">1.2K</span></p></body></html> + + + + + + + <html><head/><body><p><span style=" color:#2e3436;">Replies</span></p></body></html> + + + + + + + Qt::Horizontal + + + QSizePolicy::Preferred + + + + 40 + 20 + + + + + + + + + + + + <html><head/><body><p><span style=" font-weight:600;">1.2K</span></p></body></html> + + + + + + + <html><head/><body><p><span style=" color:#2e3436;">Republishes</span></p></body></html> + + + + + + + Qt::Horizontal + + + QSizePolicy::Preferred + + + + 40 + 20 + + + + + + + + + + + + <html><head/><body><p><span style=" font-weight:600;">21.3K</span></p></body></html> + + + + + + + <html><head/><body><p><span style=" color:#2e3436;">Likes</span></p></body></html> + + + + + + + Qt::Horizontal + + + QSizePolicy::Preferred + + + + 40 + 20 + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + Qt::Horizontal + + + + + + + + 0 + 0 + + + + + 0 + 40 + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + REPLY + + + + :/images/reply.png:/images/reply.png + + + Qt::ToolButtonTextBesideIcon + + + + + + + 1 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + REPUBLISH + + + + :/images/retweet.png:/images/retweet.png + + + Qt::ToolButtonTextBesideIcon + + + + + + + 1 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + LIKE + + + + :/images/like.png:/images/like.png + + + Qt::ToolButtonTextBesideIcon + + + + + + + 1 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + SHOW + + + + :/images/external-link.svg:/images/external-link.svg + + + Qt::ToolButtonTextBesideIcon + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + 0 + 0 + + + + + 0 + 40 + + + + + + + Qt::Horizontal + + + + 298 + 20 + + + + + + + + FOLLOW + + + + :/images/invite.png:/images/invite.png + + + Qt::ToolButtonTextBesideIcon + + + + + + + Qt::Horizontal + + + + 297 + 20 + + + + + + + + + + + + + + + PulseMessage + QWidget +
gui/TheWire/PulseMessage.h
+ 1 +
+
+ + + + +
diff --git a/retroshare-gui/src/gui/TheWire/PulseViewGroup.cpp b/retroshare-gui/src/gui/TheWire/PulseViewGroup.cpp new file mode 100644 index 000000000..25d393295 --- /dev/null +++ b/retroshare-gui/src/gui/TheWire/PulseViewGroup.cpp @@ -0,0 +1,108 @@ +/******************************************************************************* + * gui/TheWire/PulseViewGroup.cpp * + * * + * Copyright (c) 2012-2020 Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ + +#include +#include +#include +#include + +#include "PulseViewGroup.h" + +#include "gui/gxs/GxsIdDetails.h" +#include "util/DateTime.h" + +/** Constructor */ + +PulseViewGroup::PulseViewGroup(PulseViewHolder *holder, RsWireGroupSPtr group) +:PulseViewItem(holder), mGroup(group) +{ + setupUi(this); + setAttribute ( Qt::WA_DeleteOnClose, true ); + setup(); +} + +void PulseViewGroup::setup() +{ + if (mGroup) { + connect(toolButton_follow, SIGNAL(clicked()), this, SLOT(actionFollow())); + + label_groupName->setText("@" + QString::fromStdString(mGroup->mMeta.mGroupName)); + label_authorName->setText(BoldString(QString::fromStdString(mGroup->mMeta.mAuthorId.toStdString()))); + label_date->setText(DateTime::formatDateTime(mGroup->mMeta.mPublishTs)); + label_tagline->setText(QString::fromStdString(mGroup->mTagline)); + label_location->setText(QString::fromStdString(mGroup->mLocation)); + + // need to draw mGroup->mMasthead, as background to headshot. + // TODO frame_headerBackground->setBackground() + + if (mGroup->mHeadshot.mData) + { + QPixmap pixmap; + if (GxsIdDetails::loadPixmapFromData( + mGroup->mHeadshot.mData, + mGroup->mHeadshot.mSize, + pixmap,GxsIdDetails::ORIGINAL)) + { + pixmap = pixmap.scaled(50,50); + label_headshot->setPixmap(pixmap); + } + } + else + { + // default. + QPixmap pixmap = QPixmap(":/icons/png/posted.png").scaled(50,50); + label_headshot->setPixmap(pixmap); + } + + if (mGroup->mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_SUBSCRIBED) + { + uint32_t pulses = mGroup->mGroupPulses + mGroup->mGroupReplies; + uint32_t replies = mGroup->mRefReplies; + uint32_t republishes = mGroup->mRefRepublishes; + uint32_t likes = mGroup->mRefLikes; + + label_extra_pulses->setText(BoldString(ToNumberUnits(pulses))); + label_extra_replies->setText(BoldString(ToNumberUnits(replies))); + label_extra_republishes->setText(BoldString(ToNumberUnits(republishes))); + label_extra_likes->setText(BoldString(ToNumberUnits(likes))); + + // hide follow. + widget_actions->setVisible(false); + } + else + { + // hide stats. + widget_replies->setVisible(false); + } + } +} + +void PulseViewGroup::actionFollow() +{ + RsGxsGroupId groupId = mGroup->mMeta.mGroupId; + std::cerr << "PulseViewGroup::actionFollow() following "; + std::cerr << groupId; + std::cerr << std::endl; + + if (mHolder) { + mHolder->PVHfollow(groupId); + } +} + diff --git a/retroshare-gui/src/gui/TheWire/PulseDetails.h b/retroshare-gui/src/gui/TheWire/PulseViewGroup.h similarity index 60% rename from retroshare-gui/src/gui/TheWire/PulseDetails.h rename to retroshare-gui/src/gui/TheWire/PulseViewGroup.h index b6a623f73..4d00090ca 100644 --- a/retroshare-gui/src/gui/TheWire/PulseDetails.h +++ b/retroshare-gui/src/gui/TheWire/PulseViewGroup.h @@ -1,7 +1,7 @@ /******************************************************************************* - * gui/TheWire/PulseDetails.h * + * gui/TheWire/PulseViewGroup.h * * * - * Copyright (c) 2020 Robert Fernie * + * Copyright (c) 2020-2020 Robert Fernie * * * * This program is free software: you can redistribute it and/or modify * * it under the terms of the GNU Affero General Public License as * @@ -18,49 +18,30 @@ * * *******************************************************************************/ -#ifndef MRK_PULSE_DETAILS_H -#define MRK_PULSE_DETAILS_H +#ifndef MRK_PULSE_VIEW_GROUP_H +#define MRK_PULSE_VIEW_GROUP_H -#include "ui_PulseDetails.h" -#include "PulseItem.h" +#include "ui_PulseViewGroup.h" +#include "PulseViewItem.h" #include -class PulseDetails : public QWidget, private Ui::PulseDetails +class PulseViewGroup : public PulseViewItem, private Ui::PulseViewGroup { Q_OBJECT public: - PulseDetails(PulseHolder *actions, RsWirePulse *pulse, std::string &groupName, - std::map replies); - - // when Reply parent.... - PulseDetails(PulseHolder *actions, - RsGxsGroupId &parentGroupId, - std::string &parentGroupName, - RsGxsMessageId &parentOrigMsgId, - RsGxsId &parentAuthorId, - rstime_t &parentPublishTs, - std::string &parentPulseText); - - void setup(); - - void setBackground(QString color); + PulseViewGroup(PulseViewHolder *holder, RsWireGroupSPtr group); private slots: - void toggle(); - void follow(); - void rate(); - void reply(); + void actionFollow(); -private: - void addReplies(std::map replies); - QString getSummary(); +protected: + void setup(); - PulseHolder *mActions; - RsWirePulse mPulse; - std::string mGroupName; - bool mHasReplies; + +protected: + RsWireGroupSPtr mGroup; }; #endif diff --git a/retroshare-gui/src/gui/TheWire/PulseViewGroup.ui b/retroshare-gui/src/gui/TheWire/PulseViewGroup.ui new file mode 100644 index 000000000..7f808dd44 --- /dev/null +++ b/retroshare-gui/src/gui/TheWire/PulseViewGroup.ui @@ -0,0 +1,549 @@ + + + PulseViewGroup + + + + 0 + 0 + 745 + 483 + + + + + 0 + 0 + + + + + 9 + + + + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + 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 + + + QFrame::Raised + + + + + + + + + Qt::Horizontal + + + + 283 + 20 + + + + + + + + + 0 + 0 + + + + + 100 + 100 + + + + headshot + + + + + + + Qt::Horizontal + + + + 23 + 20 + + + + + + + + + + + + 0 + 0 + + + + + 0 + 60 + + + + + + + Qt::Horizontal + + + + 518 + 58 + + + + + + + + + 0 + 0 + + + + + 0 + 20 + + + + <html><head/><body><p><span style=" color:#555753;">@sidler_here</span></p></body></html> + + + + + + + + 0 + 0 + + + + + 0 + 20 + + + + <html><head/><body><p><span style=" font-weight:600;">Sidler</span></p></body></html> + + + + + + + Qt::Vertical + + + QSizePolicy::Minimum + + + + 20 + 10 + + + + + + + + + + + + 0 + 0 + + + + + 0 + 50 + + + + + 16777215 + 16777215 + + + + + + + + 0 + 0 + + + + + 0 + 20 + + + + <html><head/><body><p><span style=" color:#2e3436;">3:58 AM · Apr 13, 2020 ·</span></p></body></html> + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + 0 + 0 + + + + + 0 + 20 + + + + Location + + + + + + + Qt::Horizontal + + + + 2000 + 20 + + + + + + + + + 0 + 0 + + + + + 0 + 20 + + + + Tag Line + + + + + + + + + + Qt::Horizontal + + + + + + + + 0 + 0 + + + + + 0 + 40 + + + + + + + + + <html><head/><body><p><span style=" font-weight:600;">1.2K</span></p></body></html> + + + + + + + <html><head/><body><p><span style=" color:#2e3436;">Pulses</span></p></body></html> + + + + + + + Qt::Horizontal + + + QSizePolicy::Preferred + + + + 40 + 20 + + + + + + + + + + + + <html><head/><body><p><span style=" font-weight:600;">1.2K</span></p></body></html> + + + + + + + <html><head/><body><p><span style=" color:#2e3436;">Replies</span></p></body></html> + + + + + + + Qt::Horizontal + + + QSizePolicy::Preferred + + + + 40 + 20 + + + + + + + + + + + + <html><head/><body><p><span style=" font-weight:600;">1.2K</span></p></body></html> + + + + + + + <html><head/><body><p><span style=" color:#2e3436;">Republishes</span></p></body></html> + + + + + + + Qt::Horizontal + + + QSizePolicy::Preferred + + + + 40 + 20 + + + + + + + + + + + + <html><head/><body><p><span style=" font-weight:600;">21.3K</span></p></body></html> + + + + + + + <html><head/><body><p><span style=" color:#2e3436;">Likes</span></p></body></html> + + + + + + + Qt::Horizontal + + + QSizePolicy::Preferred + + + + 40 + 20 + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + Qt::Horizontal + + + + + + + + 0 + 0 + + + + + 0 + 40 + + + + + + + Qt::Horizontal + + + + 298 + 20 + + + + + + + + FOLLOW + + + + :/images/invite.png:/images/invite.png + + + Qt::ToolButtonTextBesideIcon + + + + + + + Qt::Horizontal + + + + 297 + 20 + + + + + + + + + + + + + + + + + diff --git a/retroshare-gui/src/gui/TheWire/PulseViewItem.cpp b/retroshare-gui/src/gui/TheWire/PulseViewItem.cpp new file mode 100644 index 000000000..12568dc49 --- /dev/null +++ b/retroshare-gui/src/gui/TheWire/PulseViewItem.cpp @@ -0,0 +1,464 @@ +/******************************************************************************* + * gui/TheWire/PulseViewItem.cpp * + * * + * Copyright (c) 2012-2020 Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ + +#include +#include +#include +#include + +#include "PulseViewItem.h" + +#include "gui/gxs/GxsIdDetails.h" +#include "util/DateTime.h" + +/** Constructor */ + +PulseViewItem::PulseViewItem(PulseViewHolder *holder) +:QWidget(NULL), mHolder(holder) +{ +} + + +PulseDataItem::PulseDataItem(PulseViewHolder *holder, RsWirePulseSPtr pulse) +:PulseViewItem(holder), mPulse(pulse) +{ +} + +void PulseDataItem::actionReply() +{ + std::cerr << "PulseDataItem::actionReply()"; + std::cerr << std::endl; + + if (mHolder) { + if (mPulse->mPulseType & WIRE_PULSE_TYPE_REFERENCE) { + std::cerr << "PulseDataItem::actionReply() NO ACTION FOR REF"; + std::cerr << std::endl; + return; + } + mHolder->PVHreply(mPulse->mMeta.mGroupId, mPulse->mMeta.mMsgId); + } +} + +void PulseDataItem::actionRepublish() +{ + std::cerr << "PulseDataItem::actionRepublish()"; + std::cerr << std::endl; + + if (mHolder) { + if (mPulse->mPulseType & WIRE_PULSE_TYPE_REFERENCE) { + std::cerr << "PulseDataItem::actionRepublish() NO ACTION FOR REF"; + std::cerr << std::endl; + return; + } + mHolder->PVHrepublish(mPulse->mMeta.mGroupId, mPulse->mMeta.mMsgId); + } +} + +void PulseDataItem::actionLike() +{ + std::cerr << "PulseDataItem::actionLike()"; + std::cerr << std::endl; + + if (mHolder) { + if (mPulse->mPulseType & WIRE_PULSE_TYPE_REFERENCE) { + std::cerr << "PulseDataItem::actionLike() NO ACTION FOR REF"; + std::cerr << std::endl; + return; + } + mHolder->PVHlike(mPulse->mMeta.mGroupId, mPulse->mMeta.mMsgId); + } +} + +void PulseDataItem::actionViewGroup() +{ + std::cerr << "PulseDataItem::actionViewGroup()"; + std::cerr << std::endl; + + RsGxsGroupId groupId; + + if (mPulse) { + if ((mPulse->mPulseType & WIRE_PULSE_TYPE_ORIGINAL) || + (mPulse->mPulseType & WIRE_PULSE_TYPE_RESPONSE)) + { + /* use pulse group */ + groupId = mPulse->mMeta.mGroupId; + } + else + { + /* IS REF use pulse group */ + groupId = mPulse->mRefGroupId; + } + } + + if (mHolder) { + mHolder->PVHviewGroup(groupId); + } +} + +void PulseDataItem::actionViewParent() +{ + std::cerr << "PulseDataItem::actionViewParent()"; + std::cerr << std::endl; + + // TODO + RsGxsGroupId groupId; + RsGxsMessageId msgId; + + if (mPulse) { + if (mPulse->mPulseType & WIRE_PULSE_TYPE_ORIGINAL) + { + std::cerr << "PulseDataItem::actionViewParent() Error ORIGINAL no parent"; + std::cerr << std::endl; + } + else if (mPulse->mPulseType & WIRE_PULSE_TYPE_RESPONSE) + { + /* mRefs refer to parent */ + groupId = mPulse->mRefGroupId; + msgId = mPulse->mRefOrigMsgId; + } + else + { + /* type = REF, group / thread ref to parent */ + groupId = mPulse->mMeta.mGroupId; + msgId = mPulse->mMeta.mThreadId; + } + } + + if (mHolder) { + mHolder->PVHviewPulse(groupId, msgId); + } +} + +void PulseDataItem::actionViewPulse() +{ + std::cerr << "PulseDataItem::actionViewPulse()"; + std::cerr << std::endl; + + // TODO + RsGxsGroupId groupId; + RsGxsMessageId msgId; + + if (mPulse) { + if ((mPulse->mPulseType & WIRE_PULSE_TYPE_ORIGINAL) || + (mPulse->mPulseType & WIRE_PULSE_TYPE_RESPONSE)) + { + groupId = mPulse->mMeta.mGroupId; + msgId = mPulse->mMeta.mOrigMsgId; + } + else + { + /* type = REF, mRefs link to message */ + std::cerr << "PulseDataItem::actionViewPulse() REF unlikely retrievable"; + std::cerr << std::endl; + + groupId = mPulse->mRefGroupId; + msgId = mPulse->mRefOrigMsgId; + } + } + + if (mHolder) { + mHolder->PVHviewPulse(groupId, msgId); + } +} + +void PulseDataItem::actionFollow() +{ + std::cerr << "PulseDataItem::actionFollow()"; + std::cerr << std::endl; + + RsGxsGroupId groupId; + if (mPulse->mPulseType & WIRE_PULSE_TYPE_REFERENCE) { + std::cerr << "PulseDataItem::actionFollow() REF following Replier: "; + std::cerr << mPulse->mRefGroupId; + std::cerr << std::endl; + groupId = mPulse->mRefGroupId; + } else { + std::cerr << "PulseDataItem::actionFollow() RESPONSE following Group: "; + std::cerr << mPulse->mMeta.mGroupId; + std::cerr << std::endl; + groupId = mPulse->mMeta.mGroupId; + } + + if (mHolder) { + mHolder->PVHfollow(groupId); + } +} + +void PulseDataItem::actionFollowParent() +{ + std::cerr << "PulseDataItem::actionFollowParent()"; + std::cerr << std::endl; + + RsGxsGroupId groupId; + if (mPulse->mPulseType & WIRE_PULSE_TYPE_REFERENCE) { + std::cerr << "PulseDataItem::actionFollowParent() REF following Group: "; + std::cerr << mPulse->mMeta.mGroupId; + std::cerr << std::endl; + groupId = mPulse->mMeta.mGroupId; + } else { + std::cerr << "PulseDataItem::actionFollowParent() RESPONSE following RefGroup: "; + std::cerr << mPulse->mRefGroupId; + std::cerr << std::endl; + groupId = mPulse->mRefGroupId; + } + + if (mHolder) { + mHolder->PVHfollow(groupId); + } +} + +void PulseDataItem::actionRate() +{ + std::cerr << "PulseDataItem::actionRate()"; + std::cerr << std::endl; + + // TODO + RsGxsId authorId; + + if (mHolder) { + mHolder->PVHrate(authorId); + } +} + + + +void PulseDataItem::showPulse() +{ + std::cerr << "PulseDataItem::showPulse()"; + std::cerr << std::endl; + if (!mPulse) { + std::cerr << "PulseDataItem::showPulse() PULSE invalid - skipping"; + std::cerr << std::endl; + return; + } + + /* 3 Modes: + * ORIGINAL + * RESPONSE + * REFERENCE + * + * ORIG / RESPONSE are similar. + */ + + if (mPulse->mPulseType & WIRE_PULSE_TYPE_REFERENCE) + { + + // Group + bool headshotOkay = false; + if (mPulse->mRefGroupPtr) { + if (mPulse->mRefGroupPtr->mHeadshot.mData) + { + QPixmap pixmap; + if (GxsIdDetails::loadPixmapFromData( + mPulse->mRefGroupPtr->mHeadshot.mData, + mPulse->mRefGroupPtr->mHeadshot.mSize, + pixmap,GxsIdDetails::ORIGINAL)) + { + headshotOkay = true; + pixmap = pixmap.scaled(50,50); + setHeadshot(pixmap); + } + } + } + + if (!headshotOkay) + { + // default. + QPixmap pixmap = QPixmap(":/icons/png/posted.png").scaled(50,50); + setHeadshot(pixmap); + } + + // Group + setGroupName(mPulse->mRefGroupName); + setAuthor(mPulse->mRefAuthorId.toStdString()); + + // Msg + setRefMessage(QString::fromStdString(mPulse->mRefPulseText), mPulse->mRefImageCount); + setDate(mPulse->mRefPublishTs); + + // Workout Pulse status for Stats/Follow/Msgs. + // Its a REF so cannot be FULL. + PulseStatus status = PulseStatus::REF_MSG; + if (mPulse->mRefGroupPtr) { + // bitwise comparisons. + if (mPulse->mRefGroupPtr->mMeta.mSubscribeFlags & + (GXS_SERV::GROUP_SUBSCRIBE_ADMIN | + GXS_SERV::GROUP_SUBSCRIBE_SUBSCRIBED)) { + status = PulseStatus::REF_MSG; + } else { + status = PulseStatus::UNSUBSCRIBED; + } + } else { + status = PulseStatus::NO_GROUP; + } + + setPulseStatus(status); + + if (mPulse->mGroupPtr) { + setReference(mPulse->mPulseType & WIRE_PULSE_RESPONSE_MASK, mPulse->mMeta.mGroupId, mPulse->mGroupPtr->mMeta.mGroupName); + } else { + setReference(mPulse->mPulseType & WIRE_PULSE_RESPONSE_MASK, mPulse->mMeta.mGroupId, "UNKNOWN"); + } + + } + else // ORIG / RESPONSE. + { + + // Group + bool headshotOkay = false; + if (mPulse->mGroupPtr) { + setGroupName(mPulse->mGroupPtr->mMeta.mGroupName); + + if (mPulse->mGroupPtr->mHeadshot.mData) + { + QPixmap pixmap; + if (GxsIdDetails::loadPixmapFromData( + mPulse->mGroupPtr->mHeadshot.mData, + mPulse->mGroupPtr->mHeadshot.mSize, + pixmap,GxsIdDetails::ORIGINAL)) + { + headshotOkay = true; + pixmap = pixmap.scaled(50,50); + setHeadshot(pixmap); + } + } + } else { + setGroupName("GroupName UNKNOWN"); + } + + if (!headshotOkay) + { + // default. + QPixmap pixmap = QPixmap(":/icons/png/posted.png").scaled(50,50); + setHeadshot(pixmap); // QPixmap(":/icons/png/posted.png")); + } + + setAuthor(mPulse->mMeta.mAuthorId.toStdString()); + + // Msg + setMessage(mPulse); + setDate(mPulse->mMeta.mPublishTs); + + // Possible to have ORIG and be UNSUBSCRIBED. + PulseStatus status = PulseStatus::FULL; + if (mPulse->mGroupPtr) { + // bitwise comparisons. + if (mPulse->mGroupPtr->mMeta.mSubscribeFlags & + (GXS_SERV::GROUP_SUBSCRIBE_ADMIN | + GXS_SERV::GROUP_SUBSCRIBE_SUBSCRIBED)) { + status = PulseStatus::FULL; + } else { + status = PulseStatus::UNSUBSCRIBED; + } + } + setPulseStatus(status); + setLikes(mPulse->mLikes.size()); + setReplies(mPulse->mReplies.size()); + setRepublishes(mPulse->mRepublishes.size()); + + if (mPulse->mPulseType & WIRE_PULSE_TYPE_RESPONSE) + { + setReference(mPulse->mPulseType & WIRE_PULSE_RESPONSE_MASK, mPulse->mRefGroupId, mPulse->mRefGroupName); + } + else + { + // NO Parent, so only 0 is important. + setReference(0, mPulse->mRefGroupId, mPulse->mRefGroupName); + } + } +} + +void PulseDataItem::setGroupName(std::string name) +{ + setGroupNameString(QString::fromStdString(name)); +} + +void PulseDataItem::setAuthor(std::string name) +{ + setAuthorString(QString::fromStdString(name)); +} + +void PulseDataItem::setDate(rstime_t date) +{ + // could be more intelligent. + // eg. 3 Hr ago, if recent. + setDateString(DateTime::formatDateTime(date)); +} + +void PulseDataItem::setLikes(uint32_t count) +{ + setLikesString(ToNumberUnits(count)); +} + +void PulseDataItem::setRepublishes(uint32_t count) +{ + setRepublishesString(ToNumberUnits(count)); +} + +void PulseDataItem::setReplies(uint32_t count) +{ + std::cerr << "PulseDataItem::setReplies(" << count << ")"; + std::cerr << std::endl; + setRepliesString(ToNumberUnits(count)); +} + +void PulseDataItem::setReference(uint32_t response_type, RsGxsGroupId groupId, std::string groupName) +{ + QString ref; + if (response_type == WIRE_PULSE_TYPE_REPLY) { + ref = "In reply to @" + QString::fromStdString(groupName); + } + else if (response_type == WIRE_PULSE_TYPE_REPUBLISH) { + ref = "retweeting @" + QString::fromStdString(groupName); + } + else if (response_type == WIRE_PULSE_TYPE_LIKE) { + ref = "liking @" + QString::fromStdString(groupName); + } + + setReferenceString(ref); +} + +// Utils. +QString BoldString(QString msg) +{ + QString output = "

"; + output += msg; + output += "

"; + return output; +} + +QString ToNumberUnits(uint32_t count) +{ + QString ans; + if (count > 1000000) + { + ans.sprintf("%6.2fm", count / 1000000.0); + } + else if (count > 1000) + { + ans.sprintf("%6.2fk", count / 1000.0); + } + else + { + ans.sprintf("%6d", count); + } + return ans; +} + diff --git a/retroshare-gui/src/gui/TheWire/PulseViewItem.h b/retroshare-gui/src/gui/TheWire/PulseViewItem.h new file mode 100644 index 000000000..bee96f14b --- /dev/null +++ b/retroshare-gui/src/gui/TheWire/PulseViewItem.h @@ -0,0 +1,150 @@ +/******************************************************************************* + * gui/TheWire/PulseViewItem.h * + * * + * Copyright (c) 2020-2020 Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ + +#ifndef MRK_PULSE_VIEW_ITEM_H +#define MRK_PULSE_VIEW_ITEM_H + +#include + +#include + +class PulseViewItem; + +class PulseViewHolder +{ +public: + virtual ~PulseViewHolder() {} + + // Actions. + virtual void PVHreply(const RsGxsGroupId &groupId, const RsGxsMessageId &msgId) = 0; + virtual void PVHrepublish(const RsGxsGroupId &groupId, const RsGxsMessageId &msgId) = 0; + virtual void PVHlike(const RsGxsGroupId &groupId, const RsGxsMessageId &msgId) = 0; + + virtual void PVHviewGroup(const RsGxsGroupId &groupId) = 0; + virtual void PVHviewPulse(const RsGxsGroupId &groupId, const RsGxsMessageId &msgId) = 0; + virtual void PVHviewReply(const RsGxsGroupId &groupId, const RsGxsMessageId &msgId) = 0; + + virtual void PVHfollow(const RsGxsGroupId &groupId) = 0; + virtual void PVHrate(const RsGxsId &authorId) = 0; +}; + +class PulseDataInterface +{ +public: + virtual ~PulseDataInterface() {} + + enum class PulseStatus { + FULL, // have Msg + Group: Show Stats + UNSUBSCRIBED, // Ref + unsubscribed to Group: Show Follow + NO_GROUP, // Ref Msg, unknown group: Show Missing Group. + REF_MSG // Subscribed, only Ref Msg: Show Missing Msg. + }; + +protected: + // Group + virtual void setHeadshot(const QPixmap &pixmap) = 0; + virtual void setGroupNameString(QString name) = 0; + virtual void setAuthorString(QString name) = 0; + + // Msg + virtual void setRefMessage(QString msg, uint32_t image_count) = 0; + virtual void setMessage(RsWirePulseSPtr pulse) = 0; + virtual void setDateString(QString date) = 0; + + // Refs + virtual void setLikesString(QString likes) = 0; + virtual void setRepublishesString(QString repub) = 0; + virtual void setRepliesString(QString reply) = 0; + + // + virtual void setReferenceString(QString ref) = 0; + virtual void setPulseStatus(PulseStatus status) = 0; +}; + + + +class PulseViewItem : public QWidget +{ + Q_OBJECT + +public: + PulseViewItem(PulseViewHolder *holder); + +protected: + PulseViewHolder *mHolder; +}; + + +class PulseDataItem : public PulseViewItem, public PulseDataInterface +{ + Q_OBJECT + +public: + PulseDataItem(PulseViewHolder *holder, RsWirePulseSPtr pulse); + + +private slots: + + // Action interfaces -------------------------- + void actionReply(); + void actionRepublish(); + void actionLike(); + + void actionViewGroup(); + void actionViewParent(); + void actionViewPulse(); + + void actionFollow(); + void actionFollowParent(); + void actionRate(); + // Action interfaces -------------------------- + +protected: + + // top-level set data onto UI. + virtual void showPulse(); + + // UI elements. + // Group + void setGroupName(std::string name); + void setAuthor(std::string name); + + // Msg + void setDate(rstime_t date); + + // Refs + void setLikes(uint32_t count); + void setRepublishes(uint32_t count); + void setReplies(uint32_t count); + + // + void setReference(uint32_t flags, RsGxsGroupId groupId, std::string groupName); + + // DATA. + RsWirePulseSPtr mPulse; +}; + + +// utilities. +QString BoldString(QString input); +QString ToNumberUnits(uint32_t count); + + +#endif diff --git a/retroshare-gui/src/gui/TheWire/TheWire_images.qrc b/retroshare-gui/src/gui/TheWire/TheWire_images.qrc index f6cf0b441..2c344c6bd 100644 --- a/retroshare-gui/src/gui/TheWire/TheWire_images.qrc +++ b/retroshare-gui/src/gui/TheWire/TheWire_images.qrc @@ -1,5 +1,11 @@ - - images/compose.png - + + images/compose.png + images/like.png + images/reply.png + images/retweet.png + images/link.svg + images/external-link.svg + images/invite.png + diff --git a/retroshare-gui/src/gui/TheWire/WireDialog.cpp b/retroshare-gui/src/gui/TheWire/WireDialog.cpp index 19baa25ac..06fa6ba6c 100644 --- a/retroshare-gui/src/gui/TheWire/WireDialog.cpp +++ b/retroshare-gui/src/gui/TheWire/WireDialog.cpp @@ -23,6 +23,11 @@ #include "WireGroupDialog.h" #include "WireGroupItem.h" +#include "PulseViewGroup.h" +#include "PulseReplySeperator.h" + +#include "util/qtthreadsutils.h" + #include #include @@ -56,8 +61,8 @@ WireDialog::WireDialog(QWidget *parent) ui.setupUi(this); mAddDialog = NULL; - mPulseSelected = NULL; mGroupSelected = NULL; + mHistoryIndex = -1; connect( ui.toolButton_createAccount, SIGNAL(clicked()), this, SLOT(createGroup())); connect( ui.toolButton_createPulse, SIGNAL(clicked()), this, SLOT(createPulse())); @@ -66,6 +71,11 @@ WireDialog::WireDialog(QWidget *parent) connect(ui.comboBox_groupSet, SIGNAL(currentIndexChanged(int)), this, SLOT(selectGroupSet(int))); connect(ui.comboBox_filterTime, SIGNAL(currentIndexChanged(int)), this, SLOT(selectFilterTime(int))); + connect( ui.toolButton_back, SIGNAL(clicked()), this, SLOT(back())); + connect( ui.toolButton_forward, SIGNAL(clicked()), this, SLOT(forward())); + ui.toolButton_back->setEnabled(false); + ui.toolButton_forward->setEnabled(false); + QTimer *timer = new QTimer(this); timer->connect(timer, SIGNAL(timeout()), this, SLOT(checkUpdate())); timer->start(1000); @@ -74,6 +84,9 @@ WireDialog::WireDialog(QWidget *parent) mWireQueue = new TokenQueue(rsWire->getTokenService(), this); requestGroupData(); + + // just for testing + postTestTwitterView(); } void WireDialog::refreshGroups() @@ -88,37 +101,9 @@ void WireDialog::addGroup(QWidget *item) alayout->addWidget(item); } -// PulseHolder interface. -void WireDialog::deletePulseItem(PulseItem * /* item */, uint32_t /* type */) +bool WireDialog::setupPulseAddDialog() { - return; -} - - - // Actions from PulseHolder. -void WireDialog::follow(RsGxsGroupId &groupId) -{ - std::cerr << "WireDialog::follow("; - std::cerr << groupId.toStdString(); - std::cerr << ")"; - std::cerr << std::endl; -} - -void WireDialog::rate(RsGxsId &authorId) -{ - std::cerr << "WireDialog::rate("; - std::cerr << authorId.toStdString(); - std::cerr << ")"; - std::cerr << std::endl; -} - -void WireDialog::reply(RsWirePulse &pulse, std::string &groupName) -{ - std::cerr << "WireDialog::reply("; - std::cerr << pulse.mMeta.mGroupId.toStdString(); - std::cerr << ","; - std::cerr << pulse.mMeta.mOrigMsgId.toStdString(); - std::cerr << ")"; + std::cerr << "WireDialog::setupPulseAddDialog()"; std::cerr << std::endl; if (!mAddDialog) @@ -127,39 +112,24 @@ void WireDialog::reply(RsWirePulse &pulse, std::string &groupName) mAddDialog->hide(); } + mAddDialog->cleanup(); + int idx = ui.groupChooser->currentIndex(); if (idx < 0) { - std::cerr << "WireDialog::reply() ERROR GETTING AuthorId!"; + std::cerr << "WireDialog::setupPulseAddDialog() ERROR GETTING AuthorId!"; std::cerr << std::endl; QMessageBox::warning(this, tr("RetroShare"),tr("Please create or choose Wire Groupd first"), QMessageBox::Ok, QMessageBox::Ok); - return; + return false; } // publishing group. RsWireGroup group = mOwnGroups[idx]; - mAddDialog->cleanup(); - mAddDialog->setGroup(group); + mAddDialog->setGroup(group.mMeta.mGroupId); - // establish replyTo. - mAddDialog->setReplyTo(pulse, groupName); - - mAddDialog->show(); + return true; } -void WireDialog::notifyPulseSelection(PulseItem *item) -{ - if (mPulseSelected) - { - std::cerr << "WireDialog::notifyPulseSelection() unselecting old one : " << mPulseSelected; - std::cerr << std::endl; - - mPulseSelected->setSelected(false); - } - mPulseSelected = item; -} - - void WireDialog::subscribe(RsGxsGroupId &groupId) { @@ -249,53 +219,10 @@ void WireDialog::createPulse() RsWireGroup group = mOwnGroups[idx]; mAddDialog->cleanup(); - mAddDialog->setGroup(group); + mAddDialog->setGroup(group.mMeta.mGroupId); mAddDialog->show(); } -void WireDialog::addPulse(RsWirePulse *pulse, RsWireGroup *group, - std::map replies) -{ - std::cerr << "WireDialog::addPulse() GroupId : " << pulse->mMeta.mGroupId; - std::cerr << " OrigMsgId : " << pulse->mMeta.mOrigMsgId; - std::cerr << " Replies : " << replies.size(); - std::cerr << std::endl; - - PulseItem *pulseItem = new PulseItem(this, pulse, group, replies); - - /* ensure its a boxlayout */ - QLayout *alayout = ui.scrollAreaWidgetContents->layout(); - QBoxLayout *boxlayout = dynamic_cast(alayout); - if (boxlayout == NULL) { - std::cerr << "WireDialog::addPulse() ERROR not boxlayout, inserting at end"; - std::cerr << std::endl; - alayout->addWidget(pulseItem); - return; - } - - /* iterate through layout, and insert at the correct time */ - for(int i = 0; i < alayout->count(); i++) - { - QLayoutItem *layoutItem = boxlayout->itemAt(i); - PulseItem *pitem = dynamic_cast(layoutItem->widget()); - if (pitem != NULL) - { - if (pitem->publishTs() < pulseItem->publishTs()) - { - std::cerr << "WireDialog::addPulse() Inserting at index: " << i; - std::cerr << std::endl; - /* insert at this index */ - boxlayout->insertWidget(i, pulseItem); - return; - } - } - } - // last item. - std::cerr << "WireDialog::addPulse() Inserting at end"; - std::cerr << std::endl; - boxlayout->addWidget(pulseItem); -} - void WireDialog::addGroup(const RsWireGroup &group) { std::cerr << "WireDialog::addGroup() GroupId : " << group.mMeta.mGroupId; @@ -304,37 +231,6 @@ void WireDialog::addGroup(const RsWireGroup &group) addGroup(new WireGroupItem(this, group)); } -void WireDialog::deletePulses() -{ - std::cerr << "WireDialog::deletePulses()"; - std::cerr << std::endl; - - QLayout *alayout = ui.scrollAreaWidgetContents->layout(); - QLayoutItem *item; - int i = 0; - while (i < alayout->count()) - { - item = alayout->itemAt(i); - QWidget *widget = item->widget(); - if (NULL != dynamic_cast(widget)) - { - std::cerr << "WireDialog::deletePulses() Removing Item at: " << i; - std::cerr << std::endl; - - item = alayout->takeAt(i); - delete item->widget(); - delete item; - } - else - { - std::cerr << "WireDialog::deletePulses() Leaving Item at: " << i; - std::cerr << std::endl; - - i++; - } - } -} - void WireDialog::deleteGroups() { std::cerr << "WireDialog::deleteGroups()"; @@ -415,11 +311,12 @@ void WireDialog::showSelectedGroups() ui.comboBox_filterTime->setEnabled(false); if (mGroupSelected) { - deletePulses(); // request data. std::list grpIds; grpIds.push_back(mGroupSelected->groupId()); - requestPulseData(grpIds); + + // show GroupFocus. + requestGroupFocus(mGroupSelected->groupId()); } else { @@ -431,9 +328,8 @@ void WireDialog::showGroups() { ui.comboBox_filterTime->setEnabled(false); deleteGroups(); - deletePulses(); - + std::list allGroupIds; /* depends on the comboBox */ std::map::const_iterator it; @@ -461,9 +357,11 @@ void WireDialog::showGroups() // request data. std::list grpIds; grpIds.push_back(it->second.mMeta.mGroupId); - requestPulseData(grpIds); + allGroupIds.push_back(it->second.mMeta.mGroupId); } } + + requestGroupsPulses(allGroupIds); } @@ -494,62 +392,6 @@ bool WireDialog::loadGroupData(const uint32_t &token) return true; } -void WireDialog::requestPulseData(const std::list& grpIds) -{ - std::cerr << "WireDialog::requestPulseData()"; - std::cerr << std::endl; - - RsTokReqOptions opts; - opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA; - opts.mOptions = RS_TOKREQOPT_MSG_LATEST; - uint32_t token; - mWireQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, grpIds, 0); -} - - -/* LoadPulseData... - * - * group into threads, using std::map - * then sort by publishTS, using std::map - * then add into gui. - * - use pointers to avoid copying everywhere. - * - * should we mutex Groups, or copy so we don't lose a pointer? - * should be fine, as mAllGroups only modified from loadData calls. - ****** - * - * NB: Potentially, this should be changed to use GXS to do the bulk of the work. - * - request Top-Level Msgs, sorted by PublishTS. - * - Insert into GUI. - * - for each request children Msg, and fill in "replies" - * - * This needs sorted option on GXS Data fetch. - */ - -class PulseReplySet -{ -public: - PulseReplySet() : group(NULL), msg(NULL) {} - PulseReplySet(RsWirePulse *m, RsWireGroup *g) - : group(g), msg(m) {} - - RsWireGroup *group; - RsWirePulse *msg; - std::map replies; // orig ID -> replies. -}; - -class PulseOrderedReply -{ -public: - PulseOrderedReply() : group(NULL), msg(NULL) {} - PulseOrderedReply(RsWirePulse *m, RsWireGroup *g) - : group(g), msg(m) {} - - RsWireGroup *group; - RsWirePulse *msg; - std::map replies; // publish -> replies. -}; - rstime_t WireDialog::getFilterTimestamp() { rstime_t filterTimestamp = time(NULL); @@ -573,132 +415,6 @@ rstime_t WireDialog::getFilterTimestamp() return filterTimestamp; } -bool WireDialog::loadPulseData(const uint32_t &token) -{ - std::cerr << "WireDialog::loadPulseData()"; - std::cerr << std::endl; - - std::vector pulses; - rsWire->getPulseData(token, pulses); - - std::list references; - std::map pulseGrouping; - - // setup time filtering. - uint32_t filterTimestamp; - bool filterTime = (ui.comboBox_filterTime->currentIndex() > 0); - if (filterTime) - { - filterTimestamp = getFilterTimestamp(); - } - - std::vector::iterator vit = pulses.begin(); - for(; vit != pulses.end(); vit++) - { - RsWirePulse& pulse = *vit; - if (pulse.mPulseType & WIRE_PULSE_TYPE_REPLY_REFERENCE) - { - // store references to add in later. - std::cerr << "WireDialog::loadPulseData() REF: GroupId: " << pulse.mMeta.mGroupId; - std::cerr << " PulseId: " << pulse.mMeta.mMsgId; - std::cerr << std::endl; - references.push_back(&pulse); - } - else - { - // Filter timestamp now. (as soon as possible). - if (filterTime && (pulse.mMeta.mPublishTs < filterTimestamp)) - { - std::cerr << "WireDialog::loadPulseData() SKipping OLD MSG: GroupId: " << pulse.mMeta.mGroupId; - std::cerr << " PulseId: " << pulse.mMeta.mMsgId; - std::cerr << std::endl; - continue; - } - - RsGxsGroupId &gid = pulse.mMeta.mGroupId; - std::map::iterator git = mAllGroups.find(gid); - if (git != mAllGroups.end()) - { - RsWireGroup &group = git->second; - std::cerr << "WireDialog::loadPulseData() MSG: GroupId: " << pulse.mMeta.mGroupId; - std::cerr << " PulseId: " << pulse.mMeta.mMsgId; - std::cerr << std::endl; - - // install into pulseGrouping. - pulseGrouping[pulse.mMeta.mOrigMsgId] = PulseReplySet(&pulse, &group); - } - else - { - std::cerr << "WireDialog::loadPulseData() ERROR Missing GroupId: " << pulse.mMeta.mGroupId; - std::cerr << " PulseId: " << pulse.mMeta.mMsgId; - std::cerr << std::endl; - } - } - } - - // add references. - std::list::iterator lrit; - for(lrit = references.begin(); lrit != references.end(); lrit++) - { - std::map::iterator pgit; - pgit = pulseGrouping.find((*lrit)->mMeta.mThreadId); - if (pgit != pulseGrouping.end()) - { - // install into reply map. - // TODO handle Edits / Latest MSGS. - std::map::iterator rmit; - rmit = pgit->second.replies.find((*lrit)->mMeta.mOrigMsgId); - if (rmit == pgit->second.replies.end()) - { - std::cerr << "WireDialog::loadPulseData() Installing REF: " << (*lrit)->mMeta.mOrigMsgId; - std::cerr << " to threadId: " << (*lrit)->mMeta.mThreadId; - std::cerr << std::endl; - pgit->second.replies[(*lrit)->mMeta.mOrigMsgId] = (*lrit); - } - else - { - std::cerr << "WireDialog::loadPulseData() ERROR Duplicate reply REF: " << (*lrit)->mMeta.mOrigMsgId; - std::cerr << std::endl; - } - } - else - { - // no original msg for REF. - std::cerr << "WireDialog::loadPulseData() ERROR No matching ThreadId REF: " << (*lrit)->mMeta.mThreadId; - std::cerr << std::endl; - } - } - references.clear(); - - // sort by publish time. - std::map pulseOrdering; - std::map::iterator pgit; - for(pgit = pulseGrouping.begin(); pgit != pulseGrouping.end(); pgit++) - { - - PulseOrderedReply &msg = pulseOrdering[pgit->second.msg->mMeta.mPublishTs] = - PulseOrderedReply(pgit->second.msg, pgit->second.group); - std::map::iterator rmit; - for(rmit = pgit->second.replies.begin(); - rmit != pgit->second.replies.end(); rmit++) - { - msg.replies[rmit->second->mMeta.mPublishTs] = rmit->second; - } - } - - // now add to the GUI. - std::map::reverse_iterator poit; - for (poit = pulseOrdering.rbegin(); poit != pulseOrdering.rend(); poit++) - { - // add into GUI should insert at correct time point, amongst all other ones. - addPulse(poit->second.msg, poit->second.group, poit->second.replies); - } - - // allow filterTime to be changed again - ui.comboBox_filterTime->setEnabled(true); - return true; -} - void WireDialog::acknowledgeGroup(const uint32_t &token, const uint32_t &userType) { /* reload groups */ @@ -727,9 +443,6 @@ void WireDialog::loadRequest(const TokenQueue *queue, const TokenRequest &req) case TOKENREQ_GROUPINFO: switch(req.mAnsType) { - // case RS_TOKREQ_ANSTYPE_LIST: - // loadGroupList(req.mToken); - // break; case RS_TOKREQ_ANSTYPE_DATA: loadGroupData(req.mToken); break; @@ -742,40 +455,6 @@ void WireDialog::loadRequest(const TokenQueue *queue, const TokenRequest &req) break; } break; - case TOKENREQ_MSGINFO: - switch(req.mAnsType) - { -#if 0 - case RS_TOKREQ_ANSTYPE_LIST: - loadPhotoList(req.mToken); - break; - case RS_TOKREQ_ANSTYPE_ACK: - acknowledgeMessage(req.mToken); - break; -#endif - case RS_TOKREQ_ANSTYPE_DATA: - loadPulseData(req.mToken); - break; - default: - std::cerr << "WireDialog::loadRequest() ERROR: MSG: INVALID ANS TYPE"; - std::cerr << std::endl; - break; - } - break; -#if 0 - case TOKENREQ_MSGRELATEDINFO: - switch(req.mAnsType) - { - case RS_TOKREQ_ANSTYPE_DATA: - loadPhotoData(req.mToken); - break; - default: - std::cerr << "WireDialog::loadRequest() ERROR: MSG: INVALID ANS TYPE"; - std::cerr << std::endl; - break; - } - break; -#endif default: std::cerr << "WireDialog::loadRequest() ERROR: INVALID TYPE"; std::cerr << std::endl; @@ -787,3 +466,519 @@ void WireDialog::loadRequest(const TokenQueue *queue, const TokenRequest &req) /**************************** Request / Response Filling of Data ************************/ + + + + +/****************************************************************************************/ +// TWITTER VIEW. +/****************************************************************************************/ + +// TODO +// - Handle Groups +// - Add GroupPtr to WirePulseSPtrs (DONE) +// - Add HeadShot to WireGroup +// - Add GxsIdLabel to Pulse UI elements. +// +// - Create Groups. +// - Add HeadShot +// +// - Create Pulse. +// - Add Images. +// +// - Link up Reply / Republish / Like. +// +// - showGroupFocus +// - TODO +// +// - showPulseFocus +// - Basics (DONE). +// - MoreReplies +// - Show Actual Message. + +// +// - showReplyFocus +// - TODO + + +// PulseDataItem interface +// Actions. +void WireDialog::PVHreply(const RsGxsGroupId &groupId, const RsGxsMessageId &msgId) +{ + std::cerr << "WireDialog::PVHreply() GroupId: " << groupId; + std::cerr << "MsgId: " << msgId; + std::cerr << std::endl; + + if (setupPulseAddDialog()) + { + mAddDialog->setReplyTo(groupId, msgId, WIRE_PULSE_TYPE_REPLY); + mAddDialog->show(); + } +} + +void WireDialog::PVHrepublish(const RsGxsGroupId &groupId, const RsGxsMessageId &msgId) +{ + std::cerr << "WireDialog::PVHrepublish() GroupId: " << groupId; + std::cerr << "MsgId: " << msgId; + std::cerr << std::endl; + + if (setupPulseAddDialog()) + { + mAddDialog->setReplyTo(groupId, msgId, WIRE_PULSE_TYPE_REPUBLISH); + mAddDialog->show(); + } +} + +void WireDialog::PVHlike(const RsGxsGroupId &groupId, const RsGxsMessageId &msgId) +{ + std::cerr << "WireDialog::PVHlike() GroupId: " << groupId; + std::cerr << "MsgId: " << msgId; + std::cerr << std::endl; + + if (setupPulseAddDialog()) + { + mAddDialog->setReplyTo(groupId, msgId, WIRE_PULSE_TYPE_LIKE); + mAddDialog->show(); + } +} + +void WireDialog::PVHviewGroup(const RsGxsGroupId &groupId) +{ + std::cerr << "WireDialog::PVHviewGroup("; + std::cerr << groupId.toStdString(); + std::cerr << ")"; + std::cerr << std::endl; + + requestGroupFocus(groupId); +} + +void WireDialog::PVHviewPulse(const RsGxsGroupId &groupId, const RsGxsMessageId &msgId) +{ + std::cerr << "WireDialog::PVHviewPulse("; + std::cerr << groupId.toStdString() << ","; + std::cerr << msgId.toStdString(); + std::cerr << ")"; + std::cerr << std::endl; + + requestPulseFocus(groupId, msgId); +} + +void WireDialog::PVHviewReply(const RsGxsGroupId &groupId, const RsGxsMessageId &msgId) +{ + std::cerr << "WireDialog::PVHviewReply("; + std::cerr << groupId.toStdString() << ","; + std::cerr << msgId.toStdString(); + std::cerr << ")"; + std::cerr << std::endl; + + // requestPulseFocus(groupId, msgId); +} + +void WireDialog::PVHfollow(const RsGxsGroupId &groupId) +{ + std::cerr << "WireDialog::PVHfollow("; + std::cerr << groupId.toStdString(); + std::cerr << ")"; + std::cerr << std::endl; + + uint32_t token; + rsWire->subscribeToGroup(token, groupId, true); + mWireQueue->queueRequest(token, TOKENREQ_GROUPINFO, RS_TOKREQ_ANSTYPE_ACK, WIRE_TOKEN_TYPE_SUBSCRIBE_CHANGE); +} + +void WireDialog::PVHrate(const RsGxsId &authorId) +{ + std::cerr << "WireDialog::PVHrate("; + std::cerr << authorId.toStdString(); + std::cerr << ") TODO"; + std::cerr << std::endl; +} + +void WireDialog::postTestTwitterView() +{ + clearTwitterView(); + + addTwitterView(new PulseTopLevel(NULL,RsWirePulseSPtr())); + addTwitterView(new PulseReply(NULL,RsWirePulseSPtr())); + addTwitterView(new PulseReply(NULL,RsWirePulseSPtr())); + addTwitterView(new PulseReply(NULL,RsWirePulseSPtr())); + addTwitterView(new PulseReply(NULL,RsWirePulseSPtr())); + addTwitterView(new PulseReply(NULL,RsWirePulseSPtr())); +} + +void WireDialog::clearTwitterView() +{ + std::cerr << "WireDialog::clearTwitterView()"; + std::cerr << std::endl; + + QLayout *alayout = ui.scrollAreaWidgetContents->layout(); + QLayoutItem *item; + int i = 0; + while (i < alayout->count()) + { + item = alayout->itemAt(i); + QWidget *widget = item->widget(); + if (NULL != dynamic_cast(widget)) + { + std::cerr << "WireDialog::clearTwitterView() Removing Item at: " << i; + std::cerr << std::endl; + + item = alayout->takeAt(i); + delete item->widget(); + delete item; + } + else + { + std::cerr << "WireDialog::clearTwitterView() Leaving Item at: " << i; + std::cerr << std::endl; + + i++; + } + } +} + +void WireDialog::addTwitterView(PulseViewItem *item) +{ + std::cerr << "WireDialog::addTwitterView()"; + std::cerr << std::endl; + + /* ensure its a boxlayout */ + QLayout *alayout = ui.scrollAreaWidgetContents->layout(); + QBoxLayout *boxlayout = dynamic_cast(alayout); + if (boxlayout == NULL) { + std::cerr << "WireDialog::addTwitterView() ERROR not boxlayout, not Inserting"; + std::cerr << std::endl; + return; + } + + // inserting as last item. + std::cerr << "WireDialog::addTwitterView() Inserting at end"; + std::cerr << std::endl; + boxlayout->addWidget(item); +} + +// HISTORY ------------------------------------------------------------------------------- + +void printWireViewHistory(const WireViewHistory &view) +{ + std::cerr << "WireViewHistory(" << (int) view.viewType << "): "; + switch(view.viewType) { + case WireViewType::PULSE_FOCUS: + std::cerr << " PULSE_FOCUS: grpId: " << view.groupId; + std::cerr << " msgId: " << view.msgId; + std::cerr << std::endl; + break; + case WireViewType::GROUP_FOCUS: + std::cerr << " GROUP_FOCUS: grpId: " << view.groupId; + std::cerr << std::endl; + break; + case WireViewType::GROUPS: + std::cerr << " GROUPS_PULSES: grpIds: TBD"; + std::cerr << std::endl; + break; + default: + break; + } +} + +void WireDialog::AddToHistory(const WireViewHistory &view) +{ + std::cerr << "AddToHistory():"; + printWireViewHistory(view); + + /* clear future history */ + mHistory.resize(mHistoryIndex + 1); + + mHistory.push_back(view); + mHistoryIndex = mHistory.size() - 1; + + // at end of history. + // enable back, disable forward. + ui.toolButton_back->setEnabled(mHistoryIndex > 0); + ui.toolButton_forward->setEnabled(false); +} + +void WireDialog::back() +{ + LoadHistory(mHistoryIndex-1); +} + +void WireDialog::forward() +{ + LoadHistory(mHistoryIndex+1); +} + +void WireDialog::LoadHistory(uint32_t index) +{ + if (index >= mHistory.size()) { + return; + } + + mHistoryIndex = index; + WireViewHistory view = mHistory[index]; + + std::cerr << "LoadHistory:"; + printWireViewHistory(view); + + switch(view.viewType) { + case WireViewType::PULSE_FOCUS: + showPulseFocus(view.groupId, view.msgId); + break; + case WireViewType::GROUP_FOCUS: + showGroupFocus(view.groupId); + break; + case WireViewType::GROUPS: + showGroupsPulses(view.groupIds); + break; + default: + break; + } + + ui.toolButton_back->setEnabled(index > 0); + ui.toolButton_forward->setEnabled(index + 1 < mHistory.size()); +} +// HISTORY ------------------------------------------------------------------------------- + +void WireDialog::requestPulseFocus(const RsGxsGroupId groupId, const RsGxsMessageId msgId) +{ + WireViewHistory view; + view.viewType = WireViewType::PULSE_FOCUS; + view.groupId = groupId; + view.msgId = msgId; + + AddToHistory(view); + showPulseFocus(groupId, msgId); +} + +void WireDialog::showPulseFocus(const RsGxsGroupId groupId, const RsGxsMessageId msgId) +{ + clearTwitterView(); + + // background thread for loading. + RsThread::async([this, groupId, msgId]() + { + // fetch data from backend. + RsWirePulseSPtr pPulse; + int type = 0; + bool success = rsWire->getPulseFocus(groupId, msgId, type, pPulse); + + // sleep(2); + + /* now insert the pulse + children into the layput */ + RsQThreadUtils::postToObject([pPulse,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 */ + + postPulseFocus(pPulse); + + }, this); + }); +} + + +void WireDialog::postPulseFocus(RsWirePulseSPtr pPulse) +{ + clearTwitterView(); + if (!pPulse) + { + std::cerr << "WireDialog::postPulseFocus() Invalid pulse"; + std::cerr << std::endl; + return; + } + + ui.label_viewMode->setText("Pulse Focus"); + + addTwitterView(new PulseTopLevel(this, pPulse)); + + std::list::iterator it; + for(it = pPulse->mReplies.begin(); it != pPulse->mReplies.end(); it++) + { + RsWirePulseSPtr reply = *it; + PulseReply *firstReply = new PulseReply(this, reply); + addTwitterView(firstReply); + + if (reply->mReplies.size() > 0) + { + PulseReply *secondReply = new PulseReply(this, reply->mReplies.front()); + addTwitterView(secondReply); + firstReply->showReplyLine(true); + secondReply->showReplyLine(false); + } + else + { + firstReply->showReplyLine(false); + } + + + if (reply->mReplies.size() > 1) + { + // addTwitterView(new PulseMoreReplies(NULL, reply)); + } + + addTwitterView(new PulseReplySeperator()); + } + + // Add big separator, and republishes. + if (pPulse->mReplies.size() > 0 && pPulse->mRepublishes.size() > 0) + { + addTwitterView(new PulseReplySeperator()); + addTwitterView(new PulseReplySeperator()); + } + + for(it = pPulse->mRepublishes.begin(); it != pPulse->mRepublishes.end(); it++) + { + RsWirePulseSPtr repub = *it; + + PulseReply *firstRepub = new PulseReply(this, repub); + firstRepub->showReplyLine(false); + + addTwitterView(firstRepub); + addTwitterView(new PulseReplySeperator()); + } + + +} + +void WireDialog::requestGroupFocus(const RsGxsGroupId groupId) +{ + WireViewHistory view; + view.viewType = WireViewType::GROUP_FOCUS; + view.groupId = groupId; + + AddToHistory(view); + showGroupFocus(groupId); +} + +void WireDialog::showGroupFocus(const RsGxsGroupId groupId) +{ + clearTwitterView(); + + // background thread for loading. + RsThread::async([this, groupId]() + { + // fetch data from backend. + RsWireGroupSPtr grp; + std::list pulses; + + bool success = rsWire->getWireGroup(groupId, grp); + std::list groupIds = { groupId }; + success = rsWire->getPulsesForGroups(groupIds, pulses); + + // sleep(2); + + /* now insert the pulse + children into the layput */ + RsQThreadUtils::postToObject([grp, pulses,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 */ + + postGroupFocus(grp, pulses); + + }, this); + }); +} + + +void WireDialog::postGroupFocus(RsWireGroupSPtr group, std::list pulses) +{ + std::cerr << "WireDialog::postGroupFocus()"; + std::cerr << std::endl; + + if (!group) + { + std::cerr << "WireDialog::postGroupFocus() group is INVALID"; + std::cerr << std::endl; + return; + } + + ui.label_viewMode->setText("Group Focus"); + + addTwitterView(new PulseViewGroup(this, group)); + + std::list::iterator it; + for(it = pulses.begin(); it != pulses.end(); it++) + { + RsWirePulseSPtr reply = *it; + + // don't show likes + if (reply->mPulseType & WIRE_PULSE_TYPE_LIKE) { + std::cerr << "WireDialog::postGroupFocus() Not showing LIKE"; + std::cerr << std::endl; + continue; + } + + PulseReply *firstReply = new PulseReply(this, reply); + addTwitterView(firstReply); + firstReply->showReplyLine(false); + + addTwitterView(new PulseReplySeperator()); + + } +} + +void WireDialog::requestGroupsPulses(const std::list groupIds) +{ + WireViewHistory view; + view.viewType = WireViewType::GROUPS; + view.groupIds = groupIds; + + AddToHistory(view); + showGroupsPulses(groupIds); +} + +void WireDialog::showGroupsPulses(const std::list groupIds) +{ + clearTwitterView(); + + // background thread for loading. + RsThread::async([this, groupIds]() + { + // fetch data from backend. + std::list pulses; + bool success = rsWire->getPulsesForGroups(groupIds, pulses); + + // sleep(2); + + /* now insert the pulse + children into the layput */ + RsQThreadUtils::postToObject([pulses,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 */ + + postGroupsPulses(pulses); + + }, this); + }); +} + +void WireDialog::postGroupsPulses(std::list pulses) +{ + std::cerr << "WireDialog::postGroupsPulses()"; + std::cerr << std::endl; + + ui.label_viewMode->setText("Groups Pulses"); + + std::list::iterator it; + for(it = pulses.begin(); it != pulses.end(); it++) + { + RsWirePulseSPtr reply = *it; + // don't show likes + if (reply->mPulseType & WIRE_PULSE_TYPE_LIKE) { + std::cerr << "WireDialog::postGroupsPulses() Not showing LIKE"; + std::cerr << std::endl; + continue; + } + + PulseReply *firstReply = new PulseReply(this, reply); + addTwitterView(firstReply); + firstReply->showReplyLine(false); + + addTwitterView(new PulseReplySeperator()); + + } +} + diff --git a/retroshare-gui/src/gui/TheWire/WireDialog.h b/retroshare-gui/src/gui/TheWire/WireDialog.h index 904c09ade..5a56c19ae 100644 --- a/retroshare-gui/src/gui/TheWire/WireDialog.h +++ b/retroshare-gui/src/gui/TheWire/WireDialog.h @@ -28,15 +28,47 @@ #include -#include "gui/TheWire/PulseItem.h" #include "gui/TheWire/WireGroupItem.h" #include "gui/TheWire/PulseAddDialog.h" +#include "gui/TheWire/PulseViewItem.h" +#include "gui/TheWire/PulseTopLevel.h" +#include "gui/TheWire/PulseReply.h" + + #include "util/TokenQueue.h" #define IMAGE_WIRE ":/icons/wire.png" -class WireDialog : public MainPage, public TokenResponse, public PulseHolder, public WireGroupHolder +//--------------------------- Classes for Wire View History +enum class WireViewType +{ + GROUPS, + GROUP_FOCUS, + PULSE_FOCUS, +}; + +enum class WireViewTimeRange +{ + FOREVER, + LAST_DAY, // last 24 hours. + LAST_WEEK, // actually last 7 days. + LAST_MONTH // actually last 30 days. +}; + +class WireViewHistory +{ +public: + WireViewType viewType; + WireViewTimeRange viewTimeRange; + + RsGxsGroupId groupId; + RsGxsMessageId msgId; + std::list groupIds; +}; +//--------------------------------------------------------- + +class WireDialog : public MainPage, public TokenResponse, public WireGroupHolder, public PulseViewHolder { Q_OBJECT @@ -47,19 +79,43 @@ public: virtual QString pageName() const { return tr("The Wire") ; } virtual QString helpText() const { return ""; } - // PulseHolder interface. - virtual void deletePulseItem(PulseItem *, uint32_t type); - virtual void notifyPulseSelection(PulseItem *item); - - virtual void follow(RsGxsGroupId &groupId); - virtual void rate(RsGxsId &authorId); - virtual void reply(RsWirePulse &pulse, std::string &groupName); - - // WireGroupHolder interface. - virtual void subscribe(RsGxsGroupId &groupId); - virtual void unsubscribe(RsGxsGroupId &groupId); - virtual void notifyGroupSelection(WireGroupItem *item); + virtual void subscribe(RsGxsGroupId &groupId) override; + virtual void unsubscribe(RsGxsGroupId &groupId) override; + virtual void notifyGroupSelection(WireGroupItem *item) override; + + // PulseViewItem interface + virtual void PVHreply(const RsGxsGroupId &groupId, const RsGxsMessageId &msgId) override; + virtual void PVHrepublish(const RsGxsGroupId &groupId, const RsGxsMessageId &msgId) override; + virtual void PVHlike(const RsGxsGroupId &groupId, const RsGxsMessageId &msgId) override; + + virtual void PVHviewGroup(const RsGxsGroupId &groupId) override; + virtual void PVHviewPulse(const RsGxsGroupId &groupId, const RsGxsMessageId &msgId) override; + virtual void PVHviewReply(const RsGxsGroupId &groupId, const RsGxsMessageId &msgId) override; + + virtual void PVHfollow(const RsGxsGroupId &groupId) override; + virtual void PVHrate(const RsGxsId &authorId) override; + + // New TwitterView + void postTestTwitterView(); + void clearTwitterView(); + void addTwitterView(PulseViewItem *item); + + // TwitterView History + void AddToHistory(const WireViewHistory &view); + void LoadHistory(uint32_t index); + + void requestPulseFocus(const RsGxsGroupId groupId, const RsGxsMessageId msgId); + void showPulseFocus(const RsGxsGroupId groupId, const RsGxsMessageId msgId); + void postPulseFocus(RsWirePulseSPtr pulse); + + void requestGroupFocus(const RsGxsGroupId groupId); + void showGroupFocus(const RsGxsGroupId groupId); + void postGroupFocus(RsWireGroupSPtr group, std::list pulses); + + void requestGroupsPulses(const std::list groupIds); + void showGroupsPulses(const std::list groupIds); + void postGroupsPulses(std::list pulses); private slots: @@ -70,22 +126,23 @@ private slots: void selectGroupSet(int index); void selectFilterTime(int index); + // history navigation. + void back(); + void forward(); + private: + bool setupPulseAddDialog(); + void addGroup(QWidget *item); - - void addPulse(RsWirePulse *pulse, RsWireGroup *group, - std::map replies); - void addGroup(const RsWireGroup &group); - void deletePulses(); void deleteGroups(); void showGroups(); void showSelectedGroups(); void updateGroups(std::vector &groups); - // utils. + // utils. rstime_t getFilterTimestamp(); // Loading Data. @@ -93,23 +150,20 @@ private: bool loadGroupData(const uint32_t &token); void acknowledgeGroup(const uint32_t &token, const uint32_t &userType); - void requestPulseData(const std::list& grpIds); - bool loadPulseData(const uint32_t &token); - virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req); int mGroupSet; PulseAddDialog *mAddDialog; - - PulseItem *mPulseSelected; WireGroupItem *mGroupSelected; - TokenQueue *mWireQueue; std::map mAllGroups; std::vector mOwnGroups; + int32_t mHistoryIndex; + std::vector mHistory; + /* UI - from Designer */ Ui::WireDialog ui; diff --git a/retroshare-gui/src/gui/TheWire/WireDialog.ui b/retroshare-gui/src/gui/TheWire/WireDialog.ui index eb1f91d2a..8b4f1d2a9 100644 --- a/retroshare-gui/src/gui/TheWire/WireDialog.ui +++ b/retroshare-gui/src/gui/TheWire/WireDialog.ui @@ -6,8 +6,8 @@ 0 0 - 726 - 557 + 804 + 586
@@ -192,7 +192,7 @@ 0 0 228 - 421 + 442 @@ -215,118 +215,24 @@ - + 3 0 - - QFrame::StyledPanel + + 0 - - QFrame::Raised - - - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - Show Posts from - - - - - - - - 0 - 0 - - - - - All Time - - - - - Last 24 hours - - - - - Last 7 days - - - - - Last 30 days - - - - - - - - - - - true - - - Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft - - - - - 0 - 0 - 431 - 443 - - - - QWidget#scrollAreaWidgetContents{border: none;} - - + + + HomePage + + + + + 0 @@ -343,23 +249,156 @@ 0 - + + + < + + + + + + + > + + + + + - Qt::Vertical + Qt::Horizontal + + + QSizePolicy::Preferred - 20 - 40 + 10 + 20 + + + + Most Recent + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + Show Posts from + + + + + + + + 0 + 0 + + + + + All Time + + + + + Last 24 hours + + + + + Last 7 days + + + + + Last 30 days + + + + - - - + + + + + true + + + Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft + + + + + 0 + 0 + 508 + 435 + + + + QWidget#scrollAreaWidgetContents{border: none;} + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + diff --git a/retroshare-gui/src/gui/TheWire/WireGroupDialog.cpp b/retroshare-gui/src/gui/TheWire/WireGroupDialog.cpp index 80d51f167..210a05b92 100644 --- a/retroshare-gui/src/gui/TheWire/WireGroupDialog.cpp +++ b/retroshare-gui/src/gui/TheWire/WireGroupDialog.cpp @@ -19,6 +19,8 @@ *******************************************************************************/ #include +#include "WireGroupExtra.h" + #include "WireGroupDialog.h" #include "gui/gxs/GxsIdDetails.h" @@ -27,7 +29,7 @@ const uint32_t WireCreateEnabledFlags = ( GXS_GROUP_FLAGS_NAME | GXS_GROUP_FLAGS_ICON | - GXS_GROUP_FLAGS_DESCRIPTION | + // GXS_GROUP_FLAGS_DESCRIPTION | GXS_GROUP_FLAGS_DISTRIBUTION | // GXS_GROUP_FLAGS_PUBLISHSIGN | // GXS_GROUP_FLAGS_SHAREKEYS | // disabled because the UI doesn't handle it yet. @@ -85,6 +87,9 @@ void WireGroupDialog::initUi() setUiText(UITYPE_ADD_ADMINS_CHECKBOX, tr("Add Wire Admins")); setUiText(UITYPE_CONTACTS_DOCK, tr("Select Wire Admins")); + + mExtra = new WireGroupExtra(this); + injectExtraWidget(mExtra); } QPixmap WireGroupDialog::serviceImage() @@ -95,9 +100,6 @@ QPixmap WireGroupDialog::serviceImage() void WireGroupDialog::prepareWireGroup(RsWireGroup &group, const RsGroupMetaData &meta) { group.mMeta = meta; - group.mDescription = getDescription().toUtf8().constData(); - -#if 0 QPixmap pixmap = getLogo(); if (!pixmap.isNull()) { @@ -107,12 +109,27 @@ void WireGroupDialog::prepareWireGroup(RsWireGroup &group, const RsGroupMetaData buffer.open(QIODevice::WriteOnly); pixmap.save(&buffer, "PNG"); // writes image into ba in PNG format - group.mThumbnail.copy((uint8_t *) ba.data(), ba.size()); + group.mHeadshot.copy((uint8_t *) ba.data(), ba.size()); } else { - group.mThumbnail.clear(); + group.mHeadshot.clear(); } -#endif + // from Extra Widget. + group.mTagline = mExtra->getTagline(); + group.mLocation = mExtra->getLocation(); + pixmap = mExtra->getMasthead(); + + if (!pixmap.isNull()) { + QByteArray ba; + QBuffer buffer(&ba); + + buffer.open(QIODevice::WriteOnly); + pixmap.save(&buffer, "JPG"); + + group.mMasthead.copy((uint8_t *) ba.data(), ba.size()); + } else { + group.mMasthead.clear(); + } } bool WireGroupDialog::service_createGroup(RsGroupMetaData &meta) @@ -152,7 +169,7 @@ bool WireGroupDialog::service_loadGroup(const RsGxsGenericGroupData *data, Mode } const RsWireGroup &group = *pgroup; - description = QString::fromUtf8(group.mDescription.c_str()); + // description = QString::fromUtf8(group.mDescription.c_str()); #if 0 if (group.mThumbnail.mData) { diff --git a/retroshare-gui/src/gui/TheWire/WireGroupDialog.h b/retroshare-gui/src/gui/TheWire/WireGroupDialog.h index b34d2d0dc..ca3f59e73 100644 --- a/retroshare-gui/src/gui/TheWire/WireGroupDialog.h +++ b/retroshare-gui/src/gui/TheWire/WireGroupDialog.h @@ -22,8 +22,11 @@ #define _WIRE_GROUP_DIALOG_H #include "gui/gxs/GxsGroupDialog.h" + #include +class WireGroupExtra; + class WireGroupDialog : public GxsGroupDialog { Q_OBJECT @@ -42,6 +45,8 @@ protected: private: void prepareWireGroup(RsWireGroup &group, const RsGroupMetaData &meta); + + WireGroupExtra *mExtra; }; #endif diff --git a/retroshare-gui/src/gui/TheWire/WireGroupExtra.cpp b/retroshare-gui/src/gui/TheWire/WireGroupExtra.cpp new file mode 100644 index 000000000..b6a1c5440 --- /dev/null +++ b/retroshare-gui/src/gui/TheWire/WireGroupExtra.cpp @@ -0,0 +1,83 @@ +/******************************************************************************* + * retroshare-gui/src/gui/TheWire/WireGroupExtra.cpp * + * * + * Copyright (C) 2020 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ + +#include "WireGroupExtra.h" +#include "util/misc.h" + +WireGroupExtra::WireGroupExtra(QWidget *parent) : + QWidget(NULL) +{ + ui.setupUi(this); + setUp(); +} + +WireGroupExtra::~WireGroupExtra() +{ +} + +void WireGroupExtra::setUp() +{ + connect(ui.pushButton_masthead, SIGNAL(clicked() ), this , SLOT(addMasthead())); +} + + +void WireGroupExtra::addMasthead() +{ + QPixmap img = misc::getOpenThumbnailedPicture(this, tr("Load Masthead"), 400, 100); + + if (img.isNull()) + return; + + setMasthead(img); +} + + +void WireGroupExtra::setTagline(const std::string &str) +{ + ui.lineEdit_Tagline->setText(QString::fromStdString(str)); +} + +void WireGroupExtra::setLocation(const std::string &str) +{ + ui.lineEdit_Location->setText(QString::fromStdString(str)); +} + +void WireGroupExtra::setMasthead(const QPixmap &pixmap) +{ + mMasthead = pixmap; + ui.label_masthead->setPixmap(mMasthead); +} + +std::string WireGroupExtra::getTagline() +{ + return ui.lineEdit_Tagline->text().toStdString(); +} + +std::string WireGroupExtra::getLocation() +{ + return ui.lineEdit_Location->text().toStdString(); +} + +QPixmap WireGroupExtra::getMasthead() +{ + return mMasthead; +} + + diff --git a/retroshare-gui/src/gui/TheWire/WireGroupExtra.h b/retroshare-gui/src/gui/TheWire/WireGroupExtra.h new file mode 100644 index 000000000..ce606feb3 --- /dev/null +++ b/retroshare-gui/src/gui/TheWire/WireGroupExtra.h @@ -0,0 +1,54 @@ +/******************************************************************************* + * retroshare-gui/src/gui/TheWire/WireGroupExtra.h * + * * + * Copyright (C) 2020 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ + +#ifndef WIRE_GROUP_EXTRA_H +#define WIRE_GROUP_EXTRA_H + +#include +#include "ui_WireGroupExtra.h" + +class WireGroupExtra : public QWidget +{ + Q_OBJECT + +public: + explicit WireGroupExtra(QWidget *parent = 0); + virtual ~WireGroupExtra(); + + void setMasthead(const QPixmap &pixmap); + QPixmap getMasthead(); + + void setTagline(const std::string &str); + void setLocation(const std::string &str); + + std::string getTagline(); + std::string getLocation(); + +private slots: + void addMasthead(); + +private: + void setUp(); +private: + QPixmap mMasthead; + Ui::WireGroupExtra ui; +}; + +#endif // WIRE_GROUP_EXTRA_H diff --git a/retroshare-gui/src/gui/TheWire/WireGroupExtra.ui b/retroshare-gui/src/gui/TheWire/WireGroupExtra.ui new file mode 100644 index 000000000..fb1da5e73 --- /dev/null +++ b/retroshare-gui/src/gui/TheWire/WireGroupExtra.ui @@ -0,0 +1,68 @@ + + + WireGroupExtra + + + + 0 + 0 + 516 + 199 + + + + + 0 + 0 + + + + Form + + + + + + Masthead + + + + + + + MastHead background Image + + + + + + + Select Image + + + + + + + Tagline: + + + + + + + + + + Location: + + + + + + + + + + + diff --git a/retroshare-gui/src/gui/TheWire/WireGroupItem.cpp b/retroshare-gui/src/gui/TheWire/WireGroupItem.cpp index c3843c497..5c7a00fea 100644 --- a/retroshare-gui/src/gui/TheWire/WireGroupItem.cpp +++ b/retroshare-gui/src/gui/TheWire/WireGroupItem.cpp @@ -51,6 +51,25 @@ void WireGroupItem::setup() label_authorId->setId(mGroup.mMeta.mAuthorId); frame_details->setVisible(false); + if (mGroup.mHeadshot.mData ) + { + QPixmap pixmap; + if (GxsIdDetails::loadPixmapFromData( + mGroup.mHeadshot.mData, + mGroup.mHeadshot.mSize, + pixmap,GxsIdDetails::ORIGINAL)) + { + pixmap = pixmap.scaled(32,32); + label_headshot->setPixmap(pixmap); + } + } + else + { + // default. + QPixmap pixmap = QPixmap(":/icons/wire.png").scaled(32,32); + label_headshot->setPixmap(pixmap); + } + RsIdentityDetails idDetails ; rsIdentity->getIdDetails(mGroup.mMeta.mAuthorId,idDetails); @@ -59,6 +78,7 @@ void WireGroupItem::setup() if(idDetails.mAvatar.mSize == 0 || !GxsIdDetails::loadPixmapFromData(idDetails.mAvatar.mData, idDetails.mAvatar.mSize, pixmap,GxsIdDetails::SMALL)) pixmap = GxsIdDetails::makeDefaultIcon(mGroup.mMeta.mAuthorId,GxsIdDetails::SMALL); + pixmap = pixmap.scaled(24,24); label_avatar->setPixmap(pixmap); connect(toolButton_show, SIGNAL(clicked()), this, SLOT(show())); diff --git a/retroshare-gui/src/gui/TheWire/WireGroupItem.ui b/retroshare-gui/src/gui/TheWire/WireGroupItem.ui index b0d53f4c6..eeb793614 100644 --- a/retroshare-gui/src/gui/TheWire/WireGroupItem.ui +++ b/retroshare-gui/src/gui/TheWire/WireGroupItem.ui @@ -38,7 +38,7 @@ - + 32 @@ -102,6 +102,13 @@ QFrame::Raised + + + + Avatar + + + diff --git a/retroshare-gui/src/gui/TheWire/images/external-link.svg b/retroshare-gui/src/gui/TheWire/images/external-link.svg new file mode 100644 index 000000000..d3a249f34 --- /dev/null +++ b/retroshare-gui/src/gui/TheWire/images/external-link.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/retroshare-gui/src/gui/TheWire/images/invite.png b/retroshare-gui/src/gui/TheWire/images/invite.png new file mode 100644 index 000000000..5fda4753e Binary files /dev/null and b/retroshare-gui/src/gui/TheWire/images/invite.png differ diff --git a/retroshare-gui/src/gui/TheWire/images/like.png b/retroshare-gui/src/gui/TheWire/images/like.png new file mode 100644 index 000000000..cd0cd99ef Binary files /dev/null and b/retroshare-gui/src/gui/TheWire/images/like.png differ diff --git a/retroshare-gui/src/gui/TheWire/images/link.svg b/retroshare-gui/src/gui/TheWire/images/link.svg new file mode 100644 index 000000000..fdee24b3c --- /dev/null +++ b/retroshare-gui/src/gui/TheWire/images/link.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/retroshare-gui/src/gui/TheWire/images/reply.png b/retroshare-gui/src/gui/TheWire/images/reply.png new file mode 100644 index 000000000..c2f5fdf62 Binary files /dev/null and b/retroshare-gui/src/gui/TheWire/images/reply.png differ diff --git a/retroshare-gui/src/gui/TheWire/images/retweet.png b/retroshare-gui/src/gui/TheWire/images/retweet.png new file mode 100644 index 000000000..e5272b6ba Binary files /dev/null and b/retroshare-gui/src/gui/TheWire/images/retweet.png differ diff --git a/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp b/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp index b45c448fe..bfd2ad379 100644 --- a/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp +++ b/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp @@ -92,11 +92,11 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::Wi QHeaderView_setSectionResizeModeColumn(header, COLUMN_NAME, QHeaderView::Stretch); muteAct = new QAction(QIcon(), tr("Mute participant"), this); - voteNegativeAct = new QAction(QIcon(":/icons/png/thumbs-down.png"), tr("Ban this person (Sets negative opinion)"), this); - voteNeutralAct = new QAction(QIcon(":/icons/png/thumbs-neutral.png"), tr("Give neutral opinion"), this); - votePositiveAct = new QAction(QIcon(":/icons/png/thumbs-up.png"), tr("Give positive opinion"), this); - distantChatAct = new QAction(QIcon(":/icons/png/chats.png"), tr("Start private chat"), this); - sendMessageAct = new QAction(QIcon(":/icons/mail/write-mail.png"), tr("Send Message"), this); + voteNegativeAct = new QAction(FilesDefs::getIconFromQtResourcePath(":/icons/png/thumbs-down.png"), tr("Ban this person (Sets negative opinion)"), this); + voteNeutralAct = new QAction(FilesDefs::getIconFromQtResourcePath(":/icons/png/thumbs-neutral.png"), tr("Give neutral opinion"), this); + votePositiveAct = new QAction(FilesDefs::getIconFromQtResourcePath(":/icons/png/thumbs-up.png"), tr("Give positive opinion"), this); + distantChatAct = new QAction(FilesDefs::getIconFromQtResourcePath(":/icons/png/chats.png"), tr("Start private chat"), this); + sendMessageAct = new QAction(FilesDefs::getIconFromQtResourcePath(":/icons/mail/write-mail.png"), tr("Send Message"), this); showInPeopleAct = new QAction(QIcon(), tr("Show author in people tab"), this); QActionGroup *sortgrp = new QActionGroup(this); diff --git a/retroshare-gui/src/gui/chat/ChatLobbyUserNotify.cpp b/retroshare-gui/src/gui/chat/ChatLobbyUserNotify.cpp index 81cb47846..64798a011 100644 --- a/retroshare-gui/src/gui/chat/ChatLobbyUserNotify.cpp +++ b/retroshare-gui/src/gui/chat/ChatLobbyUserNotify.cpp @@ -23,6 +23,7 @@ #include #include +#include "gui/common/FilesDefs.h" #include "ChatLobbyUserNotify.h" #include "gui/ChatLobbyWidget.h" @@ -104,12 +105,12 @@ void ChatLobbyUserNotify::setTextCaseSensitive(bool value) QIcon ChatLobbyUserNotify::getIcon() { - return QIcon(":/icons/png/chat-lobbies.png"); + return FilesDefs::getIconFromQtResourcePath(":/icons/png/chat-lobbies.png"); } QIcon ChatLobbyUserNotify::getMainIcon(bool hasNew) { - return hasNew ? QIcon(":/icons/png/chat-lobbies-notify.png") : QIcon(":/icons/png/chat-lobbies.png"); + return hasNew ? FilesDefs::getIconFromQtResourcePath(":/icons/png/chat-lobbies-notify.png") : FilesDefs::getIconFromQtResourcePath(":/icons/png/chat-lobbies.png"); } unsigned int ChatLobbyUserNotify::getNewCount() @@ -164,7 +165,7 @@ void ChatLobbyUserNotify::iconClicked() ChatLobbyInfo clInfo; if (rsMsgs->getChatLobbyInfo(clId,clInfo)) strLobbyName=QString::fromUtf8(clInfo.lobby_name.c_str()) ; - icoLobby=(clInfo.lobby_flags & RS_CHAT_LOBBY_FLAGS_PUBLIC) ? QIcon(":/images/chat_red24.png") : QIcon(":/images/chat_x24.png"); + icoLobby=(clInfo.lobby_flags & RS_CHAT_LOBBY_FLAGS_PUBLIC) ? FilesDefs::getIconFromQtResourcePath(":/images/chat_red24.png") : FilesDefs::getIconFromQtResourcePath(":/images/chat_x24.png"); bFound=true; break; } diff --git a/retroshare-gui/src/gui/chat/ChatTabWidget.cpp b/retroshare-gui/src/gui/chat/ChatTabWidget.cpp index ad15fb905..03357a3e4 100644 --- a/retroshare-gui/src/gui/chat/ChatTabWidget.cpp +++ b/retroshare-gui/src/gui/chat/ChatTabWidget.cpp @@ -22,6 +22,7 @@ #include +#include "gui/common/FilesDefs.h" #include "ChatTabWidget.h" #include "ui_ChatTabWidget.h" #include "ChatDialog.h" @@ -102,9 +103,9 @@ void ChatTabWidget::tabInfoChanged(ChatDialog *dialog) if (tab >= 0) { if (dialog->isTyping()) { setBlinking(tab, false); - setTabIcon(tab, QIcon(IMAGE_TYPING)); + setTabIcon(tab, FilesDefs::getIconFromQtResourcePath(IMAGE_TYPING)); } else if (dialog->hasNewMessages()) { - setTabIcon(tab, QIcon(IMAGE_CHAT)); + setTabIcon(tab, FilesDefs::getIconFromQtResourcePath(IMAGE_CHAT)); if (dialog->notifyBlink()) { setBlinking(tab, true); } else { @@ -148,9 +149,9 @@ void ChatTabWidget::getInfo(bool &isTyping, bool &hasNewMessage, QIcon *icon) if (icon) { if (isTyping) { - *icon = QIcon(IMAGE_TYPING); + *icon = FilesDefs::getIconFromQtResourcePath(IMAGE_TYPING); } else if (hasNewMessage) { - *icon = QIcon(IMAGE_CHAT); + *icon = FilesDefs::getIconFromQtResourcePath(IMAGE_CHAT); } else { cd = dynamic_cast(currentWidget()); if (cd && cd->hasPeerStatus()) { diff --git a/retroshare-gui/src/gui/chat/ChatUserNotify.cpp b/retroshare-gui/src/gui/chat/ChatUserNotify.cpp index ecb563938..2e9fb2d1a 100644 --- a/retroshare-gui/src/gui/chat/ChatUserNotify.cpp +++ b/retroshare-gui/src/gui/chat/ChatUserNotify.cpp @@ -20,6 +20,7 @@ * * *******************************************************************************/ +#include "gui/common/FilesDefs.h" #include "ChatUserNotify.h" #include "gui/notifyqt.h" #include "gui/MainWindow.h" @@ -75,12 +76,12 @@ bool ChatUserNotify::hasSetting(QString *name, QString *group) QIcon ChatUserNotify::getIcon() { - return QIcon(":/images/chat.png"); + return FilesDefs::getIconFromQtResourcePath(":/images/chat.png"); } QIcon ChatUserNotify::getMainIcon(bool hasNew) { - return hasNew ? QIcon(":/icons/png/network-notify.png") : QIcon(":/icons/png/network.png"); + return hasNew ? FilesDefs::getIconFromQtResourcePath(":/icons/png/network-notify.png") : FilesDefs::getIconFromQtResourcePath(":/icons/png/network.png"); } unsigned int ChatUserNotify::getNewCount() diff --git a/retroshare-gui/src/gui/chat/ChatWidget.cpp b/retroshare-gui/src/gui/chat/ChatWidget.cpp index 6c36a392b..5506dedfb 100644 --- a/retroshare-gui/src/gui/chat/ChatWidget.cpp +++ b/retroshare-gui/src/gui/chat/ChatWidget.cpp @@ -245,7 +245,7 @@ ChatWidget::ChatWidget(QWidget *parent) //#ifdef ENABLE_DISTANT_CHAT_AND_MSGS // contextMnu->addSeparator(); -// QAction *action = new QAction(QIcon(":/images/pasterslink.png"), tr("Paste/Create private chat or Message link..."), this); +// QAction *action = new QAction(FilesDefs::getIconFromQtResourcePath(":/images/pasterslink.png"), tr("Paste/Create private chat or Message link..."), this); // connect(action, SIGNAL(triggered()), this, SLOT(pasteCreateMsgLink())); // ui->chatTextEdit->addContextMenuAction(action); //#endif @@ -1067,7 +1067,7 @@ void ChatWidget::addChatMsg(bool incoming, const QString &name, const RsGxsId gx rsIdentity->getIdDetails(gxsId, details); bool isUnsigned = !(details.mFlags & RS_IDENTITY_FLAGS_PGP_LINKED); if(isUnsigned && ui->textBrowser->getShowImages()) { - QIcon icon = QIcon(":/icons/anonymous_blue_128.png"); + QIcon icon = FilesDefs::getIconFromQtResourcePath(":/icons/anonymous_blue_128.png"); int height = ui->textBrowser->fontMetrics().height()*0.8; QImage image(icon.pixmap(height,height).toImage()); QByteArray byteArray; diff --git a/retroshare-gui/src/gui/chat/PopupChatDialog.cpp b/retroshare-gui/src/gui/chat/PopupChatDialog.cpp index 1591669f4..9cb422a8f 100644 --- a/retroshare-gui/src/gui/chat/PopupChatDialog.cpp +++ b/retroshare-gui/src/gui/chat/PopupChatDialog.cpp @@ -23,6 +23,7 @@ #include "PopupChatDialog.h" #include "PopupChatWindow.h" +#include "gui/common/FilesDefs.h" #include "gui/settings/rsharesettings.h" #include "gui/settings/RsharePeerSettings.h" #include "gui/notifyqt.h" @@ -149,10 +150,10 @@ void PopupChatDialog::showAvatarFrame(bool show) if (show) { ui.avatarFrameButton->setToolTip(tr("Hide Avatar")); - ui.avatarFrameButton->setIcon(QIcon(":images/hide_toolbox_frame.png")); + ui.avatarFrameButton->setIcon(FilesDefs::getIconFromQtResourcePath(":images/hide_toolbox_frame.png")); } else { ui.avatarFrameButton->setToolTip(tr("Show Avatar")); - ui.avatarFrameButton->setIcon(QIcon(":images/show_toolbox_frame.png")); + ui.avatarFrameButton->setIcon(FilesDefs::getIconFromQtResourcePath(":images/show_toolbox_frame.png")); } PeerSettings->setShowAvatarFrame(mChatId, show); diff --git a/retroshare-gui/src/gui/chat/PopupChatWindow.cpp b/retroshare-gui/src/gui/chat/PopupChatWindow.cpp index 6d6502c5f..6c1f9128d 100644 --- a/retroshare-gui/src/gui/chat/PopupChatWindow.cpp +++ b/retroshare-gui/src/gui/chat/PopupChatWindow.cpp @@ -24,6 +24,7 @@ #include #include +#include "gui/common/FilesDefs.h" #include "PopupChatWindow.h" #include "ChatDialog.h" #include "gui/settings/rsharesettings.h" @@ -113,14 +114,14 @@ PopupChatWindow::PopupChatWindow(bool tabbed, QWidget *parent, Qt::WindowFlags f void PopupChatWindow::showContextMenu(QPoint) { QMenu contextMnu(this); - contextMnu.addAction(QIcon(":/images/highlight.png"),tr("Choose window color..."),this,SLOT(setStyle())); + contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(":/images/highlight.png"),tr("Choose window color..."),this,SLOT(setStyle())); if (Settings->getChatFlags() & RS_CHAT_TABBED_WINDOW) { if(tabbedWindow) - contextMnu.addAction(QIcon(":/images/tab-dock.png"),tr("Dock window"),this,SLOT(docTab())); + contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(":/images/tab-dock.png"),tr("Dock window"),this,SLOT(docTab())); - contextMnu.addAction(QIcon(":/images/tab-undock.png"),tr("Dock window"),this,SLOT(undockTab())); + contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(":/images/tab-undock.png"),tr("Dock window"),this,SLOT(undockTab())); } contextMnu.exec(QCursor::pos()); } @@ -295,9 +296,9 @@ void PopupChatWindow::calculateTitle(ChatDialog *dialog) QIcon icon; if (isTyping) { mBlinkIcon = QIcon(); - icon = QIcon(IMAGE_TYPING); + icon = FilesDefs::getIconFromQtResourcePath(IMAGE_TYPING); } else if (hasNewMessages) { - icon = QIcon(IMAGE_CHAT); + icon = FilesDefs::getIconFromQtResourcePath(IMAGE_CHAT); if (Settings->getChatFlags() & RS_CHAT_BLINK) { mBlinkIcon = icon; } else { diff --git a/retroshare-gui/src/gui/chat/PopupDistantChatDialog.cpp b/retroshare-gui/src/gui/chat/PopupDistantChatDialog.cpp index b93c2d438..f78b5cc30 100644 --- a/retroshare-gui/src/gui/chat/PopupDistantChatDialog.cpp +++ b/retroshare-gui/src/gui/chat/PopupDistantChatDialog.cpp @@ -26,11 +26,13 @@ #include +#include "gui/common/FilesDefs.h" #include #include #include -#include "RsAutoUpdatePage.h" +#include + #include "PopupDistantChatDialog.h" #define IMAGE_RED_LED ":/icons/bullet_red_128.png" @@ -112,7 +114,7 @@ void PopupDistantChatDialog::updateDisplay() { case RS_DISTANT_CHAT_STATUS_UNKNOWN: - _status_label->setIcon(QIcon(IMAGE_GRY_LED)); + _status_label->setIcon(FilesDefs::getIconFromQtResourcePath(IMAGE_GRY_LED)); msg = tr("Remote status unknown."); _status_label->setToolTip(msg); getChatWidget()->updateStatusString("%1", msg, true); @@ -123,7 +125,7 @@ void PopupDistantChatDialog::updateDisplay() break ; case RS_DISTANT_CHAT_STATUS_REMOTELY_CLOSED: std::cerr << "Chat remotely closed. " << std::endl; - _status_label->setIcon(QIcon(IMAGE_RED_LED)); + _status_label->setIcon(FilesDefs::getIconFromQtResourcePath(IMAGE_RED_LED)); _status_label->setToolTip( QObject::tr("Distant peer has closed the chat") ); getChatWidget()->updateStatusString("%1", tr( "Your partner closed the conversation." ), true ); @@ -134,7 +136,7 @@ void PopupDistantChatDialog::updateDisplay() case RS_DISTANT_CHAT_STATUS_TUNNEL_DN: - _status_label->setIcon(QIcon(IMAGE_YEL_LED)); + _status_label->setIcon(FilesDefs::getIconFromQtResourcePath(IMAGE_YEL_LED)); msg = QObject::tr( "Tunnel is pending"); if(tinfo.pending_items > 0) @@ -147,7 +149,7 @@ void PopupDistantChatDialog::updateDisplay() break; case RS_DISTANT_CHAT_STATUS_CAN_TALK: - _status_label->setIcon(QIcon(IMAGE_GRN_LED)); + _status_label->setIcon(FilesDefs::getIconFromQtResourcePath(IMAGE_GRN_LED)); msg = QObject::tr( "End-to-end encrypted conversation established"); _status_label->setToolTip(msg); getChatWidget()->unblockSending(); diff --git a/retroshare-gui/src/gui/common/Emoticons.cpp b/retroshare-gui/src/gui/common/Emoticons.cpp index 347d88b6e..47a1d67bf 100644 --- a/retroshare-gui/src/gui/common/Emoticons.cpp +++ b/retroshare-gui/src/gui/common/Emoticons.cpp @@ -37,6 +37,7 @@ #include "Emoticons.h" #include "util/HandleRichText.h" #include "retroshare/rsinit.h" +#include "gui/common/FilesDefs.h" #define ICONNAME "groupicon.png" @@ -210,7 +211,7 @@ void Emoticons::showSmileyWidget(QWidget *parent, QWidget *button, const char *s smTab->setStyleSheet("QTabBar::tab { height: 44px; width: 44px; }"); if (groupName.right(4).toLower() == ".png") - smTab->addTab( tabGrpWidget, QIcon(groupName), ""); + smTab->addTab( tabGrpWidget, FilesDefs::getIconFromQtResourcePath(groupName), ""); else smTab->addTab( tabGrpWidget, groupName); } else { @@ -371,9 +372,9 @@ void Emoticons::showStickerWidget(QWidget *parent, QWidget *button, const char * int index; if (groupDir.exists(ICONNAME)) //use groupicon.png if exists, else the first png as a group icon - index = smTab->addTab( tabGrpWidget, QIcon(groupDir.absoluteFilePath(ICONNAME)), ""); + index = smTab->addTab( tabGrpWidget, FilesDefs::getIconFromQtResourcePath(groupDir.absoluteFilePath(ICONNAME)), ""); else - index = smTab->addTab( tabGrpWidget, QIcon(groupDir.entryInfoList(QDir::Files)[0].canonicalFilePath()), ""); + index = smTab->addTab( tabGrpWidget, FilesDefs::getIconFromQtResourcePath(groupDir.entryInfoList(QDir::Files)[0].canonicalFilePath()), ""); smTab->setTabToolTip(index, groupName); } else { tabGrpWidget = smWidget; diff --git a/retroshare-gui/src/gui/common/FriendList.cpp b/retroshare-gui/src/gui/common/FriendList.cpp index 967d8df5d..257a0349a 100644 --- a/retroshare-gui/src/gui/common/FriendList.cpp +++ b/retroshare-gui/src/gui/common/FriendList.cpp @@ -352,25 +352,25 @@ void FriendList::peerTreeWidgetCustomPopupMenu() { bool standard = c->data(COLUMN_DATA, ROLE_STANDARD).toBool(); #ifdef RS_DIRECT_CHAT - contextMenu->addAction(QIcon(IMAGE_MSG), tr("Send message to whole group"), this, SLOT(msgfriend())); + contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_MSG), tr("Send message to whole group"), this, SLOT(msgfriend())); contextMenu->addSeparator(); #endif // RS_DIRECT_CHAT - contextMenu->addAction(QIcon(IMAGE_EDIT), tr("Edit Group"), this, SLOT(editGroup())); + contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_EDIT), tr("Edit Group"), this, SLOT(editGroup())); - QAction *action = contextMenu->addAction(QIcon(IMAGE_REMOVE), tr("Remove Group"), this, SLOT(removeGroup())); + QAction *action = contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_REMOVE), tr("Remove Group"), this, SLOT(removeGroup())); action->setDisabled(standard); } break; case TYPE_GPG: { #ifdef RS_DIRECT_CHAT - contextMenu->addAction(QIcon(IMAGE_CHAT), tr("Chat"), this, SLOT(chatfriendproxy())); - contextMenu->addAction(QIcon(IMAGE_MSG), tr("Send message"), this, SLOT(msgfriend())); + contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_CHAT), tr("Chat"), this, SLOT(chatfriendproxy())); + contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_MSG), tr("Send message"), this, SLOT(msgfriend())); contextMenu->addSeparator(); #endif // RS_DIRECT_CHAT - contextMenu->addAction(QIcon(IMAGE_FRIENDINFO), tr("Profile details"), this, SLOT(configurefriend())); - contextMenu->addAction(QIcon(IMAGE_DENYFRIEND), tr("Deny connections"), this, SLOT(removefriend())); + contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_FRIENDINFO), tr("Profile details"), this, SLOT(configurefriend())); + contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_DENYFRIEND), tr("Deny connections"), this, SLOT(removefriend())); if(mShowGroups) { @@ -412,8 +412,8 @@ void FriendList::peerTreeWidgetCustomPopupMenu() } } - QMenu *groupsMenu = contextMenu->addMenu(QIcon(IMAGE_GROUP16), tr("Groups")); - groupsMenu->addAction(QIcon(IMAGE_EXPAND), tr("Create new group"), this, SLOT(createNewGroup())); + QMenu *groupsMenu = contextMenu->addMenu(FilesDefs::getIconFromQtResourcePath(IMAGE_GROUP16), tr("Groups")); + groupsMenu->addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_EXPAND), tr("Create new group"), this, SLOT(createNewGroup())); if (addToGroupMenu || moveToGroupMenu || foundGroup) { if (addToGroupMenu) { @@ -445,24 +445,24 @@ void FriendList::peerTreeWidgetCustomPopupMenu() case TYPE_SSL: { #ifdef RS_DIRECT_CHAT - contextMenu->addAction(QIcon(IMAGE_CHAT), tr("Chat"), this, SLOT(chatfriendproxy())); - contextMenu->addAction(QIcon(IMAGE_MSG), tr("Send message to this node"), this, SLOT(msgfriend())); + contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_CHAT), tr("Chat"), this, SLOT(chatfriendproxy())); + contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_MSG), tr("Send message to this node"), this, SLOT(msgfriend())); contextMenu->addSeparator(); #endif // RS_DIRECT_CHAT - contextMenu->addAction(QIcon(IMAGE_FRIENDINFO), tr("Node details"), this, SLOT(configurefriend())); + contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_FRIENDINFO), tr("Node details"), this, SLOT(configurefriend())); if (type == TYPE_GPG || type == TYPE_SSL) { - contextMenu->addAction(QIcon(IMAGE_EXPORTFRIEND), tr("Recommend this node to..."), this, SLOT(recommendfriend())); + contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_EXPORTFRIEND), tr("Recommend this node to..."), this, SLOT(recommendfriend())); } if(!rsPeers->isHiddenNode(rsPeers->getOwnId()) || rsPeers->isHiddenNode( RsPeerId(getRsId(c)) )) - contextMenu->addAction(QIcon(IMAGE_CONNECT), tr("Attempt to connect"), this, SLOT(connectfriend())); + contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_CONNECT), tr("Attempt to connect"), this, SLOT(connectfriend())); - contextMenu->addAction(QIcon(IMAGE_COPYLINK), tr("Copy certificate link"), this, SLOT(copyFullCertificate())); + contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_COPYLINK), tr("Copy certificate link"), this, SLOT(copyFullCertificate())); //this is a SSL key - contextMenu->addAction(QIcon(IMAGE_REMOVEFRIEND), tr("Remove Friend Node"), this, SLOT(removefriend())); + contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_REMOVEFRIEND), tr("Remove Friend Node"), this, SLOT(removefriend())); } } @@ -471,12 +471,12 @@ void FriendList::peerTreeWidgetCustomPopupMenu() contextMenu->addSeparator(); - QAction *action = contextMenu->addAction(QIcon(IMAGE_PASTELINK), tr("Paste certificate link"), this, SLOT(pastePerson())); + QAction *action = contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_PASTELINK), tr("Paste certificate link"), this, SLOT(pastePerson())); if (RSLinkClipboard::empty(RetroShareLink::TYPE_CERTIFICATE)) action->setDisabled(true); - contextMenu->addAction(QIcon(IMAGE_EXPAND), tr("Expand all"), ui->peerTreeWidget, SLOT(expandAll())); - contextMenu->addAction(QIcon(IMAGE_COLLAPSE), tr("Collapse all"), ui->peerTreeWidget, SLOT(collapseAll())); + contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_EXPAND), tr("Expand all"), ui->peerTreeWidget, SLOT(expandAll())); + contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_COLLAPSE), tr("Collapse all"), ui->peerTreeWidget, SLOT(collapseAll())); contextMenu = ui->peerTreeWidget->createStandardContextMenu(contextMenu); @@ -716,7 +716,7 @@ void FriendList::insertPeers() groupItem->setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicatorWhenChildless); groupItem->setTextAlignment(COLUMN_NAME, Qt::AlignLeft | Qt::AlignVCenter); - groupItem->setIcon(COLUMN_NAME, QIcon(IMAGE_GROUP24)); + groupItem->setIcon(COLUMN_NAME, FilesDefs::getIconFromQtResourcePath(IMAGE_GROUP24)); groupItem->setData(COLUMN_NAME, Qt::ForegroundRole, textColorGroup()); /* used to find back the item */ diff --git a/retroshare-gui/src/gui/common/FriendListModel.cpp b/retroshare-gui/src/gui/common/FriendListModel.cpp index 74d5d8746..39d4bbded 100644 --- a/retroshare-gui/src/gui/common/FriendListModel.cpp +++ b/retroshare-gui/src/gui/common/FriendListModel.cpp @@ -152,15 +152,13 @@ void RsFriendListModel::setDisplayGroups(bool b) } void RsFriendListModel::preMods() { - emit layoutAboutToBeChanged(); - beginResetModel(); } void RsFriendListModel::postMods() { endResetModel(); - emit layoutChanged(); - emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mTopLevel.size()-1,COLUMN_THREAD_NB_COLUMNS-1,(void*)NULL)); + + emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(rowCount()-1,columnCount()-1,(void*)NULL)); } int RsFriendListModel::rowCount(const QModelIndex& parent) const @@ -1060,14 +1058,16 @@ void RsFriendListModel::updateInternalData() preMods(); beginRemoveRows(QModelIndex(),0,mTopLevel.size()-1); - endRemoveRows(); mGroups.clear(); mProfiles.clear(); mLocations.clear(); - mTopLevel.clear(); + endRemoveRows(); + + auto TL = mTopLevel ; // This allows to fill TL without touching mTopLevel outside of [begin/end]InsertRows(). + // create a map of profiles and groups std::map pgp_indices; @@ -1155,7 +1155,6 @@ void RsFriendListModel::updateInternalData() RsDbg() << "Creating top level list" << std::endl; #endif - mTopLevel.clear(); std::set already_in_a_group; if(mDisplayGroups) // in this case, we list all groups at the top level followed by the profiles without parent group @@ -1170,7 +1169,7 @@ void RsFriendListModel::updateInternalData() e.type = ENTRY_TYPE_GROUP; e.group_index = i; - mTopLevel.push_back(e); + TL.push_back(e); for(uint32_t j=0;jprofile_info.gpg_id.toStdString(); if(!s.empty()) - mExpandedProfiles.insert(s); + mExpandedProfiles.insert(s); // apparently we cannot be subtle here. - emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mTopLevel.size()-1,COLUMN_THREAD_NB_COLUMNS-1,(void*)NULL)); + emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mTopLevel.size()-1,columnCount()-1,(void*)NULL)); } bool RsFriendListModel::isProfileExpanded(const EntryIndex& e) const diff --git a/retroshare-gui/src/gui/common/FriendListModel.h b/retroshare-gui/src/gui/common/FriendListModel.h index 5e8d84930..871dc14b9 100644 --- a/retroshare-gui/src/gui/common/FriendListModel.h +++ b/retroshare-gui/src/gui/common/FriendListModel.h @@ -39,8 +39,16 @@ public: explicit RsFriendListModel(QObject *parent = NULL); ~RsFriendListModel(){} - class RsNodeDetails: public RsPeerDetails {};// in the near future, there will be a specific class for Profile/Node details in replacement of RsPeerDetails - class RsProfileDetails: public RsPeerDetails {}; + class RsNodeDetails: public RsPeerDetails + { + public: + virtual ~RsNodeDetails() {} + };// in the near future, there will be a specific class for Profile/Node details in replacement of RsPeerDetails + class RsProfileDetails: public RsPeerDetails + { + public: + virtual ~RsProfileDetails() {} + }; struct HierarchicalGroupInformation { @@ -55,6 +63,7 @@ public: struct HierarchicalNodeInformation { HierarchicalNodeInformation() : last_update_ts(0) {} + virtual ~HierarchicalNodeInformation() {} rstime_t last_update_ts; RsNodeDetails node_info; diff --git a/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp b/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp index 4043fe424..d253691bf 100644 --- a/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp +++ b/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp @@ -18,6 +18,7 @@ * * *******************************************************************************/ +#include "gui/common/FilesDefs.h" #include #include #include "FriendSelectionWidget.h" @@ -219,7 +220,7 @@ static void initSslItem(QTreeWidgetItem *item, const RsPeerDetails &detail, cons item->setData(COLUMN_NAME, Qt::ForegroundRole, textColorOnline); } - item->setIcon(COLUMN_NAME, QIcon(StatusDefs::imageUser(state))); + item->setIcon(COLUMN_NAME, FilesDefs::getIconFromQtResourcePath(StatusDefs::imageUser(state))); item->setData(COLUMN_DATA, ROLE_ID, QString::fromStdString(detail.id.toStdString())); item->setData(COLUMN_NAME, ROLE_SORT_GROUP, 1); @@ -381,7 +382,7 @@ void FriendSelectionWidget::secured_fillList() groupItem->setFlags(Qt::ItemIsUserCheckable | groupItem->flags()); groupItem->setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicatorWhenChildless); groupItem->setTextAlignment(COLUMN_NAME, Qt::AlignLeft | Qt::AlignVCenter); - groupItem->setIcon(COLUMN_NAME, QIcon(IMAGE_GROUP16)); + groupItem->setIcon(COLUMN_NAME, FilesDefs::getIconFromQtResourcePath(IMAGE_GROUP16)); groupItem->setData(COLUMN_DATA, ROLE_ID, QString::fromStdString(groupInfo->id.toStdString())); @@ -454,7 +455,7 @@ void FriendSelectionWidget::secured_fillList() } gpgItem->setFlags(Qt::ItemIsUserCheckable | gpgItem->flags()); - gpgItem->setIcon(COLUMN_NAME, QIcon(StatusDefs::imageUser(state))); + gpgItem->setIcon(COLUMN_NAME, FilesDefs::getIconFromQtResourcePath(StatusDefs::imageUser(state))); gpgItem->setData(COLUMN_DATA, ROLE_ID, QString::fromStdString(detail.gpg_id.toStdString())); gpgItem->setData(COLUMN_NAME, ROLE_SORT_GROUP, 1); @@ -773,7 +774,7 @@ void FriendSelectionWidget::peerStatusChanged(const QString& peerId, int status) item->setData(COLUMN_NAME, Qt::ForegroundRole, QVariant()); } - item->setIcon(COLUMN_NAME, QIcon(StatusDefs::imageUser(gpgStatus))); + item->setIcon(COLUMN_NAME, FilesDefs::getIconFromQtResourcePath(StatusDefs::imageUser(gpgStatus))); item->setData(COLUMN_NAME, ROLE_SORT_STATE, gpgStatus); @@ -790,7 +791,7 @@ void FriendSelectionWidget::peerStatusChanged(const QString& peerId, int status) item->setData(COLUMN_NAME, Qt::ForegroundRole, QVariant()); } - item->setIcon(COLUMN_NAME, QIcon(StatusDefs::imageUser(status))); + item->setIcon(COLUMN_NAME, FilesDefs::getIconFromQtResourcePath(StatusDefs::imageUser(status))); item->setData(COLUMN_NAME, ROLE_SORT_STATE, status); diff --git a/retroshare-gui/src/gui/common/GroupFlagsWidget.cpp b/retroshare-gui/src/gui/common/GroupFlagsWidget.cpp index d4142f886..9b40df3d0 100644 --- a/retroshare-gui/src/gui/common/GroupFlagsWidget.cpp +++ b/retroshare-gui/src/gui/common/GroupFlagsWidget.cpp @@ -18,6 +18,7 @@ * * *******************************************************************************/ +#include "gui/common/FilesDefs.h" #include #include #include "GroupFlagsWidget.h" @@ -54,12 +55,12 @@ GroupFlagsWidget::GroupFlagsWidget(QWidget *parent,FileStorageFlags flags) setMaximumSize(128 * QFontMetricsF(font()).height()/14.0,32 * QFontMetricsF(font()).height()/14.0) ; setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); - _icons[2*INDEX_BROWSABLE+0] = new QIcon(FLAGS_BROWSABLE_OFF) ; - _icons[2*INDEX_BROWSABLE+1] = new QIcon(FLAGS_BROWSABLE_ON) ; - _icons[2*INDEX_ANON_SEARCH+0] = new QIcon(FLAGS_ANONYMOUS_SEARCH_OFF) ; - _icons[2*INDEX_ANON_SEARCH+1] = new QIcon(FLAGS_ANONYMOUS_SEARCH_ON) ; - _icons[2*INDEX_ANON_DL+0] = new QIcon(FLAGS_ANONYMOUS_DL_OFF) ; - _icons[2*INDEX_ANON_DL+1] = new QIcon(FLAGS_ANONYMOUS_DL_ON) ; + _icons[2*INDEX_BROWSABLE+0] = FilesDefs::getIconFromQtResourcePath(FLAGS_BROWSABLE_OFF) ; + _icons[2*INDEX_BROWSABLE+1] = FilesDefs::getIconFromQtResourcePath(FLAGS_BROWSABLE_ON) ; + _icons[2*INDEX_ANON_SEARCH+0] = FilesDefs::getIconFromQtResourcePath(FLAGS_ANONYMOUS_SEARCH_OFF) ; + _icons[2*INDEX_ANON_SEARCH+1] = FilesDefs::getIconFromQtResourcePath(FLAGS_ANONYMOUS_SEARCH_ON) ; + _icons[2*INDEX_ANON_DL+0] = FilesDefs::getIconFromQtResourcePath(FLAGS_ANONYMOUS_DL_OFF) ; + _icons[2*INDEX_ANON_DL+1] = FilesDefs::getIconFromQtResourcePath(FLAGS_ANONYMOUS_DL_ON) ; setLayout(_layout) ; @@ -136,7 +137,7 @@ void GroupFlagsWidget::update_button_state(bool b,int button_id) tip_on = ""; tip_off = ""; } - _buttons[button_id]->setIcon(*_icons[2*button_id+(int)b]) ; + _buttons[button_id]->setIcon(_icons[2*button_id+(int)b]) ; _buttons[button_id]->setToolTip(b?tip_on:tip_off) ; } @@ -183,10 +184,6 @@ void GroupFlagsWidget::update_BR_button(bool b) { update_button_state(b,INDEX_BR GroupFlagsWidget::~GroupFlagsWidget() { for(int i=0;i<3;++i) - { delete _buttons[i] ; - delete _icons[2*i+0] ; - delete _icons[2*i+1] ; - } } diff --git a/retroshare-gui/src/gui/common/GroupFlagsWidget.h b/retroshare-gui/src/gui/common/GroupFlagsWidget.h index 4703d124d..d4ef95295 100644 --- a/retroshare-gui/src/gui/common/GroupFlagsWidget.h +++ b/retroshare-gui/src/gui/common/GroupFlagsWidget.h @@ -55,7 +55,7 @@ class GroupFlagsWidget: public QWidget QPushButton *_buttons[4] ; QLayout *_layout ; - QIcon *_icons[6] ; + QIcon _icons[6] ; FileStorageFlags _flags[4] ; static QString _tooltips_on[4] ; diff --git a/retroshare-gui/src/gui/common/GroupTreeWidget.cpp b/retroshare-gui/src/gui/common/GroupTreeWidget.cpp index db9b487b4..aa9b76023 100644 --- a/retroshare-gui/src/gui/common/GroupTreeWidget.cpp +++ b/retroshare-gui/src/gui/common/GroupTreeWidget.cpp @@ -21,6 +21,7 @@ #include "GroupTreeWidget.h" #include "ui_GroupTreeWidget.h" +#include "gui/common/FilesDefs.h" #include "retroshare/rsgxsflags.h" #include "PopularityDefs.h" @@ -250,11 +251,11 @@ void GroupTreeWidget::initDisplayMenu(QToolButton *toolButton) displayMenu = new QMenu(); QActionGroup *actionGroupAsc = new QActionGroup(displayMenu); - actionSortDescending = displayMenu->addAction(QIcon(":/images/sort_decrease.png"), tr("Sort Descending Order"), this, SLOT(sort())); + actionSortDescending = displayMenu->addAction(FilesDefs::getIconFromQtResourcePath(":/images/sort_decrease.png"), tr("Sort Descending Order"), this, SLOT(sort())); actionSortDescending->setCheckable(true); actionSortDescending->setActionGroup(actionGroupAsc); - actionSortAscending = displayMenu->addAction(QIcon(":/images/sort_incr.png"), tr("Sort Ascending Order"), this, SLOT(sort())); + actionSortAscending = displayMenu->addAction(FilesDefs::getIconFromQtResourcePath(":/images/sort_incr.png"), tr("Sort Ascending Order"), this, SLOT(sort())); actionSortAscending->setCheckable(true); actionSortAscending->setActionGroup(actionGroupAsc); diff --git a/retroshare-gui/src/gui/common/LineEditClear.cpp b/retroshare-gui/src/gui/common/LineEditClear.cpp index 05bdca90b..b439aaa07 100644 --- a/retroshare-gui/src/gui/common/LineEditClear.cpp +++ b/retroshare-gui/src/gui/common/LineEditClear.cpp @@ -18,6 +18,7 @@ * * *******************************************************************************/ +#include "gui/common/FilesDefs.h" #include "LineEditClear.h" #include @@ -124,9 +125,8 @@ void LineEditClear::showFilterIcon() mFilterButton = new QToolButton(this); mFilterButton->setFixedSize(16, 16); - QPixmap filterPixmap(IMAGE_FILTER); - mFilterButton->setIcon(QIcon(filterPixmap)); - mFilterButton->setIconSize(filterPixmap.size()); + mFilterButton->setIcon(FilesDefs::getIconFromQtResourcePath(IMAGE_FILTER)); + //mFilterButton->setIconSize(filterPixmap.size()); mFilterButton->setCursor(Qt::ArrowCursor); mFilterButton->setStyleSheet("QToolButton { border: none; padding: 0px; }" "QToolButton[popupMode=\"2\"] { padding-right: 10px; }" @@ -224,7 +224,7 @@ void LineEditClear::activateAction(QAction *action) QIcon icon = action->icon(); if (icon.isNull()) { - icon = QIcon(IMAGE_FILTER); + icon = FilesDefs::getIconFromQtResourcePath(IMAGE_FILTER); } mFilterButton->setIcon(icon); diff --git a/retroshare-gui/src/gui/common/MimeTextEdit.cpp b/retroshare-gui/src/gui/common/MimeTextEdit.cpp index cac02dc3e..b24a65879 100644 --- a/retroshare-gui/src/gui/common/MimeTextEdit.cpp +++ b/retroshare-gui/src/gui/common/MimeTextEdit.cpp @@ -18,6 +18,7 @@ * * *******************************************************************************/ +#include "gui/common/FilesDefs.h" #include #include #include @@ -250,8 +251,8 @@ void MimeTextEdit::contextMenuEvent(QContextMenuEvent *e) QAction *spoilerAction = contextMenu->addAction(tr("Spoiler"), this, SLOT(spoiler())); spoilerAction->setToolTip(tr("Select text to hide, then push this button")); contextMenu->addSeparator(); - QAction *pasteLinkAction = contextMenu->addAction(QIcon(":/images/pasterslink.png"), tr("Paste RetroShare Link"), this, SLOT(pasteLink())); - contextMenu->addAction(QIcon(":/images/pasterslink.png"), tr("Paste my certificate link"), this, SLOT(pasteOwnCertificateLink())); + QAction *pasteLinkAction = contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(":/images/pasterslink.png"), tr("Paste RetroShare Link"), this, SLOT(pasteLink())); + contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(":/images/pasterslink.png"), tr("Paste my certificate link"), this, SLOT(pasteOwnCertificateLink())); if (RSLinkClipboard::empty()) { pasteLinkAction->setDisabled(true); diff --git a/retroshare-gui/src/gui/common/NewFriendList.cpp b/retroshare-gui/src/gui/common/NewFriendList.cpp index 9d9908642..8b6f982bb 100644 --- a/retroshare-gui/src/gui/common/NewFriendList.cpp +++ b/retroshare-gui/src/gui/common/NewFriendList.cpp @@ -32,6 +32,7 @@ #include "GroupDefs.h" #include "gui/chat/ChatDialog.h" #include "gui/common/AvatarDefs.h" +#include "gui/common/FilesDefs.h" #include "gui/connect/ConfCertDialog.h" #include "gui/connect/PGPKeyDialog.h" @@ -453,6 +454,7 @@ void NewFriendList::processSettings(bool load) if (load) // load settings { + std::cerr <<"Re-loading settings..." << std::endl; // states setShowUnconnected(!Settings->value("hideUnconnected", !mProxyModel->showOfflineNodes()).toBool()); setShowState(Settings->value("showState", mModel->getDisplayStatusString()).toBool()); @@ -577,20 +579,20 @@ void NewFriendList::peerTreeWidgetCustomPopupMenu() bool standard = group_info.flag & RS_GROUP_FLAG_STANDARD; #ifdef RS_DIRECT_CHAT - contextMenu.addAction(QIcon(IMAGE_MSG), tr("Send message to whole group"), this, SLOT(msgGroup())); + contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_MSG), tr("Send message to whole group"), this, SLOT(msgGroup())); contextMenu.addSeparator(); #endif // RS_DIRECT_CHAT - contextMenu.addAction(QIcon(IMAGE_EDIT), tr("Edit Group"), this, SLOT(editGroup())); + contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_EDIT), tr("Edit Group"), this, SLOT(editGroup())); - QAction *action = contextMenu.addAction(QIcon(IMAGE_REMOVE), tr("Remove Group"), this, SLOT(removeGroup())); + QAction *action = contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_REMOVE), tr("Remove Group"), this, SLOT(removeGroup())); action->setDisabled(standard); } break; case RsFriendListModel::ENTRY_TYPE_PROFILE: { - contextMenu.addAction(QIcon(IMAGE_FRIENDINFO), tr("Profile details"), this, SLOT(configureProfile())); - contextMenu.addAction(QIcon(IMAGE_DENYFRIEND), tr("Deny connections"), this, SLOT(removeProfile())); + contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_FRIENDINFO), tr("Profile details"), this, SLOT(configureProfile())); + contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_DENYFRIEND), tr("Deny connections"), this, SLOT(removeProfile())); RsFriendListModel::RsProfileDetails details; mModel->getProfileData(index,details); @@ -636,8 +638,8 @@ void NewFriendList::peerTreeWidgetCustomPopupMenu() } } - QMenu *groupsMenu = contextMenu.addMenu(QIcon(IMAGE_GROUP16), tr("Groups")); - groupsMenu->addAction(QIcon(IMAGE_EXPAND), tr("Create new group"), this, SLOT(createNewGroup())); + QMenu *groupsMenu = contextMenu.addMenu(FilesDefs::getIconFromQtResourcePath(IMAGE_GROUP16), tr("Groups")); + groupsMenu->addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_EXPAND), tr("Create new group"), this, SLOT(createNewGroup())); if (addToGroupMenu || moveToGroupMenu || foundGroup) { if (addToGroupMenu) { @@ -674,26 +676,26 @@ void NewFriendList::peerTreeWidgetCustomPopupMenu() case RsFriendListModel::ENTRY_TYPE_NODE: { #ifdef RS_DIRECT_CHAT - contextMenu.addAction(QIcon(IMAGE_CHAT), tr("Chat"), this, SLOT(chatNode())); - contextMenu.addAction(QIcon(IMAGE_MSG), tr("Send message to this node"), this, SLOT(msgNode())); + contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_CHAT), tr("Chat"), this, SLOT(chatNode())); + contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_MSG), tr("Send message to this node"), this, SLOT(msgNode())); contextMenu.addSeparator(); #endif // RS_DIRECT_CHAT - contextMenu.addAction(QIcon(IMAGE_FRIENDINFO), tr("Node details"), this, SLOT(configureNode())); + contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_FRIENDINFO), tr("Node details"), this, SLOT(configureNode())); if (type == RsFriendListModel::ENTRY_TYPE_PROFILE || type == RsFriendListModel::ENTRY_TYPE_NODE) - contextMenu.addAction(QIcon(IMAGE_EXPORTFRIEND), tr("Recommend this node to..."), this, SLOT(recommendNode())); + contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_EXPORTFRIEND), tr("Recommend this node to..."), this, SLOT(recommendNode())); RsFriendListModel::RsNodeDetails details; mModel->getNodeData(index,details); if(!rsPeers->isHiddenNode(rsPeers->getOwnId()) || rsPeers->isHiddenNode( details.id )) - contextMenu.addAction(QIcon(IMAGE_CONNECT), tr("Attempt to connect"), this, SLOT(connectNode())); + contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_CONNECT), tr("Attempt to connect"), this, SLOT(connectNode())); - contextMenu.addAction(QIcon(IMAGE_COPYLINK), tr("Copy certificate link"), this, SLOT(copyFullCertificate())); + contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_COPYLINK), tr("Copy certificate link"), this, SLOT(copyFullCertificate())); //this is a SSL key - contextMenu.addAction(QIcon(IMAGE_REMOVEFRIEND), tr("Remove Friend Node"), this, SLOT(removeNode())); + contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_REMOVEFRIEND), tr("Remove Friend Node"), this, SLOT(removeNode())); } } @@ -702,12 +704,12 @@ void NewFriendList::peerTreeWidgetCustomPopupMenu() contextMenu.addSeparator(); - QAction *action = contextMenu.addAction(QIcon(IMAGE_PASTELINK), tr("Paste certificate link"), this, SLOT(pastePerson())); + QAction *action = contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_PASTELINK), tr("Paste certificate link"), this, SLOT(pastePerson())); if (RSLinkClipboard::empty(RetroShareLink::TYPE_CERTIFICATE)) action->setDisabled(true); - contextMenu.addAction(QIcon(IMAGE_EXPAND), tr("Expand all"), ui->peerTreeWidget, SLOT(expandAll())); - contextMenu.addAction(QIcon(IMAGE_COLLAPSE), tr("Collapse all"), ui->peerTreeWidget, SLOT(collapseAll())); + contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_EXPAND), tr("Expand all"), ui->peerTreeWidget, SLOT(expandAll())); + contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_COLLAPSE), tr("Collapse all"), ui->peerTreeWidget, SLOT(collapseAll())); contextMenu.addSeparator(); @@ -1087,16 +1089,46 @@ void NewFriendList::removeGroup() checkInternalData(true); } -void NewFriendList::checkInternalData(bool force) +void NewFriendList::applyWhileKeepingTree(std::function predicate) { std::set expanded_indexes; - std::set selected_indexes; + std::set selected_indexes; - saveExpandedPathsAndSelection(expanded_indexes, selected_indexes); + saveExpandedPathsAndSelection(expanded_indexes, selected_indexes); - mModel->checkInternalData(force); + // This is a hack to avoid crashes on windows while calling endInsertRows(). I'm not sure wether these crashes are + // due to a Qt bug, or a misuse of the proxy model on my side. Anyway, this solves them for good. + // As a side effect we need to save/restore hidden columns because setSourceModel() resets this setting. - restoreExpandedPathsAndSelection(expanded_indexes, selected_indexes); + // save hidden columns and sizes + std::vector col_visible(RsFriendListModel::COLUMN_THREAD_NB_COLUMNS); + std::vector col_sizes(RsFriendListModel::COLUMN_THREAD_NB_COLUMNS); + + for(int i=0;ipeerTreeWidget->isColumnHidden(i); + col_sizes[i] = ui->peerTreeWidget->columnWidth(i); + } + + + mProxyModel->setSourceModel(nullptr); + + predicate(); + + mProxyModel->setSourceModel(mModel); + restoreExpandedPathsAndSelection(expanded_indexes, selected_indexes); + + // restore hidden columns + for(uint32_t i=0;ipeerTreeWidget->setColumnHidden(i,!col_visible[i]); + ui->peerTreeWidget->setColumnWidth(i,col_sizes[i]); + } +} + +void NewFriendList::checkInternalData(bool force) +{ + applyWhileKeepingTree([force,this]() { mModel->checkInternalData(force) ; }); } void NewFriendList::exportFriendlistClicked() @@ -1484,6 +1516,7 @@ bool NewFriendList::isColumnVisible(int col) const } void NewFriendList::setColumnVisible(int col,bool visible) { + std::cerr << "Setting column " << col << " to be visible: " << visible << std::endl; ui->peerTreeWidget->setColumnHidden(col, !visible); } void NewFriendList::toggleColumnVisible() @@ -1501,12 +1534,12 @@ void NewFriendList::toggleColumnVisible() void NewFriendList::setShowState(bool show) { - mModel->setDisplayStatusString(show); + applyWhileKeepingTree([show,this]() { mModel->setDisplayStatusString(show) ; }); } void NewFriendList::setShowGroups(bool show) { - mModel->setDisplayGroups(show); + applyWhileKeepingTree([show,this]() { mModel->setDisplayGroups(show) ; }); } /** diff --git a/retroshare-gui/src/gui/common/NewFriendList.h b/retroshare-gui/src/gui/common/NewFriendList.h index 2a1955ced..7387a477e 100644 --- a/retroshare-gui/src/gui/common/NewFriendList.h +++ b/retroshare-gui/src/gui/common/NewFriendList.h @@ -25,8 +25,9 @@ #include #include +#include + #include "FriendListModel.h" -#include "RsAutoUpdatePage.h" #include "retroshare/rsstatus.h" namespace Ui { @@ -102,7 +103,9 @@ private: RsFriendListModel *mModel; QAction *mActionSortByState; - void expandGroup(const RsNodeGroupId& gid); + void applyWhileKeepingTree(std::function predicate); + + void expandGroup(const RsNodeGroupId& gid); void recursRestoreExpandedItems(const QModelIndex& index, const QString& parent_path, const std::set& exp, const std::set &sel); void recursSaveExpandedItems(const QModelIndex& index,const QString& parent_path,std::set& exp, std::set& sel); void saveExpandedPathsAndSelection(std::set& expanded_indexes, std::set& selected_indexes); diff --git a/retroshare-gui/src/gui/common/PopularityDefs.cpp b/retroshare-gui/src/gui/common/PopularityDefs.cpp index 096cdc1cf..d027c4248 100644 --- a/retroshare-gui/src/gui/common/PopularityDefs.cpp +++ b/retroshare-gui/src/gui/common/PopularityDefs.cpp @@ -20,22 +20,23 @@ #include +#include "FilesDefs.h" #include "PopularityDefs.h" QIcon PopularityDefs::icon(int popularity) { if (popularity <= 1) - return QIcon(":/images/hot_0.png"); + return FilesDefs::getIconFromQtResourcePath(":/images/hot_0.png"); else if (popularity <= 2) /* 1-1 */ - return QIcon(":/images/hot_1.png"); + return FilesDefs::getIconFromQtResourcePath(":/images/hot_1.png"); else if (popularity <= 5) /* 2-2 */ - return QIcon(":/images/hot_2.png"); + return FilesDefs::getIconFromQtResourcePath(":/images/hot_2.png"); else if (popularity <= 10) /* 3-5 */ - return QIcon(":/images/hot_3.png"); + return FilesDefs::getIconFromQtResourcePath(":/images/hot_3.png"); else if (popularity <= 20) /* 6-10 */ - return QIcon(":/images/hot_4.png"); + return FilesDefs::getIconFromQtResourcePath(":/images/hot_4.png"); else /* >10 */ - return QIcon(":/images/hot_5.png"); + return FilesDefs::getIconFromQtResourcePath(":/images/hot_5.png"); } QString PopularityDefs::tooltip(int popularity) diff --git a/retroshare-gui/src/gui/common/RsCollectionDialog.cpp b/retroshare-gui/src/gui/common/RsCollectionDialog.cpp index b9a84b7a1..89976f6e8 100644 --- a/retroshare-gui/src/gui/common/RsCollectionDialog.cpp +++ b/retroshare-gui/src/gui/common/RsCollectionDialog.cpp @@ -18,6 +18,7 @@ * * *******************************************************************************/ +#include "gui/common/FilesDefs.h" #include "RsCollectionDialog.h" #include "RsCollection.h" @@ -254,7 +255,7 @@ void RsCollectionDialog::openDestinationDirectoryMenu() contextMnu.addAction(QString::fromUtf8((*it).filename.c_str()), this, SLOT(setDestinationDirectory()))->setData(QString::fromUtf8( (*it).filename.c_str() ) ) ; } - contextMnu.addAction( QIcon(IMAGE_SEARCH),tr("Specify..."),this,SLOT(chooseDestinationDirectory())); + contextMnu.addAction( FilesDefs::getIconFromQtResourcePath(IMAGE_SEARCH),tr("Specify..."),this,SLOT(chooseDestinationDirectory())); contextMnu.exec(QCursor::pos()) ; } diff --git a/retroshare-gui/src/gui/common/SubscribeToolButton.cpp b/retroshare-gui/src/gui/common/SubscribeToolButton.cpp index 4bb0147e6..4015e641c 100644 --- a/retroshare-gui/src/gui/common/SubscribeToolButton.cpp +++ b/retroshare-gui/src/gui/common/SubscribeToolButton.cpp @@ -18,6 +18,7 @@ * * *******************************************************************************/ +#include "gui/common/FilesDefs.h" #include #include "SubscribeToolButton.h" @@ -64,14 +65,14 @@ void SubscribeToolButton::updateUi() #else setPopupMode(QToolButton::InstantPopup); #endif - //setIcon(QIcon(":/images/accepted16.png")); + //setIcon(FilesDefs::getIconFromQtResourcePath(":/images/accepted16.png")); setText(tr("Subscribed")); if(mMenu != NULL) // that's because setMenu does not give away memory ownership delete mMenu ; mMenu = new QMenu; - mMenu->addAction(QIcon(":/images/cancel.png"), tr("Unsubscribe"), this, SLOT(unsubscribePrivate())); + mMenu->addAction(FilesDefs::getIconFromQtResourcePath(":/images/cancel.png"), tr("Unsubscribe"), this, SLOT(unsubscribePrivate())); if (!mSubscribedActions.empty()) { mMenu->addSeparator(); @@ -86,7 +87,7 @@ void SubscribeToolButton::updateUi() } else { setPopupMode(QToolButton::DelayedPopup); setMenu(NULL); - //setIcon(QIcon(":/images/RSS_004_32.png")); + //setIcon(FilesDefs::getIconFromQtResourcePath(":/images/RSS_004_32.png")); setText(tr("Subscribe")); #ifndef USE_MENUBUTTONPOPUP diff --git a/retroshare-gui/src/gui/connect/ConfCertDialog.cpp b/retroshare-gui/src/gui/connect/ConfCertDialog.cpp index fc56ebef5..92ab22142 100644 --- a/retroshare-gui/src/gui/connect/ConfCertDialog.cpp +++ b/retroshare-gui/src/gui/connect/ConfCertDialog.cpp @@ -32,6 +32,8 @@ #include #include +#include + #include "gui/help/browser/helpbrowser.h" #include "gui/common/PeerDefs.h" #include "gui/common/StatusDefs.h" @@ -39,7 +41,6 @@ #include "gui/notifyqt.h" #include "gui/common/AvatarDefs.h" #include "gui/MainWindow.h" -#include "mainpage.h" #include "util/DateTime.h" #include "util/misc.h" diff --git a/retroshare-gui/src/gui/connect/ConfCertDialog.ui b/retroshare-gui/src/gui/connect/ConfCertDialog.ui index 5862464c7..5c6fdabde 100644 --- a/retroshare-gui/src/gui/connect/ConfCertDialog.ui +++ b/retroshare-gui/src/gui/connect/ConfCertDialog.ui @@ -446,6 +446,27 @@ 1 + + stabWidget + pgpfingerprint + peerid + loc + statusline + crypto_info + lastcontact + version + statusmessage + localAddress + localPort + extAddress + extPort + dynDNS + ipAddressList + userCertificateText + _shouldAddSignatures_CB + _shortFormat_CB + _includeIPHistory_CB + diff --git a/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp b/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp index 4ad6315b9..c225d3eac 100755 --- a/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp +++ b/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp @@ -33,6 +33,7 @@ #include #endif +#include "gui/common/FilesDefs.h" #include "gui/settings/rsharesettings.h" #include "util/misc.h" #include "ConnectFriendWizard.h" @@ -145,11 +146,11 @@ ConnectFriendWizard::ConnectFriendWizard(QWidget *parent) : switch (rsFiles->filePermDirectDL()) { case RS_FILE_PERM_DIRECT_DL_YES: - ui->_direct_transfer_CB_2->setIcon(QIcon(":/icons/warning_yellow_128.png")); + ui->_direct_transfer_CB_2->setIcon(FilesDefs::getIconFromQtResourcePath(":/icons/warning_yellow_128.png")); ui->_direct_transfer_CB_2->setToolTip(ui->_direct_transfer_CB_2->toolTip().append(tr("\nWarning: In your File-Transfer option, you select allow direct download to Yes."))); break ; case RS_FILE_PERM_DIRECT_DL_NO: - ui->_direct_transfer_CB_2->setIcon(QIcon(":/icons/warning_yellow_128.png")); + ui->_direct_transfer_CB_2->setIcon(FilesDefs::getIconFromQtResourcePath(":/icons/warning_yellow_128.png")); ui->_direct_transfer_CB_2->setToolTip(ui->_direct_transfer_CB_2->toolTip().append(tr("\nWarning: In your File-Transfer option, you select allow direct download to No."))); break ; diff --git a/retroshare-gui/src/gui/connect/PGPKeyDialog.cpp b/retroshare-gui/src/gui/connect/PGPKeyDialog.cpp index d27e779fd..a082a79eb 100644 --- a/retroshare-gui/src/gui/connect/PGPKeyDialog.cpp +++ b/retroshare-gui/src/gui/connect/PGPKeyDialog.cpp @@ -18,6 +18,7 @@ * * *******************************************************************************/ +#include "gui/common/FilesDefs.h" #include "PGPKeyDialog.h" #include @@ -32,6 +33,8 @@ #include #include +#include + #include "gui/help/browser/helpbrowser.h" #include "gui/common/PeerDefs.h" #include "gui/common/StatusDefs.h" @@ -39,7 +42,6 @@ #include "gui/notifyqt.h" #include "gui/common/AvatarDefs.h" #include "gui/MainWindow.h" -#include "mainpage.h" #include "util/DateTime.h" #include "util/misc.h" @@ -156,11 +158,11 @@ void PGPKeyDialog::load() switch (rsFiles->filePermDirectDL()) { case RS_FILE_PERM_DIRECT_DL_YES: - ui._direct_transfer_CB->setIcon(QIcon(":/icons/warning_yellow_128.png")); + ui._direct_transfer_CB->setIcon(FilesDefs::getIconFromQtResourcePath(":/icons/warning_yellow_128.png")); ui._direct_transfer_CB->setToolTip(ui._direct_transfer_CB->toolTip().append(tr("\nWarning: In your File-Transfer option, you select allow direct download to Yes."))); break ; case RS_FILE_PERM_DIRECT_DL_NO: - ui._direct_transfer_CB->setIcon(QIcon(":/icons/warning_yellow_128.png")); + ui._direct_transfer_CB->setIcon(FilesDefs::getIconFromQtResourcePath(":/icons/warning_yellow_128.png")); ui._direct_transfer_CB->setToolTip(ui._direct_transfer_CB->toolTip().append(tr("\nWarning: In your File-Transfer option, you select allow direct download to No."))); break ; diff --git a/retroshare-gui/src/gui/elastic/elnode.cpp b/retroshare-gui/src/gui/elastic/elnode.cpp index 0fef49cba..86bb4e31e 100644 --- a/retroshare-gui/src/gui/elastic/elnode.cpp +++ b/retroshare-gui/src/gui/elastic/elnode.cpp @@ -20,6 +20,7 @@ // This code is inspired from http://doc.qt.io/qt-5/qtwidgets-graphicsview-elasticnodes-node-cpp.html +#include "gui/common/FilesDefs.h" #include #include @@ -366,11 +367,11 @@ void Node::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) QMenu contextMnu ; if(_type == GraphWidget::ELASTIC_NODE_TYPE_FRIEND) - contextMnu.addAction(QIcon(IMAGE_DENIED), QObject::tr( "Deny friend" ), this, SLOT(denyFriend()) ); + contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_DENIED), QObject::tr( "Deny friend" ), this, SLOT(denyFriend()) ); else if(_type != GraphWidget::ELASTIC_NODE_TYPE_OWN) - contextMnu.addAction(QIcon(IMAGE_MAKEFRIEND), QObject::tr( "Make friend" ), this, SLOT(makeFriend()) ); + contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_MAKEFRIEND), QObject::tr( "Make friend" ), this, SLOT(makeFriend()) ); - contextMnu.addAction(QIcon(IMAGE_MAKEFRIEND), QObject::tr( "Peer details" ), this, SLOT(peerDetails()) ); + contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_MAKEFRIEND), QObject::tr( "Peer details" ), this, SLOT(peerDetails()) ); contextMnu.exec(event->screenPos()); } diff --git a/retroshare-gui/src/gui/feeds/GxsChannelGroupItem.cpp b/retroshare-gui/src/gui/feeds/GxsChannelGroupItem.cpp index e1c9a028f..8f53b5fe4 100644 --- a/retroshare-gui/src/gui/feeds/GxsChannelGroupItem.cpp +++ b/retroshare-gui/src/gui/feeds/GxsChannelGroupItem.cpp @@ -24,6 +24,7 @@ #include "FeedHolder.h" #include "util/qtthreadsutils.h" +#include "gui/common/FilesDefs.h" #include "gui/NewsFeed.h" #include "gui/RetroShareLink.h" @@ -187,13 +188,13 @@ void GxsChannelGroupItem::doExpand(bool open) if (open) { ui->expandFrame->show(); - ui->expandButton->setIcon(QIcon(QString(":/icons/png/up-arrow.png"))); + ui->expandButton->setIcon(FilesDefs::getIconFromQtResourcePath(QString(":/icons/png/up-arrow.png"))); ui->expandButton->setToolTip(tr("Hide")); } else { ui->expandFrame->hide(); - ui->expandButton->setIcon(QIcon(QString(":/icons/png/down-arrow.png"))); + ui->expandButton->setIcon(FilesDefs::getIconFromQtResourcePath(QString(":/icons/png/down-arrow.png"))); ui->expandButton->setToolTip(tr("Expand")); } diff --git a/retroshare-gui/src/gui/feeds/GxsForumGroupItem.cpp b/retroshare-gui/src/gui/feeds/GxsForumGroupItem.cpp index 4a559e001..5df1a8906 100644 --- a/retroshare-gui/src/gui/feeds/GxsForumGroupItem.cpp +++ b/retroshare-gui/src/gui/feeds/GxsForumGroupItem.cpp @@ -22,6 +22,7 @@ #include "ui_GxsForumGroupItem.h" #include "gui/NewsFeed.h" +#include "gui/common/FilesDefs.h" #include "FeedHolder.h" #include "gui/RetroShareLink.h" #include "util/qtthreadsutils.h" @@ -251,13 +252,13 @@ void GxsForumGroupItem::doExpand(bool open) if (open) { ui->expandFrame->show(); - ui->expandButton->setIcon(QIcon(QString(":/icons/png/up-arrow.png"))); + ui->expandButton->setIcon(FilesDefs::getIconFromQtResourcePath(QString(":/icons/png/up-arrow.png"))); ui->expandButton->setToolTip(tr("Hide")); } else { ui->expandFrame->hide(); - ui->expandButton->setIcon(QIcon(QString(":/icons/png/down-arrow.png"))); + ui->expandButton->setIcon(FilesDefs::getIconFromQtResourcePath(QString(":/icons/png/down-arrow.png"))); ui->expandButton->setToolTip(tr("Expand")); } diff --git a/retroshare-gui/src/gui/feeds/GxsForumMsgItem.cpp b/retroshare-gui/src/gui/feeds/GxsForumMsgItem.cpp index f6afc8cdd..4d4bdd661 100644 --- a/retroshare-gui/src/gui/feeds/GxsForumMsgItem.cpp +++ b/retroshare-gui/src/gui/feeds/GxsForumMsgItem.cpp @@ -28,6 +28,7 @@ #include "FeedHolder.h" #include "gui/RetroShareLink.h" +#include "gui/common/FilesDefs.h" #include "gui/gxs/GxsIdDetails.h" #include "util/HandleRichText.h" #include "util/qtthreadsutils.h" @@ -421,7 +422,7 @@ void GxsForumMsgItem::doExpand(bool open) if (open) { ui->expandFrame->show(); - ui->expandButton->setIcon(QIcon(QString(":/icons/png/up-arrow.png"))); + ui->expandButton->setIcon(FilesDefs::getIconFromQtResourcePath(QString(":/icons/png/up-arrow.png"))); ui->expandButton->setToolTip(tr("Hide")); if (!mParentMessage.mMeta.mMsgId.isNull()) { @@ -434,7 +435,7 @@ void GxsForumMsgItem::doExpand(bool open) { ui->expandFrame->hide(); ui->parentFrame->hide(); - ui->expandButton->setIcon(QIcon(QString(":/icons/png/down-arrow.png"))); + ui->expandButton->setIcon(FilesDefs::getIconFromQtResourcePath(QString(":/icons/png/down-arrow.png"))); ui->expandButton->setToolTip(tr("Expand")); } diff --git a/retroshare-gui/src/gui/feeds/MsgItem.cpp b/retroshare-gui/src/gui/feeds/MsgItem.cpp index 181774a00..a25e97873 100644 --- a/retroshare-gui/src/gui/feeds/MsgItem.cpp +++ b/retroshare-gui/src/gui/feeds/MsgItem.cpp @@ -29,6 +29,7 @@ #include "util/HandleRichText.h" #include "util/DateTime.h" #include "gui/common/AvatarDefs.h" +#include "gui/common/FilesDefs.h" #include "gui/notifyqt.h" #include @@ -231,7 +232,7 @@ void MsgItem::doExpand(bool open) if (open) { expandFrame->show(); - expandButton->setIcon(QIcon(QString(":/icons/png/up-arrow.png"))); + expandButton->setIcon(FilesDefs::getIconFromQtResourcePath(QString(":/icons/png/up-arrow.png"))); expandButton->setToolTip(tr("Hide")); mCloseOnRead = false; @@ -241,7 +242,7 @@ void MsgItem::doExpand(bool open) else { expandFrame->hide(); - expandButton->setIcon(QIcon(QString(":/icons/png/down-arrow.png"))); + expandButton->setIcon(FilesDefs::getIconFromQtResourcePath(QString(":/icons/png/down-arrow.png"))); expandButton->setToolTip(tr("Expand")); } diff --git a/retroshare-gui/src/gui/feeds/NewsFeedUserNotify.cpp b/retroshare-gui/src/gui/feeds/NewsFeedUserNotify.cpp index e71c166f2..65a377edf 100644 --- a/retroshare-gui/src/gui/feeds/NewsFeedUserNotify.cpp +++ b/retroshare-gui/src/gui/feeds/NewsFeedUserNotify.cpp @@ -18,6 +18,7 @@ * * *******************************************************************************/ +#include "gui/common/FilesDefs.h" #include "NewsFeedUserNotify.h" #include "gui/NewsFeed.h" @@ -37,7 +38,7 @@ void NewsFeedUserNotify::newsFeedChanged(int count) QIcon NewsFeedUserNotify::getMainIcon(bool hasNew) { - return hasNew ? QIcon(":/icons/png/newsfeed-notify.png") : QIcon(":/icons/png/newsfeed.png"); + return hasNew ? FilesDefs::getIconFromQtResourcePath(":/icons/png/newsfeed-notify.png") : FilesDefs::getIconFromQtResourcePath(":/icons/png/newsfeed.png"); } unsigned int NewsFeedUserNotify::getNewCount() diff --git a/retroshare-gui/src/gui/feeds/PeerItem.cpp b/retroshare-gui/src/gui/feeds/PeerItem.cpp index 2a6f0b19d..a03572f61 100644 --- a/retroshare-gui/src/gui/feeds/PeerItem.cpp +++ b/retroshare-gui/src/gui/feeds/PeerItem.cpp @@ -26,6 +26,7 @@ #include "retroshare-gui/RsAutoUpdatePage.h" #include "gui/msgs/MessageComposer.h" #include "gui/common/StatusDefs.h" +#include "gui/common/FilesDefs.h" #include "gui/common/AvatarDefs.h" #include "util/DateTime.h" @@ -243,13 +244,13 @@ void PeerItem::doExpand(bool open) if (open) { expandFrame->show(); - expandButton->setIcon(QIcon(QString(":/icons/png/up-arrow.png"))); + expandButton->setIcon(FilesDefs::getIconFromQtResourcePath(QString(":/icons/png/up-arrow.png"))); expandButton->setToolTip(tr("Hide")); } else { expandFrame->hide(); - expandButton->setIcon(QIcon(QString(":/icons/png/down-arrow.png"))); + expandButton->setIcon(FilesDefs::getIconFromQtResourcePath(QString(":/icons/png/down-arrow.png"))); expandButton->setToolTip(tr("Expand")); } diff --git a/retroshare-gui/src/gui/feeds/PostedGroupItem.cpp b/retroshare-gui/src/gui/feeds/PostedGroupItem.cpp index 6b39566aa..90d766bc2 100644 --- a/retroshare-gui/src/gui/feeds/PostedGroupItem.cpp +++ b/retroshare-gui/src/gui/feeds/PostedGroupItem.cpp @@ -25,6 +25,7 @@ #include "util/qtthreadsutils.h" #include "gui/RetroShareLink.h" #include "gui/gxs/GxsIdDetails.h" +#include "gui/common/FilesDefs.h" /**** * #define DEBUG_ITEM 1 @@ -204,13 +205,13 @@ void PostedGroupItem::doExpand(bool open) if (open) { ui->expandFrame->show(); - ui->expandButton->setIcon(QIcon(QString(":/icons/png/up-arrow.png"))); + ui->expandButton->setIcon(FilesDefs::getIconFromQtResourcePath(QString(":/icons/png/up-arrow.png"))); ui->expandButton->setToolTip(tr("Hide")); } else { ui->expandFrame->hide(); - ui->expandButton->setIcon(QIcon(QString(":/icons/png/down-arrow.png"))); + ui->expandButton->setIcon(FilesDefs::getIconFromQtResourcePath(QString(":/icons/png/down-arrow.png"))); ui->expandButton->setToolTip(tr("Expand")); } diff --git a/retroshare-gui/src/gui/feeds/SecurityIpItem.cpp b/retroshare-gui/src/gui/feeds/SecurityIpItem.cpp index 590bd0588..6e543108d 100644 --- a/retroshare-gui/src/gui/feeds/SecurityIpItem.cpp +++ b/retroshare-gui/src/gui/feeds/SecurityIpItem.cpp @@ -29,6 +29,7 @@ #include "util/DateTime.h" #include "gui/common/PeerDefs.h" #include "gui/common/RsBanListDefs.h" +#include "gui/common/FilesDefs.h" #include #include @@ -199,13 +200,13 @@ void SecurityIpItem::doExpand(bool open) if (open) { ui->expandFrame->show(); - ui->expandButton->setIcon(QIcon(":/icons/png/up-arrow.png")); + ui->expandButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/icons/png/up-arrow.png")); ui->expandButton->setToolTip(tr("Hide")); } else { ui->expandFrame->hide(); - ui->expandButton->setIcon(QIcon(":/icons/png/down-arrow.png")); + ui->expandButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/icons/png/down-arrow.png")); ui->expandButton->setToolTip(tr("Expand")); } diff --git a/retroshare-gui/src/gui/feeds/SecurityItem.cpp b/retroshare-gui/src/gui/feeds/SecurityItem.cpp index aedfd4e6c..b2bbc2cf3 100644 --- a/retroshare-gui/src/gui/feeds/SecurityItem.cpp +++ b/retroshare-gui/src/gui/feeds/SecurityItem.cpp @@ -29,6 +29,7 @@ #include "gui/common/StatusDefs.h" #include "gui/connect/ConfCertDialog.h" #include "gui/connect/PGPKeyDialog.h" +#include "gui/common/FilesDefs.h" #include "gui/connect/ConnectFriendWizard.h" #include "gui/common/AvatarDefs.h" #include "util/DateTime.h" @@ -295,13 +296,13 @@ void SecurityItem::doExpand(bool open) if (open) { expandFrame->show(); - expandButton->setIcon(QIcon(QString(":/icons/png/up-arrow.png"))); + expandButton->setIcon(FilesDefs::getIconFromQtResourcePath(QString(":/icons/png/up-arrow.png"))); expandButton->setToolTip(tr("Hide")); } else { expandFrame->hide(); - expandButton->setIcon(QIcon(QString(":/icons/png/down-arrow.png"))); + expandButton->setIcon(FilesDefs::getIconFromQtResourcePath(QString(":/icons/png/down-arrow.png"))); expandButton->setToolTip(tr("Expand")); } diff --git a/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.cpp b/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.cpp index a1f824e9a..dfdd9bd04 100644 --- a/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.cpp +++ b/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.cpp @@ -211,14 +211,14 @@ void GxsCommentTreeWidget::customPopUpMenu(const QPoint& /*point*/) contextMnu.addSeparator(); QMenu *rep_menu = contextMnu.addMenu(tr("Reputation")); - action = rep_menu->addAction(QIcon(IMAGE_MESSAGE), tr("Show Reputation"), this, SLOT(showReputation())); + action = rep_menu->addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_MESSAGE), tr("Show Reputation"), this, SLOT(showReputation())); contextMnu.addSeparator(); - action = rep_menu->addAction(QIcon(IMAGE_MESSAGE), tr("Interesting User"), this, SLOT(markInteresting())); + action = rep_menu->addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_MESSAGE), tr("Interesting User"), this, SLOT(markInteresting())); contextMnu.addSeparator(); - action = rep_menu->addAction(QIcon(IMAGE_MESSAGE), tr("Mark Spammy"), this, SLOT(markSpammer())); - action = rep_menu->addAction(QIcon(IMAGE_MESSAGE), tr("Ban User"), this, SLOT(banUser())); + action = rep_menu->addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_MESSAGE), tr("Mark Spammy"), this, SLOT(markSpammer())); + action = rep_menu->addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_MESSAGE), tr("Ban User"), this, SLOT(banUser())); */ } diff --git a/retroshare-gui/src/gui/gxs/GxsCreateCommentDialog.ui b/retroshare-gui/src/gui/gxs/GxsCreateCommentDialog.ui index 550610748..27d128867 100644 --- a/retroshare-gui/src/gui/gxs/GxsCreateCommentDialog.ui +++ b/retroshare-gui/src/gui/gxs/GxsCreateCommentDialog.ui @@ -112,6 +112,12 @@ p, li { white-space: pre-wrap; } true + + true + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + diff --git a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp index b7f3fcf20..1021a3937 100644 --- a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp +++ b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp @@ -151,16 +151,16 @@ void GxsGroupFrameDialog::initUi() /* Initialize group tree */ QToolButton *newGroupButton = new QToolButton(this); - newGroupButton->setIcon(QIcon(icon(ICON_NEW))); + newGroupButton->setIcon(FilesDefs::getIconFromQtResourcePath(icon(ICON_NEW))); newGroupButton->setToolTip(text(TEXT_NEW)); connect(newGroupButton, SIGNAL(clicked()), this, SLOT(newGroup())); ui->groupTreeWidget->addToolButton(newGroupButton); /* Create group tree */ - mYourGroups = ui->groupTreeWidget->addCategoryItem(text(TEXT_YOUR_GROUP), QIcon(icon(ICON_YOUR_GROUP)), true); - mSubscribedGroups = ui->groupTreeWidget->addCategoryItem(text(TEXT_SUBSCRIBED_GROUP), QIcon(icon(ICON_SUBSCRIBED_GROUP)), true); - mPopularGroups = ui->groupTreeWidget->addCategoryItem(text(TEXT_POPULAR_GROUP), QIcon(icon(ICON_POPULAR_GROUP)), false); - mOtherGroups = ui->groupTreeWidget->addCategoryItem(text(TEXT_OTHER_GROUP), QIcon(icon(ICON_OTHER_GROUP)), false); + mYourGroups = ui->groupTreeWidget->addCategoryItem(text(TEXT_YOUR_GROUP), FilesDefs::getIconFromQtResourcePath(icon(ICON_YOUR_GROUP)), true); + mSubscribedGroups = ui->groupTreeWidget->addCategoryItem(text(TEXT_SUBSCRIBED_GROUP), FilesDefs::getIconFromQtResourcePath(icon(ICON_SUBSCRIBED_GROUP)), true); + mPopularGroups = ui->groupTreeWidget->addCategoryItem(text(TEXT_POPULAR_GROUP), FilesDefs::getIconFromQtResourcePath(icon(ICON_POPULAR_GROUP)), false); + mOtherGroups = ui->groupTreeWidget->addCategoryItem(text(TEXT_OTHER_GROUP), FilesDefs::getIconFromQtResourcePath(icon(ICON_OTHER_GROUP)), false); if (text(TEXT_TODO).isEmpty()) { ui->todoPushButton->hide(); @@ -410,8 +410,8 @@ void GxsGroupFrameDialog::groupTreeCustomPopupMenu(QPoint point) { QMenu contextMnu(this); - contextMnu.addAction(QIcon(IMAGE_DELETE), tr("Remove this search"), this, SLOT(removeCurrentSearch()))->setData(search_request_id); - contextMnu.addAction(QIcon(IMAGE_DELETE), tr("Remove all searches"), this, SLOT(removeAllSearches())); + contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_DELETE), tr("Remove this search"), this, SLOT(removeCurrentSearch()))->setData(search_request_id); + contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_DELETE), tr("Remove all searches"), this, SLOT(removeAllSearches())); contextMnu.exec(QCursor::pos()); return ; } @@ -424,7 +424,7 @@ void GxsGroupFrameDialog::groupTreeCustomPopupMenu(QPoint point) { QMenu contextMnu(this); - contextMnu.addAction(QIcon(IMAGE_RETRIEVE), tr("Request data"), this, SLOT(distantRequestGroupData()))->setData(group_id_s); + contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_RETRIEVE), tr("Request data"), this, SLOT(distantRequestGroupData()))->setData(group_id_s); contextMnu.exec(QCursor::pos()); return ; } @@ -442,27 +442,27 @@ void GxsGroupFrameDialog::groupTreeCustomPopupMenu(QPoint point) QMenu contextMnu(this); QAction *action; - action = contextMnu.addAction(QIcon(IMAGE_TABNEW), tr("Open in new tab"), this, SLOT(openInNewTab())); + action = contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_TABNEW), tr("Open in new tab"), this, SLOT(openInNewTab())); if(mGroupId.isNull()) // dont enable the open in tab if a tab is already here action->setEnabled(false); if (isSubscribed) { - action = contextMnu.addAction(QIcon(IMAGE_UNSUBSCRIBE), tr("Unsubscribe"), this, SLOT(unsubscribeGroup())); + action = contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_UNSUBSCRIBE), tr("Unsubscribe"), this, SLOT(unsubscribeGroup())); action->setEnabled (!mGroupId.isNull() && IS_GROUP_SUBSCRIBED(subscribeFlags)); } else { - action = contextMnu.addAction(QIcon(IMAGE_SUBSCRIBE), tr("Subscribe"), this, SLOT(subscribeGroup())); + action = contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_SUBSCRIBE), tr("Subscribe"), this, SLOT(subscribeGroup())); action->setDisabled (mGroupId.isNull() || IS_GROUP_SUBSCRIBED(subscribeFlags)); } contextMnu.addSeparator(); - contextMnu.addAction(QIcon(icon(ICON_NEW)), text(TEXT_NEW), this, SLOT(newGroup())); + contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(icon(ICON_NEW)), text(TEXT_NEW), this, SLOT(newGroup())); - action = contextMnu.addAction(QIcon(IMAGE_INFO), tr("Show Details"), this, SLOT(showGroupDetails())); + action = contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_INFO), tr("Show Details"), this, SLOT(showGroupDetails())); action->setEnabled (!mGroupId.isNull()); - action = contextMnu.addAction(QIcon(IMAGE_EDIT), tr("Edit Details"), this, SLOT(editGroupDetails())); + action = contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_EDIT), tr("Edit Details"), this, SLOT(editGroupDetails())); action->setEnabled (!mGroupId.isNull() && isAdmin); uint32_t current_store_time = checkDelay(mInterface->getStoragePeriod(mGroupId))/86400 ; @@ -472,39 +472,39 @@ void GxsGroupFrameDialog::groupTreeCustomPopupMenu(QPoint point) QAction *actnn = NULL; QMenu *ctxMenu2 = contextMnu.addMenu(tr("Synchronise posts of last...")) ; - actnn = ctxMenu2->addAction(tr(" 5 days" ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant( 5)) ; if(current_sync_time == 5) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));} - actnn = ctxMenu2->addAction(tr(" 2 weeks" ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant( 15)) ; if(current_sync_time == 15) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));} - actnn = ctxMenu2->addAction(tr(" 1 month" ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant( 30)) ; if(current_sync_time == 30) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));} - actnn = ctxMenu2->addAction(tr(" 3 months" ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant( 90)) ; if(current_sync_time == 90) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));} - actnn = ctxMenu2->addAction(tr(" 6 months" ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant(180)) ; if(current_sync_time ==180) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));} - actnn = ctxMenu2->addAction(tr(" 1 year " ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant(365)) ; if(current_sync_time ==365) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));} - actnn = ctxMenu2->addAction(tr(" Indefinitly"),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant( 0)) ; if(current_sync_time == 0) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));} + actnn = ctxMenu2->addAction(tr(" 5 days" ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant( 5)) ; if(current_sync_time == 5) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} + actnn = ctxMenu2->addAction(tr(" 2 weeks" ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant( 15)) ; if(current_sync_time == 15) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} + actnn = ctxMenu2->addAction(tr(" 1 month" ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant( 30)) ; if(current_sync_time == 30) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} + actnn = ctxMenu2->addAction(tr(" 3 months" ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant( 90)) ; if(current_sync_time == 90) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} + actnn = ctxMenu2->addAction(tr(" 6 months" ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant(180)) ; if(current_sync_time ==180) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} + actnn = ctxMenu2->addAction(tr(" 1 year " ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant(365)) ; if(current_sync_time ==365) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} + actnn = ctxMenu2->addAction(tr(" Indefinitly"),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant( 0)) ; if(current_sync_time == 0) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} ctxMenu2 = contextMnu.addMenu(tr("Store posts for at most...")) ; - actnn = ctxMenu2->addAction(tr(" 5 days" ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant( 5)) ; if(current_store_time == 5) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));} - actnn = ctxMenu2->addAction(tr(" 2 weeks" ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant( 15)) ; if(current_store_time == 15) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));} - actnn = ctxMenu2->addAction(tr(" 1 month" ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant( 30)) ; if(current_store_time == 30) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));} - actnn = ctxMenu2->addAction(tr(" 3 months" ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant( 90)) ; if(current_store_time == 90) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));} - actnn = ctxMenu2->addAction(tr(" 6 months" ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant(180)) ; if(current_store_time ==180) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));} - actnn = ctxMenu2->addAction(tr(" 1 year " ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant(365)) ; if(current_store_time ==365) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));} - actnn = ctxMenu2->addAction(tr(" Indefinitly"),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant( 0)) ; if(current_store_time == 0) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));} + actnn = ctxMenu2->addAction(tr(" 5 days" ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant( 5)) ; if(current_store_time == 5) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} + actnn = ctxMenu2->addAction(tr(" 2 weeks" ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant( 15)) ; if(current_store_time == 15) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} + actnn = ctxMenu2->addAction(tr(" 1 month" ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant( 30)) ; if(current_store_time == 30) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} + actnn = ctxMenu2->addAction(tr(" 3 months" ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant( 90)) ; if(current_store_time == 90) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} + actnn = ctxMenu2->addAction(tr(" 6 months" ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant(180)) ; if(current_store_time ==180) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} + actnn = ctxMenu2->addAction(tr(" 1 year " ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant(365)) ; if(current_store_time ==365) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} + actnn = ctxMenu2->addAction(tr(" Indefinitly"),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant( 0)) ; if(current_store_time == 0) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} if (shareKeyType()) { - action = contextMnu.addAction(QIcon(IMAGE_SHARE), tr("Share publish permissions..."), this, SLOT(sharePublishKey())); + action = contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_SHARE), tr("Share publish permissions..."), this, SLOT(sharePublishKey())); action->setEnabled(!mGroupId.isNull() && isPublisher); } if (getLinkType() != RetroShareLink::TYPE_UNKNOWN) { - action = contextMnu.addAction(QIcon(IMAGE_COPYLINK), tr("Copy RetroShare Link"), this, SLOT(copyGroupLink())); + action = contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_COPYLINK), tr("Copy RetroShare Link"), this, SLOT(copyGroupLink())); action->setEnabled(!mGroupId.isNull()); } contextMnu.addSeparator(); - action = contextMnu.addAction(QIcon(":/images/message-mail-read.png"), tr("Mark all as read"), this, SLOT(markMsgAsRead())); + action = contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(":/images/message-mail-read.png"), tr("Mark all as read"), this, SLOT(markMsgAsRead())); action->setEnabled (!mGroupId.isNull() && isSubscribed); - action = contextMnu.addAction(QIcon(":/images/message-mail.png"), tr("Mark all as unread"), this, SLOT(markMsgAsUnread())); + action = contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(":/images/message-mail.png"), tr("Mark all as unread"), this, SLOT(markMsgAsUnread())); action->setEnabled (!mGroupId.isNull() && isSubscribed); /* Add special actions */ @@ -739,7 +739,7 @@ void GxsGroupFrameDialog::loadComment(const RsGxsGroupId &grpId, const QVectorcommentLoad(grpId, msgv,most_recent_msgId); int index = ui->messageTabWidget->addTab(commentDialog, comments); - ui->messageTabWidget->setTabIcon(index, QIcon(IMAGE_COMMENT)); + ui->messageTabWidget->setTabIcon(index, FilesDefs::getIconFromQtResourcePath(IMAGE_COMMENT)); } ui->messageTabWidget->setCurrentWidget(commentDialog); @@ -956,12 +956,12 @@ void GxsGroupFrameDialog::groupInfoToGroupItemInfo(const RsGxsGenericGroupData * #if TOGXS if (groupInfo.mGroupFlags & RS_DISTRIB_AUTHEN_REQ) { groupItemInfo.name += " (" + tr("AUTHD") + ")"; - groupItemInfo.icon = QIcon(IMAGE_GROUPAUTHD); + groupItemInfo.icon = FilesDefs::getIconFromQtResourcePath(IMAGE_GROUPAUTHD); } else #endif { - groupItemInfo.icon = QIcon(icon(ICON_DEFAULT)); + groupItemInfo.icon = FilesDefs::getIconFromQtResourcePath(icon(ICON_DEFAULT)); } } @@ -1209,7 +1209,7 @@ void GxsGroupFrameDialog::searchNetwork(const QString& search_string) if(request_id == 0) return ; - mSearchGroupsItems[request_id] = ui->groupTreeWidget->addSearchItem(tr("Search for")+ " \"" + search_string + "\"",(uint32_t)request_id,QIcon(icon(ICON_SEARCH))); + mSearchGroupsItems[request_id] = ui->groupTreeWidget->addSearchItem(tr("Search for")+ " \"" + search_string + "\"",(uint32_t)request_id,FilesDefs::getIconFromQtResourcePath(icon(ICON_SEARCH))); } void GxsGroupFrameDialog::distantRequestGroupData() diff --git a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.h b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.h index 006f593a4..eaf1d0d34 100644 --- a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.h +++ b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.h @@ -21,8 +21,9 @@ #ifndef _GXSGROUPFRAMEDIALOG_H #define _GXSGROUPFRAMEDIALOG_H +#include + #include "gui/gxs/RsGxsUpdateBroadcastPage.h" -#include "RsAutoUpdatePage.h" #include "gui/RetroShareLink.h" #include "gui/settings/rsharesettings.h" #include "util/RsUserdata.h" diff --git a/retroshare-gui/src/gui/gxs/GxsIdChooser.cpp b/retroshare-gui/src/gui/gxs/GxsIdChooser.cpp index 2db5d8534..6235c025f 100644 --- a/retroshare-gui/src/gui/gxs/GxsIdChooser.cpp +++ b/retroshare-gui/src/gui/gxs/GxsIdChooser.cpp @@ -22,6 +22,7 @@ #include "GxsIdDetails.h" #include "RsGxsUpdateBroadcastBase.h" #include "gui/Identity/IdEditDialog.h" +#include "gui/common/FilesDefs.h" #include "util/misc.h" #include @@ -162,7 +163,7 @@ static void loadPrivateIdsCallback(GxsIdDetailsType type, const RsIdentityDetail break; case GXS_ID_DETAILS_TYPE_BANNED: - icons.push_back(QIcon(BANNED_ICON)) ; + icons.push_back(FilesDefs::getIconFromQtResourcePath(BANNED_ICON)) ; break; } @@ -285,7 +286,7 @@ void GxsIdChooser::loadPrivateIds() QString str = tr("Create new Identity"); QString id = ""; - addItem(QIcon(":/icons/png/add-identity.png"), str, id); + addItem(FilesDefs::getIconFromQtResourcePath(":/icons/png/add-identity.png"), str, id); setItemData(count() - 1, QString("%1_%2").arg(TYPE_CREATE_ID).arg(str), ROLE_SORT); setItemData(count() - 1, TYPE_CREATE_ID, ROLE_TYPE); diff --git a/retroshare-gui/src/gui/gxs/GxsIdDetails.cpp b/retroshare-gui/src/gui/gxs/GxsIdDetails.cpp index 701a9153d..a7d050dd5 100644 --- a/retroshare-gui/src/gui/gxs/GxsIdDetails.cpp +++ b/retroshare-gui/src/gui/gxs/GxsIdDetails.cpp @@ -21,6 +21,7 @@ #include "GxsIdDetails.h" #include "gui/common/AvatarDialog.h" +#include "gui/common/FilesDefs.h" #include "retroshare-gui/RsAutoUpdatePage.h" #include @@ -375,10 +376,10 @@ static bool findTagIcon(int tag_class, int /*tag_type*/, QIcon &icon) { default: case 0: - icon = QIcon(IMAGE_DEV_AMBASSADOR); + icon = FilesDefs::getIconFromQtResourcePath(IMAGE_DEV_AMBASSADOR); break; case 1: - icon = QIcon(IMAGE_DEV_CONTRIBUTOR); + icon = FilesDefs::getIconFromQtResourcePath(IMAGE_DEV_CONTRIBUTOR); break; } return true; @@ -974,7 +975,7 @@ QString GxsIdDetails::getNameForType(GxsIdDetailsType type, const RsIdentityDeta QIcon GxsIdDetails::getLoadingIcon(const RsGxsId &/*id*/) { - return QIcon(IMAGE_LOADING); + return FilesDefs::getIconFromQtResourcePath(IMAGE_LOADING); } bool GxsIdDetails::MakeIdDesc(const RsGxsId &id, bool doIcons, QString &str, QList &icons, QString& comment,uint32_t icon_types) @@ -1005,9 +1006,9 @@ bool GxsIdDetails::MakeIdDesc(const RsGxsId &id, bool doIcons, QString &str, QLi // Cyril: I disabled these three which I believe to have been put for testing purposes. // -// icons.push_back(QIcon(IMAGE_ANON)); -// icons.push_back(QIcon(IMAGE_ANON)); -// icons.push_back(QIcon(IMAGE_ANON)); +// icons.push_back(FilesDefs::getIconFromQtResourcePath(IMAGE_ANON)); +// icons.push_back(FilesDefs::getIconFromQtResourcePath(IMAGE_ANON)); +// icons.push_back(FilesDefs::getIconFromQtResourcePath(IMAGE_ANON)); // std::cerr << "GxsIdTreeWidget::MakeIdDesc() ID Ok. Comment: " << comment.toStdString() ; // std::cerr << std::endl; @@ -1083,20 +1084,20 @@ QIcon GxsIdDetails::getReputationIcon( RsReputationLevel icon_index, uint32_t min_reputation ) { if( static_cast(icon_index) >= min_reputation ) - return QIcon(REPUTATION_VOID); + return FilesDefs::getIconFromQtResourcePath(REPUTATION_VOID); switch(icon_index) { case RsReputationLevel::LOCALLY_NEGATIVE: - return QIcon(REPUTATION_LOCALLY_NEGATIVE_ICON); + return FilesDefs::getIconFromQtResourcePath(REPUTATION_LOCALLY_NEGATIVE_ICON); case RsReputationLevel::LOCALLY_POSITIVE: - return QIcon(REPUTATION_LOCALLY_POSITIVE_ICON); + return FilesDefs::getIconFromQtResourcePath(REPUTATION_LOCALLY_POSITIVE_ICON); case RsReputationLevel::REMOTELY_POSITIVE: - return QIcon(REPUTATION_REMOTELY_POSITIVE_ICON); + return FilesDefs::getIconFromQtResourcePath(REPUTATION_REMOTELY_POSITIVE_ICON); case RsReputationLevel::REMOTELY_NEGATIVE: - return QIcon(REPUTATION_REMOTELY_NEGATIVE_ICON); + return FilesDefs::getIconFromQtResourcePath(REPUTATION_REMOTELY_NEGATIVE_ICON); case RsReputationLevel::NEUTRAL: - return QIcon(REPUTATION_NEUTRAL_ICON); + return FilesDefs::getIconFromQtResourcePath(REPUTATION_NEUTRAL_ICON); default: std::cerr << "Asked for unidentified icon index " << static_cast(icon_index) << std::endl; @@ -1112,7 +1113,7 @@ void GxsIdDetails::getIcons(const RsIdentityDetails &details, QList &icon RsReputationLevel::LOCALLY_NEGATIVE ) { icons.clear() ; - icons.push_back(QIcon(IMAGE_BANNED)) ; + icons.push_back(FilesDefs::getIconFromQtResourcePath(IMAGE_BANNED)) ; return ; } @@ -1141,12 +1142,12 @@ void GxsIdDetails::getIcons(const RsIdentityDetails &details, QList &icon if (details.mFlags & RS_IDENTITY_FLAGS_PGP_LINKED) { if (details.mFlags & RS_IDENTITY_FLAGS_PGP_KNOWN) - baseIcon = QIcon(IMAGE_PGPKNOWN); + baseIcon = FilesDefs::getIconFromQtResourcePath(IMAGE_PGPKNOWN); else - baseIcon = QIcon(IMAGE_PGPUNKNOWN); + baseIcon = FilesDefs::getIconFromQtResourcePath(IMAGE_PGPUNKNOWN); } else - baseIcon = QIcon(IMAGE_ANON); + baseIcon = FilesDefs::getIconFromQtResourcePath(IMAGE_ANON); icons.push_back(baseIcon); } diff --git a/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.cpp b/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.cpp index 413aef616..aa9201e95 100644 --- a/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.cpp +++ b/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.cpp @@ -67,7 +67,7 @@ static void fillGxsIdRSTreeWidgetItemCallback(GxsIdDetailsType type, const RsIde break; case GXS_ID_DETAILS_TYPE_BANNED: - icons.push_back(QIcon("BANNED_IMAGE")) ; + icons.push_back(FilesDefs::getIconFromQtResourcePath("BANNED_IMAGE")) ; break ; } diff --git a/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastPage.h b/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastPage.h index 2e13e0910..2a983bf8d 100644 --- a/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastPage.h +++ b/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastPage.h @@ -20,7 +20,7 @@ #pragma once -#include "mainpage.h" +#include #include // This class implement a basic RS functionality which is that widgets displaying info diff --git a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp index ef1a6271e..177289f09 100644 --- a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp +++ b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp @@ -122,9 +122,9 @@ void CreateGxsChannelMsg::contextMenu(QPoint /*point*/) QAction *action ; if(n_file > 1) - action = contextMnu.addAction(QIcon(":/images/pasterslink.png"), tr("Paste RetroShare Links"), this, SLOT(pasteLink())); + action = contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(":/images/pasterslink.png"), tr("Paste RetroShare Links"), this, SLOT(pasteLink())); else - action = contextMnu.addAction(QIcon(":/images/pasterslink.png"), tr("Paste RetroShare Link"), this, SLOT(pasteLink())); + action = contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(":/images/pasterslink.png"), tr("Paste RetroShare Link"), this, SLOT(pasteLink())); action->setDisabled(n_file < 1) ; contextMnu.exec(QCursor::pos()); diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.cpp index 5e1c40fe4..09dec15c7 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.cpp @@ -108,6 +108,7 @@ QString GxsChannelDialog::getHelpString() const

Channels can be made anonymous, or attached to a Retroshare identity so that readers can contact you if needed.\ Enable \"Allow Comments\" if you want to let users comment on your posts.

\

Channel posts are kept for %1 days, and sync-ed over the last %2 days, unless you change this.

\ +

UI Tip: use Control + mouse wheel to control image size in the thumbnail view.

\ ").arg(QString::number(rsGxsChannels->getDefaultStoragePeriod()/86400)).arg(QString::number(rsGxsChannels->getDefaultSyncPeriod()/86400)); return hlp_str ; @@ -251,8 +252,8 @@ void GxsChannelDialog::groupTreeCustomActions(RsGxsGroupId grpId, int subscribeF if (isSubscribed) { - QAction *action = autoDownload ? (new QAction(QIcon(":/images/redled.png"), tr("Disable Auto-Download"), this)) - : (new QAction(QIcon(":/images/start.png"),tr("Enable Auto-Download"), this)); + QAction *action = autoDownload ? (new QAction(FilesDefs::getIconFromQtResourcePath(":/images/redled.png"), tr("Disable Auto-Download"), this)) + : (new QAction(FilesDefs::getIconFromQtResourcePath(":/images/start.png"),tr("Enable Auto-Download"), this)); connect(action, SIGNAL(triggered()), this, SLOT(toggleAutoDownload())); actions.append(action); @@ -263,7 +264,7 @@ void GxsChannelDialog::groupTreeCustomActions(RsGxsGroupId grpId, int subscribeF QMenu *mnu = new QMenu(tr("Set download directory")) ; if(dl_directory.empty()) - mnu->addAction(QIcon(":/images/start.png"),tr("[Default directory]"), this, SLOT(setDefaultDirectory())) ; + mnu->addAction(FilesDefs::getIconFromQtResourcePath(":/images/start.png"),tr("[Default directory]"), this, SLOT(setDefaultDirectory())) ; else mnu->addAction(tr("[Default directory]"), this, SLOT(setDefaultDirectory())) ; @@ -277,7 +278,7 @@ void GxsChannelDialog::groupTreeCustomActions(RsGxsGroupId grpId, int subscribeF if(dl_directory == it->filename) { - action = new QAction(QIcon(":/images/start.png"),QString::fromUtf8(it->filename.c_str()),NULL) ; + action = new QAction(FilesDefs::getIconFromQtResourcePath(":/images/start.png"),QString::fromUtf8(it->filename.c_str()),NULL) ; found = true ; } else @@ -291,7 +292,7 @@ void GxsChannelDialog::groupTreeCustomActions(RsGxsGroupId grpId, int subscribeF if(!found && !dl_directory.empty()) { - QAction *action = new QAction(QIcon(":/images/start.png"),QString::fromUtf8(dl_directory.c_str()),NULL) ; + QAction *action = new QAction(FilesDefs::getIconFromQtResourcePath(":/images/start.png"),QString::fromUtf8(dl_directory.c_str()),NULL) ; connect(action,SIGNAL(triggered()),this,SLOT(setDownloadDirectory())) ; action->setData(QString::fromUtf8(dl_directory.c_str())) ; @@ -391,7 +392,7 @@ void GxsChannelDialog::groupInfoToGroupItemInfo(const RsGxsGenericGroupData *gro groupItemInfo.icon = image; } else - groupItemInfo.icon = QIcon(":icons/png/channel.png"); + groupItemInfo.icon = FilesDefs::getIconFromQtResourcePath(":icons/png/channel.png"); groupItemInfo.description = QString::fromUtf8(channelGroupData->mDescription.c_str()); } diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp index 47f46bfe9..58715e48d 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp @@ -171,7 +171,7 @@ void RsGxsChannelPostsModel::setFilter(const QStringList& strings, uint32_t& cou if(strings.empty()) { mFilteredPosts.clear(); - for(int i=0;i= mColumns) + if(row < 0 || column < 0 || column >= (int)mColumns) return QModelIndex(); quintptr ref = getChildRef(parent.internalId(),column + row*mColumns); @@ -684,7 +684,19 @@ void RsGxsChannelPostsModel::createPostsArray(std::vector& pos } } -void RsGxsChannelPostsModel::setMsgReadStatus(const QModelIndex& i,bool read_status,bool with_children) +void RsGxsChannelPostsModel::setAllMsgReadStatus(bool read_status) +{ + // No need to call preMods()/postMods() here because we're not changing the model + // All operations below are done async + + RsThread::async([this, read_status]() + { + for(uint32_t i=0;imarkRead(RsGxsGrpMsgIdPair(mPosts[i].mMeta.mGroupId,mPosts[i].mMeta.mMsgId),read_status); + }); +} + +void RsGxsChannelPostsModel::setMsgReadStatus(const QModelIndex& i,bool read_status) { if(!i.isValid()) return ; @@ -697,10 +709,7 @@ void RsGxsChannelPostsModel::setMsgReadStatus(const QModelIndex& i,bool read_sta if(!convertRefPointerToTabEntry(ref,entry) || entry >= mFilteredPosts.size()) return ; -#warning TODO -// bool has_unread_below, has_read_below; -// recursSetMsgReadStatus(entry,read_status,with_children) ; -// recursUpdateReadStatusAndTimes(0,has_unread_below,has_read_below); + rsGxsChannels->markRead(RsGxsGrpMsgIdPair(mPosts[mFilteredPosts[entry]].mMeta.mGroupId,mPosts[mFilteredPosts[entry]].mMeta.mMsgId),read_status); } QModelIndex RsGxsChannelPostsModel::getIndexOfMessage(const RsGxsMessageId& mid) const diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.h b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.h index 6ceedddfb..47e0caee5 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.h +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.h @@ -127,7 +127,9 @@ public: void setTextColorMissing (QColor color) { mTextColorMissing = color;} #endif - void setMsgReadStatus(const QModelIndex &i, bool read_status, bool with_children); + void setMsgReadStatus(const QModelIndex &i, bool read_status); + void setAllMsgReadStatus(bool read_status); + void setFilter(const QStringList &strings, uint32_t &count) ; #ifdef TODO diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp index cc60e003b..093c5b12c 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp @@ -102,7 +102,6 @@ void ChannelPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem & RsGxsChannelPost post = index.data(Qt::UserRole).value() ; - painter->save(); painter->fillRect( option.rect, option.backgroundBrush); painter->restore(); @@ -246,7 +245,7 @@ GxsChannelPostsWidgetWithModel::GxsChannelPostsWidgetWithModel(const RsGxsGroupI ui->channelPostFiles_TV->sortByColumn(0, Qt::AscendingOrder); ui->channelFiles_TV->setModel(mChannelFilesModel = new RsGxsChannelPostFilesModel()); - ui->channelFiles_TV->setItemDelegate(new ChannelPostFilesDelegate()); + ui->channelFiles_TV->setItemDelegate(mFilesDelegate = new ChannelPostFilesDelegate()); ui->channelFiles_TV->setPlaceholderText(tr("No files in the channel, or no channel selected")); ui->channelFiles_TV->setSortingEnabled(true); ui->channelFiles_TV->sortByColumn(0, Qt::AscendingOrder); @@ -632,6 +631,7 @@ GxsChannelPostsWidgetWithModel::~GxsChannelPostsWidgetWithModel() processSettings(false); delete(mAutoDownloadAction); + delete mFilesDelegate; delete ui; } @@ -1148,6 +1148,7 @@ public: uint32_t mLastToken; }; +#ifdef TO_REMOVE static void setAllMessagesReadCallback(FeedItem *feedItem, void *data) { GxsChannelPostItem *channelPostItem = dynamic_cast(feedItem); @@ -1164,16 +1165,15 @@ static void setAllMessagesReadCallback(FeedItem *feedItem, void *data) RsGxsGrpMsgIdPair msgPair = std::make_pair(channelPostItem->groupId(), channelPostItem->messageId()); rsGxsChannels->setMessageReadStatus(readData->mLastToken, msgPair, readData->mRead); } +#endif -void GxsChannelPostsWidgetWithModel::setAllMessagesReadDo(bool read, uint32_t &token) +void GxsChannelPostsWidgetWithModel::setAllMessagesReadDo(bool read, uint32_t& /*token*/) { - if (groupId().isNull() || !IS_GROUP_SUBSCRIBED(mGroup.mMeta.mSubscribeFlags)) { - return; - } + if (groupId().isNull() || !IS_GROUP_SUBSCRIBED(mGroup.mMeta.mSubscribeFlags)) + return; - GxsChannelPostsReadData data(read); - //ui->feedWidget->withAll(setAllMessagesReadCallback, &data); + QModelIndex src_index; - token = data.mLastToken; + mChannelPostsModel->setAllMsgReadStatus(read); } diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h index be2ccdf6c..5fb04bb6f 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h @@ -174,6 +174,7 @@ private: RsGxsChannelPostFilesModel *mChannelPostFilesModel; RsGxsChannelPostFilesModel *mChannelFilesModel; ChannelPostDelegate *mChannelPostsDelegate; + ChannelPostFilesDelegate *mFilesDelegate; RsGxsMessageId mSelectedPost; diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp index fd9c591ca..04777fa8c 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp @@ -775,7 +775,7 @@ void GxsForumThreadWidget::togglethreadview_internal() ui->expandButton->setToolTip(tr("Hide")); // } else { // ui->postText->setVisible(false); -// ui->expandButton->setIcon(QIcon(QString(":/images/edit_add24.png"))); +// ui->expandButton->setIcon(FilesDefs::getIconFromQtResourcePath(QString(":/images/edit_add24.png"))); // ui->expandButton->setToolTip(tr("Expand")); // } } diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.cpp index b0dcc0402..7ce84ea5c 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.cpp @@ -228,8 +228,8 @@ void GxsForumsDialog::groupInfoToGroupItemInfo(const RsGxsGenericGroupData *grou groupItemInfo.description = QString::fromUtf8(forumGroupData->mDescription.c_str()); if(IS_GROUP_ADMIN(groupData->mMeta.mSubscribeFlags)) - groupItemInfo.icon = QIcon(":icons/png/forums.png"); + groupItemInfo.icon = FilesDefs::getIconFromQtResourcePath(":icons/png/forums.png"); else if ((IS_GROUP_PGP_AUTHED(groupData->mMeta.mSignFlags)) || (IS_GROUP_MESSAGE_TRACKING(groupData->mMeta.mSignFlags)) ) - groupItemInfo.icon = QIcon(":icons/png/forums-signed.png"); + groupItemInfo.icon = FilesDefs::getIconFromQtResourcePath(":icons/png/forums-signed.png"); } diff --git a/retroshare-gui/src/gui/msgs/MessageComposer.cpp b/retroshare-gui/src/gui/msgs/MessageComposer.cpp index 92f4de457..db3083686 100644 --- a/retroshare-gui/src/gui/msgs/MessageComposer.cpp +++ b/retroshare-gui/src/gui/msgs/MessageComposer.cpp @@ -18,6 +18,7 @@ * * *******************************************************************************/ +#include "gui/common/FilesDefs.h" #include #include #include @@ -696,7 +697,7 @@ void MessageComposer::contextMenuFileList(QPoint) { QMenu contextMnu(this); - QAction *action = contextMnu.addAction(QIcon(":/images/pasterslink.png"), tr("Paste RetroShare Link"), this, SLOT(pasteRecommended())); + QAction *action = contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(":/images/pasterslink.png"), tr("Paste RetroShare Link"), this, SLOT(pasteRecommended())); action->setDisabled(RSLinkClipboard::empty(RetroShareLink::TYPE_FILE)); contextMnu.exec(QCursor::pos()); @@ -805,7 +806,7 @@ void MessageComposer::peerStatusChanged(const QString& peer_id, int status) { QTableWidgetItem *item = ui.recipientWidget->item(row, COLUMN_RECIPIENT_ICON); if (item) - item->setIcon(QIcon(StatusDefs::imageUser(status))); + item->setIcon(FilesDefs::getIconFromQtResourcePath(StatusDefs::imageUser(status))); } } } @@ -1606,7 +1607,7 @@ void MessageComposer::setRecipientToRow(int row, enumType type, destinationType switch(dest_type) { case PEER_TYPE_GROUP: { - icon = QIcon(IMAGE_GROUP16); + icon = FilesDefs::getIconFromQtResourcePath(IMAGE_GROUP16); RsGroupInfo groupInfo; if (rsPeers->getGroupInfo(RsNodeGroupId(id), groupInfo)) { @@ -1652,7 +1653,7 @@ void MessageComposer::setRecipientToRow(int row, enumType type, destinationType // No check of return value. Non existing status info is handled as offline. rsStatus->getStatus(RsPeerId(id), peerStatusInfo); - icon = QIcon(StatusDefs::imageUser(peerStatusInfo.status)); + icon = FilesDefs::getIconFromQtResourcePath(StatusDefs::imageUser(peerStatusInfo.status)); } break ; default: @@ -1928,7 +1929,7 @@ void MessageComposer::setupFileActions() connect(a, SIGNAL(triggered()), this, SLOT(filePrint())); menu->addAction(a); - /*a = new QAction(QIcon(":/images/textedit/fileprint.png"), tr("Print Preview..."), this); + /*a = new QAction(FilesDefs::getIconFromQtResourcePath(":/images/textedit/fileprint.png"), tr("Print Preview..."), this); connect(a, SIGNAL(triggered()), this, SLOT(filePrintPreview())); menu->addAction(a);*/ @@ -2021,7 +2022,7 @@ void MessageComposer::setupContactActions() connect(mActionAddBCC, SIGNAL(triggered(bool)), this, SLOT(addBcc())); mActionAddRecommend = new QAction(tr("Add as Recommend"), this); connect(mActionAddRecommend, SIGNAL(triggered(bool)), this, SLOT(addRecommend())); - mActionContactDetails = new QAction(QIcon(IMAGE_FRIENDINFO), tr("Details"), this); + mActionContactDetails = new QAction(FilesDefs::getIconFromQtResourcePath(IMAGE_FRIENDINFO), tr("Details"), this); connect(mActionContactDetails, SIGNAL(triggered(bool)), this, SLOT(contactDetails())); ui.friendSelectionWidget->addContextMenuAction(mActionAddTo); @@ -2435,9 +2436,9 @@ void MessageComposer::on_contactsdockWidget_visibilityChanged(bool visible) void MessageComposer::updatecontactsviewicons() { if(!ui.contactsdockWidget->isVisible()){ - ui.actionContactsView->setIcon(QIcon(":/icons/mail/contacts.png")); + ui.actionContactsView->setIcon(FilesDefs::getIconFromQtResourcePath(":/icons/mail/contacts.png")); }else{ - ui.actionContactsView->setIcon(QIcon(":/icons/mail/contacts.png")); + ui.actionContactsView->setIcon(FilesDefs::getIconFromQtResourcePath(":/icons/mail/contacts.png")); } } diff --git a/retroshare-gui/src/gui/msgs/MessageUserNotify.cpp b/retroshare-gui/src/gui/msgs/MessageUserNotify.cpp index fa586f1c8..4144867c6 100644 --- a/retroshare-gui/src/gui/msgs/MessageUserNotify.cpp +++ b/retroshare-gui/src/gui/msgs/MessageUserNotify.cpp @@ -18,6 +18,7 @@ * * *******************************************************************************/ +#include "gui/common/FilesDefs.h" #include "MessageUserNotify.h" #include "gui/notifyqt.h" #include "gui/MainWindow.h" @@ -40,12 +41,12 @@ bool MessageUserNotify::hasSetting(QString *name, QString *group) QIcon MessageUserNotify::getIcon() { - return QIcon(":/icons/png/messages.png"); + return FilesDefs::getIconFromQtResourcePath(":/icons/png/messages.png"); } QIcon MessageUserNotify::getMainIcon(bool hasNew) { - return hasNew ? QIcon(":/icons/png/messages-notify.png") : QIcon(":/icons/png/messages.png"); + return hasNew ? FilesDefs::getIconFromQtResourcePath(":/icons/png/messages-notify.png") : FilesDefs::getIconFromQtResourcePath(":/icons/png/messages.png"); } unsigned int MessageUserNotify::getNewCount() diff --git a/retroshare-gui/src/gui/msgs/MessageWidget.cpp b/retroshare-gui/src/gui/msgs/MessageWidget.cpp index 086986230..d3f3af131 100644 --- a/retroshare-gui/src/gui/msgs/MessageWidget.cpp +++ b/retroshare-gui/src/gui/msgs/MessageWidget.cpp @@ -315,8 +315,8 @@ void MessageWidget::msgfilelistWidgetCostumPopupMenu( QPoint /*point*/ ) { QMenu contextMnu(this); - contextMnu.addAction(QIcon(IMAGE_DOWNLOAD), tr("Download"), this, SLOT(getcurrentrecommended())); - contextMnu.addAction(QIcon(IMAGE_DOWNLOADALL), tr("Download all"), this, SLOT(getallrecommended())); + contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_DOWNLOAD), tr("Download"), this, SLOT(getcurrentrecommended())); + contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_DOWNLOADALL), tr("Download all"), this, SLOT(getallrecommended())); contextMnu.exec(QCursor::pos()); } @@ -328,10 +328,10 @@ void MessageWidget::togglefileview(bool noUpdate/*=false*/) */ if (ui.expandFilesButton->isChecked()) { - ui.expandFilesButton->setIcon(QIcon(QString(":/icons/png/down-arrow.png"))); + ui.expandFilesButton->setIcon(FilesDefs::getIconFromQtResourcePath(QString(":/icons/png/down-arrow.png"))); ui.expandFilesButton->setToolTip(tr("Hide the attachment pane")); } else { - ui.expandFilesButton->setIcon(QIcon(QString(":/icons/png/up-arrow.png"))); + ui.expandFilesButton->setIcon(FilesDefs::getIconFromQtResourcePath(QString(":/icons/png/up-arrow.png"))); ui.expandFilesButton->setToolTip(tr("Show the attachment pane")); } if (!noUpdate) diff --git a/retroshare-gui/src/gui/msgs/MessageWindow.cpp b/retroshare-gui/src/gui/msgs/MessageWindow.cpp index 17355143f..ad1067367 100644 --- a/retroshare-gui/src/gui/msgs/MessageWindow.cpp +++ b/retroshare-gui/src/gui/msgs/MessageWindow.cpp @@ -18,6 +18,7 @@ * * *******************************************************************************/ +#include "gui/common/FilesDefs.h" #include "MessageWindow.h" #include "MessageWidget.h" #include "MessageComposer.h" @@ -180,12 +181,12 @@ void MessageWindow::setupFileActions() menuBar()->addMenu(menu); actionSaveAs = menu->addAction(tr("Save &As File")); - actionPrint = menu->addAction(QIcon(":/images/textedit/fileprint.png"), tr("&Print...")); + actionPrint = menu->addAction(FilesDefs::getIconFromQtResourcePath(":/images/textedit/fileprint.png"), tr("&Print...")); actionPrint->setShortcut(QKeySequence::Print); - actionPrintPreview = menu->addAction(QIcon(":/images/textedit/fileprint.png"), tr("Print Preview...")); + actionPrintPreview = menu->addAction(FilesDefs::getIconFromQtResourcePath(":/images/textedit/fileprint.png"), tr("Print Preview...")); -// a = new QAction(QIcon(":/images/textedit/exportpdf.png"), tr("&Export PDF..."), this); +// a = new QAction(FilesDefs::getIconFromQtResourcePath(":/images/textedit/exportpdf.png"), tr("&Export PDF..."), this); // a->setShortcut(Qt::CTRL + Qt::Key_D); // connect(a, SIGNAL(triggered()), this, SLOT(filePrintPdf())); // menu->addAction(a); diff --git a/retroshare-gui/src/gui/msgs/MessagesDialog.cpp b/retroshare-gui/src/gui/msgs/MessagesDialog.cpp index 40b61739a..acb19d900 100644 --- a/retroshare-gui/src/gui/msgs/MessagesDialog.cpp +++ b/retroshare-gui/src/gui/msgs/MessagesDialog.cpp @@ -422,7 +422,7 @@ void MessagesDialog::fillQuickView() // add static items item = new QListWidgetItem(tr("Starred"), ui.quickViewWidget); - item->setIcon(QIcon(IMAGE_STAR_ON)); + item->setIcon(FilesDefs::getIconFromQtResourcePath(IMAGE_STAR_ON)); item->setData(ROLE_QUICKVIEW_TYPE, QUICKVIEW_TYPE_STATIC); item->setData(ROLE_QUICKVIEW_ID, QUICKVIEW_STATIC_ID_STARRED); item->setData(ROLE_QUICKVIEW_TEXT, item->text()); // for updateMessageSummaryList @@ -432,7 +432,7 @@ void MessagesDialog::fillQuickView() } item = new QListWidgetItem(tr("System"), ui.quickViewWidget); - item->setIcon(QIcon(IMAGE_NOTFICATION)); + item->setIcon(FilesDefs::getIconFromQtResourcePath(IMAGE_NOTFICATION)); item->setData(ROLE_QUICKVIEW_TYPE, QUICKVIEW_TYPE_STATIC); item->setData(ROLE_QUICKVIEW_ID, QUICKVIEW_STATIC_ID_SYSTEM); item->setData(ROLE_QUICKVIEW_TEXT, item->text()); // for updateMessageSummaryList @@ -442,7 +442,7 @@ void MessagesDialog::fillQuickView() } item = new QListWidgetItem(tr("Spam"), ui.quickViewWidget); - item->setIcon(QIcon(IMAGE_SPAM_ON)); + item->setIcon(FilesDefs::getIconFromQtResourcePath(IMAGE_SPAM_ON)); item->setData(ROLE_QUICKVIEW_TYPE, QUICKVIEW_TYPE_STATIC); item->setData(ROLE_QUICKVIEW_ID, QUICKVIEW_STATIC_ID_SPAM); item->setData(ROLE_QUICKVIEW_TEXT, item->text()); // for updateMessageSummaryList @@ -452,7 +452,7 @@ void MessagesDialog::fillQuickView() } item = new QListWidgetItem(tr("Attachment"), ui.quickViewWidget); - item->setIcon(QIcon(IMAGE_ATTACHMENT)); + item->setIcon(FilesDefs::getIconFromQtResourcePath(IMAGE_ATTACHMENT)); item->setData(ROLE_QUICKVIEW_TYPE, QUICKVIEW_TYPE_STATIC); item->setData(ROLE_QUICKVIEW_ID, QUICKVIEW_STATIC_ID_ATTACHMENT); item->setData(ROLE_QUICKVIEW_TEXT, item->text()); // for updateMessageSummaryList @@ -584,13 +584,13 @@ void MessagesDialog::messageTreeWidgetCustomPopupMenu(QPoint /*point*/) QMenu contextMnu( this ); - QAction *action = contextMnu.addAction(QIcon(":/images/view_split_top_bottom.png"), tr("Open in a new window"), this, SLOT(openAsWindow())); + QAction *action = contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(":/images/view_split_top_bottom.png"), tr("Open in a new window"), this, SLOT(openAsWindow())); if (nCount != 1) { action->setDisabled(true); } - action = contextMnu.addAction(QIcon(":/images/tab-dock.png"), tr("Open in a new tab"), this, SLOT(openAsTab())); + action = contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(":/images/tab-dock.png"), tr("Open in a new tab"), this, SLOT(openAsTab())); if (nCount != 1) { action->setDisabled(true); } @@ -608,12 +608,12 @@ void MessagesDialog::messageTreeWidgetCustomPopupMenu(QPoint /*point*/) contextMnu.addSeparator(); - action = contextMnu.addAction(QIcon(":/images/message-mail-read.png"), tr("Mark as read"), this, SLOT(markAsRead())); + action = contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(":/images/message-mail-read.png"), tr("Mark as read"), this, SLOT(markAsRead())); if (itemsUnread.isEmpty()) { action->setDisabled(true); } - action = contextMnu.addAction(QIcon(":/images/message-mail.png"), tr("Mark as unread"), this, SLOT(markAsUnread())); + action = contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(":/images/message-mail.png"), tr("Mark as unread"), this, SLOT(markAsUnread())); if (itemsRead.isEmpty()) { action->setDisabled(true); @@ -647,7 +647,7 @@ void MessagesDialog::messageTreeWidgetCustomPopupMenu(QPoint /*point*/) action->setDisabled(true); } - action = contextMnu.addAction(QIcon(IMAGE_MESSAGEREMOVE), (nCount > 1) ? tr("Remove Messages") : tr("Remove Message"), this, SLOT(removemessage())); + action = contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_MESSAGEREMOVE), (nCount > 1) ? tr("Remove Messages") : tr("Remove Message"), this, SLOT(removemessage())); if (nCount == 0) { action->setDisabled(true); } @@ -674,11 +674,11 @@ void MessagesDialog::messageTreeWidgetCustomPopupMenu(QPoint /*point*/) { std::cerr << "Src ID = " << msgInfo.rsgxsid_srcId << std::endl; - contextMnu.addAction(QIcon(IMAGE_AUTHOR_INFO),tr("Show author in People"),this,SLOT(showAuthorInPeopleTab())); + contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_AUTHOR_INFO),tr("Show author in People"),this,SLOT(showAuthorInPeopleTab())); contextMnu.addSeparator(); } - contextMnu.addAction(QIcon(IMAGE_MESSAGE), tr("New Message"), this, SLOT(newmessage())); + contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_MESSAGE), tr("New Message"), this, SLOT(newmessage())); contextMnu.exec(QCursor::pos()); } @@ -767,7 +767,7 @@ void MessagesDialog::openAsTab() return; } - ui.tabWidget->addTab(msgWidget,QIcon(IMAGE_MAIL), msgWidget->subject(true)); + ui.tabWidget->addTab(msgWidget,FilesDefs::getIconFromQtResourcePath(IMAGE_MAIL), msgWidget->subject(true)); ui.tabWidget->setCurrentWidget(msgWidget); connect(msgWidget, SIGNAL(messageRemoved()), this, SLOT(messageRemoved())); @@ -1284,7 +1284,7 @@ void MessagesDialog::updateMessageSummaryList() QFont qf = item->font(); qf.setBold(true); item->setFont(qf); - item->setIcon(QIcon(":/images/folder-inbox-new.png")); + item->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/folder-inbox-new.png")); item->setData(Qt::ForegroundRole, mTextColorInbox); } else @@ -1294,7 +1294,7 @@ void MessagesDialog::updateMessageSummaryList() QFont qf = item->font(); qf.setBold(false); item->setFont(qf); - item->setIcon(QIcon(":/images/folder-inbox.png")); + item->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/folder-inbox.png")); item->setData(Qt::ForegroundRole, QVariant()); } @@ -1553,6 +1553,6 @@ void MessagesDialog::updateInterface() else { ui.tabWidget->setTabText(0, tr("No Box selected.")); - ui.tabWidget->setTabIcon(0, QIcon(":/icons/warning_yellow_128.png")); + ui.tabWidget->setTabIcon(0, FilesDefs::getIconFromQtResourcePath(":/icons/warning_yellow_128.png")); } } diff --git a/retroshare-gui/src/gui/msgs/MessagesDialog.h b/retroshare-gui/src/gui/msgs/MessagesDialog.h index abc80349d..bf0148cf5 100644 --- a/retroshare-gui/src/gui/msgs/MessagesDialog.h +++ b/retroshare-gui/src/gui/msgs/MessagesDialog.h @@ -23,7 +23,8 @@ #include -#include "mainpage.h" +#include + #include "ui_MessagesDialog.h" #define IMAGE_MESSAGES ":/icons/png/message.png" diff --git a/retroshare-gui/src/gui/notifyqt.cpp b/retroshare-gui/src/gui/notifyqt.cpp index e2e933a32..7bb1b6cf2 100644 --- a/retroshare-gui/src/gui/notifyqt.cpp +++ b/retroshare-gui/src/gui/notifyqt.cpp @@ -18,6 +18,7 @@ * * *******************************************************************************/ +#include "gui/common/FilesDefs.h" #include #include @@ -32,7 +33,7 @@ #include #include -#include "RsAutoUpdatePage.h" +#include #include "MainWindow.h" #include "toaster/OnlineToaster.h" @@ -276,7 +277,7 @@ bool NotifyQt::askForPluginConfirmation(const std::string& plugin_file_name, con text += "" ; dialog.setText(text) ; - dialog.setWindowIcon(QIcon(":/icons/logo_128.png")); + dialog.setWindowIcon(FilesDefs::getIconFromQtResourcePath(":/icons/logo_128.png")); dialog.setStandardButtons(QMessageBox::Yes | QMessageBox::No) ; int ret = dialog.exec(); diff --git a/retroshare-gui/src/gui/profile/ProfileManager.cpp b/retroshare-gui/src/gui/profile/ProfileManager.cpp index 0a8a80df6..7041f7201 100644 --- a/retroshare-gui/src/gui/profile/ProfileManager.cpp +++ b/retroshare-gui/src/gui/profile/ProfileManager.cpp @@ -19,6 +19,7 @@ *******************************************************************************/ +#include "gui/common/FilesDefs.h" #include #include #include @@ -67,7 +68,7 @@ void ProfileManager::identityTreeWidgetCostumPopupMenu(QPoint) QMenu contextMnu(this); - QAction *action = contextMnu.addAction(QIcon(IMAGE_EXPORT), tr("Export Identity"), this, SLOT(exportIdentity())); + QAction *action = contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_EXPORT), tr("Export Identity"), this, SLOT(exportIdentity())); action->setEnabled(item != NULL); contextMnu.exec(QCursor::pos()); diff --git a/retroshare-gui/src/gui/settings/AppearancePage.cpp b/retroshare-gui/src/gui/settings/AppearancePage.cpp index 0c3c2c924..02ad43143 100755 --- a/retroshare-gui/src/gui/settings/AppearancePage.cpp +++ b/retroshare-gui/src/gui/settings/AppearancePage.cpp @@ -42,6 +42,7 @@ #include "gui/statusbar/SoundStatus.h" #include "gui/statusbar/ToasterDisable.h" #include "gui/statusbar/SysTrayStatus.h" +#include "gui/common/FilesDefs.h" /** Constructor */ AppearancePage::AppearancePage(QWidget * parent, Qt::WindowFlags flags) @@ -69,7 +70,7 @@ AppearancePage::AppearancePage(QWidget * parent, Qt::WindowFlags flags) /* Populate combo boxes */ foreach (QString code, LanguageSupport::languageCodes()) { - ui.cmboLanguage->addItem(QIcon(":/images/flags/" + code + ".png"), LanguageSupport::languageName(code), code); + ui.cmboLanguage->addItem(FilesDefs::getIconFromQtResourcePath(":/images/flags/" + code + ".png"), LanguageSupport::languageName(code), code); } foreach (QString style, QStyleFactory::keys()) { ui.cmboStyle->addItem(style, style.toLower()); diff --git a/retroshare-gui/src/gui/settings/FileAssociationsPage.cpp b/retroshare-gui/src/gui/settings/FileAssociationsPage.cpp index e6e5f67e3..fe7e36a7b 100755 --- a/retroshare-gui/src/gui/settings/FileAssociationsPage.cpp +++ b/retroshare-gui/src/gui/settings/FileAssociationsPage.cpp @@ -19,6 +19,7 @@ * * *******************************************************************************/ +#include "gui/common/FilesDefs.h" #include "FileAssociationsPage.h" #include "AddFileAssociationDialog.h" //#include "rshare.h" // for Rshare::dataDirectory() method @@ -60,19 +61,19 @@ FileAssociationsPage::FileAssociationsPage(QWidget * parent, Qt::WindowFlags fla QVBoxLayout* pageLay = new QVBoxLayout(this); toolBar = new QToolBar("actions", this); - newAction = new QAction(QIcon(":/icons/png/add.png"), tr("&New"), this); + newAction = new QAction(FilesDefs::getIconFromQtResourcePath(":/icons/png/add.png"), tr("&New"), this); //newAction->setShortcut(tr("Ctrl+N")); newAction->setStatusTip(tr("Add new Association")); connect(newAction, SIGNAL(triggered()), this, SLOT(addnew())); toolBar->addAction(newAction); - editAction = new QAction(QIcon(":/images/kcmsystem24.png"), + editAction = new QAction(FilesDefs::getIconFromQtResourcePath(":/images/kcmsystem24.png"), tr("&Edit"), this); editAction->setStatusTip(tr("Edit this Association")); connect(editAction, SIGNAL(triggered()), this, SLOT(edit())); toolBar->addAction(editAction); - removeAction = new QAction(QIcon(":/images/edit_remove24.png"), + removeAction = new QAction(FilesDefs::getIconFromQtResourcePath(":/images/edit_remove24.png"), tr("&Remove"), this); removeAction->setStatusTip(tr("Remove this Association")); connect(removeAction, SIGNAL(triggered()), this, SLOT(remove())); diff --git a/retroshare-gui/src/gui/settings/ServerPage.cpp b/retroshare-gui/src/gui/settings/ServerPage.cpp index 37291be0f..64392aa08 100755 --- a/retroshare-gui/src/gui/settings/ServerPage.cpp +++ b/retroshare-gui/src/gui/settings/ServerPage.cpp @@ -1352,7 +1352,7 @@ void ServerPage::updateInProxyIndicator() return ; //ui.iconlabel_tor_incoming->setPixmap(QPixmap(ICON_STATUS_UNKNOWN)) ; - //ui.testIncomingTor_PB->setIcon(QIcon(":/loader/circleball-16.gif")) ; + //ui.testIncomingTor_PB->setIcon(FilesDefs::getIconFromQtResourcePath(":/loader/circleball-16.gif")) ; QMovie *movie = new QMovie(":/images/loader/circleball-16.gif"); ui.iconlabel_service_incoming->setMovie(movie); movie->start(); @@ -1846,11 +1846,11 @@ void ServerPage::updateInProxyIndicatorResult(bool success) ui.iconlabel_service_incoming->setPixmap(QPixmap(ICON_STATUS_OK)) ; ui.iconlabel_service_incoming->setToolTip(tr("You are reachable through the hidden service.")) ; - //ui.testIncomingTor_PB->setIcon(QIcon(ICON_STATUS_OK)) ; + //ui.testIncomingTor_PB->setIcon(FilesDefs::getIconFromQtResourcePath(ICON_STATUS_OK)) ; } else { std::cerr <<"Failed!" << std::endl; - //ui.testIncomingTor_PB->setIcon(QIcon(ICON_STATUS_UNKNOWN)) ; + //ui.testIncomingTor_PB->setIcon(FilesDefs::getIconFromQtResourcePath(ICON_STATUS_UNKNOWN)) ; ui.iconlabel_service_incoming->setPixmap(QPixmap(ICON_STATUS_UNKNOWN)) ; ui.iconlabel_service_incoming->setToolTip(tr("The proxy is not enabled or broken.\nAre all services up and running fine??\nAlso check your ports!")) ; } diff --git a/retroshare-gui/src/gui/settings/rsettingswin.h b/retroshare-gui/src/gui/settings/rsettingswin.h index 7a9864fff..a3242aaa4 100755 --- a/retroshare-gui/src/gui/settings/rsettingswin.h +++ b/retroshare-gui/src/gui/settings/rsettingswin.h @@ -21,10 +21,12 @@ #ifndef RSETTINGSWIN_HPP_ #define RSETTINGSWIN_HPP_ +#include "gui/common/FilesDefs.h" #include #include +#include + #include "ui_settingsw.h" -#include "mainpage.h" class FloatingHelpBrowser; @@ -44,7 +46,7 @@ public: void postModDirectories(bool update_local); - virtual QIcon iconPixmap() const { return QIcon(IMAGE_PREFERENCES) ; } //MainPage + virtual QIcon iconPixmap() const { return FilesDefs::getIconFromQtResourcePath(IMAGE_PREFERENCES) ; } //MainPage virtual QString pageName() const { return tr("Preferences") ; } //MainPage protected: diff --git a/retroshare-gui/src/gui/statistics/BwCtrlWindow.h b/retroshare-gui/src/gui/statistics/BwCtrlWindow.h index d47867d4f..4126eb6bc 100644 --- a/retroshare-gui/src/gui/statistics/BwCtrlWindow.h +++ b/retroshare-gui/src/gui/statistics/BwCtrlWindow.h @@ -24,7 +24,7 @@ #include -#include "RsAutoUpdatePage.h" +#include #include "gui/common/RSGraphWidget.h" #include "ui_BwCtrlWindow.h" diff --git a/retroshare-gui/src/gui/statistics/DhtWindow.h b/retroshare-gui/src/gui/statistics/DhtWindow.h index 8199b5a1d..795a80a36 100644 --- a/retroshare-gui/src/gui/statistics/DhtWindow.h +++ b/retroshare-gui/src/gui/statistics/DhtWindow.h @@ -21,7 +21,8 @@ #ifndef RSDHT_WINDOW_H #define RSDHT_WINDOW_H -#include "RsAutoUpdatePage.h" +#include + #include "ui_DhtWindow.h" class DhtWindow : public RsAutoUpdatePage/*, public Ui::DhtWindow*/ { diff --git a/retroshare-gui/src/gui/statistics/GlobalRouterStatistics.cpp b/retroshare-gui/src/gui/statistics/GlobalRouterStatistics.cpp index 0a992353b..1fc583b18 100644 --- a/retroshare-gui/src/gui/statistics/GlobalRouterStatistics.cpp +++ b/retroshare-gui/src/gui/statistics/GlobalRouterStatistics.cpp @@ -126,7 +126,7 @@ void GlobalRouterStatistics::CustomPopupMenu( QPoint ) QTreeWidgetItem *item = treeWidget->currentItem(); if (item) { - contextMnu.addAction(QIcon(":/images/info16.png"), tr("Details"), this, SLOT(personDetails())); + contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(":/images/info16.png"), tr("Details"), this, SLOT(personDetails())); } diff --git a/retroshare-gui/src/gui/statistics/GlobalRouterStatistics.h b/retroshare-gui/src/gui/statistics/GlobalRouterStatistics.h index c8d132740..c8e49fb4a 100644 --- a/retroshare-gui/src/gui/statistics/GlobalRouterStatistics.h +++ b/retroshare-gui/src/gui/statistics/GlobalRouterStatistics.h @@ -24,7 +24,8 @@ #include #include -#include "RsAutoUpdatePage.h" +#include + #include "ui_GlobalRouterStatistics.h" class GlobalRouterStatisticsWidget ; diff --git a/retroshare-gui/src/gui/statistics/GxsIdStatistics.cpp b/retroshare-gui/src/gui/statistics/GxsIdStatistics.cpp new file mode 100644 index 000000000..a09053deb --- /dev/null +++ b/retroshare-gui/src/gui/statistics/GxsIdStatistics.cpp @@ -0,0 +1,588 @@ +/******************************************************************************* + * gui/statistics/GlobalRouterStatistics.cpp * + * * + * Copyright (c) 2011 Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ + +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "GxsIdStatistics.h" + +#include "util/DateTime.h" +#include "util/QtVersion.h" +#include "util/misc.h" +#include "util/qtthreadsutils.h" + +static QColor colorScale(float f) +{ + if(f == 0) + return QColor::fromHsv(0,0,192) ; + else + return QColor::fromHsv((int)((1.0-f)*280),200,255) ; +} + +GxsIdStatistics::GxsIdStatistics(QWidget *parent) + : RsAutoUpdatePage(4000,parent) +{ + setupUi(this) ; + + _stats_F->setWidget(_tst_CW = new GxsIdStatisticsWidget); + m_bProcessSettings = false; + + // load settings + processSettings(true); +} + +GxsIdStatistics::~GxsIdStatistics() +{ + // save settings + processSettings(false); +} + +void GxsIdStatistics::processSettings(bool bLoad) +{ + m_bProcessSettings = true; + + Settings->beginGroup(QString("GlobalRouterStatistics")); + + if (bLoad) { + // load settings + + // state of splitter + //splitter->restoreState(Settings->value("Splitter").toByteArray()); + } else { + // save settings + + // state of splitter + //Settings->setValue("Splitter", splitter->saveState()); + + } + + Settings->endGroup(); + + m_bProcessSettings = false; +} + +void GxsIdStatistics::updateDisplay() +{ + _tst_CW->updateContent() ; + + static rstime_t last_data_update_time = 0; + rstime_t now = time(NULL); + + if(now > last_data_update_time + 60) + { + last_data_update_time = now; + _tst_CW->updateData(); + } +} + +static QString getServiceName(uint32_t s) +{ + switch(s) + { + default: + case 0x0011 /* GOSSIP_DISCOVERY */ : return QObject::tr("Discovery"); + case 0x0012 /* CHAT */ : return QObject::tr("Chat"); + case 0x0013 /* MSG */ : return QObject::tr("Messages"); + case 0x0014 /* TURTLE */ : return QObject::tr("Turtle"); + case 0x0016 /* HEARTBEAT */ : return QObject::tr("Heartbeat"); + case 0x0017 /* FILE_TRANSFER */ : return QObject::tr("File transfer"); + case 0x0018 /* GROUTER */ : return QObject::tr("Global router"); + case 0x0019 /* FILE_DATABASE */ : return QObject::tr("File database"); + case 0x0020 /* SERVICEINFO */ : return QObject::tr("Service info"); + case 0x0021 /* BANDWIDTH_CONTROL */ : return QObject::tr("Bandwidth control"); + case 0x0022 /* MAIL */ : return QObject::tr("Mail"); + case 0x0023 /* DIRECT_MAIL */ : return QObject::tr("Mail"); + case 0x0024 /* DISTANT_MAIL */ : return QObject::tr("Distant mail"); + case 0x0026 /* SERVICE_CONTROL */ : return QObject::tr("Service control"); + case 0x0027 /* DISTANT_CHAT */ : return QObject::tr("Distant chat"); + case 0x0028 /* GXS_TUNNEL */ : return QObject::tr("GXS Tunnel"); + case 0x0101 /* BANLIST */ : return QObject::tr("Ban list"); + case 0x0102 /* STATUS */ : return QObject::tr("Status"); + case 0x0200 /* NXS */ : return QObject::tr("NXS"); + case 0x0211 /* GXSID */ : return QObject::tr("Identities"); + case 0x0212 /* PHOTO */ : return QObject::tr("GXS Photo"); + case 0x0213 /* WIKI */ : return QObject::tr("GXS Wiki"); + case 0x0214 /* WIRE */ : return QObject::tr("GXS TheWire"); + case 0x0215 /* FORUMS */ : return QObject::tr("Forums"); + case 0x0216 /* POSTED */ : return QObject::tr("Boards"); + case 0x0217 /* CHANNELS */ : return QObject::tr("Channels"); + case 0x0218 /* GXSCIRCLE */ : return QObject::tr("Circles"); + /// entiti not gxs, but used with :dentities. + case 0x0219 /* REPUTATION */ : return QObject::tr("Reputation"); + case 0x0220 /* GXS_RECOGN */ : return QObject::tr("Recogn"); + case 0x0230 /* GXS_TRANS */ : return QObject::tr("GXS Transport"); + case 0x0240 /* JSONAPI */ : return QObject::tr("JSon API"); + + } +} + +static QString getUsageStatisticsName(RsIdentityUsage::UsageCode code) +{ + switch(code) + { + default: + case RsIdentityUsage::UNKNOWN_USAGE : return QObject::tr("Unknown"); + case RsIdentityUsage::GROUP_ADMIN_SIGNATURE_CREATION : return QObject::tr("Group admin signature creation"); + case RsIdentityUsage::GROUP_ADMIN_SIGNATURE_VALIDATION : return QObject::tr("Group admin signature validation"); + case RsIdentityUsage::GROUP_AUTHOR_SIGNATURE_CREATION : return QObject::tr("Group author signature creation"); + case RsIdentityUsage::GROUP_AUTHOR_SIGNATURE_VALIDATION : return QObject::tr("Group author signature validation"); + case RsIdentityUsage::MESSAGE_AUTHOR_SIGNATURE_CREATION : return QObject::tr("Message author signature creation"); + case RsIdentityUsage::MESSAGE_AUTHOR_SIGNATURE_VALIDATION : return QObject::tr("Message author signature validation"); + case RsIdentityUsage::GROUP_AUTHOR_KEEP_ALIVE : return QObject::tr("Routine group author signature check."); + case RsIdentityUsage::MESSAGE_AUTHOR_KEEP_ALIVE : return QObject::tr("Routine message author signature check"); + case RsIdentityUsage::CHAT_LOBBY_MSG_VALIDATION : return QObject::tr("Chat room signature validation"); + case RsIdentityUsage::GLOBAL_ROUTER_SIGNATURE_CHECK : return QObject::tr("Global router message validation"); + case RsIdentityUsage::GLOBAL_ROUTER_SIGNATURE_CREATION : return QObject::tr("Global router message creation"); + case RsIdentityUsage::GXS_TUNNEL_DH_SIGNATURE_CHECK : return QObject::tr("DH Key exchange validation for GXS tunnel"); + case RsIdentityUsage::GXS_TUNNEL_DH_SIGNATURE_CREATION : return QObject::tr("DH Key exchange creation for GXS tunnel"); + case RsIdentityUsage::IDENTITY_NEW_FROM_GXS_SYNC : return QObject::tr("New identity from GXS sync"); + case RsIdentityUsage::IDENTITY_NEW_FROM_DISCOVERY : return QObject::tr("New friend identity from discovery"); + case RsIdentityUsage::IDENTITY_NEW_FROM_EXPLICIT_REQUEST : return QObject::tr("New identity requested from friend node"); + case RsIdentityUsage::IDENTITY_GENERIC_SIGNATURE_CHECK : return QObject::tr("Generic signature validation"); + case RsIdentityUsage::IDENTITY_GENERIC_SIGNATURE_CREATION : return QObject::tr("Generic signature creation"); + case RsIdentityUsage::IDENTITY_GENERIC_ENCRYPTION : return QObject::tr("Generic data decryption"); + case RsIdentityUsage::IDENTITY_GENERIC_DECRYPTION : return QObject::tr("Generic data encryption"); + case RsIdentityUsage::CIRCLE_MEMBERSHIP_CHECK : return QObject::tr("Circle membership checking"); + } +} + +void GxsIdStatisticsWidget::updateData() +{ + // get the info, stats, histograms and pass them + + RsThread::async([this]() + { + // 1 - get group data + +#ifdef DEBUG_FORUMS + std::cerr << "Retrieving post data for post " << mThreadId << std::endl; +#endif + + auto pids = new std::list() ; + rsIdentity->getIdentitiesSummaries(*pids) ; + + RsQThreadUtils::postToObject( [pids,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 */ + + const auto& ids(*pids); + + time_t now = time(NULL); + mPublishDateHist = Histogram(now - mNbWeeks*7*86400,now,mNbWeeks); + mLastUsedHist = Histogram(now - 3600*mNbHours,now,mNbHours); + mTotalIdentities = 0; + mUsageMap.clear(); + mPerServiceUsageMap.clear(); + + for(auto& meta:ids) + { + RsIdentityDetails det; + + if(!rsIdentity->getIdDetails(RsGxsId(meta.mGroupId),det)) + continue; + + mPublishDateHist.insert((double)meta.mPublishTs); + mLastUsedHist.insert((double)det.mLastUsageTS); + + for(auto it:det.mUseCases) + { + auto it2 = mUsageMap.find(it.first.mUsageCode); + if(it2 == mUsageMap.end()) + mUsageMap[it.first.mUsageCode] = 0 ; + + ++mUsageMap[it.first.mUsageCode]; + + uint32_t s = static_cast(it.first.mServiceId); + auto it3 = mPerServiceUsageMap.find(s); + if(it3 == mPerServiceUsageMap.end()) + mPerServiceUsageMap[s] = 0; + + ++mPerServiceUsageMap[s]; + } + + ++mTotalIdentities; + } + + delete pids; + + }, this ); + }); +} + +void GxsIdStatisticsWidget::updateContent() +{ + // Now draw the info int the widget's pixmap + + float size = QFontMetricsF(font()).height() ; + float fact = size/14.0 ; + + QPixmap tmppixmap(mMaxWidth, mMaxHeight); + tmppixmap.fill(Qt::transparent); + setFixedHeight(mMaxHeight); + + QPainter painter(&tmppixmap); + painter.initFrom(this); + painter.setPen(QColor::fromRgb(0,0,0)) ; + + QFont times_f(font());//"Times") ; + QFont monospace_f("Monospace") ; + monospace_f.setStyleHint(QFont::TypeWriter) ; + monospace_f.setPointSize(font().pointSize()) ; + + QFontMetricsF fm_monospace(monospace_f) ; + QFontMetricsF fm_times(times_f) ; + + int cellx = fm_monospace.width(QString(" ")) ; + int celly = fm_monospace.height() ; + + // Display general statistics + + int ox=5*fact,oy=15*fact ; + + painter.setFont(times_f) ; + painter.drawText(ox,oy,tr("Total identities: ")+QString::number(mTotalIdentities)) ; oy += celly*2 ; + + uint32_t total_per_type = 0; + for(auto it:mUsageMap) + total_per_type += it.second; + + painter.setFont(times_f) ; + painter.drawText(ox,oy,tr("Usage types") + "(" + QString::number(total_per_type) + " hits): ") ; oy += 2*celly; + + for(auto it:mUsageMap) + { + painter.drawText(ox+2*cellx,oy, getUsageStatisticsName(it.first) + ": " + QString::number(it.second)) ; + oy += celly ; + } + oy += celly ; + + // Display per-service statistics + + uint32_t total_per_service = 0; + for(auto it:mPerServiceUsageMap) + total_per_service += it.second; + + painter.setFont(times_f) ; + painter.drawText(ox,oy,tr("Usage per service") + "(" + QString::number(total_per_service) + " hits): ") ; oy += 2*celly; + + for(auto it:mPerServiceUsageMap) + { + painter.drawText(ox+2*cellx,oy, getServiceName(it.first) + ": " + QString::number(it.second)) ; + oy += celly ; + } + oy += celly ; + + // Draw the creation time histogram + + painter.setFont(times_f) ; + painter.drawText(ox,oy,tr("Identity age (in weeks):")) ; oy += celly ; + + uint32_t hist_height = 10; + oy += hist_height*celly; + + painter.drawLine(QPoint(ox+4*cellx,oy),QPoint(ox+4*cellx+cellx*mNbWeeks*2,oy)); + painter.drawLine(QPoint(ox+4*cellx,oy),QPoint(ox+4*cellx,oy-celly*hist_height)); + + uint32_t max_entry=0; + for(int i=0;i each [] shows a square (one per friend node) that is the routing probabilities for all connected friends + // computed using the "computeRoutingProbabilitites()" method. + // + // Own key ids + // key service id description + // + // Data items + // Msg id Local origin Destination Time Status + // + QPixmap tmppixmap(maxWidth, maxHeight); + tmppixmap.fill(Qt::transparent); + setFixedHeight(maxHeight); + + QPainter painter(&tmppixmap); + painter.initFrom(this); + painter.setPen(QColor::fromRgb(0,0,0)) ; + + QFont times_f(font());//"Times") ; + QFont monospace_f("Monospace") ; + monospace_f.setStyleHint(QFont::TypeWriter) ; + monospace_f.setPointSize(font().pointSize()) ; + + QFontMetricsF fm_monospace(monospace_f) ; + QFontMetricsF fm_times(times_f) ; + + static const int cellx = fm_monospace.width(QString(" ")) ; + static const int celly = fm_monospace.height() ; + + maxHeight = 500*fact ; + + // std::cerr << "Drawing into pixmap of size " << maxWidth << "x" << maxHeight << std::endl; + // draw... + int ox=5*fact,oy=5*fact ; + + + painter.setFont(times_f) ; + painter.drawText(ox,oy+celly,tr("Managed keys")+":" + QString::number(matrix_info.published_keys.size())) ; oy += celly*2 ; + + painter.setFont(monospace_f) ; + for(std::map::const_iterator it(matrix_info.published_keys.begin());it!=matrix_info.published_keys.end();++it) + { + QString packet_string ; + packet_string += QString::fromStdString(it->second.authentication_key.toStdString()) ; + packet_string += tr(" : Service ID =")+" "+QString::number(it->second.service_id,16) ; + packet_string += " \""+QString::fromUtf8(it->second.description_string.c_str()) + "\"" ; + + painter.drawText(ox+2*cellx,oy+celly,packet_string ) ; oy += celly ; + } + oy += celly ; + + + std::map > tos ; + + // Now draw the matrix + + QString prob_string ; + painter.setFont(times_f) ; + QString Q = tr("Routing matrix (") ; + + painter.drawText(ox+0*cellx,oy+fm_times.height(),Q) ; + + // draw scale + + for(int i=0;i<100*fact;++i) + { + painter.setPen(colorScale(i/100.0/fact)) ; + painter.drawLine(ox+fm_times.width(Q)+i,oy+fm_times.height()*0.5,ox+fm_times.width(Q)+i,oy+fm_times.height()) ; + } + painter.setPen(QColor::fromRgb(0,0,0)) ; + + painter.drawText(ox+fm_times.width(Q) + 102*fact,oy+celly,")") ; + + oy += celly ; + oy += celly ; + + //static const int MaxKeySize = 20*fact ; + painter.setFont(monospace_f) ; + + int n=0; + QString ids; + std::vector current_probs ; + int current_oy = 0 ; + + mMinWheelZoneX = ox+2*cellx ; + mMinWheelZoneY = oy ; + + RsGxsId current_id ; + float current_width=0 ; + + for(std::map >::const_iterator it(matrix_info.per_friend_probabilities.begin());it!=matrix_info.per_friend_probabilities.end();++it,++n) + if(n >= mCurrentN-PARTIAL_VIEW_SIZE/2 && n <= mCurrentN+PARTIAL_VIEW_SIZE/2) + { + ids = QString::fromStdString(it->first.toStdString())+" : " ; + painter.drawText(ox+2*cellx,oy+celly,ids) ; + + for(uint32_t i=0;isecond[i])) ; + + if(n == mCurrentN) + { + current_probs = it->second ; + current_oy = oy ; + current_id = it->first ; + current_width = ox+matrix_info.friend_ids.size()*cellx+fm_monospace.width(ids); + } + + oy += celly ; + } + mMaxWheelZoneX = ox+matrix_info.friend_ids.size()*cellx + fm_monospace.width(ids); + + RsIdentityDetails iddetails ; + if(rsIdentity->getIdDetails(current_id,iddetails)) + painter.drawText(current_width+cellx, current_oy+celly, QString::fromUtf8(iddetails.mNickname.c_str())) ; + else + painter.drawText(current_width+cellx, current_oy+celly, tr("[Unknown identity]")) ; + + mMaxWheelZoneY = oy+celly ; + + painter.setPen(QColor::fromRgb(0,0,0)) ; + + painter.setPen(QColor::fromRgb(127,127,127)); + painter.drawRect(ox+2*cellx,current_oy+0.15*celly,fm_monospace.width(ids)+cellx*matrix_info.friend_ids.size()- 2*cellx,celly) ; + + float total_length = (matrix_info.friend_ids.size()+2)*cellx ; + + if(!current_probs.empty()) + for(uint32_t i=0;igetPeerDetails(matrix_info.friend_ids[i], peer_ssl_details); + + painter.drawLine(x1,y1,x1,y2); + painter.drawLine(x1,y2,x1 + total_length - i*cellx,y2) ; + painter.drawText(cellx+ x1 + total_length - i*cellx,y2+(0.35)*celly, QString::fromUtf8(peer_ssl_details.name.c_str()) + " - " + QString::fromUtf8(peer_ssl_details.location.c_str()) + " ("+QString::number(current_probs[i])+")"); + } + oy += celly * (2+matrix_info.friend_ids.size()); + + oy += celly ; + oy += celly ; + + // update the pixmap + // + pixmap = tmppixmap; + maxHeight = oy ; +} +#endif + +void GxsIdStatisticsWidget::paintEvent(QPaintEvent */*event*/) +{ + QStylePainter(this).drawPixmap(0, 0, pixmap); +} + +void GxsIdStatisticsWidget::resizeEvent(QResizeEvent *event) +{ + QRect rect = geometry(); + + mMaxWidth = rect.width(); + mMaxHeight = rect.height() ; + + QWidget::resizeEvent(event); + updateContent(); +} diff --git a/retroshare-gui/src/gui/statistics/GxsIdStatistics.h b/retroshare-gui/src/gui/statistics/GxsIdStatistics.h new file mode 100644 index 000000000..fc0ab93fd --- /dev/null +++ b/retroshare-gui/src/gui/statistics/GxsIdStatistics.h @@ -0,0 +1,95 @@ +/******************************************************************************* + * gui/statistics/GxsIdStatistics.h * + * * + * Copyright (c) 2011 Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ + +#pragma once + +#include +#include +#include + +#include + +#include "Histogram.h" +#include "ui_GxsIdStatistics.h" + +// In this statistics panel we show: +// +// - histograms +// * age histogram of GXS ids (creation time) +// * last usage histogram +// * number of IDs used in each service as reported by UsageStatistics +// +// (note: we could use that histogram class for packets statistics, so we made a separate class) +// +// And general statistics: +// +// - total number of IDs +// - total number of signed IDs +// - total number of own IDs +// +class GxsIdStatisticsWidget ; + +class GxsIdStatistics: public RsAutoUpdatePage, public Ui::GxsIdStatistics +{ + Q_OBJECT + + public: + GxsIdStatistics(QWidget *parent = NULL) ; + ~GxsIdStatistics(); + + void updateContent() ; + + private: + + void processSettings(bool bLoad); + bool m_bProcessSettings; + + virtual void updateDisplay() ; + + GxsIdStatisticsWidget *_tst_CW ; +} ; + +class GxsIdStatisticsWidget: public QWidget +{ + Q_OBJECT + + public: + GxsIdStatisticsWidget(QWidget *parent = NULL) ; + + virtual void paintEvent(QPaintEvent *event) ; + virtual void resizeEvent(QResizeEvent *event); + + void updateContent() ; + void updateData(); + private: + static QString speedString(float f) ; + + QPixmap pixmap ; + int mMaxWidth,mMaxHeight ; + uint32_t mNbWeeks; + uint32_t mNbHours; + uint32_t mTotalIdentities; + Histogram mPublishDateHist ; + Histogram mLastUsedHist ; + + std::map mUsageMap; + std::map mPerServiceUsageMap; +}; + diff --git a/retroshare-gui/src/gui/statistics/GxsIdStatistics.ui b/retroshare-gui/src/gui/statistics/GxsIdStatistics.ui new file mode 100644 index 000000000..0c42ab780 --- /dev/null +++ b/retroshare-gui/src/gui/statistics/GxsIdStatistics.ui @@ -0,0 +1,49 @@ + + + GxsIdStatistics + + + + 0 + 0 + 1468 + 659 + + + + Router Statistics + + + + + + Qt::Vertical + + + + QFrame::NoFrame + + + Qt::ScrollBarAlwaysOff + + + true + + + + + 0 + 0 + 1450 + 641 + + + + + + + + + + + diff --git a/retroshare-gui/src/gui/statistics/GxsTransportStatistics.h b/retroshare-gui/src/gui/statistics/GxsTransportStatistics.h index d23fdaa0f..0b9970c1c 100644 --- a/retroshare-gui/src/gui/statistics/GxsTransportStatistics.h +++ b/retroshare-gui/src/gui/statistics/GxsTransportStatistics.h @@ -27,7 +27,8 @@ #include #include -#include "RsAutoUpdatePage.h" +#include + #include "ui_GxsTransportStatistics.h" #include "gui/gxs/RsGxsUpdateBroadcastPage.h" #include "util/rstime.h" diff --git a/retroshare-gui/src/gui/statistics/Histogram.cpp b/retroshare-gui/src/gui/statistics/Histogram.cpp new file mode 100644 index 000000000..6cd1c4906 --- /dev/null +++ b/retroshare-gui/src/gui/statistics/Histogram.cpp @@ -0,0 +1,55 @@ +/******************************************************************************* + * gui/statistics/Histogram.cpp * + * * + * Copyright (c) 2020 Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ + +#include + +#include "Histogram.h" + +Histogram::Histogram() + : mStart(0),mEnd(1.0),mBins(10,0) +{} + +Histogram::Histogram(double start, double end, int bins) + : mStart(start),mEnd(end),mBins(bins,0) +{ + if(mEnd <= mStart) + std::cerr << "Null histogram created! Please check your parameters" << std::endl; +} + +void Histogram::draw(QPainter *painter) const +{ +} + +void Histogram::insert(double val) +{ + long int bin = (uint32_t)floor((val - mStart)/(mEnd - mStart) * mBins.size()); + + if(bin >= 0 && bin < mBins.size()) + ++mBins[bin]; +} + +std::ostream& operator<<(std::ostream& o,const Histogram& h) +{ + o << "Histogram: [" << h.mStart << "..." << h.mEnd << "] " << h.mBins.size() << " bins." << std::endl; + for(uint32_t i=0;i * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ + +#include +#include + +class QPainter; + +class Histogram +{ + public: + Histogram(); + Histogram(double start, double end, int bins); + + void draw(QPainter *painter) const ; + void insert(double val); + + const std::vector& entries() const { return mBins; } + + private: + double mStart; + double mEnd; + + std::vector mBins; + + friend std::ostream& operator<<(std::ostream& o,const Histogram& h); +}; + diff --git a/retroshare-gui/src/gui/statistics/RttStatistics.h b/retroshare-gui/src/gui/statistics/RttStatistics.h index 2cefe3bb7..32c8b4f1b 100644 --- a/retroshare-gui/src/gui/statistics/RttStatistics.h +++ b/retroshare-gui/src/gui/statistics/RttStatistics.h @@ -22,8 +22,9 @@ #include #include +#include + #include "ui_RttStatistics.h" -#include "RsAutoUpdatePage.h" #include class RttStatisticsWidget ; diff --git a/retroshare-gui/src/gui/statistics/StatisticsWindow.cpp b/retroshare-gui/src/gui/statistics/StatisticsWindow.cpp index bbda5101a..3d3868135 100644 --- a/retroshare-gui/src/gui/statistics/StatisticsWindow.cpp +++ b/retroshare-gui/src/gui/statistics/StatisticsWindow.cpp @@ -34,9 +34,11 @@ #include #include +#include "gui/common/FilesDefs.h" #include #include +#include #include #include #include @@ -52,6 +54,7 @@ #define IMAGE_DHT ":/icons/DHT128.png" #define IMAGE_TURTLE ":/icons/turtle128.png" +#define IMAGE_IDENTITIES ":/icons/avatar_128.png" #define IMAGE_BWGRAPH ":/icons/bandwidth128.png" #define IMAGE_GLOBALROUTER ":/icons/GRouter128.png" #define IMAGE_GXSTRANSPORT ":/icons/transport128.png" @@ -138,19 +141,22 @@ void StatisticsWindow::initStackedPage() QAction *action; ui->stackPages->add(bwdlg = new BwCtrlWindow(ui->stackPages), - action = createPageAction(QIcon(IMAGE_BWGRAPH), tr("Bandwidth"), grp)); + action = createPageAction(FilesDefs::getIconFromQtResourcePath(IMAGE_BWGRAPH), tr("Bandwidth"), grp)); ui->stackPages->add(trsdlg = new TurtleRouterStatistics(ui->stackPages), - action = createPageAction(QIcon(IMAGE_TURTLE), tr("Turtle Router"), grp)); + action = createPageAction(FilesDefs::getIconFromQtResourcePath(IMAGE_TURTLE), tr("Turtle Router"), grp)); + ui->stackPages->add(gxsiddlg = new GxsIdStatistics(ui->stackPages), + action = createPageAction(FilesDefs::getIconFromQtResourcePath(IMAGE_IDENTITIES), tr("Identities"), grp)); + ui->stackPages->add(grsdlg = new GlobalRouterStatistics(ui->stackPages), - action = createPageAction(QIcon(IMAGE_GLOBALROUTER), tr("Global Router"), grp)); + action = createPageAction(FilesDefs::getIconFromQtResourcePath(IMAGE_GLOBALROUTER), tr("Global Router"), grp)); ui->stackPages->add(gxsdlg = new GxsTransportStatistics(ui->stackPages), - action = createPageAction(QIcon(IMAGE_GXSTRANSPORT), tr("Gxs Transport"), grp)); + action = createPageAction(FilesDefs::getIconFromQtResourcePath(IMAGE_GXSTRANSPORT), tr("Gxs Transport"), grp)); ui->stackPages->add(rttdlg = new RttStatistics(ui->stackPages), - action = createPageAction(QIcon(IMAGE_RTT), tr("RTT Statistics"), grp)); + action = createPageAction(FilesDefs::getIconFromQtResourcePath(IMAGE_RTT), tr("RTT Statistics"), grp)); bool showdht = true; RsPeerDetails detail; @@ -162,7 +168,7 @@ void StatisticsWindow::initStackedPage() if(showdht) { ui->stackPages->add(dhtw = new DhtWindow(ui->stackPages), - action = createPageAction(QIcon(IMAGE_DHT), tr("DHT"), grp)); + action = createPageAction(FilesDefs::getIconFromQtResourcePath(IMAGE_DHT), tr("DHT"), grp)); } /*std::cerr << "Looking for interfaces in existing plugins:" << std::endl; @@ -175,7 +181,7 @@ void StatisticsWindow::initStackedPage() if(rsPlugins->plugin(i)->qt_icon() != NULL) icon = *rsPlugins->plugin(i)->qt_icon() ; else - icon = QIcon(":images/extension_48.png") ; + icon = FilesDefs::getIconFromQtResourcePath(":images/extension_48.png") ; std::cerr << " Addign widget page for plugin " << rsPlugins->plugin(i)->getPluginName() << std::endl; MainPage *pluginPage = rsPlugins->plugin(i)->qt_page(); diff --git a/retroshare-gui/src/gui/statistics/StatisticsWindow.h b/retroshare-gui/src/gui/statistics/StatisticsWindow.h index db2d75939..2450812d7 100644 --- a/retroshare-gui/src/gui/statistics/StatisticsWindow.h +++ b/retroshare-gui/src/gui/statistics/StatisticsWindow.h @@ -38,6 +38,7 @@ class TurtleRouterStatistics; class GlobalRouterStatistics; class GxsTransportStatistics; class RttStatistics; +class GxsIdStatistics; class StatisticsWindow : public QMainWindow { Q_OBJECT @@ -57,6 +58,7 @@ public: BwCtrlWindow *bwdlg; TurtleRouterStatistics *trsdlg; RttStatistics *rttdlg; + GxsIdStatistics *gxsiddlg; public slots: diff --git a/retroshare-gui/src/gui/statistics/TurtleRouterDialog.h b/retroshare-gui/src/gui/statistics/TurtleRouterDialog.h index 4fc00b004..94e1ce269 100644 --- a/retroshare-gui/src/gui/statistics/TurtleRouterDialog.h +++ b/retroshare-gui/src/gui/statistics/TurtleRouterDialog.h @@ -22,9 +22,11 @@ #include #include + +#include + #include "ui_TurtleRouterDialog.h" #include "ui_TurtleRouterStatistics.h" -#include "RsAutoUpdatePage.h" class TurtleRouterDialog: public RsAutoUpdatePage, public Ui::TurtleRouterDialogForm diff --git a/retroshare-gui/src/gui/statistics/TurtleRouterStatistics.h b/retroshare-gui/src/gui/statistics/TurtleRouterStatistics.h index f7613de94..7cba37c18 100644 --- a/retroshare-gui/src/gui/statistics/TurtleRouterStatistics.h +++ b/retroshare-gui/src/gui/statistics/TurtleRouterStatistics.h @@ -23,8 +23,10 @@ #include #include #include + +#include + #include "ui_TurtleRouterStatistics.h" -#include "RsAutoUpdatePage.h" class TurtleRouterStatisticsWidget ; diff --git a/retroshare-gui/src/gui/statusbar/SoundStatus.cpp b/retroshare-gui/src/gui/statusbar/SoundStatus.cpp index 531133008..374a61b12 100644 --- a/retroshare-gui/src/gui/statusbar/SoundStatus.cpp +++ b/retroshare-gui/src/gui/statusbar/SoundStatus.cpp @@ -18,6 +18,7 @@ * * *******************************************************************************/ +#include "gui/common/FilesDefs.h" #include #include @@ -54,6 +55,6 @@ SoundStatus::SoundStatus(QWidget *parent) void SoundStatus::mute(bool isMute) { - imageButton->setIcon(QIcon(isMute ? IMAGE_MUTE_ON : IMAGE_MUTE_OFF)); + imageButton->setIcon(FilesDefs::getIconFromQtResourcePath(isMute ? IMAGE_MUTE_ON : IMAGE_MUTE_OFF)); imageButton->setToolTip(isMute ? tr("Sound is off, click to turn it on") : tr("Sound is on, click to turn it off")); } diff --git a/retroshare-gui/src/gui/statusbar/SysTrayStatus.cpp b/retroshare-gui/src/gui/statusbar/SysTrayStatus.cpp index b465e83e3..1f52163ec 100644 --- a/retroshare-gui/src/gui/statusbar/SysTrayStatus.cpp +++ b/retroshare-gui/src/gui/statusbar/SysTrayStatus.cpp @@ -18,6 +18,7 @@ * * *******************************************************************************/ +#include "gui/common/FilesDefs.h" #include #include #include @@ -36,7 +37,7 @@ SysTrayStatus::SysTrayStatus(QWidget *parent) : hbox->setSpacing(0); imageButton = new QPushButton(this); - imageButton->setIcon(QIcon(IMAGE_NOONLINE)); + imageButton->setIcon(FilesDefs::getIconFromQtResourcePath(IMAGE_NOONLINE)); imageButton->setFlat(true); imageButton->setCheckable(false); imageButton->setFocusPolicy(Qt::ClickFocus); diff --git a/retroshare-gui/src/gui/unfinished/ApplicationWindow.cpp b/retroshare-gui/src/gui/unfinished/ApplicationWindow.cpp index 9db4326a4..923d1ba88 100644 --- a/retroshare-gui/src/gui/unfinished/ApplicationWindow.cpp +++ b/retroshare-gui/src/gui/unfinished/ApplicationWindow.cpp @@ -74,7 +74,7 @@ ApplicationWindow::ApplicationWindow(QWidget* parent, Qt::WindowFlags flags) //StatisticDialog *statisticDialog = NULL; //ui.stackPages->add(statisticDialog = new StatisticDialog(ui.stackPages), - // createPageAction(QIcon(IMAGE_STATISTIC), tr("Statistics"), grp)); + // createPageAction(FilesDefs::getIconFromQtResourcePath(IMAGE_STATISTIC), tr("Statistics"), grp)); //GamesDialog *gamesDialog = NULL; //ui.stackPages->add(gamesDialog = new GamesDialog(ui.stackPages), @@ -91,7 +91,7 @@ ApplicationWindow::ApplicationWindow(QWidget* parent, Qt::WindowFlags flags) #ifdef RS_USE_CIRCLES CirclesDialog *circlesDialog = NULL; ui.stackPages->add(circlesDialog = new CirclesDialog(ui.stackPages), - action = createPageAction(QIcon(IMAGE_CIRCLES ), tr("Circles"), grp)); + action = createPageAction(FilesDefs::getIconFromQtResourcePath(IMAGE_CIRCLES ), tr("Circles"), grp)); mNotify.push_back(QPair(circlesDialog, action)); #endif #endif @@ -105,13 +105,13 @@ ApplicationWindow::ApplicationWindow(QWidget* parent, Qt::WindowFlags flags) /*PostedDialog *postedDialog = NULL; ui.stackPages->add(postedDialog = new PostedDialog(ui.stackPages), - action = createPageAction(QIcon(IMAGE_POSTED), tr("Posted Links"), grp)); + action = createPageAction(FilesDefs::getIconFromQtResourcePath(IMAGE_POSTED), tr("Posted Links"), grp)); postedDialog->setup(); mNotify.push_back(QPair(postedDialog, action)); WikiDialog *wikiDialog = NULL; ui.stackPages->add(wikiDialog = new WikiDialog(ui.stackPages), - action = createPageAction(QIcon(IMAGE_WIKI), tr("Wiki Pages"), grp)); + action = createPageAction(FilesDefs::getIconFromQtResourcePath(IMAGE_WIKI), tr("Wiki Pages"), grp)); mNotify.push_back(QPair(wikiDialog, action));*/ // THESE HAVE TO BE CONVERTED TO VEG FORMAT diff --git a/retroshare-gui/src/main.cpp b/retroshare-gui/src/main.cpp index 490878e57..4c427d289 100644 --- a/retroshare-gui/src/main.cpp +++ b/retroshare-gui/src/main.cpp @@ -30,6 +30,7 @@ CrashStackTrace gCrashStackTrace; #include #include +#include "gui/common/FilesDefs.h" #include "gui/FriendsDialog.h" #include "gui/GenCertDialog.h" #include "gui/MainWindow.h" @@ -136,7 +137,7 @@ static void displayWarningAboutDSAKeys() msgBox.setInformativeText(QObject::tr("DSA keys are not yet supported by this version of RetroShare. All these nodes will be unusable. We're very sorry for that.")); msgBox.setStandardButtons(QMessageBox::Ok); msgBox.setDefaultButton(QMessageBox::Ok); - msgBox.setWindowIcon(QIcon(":/icons/logo_128.png")); + msgBox.setWindowIcon(FilesDefs::getIconFromQtResourcePath(":/icons/logo_128.png")); msgBox.exec(); } @@ -270,7 +271,7 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO); msgBox.setInformativeText(QObject::tr("Choose between:
  • Ok to copy the existing keyring from gnupg (safest bet), or
  • Close without saving to start fresh with an empty keyring (you will be asked to create a new PGP key to work with RetroShare, or import a previously saved pgp keypair).
  • Cancel to quit and forge a keyring by yourself (needs some PGP skills)
")); msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Discard | QMessageBox::Cancel); msgBox.setDefaultButton(QMessageBox::Ok); - msgBox.setWindowIcon(QIcon(":/icons/logo_128.png")); + msgBox.setWindowIcon(FilesDefs::getIconFromQtResourcePath(":/icons/logo_128.png")); int ret = msgBox.exec(); @@ -299,7 +300,7 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO); displayWarningAboutDSAKeys(); QMessageBox mb(QMessageBox::Critical, QObject::tr("RetroShare"), "", QMessageBox::Ok); - mb.setWindowIcon(QIcon(":/icons/logo_128.png")); + mb.setWindowIcon(FilesDefs::getIconFromQtResourcePath(":/icons/logo_128.png")); switch (initResult) { diff --git a/retroshare-gui/src/retroshare-gui.pro b/retroshare-gui/src/retroshare-gui.pro index cc2695781..785f1b91f 100644 --- a/retroshare-gui/src/retroshare-gui.pro +++ b/retroshare-gui/src/retroshare-gui.pro @@ -25,8 +25,8 @@ CONFIG += console TARGET = retroshare DEFINES += TARGET=\\\"$${TARGET}\\\" -DEPENDPATH *= $${PWD} $${RS_INCLUDE_DIR} retroshare-gui -INCLUDEPATH *= $${PWD} retroshare-gui +DEPENDPATH *= $${PWD} $${RS_INCLUDE_DIR} +INCLUDEPATH *= $${PWD} !include("../../libretroshare/src/use_libretroshare.pri"):error("Including") @@ -59,7 +59,7 @@ rs_gui_cmark { DUMMYCMARKINPUT = FORCE CMAKE_GENERATOR_OVERRIDE="" - win32-g++:CMAKE_GENERATOR_OVERRIDE="-G \"MSYS Makefiles\"" + win32-g++|win32-clang-g++:CMAKE_GENERATOR_OVERRIDE="-G \"MSYS Makefiles\"" gencmarklib.name = Generating libcmark. gencmarklib.input = DUMMYCMARKINPUT gencmarklib.output = $$clean_path($${CMARK_BUILD_PATH}/src/libcmark.a) @@ -73,6 +73,7 @@ rs_gui_cmark { mkdir -p $${CMARK_BUILD_PATH} && cd $${CMARK_BUILD_PATH} && \ cmake \ -DCMAKE_CXX_COMPILER=$$QMAKE_CXX \ + \"-DCMAKE_CXX_FLAGS=$${QMAKE_CXXFLAGS}\" \ $${CMAKE_GENERATOR_OVERRIDE} \ -DCMAKE_INSTALL_PREFIX=. \ -B. \ @@ -209,7 +210,7 @@ win32-x-g++ { #################################### Windows ##################################### -win32-g++ { +win32-g++|win32-clang-g++ { CONFIG(debug, debug|release) { # show console output CONFIG += console @@ -437,7 +438,9 @@ HEADERS += rshare.h \ gui/FileTransfer/BannedFilesDialog.h \ gui/statistics/TurtleRouterDialog.h \ gui/statistics/TurtleRouterStatistics.h \ + gui/statistics/GxsIdStatistics.h \ gui/statistics/dhtgraph.h \ + gui/statistics/Histogram.h \ gui/statistics/BandwidthGraphWindow.h \ gui/statistics/turtlegraph.h \ gui/statistics/BandwidthStatsWidget.h \ @@ -755,6 +758,7 @@ FORMS += gui/StartDialog.ui \ gui/statistics/DhtWindow.ui \ gui/statistics/TurtleRouterDialog.ui \ gui/statistics/TurtleRouterStatistics.ui \ + gui/statistics/GxsIdStatistics.ui \ gui/statistics/GlobalRouterStatistics.ui \ gui/statistics/GxsTransportStatistics.ui \ gui/statistics/StatisticsWindow.ui \ @@ -995,8 +999,10 @@ SOURCES += main.cpp \ gui/statistics/BandwidthGraphWindow.cpp \ gui/statistics/BandwidthStatsWidget.cpp \ gui/statistics/DhtWindow.cpp \ + gui/statistics/Histogram.cpp \ gui/statistics/TurtleRouterDialog.cpp \ gui/statistics/TurtleRouterStatistics.cpp \ + gui/statistics/GxsIdStatistics.cpp \ gui/statistics/GlobalRouterStatistics.cpp \ gui/statistics/GxsTransportStatistics.cpp \ gui/statistics/StatisticsWindow.cpp \ @@ -1225,25 +1231,39 @@ gxsthewire { DEFINES += RS_USE_WIRE - HEADERS += gui/TheWire/PulseItem.h \ - gui/TheWire/PulseDetails.h \ - gui/TheWire/WireDialog.h \ + HEADERS += gui/TheWire/WireDialog.h \ gui/TheWire/WireGroupItem.h \ gui/TheWire/WireGroupDialog.h \ + gui/TheWire/WireGroupExtra.h \ gui/TheWire/PulseAddDialog.h \ - - FORMS += gui/TheWire/PulseItem.ui \ - gui/TheWire/PulseDetails.ui \ + gui/TheWire/PulseViewItem.h \ + gui/TheWire/PulseTopLevel.h \ + gui/TheWire/PulseViewGroup.h \ + gui/TheWire/PulseReply.h \ + gui/TheWire/PulseReplySeperator.h \ + gui/TheWire/PulseMessage.h \ + + FORMS += gui/TheWire/WireDialog.ui \ gui/TheWire/WireGroupItem.ui \ - gui/TheWire/WireDialog.ui \ + gui/TheWire/WireGroupExtra.ui \ gui/TheWire/PulseAddDialog.ui \ + gui/TheWire/PulseTopLevel.ui \ + gui/TheWire/PulseViewGroup.ui \ + gui/TheWire/PulseReply.ui \ + gui/TheWire/PulseReplySeperator.ui \ + gui/TheWire/PulseMessage.ui \ - SOURCES += gui/TheWire/PulseItem.cpp \ - gui/TheWire/PulseDetails.cpp \ - gui/TheWire/WireDialog.cpp \ + SOURCES += gui/TheWire/WireDialog.cpp \ gui/TheWire/WireGroupItem.cpp \ gui/TheWire/WireGroupDialog.cpp \ + gui/TheWire/WireGroupExtra.cpp \ gui/TheWire/PulseAddDialog.cpp \ + gui/TheWire/PulseViewItem.cpp \ + gui/TheWire/PulseTopLevel.cpp \ + gui/TheWire/PulseViewGroup.cpp \ + gui/TheWire/PulseReply.cpp \ + gui/TheWire/PulseReplySeperator.cpp \ + gui/TheWire/PulseMessage.cpp \ RESOURCES += gui/TheWire/TheWire_images.qrc } diff --git a/retroshare-gui/src/rshare.cpp b/retroshare-gui/src/rshare.cpp index 3898a899a..cbed6698a 100644 --- a/retroshare-gui/src/rshare.cpp +++ b/retroshare-gui/src/rshare.cpp @@ -42,6 +42,7 @@ #include #include +#include "gui/common/FilesDefs.h" #include #include #include @@ -258,7 +259,7 @@ Rshare::Rshare(QStringList args, int &argc, char **argv, const QString &dir) #ifndef __APPLE__ /* set default window icon */ - setWindowIcon(QIcon(":/icons/logo_128.png")); + setWindowIcon(FilesDefs::getIconFromQtResourcePath(":/icons/logo_128.png")); #endif diff --git a/retroshare-service/src/retroshare-service.pro b/retroshare-service/src/retroshare-service.pro index ae3b38049..c9c884cee 100644 --- a/retroshare-service/src/retroshare-service.pro +++ b/retroshare-service/src/retroshare-service.pro @@ -88,7 +88,7 @@ macx { ################################# Windows ########################################## -win32-g++ { +win32-g++|win32-clang-g++ { CONFIG(debug, debug|release) { # show console output CONFIG += console diff --git a/retroshare.pri b/retroshare.pri index 994ced0f2..500300cfd 100644 --- a/retroshare.pri +++ b/retroshare.pri @@ -146,12 +146,12 @@ CONFIG *= rs_bob no_rs_bob:CONFIG -= rs_bob # To enable channel indexing append the following assignation to qmake command -# line "CONFIG+=rs_deep_channel_index" -CONFIG *= no_rs_deep_channel_index -rs_deep_channel_index:CONFIG -= no_rs_deep_channel_index +# line "CONFIG+=rs_deep_channels_index" +CONFIG *= no_rs_deep_channels_index +rs_deep_channels_index:CONFIG -= no_rs_deep_channels_index # To enable deep files indexing append the following assignation to qmake -# command line "CONFIG+=rs_files_index" +# command line "CONFIG+=rs_deep_files_index" CONFIG *= no_rs_deep_files_index rs_deep_files_index:CONFIG -= no_rs_deep_files_index @@ -430,7 +430,7 @@ defined in command line") DEFINES += RS_MINI_VERSION=$${RS_MINI_VERSION} DEFINES += RS_EXTRA_VERSION=\\\"$${RS_EXTRA_VERSION}\\\" } else { - RS_GIT_DESCRIBE = $$system(git describe) + RS_GIT_DESCRIBE = $$system(git describe --long --match v*.*.*) contains(RS_GIT_DESCRIBE, ^v\d+\.\d+\.\d+.*) { RS_GIT_DESCRIBE_SPLIT = $$split(RS_GIT_DESCRIBE, v) RS_GIT_DESCRIBE_SPLIT = $$split(RS_GIT_DESCRIBE_SPLIT, .) @@ -640,7 +640,7 @@ android-* { RS_THREAD_LIB = } -win32-g++ { +win32-g++|win32-clang-g++ { !isEmpty(EXTERNAL_LIB_DIR) { message(Use pre-compiled libraries in $${EXTERNAL_LIB_DIR}.) PREFIX = $$system_path($$EXTERNAL_LIB_DIR) @@ -692,6 +692,10 @@ win32-g++ { message(***retroshare.pri:Win32 PREFIX $$PREFIX INCLUDEPATH $$INCLUDEPATH QMAKE_LIBDIR $$QMAKE_LIBDIR DEFINES $$DEFINES) } +win32-clang-g++ { + QMAKE_CXXFLAGS += -femulated-tls +} + macx-* { rs_macos10.8 { message(***retroshare.pri: Set Target and SDK to MacOS 10.8 )