merged upstream/master

This commit is contained in:
csoler 2018-07-08 21:17:48 +02:00
commit 6848a586f3
No known key found for this signature in database
GPG Key ID: 7BCA522266C0804C
94 changed files with 1618 additions and 758 deletions

View File

@ -52,7 +52,7 @@ on_finish:
#- ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
# clone directory
clone_folder: c:\projects\RetroShare
clone_folder: C:\projects\RetroShare
# fetch repository as zip archive
#shallow_clone: true # default is "false"
@ -62,19 +62,18 @@ clone_depth: 1 # clone entire repository history if not de
environment:
global:
#Qt: https://www.appveyor.com/docs/installed-software#qt
QTDIR: C:\Qt\5.4\mingw491_32
## Qt: https://www.appveyor.com/docs/installed-software#qt
# QTDIR: C:\Qt\5.10.1\mingw53_32
MSYS2_ARCH: i686
TARGET: i686_32-pc-msys
MINGW_PREFIX: C:\msys64\mingw32
RS_DEPLOY: RetroShare_deploy
# build cache to preserve files/folders between builds
cache:
- c:\projects\libs
# - packages -> **\packages.config # preserve "packages" directory in the root of build folder but will reset it if packages.config is modified
# - projectA\libs
# - node_modules # local npm modules
# - %APPDATA%\npm-cache # npm cache
#cache:
# Disabled because it's bigger then supported by appveyor free plan
# - C:\msys64\var\cache\pacman\pkg
# scripts that run after cloning repository
#install:
@ -89,24 +88,12 @@ install:
# Configuring MSys2
- set PATH=C:\msys64\usr\bin;%PATH%
- set PATH=C:\msys64\mingw32\bin;%PATH%
- pacman --noconfirm -S mingw-w64-i686-qt5 mingw-w64-i686-miniupnpc mingw-w64-i686-sqlcipher mingw-w64-i686-libmicrohttpd
#- pacman --noconfirm -S mingw-w64-i686-qt5-static mingw-w64-i686-miniupnpc mingw-w64-i686-sqlcipher mingw-w64-i686-libmicrohttpd
#- set PATH=C:\msys64\mingw32\qt5-static\bin\;%PATH%
# Configuring Qt
- set PATH=%QTDIR%\bin;C:\Qt\Tools\mingw491_32\bin;%PATH%
# Install all default programms
#- C:\msys64\usr\bin\bash -lc "pacman --noconfirm -Sy base-devel git mercurial cvs wget p7zip gcc perl ruby python2" #Already installed
- C:\msys64\usr\bin\bash -lc "pacman --noconfirm -Sy openssl-devel"
# Install toolchain
#- C:\msys64\usr\bin\bash -lc "pacman --noconfirm -S mingw-w64-i686-toolchain mingw-w64-x86_64-toolchain" #Already installed
# Install other binutils
- C:\msys64\usr\bin\bash -lc "pacman --noconfirm -S mingw-w64-i686-curl mingw-w64-x86_64-curl"
- C:\msys64\usr\bin\bash -lc "pacman --noconfirm -S mingw-w64-i686-miniupnpc mingw-w64-x86_64-miniupnpc"
- C:\msys64\usr\bin\bash -lc "pacman --noconfirm -S mingw-w64-i686-sqlite3 mingw-w64-x86_64-sqlite3"
- C:\msys64\usr\bin\bash -lc "pacman --noconfirm -S mingw-w64-i686-speex mingw-w64-x86_64-speex"
- C:\msys64\usr\bin\bash -lc "pacman --noconfirm -S mingw-w64-i686-speexdsp mingw-w64-x86_64-speexdsp"
- C:\msys64\usr\bin\bash -lc "pacman --noconfirm -S mingw-w64-i686-opencv mingw-w64-x86_64-opencv"
- C:\msys64\usr\bin\bash -lc "pacman --noconfirm -S mingw-w64-i686-ffmpeg mingw-w64-x86_64-ffmpeg"
- C:\msys64\usr\bin\bash -lc "pacman --noconfirm -S mingw-w64-i686-libmicrohttpd mingw-w64-x86_64-libmicrohttpd"
- C:\msys64\usr\bin\bash -lc "pacman --noconfirm -S mingw-w64-i686-libxslt mingw-w64-x86_64-libxslt"
- C:\msys64\usr\bin\bash -lc "pacman --noconfirm -S mingw-w64-i686-rapidjson mingw-w64-x86_64-rapidjson"
# - set PATH=%QTDIR%\bin;C:\Qt\Tools\mingw491_32\bin;%PATH%
# Hack for new MSys2
- copy C:\msys64\mingw32\i686-w64-mingw32\bin\ar.exe C:\msys64\mingw32\bin\i686-w64-mingw32-ar.exe
@ -115,10 +102,6 @@ install:
- copy C:\msys64\mingw64\x86_64-w64-mingw32\bin\ar.exe C:\msys64\mingw64\bin\x86_64-w64-mingw32-ar.exe
- copy C:\msys64\mingw64\x86_64-w64-mingw32\bin\ranlib.exe C:\msys64\mingw64\bin\x86_64-w64-mingw32-ranlib.exe
- copy C:\msys64\mingw64\bin\windres.exe C:\msys64\mingw64\bin\x86_64-w64-mingw32-windres.exe
# Build missing Libs
#- C:\msys64\mingw32.exe -lc "cd /c/projects/RetroShare/msys2_build_libs/ && make"
# Clone RetroShare
#- git clone -q --branch={branch} https://github.com/RetroShare/RetroShare.git C:\projects\RetroShare
#---------------------------------#
@ -143,18 +126,112 @@ configuration: Release
# scripts to run before build
before_build:
- cd C:\projects\RetroShare
# - find C:\ > filelist.txt
# scripts to run *after* solution is built and *before* automatic packaging occurs (web apps, NuGet packages, Azure Cloud Services)
before_package:
# scripts to run after build
after_build:
# to run your custom scripts instead of automatic MSBuild
build_script:
- cd C:\projects\RetroShare
- qmake CONFIG+=no_sqlcipher
- make
- qmake -Wall -spec win32-g++ "CONFIG=debug"
- mingw32-make -j3
# scripts to run after build
after_build:
- mkdir %RS_DEPLOY%
- copy retroshare-nogui\src\retroshare-nogui.exe %RS_DEPLOY%\
- copy retroshare-gui\src\retroshare.exe %RS_DEPLOY%\
## In Debug build winedeplyqt forget the non debug Qt libs
- copy C:\msys64\mingw32\bin\Qt5Svg.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\Qt5Core.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\Qt5Multimedia.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\Qt5Widgets.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\Qt5Xml.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\Qt5PrintSupport.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\Qt5Gui.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\Qt5Network.dll %RS_DEPLOY%\
- mkdir %RS_DEPLOY%\playlistformats\
- copy C:\msys64\mingw32\share\qt5\plugins\playlistformats\qtmultimedia_m3u.dll %RS_DEPLOY%\playlistformats
- mkdir %RS_DEPLOY%\printsupport\
- copy C:\msys64\mingw32\share\qt5\plugins\printsupport\windowsprintersupport.dll %RS_DEPLOY%\printsupport\
- mkdir %RS_DEPLOY%\iconengines\
- copy C:\msys64\mingw32\share\qt5\plugins\iconengines\qsvgicon.dll %RS_DEPLOY%\iconengines\
- mkdir %RS_DEPLOY%\bearer\
- copy C:\msys64\mingw32\share\qt5\plugins\bearer\qgenericbearer.dll %RS_DEPLOY%\bearer\
- mkdir %RS_DEPLOY%\mediaservice\
- copy C:\msys64\mingw32\share\qt5\plugins\mediaservice\qtmedia_audioengine.dll %RS_DEPLOY%\mediaservice\
- copy C:\msys64\mingw32\share\qt5\plugins\mediaservice\dsengine.dll %RS_DEPLOY%\mediaservice\
- mkdir %RS_DEPLOY%\styles\
- copy C:\msys64\mingw32\share\qt5\plugins\styles\qwindowsvistastyle.dll %RS_DEPLOY%\styles\
- mkdir %RS_DEPLOY%\imageformats\
- copy C:\msys64\mingw32\share\qt5\plugins\imageformats\qwebp.dll %RS_DEPLOY%\imageformats\
- copy C:\msys64\mingw32\share\qt5\plugins\imageformats\qicns.dll %RS_DEPLOY%\imageformats\
- copy C:\msys64\mingw32\share\qt5\plugins\imageformats\qjpeg.dll %RS_DEPLOY%\imageformats\
- copy C:\msys64\mingw32\share\qt5\plugins\imageformats\qtiff.dll %RS_DEPLOY%\imageformats\
- copy C:\msys64\mingw32\share\qt5\plugins\imageformats\qtga.dll %RS_DEPLOY%\imageformats\
- copy C:\msys64\mingw32\share\qt5\plugins\imageformats\qjp2.dll %RS_DEPLOY%\imageformats\
- copy C:\msys64\mingw32\share\qt5\plugins\imageformats\qico.dll %RS_DEPLOY%\imageformats\
- copy C:\msys64\mingw32\share\qt5\plugins\imageformats\qwbmp.dll %RS_DEPLOY%\imageformats\
- copy C:\msys64\mingw32\share\qt5\plugins\imageformats\qicns.dll %RS_DEPLOY%\imageformats\
- copy C:\msys64\mingw32\share\qt5\plugins\imageformats\qgif.dll %RS_DEPLOY%\imageformats\
- copy C:\msys64\mingw32\share\qt5\plugins\imageformats\qsvg.dll %RS_DEPLOY%\imageformats\
- mkdir %RS_DEPLOY%\platforms\
- copy C:\msys64\mingw32\share\qt5\plugins\platforms\qwindows.dll %RS_DEPLOY%\platforms\
- mkdir %RS_DEPLOY%\audio\
- copy C:\msys64\mingw32\share\qt5\plugins\audio\qtaudio_windows.dll %RS_DEPLOY%\audio\
- windeployqt %RS_DEPLOY%\retroshare.exe
- copy C:\msys64\mingw32\bin\libbz2*.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\libeay32.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\libminiupnpc.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\libsqlcipher*.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\libsqlite3*.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\ssleay32.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\zlib*.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\libgcc_s_dw2*.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\libstdc*.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\libwinpthread*.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\libicu*.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\libpcre*.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\libharfbuzz*.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\libpng*.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\libfreetype*.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\libglib*.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\libgraphite2.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\libintl*.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\libiconv*.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\libjasper*.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\libjpeg*.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\libtiff*.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\libwebp*.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\libwebpdemux*.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\liblzma*.dll %RS_DEPLOY%\
## Needed for libresapi http
- copy C:\msys64\mingw32\bin\libmicrohttpd*.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\libgnutls*.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\libgmp*.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\libhogweed*.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\libidn2*.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\libnettle*.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\libp11-kit*.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\libtasn1*.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\libunistring*.dll %RS_DEPLOY%\
- copy C:\msys64\mingw32\bin\libffi*.dll %RS_DEPLOY%\
- find C:\projects\RetroShare >> filelist.txt
# to disable automatic builds
#build: off
@ -163,7 +240,10 @@ build_script:
# artifacts configuration #
#---------------------------------#
#artifacts:
artifacts:
- path: $(RS_DEPLOY)
- path: '**\*.exe'
- path: filelist.txt
#
# # pushing a single file
# - path: test.zip

View File

@ -1,5 +1,82 @@
retroshare (ZZZZZZ-1.XXXXXX~YYYYYY) YYYYYY; urgency=low
f663600 csoler Fri, 1 Jun 2018 22:27:59 +0200 fixed makeSourcePackage.sh
9b16e33 csoler Fri, 11 May 2018 20:53:29 +0200 removed conflicts to retroshare06 in debian control file
57dde55 csoler Sat, 26 May 2018 11:23:33 +0200 Merge pull request #1269 from PhenomRetroShare/Add_NeverAskMeForExternalLinkActivated
33fe823 csoler Sat, 26 May 2018 11:22:47 +0200 Merge pull request #1271 from sehraf/pr_compile-fix-unused-services
65beb2c csoler Sat, 26 May 2018 11:09:41 +0200 Merge pull request #1275 from sehraf/pr_fix-IDdialog-chat-link
d8b3fc0 csoler Sat, 26 May 2018 11:08:46 +0200 Merge pull request #1274 from PhenomRetroShare/Fix_AppVeyorCompil
f53e5e8 sehraf Fri, 25 May 2018 23:59:02 +0200 Fix displayed chat link name in id dialog before (decimal): Message in chat room 5327517029776505601 after (proper id): Message in chat room LFD6E08C33A98C658
428b331 sehraf Fri, 25 May 2018 23:12:35 +0200 fix for Qt 5.11
7c77e93 Phenom Fri, 25 May 2018 17:32:36 +0200 Fix AppVeyor Compilation
de65cb6 csoler Tue, 22 May 2018 23:59:26 +0200 Merge pull request #1272 from G10h4ck/net_little_fixes
1ad1fdc Gioacc Tue, 22 May 2018 19:17:37 +0200 p3NetMgrIMPL::checkNetAddress() notify if port change
0bf02e2 Gioacc Tue, 22 May 2018 19:14:25 +0200 pqissludp::Initiate_Connection() check remote_addr to be IPv4 before use
0c19a56 sehraf Mon, 21 May 2018 14:55:10 +0200 compile fix gxsphoto
92b21d7 sehraf Mon, 21 May 2018 14:26:46 +0200 compile fix wikipoos
8f107cc Phenom Sat, 19 May 2018 16:37:29 +0200 Add Never Ask Me For External Link Activated
186617f Gioacc Thu, 17 May 2018 16:43:14 +0200 Fix missing include
28981b6 csoler Wed, 16 May 2018 13:37:02 +0200 Merge pull request #1251 from PhenomRetroShare/Fix_Cppcheck(duplInheritedMember)InRsItem
d11f88c csoler Wed, 16 May 2018 13:33:25 +0200 Merge pull request #1252 from PhenomRetroShare/Fix_Cppcheck(duplInheritedMember)InbdNode
2145911 csoler Wed, 16 May 2018 13:30:56 +0200 Merge pull request #1262 from PhenomRetroShare/Fix_PartialDirCheck
e232000 csoler Wed, 16 May 2018 13:28:23 +0200 Merge pull request #1266 from csoler/v0.6-FT
3f88e3e csoler Wed, 16 May 2018 13:24:52 +0200 added check to avoid hashing files that are currently being modified
8451550 csoler Wed, 16 May 2018 11:40:39 +0200 added missing licence to file_tree.h
291c86e csoler Wed, 16 May 2018 11:17:22 +0200 Merge pull request #1265 from csoler/v0.6-GxsFix
4661329 csoler Wed, 16 May 2018 11:15:18 +0200 fixed bug causing new forums and identities to not show up immediately
9f37b63 G10h4c Wed, 16 May 2018 10:49:28 +0200 Merge pull request #1264 from G10h4ck/channel_json_api_v2
181d99e Gioacc Wed, 16 May 2018 10:38:47 +0200 Give proper error message if Qt version is too old
f12cd57 Phenom Sat, 12 May 2018 14:31:17 +0200 Fix Partial Dir Check
57cff61 csoler Fri, 11 May 2018 20:28:53 +0200 fixed merge
ecbd115 csoler Fri, 11 May 2018 20:24:24 +0200 added missing include path for libretroshare/src in libresapi
fe5ea9e csoler Fri, 11 May 2018 17:37:15 +0200 additional fixes to debian packaging files
2173aab csoler Fri, 11 May 2018 17:02:58 +0200 fixed rules file again
84a02cb csoler Fri, 11 May 2018 16:39:49 +0200 added missing targets in rules file
4b6304e csoler Fri, 11 May 2018 16:33:19 +0200 few fixes according to lintian complaints
c2492fe csoler Thu, 10 May 2018 23:10:16 +0200 fixed a few lintian errors in debian/control
9f5409b csoler Thu, 10 May 2018 22:04:11 +0200 fixed email to match mentors login
45fdbb4 csoler Thu, 10 May 2018 22:03:39 +0200 fixed email to match mentors login
b4ada80 csoler Wed, 9 May 2018 13:54:40 +0200 removed > 3.4.1 in debian/control, because pbuilder would not build
e81c82e csoler Wed, 9 May 2018 13:37:25 +0200 added notes file for debian release
4d287d6 csoler Wed, 9 May 2018 13:27:16 +0200 fixed weird mistake in grouter which causes an issue only in gcc > 8
889c277 csoler Wed, 9 May 2018 10:15:32 +0200 fixed packaging script for debian release
f406d9a csoler Wed, 9 May 2018 10:15:02 +0200 updated debian/control to be the control file for stretch. Updated copyright notice
186ff0f csoler Wed, 9 May 2018 10:12:34 +0200 created proper debian changelog using dch and updated project url
6d67936 csoler Tue, 8 May 2018 15:34:44 +0200 Merge pull request #1253 from PhenomRetroShare/Add_LastPostColInGroupTreeWidget
2ebacf3 Phenom Tue, 8 May 2018 12:08:08 +0200 Add Last Post Column in GroupTreeWidget.
4d748bd Phenom Mon, 7 May 2018 18:05:07 +0200 Fix CppCheck duplInheritedMember warning in bdNode
f39fd06 Phenom Mon, 7 May 2018 17:29:11 +0200 Fix CppCheck duplInheritedMember warning in RsItem
1352631 thunde Mon, 7 May 2018 06:42:52 +0200 Updated Windows build environment
38ac234 thunde Mon, 7 May 2018 07:30:29 +0200 Fixed Windows compile with pre-compiled libraries Added new variable EXTERNAL_LIB_DIR to specify path of external libraries
d9a75a9 thunde Sun, 29 Apr 2018 20:40:05 +0200 Added RapidJSON to Windows build environment
5b607ad csoler Sun, 6 May 2018 23:53:45 +0200 Merge pull request #1245 from PhenomRetroShare/AddContextMenuForGxsIdInTextChatBrowser
a6821f4 csoler Sun, 6 May 2018 23:02:18 +0200 Merge pull request #1249 from sehraf/pr_libsecret
c20436e csoler Sun, 6 May 2018 22:59:20 +0200 Merge pull request #1250 from PhenomRetroShare/Fix_CppCheckerWarningInFtController
d8dc2a8 csoler Sun, 6 May 2018 22:57:57 +0200 Merge pull request #1246 from PhenomRetroShare/Add_GxsIdInRestoredChatMsg
dca33da Phenom Sun, 6 May 2018 18:53:29 +0200 Fix CppCheck in ftcontroller.cc
c89e36a sehraf Fri, 4 May 2018 20:52:31 +0200 add auto selection of libsecret with fallback to libgnome-keyring
1129bcb sehraf Fri, 4 May 2018 20:47:41 +0200 Add support for libsecret
10badf5 sehraf Fri, 4 May 2018 20:43:40 +0200 fix retroshare-nogui.pro autologin
676c070 csoler Thu, 3 May 2018 15:55:21 +0200 extended the rapid_json trick to plugins
5f12b60 csoler Thu, 3 May 2018 15:22:39 +0200 added -lgnome-keyring to unix LIBS when rs_autologin is set
bfe8e40 csoler Thu, 3 May 2018 15:22:03 +0200 updated ubuntu changelog
98f0052 Phenom Thu, 3 May 2018 15:04:22 +0200 Add GxsId in Restored Chat Message.
ecba4c2 Phenom Wed, 2 May 2018 20:31:52 +0200 Add Context Menu for GxsId in lobby textBrowser.
91ed367 csoler Thu, 3 May 2018 13:45:44 +0200 added packaging for ubuntu bionic
56e8134 cyril soler Thu, 3 May 2018 11:32:24 +0200 removed sqlite3 lib from ld when using sqlcipher.
1366f61 csoler Wed, 2 May 2018 23:51:46 +0200 Merge pull request #1241 from RetroPooh/chatimgattprev1
8e111c2 csoler Wed, 2 May 2018 22:46:27 +0200 added rapidjson-1.1.0 code hard-coded in the source directory to allow everyone to compile without the need to tweak too much. When v1.1.0 is mainstream (espcially on ubuntu) we can revert back to an external dependency
48c4b4c G10h4c Sat, 28 Apr 2018 09:34:14 +0200 Merge pull request #1242 from beardog108/master
ccede9d G10h4c Sat, 28 Apr 2018 09:33:14 +0200 Merge pull request #1243 from sehraf/pr_fix-make-install
10daf3b sehraf Sat, 28 Apr 2018 09:06:10 +0200 Fix 'make install'
82a00c2 KevinF Fri, 27 Apr 2018 15:34:43 -0500 added rapidjson to package installation command on Debian/OpenSUSE/Arch
be75e89 Gioacc Fri, 27 Apr 2018 20:55:38 +0200 Fix compialtion after merge
f3ae61b Gioacc Fri, 27 Apr 2018 18:17:09 +0200 Merge branch 'json_experiments'
-- Retroshare Dev Team <contact@retroshare.net> Thu, 03 May 2018 12:00:00 +0100
retroshare (0.6.4-1.20180503.676c0701~xenial) xenial; urgency=low
2dc69cb RetroP Fri, 27 Apr 2018 16:50:00 +0300 embed preview for images on file attach in chat
c199199 Gioacc Sun, 8 Apr 2018 12:37:41 +0200 pqissl silence extra debug message
8245d74 csoler Sat, 7 Apr 2018 14:33:58 +0200 Merge pull request #1230 from csoler/master

View File

@ -2,8 +2,8 @@
###################### PARAMETERS ####################
gitpath="https://github.com/RetroShare/RetroShare.git"
#branch="master"
branch="v0.6.4-official_release"
branch="master"
#branch="v0.6.4-official_release"
#bubba3="Y" # comment out to compile for bubba3
######################################################
@ -33,7 +33,7 @@ gpgkey="0932399B"
date=`git log --pretty=format:"%ai" | head -1 | cut -d\ -f1 | sed -e s/-//g`
time=`git log --pretty=format:"%aD" | head -1 | cut -d\ -f5 | sed -e s/://g`
hhsh=`git log --pretty=format:"%H" | head -1 | cut -c1-8`
hhsh=`git log --pretty=format:"%H" | head -1 | cut -c1-8`
rev=${date}.${hhsh}
useretrotor="false"

View File

@ -9,7 +9,7 @@ call "%EnvPath%\env.bat"
if errorlevel 1 goto error_env
:: Initialize environment
call "%~dp0env.bat" %*
call "%~dp0env.bat" standard
if errorlevel 2 exit /B 2
if errorlevel 1 goto error_env

View File

@ -52,7 +52,7 @@ title Build - %SourceName%%RsType%-%RsBuildConfig% [qmake]
set RS_QMAKE_CONFIG=%RsBuildConfig% version_detail_bash_script rs_autologin retroshare_plugins
if "%RsRetroTor%"=="1" set RS_QMAKE_CONFIG=%RS_QMAKE_CONFIG% retrotor
qmake "%SourcePath%\RetroShare.pro" -r "CONFIG+=%RS_QMAKE_CONFIG%" "EXTERNAL_LIB_DIR=%BuildLibsPath%\libs"
qmake "%SourcePath%\RetroShare.pro" -r -spec win32-g++ "CONFIG+=%RS_QMAKE_CONFIG%" "EXTERNAL_LIB_DIR=%BuildLibsPath%\libs"
if errorlevel 1 goto error
echo.

View File

@ -8,6 +8,6 @@ if "%~2"=="" (
)
::"%EnvCurlExe%" -L -k "%~1" -o "%~2"
"%EnvWgetExe%" --continue "%~1" --output-document="%~2"
"%EnvWgetExe%" --no-check-certificate --continue "%~1" --output-document="%~2"
exit /B %ERRORLEVEL%

View File

@ -515,7 +515,7 @@ void bdNode::checkPotentialPeer(bdId *id, bdId *src)
#ifndef DISABLE_BAD_PEER_FILTER
std::cerr << "bdNode::checkPotentialPeer(";
mFns->bdPrintId(std::cerr, id);
std::cerr << ") MASQARADING AS KNOWN PEER - FLAGGING AS BAD";
std::cerr << ") MASQUERADING AS KNOWN PEER - FLAGGING AS BAD";
std::cerr << std::endl;
// Stores in queue for later callback and desemination around the network.
@ -600,7 +600,7 @@ void bdNode::addPeer(const bdId *id, uint32_t peerflags)
std::cerr << "bdNode::addPeer(";
mFns->bdPrintId(std::cerr, id);
std::cerr << ", " << std::hex << peerflags << std::dec;
std::cerr << ") MASQARADING AS KNOWN PEER - FLAGGING AS BAD";
std::cerr << ") MASQUERADING AS KNOWN PEER - FLAGGING AS BAD";
std::cerr << std::endl;

View File

@ -26,6 +26,8 @@
#include <util/radix64.h>
#include <util/rstime.h>
#include <algorithm>
#include <time.h>
#include "Operators.h"
namespace resource_api
@ -53,7 +55,8 @@ ChannelsHandler::ChannelsHandler(RsGxsChannels& channels): mChannels(channels)
{
addResourceHandler("list_channels", this,
&ChannelsHandler::handleListChannels);
addResourceHandler("get_channel", this, &ChannelsHandler::handleGetChannel);
addResourceHandler("get_channel_info", this, &ChannelsHandler::handleGetChannelInfo);
addResourceHandler("get_channel_content", this, &ChannelsHandler::handleGetChannelContent);
addResourceHandler("toggle_subscribe", this, &ChannelsHandler::handleToggleSubscription);
addResourceHandler("toggle_auto_download", this, &ChannelsHandler::handleToggleAutoDownload);
addResourceHandler("toggle_read", this, &ChannelsHandler::handleTogglePostRead);
@ -64,12 +67,77 @@ ChannelsHandler::ChannelsHandler(RsGxsChannels& channels): mChannels(channels)
void ChannelsHandler::handleListChannels(Request& /*req*/, Response& resp)
{
RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
opts.mReqType = GXS_REQUEST_TYPE_GROUP_META;
uint32_t token;
RsTokenService& tChannels = *mChannels.getTokenService();
tChannels.requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts);
tChannels.requestGroupInfo(token, RS_DEPRECATED_TOKREQ_ANSTYPE, opts);
time_t start = time(NULL);
while((tChannels.requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE)
&&(tChannels.requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_FAILED)
&&((time(NULL) < (start+10)))) rstime::rs_usleep(500*1000);
std::list<RsGroupMetaData> grps;
if( tChannels.requestStatus(token) == RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE
&& mChannels.getGroupSummary(token, grps) )
{
for( RsGroupMetaData& grp : grps )
{
KeyValueReference<RsGxsGroupId> id("channel_id", grp.mGroupId);
KeyValueReference<uint32_t> vis_msg("visible_msg_count", grp.mVisibleMsgCount);
bool own = (grp.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN);
bool subscribed = IS_GROUP_SUBSCRIBED(grp.mSubscribeFlags);
std::string lastPostTsStr = std::to_string(grp.mLastPost);
std::string publishTsStr = std::to_string(grp.mPublishTs);
resp.mDataStream.getStreamToMember()
<< id
<< makeKeyValueReference("name", grp.mGroupName)
<< makeKeyValueReference("last_post_ts", lastPostTsStr)
<< makeKeyValueReference("popularity", grp.mPop)
<< makeKeyValueReference("publish_ts", publishTsStr)
<< vis_msg
<< makeKeyValueReference("group_status", grp.mGroupStatus)
<< makeKeyValueReference("author_id", grp.mAuthorId)
<< makeKeyValueReference("parent_grp_id", grp.mParentGrpId)
<< makeKeyValueReference("own", own)
<< makeKeyValueReference("subscribed", subscribed);
}
resp.setOk();
}
else resp.setFail("Cant get data from GXS!");
}
void ChannelsHandler::handleGetChannelInfo(Request& req, Response& resp)
{
std::string chanIdStr;
req.mStream << makeKeyValueReference("channel_id", chanIdStr);
if(chanIdStr.empty())
{
resp.setFail("channel_id required!");
return;
}
RsGxsGroupId chanId(chanIdStr);
if(chanId.isNull())
{
resp.setFail("Invalid channel_id:" + chanIdStr);
return;
}
bool wantThumbnail = true;
req.mStream << makeKeyValueReference("want_thumbnail", wantThumbnail);
std::list<RsGxsGroupId> groupIds; groupIds.push_back(chanId);
RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
uint32_t token;
RsTokenService& tChannels = *mChannels.getTokenService();
tChannels.requestGroupInfo( token, RS_DEPRECATED_TOKREQ_ANSTYPE,
opts, groupIds );
time_t start = time(NULL);
while((tChannels.requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE)
@ -80,33 +148,35 @@ void ChannelsHandler::handleListChannels(Request& /*req*/, Response& resp)
if( tChannels.requestStatus(token) == RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE
&& mChannels.getGroupData(token, grps) )
{
for( std::vector<RsGxsChannelGroup>::iterator vit = grps.begin();
vit != grps.end(); ++vit )
for( RsGxsChannelGroup& grp : grps )
{
RsGxsChannelGroup& grp = *vit;
KeyValueReference<RsGxsGroupId> id("channel_id", grp.mMeta.mGroupId);
KeyValueReference<uint32_t> vis_msg("visible_msg_count", grp.mMeta.mVisibleMsgCount);
bool own = (grp.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN);
bool subscribed = IS_GROUP_SUBSCRIBED(grp.mMeta.mSubscribeFlags);
std::string lastPostTsStr = std::to_string(grp.mMeta.mLastPost);
std::string publishTsStr = std::to_string(grp.mMeta.mPublishTs);
std::string thumbnail_base64;
Radix64::encode(grp.mImage.mData, grp.mImage.mSize, thumbnail_base64);
resp.mDataStream.getStreamToMember()
<< id
<< makeKeyValueReference("name", grp.mMeta.mGroupName)
<< makeKeyValueReference("last_post_ts", lastPostTsStr)
<< makeKeyValueReference("popularity", grp.mMeta.mPop)
<< makeKeyValueReference("publish_ts", publishTsStr)
<< vis_msg
<< makeKeyValueReference("group_status", grp.mMeta.mGroupStatus)
<< makeKeyValueReference("author_id", grp.mMeta.mAuthorId)
<< makeKeyValueReference("parent_grp_id", grp.mMeta.mParentGrpId)
<< makeKeyValueReference("description", grp.mDescription)
<< makeKeyValueReference("own", own)
<< makeKeyValueReference("subscribed", subscribed)
<< makeKeyValueReference("thumbnail_base64_png", thumbnail_base64)
<< makeKeyValueReference("auto_download", grp.mAutoDownload);
StreamBase& rgrp(resp.mDataStream.getStreamToMember());
rgrp << id
<< makeKeyValueReference("name", grp.mMeta.mGroupName)
<< makeKeyValueReference("last_post_ts", lastPostTsStr)
<< makeKeyValueReference("popularity", grp.mMeta.mPop)
<< makeKeyValueReference("publish_ts", publishTsStr)
<< vis_msg
<< makeKeyValueReference("group_status", grp.mMeta.mGroupStatus)
<< makeKeyValueReference("author_id", grp.mMeta.mAuthorId)
<< makeKeyValueReference("parent_grp_id", grp.mMeta.mParentGrpId)
<< makeKeyValueReference("description", grp.mDescription)
<< makeKeyValueReference("own", own)
<< makeKeyValueReference("subscribed", subscribed)
<< makeKeyValueReference("auto_download", grp.mAutoDownload);
if(wantThumbnail)
{
std::string thumbnail_base64;
Radix64::encode(grp.mImage.mData, grp.mImage.mSize, thumbnail_base64);
rgrp << makeKeyValueReference("thumbnail_base64_png", thumbnail_base64);
}
}
resp.setOk();
@ -114,7 +184,7 @@ void ChannelsHandler::handleListChannels(Request& /*req*/, Response& resp)
else resp.setFail("Cant get data from GXS!");
}
void ChannelsHandler::handleGetChannel(Request& req, Response& resp)
void ChannelsHandler::handleGetChannelContent(Request& req, Response& resp)
{
std::string chanIdStr;
req.mStream << makeKeyValueReference("channel_id", chanIdStr);
@ -122,7 +192,6 @@ void ChannelsHandler::handleGetChannel(Request& req, Response& resp)
{
resp.setFail("channel_id required!");
return;
}
RsGxsGroupId chanId(chanIdStr);

View File

@ -34,7 +34,8 @@ struct ChannelsHandler : ResourceRouter
private:
void handleListChannels(Request& req, Response& resp);
void handleGetChannel(Request& req, Response& resp);
void handleGetChannelInfo(Request& req, Response& resp);
void handleGetChannelContent(Request& req, Response& resp);
void handleToggleSubscription(Request& req, Response& resp);
void handleCreateChannel(Request& req, Response& resp);
void handleToggleAutoDownload(Request& req, Response& resp);

View File

@ -40,6 +40,16 @@ FileSharingHandler::FileSharingHandler(StateTokenServer *sts, RsFiles *files,
addResourceHandler("get_dir_parent", this, &FileSharingHandler::handleGetDirectoryParent);
addResourceHandler("get_dir_childs", this, &FileSharingHandler::handleGetDirectoryChilds);
addResourceHandler( "get_download_directory", this,
&FileSharingHandler::handleGetDownloadDirectory );
addResourceHandler( "set_download_directory", this,
&FileSharingHandler::handleSetDownloadDirectory );
addResourceHandler( "get_partials_directory", this,
&FileSharingHandler::handleGetPartialsDirectory );
addResourceHandler( "set_partials_directory", this,
&FileSharingHandler::handleSetPartialsDirectory );
addResourceHandler("is_dl_dir_shared", this, &FileSharingHandler::handleIsDownloadDirShared);
addResourceHandler("share_dl_dir", this, &FileSharingHandler::handleShareDownloadDirectory);
@ -516,4 +526,48 @@ void FileSharingHandler::handleDownload(Request& req, Response& resp)
resp.setFail("Couldn't download file");
}
void FileSharingHandler::handleGetDownloadDirectory( Request& /*req*/,
Response& resp )
{
std::string dlDir = mRsFiles->getDownloadDirectory();
resp.mDataStream << makeKeyValueReference("download_directory", dlDir);
resp.setOk();
}
void FileSharingHandler::handleSetDownloadDirectory( Request& req,
Response& resp )
{
std::string dlDir;
req.mStream << makeKeyValueReference("download_directory", dlDir);
if(dlDir.empty()) resp.setFail("missing download_directory");
else
{
mRsFiles->setDownloadDirectory(dlDir);
resp.setOk();
}
}
void FileSharingHandler::handleGetPartialsDirectory( Request& /*req*/,
Response& resp )
{
std::string partialsDir = mRsFiles->getPartialsDirectory();
resp.mDataStream << makeKeyValueReference("partials_directory", partialsDir);
resp.setOk();
}
void FileSharingHandler::handleSetPartialsDirectory( Request& req,
Response& resp )
{
std::string partialsDir;
req.mStream << makeKeyValueReference("partials_directory", partialsDir);
if(partialsDir.empty()) resp.setFail("missing partials_directory");
else
{
mRsFiles->setPartialsDirectory(partialsDir);
resp.setOk();
}
}
} // namespace resource_api

View File

@ -60,6 +60,12 @@ private:
void handleDownload(Request& req, Response& resp);
void handleGetDownloadDirectory(Request& req, Response& resp);
void handleSetDownloadDirectory(Request& req, Response& resp);
void handleGetPartialsDirectory(Request& req, Response& resp);
void handleSetPartialsDirectory(Request& req, Response& resp);
/// Token indicating change in local shared files
StateToken mLocalDirStateToken;

View File

@ -730,6 +730,11 @@ void PeersHandler::handleWildcard(Request &req, Response &resp)
peerDetails.localPort );
if (!peerDetails.dyndns.empty())
mRsPeers->setDynDNS(peerDetails.id, peerDetails.dyndns);
for(auto&& ipr : peerDetails.ipAddressList)
mRsPeers->addPeerLocator(
peerDetails.id,
RsUrl(ipr.substr(0, ipr.find(' '))) );
}
}
while(false);

View File

@ -36,6 +36,14 @@ TransfersHandler::TransfersHandler(StateTokenServer *sts, RsFiles *files, RsPeer
addResourceHandler("downloads", this, &TransfersHandler::handleDownloads);
addResourceHandler("uploads", this, &TransfersHandler::handleUploads);
addResourceHandler("control_download", this, &TransfersHandler::handleControlDownload);
addResourceHandler( "set_file_destination_directory", this,
&TransfersHandler::handleSetFileDestinationDirectory );
addResourceHandler( "set_file_destination_name", this,
&TransfersHandler::handleSetFileDestinationName );
addResourceHandler( "set_file_chunk_strategy", this,
&TransfersHandler::handleSetFileChunkStrategy );
mStateToken = mStateTokenServer->getNewToken();
mStateTokenServer->registerTickClient(this);
mNotify.registerNotifyClient(this);
@ -309,4 +317,58 @@ void TransfersHandler::handleUploads(Request & /* req */, Response &resp)
resp.setOk();
}
void TransfersHandler::handleSetFileDestinationDirectory( Request& req,
Response& resp )
{
mStateTokenServer->replaceToken(mStateToken);
std::string hashString;
std::string newPath;
req.mStream << makeKeyValueReference("path", newPath);
req.mStream << makeKeyValueReference("hash", hashString);
RsFileHash hash(hashString);
if (mFiles->setDestinationDirectory(hash, newPath)) resp.setOk();
else resp.setFail();
}
void TransfersHandler::handleSetFileDestinationName( Request& req,
Response& resp )
{
mStateTokenServer->replaceToken(mStateToken);
std::string hashString;
std::string newName;
req.mStream << makeKeyValueReference("name", newName);
req.mStream << makeKeyValueReference("hash", hashString);
RsFileHash hash(hashString);
if (mFiles->setDestinationName(hash, newName)) resp.setOk();
else resp.setFail();
}
void TransfersHandler::handleSetFileChunkStrategy(Request& req, Response& resp)
{
mStateTokenServer->replaceToken(mStateToken);
std::string hashString;
std::string newChunkStrategyStr;
req.mStream << makeKeyValueReference("chuck_stategy", newChunkStrategyStr);
req.mStream << makeKeyValueReference("hash", hashString);
RsFileHash hash(hashString);
FileChunksInfo::ChunkStrategy newStrategy =
FileChunksInfo::CHUNK_STRATEGY_PROGRESSIVE;
if ( newChunkStrategyStr == "streaming" )
newStrategy = FileChunksInfo::CHUNK_STRATEGY_STREAMING;
else if ( newChunkStrategyStr == "random" )
newStrategy = FileChunksInfo::CHUNK_STRATEGY_RANDOM;
else if ( newChunkStrategyStr == "progressive" )
newStrategy = FileChunksInfo::CHUNK_STRATEGY_PROGRESSIVE;
if (mFiles->setChunkStrategy(hash, newStrategy)) resp.setOk();
else resp.setFail();
}
} // namespace resource_api

View File

@ -51,6 +51,9 @@ private:
void handleControlDownload(Request& req, Response& resp);
void handleDownloads(Request& req, Response& resp);
void handleUploads(Request& req, Response& resp);
void handleSetFileDestinationDirectory(Request& req, Response& resp);
void handleSetFileDestinationName(Request& req, Response& resp);
void handleSetFileChunkStrategy(Request& req, Response& resp);
StateTokenServer* mStateTokenServer;
RsFiles* mFiles;

View File

@ -26,23 +26,14 @@ DESTDIR = lib
!include(use_libresapi.pri):error("Including")
# when rapidjson is mainstream on all distribs, we will not need the sources anymore
# in the meantime, they are part of the RS directory so that it is always possible to find them
INCLUDEPATH += ../../rapidjson-1.1.0
INCLUDEPATH += ../../libretroshare/src
libresapilocalserver {
CONFIG *= qt
QT *= network
SOURCES *= api/ApiServerLocal.cpp
HEADERS *= api/ApiServerLocal.h
}
libresapi_settings {
CONFIG *= qt
QT *= core
SOURCES += api/SettingsHandler.cpp
HEADERS += api/SettingsHandler.h
}

View File

@ -27,6 +27,16 @@ sLibs =
mLibs =
dLibs =
libresapilocalserver {
CONFIG *= qt
QT *= network
}
libresapi_settings {
CONFIG *= qt
QT *= core
}
libresapihttpserver {
mLibs *= microhttpd
}

View File

@ -254,7 +254,9 @@ void ChunkMap::setChunkCheckingResult(uint32_t chunk_number,bool check_succeeded
}
}
bool ChunkMap::reAskPendingChunk(const RsPeerId& peer_id,uint32_t size_hint,uint64_t& offset,uint32_t& size)
bool ChunkMap::reAskPendingChunk( const RsPeerId& peer_id,
uint32_t /*size_hint*/,
uint64_t& offset, uint32_t& size)
{
// make sure that we're at the end of the file. No need to be too greedy in the middle of it.

View File

@ -1213,7 +1213,7 @@ int RsDataService::retrieveNxsMsgs(const GxsMsgReq &reqIds, GxsMsgResult &msg, b
const RsGxsGroupId& grpId = mit->first;
// if vector empty then request all messages
const std::vector<RsGxsMessageId>& msgIdV = mit->second;
const std::set<RsGxsMessageId>& msgIdV = mit->second;
std::vector<RsNxsMsg*> msgSet;
if(msgIdV.empty()){
@ -1231,7 +1231,7 @@ int RsDataService::retrieveNxsMsgs(const GxsMsgReq &reqIds, GxsMsgResult &msg, b
}else{
// request each grp
std::vector<RsGxsMessageId>::const_iterator sit = msgIdV.begin();
std::set<RsGxsMessageId>::const_iterator sit = msgIdV.begin();
for(; sit!=msgIdV.end();++sit){
const RsGxsMessageId& msgId = *sit;
@ -1301,7 +1301,7 @@ int RsDataService::retrieveGxsMsgMetaData(const GxsMsgReq& reqIds, GxsMsgMetaRes
const RsGxsGroupId& grpId = mit->first;
// if vector empty then request all messages
const std::vector<RsGxsMessageId>& msgIdV = mit->second;
const std::set<RsGxsMessageId>& msgIdV = mit->second;
std::vector<RsGxsMsgMetaData*> metaSet;
if(msgIdV.empty()){
@ -1317,7 +1317,7 @@ int RsDataService::retrieveGxsMsgMetaData(const GxsMsgReq& reqIds, GxsMsgMetaRes
}else{
// request each grp
std::vector<RsGxsMessageId>::const_iterator sit = msgIdV.begin();
std::set<RsGxsMessageId>::const_iterator sit = msgIdV.begin();
for(; sit!=msgIdV.end(); ++sit){
const RsGxsMessageId& msgId = *sit;
@ -1557,7 +1557,7 @@ int RsDataService::removeMsgs(const GxsMsgReq& msgIds)
for(; mit != msgIds.end(); ++mit)
{
const std::vector<RsGxsMessageId>& msgIdV = mit->second;
const std::set<RsGxsMessageId>& msgIdV = mit->second;
const RsGxsGroupId& grpId = mit->first;
// delete messages
@ -1618,7 +1618,7 @@ int RsDataService::retrieveGroupIds(std::vector<RsGxsGroupId> &grpIds)
return 1;
}
int RsDataService::retrieveMsgIds(const RsGxsGroupId& grpId, RsGxsMessageId::std_vector& msgIds)
int RsDataService::retrieveMsgIds(const RsGxsGroupId& grpId, RsGxsMessageId::std_set& msgIds)
{
#ifdef RS_DATA_SERVICE_DEBUG_TIME
rstime::RsScopeTimer timer("");
@ -1639,7 +1639,7 @@ int RsDataService::retrieveMsgIds(const RsGxsGroupId& grpId, RsGxsMessageId::std
if(c->columnCount() != 1)
std::cerr << "(EE) ********* not retrieving all columns!!" << std::endl;
msgIds.push_back(RsGxsMessageId(msgId));
msgIds.insert(RsGxsMessageId(msgId));
valid = c->moveToNext();
#ifdef RS_DATA_SERVICE_DEBUG_TIME
@ -1670,8 +1670,8 @@ bool RsDataService::locked_removeMessageEntries(const GxsMsgReq& msgIds)
for(; mit != msgIds.end(); ++mit)
{
const RsGxsGroupId& grpId = mit->first;
const std::vector<RsGxsMessageId>& msgsV = mit->second;
std::vector<RsGxsMessageId>::const_iterator vit = msgsV.begin();
const std::set<RsGxsMessageId>& msgsV = mit->second;
std::set<RsGxsMessageId>::const_iterator vit = msgsV.begin();
for(; vit != msgsV.end(); ++vit)
{

View File

@ -106,7 +106,7 @@ public:
* @param msgId msgsids retrieved
* @return error code
*/
int retrieveMsgIds(const RsGxsGroupId& grpId, RsGxsMessageId::std_vector& msgId);
int retrieveMsgIds(const RsGxsGroupId& grpId, RsGxsMessageId::std_set& msgId);
/*!
* @return the cache size set for this RsGeneralDataService in bytes

View File

@ -204,7 +204,7 @@ public:
* @param msgId msgsids retrieved
* @return error code
*/
virtual int retrieveMsgIds(const RsGxsGroupId& grpId, RsGxsMessageId::std_vector& msgId) = 0;
virtual int retrieveMsgIds(const RsGxsGroupId& grpId, RsGxsMessageId::std_set& msgId) = 0;
/*!
* @return the cache size set for this RsGeneralDataService in bytes

View File

@ -212,7 +212,7 @@ void RsGenExchange::tick()
RS_STACK_MUTEX(mGenMtx) ;
std::list<RsGxsGroupId> grpIds;
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > msgIds;
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > msgIds;
mIntegrityCheck->getDeletedIds(grpIds, msgIds);
if (!grpIds.empty())
@ -1073,23 +1073,19 @@ bool RsGenExchange::checkAuthenFlag(const PrivacyBitPos& pos, const uint8_t& fla
}
}
static void addMessageChanged(std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &msgs, const std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &msgChanged)
static void addMessageChanged(std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &msgs, const std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &msgChanged)
{
if (msgs.empty()) {
msgs = msgChanged;
} else {
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >::const_iterator mapIt;
for (mapIt = msgChanged.begin(); mapIt != msgChanged.end(); ++mapIt) {
for (auto mapIt = msgChanged.begin(); mapIt != msgChanged.end(); ++mapIt)
{
const RsGxsGroupId &grpId = mapIt->first;
const std::vector<RsGxsMessageId> &srcMsgIds = mapIt->second;
std::vector<RsGxsMessageId> &destMsgIds = msgs[grpId];
const std::set<RsGxsMessageId> &srcMsgIds = mapIt->second;
std::set<RsGxsMessageId> &destMsgIds = msgs[grpId];
std::vector<RsGxsMessageId>::const_iterator msgIt;
for (msgIt = srcMsgIds.begin(); msgIt != srcMsgIds.end(); ++msgIt) {
if (std::find(destMsgIds.begin(), destMsgIds.end(), *msgIt) == destMsgIds.end()) {
destMsgIds.push_back(*msgIt);
}
}
for (auto msgIt = srcMsgIds.begin(); msgIt != srcMsgIds.end(); ++msgIt)
destMsgIds.insert(*msgIt) ;
}
}
}
@ -1784,8 +1780,8 @@ void RsGenExchange::deleteMsgs(uint32_t& token, const GxsMsgReq& msgs)
if(mNetService != NULL)
for(GxsMsgReq::const_iterator it(msgs.begin());it!=msgs.end();++it)
for(uint32_t i=0;i<it->second.size();++i)
mNetService->rejectMessage(it->second[i]) ;
for(auto it2(it->second.begin());it2!=it->second.end();++it2)
mNetService->rejectMessage(*it2);
}
void RsGenExchange::publishMsg(uint32_t& token, RsGxsMsgItem *msgItem)
@ -1956,8 +1952,8 @@ void RsGenExchange::processMsgMetaChanges()
if(m.val.getAsInt32(RsGeneralDataService::MSG_META_STATUS+GXS_MASK, mask))
{
GxsMsgReq req;
std::vector<RsGxsMessageId> msgIdV;
msgIdV.push_back(m.msgId.second);
std::set<RsGxsMessageId> msgIdV;
msgIdV.insert(m.msgId.second);
req.insert(std::make_pair(m.msgId.first, msgIdV));
GxsMsgMetaResult result;
mDataStore->retrieveGxsMsgMetaData(req, result);
@ -1989,7 +1985,7 @@ void RsGenExchange::processMsgMetaChanges()
mDataAccess->updatePublicRequestStatus(token, RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE);
if (changed)
{
msgIds[m.msgId.first].push_back(m.msgId.second);
msgIds[m.msgId.first].insert(m.msgId.second);
}
}
else
@ -2005,7 +2001,7 @@ void RsGenExchange::processMsgMetaChanges()
if (!msgIds.empty()) {
RS_STACK_MUTEX(mGenMtx);
RsGxsMsgChange* c = new RsGxsMsgChange(RsGxsNotify::TYPE_PROCESSED, true);
RsGxsMsgChange* c = new RsGxsMsgChange(RsGxsNotify::TYPE_PROCESSED, false);
c->msgChangeMap = msgIds;
mNotifications.push_back(c);
}
@ -2140,7 +2136,7 @@ void RsGenExchange::publishMsgs()
mMsgsToPublish.insert(std::make_pair(sign_it->first, item.mItem));
}
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > msgChangeMap;
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > msgChangeMap;
std::map<uint32_t, RsGxsMsgItem*>::iterator mit = mMsgsToPublish.begin();
for(; mit != mMsgsToPublish.end(); ++mit)
@ -2268,7 +2264,7 @@ void RsGenExchange::publishMsgs()
mDataAccess->addMsgData(msg);
delete msg ;
msgChangeMap[grpId].push_back(msgId);
msgChangeMap[grpId].insert(msgId);
delete[] metaDataBuff;
@ -2967,10 +2963,10 @@ void RsGenExchange::processRecvdMessages()
msg->metaData->mMsgStatus = GXS_SERV::GXS_MSG_STATUS_UNPROCESSED | GXS_SERV::GXS_MSG_STATUS_GUI_NEW | GXS_SERV::GXS_MSG_STATUS_GUI_UNREAD;
msgs_to_store.push_back(msg);
std::vector<RsGxsMessageId> &msgv = msgIds[msg->grpId];
if (std::find(msgv.begin(), msgv.end(), msg->msgId) == msgv.end())
msgv.push_back(msg->msgId);
msgIds[msg->grpId].insert(msg->msgId);
// std::vector<RsGxsMessageId> &msgv = msgIds[msg->grpId];
// if (std::find(msgv.begin(), msgv.end(), msg->msgId) == msgv.end())
// msgv.push_back(msg->msgId);
computeHash(msg->msg, msg->metaData->mHash);
msg->metaData->recvTS = time(NULL);
@ -3325,7 +3321,7 @@ void RsGenExchange::removeDeleteExistingMessages( std::list<RsNxsMsg*>& msgs, Gx
//RsGxsGroupId::std_list grpIds(mGrpIdsUnique.begin(), mGrpIdsUnique.end());
//RsGxsGroupId::std_list::const_iterator it = grpIds.begin();
typedef std::map<RsGxsGroupId, RsGxsMessageId::std_vector> MsgIdReq;
typedef std::map<RsGxsGroupId, RsGxsMessageId::std_set> MsgIdReq;
MsgIdReq msgIdReq;
// now get a list of all msgs ids for each group
@ -3345,7 +3341,7 @@ void RsGenExchange::removeDeleteExistingMessages( std::list<RsNxsMsg*>& msgs, Gx
// now for each msg to be stored that exist in the retrieved msg/grp "index" delete and erase from map
for(std::list<RsNxsMsg*>::iterator cit2 = msgs.begin(); cit2 != msgs.end();)
{
const RsGxsMessageId::std_vector& msgIds = msgIdReq[(*cit2)->metaData->mGroupId];
const RsGxsMessageId::std_set& msgIds = msgIdReq[(*cit2)->metaData->mGroupId];
#ifdef GEN_EXCH_DEBUG
std::cerr << " grpid=" << (*cit2)->grpId << ", msgid=" << (*cit2)->msgId ;
@ -3353,12 +3349,13 @@ void RsGenExchange::removeDeleteExistingMessages( std::list<RsNxsMsg*>& msgs, Gx
// Avoid storing messages that are already in the database, as well as messages that are too old (or generally do not pass the database storage test)
//
if(std::find(msgIds.begin(), msgIds.end(), (*cit2)->metaData->mMsgId) != msgIds.end() || !messagePublicationTest( *(*cit2)->metaData))
if(msgIds.find((*cit2)->metaData->mMsgId) != msgIds.end() || !messagePublicationTest( *(*cit2)->metaData))
{
// msg exist in retrieved index. We should use a std::set here instead of a vector.
RsGxsMessageId::std_vector& notifyIds = msgIdsNotify[ (*cit2)->metaData->mGroupId];
RsGxsMessageId::std_vector::iterator it2 = std::find(notifyIds.begin(), notifyIds.end(), (*cit2)->metaData->mMsgId);
RsGxsMessageId::std_set& notifyIds = msgIdsNotify[ (*cit2)->metaData->mGroupId];
RsGxsMessageId::std_set::iterator it2 = notifyIds.find((*cit2)->metaData->mMsgId);
if(it2 != notifyIds.end())
{
notifyIds.erase(it2);

View File

@ -222,7 +222,7 @@ bool RsGxsDataAccess::requestMsgInfo(uint32_t &token, uint32_t ansType,
MsgMetaReq* mmr = new MsgMetaReq();
for(; lit != grpIds.end(); ++lit)
mmr->mMsgIds[*lit] = std::vector<RsGxsMessageId>();
mmr->mMsgIds[*lit] = std::set<RsGxsMessageId>();
req = mmr;
}else if(reqType & GXS_REQUEST_TYPE_MSG_DATA)
@ -230,7 +230,7 @@ bool RsGxsDataAccess::requestMsgInfo(uint32_t &token, uint32_t ansType,
MsgDataReq* mdr = new MsgDataReq();
for(; lit != grpIds.end(); ++lit)
mdr->mMsgIds[*lit] = std::vector<RsGxsMessageId>();
mdr->mMsgIds[*lit] = std::set<RsGxsMessageId>();
req = mdr;
}else if(reqType & GXS_REQUEST_TYPE_MSG_IDS)
@ -238,7 +238,7 @@ bool RsGxsDataAccess::requestMsgInfo(uint32_t &token, uint32_t ansType,
MsgIdReq* mir = new MsgIdReq();
for(; lit != grpIds.end(); ++lit)
mir->mMsgIds[*lit] = std::vector<RsGxsMessageId>();
mir->mMsgIds[*lit] = std::set<RsGxsMessageId>();
req = mir;
}
@ -1188,7 +1188,7 @@ bool RsGxsDataAccess::getMsgList(const GxsMsgReq& msgIds, const RsTokReqOptions&
// Add the discovered Latest Msgs.
for(oit = origMsgTs.begin(); oit != origMsgTs.end(); ++oit)
{
msgIdsOut[grpId].push_back(oit->second.first);
msgIdsOut[grpId].insert(oit->second.first);
}
}
@ -1225,7 +1225,7 @@ bool RsGxsDataAccess::getMsgList(const GxsMsgReq& msgIds, const RsTokReqOptions&
if (add)
{
msgIdsOut[grpId].push_back(msgMeta->mMsgId);
msgIdsOut[grpId].insert(msgMeta->mMsgId);
metaFilter[grpId].insert(std::make_pair(msgMeta->mMsgId, msgMeta));
}
@ -1370,7 +1370,7 @@ bool RsGxsDataAccess::getMsgRelatedInfo(MsgRelatedInfoReq *req)
// get meta data for all in group
GxsMsgMetaResult result;
GxsMsgReq msgIds;
msgIds.insert(std::make_pair(grpMsgIdPair.first, std::vector<RsGxsMessageId>()));
msgIds.insert(std::make_pair(grpMsgIdPair.first, std::set<RsGxsMessageId>()));
mDataStore->retrieveGxsMsgMetaData(msgIds, result);
std::vector<RsGxsMsgMetaData*>& metaV = result[grpMsgIdPair.first];
std::vector<RsGxsMsgMetaData*>::iterator vit_meta;
@ -1379,7 +1379,7 @@ bool RsGxsDataAccess::getMsgRelatedInfo(MsgRelatedInfoReq *req)
const RsGxsMessageId& msgId = grpMsgIdPair.second;
const RsGxsGroupId& grpId = grpMsgIdPair.first;
std::vector<RsGxsMessageId> outMsgIds;
std::set<RsGxsMessageId> outMsgIds;
RsGxsMsgMetaData* origMeta = NULL;
for(vit_meta = metaV.begin(); vit_meta != metaV.end(); ++vit_meta)
@ -1474,7 +1474,7 @@ bool RsGxsDataAccess::getMsgRelatedInfo(MsgRelatedInfoReq *req)
// Add the discovered Latest Msgs.
for(oit = origMsgTs.begin(); oit != origMsgTs.end(); ++oit)
{
outMsgIds.push_back(oit->second.first);
outMsgIds.insert(oit->second.first);
}
}
else
@ -1499,7 +1499,7 @@ bool RsGxsDataAccess::getMsgRelatedInfo(MsgRelatedInfoReq *req)
}
}
}
outMsgIds.push_back(latestMsgId);
outMsgIds.insert(latestMsgId);
metaMap.insert(std::make_pair(latestMsgId, latestMeta));
}
}
@ -1511,7 +1511,7 @@ bool RsGxsDataAccess::getMsgRelatedInfo(MsgRelatedInfoReq *req)
if (meta->mOrigMsgId == origMsgId)
{
outMsgIds.push_back(meta->mMsgId);
outMsgIds.insert(meta->mMsgId);
metaMap.insert(std::make_pair(meta->mMsgId, meta));
}
}
@ -1553,7 +1553,7 @@ bool RsGxsDataAccess::getGroupStatistic(GroupStatisticRequest *req)
{
// filter based on options
GxsMsgIdResult metaReq;
metaReq[req->mGrpId] = std::vector<RsGxsMessageId>();
metaReq[req->mGrpId] = std::set<RsGxsMessageId>();
GxsMsgMetaResult metaResult;
mDataStore->retrieveGxsMsgMetaData(metaReq, metaResult);
@ -1669,7 +1669,7 @@ bool RsGxsDataAccess::getMsgList(MsgIdReq* req)
for(; vit != vit_end; ++vit)
{
RsGxsMsgMetaData* meta = *vit;
req->mMsgIdResult[grpId].push_back(meta->mMsgId);
req->mMsgIdResult[grpId].insert(meta->mMsgId);
delete meta; // discard meta data mem
}
}
@ -1715,8 +1715,8 @@ void RsGxsDataAccess::filterMsgList(GxsMsgIdResult& msgIds, const RsTokReqOption
if(cit == msgMetas.end())
continue;
std::vector<RsGxsMessageId>& msgs = mit->second;
std::vector<RsGxsMessageId>::iterator vit = msgs.begin();
std::set<RsGxsMessageId>& msgs = mit->second;
std::set<RsGxsMessageId>::iterator vit = msgs.begin();
const std::map<RsGxsMessageId, RsGxsMsgMetaData*>& meta = cit->second;
std::map<RsGxsMessageId, RsGxsMsgMetaData*>::const_iterator cit2;

View File

@ -781,7 +781,7 @@ void RsGxsNetService::handleRecvSyncGrpStatistics(RsNxsSyncGrpStatsItem *grs)
// now count available messages
GxsMsgReq reqIds;
reqIds[grs->grpId] = std::vector<RsGxsMessageId>();
reqIds[grs->grpId] = std::set<RsGxsMessageId>();
GxsMsgMetaResult result;
#ifdef NXS_NET_DEBUG_6
@ -2754,7 +2754,7 @@ void RsGxsNetService::locked_genReqMsgTransaction(NxsTransaction* tr)
#endif
GxsMsgReq reqIds;
reqIds[grpId] = std::vector<RsGxsMessageId>();
reqIds[grpId] = std::set<RsGxsMessageId>();
GxsMsgMetaResult result;
mDataStore->retrieveGxsMsgMetaData(reqIds, result);
std::vector<RsGxsMsgMetaData*> &msgMetaV = result[grpId];
@ -3293,7 +3293,7 @@ void RsGxsNetService::locked_genSendMsgsTransaction(NxsTransaction* tr)
RsNxsSyncMsgItem* item = dynamic_cast<RsNxsSyncMsgItem*>(*lit);
if (item)
{
msgIds[item->grpId].push_back(item->msgId);
msgIds[item->grpId].insert(item->msgId);
if(grpId.isNull())
grpId = item->grpId;
@ -4124,7 +4124,7 @@ void RsGxsNetService::handleRecvSyncMessage(RsNxsSyncMsgReqItem *item,bool item_
}
GxsMsgReq req;
req[item->grpId] = std::vector<RsGxsMessageId>();
req[item->grpId] = std::set<RsGxsMessageId>();
GxsMsgMetaResult metaResult;
mDataStore->retrieveGxsMsgMetaData(req, metaResult);

View File

@ -63,7 +63,7 @@ bool RsGxsMessageCleanUp::clean()
GxsMsgReq req;
GxsMsgMetaResult result;
req[grpId] = std::vector<RsGxsMessageId>();
req[grpId] = std::set<RsGxsMessageId>();
mDs->retrieveGxsMsgMetaData(req, result);
GxsMsgMetaResult::iterator mit = result.begin();
@ -113,7 +113,7 @@ bool RsGxsMessageCleanUp::clean()
if( remove )
{
req[grpId].push_back(meta->mMsgId);
req[grpId].insert(meta->mMsgId);
#ifdef DEBUG_GXSUTIL
std::cerr << " Scheduling for removal." << std::endl;
@ -237,9 +237,9 @@ bool RsGxsIntegrityCheck::check()
for (msgIdsIt = msgIds.begin(); msgIdsIt != msgIds.end(); ++msgIdsIt)
{
const RsGxsGroupId& grpId = msgIdsIt->first;
std::vector<RsGxsMessageId> &msgIdV = msgIdsIt->second;
std::set<RsGxsMessageId> &msgIdV = msgIdsIt->second;
std::vector<RsGxsMessageId>::iterator msgIdIt;
std::set<RsGxsMessageId>::iterator msgIdIt;
for (msgIdIt = msgIdV.begin(); msgIdIt != msgIdV.end(); ++msgIdIt)
{
const RsGxsMessageId& msgId = *msgIdIt;
@ -257,7 +257,7 @@ bool RsGxsIntegrityCheck::check()
if (nxsMsgIt == nxsMsgV.end())
{
msgsToDel[grpId].push_back(msgId);
msgsToDel[grpId].insert(msgId);
}
}
}
@ -280,7 +280,7 @@ bool RsGxsIntegrityCheck::check()
if(msg->metaData == NULL || currHash != msg->metaData->mHash)
{
std::cerr << "(EE) deleting message data with wrong hash or null meta data. meta=" << (void*)msg->metaData << std::endl;
msgsToDel[msg->grpId].push_back(msg->msgId);
msgsToDel[msg->grpId].insert(msg->msgId);
}
else if(!msg->metaData->mAuthorId.isNull() && subscribed_groups.find(msg->metaData->mGroupId)!=subscribed_groups.end())
{
@ -373,7 +373,7 @@ bool RsGxsIntegrityCheck::isDone()
return mDone;
}
void RsGxsIntegrityCheck::getDeletedIds(std::list<RsGxsGroupId>& grpIds, std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >& msgIds)
void RsGxsIntegrityCheck::getDeletedIds(std::list<RsGxsGroupId>& grpIds, std::map<RsGxsGroupId, std::set<RsGxsMessageId> >& msgIds)
{
RsStackMutex stack(mIntegrityMutex);

View File

@ -205,7 +205,7 @@ public:
void run();
void getDeletedIds(std::list<RsGxsGroupId>& grpIds, std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >& msgIds);
void getDeletedIds(std::list<RsGxsGroupId>& grpIds, std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &msgIds);
private:
@ -214,7 +214,7 @@ private:
bool mDone;
RsMutex mIntegrityMutex;
std::list<RsGxsGroupId> mDeletedGrps;
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > mDeletedMsgs;
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > mDeletedMsgs;
RsGixs *mGixs ;
};

View File

@ -458,7 +458,7 @@ void p3GxsTrans::GxsTransIntegrityCleanupThread::run()
if(stored_msgs.end() != it2)
{
msgsToDel[it2->second.first].push_back(it2->second.second);
msgsToDel[it2->second.first].insert(it2->second.second);
#ifdef DEBUG_GXSTRANS
std::cerr << " scheduling msg " << std::hex << it2->second.first << "," << it2->second.second << " for deletion." << std::endl;

View File

@ -38,11 +38,6 @@ DESTDIR = lib
#QMAKE_CFLAGS += -Werror
#QMAKE_CXXFLAGS += -Werror
# when rapidjson is mainstream on all distribs, we will not need the sources anymore
# in the meantime, they are part of the RS directory so that it is always possible to find them
INCLUDEPATH += ../../rapidjson-1.1.0
debug {
# DEFINES *= DEBUG
# DEFINES *= OPENDHT_DEBUG DHT_DEBUG CONN_DEBUG DEBUG_UDP_SORTER P3DISC_DEBUG DEBUG_UDP_LAYER FT_DEBUG EXTADDRSEARCH_DEBUG
@ -288,8 +283,6 @@ win32-g++ {
DEFINES += USE_CMD_ARGS
CONFIG += upnp_miniupnpc
wLibs = ws2_32 gdi32 uuid iphlpapi crypt32 ole32 winmm
LIBS += $$linkDynamicLibs(wLibs)
}
@ -300,22 +293,10 @@ mac {
QMAKE_CC = $${QMAKE_CXX}
OBJECTS_DIR = temp/obj
MOC_DIR = temp/moc
#DEFINES = WINDOWS_SYS WIN32 STATICLIB MINGW
#DEFINES *= MINIUPNPC_VERSION=13
CONFIG += upnp_miniupnpc
CONFIG += c++11
# zeroconf disabled at the end of libretroshare.pro (but need the code)
#CONFIG += zeroconf
#CONFIG += zcnatassist
# Beautiful Hack to fix 64bit file access.
QMAKE_CXXFLAGS *= -Dfseeko64=fseeko -Dftello64=ftello -Dfopen64=fopen -Dvstatfs64=vstatfs
#GPG_ERROR_DIR = ../../../../libgpg-error-1.7
#GPGME_DIR = ../../../../gpgme-1.1.8
for(lib, LIB_DIR):LIBS += -L"$$lib"
for(bin, BIN_DIR):LIBS += -L"$$bin"
@ -541,7 +522,8 @@ HEADERS += util/folderiterator.h \
util/rstime.h \
util/stacktrace.h \
util/rsdeprecate.h \
util/cxx11retrocompat.h
util/cxx11retrocompat.h \
util/rsurl.h
SOURCES += ft/ftchunkmap.cc \
ft/ftcontroller.cc \
@ -684,7 +666,8 @@ SOURCES += util/folderiterator.cc \
util/rsrandom.cc \
util/rstickevent.cc \
util/rsrecogn.cc \
util/rstime.cc
util/rstime.cc \
util/rsurl.cc
## Added for retrocompatibility remove ASAP
isEmpty(RS_UPNP_LIB) {

View File

@ -4,6 +4,7 @@
* libretroshare: retroshare core library *
* *
* Copyright 2016 Cyril Soler <csoler@users.sourceforge.net> *
* Copyright 2018 Gioacchino Mazzurco <gio@eigenlab.org> *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
@ -32,25 +33,21 @@
//#define DEBUG_RSCERTIFICATE
static const std::string PGP_CERTIFICATE_START ( "-----BEGIN PGP PUBLIC KEY BLOCK-----" );
static const std::string PGP_CERTIFICATE_END ( "-----END PGP PUBLIC KEY BLOCK-----" );
static const std::string EXTERNAL_IP_BEGIN_SECTION ( "--EXT--" );
static const std::string LOCAL_IP_BEGIN_SECTION ( "--LOCAL--" );
static const std::string SSLID_BEGIN_SECTION ( "--SSLID--" );
static const std::string LOCATION_BEGIN_SECTION ( "--LOCATION--" );
static const std::string HIDDEN_NODE_BEGIN_SECTION ( "--HIDDEN--" );
static const uint8_t CERTIFICATE_VERSION_06 = 0x06;
static const uint8_t CERTIFICATE_PTAG_PGP_SECTION = 0x01 ;
static const uint8_t CERTIFICATE_PTAG_EXTIPANDPORT_SECTION = 0x02 ;
static const uint8_t CERTIFICATE_PTAG_LOCIPANDPORT_SECTION = 0x03 ;
static const uint8_t CERTIFICATE_PTAG_DNS_SECTION = 0x04 ;
static const uint8_t CERTIFICATE_PTAG_SSLID_SECTION = 0x05 ;
static const uint8_t CERTIFICATE_PTAG_NAME_SECTION = 0x06 ;
static const uint8_t CERTIFICATE_PTAG_CHECKSUM_SECTION = 0x07 ;
static const uint8_t CERTIFICATE_PTAG_HIDDENNODE_SECTION = 0x08 ;
static const uint8_t CERTIFICATE_PTAG_VERSION_SECTION = 0x09 ;
static const uint8_t CERTIFICATE_VERSION_06 = 0x06 ;
enum CertificatePtag : uint8_t
{
CERTIFICATE_PTAG_PGP_SECTION = 0x01,
CERTIFICATE_PTAG_EXTIPANDPORT_SECTION = 0x02,
CERTIFICATE_PTAG_LOCIPANDPORT_SECTION = 0x03,
CERTIFICATE_PTAG_DNS_SECTION = 0x04,
CERTIFICATE_PTAG_SSLID_SECTION = 0x05,
CERTIFICATE_PTAG_NAME_SECTION = 0x06,
CERTIFICATE_PTAG_CHECKSUM_SECTION = 0x07,
CERTIFICATE_PTAG_HIDDENNODE_SECTION = 0x08,
CERTIFICATE_PTAG_VERSION_SECTION = 0x09,
CERTIFICATE_PTAG_EXTRA_LOCATOR = 10
};
static bool is_acceptable_radix64Char(char c)
{
@ -116,6 +113,14 @@ std::string RsCertificate::toStdString() const
addPacket( CERTIFICATE_PTAG_NAME_SECTION , (unsigned char *)location_name.c_str() ,location_name.length() , buf, p, BS ) ;
addPacket( CERTIFICATE_PTAG_SSLID_SECTION , location_id.toByteArray() ,location_id.SIZE_IN_BYTES, buf, p, BS ) ;
for (const RsUrl& locator : mLocators)
{
std::string urlStr(locator.toString());
addPacket( CERTIFICATE_PTAG_EXTRA_LOCATOR,
(unsigned char *) urlStr.c_str(), urlStr.size(),
buf, p, BS );
}
}
uint32_t computed_crc = PGPKeyManagement::compute24bitsCRC(buf,p) ;
@ -216,7 +221,10 @@ RsCertificate::RsCertificate(const RsPeerDetails& Detail, const unsigned char *b
memset(ipv4_external_ip_and_port,0,6) ;
}
dns_name = Detail.dyndns ;
dns_name = Detail.dyndns;
for(auto&& ipr : Detail.ipAddressList)
mLocators.insert(RsUrl(ipr.substr(0, ipr.find(' '))));
}
}
else
@ -275,19 +283,19 @@ bool RsCertificate::initFromString(const std::string& instr,uint32_t& err_code)
std::vector<uint8_t> bf = Radix64::decode(str) ;
size_t size = bf.size();
bool checksum_check_passed = false ;
unsigned char *buf = bf.data() ;
size_t total_s = 0 ;
only_pgp = true ;
uint8_t certificate_version = 0x00 ;
bool checksum_check_passed = false;
unsigned char *buf = bf.data();
size_t total_s = 0;
only_pgp = true;
uint8_t certificate_version = 0x00;
while(total_s < size)
{
uint8_t ptag = buf[0];
buf = &buf[1] ;
buf = &buf[1];
unsigned char *buf2 = buf ;
uint32_t s = PGPKeyParser::read_125Size(buf) ;
unsigned char *buf2 = buf;
uint32_t s = PGPKeyParser::read_125Size(buf);
total_s += 1 + ((unsigned long)buf-(unsigned long)buf2) ;
@ -302,90 +310,80 @@ bool RsCertificate::initFromString(const std::string& instr,uint32_t& err_code)
#endif
switch(ptag)
{
case CERTIFICATE_PTAG_VERSION_SECTION: certificate_version = buf[0] ;
buf = &buf[s] ;
break ;
case CERTIFICATE_PTAG_PGP_SECTION: binary_pgp_key = new unsigned char[s] ;
memcpy(binary_pgp_key,buf,s) ;
binary_pgp_key_size = s ;
buf = &buf[s] ;
break ;
case CERTIFICATE_PTAG_NAME_SECTION: location_name = std::string((char *)buf,s) ;
buf = &buf[s] ;
break ;
case CERTIFICATE_PTAG_SSLID_SECTION:
if(s != location_id.SIZE_IN_BYTES)
{
err_code = CERTIFICATE_PARSING_ERROR_INVALID_LOCATION_ID ;
return false ;
}
location_id = RsPeerId(buf) ;
buf = &buf[s] ;
only_pgp = false ;
break ;
case CERTIFICATE_PTAG_DNS_SECTION: dns_name = std::string((char *)buf,s) ;
buf = &buf[s] ;
break ;
case CERTIFICATE_PTAG_HIDDENNODE_SECTION:
hidden_node_address = std::string((char *)buf,s);
hidden_node = true;
buf = &buf[s];
break ;
case CERTIFICATE_PTAG_LOCIPANDPORT_SECTION:
if(s != 6)
{
err_code = CERTIFICATE_PARSING_ERROR_INVALID_LOCAL_IP;
return false ;
}
memcpy(ipv4_internal_ip_and_port,buf,s) ;
buf = &buf[s] ;
break ;
case CERTIFICATE_PTAG_EXTIPANDPORT_SECTION:
if(s != 6)
{
err_code = CERTIFICATE_PARSING_ERROR_INVALID_EXTERNAL_IP;
return false ;
}
memcpy(ipv4_external_ip_and_port,buf,s) ;
buf = &buf[s] ;
break ;
case CERTIFICATE_PTAG_CHECKSUM_SECTION:
{
if(s != 3 || total_s+3 != size)
{
err_code = CERTIFICATE_PARSING_ERROR_INVALID_CHECKSUM_SECTION ;
return false ;
}
uint32_t computed_crc = PGPKeyManagement::compute24bitsCRC(bf.data(),size-5) ;
uint32_t certificate_crc = buf[0] + (buf[1] << 8) + (buf[2] << 16) ;
if(computed_crc != certificate_crc)
{
err_code = CERTIFICATE_PARSING_ERROR_CHECKSUM_ERROR ;
return false ;
}
else
checksum_check_passed = true ;
}
break ;
default:
std::cerr << "(WW) unknwown PTAG 0x" << std::hex << ptag << std::dec << " in certificate! Ignoring it." << std::endl;
buf = &buf[s] ;
break ;
case CERTIFICATE_PTAG_VERSION_SECTION:
certificate_version = buf[0];
break;
case CERTIFICATE_PTAG_PGP_SECTION:
binary_pgp_key = new unsigned char[s];
memcpy(binary_pgp_key,buf,s);
binary_pgp_key_size = s;
break;
case CERTIFICATE_PTAG_NAME_SECTION:
location_name = std::string((char *)buf,s);
break;
case CERTIFICATE_PTAG_SSLID_SECTION:
if(s != location_id.SIZE_IN_BYTES)
{
err_code = CERTIFICATE_PARSING_ERROR_INVALID_LOCATION_ID;
return false;
}
location_id = RsPeerId(buf);
only_pgp = false;
break;
case CERTIFICATE_PTAG_DNS_SECTION:
dns_name = std::string((char *)buf,s);
break;
case CERTIFICATE_PTAG_HIDDENNODE_SECTION:
hidden_node_address = std::string((char *)buf,s);
hidden_node = true;
break;
case CERTIFICATE_PTAG_LOCIPANDPORT_SECTION:
if(s != 6)
{
err_code = CERTIFICATE_PARSING_ERROR_INVALID_LOCAL_IP;
return false;
}
memcpy(ipv4_internal_ip_and_port,buf,s);
break;
case CERTIFICATE_PTAG_EXTIPANDPORT_SECTION:
if(s != 6)
{
err_code = CERTIFICATE_PARSING_ERROR_INVALID_EXTERNAL_IP;
return false;
}
memcpy(ipv4_external_ip_and_port,buf,s);
break;
case CERTIFICATE_PTAG_CHECKSUM_SECTION:
{
if(s != 3 || total_s+3 != size)
{
err_code =
CERTIFICATE_PARSING_ERROR_INVALID_CHECKSUM_SECTION;
return false;
}
uint32_t computed_crc =
PGPKeyManagement::compute24bitsCRC(bf.data(),size-5);
uint32_t certificate_crc =
buf[0] + (buf[1] << 8) + (buf[2] << 16);
if(computed_crc != certificate_crc)
{
err_code = CERTIFICATE_PARSING_ERROR_CHECKSUM_ERROR;
return false;
}
else checksum_check_passed = true;
break;
}
case CERTIFICATE_PTAG_EXTRA_LOCATOR:
mLocators.insert(RsUrl(std::string((char *)buf, s)));
break;
default:
std::cerr << "(WW) unknwown PTAG 0x" << std::hex << ptag
<< std::dec << " in certificate! Ignoring it."
<< std::endl;
break;
}
buf = &buf[s];
total_s += s ;
}

View File

@ -22,9 +22,30 @@
#pragma once
#pragma once
/*
* RetroShare
*
* Copyright (C) 2012-2014 Cyril Soler <csoler@users.sourceforge.net>
*
* 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 <http://www.gnu.org/licenses/>.
*/
#include "retroshare/rstypes.h"
#include "util/rsurl.h"
#include <set>
#include <string>
#include <retroshare/rstypes.h>
class RsPeerDetails ;
@ -65,6 +86,7 @@ class RsCertificate
size_t pgp_key_size() const { return binary_pgp_key_size ; }
static bool cleanCertificate(const std::string& input, std::string& output, RsCertificate::Format& format, int& error_code, bool check_content) ;
const std::set<RsUrl>& locators() const { return mLocators; }
private:
static bool cleanCertificate(const std::string& input,std::string& output,int&) ; // new radix format
@ -92,6 +114,7 @@ class RsCertificate
std::string pgp_version ;
std::string dns_name ;
std::string hidden_node_address;
std::set<RsUrl> mLocators;
bool only_pgp ; // does the cert contain only pgp info?
bool hidden_node; // IP or hidden Node Address.

View File

@ -983,8 +983,8 @@ bool p3NetMgrIMPL::checkNetAddress()
bool addrChanged = false;
bool validAddr = false;
struct sockaddr_storage prefAddr;
struct sockaddr_storage oldAddr;
sockaddr_storage prefAddr;
sockaddr_storage oldAddr;
if (mNetMode & RS_NET_MODE_TRY_LOOPBACK)
{
@ -992,7 +992,7 @@ bool p3NetMgrIMPL::checkNetAddress()
std::cerr << "p3NetMgrIMPL::checkNetAddress() LOOPBACK ... forcing to 127.0.0.1";
std::cerr << std::endl;
#endif
sockaddr_storage_ipv4_aton(prefAddr, "127.0.0.1");
sockaddr_storage_ipv4_aton(prefAddr, "127.0.0.1");
validAddr = true;
}
else
@ -1008,7 +1008,7 @@ bool p3NetMgrIMPL::checkNetAddress()
std::vector<sockaddr_storage> addrs;
if (getLocalAddresses(addrs))
{
for (auto it = addrs.begin(); it!=addrs.end(); ++it)
for (auto it = addrs.begin(); it != addrs.end(); ++it)
{
sockaddr_storage& addr(*it);
if( sockaddr_storage_isValidNet(addr) &&
@ -1056,8 +1056,8 @@ bool p3NetMgrIMPL::checkNetAddress()
{
RS_STACK_MUTEX(mNetMtx);
oldAddr = mLocalAddr;
sockaddr_storage_copy(mLocalAddr, oldAddr);
addrChanged = !sockaddr_storage_sameip(prefAddr, mLocalAddr);
#ifdef NETMGR_DEBUG_TICK
@ -1083,7 +1083,7 @@ bool p3NetMgrIMPL::checkNetAddress()
// update address.
sockaddr_storage_copyip(mLocalAddr, prefAddr);
mNetFlags.mLocalAddr = mLocalAddr;
sockaddr_storage_copy(mLocalAddr, mNetFlags.mLocalAddr);
if(sockaddr_storage_isLoopbackNet(mLocalAddr))
{
@ -1115,12 +1115,7 @@ bool p3NetMgrIMPL::checkNetAddress()
#ifdef NETMGR_DEBUG
std::cerr << "p3NetMgrIMPL::checkNetAddress() Correcting Port to DEFAULT" << std::endl;
#endif
// Generate a default port from SSL id. The port will always be the
// same, but appear random from peer to peer.
// Random port avoids clashes, improves anonymity.
//
int new_port = htons(PQI_MIN_PORT_RNG + (RSRandom::random_u32() % (PQI_MAX_PORT - PQI_MIN_PORT_RNG)));
uint16_t new_port = htons(PQI_MIN_PORT_RNG + (RSRandom::random_u32() % (PQI_MAX_PORT - PQI_MIN_PORT_RNG)));
sockaddr_storage_setport(mLocalAddr, new_port);
addrChanged = true;
@ -1130,9 +1125,13 @@ bool p3NetMgrIMPL::checkNetAddress()
* are the same (modify server)... this mismatch can
* occur when the local port is changed....
*/
if (sockaddr_storage_sameip(mLocalAddr, mExtAddr))
if (sockaddr_storage_sameip(mLocalAddr, mExtAddr) && sockaddr_storage_port(mLocalAddr) != sockaddr_storage_port(mExtAddr))
{
#ifdef NETMGR_DEBUG_RESET
std::cerr << "p3NetMgrIMPL::checkNetAddress() local and external ports are not the same. Setting external port to " << sockaddr_storage_port(mLocalAddr) << std::endl;
#endif
sockaddr_storage_setport(mExtAddr, sockaddr_storage_port(mLocalAddr));
addrChanged = true;
}
// ensure that address family is set, otherwise windows Barfs.

View File

@ -1235,11 +1235,11 @@ bool p3PeerMgrIMPL::UpdateOwnAddress( const sockaddr_storage& pLocalAddr,
sockaddr_storage_copy(pExtAddr, extAddr);
sockaddr_storage_ipv6_to_ipv4(extAddr);
#ifdef PEER_DEBUG
//#ifdef PEER_DEBUG
std::cerr << "p3PeerMgrIMPL::UpdateOwnAddress("
<< sockaddr_storage_tostring(localAddr) << ", "
<< sockaddr_storage_tostring(extAddr) << ")" << std::endl;
#endif
//#endif
if( rsBanList &&
!rsBanList->isAddressAccepted(localAddr,
@ -1361,16 +1361,63 @@ bool p3PeerMgrIMPL::UpdateOwnAddress( const sockaddr_storage& pLocalAddr,
}
bool p3PeerMgrIMPL::addPeerLocator(const RsPeerId &sslId, const RsUrl& locator)
{
std::string host(locator.host());
pqiIpAddress ip;
if(!locator.hasPort() || host.empty() ||
!sockaddr_storage_inet_pton(ip.mAddr, host) ||
!sockaddr_storage_setport(ip.mAddr, locator.port())) return false;
ip.mSeenTime = time(NULL);
bool changed = false;
bool p3PeerMgrIMPL::setLocalAddress(const RsPeerId &id, const struct sockaddr_storage &addr)
if (sslId == AuthSSL::getAuthSSL()->OwnId())
{
RS_STACK_MUTEX(mPeerMtx);
changed = mOwnState.ipAddrs.updateLocalAddrs(ip);
}
else
{
RS_STACK_MUTEX(mPeerMtx);
auto it = mFriendList.find(sslId);
if (it == mFriendList.end())
{
it = mOthersList.find(sslId);
if (it == mOthersList.end())
{
#ifdef PEER_DEBUG
std::cerr << __PRETTY_FUNCTION__ << "cannot add address "
<< "info, peer id: " << sslId << " not found in list"
<< std::endl;
#endif
return false;
}
}
changed = it->second.ipAddrs.updateLocalAddrs(ip);
}
if (changed)
{
#ifdef PEER_DEBUG
std::cerr << __PRETTY_FUNCTION__ << " Added locator: "
<< locator.toString() << std::endl;
#endif
IndicateConfigChanged();
}
return changed;
}
bool p3PeerMgrIMPL::setLocalAddress( const RsPeerId &id,
const sockaddr_storage &addr )
{
bool changed = false;
if (id == AuthSSL::getAuthSSL()->OwnId())
{
{
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
RS_STACK_MUTEX(mPeerMtx);
if (!sockaddr_storage_same(mOwnState.localaddr, addr))
{
mOwnState.localaddr = addr;
@ -1388,7 +1435,7 @@ bool p3PeerMgrIMPL::setLocalAddress(const RsPeerId &id, const struct sockaddr
return changed;
}
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
RS_STACK_MUTEX(mPeerMtx);
/* check if it is a friend */
std::map<RsPeerId, peerState>::iterator it;
if (mFriendList.end() == (it = mFriendList.find(id)))
@ -1396,7 +1443,9 @@ bool p3PeerMgrIMPL::setLocalAddress(const RsPeerId &id, const struct sockaddr
if (mOthersList.end() == (it = mOthersList.find(id)))
{
#ifdef PEER_DEBUG
std::cerr << "p3PeerMgrIMPL::setLocalAddress() cannot add addres info : peer id not found in friend list id: " << id << std::endl;
std::cerr << "p3PeerMgrIMPL::setLocalAddress() cannot add addres "
<< "info : peer id not found in friend list id: "
<< id << std::endl;
#endif
return false;
}
@ -1417,28 +1466,29 @@ bool p3PeerMgrIMPL::setLocalAddress(const RsPeerId &id, const struct sockaddr
it->second.updateIpAddressList(ipAddressTimed);
#endif
if (changed) {
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
}
if (changed) IndicateConfigChanged();
return changed;
}
bool p3PeerMgrIMPL::setExtAddress(const RsPeerId &id, const struct sockaddr_storage &addr)
bool p3PeerMgrIMPL::setExtAddress( const RsPeerId &id,
const sockaddr_storage &addr )
{
bool changed = false;
uint32_t check_res = 0 ;
bool changed = false;
uint32_t check_res = 0;
if(rsBanList!=NULL && !rsBanList->isAddressAccepted(addr,RSBANLIST_CHECKING_FLAGS_BLACKLIST,&check_res))
{
std::cerr << "(SS) trying to set external contact address for peer " << id << " to a banned address " << sockaddr_storage_iptostring(addr )<< std::endl;
return false ;
}
if( rsBanList!=NULL && !rsBanList->isAddressAccepted(
addr, RSBANLIST_CHECKING_FLAGS_BLACKLIST, &check_res) )
{
std::cerr << "(SS) trying to set external contact address for peer "
<< id << " to a banned address "
<< sockaddr_storage_iptostring(addr) << std::endl;
return false;
}
if (id == AuthSSL::getAuthSSL()->OwnId())
{
{
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
RS_STACK_MUTEX(mPeerMtx);
if (!sockaddr_storage_same(mOwnState.serveraddr, addr))
{
mOwnState.serveraddr = addr;
@ -1451,7 +1501,7 @@ bool p3PeerMgrIMPL::setExtAddress(const RsPeerId &id, const struct sockaddr_s
return changed;
}
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
RS_STACK_MUTEX(mPeerMtx);
/* check if it is a friend */
std::map<RsPeerId, peerState>::iterator it;
if (mFriendList.end() == (it = mFriendList.find(id)))
@ -1459,7 +1509,9 @@ bool p3PeerMgrIMPL::setExtAddress(const RsPeerId &id, const struct sockaddr_s
if (mOthersList.end() == (it = mOthersList.find(id)))
{
#ifdef PEER_DEBUG
std::cerr << "p3PeerMgrIMPL::setLocalAddress() cannot add addres info : peer id not found in friend list id: " << id << std::endl;
std::cerr << "p3PeerMgrIMPL::setLocalAddress() cannot add addres "
<< "info : peer id not found in friend list id: " << id
<< std::endl;
#endif
return false;
}

View File

@ -159,6 +159,7 @@ virtual bool assignPeersToGroup(const RsNodeGroupId &groupId, const std::list
* 3) p3disc - reasonable
*/
virtual bool addPeerLocator(const RsPeerId &ssl_id, const RsUrl& locator) = 0;
virtual bool setLocalAddress(const RsPeerId &id, const struct sockaddr_storage &addr) = 0;
virtual bool setExtAddress(const RsPeerId &id, const struct sockaddr_storage &addr) = 0;
virtual bool setDynDNS(const RsPeerId &id, const std::string &dyndns) = 0;
@ -273,6 +274,7 @@ public:
* 3) p3disc - reasonable
*/
virtual bool addPeerLocator(const RsPeerId &ssl_id, const RsUrl& locator);
virtual bool setLocalAddress(const RsPeerId &id, const struct sockaddr_storage &addr);
virtual bool setExtAddress(const RsPeerId &id, const struct sockaddr_storage &addr);
virtual bool setDynDNS(const RsPeerId &id, const std::string &dyndns);

View File

@ -223,6 +223,15 @@ int pqissludp::Initiate_Connection()
return -1;
}
if(!sockaddr_storage_ipv6_to_ipv4(remote_addr))
{
std::cerr << __PRETTY_FUNCTION__ << "Error: remote_addr is not "
<< "valid IPv4!" << std::endl;
sockaddr_storage_dump(remote_addr);
print_stacktrace();
return -EINVAL;
}
mTimeoutTS = time(NULL) + mConnectTimeout;
//std::cerr << "Setting Connect Timeout " << mConnectTimeout << " Seconds into Future " << std::endl;
//std::cerr << " Connect Period is:" << mConnectPeriod << std::endl;
@ -250,32 +259,22 @@ int pqissludp::Initiate_Connection()
struct sockaddr_in proxyaddr;
struct sockaddr_in remoteaddr;
bool nonIpV4 = false;
if(!sockaddr_storage_ipv6_to_ipv4(remote_addr))
{
nonIpV4 = true;
std::cerr << __PRETTY_FUNCTION__ << "Error: remote_addr is not "
<< "valid IPv4!" << std::endl;
sockaddr_storage_dump(remote_addr);
}
if(!sockaddr_storage_ipv6_to_ipv4(mConnectSrcAddr))
{
nonIpV4 = true;
std::cerr << __PRETTY_FUNCTION__ << "Error: mConnectSrcAddr is "
<< "not valid IPv4!" << std::endl;
sockaddr_storage_dump(mConnectSrcAddr);
print_stacktrace();
return -EINVAL;
}
if(!sockaddr_storage_ipv6_to_ipv4(mConnectProxyAddr))
{
nonIpV4 = true;
std::cerr << __PRETTY_FUNCTION__ << "Error: mConnectProxyAddr "
<< "is not valid IPv4!" << std::endl;
sockaddr_storage_dump(mConnectProxyAddr);
}
if(!nonIpV4)
{
print_stacktrace();
return -EINVAL;
}
struct sockaddr_in *rap = (struct sockaddr_in *) &remote_addr;
@ -297,7 +296,6 @@ int pqissludp::Initiate_Connection()
err = tou_connect_via_relay(sockfd, &srcaddr, &proxyaddr, &remoteaddr);
}
/*** It seems that the UDP Layer sees x 1.2 the traffic of the SSL layer.
* We need to compensate somewhere... we drop the maximum traffic to 75% of limit

View File

@ -163,10 +163,9 @@ public:
class RsFiles
{
public:
RsFiles() { return; }
virtual ~RsFiles() { return; }
public:
RsFiles() {}
virtual ~RsFiles() {}
/**
* Provides file data for the gui: media streaming or rpc clients.

View File

@ -40,8 +40,8 @@ class RsGxsChanges
public:
RsGxsChanges(): mService(0){}
RsTokenService *mService;
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > mMsgs;
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > mMsgsMeta;
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > mMsgs;
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > mMsgsMeta;
std::list<RsGxsGroupId> mGrps;
std::list<RsGxsGroupId> mGrpsMeta;
};

View File

@ -38,10 +38,10 @@ typedef Sha1CheckSum RsGxsMessageId;
typedef GXSId RsGxsId;
typedef GXSCircleId RsGxsCircleId;
typedef std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > GxsMsgIdResult;
typedef std::map<RsGxsGroupId, std::set<RsGxsMessageId> > GxsMsgIdResult;
typedef std::pair<RsGxsGroupId, RsGxsMessageId> RsGxsGrpMsgIdPair;
typedef std::map<RsGxsGrpMsgIdPair, std::vector<RsGxsMessageId> > MsgRelatedIdResult;
typedef std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > GxsMsgReq;
typedef std::map<RsGxsGrpMsgIdPair, std::set<RsGxsMessageId> > MsgRelatedIdResult;
typedef std::map<RsGxsGroupId, std::set<RsGxsMessageId> > GxsMsgReq;
struct RsMsgMetaData;

View File

@ -67,7 +67,7 @@ class RsGxsMsgChange : public RsGxsNotify
{
public:
RsGxsMsgChange(NotifyType type, bool metaChange) : NOTIFY_TYPE(type), mMetaChange(metaChange) {}
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > msgChangeMap;
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > msgChangeMap;
NotifyType getType(){ return NOTIFY_TYPE;}
bool metaChange() { return mMetaChange; }
private:

View File

@ -29,6 +29,7 @@
#include <retroshare/rstypes.h>
#include <retroshare/rsfiles.h>
#include <retroshare/rsids.h>
#include "util/rsurl.h"
/* The Main Interface Class - for information about your Peers
* A peer is another RS instance, means associated with an SSL certificate
@ -366,6 +367,7 @@ public:
virtual bool setHiddenNode(const RsPeerId &id, const std::string &address, uint16_t port) = 0;
virtual bool isHiddenNode(const RsPeerId &id) = 0;
virtual bool addPeerLocator(const RsPeerId &ssl_id, const RsUrl& locator) = 0;
virtual bool setLocalAddress(const RsPeerId &ssl_id, const std::string &addr, uint16_t port) = 0;
virtual bool setExtAddress( const RsPeerId &ssl_id, const std::string &addr, uint16_t port) = 0;
virtual bool setDynDNS(const RsPeerId &id, const std::string &addr) = 0;
@ -380,11 +382,30 @@ public:
virtual bool resetOwnExternalAddressList() = 0;
virtual bool getAllowServerIPDetermination() = 0 ;
/**
* @brief Get RetroShare invite of the given peer
* @param[in] sslId Id of the peer of which we want to generate an invite
* @param[in] includeSignatures true to add key signatures to the invite
* @param[in] includeExtraLocators false to avoid to add extra locators
* @return invite string
*/
virtual std::string GetRetroshareInvite(
const RsPeerId& sslId, bool includeSignatures = false,
bool includeExtraLocators = true ) = 0;
/**
* @brief Get RetroShare invite of our own peer
* @param[in] includeSignatures true to add key signatures to the invite
* @param[in] includeExtraLocators false to avoid to add extra locators
* @return invite string
*/
virtual std::string GetRetroshareInvite(
bool includeSignatures = false,
bool includeExtraLocators = true ) = 0;
/* Auth Stuff */
virtual std::string GetRetroshareInvite(const RsPeerId& ssl_id,bool include_signatures) = 0;
virtual std::string getPGPKey(const RsPgpId& pgp_id,bool include_signatures) = 0;
virtual bool GetPGPBase64StringAndCheckSum(const RsPgpId& gpg_id,std::string& gpg_base64_string,std::string& gpg_base64_checksum) = 0;
virtual std::string GetRetroshareInvite(bool include_signatures) = 0;
virtual bool hasExportMinimal() = 0;
// Add keys to the keyring

View File

@ -57,14 +57,17 @@
/* TODO CLEANUP: RS_TOKREQ_ANSTYPE_* values are meaningless and not used by
* RsTokenService or its implementation, and may be arbitrarly defined by each
* GXS client as they are of no usage, their use is deprecated */
* GXS client as they are of no usage, their use is deprecated, up until the
* definitive cleanup is done new code must use RS_DEPRECATED_TOKREQ_ANSTYPE for
* easier cleanup. */
#ifndef RS_NO_WARN_DEPRECATED
# warning RS_TOKREQ_ANSTYPE_* macros are deprecated!
#endif
#define RS_TOKREQ_ANSTYPE_LIST 0x0001
#define RS_TOKREQ_ANSTYPE_SUMMARY 0x0002
#define RS_TOKREQ_ANSTYPE_DATA 0x0003
#define RS_TOKREQ_ANSTYPE_ACK 0x0004
#define RS_DEPRECATED_TOKREQ_ANSTYPE 0x0000
#define RS_TOKREQ_ANSTYPE_LIST 0x0001
#define RS_TOKREQ_ANSTYPE_SUMMARY 0x0002
#define RS_TOKREQ_ANSTYPE_DATA 0x0003
#define RS_TOKREQ_ANSTYPE_ACK 0x0004
/*!

View File

@ -57,24 +57,23 @@ void RsGxsPhotoAlbumItem::serial_process(RsGenericSerializer::SerializeJob j,RsG
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_LOCATION, album.mWhere, "mWhere");
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_PIC_TYPE, album.mThumbnail.type,"mThumbnail.type");
RsTlvBinaryDataRef b(RS_SERVICE_GXS_TYPE_PHOTO, album.mThumbnail.data,album.mThumbnail.size);
RsTypeSerializer::serial_process<RsTlvItem>(j,ctx,b,"thumbnail binary data") ;
RsTlvBinaryDataRef b(RS_SERVICE_GXS_TYPE_PHOTO, album.mThumbnail.data, album.mThumbnail.size);
RsTypeSerializer::serial_process<RsTlvItem>(j, ctx, b, "thumbnail binary data") ;
}
void RsGxsPhotoPhotoItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
{
RsTypeSerializer::serial_process(j,ctx, TLV_TYPE_STR_CAPTION, photo.mCaption);
RsTypeSerializer::serial_process(j,ctx, TLV_TYPE_STR_CATEGORY, photo.mCategory);
RsTypeSerializer::serial_process(j,ctx, TLV_TYPE_STR_DESCR, photo.mDescription);
RsTypeSerializer::serial_process(j,ctx, TLV_TYPE_STR_HASH_TAG, photo.mHashTags);
RsTypeSerializer::serial_process(j,ctx, TLV_TYPE_STR_MSG, photo.mOther);
RsTypeSerializer::serial_process(j,ctx, TLV_TYPE_STR_PIC_AUTH, photo.mPhotographer);
RsTypeSerializer::serial_process(j,ctx, TLV_TYPE_STR_DATE, photo.mWhen);
RsTypeSerializer::serial_process(j,ctx, TLV_TYPE_STR_LOCATION, photo.mWhere);
RsTypeSerializer::serial_process(j,ctx, TLV_TYPE_STR_PIC_TYPE, photo.mThumbnail.type);
RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_CAPTION, photo.mCaption, "mCaption");
RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_CATEGORY, photo.mCategory, "mCategory");
RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_DESCR, photo.mDescription, "mDescription");
RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_HASH_TAG, photo.mHashTags, "mHashTags");
RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_MSG, photo.mOther, "mOther");
RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_PIC_AUTH, photo.mPhotographer, "mPhotographer");
RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_DATE, photo.mWhen, "mWhen");
RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_LOCATION, photo.mWhere, "mWhere");
RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_PIC_TYPE, photo.mThumbnail.type, "mThumbnail.type");
RsTlvBinaryDataRef b(RS_SERVICE_GXS_TYPE_PHOTO,photo.mThumbnail.data, photo.mThumbnail.size);
RsTypeSerializer::serial_process<RsTlvItem>(j,ctx, b, "mThumbnail") ;
RsTlvBinaryDataRef b(RS_SERVICE_GXS_TYPE_PHOTO, photo.mThumbnail.data, photo.mThumbnail.size);
RsTypeSerializer::serial_process<RsTlvItem>(j, ctx, b, "mThumbnail") ;
}
void RsGxsPhotoCommentItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
{

View File

@ -46,7 +46,7 @@ public:
virtual ~RsGxsPhotoAlbumItem() { return;}
void clear();
std::ostream &print(std::ostream &out, uint16_t indent = 0);
// std::ostream &print(std::ostream &out, uint16_t indent = 0);
virtual void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);

View File

@ -332,8 +332,8 @@ bool p3Peers::getPeerDetails(const RsPeerId& id, RsPeerDetails &d)
if(!sockaddr_storage_isnull(ps.localaddr))
{
sockaddr_storage_ipv6_to_ipv4(ps.localaddr);
d.localAddr = sockaddr_storage_iptostring(ps.localaddr);
d.localPort = sockaddr_storage_port(ps.localaddr);
d.localAddr = sockaddr_storage_iptostring(ps.localaddr);
d.localPort = sockaddr_storage_port(ps.localaddr);
}
else
{
@ -900,6 +900,9 @@ bool p3Peers::setHiddenNode(const RsPeerId &id, const std::string &address, uin
return true;
}
bool p3Peers::addPeerLocator(const RsPeerId &ssl_id, const RsUrl& locator)
{ return mPeerMgr->addPeerLocator(ssl_id, locator); }
bool p3Peers::setLocalAddress(const RsPeerId &id,
const std::string &addr_str, uint16_t port)
{
@ -1041,9 +1044,11 @@ bool p3Peers::setProxyServer(const uint32_t type, const std::string &addr_str, c
//===========================================================================
/* Auth Stuff */
std::string p3Peers::GetRetroshareInvite(bool include_signatures)
std::string p3Peers::GetRetroshareInvite(
bool include_signatures, bool includeExtraLocators )
{
return GetRetroshareInvite(getOwnId(),include_signatures);
return GetRetroshareInvite(
getOwnId(), include_signatures, includeExtraLocators );
}
std::string p3Peers::getPGPKey(const RsPgpId& pgp_id,bool include_signatures)
{
@ -1094,37 +1099,42 @@ bool p3Peers::GetPGPBase64StringAndCheckSum( const RsPgpId& gpg_id,
return true ;
}
std::string p3Peers::GetRetroshareInvite(const RsPeerId& ssl_id,bool include_signatures)
std::string p3Peers::GetRetroshareInvite(
const RsPeerId& ssl_id, bool include_signatures,
bool includeExtraLocators )
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::GetRetroshareInvite()" << std::endl;
std::cerr << __PRETTY_FUNCTION__ << std::endl;
#endif
//add the sslid, location, ip local and external address after the signature
RsPeerDetails Detail;
std::string invite ;
RsPeerDetails detail;
std::string invite;
if (getPeerDetails(ssl_id, Detail))
if (getPeerDetails(ssl_id, detail))
{
unsigned char *mem_block = NULL;
if(!includeExtraLocators) detail.ipAddressList.clear();
unsigned char *mem_block = nullptr;
size_t mem_block_size = 0;
if(!AuthGPG::getAuthGPG()->exportPublicKey(RsPgpId(Detail.gpg_id),mem_block,mem_block_size,false,include_signatures))
if(!AuthGPG::getAuthGPG()->exportPublicKey(
RsPgpId(detail.gpg_id), mem_block, mem_block_size, false,
include_signatures ))
{
std::cerr << "Cannot output certificate for id \"" << Detail.gpg_id << "\". Sorry." << std::endl;
return "" ;
std::cerr << "Cannot output certificate for id \"" << detail.gpg_id
<< "\". Sorry." << std::endl;
return "";
}
RsCertificate cert( Detail,mem_block,mem_block_size ) ;
delete[] mem_block ;
return cert.toStdString() ;
RsCertificate cert(detail, mem_block, mem_block_size);
delete[] mem_block;
return cert.toStdString();
}
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::GetRetroshareInvite() returns : \n" << invite << std::endl;
std::cerr << __PRETTY_FUNCTION__ << " returns : \n" << invite << std::endl;
#endif
return invite;
}
@ -1144,11 +1154,12 @@ bool p3Peers::loadCertificateFromString(const std::string& cert, RsPeerId& ssl_
return res ;
}
bool p3Peers::loadDetailsFromStringCert(const std::string &certstr, RsPeerDetails &pd,uint32_t& error_code)
bool p3Peers::loadDetailsFromStringCert( const std::string &certstr,
RsPeerDetails &pd,
uint32_t& error_code )
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::LoadCertificateFromString() ";
std::cerr << std::endl;
std::cerr << "p3Peers::LoadCertificateFromString() " << std::endl;
#endif
//parse the text to get ip address
try
@ -1188,9 +1199,11 @@ bool p3Peers::loadDetailsFromStringCert(const std::string &certstr, RsPeerDetai
pd.localPort = cert.loc_port_us();
pd.extAddr = cert.ext_ip_string();
pd.extPort = cert.ext_port_us();
pd.dyndns = cert.dns_string() ;
pd.dyndns = cert.dns_string();
for(const RsUrl& locator : cert.locators())
pd.ipAddressList.push_back(locator.toString());
}
}
}
catch(uint32_t e)
{
std::cerr << "ConnectFriendWizard : Parse ip address error :" << e << std::endl;

View File

@ -31,6 +31,7 @@
#endif
#include "retroshare/rspeers.h"
#include "util/rsurl.h"
class p3LinkMgr;
class p3PeerMgr;
@ -91,7 +92,8 @@ public:
virtual bool setHiddenNode(const RsPeerId &id, const std::string &address, uint16_t port);
virtual bool isHiddenNode(const RsPeerId &id);
virtual bool setLocalAddress(const RsPeerId &id, const std::string &addr, uint16_t port);
virtual bool addPeerLocator(const RsPeerId &ssl_id, const RsUrl& locator);
virtual bool setLocalAddress(const RsPeerId &id, const std::string &addr, uint16_t port);
virtual bool setExtAddress(const RsPeerId &id, const std::string &addr, uint16_t port);
virtual bool setDynDNS(const RsPeerId &id, const std::string &dyndns);
virtual bool setNetworkMode(const RsPeerId &id, uint32_t netMode);
@ -108,11 +110,15 @@ public:
/* Auth Stuff */
// Get the invitation (GPG cert + local/ext address + SSL id for the given peer)
virtual std::string GetRetroshareInvite(const RsPeerId& ssl_id,bool include_signatures);
virtual std::string getPGPKey(const RsPgpId& pgp_id,bool include_signatures) ;
virtual std::string GetRetroshareInvite(
const RsPeerId& ssl_id, bool include_signatures = false,
bool includeExtraLocators = true );
virtual std::string getPGPKey(const RsPgpId& pgp_id,bool include_signatures);
// same but for own id
virtual std::string GetRetroshareInvite(bool include_signatures);
virtual std::string GetRetroshareInvite(
bool include_signatures = false,
bool includeExtraLocators = true );
virtual bool GetPGPBase64StringAndCheckSum(const RsPgpId& gpg_id,std::string& gpg_base64_string,std::string& gpg_base64_checksum);
virtual bool hasExportMinimal();

View File

@ -1348,11 +1348,11 @@ int RsServer::StartupRetroShare()
p3Wiki *mWiki = new p3Wiki(wiki_ds, NULL, mGxsIdService);
// create GXS wiki service
RsGxsNetService* wiki_ns = new RsGxsNetService(
RS_SERVICE_GXS_TYPE_WIKI, wiki_ds, nxsMgr,
mWiki, mWiki->getServiceInfo(),
mGxsIdService, mGxsCircles,
pgpAuxUtils);
RsGxsNetService* wiki_ns = new RsGxsNetService(
RS_SERVICE_GXS_TYPE_WIKI, wiki_ds, nxsMgr,
mWiki, mWiki->getServiceInfo(),
mReputations, mGxsCircles, mGxsIdService,
pgpAuxUtils);
mWiki->setNetworkExchangeService(wiki_ns) ;
#endif

View File

@ -222,6 +222,13 @@ struct RsGenericSerializer : RsSerialType
/** Allow shared allocator usage to avoid costly JSON deepcopy for
* nested RsSerializable */
SerializeContext(
uint8_t *data, uint32_t size,
SerializationFlags flags = SERIALIZATION_FLAG_NONE,
RsJson::AllocatorType* allocator = nullptr) :
mData(data), mSize(size), mOffset(0), mOk(true), mFlags(flags),
mJson(rapidjson::kObjectType, allocator) {}
RS_DEPRECATED SerializeContext(
uint8_t *data, uint32_t size, SerializationFormat format,
SerializationFlags flags,
RsJson::AllocatorType* allocator = nullptr) :

View File

@ -288,8 +288,8 @@ bool RsTypeSerializer::from_JSON( const std::string& memberName,
uint64_t& member, RsJson& jDoc )
{
SAFE_GET_JSON_V();
ret = ret && v.IsUint();
if(ret) member = v.GetUint();
ret = ret && v.IsUint64();
if(ret) member = v.GetUint64();
return ret;
}

View File

@ -214,8 +214,7 @@ RsGenExchange::ServiceCreate_Return p3GxsChannels::service_CreateGroup(RsGxsGrpI
void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
{
#ifdef GXSCHANNELS_DEBUG
std::cerr << "p3GxsChannels::notifyChanges()";
std::cerr << std::endl;
std::cerr << "p3GxsChannels::notifyChanges() : " << changes.size() << "changes to notify" << std::endl;
#endif
p3Notify *notify = NULL;
@ -238,16 +237,12 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
/* message received */
if (notify)
{
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &msgChangeMap = msgChange->msgChangeMap;
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >::iterator mit;
for (mit = msgChangeMap.begin(); mit != msgChangeMap.end(); ++mit)
{
std::vector<RsGxsMessageId>::iterator mit1;
for (mit1 = mit->second.begin(); mit1 != mit->second.end(); ++mit1)
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &msgChangeMap = msgChange->msgChangeMap;
for (auto mit = msgChangeMap.begin(); mit != msgChangeMap.end(); ++mit)
for (auto mit1 = mit->second.begin(); mit1 != mit->second.end(); ++mit1)
{
notify->AddFeedItem(RS_FEED_ITEM_CHANNEL_MSG, mit->first.toStdString(), mit1->toStdString());
}
}
}
}
@ -258,9 +253,8 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
std::cerr << std::endl;
#endif
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &msgChangeMap = msgChange->msgChangeMap;
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >::iterator mit;
for(mit = msgChangeMap.begin(); mit != msgChangeMap.end(); ++mit)
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &msgChangeMap = msgChange->msgChangeMap;
for(auto mit = msgChangeMap.begin(); mit != msgChangeMap.end(); ++mit)
{
#ifdef GXSCHANNELS_DEBUG
std::cerr << "p3GxsChannels::notifyChanges() Msgs for Group: " << mit->first;
@ -804,10 +798,7 @@ void p3GxsChannels::request_SpecificUnprocessedPosts(std::list<std::pair<RsGxsGr
GxsMsgReq msgIds;
std::list<std::pair<RsGxsGroupId, RsGxsMessageId> >::iterator it;
for(it = ids.begin(); it != ids.end(); ++it)
{
std::vector<RsGxsMessageId> &vect_msgIds = msgIds[it->first];
vect_msgIds.push_back(it->second);
}
msgIds[it->first].insert(it->second);
RsGenExchange::getTokenService()->requestMsgInfo(token, ansType, opts, msgIds);
GxsTokenQueue::queueRequest(token, GXSCHANNELS_UNPROCESSED_SPECIFIC);

View File

@ -208,14 +208,14 @@ void p3GxsCircles::notifyChanges(std::vector<RsGxsNotify *> &changes)
#ifdef DEBUG_CIRCLES
std::cerr << " Found circle Message Change Notification" << std::endl;
#endif
for(std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >::iterator mit = msgChange->msgChangeMap.begin(); mit != msgChange->msgChangeMap.end(); ++mit)
for(auto mit = msgChange->msgChangeMap.begin(); mit != msgChange->msgChangeMap.end(); ++mit)
{
#ifdef DEBUG_CIRCLES
std::cerr << " Msgs for Group: " << mit->first << std::endl;
#endif
force_cache_reload(RsGxsCircleId(mit->first));
if (notify && (c->getType() == RsGxsNotify::TYPE_RECEIVE) )
for (std::vector<RsGxsMessageId>::const_iterator msgIdIt(mit->second.begin()), end(mit->second.end()); msgIdIt != end; ++msgIdIt)
for (auto msgIdIt(mit->second.begin()), end(mit->second.end()); msgIdIt != end; ++msgIdIt)
{
const RsGxsMessageId& msgId = *msgIdIt;
notify->AddFeedItem(RS_FEED_ITEM_CIRCLE_MEMB_REQ,RsGxsCircleId(mit->first).toStdString(),msgId.toStdString());
@ -2116,7 +2116,7 @@ bool p3GxsCircles::processMembershipRequests(uint32_t token)
#ifdef DEBUG_CIRCLES
std::cerr << " Older than last known (" << time(NULL)-info.last_subscription_TS << " seconds ago): deleting." << std::endl;
#endif
messages_to_delete[RsGxsGroupId(cid)].push_back(it->second[i]->meta.mMsgId) ;
messages_to_delete[RsGxsGroupId(cid)].insert(it->second[i]->meta.mMsgId) ;
}
}

View File

@ -498,8 +498,8 @@ bool p3GxsCommentService::createGxsVote(uint32_t &token, RsGxsVote &vote)
opts.mReqType = GXS_REQUEST_TYPE_MSG_META;
GxsMsgReq msgIds;
std::vector<RsGxsMessageId> &vect_msgIds = msgIds[parentId.first];
vect_msgIds.push_back(parentId.second);
std::set<RsGxsMessageId> &vect_msgIds = msgIds[parentId.first];
vect_msgIds.insert(parentId.second);
uint32_t int_token;
mExchange->getTokenService()->requestMsgInfo(int_token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, msgIds);

View File

@ -201,15 +201,12 @@ void p3GxsForums::notifyChanges(std::vector<RsGxsNotify *> &changes)
RsGxsMsgChange *msgChange = dynamic_cast<RsGxsMsgChange*>(c);
if (msgChange)
{
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &msgChangeMap = msgChange->msgChangeMap;
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >::iterator mit;
for (mit = msgChangeMap.begin(); mit != msgChangeMap.end(); ++mit)
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &msgChangeMap = msgChange->msgChangeMap;
for (auto mit = msgChangeMap.begin(); mit != msgChangeMap.end(); ++mit)
{
std::vector<RsGxsMessageId>::iterator mit1;
for (mit1 = mit->second.begin(); mit1 != mit->second.end(); ++mit1)
{
for (auto mit1 = mit->second.begin(); mit1 != mit->second.end(); ++mit1)
notify->AddFeedItem(RS_FEED_ITEM_FORUM_MSG, mit->first.toStdString(), mit1->toStdString());
}
}
break;
}

View File

@ -558,8 +558,8 @@ void p3IdService::notifyChanges(std::vector<RsGxsNotify *> &changes)
std::cerr << std::endl;
#endif
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &msgChangeMap = msgChange->msgChangeMap;
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >::iterator mit;
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &msgChangeMap = msgChange->msgChangeMap;
std::map<RsGxsGroupId, std::set<RsGxsMessageId> >::iterator mit;
for(mit = msgChangeMap.begin(); mit != msgChangeMap.end(); ++mit)
{
#ifdef DEBUG_IDS

View File

@ -106,9 +106,8 @@ void p3PostBase::notifyChanges(std::vector<RsGxsNotify *> &changes)
std::cerr << std::endl;
#endif
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &msgChangeMap = msgChange->msgChangeMap;
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >::iterator mit;
for(mit = msgChangeMap.begin(); mit != msgChangeMap.end(); ++mit)
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &msgChangeMap = msgChange->msgChangeMap;
for(auto mit = msgChangeMap.begin(); mit != msgChangeMap.end(); ++mit)
{
#ifdef POSTBASE_DEBUG
std::cerr << "p3PostBase::notifyChanges() Msgs for Group: " << mit->first;
@ -121,8 +120,7 @@ void p3PostBase::notifyChanges(std::vector<RsGxsNotify *> &changes)
if (notify && msgChange->getType() == RsGxsNotify::TYPE_RECEIVE)
{
std::vector<RsGxsMessageId>::iterator mit1;
for (mit1 = mit->second.begin(); mit1 != mit->second.end(); ++mit1)
for (auto mit1 = mit->second.begin(); mit1 != mit->second.end(); ++mit1)
{
notify->AddFeedItem(RS_FEED_ITEM_POSTED_MSG, mit->first.toStdString(), mit1->toStdString());
}
@ -427,7 +425,7 @@ void p3PostBase::background_loadMsgs(const uint32_t &token, bool unprocessed)
mBgIncremental = unprocessed;
}
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > postMap;
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > postMap;
// generate vector of changes to push to the GUI.
std::vector<RsGxsNotify *> changes;
@ -483,7 +481,7 @@ void p3PostBase::background_loadMsgs(const uint32_t &token, bool unprocessed)
#endif
/* but we need to notify GUI about them */
msgChanges->msgChangeMap[mit->first].push_back((*vit)->meta.mMsgId);
msgChanges->msgChangeMap[mit->first].insert((*vit)->meta.mMsgId);
}
else if (NULL != (commentItem = dynamic_cast<RsGxsCommentItem *>(*vit)))
{
@ -542,7 +540,7 @@ void p3PostBase::background_loadMsgs(const uint32_t &token, bool unprocessed)
if (sit == mBgStatsMap.end())
{
// add to map of ones to update.
postMap[groupId].push_back(threadId);
postMap[groupId].insert(threadId);
mBgStatsMap[threadId] = PostStats(0,0,0);
sit = mBgStatsMap.find(threadId);
@ -700,7 +698,7 @@ void p3PostBase::background_updateVoteCounts(const uint32_t &token)
#endif
stats.increment(it->second);
msgChanges->msgChangeMap[mit->first].push_back(vit->mMsgId);
msgChanges->msgChangeMap[mit->first].insert(vit->mMsgId);
}
else
{

View File

@ -30,6 +30,11 @@ bitdht {
!include("../../libbitdht/src/use_libbitdht.pri"):error("Including")
}
# when rapidjson is mainstream on all distribs, we will not need the sources
# anymore in the meantime, they are part of the RS directory so that it is
# always possible to find them
INCLUDEPATH *= $$system_path($$clean_path($${PWD}/../../rapidjson-1.1.0))
sLibs =
mLibs = $$RS_SQL_LIB ssl crypto $$RS_THREAD_LIB $$RS_UPNP_LIB
dLibs =

View File

@ -138,6 +138,7 @@ bool sockaddr_storage_sameip(const struct sockaddr_storage &addr, const struct s
// string,
std::string sockaddr_storage_tostring(const struct sockaddr_storage &addr);
bool sockaddr_storage_fromString(const std::string& str, sockaddr_storage &addr);
std::string sockaddr_storage_familytostring(const struct sockaddr_storage &addr);
std::string sockaddr_storage_iptostring(const struct sockaddr_storage &addr);
std::string sockaddr_storage_porttostring(const struct sockaddr_storage &addr);

View File

@ -21,6 +21,8 @@
* *
*******************************************************************************/
#include "util/rsurl.h"
#include <sstream>
#include <iomanip>
#include <cstdlib>
@ -187,8 +189,7 @@ bool sockaddr_storage_copyip(struct sockaddr_storage &dst, const struct sockaddr
uint16_t sockaddr_storage_port(const struct sockaddr_storage &addr)
{
#ifdef SS_DEBUG
std::cerr << "sockaddr_storage_port()";
std::cerr << std::endl;
std::cerr << "sockaddr_storage_port()" << std::endl;
#endif
switch(addr.ss_family)
{
@ -198,8 +199,10 @@ uint16_t sockaddr_storage_port(const struct sockaddr_storage &addr)
return sockaddr_storage_ipv6_port(addr);
default:
std::cerr << "sockaddr_storage_port() invalid addr.ss_family" << std::endl;
#ifdef SS_DEBUG
sockaddr_storage_dump(addr);
print_stacktrace();
#endif
break;
}
return 0;
@ -488,27 +491,32 @@ bool sockaddr_storage_sameip(const struct sockaddr_storage &addr, const struct s
std::string sockaddr_storage_tostring(const struct sockaddr_storage &addr)
{
std::string output;
output += sockaddr_storage_familytostring(addr);
RsUrl url;
switch(addr.ss_family)
{
case AF_INET:
output += "=";
output += sockaddr_storage_iptostring(addr);
output += ":";
output += sockaddr_storage_porttostring(addr);
url.setScheme("ipv4");
break;
case AF_INET6:
output += "=[";
output += sockaddr_storage_iptostring(addr);
output += "]:";
output += sockaddr_storage_porttostring(addr);
url.setScheme("ipv6");
break;
default:
break;
return "AF_INVALID";
}
return output;
url.setHost(sockaddr_storage_iptostring(addr))
.setPort(sockaddr_storage_port(addr));
return url.toString();
}
bool sockaddr_storage_fromString(const std::string& str, sockaddr_storage &addr)
{
RsUrl url(str);
bool valid = sockaddr_storage_inet_pton(addr, url.host());
if(url.hasPort()) sockaddr_storage_setport(addr, url.port());
return valid;
}
void sockaddr_storage_dump(const sockaddr_storage & addr, std::string * outputString)
@ -603,9 +611,11 @@ std::string sockaddr_storage_iptostring(const struct sockaddr_storage &addr)
break;
default:
output = "INVALID_IP";
std::cerr << __PRETTY_FUNCTION__ << " Got invalid IP:" << std::endl;
std::cerr << __PRETTY_FUNCTION__ << " Got invalid IP!" << std::endl;
#ifdef SS_DEBUG
sockaddr_storage_dump(addr);
print_stacktrace();
#endif
break;
}
return output;

View File

@ -0,0 +1,267 @@
/*
* RetroShare
* Copyright (C) 2018 Gioacchino Mazzurco <gio@eigenlab.org>
*
* 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 <http://www.gnu.org/licenses/>.
*/
//#include "util/rsurl.h"
#include "rsurl.h"
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <sstream>
using namespace std;
RsUrl::RsUrl() : mPort(0), mHasPort(false) {}
RsUrl::RsUrl(const std::string& urlStr) : mPort(0), mHasPort(false)
{ fromString(urlStr); }
RsUrl& RsUrl::fromString(const std::string& urlStr)
{
size_t endI = urlStr.size()-1;
size_t schemeEndI = urlStr.find(schemeSeparator);
if(schemeEndI >= endI)
{
mScheme = urlStr;
return *this;
}
mScheme = urlStr.substr(0, schemeEndI);
size_t hostBeginI = schemeEndI + 3;
if(hostBeginI >= endI) return *this;
bool hasSquareBr = (urlStr[hostBeginI] == ipv6WrapOpen[0]);
size_t hostEndI;
if(hasSquareBr)
{
if(++hostBeginI >= endI) return *this;
hostEndI = urlStr.find(ipv6WrapClose, hostBeginI);
mHost = urlStr.substr(hostBeginI, hostEndI - hostBeginI - 1);
++hostEndI;
}
else
{
hostEndI = urlStr.find(pathSeparator, hostBeginI);
hostEndI = min(hostEndI, urlStr.find(portSeparator, hostBeginI));
hostEndI = min(hostEndI, urlStr.find(querySeparator, hostBeginI));
hostEndI = min(hostEndI, urlStr.find(fragmentSeparator, hostBeginI));
mHost = urlStr.substr(hostBeginI, hostEndI - hostBeginI);
}
if( hostEndI >= endI ) return *this;
mHasPort = (sscanf(&urlStr[hostEndI], ":%hu", &mPort) == 1);
size_t pathBeginI = urlStr.find(pathSeparator, hostBeginI);
size_t pathEndI = string::npos;
if(pathBeginI < endI)
{
pathEndI = urlStr.find(querySeparator, pathBeginI);
pathEndI = min(pathEndI, urlStr.find(fragmentSeparator, pathBeginI));
mPath = UrlDecode(urlStr.substr(pathBeginI, pathEndI - pathBeginI));
if(pathEndI >= endI) return *this;
}
size_t queryBeginI = urlStr.find(querySeparator, hostBeginI);
size_t queryEndI = urlStr.find(fragmentSeparator, hostBeginI);
if(queryBeginI < endI)
{
string qStr = urlStr.substr(queryBeginI+1, queryEndI-queryBeginI-1);
size_t kPos = 0;
size_t assPos = qStr.find(queryAssign);
do
{
size_t vEndPos = qStr.find(queryFieldSep, assPos);
mQuery.insert( std::make_pair( qStr.substr(kPos, assPos-kPos),
UrlDecode(qStr.substr(assPos+1, vEndPos-assPos-1))
) );
kPos = vEndPos+1;
assPos = qStr.find(queryAssign, vEndPos);
}
while(assPos < endI);
if(queryEndI >= endI) return *this;
}
size_t fragmentBeginI = urlStr.find(fragmentSeparator, hostBeginI);
if(fragmentBeginI < endI)
mFragment = UrlDecode(urlStr.substr(++fragmentBeginI));
return *this;
}
std::string RsUrl::toString() const
{
std::string urlStr(mScheme);
urlStr += schemeSeparator;
if(!mHost.empty())
{
if(mHost.find(ipv6Separator) != string::npos &&
mHost[0] != ipv6WrapOpen[0] )
urlStr += ipv6WrapOpen + mHost + ipv6WrapClose;
else urlStr += mHost;
}
if(mHasPort) urlStr += portSeparator + std::to_string(mPort);
urlStr += UrlEncode(mPath, pathSeparator);
bool hasQuery = !mQuery.empty();
if(hasQuery) urlStr += querySeparator;
for(auto&& kv : mQuery)
{
urlStr += kv.first;
urlStr += queryAssign;
urlStr += UrlEncode(kv.second);
urlStr += queryFieldSep;
}
if(hasQuery) urlStr.pop_back();
if(!mFragment.empty()) urlStr += fragmentSeparator + UrlEncode(mFragment);
return urlStr;
}
const std::string& RsUrl::scheme() const { return mScheme; }
RsUrl& RsUrl::setScheme(const std::string& scheme)
{
mScheme = scheme;
return *this;
}
const std::string& RsUrl::host() const { return mHost; }
RsUrl& RsUrl::setHost(const std::string& host)
{
mHost = host;
return *this;
}
bool RsUrl::hasPort() const { return mHasPort; }
uint16_t RsUrl::port(uint16_t def) const
{
if(mHasPort) return mPort;
return def;
}
RsUrl& RsUrl::setPort(uint16_t port)
{
mPort = port;
mHasPort = true;
return *this;
}
RsUrl& RsUrl::unsetPort()
{
mPort = 0;
mHasPort = false;
return *this;
}
const std::string& RsUrl::path() const { return mPath; }
RsUrl& RsUrl::setPath(const std::string& path)
{
mPath = path;
return *this;
}
const std::map<std::string, std::string>& RsUrl::query() const
{ return mQuery; }
RsUrl& RsUrl::setQuery(const std::map<std::string, std::string>& query)
{
mQuery = query;
return *this;
}
RsUrl& RsUrl::setQueryKV(const std::string& key, const std::string& value)
{
mQuery.insert(std::make_pair(key, value));
return *this;
}
RsUrl& RsUrl::delQueryK(const std::string& key)
{
mQuery.erase(key);
return *this;
}
const std::string& RsUrl::fragment() const { return mFragment; }
RsUrl& RsUrl::setFragment(const std::string& fragment)
{
mFragment = fragment;
return *this;
}
/*static*/ std::string RsUrl::UrlEncode( const std::string& str,
const std::string& ignore )
{
ostringstream escaped;
escaped.fill('0');
escaped << hex;
for (string::value_type c : str)
{
// Keep alphanumeric and other accepted characters intact
if ( isalnum(c) || c == '-' || c == '_' || c == '.' || c == '~'
|| ignore.find(c) != string::npos )
{
escaped << c;
continue;
}
// Any other characters are percent-encoded
escaped << uppercase;
escaped << '%' << setw(2) << int((unsigned char) c);
escaped << nouppercase;
}
return escaped.str();
}
/*static*/ std::string RsUrl::UrlDecode(const std::string& str)
{
ostringstream decoded;
size_t len = str.size();
size_t boundary = len-2; // % Encoded char must be at least 2 hex char
for (size_t i = 0; i < len; ++i)
{
if(str[i] == '%' && i < boundary)
{
decoded << static_cast<char>(stoi(str.substr(++i, 2), 0, 16));
++i;
}
else decoded << str[i];
}
return decoded.str();
}
/*static*/ const std::string RsUrl::schemeSeparator("://");
/*static*/ const std::string RsUrl::ipv6WrapOpen("[");
/*static*/ const std::string RsUrl::ipv6Separator(":");
/*static*/ const std::string RsUrl::ipv6WrapClose("]");
/*static*/ const std::string RsUrl::portSeparator(":");
/*static*/ const std::string RsUrl::pathSeparator("/");
/*static*/ const std::string RsUrl::querySeparator("?");
/*static*/ const std::string RsUrl::queryAssign("=");
/*static*/ const std::string RsUrl::queryFieldSep("&");
/*static*/ const std::string RsUrl::fragmentSeparator("#");

View File

@ -0,0 +1,102 @@
#pragma once
/*
* RetroShare
* Copyright (C) 2018 Gioacchino Mazzurco <gio@eigenlab.org>
*
* 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 <http://www.gnu.org/licenses/>.
*/
#include <string>
#include <map>
/**
* Very simplistic and minimal URL helper class for RetroShare, after looking
* for a small and self-contained C/C++ URL parsing and manipulation library,
* haven't found nothing satisfactory except for implementation like QUrl that
* rely on bigger library.
* ATM this implementation is not standard compliant and doesn't aim to be.
* Improvements to this are welcome.
*
* Anyway this should support most common URLs of the form
* scheme://host[:port][/path][?query][#fragment]
*/
struct RsUrl
{
RsUrl();
RsUrl(const std::string& urlStr);
RsUrl& fromString(const std::string& urlStr);
std::string toString() const;
const std::string& scheme() const;
RsUrl& setScheme(const std::string& scheme);
const std::string& host() const;
RsUrl& setHost(const std::string& host);
bool hasPort() const;
uint16_t port(uint16_t def = 0) const;
RsUrl& setPort(uint16_t port);
RsUrl& unsetPort();
const std::string& path() const;
RsUrl& setPath(const std::string& path);
const std::map<std::string, std::string>& query() const;
RsUrl& setQuery(const std::map<std::string, std::string>& query);
RsUrl& setQueryKV(const std::string& key, const std::string& value);
RsUrl& delQueryK(const std::string& key);
const std::string& fragment() const;
RsUrl& setFragment(const std::string& fragment);
static std::string UrlEncode(const std::string& str,
const std::string& ignoreChars = "");
static std::string UrlDecode(const std::string& str);
inline bool operator<(const RsUrl& rhs) const
{ return toString() < rhs.toString(); }
inline bool operator>(const RsUrl& rhs) const
{ return toString() > rhs.toString(); }
inline bool operator<=(const RsUrl& rhs) const
{ return toString() <= rhs.toString(); }
inline bool operator>=(const RsUrl& rhs) const
{ return toString() >= rhs.toString(); }
inline bool operator==(const RsUrl& rhs) const
{ return toString() == rhs.toString(); }
inline bool operator!=(const RsUrl& rhs) const
{ return toString() != rhs.toString(); }
static const std::string schemeSeparator;
static const std::string ipv6WrapOpen;
static const std::string ipv6Separator;
static const std::string ipv6WrapClose;
static const std::string portSeparator;
static const std::string pathSeparator;
static const std::string querySeparator;
static const std::string queryAssign;
static const std::string queryFieldSep;
static const std::string fragmentSeparator;
private:
std::string mScheme;
std::string mHost;
uint16_t mPort;
bool mHasPort;
std::string mPath;
std::map<std::string, std::string> mQuery;
std::string mFragment;
};

View File

@ -1994,7 +1994,8 @@ QString IdDialog::createUsageString(const RsIdentityUsage& u) const
}
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.
{
RetroShareLink l = RetroShareLink::createChatRoom(ChatId(ChatLobbyId(u.mAdditionalId)),QString::number(u.mAdditionalId));
ChatId id = ChatId(ChatLobbyId(u.mAdditionalId));
RetroShareLink l = RetroShareLink::createChatRoom(id, QString::fromStdString(id.toStdString()));
return tr("Message in chat room %1").arg(l.toHtml()) ;
}
case RsIdentityUsage::GLOBAL_ROUTER_SIGNATURE_CHECK: // Global router message validation
@ -2124,19 +2125,19 @@ void IdDialog::updateDisplay(bool complete)
if (complete) {
/* Fill complete */
requestIdList();
requestIdDetails();
//requestIdDetails();
requestRepList();
return;
}
requestCircleGroupMeta();
std::list<RsGxsGroupId> grpIds;
std::set<RsGxsGroupId> grpIds;
getAllGrpIds(grpIds);
if (!getGrpIds().empty()) {
requestIdList();
if (!mId.isNull() && std::find(grpIds.begin(), grpIds.end(), mId) != grpIds.end()) {
if (!mId.isNull() && grpIds.find(mId)!=grpIds.end()) {
requestIdDetails();
requestRepList();
}

View File

@ -733,16 +733,16 @@ void MainWindow::updateStatus()
if (ratesstatus)
ratesstatus->getRatesStatus(downKb, upKb);
if(torstatus)
torstatus->getTorStatus();
if(torstatus)
torstatus->getTorStatus();
if(!hiddenmode)
{
if (natstatus)
natstatus->getNATStatus();
if (dhtstatus)
dhtstatus->getDHTStatus();
if (natstatus)
natstatus->getNATStatus();
if (dhtstatus)
dhtstatus->getDHTStatus();
}
if (discstatus) {
@ -1434,27 +1434,37 @@ void MainWindow::settingsChanged()
void MainWindow::externalLinkActivated(const QUrl &url)
{
static bool already_warned = false ;
bool never_ask_me = Settings->value("NeverAskMeForExternalLinkActivated",false).toBool();
if(!already_warned)
if(!already_warned && !never_ask_me)
{
QMessageBox mb(QObject::tr("Confirmation"), QObject::tr("Do you want this link to be handled by your system?")+"<br/><br/>"+ url.toString()+"<br/><br/>"+tr("Make sure this link has not been forged to drag you to a malicious website."), QMessageBox::Question, QMessageBox::Yes,QMessageBox::No, 0);
QCheckBox *checkbox = new QCheckBox(tr("Don't ask me again")) ;
QCheckBox *dontAsk_CB = new QCheckBox(tr("Don't ask me again"));
QCheckBox *neverAsk_CB = new QCheckBox(tr("Never ask me again"));
dontAsk_CB->setToolTip(tr("This will be saved only for this session."));
neverAsk_CB->setToolTip(tr("This will be saved permanently. You'll need to clean RetroShare.conf to revert."));
QGridLayout* layout = qobject_cast<QGridLayout*>(mb.layout());
if (layout)
{
layout->addWidget(checkbox,layout->rowCount(),0,1, layout->columnCount(), Qt::AlignLeft);
layout->addWidget(dontAsk_CB,layout->rowCount(),0,1, layout->columnCount(), Qt::AlignLeft);
layout->addWidget(neverAsk_CB,layout->rowCount(),0,1, layout->columnCount(), Qt::AlignLeft);
} else {
//Not QGridLayout so add at end
mb.layout()->addWidget(checkbox) ;
mb.layout()->addWidget(dontAsk_CB);
mb.layout()->addWidget(neverAsk_CB);
}
int res = mb.exec() ;
if (res == QMessageBox::No)
return ;
else if(checkbox->isChecked())
if(dontAsk_CB->isChecked())
already_warned = true ;
if(neverAsk_CB->isChecked())
Settings->setValue("NeverAskMeForExternalLinkActivated",true);
}
QDesktopServices::openUrl(url) ;

View File

@ -366,8 +366,8 @@ void NewsFeed::updateDisplay()
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
GxsMsgReq msgIds;
std::vector<RsGxsMessageId> &vect_msgIds = msgIds[grpId];
vect_msgIds.push_back(msgId);
std::set<RsGxsMessageId> &vect_msgIds = msgIds[grpId];
vect_msgIds.insert(msgId);
uint32_t token;
mTokenQueueCircle->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, TOKEN_TYPE_MESSAGE);

View File

@ -22,6 +22,7 @@
*/
#include <QDateTime>
#include <QStyle>
#include "rshare.h"
#include "PostedItem.h"

View File

@ -374,7 +374,7 @@ const QIcon& RetroshareDirModel::getFlagsIcon(FileStorageFlags flags)
return *static_icons[n] ;
}
QVariant RetroshareDirModel::filterRole(const DirDetails& details,int coln) const
QVariant RetroshareDirModel::filterRole(const DirDetails& details, int /*coln*/) const
{
if(mFilteredPointers.empty() || mFilteredPointers.find(details.ref) != mFilteredPointers.end())
return QString(RETROSHARE_DIR_MODEL_FILTER_STRING);

View File

@ -715,7 +715,7 @@ void WikiEditDialog::loadBaseHistory(const uint32_t &token)
std::cerr << " ParentId: " << page.mMeta.mParentId;
std::cerr << std::endl;
GxsIdRSTreeWidgetItem *modItem = new GxsIdRSTreeWidgetItem(mThreadCompareRole);
GxsIdRSTreeWidgetItem *modItem = new GxsIdRSTreeWidgetItem(mThreadCompareRole, GxsIdDetails::ICON_TYPE_AVATAR);
modItem->setData(WET_DATA_COLUMN, WET_ROLE_ORIGPAGEID, QString::fromStdString(page.mMeta.mOrigMsgId.toStdString()));
modItem->setData(WET_DATA_COLUMN, WET_ROLE_PAGEID, QString::fromStdString(page.mMeta.mMsgId.toStdString()));
@ -830,7 +830,7 @@ void WikiEditDialog::loadEditTreeData(const uint32_t &token)
}
/* create an Entry */
GxsIdRSTreeWidgetItem *modItem = new GxsIdRSTreeWidgetItem(mThreadCompareRole);
GxsIdRSTreeWidgetItem *modItem = new GxsIdRSTreeWidgetItem(mThreadCompareRole, GxsIdDetails::ICON_TYPE_AVATAR);
modItem->setData(WET_DATA_COLUMN, WET_ROLE_ORIGPAGEID, QString::fromStdString(snapshot.mMeta.mOrigMsgId.toStdString()));
modItem->setData(WET_DATA_COLUMN, WET_ROLE_PAGEID, QString::fromStdString(snapshot.mMeta.mMsgId.toStdString()));
modItem->setData(WET_DATA_COLUMN, WET_ROLE_PARENTID, QString::fromStdString(snapshot.mMeta.mParentId.toStdString()));

View File

@ -2,7 +2,7 @@
*
* RetroShare is distributed under the following license:
*
* Copyright (C) 2011, csoler
* Copyright (C) 2011, csoler
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -16,7 +16,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
****************************************************************/
@ -80,14 +80,14 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::Wi
connect(ui.filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString)));
int S = QFontMetricsF(font()).height() ;
int S = QFontMetricsF(font()).height() ;
ui.participantsList->setIconSize(QSize(1.4*S,1.4*S));
ui.participantsList->setColumnCount(COLUMN_COUNT);
ui.participantsList->setColumnWidth(COLUMN_ICON, 1.7*S);
ui.participantsList->setColumnHidden(COLUMN_ACTIVITY,true);
ui.participantsList->setColumnHidden(COLUMN_ID,true);
/* Set header resize modes and initial section sizes */
QHeaderView * header = ui.participantsList->header();
QHeaderView_setSectionResizeModeColumn(header, COLUMN_NAME, QHeaderView::Stretch);
@ -99,16 +99,16 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::Wi
distantChatAct = new QAction(QIcon(":/images/chat_24.png"), tr("Start private chat"), this);
sendMessageAct = new QAction(QIcon(":/images/mail_new.png"), tr("Send Message"), this);
showInPeopleAct = new QAction(QIcon(), tr("Show author in people tab"), this);
QActionGroup *sortgrp = new QActionGroup(this);
actionSortByName = new QAction(QIcon(), tr("Sort by Name"), this);
actionSortByName->setCheckable(true);
actionSortByName->setChecked(true);
actionSortByName->setChecked(true);
actionSortByName->setActionGroup(sortgrp);
actionSortByActivity = new QAction(QIcon(), tr("Sort by Activity"), this);
actionSortByActivity->setCheckable(true);
actionSortByActivity->setChecked(false);
actionSortByActivity->setChecked(false);
actionSortByActivity->setActionGroup(sortgrp);
@ -122,29 +122,33 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::Wi
connect(actionSortByName, SIGNAL(triggered()), this, SLOT(sortParcipants()));
connect(actionSortByActivity, SIGNAL(triggered()), this, SLOT(sortParcipants()));
/* Add filter actions */
QTreeWidgetItem *headerItem = ui.participantsList->headerItem();
QString headerText = headerItem->text(COLUMN_NAME );
ui.filterLineEdit->addFilter(QIcon(), headerText, COLUMN_NAME , QString("%1 %2").arg(tr("Search"), headerText));
// just empiric values
double scaler_factor = S > 25 ? 2.4 : 1.8;
QSize icon_size(scaler_factor * S, scaler_factor * S);
// Add a button to invite friends.
//
inviteFriendsButton = new QToolButton ;
inviteFriendsButton->setMinimumSize(QSize(2.4*S,2.4*S)) ;
inviteFriendsButton->setMaximumSize(QSize(2.4*S,2.4*S)) ;
inviteFriendsButton->setMinimumSize(icon_size);
inviteFriendsButton->setMaximumSize(icon_size);
inviteFriendsButton->setText(QString()) ;
inviteFriendsButton->setAutoRaise(true) ;
inviteFriendsButton->setToolTip(tr("Invite friends to this lobby"));
mParticipantCompareRole = new RSTreeWidgetItemCompareRole;
mParticipantCompareRole->setRole(COLUMN_ACTIVITY, ROLE_SORT);
mParticipantCompareRole = new RSTreeWidgetItemCompareRole;
mParticipantCompareRole->setRole(COLUMN_ACTIVITY, ROLE_SORT);
{
QIcon icon ;
icon.addPixmap(QPixmap(":/icons/png/invite.png")) ;
inviteFriendsButton->setIcon(icon) ;
inviteFriendsButton->setIconSize(QSize(2.4*S,2.4*S)) ;
inviteFriendsButton->setIconSize(icon_size);
}
connect(inviteFriendsButton, SIGNAL(clicked()), this , SLOT(inviteFriends()));
@ -163,7 +167,7 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::Wi
}
ownIdChooser = new GxsIdChooser() ;
ownIdChooser->loadIds(idChooserFlag, current_id) ;
QWidgetAction *checkableAction = new QWidgetAction(this);
checkableAction->setDefaultWidget(ownIdChooser);
@ -175,9 +179,9 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::Wi
connect(ownIdChooser,SIGNAL(currentIndexChanged(int)),this,SLOT(changeNickname())) ;
unsubscribeButton = new QToolButton ;
unsubscribeButton->setMinimumSize(QSize(2.4*S,2.4*S)) ;
unsubscribeButton->setMaximumSize(QSize(2.4*S,2.4*S)) ;
unsubscribeButton = new QToolButton;
unsubscribeButton->setMinimumSize(icon_size);
unsubscribeButton->setMaximumSize(icon_size);
unsubscribeButton->setText(QString()) ;
unsubscribeButton->setAutoRaise(true) ;
unsubscribeButton->setToolTip(tr("Leave this chat room (Unsubscribe)"));
@ -186,7 +190,7 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::Wi
QIcon icon ;
icon.addPixmap(QPixmap(":/icons/png/leave.png")) ;
unsubscribeButton->setIcon(icon) ;
unsubscribeButton->setIconSize(QSize(2.4*S,2.4*S)) ;
unsubscribeButton->setIconSize(icon_size);
}
/* Initialize splitter */
@ -246,8 +250,8 @@ void ChatLobbyDialog::participantsTreeWidgetCustomPopupMenu(QPoint)
void ChatLobbyDialog::textBrowserAskContextMenu(QMenu* contextMnu, QString anchorForPosition, const QPoint /*point*/)
{
if (anchorForPosition.startsWith(PERSONID)){
QString strId = anchorForPosition.replace(PERSONID,"");
if (anchorForPosition.startsWith(PERSONID)) {
QString strId = anchorForPosition.replace(PERSONID, "");
if (strId.contains(" "))
strId.truncate(strId.indexOf(" "));
@ -263,6 +267,8 @@ void ChatLobbyDialog::initParticipantsContextMenu(QMenu *contextMnu, QList<RsGxs
{
if (!contextMnu)
return;
if (idList.isEmpty())
return;
contextMnu->addAction(distantChatAct);
contextMnu->addAction(sendMessageAct);
@ -281,7 +287,7 @@ void ChatLobbyDialog::initParticipantsContextMenu(QMenu *contextMnu, QList<RsGxs
votePositiveAct->setEnabled(false);
voteNeutralAct->setEnabled(false);
voteNegativeAct->setEnabled(false);
showInPeopleAct->setEnabled(idList.count()==1);
showInPeopleAct->setEnabled(idList.count() == 1);
distantChatAct->setData(QVariant::fromValue(idList));
sendMessageAct->setData(QVariant::fromValue(idList));
@ -291,19 +297,16 @@ void ChatLobbyDialog::initParticipantsContextMenu(QMenu *contextMnu, QList<RsGxs
voteNegativeAct->setData(QVariant::fromValue(idList));
showInPeopleAct->setData(QVariant::fromValue(idList));
if(idList.count()==1)
{
RsGxsId gxsid = idList.at(0);
RsGxsId gxsid = idList.at(0);
if(!gxsid.isNull() && !rsIdentity->isOwnId(gxsid))
{
distantChatAct->setEnabled(true);
votePositiveAct->setEnabled(rsReputations->overallReputationLevel(gxsid) != RsReputations::REPUTATION_LOCALLY_POSITIVE);
voteNeutralAct->setEnabled((rsReputations->overallReputationLevel(gxsid) == RsReputations::REPUTATION_LOCALLY_POSITIVE) || (rsReputations->overallReputationLevel(gxsid) == RsReputations::REPUTATION_LOCALLY_NEGATIVE) );
voteNegativeAct->setEnabled(rsReputations->overallReputationLevel(gxsid) != RsReputations::REPUTATION_LOCALLY_NEGATIVE);
muteAct->setEnabled(true);
muteAct->setChecked(isParticipantMuted(gxsid));
}
if(!gxsid.isNull() && !rsIdentity->isOwnId(gxsid))
{
distantChatAct->setEnabled(true);
votePositiveAct->setEnabled(rsReputations->overallReputationLevel(gxsid) != RsReputations::REPUTATION_LOCALLY_POSITIVE);
voteNeutralAct->setEnabled((rsReputations->overallReputationLevel(gxsid) == RsReputations::REPUTATION_LOCALLY_POSITIVE) || (rsReputations->overallReputationLevel(gxsid) == RsReputations::REPUTATION_LOCALLY_NEGATIVE) );
voteNegativeAct->setEnabled(rsReputations->overallReputationLevel(gxsid) != RsReputations::REPUTATION_LOCALLY_NEGATIVE);
muteAct->setEnabled(true);
muteAct->setChecked(isParticipantMuted(gxsid));
}
}
@ -443,17 +446,17 @@ void ChatLobbyDialog::processSettings(bool load)
// state of splitter
ui.splitter->restoreState(Settings->value("splitter").toByteArray());
// load sorting
actionSortByActivity->setChecked(Settings->value("sortbyActivity", QVariant(false)).toBool());
actionSortByName->setChecked(Settings->value("sortbyName", QVariant(true)).toBool());
} else {
// save settings
// state of splitter
Settings->setValue("splitter", ui.splitter->saveState());
//save sorting
Settings->setValue("sortbyActivity", actionSortByActivity->isChecked());
Settings->setValue("sortbyName", actionSortByName->isChecked());
@ -464,7 +467,7 @@ void ChatLobbyDialog::processSettings(bool load)
/**
* Change your Nickname
*
*
* - send a Message to all Members => later: send hidden message to clients, so they can actualize there mutedParticipants list
*/
void ChatLobbyDialog::setIdentity(const RsGxsId& gxs_id)
@ -500,7 +503,7 @@ void ChatLobbyDialog::changeNickname()
/**
* We get a new Message from a chat participant
*
*
* - Ignore Messages from muted chat participants
*/
void ChatLobbyDialog::addChatMsg(const ChatMessage& msg)
@ -509,7 +512,7 @@ void ChatLobbyDialog::addChatMsg(const ChatMessage& msg)
QDateTime recvTime = QDateTime::fromTime_t(msg.recvTime);
QString message = QString::fromUtf8(msg.msg.c_str());
RsGxsId gxs_id = msg.lobby_peer_gxs_id ;
if(!isParticipantMuted(gxs_id))
{
// We could change addChatMsg to display the peers icon, passing a ChatId
@ -551,7 +554,7 @@ void ChatLobbyDialog::addChatMsg(const ChatMessage& msg)
/**
* Regenerate the QTreeWidget participant list of a Chat Lobby
*
*
* Show yellow icon for muted Participants
*/
void ChatLobbyDialog::updateParticipantsList()
@ -602,7 +605,7 @@ void ChatLobbyDialog::updateParticipantsList()
time_t tLastAct=widgetitem->text(COLUMN_ACTIVITY).toInt();
time_t now = time(NULL);
widgetitem->setSizeHint(COLUMN_ICON, QSize(20,20));
@ -619,7 +622,7 @@ void ChatLobbyDialog::updateParticipantsList()
if (RsGxsId(participant.toStdString()) == gxs_id) widgetitem->setIcon(COLUMN_ICON, bullet_yellow_128);
widgetitem->updateBannedState();
QTime qtLastAct=QTime(0,0,0).addSecs(now-tLastAct);
widgetitem->setToolTip(COLUMN_ICON,tr("Right click to mute/unmute participants<br/>Double click to address this person<br/>")
+tr("This participant is not active since:")
@ -635,7 +638,7 @@ void ChatLobbyDialog::updateParticipantsList()
/**
* Called when a Participant get Clicked / Changed
*
*
* Check if the Checkbox altered and Mute User
*/
void ChatLobbyDialog::changeParticipationState()
@ -787,15 +790,15 @@ bool ChatLobbyDialog::isNicknameInLobby(const RsGxsId& nickname)
return clinfo.gxs_ids.find(nickname) != clinfo.gxs_ids.end() ;
}
/**
/**
* Should Messages from this Nickname be muted?
*
*
* At the moment it is not possible to 100% know which peer sendet the message, and only
* the nickname is available. So this couldn't work for 100%. So, for example, if a peer
* change his name to the name of a other peer, we couldn't block him. A real implementation
* the nickname is available. So this couldn't work for 100%. So, for example, if a peer
* change his name to the name of a other peer, we couldn't block him. A real implementation
* will be possible if we transfer a temporary Session ID from the sending Retroshare client
* version 0.6
*
*
* @param QString nickname to check
*/
bool ChatLobbyDialog::isParticipantMuted(const RsGxsId& participant)
@ -901,7 +904,7 @@ bool ChatLobbyDialog::canClose()
void ChatLobbyDialog::showDialog(uint chatflags)
{
if (chatflags & RS_CHAT_FOCUS)
if (chatflags & RS_CHAT_FOCUS)
{
MainWindow::showWindow(MainWindow::ChatLobby);
dynamic_cast<ChatLobbyWidget*>(MainWindow::getPage(MainWindow::ChatLobby))->setCurrentChatPage(this) ;
@ -916,7 +919,7 @@ void ChatLobbyDialog::sortParcipants()
} else if (actionSortByName->isChecked()) {
ui.participantsList->sortItems(COLUMN_NAME, Qt::AscendingOrder);
}
}
void ChatLobbyDialog::filterChanged(const QString& /*text*/)

View File

@ -28,6 +28,7 @@
#include "ChatDialog.h"
Q_DECLARE_METATYPE(RsGxsId)
Q_DECLARE_METATYPE(QList<RsGxsId>)
class GxsIdChooser ;
class QToolButton;

View File

@ -20,6 +20,8 @@
* Boston, MA 02110-1301, USA.
****************************************************************/
#include <QTabBar>
#include "ChatTabWidget.h"
#include "ui_ChatTabWidget.h"
#include "ChatDialog.h"

View File

@ -65,6 +65,8 @@
#include <time.h>
#define FMM 2.5//fontMetricsMultiplicator
#define FMM_SMALLER 1.8
#define FMM_THRESHOLD 25
/*****
* #define CHAT_DEBUG 1
@ -75,9 +77,12 @@ ChatWidget::ChatWidget(QWidget *parent) :
{
ui->setupUi(this);
int iconHeight = FMM*QFontMetricsF(font()).height() ;
QSize iconSize = QSize(iconHeight,iconHeight);
QSize buttonSize = QSize(iconSize + QSize((int)FMM,(int)FMM));
int iconHeight = QFontMetricsF(font()).height();
double fmm = iconHeight > FMM_THRESHOLD ? FMM : FMM_SMALLER;
iconHeight *= fmm;
QSize iconSize = QSize(iconHeight, iconHeight);
int butt_size(iconSize.height() + fmm);
QSize buttonSize = QSize(butt_size, butt_size);
newMessages = false;
typing = false;
@ -110,7 +115,7 @@ ChatWidget::ChatWidget(QWidget *parent) :
ui->searchButton->setIconSize(iconSize);
ui->sendButton->setFixedHeight(iconHeight);
ui->sendButton->setIconSize(iconSize);
//Initialize search
iCharToStartSearch=Settings->getChatSearchCharToStartSearch();
bFindCaseSensitively=Settings->getChatSearchCaseSensitively();
@ -177,7 +182,7 @@ ChatWidget::ChatWidget(QWidget *parent) :
ui->infoFrame->setVisible(false);
ui->statusMessageLabel->hide();
setAcceptDrops(true);
ui->chatTextEdit->setAcceptDrops(false);
ui->hashBox->setDropWidget(this);
@ -197,7 +202,7 @@ ChatWidget::ChatWidget(QWidget *parent) :
menu->addAction(ui->actionMessageHistory);
ui->pushtoolsButton->setMenu(menu);
menu->addMenu(fontmenu);
ui->actionSendAsPlainText->setChecked(Settings->getChatSendAsPlainTextByDef());
ui->chatTextEdit->setOnlyPlainText(ui->actionSendAsPlainText->isChecked());
connect(ui->actionSendAsPlainText, SIGNAL(toggled(bool)), ui->chatTextEdit, SLOT(setOnlyPlainText(bool)) );
@ -259,9 +264,12 @@ void ChatWidget::addChatHorizontalWidget(QWidget *w)
void ChatWidget::addChatBarWidget(QWidget *w)
{
int iconHeight = FMM*QFontMetricsF(font()).height() ;
QSize iconSize = QSize(iconHeight,iconHeight);
QSize buttonSize = QSize(iconSize + QSize((int)FMM,(int)FMM));
int iconHeight = QFontMetricsF(font()).height();
double fmm = iconHeight > FMM_THRESHOLD ? FMM : FMM_SMALLER;
iconHeight *= fmm;
QSize iconSize = QSize(iconHeight, iconHeight);
int butt_size(iconSize.height() + fmm);
QSize buttonSize = QSize(butt_size, butt_size);
w->setFixedSize(buttonSize);
ui->pluginButtonFrame->layout()->addWidget(w) ;
}
@ -357,12 +365,12 @@ void ChatWidget::init(const ChatId &chat_id, const QString &title)
ui->titleBarFrame->setVisible(false);
}
if (rsHistory->getEnable(hist_chat_type))
if (rsHistory->getEnable(hist_chat_type))
{
// get chat messages from history
std::list<HistoryMsg> historyMsgs;
if (messageCount > 0)
if (messageCount > 0)
{
rsHistory->getMessages(chatId, historyMsgs, messageCount);
@ -376,7 +384,7 @@ void ChatWidget::init(const ChatId &chat_id, const QString &title)
continue;
QString name;
if (chatId.isLobbyId() || chatId.isDistantChatId())
if (chatId.isLobbyId() || chatId.isDistantChatId())
{
RsIdentityDetails details;
if (rsIdentity->getIdDetails(RsGxsId(historyIt->peerName), details))
@ -962,7 +970,7 @@ void ChatWidget::addChatMsg(bool incoming, const QString &name, const RsGxsId gx
unsigned int formatFlag = 0;
bool addDate = false;
if (QDate::currentDate()>lastMsgDate)
if (QDate::currentDate()>lastMsgDate)
{
addDate=true;
}
@ -1095,7 +1103,8 @@ void ChatWidget::contextMenuTextBrowser(QPoint point)
contextMnu->addSeparator();
contextMnu->addAction(ui->actionClearChatHistory);
contextMnu->addAction(ui->actionQuote);
if (ui->textBrowser->textCursor().selection().toPlainText().length())
contextMnu->addAction(ui->actionQuote);
contextMnu->addAction(ui->actionDropPlacemark);
if(ui->textBrowser->checkImage(point))
@ -1161,13 +1170,14 @@ void ChatWidget::resetStatusBar()
void ChatWidget::updateStatusTyping()
{
if(Settings->getChatDoNotSendIsTyping())
return;
if (time(NULL) - lastStatusSendTime > 5) // limit 'peer is typing' packets to at most every 10 sec
{
#ifdef ONLY_FOR_LINGUIST
tr("is typing...");
#endif
if(!Settings->getChatDoNotSendIsTyping())
rsMsgs->sendStatusString(chatId, "is typing...");
rsMsgs->sendStatusString(chatId, "is typing...");
lastStatusSendTime = time(NULL) ;
}
}
@ -1673,7 +1683,7 @@ void ChatWidget::updateStatus(const QString &peer_id, int status)
vpid = chatId.toPeerId();
/* set font size for status */
if (peer_id.toStdString() == vpid.toStdString())
if (peer_id.toStdString() == vpid.toStdString())
{
// the peers status has changed
@ -1816,13 +1826,10 @@ bool ChatWidget::setStyle()
void ChatWidget::quote()
{
QString text = ui->textBrowser->textCursor().selection().toPlainText();
if(text.length() > 0)
{
QStringList sl = text.split(QRegExp("[\r\n]"),QString::SkipEmptyParts);
text = sl.join("\n> ");
text.replace(QChar(-4)," ");//Char used when image on text.
emit ui->chatTextEdit->append(QString("> ") + text);
}
QStringList sl = text.split(QRegExp("[\r\n]"), QString::SkipEmptyParts);
text = sl.join("\n> ");
text.replace(QChar(-4), " "); // Char used when image on text.
emit ui->chatTextEdit->append(QString("> ") + text);
}
void ChatWidget::dropPlacemark()

View File

@ -2066,6 +2066,10 @@ bool FriendList::importFriendlist(QString &fileName, bool &errorPeers, bool &err
rsPeers->setDynDNS(rsPeerDetails.id, rsPeerDetails.dyndns);
if (!rsPeerDetails.location.empty())
rsPeers->setLocation(rsPeerDetails.id, rsPeerDetails.location);
for(auto&& ipr : rsPeerDetails.ipAddressList)
rsPeers->addPeerLocator(
rsPeerDetails.id,
RsUrl(ipr.substr(0, ipr.find(' '))) );
}
} else if (!rsPeerDetails.gpg_id.isNull()) {
// only pgp id is avaiable

View File

@ -251,22 +251,53 @@ bool RSTextBrowser::checkImage(QPoint pos, QString &imageStr)
*/
QString RSTextBrowser::anchorForPosition(const QPoint &pos) const
{
// Many calls when time label shows up
QTextCursor cursor = cursorForPosition(pos);
cursor.select(QTextCursor::WordUnderCursor);
QString word = cursor.selectedText();
QString anchor = "";
if (!cursor.selectedText().isEmpty()){
QRegExp rx("<a name=\"(.*)\"",Qt::CaseSensitive, QRegExp::RegExp2);
rx.setMinimal(true);
QString sel = cursor.selection().toHtml();
QStringList anchors;
int pos=0;
while ((pos = rx.indexIn(sel,pos)) != -1) {
anchors << rx.cap(1);
pos += rx.matchedLength();
}
if (!anchors.isEmpty()){
anchor = anchors.at(0);
if (word.isEmpty())
return anchor;
// For finding positions
QTextCursor cursor_line = cursorForPosition(pos);
cursor_line.select(QTextCursor::LineUnderCursor);
QString line = cursor_line.selectedText();
// End of nickname (more or less, of course, because some can has colon in
// name)
int end_of_name = line.indexOf(": ") + 1;
// Start of nickname (after time)
int space_index = line.indexOf(' ') + 1;
int word_index = line.indexOf(word) + 1;
int once = 1;
cursor_line.movePosition(QTextCursor::StartOfLine, QTextCursor::MoveAnchor, once);
bool after_name = cursor_line.position() + end_of_name < cursor.position();
bool cursor_after_time = space_index < word_index;
bool cursor_within_name = word_index <= end_of_name;
if (!after_name && cursor_after_time && cursor_within_name) {
cursor.movePosition(QTextCursor::StartOfLine, QTextCursor::MoveAnchor, once);
cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::MoveAnchor,
space_index);
cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor,
end_of_name - space_index);
if (cursor.selectedText().isEmpty()) {
return anchor;
}
} else {
return anchor;
}
QRegExp rx("<a name=\"(.*)\"",Qt::CaseSensitive, QRegExp::RegExp2);
rx.setMinimal(true);
QString sel = cursor.selection().toHtml();
QStringList anchors;
int position = 0;
while ((position = rx.indexIn(sel, position)) != -1) {
anchors << rx.cap(1);
position += rx.matchedLength();
}
if (!anchors.isEmpty()) {
anchor = anchors.at(0);
}
return anchor;
}

View File

@ -974,6 +974,10 @@ void ConnectFriendWizard::accept()
std::cerr << "ConnectFriendWizard::accept() : setting DynDNS." << std::endl;
rsPeers->setDynDNS(peerDetails.id, peerDetails.dyndns);
}
for(auto&& ipr : peerDetails.ipAddressList)
rsPeers->addPeerLocator(
peerDetails.id,
RsUrl(ipr.substr(0, ipr.find(' '))) );
}
}

View File

@ -23,6 +23,7 @@
#include <QTimer>
#include <QFileInfo>
#include <QStyle>
#include "rshare.h"
#include "GxsChannelPostItem.h"

View File

@ -23,6 +23,7 @@
#include <QTimer>
#include <QFileInfo>
#include <QStyle>
#include "rshare.h"
#include "GxsForumMsgItem.h"
@ -437,8 +438,8 @@ void GxsForumMsgItem::requestParentMessage(const RsGxsMessageId &msgId)
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
GxsMsgReq msgIds;
std::vector<RsGxsMessageId> &vect_msgIds = msgIds[groupId()];
vect_msgIds.push_back(msgId);
std::set<RsGxsMessageId> &vect_msgIds = msgIds[groupId()];
vect_msgIds.insert(msgId);
uint32_t token;
mLoadQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, mTokenTypeParentMessage);

View File

@ -93,19 +93,15 @@ void GxsFeedItem::fillDisplay(RsGxsUpdateBroadcastBase *updateBroadcastBase, boo
{
GxsGroupFeedItem::fillDisplay(updateBroadcastBase, complete);
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > msgs;
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > msgs;
updateBroadcastBase->getAllMsgIds(msgs);
if (!msgs.empty())
{
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >::const_iterator mit = msgs.find(groupId());
if (mit != msgs.end())
{
const std::vector<RsGxsMessageId> &msgIds = mit->second;
if (std::find(msgIds.begin(), msgIds.end(), messageId()) != msgIds.end()) {
std::map<RsGxsGroupId, std::set<RsGxsMessageId> >::const_iterator mit = msgs.find(groupId());
if (mit != msgs.end() && mit->second.find(messageId()) != mit->second.end())
requestMessage();
}
}
}
}
@ -129,8 +125,8 @@ void GxsFeedItem::requestMessage()
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
GxsMsgReq msgIds;
std::vector<RsGxsMessageId> &vect_msgIds = msgIds[groupId()];
vect_msgIds.push_back(mMessageId);
std::set<RsGxsMessageId> &vect_msgIds = msgIds[groupId()];
vect_msgIds.insert(mMessageId);
uint32_t token;
mLoadQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, mTokenTypeMessage);

View File

@ -170,12 +170,11 @@ void GxsGroupFeedItem::fillDisplaySlot(bool complete)
void GxsGroupFeedItem::fillDisplay(RsGxsUpdateBroadcastBase *updateBroadcastBase, bool /*complete*/)
{
std::list<RsGxsGroupId> grpIds;
std::set<RsGxsGroupId> grpIds;
updateBroadcastBase->getAllGrpIds(grpIds);
if (std::find(grpIds.begin(), grpIds.end(), groupId()) != grpIds.end()) {
if (grpIds.find(groupId()) != grpIds.end())
requestGroup();
}
}
/***********************************************************/

View File

@ -236,11 +236,10 @@ void GxsGroupFrameDialog::updateDisplay(bool complete)
requestGroupSummary();
} else {
/* Update all groups of changed messages */
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > msgIds;
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > msgIds;
getAllMsgIds(msgIds);
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >::iterator msgIt;
for (msgIt = msgIds.begin(); msgIt != msgIds.end(); ++msgIt) {
for (auto msgIt = msgIds.begin(); msgIt != msgIds.end(); ++msgIt) {
updateMessageSummaryList(msgIt->first);
}
}

View File

@ -109,21 +109,22 @@ void GxsMessageFramePostWidget::updateDisplay(bool complete)
}
bool updateGroup = false;
const std::list<RsGxsGroupId> &grpIdsMeta = getGrpIdsMeta();
if (std::find(grpIdsMeta.begin(), grpIdsMeta.end(), groupId()) != grpIdsMeta.end()) {
updateGroup = true;
}
const std::set<RsGxsGroupId> &grpIdsMeta = getGrpIdsMeta();
const std::list<RsGxsGroupId> &grpIds = getGrpIds();
if (!groupId().isNull() && std::find(grpIds.begin(), grpIds.end(), groupId()) != grpIds.end()) {
if(grpIdsMeta.find(groupId())!=grpIdsMeta.end())
updateGroup = true;
const std::set<RsGxsGroupId> &grpIds = getGrpIds();
if (!groupId().isNull() && grpIds.find(groupId())!=grpIds.end())
{
updateGroup = true;
/* Do we need to fill all posts? */
requestAllPosts();
} else {
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > msgs;
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > msgs;
getAllMsgIds(msgs);
if (!msgs.empty()) {
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >::const_iterator mit = msgs.find(groupId());
auto mit = msgs.find(groupId());
if (mit != msgs.end()) {
requestPosts(mit->second);
}
@ -341,7 +342,7 @@ void GxsMessageFramePostWidget::loadAllPosts(const uint32_t &token)
emit groupChanged(this);
}
void GxsMessageFramePostWidget::requestPosts(const std::vector<RsGxsMessageId> &msgIds)
void GxsMessageFramePostWidget::requestPosts(const std::set<RsGxsMessageId> &msgIds)
{
#ifdef ENABLE_DEBUG
std::cerr << "GxsMessageFramePostWidget::requestPosts()";

View File

@ -72,7 +72,7 @@ protected:
void loadAllPosts(const uint32_t &token);
virtual void insertAllPosts(const uint32_t &token, GxsMessageFramePostThread *thread) = 0;
void requestPosts(const std::vector<RsGxsMessageId> &msgIds);
void requestPosts(const std::set<RsGxsMessageId> &msgIds);
void loadPosts(const uint32_t &token);
virtual void insertPosts(const uint32_t &token) = 0;

View File

@ -15,7 +15,7 @@ RsGxsUpdateBroadcastBase::RsGxsUpdateBroadcastBase(RsGxsIfaceHelper *ifaceImpl,
mUpdateBroadcast = RsGxsUpdateBroadcast::get(ifaceImpl);
connect(mUpdateBroadcast, SIGNAL(changed()), this, SLOT(updateBroadcastChanged()));
connect(mUpdateBroadcast, SIGNAL(grpsChanged(std::list<RsGxsGroupId>, std::list<RsGxsGroupId>)), this, SLOT(updateBroadcastGrpsChanged(std::list<RsGxsGroupId>,std::list<RsGxsGroupId>)));
connect(mUpdateBroadcast, SIGNAL(msgsChanged(std::map<RsGxsGroupId,std::vector<RsGxsMessageId> >, std::map<RsGxsGroupId,std::vector<RsGxsMessageId> >)), this, SLOT(updateBroadcastMsgsChanged(std::map<RsGxsGroupId,std::vector<RsGxsMessageId> >,std::map<RsGxsGroupId,std::vector<RsGxsMessageId> >)));
connect(mUpdateBroadcast, SIGNAL(msgsChanged(std::map<RsGxsGroupId,std::set<RsGxsMessageId> >, std::map<RsGxsGroupId,std::set<RsGxsMessageId> >)), this, SLOT(updateBroadcastMsgsChanged(std::map<RsGxsGroupId,std::set<RsGxsMessageId> >,std::map<RsGxsGroupId,std::set<RsGxsMessageId> >)));
}
RsGxsUpdateBroadcastBase::~RsGxsUpdateBroadcastBase()
@ -68,7 +68,14 @@ void RsGxsUpdateBroadcastBase::updateBroadcastChanged()
/* Update only update when the widget is visible. */
if (mUpdateWhenInvisible || !widget || widget->isVisible()) {
if (!mGrpIds.empty() || !mGrpIdsMeta.empty() || !mMsgIds.empty() || !mMsgIdsMeta.empty())
// (cyril) Re-load the entire group is new messages are here, or if group metadata has changed (e.g. visibility permissions, admin rights, etc).
// Do not re-load if Msg data has changed, which means basically the READ flag has changed, because this action is done in the UI in the
// first place so there's no need to re-update the UI once this is done.
//
// The question to whether we should re=load when mGrpIds is not empty is still open. It's not harmful anyway.
// This should probably be decided by the service itself.
if (!mGrpIds.empty() || !mGrpIdsMeta.empty() /*|| !mMsgIds.empty()*/ || !mMsgIdsMeta.empty())
mFillComplete = true ;
securedUpdateDisplay();
@ -78,79 +85,36 @@ void RsGxsUpdateBroadcastBase::updateBroadcastChanged()
void RsGxsUpdateBroadcastBase::updateBroadcastGrpsChanged(const std::list<RsGxsGroupId> &grpIds, const std::list<RsGxsGroupId> &grpIdsMeta)
{
std::list<RsGxsGroupId>::const_iterator it;
for (it = grpIds.begin(); it != grpIds.end(); ++it) {
if (std::find(mGrpIds.begin(), mGrpIds.end(), *it) == mGrpIds.end()) {
mGrpIds.push_back(*it);
}
}
for (it = grpIdsMeta.begin(); it != grpIdsMeta.end(); ++it) {
if (std::find(mGrpIdsMeta.begin(), mGrpIdsMeta.end(), *it) == mGrpIdsMeta.end()) {
mGrpIdsMeta.push_back(*it);
}
}
for (it = grpIds.begin(); it != grpIds.end(); ++it)
mGrpIds.insert(*it) ;
for (it = grpIdsMeta.begin(); it != grpIdsMeta.end(); ++it)
mGrpIdsMeta.insert(*it);
}
void RsGxsUpdateBroadcastBase::updateBroadcastMsgsChanged(const std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &msgIds, const std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &msgIdsMeta)
template<class U> void merge(std::set<U>& dst,const std::set<U>& src) { for(auto it(src.begin());it!=src.end();++it) dst.insert(*it) ; }
void RsGxsUpdateBroadcastBase::updateBroadcastMsgsChanged(const std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &msgIds, const std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &msgIdsMeta)
{
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >::const_iterator mapIt;
for (mapIt = msgIds.begin(); mapIt != msgIds.end(); ++mapIt) {
const RsGxsGroupId &grpId = mapIt->first;
const std::vector<RsGxsMessageId> &srcMsgIds = mapIt->second;
std::vector<RsGxsMessageId> &destMsgIds = mMsgIds[grpId];
for (auto mapIt = msgIds.begin(); mapIt != msgIds.end(); ++mapIt)
merge(mMsgIds[mapIt->first],mapIt->second) ;
std::vector<RsGxsMessageId>::const_iterator msgIt;
for (msgIt = srcMsgIds.begin(); msgIt != srcMsgIds.end(); ++msgIt) {
if (std::find(destMsgIds.begin(), destMsgIds.end(), *msgIt) == destMsgIds.end()) {
destMsgIds.push_back(*msgIt);
}
}
}
for (mapIt = msgIdsMeta.begin(); mapIt != msgIdsMeta.end(); ++mapIt) {
const RsGxsGroupId &grpId = mapIt->first;
const std::vector<RsGxsMessageId> &srcMsgIds = mapIt->second;
std::vector<RsGxsMessageId> &destMsgIds = mMsgIdsMeta[grpId];
std::vector<RsGxsMessageId>::const_iterator msgIt;
for (msgIt = srcMsgIds.begin(); msgIt != srcMsgIds.end(); ++msgIt) {
if (std::find(destMsgIds.begin(), destMsgIds.end(), *msgIt) == destMsgIds.end()) {
destMsgIds.push_back(*msgIt);
}
}
}
for (auto mapIt = msgIdsMeta.begin(); mapIt != msgIdsMeta.end(); ++mapIt)
merge(mMsgIdsMeta[mapIt->first],mapIt->second) ;
}
void RsGxsUpdateBroadcastBase::getAllGrpIds(std::list<RsGxsGroupId> &grpIds)
void RsGxsUpdateBroadcastBase::getAllGrpIds(std::set<RsGxsGroupId> &grpIds)
{
std::list<RsGxsGroupId>::const_iterator it;
for (it = mGrpIds.begin(); it != mGrpIds.end(); ++it) {
if (std::find(grpIds.begin(), grpIds.end(), *it) == grpIds.end()) {
grpIds.push_back(*it);
}
}
for (it = mGrpIdsMeta.begin(); it != mGrpIdsMeta.end(); ++it) {
if (std::find(grpIds.begin(), grpIds.end(), *it) == grpIds.end()) {
grpIds.push_back(*it);
}
}
grpIds = mGrpIds;
merge(grpIds,mGrpIdsMeta) ;
}
void RsGxsUpdateBroadcastBase::getAllMsgIds(std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &msgIds)
void RsGxsUpdateBroadcastBase::getAllMsgIds(std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &msgIds)
{
/* Copy first map */
msgIds = mMsgIds;
/* Append second map */
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >::const_iterator mapIt;
for (mapIt = mMsgIdsMeta.begin(); mapIt != mMsgIdsMeta.end(); ++mapIt) {
const RsGxsGroupId &grpId = mapIt->first;
const std::vector<RsGxsMessageId> &srcMsgIds = mapIt->second;
std::vector<RsGxsMessageId> &destMsgIds = msgIds[grpId];
std::vector<RsGxsMessageId>::const_iterator msgIt;
for (msgIt = srcMsgIds.begin(); msgIt != srcMsgIds.end(); ++msgIt) {
if (std::find(destMsgIds.begin(), destMsgIds.end(), *msgIt) == destMsgIds.end()) {
destMsgIds.push_back(*msgIt);
}
}
}
for (auto mapIt = mMsgIdsMeta.begin(); mapIt != mMsgIdsMeta.end(); ++mapIt)
merge(msgIds[mapIt->first],mapIt->second);
}

View File

@ -19,12 +19,12 @@ public:
RsGxsUpdateBroadcastBase(RsGxsIfaceHelper* ifaceImpl, QWidget *parent = NULL);
virtual ~RsGxsUpdateBroadcastBase();
const std::list<RsGxsGroupId> &getGrpIds() { return mGrpIds; }
const std::list<RsGxsGroupId> &getGrpIdsMeta() { return mGrpIdsMeta; }
void getAllGrpIds(std::list<RsGxsGroupId> &grpIds);
const std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &getMsgIds() { return mMsgIds; }
const std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &getMsgIdsMeta() { return mMsgIdsMeta; }
void getAllMsgIds(std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &msgIds);
const std::set<RsGxsGroupId> &getGrpIds() { return mGrpIds; }
const std::set<RsGxsGroupId> &getGrpIdsMeta() { return mGrpIdsMeta; }
void getAllGrpIds(std::set<RsGxsGroupId> &grpIds);
const std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &getMsgIds() { return mMsgIds; }
const std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &getMsgIdsMeta() { return mMsgIdsMeta; }
void getAllMsgIds(std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &msgIds);
protected:
void fillComplete();
@ -38,15 +38,15 @@ signals:
private slots:
void updateBroadcastChanged();
void updateBroadcastGrpsChanged(const std::list<RsGxsGroupId>& grpIds, const std::list<RsGxsGroupId> &grpIdsMeta);
void updateBroadcastMsgsChanged(const std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >& msgIds, const std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >& msgIdsMeta);
void updateBroadcastMsgsChanged(const std::map<RsGxsGroupId, std::set<RsGxsMessageId> >& msgIds, const std::map<RsGxsGroupId, std::set<RsGxsMessageId> >& msgIdsMeta);
void securedUpdateDisplay();
private:
RsGxsUpdateBroadcast *mUpdateBroadcast;
bool mFillComplete;
bool mUpdateWhenInvisible; // Update also when not visible
std::list<RsGxsGroupId> mGrpIds;
std::list<RsGxsGroupId> mGrpIdsMeta;
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > mMsgIds;
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > mMsgIdsMeta;
std::set<RsGxsGroupId> mGrpIds;
std::set<RsGxsGroupId> mGrpIdsMeta;
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > mMsgIds;
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > mMsgIdsMeta;
};

View File

@ -22,32 +22,32 @@ void RsGxsUpdateBroadcastPage::setUpdateWhenInvisible(bool update)
mBase->setUpdateWhenInvisible(update);
}
const std::list<RsGxsGroupId> &RsGxsUpdateBroadcastPage::getGrpIdsMeta()
const std::set<RsGxsGroupId> &RsGxsUpdateBroadcastPage::getGrpIdsMeta()
{
return mBase->getGrpIdsMeta();
}
void RsGxsUpdateBroadcastPage::getAllGrpIds(std::list<RsGxsGroupId> &grpIds)
void RsGxsUpdateBroadcastPage::getAllGrpIds(std::set<RsGxsGroupId> &grpIds)
{
mBase->getAllGrpIds(grpIds);
}
const std::list<RsGxsGroupId> &RsGxsUpdateBroadcastPage::getGrpIds()
const std::set<RsGxsGroupId> &RsGxsUpdateBroadcastPage::getGrpIds()
{
return mBase->getGrpIds();
}
const std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &RsGxsUpdateBroadcastPage::getMsgIdsMeta()
const std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &RsGxsUpdateBroadcastPage::getMsgIdsMeta()
{
return mBase->getMsgIdsMeta();
}
void RsGxsUpdateBroadcastPage::getAllMsgIds(std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &msgIds)
void RsGxsUpdateBroadcastPage::getAllMsgIds(std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &msgIds)
{
mBase->getAllMsgIds(msgIds);
}
const std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &RsGxsUpdateBroadcastPage::getMsgIds()
const std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &RsGxsUpdateBroadcastPage::getMsgIds()
{
return mBase->getMsgIds();
}

View File

@ -24,12 +24,12 @@ public:
void fillComplete();
void setUpdateWhenInvisible(bool update);
const std::list<RsGxsGroupId> &getGrpIds();
const std::list<RsGxsGroupId> &getGrpIdsMeta();
void getAllGrpIds(std::list<RsGxsGroupId> &grpIds);
const std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &getMsgIds();
const std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &getMsgIdsMeta();
void getAllMsgIds(std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &msgIds);
const std::set<RsGxsGroupId> &getGrpIds();
const std::set<RsGxsGroupId> &getGrpIdsMeta();
void getAllGrpIds(std::set<RsGxsGroupId> &grpIds);
const std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &getMsgIds();
const std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &getMsgIdsMeta();
void getAllMsgIds(std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &msgIds);
protected:
virtual void showEvent(QShowEvent *event);

View File

@ -2,12 +2,12 @@
#include "RsGxsUpdateBroadcastBase.h"
RsGxsUpdateBroadcastWidget::RsGxsUpdateBroadcastWidget(RsGxsIfaceHelper *ifaceImpl, QWidget *parent, Qt::WindowFlags flags)
: QWidget(parent, flags)
: QWidget(parent, flags)
{
mBase = new RsGxsUpdateBroadcastBase(ifaceImpl, this);
connect(mBase, SIGNAL(fillDisplay(bool)), this, SLOT(fillDisplay(bool)));
mBase = new RsGxsUpdateBroadcastBase(ifaceImpl, this);
connect(mBase, SIGNAL(fillDisplay(bool)), this, SLOT(fillDisplay(bool)));
mInterfaceHelper = ifaceImpl;
mInterfaceHelper = ifaceImpl;
}
RsGxsUpdateBroadcastWidget::~RsGxsUpdateBroadcastWidget()
@ -16,52 +16,52 @@ RsGxsUpdateBroadcastWidget::~RsGxsUpdateBroadcastWidget()
void RsGxsUpdateBroadcastWidget::fillComplete()
{
mBase->fillComplete();
mBase->fillComplete();
}
void RsGxsUpdateBroadcastWidget::setUpdateWhenInvisible(bool update)
{
mBase->setUpdateWhenInvisible(update);
mBase->setUpdateWhenInvisible(update);
}
const std::list<RsGxsGroupId> &RsGxsUpdateBroadcastWidget::getGrpIds()
const std::set<RsGxsGroupId> &RsGxsUpdateBroadcastWidget::getGrpIds()
{
return mBase->getGrpIds();
return mBase->getGrpIds();
}
const std::list<RsGxsGroupId> &RsGxsUpdateBroadcastWidget::getGrpIdsMeta()
const std::set<RsGxsGroupId> &RsGxsUpdateBroadcastWidget::getGrpIdsMeta()
{
return mBase->getGrpIdsMeta();
return mBase->getGrpIdsMeta();
}
void RsGxsUpdateBroadcastWidget::getAllGrpIds(std::list<RsGxsGroupId> &grpIds)
void RsGxsUpdateBroadcastWidget::getAllGrpIds(std::set<RsGxsGroupId> &grpIds)
{
mBase->getAllGrpIds(grpIds);
mBase->getAllGrpIds(grpIds);
}
const std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &RsGxsUpdateBroadcastWidget::getMsgIds()
const std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &RsGxsUpdateBroadcastWidget::getMsgIds()
{
return mBase->getMsgIds();
return mBase->getMsgIds();
}
const std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &RsGxsUpdateBroadcastWidget::getMsgIdsMeta()
const std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &RsGxsUpdateBroadcastWidget::getMsgIdsMeta()
{
return mBase->getMsgIdsMeta();
return mBase->getMsgIdsMeta();
}
void RsGxsUpdateBroadcastWidget::getAllMsgIds(std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &msgIds)
void RsGxsUpdateBroadcastWidget::getAllMsgIds(std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &msgIds)
{
mBase->getAllMsgIds(msgIds);
mBase->getAllMsgIds(msgIds);
}
void RsGxsUpdateBroadcastWidget::fillDisplay(bool complete)
{
updateDisplay(complete);
update(); // Qt flush
updateDisplay(complete);
update(); // Qt flush
}
void RsGxsUpdateBroadcastWidget::showEvent(QShowEvent *event)
{
mBase->showEvent(event);
QWidget::showEvent(event);
mBase->showEvent(event);
QWidget::showEvent(event);
}

View File

@ -24,12 +24,12 @@ public:
void fillComplete();
void setUpdateWhenInvisible(bool update);
const std::list<RsGxsGroupId> &getGrpIds();
const std::list<RsGxsGroupId> &getGrpIdsMeta();
void getAllGrpIds(std::list<RsGxsGroupId> &grpIds);
const std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &getMsgIds();
const std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &getMsgIdsMeta();
void getAllMsgIds(std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &msgIds);
const std::set<RsGxsGroupId> &getGrpIds();
const std::set<RsGxsGroupId> &getGrpIdsMeta();
void getAllGrpIds(std::set<RsGxsGroupId> &grpIds);
const std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &getMsgIds();
const std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &getMsgIdsMeta();
void getAllMsgIds(std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &msgIds);
RsGxsIfaceHelper *interfaceHelper() { return mInterfaceHelper; }

View File

@ -604,7 +604,7 @@ void CreateGxsChannelMsg::newChannelMsg()
GxsMsgReq message_ids;
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
message_ids[mChannelId].push_back(mOrigPostId);
message_ids[mChannelId].insert(mOrigPostId);
mChannelQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, message_ids, CREATEMSG_CHANNEL_POST_INFO);
}
}

View File

@ -185,8 +185,8 @@ void CreateGxsForumMsg::newMsg()
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
GxsMsgReq msgIds;
std::vector<RsGxsMessageId> &vect = msgIds[mForumId];
vect.push_back(mParentId);
std::set<RsGxsMessageId> &vect = msgIds[mForumId];
vect.insert(mParentId);
//std::cerr << "ForumsV2Dialog::newMsg() Requesting Parent Summary(" << mParentId << ")";
//std::cerr << std::endl;
@ -205,8 +205,8 @@ void CreateGxsForumMsg::newMsg()
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
GxsMsgReq msgIds;
std::vector<RsGxsMessageId> &vect = msgIds[mForumId];
vect.push_back(mOrigMsgId);
std::set<RsGxsMessageId> &vect = msgIds[mForumId];
vect.insert(mOrigMsgId);
//std::cerr << "ForumsV2Dialog::newMsg() Requesting Parent Summary(" << mParentId << ")";
//std::cerr << std::endl;

View File

@ -404,25 +404,25 @@ void GxsForumThreadWidget::changeEvent(QEvent *e)
}
}
static void removeMessages(std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &msgIds, QList<RsGxsMessageId> &removeMsgId)
static void removeMessages(std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &msgIds, QList<RsGxsMessageId> &removeMsgId)
{
QList<RsGxsMessageId> removedMsgId;
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >::iterator grpIt;
for (grpIt = msgIds.begin(); grpIt != msgIds.end(); ) {
std::vector<RsGxsMessageId> &msgs = grpIt->second;
for (auto grpIt = msgIds.begin(); grpIt != msgIds.end(); )
{
std::set<RsGxsMessageId> &msgs = grpIt->second;
QList<RsGxsMessageId>::const_iterator removeMsgIt;
for (removeMsgIt = removeMsgId.begin(); removeMsgIt != removeMsgId.end(); ++removeMsgIt) {
std::vector<RsGxsMessageId>::iterator msgIt = std::find(msgs.begin(), msgs.end(), *removeMsgIt);
if (msgIt != msgs.end()) {
if(msgs.find(*removeMsgIt) != msgs.end())
{
removedMsgId.push_back(*removeMsgIt);
msgs.erase(msgIt);
msgs.erase(*removeMsgIt);
}
}
if (msgs.empty()) {
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >::iterator grpItErase = grpIt++;
std::map<RsGxsGroupId, std::set<RsGxsMessageId> >::iterator grpItErase = grpIt++;
msgIds.erase(grpItErase);
} else {
++grpIt;
@ -452,18 +452,18 @@ void GxsForumThreadWidget::updateDisplay(bool complete)
}
bool updateGroup = false;
const std::list<RsGxsGroupId> &grpIdsMeta = getGrpIdsMeta();
if (std::find(grpIdsMeta.begin(), grpIdsMeta.end(), groupId()) != grpIdsMeta.end()) {
updateGroup = true;
}
const std::set<RsGxsGroupId> &grpIdsMeta = getGrpIdsMeta();
const std::list<RsGxsGroupId> &grpIds = getGrpIds();
if (std::find(grpIds.begin(), grpIds.end(), groupId()) != grpIds.end()) {
if(grpIdsMeta.find(groupId())!=grpIdsMeta.end())
updateGroup = true;
const std::set<RsGxsGroupId> &grpIds = getGrpIds();
if (grpIds.find(groupId())!=grpIds.end()){
updateGroup = true;
/* Update threads */
insertThreads();
} else {
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > msgIds;
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > msgIds;
getAllMsgIds(msgIds);
if (!mIgnoredMsgId.empty()) {
@ -2111,8 +2111,8 @@ void GxsForumThreadWidget::flagperson()
#endif
GxsMsgReq msgIds;
std::vector<RsGxsMessageId> &vect = msgIds[postId.first];
vect.push_back(postId.second);
std::set<RsGxsMessageId> &vect = msgIds[postId.first];
vect.insert(postId.second);
uint32_t token;
mTokenQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, token_type);
@ -2413,8 +2413,8 @@ void GxsForumThreadWidget::requestMessageData(const RsGxsGrpMsgIdPair &msgId)
#endif
GxsMsgReq msgIds;
std::vector<RsGxsMessageId> &vect = msgIds[msgId.first];
vect.push_back(msgId.second);
std::set<RsGxsMessageId> &vect = msgIds[msgId.first];
vect.insert(msgId.second);
uint32_t token;
mTokenQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, mTokenTypeMessageData);
@ -2464,8 +2464,8 @@ void GxsForumThreadWidget::requestMsgData_ReplyWithPrivateMessage(const RsGxsGrp
#endif
GxsMsgReq msgIds;
std::vector<RsGxsMessageId> &vect = msgIds[msgId.first];
vect.push_back(msgId.second);
std::set<RsGxsMessageId> &vect = msgIds[msgId.first];
vect.insert(msgId.second);
uint32_t token;
mTokenQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, mTokenTypeReplyMessage);
@ -2482,8 +2482,8 @@ void GxsForumThreadWidget::requestMsgData_ShowAuthorInPeople(const RsGxsGrpMsgId
#endif
GxsMsgReq msgIds;
std::vector<RsGxsMessageId> &vect = msgIds[msgId.first];
vect.push_back(msgId.second);
std::set<RsGxsMessageId> &vect = msgIds[msgId.first];
vect.insert(msgId.second);
uint32_t token;
mTokenQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, mTokenTypeShowAuthorInPeople);
@ -2499,8 +2499,8 @@ void GxsForumThreadWidget::requestMsgData_EditForumMessage(const RsGxsGrpMsgIdPa
#endif
GxsMsgReq msgIds;
std::vector<RsGxsMessageId> &vect = msgIds[msgId.first];
vect.push_back(msgId.second);
std::set<RsGxsMessageId> &vect = msgIds[msgId.first];
vect.insert(msgId.second);
uint32_t token;
mTokenQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, mTokenTypeEditForumMessage);
@ -2516,8 +2516,8 @@ void GxsForumThreadWidget::requestMsgData_ReplyForumMessage(const RsGxsGrpMsgIdP
#endif
GxsMsgReq msgIds;
std::vector<RsGxsMessageId> &vect = msgIds[msgId.first];
vect.push_back(msgId.second);
std::set<RsGxsMessageId> &vect = msgIds[msgId.first];
vect.insert(msgId.second);
uint32_t token;
mTokenQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, mTokenTypeReplyForumMessage);

View File

@ -846,10 +846,15 @@ void ServerPage::updateStatus()
return;
}
/* load up configuration from rsPeers */
RsPeerDetails detail;
if (!rsPeers->getPeerDetails(rsPeers->getOwnId(), detail))
return;
/* load up configuration from rsPeers */
RsPeerDetails detail;
if (!rsPeers->getPeerDetails(rsPeers->getOwnId(), detail))
{
std::cerr << __PRETTY_FUNCTION__ << " getPeerDetails(...) failed!"
<< " This is unexpected report to developers please."
<< std::endl;
return;
}
/* only update if can't edit */
if (!ui.localPort->isEnabled())

View File

@ -34,8 +34,8 @@
#include <retroshare/rsnotify.h>
#include <retroshare/rspeers.h>
#if defined(Q_OS_WIN)
#include <util/retroshareWin32.h>
#ifdef Q_OS_WIN
# include <util/retroshareWin32.h>
#endif
/* Retroshare's Settings */

View File

@ -10,11 +10,6 @@ DEFINES += TARGET=\\\"$${TARGET}\\\"
DEPENDPATH *= $${PWD} $${RS_INCLUDE_DIR} retroshare-gui
INCLUDEPATH *= $${PWD} retroshare-gui
# when rapidjson is mainstream on all distribs, we will not need the sources anymore
# in the meantime, they are part of the RS directory so that it is always possible to find them
INCLUDEPATH += ../../rapidjson-1.1.0
libresapihttpserver {
!include("../../libresapi/src/use_libresapi.pri"):error("Including")
HEADERS *= gui/settings/WebuiPage.h

View File

@ -50,15 +50,16 @@ void RsGxsUpdateBroadcast::onChangesReceived(const RsGxsChanges& changes)
{
std::cerr << "Received changes for service " << (void*)changes.mService << ", expecting service " << (void*)mIfaceImpl->getTokenService() << std::endl;
std::cerr << " changes content: " << std::endl;
for(std::list<RsGxsGroupId>::const_iterator it(changes.mGrps.begin());it!=changes.mGrps.end();++it) std::cerr << " grp id: " << *it << std::endl;
for(std::list<RsGxsGroupId>::const_iterator it(changes.mGrpsMeta.begin());it!=changes.mGrpsMeta.end();++it) std::cerr << " grp meta: " << *it << std::endl;
for(std::list<RsGxsGroupId>::const_iterator it(changes.mGrps.begin());it!=changes.mGrps.end();++it)
std::cerr << "[GRP CHANGE] grp id: " << *it << std::endl;
for(std::list<RsGxsGroupId>::const_iterator it(changes.mGrpsMeta.begin());it!=changes.mGrpsMeta.end();++it)
std::cerr << "[GRP CHANGE] grp meta: " << *it << std::endl;
for(std::map<RsGxsGroupId,std::vector<RsGxsMessageId> >::const_iterator it(changes.mMsgs.begin());it!=changes.mMsgs.end();++it)
for(uint32_t i=0;i<it->second.size();++i)
std::cerr << " grp id: " << it->first << ". Msg ID " << it->second[i] << std::endl;
std::cerr << "[MSG CHANGE] grp id: " << it->first << ". Msg ID " << it->second[i] << std::endl;
for(std::map<RsGxsGroupId,std::vector<RsGxsMessageId> >::const_iterator it(changes.mMsgsMeta.begin());it!=changes.mMsgsMeta.end();++it)
for(uint32_t i=0;i<it->second.size();++i)
std::cerr << " grp id: " << it->first << ". Msg Meta " << it->second[i] << std::endl;
std::cerr << "[MSG CHANGE] grp id: " << it->first << ". Msg Meta " << it->second[i] << std::endl;
}
#endif
if(changes.mService != mIfaceImpl->getTokenService())

View File

@ -19,7 +19,7 @@ public:
signals:
void changed();
void msgsChanged(const std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >& msgIds, const std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >& msgIdsMeta);
void msgsChanged(const std::map<RsGxsGroupId, std::set<RsGxsMessageId> >& msgIds, const std::map<RsGxsGroupId, std::set<RsGxsMessageId> >& msgIdsMeta);
void grpsChanged(const std::list<RsGxsGroupId>& grpIds, const std::list<RsGxsGroupId>& grpIdsMeta);
private slots:

View File

@ -103,6 +103,15 @@ static std::string readStringFromKeyboard(bool passwd_mode)
while((c=getchar()) != '\n')
{
// handle backspace
if (c == 127) {
if(s.length()!=0) {
std::cout << "\b \b";
s.resize(s.length()-1);
}
continue;
}
if(passwd_mode)
putchar('*') ;
else

View File

@ -16,10 +16,6 @@ libresapihttpserver {
!include("../../libretroshare/src/use_libretroshare.pri"):error("Including")
# when rapidjson is mainstream on all distribs, we will not need the sources anymore
# in the meantime, they are part of the RS directory so that it is always possible to find them
INCLUDEPATH += ../../rapidjson-1.1.0
################################# Linux ##########################################
linux-* {

View File

@ -418,13 +418,11 @@ win32-g++ {
PREFIX_MSYS2=$${TEMPTATIVE_MSYS2}
}
!isEmpty(PREFIX_MSYS2) {
message(Found MSYS2: $${PREFIX_MSYS2})
!isEmpty(PREFIX_MSYS2):message(Found MSYS2: $${PREFIX_MSYS2})
}
isEmpty(PREFIX) {
PREFIX = $$system_path($${PREFIX_MSYS2})
}
}
isEmpty(PREFIX):!isEmpty(PREFIX_MSYS2) {
PREFIX = $$system_path($${PREFIX_MSYS2})
}
isEmpty(PREFIX) {