diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 000000000..c4d514cea --- /dev/null +++ b/.gitmodules @@ -0,0 +1,6 @@ +[submodule "supportlibs/restbed"] + path = supportlibs/restbed + url = https://github.com/Corvusoft/restbed.git +[submodule "cmark"] + path = supportlibs/cmark + url = https://github.com/commonmark/cmark.git diff --git a/.travis.yml b/.travis.yml index 4ecc0dab7..e11da2148 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,10 +13,10 @@ matrix: before_install: - if [ $TRAVIS_OS_NAME == linux ]; then sudo apt-get update; fi - - if [ $TRAVIS_OS_NAME == linux ]; then sudo apt-get install -y build-essential libssl-dev libsqlcipher-dev libbz2-dev libmicrohttpd-dev libsqlite3-dev libupnp-dev pkg-config qt5-default libxss-dev qtmultimedia5-dev libqt5x11extras5-dev libqt5designer5 qttools5-dev; fi + - if [ $TRAVIS_OS_NAME == linux ]; then sudo apt-get install -y build-essential libssl-dev libsqlcipher-dev libbz2-dev libmicrohttpd-dev libsqlite3-dev libupnp-dev pkg-config qt5-default libxss-dev qtmultimedia5-dev libqt5x11extras5-dev libqt5designer5 libxapian-dev qttools5-dev; fi - if [ $TRAVIS_OS_NAME == osx ]; then brew update ; fi - - if [ $TRAVIS_OS_NAME == osx ]; then brew install qt55 openssl miniupnpc libmicrohttpd sqlcipher; fi + - if [ $TRAVIS_OS_NAME == osx ]; then brew install qt55 openssl miniupnpc libmicrohttpd sqlcipher xapian; fi - if [ $TRAVIS_OS_NAME == osx ]; then brew link --force qt55 ; fi - wget https://github.com/Tencent/rapidjson/archive/v1.1.0.tar.gz diff --git a/README.md b/README.md index c726983e5..3d98c2312 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Build Status | Platform | Build Status | | :------------- | :------------- | | GNU/Linux, MacOS, (via travis-ci) | [![Build Status](https://travis-ci.org/RetroShare/RetroShare.svg?branch=master)](https://travis-ci.org/RetroShare/RetroShare) | -| Windows, `MSys2` (via appveyor) | [![Build status](https://ci.appveyor.com/api/projects/status/fu7q0ye6pge53579?svg=true)](https://ci.appveyor.com/project/PhenomRetroShare/retroshare-59qxh) | +| Windows, `MSys2` (via appveyor) | [![Build status](https://ci.appveyor.com/api/projects/status/github/RetroShare/RetroShare?svg=true)](https://ci.appveyor.com/project/G10h4ck/retroshare-u4lmn) | Compilation on Windows ---------------------------- diff --git a/RetroShare.pro b/RetroShare.pro index d124ce94d..4197db2e0 100644 --- a/RetroShare.pro +++ b/RetroShare.pro @@ -1,3 +1,21 @@ +################################################################################ +# Retroshare.pro # +# Copyright (C) 2018, Retroshare team # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU Affero General Public License as # +# published by the Free Software Foundation, either version 3 of the # +# License, or (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU Affero General Public License for more details. # +# # +# You should have received a copy of the GNU Affero General Public License # +# along with this program. If not, see . # +################################################################################ + !include("retroshare.pri"): error("Could not include file retroshare.pri") TEMPLATE = subdirs @@ -5,14 +23,16 @@ TEMPLATE = subdirs SUBDIRS += openpgpsdk openpgpsdk.file = openpgpsdk/src/openpgpsdk.pro -retrotor { - libretroshare.depends = openpgpsdk -} else { - SUBDIRS += libbitdht - libbitdht.file = libbitdht/src/libbitdht.pro - libretroshare.depends = openpgpsdk libbitdht +rs_jsonapi { + SUBDIRS += jsonapi-generator + jsonapi-generator.file = jsonapi-generator/src/jsonapi-generator.pro + libretroshare.depends += jsonapi-generator } +SUBDIRS += libbitdht +libbitdht.file = libbitdht/src/libbitdht.pro +libretroshare.depends = openpgpsdk libbitdht + SUBDIRS += libretroshare libretroshare.file = libretroshare/src/libretroshare.pro @@ -27,15 +47,12 @@ retroshare_gui { retroshare_gui.target = retroshare_gui } -retrotor { -} else { retroshare_nogui { SUBDIRS += retroshare_nogui retroshare_nogui.file = retroshare-nogui/src/retroshare-nogui.pro retroshare_nogui.depends = libretroshare libresapi retroshare_nogui.target = retroshare_nogui } -} retroshare_android_service { SUBDIRS += retroshare_android_service diff --git a/WindowsMSys2_InstallGuide.md b/WindowsMSys2_InstallGuide.md index 3eb0085a5..31cd5caef 100644 --- a/WindowsMSys2_InstallGuide.md +++ b/WindowsMSys2_InstallGuide.md @@ -1,88 +1,73 @@ ## Compilation on Windows -### Qt Installation +The preferred build method on Windows is by using MSYS2 which is a collection +of packages providing unix-like tools to build native Windows software. -Install Qt via: [Qt Download](http://www.qt.io/download/) +Requirements: about 12 GB of free space -Use default options. -Add to the PATH environment variable - - ;C:\Qt\5.5\mingw492_32\bin;C:\Qt\Tools\mingw492_32\bin;C:\Qt\Tools\mingw492_32\opt\bin - -Depends on wich version of Qt you use. -Change build-all-mingw32make.bat with these values too if you don't use MSys2. +The resulting binary is a 32-bit build of Retroshare which will also work +fine on a 64-bit system. ### MSYS2 INSTALLATION -Choose your MSYS2 installer here: [MSYS2](http://msys2.github.io/) +Download MSYS2 from [MSYS2](http://www.msys2.org/). Get the i686 version +if you run a 32-bit Windows or the x86_64 if you run a 64-bit Windows. -Follow install procedure. -Don't forget to sync & Update pacman. +Run the installer and install MSYS2. - pacman --needed -Sy bash pacman pacman-mirrors msys2-runtime +At the end of the installation, it'll automatically open an MSYS shell terminal. +You can also find it on the start menu as MSYS2 MSYS. This is the shell you'll +use to install packages with pacman and do maintenance but NOT to build +RetroShare. -Restart console +First, update your MSYS2 environment to the latest version by typing: - pacman -Su + pacman -Syu -Install all default programms +Close the terminal window. - pacman -S base-devel git mercurial cvs wget p7zip gcc perl ruby python2 +Run MSYS2 MSYS again and finish updating with: -Choose only w64-i686 if you want only compilation in 32b architecture. + pacman -Su - pacman -S mingw-w64-i686-toolchain mingw-w64-x86_64-toolchain +Install the default programs needed to build: -### Install other binutils: - pacman -S mingw-w64-i686-miniupnpc mingw-w64-x86_64-miniupnpc - pacman -S mingw-w64-i686-sqlite3 mingw-w64-x86_64-sqlite3 - pacman -S mingw-w64-i686-speex mingw-w64-x86_64-speex - pacman -S mingw-w64-i686-speexdsp mingw-w64-x86_64-speexdsp - pacman -S mingw-w64-i686-opencv mingw-w64-x86_64-opencv - pacman -S mingw-w64-i686-ffmpeg mingw-w64-x86_64-ffmpeg - pacman -S mingw-w64-i686-libmicrohttpd mingw-w64-x86_64-libmicrohttpd - pacman -S mingw-w64-i686-libxslt mingw-w64-x86_64-libxslt + pacman -S base-devel git wget p7zip gcc perl ruby python2 -Add MSYS2 to PATH environment variable depends your windows +Install the 32-bit toolchain: - ;C:\msys64\mingw32\bin - ;C:\msys32\mingw32\bin + pacman -S mingw-w64-i686-toolchain +Install all needed dependencies: -### Git Installation + pacman -S mingw-w64-i686-miniupnpc + pacman -S mingw-w64-i686-libmicrohttpd + pacman -S mingw-w64-i686-libxslt + pacman -S mingw-w64-i686-xapian-core + pacman -S mingw-w64-i686-sqlcipher + pacman -S mingw-w64-i686-qt5 -Install Git Gui or other client: [Git Scm](https://git-scm.com/download/win) +We're done installing MSYS2, close the shell terminal. -Create a new directory named: +### BUILDING RETROSHARE - C:\Development\GIT +Now run the MSYS2 MinGW 32-bit shell terminal (it's in the start menu). +We will use it to checkout Retroshare and build it: -Right-click on it and choose: *Git Bash Here* + git clone https://github.com/RetroShare/RetroShare.git -Paste this text on git console: -git clone https://github.com/RetroShare/RetroShare.git +Go to the RetroShare directory and configure to your liking, for example: + + cd RetroShare + qmake -r -Wall -spec win32-g++ "CONFIG+=debug" "CONFIG+=rs_autologin" +Now we're ready to build Retroshare. Use the '-j' option with the number of +cores you have for a faster build, for instance if you have 4 cores: -### Last Settings + mingw32-make -j4 +Make sure your current Retroshare is not running. Then just run: -In QtCreator Option Git add its path: *C:\Program Files\Git\bin* -and select "Pull" with "Rebase" + retroshare-gui/src/debug/retroshare.exe - -Open an MSys2 32|64 shell -Move to build_scripts: - - cd /c/Development/GIT/RetroShare/msys2_build_libs/ - -### Compile missing library - make - -You can now compile RS into Qt Creator - -For using, and debugging Plugins, you can use [Symlinker](http://amd989.github.io/Symlinker/) to link -the files in - - \build-RetroShare-Desktop_Qt_X_Y_Z_MinGW_32bit-Debug\plugins\PluginName\debug\*.dll -to -*%appdata%\RetroShare\extensions6* +You'll get debug output in the terminal and a running Retroshare instance. diff --git a/appveyor.yml b/appveyor.yml index 6f26a1c67..b0b602cd1 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -85,10 +85,11 @@ environment: # - cmd: echo This is batch again # - cmd: set MY_VAR=12345 install: + - git submodule update --init # 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 mingw-w64-i686-miniupnpc mingw-w64-i686-sqlcipher mingw-w64-i686-libmicrohttpd mingw-w64-i686-xapian-core #- 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% diff --git a/build_scripts/Debian+Ubuntu/debian/control b/build_scripts/Debian+Ubuntu/debian/control index f93af67e9..ccf757edb 100644 --- a/build_scripts/Debian+Ubuntu/debian/control +++ b/build_scripts/Debian+Ubuntu/debian/control @@ -1,6 +1,6 @@ Source: retroshare Section: devel -Priority: standard +Priority: optional Maintainer: Cyril Soler Build-Depends: debhelper (>= 9), libglib2.0-dev, libupnp-dev, libssl-dev, libxss-dev, libgnome-keyring-dev, libbz2-dev, libspeex-dev, libspeexdsp-dev, libxslt1-dev, cmake, libcurl4-openssl-dev, libopencv-dev, tcl8.6, libsqlcipher-dev, libmicrohttpd-dev, libavcodec-dev, qtmultimedia5-dev, qttools5-dev, libqt5x11extras5-dev, qtbase5-dev, qt5-qmake, qtbase5-dev-tools Standards-Version: 4.1.4 diff --git a/build_scripts/Debian+Ubuntu/debian_release_howto.txt b/build_scripts/Debian+Ubuntu/debian_release_howto.txt index f77a9dd3e..db9f8d9bf 100644 --- a/build_scripts/Debian+Ubuntu/debian_release_howto.txt +++ b/build_scripts/Debian+Ubuntu/debian_release_howto.txt @@ -2,8 +2,8 @@ Creation of a new Debian changelog: dch --create --package retroshare --newversion 0.6.4-1 - Note: dch reads email in $DEBMAIL or $USER@$HOSTNAME, so it should be made correct in debian/changlog - If the email does not match the email in mentors, the package will be rejected. + Note: dch reads email in $DEBMAIL or $USER@$HOSTNAME, so it should be made correct in debian/changlog + If the email does not match the email in mentors, the package will be rejected. dget command to retrieve source package: @@ -16,17 +16,34 @@ When ready: dput mentors retroshare_0.6.4-1_source.changes -Checkign with lintian: - lintian --pedantic --profile debian retroshare_0.6.4-1_source.changes +Checking with lintian: + lintian -EI --pedantic --profile debian retroshare_0.6.4-1_source.changes + echo -e 'display-info=y\ndisplay-experimental=y\npedantic=y\ncolor=auto' > ~/.config/lintian/lintianrc + + Also apply lintian to binaries + * fix overlinking in voip plugin + +Turn the RFP bug into ITP + you have to send an e-mail to control@bugs.debian.org and use the "retitle" command + [05/13/2018] successfully retitled. The mail *body* (instead of subject) needs to contain the command in a single line. Todo - * make a sid binary package. - * test in sid using pbuilder chroot system (pbuilder login) - * upload to mentors - * request for sponsorship + x make a sid binary package. + * test in sid using pbuilder chroot system (pbuilder login) + x upload to mentors + x request for sponsorship + * Getting help: - https://webchat.oftc.net/ + https://webchat.oftc.net/ Bug creation/report - reportbug -B debian + reportbug -B debian + +Re-do debian/rules according to + https://sources.debian.org/src/sleepyhead/1.0.0-beta-2+dfsg-5/debian/rules/ + the proper way to use qtchooser in d/rules is exporting QT_SELECT in d/rules, see https://pkg-kde.alioth.debian.org/packagingqtbasedstuff.html + disable autologin + +Put the package on salsa: + salsa.debian.org diff --git a/build_scripts/Debian/clean.sh b/build_scripts/Debian/clean.sh new file mode 100755 index 000000000..8750b8f46 --- /dev/null +++ b/build_scripts/Debian/clean.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +rm -f ./retroshare_0.?.?-1_source.build +rm -f ./retroshare_0.?.?-1_source.changes +rm -f ./retroshare_0.?.?-1.tar.gz +rm -f ./retroshare_0.?.?-1.diff.gz +rm -f ./retroshare_0.?.?-1.dsc + +rm -f *~ +find . -name "*~" -exec rm {} \; + diff --git a/build_scripts/Debian/debian/README.Debian b/build_scripts/Debian/debian/README.Debian new file mode 100644 index 000000000..1d60d62a6 --- /dev/null +++ b/build_scripts/Debian/debian/README.Debian @@ -0,0 +1,6 @@ +retroshare for Debian +--------------------- + + + + -- Cyril Soler Sat, 06 Feb 2010 07:15:46 +0100 diff --git a/build_scripts/Debian/debian/changelog b/build_scripts/Debian/debian/changelog new file mode 100644 index 000000000..c4dd0e732 --- /dev/null +++ b/build_scripts/Debian/debian/changelog @@ -0,0 +1,5 @@ +retroshare (0.6.4-1) UNRELEASED; urgency=medium + + * Initial release for Debian. (Closes: #659069) + + -- Cyril Soler Wed, 09 May 2018 10:11:31 +0200 diff --git a/build_scripts/Debian/debian/compat b/build_scripts/Debian/debian/compat new file mode 100644 index 000000000..f599e28b8 --- /dev/null +++ b/build_scripts/Debian/debian/compat @@ -0,0 +1 @@ +10 diff --git a/build_scripts/Debian/debian/control b/build_scripts/Debian/debian/control new file mode 100644 index 000000000..42646702d --- /dev/null +++ b/build_scripts/Debian/debian/control @@ -0,0 +1,39 @@ +Source: retroshare +Section: devel +Priority: optional +Maintainer: Cyril Soler +Build-Depends: debhelper (>= 10), libglib2.0-dev, libupnp-dev, libssl-dev, libxss-dev, libgnome-keyring-dev, libbz2-dev, libspeex-dev, libspeexdsp-dev, libxslt1-dev, cmake, libcurl4-openssl-dev, libopencv-dev, tcl8.6, libsqlcipher-dev, libmicrohttpd-dev, libavcodec-dev, qtmultimedia5-dev, qttools5-dev, libqt5x11extras5-dev, qtbase5-dev, qt5-qmake, qtbase5-dev-tools +Standards-Version: 4.1.4 +Homepage: http://retroshare.sourceforge.net + +Package: retroshare-voip-plugin +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends}, retroshare, libspeex1, libspeexdsp1, libqt5multimedia5 +Description: VOIP plugin for the Retroshare communication platform + This package provides a plugin for RetroShare, a secured Friend-to-Friend + communication plateform. The plugin adds voice-over-IP functionality to the + private chat window. Both friends chatting together need the plugin installed + to be able to talk together. + +Package: retroshare-feedreader-plugin +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends}, retroshare +Description: FeedReader plugin for the Retroshare communication platform + Plugin for Retroshare, adding a RSS feed reader tab to retroshare. + +Package: retroshare-nogui +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends}, gnome-keyring +Conflicts: retroshare +Description: headless version of Retroshare software + Headless version of the Retroshare platform. + +Package: retroshare +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends}, gnome-keyring +Conflicts: retroshare-nogui +Description: Secure communication with friends + RetroShare is a Open Source, private and secure decentralised + commmunication platform. It creates mesh of computers linked with TLS + connections, on top of which it provides file transfer, asynchronous email, + forums, channels and chat. diff --git a/build_scripts/Debian/debian/copyright b/build_scripts/Debian/debian/copyright new file mode 100644 index 000000000..e230e1ad4 --- /dev/null +++ b/build_scripts/Debian/debian/copyright @@ -0,0 +1,49 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: retroshare +Upstream-Contact: retroshare.team@gmail.com +Source: https://github.com/retroshare/retroshare + +Files: * +Copyright: Copyright 2007-2018, Retroshare Team +License: GPL-2+ + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License version 2 as + published by the Free Software Foundation. + . + 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 General Public License for more details. + . + 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, Boston, MA 02110-1301 USA. + . + See /usr/share/common-licenses/GPL-2 on your Debian system. + . + In addition to these license terms, the author grants the following + additional rights: + . + If you modify this program, or any covered work, by linking or + combining it with the OpenSSL project's OpenSSL library (or a + modified version of that library), containing parts covered by the + terms of the OpenSSL or SSLeay licenses, the author + grants you additional permission to convey the resulting work. + Corresponding Source for a non-source form of such a combination + shall include the source code for the parts of OpenSSL used as well + as that of the covered work. + . + You may at your option choose to remove this additional permission from + the work, or from any part of it. + . + It is possible to build this program in a way that it loads OpenSSL + libraries at run-time. If doing so, the following notices are required + by the OpenSSL and SSLeay licenses: + . + This product includes software developed by the OpenSSL Project + for use in the OpenSSL Toolkit. (http://www.openssl.org/) + . + This product includes cryptographic software written by Eric Young + (eay@cryptsoft.com) + + diff --git a/build_scripts/Debian/debian/docs b/build_scripts/Debian/debian/docs new file mode 100644 index 000000000..e69de29bb diff --git a/build_scripts/Debian/debian/retroshare-feedreader-plugin.install b/build_scripts/Debian/debian/retroshare-feedreader-plugin.install new file mode 100644 index 000000000..5fc9c6571 --- /dev/null +++ b/build_scripts/Debian/debian/retroshare-feedreader-plugin.install @@ -0,0 +1 @@ +debian/tmp/usr/lib/retroshare/extensions6/libFeedReader.so* diff --git a/build_scripts/Debian/debian/retroshare-nogui.install b/build_scripts/Debian/debian/retroshare-nogui.install new file mode 100644 index 000000000..5fb7e3c8d --- /dev/null +++ b/build_scripts/Debian/debian/retroshare-nogui.install @@ -0,0 +1,3 @@ +debian/tmp/usr/bin/retroshare-nogui +debian/tmp/usr/share/retroshare/bdboot.txt +debian/tmp/usr/share/retroshare/webui/* diff --git a/build_scripts/Debian/debian/retroshare-voip-plugin.install b/build_scripts/Debian/debian/retroshare-voip-plugin.install new file mode 100644 index 000000000..48f8bdbab --- /dev/null +++ b/build_scripts/Debian/debian/retroshare-voip-plugin.install @@ -0,0 +1 @@ +debian/tmp/usr/lib/retroshare/extensions6/libVOIP.so* diff --git a/build_scripts/Debian/debian/retroshare.install b/build_scripts/Debian/debian/retroshare.install new file mode 100644 index 000000000..e8bfb8315 --- /dev/null +++ b/build_scripts/Debian/debian/retroshare.install @@ -0,0 +1,6 @@ +debian/tmp/usr/bin/retroshare +debian/tmp/usr/bin/retroshare-nogui +debian/tmp/usr/share/applications/retroshare.desktop +debian/tmp/usr/share/icons/hicolor/* +debian/tmp/usr/share/pixmaps/retroshare.xpm +debian/tmp/usr/share/retroshare/* diff --git a/build_scripts/Debian/debian/retrotor.install b/build_scripts/Debian/debian/retrotor.install new file mode 100644 index 000000000..2a81067cd --- /dev/null +++ b/build_scripts/Debian/debian/retrotor.install @@ -0,0 +1,5 @@ +debian/tmp/usr/bin/retroshare +debian/tmp/usr/share/applications/retroshare.desktop +debian/tmp/usr/share/icons/hicolor/* +debian/tmp/usr/share/pixmaps/retroshare.xpm +debian/tmp/usr/share/retroshare/* diff --git a/build_scripts/Debian/debian/rules b/build_scripts/Debian/debian/rules new file mode 100755 index 000000000..28e804a5f --- /dev/null +++ b/build_scripts/Debian/debian/rules @@ -0,0 +1,24 @@ +#!/usr/bin/make -f + +export DH_VERBOSE = 1 + +DPKG_EXPORT_BUILDFLAGS = 1 + +# skip *-dbgsym packages +DEB_BUILD_OPTIONS=noddebs + +include /usr/share/dpkg/default.mk + +#export DEB_BUILD_MAINT_PTIONS = hardening=+all +export QT_SELECT = qt5 + +MY_BUILDDIR = _build + +%: + dh $@ --buildsystem=qmake --builddirectory=$(MY_BUILDDIR) + +# Override dh_auto_configure in order to call qmake on the parent dir. We call mkdir here because of #800738. + +override_dh_auto_configure: + @mkdir -p $(MY_BUILDDIR) + dh_auto_configure -- CONFIG="unix release retroshare_plugins rs_autologin" PREFIX=/usr LIB_DIR=/usr/lib ../src diff --git a/build_scripts/Debian/debian/source/format b/build_scripts/Debian/debian/source/format new file mode 100644 index 000000000..d3827e75a --- /dev/null +++ b/build_scripts/Debian/debian/source/format @@ -0,0 +1 @@ +1.0 diff --git a/build_scripts/Debian/debian_release_howto.txt b/build_scripts/Debian/debian_release_howto.txt new file mode 100644 index 000000000..8d669d311 --- /dev/null +++ b/build_scripts/Debian/debian_release_howto.txt @@ -0,0 +1,145 @@ +Creation of a new Debian changelog: + + dch --create --package retroshare --newversion 0.6.4-1 + + Note: dch reads email in $DEBMAIL or $USER@$HOSTNAME, so it should be made correct in debian/changlog + If the email does not match the email in mentors, the package will be rejected. + +dget command to retrieve source package: + + dget -u https://launchpad.net/~retroshare/+archive/ubuntu/stable/+files/retroshare_0.6.4-1.20180313.0e6d27ad~xenial.dsc + + (-u means don't check PGP signature) + +When ready: + * updload the package in a place that can be used to dget the package on mentors.debian.net. + + dput mentors retroshare_0.6.4-1_source.changes + +Checking with lintian: + lintian -EI --pedantic --profile debian retroshare_0.6.4-1_source.changes + echo -e 'display-info=y\ndisplay-experimental=y\npedantic=y\ncolor=auto' > ~/.config/lintian/lintianrc + + Also apply lintian to binaries + * fix overlinking in voip plugin + +Turn the RFP bug into ITP + you have to send an e-mail to control@bugs.debian.org and use the "retitle" command + [05/13/2018] successfully retitled. The mail *body* (instead of subject) needs to contain the command in a single line. + +Todo + x make a sid binary package. + * test in sid using pbuilder chroot system (pbuilder login) + x upload to mentors + x request for sponsorship + * + +Getting help: + https://webchat.oftc.net/ + +Bug creation/report + reportbug -B debian + +Re-do debian/rules according to + https://sources.debian.org/src/sleepyhead/1.0.0-beta-2+dfsg-5/debian/rules/ + the proper way to use qtchooser in d/rules is exporting QT_SELECT in d/rules, see https://pkg-kde.alioth.debian.org/packagingqtbasedstuff.html + disable autologin + +Put the package on salsa: + salsa.debian.org + +Debian binary changes file signature: + gpg --clearsign -u 0932399B retroshare_0.6.4-1_amd64.changes + + Signature does only work when done with debsign: + debsign -k0932399B retroshare_0.6.4-1.dsc + debsign -k0932399B retroshare_0.6.4-1_source.changes + debsign -k0932399B retroshare_0.6.4-1_amd64.changes + +Uploading-to-mentors bug: + Apparently the system prevents you from uploading while a package is in the + queue. So the upload responds "403 forbidden" whene e.g. the previous + upload was cancelled by ^C. + + +Licensing issues: + Various licenses involved: + + R: re-licence to GPLv3 + D: delete + + Code part | Licenses |A| Authors | Comment + --------------------------------+------------------------+-+----------------------------------------------+------------------------------------------------- + libbitdht | GPLv3 | | drbob, csoler, Retroshare team | + bitdht/bencode.h | Public domain | | Mike Frysinger | + bitdht/bdrandom.h | GPLv2 |R| csoler | + --------------------------------+------------------------+-+----------------------------------------------+------------------------------------------------- + libresapi | GPLv3 | | G10H4ck, [], electron128 | Most files are unlicenced + libretroshare | GPLv2,GPLv3 | | csoler,drbob,Mr-alice,Chris,Thunder | Some files unversionned. + plugins/dlfcn_win32.cc | GPLv2.1 |R| Ramiro Polla | + pqi/authgpg.h | GPLv2 |R| Raghu Dev R. | .cc is authed by drbob + upnp/UPnPBase.h | GPLv2 | | Marcelo Roberto Jimenez, aMule Team | other code in upnp/ not copyrighted + util/pugiconfig.h | MIT | | Arseny Kapoulkyne | [unused file!] + util/rsstring.h | GPLv2 |R| Thomas Kister | + util/rswin.h | GPLv2 |R| Thomas Kister | + util/rsversioninfo.h | [none] | | Alexandrut | + util/stacktrace.h | GPLv2 |R| Timo Bingmann, G10H4ck | + librssimulator | [None] | | No authors | + openpgpsdk | Apache | | Rachell Wilmer, Ben Laurie | + pegmarkdown | All right reserved | | Daniel Jalkut - Code currently unused | + plugins/feedreader | GPLv2 | | Thunder | + plugins/VOIP | | | | + AudioInputConfig.h+ | All right reserved | | Thorvald Natvig | Code can be modified/re-used. Mumble's code. + SpeezProcessor.h | | | Peter Zotov | + retroshare-android-notify-* | GPLv3 | | G10H4ck | + retroshare-android-service | GPLv3 | | G10H4ck | + retroshare-gui/src | | | Thunder, csoler, drbob, crypton | + control/* | GPLv2 | | Matt Edman, crypton, Justin Hiple | [Unused code] + common/ElideLabel.h | BSD | | Qt Toolkit | + common/FlowLayout.h | BSD | | Qt Toolkit | Is that really Qt code?? Qt examples can be used. + common/html.h | GPLv2 | | Matt Edman, defnax, Justin Hiple | + common/rwindow.h | GPLv2 | | Matt Edman, defnax, Justin Hiple | + common/vmessagebox.h | GPLv2 | | Matt Edman, defnax, Justin Hiple | + common/PictureFlow | unclear | | Ariya Hidayat (@kde.org) | [Unused code] + elastic/* | LGPL | | Trolltech | + FileTransfer/FTIWidget | GPLv2 | | defnax, lsn752 | + FileTransfer/xprogressb | GPLv2 | | Xesc | + help/browser.h | GPLv2 | | Matt Edman, defnax, Justin Hiple | + images/retroshare_win.rc.h | GPLv2 | | crypton | [Unused code] + msgs/textformat.h | GPLv3 | | Merdhah Momeny, Golnaz Nilieh | very simple .h. Can be re-implemented + settings/rsettings.h | GPLv2 | | Matt Edman, defnax, Justin Hiple | + statistics/BandwidthGraphW.h| GPLv2 | | Matt Edman, defnax, Justin Hiple | + statistics/dhtgraph.h | GPLv2 | | Matt Edman, defnax, Justin Hiple | + toaster/MessageToaster.h | GPLv3 | | Xesc | + toaster/DownloadToaster.h | GPLv3 | | Xesc | + About{Widget,Dialog}.h | GPLv2 | | Unipro, Russia | Very small file. + linetypes.h | GPLv2 | | Merdhah Momeny, Golnaz Nilieh | very simple .h. Can be re-implemented + mainpagestack.h | GPLv2 | | Matt Edman, crypton, Justin Hiple | + land/langagesupport.h | GPLv2 | | Matt Edman, crypton, Justin Hiple | + util/log.h | GPLv2 | | Matt Edman, crypton, Justin Hiple | + idle/idle.h | GPLv2 | | Justin Karneges | May be re-implemented + TorControl/* |* Public domaine | | John Brooks | Code from Ricochet.im + util/HandleRichText.h | GPLv2 | | Thomas Kister | + util/misc.h | GPLv2 | | defnax, Christophe Dumez | + util/printpreview.h | GPLv2 | | Trolltech example | + util/retrosharewin32.h | GPLv2 | | Matt Edman, crypton, Justin Hiple | + util/stringutil.h | GPLv2 | | Matt Edman, crypton, Justin Hiple | + rshare.h | GPLv2 | | Matt Edman, crypton, Justin Hiple | + retroshare-nogui/* | GPLv2 | | drbob | + + + Plan: move to GPLv3 with OpenSSL exception + + - Appache is compatible with GPLv3 + + Many files unversionned. + + Use a pointer to the top level licence file + + +Files after switch: + + libresapi/api/json.h MIT license Copyright (c) 2013 Jeff Weinstein (jeff.weinstein at gmail) + libretroshare/src/tcponudp/bss_tou.cc SSL Licence Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + libretroshare/src/upnp/UPnPBase.{h,cpp} GPL Licence Copyright (c) 2004-2009 Marcelo Roberto Jimenez ( phoenix@amule.org ) + diff --git a/build_scripts/Debian/makeSourcePackage.sh b/build_scripts/Debian/makeSourcePackage.sh new file mode 100755 index 000000000..30e6aa736 --- /dev/null +++ b/build_scripts/Debian/makeSourcePackage.sh @@ -0,0 +1,189 @@ +#!/bin/sh + +###################### PARAMETERS #################### +gitpath="https://github.com/RetroShare/RetroShare.git" +#branch="master" +branch="v0.6.4-official_release" +#bubba3="Y" # comment out to compile for bubba3 +###################################################### + +RS_MAJOR_VERSION=`fgrep RS_MAJOR_VERSION ../../libretroshare/src/retroshare/rsversion.h | cut -d\\ -f3- | sed -e s\/\ \/\/g | cut -c1` +RS_MINOR_VERSION=`fgrep RS_MINOR_VERSION ../../libretroshare/src/retroshare/rsversion.h | cut -d\\ -f3- | sed -e s\/\ \/\/g | cut -c1` +RS_BUILD_NUMBER=`fgrep RS_BUILD_NUMBER ../../libretroshare/src/retroshare/rsversion.h | grep -v BUILD_NUMBER_ADD | cut -d\\ -f3- | sed -e s\/\ \/\/g | cut -c1` + +# echo "RS_MAJOR_VERSION="${RS_MAJOR_VERSION} +# echo "RS_MINOR_VERSION="${RS_MINOR_VERSION} +# echo "RS_BUILD_NUMBER="${RS_BUILD_NUMBER} + +version_number="${RS_MAJOR_VERSION}"'.'"${RS_MINOR_VERSION}"'.'"${RS_BUILD_NUMBER}" +workdir=retroshare-${version_number} + +echo This script is going to build the debian source package for RetroShare, from the Git repository. + +if test -d "${workdir}" ; then + echo Removing the ${workdir} directory... + rm -rf ${workdir} +fi + +# Parse options +rev="" +dist="" +# This is the key for "Cyril Soler " +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` + +rev=${date}.${hhsh} +useretrotor="false" + +while [ ${#} -gt 0 ]; do + case ${1} in + "-rev") shift + rev=${1} + shift + ;; + "-key") shift + gpgkey=${1} + shift + ;; + "-nodl") + nodl=yes + shift + ;; + "-makeorig") + makeorig=yes + shift + ;; + "-h") shift + echo Package building script for debian/ubuntu distributions + echo Usage: + echo " "${0} '-key [PGP key id] -rev [svn revision number] -distribution [distrib name list with quotes, in (wheezy, sid, precise, saucy, etc)]' + exit 1 + ;; + "*") echo "Unknown option" + exit 1 + ;; + esac +done + +echo Attempting to get revision number... +ccount=`git rev-list --count --all` +ccount=`expr $ccount + 8613 - 8267` + +echo " Workdir :"${workdir} +echo " Version :"${version_number} +echo " Using revision :"${rev} +echo " Commit count :"${ccount} +echo " Hash :"${hhsh} +echo " Date :"${date} +echo " Time :"${time} +echo " Using branch :"${branch} +echo " Using PGP key id :"${gpgkey} + +if test ${useretrotor} = "true"; then + echo " "Specific flags : retrotor +fi + +echo Done. +version="${version_number}"."${rev}" +echo Got version number ${version} +echo +echo Please check that the changelog is up to date. +echo Hit ENTER if this is correct. Otherwise hit Ctrl+C +read tmp + +echo Extracting base archive... + +if ! test "${makeorig}" = "yes" ; then + if ! test -f retroshare_${version_number}.orig.tar.gz; then + echo Error: no orig file found. Please call with -makeorig option first + exit + fi +fi + +if ! test "${nodl}" = "yes"; then + mkdir -p ${workdir}/src + echo Checking out latest snapshot... + cd ${workdir}/src + git clone --depth 1 ${gitpath} --single-branch --branch $branch . + + cd - + + if ! test -d ${workdir}/src/libretroshare/; then + echo Git clone failed. + exit + fi + + cp -r debian ${workdir}/debian + + # VOIP tweak + cp ${workdir}/src/retroshare-gui/src/gui/chat/PopupChatDialog.ui ${workdir}/src/plugins/VOIP/gui/PopupChatDialog.ui + + # remove unised qml code, only needed on Android + rm -rf ${workdir}/src/retroshare-qml-app/ + rm -rf ${workdir}/src/librssimulator/ + rm -rf ${workdir}/src/retroshare-android-notify-service/ + rm -rf ${workdir}/src/retroshare-android-service/ + rm -rf ${workdir}/src/libretroshare/src/unused/ + rm -rf ${workdir}/src/pegmarkdown/ + rm -rf ${workdir}/src/unittests/ + rm -rf ${workdir}/src/build_scripts/ + rm -f ${workdir}/debian/*~ + rm -f ${workdir}/debian/.*.sw? + rm -f ${workdir}/src/retroshare-gui/src/gui/qss/chat/Bubble_Compact/private/images.sh + rm -f ${workdir}/src/retroshare-gui/src/gui/qss/chat/Bubble/src/images.sh + rm -f ${workdir}/src/retroshare-gui/src/gui/qss/chat/Bubble/public/images.sh + rm -f ${workdir}/src/retroshare-gui/src/gui/qss/chat/Bubble/"history"/images.sh + rm -f ${workdir}/src/retroshare-gui/src/gui/qss/chat/Bubble/private/images.sh + + cd ${workdir} + echo Setting version numbers... + + # setup version numbers + sed -e "s%RS_REVISION_NUMBER.*%RS_REVISION_NUMBER 0x${hhsh}%" src/libretroshare/src/retroshare/rsversion.in > src/libretroshare/src/retroshare/rsversion.h + + # Various cleaning + echo Cleaning... + + \rm -rf src/.git + + if test "${makeorig}" = "yes" ; then + echo making orig archive + cd - + tar zcvf retroshare_${version_number}.orig.tar.gz ${workdir} + exit + fi + + cd - +else + tar zxvf retroshare_${version_number}.orig.tar.gz + + cp -r debian/* ${workdir}/debian/ + rm -rf ${workdir}/src/retroshare-qml-app/ + rm -rf ${workdir}/src/retroshare-android-notify-service/ + rm -rf ${workdir}/src/retroshare-android-service/ + rm -rf ${workdir}/src/librssimulator/ + rm -rf ${workdir}/src/unittests/ + rm -rf ${workdir}/src/libretroshare/src/unused/ + rm -rf ${workdir}/src/pegmarkdown/ + rm -rf ${workdir}/src/build_scripts/ + rm -f ${workdir}/debian/*~ + rm -f ${workdir}/debian/.*.sw? + rm -f ${workdir}/src/retroshare-gui/src/gui/qss/chat/Bubble_Compact/private/images.sh + rm -f ${workdir}/src/retroshare-gui/src/gui/qss/chat/Bubble/src/images.sh + rm -f ${workdir}/src/retroshare-gui/src/gui/qss/chat/Bubble/public/images.sh + rm -f ${workdir}/src/retroshare-gui/src/gui/qss/chat/Bubble/"history"/images.sh + rm -f ${workdir}/src/retroshare-gui/src/gui/qss/chat/Bubble/private/images.sh +fi + +# Cloning sqlcipher +# git clone https://github.com/sqlcipher/sqlcipher.git + +echo Calling debuild... +cd ${workdir} +debuild -S -k${gpgkey} --lintian-opts +pedantic -EviIL +cd - + +exit 0 diff --git a/build_scripts/Windows-msys2/build-tor.bat b/build_scripts/Windows-msys2/build-tor.bat new file mode 100644 index 000000000..125cec8ee --- /dev/null +++ b/build_scripts/Windows-msys2/build-tor.bat @@ -0,0 +1,23 @@ +@echo off + +setlocal + +:: Initialize environment +call "%~dp0env.bat" +if errorlevel 1 goto error_env +call "%EnvPath%\env.bat" +if errorlevel 1 goto error_env + +%cecho% info "Build %SourceName%" +call "%~dp0build\build.bat" 32 release tor version autologin plugins +if errorlevel 1 %cecho% error "Failed to build %SourceName%." & exit /B %ERRORLEVEL% + +%cecho% info "Pack %SourceName%" +call "%~dp0build\pack.bat" 32 release tor +if errorlevel 1 %cecho% error "Failed to pack %SourceName%." & exit /B %ERRORLEVEL% + +exit /B 0 + +:error_env +echo Failed to initialize environment. +exit /B 1 diff --git a/build_scripts/Windows-msys2/build.bat b/build_scripts/Windows-msys2/build.bat new file mode 100644 index 000000000..31ece29fb --- /dev/null +++ b/build_scripts/Windows-msys2/build.bat @@ -0,0 +1,23 @@ +@echo off + +setlocal + +:: Initialize environment +call "%~dp0env.bat" +if errorlevel 1 goto error_env +call "%EnvPath%\env.bat" +if errorlevel 1 goto error_env + +%cecho% info "Build %SourceName%" +call "%~dp0build\build.bat" 32 release version autologin plugins +if errorlevel 1 %cecho% error "Failed to build %SourceName%." & exit /B %ERRORLEVEL% + +%cecho% info "Pack %SourceName%" +call "%~dp0build\pack.bat" 32 release +if errorlevel 1 %cecho% error "Failed to pack %SourceName%." & exit /B %ERRORLEVEL% + +exit /B 0 + +:error_env +echo Failed to initialize environment. +exit /B 1 diff --git a/build_scripts/Windows-msys2/build/build.bat b/build_scripts/Windows-msys2/build/build.bat new file mode 100644 index 000000000..37032013c --- /dev/null +++ b/build_scripts/Windows-msys2/build/build.bat @@ -0,0 +1,81 @@ +@echo off + +setlocal + +:: Initialize environment +call "%~dp0..\env.bat" +if errorlevel 1 goto error_env +call "%EnvPath%\env.bat" +if errorlevel 1 goto error_env +call "%EnvPath%\env.bat" +if errorlevel 1 goto error_env +call "%EnvPath%\env-msys2.bat" +if errorlevel 1 goto error_env + +:: Initialize base environment +call "%~dp0env-base.bat" %* +if errorlevel 2 exit /B 2 +if errorlevel 1 goto error_env + +:: Install needed things +%EnvMSYS2Cmd% "pacman --noconfirm --needed -S make git mingw-w64-%RsMSYS2Architecture%-toolchain mingw-w64-%RsMSYS2Architecture%-qt5 mingw-w64-%RsMSYS2Architecture%-miniupnpc mingw-w64-%RsMSYS2Architecture%-sqlcipher mingw-w64-%RsMSYS2Architecture%-libmicrohttpd mingw-w64-%RsMSYS2Architecture%-xapian-core" + +:: Plugins +if "%ParamPlugins%"=="1" %EnvMSYS2Cmd% "pacman --noconfirm --needed -S mingw-w64-%RsMSYS2Architecture%-speex mingw-w64-%RsMSYS2Architecture%-speexdsp mingw-w64-%RsMSYS2Architecture%-curl mingw-w64-%RsMSYS2Architecture%-libxslt mingw-w64-%RsMSYS2Architecture%-opencv mingw-w64-%RsMSYS2Architecture%-ffmpeg" + +:: Initialize environment +call "%~dp0env.bat" %* +if errorlevel 2 exit /B 2 +if errorlevel 1 goto error_env + +echo. +echo === Version +echo. + +title Build - %SourceName%-%RsBuildConfig% [Version] + +pushd "%SourcePath%\retroshare-gui\src\gui\images" +:: Touch resource file +copy /b retroshare_win.rc +,, +popd + +if not exist "%RsBuildPath%" mkdir "%RsBuildPath%" +pushd "%RsBuildPath%" + +echo. +echo === qmake +echo. + +title Build - %SourceName%-%RsBuildConfig% [qmake] + +set RS_QMAKE_CONFIG="CONFIG+=%RsBuildConfig%" +if "%ParamVersion%"=="1" set RS_QMAKE_CONFIG=%RS_QMAKE_CONFIG% "CONFIG+=version_detail_bash_script" +if "%ParamAutologin%"=="1" set RS_QMAKE_CONFIG=%RS_QMAKE_CONFIG% "CONFIG+=rs_autologin" +if "%ParamPlugins%"=="1" set RS_QMAKE_CONFIG=%RS_QMAKE_CONFIG% "CONFIG+=retroshare_plugins" +if "%ParamRetroTor%"=="1" set RS_QMAKE_CONFIG=%RS_QMAKE_CONFIG% "CONFIG+=retrotor" + +call "%ToolsPath%\msys2-path.bat" "%SourcePath%" MSYS2SourcePath +call "%ToolsPath%\msys2-path.bat" "%EnvMSYS2Path%" MSYS2EnvMSYS2Path +%EnvMSYS2Cmd% "qmake "%MSYS2SourcePath%/RetroShare.pro" -r -spec win32-g++ %RS_QMAKE_CONFIG%" +if errorlevel 1 goto error + +echo. +echo === make +echo. + +title Build - %SourceName%-%RsBuildConfig% [make] + +%EnvMSYS2Cmd% "make -j 4" + +:error +popd + +title %COMSPEC% + +if errorlevel 1 echo.& echo Build failed& echo. +exit /B %ERRORLEVEL% + +:error_env +echo Failed to initialize environment. +endlocal +exit /B 1 diff --git a/build_scripts/Windows-msys2/build/clean.bat b/build_scripts/Windows-msys2/build/clean.bat new file mode 100644 index 000000000..935495580 --- /dev/null +++ b/build_scripts/Windows-msys2/build/clean.bat @@ -0,0 +1,25 @@ +@echo off + +setlocal + +:: Initialize environment +call "%~dp0..\env.bat" +if errorlevel 1 goto error_env +call "%EnvPath%\env.bat" +if errorlevel 1 goto error_env +call "%EnvPath%\env-msys2.bat" +if errorlevel 1 goto error_env + +call "%~dp0env.bat" %* +if errorlevel 2 exit /B 2 +if errorlevel 1 goto error_env + +if not exist "%RsBuildPath%" exit /B 0 +call "%ToolsPath%\remove-dir.bat" "%RsBuildPath%" + +exit /B %ERRORLEVEL% + +:error_env +echo Failed to initialize environment. +endlocal +exit /B 1 diff --git a/build_scripts/Windows-msys2/build/env-base.bat b/build_scripts/Windows-msys2/build/env-base.bat new file mode 100644 index 000000000..4c7226a7f --- /dev/null +++ b/build_scripts/Windows-msys2/build/env-base.bat @@ -0,0 +1,97 @@ +:: Process commandline parameter +set Param32=0 +set Param64=0 +set ParamRelease=0 +set ParamDebug=0 +set ParamVersion=0 +set ParamAutologin=0 +set ParamPlugins=0 +set ParamTor=0 + +:parameter_loop +if "%~1" NEQ "" ( + for /f "tokens=1,2 delims==" %%a in ("%~1") do ( + if "%%~a"=="32" ( + set Param32=1 + ) else if "%%~a"=="64" ( + set Param64=1 + ) else if "%%~a"=="release" ( + set ParamRelease=1 + ) else if "%%~a"=="debug" ( + set ParamDebug=1 + ) else if "%%~a"=="version" ( + set ParamVersion=1 + ) else if "%%~a"=="autologin" ( + set ParamAutologin=1 + ) else if "%%~a"=="plugins" ( + set ParamPlugins=1 + ) else if "%%~a"=="tor" ( + set ParamTor=1 + ) else ( + echo. + echo Unknown parameter %1 + goto :usage + ) + ) + shift /1 + goto parameter_loop +) + +if "%Param32%"=="1" ( + if "%Param64%"=="1" ( + echo. + echo 32-bit or 64-bit? + goto :usage + ) + + set RsBit=32 + set RsArchitecture=x86 + set RsMSYS2Architecture=i686 +) + +if "%Param64%"=="1" ( + set RsBit=64 + set RsArchitecture=x64 + set RsMSYS2Architecture=x86_64 +) + +if "%RsBit%"=="" goto :usage + +if "%ParamRelease%"=="1" ( + if "%ParamDebug%"=="1" ( + echo. + echo Release or Debug? + goto :usage + ) + + set RsBuildConfig=release +) else if "%ParamDebug%"=="1" ( + set RsBuildConfig=debug +) else goto :usage + +if "%ParamTor%"=="1" ( + set RsType=-tor +) else ( + set RsType= +) + + +exit /B 0 + +:usage +echo. +echo Usage: 32^|64 release^|debug [version autologin plugins] +echo. +echo Mandatory parameter +echo 32^|64 32-bit or 64-bit Version +echo release^|debug Build release or debug version +echo. +echo Optional parameter (need clean when changed) +echo version Create version information from git +echo autologin Build with autologin +echo plugins Build plugins +echo. +echo Parameter for pack +echo tor Pack tor version +echo. +exit /B 2 diff --git a/build_scripts/Windows-msys2/build/env.bat b/build_scripts/Windows-msys2/build/env.bat new file mode 100644 index 000000000..81912fb38 --- /dev/null +++ b/build_scripts/Windows-msys2/build/env.bat @@ -0,0 +1,29 @@ +call "%~dp0env-base.bat" %* +if errorlevel 2 exit /B 2 +if errorlevel 1 goto error_env + +set MSYSTEM=MINGW%RsBit% + +set BuildPath=%EnvRootPath%\builds +set DeployPath=%EnvRootPath%\deploy + +if not exist "%BuildPath%" mkdir "%BuildPath%" +if not exist "%DeployPath%" mkdir "%DeployPath%" + +:: Get Qt version +call "%ToolsPath%\get-qt-version.bat" QtVersion +if "%QtVersion%"=="" %cecho% error "Cannot get Qt version." & exit /B 1 + +set RsMinGWPath=%EnvMSYS2BasePath%\mingw%RsBit% + +set RsBuildPath=%BuildPath%\Qt-%QtVersion%-%RsArchitecture%-%RsBuildConfig% +set RsDeployPath=%DeployPath%\Qt-%QtVersion%%RsType%-%RsArchitecture%-%RsBuildConfig% +set RsPackPath=%DeployPath% +set RsArchiveAdd= + +if not exist "%~dp0env-mod.bat" goto no_mod +call "%~dp0env-mod.bat" +if errorlevel 1 exit /B %ERRORLEVEL% +:no_mod + +exit /B 0 diff --git a/build_scripts/Windows-msys2/build/git-log.bat b/build_scripts/Windows-msys2/build/git-log.bat new file mode 100644 index 000000000..9c7814ebe --- /dev/null +++ b/build_scripts/Windows-msys2/build/git-log.bat @@ -0,0 +1,118 @@ +@echo off + +setlocal + +set NoAsk= +if "%~2"=="no-ask" set NoAsk=1 + +:: Initialize environment +call "%~dp0..\env.bat" +if errorlevel 1 goto error_env +call "%EnvPath%\env.bat" +if errorlevel 1 goto error_env +call "%EnvPath%\env-msys2.bat" +if errorlevel 1 goto error_env + +call "%~dp0env.bat" %* +if errorlevel 2 exit /B 2 +if errorlevel 1 goto error_env + +:: Check git executable +set GitPath= +call "%ToolsPath%\find-in-path.bat" GitPath git.exe +if "%GitPath%"=="" echo Git executable not found in PATH.& exit /B 1 + +:: Get compiled revision +set GetRsVersion=%SourcePath%\build_scripts\Windows\tools\get-rs-version.bat +if not exist "%GetRsVersion%" ( + echo File not found + echo %GetRsVersion% + exit /B 1 +) + +call "%GetRsVersion%" RS_REVISION_STRING RsRevision +if "%RsRevision%"=="" echo Revision not found.& exit /B 1 + +:: Get compiled version +call "%GetRsVersion%" RS_REVISION_STRING RsRevision +if "%RsRevision%"=="" echo Revision not found.& exit /B 1 + +call "%GetRsVersion%" RS_MAJOR_VERSION RsMajorVersion +if "%RsMajorVersion%"=="" echo Major version not found.& exit /B 1 + +call "%GetRsVersion%" RS_MINOR_VERSION RsMinorVersion +if "%RsMinorVersion%"=="" echo Minor version not found.& exit /B 1 + +call "%GetRsVersion%" RS_BUILD_NUMBER RsBuildNumber +if "%RsBuildNumber%"=="" echo Build number not found.& exit /B 1 + +call "%GetRsVersion%" RS_BUILD_NUMBER_ADD RsBuildNumberAdd + +set RsVersion=%RsMajorVersion%.%RsMinorVersion%.%RsBuildNumber%%RsBuildNumberAdd% + +:: Check WMIC is available +wmic.exe alias /? >nul 2>&1 || echo WMIC is not available.&& exit /B 1 + +:: Use WMIC to retrieve date in format YYYYMMDD +set RsDate= +for /f "tokens=2 delims==" %%I in ('wmic os get localdatetime /format:list') do set RsDate=%%I +set RsDate=%RsDate:~0,4%%RsDate:~4,2%%RsDate:~6,2% + +:: Get last revision +set RsLastRefFile=%BuildPath%\Qt-%QtVersion%%RsType%-%RsBuildConfig%-LastRef.txt +set RsLastRef= +if exist "%RsLastRefFile%" set /P RsLastRef=<"%RsLastRefFile%" + +if "%NoAsk%"=="1" goto no_ask_for_last_revision +if not "%RsLastRef%"=="" echo Last Revision was %RsLastRef% +set /P RsLastRefInput=Last Revision: +if "%RsLastRefInput%" NEQ "" set RsLastRef=%RsLastRefInput% +:no_ask_for_last_revision + +:: Get current revision +pushd "%SourcePath%" +call "%ToolsPath%\get-git-ref.bat" RsRef +popd + +if errorlevel 1 exit /B 1 +if "%RsRef%"=="" echo Cannot get git revision.& exit /B 1 + +echo. +echo Creating log from %RsLastRef% +echo to %RsRef% + +if "%NoAsk%"=="1" goto no_confirm +choice /M "Do you want to proceed?" +if %errorlevel%==2 exit /B 1 +:no_confirm + +if "%RsBuildConfig%" NEQ "release" ( + set RsGitLog=%DeployPath%\RetroShare-%RsVersion%-Windows-Portable-%RsDate%-%RsRevision%-Qt-%QtVersion%%RsType%-msys2%RsArchiveAdd%-%RsBuildConfig%.txt +) else ( + set RsGitLog=%DeployPath%\RetroShare-%RsVersion%-Windows-Portable-%RsDate%-%RsRevision%-Qt-%QtVersion%%RsType%-msys2%RsArchiveAdd%.txt +) + +title %SourceName%-%RsBuildConfig% [git log] + +pushd "%SourcePath%" +if "%RsLastRef%"=="" ( + git log %RsRef% >"%RsGitLog%" +) else ( + if "%RsLastRef%"=="%RsRef%" ( + git log %RsRef% --max-count=1 >"%RsGitLog%" + ) else ( + git log %RsLastRef%..%RsRef% >"%RsGitLog%" + ) +) +popd + +title %COMSPEC% + +echo %RsRef%>"%RsLastRefFile%" + +exit /B %ERRORLEVEL% + +:error_env +echo Failed to initialize environment. +endlocal +exit /B 1 diff --git a/build_scripts/Windows-msys2/build/pack.bat b/build_scripts/Windows-msys2/build/pack.bat new file mode 100644 index 000000000..675226459 --- /dev/null +++ b/build_scripts/Windows-msys2/build/pack.bat @@ -0,0 +1,222 @@ +@echo off + +setlocal + +set Quite=^>nul + +:: Initialize environment +call "%~dp0..\env.bat" +if errorlevel 1 goto error_env +call "%EnvPath%\env.bat" +if errorlevel 1 goto error_env +call "%EnvPath%\env-msys2.bat" +if errorlevel 1 goto error_env + +:: Initialize environment +call "%~dp0env.bat" %* +if errorlevel 2 exit /B 2 +if errorlevel 1 goto error_env + +:: Remove deploy path +if exist "%RsDeployPath%" rmdir /S /Q "%RsDeployPath%" + +:: Check compilation +if not exist "%RsBuildPath%\Makefile" echo Project is not compiled.& goto error + +:: Get compiled revision +set GetRsVersion=%SourcePath%\build_scripts\Windows\tools\get-rs-version.bat +if not exist "%GetRsVersion%" ( + echo File not found + echo %GetRsVersion% + goto error +) + +call "%GetRsVersion%" RS_REVISION_STRING RsRevision +if "%RsRevision%"=="" echo Revision not found.& goto error + +:: Get compiled version +call "%GetRsVersion%" RS_MAJOR_VERSION RsMajorVersion +if "%RsMajorVersion%"=="" echo Major version not found.& goto error + +call "%GetRsVersion%" RS_MINOR_VERSION RsMinorVersion +if "%RsMinorVersion%"=="" echo Minor version not found.& goto error + +call "%GetRsVersion%" RS_BUILD_NUMBER RsBuildNumber +if "%RsBuildNumber%"=="" echo Build number not found.& goto error + +call "%GetRsVersion%" RS_BUILD_NUMBER_ADD RsBuildNumberAdd + +set RsVersion=%RsMajorVersion%.%RsMinorVersion%.%RsBuildNumber%%RsBuildNumberAdd% + +:: Check WMIC is available +wmic.exe alias /? >nul 2>&1 || echo WMIC is not available.&& goto error + +:: Use WMIC to retrieve date in format YYYYMMDD +set RsDate= +for /f "tokens=2 delims==" %%I in ('wmic os get localdatetime /format:list') do set RsDate=%%I +set RsDate=%RsDate:~0,4%%RsDate:~4,2%%RsDate:~6,2% + +if "%ParamTor%"=="1" ( + :: Check for tor executable + if not exist "%EnvDownloadPath%\tor\Tor\tor.exe" ( + echo Tor binary not found. Please download Tor Expert Bundle from + echo https://www.torproject.org/download/download.html.en + echo and unpack to + echo %EnvDownloadPath%\tor + goto error + ) +) + +set QtMainVersion=%QtVersion:~0,1% +set QtSharePath=%RsMinGWPath%\share\qt%QtMainVersion%\ + +rem Qt 4 = QtSvg4.dll +rem Qt 5 = Qt5Svg.dll +set QtMainVersion1= +set QtMainVersion2= +if "%QtMainVersion%"=="4" set QtMainVersion2=4 +if "%QtMainVersion%"=="5" set QtMainVersion1=5 + +if "%RsBuildConfig%" NEQ "release" ( + set Archive=%RsPackPath%\RetroShare-%RsVersion%-Windows-Portable-%RsDate%-%RsRevision%-Qt-%QtVersion%-msys2%RsType%%RsArchiveAdd%-%RsBuildConfig%.7z +) else ( + set Archive=%RsPackPath%\RetroShare-%RsVersion%-Windows-Portable-%RsDate%-%RsRevision%-Qt-%QtVersion%-msys2%RsType%%RsArchiveAdd%.7z +) + +if exist "%Archive%" del /Q "%Archive%" + +:: Create deploy path +mkdir "%RsDeployPath%" + +title Pack - %SourceName%%RsType%-%RsBuildConfig% [copy files] + +set ExtensionsFile=%SourcePath%\libretroshare\src\rsserver\rsinit.cc +set Extensions= +for /f %%e in ('type "%ExtensionsFile%" ^| sed.exe -n "s/^.*\/\(extensions[^/]*\)\/.*$/\1/p" ^| sed.exe -n "1,1p"') do set Extensions=%%e +if "%Extensions%"=="" echo Folder for extensions not found in %ExtensionsFile%& goto error + +:: Copy files +mkdir "%RsDeployPath%\Data\%Extensions%" +mkdir "%RsDeployPath%\imageformats" +mkdir "%RsDeployPath%\qss" +mkdir "%RsDeployPath%\stylesheets" +mkdir "%RsDeployPath%\sounds" +mkdir "%RsDeployPath%\translations" + +copy nul "%RsDeployPath%\portable" %Quite% + +echo copy binaries +copy "%RsBuildPath%\retroshare-gui\src\%RsBuildConfig%\RetroShare*.exe" "%RsDeployPath%" %Quite% +copy "%RsBuildPath%\retroshare-nogui\src\%RsBuildConfig%\retroshare*-nogui.exe" "%RsDeployPath%" %Quite% + +echo copy extensions +for /D %%D in ("%RsBuildPath%\plugins\*") do ( + call :copy_extension "%%D" "%RsDeployPath%\Data\%Extensions%" + call :copy_dependencies "%RsDeployPath%\Data\%Extensions%\%%~nxD.dll" "%RsDeployPath%" +) + +echo copy dependencies +call :copy_dependencies "%RsDeployPath%\retroshare.exe" "%RsDeployPath%" + +echo copy Qt DLL's +copy "%RsMinGWPath%\bin\Qt%QtMainVersion1%Svg%QtMainVersion2%.dll" "%RsDeployPath%" %Quite% + +if "%QtMainVersion%"=="5" ( + mkdir "%RsDeployPath%\platforms" + copy "%QtSharePath%\plugins\platforms\qwindows.dll" "%RsDeployPath%\platforms" %Quite% + mkdir "%RsDeployPath%\audio" + copy "%QtSharePath%\plugins\audio\qtaudio_windows.dll" "%RsDeployPath%\audio" %Quite% +) + +if exist "%QtSharePath%\plugins\styles\qwindowsvistastyle.dll" ( + echo Copy styles + mkdir "%RsDeployPath%\styles" %Quite% + copy "%QtSharePath%\plugins\styles\qwindowsvistastyle.dll" "%RsDeployPath%\styles" %Quite% +) + +copy "%QtSharePath%\plugins\imageformats\*.dll" "%RsDeployPath%\imageformats" %Quite% +del /Q "%RsDeployPath%\imageformats\*d?.dll" %Quite% + +echo copy qss +xcopy /S "%SourcePath%\retroshare-gui\src\qss" "%RsDeployPath%\qss" %Quite% + +echo copy stylesheets +xcopy /S "%SourcePath%\retroshare-gui\src\gui\qss\chat" "%RsDeployPath%\stylesheets" %Quite% +rmdir /S /Q "%RsDeployPath%\stylesheets\compact" %Quite% +rmdir /S /Q "%RsDeployPath%\stylesheets\standard" %Quite% +rmdir /S /Q "%RsDeployPath%\stylesheets\__MACOSX__Bubble" %Quite% + +echo copy sounds +xcopy /S "%SourcePath%\retroshare-gui\src\sounds" "%RsDeployPath%\sounds" %Quite% + +echo copy translation +copy "%SourcePath%\retroshare-gui\src\translations\qt_tr.qm" "%RsDeployPath%\translations" %Quite% +copy "%QtSharePath%\translations\qt_*.qm" "%RsDeployPath%\translations" %Quite% +if "%QtMainVersion%"=="5" ( + copy "%QtSharePath%\translations\qtbase_*.qm" "%RsDeployPath%\translations" %Quite% + copy "%QtSharePath%\translations\qtscript_*.qm" "%RsDeployPath%\translations" %Quite% + copy "%QtSharePath%\translations\qtquick1_*.qm" "%RsDeployPath%\translations" %Quite% + copy "%QtSharePath%\translations\qtmultimedia_*.qm" "%RsDeployPath%\translations" %Quite% + copy "%QtSharePath%\translations\qtxmlpatterns_*.qm" "%RsDeployPath%\translations" %Quite% +) + +echo copy bdboot.txt +copy "%SourcePath%\libbitdht\src\bitdht\bdboot.txt" "%RsDeployPath%" %Quite% + +echo copy changelog.txt +copy "%SourcePath%\retroshare-gui\src\changelog.txt" "%RsDeployPath%" %Quite% + +if exist "%SourcePath%\libresapi\src\webui" ( + echo copy webui + mkdir "%RsDeployPath%\webui" + xcopy /S "%SourcePath%\libresapi\src\webui" "%RsDeployPath%\webui" %Quite% +) + +if "%ParamTor%"=="1" ( + echo copy tor + echo n | copy /-y "%EnvDownloadPath%\tor\Tor\*.*" "%RsDeployPath%" %Quite% +) + +rem pack files +title Pack - %SourceName%%RsType%-%RsBuildConfig% [pack files] + +"%EnvSevenZipExe%" a -mx=9 -t7z "%Archive%" "%RsDeployPath%\*" + +title %COMSPEC% + +call :cleanup + +endlocal +exit /B 0 + +:error +call :Cleanup +endlocal +exit /B 1 + +:cleanup +goto :EOF + +:error_env +echo Failed to initialize environment. +endlocal +exit /B 1 + +:copy_extension +if exist "%~1\%RsBuildConfig%\%~n1.dll" ( + copy "%~1\%RsBuildConfig%\%~n1.dll" %2 %Quite% +) +goto :EOF + +:copy_dependencies +set CopyDependenciesCopiedSomething=0 +for /F "usebackq" %%A in (`%ToolsPath%\depends.bat list %1`) do ( + if not exist "%~2\%%A" ( + if exist "%RsMinGWPath%\bin\%%A" ( + set CopyDependenciesCopiedSomething=1 + copy "%RsMinGWPath%\bin\%%A" %2 %Quite% + ) + ) +) +if "%CopyDependenciesCopiedSomething%"=="1" goto copy_dependencies +goto :EOF diff --git a/build_scripts/Windows-msys2/env.bat b/build_scripts/Windows-msys2/env.bat new file mode 100644 index 000000000..b8beb566d --- /dev/null +++ b/build_scripts/Windows-msys2/env.bat @@ -0,0 +1,19 @@ +call :make_path SourcePath "%~dp0..\.." +call :make_path RootPath "%SourcePath%\.." +call :source_name SourceName "%SourcePath%" +set ToolsPath=%~dp0tools +set EnvPath=%~dp0env + +exit /B 0 + +:make_path +setlocal +set Var=%~1 +pushd %2 +set CD=%cd% +popd +endlocal & set %Var%=%CD% +goto :EOF + +:source_name +set %~1=%~nx2 diff --git a/build_scripts/Windows-msys2/env/env-msys2.bat b/build_scripts/Windows-msys2/env/env-msys2.bat new file mode 100644 index 000000000..ff08ff961 --- /dev/null +++ b/build_scripts/Windows-msys2/env/env-msys2.bat @@ -0,0 +1,37 @@ +:: Usage: +:: call env-msys2.bat [reinstall|clean] + +:: Initialize environment +call "%~dp0env.bat" +if errorlevel 1 goto error_env + +IF DEFINED ProgramFiles(x86) ( + :: x64 + set MSYS2Architecture=x86_64 + set MSYS2Base=64 +) else ( + :: x86 + set MSYS2Architecture=i686 + set MSYS2Base=32 +) + +set CHERE_INVOKING=1 + +set EnvMSYS2Path=%EnvRootPath%\msys2 +set EnvMSYS2BasePath=%EnvMSYS2Path%\msys%MSYS2Base% + +call "%~dp0tools\prepare-msys2.bat" %1 +if errorlevel 1 exit /B %ERRORLEVEL% + +set EnvMSYS2SH=%EnvMSYS2BasePath%\usr\bin\sh.exe +if not exist "%EnvMSYS2SH%" if errorlevel 1 goto error_env + +set EnvMSYS2Cmd="%EnvMSYS2SH%" -lc + +set PATH=%EnvMSYS2BasePath%\usr\bin;%PATH% + +exit /B 0 + +:error_env +echo Failed to initialize environment. +exit /B 1 diff --git a/build_scripts/Windows-msys2/env/env.bat b/build_scripts/Windows-msys2/env/env.bat new file mode 100644 index 000000000..11cbcb986 --- /dev/null +++ b/build_scripts/Windows-msys2/env/env.bat @@ -0,0 +1,26 @@ +:: Initialize environment +call "%~dp0..\env.bat" +if errorlevel 1 goto error_env + +set EnvRootPath=%RootPath%\%SourceName%-msys2 +set EnvToolsPath=%EnvRootPath%\tools +set EnvTempPath=%EnvRootPath%\tmp +set EnvDownloadPath=%EnvRootPath%\download + +set EnvWgetExe=%EnvToolsPath%\wget.exe +set EnvSevenZipExe=%EnvToolsPath%\7z.exe +set EnvDependsExe=%EnvToolsPath%\depends.exe +set EnvCEchoExe=%EnvToolsPath%\cecho.exe +set cecho=call "%ToolsPath%\cecho.bat" + +:: Create folders +if not exist "%EnvRootPath%" mkdir "%EnvRootPath%" +if not exist "%EnvToolsPath%" mkdir "%EnvToolsPath%" +if not exist "%EnvDownloadPath%" mkdir "%EnvDownloadPath%" + +call "%~dp0tools\prepare-tools.bat" +exit /B %ERRORLEVEL% + +:error_env +echo Failed to initialize environment. +exit /B 1 diff --git a/build_scripts/Windows-msys2/env/tools/prepare-msys2.bat b/build_scripts/Windows-msys2/env/tools/prepare-msys2.bat new file mode 100644 index 000000000..a7b7cd4b1 --- /dev/null +++ b/build_scripts/Windows-msys2/env/tools/prepare-msys2.bat @@ -0,0 +1,57 @@ +:: Usage: +:: call prepare-msys2.bat [reinstall|clean] + +setlocal enabledelayedexpansion + +if "%EnvMSYS2Path%"=="" exit /B 1 +if "%MSYS2Architecture%"=="" exit /B 1 +if "%MSYS2Base%"=="" exit /B 1 +if not exist "%EnvRootPath%"=="" exit /B 1 + +copy "%~dp0root\update-msys2.bat" "%EnvRootPath%" >nul + +if "%~1"=="clean" ( + %cecho% info "Clean MSYS2" + call "%ToolsPath%\remove-dir.bat" "%EnvMSYS2Path%" + goto exit +) + +if exist "%EnvMSYS2Path%\msys%MSYS2Base%\usr\bin\pacman.exe" ( + if "%~1"=="reinstall" ( + choice /M "Found existing MSYS2 version. Do you want to proceed?" + if !ERRORLEVEL!==2 goto exit + ) else ( + goto exit + ) +) + +set MSYS2Install=msys2-base-%MSYS2Architecture%-20180531.tar.xz +set MSYS2Url=http://sourceforge.net/projects/msys2/files/Base/%MSYS2Architecture%/%MSYS2Install%/download + +%cecho% info "Remove previous MSYS2 version" +call "%ToolsPath%\remove-dir.bat" "%EnvMSYS2Path%" + +%cecho% info "Download installation files" +if not exist "%EnvDownloadPath%\%MSYS2Install%" call "%ToolsPath%\download-file.bat" "%MSYS2Url%" "%EnvDownloadPath%\%MSYS2Install%" +if not exist "%EnvDownloadPath%\%MSYS2Install%" %cecho% error "Cannot download MSYS" & goto error + +%cecho% info "Unpack MSYS2" +"%EnvSevenZipExe%" x -so "%EnvDownloadPath%\%MSYS2Install%" | "%EnvSevenZipExe%" x -y -si -ttar -o"%EnvMSYS2Path%" + +set MSYS2SH=%EnvMSYS2Path%\msys%MSYS2Base%\usr\bin\sh + +%cecho% info "Initialize MSYS2" +"%MSYS2SH%" -lc "pacman -Sy" +"%MSYS2SH%" -lc "pacman --noconfirm --needed -S bash pacman pacman-mirrors msys2-runtime" + +call "%EnvMSYS2Path%\msys%MSYS2Base%\autorebase.bat" +call "%EnvRootPath%\update-msys2.bat" +call "%EnvRootPath%\update-msys2.bat" + +:exit +endlocal +exit /B 0 + +:error +endlocal +exit /B 1 diff --git a/build_scripts/Windows-msys2/env/tools/prepare-tools.bat b/build_scripts/Windows-msys2/env/tools/prepare-tools.bat new file mode 100644 index 000000000..e8788d52d --- /dev/null +++ b/build_scripts/Windows-msys2/env/tools/prepare-tools.bat @@ -0,0 +1,79 @@ +setlocal + +if "%EnvRootPath%"=="" exit /B 1 + +set CEchoUrl=https://github.com/lordmulder/cecho/releases/download/2015-10-10/cecho.2015-10-10.zip +set CEchoInstall=cecho.2015-10-10.zip +set SevenZipUrl=https://sourceforge.net/projects/sevenzip/files/7-Zip/18.05/7z1805.msi/download +set SevenZipInstall=7z1805.msi +set WgetUrl=https://eternallybored.org/misc/wget/1.19.4/32/wget.exe +set WgetInstall=wget.exe +set DependsUrl=http://www.dependencywalker.com/depends22_x86.zip +set DependsInstall=depends22_x86.zip + +if not exist "%EnvToolsPath%\wget.exe" ( + echo Download Wget installation + + if not exist "%EnvDownloadPath%\%WgetInstall%" call "%ToolsPath%\winhttpjs.bat" %WgetUrl% -saveTo "%EnvDownloadPath%\%WgetInstall%" + if not exist "%EnvDownloadPath%\%WgetInstall%" %cecho% error "Cannot download Wget installation" & goto error + + echo Copy Wget + copy "%EnvDownloadPath%\wget.exe" "%EnvToolsPath%" +) + +if not exist "%EnvToolsPath%\7z.exe" ( + call "%ToolsPath%\remove-dir.bat" "%EnvTempPath%" + mkdir "%EnvTempPath%" + + echo Download 7z installation + + if not exist "%EnvDownloadPath%\%SevenZipInstall%" call "%ToolsPath%\download-file.bat" "%SevenZipUrl%" "%EnvDownloadPath%\%SevenZipInstall%" + if not exist "%EnvDownloadPath%\%SevenZipInstall%" echo Cannot download 7z installation& goto error + + echo Unpack 7z + msiexec /a "%EnvDownloadPath%\%SevenZipInstall%" /qb TARGETDIR="%EnvTempPath%" + copy "%EnvTempPath%\Files\7-Zip\7z.dll" "%EnvToolsPath%" + copy "%EnvTempPath%\Files\7-Zip\7z.exe" "%EnvToolsPath%" + + call "%ToolsPath%\remove-dir.bat" "%EnvTempPath%" +) + +if not exist "%EnvToolsPath%\cecho.exe" ( + call "%ToolsPath%\remove-dir.bat" "%EnvTempPath%" + mkdir "%EnvTempPath%" + + echo Download cecho installation + + if not exist "%EnvDownloadPath%\%CEchoInstall%" call "%ToolsPath%\download-file.bat" "%CEchoUrl%" "%EnvDownloadPath%\%CEchoInstall%" + if not exist "%EnvDownloadPath%\%cCEhoInstall%" echo Cannot download cecho installation& goto error + + echo Unpack cecho + "%EnvSevenZipExe%" x -o"%EnvTempPath%" "%EnvDownloadPath%\%CEchoInstall%" + copy "%EnvTempPath%\cecho.exe" "%EnvToolsPath%" + + call "%ToolsPath%\remove-dir.bat" "%EnvTempPath%" +) + +if not exist "%EnvToolsPath%\depends.exe" ( + call "%ToolsPath%\remove-dir.bat" "%EnvTempPath%" + mkdir "%EnvTempPath%" + + %cecho% info "Download Dependency Walker installation" + + if not exist "%EnvDownloadPath%\%DependsInstall%" call "%ToolsPath%\winhttpjs.bat" %DependsUrl% -saveTo "%EnvDownloadPath%\%DependsInstall%" + if not exist "%EnvDownloadPath%\%DependsInstall%" %cecho% error "Cannot download Dependendy Walker installation" & goto error + + %cecho% info "Unpack Dependency Walker" + "%EnvSevenZipExe%" x -o"%EnvTempPath%" "%EnvDownloadPath%\%DependsInstall%" + copy "%EnvTempPath%\*" "%EnvToolsPath%" + + call "%ToolsPath%\remove-dir.bat" "%EnvTempPath%" +) + +:exit +endlocal +exit /B 0 + +:error +endlocal +exit /B 1 diff --git a/build_scripts/Windows-msys2/env/tools/root/update-msys2.bat b/build_scripts/Windows-msys2/env/tools/root/update-msys2.bat new file mode 100644 index 000000000..1441ea388 --- /dev/null +++ b/build_scripts/Windows-msys2/env/tools/root/update-msys2.bat @@ -0,0 +1,19 @@ +@echo off + +setlocal + +if exist "%~dp0msys2\msys32" call :update 32 +if exist "%~dp0msys2\msys64" call :update 64 + +goto :EOF + +:update +set MSYSSH=%~dp0msys2\msys%~1\usr\bin\sh + +echo Update MSYS2 %~1 +"%MSYSSH%" -lc "pacman -Sy" +"%MSYSSH%" -lc "pacman --noconfirm -Su" + +:exit +endlocal +goto :EOF diff --git a/build_scripts/Windows-msys2/tools/cecho.bat b/build_scripts/Windows-msys2/tools/cecho.bat new file mode 100644 index 000000000..f25966de7 --- /dev/null +++ b/build_scripts/Windows-msys2/tools/cecho.bat @@ -0,0 +1,6 @@ +:: Usage: +:: call cecho.bat [info|error|std] "text" + +if "%~1"=="std" echo %~2 +if "%~1"=="info" "%EnvCEchoExe%" green "%~2" +if "%~1"=="error" "%EnvCEchoExe%" red "%~2" diff --git a/build_scripts/Windows-msys2/tools/depends.bat b/build_scripts/Windows-msys2/tools/depends.bat new file mode 100644 index 000000000..cd5e97ffd --- /dev/null +++ b/build_scripts/Windows-msys2/tools/depends.bat @@ -0,0 +1,40 @@ +:: Usage: +:: call depends.bat [list^|missing] file + +if "%2"=="" ( + echo Usage: %~nx0 [list^|missing] File + exit /B 1 +) + +setlocal + +if not exist "%EnvDependsExe%" echo depends.exe not found in %EnvToolsPath%.& exit /B 1 + +set CutPath= +call "%ToolsPath%\find-in-path.bat" CutPath cut.exe +if "%CutPath%"=="" echo cut.exe not found in PATH.& exit /B 1 + +start /wait "" "%EnvDependsExe%" /c /oc:"%~dp0depends.tmp" %2 +if "%1"=="missing" ( + cut.exe --delimiter=, --fields=1,2 "%~dp0depends.tmp" >"%~dp0depends1.tmp" + for /F "tokens=1,2 delims=," %%A in (%~sdp0depends1.tmp) do ( + if "%%A"=="?" ( + echo %%~B + ) + ) +) + +if "%1"=="list" ( + cut.exe --delimiter=, --fields=2 "%~dp0depends.tmp" >"%~dp0depends1.tmp" + for /F "tokens=1 delims=," %%A in (%~sdp0depends1.tmp) do ( + if "%%A" NEQ "Module" ( + echo %%~A + ) + ) +) + +if exist "%~dp0depends.tmp" del /Q "%~dp0depends.tmp" +if exist "%~dp0depends1.tmp" del /Q "%~dp0depends1.tmp" + +endlocal +exit /B 0 \ No newline at end of file diff --git a/build_scripts/Windows-msys2/tools/download-file.bat b/build_scripts/Windows-msys2/tools/download-file.bat new file mode 100644 index 000000000..b0e93be5f --- /dev/null +++ b/build_scripts/Windows-msys2/tools/download-file.bat @@ -0,0 +1,13 @@ +:: Usage: +:: call download-file.bat url file + +if "%~2"=="" ( + echo. + echo Parameter error. + exit /B 1 +) + +::"%EnvCurlExe%" -L -k "%~1" -o "%~2" +"%EnvWgetExe%" --no-check-certificate --continue "%~1" --output-document="%~2" + +exit /B %ERRORLEVEL% diff --git a/build_scripts/Windows-msys2/tools/find-in-path.bat b/build_scripts/Windows-msys2/tools/find-in-path.bat new file mode 100644 index 000000000..895a10a3d --- /dev/null +++ b/build_scripts/Windows-msys2/tools/find-in-path.bat @@ -0,0 +1,26 @@ +:: Usage: +:: call find-in-path.bat variable file + +setlocal + +set Var=%~1 +set File=%~2 + +if "%File%"=="" ( + echo. + echo Parameter error. + exit /B 1 +) + +set FoundPath= + +SET PathTemp="%Path:;=";"%" +FOR %%P IN (%PathTemp%) DO ( + IF EXIST "%%~P.\%File%" ( + set FoundPath=%%~P + goto :found + ) +) + +:found +endlocal & set %Var%=%FoundPath% diff --git a/build_scripts/Windows-msys2/tools/get-git-ref.bat b/build_scripts/Windows-msys2/tools/get-git-ref.bat new file mode 100644 index 000000000..fbf1ae600 --- /dev/null +++ b/build_scripts/Windows-msys2/tools/get-git-ref.bat @@ -0,0 +1,39 @@ +REM Usage: +REM call get-git-ref.bat Variable [Branch] + +setlocal + +set Variable=%~1 +if "%Variable%"=="" ( + echo. + echo Parameter error + exit /B 1 +) + +set Ref= + +:: Check git executable +set GitPath= +call "%~dp0find-in-path.bat" GitPath git.exe +if "%GitPath%"=="" ( + echo. + echo Git executable not found in PATH. + goto exit +) + +set GitParameter= +set Branch=%~2 +if "%Branch%"=="" ( + set Branch=HEAD + set GitParameter=--head +) + +for /F "tokens=1*" %%A in ('git show-ref %GitParameter% %Branch%') do ( + if "%%B"=="%Branch%" ( + set Ref=%%A + ) +) + +:exit +endlocal & set %Variable%=%Ref% +exit /B 0 diff --git a/build_scripts/Windows-msys2/tools/get-qt-version.bat b/build_scripts/Windows-msys2/tools/get-qt-version.bat new file mode 100644 index 000000000..33abcb53f --- /dev/null +++ b/build_scripts/Windows-msys2/tools/get-qt-version.bat @@ -0,0 +1,27 @@ +:: Usage: +:: call get-qt-version.bat variable + +setlocal + +set Var=%~1 +if "%Var%"=="" ( + echo. + echo Parameter error. + exit /B 1 +) + +set QtVersion= + +%EnvMSYS2Cmd% "qmake -version" >"%~dp0qtversion.tmp" +for /F "tokens=1,2,3,4" %%A in (%~sdp0qtversion.tmp) do ( + if "%%A"=="Using" ( + set QtVersion=%%D + goto exit + ) +) + +:exit +if exist "%~dp0qtversion.tmp" del /Q "%~dp0qtversion.tmp" + +endlocal & set %Var%=%QtVersion% +exit /B 0 \ No newline at end of file diff --git a/build_scripts/Windows-msys2/tools/get-rs-version.bat b/build_scripts/Windows-msys2/tools/get-rs-version.bat new file mode 100644 index 000000000..82fe88262 --- /dev/null +++ b/build_scripts/Windows-msys2/tools/get-rs-version.bat @@ -0,0 +1,33 @@ +:: Usage: +:: call get-rs-version.bat Define Variable + +setlocal + +set Define=%~1 +set Variable=%~2 +if "%Variable%"=="" ( + echo. + echo Parameter error. + exit /B 1 +) + +set Result= +set VersionFile="%~dp0..\..\..\libretroshare\src\retroshare\rsversion.h" + +if not exist "%VersionFile%" ( + echo. + echo Version file doesn't exist. + echo %VersionFile% + exit /B1 +) + +for /F "usebackq tokens=1,2,3" %%A in (%VersionFile%) do ( + if "%%A"=="#define" ( + if "%%B"=="%Define%" ( + set Result=%%~C + ) + ) +) + +endlocal & set %Variable%=%Result% +exit /B 0 \ No newline at end of file diff --git a/build_scripts/Windows-msys2/tools/msys2-path.bat b/build_scripts/Windows-msys2/tools/msys2-path.bat new file mode 100644 index 000000000..3649b32d3 --- /dev/null +++ b/build_scripts/Windows-msys2/tools/msys2-path.bat @@ -0,0 +1,20 @@ +:: Usage: +:: call msys2-path.bat path variable + +setlocal + +set WinPath=%~1 +set MSYS2Var=%~2 + +if "%MSYS2Var%"=="" ( + echo. + echo Parameter error. + exit /B 1 +) + +set MSYS2Path=/%WinPath:~0,1%/%WinPath:~3% +set MSYS2Path=%MSYS2Path:\=/% + +endlocal & set %MSYS2Var%=%MSYS2Path% + +exit /B 0 diff --git a/build_scripts/Windows-msys2/tools/remove-dir.bat b/build_scripts/Windows-msys2/tools/remove-dir.bat new file mode 100644 index 000000000..2bcb14c51 --- /dev/null +++ b/build_scripts/Windows-msys2/tools/remove-dir.bat @@ -0,0 +1,15 @@ +:: Usage: +:: call remove-dir.bat path + +if "%~1"=="" ( + echo. + echo Parameter error. + exit /B 1 +) + +if exist %1 ( + del /s /f /q %1 >nul + rmdir /s /q %1 +) + +exit /B 0 diff --git a/build_scripts/Windows-msys2/tools/winhttpjs.bat b/build_scripts/Windows-msys2/tools/winhttpjs.bat new file mode 100644 index 000000000..0c1847fac --- /dev/null +++ b/build_scripts/Windows-msys2/tools/winhttpjs.bat @@ -0,0 +1,584 @@ +@if (@X) == (@Y) @end /* JScript comment + @echo off + + rem :: the first argument is the script name as it will be used for proper help message + cscript //E:JScript //nologo "%~f0" "%~nx0" %* + + exit /b %errorlevel% + +@if (@X)==(@Y) @end JScript comment */ + +// used resources + +// update 12.10.15 +// osvikvi(https://github.com/osvikvi) has nodited that the -password option is not set , so this is fixed + +//https://msdn.microsoft.com/en-us/library/windows/desktop/aa384058(v=vs.85).aspx +//https://msdn.microsoft.com/en-us/library/windows/desktop/aa384055(v=vs.85).aspx +//https://msdn.microsoft.com/en-us/library/windows/desktop/aa384059(v=vs.85).aspx + +// global variables and constants + + +// ---------------------------------- +// -- asynch requests not included -- +// ---------------------------------- + + +//todo - save responceStream instead of responceBody !! +//todo - set all winthttp options ->//https://msdn.microsoft.com/en-us/library/windows/desktop/aa384108(v=vs.85).aspx +//todo - log all options +//todo - improve help message . eventual verbose option + + +var ARGS = WScript.Arguments; +var scriptName = ARGS.Item(0); + +var url = ""; +var saveTo = ""; + +var user = 0; +var pass = 0; + +var proxy = 0; +var bypass = 0; +var proxy_user = 0; +var proxy_pass = 0; + +var certificate = 0; + +var force = true; + +var body = ""; + +//ActiveX objects +var WinHTTPObj = new ActiveXObject("WinHttp.WinHttpRequest.5.1"); +var FileSystemObj = new ActiveXObject("Scripting.FileSystemObject"); +var AdoDBObj = new ActiveXObject("ADODB.Stream"); + +// HttpRequest SetCredentials flags. +var proxy_settings = 0; + +// +HTTPREQUEST_SETCREDENTIALS_FOR_SERVER = 0; +HTTPREQUEST_SETCREDENTIALS_FOR_PROXY = 1; + +//timeouts and their default values +var RESOLVE_TIMEOUT = 0; +var CONNECT_TIMEOUT = 90000; +var SEND_TIMEOUT = 90000; +var RECEIVE_TIMEOUT = 90000; + +//HttpRequestMethod +var http_method = 'GET'; + +//header +var header_file = ""; + +//report +var reportfile = ""; + +//test-this: +var use_stream = false; + +//autologon policy +var autologon_policy = 1; //0,1,2 + + +//headers will be stored as multi-dimensional array +var headers = []; + +//user-agent +var ua = ""; + +//escape URL +var escape = false; + +function printHelp() { + WScript.Echo(scriptName + " - sends HTTP request and saves the request body as a file and/or a report of the sent request"); + WScript.Echo(scriptName + " url [-force yes|no] [-user username -password password] [-proxy proxyserver:port] [-bypass bypass_list]"); + WScript.Echo(" [-proxyuser proxy_username -proxypassword proxy_password] [-certificate certificateString]"); + WScript.Echo(" [-method GET|POST|PATCH|DELETE|HEAD|OPTIONS|CONNECT]"); + WScript.Echo(" [-saveTo file] - to print response to console use con"); + + WScript.Echo(" [-sendTimeout int(milliseconds)]"); + WScript.Echo(" [-resolveTimeout int(milliseconds)]"); + WScript.Echo(" [-connectTimeout int(milliseconds)]"); + WScript.Echo(" [-receiveTimeout int(milliseconds)]"); + + WScript.Echo(" [-autologonPolicy 1|2|3]"); + WScript.Echo(" [-proxySettings 1|2|3] (https://msdn.microsoft.com/en-us/library/windows/desktop/aa384059(v=vs.85).aspx)"); + + //header + WScript.Echo(" [-headers-file header_file]"); + //reportfile + WScript.Echo(" [-reportfile reportfile]"); + WScript.Echo(" [-ua user-agent]"); + WScript.Echo(" [-ua-file user-agent-file]"); + + WScript.Echo(" [-escape yes|no]"); + + WScript.Echo(" [-body body-string]"); + WScript.Echo(" [-body-file body-file]"); + + WScript.Echo("-force - decide to not or to overwrite if the local files exists"); + + WScript.Echo("proxyserver:port - the proxy server"); + WScript.Echo("bypass- bypass list"); + WScript.Echo("proxy_user , proxy_password - credentials for proxy server"); + WScript.Echo("user , password - credentials for the server"); + WScript.Echo("certificate - location of SSL certificate"); + WScript.Echo("method - what HTTP method will be used.Default is GET"); + WScript.Echo("saveTo - save the responce as binary file"); + WScript.Echo(" "); + WScript.Echo("Header file should contain key:value pairs.Lines starting with \"#\" will be ignored."); + WScript.Echo("value should NOT be enclosed with quotes"); + WScript.Echo(" "); + WScript.Echo("Examples:"); + + WScript.Echo(scriptName + " http://somelink.com/somefile.zip -saveTo c:\\somefile.zip -certificate \"LOCAL_MACHINE\\Personal\\My Middle-Tier Certificate\""); + WScript.Echo(scriptName + " http://somelink.com/something.html -method POST -certificate \"LOCAL_MACHINE\\Personal\\My Middle-Tier Certificate\" -header c:\\header_file -reportfile c:\\reportfile.txt"); + WScript.Echo(scriptName + "\"http://somelink\" -method POST -header hdrs.txt -reportfile reportfile2.txt -saveTo responsefile2 -ua \"Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36\" -body-file some.json"); + +} + +function parseArgs() { + // + if (ARGS.Length < 2) { + WScript.Echo("insufficient arguments"); + printHelp(); + WScript.Quit(43); + } + // !!! + url = ARGS.Item(1); + // !!! + if (ARGS.Length % 2 != 0) { + WScript.Echo("illegal arguments"); + printHelp(); + WScript.Quit(44); + } + + for (var i = 2; i < ARGS.Length - 1; i = i + 2) { + var arg = ARGS.Item(i).toLowerCase(); + var next = ARGS.Item(i + 1); + + + try { + switch (arg) { // the try-catch is set mainly because of the parseInts + case "-force": + if (next == "no") { + force = false; + } + break; + case "-escape": + if (next == "yes") { + escape = true; + } + break; + case "-saveto": + saveTo = next; + break; + case "-user": + case "-u": + user = next; + break; + case "-pass": + case "-password": + case "-p": + pass = next; + break; + case "-proxy": + proxy = next; + break; + case "-bypass": + bypass = next; + break; + case "-proxyuser": + case "-pu": + proxy_user = next; + break; + case "-proxypassword": + case "-pp": + proxy_pass = next; + break; + case "-ua": + ua = next; + break; + case "-ua-file": + ua = readFile(next); + break; + case "-body": + body = next; + break; + case "-usestream": + //WScript.Echo("~~"); + if (next.toLowerCase() === "yes") { + use_stream = true + }; + break; + case "-body-file": + body = readFile(next); + break; + case "-certificate": + certificate = next; + break; + case "-method": + switch (next.toLowerCase()) { + case "post": + http_method = 'POST'; + break; + case "get": + http_method = 'GET'; + break; + case "head": + http_method = 'HEAD'; + break; + case "put": + http_method = 'PUT'; + break; + case "options": + http_method = 'OPTIONS'; + break; + case "connect": + http_method = 'CONNECT'; + break; + case "patch": + http_method = 'PATCH'; + break; + case "delete": + http_method = 'DELETE'; + break; + default: + WScript.Echo("Invalid http method passed " + next); + WScript.Echo("possible values are GET,POST,DELETE,PUT,CONNECT,PATCH,HEAD,OPTIONS"); + WScript.Quit(1326); + break; + } + break; + case "-headers-file": + case "-header": + headers = readPropFile(next); + break; + case "-reportfile": + reportfile = next; + break; + //timeouts + case "-sendtimeout": + SEND_TIMEOUT = parseInt(next); + break; + case "-connecttimeout": + CONNECT_TIMEOUT = parseint(next); + break; + case "-resolvetimeout": + RESOLVE_TIMEOUT = parseInt(next); + break; + case "-receivetimeout": + RECEIVE_TIMEOUT = parseInt(next); + break; + + case "-autologonpolicy": + autologon_policy = parseInt(next); + if (autologon_policy > 2 || autologon_policy < 0) { + WScript.Echo("out of autologon policy range"); + WScript.Quit(87); + }; + break; + case "-proxysettings": + proxy_settings = parseInt(next); + if (proxy_settings > 2 || proxy_settings < 0) { + WScript.Echo("out of proxy settings range"); + WScript.Quit(87); + }; + break; + default: + WScript.Echo("Invalid command line switch: " + arg); + WScript.Quit(1405); + break; + } + } catch (err) { + WScript.Echo(err.message); + WScript.Quit(1348); + } + } +} + +stripTrailingSlash = function(path) { + while (path.substr(path.length - 1, path.length) == '\\') { + path = path.substr(0, path.length - 1); + } + return path; +} + +function existsItem(path) { + return FileSystemObj.FolderExists(path) || FileSystemObj.FileExists(path); +} + +function deleteItem(path) { + if (FileSystemObj.FileExists(path)) { + FileSystemObj.DeleteFile(path); + return true; + } else if (FileSystemObj.FolderExists(path)) { + FileSystemObj.DeleteFolder(stripTrailingSlash(path)); + return true; + } else { + return false; + } +} + +//------------------------------- +//---------------------- +//---------- +//----- +//-- +function request(url) { + + try { + + WinHTTPObj.Open(http_method, url, false); + if (proxy != 0 && bypass != 0) { + WinHTTPObj.SetProxy(proxy_settings, proxy, bypass); + } + + if (proxy != 0) { + WinHTTPObj.SetProxy(proxy_settings, proxy); + } + + if (user != 0 && pass != 0) { + WinHTTPObj.SetCredentials(user, pass, HTTPREQUEST_SETCREDENTIALS_FOR_SERVER); + } + + if (proxy_user != 0 && proxy_pass != 0) { + WinHTTPObj.SetCredentials(proxy_user, proxy_pass, HTTPREQUEST_SETCREDENTIALS_FOR_PROXY); + } + + if (certificate != 0) { + WinHTTPObj.SetClientCertificate(certificate); + } + + //set autologin policy + WinHTTPObj.SetAutoLogonPolicy(autologon_policy); + //set timeouts + WinHTTPObj.SetTimeouts(RESOLVE_TIMEOUT, CONNECT_TIMEOUT, SEND_TIMEOUT, RECEIVE_TIMEOUT); + + if (headers.length !== 0) { + WScript.Echo("Sending with headers:"); + for (var i = 0; i < headers.length; i++) { + WinHTTPObj.SetRequestHeader(headers[i][0], headers[i][1]); + WScript.Echo(headers[i][0] + ":" + headers[i][1]); + } + WScript.Echo(""); + } + + if (ua !== "") { + //user-agent option from: + //WinHttpRequestOption enumeration + // other options can be added like bellow + //https://msdn.microsoft.com/en-us/library/windows/desktop/aa384108(v=vs.85).aspx + WinHTTPObj.Option(0) = ua; + } + if (escape) { + WinHTTPObj.Option(3) = true; + } + if (trim(body) === "") { + WinHTTPObj.Send(); + } else { + WinHTTPObj.Send(body); + } + + var status = WinHTTPObj.Status + } catch (err) { + WScript.Echo(err.message); + WScript.Quit(666); + } + + //////////////////////// + // report // + //////////////////////// + + if (reportfile != "") { + + //var report_string=""; + var n = "\r\n"; + var report_string = "Status:" + n; + report_string = report_string + " " + WinHTTPObj.Status; + report_string = report_string + " " + WinHTTPObj.StatusText + n; + report_string = report_string + " " + n; + report_string = report_string + "Response:" + n; + report_string = report_string + WinHTTPObj.ResponseText + n; + report_string = report_string + " " + n; + report_string = report_string + "Headers:" + n; + report_string = report_string + WinHTTPObj.GetAllResponseHeaders() + n; + + WinHttpRequestOption_UserAgentString = 0; // Name of the user agent + WinHttpRequestOption_URL = 1; // Current URL + WinHttpRequestOption_URLCodePage = 2; // Code page + WinHttpRequestOption_EscapePercentInURL = 3; // Convert percents + // in the URL + // rest of the options can be seen and eventually added using this as reference + // https://msdn.microsoft.com/en-us/library/windows/desktop/aa384108(v=vs.85).aspx + + report_string = report_string + "URL:" + n; + report_string = report_string + WinHTTPObj.Option(WinHttpRequestOption_URL) + n; + + report_string = report_string + "URL Code Page:" + n; + report_string = report_string + WinHTTPObj.Option(WinHttpRequestOption_URLCodePage) + n; + + report_string = report_string + "User Agent:" + n; + report_string = report_string + WinHTTPObj.Option(WinHttpRequestOption_UserAgentString) + n; + + report_string = report_string + "Escapped URL:" + n; + report_string = report_string + WinHTTPObj.Option(WinHttpRequestOption_EscapePercentInURL) + n; + + prepareateFile(force, reportfile); + + WScript.Echo("Writing report to " + reportfile); + + writeFile(reportfile, report_string); + + } + + switch (status) { + case 200: + WScript.Echo("Status: 200 OK"); + break; + default: + WScript.Echo("Status: " + status); + WScript.Echo("Status was not OK. More info -> https://en.wikipedia.org/wiki/List_of_HTTP_status_codes"); + } + + //if as binary + if (saveTo.toLowerCase() === "con") { + WScript.Echo(WinHTTPObj.ResponseText); + } + if (saveTo !== "" && saveTo.toLowerCase() !== "con") { + prepareateFile(force, saveTo); + try { + + if (use_stream) { + writeBinFile(saveTo, WinHTTPObj.ResponseStream); + } else { + writeBinFile(saveTo, WinHTTPObj.ResponseBody); + } + + } catch (err) { + WScript.Echo("Failed to save the file as binary.Attempt to save it as text"); + AdoDBObj.Close(); + prepareateFile(true, saveTo); + writeFile(saveTo, WinHTTPObj.ResponseText); + } + } + WScript.Quit(status); +} + +//-- +//----- +//---------- +//---------------------- +//------------------------------- + +function prepareateFile(force, file) { + if (force && existsItem(file)) { + if (!deleteItem(file)) { + WScript.Echo("Unable to delete " + file); + WScript.Quit(8); + } + } else if (existsItem(file)) { + WScript.Echo("Item " + file + " already exist"); + WScript.Quit(9); + } +} + +function writeBinFile(fileName, data) { + AdoDBObj.Type = 1; + AdoDBObj.Open(); + AdoDBObj.Position = 0; + AdoDBObj.Write(data); + AdoDBObj.SaveToFile(fileName, 2); + AdoDBObj.Close(); +} + +function writeFile(fileName, data) { + AdoDBObj.Type = 2; + AdoDBObj.CharSet = "iso-8859-1"; + AdoDBObj.Open(); + AdoDBObj.Position = 0; + AdoDBObj.WriteText(data); + AdoDBObj.SaveToFile(fileName, 2); + AdoDBObj.Close(); +} + + +function readFile(fileName) { + //check existence + try { + if (!FileSystemObj.FileExists(fileName)) { + WScript.Echo("file " + fileName + " does not exist!"); + WScript.Quit(13); + } + if (FileSystemObj.GetFile(fileName).Size === 0) { + return ""; + } + var fileR = FileSystemObj.OpenTextFile(fileName, 1); + var content = fileR.ReadAll(); + fileR.Close(); + return content; + } catch (err) { + WScript.Echo("Error while reading file: " + fileName); + WScript.Echo(err.message); + WScript.Echo("Will return empty string"); + return ""; + } +} + +function readPropFile(fileName) { + //check existence + resultArray = []; + if (!FileSystemObj.FileExists(fileName)) { + WScript.Echo("(headers)file " + fileName + " does not exist!"); + WScript.Quit(15); + } + if (FileSystemObj.GetFile(fileName).Size === 0) { + return resultArray; + } + var fileR = FileSystemObj.OpenTextFile(fileName, 1); + var line = ""; + var k = ""; + var v = ""; + var lineN = 0; + var index = 0; + try { + WScript.Echo("parsing headers form " + fileName + " property file "); + while (!fileR.AtEndOfStream) { + line = fileR.ReadLine(); + lineN++; + index = line.indexOf(":"); + if (line.indexOf("#") === 0 || trim(line) === "") { + continue; + } + if (index === -1 || index === line.length - 1 || index === 0) { + WScript.Echo("Invalid line " + lineN); + WScript.Quit(93); + } + k = trim(line.substring(0, index)); + v = trim(line.substring(index + 1, line.length)); + resultArray.push([k, v]); + } + fileR.Close(); + return resultArray; + } catch (err) { + WScript.Echo("Error while reading headers file: " + fileName); + WScript.Echo(err.message); + WScript.Echo("Will return empty array"); + return resultArray; + } +} + +function trim(str) { + return str.replace(/^\s+/, '').replace(/\s+$/, ''); +} + +function main() { + parseArgs(); + request(url); +} +main(); diff --git a/build_scripts/Windows/build-libs/Makefile b/build_scripts/Windows/build-libs/Makefile index 6ed67ed56..697d4c286 100755 --- a/build_scripts/Windows/build-libs/Makefile +++ b/build_scripts/Windows/build-libs/Makefile @@ -13,12 +13,13 @@ SQLCIPHER_VERSION=2.2.1 LIBMICROHTTPD_VERSION=0.9.59 FFMPEG_VERSION=3.4 RAPIDJSON_VERSION=1.1.0 +XAPIAN_VERSION=1.4.7 DOWNLOAD_PATH?=download BUILD_PATH=build LIBS_PATH?=libs -all: dirs zlib bzip2 miniupnpc openssl speex speexdsp opencv libxml2 libxslt curl sqlcipher libmicrohttpd ffmpeg rapidjson copylibs +all: dirs zlib bzip2 miniupnpc openssl speex speexdsp opencv libxml2 libxslt curl sqlcipher libmicrohttpd ffmpeg rapidjson xapian copylibs download: \ $(DOWNLOAD_PATH)/zlib-$(ZLIB_VERSION).tar.gz \ @@ -35,7 +36,8 @@ download: \ $(DOWNLOAD_PATH)/sqlcipher-$(SQLCIPHER_VERSION).tar.gz \ $(DOWNLOAD_PATH)/libmicrohttpd-$(LIBMICROHTTPD_VERSION).tar.gz \ $(DOWNLOAD_PATH)/ffmpeg-$(FFMPEG_VERSION).tar.gz \ - $(DOWNLOAD_PATH)/rapidjson-$(RAPIDJSON_VERSION).tar.gz + $(DOWNLOAD_PATH)/rapidjson-$(RAPIDJSON_VERSION).tar.gz \ + $(DOWNLOAD_PATH)/xapian-core-$(XAPIAN_VERSION).tar.xz clean: rm -r -f $(BUILD_PATH) @@ -360,6 +362,30 @@ $(BUILD_PATH)/rapidjson-$(RAPIDJSON_VERSION): $(DOWNLOAD_PATH)/rapidjson-$(RAPID rm -r -f rapidjson-$(RAPIDJSON_VERSION) mv $(BUILD_PATH)/rapidjson-$(RAPIDJSON_VERSION).tmp $(BUILD_PATH)/rapidjson-$(RAPIDJSON_VERSION) +xapian: $(BUILD_PATH)/xapian-core-$(XAPIAN_VERSION) + +$(DOWNLOAD_PATH)/xapian-core-$(XAPIAN_VERSION).tar.xz: + wget --no-check-certificate https://oligarchy.co.uk/xapian/$(XAPIAN_VERSION)/xapian-core-$(XAPIAN_VERSION).tar.xz -O $(DOWNLOAD_PATH)/xapian-core-$(XAPIAN_VERSION).tar.xz + +$(BUILD_PATH)/xapian-core-$(XAPIAN_VERSION): $(DOWNLOAD_PATH)/xapian-core-$(XAPIAN_VERSION).tar.xz + # prepare + rm -r -f $(BUILD_PATH)/xapian-core-* + tar xvf $(DOWNLOAD_PATH)/xapian-core-$(XAPIAN_VERSION).tar.xz + # build + #cd xapian-core-$(XAPIAN_VERSION) && ./configure --disable-shared --enable-static --prefix="`pwd`/../$(BUILD_PATH)/xapian-core-$(XAPIAN_VERSION).tmp" + #cd xapian-core-$(XAPIAN_VERSION) && make install + cd xapian-core-$(XAPIAN_VERSION) && ./configure --disable-shared --enable-static + cd xapian-core-$(XAPIAN_VERSION) && make + # copy files + mkdir -p $(BUILD_PATH)/xapian-core-$(XAPIAN_VERSION).tmp/include + cp -r xapian-core-$(XAPIAN_VERSION)/include/* $(BUILD_PATH)/xapian-core-$(XAPIAN_VERSION).tmp/include/ + rm $(BUILD_PATH)/xapian-core-$(XAPIAN_VERSION).tmp/include/Makefile* + mkdir -p $(BUILD_PATH)/xapian-core-$(XAPIAN_VERSION).tmp/lib + cp -r xapian-core-$(XAPIAN_VERSION)/.libs/libxapian.a $(BUILD_PATH)/xapian-core-$(XAPIAN_VERSION).tmp/lib/ + # cleanup + rm -r -f xapian-core-$(XAPIAN_VERSION) + mv $(BUILD_PATH)/xapian-core-$(XAPIAN_VERSION).tmp $(BUILD_PATH)/xapian-core-$(XAPIAN_VERSION) + copylibs: rm -r -f $(LIBS_PATH) ; \ mkdir -p $(LIBS_PATH) ; \ diff --git a/build_scripts/Windows/build-retrotor.bat b/build_scripts/Windows/build-tor.bat similarity index 85% rename from build_scripts/Windows/build-retrotor.bat rename to build_scripts/Windows/build-tor.bat index f00014187..c074d6289 100644 --- a/build_scripts/Windows/build-retrotor.bat +++ b/build_scripts/Windows/build-tor.bat @@ -13,11 +13,11 @@ call "%~dp0build-libs\build-libs.bat" if errorlevel 1 %cecho% error "Failed to build libraries." & exit /B %ERRORLEVEL% %cecho% info "Build %SourceName%" -call "%~dp0build\build.bat" retrotor +call "%~dp0build\build.bat" release tor version autologin plugins if errorlevel 1 %cecho% error "Failed to build %SourceName%." & exit /B %ERRORLEVEL% %cecho% info "Pack %SourceName%" -call "%~dp0build\pack.bat" retrotor +call "%~dp0build\pack.bat" release tor if errorlevel 1 %cecho% error "Failed to pack %SourceName%." & exit /B %ERRORLEVEL% exit /B 0 diff --git a/build_scripts/Windows/build.bat b/build_scripts/Windows/build.bat index 642f21454..dd9d0dddf 100644 --- a/build_scripts/Windows/build.bat +++ b/build_scripts/Windows/build.bat @@ -13,11 +13,11 @@ call "%~dp0build-libs\build-libs.bat" if errorlevel 1 %cecho% error "Failed to build libraries." & exit /B %ERRORLEVEL% %cecho% info "Build %SourceName%" -call "%~dp0build\build.bat" standard +call "%~dp0build\build.bat" release version autologin plugins if errorlevel 1 %cecho% error "Failed to build %SourceName%." & exit /B %ERRORLEVEL% %cecho% info "Pack %SourceName%" -call "%~dp0build\pack.bat" standard +call "%~dp0build\pack.bat" release if errorlevel 1 %cecho% error "Failed to pack %SourceName%." & exit /B %ERRORLEVEL% %cecho% info "Build installer" diff --git a/build_scripts/Windows/build/build-installer.bat b/build_scripts/Windows/build/build-installer.bat index c986adbba..720aae3e4 100644 --- a/build_scripts/Windows/build/build-installer.bat +++ b/build_scripts/Windows/build/build-installer.bat @@ -9,7 +9,7 @@ call "%EnvPath%\env.bat" if errorlevel 1 goto error_env :: Initialize environment -call "%~dp0env.bat" standard +call "%~dp0env.bat" release if errorlevel 2 exit /B 2 if errorlevel 1 goto error_env @@ -29,6 +29,7 @@ set NSIS_PARAM=%NSIS_PARAM% /DQTDIR="%QtPath%\.." set NSIS_PARAM=%NSIS_PARAM% /DMINGWDIR="%MinGWPath%\.." set NSIS_PARAM=%NSIS_PARAM% /DOUTDIR="%RsPackPath%" set NSIS_PARAM=%NSIS_PARAM% /DINSTALLERADD="%RsArchiveAdd%" +set NSIS_PARAM=%NSIS_PARAM% /DEXTERNAL_LIB_DIR="%BuildLibsPath%\libs" :: Scan version from source set RsRevision= diff --git a/build_scripts/Windows/build/build.bat b/build_scripts/Windows/build/build.bat index 3fa8fb49a..86ed635f1 100644 --- a/build_scripts/Windows/build/build.bat +++ b/build_scripts/Windows/build/build.bat @@ -22,6 +22,7 @@ set /P LibsGCCVersion=<"%BuildLibsPath%\libs\gcc-version" if "%LibsGCCVersion%" NEQ "%GCCVersion%" %cecho% error "Please use correct version of external libraries. (gcc %GCCVersion% ^<^> libs %LibsGCCVersion%)." & exit /B 1 :: Check git executable +if "%ParamVersion%"=="0" goto found_git set GitPath= call "%ToolsPath%\find-in-path.bat" GitPath git.exe if "%GitPath%" NEQ "" goto found_git @@ -33,7 +34,7 @@ echo. echo === Version echo. -title Build - %SourceName%%RsType%-%RsBuildConfig% [Version] +title Build - %SourceName%-%RsBuildConfig% [Version] pushd "%SourcePath%\retroshare-gui\src\gui\images" :: Touch resource file @@ -47,10 +48,12 @@ echo. echo === qmake echo. -title Build - %SourceName%%RsType%-%RsBuildConfig% [qmake] +title Build - %SourceName%-%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 +set RS_QMAKE_CONFIG=%RsBuildConfig% +if "%ParamVersion%"=="1" set RS_QMAKE_CONFIG=%RS_QMAKE_CONFIG% version_detail_bash_script +if "%ParamAutologin%"=="1" set RS_QMAKE_CONFIG=%RS_QMAKE_CONFIG% rs_autologin +if "%ParamPlugins%"=="1" set RS_QMAKE_CONFIG=%RS_QMAKE_CONFIG% retroshare_plugins qmake "%SourcePath%\RetroShare.pro" -r -spec win32-g++ "CONFIG+=%RS_QMAKE_CONFIG%" "EXTERNAL_LIB_DIR=%BuildLibsPath%\libs" if errorlevel 1 goto error @@ -59,7 +62,7 @@ echo. echo === make echo. -title Build - %SourceName%%RsType%-%RsBuildConfig% [make] +title Build - %SourceName%-%RsBuildConfig% [make] if exist "%EnvJomExe%" ( "%EnvJomExe%" diff --git a/build_scripts/Windows/build/clean.bat b/build_scripts/Windows/build/clean.bat index d8b725535..e8d5aa7b8 100644 --- a/build_scripts/Windows/build/clean.bat +++ b/build_scripts/Windows/build/clean.bat @@ -7,7 +7,9 @@ call "%~dp0..\env.bat" if errorlevel 1 goto error_env call "%EnvPath%\env.bat" if errorlevel 1 goto error_env + call "%~dp0env.bat" %* +if errorlevel 2 exit /B 2 if errorlevel 1 goto error_env if not exist "%RsBuildPath%" exit /B 0 diff --git a/build_scripts/Windows/build/env.bat b/build_scripts/Windows/build/env.bat index b0c765e03..074c976c3 100644 --- a/build_scripts/Windows/build/env.bat +++ b/build_scripts/Windows/build/env.bat @@ -1,16 +1,52 @@ -if "%~1"=="standard" ( - set RsRetroTor= - set RsType= -) else ( - if "%~1"=="retrotor" ( - set RsRetroTor=1 - set RsType=-tor - ) else ( - echo. - echo Usage: standard^|retrotor - echo. - exit /B 2 +:: Process commandline parameter +set ParamRelease=0 +set ParamDebug=0 +set ParamVersion=0 +set ParamAutologin=0 +set ParamPlugins=0 +set ParamTor=0 + +:parameter_loop +if "%~1" NEQ "" ( + for /f "tokens=1,2 delims==" %%a in ("%~1") do ( + if "%%~a"=="release" ( + set ParamRelease=1 + ) else if "%%~a"=="debug" ( + set ParamDebug=1 + ) else if "%%~a"=="version" ( + set ParamVersion=1 + ) else if "%%~a"=="autologin" ( + set ParamAutologin=1 + ) else if "%%~a"=="plugins" ( + set ParamPlugins=1 + ) else if "%%~a"=="tor" ( + set ParamTor=1 + ) else ( + echo. + echo Unknown parameter %1 + goto :usage + ) ) + shift /1 + goto parameter_loop +) + +if "%ParamRelease%"=="1" ( + if "%ParamDebug%"=="1" ( + echo. + echo Release or Debug? + goto :usage + ) + + set RsBuildConfig=release +) else if "%ParamDebug%"=="1" ( + set RsBuildConfig=debug +) else goto :usage + +if "%ParamTor%"=="1" ( + set RsType=-tor +) else ( + set RsType= ) set BuildPath=%EnvRootPath%\builds @@ -39,8 +75,7 @@ if "%GCCVersion%"=="" %cecho% error "Cannot get gcc version." & exit /B 1 set BuildLibsPath=%EnvRootPath%\build-libs\gcc-%GCCVersion% -set RsBuildConfig=release -set RsBuildPath=%BuildPath%\Qt-%QtVersion%%RsType%-%RsBuildConfig% +set RsBuildPath=%BuildPath%\Qt-%QtVersion%-%RsBuildConfig% set RsDeployPath=%DeployPath%\Qt-%QtVersion%%RsType%-%RsBuildConfig% set RsPackPath=%DeployPath% set RsArchiveAdd= @@ -50,4 +85,21 @@ call "%~dp0env-mod.bat" if errorlevel 1 exit /B %ERRORLEVEL% :no_mod -exit /B 0 \ No newline at end of file +exit /B 0 + +:usage +echo. +echo Usage: release^|debug [version autologin plugins] +echo. +echo Mandatory parameter +echo release^|debug Build release or debug version +echo. +echo Optional parameter (need clean when changed) +echo version Create version information from git +echo autologin Build with autologin +echo plugins Build plugins +echo. +echo Parameter for pack +echo tor Pack tor version +echo. +exit /B 2 diff --git a/build_scripts/Windows/build/git-log.bat b/build_scripts/Windows/build/git-log.bat index 5923397f1..d711ededb 100644 --- a/build_scripts/Windows/build/git-log.bat +++ b/build_scripts/Windows/build/git-log.bat @@ -1,6 +1,3 @@ -:: Usage: -:: call git-log.bat standard|retrotor [no-ask] - @echo off setlocal @@ -13,7 +10,9 @@ call "%~dp0..\env.bat" if errorlevel 1 goto error_env call "%EnvPath%\env.bat" if errorlevel 1 goto error_env -call "%~dp0env.bat" %1 + +call "%~dp0env.bat" %* +if errorlevel 2 exit /B 2 if errorlevel 1 goto error_env :: Check git executable diff --git a/build_scripts/Windows/build/pack.bat b/build_scripts/Windows/build/pack.bat index 8122cc2e0..bd526035c 100644 --- a/build_scripts/Windows/build/pack.bat +++ b/build_scripts/Windows/build/pack.bat @@ -62,8 +62,8 @@ set RsDate= for /f "tokens=2 delims==" %%I in ('wmic os get localdatetime /format:list') do set RsDate=%%I set RsDate=%RsDate:~0,4%%RsDate:~4,2%%RsDate:~6,2% -if "%RsRetroTor%"=="1" ( - :: Check Retrotor +if "%ParamTor%"=="1" ( + :: Check for tor executable if not exist "%EnvDownloadPath%\tor\Tor\tor.exe" ( echo Tor binary not found. Please download Tor Expert Bundle from echo https://www.torproject.org/download/download.html.en @@ -121,7 +121,7 @@ for /D %%D in ("%RsBuildPath%\plugins\*") do ( ) echo copy external binaries -copy "%RootPath%\libs\bin\*.dll" "%RsDeployPath%" %Quite% +copy "%BuildLibsPath%\libs\bin\*.dll" "%RsDeployPath%" %Quite% echo copy dependencies call :copy_dependencies "%RsDeployPath%\retroshare.exe" "%RsDeployPath%" @@ -180,7 +180,7 @@ if exist "%SourcePath%\libresapi\src\webui" ( xcopy /S "%SourcePath%\libresapi\src\webui" "%RsDeployPath%\webui" %Quite% ) -if "%RsRetroTor%"=="1" ( +if "%ParamTor%"=="1" ( echo copy tor echo n | copy /-y "%EnvDownloadPath%\tor\Tor\*.*" "%RsDeployPath%" %Quite% ) @@ -217,13 +217,19 @@ if exist "%~1\%RsBuildConfig%\%~n1.dll" ( goto :EOF :copy_dependencies +set CopyDependenciesCopiedSomething=0 for /F "usebackq" %%A in (`%ToolsPath%\depends.bat list %1`) do ( - if exist "%QtPath%\%%A" ( - copy "%QtPath%\%%A" %2 %Quite% - ) else ( - if exist "%MinGWPath%\%%A" ( - copy "%MinGWPath%\%%A" %2 %Quite% + if not exist "%~2\%%A" ( + if exist "%QtPath%\%%A" ( + set CopyDependenciesCopiedSomething=1 + copy "%QtPath%\%%A" %2 %Quite% + ) else ( + if exist "%MinGWPath%\%%A" ( + set CopyDependenciesCopiedSomething=1 + copy "%MinGWPath%\%%A" %2 %Quite% + ) ) ) ) +if "%CopyDependenciesCopiedSomething%"=="1" goto copy_dependencies goto :EOF diff --git a/build_scripts/Windows/compilingForWindows.txt b/build_scripts/Windows/compilingForWindows.txt deleted file mode 100644 index 963f24107..000000000 --- a/build_scripts/Windows/compilingForWindows.txt +++ /dev/null @@ -1,224 +0,0 @@ - -Compling for Windows. ------------------------------------ -For Version V0.5.0+ we are switching to GPGme libraries. -This documents a clean compilation of V0.5 for Windows. - -Tested on: WinXP July 2009. - -You will need: - * Qt4.5 Development Libraries (from TrollTech) - * MinGw/MinSys full installation (from sourceforge.net) - * Cygwin (for OpenSSL compilation / SVN / Unix Tools) - * OpenSSL standard libraries. - * GPG Windows Install (includes gpg.exe) - * MiniUpnp library - * gpgme Library. - * libgpg-error Library. - - -This compilation is a little tricky as different environments -are needed to compile different libraries. -a) Cygwin: libssl.a libcrypto.a -b) MinGW/MSYS: libgpg-error, libgpgme.a, libretroshare.a, libminiupnp.a -c) Qt/MinGW: Retroshare.exe - - -/***************** Installation of Development Tools **************/ -In this section we install: cygwin, mingw/msys and Qt4.5 - -1) Install Cygwin - a) download the installer and run. - b) be sure to select from the development packages: - * mingw - * svn - * gcc/gdb - * make - links: - http://www.cygwin.org/ - -2) install the MinGW/Msys package. - a) Download MinGW-5.1.4 installer and run. - b) Download MSYS-1.0.11 installer and run. - - links: - http://downloads.sourceforge.net/mingw/MinGW-5.1.4.exe - http://downloads.sourceforge.net/mingw/MSYS-1.0.11.exe - http://www.mingw.org/ - http://sourceforge.net/projects/mingw/files/ - -3) Install Qt4.5 LGPL Version. (Qt SDK 2009.03) - a) Download from website and run. - b) Select all options (including MinGW) - - links: - http://www.qtsoftware.com/downloads - -/***************** Installation of Development Tools **************/ -/******************* Compiling Support Libraries ******************/ - -1) Compile OpenSSL using Cygwin. - a) launch cygwin xterm - b) untar openssl source package. - c) Configure mingw - d) make. - -2) Compile gpg-error - a) Download from gpg - b) load up MinGW/MSYS Bash shell. - c) extract code. - d) configure - e) make - f) make install - - The library will end up in /local/lib - -3) Compile gpgme - a) Download from gpg - b) load up MinGW/MSYS Bash shell. - c) extract code. - d) configure - e) make - f) make install - - The library will end up in /local/lib - - -4) Compile MiniUPnP. - up to release v1.3 now. - links: - http://miniupnp.free.fr/ - http://miniupnp.free.fr/files/ - -5) Install pthreads - - links: - http://sourceware.org/pthreads-win32/ - ftp://sourceware.org/pub/pthreads-win32/pthreads-w32-2-8-0-release.exe - -/******************* Compiling Support Libraries ******************/ -/*********************** Compiling Retroshare *********************/ - -1) Setup Source Code TAR (TODO: Update for windows). - This is useful as it provides a standard structure to work against, - we will update this with the required support libraries soon. - - a) Open MSYS Bash shell, and change to this location. - c:/msys/1.0/home/XXX/retroshare - b) create a working directory under this. - 1) c:/msys/1.0/home/XXX/miniupnpc-1.3 - 2) c:/msys/1.0/home/XXX/pthreads-w32-2-8-0-release - 3) c:/msys/1.0/home/XXX/zlib-1.2.3 - 4) c:/msys/1.0/home/XXX/gpgme-1.1.8 - 5) c:/msys/1.0/home/XXX/libgpg-error-1.7 - c) Install OpenSSL to this directory (get from http://www.slproweb.com/download/Win32OpenSSL-0_9_8k.exe) - 1) c:/msys/1.0/home/XXX/OpenSSL - d) get the latest svn trunk and unzip to (get from http://retroshare.svn.sourceforge.net/viewvc/retroshare/trunk.tar.gz) . - 1) c:/msys/1.0/home/XXX/retroshare - -2) Compile libretroshare - a) change to the libretroshare directory. - 1) cd c:/msys/1.0/home/XXX/retroshare/libretroshare/src - b) modify support directory paths to point at correct locations. - 1) open scripts/config.mk and enable OS = Win # MinGw. - 2) open scripts/config-mingw.mk - 3) disable lines (line 20-29) - 4) enable lines 34-42 and 118-119 - #### Enable this section for compiling with MSYS/MINGW compile - SRC_ROOT=/home/linux - - SSL_DIR=$(SRC_ROOT)/OpenSSL - GPGME_DIR=$(SRC_ROOT)/gpgme-1.1.8 - GPG_ERROR_DIR=$(SRC_ROOT)/libgpg-error-1.7 - - ZLIB_DIR=$(SRC_ROOT)/zlib-1.2.3 - UPNPC_DIR=$(SRC_ROOT)/miniupnpc-1.0 - PTHREADS_DIR=$(SRC_ROOT)/pthreads-w32-2-8-0-release - - ### Enable this for GPGME and GPG ERROR dirs - CFLAGS += -I$(GPGME_DIR)/src - CFLAGS += -I$(GPG_ERROR_DIR)/src - 5) Edit your SRC_ROOT to your /home/xxxx dir - - - c) compile libretroshare - 1) make - -3) Copy all the required support libraries into the library directory: - c:/msys/1.0/home/XXX/lib - - This should include: - - gpg-error / gpgme libraries: - libgpg-error.a - libgpg-error.dll.a - libgpg-error.la - libgpgme.dll.a - libgpgme.la - - openssl libraries: - libcrypto.a - libssl.a - - miniupnpc / pthreads / libz - - libminiupnpc.a - miniupnpc.dll - libpthreadGCE2.a - pthreadGCE2.dll - libz.a - - extra library from cygwin. (renamed from libcrypt32.a) - libcrypt32-cygwin.a - - libretroshare - libretroshare.a - - -4) Compile GUI. - -/*********************** Compiling Retroshare *********************/ -/************************ Running Retroshare **********************/ - -1) Collect Relevant DLL's with Application. - a) make retroshare application directory. - b) copy Retroshare.exe executable into directory. - c) Copy required DLL's into that directory. - These include: - - mingw runtime: - mingwm10.dll - - gpgme/gpg-error: - libgpg-error-0.dll - libgpgme-11.dll - - other support libraries: - miniupnpc.dll - pthreadGCE2.dll - - Qt DLLs: - QtCore4.dll, - QtGui4.dll,... - etc. - - d) You should be able to run Retroshare from this directory now! - -2) Install gpg4win package... for gpg.exe - -3) Create an OpenGPG identity using gpa or Enigmail or other PGP tool. - -4) You should be able to use Retroshare on your PC now. - -/************************ Running Retroshare **********************/ -/******************************** FAQs ****************************/ -Ask and it might be answered! -/******************************** FAQs ****************************/ - -This is obviously a work in progress - -drBob. - - - - - diff --git a/build_scripts/Windows/env/tools/prepare-tools.bat b/build_scripts/Windows/env/tools/prepare-tools.bat index 587327f0e..1846bc591 100644 --- a/build_scripts/Windows/env/tools/prepare-tools.bat +++ b/build_scripts/Windows/env/tools/prepare-tools.bat @@ -53,7 +53,7 @@ if not exist "%EnvToolsPath%\cecho.exe" ( echo Download cecho installation - if not exist "%EnvDownloadPath%\%CEchoInstall%" call "%ToolsPath%\winhttpjs.bat" "%CEchoUrl%" -saveTo "%EnvDownloadPath%\%CEchoInstall%" + if not exist "%EnvDownloadPath%\%CEchoInstall%" call "%ToolsPath%\download-file.bat" "%CEchoUrl%" "%EnvDownloadPath%\%CEchoInstall%" if not exist "%EnvDownloadPath%\%cCEhoInstall%" echo Cannot download cecho installation& goto error echo Unpack cecho diff --git a/build_scripts/Windows/installer/ifexist.nsh b/build_scripts/Windows/installer/ifexist.nsh new file mode 100644 index 000000000..18786f3b3 --- /dev/null +++ b/build_scripts/Windows/installer/ifexist.nsh @@ -0,0 +1,15 @@ +; See http://nsis.sourceforge.net/Check_if_a_file_exists_at_compile_time for documentation +!macro !defineifexist _VAR_NAME _FILE_NAME + !tempfile _TEMPFILE + !ifdef NSIS_WIN32_MAKENSIS + ; Windows - cmd.exe + !system 'if exist "${_FILE_NAME}" echo !define ${_VAR_NAME} > "${_TEMPFILE}"' + !else + ; Posix - sh + !system 'if [ -e "${_FILE_NAME}" ]; then echo "!define ${_VAR_NAME}" > "${_TEMPFILE}"; fi' + !endif + !include '${_TEMPFILE}' + !delfile '${_TEMPFILE}' + !undef _TEMPFILE +!macroend +!define !defineifexist "!insertmacro !defineifexist" \ No newline at end of file diff --git a/build_scripts/Windows/installer/retroshare-Qt4.nsi b/build_scripts/Windows/installer/retroshare-Qt4.nsi index fef0d90e8..971917d4a 100644 --- a/build_scripts/Windows/installer/retroshare-Qt4.nsi +++ b/build_scripts/Windows/installer/retroshare-Qt4.nsi @@ -1,6 +1,8 @@ ; Script generated with the Venis Install Wizard & modified by defnax ; Reworked by Thunder +!include ifexist.nsh + # Needed defines ;!define BUILDADD "" ;!define RELEASEDIR "" @@ -197,9 +199,9 @@ Section $(Section_Main) Section_Main File "${MINGWDIR}\bin\libwinpthread-1.dll" ; External binaries - File "${SOURCEDIR}\..\libs\bin\miniupnpc.dll" - File "${SOURCEDIR}\..\libs\bin\libeay32.dll" - File "${SOURCEDIR}\..\libs\bin\ssleay32.dll" + File "${EXTERNAL_LIB_DIR}\bin\miniupnpc.dll" + File "${EXTERNAL_LIB_DIR}\bin\libeay32.dll" + File "${EXTERNAL_LIB_DIR}\bin\ssleay32.dll" ; Other files File "${SOURCEDIR}\retroshare-gui\src\changelog.txt" @@ -234,17 +236,33 @@ Section $(Section_Main) Section_Main SectionEnd # Plugins -SectionGroup $(Section_Plugins) Section_Plugins -Section $(Section_Plugin_FeedReader) Section_Plugin_FeedReader - SetOutPath "$DataDir\extensions6" - File "${RELEASEDIR}\plugins\FeedReader\release\FeedReader.dll" -SectionEnd +${!defineifexist} PLUGIN_FEEDREADER_EXISTS "${RELEASEDIR}\plugins\FeedReader\release\FeedReader.dll" +${!defineifexist} PLUGIN_VOIP_EXISTS "${RELEASEDIR}\plugins\VOIP\release\VOIP.dll" -Section $(Section_Plugin_VOIP) Section_Plugin_VOIP - SetOutPath "$DataDir\extensions6" - File "${RELEASEDIR}\plugins\VOIP\release\VOIP.dll" -SectionEnd -SectionGroupEnd +!ifdef PLUGIN_FEEDREADER_EXISTS +!define /ifndef PLUGIN_EXISTS +!endif +!ifdef PLUGIN_VOIP_EXISTS +!define /ifndef PLUGIN_EXISTS +!endif + +!ifdef PLUGIN_EXISTS + SectionGroup $(Section_Plugins) Section_Plugins + !ifdef PLUGIN_FEEDREADER_EXISTS + Section $(Section_Plugin_FeedReader) Section_Plugin_FeedReader + SetOutPath "$DataDir\extensions6" + File "${RELEASEDIR}\plugins\FeedReader\release\FeedReader.dll" + SectionEnd + !endif + + !ifdef PLUGIN_VOIP_EXISTS + Section $(Section_Plugin_VOIP) Section_Plugin_VOIP + SetOutPath "$DataDir\extensions6" + File "${RELEASEDIR}\plugins\VOIP\release\VOIP.dll" + SectionEnd + !endif + SectionGroupEnd +!endif # Data (Styles) Section $(Section_Data) Section_Data diff --git a/build_scripts/Windows/installer/retroshare-Qt5.nsi b/build_scripts/Windows/installer/retroshare-Qt5.nsi index 94dae3603..244baf6dc 100644 --- a/build_scripts/Windows/installer/retroshare-Qt5.nsi +++ b/build_scripts/Windows/installer/retroshare-Qt5.nsi @@ -1,6 +1,8 @@ ; Script generated with the Venis Install Wizard & modified by defnax ; Reworked by Thunder +!include ifexist.nsh + # Needed defines ;!define BUILDADD "" ;!define RELEASEDIR "" @@ -212,9 +214,9 @@ Section $(Section_Main) Section_Main File "${MINGWDIR}\bin\libwinpthread-1.dll" ; External binaries - File "${SOURCEDIR}\..\libs\bin\miniupnpc.dll" - File "${SOURCEDIR}\..\libs\bin\libeay32.dll" - File "${SOURCEDIR}\..\libs\bin\ssleay32.dll" + File "${EXTERNAL_LIB_DIR}\bin\miniupnpc.dll" + File "${EXTERNAL_LIB_DIR}\bin\libeay32.dll" + File "${EXTERNAL_LIB_DIR}\bin\ssleay32.dll" ; Other files File "${SOURCEDIR}\retroshare-gui\src\changelog.txt" @@ -256,17 +258,33 @@ Section $(Section_Main) Section_Main SectionEnd # Plugins -SectionGroup $(Section_Plugins) Section_Plugins -Section $(Section_Plugin_FeedReader) Section_Plugin_FeedReader - SetOutPath "$DataDir\extensions6" - File "${RELEASEDIR}\plugins\FeedReader\release\FeedReader.dll" -SectionEnd +${!defineifexist} PLUGIN_FEEDREADER_EXISTS "${RELEASEDIR}\plugins\FeedReader\release\FeedReader.dll" +${!defineifexist} PLUGIN_VOIP_EXISTS "${RELEASEDIR}\plugins\VOIP\release\VOIP.dll" -Section $(Section_Plugin_VOIP) Section_Plugin_VOIP - SetOutPath "$DataDir\extensions6" - File "${RELEASEDIR}\plugins\VOIP\release\VOIP.dll" -SectionEnd -SectionGroupEnd +!ifdef PLUGIN_FEEDREADER_EXISTS +!define /ifndef PLUGIN_EXISTS +!endif +!ifdef PLUGIN_VOIP_EXISTS +!define /ifndef PLUGIN_EXISTS +!endif + +!ifdef PLUGIN_EXISTS + SectionGroup $(Section_Plugins) Section_Plugins + !ifdef PLUGIN_FEEDREADER_EXISTS + Section $(Section_Plugin_FeedReader) Section_Plugin_FeedReader + SetOutPath "$DataDir\extensions6" + File "${RELEASEDIR}\plugins\FeedReader\release\FeedReader.dll" + SectionEnd + !endif + + !ifdef PLUGIN_VOIP_EXISTS + Section $(Section_Plugin_VOIP) Section_Plugin_VOIP + SetOutPath "$DataDir\extensions6" + File "${RELEASEDIR}\plugins\VOIP\release\VOIP.dll" + SectionEnd + !endif + SectionGroupEnd +!endif # Data (Styles) Section $(Section_Data) Section_Data diff --git a/build_scripts/Windows/tools/depends.bat b/build_scripts/Windows/tools/depends.bat index 3f1bb3d08..8238c974c 100644 --- a/build_scripts/Windows/tools/depends.bat +++ b/build_scripts/Windows/tools/depends.bat @@ -1,15 +1,15 @@ :: Usage: :: call depends.bat [list^|missing] file -setlocal - if "%2"=="" ( echo Usage: %~nx0 [list^|missing] File - goto :exit + exit /B 1 ) -if not exist "%EnvDependsExe%" echo depends.exe not found in %EnvToolsPath%.& goto exit -if not exist "%EnvCutExe%" echo cut.exe not found in %EnvToolsPath%.& goto exit +setlocal + +if not exist "%EnvDependsExe%" echo depends.exe not found in %EnvToolsPath%.& exit /B 1 +if not exist "%EnvCutExe%" echo cut.exe not found in %EnvToolsPath%.& exit /B 1 start /wait "" "%EnvDependsExe%" /c /oc:"%~dp0depends.tmp" %2 if "%1"=="missing" ( @@ -33,5 +33,5 @@ if "%1"=="list" ( if exist "%~dp0depends.tmp" del /Q "%~dp0depends.tmp" if exist "%~dp0depends1.tmp" del /Q "%~dp0depends1.tmp" -:exit endlocal +exit /B 0 \ No newline at end of file diff --git a/jsonapi-generator/README.adoc b/jsonapi-generator/README.adoc new file mode 100644 index 000000000..fe3566fa6 --- /dev/null +++ b/jsonapi-generator/README.adoc @@ -0,0 +1,313 @@ +RetroShare JSON API +=================== + +:Cxx: C++ + +== How to use RetroShare JSON API + +Look for methods marked with +@jsonapi+ doxygen custom command into ++libretroshare/src/retroshare+. The method path is composed by service instance +pointer name like +rsGxsChannels+ for +RsGxsChannels+, and the method name like ++createGroup+ and pass the input paramethers as a JSON object. + +.Service instance pointer in rsgxschannels.h +[source,cpp] +-------------------------------------------------------------------------------- +/** + * Pointer to global instance of RsGxsChannels service implementation + * @jsonapi{development} + */ +extern RsGxsChannels* rsGxsChannels; +-------------------------------------------------------------------------------- + +.Method declaration in rsgxschannels.h +[source,cpp] +-------------------------------------------------------------------------------- + /** + * @brief Request channel creation. + * The action is performed asyncronously, so it could fail in a subsequent + * phase even after returning true. + * @jsonapi{development} + * @param[out] token Storage for RsTokenService token to track request + * status. + * @param[in] group Channel data (name, description...) + * @return false on error, true otherwise + */ + virtual bool createGroup(uint32_t& token, RsGxsChannelGroup& group) = 0; +-------------------------------------------------------------------------------- + +.paramethers.json +[source,json] +-------------------------------------------------------------------------------- +{ + "group":{ + "mMeta":{ + "mGroupName":"JSON test group", + "mGroupFlags":4, + "mSignFlags":520 + }, + "mDescription":"JSON test group description" + }, + "caller_data":"Here can go any kind of JSON data (even objects) that the caller want to get back together with the response" +} +-------------------------------------------------------------------------------- + +.Calling the JSON API with curl on the terminal +[source,bash] +-------------------------------------------------------------------------------- +curl -H "Content-Type: application/json" --data @paramethers.json \ + http://127.0.0.1:9092/rsGxsChannels/createGroup +-------------------------------------------------------------------------------- + +.JSON API call result +[source,json] +-------------------------------------------------------------------------------- +{ + "caller_data": "Here can go any kind of JSON data (even objects) that the caller want to get back together with the response", + "retval": true, + "token": 3 +} +-------------------------------------------------------------------------------- + + +== Offer new RetroShare services through JSON API + +To offer a retroshare service through the JSON API, first of all one need find +the global pointer to the service instance and document it in doxygen syntax, +plus marking with the custom doxygen command +@jsonapi{RS_VERSION}+ where ++RS_VERSION+ is the retroshare version in which this service became available +with the current semantic (major changes to the service semantic, changes the +meaning of the service itself, so the version should be updated in the +documentation in that case). + +.Service instance pointer in rsgxschannels.h +[source,cpp] +-------------------------------------------------------------------------------- +/** + * Pointer to global instance of RsGxsChannels service implementation + * @jsonapi{development} + */ +extern RsGxsChannels* rsGxsChannels; +-------------------------------------------------------------------------------- + + +Once the service instance itself is known to the JSON API you need to document +in doxygen syntax and mark with the custom doxygen command ++@jsonapi{RS_VERSION}+ the methods of the service that you want to make +available through JSON API. + +.Offering RsGxsChannels::getChannelDownloadDirectory in rsgxschannels.h +[source,cpp] +-------------------------------------------------------------------------------- + /** + * Get download directory for the given channel + * @jsonapi{development} + * @param[in] channelId id of the channel + * @param[out] directory reference to string where to store the path + * @return false on error, true otherwise + */ + virtual bool getChannelDownloadDirectory( const RsGxsGroupId& channelId, + std::string& directory ) = 0; +-------------------------------------------------------------------------------- + +For each paramether you must specify if it is used as input +@param[in]+ as +output +@param[out]+ or both +@param[inout]+. Paramethers and return value +types must be of a type supported by +RsTypeSerializer+ which already support +most basic types (+bool+, +std::string+...), +RsSerializable+ and containers of +them like +std::vector+. Paramethers passed by value and by +reference of those types are both supported, while passing by pointer is not +supported. If your paramether or return +class+/+struct+ type is not supported +yet by +RsTypeSerializer+ most convenient approach is to make it derive from ++RsSerializable+ and implement +serial_process+ method like I did with ++RsGxsChannelGroup+. + +.Deriving RsGxsChannelGroup from RsSerializable in rsgxschannels.h +[source,cpp] +-------------------------------------------------------------------------------- +struct RsGxsChannelGroup : RsSerializable +{ + RsGroupMetaData mMeta; + std::string mDescription; + RsGxsImage mImage; + + bool mAutoDownload; + + /// @see RsSerializable + virtual void serial_process( RsGenericSerializer::SerializeJob j, + RsGenericSerializer::SerializeContext& ctx ) + { + RS_SERIAL_PROCESS(mMeta); + RS_SERIAL_PROCESS(mDescription); + RS_SERIAL_PROCESS(mImage); + RS_SERIAL_PROCESS(mAutoDownload); + } +}; +-------------------------------------------------------------------------------- + +You can do the same recursively for any member of your +struct+ that is not yet +supported by +RsTypeSerializer+. + +Some Retroshare {Cxx} API functions are asyncronous, historically RetroShare +didn't follow a policy on how to expose asyncronous API so differents services +and some times even differents method of the same service follow differents +asyncronous patterns, thus making automatic generation of JSON API wrappers for +those methods impractical. Instead of dealing with all those differents patterns +I have chosed to support only one new pattern taking advantage of modern {Cxx}11 +and restbed features. On the {Cxx}11 side lambdas and +std::function+s are used, +on the restbed side Server Side Events are used to send asyncronous results. + +Lets see an example so it will be much esier to understand. + +.RsGxsChannels::turtleSearchRequest asyncronous API +[source,cpp] +-------------------------------------------------------------------------------- + /** + * @brief Request remote channels search + * @jsonapi{development} + * @param[in] matchString string to look for in the search + * @param multiCallback function that will be called each time a search + * result is received + * @param[in] maxWait maximum wait time in seconds for search results + * @return false on error, true otherwise + */ + virtual bool turtleSearchRequest( + const std::string& matchString, + const std::function& multiCallback, + std::time_t maxWait = 300 ) = 0; +-------------------------------------------------------------------------------- + ++RsGxsChannels::turtleSearchRequest(...)+ is an asyncronous method because it +send a channel search request on turtle network and then everytime a result is +received from the network +multiCallback+ is called and the result is passed as +parameter. To be supported by the automatic JSON API wrappers generator an +asyncronous method need a parameter of type +std::function+ called ++callback+ if the callback will be called only once or +multiCallback+ if the +callback is expected to be called more then once like in this case. +A second mandatory parameter is +maxWait+ of type +std::time_t+ it indicates the +maximum amount of time in seconds for which the caller is willing to wait for +results, in case the timeout is reached the callback will not be called anymore. + +[IMPORTANT] +================================================================================ ++callback+ and +multiCallback+ parameters documentation must *not* specify ++[in]+, +[out]+, +[inout]+, in Doxygen documentation as this would fool the +automatic wrapper generator, and ultimately break the compilation. +================================================================================ + +.RsFiles::turtleSearchRequest asyncronous JSON API usage example +[source,bash] +-------------------------------------------------------------------------------- +$ cat turtle_search.json +{ + "matchString":"linux" +} +$ curl --data @turtle_search.json http://127.0.0.1:9092/rsFiles/turtleSearchRequest +data: {"retval":true} + +data: {"results":[{"size":157631,"hash":"69709b4d01025584a8def5cd78ebbd1a3cf3fd05","name":"kill_bill_linux_1024x768.jpg"},{"size":192560,"hash":"000000000000000000009a93e5be8486c496f46c","name":"coffee_box_linux2.jpg"},{"size":455087,"hash":"9a93e5be8486c496f46c00000000000000000000","name":"Linux.png"},{"size":182004,"hash":"e8845280912ebf3779e400000000000000000000","name":"Linux_2_6.png"}]} + +data: {"results":[{"size":668,"hash":"e8845280912ebf3779e400000000000000000000","name":"linux.png"},{"size":70,"hash":"e8845280912ebf3779e400000000000000000000","name":"kali-linux-2016.2-amd64.txt.sha1sum"},{"size":3076767744,"hash":"e8845280912ebf3779e400000000000000000000","name":"kali-linux-2016.2-amd64.iso"},{"size":2780872,"hash":"e8845280912ebf3779e400000000000000000000","name":"openwrt-ar71xx-generic-vmlinux.bin"},{"size":917504,"hash":"e8845280912ebf3779e400000000000000000000","name":"openwrt-ar71xx-generic-vmlinux.lzma"},{"size":2278404096,"hash":"e8845280912ebf3779e400000000000000000000","name":"gentoo-linux-livedvd-amd64-multilib-20160704.iso"},{"size":151770333,"hash":"e8845280912ebf3779e400000000000000000000","name":"flashtool-0.9.23.0-linux.tar.7z"},{"size":2847372,"hash":"e8845280912ebf3779e400000000000000000000","name":"openwrt-ar71xx-generic-vmlinux.elf"},{"size":1310720,"hash":"e8845280912ebf3779e400000000000000000000","name":"openwrt-ar71xx-generic-vmlinux.gz"},{"size":987809,"hash":"e8845280912ebf3779e400000000000000000000","name":"openwrt-ar71xx-generic-vmlinux-lzma.elf"}]} + +-------------------------------------------------------------------------------- + +== A bit of history + +=== First writings about this + +The previous attempt of exposing a RetroShare JSON API is called +libresapi+ and +unfortunatley it requires a bunch of boilerplate code when we want to expose +something present in the {Cxx} API in the JSON API. + +As an example here you can see the libresapi that exposes part of the retroshare +chat {Cxx} API and lot of boilerplate code just to convert {Cxx} objects to JSON + +https://github.com/RetroShare/RetroShare/blob/v0.6.4/libresapi/src/api/ChatHandler.cpp#L44 + +To avoid the {Cxx} to JSON and back conversion boilerplate code I have worked out +an extension to our {Cxx} serialization code so it is capable to serialize and +deserialize to JSON you can see it in this pull request + +https://github.com/RetroShare/RetroShare/pull/1155 + +So first step toward having a good API is to take advantage of the fact that RS +is now capable of converting C++ objects from and to JSON. + +The current API is accessible via HTTP and unix socket, there is no +authentication in both of them, so anyone having access to the HTTP server or to +the unix socket can access the API without extra restrictions. +Expecially for the HTTP API this is a big risk because also if the http server +listen on 127.0.0.1 every application on the machine (even rogue javascript +running on your web browser) can access that and for example on android it is +not safe at all (because of that I implemented the unix socket access so at +least in android API was reasonably safe) because of this. + +A second step to improve the API would be to implement some kind of API +authentication mechanism (it would be nice that the mechanism is handled at API +level and not at transport level so we can use it for any API trasport not just +HTTP for example) + +The HTTP server used by libresapi is libmicrohttpd server that is very minimal, +it doesn't provide HTTPS nor modern HTTP goodies, like server notifications, +websockets etc. because the lack of support we have a token polling mechanism in +libresapi to avoid polling for every thing but it is still ugly, so if we can +completely get rid of polling in the API that would be really nice. +I have done a crawl to look for a replacement and briefly looked at + +- https://www.gnu.org/software/libmicrohttpd/ +- http://wolkykim.github.io/libasyncd/ +- https://github.com/corvusoft/restbed +- https://code.facebook.com/posts/1503205539947302/introducing-proxygen-facebook-s-c-http-framework/ +- https://github.com/cmouse/yahttp + +taking in account a few metrics like modern HTTP goodies support, license, +platform support, external dependencies and documentation it seemed to me that +restbed is the more appropriate. + +Another source of boilerplate code into libresapi is the mapping between JSON +API requests and C++ API methods as an example you can look at this + +https://github.com/RetroShare/RetroShare/blob/v0.6.4/libresapi/src/api/ChatHandler.cpp#L158 + +and this + +https://github.com/RetroShare/RetroShare/blob/v0.6.4/libresapi/src/api/ApiServer.cpp#L253 + +The abstract logic of this thing is, when libreasapi get a request like ++/chat/initiate_distant_chat+ then call ++ChatHandler::handleInitiateDistantChatConnexion+ which in turn is just a +wrapper of +RsMsgs::initiateDistantChatConnexion+ all this process is basically +implemented as boilerplate code and would be unnecessary in a smarter design of +the API because almost all the information needed is already present in the +C++ API +libretroshare/src/retroshare+. + +So a third step to improve the JSON API would be to remove this source of +boilerplate code by automatizing the mapping between C++ and JSON API call. + +This may result a little tricky as language parsing or other adevanced things +may be required. + +Hope this dive is useful for you + +Cheers + +G10h4ck + +=== Second writings about this + +I have been investigating a bit more about: +[verse, G10h4ck] +________________________________________________________________________________ +So a third step to improve the JSON API would be to remove this source of +boilerplate code by automatizing the mapping between C++ and JSON API call +________________________________________________________________________________ + +After spending some hours investigating this topic the most reasonable approach +seems to: + +1. Properly document headers in +libretroshare/src/retroshare/+ in doxygen syntax +specifying wihich params are input and/or output (doxygen sysntax for this is ++@param[in/out/inout]+) this will be the API documentation too. + +2. At compile time use doxygen to generate XML description of the headers and use +the XML to generate the JSON api server stub. +http://www.stack.nl/~dimitri/doxygen/manual/customize.html#xmlgenerator + +3. Enjoy diff --git a/jsonapi-generator/src/async-method-wrapper-template.cpp.tmpl b/jsonapi-generator/src/async-method-wrapper-template.cpp.tmpl new file mode 100644 index 000000000..8dd03a505 --- /dev/null +++ b/jsonapi-generator/src/async-method-wrapper-template.cpp.tmpl @@ -0,0 +1,73 @@ +/* + * RetroShare JSON API + * Copyright (C) 2018 Gioacchino Mazzurco + * + * 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 . + */ + +registerHandler("$%apiPath%$", + [$%captureVars%$](const std::shared_ptr session) +{ + const std::multimap headers + { + { "Connection", "keep-alive" }, + { "Content-Type", "text/event-stream" } + }; + session->yield(rb::OK, headers); + + size_t reqSize = session->get_request()->get_header("Content-Length", 0); + session->fetch( reqSize, [$%captureVars%$]( + const std::shared_ptr session, + const rb::Bytes& body ) + { + RsGenericSerializer::SerializeContext cReq( + nullptr, 0, + RsGenericSerializer::SERIALIZATION_FLAG_YIELDING ); + RsJson& jReq(cReq.mJson); + jReq.Parse(reinterpret_cast(body.data()), body.size()); + + RsGenericSerializer::SerializeContext cAns; + RsJson& jAns(cAns.mJson); + + // if caller specified caller_data put it back in the answhere + const char kcd[] = "caller_data"; + if(jReq.HasMember(kcd)) + jAns.AddMember(kcd, jReq[kcd], jAns.GetAllocator()); + +$%paramsDeclaration%$ + +$%inputParamsDeserialization%$ + + $%callbackName%$ = [session]($%callbackParams%$) + { +$%callbackParamsSerialization%$ + + std::stringstream message; + message << "data: " << compactJSON << ctx.mJson << "\n\n"; + session->yield(message.str()); + $%sessionEarlyClose%$ + }; + +$%functionCall%$ + +$%outputParamsSerialization%$ + + // return them to the API caller + std::stringstream message; + message << "data: " << compactJSON << cAns.mJson << "\n\n"; + session->yield(message.str()); + $%sessionDelayedClose%$ + } ); +}); + diff --git a/jsonapi-generator/src/jsonapi-generator-doxygen.conf b/jsonapi-generator/src/jsonapi-generator-doxygen.conf new file mode 100644 index 000000000..d7fbafebb --- /dev/null +++ b/jsonapi-generator/src/jsonapi-generator-doxygen.conf @@ -0,0 +1,229 @@ +DOXYFILE_ENCODING = UTF-8 +PROJECT_NAME = "libretroshare" + +ALIASES += jsonapi{1}="\xmlonly\endxmlonly" + +# If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the +# documentation from any documented member that it re-implements. +# The default value is: YES. + +INHERIT_DOCS = YES + +# If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments +# according to the Markdown format, which allows for more readable +# documentation. See http://daringfireball.net/projects/markdown/ for details. +# The output of markdown processing is further processed by doxygen, so you can +# mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in +# case of backward compatibilities issues. +# The default value is: YES. + +MARKDOWN_SUPPORT = YES + +# When enabled doxygen tries to link words that correspond to documented +# classes, or namespaces to their corresponding documentation. Such a link can +# be prevented in individual cases by putting a % sign in front of the word or +# globally by setting AUTOLINK_SUPPORT to NO. +# The default value is: YES. + +AUTOLINK_SUPPORT = YES + + +# If the EXTRACT_ALL tag is set to YES, doxygen will assume all entities in +# documentation are documented, even if no documentation was available. Private +# class members and static file members will be hidden unless the +# EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES. +# Note: This will also disable the warnings about undocumented members that are +# normally produced when WARNINGS is set to YES. +# The default value is: NO. + +EXTRACT_ALL = YES + + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all +# undocumented members inside documented classes or files. If set to NO these +# members will be included in the various overviews, but no documentation +# section is generated. This option has no effect if EXTRACT_ALL is enabled. +# The default value is: NO. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. If set +# to NO, these classes will be included in the various overviews. This option +# has no effect if EXTRACT_ALL is enabled. +# The default value is: NO. + +HIDE_UNDOC_CLASSES = NO + + +#--------------------------------------------------------------------------- +# Configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag is used to specify the files and/or directories that contain +# documented source files. You may enter file names like myfile.cpp or +# directories like /usr/src/myproject. Separate the files or directories with +# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING +# Note: If this tag is empty the current directory is searched. + +#INPUT = + +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses +# libiconv (or the iconv built into libc) for the transcoding. See the libiconv +# documentation (see: https://www.gnu.org/software/libiconv/) for the list of +# possible encodings. +# The default value is: UTF-8. + +INPUT_ENCODING = UTF-8 + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and +# *.h) to filter out the source-files in the directories. +# +# Note that for custom extensions or not directly supported extensions you also +# need to set EXTENSION_MAPPING for the extension otherwise the files are not +# read by doxygen. +# +# If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp, +# *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, +# *.hh, *.hxx, *.hpp, *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, +# *.m, *.markdown, *.md, *.mm, *.dox, *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, +# *.f, *.for, *.tcl, *.vhd, *.vhdl, *.ucf and *.qsf. + +FILE_PATTERNS = *.c \ + *.cc \ + *.cxx \ + *.cpp \ + *.c++ \ + *.java \ + *.ii \ + *.ixx \ + *.ipp \ + *.i++ \ + *.inl \ + *.idl \ + *.ddl \ + *.odl \ + *.h \ + *.hh \ + *.hxx \ + *.hpp \ + *.h++ \ + *.cs \ + *.d \ + *.php \ + *.php4 \ + *.php5 \ + *.phtml \ + *.inc \ + *.m \ + *.markdown \ + *.md \ + *.mm \ + *.dox \ + *.py \ + *.pyw \ + *.f90 \ + *.f95 \ + *.f03 \ + *.f08 \ + *.f \ + *.for \ + *.tcl \ + *.vhd \ + *.vhdl \ + *.ucf \ + *.qsf + +# The RECURSIVE tag can be used to specify whether or not subdirectories should +# be searched for input files as well. +# The default value is: NO. + +RECURSIVE = YES + +# The EXCLUDE tag can be used to specify files and/or directories that should be +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. +# +# Note that relative paths are relative to the directory from which doxygen is +# run. + +EXCLUDE = + +# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or +# directories that are symbolic links (a Unix file system feature) are excluded +# from the input. +# The default value is: NO. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. +# +# Note that the wildcards are matched against the file with absolute path, so to +# exclude all test directories for example use the pattern */test/* + +EXCLUDE_PATTERNS = + +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, +# AClass::ANamespace, ANamespace::*Test +# +# Note that the wildcards are matched against the file with absolute path, so to +# exclude all test directories use the pattern */test/* + +EXCLUDE_SYMBOLS = + + +#--------------------------------------------------------------------------- +# Configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES, doxygen will generate HTML output +# The default value is: YES. + +GENERATE_HTML = NO + +# If the GENERATE_LATEX tag is set to YES, doxygen will generate LaTeX output. +# The default value is: YES. + +GENERATE_LATEX = NO + +# If the GENERATE_XML tag is set to YES, doxygen will generate an XML file that +# captures the structure of the code including all documentation. +# The default value is: NO. + +GENERATE_XML = YES + + +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- + +# If the ENABLE_PREPROCESSING tag is set to YES, doxygen will evaluate all +# C-preprocessor directives found in the sources and include files. +# The default value is: YES. + +ENABLE_PREPROCESSING = YES + +# If the MACRO_EXPANSION tag is set to YES, doxygen will expand all macro names +# in the source code. If set to NO, only conditional compilation will be +# performed. Macro expansion can be done in a controlled way by setting +# EXPAND_ONLY_PREDEF to YES. +# The default value is: NO. +# This tag requires that the tag ENABLE_PREPROCESSING is set to YES. + +MACRO_EXPANSION = NO + +# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES then +# the macro expansion is limited to the macros specified with the PREDEFINED and +# EXPAND_AS_DEFINED tags. +# The default value is: NO. +# This tag requires that the tag ENABLE_PREPROCESSING is set to YES. + +EXPAND_ONLY_PREDEF = NO + diff --git a/jsonapi-generator/src/jsonapi-generator.cpp b/jsonapi-generator/src/jsonapi-generator.cpp new file mode 100644 index 000000000..4977f850f --- /dev/null +++ b/jsonapi-generator/src/jsonapi-generator.cpp @@ -0,0 +1,364 @@ +/* + * RetroShare JSON API + * Copyright (C) 2018 Gioacchino Mazzurco + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#include +#include +#include +#include +#include +#include + +struct MethodParam +{ + MethodParam() : + in(false), out(false), isMultiCallback(false), isSingleCallback(false){} + + QString type; + QString name; + QString defval; + bool in; + bool out; + bool isMultiCallback; + bool isSingleCallback; +}; + +int main(int argc, char *argv[]) +{ + if(argc != 3) + qFatal("Usage: jsonapi-generator SOURCE_PATH OUTPUT_PATH"); + + QString sourcePath(argv[1]); + QString outputPath(argv[2]); + QString doxPrefix(outputPath+"/xml/"); + + QString wrappersDefFilePath(outputPath + "/jsonapi-wrappers.inl"); + QFile wrappersDefFile(wrappersDefFilePath); + wrappersDefFile.remove(); + if(!wrappersDefFile.open(QIODevice::WriteOnly|QIODevice::Append|QIODevice::Text)) + qFatal(QString("Can't open: " + wrappersDefFilePath).toLatin1().data()); + + QString cppApiIncludesFilePath(outputPath + "/jsonapi-includes.inl"); + QFile cppApiIncludesFile(cppApiIncludesFilePath); + cppApiIncludesFile.remove(); + if(!cppApiIncludesFile.open(QIODevice::WriteOnly|QIODevice::Append|QIODevice::Text)) + qFatal(QString("Can't open: " + cppApiIncludesFilePath).toLatin1().data()); + QSet cppApiIncludesSet; + + QDirIterator it(doxPrefix, QStringList() << "*8h.xml", QDir::Files); + while(it.hasNext()) + { + QDomDocument hDoc; + QString hFilePath(it.next()); + QString parseError; int line, column; + QFile hFile(hFilePath); + if (!hFile.open(QIODevice::ReadOnly) || + !hDoc.setContent(&hFile, &parseError, &line, &column)) + { + qWarning() << "Error parsing:" << hFilePath + << parseError << line << column; + continue; + } + + QFileInfo hfi(hFile); + QString headerFileName(hfi.fileName()); + headerFileName.replace(QString("_8h.xml"), QString(".h")); + + QDomNodeList sectiondefs = hDoc.elementsByTagName("sectiondef"); + for(int j = 0; j < sectiondefs.size(); ++j) + { + QDomElement sectDef = sectiondefs.item(j).toElement(); + + if( sectDef.attributes().namedItem("kind").nodeValue() != "var" + || sectDef.elementsByTagName("jsonapi").isEmpty() ) + continue; + + QString instanceName = + sectDef.elementsByTagName("name").item(0).toElement().text(); + QString typeName = + sectDef.elementsByTagName("ref").item(0).toElement().text(); + QString typeFilePath(doxPrefix); + typeFilePath += sectDef.elementsByTagName("ref").item(0) + .attributes().namedItem("refid").nodeValue(); + typeFilePath += ".xml"; + + QDomDocument typeDoc; + QFile typeFile(typeFilePath); + if ( !typeFile.open(QIODevice::ReadOnly) || + !typeDoc.setContent(&typeFile, &parseError, &line, &column) ) + { + qWarning() << "Error parsing:" << typeFilePath + << parseError << line << column; + continue; + } + + QDomNodeList members = typeDoc.elementsByTagName("member"); + for (int i = 0; i < members.size(); ++i) + { + QDomNode member = members.item(i); + QString refid(member.attributes().namedItem("refid").nodeValue()); + QString methodName(member.firstChildElement("name").toElement().text()); + QString wrapperName(instanceName+methodName+"Wrapper"); + QString defFilePath(doxPrefix + refid.split('_')[0] + ".xml"); + + qDebug() << "Looking for" << typeName << methodName << "into" + << typeFilePath; + + QDomDocument defDoc; + QFile defFile(defFilePath); + if ( !defFile.open(QIODevice::ReadOnly) || + !defDoc.setContent(&defFile, &parseError, &line, &column) ) + { + qWarning() << "Error parsing:" << defFilePath + << parseError << line << column; + continue; + } + + QDomElement memberdef; + QDomNodeList memberdefs = defDoc.elementsByTagName("memberdef"); + for (int k = 0; k < memberdefs.size(); ++k) + { + QDomElement tmpMBD = memberdefs.item(k).toElement(); + QString tmpId = tmpMBD.attributes().namedItem("id").nodeValue(); + QString tmpKind = tmpMBD.attributes().namedItem("kind").nodeValue(); + bool hasJsonApi = !tmpMBD.elementsByTagName("jsonapi").isEmpty(); + if( tmpId == refid && tmpKind == "function" && hasJsonApi ) + { + memberdef = tmpMBD; + break; + } + } + + if(memberdef.isNull()) continue; + + QString apiPath("/" + instanceName + "/" + methodName); + QString retvalType = memberdef.firstChildElement("type").text(); + QMap paramsMap; + QStringList orderedParamNames; + bool hasInput = false; + bool hasOutput = false; + bool hasSingleCallback = false; + bool hasMultiCallback = false; + QString callbackName; + QString callbackParams; + + QDomNodeList params = memberdef.elementsByTagName("param"); + for (int k = 0; k < params.size(); ++k) + { + QDomElement tmpPE = params.item(k).toElement(); + MethodParam tmpParam; + QString& pName(tmpParam.name); + QString& pType(tmpParam.type); + pName = tmpPE.firstChildElement("declname").text(); + QDomElement tmpDefval = tmpPE.firstChildElement("defval"); + if(!tmpDefval.isNull()) tmpParam.defval = tmpDefval.text(); + QDomElement tmpType = tmpPE.firstChildElement("type"); + pType = tmpType.text(); + if(pType.startsWith("const ")) pType.remove(0,6); + if(pType.startsWith("std::function")) + { + if(pType.endsWith('&')) pType.chop(1); + if(pName.startsWith("multiCallback")) + { + tmpParam.isMultiCallback = true; + hasMultiCallback = true; + } + else if(pName.startsWith("callback")) + { + tmpParam.isSingleCallback = true; + hasSingleCallback = true; + } + callbackName = pName; + callbackParams = pType; + } + else + { + pType.replace(QString("&"), QString()); + pType.replace(QString(" "), QString()); + } + paramsMap.insert(tmpParam.name, tmpParam); + orderedParamNames.push_back(tmpParam.name); + } + + QDomNodeList parameternames = memberdef.elementsByTagName("parametername"); + for (int k = 0; k < parameternames.size(); ++k) + { + QDomElement tmpPN = parameternames.item(k).toElement(); + MethodParam& tmpParam = paramsMap[tmpPN.text()]; + QString tmpD = tmpPN.attributes().namedItem("direction").nodeValue(); + if(tmpD.contains("in")) + { + tmpParam.in = true; + hasInput = true; + } + if(tmpD.contains("out")) + { + tmpParam.out = true; + hasOutput = true; + } + } + + QString functionCall("\t\t"); + if(retvalType != "void") + { + functionCall += retvalType + " retval = "; + hasOutput = true; + } + functionCall += instanceName + "->" + methodName + "("; + functionCall += orderedParamNames.join(", ") + ");\n"; + + qDebug() << instanceName << apiPath << retvalType << typeName + << methodName; + for (const QString& pn : orderedParamNames) + { + const MethodParam& mp(paramsMap[pn]); + qDebug() << "\t" << mp.type << mp.name << mp.in << mp.out; + } + + QString inputParamsDeserialization; + if(hasInput) + { + inputParamsDeserialization += + "\t\t{\n" + "\t\t\tRsGenericSerializer::SerializeContext& ctx(cReq);\n" + "\t\t\tRsGenericSerializer::SerializeJob j(RsGenericSerializer::FROM_JSON);\n"; + } + + QString outputParamsSerialization; + if(hasOutput) + { + outputParamsSerialization += + "\t\t{\n" + "\t\t\tRsGenericSerializer::SerializeContext& ctx(cAns);\n" + "\t\t\tRsGenericSerializer::SerializeJob j(RsGenericSerializer::TO_JSON);\n"; + } + + QString paramsDeclaration; + for (const QString& pn : orderedParamNames) + { + const MethodParam& mp(paramsMap[pn]); + paramsDeclaration += "\t\t" + mp.type + " " + mp.name; + if(!mp.defval.isEmpty()) + paramsDeclaration += "(" + mp.defval + ")"; + paramsDeclaration += ";\n"; + if(mp.in) + inputParamsDeserialization += "\t\t\tRS_SERIAL_PROCESS(" + + mp.name + ");\n"; + if(mp.out) + outputParamsSerialization += "\t\t\tRS_SERIAL_PROCESS(" + + mp.name + ");\n"; + } + + if(hasInput) inputParamsDeserialization += "\t\t}\n"; + if(retvalType != "void") + outputParamsSerialization += + "\t\t\tRS_SERIAL_PROCESS(retval);\n"; + if(hasOutput) outputParamsSerialization += "\t\t}\n"; + + QString captureVars; + + QString sessionEarlyClose; + if(hasSingleCallback) + sessionEarlyClose = "session->close();"; + + QString sessionDelayedClose; + if(hasMultiCallback) + { + sessionDelayedClose = "mService.schedule( [session](){session->close();}, std::chrono::seconds(maxWait+120) );"; + captureVars = "this"; + } + + QString callbackParamsSerialization; + + if(hasSingleCallback || hasMultiCallback || + ((callbackParams.indexOf('(')+2) < callbackParams.indexOf(')'))) + { + QString& cbs(callbackParamsSerialization); + + callbackParams = callbackParams.split('(')[1]; + callbackParams = callbackParams.split(')')[0]; + + cbs += "\t\t\tRsGenericSerializer::SerializeContext ctx;\n"; + + for (QString cbPar : callbackParams.split(',')) + { + bool isConst(cbPar.startsWith("const ")); + QChar pSep(' '); + bool isRef(cbPar.contains('&')); + if(isRef) pSep = '&'; + int sepIndex = cbPar.lastIndexOf(pSep)+1; + QString cpt(cbPar.mid(0, sepIndex)); + cpt.remove(0,6); + QString cpn(cbPar.mid(sepIndex)); + + cbs += "\t\t\tRsTypeSerializer::serial_process("; + cbs += "RsGenericSerializer::TO_JSON, ctx, "; + if(isConst) + { + cbs += "const_cast<"; + cbs += cpt; + cbs += ">("; + } + cbs += cpn; + if(isConst) cbs += ")"; + cbs += ", \""; + cbs += cpn; + cbs += "\" );\n"; + } + } + + QMap substitutionsMap; + substitutionsMap.insert("paramsDeclaration", paramsDeclaration); + substitutionsMap.insert("inputParamsDeserialization", inputParamsDeserialization); + substitutionsMap.insert("outputParamsSerialization", outputParamsSerialization); + substitutionsMap.insert("wrapperName", wrapperName); + substitutionsMap.insert("headerFileName", headerFileName); + substitutionsMap.insert("functionCall", functionCall); + substitutionsMap.insert("apiPath", apiPath); + substitutionsMap.insert("sessionEarlyClose", sessionEarlyClose); + substitutionsMap.insert("sessionDelayedClose", sessionDelayedClose); + substitutionsMap.insert("captureVars", captureVars); + substitutionsMap.insert("callbackName", callbackName); + substitutionsMap.insert("callbackParams", callbackParams); + substitutionsMap.insert("callbackParamsSerialization", callbackParamsSerialization); + + QString templFilePath(sourcePath); + if(hasMultiCallback || hasSingleCallback) + templFilePath.append("/async-method-wrapper-template.cpp.tmpl"); + else templFilePath.append("/method-wrapper-template.cpp.tmpl"); + + QFile templFile(templFilePath); + templFile.open(QIODevice::ReadOnly); + QString wrapperDef(templFile.readAll()); + + QMap::iterator it; + for ( it = substitutionsMap.begin(); + it != substitutionsMap.end(); ++it ) + wrapperDef.replace(QString("$%"+it.key()+"%$"), QString(it.value()), Qt::CaseSensitive); + + wrappersDefFile.write(wrapperDef.toLocal8Bit()); + + cppApiIncludesSet.insert("#include \"retroshare/" + headerFileName + "\"\n"); + } + } + } + + for(const QString& incl : cppApiIncludesSet) + cppApiIncludesFile.write(incl.toLocal8Bit()); + + return 0; +} diff --git a/jsonapi-generator/src/jsonapi-generator.pro b/jsonapi-generator/src/jsonapi-generator.pro new file mode 100644 index 000000000..c36eeea1d --- /dev/null +++ b/jsonapi-generator/src/jsonapi-generator.pro @@ -0,0 +1,6 @@ +TARGET = jsonapi-generator + +QT *= core xml +QT -= gui + +SOURCES += jsonapi-generator.cpp diff --git a/jsonapi-generator/src/method-wrapper-template.cpp.tmpl b/jsonapi-generator/src/method-wrapper-template.cpp.tmpl new file mode 100644 index 000000000..f9be77d76 --- /dev/null +++ b/jsonapi-generator/src/method-wrapper-template.cpp.tmpl @@ -0,0 +1,64 @@ +/* + * RetroShare JSON API + * Copyright (C) 2018 Gioacchino Mazzurco + * + * 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 . + */ + +registerHandler("$%apiPath%$", + [$%captureVars%$](const std::shared_ptr session) +{ + size_t reqSize = session->get_request()->get_header("Content-Length", 0); + session->fetch( reqSize, []( + const std::shared_ptr session, + const rb::Bytes& body ) + { + RsGenericSerializer::SerializeContext cReq( + nullptr, 0, + RsGenericSerializer::SERIALIZATION_FLAG_YIELDING ); + RsJson& jReq(cReq.mJson); + jReq.Parse(reinterpret_cast(body.data()), body.size()); + + RsGenericSerializer::SerializeContext cAns; + RsJson& jAns(cAns.mJson); + + // if caller specified caller_data put it back in the answhere + const char kcd[] = "caller_data"; + if(jReq.HasMember(kcd)) + jAns.AddMember(kcd, jReq[kcd], jAns.GetAllocator()); + +$%paramsDeclaration%$ + + // deserialize input parameters from JSON +$%inputParamsDeserialization%$ + + // call retroshare C++ API +$%functionCall%$ + + // serialize out parameters and return value to JSON +$%outputParamsSerialization%$ + + // return them to the API caller + std::stringstream ss; + ss << jAns; + std::string&& ans(ss.str()); + const std::multimap headers + { + { "Content-Type", "text/json" }, + { "Content-Length", std::to_string(ans.length()) } + }; + session->close(rb::OK, ans, headers); + } ); +}); + diff --git a/libbitdht/src/bitdht/bdaccount.cc b/libbitdht/src/bitdht/bdaccount.cc index 6246b0241..57de177f7 100644 --- a/libbitdht/src/bitdht/bdaccount.cc +++ b/libbitdht/src/bitdht/bdaccount.cc @@ -1,27 +1,24 @@ -/* - * bitdht/bdaccount.cc - * - * BitDHT: An Flexible DHT library. - * - * Copyright 2011 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 3 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "bitdht@lunamutt.com". - * - */ +/******************************************************************************* + * bitdht/bdaccount.cc * + * * + * BitDHT: An Flexible DHT library. * + * * + * Copyright 2011 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "bitdht/bdaccount.h" diff --git a/libbitdht/src/bitdht/bdaccount.h b/libbitdht/src/bitdht/bdaccount.h index 5e9b6cc61..7116e3ced 100644 --- a/libbitdht/src/bitdht/bdaccount.h +++ b/libbitdht/src/bitdht/bdaccount.h @@ -1,30 +1,27 @@ #ifndef BITDHT_ACCOUNT_H #define BITDHT_ACCOUNT_H -/* - * bitdht/bdaccount.h - * - * BitDHT: An Flexible DHT library. - * - * Copyright 2011 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 3 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "bitdht@lunamutt.com". - * - */ +/******************************************************************************* + * bitdht/bdaccount.h * + * * + * BitDHT: An Flexible DHT library. * + * * + * Copyright 2011 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include #include diff --git a/libbitdht/src/bitdht/bdconnection.cc b/libbitdht/src/bitdht/bdconnection.cc index 90e6afa98..494e076f3 100644 --- a/libbitdht/src/bitdht/bdconnection.cc +++ b/libbitdht/src/bitdht/bdconnection.cc @@ -1,27 +1,24 @@ -/* - * bitdht/bdconnection.cc - * - * BitDHT: An Flexible DHT library. - * - * Copyright 2011 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 3 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "bitdht@lunamutt.com". - * - */ +/******************************************************************************* + * bitdht/bdconnection.cc * + * * + * BitDHT: An Flexible DHT library. * + * * + * Copyright 2011 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include #include "bitdht/bdiface.h" diff --git a/libbitdht/src/bitdht/bdconnection.h b/libbitdht/src/bitdht/bdconnection.h index 4453a0bf0..c55d95c09 100644 --- a/libbitdht/src/bitdht/bdconnection.h +++ b/libbitdht/src/bitdht/bdconnection.h @@ -1,32 +1,28 @@ +/******************************************************************************* + * bitdht/bdconnection.h * + * * + * BitDHT: An Flexible DHT library. * + * * + * Copyright 2011 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ + #ifndef BITDHT_CONNECTION_H #define BITDHT_CONNECTION_H -/* - * bitdht/bdconnection.h - * - * BitDHT: An Flexible DHT library. - * - * Copyright 2011 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 3 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "bitdht@lunamutt.com". - * - */ - - #include "bitdht/bdiface.h" class bdQueryManager; diff --git a/libbitdht/src/bitdht/bdfilter.cc b/libbitdht/src/bitdht/bdfilter.cc index 5be9e1178..1ba7d3aca 100644 --- a/libbitdht/src/bitdht/bdfilter.cc +++ b/libbitdht/src/bitdht/bdfilter.cc @@ -1,29 +1,24 @@ - -/* - * bitdht/bdfilter.cc - * - * BitDHT: An Flexible DHT library. - * - * Copyright 2010 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 3 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "bitdht@lunamutt.com". - * - */ - +/******************************************************************************* + * bitdht/bdfilter.cc * + * * + * BitDHT: An Flexible DHT library. * + * * + * Copyright 2010 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "bitdht/bdfilter.h" #include "bitdht/bdmanager.h" diff --git a/libbitdht/src/bitdht/bdfilter.h b/libbitdht/src/bitdht/bdfilter.h index 7c1d940d3..27d32a7d4 100644 --- a/libbitdht/src/bitdht/bdfilter.h +++ b/libbitdht/src/bitdht/bdfilter.h @@ -1,36 +1,28 @@ +/******************************************************************************* + * bitdht/bdfilter.h * + * * + * BitDHT: An Flexible DHT library. * + * * + * Copyright 2010 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ + #ifndef BITDHT_FILTER_H #define BITDHT_FILTER_H -/* - * bitdht/bdfilter.h - * - * BitDHT: An Flexible DHT library. - * - * Copyright 2010 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 3 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "bitdht@lunamutt.com". - * - */ - -/* This class is used to detect bad and filter them peers - * - */ - - #include "bitdht/bdiface.h" #include diff --git a/libbitdht/src/bitdht/bdfriendlist.cc b/libbitdht/src/bitdht/bdfriendlist.cc index 3bb258c40..487f0a75c 100644 --- a/libbitdht/src/bitdht/bdfriendlist.cc +++ b/libbitdht/src/bitdht/bdfriendlist.cc @@ -1,28 +1,24 @@ - -/* - * bitdht/bdfriendlist.cc - * - * BitDHT: An Flexible DHT library. - * - * Copyright 2011 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 3 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "bitdht@lunamutt.com". - * - */ +/******************************************************************************* + * bitdht/bdfriendlist.cc * + * * + * BitDHT: An Flexible DHT library. * + * * + * Copyright 2010 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "bitdht/bdfriendlist.h" #include "bitdht/bdstddht.h" diff --git a/libbitdht/src/bitdht/bdfriendlist.h b/libbitdht/src/bitdht/bdfriendlist.h index 35cad86bb..a58888ed8 100644 --- a/libbitdht/src/bitdht/bdfriendlist.h +++ b/libbitdht/src/bitdht/bdfriendlist.h @@ -1,31 +1,28 @@ +/******************************************************************************* + * bitdht/bdfriendlist.h * + * * + * BitDHT: An Flexible DHT library. * + * * + * Copyright 2010 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ + #ifndef BITDHT_FRIEND_LIST_H #define BITDHT_FRIEND_LIST_H -/* - * bitdht/bdfriendlist.h - * - * BitDHT: An Flexible DHT library. - * - * Copyright 2011 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 3 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "bitdht@lunamutt.com". - * - */ - /* * This class maintains a list of current friends and friends-of-friends. * It should also be updated when a peer's address has been identified. diff --git a/libbitdht/src/bitdht/bdhash.cc b/libbitdht/src/bitdht/bdhash.cc index 762ca5e1b..5eabd3d95 100644 --- a/libbitdht/src/bitdht/bdhash.cc +++ b/libbitdht/src/bitdht/bdhash.cc @@ -1,28 +1,24 @@ -/* - * bitdht/bdhash.cc - * - * BitDHT: An Flexible DHT library. - * - * Copyright 2010 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 3 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "bitdht@lunamutt.com". - * - */ - +/******************************************************************************* + * bitdht/bdhash.cc * + * * + * BitDHT: An Flexible DHT library. * + * * + * Copyright 2010 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "bitdht/bdhash.h" #include "bitdht/bdstddht.h" diff --git a/libbitdht/src/bitdht/bdhash.h b/libbitdht/src/bitdht/bdhash.h index 10c8fd6e2..680169665 100644 --- a/libbitdht/src/bitdht/bdhash.h +++ b/libbitdht/src/bitdht/bdhash.h @@ -1,31 +1,28 @@ +/******************************************************************************* + * bitdht/bdhash.h * + * * + * BitDHT: An Flexible DHT library. * + * * + * Copyright 2010 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ + #ifndef BITDHT_HASH_SPACE_H #define BITDHT_HASH_SPACE_H -/* - * bitdht/bdhash.h - * - * BitDHT: An Flexible DHT library. - * - * Copyright 2010 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 3 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "bitdht@lunamutt.com". - * - */ - #include "bitdht/bdpeer.h" #include diff --git a/libbitdht/src/bitdht/bdhistory.cc b/libbitdht/src/bitdht/bdhistory.cc index 434ab3333..05bb73fa0 100644 --- a/libbitdht/src/bitdht/bdhistory.cc +++ b/libbitdht/src/bitdht/bdhistory.cc @@ -1,3 +1,24 @@ +/******************************************************************************* + * bitdht/bdhistory.cc * + * * + * BitDHT: An Flexible DHT library. * + * * + * Copyright 2010 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "bitdht/bdhistory.h" diff --git a/libbitdht/src/bitdht/bdhistory.h b/libbitdht/src/bitdht/bdhistory.h index 656d91413..79e420d92 100644 --- a/libbitdht/src/bitdht/bdhistory.h +++ b/libbitdht/src/bitdht/bdhistory.h @@ -1,3 +1,25 @@ +/******************************************************************************* + * bitdht/bdhistory.h * + * * + * BitDHT: An Flexible DHT library. * + * * + * Copyright 2010 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ + #ifndef BITDHT_HISTORY_H #define BITDHT_HISTORY_H diff --git a/libbitdht/src/bitdht/bdiface.h b/libbitdht/src/bitdht/bdiface.h index f6f47126c..4e571ccdb 100644 --- a/libbitdht/src/bitdht/bdiface.h +++ b/libbitdht/src/bitdht/bdiface.h @@ -1,31 +1,27 @@ +/******************************************************************************* + * bitdht/bdiface.h * + * * + * BitDHT: An Flexible DHT library. * + * * + * Copyright 2010 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef BIT_DHT_INTERFACE_H #define BIT_DHT_INTERFACE_H -/* - * bitdht/bdiface.h - * - * BitDHT: An Flexible DHT library. - * - * Copyright 2010 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 3 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "bitdht@lunamutt.com". - * - */ - #include #include #include diff --git a/libbitdht/src/bitdht/bdmanager.cc b/libbitdht/src/bitdht/bdmanager.cc index 52ac66e9a..522b0629f 100644 --- a/libbitdht/src/bitdht/bdmanager.cc +++ b/libbitdht/src/bitdht/bdmanager.cc @@ -1,28 +1,24 @@ -/* - * bitdht/bdmanager.cc - * - * BitDHT: An Flexible DHT library. - * - * Copyright 2010 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 3 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "bitdht@lunamutt.com". - * - */ - +/******************************************************************************* + * bitdht/bdmanager.cc * + * * + * BitDHT: An Flexible DHT library. * + * * + * Copyright 2010 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ /******* * Node Manager. diff --git a/libbitdht/src/bitdht/bdmanager.h b/libbitdht/src/bitdht/bdmanager.h index c494b2bef..1a6a2cebd 100644 --- a/libbitdht/src/bitdht/bdmanager.h +++ b/libbitdht/src/bitdht/bdmanager.h @@ -1,33 +1,27 @@ +/******************************************************************************* + * bitdht/bdmanager.h * + * * + * BitDHT: An Flexible DHT library. * + * * + * Copyright 2010 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef BITDHT_MANAGER_H #define BITDHT_MANAGER_H -/* - * bitdht/bdmanager.h - * - * BitDHT: An Flexible DHT library. - * - * Copyright 2010 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 3 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "bitdht@lunamutt.com". - * - */ - - - /******* * Node Manager. ******/ diff --git a/libbitdht/src/bitdht/bdmsgs.cc b/libbitdht/src/bitdht/bdmsgs.cc index ebaccefcc..1af0c9814 100644 --- a/libbitdht/src/bitdht/bdmsgs.cc +++ b/libbitdht/src/bitdht/bdmsgs.cc @@ -1,27 +1,24 @@ -/* - * bitdht/bdmsgs.cc - * - * BitDHT: An Flexible DHT library. - * - * Copyright 2010 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 3 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "bitdht@lunamutt.com". - * - */ +/******************************************************************************* + * bitdht/bdmsgs.cc * + * * + * BitDHT: An Flexible DHT library. * + * * + * Copyright 2010 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include #include diff --git a/libbitdht/src/bitdht/bdmsgs.h b/libbitdht/src/bitdht/bdmsgs.h index ea7b8a3a1..99a26d76a 100644 --- a/libbitdht/src/bitdht/bdmsgs.h +++ b/libbitdht/src/bitdht/bdmsgs.h @@ -1,32 +1,27 @@ +/******************************************************************************* + * bitdht/bdmsgs.h * + * * + * BitDHT: An Flexible DHT library. * + * * + * Copyright 2010 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef BITDHT_MSGS_H #define BITDHT_MSGS_H -/* - * bitdht/bdmsgs.h - * - * BitDHT: An Flexible DHT library. - * - * Copyright 2010 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 3 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "bitdht@lunamutt.com". - * - */ - - #include #include #include diff --git a/libbitdht/src/bitdht/bdnode.cc b/libbitdht/src/bitdht/bdnode.cc index 95d1d1c7e..aec11fe11 100644 --- a/libbitdht/src/bitdht/bdnode.cc +++ b/libbitdht/src/bitdht/bdnode.cc @@ -1,27 +1,24 @@ -/* - * bitdht/bdnode.cc - * - * BitDHT: An Flexible DHT library. - * - * Copyright 2010-2011 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 3 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "bitdht@lunamutt.com". - * - */ +/******************************************************************************* + * bitdht/bdnode.cc * + * * + * BitDHT: An Flexible DHT library. * + * * + * Copyright 2010 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "bitdht/bdnode.h" diff --git a/libbitdht/src/bitdht/bdnode.h b/libbitdht/src/bitdht/bdnode.h index 5acb1255b..ad1ffe2fb 100644 --- a/libbitdht/src/bitdht/bdnode.h +++ b/libbitdht/src/bitdht/bdnode.h @@ -1,32 +1,27 @@ +/******************************************************************************* + * bitdht/bdnode.h * + * * + * BitDHT: An Flexible DHT library. * + * * + * Copyright 2010 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef BITDHT_NODE_H #define BITDHT_NODE_H -/* - * bitdht/bdnode.h - * - * BitDHT: An Flexible DHT library. - * - * Copyright 2010 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 3 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "bitdht@lunamutt.com". - * - */ - - #include "bitdht/bdpeer.h" #include "bitdht/bdquery.h" #include "bitdht/bdstore.h" diff --git a/libbitdht/src/bitdht/bdobj.cc b/libbitdht/src/bitdht/bdobj.cc index df22686cc..9832796d2 100644 --- a/libbitdht/src/bitdht/bdobj.cc +++ b/libbitdht/src/bitdht/bdobj.cc @@ -1,28 +1,24 @@ - -/* - * bitdht/bdobj.cc - * - * BitDHT: An Flexible DHT library. - * - * Copyright 2010 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 3 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "bitdht@lunamutt.com". - * - */ +/******************************************************************************* + * bitdht/bdobj.cc * + * * + * BitDHT: An Flexible DHT library. * + * * + * Copyright 2010 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "bitdht/bdobj.h" diff --git a/libbitdht/src/bitdht/bdobj.h b/libbitdht/src/bitdht/bdobj.h index dbc8b5385..d193c59a8 100644 --- a/libbitdht/src/bitdht/bdobj.h +++ b/libbitdht/src/bitdht/bdobj.h @@ -1,32 +1,27 @@ +/******************************************************************************* + * bitdht/bdobj.h * + * * + * BitDHT: An Flexible DHT library. * + * * + * Copyright 2010 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef BITDHT_OBJECTS_H #define BITDHT_OBJECTS_H -/* - * bitdht/bdobj.h - * - * BitDHT: An Flexible DHT library. - * - * Copyright 2010 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 3 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "bitdht@lunamutt.com". - * - */ - - #define BITDHT_TOKEN_MAX_LEN 20 #include diff --git a/libbitdht/src/bitdht/bdpeer.cc b/libbitdht/src/bitdht/bdpeer.cc index 295ca083d..65cfb31b5 100644 --- a/libbitdht/src/bitdht/bdpeer.cc +++ b/libbitdht/src/bitdht/bdpeer.cc @@ -1,28 +1,24 @@ -/* - * bitdht/bdpeer.cc - * - * BitDHT: An Flexible DHT library. - * - * Copyright 2010 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 3 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "bitdht@lunamutt.com". - * - */ - +/******************************************************************************* + * bitdht/bdpeer.cc * + * * + * BitDHT: An Flexible DHT library. * + * * + * Copyright 2010 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "bitdht/bdpeer.h" #include "util/bdnet.h" diff --git a/libbitdht/src/bitdht/bdpeer.h b/libbitdht/src/bitdht/bdpeer.h index 59175c531..d663a7ecd 100644 --- a/libbitdht/src/bitdht/bdpeer.h +++ b/libbitdht/src/bitdht/bdpeer.h @@ -1,31 +1,27 @@ +/******************************************************************************* + * bitdht/bdpeer.h * + * * + * BitDHT: An Flexible DHT library. * + * * + * Copyright 2010 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef BITDHT_PEER_H #define BITDHT_PEER_H -/* - * bitdht/bdpeer.h - * - * BitDHT: An Flexible DHT library. - * - * Copyright 2010 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 3 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "bitdht@lunamutt.com". - * - */ - #include "bitdht/bdiface.h" #include diff --git a/libbitdht/src/bitdht/bdquery.cc b/libbitdht/src/bitdht/bdquery.cc index e93000a84..f9b77002d 100644 --- a/libbitdht/src/bitdht/bdquery.cc +++ b/libbitdht/src/bitdht/bdquery.cc @@ -1,29 +1,24 @@ - -/* - * bitdht/bdquery.cc - * - * BitDHT: An Flexible DHT library. - * - * Copyright 2010 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 3 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "bitdht@lunamutt.com". - * - */ - +/******************************************************************************* + * bitdht/bdquery.cc * + * * + * BitDHT: An Flexible DHT library. * + * * + * Copyright 2010 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "bitdht/bdquery.h" #include "bitdht/bdstddht.h" diff --git a/libbitdht/src/bitdht/bdquery.h b/libbitdht/src/bitdht/bdquery.h index 2c17ae1d5..4cb08f165 100644 --- a/libbitdht/src/bitdht/bdquery.h +++ b/libbitdht/src/bitdht/bdquery.h @@ -1,32 +1,27 @@ +/******************************************************************************* + * bitdht/bdquery.h * + * * + * BitDHT: An Flexible DHT library. * + * * + * Copyright 2010 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef BITDHT_QUERY_H #define BITDHT_QUERY_H -/* - * bitdht/bdquery.h - * - * BitDHT: An Flexible DHT library. - * - * Copyright 2010 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 3 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "bitdht@lunamutt.com". - * - */ - - #include "bitdht/bdiface.h" #include "bitdht/bdpeer.h" #include "bitdht/bdobj.h" diff --git a/libbitdht/src/bitdht/bdquerymgr.cc b/libbitdht/src/bitdht/bdquerymgr.cc index d920d1283..70f58ce90 100644 --- a/libbitdht/src/bitdht/bdquerymgr.cc +++ b/libbitdht/src/bitdht/bdquerymgr.cc @@ -1,27 +1,24 @@ -/* - * bitdht/bdnode.cc - * - * BitDHT: An Flexible DHT library. - * - * Copyright 2010 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 3 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "bitdht@lunamutt.com". - * - */ +/******************************************************************************* + * bitdht/bdquerymgr.cc * + * * + * BitDHT: An Flexible DHT library. * + * * + * Copyright 2011 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "bitdht/bdquerymgr.h" #include "bitdht/bdnode.h" diff --git a/libbitdht/src/bitdht/bdquerymgr.h b/libbitdht/src/bitdht/bdquerymgr.h index 042fbec41..355781244 100644 --- a/libbitdht/src/bitdht/bdquerymgr.h +++ b/libbitdht/src/bitdht/bdquerymgr.h @@ -1,32 +1,27 @@ +/******************************************************************************* + * bitdht/bdquerymgr.h * + * * + * BitDHT: An Flexible DHT library. * + * * + * Copyright 2011 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef BITDHT_QUERY_MANAGER_H #define BITDHT_QUERY_MANAGER_H -/* - * bitdht/bdquerymgr.h - * - * BitDHT: An Flexible DHT library. - * - * Copyright 2011 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 3 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "bitdht@lunamutt.com". - * - */ - - #include "bitdht/bdquery.h" class bdNodePublisher; diff --git a/libbitdht/src/bitdht/bdstddht.cc b/libbitdht/src/bitdht/bdstddht.cc index 3faa85df2..eac5c148e 100644 --- a/libbitdht/src/bitdht/bdstddht.cc +++ b/libbitdht/src/bitdht/bdstddht.cc @@ -1,28 +1,24 @@ -/* - * bitdht/bdstddht.cc - * - * BitDHT: An Flexible DHT library. - * - * Copyright 2010 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 3 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "bitdht@lunamutt.com". - * - */ - +/******************************************************************************* + * bitdht/bdstddht.cc * + * * + * BitDHT: An Flexible DHT library. * + * * + * Copyright 2011 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "bitdht/bdstddht.h" #include "bitdht/bdpeer.h" diff --git a/libbitdht/src/bitdht/bdstddht.h b/libbitdht/src/bitdht/bdstddht.h index 4637cc8f2..d38c19724 100644 --- a/libbitdht/src/bitdht/bdstddht.h +++ b/libbitdht/src/bitdht/bdstddht.h @@ -1,32 +1,27 @@ +/******************************************************************************* + * bitdht/bdstddht.h * + * * + * BitDHT: An Flexible DHT library. * + * * + * Copyright 2011 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef BITDHT_STANDARD_DHT_H #define BITDHT_STANDARD_DHT_H -/* - * bitdht/bdstddht.h - * - * BitDHT: An Flexible DHT library. - * - * Copyright 2010 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 3 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "bitdht@lunamutt.com". - * - */ - - #include "bitdht/bdiface.h" #define BITDHT_STANDARD_BUCKET_SIZE 10 // 20 too many per query? diff --git a/libbitdht/src/bitdht/bdstore.cc b/libbitdht/src/bitdht/bdstore.cc index 3465d71c6..40031abac 100644 --- a/libbitdht/src/bitdht/bdstore.cc +++ b/libbitdht/src/bitdht/bdstore.cc @@ -1,28 +1,24 @@ -/* - * bitdht/bdstore.cc - * - * BitDHT: An Flexible DHT library. - * - * Copyright 2010 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 3 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "bitdht@lunamutt.com". - * - */ - +/******************************************************************************* + * bitdht/bdstore.cc * + * * + * BitDHT: An Flexible DHT library. * + * * + * Copyright 2011 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "bitdht/bdstore.h" #include "util/bdnet.h" diff --git a/libbitdht/src/bitdht/bdstore.h b/libbitdht/src/bitdht/bdstore.h index 627972716..a01f5aa2c 100644 --- a/libbitdht/src/bitdht/bdstore.h +++ b/libbitdht/src/bitdht/bdstore.h @@ -1,32 +1,27 @@ +/******************************************************************************* + * bitdht/bdstore.h * + * * + * BitDHT: An Flexible DHT library. * + * * + * Copyright 2011 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef BITDHT_STORE_H #define BITDHT_STORE_H -/* - * bitdht/bdstore.h - * - * BitDHT: An Flexible DHT library. - * - * Copyright 2010 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 3 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "bitdht@lunamutt.com". - * - */ - - #include #include "bitdht/bdiface.h" #include "bitdht/bdpeer.h" diff --git a/libbitdht/src/bitdht/bencode.c b/libbitdht/src/bitdht/bencode.c index b1f4c2eaf..a496f5bc3 100644 --- a/libbitdht/src/bitdht/bencode.c +++ b/libbitdht/src/bitdht/bencode.c @@ -1,16 +1,25 @@ -/* - * C implementation of a bencode decoder. - * This is the format defined by BitTorrent: - * http://wiki.theory.org/BitTorrentSpecification#bencoding - * - * The only external requirements are a few [standard] function calls and - * the long long type. Any sane system should provide all of these things. - * - * See the bencode.h header file for usage information. - * - * This is released into the public domain. - * Written by Mike Frysinger . - */ +/******************************************************************************* + * bitdht/bdencode.cc * + * * + * BitDHT: An Flexible DHT library. * + * * + * Copyright 2011 by Robert Fernie * + * by Mike Frysinger * + * * + * 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 . * + * * + *******************************************************************************/ /* * This implementation isn't optimized at all as I wrote it to support diff --git a/libbitdht/src/bitdht/bencode.h b/libbitdht/src/bitdht/bencode.h index 211c96542..4e733b66f 100644 --- a/libbitdht/src/bitdht/bencode.h +++ b/libbitdht/src/bitdht/bencode.h @@ -1,14 +1,27 @@ -/* - * C implementation of a bencode decoder. - * This is the format defined by BitTorrent: - * http://wiki.theory.org/BitTorrentSpecification#bencoding - * - * The only external requirements are a few [standard] function calls and - * the long long type. Any sane system should provide all of these things. - * - * This is released into the public domain. - * Written by Mike Frysinger . - */ +/******************************************************************************* + * bitdht/bdencode.h * + * * + * BitDHT: An Flexible DHT library. * + * * + * Copyright 2011 by Robert Fernie * + * by Mike Frysinger * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ +#ifndef _BENCODE_H +#define _BENCODE_H /* USAGE: * - pass the string full of the bencoded data to be_decode() @@ -16,9 +29,6 @@ * - call be_free() on the tree to release resources */ -#ifndef _BENCODE_H -#define _BENCODE_H - #ifdef __cplusplus extern "C" { #endif diff --git a/libbitdht/src/libbitdht.pro b/libbitdht/src/libbitdht.pro index d9e5816c4..e375c5b90 100644 --- a/libbitdht/src/libbitdht.pro +++ b/libbitdht/src/libbitdht.pro @@ -1,3 +1,21 @@ +################################################################################ +# libbitdht.pro # +# Copyright (C) 2018, Retroshare team # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU Affero General Public License as # +# published by the Free Software Foundation, either version 3 of the # +# License, or (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU Affero General Public License for more details. # +# # +# You should have received a copy of the GNU Affero General Public License # +# along with this program. If not, see . # +################################################################################ + !include("../../retroshare.pri"): error("Could not include file ../../retroshare.pri") TEMPLATE = lib diff --git a/libbitdht/src/udp/udpbitdht.cc b/libbitdht/src/udp/udpbitdht.cc index 39c13e182..72357c91f 100644 --- a/libbitdht/src/udp/udpbitdht.cc +++ b/libbitdht/src/udp/udpbitdht.cc @@ -1,28 +1,24 @@ -/* - * bitdht/udpbitdht.cc - * - * BitDHT: An Flexible DHT library. - * - * Copyright 2010 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 3 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "bitdht@lunamutt.com". - * - */ - +/******************************************************************************* + * bitdht/udpbitdht.cc * + * * + * BitDHT: An Flexible DHT library. * + * * + * Copyright 2011 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "udp/udpbitdht.h" #include "bitdht/bdpeer.h" diff --git a/libbitdht/src/udp/udpbitdht.h b/libbitdht/src/udp/udpbitdht.h index f1e167abf..5cbf0622d 100644 --- a/libbitdht/src/udp/udpbitdht.h +++ b/libbitdht/src/udp/udpbitdht.h @@ -1,32 +1,27 @@ +/******************************************************************************* + * udp/udpbitdht.h * + * * + * BitDHT: An Flexible DHT library. * + * * + * Copyright 2011 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef UDP_BIT_DHT_CLASS_H #define UDP_BIT_DHT_CLASS_H -/* - * bitdht/udpbitdht.h - * - * BitDHT: An Flexible DHT library. - * - * Copyright 2010 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 3 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "bitdht@lunamutt.com". - * - */ - - #include #include #include diff --git a/libbitdht/src/udp/udplayer.cc b/libbitdht/src/udp/udplayer.cc index a0cc2324e..1a82c3d81 100644 --- a/libbitdht/src/udp/udplayer.cc +++ b/libbitdht/src/udp/udplayer.cc @@ -1,27 +1,24 @@ -/* - * udp/udplayer.cc - * - * BitDHT: An Flexible DHT library. - * - * Copyright 2004-2010 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 3 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "bitdht@lunamutt.com". - * - */ +/******************************************************************************* + * udp/udplayer.cc * + * * + * BitDHT: An Flexible DHT library. * + * * + * Copyright 2004-2010 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "udp/udplayer.h" #include "util/bdrandom.h" diff --git a/libbitdht/src/udp/udplayer.h b/libbitdht/src/udp/udplayer.h index 8f2551cb0..06e76c647 100644 --- a/libbitdht/src/udp/udplayer.h +++ b/libbitdht/src/udp/udplayer.h @@ -1,31 +1,27 @@ +/******************************************************************************* + * udp/udplayer.h * + * * + * BitDHT: An Flexible DHT library. * + * * + * Copyright 2004-2010 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef BITDHT_UDP_LAYER_H #define BITDHT_UDP_LAYER_H -/* - * udp/udplayer.h - * - * BitDHT: An Flexible DHT library. - * - * Copyright 2004-2010 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 3 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "bitdht@lunamutt.com". - * - */ - #include "util/bdthreads.h" #include "util/bdnet.h" diff --git a/libbitdht/src/udp/udpstack.cc b/libbitdht/src/udp/udpstack.cc index a66f4c6e2..fdf8eb9cf 100644 --- a/libbitdht/src/udp/udpstack.cc +++ b/libbitdht/src/udp/udpstack.cc @@ -1,27 +1,24 @@ -/* - * udp/udpstack.cc - * - * BitDHT: An Flexible DHT library. - * - * Copyright 2010 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 3 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "bitdht@lunamutt.com". - * - */ +/******************************************************************************* + * udp/udpstack.cc * + * * + * BitDHT: An Flexible DHT library. * + * * + * Copyright 2011 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "udp/udpstack.h" diff --git a/libbitdht/src/udp/udpstack.h b/libbitdht/src/udp/udpstack.h index 3f04f0d38..31b8ec324 100644 --- a/libbitdht/src/udp/udpstack.h +++ b/libbitdht/src/udp/udpstack.h @@ -1,32 +1,27 @@ +/******************************************************************************* + * udp/udpstack.h * + * * + * BitDHT: An Flexible DHT library. * + * * + * Copyright 2011 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef BITDHT_UDP_STACK_RECEIVER_H #define BITDHT_UDP_STACK_RECEIVER_H -/* - * udp/udpstack.h - * - * BitDHT: An Flexible DHT library. - * - * Copyright 2010 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 3 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "bitdht@lunamutt.com". - * - */ - - #include "util/bdthreads.h" #include "util/bdnet.h" diff --git a/libbitdht/src/use_libbitdht.pri b/libbitdht/src/use_libbitdht.pri index bbaf1d4d5..a31c0d452 100644 --- a/libbitdht/src/use_libbitdht.pri +++ b/libbitdht/src/use_libbitdht.pri @@ -1,3 +1,21 @@ +################################################################################ +# use_libbitdht.pri # +# Copyright (C) 2018, Retroshare team # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU Lesser 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 Lesser General Public License for more details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with this program. If not, see . # +################################################################################ + DEPENDPATH *= $$system_path($$clean_path($${PWD}/../../libbitdht/src)) INCLUDEPATH *= $$system_path($$clean_path($${PWD}/../../libbitdht/src)) LIBS *= -L$$system_path($$clean_path($${OUT_PWD}/../../libbitdht/src/lib/)) -lbitdht diff --git a/libbitdht/src/util/bdbloom.cc b/libbitdht/src/util/bdbloom.cc index 016808ea4..739e2c793 100644 --- a/libbitdht/src/util/bdbloom.cc +++ b/libbitdht/src/util/bdbloom.cc @@ -1,27 +1,24 @@ -/* - * bitdht/bdbloom.cc - * - * BitDHT: An Flexible DHT library. - * - * Copyright 2011 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 3 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "bitdht@lunamutt.com". - * - */ +/******************************************************************************* + * util/bdbloom.cc * + * * + * BitDHT: An Flexible DHT library. * + * * + * Copyright 2011 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "util/bdbloom.h" #include "util/bdstring.h" diff --git a/libbitdht/src/util/bdbloom.h b/libbitdht/src/util/bdbloom.h index 91257514e..8ffd13f1e 100644 --- a/libbitdht/src/util/bdbloom.h +++ b/libbitdht/src/util/bdbloom.h @@ -1,32 +1,27 @@ +/******************************************************************************* + * util/bdbloom.h * + * * + * BitDHT: An Flexible DHT library. * + * * + * Copyright 2011 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef BITDHT_BLOOM_H #define BITDHT_BLOOM_H -/* - * bitdht/bdbloom.h - * - * BitDHT: An Flexible DHT library. - * - * Copyright 2011 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 3 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "bitdht@lunamutt.com". - * - */ - - #include #include diff --git a/libbitdht/src/util/bdfile.cc b/libbitdht/src/util/bdfile.cc index 48db4a232..bcd2eb64b 100644 --- a/libbitdht/src/util/bdfile.cc +++ b/libbitdht/src/util/bdfile.cc @@ -1,3 +1,24 @@ +/******************************************************************************* + * util/bdfile.cc * + * * + * BitDHT: An Flexible DHT library. * + * * + * Copyright 2011 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifdef WIN32 #include #endif diff --git a/libbitdht/src/util/bdfile.h b/libbitdht/src/util/bdfile.h index c3d5444d7..5228f986a 100644 --- a/libbitdht/src/util/bdfile.h +++ b/libbitdht/src/util/bdfile.h @@ -1,3 +1,24 @@ +/******************************************************************************* + * util/bdfile.h * + * * + * BitDHT: An Flexible DHT library. * + * * + * Copyright 2011 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once #include diff --git a/libbitdht/src/util/bdnet.cc b/libbitdht/src/util/bdnet.cc index 3bccf0d65..4c5f681a6 100644 --- a/libbitdht/src/util/bdnet.cc +++ b/libbitdht/src/util/bdnet.cc @@ -1,28 +1,24 @@ - -/* - * util/bdnet.cc - * - * BitDHT: An Flexible DHT library. - * - * Copyright 2010 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 3 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "bitdht@lunamutt.com". - * - */ +/******************************************************************************* + * util/bdnet.cc * + * * + * BitDHT: An Flexible DHT library. * + * * + * Copyright 2010 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "bdnet.h" #include "bdstring.h" diff --git a/libbitdht/src/util/bdnet.h b/libbitdht/src/util/bdnet.h index 7e3e24644..639a2ed1a 100644 --- a/libbitdht/src/util/bdnet.h +++ b/libbitdht/src/util/bdnet.h @@ -1,30 +1,26 @@ +/******************************************************************************* + * util/bdnet.h * + * * + * BitDHT: An Flexible DHT library. * + * * + * Copyright 2010 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef BITDHT_UNIVERSAL_NETWORK_HEADER #define BITDHT_UNIVERSAL_NETWORK_HEADER -/* - * - * util/bdnet.h - * - * BitDHT: An Flexible DHT library. - * - * Copyright 2004-2010 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 3 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "bitdht@lunamutt.com". - * - */ #include #include diff --git a/libbitdht/src/util/bdrandom.cc b/libbitdht/src/util/bdrandom.cc index 6288f86b8..93a0352dd 100644 --- a/libbitdht/src/util/bdrandom.cc +++ b/libbitdht/src/util/bdrandom.cc @@ -1,3 +1,24 @@ +/******************************************************************************* + * util/bdrandom.cc * + * * + * BitDHT: An Flexible DHT library. * + * * + * Copyright (C) 2010 Cyril Soler * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include #include #include diff --git a/libbitdht/src/util/bdrandom.h b/libbitdht/src/util/bdrandom.h index 95d70bf13..9ab3f22bd 100644 --- a/libbitdht/src/util/bdrandom.h +++ b/libbitdht/src/util/bdrandom.h @@ -1,39 +1,37 @@ +/******************************************************************************* + * util/bdrandom.h * + * * + * BitDHT: An Flexible DHT library. * + * * + * Copyright (C) 2010 Cyril Soler * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef BITDHT_UTILS_BDRANDOM_H #define BITDHT_UTILS_BDRANDOM_H - -/**************************************************************** - * libbitdht is distributed under the following license: - * - * Copyright (C) 2010 Cyril Soler - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * 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 General Public License for more details. - * - * 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, - * Boston, MA 02110-1301, USA. - ****************************************************************/ - /* This Source Code is basically a direct copy of libretroshare's RsRandom. * the function names have just been renamed. drbob */ - // bdRandom contains a random number generator that is // - thread safe // - system independant // - fast // - NOT CRYPTOGRAPHICALLY SAFE -// - DO NOT USE FOR ANYTHING REQUIRING STRONG RANDOMNESS +// - DO NOT USE FOR ANYTHING REQUIRING STRONG UNPREDICTABLE RANDOMNESS // // The implementation is adapted from the Mersenne Twister page of Wikipedia. // diff --git a/libbitdht/src/util/bdstring.cc b/libbitdht/src/util/bdstring.cc index 07fd4632f..2b9b289f4 100644 --- a/libbitdht/src/util/bdstring.cc +++ b/libbitdht/src/util/bdstring.cc @@ -1,23 +1,24 @@ -/**************************************************************** - * This file is distributed under the following license: - * - * Copyright (c) 2012, RetroShare Team - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * 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 General Public License for more details. - * - * 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, - * Boston, MA 02110-1301, USA. - ****************************************************************/ +/******************************************************************************* + * util/bdstring.h * + * * + * BitDHT: An Flexible DHT library. * + * * + * Copyright (C) 2010 Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "bdstring.h" diff --git a/libbitdht/src/util/bdstring.h b/libbitdht/src/util/bdstring.h index 9c4dc94aa..7bd76892d 100644 --- a/libbitdht/src/util/bdstring.h +++ b/libbitdht/src/util/bdstring.h @@ -1,27 +1,27 @@ +/******************************************************************************* + * util/bdstring.cc * + * * + * BitDHT: An Flexible DHT library. * + * * + * Copyright (C) 2010 Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef BITDHT_UTILS_BDSTRING_H #define BITDHT_UTILS_BDSTRING_H -/**************************************************************** - * libbitdht is distributed under the following license: - * - * Copyright (C) 2012 RetroShare Team - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * 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 General Public License for more details. - * - * 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, - * Boston, MA 02110-1301, USA. - ****************************************************************/ - #ifdef WIN32 // for proper handling of %ll #define bd_snprintf __mingw_snprintf diff --git a/libbitdht/src/util/bdthreads.cc b/libbitdht/src/util/bdthreads.cc index b52d152da..942df305f 100644 --- a/libbitdht/src/util/bdthreads.cc +++ b/libbitdht/src/util/bdthreads.cc @@ -1,29 +1,24 @@ -/* - * util/bdthreads.cc - * - * BitDHT: An Flexible DHT library. - * - * Copyright 2004-2010 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 3 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "bitdht@lunamutt.com". - * - */ - - +/******************************************************************************* + * util/bdthread.cc * + * * + * BitDHT: An Flexible DHT library. * + * * + * Copyright (C) 2004-2010 Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "bdthreads.h" #include /* for usleep() */ diff --git a/libbitdht/src/util/bdthreads.h b/libbitdht/src/util/bdthreads.h index 23350af18..34c48b1bc 100644 --- a/libbitdht/src/util/bdthreads.h +++ b/libbitdht/src/util/bdthreads.h @@ -1,32 +1,27 @@ +/******************************************************************************* + * util/bdthread.cc * + * * + * BitDHT: An Flexible DHT library. * + * * + * Copyright (C) 2004-2010 Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef BITDHT_THREADS_H #define BITDHT_THREADS_H -/* - * util/bdthreads.h - * - * BitDHT: An Flexible DHT library. - * - * Copyright 2004-2010 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 3 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "bitdht@lunamutt.com". - * - */ - - #include #include #include diff --git a/libresapi/src/api/ApiPluginHandler.cpp b/libresapi/src/api/ApiPluginHandler.cpp index fe3211eac..304e8e805 100644 --- a/libresapi/src/api/ApiPluginHandler.cpp +++ b/libresapi/src/api/ApiPluginHandler.cpp @@ -1,3 +1,24 @@ +/******************************************************************************* + * libresapi/api/ApiPluginHandler.cpp * + * * + * LibResAPI: API for local socket server * + * * + * Copyright 2018 by Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "ApiPluginHandler.h" namespace resource_api diff --git a/libresapi/src/api/ApiPluginHandler.h b/libresapi/src/api/ApiPluginHandler.h index ad29922f6..5fa8c8098 100644 --- a/libresapi/src/api/ApiPluginHandler.h +++ b/libresapi/src/api/ApiPluginHandler.h @@ -1,3 +1,24 @@ +/******************************************************************************* + * libresapi/api/ApiPluginHandler.h * + * * + * LibResAPI: API for local socket server * + * * + * Copyright 2018 by Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once #include "ResourceRouter.h" diff --git a/libresapi/src/api/ApiServer.cpp b/libresapi/src/api/ApiServer.cpp index cc78f7eb8..420a8ef05 100644 --- a/libresapi/src/api/ApiServer.cpp +++ b/libresapi/src/api/ApiServer.cpp @@ -1,3 +1,24 @@ +/******************************************************************************* + * libresapi/api/ApiServer.cpp * + * * + * LibResAPI: API for local socket server * + * * + * Copyright 2018 by Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "ApiServer.h" #include diff --git a/libresapi/src/api/ApiServer.h b/libresapi/src/api/ApiServer.h index 807271eb5..6843d39e7 100644 --- a/libresapi/src/api/ApiServer.h +++ b/libresapi/src/api/ApiServer.h @@ -1,3 +1,24 @@ +/******************************************************************************* + * libresapi/api/ApiServer.h * + * * + * LibResAPI: API for local socket server * + * * + * Copyright 2018 by Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once #include diff --git a/libresapi/src/api/ApiServerLocal.cpp b/libresapi/src/api/ApiServerLocal.cpp index e14f85520..e856f2db2 100644 --- a/libresapi/src/api/ApiServerLocal.cpp +++ b/libresapi/src/api/ApiServerLocal.cpp @@ -1,20 +1,24 @@ -/* - * libresapi local socket server - * Copyright (C) 2016 Gioacchino Mazzurco - * - * 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 . - */ +/******************************************************************************* + * libresapi/api/ApiServer.cpp * + * * + * LibResAPI: API for local socket server * + * * + * Copyright 2016 by Gioacchino Mazzurco * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include #include diff --git a/libresapi/src/api/ApiServerLocal.h b/libresapi/src/api/ApiServerLocal.h index 1d6c87ae5..c9ef246b8 100644 --- a/libresapi/src/api/ApiServerLocal.h +++ b/libresapi/src/api/ApiServerLocal.h @@ -1,21 +1,25 @@ +/******************************************************************************* + * libresapi/api/ApiServer.h * + * * + * LibResAPI: API for local socket server * + * * + * Copyright 2016 by Gioacchino Mazzurco * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once -/* - * libresapi local socket server - * Copyright (C) 2016 Gioacchino Mazzurco - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ #include #include diff --git a/libresapi/src/api/ApiServerMHD.cpp b/libresapi/src/api/ApiServerMHD.cpp index 6b77db59a..c14c4ea71 100644 --- a/libresapi/src/api/ApiServerMHD.cpp +++ b/libresapi/src/api/ApiServerMHD.cpp @@ -1,3 +1,24 @@ +/******************************************************************************* + * libresapi/api/ApiServerMHD.cpp * + * * + * LibResAPI: API for local socket server * + * * + * Copyright 2018 by Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "ApiServerMHD.h" #include @@ -73,7 +94,7 @@ namespace resource_api{ std::string getDefaultDocroot() { - return RsAccounts::DataDirectory(false) + "/webui"; + return RsAccounts::systemDataDirectory(false) + "/webui"; } const char* API_ENTRY_PATH = "/api/v2"; diff --git a/libresapi/src/api/ApiServerMHD.h b/libresapi/src/api/ApiServerMHD.h index ec0897c95..9046f0aa7 100644 --- a/libresapi/src/api/ApiServerMHD.h +++ b/libresapi/src/api/ApiServerMHD.h @@ -1,3 +1,24 @@ +/******************************************************************************* + * libresapi/api/ApiServerMHD.h * + * * + * LibResAPI: API for local socket server * + * * + * Copyright 2018 by Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once #include diff --git a/libresapi/src/api/ApiTypes.h b/libresapi/src/api/ApiTypes.h index 6d6d5c746..21e1b2132 100644 --- a/libresapi/src/api/ApiTypes.h +++ b/libresapi/src/api/ApiTypes.h @@ -1,3 +1,24 @@ +/******************************************************************************* + * libresapi/api/ApiTypes.h * + * * + * LibResAPI: API for local socket server * + * * + * Copyright 2018 by Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once #include diff --git a/libresapi/src/api/ChannelsHandler.cpp b/libresapi/src/api/ChannelsHandler.cpp index c79d693b1..01000f7d0 100644 --- a/libresapi/src/api/ChannelsHandler.cpp +++ b/libresapi/src/api/ChannelsHandler.cpp @@ -1,20 +1,24 @@ -/* - * RetroShare JSON API - * Copyright (C) 2018 Gioacchino Mazzurco - * - * 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 . - */ +/******************************************************************************* + * libresapi/api/ChannelsHandler.cpp * + * * + * LibResAPI: API for local socket server * + * * + * Copyright 2018 by Gioacchino Mazzurco * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "ChannelsHandler.h" @@ -71,12 +75,12 @@ void ChannelsHandler::handleListChannels(Request& /*req*/, Response& resp) 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) + while((tChannels.requestStatus(token) != RsTokenService::COMPLETE) + &&(tChannels.requestStatus(token) != RsTokenService::FAILED) &&((time(NULL) < (start+10)))) rstime::rs_usleep(500*1000); std::list grps; - if( tChannels.requestStatus(token) == RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE + if( tChannels.requestStatus(token) == RsTokenService::COMPLETE && mChannels.getGroupSummary(token, grps) ) { for( RsGroupMetaData& grp : grps ) @@ -136,12 +140,12 @@ void ChannelsHandler::handleGetChannelInfo(Request& req, Response& resp) opts, groupIds ); time_t start = time(NULL); - while((tChannels.requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) - &&(tChannels.requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_FAILED) + while((tChannels.requestStatus(token) != RsTokenService::COMPLETE) + &&(tChannels.requestStatus(token) != RsTokenService::FAILED) &&((time(NULL) < (start+10)))) rstime::rs_usleep(500*1000); std::vector grps; - if( tChannels.requestStatus(token) == RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE + if( tChannels.requestStatus(token) == RsTokenService::COMPLETE && mChannels.getGroupData(token, grps) ) { for( RsGxsChannelGroup& grp : grps ) @@ -210,14 +214,14 @@ void ChannelsHandler::handleGetChannelContent(Request& req, Response& resp) } time_t start = time(NULL); - while((mChannels.getTokenService()->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) - &&(mChannels.getTokenService()->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_FAILED) + while((mChannels.getTokenService()->requestStatus(token) != RsTokenService::COMPLETE) + &&(mChannels.getTokenService()->requestStatus(token) != RsTokenService::FAILED) &&((time(NULL) < (start+10)))) rstime::rs_usleep(500*1000); std::vector posts; std::vector comments; if( mChannels.getTokenService()->requestStatus(token) == - RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE && + RsTokenService::COMPLETE && mChannels.getPostData(token, posts, comments) ) { for( std::vector::iterator vit = posts.begin(); @@ -286,11 +290,11 @@ void ChannelsHandler::handleToggleSubscription(Request& req, Response& resp) RsTokenService& tChannels = *mChannels.getTokenService(); time_t start = time(NULL); - while((tChannels.requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) - &&(tChannels.requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_FAILED) + while((tChannels.requestStatus(token) != RsTokenService::COMPLETE) + &&(tChannels.requestStatus(token) != RsTokenService::FAILED) &&((time(NULL) < (start+10)))) rstime::rs_usleep(500*1000); - if(tChannels.requestStatus(token) == RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) + if(tChannels.requestStatus(token) == RsTokenService::COMPLETE) resp.setOk(); else resp.setFail("Unknown GXS error!"); } @@ -353,11 +357,11 @@ void ChannelsHandler::handleCreateChannel(Request& req, Response& resp) RsTokenService& tChannels = *mChannels.getTokenService(); time_t start = time(NULL); - while((tChannels.requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) - &&(tChannels.requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_FAILED) + while((tChannels.requestStatus(token) != RsTokenService::COMPLETE) + &&(tChannels.requestStatus(token) != RsTokenService::FAILED) &&((time(NULL) < (start+10)))) rstime::rs_usleep(500*1000); - if(tChannels.requestStatus(token) == RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) + if(tChannels.requestStatus(token) == RsTokenService::COMPLETE) resp.setOk(); else resp.setFail("Unknown GXS error!"); } @@ -436,11 +440,11 @@ void ChannelsHandler::handleTogglePostRead(Request& req, Response& resp) RsTokenService& tChannels = *mChannels.getTokenService(); time_t start = time(NULL); - while((tChannels.requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) - &&(tChannels.requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_FAILED) + while((tChannels.requestStatus(token) != RsTokenService::COMPLETE) + &&(tChannels.requestStatus(token) != RsTokenService::FAILED) &&((time(NULL) < (start+10)))) rstime::rs_usleep(500*1000); - if(tChannels.requestStatus(token) == RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) + if(tChannels.requestStatus(token) == RsTokenService::COMPLETE) resp.setOk(); else resp.setFail("Unknown GXS error!"); } @@ -522,11 +526,11 @@ void ChannelsHandler::handleCreatePost(Request &req, Response &resp) RsTokenService& tChannels = *mChannels.getTokenService(); time_t start = time(NULL); - while((tChannels.requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) - &&(tChannels.requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_FAILED) + while((tChannels.requestStatus(token) != RsTokenService::COMPLETE) + &&(tChannels.requestStatus(token) != RsTokenService::FAILED) &&((time(NULL) < (start+10)))) rstime::rs_usleep(500*1000); - if(tChannels.requestStatus(token) == RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) + if(tChannels.requestStatus(token) == RsTokenService::COMPLETE) resp.setOk(); else resp.setFail("Unknown GXS error!"); } diff --git a/libresapi/src/api/ChannelsHandler.h b/libresapi/src/api/ChannelsHandler.h index 55c5fec2d..3a731e321 100644 --- a/libresapi/src/api/ChannelsHandler.h +++ b/libresapi/src/api/ChannelsHandler.h @@ -1,21 +1,25 @@ +/******************************************************************************* + * libresapi/api/ChannelsHandler.h * + * * + * LibResAPI: API for local socket server * + * * + * Copyright 2018 by Gioacchino Mazzurco * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once -/* - * RetroShare JSON API - * Copyright (C) 2018 Gioacchino Mazzurco - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ #include "ResourceRouter.h" diff --git a/libresapi/src/api/ChatHandler.cpp b/libresapi/src/api/ChatHandler.cpp index f03df69f9..b7917eb19 100644 --- a/libresapi/src/api/ChatHandler.cpp +++ b/libresapi/src/api/ChatHandler.cpp @@ -1,21 +1,25 @@ -/* - * libresapi - * Copyright (C) 2015 electron128 - * Copyright (C) 2017 Gioacchino Mazzurco - * - * 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 . - */ +/******************************************************************************* + * libresapi/api/ChatHandler.cpp * + * * + * LibResAPI: API for local socket server * + * * + * Copyright 2015 by electron128 * + * Copyright 2017 by Gioacchino Mazzurco * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "ChatHandler.h" #include "Pagination.h" diff --git a/libresapi/src/api/ChatHandler.h b/libresapi/src/api/ChatHandler.h index 4d6104592..d635c02dc 100644 --- a/libresapi/src/api/ChatHandler.h +++ b/libresapi/src/api/ChatHandler.h @@ -1,3 +1,25 @@ +/******************************************************************************* + * libresapi/api/ChatHandler.h * + * * + * LibResAPI: API for local socket server * + * * + * Copyright 2015 by electron128 * + * Copyright 2017 by Gioacchino Mazzurco * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once #include "ResourceRouter.h" diff --git a/libresapi/src/api/FileSearchHandler.cpp b/libresapi/src/api/FileSearchHandler.cpp index 0382005df..c768b1112 100644 --- a/libresapi/src/api/FileSearchHandler.cpp +++ b/libresapi/src/api/FileSearchHandler.cpp @@ -1,3 +1,24 @@ +/******************************************************************************* + * libresapi/api/FileSearchHandler.cpp * + * * + * LibResAPI: API for local socket server * + * * + * Copyright 2018 by Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include #include "FileSearchHandler.h" @@ -29,7 +50,7 @@ FileSearchHandler::~FileSearchHandler() mStateTokenServer->discardToken(mSearchesStateToken); } -void FileSearchHandler::notifyTurtleSearchResult(uint32_t search_id, const std::list& files) +void FileSearchHandler::notifyTurtleSearchResult(const RsPeerId& pid,uint32_t search_id, const std::list& files) { RS_STACK_MUTEX(mMtx); // ********** LOCKED ********** std::map::iterator mit = mSearches.find(search_id); @@ -190,9 +211,9 @@ void FileSearchHandler::handleCreateSearch(Request &req, Response &resp) // i have no idea what the reasons for two different search modes are // rs-gui does it, so do we if(words.size() == 1) - search_id = mTurtle->turtleSearch(words.front()); + search_id = rsFiles->turtleSearch(words.front()); else - search_id = mTurtle->turtleSearch(lin_exp); + search_id = rsFiles->turtleSearch(lin_exp); } std::list results; diff --git a/libresapi/src/api/FileSearchHandler.h b/libresapi/src/api/FileSearchHandler.h index 5832577b5..66b79209c 100644 --- a/libresapi/src/api/FileSearchHandler.h +++ b/libresapi/src/api/FileSearchHandler.h @@ -1,3 +1,24 @@ +/******************************************************************************* + * libresapi/api/FileSearchHandler.h * + * * + * LibResAPI: API for local socket server * + * * + * Copyright 2018 by Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once #include "ResourceRouter.h" #include "StateTokenServer.h" @@ -16,7 +37,7 @@ public: virtual ~FileSearchHandler(); // from NotifyClient - virtual void notifyTurtleSearchResult(uint32_t search_id, const std::list& files); + virtual void notifyTurtleSearchResult(const RsPeerId &pid, uint32_t search_id, const std::list& files); private: void handleWildcard(Request& req, Response& resp); void handleCreateSearch(Request& req, Response& resp); diff --git a/libresapi/src/api/FileSharingHandler.cpp b/libresapi/src/api/FileSharingHandler.cpp index 44c94cfad..5ad9b4601 100644 --- a/libresapi/src/api/FileSharingHandler.cpp +++ b/libresapi/src/api/FileSharingHandler.cpp @@ -1,21 +1,24 @@ -/* - * libresapi - * - * Copyright (C) 2017, Konrad Dębiec - * - * 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 . - */ +/******************************************************************************* + * libresapi/api/FileSharingHandler.cpp * + * * + * LibResAPI: API for local socket server * + * * + * Copyright (C) 2017, Konrad Dębiec * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "FileSharingHandler.h" namespace resource_api diff --git a/libresapi/src/api/FileSharingHandler.h b/libresapi/src/api/FileSharingHandler.h index cd78f338f..887d4b9d3 100644 --- a/libresapi/src/api/FileSharingHandler.h +++ b/libresapi/src/api/FileSharingHandler.h @@ -1,21 +1,24 @@ -/* - * libresapi - * - * Copyright (C) 2017, Konrad Dębiec - * - * 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 . - */ +/******************************************************************************* + * libresapi/api/FileSharingHandler.cpp * + * * + * LibResAPI: API for local socket server * + * * + * Copyright (C) 2017, Konrad Dębiec * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once #include "ResourceRouter.h" diff --git a/libresapi/src/api/ForumHandler.cpp b/libresapi/src/api/ForumHandler.cpp index fa7562691..4180eb023 100644 --- a/libresapi/src/api/ForumHandler.cpp +++ b/libresapi/src/api/ForumHandler.cpp @@ -1,3 +1,24 @@ +/******************************************************************************* + * libresapi/api/ForumHandler.cpp * + * * + * LibResAPI: API for local socket server * + * * + * Copyright 2018 by Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "ForumHandler.h" #include @@ -38,8 +59,8 @@ void ForumHandler::handleWildcard(Request &req, Response &resp) mRsGxsForums->getTokenService()->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, groupIds); time_t start = time(NULL); - while((mRsGxsForums->getTokenService()->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) - &&(mRsGxsForums->getTokenService()->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_FAILED) + while((mRsGxsForums->getTokenService()->requestStatus(token) != RsTokenService::COMPLETE) + &&(mRsGxsForums->getTokenService()->requestStatus(token) != RsTokenService::FAILED) &&((time(NULL) < (start+10))) ) { @@ -50,7 +71,7 @@ void ForumHandler::handleWildcard(Request &req, Response &resp) #endif } - if(mRsGxsForums->getTokenService()->requestStatus(token) == RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) + if(mRsGxsForums->getTokenService()->requestStatus(token) == RsTokenService::COMPLETE) { std::vector grps; ok &= mRsGxsForums->getMsgData(token, grps); @@ -86,8 +107,8 @@ void ForumHandler::handleWildcard(Request &req, Response &resp) mRsGxsForums->getTokenService()->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts); time_t start = time(NULL); - while((mRsGxsForums->getTokenService()->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) - &&(mRsGxsForums->getTokenService()->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_FAILED) + while((mRsGxsForums->getTokenService()->requestStatus(token) != RsTokenService::COMPLETE) + &&(mRsGxsForums->getTokenService()->requestStatus(token) != RsTokenService::FAILED) &&((time(NULL) < (start+10))) ) { @@ -97,7 +118,7 @@ void ForumHandler::handleWildcard(Request &req, Response &resp) usleep(500*1000) ; #endif } - if(mRsGxsForums->getTokenService()->requestStatus(token) == RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) + if(mRsGxsForums->getTokenService()->requestStatus(token) == RsTokenService::COMPLETE) { std::vector grps; ok &= mRsGxsForums->getGroupData(token, grps); diff --git a/libresapi/src/api/ForumHandler.h b/libresapi/src/api/ForumHandler.h index e44b19818..39fa0167f 100644 --- a/libresapi/src/api/ForumHandler.h +++ b/libresapi/src/api/ForumHandler.h @@ -1,3 +1,24 @@ +/******************************************************************************* + * libresapi/api/ForumHandler.h * + * * + * LibResAPI: API for local socket server * + * * + * Copyright 2018 by Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef FORUMHANDLER_H #define FORUMHANDLER_H diff --git a/libresapi/src/api/GetPluginInterfaces.cpp b/libresapi/src/api/GetPluginInterfaces.cpp index f2bac46b0..f2558a469 100644 --- a/libresapi/src/api/GetPluginInterfaces.cpp +++ b/libresapi/src/api/GetPluginInterfaces.cpp @@ -1,3 +1,24 @@ +/******************************************************************************* + * libresapi/api/GetPluginInterfaces.cpp * + * * + * LibResAPI: API for local socket server * + * * + * Copyright 2018 by Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "GetPluginInterfaces.h" #include diff --git a/libresapi/src/api/GetPluginInterfaces.h b/libresapi/src/api/GetPluginInterfaces.h index 73cca040a..c7f92b263 100644 --- a/libresapi/src/api/GetPluginInterfaces.h +++ b/libresapi/src/api/GetPluginInterfaces.h @@ -1,3 +1,24 @@ +/******************************************************************************* + * libresapi/api/GetPluginInterfaces.h * + * * + * LibResAPI: API for local socket server * + * * + * Copyright 2018 by Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once class RsPlugInInterfaces; diff --git a/libresapi/src/api/GxsResponseTask.cpp b/libresapi/src/api/GxsResponseTask.cpp index dcb4ebb51..036a1f60a 100644 --- a/libresapi/src/api/GxsResponseTask.cpp +++ b/libresapi/src/api/GxsResponseTask.cpp @@ -1,3 +1,24 @@ +/******************************************************************************* + * libresapi/api/GxsResponseTask.cpp * + * * + * LibResAPI: API for local socket server * + * * + * Copyright 2018 by Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "GxsResponseTask.h" #include "Operators.h" @@ -21,11 +42,11 @@ bool GxsResponseTask::doWork(Request &req, Response &resp) for(std::vector::iterator vit = mWaitingTokens.begin(); vit != mWaitingTokens.end(); ++vit) { uint8_t status = mTokenService->requestStatus(*vit); - if(status != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) + if(status != RsTokenService::COMPLETE) { ready = false; } - if(status == RsTokenService::GXS_REQUEST_V2_STATUS_FAILED) + if(status == RsTokenService::FAILED) { std::cerr << "GxsResponseTask::doWork() Error: token failed. aborting." << std::endl; resp.setFail("GxsResponseTask::doWork() Error: token failed."); diff --git a/libresapi/src/api/GxsResponseTask.h b/libresapi/src/api/GxsResponseTask.h index 8200b3eee..69e31d38d 100644 --- a/libresapi/src/api/GxsResponseTask.h +++ b/libresapi/src/api/GxsResponseTask.h @@ -1,3 +1,24 @@ +/******************************************************************************* + * libresapi/api/GxsResponseTask.h * + * * + * LibResAPI: API for local socket server * + * * + * Copyright 2018 by Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once #include "ApiTypes.h" diff --git a/libresapi/src/api/IdentityHandler.cpp b/libresapi/src/api/IdentityHandler.cpp index ff5e50a1e..9e7228759 100644 --- a/libresapi/src/api/IdentityHandler.cpp +++ b/libresapi/src/api/IdentityHandler.cpp @@ -1,22 +1,25 @@ -/* - * libresapi - * - * Copyright (C) 2015 electron128 - * Copyright (C) 2017 Gioacchino Mazzurco - * - * 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 . - */ +/******************************************************************************* + * libresapi/api/IdentityHandler.cpp * + * * + * LibResAPI: API for local socket server * + * * + * Copyright (C) 2015 electron128 * + * Copyright (C) 2017 Gioacchino Mazzurco * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "IdentityHandler.h" @@ -220,15 +223,15 @@ void IdentityHandler::handleWildcard(Request & /*req*/, Response &resp) time_t timeout = time(NULL)+10; uint8_t rStatus = mRsIdentity->getTokenService()->requestStatus(token); - while( rStatus != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE && - rStatus != RsTokenService::GXS_REQUEST_V2_STATUS_FAILED && + while( rStatus != RsTokenService::COMPLETE && + rStatus != RsTokenService::FAILED && time(NULL) < timeout ) { usleep(50*1000); rStatus = mRsIdentity->getTokenService()->requestStatus(token); } - if(rStatus == RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) + if(rStatus == RsTokenService::COMPLETE) { std::vector grps; ok &= mRsIdentity->getGroupData(token, grps); @@ -277,15 +280,15 @@ void IdentityHandler::handleNotOwnIdsRequest(Request & /*req*/, Response &resp) time_t timeout = time(NULL)+10; uint8_t rStatus = mRsIdentity->getTokenService()->requestStatus(token); - while( rStatus != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE && - rStatus != RsTokenService::GXS_REQUEST_V2_STATUS_FAILED && + while( rStatus != RsTokenService::COMPLETE && + rStatus != RsTokenService::FAILED && time(NULL) < timeout ) { usleep(50*1000); rStatus = mRsIdentity->getTokenService()->requestStatus(token); } - if(rStatus == RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) + if(rStatus == RsTokenService::COMPLETE) { std::vector grps; ok &= mRsIdentity->getGroupData(token, grps); @@ -327,8 +330,8 @@ void IdentityHandler::handleOwnIdsRequest(Request & /*req*/, Response &resp) mRsIdentity->getTokenService()->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts); time_t start = time(NULL); - while((mRsIdentity->getTokenService()->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) - &&(mRsIdentity->getTokenService()->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_FAILED) + while((mRsIdentity->getTokenService()->requestStatus(token) != RsTokenService::COMPLETE) + &&(mRsIdentity->getTokenService()->requestStatus(token) != RsTokenService::FAILED) &&((time(NULL) < (start+10))) ) { @@ -339,7 +342,7 @@ void IdentityHandler::handleOwnIdsRequest(Request & /*req*/, Response &resp) #endif } - if(mRsIdentity->getTokenService()->requestStatus(token) == RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) + if(mRsIdentity->getTokenService()->requestStatus(token) == RsTokenService::COMPLETE) { std::vector grps; ok &= mRsIdentity->getGroupData(token, grps); @@ -410,8 +413,8 @@ void IdentityHandler::handleGetIdentityDetails(Request& req, Response& resp) mRsIdentity->getTokenService()->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, groupIds); time_t start = time(NULL); - while((mRsIdentity->getTokenService()->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) - &&(mRsIdentity->getTokenService()->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_FAILED) + while((mRsIdentity->getTokenService()->requestStatus(token) != RsTokenService::COMPLETE) + &&(mRsIdentity->getTokenService()->requestStatus(token) != RsTokenService::FAILED) &&((time(NULL) < (start+10))) ) { @@ -545,8 +548,8 @@ void IdentityHandler::handleSetAvatar(Request& req, Response& resp) mRsIdentity->getTokenService()->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, groupIds); time_t start = time(NULL); - while((mRsIdentity->getTokenService()->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) - &&(mRsIdentity->getTokenService()->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_FAILED) + while((mRsIdentity->getTokenService()->requestStatus(token) != RsTokenService::COMPLETE) + &&(mRsIdentity->getTokenService()->requestStatus(token) != RsTokenService::FAILED) &&((time(NULL) < (start+10))) ) { diff --git a/libresapi/src/api/IdentityHandler.h b/libresapi/src/api/IdentityHandler.h index dff974e73..08bc5fbed 100644 --- a/libresapi/src/api/IdentityHandler.h +++ b/libresapi/src/api/IdentityHandler.h @@ -1,23 +1,26 @@ +/******************************************************************************* + * libresapi/api/IdentityHandler.h * + * * + * LibResAPI: API for local socket server * + * * + * Copyright (C) 2015 electron128 * + * Copyright (C) 2017 Gioacchino Mazzurco * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once -/* - * libresapi - * - * Copyright (C) 2015 electron128 - * Copyright (C) 2017 Gioacchino Mazzurco - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ #include #include diff --git a/libresapi/src/api/JsonStream.cpp b/libresapi/src/api/JsonStream.cpp index bbba2f2c8..9802efe2a 100644 --- a/libresapi/src/api/JsonStream.cpp +++ b/libresapi/src/api/JsonStream.cpp @@ -1,3 +1,24 @@ +/******************************************************************************* + * libresapi/api/jsonStream.cpp * + * * + * LibResAPI: API for local socket server * + * * + * Copyright 2018 by Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "JsonStream.h" #include diff --git a/libresapi/src/api/JsonStream.h b/libresapi/src/api/JsonStream.h index 25b7d8f93..720b239d2 100644 --- a/libresapi/src/api/JsonStream.h +++ b/libresapi/src/api/JsonStream.h @@ -1,3 +1,24 @@ +/******************************************************************************* + * libresapi/api/jsonStream.h * + * * + * LibResAPI: API for local socket server * + * * + * Copyright 2018 by Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once #include "ApiTypes.h" diff --git a/libresapi/src/api/LivereloadHandler.cpp b/libresapi/src/api/LivereloadHandler.cpp index 1f433754f..e67cc2327 100644 --- a/libresapi/src/api/LivereloadHandler.cpp +++ b/libresapi/src/api/LivereloadHandler.cpp @@ -1,3 +1,24 @@ +/******************************************************************************* + * libresapi/api/LivereloadHarder.cpp * + * * + * LibResAPI: API for local socket server * + * * + * Copyright 2018 by Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "LivereloadHandler.h" namespace resource_api diff --git a/libresapi/src/api/LivereloadHandler.h b/libresapi/src/api/LivereloadHandler.h index 9d85999e4..e32b206c9 100644 --- a/libresapi/src/api/LivereloadHandler.h +++ b/libresapi/src/api/LivereloadHandler.h @@ -1,3 +1,24 @@ +/******************************************************************************* + * libresapi/api/LivereloadHarder.h * + * * + * LibResAPI: API for local socket server * + * * + * Copyright 2018 by Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once #include "ResourceRouter.h" diff --git a/libresapi/src/api/Operators.cpp b/libresapi/src/api/Operators.cpp index 97dff652d..643b39c7a 100644 --- a/libresapi/src/api/Operators.cpp +++ b/libresapi/src/api/Operators.cpp @@ -1,3 +1,24 @@ +/******************************************************************************* + * libresapi/api/Operators.cpp * + * * + * LibResAPI: API for local socket server * + * * + * Copyright 2018 by Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "Operators.h" namespace resource_api diff --git a/libresapi/src/api/Operators.h b/libresapi/src/api/Operators.h index 06683cb94..92bed4c16 100644 --- a/libresapi/src/api/Operators.h +++ b/libresapi/src/api/Operators.h @@ -1,3 +1,24 @@ +/******************************************************************************* + * libresapi/api/Operators.h * + * * + * LibResAPI: API for local socket server * + * * + * Copyright 2018 by Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once #include diff --git a/libresapi/src/api/PeersHandler.cpp b/libresapi/src/api/PeersHandler.cpp index f812a54f4..71075e849 100644 --- a/libresapi/src/api/PeersHandler.cpp +++ b/libresapi/src/api/PeersHandler.cpp @@ -1,22 +1,25 @@ -/* - * libresapi - * - * Copyright (C) 2015 electron128 - * Copyright (C) 2017 Gioacchino Mazzurco - * - * 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 . - */ +/******************************************************************************* + * libresapi/api/PeersHandler.cpp * + * * + * LibResAPI: API for local socket server * + * * + * Copyright (C) 2015 electron128 * + * Copyright (C) 2017 Gioacchino Mazzurco * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "PeersHandler.h" diff --git a/libresapi/src/api/PeersHandler.h b/libresapi/src/api/PeersHandler.h index d15705602..60b92a797 100644 --- a/libresapi/src/api/PeersHandler.h +++ b/libresapi/src/api/PeersHandler.h @@ -1,23 +1,26 @@ +/******************************************************************************* + * libresapi/api/PeersHandler.h * + * * + * LibResAPI: API for local socket server * + * * + * Copyright (C) 2015 electron128 * + * Copyright (C) 2017 Gioacchino Mazzurco * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once -/* - * libresapi - * - * Copyright (C) 2015 electron128 - * Copyright (C) 2017 Gioacchino Mazzurco - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ #include "ResourceRouter.h" #include "StateTokenServer.h" diff --git a/libresapi/src/api/ResourceRouter.cpp b/libresapi/src/api/ResourceRouter.cpp index 48050cdb6..2c780ec2b 100644 --- a/libresapi/src/api/ResourceRouter.cpp +++ b/libresapi/src/api/ResourceRouter.cpp @@ -1,3 +1,24 @@ +/******************************************************************************* + * libresapi/api/ResourceRouter.cpp * + * * + * LibResAPI: API for local socket server * + * * + * Copyright 2018 by Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "ResourceRouter.h" diff --git a/libresapi/src/api/ResourceRouter.h b/libresapi/src/api/ResourceRouter.h index 2bb5930a3..53222ac75 100644 --- a/libresapi/src/api/ResourceRouter.h +++ b/libresapi/src/api/ResourceRouter.h @@ -1,3 +1,24 @@ +/******************************************************************************* + * libresapi/api/ResourceRouter.h * + * * + * LibResAPI: API for local socket server * + * * + * Copyright 2018 by Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once #include "ApiTypes.h" diff --git a/libresapi/src/api/RsControlModule.cpp b/libresapi/src/api/RsControlModule.cpp index ebeadf986..5caca6b8b 100644 --- a/libresapi/src/api/RsControlModule.cpp +++ b/libresapi/src/api/RsControlModule.cpp @@ -1,3 +1,24 @@ +/******************************************************************************* + * libresapi/api/RsControlModule.cpp * + * * + * LibResAPI: API for local socket server * + * * + * Copyright 2018 by Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "RsControlModule.h" #include @@ -446,6 +467,8 @@ void RsControlModule::handleCreateLocation(Request &req, Response &resp) req.mStream << makeKeyValueReference("hidden_adress", hidden_address) << makeKeyValueReference("hidden_port", hidden_port_str); uint16_t hidden_port = 0; + bool auto_tor = false ; // to be set by API, so disabled until then. + if(hidden_address.empty() != hidden_port_str.empty()) { resp.setFail("you must both specify string hidden_adress and string hidden_port to create a hidden node."); @@ -518,7 +541,7 @@ void RsControlModule::handleCreateLocation(Request &req, Response &resp) mPassword = pgp_password; mFixedPassword = pgp_password; } - bool ssl_ok = RsAccounts::GenerateSSLCertificate(pgp_id, "", ssl_name, "", hidden_port!=0, ssl_password, ssl_id, err_string); + bool ssl_ok = RsAccounts::createNewAccount(pgp_id, "", ssl_name, "", hidden_port!=0, auto_tor!=0, ssl_password, ssl_id, err_string); // clear fixed password to restore normal password operation // { diff --git a/libresapi/src/api/RsControlModule.h b/libresapi/src/api/RsControlModule.h index e81bb66f1..cb3b7834d 100644 --- a/libresapi/src/api/RsControlModule.h +++ b/libresapi/src/api/RsControlModule.h @@ -1,3 +1,24 @@ +/******************************************************************************* + * libresapi/api/RsControlModule.h * + * * + * LibResAPI: API for local socket server * + * * + * Copyright 2018 by Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once #include diff --git a/libresapi/src/api/ServiceControlHandler.cpp b/libresapi/src/api/ServiceControlHandler.cpp index f426f3378..6597d9d43 100644 --- a/libresapi/src/api/ServiceControlHandler.cpp +++ b/libresapi/src/api/ServiceControlHandler.cpp @@ -1,3 +1,24 @@ +/******************************************************************************* + * libresapi/api/ServiceControlHandler.cpp * + * * + * LibResAPI: API for local socket server * + * * + * Copyright 2018 by Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "ServiceControlHandler.h" #include "retroshare/rsservicecontrol.h" diff --git a/libresapi/src/api/ServiceControlHandler.h b/libresapi/src/api/ServiceControlHandler.h index da1db64e4..5ee9f6250 100644 --- a/libresapi/src/api/ServiceControlHandler.h +++ b/libresapi/src/api/ServiceControlHandler.h @@ -1,3 +1,24 @@ +/******************************************************************************* + * libresapi/api/ServiceControlHandler.h * + * * + * LibResAPI: API for local socket server * + * * + * Copyright 2018 by Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once #include "ApiTypes.h" diff --git a/libresapi/src/api/SettingsHandler.cpp b/libresapi/src/api/SettingsHandler.cpp index 6e1aa75da..64a4d4997 100644 --- a/libresapi/src/api/SettingsHandler.cpp +++ b/libresapi/src/api/SettingsHandler.cpp @@ -1,3 +1,24 @@ +/******************************************************************************* + * libresapi/api/SettingsHandler.cpp * + * * + * LibResAPI: API for local socket server * + * * + * Copyright 2018 by Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "SettingsHandler.h" #include diff --git a/libresapi/src/api/SettingsHandler.h b/libresapi/src/api/SettingsHandler.h index b4c21fae2..6d7b040e8 100644 --- a/libresapi/src/api/SettingsHandler.h +++ b/libresapi/src/api/SettingsHandler.h @@ -1,3 +1,24 @@ +/******************************************************************************* + * libresapi/api/SettingsHandler.h * + * * + * LibResAPI: API for local socket server * + * * + * Copyright 2018 by Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef SETTINGSHANDLER_H #define SETTINGSHANDLER_H diff --git a/libresapi/src/api/StateTokenServer.cpp b/libresapi/src/api/StateTokenServer.cpp index 6c113cdae..7bd77a41f 100644 --- a/libresapi/src/api/StateTokenServer.cpp +++ b/libresapi/src/api/StateTokenServer.cpp @@ -1,3 +1,24 @@ +/******************************************************************************* + * libresapi/api/StateTokenServer.cpp * + * * + * LibResAPI: API for local socket server * + * * + * Copyright 2018 by Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "StateTokenServer.h" #include diff --git a/libresapi/src/api/StateTokenServer.h b/libresapi/src/api/StateTokenServer.h index 8b80b9350..17900de8e 100644 --- a/libresapi/src/api/StateTokenServer.h +++ b/libresapi/src/api/StateTokenServer.h @@ -1,3 +1,24 @@ +/******************************************************************************* + * libresapi/api/StateTokenServer.h * + * * + * LibResAPI: API for local socket server * + * * + * Copyright 2018 by Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once #include diff --git a/libresapi/src/api/StatsHandler.cpp b/libresapi/src/api/StatsHandler.cpp index 46bf600d4..49ce23487 100644 --- a/libresapi/src/api/StatsHandler.cpp +++ b/libresapi/src/api/StatsHandler.cpp @@ -1,3 +1,24 @@ +/******************************************************************************* + * libresapi/api/StatsHandler.cpp * + * * + * LibResAPI: API for local socket server * + * * + * Copyright 2018 by Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "StatsHandler.h" #include "Operators.h" diff --git a/libresapi/src/api/StatsHandler.h b/libresapi/src/api/StatsHandler.h index cbe8ae231..0b6d65009 100644 --- a/libresapi/src/api/StatsHandler.h +++ b/libresapi/src/api/StatsHandler.h @@ -1,3 +1,24 @@ +/******************************************************************************* + * libresapi/api/StatsHandler.h * + * * + * LibResAPI: API for local socket server * + * * + * Copyright 2018 by Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef STATSHANDLER_H #define STATSHANDLER_H diff --git a/libresapi/src/api/TmpBlobStore.cpp b/libresapi/src/api/TmpBlobStore.cpp index c179b6830..098f02e39 100644 --- a/libresapi/src/api/TmpBlobStore.cpp +++ b/libresapi/src/api/TmpBlobStore.cpp @@ -1,3 +1,24 @@ +/******************************************************************************* + * libresapi/api/TmpBLogStore.cpp * + * * + * LibResAPI: API for local socket server * + * * + * Copyright 2018 by Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "TmpBlobStore.h" #include diff --git a/libresapi/src/api/TmpBlobStore.h b/libresapi/src/api/TmpBlobStore.h index 1cf439b85..18ec6917b 100644 --- a/libresapi/src/api/TmpBlobStore.h +++ b/libresapi/src/api/TmpBlobStore.h @@ -1,3 +1,24 @@ +/******************************************************************************* + * libresapi/api/TmpBLogStore.h * + * * + * LibResAPI: API for local socket server * + * * + * Copyright 2018 by Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once #include "StateTokenServer.h" diff --git a/libresapi/src/api/TransfersHandler.cpp b/libresapi/src/api/TransfersHandler.cpp index dc28e9596..c3b499a7e 100644 --- a/libresapi/src/api/TransfersHandler.cpp +++ b/libresapi/src/api/TransfersHandler.cpp @@ -1,3 +1,24 @@ +/******************************************************************************* + * libresapi/api/TransfersHandler.cpp * + * * + * LibResAPI: API for local socket server * + * * + * Copyright 2018 by Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "TransfersHandler.h" #include "Operators.h" #include diff --git a/libresapi/src/api/TransfersHandler.h b/libresapi/src/api/TransfersHandler.h index 7e43c3614..41b442838 100644 --- a/libresapi/src/api/TransfersHandler.h +++ b/libresapi/src/api/TransfersHandler.h @@ -1,3 +1,24 @@ +/******************************************************************************* + * libresapi/api/TransfersHandler.h * + * * + * LibResAPI: API for local socket server * + * * + * Copyright 2018 by Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once #include "ResourceRouter.h" diff --git a/libresapi/src/api/json.cpp b/libresapi/src/api/json.cpp index 2bcec7e81..103ad9b67 100644 --- a/libresapi/src/api/json.cpp +++ b/libresapi/src/api/json.cpp @@ -1,3 +1,24 @@ +/******************************************************************************* + * libresapi/api/json.cpp * + * * + * LibResAPI: API for local socket server * + * * + * Copyright 2018 by Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #define nullptr 0 #include "json.h" diff --git a/libresapi/src/libresapi.pro b/libresapi/src/libresapi.pro index 5f4c973e9..ba728f9a5 100644 --- a/libresapi/src/libresapi.pro +++ b/libresapi/src/libresapi.pro @@ -1,3 +1,20 @@ +################################################################################ +# libresapi.pro # +# Copyright (C) 2018, Retroshare team # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU Affero General Public License as # +# published by the Free Software Foundation, either version 3 of the # +# License, or (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU Affero General Public License for more details. # +# # +# You should have received a copy of the GNU Affero General Public License # +# along with this program. If not, see . # +################################################################################ !include("../../retroshare.pri"): error("Could not include file ../../retroshare.pri") TEMPLATE = lib @@ -93,7 +110,7 @@ libresapihttpserver { QMAKE_EXTRA_COMPILERS += create_webfiles_html create_webfiles_js create_webfiles_css } - win32 { + appveyor { DEFINES *= WINDOWS_SYS INCLUDEPATH += . $$INC_DIR @@ -109,6 +126,19 @@ libresapihttpserver { system($$MAKE_SRC\\init.bat .) } + win32 { + DEFINES *= WINDOWS_SYS + INCLUDEPATH += . $$INC_DIR + + PRO_PATH=$$shell_path($$_PRO_FILE_PWD_) + MAKE_SRC=$$shell_path($$PRO_PATH/webui-src/make-src) + + QMAKE_POST_LINK=$$MAKE_SRC/build.sh $$PRO_PATH + + # create dummy files + system($$MAKE_SRC/init.sh .) + } + linux { CONFIG += link_pkgconfig PKGCONFIG *= libmicrohttpd diff --git a/libresapi/src/use_libresapi.pri b/libresapi/src/use_libresapi.pri index ee4c87d46..8bdfe714e 100644 --- a/libresapi/src/use_libresapi.pri +++ b/libresapi/src/use_libresapi.pri @@ -1,3 +1,20 @@ +################################################################################ +# uselibresapi.pri # +# Copyright (C) 2018, Retroshare team # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU Affero General Public License as # +# published by the Free Software Foundation, either version 3 of the # +# License, or (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU Affero General Public License for more details. # +# # +# You should have received a copy of the GNU Affero General Public License # +# along with this program. If not, see . # +################################################################################ DEPENDPATH *= $$system_path($$clean_path($$PWD/../../libresapi/src)) INCLUDEPATH *= $$system_path($$clean_path($${PWD}/../../libresapi/src)) LIBS *= -L$$system_path($$clean_path($${OUT_PWD}/../../libresapi/src/lib/)) -lresapi diff --git a/libresapi/src/util/ContentTypes.cpp b/libresapi/src/util/ContentTypes.cpp index 30434e093..3d026932b 100644 --- a/libresapi/src/util/ContentTypes.cpp +++ b/libresapi/src/util/ContentTypes.cpp @@ -1,3 +1,24 @@ +/******************************************************************************* + * libresapi/util/ContentTypes.cpp * + * * + * LibResAPI: API for local socket server * + * * + * Copyright 2018 by Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "ContentTypes.h" #include #include diff --git a/libresapi/src/util/ContentTypes.h b/libresapi/src/util/ContentTypes.h index 0e6b71e73..269383bae 100644 --- a/libresapi/src/util/ContentTypes.h +++ b/libresapi/src/util/ContentTypes.h @@ -1,3 +1,24 @@ +/******************************************************************************* + * libresapi/util/ContentTypes.h * + * * + * LibResAPI: API for local socket server * + * * + * Copyright 2018 by Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef CONTENTTYPES_H #define CONTENTTYPES_H diff --git a/libretroshare/src/chat/distantchat.cc b/libretroshare/src/chat/distantchat.cc index c9999c56d..60b11b0b3 100644 --- a/libretroshare/src/chat/distantchat.cc +++ b/libretroshare/src/chat/distantchat.cc @@ -1,28 +1,24 @@ -/* - * libretroshare/src/chat: distantchat.cc - * - * Services for RetroShare. - * - * Copyright 2014 by Cyril Soler - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "csoler@users.sourceforge.net". - * - */ - +/******************************************************************************* + * libretroshare/src/chat: distantchat.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2014 by Cyril Soler * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include #include @@ -31,7 +27,7 @@ #include "openssl/dh.h" #include "openssl/err.h" -#include "util/rsaes.h" +#include "crypto/rsaes.h" #include "util/rsmemory.h" #include "util/rsprint.h" diff --git a/libretroshare/src/chat/distantchat.h b/libretroshare/src/chat/distantchat.h index b177e6029..196c1079f 100644 --- a/libretroshare/src/chat/distantchat.h +++ b/libretroshare/src/chat/distantchat.h @@ -1,27 +1,24 @@ -/* - * libretroshare/src/chat: distantchat.h - * - * Services for RetroShare. - * - * Copyright 2014 by Cyril Soler - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "csoler@users.sourceforge.net". - * - */ +/******************************************************************************* + * libretroshare/src/chat: distantchat.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2014 by Cyril Soler * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once diff --git a/libretroshare/src/chat/distributedchat.cc b/libretroshare/src/chat/distributedchat.cc index 00fcd3a97..0c7a765de 100644 --- a/libretroshare/src/chat/distributedchat.cc +++ b/libretroshare/src/chat/distributedchat.cc @@ -1,27 +1,24 @@ -/* - * libretroshare/src/chat: distributedchat.cc - * - * Services for RetroShare. - * - * Copyright 2014 by Cyril Soler - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "csoler@users.sourceforge.net". - * - */ +/******************************************************************************* + * libretroshare/src/chat: distributedchat.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2014 by Cyril Soler * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include #include diff --git a/libretroshare/src/chat/distributedchat.h b/libretroshare/src/chat/distributedchat.h index ca7155dd2..f0db7f649 100644 --- a/libretroshare/src/chat/distributedchat.h +++ b/libretroshare/src/chat/distributedchat.h @@ -1,27 +1,24 @@ -/* - * libretroshare/src/chat/distributedchat.h - * - * Services for RetroShare. - * - * Copyright 2014 by Cyril Soler - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "csoler@users.sourceforge.net". - * - */ +/******************************************************************************* + * libretroshare/src/chat: distributedchat.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2014 by Cyril Soler * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once #include diff --git a/libretroshare/src/chat/p3chatservice.cc b/libretroshare/src/chat/p3chatservice.cc index 9b34460e7..08267f6be 100644 --- a/libretroshare/src/chat/p3chatservice.cc +++ b/libretroshare/src/chat/p3chatservice.cc @@ -1,34 +1,32 @@ -/* - * "$Id: p3ChatService.cc,v 1.24 2007-05-05 16:10:06 rmf24 Exp $" - * - * Other Bits for RetroShare. - * - * Copyright 2004-2006 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ +/******************************************************************************* + * libretroshare/src/chat: chatservice.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2008 by Robert Fernie. * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ + #include #include #include #include "util/rsdir.h" #include "util/radix64.h" -#include "util/rsaes.h" +#include "crypto/rsaes.h" #include "util/rsrandom.h" #include "util/rsstring.h" #include "retroshare/rsiface.h" diff --git a/libretroshare/src/chat/p3chatservice.h b/libretroshare/src/chat/p3chatservice.h index bcd0af977..3a5b08ab9 100644 --- a/libretroshare/src/chat/p3chatservice.h +++ b/libretroshare/src/chat/p3chatservice.h @@ -1,28 +1,24 @@ -/* - * libretroshare/src/services chatservice.h - * - * Services for RetroShare. - * - * Copyright 2004-2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/chat: chatservice.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2008 by Robert Fernie. * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef SERVICE_CHAT_HEADER #define SERVICE_CHAT_HEADER diff --git a/libretroshare/src/chat/rschatitems.cc b/libretroshare/src/chat/rschatitems.cc index 7ae680105..bd79f6821 100644 --- a/libretroshare/src/chat/rschatitems.cc +++ b/libretroshare/src/chat/rschatitems.cc @@ -1,28 +1,24 @@ - -/* - * libretroshare/src/serialiser: rsbaseitems.cc - * - * RetroShare Serialiser. - * - * Copyright 2007-2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ +/******************************************************************************* + * libretroshare/src/chat: rschatitems.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2007-2008 by Robert Fernie. * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include #include diff --git a/libretroshare/src/chat/rschatitems.h b/libretroshare/src/chat/rschatitems.h index 8ea4189f4..f2ca0731d 100644 --- a/libretroshare/src/chat/rschatitems.h +++ b/libretroshare/src/chat/rschatitems.h @@ -1,27 +1,24 @@ -/* - * libretroshare/src/serialiser: rschatitems.h - * - * RetroShare Serialiser. - * - * Copyright 2007-2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ +/******************************************************************************* + * libretroshare/src/chat: rschatitems.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2007-2008 by Robert Fernie. * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once diff --git a/libretroshare/src/crypto/chacha20.cpp b/libretroshare/src/crypto/chacha20.cpp index 3f12b2086..228162622 100644 --- a/libretroshare/src/crypto/chacha20.cpp +++ b/libretroshare/src/crypto/chacha20.cpp @@ -1,27 +1,24 @@ -/* - * RetroShare C++ File sharing default variables - * - * file_sharing/file_sharing_defaults.h - * - * Copyright 2016 by Mr.Alice - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare.project@gmail.com". - * - */ +/******************************************************************************* + * libretroshare/src/crypto: chacha20.cpp * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2016 by Mr.Alice * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include #include #include diff --git a/libretroshare/src/crypto/chacha20.h b/libretroshare/src/crypto/chacha20.h index ffce04605..1b19a1402 100644 --- a/libretroshare/src/crypto/chacha20.h +++ b/libretroshare/src/crypto/chacha20.h @@ -1,27 +1,24 @@ -/* - * RetroShare C++ File sharing default variables - * - * crypto/chacha20.h - * - * Copyright 2016 by Mr.Alice - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare.project@gmail.com". - * - */ +/******************************************************************************* + * libretroshare/src/crypto: chacha20.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2016 by Mr.Alice * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include diff --git a/libretroshare/src/crypto/hashstream.cc b/libretroshare/src/crypto/hashstream.cc index 3f97cef7b..88709acfc 100644 --- a/libretroshare/src/crypto/hashstream.cc +++ b/libretroshare/src/crypto/hashstream.cc @@ -1,3 +1,24 @@ +/******************************************************************************* + * libretroshare/src/crypto: hashstream.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2018 by Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "hashstream.h" #include diff --git a/libretroshare/src/crypto/hashstream.h b/libretroshare/src/crypto/hashstream.h index c73c7367c..fe276b6b4 100644 --- a/libretroshare/src/crypto/hashstream.h +++ b/libretroshare/src/crypto/hashstream.h @@ -1,3 +1,24 @@ +/******************************************************************************* + * libretroshare/src/crypto: hashstream.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2018 by Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once #include diff --git a/libretroshare/src/util/rsaes.cc b/libretroshare/src/crypto/rsaes.cc similarity index 68% rename from libretroshare/src/util/rsaes.cc rename to libretroshare/src/crypto/rsaes.cc index 7be5175f9..d5ad2c7a0 100644 --- a/libretroshare/src/util/rsaes.cc +++ b/libretroshare/src/crypto/rsaes.cc @@ -1,28 +1,24 @@ -/* - * libretroshare/src/utils: rsaes.cc - * - * AES crptography for RetroShare. - * - * Copyright 2013 by Cyril Soler - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "csoler@users.sourceforge.net". - * - */ - +/******************************************************************************* + * libretroshare/src/util: rsaes.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2013-2013 Cyril Soler * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include #include #include diff --git a/libretroshare/src/crypto/rsaes.h b/libretroshare/src/crypto/rsaes.h new file mode 100644 index 000000000..d4592793d --- /dev/null +++ b/libretroshare/src/crypto/rsaes.h @@ -0,0 +1,43 @@ +/******************************************************************************* + * libretroshare/src/util: rsaes.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2013-2013 Cyril Soler * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ +#include + +class RsAES +{ + public: + // Crypt/decrypt data using a 16 bytes key and a 8 bytes salt. + // + // output_data allocation is left to the client. The size should be at least RsAES::get_buffer_size(input_data_length) + // + // Return value: + // true: encryption/decryption ok + // + // false: encryption/decryption went bad. Check buffer size. + // + static bool aes_crypt_8_16(const uint8_t *input_data,uint32_t input_data_length,uint8_t key[16],uint8_t salt[8],uint8_t *output_data,uint32_t& output_data_length) ; + static bool aes_decrypt_8_16(const uint8_t *input_data,uint32_t input_data_length,uint8_t key[16],uint8_t salt[8],uint8_t *output_data,uint32_t& output_data_length) ; + + // computes the safe buffer size to store encrypted/decrypted data for the given input stream size + // + static uint32_t get_buffer_size(uint32_t size) ; +}; + diff --git a/libretroshare/src/crypto/rscrypto.cpp b/libretroshare/src/crypto/rscrypto.cpp new file mode 100644 index 000000000..0a296673e --- /dev/null +++ b/libretroshare/src/crypto/rscrypto.cpp @@ -0,0 +1,212 @@ +/******************************************************************************* + * libretroshare/src/crypto: crypto.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2018 by Cyril Soler * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ + +#include +#include +#include + +#include "rscrypto.h" +#include "util/rsrandom.h" + +//#define CRYPTO_DEBUG 1 + +namespace librs { +namespace crypto { + +#define RSCRYPTO_DEBUG() std::cerr << time(NULL) << " : RSCRYPTO : " << __FUNCTION__ << " : " +#define RSCRYPTO_ERROR() std::cerr << "(EE) RSCRYPTO ERROR : " + +static const uint32_t ENCRYPTED_MEMORY_INITIALIZATION_VECTOR_SIZE = 12 ; +static const uint32_t ENCRYPTED_MEMORY_AUTHENTICATION_TAG_SIZE = 16 ; +static const uint32_t ENCRYPTED_MEMORY_HEADER_SIZE = 4 ; +static const uint32_t ENCRYPTED_MEMORY_EDATA_SIZE = 4 ; + +static const uint8_t ENCRYPTED_MEMORY_FORMAT_AEAD_CHACHA20_POLY1305 = 0x01 ; +static const uint8_t ENCRYPTED_MEMORY_FORMAT_AEAD_CHACHA20_SHA256 = 0x02 ; + +bool encryptAuthenticateData(const unsigned char *clear_data,uint32_t clear_data_size,uint8_t *encryption_master_key,unsigned char *& encrypted_data,uint32_t& encrypted_data_len) +{ + uint8_t initialization_vector[ENCRYPTED_MEMORY_INITIALIZATION_VECTOR_SIZE] ; + + RSRandom::random_bytes(initialization_vector,ENCRYPTED_MEMORY_INITIALIZATION_VECTOR_SIZE) ; + +#ifdef CRYPTO_DEBUG + RSCRYPTO_DEBUG() << "ftServer::Encrypting ft item." << std::endl; + RSCRYPTO_DEBUG() << " random nonce : " << RsUtil::BinToHex(initialization_vector,ENCRYPTED_MEMORY_INITIALIZATION_VECTOR_SIZE) << std::endl; +#endif + + uint32_t item_serialized_size = clear_data_size;//RsGenericSerializer().size(clear_item) ; + uint32_t total_data_size = ENCRYPTED_MEMORY_HEADER_SIZE + ENCRYPTED_MEMORY_INITIALIZATION_VECTOR_SIZE + ENCRYPTED_MEMORY_EDATA_SIZE + item_serialized_size + ENCRYPTED_MEMORY_AUTHENTICATION_TAG_SIZE ; + +#ifdef CRYPTO_DEBUG + RSCRYPTO_DEBUG() << " clear part size : " << size(clear_item) << std::endl; + RSCRYPTO_DEBUG() << " total item size : " << total_data_size << std::endl; +#endif + + encrypted_data = (unsigned char*)rs_malloc( total_data_size ) ; + encrypted_data_len = total_data_size ; + + if(encrypted_data == NULL) + return false ; + + uint8_t *edata = (uint8_t*)encrypted_data; + uint32_t edata_size = item_serialized_size; + uint32_t offset = 0; + + edata[0] = 0xae ; + edata[1] = 0xad ; + edata[2] = ENCRYPTED_MEMORY_FORMAT_AEAD_CHACHA20_SHA256 ; // means AEAD_chacha20_sha256 + edata[3] = 0x01 ; + + offset += ENCRYPTED_MEMORY_HEADER_SIZE; + uint32_t aad_offset = offset ; + uint32_t aad_size = ENCRYPTED_MEMORY_INITIALIZATION_VECTOR_SIZE + ENCRYPTED_MEMORY_EDATA_SIZE ; + + memcpy(&edata[offset], initialization_vector, ENCRYPTED_MEMORY_INITIALIZATION_VECTOR_SIZE) ; + offset += ENCRYPTED_MEMORY_INITIALIZATION_VECTOR_SIZE ; + + edata[offset+0] = (edata_size >> 0) & 0xff ; + edata[offset+1] = (edata_size >> 8) & 0xff ; + edata[offset+2] = (edata_size >> 16) & 0xff ; + edata[offset+3] = (edata_size >> 24) & 0xff ; + + offset += ENCRYPTED_MEMORY_EDATA_SIZE ; + + memcpy(&edata[offset],clear_data,clear_data_size); + +#ifdef CRYPTO_DEBUG + RSCRYPTO_DEBUG() << " clear item : " << RsUtil::BinToHex(&edata[offset],std::min(50,(int)total_data_size-(int)offset)) << "(...)" << std::endl; +#endif + + uint32_t clear_item_offset = offset ; + offset += edata_size ; + + uint32_t authentication_tag_offset = offset ; + assert(ENCRYPTED_MEMORY_AUTHENTICATION_TAG_SIZE + offset == total_data_size) ; + + //uint8_t encryption_key[32] ; + //deriveEncryptionKey(hash,encryption_key) ; + + if(edata[2] == ENCRYPTED_MEMORY_FORMAT_AEAD_CHACHA20_POLY1305) + librs::crypto::AEAD_chacha20_poly1305(encryption_master_key,initialization_vector,&edata[clear_item_offset],edata_size, &edata[aad_offset],aad_size, &edata[authentication_tag_offset],true) ; + else if(edata[2] == ENCRYPTED_MEMORY_FORMAT_AEAD_CHACHA20_SHA256) + librs::crypto::AEAD_chacha20_sha256 (encryption_master_key,initialization_vector,&edata[clear_item_offset],edata_size, &edata[aad_offset],aad_size, &edata[authentication_tag_offset],true) ; + else + return false ; + +#ifdef CRYPTO_DEBUG + RSCRYPTO_DEBUG() << " encryption key : " << RsUtil::BinToHex(encryption_key,32) << std::endl; + RSCRYPTO_DEBUG() << " authen. tag : " << RsUtil::BinToHex(&edata[authentication_tag_offset],ENCRYPTED_MEMORY_AUTHENTICATION_TAG_SIZE) << std::endl; + RSCRYPTO_DEBUG() << " final item : " << RsUtil::BinToHex(&edata[0],std::min(50u,total_data_size)) << "(...)" << std::endl; +#endif + + return true ; +} + +// Decrypts the given item using aead-chacha20-poly1305 +bool decryptAuthenticateData(const unsigned char *encrypted_data,uint32_t encrypted_data_len,uint8_t *encryption_master_key, unsigned char *& decrypted_data, uint32_t& decrypted_data_size) +{ + //uint8_t encryption_key[32] ; + //deriveEncryptionKey(hash,encryption_key) ; + + uint8_t *edata = (uint8_t*)encrypted_data; + uint32_t offset = 0; + + if(encrypted_data_len < ENCRYPTED_MEMORY_HEADER_SIZE + ENCRYPTED_MEMORY_INITIALIZATION_VECTOR_SIZE + ENCRYPTED_MEMORY_EDATA_SIZE) return false ; + + if(edata[0] != 0xae) return false ; + if(edata[1] != 0xad) return false ; + if(edata[2] != ENCRYPTED_MEMORY_FORMAT_AEAD_CHACHA20_POLY1305 && edata[2] != ENCRYPTED_MEMORY_FORMAT_AEAD_CHACHA20_SHA256) return false ; + if(edata[3] != 0x01) return false ; + + offset += ENCRYPTED_MEMORY_HEADER_SIZE ; + uint32_t aad_offset = offset ; + uint32_t aad_size = ENCRYPTED_MEMORY_EDATA_SIZE + ENCRYPTED_MEMORY_INITIALIZATION_VECTOR_SIZE ; + + uint8_t *initialization_vector = &edata[offset] ; + +#ifdef CRYPTO_DEBUG + RSCRYPTO_DEBUG() << "ftServer::decrypting ft item." << std::endl; + RSCRYPTO_DEBUG() << " item data : " << RsUtil::BinToHex(edata,std::min(50u,encrypted_data_len) << "(...)" << std::endl; + RSCRYPTO_DEBUG() << " hash : " << hash << std::endl; + RSCRYPTO_DEBUG() << " encryption key : " << RsUtil::BinToHex(encryption_key,32) << std::endl; + RSCRYPTO_DEBUG() << " random nonce : " << RsUtil::BinToHex(initialization_vector,ENCRYPTED_MEMORY_INITIALIZATION_VECTOR_SIZE) << std::endl; +#endif + + offset += ENCRYPTED_MEMORY_INITIALIZATION_VECTOR_SIZE ; + + uint32_t edata_size = 0 ; + edata_size += ((uint32_t)edata[offset+0]) << 0 ; + edata_size += ((uint32_t)edata[offset+1]) << 8 ; + edata_size += ((uint32_t)edata[offset+2]) << 16 ; + edata_size += ((uint32_t)edata[offset+3]) << 24 ; + + if(edata_size + ENCRYPTED_MEMORY_EDATA_SIZE + ENCRYPTED_MEMORY_AUTHENTICATION_TAG_SIZE + ENCRYPTED_MEMORY_INITIALIZATION_VECTOR_SIZE + ENCRYPTED_MEMORY_HEADER_SIZE != encrypted_data_len) + { + RSCRYPTO_ERROR() << " ERROR: encrypted data size is " << edata_size << ", should be " << encrypted_data_len - (ENCRYPTED_MEMORY_EDATA_SIZE + ENCRYPTED_MEMORY_AUTHENTICATION_TAG_SIZE + ENCRYPTED_MEMORY_INITIALIZATION_VECTOR_SIZE + ENCRYPTED_MEMORY_HEADER_SIZE ) << std::endl; + return false ; + } + + offset += ENCRYPTED_MEMORY_EDATA_SIZE ; + uint32_t clear_item_offset = offset ; + + uint32_t authentication_tag_offset = offset + edata_size ; +#ifdef CRYPTO_DEBUG + RSCRYPTO_DEBUG() << " authen. tag : " << RsUtil::BinToHex(&edata[authentication_tag_offset],ENCRYPTED_MEMORY_AUTHENTICATION_TAG_SIZE) << std::endl; +#endif + + bool result ; + + if(edata[2] == ENCRYPTED_MEMORY_FORMAT_AEAD_CHACHA20_POLY1305) + result = librs::crypto::AEAD_chacha20_poly1305(encryption_master_key,initialization_vector,&edata[clear_item_offset],edata_size, &edata[aad_offset],aad_size, &edata[authentication_tag_offset],false) ; + else if(edata[2] == ENCRYPTED_MEMORY_FORMAT_AEAD_CHACHA20_SHA256) + result = librs::crypto::AEAD_chacha20_sha256 (encryption_master_key,initialization_vector,&edata[clear_item_offset],edata_size, &edata[aad_offset],aad_size, &edata[authentication_tag_offset],false) ; + else + return false ; + +#ifdef CRYPTO_DEBUG + RSCRYPTO_DEBUG() << " authen. result : " << result << std::endl; + RSCRYPTO_DEBUG() << " decrypted daya : " << RsUtil::BinToHex(&edata[clear_item_offset],std::min(50u,edata_size)) << "(...)" << std::endl; +#endif + + if(!result) + { + RSCRYPTO_ERROR() << "(EE) decryption/authentication went wrong." << std::endl; + return false ; + } + + decrypted_data_size = edata_size ; + decrypted_data = (unsigned char*)rs_malloc(edata_size) ; + + if(decrypted_data == NULL) + { + std::cerr << "Failed to allocate memory for decrypted data chunk of size " << edata_size << std::endl; + return false ; + } + memcpy(decrypted_data,&edata[clear_item_offset],edata_size) ; + + return true ; +} + +} +} + diff --git a/libretroshare/src/crypto/rscrypto.h b/libretroshare/src/crypto/rscrypto.h new file mode 100644 index 000000000..9666aed28 --- /dev/null +++ b/libretroshare/src/crypto/rscrypto.h @@ -0,0 +1,59 @@ + +/******************************************************************************* + * libretroshare/src/crypto: crypto.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2018 by Cyril Soler * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ + +#include "crypto/chacha20.h" + +namespace librs +{ +namespace crypto +{ +/*! + * \brief encryptAuthenticateData + Encrypts/decrypts data, using a autenticated construction + chacha20, based on a given 32 bytes master key. The actual encryption using a randomized key + based on a 96 bits IV. Input values are not touched (memory is not released). Memory ownership of outputs is left to the client. + * \param clear_data input data to encrypt + * \param clear_data_size length of input data + * \param encryption_master_key encryption master key of length 32 bytes. + * \param encrypted_data encrypted data, allocated using malloc + * \param encrypted_data_len length of encrypted data + * \return + * true if everything went well. + */ +bool encryptAuthenticateData(const unsigned char *clear_data,uint32_t clear_data_size,uint8_t *encryption_master_key,unsigned char *& encrypted_data,uint32_t& encrypted_data_size); + +/*! + * \brief decryptAuthenticateData + Encrypts/decrypts data, using a autenticated construction + chacha20, based on a given 32 bytes master key. The actual encryption using a randomized key + based on a 96 bits IV. Input values are not touched (memory is not released). Memory ownership of outputs is left to the client. + * \param encrypted_data input encrypted data + * \param encrypted_data_size input encrypted data length + * \param encryption_master_key encryption master key of length 32 bytes. + * \param decrypted_data decrypted data, allocated using malloc. + * \param decrypted_data_size length of allocated decrypted data. + * \return + * true if decryption + authentication are ok. + */ +bool decryptAuthenticateData(const unsigned char *encrypted_data,uint32_t encrypted_data_size, uint8_t* encryption_master_key, unsigned char *& decrypted_data,uint32_t& decrypted_data_size); +} +} + diff --git a/libretroshare/src/deep_search/deep_search.h b/libretroshare/src/deep_search/deep_search.h new file mode 100644 index 000000000..edbf546e9 --- /dev/null +++ b/libretroshare/src/deep_search/deep_search.h @@ -0,0 +1,271 @@ +#pragma once +/* + * RetroShare Content Search and Indexing. + * Copyright (C) 2018 Gioacchino Mazzurco + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#include +#include +#include + +#include "retroshare/rsgxschannels.h" +#include "retroshare/rsinit.h" +#include "util/rsurl.h" + +#ifndef XAPIAN_AT_LEAST +#define XAPIAN_AT_LEAST(A,B,C) (XAPIAN_MAJOR_VERSION > (A) || \ + (XAPIAN_MAJOR_VERSION == (A) && \ + (XAPIAN_MINOR_VERSION > (B) || \ + (XAPIAN_MINOR_VERSION == (B) && XAPIAN_REVISION >= (C))))) +#endif // ndef XAPIAN_AT_LEAST + +struct DeepSearch +{ + struct SearchResult + { + std::string mUrl; + std::string mSnippet; + }; + + /** + * @param[in] maxResults maximum number of acceptable search results, 0 for + * no limits + * @return search results count + */ + static uint32_t search( const std::string& queryStr, + std::vector& results, + uint32_t maxResults = 100 ) + { + results.clear(); + + Xapian::Database db; + + // Open the database we're going to search. + try { db = Xapian::Database(dbPath()); } + catch(Xapian::DatabaseOpeningError e) + { + std::cerr << __PRETTY_FUNCTION__ << " " << e.get_msg() + << ", probably nothing has been indexed yet."<< std::endl; + return 0; + } + catch(Xapian::DatabaseError e) + { + std::cerr << __PRETTY_FUNCTION__ << " " << e.get_msg() + << " this is fishy, maybe " << dbPath() + << " has been corrupted (deleting it may help in that " + << "case without loosing data)" << std::endl; + return 0; + } + + // Set up a QueryParser with a stemmer and suitable prefixes. + Xapian::QueryParser queryparser; + //queryparser.set_stemmer(Xapian::Stem("en")); + queryparser.set_stemming_strategy(queryparser.STEM_SOME); + // Start of prefix configuration. + //queryparser.add_prefix("title", "S"); + //queryparser.add_prefix("description", "XD"); + // End of prefix configuration. + + // And parse the query. + Xapian::Query query = queryparser.parse_query(queryStr); + + // Use an Enquire object on the database to run the query. + Xapian::Enquire enquire(db); + enquire.set_query(query); + + Xapian::MSet mset = enquire.get_mset( + 0, maxResults ? maxResults : db.get_doccount() ); + + for ( Xapian::MSetIterator m = mset.begin(); m != mset.end(); ++m ) + { + const Xapian::Document& doc = m.get_document(); + SearchResult s; + s.mUrl = doc.get_value(URL_VALUENO); +#if XAPIAN_AT_LEAST(1,3,5) + s.mSnippet = mset.snippet(doc.get_data()); +#endif // XAPIAN_AT_LEAST(1,3,5) + results.push_back(s); + } + + return results.size(); + } + + + static void indexChannelGroup(const RsGxsChannelGroup& chan) + { + Xapian::WritableDatabase db(dbPath(), Xapian::DB_CREATE_OR_OPEN); + + // Set up a TermGenerator that we'll use in indexing. + Xapian::TermGenerator termgenerator; + //termgenerator.set_stemmer(Xapian::Stem("en")); + + // We make a document and tell the term generator to use this. + Xapian::Document doc; + termgenerator.set_document(doc); + + // Index each field with a suitable prefix. + termgenerator.index_text(chan.mMeta.mGroupName, 1, "G"); + termgenerator.index_text(timetToXapianDate(chan.mMeta.mPublishTs), 1, "D"); + termgenerator.index_text(chan.mDescription, 1, "XD"); + + // Index fields without prefixes for general search. + termgenerator.index_text(chan.mMeta.mGroupName); + termgenerator.increase_termpos(); + termgenerator.index_text(chan.mDescription); + + RsUrl chanUrl; chanUrl + .setScheme("retroshare").setPath("/channel") + .setQueryKV("id", chan.mMeta.mGroupId.toStdString()); + const std::string idTerm("Q" + chanUrl.toString()); + + chanUrl.setQueryKV("publishTs", std::to_string(chan.mMeta.mPublishTs)); + chanUrl.setQueryKV("name", chan.mMeta.mGroupName); + if(!chan.mMeta.mAuthorId.isNull()) + chanUrl.setQueryKV("authorId", chan.mMeta.mAuthorId.toStdString()); + if(chan.mMeta.mSignFlags) + chanUrl.setQueryKV( "signFlags", + std::to_string(chan.mMeta.mSignFlags) ); + std::string rsLink(chanUrl.toString()); + + // store the RS link so we are able to retrive it on matching search + doc.add_value(URL_VALUENO, rsLink); + + // Store some fields for display purposes. + doc.set_data(chan.mMeta.mGroupName + "\n" + chan.mDescription); + + // We use the identifier to ensure each object ends up in the + // database only once no matter how many times we run the + // indexer. "Q" prefix is a Xapian convention for unique id term. + doc.add_boolean_term(idTerm); + db.replace_document(idTerm, doc); + } + + static void removeChannelFromIndex(RsGxsGroupId grpId) + { + // "Q" prefix is a Xapian convention for unique id term. + RsUrl chanUrl; chanUrl + .setScheme("retroshare").setPath("/channel") + .setQueryKV("id", grpId.toStdString()); + std::string idTerm("Q" + chanUrl.toString()); + + Xapian::WritableDatabase db(dbPath(), Xapian::DB_CREATE_OR_OPEN); + db.delete_document(idTerm); + } + + static void indexChannelPost(const RsGxsChannelPost& post) + { + Xapian::WritableDatabase db(dbPath(), Xapian::DB_CREATE_OR_OPEN); + + // Set up a TermGenerator that we'll use in indexing. + Xapian::TermGenerator termgenerator; + //termgenerator.set_stemmer(Xapian::Stem("en")); + + // We make a document and tell the term generator to use this. + Xapian::Document doc; + termgenerator.set_document(doc); + + // Index each field with a suitable prefix. + termgenerator.index_text(post.mMeta.mMsgName, 1, "S"); + termgenerator.index_text(timetToXapianDate(post.mMeta.mPublishTs), 1, "D"); + + // Avoid indexing HTML + bool isPlainMsg = post.mMsg[0] != '<' || post.mMsg[post.mMsg.size() - 1] != '>'; + + if(isPlainMsg) + termgenerator.index_text(post.mMsg, 1, "XD"); + + // Index fields without prefixes for general search. + termgenerator.index_text(post.mMeta.mMsgName); + if(isPlainMsg) + { + termgenerator.increase_termpos(); + termgenerator.index_text(post.mMsg); + } + + for(const RsGxsFile& attachment : post.mFiles) + { + termgenerator.index_text(attachment.mName, 1, "F"); + + termgenerator.increase_termpos(); + termgenerator.index_text(attachment.mName); + } + + // We use the identifier to ensure each object ends up in the + // database only once no matter how many times we run the + // indexer. + RsUrl postUrl; postUrl + .setScheme("retroshare").setPath("/channel") + .setQueryKV("id", post.mMeta.mGroupId.toStdString()) + .setQueryKV("msgid", post.mMeta.mMsgId.toStdString()); + std::string idTerm("Q" + postUrl.toString()); + + postUrl.setQueryKV("publishTs", std::to_string(post.mMeta.mPublishTs)); + postUrl.setQueryKV("name", post.mMeta.mMsgName); + postUrl.setQueryKV("authorId", post.mMeta.mAuthorId.toStdString()); + std::string rsLink(postUrl.toString()); + + // store the RS link so we are able to retrive it on matching search + doc.add_value(URL_VALUENO, rsLink); + + // Store some fields for display purposes. + if(isPlainMsg) + doc.set_data(post.mMeta.mMsgName + "\n" + post.mMsg); + else doc.set_data(post.mMeta.mMsgName); + + doc.add_boolean_term(idTerm); + db.replace_document(idTerm, doc); + } + + static void removeChannelPostFromIndex( + RsGxsGroupId grpId, RsGxsMessageId msgId ) + { + RsUrl postUrl; postUrl + .setScheme("retroshare").setPath("/channel") + .setQueryKV("id", grpId.toStdString()) + .setQueryKV("msgid", msgId.toStdString()); + // "Q" prefix is a Xapian convention for unique id term. + std::string idTerm("Q" + postUrl.toString()); + + Xapian::WritableDatabase db(dbPath(), Xapian::DB_CREATE_OR_OPEN); + db.delete_document(idTerm); + } + +private: + + enum : Xapian::valueno + { + /// Used to store retroshare url of indexed documents + URL_VALUENO, + + /// @see Xapian::BAD_VALUENO + BAD_VALUENO = Xapian::BAD_VALUENO + }; + + static const std::string& dbPath() + { + static const std::string dbDir = + RsAccounts::AccountDirectory() + "/deep_search_xapian_db"; + return dbDir; + } + + static std::string timetToXapianDate(const time_t& time) + { + char date[] = "YYYYMMDD\0"; + std::strftime(date, 9, "%Y%m%d", std::gmtime(&time)); + return date; + } +}; + diff --git a/libretroshare/src/dht/connectstatebox.cc b/libretroshare/src/dht/connectstatebox.cc index ca631687d..a5b0d44cb 100644 --- a/libretroshare/src/dht/connectstatebox.cc +++ b/libretroshare/src/dht/connectstatebox.cc @@ -1,27 +1,24 @@ -/* - * libretroshare/src/dht: connectstatebox.cc - * - * RetroShare DHT C++ Interface. - * - * Copyright 2011-2011 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ +/******************************************************************************* + * libretroshare/src/dht: connectstatebox.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2011-2011 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "dht/connectstatebox.h" #include "retroshare/rsconfig.h" diff --git a/libretroshare/src/dht/connectstatebox.h b/libretroshare/src/dht/connectstatebox.h index 178dcd00d..15334c284 100644 --- a/libretroshare/src/dht/connectstatebox.h +++ b/libretroshare/src/dht/connectstatebox.h @@ -1,31 +1,27 @@ +/******************************************************************************* + * libretroshare/src/dht: connectstatebox.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2011-2011 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef CONNECT_STATUS_BOX_H #define CONNECT_STATUS_BOX_H -/* - * libretroshare/src/dht: connectstatebox.h - * - * RetroShare DHT C++ Interface. - * - * Copyright 2011-2011 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - /* a connect state box */ #define CSB_START 1 diff --git a/libretroshare/src/dht/p3bitdht.cc b/libretroshare/src/dht/p3bitdht.cc index 4cb4aa973..a1fed1824 100644 --- a/libretroshare/src/dht/p3bitdht.cc +++ b/libretroshare/src/dht/p3bitdht.cc @@ -1,27 +1,24 @@ -/* - * libretroshare/src/dht: p3bitdht.h - * - * BitDht interface for RetroShare. - * - * Copyright 2009-2010 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ +/******************************************************************************* + * libretroshare/src/dht: p3bitdht.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2009-2010 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include diff --git a/libretroshare/src/dht/p3bitdht.h b/libretroshare/src/dht/p3bitdht.h index 92c2e626d..2935fcf16 100644 --- a/libretroshare/src/dht/p3bitdht.h +++ b/libretroshare/src/dht/p3bitdht.h @@ -1,28 +1,24 @@ -/* - * libretroshare/src/dht: p3bitdht.h - * - * BitDht interface for RetroShare. - * - * Copyright 2009-2010 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/dht: p3bitdht.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2009-2010 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef MRK_P3_BITDHT_H #define MRK_P3_BITDHT_H diff --git a/libretroshare/src/dht/p3bitdht_interface.cc b/libretroshare/src/dht/p3bitdht_interface.cc index e82758964..1b7ff35f5 100644 --- a/libretroshare/src/dht/p3bitdht_interface.cc +++ b/libretroshare/src/dht/p3bitdht_interface.cc @@ -1,27 +1,24 @@ -/* - * libretroshare/src/dht: p3bitdht.h - * - * BitDht interface for RetroShare. - * - * Copyright 2009-2011 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ +/******************************************************************************* + * libretroshare/src/dht: p3bitdht_interface.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2009-2011 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "util/rsnet.h" #include "dht/p3bitdht.h" diff --git a/libretroshare/src/dht/p3bitdht_peernet.cc b/libretroshare/src/dht/p3bitdht_peernet.cc index 3f37f8793..4be52dfa5 100644 --- a/libretroshare/src/dht/p3bitdht_peernet.cc +++ b/libretroshare/src/dht/p3bitdht_peernet.cc @@ -1,3 +1,24 @@ +/******************************************************************************* + * libretroshare/src/dht: p3bitdht_peernet.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2009-2011 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "dht/p3bitdht.h" diff --git a/libretroshare/src/dht/p3bitdht_peers.cc b/libretroshare/src/dht/p3bitdht_peers.cc index cf2d2af97..950b1bfd8 100644 --- a/libretroshare/src/dht/p3bitdht_peers.cc +++ b/libretroshare/src/dht/p3bitdht_peers.cc @@ -1,30 +1,25 @@ -/* - * libretroshare/src/dht: p3bitdht.h - * - * BitDht interface for RetroShare. - * - * Copyright 2009-2010 by Robert Fernie. - * Copyright (C) 2015-2018 Gioacchino Mazzurco - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - +/******************************************************************************* + * libretroshare/src/dht: p3bitdht_peernet.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2009-2010 by Robert Fernie. * + * Copyright (C) 2015-2018 Gioacchino Mazzurco * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "dht/p3bitdht.h" #include "bitdht/bdstddht.h" diff --git a/libretroshare/src/dht/p3bitdht_relay.cc b/libretroshare/src/dht/p3bitdht_relay.cc index d846e7691..8939da5c7 100644 --- a/libretroshare/src/dht/p3bitdht_relay.cc +++ b/libretroshare/src/dht/p3bitdht_relay.cc @@ -1,27 +1,24 @@ -/* - * libretroshare/src/dht: p3bitdht.h - * - * BitDht interface for RetroShare. - * - * Copyright 2009-2011 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ +/******************************************************************************* + * libretroshare/src/dht: p3bitdht_relay.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2009-2011 by Robert Fernie. * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + ******************************************************************************/ #include "util/rsnet.h" #include "dht/p3bitdht.h" diff --git a/libretroshare/src/dht/stunaddrassist.h b/libretroshare/src/dht/stunaddrassist.h index 1df0bfabc..195337b1a 100644 --- a/libretroshare/src/dht/stunaddrassist.h +++ b/libretroshare/src/dht/stunaddrassist.h @@ -1,28 +1,24 @@ -/* - * libretroshare/src/dht: stunaddrassist.h - * - * BitDht interface for RetroShare. - * - * Copyright 2011-2011 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/dht: stunaddrassist.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2011-2011 by Robert Fernie. * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + ******************************************************************************/ #ifndef STUN_ADDR_ASSIST_H #define STUN_ADDR_ASSIST_H diff --git a/libretroshare/src/file_sharing/dir_hierarchy.cc b/libretroshare/src/file_sharing/dir_hierarchy.cc index c2b7baa44..743176e38 100644 --- a/libretroshare/src/file_sharing/dir_hierarchy.cc +++ b/libretroshare/src/file_sharing/dir_hierarchy.cc @@ -1,27 +1,24 @@ -/* - * RetroShare Internal directory storage class. - * - * file_sharing/dir_hierarchy.cc - * - * Copyright 2016 Mr.Alice - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare.project@gmail.com". - * - */ +/******************************************************************************* + * libretroshare/src/file_sharing: dir_hierarchy.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2016 by Mr.Alice * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + ******************************************************************************/ #include #include #include diff --git a/libretroshare/src/file_sharing/dir_hierarchy.h b/libretroshare/src/file_sharing/dir_hierarchy.h index 0eeda5e6f..50b8217b0 100644 --- a/libretroshare/src/file_sharing/dir_hierarchy.h +++ b/libretroshare/src/file_sharing/dir_hierarchy.h @@ -1,29 +1,24 @@ -/* - * RetroShare C++ Internal directory hierarchy class. - * - * file_sharing/dir_hierarchy.h - * - * Copyright 2016 by Mr.Alice - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare.project@gmail.com". - * - */ - - +/******************************************************************************* + * libretroshare/src/file_sharing: dir_hierarchy.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2016 by Mr.Alice * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + ******************************************************************************/ #pragma once #include diff --git a/libretroshare/src/file_sharing/directory_storage.cc b/libretroshare/src/file_sharing/directory_storage.cc index d39401e06..a0164a94b 100644 --- a/libretroshare/src/file_sharing/directory_storage.cc +++ b/libretroshare/src/file_sharing/directory_storage.cc @@ -1,27 +1,24 @@ -/* - * RetroShare File list storage system. - * - * file_sharing/directory_storage.cc - * - * Copyright 2016 Mr.Alice - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare.project@gmail.com". - * - */ +/******************************************************************************* + * libretroshare/src/file_sharing: directory_storage.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2016 by Mr.Alice * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + ******************************************************************************/ #include #include #include "serialiser/rstlvbinary.h" diff --git a/libretroshare/src/file_sharing/directory_storage.h b/libretroshare/src/file_sharing/directory_storage.h index 22377bb0b..e7c4d14b7 100644 --- a/libretroshare/src/file_sharing/directory_storage.h +++ b/libretroshare/src/file_sharing/directory_storage.h @@ -1,28 +1,24 @@ -/* - * RetroShare C++ Directory Storage system. - * - * file_sharing/directory_storage.h - * - * Copyright 2016 by Mr.Alice - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare.project@gmail.com". - * - */ - +/******************************************************************************* + * libretroshare/src/file_sharing: directory_storage.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2016 by Mr.Alice * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + ******************************************************************************/ #pragma once #include diff --git a/libretroshare/src/file_sharing/directory_updater.cc b/libretroshare/src/file_sharing/directory_updater.cc index dffef92c7..3bf125839 100644 --- a/libretroshare/src/file_sharing/directory_updater.cc +++ b/libretroshare/src/file_sharing/directory_updater.cc @@ -1,27 +1,24 @@ -/* - * RetroShare Directory watching system. - * - * file_sharing/directory_updater.cc - * - * Copyright 2016 Mr.Alice - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare.project@gmail.com". - * - */ +/******************************************************************************* + * libretroshare/src/file_sharing: directory_updater.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2016 by Mr.Alice * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + ******************************************************************************/ #include "util/folderiterator.h" #include "util/rstime.h" #include "rsserver/p3face.h" diff --git a/libretroshare/src/file_sharing/directory_updater.h b/libretroshare/src/file_sharing/directory_updater.h index 4c6e05649..366e1330e 100644 --- a/libretroshare/src/file_sharing/directory_updater.h +++ b/libretroshare/src/file_sharing/directory_updater.h @@ -1,28 +1,24 @@ -/* - * RetroShare C++ Directory parsing code. - * - * file_sharing/directory_updater.h - * - * Copyright 2016 by Mr.Alice - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare.project@gmail.com". - * - */ - +/******************************************************************************* + * libretroshare/src/file_sharing: directory_updater.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2016 by Mr.Alice * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + ******************************************************************************/ // This class crawls the given directry hierarchy and updates it. It does so by calling the // shared file list source. This source may be of two types: diff --git a/libretroshare/src/file_sharing/file_sharing_defaults.h b/libretroshare/src/file_sharing/file_sharing_defaults.h index 8de4b31c8..6633e348f 100644 --- a/libretroshare/src/file_sharing/file_sharing_defaults.h +++ b/libretroshare/src/file_sharing/file_sharing_defaults.h @@ -1,49 +1,45 @@ -/* - * RetroShare C++ File sharing default variables - * - * file_sharing/file_sharing_defaults.h - * - * Copyright 2016 by Mr.Alice - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare.project@gmail.com". - * - */ - - +/******************************************************************************* + * libretroshare/src/file_sharing: file_sharing_defaults.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2016 by Mr.Alice * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + ******************************************************************************/ #pragma once -static const uint32_t DELAY_BETWEEN_DIRECTORY_UPDATES = 600 ; // 10 minutes -static const uint32_t DELAY_BETWEEN_REMOTE_DIRECTORY_SYNC_REQ = 120 ; // 2 minutes -static const uint32_t DELAY_BETWEEN_LOCAL_DIRECTORIES_TS_UPDATE = 20 ; // 20 sec. But we only update for real if something has changed. -static const uint32_t DELAY_BETWEEN_REMOTE_DIRECTORIES_SWEEP = 60 ; // 60 sec. +static const uint32_t DELAY_BETWEEN_DIRECTORY_UPDATES = 600 ; // 10 minutes +static const uint32_t DELAY_BETWEEN_REMOTE_DIRECTORY_SYNC_REQ = 120 ; // 2 minutes +static const uint32_t DELAY_BETWEEN_LOCAL_DIRECTORIES_TS_UPDATE = 20 ; // 20 sec. But we only update for real if something has changed. +static const uint32_t DELAY_BETWEEN_REMOTE_DIRECTORIES_SWEEP = 60 ; // 60 sec. static const uint32_t DELAY_BEFORE_DELETE_NON_EMPTY_REMOTE_DIR = 60*24*86400 ; // delete non empty remoe directories after 60 days of inactivity static const uint32_t DELAY_BEFORE_DELETE_EMPTY_REMOTE_DIR = 5*24*86400 ; // delete empty remote directories after 5 days of inactivity -static const std::string HASH_CACHE_DURATION_SS = "HASH_CACHE_DURATION" ; // key string to store hash remembering time -static const std::string WATCH_FILE_DURATION_SS = "WATCH_FILES_DELAY" ; // key to store delay before re-checking for new files -static const std::string WATCH_FILE_ENABLED_SS = "WATCH_FILES_ENABLED"; // key to store ON/OFF flags for file whatch -static const std::string FOLLOW_SYMLINKS_SS = "FOLLOW_SYMLINKS"; // dereference symbolic links, or just ignore them. -static const std::string IGNORE_DUPLICATES = "IGNORE_DUPLICATES"; // do not index files that are referenced multiple times because of links -static const std::string WATCH_HASH_SALT_SS = "WATCH_HASH_SALT"; // Salt that is used to hash directory names -static const std::string IGNORED_PREFIXES_SS = "IGNORED_PREFIXES"; // ignore file prefixes -static const std::string IGNORED_SUFFIXES_SS = "IGNORED_SUFFIXES"; // ignore file suffixes -static const std::string IGNORE_LIST_FLAGS_SS = "IGNORED_FLAGS"; // ignore file flags -static const std::string MAX_SHARE_DEPTH = "MAX_SHARE_DEPTH"; // maximum depth of shared directories +static const std::string HASH_CACHE_DURATION_SS = "HASH_CACHE_DURATION" ; // key string to store hash remembering time +static const std::string WATCH_FILE_DURATION_SS = "WATCH_FILES_DELAY" ; // key to store delay before re-checking for new files +static const std::string WATCH_FILE_ENABLED_SS = "WATCH_FILES_ENABLED"; // key to store ON/OFF flags for file whatch +static const std::string TRUST_FRIEND_NODES_FOR_BANNED_FILES_SS = "TRUST_FRIEND_NODES_FOR_BANNED_FILES"; // should we trust friends for banned files or not +static const std::string FOLLOW_SYMLINKS_SS = "FOLLOW_SYMLINKS"; // dereference symbolic links, or just ignore them. +static const std::string IGNORE_DUPLICATES = "IGNORE_DUPLICATES"; // do not index files that are referenced multiple times because of links +static const std::string WATCH_HASH_SALT_SS = "WATCH_HASH_SALT"; // Salt that is used to hash directory names +static const std::string IGNORED_PREFIXES_SS = "IGNORED_PREFIXES"; // ignore file prefixes +static const std::string IGNORED_SUFFIXES_SS = "IGNORED_SUFFIXES"; // ignore file suffixes +static const std::string IGNORE_LIST_FLAGS_SS = "IGNORED_FLAGS"; // ignore file flags +static const std::string MAX_SHARE_DEPTH = "MAX_SHARE_DEPTH"; // maximum depth of shared directories static const std::string FILE_SHARING_DIR_NAME = "file_sharing" ; // hard-coded directory name to store friend file lists, hash cache, etc. static const std::string HASH_CACHE_FILE_NAME = "hash_cache.bin" ; // hard-coded directory name to store encrypted hash cache. @@ -66,6 +62,7 @@ static const uint64_t ENTRY_INDEX_BIT_MASK_64BITS = 0x0000000 static const uint32_t DELAY_BEFORE_DROP_REQUEST = 600; // every 10 min -static const bool FOLLOW_SYMLINKS_DEFAULT = true; +static const bool FOLLOW_SYMLINKS_DEFAULT = true; +static const bool TRUST_FRIEND_NODES_FOR_BANNED_FILES_DEFAULT = true; static const uint32_t FL_BASE_TMP_SECTION_SIZE = 4096 ; diff --git a/libretroshare/src/file_sharing/file_tree.cc b/libretroshare/src/file_sharing/file_tree.cc index 92ee6a362..e96217804 100644 --- a/libretroshare/src/file_sharing/file_tree.cc +++ b/libretroshare/src/file_sharing/file_tree.cc @@ -1,3 +1,24 @@ +/******************************************************************************* + * libretroshare/src/file_sharing: file_tree.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2018 by Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + ******************************************************************************/ #include #include #include diff --git a/libretroshare/src/file_sharing/file_tree.h b/libretroshare/src/file_sharing/file_tree.h index 0505ceed5..c5328a6df 100644 --- a/libretroshare/src/file_sharing/file_tree.h +++ b/libretroshare/src/file_sharing/file_tree.h @@ -1,28 +1,24 @@ -/* - * RetroShare C++ File lists IO methods. - * - * file_sharing/file_tree.h - * - * Copyright 2017 by csoler - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare.project@gmail.com". - * - */ - +/******************************************************************************* + * libretroshare/src/file_sharing: file_tree.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2018 by Cyril Soler * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + ******************************************************************************/ #include "retroshare/rsfiles.h" class FileTreeImpl: public FileTree diff --git a/libretroshare/src/file_sharing/filelist_io.cc b/libretroshare/src/file_sharing/filelist_io.cc index 15d4d1b53..baf34f710 100644 --- a/libretroshare/src/file_sharing/filelist_io.cc +++ b/libretroshare/src/file_sharing/filelist_io.cc @@ -1,28 +1,24 @@ -/* - * RetroShare File lists IO methods. - * - * file_sharing/filelist_io.h - * - * Copyright 2016 Mr.Alice - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare.project@gmail.com". - * - */ - +/******************************************************************************* + * libretroshare/src/file_sharing: filelist_io.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2018 by Mr.Alice * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + ******************************************************************************/ #include #include "retroshare/rsids.h" #include "pqi/authssl.h" @@ -198,10 +194,10 @@ bool FileListIO::loadEncryptedDataFromFile(const std::string& fname,unsigned cha { uint64_t file_size ; - if(!RsDirUtil::checkFile( fname,file_size,false ) ) + if(!RsDirUtil::checkFile( fname,file_size,true ) ) { #ifdef FIM_DEBUG - std::cerr << "Encrypted file " << fname << " not available." << std::endl; + std::cerr << "Encrypted file " << fname << " not available or empty." << std::endl; #endif return false; } diff --git a/libretroshare/src/file_sharing/filelist_io.h b/libretroshare/src/file_sharing/filelist_io.h index 8eccd6b27..65863ffd0 100644 --- a/libretroshare/src/file_sharing/filelist_io.h +++ b/libretroshare/src/file_sharing/filelist_io.h @@ -1,29 +1,24 @@ -/* - * RetroShare C++ File lists IO methods. - * - * file_sharing/filelist_io.h - * - * Copyright 2016 by Mr.Alice - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare.project@gmail.com". - * - */ - - +/******************************************************************************* + * libretroshare/src/file_sharing: filelist_io.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2018 by Mr.Alice * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + ******************************************************************************/ #pragma once #include diff --git a/libretroshare/src/file_sharing/hash_cache.cc b/libretroshare/src/file_sharing/hash_cache.cc index f0db680cf..d40f49581 100644 --- a/libretroshare/src/file_sharing/hash_cache.cc +++ b/libretroshare/src/file_sharing/hash_cache.cc @@ -1,27 +1,24 @@ -/* - * RetroShare Hash cache - * - * file_sharing/hash_cache.cc - * - * Copyright 2016 Mr.Alice - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare.project@gmail.com". - * - */ +/******************************************************************************* + * libretroshare/src/file_sharing: hash_cache.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2018 by Mr.Alice * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + ******************************************************************************/ #include "util/rsdir.h" #include "util/rsprint.h" #include "util/rstime.h" @@ -30,6 +27,7 @@ #include "hash_cache.h" #include "filelist_io.h" #include "file_sharing_defaults.h" +#include "retroshare/rsinit.h" //#define HASHSTORAGE_DEBUG 1 @@ -481,7 +479,7 @@ bool HashStorage::try_load_import_old_hash_cache() { // compute file name - std::string base_dir = rsAccounts->PathAccountDirectory(); + std::string base_dir = RsAccounts::AccountDirectory(); std::string old_cache_filename = base_dir + "/" + "file_cache.bin" ; // check for unencrypted diff --git a/libretroshare/src/file_sharing/hash_cache.h b/libretroshare/src/file_sharing/hash_cache.h index 05dcbd9c3..f9123b998 100644 --- a/libretroshare/src/file_sharing/hash_cache.h +++ b/libretroshare/src/file_sharing/hash_cache.h @@ -1,27 +1,24 @@ -/* - * RetroShare C++ Hash cache. - * - * file_sharing/hash_cache.h - * - * Copyright 2016 by Mr.Alice - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare.project@gmail.com". - * - */ +/******************************************************************************* + * libretroshare/src/file_sharing: hash_cache.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2018 by Mr.Alice * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + ******************************************************************************/ #pragma once diff --git a/libretroshare/src/file_sharing/p3filelists.cc b/libretroshare/src/file_sharing/p3filelists.cc index 3eaaa9d03..156490e18 100644 --- a/libretroshare/src/file_sharing/p3filelists.cc +++ b/libretroshare/src/file_sharing/p3filelists.cc @@ -1,27 +1,24 @@ -/* - * RetroShare File lists service. - * - * file_sharing/p3filelists.cc - * - * Copyright 2016 Mr.Alice - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare.project@gmail.com". - * - */ +/******************************************************************************* + * libretroshare/src/file_sharing: p3filelists.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2018 by Mr.Alice * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + ******************************************************************************/ #include "rsitems/rsserviceids.h" #include "file_sharing/p3filelists.h" @@ -32,7 +29,7 @@ #include "retroshare/rsids.h" #include "retroshare/rspeers.h" -#include "rsserver/rsaccounts.h" +#include "retroshare/rsinit.h" #include "rsserver/p3face.h" @@ -40,6 +37,7 @@ #define P3FILELISTS_ERROR() std::cerr << "***ERROR***" << " : FILE_LISTS : " << __FUNCTION__ << " : " //#define DEBUG_P3FILELISTS 1 +#define DEBUG_CONTENT_FILTERING 1 static const uint32_t P3FILELISTS_UPDATE_FLAG_NOTHING_CHANGED = 0x0000 ; static const uint32_t P3FILELISTS_UPDATE_FLAG_REMOTE_MAP_CHANGED = 0x0001 ; @@ -51,7 +49,7 @@ p3FileDatabase::p3FileDatabase(p3ServiceControl *mpeers) { // make sure the base directory exists - std::string base_dir = rsAccounts->PathAccountDirectory(); + std::string base_dir = RsAccounts::AccountDirectory(); if(base_dir.empty()) throw std::runtime_error("Cannot create base directory to store/access file sharing files.") ; @@ -75,6 +73,8 @@ p3FileDatabase::p3FileDatabase(p3ServiceControl *mpeers) mLastRemoteDirSweepTS = 0 ; mLastCleanupTime = 0 ; mLastDataRecvTS = 0 ; + mTrustFriendNodesForBannedFiles = TRUST_FRIEND_NODES_FOR_BANNED_FILES_DEFAULT; + mLastPrimaryBanListChangeTimeStamp = 0; // This is for the transmission of data @@ -185,15 +185,19 @@ int p3FileDatabase::tick() if(last_print_time + 20 < now) { - RS_STACK_MUTEX(mFLSMtx) ; + { + RS_STACK_MUTEX(mFLSMtx) ; #ifdef DEBUG_FILE_HIERARCHY - mLocalSharedDirs->print(); + mLocalSharedDirs->print(); #endif - last_print_time = now ; + last_print_time = now ; + } #warning mr-alice 2016-08-19: "This should be removed, but it's necessary atm for updating the GUI" RsServer::notify()->notifyListChange(NOTIFY_LIST_DIRLIST_LOCAL, 0); + + checkSendBannedFilesInfo(); } if(mUpdateFlags) @@ -307,6 +311,15 @@ cleanup = true; } } + { + RS_STACK_MUTEX(mFLSMtx) ; + + RsFileListsBannedHashesConfigItem *item = new RsFileListsBannedHashesConfigItem ; + + item->primary_banned_files_list = mPrimaryBanList; + sList.push_back(item) ; + } + RsConfigKeyValueSet *rskv = new RsConfigKeyValueSet(); /* basic control parameters */ @@ -372,6 +385,14 @@ cleanup = true; { RsTlvKeyValue kv; + kv.key = TRUST_FRIEND_NODES_FOR_BANNED_FILES_SS; + kv.value = trustFriendNodesForBannedFiles()?"YES":"NO" ; + + rskv->tlvkvs.pairs.push_back(kv); + } + { + RsTlvKeyValue kv; + kv.key = WATCH_HASH_SALT_SS; kv.value = mLocalDirWatcher->hashSalt().toStdString(); @@ -465,6 +486,10 @@ bool p3FileDatabase::loadList(std::list& load) { setWatchEnabled(kit->value == "YES") ; } + else if(kit->key == TRUST_FRIEND_NODES_FOR_BANNED_FILES_SS) + { + setTrustFriendNodesForBannedFiles(kit->value == "YES") ; + } else if(kit->key == WATCH_HASH_SALT_SS) { std::cerr << "Initing directory watcher with saved secret salt..." << std::endl; @@ -536,6 +561,15 @@ bool p3FileDatabase::loadList(std::list& load) dirList.push_back(info) ; } + RsFileListsBannedHashesConfigItem *fb = dynamic_cast(*it) ; + + if(fb) + { + mPrimaryBanList = fb->primary_banned_files_list ; + mBannedFileListNeedsUpdate = true; + mLastPrimaryBanListChangeTimeStamp = time(NULL); + } + delete *it ; } @@ -1405,8 +1439,8 @@ void p3FileDatabase::tickRecv() { switch(item->PacketSubType()) { - case RS_PKT_SUBTYPE_FILELISTS_SYNC_REQ_ITEM: handleDirSyncRequest( dynamic_cast(item) ) ; - break ; + case RS_PKT_SUBTYPE_FILELISTS_SYNC_REQ_ITEM: handleDirSyncRequest( dynamic_cast(item) ) ; break ; + case RS_PKT_SUBTYPE_FILELISTS_BANNED_HASHES_ITEM : handleBannedFilesInfo( dynamic_cast(item) ) ; break ; case RS_PKT_SUBTYPE_FILELISTS_SYNC_RSP_ITEM: { RsFileListsSyncResponseItem *sitem = dynamic_cast(item); @@ -1858,6 +1892,262 @@ bool p3FileDatabase::locked_generateAndSendSyncRequest(RemoteDirectoryStorage *r } +//=========================================================================================================================// +// Unwanted content filtering system // +//=========================================================================================================================// +bool p3FileDatabase::banFile(const RsFileHash& real_file_hash, const std::string& filename, uint64_t file_size) +{ +#ifdef DEBUG_CONTENT_FILTERING + P3FILELISTS_DEBUG() << " setting file \"" << filename << "\" size=" << file_size << " hash=" << real_file_hash << " as banned." << std::endl; +#endif + { + RS_STACK_MUTEX(mFLSMtx) ; + BannedFileEntry& entry(mPrimaryBanList[real_file_hash]) ; // primary list (user controlled) of files banned from FT search and forwarding. map + if(entry.ban_time_stamp == 0) + { + entry.filename = filename ; + entry.size = file_size ; + entry.ban_time_stamp = time(NULL); + + RsFileHash hash_of_hash ; + ftServer::encryptHash(real_file_hash,hash_of_hash) ; + + mBannedFileList.insert(real_file_hash) ; + mBannedFileList.insert(hash_of_hash) ; + + mLastPrimaryBanListChangeTimeStamp = time(NULL); + mBannedFileListNeedsUpdate = true ; + } + } + + IndicateConfigChanged(); + return true; +} +bool p3FileDatabase::unbanFile(const RsFileHash& real_file_hash) +{ +#ifdef DEBUG_CONTENT_FILTERING + P3FILELISTS_DEBUG() << " unbanning file with hash " << real_file_hash << std::endl; +#endif + { + RS_STACK_MUTEX(mFLSMtx) ; + mPrimaryBanList.erase(real_file_hash) ; + mLastPrimaryBanListChangeTimeStamp = time(NULL); + mBannedFileListNeedsUpdate = true ; + } + + IndicateConfigChanged(); + return true; +} + +bool p3FileDatabase::isFileBanned(const RsFileHash& hash) +{ + RS_STACK_MUTEX(mFLSMtx) ; + + if(mBannedFileList.empty()) // quick exit + return false ; + + RsFileHash hash_of_hash ; + ftServer::encryptHash(hash,hash_of_hash) ; + + bool res = mBannedFileList.find(hash) != mBannedFileList.end() || mBannedFileList.find(hash_of_hash) != mBannedFileList.end() ; + +#ifdef DEBUG_CONTENT_FILTERING + if(res) + P3FILELISTS_DEBUG() << " is file banned(" << hash << "): " << (res?"YES":"NO") << std::endl; +#endif + return res ; +} + +bool p3FileDatabase::getPrimaryBannedFilesList(std::map& banned_files) +{ + RS_STACK_MUTEX(mFLSMtx) ; + banned_files = mPrimaryBanList; + + return true ; +} + +bool p3FileDatabase::trustFriendNodesForBannedFiles() const +{ + RS_STACK_MUTEX(mFLSMtx) ; + return mTrustFriendNodesForBannedFiles; +} + +void p3FileDatabase::setTrustFriendNodesForBannedFiles(bool b) +{ + if(b != mTrustFriendNodesForBannedFiles) + { + IndicateConfigChanged(); + mBannedFileListNeedsUpdate = true; + } + + RS_STACK_MUTEX(mFLSMtx) ; + mTrustFriendNodesForBannedFiles = b; +} + +void p3FileDatabase::checkSendBannedFilesInfo() +{ + RS_STACK_MUTEX(mFLSMtx) ; + + // 1 - compare records to list of online friends, send own info of not already + +#ifdef DEBUG_CONTENT_FILTERING + P3FILELISTS_DEBUG() << " Checking banned files information: " << std::endl; +#endif + + time_t now = time(NULL); + std::list online_friends ; + rsPeers->getOnlineList(online_friends); + + std::set peers ; + for(auto it(online_friends.begin());it!=online_friends.end();++it) // convert to std::set for efficient search + peers.insert(*it) ; + + for(auto it(mPeerBannedFiles.begin());it!=mPeerBannedFiles.end();) + { + if(peers.find(it->first) == peers.end()) // friend not online, remove his record + { + it = mPeerBannedFiles.erase(it) ; +#ifdef DEBUG_CONTENT_FILTERING + P3FILELISTS_DEBUG() << " Peer " << it->first << " is offline: removign record." << std::endl; +#endif + continue; + } + + if(it->second.mLastSent < mLastPrimaryBanListChangeTimeStamp) // has ban info already been sent? If not do it. + { +#ifdef DEBUG_CONTENT_FILTERING + P3FILELISTS_DEBUG() << " Peer " << it->first << " is online and hasn't been sent since last change: sending..." << std::endl; +#endif + locked_sendBanInfo(it->first); + it->second.mLastSent = now; + } + + peers.erase(it->first); // friend has been handled -> remove from list + ++it; + } + + // 2 - add a new record for friends not already in the record map + + for(auto it(peers.begin());it!=peers.end();++it) + { + locked_sendBanInfo(*it); + mPeerBannedFiles[*it].mLastSent = now; +#ifdef DEBUG_CONTENT_FILTERING + P3FILELISTS_DEBUG() << " Peer " << *it << " is online and hasn't been sent info at all: sending..." << std::endl; +#endif + } + + // 3 - update list of banned hashes if it has changed somehow + + if(mBannedFileListNeedsUpdate) + { + mBannedFileList.clear(); + +#ifdef DEBUG_CONTENT_FILTERING + P3FILELISTS_DEBUG() << " Creating local banned file list: " << std::endl; +#endif + // Add all H(H(f)) from friends + + if(mTrustFriendNodesForBannedFiles) + for(auto it(mPeerBannedFiles.begin());it!=mPeerBannedFiles.end();++it) + for(auto it2(it->second.mBannedHashOfHash.begin());it2!=it->second.mBannedHashOfHash.end();++it2) + { + mBannedFileList.insert(*it2); + +#ifdef DEBUG_CONTENT_FILTERING + P3FILELISTS_DEBUG() << " from " << it->first << ": H(H(f)) = " << *it2 << std::endl; +#endif + } + + // Add H(f) and H(H(f)) from our primary list + + for(auto it(mPrimaryBanList.begin());it!=mPrimaryBanList.end();++it) + { + mBannedFileList.insert(it->first) ; + + RsFileHash hash_of_hash ; + ftServer::encryptHash(it->first,hash_of_hash) ; + + mBannedFileList.insert(hash_of_hash) ; + +#ifdef DEBUG_CONTENT_FILTERING + P3FILELISTS_DEBUG() << " primary: H(f) = " << it->first << ": H(H(f)) = " << hash_of_hash << std::endl; +#endif + } + + mBannedFileListNeedsUpdate = false ; + } + +#ifdef DEBUG_CONTENT_FILTERING + P3FILELISTS_DEBUG() << " Final list of locally banned hashes contains: " << mBannedFileList.size() << " elements." << std::endl; +#endif +} + +void p3FileDatabase::locked_sendBanInfo(const RsPeerId& peer) +{ + RsFileListsBannedHashesItem *item = new RsFileListsBannedHashesItem ; + uint32_t session_id = RSRandom::random_u32(); + + item->session_id = session_id ; + item->PeerId(peer); + + for(auto it(mPrimaryBanList.begin());it!=mPrimaryBanList.end();++it) + { + RsFileHash hash_of_hash ; + + ftServer::encryptHash(it->first,hash_of_hash) ; + + if(!item) + { + item = new RsFileListsBannedHashesItem ; + + item->PeerId(peer); + item->session_id = session_id ; + } + + item->encrypted_hashes.insert(hash_of_hash) ; + + if(item->encrypted_hashes.size() >= 200) + { + sendItem(item); + item = NULL ; + } + } + + if(item) + sendItem(item); +} + +void p3FileDatabase::handleBannedFilesInfo(RsFileListsBannedHashesItem *item) +{ + RS_STACK_MUTEX(mFLSMtx) ; + +#ifdef DEBUG_CONTENT_FILTERING + P3FILELISTS_DEBUG() << " received banned files info from peer " << item->PeerId() << ", session id = " << std::hex << item->session_id << std::dec << ": " << item->encrypted_hashes.size() << " files:" << std::endl; +#endif + // 1 - localize the friend in the banned file map + + PeerBannedFilesEntry& pbfe(mPeerBannedFiles[item->PeerId()]) ; + + if(pbfe.mSessionId != item->session_id) + pbfe.mBannedHashOfHash.clear(); + + pbfe.mSessionId = item->session_id ; + + // 2 - replace/update the list, depending on the session_id + + for(auto it(item->encrypted_hashes.begin());it!=item->encrypted_hashes.end();++it) + { + pbfe.mBannedHashOfHash.insert(*it); +#ifdef DEBUG_CONTENT_FILTERING + P3FILELISTS_DEBUG() << " added H(H(f)) = " << *it << std::endl; +#endif + } + + // 3 - tell the updater that the banned file list has changed + + mBannedFileListNeedsUpdate = true ; +} diff --git a/libretroshare/src/file_sharing/p3filelists.h b/libretroshare/src/file_sharing/p3filelists.h index 4de5e24b3..a8ac377ea 100644 --- a/libretroshare/src/file_sharing/p3filelists.h +++ b/libretroshare/src/file_sharing/p3filelists.h @@ -1,28 +1,24 @@ -/* - * RetroShare C++ File lists service. - * - * file_sharing/p3filelists.h - * - * Copyright 2016 by Mr.Alice - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare.project@gmail.com". - * - */ - +/******************************************************************************* + * libretroshare/src/file_sharing: p3filelists.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2018 by Mr.Alice * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + ******************************************************************************/ // // This class is responsible for @@ -66,9 +62,17 @@ class LocalDirectoryStorage ; class RsFileListsSyncRequestItem ; class RsFileListsSyncResponseItem ; +class RsFileListsBannedHashesItem ; class HashStorage ; +struct PeerBannedFilesEntry +{ + std::set mBannedHashOfHash; + uint32_t mSessionId ; // used for when a friend sends multiple packets in separate items. + time_t mLastSent; +}; + class p3FileDatabase: public p3Service, public p3Config, public ftSearch //, public RsSharedFileService { public: @@ -136,6 +140,13 @@ class p3FileDatabase: public p3Service, public p3Config, public ftSearch //, pub void setMaxShareDepth(int i) ; int maxShareDepth() const ; + bool banFile(const RsFileHash& real_file_hash, const std::string& filename, uint64_t file_size) ; + bool unbanFile(const RsFileHash& real_file_hash); + bool isFileBanned(const RsFileHash& hash) ; + bool getPrimaryBannedFilesList(std::map& banned_files) ; + bool trustFriendNodesForBannedFiles() const ; + void setTrustFriendNodesForBannedFiles(bool b) ; + // computes/gathers statistics about shared directories int getSharedDirStatistics(const RsPeerId& pid,SharedDirStats& stats); @@ -172,6 +183,8 @@ class p3FileDatabase: public p3Service, public p3Config, public ftSearch //, pub void tickRecv(); void tickSend(); + void checkSendBannedFilesInfo(); + private: p3ServiceControl *mServCtrl ; RsPeerId mOwnId ; @@ -248,5 +261,18 @@ class p3FileDatabase: public p3Service, public p3Config, public ftSearch //, pub std::string mFileSharingDir ; time_t mLastCleanupTime; time_t mLastDataRecvTS ; + + // File filtering. Not explicitly related to shared files, but has its place here + // + + std::map mPrimaryBanList ; // primary list (user controlled) of files banned from FT search and forwarding. map + std::map mPeerBannedFiles ; // records of which files other peers ban, stored as H(H(f)) + std::set mBannedFileList ; // list of banned hashes. This include original hashs and H(H(f)) when coming from friends. + bool mTrustFriendNodesForBannedFiles ; + bool mBannedFileListNeedsUpdate; + time_t mLastPrimaryBanListChangeTimeStamp; + + void locked_sendBanInfo(const RsPeerId& pid); + void handleBannedFilesInfo(RsFileListsBannedHashesItem *item); }; diff --git a/libretroshare/src/file_sharing/rsfilelistitems.cc b/libretroshare/src/file_sharing/rsfilelistitems.cc index 7d91549d4..c443d1f3a 100644 --- a/libretroshare/src/file_sharing/rsfilelistitems.cc +++ b/libretroshare/src/file_sharing/rsfilelistitems.cc @@ -1,27 +1,24 @@ -/* - * RetroShare File lists service items - * - * file_sharing/rsfilelistsitems.cc - * - * Copyright 2016 Mr.Alice - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare.project@gmail.com". - * - */ +/******************************************************************************* + * libretroshare/src/file_sharing: rsfilelistsitems.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2018 by Mr.Alice * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + ******************************************************************************/ #include "serialiser/rsbaseserial.h" #include "serialiser/rstypeserializer.h" @@ -37,14 +34,28 @@ void RsFileListsSyncRequestItem::serial_process(RsGenericSerializer::SerializeJo } void RsFileListsSyncResponseItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx) { - RsTypeSerializer::serial_process (j,ctx,entry_hash,"entry_hash") ; - RsTypeSerializer::serial_process (j,ctx,checksum,"checksum") ; - RsTypeSerializer::serial_process (j,ctx,flags ,"flags") ; + RsTypeSerializer::serial_process (j,ctx,entry_hash, "entry_hash") ; + RsTypeSerializer::serial_process (j,ctx,checksum, "checksum") ; + RsTypeSerializer::serial_process (j,ctx,flags, "flags") ; RsTypeSerializer::serial_process (j,ctx,last_known_recurs_modf_TS,"last_known_recurs_modf_TS") ; - RsTypeSerializer::serial_process (j,ctx,request_id,"request_id") ; - RsTypeSerializer::serial_process(j,ctx,directory_content_data,"directory_content_data") ; + RsTypeSerializer::serial_process (j,ctx,request_id, "request_id") ; + RsTypeSerializer::serial_process(j,ctx,directory_content_data, "directory_content_data") ; +} +void RsFileListsBannedHashesItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx) +{ + RsTypeSerializer::serial_process(j,ctx,session_id ,"session_id") ; + RsTypeSerializer::serial_process(j,ctx,encrypted_hashes,"encrypted_hashes") ; +} +void RsFileListsBannedHashesConfigItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx) +{ + RsTypeSerializer::serial_process(j,ctx,primary_banned_files_list,"primary_banned_files_list") ; +} +template<> void RsTypeSerializer::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx,BannedFileEntry& entry,const std::string& /*name*/) +{ + RsTypeSerializer::serial_process (j,ctx,TLV_TYPE_STR_NAME,entry.filename ,"entry.file_name") ; + RsTypeSerializer::serial_process(j,ctx, entry.size ,"entry.size") ; + RsTypeSerializer::serial_process (j,ctx, entry.ban_time_stamp,"entry.ban_time_stamp") ; } - RsItem *RsFileListsSerialiser::create_item(uint16_t service,uint8_t type) const { if(service != RS_SERVICE_TYPE_FILE_DATABASE) @@ -52,8 +63,10 @@ RsItem *RsFileListsSerialiser::create_item(uint16_t service,uint8_t type) const switch(type) { - case RS_PKT_SUBTYPE_FILELISTS_SYNC_REQ_ITEM: return new RsFileListsSyncRequestItem(); - case RS_PKT_SUBTYPE_FILELISTS_SYNC_RSP_ITEM: return new RsFileListsSyncResponseItem(); + case RS_PKT_SUBTYPE_FILELISTS_SYNC_REQ_ITEM: return new RsFileListsSyncRequestItem(); + case RS_PKT_SUBTYPE_FILELISTS_SYNC_RSP_ITEM: return new RsFileListsSyncResponseItem(); + case RS_PKT_SUBTYPE_FILELISTS_BANNED_HASHES_ITEM: return new RsFileListsBannedHashesItem(); + case RS_PKT_SUBTYPE_FILELISTS_BANNED_HASHES_CONFIG_ITEM: return new RsFileListsBannedHashesConfigItem(); default: return NULL ; } diff --git a/libretroshare/src/file_sharing/rsfilelistitems.h b/libretroshare/src/file_sharing/rsfilelistitems.h index 2f04a84a5..a8c84e18b 100644 --- a/libretroshare/src/file_sharing/rsfilelistitems.h +++ b/libretroshare/src/file_sharing/rsfilelistitems.h @@ -1,27 +1,24 @@ -/* - * RetroShare File lists service items. - * - * file_sharing/rsfilelistitems.h - * - * Copyright 2016 Mr.Alice - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare.project@gmail.com". - * - */ +/******************************************************************************* + * libretroshare/src/file_sharing: rsfilelistsitems.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2018 by Mr.Alice * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + ******************************************************************************/ #pragma once #include @@ -36,12 +33,13 @@ #include "gxs/rsgxsdata.h" #include "serialiser/rsserializer.h" +#include "retroshare/rsfiles.h" -// These items have "flag type" numbers, but this is not used. - -const uint8_t RS_PKT_SUBTYPE_FILELISTS_SYNC_REQ_ITEM = 0x01; -const uint8_t RS_PKT_SUBTYPE_FILELISTS_SYNC_RSP_ITEM = 0x02; -const uint8_t RS_PKT_SUBTYPE_FILELISTS_CONFIG_ITEM = 0x03; +const uint8_t RS_PKT_SUBTYPE_FILELISTS_SYNC_REQ_ITEM = 0x01; +const uint8_t RS_PKT_SUBTYPE_FILELISTS_SYNC_RSP_ITEM = 0x02; +const uint8_t RS_PKT_SUBTYPE_FILELISTS_CONFIG_ITEM = 0x03; +const uint8_t RS_PKT_SUBTYPE_FILELISTS_BANNED_HASHES_ITEM = 0x04; +const uint8_t RS_PKT_SUBTYPE_FILELISTS_BANNED_HASHES_CONFIG_ITEM = 0x05; /*! * Base class for filelist sync items @@ -106,6 +104,29 @@ public: RsTlvBinaryData directory_content_data ; // encoded binary data. This allows to vary the encoding format, in a way that is transparent to the serialiser. }; +class RsFileListsBannedHashesItem: public RsFileListsItem +{ +public: + RsFileListsBannedHashesItem() : RsFileListsItem(RS_PKT_SUBTYPE_FILELISTS_BANNED_HASHES_ITEM){} + + virtual void clear() { encrypted_hashes.clear(); } + virtual void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx); + + uint32_t session_id ; // used to allow to send in multiple parts. + std::set encrypted_hashes ;// hash of hash for each banned file. +}; + +class RsFileListsBannedHashesConfigItem: public RsFileListsItem +{ +public: + RsFileListsBannedHashesConfigItem() : RsFileListsItem(RS_PKT_SUBTYPE_FILELISTS_BANNED_HASHES_CONFIG_ITEM){} + + virtual void clear() { primary_banned_files_list.clear(); } + virtual void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx); + + std::map primary_banned_files_list ; +}; + class RsFileListsSerialiser : public RsServiceSerializer { public: diff --git a/libretroshare/src/ft/ftchunkmap.cc b/libretroshare/src/ft/ftchunkmap.cc index 800408ec6..622926c7a 100644 --- a/libretroshare/src/ft/ftchunkmap.cc +++ b/libretroshare/src/ft/ftchunkmap.cc @@ -1,27 +1,24 @@ -/* - * libretroshare/src/ft: ftdata.cc - * - * File Transfer for RetroShare. - * - * Copyright 2010 by Cyril Soler - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "csoler@users.sourceforge.net". - * - */ +/******************************************************************************* + * libretroshare/src/ft: ftchunkmap.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2010 by Cyril Soler * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + ******************************************************************************/ /******** * #define DEBUG_FTCHUNK 1 diff --git a/libretroshare/src/ft/ftchunkmap.h b/libretroshare/src/ft/ftchunkmap.h index f7c696b9a..a9307b966 100644 --- a/libretroshare/src/ft/ftchunkmap.h +++ b/libretroshare/src/ft/ftchunkmap.h @@ -1,3 +1,25 @@ +/******************************************************************************* + * libretroshare/src/ft: ftchunkmap.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2010 by Cyril Soler * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + ******************************************************************************/ + #pragma once #include diff --git a/libretroshare/src/ft/ftcontroller.cc b/libretroshare/src/ft/ftcontroller.cc index 9abec040f..bb0a56588 100644 --- a/libretroshare/src/ft/ftcontroller.cc +++ b/libretroshare/src/ft/ftcontroller.cc @@ -1,27 +1,24 @@ -/* - * libretroshare/src/ft: ftcontroller.cc - * - * File Transfer for RetroShare. - * - * Copyright 2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ +/******************************************************************************* + * libretroshare/src/ft: ftcontroller.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2008 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ /* * ftController diff --git a/libretroshare/src/ft/ftcontroller.h b/libretroshare/src/ft/ftcontroller.h index 564660879..6564ae7be 100644 --- a/libretroshare/src/ft/ftcontroller.h +++ b/libretroshare/src/ft/ftcontroller.h @@ -1,27 +1,24 @@ -/* - * libretroshare/src/ft: ftcontroller.h - * - * File Transfer for RetroShare. - * - * Copyright 2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ +/******************************************************************************* + * libretroshare/src/ft: ftcontroller.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2008 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef FT_CONTROLLER_HEADER #define FT_CONTROLLER_HEADER diff --git a/libretroshare/src/ft/ftdata.h b/libretroshare/src/ft/ftdata.h index 909195009..349dae521 100644 --- a/libretroshare/src/ft/ftdata.h +++ b/libretroshare/src/ft/ftdata.h @@ -1,28 +1,24 @@ -/* - * libretroshare/src/ft: ftdata.h - * - * File Transfer for RetroShare. - * - * Copyright 2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/ft: ftdata.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2008 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef FT_DATA_INTERFACE_HEADER #define FT_DATA_INTERFACE_HEADER diff --git a/libretroshare/src/ft/ftdatamultiplex.cc b/libretroshare/src/ft/ftdatamultiplex.cc index ad16e0e4c..56cdd9f52 100644 --- a/libretroshare/src/ft/ftdatamultiplex.cc +++ b/libretroshare/src/ft/ftdatamultiplex.cc @@ -1,27 +1,24 @@ -/* - * libretroshare/src/ft: ftdatamultiplex.h - * - * File Transfer for RetroShare. - * - * Copyright 2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ +/******************************************************************************* + * libretroshare/src/ft: ftdatamultiplex.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2008 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ /* * ftDataMultiplexModule. diff --git a/libretroshare/src/ft/ftdatamultiplex.h b/libretroshare/src/ft/ftdatamultiplex.h index 1679e7832..57acda1f2 100644 --- a/libretroshare/src/ft/ftdatamultiplex.h +++ b/libretroshare/src/ft/ftdatamultiplex.h @@ -1,27 +1,24 @@ -/* - * libretroshare/src/ft: ftdatamultiplex.h - * - * File Transfer for RetroShare. - * - * Copyright 2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ +/******************************************************************************* + * libretroshare/src/ft: ftdatamultiplex.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2008 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef FT_DATA_MULTIPLEX_HEADER #define FT_DATA_MULTIPLEX_HEADER diff --git a/libretroshare/src/ft/ftextralist.cc b/libretroshare/src/ft/ftextralist.cc index b6fec4076..cf5a4f603 100644 --- a/libretroshare/src/ft/ftextralist.cc +++ b/libretroshare/src/ft/ftextralist.cc @@ -1,27 +1,24 @@ -/* - * libretroshare/src/ft: ftextralist.cc - * - * File Transfer for RetroShare. - * - * Copyright 2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ +/******************************************************************************* + * libretroshare/src/ft: ftextralist.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2008 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifdef WINDOWS_SYS #include "util/rswin.h" diff --git a/libretroshare/src/ft/ftextralist.h b/libretroshare/src/ft/ftextralist.h index 211e66dc6..5832b33fd 100644 --- a/libretroshare/src/ft/ftextralist.h +++ b/libretroshare/src/ft/ftextralist.h @@ -1,27 +1,24 @@ -/* - * libretroshare/src/ft: ftextralist.h - * - * File Transfer for RetroShare. - * - * Copyright 2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ +/******************************************************************************* + * libretroshare/src/ft: ftextralist.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2008 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef FT_FILE_EXTRA_LIST_HEADER #define FT_FILE_EXTRA_LIST_HEADER diff --git a/libretroshare/src/ft/ftfilecreator.cc b/libretroshare/src/ft/ftfilecreator.cc index 56bf78bf7..fc25fe426 100644 --- a/libretroshare/src/ft/ftfilecreator.cc +++ b/libretroshare/src/ft/ftfilecreator.cc @@ -1,3 +1,24 @@ +/******************************************************************************* + * libretroshare/src/ft: ftfilecreator.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2008 by Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifdef WINDOWS_SYS #include "util/rsstring.h" #include "util/rswin.h" diff --git a/libretroshare/src/ft/ftfilecreator.h b/libretroshare/src/ft/ftfilecreator.h index 68820c160..004558307 100644 --- a/libretroshare/src/ft/ftfilecreator.h +++ b/libretroshare/src/ft/ftfilecreator.h @@ -1,27 +1,24 @@ -/* - * libretroshare/src/ft/ ftfilecreator.h - * - * File Transfer for RetroShare. - * - * Copyright 2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ +/******************************************************************************* + * libretroshare/src/ft: ftfilecreator.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2008 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef FT_FILE_CREATOR_HEADER #define FT_FILE_CREATOR_HEADER diff --git a/libretroshare/src/ft/ftfileprovider.cc b/libretroshare/src/ft/ftfileprovider.cc index e613694c1..543464515 100644 --- a/libretroshare/src/ft/ftfileprovider.cc +++ b/libretroshare/src/ft/ftfileprovider.cc @@ -1,3 +1,24 @@ +/******************************************************************************* + * libretroshare/src/ft: ftfileprovider.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2008 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifdef WINDOWS_SYS #include "util/rswin.h" #endif // WINDOWS_SYS diff --git a/libretroshare/src/ft/ftfileprovider.h b/libretroshare/src/ft/ftfileprovider.h index 8b6acf9f6..f0d9d60d1 100644 --- a/libretroshare/src/ft/ftfileprovider.h +++ b/libretroshare/src/ft/ftfileprovider.h @@ -1,27 +1,24 @@ -/* - * libretroshare/src/ft ftFileProvider.h - * - * File Transfer for RetroShare. - * - * Copyright 2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ +/******************************************************************************* + * libretroshare/src/ft: ftfileprovider.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2008 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef FT_FILE_PROVIDER_HEADER #define FT_FILE_PROVIDER_HEADER diff --git a/libretroshare/src/ft/ftfilesearch.cc b/libretroshare/src/ft/ftfilesearch.cc index 4aae20e05..c9571f9a8 100644 --- a/libretroshare/src/ft/ftfilesearch.cc +++ b/libretroshare/src/ft/ftfilesearch.cc @@ -1,28 +1,24 @@ -/* - * libretroshare/src/ft: ftfilesearch.cc - * - * File Transfer for RetroShare. - * - * Copyright 2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/ft: ftfilesearch.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2008 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "ft/ftfilesearch.h" const uint32_t MAX_SEARCHS = 24; /* lower 24 bits of hint */ diff --git a/libretroshare/src/ft/ftfilesearch.h b/libretroshare/src/ft/ftfilesearch.h index ce714ff71..46c11d33c 100644 --- a/libretroshare/src/ft/ftfilesearch.h +++ b/libretroshare/src/ft/ftfilesearch.h @@ -1,27 +1,24 @@ -/* - * libretroshare/src/ft: ftfilesearch.h - * - * File Transfer for RetroShare. - * - * Copyright 2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ +/******************************************************************************* + * libretroshare/src/ft: ftfilesearch.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2008 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef FT_FILE_SEARCH_HEADER #define FT_FILE_SEARCH_HEADER diff --git a/libretroshare/src/ft/ftsearch.h b/libretroshare/src/ft/ftsearch.h index 710e3ee92..7906d275f 100644 --- a/libretroshare/src/ft/ftsearch.h +++ b/libretroshare/src/ft/ftsearch.h @@ -1,28 +1,24 @@ -/* - * libretroshare/src/ft: ftsearch.h - * - * File Transfer for RetroShare. - * - * Copyright 2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/ft: ftsearch.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2008 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef FT_SEARCH_HEADER #define FT_SEARCH_HEADER diff --git a/libretroshare/src/ft/ftserver.cc b/libretroshare/src/ft/ftserver.cc index a3c344460..182964446 100644 --- a/libretroshare/src/ft/ftserver.cc +++ b/libretroshare/src/ft/ftserver.cc @@ -1,27 +1,24 @@ -/* - * libretroshare/src/ft: ftserver.cc - * - * File Transfer for RetroShare. - * - * Copyright 2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ +/******************************************************************************* + * libretroshare/src/ft: ftserver.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2008 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "crypto/chacha20.h" //const int ftserverzone = 29539; @@ -42,12 +39,12 @@ #include "retroshare/rstypes.h" #include "retroshare/rspeers.h" +#include "retroshare/rsinit.h" #include "rsitems/rsfiletransferitems.h" #include "rsitems/rsserviceids.h" #include "rsserver/p3face.h" -#include "rsserver/rsaccounts.h" #include "turtle/p3turtle.h" #include "util/rsdebug.h" @@ -74,7 +71,8 @@ ftServer::ftServer(p3PeerMgr *pm, p3ServiceControl *sc) mPeerMgr(pm), mServiceCtrl(sc), mFileDatabase(NULL), mFtController(NULL), mFtExtra(NULL), - mFtDataplex(NULL), mFtSearch(NULL), srvMutex("ftServer") + mFtDataplex(NULL), mFtSearch(NULL), srvMutex("ftServer"), + mSearchCallbacksMapMutex("ftServer callbacks map") { addSerialType(new RsFileTransferSerialiser()) ; } @@ -151,8 +149,9 @@ void ftServer::SetupFtServer() mFtController = new ftController(mFtDataplex, mServiceCtrl, getServiceInfo().mServiceType); mFtController -> setFtSearchNExtra(mFtSearch, mFtExtra); - std::string emergencySaveDir = rsAccounts->PathAccountDirectory(); - std::string emergencyPartialsDir = rsAccounts->PathAccountDirectory(); + std::string emergencySaveDir = RsAccounts::AccountDirectory(); + std::string emergencyPartialsDir = RsAccounts::AccountDirectory(); + if (emergencySaveDir != "") { emergencySaveDir += "/"; @@ -427,7 +426,7 @@ void ftServer::requestDirUpdate(void *ref) } /* Directory Handling */ -bool ftServer::setDownloadDirectory(std::string path) +bool ftServer::setDownloadDirectory(const std::string& path) { return mFtController->setDownloadDirectory(path); } @@ -437,7 +436,7 @@ std::string ftServer::getDownloadDirectory() return mFtController->getDownloadDirectory(); } -bool ftServer::setPartialsDirectory(std::string path) +bool ftServer::setPartialsDirectory(const std::string& path) { return mFtController->setPartialsDirectory(path); } @@ -1234,6 +1233,21 @@ static const uint8_t ENCRYPTED_FT_FORMAT_AEAD_CHACHA20_SHA256 = 0x02 ; bool ftServer::encryptItem(RsTurtleGenericTunnelItem *clear_item,const RsFileHash& hash,RsTurtleGenericDataItem *& encrypted_item) { +#ifndef USE_NEW_METHOD + uint32_t item_serialized_size = size(clear_item) ; + + RsTemporaryMemory data(item_serialized_size) ; + + if(data == NULL) + return false ; + + serialise(clear_item, data, &item_serialized_size); + + uint8_t encryption_key[32] ; + deriveEncryptionKey(hash,encryption_key) ; + + return p3turtle::encryptData(data,item_serialized_size,encryption_key,encrypted_item) ; +#else uint8_t initialization_vector[ENCRYPTED_FT_INITIALIZATION_VECTOR_SIZE] ; RSRandom::random_bytes(initialization_vector,ENCRYPTED_FT_INITIALIZATION_VECTOR_SIZE) ; @@ -1312,12 +1326,34 @@ bool ftServer::encryptItem(RsTurtleGenericTunnelItem *clear_item,const RsFileHas #endif return true ; +#endif } // Decrypts the given item using aead-chacha20-poly1305 -bool ftServer::decryptItem(RsTurtleGenericDataItem *encrypted_item,const RsFileHash& hash,RsTurtleGenericTunnelItem *& decrypted_item) +bool ftServer::decryptItem(const RsTurtleGenericDataItem *encrypted_item,const RsFileHash& hash,RsTurtleGenericTunnelItem *& decrypted_item) { +#ifndef USE_NEW_METHOD + unsigned char *data = NULL ; + uint32_t data_size = 0 ; + + uint8_t encryption_key[32] ; + deriveEncryptionKey(hash,encryption_key) ; + + if(!p3turtle::decryptItem(encrypted_item,encryption_key,data,data_size)) + { + FTSERVER_ERROR() << "Cannot decrypt data!" << std::endl; + + if(data) + free(data) ; + return false ; + } + decrypted_item = dynamic_cast(deserialise(data,&data_size)) ; + free(data); + + return (decrypted_item != NULL); + +#else uint8_t encryption_key[32] ; deriveEncryptionKey(hash,encryption_key) ; @@ -1393,6 +1429,7 @@ bool ftServer::decryptItem(RsTurtleGenericDataItem *encrypted_item,const RsFileH return false ; return true ; +#endif } bool ftServer::encryptHash(const RsFileHash& hash, RsFileHash& hash_of_hash) @@ -1430,9 +1467,34 @@ bool ftServer::findRealHash(const RsFileHash& hash, RsFileHash& real_hash) return false ; } +TurtleSearchRequestId ftServer::turtleSearch(const std::string& string_to_match) +{ + return mTurtleRouter->turtleSearch(string_to_match) ; +} +TurtleSearchRequestId ftServer::turtleSearch(const RsRegularExpression::LinearizedExpression& expr) +{ + return mTurtleRouter->turtleSearch(expr) ; +} + +#warning we should do this here, but for now it is done by turtle router. +// // Dont delete the item. The client (p3turtle) is doing it after calling this. +// // +// void ftServer::receiveSearchResult(RsTurtleSearchResultItem *item) +// { +// RsTurtleFTSearchResultItem *ft_sr = dynamic_cast(item) ; +// +// if(ft_sr == NULL) +// { +// FTSERVER_ERROR() << "(EE) ftServer::receiveSearchResult(): item cannot be cast to a RsTurtleFTSearchResultItem" << std::endl; +// return ; +// } +// +// RsServer::notify()->notifyTurtleSearchResult(ft_sr->request_id,ft_sr->result) ; +// } + // Dont delete the item. The client (p3turtle) is doing it after calling this. // -void ftServer::receiveTurtleData(RsTurtleGenericTunnelItem *i, +void ftServer::receiveTurtleData(const RsTurtleGenericTunnelItem *i, const RsFileHash& hash, const RsPeerId& virtual_peer_id, RsTurtleGenericTunnelItem::Direction direction) @@ -1452,7 +1514,7 @@ void ftServer::receiveTurtleData(RsTurtleGenericTunnelItem *i, } RsTurtleGenericTunnelItem *decrypted_item ; - if(!decryptItem(dynamic_cast(i),real_hash,decrypted_item)) + if(!decryptItem(dynamic_cast(i),real_hash,decrypted_item)) { FTSERVER_ERROR() << "(EE) decryption error." << std::endl; return ; @@ -1468,7 +1530,7 @@ void ftServer::receiveTurtleData(RsTurtleGenericTunnelItem *i, { case RS_TURTLE_SUBTYPE_FILE_REQUEST: { - RsTurtleFileRequestItem *item = dynamic_cast(i) ; + const RsTurtleFileRequestItem *item = dynamic_cast(i) ; if (item) { #ifdef SERVER_DEBUG @@ -1481,7 +1543,7 @@ void ftServer::receiveTurtleData(RsTurtleGenericTunnelItem *i, case RS_TURTLE_SUBTYPE_FILE_DATA : { - RsTurtleFileDataItem *item = dynamic_cast(i) ; + const RsTurtleFileDataItem *item = dynamic_cast(i) ; if (item) { #ifdef SERVER_DEBUG @@ -1489,7 +1551,7 @@ void ftServer::receiveTurtleData(RsTurtleGenericTunnelItem *i, #endif getMultiplexer()->recvData(virtual_peer_id,hash,0,item->chunk_offset,item->chunk_size,item->chunk_data) ; - item->chunk_data = NULL ; // this prevents deletion in the destructor of RsFileDataItem, because data will be deleted + const_cast(item)->chunk_data = NULL ; // this prevents deletion in the destructor of RsFileDataItem, because data will be deleted // down _ft_server->getMultiplexer()->recvData()...in ftTransferModule::recvFileData } } @@ -1497,7 +1559,7 @@ void ftServer::receiveTurtleData(RsTurtleGenericTunnelItem *i, case RS_TURTLE_SUBTYPE_FILE_MAP : { - RsTurtleFileMapItem *item = dynamic_cast(i) ; + const RsTurtleFileMapItem *item = dynamic_cast(i) ; if (item) { #ifdef SERVER_DEBUG @@ -1520,7 +1582,7 @@ void ftServer::receiveTurtleData(RsTurtleGenericTunnelItem *i, case RS_TURTLE_SUBTYPE_CHUNK_CRC : { - RsTurtleChunkCrcItem *item = dynamic_cast(i) ; + const RsTurtleChunkCrcItem *item = dynamic_cast(i) ; if (item) { #ifdef SERVER_DEBUG @@ -1533,7 +1595,7 @@ void ftServer::receiveTurtleData(RsTurtleGenericTunnelItem *i, case RS_TURTLE_SUBTYPE_CHUNK_CRC_REQUEST: { - RsTurtleChunkCrcRequestItem *item = dynamic_cast(i) ; + const RsTurtleChunkCrcRequestItem *item = dynamic_cast(i) ; if (item) { #ifdef SERVER_DEBUG @@ -1569,6 +1631,7 @@ int ftServer::tick() mFtDataplex->deleteUnusedServers() ; mFtDataplex->handlePendingCrcRequests() ; mFtDataplex->dispatchReceivedChunkCheckSum() ; + cleanTimedOutSearches(); } return moreToTick; @@ -1759,15 +1822,90 @@ int ftServer::handleIncoming() ********************************** *********************************/ +void ftServer::receiveSearchResult(RsTurtleFTSearchResultItem *item) +{ + bool hasCallback = false; + + { + RS_STACK_MUTEX(mSearchCallbacksMapMutex); + auto cbpt = mSearchCallbacksMap.find(item->request_id); + if(cbpt != mSearchCallbacksMap.end()) + { + hasCallback = true; + cbpt->second.first(item->result); + } + } // end RS_STACK_MUTEX(mSearchCallbacksMapMutex); + + if(!hasCallback) + RsServer::notify()->notifyTurtleSearchResult(item->PeerId(),item->request_id, item->result ); +} + /***************************** CONFIG ****************************/ bool ftServer::addConfiguration(p3ConfigMgr *cfgmgr) { /* add all the subbits to config mgr */ - cfgmgr->addConfiguration("ft_database.cfg", mFileDatabase); - cfgmgr->addConfiguration("ft_extra.cfg", mFtExtra); + cfgmgr->addConfiguration("ft_database.cfg" , mFileDatabase); + cfgmgr->addConfiguration("ft_extra.cfg" , mFtExtra ); cfgmgr->addConfiguration("ft_transfers.cfg", mFtController); return true; } +bool ftServer::turtleSearchRequest( + const std::string& matchString, + const std::function& results)>& multiCallback, + std::time_t maxWait ) +{ + if(matchString.empty()) + { + std::cerr << __PRETTY_FUNCTION__ << " match string can't be empty!" + << std::endl; + return false; + } + + TurtleRequestId sId = turtleSearch(matchString); + + RS_STACK_MUTEX(mSearchCallbacksMapMutex); + mSearchCallbacksMap.emplace( + sId, + std::make_pair( + multiCallback, + std::chrono::system_clock::now() + + std::chrono::seconds(maxWait) ) ); + + return true; +} + +void ftServer::cleanTimedOutSearches() +{ + RS_STACK_MUTEX(mSearchCallbacksMapMutex); + auto now = std::chrono::system_clock::now(); + for( auto cbpt = mSearchCallbacksMap.begin(); + cbpt != mSearchCallbacksMap.end(); ) + if(cbpt->second.second <= now) + cbpt = mSearchCallbacksMap.erase(cbpt); + else ++cbpt; +} + +// Offensive content file filtering + +int ftServer::banFile(const RsFileHash& real_file_hash, const std::string& filename, uint64_t file_size) +{ + return mFileDatabase->banFile(real_file_hash,filename,file_size) ; +} +int ftServer::unbanFile(const RsFileHash& real_file_hash) +{ + return mFileDatabase->unbanFile(real_file_hash) ; +} +bool ftServer::getPrimaryBannedFilesList(std::map& banned_files) +{ + return mFileDatabase->getPrimaryBannedFilesList(banned_files) ; +} + +bool ftServer::isHashBanned(const RsFileHash& hash) +{ + return mFileDatabase->isFileBanned(hash); +} + + diff --git a/libretroshare/src/ft/ftserver.h b/libretroshare/src/ft/ftserver.h index 440113d11..c15c991fc 100644 --- a/libretroshare/src/ft/ftserver.h +++ b/libretroshare/src/ft/ftserver.h @@ -1,27 +1,24 @@ -/* - * libretroshare/src/ft: ftserver.h - * - * File Transfer for RetroShare. - * - * Copyright 2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ +/******************************************************************************* + * libretroshare/src/ft: ftserver.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2008 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef FT_SERVER_HEADER #define FT_SERVER_HEADER @@ -42,6 +39,8 @@ #include #include #include +#include +#include #include "ft/ftdata.h" #include "turtle/turtleclientservice.h" @@ -95,8 +94,11 @@ public: // Implements RsTurtleClientService // + + uint16_t serviceId() const { return RS_SERVICE_TYPE_FILE_TRANSFER ; } virtual bool handleTunnelRequest(const RsFileHash& hash,const RsPeerId& peer_id) ; - virtual void receiveTurtleData(RsTurtleGenericTunnelItem *item,const RsFileHash& hash,const RsPeerId& virtual_peer_id,RsTurtleGenericTunnelItem::Direction direction) ; + virtual void receiveTurtleData(const RsTurtleGenericTunnelItem *item,const RsFileHash& hash,const RsPeerId& virtual_peer_id,RsTurtleGenericTunnelItem::Direction direction) ; + virtual void receiveSearchResult(RsTurtleFTSearchResultItem *item); virtual RsItem *create_item(uint16_t service,uint8_t item_type) const ; virtual RsServiceSerializer *serializer() { return this ; } @@ -143,6 +145,15 @@ public: virtual void setFilePermDirectDL(uint32_t perm) ; virtual uint32_t filePermDirectDL() ; + /// @see RsFiles + virtual bool turtleSearchRequest( + const std::string& matchString, + const std::function& results)>& multiCallback, + std::time_t maxWait = 300 ); + + virtual TurtleSearchRequestId turtleSearch(const std::string& string_to_match) ; + virtual TurtleSearchRequestId turtleSearch(const RsRegularExpression::LinearizedExpression& expr) ; + /*** * Control of Downloads Priority. ***/ @@ -189,6 +200,11 @@ public: virtual int SearchBoolExp(RsRegularExpression::Expression * exp, std::list &results,FileSearchFlags flags,const RsPeerId& peer_id); virtual int getSharedDirStatistics(const RsPeerId& pid, SharedDirStats& stats) ; + virtual int banFile(const RsFileHash& real_file_hash, const std::string& filename, uint64_t file_size) ; + virtual int unbanFile(const RsFileHash& real_file_hash); + virtual bool getPrimaryBannedFilesList(std::map& banned_files) ; + virtual bool isHashBanned(const RsFileHash& hash); + /*** * Utility Functions ***/ @@ -202,8 +218,8 @@ public: * Directory Handling ***/ virtual void requestDirUpdate(void *ref) ; // triggers the update of the given reference. Used when browsing. - virtual bool setDownloadDirectory(std::string path); - virtual bool setPartialsDirectory(std::string path); + virtual bool setDownloadDirectory(const std::string& path); + virtual bool setPartialsDirectory(const std::string& path); virtual std::string getDownloadDirectory(); virtual std::string getPartialsDirectory(); @@ -234,6 +250,8 @@ public: virtual bool ignoreDuplicates() ; virtual void setIgnoreDuplicates(bool ignore) ; + static bool encryptHash(const RsFileHash& hash, RsFileHash& hash_of_hash); + /***************************************************************/ /*************** Data Transfer Interface ***********************/ /***************************************************************/ @@ -250,7 +268,7 @@ public: static void deriveEncryptionKey(const RsFileHash& hash, uint8_t *key); bool encryptItem(RsTurtleGenericTunnelItem *clear_item,const RsFileHash& hash,RsTurtleGenericDataItem *& encrypted_item); - bool decryptItem(RsTurtleGenericDataItem *encrypted_item, const RsFileHash& hash, RsTurtleGenericTunnelItem *&decrypted_item); + bool decryptItem(const RsTurtleGenericDataItem *encrypted_item, const RsFileHash& hash, RsTurtleGenericTunnelItem *&decrypted_item); /*************** Internal Transfer Fns *************************/ virtual int tick(); @@ -279,7 +297,6 @@ protected: // fnds out what is the real hash of encrypted hash hash bool findRealHash(const RsFileHash& hash, RsFileHash& real_hash); bool findEncryptedHash(const RsPeerId& virtual_peer_id, RsFileHash& encrypted_hash); - bool encryptHash(const RsFileHash& hash, RsFileHash& hash_of_hash); bool checkUploadLimit(const RsPeerId& pid,const RsFileHash& hash); private: @@ -310,6 +327,18 @@ private: std::map mEncryptedHashes ; // This map is such that sha1(it->second) = it->first std::map mEncryptedPeerIds ; // This map holds the hash to be used with each peer id std::map > mUploadLimitMap ; + + /** Store search callbacks with timeout*/ + std::map< + TurtleRequestId, + std::pair< + std::function& results)>, + std::chrono::system_clock::time_point > + > mSearchCallbacksMap; + RsMutex mSearchCallbacksMapMutex; + + /// Cleanup mSearchCallbacksMap + void cleanTimedOutSearches(); }; diff --git a/libretroshare/src/ft/fttransfermodule.cc b/libretroshare/src/ft/fttransfermodule.cc index 46d10c400..136be4653 100644 --- a/libretroshare/src/ft/fttransfermodule.cc +++ b/libretroshare/src/ft/fttransfermodule.cc @@ -1,28 +1,24 @@ -/* - * libretroshare/src/ft: fttransfermodule.cc - * - * File Transfer for RetroShare. - * - * Copyright 2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/ft: fttransfermodule.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2008 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ /****** * #define FT_DEBUG 1 *****/ diff --git a/libretroshare/src/ft/fttransfermodule.h b/libretroshare/src/ft/fttransfermodule.h index 02cf0212d..9999cbdc1 100644 --- a/libretroshare/src/ft/fttransfermodule.h +++ b/libretroshare/src/ft/fttransfermodule.h @@ -1,26 +1,24 @@ -/* - * Retroshare file transfer module: ftTransferModule.h - * - * Copyright 2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/ft: fttransfermodule.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2008 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef FT_TRANSFER_MODULE_HEADER #define FT_TRANSFER_MODULE_HEADER diff --git a/libretroshare/src/ft/ftturtlefiletransferitem.cc b/libretroshare/src/ft/ftturtlefiletransferitem.cc index 44722af4b..14150e42d 100644 --- a/libretroshare/src/ft/ftturtlefiletransferitem.cc +++ b/libretroshare/src/ft/ftturtlefiletransferitem.cc @@ -1,28 +1,24 @@ -/* - * libretroshare/src/services: ftturtlefiletransferitem.cc - * - * Services for RetroShare. - * - * Copyright 2013 by Cyril Soler - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "csoler@users.sourceforge.net". - * - */ - +/******************************************************************************* + * libretroshare/src/ft: ftturtlefiletransferitem.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2013 by Cyril Soler * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include #include diff --git a/libretroshare/src/ft/ftturtlefiletransferitem.h b/libretroshare/src/ft/ftturtlefiletransferitem.h index a2aa18034..6bbc24aef 100644 --- a/libretroshare/src/ft/ftturtlefiletransferitem.h +++ b/libretroshare/src/ft/ftturtlefiletransferitem.h @@ -1,28 +1,24 @@ -/* - * libretroshare/src/services: ftturtlefiletransferitem.h - * - * Services for RetroShare. - * - * Copyright 2013 by Cyril Soler - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "csoler@users.sourceforge.net". - * - */ - +/******************************************************************************* + * libretroshare/src/ft: ftturtlefiletransferitem.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2013 by Cyril Soler * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include #include diff --git a/libretroshare/src/grouter/groutercache.h b/libretroshare/src/grouter/groutercache.h index b30362857..e406976b8 100644 --- a/libretroshare/src/grouter/groutercache.h +++ b/libretroshare/src/grouter/groutercache.h @@ -1,28 +1,24 @@ -/* - * libretroshare/src/services: groutercache.h - * - * Services for RetroShare. - * - * Copyright 2013 by Cyril Soler - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "csoler@users.sourceforge.net". - * - */ - +/******************************************************************************* + * libretroshare/src/grouter: groutercache.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2013 by Cyril Soler * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once #include "retroshare/rsflags.h" diff --git a/libretroshare/src/grouter/grouteritems.cc b/libretroshare/src/grouter/grouteritems.cc index 5fc4813a7..1e098de00 100644 --- a/libretroshare/src/grouter/grouteritems.cc +++ b/libretroshare/src/grouter/grouteritems.cc @@ -1,3 +1,24 @@ +/******************************************************************************* + * libretroshare/src/grouter: grouteritems.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2013 by Cyril Soler * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "util/rsprint.h" #include "serialiser/rsbaseserial.h" #include "serialiser/rstlvbase.h" diff --git a/libretroshare/src/grouter/grouteritems.h b/libretroshare/src/grouter/grouteritems.h index 9777c074b..43b69be7d 100644 --- a/libretroshare/src/grouter/grouteritems.h +++ b/libretroshare/src/grouter/grouteritems.h @@ -1,28 +1,24 @@ -/* - * libretroshare/src/services: rsgrouteritems.h - * - * Services for RetroShare. - * - * Copyright 2013 by Cyril Soler - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "csoler@users.sourceforge.net". - * - */ - +/******************************************************************************* + * libretroshare/src/grouter: grouteritems.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2013 by Cyril Soler * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once #include "util/rsmemory.h" diff --git a/libretroshare/src/grouter/groutertypes.h b/libretroshare/src/grouter/groutertypes.h index df8c90d48..ee1bda7dc 100644 --- a/libretroshare/src/grouter/groutertypes.h +++ b/libretroshare/src/grouter/groutertypes.h @@ -1,28 +1,24 @@ -/* - * libretroshare/src/services: groutermatrix.h - * - * Services for RetroShare. - * - * Copyright 2013 by Cyril Soler - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "csoler@users.sourceforge.net". - * - */ - +/******************************************************************************* + * libretroshare/src/grouter: groutertypes.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2013 by Cyril Soler * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once #include diff --git a/libretroshare/src/grouter/p3grouter.cc b/libretroshare/src/grouter/p3grouter.cc index d184b15f5..eacd3a34f 100644 --- a/libretroshare/src/grouter/p3grouter.cc +++ b/libretroshare/src/grouter/p3grouter.cc @@ -1,27 +1,24 @@ -/* - * libretroshare/src/services: p3grouter.cc - * - * Services for RetroShare. - * - * Copyright 2013 by Cyril Soler - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "csoler@users.sourceforge.net". - * - */ +/******************************************************************************* + * libretroshare/src/grouter: p3grouter.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2013 by Cyril Soler * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ //////////////////////////////////////////////////////////////////////////////////////////////////////////// // @@ -482,7 +479,7 @@ void p3GRouter::handleLowLevelTransactionAckItem(RsGRouterTransactionAcknItem *t #endif } -void p3GRouter::receiveTurtleData(RsTurtleGenericTunnelItem *gitem, const RsFileHash &/*hash*/, const RsPeerId &virtual_peer_id, RsTurtleGenericTunnelItem::Direction /*direction*/) +void p3GRouter::receiveTurtleData(const RsTurtleGenericTunnelItem *gitem, const RsFileHash &/*hash*/, const RsPeerId &virtual_peer_id, RsTurtleGenericTunnelItem::Direction /*direction*/) { #ifdef GROUTER_DEBUG std::cerr << "p3GRouter::receiveTurtleData() " << std::endl; @@ -496,7 +493,7 @@ void p3GRouter::receiveTurtleData(RsTurtleGenericTunnelItem *gitem, const RsFile // - possibly packs multi-item blocks back together // - converts it into a grouter generic item (by deserialising it) - RsTurtleGenericDataItem *item = dynamic_cast(gitem) ; + const RsTurtleGenericDataItem *item = dynamic_cast(gitem) ; if(item == NULL) { @@ -510,7 +507,8 @@ void p3GRouter::receiveTurtleData(RsTurtleGenericTunnelItem *gitem, const RsFile // Items come out of the pipe in order. We need to recover all chunks before we de-serialise the content and have it handled by handleIncoming() - RsItem *itm = RsGRouterSerialiser().deserialise(item->data_bytes,&item->data_size) ; + uint32_t size = item->data_size ; + RsItem *itm = RsGRouterSerialiser().deserialise(item->data_bytes,&size); if(itm == NULL) { diff --git a/libretroshare/src/grouter/p3grouter.h b/libretroshare/src/grouter/p3grouter.h index 71b2fc138..935b84a40 100644 --- a/libretroshare/src/grouter/p3grouter.h +++ b/libretroshare/src/grouter/p3grouter.h @@ -1,28 +1,24 @@ -/* - * libretroshare/src/services: p3grouter.h - * - * Services for RetroShare. - * - * Copyright 2013 by Cyril Soler - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "csoler@users.sourceforge.net". - * - */ - +/******************************************************************************* + * libretroshare/src/grouter: p3grouter.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2013 by Cyril Soler * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once #include @@ -208,8 +204,9 @@ protected: // Interaction with turtle router // //===================================================// + uint16_t serviceId() const { return RS_SERVICE_TYPE_GROUTER; } virtual bool handleTunnelRequest(const RsFileHash& /*hash*/,const RsPeerId& /*peer_id*/) ; - virtual void receiveTurtleData(RsTurtleGenericTunnelItem */*item*/,const RsFileHash& /*hash*/,const RsPeerId& /*virtual_peer_id*/,RsTurtleGenericTunnelItem::Direction /*direction*/); + virtual void receiveTurtleData(const RsTurtleGenericTunnelItem */*item*/,const RsFileHash& /*hash*/,const RsPeerId& /*virtual_peer_id*/,RsTurtleGenericTunnelItem::Direction /*direction*/); virtual void addVirtualPeer(const TurtleFileHash& hash,const TurtleVirtualPeerId& virtual_peer_id,RsTurtleGenericTunnelItem::Direction dir) ; virtual void removeVirtualPeer(const TurtleFileHash& hash,const TurtleVirtualPeerId& virtual_peer_id) ; diff --git a/libretroshare/src/gxs/gxssecurity.cc b/libretroshare/src/gxs/gxssecurity.cc index 7d200ab86..608e938fc 100644 --- a/libretroshare/src/gxs/gxssecurity.cc +++ b/libretroshare/src/gxs/gxssecurity.cc @@ -1,29 +1,25 @@ - -/* - * libretroshare/src/gxs: gxssecurity.cc - * - * - * Copyright 2008-2010 by Robert Fernie - * 2011-2012 Christopher Evi-Parker - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/gxs: gxssecurity.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2008-2010 by Robert Fernie * + * 2011-2012 Christopher Evi-Parker * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "gxssecurity.h" #include "pqi/authgpg.h" #include "util/rsdir.h" diff --git a/libretroshare/src/gxs/gxssecurity.h b/libretroshare/src/gxs/gxssecurity.h index 57cffcd2a..7b607c916 100644 --- a/libretroshare/src/gxs/gxssecurity.h +++ b/libretroshare/src/gxs/gxssecurity.h @@ -1,32 +1,28 @@ +/******************************************************************************* + * libretroshare/src/gxs: gxssecurity.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2008-2010 by Robert Fernie * + * 2011-2012 Christopher Evi-Parker * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef GXSSECURITY_H #define GXSSECURITY_H -/* - * libretroshare/src/gxs: gxssecurity.h - * - * Security functions for Gxs - * - * Copyright 2008-2010 by Robert Fernie - * 2011-2012 Christopher Evi-Parker - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - #include "serialiser/rstlvkeys.h" #include "rsitems/rsnxsitems.h" diff --git a/libretroshare/src/gxs/gxstokenqueue.cc b/libretroshare/src/gxs/gxstokenqueue.cc index b857ee1a8..c5ebf87fd 100644 --- a/libretroshare/src/gxs/gxstokenqueue.cc +++ b/libretroshare/src/gxs/gxstokenqueue.cc @@ -1,28 +1,24 @@ -/* - * libretroshare/src/gxs gxstokenqueue.cc - * - * Gxs Support for RetroShare. - * - * Copyright 2012-2012 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/gxs: gxstokenqueue.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012-2012 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "gxs/gxstokenqueue.h" /******* @@ -59,7 +55,7 @@ void GxsTokenQueue::checkRequests() uint32_t token = it->mToken; uint32_t status = mGenExchange->getTokenService()->requestStatus(token); - if (status == RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) + if (status == RsTokenService::COMPLETE) { toload.push_back(*it); it = mQueue.erase(it); @@ -71,7 +67,7 @@ void GxsTokenQueue::checkRequests() #endif ++it; } - else if (status == RsTokenService::GXS_REQUEST_V2_STATUS_FAILED) + else if (status == RsTokenService::FAILED) { // maybe we should do alternative callback? std::cerr << "GxsTokenQueue::checkRequests() ERROR Request Failed: " << token; diff --git a/libretroshare/src/gxs/gxstokenqueue.h b/libretroshare/src/gxs/gxstokenqueue.h index 1099cd338..0b58f7c3d 100644 --- a/libretroshare/src/gxs/gxstokenqueue.h +++ b/libretroshare/src/gxs/gxstokenqueue.h @@ -1,29 +1,26 @@ +/******************************************************************************* + * libretroshare/src/gxs: gxstokenqueue.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012-2012 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef R_GXS_TOKEN_QUEUE_H #define R_GXS_TOKEN_QUEUE_H -/* - * libretroshare/src/gxs gxstokenqueue.h - * - * Gxs Support for RetroShare. - * - * Copyright 2012-2012 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ #include "gxs/rsgenexchange.h" #include "util/rsthreads.h" diff --git a/libretroshare/src/gxs/rsdataservice.cc b/libretroshare/src/gxs/rsdataservice.cc index 0b4d0f1da..1e5f96d69 100644 --- a/libretroshare/src/gxs/rsdataservice.cc +++ b/libretroshare/src/gxs/rsdataservice.cc @@ -1,28 +1,24 @@ - -/* - * libretroshare/src/gxs: rsdataservice.cc - * - * Data Access, interface for RetroShare. - * - * Copyright 2011-2011 by Evi-Parker Christopher - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ +/******************************************************************************* + * libretroshare/src/gxs: gxsdataservice.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2011-2011 by Evi-Parker Christopher * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ /***** * #define RS_DATA_SERVICE_DEBUG 1 diff --git a/libretroshare/src/gxs/rsdataservice.h b/libretroshare/src/gxs/rsdataservice.h index cc137b320..c4a5943a5 100644 --- a/libretroshare/src/gxs/rsdataservice.h +++ b/libretroshare/src/gxs/rsdataservice.h @@ -1,31 +1,27 @@ +/******************************************************************************* + * libretroshare/src/gxs: gxsdataservice.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2011-2012 by Evi-Parker Christopher * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RSDATASERVICE_H #define RSDATASERVICE_H -/* - * libretroshare/src/gxs: rsdataservice.h - * - * General Data service, interface for RetroShare. - * - * Copyright 2011-2012 by Evi-Parker Christopher - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - #include "gxs/rsgds.h" #include "util/retrodb.h" diff --git a/libretroshare/src/gxs/rsgds.h b/libretroshare/src/gxs/rsgds.h index 78987ac66..84276d7b6 100644 --- a/libretroshare/src/gxs/rsgds.h +++ b/libretroshare/src/gxs/rsgds.h @@ -1,31 +1,27 @@ +/******************************************************************************* + * libretroshare/src/gxs: rsgds.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2011-2011 by Robert Fernie, Evi-Parker Christopher * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RSGDS_H #define RSGDS_H -/* - * libretroshare/src/gxp: gxp.h - * - * General Data service, interface for RetroShare. - * - * Copyright 2011-2011 by Robert Fernie, Evi-Parker Christopher - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - #include #include #include @@ -78,23 +74,21 @@ public: }; /*! - * This is used to query network statistics for a given group. This is useful to e.g. show group - * popularity, or number of visible messages for unsubscribed group. + * This is used to query network statistics for a given group. This is useful + * to e.g. show group popularity, or number of visible messages for unsubscribed + * group. */ - -class RsGroupNetworkStats +struct RsGroupNetworkStats { -public: - RsGroupNetworkStats() - { - mMaxVisibleCount = 0 ; - } + RsGroupNetworkStats() : + mSuppliers(0), mMaxVisibleCount(0), mGrpAutoSync(false), + mAllowMsgSync(false), mLastGroupModificationTS(0) {} - uint32_t mSuppliers ; - uint32_t mMaxVisibleCount ; - bool mGrpAutoSync ; - bool mAllowMsgSync; - time_t mLastGroupModificationTS ; + uint32_t mSuppliers; + uint32_t mMaxVisibleCount; + bool mGrpAutoSync; + bool mAllowMsgSync; + time_t mLastGroupModificationTS; }; typedef std::map > NxsMsgDataResult; diff --git a/libretroshare/src/gxs/rsgenexchange.cc b/libretroshare/src/gxs/rsgenexchange.cc index ad7e02dcb..3d1c0fc6a 100644 --- a/libretroshare/src/gxs/rsgenexchange.cc +++ b/libretroshare/src/gxs/rsgenexchange.cc @@ -1,29 +1,24 @@ - -/* - * libretroshare/src/gxs: rsgenexchange.cc - * - * RetroShare Gxs exchange interface. - * - * Copyright 2012-2012 by Christopher Evi-Parker, Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/gxs: rsgenexchange.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012-2012 by Robert Fernie, Evi-Parker Christopher * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include #include "pqi/pqihash.h" @@ -206,7 +201,8 @@ void RsGenExchange::tick() if(!mIntegrityCheck) { - mIntegrityCheck = new RsGxsIntegrityCheck(mDataStore,this,mGixs); + mIntegrityCheck = new RsGxsIntegrityCheck( mDataStore, this, + *mSerialiser, mGixs); mIntegrityCheck->start("gxs integrity"); mChecking = true; } @@ -1110,6 +1106,8 @@ void RsGenExchange::receiveChanges(std::vector& changes) RsGxsNotify* n = *vit; RsGxsGroupChange* gc; RsGxsMsgChange* mc; + RsGxsDistantSearchResultChange *gt; + if((mc = dynamic_cast(n)) != NULL) { if (mc->metaChange()) @@ -1132,6 +1130,10 @@ void RsGenExchange::receiveChanges(std::vector& changes) out.mGrps.splice(out.mGrps.end(), gc->mGrpIdList); } } + else if((gt = dynamic_cast(n)) != NULL) + { + out.mDistantSearchReqs.push_back(gt->mRequestId); + } else std::cerr << "(EE) Unknown changes type!!" << std::endl; @@ -1567,7 +1569,7 @@ bool RsGenExchange::setAuthenPolicyFlag(const uint8_t &msgFlag, uint32_t& authen return true; } -void RsGenExchange::notifyNewGroups(std::vector &groups) +void RsGenExchange::receiveNewGroups(std::vector &groups) { RS_STACK_MUTEX(mGenMtx) ; @@ -1599,7 +1601,7 @@ void RsGenExchange::notifyNewGroups(std::vector &groups) } -void RsGenExchange::notifyNewMessages(std::vector& messages) +void RsGenExchange::receiveNewMessages(std::vector& messages) { RS_STACK_MUTEX(mGenMtx) ; @@ -1635,11 +1637,21 @@ void RsGenExchange::notifyNewMessages(std::vector& messages) } } +void RsGenExchange::receiveDistantSearchResults(TurtleRequestId id,const RsGxsGroupId &grpId) +{ + RS_STACK_MUTEX(mGenMtx); + + RsGxsDistantSearchResultChange* gc = new RsGxsDistantSearchResultChange(id,grpId); + mNotifications.push_back(gc); + + std::cerr << "RsGenExchange::receiveDistantSearchResults(): received result for request " << std::hex << id << std::dec << std::endl; +} + void RsGenExchange::notifyReceivePublishKey(const RsGxsGroupId &grpId) { RS_STACK_MUTEX(mGenMtx); - RsGxsGroupChange* gc = new RsGxsGroupChange(RsGxsNotify::TYPE_PUBLISHKEY, true); + RsGxsGroupChange* gc = new RsGxsGroupChange(RsGxsNotify::TYPE_RECEIVED_PUBLISHKEY, true); gc->mGrpIdList.push_back(grpId); mNotifications.push_back(gc); } @@ -1987,7 +1999,7 @@ void RsGenExchange::processMsgMetaChanges() if(ok) { - mDataAccess->updatePublicRequestStatus(token, RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE); + mDataAccess->updatePublicRequestStatus(token, RsTokenService::COMPLETE); if (changed) { msgIds[m.msgId.first].insert(m.msgId.second); @@ -1995,7 +2007,7 @@ void RsGenExchange::processMsgMetaChanges() } else { - mDataAccess->updatePublicRequestStatus(token, RsTokenService::GXS_REQUEST_V2_STATUS_FAILED); + mDataAccess->updatePublicRequestStatus(token, RsTokenService::FAILED); } { @@ -2041,11 +2053,11 @@ void RsGenExchange::processGrpMetaChanges() if(ok) { - mDataAccess->updatePublicRequestStatus(token, RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE); + mDataAccess->updatePublicRequestStatus(token, RsTokenService::COMPLETE); grpChanged.push_back(g.grpId); }else { - mDataAccess->updatePublicRequestStatus(token, RsTokenService::GXS_REQUEST_V2_STATUS_FAILED); + mDataAccess->updatePublicRequestStatus(token, RsTokenService::FAILED); } { @@ -2278,7 +2290,7 @@ void RsGenExchange::publishMsgs() // add to published to allow acknowledgement mMsgNotify.insert(std::make_pair(mit->first, std::make_pair(grpId, msgId))); - mDataAccess->updatePublicRequestStatus(mit->first, RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE); + mDataAccess->updatePublicRequestStatus(mit->first, RsTokenService::COMPLETE); } else @@ -2288,7 +2300,7 @@ void RsGenExchange::publishMsgs() if(!tryLater) mDataAccess->updatePublicRequestStatus(mit->first, - RsTokenService::GXS_REQUEST_V2_STATUS_FAILED); + RsTokenService::FAILED); std::cerr << "RsGenExchange::publishMsgs() failed to publish msg " << std::endl; } @@ -2310,7 +2322,7 @@ void RsGenExchange::publishMsgs() if(!msgChangeMap.empty()) { - RsGxsMsgChange* ch = new RsGxsMsgChange(RsGxsNotify::TYPE_PUBLISH, false); + RsGxsMsgChange* ch = new RsGxsMsgChange(RsGxsNotify::TYPE_PUBLISHED, false); ch->msgChangeMap = msgChangeMap; mNotifications.push_back(ch); } @@ -2365,7 +2377,7 @@ void RsGenExchange::processGroupUpdatePublish() if(mit == grpMeta.end() || mit->second == NULL) { std::cerr << "Error! could not find meta of old group to update!" << std::endl; - mDataAccess->updatePublicRequestStatus(gup.mToken, RsTokenService::GXS_REQUEST_V2_STATUS_FAILED); + mDataAccess->updatePublicRequestStatus(gup.mToken, RsTokenService::FAILED); delete gup.grpItem; continue; } @@ -2393,7 +2405,7 @@ void RsGenExchange::processGroupUpdatePublish() std::cerr << "(EE) publish group fails because RS cannot find the private publish and author keys" << std::endl; delete gup.grpItem; - mDataAccess->updatePublicRequestStatus(gup.mToken, RsTokenService::GXS_REQUEST_V2_STATUS_FAILED); + mDataAccess->updatePublicRequestStatus(gup.mToken, RsTokenService::FAILED); } } @@ -2414,7 +2426,7 @@ void RsGenExchange::processRoutingClues() void RsGenExchange::processGroupDelete() { - RS_STACK_MUTEX(mGenMtx) ; + RS_STACK_MUTEX(mGenMtx); // get keys for group delete publish typedef std::pair GrpNote; @@ -2435,8 +2447,9 @@ void RsGenExchange::processGroupDelete() for(; mit != toNotify.end(); ++mit) { GrpNote& note = mit->second; - uint8_t status = note.first ? RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE - : RsTokenService::GXS_REQUEST_V2_STATUS_FAILED; + RsTokenService::GxsRequestStatus status = + note.first ? RsTokenService::COMPLETE + : RsTokenService::FAILED; mGrpNotify.insert(std::make_pair(mit->first, note.second)); mDataAccess->updatePublicRequestStatus(mit->first, status); @@ -2447,7 +2460,7 @@ void RsGenExchange::processGroupDelete() if(!grpDeleted.empty()) { - RsGxsGroupChange* gc = new RsGxsGroupChange(RsGxsNotify::TYPE_PUBLISH, false); + RsGxsGroupChange* gc = new RsGxsGroupChange(RsGxsNotify::TYPE_PUBLISHED, false); gc->mGrpIdList = grpDeleted; mNotifications.push_back(gc); } @@ -2744,8 +2757,9 @@ void RsGenExchange::publishGrps() for(; mit != toNotify.end(); ++mit) { GrpNote& note = mit->second; - uint8_t status = note.first ? RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE - : RsTokenService::GXS_REQUEST_V2_STATUS_FAILED; + RsTokenService::GxsRequestStatus status = + note.first ? RsTokenService::COMPLETE + : RsTokenService::FAILED; mGrpNotify.insert(std::make_pair(mit->first, note.second)); mDataAccess->updatePublicRequestStatus(mit->first, status); @@ -2756,7 +2770,7 @@ void RsGenExchange::publishGrps() if(!grpChanged.empty()) { - RsGxsGroupChange* gc = new RsGxsGroupChange(RsGxsNotify::TYPE_RECEIVE, true); + RsGxsGroupChange* gc = new RsGxsGroupChange(RsGxsNotify::TYPE_RECEIVED_NEW, true); gc->mGrpIdList = grpChanged; mNotifications.push_back(gc); #ifdef GEN_EXCH_DEBUG @@ -2781,7 +2795,8 @@ uint32_t RsGenExchange::generatePublicToken() return mDataAccess->generatePublicToken(); } -bool RsGenExchange::updatePublicRequestStatus(const uint32_t &token, const uint32_t &status) +bool RsGenExchange::updatePublicRequestStatus( + uint32_t token, RsTokenService::GxsRequestStatus status ) { return mDataAccess->updatePublicRequestStatus(token, status); } @@ -3022,7 +3037,7 @@ void RsGenExchange::processRecvdMessages() #endif mDataStore->storeMessage(msgs_to_store); - RsGxsMsgChange* c = new RsGxsMsgChange(RsGxsNotify::TYPE_RECEIVE, false); + RsGxsMsgChange* c = new RsGxsMsgChange(RsGxsNotify::TYPE_RECEIVED_NEW, false); c->msgChangeMap = msgIds; mNotifications.push_back(c); } @@ -3155,7 +3170,7 @@ void RsGenExchange::processRecvdGroups() if(!grpIds.empty()) { - RsGxsGroupChange* c = new RsGxsGroupChange(RsGxsNotify::TYPE_RECEIVE, false); + RsGxsGroupChange* c = new RsGxsGroupChange(RsGxsNotify::TYPE_RECEIVED_NEW, false); c->mGrpIdList = grpIds; mNotifications.push_back(c); mDataStore->storeGroup(grps_to_store); @@ -3239,7 +3254,7 @@ void RsGenExchange::performUpdateValidation() } // notify the client - RsGxsGroupChange* c = new RsGxsGroupChange(RsGxsNotify::TYPE_RECEIVE, true); + RsGxsGroupChange* c = new RsGxsGroupChange(RsGxsNotify::TYPE_RECEIVED_NEW, true); for(uint32_t i=0;i& msgs, Gx mDataStore->retrieveMsgIds(*it, msgIdReq[*it]); #ifdef GEN_EXCH_DEBUG - const std::vector& vec(msgIdReq[*it]) ; + const std::set& vec(msgIdReq[*it]) ; std::cerr << " retrieved " << vec.size() << " message ids for group " << *it << std::endl; - for(uint32_t i=0;i& msgs, Gx } } +void RsGenExchange::turtleGroupRequest(const RsGxsGroupId& group_id) +{ + mNetService->turtleGroupRequest(group_id) ; +} +void RsGenExchange::turtleSearchRequest(const std::string& match_string) +{ + mNetService->turtleSearchRequest(match_string) ; +} diff --git a/libretroshare/src/gxs/rsgenexchange.h b/libretroshare/src/gxs/rsgenexchange.h index 491ff017b..336eeb4fe 100644 --- a/libretroshare/src/gxs/rsgenexchange.h +++ b/libretroshare/src/gxs/rsgenexchange.h @@ -1,31 +1,27 @@ +/******************************************************************************* + * libretroshare/src/gxs: rsgenexchange.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012-2012 by Robert Fernie, Evi-Parker Christopher * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RSGENEXCHANGE_H #define RSGENEXCHANGE_H -/* - * libretroshare/src/gxs: rsgenexchange.h - * - * RetroShare C++ Interface. - * - * Copyright 2012-2012 by Christopher Evi-Parker, Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - #include #include @@ -121,9 +117,9 @@ public: virtual ~RsGenExchange(); - // Convention that this is implemented here. + // Convention that this is implemented here. // and passes to network service. - virtual RsServiceInfo getServiceInfo() = 0; + virtual RsServiceInfo getServiceInfo() = 0; void setNetworkExchangeService(RsNetworkExchangeService *ns) ; @@ -132,18 +128,24 @@ public: /*! * @param messages messages are deleted after function returns */ - virtual void notifyNewMessages(std::vector& messages); + virtual void receiveNewMessages(std::vector& messages); /*! * @param groups groups are deleted after function returns */ - virtual void notifyNewGroups(std::vector& groups); + virtual void receiveNewGroups(std::vector& groups); /*! * @param grpId group id */ virtual void notifyReceivePublishKey(const RsGxsGroupId &grpId); + /*! + * \brief notifyReceiveDistantSearchResults + * Should be called when new search results arrive. + * \param grpId + */ + virtual void receiveDistantSearchResults(TurtleRequestId id,const RsGxsGroupId &grpId); /*! * @param grpId group id */ @@ -287,6 +289,15 @@ public: */ bool getGroupStatistic(const uint32_t& token, GxsGroupStatistic& stats); + /*! + * \brief turtleGroupRequest + * Issues a browadcast group request using the turtle router generic search system. The request is obviously asynchroneous and will be + * handled in RsGenExchange when received. + * \param group_id + */ + void turtleGroupRequest(const RsGxsGroupId& group_id); + void turtleSearchRequest(const std::string& match_string); + protected: bool messagePublicationTest(const RsGxsMsgMetaData&) ; @@ -468,7 +479,8 @@ public: * @param status * @return false if token could not be found, true if token disposed of */ - bool updatePublicRequestStatus(const uint32_t &token, const uint32_t &status); + bool updatePublicRequestStatus( + uint32_t token, RsTokenService::GxsRequestStatus status); /*! * This gets rid of a publicly issued token @@ -566,7 +578,7 @@ public: * @param msgs */ void deleteMsgs(uint32_t& token, const GxsMsgReq& msgs); - + protected: /*! * This represents the group before its signature is calculated @@ -650,7 +662,7 @@ public: */ void shareGroupPublishKey(const RsGxsGroupId& grpId,const std::set& peers) ; - + /*! * Returns the local TS of the group as known by the network service. * This is useful to allow various network services to sync their update TS @@ -755,6 +767,8 @@ protected: */ int createMessage(RsNxsMsg* msg); + RsNetworkExchangeService *netService() const { return mNetService ; } + private: /*! * convenience function to create sign diff --git a/libretroshare/src/gxs/rsgixs.h b/libretroshare/src/gxs/rsgixs.h index 3c7c5ae1b..98b99be54 100644 --- a/libretroshare/src/gxs/rsgixs.h +++ b/libretroshare/src/gxs/rsgixs.h @@ -1,31 +1,27 @@ +/******************************************************************************* + * libretroshare/src/gxs: rsgixs.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2011-2011 by Robert Fernie, Evi-Parker Christopher * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RSGIXS_H #define RSGIXS_H -/* - * libretroshare/src/gxs: gxs.h - * - * General Identity Exchange Service interface for RetroShare. - * - * Copyright 2011-2011 by Robert Fernie, Christopher Evi-Prker - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - #include "gxs/rsgxs.h" #include "gxs/rsgenexchange.h" diff --git a/libretroshare/src/gxs/rsgxs.h b/libretroshare/src/gxs/rsgxs.h index e8e64a098..3f25b087b 100644 --- a/libretroshare/src/gxs/rsgxs.h +++ b/libretroshare/src/gxs/rsgxs.h @@ -1,30 +1,27 @@ +/******************************************************************************* + * libretroshare/src/gxs: rsgxs.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012 Christopher Evi-Parker * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RSGXS_H #define RSGXS_H -/* - * libretroshare/src/gxs : rsgxs.h - * - * Copyright 2012 Christopher Evi-Parker - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - * - */ - #include "gxs/rsgxsdata.h" #include diff --git a/libretroshare/src/gxs/rsgxsdata.cc b/libretroshare/src/gxs/rsgxsdata.cc index 48dfa9917..0ec61de8e 100644 --- a/libretroshare/src/gxs/rsgxsdata.cc +++ b/libretroshare/src/gxs/rsgxsdata.cc @@ -1,28 +1,24 @@ - -/* - * libretroshare/src/gxs: rsgxsdata.cc - * - * Gxs Data types used to specific services - * - * Copyright 2012-2012 by Christopher Evi-Parker, Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ +/******************************************************************************* + * libretroshare/src/gxs: rsgxsdata.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012-2012 by Christopher Evi-Parker, Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "rsgxsdata.h" #include "serialiser/rsbaseserial.h" diff --git a/libretroshare/src/gxs/rsgxsdata.h b/libretroshare/src/gxs/rsgxsdata.h index 3cead4a11..fffcfbe6a 100644 --- a/libretroshare/src/gxs/rsgxsdata.h +++ b/libretroshare/src/gxs/rsgxsdata.h @@ -1,31 +1,27 @@ +/******************************************************************************* + * libretroshare/src/gxs: rsgxsdata.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012-2012 by Christopher Evi-Parker, Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RSGXSMETA_H #define RSGXSMETA_H -/* - * libretroshare/src/gxs: rsgxsdata.h - * - * Gxs Data types used to specific services - * - * Copyright 2012-2012 by Christopher Evi-Parker, Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - #include #include diff --git a/libretroshare/src/gxs/rsgxsdataaccess.cc b/libretroshare/src/gxs/rsgxsdataaccess.cc index 77c0d05d9..b0219ecb2 100644 --- a/libretroshare/src/gxs/rsgxsdataaccess.cc +++ b/libretroshare/src/gxs/rsgxsdataaccess.cc @@ -1,27 +1,24 @@ -/* - * libretroshare/src/retroshare: rsgxsdataaccess.cc - * - * RetroShare C++ Interface. - * - * Copyright 2012-2013 by Robert Fernie, Christopher Evi-Parker - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ +/******************************************************************************* + * libretroshare/src/gxs: rsgxsdataaccess.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012-2013 by Christopher Evi-Parker, Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include @@ -29,15 +26,6 @@ #include "rsgxsdataaccess.h" #include "retroshare/rsgxsflags.h" -// TODO CLEANUP: This should be an enum defined in rstokenservice.h - const uint8_t RsTokenService::GXS_REQUEST_V2_STATUS_FAILED = 0; - const uint8_t RsTokenService::GXS_REQUEST_V2_STATUS_PENDING = 1; - const uint8_t RsTokenService::GXS_REQUEST_V2_STATUS_PARTIAL = 2; - const uint8_t RsTokenService::GXS_REQUEST_V2_STATUS_FINISHED_INCOMPLETE = 3; - const uint8_t RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE = 4; - const uint8_t RsTokenService::GXS_REQUEST_V2_STATUS_DONE = 5; // ONCE ALL DATA RETRIEVED. - const uint8_t RsTokenService::GXS_REQUEST_V2_STATUS_CANCELLED = 6; - /*********** * #define DATA_DEBUG 1 **********/ @@ -317,22 +305,22 @@ void RsGxsDataAccess::storeRequest(GxsRequest* req) { RsStackMutex stack(mDataMutex); /****** LOCKED *****/ - req->status = GXS_REQUEST_V2_STATUS_PENDING; + req->status = PENDING; req->reqTime = time(NULL); mRequests[req->token] = req; return; } -uint32_t RsGxsDataAccess::requestStatus(uint32_t token) +RsTokenService::GxsRequestStatus RsGxsDataAccess::requestStatus(uint32_t token) { - uint32_t status; + RsTokenService::GxsRequestStatus status; uint32_t reqtype; uint32_t anstype; time_t ts; { - RsStackMutex stack(mDataMutex); + RS_STACK_MUTEX(mDataMutex); // first check public tokens if(mPublicToken.find(token) != mPublicToken.end()) @@ -340,7 +328,7 @@ uint32_t RsGxsDataAccess::requestStatus(uint32_t token) } if (!checkRequestStatus(token, status, reqtype, anstype, ts)) - return RsTokenService::GXS_REQUEST_V2_STATUS_FAILED; + return RsTokenService::FAILED; return status; } @@ -355,7 +343,7 @@ bool RsGxsDataAccess::cancelRequest(const uint32_t& token) return false; } - req->status = GXS_REQUEST_V2_STATUS_CANCELLED; + req->status = CANCELLED; return true; } @@ -391,7 +379,7 @@ bool RsGxsDataAccess::getGroupSummary(const uint32_t& token, std::liststatus == GXS_REQUEST_V2_STATUS_COMPLETE) + else if(req->status == COMPLETE) { GroupMetaReq* gmreq = dynamic_cast(req); @@ -399,7 +387,7 @@ bool RsGxsDataAccess::getGroupSummary(const uint32_t& token, std::listmGroupMetaData; gmreq->mGroupMetaData.clear(); - locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE); + locked_updateRequestStatus(token, DONE); } else { @@ -430,7 +418,7 @@ bool RsGxsDataAccess::getGroupData(const uint32_t& token, std::list& << "data" << std::endl; return false; } - else if(req->status == GXS_REQUEST_V2_STATUS_COMPLETE) + else if(req->status == COMPLETE) { GroupDataReq* gmreq = dynamic_cast(req); GroupSerializedDataReq* gsreq = dynamic_cast(req); @@ -440,13 +428,13 @@ bool RsGxsDataAccess::getGroupData(const uint32_t& token, std::list& grpData.swap(gsreq->mGroupData); gsreq->mGroupData.clear(); - locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE); + locked_updateRequestStatus(token, DONE); } else if(gmreq) { grpData.swap(gmreq->mGroupData); gmreq->mGroupData.clear(); - locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE); + locked_updateRequestStatus(token, DONE); } else { @@ -475,7 +463,7 @@ bool RsGxsDataAccess::getMsgData(const uint32_t& token, NxsMsgDataResult& msgDat std::cerr << "RsGxsDataAccess::getMsgData() Unable to retrieve group data" << std::endl; return false; - }else if(req->status == GXS_REQUEST_V2_STATUS_COMPLETE){ + }else if(req->status == COMPLETE){ MsgDataReq* mdreq = dynamic_cast(req); @@ -483,7 +471,7 @@ bool RsGxsDataAccess::getMsgData(const uint32_t& token, NxsMsgDataResult& msgDat { msgData.swap(mdreq->mMsgData); mdreq->mMsgData.clear(); - locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE); + locked_updateRequestStatus(token, DONE); } else { @@ -509,7 +497,7 @@ bool RsGxsDataAccess::getMsgRelatedData(const uint32_t &token, NxsMsgRelatedData std::cerr << "RsGxsDataAccess::getMsgRelatedData() Unable to retrieve group data" << std::endl; return false; - }else if(req->status == GXS_REQUEST_V2_STATUS_COMPLETE){ + }else if(req->status == COMPLETE){ MsgRelatedInfoReq* mrireq = dynamic_cast(req); @@ -520,7 +508,7 @@ bool RsGxsDataAccess::getMsgRelatedData(const uint32_t &token, NxsMsgRelatedData { msgData.swap(mrireq->mMsgDataResult); mrireq->mMsgDataResult.clear(); - locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE); + locked_updateRequestStatus(token, DONE); } else { @@ -546,7 +534,7 @@ bool RsGxsDataAccess::getMsgSummary(const uint32_t& token, GxsMsgMetaResult& msg std::cerr << "RsGxsDataAccess::getMsgSummary() Unable to retrieve group data" << std::endl; return false; - }else if(req->status == GXS_REQUEST_V2_STATUS_COMPLETE){ + }else if(req->status == COMPLETE){ MsgMetaReq* mmreq = dynamic_cast(req); @@ -554,7 +542,7 @@ bool RsGxsDataAccess::getMsgSummary(const uint32_t& token, GxsMsgMetaResult& msg { msgInfo.swap(mmreq->mMsgMetaData); mmreq->mMsgMetaData.clear(); - locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE); + locked_updateRequestStatus(token, DONE); } else @@ -583,7 +571,7 @@ bool RsGxsDataAccess::getMsgRelatedSummary(const uint32_t &token, MsgRelatedMeta std::cerr << "RsGxsDataAccess::getMsgRelatedSummary() Unable to retrieve message summary" << std::endl; return false; - }else if(req->status == GXS_REQUEST_V2_STATUS_COMPLETE){ + }else if(req->status == COMPLETE){ if(req->Options.mReqType != GXS_REQUEST_TYPE_MSG_RELATED_META) return false; @@ -594,7 +582,7 @@ bool RsGxsDataAccess::getMsgRelatedSummary(const uint32_t &token, MsgRelatedMeta { msgMeta.swap(mrireq->mMsgMetaResult); mrireq->mMsgMetaResult.clear(); - locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE); + locked_updateRequestStatus(token, DONE); } else { @@ -622,7 +610,7 @@ bool RsGxsDataAccess::getMsgRelatedList(const uint32_t &token, MsgRelatedIdResul std::cerr << "RsGxsDataAccess::getMsgRelatedList() Unable to retrieve message data" << std::endl; return false; - }else if(req->status == GXS_REQUEST_V2_STATUS_COMPLETE){ + }else if(req->status == COMPLETE){ if(req->Options.mReqType != GXS_REQUEST_TYPE_MSG_RELATED_IDS) return false; @@ -633,7 +621,7 @@ bool RsGxsDataAccess::getMsgRelatedList(const uint32_t &token, MsgRelatedIdResul { msgIds.swap(mrireq->mMsgIdResult); mrireq->mMsgIdResult.clear(); - locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE); + locked_updateRequestStatus(token, DONE); } else{ std::cerr << "RsGxsDataAccess::getMsgRelatedList() Req found, failed caste" << std::endl; @@ -659,7 +647,7 @@ bool RsGxsDataAccess::getMsgList(const uint32_t& token, GxsMsgIdResult& msgIds) std::cerr << "RsGxsDataAccess::getMsgList() Unable to retrieve msg Ids" << std::endl; return false; - }else if(req->status == GXS_REQUEST_V2_STATUS_COMPLETE){ + }else if(req->status == COMPLETE){ MsgIdReq* mireq = dynamic_cast(req); @@ -667,7 +655,7 @@ bool RsGxsDataAccess::getMsgList(const uint32_t& token, GxsMsgIdResult& msgIds) { msgIds.swap(mireq->mMsgIdResult); mireq->mMsgIdResult.clear(); - locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE); + locked_updateRequestStatus(token, DONE); } else{ std::cerr << "RsGxsDataAccess::getMsgList() Req found, failed caste" << std::endl; @@ -692,7 +680,7 @@ bool RsGxsDataAccess::getGroupList(const uint32_t& token, std::liststatus == GXS_REQUEST_V2_STATUS_COMPLETE){ + }else if(req->status == COMPLETE){ GroupIdReq* gireq = dynamic_cast(req); @@ -700,7 +688,7 @@ bool RsGxsDataAccess::getGroupList(const uint32_t& token, std::listmGroupIdResult); gireq->mGroupIdResult.clear(); - locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE); + locked_updateRequestStatus(token, DONE); }else{ std::cerr << "RsGxsDataAccess::getGroupList() Req found, failed caste" << std::endl; @@ -742,21 +730,21 @@ void RsGxsDataAccess::processRequests() switch (req->status) { - case GXS_REQUEST_V2_STATUS_PENDING: + case PENDING: // process request later break; - case GXS_REQUEST_V2_STATUS_PARTIAL: + case PARTIAL: // should not happen - req->status = GXS_REQUEST_V2_STATUS_COMPLETE; + req->status = COMPLETE; break; - case GXS_REQUEST_V2_STATUS_DONE: + case DONE: #ifdef DATA_DEBUG std::cerr << "RsGxsDataAccess::processrequests() Clearing Done Request Token: " << req->token; std::cerr << std::endl; #endif toClear.push_back(req->token); break; - case GXS_REQUEST_V2_STATUS_CANCELLED: + case CANCELLED: #ifdef DATA_DEBUG std::cerr << "RsGxsDataAccess::processrequests() Clearing Cancelled Request Token: " << req->token; std::cerr << std::endl; @@ -794,10 +782,10 @@ void RsGxsDataAccess::processRequests() for (it = mRequests.begin(); it != mRequests.end(); ++it) { GxsRequest* reqCheck = it->second; - if (reqCheck->status == GXS_REQUEST_V2_STATUS_PENDING) + if (reqCheck->status == PENDING) { req = reqCheck; - req->status = GXS_REQUEST_V2_STATUS_PARTIAL; + req->status = PARTIAL; break; } } @@ -877,9 +865,9 @@ void RsGxsDataAccess::processRequests() { RsStackMutex stack(mDataMutex); /******* LOCKED *******/ - if (req->status == GXS_REQUEST_V2_STATUS_PARTIAL) + if (req->status == PARTIAL) { - req->status = ok ? GXS_REQUEST_V2_STATUS_COMPLETE : GXS_REQUEST_V2_STATUS_FAILED; + req->status = ok ? COMPLETE : FAILED; } } // END OF MUTEX. } @@ -895,14 +883,14 @@ bool RsGxsDataAccess::getGroupStatistic(const uint32_t &token, GxsGroupStatistic std::cerr << "RsGxsDataAccess::getGroupStatistic() Unable to retrieve grp stats" << std::endl; return false; - }else if(req->status == GXS_REQUEST_V2_STATUS_COMPLETE){ + }else if(req->status == COMPLETE){ GroupStatisticRequest* gsreq = dynamic_cast(req); if(gsreq) { grpStatistic = gsreq->mGroupStatistic; - locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE); + locked_updateRequestStatus(token, DONE); } else{ std::cerr << "RsGxsDataAccess::getGroupStatistic() Req found, failed caste" << std::endl; @@ -926,14 +914,14 @@ bool RsGxsDataAccess::getServiceStatistic(const uint32_t &token, GxsServiceStati std::cerr << "RsGxsDataAccess::getServiceStatistic() Unable to retrieve service stats" << std::endl; return false; - }else if(req->status == GXS_REQUEST_V2_STATUS_COMPLETE){ + }else if(req->status == COMPLETE){ ServiceStatisticRequest* ssreq = dynamic_cast(req); if(ssreq) { servStatistic = ssreq->mServiceStatistic; - locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE); + locked_updateRequestStatus(token, DONE); } else{ std::cerr << "RsGxsDataAccess::getServiceStatistic() Req found, failed caste" << std::endl; @@ -1770,15 +1758,15 @@ void RsGxsDataAccess::filterGrpList(std::list &grpIds, const RsTok } -bool RsGxsDataAccess::checkRequestStatus(const uint32_t& token, - uint32_t& status, uint32_t& reqtype, uint32_t& anstype, time_t& ts) +bool RsGxsDataAccess::checkRequestStatus( + uint32_t token, GxsRequestStatus& status, uint32_t& reqtype, + uint32_t& anstype, time_t& ts ) { - - RsStackMutex stack(mDataMutex); + RS_STACK_MUTEX(mDataMutex); GxsRequest* req = locked_retrieveRequest(token); - if (req == NULL || req->status == GXS_REQUEST_V2_STATUS_CANCELLED) + if (req == NULL || req->status == CANCELLED) return false; anstype = req->ansType; @@ -1807,6 +1795,23 @@ bool RsGxsDataAccess::updateGroupData(RsNxsGrp* grp) { return mDataStore->updateGroup(grpM); } +bool RsGxsDataAccess::getGroupData(const RsGxsGroupId& grpId, RsNxsGrp *& grp_data) +{ + RsStackMutex stack(mDataMutex); + + std::map grps ; + + grps[grpId] = NULL ; + + if(mDataStore->retrieveNxsGrps(grps, false, true)) // the false here is very important: it removes the private key parts. + { + grp_data = grps.begin()->second; + return true; + } + else + return false ; +} + bool RsGxsDataAccess::addMsgData(RsNxsMsg* msg) { RsStackMutex stack(mDataMutex); @@ -1831,70 +1836,52 @@ void RsGxsDataAccess::tokenList(std::list& tokens) } } -bool RsGxsDataAccess::locked_updateRequestStatus(const uint32_t& token, - const uint32_t& status) +bool RsGxsDataAccess::locked_updateRequestStatus( + uint32_t token, RsTokenService::GxsRequestStatus status ) { - GxsRequest* req = locked_retrieveRequest(token); - if(req) - req->status = status; - else - return false; + if(req) req->status = status; + else return false; return true; } uint32_t RsGxsDataAccess::generatePublicToken() { - uint32_t token; generateToken(token); - { - RsStackMutex stack(mDataMutex); - mPublicToken[token] = RsTokenService::GXS_REQUEST_V2_STATUS_PENDING; - } + { + RS_STACK_MUTEX(mDataMutex); + mPublicToken[token] = RsTokenService::PENDING; + } return token; } -bool RsGxsDataAccess::updatePublicRequestStatus(const uint32_t& token, - const uint32_t& status) +bool RsGxsDataAccess::updatePublicRequestStatus( + uint32_t token, RsTokenService::GxsRequestStatus status ) { - RsStackMutex stack(mDataMutex); - std::map::iterator mit = mPublicToken.find(token); - - if(mit != mPublicToken.end()) - { - mit->second = status; - } - else - { - return false; - } - + RS_STACK_MUTEX(mDataMutex); + std::map::iterator mit = + mPublicToken.find(token); + if(mit != mPublicToken.end()) mit->second = status; + else return false; return true; } -bool RsGxsDataAccess::disposeOfPublicToken(const uint32_t& token) +bool RsGxsDataAccess::disposeOfPublicToken(uint32_t token) { - RsStackMutex stack(mDataMutex); - std::map::iterator mit = mPublicToken.find(token); - - if(mit != mPublicToken.end()) - { - mPublicToken.erase(mit); - } - else - { - return false; - } - + RS_STACK_MUTEX(mDataMutex); + std::map::iterator mit = + mPublicToken.find(token); + if(mit != mPublicToken.end()) mPublicToken.erase(mit); + else return false; return true; } diff --git a/libretroshare/src/gxs/rsgxsdataaccess.h b/libretroshare/src/gxs/rsgxsdataaccess.h index 77f94137e..df79c1e95 100644 --- a/libretroshare/src/gxs/rsgxsdataaccess.h +++ b/libretroshare/src/gxs/rsgxsdataaccess.h @@ -1,31 +1,27 @@ +/******************************************************************************* + * libretroshare/src/gxs: rsgxsdataaccess.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012-2012 by Christopher Evi-Parker, Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RSGXSDATAACCESS_H #define RSGXSDATAACCESS_H -/* - * libretroshare/src/retroshare: rsgxsdataaccess.cc - * - * RetroShare C++ Interface. - * - * Copyright 2012-2012 by Robert Fernie, Christopher Evi-Parker - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - #include "retroshare/rstokenservice.h" #include "rsgxsrequesttypes.h" #include "rsgds.h" @@ -48,6 +44,8 @@ public: * deprecated and should be removed as soon as possible as it is cause of * many confusions, instead use const RsTokReqOptions::mReqType &opts to * specify the kind of data you are interested in. + * Most of the methods use const uint32_t &token as param type change it to + * uint32_t */ /*! @@ -121,7 +119,7 @@ public: /* Poll */ - uint32_t requestStatus(const uint32_t token); + GxsRequestStatus requestStatus(const uint32_t token); /* Cancel Request */ bool cancelRequest(const uint32_t &token); @@ -156,6 +154,14 @@ public: */ bool addMsgData(RsNxsMsg* msg); + /*! + * This retrieves a group from the gxs data base, this is a blocking call \n + * @param grp the group to add, memory ownership passed to the callee + * @return false if group cound not be retrieved + */ + bool getGroupData(const RsGxsGroupId& grpId,RsNxsGrp *& grp_data); + + public: @@ -296,7 +302,7 @@ private: * @param status the status to set * @return */ - bool locked_updateRequestStatus(const uint32_t &token, const uint32_t &status); + bool locked_updateRequestStatus(uint32_t token, GxsRequestStatus status); /*! * Use to query the status and other values of a given token @@ -307,7 +313,8 @@ private: * @param ts time stamp * @return false if token does not exist, true otherwise */ - bool checkRequestStatus(const uint32_t &token, uint32_t &status, uint32_t &reqtype, uint32_t &anstype, time_t &ts); + bool checkRequestStatus( uint32_t token, GxsRequestStatus &status, + uint32_t &reqtype, uint32_t &anstype, time_t &ts); // special ones for testing (not in final design) /*! @@ -337,14 +344,14 @@ public: * @param status * @return false if token could not be found, true if token disposed of */ - bool updatePublicRequestStatus(const uint32_t &token, const uint32_t &status); + bool updatePublicRequestStatus(uint32_t token, GxsRequestStatus status); /*! * This gets rid of a publicly issued token * @param token * @return false if token could not found, true if token disposed of */ - bool disposeOfPublicToken(const uint32_t &token); + bool disposeOfPublicToken(uint32_t token); private: @@ -484,7 +491,7 @@ private: RsMutex mDataMutex; /* protecting below */ uint32_t mNextToken; - std::map mPublicToken; + std::map mPublicToken; std::map mRequests; diff --git a/libretroshare/src/gxs/rsgxsnetservice.cc b/libretroshare/src/gxs/rsgxsnetservice.cc index 0f61c5a74..df19a900d 100644 --- a/libretroshare/src/gxs/rsgxsnetservice.cc +++ b/libretroshare/src/gxs/rsgxsnetservice.cc @@ -1,27 +1,24 @@ -/* - * libretroshare/src/gxs: rsgxnetservice.cc - * - * Access to rs network and synchronisation service implementation - * - * Copyright 2012-2012 by Christopher Evi-Parker - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ +/******************************************************************************* + * libretroshare/src/gxs: rsgxsnetservice.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012-2012 by Christopher Evi-Parker * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ // // RsNxsItem @@ -166,8 +163,6 @@ // | | // (Only send if rand() < sendingProb()) +---comes from mClientMsgUpdateMap -----+ // -// -// // Suggestions // =========== // * handleRecvSyncGroup should use mit->second.mLastPost to limit the sending of already known data @@ -194,6 +189,53 @@ // Problem: without msg, we cannot know the grpId!! // // * mClientMsgUpdateMap[peerid][grpId] is only updated when new msgs are received. Up to date groups will keep asking for lists! +// +// Distant sync +// ============ +// +// Distant sync uses tunnels to sync subscribed GXS groups that are not supplied by friends. Peers can subscribe to a GXS group using a RS link +// which GXS uses to request updates through tunnels. +// * The whole exchange should be kept private and anonymous between the two distant peers, so we use the same trick than for FT: encrypt the data using the group ID. +// * The same node shouldn't be known as a common server for different GXS groups +// +// GXS net service: +// * talks to virtual peers, treated like normal peers +// * virtual peers only depend on the server ID, not on tunnel ID, and be kept constant accross time so that ClientGroupUpdateMap is kept consistent +// * does not use tunnels if friends can already supply the data (??) This causes issues with "islands". +// +// Tunnels: +// * a specific service named GxsSyncTunnelService handles the creation/management of sync tunnels: +// * tunnel data need to be encrypted. +// +// bool manageTunnels(const RsGxsGroupId&) ; // start managing tunnels for this group +// bool releaseTunnels(const RsGxsGroupId&) ; // stop managing tunnels for this group +// bool sendData(const unsigned char *data,uint32_t size,const RsPeerId& virtual_peer) ; // send data to this virtual peer +// bool getVirtualPeers(const RsGxsGroupId&, std::list& peers) ; // returns the virtual peers for this group +// +// Proposed protocol: +// * request tunnels based on H(GroupId) +// * encrypt tunnel data using chacha20+HMAC-SHA256 using AEAD( GroupId, 96bits IV, tunnel ID ) (similar to what FT does) +// * when tunnel is established, exchange virtual peer names: vpid = H( GroupID | Random bias ) +// * when vpid is known, notify the client (GXS net service) which can use the virtual peer to sync +// +// * only use a single tunnel per virtual peer ID +// +// Client ------------------ TR(H(GroupId)) --------------> Server +// +// Client <-------------------- T OK ---------------------- Server +// +// [Encrypted traffic using H(GroupId, 96bits IV, tunnel ID)] +// +// Client <--------- VPID = H( Random IV | GroupId ) ------ Server +// | | +// +--------------> Mark the virtual peer active <-----------+ +// +// Unsolved problems: +// * if we want to preserve anonymity, we cannot prevent GXS from duplicating the data from virtual/real peers that actually are the same peers. +// * ultimately we should only use tunnels to sync GXS. The mix between tunnels and real peers is not a problem but will cause unnecessary traffic. +// +// Notes: +// * given that GXS only talks to peers once every 2 mins, it's likely that keep-alive packets will be needed #include @@ -209,11 +251,16 @@ #include "retroshare/rsgxscircles.h" #include "retroshare/rspeers.h" #include "pgp/pgpauxutils.h" +#include "crypto/rscrypto.h" #include "util/rsdir.h" #include "util/rstime.h" #include "util/rsmemory.h" #include "util/stacktrace.h" +#ifdef RS_DEEP_SEARCH +# include "deep_search/deep_search.h" +#endif + /*** * Use the following defines to debug: NXS_NET_DEBUG_0 shows group update high level information @@ -224,6 +271,7 @@ NXS_NET_DEBUG_5 summary of transactions (useful to just know what comes in/out) NXS_NET_DEBUG_6 group sync statistics (e.g. number of posts at nighbour nodes, etc) NXS_NET_DEBUG_7 encryption/decryption of transactions + NXS_NET_DEBUG_8 gxs distant sync ***/ //#define NXS_NET_DEBUG_0 1 @@ -234,6 +282,7 @@ //#define NXS_NET_DEBUG_5 1 //#define NXS_NET_DEBUG_6 1 //#define NXS_NET_DEBUG_7 1 +#define NXS_NET_DEBUG_8 1 //#define NXS_FRAG @@ -256,6 +305,7 @@ static const uint32_t REJECTED_MESSAGE_RETRY_DELAY = 24*3600; // static const uint32_t GROUP_STATS_UPDATE_DELAY = 240; // update unsubscribed group statistics every 3 mins static const uint32_t GROUP_STATS_UPDATE_NB_PEERS = 2; // number of peers to which the group stats are asked static const uint32_t MAX_ALLOWED_GXS_MESSAGE_SIZE = 199000; // 200,000 bytes including signature and headers +static const uint32_t MIN_DELAY_BETWEEN_GROUP_SEARCH = 40; // dont search same group more than every 40 secs. static const uint32_t RS_NXS_ITEM_ENCRYPTION_STATUS_UNKNOWN = 0x00 ; static const uint32_t RS_NXS_ITEM_ENCRYPTION_STATUS_NO_ERROR = 0x01 ; @@ -267,11 +317,12 @@ static const uint32_t RS_NXS_ITEM_ENCRYPTION_STATUS_GXS_KEY_MISSING = 0x05 ; // Debug system to allow to print only for some IDs (group, Peer, etc) #if defined(NXS_NET_DEBUG_0) || defined(NXS_NET_DEBUG_1) || defined(NXS_NET_DEBUG_2) || defined(NXS_NET_DEBUG_3) \ - || defined(NXS_NET_DEBUG_4) || defined(NXS_NET_DEBUG_5) || defined(NXS_NET_DEBUG_6) || defined(NXS_NET_DEBUG_7) + || defined(NXS_NET_DEBUG_4) || defined(NXS_NET_DEBUG_5) || defined(NXS_NET_DEBUG_6) || defined(NXS_NET_DEBUG_7) \ + || defined(NXS_NET_DEBUG_8) static const RsPeerId peer_to_print = RsPeerId(std::string("")) ; static const RsGxsGroupId group_id_to_print = RsGxsGroupId(std::string("")) ; // use this to allow to this group id only, or "" for all IDs -static const uint32_t service_to_print = RS_SERVICE_TYPE_GXS_TRANS ; // use this to allow to this service id only, or 0 for all services +static const uint32_t service_to_print = RS_SERVICE_GXS_TYPE_CHANNELS ; // use this to allow to this service id only, or 0 for all services // warning. Numbers should be SERVICE IDS (see serialiser/rsserviceids.h. E.g. 0x0215 for forums) class nullstream: public std::ostream {}; @@ -288,7 +339,6 @@ static std::string nice_time_stamp(time_t now,time_t TS) } } - static std::ostream& gxsnetdebug(const RsPeerId& peer_id,const RsGxsGroupId& grp_id,uint32_t service_type) { static nullstream null ; @@ -314,7 +364,8 @@ RsGxsNetService::RsGxsNetService(uint16_t servType, RsGeneralDataService *gds, RsNxsNetMgr *netMgr, RsNxsObserver *nxsObs, const RsServiceInfo serviceInfo, RsGixsReputation* reputations, RsGcxs* circles, RsGixs *gixs, - PgpAuxUtils *pgpUtils, bool grpAutoSync, bool msgAutoSync, uint32_t default_store_period, uint32_t default_sync_period) + PgpAuxUtils *pgpUtils, RsGxsNetTunnelService *mGxsNT, + bool grpAutoSync, bool msgAutoSync, bool distSync, uint32_t default_store_period, uint32_t default_sync_period) : p3ThreadedService(), p3Config(), mTransactionN(0), mObserver(nxsObs), mDataStore(gds), mServType(servType), mTransactionTimeOut(TRANSAC_TIMEOUT), @@ -322,8 +373,8 @@ RsGxsNetService::RsGxsNetService(uint16_t servType, RsGeneralDataService *gds, mSyncTs(0), mLastKeyPublishTs(0), mLastCleanRejectedMessages(0), mSYNC_PERIOD(SYNC_PERIOD), mCircles(circles), mGixs(gixs), - mReputations(reputations), mPgpUtils(pgpUtils), - mGrpAutoSync(grpAutoSync), mAllowMsgSync(msgAutoSync), + mReputations(reputations), mPgpUtils(pgpUtils), mGxsNetTunnel(mGxsNT), + mGrpAutoSync(grpAutoSync), mAllowMsgSync(msgAutoSync),mAllowDistSync(distSync), mServiceInfo(serviceInfo), mDefaultMsgStorePeriod(default_store_period), mDefaultMsgSyncPeriod(default_sync_period) { @@ -331,6 +382,8 @@ RsGxsNetService::RsGxsNetService(uint16_t servType, RsGeneralDataService *gds, mOwnId = mNetMgr->getOwnId(); mUpdateCounter = 0; + mLastCacheReloadTS = 0; + // check the consistency if(mDefaultMsgStorePeriod > 0 && mDefaultMsgSyncPeriod > mDefaultMsgStorePeriod) @@ -379,8 +432,7 @@ int RsGxsNetService::tick() { // always check for new items arriving // from peers - if(receivedItems()) - recvNxsItemQueue(); + recvNxsItemQueue(); bool should_notify = false; @@ -403,6 +455,7 @@ int RsGxsNetService::tick() { syncWithPeers(); syncGrpStatistics(); + checkDistantSyncState(); mSyncTs = now; } @@ -450,8 +503,8 @@ void RsGxsNetService::processObserverNotifications() mNewPublishKeysToNotify.clear() ; } - if(!grps_copy.empty()) mObserver->notifyNewGroups (grps_copy); - if(!msgs_copy.empty()) mObserver->notifyNewMessages(msgs_copy); + if(!grps_copy.empty()) mObserver->receiveNewGroups (grps_copy); + if(!msgs_copy.empty()) mObserver->receiveNewMessages(msgs_copy); for(std::set::const_iterator it(keys_copy.begin());it!=keys_copy.end();++it) mObserver->notifyReceivePublishKey(*it); @@ -520,6 +573,18 @@ void RsGxsNetService::syncWithPeers() std::set peers; mNetMgr->getOnlineList(mServiceInfo.mServiceType, peers); + + if(mAllowDistSync && mGxsNetTunnel != NULL) + { + // Grab all online virtual peers of distant tunnels for the current service. + + std::list vpids ; + mGxsNetTunnel->getVirtualPeers(vpids); + + for(auto it(vpids.begin());it!=vpids.end();++it) + peers.insert(RsPeerId(*it)) ; + } + if (peers.empty()) { // nothing to do return; @@ -549,7 +614,7 @@ void RsGxsNetService::syncWithPeers() #ifdef NXS_NET_DEBUG_5 GXSNETDEBUG_P_(*sit) << "Service "<< std::hex << ((mServiceInfo.mServiceType >> 8)& 0xffff) << std::dec << " sending global group TS of peer id: " << *sit << " ts=" << nice_time_stamp(time(NULL),updateTS) << " (secs ago) to himself" << std::endl; #endif - sendItem(grp); + generic_sendItem(grp); } if(!mAllowMsgSync) @@ -665,7 +730,7 @@ void RsGxsNetService::syncWithPeers() #ifdef NXS_NET_DEBUG_7 GXSNETDEBUG_PG(*sit,grpId) << " Service " << std::hex << ((mServiceInfo.mServiceType >> 8)& 0xffff) << std::dec << " sending message TS of peer id: " << *sit << " ts=" << nice_time_stamp(time(NULL),updateTS) << " (secs ago) for group " << grpId << " to himself - in clear " << std::endl; #endif - sendItem(msg); + generic_sendItem(msg); #ifdef NXS_NET_DEBUG_5 GXSNETDEBUG_PG(*sit,grpId) << "Service "<< std::hex << ((mServiceInfo.mServiceType >> 8)& 0xffff) << std::dec << " sending global message TS of peer id: " << *sit << " ts=" << nice_time_stamp(time(NULL),updateTS) << " (secs ago) for group " << grpId << " to himself" << std::endl; @@ -676,6 +741,91 @@ void RsGxsNetService::syncWithPeers() #endif } +void RsGxsNetService::generic_sendItem(RsNxsItem *si) +{ + // check if the item is to be sent to a distant peer or not + + RsGxsGroupId tmp_grpId; + + if(mAllowDistSync && mGxsNetTunnel != NULL && mGxsNetTunnel->isDistantPeer( static_cast(si->PeerId()),tmp_grpId)) + { + RsNxsSerialiser ser(mServType); + + uint32_t size = ser.size(si); + unsigned char *mem = (unsigned char *)rs_malloc(size) ; + + if(!mem) + return ; + +#ifdef NXS_NET_DEBUG_8 + GXSNETDEBUG_P_(si->PeerId()) << "Sending RsGxsNetTunnelService Item:" << (void*)si << " of type: " << std::hex << si->PacketId() << std::dec + << " transaction " << si->transactionNumber << " to virtual peer " << si->PeerId() << std::endl ; +#endif + ser.serialise(si,mem,&size) ; + + mGxsNetTunnel->sendTunnelData(mServType,mem,size,static_cast(si->PeerId())); + } + else + sendItem(si) ; +} + +void RsGxsNetService::checkDistantSyncState() +{ + if(!mAllowDistSync || mGxsNetTunnel==NULL || !mGrpAutoSync) + return ; + + RsGxsGrpMetaTemporaryMap grpMeta; + mDataStore->retrieveGxsGrpMetaData(grpMeta); + + // Go through group statistics and groups without information are re-requested to random peers selected + // among the ones who provided the group info. + +#ifdef NXS_NET_DEBUG_8 + GXSNETDEBUG___<< "Checking distant sync for all groups." << std::endl; +#endif + // get the list of online peers + + std::set online_peers; + mNetMgr->getOnlineList(mServiceInfo.mServiceType , online_peers); + + RS_STACK_MUTEX(mNxsMutex) ; + + for(auto it(grpMeta.begin());it!=grpMeta.end();++it) + if(it->second->mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_SUBSCRIBED) // we only consider subscribed groups here. + { +#warning (cyril) We might need to also remove peers for recently unsubscribed groups + const RsGxsGroupId& grpId(it->first); + const RsGxsGrpConfig& rec = locked_getGrpConfig(grpId) ; + +#ifdef NXS_NET_DEBUG_6 + GXSNETDEBUG__G(it->first) << " group " << grpId; +#endif + bool at_least_one_friend_is_supplier = false ; + + for(auto it2(rec.suppliers.ids.begin());it2!=rec.suppliers.ids.end() && !at_least_one_friend_is_supplier;++it2) + if(online_peers.find(*it2) != online_peers.end()) // check that the peer is online + at_least_one_friend_is_supplier = true ; + + // That strategy is likely to create islands of friends connected to each other. There's no real way + // to decide what to do here, except maybe checking the last message TS remotely vs. locally. + + if(at_least_one_friend_is_supplier) + { + mGxsNetTunnel->releaseDistantPeers(mServType,grpId); +#ifdef NXS_NET_DEBUG_8 + GXSNETDEBUG___<< " Group " << grpId << ": suppliers among friends. Releasing peers." << std::endl; +#endif + } + else + { + mGxsNetTunnel->requestDistantPeers(mServType,grpId); +#ifdef NXS_NET_DEBUG_8 + GXSNETDEBUG___<< " Group " << grpId << ": no suppliers among friends. Requesting peers." << std::endl; +#endif + } + } +} + void RsGxsNetService::syncGrpStatistics() { RS_STACK_MUTEX(mNxsMutex) ; @@ -690,6 +840,17 @@ void RsGxsNetService::syncGrpStatistics() std::set online_peers; mNetMgr->getOnlineList(mServiceInfo.mServiceType, online_peers); + if(mAllowDistSync && mGxsNetTunnel != NULL) + { + // Grab all online virtual peers of distant tunnels for the current service. + + std::list vpids ; + mGxsNetTunnel->getVirtualPeers(vpids); + + for(auto it(vpids.begin());it!=vpids.end();++it) + online_peers.insert(RsPeerId(*it)) ; + } + // Go through group statistics and groups without information are re-requested to random peers selected // among the ones who provided the group info. @@ -704,44 +865,44 @@ void RsGxsNetService::syncGrpStatistics() #endif if(rec.statistics_update_TS + GROUP_STATS_UPDATE_DELAY < now && rec.suppliers.ids.size() > 0) - { + { #ifdef NXS_NET_DEBUG_6 - GXSNETDEBUG__G(it->first) << " needs update. Randomly asking to some friends" << std::endl; + GXSNETDEBUG__G(it->first) << " needs update. Randomly asking to some friends" << std::endl; #endif - // randomly select GROUP_STATS_UPDATE_NB_PEERS friends among the suppliers of this group + // randomly select GROUP_STATS_UPDATE_NB_PEERS friends among the suppliers of this group - uint32_t n = RSRandom::random_u32() % rec.suppliers.ids.size() ; + uint32_t n = RSRandom::random_u32() % rec.suppliers.ids.size() ; - std::set::const_iterator rit = rec.suppliers.ids.begin(); - for(uint32_t i=0;i::const_iterator rit = rec.suppliers.ids.begin(); + for(uint32_t i=0;ifirst) << " asking friend " << peer_id << " for an update of stats for group " << it->first << std::endl; + GXSNETDEBUG_PG(peer_id,it->first) << " asking friend " << peer_id << " for an update of stats for group " << it->first << std::endl; #endif - RsNxsSyncGrpStatsItem *grs = new RsNxsSyncGrpStatsItem(mServType) ; + RsNxsSyncGrpStatsItem *grs = new RsNxsSyncGrpStatsItem(mServType) ; - grs->request_type = RsNxsSyncGrpStatsItem::GROUP_INFO_TYPE_REQUEST ; + grs->request_type = RsNxsSyncGrpStatsItem::GROUP_INFO_TYPE_REQUEST ; - grs->grpId = it->first ; - grs->PeerId(peer_id) ; + grs->grpId = it->first ; + grs->PeerId(peer_id) ; - sendItem(grs) ; + generic_sendItem(grs) ; + } } - } - } + } #ifdef NXS_NET_DEBUG_6 else GXSNETDEBUG__G(it->first) << " up to date." << std::endl; @@ -819,7 +980,7 @@ void RsGxsNetService::handleRecvSyncGrpStatistics(RsNxsSyncGrpStatsItem *grs) GXSNETDEBUG_PG(grs->PeerId(),grs->grpId) << " sending back statistics item with " << vec.size() << " elements." << std::endl; #endif - sendItem(grs_resp) ; + generic_sendItem(grs_resp) ; } else if(grs->request_type == RsNxsSyncGrpStatsItem::GROUP_INFO_TYPE_RESPONSE) { @@ -1391,11 +1552,11 @@ public: void operator() (RsItem* item) { - RsGxsMsgUpdateItem* mui; - RsGxsGrpUpdateItem* gui; - RsGxsServerGrpUpdateItem* gsui; - RsGxsServerMsgUpdateItem* msui; - RsGxsGrpConfigItem* mgci; + RsGxsMsgUpdateItem *mui; + RsGxsGrpUpdateItem *gui; + RsGxsServerGrpUpdateItem *gsui; + RsGxsServerMsgUpdateItem *msui; + RsGxsGrpConfigItem *mgci; if((mui = dynamic_cast(item)) != NULL) check_store(mui->peerID,mClientMsgMap,*mui); @@ -1421,7 +1582,6 @@ private: RsGxsNetService::GrpConfigMap& mGrpConfigMap; RsGxsServerGrpUpdate& mServerGrpUpdate; - }; bool RsGxsNetService::loadList(std::list &load) @@ -1431,11 +1591,10 @@ bool RsGxsNetService::loadList(std::list &load) // The delete is done in StoreHere, if necessary std::for_each(load.begin(), load.end(), StoreHere(mClientGrpUpdateMap, mClientMsgUpdateMap, mServerMsgUpdateMap, mServerGrpConfigMap, mGrpServerUpdate)); + time_t now = time(NULL); // We reset group statistics here. This is the best place since we know at this point which are all unsubscribed groups. - time_t now = time(NULL); - for(GrpConfigMap::iterator it(mServerGrpConfigMap.begin());it!=mServerGrpConfigMap.end();++it) { // At each reload, we reset the count of visible messages. It will be rapidely restored to its real value from friends. @@ -1489,6 +1648,7 @@ struct get_second : public std::unary_function& save) { RS_STACK_MUTEX(mNxsMutex) ; @@ -1520,11 +1680,44 @@ RsSerialiser *RsGxsNetService::setupSerialiser() return rss; } +RsItem *RsGxsNetService::generic_recvItem() +{ + { + RsItem *item ; + + if(NULL != (item=recvItem())) + return item ; + } + + unsigned char *data = NULL ; + uint32_t size = 0 ; + RsGxsNetTunnelVirtualPeerId virtual_peer_id ; + + while(mAllowDistSync && mGxsNetTunnel!=NULL && mGxsNetTunnel->receiveTunnelData(mServType,data,size,virtual_peer_id)) + { + RsNxsItem *item = dynamic_cast(RsNxsSerialiser(mServType).deserialise(data,&size)) ; + item->PeerId(virtual_peer_id) ; + + free(data) ; + + if(!item) + continue ; + +#ifdef NXS_NET_DEBUG_8 + GXSNETDEBUG_P_(item->PeerId()) << "Received RsGxsNetTunnelService Item:" << (void*)item << " of type: " << std::hex << item->PacketId() << std::dec + << " transaction " << item->transactionNumber << " from virtual peer " << item->PeerId() << std::endl ; +#endif + return item ; + } + + return NULL ; +} + void RsGxsNetService::recvNxsItemQueue() { RsItem *item ; - while(NULL != (item=recvItem())) + while(NULL != (item=generic_recvItem())) { #ifdef NXS_NET_DEBUG_1 GXSNETDEBUG_P_(item->PeerId()) << "Received RsGxsNetService Item:" << (void*)item << " type=" << std::hex << item->PacketId() << std::dec << std::endl ; @@ -1829,7 +2022,7 @@ void RsGxsNetService::debugDump() GXSNETDEBUG___<< "RsGxsNetService::debugDump():" << std::endl; - RsGxsMetaDataTemporaryMap grpMetas; + RsGxsGrpMetaTemporaryMap grpMetas; if(!group_id_to_print.isNull()) grpMetas[group_id_to_print] = NULL ; @@ -1842,7 +2035,7 @@ void RsGxsNetService::debugDump() for(ServerMsgMap::const_iterator it(mServerMsgUpdateMap.begin());it!=mServerMsgUpdateMap.end();++it) { - RsGxsMetaDataTemporaryMap::const_iterator it2 = grpMetas.find(it->first) ; + RsGxsGrpMetaTemporaryMap::const_iterator it2 = grpMetas.find(it->first) ; RsGxsGrpMetaData *grpMeta = (it2 != grpMetas.end())? it2->second : NULL; std::string subscribe_string = (grpMeta==NULL)?"Unknown" : ((grpMeta->mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_SUBSCRIBED)?" Subscribed":" NOT Subscribed") ; @@ -2125,7 +2318,7 @@ void RsGxsNetService::processTransactions() lit_end = tr->mItems.end(); for(; lit != lit_end; ++lit){ - sendItem(*lit); + generic_sendItem(*lit); } tr->mItems.clear(); // clear so they don't get deleted in trans cleaning @@ -2234,7 +2427,7 @@ void RsGxsNetService::processTransactions() trans->transactFlag = RsNxsTransacItem::FLAG_END_SUCCESS; trans->transactionNumber = transN; trans->PeerId(tr->mTransaction->PeerId()); - sendItem(trans); + generic_sendItem(trans); // move to completed transactions @@ -2277,7 +2470,7 @@ void RsGxsNetService::processTransactions() (tr->mTransaction->transactFlag & RsNxsTransacItem::FLAG_TYPE_MASK); trans->transactionNumber = transN; trans->PeerId(tr->mTransaction->PeerId()); - sendItem(trans); + generic_sendItem(trans); tr->mFlag = NxsTransaction::FLAG_STATE_RECEIVING; } @@ -2654,7 +2847,7 @@ void RsGxsNetService::locked_pushMsgTransactionFromList(std::list& r newTrans->mTransaction->PeerId(mOwnId); if (locked_addTransaction(newTrans)) - sendItem(transac); + generic_sendItem(transac); else { delete newTrans; @@ -2950,7 +3143,7 @@ void RsGxsNetService::locked_pushGrpTransactionFromList( std::list& newTrans->mTransaction->PeerId(mOwnId); if (locked_addTransaction(newTrans)) - sendItem(transac); + generic_sendItem(transac); else { delete newTrans; @@ -3084,7 +3277,7 @@ void RsGxsNetService::locked_genSendGrpsTransaction(NxsTransaction* tr) { #ifdef NXS_NET_DEBUG_1 - GXSNETDEBUG_P_(tr->mTransaction->PeerId()) << "locked_genSendGrpsTransaction() Generating Grp data send fron TransN: " << tr->mTransaction->transactionNumber << std::endl; + GXSNETDEBUG_P_(tr->mTransaction->PeerId()) << "locked_genSendGrpsTransaction() Generating Grp data send from TransN: " << tr->mTransaction->transactionNumber << std::endl; #endif // go groups requested in transaction tr @@ -3097,7 +3290,12 @@ void RsGxsNetService::locked_genSendGrpsTransaction(NxsTransaction* tr) { RsNxsSyncGrpItem* item = dynamic_cast(*lit); if (item) + { +#ifdef NXS_NET_DEBUG_1 + GXSNETDEBUG_PG(tr->mTransaction->PeerId(),item->grpId) << "locked_genSendGrpsTransaction() retrieving data for group \"" << item->grpId << "\"" << std::endl; +#endif grps[item->grpId] = NULL; + } else { #ifdef NXS_NET_DEBUG_1 @@ -3109,7 +3307,12 @@ void RsGxsNetService::locked_genSendGrpsTransaction(NxsTransaction* tr) if(!grps.empty()) mDataStore->retrieveNxsGrps(grps, false, false); else + { +#ifdef NXS_NET_DEBUG_1 + GXSNETDEBUG_P_(tr->mTransaction->PeerId()) << "RsGxsNetService::locked_genSendGrpsTransaction(): no group to request! This is unexpected" << std::endl; +#endif return; + } NxsTransaction* newTr = new NxsTransaction(); newTr->mFlag = NxsTransaction::FLAG_STATE_WAITING_CONFIRM; @@ -3126,6 +3329,9 @@ void RsGxsNetService::locked_genSendGrpsTransaction(NxsTransaction* tr) mit->second->transactionNumber = transN; newTr->mItems.push_back(mit->second); mit->second = NULL ; // avoids deletion +#ifdef NXS_NET_DEBUG_1 + GXSNETDEBUG_PG(tr->mTransaction->PeerId(),mit->first) << "RsGxsNetService::locked_genSendGrpsTransaction(): adding grp data of group \"" << mit->first << "\" to transaction" << std::endl; +#endif } if(newTr->mItems.empty()){ @@ -3154,8 +3360,8 @@ void RsGxsNetService::locked_genSendGrpsTransaction(NxsTransaction* tr) ntr->PeerId(tr->mTransaction->PeerId()); if(locked_addTransaction(newTr)) - sendItem(ntr); - else + generic_sendItem(ntr); + else { delete ntr ; delete newTr; @@ -3449,7 +3655,7 @@ void RsGxsNetService::locked_genSendMsgsTransaction(NxsTransaction* tr) ntr->PeerId(tr->mTransaction->PeerId()); if(locked_addTransaction(newTr)) - sendItem(ntr); + generic_sendItem(ntr); else { delete ntr ; @@ -3768,7 +3974,7 @@ void RsGxsNetService::locked_pushGrpRespFromList(std::list& respList << peer << " with " << respList.size() << " groups " << std::endl; #endif if(locked_addTransaction(tr)) - sendItem(trItem); + generic_sendItem(trItem); else { delete tr ; @@ -3910,6 +4116,18 @@ bool RsGxsNetService::canSendGrpId(const RsPeerId& sslId, const RsGxsGrpMetaData #ifdef NXS_NET_DEBUG_4 GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << "RsGxsNetService::canSendGrpId()"<< std::endl; #endif + // check if that peer is a virtual peer id, in which case we only send/recv data to/from it items for the group it's requested for + + RsGxsGroupId peer_grp ; + if(mAllowDistSync && mGxsNetTunnel != NULL && mGxsNetTunnel->isDistantPeer(RsGxsNetTunnelVirtualPeerId(sslId),peer_grp) && peer_grp != grpMeta.mGroupId) + { +#warning (cyril) make sure that this is not a problem for cross-service sending of items +#ifdef NXS_NET_DEBUG_4 + GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " Distant peer designed for group " << peer_grp << ": cannot request sync for different group." << std::endl; +#endif + return false ; + } + // first do the simple checks uint8_t circleType = grpMeta.mCircleType; @@ -3963,6 +4181,17 @@ bool RsGxsNetService::checkCanRecvMsgFromPeer(const RsPeerId& sslId, const RsGxs GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << "RsGxsNetService::checkCanRecvMsgFromPeer()"; GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " peer Id = " << sslId << ", grpId=" << grpMeta.mGroupId <isDistantPeer(RsGxsNetTunnelVirtualPeerId(sslId),peer_grp) && peer_grp != grpMeta.mGroupId) + { +#ifdef NXS_NET_DEBUG_4 + GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " Distant peer designed for group " << peer_grp << ": cannot request sync for different group." << std::endl; +#endif + return false ; + } + // first do the simple checks uint8_t circleType = grpMeta.mCircleType; should_encrypt_id.clear() ; @@ -4293,7 +4522,7 @@ void RsGxsNetService::locked_pushMsgRespFromList(std::list& itemL, c #endif // signal peer to prepare for transaction if(locked_addTransaction(tr)) - sendItem(trItem); + generic_sendItem(trItem); else { delete tr ; @@ -4306,6 +4535,16 @@ bool RsGxsNetService::canSendMsgIds(std::vector& msgMetas, co #ifdef NXS_NET_DEBUG_4 GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << "RsGxsNetService::canSendMsgIds() CIRCLE VETTING" << std::endl; #endif + // check if that peer is a virtual peer id, in which case we only send/recv data to/from it items for the group it's requested for + + RsGxsGroupId peer_grp ; + if(mAllowDistSync && mGxsNetTunnel != NULL && mGxsNetTunnel->isDistantPeer(RsGxsNetTunnelVirtualPeerId(sslId),peer_grp) && peer_grp != grpMeta.mGroupId) + { +#ifdef NXS_NET_DEBUG_4 + GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " Distant peer designed for group " << peer_grp << ": cannot request sync for different group." << std::endl; +#endif + return false ; + } // first do the simple checks uint8_t circleType = grpMeta.mCircleType; @@ -4546,7 +4785,7 @@ void RsGxsNetService::processExplicitGroupRequests() for(; git != groupIdList.end(); ++git) { #ifdef NXS_NET_DEBUG_0 - GXSNETDEBUG_PG(peerId,*git) << " group request for grp ID " << *git << " to peer " << peerId << std::endl; + GXSNETDEBUG_P_(peerId) << " group request for grp ID " << *git << " to peer " << peerId << std::endl; #endif RsNxsSyncGrpItem* item = new RsNxsSyncGrpItem(mServType); item->grpId = *git; @@ -4680,7 +4919,7 @@ void RsGxsNetService::sharePublishKeysPending() publishKeyItem->private_key = publishKey ; publishKeyItem->PeerId(*it); - sendItem(publishKeyItem); + generic_sendItem(publishKeyItem); #ifdef NXS_NET_DEBUG_3 GXSNETDEBUG_PG(*it,grpMeta->mGroupId) << " sent key item to " << *it << std::endl; #endif @@ -4841,6 +5080,18 @@ bool RsGxsNetService::removeGroups(const std::list& groups) return true ; } +bool RsGxsNetService::isDistantPeer(const RsPeerId& pid) +{ + RS_STACK_MUTEX(mNxsMutex) ; + + if(!mAllowDistSync || mGxsNetTunnel == NULL) + return false ; + + RsGxsGroupId group_id ; + + return mGxsNetTunnel->isDistantPeer(RsGxsNetTunnelVirtualPeerId(pid),group_id); +} + bool RsGxsNetService::stampMsgServerUpdateTS(const RsGxsGroupId& gid) { RS_STACK_MUTEX(mNxsMutex) ; @@ -4856,3 +5107,332 @@ bool RsGxsNetService::locked_stampMsgServerUpdateTS(const RsGxsGroupId& gid) return true; } + +TurtleRequestId RsGxsNetService::turtleGroupRequest(const RsGxsGroupId& group_id) +{ + RS_STACK_MUTEX(mNxsMutex) ; + + time_t now = time(NULL); + auto it = mSearchedGroups.find(group_id) ; + + if(mSearchedGroups.end() != it && (it->second.ts + MIN_DELAY_BETWEEN_GROUP_SEARCH > now)) + { + std::cerr << "(WW) Last turtle request was " << now - it->second.ts << " secs ago. Not searching again." << std::endl; + return it->second.request_id; + } + +#ifdef NXS_NET_DEBUG_8 + GXSNETDEBUG__G(group_id) << " requesting group id " << group_id << " using turtle" << std::endl; +#endif + TurtleRequestId req = mGxsNetTunnel->turtleGroupRequest(group_id,this) ; + + GroupRequestRecord& rec(mSearchedGroups[group_id]) ; + + rec.request_id = req; + rec.ts = now; + + mSearchRequests[req] = group_id; + + return req; +} +TurtleRequestId RsGxsNetService::turtleSearchRequest(const std::string& match_string) +{ + return mGxsNetTunnel->turtleSearchRequest(match_string,this) ; +} + +static bool termSearch(const std::string& src, const std::string& substring) +{ + /* always ignore case */ + return src.end() != std::search( src.begin(), src.end(), substring.begin(), substring.end(), RsRegularExpression::CompareCharIC() ); +} + +bool RsGxsNetService::retrieveDistantSearchResults(TurtleRequestId req,std::map& group_infos) +{ + RS_STACK_MUTEX(mNxsMutex) ; + + auto it = mDistantSearchResults.find(req) ; + + if(it == mDistantSearchResults.end()) + return false ; + + group_infos = it->second; + return true ; +} +bool RsGxsNetService::retrieveDistantGroupSummary(const RsGxsGroupId& group_id,RsGxsGroupSummary& gs) +{ + RS_STACK_MUTEX(mNxsMutex) ; + for(auto it(mDistantSearchResults.begin());it!=mDistantSearchResults.end();++it) + { + auto it2 = it->second.find(group_id) ; + + if(it2 != it->second.end()) + { + gs = it2->second; + return true ; + } + } + return false ; +} +bool RsGxsNetService::clearDistantSearchResults(const TurtleRequestId& id) +{ + RS_STACK_MUTEX(mNxsMutex) ; + mDistantSearchResults.erase(id); + return true ; +} +void RsGxsNetService::receiveTurtleSearchResults(TurtleRequestId req, const std::list& group_infos) +{ + std::set groupsToNotifyResults; + + { + RS_STACK_MUTEX(mNxsMutex); + + RsGxsGrpMetaTemporaryMap grpMeta; + std::map& + search_results_map(mDistantSearchResults[req]); + + for(auto it(group_infos.begin());it!=group_infos.end();++it) + if(search_results_map.find((*it).mGroupId) == search_results_map.end()) + grpMeta[(*it).mGroupId] = NULL; + + mDataStore->retrieveGxsGrpMetaData(grpMeta); + + // only keep groups that are not locally known, and groups that are not already in the mDistantSearchResults structure + + for(auto it(group_infos.begin());it!=group_infos.end();++it) + if(grpMeta[(*it).mGroupId] == NULL) + { + const RsGxsGroupId& grpId((*it).mGroupId); + + groupsToNotifyResults.insert(grpId); + + auto it2 = search_results_map.find(grpId); + + if(it2 != search_results_map.end()) + { + // update existing data + + it2->second.mPopularity++; + it2->second.mNumberOfMessages = std::max( + it2->second.mNumberOfMessages, + (*it).mNumberOfMessages ); + } + else + { + search_results_map[grpId] = *it; + search_results_map[grpId].mPopularity = 1; // number of results so far + } + } + } // end RS_STACK_MUTEX(mNxsMutex); + + for(const RsGxsGroupId& grpId : groupsToNotifyResults) + mObserver->receiveDistantSearchResults(req, grpId); +} + +void RsGxsNetService::receiveTurtleSearchResults(TurtleRequestId req,const unsigned char *encrypted_group_data,uint32_t encrypted_group_data_len) +{ +#ifdef NXS_NET_DEBUG_8 + GXSNETDEBUG___ << " received encrypted group data for turtle search request " << std::hex << req << std::dec << ": " << RsUtil::BinToHex(encrypted_group_data,encrypted_group_data_len,50) << std::endl; +#endif + auto it = mSearchRequests.find(req); + + if(mSearchRequests.end() == it) + { + std::cerr << "(EE) received search results for unknown request " << std::hex << req << std::dec ; + return; + } + RsGxsGroupId grpId = it->second; + + uint8_t encryption_master_key[32]; + Sha256CheckSum s = RsDirUtil::sha256sum(grpId.toByteArray(),grpId.SIZE_IN_BYTES); + memcpy(encryption_master_key,s.toByteArray(),32); + +#ifdef NXS_NET_DEBUG_8 + GXSNETDEBUG___ << " attempting data decryption with master key " << RsUtil::BinToHex(encryption_master_key,32) << std::endl; +#endif + unsigned char *clear_group_data = NULL; + uint32_t clear_group_data_len ; + + if(!librs::crypto::decryptAuthenticateData(encrypted_group_data,encrypted_group_data_len,encryption_master_key,clear_group_data,clear_group_data_len)) + { + std::cerr << "(EE) Could not decrypt data. Something went wrong. Wrong key??" << std::endl; + return ; + } + +#ifdef NXS_NET_DEBUG_8 + GXSNETDEBUG___ << " successfuly decrypted data : " << RsUtil::BinToHex(clear_group_data,clear_group_data_len,50) << std::endl; +#endif + RsItem *item = RsNxsSerialiser(mServType).deserialise(clear_group_data,&clear_group_data_len) ; + free(clear_group_data); + clear_group_data = NULL ; + + RsNxsGrp *nxs_grp = dynamic_cast(item) ; + + if(nxs_grp == NULL) + { + std::cerr << "(EE) decrypted item is not a RsNxsGrp. Weird!" << std::endl; + return ; + } + std::vector new_grps(1,nxs_grp); + +#ifdef NXS_NET_DEBUG_8 + GXSNETDEBUG___ << " passing the grp data to observer." << std::endl; +#endif + mObserver->receiveNewGroups(new_grps); +} + +bool RsGxsNetService::search( const std::string& substring, + std::list& group_infos ) +{ + group_infos.clear(); + +#ifdef RS_DEEP_SEARCH + std::vector results; + DeepSearch::search(substring, results); + + for(auto dsr : results) + { + RsUrl rUrl(dsr.mUrl); + const auto& uQ(rUrl.query()); + auto rit = uQ.find("id"); + if(rit != rUrl.query().end()) + { + RsGroupNetworkStats stats; + RsGxsGroupId grpId(rit->second); + if( !grpId.isNull() && getGroupNetworkStats(grpId, stats) ) + { + RsGxsGroupSummary s; + + s.mGroupId = grpId; + + if((rit = uQ.find("name")) != uQ.end()) + s.mGroupName = rit->second; + if((rit = uQ.find("signFlags")) != uQ.end()) + s.mSignFlags = std::stoul(rit->second); + if((rit = uQ.find("publishTs")) != uQ.end()) + s.mPublishTs = static_cast(std::stoll(rit->second)); + if((rit = uQ.find("authorId")) != uQ.end()) + s.mAuthorId = RsGxsId(rit->second); + + s.mSearchContext = dsr.mSnippet; + + s.mNumberOfMessages = stats.mMaxVisibleCount; + s.mLastMessageTs = stats.mLastGroupModificationTS; + s.mPopularity = stats.mSuppliers; + + group_infos.push_back(s); + } + } + } +#else // RS_DEEP_SEARCH + RsGxsGrpMetaTemporaryMap grpMetaMap; + { + RS_STACK_MUTEX(mNxsMutex) ; + mDataStore->retrieveGxsGrpMetaData(grpMetaMap); + } + + RsGroupNetworkStats stats; + for(auto it(grpMetaMap.begin());it!=grpMetaMap.end();++it) + if(termSearch(it->second->mGroupName,substring)) + { + getGroupNetworkStats(it->first,stats); + + RsGxsGroupSummary s; + s.mGroupId = it->first; + s.mGroupName = it->second->mGroupName; + s.mSearchContext = it->second->mGroupName; + s.mSignFlags = it->second->mSignFlags; + s.mPublishTs = it->second->mPublishTs; + s.mAuthorId = it->second->mAuthorId; + s.mNumberOfMessages = stats.mMaxVisibleCount; + s.mLastMessageTs = stats.mLastGroupModificationTS; + s.mPopularity = it->second->mPop; + + group_infos.push_back(s); + } +#endif // RS_DEEP_SEARCH + +#ifdef NXS_NET_DEBUG_8 + GXSNETDEBUG___ << " performing local substring search in response to distant request. Found " << group_infos.size() << " responses." << std::endl; +#endif + return !group_infos.empty(); +} + +bool RsGxsNetService::search(const Sha1CheckSum& hashed_group_id,unsigned char *& encrypted_group_data,uint32_t& encrypted_group_data_len) +{ + // First look into the grp hash cache + +#ifdef NXS_NET_DEBUG_8 + GXSNETDEBUG___ << " Received group data request for hash " << hashed_group_id << std::endl; +#endif + auto it = mGroupHashCache.find(hashed_group_id) ; + RsNxsGrp *grp_data = NULL ; + + if(mGroupHashCache.end() != it) + { + grp_data = it->second; + } + else + { + // Now check if the last request was too close in time, in which case, we dont retrieve data. + + if(mLastCacheReloadTS + 60 > time(NULL)) + { + std::cerr << "(WW) Not found in cache, and last cache reload less than 60 secs ago. Returning false. " << std::endl; + return false ; + } + +#ifdef NXS_NET_DEBUG_8 + GXSNETDEBUG___ << " reloading group cache information" << std::endl; +#endif + RsNxsGrpDataTemporaryMap grpDataMap; + { + RS_STACK_MUTEX(mNxsMutex) ; + mDataStore->retrieveNxsGrps(grpDataMap, true, true); + mLastCacheReloadTS = time(NULL); + } + + for(auto it(grpDataMap.begin());it!=grpDataMap.end();++it) + if(it->second->metaData->mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_SUBSCRIBED ) // only cache subscribed groups + { + RsNxsGrp *grp = it->second ; + delete grp->metaData ; // clean private keys + grp->metaData = NULL ; + + Sha1CheckSum hash(RsDirUtil::sha1sum(it->first.toByteArray(),it->first.SIZE_IN_BYTES)); + + mGroupHashCache[hash] = grp ; + it->second = NULL ; // prevents deletion + + if(hash == hashed_group_id) + grp_data = grp ; + } + } + + if(!grp_data) + { +#ifdef NXS_NET_DEBUG_8 + GXSNETDEBUG___ << " no group found for hash " << hashed_group_id << ": returning false." << std::endl; +#endif + return false ; + } + +#ifdef NXS_NET_DEBUG_8 + GXSNETDEBUG___ << " found corresponding group data group id in cache group_id=" << grp_data->grpId << std::endl; +#endif + // Finally, serialize and encrypt the grp data + + uint32_t size = RsNxsSerialiser(mServType).size(grp_data); + RsTemporaryMemory mem(size) ; + + RsNxsSerialiser(mServType).serialise(grp_data,mem,&size) ; + + uint8_t encryption_master_key[32]; + Sha256CheckSum s = RsDirUtil::sha256sum(grp_data->grpId.toByteArray(),grp_data->grpId.SIZE_IN_BYTES); + memcpy(encryption_master_key,s.toByteArray(),32); + +#ifdef NXS_NET_DEBUG_8 + GXSNETDEBUG___ << " sending data encrypted with master key " << RsUtil::BinToHex(encryption_master_key,32) << std::endl; +#endif + return librs::crypto::encryptAuthenticateData(mem,size,encryption_master_key,encrypted_group_data,encrypted_group_data_len); +} + diff --git a/libretroshare/src/gxs/rsgxsnetservice.h b/libretroshare/src/gxs/rsgxsnetservice.h index 00ba07953..67a8ca054 100644 --- a/libretroshare/src/gxs/rsgxsnetservice.h +++ b/libretroshare/src/gxs/rsgxsnetservice.h @@ -1,31 +1,27 @@ +/******************************************************************************* + * libretroshare/src/gxs: rsgxsnetservice.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012-2012 by Christopher Evi-Parker * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RSGXSNETSERVICE_H #define RSGXSNETSERVICE_H -/* - * libretroshare/src/gxs: rsgxnetservice.h - * - * Access to rs network and synchronisation service implementation - * - * Copyright 2012-2012 by Christopher Evi-Parker - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - #include #include @@ -35,6 +31,7 @@ #include "pqi/p3linkmgr.h" #include "rsitems/rsnxsitems.h" #include "rsitems/rsgxsupdateitems.h" +#include "rsgxsnettunnel.h" #include "rsgxsnetutils.h" #include "pqi/p3cfgmgr.h" #include "rsgixs.h" @@ -58,6 +55,14 @@ class RsGroupNetworkStatsRecord time_t update_TS ; }; +struct GroupRequestRecord +{ + GroupRequestRecord(): ts(0), request_id(0) {} + + time_t ts ; + TurtleRequestId request_id; +}; + /*! * This class implements the RsNetWorkExchangeService * using transactions to handle synchrnisation of Nxs items between @@ -89,8 +94,8 @@ public: RsNxsObserver *nxsObs, // used to be = NULL. const RsServiceInfo serviceInfo, RsGixsReputation* reputations = NULL, RsGcxs* circles = NULL, RsGixs *gixs=NULL, - PgpAuxUtils *pgpUtils = NULL, - bool grpAutoSync = true, bool msgAutoSync = true, + PgpAuxUtils *pgpUtils = NULL, RsGxsNetTunnelService *mGxsNT = NULL, + bool grpAutoSync = true, bool msgAutoSync = true,bool distSync=false, uint32_t default_store_period = RS_GXS_DEFAULT_MSG_STORE_PERIOD, uint32_t default_sync_period = RS_GXS_DEFAULT_MSG_REQ_PERIOD); @@ -103,6 +108,8 @@ public: public: + virtual uint16_t serviceType() const { return mServType ; } + /*! * Use this to set how far back synchronisation and storage of messages should take place * @param age the max age a sync/storage item can to be allowed in a synchronisation @@ -119,6 +126,23 @@ public: virtual void setDefaultKeepAge(uint32_t t) { mDefaultMsgStorePeriod = t ; } virtual void setDefaultSyncAge(uint32_t t) { mDefaultMsgSyncPeriod = t ; } + /*! + * \brief Search methods. + * These four methods are used to request distant search and receive the results. + * \param group_id + */ + virtual TurtleRequestId turtleGroupRequest(const RsGxsGroupId& group_id); + virtual TurtleRequestId turtleSearchRequest(const std::string& match_string); + + virtual bool search(const std::string& substring,std::list& group_infos) ; + virtual bool search(const Sha1CheckSum& hashed_group_id,unsigned char *& encrypted_group_data,uint32_t& encrypted_group_data_len); + virtual void receiveTurtleSearchResults(TurtleRequestId req,const std::list& group_infos); + virtual void receiveTurtleSearchResults(TurtleRequestId req,const unsigned char *encrypted_group_data,uint32_t encrypted_group_data_len); + + virtual bool retrieveDistantSearchResults(TurtleRequestId req, std::map &group_infos); + virtual bool clearDistantSearchResults(const TurtleRequestId& id); + virtual bool retrieveDistantGroupSummary(const RsGxsGroupId&,RsGxsGroupSummary&); + /*! * pauses synchronisation of subscribed groups and request for group id * from peers @@ -167,6 +191,7 @@ public: virtual bool getGroupServerUpdateTS(const RsGxsGroupId& gid,time_t& grp_server_update_TS,time_t& msg_server_update_TS) ; virtual bool stampMsgServerUpdateTS(const RsGxsGroupId& gid) ; virtual bool removeGroups(const std::list& groups); + virtual bool isDistantPeer(const RsPeerId& pid); /* p3Config methods */ public: @@ -394,6 +419,7 @@ private: void locked_pushGrpRespFromList(std::list& respList, const RsPeerId& peer, const uint32_t& transN); void locked_pushMsgRespFromList(std::list& itemL, const RsPeerId& sslId, const RsGxsGroupId &grp_id, const uint32_t& transN); + void checkDistantSyncState(); void syncWithPeers(); void syncGrpStatistics(); void addGroupItemToList(NxsTransaction*& tr, @@ -493,6 +519,9 @@ private: void cleanRejectedMessages(); void processObserverNotifications(); + void generic_sendItem(RsNxsItem *si); + RsItem *generic_recvItem(); + private: static void locked_checkDelay(uint32_t& time_in_secs); @@ -541,8 +570,11 @@ private: RsGixs *mGixs; RsGixsReputation* mReputations; PgpAuxUtils *mPgpUtils; + RsGxsNetTunnelService *mGxsNetTunnel; + bool mGrpAutoSync; bool mAllowMsgSync; + bool mAllowDistSync; // need to be verfied std::vector mPendingResp; @@ -577,10 +609,18 @@ private: std::set mNewStatsToNotify ; std::set mNewPublishKeysToNotify ; + // Distant search result map + std::map > mDistantSearchResults ; + void debugDump(); uint32_t mDefaultMsgStorePeriod ; uint32_t mDefaultMsgSyncPeriod ; + + std::map mGroupHashCache; + std::map mSearchRequests; + std::map mSearchedGroups ; + time_t mLastCacheReloadTS ; }; #endif // RSGXSNETSERVICE_H diff --git a/libretroshare/src/gxs/rsgxsnettunnel.cc b/libretroshare/src/gxs/rsgxsnettunnel.cc new file mode 100644 index 000000000..026ba822b --- /dev/null +++ b/libretroshare/src/gxs/rsgxsnettunnel.cc @@ -0,0 +1,1159 @@ +/* + * libretroshare/src/gxs: rsgxsnettunnel.cc + * + * General Data service, interface for RetroShare. + * + * Copyright 2018-2018 by Cyril Soler + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License Version 2 as published by the Free Software Foundation. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA. + * + * Please report all bugs and problems to "retroshare.project@gmail.com" + * + */ + +#include "util/rsdir.h" +#include "util/rstime.h" +#include "retroshare/rspeers.h" +#include "serialiser/rstypeserializer.h" +#include "gxs/rsnxs.h" +#include "rsgxsnettunnel.h" + +// #define DEBUG_RSGXSNETTUNNEL 1 + +#define GXS_NET_TUNNEL_NOT_IMPLEMENTED() { std::cerr << __PRETTY_FUNCTION__ << ": not yet implemented." << std::endl; } +#define GXS_NET_TUNNEL_DEBUG() std::cerr << time(NULL) << " : GXS_NET_TUNNEL: " << __FUNCTION__ << " : " +#define GXS_NET_TUNNEL_ERROR() std::cerr << "(EE) GXS_NET_TUNNEL ERROR : " + +static const uint32_t RS_GXS_NET_TUNNEL_MAX_ALLOWED_HITS_GROUP_DATA = 1; +static const uint32_t RS_GXS_NET_TUNNEL_MAX_ALLOWED_HITS_GROUP_SEARCH = 100; + +RsGxsDistSync *rsGxsDistSync = NULL; + +RsGxsNetTunnelService::RsGxsNetTunnelService(): mGxsNetTunnelMtx("GxsNetTunnel") +{ + mRandomBias.clear(); + + mLastKeepAlive = time(NULL) + (RSRandom::random_u32()%20); // adds some variance in order to avoid doing all this tasks at once across services + mLastAutoWash = time(NULL) + (RSRandom::random_u32()%20); + mLastDump = time(NULL) + (RSRandom::random_u32()%20); +} + +//===========================================================================================================================================// +// Transport Items // +//===========================================================================================================================================// + +const uint16_t RS_SERVICE_TYPE_GXS_NET_TUNNEL = 0x2233 ; + +const uint8_t RS_PKT_SUBTYPE_GXS_NET_TUNNEL_VIRTUAL_PEER = 0x01 ; +const uint8_t RS_PKT_SUBTYPE_GXS_NET_TUNNEL_KEEP_ALIVE = 0x02 ; +const uint8_t RS_PKT_SUBTYPE_GXS_NET_TUNNEL_RANDOM_BIAS = 0x03 ; +const uint8_t RS_PKT_SUBTYPE_GXS_NET_TUNNEL_TURTLE_SEARCH_SUBSTRING = 0x04 ; +const uint8_t RS_PKT_SUBTYPE_GXS_NET_TUNNEL_TURTLE_SEARCH_GROUP_REQUEST = 0x05 ; +// const uint8_t RS_PKT_SUBTYPE_GXS_NET_TUNNEL_TURTLE_SEARCH_GROUP_SUMMARY = 0x06; // DEPRECATED +const uint8_t RS_PKT_SUBTYPE_GXS_NET_TUNNEL_TURTLE_SEARCH_GROUP_DATA = 0x07 ; +const uint8_t RS_PKT_SUBTYPE_GXS_NET_TUNNEL_TURTLE_SEARCH_GROUP_SUMMARY = 0x08; + +class RsGxsNetTunnelItem: public RsItem +{ +public: + explicit RsGxsNetTunnelItem(uint8_t item_subtype) : RsItem(RS_PKT_VERSION_SERVICE,RS_SERVICE_TYPE_GXS_NET_TUNNEL,item_subtype) + { + // no priority. All items are encapsulated into generic Turtle items anyway. + } + + virtual ~RsGxsNetTunnelItem() {} + virtual void clear() {} +}; + +class RsGxsNetTunnelVirtualPeerItem: public RsGxsNetTunnelItem +{ +public: + RsGxsNetTunnelVirtualPeerItem() :RsGxsNetTunnelItem(RS_PKT_SUBTYPE_GXS_NET_TUNNEL_VIRTUAL_PEER) {} + + virtual ~RsGxsNetTunnelVirtualPeerItem() {} + + virtual void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx) + { + RsTypeSerializer::serial_process(j,ctx,virtual_peer_id,"virtual_peer_id") ; + } + + RsPeerId virtual_peer_id ; +}; + +class RsGxsNetTunnelKeepAliveItem: public RsGxsNetTunnelItem +{ +public: + RsGxsNetTunnelKeepAliveItem() :RsGxsNetTunnelItem(RS_PKT_SUBTYPE_GXS_NET_TUNNEL_KEEP_ALIVE) {} + + virtual ~RsGxsNetTunnelKeepAliveItem() {} + virtual void serial_process(RsGenericSerializer::SerializeJob /* j */,RsGenericSerializer::SerializeContext& /* ctx */) {} +}; + +class RsGxsNetTunnelRandomBiasItem: public RsGxsNetTunnelItem +{ +public: + explicit RsGxsNetTunnelRandomBiasItem() : RsGxsNetTunnelItem(RS_PKT_SUBTYPE_GXS_NET_TUNNEL_RANDOM_BIAS) { clear();} + virtual ~RsGxsNetTunnelRandomBiasItem() {} + + virtual void clear() { mRandomBias.clear() ; } + virtual void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx) + { + RsTypeSerializer::serial_process(j,ctx,mRandomBias,"random bias") ; + } + + Bias20Bytes mRandomBias; // Cannot be a simple char[] because of serialization. +}; + +class RsGxsNetTunnelTurtleSearchSubstringItem: public RsGxsNetTunnelItem +{ +public: + explicit RsGxsNetTunnelTurtleSearchSubstringItem(): RsGxsNetTunnelItem(RS_PKT_SUBTYPE_GXS_NET_TUNNEL_TURTLE_SEARCH_SUBSTRING) {} + virtual ~RsGxsNetTunnelTurtleSearchSubstringItem() {} + + uint16_t service ; + std::string substring_match ; + + virtual void clear() { substring_match.clear() ; } + virtual void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx) + { + RsTypeSerializer::serial_process(j,ctx,service,"service") ; + RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_KEY,substring_match,"substring_match") ; + } +}; + +class RsGxsNetTunnelTurtleSearchGroupRequestItem: public RsGxsNetTunnelItem +{ +public: + explicit RsGxsNetTunnelTurtleSearchGroupRequestItem(): RsGxsNetTunnelItem(RS_PKT_SUBTYPE_GXS_NET_TUNNEL_TURTLE_SEARCH_GROUP_REQUEST) {} + virtual ~RsGxsNetTunnelTurtleSearchGroupRequestItem() {} + + uint16_t service ; + Sha1CheckSum hashed_group_id ; + + virtual void clear() { hashed_group_id.clear() ; } + virtual void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx) + { + RsTypeSerializer::serial_process(j,ctx,service,"service") ; + RsTypeSerializer::serial_process(j,ctx,hashed_group_id,"hashed_group_id") ; + } +}; + +class RsGxsNetTunnelTurtleSearchGroupSummaryItem: public RsGxsNetTunnelItem +{ +public: + explicit RsGxsNetTunnelTurtleSearchGroupSummaryItem(): RsGxsNetTunnelItem(RS_PKT_SUBTYPE_GXS_NET_TUNNEL_TURTLE_SEARCH_GROUP_SUMMARY) {} + virtual ~RsGxsNetTunnelTurtleSearchGroupSummaryItem() {} + + uint16_t service ; + std::list group_infos; + + virtual void clear() { group_infos.clear() ; } + + virtual void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx) + { + RsTypeSerializer::serial_process(j,ctx,service,"service") ; + RsTypeSerializer::serial_process(j,ctx,group_infos,"group_infos") ; + } +}; +class RsGxsNetTunnelTurtleSearchGroupDataItem: public RsGxsNetTunnelItem +{ +public: + explicit RsGxsNetTunnelTurtleSearchGroupDataItem(): RsGxsNetTunnelItem(RS_PKT_SUBTYPE_GXS_NET_TUNNEL_TURTLE_SEARCH_GROUP_DATA) {} + virtual ~RsGxsNetTunnelTurtleSearchGroupDataItem() {} + + uint16_t service ; + unsigned char *encrypted_group_data ; + uint32_t encrypted_group_data_len ; + + virtual void clear() { free(encrypted_group_data);encrypted_group_data=NULL;encrypted_group_data_len=0; } + + virtual void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx) + { + RsTypeSerializer::serial_process(j,ctx,service,"service") ; + + RsTypeSerializer::TlvMemBlock_proxy prox(encrypted_group_data,encrypted_group_data_len) ; + RsTypeSerializer::serial_process(j,ctx,prox,"encrypted_group_data") ; + } +}; + +class RsGxsNetTunnelSerializer: public RsServiceSerializer +{ +public: + RsGxsNetTunnelSerializer() :RsServiceSerializer(RS_SERVICE_TYPE_GXS_NET_TUNNEL) {} + + virtual RsItem *create_item(uint16_t service,uint8_t item_subtype) const + { + if(service != RS_SERVICE_TYPE_GXS_NET_TUNNEL) + { + GXS_NET_TUNNEL_ERROR() << "received item with wrong service ID " << std::hex << service << std::dec << std::endl; + return NULL ; + } + + switch(item_subtype) + { + case RS_PKT_SUBTYPE_GXS_NET_TUNNEL_VIRTUAL_PEER : return new RsGxsNetTunnelVirtualPeerItem ; + case RS_PKT_SUBTYPE_GXS_NET_TUNNEL_KEEP_ALIVE : return new RsGxsNetTunnelKeepAliveItem ; + case RS_PKT_SUBTYPE_GXS_NET_TUNNEL_RANDOM_BIAS : return new RsGxsNetTunnelRandomBiasItem ; + case RS_PKT_SUBTYPE_GXS_NET_TUNNEL_TURTLE_SEARCH_SUBSTRING : return new RsGxsNetTunnelTurtleSearchSubstringItem; + case RS_PKT_SUBTYPE_GXS_NET_TUNNEL_TURTLE_SEARCH_GROUP_REQUEST : return new RsGxsNetTunnelTurtleSearchGroupRequestItem; + case RS_PKT_SUBTYPE_GXS_NET_TUNNEL_TURTLE_SEARCH_GROUP_SUMMARY : return new RsGxsNetTunnelTurtleSearchGroupSummaryItem; + case RS_PKT_SUBTYPE_GXS_NET_TUNNEL_TURTLE_SEARCH_GROUP_DATA : return new RsGxsNetTunnelTurtleSearchGroupDataItem; + default: + GXS_NET_TUNNEL_ERROR() << "type ID " << std::hex << (int)item_subtype << std::dec << " is not handled!" << std::endl; + return NULL ; + } + } +}; + +//===========================================================================================================================================// +// Interface with rest of the software // +//===========================================================================================================================================// + +uint16_t RsGxsNetTunnelService::serviceId() const +{ + return RS_SERVICE_TYPE_GXS_NET_TUNNEL; +} + +bool RsGxsNetTunnelService::registerSearchableService(RsNetworkExchangeService *gxs_service) +{ + RS_STACK_MUTEX(mGxsNetTunnelMtx); + + mSearchableServices[gxs_service->serviceType()] = gxs_service ; + + return true; +} + +class DataAutoDelete +{ +public: + DataAutoDelete(unsigned char *& data) : mData(data) {} + ~DataAutoDelete() { free(mData); mData=NULL ; } + unsigned char *& mData; +}; + +RsGxsNetTunnelService::~RsGxsNetTunnelService() +{ + RS_STACK_MUTEX(mGxsNetTunnelMtx); + + // This is needed because we need to clear these structure in a mutex protected environment + // Also this calls the destructor of the objects which calls the freeing of memory e.g. allocated in the incoming data list. + + mGroups.clear(); + mHandledHashes.clear(); + mVirtualPeers.clear(); + + for(auto it(mIncomingData.begin());it!=mIncomingData.end();++it) + for(auto it2(it->second.begin());it2!=it->second.end();++it2) + delete it2->second; + + mIncomingData.clear(); +} + +bool RsGxsNetTunnelService::isDistantPeer(const RsGxsNetTunnelVirtualPeerId& virtual_peer, RsGxsGroupId& group_id) +{ + RS_STACK_MUTEX(mGxsNetTunnelMtx); + + auto it = mVirtualPeers.find(virtual_peer) ; + + if(it != mVirtualPeers.end()) + { + group_id = it->second.group_id ; + return true ; + } + else + return false ; +} + +bool RsGxsNetTunnelService::receiveTunnelData(uint16_t service_id, unsigned char *& data, uint32_t& data_len, RsGxsNetTunnelVirtualPeerId& virtual_peer) +{ + RS_STACK_MUTEX(mGxsNetTunnelMtx); + + std::list >& lst(mIncomingData[service_id]); + + if(lst.empty()) + { + data = NULL; + data_len = 0; + return false ; + } + + data = (unsigned char*)lst.front().second->bin_data ; + data_len = lst.front().second->bin_len ; + virtual_peer = lst.front().first; + + lst.front().second->bin_data = NULL ; // avoids deletion + lst.front().second->bin_len = 0 ; // avoids deletion + + delete lst.front().second; + lst.pop_front(); + + return true; +} + +bool RsGxsNetTunnelService::sendTunnelData(uint16_t /* service_id */,unsigned char *& data,uint32_t data_len,const RsGxsNetTunnelVirtualPeerId& virtual_peer) +{ + RS_STACK_MUTEX(mGxsNetTunnelMtx); + // The item is serialized and encrypted using chacha20+SHA256, using the generic turtle encryption, and then sent to the turtle router. + + DataAutoDelete iad(data) ; // This ensures the item is deleted whatsoever when leaving + + // 1 - find the virtual peer and the proper master key to encrypt with, and check that all the info is known + + auto it = mVirtualPeers.find(virtual_peer) ; + + if(it == mVirtualPeers.end()) + { + GXS_NET_TUNNEL_ERROR() << "cannot find virtual peer " << virtual_peer << ". Data is dropped." << std::endl; + return false ; + } + + if(it->second.vpid_status != RsGxsNetTunnelVirtualPeerInfo::RS_GXS_NET_TUNNEL_VP_STATUS_ACTIVE) + { + GXS_NET_TUNNEL_ERROR() << "virtual peer " << virtual_peer << " is not active. Data is dropped." << std::endl; + return false ; + } + + it->second.last_contact = time(NULL) ; + + // 2 - encrypt and send the item. + + RsTurtleGenericDataItem *encrypted_turtle_item = NULL ; + + if(!p3turtle::encryptData(data,data_len,it->second.encryption_master_key,encrypted_turtle_item)) + { + GXS_NET_TUNNEL_ERROR() << "cannot encrypt. Something's wrong. Data is dropped." << std::endl; + return false ; + } + + mTurtle->sendTurtleData(it->second.turtle_virtual_peer_id,encrypted_turtle_item) ; + + return true ; +} + +bool RsGxsNetTunnelService::getVirtualPeers(std::list& peers) +{ + // This function has two effects: + // - return the virtual peers for this group + // - passively set the group as "managed", so that it we answer tunnel requests. + + RS_STACK_MUTEX(mGxsNetTunnelMtx); + + // update the hash entry if needed + + for(auto it(mVirtualPeers.begin());it!=mVirtualPeers.end();++it) + peers.push_back(it->first) ; + +#ifdef DEBUG_RSGXSNETTUNNEL + GXS_NET_TUNNEL_DEBUG() << " returning " << peers.size() << " peers." << std::endl; +#endif + + return true ; +} + +bool RsGxsNetTunnelService::requestDistantPeers(uint16_t service_id, const RsGxsGroupId& group_id) +{ + RS_STACK_MUTEX(mGxsNetTunnelMtx); + + // Now ask the turtle router to manage a tunnel for that hash. + + RsGxsNetTunnelGroupInfo& ginfo( mGroups[group_id] ) ; + + if(ginfo.group_policy < RsGxsNetTunnelGroupInfo::RS_GXS_NET_TUNNEL_GRP_POLICY_ACTIVE) + ginfo.group_policy = RsGxsNetTunnelGroupInfo::RS_GXS_NET_TUNNEL_GRP_POLICY_ACTIVE; + + ginfo.hash = calculateGroupHash(group_id) ; + ginfo.service_id = service_id; + + mHandledHashes[ginfo.hash] = group_id ; + + // we dont set the group policy here. It will only be set if no peers, or too few peers are available. +#ifdef DEBUG_RSGXSNETTUNNEL + GXS_NET_TUNNEL_DEBUG() << " requesting peers for group " << group_id << std::endl; +#endif + + return true; +} + +bool RsGxsNetTunnelService::releaseDistantPeers(uint16_t /* service_id */,const RsGxsGroupId& group_id) +{ + RS_STACK_MUTEX(mGxsNetTunnelMtx); + + // Ask turtle router to stop requesting tunnels for that hash. + + RsGxsNetTunnelGroupInfo& ginfo( mGroups[group_id] ) ; + + ginfo.group_policy = RsGxsNetTunnelGroupInfo::RS_GXS_NET_TUNNEL_GRP_POLICY_PASSIVE; + ginfo.hash = calculateGroupHash(group_id) ; + + mHandledHashes[ginfo.hash] = group_id ; // yes, we do not remove, because we're supposed to answer tunnel requests from other peers. + + mTurtle->stopMonitoringTunnels(ginfo.hash) ; + +#ifdef DEBUG_RSGXSNETTUNNEL + GXS_NET_TUNNEL_DEBUG() << " releasing peers for group " << group_id << std::endl; +#endif + return true; +} + +void RsGxsNetTunnelService::dump() const +{ + RS_STACK_MUTEX(mGxsNetTunnelMtx); + + static std::string group_status_str[4] = { + std::string("[UNKNOWN ]"), + std::string("[IDLE ]"), + std::string("[TUNNELS_REQUESTED]"), + std::string("[VPIDS_AVAILABLE ]") + }; + + static std::string group_policy_str[4] = { + std::string("[UNKNOWN ]"), + std::string("[PASSIVE ]"), + std::string("[ACTIVE ]"), + std::string("[REQUESTING]"), + }; + static std::string vpid_status_str[3] = { + std::string("[UNKNOWN ]"), + std::string("[TUNNEL_OK]"), + std::string("[ACTIVE ]") + }; + + std::cerr << "GxsNetTunnelService dump (this=" << (void*)this << ": " << std::endl; + std::cerr << " Managed GXS groups: " << std::endl; + + for(auto it(mGroups.begin());it!=mGroups.end();++it) + { + std::cerr << " " << it->first << " hash: " << it->second.hash << " policy: " << group_policy_str[it->second.group_policy] << " status: " << group_status_str[it->second.group_status] << " Last contact: " << time(NULL) - it->second.last_contact << " secs ago" << std::endl; + + if(!it->second.virtual_peers.empty()) + std::cerr << " virtual peers:" << std::endl; + for(auto it2(it->second.virtual_peers.begin());it2!=it->second.virtual_peers.end();++it2) + std::cerr << " " << *it2 << std::endl; + } + + std::cerr << " Virtual peers: " << std::endl; + for(auto it(mVirtualPeers.begin());it!=mVirtualPeers.end();++it) + std::cerr << " GXS Peer:" << it->first << " Turtle:" << it->second.turtle_virtual_peer_id + << " status: " << vpid_status_str[it->second.vpid_status] + << " group_id: " << it->second.group_id + << " direction: " << (int)it->second.side + << " last seen " << time(NULL)-it->second.last_contact << " secs ago" + << " ekey: " << RsUtil::BinToHex(it->second.encryption_master_key,RS_GXS_TUNNEL_CONST_EKEY_SIZE,10) << std::endl; + + std::cerr << " Virtual peer turtle => GXS conversion table: " << std::endl; + for(auto it(mTurtle2GxsPeer.begin());it!=mTurtle2GxsPeer.end();++it) + std::cerr << " " << it->first << " => " << it->second << std::endl; + + std::cerr << " Hashes: " << std::endl; + for(auto it(mHandledHashes.begin());it!=mHandledHashes.end();++it) + std::cerr << " hash: " << it->first << " GroupId: " << it->second << std::endl; + + std::cerr << " Incoming data: " << std::endl; + for(auto it(mIncomingData.begin());it!=mIncomingData.end();++it) + { + std::cerr << " service " << std::hex << it->first << std::dec << std::endl; + + for(auto it2(it->second.begin());it2!=it->second.end();++it2) + std::cerr << " peer id " << it2->first << " " << (void*)it2->second << std::endl; + } +} + +//===========================================================================================================================================// +// Interaction with Turtle Router // +//===========================================================================================================================================// + +void RsGxsNetTunnelService::connectToTurtleRouter(p3turtle *tr) +{ + mTurtle = tr ; + mTurtle->registerTunnelService(this) ; +} + +bool RsGxsNetTunnelService::handleTunnelRequest(const RsFileHash &hash,const RsPeerId& /* peer_id */) +{ + RS_STACK_MUTEX(mGxsNetTunnelMtx); + // We simply check for wether a managed group has a hash that corresponds to the given hash. + + return mHandledHashes.find(hash) != mHandledHashes.end(); +} + +void RsGxsNetTunnelService::receiveTurtleData(const RsTurtleGenericTunnelItem *item, const RsFileHash& hash, const RsPeerId& turtle_virtual_peer_id, RsTurtleGenericTunnelItem::Direction direction) +{ + RS_STACK_MUTEX(mGxsNetTunnelMtx); + +#ifdef DEBUG_RSGXSNETTUNNEL + GXS_NET_TUNNEL_DEBUG() << " received turtle data for vpid " << turtle_virtual_peer_id << " for hash " << hash << " in direction " << (int)direction << std::endl; +#endif + + if(item->PacketSubType() != RS_TURTLE_SUBTYPE_GENERIC_DATA) + { + GXS_NET_TUNNEL_ERROR() << "item with type " << std::hex << item->PacketSubType() << std::dec << " received by GxsNetTunnel, but is not handled!" << std::endl; + return; + } + // find the group id + + auto it4 = mHandledHashes.find(hash) ; + + if(it4 == mHandledHashes.end()) + { + GXS_NET_TUNNEL_ERROR() << "Cannot find hash " << hash << " to be handled by GxsNetTunnel" << std::endl; + return; + } + RsGxsGroupId group_id = it4->second; + + // Now check if we got an item to advertise a virtual peer + + unsigned char *data = NULL ; + uint32_t data_size = 0 ; + + // generate the decryption key based on virtual peer id and group id + + uint8_t encryption_master_key[RS_GXS_TUNNEL_CONST_EKEY_SIZE] ; + + generateEncryptionKey(group_id,turtle_virtual_peer_id,encryption_master_key); + + if(!p3turtle::decryptItem(static_cast(item),encryption_master_key,data,data_size)) + { + GXS_NET_TUNNEL_ERROR() << "Cannot decrypt data!" << std::endl; + + if(data) + free(data) ; + + return ; + } + + uint16_t service_id = getRsItemService(getRsItemId(data)); + + if(service_id == RS_SERVICE_TYPE_GXS_NET_TUNNEL) + { + RsItem *decrypted_item = RsGxsNetTunnelSerializer().deserialise(data,&data_size); + RsGxsNetTunnelVirtualPeerItem *pid_item = dynamic_cast(decrypted_item) ; + + if(!pid_item) // this handles the case of a KeepAlive packet. + { + delete decrypted_item ; + return ; + } + +#ifdef DEBUG_RSGXSNETTUNNEL + GXS_NET_TUNNEL_DEBUG() << " item is a virtual peer id item with vpid = "<< pid_item->virtual_peer_id + << " for group " << group_id << ". Setting virtual peer." << std::endl; +#endif + // we receive a virtual peer id, so we need to update the local information for this peer id + + mTurtle2GxsPeer[turtle_virtual_peer_id] = pid_item->virtual_peer_id ; + + RsGxsNetTunnelVirtualPeerInfo& vp_info(mVirtualPeers[pid_item->virtual_peer_id]) ; + + vp_info.vpid_status = RsGxsNetTunnelVirtualPeerInfo::RS_GXS_NET_TUNNEL_VP_STATUS_ACTIVE ; // status of the peer + vp_info.side = direction; // client/server + vp_info.last_contact = time(NULL); // last time some data was sent/recvd + vp_info.group_id = group_id; + vp_info.service_id = mGroups[group_id].service_id ; + + memcpy(vp_info.encryption_master_key,encryption_master_key,RS_GXS_TUNNEL_CONST_EKEY_SIZE); + + vp_info.turtle_virtual_peer_id = turtle_virtual_peer_id; // turtle peer to use when sending data to this vpid. + + free(data); + + return ; + } + + + // item is a generic data item for the client. Let's store the data in the appropriate incoming data queue. + + auto it = mTurtle2GxsPeer.find(turtle_virtual_peer_id) ; + + if(it == mTurtle2GxsPeer.end()) + { + GXS_NET_TUNNEL_ERROR() << "item received by GxsNetTunnel for vpid " << turtle_virtual_peer_id << " but this vpid is unknown!" << std::endl; + free(data); + return; + } + + RsGxsNetTunnelVirtualPeerId gxs_vpid = it->second ; + + auto it2 = mVirtualPeers.find(gxs_vpid) ; + + if(it2 == mVirtualPeers.end()) + { + GXS_NET_TUNNEL_ERROR() << "item received by GxsNetTunnel for GXS vpid " << gxs_vpid << " but the virtual peer id is missing!" << std::endl; + free(data); + return; + } + it2->second.vpid_status = RsGxsNetTunnelVirtualPeerInfo::RS_GXS_NET_TUNNEL_VP_STATUS_ACTIVE ; // status of the peer + it2->second.last_contact = time(NULL); // last time some data was sent/recvd + + if(service_id != it2->second.service_id && service_id != RS_SERVICE_GXS_TYPE_GXSID) + { + GXS_NET_TUNNEL_ERROR() << " received an item for VPID " << gxs_vpid << " openned for service " << it2->second.service_id << " that is not for that service nor for GXS Id service (service=" << std::hex << service_id << std::dec << ". Rejecting!" << std::endl; + free(data); + return ; + } + +#ifdef DEBUG_RSGXSNETTUNNEL + GXS_NET_TUNNEL_DEBUG() << "item contains generic data for VPID " << gxs_vpid << ". service_id = " << std::hex << service_id << std::dec << ". Storing in incoming list" << std::endl; +#endif + + // push the data into the incoming data list + + RsTlvBinaryData *bind = new RsTlvBinaryData; + bind->tlvtype = 0; + bind->bin_len = data_size; + bind->bin_data = data; + + mIncomingData[service_id].push_back(std::make_pair(gxs_vpid,bind)) ; +} + +void RsGxsNetTunnelService::addVirtualPeer(const TurtleFileHash& hash, const TurtleVirtualPeerId& vpid,RsTurtleGenericTunnelItem::Direction dir) +{ + RS_STACK_MUTEX(mGxsNetTunnelMtx); + + auto it = mHandledHashes.find(hash) ; + + if(it == mHandledHashes.end()) + { + std::cerr << "RsGxsNetTunnelService::addVirtualPeer(): error! hash " << hash << " is not handled. Cannot add vpid " << vpid << " in direction " << dir << std::endl; + return ; + } + +#ifdef DEBUG_RSGXSNETTUNNEL + GXS_NET_TUNNEL_DEBUG() << " adding virtual peer " << vpid << " for hash " << hash << " in direction " << dir << std::endl; +#endif + const RsGxsGroupId group_id(it->second) ; + + RsGxsNetTunnelGroupInfo& ginfo( mGroups[group_id] ) ; + ginfo.group_status = RsGxsNetTunnelGroupInfo::RS_GXS_NET_TUNNEL_GRP_STATUS_VPIDS_AVAILABLE ; + ginfo.virtual_peers.insert(vpid); + + uint8_t encryption_master_key[RS_GXS_TUNNEL_CONST_EKEY_SIZE]; + + generateEncryptionKey(group_id,vpid,encryption_master_key ); + + // We need to send our own virtual peer id to the other end of the tunnel + + RsGxsNetTunnelVirtualPeerId net_service_virtual_peer = locked_makeVirtualPeerId(group_id); + +#ifdef DEBUG_RSGXSNETTUNNEL + GXS_NET_TUNNEL_DEBUG() << " sending back virtual peer name " << net_service_virtual_peer << " to end of tunnel" << std::endl; +#endif + RsGxsNetTunnelVirtualPeerItem pitem ; + pitem.virtual_peer_id = net_service_virtual_peer ; + + RsTemporaryMemory tmpmem( RsGxsNetTunnelSerializer().size(&pitem) ) ; + uint32_t len = tmpmem.size(); + + RsGxsNetTunnelSerializer().serialise(&pitem,tmpmem,&len); + + RsTurtleGenericDataItem *encrypted_turtle_item = NULL ; + + if(p3turtle::encryptData(tmpmem,len,encryption_master_key,encrypted_turtle_item)) + mPendingTurtleItems.push_back(std::make_pair(vpid,encrypted_turtle_item)) ; // we cannot send directly because of turtle mutex locked before calling addVirtualPeer. + else + GXS_NET_TUNNEL_ERROR() << "cannot encrypt. Something's wrong. Data is dropped." << std::endl; +} + +void RsGxsNetTunnelService::removeVirtualPeer(const TurtleFileHash& hash, const TurtleVirtualPeerId& vpid) +{ + RS_STACK_MUTEX(mGxsNetTunnelMtx); + +#ifdef DEBUG_RSGXSNETTUNNEL + GXS_NET_TUNNEL_DEBUG() << " removing virtual peer " << vpid << " for hash " << hash << std::endl; +#endif + mTurtle2GxsPeer.erase(vpid); + + auto it = mHandledHashes.find(hash) ; + + if(it == mHandledHashes.end()) + { + std::cerr << "RsGxsNetTunnelService::removeVirtualPeer(): error! hash " << hash << " is not handled. Cannot remove vpid " << vpid << std::endl; + return ; + } + + const RsGxsGroupId group_id(it->second) ; + + RsGxsNetTunnelGroupInfo& ginfo( mGroups[group_id] ) ; + + ginfo.virtual_peers.erase(vpid); + + if(ginfo.virtual_peers.empty()) + { + ginfo.group_status = RsGxsNetTunnelGroupInfo::RS_GXS_NET_TUNNEL_GRP_STATUS_IDLE ; + +#ifdef DEBUG_RSGXSNETTUNNEL + GXS_NET_TUNNEL_DEBUG() << " no more virtual peers for group " << group_id << ": setting status to TUNNELS_REQUESTED" << std::endl; +#endif + } +} + +RsFileHash RsGxsNetTunnelService::calculateGroupHash(const RsGxsGroupId& group_id) const +{ + return RsDirUtil::sha1sum(group_id.toByteArray(),RsGxsGroupId::SIZE_IN_BYTES) ; +} + +void RsGxsNetTunnelService::generateEncryptionKey(const RsGxsGroupId& group_id,const TurtleVirtualPeerId& vpid,unsigned char key[RS_GXS_TUNNEL_CONST_EKEY_SIZE]) +{ + // The key is generated as H(group_id | vpid) + // Because group_id is not known it shouldn't be possible to recover the key by observing the traffic. + + assert(Sha256CheckSum::SIZE_IN_BYTES == 32) ; + + unsigned char mem[RsGxsGroupId::SIZE_IN_BYTES + TurtleVirtualPeerId::SIZE_IN_BYTES] ; + + memcpy(mem ,group_id.toByteArray(),RsGxsGroupId::SIZE_IN_BYTES) ; + memcpy(mem+RsGxsGroupId::SIZE_IN_BYTES,vpid.toByteArray() ,TurtleVirtualPeerId::SIZE_IN_BYTES) ; + + memcpy( key, RsDirUtil::sha256sum(mem,RsGxsGroupId::SIZE_IN_BYTES+TurtleVirtualPeerId::SIZE_IN_BYTES).toByteArray(), RS_GXS_TUNNEL_CONST_EKEY_SIZE ) ; +} + +//===========================================================================================================================================// +// Service parts // +//===========================================================================================================================================// + +void RsGxsNetTunnelService::data_tick() +{ + while(!mPendingTurtleItems.empty()) + { + auto& it(mPendingTurtleItems.front()); + + mTurtle->sendTurtleData(it.first,it.second) ; + mPendingTurtleItems.pop_front(); + } + + time_t now = time(NULL); + + // cleanup + + if(mLastAutoWash + 5 < now) + { + autowash(); + mLastAutoWash = now; + } + + if(mLastKeepAlive + 20 < now) + { + mLastKeepAlive = now ; + sendKeepAlivePackets() ; + } + +#ifdef DEBUG_RSGXSNETTUNNEL + if(mLastDump + 10 < now) + { + mLastDump = now; + dump(); + } +#endif + + rstime::rs_usleep(1*1000*1000) ; // 1 sec +} + +const Bias20Bytes& RsGxsNetTunnelService::locked_randomBias() +{ + if(mRandomBias.isNull()) + { + mRandomBias = Bias20Bytes::random(); + IndicateConfigChanged(); + + std::cerr << "Initialized RsGxsNetTunnel random bias to " << RsUtil::BinToHex(mRandomBias.toByteArray(),mRandomBias.SIZE_IN_BYTES) << std::endl; + } + + return mRandomBias ; +} + +RsGxsNetTunnelVirtualPeerId RsGxsNetTunnelService::locked_makeVirtualPeerId(const RsGxsGroupId& group_id) +{ + assert(RsPeerId::SIZE_IN_BYTES <= Sha1CheckSum::SIZE_IN_BYTES) ;// so that we can build the virtual PeerId from a SHA1 sum. + + // We compute sha1( GroupId | mRandomBias ) and trunk it to 16 bytes in order to compute a RsPeerId + + Bias20Bytes rb(locked_randomBias()); + + unsigned char mem[group_id.SIZE_IN_BYTES + rb.SIZE_IN_BYTES]; + + memcpy(mem ,group_id.toByteArray(),group_id.SIZE_IN_BYTES) ; + memcpy(mem+group_id.SIZE_IN_BYTES,rb.toByteArray(),rb.SIZE_IN_BYTES) ; + + return RsGxsNetTunnelVirtualPeerId(RsDirUtil::sha1sum(mem,group_id.SIZE_IN_BYTES+rb.SIZE_IN_BYTES).toByteArray()); +} + + +void RsGxsNetTunnelService::sendKeepAlivePackets() +{ + RS_STACK_MUTEX(mGxsNetTunnelMtx); +#ifdef DEBUG_RSGXSNETTUNNEL + GXS_NET_TUNNEL_DEBUG() << " sending keep-alive packets. " << std::endl; +#endif + + // We send KA packets for each GXS virtual peer. The advantage is that unused tunnels will automatically die which eliminates duplicate tunnels + // automatically. We only send from the client side. + + for(auto it(mVirtualPeers.begin());it!=mVirtualPeers.end();++it) + { + RsGxsNetTunnelVirtualPeerId own_gxs_vpid = locked_makeVirtualPeerId(it->second.group_id) ; + +#ifdef DEBUG_RSGXSNETTUNNEL + GXS_NET_TUNNEL_DEBUG() << " virtual peer " << it->first << " through tunnel " << it->second.turtle_virtual_peer_id << " for group " << it->second.group_id ; +#endif + + if(own_gxs_vpid < it->first) + { +#ifdef DEBUG_RSGXSNETTUNNEL + std::cerr << ": sent!" << std::endl; +#endif + RsGxsNetTunnelKeepAliveItem pitem ; + RsTemporaryMemory tmpmem( RsGxsNetTunnelSerializer().size(&pitem) ) ; + uint32_t len = tmpmem.size(); + + RsGxsNetTunnelSerializer().serialise(&pitem,tmpmem,&len); + + RsTurtleGenericDataItem *encrypted_turtle_item = NULL ; + + if(p3turtle::encryptData(tmpmem,len,it->second.encryption_master_key,encrypted_turtle_item)) + mPendingTurtleItems.push_back(std::make_pair(it->second.turtle_virtual_peer_id,encrypted_turtle_item)) ; + + it->second.last_contact = time(NULL) ; + } +#ifdef DEBUG_RSGXSNETTUNNEL + else + std::cerr << ": ignored!" << std::endl; +#endif + } +} + +void RsGxsNetTunnelService::autowash() +{ + RS_STACK_MUTEX(mGxsNetTunnelMtx); + +#ifdef DEBUG_RSGXSNETTUNNEL + GXS_NET_TUNNEL_DEBUG() << " performing per-group consistency test." << std::endl; +#endif + for(auto it(mGroups.begin());it!=mGroups.end();++it) + { + RsGxsNetTunnelVirtualPeerId own_gxs_vpid = locked_makeVirtualPeerId(it->first) ; + RsGxsNetTunnelGroupInfo& ginfo(it->second) ; + bool should_monitor_tunnels = false ; + +#ifdef DEBUG_RSGXSNETTUNNEL + GXS_NET_TUNNEL_DEBUG() << " group " << it->first << ": " ; +#endif + // check whether the group already has GXS virtual peers with suppliers. If so, we can set the GRP policy as passive. + + if(ginfo.group_policy >= RsGxsNetTunnelGroupInfo::RS_GXS_NET_TUNNEL_GRP_POLICY_ACTIVE) + { + bool found = false ; + + // check wether one virtual peer provided by GXS has ID > own ID. In this case we leave the priority to it. + + for(auto it2(ginfo.virtual_peers.begin());!found && it2!=ginfo.virtual_peers.end();++it2) + { + auto it3 = mTurtle2GxsPeer.find(*it2) ; + + if( it3 != mTurtle2GxsPeer.end() && it3->second < own_gxs_vpid) + found = true ; + } + + if(found) + { +#ifdef DEBUG_RSGXSNETTUNNEL + std::cerr << " active, with client-side peers : "; +#endif + should_monitor_tunnels = false ; + ginfo.group_policy = RsGxsNetTunnelGroupInfo::RS_GXS_NET_TUNNEL_GRP_POLICY_ACTIVE ; + } + else + { + should_monitor_tunnels = true ; + ginfo.group_policy = RsGxsNetTunnelGroupInfo::RS_GXS_NET_TUNNEL_GRP_POLICY_REQUESTING ; +#ifdef DEBUG_RSGXSNETTUNNEL + std::cerr << " active, and no client-side peers available : " ; +#endif + } + } +#ifdef DEBUG_RSGXSNETTUNNEL + else + std::cerr << " passive : "; +#endif + + // We should also check whether the group is supplied using another tunnel. If so, no need to request tunnels. + // Otherwise the engine will keep requesting tunnels for all groups. +#warning CODE MISSING HERE + + if(should_monitor_tunnels) + { +#ifdef DEBUG_RSGXSNETTUNNEL + std::cerr << " requesting tunnels" << std::endl; +#endif + mTurtle->monitorTunnels(ginfo.hash,this,false) ; + } + else + { +#ifdef DEBUG_RSGXSNETTUNNEL + std::cerr << " dropping tunnels" << std::endl; +#endif + mTurtle->stopMonitoringTunnels(ginfo.hash); + } + } +} + +bool RsGxsNetTunnelService::saveList(bool& cleanup, std::list& save) +{ + RsGxsNetTunnelRandomBiasItem *it2 = new RsGxsNetTunnelRandomBiasItem() ; + + { + RS_STACK_MUTEX(mGxsNetTunnelMtx); + it2->mRandomBias = mRandomBias; + std::cerr << "Saving RsGxsNetTunnel random bias to disc" << std::endl; + } + + save.push_back(it2) ; + cleanup = true ; + + return true; +} + +bool RsGxsNetTunnelService::loadList(std::list &load) +{ + RsGxsNetTunnelRandomBiasItem *rbsi ; + + for(auto it(load.begin());it!=load.end();++it) + { + if((rbsi = dynamic_cast(*it))!=NULL) + { + RS_STACK_MUTEX(mGxsNetTunnelMtx); + mRandomBias = rbsi->mRandomBias; + + std::cerr << "Loaded RsGxsNetTunnel random bias from disc: " << RsUtil::BinToHex(mRandomBias.toByteArray(),mRandomBias.SIZE_IN_BYTES) << std::endl; + } + else + GXS_NET_TUNNEL_ERROR() << " unknown item in config file: type=" << std::hex << (*it)->PacketId() << std::dec << std::endl; + + delete *it; + } + + return true; +} + +RsSerialiser *RsGxsNetTunnelService::setupSerialiser() +{ + RsSerialiser *ser = new RsSerialiser ; + ser->addSerialType(new RsGxsNetTunnelSerializer) ; + + return ser ; +} + +//===========================================================================================================================================// +// Turtle Search system // +//===========================================================================================================================================// + +TurtleRequestId RsGxsNetTunnelService::turtleGroupRequest(const RsGxsGroupId& group_id,RsNetworkExchangeService *client_service) +{ + Sha1CheckSum hashed_group_id = RsDirUtil::sha1sum(group_id.toByteArray(),group_id.SIZE_IN_BYTES) ; + + GXS_NET_TUNNEL_DEBUG() << ": starting a turtle group request for grp \"" << group_id << "\" hashed to \"" << hashed_group_id << "\"" << std::endl; + + RsGxsNetTunnelTurtleSearchGroupRequestItem search_item ; + search_item.hashed_group_id = hashed_group_id ; + search_item.service = client_service->serviceType() ; + + uint32_t size = RsGxsNetTunnelSerializer().size(&search_item) ; + unsigned char *mem = (unsigned char*)rs_malloc(size) ; + + if(mem == NULL) + return 0 ; + + RsGxsNetTunnelSerializer().serialise(&search_item,mem,&size); + + return mTurtle->turtleSearch(mem,size,this) ; +} + +TurtleRequestId RsGxsNetTunnelService::turtleSearchRequest(const std::string& match_string,RsNetworkExchangeService *client_service) +{ + GXS_NET_TUNNEL_DEBUG() << ": starting a turtle search request for string \"" << match_string << "\"" << std::endl; + + RsGxsNetTunnelTurtleSearchSubstringItem search_item ; + search_item.substring_match = match_string ; + search_item.service = client_service->serviceType() ; + + uint32_t size = RsGxsNetTunnelSerializer().size(&search_item) ; + unsigned char *mem = (unsigned char*)rs_malloc(size) ; + + if(mem == NULL) + return 0 ; + + RsGxsNetTunnelSerializer().serialise(&search_item,mem,&size); + + RS_STACK_MUTEX(mGxsNetTunnelMtx); + return mTurtle->turtleSearch(mem,size,this) ; +} + +bool RsGxsNetTunnelService::receiveSearchRequest(unsigned char *search_request_data,uint32_t search_request_data_len,unsigned char *& search_result_data,uint32_t& search_result_data_size,uint32_t& max_allowed_hits) +{ + GXS_NET_TUNNEL_DEBUG() << ": received a request." << std::endl; + + RsItem *item = RsGxsNetTunnelSerializer().deserialise(search_request_data,&search_request_data_len) ; + + RsGxsNetTunnelTurtleSearchSubstringItem *substring_sr = dynamic_cast(item) ; + + if(substring_sr != NULL) + { + GXS_NET_TUNNEL_DEBUG() << " : type is substring for service " << std::hex << (int)substring_sr->service << std::dec << std::endl; + + max_allowed_hits = RS_GXS_NET_TUNNEL_MAX_ALLOWED_HITS_GROUP_SEARCH ; + + std::list results ; + + RS_STACK_MUTEX(mGxsNetTunnelMtx); + + auto it = mSearchableServices.find(substring_sr->service) ; + + if(it != mSearchableServices.end() && it->second->search(substring_sr->substring_match,results)) + { + RsGxsNetTunnelTurtleSearchGroupSummaryItem search_result_item ; + + GXS_NET_TUNNEL_DEBUG() << " : " << results.size() << " result found. Sending back." << std::endl; + + search_result_item.service = substring_sr->service ; + search_result_item.group_infos = results ; + + search_result_data_size = RsGxsNetTunnelSerializer().size(&search_result_item) ; + search_result_data = (unsigned char*)rs_malloc(search_result_data_size) ; + + if(search_result_data == NULL) + return false ; + + RsGxsNetTunnelSerializer().serialise(&search_result_item,search_result_data,&search_result_data_size); + + return true ; + } + } + + RsGxsNetTunnelTurtleSearchGroupRequestItem *substring_gr = dynamic_cast(item) ; + + if(substring_gr != NULL) + { + RS_STACK_MUTEX(mGxsNetTunnelMtx); + auto it = mSearchableServices.find(substring_gr->service) ; + + max_allowed_hits = RS_GXS_NET_TUNNEL_MAX_ALLOWED_HITS_GROUP_DATA ; + + unsigned char *encrypted_group_data = NULL ; + uint32_t encrypted_group_data_len = 0 ; + + if(it != mSearchableServices.end() && it->second->search(substring_gr->hashed_group_id,encrypted_group_data,encrypted_group_data_len)) + { + RsGxsNetTunnelTurtleSearchGroupDataItem search_result_item ; + + search_result_item.service = substring_gr->service ; + search_result_item.encrypted_group_data = encrypted_group_data ; + search_result_item.encrypted_group_data_len = encrypted_group_data_len; + + search_result_data_size = RsGxsNetTunnelSerializer().size(&search_result_item) ; + search_result_data = (unsigned char*)rs_malloc(search_result_data_size) ; + + if(search_result_data == NULL) + return false ; + + RsGxsNetTunnelSerializer().serialise(&search_result_item,search_result_data,&search_result_data_size); + + return true ; + } + } + + return false ; +} + +void RsGxsNetTunnelService::receiveSearchResult(TurtleSearchRequestId request_id,unsigned char *search_result_data,uint32_t search_result_data_len) +{ + RsItem *item = RsGxsNetTunnelSerializer().deserialise(search_result_data,&search_result_data_len); + + GXS_NET_TUNNEL_DEBUG() << " : received search result for search request " << std::hex << request_id << "" << std::endl; + + RsGxsNetTunnelTurtleSearchGroupSummaryItem *result_gs = dynamic_cast(item) ; + + if(result_gs != NULL) + { + GXS_NET_TUNNEL_DEBUG() << " : result is of type group summary result for service " << result_gs->service << std::dec << ": " << std::endl; + + for(auto it(result_gs->group_infos.begin());it!=result_gs->group_infos.end();++it) + std::cerr << " group " << (*it).mGroupId << ": " << (*it).mGroupName << ", " << (*it).mNumberOfMessages << " messages, last is " << time(NULL)-(*it).mLastMessageTs << " secs ago." << std::endl; + + auto it = mSearchableServices.find(result_gs->service) ; + + if(it == mSearchableServices.end()) + { + GXS_NET_TUNNEL_ERROR() << ": deserialized item is for service " << std::hex << result_gs->service << std::dec << " that is not in the searchable services list." << std::endl; + delete item; + return ; + } + + it->second->receiveTurtleSearchResults(request_id,result_gs->group_infos) ; + + delete item; + return ; + } + + RsGxsNetTunnelTurtleSearchGroupDataItem *result_gd = dynamic_cast(item) ; + + if(result_gd != NULL) + { + GXS_NET_TUNNEL_DEBUG() << " : result is of type group data for service " << result_gd->service << std::dec << ": " << std::endl; + + auto it = mSearchableServices.find(result_gd->service) ; + + if(it == mSearchableServices.end()) + { + GXS_NET_TUNNEL_ERROR() << ": deserialized item is for service " << std::hex << result_gd->service << std::dec << " that is not in the searchable services list." << std::endl; + delete item; + return ; + } + + it->second->receiveTurtleSearchResults(request_id,result_gd->encrypted_group_data,result_gd->encrypted_group_data_len) ; + + result_gd->encrypted_group_data = NULL ; // prevents deletion + delete item; + + return ; + } + + GXS_NET_TUNNEL_ERROR() << ": deserialized item is of unknown type. Dropping!" << std::endl; +} + +void RsGxsNetTunnelService::getStatistics(std::map& groups, std::map& virtual_peers, std::map &turtle_vpid_to_net_tunnel_vpid, Bias20Bytes& bias ) const +{ + groups = mGroups ; + virtual_peers = mVirtualPeers ; + turtle_vpid_to_net_tunnel_vpid = mTurtle2GxsPeer; + bias = mRandomBias ; +} + + + + + + + + + + + + + + + + + + + + diff --git a/libretroshare/src/gxs/rsgxsnettunnel.h b/libretroshare/src/gxs/rsgxsnettunnel.h new file mode 100644 index 000000000..cbac109a9 --- /dev/null +++ b/libretroshare/src/gxs/rsgxsnettunnel.h @@ -0,0 +1,277 @@ +/* + * libretroshare/src/gxs: rsgxsnettunnel.h + * + * General Data service, interface for RetroShare. + * + * Copyright 2018-2018 by Cyril Soler + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License Version 2 as published by the Free Software Foundation. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA. + * + * Please report all bugs and problems to "retroshare.project@gmail.com" + * + */ + +#pragma once + +#include + +#include "turtle/p3turtle.h" +#include "retroshare/rsgxsdistsync.h" + +/*! + * \brief The RsGxsNetTunnelService class takes care of requesting tunnels to the turtle router, through which it is possible to sync + * a particular GXS group. For each group, a set of virtual peers, corresponding to active tunnels will be made available + * to RsGxsNetService. + * + * It is the responsibility of RsGxsNetService to activate/desactivate tunnels for each particular group, depending on wether the group + * is already available at regular friends or not. + * + * Tunnel management is done at the level of groups rather than services, because we would like to keep the possibility to not + * request tunnels for some groups which do not need it, and only request tunnels for specific groups that cannot be provided + * by direct connections. + */ + +// Protocol: +// * request tunnels based on H(GroupId) +// * encrypt tunnel data using chacha20+HMAC-SHA256 using AEAD( GroupId, 96bits IV, tunnel ID ) (similar to what FT does) +// * when tunnel is established, exchange virtual peer names: vpid = H( GroupID | Random bias ) +// * when vpid is known, notify the client (GXS net service) which can use the virtual peer to sync +// * only use a single tunnel per virtual peer ID +// - +// Client ------------------ TR(H(GroupId)) --------------> Server | +// | Turtle +// Client <-------------------- T OK ---------------------- Server | +// - +// Here, a turtle vpid is known | [ addVirtualPeer() called by turtle ] +// - +// [Encrypted traffic using H(GroupId | Tunnel ID, 96bits IV)] | +// | +// Client <--------- VPID = H( Random IV | GroupId ) ------ Server | +// | | | +// +--------------> Mark the virtual peer active <-----------+ | Encrypted traffic decoded locally and sorted +// | +// Here, a consistent virtual peer ID is known | +// | +// Client <------------------- GXS Data ------------------> Server | +// - +// Notes: +// * tunnels are established symmetrically. If a distant peers wants to sync the same group, they'll have to open a single tunnel, with a different ID. +// Groups therefore have two states: +// - managed : the group can be used to answer tunnel requests. If server tunnels are established, the group will be synced with these peers +// - tunneled: the group will actively request tunnels. If tunnels are established both ways, the same virtual peers will be used so the tunnels are "merged". +// * In practice, that means one of the two tunnels will not be used and therefore die. +// * If a tunneled group already has enough virtual peers, it will not request for tunnels itself. +// +// Group policy | Request tunnels | SyncWithPeers | Item receipt +// --------------------+-------------------+-----------------------+---------------- +// Passive | no | If peers present | If peers present +// Active | yes, if no peers | If peers present | If peers present +// | | | +// +// * when a service has the DistSync flag set, groups to sync are communicated passively to the GxsNetTunnel service when requesting distant peers. +// However, a call should be made to set a particular group policy to "ACTIVE" for group that do not have peers and need some. +// +// * services also need to retrieve GXS data items that come out of tunnels. These will be available as (data,len) type, since they are not de-serialized. +// +// * GxsNetService stores data information (such as update maps) per peerId, so it makes sense to use the same PeerId for all groups of a given service +// Therefore, virtual peers are stored separately from groups, because each one can sync multiple groups. +// +// * virtual peers are also shared among services. This reduces the required amount of tunnels and tunnel requests to send. +// +// * tunnels for a given service may also be used by the net service of p3IdService in order to explicitely request missing GxsIds. +// So GxsNetTunnel somehow allows different services to use the same tunnel. However we make sure that this traffic is limited to only p3IdService. +// +// How do we know that a group needs distant sync? +// * look into GrpConfigMap for suppliers. Suppliers is cleared at load. +// * last_update_TS in GrpConfigMap is randomised so it cannot be used +// * we need a way to know that there's no suppliers for good reasons (not that we just started) +// +// Security +// * the question of sync-ing with distant anonymous peers is a bit tricky because these peers can try to generate fake requests or change which messages are available +// and there is no way to prevent it. We therefore rely on GXS data integrity system to prevent this to happen. +// + +class RsGxsNetTunnelItem ; +class RsNetworkExchangeService ; + +class RsGxsNetTunnelService: public RsTurtleClientService, public RsTickingThread, public p3Config, public RsGxsDistSync +{ +public: + RsGxsNetTunnelService() ; + virtual ~RsGxsNetTunnelService() ; + + /*! + * \brief registerSearchableService + * Adds the network exchange service as a possible search source. This is used to allow distant search on the corresponding + * GXS service. + * \return + * always returns true. + */ + bool registerSearchableService(RsNetworkExchangeService *) ; + + /*! + * \brief Manage tunnels for this group + * @param group_id group for which tunnels should be released + */ + bool requestDistantPeers(uint16_t service_id,const RsGxsGroupId&group_id) ; + + /*! + * \brief Stop managing tunnels for this group + * @param group_id group for which tunnels should be released + */ + bool releaseDistantPeers(uint16_t service_id, const RsGxsGroupId&group_id) ; + + /*! + * \brief Get the list of active virtual peers for a given group. This implies that a tunnel is up and + * alive. This function also "registers" the group which allows to handle tunnel requests in the server side. + */ + bool getVirtualPeers(std::list& peers) ; // returns the virtual peers for this service + + /*! + * \brief serviceId + * Overloads the method in RsTurtleClientService. + * \return + * The service id for RsGxsNetTunnel. + */ + uint16_t serviceId() const ; + + /*! + * \brief sendData + * send data to this virtual peer, and takes memory ownership (deletes the item) + * \param item item to send + * \param virtual_peer destination virtual peer + * \return + * true if succeeded. + */ + bool sendTunnelData(uint16_t service_id,unsigned char *& data, uint32_t data_len, const RsGxsNetTunnelVirtualPeerId& virtual_peer) ; + + /*! + * \brief receiveData + * returns the next piece of data received, and the virtual GXS peer that sended it. + * \param data memory check containing the data. Memory ownership belongs to the client. + * \param data_len length of memory chunk + * \param virtual_peer peer who sent the data + * \return + * true if something is returned. If not, data is set to NULL, data_len to 0. + */ + bool receiveTunnelData(uint16_t service_id, unsigned char *& data, uint32_t& data_len, RsGxsNetTunnelVirtualPeerId& virtual_peer) ; + + /*! + * \brief isDistantPeer + * returns wether the peer is in the list of available distant peers or not + * \param group_id returned by the service to indicate which group this peer id is designed for. + * \return true if the peer is a distant GXS peer. + */ + + bool isDistantPeer(const RsGxsNetTunnelVirtualPeerId& virtual_peer,RsGxsGroupId& group_id) ; + + /*! + * \brief dumps all information about monitored groups. + */ + void dump() const; + + /*! + * \brief connectToTurtleRouter + * Should be called after allocating a RsGxsNetTunnelService + * \param tr turtle router object + */ + virtual void connectToTurtleRouter(p3turtle *tr) ; + + TurtleRequestId turtleGroupRequest(const RsGxsGroupId& group_id, RsNetworkExchangeService *client_service) ; + TurtleRequestId turtleSearchRequest(const std::string& match_string,RsNetworkExchangeService *client_service) ; + + /*! + * \brief receiveSearchRequest + * See RsTurtleClientService::@ + */ + virtual bool receiveSearchRequest(unsigned char *search_request_data, uint32_t search_request_data_len, unsigned char *& search_result_data, uint32_t& search_result_data_len, uint32_t &max_allowed_hits); + virtual void receiveSearchResult(TurtleSearchRequestId request_id,unsigned char *search_result_data,uint32_t search_result_data_len); + + // Overloaded from RsTickingThread + + void data_tick() ; + + // Overloads p3Config + + RsSerialiser *setupSerialiser(); + bool saveList(bool& cleanup, std::list& save); + bool loadList(std::list &load); + + // Overloads RsGxsDistSync + + void getStatistics(std::map& groups, // groups on the client and server side + std::map& virtual_peers, // current virtual peers, which group they provide, and how to talk to them through turtle + std::map& turtle_vpid_to_net_tunnel_vpid, + Bias20Bytes& bias) const; + +protected: + // interaction with turtle router + + virtual bool handleTunnelRequest(const RsFileHash &hash,const RsPeerId& peer_id) ; + virtual void receiveTurtleData(const RsTurtleGenericTunnelItem *item,const RsFileHash& hash,const RsPeerId& virtual_peer_id,RsTurtleGenericTunnelItem::Direction direction) ; + void addVirtualPeer(const TurtleFileHash&, const TurtleVirtualPeerId&,RsTurtleGenericTunnelItem::Direction dir) ; + void removeVirtualPeer(const TurtleFileHash&, const TurtleVirtualPeerId&) ; + const Bias20Bytes& locked_randomBias() ; + + p3turtle *mTurtle ; + + static const uint32_t RS_GXS_TUNNEL_CONST_RANDOM_BIAS_SIZE = 20 ; + static const uint32_t RS_GXS_TUNNEL_CONST_EKEY_SIZE = 32 ; + + mutable Bias20Bytes mRandomBias ; // constant accross reboots. Allows to disguise the real SSL id while providing a consistent value accross time. +private: + void autowash() ; + void sendKeepAlivePackets() ; + void handleIncoming(RsGxsNetTunnelItem *item) ; + void flush_pending_items(); + + std::map mGroups ; // groups on the client and server side + + std::map mVirtualPeers ; // current virtual peers, which group they provide, and how to talk to them through turtle + std::map mHandledHashes ; // hashes asked to turtle. Used to answer tunnel requests + std::map mTurtle2GxsPeer ; // convertion table to find GXS peer id from turtle + + std::list > mPendingTurtleItems ; // items that need to be sent off-turtle Mutex. + + std::map > > mIncomingData; // list of incoming data items + + std::map mSearchableServices ; + + /*! + * \brief Generates the hash to request tunnels for this group. This hash is only used by turtle, and is used to + * hide the real group id. + */ + + RsFileHash calculateGroupHash(const RsGxsGroupId&group_id) const ; + + /*! + * \brief makeVirtualPeerIdForGroup creates a virtual peer id that can be used and that will be constant accross time, whatever the + * tunnel ID and turtle virtual peer id. This allows RsGxsNetService to keep sync-ing the data consistently. + */ + + RsGxsNetTunnelVirtualPeerId locked_makeVirtualPeerId(const RsGxsGroupId& group_id) ; + + static void generateEncryptionKey(const RsGxsGroupId& group_id,const TurtleVirtualPeerId& vpid,unsigned char key[RS_GXS_TUNNEL_CONST_EKEY_SIZE]) ; + + mutable RsMutex mGxsNetTunnelMtx; + + friend class RsGxsTunnelRandomBiasItem ; + friend class StoreHere ; + + time_t mLastKeepAlive ; + time_t mLastAutoWash ; + time_t mLastDump ; +}; + diff --git a/libretroshare/src/gxs/rsgxsnetutils.cc b/libretroshare/src/gxs/rsgxsnetutils.cc index 7454ba58a..7195ff519 100644 --- a/libretroshare/src/gxs/rsgxsnetutils.cc +++ b/libretroshare/src/gxs/rsgxsnetutils.cc @@ -1,27 +1,24 @@ -/* - * libretroshare/src/gxs: rsgxnetutils.cc - * - * Helper objects for the operation rsgxsnetservice - * - * Copyright 2012-2013 by Christopher Evi-Parker - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ +/******************************************************************************* + * libretroshare/src/gxs: rsgxsnetutils.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012-2013 by Christopher Evi-Parker * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "rsgxsnetutils.h" #include "pqi/p3servicecontrol.h" diff --git a/libretroshare/src/gxs/rsgxsnetutils.h b/libretroshare/src/gxs/rsgxsnetutils.h index aae2be9f8..90ab64cf9 100644 --- a/libretroshare/src/gxs/rsgxsnetutils.h +++ b/libretroshare/src/gxs/rsgxsnetutils.h @@ -1,27 +1,24 @@ -/* - * libretroshare/src/gxs: rsgxnetutils.h - * - * Helper objects for the operation rsgxsnetservice - * - * Copyright 2012-2013 by Christopher Evi-Parker - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ +/******************************************************************************* + * libretroshare/src/gxs: rsgxsnetutils.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012-2013 by Christopher Evi-Parker * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RSGXSNETUTILS_H_ #define RSGXSNETUTILS_H_ diff --git a/libretroshare/src/gxs/rsgxsrequesttypes.cc b/libretroshare/src/gxs/rsgxsrequesttypes.cc index 81dec52ab..d57b4d353 100644 --- a/libretroshare/src/gxs/rsgxsrequesttypes.cc +++ b/libretroshare/src/gxs/rsgxsrequesttypes.cc @@ -1,27 +1,24 @@ -/* - * libretroshare/src/gxs: rgxsrequesttypes.cc - * - * Type introspect request types for data access request implementation - * - * Copyright 2012-2012 by Christopher Evi-Parker - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ +/******************************************************************************* + * libretroshare/src/gxs: rsgxsrequesttypes.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012-2012 by Christopher Evi-Parker * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "rsgxsrequesttypes.h" #include "util/rsstd.h" diff --git a/libretroshare/src/gxs/rsgxsrequesttypes.h b/libretroshare/src/gxs/rsgxsrequesttypes.h index 5c70c9d52..7af50b135 100644 --- a/libretroshare/src/gxs/rsgxsrequesttypes.h +++ b/libretroshare/src/gxs/rsgxsrequesttypes.h @@ -1,38 +1,36 @@ +/******************************************************************************* + * libretroshare/src/gxs: rsgxsrequesttypes.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012-2012 by Christopher Evi-Parker * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RSGXSREQUESTTYPES_H_ #define RSGXSREQUESTTYPES_H_ -/* - * libretroshare/src/gxs: rgxsrequesttypes.h - * - * Type introspect request types for data access request implementation - * - * Copyright 2012-2012 by Christopher Evi-Parker - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - #include "retroshare/rstokenservice.h" #include "gxs/rsgds.h" #include "util/rsdeprecate.h" struct GxsRequest { - GxsRequest() : token(0), reqTime(0), ansType(0), reqType(0), status(0) {} + GxsRequest() : + token(0), reqTime(0), ansType(0), reqType(0), + status(RsTokenService::FAILED) {} virtual ~GxsRequest() {} uint32_t token; @@ -42,7 +40,7 @@ struct GxsRequest uint32_t reqType; RsTokReqOptions Options; - uint32_t status; + RsTokenService::GxsRequestStatus status; }; class GroupMetaReq : public GxsRequest diff --git a/libretroshare/src/gxs/rsgxsutil.cc b/libretroshare/src/gxs/rsgxsutil.cc index bb0b1fb05..2e7a69079 100644 --- a/libretroshare/src/gxs/rsgxsutil.cc +++ b/libretroshare/src/gxs/rsgxsutil.cc @@ -1,27 +1,25 @@ -/* - * libretroshare/src/gxs: rsgxsutil.cc - * - * RetroShare C++ Interface. Generic routines that are useful in GXS - * - * Copyright 2013-2013 by Christopher Evi-Parker - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ +/******************************************************************************* + * libretroshare/src/gxs: rsgxsutil.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2013-2013 by Christopher Evi-Parker * + * Copyright (C) 2018 Gioacchino Mazzurco * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include @@ -31,6 +29,12 @@ #include "pqi/pqihash.h" #include "gxs/rsgixs.h" +#ifdef RS_DEEP_SEARCH +# include "deep_search/deep_search.h" +# include "services/p3gxschannels.h" +# include "rsitems/rsgxschannelitems.h" +#endif + static const uint32_t MAX_GXS_IDS_REQUESTS_NET = 10 ; // max number of requests from cache/net (avoids killing the system!) //#define DEBUG_GXSUTIL 1 @@ -141,20 +145,27 @@ bool RsGxsMessageCleanUp::clean() return mGrpMeta.empty(); } -RsGxsIntegrityCheck::RsGxsIntegrityCheck(RsGeneralDataService* const dataService, RsGenExchange *genex, RsGixs *gixs) : - mDs(dataService),mGenExchangeClient(genex), mDone(false), mIntegrityMutex("integrity"),mGixs(gixs) -{ } +RsGxsIntegrityCheck::RsGxsIntegrityCheck( + RsGeneralDataService* const dataService, RsGenExchange* genex, + RsSerialType& serializer, RsGixs* gixs ) : + mDs(dataService), mGenExchangeClient(genex), mSerializer(serializer), + mDone(false), mIntegrityMutex("integrity"), mGixs(gixs) {} void RsGxsIntegrityCheck::run() { check(); - RsStackMutex stack(mIntegrityMutex); - mDone = true; + RS_STACK_MUTEX(mIntegrityMutex); + mDone = true; } bool RsGxsIntegrityCheck::check() { +#ifdef RS_DEEP_SEARCH + bool isGxsChannels = mGenExchangeClient->serviceType() == RS_SERVICE_GXS_TYPE_CHANNELS; + std::set indexedGroups; +#endif + // first take out all the groups std::map grp; mDs->retrieveNxsGrps(grp, true, true); @@ -166,67 +177,104 @@ bool RsGxsIntegrityCheck::check() std::set subscribed_groups ; // compute hash and compare to stored value, if it fails then simply add it - // to list - std::map::iterator git = grp.begin(); - for(; git != grp.end(); ++git) - { - RsNxsGrp* grp = git->second; - RsFileHash currHash; - pqihash pHash; - pHash.addData(grp->grp.bin_data, grp->grp.bin_len); - pHash.Complete(currHash); + // to list + for( std::map::iterator git = grp.begin(); + git != grp.end(); ++git ) + { + RsNxsGrp* grp = git->second; + RsFileHash currHash; + pqihash pHash; + pHash.addData(grp->grp.bin_data, grp->grp.bin_len); + pHash.Complete(currHash); - if(currHash == grp->metaData->mHash) - { - // get all message ids of group - if (mDs->retrieveMsgIds(grp->grpId, msgIds[grp->grpId]) == 1) - { - // store the group for retrieveNxsMsgs - grps[grp->grpId]; + if(currHash == grp->metaData->mHash) + { + // get all message ids of group + if (mDs->retrieveMsgIds(grp->grpId, msgIds[grp->grpId]) == 1) + { + // store the group for retrieveNxsMsgs + grps[grp->grpId]; - if(grp->metaData->mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_SUBSCRIBED) - { - subscribed_groups.insert(git->first) ; + if(grp->metaData->mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_SUBSCRIBED) + { + subscribed_groups.insert(git->first); - if(!grp->metaData->mAuthorId.isNull()) - { + if(!grp->metaData->mAuthorId.isNull()) + { #ifdef DEBUG_GXSUTIL - GXSUTIL_DEBUG() << "TimeStamping group authors' key ID " << grp->metaData->mAuthorId << " in group ID " << grp->grpId << std::endl; + GXSUTIL_DEBUG() << "TimeStamping group authors' key ID " << grp->metaData->mAuthorId << " in group ID " << grp->grpId << std::endl; #endif + if( rsReputations && rsReputations->overallReputationLevel(grp->metaData->mAuthorId ) > RsReputations::REPUTATION_LOCALLY_NEGATIVE ) + used_gxs_ids.insert(std::make_pair(grp->metaData->mAuthorId, RsIdentityUsage(mGenExchangeClient->serviceType(), RsIdentityUsage::GROUP_AUTHOR_KEEP_ALIVE,grp->grpId))); + } + } + } + else msgIds.erase(msgIds.find(grp->grpId)); - if(rsReputations!=NULL && rsReputations->overallReputationLevel(grp->metaData->mAuthorId) > RsReputations::REPUTATION_LOCALLY_NEGATIVE) - used_gxs_ids.insert(std::make_pair(grp->metaData->mAuthorId,RsIdentityUsage(mGenExchangeClient->serviceType(),RsIdentityUsage::GROUP_AUTHOR_KEEP_ALIVE,grp->grpId))) ; - } - } - } - else - { - msgIds.erase(msgIds.find(grp->grpId)); - // grpsToDel.push_back(grp->grpId); - } +#ifdef RS_DEEP_SEARCH + if( isGxsChannels + && grp->metaData->mCircleType == GXS_CIRCLE_TYPE_PUBLIC + && grp->metaData->mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_SUBSCRIBED ) + { + RsGxsGrpMetaData meta; + meta.deserialise(grp->meta.bin_data, grp->meta.bin_len); - } - else - { - grpsToDel.push_back(grp->grpId); - } + uint32_t blz = grp->grp.bin_len; + RsItem* rIt = mSerializer.deserialise(grp->grp.bin_data, + &blz); - if(!(grp->metaData->mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_SUBSCRIBED) && !(grp->metaData->mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN) && !(grp->metaData->mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_PUBLISH)) - { - RsGroupNetworkStats stats ; - mGenExchangeClient->getGroupNetworkStats(grp->grpId,stats); + if( RsGxsChannelGroupItem* cgIt = + dynamic_cast(rIt) ) + { + RsGxsChannelGroup cg; + cgIt->toChannelGroup(cg, false); + cg.mMeta = meta; - if(stats.mSuppliers == 0 && stats.mMaxVisibleCount == 0 && stats.mGrpAutoSync) - { + indexedGroups.insert(grp->grpId); + DeepSearch::indexChannelGroup(cg); + } + else + { + std::cerr << __PRETTY_FUNCTION__ << " Group: " + << meta.mGroupId.toStdString() << " " + << meta.mGroupName + << " doesn't seems a channel, please " + << "report to developers" + << std::endl; + print_stacktrace(); + } + + delete rIt; + } +#endif + } + else + { + grpsToDel.push_back(grp->grpId); +#ifdef RS_DEEP_SEARCH + if(isGxsChannels) DeepSearch::removeChannelFromIndex(grp->grpId); +#endif + } + + if( !(grp->metaData->mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_SUBSCRIBED) && + !(grp->metaData->mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN) && + !(grp->metaData->mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_PUBLISH) ) + { + RsGroupNetworkStats stats; + mGenExchangeClient->getGroupNetworkStats(grp->grpId,stats); + + if( stats.mSuppliers == 0 && stats.mMaxVisibleCount == 0 + && stats.mGrpAutoSync ) + { #ifdef DEBUG_GXSUTIL - GXSUTIL_DEBUG() << "Scheduling group \"" << grp->metaData->mGroupName << "\" ID=" << grp->grpId << " in service " << std::hex << mGenExchangeClient->serviceType() << std::dec << " for deletion because it has no suppliers not any visible data at friends." << std::endl; + GXSUTIL_DEBUG() << "Scheduling group \"" << grp->metaData->mGroupName << "\" ID=" << grp->grpId << " in service " << std::hex << mGenExchangeClient->serviceType() << std::dec << " for deletion because it has no suppliers not any visible data at friends." << std::endl; #endif grpsToDel.push_back(grp->grpId); - } - } + } + } - delete grp; - } + delete grp; + } mDs->removeGroups(grpsToDel); @@ -260,40 +308,90 @@ bool RsGxsIntegrityCheck::check() } if (nxsMsgIt == nxsMsgV.end()) - { - msgsToDel[grpId].insert(msgId); + { + msgsToDel[grpId].insert(msgId); +#ifdef RS_DEEP_SEARCH + if(isGxsChannels) + DeepSearch::removeChannelPostFromIndex(grpId, msgId); +#endif } } } - GxsMsgResult::iterator mit = msgs.begin(); + GxsMsgResult::iterator mit = msgs.begin(); + for(; mit != msgs.end(); ++mit) + { + std::vector& msgV = mit->second; + std::vector::iterator vit = msgV.begin(); - for(; mit != msgs.end(); ++mit) - { - std::vector& msgV = mit->second; - std::vector::iterator vit = msgV.begin(); + for(; vit != msgV.end(); ++vit) + { + RsNxsMsg* msg = *vit; + RsFileHash currHash; + pqihash pHash; + pHash.addData(msg->msg.bin_data, msg->msg.bin_len); + pHash.Complete(currHash); - for(; vit != msgV.end(); ++vit) - { - RsNxsMsg* msg = *vit; - RsFileHash currHash; - pqihash pHash; - pHash.addData(msg->msg.bin_data, msg->msg.bin_len); - pHash.Complete(currHash); - - 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].insert(msg->msgId); - } - else if(!msg->metaData->mAuthorId.isNull() && subscribed_groups.find(msg->metaData->mGroupId)!=subscribed_groups.end()) - { -#ifdef DEBUG_GXSUTIL - GXSUTIL_DEBUG() << "TimeStamping message authors' key ID " << msg->metaData->mAuthorId << " in message " << msg->msgId << ", group ID " << msg->grpId<< std::endl; + if(msg->metaData == NULL || currHash != msg->metaData->mHash) + { + std::cerr << __PRETTY_FUNCTION__ <<" (EE) deleting message data" + << " with wrong hash or null meta data. meta=" + << (void*)msg->metaData << std::endl; + msgsToDel[msg->grpId].insert(msg->msgId); +#ifdef RS_DEEP_SEARCH + if(isGxsChannels) + DeepSearch::removeChannelPostFromIndex(msg->grpId, msg->msgId); #endif - if(rsReputations!=NULL && rsReputations->overallReputationLevel(msg->metaData->mAuthorId) > RsReputations::REPUTATION_LOCALLY_NEGATIVE) - used_gxs_ids.insert(std::make_pair(msg->metaData->mAuthorId,RsIdentityUsage(mGenExchangeClient->serviceType(),RsIdentityUsage::MESSAGE_AUTHOR_KEEP_ALIVE,msg->metaData->mGroupId,msg->metaData->mMsgId))) ; - } + } + else if (subscribed_groups.count(msg->metaData->mGroupId)) + { +#ifdef RS_DEEP_SEARCH + if( isGxsChannels + && indexedGroups.count(msg->metaData->mGroupId) ) + { + RsGxsMsgMetaData meta; + meta.deserialise(msg->meta.bin_data, &msg->meta.bin_len); + + uint32_t blz = msg->msg.bin_len; + RsItem* rIt = mSerializer.deserialise(msg->msg.bin_data, + &blz); + + if( RsGxsChannelPostItem* cgIt = + dynamic_cast(rIt) ) + { + RsGxsChannelPost cg; + cgIt->toChannelPost(cg, false); + cg.mMeta = meta; + + DeepSearch::indexChannelPost(cg); + } + else if(dynamic_cast(rIt)) {} + else if(dynamic_cast(rIt)) {} + else + { + std::cerr << __PRETTY_FUNCTION__ << " Message: " + << meta.mMsgId.toStdString() + << " in group: " + << meta.mGroupId.toStdString() << " " + << " doesn't seems a channel post, please " + << "report to developers" + << std::endl; + print_stacktrace(); + } + + delete rIt; + } +#endif + + if(!msg->metaData->mAuthorId.isNull()) + { +#ifdef DEBUG_GXSUTIL + GXSUTIL_DEBUG() << "TimeStamping message authors' key ID " << msg->metaData->mAuthorId << " in message " << msg->msgId << ", group ID " << msg->grpId<< std::endl; +#endif + if(rsReputations!=NULL && rsReputations->overallReputationLevel(msg->metaData->mAuthorId) > RsReputations::REPUTATION_LOCALLY_NEGATIVE) + used_gxs_ids.insert(std::make_pair(msg->metaData->mAuthorId,RsIdentityUsage(mGenExchangeClient->serviceType(),RsIdentityUsage::MESSAGE_AUTHOR_KEEP_ALIVE,msg->metaData->mGroupId,msg->metaData->mMsgId))) ; + } + } delete msg; } @@ -302,7 +400,7 @@ bool RsGxsIntegrityCheck::check() mDs->removeMsgs(msgsToDel); { - RsStackMutex stack(mIntegrityMutex); + RS_STACK_MUTEX(mIntegrityMutex); std::vector::iterator grpIt; for(grpIt = grpsToDel.begin(); grpIt != grpsToDel.end(); ++grpIt) @@ -373,14 +471,13 @@ bool RsGxsIntegrityCheck::check() bool RsGxsIntegrityCheck::isDone() { - RsStackMutex stack(mIntegrityMutex); + RS_STACK_MUTEX(mIntegrityMutex); return mDone; } void RsGxsIntegrityCheck::getDeletedIds(std::list& grpIds, std::map >& msgIds) { - RsStackMutex stack(mIntegrityMutex); - + RS_STACK_MUTEX(mIntegrityMutex); grpIds = mDeletedGrps; msgIds = mDeletedMsgs; } diff --git a/libretroshare/src/gxs/rsgxsutil.h b/libretroshare/src/gxs/rsgxsutil.h index 70e832c3e..d4770303e 100644 --- a/libretroshare/src/gxs/rsgxsutil.h +++ b/libretroshare/src/gxs/rsgxsutil.h @@ -1,27 +1,25 @@ -/* - * libretroshare/src/gxs: rsgxsutil.h - * - * RetroShare C++ Interface. Generic routines that are useful in GXS - * - * Copyright 2013-2013 by Christopher Evi-Parker - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ +/******************************************************************************* + * libretroshare/src/gxs: rsgxsutil.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2013-2013 by Christopher Evi-Parker * + * Copyright (C) 2018 Gioacchino Mazzurco * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef GXSUTIL_H_ #define GXSUTIL_H_ @@ -201,7 +199,9 @@ public: * @param chunkSize * @param sleepPeriod */ - RsGxsIntegrityCheck(RsGeneralDataService* const dataService, RsGenExchange *genex, RsGixs *gixs); + RsGxsIntegrityCheck( RsGeneralDataService* const dataService, + RsGenExchange *genex, RsSerialType& gxsSerialiser, + RsGixs *gixs); bool check(); bool isDone(); @@ -213,13 +213,15 @@ public: private: RsGeneralDataService* const mDs; - RsGenExchange *mGenExchangeClient; + RsGenExchange *mGenExchangeClient; + RsSerialType& mSerializer; + bool mDone; RsMutex mIntegrityMutex; std::list mDeletedGrps; std::map > mDeletedMsgs; - - RsGixs *mGixs ; + + RsGixs* mGixs; }; class GroupUpdate diff --git a/libretroshare/src/gxs/rsnxs.h b/libretroshare/src/gxs/rsnxs.h index 283c96e65..a6044aa46 100644 --- a/libretroshare/src/gxs/rsnxs.h +++ b/libretroshare/src/gxs/rsnxs.h @@ -36,6 +36,7 @@ #include "services/p3service.h" #include "retroshare/rsreputations.h" #include "retroshare/rsidentity.h" +#include "retroshare/rsturtle.h" #include "rsgds.h" /*! @@ -58,6 +59,7 @@ * 2 transfers only between group * - the also group matrix settings which is by default everyone can transfer to each other */ + class RsNetworkExchangeService { public: @@ -65,6 +67,7 @@ public: RsNetworkExchangeService(){ return;} virtual ~RsNetworkExchangeService() {} + virtual uint16_t serviceType() const =0; /*! * Use this to set how far back synchronisation of messages should take place * @param age in seconds the max age a sync/store item can to be allowed in a synchronisation @@ -81,6 +84,65 @@ public: virtual uint32_t getDefaultSyncAge() =0; virtual uint32_t getDefaultKeepAge() =0; + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + /// DISTANT SEARCH FUNCTIONS /// + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + /*! + * \brief turtleGroupRequest + * Requests a particular group meta data. The request protects the group ID. + * \param group_id + * \return + * returns the turtle request ID that might be associated to some results. + */ + virtual TurtleRequestId turtleGroupRequest(const RsGxsGroupId& group_id)=0; + + /*! + * \brief turtleSearchRequest + * Uses distant search to match the substring to the group meta data. + * \param match_string + * \return + * returns the turtle request ID that might be associated to some results. + */ + virtual TurtleRequestId turtleSearchRequest(const std::string& match_string)=0; + + /*! + * \brief receiveTurtleSearchResults + * Called by turtle (through RsGxsNetTunnel) when new results are received + * \param req Turtle search request ID associated with this result + * \param group_infos Group summary information for the groups returned by the search + */ + virtual void receiveTurtleSearchResults(TurtleRequestId req,const std::list& group_infos)=0; + + /*! + * \brief receiveTurtleSearchResults + * Called by turtle (through RsGxsNetTunnel) when new data is received + * \param req Turtle search request ID associated with this result + * \param encrypted_group_data Group data + */ + virtual void receiveTurtleSearchResults(TurtleRequestId req,const unsigned char *encrypted_group_data,uint32_t encrypted_group_data_len)=0; + + /*! + * \brief retrieveTurtleSearchResults + * To be used to retrieve the search results that have been notified (or not) + * \param req request that match the results to retrieve + * \param group_infos results to retrieve. + * \return + * false when the request is unknown. + */ + virtual bool retrieveDistantSearchResults(TurtleRequestId req, std::map &group_infos)=0; + /*! + * \brief getDistantSearchResults + * \param id + * \param group_infos + * \return + */ + virtual bool clearDistantSearchResults(const TurtleRequestId& id)=0; + virtual bool retrieveDistantGroupSummary(const RsGxsGroupId&,RsGxsGroupSummary&)=0; + + virtual bool search(const std::string& substring,std::list& group_infos) =0; + virtual bool search(const Sha1CheckSum& hashed_group_id,unsigned char *& encrypted_group_data,uint32_t& encrypted_group_data_len)=0; + /*! * Initiates a search through the network * This returns messages which contains the search terms set in RsGxsSearch @@ -99,6 +161,9 @@ public: */ //virtual int searchGrps(RsGxsSearch* search, uint8_t hops = 1, bool retrieve = 0) = 0; + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + /// DATA ACCESS FUNCTIONS /// + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /*! * pauses synchronisation of subscribed groups and request for group id @@ -166,6 +231,14 @@ public: */ virtual bool stampMsgServerUpdateTS(const RsGxsGroupId& gid) =0; + /*! + * \brief isDistantPeer + * \param pid peer that is a virtual peer provided by GxsNetTunnel + * \return + * true if the peer exists (adn therefore is online) + */ + virtual bool isDistantPeer(const RsPeerId& pid)=0; + /*! * \brief removeGroups * Removes time stamp information from the list of groups. This allows to re-sync them if suppliers are present. diff --git a/libretroshare/src/gxs/rsnxsobserver.h b/libretroshare/src/gxs/rsnxsobserver.h index 087842ef0..164cce366 100644 --- a/libretroshare/src/gxs/rsnxsobserver.h +++ b/libretroshare/src/gxs/rsnxsobserver.h @@ -1,34 +1,31 @@ +/******************************************************************************* + * libretroshare/src/gxs: rsgxsobserver.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2011-2012 by Robert Fernie, Evi-Parker Christopher * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RSNXSOBSERVER_H #define RSNXSOBSERVER_H -/* - * libretroshare/src/gxs: rsnxsobserver.h - * - * Observer interface used by nxs to transport new messages to clients - * - * Copyright 2011-2012 by Robert Fernie, Evi-Parker Christopher - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - #include #include "rsitems/rsnxsitems.h" +typedef uint32_t TurtleRequestId ; class RsNxsObserver { @@ -42,12 +39,22 @@ public: /*! * @param messages messages are deleted after function returns */ - virtual void notifyNewMessages(std::vector& messages) = 0; + virtual void receiveNewMessages(std::vector& messages) = 0; /*! * @param groups groups are deleted after function returns */ - virtual void notifyNewGroups(std::vector& groups) = 0; + virtual void receiveNewGroups(std::vector& groups) = 0; + + /*! + * \brief receiveDistantSearchResults + * Called when new distant search result arrive. + * \param grpId + */ + virtual void receiveDistantSearchResults(TurtleRequestId /*id*/,const RsGxsGroupId& /*grpId*/) + { + std::cerr << __PRETTY_FUNCTION__ << ": not overloaded but still called. Nothing will happen." << std::endl; + } /*! * @param grpId group id diff --git a/libretroshare/src/gxstrans/p3gxstrans.cc b/libretroshare/src/gxstrans/p3gxstrans.cc index 5b3834ea8..c57b24fbc 100644 --- a/libretroshare/src/gxstrans/p3gxstrans.cc +++ b/libretroshare/src/gxstrans/p3gxstrans.cc @@ -1,21 +1,24 @@ -/* - * GXS Mailing Service - * Copyright (C) 2016-2017 Gioacchino Mazzurco - * - * 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 . - */ - +/******************************************************************************* + * libretroshare/src/gxstrans: p3gxstrans.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright (C) 2016-2017 Gioacchino Mazzurco * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "util/rsdir.h" #include "gxstrans/p3gxstrans.h" #include "util/stacktrace.h" @@ -839,7 +842,7 @@ bool p3GxsTrans::dispatchDecryptedMail( const RsGxsId& authorId, #endif std::vector rcct; rcct.push_back(receipt); - RsGenExchange::notifyNewMessages(rcct); + RsGenExchange::receiveNewMessages(rcct); GxsTransClient* recipientService = NULL; { diff --git a/libretroshare/src/gxstrans/p3gxstrans.h b/libretroshare/src/gxstrans/p3gxstrans.h index af79679d9..3b0aca003 100644 --- a/libretroshare/src/gxstrans/p3gxstrans.h +++ b/libretroshare/src/gxstrans/p3gxstrans.h @@ -1,21 +1,25 @@ +/******************************************************************************* + * libretroshare/src/gxstrans: p3gxstrans.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright (C) 2016-2017 Gioacchino Mazzurco * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once -/* - * GXS Mailing Service - * Copyright (C) 2016-2017 Gioacchino Mazzurco - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ #include #include @@ -85,7 +89,7 @@ struct MsgSizeCount * @see GxsTransClient::receiveGxsTransMail(...), * @see GxsTransClient::notifyGxsTransSendStatus(...). */ -class p3GxsTrans : public RsGenExchange, public GxsTokenQueue, public p3Config, public RsGxsTrans +struct p3GxsTrans : RsGenExchange, GxsTokenQueue, p3Config, RsGxsTrans { public: p3GxsTrans( RsGeneralDataService* gds, RsNetworkExchangeService* nes, @@ -94,17 +98,16 @@ public: RS_SERVICE_TYPE_GXS_TRANS, &identities, AuthenPolicy()), GxsTokenQueue(this), - RsGxsTrans(this), - mIdService(identities), + RsGxsTrans(static_cast(*this)), + // always check 30 secs after start) + mLastMsgCleanup(time(NULL) - MAX_DELAY_BETWEEN_CLEANUPS + 30), + mIdService(identities), mServClientsMutex("p3GxsTrans client services map mutex"), mOutgoingMutex("p3GxsTrans outgoing queue map mutex"), mIngoingMutex("p3GxsTrans ingoing queue map mutex"), + mCleanupThread(nullptr), mPerUserStatsMutex("p3GxsTrans user stats mutex"), - mDataMutex("p3GxsTrans data mutex") - { - mLastMsgCleanup = time(NULL) - MAX_DELAY_BETWEEN_CLEANUPS + 30; // always check 30 secs after start - mCleanupThread = NULL ; - } + mDataMutex("p3GxsTrans data mutex") {} virtual ~p3GxsTrans(); diff --git a/libretroshare/src/gxstrans/p3gxstransitems.cc b/libretroshare/src/gxstrans/p3gxstransitems.cc index 5d28ec582..733d40bec 100644 --- a/libretroshare/src/gxstrans/p3gxstransitems.cc +++ b/libretroshare/src/gxstrans/p3gxstransitems.cc @@ -1,21 +1,24 @@ -/* - * GXS Mailing Service - * Copyright (C) 2016-2018 Gioacchino Mazzurco - * - * 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 . - */ - +/******************************************************************************* + * libretroshare/src/gxstrans: p3gxstrans.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright (C) 2016-2018 Gioacchino Mazzurco * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "gxstrans/p3gxstransitems.h" #include "serialiser/rstypeserializer.h" diff --git a/libretroshare/src/gxstrans/p3gxstransitems.h b/libretroshare/src/gxstrans/p3gxstransitems.h index bd13c9e71..cc7322844 100644 --- a/libretroshare/src/gxstrans/p3gxstransitems.h +++ b/libretroshare/src/gxstrans/p3gxstransitems.h @@ -1,21 +1,25 @@ +/******************************************************************************* + * libretroshare/src/gxstrans: p3gxstrans.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright (C) 2016-2017 Gioacchino Mazzurco * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once -/* - * GXS Mailing Service - * Copyright (C) 2016-2017 Gioacchino Mazzurco - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ #include diff --git a/libretroshare/src/gxstunnel/p3gxstunnel.cc b/libretroshare/src/gxstunnel/p3gxstunnel.cc index eef365230..f6d5cd7fd 100644 --- a/libretroshare/src/gxstunnel/p3gxstunnel.cc +++ b/libretroshare/src/gxstunnel/p3gxstunnel.cc @@ -1,36 +1,31 @@ -/* - * libretroshare/src/chat: distantchat.cc - * - * Services for RetroShare. - * - * Copyright 2014 by Cyril Soler - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "csoler@users.sourceforge.net". - * - */ - - +/******************************************************************************* + * libretroshare/src/chat: distantchat.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2015 by Cyril Soler * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include #include "openssl/rand.h" #include "openssl/dh.h" #include "openssl/err.h" -#include "util/rsaes.h" +#include "crypto/rsaes.h" #include "util/rsprint.h" #include "util/rsmemory.h" @@ -685,7 +680,7 @@ void p3GxsTunnelService::removeVirtualPeer(const TurtleFileHash& hash,const Turt } } -void p3GxsTunnelService::receiveTurtleData(RsTurtleGenericTunnelItem *gitem,const RsFileHash& hash, const RsPeerId& virtual_peer_id,RsTurtleGenericTunnelItem::Direction direction) +void p3GxsTunnelService::receiveTurtleData(const RsTurtleGenericTunnelItem *gitem, const RsFileHash& hash, const RsPeerId& virtual_peer_id, RsTurtleGenericTunnelItem::Direction direction) { #ifdef DEBUG_GXS_TUNNEL std::cerr << "GxsTunnelService::receiveTurtleData(): Received turtle data. " << std::endl; @@ -697,7 +692,7 @@ void p3GxsTunnelService::receiveTurtleData(RsTurtleGenericTunnelItem *gitem,cons (void) direction; #endif - RsTurtleGenericDataItem *item = dynamic_cast(gitem) ; + const RsTurtleGenericDataItem *item = dynamic_cast(gitem) ; if(item == NULL) { diff --git a/libretroshare/src/gxstunnel/p3gxstunnel.h b/libretroshare/src/gxstunnel/p3gxstunnel.h index cabe520d4..e32626c7f 100644 --- a/libretroshare/src/gxstunnel/p3gxstunnel.h +++ b/libretroshare/src/gxstunnel/p3gxstunnel.h @@ -1,28 +1,24 @@ -/* - * libretroshare/src/chat: distantchat.h - * - * Services for RetroShare. - * - * Copyright 2015 by Cyril Soler - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "csoler@users.sourceforge.net". - * - */ - +/******************************************************************************* + * libretroshare/src/chat: distantchat.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2015 by Cyril Soler * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once // Generic tunnel service @@ -95,7 +91,7 @@ // by a mix between our own GXS id and the GXS id we're talking to. That is what the TunnelVirtualPeer is. // // -// RequestTunnel(source_own_id,destination_id) - +// RequestTunnel(source_own_id,destination_id) - // | | // +---------------------------> p3Turtle::monitorTunnels( hash(destination_id) ) | // | | @@ -127,6 +123,8 @@ public: explicit p3GxsTunnelService(RsGixs *pids) ; virtual void connectToTurtleRouter(p3turtle *) ; + uint16_t serviceId() const { return RS_SERVICE_TYPE_GXS_TUNNEL ; } + // Creates the invite if the public key of the distant peer is available. // Om success, stores the invite in the map above, so that we can respond to tunnel requests. // @@ -211,7 +209,7 @@ private: // Overloaded from RsTurtleClientService virtual bool handleTunnelRequest(const RsFileHash &hash,const RsPeerId& peer_id) ; - virtual void receiveTurtleData(RsTurtleGenericTunnelItem *item,const RsFileHash& hash,const RsPeerId& virtual_peer_id,RsTurtleGenericTunnelItem::Direction direction) ; + virtual void receiveTurtleData(const RsTurtleGenericTunnelItem *item,const RsFileHash& hash,const RsPeerId& virtual_peer_id,RsTurtleGenericTunnelItem::Direction direction) ; void addVirtualPeer(const TurtleFileHash&, const TurtleVirtualPeerId&,RsTurtleGenericTunnelItem::Direction dir) ; void removeVirtualPeer(const TurtleFileHash&, const TurtleVirtualPeerId&) ; diff --git a/libretroshare/src/gxstunnel/rsgxstunnelitems.cc b/libretroshare/src/gxstunnel/rsgxstunnelitems.cc index d653b03ea..c43e4baae 100644 --- a/libretroshare/src/gxstunnel/rsgxstunnelitems.cc +++ b/libretroshare/src/gxstunnel/rsgxstunnelitems.cc @@ -1,28 +1,24 @@ - -/* - * libretroshare/src/serialiser: rsbaseitems.cc - * - * RetroShare Serialiser. - * - * Copyright 2007-2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ +/******************************************************************************* + * libretroshare/src/gxstunnel: rsgxstunnelitems.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2015 by Cyril Soler * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include #include diff --git a/libretroshare/src/gxstunnel/rsgxstunnelitems.h b/libretroshare/src/gxstunnel/rsgxstunnelitems.h index 8c4e95ba4..a098c8c05 100644 --- a/libretroshare/src/gxstunnel/rsgxstunnelitems.h +++ b/libretroshare/src/gxstunnel/rsgxstunnelitems.h @@ -1,28 +1,24 @@ -/* - * libretroshare/src/serialiser: rschatitems.h - * - * RetroShare Serialiser. - * - * Copyright 2007-2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/chat: rsgxstunnelitems.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2015 by Cyril Soler * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once #include diff --git a/libretroshare/src/jsonapi/jsonapi.cpp b/libretroshare/src/jsonapi/jsonapi.cpp new file mode 100644 index 000000000..255fd0548 --- /dev/null +++ b/libretroshare/src/jsonapi/jsonapi.cpp @@ -0,0 +1,145 @@ +/* + * RetroShare JSON API + * Copyright (C) 2018 Gioacchino Mazzurco + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#include "jsonapi.h" + +#include +#include +#include +#include + +#include "util/rsjson.h" +#include "retroshare/rsfiles.h" +#include "util/radix64.h" + +// Generated at compile time +#include "jsonapi-includes.inl" + +JsonApiServer::JsonApiServer( + uint16_t port, const std::function shutdownCallback) : + mPort(port), mShutdownCallback(shutdownCallback) +{ + registerHandler("/jsonApiServer/shutdown", + [this](const std::shared_ptr) + { + shutdown(); + }); + + registerHandler("/rsFiles/getFileData", + [](const std::shared_ptr session) + { + size_t reqSize = session->get_request()->get_header("Content-Length", 0); + session->fetch( reqSize, []( + const std::shared_ptr session, + const rb::Bytes& body ) + { + RsGenericSerializer::SerializeContext cReq( + nullptr, 0, + RsGenericSerializer::SERIALIZATION_FLAG_YIELDING ); + RsJson& jReq(cReq.mJson); + jReq.Parse(reinterpret_cast(body.data()), body.size()); + + RsGenericSerializer::SerializeContext cAns; + RsJson& jAns(cAns.mJson); + + // if caller specified caller_data put it back in the answhere + const char kcd[] = "caller_data"; + if(jReq.HasMember(kcd)) + jAns.AddMember(kcd, jReq[kcd], jAns.GetAllocator()); + + RsFileHash hash; + uint64_t offset; + uint32_t requested_size; + bool retval = false; + std::string errorMessage; + std::string base64data; + + // deserialize input parameters from JSON + { + RsGenericSerializer::SerializeContext& ctx(cReq); + RsGenericSerializer::SerializeJob j(RsGenericSerializer::FROM_JSON); + RS_SERIAL_PROCESS(hash); + RS_SERIAL_PROCESS(offset); + RS_SERIAL_PROCESS(requested_size); + } + + if(requested_size > 10485760) + errorMessage = "requested_size is too big! Better less then 1M"; + else + { + std::vector buffer(requested_size); + + // call retroshare C++ API + retval = rsFiles->getFileData( + hash, offset, requested_size, buffer.data()); + + Radix64::encode(buffer.data(), requested_size, base64data); + } + + // serialize out parameters and return value to JSON + { + RsGenericSerializer::SerializeContext& ctx(cAns); + RsGenericSerializer::SerializeJob j(RsGenericSerializer::TO_JSON); + RS_SERIAL_PROCESS(retval); + RS_SERIAL_PROCESS(requested_size); + RS_SERIAL_PROCESS(base64data); + if(!errorMessage.empty()) RS_SERIAL_PROCESS(errorMessage); + } + + // return them to the API caller + std::stringstream ss; + ss << jAns; + std::string&& ans(ss.str()); + const std::multimap headers + { + { "Content-Type", "text/json" }, + { "Content-Length", std::to_string(ans.length()) } + }; + session->close(rb::OK, ans, headers); + } ); + }); + +// Generated at compile time +#include "jsonapi-wrappers.inl" +} + +void JsonApiServer::run() +{ + std::shared_ptr settings(new rb::Settings); + settings->set_port(mPort); +// settings->set_default_header("Connection", "close"); + settings->set_default_header("Cache-Control", "no-cache"); + mService.start(settings); +} + +void JsonApiServer::registerHandler( + const std::string& path, + const std::function)>& handler) +{ + std::shared_ptr resource(new rb::Resource); + resource->set_path(path); + resource->set_method_handler("GET", handler); + resource->set_method_handler("POST", handler); + mService.publish(resource); +} + +void JsonApiServer::shutdown(int exitCode) +{ + mService.stop(); + mShutdownCallback(exitCode); +} diff --git a/libretroshare/src/jsonapi/jsonapi.h b/libretroshare/src/jsonapi/jsonapi.h new file mode 100644 index 000000000..f06f7e459 --- /dev/null +++ b/libretroshare/src/jsonapi/jsonapi.h @@ -0,0 +1,73 @@ +/* + * RetroShare JSON API + * Copyright (C) 2018 Gioacchino Mazzurco + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#include +#include +#include + +#include "util/rsthreads.h" + +namespace rb = restbed; + + +/** + * Simple usage + * \code{.cpp} + * JsonApiServer jas(9092); + * jas.start("JsonApiServer"); + * \endcode + */ +struct JsonApiServer : RsSingleJobThread +{ + JsonApiServer( + uint16_t port, + const std::function shutdownCallback = [](int){} ); + + /// @see RsSingleJobThread + virtual void run(); + + /** + * @param[in] path Path itno which publish the API call + * @param[in] handler function which will be called to handle the requested + * path, the function must be declared like: + * \code{.cpp} + * void functionName(const shared_ptr session) + * \endcode + */ + void registerHandler( + const std::string& path, + const std::function)>& handler ); + + /** + * @brief Shutdown the JSON API server and call shutdownCallback + * @jsonapi{development} + * Beware that this method shout down only the JSON API server instance not + * the whole RetroShare instance, this behaviour can be altered via + * shutdownCallback paramether of @see JsonApiServer::JsonApiServer + * This method is made available also via JSON API with path + * /jsonApiServer/shutdown + * @param exitCode just passed down to the shutdownCallback + */ + void shutdown(int exitCode = 0); + +private: + uint16_t mPort; + rb::Service mService; + const std::function mShutdownCallback; +}; + diff --git a/libretroshare/src/libretroshare.pro b/libretroshare/src/libretroshare.pro index 13d8fc8b2..68bf97161 100644 --- a/libretroshare/src/libretroshare.pro +++ b/libretroshare/src/libretroshare.pro @@ -1,3 +1,24 @@ +################################################################################ +# libretroshare.pro # +# Copyright (C) 2018, Retroshare team # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU Lesser 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 Lesser General Public License for more details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with this program. If not, see . # +################################################################################ +!include("../../retroshare.pri"): error("Could not include file ../../retroshare.pri") + +TEMPLATE = lib +CONFIG += staticlib !include("../../retroshare.pri"): error("Could not include file ../../retroshare.pri") TEMPLATE = lib @@ -137,6 +158,7 @@ PUBLIC_HEADERS = retroshare/rsdisc.h \ retroshare/rsconfig.h \ retroshare/rsversion.h \ retroshare/rsservicecontrol.h \ + retroshare/rsgxsdistsync.h HEADERS += plugins/pluginmanager.h \ plugins/dlfcn_win32.h \ @@ -351,7 +373,9 @@ HEADERS += ft/ftchunkmap.h \ ft/ftturtlefiletransferitem.h HEADERS += crypto/chacha20.h \ - crypto/hashstream.h + crypto/rsaes.h \ + crypto/hashstream.h \ + crypto/rscrypto.h HEADERS += directory_updater.h \ directory_list.h \ @@ -366,7 +390,6 @@ HEADERS += pqi/authssl.h \ pqi/authgpg.h \ pgp/pgphandler.h \ pgp/pgpkeyutil.h \ - pgp/rsaes.h \ pgp/rscertificate.h \ pgp/pgpauxutils.h \ pqi/p3cfgmgr.h \ @@ -378,7 +401,6 @@ HEADERS += pqi/authssl.h \ pqi/pqiqos.h \ pqi/pqi.h \ pqi/pqi_base.h \ - pqi/pqiarchive.h \ pqi/pqiassist.h \ pqi/pqibin.h \ pqi/pqihandler.h \ @@ -470,7 +492,7 @@ HEADERS += services/autoproxy/p3i2pbob.h \ services/p3discovery2.h \ services/p3heartbeat.h \ services/p3rtt.h \ - services/p3serviceinfo.cc \ + services/p3serviceinfo.h \ HEADERS += turtle/p3turtle.h \ turtle/rsturtleitem.h \ @@ -480,7 +502,6 @@ HEADERS += turtle/p3turtle.h \ HEADERS += util/folderiterator.h \ util/rsdebug.h \ util/rsmemory.h \ - util/rscompress.h \ util/smallobject.h \ util/rsdir.h \ util/rsdiscspace.h \ @@ -497,7 +518,6 @@ HEADERS += util/folderiterator.h \ util/rsversioninfo.h \ util/rswin.h \ util/rsrandom.h \ - util/pugiconfig.h \ util/rsmemcache.h \ util/rstickevent.h \ util/rsrecogn.h \ @@ -519,7 +539,10 @@ SOURCES += ft/ftchunkmap.cc \ ft/ftturtlefiletransferitem.cc SOURCES += crypto/chacha20.cpp \ - crypto/hashstream.cc + crypto/rsaes.cc \ + crypto/hashstream.cc\ + crypto/hashstream.cc \ + crypto/rscrypto.cpp SOURCES += chat/distantchat.cc \ chat/p3chatservice.cc \ @@ -538,7 +561,6 @@ SOURCES += pqi/authgpg.cc \ pqi/p3netmgr.cc \ pqi/p3notify.cc \ pqi/pqiqos.cc \ - pqi/pqiarchive.cc \ pqi/pqibin.cc \ pqi/pqihandler.cc \ pqi/p3historymgr.cc \ @@ -633,7 +655,6 @@ SOURCES += turtle/p3turtle.cc \ SOURCES += util/folderiterator.cc \ util/rsdebug.cc \ util/rsexpr.cc \ - util/rscompress.cc \ util/smallobject.cc \ util/rsdir.cc \ util/rsmemory.cc \ @@ -646,8 +667,6 @@ SOURCES += util/folderiterator.cc \ util/rsstring.cc \ util/rsthreads.cc \ util/rsversioninfo.cc \ - util/rswin.cc \ - util/rsaes.cc \ util/rsrandom.cc \ util/rstickevent.cc \ util/rsrecogn.cc \ @@ -707,6 +726,7 @@ HEADERS += rsitems/rsnxsitems.h \ gxs/rsgxs.h \ gxs/rsdataservice.h \ gxs/rsgxsnetservice.h \ + gxs/rsgxsnettunnel.h \ retroshare/rsgxsflags.h \ retroshare/rsgxsifacetypes.h \ gxs/rsgenexchange.h \ @@ -732,6 +752,7 @@ SOURCES += rsitems/rsnxsitems.cc \ gxs/rsdataservice.cc \ gxs/rsgenexchange.cc \ gxs/rsgxsnetservice.cc \ + gxs/rsgxsnettunnel.cc \ gxs/rsgxsdata.cc \ rsitems/rsgxsitems.cc \ gxs/rsgxsdataaccess.cc \ @@ -755,10 +776,12 @@ SOURCES += gxstunnel/p3gxstunnel.cc \ # new serialization code HEADERS += serialiser/rsserializable.h \ serialiser/rsserializer.h \ - serialiser/rstypeserializer.h + serialiser/rstypeserializer.h \ + util/rsjson.h SOURCES += serialiser/rsserializer.cc \ - serialiser/rstypeserializer.cc + serialiser/rstypeserializer.cc \ + util/rsjson.cc # Identity Service HEADERS += retroshare/rsidentity.h \ @@ -846,8 +869,63 @@ rs_gxs_trans { SOURCES += gxstrans/p3gxstransitems.cc gxstrans/p3gxstrans.cc } +rs_jsonapi { + JSONAPI_GENERATOR_SRC=$$system_path($$clean_path($${RS_SRC_PATH}/jsonapi-generator/src/)) + JSONAPI_GENERATOR_OUT=$$system_path($$clean_path($${RS_BUILD_PATH}/jsonapi-generator/src/)) + JSONAPI_GENERATOR_EXE=$$system_path($$clean_path($${JSONAPI_GENERATOR_OUT}/jsonapi-generator)) + DOXIGEN_INPUT_DIRECTORY=$$system_path($$clean_path($${PWD})) + DOXIGEN_CONFIG_SRC=$$system_path($$clean_path($${RS_SRC_PATH}/jsonapi-generator/src/jsonapi-generator-doxygen.conf)) + DOXIGEN_CONFIG_OUT=$$system_path($$clean_path($${JSONAPI_GENERATOR_OUT}/jsonapi-generator-doxygen.conf)) + WRAPPERS_INCL_FILE=$$system_path($$clean_path($${JSONAPI_GENERATOR_OUT}/jsonapi-includes.inl)) + WRAPPERS_REG_FILE=$$system_path($$clean_path($${JSONAPI_GENERATOR_OUT}/jsonapi-wrappers.inl)) + restbed.target = $$system_path($$clean_path($${RESTBED_BUILD_PATH}/library/librestbed.a)) + restbed.commands = \ + cd $${RS_SRC_PATH};\ + git submodule update --init --recommend-shallow supportlibs/restbed;\ + cd $${RESTBED_SRC_PATH};\ + git submodule update --init --recommend-shallow dependency/asio;\ + git submodule update --init --recommend-shallow dependency/catch;\ + git submodule update --init --recommend-shallow dependency/kashmir;\ + mkdir -p $${RESTBED_BUILD_PATH}; cd $${RESTBED_BUILD_PATH};\ + cmake -DBUILD_SSL=OFF -DCMAKE_INSTALL_PREFIX=. -B. -H$${RESTBED_SRC_PATH};\ + make; make install + QMAKE_EXTRA_TARGETS += restbed + libretroshare.depends += restbed + PRE_TARGETDEPS *= $${restbed.target} + PRE_TARGETDEPS *= $${JSONAPI_GENERATOR_EXE} + INCLUDEPATH *= $${JSONAPI_GENERATOR_OUT} + GENERATED_HEADERS += $${WRAPPERS_INCL_FILE} + + jsonwrappersincl.target = $${WRAPPERS_INCL_FILE} + jsonwrappersincl.commands = \ + cp $${DOXIGEN_CONFIG_SRC} $${DOXIGEN_CONFIG_OUT}; \ + echo OUTPUT_DIRECTORY=$${JSONAPI_GENERATOR_OUT} >> $${DOXIGEN_CONFIG_OUT};\ + echo INPUT=$${DOXIGEN_INPUT_DIRECTORY} >> $${DOXIGEN_CONFIG_OUT}; \ + doxygen $${DOXIGEN_CONFIG_OUT}; \ + $${JSONAPI_GENERATOR_EXE} $${JSONAPI_GENERATOR_SRC} $${JSONAPI_GENERATOR_OUT}; + QMAKE_EXTRA_TARGETS += jsonwrappersincl + libretroshare.depends += jsonwrappersincl + PRE_TARGETDEPS *= $${WRAPPERS_INCL_FILE} + + jsonwrappersreg.target = $${WRAPPERS_REG_FILE} + jsonwrappersreg.commands = touch $${WRAPPERS_REG_FILE} + jsonwrappersreg.depends = jsonwrappersincl + QMAKE_EXTRA_TARGETS += jsonwrappersreg + libretroshare.depends += jsonwrappersreg + PRE_TARGETDEPS *= $${WRAPPERS_REG_FILE} + + # Force recalculation of libretroshare dependencies see https://stackoverflow.com/a/47884045 + QMAKE_EXTRA_TARGETS += libretroshare + + HEADERS += jsonapi/jsonapi.h + SOURCES += jsonapi/jsonapi.cpp +} + +rs_deep_search { + HEADERS += deep_search/deep_search.h +} ########################################################################################################### # OLD CONFIG OPTIONS. diff --git a/libretroshare/src/pgp/pgpauxutils.cc b/libretroshare/src/pgp/pgpauxutils.cc index 6cd4ebf08..a6a592c2c 100644 --- a/libretroshare/src/pgp/pgpauxutils.cc +++ b/libretroshare/src/pgp/pgpauxutils.cc @@ -1,28 +1,24 @@ -/* - * libretroshare/src/pgp: pgpauxutils.cc - * - * PGP interface for RetroShare. - * - * Copyright 2014-2014 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/pgp: pgpauxutils.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2014 Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "pgp/pgpauxutils.h" #include "pqi/authgpg.h" diff --git a/libretroshare/src/pgp/pgpauxutils.h b/libretroshare/src/pgp/pgpauxutils.h index 2ead59db8..6ead67a2d 100644 --- a/libretroshare/src/pgp/pgpauxutils.h +++ b/libretroshare/src/pgp/pgpauxutils.h @@ -1,28 +1,24 @@ -/* - * libretroshare/src/pgp: pgpauxutils.h - * - * PGP interface for RetroShare. - * - * Copyright 2014-2014 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/pgp: pgpauxutils.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2014 Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once #include "retroshare/rsids.h" diff --git a/libretroshare/src/pgp/pgphandler.cc b/libretroshare/src/pgp/pgphandler.cc index df95fc7f9..f5ca9fa1e 100644 --- a/libretroshare/src/pgp/pgphandler.cc +++ b/libretroshare/src/pgp/pgphandler.cc @@ -1,3 +1,24 @@ +/******************************************************************************* + * libretroshare/src/pgp: pgphandler.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2018 Cyril Soler * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include #include #include diff --git a/libretroshare/src/pgp/pgphandler.h b/libretroshare/src/pgp/pgphandler.h index 8b3d9a4fe..9fe4abfbb 100644 --- a/libretroshare/src/pgp/pgphandler.h +++ b/libretroshare/src/pgp/pgphandler.h @@ -1,3 +1,26 @@ +/******************************************************************************* + * libretroshare/src/pgp: pgphandler.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2018 Cyril Soler * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ +#pragma once + #pragma once // This class implements an abstract pgp handler to be used in RetroShare. diff --git a/libretroshare/src/pgp/pgpkeyutil.cc b/libretroshare/src/pgp/pgpkeyutil.cc index ebd2ccf5b..76b332edf 100644 --- a/libretroshare/src/pgp/pgpkeyutil.cc +++ b/libretroshare/src/pgp/pgpkeyutil.cc @@ -1,3 +1,24 @@ +/******************************************************************************* + * libretroshare/src/pgp: pgpkeyutil.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2018 Cyril Soler * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include #include #include "pgpkeyutil.h" diff --git a/libretroshare/src/pgp/pgpkeyutil.h b/libretroshare/src/pgp/pgpkeyutil.h index 672550b1b..38a02dedf 100644 --- a/libretroshare/src/pgp/pgpkeyutil.h +++ b/libretroshare/src/pgp/pgpkeyutil.h @@ -1,24 +1,24 @@ -/**************************************************************** - * RetroShare is distributed under the following license: - * - * Copyright (C) 2012 Cyril Soler - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * 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 General Public License for more details. - * - * 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, - * Boston, MA 02110-1301, USA. - ****************************************************************/ - +/******************************************************************************* + * libretroshare/src/pgp: pgpkeyutil.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012 Cyril Soler * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once // refer to RFC4880 specif document for loading GPG public keys: diff --git a/libretroshare/src/pgp/rscertificate.cc b/libretroshare/src/pgp/rscertificate.cc index 08ea78a31..76e2005b8 100644 --- a/libretroshare/src/pgp/rscertificate.cc +++ b/libretroshare/src/pgp/rscertificate.cc @@ -1,23 +1,25 @@ -/* - * RetroShare - * - * Copyright (C) 2012-2014 Cyril Soler - * Copyright (C) 2018 Gioacchino Mazzurco - * - * 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 . - */ - +/******************************************************************************* + * libretroshare/src/pgp: rscertificate.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2016 Cyril Soler * + * Copyright 2018 Gioacchino Mazzurco * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include #include #include diff --git a/libretroshare/src/pgp/rscertificate.h b/libretroshare/src/pgp/rscertificate.h index 131652d0a..b0fd70801 100644 --- a/libretroshare/src/pgp/rscertificate.h +++ b/libretroshare/src/pgp/rscertificate.h @@ -1,3 +1,26 @@ +/******************************************************************************* + * libretroshare/src/pgp: rscertificate.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2016 Cyril Soler * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ +#pragma once + #pragma once /* * RetroShare diff --git a/libretroshare/src/plugins/dlfcn_win32.cc b/libretroshare/src/plugins/dlfcn_win32.cc index 1a6b107b5..b669cfa54 100644 --- a/libretroshare/src/plugins/dlfcn_win32.cc +++ b/libretroshare/src/plugins/dlfcn_win32.cc @@ -1,21 +1,24 @@ -/* - * dlfcn-win32 - * Copyright (c) 2007 Ramiro Polla - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ +/******************************************************************************* + * libretroshare/src/plugins: dlfcn_win32.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2007 Ramiro Polla * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifdef WINDOWS_SYS diff --git a/libretroshare/src/plugins/dlfcn_win32.h b/libretroshare/src/plugins/dlfcn_win32.h index af33af443..3298777dd 100644 --- a/libretroshare/src/plugins/dlfcn_win32.h +++ b/libretroshare/src/plugins/dlfcn_win32.h @@ -1,21 +1,25 @@ -/* - * dlfcn-win32 - * Copyright (c) 2007 Ramiro Polla - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ +/******************************************************************************* + * libretroshare/src/plugins: dlfcn_win32.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2007 Ramiro Polla * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ +#pragma once #ifdef WINDOWS_SYS #ifndef DLFCN_H diff --git a/libretroshare/src/plugins/pluginmanager.cc b/libretroshare/src/plugins/pluginmanager.cc index 61757f31d..ea3a72932 100644 --- a/libretroshare/src/plugins/pluginmanager.cc +++ b/libretroshare/src/plugins/pluginmanager.cc @@ -1,3 +1,24 @@ +/******************************************************************************* + * libretroshare/src/plugins: pluginmanager.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012 Cyril Soler * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include #include "pluginmanager.h" diff --git a/libretroshare/src/plugins/pluginmanager.h b/libretroshare/src/plugins/pluginmanager.h index 09f05563b..021a80463 100644 --- a/libretroshare/src/plugins/pluginmanager.h +++ b/libretroshare/src/plugins/pluginmanager.h @@ -1,3 +1,24 @@ +/******************************************************************************* + * libretroshare/src/plugins: pluginmanager.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012 Cyril Soler * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once #include diff --git a/libretroshare/src/pqi/authgpg.cc b/libretroshare/src/pqi/authgpg.cc index ccfb8a260..318397b2c 100644 --- a/libretroshare/src/pqi/authgpg.cc +++ b/libretroshare/src/pqi/authgpg.cc @@ -1,29 +1,24 @@ -/* - * libretroshare/src AuthGPG.cc - * - * GnuPG/GPGme interface for RetroShare. - * - * Copyright 2008-2009 by Robert Fernie, Retroshare Team. - * - * This library is free software; you can redistribute it and/or - * modify it under the termsf the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - * - */ - +/******************************************************************************* + * libretroshare/src/pqi: authgpg.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2008-2009 by Robert Fernie, Retroshare Team. * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "authgpg.h" #include "retroshare/rsiface.h" // For rsicontrol. #include "retroshare/rspeers.h" // For RsPeerDetails. @@ -100,7 +95,11 @@ std::string pgp_pwd_callback(void * /*hook*/, const char *uid_title, const char return password ; } -void AuthGPG::init(const std::string& path_to_public_keyring,const std::string& path_to_secret_keyring,const std::string& path_to_trustdb,const std::string& pgp_lock_file) +void AuthGPG::init( + const std::string& path_to_public_keyring, + const std::string& path_to_secret_keyring, + const std::string& path_to_trustdb, + const std::string& pgp_lock_file) { if(_instance != NULL) { @@ -108,8 +107,11 @@ void AuthGPG::init(const std::string& path_to_public_keyring,const std::string& std::cerr << "AuthGPG::init() called twice!" << std::endl ; } - PGPHandler::setPassphraseCallback(pgp_pwd_callback) ; - _instance = new AuthGPG(path_to_public_keyring,path_to_secret_keyring,path_to_trustdb,pgp_lock_file) ; +// if(cb) PGPHandler::setPassphraseCallback(cb);else + PGPHandler::setPassphraseCallback(pgp_pwd_callback); + _instance = new AuthGPG( path_to_public_keyring, + path_to_secret_keyring, + path_to_trustdb, pgp_lock_file ); } void AuthGPG::exit() diff --git a/libretroshare/src/pqi/authgpg.h b/libretroshare/src/pqi/authgpg.h index 4ad48c42b..bc01b1cd0 100644 --- a/libretroshare/src/pqi/authgpg.h +++ b/libretroshare/src/pqi/authgpg.h @@ -1,31 +1,24 @@ -/* - * libretroshare/src/ : gpgauthmgr.h - * - * GPG interface for RetroShare. - * - * Copyright 2008-2009 by Raghu Dev R. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - * This is *THE* auth manager. It provides the web-of-trust via - * gpgme, and authenticates the certificates that are managed - * by the sublayer AuthSSL. - * - */ +/******************************************************************************* + * libretroshare/src/pqi: authgpg.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2008-2009 by Raghu Dev R. * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ /**** * Here's GPG policy : @@ -89,8 +82,8 @@ public: class AuthGPGService { public: - AuthGPGService() {}; - ~AuthGPGService() {}; + AuthGPGService() {} + ~AuthGPGService() {} virtual AuthGPGOperation *getGPGOperation() = 0; virtual void setGPGOperation(AuthGPGOperation *operation) = 0; @@ -98,12 +91,11 @@ public: class AuthGPG: public p3Config, public RsTickingThread, public PGPHandler { - public: - - static void init( const std::string& path_to_pubring, - const std::string& path_to_secring, - const std::string& path_to_trustdb, - const std::string& pgp_lock_file); +public: + static void init(const std::string& path_to_pubring, + const std::string& path_to_secring, + const std::string& path_to_trustdb, + const std::string& pgp_lock_file); static void exit(); static AuthGPG *getAuthGPG() { return _instance ; } diff --git a/libretroshare/src/pqi/authssl.cc b/libretroshare/src/pqi/authssl.cc index 9956459d3..a885c3318 100644 --- a/libretroshare/src/pqi/authssl.cc +++ b/libretroshare/src/pqi/authssl.cc @@ -1,33 +1,24 @@ -/* - * libretroshare/src/pqi: authssl.cc - * - * 3P/PQI network interface for RetroShare. - * - * Copyright 2004-2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - * - * This class is designed to provide authentication using ssl certificates - * only. It is intended to be wrapped by an gpgauthmgr to provide - * pgp + ssl web-of-trust authentication. - * - */ - +/******************************************************************************* + * libretroshare/src/pqi: authssl.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2008 by Robert Fernie, Retroshare Team. * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifdef WINDOWS_SYS #include "util/rswin.h" #endif // WINDOWS_SYS diff --git a/libretroshare/src/pqi/authssl.h b/libretroshare/src/pqi/authssl.h index bdfd141c0..e6dd33078 100644 --- a/libretroshare/src/pqi/authssl.h +++ b/libretroshare/src/pqi/authssl.h @@ -1,28 +1,24 @@ -/* - * libretroshare/src/pqi: authssl.h - * - * 3P/PQI network interface for RetroShare. - * - * Copyright 2004-2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/pqi: authssl.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2008 by Robert Fernie, Retroshare Team. * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef MRK_AUTH_SSL_HEADER #define MRK_AUTH_SSL_HEADER diff --git a/libretroshare/src/pqi/p3cfgmgr.cc b/libretroshare/src/pqi/p3cfgmgr.cc index 3266f68d4..d41a47c80 100644 --- a/libretroshare/src/pqi/p3cfgmgr.cc +++ b/libretroshare/src/pqi/p3cfgmgr.cc @@ -1,35 +1,30 @@ -/* - * libretroshare/src/pqi: p3cfgmgr.cc - * - * 3P/PQI network interface for RetroShare. - * - * Copyright 2007-2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/pqi: p3cfgmgr.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2007-2008 by Robert Fernie, Retroshare Team. * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "util/rsdir.h" //#include "retroshare/rspeers.h" #include "pqi/p3cfgmgr.h" #include "pqi/authssl.h" #include "pqi/pqibin.h" #include "pqi/pqistore.h" -#include "pqi/pqiarchive.h" #include #include #include @@ -65,7 +60,7 @@ void p3ConfigMgr::tick() #ifdef CONFIG_DEBUG std::cerr << "p3ConfigMgr::tick() Config Changed - Element: "; - std::cerr << it->first; + std::cerr << *it; std::cerr << std::endl; #endif @@ -111,7 +106,7 @@ void p3ConfigMgr::saveConfig() { #ifdef CONFIG_DEBUG std::cerr << "p3ConfigMgr::globalSaveConfig() Saving Element: "; - std::cerr << it->first; + std::cerr << *it; std::cerr << std::endl; #endif ok &= (*it)->saveConfiguration(); @@ -137,7 +132,7 @@ void p3ConfigMgr::loadConfig() { #ifdef CONFIG_DEBUG std::cerr << "p3ConfigMgr::loadConfig() Element: "; - std::cerr << cit->first <<"Dummy Hash: " << dummyHash; + std::cerr << *cit <<" Dummy Hash: " << dummyHash; std::cerr << std::endl; #endif diff --git a/libretroshare/src/pqi/p3cfgmgr.h b/libretroshare/src/pqi/p3cfgmgr.h index 43e19b66e..b1e554c98 100644 --- a/libretroshare/src/pqi/p3cfgmgr.h +++ b/libretroshare/src/pqi/p3cfgmgr.h @@ -1,30 +1,24 @@ -/* - * libretroshare/src/pqi: p3cfgmgr.h - * - * 3P/PQI network interface for RetroShare. - * - * Copyright 2007-2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - - +/******************************************************************************* + * libretroshare/src/pqi: p3cfgmgr.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2008 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef P3_CONFIG_MGR_HEADER #define P3_CONFIG_MGR_HEADER diff --git a/libretroshare/src/pqi/p3historymgr.cc b/libretroshare/src/pqi/p3historymgr.cc index e1acb0888..00b36a505 100644 --- a/libretroshare/src/pqi/p3historymgr.cc +++ b/libretroshare/src/pqi/p3historymgr.cc @@ -1,28 +1,24 @@ -/* - * libretroshare/src/services: p3HistoryMgr.cc - * - * RetroShare C++ . - * - * Copyright 2011 by Thunder. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/pqi: p3historymgr.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2011 by Thunder. * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include #include "p3historymgr.h" diff --git a/libretroshare/src/pqi/p3historymgr.h b/libretroshare/src/pqi/p3historymgr.h index 3f3c9a6f1..897688fa8 100644 --- a/libretroshare/src/pqi/p3historymgr.h +++ b/libretroshare/src/pqi/p3historymgr.h @@ -1,31 +1,27 @@ +/******************************************************************************* + * libretroshare/src/pqi: p3historymgr.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2011 by Thunder. * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RS_P3_HISTORY_MGR_H #define RS_P3_HISTORY_MGR_H -/* - * libretroshare/src/services: p3historymgr.h - * - * RetroShare C++ - * - * Copyright 2011 by Thunder. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - #include #include diff --git a/libretroshare/src/pqi/p3linkmgr.cc b/libretroshare/src/pqi/p3linkmgr.cc index 302efd255..c380c205b 100644 --- a/libretroshare/src/pqi/p3linkmgr.cc +++ b/libretroshare/src/pqi/p3linkmgr.cc @@ -1,29 +1,25 @@ -/* - * libretroshare/src/pqi: p3linkmgr.cc - * - * 3P/PQI network interface for RetroShare. - * - * Copyright (C) 2007-2011 Robert Fernie. - * Copyright (C) 2015-2018 Gioacchino Mazzurco - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/pqi: p3linkmgr.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2007-2011 by Robert Fernie. * + * Copyright (C) 2015-2018 Gioacchino Mazzurco * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "pqi/p3linkmgr.h" #include "pqi/p3peermgr.h" diff --git a/libretroshare/src/pqi/p3linkmgr.h b/libretroshare/src/pqi/p3linkmgr.h index 1fee7d6f2..57638c174 100644 --- a/libretroshare/src/pqi/p3linkmgr.h +++ b/libretroshare/src/pqi/p3linkmgr.h @@ -1,28 +1,24 @@ -/* - * libretroshare/src/pqi: p3linkmgr.h - * - * 3P/PQI network interface for RetroShare. - * - * Copyright 2007-2011 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/pqi: p3linkmgr.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2007-2011 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef MRK_PQI_LINK_MANAGER_HEADER #define MRK_PQI_LINK_MANAGER_HEADER diff --git a/libretroshare/src/pqi/p3netmgr.cc b/libretroshare/src/pqi/p3netmgr.cc index 9ce48ed6b..162370977 100644 --- a/libretroshare/src/pqi/p3netmgr.cc +++ b/libretroshare/src/pqi/p3netmgr.cc @@ -1,29 +1,25 @@ -/* - * libretroshare/src/pqi: p3netmgr.cc - * - * 3P/PQI network interface for RetroShare. - * - * Copyright (C) 2007-2011 Robert Fernie - * Copyright (C) 2015-2018 Gioacchino Mazzurco - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/pqi: p3netmgr.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2007-2011 by Robert Fernie. * + * Copyright (C) 2015-2018 Gioacchino Mazzurco * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include #include diff --git a/libretroshare/src/pqi/p3netmgr.h b/libretroshare/src/pqi/p3netmgr.h index 1b379afec..56e9b1778 100644 --- a/libretroshare/src/pqi/p3netmgr.h +++ b/libretroshare/src/pqi/p3netmgr.h @@ -1,28 +1,24 @@ -/* - * libretroshare/src/pqi: p3netmgr.h - * - * 3P/PQI network interface for RetroShare. - * - * Copyright 2007-2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/pqi: p3netmgr.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2007-2008 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef MRK_PQI_NET_MANAGER_HEADER #define MRK_PQI_NET_MANAGER_HEADER diff --git a/libretroshare/src/pqi/p3notify.cc b/libretroshare/src/pqi/p3notify.cc index 43caf9758..2ffd3c5cd 100644 --- a/libretroshare/src/pqi/p3notify.cc +++ b/libretroshare/src/pqi/p3notify.cc @@ -1,29 +1,24 @@ -/* - * libretroshare/src/rsserver: p3notify.cc - * - * RetroShare C++ Interface. - * - * Copyright 2007-2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - +/******************************************************************************* + * libretroshare/src/pqi: p3notify.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright (C) 2007-2008 Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "pqi/p3notify.h" #include #include @@ -230,8 +225,10 @@ void p3Notify::notifyChatCleared (const ChatId& chat_id) void p3Notify::notifyChatLobbyTimeShift (int time_shift) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyChatLobbyTimeShift(time_shift) ; } void p3Notify::notifyCustomState (const std::string& peer_id , const std::string& status_string ) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyCustomState (peer_id,status_string) ; } void p3Notify::notifyHashingInfo (uint32_t type , const std::string& fileinfo ) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyHashingInfo (type,fileinfo) ; } -void p3Notify::notifyTurtleSearchResult (uint32_t search_id , const std::list& files ) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyTurtleSearchResult(search_id,files) ; } -void p3Notify::notifyPeerHasNewAvatar (std::string peer_id ) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyPeerHasNewAvatar(peer_id) ; } +void p3Notify::notifyTurtleSearchResult (const RsPeerId& pid , uint32_t search_id , const std::list& files ) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyTurtleSearchResult(pid,search_id,files) ; } +#warning MISSING CODE HERE +//void p3Notify::notifyTurtleSearchResult (uint32_t search_id , const std::list& groups ) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyTurtleSearchResult(search_id,groups) ; } +void p3Notify::notifyPeerHasNewAvatar (std::string peer_id ) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyPeerHasNewAvatar(peer_id) ; } void p3Notify::notifyOwnAvatarChanged () { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyOwnAvatarChanged() ; } void p3Notify::notifyOwnStatusMessageChanged() { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyOwnStatusMessageChanged() ; } void p3Notify::notifyDiskFull (uint32_t location , uint32_t size_limit_in_MB ) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyDiskFull (location,size_limit_in_MB) ; } diff --git a/libretroshare/src/pqi/p3notify.h b/libretroshare/src/pqi/p3notify.h index 820c4a6bb..d288091c3 100644 --- a/libretroshare/src/pqi/p3notify.h +++ b/libretroshare/src/pqi/p3notify.h @@ -1,31 +1,27 @@ +/******************************************************************************* + * libretroshare/src/pqi: p3notify.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2007-2008 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RS_P3_NOTIFY_INTERFACE_H #define RS_P3_NOTIFY_INTERFACE_H -/* - * libretroshare/src/rsserver: p3notify.h - * - * RetroShare C++ Interface. - * - * Copyright 2007-2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - #include "retroshare/rsnotify.h" #include "retroshare/rsturtle.h" @@ -105,7 +101,9 @@ class p3Notify: public RsNotify void notifyChatLobbyTimeShift (int /* time_shift*/) ; void notifyCustomState (const std::string& /* peer_id */, const std::string& /* status_string */) ; void notifyHashingInfo (uint32_t /* type */, const std::string& /* fileinfo */) ; - void notifyTurtleSearchResult (uint32_t /* search_id */, const std::list& /* files */) ; + void notifyTurtleSearchResult (const RsPeerId &pid, uint32_t /* search_id */, const std::list& /* files */) ; +#warning MISSING CODE HERE +// void notifyTurtleSearchResult (uint32_t /* search_id */, const std::list& /* groups */) ; void notifyPeerHasNewAvatar (std::string /* peer_id */) ; void notifyOwnAvatarChanged () ; void notifyOwnStatusMessageChanged () ; diff --git a/libretroshare/src/pqi/p3peermgr.cc b/libretroshare/src/pqi/p3peermgr.cc index fb17dddb6..305bf528c 100644 --- a/libretroshare/src/pqi/p3peermgr.cc +++ b/libretroshare/src/pqi/p3peermgr.cc @@ -1,29 +1,25 @@ -/* - * libretroshare/src/pqi: p3peermgr.cc - * - * 3P/PQI network interface for RetroShare. - * - * Copyright 2007-2011 by Robert Fernie. - * Copyright (C) 2015-2018 Gioacchino Mazzurco - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/pqi: p3peermgr.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright (C) 2007-2011 Robert Fernie * + * Copyright (C) 2015-2018 Gioacchino Mazzurco * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include // for std::vector #include // for std::random_shuffle @@ -89,11 +85,11 @@ static const std::string kConfigKeyProxyServerIpAddrTor = "PROXY_SERVER_IPADDR"; static const std::string kConfigKeyProxyServerPortTor = "PROXY_SERVER_PORT"; static const std::string kConfigKeyProxyServerIpAddrI2P = "PROXY_SERVER_IPADDR_I2P"; static const std::string kConfigKeyProxyServerPortI2P = "PROXY_SERVER_PORT_I2P"; - + void printConnectState(std::ostream &out, peerState &peer); peerState::peerState() - :netMode(RS_NET_MODE_UNKNOWN), vs_disc(RS_VS_DISC_FULL), vs_dht(RS_VS_DHT_FULL), lastcontact(0), + :netMode(RS_NET_MODE_UNKNOWN), vs_disc(RS_VS_DISC_FULL), vs_dht(RS_VS_DHT_FULL), lastcontact(0), hiddenNode(false), hiddenPort(0), hiddenType(RS_HIDDEN_TYPE_NONE) { sockaddr_storage_clear(localaddr); @@ -107,13 +103,13 @@ std::string textPeerConnectState(peerState &state) std::string out = "Id: " + state.id.toStdString() + "\n"; rs_sprintf_append(out, "NetMode: %lu\n", state.netMode); rs_sprintf_append(out, "VisState: Disc: %u Dht: %u\n", state.vs_disc, state.vs_dht); - + out += "laddr: "; out += sockaddr_storage_tostring(state.localaddr); out += "\neaddr: "; out += sockaddr_storage_tostring(state.serveraddr); out += "\n"; - + return out; } @@ -136,7 +132,7 @@ p3PeerMgrIMPL::p3PeerMgrIMPL(const RsPeerId& ssl_own_id, const RsPgpId& gpg_own_ mOwnState.netMode = RS_NET_MODE_UPNP; // Default to UPNP. mOwnState.vs_disc = RS_VS_DISC_FULL; mOwnState.vs_dht = RS_VS_DHT_FULL; - + // setup default ProxyServerAddress. // Tor sockaddr_storage_clear(mProxyServerAddressTor); @@ -154,7 +150,7 @@ p3PeerMgrIMPL::p3PeerMgrIMPL(const RsPeerId& ssl_own_id, const RsPgpId& gpg_own_ mProxyServerStatusTor = RS_NET_PROXY_STATUS_UNKNOWN ; mProxyServerStatusI2P = RS_NET_PROXY_STATUS_UNKNOWN; } - + #ifdef PEER_DEBUG std::cerr << "p3PeerMgr() Startup" << std::endl; #endif @@ -222,8 +218,8 @@ bool p3PeerMgrIMPL::forceHiddenNode() struct sockaddr_storage loopback; sockaddr_storage_clear(loopback); sockaddr_storage_ipv4_aton(loopback, "127.0.0.1"); - uint16_t port = sockaddr_storage_port(mOwnState.localaddr); - sockaddr_storage_ipv4_setport(loopback, port); + uint16_t port = sockaddr_storage_port(mOwnState.localaddr); + sockaddr_storage_ipv4_setport(loopback, port); setLocalAddress(AuthSSL::getAuthSSL()->OwnId(), loopback); @@ -254,7 +250,7 @@ bool p3PeerMgrIMPL::setOwnNetworkMode(uint32_t netMode) changed = true; } } - + // Pass on Flags to NetMgr. mNetMgr->setNetworkMode((netMode & RS_NET_MODE_ACTUAL)); return changed; @@ -267,7 +263,7 @@ bool p3PeerMgrIMPL::setOwnVisState(uint16_t vs_disc, uint16_t vs_dht) RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/ std::string out; - rs_sprintf(out, "p3PeerMgr::setOwnVisState() Existing vis: %u/%u Input vis: %u/%u", + rs_sprintf(out, "p3PeerMgr::setOwnVisState() Existing vis: %u/%u Input vis: %u/%u", mOwnState.vs_disc, mOwnState.vs_dht, vs_disc, vs_dht); rslog(RSL_WARNING, p3peermgrzone, out); @@ -275,7 +271,7 @@ bool p3PeerMgrIMPL::setOwnVisState(uint16_t vs_disc, uint16_t vs_dht) std::cerr << out.c_str() << std::endl; #endif - if (mOwnState.vs_disc != vs_disc || mOwnState.vs_dht != vs_dht) + if (mOwnState.vs_disc != vs_disc || mOwnState.vs_dht != vs_dht) { mOwnState.vs_disc = vs_disc; mOwnState.vs_dht = vs_dht; @@ -283,7 +279,7 @@ bool p3PeerMgrIMPL::setOwnVisState(uint16_t vs_disc, uint16_t vs_dht) IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/ } } - + // Pass on Flags to NetMgr. mNetMgr->setVisState(vs_disc, vs_dht); @@ -575,7 +571,7 @@ bool p3PeerMgrIMPL::setHiddenDomainPort(const RsPeerId &ssl_id, const std::strin IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/ - if (ssl_id == AuthSSL::getAuthSSL()->OwnId()) + if (ssl_id == AuthSSL::getAuthSSL()->OwnId()) { mOwnState.hiddenNode = true; mOwnState.hiddenDomain = domain; @@ -917,7 +913,7 @@ bool p3PeerMgrIMPL::addFriend(const RsPeerId& input_id, const RsPgpId& input_gpg RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/ - if (id == AuthSSL::getAuthSSL()->OwnId()) + if (id == AuthSSL::getAuthSSL()->OwnId()) { #ifdef PEER_DEBUG std::cerr << "p3PeerMgrIMPL::addFriend() cannot add own id as a friend." << std::endl; @@ -973,7 +969,7 @@ bool p3PeerMgrIMPL::addFriend(const RsPeerId& input_id, const RsPgpId& input_gpg /* setup connectivity parameters */ it->second.vs_disc = vs_disc; it->second.vs_dht = vs_dht; - + it->second.netMode = netMode; it->second.lastcontact = lastContact; @@ -995,7 +991,7 @@ bool p3PeerMgrIMPL::addFriend(const RsPeerId& input_id, const RsPgpId& input_gpg pstate.id = id; pstate.gpg_id = gpg_id; pstate.name = AuthGPG::getAuthGPG()->getGPGName(gpg_id); - + pstate.vs_disc = vs_disc; pstate.vs_dht = vs_dht; pstate.netMode = netMode; @@ -1018,7 +1014,7 @@ bool p3PeerMgrIMPL::addFriend(const RsPeerId& input_id, const RsPgpId& input_gpg mLinkMgr->addFriend(id, vs_dht != RS_VS_DHT_OFF); } - service_flags &= servicePermissionFlags(gpg_id) ; // Always reduce the permissions. + service_flags &= servicePermissionFlags(gpg_id) ; // Always reduce the permissions. #ifdef RS_CHATSERVER //Defined by chatserver setServicePermissionFlags(gpg_id,RS_NODE_PERM_NONE) ; #else @@ -1029,7 +1025,7 @@ bool p3PeerMgrIMPL::addFriend(const RsPeerId& input_id, const RsPgpId& input_gpg printPeerLists(std::cerr); mLinkMgr->printPeerLists(std::cerr); #endif - + return true; } @@ -1071,10 +1067,10 @@ bool p3PeerMgrIMPL::removeFriend(const RsPgpId &id) } for(std::list::iterator rit = sslid_toRemove.begin(); rit != sslid_toRemove.end(); ++rit) - if (mFriendList.end() != (it = mFriendList.find(*rit))) + if (mFriendList.end() != (it = mFriendList.find(*rit))) mFriendList.erase(it); - std::map::iterator it2 = mFriendsPermissionFlags.find(id) ; + std::map::iterator it2 = mFriendsPermissionFlags.find(id) ; if(it2 != mFriendsPermissionFlags.end()) mFriendsPermissionFlags.erase(it2); @@ -1146,13 +1142,13 @@ bool p3PeerMgrIMPL::removeFriend(const RsPeerId &id, bool removePgpId) } for(std::list::iterator rit = sslid_toRemove.begin(); rit != sslid_toRemove.end(); ++rit) - if (mFriendList.end() != (it = mFriendList.find(*rit))) + if (mFriendList.end() != (it = mFriendList.find(*rit))) mFriendList.erase(it); std::map::iterator it2 ; for(std::list::iterator rit = pgpid_toRemove.begin(); rit != pgpid_toRemove.end(); ++rit) - if (mFriendsPermissionFlags.end() != (it2 = mFriendsPermissionFlags.find(*rit))) + if (mFriendsPermissionFlags.end() != (it2 = mFriendsPermissionFlags.find(*rit))) mFriendsPermissionFlags.erase(it2); #ifdef PEER_DEBUG @@ -1432,7 +1428,7 @@ bool p3PeerMgrIMPL::setLocalAddress( const RsPeerId &id, if (changed) { IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/ - + mNetMgr->setLocalAddress(addr); mLinkMgr->setLocalAddress(addr); } @@ -1499,9 +1495,9 @@ bool p3PeerMgrIMPL::setExtAddress( const RsPeerId &id, changed = true; } } - + mNetMgr->setExtAddress(addr); - + return changed; } @@ -1584,12 +1580,16 @@ bool p3PeerMgrIMPL::setDynDNS(const RsPeerId &id, const std::string &dyndns) return changed; } +namespace pqi { + struct ZeroedInt { ZeroedInt() { n=0 ;} int n ; }; +} + bool p3PeerMgrIMPL::addCandidateForOwnExternalAddress(const RsPeerId &from, const sockaddr_storage &addr) { // The algorithm is the following: @@ -1617,10 +1617,10 @@ bool p3PeerMgrIMPL::addCandidateForOwnExternalAddress(const RsPeerId &from, cons // Update a list of own IPs: // - remove old values for that same peer // - remove values for non connected peers - + { RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/ - + mReportedOwnAddresses[from] = addr_filtered ; for(std::map::iterator it(mReportedOwnAddresses.begin());it!=mReportedOwnAddresses.end();) @@ -1641,8 +1641,8 @@ bool p3PeerMgrIMPL::addCandidateForOwnExternalAddress(const RsPeerId &from, cons std::cerr << "p3PeerMgr:: Current external address is calculated to be: " << sockaddr_storage_iptostring(current_best_ext_address_guess) << " (simultaneously reported by " << count << " peers)." << std::endl; } - - // now current + + // now current sockaddr_storage own_addr ; @@ -1665,7 +1665,7 @@ bool p3PeerMgrIMPL::addCandidateForOwnExternalAddress(const RsPeerId &from, cons RsServer::notify()->AddFeedItem(RS_FEED_ITEM_SEC_IP_WRONG_EXTERNAL_IP_REPORTED, from.toStdString(), sockaddr_storage_iptostring(own_addr), sockaddr_storage_iptostring(addr)); } - + // we could also sweep over all connected friends and see if some report a different address. return true ; @@ -1673,46 +1673,46 @@ bool p3PeerMgrIMPL::addCandidateForOwnExternalAddress(const RsPeerId &from, cons bool p3PeerMgrIMPL::locked_computeCurrentBestOwnExtAddressCandidate(sockaddr_storage& addr, uint32_t& count) { - std::map addr_counts ; - + std::map addr_counts ; + for(std::map::iterator it(mReportedOwnAddresses.begin());it!=mReportedOwnAddresses.end();++it) ++addr_counts[it->second].n ; #ifdef PEER_DEBUG std::cerr << "Current ext addr statistics:" << std::endl; #endif - + count = 0 ; - - for(std::map::const_iterator it(addr_counts.begin());it!=addr_counts.end();++it) + + for(std::map::const_iterator it(addr_counts.begin());it!=addr_counts.end();++it) { if(uint32_t(it->second.n) > count) { addr = it->first ; count = it->second.n ; } - + #ifdef PEER_DEBUG std::cerr << sockaddr_storage_iptostring(it->first) << " : " << it->second.n << std::endl; #endif } - + return true ; } - + bool p3PeerMgrIMPL::getExtAddressReportedByFriends(sockaddr_storage &addr, uint8_t& /*isstable*/) { RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/ - + uint32_t count ; - + locked_computeCurrentBestOwnExtAddressCandidate(addr,count) ; - + #ifdef PEER_DEBUG std::cerr << "Estimation count = " << count << ". Trusted? = " << (count>=2) << std::endl; #endif - - return count >= 2 ;// 2 is not conservative enough. 3 should be probably better. + + return count >= 2 ;// 2 is not conservative enough. 3 should be probably better. } static bool cleanIpList(std::list& lst,const RsPeerId& pid,p3LinkMgr *link_mgr) @@ -1765,7 +1765,7 @@ bool p3PeerMgrIMPL::updateAddressList(const RsPeerId& id, const pqiIpAddrSet RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/ /* check if it is our own ip */ - if (id == getOwnId()) + if (id == getOwnId()) { mOwnState.ipAddrs.updateAddrs(clean_set); return true; @@ -1811,11 +1811,11 @@ bool p3PeerMgrIMPL::updateCurrentAddress(const RsPeerId& id, const pqiIpAddre #ifdef PEER_DEBUG std::cerr << "p3PeerMgrIMPL::updateCurrentAddress() called for id : " << id << std::endl; #endif - + RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/ - + /* cannot be own id */ - + /* check if it is a friend */ std::map::iterator it; if (mFriendList.end() == (it = mFriendList.find(id))) @@ -1846,23 +1846,23 @@ bool p3PeerMgrIMPL::updateCurrentAddress(const RsPeerId& id, const pqiIpAddre std::cerr << addrstr; std::cerr << std::endl; #endif - + IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/ - + return true; } - + bool p3PeerMgrIMPL::updateLastContact(const RsPeerId& id) { #ifdef PEER_DEBUG std::cerr << "p3PeerMgrIMPL::updateLastContact() called for id : " << id << std::endl; #endif - + RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/ - + /* cannot be own id */ - + /* check if it is a friend */ std::map::iterator it; if (mFriendList.end() == (it = mFriendList.find(id))) @@ -1877,7 +1877,7 @@ bool p3PeerMgrIMPL::updateLastContact(const RsPeerId& id) it->second.lastcontact = time(NULL); IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/ - + return true; } @@ -2061,7 +2061,7 @@ bool p3PeerMgrIMPL::saveList(bool &cleanup, std::list& saveData) getProxyServerAddress(RS_HIDDEN_TYPE_TOR, proxy_addr_tor); getProxyServerAddress(RS_HIDDEN_TYPE_I2P, proxy_addr_i2p); - mPeerMtx.lock(); /****** MUTEX LOCKED *******/ + mPeerMtx.lock(); /****** MUTEX LOCKED *******/ RsPeerNetItem *item = new RsPeerNetItem(); item->clear(); @@ -2088,14 +2088,14 @@ bool p3PeerMgrIMPL::saveList(bool &cleanup, std::list& saveData) item->vs_disc = mOwnState.vs_disc; item->vs_dht = mOwnState.vs_dht; - + item->lastContact = mOwnState.lastcontact; item->localAddrV4.addr = mOwnState.localaddr; item->extAddrV4.addr = mOwnState.serveraddr; sockaddr_storage_clear(item->localAddrV6.addr); sockaddr_storage_clear(item->extAddrV6.addr); - + item->dyndns = mOwnState.dyndns; mOwnState.ipAddrs.mLocal.loadTlv(item->localAddrList); mOwnState.ipAddrs.mExt.loadTlv(item->extAddrList); @@ -2125,20 +2125,20 @@ bool p3PeerMgrIMPL::saveList(bool &cleanup, std::list& saveData) item->vs_dht = (it->second).vs_dht; item->lastContact = (it->second).lastcontact; - + item->localAddrV4.addr = (it->second).localaddr; item->extAddrV4.addr = (it->second).serveraddr; sockaddr_storage_clear(item->localAddrV6.addr); sockaddr_storage_clear(item->extAddrV6.addr); - - + + item->dyndns = (it->second).dyndns; (it->second).ipAddrs.mLocal.loadTlv(item->localAddrList); (it->second).ipAddrs.mExt.loadTlv(item->extAddrList); item->domain_addr = (it->second).hiddenDomain; item->domain_port = (it->second).hiddenPort; - + saveData.push_back(item); #ifdef PEER_DEBUG std::cerr << "p3PeerMgrIMPL::saveList() Peer Config Item:" << std::endl; @@ -2150,7 +2150,7 @@ bool p3PeerMgrIMPL::saveList(bool &cleanup, std::list& saveData) RsPeerBandwidthLimitsItem *pblitem = new RsPeerBandwidthLimitsItem ; pblitem->peers = mPeerBandwidthLimits ; saveData.push_back(pblitem) ; - + RsPeerServicePermissionItem *sitem = new RsPeerServicePermissionItem ; for(std::map::const_iterator it(mFriendsPermissionFlags.begin());it!=mFriendsPermissionFlags.end();++it) @@ -2158,11 +2158,11 @@ bool p3PeerMgrIMPL::saveList(bool &cleanup, std::list& saveData) sitem->pgp_ids.push_back(it->first) ; sitem->service_flags.push_back(it->second) ; } - + saveData.push_back(sitem) ; // Now save config for network digging strategies - + RsConfigKeyValueSet *vitem = new RsConfigKeyValueSet ; RsTlvKeyValue kv; @@ -2199,7 +2199,7 @@ bool p3PeerMgrIMPL::saveList(bool &cleanup, std::list& saveData) kv.key = kConfigKeyProxyServerPortI2P; kv.value = sockaddr_storage_porttostring(proxy_addr_i2p); vitem->tlvkvs.pairs.push_back(kv) ; - + saveData.push_back(vitem); /* save groups */ @@ -2213,7 +2213,7 @@ bool p3PeerMgrIMPL::saveList(bool &cleanup, std::list& saveData) return true; } -bool p3PeerMgrIMPL::getMaxRates(const RsPeerId& pid,uint32_t& maxUp,uint32_t& maxDn) +bool p3PeerMgrIMPL::getMaxRates(const RsPeerId& pid,uint32_t& maxUp,uint32_t& maxDn) { RsPgpId pgp_id ; @@ -2235,7 +2235,7 @@ bool p3PeerMgrIMPL::getMaxRates(const RsPeerId& pid,uint32_t& maxUp,uint32_t& ma return getMaxRates(pgp_id,maxUp,maxDn) ; } -bool p3PeerMgrIMPL::getMaxRates(const RsPgpId& pid,uint32_t& maxUp,uint32_t& maxDn) +bool p3PeerMgrIMPL::getMaxRates(const RsPgpId& pid,uint32_t& maxUp,uint32_t& maxDn) { RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/ @@ -2254,25 +2254,25 @@ bool p3PeerMgrIMPL::getMaxRates(const RsPgpId& pid,uint32_t& maxUp,uint32_t& max return false ; } } -bool p3PeerMgrIMPL::setMaxRates(const RsPgpId& pid,uint32_t maxUp,uint32_t maxDn) +bool p3PeerMgrIMPL::setMaxRates(const RsPgpId& pid,uint32_t maxUp,uint32_t maxDn) { RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/ PeerBandwidthLimits& p(mPeerBandwidthLimits[pid]) ; - + if(maxUp == p.max_up_rate_kbs && maxDn == p.max_dl_rate_kbs) return true ; - + std::cerr << "Updating max rates for peer " << pid << " to " << maxUp << " kB/s (up), " << maxDn << " kB/s (dn)" << std::endl; - + p.max_up_rate_kbs = maxUp ; p.max_dl_rate_kbs = maxDn ; - + IndicateConfigChanged(); - + return true ; } - + void p3PeerMgrIMPL::saveDone() { /* clean up the save List */ @@ -2396,7 +2396,7 @@ bool p3PeerMgrIMPL::loadList(std::list& load) #ifdef PEER_DEBUG std::cerr << "setting use_extr_addr_finder to " << useExtAddrFinder << std::endl ; #endif - } + } // Tor else if (kit->key == kConfigKeyProxyServerIpAddrTor) { @@ -2859,13 +2859,13 @@ bool p3PeerMgrIMPL::removeAllFriendLocations(const RsPgpId &gpgid) { return false; } - + std::list::iterator it; for(it = sslIds.begin(); it != sslIds.end(); ++it) { removeFriend(*it, true); } - + return true; } @@ -2877,7 +2877,7 @@ bool p3PeerMgrIMPL::getAssociatedPeers(const RsPgpId &gpg_id, std::list::iterator it; for(it = mFriendList.begin(); it != mFriendList.end(); ++it) @@ -2890,10 +2890,10 @@ bool p3PeerMgrIMPL::getAssociatedPeers(const RsPgpId &gpg_id, std::listfirst << std::endl; #endif - + } } - + return (count > 0); } @@ -2930,10 +2930,10 @@ bool p3PeerMgrIMPL::removeBannedIps() return true ; } -// /* This only removes SSL certs, that are old... Can end up with no Certs per GPG Id +// /* This only removes SSL certs, that are old... Can end up with no Certs per GPG Id // * We are removing the concept of a "DummyId" - There is no need for it. // */ -// +// // bool isDummyFriend(RsPeerId id) // { // bool ret = (id.substr(0,5) == "dummy"); @@ -2974,7 +2974,7 @@ bool p3PeerMgrIMPL::removeUnusedLocations() { RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/ - + // First put a sensible number in all PGP ids for(std::list::const_iterator it = pgpList.begin(); it != pgpList.end(); ++it) @@ -2984,7 +2984,7 @@ bool p3PeerMgrIMPL::removeUnusedLocations() std::cerr << "p3PeerMgr::removeUnusedLocations()" << std::endl; #endif // Then compute the most recently used location for all PGP ids - + for( std::map::iterator it = mFriendList.begin(); it != mFriendList.end(); ++it) { time_t& bst(mostRecentTime[it->second.gpg_id]) ; @@ -3010,4 +3010,4 @@ bool p3PeerMgrIMPL::removeUnusedLocations() return true; } - + diff --git a/libretroshare/src/pqi/p3peermgr.h b/libretroshare/src/pqi/p3peermgr.h index 390030893..70d74f141 100644 --- a/libretroshare/src/pqi/p3peermgr.h +++ b/libretroshare/src/pqi/p3peermgr.h @@ -1,28 +1,24 @@ -/* - * libretroshare/src/pqi: p3peermgr.h - * - * 3P/PQI network interface for RetroShare. - * - * Copyright 2007-2011 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/pqi: p3peermgr.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2007-2011 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef MRK_PQI_PEER_MANAGER_HEADER #define MRK_PQI_PEER_MANAGER_HEADER diff --git a/libretroshare/src/pqi/p3servicecontrol.cc b/libretroshare/src/pqi/p3servicecontrol.cc index 251777e70..5207b9829 100644 --- a/libretroshare/src/pqi/p3servicecontrol.cc +++ b/libretroshare/src/pqi/p3servicecontrol.cc @@ -1,28 +1,24 @@ -/* - * libretroshare/src/pqi: p3servicecontrol.cc - * - * 3P/PQI network interface for RetroShare. - * - * Copyright 2014 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/pqi: p3servicecontrol.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright (C) 2014-2014 Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include #include "p3servicecontrol.h" @@ -1373,13 +1369,18 @@ RsServiceInfo::RsServiceInfo( const uint16_t min_version_major, const uint16_t min_version_minor) :mServiceName(service_name), - mServiceType((((uint32_t) RS_PKT_VERSION_SERVICE) << 24) + (((uint32_t) service_type) << 8)), + mServiceType(RsServiceInfoUIn16ToFullServiceId(service_type)), mVersionMajor(version_major), mVersionMinor(version_minor), mMinVersionMajor(min_version_major), mMinVersionMinor(min_version_minor) { - return; + return; +} + +unsigned int RsServiceInfo::RsServiceInfoUIn16ToFullServiceId(uint16_t serviceType) +{ + return (((uint32_t) RS_PKT_VERSION_SERVICE) << 24) + (((uint32_t) serviceType) << 8); } diff --git a/libretroshare/src/pqi/p3servicecontrol.h b/libretroshare/src/pqi/p3servicecontrol.h index e7f4e5959..6cabf1193 100644 --- a/libretroshare/src/pqi/p3servicecontrol.h +++ b/libretroshare/src/pqi/p3servicecontrol.h @@ -1,29 +1,24 @@ -/* - * libretroshare/src/pqi: p3servicecontrol.h - * - * 3P/PQI network interface for RetroShare. - * - * Copyright 2014 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - +/******************************************************************************* + * libretroshare/src/pqi: p3servicecontrol.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2014-2014 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef P3_SERVICE_CONTROL_HEADER #define P3_SERVICE_CONTROL_HEADER diff --git a/libretroshare/src/pqi/p3upnpmgr.h b/libretroshare/src/pqi/p3upnpmgr.h index 47b95d5cc..6f58aa8ae 100644 --- a/libretroshare/src/pqi/p3upnpmgr.h +++ b/libretroshare/src/pqi/p3upnpmgr.h @@ -1,29 +1,24 @@ -/* - * libretroshare/src/pqi: p3upnpmgr.h - * - * 3P/PQI network interface for RetroShare. - * - * Copyright 2004-2007 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - +/******************************************************************************* + * libretroshare/src/pqi: p3upnpmgr.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2007 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef MRK_P3_UPNP_MANAGER_H #define MRK_P3_UPNP_MANAGER_H diff --git a/libretroshare/src/pqi/pqi.h b/libretroshare/src/pqi/pqi.h index 07cf00f9d..1bf581ff1 100644 --- a/libretroshare/src/pqi/pqi.h +++ b/libretroshare/src/pqi/pqi.h @@ -1,29 +1,24 @@ -/* - * libretroshare/src/pqi pqi.h - * - * 3P/PQI network interface for RetroShare. - * - * Copyright 2004-2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - +/******************************************************************************* + * libretroshare/src/pqi: pqi.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2008 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef PQI_TOP_HEADER #define PQI_TOP_HEADER diff --git a/libretroshare/src/pqi/pqi_base.h b/libretroshare/src/pqi/pqi_base.h index a7d06c644..0741df1c5 100644 --- a/libretroshare/src/pqi/pqi_base.h +++ b/libretroshare/src/pqi/pqi_base.h @@ -1,30 +1,24 @@ -/* - * "$Id: pqi_base.h,v 1.18 2007-05-05 16:10:05 rmf24 Exp $" - * - * 3P/PQI network interface for RetroShare. - * - * Copyright 2004-2006 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - - +/******************************************************************************* + * libretroshare/src/pqi: pqi_base.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2006 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef PQI_BASE_ITEM_HEADER #define PQI_BASE_ITEM_HEADER diff --git a/libretroshare/src/pqi/pqiarchive.h b/libretroshare/src/pqi/pqiarchive.h deleted file mode 100644 index e80d634b0..000000000 --- a/libretroshare/src/pqi/pqiarchive.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * "$Id: pqiarchive.h,v 1.3 2007-02-18 21:46:49 rmf24 Exp $" - * - * 3P/PQI network interface for RetroShare. - * - * Copyright 2004-2006 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - -#ifdef SUSPENDED_UNUSED_CODE - -#ifndef MRK_PQI_ARCHIVE_STREAMER_HEADER -#define MRK_PQI_ARCHIVE_STREAMER_HEADER - -#include "pqi/pqi.h" - -#include - -/******************************************************************* - * pqiarchive provides an archive stream. - * This stores RsItem + Person Reference + Timestamp, - * - * and allows Objects to be replayed or restored, - * independently of the rest of the pqi system. - * - */ - -class pqiarchive: public PQInterface -{ -public: - pqiarchive(RsSerialiser *rss, BinInterface *bio_in, int bio_flagsin); -virtual ~pqiarchive(); - -// PQInterface -virtual int SendItem(RsItem *); -virtual RsItem *GetItem(); - -virtual int tick(); -virtual int status(); - -virtual void setRealTime(bool r) { realTime = r; } - -std::string gethash(); - - private: -int writePkt(RsItem *item); -int readPkt(RsItem **item_out, long *ts); - - // Serialiser - RsSerialiser *rsSerialiser; - // Binary Interface for IO, initialisated at startup. - BinInterface *bio; - unsigned int bio_flags; // only BIN_NO_CLOSE at the moment. - - // Temp Storage for transient data..... - RsItem *nextPkt; - long nextPktTS; /* timestamp associated with nextPkt */ - long firstPktTS; /* timestamp associated with first read Pkt */ - long initTS; /* clock timestamp at first read */ - - bool realTime; -}; - - -#endif //MRK_PQI_ARCHIVE_STREAMER_HEADER -#endif //SUSPENDED_UNUSED_CODE diff --git a/libretroshare/src/pqi/pqiassist.h b/libretroshare/src/pqi/pqiassist.h index 9f93b07df..1bc00fbe9 100644 --- a/libretroshare/src/pqi/pqiassist.h +++ b/libretroshare/src/pqi/pqiassist.h @@ -1,29 +1,24 @@ -/* - * libretroshare/src/pqi: pqiassist.h - * - * 3P/PQI network interface for RetroShare. - * - * Copyright 2004-2007 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - +/******************************************************************************* + * libretroshare/src/pqi: pqiassist.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2007 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef MRK_PQI_ASSIST_H #define MRK_PQI_ASSIST_H diff --git a/libretroshare/src/pqi/pqibin.cc b/libretroshare/src/pqi/pqibin.cc index 172a23b14..75e0b4b39 100644 --- a/libretroshare/src/pqi/pqibin.cc +++ b/libretroshare/src/pqi/pqibin.cc @@ -1,28 +1,24 @@ -/* - * "$Id: pqibin.cc,v 1.4 2007-02-18 21:46:49 rmf24 Exp $" - * - * 3P/PQI network interface for RetroShare. - * - * Copyright 2004-2006 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/pqi: pqibin.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright (C) 2004-2006 Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "pqi/pqibin.h" #include "pqi/authssl.h" #include "util/rsnet.h" diff --git a/libretroshare/src/pqi/pqibin.h b/libretroshare/src/pqi/pqibin.h index 706a0a04f..b8cbb1c58 100644 --- a/libretroshare/src/pqi/pqibin.h +++ b/libretroshare/src/pqi/pqibin.h @@ -1,30 +1,24 @@ -/* - * "$Id: pqibin.h,v 1.2 2007-02-18 21:46:49 rmf24 Exp $" - * - * 3P/PQI network interface for RetroShare. - * - * Copyright 2004-2006 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - - +/******************************************************************************* + * libretroshare/src/pqi: pqibin.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2006 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef PQI_BIN_INTERFACE_HEADER #define PQI_BIN_INTERFACE_HEADER diff --git a/libretroshare/src/pqi/pqihandler.cc b/libretroshare/src/pqi/pqihandler.cc index a589f7e26..cb7d9f4a2 100644 --- a/libretroshare/src/pqi/pqihandler.cc +++ b/libretroshare/src/pqi/pqihandler.cc @@ -1,28 +1,24 @@ -/* - * "$Id: pqihandler.cc,v 1.12 2007-03-31 09:41:32 rmf24 Exp $" - * - * 3P/PQI network interface for RetroShare. - * - * Copyright 2004-2006 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/pqi: pqihandler.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright (C) 2004-2006 Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "pqi/pqihandler.h" #include // for NULL diff --git a/libretroshare/src/pqi/pqihandler.h b/libretroshare/src/pqi/pqihandler.h index c285c4ef7..755b13cfd 100644 --- a/libretroshare/src/pqi/pqihandler.h +++ b/libretroshare/src/pqi/pqihandler.h @@ -1,28 +1,24 @@ -/* - * "$Id: pqihandler.h,v 1.10 2007-03-31 09:41:32 rmf24 Exp $" - * - * 3P/PQI network interface for RetroShare. - * - * Copyright 2004-2006 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/pqi: pqihandler.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2006 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef MRK_PQI_HANDLER_HEADER #define MRK_PQI_HANDLER_HEADER diff --git a/libretroshare/src/pqi/pqihash.h b/libretroshare/src/pqi/pqihash.h index 5c1ecd986..9a36cb89c 100644 --- a/libretroshare/src/pqi/pqihash.h +++ b/libretroshare/src/pqi/pqihash.h @@ -1,28 +1,24 @@ -/* - * libretroshare/src/pqi: pqihash.h - * - * 3P/PQI network interface for RetroShare. - * - * Copyright 2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/pqi: pqihash.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2008-2008 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef PQI_HASH_ #define PQI_HASH_ diff --git a/libretroshare/src/pqi/pqiindic.h b/libretroshare/src/pqi/pqiindic.h index 391f4791a..28f619b16 100644 --- a/libretroshare/src/pqi/pqiindic.h +++ b/libretroshare/src/pqi/pqiindic.h @@ -1,30 +1,24 @@ -/* - * "$Id: pqiindic.h,v 1.3 2007-02-18 21:46:49 rmf24 Exp $" - * - * 3P/PQI network interface for RetroShare. - * - * Copyright 2004-2006 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - - +/******************************************************************************* + * libretroshare/src/pqi: pqiindic.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2006 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef MRK_PQI_INDICATOR_HEADER #define MRK_PQI_INDICATOR_HEADER diff --git a/libretroshare/src/pqi/pqiipset.cc b/libretroshare/src/pqi/pqiipset.cc index 8fa686844..8d9017442 100644 --- a/libretroshare/src/pqi/pqiipset.cc +++ b/libretroshare/src/pqi/pqiipset.cc @@ -1,28 +1,24 @@ -/* - * libretroshare/src/pqi: pqiipset.cc - * - * 3P/PQI network interface for RetroShare. - * - * Copyright 2007-2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/pqi: pqiipset.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2007-2008 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include #include "pqi/pqiipset.h" #include "util/rsstring.h" diff --git a/libretroshare/src/pqi/pqiipset.h b/libretroshare/src/pqi/pqiipset.h index 6da862b08..ef2d8a09a 100644 --- a/libretroshare/src/pqi/pqiipset.h +++ b/libretroshare/src/pqi/pqiipset.h @@ -1,31 +1,27 @@ +/******************************************************************************* + * libretroshare/src/pqi: pqiipset.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2009-2010 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef PQI_IP_SET_H #define PQI_IP_SET_H -/* - * libretroshare/src/pqi: pqiipset.h - * - * 3P/PQI network interface for RetroShare. - * - * Copyright 2009-2010 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - #include "util/rsnet.h" #include "serialiser/rstlvaddrs.h" diff --git a/libretroshare/src/pqi/pqilistener.h b/libretroshare/src/pqi/pqilistener.h index 6d02db294..5f748dc8f 100644 --- a/libretroshare/src/pqi/pqilistener.h +++ b/libretroshare/src/pqi/pqilistener.h @@ -1,28 +1,24 @@ -/* - * libretroshare/src/pqi: pqilistener.h - * - * 3P/PQI network interface for RetroShare. - * - * Copyright 2004-2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/pqi: pqilistener.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2008 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef MRK_PQI_GENERIC_LISTEN_HEADER #define MRK_PQI_GENERIC_LISTEN_HEADER diff --git a/libretroshare/src/pqi/pqiloopback.cc b/libretroshare/src/pqi/pqiloopback.cc index 8a8ba342b..69e70488b 100644 --- a/libretroshare/src/pqi/pqiloopback.cc +++ b/libretroshare/src/pqi/pqiloopback.cc @@ -1,28 +1,24 @@ -/* - * libretroshare/src/pqi: pqiloopback.cc - * - * 3P/PQI network interface for RetroShare. - * - * Copyright 2004-2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/pqi: pqiloopback.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2008 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "pqi/pqiloopback.h" #include // for NULL diff --git a/libretroshare/src/pqi/pqiloopback.h b/libretroshare/src/pqi/pqiloopback.h index 82c3923d8..f8d40e667 100644 --- a/libretroshare/src/pqi/pqiloopback.h +++ b/libretroshare/src/pqi/pqiloopback.h @@ -1,28 +1,24 @@ -/* - * libretroshare/src/pqi: pqiloopback.h - * - * 3P/PQI network interface for RetroShare. - * - * Copyright 2004-2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/pqi: pqiloopback.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2008 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef MRK_PQI_LOOPBACK_HEADER #define MRK_PQI_LOOPBACK_HEADER diff --git a/libretroshare/src/pqi/pqimonitor.cc b/libretroshare/src/pqi/pqimonitor.cc index fac7a50f9..550cd7b5a 100644 --- a/libretroshare/src/pqi/pqimonitor.cc +++ b/libretroshare/src/pqi/pqimonitor.cc @@ -1,28 +1,24 @@ -/* - * libretroshare/src/pqi: pqimonitor.cc - * - * 3P/PQI network interface for RetroShare. - * - * Copyright 2007-2008 Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/pqi: pqimonitor.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2007-2008 by Robert Fernie. * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "pqi/pqimonitor.h" #include "pqi/pqinetwork.h" #include "pqi/pqiipset.h" diff --git a/libretroshare/src/pqi/pqimonitor.h b/libretroshare/src/pqi/pqimonitor.h index 94e9bdf05..eaba16b73 100644 --- a/libretroshare/src/pqi/pqimonitor.h +++ b/libretroshare/src/pqi/pqimonitor.h @@ -1,27 +1,24 @@ -/* - * libretroshare/src/pqi: pqimonitor.h - * - * 3P/PQI network interface for RetroShare. - * - * Copyright 2007-2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ +/******************************************************************************* + * libretroshare/src/pqi: pqimonitor.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2007-2008 by Robert Fernie. * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef PQI_MONITOR_H #define PQI_MONITOR_H diff --git a/libretroshare/src/pqi/pqinetstatebox.cc b/libretroshare/src/pqi/pqinetstatebox.cc index 128c4d9e5..c10e5ed6d 100644 --- a/libretroshare/src/pqi/pqinetstatebox.cc +++ b/libretroshare/src/pqi/pqinetstatebox.cc @@ -1,3 +1,24 @@ +/******************************************************************************* + * libretroshare/src/pqi: pqinetstatebox.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2018 Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "retroshare/rsconfig.h" #include "util/rsnet.h" diff --git a/libretroshare/src/pqi/pqinetstatebox.h b/libretroshare/src/pqi/pqinetstatebox.h index 6b266b627..615099864 100644 --- a/libretroshare/src/pqi/pqinetstatebox.h +++ b/libretroshare/src/pqi/pqinetstatebox.h @@ -1,3 +1,24 @@ +/******************************************************************************* + * libretroshare/src/pqi: pqinetstatebox.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2018 Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef PQI_NET_STATUS_BOX_H #define PQI_NET_STATUS_BOX_H diff --git a/libretroshare/src/pqi/pqinetwork.cc b/libretroshare/src/pqi/pqinetwork.cc index 8f843cfeb..a3f4ac47f 100644 --- a/libretroshare/src/pqi/pqinetwork.cc +++ b/libretroshare/src/pqi/pqinetwork.cc @@ -1,29 +1,25 @@ -/* - * "$Id: pqinetwork.cc,v 1.18 2007-04-15 18:45:18 rmf24 Exp $" - * - * 3P/PQI network interface for RetroShare. - * - * Copyright (C) 2004-2006 Robert Fernie. - * Copyright (C) 2015-2018 Gioacchino Mazzurco - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/pqi: pqinetwork.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright (C) 2004-2006 Robert Fernie * + * Copyright (C) 2015-2018 Gioacchino Mazzurco * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifdef WINDOWS_SYS # include "util/rswin.h" # include "util/rsmemory.h" diff --git a/libretroshare/src/pqi/pqinetwork.h b/libretroshare/src/pqi/pqinetwork.h index e974f68cf..e4238ee5e 100644 --- a/libretroshare/src/pqi/pqinetwork.h +++ b/libretroshare/src/pqi/pqinetwork.h @@ -1,30 +1,25 @@ -/* - * "$Id: pqinetwork.h,v 1.15 2007-04-15 18:45:18 rmf24 Exp $" - * - * 3P/PQI network interface for RetroShare. - * - * Copyright (C) 2004-2006 Robert Fernie. - * Copyright (C) 2015-2018 Gioacchino Mazzurco - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - +/******************************************************************************* + * libretroshare/src/pqi: pqinetwork.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright (C) 2004-2006 Robert Fernie * + * Copyright (C) 2015-2018 Gioacchino Mazzurco * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef MRK_PQI_NETWORKING_HEADER #define MRK_PQI_NETWORKING_HEADER diff --git a/libretroshare/src/pqi/pqiperson.cc b/libretroshare/src/pqi/pqiperson.cc index 7f33a3e1b..30f7d37d3 100644 --- a/libretroshare/src/pqi/pqiperson.cc +++ b/libretroshare/src/pqi/pqiperson.cc @@ -1,28 +1,24 @@ -/* - * libretroshare/src/pqi pqiperson.cc - * - * 3P/PQI network interface for RetroShare. - * - * Copyright 2004-2006 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/pqi: pqiperson.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright (C) 2004-2006 Robert Fernie. * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "pqi/pqi.h" #include "pqi/pqiperson.h" #include "pqi/pqipersongrp.h" diff --git a/libretroshare/src/pqi/pqiperson.h b/libretroshare/src/pqi/pqiperson.h index 69faec48c..895af2925 100644 --- a/libretroshare/src/pqi/pqiperson.h +++ b/libretroshare/src/pqi/pqiperson.h @@ -1,30 +1,24 @@ -/* - * libretroshare/src/pqi pqiperson.h - * - * 3P/PQI network interface for RetroShare. - * - * Copyright 2004-2006 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - - +/******************************************************************************* + * libretroshare/src/pqi: pqiperson.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright (C) 2004-2006 Robert Fernie. * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef MRK_PQI_PERSON_HEADER #define MRK_PQI_PERSON_HEADER diff --git a/libretroshare/src/pqi/pqipersongrp.cc b/libretroshare/src/pqi/pqipersongrp.cc index 3df48fdb3..7146be7de 100644 --- a/libretroshare/src/pqi/pqipersongrp.cc +++ b/libretroshare/src/pqi/pqipersongrp.cc @@ -1,28 +1,24 @@ -/* - * libretroshare/src/pqi: pqipersongrp.cc - * - * 3P/PQI network interface for RetroShare. - * - * Copyright 2004-2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/pqi: pqipersongrp.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright (C) 2004-2008 Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "pqi/pqipersongrp.h" #include "pqi/p3linkmgr.h" #include "util/rsdebug.h" diff --git a/libretroshare/src/pqi/pqipersongrp.h b/libretroshare/src/pqi/pqipersongrp.h index 18c124968..0afd00a78 100644 --- a/libretroshare/src/pqi/pqipersongrp.h +++ b/libretroshare/src/pqi/pqipersongrp.h @@ -1,29 +1,24 @@ -/* - * libretroshare/src/pqi: pqipersongrp.h - * - * 3P/PQI network interface for RetroShare. - * - * Copyright 2004-2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - +/******************************************************************************* + * libretroshare/src/pqi: pqipersongrp.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright (C) 2004-2008 Robert Fernie. * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef MRK_PQI_PERSON_HANDLER_HEADER #define MRK_PQI_PERSON_HANDLER_HEADER diff --git a/libretroshare/src/pqi/pqiqos.cc b/libretroshare/src/pqi/pqiqos.cc index 9fc62aa8c..0b2b484fa 100644 --- a/libretroshare/src/pqi/pqiqos.cc +++ b/libretroshare/src/pqi/pqiqos.cc @@ -1,3 +1,24 @@ +/******************************************************************************* + * libretroshare/src/pqi: pqiqos.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright (C) 2004-2008 Cyril Soler * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include #include #include diff --git a/libretroshare/src/pqi/pqiqos.h b/libretroshare/src/pqi/pqiqos.h index 3a006b5a0..15e42b803 100644 --- a/libretroshare/src/pqi/pqiqos.h +++ b/libretroshare/src/pqi/pqiqos.h @@ -1,27 +1,24 @@ -/* - * libretroshare/src/pqi: pqiqos.h - * - * 3P/PQI network interface for RetroShare. - * - * Copyright 2004-2008 by Cyril Soler - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "csoler@users.sourceforge.net" - * - */ +/******************************************************************************* + * libretroshare/src/pqi: pqiqos.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright (C) 2004-2008 Cyril Soler * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ // This class handles the prioritisation of RsItem, based on the // priority level. The QoS algorithm must ensure that: diff --git a/libretroshare/src/pqi/pqiqosstreamer.cc b/libretroshare/src/pqi/pqiqosstreamer.cc index 2b4d02681..2818b3ee7 100644 --- a/libretroshare/src/pqi/pqiqosstreamer.cc +++ b/libretroshare/src/pqi/pqiqosstreamer.cc @@ -1,28 +1,24 @@ -/* - * libretroshare/src/pqi pqistreamer.h - * - * 3P/PQI network interface for RetroShare. - * - * Copyright 2012-2012 by Cyril Soler - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/pqi: pqiqosstreamer.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright (C) 2012-2012 Cyril Soler * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "pqiqosstreamer.h" //#define DEBUG_PQIQOSSTREAMER 1 diff --git a/libretroshare/src/pqi/pqiqosstreamer.h b/libretroshare/src/pqi/pqiqosstreamer.h index 0144cbdb8..5964b6cbe 100644 --- a/libretroshare/src/pqi/pqiqosstreamer.h +++ b/libretroshare/src/pqi/pqiqosstreamer.h @@ -1,28 +1,24 @@ -/* - * libretroshare/src/pqi pqistreamer.h - * - * 3P/PQI network interface for RetroShare. - * - * Copyright 2012-2012 by Cyril Soler - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/pqi: pqiqosstreamer.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright (C) 2012-2012 Cyril Soler * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once #include "pqiqos.h" diff --git a/libretroshare/src/pqi/pqiservice.cc b/libretroshare/src/pqi/pqiservice.cc index dbe20279a..3d28f9164 100644 --- a/libretroshare/src/pqi/pqiservice.cc +++ b/libretroshare/src/pqi/pqiservice.cc @@ -1,28 +1,24 @@ -/* - * libretroshare/src/pqi pqiservice.cc - * - * 3P/PQI network interface for RetroShare. - * - * Copyright 2004-2013 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/pqi: pqiservice.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2013 by Robert Fernie. * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "pqi/pqiservice.h" #include "util/rsdebug.h" #include "util/rsstring.h" diff --git a/libretroshare/src/pqi/pqiservice.h b/libretroshare/src/pqi/pqiservice.h index 41c540d4c..ad983266e 100644 --- a/libretroshare/src/pqi/pqiservice.h +++ b/libretroshare/src/pqi/pqiservice.h @@ -1,29 +1,24 @@ -/* - * libretroshare/src/pqi pqiservice.h - * - * 3P/PQI network interface for RetroShare. - * - * Copyright 2004-2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - +/******************************************************************************* + * libretroshare/src/pqi: pqiservice.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2008 by Robert Fernie. * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef PQI_SERVICE_HEADER #define PQI_SERVICE_HEADER diff --git a/libretroshare/src/pqi/pqissl.cc b/libretroshare/src/pqi/pqissl.cc index 47da19b93..c1ea271a3 100644 --- a/libretroshare/src/pqi/pqissl.cc +++ b/libretroshare/src/pqi/pqissl.cc @@ -1,29 +1,25 @@ -/* - * "$Id: pqissl.cc,v 1.28 2007-03-17 19:32:59 rmf24 Exp $" - * - * 3P/PQI network interface for RetroShare. - * - * Copyright 2004-2006 by Robert Fernie. - * Copyright (C) 2015-2018 Gioacchino Mazzurco - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/pqi: pqissl.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2006 by Robert Fernie * + * Copyright (C) 2015-2018 Gioacchino Mazzurco * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "pqi/pqissl.h" #include "pqi/pqinetwork.h" #include "pqi/sslfns.h" diff --git a/libretroshare/src/pqi/pqissl.h b/libretroshare/src/pqi/pqissl.h index e14e3928d..712e06a11 100644 --- a/libretroshare/src/pqi/pqissl.h +++ b/libretroshare/src/pqi/pqissl.h @@ -1,31 +1,25 @@ -/* - * "$Id: pqissl.h,v 1.18 2007-03-11 14:54:22 rmf24 Exp $" - * - * 3P/PQI network interface for RetroShare. - * - * Copyright 2004-2006 by Robert Fernie. - * Copyright (C) 2015-2018 Gioacchino Mazzurco - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - - +/******************************************************************************* + * libretroshare/src/pqi: pqissl.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2006 by Robert Fernie * + * Copyright (C) 2015-2018 Gioacchino Mazzurco * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef MRK_PQI_SSL_HEADER #define MRK_PQI_SSL_HEADER diff --git a/libretroshare/src/pqi/pqissli2pbob.cpp b/libretroshare/src/pqi/pqissli2pbob.cpp index 4b1b05dc6..5551ce788 100644 --- a/libretroshare/src/pqi/pqissli2pbob.cpp +++ b/libretroshare/src/pqi/pqissli2pbob.cpp @@ -1,3 +1,24 @@ +/******************************************************************************* + * libretroshare/src/pqi: pqissli2pbob.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2016 by Sehraf * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "pqissli2pbob.h" bool pqissli2pbob::connect_parameter(uint32_t type, const std::string &value) diff --git a/libretroshare/src/pqi/pqissli2pbob.h b/libretroshare/src/pqi/pqissli2pbob.h index e36112c08..b1a643a75 100644 --- a/libretroshare/src/pqi/pqissli2pbob.h +++ b/libretroshare/src/pqi/pqissli2pbob.h @@ -1,3 +1,24 @@ +/******************************************************************************* + * libretroshare/src/pqi: pqissli2pbob.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2016 by Sehraf * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef PQISSLI2PBOB_H #define PQISSLI2PBOB_H diff --git a/libretroshare/src/pqi/pqissllistener.cc b/libretroshare/src/pqi/pqissllistener.cc index c81c96cd2..676ac8226 100644 --- a/libretroshare/src/pqi/pqissllistener.cc +++ b/libretroshare/src/pqi/pqissllistener.cc @@ -1,29 +1,25 @@ -/* - * "$Id: pqissllistener.cc,v 1.3 2007-02-18 21:46:49 rmf24 Exp $" - * - * 3P/PQI network interface for RetroShare. - * - * Copyright 2004-2006 by Robert Fernie. - * Copyright (C) 2015-2018 Gioacchino Mazzurco - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/pqi: pqissllistener.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2006 by Robert Fernie * + * Copyright (C) 2015-2018 Gioacchino Mazzurco * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "pqi/pqissl.h" #include "pqi/pqissllistener.h" #include "pqi/pqinetwork.h" diff --git a/libretroshare/src/pqi/pqissllistener.h b/libretroshare/src/pqi/pqissllistener.h index b5de39069..98e3a77e2 100644 --- a/libretroshare/src/pqi/pqissllistener.h +++ b/libretroshare/src/pqi/pqissllistener.h @@ -1,30 +1,24 @@ -/* - * "$Id: pqissllistener.h,v 1.2 2007-02-18 21:46:49 rmf24 Exp $" - * - * 3P/PQI network interface for RetroShare. - * - * Copyright 2004-2006 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - - +/******************************************************************************* + * libretroshare/src/pqi: pqissllistener.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2006 by Robert Fernie. * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef MRK_PQI_SSL_LISTEN_HEADER #define MRK_PQI_SSL_LISTEN_HEADER diff --git a/libretroshare/src/pqi/pqisslpersongrp.cc b/libretroshare/src/pqi/pqisslpersongrp.cc index 20fe314d4..7016a2fa6 100644 --- a/libretroshare/src/pqi/pqisslpersongrp.cc +++ b/libretroshare/src/pqi/pqisslpersongrp.cc @@ -1,28 +1,24 @@ -/* - * libretroshare/src/pqi: pqisslpersongrp.cc - * - * 3P/PQI network interface for RetroShare. - * - * Copyright 2004-2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/pqi: pqisslpersongrp.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2008 by Robert Fernie. * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "serialiser/rsserializer.h" #include "services/autoproxy/rsautoproxymonitor.h" #include "util/rsdebug.h" @@ -36,9 +32,6 @@ static struct RsLog::logInfo pqipersongrpzoneInfo = {RsLog::Default, "pqipersong /**** * #define PQI_DISABLE_UDP 1 ***/ -#ifdef RETROTOR -#define PQI_DISABLE_UDP 1 -#endif /********************************** SSL Specific features ***************************/ diff --git a/libretroshare/src/pqi/pqisslpersongrp.h b/libretroshare/src/pqi/pqisslpersongrp.h index 5027abd66..aa574e617 100644 --- a/libretroshare/src/pqi/pqisslpersongrp.h +++ b/libretroshare/src/pqi/pqisslpersongrp.h @@ -1,30 +1,24 @@ -/* - * libretroshare/src/pqi: pqisslpersongrp.h - * - * 3P/PQI network interface for RetroShare. - * - * Copyright 2004-2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - - +/******************************************************************************* + * libretroshare/src/pqi: pqisslpersongrp.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2008 by Robert Fernie. * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef MRK_PQI_SSL_PERSON_HANDLER_HEADER #define MRK_PQI_SSL_PERSON_HANDLER_HEADER diff --git a/libretroshare/src/pqi/pqisslproxy.cc b/libretroshare/src/pqi/pqisslproxy.cc index 500c6a7d8..1c61bef78 100644 --- a/libretroshare/src/pqi/pqisslproxy.cc +++ b/libretroshare/src/pqi/pqisslproxy.cc @@ -1,30 +1,24 @@ -/* - * pqisslproxy.cc - * - * 3P/PQI network interface for RetroShare. - * - * Copyright 2004-2013 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - - +/******************************************************************************* + * libretroshare/src/pqi: pqisslproxy.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2013 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "pqi/pqisslproxy.h" #include "pqi/pqinetwork.h" diff --git a/libretroshare/src/pqi/pqisslproxy.h b/libretroshare/src/pqi/pqisslproxy.h index 347a9fa7f..d643ccb2e 100644 --- a/libretroshare/src/pqi/pqisslproxy.h +++ b/libretroshare/src/pqi/pqisslproxy.h @@ -1,30 +1,24 @@ -/* - * pqisslproxy.h - * - * 3P/PQI network interface for RetroShare. - * - * Copyright 2004-2013 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - - +/******************************************************************************* + * libretroshare/src/pqi: pqisslproxy.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2013 by Robert Fernie. * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef MRK_PQI_SSL_PROXY_HEADER #define MRK_PQI_SSL_PROXY_HEADER diff --git a/libretroshare/src/pqi/pqissludp.cc b/libretroshare/src/pqi/pqissludp.cc index dbde145df..6ba24b6f6 100644 --- a/libretroshare/src/pqi/pqissludp.cc +++ b/libretroshare/src/pqi/pqissludp.cc @@ -1,28 +1,24 @@ -/* - * "$Id: pqissludp.cc,v 1.16 2007-02-18 21:46:49 rmf24 Exp $" - * - * 3P/PQI network interface for RetroShare. - * - * Copyright 2004-2006 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/pqi: pqissludp.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2006 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "pqi/pqissludp.h" #include "pqi/pqinetwork.h" diff --git a/libretroshare/src/pqi/pqissludp.h b/libretroshare/src/pqi/pqissludp.h index 195e9e604..9cc5e3b23 100644 --- a/libretroshare/src/pqi/pqissludp.h +++ b/libretroshare/src/pqi/pqissludp.h @@ -1,30 +1,24 @@ -/* - * "$Id: pqissludp.h,v 1.8 2007-02-18 21:46:49 rmf24 Exp $" - * - * 3P/PQI network interface for RetroShare. - * - * Copyright 2004-2006 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - - +/******************************************************************************* + * libretroshare/src/pqi: pqissludp.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2006 by Robert Fernie. * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef MRK_PQI_SSL_UDP_HEADER #define MRK_PQI_SSL_UDP_HEADER diff --git a/libretroshare/src/pqi/pqistore.cc b/libretroshare/src/pqi/pqistore.cc index 09932a029..090a6a794 100644 --- a/libretroshare/src/pqi/pqistore.cc +++ b/libretroshare/src/pqi/pqistore.cc @@ -1,30 +1,24 @@ -/* - * "$Id: pqistore.cc,v 1.5 2007-03-21 18:45:41 rmf24 Exp $" - * - * 3P/PQI network interface for RetroShare. - * - * Copyright 2004-2006 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - - +/******************************************************************************* + * libretroshare/src/pqi: pqistore.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2006 by Robert Fernie. * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ /* This is dependent on the sslroot at the moment. * -> as we need to create/restore references to the Person. diff --git a/libretroshare/src/pqi/pqistore.h b/libretroshare/src/pqi/pqistore.h index 7870c39b3..f8a586c67 100644 --- a/libretroshare/src/pqi/pqistore.h +++ b/libretroshare/src/pqi/pqistore.h @@ -1,30 +1,24 @@ -/* - * pqistore.h - * - * 3P/PQI network interface for RetroShare. - * - * Copyright 2004-2006 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - - +/******************************************************************************* + * libretroshare/src/pqi: pqistore.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2006 by Robert Fernie. * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef MRK_PQI_STORE_STREAMER_HEADER #define MRK_PQI_STORE_STREAMER_HEADER diff --git a/libretroshare/src/pqi/pqistreamer.cc b/libretroshare/src/pqi/pqistreamer.cc index 839a5364e..9015492a3 100644 --- a/libretroshare/src/pqi/pqistreamer.cc +++ b/libretroshare/src/pqi/pqistreamer.cc @@ -1,29 +1,24 @@ -/* - * "$Id: pqistreamer.cc,v 1.19 2007-02-18 21:46:50 rmf24 Exp $" - * - * 3P/PQI network interface for RetroShare. - * - * Copyright 2004-2006 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - +/******************************************************************************* + * libretroshare/src/pqi: pqistreamer.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2006 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "pqi/pqistreamer.h" #include // for gettimeofday diff --git a/libretroshare/src/pqi/pqistreamer.h b/libretroshare/src/pqi/pqistreamer.h index 9908651b2..c9ab558cd 100644 --- a/libretroshare/src/pqi/pqistreamer.h +++ b/libretroshare/src/pqi/pqistreamer.h @@ -1,29 +1,24 @@ -/* - * libretroshare/src/pqi pqistreamer.h - * - * 3P/PQI network interface for RetroShare. - * - * Copyright 2004-2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - +/******************************************************************************* + * libretroshare/src/pqi: pqistreamer.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2008 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef MRK_PQI_STREAMER_HEADER #define MRK_PQI_STREAMER_HEADER diff --git a/libretroshare/src/pqi/pqithreadstreamer.cc b/libretroshare/src/pqi/pqithreadstreamer.cc index 54ab925e1..8f2bd47c3 100644 --- a/libretroshare/src/pqi/pqithreadstreamer.cc +++ b/libretroshare/src/pqi/pqithreadstreamer.cc @@ -1,29 +1,24 @@ -/* - * pqithreadstreamer.cc - * - * 3P/PQI network interface for RetroShare. - * - * Copyright 2004-2013 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - +/******************************************************************************* + * libretroshare/src/pqi: pqithreadstreamer.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2013 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "util/rstime.h" #include "pqi/pqithreadstreamer.h" #include diff --git a/libretroshare/src/pqi/pqithreadstreamer.h b/libretroshare/src/pqi/pqithreadstreamer.h index 65cfabdfe..cfa3c12d4 100644 --- a/libretroshare/src/pqi/pqithreadstreamer.h +++ b/libretroshare/src/pqi/pqithreadstreamer.h @@ -1,28 +1,24 @@ -/* - * libretroshare/src/pqi pqithreadstreamer.h - * - * 3P/PQI network interface for RetroShare. - * - * Copyright 2004-2013 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/pqi: pqithreadstreamer.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2013 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef MRK_PQI_THREAD_STREAMER_HEADER #define MRK_PQI_THREAD_STREAMER_HEADER diff --git a/libretroshare/src/pqi/sslfns.cc b/libretroshare/src/pqi/sslfns.cc index ff964c45c..59bdc884a 100644 --- a/libretroshare/src/pqi/sslfns.cc +++ b/libretroshare/src/pqi/sslfns.cc @@ -1,27 +1,24 @@ -/* - * libretroshare/src/pqi: sslfns.cc - * - * 3P/PQI network interface for RetroShare. - * - * Copyright 2004-2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ +/******************************************************************************* + * libretroshare/src/pqi: sslfns.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2008 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ /* Functions in this file are SSL only, * and have no dependence on SSLRoot() etc. diff --git a/libretroshare/src/pqi/sslfns.h b/libretroshare/src/pqi/sslfns.h index 4682810b5..0a19904e1 100644 --- a/libretroshare/src/pqi/sslfns.h +++ b/libretroshare/src/pqi/sslfns.h @@ -1,31 +1,27 @@ -#ifndef RS_PQI_SSL_HELPER_H +/******************************************************************************* + * libretroshare/src/pqi: sslfns.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2008 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ +#ifndef RS_PQI_SSL_HELPER_H #define RS_PQI_SSL_HELPER_H -/* - * libretroshare/src/pqi: sslfns.cc - * - * 3P/PQI network interface for RetroShare. - * - * Copyright 2004-2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - /* Functions in this file are SSL only, * and have no dependence on SSLRoot() etc. * might need SSL_Init() to be called - thats it! diff --git a/libretroshare/src/retroshare/rsbanlist.h b/libretroshare/src/retroshare/rsbanlist.h index b6778f0e3..f60b129f9 100644 --- a/libretroshare/src/retroshare/rsbanlist.h +++ b/libretroshare/src/retroshare/rsbanlist.h @@ -1,28 +1,24 @@ -/* - * libretroshare/src/services/p3banlist.h - * - * Exchange list of Peers for Banning / Whitelisting. - * - * Copyright 2011 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/retroshare: rsbanlist.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2011-2011 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once #include "util/rsnet.h" diff --git a/libretroshare/src/retroshare/rsconfig.h b/libretroshare/src/retroshare/rsconfig.h index e3b74aa4b..962519ad9 100644 --- a/libretroshare/src/retroshare/rsconfig.h +++ b/libretroshare/src/retroshare/rsconfig.h @@ -1,31 +1,27 @@ +/******************************************************************************* + * libretroshare/src/retroshare: rsconfig.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2011-2011 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RETROSHARE_CONFIG_GUI_INTERFACE_H #define RETROSHARE_CONFIG_GUI_INTERFACE_H -/* - * libretroshare/src/retroshare: rsconfig.h - * - * RetroShare C++ Interface. - * - * Copyright 2011-2011 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - #include #include #include diff --git a/libretroshare/src/retroshare/rsdht.h b/libretroshare/src/retroshare/rsdht.h index 35dee0354..022fb421b 100644 --- a/libretroshare/src/retroshare/rsdht.h +++ b/libretroshare/src/retroshare/rsdht.h @@ -1,31 +1,27 @@ +/******************************************************************************* + * libretroshare/src/retroshare: rsdht.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2011-2011 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RETROSHARE_DHT_GUI_INTERFACE_H #define RETROSHARE_DHT_GUI_INTERFACE_H -/* - * libretroshare/src/rsiface: rsdht.h - * - * RetroShare C++ Interface. - * - * Copyright 2011-2011 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - #include #include #include diff --git a/libretroshare/src/retroshare/rsdisc.h b/libretroshare/src/retroshare/rsdisc.h index e97f19571..b81e03c3c 100644 --- a/libretroshare/src/retroshare/rsdisc.h +++ b/libretroshare/src/retroshare/rsdisc.h @@ -1,31 +1,27 @@ +/******************************************************************************* + * libretroshare/src/retroshare: rsdht.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2008-2008 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RETROSHARE_DISC_GUI_INTERFACE_H #define RETROSHARE_DISC_GUI_INTERFACE_H -/* - * libretroshare/src/rsiface: rsdisc.h - * - * RetroShare C++ Interface. - * - * Copyright 2008-2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - #include #include #include diff --git a/libretroshare/src/retroshare/rsexpr.h b/libretroshare/src/retroshare/rsexpr.h index 72c63d463..7c391a4be 100644 --- a/libretroshare/src/retroshare/rsexpr.h +++ b/libretroshare/src/retroshare/rsexpr.h @@ -1,28 +1,24 @@ -/* - * rs-core/src/rsiface: rsexpr.h - * - * RetroShare C++ Interface. - * - * Copyright 2007-2008 by Kashif Kaleem. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/retroshare: rsexpr.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2007-2008 by Kashif Kaleem * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once #include @@ -185,7 +181,7 @@ public: StringExpression(enum StringOperator op, const std::list &t, bool ic): Op(op),terms(t), IgnoreCase(ic){} virtual void linearize(LinearizedExpression& e) const ; - virtual std::string toStdString(const std::string& varstr) const; + virtual std::string toStdStringWithParam(const std::string& varstr) const; protected: bool evalStr(const std::string &str); @@ -201,7 +197,7 @@ public: RelExpression(enum RelOperator op, T lv, T hv): Op(op), LowerValue(lv), HigherValue(hv) {} virtual void linearize(LinearizedExpression& e) const ; - virtual std::string toStdString(const std::string& typestr) const; + virtual std::string toStdStringWithParam(const std::string& typestr) const; protected: bool evalRel(T val); @@ -233,7 +229,7 @@ bool RelExpression::evalRel(T val) { } template -std::string RelExpression::toStdString(const std::string& typestr) const +std::string RelExpression::toStdStringWithParam(const std::string& typestr) const { std::string LowerValueStr = RsUtil::NumberToString(LowerValue) ; @@ -279,7 +275,7 @@ public: StringExpression(op,t,ic) {} bool eval(const ExpFileEntry& file); - virtual std::string toStdString() const { return StringExpression::toStdString("NAME"); } + virtual std::string toStdString() const { return StringExpression::toStdStringWithParam("NAME"); } virtual void linearize(LinearizedExpression& e) const { @@ -294,7 +290,7 @@ public: StringExpression(op,t,ic) {} bool eval(const ExpFileEntry& file); - virtual std::string toStdString()const { return StringExpression::toStdString("PATH"); } + virtual std::string toStdString()const { return StringExpression::toStdStringWithParam("PATH"); } virtual void linearize(LinearizedExpression& e) const { @@ -309,7 +305,7 @@ public: StringExpression(op,t,ic) {} bool eval(const ExpFileEntry& file); - virtual std::string toStdString()const { return StringExpression::toStdString("EXTENSION"); } + virtual std::string toStdString()const { return StringExpression::toStdStringWithParam("EXTENSION"); } virtual void linearize(LinearizedExpression& e) const { @@ -324,7 +320,7 @@ public: StringExpression(op,t, true) {} bool eval(const ExpFileEntry& file); - virtual std::string toStdString() const { return StringExpression::toStdString("HASH"); } + virtual std::string toStdString() const { return StringExpression::toStdStringWithParam("HASH"); } virtual void linearize(LinearizedExpression& e) const { @@ -346,7 +342,7 @@ public: RelExpression(op,lv,hv) {} bool eval(const ExpFileEntry& file); - virtual std::string toStdString() const { return RelExpression::toStdString("DATE"); } + virtual std::string toStdString() const { return RelExpression::toStdStringWithParam("DATE"); } virtual void linearize(LinearizedExpression& e) const { @@ -363,7 +359,7 @@ public: RelExpression(op,lv,hv) {} bool eval(const ExpFileEntry& file); - virtual std::string toStdString() const { return RelExpression::toStdString("SIZE"); } + virtual std::string toStdString() const { return RelExpression::toStdStringWithParam("SIZE"); } virtual void linearize(LinearizedExpression& e) const { @@ -380,7 +376,7 @@ public: RelExpression(op,lv,hv) {} bool eval(const ExpFileEntry& file); - virtual std::string toStdString() const { return RelExpression::toStdString("SIZE"); } + virtual std::string toStdString() const { return RelExpression::toStdStringWithParam("SIZE"); } virtual void linearize(LinearizedExpression& e) const { @@ -396,7 +392,7 @@ public: PopExpression(const LinearizedExpression& e) ; bool eval(const ExpFileEntry& file); - virtual std::string toStdString() const { return RelExpression::toStdString("POPULARITY"); } + virtual std::string toStdString() const { return RelExpression::toStdStringWithParam("POPULARITY"); } virtual void linearize(LinearizedExpression& e) const { diff --git a/libretroshare/src/retroshare/rsfiles.h b/libretroshare/src/retroshare/rsfiles.h index 83301de98..9a312683f 100644 --- a/libretroshare/src/retroshare/rsfiles.h +++ b/libretroshare/src/retroshare/rsfiles.h @@ -1,40 +1,43 @@ -#ifndef RS_FILES_GUI_INTERFACE_H -#define RS_FILES_GUI_INTERFACE_H - -/* - * libretroshare/src/rsiface: rsfiles.h - * - * RetroShare C++ Interface. - * - * Copyright 2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/retroshare: rsfiles.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2008-2008 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ +#pragma once #include #include #include +#include +#include #include "rstypes.h" +#include "serialiser/rsserializable.h" +#include "rsturtle.h" class RsFiles; -extern RsFiles *rsFiles; + +/** + * Pointer to global instance of RsFiles service implementation + * @jsonapi{development} + */ +extern RsFiles* rsFiles; namespace RsRegularExpression { class Expression; } @@ -108,7 +111,7 @@ const TransferRequestFlags RS_FILE_REQ_NO_SEARCH ( 0x02000000 ); // di const uint32_t RS_FILE_EXTRA_DELETE = 0x0010; -struct SharedDirInfo +struct SharedDirInfo : RsSerializable { static bool sameLists(const std::list& l1,const std::list& l2) { @@ -122,10 +125,22 @@ struct SharedDirInfo return it1 == l1.end() && it2 == l2.end() ; } - std::string filename ; - std::string virtualname ; - FileStorageFlags shareflags ; // combnation of DIR_FLAGS_ANONYMOUS_DOWNLOAD | DIR_FLAGS_BROWSABLE | ... - std::list parent_groups ; + std::string filename; + std::string virtualname; + + /// combnation of DIR_FLAGS_ANONYMOUS_DOWNLOAD | DIR_FLAGS_BROWSABLE | ... + FileStorageFlags shareflags; + std::list parent_groups; + + /// @see RsSerializable::serial_process + virtual void serial_process(RsGenericSerializer::SerializeJob j, + RsGenericSerializer::SerializeContext& ctx) + { + RS_SERIAL_PROCESS(filename); + RS_SERIAL_PROCESS(virtualname); + RS_SERIAL_PROCESS(shareflags); + RS_SERIAL_PROCESS(parent_groups); + } }; struct SharedDirStats @@ -166,44 +181,143 @@ public: uint64_t mTotalSize ; }; +struct BannedFileEntry +{ + BannedFileEntry() : size(0),filename(""),ban_time_stamp(0) {} + + uint64_t size ; + std::string filename ; + time_t ban_time_stamp; +}; + class RsFiles { public: RsFiles() {} virtual ~RsFiles() {} - /** - * Provides file data for the gui: media streaming or rpc clients. - * It may return unverified chunks. This allows streaming without having to wait for hashes or completion of the file. - * This function returns an unspecified amount of bytes. Either as much data as available or a sensible maximum. Expect a block size of around 1MiB. - * To get more data, call this function repeatedly with different offsets. - * Returns false in case - * - the files is not available on the local node - * - not downloading - * - the requested data was not downloaded yet - * - end of file was reached - * @param hash hash of a file. The file has to be available on this node or it has to be in downloading state. - * @param offset where the desired block starts - * @param requested_size size of pre-allocated data. Will be updated by the function. - * @param data pre-allocated memory chunk of size 'requested_size' by the client - */ - virtual bool getFileData(const RsFileHash& hash, uint64_t offset, uint32_t& requested_size,uint8_t *data)=0; + /** + * Provides file data for the gui, media streaming or rpc clients. + * It may return unverified chunks. This allows streaming without having to + * wait for hashes or completion of the file. + * This function returns an unspecified amount of bytes. Either as much data + * as available or a sensible maximum. Expect a block size of around 1MiB. + * To get more data, call this function repeatedly with different offsets. + * + * jsonapi{development} + * note the missing @ the wrapper for this is written manually not + * autogenerated @see JsonApiServer. + * + * @param[in] hash hash of the file. The file has to be available on this node + * or it has to be in downloading state. + * @param[in] offset where the desired block starts + * @param[inout] requested_size size of pre-allocated data. Will be updated + * by the function. + * @param data pre-allocated memory chunk of size 'requested_size' by the + * client + * @return Returns false in case + * - the files is not available on the local node + * - not downloading + * - the requested data was not downloaded yet + * - end of file was reached + */ + virtual bool getFileData( const RsFileHash& hash, uint64_t offset, + uint32_t& requested_size, uint8_t* data ) = 0; - /*** - * Control of Downloads. - ***/ + /** + * @brief Check if we already have a file + * @jsonapi{development} + * @param[in] hash file identifier + * @param[out] info storage for the possibly found file information + * @return true if the file is already present, false otherwise + */ + virtual bool alreadyHaveFile(const RsFileHash& hash, FileInfo &info) = 0; + + /** + * @brief Initiate downloading of a file + * @jsonapi{development} + * @param[in] fileName + * @param[in] hash + * @param[in] size + * @param[in] destPath in not empty specify a destination path + * @param[in] flags you usually want RS_FILE_REQ_ANONYMOUS_ROUTING + * @param[in] srcIds eventually specify known sources + * @return false if we already have the file, true otherwhise + */ + virtual bool FileRequest( + const std::string& fileName, const RsFileHash& hash, uint64_t size, + const std::string& destPath, TransferRequestFlags flags, + const std::list& srcIds ) = 0; + + /** + * @brief Cancel file downloading + * @jsonapi{development} + * @param[in] hash + * @return false if the file is not in the download queue, true otherwhise + */ + virtual bool FileCancel(const RsFileHash& hash) = 0; + + /** + * @brief Set destination directory for given file + * @jsonapi{development} + * @param[in] hash file identifier + * @param[in] newPath + * @return false if some error occurred, true otherwise + */ + virtual bool setDestinationDirectory( + const RsFileHash& hash, const std::string& newPath ) = 0; + + /** + * @brief Set name for dowloaded file + * @jsonapi{development} + * @param[in] hash file identifier + * @param[in] newName + * @return false if some error occurred, true otherwise + */ + virtual bool setDestinationName( + const RsFileHash& hash, const std::string& newName ) = 0; + + /** + * @brief Set chunk strategy for file, useful to set streaming mode to be + * able of see video or other media preview while it is still downloading + * @jsonapi{development} + * @param[in] hash file identifier + * @param[in] newStrategy + * @return false if some error occurred, true otherwise + */ + virtual bool setChunkStrategy( + const RsFileHash& hash, + FileChunksInfo::ChunkStrategy newStrategy ) = 0; + + /** + * @brief Set default chunk strategy + * @jsonapi{development} + * @param[in] strategy + */ + virtual void setDefaultChunkStrategy( + FileChunksInfo::ChunkStrategy strategy ) = 0; + + /** + * @brief Get default chunk strategy + * @jsonapi{development} + * @return current default chunck strategy + */ + virtual FileChunksInfo::ChunkStrategy defaultChunkStrategy() = 0; + + /** + * @brief Get free disk space limit + * @jsonapi{development} + * @return current current minimum free space on disk in MB + */ + virtual uint32_t freeDiskSpaceLimit() const = 0; + + /** + * @brief Set minimum free disk space limit + * @jsonapi{development} + * @param[in] minimumFreeMB minimum free space in MB + */ + virtual void setFreeDiskSpaceLimit(uint32_t minimumFreeMB) = 0; - virtual bool alreadyHaveFile(const RsFileHash& hash, FileInfo &info) = 0; - /// Returns false is we already have the file. Otherwise, initiates the dl and returns true. - virtual bool FileRequest(const std::string& fname, const RsFileHash& hash, uint64_t size, const std::string& dest, TransferRequestFlags flags, const std::list& srcIds) = 0; - virtual bool FileCancel(const RsFileHash& hash) = 0; - virtual bool setDestinationDirectory(const RsFileHash& hash,const std::string& new_path) = 0; - virtual bool setDestinationName(const RsFileHash& hash,const std::string& new_name) = 0; - virtual bool setChunkStrategy(const RsFileHash& hash,FileChunksInfo::ChunkStrategy) = 0; - virtual void setDefaultChunkStrategy(FileChunksInfo::ChunkStrategy) = 0; - virtual FileChunksInfo::ChunkStrategy defaultChunkStrategy() = 0; - virtual uint32_t freeDiskSpaceLimit() const =0; - virtual void setFreeDiskSpaceLimit(uint32_t size_in_mb) =0; virtual bool FileControl(const RsFileHash& hash, uint32_t flags) = 0; virtual bool FileClearCompleted() = 0; virtual void setDefaultEncryptionPolicy(uint32_t policy)=0; // RS_FILE_CTRL_ENCRYPTION_POLICY_STRICT/PERMISSIVE @@ -213,6 +327,24 @@ public: virtual void setFilePermDirectDL(uint32_t perm)=0; virtual uint32_t filePermDirectDL()=0; + /** + * @brief Request remote files search + * @jsonapi{development} + * @param[in] matchString string to look for in the search + * @param multiCallback function that will be called each time a search + * result is received + * @param[in] maxWait maximum wait time in seconds for search results + * @return false on error, true otherwise + */ + virtual bool turtleSearchRequest( + const std::string& matchString, + const std::function& results)>& multiCallback, + std::time_t maxWait = 300 ) = 0; + + virtual TurtleRequestId turtleSearch(const std::string& string_to_match) = 0; + virtual TurtleRequestId turtleSearch( + const RsRegularExpression::LinearizedExpression& expr) = 0; + /*** * Control of Downloads Priority. ***/ @@ -222,21 +354,56 @@ public: virtual bool changeDownloadSpeed(const RsFileHash& hash, int speed) = 0; virtual bool getDownloadSpeed(const RsFileHash& hash, int & speed) = 0; virtual bool clearDownload(const RsFileHash& hash) = 0; -// virtual void getDwlDetails(std::list & details) = 0; - /*** - * Download / Upload Details. - ***/ - virtual void FileDownloads(std::list &hashs) = 0; - virtual bool FileUploads(std::list &hashs) = 0; - virtual bool FileDetails(const RsFileHash &hash, FileSearchFlags hintflags, FileInfo &info) = 0; + /** + * @brief Get incoming files list + * @jsonapi{development} + * @param[out] hashs storage for files identifiers list + */ + virtual void FileDownloads(std::list& hashs) = 0; + + /** + * @brief Get outgoing files list + * @jsonapi{development} + * @param[out] hashs storage for files identifiers list + * @return false if some error occurred, true otherwise + */ + virtual bool FileUploads(std::list& hashs) = 0; + + /** + * @brief Get file details + * @jsonapi{development} + * @param[in] hash file identifier + * @param[in] hintflags filtering hint (RS_FILE_HINTS_EXTRA|...|RS_FILE_HINTS_LOCAL) + * @param[out] info storage for file information + * @return true if file found, false otherwise + */ + virtual bool FileDetails( + const RsFileHash &hash, FileSearchFlags hintflags, FileInfo& info ) = 0; + virtual bool isEncryptedSource(const RsPeerId& virtual_peer_id) =0; - /// Gives chunk details about the downloaded file with given hash. - virtual bool FileDownloadChunksDetails(const RsFileHash& hash,FileChunksInfo& info) = 0 ; + /** + * @brief Get chunk details about the downloaded file with given hash. + * @jsonapi{development} + * @param[in] hash file identifier + * @param[out] info storage for file information + * @return true if file found, false otherwise + */ + virtual bool FileDownloadChunksDetails( + const RsFileHash& hash, FileChunksInfo& info) = 0; - /// details about the upload with given hash - virtual bool FileUploadChunksDetails(const RsFileHash& hash,const RsPeerId& peer_id,CompressedChunkMap& map) = 0 ; + /** + * @brief Get details about the upload with given hash + * @jsonapi{development} + * @param[in] hash file identifier + * @param[in] peer_id peer identifier + * @param[out] map storage for chunk info + * @return true if file found, false otherwise + */ + virtual bool FileUploadChunksDetails( + const RsFileHash& hash, const RsPeerId& peer_id, + CompressedChunkMap& map ) = 0; /*** * Extra List Access @@ -263,6 +430,11 @@ public: virtual int SearchBoolExp(RsRegularExpression::Expression * exp, std::list &results,FileSearchFlags flags,const RsPeerId& peer_id) = 0; virtual int getSharedDirStatistics(const RsPeerId& pid, SharedDirStats& stats) =0; + virtual int banFile(const RsFileHash& real_file_hash, const std::string& filename, uint64_t file_size) =0; + virtual int unbanFile(const RsFileHash& real_file_hash)=0; + virtual bool getPrimaryBannedFilesList(std::map& banned_files) =0; + virtual bool isHashBanned(const RsFileHash& hash) =0; + /*** * Utility Functions. ***/ @@ -277,16 +449,76 @@ public: ***/ virtual void requestDirUpdate(void *ref) =0 ; // triggers the update of the given reference. Used when browsing. - virtual bool setDownloadDirectory(std::string path) = 0; - virtual bool setPartialsDirectory(std::string path) = 0; - virtual std::string getDownloadDirectory() = 0; - virtual std::string getPartialsDirectory() = 0; + /** + * @brief Set default complete downloads directory + * @jsonapi{development} + * @param[in] path directory path + * @return false if something failed, true otherwhise + */ + virtual bool setDownloadDirectory(const std::string& path) = 0; - virtual bool getSharedDirectories(std::list& dirs) = 0; - virtual bool setSharedDirectories(const std::list& dirs) = 0; - virtual bool addSharedDirectory(const SharedDirInfo& dir) = 0; - virtual bool updateShareFlags(const SharedDirInfo& dir) = 0; // updates the flags. The directory should already exist ! - virtual bool removeSharedDirectory(std::string dir) = 0; + /** + * @brief Set partial downloads directory + * @jsonapi{development} + * @param[in] path directory path + * @return false if something failed, true otherwhise + */ + virtual bool setPartialsDirectory(const std::string& path) = 0; + + /** + * @brief Get default complete downloads directory + * @jsonapi{development} + * @return default completed downloads directory path + */ + virtual std::string getDownloadDirectory() = 0; + + /** + * @brief Get partial downloads directory + * @jsonapi{development} + * @return partials downloads directory path + */ + virtual std::string getPartialsDirectory() = 0; + + /** + * @brief Get list of current shared directories + * @jsonapi{development} + * @param[out] dirs storage for the list of share directories + * @return false if something failed, true otherwhise + */ + virtual bool getSharedDirectories(std::list& dirs) = 0; + + /** + * @brief Set shared directories + * @jsonapi{development} + * @param[in] dirs list of shared directories with share options + * @return false if something failed, true otherwhise + */ + virtual bool setSharedDirectories(const std::list& dirs) = 0; + + /** + * @brief Add shared directory + * @jsonapi{development} + * @param[in] dir directory to share with sharing options + * @return false if something failed, true otherwhise + */ + virtual bool addSharedDirectory(const SharedDirInfo& dir) = 0; + + /** + * @brief Updates shared directory sharing flags. + * The directory should be already shared! + * @jsonapi{development} + * @param[in] dir Shared directory with updated sharing options + * @return false if something failed, true otherwhise + */ + virtual bool updateShareFlags(const SharedDirInfo& dir) = 0; + + /** + * @brief Remove directory from shared list + * @jsonapi{development} + * @param[in] dir Path of the directory to remove from shared list + * @return false if something failed, true otherwhise + */ + virtual bool removeSharedDirectory(std::string dir) = 0; virtual bool getIgnoreLists(std::list& ignored_prefixes, std::list& ignored_suffixes,uint32_t& flags) =0; virtual void setIgnoreLists(const std::list& ignored_prefixes, const std::list& ignored_suffixes,uint32_t flags) =0; @@ -308,8 +540,4 @@ public: virtual bool ignoreDuplicates() = 0; virtual void setIgnoreDuplicates(bool ignore) = 0; - }; - - -#endif diff --git a/libretroshare/src/retroshare/rsgxschannels.h b/libretroshare/src/retroshare/rsgxschannels.h index c75235f0e..383ebc7df 100644 --- a/libretroshare/src/retroshare/rsgxschannels.h +++ b/libretroshare/src/retroshare/rsgxschannels.h @@ -1,67 +1,76 @@ -#ifndef RETROSHARE_GXS_CHANNEL_GUI_INTERFACE_H -#define RETROSHARE_GXS_CHANNEL_GUI_INTERFACE_H - -/* - * libretroshare/src/retroshare: rsgxschannel.h - * - * RetroShare C++ Interface. - * - * Copyright 2012-2012 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ +#pragma once +/******************************************************************************* + * libretroshare/src/retroshare: rsgxschannels.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012-2012 by Robert Fernie * + * Copyright (C) 2018 Gioacchino Mazzurco * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include #include #include +#include #include "retroshare/rstokenservice.h" #include "retroshare/rsgxsifacehelper.h" #include "retroshare/rsgxscommon.h" +#include "serialiser/rsserializable.h" +#include "retroshare/rsturtle.h" - - -/* The Main Interface Class - for information about your Peers */ class RsGxsChannels; -extern RsGxsChannels *rsGxsChannels; +/** + * Pointer to global instance of RsGxsChannels service implementation + * @jsonapi{development} + */ +extern RsGxsChannels* rsGxsChannels; // These should be in rsgxscommon.h - -class RsGxsChannelGroup +struct RsGxsChannelGroup : RsSerializable { - public: RsGroupMetaData mMeta; std::string mDescription; RsGxsImage mImage; bool mAutoDownload; + + /// @see RsSerializable + virtual void serial_process( RsGenericSerializer::SerializeJob j, + RsGenericSerializer::SerializeContext& ctx ) + { + RS_SERIAL_PROCESS(mMeta); + RS_SERIAL_PROCESS(mDescription); + RS_SERIAL_PROCESS(mImage); + RS_SERIAL_PROCESS(mAutoDownload); + } }; -class RsGxsChannelPost +std::ostream &operator<<(std::ostream& out, const RsGxsChannelGroup& group); + + +struct RsGxsChannelPost : RsSerializable { -public: RsGxsChannelPost() : mCount(0), mSize(0) {} -public: RsMsgMetaData mMeta; - std::set mOlderVersions ; + std::set mOlderVersions; std::string mMsg; // UTF8 encoded. std::list mFiles; @@ -69,65 +78,225 @@ public: uint64_t mSize; // auto calced. RsGxsImage mThumbnail; + + /// @see RsSerializable + virtual void serial_process( RsGenericSerializer::SerializeJob j, + RsGenericSerializer::SerializeContext& ctx ) + { + RS_SERIAL_PROCESS(mMeta); + RS_SERIAL_PROCESS(mOlderVersions); + + RS_SERIAL_PROCESS(mMsg); + RS_SERIAL_PROCESS(mFiles); + RS_SERIAL_PROCESS(mCount); + RS_SERIAL_PROCESS(mSize); + RS_SERIAL_PROCESS(mThumbnail); + } }; +std::ostream &operator<<(std::ostream& out, const RsGxsChannelPost& post); -std::ostream &operator<<(std::ostream &out, const RsGxsChannelGroup &group); -std::ostream &operator<<(std::ostream &out, const RsGxsChannelPost &post); class RsGxsChannels: public RsGxsIfaceHelper, public RsGxsCommentService { - public: +public: - explicit RsGxsChannels(RsGxsIface *gxs) - :RsGxsIfaceHelper(gxs) {} + explicit RsGxsChannels(RsGxsIface& gxs) : RsGxsIfaceHelper(gxs) {} virtual ~RsGxsChannels() {} - /* Specific Service Data */ -virtual bool getGroupData(const uint32_t &token, std::vector &groups) = 0; -virtual bool getPostData(const uint32_t &token, std::vector &posts, std::vector &cmts) = 0; -virtual bool getPostData(const uint32_t &token, std::vector &posts) = 0; -//Not currently used -//virtual bool getRelatedPosts(const uint32_t &token, std::vector &posts) = 0; + /** + * @brief Get channels summaries list. Blocking API. + * @jsonapi{development} + * @param[out] channels list where to store the channels + * @return false if something failed, true otherwhise + */ + virtual bool getChannelsSummaries(std::list& channels) = 0; - /* From RsGxsCommentService */ -//virtual bool getCommentData(const uint32_t &token, std::vector &comments) = 0; -//virtual bool getRelatedComments(const uint32_t &token, std::vector &comments) = 0; -//virtual bool createComment(uint32_t &token, RsGxsComment &comment) = 0; -//virtual bool createVote(uint32_t &token, RsGxsVote &vote) = 0; + /** + * @brief Get channels information (description, thumbnail...). + * Blocking API. + * @jsonapi{development} + * @param[in] chanIds ids of the channels of which to get the informations + * @param[out] channelsInfo storage for the channels informations + * @return false if something failed, true otherwhise + */ + virtual bool getChannelsInfo( + const std::list& chanIds, + std::vector& channelsInfo ) = 0; - ////////////////////////////////////////////////////////////////////////////// -virtual void setMessageReadStatus(uint32_t& token, const RsGxsGrpMsgIdPair& msgId, bool read) = 0; + /** + * @brief Get content of specified channels. Blocking API + * @jsonapi{development} + * @param[in] chanIds id of the channels of which the content is requested + * @param[out] posts storage for the posts + * @param[out] comments storage for the comments + * @return false if something failed, true otherwhise + */ + virtual bool getChannelsContent( + const std::list& chanIds, + std::vector& posts, + std::vector& comments ) = 0; -virtual bool setChannelAutoDownload(const RsGxsGroupId &groupId, bool enabled) = 0; -virtual bool getChannelAutoDownload(const RsGxsGroupId &groupid, bool& enabled) = 0; + /* Specific Service Data + * TODO: change the orrible const uint32_t &token to uint32_t token + * TODO: create a new typedef for token so code is easier to read + */ -virtual bool setChannelDownloadDirectory(const RsGxsGroupId &groupId, const std::string& directory)=0; -virtual bool getChannelDownloadDirectory(const RsGxsGroupId &groupId, std::string& directory)=0; + virtual bool getGroupData(const uint32_t &token, std::vector &groups) = 0; + virtual bool getPostData(const uint32_t &token, std::vector &posts, std::vector &cmts) = 0; + virtual bool getPostData(const uint32_t &token, std::vector &posts) = 0; -//virtual void setChannelAutoDownload(uint32_t& token, const RsGxsGroupId& groupId, bool autoDownload) = 0; + /** + * @brief toggle message read status + * @jsonapi{development} + * @param[out] token GXS token queue token + * @param[in] msgId + * @param[in] read + */ + virtual void setMessageReadStatus( + uint32_t& token, const RsGxsGrpMsgIdPair& msgId, bool read) = 0; -//virtual bool setMessageStatus(const std::string &msgId, const uint32_t status, const uint32_t statusMask); -//virtual bool setGroupSubscribeFlags(const std::string &groupId, uint32_t subscribeFlags, uint32_t subscribeMask); + /** + * @brief Enable or disable auto-download for given channel + * @jsonapi{development} + * @param[in] groupId channel id + * @param[in] enable true to enable, false to disable + * @return false if something failed, true otherwhise + */ + virtual bool setChannelAutoDownload( + const RsGxsGroupId &groupId, bool enable) = 0; -//virtual bool groupRestoreKeys(const std::string &groupId); - virtual bool groupShareKeys(const RsGxsGroupId &groupId, std::set& peers)=0; + /** + * @brief Get auto-download option value for given channel + * @jsonapi{development} + * @param[in] groupId channel id + * @param[in] enabled storage for the auto-download option value + * @return false if something failed, true otherwhise + */ + virtual bool getChannelAutoDownload( + const RsGxsGroupId &groupId, bool& enabled) = 0; - // Overloaded subscribe fn. -virtual bool subscribeToGroup(uint32_t &token, const RsGxsGroupId &groupId, bool subscribe) = 0; + /** + * @brief Set download directory for the given channel + * @jsonapi{development} + * @param[in] channelId id of the channel + * @param[in] directory path + * @return false on error, true otherwise + */ + virtual bool setChannelDownloadDirectory( + const RsGxsGroupId& channelId, const std::string& directory) = 0; -virtual bool createGroup(uint32_t &token, RsGxsChannelGroup &group) = 0; -virtual bool createPost(uint32_t &token, RsGxsChannelPost &post) = 0; + /** + * @brief Get download directory for the given channel + * @jsonapi{development} + * @param[in] channelId id of the channel + * @param[out] directory reference to string where to store the path + * @return false on error, true otherwise + */ + virtual bool getChannelDownloadDirectory( const RsGxsGroupId& channelId, + std::string& directory ) = 0; -virtual bool updateGroup(uint32_t &token, RsGxsChannelGroup &group) = 0; + /** + * @brief Share channel publishing key + * This can be used to authorize other peers to post on the channel + * @jsonapi{development} + * param[in] groupId Channel id + * param[in] peers peers to which share the key + * @return false on error, true otherwise + */ + virtual bool groupShareKeys( + const RsGxsGroupId& groupId, const std::set& peers ) = 0; - // File Interface -virtual bool ExtraFileHash(const std::string &path, std::string filename) = 0; -virtual bool ExtraFileRemove(const RsFileHash &hash) = 0; + /** + * @brief Request subscription to a group. + * The action is performed asyncronously, so it could fail in a subsequent + * phase even after returning true. + * @jsonapi{development} + * @param[out] token Storage for RsTokenService token to track request + * status. + * @param[in] groupId Channel id + * @param[in] subscribe + * @return false on error, true otherwise + */ + virtual bool subscribeToGroup( uint32_t& token, const RsGxsGroupId &groupId, + bool subscribe ) = 0; + /** + * @brief Request channel creation. + * The action is performed asyncronously, so it could fail in a subsequent + * phase even after returning true. + * @jsonapi{development} + * @param[out] token Storage for RsTokenService token to track request + * status. + * @param[in] group Channel data (name, description...) + * @return false on error, true otherwise + */ + virtual bool createGroup(uint32_t& token, RsGxsChannelGroup& group) = 0; + /** + * @brief Request post creation. + * The action is performed asyncronously, so it could fail in a subsequent + * phase even after returning true. + * @jsonapi{development} + * @param[out] token Storage for RsTokenService token to track request + * status. + * @param[in] post + * @return false on error, true otherwise + */ + virtual bool createPost(uint32_t& token, RsGxsChannelPost& post) = 0; + + /** + * @brief Request channel change. + * The action is performed asyncronously, so it could fail in a subsequent + * phase even after returning true. + * @jsonapi{development} + * @param[out] token Storage for RsTokenService token to track request + * status. + * @param[in] group Channel data (name, description...) with modifications + * @return false on error, true otherwise + */ + virtual bool updateGroup(uint32_t& token, RsGxsChannelGroup& group) = 0; + + /** + * @brief Share extra file + * Can be used to share extra file attached to a channel post + * @jsonapi{development} + * @param[in] path file path + * @return false on error, true otherwise + */ + virtual bool ExtraFileHash(const std::string& path) = 0; + + /** + * @brief Remove extra file from shared files + * @jsonapi{development} + * @param[in] hash hash of the file to remove + * @return false on error, true otherwise + */ + virtual bool ExtraFileRemove(const RsFileHash& hash) = 0; + + /** + * @brief Request remote channels search + * @jsonapi{development} + * @param[in] matchString string to look for in the search + * @param multiCallback function that will be called each time a search + * result is received + * @param[in] maxWait maximum wait time in seconds for search results + * @return false on error, true otherwise + */ + virtual bool turtleSearchRequest( + const std::string& matchString, + const std::function& multiCallback, + std::time_t maxWait = 300 ) = 0; + + ////////////////////////////////////////////////////////////////////////////// + /// Distant synchronisation methods /// + ////////////////////////////////////////////////////////////////////////////// + /// + virtual TurtleRequestId turtleGroupRequest(const RsGxsGroupId& group_id)=0; + virtual TurtleRequestId turtleSearchRequest(const std::string& match_string)=0; + virtual bool retrieveDistantSearchResults(TurtleRequestId req, std::map &results) =0; + virtual bool clearDistantSearchResults(TurtleRequestId req)=0; + virtual bool retrieveDistantGroup(const RsGxsGroupId& group_id,RsGxsChannelGroup& distant_group)=0; + + ////////////////////////////////////////////////////////////////////////////// }; - - - -#endif diff --git a/libretroshare/src/retroshare/rsgxscircles.h b/libretroshare/src/retroshare/rsgxscircles.h index 8ce446200..f01e92ef3 100644 --- a/libretroshare/src/retroshare/rsgxscircles.h +++ b/libretroshare/src/retroshare/rsgxscircles.h @@ -1,31 +1,27 @@ +/******************************************************************************* + * libretroshare/src/retroshare: rsgxscircles.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012-2012 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RETROSHARE_GXSCIRCLES_INTERFACE_H #define RETROSHARE_GXSCIRCLES_INTERFACE_H -/* - * libretroshare/src/retroshare: rsgxscircles.h - * - * RetroShare C++ Interface. - * - * Copyright 2012-2012 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - #include #include #include @@ -49,10 +45,9 @@ extern RsGxsCircles *rsGxsCircles; typedef RsPgpId RsPgpId; -// The meaning of the different circle types is: -// -// -static const uint32_t GXS_CIRCLE_TYPE_UNKNOWN = 0x0000 ; // not known. Is treated as public. +/// The meaning of the different circle types is: +/// TODO: convert to enum +static const uint32_t GXS_CIRCLE_TYPE_UNKNOWN = 0x0000 ; /// Used to detect uninizialized values. static const uint32_t GXS_CIRCLE_TYPE_PUBLIC = 0x0001 ; // not restricted to a circle static const uint32_t GXS_CIRCLE_TYPE_EXTERNAL = 0x0002 ; // restricted to an external circle, made of RsGxsId static const uint32_t GXS_CIRCLE_TYPE_YOUR_FRIENDS_ONLY = 0x0003 ; // restricted to a subset of friend nodes of a given RS node given by a RsPgpId list @@ -127,8 +122,8 @@ class RsGxsCircles: public RsGxsIfaceHelper { public: - RsGxsCircles(RsGxsIface *gxs) :RsGxsIfaceHelper(gxs) { return; } - virtual ~RsGxsCircles() { return; } + RsGxsCircles(RsGxsIface& gxs) :RsGxsIfaceHelper(gxs) {} + virtual ~RsGxsCircles() {} /* External Interface (Cached stuff) */ virtual bool getCircleDetails(const RsGxsCircleId &id, RsGxsCircleDetails &details) = 0; diff --git a/libretroshare/src/retroshare/rsgxscommon.h b/libretroshare/src/retroshare/rsgxscommon.h index b1579e406..57b17ed35 100644 --- a/libretroshare/src/retroshare/rsgxscommon.h +++ b/libretroshare/src/retroshare/rsgxscommon.h @@ -31,37 +31,55 @@ #include #include "rsgxsifacetypes.h" +#include "serialiser/rsserializable.h" -class RsGxsFile +struct RsGxsFile : RsSerializable { - public: RsGxsFile(); std::string mName; RsFileHash mHash; uint64_t mSize; - //std::string mPath; + + /// @see RsSerializable + virtual void serial_process( RsGenericSerializer::SerializeJob j, + RsGenericSerializer::SerializeContext& ctx ) + { + RS_SERIAL_PROCESS(mName); + RS_SERIAL_PROCESS(mHash); + RS_SERIAL_PROCESS(mSize); + } }; -class RsGxsImage +struct RsGxsImage : RsSerializable { - public: - RsGxsImage(); + RsGxsImage(); ~RsGxsImage(); - RsGxsImage(const RsGxsImage& a); // TEMP use copy constructor and duplicate memory. -RsGxsImage &operator=(const RsGxsImage &a); // Need this as well? -//NB: Must make sure that we always use methods - to be consistent about malloc/free for this data. -static uint8_t *allocate(uint32_t size); -static void release(void *data); + /// Use copy constructor and duplicate memory. + RsGxsImage(const RsGxsImage& a); + + RsGxsImage &operator=(const RsGxsImage &a); // Need this as well? + + /** NB: Must make sure that we always use methods - to be consistent about + * malloc/free for this data. */ + static uint8_t *allocate(uint32_t size); + static void release(void *data); void take(uint8_t *data, uint32_t size); // Copies Pointer. void copy(uint8_t *data, uint32_t size); // Allocates and Copies. void clear(); // Frees. void shallowClear(); // Clears Pointer. - uint8_t *mData; uint32_t mSize; + uint8_t* mData; + /// @see RsSerializable + virtual void serial_process( RsGenericSerializer::SerializeJob j, + RsGenericSerializer::SerializeContext& ctx ) + { + RsTypeSerializer::TlvMemBlock_proxy b(mData, mSize); + RsTypeSerializer::serial_process(j, ctx, b, "mData"); + } }; @@ -84,17 +102,23 @@ namespace GXS_SERV { -class RsGxsVote +struct RsGxsVote : RsSerializable { - public: RsGxsVote(); RsMsgMetaData mMeta; uint32_t mVoteType; + + /// @see RsSerializable + virtual void serial_process( RsGenericSerializer::SerializeJob j, + RsGenericSerializer::SerializeContext& ctx ) + { + RS_SERIAL_PROCESS(mMeta); + RS_SERIAL_PROCESS(mVoteType); + } }; -class RsGxsComment +struct RsGxsComment : RsSerializable { - public: RsGxsComment(); RsMsgMetaData mMeta; std::string mComment; @@ -109,6 +133,19 @@ class RsGxsComment // This is filled in if detailed Comment Data is called. std::list mVotes; + /// @see RsSerializable + virtual void serial_process( RsGenericSerializer::SerializeJob j, + RsGenericSerializer::SerializeContext& ctx ) + { + RS_SERIAL_PROCESS(mMeta); + RS_SERIAL_PROCESS(mComment); + RS_SERIAL_PROCESS(mUpVotes); + RS_SERIAL_PROCESS(mDownVotes); + RS_SERIAL_PROCESS(mScore); + RS_SERIAL_PROCESS(mOwnVote); + RS_SERIAL_PROCESS(mVotes); + } + const std::ostream &print(std::ostream &out, std::string indent = "", std::string varName = "") const { out << indent << varName << " of RsGxsComment Values ###################" << std::endl; mMeta.print(out, indent + " ", "mMeta"); diff --git a/libretroshare/src/retroshare/rsgxsdistsync.h b/libretroshare/src/retroshare/rsgxsdistsync.h new file mode 100644 index 000000000..df597f03a --- /dev/null +++ b/libretroshare/src/retroshare/rsgxsdistsync.h @@ -0,0 +1,92 @@ +/* + * RetroShare C++ Interface. + * + * Copyright 2018 by Cyril Soler + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License Version 2 as published by the Free Software Foundation. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA. + * + * Please report all bugs and problems to "retroshare@lunamutt.com". + * + */ + +#pragma once + +#include "retroshare/rsfiles.h" +#include "retroshare/rsturtle.h" + +typedef RsPeerId RsGxsNetTunnelVirtualPeerId ; + +struct RsGxsNetTunnelVirtualPeerInfo +{ + enum { RS_GXS_NET_TUNNEL_VP_STATUS_UNKNOWN = 0x00, // unknown status. + RS_GXS_NET_TUNNEL_VP_STATUS_TUNNEL_OK = 0x01, // tunnel has been established and we're waiting for virtual peer id + RS_GXS_NET_TUNNEL_VP_STATUS_ACTIVE = 0x02 // virtual peer id is known. Data can transfer. + }; + + RsGxsNetTunnelVirtualPeerInfo() : vpid_status(RS_GXS_NET_TUNNEL_VP_STATUS_UNKNOWN), last_contact(0),side(0) { memset(encryption_master_key,0,32) ; } + virtual ~RsGxsNetTunnelVirtualPeerInfo(){} + + uint8_t vpid_status ; // status of the peer + time_t last_contact ; // last time some data was sent/recvd + uint8_t side ; // client/server + uint8_t encryption_master_key[32]; + + TurtleVirtualPeerId turtle_virtual_peer_id ; // turtle peer to use when sending data to this vpid. + + RsGxsGroupId group_id ; // group that virtual peer is providing + uint16_t service_id ; // this is used for checkng consistency of the incoming data +}; + +struct RsGxsNetTunnelGroupInfo +{ + enum GroupStatus { + RS_GXS_NET_TUNNEL_GRP_STATUS_UNKNOWN = 0x00, // unknown status + RS_GXS_NET_TUNNEL_GRP_STATUS_IDLE = 0x01, // no virtual peers requested, just waiting + RS_GXS_NET_TUNNEL_GRP_STATUS_VPIDS_AVAILABLE = 0x02 // some virtual peers are available. Data can be read/written + }; + + enum GroupPolicy { + RS_GXS_NET_TUNNEL_GRP_POLICY_UNKNOWN = 0x00, // nothing has been set + RS_GXS_NET_TUNNEL_GRP_POLICY_PASSIVE = 0x01, // group is available for server side tunnels, but does not explicitely request tunnels + RS_GXS_NET_TUNNEL_GRP_POLICY_ACTIVE = 0x02, // group will only explicitely request tunnels if none available + RS_GXS_NET_TUNNEL_GRP_POLICY_REQUESTING = 0x03, // group explicitely requests tunnels + }; + + RsGxsNetTunnelGroupInfo() : group_policy(RS_GXS_NET_TUNNEL_GRP_POLICY_PASSIVE),group_status(RS_GXS_NET_TUNNEL_GRP_STATUS_IDLE),last_contact(0) {} + + GroupPolicy group_policy ; + GroupStatus group_status ; + time_t last_contact ; + RsFileHash hash ; + uint16_t service_id ; + + std::set virtual_peers ; // list of which virtual peers provide this group. Can me more than 1. +}; + +// This class is here to provide statistics about GXS dist sync internals. It +// +class RsGxsDistSync +{ + public: + virtual void getStatistics( + std::map& groups, // groups on the client and server side + std::map& virtual_peers, // current virtual peers, which group they provide, and how to talk to them through turtle + std::map& turtle_vpid_to_net_tunnel_vpid, + Bias20Bytes& bias + ) const =0; +}; + +extern RsGxsDistSync *rsGxsDistSync ; + diff --git a/libretroshare/src/retroshare/rsgxsflags.h b/libretroshare/src/retroshare/rsgxsflags.h index 921c843fa..b2645aaab 100644 --- a/libretroshare/src/retroshare/rsgxsflags.h +++ b/libretroshare/src/retroshare/rsgxsflags.h @@ -1,3 +1,24 @@ +/******************************************************************************* + * libretroshare/src/retroshare: rsgxsflags.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012-2018 by Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RSGXSFLAGS_H #define RSGXSFLAGS_H diff --git a/libretroshare/src/retroshare/rsgxsforums.h b/libretroshare/src/retroshare/rsgxsforums.h index b1e7733af..802603ce5 100644 --- a/libretroshare/src/retroshare/rsgxsforums.h +++ b/libretroshare/src/retroshare/rsgxsforums.h @@ -1,31 +1,27 @@ +/******************************************************************************* + * libretroshare/src/retroshare: rsgxsforums.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012-2012 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RETROSHARE_GXS_FORUM_GUI_INTERFACE_H #define RETROSHARE_GXS_FORUM_GUI_INTERFACE_H -/* - * libretroshare/src/retroshare: rsgxsforum.h - * - * RetroShare C++ Interface. - * - * Copyright 2012-2012 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - #include #include #include @@ -67,8 +63,7 @@ class RsGxsForums: public RsGxsIfaceHelper { public: - explicit RsGxsForums(RsGxsIface *gxs) - :RsGxsIfaceHelper(gxs) {} + explicit RsGxsForums(RsGxsIface& gxs) : RsGxsIfaceHelper(gxs) {} virtual ~RsGxsForums() {} /* Specific Service Data */ diff --git a/libretroshare/src/retroshare/rsgxsiface.h b/libretroshare/src/retroshare/rsgxsiface.h index 36c660ef8..7fbf4b691 100644 --- a/libretroshare/src/retroshare/rsgxsiface.h +++ b/libretroshare/src/retroshare/rsgxsiface.h @@ -31,31 +31,69 @@ #include "retroshare/rsgxsservice.h" #include "gxs/rsgxsdata.h" #include "retroshare/rsgxsifacetypes.h" +#include "util/rsdeprecate.h" +#include "serialiser/rsserializable.h" + +/*! + * This structure is used to transport group summary information when a GXS + * service is searched. It contains the group information as well as a context + * string to tell where the information was found. It is more compact than a + * GroupMeta object, so as to make search responses as light as possible. + */ +struct RsGxsGroupSummary : RsSerializable +{ + RsGxsGroupSummary() : + mPublishTs(0), mNumberOfMessages(0),mLastMessageTs(0), + mSignFlags(0),mPopularity(0) {} + + RsGxsGroupId mGroupId; + std::string mGroupName; + RsGxsId mAuthorId; + time_t mPublishTs; + uint32_t mNumberOfMessages; + time_t mLastMessageTs; + uint32_t mSignFlags; + uint32_t mPopularity; + + std::string mSearchContext; + + /// @see RsSerializable::serial_process + void serial_process( RsGenericSerializer::SerializeJob j, + RsGenericSerializer::SerializeContext& ctx ) + { + RS_SERIAL_PROCESS(mGroupId); + RS_SERIAL_PROCESS(mGroupName); + RS_SERIAL_PROCESS(mAuthorId); + RS_SERIAL_PROCESS(mPublishTs); + RS_SERIAL_PROCESS(mNumberOfMessages); + RS_SERIAL_PROCESS(mLastMessageTs); + RS_SERIAL_PROCESS(mSignFlags); + RS_SERIAL_PROCESS(mPopularity); + RS_SERIAL_PROCESS(mSearchContext); + } +}; + /*! * Stores ids of changed gxs groups and messages. It is used to notify the GUI about changes. */ -class RsGxsChanges +struct RsGxsChanges { -public: RsGxsChanges(): mService(0){} RsTokenService *mService; std::map > mMsgs; std::map > mMsgsMeta; std::list mGrps; std::list mGrpsMeta; + std::list mDistantSearchReqs; }; /*! * All implementations must offer thread safety */ -class RsGxsIface +struct RsGxsIface { -public: - - virtual ~RsGxsIface(){}; - -public: + virtual ~RsGxsIface() {} /*! * Gxs services should call this for automatic handling of diff --git a/libretroshare/src/retroshare/rsgxsifacehelper.h b/libretroshare/src/retroshare/rsgxsifacehelper.h index fbe12570e..5a8c2d5fd 100644 --- a/libretroshare/src/retroshare/rsgxsifacehelper.h +++ b/libretroshare/src/retroshare/rsgxsifacehelper.h @@ -7,6 +7,7 @@ * RetroShare GXS. Convenience interface implementation * * Copyright 2012 by Christopher Evi-Parker + * Copyright (C) 2018 Gioacchino Mazzurco * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -26,29 +27,30 @@ * */ +#include +#include + #include "retroshare/rsgxsiface.h" #include "retroshare/rsreputations.h" #include "rsgxsflags.h" +#include "util/rsdeprecate.h" /*! - * The simple idea of this class is to implement the simple interface functions - * of gen exchange. - * This class provides convenience implementations of: - * - Handle msg and group changes (client class must pass changes sent by RsGenExchange to it) - * - subscription to groups - * - retrieval of msgs and group ids and meta info + * This class only make method of internal members visible tu upper level to + * offer a more friendly API. + * This is just a workaround to awkward GXS API design, do not take it as an + * example for your coding. + * To properly fix the API design many changes with the implied chain reactions + * are necessary, so at this point this workaround seems acceptable. */ -class RsGxsIfaceHelper +struct RsGxsIfaceHelper { -public: - - /*! - * - * @param gxs handle to RsGenExchange instance of service (Usually the service class itself) - */ - RsGxsIfaceHelper(RsGxsIface* gxs) - : mGxs(gxs) - {} + /*! + * @param gxs handle to RsGenExchange instance of service (Usually the + * service class itself) + */ + RsGxsIfaceHelper(RsGxsIface& gxs) : + mGxs(gxs), mTokenService(*gxs.getTokenService()) {} ~RsGxsIfaceHelper(){} @@ -59,15 +61,7 @@ public: */ void receiveChanges(std::vector &changes) { - mGxs->receiveChanges(changes); - } - - /*! - * @return handle to token service for this GXS service - */ - RsTokenService* getTokenService() - { - return mGxs->getTokenService(); + mGxs.receiveChanges(changes); } /* Generic Lists */ @@ -81,7 +75,7 @@ public: bool getGroupList(const uint32_t &token, std::list &groupIds) { - return mGxs->getGroupList(token, groupIds); + return mGxs.getGroupList(token, groupIds); } /*! @@ -93,7 +87,7 @@ public: bool getMsgList(const uint32_t &token, GxsMsgIdResult& msgIds) { - return mGxs->getMsgList(token, msgIds); + return mGxs.getMsgList(token, msgIds); } /*! @@ -104,7 +98,7 @@ public: */ bool getMsgRelatedList(const uint32_t &token, MsgRelatedIdResult &msgIds) { - return mGxs->getMsgRelatedList(token, msgIds); + return mGxs.getMsgRelatedList(token, msgIds); } /*! @@ -115,7 +109,7 @@ public: bool getGroupSummary(const uint32_t &token, std::list &groupInfo) { - return mGxs->getGroupMeta(token, groupInfo); + return mGxs.getGroupMeta(token, groupInfo); } /*! @@ -126,7 +120,7 @@ public: bool getMsgSummary(const uint32_t &token, GxsMsgMetaMap &msgInfo) { - return mGxs->getMsgMeta(token, msgInfo); + return mGxs.getMsgMeta(token, msgInfo); } /*! @@ -136,7 +130,7 @@ public: */ bool getMsgRelatedSummary(const uint32_t &token, GxsMsgRelatedMetaMap &msgInfo) { - return mGxs->getMsgRelatedMeta(token, msgInfo); + return mGxs.getMsgRelatedMeta(token, msgInfo); } /*! @@ -147,7 +141,7 @@ public: */ bool subscribeToGroup(uint32_t& token, const RsGxsGroupId& grpId, bool subscribe) { - return mGxs->subscribeToGroup(token, grpId, subscribe); + return mGxs.subscribeToGroup(token, grpId, subscribe); } /*! @@ -159,7 +153,7 @@ public: */ bool acknowledgeMsg(const uint32_t& token, std::pair& msgId) { - return mGxs->acknowledgeTokenMsg(token, msgId); + return mGxs.acknowledgeTokenMsg(token, msgId); } /*! @@ -171,7 +165,7 @@ public: */ bool acknowledgeGrp(const uint32_t& token, RsGxsGroupId& grpId) { - return mGxs->acknowledgeTokenGrp(token, grpId); + return mGxs.acknowledgeTokenGrp(token, grpId); } /*! @@ -182,7 +176,7 @@ public: */ bool getServiceStatistic(const uint32_t& token, GxsServiceStatistic& stats) { - return mGxs->getServiceStatistic(token, stats); + return mGxs.getServiceStatistic(token, stats); } /*! @@ -193,7 +187,7 @@ public: */ bool getGroupStatistic(const uint32_t& token, GxsGroupStatistic& stats) { - return mGxs->getGroupStatistic(token, stats); + return mGxs.getGroupStatistic(token, stats); } /*! @@ -206,7 +200,7 @@ public: */ void setGroupReputationCutOff(uint32_t& token, const RsGxsGroupId& grpId, int CutOff) { - return mGxs->setGroupReputationCutOff(token, grpId, CutOff); + return mGxs.setGroupReputationCutOff(token, grpId, CutOff); } /*! @@ -214,36 +208,111 @@ public: */ uint32_t getDefaultStoragePeriod() { - return mGxs->getDefaultStoragePeriod(); + return mGxs.getDefaultStoragePeriod(); } uint32_t getStoragePeriod(const RsGxsGroupId& grpId) { - return mGxs->getStoragePeriod(grpId); + return mGxs.getStoragePeriod(grpId); } void setStoragePeriod(const RsGxsGroupId& grpId,uint32_t age_in_secs) { - mGxs->setStoragePeriod(grpId,age_in_secs); + mGxs.setStoragePeriod(grpId,age_in_secs); } uint32_t getDefaultSyncPeriod() { - return mGxs->getDefaultSyncPeriod(); + return mGxs.getDefaultSyncPeriod(); } uint32_t getSyncPeriod(const RsGxsGroupId& grpId) { - return mGxs->getSyncPeriod(grpId); + return mGxs.getSyncPeriod(grpId); } void setSyncPeriod(const RsGxsGroupId& grpId,uint32_t age_in_secs) { - mGxs->setSyncPeriod(grpId,age_in_secs); + mGxs.setSyncPeriod(grpId,age_in_secs); } RsReputations::ReputationLevel minReputationForForwardingMessages(uint32_t group_sign_flags,uint32_t identity_flags) { - return mGxs->minReputationForForwardingMessages(group_sign_flags,identity_flags); + return mGxs.minReputationForForwardingMessages(group_sign_flags,identity_flags); } -private: - RsGxsIface* mGxs; + /// @see RsTokenService::requestGroupInfo + bool requestGroupInfo( uint32_t& token, const RsTokReqOptions& opts, + const std::list &groupIds ) + { return mTokenService.requestGroupInfo(token, 0, opts, groupIds); } + + /// @see RsTokenService::requestGroupInfo + bool requestGroupInfo(uint32_t& token, const RsTokReqOptions& opts) + { return mTokenService.requestGroupInfo(token, 0, opts); } + + /// @see RsTokenService::requestMsgInfo + bool requestMsgInfo( uint32_t& token, + const RsTokReqOptions& opts, const GxsMsgReq& msgIds ) + { return mTokenService.requestMsgInfo(token, 0, opts, msgIds); } + + /// @see RsTokenService::requestMsgInfo + bool requestMsgInfo( + uint32_t& token, const RsTokReqOptions& opts, + const std::list& grpIds ) + { return mTokenService.requestMsgInfo(token, 0, opts, grpIds); } + + /// @see RsTokenService::requestMsgRelatedInfo + bool requestMsgRelatedInfo( + uint32_t& token, const RsTokReqOptions& opts, + const std::vector& msgIds ) + { return mTokenService.requestMsgRelatedInfo(token, 0, opts, msgIds); } + + /** + * @jsonapi{development} + * @param[in] token + */ + RsTokenService::GxsRequestStatus requestStatus(uint32_t token) + { return mTokenService.requestStatus(token); } + + /// @see RsTokenService::requestServiceStatistic + void requestServiceStatistic(uint32_t& token) + { mTokenService.requestServiceStatistic(token); } + + /// @see RsTokenService::requestGroupStatistic + void requestGroupStatistic(uint32_t& token, const RsGxsGroupId& grpId) + { mTokenService.requestGroupStatistic(token, grpId); } + + /// @see RsTokenService::cancelRequest + bool cancelRequest(uint32_t token) + { return mTokenService.cancelRequest(token); } + + /** + * @deprecated + * Token service methods are already exposed by this helper, so you should + * not need to get token service pointer directly anymore. + */ + RS_DEPRECATED RsTokenService* getTokenService() { return &mTokenService; } + +protected: + /** + * Block caller while request is being processed. + * Useful for blocking API implementation. + * @param[in] token token associated to the request caller is waiting for + * @param[in] maxWait maximum waiting time in milliseconds + */ + RsTokenService::GxsRequestStatus waitToken( + uint32_t token, + std::chrono::milliseconds maxWait = std::chrono::milliseconds(500) ) + { + auto timeout = std::chrono::steady_clock::now() + maxWait; + auto st = requestStatus(token); + while( !(st == RsTokenService::FAILED || st >= RsTokenService::COMPLETE) + && std::chrono::steady_clock::now() < timeout ) + { + std::this_thread::sleep_for(std::chrono::milliseconds(2)); + st = requestStatus(token); + } + return st; + } + +private: + RsGxsIface& mGxs; + RsTokenService& mTokenService; }; #endif // RSGXSIFACEIMPL_H diff --git a/libretroshare/src/retroshare/rsgxsifacetypes.h b/libretroshare/src/retroshare/rsgxsifacetypes.h index 071b6bd46..8c90cb3b2 100644 --- a/libretroshare/src/retroshare/rsgxsifacetypes.h +++ b/libretroshare/src/retroshare/rsgxsifacetypes.h @@ -1,30 +1,25 @@ -/* - * rsgxsifacetypes.h - * - * Copyright (C) 2013 crispy - * Copyright (C) 2018 Gioacchino Mazzurco - * - * 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 . - */ - -/* - * rsgxsifacetypes.h - * - * Created on: 28 Feb 2013 - * Author: crispy - */ - +/******************************************************************************* + * libretroshare/src/retroshare: rsgxsifacetypes.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright (C) 2013 crispy * + * Copyright (C) 2018 Gioacchino Mazzurco * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RSGXSIFACETYPES_H_ #define RSGXSIFACETYPES_H_ @@ -69,18 +64,18 @@ struct RsGroupMetaData : RsSerializable RsGxsGroupId mGroupId; std::string mGroupName; - uint32_t mGroupFlags; // Combination of FLAG_PRIVACY_PRIVATE | FLAG_PRIVACY_RESTRICTED | FLAG_PRIVACY_PUBLIC - uint32_t mSignFlags; // Combination of RSGXS_GROUP_SIGN_PUBLISH_MASK & RSGXS_GROUP_SIGN_AUTHOR_MASK. + uint32_t mGroupFlags; // Combination of FLAG_PRIVACY_PRIVATE | FLAG_PRIVACY_RESTRICTED | FLAG_PRIVACY_PUBLIC: diffusion + uint32_t mSignFlags; // Combination of RSGXS_GROUP_SIGN_PUBLISH_MASK & RSGXS_GROUP_SIGN_AUTHOR_MASK, i.e. what signatures are required for parent and child msgs time_t mPublishTs; // Mandatory. - RsGxsId mAuthorId; // Optional. + RsGxsId mAuthorId; // Author of the group. Left to "000....0" if anonymous // for circles - RsGxsCircleId mCircleId; - uint32_t mCircleType; + RsGxsCircleId mCircleId; // Id of the circle to which the group is restricted + uint32_t mCircleType; // combination of CIRCLE_TYPE_{ PUBLIC,EXTERNAL,YOUR_FRIENDS_ONLY,LOCAL,EXT_SELF,YOUR_EYES_ONLY } // other stuff. - uint32_t mAuthenFlags; + uint32_t mAuthenFlags; // Actually not used yet. RsGxsGroupId mParentGrpId; // BELOW HERE IS LOCAL DATA, THAT IS NOT FROM MSG. @@ -124,7 +119,7 @@ struct RsGroupMetaData : RsSerializable -struct RsMsgMetaData +struct RsMsgMetaData : RsSerializable { RsMsgMetaData() : mPublishTs(0), mMsgFlags(0), mMsgStatus(0), mChildTs(0) {} @@ -155,6 +150,24 @@ struct RsMsgMetaData time_t mChildTs; std::string mServiceString; // Service Specific Free-Form extra storage. + /// @see RsSerializable + virtual void serial_process( RsGenericSerializer::SerializeJob j, + RsGenericSerializer::SerializeContext& ctx ) + { + RS_SERIAL_PROCESS(mGroupId); + RS_SERIAL_PROCESS(mMsgId); + RS_SERIAL_PROCESS(mThreadId); + RS_SERIAL_PROCESS(mParentId); + RS_SERIAL_PROCESS(mOrigMsgId); + RS_SERIAL_PROCESS(mAuthorId); + RS_SERIAL_PROCESS(mMsgName); + RS_SERIAL_PROCESS(mPublishTs); + RS_SERIAL_PROCESS(mMsgFlags); + RS_SERIAL_PROCESS(mMsgStatus); + RS_SERIAL_PROCESS(mChildTs); + RS_SERIAL_PROCESS(mServiceString); + } + const std::ostream &print(std::ostream &out, std::string indent = "", std::string varName = "") const { out << indent << varName << " of RsMsgMetaData Values ###################" << std::endl diff --git a/libretroshare/src/retroshare/rsgxsservice.h b/libretroshare/src/retroshare/rsgxsservice.h index b8b98940a..9e217a04a 100644 --- a/libretroshare/src/retroshare/rsgxsservice.h +++ b/libretroshare/src/retroshare/rsgxsservice.h @@ -1,3 +1,24 @@ +/******************************************************************************* + * libretroshare/src/retroshare: rsgxsservice.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright (C) 2015 Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RSGXSSERVICE_H #define RSGXSSERVICE_H @@ -6,6 +27,7 @@ #include "retroshare/rstokenservice.h" struct RsMsgMetaData ; +typedef uint32_t TurtleRequestId; typedef std::map > GxsMsgMetaMap; typedef std::map > GxsMsgRelatedMetaMap; @@ -18,7 +40,7 @@ typedef std::map > GxsMsgRelatedMe struct RsGxsNotify { enum NotifyType - { TYPE_PUBLISH, TYPE_RECEIVE, TYPE_PROCESSED, TYPE_PUBLISHKEY }; + { TYPE_PUBLISHED, TYPE_RECEIVED_NEW, TYPE_PROCESSED, TYPE_RECEIVED_PUBLISHKEY, TYPE_RECEIVED_DISTANT_SEARCH_RESULTS }; virtual ~RsGxsNotify() {} virtual NotifyType getType() = 0; @@ -39,6 +61,17 @@ private: bool mMetaChange; }; +class RsGxsDistantSearchResultChange: public RsGxsNotify +{ +public: + RsGxsDistantSearchResultChange(TurtleRequestId id,const RsGxsGroupId& group_id) : mRequestId(id),mGroupId(group_id){} + + NotifyType getType() { return TYPE_RECEIVED_DISTANT_SEARCH_RESULTS ; } + + TurtleRequestId mRequestId ; + RsGxsGroupId mGroupId; +}; + /*! * Relevant to message changes */ diff --git a/libretroshare/src/retroshare/rsgxstrans.h b/libretroshare/src/retroshare/rsgxstrans.h index b78191d97..bee1e11ec 100644 --- a/libretroshare/src/retroshare/rsgxstrans.h +++ b/libretroshare/src/retroshare/rsgxstrans.h @@ -91,7 +91,7 @@ public: std::vector outgoing_records; }; - RsGxsTrans(RsGxsIface *gxs) : RsGxsIfaceHelper(gxs) {} + RsGxsTrans(RsGxsIface& gxs) : RsGxsIfaceHelper(gxs) {} virtual ~RsGxsTrans() {} diff --git a/libretroshare/src/retroshare/rsgxstunnel.h b/libretroshare/src/retroshare/rsgxstunnel.h index 4d3588c9f..ce7798300 100644 --- a/libretroshare/src/retroshare/rsgxstunnel.h +++ b/libretroshare/src/retroshare/rsgxstunnel.h @@ -1,28 +1,24 @@ -/* - * libretroshare/src/services: rsgrouter.h - * - * Services for RetroShare. - * - * Copyright 2013 by Cyril Soler - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "csoler@users.sourceforge.net". - * - */ - +/******************************************************************************* + * libretroshare/src/retroshare: rsgxstunnel.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2013 by Cyril Soler * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once #include "util/rsdir.h" diff --git a/libretroshare/src/retroshare/rshistory.h b/libretroshare/src/retroshare/rshistory.h index 77e30b35d..eff72e237 100644 --- a/libretroshare/src/retroshare/rshistory.h +++ b/libretroshare/src/retroshare/rshistory.h @@ -1,31 +1,27 @@ +/******************************************************************************* + * libretroshare/src/retroshare: rshistory.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2011 by Thunder * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RS_HISTORY_INTERFACE_H #define RS_HISTORY_INTERFACE_H -/* - * libretroshare/src/retroshare: rshistory.h - * - * RetroShare C++ . - * - * Copyright 2011 by Thunder. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - class RsHistory; class ChatId; diff --git a/libretroshare/src/retroshare/rsidentity.h b/libretroshare/src/retroshare/rsidentity.h index 47da42de4..687d3d3a5 100644 --- a/libretroshare/src/retroshare/rsidentity.h +++ b/libretroshare/src/retroshare/rsidentity.h @@ -1,32 +1,28 @@ +/******************************************************************************* + * libretroshare/src/retroshare: rsidentity.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright (C) 2012 Robert Fernie * + * Copyright (C) 2018 Gioacchino Mazzurco * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RETROSHARE_IDENTITY_GUI_INTERFACE_H #define RETROSHARE_IDENTITY_GUI_INTERFACE_H -/* - * libretroshare/src/retroshare: rsidentity.h - * - * RetroShare C++ Interface. - * - * Copyright (C) 2012 Robert Fernie. - * Copyright (C) 2018 Gioacchino Mazzurco - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - #include #include #include @@ -343,7 +339,7 @@ struct RsIdentityDetails : RsSerializable struct RsIdentity : RsGxsIfaceHelper { - explicit RsIdentity(RsGxsIface *gxs): RsGxsIfaceHelper(gxs) {} + explicit RsIdentity(RsGxsIface& gxs): RsGxsIfaceHelper(gxs) {} virtual ~RsIdentity() {} /********************************************************************************************/ diff --git a/libretroshare/src/retroshare/rsids.h b/libretroshare/src/retroshare/rsids.h index 21a8fd754..3f0deaca9 100644 --- a/libretroshare/src/retroshare/rsids.h +++ b/libretroshare/src/retroshare/rsids.h @@ -1,3 +1,25 @@ +/******************************************************************************* + * libretroshare/src/retroshare: rsids.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2013 by Cyril Soler * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ + // This class aims at defining a generic ID type that is a list of bytes. It // can be converted into a hexadecial string for printing, mainly) or for // compatibility with old methods. @@ -238,12 +260,14 @@ static const uint32_t RS_GENERIC_ID_GXS_TUNNEL_ID_TYPE = 0x0010 ; static const uint32_t RS_GENERIC_ID_GXS_DISTANT_CHAT_ID_TYPE = 0x0011 ; static const uint32_t RS_GENERIC_ID_NODE_GROUP_ID_TYPE = 0x0012 ; static const uint32_t RS_GENERIC_ID_SHA256_ID_TYPE = 0x0013 ; +static const uint32_t RS_GENERIC_ID_20_BYTES_UNTYPED = 0x0014 ; typedef t_RsGenericIdType< SSL_ID_SIZE , false, RS_GENERIC_ID_SSL_ID_TYPE> SSLIdType ; typedef t_RsGenericIdType< PGP_KEY_ID_SIZE , true, RS_GENERIC_ID_PGP_ID_TYPE> PGPIdType ; typedef t_RsGenericIdType< SHA1_SIZE , false, RS_GENERIC_ID_SHA1_ID_TYPE> Sha1CheckSum ; typedef t_RsGenericIdType< SHA256_SIZE , false, RS_GENERIC_ID_SHA256_ID_TYPE> Sha256CheckSum ; typedef t_RsGenericIdType< PGP_KEY_FINGERPRINT_SIZE, true, RS_GENERIC_ID_PGP_FINGERPRINT_TYPE> PGPFingerprintType ; +typedef t_RsGenericIdType< SHA1_SIZE , true, RS_GENERIC_ID_20_BYTES_UNTYPED> Bias20Bytes ; typedef t_RsGenericIdType< CERT_SIGN_LEN , false, RS_GENERIC_ID_GXS_GROUP_ID_TYPE > GXSGroupId ; typedef t_RsGenericIdType< CERT_SIGN_LEN , false, RS_GENERIC_ID_GXS_ID_TYPE > GXSId ; diff --git a/libretroshare/src/retroshare/rsiface.h b/libretroshare/src/retroshare/rsiface.h index 2eb905e3a..643e404c0 100644 --- a/libretroshare/src/retroshare/rsiface.h +++ b/libretroshare/src/retroshare/rsiface.h @@ -1,32 +1,27 @@ +/******************************************************************************* + * libretroshare/src/retroshare: rsiface.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2006 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RETROSHARE_GUI_INTERFACE_H #define RETROSHARE_GUI_INTERFACE_H -/* - * "$Id: rsiface.h,v 1.9 2007-04-21 19:08:51 rmf24 Exp $" - * - * RetroShare C++ Interface. - * - * Copyright 2004-2006 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - #include "retroshare/rsnotify.h" #include "rstypes.h" diff --git a/libretroshare/src/retroshare/rsinit.h b/libretroshare/src/retroshare/rsinit.h index 18326d3a1..c99978aea 100644 --- a/libretroshare/src/retroshare/rsinit.h +++ b/libretroshare/src/retroshare/rsinit.h @@ -1,31 +1,27 @@ +/******************************************************************************* + * libretroshare/src/retroshare: rsinit.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2006 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RETROSHARE_INIT_INTERFACE_H #define RETROSHARE_INIT_INTERFACE_H -/* - * "$Id: rsiface.h,v 1.9 2007-04-21 19:08:51 rmf24 Exp $" - * - * RetroShare C++ Interface. - * - * Copyright 2004-2006 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - // Initialize ok, result >= 0 #define RS_INIT_OK 0 // Initialize ok #define RS_INIT_HAVE_ACCOUNT 1 // Initialize ok, have account @@ -47,132 +43,231 @@ #include #include +struct RsLoginHelper; + +/** + * Pointer to global instance of RsLoginHelper + * @jsonapi{development} + */ +extern RsLoginHelper* rsLoginHelper; + /*! * Initialisation Class (not publicly disclosed to RsIFace) */ class RsInit { - public: - /* reorganised RsInit system */ +public: + enum LoadCertificateStatus : uint8_t + { + OK, /// Everything go as expected, no error occurred + ERR_ALREADY_RUNNING, /// Another istance is running already + ERR_CANT_ACQUIRE_LOCK, /// Another istance is already running? + ERR_UNKOWN /// Unkown error, maybe password is wrong? + }; - /*! - * PreLogin - * Call before init retroshare, initialises rsinitconfig's public attributes - */ - static void InitRsConfig() ; + /* reorganised RsInit system */ - /*! - * Should be called to load up ssl cert and private key, and intialises gpg - * this must be called before accessing rsserver (e.g. ::startupretroshare) - * @param argc passed from executable - * @param argv commandline arguments passed to executable - * @param strictCheck set to true if you want rs to continue executing if invalid argument passed and vice versa - * @return RS_INIT_... - */ - static int InitRetroShare(int argc, char **argv, bool strictCheck=true); + /*! + * PreLogin + * Call before init retroshare, initialises rsinitconfig's public attributes + */ + static void InitRsConfig(); - static bool isPortable(); - static bool isWindowsXP(); - static bool collectEntropy(uint32_t bytes) ; + /*! + * Should be called to load up ssl cert and private key, and intialises gpg + * this must be called before accessing rsserver (e.g. ::startupretroshare) + * @param argc passed from executable + * @param argv commandline arguments passed to executable + * @param strictCheck set to true if you want rs to continue executing if + * invalid argument passed and vice versa + * @return RS_INIT_... + */ + static int InitRetroShare(int argc, char **argv, bool strictCheck=true); - /*! - * Setup Hidden Location; - */ - static void SetHiddenLocation(const std::string& hiddenaddress, uint16_t port, bool useBob); + static bool isPortable(); + static bool isWindowsXP(); + static bool collectEntropy(uint32_t bytes) ; - static bool LoadPassword(const std::string& passwd) ; + /* + * Setup Hidden Location; + */ + static void SetHiddenLocation(const std::string& hiddenaddress, uint16_t port, bool useBob); - /*! + static bool LoadPassword(const std::string& passwd) ; + /* + * Final Certificate load. This can be called if: + * a) InitRetroshare() returns RS_INIT_HAVE_ACCOUNT -> autoLoad/password Set. + * b) or LoadPassword() + * + * This uses the preferredId from RsAccounts. + * This wrapper also locks the profile before finalising the login + */ + static LoadCertificateStatus LockAndLoadCertificates( + bool autoLoginNT, std::string& lockFilePath ); - * Final Certificate load. This can be called if: - * a) InitRetroshare() returns RS_INIT_HAVE_ACCOUNT -> autoLoad/password Set. - * b) or LoadPassword() - * - * This uses the preferredId from RsAccounts. - * This wrapper also locks the profile before finalising the login - */ - static int LockAndLoadCertificates(bool autoLoginNT, std::string& lockFilePath); + // Post Login Options + static bool getStartMinimised(); - /*! - * Post Login Options - */ + static int getSslPwdLen(); + static bool getAutoLogin(); + static void setAutoLogin(bool autoLogin); + static bool RsClearAutoLogin() ; - static bool getStartMinimised(); +private: + /** @brief Lock profile directory + * param[in] accountDir account directory to lock + * param[out] lockFilePath path of the created lock-file + */ + static LoadCertificateStatus LockConfigDirectory( + const std::string& accountDir, std::string& lockFilePath); - static int getSslPwdLen(); - static bool getAutoLogin(); - static void setAutoLogin(bool autoLogin); - static bool RsClearAutoLogin() ; - - private: - -#if 0 - /* Auto Login */ - static bool RsStoreAutoLogin() ; - static bool RsTryAutoLogin() ; -#endif - -// THESE CAN BE REMOVED FROM THE CLASS TOO. - /* Lock/unlock profile directory */ - static int LockConfigDirectory(const std::string& accountDir, std::string& lockFilePath); - static void UnlockConfigDirectory(); - - /* The true LoadCertificates() method */ - static int LoadCertificates(bool autoLoginNT) ; + /// @brief Unlock profile directory + static void UnlockConfigDirectory(); + static int LoadCertificates(bool autoLoginNT); }; -/* Seperate Class for dealing with Accounts */ +/* Seperate static Class for dealing with Accounts */ -namespace RsAccounts +class RsAccountsDetail ; + +class RsAccounts { - /** - * @brief ConfigDirectory (normally ~/.retroshare) you can call this method - * even before initialisation (you can't with some other methods) - * @see RsAccountsDetail::PathBaseDirectory() - */ - std::string ConfigDirectory(); +public: + // Should be called once before everything else. + + static bool init(const std::string &opt_base_dir, int& error_code); /** - * @brief DataDirectory - * you can call this method even before initialisation (you can't with some other methods) - * @param check if set to true and directory does not exist, return empty string - * @return path where global platform independent files are stored, like bdboot.txt or webinterface files - */ - std::string DataDirectory(bool check = true); + * @brief ConfigDirectory (normally ~/.retroshare) you can call this method + * even before initialisation (you can't with some other methods) + * + * On linux: ~/.retroshare/ + * + * @see RsAccountsDetail::PathBaseDirectory() + */ + static std::string ConfigDirectory(); - std::string PGPDirectory(); - std::string AccountDirectory(); + /** + * @brief DataDirectory + * you can call this method even before initialisation (you can't with some other methods) + * @param check if set to true and directory does not exist, return empty string + * @return path where global platform independent files are stored, like bdboot.txt or webinterface files + */ + static std::string systemDataDirectory(bool check = true); + static std::string PGPDirectory(); // PGP Accounts. - int GetPGPLogins(std::list &pgpIds); - int GetPGPLoginDetails(const RsPgpId& id, std::string &name, std::string &email); - bool GeneratePGPCertificate(const std::string&, const std::string& email, const std::string& passwd, RsPgpId &pgpId, const int keynumbits, std::string &errString); + static int GetPGPLogins(std::list &pgpIds); + static int GetPGPLoginDetails(const RsPgpId& id, std::string &name, std::string &email); + static bool GeneratePGPCertificate(const std::string&, const std::string& email, const std::string& passwd, RsPgpId &pgpId, const int keynumbits, std::string &errString); // PGP Support Functions. - bool ExportIdentity(const std::string& fname,const RsPgpId& pgp_id) ; - bool ImportIdentity(const std::string& fname,RsPgpId& imported_pgp_id,std::string& import_error) ; - bool ImportIdentityFromString(const std::string& data,RsPgpId& imported_pgp_id,std::string& import_error) ; - void GetUnsupportedKeys(std::map > &unsupported_keys); - bool CopyGnuPGKeyrings() ; + static bool ExportIdentity(const std::string& fname,const RsPgpId& pgp_id) ; + static bool ImportIdentity(const std::string& fname,RsPgpId& imported_pgp_id,std::string& import_error) ; + static bool ImportIdentityFromString(const std::string& data,RsPgpId& imported_pgp_id,std::string& import_error) ; + static void GetUnsupportedKeys(std::map > &unsupported_keys); + static bool CopyGnuPGKeyrings() ; // Rs Accounts - bool SelectAccount(const RsPeerId& id); + static bool SelectAccount(const RsPeerId& id); + static bool GetPreferredAccountId(RsPeerId &id); + static bool GetAccountIds(std::list &ids); - bool GetPreferredAccountId(RsPeerId &id); - bool GetAccountIds(std::list &ids); - bool GetAccountDetails(const RsPeerId &id, - RsPgpId &gpgId, std::string &gpgName, - std::string &gpgEmail, std::string &location); + static bool GetAccountDetails(const RsPeerId &id, RsPgpId &gpgId, std::string &gpgName, std::string &gpgEmail, std::string &location); - bool GenerateSSLCertificate(const RsPgpId& pgp_id, const std::string& org, const std::string& loc, const std::string& country, const bool ishiddenloc, const std::string& passwd, RsPeerId &sslId, std::string &errString); + static bool createNewAccount( + const RsPgpId& pgp_id, const std::string& org, + const std::string& loc, const std::string& country, + bool ishiddenloc, bool is_auto_tor, const std::string& passwd, + RsPeerId &sslId, std::string &errString ); + static void storeSelectedAccount() ; + + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // All methods bellow can only be called ones SelectAccount() as been called. // + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + static bool getCurrentAccountOptions(bool& is_hidden,bool& is_tor_auto,bool& is_first_time) ; + + static bool checkCreateAccountDirectory(); // Generate the hierarchy of directories below ~/.retroshare/[SSL dir]/ + static bool isHiddenNode() ; // true if the running node is a hidden node. Used to choose which services to start. + static bool isTorAuto() ; // true if the running node is a hidden node using automated Tor management + + static std::string AccountDirectory(); // linux: ~/.retroshare/[SSL dir]/ + static std::string AccountKeysDirectory(); // linux: ~/.retroshare/[SSL dir]/keys/ + static std::string AccountPathCertFile(); // linux: ~/.retroshare/[SSL dir]/keys/user_cert.pem + static std::string AccountPathKeyFile(); // linux: ~/.retroshare/[SSL dir]/keys/user_pk.pem + static std::string AccountLocationName(); + + static bool lockPreferredAccount() ; // are these methods any useful?? + static void unlockPreferredAccount() ; + +private: + static RsAccountsDetail *rsAccounts ; }; +/** + * This helper class have been implemented because there was not reasonable way + * to login in the API that could be exposed via JSON API + */ +struct RsLoginHelper +{ + /** + * @brief Normal way to attempt login + * @jsonapi{development} + * @param[in] account Id of the account to which attempt login + * @param[in] password Password for the given account + * @return RsInit::OK if login attempt success, error code otherwhise + */ + RsInit::LoadCertificateStatus attemptLogin( + const RsPeerId& account, const std::string& password ); + struct Location : RsSerializable + { + RsPeerId mLocationId; + RsPgpId mPgpId; + std::string mLocationName; + std::string mPpgName; + + /// @see RsSerializable::serial_process + void serial_process( RsGenericSerializer::SerializeJob j, + RsGenericSerializer::SerializeContext& ctx ); + }; + + /** + * @brief Get locations and associated information + * @jsonapi{development} + * @param[out] locations storage for the retrived locations + */ + void getLocations(std::vector& locations); + + /** + * @brief Creates a new RetroShare location, and log in once is created + * @jsonapi{development} + * @param[inout] location provide input information to generate the location + * and storage to output the data of the generated location + * @param[in] password to protect and unlock the associated PGP key + * @param[in] makeHidden pass true to create an hidden location. UNTESTED! + * @param[in] makeAutoTor pass true to create an automatically configured + * Tor hidden location. UNTESTED! + * @param[out] errorMessage if some error occurred human readable error + * message + * @return true if success, false otherwise + */ + bool createLocation( RsLoginHelper::Location& location, + const std::string& password, bool makeHidden, + bool makeAutoTor, std::string& errorMessage ); + + /** + * @brief Close RetroShare session + * @jsonapi{development} + */ + void closeSession(); +}; #endif diff --git a/libretroshare/src/retroshare/rsmsgs.h b/libretroshare/src/retroshare/rsmsgs.h index bf36100b3..a459a489c 100644 --- a/libretroshare/src/retroshare/rsmsgs.h +++ b/libretroshare/src/retroshare/rsmsgs.h @@ -1,32 +1,27 @@ +/******************************************************************************* + * libretroshare/src/retroshare: rsmsgs.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2007-2008 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RS_MSG_GUI_INTERFACE_H #define RS_MSG_GUI_INTERFACE_H -/* - * libretroshare/src/rsiface: rsmsgs.h - * - * RetroShare C++ Interface. - * - * Copyright 2007-2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - #include #include #include @@ -97,7 +92,7 @@ const ChatLobbyFlags RS_CHAT_LOBBY_FLAGS_PGP_SIGNED ( 0x00000010 ) ; // requi typedef uint64_t ChatLobbyId ; typedef uint64_t ChatLobbyMsgId ; -typedef std::string ChatLobbyNickName ; +typedef std::string ChatLobbyNickName ; typedef uint64_t MessageId ; @@ -284,7 +279,7 @@ struct DistantChatPeerInfo // Identifier for an chat endpoint like // neighbour peer, distant peer, chatlobby, broadcast -class ChatId +class ChatId : RsSerializable { public: ChatId(); @@ -315,17 +310,28 @@ public: // this defines from which peer the status string came from RsPeerId broadcast_status_peer_id; private: - enum Type { TYPE_NOT_SET, - TYPE_PRIVATE, // private chat with directly connected friend, peer_id is valid - TYPE_PRIVATE_DISTANT, // private chat with distant peer, gxs_id is valid - TYPE_LOBBY, // chat lobby id, lobby_id is valid - TYPE_BROADCAST // message to/from all connected peers - }; + enum Type : uint8_t + { TYPE_NOT_SET, + TYPE_PRIVATE, // private chat with directly connected friend, peer_id is valid + TYPE_PRIVATE_DISTANT, // private chat with distant peer, gxs_id is valid + TYPE_LOBBY, // chat lobby id, lobby_id is valid + TYPE_BROADCAST // message to/from all connected peers + }; Type type; RsPeerId peer_id; DistantChatPeerId distant_chat_id; ChatLobbyId lobby_id; + + // RsSerializable interface +public: + void serial_process(RsGenericSerializer::SerializeJob j, RsGenericSerializer::SerializeContext &ctx) { + RS_SERIAL_PROCESS(broadcast_status_peer_id); + RS_SERIAL_PROCESS(type); + RS_SERIAL_PROCESS(peer_id); + RS_SERIAL_PROCESS(distant_chat_id); + RS_SERIAL_PROCESS(lobby_id); + } }; class ChatMessage @@ -345,49 +351,90 @@ public: //bool system_message; }; -class ChatLobbyInvite +class ChatLobbyInvite : RsSerializable { - public: - ChatLobbyId lobby_id ; - RsPeerId peer_id ; - std::string lobby_name ; - std::string lobby_topic ; - ChatLobbyFlags lobby_flags ; +public: + ChatLobbyId lobby_id ; + RsPeerId peer_id ; + std::string lobby_name ; + std::string lobby_topic ; + ChatLobbyFlags lobby_flags ; + + // RsSerializable interface +public: + void serial_process(RsGenericSerializer::SerializeJob j, RsGenericSerializer::SerializeContext &ctx) { + RS_SERIAL_PROCESS(lobby_id); + RS_SERIAL_PROCESS(peer_id); + RS_SERIAL_PROCESS(lobby_name); + RS_SERIAL_PROCESS(lobby_topic); + RS_SERIAL_PROCESS(lobby_flags); + } }; -class VisibleChatLobbyRecord +class VisibleChatLobbyRecord : RsSerializable { public: VisibleChatLobbyRecord(): lobby_id(0), total_number_of_peers(0), last_report_time(0){} - ChatLobbyId lobby_id ; // unique id of the lobby - std::string lobby_name ; // name to use for this lobby - std::string lobby_topic ; // topic to use for this lobby - std::set participating_friends ; // list of direct friend who participate. + ChatLobbyId lobby_id ; // unique id of the lobby + std::string lobby_name ; // name to use for this lobby + std::string lobby_topic ; // topic to use for this lobby + std::set participating_friends ; // list of direct friend who participate. - uint32_t total_number_of_peers ; // total number of particpating peers. Might not be - time_t last_report_time ; // last time the lobby was reported. - ChatLobbyFlags lobby_flags ; // see RS_CHAT_LOBBY_PRIVACY_LEVEL_PUBLIC / RS_CHAT_LOBBY_PRIVACY_LEVEL_PRIVATE + uint32_t total_number_of_peers ; // total number of particpating peers. Might not be + time_t last_report_time ; // last time the lobby was reported. + ChatLobbyFlags lobby_flags ; // see RS_CHAT_LOBBY_PRIVACY_LEVEL_PUBLIC / RS_CHAT_LOBBY_PRIVACY_LEVEL_PRIVATE + + // RsSerializable interface +public: + void serial_process(RsGenericSerializer::SerializeJob j, RsGenericSerializer::SerializeContext &ctx) { + RS_SERIAL_PROCESS(lobby_id); + RS_SERIAL_PROCESS(lobby_name); + RS_SERIAL_PROCESS(lobby_topic); + RS_SERIAL_PROCESS(participating_friends); + + RS_SERIAL_PROCESS(total_number_of_peers); + RS_SERIAL_PROCESS(last_report_time); + RS_SERIAL_PROCESS(lobby_flags); + } }; -class ChatLobbyInfo +class ChatLobbyInfo : RsSerializable { - public: - ChatLobbyId lobby_id ; // unique id of the lobby - std::string lobby_name ; // name to use for this lobby - std::string lobby_topic ; // topic to use for this lobby - std::set participating_friends ; // list of direct friend who participate. Used to broadcast sent messages. - RsGxsId gxs_id ; // ID to sign messages +public: + ChatLobbyId lobby_id ; // unique id of the lobby + std::string lobby_name ; // name to use for this lobby + std::string lobby_topic ; // topic to use for this lobby + std::set participating_friends ; // list of direct friend who participate. Used to broadcast sent messages. + RsGxsId gxs_id ; // ID to sign messages - ChatLobbyFlags lobby_flags ; // see RS_CHAT_LOBBY_PRIVACY_LEVEL_PUBLIC / RS_CHAT_LOBBY_PRIVACY_LEVEL_PRIVATE - std::map gxs_ids ; // list of non direct friend who participate. Used to display only. - time_t last_activity ; // last recorded activity. Useful for removing dead lobbies. + ChatLobbyFlags lobby_flags ; // see RS_CHAT_LOBBY_PRIVACY_LEVEL_PUBLIC / RS_CHAT_LOBBY_PRIVACY_LEVEL_PRIVATE + std::map gxs_ids ; // list of non direct friend who participate. Used to display only. + time_t last_activity ; // last recorded activity. Useful for removing dead lobbies. + + // RsSerializable interface +public: + void serial_process(RsGenericSerializer::SerializeJob j, RsGenericSerializer::SerializeContext &ctx) { + RS_SERIAL_PROCESS(lobby_id); + RS_SERIAL_PROCESS(lobby_name); + RS_SERIAL_PROCESS(lobby_topic); + RS_SERIAL_PROCESS(participating_friends); + RS_SERIAL_PROCESS(gxs_id); + + RS_SERIAL_PROCESS(lobby_flags); + RS_SERIAL_PROCESS(gxs_ids); + RS_SERIAL_PROCESS(last_activity); + } }; std::ostream &operator<<(std::ostream &out, const Rs::Msgs::MessageInfo &info); class RsMsgs; +/** + * @brief Pointer to retroshare's message service + * @jsonapi{development} + */ extern RsMsgs *rsMsgs; class RsMsgs @@ -443,15 +490,59 @@ virtual bool resetMessageStandardTagTypes(Rs::Msgs::MsgTagType& tags) = 0; // sendChat for broadcast, private, lobby and private distant chat // note: for lobby chat, you first have to subscribe to a lobby // for private distant chat, it is reqired to have an active distant chat session -virtual bool sendChat(ChatId id, std::string msg) = 0; -virtual uint32_t getMaxMessageSecuritySize(int type) = 0; -virtual void sendStatusString(const ChatId& id,const std::string& status_string) = 0; -virtual void clearChatLobby(const ChatId& id) = 0; + /** + * @brief sendChat send a chat message to a given id + * @jsonapi{development} + * @param[in] id id to send the message + * @param[in] msg message to send + * @return true on success + */ + virtual bool sendChat(ChatId id, std::string msg) = 0; -virtual void setCustomStateString(const std::string& status_string) = 0 ; -virtual std::string getCustomStateString() = 0 ; -virtual std::string getCustomStateString(const RsPeerId& peer_id) = 0 ; + /** + * @brief getMaxMessageSecuritySize get the maximum size of a chta message + * @jsonapi{development} + * @param[in] type chat type + * @return maximum size or zero for infinite + */ + virtual uint32_t getMaxMessageSecuritySize(int type) = 0; + + /** + * @brief sendStatusString send a status string + * @jsonapi{development} + * @param[in] id chat id to send the status string to + * @param[in] status_string status string + */ + virtual void sendStatusString(const ChatId &id, const std::string &status_string) = 0; + + /** + * @brief clearChatLobby clear a chat lobby + * @jsonapi{development} + * @param[in] id chat lobby id to clear + */ + virtual void clearChatLobby(const ChatId &id) = 0; + + /** + * @brief setCustomStateString set your custom status message + * @jsonapi{development} + * @param[in] status_string status message + */ + virtual void setCustomStateString(const std::string &status_string) = 0; + + /** + * @brief getCustomStateString get your custom status message + * @return status message + */ + virtual std::string getCustomStateString() = 0; + + /** + * @brief getCustomStateString get the custom status message from a peer + * @jsonapi{development} + * @param[in] peer_id peer id to the peer you want to get the status message from + * @return status message + */ + virtual std::string getCustomStateString(const RsPeerId &peer_id) = 0; // get avatar data for peer pid virtual void getAvatarData(const RsPeerId& pid,unsigned char *& data,int& size) = 0 ; @@ -459,29 +550,139 @@ virtual void getAvatarData(const RsPeerId& pid,unsigned char *& data,int& size) virtual void setOwnAvatarData(const unsigned char *data,int size) = 0 ; virtual void getOwnAvatarData(unsigned char *& data,int& size) = 0 ; -/****************************************/ -/* Chat lobbies */ -/****************************************/ + /****************************************/ + /* Chat lobbies */ + /****************************************/ + /** + * @brief joinVisibleChatLobby join a lobby that is visible + * @jsonapi{development} + * @param[in] lobby_id lobby to join to + * @param[in] own_id chat id to use + * @return true on success + */ + virtual bool joinVisibleChatLobby(const ChatLobbyId &lobby_id, const RsGxsId &own_id) = 0 ; -virtual bool joinVisibleChatLobby(const ChatLobbyId& lobby_id,const RsGxsId& own_id) = 0 ; -/// get ids of subscribed lobbies -virtual void getChatLobbyList(std::list& cl_list) = 0; -/// get lobby info of a subscribed chat lobby. Returns true if lobby id is valid. -virtual bool getChatLobbyInfo(const ChatLobbyId& id,ChatLobbyInfo& info) = 0 ; -/// get info about all lobbies, subscribed and unsubscribed -virtual void getListOfNearbyChatLobbies(std::vector& public_lobbies) = 0 ; -virtual void invitePeerToLobby(const ChatLobbyId& lobby_id,const RsPeerId& peer_id) = 0; -virtual bool acceptLobbyInvite(const ChatLobbyId& id,const RsGxsId& identity) = 0 ; -virtual void denyLobbyInvite(const ChatLobbyId& id) = 0 ; -virtual void getPendingChatLobbyInvites(std::list& invites) = 0; -virtual void unsubscribeChatLobby(const ChatLobbyId& lobby_id) = 0; -virtual bool setIdentityForChatLobby(const ChatLobbyId& lobby_id,const RsGxsId& nick) = 0; -virtual bool getIdentityForChatLobby(const ChatLobbyId& lobby_id,RsGxsId& nick) = 0 ; -virtual bool setDefaultIdentityForChatLobby(const RsGxsId& nick) = 0; -virtual void getDefaultIdentityForChatLobby(RsGxsId& id) = 0 ; -virtual void setLobbyAutoSubscribe(const ChatLobbyId& lobby_id, const bool autoSubscribe) = 0 ; -virtual bool getLobbyAutoSubscribe(const ChatLobbyId& lobby_id) = 0 ; -virtual ChatLobbyId createChatLobby(const std::string& lobby_name,const RsGxsId& lobby_identity,const std::string& lobby_topic,const std::set& invited_friends,ChatLobbyFlags lobby_privacy_type) = 0 ; + /** + * @brief getChatLobbyList get ids of subscribed lobbies + * @jsonapi{development} + * @param[out] cl_list lobby list + */ + virtual void getChatLobbyList(std::list &cl_list) = 0; + + /** + * @brief getChatLobbyInfo get lobby info of a subscribed chat lobby. Returns true if lobby id is valid. + * @jsonapi{development} + * @param[in] id id to get infos from + * @param[out] info lobby infos + * @return true on success + */ + virtual bool getChatLobbyInfo(const ChatLobbyId &id, ChatLobbyInfo &info) = 0 ; + + /** + * @brief getListOfNearbyChatLobbies get info about all lobbies, subscribed and unsubscribed + * @jsonapi{development} + * @param[out] public_lobbies list of all visible lobbies + */ + virtual void getListOfNearbyChatLobbies(std::vector &public_lobbies) = 0 ; + + /** + * @brief invitePeerToLobby invite a peer to join a lobby + * @jsonapi{development} + * @param[in] lobby_id lobby it to invite into + * @param[in] peer_id peer to invite + */ + virtual void invitePeerToLobby(const ChatLobbyId &lobby_id, const RsPeerId &peer_id) = 0; + + /** + * @brief acceptLobbyInvite accept a chat invite + * @jsonapi{development} + * @param[in] id chat lobby id you were invited into and you want to join + * @param[in] identity chat identity to use + * @return true on success + */ + virtual bool acceptLobbyInvite(const ChatLobbyId &id, const RsGxsId &identity) = 0 ; + + /** + * @brief denyLobbyInvite deny a chat lobby invite + * @jsonapi{development} + * @param[in] id chat lobby id you were invited into + */ + virtual void denyLobbyInvite(const ChatLobbyId &id) = 0 ; + + /** + * @brief getPendingChatLobbyInvites get a list of all pending chat lobby invites + * @jsonapi{development} + * @param[out] invites list of all pending chat lobby invites + */ + virtual void getPendingChatLobbyInvites(std::list &invites) = 0; + + /** + * @brief unsubscribeChatLobby leave a chat lobby + * @jsonapi{development} + * @param[in] lobby_id lobby to leave + */ + virtual void unsubscribeChatLobby(const ChatLobbyId &lobby_id) = 0; + + /** + * @brief setIdentityForChatLobby set the chat identit + * @jsonapi{development} + * @param[in] lobby_id lobby to change the chat idnetity for + * @param[in] nick new chat identity + * @return true on success + */ + virtual bool setIdentityForChatLobby(const ChatLobbyId &lobby_id, const RsGxsId &nick) = 0; + + /** + * @brief getIdentityForChatLobby + * @jsonapi{development} + * @param[in] lobby_id lobby to get the chat id from + * @param[out] nick chat identity + * @return true on success + */ + virtual bool getIdentityForChatLobby(const ChatLobbyId &lobby_id, RsGxsId &nick) = 0 ; + + /** + * @brief setDefaultIdentityForChatLobby set the default identity used for chat lobbies + * @jsonapi{development} + * @param[in] nick chat identitiy to use + * @return true on success + */ + virtual bool setDefaultIdentityForChatLobby(const RsGxsId &nick) = 0; + + /** + * @brief getDefaultIdentityForChatLobby get the default identity used for chat lobbies + * @jsonapi{development} + * @param[out] id chat identitiy to use + */ + virtual void getDefaultIdentityForChatLobby(RsGxsId &id) = 0 ; + + /** + * @brief setLobbyAutoSubscribe enable or disable auto subscribe for a chat lobby + * @jsonapi{development} + * @param[in] lobby_id lobby to auto (un)subscribe + * @param[in] autoSubscribe set value for auto subscribe + */ + virtual void setLobbyAutoSubscribe(const ChatLobbyId &lobby_id, const bool autoSubscribe) = 0 ; + + /** + * @brief getLobbyAutoSubscribe get current value of auto subscribe + * @jsonapi{development} + * @param[in] lobby_id lobby to get value from + * @return wether lobby has auto subscribe enabled or disabled + */ + virtual bool getLobbyAutoSubscribe(const ChatLobbyId &lobby_id) = 0 ; + + /** + * @brief createChatLobby create a new chat lobby + * @jsonapi{development} + * @param[in] lobby_name lobby name + * @param[in] lobby_identity chat id to use for new lobby + * @param[in] lobby_topic lobby toppic + * @param[in] invited_friends list of friends to invite + * @param[in] lobby_privacy_type flag for new chat lobby + * @return chat id of new lobby + */ + virtual ChatLobbyId createChatLobby(const std::string &lobby_name, const RsGxsId &lobby_identity, const std::string &lobby_topic, const std::set &invited_friends, ChatLobbyFlags lobby_privacy_type) = 0 ; /****************************************/ /* Distant chat */ diff --git a/libretroshare/src/retroshare/rsnotify.h b/libretroshare/src/retroshare/rsnotify.h index b73c577e9..cf7777e9e 100644 --- a/libretroshare/src/retroshare/rsnotify.h +++ b/libretroshare/src/retroshare/rsnotify.h @@ -1,32 +1,27 @@ +/******************************************************************************* + * libretroshare/src/retroshare: rsnotify.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2007-2008 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RS_NOTIFY_GUI_INTERFACE_H #define RS_NOTIFY_GUI_INTERFACE_H -/* - * libretroshare/src/rsiface: rsnotify.h - * - * RetroShare C++ Interface. - * - * Copyright 2007-2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - #include #include #include @@ -186,7 +181,7 @@ class RsFeedItem // This mechanism can be used in plugins, new services, etc. // -class NotifyClient ; +class NotifyClient; class RsNotify { @@ -213,40 +208,41 @@ class RsNotify class NotifyClient { - public: - NotifyClient() {} - virtual ~NotifyClient() {} +public: + NotifyClient() {} + virtual ~NotifyClient() {} - virtual void notifyListPreChange (int /* list */, int /* type */) {} - virtual void notifyListChange (int /* list */, int /* type */) {} - virtual void notifyErrorMsg (int /* list */, int /* sev */, std::string /* msg */) {} - virtual void notifyChatMessage (const ChatMessage& /* msg */) {} - virtual void notifyChatStatus (const ChatId& /* chat_id */, const std::string& /* status_string */) {} - virtual void notifyChatCleared (const ChatId& /* chat_id */) {} - virtual void notifyChatLobbyEvent (uint64_t /* lobby id */, uint32_t /* event type */ ,const RsGxsId& /* nickname */,const std::string& /* any string */) {} - virtual void notifyChatLobbyTimeShift (int /* time_shift*/) {} - virtual void notifyCustomState (const std::string& /* peer_id */, const std::string& /* status_string */) {} - virtual void notifyHashingInfo (uint32_t /* type */, const std::string& /* fileinfo */) {} - virtual void notifyTurtleSearchResult (uint32_t /* search_id */, const std::list& /* files */) {} - virtual void notifyPeerHasNewAvatar (std::string /* peer_id */) {} - virtual void notifyOwnAvatarChanged () {} - virtual void notifyOwnStatusMessageChanged () {} - virtual void notifyDiskFull (uint32_t /* location */, uint32_t /* size limit in MB */) {} - virtual void notifyPeerStatusChanged (const std::string& /* peer_id */, uint32_t /* status */) {} - virtual void notifyGxsChange (const RsGxsChanges& /* changes */) {} - virtual void notifyConnectionWithoutCert () {} + virtual void notifyListPreChange (int /* list */, int /* type */) {} + virtual void notifyListChange (int /* list */, int /* type */) {} + virtual void notifyErrorMsg (int /* list */, int /* sev */, std::string /* msg */) {} + virtual void notifyChatMessage (const ChatMessage& /* msg */) {} + virtual void notifyChatStatus (const ChatId& /* chat_id */, const std::string& /* status_string */) {} + virtual void notifyChatCleared (const ChatId& /* chat_id */) {} + virtual void notifyChatLobbyEvent (uint64_t /* lobby id */, uint32_t /* event type */ ,const RsGxsId& /* nickname */,const std::string& /* any string */) {} + virtual void notifyChatLobbyTimeShift (int /* time_shift*/) {} + virtual void notifyCustomState (const std::string& /* peer_id */, const std::string& /* status_string */) {} + virtual void notifyHashingInfo (uint32_t /* type */, const std::string& /* fileinfo */) {} + virtual void notifyTurtleSearchResult (const RsPeerId& /* pid */, uint32_t /* search_id */, const std::list& /* files */) {} +#warning MISSING CODE HERE + // virtual void notifyTurtleSearchResult (uint32_t /* search_id */, const std::list& /* groups */) {} + virtual void notifyPeerHasNewAvatar (std::string /* peer_id */) {} + virtual void notifyOwnAvatarChanged () {} + virtual void notifyOwnStatusMessageChanged () {} + virtual void notifyDiskFull (uint32_t /* location */, uint32_t /* size limit in MB */) {} + virtual void notifyPeerStatusChanged (const std::string& /* peer_id */, uint32_t /* status */) {} + virtual void notifyGxsChange (const RsGxsChanges& /* changes */) {} + virtual void notifyConnectionWithoutCert () {} - /* one or more peers has changed the states */ - virtual void notifyPeerStatusChangedSummary () {} - virtual void notifyDiscInfoChanged () {} + /* one or more peers has changed the states */ + virtual void notifyPeerStatusChangedSummary () {} + virtual void notifyDiscInfoChanged () {} - virtual bool askForDeferredSelfSignature (const void * /* data */, const uint32_t /* len */, unsigned char * /* sign */, unsigned int * /* signlen */,int& signature_result , std::string /*reason = ""*/) { signature_result = false ;return true; } - virtual void notifyDownloadComplete (const std::string& /* fileHash */) {} - virtual void notifyDownloadCompleteCount (uint32_t /* count */) {} - virtual void notifyHistoryChanged (uint32_t /* msgId */, int /* type */) {} - - virtual bool askForPassword (const std::string& /* title */, const std::string& /* key_details */, bool /* prev_is_bad */, std::string& /* password */,bool& /* cancelled */ ) { return false ;} - virtual bool askForPluginConfirmation (const std::string& /* plugin_filename */, const std::string& /* plugin_file_hash */,bool /* first_time */) { return false ;} + virtual bool askForDeferredSelfSignature (const void * /* data */, const uint32_t /* len */, unsigned char * /* sign */, unsigned int * /* signlen */,int& signature_result , std::string /*reason = ""*/) { signature_result = false ;return true; } + virtual void notifyDownloadComplete (const std::string& /* fileHash */) {} + virtual void notifyDownloadCompleteCount (uint32_t /* count */) {} + virtual void notifyHistoryChanged (uint32_t /* msgId */, int /* type */) {} + virtual bool askForPassword (const std::string& /* title */, const std::string& /* key_details */, bool /* prev_is_bad */, std::string& /* password */,bool& /* cancelled */ ) { return false ;} + virtual bool askForPluginConfirmation (const std::string& /* plugin_filename */, const std::string& /* plugin_file_hash */,bool /* first_time */) { return false ;} }; #endif diff --git a/libretroshare/src/retroshare/rspeers.h b/libretroshare/src/retroshare/rspeers.h index 7824daa11..a77a5c4b3 100644 --- a/libretroshare/src/retroshare/rspeers.h +++ b/libretroshare/src/retroshare/rspeers.h @@ -1,31 +1,27 @@ +/******************************************************************************* + * libretroshare/src/retroshare: rspeers.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2008 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RETROSHARE_PEER_GUI_INTERFACE_H #define RETROSHARE_PEER_GUI_INTERFACE_H -/* - * libretroshare/src/rsiface: rspeer.h - * - * RetroShare C++ Interface. - * - * Copyright 2004-2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - #include #include #include @@ -297,16 +293,25 @@ public: std::string cipher_version; }; -class RsGroupInfo +class RsGroupInfo : RsSerializable { public: - RsGroupInfo(); + RsGroupInfo(); - RsNodeGroupId id; - std::string name; - uint32_t flag; + RsNodeGroupId id; + std::string name; + uint32_t flag; - std::set peerIds; + std::set peerIds; + + // RsSerializable interface +public: + void serial_process(RsGenericSerializer::SerializeJob j, RsGenericSerializer::SerializeContext &ctx) { + RS_SERIAL_PROCESS(id); + RS_SERIAL_PROCESS(name); + RS_SERIAL_PROCESS(flag); + RS_SERIAL_PROCESS(peerIds); + } }; std::ostream &operator<<(std::ostream &out, const RsPeerDetails &detail); diff --git a/libretroshare/src/retroshare/rsphoto.h b/libretroshare/src/retroshare/rsphoto.h index 1e782d2ef..7e5b6ea99 100644 --- a/libretroshare/src/retroshare/rsphoto.h +++ b/libretroshare/src/retroshare/rsphoto.h @@ -1,31 +1,27 @@ +/******************************************************************************* + * libretroshare/src/retroshare: rsphoto.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2008-2012 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RSPHOTOV2_H #define RSPHOTOV2_H -/* - * libretroshare/src/retroshare: rsphoto.h - * - * RetroShare C++ Interface. - * - * Copyright 2008-2012 by Robert Fernie, Christopher Evi-Parker - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - #include #include #include diff --git a/libretroshare/src/retroshare/rsplugin.h b/libretroshare/src/retroshare/rsplugin.h index 6b8363c37..557f9a61d 100644 --- a/libretroshare/src/retroshare/rsplugin.h +++ b/libretroshare/src/retroshare/rsplugin.h @@ -1,28 +1,24 @@ -/* - * "$Id: rsiface.h,v 1.9 2007-04-21 19:08:51 rmf24 Exp $" - * - * RetroShare C++ Interface. - * - * Copyright 2011-2011 by Cyril Soler - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/retroshare: rsplugin.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2011-2011 by Cyril Soler * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once #include diff --git a/libretroshare/src/retroshare/rsposted.h b/libretroshare/src/retroshare/rsposted.h index 586449a47..12d729d7a 100644 --- a/libretroshare/src/retroshare/rsposted.h +++ b/libretroshare/src/retroshare/rsposted.h @@ -1,31 +1,27 @@ +/******************************************************************************* + * libretroshare/src/retroshare: rsposted.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2008-2012 by Robert Fernie, Christopher Evi-Parker * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RETROSHARE_GXS_RSPOSTED_GUI_INTERFACE_H #define RETROSHARE_GXS_RSPOSTED_GUI_INTERFACE_H -/* - * libretroshare/src/retroshare: rsposted.h - * - * RetroShare C++ Interface. - * - * Copyright 2008-2012 by Robert Fernie, Christopher Evi-Parker - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - #include #include #include @@ -78,7 +74,7 @@ class RsPosted : public RsGxsIfaceHelper, public RsGxsCommentService //static const uint32_t FLAG_MSGTYPE_POST; //static const uint32_t FLAG_MSGTYPE_MASK; - explicit RsPosted(RsGxsIface* gxs) : RsGxsIfaceHelper(gxs) {} + explicit RsPosted(RsGxsIface& gxs) : RsGxsIfaceHelper(gxs) {} virtual ~RsPosted() {} /* Specific Service Data */ diff --git a/libretroshare/src/retroshare/rsrtt.h b/libretroshare/src/retroshare/rsrtt.h index 6d9422562..e55220307 100644 --- a/libretroshare/src/retroshare/rsrtt.h +++ b/libretroshare/src/retroshare/rsrtt.h @@ -1,31 +1,27 @@ +/******************************************************************************* + * libretroshare/src/retroshare: rsposted.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2011-2011 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RETROSHARE_RTT_INTERFACE_H #define RETROSHARE_RTT_INTERFACE_H -/* - * libretroshare/src/retroshare: rsrtt.h - * - * RetroShare C++ Interface. - * - * Copyright 2011-2011 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - #include #include #include diff --git a/libretroshare/src/retroshare/rsservicecontrol.h b/libretroshare/src/retroshare/rsservicecontrol.h index 12d9dc5d2..1e22449ae 100644 --- a/libretroshare/src/retroshare/rsservicecontrol.h +++ b/libretroshare/src/retroshare/rsservicecontrol.h @@ -1,31 +1,27 @@ +/******************************************************************************* + * libretroshare/src/retroshare: rsservicecontrol.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2014-2014 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RETROSHARE_SERVICE_CONTROL_GUI_INTERFACE_H #define RETROSHARE_SERVICE_CONTROL_GUI_INTERFACE_H -/* - * libretroshare/src/rsiface: rsservicecontrol.h - * - * RetroShare C++ Interface. - * - * Copyright 2014 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - #include #include #include @@ -57,6 +53,8 @@ class RsServiceInfo // minimum version can communicate with. uint16_t mMinVersionMajor; uint16_t mMinVersionMinor; + + static unsigned int RsServiceInfoUIn16ToFullServiceId(uint16_t serviceType); }; diff --git a/libretroshare/src/retroshare/rsstatus.h b/libretroshare/src/retroshare/rsstatus.h index 00b82eab7..4698cd8b5 100644 --- a/libretroshare/src/retroshare/rsstatus.h +++ b/libretroshare/src/retroshare/rsstatus.h @@ -1,31 +1,27 @@ +/******************************************************************************* + * libretroshare/src/retroshare: rsstatus.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2007-2008 by Vinny Do, Chris Evi-Parker * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RS_STATUS_INTERFACE_H #define RS_STATUS_INTERFACE_H -/* - * libretroshare/src/rsiface: rsstatus.h - * - * RetroShare C++ . - * - * Copyright 2007-2008 by Vinny Do, Chris Evi-Parker. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - class RsStatus; extern RsStatus *rsStatus; diff --git a/libretroshare/src/retroshare/rstokenservice.h b/libretroshare/src/retroshare/rstokenservice.h index 079f34023..90c0694e6 100644 --- a/libretroshare/src/retroshare/rstokenservice.h +++ b/libretroshare/src/retroshare/rstokenservice.h @@ -1,31 +1,27 @@ +/******************************************************************************* + * libretroshare/src/retroshare: rstokenservice.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012-2012 by Robert Fernie, Chris Evi-Parker * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RSTOKENSERVICE_H #define RSTOKENSERVICE_H -/* - * libretroshare/src/retroshare: rstokenservice.h - * - * RetroShare C++ Interface. - * - * Copyright 2012-2012 by Robert Fernie, Christopher Evi-Parker - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - #include #include #include @@ -123,19 +119,19 @@ class RsTokenService public: - // TODO CLEANUP: This should be an enum - static const uint8_t GXS_REQUEST_V2_STATUS_FAILED; - static const uint8_t GXS_REQUEST_V2_STATUS_PENDING; - static const uint8_t GXS_REQUEST_V2_STATUS_PARTIAL; - static const uint8_t GXS_REQUEST_V2_STATUS_FINISHED_INCOMPLETE; - static const uint8_t GXS_REQUEST_V2_STATUS_COMPLETE; - static const uint8_t GXS_REQUEST_V2_STATUS_DONE; // ONCE ALL DATA RETRIEVED. - static const uint8_t GXS_REQUEST_V2_STATUS_CANCELLED; + enum GxsRequestStatus : uint8_t + { + FAILED, + PENDING, + PARTIAL, + COMPLETE, + DONE, /// Once all data has been retrived + CANCELLED + }; -public: - RsTokenService() { return; } - virtual ~RsTokenService() { return; } + RsTokenService() {} + virtual ~RsTokenService() {} /* Data Requests */ @@ -199,7 +195,7 @@ public: * @param token value of token to check status for * @return the current status of request */ - virtual uint32_t requestStatus(const uint32_t token) = 0; + virtual GxsRequestStatus requestStatus(const uint32_t token) = 0; /*! * This request statistics on amount of data held @@ -220,19 +216,14 @@ public: */ virtual void requestGroupStatistic(uint32_t& token, const RsGxsGroupId& grpId) = 0; - - /* Cancel Request */ - - /*! - * If this function returns false, it may be that the request has completed - * already. Useful for very expensive request. This is a blocking operation - * @param token the token of the request to cancel - * @return false if unusuccessful in cancelling request, true if successful - */ - virtual bool cancelRequest(const uint32_t &token) = 0; - - - + /*! + * @brief Cancel Request + * If this function returns false, it may be that the request has completed + * already. Useful for very expensive request. + * @param token the token of the request to cancel + * @return false if unusuccessful in cancelling request, true if successful + */ + virtual bool cancelRequest(const uint32_t &token) = 0; }; #endif // RSTOKENSERVICE_H diff --git a/libretroshare/src/retroshare/rsturtle.h b/libretroshare/src/retroshare/rsturtle.h index 7cef4fd77..6f5ac469c 100644 --- a/libretroshare/src/retroshare/rsturtle.h +++ b/libretroshare/src/retroshare/rsturtle.h @@ -1,31 +1,24 @@ -#ifndef RETROSHARE_TURTLE_GUI_INTERFACE_H -#define RETROSHARE_TURTLE_GUI_INTERFACE_H - -/* - * libretroshare/src/rsiface: rsturtle.h - * - * RetroShare C++ Interface. - * - * Copyright 2009 by Cyril Soler. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "csoler@users.sourceforge.net" - * - */ - +/******************************************************************************* + * libretroshare/src/retroshare: rsturtle.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2009-2018 by Cyril Soler * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once #include @@ -33,25 +26,47 @@ #include #include +#include "serialiser/rstlvbinary.h" #include "retroshare/rstypes.h" +#include "retroshare/rsgxsifacetypes.h" +#include "serialiser/rsserializable.h" namespace RsRegularExpression { class LinearizedExpression ; } class RsTurtleClientService ; class RsTurtle; -extern RsTurtle *rsTurtle ; + +/** + * Pointer to global instance of RsTurtle service implementation + */ +extern RsTurtle* rsTurtle; typedef uint32_t TurtleRequestId ; +typedef RsPeerId TurtleVirtualPeerId; -// This is the structure used to send back results of the turtle search -// to the notifyBase class, or send info to the GUI. - -struct TurtleFileInfo +/** + * This is the structure used to send back results of the turtle search, + * to other peers, to the notifyBase class, to the search caller or to the GUI. + */ +struct TurtleFileInfo : RsSerializable { - RsFileHash hash ; - std::string name ; - uint64_t size ; + uint64_t size; /// File size + RsFileHash hash; /// File hash + std::string name; /// File name + + /// @see RsSerializable::serial_process + void serial_process( RsGenericSerializer::SerializeJob j, + RsGenericSerializer::SerializeContext& ctx ) + { + RS_SERIAL_PROCESS(size); + RS_SERIAL_PROCESS(hash); + + // Use String TLV serial process for retrocompatibility + RsTypeSerializer::serial_process( + j, ctx, TLV_TYPE_STR_NAME, name, "name" ); + } }; + struct TurtleTunnelRequestDisplayInfo { uint32_t request_id ; // Id of the request @@ -93,7 +108,7 @@ class TurtleTrafficStatisticsInfo // class RsTurtle { - public: +public: RsTurtle() {} virtual ~RsTurtle() {} @@ -109,8 +124,9 @@ class RsTurtle // the request id, which will be further used by the gui to store results // as they come back. // - virtual TurtleRequestId turtleSearch(const std::string& match_string) = 0 ; - virtual TurtleRequestId turtleSearch(const RsRegularExpression::LinearizedExpression& expr) = 0 ; + virtual TurtleRequestId turtleSearch( + unsigned char *search_bin_data, uint32_t search_bin_data_len, + RsTurtleClientService* client_service ) = 0; // Initiates tunnel handling for the given file hash. tunnels. Launches // an exception if an error occurs during the initialization process. The @@ -155,5 +171,3 @@ class RsTurtle virtual void setMaxTRForwardRate(int max_tr_up_rate) = 0 ; virtual int getMaxTRForwardRate() const = 0 ; }; - -#endif diff --git a/libretroshare/src/retroshare/rstypes.h b/libretroshare/src/retroshare/rstypes.h index dcad22795..b1b35748c 100644 --- a/libretroshare/src/retroshare/rstypes.h +++ b/libretroshare/src/retroshare/rstypes.h @@ -1,32 +1,27 @@ +/******************************************************************************* + * libretroshare/src/retroshare: rsturtle.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2006 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RS_TYPES_GUI_INTERFACE_H #define RS_TYPES_GUI_INTERFACE_H -/* - * "$Id: rstypes.h,v 1.7 2007-05-05 16:10:05 rmf24 Exp $" - * - * RetroShare C++ Interface. - * - * Copyright 2004-2006 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - #include #include #include @@ -70,15 +65,25 @@ const uint32_t RS_CONFIG_DIRECTORY = 0x0002 ; const uint32_t RS_PGP_DIRECTORY = 0x0003 ; const uint32_t RS_DIRECTORY_COUNT = 0x0004 ; -class TransferInfo +struct TransferInfo : RsSerializable { - public: - /**** Need Some of these Fields ****/ - RsPeerId peerId; - std::string name; /* if has alternative name? */ - double tfRate; /* kbytes */ - int status; /* FT_STATE_... */ - uint64_t transfered ; // used when no chunkmap data is available + /**** Need Some of these Fields ****/ + RsPeerId peerId; + std::string name; /* if has alternative name? */ + double tfRate; /* kbytes */ + int status; /* FT_STATE_... */ + uint64_t transfered ; // used when no chunkmap data is available + + /// @see RsSerializable + void serial_process(RsGenericSerializer::SerializeJob j, + RsGenericSerializer::SerializeContext& ctx) + { + RS_SERIAL_PROCESS(peerId); + RS_SERIAL_PROCESS(name); + RS_SERIAL_PROCESS(tfRate); + RS_SERIAL_PROCESS(status); + RS_SERIAL_PROCESS(transfered); + } }; enum QueueMove { QUEUE_TOP = 0x00, @@ -87,9 +92,11 @@ enum QueueMove { QUEUE_TOP = 0x00, QUEUE_BOTTOM = 0x03 }; -enum DwlSpeed { SPEED_LOW = 0x00, - SPEED_NORMAL = 0x01, - SPEED_HIGH = 0x02 +enum DwlSpeed : uint8_t +{ + SPEED_LOW = 0x00, + SPEED_NORMAL = 0x01, + SPEED_HIGH = 0x02 }; @@ -176,54 +183,76 @@ const FileStorageFlags DIR_FLAGS_PERMISSIONS_MASK ( DIR_FLAGS_ANONYMOUS_DOW const FileStorageFlags DIR_FLAGS_LOCAL ( 0x1000 ); const FileStorageFlags DIR_FLAGS_REMOTE ( 0x2000 ); -class FileInfo +struct FileInfo : RsSerializable { - /* old BaseInfo Entries */ - public: + FileInfo(): + mId(0), searchId(0), size(0), avail(0), rank(0), age(0), + queue_position(0), transfered(0), tfRate(0), downloadStatus(0), + priority(SPEED_NORMAL), lastTS(0) {} - FileInfo() : mId(0), searchId(0), size(0), avail(0), rank(0), age(0), queue_position(0), - transfered(0), tfRate(0), downloadStatus(0), priority(SPEED_NORMAL), lastTS(0){} -// RsCertId id; /* key for matching everything */ + /// Combination of the four RS_DIR_FLAGS_*. Updated when the file is a local stored file. + FileStorageFlags storage_permission_flags; - FileStorageFlags storage_permission_flags; // Combination of the four RS_DIR_FLAGS_*. Updated when the file is a local stored file. - TransferRequestFlags transfer_info_flags ; // various flags from RS_FILE_HINTS_* + /// various flags from RS_FILE_HINTS_* + TransferRequestFlags transfer_info_flags; - /* allow this to be tweaked by the GUI Model */ - mutable unsigned int mId; /* (GUI) Model Id -> unique number */ + /** allow this to be tweaked by the GUI Model + * (GUI) Model Id -> unique number + */ + mutable unsigned int mId; - /* Old FileInfo Entries */ - public: - static const int kRsFiStatusNone = 0; - static const int kRsFiStatusStall = 1; - static const int kRsFiStatusProgress = 2; - static const int kRsFiStatusDone = 2; + /// 0 if none + int searchId; - /* FileInfo(); */ + std::string path; + std::string fname; + RsFileHash hash; + std::string ext; - int searchId; /* 0 if none */ - std::string path; - std::string fname; - RsFileHash hash; - std::string ext; + uint64_t size; + uint64_t avail; /// how much we have - uint64_t size; - uint64_t avail; /* how much we have */ + double rank; + int age; + uint32_t queue_position; - double rank; - int age; - uint32_t queue_position ; + /* Transfer Stuff */ + uint64_t transfered; + double tfRate; /// in kbytes + uint32_t downloadStatus; /// FT_STATE_DOWNLOADING & co. See rstypes.h + std::vector peers; - /* Transfer Stuff */ - uint64_t transfered; - double tfRate; /* in kbytes */ - uint32_t downloadStatus; // FT_STATE_DOWNLOADING & co. See rstypes.h - std::vector peers; + DwlSpeed priority; + time_t lastTS; - DwlSpeed priority ; - time_t lastTS; - - std::list parent_groups ; + std::list parent_groups; + + /// @see RsSerializable + void serial_process(RsGenericSerializer::SerializeJob j, + RsGenericSerializer::SerializeContext& ctx) + { + RS_SERIAL_PROCESS(storage_permission_flags); + RS_SERIAL_PROCESS(transfer_info_flags); + RS_SERIAL_PROCESS(mId); + RS_SERIAL_PROCESS(searchId); + RS_SERIAL_PROCESS(path); + RS_SERIAL_PROCESS(fname); + RS_SERIAL_PROCESS(hash); + RS_SERIAL_PROCESS(ext); + RS_SERIAL_PROCESS(size); + RS_SERIAL_PROCESS(avail); + RS_SERIAL_PROCESS(rank); + RS_SERIAL_PROCESS(age); + RS_SERIAL_PROCESS(queue_position); + RS_SERIAL_PROCESS(transfered); + RS_SERIAL_PROCESS(tfRate); + RS_SERIAL_PROCESS(downloadStatus); + RS_SERIAL_PROCESS(peers); + RS_SERIAL_PROCESS(priority); + RS_SERIAL_PROCESS(lastTS); + RS_SERIAL_PROCESS(parent_groups); + } }; std::ostream &operator<<(std::ostream &out, const FileInfo& info); @@ -273,36 +302,58 @@ class FileDetail class CompressedChunkMap ; -class FileChunksInfo +struct FileChunksInfo : RsSerializable { - public: - enum ChunkState { CHUNK_CHECKING=3, CHUNK_DONE=2, CHUNK_ACTIVE=1, CHUNK_OUTSTANDING=0 } ; - enum ChunkStrategy { CHUNK_STRATEGY_STREAMING, CHUNK_STRATEGY_RANDOM, CHUNK_STRATEGY_PROGRESSIVE } ; + enum ChunkState : uint8_t + { + CHUNK_OUTSTANDING = 0, + CHUNK_ACTIVE = 1, + CHUNK_DONE = 2, + CHUNK_CHECKING = 3 + }; - struct SliceInfo - { - uint32_t start ; - uint32_t size ; - RsPeerId peer_id ; - }; + enum ChunkStrategy : uint8_t + { + CHUNK_STRATEGY_STREAMING, + CHUNK_STRATEGY_RANDOM, + CHUNK_STRATEGY_PROGRESSIVE + }; - uint64_t file_size ; // real size of the file - uint32_t chunk_size ; // size of chunks - uint32_t strategy ; + struct SliceInfo + { + uint32_t start; + uint32_t size; + RsPeerId peer_id; + }; - // dl state of chunks. Only the last chunk may have size < chunk_size - std::vector chunks ; + uint64_t file_size; /// real size of the file + uint32_t chunk_size; /// size of chunks + ChunkStrategy strategy; - // For each source peer, gives the compressed bit map of have/don't have sate - std::map compressed_peer_availability_maps ; + /// dl state of chunks. Only the last chunk may have size < chunk_size + std::vector chunks; - // For each chunk (by chunk number), gives the completion of the chunk. - // - std::vector > active_chunks ; + /// For each source peer, gives the compressed bit map of have/don't have sate + std::map compressed_peer_availability_maps; - // The list of pending requests, chunk per chunk (by chunk id) - // - std::map > pending_slices ; + /// For each chunk (by chunk number), gives the completion of the chunk. + std::vector > active_chunks; + + /// The list of pending requests, chunk per chunk (by chunk id) + std::map > pending_slices; + + /// @see RsSerializable + void serial_process(RsGenericSerializer::SerializeJob j, + RsGenericSerializer::SerializeContext& ctx) + { + RS_SERIAL_PROCESS(file_size); + RS_SERIAL_PROCESS(chunk_size); + RS_SERIAL_PROCESS(strategy); + RS_SERIAL_PROCESS(chunks); + RS_SERIAL_PROCESS(compressed_peer_availability_maps); + RS_SERIAL_PROCESS(active_chunks); + //RS_SERIAL_PROCESS(pending_slices); + } }; class CompressedChunkMap : public RsSerializable diff --git a/libretroshare/src/retroshare/rsversion.h b/libretroshare/src/retroshare/rsversion.h index d194024d7..110d622fa 100644 --- a/libretroshare/src/retroshare/rsversion.h +++ b/libretroshare/src/retroshare/rsversion.h @@ -1,3 +1,24 @@ +/******************************************************************************* + * libretroshare/src/retroshare: rsversion.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012-2018 by Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #define RS_MAJOR_VERSION 0 #define RS_MINOR_VERSION 6 #define RS_BUILD_NUMBER 4 diff --git a/libretroshare/src/retroshare/rswiki.h b/libretroshare/src/retroshare/rswiki.h index 9db3ff7e6..feb7dead2 100644 --- a/libretroshare/src/retroshare/rswiki.h +++ b/libretroshare/src/retroshare/rswiki.h @@ -1,31 +1,27 @@ +/******************************************************************************* + * libretroshare/src/retroshare: rsturtle.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012-2012 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RETROSHARE_WIKI_GUI_INTERFACE_H #define RETROSHARE_WIKI_GUI_INTERFACE_H -/* - * libretroshare/src/retroshare: rswiki.h - * - * RetroShare C++ Interface. - * - * Copyright 2012-2012 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - #include #include #include @@ -115,10 +111,10 @@ std::ostream &operator<<(std::ostream &out, const RsWikiComment &comment); class RsWiki: public RsGxsIfaceHelper { - public: +public: - RsWiki(RsGxsIface *gxs): RsGxsIfaceHelper(gxs) { return; } -virtual ~RsWiki() { return; } + RsWiki(RsGxsIface& gxs): RsGxsIfaceHelper(gxs) {} + virtual ~RsWiki() {} /* Specific Service Data */ virtual bool getCollections(const uint32_t &token, std::vector &collections) = 0; diff --git a/libretroshare/src/retroshare/rswire.h b/libretroshare/src/retroshare/rswire.h index d9cdb7832..580d3f279 100644 --- a/libretroshare/src/retroshare/rswire.h +++ b/libretroshare/src/retroshare/rswire.h @@ -1,31 +1,27 @@ +/******************************************************************************* + * libretroshare/src/retroshare: rsturtle.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012-2012 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RETROSHARE_WIRE_GUI_INTERFACE_H #define RETROSHARE_WIRE_GUI_INTERFACE_H -/* - * libretroshare/src/retroshare: rswire.h - * - * RetroShare C++ Interface. - * - * Copyright 2012-2012 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - #include #include #include @@ -108,7 +104,7 @@ class RsWire: public RsGxsIfaceHelper { public: - explicit RsWire(RsGxsIface *gxs): RsGxsIfaceHelper(gxs) {} + explicit RsWire(RsGxsIface& gxs) : RsGxsIfaceHelper(gxs) {} virtual ~RsWire() {} /* Specific Service Data */ diff --git a/libretroshare/src/rsitems/itempriorities.h b/libretroshare/src/rsitems/itempriorities.h index f5008eef0..dc346b7c3 100644 --- a/libretroshare/src/rsitems/itempriorities.h +++ b/libretroshare/src/rsitems/itempriorities.h @@ -1,28 +1,24 @@ -/* - * libretroshare/src/serialiser: itempriorities.h - * - * 3P/PQI network interface for RetroShare. - * - * Copyright 2011-2011 by Cyril Soler - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "csoler@users.sourceforge.net" - * - */ - +/******************************************************************************* + * libretroshare/src/rsitems: rsitempriorities.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2011-2011 by Cyril Soler * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once #include diff --git a/libretroshare/src/rsitems/rsbanlistitems.cc b/libretroshare/src/rsitems/rsbanlistitems.cc index 44f908dee..f5dd9fca8 100644 --- a/libretroshare/src/rsitems/rsbanlistitems.cc +++ b/libretroshare/src/rsitems/rsbanlistitems.cc @@ -1,28 +1,24 @@ -/* - * libretroshare/src/serialiser: rsbanlist.cc - * - * RetroShare Serialiser. - * - * Copyright 2011 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/rsitems: rsbanlistitems.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2011 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "serialiser/rsbaseserial.h" #include "rsitems/rsbanlistitems.h" diff --git a/libretroshare/src/rsitems/rsbanlistitems.h b/libretroshare/src/rsitems/rsbanlistitems.h index 6aec4b115..2f22a199e 100644 --- a/libretroshare/src/rsitems/rsbanlistitems.h +++ b/libretroshare/src/rsitems/rsbanlistitems.h @@ -1,31 +1,27 @@ +/******************************************************************************* + * libretroshare/src/rsitems: rsbanlistitems.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2011 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RS_BANLIST_ITEMS_H #define RS_BANLIST_ITEMS_H -/* - * libretroshare/src/serialiser: rsbanlistitems.h - * - * RetroShare Serialiser. - * - * Copyright 2011 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - #include #include "rsitems/rsserviceids.h" diff --git a/libretroshare/src/rsitems/rsbwctrlitems.cc b/libretroshare/src/rsitems/rsbwctrlitems.cc index bfa172b45..759264aa0 100644 --- a/libretroshare/src/rsitems/rsbwctrlitems.cc +++ b/libretroshare/src/rsitems/rsbwctrlitems.cc @@ -1,28 +1,24 @@ -/* - * libretroshare/src/serialiser: rsbwctrlitems.cc - * - * RetroShare Serialiser. - * - * Copyright 2012 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/rsitems: rsbwctrlitems.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "serialiser/rsbaseserial.h" #include "rsitems/rsbwctrlitems.h" diff --git a/libretroshare/src/rsitems/rsbwctrlitems.h b/libretroshare/src/rsitems/rsbwctrlitems.h index 71ec641e1..300bd6f54 100644 --- a/libretroshare/src/rsitems/rsbwctrlitems.h +++ b/libretroshare/src/rsitems/rsbwctrlitems.h @@ -1,31 +1,27 @@ +/******************************************************************************* + * libretroshare/src/rsitems: rsbwctrlitems.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RS_BANDWIDTH_CONTROL_ITEMS_H #define RS_BANDWIDTH_CONTROL_ITEMS_H -/* - * libretroshare/src/serialiser: rsbwctrlitems.h - * - * RetroShare Serialiser. - * - * Copyright 2012 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - #include #include "rsitems/rsitem.h" diff --git a/libretroshare/src/rsitems/rsconfigitems.cc b/libretroshare/src/rsitems/rsconfigitems.cc index 17edb7962..654d1a7f6 100644 --- a/libretroshare/src/rsitems/rsconfigitems.cc +++ b/libretroshare/src/rsitems/rsconfigitems.cc @@ -1,29 +1,24 @@ - -/* - * libretroshare/src/serialiser: rsconfigitems.cc - * - * RetroShare Serialiser. - * - * Copyright 2007-2008 by Robert Fernie, Chris Parker. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/rsitems: rsconfigitems.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2007-2008 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "serialiser/rsbaseserial.h" #include "rsitems/rsconfigitems.h" #include "retroshare/rspeers.h" // Needed for RsGroupInfo. diff --git a/libretroshare/src/rsitems/rsconfigitems.h b/libretroshare/src/rsitems/rsconfigitems.h index a22f907d6..376bebb78 100644 --- a/libretroshare/src/rsitems/rsconfigitems.h +++ b/libretroshare/src/rsitems/rsconfigitems.h @@ -1,31 +1,27 @@ +/******************************************************************************* + * libretroshare/src/rsitems: rsconfigitems.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2007-2008 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RS_CONFIG_ITEMS_SERIALISER_H #define RS_CONFIG_ITEMS_SERIALISER_H -/* - * libretroshare/src/serialiser: rsconfigitems.h - * - * RetroShare Serialiser. - * - * Copyright 2007-2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - #include #include diff --git a/libretroshare/src/rsitems/rsdiscovery2items.cc b/libretroshare/src/rsitems/rsdiscovery2items.cc index 0d1d3a493..1a23583db 100644 --- a/libretroshare/src/rsitems/rsdiscovery2items.cc +++ b/libretroshare/src/rsitems/rsdiscovery2items.cc @@ -1,29 +1,24 @@ - -/* - * libretroshare/src/serialiser: rsdiscitems.cc - * - * RetroShare Serialiser. - * - * Copyright 2007-2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/rsitems: rsdiscitems.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2007-2008 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "rsitems/rsdiscovery2items.h" #include "serialiser/rsbaseserial.h" diff --git a/libretroshare/src/rsitems/rsdiscovery2items.h b/libretroshare/src/rsitems/rsdiscovery2items.h index 012ebe1b5..85f30b995 100644 --- a/libretroshare/src/rsitems/rsdiscovery2items.h +++ b/libretroshare/src/rsitems/rsdiscovery2items.h @@ -1,30 +1,24 @@ -/* - * libretroshare/src/serialiser: rsdiscitems.h - * - * Serialiser for RetroShare. - * - * Copyright 2004-2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - - +/******************************************************************************* + * libretroshare/src/rsitems: rsdiscitems.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2008 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RS_DISC_ITEMS_H #define RS_DISC_ITEMS_H diff --git a/libretroshare/src/rsitems/rsfiletransferitems.cc b/libretroshare/src/rsitems/rsfiletransferitems.cc index 4241081a7..3c34acf6a 100644 --- a/libretroshare/src/rsitems/rsfiletransferitems.cc +++ b/libretroshare/src/rsitems/rsfiletransferitems.cc @@ -1,29 +1,24 @@ - -/* - * libretroshare/src/serialiser: rsbaseitems.cc - * - * RetroShare Serialiser. - * - * Copyright 2007-2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/rsitems: rsfiletransferitems.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2007-2008 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "serialiser/rsbaseserial.h" #include "serialiser/rstlvbase.h" #include "rsitems/rsfiletransferitems.h" diff --git a/libretroshare/src/rsitems/rsfiletransferitems.h b/libretroshare/src/rsitems/rsfiletransferitems.h index 85f6d5eab..60514e41f 100644 --- a/libretroshare/src/rsitems/rsfiletransferitems.h +++ b/libretroshare/src/rsitems/rsfiletransferitems.h @@ -1,30 +1,26 @@ +/******************************************************************************* + * libretroshare/src/rsitems: rsfiletransferitems.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2007-2008 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once -/* - * libretroshare/src/serialiser: rsbaseitems.h - * - * RetroShare Serialiser. - * - * Copyright 2007-2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - #include #include "retroshare/rstypes.h" diff --git a/libretroshare/src/rsitems/rsgxschannelitems.cc b/libretroshare/src/rsitems/rsgxschannelitems.cc index a8cc067b1..123e85c17 100644 --- a/libretroshare/src/rsitems/rsgxschannelitems.cc +++ b/libretroshare/src/rsitems/rsgxschannelitems.cc @@ -1,28 +1,24 @@ -/* - * libretroshare/src/serialiser: rsgxschannelitems.cc - * - * RetroShare C++ Interface. - * - * Copyright 2012-2012 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/rsitems: rsgxschannelitems.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012-2012 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include #include "rsgxschannelitems.h" diff --git a/libretroshare/src/rsitems/rsgxschannelitems.h b/libretroshare/src/rsitems/rsgxschannelitems.h index b0fc67987..fa52c8cfc 100644 --- a/libretroshare/src/rsitems/rsgxschannelitems.h +++ b/libretroshare/src/rsitems/rsgxschannelitems.h @@ -1,28 +1,24 @@ -/* - * libretroshare/src/serialiser: rsgxschannelitems.h - * - * RetroShare C++ Interface. - * - * Copyright 2012-2012 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/rsitems: rsgxschannelitems.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012-2012 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RS_GXS_CHANNEL_ITEMS_H #define RS_GXS_CHANNEL_ITEMS_H diff --git a/libretroshare/src/rsitems/rsgxscircleitems.cc b/libretroshare/src/rsitems/rsgxscircleitems.cc index a468f483f..0acdd03de 100644 --- a/libretroshare/src/rsitems/rsgxscircleitems.cc +++ b/libretroshare/src/rsitems/rsgxscircleitems.cc @@ -1,28 +1,24 @@ -/* - * libretroshare/src/serialiser: rswikiitems.cc - * - * RetroShare C++ Interface. - * - * Copyright 2012-2012 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/rsitems: rsgxscircleitems.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012-2012 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include #include "rsgxscircleitems.h" diff --git a/libretroshare/src/rsitems/rsgxscircleitems.h b/libretroshare/src/rsitems/rsgxscircleitems.h index 8e57b478c..6338fb368 100644 --- a/libretroshare/src/rsitems/rsgxscircleitems.h +++ b/libretroshare/src/rsitems/rsgxscircleitems.h @@ -1,28 +1,24 @@ -/* - * libretroshare/src/serialiser: rsgxscircleitems.h - * - * RetroShare C++ Interface. - * - * Copyright 2012-2012 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/rsitems: rsgxscircleitems.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012-2012 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RS_GXSCIRCLE_ITEMS_H #define RS_GXSCIRCLE_ITEMS_H diff --git a/libretroshare/src/rsitems/rsgxscommentitems.cc b/libretroshare/src/rsitems/rsgxscommentitems.cc index 8c175a1bd..2386fb069 100644 --- a/libretroshare/src/rsitems/rsgxscommentitems.cc +++ b/libretroshare/src/rsitems/rsgxscommentitems.cc @@ -1,28 +1,24 @@ -/* - * libretroshare/src/serialiser: rsgxscommentitems.cc - * - * RetroShare C++ Interface. - * - * Copyright 2012-2013 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/rsitems: rsgxscommentitems.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012-2013 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include #include "rsgxscommentitems.h" diff --git a/libretroshare/src/rsitems/rsgxscommentitems.h b/libretroshare/src/rsitems/rsgxscommentitems.h index ec5d6ae2c..c35c6c2aa 100644 --- a/libretroshare/src/rsitems/rsgxscommentitems.h +++ b/libretroshare/src/rsitems/rsgxscommentitems.h @@ -1,28 +1,24 @@ -/* - * libretroshare/src/serialiser: rsgxscommentitems.h - * - * RetroShare C++ Interface. - * - * Copyright 2012-2012 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/rsitems: rsgxscommentitems.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012-2012 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RS_GXS_COMMENT_ITEMS_H #define RS_GXS_COMMENT_ITEMS_H diff --git a/libretroshare/src/rsitems/rsgxsforumitems.cc b/libretroshare/src/rsitems/rsgxsforumitems.cc index 3a4b5ebda..1918fd980 100644 --- a/libretroshare/src/rsitems/rsgxsforumitems.cc +++ b/libretroshare/src/rsitems/rsgxsforumitems.cc @@ -1,28 +1,24 @@ -/* - * libretroshare/src/serialiser: rsgxsforumitems.cc - * - * RetroShare C++ Interface. - * - * Copyright 2012-2012 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/rsitems: rsgxsforumitems.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012-2012 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include #include "rsgxsforumitems.h" diff --git a/libretroshare/src/rsitems/rsgxsforumitems.h b/libretroshare/src/rsitems/rsgxsforumitems.h index 5ce8a84ee..30c6c4e08 100644 --- a/libretroshare/src/rsitems/rsgxsforumitems.h +++ b/libretroshare/src/rsitems/rsgxsforumitems.h @@ -1,28 +1,24 @@ -/* - * libretroshare/src/serialiser: rsgxsforumitems.h - * - * RetroShare C++ Interface. - * - * Copyright 2012-2012 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/rsitems: rsgxsforumitems.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012-2012 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RS_GXS_FORUM_ITEMS_H #define RS_GXS_FORUM_ITEMS_H diff --git a/libretroshare/src/rsitems/rsgxsiditems.cc b/libretroshare/src/rsitems/rsgxsiditems.cc index 1a4eac4e8..ee94d3682 100644 --- a/libretroshare/src/rsitems/rsgxsiditems.cc +++ b/libretroshare/src/rsitems/rsgxsiditems.cc @@ -1,28 +1,24 @@ -/* - * libretroshare/src/serialiser: rsgxsiditems.cc - * - * RetroShare C++ Interface. - * - * Copyright 2012-2012 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/rsitems: rsgxsiditems.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012-2012 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include #include "rsgxsiditems.h" diff --git a/libretroshare/src/rsitems/rsgxsiditems.h b/libretroshare/src/rsitems/rsgxsiditems.h index 19802a9a1..61c7500f3 100644 --- a/libretroshare/src/rsitems/rsgxsiditems.h +++ b/libretroshare/src/rsitems/rsgxsiditems.h @@ -1,28 +1,24 @@ -/* - * libretroshare/src/serialiser: rsgxsiditems.h - * - * RetroShare C++ Interface. - * - * Copyright 2012-2012 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/rsitems: rsgxsiditems.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012-2012 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RS_GXS_IDENTITY_ITEMS_H #define RS_GXS_IDENTITY_ITEMS_H diff --git a/libretroshare/src/rsitems/rsgxsitems.cc b/libretroshare/src/rsitems/rsgxsitems.cc index 9971514ec..d8f96555b 100644 --- a/libretroshare/src/rsitems/rsgxsitems.cc +++ b/libretroshare/src/rsitems/rsgxsitems.cc @@ -1,11 +1,27 @@ -/* - * rsgxsitems.cc - * - * Created on: 26 Jul 2012 - * Author: crispy - */ - - +/******************************************************************************* + * libretroshare/src/rsitems: rsgxsitems.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012-2012 by Robert Fernie * + * Copyright 2012-2012 by Christopher Evi-Parker * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ +#include "serialiser/rstypeserializer.h" +#include "serialiser/rsbaseserial.h" #include "rsgxsitems.h" #include "gxs/rsgxsdata.h" #include @@ -70,4 +86,62 @@ std::ostream &operator<<(std::ostream &out, const RsMsgMetaData &meta) return out; } +template<> uint32_t RsTypeSerializer::serial_size(const TurtleGxsInfo& i) +{ + uint32_t s = 0 ; + + s += 2 ; // service_id + s += i.group_id.SIZE_IN_BYTES ; + s += GetTlvStringSize(i.name) ; + + return s; +} + +template<> bool RsTypeSerializer::deserialize(const uint8_t data[],uint32_t size,uint32_t& offset,TurtleGxsInfo& i) +{ + uint32_t saved_offset = offset ; + bool ok = true ; + + ok &= getRawUInt16(data, size, &offset, &i.service_id); // service_id + ok &= i.group_id.deserialise(data, size, offset); // group_id + ok &= GetTlvString(data, size, &offset, TLV_TYPE_STR_NAME, i.name); // group name + + if(!ok) + offset = saved_offset ; + + return ok; +} + +template<> bool RsTypeSerializer::serialize(uint8_t data[],uint32_t size,uint32_t& offset,const TurtleGxsInfo& i) +{ + uint32_t saved_offset = offset ; + bool ok = true ; + + ok &= setRawUInt16(data, size, &offset, i.service_id); // service_id + ok &= i.group_id.serialise(data, size, offset); // group_id + ok &= SetTlvString(data, size, &offset, TLV_TYPE_STR_NAME, i.name); // group name + + if(!ok) + offset = saved_offset ; + + return ok; +} + +template<> void RsTypeSerializer::print_data(const std::string& n, const TurtleGxsInfo& i) +{ + std::cerr << " [GXS Info ] " << n << " group_id=" << i.group_id << " service=" << std::hex << i.service_id << std::dec << ", name=" << i.name << std::endl; +} + +void RsTurtleGxsSearchResultGroupSummaryItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx) +{ + RsTypeSerializer::serial_process(j,ctx,result,"result") ; +} +void RsTurtleGxsSearchResultGroupDataItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx) +{ + RsTypeSerializer::TlvMemBlock_proxy prox(encrypted_nxs_group_data,encrypted_nxs_group_data_len) ; + RsTypeSerializer::serial_process(j,ctx,prox,"encrypted_nxs_data") ; +} + +RS_TYPE_SERIALIZER_FROM_JSON_NOT_IMPLEMENTED_DEF(TurtleGxsInfo) +RS_TYPE_SERIALIZER_TO_JSON_NOT_IMPLEMENTED_DEF(TurtleGxsInfo) diff --git a/libretroshare/src/rsitems/rsgxsitems.h b/libretroshare/src/rsitems/rsgxsitems.h index fa461a0e8..22135f5e5 100644 --- a/libretroshare/src/rsitems/rsgxsitems.h +++ b/libretroshare/src/rsitems/rsgxsitems.h @@ -1,31 +1,28 @@ +/******************************************************************************* + * libretroshare/src/rsitems: rsgxsitems.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012-2012 by Robert Fernie * + * Copyright 2012-2012 by Christopher Evi-Parker * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RSGXSITEMS_H #define RSGXSITEMS_H -/* - * libretroshare/src/serialiser: rsgxsitems.h - * - * RetroShare Serialiser. - * - * Copyright 2012 Christopher Evi-Parker, Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - #include "rsitems/rsitem.h" #include "rsitems/rsserviceids.h" @@ -57,6 +54,82 @@ public: RsMsgMetaData meta; }; +// We should make these items templates or generic classes so that each GXS service will handle them on its own. + +static const uint8_t RS_PKT_SUBTYPE_GXS_SUBSTRING_SEARCH_ITEM = 0x20 ; +static const uint8_t RS_PKT_SUBTYPE_GXS_GROUP_SEARCH_ITEM = 0x21 ; +static const uint8_t RS_PKT_SUBTYPE_GXS_GROUP_SUMMARY_ITEM = 0x22 ; +static const uint8_t RS_PKT_SUBTYPE_GXS_GROUP_DATA_ITEM = 0x23 ; + +class RsGxsTurtleSubStringSearchItem: public RsItem +{ + public: + RsGxsTurtleSubStringSearchItem(uint16_t service): RsItem(RS_PKT_VERSION_SERVICE,service,RS_PKT_SUBTYPE_GXS_SUBSTRING_SEARCH_ITEM) {} + virtual ~RsGxsTurtleSubStringSearchItem() {} + + std::string match_string ; // string to match + + std::string GetKeywords() { return match_string; } + void clear() { match_string.clear() ; } + + protected: + void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx); +}; + +class RsGxsTurtleGroupSearchItem: public RsItem +{ + public: + RsGxsTurtleGroupSearchItem(uint16_t service): RsItem(RS_PKT_VERSION_SERVICE,service,RS_PKT_SUBTYPE_GXS_GROUP_SEARCH_ITEM) {} + virtual ~RsGxsTurtleGroupSearchItem() {} + + uint16_t service_id ; // searvice to search + Sha1CheckSum hashed_group_id ; // the group ID is hashed in order to keep it private. + + std::string GetKeywords() { return std::string("Group request for [hashed] ")+hashed_group_id.toStdString() ; } + void clear() { hashed_group_id.clear() ; } + + protected: + void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx); +}; + +struct TurtleGxsInfo +{ + uint16_t service_id ; + RsGxsGroupId group_id ; + RsGxsId author; + std::string name ; + std::string description ; + time_t last_post ; + uint32_t number_of_posts ; +}; + +class RsTurtleGxsSearchResultGroupSummaryItem: public RsItem +{ + public: + RsTurtleGxsSearchResultGroupSummaryItem(uint16_t service) : RsItem(RS_PKT_VERSION_SERVICE,service,RS_PKT_SUBTYPE_GXS_GROUP_SUMMARY_ITEM){} + virtual ~RsTurtleGxsSearchResultGroupSummaryItem() {} + + std::list result ; + + void clear() { result.clear() ; } + protected: + void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx); +}; + +class RsTurtleGxsSearchResultGroupDataItem: public RsItem +{ + public: + RsTurtleGxsSearchResultGroupDataItem(uint16_t service) : RsItem(RS_PKT_VERSION_SERVICE,service,RS_PKT_SUBTYPE_GXS_GROUP_DATA_ITEM){} + virtual ~RsTurtleGxsSearchResultGroupDataItem() {} + + unsigned char *encrypted_nxs_group_data; // data is encrypted with group ID. Only the requester, or anyone who already know the group id can decrypt. + uint32_t encrypted_nxs_group_data_len ; + + void clear() { free(encrypted_nxs_group_data); encrypted_nxs_group_data=NULL; encrypted_nxs_group_data_len=0; } + protected: + void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx); +}; + diff --git a/libretroshare/src/rsitems/rsgxsrecognitems.cc b/libretroshare/src/rsitems/rsgxsrecognitems.cc index bb6a40ca8..4113a051c 100644 --- a/libretroshare/src/rsitems/rsgxsrecognitems.cc +++ b/libretroshare/src/rsitems/rsgxsrecognitems.cc @@ -1,28 +1,24 @@ -/* - * libretroshare/src/serialiser: rsgxsrecogitems.cc - * - * RetroShare Serialiser. - * - * Copyright 2013-2013 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/rsitems: rsgxsrecogitems.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2013-2013 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "rsitems/rsgxsrecognitems.h" #include "serialiser/rstypeserializer.h" diff --git a/libretroshare/src/rsitems/rsgxsrecognitems.h b/libretroshare/src/rsitems/rsgxsrecognitems.h index 68a9aa174..3e049f0c2 100644 --- a/libretroshare/src/rsitems/rsgxsrecognitems.h +++ b/libretroshare/src/rsitems/rsgxsrecognitems.h @@ -1,31 +1,27 @@ +/******************************************************************************* + * libretroshare/src/rsitems: rsgxsrecogitems.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2013-2013 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RS_GXS_RECOG_ITEMS_H #define RS_GXS_RECOG_ITEMS_H -/* - * libretroshare/src/serialiser: rsgxsrecogitems.h - * - * RetroShare Serialiser. - * - * Copyright 2013-2013 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - #include #include "rsitems/rsitem.h" diff --git a/libretroshare/src/rsitems/rsgxsreputationitems.cc b/libretroshare/src/rsitems/rsgxsreputationitems.cc index 7b558131a..9aa8c6e9c 100644 --- a/libretroshare/src/rsitems/rsgxsreputationitems.cc +++ b/libretroshare/src/rsitems/rsgxsreputationitems.cc @@ -1,28 +1,24 @@ -/* - * libretroshare/src/serialiser: rsbanlist.cc - * - * RetroShare Serialiser. - * - * Copyright 2011 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/rsitems: rsgxsreputationitems.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2011-2011 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include #include #include "serialiser/rsbaseserial.h" diff --git a/libretroshare/src/rsitems/rsgxsreputationitems.h b/libretroshare/src/rsitems/rsgxsreputationitems.h index d4134f745..6bcd77451 100644 --- a/libretroshare/src/rsitems/rsgxsreputationitems.h +++ b/libretroshare/src/rsitems/rsgxsreputationitems.h @@ -1,31 +1,27 @@ +/******************************************************************************* + * libretroshare/src/rsitems: rsgxsreputationitems.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2014-2014 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RS_GXSREPUTATION_ITEMS_H #define RS_GXSREPUTATION_ITEMS_H -/* - * libretroshare/src/serialiser: rsgxsreputationitems.h - * - * RetroShare Serialiser. - * - * Copyright 2014 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - #include #include "rsitems/rsserviceids.h" diff --git a/libretroshare/src/rsitems/rsgxsupdateitems.cc b/libretroshare/src/rsitems/rsgxsupdateitems.cc index a5f3ecf02..b129dc460 100644 --- a/libretroshare/src/rsitems/rsgxsupdateitems.cc +++ b/libretroshare/src/rsitems/rsgxsupdateitems.cc @@ -1,28 +1,24 @@ -/* - * libretroshare/src/serialiser: rsgxsupdateitems.h - * - * RetroShare Serialiser. - * - * Copyright 2012 Christopher Evi-Parker - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/rsitems: rsgxsupdateitems.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012 Christopher Evi-Parker * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "serialiser/rstypeserializer.h" #include "serialiser/rsbaseserial.h" @@ -97,6 +93,31 @@ void RsGxsMsgUpdateItem::serial_process(RsGenericSerializer::SerializeJob j,RsGe RsTypeSerializer::serial_process(j,ctx,msgUpdateInfos,"msgUpdateInfos"); } +template<> bool RsTypeSerializer::serialize(uint8_t data[], uint32_t size, uint32_t &offset, const RsGxsMsgUpdateItem::MsgUpdateInfo& info) +{ + bool ok = true ; + + ok = ok && setRawUInt32(data,size,&offset,info.time_stamp); + ok = ok && setRawUInt32(data,size,&offset,info.message_count); + + return ok; +} +template<> bool RsTypeSerializer::deserialize(const uint8_t data[], uint32_t size, uint32_t &offset, RsGxsMsgUpdateItem::MsgUpdateInfo& info) +{ + bool ok = true ; + + ok = ok && getRawUInt32(data,size,&offset,&info.time_stamp); + ok = ok && getRawUInt32(data,size,&offset,&info.message_count); + + return ok; +} +template<> uint32_t RsTypeSerializer::serial_size(const RsGxsMsgUpdateItem::MsgUpdateInfo& /* info */) { return 8; } + +template<> void RsTypeSerializer::print_data(const std::string& name,const RsGxsMsgUpdateItem::MsgUpdateInfo& info) +{ + std::cerr << "[MsgUpdateInfo]: " << name << ": " << info.time_stamp << ", " << info.message_count << std::endl; +} + void RsGxsServerMsgUpdateItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx) { RsTypeSerializer::serial_process (j,ctx,grpId,"grpId"); @@ -109,3 +130,4 @@ void RsGxsGrpConfigItem::serial_process(RsGenericSerializer::SerializeJob j,RsGe RsTypeSerializer::serial_process(j,ctx,msg_send_delay,"msg_send_delay") ; RsTypeSerializer::serial_process(j,ctx,msg_req_delay,"msg_req_delay") ; } + diff --git a/libretroshare/src/rsitems/rsgxsupdateitems.h b/libretroshare/src/rsitems/rsgxsupdateitems.h index 5d13028ff..0ac06920d 100644 --- a/libretroshare/src/rsitems/rsgxsupdateitems.h +++ b/libretroshare/src/rsitems/rsgxsupdateitems.h @@ -1,35 +1,30 @@ +/******************************************************************************* + * libretroshare/src/rsitems: rsgxsupdateitems.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012 Christopher Evi-Parker * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RSGXSUPDATEITEMS_H_ #define RSGXSUPDATEITEMS_H_ -/* - * libretroshare/src/serialiser: rsgxsupdateitems.h - * - * RetroShare Serialiser. - * - * Copyright 2012 Christopher Evi-Parker - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - - #include "gxs/rsgxs.h" #include "gxs/rsgxsdata.h" +#include "gxs/rsgxsnettunnel.h" #include "serialiser/rstlvidset.h" #include "serialiser/rstypeserializer.h" #include "serialiser/rsserializable.h" @@ -41,6 +36,7 @@ const uint8_t RS_PKT_SUBTYPE_GXS_MSG_UPDATE = 0x03; const uint8_t RS_PKT_SUBTYPE_GXS_SERVER_GRP_UPDATE = 0x04; const uint8_t RS_PKT_SUBTYPE_GXS_SERVER_MSG_UPDATE = 0x08; const uint8_t RS_PKT_SUBTYPE_GXS_GRP_CONFIG = 0x09; +const uint8_t RS_PKT_SUBTYPE_GXS_RANDOM_BIAS = 0x0a; class RsGxsNetServiceItem: public RsItem { @@ -188,7 +184,6 @@ public: RsGxsGroupId grpId; }; - class RsGxsUpdateSerialiser : public RsServiceSerializer { public: diff --git a/libretroshare/src/rsitems/rsheartbeatitems.h b/libretroshare/src/rsitems/rsheartbeatitems.h index 87d480b3e..b7e4f27c6 100644 --- a/libretroshare/src/rsitems/rsheartbeatitems.h +++ b/libretroshare/src/rsitems/rsheartbeatitems.h @@ -1,30 +1,24 @@ -/* - * libretroshare/src/serialiser: rsheartbeatitems.h - * - * Serialiser for RetroShare. - * - * Copyright 2004-2013 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - - +/******************************************************************************* + * libretroshare/src/rsitems: rsheartbeatitems.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2013 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RS_HEARTBEAT_ITEMS_H #define RS_HEARTBEAT_ITEMS_H diff --git a/libretroshare/src/rsitems/rshistoryitems.cc b/libretroshare/src/rsitems/rshistoryitems.cc index 1f16e976f..4cfb04945 100644 --- a/libretroshare/src/rsitems/rshistoryitems.cc +++ b/libretroshare/src/rsitems/rshistoryitems.cc @@ -1,28 +1,24 @@ -/* - * libretroshare/src/serialiser: rshistoryitems.cc - * - * RetroShare Serialiser. - * - * Copyright 2011 by Thunder. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/rsitems: rshistoryitems.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2007-2008 by Thunder. * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "rsitems/rshistoryitems.h" #include "rsitems/rsconfigitems.h" diff --git a/libretroshare/src/rsitems/rshistoryitems.h b/libretroshare/src/rsitems/rshistoryitems.h index 7f65f3d19..693817757 100644 --- a/libretroshare/src/rsitems/rshistoryitems.h +++ b/libretroshare/src/rsitems/rshistoryitems.h @@ -1,31 +1,27 @@ +/******************************************************************************* + * libretroshare/src/rsitems: rshistoryitems.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2007-2008 by Thunder. * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RS_HISTORY_ITEMS_H #define RS_HISTORY_ITEMS_H -/* - * libretroshare/src/serialiser: rshistoryitems.h - * - * RetroShare Serialiser. - * - * Copyright 2007-2008 by Thunder. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - #include "rsitems/rsserviceids.h" #include "serialiser/rsserial.h" #include "rsitems/rsconfigitems.h" diff --git a/libretroshare/src/rsitems/rsitem.h b/libretroshare/src/rsitems/rsitem.h index 545870631..d8495ab58 100644 --- a/libretroshare/src/rsitems/rsitem.h +++ b/libretroshare/src/rsitems/rsitem.h @@ -1,21 +1,25 @@ +/******************************************************************************* + * libretroshare/src/rsitems: rsitem.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright (C) 2018 Gioacchino Mazzurco * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once -/* - * RetroShare Serialiser. - * Copyright (C) 2018 Gioacchino Mazzurco - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ #include // for typeid @@ -73,7 +77,7 @@ struct RsItem : RsMemoryManagement::SmallObject, RsSerializable inline uint8_t priority_level() const { return _priority_level ;} inline void setPriorityLevel(uint8_t l) { _priority_level = l ;} - /** + /* * TODO: This default implementation should be removed and childs structs * implement ::serial_process(...) as soon as all the codebase is ported to * the new serialization system diff --git a/libretroshare/src/rsitems/rsmsgitems.cc b/libretroshare/src/rsitems/rsmsgitems.cc index e9668cc9f..32d32dd06 100644 --- a/libretroshare/src/rsitems/rsmsgitems.cc +++ b/libretroshare/src/rsitems/rsmsgitems.cc @@ -1,29 +1,24 @@ - -/* - * libretroshare/src/serialiser: rsbaseitems.cc - * - * RetroShare Serialiser. - * - * Copyright 2007-2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/rsitems: rsmsgitems.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2007-2008 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include #include #include "serialiser/rsbaseserial.h" diff --git a/libretroshare/src/rsitems/rsmsgitems.h b/libretroshare/src/rsitems/rsmsgitems.h index 71f546683..ad84ec3ba 100644 --- a/libretroshare/src/rsitems/rsmsgitems.h +++ b/libretroshare/src/rsitems/rsmsgitems.h @@ -1,31 +1,27 @@ +/******************************************************************************* + * libretroshare/src/rsitems: rsmsgitems.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2007-2008 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RS_MSG_ITEMS_H #define RS_MSG_ITEMS_H -/* - * libretroshare/src/serialiser: rsmsgitems.h - * - * RetroShare Serialiser. - * - * Copyright 2007-2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - #include #include "retroshare/rstypes.h" diff --git a/libretroshare/src/rsitems/rsnxsitems.cc b/libretroshare/src/rsitems/rsnxsitems.cc index 8c6775275..ab596a99b 100644 --- a/libretroshare/src/rsitems/rsnxsitems.cc +++ b/libretroshare/src/rsitems/rsnxsitems.cc @@ -1,3 +1,24 @@ +/******************************************************************************* + * libretroshare/src/rsitems: rsnxsitems.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012 Christopher Evi-Parker,Robert Fernie* + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "rsnxsitems.h" #include "util/rsprint.h" #include diff --git a/libretroshare/src/rsitems/rsnxsitems.h b/libretroshare/src/rsitems/rsnxsitems.h index f717a3d09..56920a058 100644 --- a/libretroshare/src/rsitems/rsnxsitems.h +++ b/libretroshare/src/rsitems/rsnxsitems.h @@ -1,32 +1,27 @@ +/******************************************************************************* + * libretroshare/src/rsitems: rsnxsitems.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012 Christopher Evi-Parker,Robert Fernie* + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RSNXSITEMS_H #define RSNXSITEMS_H -/* - * libretroshare/src/serialiser: rsnxssitems.h - * - * RetroShare Serialiser. - * - * Copyright 2012 Christopher Evi-Parker, Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - #include #include @@ -293,7 +288,8 @@ public: virtual void clear(); - virtual void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx); + virtual void serial_process( RsGenericSerializer::SerializeJob j, + RsGenericSerializer::SerializeContext& ctx ); RsGxsGroupId grpId; /// group Id, needed to complete version Id (ncvi) static int refcount; diff --git a/libretroshare/src/rsitems/rsphotoitems.cc b/libretroshare/src/rsitems/rsphotoitems.cc index 3a5ad1ead..e462d8ee9 100644 --- a/libretroshare/src/rsitems/rsphotoitems.cc +++ b/libretroshare/src/rsitems/rsphotoitems.cc @@ -1,28 +1,24 @@ -/* - * libretroshare/src/retroshare: rsphoto.h - * - * RetroShare C++ Interface. - * - * Copyright 2012-2012 by Christopher Evi-Parker, Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/rsitems: rsphotoitems.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012 Christopher Evi-Parker,Robert Fernie* + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include #include "rsitems/rsphotoitems.h" diff --git a/libretroshare/src/rsitems/rsphotoitems.h b/libretroshare/src/rsitems/rsphotoitems.h index cf809ce8e..92f99843c 100644 --- a/libretroshare/src/rsitems/rsphotoitems.h +++ b/libretroshare/src/rsitems/rsphotoitems.h @@ -1,28 +1,24 @@ -/* - * libretroshare/src/retroshare: rsphoto.h - * - * RetroShare C++ Interface. - * - * Copyright 2012-2012 by Christopher Evi-Parker, Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/rsitems: rsphotoitems.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012 Christopher Evi-Parker,Robert Fernie* + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RSPHOTOV2ITEMS_H_ #define RSPHOTOV2ITEMS_H_ diff --git a/libretroshare/src/rsitems/rspluginitems.h b/libretroshare/src/rsitems/rspluginitems.h index c21567cd1..29069815d 100644 --- a/libretroshare/src/rsitems/rspluginitems.h +++ b/libretroshare/src/rsitems/rspluginitems.h @@ -1,29 +1,24 @@ -/* - * libretroshare/src/services: p3turtle.h - * - * Services for RetroShare. - * - * Copyright 2009 by Cyril Soler - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "csoler@users.sourceforge.net". - * - */ - - +/******************************************************************************* + * libretroshare/src/rsitems: rspluginitems.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2009 by Cyril Soler * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once #include "rsitems/rsitem.h" diff --git a/libretroshare/src/rsitems/rsposteditems.cc b/libretroshare/src/rsitems/rsposteditems.cc index 378153df3..67a5a9873 100644 --- a/libretroshare/src/rsitems/rsposteditems.cc +++ b/libretroshare/src/rsitems/rsposteditems.cc @@ -1,29 +1,24 @@ - -/* - * libretroshare/src/gxs: rsopsteditems.cc - * - * RetroShare Serialiser. - * - * Copyright 2012-2013 by Robert Fernie, Christopher Evi-Parker - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/rsitems: rsposteditems.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "rsitems/rsposteditems.h" #include "serialiser/rstypeserializer.h" diff --git a/libretroshare/src/rsitems/rsposteditems.h b/libretroshare/src/rsitems/rsposteditems.h index b78835451..62ab7a6af 100644 --- a/libretroshare/src/rsitems/rsposteditems.h +++ b/libretroshare/src/rsitems/rsposteditems.h @@ -1,3 +1,24 @@ +/******************************************************************************* + * libretroshare/src/rsitems: rsposteditems.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RSPOSTEDITEMS_H #define RSPOSTEDITEMS_H diff --git a/libretroshare/src/rsitems/rsrttitems.cc b/libretroshare/src/rsitems/rsrttitems.cc index 033975a3b..739f1c06d 100644 --- a/libretroshare/src/rsitems/rsrttitems.cc +++ b/libretroshare/src/rsitems/rsrttitems.cc @@ -1,29 +1,24 @@ - -/* - * libretroshare/src/serialiser: rsrttitems.cc - * - * RetroShare Serialiser. - * - * Copyright 2011-2013 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/rsitems: rsrttitems.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2011-2013 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "rsitems/rsrttitems.h" /*** diff --git a/libretroshare/src/rsitems/rsrttitems.h b/libretroshare/src/rsitems/rsrttitems.h index 90b2e385e..54f612ee6 100644 --- a/libretroshare/src/rsitems/rsrttitems.h +++ b/libretroshare/src/rsitems/rsrttitems.h @@ -1,31 +1,27 @@ +/******************************************************************************* + * libretroshare/src/rsitems: rsrttitems.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2011-2013 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RS_RTT_ITEMS_H #define RS_RTT_ITEMS_H -/* - * libretroshare/src/serialiser: rsrttitems.h - * - * RetroShare Serialiser. - * - * Copyright 2011-2013 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - #include #include "rsitems/rsitem.h" diff --git a/libretroshare/src/rsitems/rsserviceids.h b/libretroshare/src/rsitems/rsserviceids.h index 557bc54d7..4c7f26fd8 100644 --- a/libretroshare/src/rsitems/rsserviceids.h +++ b/libretroshare/src/rsitems/rsserviceids.h @@ -1,31 +1,27 @@ +/******************************************************************************* + * libretroshare/src/rsitems: rsserviceids.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2007-2008 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RS_SERVICE_IDS_H #define RS_SERVICE_IDS_H -/* - * libretroshare/src/serialiser: rsserviceids.h - * - * RetroShare Serialiser. - * - * Copyright 2007-2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - #include /* Single place for Cache/Service Ids (uint16_t) diff --git a/libretroshare/src/rsitems/rsserviceinfoitems.cc b/libretroshare/src/rsitems/rsserviceinfoitems.cc index d0d2070ab..8d007941d 100644 --- a/libretroshare/src/rsitems/rsserviceinfoitems.cc +++ b/libretroshare/src/rsitems/rsserviceinfoitems.cc @@ -1,28 +1,24 @@ -/* - * libretroshare/src/serialiser: rsserviceinfoitems.cc - * - * RetroShare Serialiser. - * - * Copyright 2014 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/rsitems: rsserviceinfoitems.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012-2012 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "serialiser/rsbaseserial.h" #include "serialiser/rstypeserializer.h" #include "rsitems/rsserviceinfoitems.h" diff --git a/libretroshare/src/rsitems/rsserviceinfoitems.h b/libretroshare/src/rsitems/rsserviceinfoitems.h index 04a524331..e3d04b3c8 100644 --- a/libretroshare/src/rsitems/rsserviceinfoitems.h +++ b/libretroshare/src/rsitems/rsserviceinfoitems.h @@ -1,31 +1,27 @@ +/******************************************************************************* + * libretroshare/src/rsitems: rsserviceinfoitems.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012-2012 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RS_SERVICE_INFO_ITEMS_H #define RS_SERVICE_INFO_ITEMS_H -/* - * libretroshare/src/serialiser: rsserviceinfoitems.h - * - * RetroShare Serialiser. - * - * Copyright 2012 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - // Provides serialiser for p3ServiceControl & p3ServiceInfo. #include diff --git a/libretroshare/src/rsitems/rsstatusitems.h b/libretroshare/src/rsitems/rsstatusitems.h index 8a8a946b7..e92db7816 100644 --- a/libretroshare/src/rsitems/rsstatusitems.h +++ b/libretroshare/src/rsitems/rsstatusitems.h @@ -1,31 +1,27 @@ +/******************************************************************************* + * libretroshare/src/rsitems: rsstatusitems.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2007-2008 by Vinny Do. * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RS_STATUS_ITEMS_H #define RS_STATUS_ITEMS_H -/* - * libretroshare/src/serialiser: rsstatusitems.h - * - * RetroShare Serialiser. - * - * Copyright 2007-2008 by Vinny Do. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - #include "rsitems/rsserviceids.h" #include "rsitems/itempriorities.h" #include "rsitems/rsitem.h" diff --git a/libretroshare/src/rsitems/rswikiitems.cc b/libretroshare/src/rsitems/rswikiitems.cc index 96f9e2768..e7ffa8508 100644 --- a/libretroshare/src/rsitems/rswikiitems.cc +++ b/libretroshare/src/rsitems/rswikiitems.cc @@ -1,28 +1,24 @@ -/* - * libretroshare/src/serialiser: rswikiitems.cc - * - * RetroShare C++ Interface. - * - * Copyright 2012-2012 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/rsitems: rswikiitems.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012-2012 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include #include "rsitems/rswikiitems.h" diff --git a/libretroshare/src/rsitems/rswikiitems.h b/libretroshare/src/rsitems/rswikiitems.h index 378b77e5a..fa5cf1533 100644 --- a/libretroshare/src/rsitems/rswikiitems.h +++ b/libretroshare/src/rsitems/rswikiitems.h @@ -1,27 +1,24 @@ -/* - * libretroshare/src/serialiser: rswikiitems.h - * - * RetroShare C++ Interface. - * - * Copyright 2012-2012 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ +/******************************************************************************* + * libretroshare/src/rsitems: rswikiitems.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012-2012 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RS_WIKI_ITEMS_H #define RS_WIKI_ITEMS_H diff --git a/libretroshare/src/rsitems/rswireitems.cc b/libretroshare/src/rsitems/rswireitems.cc index 7a8008ff8..eb3896f17 100644 --- a/libretroshare/src/rsitems/rswireitems.cc +++ b/libretroshare/src/rsitems/rswireitems.cc @@ -1,32 +1,27 @@ -/* - * libretroshare/src/serialiser: rswikiitems.cc - * - * RetroShare C++ Interface. - * - * Copyright 2012-2012 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/rsitems: rswireitems.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012-2012 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include #include "rswireitems.h" - #include "serialiser/rstypeserializer.h" #define WIRE_DEBUG 1 diff --git a/libretroshare/src/rsitems/rswireitems.h b/libretroshare/src/rsitems/rswireitems.h index 137619aa6..4db5f3d25 100644 --- a/libretroshare/src/rsitems/rswireitems.h +++ b/libretroshare/src/rsitems/rswireitems.h @@ -1,27 +1,24 @@ -/* - * libretroshare/src/serialiser: rswireitems.h - * - * RetroShare C++ Interface. - * - * Copyright 2012-2012 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ +/******************************************************************************* + * libretroshare/src/rsitems: rswireitems.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012-2012 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RS_WIRE_ITEMS_H #define RS_WIRE_ITEMS_H diff --git a/libretroshare/src/rsserver/p3face.h b/libretroshare/src/rsserver/p3face.h index 8e1ffac56..6a9d7b2ea 100644 --- a/libretroshare/src/rsserver/p3face.h +++ b/libretroshare/src/rsserver/p3face.h @@ -1,31 +1,27 @@ +/******************************************************************************* + * libretroshare/src/rsserver: p3face.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2006 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef MRK_P3RS_INTERFACE_H #define MRK_P3RS_INTERFACE_H -/* - * "$Id: p3face.h,v 1.9 2007-05-05 16:10:06 rmf24 Exp $" - * - * RetroShare C++ Interface. - * - * Copyright 2004-2006 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - //#include "server/filedexserver.h" #include "ft/ftserver.h" //#include "pqi/pqissl.h" diff --git a/libretroshare/src/rsserver/p3history.cc b/libretroshare/src/rsserver/p3history.cc index 6c631ef43..9492a09f0 100644 --- a/libretroshare/src/rsserver/p3history.cc +++ b/libretroshare/src/rsserver/p3history.cc @@ -1,29 +1,24 @@ -/* - * libretroshare/src/rsserver: p3history.h - * - * RetroShare C++ Interface. - * - * Copyright 2011 by Thunder. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - +/******************************************************************************* + * libretroshare/src/rsserver: p3history.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2011 by Thunder. * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "p3history.h" #include "pqi/p3historymgr.h" diff --git a/libretroshare/src/rsserver/p3history.h b/libretroshare/src/rsserver/p3history.h index 70b7c701b..73d009657 100644 --- a/libretroshare/src/rsserver/p3history.h +++ b/libretroshare/src/rsserver/p3history.h @@ -1,31 +1,27 @@ +/******************************************************************************* + * libretroshare/src/rsserver: p3history.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2011 by Thunder. * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RS_P3HISTORY_INTERFACE_H #define RS_P3HISTORY_INTERFACE_H -/* - * libretroshare/src/rsserver: p3history.h - * - * RetroShare C++ Interface. - * - * Copyright 2011 by Thunder. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - #include "retroshare/rshistory.h" class p3HistoryMgr; diff --git a/libretroshare/src/rsserver/p3msgs.cc b/libretroshare/src/rsserver/p3msgs.cc index 0e058cac9..da2220912 100644 --- a/libretroshare/src/rsserver/p3msgs.cc +++ b/libretroshare/src/rsserver/p3msgs.cc @@ -1,31 +1,24 @@ - -/* - * "$Id: p3face-msgs.cc,v 1.7 2007-05-05 16:10:06 rmf24 Exp $" - * - * RetroShare C++ Interface. - * - * Copyright 2004-2006 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - - +/******************************************************************************* + * libretroshare/src/rsserver: p3msgs.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2006 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include #include "util/rsdir.h" diff --git a/libretroshare/src/rsserver/p3msgs.h b/libretroshare/src/rsserver/p3msgs.h index 7c242680f..edd5911a8 100644 --- a/libretroshare/src/rsserver/p3msgs.h +++ b/libretroshare/src/rsserver/p3msgs.h @@ -1,31 +1,27 @@ +/******************************************************************************* + * libretroshare/src/rsserver: p3msgs.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2007-2008 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RS_P3MSG_INTERFACE_H #define RS_P3MSG_INTERFACE_H -/* - * libretroshare/src/rsserver: p3msgs.h - * - * RetroShare C++ Interface. - * - * Copyright 2007-2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - #include "retroshare/rsmsgs.h" #include "retroshare/rsgxsifacetypes.h" diff --git a/libretroshare/src/rsserver/p3peers.cc b/libretroshare/src/rsserver/p3peers.cc index 36509c33b..30270e0f5 100644 --- a/libretroshare/src/rsserver/p3peers.cc +++ b/libretroshare/src/rsserver/p3peers.cc @@ -1,29 +1,25 @@ -/* - * libretroshare/src/rsserver: p3peers.cc - * - * RetroShare C++ Interface. - * - * Copyright 2004-2008 by Robert Fernie. - * Copyright (C) 2015-2018 Gioacchino Mazzurco - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/rsserver: p3peers.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2008 by Robert Fernie * + * Copyright (C) 2015-2018 Gioacchino Mazzurco * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "util/radix64.h" #include "pgp/pgpkeyutil.h" diff --git a/libretroshare/src/rsserver/p3peers.h b/libretroshare/src/rsserver/p3peers.h index d2333c420..fdef02602 100644 --- a/libretroshare/src/rsserver/p3peers.h +++ b/libretroshare/src/rsserver/p3peers.h @@ -1,31 +1,26 @@ +/******************************************************************************* + * libretroshare/src/rsserver: p3peers.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2008 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RETROSHARE_P3_PEER_INTERFACE_H #define RETROSHARE_P3_PEER_INTERFACE_H - -/* - * libretroshare/src/rsserver: p3peers.h - * - * RetroShare C++ Interface. - * - * Copyright 2004-2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - /* get OS-specific definitions for: * struct sockaddr_storage */ diff --git a/libretroshare/src/rsserver/p3serverconfig.cc b/libretroshare/src/rsserver/p3serverconfig.cc index eab0f5722..21d43cbae 100644 --- a/libretroshare/src/rsserver/p3serverconfig.cc +++ b/libretroshare/src/rsserver/p3serverconfig.cc @@ -1,28 +1,24 @@ -/* - * libretroshare/src/rsserver: p3serverconfig.h - * - * RetroShare C++ Interface. - * - * Copyright 2011-2011 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/rsserver: p3serverconfig.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2011-2011 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include #include "rsserver/p3serverconfig.h" #include "services/p3bwctrl.h" diff --git a/libretroshare/src/rsserver/p3serverconfig.h b/libretroshare/src/rsserver/p3serverconfig.h index 134558049..1a806d713 100644 --- a/libretroshare/src/rsserver/p3serverconfig.h +++ b/libretroshare/src/rsserver/p3serverconfig.h @@ -1,32 +1,27 @@ +/******************************************************************************* + * libretroshare/src/rsserver: p3serverconfig.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2011-2011 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef LIBRETROSHARE_CONFIG_IMPLEMENTATION_H #define LIBRETROSHARE_CONFIG_IMPLEMENTATION_H -/* - * libretroshare/src/rsserver: p3serverconfig.h - * - * RetroShare C++ Interface. - * - * Copyright 2011-2011 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - #include "retroshare/rsconfig.h" #include "pqi/p3peermgr.h" #include "pqi/p3linkmgr.h" diff --git a/libretroshare/src/rsserver/p3status.cc b/libretroshare/src/rsserver/p3status.cc index a1733a86c..4185e6802 100644 --- a/libretroshare/src/rsserver/p3status.cc +++ b/libretroshare/src/rsserver/p3status.cc @@ -1,29 +1,24 @@ -/* - * libretroshare/src/rsserver: p3msgs.h - * - * RetroShare C++ Interface. - * - * Copyright 2007-2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - +/******************************************************************************* + * libretroshare/src/rsserver: p3status.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2007-2008 by Chris Evi-Parker. * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "p3status.h" #include "services/p3statusservice.h" diff --git a/libretroshare/src/rsserver/p3status.h b/libretroshare/src/rsserver/p3status.h index bec3d4822..a6ae941f0 100644 --- a/libretroshare/src/rsserver/p3status.h +++ b/libretroshare/src/rsserver/p3status.h @@ -1,31 +1,27 @@ +/******************************************************************************* + * libretroshare/src/rsserver: p3status.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2007-2008 by Chris Evi-Parker. * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RS_P3STATUS_INTERFACE_H #define RS_P3STATUS_INTERFACE_H -/* - * libretroshare/src/rsserver: p3status.h - * - * RetroShare C++ Interface. - * - * Copyright 2007-2008 by Chris Evi-Parker. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - #include "retroshare/rsstatus.h" diff --git a/libretroshare/src/rsserver/rsaccounts.cc b/libretroshare/src/rsserver/rsaccounts.cc index 6136a2a87..c989d0bca 100644 --- a/libretroshare/src/rsserver/rsaccounts.cc +++ b/libretroshare/src/rsserver/rsaccounts.cc @@ -1,28 +1,24 @@ -/* - * libretroshare/src/rsserver/rsaccounts.cc - * - * RetroShare C++ Interface. - * - * Copyright 2013-2014 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/rsserver: rsaccounts.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2013-2014 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ /********************************************************************* * Libretroshare interface declared in rsaccounts.h. @@ -53,7 +49,7 @@ #include // Global singleton declaration of data. -RsAccountsDetail *rsAccounts; +RsAccountsDetail *RsAccounts::rsAccounts; /* Uses private class - so must be hidden */ static bool checkAccount(const std::string &accountdir, AccountDetails &account,std::map >& unsupported_keys); @@ -71,11 +67,8 @@ RsAccountsDetail::RsAccountsDetail() : mAccountsLocked(false), mPreferredId("") bool RsAccountsDetail::loadAccounts() { int failing_accounts ; -#ifdef RETROTOR - getAvailableAccounts(mAccounts,failing_accounts,mUnsupportedKeys,true); -#else +#warning we might need some switch here for hidden nodes only getAvailableAccounts(mAccounts,failing_accounts,mUnsupportedKeys,false); -#endif loadPreferredAccount(); checkPreferredId(); @@ -109,7 +102,7 @@ bool RsAccountsDetail::checkAccountDirectory() return false; } - return setupAccount(PathAccountDirectory()); + return setupAccount(getCurrentAccountPathAccountDirectory()); } #warning we need to clean that up. Login should only ask for a SSL id, instead of a std::string. @@ -223,7 +216,7 @@ std::string RsAccountsDetail::PathBaseDirectory() } -std::string RsAccountsDetail::PathAccountDirectory() +std::string RsAccountsDetail::getCurrentAccountPathAccountDirectory() { std::string path; @@ -239,9 +232,9 @@ std::string RsAccountsDetail::PathAccountDirectory() return path; } -std::string RsAccountsDetail::PathAccountKeysDirectory() +std::string RsAccountsDetail::getCurrentAccountPathAccountKeysDirectory() { - std::string path = PathAccountDirectory(); + std::string path = getCurrentAccountPathAccountDirectory(); if (path.empty()) { return path; @@ -251,9 +244,9 @@ std::string RsAccountsDetail::PathAccountKeysDirectory() return path; } -std::string RsAccountsDetail::PathKeyFile() +std::string RsAccountsDetail::getCurrentAccountPathKeyFile() { - std::string path = PathAccountKeysDirectory(); + std::string path = getCurrentAccountPathAccountKeysDirectory(); if (path.empty()) { return path; @@ -263,9 +256,9 @@ std::string RsAccountsDetail::PathKeyFile() return path; } -std::string RsAccountsDetail::PathCertFile() +std::string RsAccountsDetail::getCurrentAccountPathCertFile() { - std::string path = PathAccountKeysDirectory(); + std::string path = getCurrentAccountPathAccountKeysDirectory(); if (path.empty()) { return path; @@ -274,7 +267,7 @@ std::string RsAccountsDetail::PathCertFile() return path; } -std::string RsAccountsDetail::LocationName() +std::string RsAccountsDetail::getCurrentAccountLocationName() { std::map::const_iterator it; it = mAccounts.find(mPreferredId); @@ -454,7 +447,7 @@ bool RsAccountsDetail::storePreferredAccount() * */ -bool RsAccountsDetail::getPreferredAccountId(RsPeerId &id) +bool RsAccountsDetail::getCurrentAccountId(RsPeerId &id) { id = mPreferredId; return (!mPreferredId.isNull()); @@ -483,7 +476,7 @@ bool RsAccountsDetail::getAccountIds(std::list &ids) } -bool RsAccountsDetail::getAccountDetails(const RsPeerId &id, +bool RsAccountsDetail::getCurrentAccountDetails(const RsPeerId &id, RsPgpId &gpgId, std::string &gpgName, std::string &gpgEmail, std::string &location) { @@ -500,14 +493,16 @@ bool RsAccountsDetail::getAccountDetails(const RsPeerId &id, return false; } -bool RsAccountsDetail::getAccountOptions(bool &ishidden, bool &isFirstTimeRun) +bool RsAccountsDetail::getCurrentAccountOptions(bool &ishidden,bool& isautotor, bool &isFirstTimeRun) { std::map::iterator it; it = mAccounts.find(mPreferredId); if (it != mAccounts.end()) { - ishidden = it->second.mIsHiddenLoc; + ishidden = it->second.mIsHiddenLoc; isFirstTimeRun = it->second.mFirstRun; + isautotor = it->second.mIsAutoTor; + return true; } return false; @@ -602,7 +597,9 @@ bool RsAccountsDetail::getAvailableAccounts(std::map & std::string lochex = (*it).substr(6); // rest of string. bool hidden_location = false; + bool auto_tor = false; bool valid_prefix = false; + if (prefix == "LOC06_") { valid_prefix = true; @@ -611,6 +608,8 @@ bool RsAccountsDetail::getAvailableAccounts(std::map & { valid_prefix = true; hidden_location = true; + + auto_tor = RsDirUtil::checkDirectory(mBaseDirectory+"/"+*it+"/hidden_service"); } else { @@ -630,7 +629,9 @@ bool RsAccountsDetail::getAvailableAccounts(std::map & AccountDetails tmpId; tmpId.mIsHiddenLoc = hidden_location; + tmpId.mIsAutoTor = auto_tor; tmpId.mAccountDir = *it; + if (checkAccount(accountdir, tmpId,unsupported_keys)) { #ifdef GPG_DEBUG @@ -696,7 +697,7 @@ static bool checkAccount(const std::string &accountdir, AccountDetails &account, std::cerr << "issuerName: " << account.mPgpId << " id: " << account.mSslId << std::endl; #endif - if(! rsAccounts->GetPGPLoginDetails(account.mPgpId, account.mPgpName, account.mPgpEmail)) + if(! RsAccounts::GetPGPLoginDetails(account.mPgpId, account.mPgpName, account.mPgpEmail)) return false ; if(!AuthGPG::getAuthGPG()->haveSecretKey(account.mPgpId)) @@ -987,7 +988,7 @@ bool RsAccountsDetail::copyGnuPGKeyrings() /* Create SSL Certificates */ -bool RsAccountsDetail::GenerateSSLCertificate(const RsPgpId& pgp_id, const std::string& org, const std::string& loc, const std::string& country, const bool ishiddenloc, const std::string& passwd, RsPeerId &sslId, std::string &errString) +bool RsAccountsDetail::GenerateSSLCertificate(const RsPgpId& pgp_id, const std::string& org, const std::string& loc, const std::string& country, bool ishiddenloc,bool isautotor, const std::string& passwd, RsPeerId &sslId, std::string &errString) { /* select the PGP Identity first */ if (!SelectPGPAccount(pgp_id)) @@ -1140,6 +1141,7 @@ bool RsAccountsDetail::GenerateSSLCertificate(const RsPgpId& pgp_id, const s newAccount.mLocation = loc; newAccount.mIsHiddenLoc = ishiddenloc; + newAccount.mIsAutoTor = isautotor; newAccount.mFirstRun = true; @@ -1263,11 +1265,51 @@ bool RsInit::LoadPassword(const std::string& id, const std::string& inPwd) * PUBLIC INTERFACE FUNCTIONS ********************************************************************************/ +bool RsAccounts::init(const std::string& opt_base_dir,int& error_code) +{ + rsAccounts = new RsAccountsDetail ; + + // first check config directories, and set bootstrap values. + if(!rsAccounts->setupBaseDirectory(opt_base_dir)) + { + error_code = RS_INIT_BASE_DIR_ERROR ; + return false ; + } + + // Setup PGP stuff. + std::string pgp_dir = rsAccounts->PathPGPDirectory(); + + if(!RsDirUtil::checkCreateDirectory(pgp_dir)) + throw std::runtime_error("Cannot create pgp directory " + pgp_dir) ; + + AuthGPG::init( pgp_dir + "/retroshare_public_keyring.gpg", + pgp_dir + "/retroshare_secret_keyring.gpg", + pgp_dir + "/retroshare_trustdb.gpg", + pgp_dir + "/lock"); + + // load Accounts. + if (!rsAccounts->loadAccounts()) + { + error_code = RS_INIT_NO_KEYRING ; + return false ; + } + return true; +} + // Directories. std::string RsAccounts::ConfigDirectory() { return RsAccountsDetail::PathBaseDirectory(); } -std::string RsAccounts::DataDirectory(bool check) { return RsAccountsDetail::PathDataDirectory(check); } +std::string RsAccounts::systemDataDirectory(bool check) { return RsAccountsDetail::PathDataDirectory(check); } std::string RsAccounts::PGPDirectory() { return rsAccounts->PathPGPDirectory(); } -std::string RsAccounts::AccountDirectory() { return rsAccounts->PathAccountDirectory(); } +std::string RsAccounts::AccountDirectory() { return rsAccounts->getCurrentAccountPathAccountDirectory(); } +std::string RsAccounts::AccountKeysDirectory() { return rsAccounts->getCurrentAccountPathAccountKeysDirectory(); } +std::string RsAccounts::AccountPathCertFile() { return rsAccounts->getCurrentAccountPathCertFile(); } +std::string RsAccounts::AccountPathKeyFile() { return rsAccounts->getCurrentAccountPathKeyFile(); } +std::string RsAccounts::AccountLocationName() { return rsAccounts->getCurrentAccountLocationName(); } + +bool RsAccounts::lockPreferredAccount() { return rsAccounts->lockPreferredAccount();} // are these methods any useful?? +void RsAccounts::unlockPreferredAccount() { rsAccounts->unlockPreferredAccount(); } + +bool RsAccounts::checkCreateAccountDirectory() { return rsAccounts->checkAccountDirectory(); } // PGP Accounts. int RsAccounts::GetPGPLogins(std::list &pgpIds) @@ -1311,6 +1353,7 @@ bool RsAccounts::CopyGnuPGKeyrings() return rsAccounts->copyGnuPGKeyrings(); } +void RsAccounts::storeSelectedAccount() { rsAccounts->storePreferredAccount() ;} // Rs Accounts bool RsAccounts::SelectAccount(const RsPeerId &id) { @@ -1319,7 +1362,40 @@ bool RsAccounts::SelectAccount(const RsPeerId &id) bool RsAccounts::GetPreferredAccountId(RsPeerId &id) { - return rsAccounts->getPreferredAccountId(id); + return rsAccounts->getCurrentAccountId(id); +} + +bool RsAccounts::getCurrentAccountOptions(bool& is_hidden,bool& is_tor_auto,bool& is_first_time) +{ + return rsAccounts->getCurrentAccountOptions(is_hidden,is_tor_auto,is_first_time); +} +bool RsAccounts::isHiddenNode() +{ + bool hidden = false ; + bool is_tor_only = false ; + bool is_first_time = false ; + + if(!getCurrentAccountOptions(hidden,is_tor_only,is_first_time)) + { + std::cerr << "(EE) Critical problem: RsAccounts::getCurrentAccountOptions() called but no account chosen!" << std::endl; + throw std::runtime_error("inconsistent configuration") ; + } + + return hidden ; +} +bool RsAccounts::isTorAuto() +{ + bool hidden = false ; + bool is_tor_only = false ; + bool is_first_time = false ; + + if(!getCurrentAccountOptions(hidden,is_tor_only,is_first_time)) + { + std::cerr << "(EE) Critical problem: RsAccounts::getCurrentAccountOptions() called but no account chosen!" << std::endl; + throw std::runtime_error("inconsistent configuration") ; + } + + return is_tor_only ; } bool RsAccounts::GetAccountIds(std::list &ids) @@ -1331,12 +1407,15 @@ bool RsAccounts::GetAccountDetails(const RsPeerId &id, RsPgpId &pgpId, std::string &pgpName, std::string &pgpEmail, std::string &location) { - return rsAccounts->getAccountDetails(id, pgpId, pgpName, pgpEmail, location); + return rsAccounts->getCurrentAccountDetails(id, pgpId, pgpName, pgpEmail, location); } -bool RsAccounts::GenerateSSLCertificate(const RsPgpId& pgp_id, const std::string& org, const std::string& loc, const std::string& country, const bool ishiddenloc, const std::string& passwd, RsPeerId &sslId, std::string &errString) +bool RsAccounts::createNewAccount( + const RsPgpId& pgp_id, const std::string& org, const std::string& loc, + const std::string& country, bool ishiddenloc, bool isautotor, + const std::string& passwd, RsPeerId &sslId, std::string &errString ) { - return rsAccounts->GenerateSSLCertificate(pgp_id, org, loc, country, ishiddenloc, passwd, sslId, errString); + return rsAccounts->GenerateSSLCertificate(pgp_id, org, loc, country, ishiddenloc, isautotor, passwd, sslId, errString); } /********************************************************************************* diff --git a/libretroshare/src/rsserver/rsaccounts.h b/libretroshare/src/rsserver/rsaccounts.h index 8ff253587..518885a47 100644 --- a/libretroshare/src/rsserver/rsaccounts.h +++ b/libretroshare/src/rsserver/rsaccounts.h @@ -1,28 +1,24 @@ -/* - * libretroshare/src/rsserver/rsaccounts.h - * - * RetroShare C++ Interface. - * - * Copyright 2013-2014 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/rsserver: rsaccounts.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2013-2014 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ /********************************************************************* * Header providing interface for libretroshare access to RsAccounts stuff. @@ -53,6 +49,7 @@ class AccountDetails std::string mLocation; bool mIsHiddenLoc; bool mFirstRun; + bool mIsAutoTor; }; @@ -62,9 +59,6 @@ class RsAccountsDetail RsAccountsDetail(); // These functions are externally accessible via RsAccounts namespace. - - - // These functions are accessible from inside libretroshare. bool setupBaseDirectory(std::string alt_basedir); @@ -91,52 +85,43 @@ class RsAccountsDetail // PGP Path is only dependent on BaseDirectory. std::string PathPGPDirectory(); - // Below are dependent on mPreferredId. - std::string PathAccountDirectory(); - std::string PathAccountKeysDirectory(); - std::string PathKeyFile(); - std::string PathCertFile(); - std::string LocationName(); + // Generate a new account based on a given PGP key returns its SSL id and sets it to be the preferred account. + + bool GenerateSSLCertificate(const RsPgpId& gpg_id, const std::string& org, const std::string& loc, const std::string& country, bool ishiddenloc, bool is_auto_tor,const std::string& passwd, RsPeerId &sslId, std::string &errString); // PGP Accounts. int GetPGPLogins(std::list &pgpIds); - int GetPGPLoginDetails(const RsPgpId& id, std::string &name, std::string &email); + int GetPGPLoginDetails(const RsPgpId& id, std::string &name, std::string &email); bool GeneratePGPCertificate(const std::string&, const std::string& email, const std::string& passwd, RsPgpId &pgpId, const int keynumbits, std::string &errString); - - bool SelectPGPAccount(const RsPgpId& pgpId); + bool SelectPGPAccount(const RsPgpId& pgpId); // PGP Support Functions. bool exportIdentity(const std::string& fname,const RsPgpId& pgp_id) ; bool importIdentity(const std::string& fname,RsPgpId& imported_pgp_id,std::string& import_error) ; bool importIdentityFromString(const std::string& data,RsPgpId& imported_pgp_id,std::string& import_error) ; - void getUnsupportedKeys(std::map > &unsupported_keys); + void getUnsupportedKeys(std::map > &unsupported_keys); bool copyGnuPGKeyrings() ; - // Selecting Rs Account. + bool getAccountIds(std::list &ids); bool selectAccountByString(const std::string &prefUserString); bool selectId(const RsPeerId& preferredId); - - // Details of Rs Account. - bool getPreferredAccountId(RsPeerId &id); - bool getAccountDetails(const RsPeerId &id, RsPgpId& gpgId, std::string &gpgName, std::string &gpgEmail, std::string &location); - - bool getAccountOptions(bool &ishidden, bool &isFirstTimeRun); - - - bool getAccountIds(std::list &ids); - - bool GenerateSSLCertificate(const RsPgpId& gpg_id, - const std::string& org, const std::string& loc, - const std::string& country, const bool ishiddenloc, - const std::string& passwd, RsPeerId &sslId, - std::string &errString); - - // From init file. bool storePreferredAccount(); bool loadPreferredAccount(); + // Details of current Rs Account. + bool getCurrentAccountId(RsPeerId &id); + bool getCurrentAccountDetails(const RsPeerId &id, RsPgpId& gpgId, std::string &gpgName, std::string &gpgEmail, std::string &location); + bool getCurrentAccountOptions(bool &ishidden, bool &isautotor, bool &isFirstTimeRun); + + std::string getCurrentAccountPathAccountDirectory(); + std::string getCurrentAccountPathAccountKeysDirectory(); + std::string getCurrentAccountPathKeyFile(); + std::string getCurrentAccountPathCertFile(); + std::string getCurrentAccountLocationName(); + + private: bool checkPreferredId(); @@ -159,6 +144,4 @@ class RsAccountsDetail std::map > mUnsupportedKeys ; }; -// Global singleton declaration of data. -extern RsAccountsDetail *rsAccounts; diff --git a/libretroshare/src/rsserver/rsinit.cc b/libretroshare/src/rsserver/rsinit.cc index 095dbaeaf..3a76fd79a 100644 --- a/libretroshare/src/rsserver/rsinit.cc +++ b/libretroshare/src/rsserver/rsinit.cc @@ -1,27 +1,24 @@ -/* - * libretroshare/src/reserver rsinit.cc - * - * RetroShare C++ Interface. - * - * Copyright 2004-2006 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ +/******************************************************************************* + * libretroshare/src/retroshare: rsinit.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2006 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ /* This is an updated startup class. Class variables are hidden from * the GUI / External via a hidden class */ @@ -62,6 +59,7 @@ #include #include "gxstunnel/p3gxstunnel.h" +#include "retroshare/rsgxsdistsync.h" #include "file_sharing/p3filelists.h" #define ENABLE_GROUTER @@ -103,7 +101,9 @@ RsDht *rsDht = NULL ; //std::map > RsInit::unsupported_keys ; -class RsInitConfig +RsLoginHelper* rsLoginHelper; + +class RsInitConfig { public: @@ -433,26 +433,12 @@ int RsInit::InitRetroShare(int argc, char **argv, bool /* strictCheck */) AuthSSL::AuthSSLInit(); AuthSSL::getAuthSSL() -> InitAuth(NULL, NULL, NULL, ""); - rsAccounts = new RsAccountsDetail(); + rsLoginHelper = new RsLoginHelper; - // first check config directories, and set bootstrap values. - if(!rsAccounts->setupBaseDirectory(opt_base_dir)) - return RS_INIT_BASE_DIR_ERROR ; + int error_code ; - // Setup PGP stuff. - std::string pgp_dir = rsAccounts->PathPGPDirectory(); - - if(!RsDirUtil::checkCreateDirectory(pgp_dir)) - throw std::runtime_error("Cannot create pgp directory " + pgp_dir) ; - - AuthGPG::init( pgp_dir + "/retroshare_public_keyring.gpg", - pgp_dir + "/retroshare_secret_keyring.gpg", - pgp_dir + "/retroshare_trustdb.gpg", - pgp_dir + "/lock"); - - // load Accounts. - if (!rsAccounts->loadAccounts()) - return RS_INIT_NO_KEYRING ; + if(!RsAccounts::init(opt_base_dir,error_code)) + return error_code ; // choose alternative account. if(prefUserString != "") @@ -466,7 +452,7 @@ int RsInit::InitRetroShare(int argc, char **argv, bool /* strictCheck */) return RS_INIT_AUTH_FAILED ; } - if(rsAccounts->selectId(ssl_id)) + if(RsAccounts::SelectAccount(ssl_id)) { std::cerr << "Auto-selectng account ID " << ssl_id << std::endl; return RS_INIT_HAVE_ACCOUNT; @@ -476,7 +462,7 @@ int RsInit::InitRetroShare(int argc, char **argv, bool /* strictCheck */) #ifdef RS_AUTOLOGIN /* check that we have selected someone */ RsPeerId preferredId; - bool existingUser = rsAccounts->getPreferredAccountId(preferredId); + bool existingUser = RsAccounts::GetPreferredAccountId(preferredId); if (existingUser) { @@ -503,12 +489,21 @@ int RsInit::InitRetroShare(int argc, char **argv, bool /* strictCheck */) * 1 : Another instance already has the lock * 2 : Unexpected error */ -int RsInit::LockConfigDirectory(const std::string& accountDir, std::string& lockFilePath) +RsInit::LoadCertificateStatus RsInit::LockConfigDirectory( + const std::string& accountDir, std::string& lockFilePath ) { const std::string lockFile = accountDir + "/" + "lock"; lockFilePath = lockFile; - return RsDirUtil::createLockFile(lockFile,rsInitConfig->lockHandle) ; + int rt = RsDirUtil::createLockFile(lockFile,rsInitConfig->lockHandle); + + switch (rt) + { + case 0: return RsInit::OK; + case 1: return RsInit::ERR_ALREADY_RUNNING; + case 2: return RsInit::ERR_CANT_ACQUIRE_LOCK; + default: return RsInit::ERR_UNKOWN; + } } /* @@ -540,56 +535,47 @@ bool RsInit::LoadPassword(const std::string& inPwd) return true; } - -/** - * Locks the profile directory and tries to finalize the login procedure - * - * Return value: - * 0 : success - * 1 : another instance is already running - * 2 : unexpected error while locking - * 3 : unexpected error while loading certificates - */ -int RsInit::LockAndLoadCertificates(bool autoLoginNT, std::string& lockFilePath) +RsInit::LoadCertificateStatus RsInit::LockAndLoadCertificates( + bool autoLoginNT, std::string& lockFilePath ) { - if (!rsAccounts->lockPreferredAccount()) + try { - return 3; // invalid PreferredAccount. + if (!RsAccounts::lockPreferredAccount()) + throw RsInit::ERR_UNKOWN; // invalid PreferredAccount. + + // Logic that used to be external to RsInit... + RsPeerId accountId; + if (!RsAccounts::GetPreferredAccountId(accountId)) + throw RsInit::ERR_UNKOWN; // invalid PreferredAccount; + + RsPgpId pgpId; + std::string pgpName, pgpEmail, location; + + if(!RsAccounts::GetAccountDetails(accountId, pgpId, pgpName, pgpEmail, location)) + throw RsInit::ERR_UNKOWN; // invalid PreferredAccount; + + if(0 == AuthGPG::getAuthGPG() -> GPGInit(pgpId)) + throw RsInit::ERR_UNKOWN; // PGP Error. + + LoadCertificateStatus retVal = + LockConfigDirectory(RsAccounts::AccountDirectory(), lockFilePath); + + if(retVal > 0) + throw retVal ; + + if(LoadCertificates(autoLoginNT) != 1) + { + UnlockConfigDirectory(); + throw RsInit::ERR_UNKOWN; + } + + return RsInit::OK; } - - int retVal = 0; - - // Logic that used to be external to RsInit... - RsPeerId accountId; - if (!rsAccounts->getPreferredAccountId(accountId)) - { - retVal = 3; // invalid PreferredAccount; - } - - RsPgpId pgpId; - std::string pgpName, pgpEmail, location; - - if (retVal == 0 && !rsAccounts->getAccountDetails(accountId, pgpId, pgpName, pgpEmail, location)) - retVal = 3; // invalid PreferredAccount; - - if (retVal == 0 && !rsAccounts->SelectPGPAccount(pgpId)) - retVal = 3; // PGP Error. - - if(retVal == 0) - retVal = LockConfigDirectory(rsAccounts->PathAccountDirectory(), lockFilePath); - - if(retVal == 0 && LoadCertificates(autoLoginNT) != 1) - { - UnlockConfigDirectory(); - retVal = 3; - } - - if(retVal != 0) - { - rsAccounts->unlockPreferredAccount(); - } - - return retVal; + catch(LoadCertificateStatus retVal) + { + RsAccounts::unlockPreferredAccount(); + return retVal ; + } } @@ -605,20 +591,20 @@ int RsInit::LockAndLoadCertificates(bool autoLoginNT, std::string& lockFilePath int RsInit::LoadCertificates(bool autoLoginNT) { RsPeerId preferredId; - if (!rsAccounts->getPreferredAccountId(preferredId)) + if (!RsAccounts::GetPreferredAccountId(preferredId)) { std::cerr << "No Account Selected" << std::endl; return 0; } - if (rsAccounts->PathCertFile() == "") + if (RsAccounts::AccountPathCertFile() == "") { std::cerr << "RetroShare needs a certificate" << std::endl; return 0; } - if (rsAccounts->PathKeyFile() == "") + if (RsAccounts::AccountPathKeyFile() == "") { std::cerr << "RetroShare needs a key" << std::endl; return 0; @@ -640,9 +626,10 @@ int RsInit::LoadCertificates(bool autoLoginNT) } } - std::cerr << "rsAccounts->PathKeyFile() : " << rsAccounts->PathKeyFile() << std::endl; + std::cerr << "rsAccounts->PathKeyFile() : " << RsAccounts::AccountPathKeyFile() << std::endl; - if(0 == AuthSSL::getAuthSSL() -> InitAuth(rsAccounts->PathCertFile().c_str(), rsAccounts->PathKeyFile().c_str(), rsInitConfig->passwd.c_str(), rsAccounts->LocationName())) + if(0 == AuthSSL::getAuthSSL() -> InitAuth(RsAccounts::AccountPathCertFile().c_str(), RsAccounts::AccountPathKeyFile().c_str(), rsInitConfig->passwd.c_str(), + RsAccounts::AccountLocationName())) { std::cerr << "SSL Auth Failed!"; return 0 ; @@ -667,7 +654,7 @@ int RsInit::LoadCertificates(bool autoLoginNT) rsInitConfig->gxs_passwd = rsInitConfig->passwd; rsInitConfig->passwd = ""; - rsAccounts->storePreferredAccount(); + RsAccounts::storeSelectedAccount(); return 1; } @@ -675,7 +662,7 @@ int RsInit::LoadCertificates(bool autoLoginNT) bool RsInit::RsClearAutoLogin() { RsPeerId preferredId; - if (!rsAccounts->getPreferredAccountId(preferredId)) + if (!RsAccounts::GetPreferredAccountId(preferredId)) { std::cerr << "RsInit::RsClearAutoLogin() No Account Selected" << std::endl; return 0; @@ -835,11 +822,8 @@ RsGRouter *rsGRouter = NULL ; #include "pqi/p3linkmgr.h" #include "pqi/p3netmgr.h" -#ifndef RETROTOR #include "tcponudp/tou.h" #include "tcponudp/rsudpstack.h" -#endif - #ifdef RS_USE_BITDHT #include "dht/p3bitdht.h" @@ -886,6 +870,17 @@ RsControl *RsControl::instance() int RsServer::StartupRetroShare() { + RsPeerId ownId = AuthSSL::getAuthSSL()->OwnId(); + + std::cerr << "========================================================================" << std::endl; + std::cerr << "== RsInit:: starting up Retroshare core ==" << std::endl; + std::cerr << "== ==" << std::endl; + std::cerr << "== Account/SSL ID : " << ownId << " ==" << std::endl; + std::cerr << "== Node type : " << (RsAccounts::isHiddenNode()?"Hidden":"Normal") << " ==" << std::endl; + if(RsAccounts::isHiddenNode()) + std::cerr << "== Tor/I2P configuration : " << (RsAccounts::isTorAuto()?"Tor Auto":"Manual ") << " ==" << std::endl; + std::cerr << "========================================================================" << std::endl; + /**************************************************************************/ /* STARTUP procedure */ /**************************************************************************/ @@ -901,8 +896,6 @@ int RsServer::StartupRetroShare() return false ; } - RsPeerId ownId = AuthSSL::getAuthSSL()->OwnId(); - /**************************************************************************/ /* Any Initial Configuration (Commandline Options) */ /**************************************************************************/ @@ -911,7 +904,7 @@ int RsServer::StartupRetroShare() std::cerr << "set the debugging to crashMode." << std::endl; if ((!rsInitConfig->haveLogFile) && (!rsInitConfig->outStderr)) { - std::string crashfile = rsAccounts->PathAccountDirectory(); + std::string crashfile = RsAccounts::AccountDirectory(); crashfile += "/" + configLogFileName; setDebugCrashMode(crashfile.c_str()); } @@ -923,7 +916,7 @@ int RsServer::StartupRetroShare() } /* check account directory */ - if (!rsAccounts->checkAccountDirectory()) + if (!RsAccounts::checkCreateAccountDirectory()) { std::cerr << "RsServer::StartupRetroShare() - Fatal Error....." << std::endl; std::cerr << "checkAccount failed!" << std::endl; @@ -935,8 +928,8 @@ int RsServer::StartupRetroShare() // Load up Certificates, and Old Configuration (if present) std::cerr << "Load up Certificates, and Old Configuration (if present)." << std::endl; - std::string emergencySaveDir = rsAccounts->PathAccountDirectory(); - std::string emergencyPartialsDir = rsAccounts->PathAccountDirectory(); + std::string emergencySaveDir = RsAccounts::AccountDirectory(); + std::string emergencyPartialsDir = RsAccounts::AccountDirectory(); if (emergencySaveDir != "") { emergencySaveDir += "/"; @@ -950,13 +943,15 @@ int RsServer::StartupRetroShare() /**************************************************************************/ std::cerr << "Load Configuration" << std::endl; - mConfigMgr = new p3ConfigMgr(rsAccounts->PathAccountDirectory()); + mConfigMgr = new p3ConfigMgr(RsAccounts::AccountDirectory()); mGeneralConfig = new p3GeneralConfig(); // Get configuration options from rsAccounts. bool isHiddenNode = false; bool isFirstTimeRun = false; - rsAccounts->getAccountOptions(isHiddenNode, isFirstTimeRun); + bool isTorAuto = false; + + RsAccounts::getCurrentAccountOptions(isHiddenNode,isTorAuto, isFirstTimeRun); /**************************************************************************/ /* setup classes / structures */ @@ -997,36 +992,40 @@ int RsServer::StartupRetroShare() sockaddr_clear(&tmpladdr); tmpladdr.sin_port = htons(rsInitConfig->port); + rsUdpStack *mDhtStack = NULL ; + if(!RsAccounts::isHiddenNode()) + { #ifdef LOCALNET_TESTING - rsUdpStack *mDhtStack = new rsUdpStack(UDP_TEST_RESTRICTED_LAYER, tmpladdr); + mDhtStack = new rsUdpStack(UDP_TEST_RESTRICTED_LAYER, tmpladdr); - /* parse portRestrictions */ - unsigned int lport, uport; + /* parse portRestrictions */ + unsigned int lport, uport; - if (doPortRestrictions) - { - if (2 == sscanf(portRestrictions.c_str(), "%u-%u", &lport, &uport)) + if (doPortRestrictions) { - std::cerr << "Adding Port Restriction (" << lport << "-" << uport << ")"; - std::cerr << std::endl; - } - else - { - std::cerr << "Failed to parse Port Restrictions ... exiting"; - std::cerr << std::endl; - exit(1); - } + if (2 == sscanf(portRestrictions.c_str(), "%u-%u", &lport, &uport)) + { + std::cerr << "Adding Port Restriction (" << lport << "-" << uport << ")"; + std::cerr << std::endl; + } + else + { + std::cerr << "Failed to parse Port Restrictions ... exiting"; + std::cerr << std::endl; + exit(1); + } - RestrictedUdpLayer *url = (RestrictedUdpLayer *) mDhtStack->getUdpLayer(); - url->addRestrictedPortRange(lport, uport); - } + RestrictedUdpLayer *url = (RestrictedUdpLayer *) mDhtStack->getUdpLayer(); + url->addRestrictedPortRange(lport, uport); + } #else //LOCALNET_TESTING #ifdef RS_USE_BITDHT - rsUdpStack *mDhtStack = new rsUdpStack(tmpladdr); + mDhtStack = new rsUdpStack(tmpladdr); #endif #endif //LOCALNET_TESTING + } #ifdef RS_USE_BITDHT @@ -1034,12 +1033,12 @@ int RsServer::StartupRetroShare() #define BITDHT_FILTERED_IP_FILENAME "bdfilter.txt" - std::string bootstrapfile = rsAccounts->PathAccountDirectory(); + std::string bootstrapfile = RsAccounts::AccountDirectory(); if (bootstrapfile != "") bootstrapfile += "/"; bootstrapfile += BITDHT_BOOTSTRAP_FILENAME; - std::string filteredipfile = rsAccounts->PathAccountDirectory(); + std::string filteredipfile = RsAccounts::AccountDirectory(); if (filteredipfile != "") filteredipfile += "/"; filteredipfile += BITDHT_FILTERED_IP_FILENAME; @@ -1079,7 +1078,7 @@ int RsServer::StartupRetroShare() bdbootRF.close(); } #else - std::string installfile = rsAccounts->PathDataDirectory(); + std::string installfile = RsAccounts::systemDataDirectory(); installfile += "/"; installfile += BITDHT_BOOTSTRAP_FILENAME; @@ -1106,96 +1105,105 @@ int RsServer::StartupRetroShare() /* construct the rest of the stack, important to build them in the correct order! */ /* MOST OF THIS IS COMMENTED OUT UNTIL THE REST OF libretroshare IS READY FOR IT! */ - UdpSubReceiver *udpReceivers[RSUDP_NUM_TOU_RECVERS]; - int udpTypes[RSUDP_NUM_TOU_RECVERS]; + p3BitDht *mBitDht = NULL ; + rsDht = NULL ; + rsFixedUdpStack *mProxyStack = NULL ; -#ifdef RS_USE_DHT_STUNNER - // FIRST DHT STUNNER. - UdpStunner *mDhtStunner = new UdpStunner(mDhtStack); - mDhtStunner->setTargetStunPeriod(300); /* slow (5mins) */ - mDhtStack->addReceiver(mDhtStunner); - -#ifdef LOCALNET_TESTING - mDhtStunner->SetAcceptLocalNet(); -#endif -#endif // RS_USE_DHT_STUNNER - - - // NEXT BITDHT. - p3BitDht *mBitDht = new p3BitDht(ownId, mLinkMgr, mNetMgr, mDhtStack, bootstrapfile, filteredipfile); - - /* install external Pointer for Interface */ - rsDht = mBitDht; - - // NEXT THE RELAY (NEED to keep a reference for installing RELAYS) - UdpRelayReceiver *mRelay = new UdpRelayReceiver(mDhtStack); - udpReceivers[RSUDP_TOU_RECVER_RELAY_IDX] = mRelay; /* RELAY Connections (DHT Port) */ - udpTypes[RSUDP_TOU_RECVER_RELAY_IDX] = TOU_RECEIVER_TYPE_UDPRELAY; - mDhtStack->addReceiver(udpReceivers[RSUDP_TOU_RECVER_RELAY_IDX]); - - // LAST ON THIS STACK IS STANDARD DIRECT TOU - udpReceivers[RSUDP_TOU_RECVER_DIRECT_IDX] = new UdpPeerReceiver(mDhtStack); /* standard DIRECT Connections (DHT Port) */ - udpTypes[RSUDP_TOU_RECVER_DIRECT_IDX] = TOU_RECEIVER_TYPE_UDPPEER; - mDhtStack->addReceiver(udpReceivers[RSUDP_TOU_RECVER_DIRECT_IDX]); - - // NOW WE BUILD THE SECOND STACK. - // Create the Second UdpStack... Port should be random (but openable!). - // We do this by binding to xx.xx.xx.xx:0 which which gives us a random port. - - struct sockaddr_in sndladdr; - sockaddr_clear(&sndladdr); - -#ifdef LOCALNET_TESTING - - // // HACK Proxy Port near Dht Port - For Relay Testing. - // uint16_t rndport = rsInitConfig->port + 3; - // sndladdr.sin_port = htons(rndport); - - rsFixedUdpStack *mProxyStack = new rsFixedUdpStack(UDP_TEST_RESTRICTED_LAYER, sndladdr); - - /* portRestrictions already parsed */ - if (doPortRestrictions) + if(!RsAccounts::isHiddenNode()) { - RestrictedUdpLayer *url = (RestrictedUdpLayer *) mProxyStack->getUdpLayer(); - url->addRestrictedPortRange(lport, uport); - } -#else - rsFixedUdpStack *mProxyStack = new rsFixedUdpStack(sndladdr); -#endif + UdpSubReceiver *udpReceivers[RSUDP_NUM_TOU_RECVERS]; + int udpTypes[RSUDP_NUM_TOU_RECVERS]; #ifdef RS_USE_DHT_STUNNER - // FIRSTLY THE PROXY STUNNER. - UdpStunner *mProxyStunner = new UdpStunner(mProxyStack); - mProxyStunner->setTargetStunPeriod(300); /* slow (5mins) */ - mProxyStack->addReceiver(mProxyStunner); + // FIRST DHT STUNNER. + UdpStunner *mDhtStunner = new UdpStunner(mDhtStack); + mDhtStunner->setTargetStunPeriod(300); /* slow (5mins) */ + mDhtStack->addReceiver(mDhtStunner); #ifdef LOCALNET_TESTING - mProxyStunner->SetAcceptLocalNet(); + mDhtStunner->SetAcceptLocalNet(); #endif #endif // RS_USE_DHT_STUNNER - // FINALLY THE PROXY UDP CONNECTIONS - udpReceivers[RSUDP_TOU_RECVER_PROXY_IDX] = new UdpPeerReceiver(mProxyStack); /* PROXY Connections (Alt UDP Port) */ - udpTypes[RSUDP_TOU_RECVER_PROXY_IDX] = TOU_RECEIVER_TYPE_UDPPEER; - mProxyStack->addReceiver(udpReceivers[RSUDP_TOU_RECVER_PROXY_IDX]); + // NEXT BITDHT. - // REAL INITIALISATION - WITH THREE MODES - tou_init((void **) udpReceivers, udpTypes, RSUDP_NUM_TOU_RECVERS); + + mBitDht = new p3BitDht(ownId, mLinkMgr, mNetMgr, mDhtStack, bootstrapfile, filteredipfile); + + // NEXT THE RELAY (NEED to keep a reference for installing RELAYS) + UdpRelayReceiver *mRelay = new UdpRelayReceiver(mDhtStack); + udpReceivers[RSUDP_TOU_RECVER_RELAY_IDX] = mRelay; /* RELAY Connections (DHT Port) */ + udpTypes[RSUDP_TOU_RECVER_RELAY_IDX] = TOU_RECEIVER_TYPE_UDPRELAY; + mDhtStack->addReceiver(udpReceivers[RSUDP_TOU_RECVER_RELAY_IDX]); + + // LAST ON THIS STACK IS STANDARD DIRECT TOU + udpReceivers[RSUDP_TOU_RECVER_DIRECT_IDX] = new UdpPeerReceiver(mDhtStack); /* standard DIRECT Connections (DHT Port) */ + udpTypes[RSUDP_TOU_RECVER_DIRECT_IDX] = TOU_RECEIVER_TYPE_UDPPEER; + mDhtStack->addReceiver(udpReceivers[RSUDP_TOU_RECVER_DIRECT_IDX]); + + /* install external Pointer for Interface */ + rsDht = mBitDht; + + // NOW WE BUILD THE SECOND STACK. + // Create the Second UdpStack... Port should be random (but openable!). + // We do this by binding to xx.xx.xx.xx:0 which which gives us a random port. + + struct sockaddr_in sndladdr; + sockaddr_clear(&sndladdr); + +#ifdef LOCALNET_TESTING + + // // HACK Proxy Port near Dht Port - For Relay Testing. + // uint16_t rndport = rsInitConfig->port + 3; + // sndladdr.sin_port = htons(rndport); + + mProxyStack = new rsFixedUdpStack(UDP_TEST_RESTRICTED_LAYER, sndladdr); + + /* portRestrictions already parsed */ + if (doPortRestrictions) + { + RestrictedUdpLayer *url = (RestrictedUdpLayer *) mProxyStack->getUdpLayer(); + url->addRestrictedPortRange(lport, uport); + } +#else + mProxyStack = new rsFixedUdpStack(sndladdr); +#endif #ifdef RS_USE_DHT_STUNNER - mBitDht->setupConnectBits(mDhtStunner, mProxyStunner, mRelay); + // FIRSTLY THE PROXY STUNNER. + UdpStunner *mProxyStunner = new UdpStunner(mProxyStack); + mProxyStunner->setTargetStunPeriod(300); /* slow (5mins) */ + mProxyStack->addReceiver(mProxyStunner); + +#ifdef LOCALNET_TESTING + mProxyStunner->SetAcceptLocalNet(); +#endif +#endif // RS_USE_DHT_STUNNER + + + // FINALLY THE PROXY UDP CONNECTIONS + udpReceivers[RSUDP_TOU_RECVER_PROXY_IDX] = new UdpPeerReceiver(mProxyStack); /* PROXY Connections (Alt UDP Port) */ + udpTypes[RSUDP_TOU_RECVER_PROXY_IDX] = TOU_RECEIVER_TYPE_UDPPEER; + mProxyStack->addReceiver(udpReceivers[RSUDP_TOU_RECVER_PROXY_IDX]); + + // REAL INITIALISATION - WITH THREE MODES + tou_init((void **) udpReceivers, udpTypes, RSUDP_NUM_TOU_RECVERS); + +#ifdef RS_USE_DHT_STUNNER + mBitDht->setupConnectBits(mDhtStunner, mProxyStunner, mRelay); #else // RS_USE_DHT_STUNNER - mBitDht->setupConnectBits(mRelay); + mBitDht->setupConnectBits(mRelay); #endif // RS_USE_DHT_STUNNER #ifdef RS_USE_DHT_STUNNER - mNetMgr->setAddrAssist(new stunAddrAssist(mDhtStunner), new stunAddrAssist(mProxyStunner)); + mNetMgr->setAddrAssist(new stunAddrAssist(mDhtStunner), new stunAddrAssist(mProxyStunner)); #endif // RS_USE_DHT_STUNNER -// #else //RS_USE_BITDHT -// /* install NULL Pointer for rsDht Interface */ -// rsDht = NULL; + // #else //RS_USE_BITDHT + // /* install NULL Pointer for rsDht Interface */ + // rsDht = NULL; #endif //RS_USE_BITDHT + } /**************************** BITDHT ***********************************/ @@ -1210,7 +1218,7 @@ int RsServer::StartupRetroShare() /****** New Ft Server **** !!! */ ftServer *ftserver = new ftServer(mPeerMgr, serviceCtrl); - ftserver->setConfigDirectory(rsAccounts->PathAccountDirectory()); + ftserver->setConfigDirectory(RsAccounts::AccountDirectory()); ftserver->SetupFtServer() ; @@ -1226,12 +1234,12 @@ int RsServer::StartupRetroShare() std::vector plugins_directories ; #ifdef __APPLE__ - plugins_directories.push_back(rsAccounts->PathDataDirectory()) ; + plugins_directories.push_back(RsAccounts::systemDataDirectory()) ; #endif #if !defined(WINDOWS_SYS) && defined(PLUGIN_DIR) plugins_directories.push_back(std::string(PLUGIN_DIR)) ; #endif - std::string extensions_dir = rsAccounts->PathBaseDirectory() + "/extensions6/" ; + std::string extensions_dir = RsAccounts::ConfigDirectory() + "/extensions6/" ; plugins_directories.push_back(extensions_dir) ; if(!RsDirUtil::checkCreateDirectory(extensions_dir)) @@ -1274,11 +1282,20 @@ int RsServer::StartupRetroShare() #ifdef RS_ENABLE_GXS - std::string currGxsDir = rsAccounts->PathAccountDirectory() + "/gxs"; + std::string currGxsDir = RsAccounts::AccountDirectory() + "/gxs"; RsDirUtil::checkCreateDirectory(currGxsDir); RsNxsNetMgr* nxsMgr = new RsNxsNetMgrImpl(serviceCtrl); + /**** GXS Dist sync service ****/ + +#ifdef RS_USE_GXS_DISTANT_SYNC + RsGxsNetTunnelService *mGxsNetTunnel = new RsGxsNetTunnelService ; + rsGxsDistSync = mGxsNetTunnel ; +#else + RsGxsNetTunnelService *mGxsNetTunnel = NULL ; +#endif + /**** Identity service ****/ RsGeneralDataService* gxsid_ds = new RsDataService(currGxsDir + "/", "gxsid_db", @@ -1300,9 +1317,10 @@ int RsServer::StartupRetroShare() RS_SERVICE_GXS_TYPE_GXSID, gxsid_ds, nxsMgr, mGxsIdService, mGxsIdService->getServiceInfo(), mReputations, mGxsCircles,mGxsIdService, - pgpAuxUtils, - false,false); // don't synchronise group automatic (need explicit group request) + pgpAuxUtils,mGxsNetTunnel, + false,false,true); // don't synchronise group automatic (need explicit group request) // don't sync messages at all. + // allow distsync, so that we can grab GXS id requests for other services // Normally we wouldn't need this (we do in other service): // mGxsIdService->setNetworkExchangeService(gxsid_ns) ; @@ -1319,9 +1337,7 @@ int RsServer::StartupRetroShare() RS_SERVICE_GXS_TYPE_GXSCIRCLE, gxscircles_ds, nxsMgr, mGxsCircles, mGxsCircles->getServiceInfo(), mReputations, mGxsCircles,mGxsIdService, - pgpAuxUtils, - true, // synchronise group automatic - true); // sync messages automatic, since they contain subscription requests. + pgpAuxUtils); mGxsCircles->setNetworkExchangeService(gxscircles_ns) ; @@ -1373,7 +1389,7 @@ int RsServer::StartupRetroShare() RS_SERVICE_GXS_TYPE_FORUMS, gxsforums_ds, nxsMgr, mGxsForums, mGxsForums->getServiceInfo(), mReputations, mGxsCircles,mGxsIdService, - pgpAuxUtils); + pgpAuxUtils);//,mGxsNetTunnel,true,true,true); mGxsForums->setNetworkExchangeService(gxsforums_ns) ; @@ -1386,10 +1402,10 @@ int RsServer::StartupRetroShare() // create GXS photo service RsGxsNetService* gxschannels_ns = new RsGxsNetService( - RS_SERVICE_GXS_TYPE_CHANNELS, gxschannels_ds, nxsMgr, - mGxsChannels, mGxsChannels->getServiceInfo(), - mReputations, mGxsCircles,mGxsIdService, - pgpAuxUtils); + RS_SERVICE_GXS_TYPE_CHANNELS, gxschannels_ds, nxsMgr, + mGxsChannels, mGxsChannels->getServiceInfo(), + mReputations, mGxsCircles,mGxsIdService, + pgpAuxUtils,mGxsNetTunnel,true,true,true); mGxsChannels->setNetworkExchangeService(gxschannels_ns) ; @@ -1444,7 +1460,7 @@ int RsServer::StartupRetroShare() RsGxsNetService* gxstrans_ns = new RsGxsNetService( RS_SERVICE_TYPE_GXS_TRANS, gxstrans_ds, nxsMgr, mGxsTrans, mGxsTrans->getServiceInfo(), mReputations, mGxsCircles, - mGxsIdService, pgpAuxUtils,true,true,p3GxsTrans::GXS_STORAGE_PERIOD,p3GxsTrans::GXS_SYNC_PERIOD); + mGxsIdService, pgpAuxUtils,NULL,true,true,false,p3GxsTrans::GXS_STORAGE_PERIOD,p3GxsTrans::GXS_SYNC_PERIOD); mGxsTrans->setNetworkExchangeService(gxstrans_ns); pqih->addService(gxstrans_ns, true); @@ -1477,9 +1493,11 @@ int RsServer::StartupRetroShare() pqih -> addService(fdb,true); pqih -> addService(ftserver,true); - mGxsTunnels = new p3GxsTunnelService(mGxsIdService) ; - mGxsTunnels->connectToTurtleRouter(tr) ; - rsGxsTunnel = mGxsTunnels; + mGxsTunnels = new p3GxsTunnelService(mGxsIdService) ; + mGxsTunnels->connectToTurtleRouter(tr) ; + rsGxsTunnel = mGxsTunnels; + + mGxsNetTunnel->connectToTurtleRouter(tr) ; rsDisc = mDisc; rsMsgs = new p3Msgs(msgSrv, chatSrv); @@ -1549,17 +1567,17 @@ int RsServer::StartupRetroShare() #endif // new services to test. -#ifndef RETROTOR - p3BanList *mBanList = new p3BanList(serviceCtrl, mNetMgr); - rsBanList = mBanList ; - pqih -> addService(mBanList, true); -#else - rsBanList = NULL ; -#endif -#ifdef RS_USE_BITDHT - mBitDht->setupPeerSharer(mBanList); -#endif + p3BanList *mBanList = NULL; + + if(!RsAccounts::isHiddenNode()) + { + mBanList = new p3BanList(serviceCtrl, mNetMgr); + rsBanList = mBanList ; + pqih -> addService(mBanList, true); + } + else + rsBanList = NULL ; p3BandwidthControl *mBwCtrl = new p3BandwidthControl(pqih); pqih -> addService(mBwCtrl, true); @@ -1573,30 +1591,34 @@ int RsServer::StartupRetroShare() /**************************************************************************/ + if(!RsAccounts::isHiddenNode()) + { #ifdef RS_USE_BITDHT - mNetMgr->addNetAssistConnect(1, mBitDht); - mNetMgr->addNetListener(mDhtStack); - mNetMgr->addNetListener(mProxyStack); + mBitDht->setupPeerSharer(mBanList); + mNetMgr->addNetAssistConnect(1, mBitDht); + mNetMgr->addNetListener(mDhtStack); + mNetMgr->addNetListener(mProxyStack); #endif #ifdef RS_ENABLE_ZEROCONF - p3ZeroConf *mZeroConf = new p3ZeroConf( - AuthGPG::getAuthGPG()->getGPGOwnId(), ownId, - mLinkMgr, mNetMgr, mPeerMgr); - mNetMgr->addNetAssistConnect(2, mZeroConf); - mNetMgr->addNetListener(mZeroConf); + p3ZeroConf *mZeroConf = new p3ZeroConf( + AuthGPG::getAuthGPG()->getGPGOwnId(), ownId, + mLinkMgr, mNetMgr, mPeerMgr); + mNetMgr->addNetAssistConnect(2, mZeroConf); + mNetMgr->addNetListener(mZeroConf); #endif #ifdef RS_ENABLE_ZCNATASSIST - // Apple's UPnP & NAT-PMP assistance. - p3zcNatAssist *mZcNatAssist = new p3zcNatAssist(); - mNetMgr->addNetAssistFirewall(1, mZcNatAssist); + // Apple's UPnP & NAT-PMP assistance. + p3zcNatAssist *mZcNatAssist = new p3zcNatAssist(); + mNetMgr->addNetAssistFirewall(1, mZcNatAssist); #else - // Original UPnP Interface. - pqiNetAssistFirewall *mUpnpMgr = new upnphandler(); - mNetMgr->addNetAssistFirewall(1, mUpnpMgr); + // Original UPnP Interface. + pqiNetAssistFirewall *mUpnpMgr = new upnphandler(); + mNetMgr->addNetAssistFirewall(1, mUpnpMgr); #endif + } /**************************************************************************/ /* need to Monitor too! */ @@ -1612,48 +1634,53 @@ int RsServer::StartupRetroShare() serviceCtrl->registerServiceMonitor(mBwCtrl, mBwCtrl->getServiceInfo().mServiceType); /**************************************************************************/ + // Turtle search for GXS services + + mGxsNetTunnel->registerSearchableService(gxschannels_ns) ; + + /**************************************************************************/ //mConfigMgr->addConfiguration("ftserver.cfg", ftserver); // - mConfigMgr->addConfiguration("gpg_prefs.cfg", AuthGPG::getAuthGPG()); - mConfigMgr->loadConfiguration(); + mConfigMgr->addConfiguration("gpg_prefs.cfg" , AuthGPG::getAuthGPG()); + mConfigMgr->addConfiguration("gxsnettunnel.cfg", mGxsNetTunnel); + mConfigMgr->addConfiguration("peers.cfg" , mPeerMgr); + mConfigMgr->addConfiguration("general.cfg" , mGeneralConfig); + mConfigMgr->addConfiguration("msgs.cfg" , msgSrv); + mConfigMgr->addConfiguration("chat.cfg" , chatSrv); + mConfigMgr->addConfiguration("p3History.cfg" , mHistoryMgr); + mConfigMgr->addConfiguration("p3Status.cfg" , mStatusSrv); + mConfigMgr->addConfiguration("turtle.cfg" , tr); + + if(mBanList != NULL) + mConfigMgr->addConfiguration("banlist.cfg" , mBanList); - mConfigMgr->addConfiguration("peers.cfg", mPeerMgr); - mConfigMgr->addConfiguration("general.cfg", mGeneralConfig); - mConfigMgr->addConfiguration("msgs.cfg", msgSrv); - mConfigMgr->addConfiguration("chat.cfg", chatSrv); - mConfigMgr->addConfiguration("p3History.cfg", mHistoryMgr); - mConfigMgr->addConfiguration("p3Status.cfg", mStatusSrv); - mConfigMgr->addConfiguration("turtle.cfg", tr); -#ifndef RETROTOR - mConfigMgr->addConfiguration("banlist.cfg", mBanList); -#endif mConfigMgr->addConfiguration("servicecontrol.cfg", serviceCtrl); - mConfigMgr->addConfiguration("reputations.cfg", mReputations); + mConfigMgr->addConfiguration("reputations.cfg" , mReputations); #ifdef ENABLE_GROUTER - mConfigMgr->addConfiguration("grouter.cfg", gr); + mConfigMgr->addConfiguration("grouter.cfg" , gr); #endif #ifdef RS_USE_BITDHT - mConfigMgr->addConfiguration("bitdht.cfg", mBitDht); + if(mBitDht != NULL) + mConfigMgr->addConfiguration("bitdht.cfg" , mBitDht); #endif #ifdef RS_ENABLE_GXS # ifdef RS_GXS_TRANS mConfigMgr->addConfiguration("gxs_trans_ns.cfg", gxstrans_ns); - mConfigMgr->addConfiguration("gxs_trans.cfg", mGxsTrans); + mConfigMgr->addConfiguration("gxs_trans.cfg" , mGxsTrans); # endif // RS_GXS_TRANS - mConfigMgr->addConfiguration("p3identity.cfg", mGxsIdService); - - mConfigMgr->addConfiguration("identity.cfg", gxsid_ns); - mConfigMgr->addConfiguration("gxsforums.cfg", gxsforums_ns); + mConfigMgr->addConfiguration("p3identity.cfg" , mGxsIdService); + mConfigMgr->addConfiguration("identity.cfg" , gxsid_ns); + mConfigMgr->addConfiguration("gxsforums.cfg" , gxsforums_ns); mConfigMgr->addConfiguration("gxsforums_srv.cfg", mGxsForums); - mConfigMgr->addConfiguration("gxschannels.cfg", gxschannels_ns); + mConfigMgr->addConfiguration("gxschannels.cfg" , gxschannels_ns); mConfigMgr->addConfiguration("gxschannels_srv.cfg", mGxsChannels); - mConfigMgr->addConfiguration("gxscircles.cfg", gxscircles_ns); - mConfigMgr->addConfiguration("posted.cfg", posted_ns); + mConfigMgr->addConfiguration("gxscircles.cfg" , gxscircles_ns); + mConfigMgr->addConfiguration("posted.cfg" , posted_ns); #ifdef RS_USE_WIKI mConfigMgr->addConfiguration("wiki.cfg", wiki_ns); #endif @@ -1824,6 +1851,8 @@ int RsServer::StartupRetroShare() //rsWire = mWire; /*** start up GXS core runner ***/ + + startServiceThread(mGxsNetTunnel, "gxs net tunnel"); startServiceThread(mGxsIdService, "gxs id"); startServiceThread(mGxsCircles, "gxs circle"); startServiceThread(mPosted, "gxs posted"); @@ -1861,7 +1890,8 @@ int RsServer::StartupRetroShare() //mDhtMgr->start(); #ifdef RS_USE_BITDHT - mBitDht->start(); + if(mBitDht != NULL) + mBitDht->start(); #endif /**************************************************************************/ @@ -1897,6 +1927,96 @@ int RsServer::StartupRetroShare() /* Startup this thread! */ start("rs main") ; + std::cerr << "========================================================================" << std::endl; + std::cerr << "== RsInit:: Retroshare core started ==" << std::endl; + std::cerr << "========================================================================" << std::endl; + return 1; } +RsInit::LoadCertificateStatus RsLoginHelper::attemptLogin( + const RsPeerId& account, const std::string& password) +{ + if(!rsNotify->cachePgpPassphrase(password)) return RsInit::ERR_UNKOWN; + if(!rsNotify->setDisableAskPassword(true)) return RsInit::ERR_UNKOWN; + if(!RsAccounts::SelectAccount(account)) return RsInit::ERR_UNKOWN; + std::string _ignore_lockFilePath; + RsInit::LoadCertificateStatus ret = + RsInit::LockAndLoadCertificates(false, _ignore_lockFilePath); + if(!rsNotify->setDisableAskPassword(false)) return RsInit::ERR_UNKOWN; + if(!rsNotify->clearPgpPassphrase()) return RsInit::ERR_UNKOWN; + if(ret != RsInit::OK) return ret; + if(RsControl::instance()->StartupRetroShare() == 1) return RsInit::OK; + return RsInit::ERR_UNKOWN; +} + +void RsLoginHelper::getLocations(std::vector& store) +{ + std::list locIds; + RsAccounts::GetAccountIds(locIds); + store.clear(); + + for(const RsPeerId& locId : locIds ) + { + Location l; l.mLocationId = locId; + std::string discardPgpMail; + RsAccounts::GetAccountDetails( locId, l.mPgpId, l.mPpgName, + discardPgpMail, l.mLocationName ); + store.push_back(l); + } +} + +bool RsLoginHelper::createLocation( + RsLoginHelper::Location& l, const std::string& password, + bool makeHidden, bool makeAutoTor, std::string& errorMessage ) +{ + if(l.mLocationName.empty()) + { + errorMessage = "Location name is needed"; + return false; + } + + if(l.mPgpId.isNull() && l.mPpgName.empty()) + { + errorMessage = "Either PGP name or PGP id is needed"; + return false; + } + + if(l.mPgpId.isNull() && !RsAccounts::GeneratePGPCertificate( + l.mPpgName, "", password, l.mPgpId, 4096, errorMessage) ) + { + errorMessage = "Failure creating PGP key: " + errorMessage; + return false; + } + + std::string sslPassword = + RSRandom::random_alphaNumericString(RsInit::getSslPwdLen()); + + if(!rsNotify->cachePgpPassphrase(password)) return false; + if(!rsNotify->setDisableAskPassword(true)) return false; + + bool ret = RsAccounts::createNewAccount( + l.mPgpId, "", l.mLocationName, "", makeHidden, makeAutoTor, + sslPassword, l.mLocationId, errorMessage ); + + ret = ret && RsInit::LoadPassword(sslPassword); + ret = ret && RsInit::OK == attemptLogin(l.mLocationId, password); + + rsNotify->setDisableAskPassword(false); + return ret; +} + +void RsLoginHelper::closeSession() +{ + RsControl::instance()->rsGlobalShutDown(); +} + +void RsLoginHelper::Location::serial_process( + RsGenericSerializer::SerializeJob j, + RsGenericSerializer::SerializeContext& ctx ) +{ + RS_SERIAL_PROCESS(mLocationId); + RS_SERIAL_PROCESS(mPgpId); + RS_SERIAL_PROCESS(mLocationName); + RS_SERIAL_PROCESS(mPpgName); +} diff --git a/libretroshare/src/rsserver/rsloginhandler.cc b/libretroshare/src/rsserver/rsloginhandler.cc index ed952791f..f94c7115b 100644 --- a/libretroshare/src/rsserver/rsloginhandler.cc +++ b/libretroshare/src/rsserver/rsloginhandler.cc @@ -3,7 +3,7 @@ #include #include "rsloginhandler.h" #include "util/rsdir.h" -#include "rsaccounts.h" +#include "retroshare/rsinit.h" //#define DEBUG_RSLOGINHANDLER 1 @@ -91,7 +91,7 @@ bool RsLoginHandler::getSSLPasswdFromGPGFile(const RsPeerId& ssl_id,std::string& std::string RsLoginHandler::getSSLPasswdFileName(const RsPeerId& /*ssl_id*/) { - return rsAccounts->PathAccountKeysDirectory() + "/" + "ssl_passphrase.pgp"; + return RsAccounts::AccountKeysDirectory() + "/" + "ssl_passphrase.pgp"; } #ifdef RS_AUTOLOGIN @@ -755,7 +755,7 @@ bool RsLoginHandler::clearAutoLogin(const RsPeerId& ssl_id) std::string RsLoginHandler::getAutologinFileName(const RsPeerId& /*ssl_id*/) { - return rsAccounts->PathAccountKeysDirectory() + "/" + "help.dta" ; + return RsAccounts::AccountKeysDirectory() + "/" + "help.dta" ; } #endif // RS_AUTOLOGIN diff --git a/libretroshare/src/serialiser/rsbaseserial.cc b/libretroshare/src/serialiser/rsbaseserial.cc index ef862db5c..65528c801 100644 --- a/libretroshare/src/serialiser/rsbaseserial.cc +++ b/libretroshare/src/serialiser/rsbaseserial.cc @@ -1,28 +1,24 @@ - -/* - * libretroshare/src/serialiser: rsbaseserial.cc - * - * RetroShare Serialiser. - * - * Copyright 2007-2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ +/******************************************************************************* + * libretroshare/src/serialiser: rsbaseserial.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2007-2008 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include /* Included because GCC4.4 wants it */ #include /* Included because GCC4.4 wants it */ @@ -248,9 +244,10 @@ bool getRawString(const void *data, uint32_t size, uint32_t *offset, std::string } /* check there is space for string */ - if(len > size || size-len < *offset) // better than if(size < *offset + len) because it avoids integer overflow + if(len > size || size-len < *offset) // better than if(size < *offset + len) because it avoids integer overflow { - std::cerr << "getRawString() not enough size" << std::endl; + std::cerr << "getRawString() not enough size" << std::endl; + print_stacktrace(); return false; } uint8_t *buf = &(((uint8_t *) data)[*offset]); diff --git a/libretroshare/src/serialiser/rsbaseserial.h b/libretroshare/src/serialiser/rsbaseserial.h index 650fc9e6d..512feb393 100644 --- a/libretroshare/src/serialiser/rsbaseserial.h +++ b/libretroshare/src/serialiser/rsbaseserial.h @@ -1,31 +1,27 @@ +/******************************************************************************* + * libretroshare/src/serialiser: rsbaseserial.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2007-2008 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RS_BASE_PACKING_H #define RS_BASE_PACKING_H -/* - * libretroshare/src/serialiser: rsbaseserial.h - * - * RetroShare Serialiser. - * - * Copyright 2007-2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - #include #include #include diff --git a/libretroshare/src/serialiser/rsserial.cc b/libretroshare/src/serialiser/rsserial.cc index 230501ea8..0a1a7503f 100644 --- a/libretroshare/src/serialiser/rsserial.cc +++ b/libretroshare/src/serialiser/rsserial.cc @@ -1,28 +1,24 @@ - -/* - * libretroshare/src/serialiser: rsserial.cc - * - * RetroShare Serialiser. - * - * Copyright 2007-2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ +/******************************************************************************* + * libretroshare/src/serialiser: rsserial.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2007-2008 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "serialiser/rsbaseserial.h" diff --git a/libretroshare/src/serialiser/rsserial.h b/libretroshare/src/serialiser/rsserial.h index ee3a79537..3ce56a424 100644 --- a/libretroshare/src/serialiser/rsserial.h +++ b/libretroshare/src/serialiser/rsserial.h @@ -1,31 +1,27 @@ +/******************************************************************************* + * libretroshare/src/serialiser: rsserial.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2007-2008 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RS_BASE_SERIALISER_H #define RS_BASE_SERIALISER_H -/* - * libretroshare/src/serialiser: rsserial.h - * - * RetroShare Serialiser. - * - * Copyright 2007-2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - #include #include #include diff --git a/libretroshare/src/serialiser/rsserializable.h b/libretroshare/src/serialiser/rsserializable.h index c717afc4b..fc6d73662 100644 --- a/libretroshare/src/serialiser/rsserializable.h +++ b/libretroshare/src/serialiser/rsserializable.h @@ -1,22 +1,25 @@ +/******************************************************************************* + * libretroshare/src/serialiser: rsserializable.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright (C) 2016-2018 Gioacchino Mazzurco * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once -/* - * RetroShare Serialiser. - * Copyright (C) 2016-2018 Gioacchino Mazzurco - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - #include "serialiser/rsserializer.h" diff --git a/libretroshare/src/serialiser/rsserializer.cc b/libretroshare/src/serialiser/rsserializer.cc index 164f31342..c1385fddf 100644 --- a/libretroshare/src/serialiser/rsserializer.cc +++ b/libretroshare/src/serialiser/rsserializer.cc @@ -1,28 +1,24 @@ -/* - * libretroshare/src/serialiser: rsserializer.cc - * - * RetroShare Serialiser. - * - * Copyright 2016 by Cyril Soler - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "csoler@users.sourceforge.net". - * - */ - +/******************************************************************************* + * libretroshare/src/serialiser: rsserializer.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright (C) 2016 Cyril Soler * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include #include "rsitems/rsitem.h" @@ -30,11 +26,13 @@ #include "util/rsprint.h" #include "serialiser/rsserializer.h" #include "serialiser/rstypeserializer.h" +#include "util/stacktrace.h" const SerializationFlags RsGenericSerializer::SERIALIZATION_FLAG_NONE ( 0x0000 ); const SerializationFlags RsGenericSerializer::SERIALIZATION_FLAG_CONFIG ( 0x0001 ); const SerializationFlags RsGenericSerializer::SERIALIZATION_FLAG_SIGNATURE ( 0x0002 ); const SerializationFlags RsGenericSerializer::SERIALIZATION_FLAG_SKIP_HEADER ( 0x0004 ); +const SerializationFlags RsGenericSerializer::SERIALIZATION_FLAG_YIELDING ( 0x0008 ); RsItem *RsServiceSerializer::deserialise(void *data, uint32_t *size) { @@ -244,3 +242,31 @@ RsItem *RsRawSerialiser::deserialise(void *data, uint32_t *pktsize) return item; } + +RsGenericSerializer::SerializeContext::SerializeContext( + uint8_t* data, uint32_t size, SerializationFlags flags, + RsJson::AllocatorType* allocator ) : + mData(data), mSize(size), mOffset(0), mOk(true), mFlags(flags), + mJson(rapidjson::kObjectType, allocator) +{ + if(data) + { + if(size == 0) + { + std::cerr << __PRETTY_FUNCTION__ << " data passed without " + << "size! This make no sense report to developers!" + << std::endl; + print_stacktrace(); + } + + if(flags & SERIALIZATION_FLAG_YIELDING) + { + std::cerr << __PRETTY_FUNCTION__ << " Attempt to create a " + << "binary serialization context with " + << "SERIALIZATION_FLAG_YIELDING! " + << "This make no sense report to developers!" + << std::endl; + print_stacktrace(); + } + } +} diff --git a/libretroshare/src/serialiser/rsserializer.h b/libretroshare/src/serialiser/rsserializer.h index 35dc091c3..40ccc35e9 100644 --- a/libretroshare/src/serialiser/rsserializer.h +++ b/libretroshare/src/serialiser/rsserializer.h @@ -1,28 +1,25 @@ -/* - * libretroshare/src/serialiser: rsserializer.h - * - * RetroShare Serialiser. - * - * Copyright (C) 2016 Cyril Soler - * Copyright (C) 2018 Gioacchino Mazzurco - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "csoler@users.sourceforge.net". - * - */ +/******************************************************************************* + * libretroshare/src/serialiser: rsserializer.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright (C) 2016 Cyril Soler * + * Copyright (C) 2018 Gioacchino Mazzurco * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once /////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -154,16 +151,14 @@ #include #include #include -#include #include "retroshare/rsflags.h" #include "serialiser/rsserial.h" #include "util/rsdeprecate.h" +#include "util/rsjson.h" struct RsItem; -#define SERIALIZE_ERROR() std::cerr << __PRETTY_FUNCTION__ << " : " - // This is the base class for serializers. class RsSerialType @@ -197,8 +192,6 @@ class RsRawSerialiser: public RsSerialType virtual RsItem * deserialise(void *data, uint32_t *size); }; -typedef rapidjson::Document RsJson; - /// Top class for all services and config serializers. struct RsGenericSerializer : RsSerialType { @@ -225,11 +218,9 @@ struct RsGenericSerializer : RsSerialType /** Allow shared allocator usage to avoid costly JSON deepcopy for * nested RsSerializable */ SerializeContext( - uint8_t *data, uint32_t size, + uint8_t* data = nullptr, uint32_t size = 0, SerializationFlags flags = SERIALIZATION_FLAG_NONE, - RsJson::AllocatorType* allocator = nullptr) : - mData(data), mSize(size), mOffset(0), mOk(true), mFlags(flags), - mJson(rapidjson::kObjectType, allocator) {} + RsJson::AllocatorType* allocator = nullptr); RS_DEPRECATED SerializeContext( uint8_t *data, uint32_t size, SerializationFormat format, @@ -260,6 +251,12 @@ struct RsGenericSerializer : RsSerialType static const SerializationFlags SERIALIZATION_FLAG_SIGNATURE; // 0x0002 static const SerializationFlags SERIALIZATION_FLAG_SKIP_HEADER; // 0x0004 + /** Used for JSON deserialization in JSON API, it causes the deserialization + * to continue even if some field is missing (or incorrect), this way the + * API is more user friendly as some methods need just part of the structs + * they take as parameters. */ + static const SerializationFlags SERIALIZATION_FLAG_YIELDING; // 0x0008 + /** * The following functions overload RsSerialType. * They *should not* need to be further overloaded. diff --git a/libretroshare/src/serialiser/rstlvaddrs.cc b/libretroshare/src/serialiser/rstlvaddrs.cc index d3f7da87f..5f9a06390 100644 --- a/libretroshare/src/serialiser/rstlvaddrs.cc +++ b/libretroshare/src/serialiser/rstlvaddrs.cc @@ -1,29 +1,24 @@ - -/* - * libretroshare/src/serialiser: rstlvtypes.cc - * - * RetroShare Serialiser. - * - * Copyright 2007-2008 by Robert Fernie, Chris Parker - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/serialiser: rstlvaddr.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2010 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "serialiser/rstlvbase.h" #include "serialiser/rstlvaddrs.h" #include "serialiser/rsbaseserial.h" diff --git a/libretroshare/src/serialiser/rstlvaddrs.h b/libretroshare/src/serialiser/rstlvaddrs.h index eebda4b31..07b668559 100644 --- a/libretroshare/src/serialiser/rstlvaddrs.h +++ b/libretroshare/src/serialiser/rstlvaddrs.h @@ -1,30 +1,26 @@ +/******************************************************************************* + * libretroshare/src/serialiser: rstlvaddr.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2010 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once -/* - * libretroshare/src/serialiser: rstlvaddrs.h - * - * RetroShare Serialiser. - * - * Copyright 2010 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - /******************************************************************* * These are the Compound TLV structures that must be (un)packed. ******************************************************************/ diff --git a/libretroshare/src/serialiser/rstlvbanlist.cc b/libretroshare/src/serialiser/rstlvbanlist.cc index 16cef67dc..92bd3a6d2 100644 --- a/libretroshare/src/serialiser/rstlvbanlist.cc +++ b/libretroshare/src/serialiser/rstlvbanlist.cc @@ -1,29 +1,24 @@ - -/* - * libretroshare/src/serialiser: rstlvtypes.cc - * - * RetroShare Serialiser. - * - * Copyright 2007-2008 by Robert Fernie, Chris Parker - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/serialiser: rstlvbanlist.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2011 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "serialiser/rstlvbanlist.h" #include "serialiser/rstlvbase.h" diff --git a/libretroshare/src/serialiser/rstlvbanlist.h b/libretroshare/src/serialiser/rstlvbanlist.h index f4cbf54c4..a08f92a7a 100644 --- a/libretroshare/src/serialiser/rstlvbanlist.h +++ b/libretroshare/src/serialiser/rstlvbanlist.h @@ -1,30 +1,26 @@ +/******************************************************************************* + * libretroshare/src/serialiser: rstlvbanlist.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2011 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once -/* - * libretroshare/src/serialiser: rstlvbanlist.h - * - * RetroShare Serialiser. - * - * Copyright 2011 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - /******************************************************************* * These are the Compound TLV structures that must be (un)packed. ******************************************************************/ diff --git a/libretroshare/src/serialiser/rstlvbase.cc b/libretroshare/src/serialiser/rstlvbase.cc index f92dae4d9..9cf713193 100644 --- a/libretroshare/src/serialiser/rstlvbase.cc +++ b/libretroshare/src/serialiser/rstlvbase.cc @@ -1,29 +1,24 @@ - -/* - * libretroshare/src/serialiser: rstlvbase.cc - * - * RetroShare Serialiser. - * - * Copyright 2007-2008 by Robert Fernie, Horatio, Chris Parker - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/serialiser: rstlvbase.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2007-2008 by Robert Fernie, Horatio, Chris Parker * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include #include "serialiser/rstlvbase.h" diff --git a/libretroshare/src/serialiser/rstlvbase.h b/libretroshare/src/serialiser/rstlvbase.h index e36805eae..e153f1797 100644 --- a/libretroshare/src/serialiser/rstlvbase.h +++ b/libretroshare/src/serialiser/rstlvbase.h @@ -1,31 +1,26 @@ +/******************************************************************************* + * libretroshare/src/serialiser: rstlvbase.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2007-2008 by Robert Fernie, Horatio, Chris Parker * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once -/* - * libretroshare/src/serialiser: rstlvbase.h - * - * RetroShare Serialiser. - * - * Copyright 2007-2008 by Robert Fernie, Horatio, Chris Parker - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - /******************************************************************* * These are the general TLV (un)packing routines. * diff --git a/libretroshare/src/serialiser/rstlvbinary.cc b/libretroshare/src/serialiser/rstlvbinary.cc index 9c84f6ec2..daa35c56d 100644 --- a/libretroshare/src/serialiser/rstlvbinary.cc +++ b/libretroshare/src/serialiser/rstlvbinary.cc @@ -1,29 +1,24 @@ - -/* - * libretroshare/src/serialiser: rstlvbinary.cc - * - * RetroShare Serialiser. - * - * Copyright 2007-2008 by Robert Fernie, Chris Parker - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/serialiser: rstlvbinary.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2007-2008 by Robert Fernie,Chris Parker * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "util/rsmemory.h" #include "serialiser/rstlvbinary.h" diff --git a/libretroshare/src/serialiser/rstlvbinary.h b/libretroshare/src/serialiser/rstlvbinary.h index a22269e0f..3d41d5402 100644 --- a/libretroshare/src/serialiser/rstlvbinary.h +++ b/libretroshare/src/serialiser/rstlvbinary.h @@ -1,30 +1,26 @@ +/******************************************************************************* + * libretroshare/src/serialiser: rstlvbinary.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2007-2008 by Robert Fernie,Chris Parker * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once -/* - * libretroshare/src/serialiser: rstlvbinary.h - * - * RetroShare Serialiser. - * - * Copyright 2007-2008 by Robert Fernie, Chris Parker - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - /******************************************************************* * These are the Compound TLV structures that must be (un)packed. * diff --git a/libretroshare/src/serialiser/rstlvfileitem.cc b/libretroshare/src/serialiser/rstlvfileitem.cc index dfc90672c..098b8de6f 100644 --- a/libretroshare/src/serialiser/rstlvfileitem.cc +++ b/libretroshare/src/serialiser/rstlvfileitem.cc @@ -1,29 +1,24 @@ - -/* - * libretroshare/src/serialiser: rstlvfileitem.cc - * - * RetroShare Serialiser. - * - * Copyright 2007-2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/serialiser: rstlvfileitem.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2007-2008 by Robert Fernie,Chris Parker * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "serialiser/rstlvfileitem.h" #include "serialiser/rsbaseserial.h" diff --git a/libretroshare/src/serialiser/rstlvfileitem.h b/libretroshare/src/serialiser/rstlvfileitem.h index 1a474e60c..174753364 100644 --- a/libretroshare/src/serialiser/rstlvfileitem.h +++ b/libretroshare/src/serialiser/rstlvfileitem.h @@ -1,30 +1,26 @@ +/******************************************************************************* + * libretroshare/src/serialiser: rstlvfileitem.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2007-2008 by Robert Fernie,Chris Parker * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once -/* - * libretroshare/src/serialiser: rstlvfileitem.h - * - * RetroShare Serialiser. - * - * Copyright 2007-2008 by Robert Fernie, Chris Parker - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - /******************************************************************* * These are the Compound TLV structures that must be (un)packed. * diff --git a/libretroshare/src/serialiser/rstlvgenericmap.h b/libretroshare/src/serialiser/rstlvgenericmap.h index baccae90f..0cc4a3a88 100644 --- a/libretroshare/src/serialiser/rstlvgenericmap.h +++ b/libretroshare/src/serialiser/rstlvgenericmap.h @@ -1,31 +1,27 @@ +/******************************************************************************* + * libretroshare/src/serialiser: rstlvgenericmap.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2014 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RS_TLV_GENERIC_MAP_H #define RS_TLV_GENERIC_MAP_H -/* - * libretroshare/src/serialiser: rstlvgenericmap.h - * - * RetroShare Serialiser. - * - * Copyright 2014 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - #include "serialiser/rstlvitem.h" #include "serialiser/rstlvgenericparam.h" diff --git a/libretroshare/src/serialiser/rstlvgenericmap.inl b/libretroshare/src/serialiser/rstlvgenericmap.inl index 540ee5d2e..b5239d2f7 100644 --- a/libretroshare/src/serialiser/rstlvgenericmap.inl +++ b/libretroshare/src/serialiser/rstlvgenericmap.inl @@ -1,28 +1,24 @@ - -/* - * libretroshare/src/serialiser: rstlvgenericmap.inl - * - * RetroShare Serialiser. - * - * Copyright 2014 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ +/******************************************************************************* + * libretroshare/src/serialiser: rstlvgenericmap.inl * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2014 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "serialiser/rstlvbase.h" diff --git a/libretroshare/src/serialiser/rstlvgenericparam.cc b/libretroshare/src/serialiser/rstlvgenericparam.cc index 483bae0fb..941fd6883 100644 --- a/libretroshare/src/serialiser/rstlvgenericparam.cc +++ b/libretroshare/src/serialiser/rstlvgenericparam.cc @@ -1,29 +1,24 @@ - -/* - * libretroshare/src/serialiser: rstlvgenericparam.cc - * - * RetroShare Serialiser. - * - * Copyright 2014 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/serialiser: rstlvgenericparam.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2014 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "serialiser/rstlvgenericparam.h" #include "serialiser/rstlvbase.h" #include diff --git a/libretroshare/src/serialiser/rstlvgenericparam.h b/libretroshare/src/serialiser/rstlvgenericparam.h index 31da8e275..b1b6417a7 100644 --- a/libretroshare/src/serialiser/rstlvgenericparam.h +++ b/libretroshare/src/serialiser/rstlvgenericparam.h @@ -1,31 +1,27 @@ +/******************************************************************************* + * libretroshare/src/serialiser: rstlvgenericparam.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2014 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RS_TLV_GENERIC_PARAM_H #define RS_TLV_GENERIC_PARAM_H -/* - * libretroshare/src/serialiser: rstlvgenericparam.h - * - * RetroShare Serialiser. - * - * Copyright 2014 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - #include "serialiser/rstlvitem.h" #if 0 diff --git a/libretroshare/src/serialiser/rstlvidset.cc b/libretroshare/src/serialiser/rstlvidset.cc index 918d98526..c3d6ac3d7 100644 --- a/libretroshare/src/serialiser/rstlvidset.cc +++ b/libretroshare/src/serialiser/rstlvidset.cc @@ -1,41 +1,26 @@ - -/* - * libretroshare/src/serialiser: rstlvtypes.cc - * - * RetroShare Serialiser. - * - * Copyright 2007-2008 by Robert Fernie, Chris Parker - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/serialiser: rstlvidset.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2007-2008 by Robert Fernie,Chris Parker * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "rstlvidset.h" -#if 0 -#include "rstlvbase.h" -#include "rsbaseserial.h" -#include "util/rsprint.h" -#include -#include -#include -#include -#endif - #define TLV_DEBUG 1 /************************************* Service Id Set ************************************/ diff --git a/libretroshare/src/serialiser/rstlvidset.h b/libretroshare/src/serialiser/rstlvidset.h index cd04ce382..f722947de 100644 --- a/libretroshare/src/serialiser/rstlvidset.h +++ b/libretroshare/src/serialiser/rstlvidset.h @@ -1,30 +1,26 @@ +/******************************************************************************* + * libretroshare/src/serialiser: rstlvidset.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2007-2008 by Robert Fernie,Chris Parker * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once -/* - * libretroshare/src/serialiser: rstlvidset.h - * - * RetroShare Serialiser. - * - * Copyright 2007-2008 by Robert Fernie, Chris Parker - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - /******************************************************************* * These are the Compound TLV structures that must be (un)packed. * diff --git a/libretroshare/src/serialiser/rstlvimage.cc b/libretroshare/src/serialiser/rstlvimage.cc index 4083f9e54..ce8ea5d6c 100644 --- a/libretroshare/src/serialiser/rstlvimage.cc +++ b/libretroshare/src/serialiser/rstlvimage.cc @@ -1,29 +1,24 @@ - -/* - * libretroshare/src/serialiser: rstlvimage.cc - * - * RetroShare Serialiser. - * - * Copyright 2007-2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/serialiser: rstlvimage.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2007-2008 by Robert Fernie,Chris Parker * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "serialiser/rstlvimage.h" #if 0 diff --git a/libretroshare/src/serialiser/rstlvimage.h b/libretroshare/src/serialiser/rstlvimage.h index 51c18288c..b5602096f 100644 --- a/libretroshare/src/serialiser/rstlvimage.h +++ b/libretroshare/src/serialiser/rstlvimage.h @@ -1,30 +1,26 @@ +/******************************************************************************* + * libretroshare/src/serialiser: rstlvimage.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2007-2008 by Robert Fernie,Chris Parker * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once -/* - * libretroshare/src/serialiser: rstlvimage.h - * - * RetroShare Serialiser. - * - * Copyright 2007-2008 by Robert Fernie, Chris Parker - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - /******************************************************************* * These are the Compound TLV structures that must be (un)packed. * diff --git a/libretroshare/src/serialiser/rstlvitem.cc b/libretroshare/src/serialiser/rstlvitem.cc index 02a1f8c63..16ca002db 100644 --- a/libretroshare/src/serialiser/rstlvitem.cc +++ b/libretroshare/src/serialiser/rstlvitem.cc @@ -1,29 +1,24 @@ - -/* - * libretroshare/src/serialiser: rstlvtypes.cc - * - * RetroShare Serialiser. - * - * Copyright 2007-2008 by Robert Fernie, Chris Parker - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/serialiser: rstlvitem.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2007-2008 by Robert Fernie,Chris Parker * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "rstlvitem.h" #include "rstlvbase.h" #include diff --git a/libretroshare/src/serialiser/rstlvitem.h b/libretroshare/src/serialiser/rstlvitem.h index 0cd0d42d7..1623a8224 100644 --- a/libretroshare/src/serialiser/rstlvitem.h +++ b/libretroshare/src/serialiser/rstlvitem.h @@ -1,28 +1,25 @@ +/******************************************************************************* + * libretroshare/src/serialiser: rstlvitem.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2007-2008 by Robert Fernie,Chris Parker * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once -/* - * libretroshare/src/serialiser: rstlvitem.h - * - * RetroShare Serialiser. - * - * Copyright 2007-2008 by Robert Fernie, Chris Parker - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ /******************************************************************* * These are the Compound TLV structures that must be (un)packed. diff --git a/libretroshare/src/serialiser/rstlvkeys.cc b/libretroshare/src/serialiser/rstlvkeys.cc index 538862320..b13250479 100644 --- a/libretroshare/src/serialiser/rstlvkeys.cc +++ b/libretroshare/src/serialiser/rstlvkeys.cc @@ -1,29 +1,24 @@ - -/* - * libretroshare/src/serialiser: rstlvtypes.cc - * - * RetroShare Serialiser. - * - * Copyright 2007-2008 by Robert Fernie, Chris Parker - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/serialiser: rstlvkeys.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2008 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "rstlvkeys.h" #include "rstlvbase.h" #include "rsbaseserial.h" diff --git a/libretroshare/src/serialiser/rstlvkeys.h b/libretroshare/src/serialiser/rstlvkeys.h index 632a7fb09..5f82e51f0 100644 --- a/libretroshare/src/serialiser/rstlvkeys.h +++ b/libretroshare/src/serialiser/rstlvkeys.h @@ -1,30 +1,26 @@ +/******************************************************************************* + * libretroshare/src/serialiser: rstlvkeys.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2008 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once -/* - * libretroshare/src/serialiser: rstlvkeys.h - * - * RetroShare Serialiser. - * - * Copyright 2008 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - /******************************************************************* * These are the Compound TLV structures that must be (un)packed. ******************************************************************/ diff --git a/libretroshare/src/serialiser/rstlvkeyvalue.cc b/libretroshare/src/serialiser/rstlvkeyvalue.cc index 6bef23277..2e1a9dd16 100644 --- a/libretroshare/src/serialiser/rstlvkeyvalue.cc +++ b/libretroshare/src/serialiser/rstlvkeyvalue.cc @@ -1,29 +1,24 @@ - -/* - * libretroshare/src/serialiser: rstlvtypes.cc - * - * RetroShare Serialiser. - * - * Copyright 2007-2008 by Robert Fernie, Chris Parker - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/serialiser: rstlvkeyvalue.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2008 by Robert Fernie,Chris Parker * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "rstlvkeyvalue.h" #include "rstlvbase.h" diff --git a/libretroshare/src/serialiser/rstlvkeyvalue.h b/libretroshare/src/serialiser/rstlvkeyvalue.h index 2e288a15b..63cf3091f 100644 --- a/libretroshare/src/serialiser/rstlvkeyvalue.h +++ b/libretroshare/src/serialiser/rstlvkeyvalue.h @@ -1,30 +1,26 @@ +/******************************************************************************* + * libretroshare/src/serialiser: rstlvkeyvalue.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2008 by Robert Fernie,Chris Parker * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once -/* - * libretroshare/src/serialiser: rstlvkeyvalue.h - * - * RetroShare Serialiser. - * - * Copyright 2007-2008 by Robert Fernie, Chris Parker - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - /******************************************************************* * These are the Compound TLV structures that must be (un)packed. * diff --git a/libretroshare/src/serialiser/rstlvlist.h b/libretroshare/src/serialiser/rstlvlist.h index decd2bc6b..099868179 100644 --- a/libretroshare/src/serialiser/rstlvlist.h +++ b/libretroshare/src/serialiser/rstlvlist.h @@ -1,30 +1,26 @@ +/******************************************************************************* + * libretroshare/src/serialiser: rstlvlist.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2008 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once -/* - * libretroshare/src/serialiser: rstlvlist.h - * - * RetroShare Serialiser. - * - * Copyright 2014 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - #include "serialiser/rstlvbase.h" #include "serialiser/rstlvitem.h" diff --git a/libretroshare/src/serialiser/rstlvmaps.h b/libretroshare/src/serialiser/rstlvmaps.h index 06a3fd6d5..49b05e382 100644 --- a/libretroshare/src/serialiser/rstlvmaps.h +++ b/libretroshare/src/serialiser/rstlvmaps.h @@ -1,37 +1,27 @@ +/******************************************************************************* + * libretroshare/src/serialiser: rstlvmaps.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2014 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RS_TLV_MAPS_H #define RS_TLV_MAPS_H -/* - * libretroshare/src/serialiser: rstlvmaps.h - * - * RetroShare Serialiser. - * - * Copyright 2014 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - -#if 0 -#include "serialiser/rstlvgenericmaps.h" - -#endif - - class RsTlvOpinionMapRef: public RsTlvGenericMapRef { public: diff --git a/libretroshare/src/serialiser/rstlvstring.cc b/libretroshare/src/serialiser/rstlvstring.cc index 43344c118..8f800b73c 100644 --- a/libretroshare/src/serialiser/rstlvstring.cc +++ b/libretroshare/src/serialiser/rstlvstring.cc @@ -1,29 +1,24 @@ - -/* - * libretroshare/src/serialiser: rstlvstring.cc - * - * RetroShare Serialiser. - * - * Copyright 2007-2008 by Robert Fernie, Chris Parker - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/serialiser: rstlvstring.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2007-2008 by Robert Fernie,Chris Parker * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "serialiser/rstlvstring.h" #include "serialiser/rstlvbase.h" diff --git a/libretroshare/src/serialiser/rstlvstring.h b/libretroshare/src/serialiser/rstlvstring.h index 9c22ee939..5e0c2f276 100644 --- a/libretroshare/src/serialiser/rstlvstring.h +++ b/libretroshare/src/serialiser/rstlvstring.h @@ -1,30 +1,26 @@ +/******************************************************************************* + * libretroshare/src/serialiser: rstlvstring.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2007-2008 by Robert Fernie,Chris Parker * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once -/* - * libretroshare/src/serialiser: rstlvstring.h - * - * RetroShare Serialiser. - * - * Copyright 2007-2008 by Robert Fernie, Chris Parker - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - /******************************************************************* * These are the Compound TLV structures that must be (un)packed. * diff --git a/libretroshare/src/serialiser/rstypeserializer.cc b/libretroshare/src/serialiser/rstypeserializer.cc index 72d20ecc2..f620f7af0 100644 --- a/libretroshare/src/serialiser/rstypeserializer.cc +++ b/libretroshare/src/serialiser/rstypeserializer.cc @@ -1,34 +1,31 @@ -/* - * libretroshare/src/serialiser: rstypeserializer.cc - * - * RetroShare Serialiser. - * - * Copyright (C) 2017 Cyril Soler - * Copyright (C) 2018 Gioacchino Mazzurco - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "csoler@users.sourceforge.net". - * - */ +/******************************************************************************* + * libretroshare/src/serialiser: rstypeserializer.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright (C) 2017 Cyril Soler * + * Copyright (C) 2018 Gioacchino Mazzurco * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "serialiser/rsserializer.h" #include "serialiser/rstypeserializer.h" #include "serialiser/rsbaseserial.h" #include "serialiser/rstlvkeys.h" #include "serialiser/rsserializable.h" - +#include "util/radix64.h" #include "util/rsprint.h" #include @@ -36,13 +33,17 @@ #include #include // for typeid -#include +#ifdef HAS_RAPIDJSON +#include +#else #include +#endif // HAS_RAPIDJSON //static const uint32_t MAX_SERIALIZED_ARRAY_SIZE = 500 ; static const uint32_t MAX_SERIALIZED_CHUNK_SIZE = 10*1024*1024 ; // 10 MB. -#define SAFE_GET_JSON_V() \ +#ifdef RSSERIAL_DEBUG +# define SAFE_GET_JSON_V() \ const char* mName = memberName.c_str(); \ bool ret = jDoc.HasMember(mName); \ if(!ret) \ @@ -50,10 +51,16 @@ static const uint32_t MAX_SERIALIZED_CHUNK_SIZE = 10*1024*1024 ; // 10 MB. std::cerr << __PRETTY_FUNCTION__ << " \"" << memberName \ << "\" not found in JSON:" << std::endl \ << jDoc << std::endl << std::endl; \ - print_stacktrace(); \ return false; \ } \ rapidjson::Value& v = jDoc[mName] +#else // ifdef RSSERIAL_DEBUG +# define SAFE_GET_JSON_V() \ + const char* mName = memberName.c_str(); \ + bool ret = jDoc.HasMember(mName); \ + if(!ret) return false; \ + rapidjson::Value& v = jDoc[mName] +#endif // ifdef RSSERIAL_DEBUG //============================================================================// @@ -162,23 +169,23 @@ template<> void RsTypeSerializer::print_data(const std::string& n, const bool & } template<> void RsTypeSerializer::print_data(const std::string& n, const int32_t& V) { - std::cerr << " [int32_t ] " << n << ": " << V << std::endl; + std::cerr << " [int32_t ] " << n << ": " << std::to_string(V) << std::endl; } template<> void RsTypeSerializer::print_data(const std::string& n, const uint8_t & V) { - std::cerr << " [uint8_t ] " << n << ": " << V << std::endl; + std::cerr << " [uint8_t ] " << n << ": " << std::to_string(V) << std::endl; } template<> void RsTypeSerializer::print_data(const std::string& n, const uint16_t& V) { - std::cerr << " [uint16_t ] " << n << ": " << V << std::endl; + std::cerr << " [uint16_t ] " << n << ": " << std::to_string(V) << std::endl; } template<> void RsTypeSerializer::print_data(const std::string& n, const uint32_t& V) { - std::cerr << " [uint32_t ] " << n << ": " << V << std::endl; + std::cerr << " [uint32_t ] " << n << ": " << std::to_string(V) << std::endl; } template<> void RsTypeSerializer::print_data(const std::string& n, const uint64_t& V) { - std::cerr << " [uint64_t ] " << n << ": " << V << std::endl; + std::cerr << " [uint64_t ] " << n << ": " << std::to_string(V) << std::endl; } template<> void RsTypeSerializer::print_data(const std::string& n, const time_t& V) { @@ -328,6 +335,49 @@ bool RsTypeSerializer::from_JSON( const std::string& memberName, return ret; } +template<> /*static*/ +uint32_t RsTypeSerializer::serial_size(const double&) +{ + std::cerr << "Binary [de]serialization not implemented yet for double" + << std::endl; + print_stacktrace(); + return 0; +} + +template<> /*static*/ +bool RsTypeSerializer::serialize(uint8_t[], uint32_t, uint32_t&, const double&) +{ + std::cerr << "Binary [de]serialization not implemented yet for double" + << std::endl; + print_stacktrace(); + return false; +} + +template<> /*static*/ +bool RsTypeSerializer::deserialize(const uint8_t[], uint32_t, uint32_t&, double&) +{ + std::cerr << "Binary [de]serialization not implemented yet for double" + << std::endl; + print_stacktrace(); + return false; +} + +template<> /*static*/ +void RsTypeSerializer::print_data(const std::string& n, const double& V) +{ std::cerr << " [double ] " << n << ": " << V << std::endl; } + +SIMPLE_TO_JSON_DEF(double) + +template<> /*static*/ +bool RsTypeSerializer::from_JSON( const std::string& memberName, + double& member, RsJson& jDoc ) +{ + SAFE_GET_JSON_V(); + ret = ret && v.IsDouble(); + if(ret) member = v.GetDouble(); + return ret; +} + //============================================================================// // std::string // @@ -596,9 +646,12 @@ bool RsTypeSerializer::to_JSON( rapidjson::Value key; key.SetString(memberName.c_str(), memberName.length(), allocator); + std::string encodedValue; + Radix64::encode( reinterpret_cast(member.first), + member.second, encodedValue ); + rapidjson::Value value; - const char* tName = typeid(member).name(); - value.SetString(tName, allocator); + value.SetString(encodedValue.data(), allocator); jDoc.AddMember(key, value, allocator); @@ -606,20 +659,27 @@ bool RsTypeSerializer::to_JSON( } template<> /*static*/ -bool RsTypeSerializer::from_JSON( const std::string& /*memberName*/, - RsTypeSerializer::TlvMemBlock_proxy&, - RsJson& /*jDoc*/) -{ return true; } - - -//============================================================================// -// RsJson std:ostream support // -//============================================================================// - -std::ostream &operator<<(std::ostream &out, const RsJson &jDoc) +bool RsTypeSerializer::from_JSON( const std::string& memberName, + RsTypeSerializer::TlvMemBlock_proxy& member, + RsJson& jDoc) { - rapidjson::StringBuffer buffer; buffer.Clear(); - rapidjson::PrettyWriter writer(buffer); - jDoc.Accept(writer); - return out << buffer.GetString(); + SAFE_GET_JSON_V(); + ret = ret && v.IsString(); + if(ret) + { + std::string encodedValue = v.GetString(); + std::vector decodedValue = Radix64::decode(encodedValue); + member.second = decodedValue.size(); + + if(member.second == 0) + { + member.first = nullptr; + return ret; + } + + member.first = rs_malloc(member.second); + ret = ret && member.first && + memcpy(member.first, decodedValue.data(), member.second); + } + return ret; } diff --git a/libretroshare/src/serialiser/rstypeserializer.h b/libretroshare/src/serialiser/rstypeserializer.h index 3e3c0b251..fc13d42e4 100644 --- a/libretroshare/src/serialiser/rstypeserializer.h +++ b/libretroshare/src/serialiser/rstypeserializer.h @@ -1,28 +1,25 @@ -/* - * libretroshare/src/serialiser: rstypeserializer.h - * - * RetroShare Serialiser. - * - * Copyright (C) 2017 Cyril Soler - * Copyright (C) 2018 Gioacchino Mazzurco - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "csoler@users.sourceforge.net". - * - */ +/******************************************************************************* + * libretroshare/src/serialiser: rstypeserializer.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright (C) 2017 Cyril Soler * + * Copyright (C) 2018 Gioacchino Mazzurco * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once #include "serialiser/rsserial.h" @@ -34,14 +31,14 @@ #include "serialiser/rsserializer.h" #include "serialiser/rsserializable.h" +#include "util/rsjson.h" -#include #include // for typeid #include #include -/** INTERNAL ONLY helper to avoid copy paste code for std::{vector,list,set} +/* INTERNAL ONLY helper to avoid copy paste code for std::{vector,list,set} * Can't use a template function because T is needed for const_cast */ #define RsTypeSerializer_PRIVATE_TO_JSON_ARRAY() do \ { \ @@ -57,9 +54,7 @@ { \ /* Use same allocator to avoid deep copy */\ RsGenericSerializer::SerializeContext elCtx(\ - nullptr, 0, RsGenericSerializer::FORMAT_BINARY,\ - RsGenericSerializer::SERIALIZATION_FLAG_NONE,\ - &allocator );\ + nullptr, 0, ctx.mFlags, &allocator );\ \ /* If el is const the default serial_process template is matched */ \ /* also when specialization is necessary so the compilation break */ \ @@ -77,7 +72,7 @@ ctx.mJson.AddMember(arrKey, arr, allocator);\ } while (false) -/** INTERNAL ONLY helper to avoid copy paste code for std::{vector,list,set} +/* INTERNAL ONLY helper to avoid copy paste code for std::{vector,list,set} * Can't use a template function because std::{vector,list,set} has different * name for insert/push_back function */ @@ -85,7 +80,7 @@ {\ using namespace rapidjson;\ \ - bool& ok(ctx.mOk);\ + bool ok = ctx.mOk || ctx.mFlags & RsGenericSerializer::SERIALIZATION_FLAG_YIELDING;\ Document& jDoc(ctx.mJson);\ Document::AllocatorType& allocator = jDoc.GetAllocator();\ \ @@ -99,23 +94,28 @@ {\ for (auto&& arrEl : jDoc[arrKey].GetArray())\ {\ + Value arrKeyT;\ + arrKeyT.SetString(memberName.c_str(), memberName.length());\ +\ RsGenericSerializer::SerializeContext elCtx(\ - nullptr, 0, RsGenericSerializer::FORMAT_BINARY,\ - RsGenericSerializer::SERIALIZATION_FLAG_NONE,\ - &allocator );\ - elCtx.mJson.AddMember(arrKey, arrEl, allocator);\ + nullptr, 0, ctx.mFlags, &allocator );\ + elCtx.mJson.AddMember(arrKeyT, arrEl, allocator);\ \ T el;\ serial_process(j, elCtx, el, memberName); \ ok = ok && elCtx.mOk;\ -\ + ctx.mOk &= ok;\ if(ok) v.INSERT_FUN(el);\ else break;\ }\ }\ + else\ + {\ + ctx.mOk = false;\ + }\ +\ } while(false) -std::ostream &operator<<(std::ostream &out, const RsJson &jDoc); struct RsTypeSerializer { @@ -133,8 +133,8 @@ struct RsTypeSerializer template typename std::enable_if::value || !(std::is_base_of::value || std::is_enum::value || std::is_base_of::value)>::type static /*void*/ serial_process( RsGenericSerializer::SerializeJob j, - RsGenericSerializer::SerializeContext& ctx, - T& member, const std::string& member_name) + RsGenericSerializer::SerializeContext& ctx, + T& member, const std::string& member_name ) { switch(j) { @@ -156,7 +156,8 @@ struct RsTypeSerializer ctx.mOk = ctx.mOk && to_JSON(member_name, member, ctx.mJson); break; case RsGenericSerializer::FROM_JSON: - ctx.mOk = ctx.mOk && from_JSON(member_name, member, ctx.mJson); + ctx.mOk &= (ctx.mOk || ctx.mFlags & RsGenericSerializer::SERIALIZATION_FLAG_YIELDING) + && from_JSON(member_name, member, ctx.mJson); break; default: std::cerr << __PRETTY_FUNCTION__ << " Unknown serial job: " @@ -194,8 +195,9 @@ struct RsTypeSerializer to_JSON(member_name, type_id, member, ctx.mJson); break; case RsGenericSerializer::FROM_JSON: - ctx.mOk = ctx.mOk && - from_JSON(member_name, type_id, member, ctx.mJson); + ctx.mOk &= + (ctx.mOk || ctx.mFlags & RsGenericSerializer::SERIALIZATION_FLAG_YIELDING) + && from_JSON(member_name, type_id, member, ctx.mJson); break; default: std::cerr << __PRETTY_FUNCTION__ << " Unknown serial job: " @@ -287,15 +289,11 @@ struct RsTypeSerializer { // Use same allocator to avoid deep copy RsGenericSerializer::SerializeContext kCtx( - nullptr, 0, RsGenericSerializer::FORMAT_BINARY, - RsGenericSerializer::SERIALIZATION_FLAG_NONE, - &allocator ); + nullptr, 0, ctx.mFlags, &allocator ); serial_process(j, kCtx, const_cast(kv.first), "key"); RsGenericSerializer::SerializeContext vCtx( - nullptr, 0, RsGenericSerializer::FORMAT_BINARY, - RsGenericSerializer::SERIALIZATION_FLAG_NONE, - &allocator ); + nullptr, 0, ctx.mFlags, &allocator ); serial_process(j, vCtx, const_cast(kv.second), "value"); if(kCtx.mOk && vCtx.mOk) @@ -316,7 +314,7 @@ struct RsTypeSerializer { using namespace rapidjson; - bool& ok(ctx.mOk); + bool ok = ctx.mOk || ctx.mFlags & RsGenericSerializer::SERIALIZATION_FLAG_YIELDING; Document& jDoc(ctx.mJson); Document::AllocatorType& allocator = jDoc.GetAllocator(); @@ -336,9 +334,7 @@ struct RsTypeSerializer if (!ok) break; RsGenericSerializer::SerializeContext kCtx( - nullptr, 0, RsGenericSerializer::FORMAT_BINARY, - RsGenericSerializer::SERIALIZATION_FLAG_NONE, - &allocator ); + nullptr, 0, ctx.mFlags, &allocator ); if(ok) kCtx.mJson.AddMember("key", kvEl["key"], allocator); @@ -346,9 +342,7 @@ struct RsTypeSerializer ok = ok && (serial_process(j, kCtx, key, "key"), kCtx.mOk); RsGenericSerializer::SerializeContext vCtx( - nullptr, 0, RsGenericSerializer::FORMAT_BINARY, - RsGenericSerializer::SERIALIZATION_FLAG_NONE, - &allocator ); + nullptr, 0, ctx.mFlags, &allocator ); if(ok) vCtx.mJson.AddMember("value", kvEl["value"], allocator); @@ -356,14 +350,102 @@ struct RsTypeSerializer ok = ok && ( serial_process(j, vCtx, value, "value"), vCtx.mOk ); + ctx.mOk &= ok; if(ok) v.insert(std::pair(key,value)); else break; } } + else + { + ctx.mOk = false; + } + break; + } + default: + std::cerr << __PRETTY_FUNCTION__ << " Unknown serial job: " + << static_cast::type>(j) + << std::endl; + exit(EINVAL); + } + } + + /// std::pair + template + static void serial_process( RsGenericSerializer::SerializeJob j, + RsGenericSerializer::SerializeContext& ctx, + std::pair& p, + const std::string& memberName ) + { + switch(j) + { + case RsGenericSerializer::SIZE_ESTIMATE: // fallthrough + case RsGenericSerializer::DESERIALIZE: // fallthrough + case RsGenericSerializer::SERIALIZE: // fallthrough + case RsGenericSerializer::PRINT: + serial_process(j, ctx, p.first, "pair::first"); + serial_process(j, ctx, p.second, "pair::second"); + break; + case RsGenericSerializer::TO_JSON: + { + RsJson& jDoc(ctx.mJson); + RsJson::AllocatorType& allocator = jDoc.GetAllocator(); + + // Reuse allocator to avoid deep copy later + RsGenericSerializer::SerializeContext lCtx( + nullptr, 0, ctx.mFlags, &allocator ); + + serial_process(j, ctx, p.first, "first"); + serial_process(j, ctx, p.second, "second"); + + rapidjson::Value key; + key.SetString(memberName.c_str(), memberName.length(), allocator); + + /* Because the passed allocator is reused it doesn't go out of scope + * and there is no need of deep copy and we can take advantage of + * the much faster rapidjson move semantic */ + jDoc.AddMember(key, lCtx.mJson, allocator); + + ctx.mOk = ctx.mOk && lCtx.mOk; + break; + } + case RsGenericSerializer::FROM_JSON: + { + RsJson& jDoc(ctx.mJson); + const char* mName = memberName.c_str(); + bool hasMember = jDoc.HasMember(mName); + bool yielding = ctx.mFlags & + RsGenericSerializer::SERIALIZATION_FLAG_YIELDING; + + if(!hasMember) + { + if(!yielding) + { + std::cerr << __PRETTY_FUNCTION__ << " \"" << memberName + << "\" not found in JSON:" << std::endl + << jDoc << std::endl << std::endl; + print_stacktrace(); + } + ctx.mOk = false; + break; + } + + rapidjson::Value& v = jDoc[mName]; + + RsGenericSerializer::SerializeContext lCtx(nullptr, 0, ctx.mFlags); + lCtx.mJson.SetObject() = v; // Beware of move semantic!! + + serial_process(j, ctx, p.first, "first"); + serial_process(j, ctx, p.second, "second"); + ctx.mOk &= lCtx.mOk; break; } - default: break; + default: + std::cerr << __PRETTY_FUNCTION__ << " Unknown serial job: " + << static_cast::type>(j) + << std::endl; + exit(EINVAL); + break; } } @@ -403,10 +485,12 @@ struct RsTypeSerializer case RsGenericSerializer::PRINT: { if(v.empty()) - std::cerr << " Empty array"<< std::endl; - else - std::cerr << " Array of " << v.size() << " elements:" + std::cerr << " Empty vector \"" << memberName << "\"" << std::endl; + else + std::cerr << " Vector of " << v.size() << " elements: \"" + << memberName << "\"" << std::endl; + for(uint32_t i=0;i(f); break; } @@ -623,9 +715,7 @@ struct RsTypeSerializer // Reuse allocator to avoid deep copy later RsGenericSerializer::SerializeContext lCtx( - nullptr, 0, RsGenericSerializer::FORMAT_BINARY, - RsGenericSerializer::SERIALIZATION_FLAG_NONE, - &allocator ); + nullptr, 0, ctx.mFlags, &allocator ); member.serial_process(j, lCtx); @@ -642,28 +732,32 @@ struct RsTypeSerializer } case RsGenericSerializer::FROM_JSON: { - rapidjson::Document& jDoc(ctx.mJson); + RsJson& jDoc(ctx.mJson); const char* mName = memberName.c_str(); - ctx.mOk = ctx.mOk && jDoc.HasMember(mName); + bool hasMember = jDoc.HasMember(mName); + bool yielding = ctx.mFlags & + RsGenericSerializer::SERIALIZATION_FLAG_YIELDING; - if(!ctx.mOk) + if(!hasMember) { - std::cerr << __PRETTY_FUNCTION__ << " \"" << memberName - << "\" not found in JSON:" << std::endl - << jDoc << std::endl << std::endl; - print_stacktrace(); + if(!yielding) + { + std::cerr << __PRETTY_FUNCTION__ << " \"" << memberName + << "\" not found in JSON:" << std::endl + << jDoc << std::endl << std::endl; + print_stacktrace(); + } + ctx.mOk = false; break; } rapidjson::Value& v = jDoc[mName]; - RsGenericSerializer::SerializeContext lCtx( - nullptr, 0, RsGenericSerializer::FORMAT_BINARY, - RsGenericSerializer::SERIALIZATION_FLAG_NONE ); + RsGenericSerializer::SerializeContext lCtx(nullptr, 0, ctx.mFlags); lCtx.mJson.SetObject() = v; // Beware of move semantic!! member.serial_process(j, lCtx); - ctx.mOk = ctx.mOk && lCtx.mOk; + ctx.mOk &= lCtx.mOk; break; } diff --git a/libretroshare/src/services/autoproxy/p3i2pbob.cc b/libretroshare/src/services/autoproxy/p3i2pbob.cc index 36e5604c7..390477127 100644 --- a/libretroshare/src/services/autoproxy/p3i2pbob.cc +++ b/libretroshare/src/services/autoproxy/p3i2pbob.cc @@ -1,3 +1,24 @@ +/******************************************************************************* + * libretroshare/src/services/autoproxy: p3i2pbob.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2016 by Sehraf * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include #include /* for usleep() */ diff --git a/libretroshare/src/services/autoproxy/p3i2pbob.h b/libretroshare/src/services/autoproxy/p3i2pbob.h index 5fd44bc85..27b911262 100644 --- a/libretroshare/src/services/autoproxy/p3i2pbob.h +++ b/libretroshare/src/services/autoproxy/p3i2pbob.h @@ -1,3 +1,24 @@ +/******************************************************************************* + * libretroshare/src/services/autoproxy: p3i2pbob.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2016 by Sehraf * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef P3I2PBOB_H #define P3I2PBOB_H diff --git a/libretroshare/src/services/autoproxy/rsautoproxymonitor.cc b/libretroshare/src/services/autoproxy/rsautoproxymonitor.cc index d4d3f87ce..aef160590 100644 --- a/libretroshare/src/services/autoproxy/rsautoproxymonitor.cc +++ b/libretroshare/src/services/autoproxy/rsautoproxymonitor.cc @@ -1,3 +1,24 @@ +/******************************************************************************* + * libretroshare/src/services/autoproxy: rsautoproximonitor.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2016 by Sehraf * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "rsautoproxymonitor.h" #include /* for usleep() */ diff --git a/libretroshare/src/services/autoproxy/rsautoproxymonitor.h b/libretroshare/src/services/autoproxy/rsautoproxymonitor.h index 21ea95c3b..d9a4c16aa 100644 --- a/libretroshare/src/services/autoproxy/rsautoproxymonitor.h +++ b/libretroshare/src/services/autoproxy/rsautoproxymonitor.h @@ -1,3 +1,24 @@ +/******************************************************************************* + * libretroshare/src/services/autoproxy: rsautoproximonitor.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2016 by Sehraf * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RSAUTOPROXYMONITOR_H #define RSAUTOPROXYMONITOR_H diff --git a/libretroshare/src/services/p3banlist.cc b/libretroshare/src/services/p3banlist.cc index b1fc07113..eca5afb20 100644 --- a/libretroshare/src/services/p3banlist.cc +++ b/libretroshare/src/services/p3banlist.cc @@ -1,28 +1,24 @@ -/* - * libretroshare/src/services p3banlist.cc - * - * Ban List Service for RetroShare. - * - * Copyright 2011-2011 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/services: p3banlist.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2011 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "pqi/p3servicecontrol.h" #include "pqi/p3netmgr.h" #include "pqi/p3cfgmgr.h" @@ -55,7 +51,7 @@ #define RSBANLIST_DELAY_BETWEEN_TALK_TO_DHT 240 // every 4 mins. /************ IMPLEMENTATION NOTES ********************************* - * + * * Get Bad Peers passed to us (from DHT mainly). * we distribute and track the network list of bad peers. * @@ -113,6 +109,8 @@ void p3BanList::setAutoRangeLimit(int n) IndicateConfigChanged(); } +namespace services { + class ZeroedInt { public: @@ -120,6 +118,8 @@ class ZeroedInt uint32_t n ; }; +} + BanListPeer::BanListPeer() { memset(&addr, 0, sizeof(addr)); @@ -220,14 +220,14 @@ void p3BanList::autoFigureOutBanRanges() std::cerr << "Automatically figuring out IP ranges from banned IPs." << std::endl; #endif - std::map range_map ; + std::map range_map ; for(std::map::iterator it(mBanSet.begin());it!=mBanSet.end();++it) ++range_map[makeBitsRange(it->first,1)].n ; time_t now = time(NULL) ; - for(std::map::const_iterator it=range_map.begin();it!=range_map.end();++it) + for(std::map::const_iterator it=range_map.begin();it!=range_map.end();++it) { #ifdef DEBUG_BANLIST std::cerr << "Ban range: " << sockaddr_storage_iptostring(it->first) << " : " << it->second.n << std::endl; @@ -646,7 +646,7 @@ bool p3BanList::processIncoming() break; case RS_PKT_SUBTYPE_BANLIST_ITEM: { - // Order is important!. + // Order is important!. updated = (recvBanItem((RsBanListItem *) item) || updated); } break; @@ -669,8 +669,8 @@ bool p3BanList::processIncoming() } return true ; -} - +} + bool p3BanList::recvBanItem(RsBanListItem *item) { @@ -681,7 +681,7 @@ bool p3BanList::recvBanItem(RsBanListItem *item) for(it = item->peerList.mList.begin(); it != item->peerList.mList.end(); ++it) { - // Order is important!. + // Order is important!. updated = (addBanEntry(item->PeerId(), it->addr.addr, it->level, it->reason, now - it->age) || updated); } return updated; @@ -961,7 +961,7 @@ bool p3BanList::addBanEntry( const RsPeerId &peerId, it = mBanSources.find(peerId); updated = true; } - + // index is FAMILY + IP - the rest should be Zeros.. struct sockaddr_storage bannedaddr; sockaddr_storage_clear(bannedaddr); @@ -980,7 +980,7 @@ bool p3BanList::addBanEntry( const RsPeerId &peerId, blp.level = level; blp.mTs = time_stamp ; blp.masked_bytes = 0 ; - + it->second.mBanPeers[bannedaddr] = blp; it->second.mLastUpdate = now; updated = true; @@ -1036,7 +1036,7 @@ int p3BanList::condenseBanSources_locked() time_t now = time(NULL); RsPeerId ownId = mServiceCtrl->getOwnId(); - + #ifdef DEBUG_BANLIST std::cerr << "p3BanList::condenseBanSources_locked()"; std::cerr << std::endl; @@ -1062,7 +1062,7 @@ int p3BanList::condenseBanSources_locked() std::cerr << " Condensing Info from peer: " << it->first; std::cerr << std::endl; #endif - + std::map::const_iterator lit; for(lit = it->second.mBanPeers.begin(); lit != it->second.mBanPeers.end(); ++lit) { @@ -1135,7 +1135,7 @@ int p3BanList::condenseBanSources_locked() } } - + #ifdef DEBUG_BANLIST std::cerr << "p3BanList::condenseBanSources_locked() Printing New Set:"; std::cerr << std::endl; @@ -1280,7 +1280,7 @@ int p3BanList::printBanSet_locked(std::ostream &out) int p3BanList::printBanSources_locked(std::ostream &out) { time_t now = time(NULL); - + std::map::const_iterator it; for(it = mBanSources.begin(); it != mBanSources.end(); ++it) { diff --git a/libretroshare/src/services/p3banlist.h b/libretroshare/src/services/p3banlist.h index 34d4bc50c..ac22996a9 100644 --- a/libretroshare/src/services/p3banlist.h +++ b/libretroshare/src/services/p3banlist.h @@ -1,29 +1,24 @@ -/* - * libretroshare/src/services/p3banlist.h - * - * Exchange list of Peers for Banning / Whitelisting. - * - * Copyright 2011 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - +/******************************************************************************* + * libretroshare/src/services: p3banlist.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2011 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef SERVICE_RSBANLIST_HEADER #define SERVICE_RSBANLIST_HEADER diff --git a/libretroshare/src/services/p3bwctrl.cc b/libretroshare/src/services/p3bwctrl.cc index aa9106e47..7597c7fc9 100644 --- a/libretroshare/src/services/p3bwctrl.cc +++ b/libretroshare/src/services/p3bwctrl.cc @@ -1,28 +1,24 @@ -/* - * libretroshare/src/services p3bwctrl.cc - * - * Bandwidth Control Service for RetroShare. - * - * Copyright 2011-2011 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/services: p3bwctrl.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "pqi/p3linkmgr.h" #include "pqi/p3netmgr.h" #include "pqi/pqipersongrp.h" diff --git a/libretroshare/src/services/p3bwctrl.h b/libretroshare/src/services/p3bwctrl.h index 67e6f97fd..9b53f2d0d 100644 --- a/libretroshare/src/services/p3bwctrl.h +++ b/libretroshare/src/services/p3bwctrl.h @@ -1,29 +1,24 @@ -/* - * libretroshare/src/services/p3bwctrl.h - * - * Bandwidth Control. - * - * Copyright 2012 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - +/******************************************************************************* + * libretroshare/src/services: p3bwctrl.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef SERVICE_RSBANDWIDTH_CONTROL_HEADER #define SERVICE_RSBANDWIDTH_CONTROL_HEADER diff --git a/libretroshare/src/services/p3discovery2.cc b/libretroshare/src/services/p3discovery2.cc index 3eacf2548..cf4bc28dd 100644 --- a/libretroshare/src/services/p3discovery2.cc +++ b/libretroshare/src/services/p3discovery2.cc @@ -1,29 +1,25 @@ -/* - * libretroshare/src/services: p3discovery2.cc - * - * Services for RetroShare. - * - * Copyright (C) 2004-2013 Robert Fernie. - * Copyright (C) 2018 Gioacchino Mazzurco - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/services: p3discovery2.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2013 Robert Fernie * + * Copyright (C) 2018 Gioacchino Mazzurco * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "services/p3discovery2.h" #include "pqi/p3peermgr.h" #include "util/rsversioninfo.h" diff --git a/libretroshare/src/services/p3discovery2.h b/libretroshare/src/services/p3discovery2.h index 79ac13135..a4b127553 100644 --- a/libretroshare/src/services/p3discovery2.h +++ b/libretroshare/src/services/p3discovery2.h @@ -1,28 +1,24 @@ -/* - * libretroshare/src/services: p3discovery2.h - * - * Services for RetroShare. - * - * Copyright 2004-2013 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/services: p3discovery2.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2013 Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef MRK_SERVICES_DISCOVERY2_H #define MRK_SERVICES_DISCOVERY2_H diff --git a/libretroshare/src/services/p3gxschannels.cc b/libretroshare/src/services/p3gxschannels.cc index dd284a4f1..386fe4ee0 100644 --- a/libretroshare/src/services/p3gxschannels.cc +++ b/libretroshare/src/services/p3gxschannels.cc @@ -1,28 +1,24 @@ -/* - * libretroshare/src/services p3gxschannels.cc - * - * GxsChannels interface for RetroShare. - * - * Copyright 2012-2012 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/services: p3gxschannels.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012-2012 Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "services/p3gxschannels.h" #include "rsitems/rsgxschannelitems.h" #include "util/radix64.h" @@ -68,8 +64,13 @@ RsGxsChannels *rsGxsChannels = NULL; /******************* Startup / Tick ******************************************/ /********************************************************************************/ -p3GxsChannels::p3GxsChannels(RsGeneralDataService *gds, RsNetworkExchangeService *nes, RsGixs* gixs) - : RsGenExchange(gds, nes, new RsGxsChannelSerialiser(), RS_SERVICE_GXS_TYPE_CHANNELS, gixs, channelsAuthenPolicy()), RsGxsChannels(this), GxsTokenQueue(this) +p3GxsChannels::p3GxsChannels( + RsGeneralDataService *gds, RsNetworkExchangeService *nes, + RsGixs* gixs ) : + RsGenExchange( gds, nes, new RsGxsChannelSerialiser(), + RS_SERVICE_GXS_TYPE_CHANNELS, gixs, channelsAuthenPolicy() ), + RsGxsChannels(static_cast(*this)), GxsTokenQueue(this), + mSearchCallbacksMapMutex("GXS channels search") { // For Dummy Msgs. mGenActive = false; @@ -236,7 +237,7 @@ void p3GxsChannels::notifyChanges(std::vector &changes) RsGxsMsgChange *msgChange = dynamic_cast(*it); if (msgChange) { - if (msgChange->getType() == RsGxsNotify::TYPE_RECEIVE) + if (msgChange->getType() == RsGxsNotify::TYPE_RECEIVED_NEW) { /* message received */ if (notify) @@ -289,11 +290,12 @@ void p3GxsChannels::notifyChanges(std::vector &changes) { switch (grpChange->getType()) { + default: case RsGxsNotify::TYPE_PROCESSED: - case RsGxsNotify::TYPE_PUBLISH: + case RsGxsNotify::TYPE_PUBLISHED: break; - case RsGxsNotify::TYPE_RECEIVE: + case RsGxsNotify::TYPE_RECEIVED_NEW: { /* group received */ std::list &grpList = grpChange->mGrpIdList; @@ -311,7 +313,7 @@ void p3GxsChannels::notifyChanges(std::vector &changes) break; } - case RsGxsNotify::TYPE_PUBLISHKEY: + case RsGxsNotify::TYPE_RECEIVED_PUBLISHKEY: { /* group received */ std::list &grpList = grpChange->mGrpIdList; @@ -350,8 +352,6 @@ static time_t last_dummy_tick = 0; GxsTokenQueue::checkRequests(); mCommentService->comment_tick(); - - return; } bool p3GxsChannels::getGroupData(const uint32_t &token, std::vector &groups) @@ -395,10 +395,11 @@ bool p3GxsChannels::getGroupData(const uint32_t &token, std::vector& peers) +bool p3GxsChannels::groupShareKeys( + const RsGxsGroupId &groupId, const std::set& peers ) { - RsGenExchange::shareGroupPublishKey(groupId,peers) ; - return true ; + RsGenExchange::shareGroupPublishKey(groupId,peers); + return true; } @@ -995,6 +996,50 @@ void p3GxsChannels::handleResponse(uint32_t token, uint32_t req_type) } } +//////////////////////////////////////////////////////////////////////////////// +/// Blocking API implementation begin +//////////////////////////////////////////////////////////////////////////////// + +bool p3GxsChannels::getChannelsSummaries( + std::list& channels ) +{ + uint32_t token; + RsTokReqOptions opts; + opts.mReqType = GXS_REQUEST_TYPE_GROUP_META; + if( !requestGroupInfo(token, opts) + || waitToken(token) != RsTokenService::COMPLETE ) return false; + return getGroupSummary(token, channels); +} + +bool p3GxsChannels::getChannelsInfo( + const std::list& chanIds, + std::vector& channelsInfo ) +{ + uint32_t token; + RsTokReqOptions opts; + opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA; + if( !requestGroupInfo(token, opts, chanIds) + || waitToken(token) != RsTokenService::COMPLETE ) return false; + return getGroupData(token, channelsInfo); +} + +bool p3GxsChannels::getChannelsContent( + const std::list& chanIds, + std::vector& posts, + std::vector& comments ) +{ + uint32_t token; + RsTokReqOptions opts; + opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA; + if( !requestMsgInfo(token, opts, chanIds) + || waitToken(token) != RsTokenService::COMPLETE ) return false; + return getPostData(token, posts, comments); +} + +//////////////////////////////////////////////////////////////////////////////// +/// Blocking API implementation end +//////////////////////////////////////////////////////////////////////////////// + /********************************************************************************************/ /********************************************************************************************/ @@ -1237,17 +1282,10 @@ bool p3GxsChannels::createPost(uint32_t &token, RsGxsChannelPost &msg) /********************************************************************************************/ /********************************************************************************************/ -bool p3GxsChannels::ExtraFileHash(const std::string &path, std::string filename) +bool p3GxsChannels::ExtraFileHash(const std::string& path) { - /* extract filename */ - filename = RsDirUtil::getTopDir(path); - - TransferRequestFlags flags = RS_FILE_REQ_ANONYMOUS_ROUTING; - if(!rsFiles->ExtraFileHash(path, GXSCHANNEL_STOREPERIOD, flags)) - return false; - - return true; + return rsFiles->ExtraFileHash(path, GXSCHANNEL_STOREPERIOD, flags); } @@ -1315,14 +1353,14 @@ void p3GxsChannels::dummy_tick() #endif uint32_t status = RsGenExchange::getTokenService()->requestStatus(mGenToken); - if (status != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) + if (status != RsTokenService::COMPLETE) { #ifdef GXSCHANNELS_DEBUG std::cerr << "p3GxsChannels::dummy_tick() Status: " << status; std::cerr << std::endl; #endif - if (status == RsTokenService::GXS_REQUEST_V2_STATUS_FAILED) + if (status == RsTokenService::FAILED) { #ifdef GXSCHANNELS_DEBUG std::cerr << "p3GxsChannels::dummy_tick() generateDummyMsgs() FAILED"; @@ -1521,6 +1559,8 @@ void p3GxsChannels::dummy_tick() } } + + cleanTimedOutSearches(); } @@ -1686,3 +1726,110 @@ void p3GxsChannels::handle_event(uint32_t event_type, const std::string &elabel) } } +TurtleRequestId p3GxsChannels::turtleGroupRequest(const RsGxsGroupId& group_id) +{ + return netService()->turtleGroupRequest(group_id) ; +} +TurtleRequestId p3GxsChannels::turtleSearchRequest(const std::string& match_string) +{ + return netService()->turtleSearchRequest(match_string) ; +} + +bool p3GxsChannels::clearDistantSearchResults(TurtleRequestId req) +{ + return netService()->clearDistantSearchResults(req); +} +bool p3GxsChannels::retrieveDistantSearchResults(TurtleRequestId req,std::map& results) +{ + return netService()->retrieveDistantSearchResults(req,results); +} + +bool p3GxsChannels::retrieveDistantGroup(const RsGxsGroupId& group_id,RsGxsChannelGroup& distant_group) +{ + RsGxsGroupSummary gs; + + if(netService()->retrieveDistantGroupSummary(group_id,gs)) + { + // This is a placeholder information by the time we receive the full group meta data. + distant_group.mMeta.mGroupId = gs.mGroupId ; + distant_group.mMeta.mGroupName = gs.mGroupName; + distant_group.mMeta.mGroupFlags = GXS_SERV::FLAG_PRIVACY_PUBLIC ; + distant_group.mMeta.mSignFlags = gs.mSignFlags; + + distant_group.mMeta.mPublishTs = gs.mPublishTs; + distant_group.mMeta.mAuthorId = gs.mAuthorId; + + distant_group.mMeta.mCircleType = GXS_CIRCLE_TYPE_PUBLIC ;// guessed, otherwise the group would not be search-able. + + // other stuff. + distant_group.mMeta.mAuthenFlags = 0; // wild guess... + + distant_group.mMeta.mSubscribeFlags = GXS_SERV::GROUP_SUBSCRIBE_NOT_SUBSCRIBED ; + + distant_group.mMeta.mPop = gs.mPopularity; // Popularity = number of friend subscribers + distant_group.mMeta.mVisibleMsgCount = gs.mNumberOfMessages; // Max messages reported by friends + distant_group.mMeta.mLastPost = gs.mLastMessageTs; // Timestamp for last message. Not used yet. + + return true ; + } + else + return false ; +} + +bool p3GxsChannels::turtleSearchRequest( + const std::string& matchString, + const std::function& multiCallback, + std::time_t maxWait ) +{ + if(matchString.empty()) + { + std::cerr << __PRETTY_FUNCTION__ << " match string can't be empty!" + << std::endl; + return false; + } + + TurtleRequestId sId = turtleSearchRequest(matchString); + + RS_STACK_MUTEX(mSearchCallbacksMapMutex); + mSearchCallbacksMap.emplace( + sId, + std::make_pair( + multiCallback, + std::chrono::system_clock::now() + + std::chrono::seconds(maxWait) ) ); + + return true; +} + +void p3GxsChannels::receiveDistantSearchResults( + TurtleRequestId id, const RsGxsGroupId& grpId ) +{ + std::cerr << __PRETTY_FUNCTION__ << "(" << id << ", " << grpId << ")" + << std::endl; + + RsGenExchange::receiveDistantSearchResults(id, grpId); + RsGxsGroupSummary gs; + gs.mGroupId = grpId; + netService()->retrieveDistantGroupSummary(grpId, gs); + + { + RS_STACK_MUTEX(mSearchCallbacksMapMutex); + auto cbpt = mSearchCallbacksMap.find(id); + if(cbpt != mSearchCallbacksMap.end()) + cbpt->second.first(gs); + } // end RS_STACK_MUTEX(mSearchCallbacksMapMutex); +} + +void p3GxsChannels::cleanTimedOutSearches() +{ + RS_STACK_MUTEX(mSearchCallbacksMapMutex); + auto now = std::chrono::system_clock::now(); + for( auto cbpt = mSearchCallbacksMap.begin(); + cbpt != mSearchCallbacksMap.end(); ) + if(cbpt->second.second <= now) + { + clearDistantSearchResults(cbpt->first); + cbpt = mSearchCallbacksMap.erase(cbpt); + } + else ++cbpt; +} diff --git a/libretroshare/src/services/p3gxschannels.h b/libretroshare/src/services/p3gxschannels.h index 0e6156f48..4f24f88b9 100644 --- a/libretroshare/src/services/p3gxschannels.h +++ b/libretroshare/src/services/p3gxschannels.h @@ -1,28 +1,24 @@ -/* - * libretroshare/src/services: p3gxschannels.h - * - * GxsChannel interface for RetroShare. - * - * Copyright 2012-2012 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/services: p3gxschannels.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012-2012 Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef P3_GXSCHANNELS_SERVICE_HEADER #define P3_GXSCHANNELS_SERVICE_HEADER @@ -58,20 +54,26 @@ class p3GxsChannels: public RsGenExchange, public RsGxsChannels, public GxsTokenQueue, public p3Config, public RsTickEvent /* only needed for testing - remove after */ { - public: +public: + p3GxsChannels( RsGeneralDataService* gds, RsNetworkExchangeService* nes, + RsGixs* gixs ); + virtual RsServiceInfo getServiceInfo(); - p3GxsChannels(RsGeneralDataService* gds, RsNetworkExchangeService* nes, RsGixs* gixs); -virtual RsServiceInfo getServiceInfo(); + virtual void service_tick(); -virtual void service_tick(); - - protected: +protected: virtual RsSerialiser* setupSerialiser(); // @see p3Config::setupSerialiser() virtual bool saveList(bool &cleanup, std::list&saveList); // @see p3Config::saveList(bool &cleanup, std::list&) virtual bool loadList(std::list& loadList); // @see p3Config::loadList(std::list&) + virtual TurtleRequestId turtleGroupRequest(const RsGxsGroupId& group_id); + virtual TurtleRequestId turtleSearchRequest(const std::string& match_string); + virtual bool retrieveDistantSearchResults(TurtleRequestId req, std::map &results) ; + virtual bool clearDistantSearchResults(TurtleRequestId req); + virtual bool retrieveDistantGroup(const RsGxsGroupId& group_id,RsGxsChannelGroup& distant_group); + // Overloaded to cache new groups. virtual RsGenExchange::ServiceCreate_Return service_CreateGroup(RsGxsGrpItem* grpItem, RsTlvSecurityKeySet& keySet); @@ -80,7 +82,7 @@ virtual void notifyChanges(std::vector& changes); // Overloaded from RsTickEvent. virtual void handle_event(uint32_t event_type, const std::string &elabel); - public: +public: virtual bool getGroupData(const uint32_t &token, std::vector &groups); virtual bool getPostData(const uint32_t &token, std::vector &posts, std::vector &cmts); @@ -94,7 +96,8 @@ virtual bool getPostData(const uint32_t &token, std::vector &p //virtual bool setGroupSubscribeFlags(const std::string &groupId, uint32_t subscribeFlags, uint32_t subscribeMask); //virtual bool groupRestoreKeys(const std::string &groupId); - virtual bool groupShareKeys(const RsGxsGroupId &groupId, std::set& peers) ; + virtual bool groupShareKeys( + const RsGxsGroupId &groupId, const std::set& peers); virtual bool createGroup(uint32_t &token, RsGxsChannelGroup &group); virtual bool createPost(uint32_t &token, RsGxsChannelPost &post); @@ -107,6 +110,18 @@ virtual bool getChannelAutoDownload(const RsGxsGroupId &groupid, bool& enabled); virtual bool setChannelDownloadDirectory(const RsGxsGroupId &groupId, const std::string& directory); virtual bool getChannelDownloadDirectory(const RsGxsGroupId &groupId, std::string& directory); + /// @see RsGxsChannels::turtleSearchRequest + virtual bool turtleSearchRequest(const std::string& matchString, + const std::function& multiCallback, + std::time_t maxWait = 300 ); + + /** + * Receive results from turtle search @see RsGenExchange @see RsNxsObserver + * @see p3turtle::handleSearchResult + */ + void receiveDistantSearchResults( TurtleRequestId id, + const RsGxsGroupId& grpId ); + /* Comment service - Provide RsGxsCommentService - redirect to p3GxsCommentService */ virtual bool getCommentData(uint32_t token, std::vector &msgs) { return mCommentService->getGxsCommentData(token, msgs); } @@ -149,15 +164,30 @@ virtual void setMessageProcessedStatus(uint32_t& token, const RsGxsGrpMsgIdPair& virtual void setMessageReadStatus(uint32_t& token, const RsGxsGrpMsgIdPair& msgId, bool read); // File Interface -virtual bool ExtraFileHash(const std::string &path, std::string filename); + virtual bool ExtraFileHash(const std::string& path); virtual bool ExtraFileRemove(const RsFileHash &hash); - protected: + /// Implementation of @see RsGxsChannels::getChannelsSummaries + virtual bool getChannelsSummaries(std::list& channels); + + /// Implementation of @see RsGxsChannels::getChannelsInfo + virtual bool getChannelsInfo( + const std::list& chanIds, + std::vector& channelsInfo ); + + /// Implementation of @see RsGxsChannels::getChannelContent + virtual bool getChannelsContent( + const std::list& chanIds, + std::vector& posts, + std::vector& comments ); + +protected: // Overloaded from GxsTokenQueue for Request callbacks. -virtual void handleResponse(uint32_t token, uint32_t req_type); + virtual void handleResponse(uint32_t token, uint32_t req_type); - private: + +private: static uint32_t channelsAuthenPolicy(); @@ -218,8 +248,20 @@ bool generateGroup(uint32_t &token, std::string groupName); std::vector mGenRefs; RsGxsMessageId mGenThreadId; - p3GxsCommentService *mCommentService; + p3GxsCommentService *mCommentService; std::map mKnownChannels; + + /** Store search callbacks with timeout*/ + std::map< + TurtleRequestId, + std::pair< + std::function, + std::chrono::system_clock::time_point > + > mSearchCallbacksMap; + RsMutex mSearchCallbacksMapMutex; + + /// Cleanup mSearchCallbacksMap + void cleanTimedOutSearches(); }; #endif diff --git a/libretroshare/src/services/p3gxscircles.cc b/libretroshare/src/services/p3gxscircles.cc index 063361121..10e6f3628 100644 --- a/libretroshare/src/services/p3gxscircles.cc +++ b/libretroshare/src/services/p3gxscircles.cc @@ -1,28 +1,24 @@ -/* - * libretroshare/src/services p3gxscircles.cc - * - * Circles Interface for RetroShare. - * - * Copyright 2012-2012 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/services: p3gxscircles.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012-2012 Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "rsitems/rsgxscircleitems.h" #include "services/p3gxscircles.h" @@ -111,16 +107,16 @@ RsGxsCircles *rsGxsCircles = NULL; /******************* Startup / Tick ******************************************/ /********************************************************************************/ -p3GxsCircles::p3GxsCircles(RsGeneralDataService *gds, RsNetworkExchangeService *nes, - p3IdService *identities, PgpAuxUtils *pgpUtils) - : RsGxsCircleExchange(gds, nes, new RsGxsCircleSerialiser(), - RS_SERVICE_GXS_TYPE_GXSCIRCLE, identities, circleAuthenPolicy()), - RsGxsCircles(this), GxsTokenQueue(this), RsTickEvent(), - mIdentities(identities), - mPgpUtils(pgpUtils), - mCircleMtx("p3GxsCircles"), - mCircleCache(DEFAULT_MEM_CACHE_SIZE, "GxsCircleCache") - +p3GxsCircles::p3GxsCircles( + RsGeneralDataService *gds, RsNetworkExchangeService *nes, + p3IdService *identities, PgpAuxUtils *pgpUtils) : + RsGxsCircleExchange( + gds, nes, new RsGxsCircleSerialiser(), RS_SERVICE_GXS_TYPE_GXSCIRCLE, + identities, circleAuthenPolicy() ), + RsGxsCircles(static_cast(*this)), GxsTokenQueue(this), + RsTickEvent(), mIdentities(identities), mPgpUtils(pgpUtils), + mCircleMtx("p3GxsCircles"), + mCircleCache(DEFAULT_MEM_CACHE_SIZE, "GxsCircleCache" ) { // Kick off Cache Testing, + Others. //RsTickEvent::schedule_in(CIRCLE_EVENT_CACHETEST, CACHETEST_PERIOD); @@ -218,7 +214,8 @@ void p3GxsCircles::notifyChanges(std::vector &changes) std::cerr << " Msgs for Group: " << mit->first << std::endl; #endif force_cache_reload(RsGxsCircleId(mit->first)); - if (notify && (c->getType() == RsGxsNotify::TYPE_RECEIVE) ) + + if (notify && (c->getType() == RsGxsNotify::TYPE_RECEIVED_NEW) ) for (auto msgIdIt(mit->second.begin()), end(mit->second.end()); msgIdIt != end; ++msgIdIt) { const RsGxsMessageId& msgId = *msgIdIt; @@ -261,7 +258,7 @@ void p3GxsCircles::notifyChanges(std::vector &changes) std::cerr << " forcing cache loading for circle " << *git << " in order to trigger subscribe update." << std::endl; #endif force_cache_reload(RsGxsCircleId(*git)) ; - if (notify && (c->getType() == RsGxsNotify::TYPE_RECEIVE) ) + if (notify && (c->getType() == RsGxsNotify::TYPE_RECEIVED_NEW) ) notify->AddFeedItem(RS_FEED_ITEM_CIRCLE_INVIT_REC,RsGxsCircleId(*git).toStdString(),""); } @@ -1656,8 +1653,8 @@ void p3GxsCircles::checkDummyIdData() // check the token. uint32_t status = rsIdentity->getTokenService()->requestStatus(mDummyIdToken); - if ( (RsTokenService::GXS_REQUEST_V2_STATUS_FAILED == status) || - (RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE == status) ) + if ( (RsTokenService::FAILED == status) || + (RsTokenService::COMPLETE == status) ) { std::vector ids; if (!rsIdentity->getGroupData(mDummyIdToken, ids)) diff --git a/libretroshare/src/services/p3gxscircles.h b/libretroshare/src/services/p3gxscircles.h index 4e011eea0..a5a56efc0 100644 --- a/libretroshare/src/services/p3gxscircles.h +++ b/libretroshare/src/services/p3gxscircles.h @@ -1,28 +1,24 @@ -/* - * libretroshare/src/services: p3circles.h - * - * Identity interface for RetroShare. - * - * Copyright 2012-2012 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/services: p3gxscircles.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012-2012 Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef P3_CIRCLES_SERVICE_HEADER #define P3_CIRCLES_SERVICE_HEADER diff --git a/libretroshare/src/services/p3gxscommon.cc b/libretroshare/src/services/p3gxscommon.cc index e1db6750d..28d94e28c 100644 --- a/libretroshare/src/services/p3gxscommon.cc +++ b/libretroshare/src/services/p3gxscommon.cc @@ -1,28 +1,24 @@ -/* - * libretroshare/src/services p3gxscommon.cc - * - * GxsChannels interface for RetroShare. - * - * Copyright 2012-2013 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/services: p3gxscommon.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012-2013 Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "retroshare/rsgxscommon.h" #include "services/p3gxscommon.h" #include "rsitems/rsgxscommentitems.h" @@ -556,24 +552,22 @@ void p3GxsCommentService::load_PendingVoteParent(const uint32_t &token) pit = mPendingVotes.find(parentId); if (pit == mPendingVotes.end()) { - std::cerr << "p3GxsCommentService::load_PendingVoteParent() ERROR Finding Pending Vote"; - std::cerr << std::endl; + std::cerr << __PRETTY_FUNCTION__ + << " ERROR Finding Pending Vote" << std::endl; continue; } RsGxsVote vote = pit->second.mVote; if (meta.mMsgStatus & GXS_SERV::GXS_MSG_STATUS_VOTE_MASK) { - std::cerr << "p3GxsCommentService::load_PendingVoteParent() ERROR Already Voted"; - std::cerr << std::endl; - std::cerr << "mGroupId: " << meta.mGroupId; - std::cerr << std::endl; - std::cerr << "mMsgId: " << meta.mMsgId; - std::cerr << std::endl; + std::cerr << __PRETTY_FUNCTION__ << " ERROR Already Voted" + << std::endl + << "mGroupId: " << meta.mGroupId << std::endl + << "mMsgId: " << meta.mMsgId << std::endl; pit->second.mStatus = VoteHolder::VOTE_ERROR; - uint32_t status = RsTokenService::GXS_REQUEST_V2_STATUS_FAILED; - mExchange->updatePublicRequestStatus(pit->second.mReqToken, status); + mExchange->updatePublicRequestStatus( + pit->second.mReqToken, RsTokenService::FAILED ); continue; } @@ -617,8 +611,8 @@ void p3GxsCommentService::completeInternalVote(uint32_t &token) { if (it->second.mVoteToken == token) { - - uint32_t status = mExchange->getTokenService()->requestStatus(token); + RsTokenService::GxsRequestStatus status = + mExchange->getTokenService()->requestStatus(token); mExchange->updatePublicRequestStatus(it->second.mReqToken, status); #ifdef DEBUG_GXSCOMMON diff --git a/libretroshare/src/services/p3gxscommon.h b/libretroshare/src/services/p3gxscommon.h index af7e0983c..469fa3426 100644 --- a/libretroshare/src/services/p3gxscommon.h +++ b/libretroshare/src/services/p3gxscommon.h @@ -1,27 +1,24 @@ -/* - * libretroshare/src/services p3gxscommon.cc - * - * GxsChannels interface for RetroShare. - * - * Copyright 2012-2013 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ +/******************************************************************************* + * libretroshare/src/services: p3gxscommon.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012-2013 Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef P3_GXSCOMMON_SERVICE_HEADER #define P3_GXSCOMMON_SERVICE_HEADER diff --git a/libretroshare/src/services/p3gxsforums.cc b/libretroshare/src/services/p3gxsforums.cc index 1be91dc00..1a348b61c 100644 --- a/libretroshare/src/services/p3gxsforums.cc +++ b/libretroshare/src/services/p3gxsforums.cc @@ -1,28 +1,24 @@ -/* - * libretroshare/src/services p3gxsforums.cc - * - * GxsForums interface for RetroShare. - * - * Copyright 2012-2012 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/services: p3gxsforums.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012-2012 Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "services/p3gxsforums.h" #include "rsitems/rsgxsforumitems.h" @@ -55,7 +51,8 @@ p3GxsForums::p3GxsForums( RsGeneralDataService *gds, RsNetworkExchangeService *nes, RsGixs* gixs ) : RsGenExchange( gds, nes, new RsGxsForumSerialiser(), RS_SERVICE_GXS_TYPE_FORUMS, gixs, forumsAuthenPolicy()), - RsGxsForums(this), mGenToken(0), mGenActive(false), mGenCount(0) + RsGxsForums(static_cast(*this)), mGenToken(0), + mGenActive(false), mGenCount(0) { // Test Data disabled in Repo. //RsTickEvent::schedule_in(FORUM_TESTEVENT_DUMMYDATA, DUMMYDATA_PERIOD); @@ -196,11 +193,12 @@ void p3GxsForums::notifyChanges(std::vector &changes) switch (c->getType()) { + default: case RsGxsNotify::TYPE_PROCESSED: - case RsGxsNotify::TYPE_PUBLISH: + case RsGxsNotify::TYPE_PUBLISHED: break; - case RsGxsNotify::TYPE_RECEIVE: + case RsGxsNotify::TYPE_RECEIVED_NEW: { RsGxsMsgChange *msgChange = dynamic_cast(c); if (msgChange) @@ -239,7 +237,7 @@ void p3GxsForums::notifyChanges(std::vector &changes) break; } - case RsGxsNotify::TYPE_PUBLISHKEY: + case RsGxsNotify::TYPE_RECEIVED_PUBLISHKEY: { RsGxsGroupChange *grpChange = dynamic_cast(*it); if (grpChange) @@ -489,12 +487,12 @@ void p3GxsForums::dummy_tick() std::cerr << std::endl; uint32_t status = RsGenExchange::getTokenService()->requestStatus(mGenToken); - if (status != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) + if (status != RsTokenService::COMPLETE) { std::cerr << "p3GxsForums::dummy_tick() Status: " << status; std::cerr << std::endl; - if (status == RsTokenService::GXS_REQUEST_V2_STATUS_FAILED) + if (status == RsTokenService::FAILED) { std::cerr << "p3GxsForums::dummy_tick() generateDummyMsgs() FAILED"; std::cerr << std::endl; diff --git a/libretroshare/src/services/p3gxsforums.h b/libretroshare/src/services/p3gxsforums.h index a4e0ebf47..c6341c333 100644 --- a/libretroshare/src/services/p3gxsforums.h +++ b/libretroshare/src/services/p3gxsforums.h @@ -1,28 +1,24 @@ -/* - * libretroshare/src/services: p3gxsforums.h - * - * GxsForum interface for RetroShare. - * - * Copyright 2012-2012 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/services: p3gxsforums.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012-2012 Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef P3_GXSFORUMS_SERVICE_HEADER #define P3_GXSFORUMS_SERVICE_HEADER diff --git a/libretroshare/src/services/p3gxsreputation.cc b/libretroshare/src/services/p3gxsreputation.cc index 118d404e5..01e022c8e 100644 --- a/libretroshare/src/services/p3gxsreputation.cc +++ b/libretroshare/src/services/p3gxsreputation.cc @@ -1,28 +1,24 @@ -/* - * libretroshare/src/services p3gxsreputation.cc - * - * Gxs Reputation Service for RetroShare. - * - * Copyright 2011-2014 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/services: p3gxsreputation.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2014-2014 Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include #include "pqi/p3linkmgr.h" diff --git a/libretroshare/src/services/p3gxsreputation.h b/libretroshare/src/services/p3gxsreputation.h index ad45e2298..75d5d628c 100644 --- a/libretroshare/src/services/p3gxsreputation.h +++ b/libretroshare/src/services/p3gxsreputation.h @@ -1,29 +1,24 @@ -/* - * libretroshare/src/services/p3gxsreputation.h - * - * Exchange list of Peers Reputations. - * - * Copyright 2014 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - +/******************************************************************************* + * libretroshare/src/services: p3gxsreputation.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2014-2014 Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef SERVICE_RSGXSREPUTATION_HEADER #define SERVICE_RSGXSREPUTATION_HEADER diff --git a/libretroshare/src/services/p3heartbeat.cc b/libretroshare/src/services/p3heartbeat.cc index 498a88cfa..e74787812 100644 --- a/libretroshare/src/services/p3heartbeat.cc +++ b/libretroshare/src/services/p3heartbeat.cc @@ -1,28 +1,24 @@ -/* - * libretroshare/src/services: p3heartbeat.cc - * - * Services for RetroShare. - * - * Copyright 2004-2013 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/services: p3heartbeat.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2013 Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include #include "services/p3heartbeat.h" diff --git a/libretroshare/src/services/p3heartbeat.h b/libretroshare/src/services/p3heartbeat.h index da7c8b1df..21dd9b6b7 100644 --- a/libretroshare/src/services/p3heartbeat.h +++ b/libretroshare/src/services/p3heartbeat.h @@ -1,28 +1,24 @@ -/* - * libretroshare/src/services: p3heartbeat.h - * - * Services for RetroShare. - * - * Copyright 2004-2013 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/services: p3heartbeat.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2013 Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef MRK_SERVICES_HEARTBEAT_H #define MRK_SERVICES_HEARTBEAT_H diff --git a/libretroshare/src/services/p3idservice.cc b/libretroshare/src/services/p3idservice.cc index 8a3f08195..a4d5fb844 100644 --- a/libretroshare/src/services/p3idservice.cc +++ b/libretroshare/src/services/p3idservice.cc @@ -1,29 +1,25 @@ -/* - * libretroshare/src/services p3idservice.cc - * - * Id interface for RetroShare. - * - * Copyright (C) 2012 Robert Fernie - * Copyright (C) 2018 Gioacchino Mazzurco - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/services: p3idservice.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012-2012 Robert Fernie * + * Copyright (C) 2018 Gioacchino Mazzurco * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include #include "services/p3idservice.h" @@ -156,12 +152,14 @@ RsIdentity *rsIdentity = NULL; /******************* Startup / Tick ******************************************/ /********************************************************************************/ -p3IdService::p3IdService(RsGeneralDataService *gds, RsNetworkExchangeService *nes, PgpAuxUtils *pgpUtils) - : RsGxsIdExchange(gds, nes, new RsGxsIdSerialiser(), RS_SERVICE_GXS_TYPE_GXSID, idAuthenPolicy()), - RsIdentity(this), GxsTokenQueue(this), RsTickEvent(), - mKeyCache(GXSID_MAX_CACHE_SIZE, "GxsIdKeyCache"), - mIdMtx("p3IdService"), mNes(nes), - mPgpUtils(pgpUtils) +p3IdService::p3IdService( + RsGeneralDataService *gds, RsNetworkExchangeService *nes, + PgpAuxUtils *pgpUtils ) : + RsGxsIdExchange( gds, nes, new RsGxsIdSerialiser(), + RS_SERVICE_GXS_TYPE_GXSID, idAuthenPolicy() ), + RsIdentity(static_cast(*this)), GxsTokenQueue(this), + RsTickEvent(), mKeyCache(GXSID_MAX_CACHE_SIZE, "GxsIdKeyCache"), + mIdMtx("p3IdService"), mNes(nes), mPgpUtils(pgpUtils) { mBgSchedule_Mode = 0; mBgSchedule_Active = false; @@ -278,7 +276,7 @@ void p3IdService::timeStampKey(const RsGxsId& gxs_id, const RsIdentityUsage& rea return ; } #ifdef DEBUG_IDS - std::cerr << "(II) time stamping key " << gxs_id << " for the following reason: " << reason << std::endl; + std::cerr << "(II) time stamping key " << gxs_id << " for the following reason: " << reason.mUsageCode << std::endl; #endif RS_STACK_MUTEX(mIdMtx) ; @@ -1536,7 +1534,7 @@ bool p3IdService::opinion_handlerequest(uint32_t token) std::cerr << "p3IdService::opinion_handlerequest() ERROR getGroupMeta()"; std::cerr << std::endl; - updatePublicRequestStatus(req.mToken, RsTokenService::GXS_REQUEST_V2_STATUS_FAILED); + updatePublicRequestStatus(req.mToken, RsTokenService::FAILED); return false; } @@ -1546,7 +1544,7 @@ bool p3IdService::opinion_handlerequest(uint32_t token) std::cerr << std::endl; // error. - updatePublicRequestStatus(req.mToken, RsTokenService::GXS_REQUEST_V2_STATUS_FAILED); + updatePublicRequestStatus(req.mToken, RsTokenService::FAILED); return false; } RsGroupMetaData &meta = *(groups.begin()); @@ -1557,7 +1555,7 @@ bool p3IdService::opinion_handlerequest(uint32_t token) std::cerr << std::endl; // error. - updatePublicRequestStatus(req.mToken, RsTokenService::GXS_REQUEST_V2_STATUS_FAILED); + updatePublicRequestStatus(req.mToken, RsTokenService::FAILED); return false; } @@ -1592,7 +1590,7 @@ bool p3IdService::opinion_handlerequest(uint32_t token) setGroupServiceString(dummyToken, meta.mGroupId, serviceString); cache_update_if_cached(RsGxsId(meta.mGroupId), serviceString); - updatePublicRequestStatus(req.mToken, RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE); + updatePublicRequestStatus(req.mToken, RsTokenService::COMPLETE); return true; } @@ -2700,7 +2698,7 @@ void p3IdService::requestIdsFromNet() bool request_can_proceed = false ; for(cit2 = peers.begin(); cit2 != peers.end(); ++cit2) - if(rsPeers->isOnline(*cit2)) // make sure that the peer in online, so that we know that the request has some chance to succeed. + if(rsPeers->isOnline(*cit2) || mNes->isDistantPeer(*cit2)) // make sure that the peer in online, so that we know that the request has some chance to succeed. { requests[*cit2].push_back(cit->first); request_can_proceed = true ; diff --git a/libretroshare/src/services/p3idservice.h b/libretroshare/src/services/p3idservice.h index f97192e72..6a5ec640f 100644 --- a/libretroshare/src/services/p3idservice.h +++ b/libretroshare/src/services/p3idservice.h @@ -1,28 +1,24 @@ -/* - * libretroshare/src/services: p3idservice.h - * - * Identity interface for RetroShare. - * - * Copyright 2012-2012 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/services: p3idservice.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012-2012 Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef P3_IDENTITY_SERVICE_HEADER #define P3_IDENTITY_SERVICE_HEADER diff --git a/libretroshare/src/services/p3msgservice.cc b/libretroshare/src/services/p3msgservice.cc index e56d2fb5a..5b270749b 100644 --- a/libretroshare/src/services/p3msgservice.cc +++ b/libretroshare/src/services/p3msgservice.cc @@ -1,35 +1,29 @@ -/* - * libretroshare/src/services msgservice.cc - * - * Services for RetroShare. - * - * Copyright 2004-2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - +/******************************************************************************* + * libretroshare/src/services: p3msgservice.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2008 Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "retroshare/rsiface.h" #include "retroshare/rspeers.h" #include "retroshare/rsidentity.h" #include "pqi/pqibin.h" -#include "pqi/pqiarchive.h" #include "pqi/p3linkmgr.h" #include "pqi/authgpg.h" #include "pqi/p3cfgmgr.h" diff --git a/libretroshare/src/services/p3msgservice.h b/libretroshare/src/services/p3msgservice.h index 7027e470b..32f087ad0 100644 --- a/libretroshare/src/services/p3msgservice.h +++ b/libretroshare/src/services/p3msgservice.h @@ -1,29 +1,24 @@ -/* - * libretroshare/src/services msgservice.h - * - * Services for RetroShare. - * - * Copyright 2004-2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - +/******************************************************************************* + * libretroshare/src/services: p3msgservice.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2008 Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef MESSAGE_SERVICE_HEADER #define MESSAGE_SERVICE_HEADER diff --git a/libretroshare/src/services/p3photoservice.cc b/libretroshare/src/services/p3photoservice.cc index 519f10c68..fa42224d7 100644 --- a/libretroshare/src/services/p3photoservice.cc +++ b/libretroshare/src/services/p3photoservice.cc @@ -1,3 +1,24 @@ +/******************************************************************************* + * libretroshare/src/services: p3photoservice.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2008-2012 Robert Fernie,Chris Evi-Parker * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "p3photoservice.h" #include "rsitems/rsphotoitems.h" #include "retroshare/rsgxsflags.h" diff --git a/libretroshare/src/services/p3photoservice.h b/libretroshare/src/services/p3photoservice.h index 236687301..3d26ea739 100644 --- a/libretroshare/src/services/p3photoservice.h +++ b/libretroshare/src/services/p3photoservice.h @@ -1,31 +1,27 @@ +/******************************************************************************* + * libretroshare/src/services: p3photoservice.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2008-2012 Robert Fernie,Chris Evi-Parker * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef P3PHOTOSERVICEV2_H #define P3PHOTOSERVICEV2_H -/* - * libretroshare/src/retroshare: rsphoto.h - * - * RetroShare C++ Interface. - * - * Copyright 2008-2012 by Robert Fernie, Christopher Evi-Parker - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - #include "gxs/rsgenexchange.h" #include "retroshare/rsphoto.h" diff --git a/libretroshare/src/services/p3postbase.cc b/libretroshare/src/services/p3postbase.cc index 9d1df6bdc..9fb939baa 100644 --- a/libretroshare/src/services/p3postbase.cc +++ b/libretroshare/src/services/p3postbase.cc @@ -1,28 +1,24 @@ -/* - * libretroshare/src/services p3posted.cc - * - * Posted interface for RetroShare. - * - * Copyright 2012-2012 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/services: p3postbase.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2008-2012 Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include #include "retroshare/rsgxsflags.h" @@ -122,7 +118,7 @@ void p3PostBase::notifyChanges(std::vector &changes) // It could be taken a step further and directly request these msgs for an update. addGroupForProcessing(mit->first); - if (notify && msgChange->getType() == RsGxsNotify::TYPE_RECEIVE) + if (notify && msgChange->getType() == RsGxsNotify::TYPE_RECEIVED_NEW) { for (auto mit1 = mit->second.begin(); mit1 != mit->second.end(); ++mit1) { @@ -149,7 +145,7 @@ void p3PostBase::notifyChanges(std::vector &changes) std::cerr << std::endl; #endif - if (notify && groupChange->getType() == RsGxsNotify::TYPE_RECEIVE) + if (notify && groupChange->getType() == RsGxsNotify::TYPE_RECEIVED_NEW) { notify->AddFeedItem(RS_FEED_ITEM_POSTED_NEW, git->toStdString()); } diff --git a/libretroshare/src/services/p3postbase.h b/libretroshare/src/services/p3postbase.h index b5ce1d895..1e63b0dcd 100644 --- a/libretroshare/src/services/p3postbase.h +++ b/libretroshare/src/services/p3postbase.h @@ -1,28 +1,24 @@ -/* - * libretroshare/src/services: p3postbase.h - * - * GxsChannel interface for RetroShare. - * - * Copyright 2012-2013 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/services: p3postbase.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2008-2012 Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef P3_POSTBASE_SERVICE_HEADER #define P3_POSTBASE_SERVICE_HEADER diff --git a/libretroshare/src/services/p3posted.cc b/libretroshare/src/services/p3posted.cc index 555f2147f..4d5cced66 100644 --- a/libretroshare/src/services/p3posted.cc +++ b/libretroshare/src/services/p3posted.cc @@ -1,28 +1,24 @@ -/* - * libretroshare/src/services p3posted.cc - * - * Posted interface for RetroShare. - * - * Copyright 2012-2012 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/services: p3posted.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012-2013 Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "services/p3posted.h" #include "rsitems/rsposteditems.h" @@ -40,13 +36,12 @@ RsPosted *rsPosted = NULL; /******************* Startup / Tick ******************************************/ /********************************************************************************/ -p3Posted::p3Posted(RsGeneralDataService *gds, RsNetworkExchangeService *nes, RsGixs* gixs) - :p3PostBase(gds, nes, gixs, new RsGxsPostedSerialiser(), RS_SERVICE_GXS_TYPE_POSTED), - RsPosted(this) -{ - return; -} - +p3Posted::p3Posted( + RsGeneralDataService *gds, RsNetworkExchangeService *nes, + RsGixs* gixs ) : + p3PostBase( gds, nes, gixs, new RsGxsPostedSerialiser(), + RS_SERVICE_GXS_TYPE_POSTED ), + RsPosted(static_cast(*this)) {} const std::string GXS_POSTED_APP_NAME = "gxsposted"; const uint16_t GXS_POSTED_APP_MAJOR_VERSION = 1; diff --git a/libretroshare/src/services/p3posted.h b/libretroshare/src/services/p3posted.h index aa4bbc8ee..4a032b49b 100644 --- a/libretroshare/src/services/p3posted.h +++ b/libretroshare/src/services/p3posted.h @@ -1,27 +1,24 @@ -/* - * libretroshare/src/services: p3posted.h - * - * GxsChannel interface for RetroShare. - * - * Copyright 2012-2013 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ +/******************************************************************************* + * libretroshare/src/services: p3posted.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012-2013 Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef P3_POSTED_SERVICE_HEADER #define P3_POSTED_SERVICE_HEADER diff --git a/libretroshare/src/services/p3rtt.cc b/libretroshare/src/services/p3rtt.cc index 2fc991227..d7fee261d 100644 --- a/libretroshare/src/services/p3rtt.cc +++ b/libretroshare/src/services/p3rtt.cc @@ -1,28 +1,24 @@ -/* - * libretroshare/src/services p3rtt.cc - * - * Round Trip Time Measurement for RetroShare. - * - * Copyright 2011-2013 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/services: p3rtt.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2011-2013 Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include #include "util/rsdir.h" diff --git a/libretroshare/src/services/p3rtt.h b/libretroshare/src/services/p3rtt.h index 067feca0c..3bc99eacc 100644 --- a/libretroshare/src/services/p3rtt.h +++ b/libretroshare/src/services/p3rtt.h @@ -1,29 +1,24 @@ -/* - * libretroshare/src/services/p3rtt.h - * - * Round Trip Time Measurement for RetroShare. - * - * Copyright 2011-2013 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - +/******************************************************************************* + * libretroshare/src/services: p3rtt.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2011-2013 Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef SERVICE_RSRTT_HEADER #define SERVICE_RSRTT_HEADER diff --git a/libretroshare/src/services/p3service.cc b/libretroshare/src/services/p3service.cc index bb15831d7..a2b7755c8 100644 --- a/libretroshare/src/services/p3service.cc +++ b/libretroshare/src/services/p3service.cc @@ -1,28 +1,24 @@ -/* - * libretroshare/src/services p3service.cc - * - * 3P/PQI network interface for RetroShare. - * - * Copyright 2004-2013 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/services: p3service.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2013 Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "rsitems/itempriorities.h" #include "pqi/pqi.h" diff --git a/libretroshare/src/services/p3service.h b/libretroshare/src/services/p3service.h index daba663c7..4eb66c470 100644 --- a/libretroshare/src/services/p3service.h +++ b/libretroshare/src/services/p3service.h @@ -1,28 +1,24 @@ -/* - * libretroshare/src/services p3service.h - * - * 3P/PQI network interface for RetroShare. - * - * Copyright 2004-2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/services: p3service.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2008 Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef P3_GENERIC_SERVICE_HEADER #define P3_GENERIC_SERVICE_HEADER diff --git a/libretroshare/src/services/p3serviceinfo.cc b/libretroshare/src/services/p3serviceinfo.cc index 0782016a1..f05604021 100644 --- a/libretroshare/src/services/p3serviceinfo.cc +++ b/libretroshare/src/services/p3serviceinfo.cc @@ -1,28 +1,24 @@ -/* - * libretroshare/src/services p3serviceinfo.cc - * - * ServiceInfo Service for RetroShare. - * - * Copyright 2014 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/services: p3serviceinfo.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2014 Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "pqi/p3linkmgr.h" #include "pqi/p3netmgr.h" diff --git a/libretroshare/src/services/p3serviceinfo.h b/libretroshare/src/services/p3serviceinfo.h index 210731af1..2d8f8a8af 100644 --- a/libretroshare/src/services/p3serviceinfo.h +++ b/libretroshare/src/services/p3serviceinfo.h @@ -1,29 +1,24 @@ -/* - * libretroshare/src/services/p3serviceinfo.h - * - * Exchange list of Service Information. - * - * Copyright 2014 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - +/******************************************************************************* + * libretroshare/src/services: p3serviceinfo.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2014 Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef SERVICE_RSSERVICEINFO_HEADER #define SERVICE_RSSERVICEINFO_HEADER diff --git a/libretroshare/src/services/p3statusservice.cc b/libretroshare/src/services/p3statusservice.cc index 54184f4db..7ff736d7b 100644 --- a/libretroshare/src/services/p3statusservice.cc +++ b/libretroshare/src/services/p3statusservice.cc @@ -1,28 +1,24 @@ -/* - * libretroshare/src/services: p3statusservice.cc - * - * RetroShare C++ . - * - * Copyright 2008 by Vinny Do, Chris Evi-Parker. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/services: p3statusservice.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2008 by Vinny Do, Chris Evi-Parker. * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "services/p3statusservice.h" #include "rsitems/rsstatusitems.h" #include "rsserver/p3face.h" diff --git a/libretroshare/src/services/p3statusservice.h b/libretroshare/src/services/p3statusservice.h index c4f730b0d..ac0b70653 100644 --- a/libretroshare/src/services/p3statusservice.h +++ b/libretroshare/src/services/p3statusservice.h @@ -1,31 +1,27 @@ +/******************************************************************************* + * libretroshare/src/services: p3statusservice.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2008 by Vinny Do, Chris Evi-Parker. * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RS_P3_STATUS_INTERFACE_H #define RS_P3_STATUS_INTERFACE_H -/* - * libretroshare/src/services: p3statusService.h - * - * RetroShare C++ - * - * Copyright 2008 by Vinny Do, Chris Evi-Parker. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - #include #include diff --git a/libretroshare/src/services/p3wiki.cc b/libretroshare/src/services/p3wiki.cc index a707596c1..26c33881a 100644 --- a/libretroshare/src/services/p3wiki.cc +++ b/libretroshare/src/services/p3wiki.cc @@ -1,28 +1,24 @@ -/* - * libretroshare/src/services p3wiki.cc - * - * Wiki interface for RetroShare. - * - * Copyright 2012-2012 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/services: p3wiki.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012-2012 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "services/p3wiki.h" #include "retroshare/rsgxsflags.h" #include "rsitems/rswikiitems.h" @@ -538,7 +534,7 @@ void p3Wiki::dummyTick() uint32_t status = RsGenExchange::getTokenService()->requestStatus(mAboutToken); - if (status == RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) + if (status == RsTokenService::COMPLETE) { std::cerr << "p3Wiki::dummyTick() AboutActive, Lines: " << mAboutLines; std::cerr << std::endl; @@ -605,7 +601,7 @@ void p3Wiki::dummyTick() uint32_t status = RsGenExchange::getTokenService()->requestStatus(mImprovToken); - if (status == RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) + if (status == RsTokenService::COMPLETE) { std::cerr << "p3Wiki::dummyTick() ImprovActive, Lines: " << mImprovLines; std::cerr << std::endl; @@ -673,7 +669,7 @@ void p3Wiki::dummyTick() uint32_t status = RsGenExchange::getTokenService()->requestStatus(mMarkdownToken); - if (status == RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) + if (status == RsTokenService::COMPLETE) { std::cerr << "p3Wiki::dummyTick() MarkdownActive, Lines: " << mMarkdownLines; std::cerr << std::endl; diff --git a/libretroshare/src/services/p3wiki.h b/libretroshare/src/services/p3wiki.h index bd53fd6b7..f6f446920 100644 --- a/libretroshare/src/services/p3wiki.h +++ b/libretroshare/src/services/p3wiki.h @@ -1,28 +1,24 @@ -/* - * libretroshare/src/services: p3wikiservice.h - * - * Wiki interface for RetroShare. - * - * Copyright 2012-2012 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/services: p3wiki.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012-2012 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef P3_WIKI_SERVICE_HEADER #define P3_WIKI_SERVICE_HEADER diff --git a/libretroshare/src/services/p3wire.cc b/libretroshare/src/services/p3wire.cc index 7edce4a4d..23d31198f 100644 --- a/libretroshare/src/services/p3wire.cc +++ b/libretroshare/src/services/p3wire.cc @@ -1,28 +1,24 @@ -/* - * libretroshare/src/services p3wire.cc - * - * Wire interface for RetroShare. - * - * Copyright 2012-2012 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/services: p3wire.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012-2012 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "services/p3wire.h" #include "rsitems/rswireitems.h" diff --git a/libretroshare/src/services/p3wire.h b/libretroshare/src/services/p3wire.h index 24c0f26e7..3858d158e 100644 --- a/libretroshare/src/services/p3wire.h +++ b/libretroshare/src/services/p3wire.h @@ -1,28 +1,24 @@ -/* - * libretroshare/src/services: p3wire.h - * - * Wiki interface for RetroShare. - * - * Copyright 2012-2012 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/services: p3wire.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012-2012 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef P3_WIRE_SERVICE_HEADER #define P3_WIRE_SERVICE_HEADER diff --git a/libretroshare/src/tcponudp/bio_tou.h b/libretroshare/src/tcponudp/bio_tou.h index cf02825e1..a82444ccc 100644 --- a/libretroshare/src/tcponudp/bio_tou.h +++ b/libretroshare/src/tcponudp/bio_tou.h @@ -1,27 +1,24 @@ -/* - * "$Id: bio_tou.h,v 1.2 2007-02-18 21:46:50 rmf24 Exp $" - * - * TCP-on-UDP (tou) network interface for RetroShare. - * - * Copyright 2004-2006 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ +/******************************************************************************* + * libretroshare/src/tcponudp: bio_tou.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2006 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef BIO_TCPONUDP_H #define BIO_TCPONUDP_H diff --git a/libretroshare/src/tcponudp/tcppacket.cc b/libretroshare/src/tcponudp/tcppacket.cc index 3351cf168..2da199288 100644 --- a/libretroshare/src/tcponudp/tcppacket.cc +++ b/libretroshare/src/tcponudp/tcppacket.cc @@ -1,31 +1,24 @@ -/* - * "$Id: tcppacket.cc,v 1.3 2007-02-18 21:46:50 rmf24 Exp $" - * - * TCP-on-UDP (tou) network interface for RetroShare. - * - * Copyright 2004-2006 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - - - +/******************************************************************************* + * libretroshare/src/tcponudp: tcppacket.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2006 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "tcppacket.h" /* diff --git a/libretroshare/src/tcponudp/tcppacket.h b/libretroshare/src/tcponudp/tcppacket.h index 3b0fe4371..e87c3e394 100644 --- a/libretroshare/src/tcponudp/tcppacket.h +++ b/libretroshare/src/tcponudp/tcppacket.h @@ -1,30 +1,24 @@ -/* - * "$Id: tcppacket.h,v 1.3 2007-02-18 21:46:50 rmf24 Exp $" - * - * TCP-on-UDP (tou) network interface for RetroShare. - * - * Copyright 2004-2006 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - - +/******************************************************************************* + * libretroshare/src/tcponudp: tcppacket.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2006 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef TOU_TCP_PACKET_H #define TOU_TCP_PACKET_H diff --git a/libretroshare/src/tcponudp/tcpstream.cc b/libretroshare/src/tcponudp/tcpstream.cc index d789def44..5af0f505d 100644 --- a/libretroshare/src/tcponudp/tcpstream.cc +++ b/libretroshare/src/tcponudp/tcpstream.cc @@ -1,29 +1,24 @@ -/* - * "$Id: tcpstream.cc,v 1.11 2007-03-01 01:09:39 rmf24 Exp $" - * - * TCP-on-UDP (tou) network interface for RetroShare. - * - * Copyright 2004-2006 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - +/******************************************************************************* + * libretroshare/src/tcponudp: tcpstream.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2006 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include #include diff --git a/libretroshare/src/tcponudp/tcpstream.h b/libretroshare/src/tcponudp/tcpstream.h index eb79620cd..87ed693d0 100644 --- a/libretroshare/src/tcponudp/tcpstream.h +++ b/libretroshare/src/tcponudp/tcpstream.h @@ -1,30 +1,24 @@ -/* - * "$Id: tcpstream.h,v 1.5 2007-02-18 21:46:50 rmf24 Exp $" - * - * TCP-on-UDP (tou) network interface for RetroShare. - * - * Copyright 2004-2006 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - - +/******************************************************************************* + * libretroshare/src/tcponudp: tcpstream.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2006 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef TOU_TCP_PROTO_H #define TOU_TCP_PROTO_H diff --git a/libretroshare/src/tcponudp/tou.cc b/libretroshare/src/tcponudp/tou.cc index e6fb7f480..4121c6985 100644 --- a/libretroshare/src/tcponudp/tou.cc +++ b/libretroshare/src/tcponudp/tou.cc @@ -1,31 +1,24 @@ -/* - * "$Id: tou.cc,v 1.7 2007-02-18 21:46:50 rmf24 Exp $" - * - * TCP-on-UDP (tou) network interface for RetroShare. - * - * Copyright 2004-2006 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - - - +/******************************************************************************* + * libretroshare/src/tcponudp: tou.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2006 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "tou.h" static const int kInitStreamTable = 5; diff --git a/libretroshare/src/tcponudp/tou.h b/libretroshare/src/tcponudp/tou.h index da72bb85d..0c09ce159 100644 --- a/libretroshare/src/tcponudp/tou.h +++ b/libretroshare/src/tcponudp/tou.h @@ -1,30 +1,24 @@ -/* - * "$Id: tou.h,v 1.4 2007-02-18 21:46:50 rmf24 Exp $" - * - * TCP-on-UDP (tou) network interface for RetroShare. - * - * Copyright 2004-2006 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - - +/******************************************************************************* + * libretroshare/src/tcponudp: tou.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2006 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef TOU_C_HEADER_H #define TOU_C_HEADER_H diff --git a/libretroshare/src/tcponudp/udppeer.cc b/libretroshare/src/tcponudp/udppeer.cc index d7b904c9a..b3cf10913 100644 --- a/libretroshare/src/tcponudp/udppeer.cc +++ b/libretroshare/src/tcponudp/udppeer.cc @@ -1,28 +1,24 @@ -/* - * tcponudp/udppeer.cc - * - * libretroshare. - * - * Copyright 2010 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 3 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/tcponudp: udppeer.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2010-2010 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "udppeer.h" #include diff --git a/libretroshare/src/tcponudp/udppeer.h b/libretroshare/src/tcponudp/udppeer.h index f25d1cffc..9ecf23419 100644 --- a/libretroshare/src/tcponudp/udppeer.h +++ b/libretroshare/src/tcponudp/udppeer.h @@ -1,31 +1,27 @@ +/******************************************************************************* + * libretroshare/src/tcponudp: udppeer.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2010-2010 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RS_UDP_PEER_RECV_H #define RS_UDP_PEER_RECV_H -/* - * tcponudp/udppeer.h - * - * libretroshare. - * - * Copyright 2010 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 3 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - #ifndef WINDOWS_SYS #include #endif diff --git a/libretroshare/src/tcponudp/udprelay.cc b/libretroshare/src/tcponudp/udprelay.cc index 2f837feec..8793eb636 100644 --- a/libretroshare/src/tcponudp/udprelay.cc +++ b/libretroshare/src/tcponudp/udprelay.cc @@ -1,28 +1,24 @@ -/* - * tcponudp/udprelay.cc - * - * libretroshare. - * - * Copyright 2010 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 3 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/tcponudp: udprelay.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2010-2010 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "udprelay.h" #include #include diff --git a/libretroshare/src/tcponudp/udprelay.h b/libretroshare/src/tcponudp/udprelay.h index e04710f2f..fda6958d3 100644 --- a/libretroshare/src/tcponudp/udprelay.h +++ b/libretroshare/src/tcponudp/udprelay.h @@ -1,31 +1,27 @@ +/******************************************************************************* + * libretroshare/src/tcponudp: udprelay.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2010-2010 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RS_UDP_RELAY_H #define RS_UDP_RELAY_H -/* - * tcponudp/udprelay.h - * - * libretroshare. - * - * Copyright 2010 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 3 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - #include "tcponudp/udppeer.h" #include #include diff --git a/libretroshare/src/tcponudp/udpstunner.cc b/libretroshare/src/tcponudp/udpstunner.cc index 421ad8f17..8fd1dfd46 100644 --- a/libretroshare/src/tcponudp/udpstunner.cc +++ b/libretroshare/src/tcponudp/udpstunner.cc @@ -1,28 +1,24 @@ -/* - * tcponudp/udpstunner.cc - * - * libretroshare. - * - * Copyright 2010 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 3 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/tcponudp: udpstunner.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2010-2010 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "tcponudp/udpstunner.h" #include #include diff --git a/libretroshare/src/tcponudp/udpstunner.h b/libretroshare/src/tcponudp/udpstunner.h index 1f55f241b..1abc48d6e 100644 --- a/libretroshare/src/tcponudp/udpstunner.h +++ b/libretroshare/src/tcponudp/udpstunner.h @@ -1,29 +1,26 @@ +/******************************************************************************* + * libretroshare/src/tcponudp: udpstunner.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2010-2010 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RS_UDP_STUN_H #define RS_UDP_STUN_H -/* - * tcponudp/udpstunner.h - * - * libretroshare. - * - * Copyright 2010 by Robert Fernie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 3 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ #ifndef WINDOWS_SYS #include diff --git a/libretroshare/src/turtle/p3turtle.cc b/libretroshare/src/turtle/p3turtle.cc index 8217db2fa..90274d02d 100644 --- a/libretroshare/src/turtle/p3turtle.cc +++ b/libretroshare/src/turtle/p3turtle.cc @@ -1,27 +1,24 @@ -/* - * libretroshare/src/services: p3turtle.cc - * - * Services for RetroShare. - * - * Copyright 2009 by Cyril Soler - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "csoler@users.sourceforge.net". - * - */ +/******************************************************************************* + * libretroshare/src/turtle: p3turtle.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2009-2018 by Cyril Soler * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ //#define P3TURTLE_DEBUG @@ -34,6 +31,7 @@ #endif #include "rsserver/p3face.h" +#include "crypto/rscrypto.h" #include "pqi/authssl.h" #include "pqi/p3linkmgr.h" @@ -63,11 +61,14 @@ static std::map > TS_request_bounces void TS_dumpState() ; #endif +#define TURTLE_DEBUG() std::cerr << time(NULL) << " : TURTLE : " << __FUNCTION__ << " : " +#define TURTLE_ERROR() std::cerr << "(EE) TURTLE ERROR : " + // These number may be quite important. I setup them with sensible values, but // an in-depth test would be better to get an idea of what the ideal values // could ever be. // -// update of 14-03-11: +// update of 14-03-11: // - I raised the cache time for tunnel requests. This avoids inconsistencies such as: // * tunnel requests bouncing back while the original request is not in the cache anymore // * special case of this for own file transfer: an outgoing tunnel is built with no end. @@ -79,17 +80,18 @@ void TS_dumpState() ; // - The total number of TR per second emmited from self will be MAX_TUNNEL_REQS_PER_SECOND / TIME_BETWEEN_TUNNEL_MANAGEMENT_CALLS = 0.5 // - I updated forward probabilities to higher values, and min them to 1/nb_connected_friends to prevent blocking tunnels. // -static const time_t TUNNEL_REQUESTS_LIFE_TIME = 240 ; /// life time for tunnel requests in the cache. -static const time_t SEARCH_REQUESTS_LIFE_TIME = 240 ; /// life time for search requests in the cache -static const time_t REGULAR_TUNNEL_DIGGING_TIME = 300 ; /// maximum interval between two tunnel digging campaigns. -static const time_t MAXIMUM_TUNNEL_IDLE_TIME = 60 ; /// maximum life time of an unused tunnel. -static const time_t EMPTY_TUNNELS_DIGGING_TIME = 50 ; /// look into tunnels regularly every 50 sec. -static const time_t TUNNEL_SPEED_ESTIMATE_LAPSE = 5 ; /// estimate tunnel speed every 5 seconds -static const time_t TUNNEL_CLEANING_LAPS_TIME = 10 ; /// clean tunnels every 10 secs -static const time_t TIME_BETWEEN_TUNNEL_MANAGEMENT_CALLS = 2 ; /// Tunnel management calls every 2 secs. -static const uint32_t MAX_TUNNEL_REQS_PER_SECOND = 1 ; /// maximum number of tunnel requests issued per second. Was 0.5 before -static const uint32_t MAX_ALLOWED_SR_IN_CACHE = 120 ; /// maximum number of search requests allowed in cache. That makes 2 per sec. -static const uint32_t TURTLE_SEARCH_RESULT_MAX_HITS =5000 ; /// maximum number of search results forwarded back to the source. +static const time_t TUNNEL_REQUESTS_LIFE_TIME = 240 ; /// life time for tunnel requests in the cache. +static const time_t SEARCH_REQUESTS_LIFE_TIME = 240 ; /// life time for search requests in the cache +static const time_t REGULAR_TUNNEL_DIGGING_TIME = 300 ; /// maximum interval between two tunnel digging campaigns. +static const time_t MAXIMUM_TUNNEL_IDLE_TIME = 60 ; /// maximum life time of an unused tunnel. +static const time_t EMPTY_TUNNELS_DIGGING_TIME = 50 ; /// look into tunnels regularly every 50 sec. +static const time_t TUNNEL_SPEED_ESTIMATE_LAPSE = 5 ; /// estimate tunnel speed every 5 seconds +static const time_t TUNNEL_CLEANING_LAPS_TIME = 10 ; /// clean tunnels every 10 secs +static const time_t TIME_BETWEEN_TUNNEL_MANAGEMENT_CALLS = 2 ; /// Tunnel management calls every 2 secs. +static const uint32_t MAX_TUNNEL_REQS_PER_SECOND = 1 ; /// maximum number of tunnel requests issued per second. Was 0.5 before +static const uint32_t MAX_ALLOWED_SR_IN_CACHE = 120 ; /// maximum number of search requests allowed in cache. That makes 2 per sec. +static const uint32_t TURTLE_SEARCH_RESULT_MAX_HITS_FILES =5000 ; /// maximum number of search results forwarded back to the source. +static const uint32_t TURTLE_SEARCH_RESULT_MAX_HITS_DEFAULT= 100 ; /// default maximum number of search results forwarded back source. static const float depth_peer_probability[7] = { 1.0f,0.99f,0.9f,0.7f,0.6f,0.5,0.4f } ; @@ -151,13 +153,15 @@ void p3turtle::getItemNames(std::map& names) const { names.clear(); - names[RS_TURTLE_SUBTYPE_STRING_SEARCH_REQUEST ] = "Search request"; - names[RS_TURTLE_SUBTYPE_SEARCH_RESULT ] = "Search result"; + names[RS_TURTLE_SUBTYPE_STRING_SEARCH_REQUEST ] = "Filename substring search request"; + names[RS_TURTLE_SUBTYPE_GENERIC_SEARCH_REQUEST ] = "Generic search request"; + names[RS_TURTLE_SUBTYPE_FT_SEARCH_RESULT ] = "File search result"; + names[RS_TURTLE_SUBTYPE_GENERIC_SEARCH_RESULT ] = "Generic search result"; names[RS_TURTLE_SUBTYPE_OPEN_TUNNEL ] = "Tunnel request"; names[RS_TURTLE_SUBTYPE_TUNNEL_OK ] = "Tunnel response"; names[RS_TURTLE_SUBTYPE_FILE_REQUEST ] = "Data request"; names[RS_TURTLE_SUBTYPE_FILE_DATA ] = "Data chunk"; - names[RS_TURTLE_SUBTYPE_REGEXP_SEARCH_REQUEST ] = "RegExp search"; + names[RS_TURTLE_SUBTYPE_REGEXP_SEARCH_REQUEST ] = "Filename RegExp search request"; names[RS_TURTLE_SUBTYPE_GENERIC_DATA ] = "Generic data"; names[RS_TURTLE_SUBTYPE_FILE_MAP ] = "Chunk map"; names[RS_TURTLE_SUBTYPE_FILE_MAP_REQUEST ] = "Chunk map request"; @@ -165,7 +169,7 @@ void p3turtle::getItemNames(std::map& names) const names[RS_TURTLE_SUBTYPE_CHUNK_CRC_REQUEST ] = "Chunk CRC request"; } -void p3turtle::setEnabled(bool b) +void p3turtle::setEnabled(bool b) { RsStackMutex stack(mTurtleMtx); /********** STACK LOCKED MTX ******/ _turtle_routing_enabled = b; @@ -184,7 +188,7 @@ bool p3turtle::enabled() const } -void p3turtle::setSessionEnabled(bool b) +void p3turtle::setSessionEnabled(bool b) { RsStackMutex stack(mTurtleMtx); /********** STACK LOCKED MTX ******/ _turtle_routing_session_enabled = b; @@ -242,7 +246,7 @@ int p3turtle::tick() RsStackMutex stack(mTurtleMtx); /********** STACK LOCKED MTX ******/ _last_tunnel_management_time = now ; - // Update traffic statistics. The constants are important: they allow a smooth variation of the + // Update traffic statistics. The constants are important: they allow a smooth variation of the // traffic speed, which is used to moderate tunnel requests statistics. // _traffic_info = _traffic_info*0.9 + _traffic_info_buffer* (0.1 / (float)TIME_BETWEEN_TUNNEL_MANAGEMENT_CALLS) ; @@ -370,8 +374,8 @@ void p3turtle::manageTunnels() // - the hash hasn't been tunneled for more than REGULAR_TUNNEL_DIGGING_TIME seconds, even if downloading. // // Candidate hashes are sorted, by olderness. The older gets tunneled first. At most MAX_TUNNEL_REQS_PER_SECOND are - // treated at once, as this method is called every second. - // Note: Because REGULAR_TUNNEL_DIGGING_TIME is larger than EMPTY_TUNNELS_DIGGING_TIME, files being downloaded get + // treated at once, as this method is called every second. + // Note: Because REGULAR_TUNNEL_DIGGING_TIME is larger than EMPTY_TUNNELS_DIGGING_TIME, files being downloaded get // re-tunneled in priority. As this happens less, they don't obliterate tunneling for files that have no tunnels yet. std::vector > hashes_to_digg ; @@ -552,7 +556,7 @@ void p3turtle::autoWash() // Now remove all the virtual peers ids at the client services. Off mutex! // - + for(uint32_t i=0;i::iterator it(_incoming_file_hashes.find(hash)) ; @@ -659,7 +663,7 @@ void p3turtle::locked_closeTunnel(TurtleTunnelId tid,std::vector& load) RsConfigKeyValueSet *vitem = dynamic_cast(*it) ; if(vitem != NULL) - for(std::list::const_iterator kit = vitem->tlvkvs.pairs.begin(); kit != vitem->tlvkvs.pairs.end(); ++kit) + for(std::list::const_iterator kit = vitem->tlvkvs.pairs.begin(); kit != vitem->tlvkvs.pairs.end(); ++kit) { if(kit->key == "TURTLE_CONFIG_MAX_TR_RATE") { @@ -824,7 +828,7 @@ int p3turtle::handleIncoming() RsTurtleGenericTunnelItem *gti = dynamic_cast(item) ; if(gti != NULL) - routeGenericTunnelItem(gti) ; /// Generic packets, that travel through established tunnels. + routeGenericTunnelItem(gti) ; /// Generic packets, that travel through established tunnels. else /// These packets should be destroyed by the client. { /// Special packets that require specific treatment, because tunnels do not exist for these packets. @@ -833,10 +837,12 @@ int p3turtle::handleIncoming() switch(item->PacketSubType()) { case RS_TURTLE_SUBTYPE_STRING_SEARCH_REQUEST: + case RS_TURTLE_SUBTYPE_GENERIC_SEARCH_REQUEST: case RS_TURTLE_SUBTYPE_REGEXP_SEARCH_REQUEST: handleSearchRequest(dynamic_cast(item)) ; break ; - case RS_TURTLE_SUBTYPE_SEARCH_RESULT : handleSearchResult(dynamic_cast(item)) ; + case RS_TURTLE_SUBTYPE_GENERIC_SEARCH_RESULT : + case RS_TURTLE_SUBTYPE_FT_SEARCH_RESULT : handleSearchResult(dynamic_cast(item)) ; break ; case RS_TURTLE_SUBTYPE_OPEN_TUNNEL : handleTunnelRequest(dynamic_cast(item)) ; @@ -862,8 +868,6 @@ int p3turtle::handleIncoming() // void p3turtle::handleSearchRequest(RsTurtleSearchRequestItem *item) { - RsStackMutex stack(mTurtleMtx); /********** STACK LOCKED MTX ******/ - // take a look at the item and test against inconsistent values // - If the item destimation is @@ -871,7 +875,7 @@ void p3turtle::handleSearchRequest(RsTurtleSearchRequestItem *item) std::cerr << "Received search request from peer " << item->PeerId() << ": " << std::endl ; item->print(std::cerr,0) ; #endif - + uint32_t item_size = RsTurtleSerialiser().size(item); if(item_size > TURTLE_MAX_SEARCH_REQ_ACCEPTED_SERIAL_SIZE) @@ -882,27 +886,56 @@ void p3turtle::handleSearchRequest(RsTurtleSearchRequestItem *item) std::cerr << " Caught a turtle search item with arbitrary large size from " << item->PeerId() << " of size " << item_size << " and depth " << item->depth << ". This is not allowed => dropping." << std::endl; return ; } - - if(_search_requests_origins.size() > MAX_ALLOWED_SR_IN_CACHE) + { + RsStackMutex stack(mTurtleMtx); /********** STACK LOCKED MTX ******/ + + if(_search_requests_origins.size() > MAX_ALLOWED_SR_IN_CACHE) + { #ifdef P3TURTLE_DEBUG - std::cerr << " Dropping, because the search request cache is full." << std::endl ; + std::cerr << " Dropping, because the search request cache is full." << std::endl ; #endif - std::cerr << " More than " << MAX_ALLOWED_SR_IN_CACHE << " search request in cache. A peer is probably trying to flood your network See the depth charts to find him." << std::endl; - return ; + std::cerr << " More than " << MAX_ALLOWED_SR_IN_CACHE << " search request in cache. A peer is probably trying to flood your network See the depth charts to find him." << std::endl; + return ; + } + + // If the item contains an already handled search request, give up. This + // happens when the same search request gets relayed by different peers + // + if(_search_requests_origins.find(item->request_id) != _search_requests_origins.end()) + { +#ifdef P3TURTLE_DEBUG + std::cerr << " This is a bouncing request. Ignoring and deleting it." << std::endl ; +#endif + return ; + } } - // If the item contains an already handled search request, give up. This - // happens when the same search request gets relayed by different peers - // - if(_search_requests_origins.find(item->request_id) != _search_requests_origins.end()) + // Perform local search off-mutex,because this might call some services that are above turtle in the mutex chain. + + uint32_t search_result_count = 0; + uint32_t max_allowed_hits = TURTLE_SEARCH_RESULT_MAX_HITS_DEFAULT; + + if(item->PeerId() != _own_id) // is the request not coming from us? { #ifdef P3TURTLE_DEBUG - std::cerr << " This is a bouncing request. Ignoring and deleting it." << std::endl ; + std::cerr << " Request not from us. Performing local search" << std::endl ; #endif - return ; + std::list search_results ; + + performLocalSearch(item,search_result_count,search_results,max_allowed_hits) ; + + for(auto it(search_results.begin());it!=search_results.end();++it) + { + (*it)->request_id = item->request_id ; + (*it)->PeerId(item->PeerId()) ; + + sendItem(*it) ; + } } + RsStackMutex stack(mTurtleMtx); /********** STACK LOCKED MTX ******/ + // This is a new request. Let's add it to the request map, and forward it to // open peers. @@ -910,67 +943,17 @@ void p3turtle::handleSearchRequest(RsTurtleSearchRequestItem *item) req.origin = item->PeerId() ; req.time_stamp = time(NULL) ; req.depth = item->depth ; - req.result_count = 0; + req.result_count = search_result_count; req.keywords = item->GetKeywords() ; - - // If it's not for us, perform a local search. If something found, forward the search result back. - - if(item->PeerId() != _own_id) - { -#ifdef P3TURTLE_DEBUG - std::cerr << " Request not from us. Performing local search" << std::endl ; -#endif - - std::list result ; - - item->performLocalSearch(result) ; - - RsTurtleSearchResultItem *res_item = NULL ; - uint32_t item_size = 0 ; - -#ifdef P3TURTLE_DEBUG - if(!result.empty()) - std::cerr << " " << result.size() << " matches found. Sending back to origin (" << item->PeerId() << ")." << std::endl ; -#endif - while(!result.empty() && req.result_count < TURTLE_SEARCH_RESULT_MAX_HITS) - { - // Let's chop search results items into several chunks of finite size to avoid exceeding streamer's capacity. - // - static const uint32_t RSTURTLE_MAX_SEARCH_RESPONSE_SIZE = 10000 ; - - if(res_item == NULL) - { - res_item = new RsTurtleSearchResultItem ; - item_size = 0 ; - - res_item->depth = 0 ; - res_item->request_id = item->request_id ; - res_item->PeerId(item->PeerId()) ; // send back to the same guy - } - res_item->result.push_back(result.front()) ; - - ++req.result_count ; // increase hit number for this particular search request. - - item_size += 8 /* size */ + result.front().hash.serial_size() + result.front().name.size() ; - result.pop_front() ; - - if(item_size > RSTURTLE_MAX_SEARCH_RESPONSE_SIZE || result.empty() || req.result_count >= TURTLE_SEARCH_RESULT_MAX_HITS) - { -#ifdef P3TURTLE_DEBUG - std::cerr << " Sending back chunk of size " << item_size << ", for " << res_item->result.size() << " elements." << std::endl ; -#endif - sendItem(res_item) ; - res_item = NULL ; - } - } - } + req.service_id = item->serviceId() ; + req.max_allowed_hits = max_allowed_hits; // if enough has been sent back already, do not sarch further #ifdef P3TURTLE_DEBUG std::cerr << " result count = " << req.result_count << std::endl; #endif - if(req.result_count >= TURTLE_SEARCH_RESULT_MAX_HITS) + if(req.result_count >= max_allowed_hits) return ; // If search depth not too large, also forward this search request to all other peers. @@ -1007,14 +990,14 @@ void p3turtle::handleSearchRequest(RsTurtleSearchRequestItem *item) // Copy current item and modify it. RsTurtleSearchRequestItem *fwd_item = item->clone() ; - // increase search depth, except in some rare cases, to prevent correlation between + // increase search depth, except in some rare cases, to prevent correlation between // TR sniffing and friend names. The strategy is to not increase depth if the depth // is 1: // If B receives a TR of depth 1 from A, B cannot deduice that A is downloading the // file, since A might have shifted the depth. // if(!random_dshift) - ++(fwd_item->depth) ; + ++(fwd_item->depth) ; fwd_item->PeerId(*it) ; @@ -1028,67 +1011,223 @@ void p3turtle::handleSearchRequest(RsTurtleSearchRequestItem *item) #endif } +// This function should be removed in the future, when file search will also use generic search items. + +void p3turtle::performLocalSearch(RsTurtleSearchRequestItem *item,uint32_t& req_result_count,std::list& search_results,uint32_t& max_allowed_hits) +{ + RsTurtleFileSearchRequestItem *ftsearch = dynamic_cast(item) ; + + if(ftsearch != NULL) + { + performLocalSearch_files(ftsearch,req_result_count,search_results,max_allowed_hits) ; + return ; + } + + RsTurtleGenericSearchRequestItem *gnsearch = dynamic_cast(item) ; + + if(gnsearch != NULL) + { + performLocalSearch_generic(gnsearch,req_result_count,search_results,max_allowed_hits) ; + return ; + } +} + +void p3turtle::performLocalSearch_generic(RsTurtleGenericSearchRequestItem *item, uint32_t& req_result_count, std::list& result,uint32_t& max_allowed_hits) +{ + unsigned char *search_result_data = NULL ; + uint32_t search_result_data_len = 0 ; + + RsTurtleClientService *client = NULL ; + + { + RsStackMutex stack(mTurtleMtx); /********** STACK LOCKED MTX ******/ + auto it = _registered_services.find(item->service_id) ; + + if(it == _registered_services.end()) + return ; + + client = it->second ; + } + + if(client->receiveSearchRequest(item->search_data,item->search_data_len,search_result_data,search_result_data_len,max_allowed_hits)) + { + RsTurtleGenericSearchResultItem *result_item = new RsTurtleGenericSearchResultItem ; + + result_item->result_data = search_result_data ; + result_item->result_data_len = search_result_data_len ; + + result.push_back(result_item) ; + } +} + +void p3turtle::performLocalSearch_files(RsTurtleFileSearchRequestItem *item,uint32_t& req_result_count,std::list& result,uint32_t& max_allowed_hits) +{ +#ifdef P3TURTLE_DEBUG + std::cerr << "Performing rsFiles->search()" << std::endl ; +#endif + // now, search! + std::list initialResults ; + item->search(initialResults) ; + +#ifdef P3TURTLE_DEBUG + std::cerr << initialResults.size() << " matches found." << std::endl ; +#endif + result.clear() ; + RsTurtleFTSearchResultItem *res_item = NULL ; + uint32_t item_size = 0 ; + + static const uint32_t RSTURTLE_MAX_SEARCH_RESPONSE_SIZE = 10000 ; + max_allowed_hits = TURTLE_SEARCH_RESULT_MAX_HITS_FILES; + + for(auto it(initialResults.begin());it!=initialResults.end();++it) + { + if(res_item == NULL) + { + res_item = new RsTurtleFTSearchResultItem ; + item_size = 0 ; + + result.push_back(res_item) ; + } + res_item->result.push_back(*it); + + // Let's chop search results items into several chunks of finite size to avoid exceeding streamer's capacity. + // + ++req_result_count ; // increase hit number for this particular search request. + + item_size += 8 /* size */ + it->hash.serial_size() + it->name.size() ; + + if(item_size > RSTURTLE_MAX_SEARCH_RESPONSE_SIZE || req_result_count >= max_allowed_hits) + { +#ifdef P3TURTLE_DEBUG + std::cerr << " Sending back chunk of size " << item_size << ", for " << res_item->result.size() << " elements." << std::endl ; +#endif + res_item = NULL ; // forces creation of a new item. + } + } +} + void p3turtle::handleSearchResult(RsTurtleSearchResultItem *item) { - RsStackMutex stack(mTurtleMtx); /********** STACK LOCKED MTX ******/ - // Find who actually sent the corresponding request. - // - std::map::iterator it = _search_requests_origins.find(item->request_id) ; -#ifdef P3TURTLE_DEBUG - std::cerr << "Received search result:" << std::endl ; - item->print(std::cerr,0) ; -#endif - if(it == _search_requests_origins.end()) + // Filter out banned hashes from the result. + + RsTurtleFTSearchResultItem *ftsr_tmp = dynamic_cast(item) ; + + if(ftsr_tmp != NULL) + { + for(auto it(ftsr_tmp->result.begin());it!=ftsr_tmp->result.end();) + if( rsFiles->isHashBanned((*it).hash) ) + { + std::cerr << "(II) filtering out banned hash " << (*it).hash << " from turtle result " << std::hex << item->request_id << std::dec << std::endl; + it = ftsr_tmp->result.erase(it); + } + else + ++it; + + if(ftsr_tmp->result.empty()) + return ; + } + + // Then handle the result + + std::list > results_to_notify_off_mutex ; + { - // This is an error: how could we receive a search result corresponding to a search item we - // have forwarded but that it not in the list ?? + RS_STACK_MUTEX(mTurtleMtx); + // Find who actually sent the corresponding request. + // + std::map::iterator it = _search_requests_origins.find(item->request_id) ; - std::cerr << __PRETTY_FUNCTION__ << ": search result has no peer direction!" << std::endl ; - return ; - } - - // Is this result's target actually ours ? - - if(it->second.origin == _own_id) - { - it->second.result_count += item->result.size() ; - returnSearchResult(item) ; // Yes, so send upward. - } - else - { // Nope, so forward it back. #ifdef P3TURTLE_DEBUG - std::cerr << " Forwarding result back to " << it->second.origin << std::endl; + std::cerr << "Received search result:" << std::endl ; + item->print(std::cerr,0) ; #endif - // We update the total count forwarded back, and chop it to TURTLE_SEARCH_RESULT_MAX_HITS. - - uint32_t n = item->result.size(); // not so good! - - if(it->second.result_count >= TURTLE_SEARCH_RESULT_MAX_HITS) + if(it == _search_requests_origins.end()) { - std::cerr << "(WW) exceeded turtle search result to forward. Req=" << std::hex << item->request_id << std::dec << ": dropping item with " << n << " elements." << std::endl; + // This is an error: how could we receive a search result corresponding to a search item we + // have forwarded but that it not in the list ?? + + std::cerr << __PRETTY_FUNCTION__ << ": search result for request " << std::hex << item->request_id << std::dec << " has no peer direction!" << std::endl ; return ; } - if(it->second.result_count + n > TURTLE_SEARCH_RESULT_MAX_HITS) - { - for(uint32_t i=it->second.result_count + n; i>TURTLE_SEARCH_RESULT_MAX_HITS;--i) - item->result.pop_back() ; + // Is this result's target actually ours ? - it->second.result_count = TURTLE_SEARCH_RESULT_MAX_HITS ; + if(it->second.origin == _own_id) + { + it->second.result_count += item->count() ; + + auto it2 = _registered_services.find(it->second.service_id) ; + + if(it2 != _registered_services.end()) + results_to_notify_off_mutex.push_back(std::make_pair(item,it2->second)) ; + else + std::cerr << "(EE) cannot find client service for ID " << std::hex << it->second.service_id << std::dec << ": search result item will be dropped." << std::endl; } else - it->second.result_count += n ; + { // Nope, so forward it back. +#ifdef P3TURTLE_DEBUG + std::cerr << " Forwarding result back to " << it->second.origin << std::endl; +#endif + // We update the total count forwarded back, and chop it to TURTLE_SEARCH_RESULT_MAX_HITS. - RsTurtleSearchResultItem *fwd_item = new RsTurtleSearchResultItem(*item) ; // copy the item + uint32_t n = item->count(); // not so good! - // Normally here, we should setup the forward adress, so that the owner's - // of the files found can be further reached by a tunnel. + if(it->second.result_count >= it->second.max_allowed_hits) + { + std::cerr << "(WW) exceeded turtle search result to forward. Req=" << std::hex << item->request_id << std::dec << ": dropping item with " << n << " elements." << std::endl; + return ; + } - fwd_item->PeerId(it->second.origin) ; - fwd_item->depth = 0 ; // obfuscate the depth for non immediate friends. Result will always be 0. This effectively removes the information. + if(it->second.result_count + n > it->second.max_allowed_hits) + { + for(uint32_t i=it->second.result_count + n; i>it->second.max_allowed_hits;--i) + item->pop() ; - sendItem(fwd_item) ; - } + it->second.result_count = it->second.max_allowed_hits ; + } + else + it->second.result_count += n ; + + RsTurtleSearchResultItem *fwd_item = item->duplicate(); + + // Normally here, we should setup the forward adress, so that the owner's + // of the files found can be further reached by a tunnel. + + fwd_item->PeerId(it->second.origin) ; + + sendItem(fwd_item) ; + } + } // mTurtleMtx end + + // now we notify clients off-mutex. + + for(auto it(results_to_notify_off_mutex.begin());it!=results_to_notify_off_mutex.end();++it) + { + // Hack to use the old search result handling in ftServer. Normally ftServer should use the new method with serialized result. + +#warning make sure memory is correctly deleted here + RsTurtleFTSearchResultItem *ftsr = dynamic_cast(it->first) ; + + if(ftsr!=NULL) + { + ftServer *client = dynamic_cast((*it).second) ; + + if(!client) + { + std::cerr << "(EE) received turtle FT search result but the service is not a ftServer!!" << std::endl; + continue; + } + //RsServer::notify()->notifyTurtleSearchResult(ftsr->request_id,ftsr->result) ; + + client->receiveSearchResult(ftsr); + continue ; + } + + RsTurtleGenericSearchResultItem *gnsr = dynamic_cast(it->first) ; + + if(gnsr!=NULL) + (*it).second->receiveSearchResult(gnsr->request_id,gnsr->result_data,gnsr->result_data_len) ; + } } // -----------------------------------------------------------------------------------// @@ -1150,8 +1289,8 @@ void p3turtle::routeGenericTunnelItem(RsTurtleGenericTunnelItem *item) // Let's figure out whether this packet is for us or not. - if(item->PeerId() == tunnel.local_dst && tunnel.local_src != _own_id) //direction == RsTurtleGenericTunnelItem::DIRECTION_CLIENT && - { + if(item->PeerId() == tunnel.local_dst && tunnel.local_src != _own_id) //direction == RsTurtleGenericTunnelItem::DIRECTION_CLIENT && + { #ifdef P3TURTLE_DEBUG std::cerr << " Forwarding generic item to peer " << tunnel.local_src << std::endl ; #endif @@ -1189,7 +1328,7 @@ void p3turtle::routeGenericTunnelItem(RsTurtleGenericTunnelItem *item) // The packet was not forwarded, so it is for us. Let's treat it. // This is done off-mutex, to avoid various deadlocks // - + handleRecvGenericTunnelItem(item) ; delete item ; @@ -1312,13 +1451,13 @@ void p3turtle::sendTurtleData(const RsPeerId& virtual_peer_id,RsTurtleGenericTun if(tunnel.local_src == _own_id) { - item->setTravelingDirection(RsTurtleGenericTunnelItem::DIRECTION_SERVER) ; + item->setTravelingDirection(RsTurtleGenericTunnelItem::DIRECTION_SERVER) ; item->PeerId(tunnel.local_dst) ; _traffic_info_buffer.data_dn_Bps += ss ; } else if(tunnel.local_dst == _own_id) { - item->setTravelingDirection(RsTurtleGenericTunnelItem::DIRECTION_CLIENT) ; + item->setTravelingDirection(RsTurtleGenericTunnelItem::DIRECTION_CLIENT) ; item->PeerId(tunnel.local_src) ; _traffic_info_buffer.data_up_Bps += ss ; } @@ -1414,6 +1553,14 @@ void p3turtle::handleTunnelRequest(RsTurtleOpenTunnelItem *item) item->print(std::cerr,0) ; #endif + // check first if the hash is in the ban list. If so, drop the request. + + if(rsFiles->isHashBanned(item->file_hash)) + { + std::cerr << "(II) Rejecting tunnel request to ban hash " << item->file_hash << std::endl; + return ; + } + #ifdef TUNNEL_STATISTICS if(TS_request_bounces.find(item->request_id) != TS_request_bounces.end()) TS_request_bounces[item->request_id].push_back(time(NULL)) ; @@ -1456,7 +1603,7 @@ void p3turtle::handleTunnelRequest(RsTurtleOpenTunnelItem *item) RsStackMutex stack(mTurtleMtx); /********** STACK LOCKED MTX ******/ std::map::iterator it = _tunnel_requests_origins.find(item->request_id) ; - + if(it != _tunnel_requests_origins.end()) { #ifdef P3TURTLE_DEBUG @@ -1497,8 +1644,6 @@ void p3turtle::handleTunnelRequest(RsTurtleOpenTunnelItem *item) } { - RsStackMutex stack(mTurtleMtx); /********** STACK LOCKED MTX ******/ - if(found) { #ifdef P3TURTLE_DEBUG @@ -1507,37 +1652,44 @@ void p3turtle::handleTunnelRequest(RsTurtleOpenTunnelItem *item) // Send back tunnel ok to the same guy // RsTurtleTunnelOkItem *res_item = new RsTurtleTunnelOkItem ; + TurtleVirtualPeerId vpid ; res_item->request_id = item->request_id ; - res_item->tunnel_id = item->partial_tunnel_id ^ generatePersonalFilePrint(item->file_hash,_random_bias,false) ; - res_item->PeerId(item->PeerId()) ; + { + RsStackMutex stack(mTurtleMtx); /********** STACK LOCKED MTX ******/ + res_item->tunnel_id = item->partial_tunnel_id ^ generatePersonalFilePrint(item->file_hash,_random_bias,false) ; - TurtleTunnelId t_id = res_item->tunnel_id ; // save it because sendItem deletes the item + res_item->PeerId(item->PeerId()) ; - sendItem(res_item) ; + TurtleTunnelId t_id = res_item->tunnel_id ; // save it because sendItem deletes the item - // Note in the tunnels list that we have an ending tunnel here. - TurtleTunnel tt ; - tt.local_src = item->PeerId() ; - tt.hash = item->file_hash ; - tt.local_dst = _own_id ; // this means us - tt.time_stamp = time(NULL) ; - tt.transfered_bytes = 0 ; - tt.speed_Bps = 0.0f ; + sendItem(res_item) ; - _local_tunnels[t_id] = tt ; + // Note in the tunnels list that we have an ending tunnel here. + TurtleTunnel tt ; + tt.local_src = item->PeerId() ; + tt.hash = item->file_hash ; + tt.local_dst = _own_id ; // this means us + tt.time_stamp = time(NULL) ; + tt.transfered_bytes = 0 ; + tt.speed_Bps = 0.0f ; - // We add a virtual peer for that tunnel+hash combination. - // - locked_addDistantPeer(item->file_hash,t_id) ; + _local_tunnels[t_id] = tt ; - // Store some info string about the tunnel. - // - _outgoing_tunnel_client_services[t_id] = service ; + // We add a virtual peer for that tunnel+hash combination. + // + locked_addDistantPeer(item->file_hash,t_id) ; + + // Store some info string about the tunnel. + // + _outgoing_tunnel_client_services[t_id] = service ; + + vpid = _local_tunnels[t_id].vpid; + } // Notify the client service that there's a new virtual peer id available as a client. // - service->addVirtualPeer(item->file_hash,_local_tunnels[t_id].vpid,RsTurtleGenericTunnelItem::DIRECTION_CLIENT) ; + service->addVirtualPeer(item->file_hash,vpid,RsTurtleGenericTunnelItem::DIRECTION_CLIENT) ; // We return straight, because when something is found, there's no need to digg a tunnel further. // @@ -1559,7 +1711,7 @@ void p3turtle::handleTunnelRequest(RsTurtleOpenTunnelItem *item) // - the tunnel id will now be unique for a given route // - allows a better balance of bandwidth for a given transfer // - avoid the waste of items that get lost when re-routing a tunnel - + #ifdef P3TURTLE_DEBUG std::cerr << "Perturbating partial tunnel id. Original=" << std::hex << item->partial_tunnel_id ; #endif @@ -1590,7 +1742,7 @@ void p3turtle::handleTunnelRequest(RsTurtleOpenTunnelItem *item) forward_probability = 1.0f / nb_online_ids ; // Setting forward_probability to 1/nb_online_ids forces at most one TR up per TR dn. But if we are overflooded by - // TR dn, we still need to control them to avoid flooding the pqiHandler outqueue. So we additionally moderate the + // TR dn, we still need to control them to avoid flooding the pqiHandler outqueue. So we additionally moderate the // forward probability so as to reduct the output rate accordingly. // if(_traffic_info.tr_dn_Bps / (float)TUNNEL_REQUEST_PACKET_SIZE > _max_tr_up_rate) @@ -1616,7 +1768,7 @@ void p3turtle::handleTunnelRequest(RsTurtleOpenTunnelItem *item) // Copy current item and modify it. RsTurtleOpenTunnelItem *fwd_item = new RsTurtleOpenTunnelItem(*item) ; - // increase search depth, except in some rare cases, to prevent correlation between + // increase search depth, except in some rare cases, to prevent correlation between // TR sniffing and friend names. The strategy is to not increase depth if the depth // is 1: // If B receives a TR of depth 1 from A, B cannot deduice that A is downloading the @@ -1773,7 +1925,9 @@ void p3turtle::handleTunnelResult(RsTurtleTunnelOkItem *item) // ------------------------------ IO with libretroshare ----------------------------// // -----------------------------------------------------------------------------------// // -void RsTurtleStringSearchRequestItem::performLocalSearch(std::list& result) const + + +void RsTurtleStringSearchRequestItem::search(std::list& result) const { /* call to core */ std::list initialResults; @@ -1796,7 +1950,7 @@ void RsTurtleStringSearchRequestItem::performLocalSearch(std::list::const_iterator it(initialResults.begin());it!=initialResults.end();++it) { // retain only file type - if (it->type == DIR_TYPE_DIR) + if (it->type == DIR_TYPE_DIR) { #ifdef P3TURTLE_DEBUG std::cerr << " Skipping directory " << it->name << std::endl ; @@ -1812,7 +1966,7 @@ void RsTurtleStringSearchRequestItem::performLocalSearch(std::list& result) const +void RsTurtleRegExpSearchRequestItem::search(std::list& result) const { /* call to core */ std::list initialResults; @@ -1835,7 +1989,7 @@ void RsTurtleRegExpSearchRequestItem::performLocalSearch(std::list::const_iterator it(initialResults.begin());it!=initialResults.end();++it) { // retain only file type - if (it->type == DIR_TYPE_DIR) + if (it->type == DIR_TYPE_DIR) { #ifdef P3TURTLE_DEBUG std::cerr << " Skipping directory " << it->name << std::endl ; @@ -1907,6 +2061,34 @@ TurtleRequestId p3turtle::turtleSearch(const RsRegularExpression::LinearizedExpr return id ; } +TurtleRequestId p3turtle::turtleSearch(unsigned char *search_bin_data,uint32_t search_bin_data_len,RsTurtleClientService *client_service) +{ + // generate a new search id. + + TurtleRequestId id = generateRandomRequestId() ; + + // Form a request packet that simulates a request from us. + // + RsTurtleGenericSearchRequestItem item ; + +#ifdef P3TURTLE_DEBUG + std::cerr << "performing search. OwnId = " << _own_id << std::endl ; +#endif + + item.PeerId(_own_id) ; + item.service_id = client_service->serviceId(); + item.search_data = search_bin_data ; + item.search_data_len = search_bin_data_len ; + item.request_id = id ; + item.depth = 0 ; + + // send it + + handleSearchRequest(&item) ; + + return id ; +} + void p3turtle::monitorTunnels(const RsFileHash& hash,RsTurtleClientService *client_service,bool allow_multi_tunnels) { { @@ -1947,29 +2129,49 @@ void p3turtle::monitorTunnels(const RsFileHash& hash,RsTurtleClientService *clie IndicateConfigChanged() ; // initiates saving of handled hashes. } -void p3turtle::returnSearchResult(RsTurtleSearchResultItem *item) -{ - // just cout for now, but it should be notified to the gui - #ifdef P3TURTLE_DEBUG std::cerr << " Returning result for search request " << HEX_PRINT(item->request_id) << " upwards." << std::endl ; #endif - RsServer::notify()->notifyTurtleSearchResult(item->request_id,item->result) ; -} + +// RsTurtleGxsSearchResultGroupSummaryItem *gxs_sr_gs = dynamic_cast(item) ; +// +// if(gxs_sr_gs != NULL) +// { +// RsServer::notify()->notifyTurtleSearchResult(gxs_sr_gs->request_id,gxs_sr_gs->result) ; +// return ; +// } +// RsTurtleGxsSearchResultGroupDataItem *gxs_sr_gd = dynamic_cast(item) ; +// +// if(gxs_sr_gd != NULL) +// { +//#warning MISSING CODE HERE TO HANDLE ENCRYPTED INCOMING GROUP DATA. +// //RsServer::notify()->notifyTurtleSearchResult(gxs_sr_gd->request_id,gxs_sr_gd->encrypted_nxs_group) ; +// return ; +// } /// Warning: this function should never be called while the turtle mutex is locked. /// Otherwize this is a possible source of cross-lock with the File mutex. // bool p3turtle::performLocalHashSearch(const TurtleFileHash& hash,const RsPeerId& peer_id,RsTurtleClientService *& service) { - if(_registered_services.empty()) - std::cerr << "Turtle router has no services registered. Tunnel requests cannot be handled." << std::endl; + std::map client_map ; + { + RsStackMutex stack(mTurtleMtx); /********** STACK LOCKED MTX ******/ - for(std::list::const_iterator it(_registered_services.begin());it!=_registered_services.end();++it) - if( (*it)->handleTunnelRequest(hash,peer_id)) + if(_registered_services.empty()) + { + std::cerr << "Turtle router has no services registered. Tunnel requests cannot be handled." << std::endl; + return false ; + } + + client_map = _registered_services ; + } + + for(auto it(client_map.begin());it!=client_map.end();++it) + if( (*it).second->handleTunnelRequest(hash,peer_id)) { - service = *it ; + service = it->second ; return true ; } @@ -1979,14 +2181,9 @@ bool p3turtle::performLocalHashSearch(const TurtleFileHash& hash,const RsPeerId& void p3turtle::registerTunnelService(RsTurtleClientService *service) { -#ifdef P3TURTLE_DEBUG - for(std::list::const_iterator it(_registered_services.begin());it!=_registered_services.end();++it) - if(service == *it) - throw std::runtime_error("p3turtle::registerTunnelService(): Cannot register the same service twice. Please fix the code!") ; -#endif - std::cerr << "p3turtle: registered new tunnel service " << (void*)service << std::endl; + std::cerr << "p3turtle: registered new tunnel service with ID=" << std::hex << service->serviceId() << std::dec << " and pointer " << (void*)service << std::endl; - _registered_services.push_back(service) ; + _registered_services[service->serviceId()] = service ; _serialiser->registerClientService(service) ; } @@ -2068,7 +2265,7 @@ std::string p3turtle::getPeerNameForVirtualPeerId(const RsPeerId& virtual_peer_i std::map::const_iterator it(_virtual_peers.find(virtual_peer_id)) ; if(it != _virtual_peers.end()) { - std::map::iterator it2( _local_tunnels.find(it->second) ) ; + std::map::iterator it2( _local_tunnels.find(it->second) ) ; if(it2 != _local_tunnels.end()) { if(it2->second.local_src == _own_id) @@ -2080,6 +2277,28 @@ std::string p3turtle::getPeerNameForVirtualPeerId(const RsPeerId& virtual_peer_i return name; } +bool p3turtle::encryptData(const unsigned char *clear_data,uint32_t clear_data_size,uint8_t *encryption_master_key,RsTurtleGenericDataItem *& encrypted_item) +{ + unsigned char *encrypted_data = NULL ; + uint32_t encrypted_data_len = 0 ; + + if(!librs::crypto::encryptAuthenticateData(clear_data,clear_data_size,encryption_master_key,encrypted_data,encrypted_data_len)) + { + delete encrypted_item ; + return false ; + } + encrypted_item = new RsTurtleGenericDataItem ; + + encrypted_item->data_bytes = encrypted_data ; + encrypted_item->data_size = encrypted_data_len ; + return true; +} + +bool p3turtle::decryptItem(const RsTurtleGenericDataItem* encrypted_item, uint8_t *encryption_master_key, unsigned char *& decrypted_data, uint32_t& decrypted_data_size) +{ + return librs::crypto::decryptAuthenticateData((unsigned char*)encrypted_item->data_bytes,encrypted_item->data_size,encryption_master_key,decrypted_data,decrypted_data_size); +} + void p3turtle::getInfo( std::vector >& hashes_info, std::vector >& tunnels_info, std::vector& search_reqs_info, @@ -2114,12 +2333,12 @@ void p3turtle::getInfo( std::vector >& hashes_info, tunnel.push_back(printNumber(it->first,true)) ; std::string name; - if(mLinkMgr->getPeerName(it->second.local_src,name)) + if(mLinkMgr->getPeerName(it->second.local_src,name)) tunnel.push_back(name) ; else tunnel.push_back(it->second.local_src.toStdString()) ; - if(mLinkMgr->getPeerName(it->second.local_dst,name)) + if(mLinkMgr->getPeerName(it->second.local_dst,name)) tunnel.push_back(name) ; else tunnel.push_back(it->second.local_dst.toStdString()); diff --git a/libretroshare/src/turtle/p3turtle.h b/libretroshare/src/turtle/p3turtle.h index 0c230b88b..95e48025b 100644 --- a/libretroshare/src/turtle/p3turtle.h +++ b/libretroshare/src/turtle/p3turtle.h @@ -1,27 +1,24 @@ -/* - * libretroshare/src/services: p3turtle.h - * - * Services for RetroShare. - * - * Copyright 2009 by Cyril Soler - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "csoler@users.sourceforge.net". - * - */ +/******************************************************************************* + * libretroshare/src/turtle: p3turtle.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2009-2018 by Cyril Soler * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ //====================================== General setup of the router ===================================// // @@ -169,10 +166,12 @@ class TurtleSearchRequestInfo { public: TurtlePeerId origin ; // where the request came from. - uint32_t time_stamp ; // last time the tunnel was actually used. Used for cleaning old tunnels. - int depth ; // depth of the request. Used to optimize tunnel length. - uint32_t result_count; // responses to this request. Useful to avoid spamming tunnel responses. - std::string keywords; + uint32_t time_stamp ; // last time the tunnel was actually used. Used for cleaning old tunnels. + int depth ; // depth of the request. Used to optimize tunnel length. + uint32_t result_count; // responses to this request. Useful to avoid spamming tunnel responses. + std::string keywords; + uint16_t service_id; // ID of the client service who issues the request. This is null if the request does not have a local origin. + uint32_t max_allowed_hits;// Max number of hits allowed for this search. This actually depends on the type of search (files, GXS groups, GXS group data, etc) }; class TurtleTunnelRequestInfo { @@ -244,11 +243,16 @@ class p3turtle: public p3Service, public RsTurtle, public p3Config // the request id, which will be further used by the gui to store results // as they come back. // - // Eventually, search requests should be handled by client services. We will therefore - // remove the specific file search packets from the turtle router. - // - virtual TurtleSearchRequestId turtleSearch(const std::string& string_to_match) ; - virtual TurtleSearchRequestId turtleSearch(const RsRegularExpression::LinearizedExpression& expr) ; + // The first two methods are old style search requests for FT, while the 3rd one is using a generic search data type, that is only to + // be deserialized by the service. The memory ownership is kept by the calling function. Similarly, the search response will be a + // generic data type that is to be deserialized by the client service. + // + // Eventually, search requests will use the generic system + // even for FT. We need to keep the old method for a while for backward compatibility. + // + virtual TurtleRequestId turtleSearch(const RsRegularExpression::LinearizedExpression& expr) ; + virtual TurtleRequestId turtleSearch(const std::string& string_to_match) ; + virtual TurtleRequestId turtleSearch(unsigned char *search_bin_data,uint32_t search_bin_data_len,RsTurtleClientService *client_service) ; // Initiates tunnel handling for the given file hash. tunnels. Launches // an exception if an error occurs during the initialization process. The @@ -332,6 +336,12 @@ class p3turtle: public p3Service, public RsTurtle, public p3Config /// Send a data request into the correct tunnel for the given file hash void sendTurtleData(const RsPeerId& virtual_peer_id, RsTurtleGenericTunnelItem *item) ; + /// Encrypts/decrypts an item, using a autenticated construction + chacha20, based on the given 32 bytes master key. + /// Input values are not touched (memory is not released). Memory ownership of outputs is left to the client. + /// + static bool encryptData(const unsigned char *clear_data,uint32_t clear_data_size,uint8_t *encryption_master_key,RsTurtleGenericDataItem *& encrypted_item); + static bool decryptItem(const RsTurtleGenericDataItem *item, uint8_t* encryption_master_key, unsigned char *& decrypted_data,uint32_t& decrypted_data_size); + private: //--------------------------- Admin/Helper functions -------------------------// @@ -385,10 +395,9 @@ class p3turtle: public p3Service, public RsTurtle, public p3Config //------ Functions connecting the turtle router to other components.----------// /// Performs a search calling local cache and search structure. - void performLocalSearch(const std::string& match_string,std::list& result) ; - - /// Returns a search result upwards (possibly to the gui) - void returnSearchResult(RsTurtleSearchResultItem *item) ; + void performLocalSearch (RsTurtleSearchRequestItem *item, uint32_t& req_result_count,std::list& result,uint32_t& max_allowed_hits) ; + void performLocalSearch_files (RsTurtleFileSearchRequestItem *item, uint32_t& req_result_count, std::list& result, uint32_t &max_allowed_hits) ; + void performLocalSearch_generic(RsTurtleGenericSearchRequestItem *item, uint32_t& req_result_count, std::list& result, uint32_t &max_allowed_hits) ; /// Returns true if the file with given hash is hosted locally, and accessible in anonymous mode the supplied peer. virtual bool performLocalHashSearch(const TurtleFileHash& hash,const RsPeerId& client_peer_id,RsTurtleClientService *& service); @@ -410,7 +419,7 @@ class p3turtle: public p3Service, public RsTurtle, public p3Config std::map _tunnel_requests_origins ; /// stores adequate tunnels for each file hash locally managed - std::map _incoming_file_hashes ; + std::map _incoming_file_hashes ; /// stores file info for each file we provide. std::map _outgoing_tunnel_client_services ; @@ -425,7 +434,7 @@ class p3turtle: public p3Service, public RsTurtle, public p3Config std::set _hashes_to_remove ; /// List of client services that have regitered. - std::list _registered_services ; + std::map _registered_services ; time_t _last_clean_time ; time_t _last_tunnel_management_time ; diff --git a/libretroshare/src/turtle/rsturtleitem.cc b/libretroshare/src/turtle/rsturtleitem.cc index cf206a153..6e3feee52 100644 --- a/libretroshare/src/turtle/rsturtleitem.cc +++ b/libretroshare/src/turtle/rsturtleitem.cc @@ -1,3 +1,24 @@ +/******************************************************************************* + * libretroshare/src/turtle: rsturtleitem.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2009-2018 by Cyril Soler * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef WINDOWS_SYS #include #endif @@ -28,10 +49,12 @@ RsItem *RsTurtleSerialiser::create_item(uint16_t service,uint8_t item_subtype) c { case RS_TURTLE_SUBTYPE_STRING_SEARCH_REQUEST : return new RsTurtleStringSearchRequestItem(); case RS_TURTLE_SUBTYPE_REGEXP_SEARCH_REQUEST : return new RsTurtleRegExpSearchRequestItem(); - case RS_TURTLE_SUBTYPE_SEARCH_RESULT : return new RsTurtleSearchResultItem(); + case RS_TURTLE_SUBTYPE_FT_SEARCH_RESULT : return new RsTurtleFTSearchResultItem(); case RS_TURTLE_SUBTYPE_OPEN_TUNNEL : return new RsTurtleOpenTunnelItem(); case RS_TURTLE_SUBTYPE_TUNNEL_OK : return new RsTurtleTunnelOkItem(); case RS_TURTLE_SUBTYPE_GENERIC_DATA : return new RsTurtleGenericDataItem(); + case RS_TURTLE_SUBTYPE_GENERIC_SEARCH_REQUEST : return new RsTurtleGenericSearchRequestItem(); + case RS_TURTLE_SUBTYPE_GENERIC_SEARCH_RESULT : return new RsTurtleGenericSearchResultItem(); default: break ; @@ -48,20 +71,44 @@ RsItem *RsTurtleSerialiser::create_item(uint16_t service,uint8_t item_subtype) c return NULL ; } +std::string RsTurtleGenericSearchRequestItem::GetKeywords() +{ + return std::string("Generic search : " + RsUtil::BinToHex(search_data,search_data_len,10)); +} + void RsTurtleStringSearchRequestItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx) { RsTypeSerializer::serial_process (j,ctx,TLV_TYPE_STR_VALUE,match_string,"match_string") ; RsTypeSerializer::serial_process(j,ctx,request_id,"request_id") ; RsTypeSerializer::serial_process(j,ctx,depth ,"depth") ; } - void RsTurtleRegExpSearchRequestItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx) { RsTypeSerializer::serial_process(j,ctx,request_id,"request_id") ; RsTypeSerializer::serial_process(j,ctx,depth,"depth") ; RsTypeSerializer::serial_process(j,ctx,expr,"expr") ; } +void RsTurtleGenericSearchRequestItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx) +{ + RsTypeSerializer::serial_process(j,ctx,request_id,"request_id") ; + RsTypeSerializer::serial_process(j,ctx,depth,"depth") ; + RsTypeSerializer::serial_process(j,ctx,service_id,"service_id") ; + RsTypeSerializer::serial_process(j,ctx,request_type,"request_type") ; + RsTypeSerializer::TlvMemBlock_proxy prox(search_data,search_data_len) ; + RsTypeSerializer::serial_process(j,ctx,prox,"search_data") ; +} +RsTurtleSearchRequestItem *RsTurtleGenericSearchRequestItem::clone() const +{ + RsTurtleGenericSearchRequestItem *sr = new RsTurtleGenericSearchRequestItem ; + + memcpy(sr,this,sizeof(RsTurtleGenericSearchRequestItem)) ; + + sr->search_data = (unsigned char*)rs_malloc(search_data_len) ; + memcpy(sr->search_data,search_data,search_data_len) ; + + return sr ; +} template<> uint32_t RsTypeSerializer::serial_size(const RsRegularExpression::LinearizedExpression& r) { uint32_t s = 0 ; @@ -143,62 +190,38 @@ template<> void RsTypeSerializer::print_data(const std::string& n, const RsRegul RS_TYPE_SERIALIZER_TO_JSON_NOT_IMPLEMENTED_DEF(RsRegularExpression::LinearizedExpression) RS_TYPE_SERIALIZER_FROM_JSON_NOT_IMPLEMENTED_DEF(RsRegularExpression::LinearizedExpression) -void RsTurtleSearchResultItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx) +void RsTurtleFTSearchResultItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx) { RsTypeSerializer::serial_process(j,ctx,request_id,"request_id") ; - RsTypeSerializer::serial_process(j,ctx,depth ,"depth") ; + + // This depth was previously a member of SearchResult parent class that was set to be always 0. It's removed, but we have to stay backward compatible. + uint16_t depth_retrocompat_unused_placeholder = 0 ; + RsTypeSerializer::serial_process(j,ctx,depth_retrocompat_unused_placeholder,"depth") ; + RsTypeSerializer::serial_process (j,ctx,result ,"result") ; } - -template<> uint32_t RsTypeSerializer::serial_size(const TurtleFileInfo& i) +void RsTurtleGenericSearchResultItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx) { - uint32_t s = 0 ; + RsTypeSerializer::serial_process(j,ctx,request_id,"request_id") ; - s += 8 ; // size - s += i.hash.SIZE_IN_BYTES ; - s += GetTlvStringSize(i.name) ; + // This depth was previously a member of SearchResult parent class that was set to be always 0. It's removed, but we have to stay backward compatible. + uint16_t depth_retrocompat_unused_placeholder = 0 ; + RsTypeSerializer::serial_process(j,ctx,depth_retrocompat_unused_placeholder,"depth") ; - return s; + RsTypeSerializer::TlvMemBlock_proxy prox(result_data,result_data_len) ; + RsTypeSerializer::serial_process(j,ctx,prox,"search_data") ; } - -template<> bool RsTypeSerializer::deserialize(const uint8_t data[],uint32_t size,uint32_t& offset,TurtleFileInfo& i) +RsTurtleSearchResultItem *RsTurtleGenericSearchResultItem::duplicate() const { - uint32_t saved_offset = offset ; - bool ok = true ; + RsTurtleGenericSearchResultItem *sr = new RsTurtleGenericSearchResultItem ; - ok &= getRawUInt64(data, size, &offset, &i.size); // file size - ok &= i.hash.deserialise(data, size, offset); // file hash - ok &= GetTlvString(data, size, &offset, TLV_TYPE_STR_NAME, i.name); // file name - - if(!ok) - offset = saved_offset ; - - return ok; + sr->result_data = (unsigned char*)rs_malloc(result_data_len) ; + memcpy(sr->result_data,result_data,result_data_len) ; + sr->result_data_len = result_data_len ; + sr->request_id = request_id ; + return sr ; } -template<> bool RsTypeSerializer::serialize(uint8_t data[],uint32_t size,uint32_t& offset,const TurtleFileInfo& i) -{ - uint32_t saved_offset = offset ; - bool ok = true ; - - ok &= setRawUInt64(data, size, &offset, i.size); // file size - ok &= i.hash.serialise(data, size, offset); // file hash - ok &= SetTlvString(data, size, &offset, TLV_TYPE_STR_NAME, i.name); // file name - - if(!ok) - offset = saved_offset ; - - return ok; -} - -template<> void RsTypeSerializer::print_data(const std::string& n, const TurtleFileInfo& i) -{ - std::cerr << " [FileInfo ] " << n << " size=" << i.size << " hash=" << i.hash << ", name=" << i.name << std::endl; -} - -RS_TYPE_SERIALIZER_TO_JSON_NOT_IMPLEMENTED_DEF(TurtleFileInfo) -RS_TYPE_SERIALIZER_FROM_JSON_NOT_IMPLEMENTED_DEF(TurtleFileInfo) - void RsTurtleOpenTunnelItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx) { RsTypeSerializer::serial_process (j,ctx,file_hash ,"file_hash") ; diff --git a/libretroshare/src/turtle/rsturtleitem.h b/libretroshare/src/turtle/rsturtleitem.h index 248082652..1f4893087 100644 --- a/libretroshare/src/turtle/rsturtleitem.h +++ b/libretroshare/src/turtle/rsturtleitem.h @@ -1,3 +1,24 @@ +/******************************************************************************* + * libretroshare/src/turtle: rsturtleitem.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2009-2018 by Cyril Soler * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once #include "rsitems/rsserviceids.h" @@ -16,20 +37,24 @@ #include "serialiser/rsserializer.h" const uint8_t RS_TURTLE_SUBTYPE_STRING_SEARCH_REQUEST = 0x01 ; -const uint8_t RS_TURTLE_SUBTYPE_SEARCH_RESULT = 0x02 ; +const uint8_t RS_TURTLE_SUBTYPE_FT_SEARCH_RESULT = 0x02 ; const uint8_t RS_TURTLE_SUBTYPE_OPEN_TUNNEL = 0x03 ; const uint8_t RS_TURTLE_SUBTYPE_TUNNEL_OK = 0x04 ; const uint8_t RS_TURTLE_SUBTYPE_FILE_REQUEST = 0x07 ; const uint8_t RS_TURTLE_SUBTYPE_FILE_DATA = 0x08 ; const uint8_t RS_TURTLE_SUBTYPE_REGEXP_SEARCH_REQUEST = 0x09 ; const uint8_t RS_TURTLE_SUBTYPE_GENERIC_DATA = 0x0a ; +const uint8_t RS_TURTLE_SUBTYPE_GENERIC_SEARCH_REQUEST = 0x0b ; +const uint8_t RS_TURTLE_SUBTYPE_GENERIC_SEARCH_RESULT = 0x0c ; const uint8_t RS_TURTLE_SUBTYPE_FILE_MAP = 0x10 ; const uint8_t RS_TURTLE_SUBTYPE_FILE_MAP_REQUEST = 0x11 ; +// const uint8_t RS_TURTLE_SUBTYPE_FILE_CRC = 0x12 ; // unused +// const uint8_t RS_TURTLE_SUBTYPE_FILE_CRC_REQUEST = 0x13 ; const uint8_t RS_TURTLE_SUBTYPE_CHUNK_CRC = 0x14 ; const uint8_t RS_TURTLE_SUBTYPE_CHUNK_CRC_REQUEST = 0x15 ; -// const uint8_t RS_TURTLE_SUBTYPE_FILE_CRC = 0x12 ; // unused -// const uint8_t RS_TURTLE_SUBTYPE_FILE_CRC_REQUEST = 0x13 ; + +class TurtleSearchRequestInfo ; /***********************************************************************************/ /* Basic Turtle Item Class */ @@ -46,49 +71,66 @@ class RsTurtleItem: public RsItem /* Specific packets */ /***********************************************************************************/ -class RsTurtleSearchResultItem: public RsTurtleItem -{ - public: - RsTurtleSearchResultItem() : RsTurtleItem(RS_TURTLE_SUBTYPE_SEARCH_RESULT), request_id(0), depth(0) { setPriorityLevel(QOS_PRIORITY_RS_TURTLE_SEARCH_RESULT) ;} +// Class hierarchy is +// +// RsTurtleItem +// | +// +---- RsTurtleSearchRequestItem +// | | +// | +---- RsTurtleFileSearchRequestItem +// | | | +// | | +---- RsTurtleStringSearchRequestItem +// | | | +// | | +---- RsTurtleReqExpSearchRequestItem +// | | +// | +---- RsTurtleGenericSearchRequestItem +// | +// +---- RsTurtleSearchResultItem +// | +// +---- RsTurtleFTSearchResultItem +// | +// +---- RsTurtleGenericSearchResultItem +// - TurtleSearchRequestId request_id ; // Randomly generated request id. - - uint16_t depth ; // The depth of a search result is obfuscated in this way: - // If the actual depth is 1, this field will be 1. - // If the actual depth is > 1, this field is a larger arbitrary integer. - std::list result ; - - void clear() { result.clear() ; } - protected: - void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx); - -}; +class RsTurtleSearchResultItem ; class RsTurtleSearchRequestItem: public RsTurtleItem { public: RsTurtleSearchRequestItem(uint32_t subtype) : RsTurtleItem(subtype), request_id(0), depth(0) { setPriorityLevel(QOS_PRIORITY_RS_TURTLE_SEARCH_REQUEST) ;} + virtual ~RsTurtleSearchRequestItem() {} + virtual RsTurtleSearchRequestItem *clone() const = 0 ; // used for cloning in routing methods - virtual void performLocalSearch(std::list&) const = 0 ; // abstracts the search method - virtual std::string GetKeywords() = 0; - + virtual uint16_t serviceId() const= 0 ; + uint32_t request_id ; // randomly generated request id. uint16_t depth ; // Used for limiting search depth. }; -class RsTurtleStringSearchRequestItem: public RsTurtleSearchRequestItem +class RsTurtleFileSearchRequestItem: public RsTurtleSearchRequestItem { public: - RsTurtleStringSearchRequestItem() : RsTurtleSearchRequestItem(RS_TURTLE_SUBTYPE_STRING_SEARCH_REQUEST) {} - + RsTurtleFileSearchRequestItem(uint32_t subtype) : RsTurtleSearchRequestItem(subtype) {} + virtual ~RsTurtleFileSearchRequestItem() {} + + virtual uint16_t serviceId() const { return RS_SERVICE_TYPE_FILE_TRANSFER ; } + virtual void search(std::list &) const =0; +}; + +class RsTurtleStringSearchRequestItem: public RsTurtleFileSearchRequestItem +{ + public: + RsTurtleStringSearchRequestItem() : RsTurtleFileSearchRequestItem(RS_TURTLE_SUBTYPE_STRING_SEARCH_REQUEST) {} + virtual ~RsTurtleStringSearchRequestItem() {} + + virtual void search(std::list &) const ; + std::string match_string ; // string to match - std::string GetKeywords() { return match_string; } - + virtual RsTurtleSearchRequestItem *clone() const { return new RsTurtleStringSearchRequestItem(*this) ; } - virtual void performLocalSearch(std::list&) const ; void clear() { match_string.clear() ; } @@ -96,10 +138,11 @@ class RsTurtleStringSearchRequestItem: public RsTurtleSearchRequestItem void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx); }; -class RsTurtleRegExpSearchRequestItem: public RsTurtleSearchRequestItem +class RsTurtleRegExpSearchRequestItem: public RsTurtleFileSearchRequestItem { public: - RsTurtleRegExpSearchRequestItem() : RsTurtleSearchRequestItem(RS_TURTLE_SUBTYPE_REGEXP_SEARCH_REQUEST) {} + RsTurtleRegExpSearchRequestItem() : RsTurtleFileSearchRequestItem(RS_TURTLE_SUBTYPE_REGEXP_SEARCH_REQUEST) {} + virtual ~RsTurtleRegExpSearchRequestItem() {} RsRegularExpression::LinearizedExpression expr ; // Reg Exp in linearised mode @@ -110,15 +153,88 @@ class RsTurtleRegExpSearchRequestItem: public RsTurtleSearchRequestItem delete ex; return exs; } - - virtual RsTurtleSearchRequestItem *clone() const { return new RsTurtleRegExpSearchRequestItem(*this) ; } - virtual void performLocalSearch(std::list&) const ; + virtual void search(std::list &) const ; + + virtual RsTurtleSearchRequestItem *clone() const { return new RsTurtleRegExpSearchRequestItem(*this) ; } void clear() { expr = RsRegularExpression::LinearizedExpression(); } protected: void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx); }; +class RsTurtleGenericSearchRequestItem: public RsTurtleSearchRequestItem +{ + public: + RsTurtleGenericSearchRequestItem() : RsTurtleSearchRequestItem(RS_TURTLE_SUBTYPE_GENERIC_SEARCH_REQUEST) {} + virtual ~RsTurtleGenericSearchRequestItem() { clear(); } + + uint16_t service_id ; // service to search + uint32_t search_data_len ; + uint8_t request_type ; // type of request. This is used to limit the number of responses. + unsigned char *search_data ; + + std::string GetKeywords() ; + virtual uint16_t serviceId() const { return service_id ; } + + virtual RsTurtleSearchRequestItem *clone() const ; + virtual uint32_t requestType() const { return request_type; } + + void clear() { free(search_data); search_data=NULL; search_data_len=0; } + + protected: + void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx); + + private: + RsTurtleGenericSearchRequestItem(const RsTurtleGenericSearchRequestItem&): RsTurtleSearchRequestItem(RS_TURTLE_SUBTYPE_GENERIC_SEARCH_REQUEST) {} // make the object non copi-able. + RsTurtleGenericSearchRequestItem& operator=(const RsTurtleGenericSearchRequestItem&) { return *this;} +}; +class RsTurtleSearchResultItem: public RsTurtleItem +{ + public: + RsTurtleSearchResultItem(uint8_t subtype) : RsTurtleItem(subtype), request_id(0) { setPriorityLevel(QOS_PRIORITY_RS_TURTLE_SEARCH_RESULT) ;} + + TurtleSearchRequestId request_id ; // Randomly generated request id. + + virtual uint32_t count() const =0; + virtual void pop() =0; + + virtual void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)=0; + virtual RsTurtleSearchResultItem *duplicate() const =0; +}; + +class RsTurtleFTSearchResultItem: public RsTurtleSearchResultItem +{ + public: + RsTurtleFTSearchResultItem() : RsTurtleSearchResultItem(RS_TURTLE_SUBTYPE_FT_SEARCH_RESULT){} + + std::list result ; + + void clear() { result.clear() ; } + uint32_t count() const { return result.size() ; } + virtual void pop() { result.pop_back() ;} + virtual RsTurtleSearchResultItem *duplicate() const { return new RsTurtleFTSearchResultItem(*this) ; } + protected: + void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx); +}; + +class RsTurtleGenericSearchResultItem: public RsTurtleSearchResultItem +{ + public: + RsTurtleGenericSearchResultItem() : RsTurtleSearchResultItem(RS_TURTLE_SUBTYPE_GENERIC_SEARCH_RESULT){} + virtual ~RsTurtleGenericSearchResultItem() {} + + uint32_t count() const { return result_data_len/50 ; } // This is a blind size estimate. We should probably use the actual size to limit search results. + virtual void pop() {} + + unsigned char *result_data ; + uint32_t result_data_len ; + + virtual RsTurtleSearchResultItem *duplicate() const ; + void clear() { free(result_data); result_data=NULL; result_data_len=0; } + protected: + void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx); +}; + /***********************************************************************************/ /* Turtle Tunnel Item classes */ /***********************************************************************************/ @@ -128,10 +244,10 @@ class RsTurtleOpenTunnelItem: public RsTurtleItem public: RsTurtleOpenTunnelItem() : RsTurtleItem(RS_TURTLE_SUBTYPE_OPEN_TUNNEL), request_id(0), partial_tunnel_id(0), depth(0) { setPriorityLevel(QOS_PRIORITY_RS_TURTLE_OPEN_TUNNEL) ;} - TurtleFileHash file_hash ; // hash to match - uint32_t request_id ; // randomly generated request id. + TurtleFileHash file_hash ; // hash to match + uint32_t request_id ; // randomly generated request id. uint32_t partial_tunnel_id ; // uncomplete tunnel id. Will be completed at destination. - uint16_t depth ; // Used for limiting search depth. + uint16_t depth ; // Used for limiting search depth. void clear() { file_hash.clear() ;} protected: @@ -167,24 +283,24 @@ class RsTurtleGenericTunnelItem: public RsTurtleItem /// Does this packet stamps tunnels when it passes through ? /// This is used for keeping trace weither tunnels are active or not. - + virtual bool shouldStampTunnel() const = 0 ; - /// All tunnels derived from RsTurtleGenericTunnelItem should have a tunnel id to + /// All tunnels derived from RsTurtleGenericTunnelItem should have a tunnel id to /// indicate which tunnel they are travelling through. - + virtual TurtleTunnelId tunnelId() const { return tunnel_id ; } /// Indicate weither the packet is a client packet (goign back to the /// client) or a server packet (going to the server. Typically file /// requests are server packets, whereas file data are client packets. - + virtual Direction travelingDirection() const { return direction ; } virtual void setTravelingDirection(Direction d) { direction = d; } Direction direction ; // This does not need to be serialised. It's only used by the client services, optionnally, // and is set by the turtle router according to which direction the item travels. - + uint32_t tunnel_id ; // Id of the tunnel to travel through }; diff --git a/libretroshare/src/turtle/turtleclientservice.h b/libretroshare/src/turtle/turtleclientservice.h index 51a9dbdc3..9cbe5763f 100644 --- a/libretroshare/src/turtle/turtleclientservice.h +++ b/libretroshare/src/turtle/turtleclientservice.h @@ -1,27 +1,24 @@ -/* - * libretroshare/src/services: turtleclientservice.h - * - * Services for RetroShare. - * - * Copyright 2013 by Cyril Soler - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "csoler@users.sourceforge.net". - * - */ +/******************************************************************************* + * libretroshare/src/turtle: rsturtleclientservice.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2013-2018 by Cyril Soler * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ // This class is the parent class for any service that will use the turtle router to distribute its packets. // Typical representative clients include: @@ -42,51 +39,125 @@ class p3turtle ; class RsTurtleClientService { public: - // Handling of tunnel request for the given hash. Most of the time, it's a search in a predefined list. - // The output info_string is used by the turtle router to display info about tunnels it manages. It is - // not passed to the tunnel. + /*! + * \brief serviceId + * Returns the ID of the client service. This is used to pass the ID to search requests, from the client services + * \return + * The service ID. + */ - virtual bool handleTunnelRequest(const RsFileHash& /*hash*/,const RsPeerId& /*peer_id*/) { return false ; } + virtual uint16_t serviceId() const + { + std::cerr << "!!!!!! Received request for service ID in turtle router client, but the client service is not handling it !!!!!!!" << std::endl ; + return 0 ; + } + + /*! + * \brief handleTunnelRequest + Handling of tunnel request for the given hash. To be derived by the service in order to tell the turtle router + whether the service handles this hash or not. Most of the time, it's a search in a predefined list. + + * \return true if the service + */ + virtual bool handleTunnelRequest(const RsFileHash& /*hash*/,const RsPeerId& /*peer_id*/) { return false ; } - // This method is called by the turtle router to send data that comes out of a turtle tunnel. - // The turtle router stays responsible for the memory management of data. Most of the time the - // data chunk is a serialized item to be de-serialized by the client service. - // - // Parameters: - // virtual_peer_id : name of the tunnel that sent the data - // data : memory chunk for the data - // size : size of data - // item->direction : direction of travel: - // RsTurtleGenericTunnelItem::DIRECTION_CLIENT: the service is acting as a client - // RsTurtleGenericTunnelItem::DIRECTION_CLIENT: the service is acting as a server - // - // Most of the time this parameter is not used by services, except when some info (such as chunk maps, chat items, etc) go - // both ways, and their nature cannot suffice to determine where they should be handled. - // - // By default (if not overloaded), the method will just free the data, as any subclass should do as well. - // Note: p3turtle stays owner of the item, so the client should not delete it! - // - virtual void receiveTurtleData(RsTurtleGenericTunnelItem */*item*/,const RsFileHash& /*hash*/,const RsPeerId& /*virtual_peer_id*/,RsTurtleGenericTunnelItem::Direction /*direction*/) + /*! + * \brief receiveTurtleData + * This method is called by the turtle router to send data that comes out of a turtle tunnel, and should + * be overloaded by the client service. + * The turtle router stays responsible for the memory management of data. Most of the time the + * data chunk is a serialized item to be de-serialized by the client service. + * + * Parameters: + * virtual_peer_id : name of the tunnel that sent the data + * data : memory chunk for the data + * size : size of data + * item->direction : direction of travel: + * RsTurtleGenericTunnelItem::DIRECTION_CLIENT: the service is acting as a client + * RsTurtleGenericTunnelItem::DIRECTION_CLIENT: the service is acting as a server + * + * Most of the time this parameter is not used by services, except when some info (such as chunk maps, chat items, etc) go + * both ways, and their nature cannot suffice to determine where they should be handled. + * + * By default (if not overloaded), the method will just free the data, as any subclass should do as well. + * Note: p3turtle stays owner of the item, so the client should not delete it! + */ + virtual void receiveTurtleData(const RsTurtleGenericTunnelItem * /* item */,const RsFileHash& /*hash*/,const RsPeerId& /*virtual_peer_id*/,RsTurtleGenericTunnelItem::Direction /*direction*/) { std::cerr << "!!!!!! Received Data from turtle router, but the client service is not handling it !!!!!!!!!!" << std::endl ; } - // Method for creating specific items of the client service. The - // method has a default behavior of not doing anything, since most client - // services might only use the generic item already provided by the turtle - // router: RsTurtleGenericDataItem + /*! + * \brief receiveSearchRequest + * This method is called by the turtle router to notify the client of a search request in the form generic data. The returned + * result contains the serialised generic result returned by the client. + * + * The turtle router keeps the memory ownership over search_request_data + * + * \param search_request_data generic serialized search data + * \param search_request_data_len length of the serialized search data + * \param search_result_data generic serialized search result data + * \param search_result_data_len length of the serialized search result data + * \param max_allowed_hits max number of hits allowed to be sent back and forwarded + * + * \return true if the search is successful. + */ + virtual bool receiveSearchRequest(unsigned char */*search_request_data*/, + uint32_t /*search_request_data_len*/, + unsigned char *& /*search_result_data*/, + uint32_t& /*search_result_data_len*/, + uint32_t& /* max_allows_hits */) + { + std::cerr << "!!!!!! Received search result from turtle router, but the client service who requested it is not handling it !!!!!!!!!!" << std::endl ; + return false; + } + /*! + * \brief receiveSearchResult + * This method is called by the turtle router to notify the client of a search result. The result is serialized for the current class to read. + * + * \param search_result_data result data. Memory ownership is owned by the turtle router. So do not delete! + * \param search_result_data length of result data + */ + virtual void receiveSearchResult(TurtleSearchRequestId /* request_id */,unsigned char * /*search_result_data*/,uint32_t /*search_result_data_len*/) + { + std::cerr << "!!!!!! Received search result from turtle router, but the client service who requested it is not handling it !!!!!!!!!!" << std::endl ; + } + + /*! + * \brief serializer + * Method for creating specific items of the client service. The + * method has a default behavior of not doing anything, since most client + * services might only use the generic item already provided by the turtle + * router: RsTurtleGenericDataItem + * + * \return the client's serializer is returned + */ virtual RsServiceSerializer *serializer() { return NULL ; } - // These methods are called by the turtle router to add/remove virtual peers when tunnels are created/deleted - // + /*! + * \brief addVirtualPeer + * These methods are called by the turtle router to notify the client in order to add/remove virtual peers when tunnels are created/deleted + * These methods must be overloaded, because a service which does not care about tunel being openned or closed is not supposed to need tunnels. + * + * \param hash hash that the tunnel responds to + * \param virtual_peer_id virtual peer id provided by turtle to allow the client to send data into this tunnel. This peer is related to the tunnel itself + * rather than to its destination. As such, multiple peer ids may actually send data to the same computer because multiple tunnels + * arrive at the same location. + * \param dir dir indicates which side the cient will be talking to: CLIENT means that the client is the server. SERVER means that the client acts + * as a client (and therefore actually requested the tunnel). + */ virtual void addVirtualPeer(const TurtleFileHash& hash,const TurtleVirtualPeerId& virtual_peer_id,RsTurtleGenericTunnelItem::Direction dir) = 0 ; virtual void removeVirtualPeer(const TurtleFileHash& hash,const TurtleVirtualPeerId& virtual_peer_id) = 0 ; - // This function is mandatory. It should do two things: - // 1 - keep a pointer to the turtle router, so as to be able to send data (e.g. copy pt into a local variable) - // 2 - call pt->registerTunnelService(this), so that the TR knows that service and can send back information to it. - // + /*! + * \brief connectToTurtleRouter + * This function must be overloaded by the client. It should do two things: + * 1 - keep a pointer to the turtle router, so as to be able to send data (e.g. store pt into a local variable) + * 2 - call pt->registerTunnelService(this), so that the TR knows that service and can send back information to it. + * + * \param pt A pointer to the turtle router. + */ virtual void connectToTurtleRouter(p3turtle *pt) = 0 ; }; diff --git a/libretroshare/src/turtle/turtletypes.h b/libretroshare/src/turtle/turtletypes.h index 840dda1d0..56fd78f8b 100644 --- a/libretroshare/src/turtle/turtletypes.h +++ b/libretroshare/src/turtle/turtletypes.h @@ -1,3 +1,24 @@ +/******************************************************************************* + * libretroshare/src/turtle: rsturtletypes.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2013-2018 by Cyril Soler * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once #include "retroshare/rsturtle.h" diff --git a/libretroshare/src/unused/p3dsdv.cc b/libretroshare/src/unused/p3dsdv.cc index 6373dea8e..b6a3cf057 100644 --- a/libretroshare/src/unused/p3dsdv.cc +++ b/libretroshare/src/unused/p3dsdv.cc @@ -1,28 +1,24 @@ -/* - * libretroshare/src/services/p3dsdv.h - * - * Network-Wide Routing Service. - * - * Copyright 2011 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/unused: p3dsdv.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2011 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include #include #include diff --git a/libretroshare/src/unused/p3dsdv.h b/libretroshare/src/unused/p3dsdv.h index 4b95fdba3..72327fd22 100644 --- a/libretroshare/src/unused/p3dsdv.h +++ b/libretroshare/src/unused/p3dsdv.h @@ -1,29 +1,24 @@ -/* - * libretroshare/src/services/p3dsdv.h - * - * Network-Wide Routing Service. - * - * Copyright 2011 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - +/******************************************************************************* + * libretroshare/src/unused: p3dsdv.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2011 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef SERVICE_RSDSDV_HEADER #define SERVICE_RSDSDV_HEADER diff --git a/libretroshare/src/pqi/pqiarchive.cc b/libretroshare/src/unused/pqiarchive.cc similarity index 84% rename from libretroshare/src/pqi/pqiarchive.cc rename to libretroshare/src/unused/pqiarchive.cc index e6d3d65e1..195d560ae 100644 --- a/libretroshare/src/pqi/pqiarchive.cc +++ b/libretroshare/src/unused/pqiarchive.cc @@ -1,27 +1,24 @@ -/* - * "$Id: pqiarchive.cc,v 1.5 2007-03-21 18:45:41 rmf24 Exp $" - * - * 3P/PQI network interface for RetroShare. - * - * Copyright 2004-2006 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ +/******************************************************************************* + * libretroshare/src/pqi: pqiarchive.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright (C) 2004-2006 Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ /* This is dependent on the sslroot at the moment. * -> as we need to create/restore references to the Person. diff --git a/libretroshare/src/unused/pqiarchive.h b/libretroshare/src/unused/pqiarchive.h new file mode 100644 index 000000000..4c2a82a96 --- /dev/null +++ b/libretroshare/src/unused/pqiarchive.h @@ -0,0 +1,78 @@ +/******************************************************************************* + * libretroshare/src/pqi: pqiarchive.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2006 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ +#ifdef SUSPENDED_UNUSED_CODE + +#ifndef MRK_PQI_ARCHIVE_STREAMER_HEADER +#define MRK_PQI_ARCHIVE_STREAMER_HEADER + +#include "pqi/pqi.h" + +#include + +/******************************************************************* + * pqiarchive provides an archive stream. + * This stores RsItem + Person Reference + Timestamp, + * + * and allows Objects to be replayed or restored, + * independently of the rest of the pqi system. + * + */ + +class pqiarchive: public PQInterface +{ +public: + pqiarchive(RsSerialiser *rss, BinInterface *bio_in, int bio_flagsin); +virtual ~pqiarchive(); + +// PQInterface +virtual int SendItem(RsItem *); +virtual RsItem *GetItem(); + +virtual int tick(); +virtual int status(); + +virtual void setRealTime(bool r) { realTime = r; } + +std::string gethash(); + + private: +int writePkt(RsItem *item); +int readPkt(RsItem **item_out, long *ts); + + // Serialiser + RsSerialiser *rsSerialiser; + // Binary Interface for IO, initialisated at startup. + BinInterface *bio; + unsigned int bio_flags; // only BIN_NO_CLOSE at the moment. + + // Temp Storage for transient data..... + RsItem *nextPkt; + long nextPktTS; /* timestamp associated with nextPkt */ + long firstPktTS; /* timestamp associated with first read Pkt */ + long initTS; /* clock timestamp at first read */ + + bool realTime; +}; + + +#endif //MRK_PQI_ARCHIVE_STREAMER_HEADER +#endif //SUSPENDED_UNUSED_CODE diff --git a/libretroshare/src/util/rscompress.cc b/libretroshare/src/unused/rscompress.cc similarity index 72% rename from libretroshare/src/util/rscompress.cc rename to libretroshare/src/unused/rscompress.cc index 1942e4feb..e3aa0f849 100644 --- a/libretroshare/src/util/rscompress.cc +++ b/libretroshare/src/unused/rscompress.cc @@ -1,28 +1,24 @@ -/* - * libretroshare/src/utils: rscompress.cc - * - * Basic memory chunk compression, based on openpgp-sdk - * - * Copyright 2013 by Cyril Soler - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "csoler@users.sourceforge.net". - * - */ - +/******************************************************************************* + * libretroshare/src/util: rscompress.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2013 Cyril Soler * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include #include #include diff --git a/libretroshare/src/unused/rscompress.h b/libretroshare/src/unused/rscompress.h new file mode 100644 index 000000000..96b9e2092 --- /dev/null +++ b/libretroshare/src/unused/rscompress.h @@ -0,0 +1,30 @@ +/******************************************************************************* + * libretroshare/src/util: rscompress.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2013 Cyril Soler * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ +#pragma once + +class RsCompress +{ + public: + static bool compress_memory_chunk(const uint8_t *input_mem,const uint32_t input_size,uint8_t *& output_mem,uint32_t& output_size) ; + static bool uncompress_memory_chunk(const uint8_t *input_mem,const uint32_t input_size,uint8_t *& output_mem,uint32_t& output_size) ; +}; + diff --git a/libretroshare/src/unused/rsdsdv.h b/libretroshare/src/unused/rsdsdv.h index dd7eb03c0..e2d634a10 100644 --- a/libretroshare/src/unused/rsdsdv.h +++ b/libretroshare/src/unused/rsdsdv.h @@ -1,31 +1,27 @@ +/******************************************************************************* + * libretroshare/src/unused: rsdsdv.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2011 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RETROSHARE_DSDV_INTERFACE_H #define RETROSHARE_DSDV_INTERFACE_H -/* - * libretroshare/src/rsiface: rsdsdv.h - * - * RetroShare C++ Interface. - * - * Copyright 2011-2011 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - #include #include #include diff --git a/libretroshare/src/unused/rsdsdvitems.cc b/libretroshare/src/unused/rsdsdvitems.cc index 4731d1814..073ebe669 100644 --- a/libretroshare/src/unused/rsdsdvitems.cc +++ b/libretroshare/src/unused/rsdsdvitems.cc @@ -1,27 +1,24 @@ -/* - * libretroshare/src/serialiser: rsgameitems.cc - * - * RetroShare Serialiser. - * - * Copyright 2007-2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ +/******************************************************************************* + * libretroshare/src/unused: rsdsdvitems.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2011 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "serialiser/rsbaseserial.h" #include "serialiser/rsdsdvitems.h" diff --git a/libretroshare/src/unused/rsdsdvitems.h b/libretroshare/src/unused/rsdsdvitems.h index fd03be486..856a06b92 100644 --- a/libretroshare/src/unused/rsdsdvitems.h +++ b/libretroshare/src/unused/rsdsdvitems.h @@ -1,31 +1,27 @@ +/******************************************************************************* + * libretroshare/src/unused: rsdsdvitems.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2011 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RS_DSDV_ITEMS_H #define RS_DSDV_ITEMS_H -/* - * libretroshare/src/serialiser: rsdsdvitems.h - * - * RetroShare Serialiser. - * - * Copyright 2011-2011 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - #include #include "rsitems/rsserviceids.h" diff --git a/libretroshare/src/upnp/upnphandler_linux.cc b/libretroshare/src/upnp/upnphandler_linux.cc index 13f70f041..4e6c344fb 100644 --- a/libretroshare/src/upnp/upnphandler_linux.cc +++ b/libretroshare/src/upnp/upnphandler_linux.cc @@ -1,6 +1,24 @@ -//Linux only -/* This stuff is actually C */ - +/******************************************************************************* + * libretroshare/src/upnp: upnphandler_linux.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2007-2018 Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifdef __cplusplus extern "C" { #endif diff --git a/libretroshare/src/upnp/upnphandler_linux.h b/libretroshare/src/upnp/upnphandler_linux.h index b22a9a9e2..741adfc47 100644 --- a/libretroshare/src/upnp/upnphandler_linux.h +++ b/libretroshare/src/upnp/upnphandler_linux.h @@ -1,3 +1,24 @@ +/******************************************************************************* + * libretroshare/src/upnp: upnphandler_linux.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2007-2018 Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef _RS_UPNP_IFACE_H #define _RS_UPNP_IFACE_H diff --git a/libretroshare/src/upnp/upnphandler_miniupnp.cc b/libretroshare/src/upnp/upnphandler_miniupnp.cc index 24a3395f4..f264d80a7 100644 --- a/libretroshare/src/upnp/upnphandler_miniupnp.cc +++ b/libretroshare/src/upnp/upnphandler_miniupnp.cc @@ -1,3 +1,24 @@ +/******************************************************************************* + * libretroshare/src/upnp: upnphandler_miniupnp.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2007-2018 Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ // Windows / Mac version. /* This stuff is actually C */ diff --git a/libretroshare/src/upnp/upnphandler_miniupnp.h b/libretroshare/src/upnp/upnphandler_miniupnp.h index 6b4660e32..1f3c33378 100644 --- a/libretroshare/src/upnp/upnphandler_miniupnp.h +++ b/libretroshare/src/upnp/upnphandler_miniupnp.h @@ -1,3 +1,24 @@ +/******************************************************************************* + * libretroshare/src/upnp: upnphandler_miniupnp.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2007-2018 Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ //windows/osx (miniupnpc) implementation #ifndef _RS_UPNP_IFACE_H #define _RS_UPNP_IFACE_H diff --git a/libretroshare/src/upnp/upnputil.c b/libretroshare/src/upnp/upnputil.c index 525878bf6..6d5bf326c 100644 --- a/libretroshare/src/upnp/upnputil.c +++ b/libretroshare/src/upnp/upnputil.c @@ -1,3 +1,22 @@ +/************************************************************************************** + * MiniUPnPc * + * Copyright (c) 2005-2016, Thomas BERNARD * + * All rights reserved. * + * * + * Redistribution and use in source and binary forms, with or without * + * modification, are permitted provided that the following conditions are met: * + * * + * * Redistributions of source code must retain the above copyright notice, * + * this list of conditions and the following disclaimer. * + * * Redistributions in binary form must reproduce the above copyright notice, * + * this list of conditions and the following disclaimer in the documentation * + * and/or other materials provided with the distribution. * + * * The name of the author may not be used to endorse or promote products * + * derived from this software without specific prior written permission. * + * This software is subject to the conditions detailed in the * + * LICENCE file provided in this distribution. * + * * + **************************************************************************************/ //this file uses miniupnp //From https://github.com/miniupnp/miniupnp/blob/master/miniupnpc/upnpc.c diff --git a/libretroshare/src/upnp/upnputil.h b/libretroshare/src/upnp/upnputil.h index 99ec61f4f..20339bb72 100644 --- a/libretroshare/src/upnp/upnputil.h +++ b/libretroshare/src/upnp/upnputil.h @@ -1,15 +1,27 @@ +/************************************************************************************** + * MiniUPnPc * + * Copyright (c) 2005-2016, Thomas BERNARD * + * All rights reserved. * + * * + * Redistribution and use in source and binary forms, with or without * + * modification, are permitted provided that the following conditions are met: * + * * + * * Redistributions of source code must retain the above copyright notice, * + * this list of conditions and the following disclaimer. * + * * Redistributions in binary form must reproduce the above copyright notice, * + * this list of conditions and the following disclaimer in the documentation * + * and/or other materials provided with the distribution. * + * * The name of the author may not be used to endorse or promote products * + * derived from this software without specific prior written permission. * + * This software is subject to the conditions detailed in the * + * LICENCE file provided in this distribution. * + * * + **************************************************************************************/ //this file uses miniupnp #ifndef MINIUPNP_UTIL_H_ #define MINIUPNP_UTIL_H_ -/* $Id: upnpc.c,v 1.50 2007/04/26 19:00:10 nanard Exp $ */ -/* Project : miniupnp - * Author : Thomas Bernard - * Copyright (c) 2005 Thomas Bernard - * This software is subject to the conditions detailed in the - * LICENCE file provided in this distribution. - * */ #include #include #include diff --git a/libretroshare/src/use_libretroshare.pri b/libretroshare/src/use_libretroshare.pri index 3a3d1acb7..abc18fff0 100644 --- a/libretroshare/src/use_libretroshare.pri +++ b/libretroshare/src/use_libretroshare.pri @@ -1,3 +1,20 @@ +################################################################################ +# uselibretroshare.pri # +# Copyright (C) 2018, Retroshare team # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU Lesser 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 Lesser General Public License for more details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with this program. If not, see . # +################################################################################ DEPENDPATH *= $$system_path($$clean_path($${PWD}/../../libretroshare/src/)) INCLUDEPATH *= $$system_path($$clean_path($${PWD}/../../libretroshare/src)) LIBS *= -L$$system_path($$clean_path($${OUT_PWD}/../../libretroshare/src/lib/)) -lretroshare @@ -16,16 +33,41 @@ bitdht { # 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)) +RAPIDJSON_AVAILABLE = $$system(pkg-config --atleast-version 1.1 RapidJSON && echo yes) +isEmpty(RAPIDJSON_AVAILABLE) { + message("using built-in rapidjson") + INCLUDEPATH *= $$system_path($$clean_path($${PWD}/../../rapidjson-1.1.0)) +} else { + message("using systems rapidjson") + DEFINES *= HAS_RAPIDJSON +} + sLibs = mLibs = $$RS_SQL_LIB ssl crypto $$RS_THREAD_LIB $$RS_UPNP_LIB dLibs = +rs_jsonapi { + RS_SRC_PATH=$$system_path($$clean_path($${PWD}/../../)) + RS_BUILD_PATH=$$system_path($$clean_path($${OUT_PWD}/../../)) + RESTBED_SRC_PATH=$$system_path($$clean_path($${RS_SRC_PATH}/supportlibs/restbed)) + RESTBED_BUILD_PATH=$$system_path($$clean_path($${RS_BUILD_PATH}/supportlibs/restbed)) + + INCLUDEPATH *= $$system_path($$clean_path($${RESTBED_BUILD_PATH}/include/)) + QMAKE_LIBDIR *= $$system_path($$clean_path($${RESTBED_BUILD_PATH}/library/)) + # Using sLibs would fail as librestbed.a is generated at compile-time + LIBS *= -L$$system_path($$clean_path($${RESTBED_BUILD_PATH}/library/)) -lrestbed +} + linux-* { mLibs += dl } +rs_deep_search { + mLibs += xapian + win32-g++:mLibs += rpcrt4 +} + static { sLibs *= $$mLibs } else { diff --git a/libretroshare/src/util/androiddebug.h b/libretroshare/src/util/androiddebug.h index 2e429b99f..c358be553 100644 --- a/libretroshare/src/util/androiddebug.h +++ b/libretroshare/src/util/androiddebug.h @@ -1,21 +1,25 @@ +/******************************************************************************* + * libretroshare/src/util: androiddebug.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright (C) 2016 Gioacchino Mazzurco * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once -/* - * Redirect plain stdout and stderr to Android debug - * Copyright (C) 2016 Gioacchino Mazzurco - * - * 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 . - */ // Inspired by: https://codelab.wordpress.com/2014/11/03/how-to-use-standard-output-streams-for-logging-in-android-apps/ diff --git a/libretroshare/src/util/contentvalue.cc b/libretroshare/src/util/contentvalue.cc index 1ab962120..e2eee943c 100644 --- a/libretroshare/src/util/contentvalue.cc +++ b/libretroshare/src/util/contentvalue.cc @@ -1,27 +1,24 @@ - -/* - * util/contentvalue.cc, key val container - * - * Copyright 2012 Christopher Evi-Parker - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/util: contentvalue.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012 Christopher Evi-Parker * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include #include diff --git a/libretroshare/src/util/contentvalue.h b/libretroshare/src/util/contentvalue.h index d81deb662..23ee55eca 100644 --- a/libretroshare/src/util/contentvalue.h +++ b/libretroshare/src/util/contentvalue.h @@ -1,29 +1,27 @@ +/******************************************************************************* + * libretroshare/src/util: contentvalue.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012 Christopher Evi-Parker * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef CONTENTVALUE_H #define CONTENTVALUE_H -/* - * util/contentvalue.h, key val container - * - * Copyright 2012 Christopher Evi-Parker - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - #include #include #include diff --git a/libretroshare/src/util/cxx11retrocompat.h b/libretroshare/src/util/cxx11retrocompat.h index 587b1374d..98dd998db 100644 --- a/libretroshare/src/util/cxx11retrocompat.h +++ b/libretroshare/src/util/cxx11retrocompat.h @@ -1,21 +1,25 @@ +/******************************************************************************* + * libretroshare/src/util: cxx11retrocompat.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright (C) 2017 Gioacchino Mazzurco * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once -/* - * RetroShare - * Copyright (C) 2017 Gioacchino Mazzurco - * - * 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 . - */ #ifdef __GNUC__ # define GCC_VERSION (__GNUC__*10000+__GNUC_MINOR__*100+__GNUC_PATCHLEVEL__) diff --git a/libretroshare/src/util/dnsresolver.cc b/libretroshare/src/util/dnsresolver.cc index e57d5864f..4807b1322 100644 --- a/libretroshare/src/util/dnsresolver.cc +++ b/libretroshare/src/util/dnsresolver.cc @@ -1,3 +1,24 @@ +/******************************************************************************* + * libretroshare/src/util: dnsresolver.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright (C) 2017 Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "dnsresolver.h" #include "pqi/pqinetwork.h" diff --git a/libretroshare/src/util/dnsresolver.h b/libretroshare/src/util/dnsresolver.h index 1f9581d1e..9db589825 100644 --- a/libretroshare/src/util/dnsresolver.h +++ b/libretroshare/src/util/dnsresolver.h @@ -1,3 +1,24 @@ +/******************************************************************************* + * libretroshare/src/util: dnsresolver.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright (C) 2017 Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once #include "pqi/pqinetwork.h" diff --git a/libretroshare/src/util/extaddrfinder.cc b/libretroshare/src/util/extaddrfinder.cc index 308a8ea48..fbed6fe85 100644 --- a/libretroshare/src/util/extaddrfinder.cc +++ b/libretroshare/src/util/extaddrfinder.cc @@ -1,3 +1,24 @@ +/******************************************************************************* + * libretroshare/src/util: extaddrfinder.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright (C) 2017 Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "extaddrfinder.h" #include "pqi/pqinetwork.h" @@ -175,7 +196,6 @@ void* doExtAddrSearch(void *p) af->mFoundTS = time(NULL) ; af->mSearching = false ; } - pthread_exit(NULL); return NULL ; } @@ -192,7 +212,6 @@ void* doExtAddrSearch(void *p) af->mFoundTS = time(NULL) ; af->mSearching = false ; } - pthread_exit(NULL); return NULL ; } @@ -203,7 +222,6 @@ void* doExtAddrSearch(void *p) af->mSearching = false ; } - pthread_exit(NULL); return NULL ; } diff --git a/libretroshare/src/util/extaddrfinder.h b/libretroshare/src/util/extaddrfinder.h index 203e1ff9e..2b4bd4da3 100644 --- a/libretroshare/src/util/extaddrfinder.h +++ b/libretroshare/src/util/extaddrfinder.h @@ -1,3 +1,24 @@ +/******************************************************************************* + * libretroshare/src/util: extaddrfinder.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright (C) 2017 Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once #include diff --git a/libretroshare/src/util/folderiterator.cc b/libretroshare/src/util/folderiterator.cc index eb70ab791..73afebeab 100644 --- a/libretroshare/src/util/folderiterator.cc +++ b/libretroshare/src/util/folderiterator.cc @@ -1,3 +1,24 @@ +/******************************************************************************* + * libretroshare/src/util: folderiterator.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright (C) 2017 Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include #include #include diff --git a/libretroshare/src/util/folderiterator.h b/libretroshare/src/util/folderiterator.h index 79a011ace..3232a4b47 100644 --- a/libretroshare/src/util/folderiterator.h +++ b/libretroshare/src/util/folderiterator.h @@ -1,3 +1,24 @@ +/******************************************************************************* + * libretroshare/src/util: folderiterator.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright (C) 2017 Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef FOLDERITERATOR_H #define FOLDERITERATOR_H diff --git a/libretroshare/src/util/pugiconfig.h b/libretroshare/src/util/pugiconfig.h deleted file mode 100644 index 6b553ae04..000000000 --- a/libretroshare/src/util/pugiconfig.h +++ /dev/null @@ -1,62 +0,0 @@ -/** - * pugixml parser - version 1.0 - * -------------------------------------------------------- - * Copyright (C) 2006-2010, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com) - * Report bugs and download new versions at http://pugixml.org/ - * - * This library is distributed under the MIT License. See notice at the end - * of this file. - * - * This work is based on the pugxml parser, which is: - * Copyright (C) 2003, by Kristen Wegner (kristen@tima.net) - */ - -#ifndef HEADER_PUGICONFIG_HPP -#define HEADER_PUGICONFIG_HPP - -// Uncomment this to enable wchar_t mode -// #define PUGIXML_WCHAR_MODE - -// Uncomment this to disable XPath -// #define PUGIXML_NO_XPATH - -// Uncomment this to disable STL -// Note: you can't use XPath with PUGIXML_NO_STL -// #define PUGIXML_NO_STL - -// Uncomment this to disable exceptions -// Note: you can't use XPath with PUGIXML_NO_EXCEPTIONS -// #define PUGIXML_NO_EXCEPTIONS - -// Set this to control attributes for public classes/functions, i.e.: -// #define PUGIXML_API __declspec(dllexport) // to export all public symbols from DLL -// #define PUGIXML_CLASS __declspec(dllimport) // to import all classes from DLL -// #define PUGIXML_FUNCTION __fastcall // to set calling conventions to all public functions to fastcall -// In absence of PUGIXML_CLASS/PUGIXML_FUNCTION definitions PUGIXML_API is used instead - -#endif - -/** - * Copyright (c) 2006-2010 Arseny Kapoulkine - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - */ diff --git a/libretroshare/src/util/radix32.h b/libretroshare/src/util/radix32.h index 008aa3e9f..af5fef3ec 100644 --- a/libretroshare/src/util/radix32.h +++ b/libretroshare/src/util/radix32.h @@ -1,3 +1,24 @@ +/******************************************************************************* + * libretroshare/src/util: radix32.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright (C) 2015 Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RADIX32_H #define RADIX32_H diff --git a/libretroshare/src/util/radix64.h b/libretroshare/src/util/radix64.h index 7776995f9..470186a02 100644 --- a/libretroshare/src/util/radix64.h +++ b/libretroshare/src/util/radix64.h @@ -1,3 +1,24 @@ +/******************************************************************************* + * libretroshare/src/util: radix64.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright (C) 2015 Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once #include diff --git a/libretroshare/src/util/retrodb.cc b/libretroshare/src/util/retrodb.cc index 9924bbf9d..5a903dd62 100644 --- a/libretroshare/src/util/retrodb.cc +++ b/libretroshare/src/util/retrodb.cc @@ -1,26 +1,24 @@ - -/* - * RetroShare : RetroDb functionality - * - * Copyright 2012-2013 Christopher Evi-Parker - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ +/******************************************************************************* + * libretroshare/src/util: retrodb.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012 Christopher Evi-Parker * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include #include diff --git a/libretroshare/src/util/retrodb.h b/libretroshare/src/util/retrodb.h index 435b6e466..8cf772c44 100644 --- a/libretroshare/src/util/retrodb.h +++ b/libretroshare/src/util/retrodb.h @@ -1,29 +1,27 @@ +/******************************************************************************* + * libretroshare/src/util: retrodb.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012 Christopher Evi-Parker * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RSSQLITE_H #define RSSQLITE_H -/* - * RetroShare : RetroDb functionality - * - * Copyright 2012 Christopher Evi-Parker - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - #ifdef NO_SQLCIPHER #include #else diff --git a/libretroshare/src/util/rsaes.h b/libretroshare/src/util/rsaes.h deleted file mode 100644 index 21a8c701c..000000000 --- a/libretroshare/src/util/rsaes.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * libretroshare/src/utils: rsaescrypt.h - * - * AES crptography for RetroShare. - * - * Copyright 2013 by Cyril Soler - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "csoler@users.sourceforge.net". - * - */ - -#include - -class RsAES -{ - public: - // Crypt/decrypt data using a 16 bytes key and a 8 bytes salt. - // - // output_data allocation is left to the client. The size should be at least RsAES::get_buffer_size(input_data_length) - // - // Return value: - // true: encryption/decryption ok - // - // false: encryption/decryption went bad. Check buffer size. - // - static bool aes_crypt_8_16(const uint8_t *input_data,uint32_t input_data_length,uint8_t key[16],uint8_t salt[8],uint8_t *output_data,uint32_t& output_data_length) ; - static bool aes_decrypt_8_16(const uint8_t *input_data,uint32_t input_data_length,uint8_t key[16],uint8_t salt[8],uint8_t *output_data,uint32_t& output_data_length) ; - - // computes the safe buffer size to store encrypted/decrypted data for the given input stream size - // - static uint32_t get_buffer_size(uint32_t size) ; -}; - diff --git a/libretroshare/src/util/rscompress.h b/libretroshare/src/util/rscompress.h deleted file mode 100644 index 0d11c3f47..000000000 --- a/libretroshare/src/util/rscompress.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * libretroshare/src/utils: rscompress.h - * - * Basic memory chunk compression, based on openpgp-sdk - * - * Copyright 2013 by Cyril Soler - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "csoler@users.sourceforge.net". - * - */ - -#pragma once - -class RsCompress -{ - public: - static bool compress_memory_chunk(const uint8_t *input_mem,const uint32_t input_size,uint8_t *& output_mem,uint32_t& output_size) ; - static bool uncompress_memory_chunk(const uint8_t *input_mem,const uint32_t input_size,uint8_t *& output_mem,uint32_t& output_size) ; -}; - diff --git a/libretroshare/src/util/rsdbbind.cc b/libretroshare/src/util/rsdbbind.cc index 31e548ebd..db5233ba8 100644 --- a/libretroshare/src/util/rsdbbind.cc +++ b/libretroshare/src/util/rsdbbind.cc @@ -1,26 +1,24 @@ -/* - * RetroShare : RetroDb functionality - * - * Copyright 2013 Christopher Evi-Parker - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/util: rsbdbind.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2013 Christopher Evi-Parker * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "rsdbbind.h" RsDoubleBind::RsDoubleBind(double value, int index) diff --git a/libretroshare/src/util/rsdbbind.h b/libretroshare/src/util/rsdbbind.h index 44c701157..aa41e5b3e 100644 --- a/libretroshare/src/util/rsdbbind.h +++ b/libretroshare/src/util/rsdbbind.h @@ -1,29 +1,27 @@ +/******************************************************************************* + * libretroshare/src/util: rsbdbind.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2013 Christopher Evi-Parker * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RSDBBIND_H_ #define RSDBBIND_H_ -/* - * RetroShare : RetroDb functionality - * - * Copyright 2013 Christopher Evi-Parker - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - #include #include diff --git a/libretroshare/src/util/rsdebug.cc b/libretroshare/src/util/rsdebug.cc index ab40c3035..434b06363 100644 --- a/libretroshare/src/util/rsdebug.cc +++ b/libretroshare/src/util/rsdebug.cc @@ -1,27 +1,24 @@ -/* - * "$Id: pqidebug.cc,v 1.6 2007-02-18 21:46:49 rmf24 Exp $" - * - * 3P/RS network interface for RetroShare. - * - * Copyright 2004-2006 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ +/******************************************************************************* + * libretroshare/src/util: rsdebug.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2008 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "util/rsdebug.h" #include "util/rsthreads.h" @@ -145,11 +142,12 @@ void rslog(const RsLog::logLvl lvl, RsLog::logInfo *info, const std::string &msg if(info->lvl == RsLog::None) return; - RsStackMutex stack(logMtx); /******** LOCKED ****************/ - bool process = info->lvl == RsLog::Default ? (lvl <= defaultLevel) : lvl <= info->lvl; - if(process) + if(!process) + return; + { + RsStackMutex stack(logMtx); /******** LOCKED ****************/ time_t t = time(NULL); if (debugMode == RS_DEBUG_LOGCRASH) @@ -182,6 +180,9 @@ void rslog(const RsLog::logLvl lvl, RsLog::logInfo *info, const std::string &msg fprintf(ofd, "(%s Z: %s, lvl: %u): %s \n", timestr2.c_str(), info->name.c_str(), (unsigned int)info->lvl, msg.c_str()); fflush(ofd); + + fprintf(stdout, "(%s Z: %s, lvl: %u): %s \n", + timestr2.c_str(), info->name.c_str(), (unsigned int)info->lvl, msg.c_str()); lineCount++; } } diff --git a/libretroshare/src/util/rsdebug.h b/libretroshare/src/util/rsdebug.h index abf39e4b0..dd054822c 100644 --- a/libretroshare/src/util/rsdebug.h +++ b/libretroshare/src/util/rsdebug.h @@ -1,29 +1,24 @@ -/* - * libretroshare/src/util: rsdebug.h - * - * Debug interface for RetroShare. - * - * Copyright 2004-2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - +/******************************************************************************* + * libretroshare/src/util: rsdebug.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2008 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ /* Moved from pqi/ to util/ so it can be used more generally. */ diff --git a/libretroshare/src/util/rsdeprecate.h b/libretroshare/src/util/rsdeprecate.h index 4d44e208e..560f91c44 100644 --- a/libretroshare/src/util/rsdeprecate.h +++ b/libretroshare/src/util/rsdeprecate.h @@ -1,21 +1,25 @@ +/******************************************************************************* + * libretroshare/src/util: rsdebug.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright (C) 2016 Gioacchino Mazzurco * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once -/* - * RetroShare deprecation macros - * Copyright (C) 2016 Gioacchino Mazzurco - * - * 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 . - */ #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) # define RS_DEPRECATED __attribute__((__deprecated__)) diff --git a/libretroshare/src/util/rsdir.cc b/libretroshare/src/util/rsdir.cc index e1c1cf4ab..a890ed8f1 100644 --- a/libretroshare/src/util/rsdir.cc +++ b/libretroshare/src/util/rsdir.cc @@ -1,28 +1,24 @@ - -/* - * "$Id: rsdir.cc,v 1.1 2007-02-19 20:08:30 rmf24 Exp $" - * - * RetroShare C++ Interface. - * - * Copyright 2004-2007 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ +/******************************************************************************* + * libretroshare/src/util: rsdir.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2007 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ // Includes for directory creation. #include diff --git a/libretroshare/src/util/rsdir.h b/libretroshare/src/util/rsdir.h index ef95e100e..b6ef4891d 100644 --- a/libretroshare/src/util/rsdir.h +++ b/libretroshare/src/util/rsdir.h @@ -1,29 +1,24 @@ - -/* - * "$Id: rsdir.h,v 1.1 2007-02-19 20:08:30 rmf24 Exp $" - * - * RetroShare C++ Interface. - * - * Copyright 2004-2007 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/util: rsdir.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2007 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RSUTIL_DIRFNS_H #define RSUTIL_DIRFNS_H diff --git a/libretroshare/src/util/rsdiscspace.cc b/libretroshare/src/util/rsdiscspace.cc index 25a764b14..bf89d30bb 100644 --- a/libretroshare/src/util/rsdiscspace.cc +++ b/libretroshare/src/util/rsdiscspace.cc @@ -1,35 +1,31 @@ -/* - * libretroshare/src/util: rsdiscspace.cc - * - * Universal Networking Header for RetroShare. - * - * Copyright 2010-2010 by Cyril Soler. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "csoler@users.sourceforge.net". - * - */ - +/******************************************************************************* + * libretroshare/src/util: rsdiscspace.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2010-2010 by Cyril Soler * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include #include #include #include "rsserver/p3face.h" #include "retroshare/rsfiles.h" #include "retroshare/rsiface.h" -#include "rsserver/rsaccounts.h" +#include "retroshare/rsinit.h" #include "rsdiscspace.h" #include @@ -170,13 +166,13 @@ bool RsDiscSpace::checkForDiscSpace(RsDiscSpace::DiscLocation loc) #endif break ; - case RS_CONFIG_DIRECTORY: rs = crossSystemDiskStats(rsAccounts->PathAccountDirectory().c_str(),free_blocks,block_size) ; + case RS_CONFIG_DIRECTORY: rs = crossSystemDiskStats(RsAccounts::AccountDirectory().c_str(),free_blocks,block_size) ; #ifdef DEBUG_RSDISCSPACE std::cerr << " path = " << RsInit::RsConfigDirectory() << std::endl ; #endif break ; - case RS_PGP_DIRECTORY: rs = crossSystemDiskStats(rsAccounts->PathPGPDirectory().c_str(),free_blocks,block_size) ; + case RS_PGP_DIRECTORY: rs = crossSystemDiskStats(RsAccounts::PGPDirectory().c_str(),free_blocks,block_size) ; #ifdef DEBUG_RSDISCSPACE std::cerr << " path = " << RsInit::RsPGPDirectory() << std::endl ; #endif diff --git a/libretroshare/src/util/rsdiscspace.h b/libretroshare/src/util/rsdiscspace.h index 1e01ebe3f..1262fd5e4 100644 --- a/libretroshare/src/util/rsdiscspace.h +++ b/libretroshare/src/util/rsdiscspace.h @@ -1,28 +1,24 @@ -/* - * libretroshare/src/util: rsdiscspace.h - * - * Universal Networking Header for RetroShare. - * - * Copyright 2010-2010 by Cyril Soler. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "csoler@users.sourceforge.net". - * - */ - +/******************************************************************************* + * libretroshare/src/util: rsdiscspace.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2010-2010 by Cyril Soler * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once #include diff --git a/libretroshare/src/util/rsexpr.cc b/libretroshare/src/util/rsexpr.cc index 73d441325..801e4fcb0 100644 --- a/libretroshare/src/util/rsexpr.cc +++ b/libretroshare/src/util/rsexpr.cc @@ -128,7 +128,7 @@ static bool StrContains( const std::string & str1, const std::string & str2, } -std::string StringExpression::toStdString(const std::string& varstr) const +std::string StringExpression::toStdStringWithParam(const std::string& varstr) const { std::string strlist ; for (auto iter = terms.begin(); iter != terms.end(); ++iter ) diff --git a/libretroshare/src/util/rsinitedptr.h b/libretroshare/src/util/rsinitedptr.h index a1d346ba0..333a8af87 100644 --- a/libretroshare/src/util/rsinitedptr.h +++ b/libretroshare/src/util/rsinitedptr.h @@ -1,3 +1,25 @@ +/******************************************************************************* + * libretroshare/src/util: rsinitedptr.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2010-2010 by Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ + #pragma once /** helper class to store a pointer diff --git a/libretroshare/src/util/rsjson.cc b/libretroshare/src/util/rsjson.cc new file mode 100644 index 000000000..37f6282e4 --- /dev/null +++ b/libretroshare/src/util/rsjson.cc @@ -0,0 +1,68 @@ +/******************************************************************************* + * * + * libretroshare: retroshare core library * + * * + * Copyright (C) 2018 Gioacchino Mazzurco * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ + +#include "util/rsjson.h" + +#ifdef HAS_RAPIDJSON +# include +# include +# include +#else +# include +# include +# include +#endif // HAS_RAPIDJSON + + +inline int getJsonManipulatorStatePosition() +{ + static int p = std::ios_base::xalloc(); + return p; +} + +std::ostream& compactJSON(std::ostream &out) +{ + out.iword(getJsonManipulatorStatePosition()) = 1; + return out; +} + +std::ostream& prettyJSON(std::ostream &out) +{ + out.iword(getJsonManipulatorStatePosition()) = 0; + return out; +} + +std::ostream& operator<<(std::ostream &out, const RsJson &jDoc) +{ + rapidjson::StringBuffer buffer; buffer.Clear(); + if(out.iword(getJsonManipulatorStatePosition())) + { + rapidjson::Writer writer(buffer); + jDoc.Accept(writer); + } + else + { + rapidjson::PrettyWriter writer(buffer); + jDoc.Accept(writer); + } + + return out << buffer.GetString(); +} diff --git a/libretroshare/src/util/rsjson.h b/libretroshare/src/util/rsjson.h new file mode 100644 index 000000000..c52584b7e --- /dev/null +++ b/libretroshare/src/util/rsjson.h @@ -0,0 +1,56 @@ +/******************************************************************************* + * * + * libretroshare: retroshare core library * + * * + * Copyright (C) 2018 Gioacchino Mazzurco * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ +#pragma once + +#include + +#ifdef HAS_RAPIDJSON +# include +#else +# include +#endif // HAS_RAPIDJSON + +/** + * Use this type for JSON documents representations in RetroShare code + */ +typedef rapidjson::Document RsJson; + +/** + * Print out RsJson to a stream, use std::stringstream to get the string + * @param[out] out output stream + * @param[in] jDoc JSON document to print + * @return same output stream passed as out parameter + */ +std::ostream &operator<<(std::ostream &out, const RsJson &jDoc); + +/** + * Stream manipulator to print RsJson in compact format + * @param[out] out output stream + * @return same output stream passed as out parameter + */ +std::ostream& compactJSON(std::ostream &out); + +/** + * Stream manipulator to print RsJson in human readable format + * @param[out] out output stream + * @return same output stream passed as out parameter + */ +std::ostream& prettyJSON(std::ostream &out); diff --git a/libretroshare/src/util/rsmemcache.h b/libretroshare/src/util/rsmemcache.h index 03ce9f44a..a0d188295 100644 --- a/libretroshare/src/util/rsmemcache.h +++ b/libretroshare/src/util/rsmemcache.h @@ -1,27 +1,24 @@ -/* - * libretroshare/src/util: rsmemcache.h - * - * Identity interface for RetroShare. - * - * Copyright 2012-2012 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ +/******************************************************************************* + * libretroshare/src/util: rsmemcache.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012-2012 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RS_UTIL_MEM_CACHE #define RS_UTIL_MEM_CACHE diff --git a/libretroshare/src/util/rsmemory.cc b/libretroshare/src/util/rsmemory.cc index 6aab9dfef..2b162c77d 100644 --- a/libretroshare/src/util/rsmemory.cc +++ b/libretroshare/src/util/rsmemory.cc @@ -1,3 +1,24 @@ +/******************************************************************************* + * libretroshare/src/util: rsmemory.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012-2012 by Cyril Soler * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "util/rsmemory.h" void *rs_malloc(size_t size) diff --git a/libretroshare/src/util/rsmemory.h b/libretroshare/src/util/rsmemory.h index 7da4245c4..b46e12ad1 100644 --- a/libretroshare/src/util/rsmemory.h +++ b/libretroshare/src/util/rsmemory.h @@ -1,3 +1,24 @@ +/******************************************************************************* + * libretroshare/src/util: rsmemory.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012-2012 by Cyril Soler * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once #include diff --git a/libretroshare/src/util/rsnet.cc b/libretroshare/src/util/rsnet.cc index 565185edc..d7d60241a 100644 --- a/libretroshare/src/util/rsnet.cc +++ b/libretroshare/src/util/rsnet.cc @@ -1,28 +1,25 @@ -/* - * libretroshare/src/util: rsnet.cc - * - * Universal Networking Header for RetroShare. - * - * Copyright 2007-2008 by Robert Fernie. - * Copyright (C) 2015-2018 Gioacchino Mazzurco - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ +/******************************************************************************* + * libretroshare/src/util: rsnet.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2006 Robert Fernie * + * Copyright 2015-2018 Gioacchino Mazzurco * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "util/rsnet.h" #include "util/rsthreads.h" diff --git a/libretroshare/src/util/rsnet.h b/libretroshare/src/util/rsnet.h index 101cdfa5a..74a1663fa 100644 --- a/libretroshare/src/util/rsnet.h +++ b/libretroshare/src/util/rsnet.h @@ -1,29 +1,25 @@ -/* - * libretroshare/src/util: rsnet.h - * - * Universal Networking Header for RetroShare. - * - * Copyright 2004-2006 by Robert Fernie. - * Copyright (C) 2015-2018 Gioacchino Mazzurco - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/util: rsnet.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2006 Robert Fernie * + * Copyright 2015-2018 Gioacchino Mazzurco * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RS_UNIVERSAL_NETWORK_HEADER #define RS_UNIVERSAL_NETWORK_HEADER diff --git a/libretroshare/src/util/rsnet_ss.cc b/libretroshare/src/util/rsnet_ss.cc index bc6d4bafb..c084f516e 100644 --- a/libretroshare/src/util/rsnet_ss.cc +++ b/libretroshare/src/util/rsnet_ss.cc @@ -1,28 +1,25 @@ -/* - * libretroshare/src/util: rsnet_ss.cc - * - * sockaddr_storage functions for RetroShare. - * - * Copyright 2013-2013 by Robert Fernie. - * Copyright (C) 2015-2018 Gioacchino Mazzurco - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ +/******************************************************************************* + * libretroshare/src/util: rsnet_ss.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2006 Robert Fernie * + * Copyright 2015-2018 Gioacchino Mazzurco * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "util/rsurl.h" diff --git a/libretroshare/src/util/rsprint.cc b/libretroshare/src/util/rsprint.cc index c87fc02f7..dca3d925c 100644 --- a/libretroshare/src/util/rsprint.cc +++ b/libretroshare/src/util/rsprint.cc @@ -1,28 +1,24 @@ - -/* - * libretroshare/src/util: rsprint.cc - * - * RetroShare Utilities - * - * Copyright 2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ +/******************************************************************************* + * libretroshare/src/util: rsprint.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2008-2008 Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "util/rsprint.h" #include "util/rsstring.h" diff --git a/libretroshare/src/util/rsprint.h b/libretroshare/src/util/rsprint.h index 3ab70a411..58a0b7f89 100644 --- a/libretroshare/src/util/rsprint.h +++ b/libretroshare/src/util/rsprint.h @@ -1,30 +1,24 @@ - -/* - * libretroshare/src/util: rsprint.h - * - * RetroShare Utilities - * - * Copyright 2008 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - +/******************************************************************************* + * libretroshare/src/util: rsprint.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2008-2008 Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RSUTIL_PRINTFNS_H #define RSUTIL_PRINTFNS_H diff --git a/libretroshare/src/util/rsrandom.cc b/libretroshare/src/util/rsrandom.cc index 03c8a95d9..86f93bf5f 100644 --- a/libretroshare/src/util/rsrandom.cc +++ b/libretroshare/src/util/rsrandom.cc @@ -1,3 +1,24 @@ +/******************************************************************************* + * libretroshare/src/util: rsrandom.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright (C) 2010 Cyril Soler * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include #include #include @@ -35,6 +56,10 @@ bool RSRandom::seed(uint32_t s) for (j=1; j> 30)) + j) & 0xffffffffUL ; + // This *does not* replace the internal seed state of RAND_bytes(), but only *adds* entropy to the random pool + // So calling this method with the same value twice does not guarranty that the output of the random bytes + // will be the same. + RAND_seed((unsigned char *)&MT[0],N*sizeof(uint32_t)) ; locked_next_state() ; @@ -66,11 +91,13 @@ uint32_t RSRandom::random_u32() y = MT[index] ; } +#ifdef UNNECESSARY_CODE // Tempering y ^= (y >> 11); y ^= (y << 7 ) & 0x9d2c5680UL; y ^= (y << 15) & 0xefc60000UL; y ^= (y >> 18); +#endif return y; } diff --git a/libretroshare/src/util/rsrandom.h b/libretroshare/src/util/rsrandom.h index 8cd66f7f6..59c488909 100644 --- a/libretroshare/src/util/rsrandom.h +++ b/libretroshare/src/util/rsrandom.h @@ -1,36 +1,31 @@ -/**************************************************************** - * RetroShare is distributed under the following license: - * - * Copyright (C) 2010 Cyril Soler - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * 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 General Public License for more details. - * - * 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, - * Boston, MA 02110-1301, USA. - ****************************************************************/ - +/******************************************************************************* + * libretroshare/src/util: rsrandom.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright (C) 2010 Cyril Soler * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once // RSRandom contains a random number generator that is // - thread safe // - system independant // - fast -// - NOT CRYPTOGRAPHICALLY SAFE -// - DO NOT USE FOR ANYTHING REQUIRING STRONG RANDOMNESS -// -// The implementation is adapted from the Mersenne Twister page of Wikipedia. -// -// http://en.wikipedia.org/wiki/Mersenne_twister +// - CRYPTOGRAPHICALLY SAFE, because it is based on openssl random number generator #include #include @@ -40,8 +35,8 @@ class RSRandom public: static uint32_t random_u32() ; static uint64_t random_u64() ; - static float random_f32() ; - static double random_f64() ; + static float random_f32() ; + static double random_f64() ; static bool seed(uint32_t s) ; diff --git a/libretroshare/src/util/rsrecogn.cc b/libretroshare/src/util/rsrecogn.cc index 2b6e51caa..581ec9268 100644 --- a/libretroshare/src/util/rsrecogn.cc +++ b/libretroshare/src/util/rsrecogn.cc @@ -1,28 +1,24 @@ -/* - * libretroshare/src/util: rsrecogn.cc - * - * RetroShare Utilities - * - * Copyright 2013 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/util: rsrandom.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright (C) 2013 Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "pqi/pqi_base.h" #include "util/rsrecogn.h" diff --git a/libretroshare/src/util/rsrecogn.h b/libretroshare/src/util/rsrecogn.h index 4f7b7cd2e..7cc33ec76 100644 --- a/libretroshare/src/util/rsrecogn.h +++ b/libretroshare/src/util/rsrecogn.h @@ -1,29 +1,24 @@ - -/* - * libretroshare/src/util: rsrecogn.h - * - * RetroShare Utilities - * - * Copyright 2013 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/util: rsrandom.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright (C) 2013 Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RSUTIL_RECOGN_H #define RSUTIL_RECOGN_H diff --git a/libretroshare/src/util/rsstd.h b/libretroshare/src/util/rsstd.h index b2ff78887..8a41a3270 100644 --- a/libretroshare/src/util/rsstd.h +++ b/libretroshare/src/util/rsstd.h @@ -1,24 +1,24 @@ -/**************************************************************** - * This file is distributed under the following license: - * - * Copyright (c) 2015, RetroShare Team - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * 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 General Public License for more details. - * - * 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, - * Boston, MA 02110-1301, USA. - ****************************************************************/ - +/******************************************************************************* + * libretroshare/src/util: rsstd.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright (C) 2015 Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RSSTD_H_ #define RSSTD_H_ diff --git a/libretroshare/src/util/rsstring.cc b/libretroshare/src/util/rsstring.cc index fe29bca92..db7000cec 100644 --- a/libretroshare/src/util/rsstring.cc +++ b/libretroshare/src/util/rsstring.cc @@ -1,24 +1,24 @@ -/**************************************************************** - * This file is distributed under the following license: - * - * Copyright (c) 2010, Thomas Kister - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * 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 General Public License for more details. - * - * 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, - * Boston, MA 02110-1301, USA. - ****************************************************************/ - +/******************************************************************************* + * libretroshare/src/util: rsstd.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright (c) 2010, Thomas Kister * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "rsstring.h" #ifdef WINDOWS_SYS diff --git a/libretroshare/src/util/rsstring.h b/libretroshare/src/util/rsstring.h index 0e9df964f..93553885e 100644 --- a/libretroshare/src/util/rsstring.h +++ b/libretroshare/src/util/rsstring.h @@ -1,24 +1,24 @@ -/**************************************************************** - * This file is distributed under the following license: - * - * Copyright (c) 2010, Thomas Kister - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * 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 General Public License for more details. - * - * 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, - * Boston, MA 02110-1301, USA. - ****************************************************************/ - +/******************************************************************************* + * libretroshare/src/util: rsstd.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright (c) 2010, Thomas Kister * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RSSTRING_H_ #define RSSTRING_H_ diff --git a/libretroshare/src/util/rsthreads.cc b/libretroshare/src/util/rsthreads.cc index 65fcad4b7..755134817 100644 --- a/libretroshare/src/util/rsthreads.cc +++ b/libretroshare/src/util/rsthreads.cc @@ -1,28 +1,24 @@ - -/* - * "$Id: rsthreads.cc,v 1.1 2007-02-19 20:08:30 rmf24 Exp $" - * - * RetroShare C++ Interface. - * - * Copyright 2004-2007 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ +/******************************************************************************* + * libretroshare/src/util: rsthreads.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2007 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "rsthreads.h" #include // for usleep() diff --git a/libretroshare/src/util/rsthreads.h b/libretroshare/src/util/rsthreads.h index 0dfbc4c44..dfad45e2c 100644 --- a/libretroshare/src/util/rsthreads.h +++ b/libretroshare/src/util/rsthreads.h @@ -1,28 +1,24 @@ -/* - * "$Id: rsthreads.h,v 1.1 2007-02-19 20:08:30 rmf24 Exp $" - * - * RetroShare C++ Interface. - * - * Copyright 2004-2006 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/util: rsthreads.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2004-2006 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once #include diff --git a/libretroshare/src/util/rstickevent.cc b/libretroshare/src/util/rstickevent.cc index 0da21cf4d..4c9cdc37b 100644 --- a/libretroshare/src/util/rstickevent.cc +++ b/libretroshare/src/util/rstickevent.cc @@ -1,28 +1,24 @@ -/* - * libretroshare/src/util: rstickevent.cc - * - * Identity interface for RetroShare. - * - * Copyright 2012-2012 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/util: rstickevent.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012-2012 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "util/rstickevent.h" #include diff --git a/libretroshare/src/util/rstickevent.h b/libretroshare/src/util/rstickevent.h index 1b26c6b43..4b08d9139 100644 --- a/libretroshare/src/util/rstickevent.h +++ b/libretroshare/src/util/rstickevent.h @@ -1,27 +1,24 @@ -/* - * libretroshare/src/util: rstickevent.h - * - * Identity interface for RetroShare. - * - * Copyright 2012-2012 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ +/******************************************************************************* + * libretroshare/src/util: rstickevent.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2012-2012 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef RS_UTIL_TICK_EVENT #define RS_UTIL_TICK_EVENT diff --git a/libretroshare/src/util/rstime.cc b/libretroshare/src/util/rstime.cc index 9733ac55d..d2180775e 100644 --- a/libretroshare/src/util/rstime.cc +++ b/libretroshare/src/util/rstime.cc @@ -1,28 +1,24 @@ -/* - * libretroshare/src/util: rsscopetimer.cc - * - * 3P/PQI network interface for RetroShare. - * - * Copyright 2013- by Cyril Soler - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/util: rstime.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2013-2013 by Cyril Soler * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include #include #include diff --git a/libretroshare/src/util/rstime.h b/libretroshare/src/util/rstime.h index 4359a28ff..a9b3dfd5b 100644 --- a/libretroshare/src/util/rstime.h +++ b/libretroshare/src/util/rstime.h @@ -1,28 +1,24 @@ -/* - * libretroshare/src/util: rsscopetimer.h - * - * 3P/PQI network interface for RetroShare. - * - * Copyright 2013- by Cyril Soler - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - +/******************************************************************************* + * libretroshare/src/util: rstime.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2013-2013 by Cyril Soler * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include namespace rstime { diff --git a/libretroshare/src/util/rsversioninfo.cc b/libretroshare/src/util/rsversioninfo.cc index 04f03322f..6e48d3939 100644 --- a/libretroshare/src/util/rsversioninfo.cc +++ b/libretroshare/src/util/rsversioninfo.cc @@ -1,10 +1,24 @@ -/* - * rsversion.cc - * - * Created on: Jun 23, 2009 - * Author: alexandrut - */ - +/******************************************************************************* + * libretroshare/src/util: rsversioninfo.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2013-2013 by Alexandrut * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "rsversioninfo.h" #include "retroshare/rsversion.h" #include "rsstring.h" diff --git a/libretroshare/src/util/rsversioninfo.h b/libretroshare/src/util/rsversioninfo.h index 3cc331aca..041839b21 100644 --- a/libretroshare/src/util/rsversioninfo.h +++ b/libretroshare/src/util/rsversioninfo.h @@ -1,10 +1,24 @@ -/* - * rsversion.h - * - * Created on: Jun 23, 2009 - * Author: alexandrut - */ - +/******************************************************************************* + * libretroshare/src/util: rsversioninfo.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2013-2013 by Alexandrut * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include #include diff --git a/libretroshare/src/util/rswin.cc b/libretroshare/src/util/rswin.cc deleted file mode 100644 index 6476c6faf..000000000 --- a/libretroshare/src/util/rswin.cc +++ /dev/null @@ -1 +0,0 @@ -#include "util/rswin.h" diff --git a/libretroshare/src/util/rswin.h b/libretroshare/src/util/rswin.h index eba97f428..22e2ead96 100644 --- a/libretroshare/src/util/rswin.h +++ b/libretroshare/src/util/rswin.h @@ -1,24 +1,24 @@ -/**************************************************************** - * This file is distributed under the following license: - * - * Copyright (c) 2010, Thomas Kister - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * 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 General Public License for more details. - * - * 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, - * Boston, MA 02110-1301, USA. - ****************************************************************/ - +/******************************************************************************* + * libretroshare/src/util: rswin.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright (c) 2010, Thomas Kister * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ /** * This file provides helper functions for the windows environment diff --git a/libretroshare/src/util/smallobject.cc b/libretroshare/src/util/smallobject.cc index baf8ee357..3e1759fed 100644 --- a/libretroshare/src/util/smallobject.cc +++ b/libretroshare/src/util/smallobject.cc @@ -1,3 +1,24 @@ +/******************************************************************************* + * libretroshare/src/util: smallobject.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright (c) 2011, Cyril Soler * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include #include "smallobject.h" #include "util/rsthreads.h" diff --git a/libretroshare/src/util/smallobject.h b/libretroshare/src/util/smallobject.h index a5b11bcc9..2f3ac592c 100644 --- a/libretroshare/src/util/smallobject.h +++ b/libretroshare/src/util/smallobject.h @@ -1,28 +1,24 @@ -/* - * libretroshare/src/util: smallobject.h - * - * Universal Networking Header for RetroShare. - * - * Copyright 2011 by Cyril Soler - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "cyril.soler@users.sourceforge.net". - * - */ - +/******************************************************************************* + * libretroshare/src/util: smallobject.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright (c) 2011, Cyril Soler * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #pragma once #include diff --git a/libretroshare/src/util/stacktrace.h b/libretroshare/src/util/stacktrace.h index 48ab2527d..f7284e7f9 100644 --- a/libretroshare/src/util/stacktrace.h +++ b/libretroshare/src/util/stacktrace.h @@ -1,25 +1,25 @@ -/* - * stacktrace.h - * - * Copyright (C) 2016 Gioacchino Mazzurco - * Copyright (C) 2008 Timo Bingmann http://idlebox.net/ - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - */ - +/******************************************************************************* + * libretroshare/src/util: smallobject.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright (C) 2016 Gioacchino Mazzurco * + * Copyright (C) 2008 Timo Bingmann http://idlebox.net/ * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef _STACKTRACE_H_ #define _STACKTRACE_H_ diff --git a/libretroshare/src/zeroconf/p3zcnatassist.cc b/libretroshare/src/zeroconf/p3zcnatassist.cc index 1e35de50b..9e3ed5e58 100644 --- a/libretroshare/src/zeroconf/p3zcnatassist.cc +++ b/libretroshare/src/zeroconf/p3zcnatassist.cc @@ -1,29 +1,24 @@ -/* - * libretroshare/src/zeroconf: p3zeroconf.cc - * - * ZeroConf interface for RetroShare. - * - * Copyright 2011-2011 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - +/******************************************************************************* + * libretroshare/src/zeroconf: p3zcnatassist.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2011-2012 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "zeroconf/p3zeroconf.h" #include "zeroconf/p3zcnatassist.h" diff --git a/libretroshare/src/zeroconf/p3zcnatassist.h b/libretroshare/src/zeroconf/p3zcnatassist.h index ad92d9a2a..9e5bcc313 100644 --- a/libretroshare/src/zeroconf/p3zcnatassist.h +++ b/libretroshare/src/zeroconf/p3zcnatassist.h @@ -1,29 +1,24 @@ -/* - * libretroshare/src/zeroconf: p3zcnatassist.h - * - * ZeroConf interface for RetroShare. - * - * Copyright 2011-2012 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - +/******************************************************************************* + * libretroshare/src/zeroconf: p3zcnatassist.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2011-2012 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef MRK_P3_ZC_NAT_ASSIST_H #define MRK_P3_ZC_NAT_ASSIST_H diff --git a/libretroshare/src/zeroconf/p3zeroconf.cc b/libretroshare/src/zeroconf/p3zeroconf.cc index b4417ddbd..65aedc7f6 100644 --- a/libretroshare/src/zeroconf/p3zeroconf.cc +++ b/libretroshare/src/zeroconf/p3zeroconf.cc @@ -1,29 +1,24 @@ -/* - * libretroshare/src/zeroconf: p3zeroconf.cc - * - * ZeroConf interface for RetroShare. - * - * Copyright 2011-2011 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - +/******************************************************************************* + * libretroshare/src/zeroconf: p3zeroconf.cc * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2011-2012 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #include "zeroconf/p3zeroconf.h" #include #include diff --git a/libretroshare/src/zeroconf/p3zeroconf.h b/libretroshare/src/zeroconf/p3zeroconf.h index 46365633b..9b7e21b5c 100644 --- a/libretroshare/src/zeroconf/p3zeroconf.h +++ b/libretroshare/src/zeroconf/p3zeroconf.h @@ -1,29 +1,24 @@ -/* - * libretroshare/src/zeroconf: p3zeroconf.h - * - * ZeroConf interface for RetroShare. - * - * Copyright 2011-2011 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - +/******************************************************************************* + * libretroshare/src/zeroconf: p3zeroconf.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright 2011-2012 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ #ifndef MRK_P3_ZEROCONF_H #define MRK_P3_ZEROCONF_H diff --git a/openpgpsdk/src/use_openpgpsdk.pri b/openpgpsdk/src/use_openpgpsdk.pri index adf10f1ca..800781a3c 100644 --- a/openpgpsdk/src/use_openpgpsdk.pri +++ b/openpgpsdk/src/use_openpgpsdk.pri @@ -1,3 +1,20 @@ +################################################################################ +# use_openpgpsdk.pri # +# Copyright (C) 2018, Retroshare team # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU Lesser 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 Lesser General Public License for more details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with this program. If not, see . # +################################################################################ DEPENDPATH *= $$system_path($$clean_path($${PWD}/../../openpgpsdk/src)) INCLUDEPATH *= $$system_path($$clean_path($${PWD}/../../openpgpsdk/src)) LIBS *= -L$$system_path($$clean_path($${OUT_PWD}/../../openpgpsdk/src/lib/)) -lops diff --git a/plugins/FeedReader/services/p3FeedReader.cc b/plugins/FeedReader/services/p3FeedReader.cc index 256a1e285..b964e0a74 100644 --- a/plugins/FeedReader/services/p3FeedReader.cc +++ b/plugins/FeedReader/services/p3FeedReader.cc @@ -2229,11 +2229,11 @@ bool p3FeedReader::waitForToken(uint32_t token) while (!mStopped) { uint32_t status = service->requestStatus(token); - if (status == RsTokenService::GXS_REQUEST_V2_STATUS_FAILED) { + if (status == RsTokenService::FAILED) { break; } - if (status == RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) { + if (status == RsTokenService::COMPLETE) { return true; } diff --git a/plugins/VOIP/VOIPPlugin.cpp b/plugins/VOIP/VOIPPlugin.cpp index bc4129e7f..96be0d3ac 100644 --- a/plugins/VOIP/VOIPPlugin.cpp +++ b/plugins/VOIP/VOIPPlugin.cpp @@ -216,7 +216,7 @@ QTranslator* VOIPPlugin::qt_translator(QApplication */*app*/, const QString& lan void VOIPPlugin::qt_sound_events(SoundEvents &events) const { - QDir baseDir = QDir(QString::fromUtf8(RsAccounts::DataDirectory().c_str()) + "/sounds"); + QDir baseDir = QDir(QString::fromUtf8(RsAccounts::systemDataDirectory().c_str()) + "/sounds"); events.addEvent(QApplication::translate("VOIP", "VOIP") , QApplication::translate("VOIP", "Incoming audio call") diff --git a/retroshare-android-service/src/service.cpp b/retroshare-android-service/src/service.cpp index 4c36916e7..83381975c 100644 --- a/retroshare-android-service/src/service.cpp +++ b/retroshare-android-service/src/service.cpp @@ -30,6 +30,22 @@ #include "api/ApiServerLocal.h" #include "api/RsControlModule.h" +#ifdef RS_JSONAPI +# include "jsonapi/jsonapi.h" +# include "retroshare/rsiface.h" + +JsonApiServer jas(9092, [](int ec) +{ + RsControl::instance()->rsGlobalShutDown(); + QCoreApplication::exit(ec); +}); + +void exitGracefully(int ec) { jas.shutdown(ec); } + +#else // ifdef RS_JSONAPI +void exitGracefully(int ec) { QCoreApplication::exit(ec); } +#endif // ifdef RS_JSONAPI + using namespace resource_api; int main(int argc, char *argv[]) @@ -40,12 +56,13 @@ int main(int argc, char *argv[]) QCoreApplication app(argc, argv); - signal(SIGINT, &QCoreApplication::exit); - signal(SIGTERM, &QCoreApplication::exit); + signal(SIGINT, exitGracefully); + signal(SIGTERM, exitGracefully); #ifdef SIGBREAK - signal(SIGBREAK, &QCoreApplication::exit); -#endif // def SIGBREAK + signal(SIGBREAK, exitGracefully); +#endif // ifdef SIGBREAK +#ifdef LIBRESAPI_LOCAL_SERVER ApiServer api; RsControlModule ctrl_mod(argc, argv, api.getStateTokenServer(), &api, true); api.addResourceHandler( @@ -53,7 +70,6 @@ int main(int argc, char *argv[]) dynamic_cast(&ctrl_mod), &resource_api::RsControlModule::handleRequest); - QString sockPath = QDir::homePath() + "/.retroshare"; sockPath.append("/libresapi.sock"); qDebug() << "Listening on:" << sockPath; @@ -64,9 +80,16 @@ int main(int argc, char *argv[]) QTimer shouldExitTimer; shouldExitTimer.setTimerType(Qt::VeryCoarseTimer); shouldExitTimer.setInterval(1000); - QObject::connect( &shouldExitTimer, &QTimer::timeout, [&](){ - if(ctrl_mod.processShouldExit()) app.quit(); } ); + QObject::connect( &shouldExitTimer, &QTimer::timeout, [&]() + { if(ctrl_mod.processShouldExit()) exitGracefully(0); } ); shouldExitTimer.start(); +#else +# error retroshare-android-service need CONFIG+=libresapilocalserver to build +#endif + +#ifdef RS_JSONAPI + jas.start(); +#endif return app.exec(); } diff --git a/retroshare-gui/src/TorControl/TorControl.h b/retroshare-gui/src/TorControl/TorControl.h index 4a47384fa..5d208656e 100644 --- a/retroshare-gui/src/TorControl/TorControl.h +++ b/retroshare-gui/src/TorControl/TorControl.h @@ -67,17 +67,17 @@ public: enum Status { Error = -1, - NotConnected, - Connecting, - Authenticating, - Connected + NotConnected = 0x00, + Connecting = 0x01, + Authenticating = 0x02, + Connected = 0x03 }; enum TorStatus { - TorUnknown, - TorOffline, - TorReady + TorUnknown = 0x00, + TorOffline = 0x01, + TorReady = 0x02 }; diff --git a/retroshare-gui/src/TorControl/TorManager.cpp b/retroshare-gui/src/TorControl/TorManager.cpp index 96c45b88b..b538964e9 100644 --- a/retroshare-gui/src/TorControl/TorManager.cpp +++ b/retroshare-gui/src/TorControl/TorManager.cpp @@ -118,12 +118,17 @@ TorProcess *TorManager::process() return d->process; } -QString TorManager::dataDirectory() const +bool TorManager::isTorAvailable() +{ + return !instance()->d->torExecutablePath().isNull(); +} + +QString TorManager::torDataDirectory() const { return d->dataDir; } -void TorManager::setDataDirectory(const QString &path) +void TorManager::setTorDataDirectory(const QString &path) { d->dataDir = QDir::fromNativeSeparators(path); diff --git a/retroshare-gui/src/TorControl/TorManager.h b/retroshare-gui/src/TorControl/TorManager.h index d81d60d57..3db1036d3 100644 --- a/retroshare-gui/src/TorControl/TorManager.h +++ b/retroshare-gui/src/TorControl/TorManager.h @@ -58,18 +58,18 @@ class TorManager : public QObject Q_PROPERTY(Tor::TorControl* control READ control CONSTANT) Q_PROPERTY(bool hasError READ hasError NOTIFY errorChanged) Q_PROPERTY(QString errorMessage READ errorMessage NOTIFY errorChanged) - Q_PROPERTY(QString dataDirectory READ dataDirectory WRITE setDataDirectory) + Q_PROPERTY(QString torDataDirectory READ torDataDirectory WRITE setTorDataDirectory) public: - - explicit TorManager(QObject *parent = 0); + static bool isTorAvailable() ; static TorManager *instance(); TorProcess *process(); TorControl *control(); - QString dataDirectory() const; - void setDataDirectory(const QString &path); + + QString torDataDirectory() const; + void setTorDataDirectory(const QString &path); QString hiddenServiceDirectory() const; void setHiddenServiceDirectory(const QString &path); @@ -100,6 +100,7 @@ signals: void errorChanged(); private: + explicit TorManager(QObject *parent = 0); TorManagerPrivate *d; }; diff --git a/retroshare-gui/src/cmark_export.h b/retroshare-gui/src/cmark_export.h new file mode 100644 index 000000000..333e5d542 --- /dev/null +++ b/retroshare-gui/src/cmark_export.h @@ -0,0 +1,42 @@ + +#ifndef CMARK_EXPORT_H +#define CMARK_EXPORT_H + +#ifdef CMARK_STATIC_DEFINE +# define CMARK_EXPORT +# define CMARK_NO_EXPORT +#else +# ifndef CMARK_EXPORT +# ifdef libcmark_EXPORTS + /* We are building this library */ +# define CMARK_EXPORT __attribute__((visibility("default"))) +# else + /* We are using this library */ +# define CMARK_EXPORT __attribute__((visibility("default"))) +# endif +# endif + +# ifndef CMARK_NO_EXPORT +# define CMARK_NO_EXPORT __attribute__((visibility("hidden"))) +# endif +#endif + +#ifndef CMARK_DEPRECATED +# define CMARK_DEPRECATED __attribute__ ((__deprecated__)) +#endif + +#ifndef CMARK_DEPRECATED_EXPORT +# define CMARK_DEPRECATED_EXPORT CMARK_EXPORT CMARK_DEPRECATED +#endif + +#ifndef CMARK_DEPRECATED_NO_EXPORT +# define CMARK_DEPRECATED_NO_EXPORT CMARK_NO_EXPORT CMARK_DEPRECATED +#endif + +#if 0 /* DEFINE_NO_DEPRECATED */ +# ifndef CMARK_NO_DEPRECATED +# define CMARK_NO_DEPRECATED +# endif +#endif + +#endif diff --git a/retroshare-gui/src/cmark_version.h b/retroshare-gui/src/cmark_version.h new file mode 100644 index 000000000..c6fe002fb --- /dev/null +++ b/retroshare-gui/src/cmark_version.h @@ -0,0 +1,7 @@ +#ifndef CMARK_VERSION_H +#define CMARK_VERSION_H + +#define CMARK_VERSION ((0 << 16) | (28 << 8) | 0) +#define CMARK_VERSION_STRING "0.28.0" + +#endif diff --git a/retroshare-gui/src/config.h b/retroshare-gui/src/config.h new file mode 100644 index 000000000..d38c7c7a5 --- /dev/null +++ b/retroshare-gui/src/config.h @@ -0,0 +1,76 @@ +#ifndef CMARK_CONFIG_H +#define CMARK_CONFIG_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define HAVE_STDBOOL_H + +#ifdef HAVE_STDBOOL_H + #include +#elif !defined(__cplusplus) + typedef char bool; +#endif + +#define HAVE___BUILTIN_EXPECT + +#define HAVE___ATTRIBUTE__ + +#ifdef HAVE___ATTRIBUTE__ + #define CMARK_ATTRIBUTE(list) __attribute__ (list) +#else + #define CMARK_ATTRIBUTE(list) +#endif + +#ifndef CMARK_INLINE + #if defined(_MSC_VER) && !defined(__cplusplus) + #define CMARK_INLINE __inline + #else + #define CMARK_INLINE inline + #endif +#endif + +/* snprintf and vsnprintf fallbacks for MSVC before 2015, + due to Valentin Milea http://stackoverflow.com/questions/2915672/ +*/ + +#if defined(_MSC_VER) && _MSC_VER < 1900 + +#include +#include + +#define snprintf c99_snprintf +#define vsnprintf c99_vsnprintf + +CMARK_INLINE int c99_vsnprintf(char *outBuf, size_t size, const char *format, va_list ap) +{ + int count = -1; + + if (size != 0) + count = _vsnprintf_s(outBuf, size, _TRUNCATE, format, ap); + if (count == -1) + count = _vscprintf(format, ap); + + return count; +} + +CMARK_INLINE int c99_snprintf(char *outBuf, size_t size, const char *format, ...) +{ + int count; + va_list ap; + + va_start(ap, format); + count = c99_vsnprintf(outBuf, size, format, ap); + va_end(ap); + + return count; +} + +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/retroshare-gui/src/gui/FileTransfer/BannedFilesDialog.cpp b/retroshare-gui/src/gui/FileTransfer/BannedFilesDialog.cpp new file mode 100644 index 000000000..5be060b09 --- /dev/null +++ b/retroshare-gui/src/gui/FileTransfer/BannedFilesDialog.cpp @@ -0,0 +1,86 @@ +/******************************************************************************* + * retroshare-gui/src/gui/FileTransfer/BannedFilesDialog.cpp * + * * + * Copyright 2018 by Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ + +#include +#include + +#include "retroshare/rsfiles.h" + +#include "BannedFilesDialog.h" + +#define COLUMN_FILE_NAME 0 +#define COLUMN_FILE_HASH 1 +#define COLUMN_FILE_SIZE 2 +#define COLUMN_FILE_TIME 3 + +BannedFilesDialog::BannedFilesDialog(QWidget *parent) + : QDialog(parent) +{ + ui.setupUi(this); + + fillFilesList() ; + + connect(ui.bannedFiles_TW, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(bannedFilesContextMenu(QPoint))); +} + +BannedFilesDialog::~BannedFilesDialog() {} + +void BannedFilesDialog::unbanFile() +{ + int row = ui.bannedFiles_TW->currentRow(); + + QTableWidgetItem *item = ui.bannedFiles_TW->item(row, COLUMN_FILE_HASH); + + RsFileHash hash(item->data(Qt::UserRole).toString().toStdString()) ; + rsFiles->unbanFile(hash) ; + + fillFilesList(); +} + +void BannedFilesDialog::bannedFilesContextMenu(QPoint) +{ + QMenu menu(this); + + menu.addAction(QIcon(":/images/FeedAdd.png"), tr("Remove"), this, SLOT(unbanFile())); + + menu.exec(QCursor::pos()); +} + +void BannedFilesDialog::fillFilesList() +{ + std::map banned_files ; + + rsFiles->getPrimaryBannedFilesList(banned_files); + int row=0; + + ui.bannedFiles_TW->setRowCount(banned_files.size()) ; + + for(auto it(banned_files.begin());it!=banned_files.end();++it) + { + ui.bannedFiles_TW->setItem(row, COLUMN_FILE_NAME, new QTableWidgetItem(QIcon(),QString::fromUtf8(it->second.filename.c_str()),0)); + ui.bannedFiles_TW->setItem(row, COLUMN_FILE_HASH, new QTableWidgetItem(QIcon(),QString::fromStdString(it->first.toStdString()),0)); + ui.bannedFiles_TW->setItem(row, COLUMN_FILE_SIZE, new QTableWidgetItem(QIcon(),QString::number(it->second.size),0)); + ui.bannedFiles_TW->setItem(row, COLUMN_FILE_TIME, new QTableWidgetItem(QIcon(),QDateTime::fromTime_t(it->second.ban_time_stamp).toString(),0)); + + ui.bannedFiles_TW->item(row, COLUMN_FILE_HASH)->setData(Qt::UserRole, QString::fromStdString(it->first.toStdString())); + + row++; + } +} diff --git a/retroshare-gui/src/gui/FileTransfer/BannedFilesDialog.h b/retroshare-gui/src/gui/FileTransfer/BannedFilesDialog.h new file mode 100644 index 000000000..cdcb4f6ee --- /dev/null +++ b/retroshare-gui/src/gui/FileTransfer/BannedFilesDialog.h @@ -0,0 +1,49 @@ +/******************************************************************************* + * retroshare-gui/src/gui/FileTransfer/BannedFilesDialog.h * + * * + * Copyright 2018 by Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ + +#pragma once + +#include "RsAutoUpdatePage.h" +#include "ui_BannedFilesDialog.h" + +class BannedFilesDialog: public QDialog +{ + Q_OBJECT + +public: + /** Default Constructor */ + BannedFilesDialog(QWidget *parent = 0); + /** Default Destructor */ + ~BannedFilesDialog(); + +private slots: + void unbanFile(); + + /** management of the adv search dialog object when switching search modes */ + //void hideEvent(QHideEvent * event); + void bannedFilesContextMenu(QPoint); + +private: + void fillFilesList(); + + /** Qt Designer generated object */ + Ui::BannedFilesDialog ui; +}; + diff --git a/retroshare-gui/src/gui/FileTransfer/BannedFilesDialog.ui b/retroshare-gui/src/gui/FileTransfer/BannedFilesDialog.ui new file mode 100644 index 000000000..78d81df79 --- /dev/null +++ b/retroshare-gui/src/gui/FileTransfer/BannedFilesDialog.ui @@ -0,0 +1,67 @@ + + + BannedFilesDialog + + + + 0 + 0 + 923 + 810 + + + + + + + <html><head/><body><p><span style=" font-weight:600;">Collaborative file control</span>: the list below contains files you choose to ban from your <span style=" font-weight:600;">local</span> network: you will not forward search results nor data from these files to your friends. This list is securely shared with your friends, unless they uncheck option &quot;Trust my friends for banning unwanted content&quot;. This feature cannot globally hide a file unless a signficant proportion of users in the same network decide to ban it.</p></body></html> + + + Qt::AlignJustify|Qt::AlignVCenter + + + true + + + + + + + Qt::CustomContextMenu + + + true + + + true + + + false + + + + Filename + + + + + Hash + + + + + Size + + + + + Banned since... + + + + + + + + + diff --git a/retroshare-gui/src/gui/FileTransfer/SearchDialog.cpp b/retroshare-gui/src/gui/FileTransfer/SearchDialog.cpp index bc2f08644..20e5157da 100644 --- a/retroshare-gui/src/gui/FileTransfer/SearchDialog.cpp +++ b/retroshare-gui/src/gui/FileTransfer/SearchDialog.cpp @@ -26,6 +26,7 @@ #include "rshare.h" #include "SearchDialog.h" +#include "gui/FileTransfer/BannedFilesDialog.h" #include "gui/RSHumanReadableDelegate.h" #include "gui/RetroShareLink.h" #include "retroshare-gui/RsAutoUpdatePage.h" @@ -54,6 +55,7 @@ #define IMAGE_COLLVIEW ":/images/library_view.png" #define IMAGE_COLLOPEN ":/images/library.png" #define IMAGE_COPYLINK ":/images/copyrslink.png" +#define IMAGE_BANFILE ":/icons/biohazard_red.png" /* Key for UI Preferences */ #define UI_PREF_ADVANCED_SEARCH "UIOptions/AdvancedSearch" @@ -117,6 +119,7 @@ SearchDialog::SearchDialog(QWidget *parent) connect( ui.searchResultWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( searchResultWidgetCustomPopupMenu( QPoint ) ) ); connect( ui.searchSummaryWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( searchSummaryWidgetCustomPopupMenu( QPoint ) ) ); + connect( ui.showBannedFiles_TB, SIGNAL( clicked() ), this, SLOT( openBannedFiles() ) ); connect( ui.lineEdit, SIGNAL( returnPressed ( void ) ), this, SLOT( searchKeywords( void ) ) ); connect( ui.lineEdit, SIGNAL( textChanged ( const QString& ) ), this, SLOT( checkText( const QString& ) ) ); @@ -165,8 +168,10 @@ SearchDialog::SearchDialog(QWidget *parent) QHeaderView_setSectionResizeModeColumn(_smheader, SS_KEYWORDS_COL, QHeaderView::Interactive); QHeaderView_setSectionResizeModeColumn(_smheader, SS_RESULTS_COL, QHeaderView::Interactive); - _smheader->resizeSection ( SS_KEYWORDS_COL, 160 ); - _smheader->resizeSection ( SS_RESULTS_COL, 50 ); + float f = QFontMetricsF(font()).height()/14.0 ; + + _smheader->resizeSection ( SS_KEYWORDS_COL, 160*f ); + _smheader->resizeSection ( SS_RESULTS_COL, 50*f ); ui.searchResultWidget->setColumnCount(SR_COL_COUNT); _smheader = ui.searchResultWidget->header () ; @@ -174,12 +179,12 @@ SearchDialog::SearchDialog(QWidget *parent) QHeaderView_setSectionResizeModeColumn(_smheader, SR_SIZE_COL, QHeaderView::Interactive); QHeaderView_setSectionResizeModeColumn(_smheader, SR_SOURCES_COL, QHeaderView::Interactive); - _smheader->resizeSection ( SR_NAME_COL, 240 ); - _smheader->resizeSection ( SR_SIZE_COL, 75 ); - _smheader->resizeSection ( SR_SOURCES_COL, 75 ); - _smheader->resizeSection ( SR_TYPE_COL, 75 ); - _smheader->resizeSection ( SR_AGE_COL, 90 ); - _smheader->resizeSection ( SR_HASH_COL, 240 ); + _smheader->resizeSection ( SR_NAME_COL, 240*f ); + _smheader->resizeSection ( SR_SIZE_COL, 75*f ); + _smheader->resizeSection ( SR_SOURCES_COL, 75*f ); + _smheader->resizeSection ( SR_TYPE_COL, 75*f ); + _smheader->resizeSection ( SR_AGE_COL, 90*f ); + _smheader->resizeSection ( SR_HASH_COL, 240*f ); // set header text aligment QTreeWidgetItem * headerItem = ui.searchResultWidget->headerItem(); @@ -201,10 +206,10 @@ SearchDialog::SearchDialog(QWidget *parent) // load settings processSettings(true); - ui._ownFiles_CB->setMinimumWidth(20); - ui._friendListsearch_SB->setMinimumWidth(20); - ui._anonF2Fsearch_CB->setMinimumWidth(20); - ui.label->setMinimumWidth(20); + ui._ownFiles_CB->setMinimumWidth(20*f); + ui._friendListsearch_SB->setMinimumWidth(20*f); + ui._anonF2Fsearch_CB->setMinimumWidth(20*f); + ui.label->setMinimumWidth(20*f); // workaround for Qt bug, be solved in next Qt release 4.7.0 // https://bugreports.qt-project.org/browse/QTBUG-8270 @@ -325,6 +330,7 @@ void SearchDialog::searchResultWidgetCustomPopupMenu( QPoint /*point*/ ) QMenu contextMnu(this) ; contextMnu.addAction(QIcon(IMAGE_START), tr("Download"), this, SLOT(download())) ; + contextMnu.addAction(QIcon(IMAGE_BANFILE), tr("Mark as bad"), this, SLOT(ban())) ; contextMnu.addSeparator();//-------------------------------------- contextMnu.addAction(QIcon(IMAGE_COPYLINK), tr("Copy RetroShare Link"), this, SLOT(copyResultLink())) ; @@ -404,22 +410,53 @@ void SearchDialog::download() std::cout << "isuing file request from search dialog: -" << (item->text(SR_NAME_COL)).toStdString() << "-" << hash << "-" << (item->text(SR_SIZE_COL)).toULongLong() << "-ids=" ; - for(std::list::const_iterator it(srcIds.begin()); it!=srcIds.end(); ++it) { + for(std::list::const_iterator it(srcIds.begin()); it!=srcIds.end(); ++it) std::cout << *it << "-" << std::endl; - }//for(std::list::const_iterator - //QColor foreground = QColor(0, 128, 0); // green + QColor foreground = textColorDownloading(); QBrush brush(foreground); for (int i = 0; i < item->columnCount(); ++i) - { item->setForeground(i, brush); - } - }//if(!rsFiles -> FileRequest( - }//if (item->text(SR_HASH_COL).isEmpty()) - }//for (int i = 0 - if (attemptDownloadLocal) { + } + } + } + if (attemptDownloadLocal) QMessageBox::information(this, tr("Download Notice"), tr("Skipping Local Files")) ; - }//if (attemptDownloadLocal) +} + +void SearchDialog::ban() +{ + /* should also be able to handle multi-selection */ + + QList itemsForDownload = ui.searchResultWidget->selectedItems() ; + int numdls = itemsForDownload.size() ; + QTreeWidgetItem * item ; + + for (int i = 0; i < numdls; ++i) + { + item = itemsForDownload.at(i) ; + // call the download + // * + if(!item->text(SR_HASH_COL).isEmpty()) + { + std::cerr << "SearchDialog::download() Calling File Ban" << std::endl ; + + RsFileHash hash( item->text(SR_HASH_COL).toStdString()) ; + + rsFiles -> banFile( hash, (item->text(SR_NAME_COL)).toUtf8().constData() , (item->text(SR_SIZE_COL)).toULongLong()); + + while(item->parent() != NULL) + item = item->parent(); + + ui.searchResultWidget->takeTopLevelItem(ui.searchResultWidget->indexOfTopLevelItem(item)) ; + } + } +} + +void SearchDialog::openBannedFiles() +{ + BannedFilesDialog d ; + d.exec(); } void SearchDialog::collCreate() @@ -792,7 +829,7 @@ void SearchDialog::advancedSearch(RsRegularExpression::Expression* expression) RsRegularExpression::LinearizedExpression e ; expression->linearize(e) ; - TurtleRequestId req_id = rsTurtle->turtleSearch(e) ; + TurtleRequestId req_id = rsFiles->turtleSearch(e) ; // This will act before turtle results come to the interface, thanks to the signals scheduling policy. initSearchResult(QString::fromStdString(e.GetStrings()),req_id, ui.FileTypeComboBox->currentIndex(), true) ; @@ -858,9 +895,9 @@ void SearchDialog::searchKeywords(const QString& keywords) if(ui._anonF2Fsearch_CB->isChecked()) { if(n==1) - req_id = rsTurtle->turtleSearch(words.front()) ; + req_id = rsFiles->turtleSearch(words.front()) ; else - req_id = rsTurtle->turtleSearch(lin_exp) ; + req_id = rsFiles->turtleSearch(lin_exp) ; } else req_id = RSRandom::random_u32() ; // generate a random 32 bits request id @@ -940,9 +977,7 @@ void SearchDialog::processResultQueue() while(!searchResultsQueue.empty() && nb_treated_elements++ < 250) { qulonglong search_id = searchResultsQueue.back().first ; - FileDetail file = searchResultsQueue.back().second ; - - searchResultsQueue.pop_back() ; + FileDetail& file = searchResultsQueue.back().second ; #ifdef DEBUG std::cout << "Updating file detail:" << std::endl ; @@ -952,6 +987,8 @@ void SearchDialog::processResultQueue() #endif insertFile(search_id,file); + + searchResultsQueue.pop_back() ; } ui.searchResultWidget->setSortingEnabled(true); if(!searchResultsQueue.empty()) @@ -1286,6 +1323,7 @@ void SearchDialog::insertFile(qulonglong searchId, const FileDetail& file, int s modifiedResult =QString::number(friendSource) + "/" + QString::number(anonymousSource); float fltRes = friendSource + (float)anonymousSource/1000; item->setText(SR_SOURCES_COL,modifiedResult); + item->setToolTip(SR_SOURCES_COL, tr("Obtained via ")+QString::fromStdString(rsPeers->getPeerName(file.id)) ); item->setData(SR_SOURCES_COL, ROLE_SORT, fltRes); item->setTextAlignment( SR_SOURCES_COL, Qt::AlignRight ); item->setText(SR_SEARCH_ID_COL, sid_hexa); diff --git a/retroshare-gui/src/gui/FileTransfer/SearchDialog.h b/retroshare-gui/src/gui/FileTransfer/SearchDialog.h index 57846692c..001ae3903 100644 --- a/retroshare-gui/src/gui/FileTransfer/SearchDialog.h +++ b/retroshare-gui/src/gui/FileTransfer/SearchDialog.h @@ -75,6 +75,7 @@ private slots: void searchSummaryWidgetCustomPopupMenu( QPoint point ); void download(); + void ban(); void collCreate(); void collModif(); @@ -86,6 +87,7 @@ private slots: void recommendtofriends(); void checkText(const QString&); + void openBannedFiles(); void copyResultLink(); void copySearchLink(); void openFolderSearch(); diff --git a/retroshare-gui/src/gui/FileTransfer/SearchDialog.ui b/retroshare-gui/src/gui/FileTransfer/SearchDialog.ui index 5411dd3c8..47e221bf5 100644 --- a/retroshare-gui/src/gui/FileTransfer/SearchDialog.ui +++ b/retroshare-gui/src/gui/FileTransfer/SearchDialog.ui @@ -6,8 +6,8 @@ 0 0 - 758 - 339 + 1531 + 889 @@ -32,7 +32,16 @@ QFrame::Sunken - + + 2 + + + 2 + + + 2 + + 2 @@ -55,15 +64,24 @@ + + 0 + + + 0 + + + 0 + + + 0 + 0 1 - - 0 - @@ -152,6 +170,23 @@ + + + + + 0 + 0 + + + + + + + + :/icons/biohazard_red.png:/icons/biohazard_red.png + + + @@ -307,7 +342,7 @@ Any - + :/images/FileTypeAny.png:/images/FileTypeAny.png @@ -316,7 +351,7 @@ Archive - + :/images/FileTypeArchive.png:/images/FileTypeArchive.png @@ -325,7 +360,7 @@ Audio - + :/images/FileTypeAudio.png:/images/FileTypeAudio.png @@ -334,7 +369,7 @@ CD-Image - + :/images/FileTypeCDImage.png:/images/FileTypeCDImage.png @@ -343,7 +378,7 @@ Document - + :/images/FileTypeDocument.png:/images/FileTypeDocument.png @@ -352,7 +387,7 @@ Picture - + :/images/FileTypePicture.png:/images/FileTypePicture.png @@ -361,7 +396,7 @@ Program - + :/images/FileTypeProgram.png:/images/FileTypeProgram.png @@ -370,7 +405,7 @@ Video - + :/images/FileTypeVideo.png:/images/FileTypeVideo.png @@ -379,7 +414,7 @@ Directory - + :/images/folder16.png:/images/folder16.png @@ -406,7 +441,7 @@ Download selected - + :/images/download16.png:/images/download16.png @@ -423,7 +458,7 @@ LineEditClear QLineEdit -
gui/common/LineEditClear.h
+
gui/common/LineEditClear.h
SearchTreeWidget @@ -432,7 +467,8 @@ - + + diff --git a/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp b/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp index 26ace2db1..cbb420eba 100644 --- a/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp +++ b/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp @@ -1140,14 +1140,14 @@ void LocalSharedFilesDialog::spawnCustomPopupMenu( QPoint point ) { shareChannelMenu.setIcon(QIcon(IMAGE_CHANNEL)); - std::list grp_metas ; + std::map grp_metas ; channelDialog->getGroupList(grp_metas) ; std::vector > grplist ; // I dont use a std::map because two or more channels may have the same name. for(auto it(grp_metas.begin());it!=grp_metas.end();++it) - if(IS_GROUP_PUBLISHER((*it).mSubscribeFlags) && IS_GROUP_SUBSCRIBED((*it).mSubscribeFlags)) - grplist.push_back(std::make_pair((*it).mGroupName, (*it).mGroupId)); + if(IS_GROUP_PUBLISHER((*it).second.mSubscribeFlags) && IS_GROUP_SUBSCRIBED((*it).second.mSubscribeFlags)) + grplist.push_back(std::make_pair((*it).second.mGroupName, (*it).second.mGroupId)); std::sort(grplist.begin(),grplist.end(),ChannelCompare()) ; @@ -1164,14 +1164,14 @@ void LocalSharedFilesDialog::spawnCustomPopupMenu( QPoint point ) { shareForumMenu.setIcon(QIcon(IMAGE_FORUMS)); - std::list grp_metas ; + std::map grp_metas ; forumsDialog->getGroupList(grp_metas) ; std::vector > grplist ; // I dont use a std::map because two or more channels may have the same name. for(auto it(grp_metas.begin());it!=grp_metas.end();++it) - if(IS_GROUP_SUBSCRIBED((*it).mSubscribeFlags)) - grplist.push_back(std::make_pair((*it).mGroupName, (*it).mGroupId)); + if(IS_GROUP_SUBSCRIBED((*it).second.mSubscribeFlags)) + grplist.push_back(std::make_pair((*it).second.mGroupName, (*it).second.mGroupId)); std::sort(grplist.begin(),grplist.end(),ChannelCompare()) ; diff --git a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.h b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.h index 51bc205d3..f98a96daa 100644 --- a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.h +++ b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.h @@ -55,7 +55,8 @@ public: /* Fixed numbers for load and save the last page */ SearchTab = 0, /** Network page. */ LocalSharedFilesTab = 1, /** Network new graph. */ - RemoteSharedFilesTab = 2 /** Old group chat page. */ + RemoteSharedFilesTab = 2, /** Old group chat page. */ + DownloadTab = 3 }; @@ -108,9 +109,6 @@ private slots: void expandAllUL(); void collapseAllUL(); -// void rootdecorated(); -// void rootisnotdecorated(); - void pauseFileTransfer(); void resumeFileTransfer(); void dlOpenFolder(); diff --git a/retroshare-gui/src/gui/GenCertDialog.cpp b/retroshare-gui/src/gui/GenCertDialog.cpp index 133bfbc4a..24a1c746e 100644 --- a/retroshare-gui/src/gui/GenCertDialog.cpp +++ b/retroshare-gui/src/gui/GenCertDialog.cpp @@ -34,6 +34,7 @@ #include #include "gui/settings/rsharesettings.h" +#include "TorControl/TorManager.h" #include "util/misc.h" #include @@ -136,7 +137,7 @@ GenCertDialog::GenCertDialog(bool onlyGenerateIdentity, QWidget *parent) //ui.headerFrame->setHeaderText(tr("Create a new profile")); connect(ui.reuse_existing_node_CB, SIGNAL(triggered()), this, SLOT(switchReuseExistingNode())); - connect(ui.adv_checkbox, SIGNAL(triggered()), this, SLOT(setupState())); + connect(ui.adv_checkbox, SIGNAL(toggled(bool)), this, SLOT(setupState())); connect(ui.nodeType_CB, SIGNAL(currentIndexChanged(int)), this, SLOT(setupState())); connect(ui.genButton, SIGNAL(clicked()), this, SLOT(genPerson())); @@ -181,10 +182,10 @@ GenCertDialog::GenCertDialog(bool onlyGenerateIdentity, QWidget *parent) * mark last one as default. */ - QMenu *menu = new QMenu(tr("Advanced options")); - menu->addAction(ui.adv_checkbox); - menu->addAction(ui.reuse_existing_node_CB); - ui.optionsButton->setMenu(menu); + //QMenu *menu = new QMenu(tr("Advanced options")); + //menu->addAction(ui.adv_checkbox); + //menu->addAction(ui.reuse_existing_node_CB); + // ui.optionsButton->setMenu(menu); mAllFieldsOk = false ; mEntropyOk = false ; @@ -195,10 +196,10 @@ GenCertDialog::GenCertDialog(bool onlyGenerateIdentity, QWidget *parent) ui.nodeType_CB->setCurrentIndex(1); ui.nodeType_CB->setEnabled(false); #endif -#ifdef RETROTOR - ui.adv_checkbox->setChecked(false); - ui.adv_checkbox->setVisible(true); -#endif +//#ifdef RETROTOR +// ui.adv_checkbox->setChecked(false); +// ui.adv_checkbox->setVisible(true); +//#endif initKeyList(); setupState(); @@ -259,30 +260,39 @@ void GenCertDialog::setupState() { bool adv_state = ui.adv_checkbox->isChecked(); -#ifdef RETROTOR - bool retrotor = true ; -#else - bool retrotor = false ; -#endif - if(!adv_state) { ui.reuse_existing_node_CB->setChecked(false) ; - ui.nodeType_CB->setCurrentIndex(retrotor?1:0) ; ui.keylength_comboBox->setCurrentIndex(0) ; +// ui.nodeType_CB->setCurrentIndex(0); } - bool hidden_state = ui.nodeType_CB->currentIndex()==1; + ui.reuse_existing_node_CB->setVisible(adv_state) ; + +// ui.nodeType_CB->setVisible(adv_state) ; +// ui.nodeType_LB->setVisible(adv_state) ; +// ui.nodeTypeExplanation_TE->setVisible(adv_state) ; + + bool hidden_state = ui.nodeType_CB->currentIndex()==1 || ui.nodeType_CB->currentIndex()==2; bool generate_new = !ui.reuse_existing_node_CB->isChecked(); + bool tor_auto = ui.nodeType_CB->currentIndex()==1; genNewGPGKey = generate_new; + switch(ui.nodeType_CB->currentIndex()) + { + case 0: ui.nodeTypeExplanation_TE->setText(tr("Your IP is visible to trusted nodes only. You can also connect to hidden nodes if running Tor on your machine. Best choice for sharing with trusted friends.")); + break; + case 1: ui.nodeTypeExplanation_TE->setText(tr("Your IP is hidden. All traffic happens over the Tor network. Best choice if you cannot trust friend nodes with your own IP.")); + break; + case 2: ui.nodeTypeExplanation_TE->setText(tr("Hidden node for advanced users only. Allows to use other proxy solutions such as I2P.")); + break; + } + //ui.no_node_label->setVisible(false); setWindowTitle(generate_new?tr("Create new profile and new Retroshare node"):tr("Create new Retroshare node")); //ui.headerFrame->setHeaderText(generate_new?tr("Create a new profile and node"):tr("Create a new node")); - ui.label_nodeType->setVisible(adv_state && !retrotor) ; - ui.nodeType_CB->setVisible(adv_state && !retrotor) ; ui.reuse_existing_node_CB->setEnabled(adv_state) ; ui.importIdentity_PB->setVisible(adv_state && !generate_new) ; ui.exportIdentity_PB->setVisible(adv_state && !generate_new) ; @@ -318,13 +328,13 @@ void GenCertDialog::setupState() ui.entropy_bar->setVisible(true); ui.genButton->setVisible(true); - ui.hiddenaddr_input->setVisible(hidden_state && !retrotor); - ui.hiddenaddr_label->setVisible(hidden_state && !retrotor); + ui.hiddenaddr_input->setVisible(hidden_state && !tor_auto); + ui.hiddenaddr_label->setVisible(hidden_state && !tor_auto); - ui.hiddenport_label->setVisible(hidden_state && !retrotor); - ui.hiddenport_spinBox->setVisible(hidden_state && !retrotor); + ui.hiddenport_label->setVisible(hidden_state && !tor_auto); + ui.hiddenport_spinBox->setVisible(hidden_state && !tor_auto); - ui.cbUseBob->setVisible(hidden_state && !retrotor); + ui.cbUseBob->setVisible(hidden_state && !tor_auto); if(!mAllFieldsOk) { @@ -470,7 +480,6 @@ void GenCertDialog::genPerson() /* Check the data from the GUI. */ std::string genLoc = ui.node_input->text().toUtf8().constData(); RsPgpId PGPId; - bool isHiddenLoc = false; if(ui.nickname_input->isVisible()) { @@ -503,18 +512,26 @@ void GenCertDialog::genPerson() } } - if (ui.nodeType_CB->currentIndex()==1) + bool isHiddenLoc = (ui.nodeType_CB->currentIndex()>0); + bool isAutoTor = (ui.nodeType_CB->currentIndex()==1); + + if(isAutoTor && !Tor::TorManager::isTorAvailable()) + { + QMessageBox::critical(this,tr("Tor is not available"),tr("No Tor executable has been found on your system. You need to install Tor before creating a hidden identity.")) ; + return ; + } + + if(isHiddenLoc) { std::string hl = ui.hiddenaddr_input->text().toStdString(); uint16_t port = ui.hiddenport_spinBox->value(); + bool useBob = ui.cbUseBob->isChecked(); if (useBob && hl.empty()) hl = "127.0.0.1"; RsInit::SetHiddenLocation(hl, port, useBob); /* parses it */ - - isHiddenLoc = true; } @@ -620,7 +637,7 @@ void GenCertDialog::genPerson() std::string err; this->hide();//To show dialog asking password PGP Key. std::cout << "RsAccounts::GenerateSSLCertificate" << std::endl; - bool okGen = RsAccounts::GenerateSSLCertificate(PGPId, "", genLoc, "", isHiddenLoc, sslPasswd, sslId, err); + bool okGen = RsAccounts::createNewAccount(PGPId, "", genLoc, "", isHiddenLoc, isAutoTor, sslPasswd, sslId, err); if (okGen) { diff --git a/retroshare-gui/src/gui/GenCertDialog.ui b/retroshare-gui/src/gui/GenCertDialog.ui index 28ce3bd88..6c030db02 100644 --- a/retroshare-gui/src/gui/GenCertDialog.ui +++ b/retroshare-gui/src/gui/GenCertDialog.ui @@ -6,8 +6,8 @@ 0 0 - 569 - 426 + 978 + 826 @@ -50,10 +50,7 @@ QFrame::Raised - - - 9 - + @@ -71,7 +68,45 @@ - + + + + + + 75 + true + + + + Node type: + + + + + + + + 0 + 0 + + + + + Standard node + + + + + Hidden node (over Tor) + + + + + Hidden node (Tor/I2P - Manually configured) + + + + @@ -86,13 +121,9 @@ - + - Options - - - - :/icons/svg/options.svg:/icons/svg/options.svg + advanced options @@ -100,16 +131,23 @@ 24 - - false - - - true - + + + + TextLabel + + + Qt::RichText + + + true + + + @@ -233,26 +271,6 @@ - - - - - 0 - 0 - - - - - Standard node - - - - - TOR/I2P Hidden node - - - - @@ -357,6 +375,13 @@ + + + + Use existing profile... + + + @@ -675,28 +700,6 @@ - - - - - 24 - 24 - - - - - - - :/icons/svg/netgraph.svg - - - true - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - -
@@ -729,22 +732,6 @@ - - - true - - - Advanced options - - - - - true - - - Use existing profile - - name_input diff --git a/retroshare-gui/src/gui/MainWindow.cpp b/retroshare-gui/src/gui/MainWindow.cpp index e00417080..07d0b01a5 100644 --- a/retroshare-gui/src/gui/MainWindow.cpp +++ b/retroshare-gui/src/gui/MainWindow.cpp @@ -84,12 +84,13 @@ #include "statusbar/ToasterDisable.h" #include "statusbar/SysTrayStatus.h" #include "statusbar/torstatus.h" -#include -#include -#include -#include -#include +#include "retroshare/rsstatus.h" +#include "retroshare/rsiface.h" +#include "retroshare/rspeers.h" +#include "retroshare/rsfiles.h" +#include "retroshare/rsnotify.h" +#include "retroshare/rsinit.h" #include "gui/gxschannels/GxsChannelDialog.h" #include "gui/gxsforums/GxsForumsDialog.h" @@ -250,14 +251,15 @@ MainWindow::MainWindow(QWidget* parent, Qt::WindowFlags flags) if(hiddenmode) { -#ifdef RETROTOR - torstatus = new TorStatus(); - torstatus->setVisible(Settings->valueFromGroup("StatusBar", "ShowTor", QVariant(true)).toBool()); - statusBar()->addWidget(torstatus); - torstatus->getTorStatus(); -#else - torstatus = NULL ; -#endif + if(RsAccounts::isHiddenNode()) + { + torstatus = new TorStatus(); + torstatus->setVisible(Settings->valueFromGroup("StatusBar", "ShowTor", QVariant(true)).toBool()); + statusBar()->addWidget(torstatus); + torstatus->getTorStatus(); + } + else + torstatus = NULL ; natstatus = NULL ; dhtstatus = NULL ; @@ -433,7 +435,7 @@ void MainWindow::initStackedPage() #ifndef RS_RELEASE_VERSION #ifdef PLUGINMGR - addPage(pluginsPage = new PluginsPage(ui->stackPages), grp, NULL); + addPage(pluginsPage = new gui::PluginsPage(ui->stackPages), grp, NULL); #endif #endif @@ -643,10 +645,10 @@ const QList &MainWindow::getUserNotifyList() /*static*/ void MainWindow::displayLobbySystrayMsg(const QString& title,const QString& msg) { - if (_instance == NULL) + if (_instance == NULL) return; - if(Settings->getDisplayTrayChatLobby()) + if(Settings->getDisplayTrayChatLobby()) _instance->displaySystrayMsg(title,msg) ; } @@ -1011,7 +1013,7 @@ void SetForegroundWindowInternal(HWND hWnd) return NULL; } - switch (page) + switch (page) { case Network: return _instance->friendsDialog->networkDialog; @@ -1457,7 +1459,7 @@ void MainWindow::externalLinkActivated(const QUrl &url) int res = mb.exec() ; - if (res == QMessageBox::No) + if (res == QMessageBox::No) return ; if(dontAsk_CB->isChecked()) diff --git a/retroshare-gui/src/gui/NetworkView.cpp b/retroshare-gui/src/gui/NetworkView.cpp index 44c99736d..d0e486293 100644 --- a/retroshare-gui/src/gui/NetworkView.cpp +++ b/retroshare-gui/src/gui/NetworkView.cpp @@ -28,7 +28,7 @@ #include #include -#include "gui/elastic/node.h" +#include "gui/elastic/elnode.h" /******** * #define DEBUG_NETWORKVIEW diff --git a/retroshare-gui/src/gui/PluginsPage.h b/retroshare-gui/src/gui/PluginsPage.h index de90a3d8f..fac165396 100644 --- a/retroshare-gui/src/gui/PluginsPage.h +++ b/retroshare-gui/src/gui/PluginsPage.h @@ -15,7 +15,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. ****************************************************************/ @@ -39,6 +39,8 @@ class QScriptEngine; class PluginManager; +namespace gui { + //! A demo widget for showing plugin engine in action :) @@ -46,7 +48,7 @@ class PluginManager; //! loaded plugin widgets. All specific actions moved to //! PluginManagerWidget class. It contains a PluginManager instance, but it's //! supposed that in future a pluginManager will become a global variable -class PluginsPage : public MainPage +class PluginsPage : public MainPage { Q_OBJECT @@ -70,10 +72,10 @@ protected: QVBoxLayout* pluginPageLayout; QGroupBox* pluginPanel; QVBoxLayout* pluginPanelLayout; - + //! Plugin widgets will be loaded into this tabs QTabWidget* pluginTabs ; - + QVBoxLayout* pmLay; QFrame* pmFrame; QSpacerItem* pmSpacer; @@ -82,5 +84,7 @@ protected: PluginManager* pluginManager; }; +} // namespace gui + #endif diff --git a/retroshare-gui/src/gui/Posted/PostedListWidget.cpp b/retroshare-gui/src/gui/Posted/PostedListWidget.cpp index d321933eb..f7e47863f 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidget.cpp +++ b/retroshare-gui/src/gui/Posted/PostedListWidget.cpp @@ -454,6 +454,10 @@ void PostedListWidget::applyRanking() ui->scrollAreaWidgetContents->update(); } +void PostedListWidget::blank() +{ + clearPosts(); +} void PostedListWidget::clearPosts() { /* clear all messages */ diff --git a/retroshare-gui/src/gui/Posted/PostedListWidget.h b/retroshare-gui/src/gui/Posted/PostedListWidget.h index 89f95e995..b9102cabb 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidget.h +++ b/retroshare-gui/src/gui/Posted/PostedListWidget.h @@ -63,6 +63,7 @@ protected: virtual void insertAllPosts(const uint32_t &token, GxsMessageFramePostThread *thread); virtual void insertPosts(const uint32_t &token); virtual void clearPosts(); + virtual void blank(); virtual bool navigatePostItem(const RsGxsMessageId& msgId); /* GxsMessageFrameWidget */ diff --git a/retroshare-gui/src/gui/RetroShareLink.cpp b/retroshare-gui/src/gui/RetroShareLink.cpp index 5b45ff584..744826bbb 100644 --- a/retroshare-gui/src/gui/RetroShareLink.cpp +++ b/retroshare-gui/src/gui/RetroShareLink.cpp @@ -860,17 +860,17 @@ QString RetroShareLink::title() const break; case TYPE_FILE: - return QString("%1 (%2)").arg(hash()).arg(misc::friendlyUnit(size())); + return QString("Size: %2 hash: %1").arg(hash()).arg(misc::friendlyUnit(size())); case TYPE_PERSON: return PeerDefs::rsidFromId(RsPgpId(hash().toStdString())); case TYPE_FORUM: - /* fallthrough */ + return QString("Forum id: %1").arg(hash()); case TYPE_CHANNEL: - /* fallthrough */ + return QString("Channel id: %1").arg(hash()); case TYPE_SEARCH: - break; + return QString("Search files"); case TYPE_MESSAGE: return PeerDefs::rsidFromId(RsPeerId(hash().toStdString())); @@ -1386,13 +1386,6 @@ static void processList(const QStringList &list, const QString &textSingular, co ++countUnknown; break; - case TYPE_FILE: - { - col.merge_in(link.name(),link.size(),RsFileHash(link.hash().toStdString())) ; - fileLinkFound = true; - } - break; - case TYPE_PERSON: { #ifdef DEBUG_RSLINK @@ -1547,6 +1540,22 @@ static void processList(const QStringList &list, const QString &textSingular, co } break ; + case TYPE_FILE: + { + FileInfo fi1; + if(links.size()==1 && rsFiles->alreadyHaveFile(RsFileHash(link.hash().toStdString()), fi1) + && !link.name().endsWith(RsCollection::ExtensionString)) + { + /* fallthrough */ + } + else + { + col.merge_in(link.name(),link.size(),RsFileHash(link.hash().toStdString())) ; + fileLinkFound = true; + break; + } + } + //break; case TYPE_EXTRAFILE: { #ifdef DEBUG_RSLINK @@ -1621,14 +1630,14 @@ static void processList(const QStringList &list, const QString &textSingular, co } else if (ret == QMessageBox::NoToAll) { dontOpenNextFile = true; } + needNotifySuccess = false; } } if (rsFiles->FileRequest(cleanname.toUtf8().constData(), RsFileHash(link.hash().toStdString()), link.size(), "", RS_FILE_REQ_ANONYMOUS_ROUTING, srcIds)) { fileAdded.append(link.name()); } else { - if (!bFileOpened) fileExist.append(link.name()); - } + if (!bFileOpened && links.size()>1) fileExist.append(link.name());} } break; diff --git a/retroshare-gui/src/gui/SoundManager.cpp b/retroshare-gui/src/gui/SoundManager.cpp index 79a2056af..5c538c4c4 100644 --- a/retroshare-gui/src/gui/SoundManager.cpp +++ b/retroshare-gui/src/gui/SoundManager.cpp @@ -76,7 +76,7 @@ SoundManager::SoundManager() : QObject() void SoundManager::soundEvents(SoundEvents &events) { - QDir baseDir = QDir(QString::fromUtf8(RsAccounts::DataDirectory().c_str()) + "/sounds"); + QDir baseDir = QDir(QString::fromUtf8(RsAccounts::systemDataDirectory().c_str()) + "/sounds"); events.mDefaultPath = baseDir.absolutePath(); diff --git a/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp b/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp index 35a6f0f54..3d98a4b62 100644 --- a/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp +++ b/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp @@ -34,7 +34,7 @@ #include "gui/FriendsDialog.h" #include "gui/MainWindow.h" #include "gui/chat/ChatWidget.h" -#include "gui/common/html.h" +#include "gui/common/rshtml.h" #include "gui/common/FriendSelectionDialog.h" #include "gui/common/RSTreeWidgetItem.h" #include "gui/gxs/GxsIdChooser.h" diff --git a/retroshare-gui/src/gui/chat/ChatStyle.cpp b/retroshare-gui/src/gui/chat/ChatStyle.cpp index 46db56f36..3cda190be 100644 --- a/retroshare-gui/src/gui/chat/ChatStyle.cpp +++ b/retroshare-gui/src/gui/chat/ChatStyle.cpp @@ -149,7 +149,7 @@ static QStringList getBaseDirList() // Search chat styles in config dir and data dir (is application dir for portable) QStringList baseDirs; baseDirs.append(QString::fromUtf8(RsAccounts::ConfigDirectory().c_str())); - baseDirs.append(QString::fromUtf8(RsAccounts::DataDirectory().c_str())); + baseDirs.append(QString::fromUtf8(RsAccounts::systemDataDirectory().c_str())); return baseDirs; } diff --git a/retroshare-gui/src/gui/chat/ChatWidget.cpp b/retroshare-gui/src/gui/chat/ChatWidget.cpp index f35c0425d..65a3597c3 100644 --- a/retroshare-gui/src/gui/chat/ChatWidget.cpp +++ b/retroshare-gui/src/gui/chat/ChatWidget.cpp @@ -72,8 +72,15 @@ * #define CHAT_DEBUG 1 *****/ -ChatWidget::ChatWidget(QWidget *parent) : - QWidget(parent), sendingBlocked(false), ui(new Ui::ChatWidget) +ChatWidget::ChatWidget(QWidget *parent) + : QWidget(parent) + , completionPosition(0), newMessages(false), typing(false), peerStatus(0) + , sendingBlocked(false), useCMark(false) + , lastStatusSendTime(0) + , firstShow(true), inChatCharFormatChanged(false), firstSearch(true) + , lastUpdateCursorPos(0), lastUpdateCursorEnd(0) + , completer(NULL), notify(NULL) + , ui(new Ui::ChatWidget) { ui->setupUi(this); @@ -84,17 +91,8 @@ ChatWidget::ChatWidget(QWidget *parent) : int butt_size(iconSize.height() + fmm); QSize buttonSize = QSize(butt_size, butt_size); - newMessages = false; - typing = false; - peerStatus = 0; - firstShow = true; - firstSearch = true; - inChatCharFormatChanged = false; - completer = NULL; lastMsgDate = QDate::currentDate(); - lastStatusSendTime = 0 ; - //Resize Tool buttons ui->emoteiconButton->setFixedSize(buttonSize); ui->emoteiconButton->setIconSize(iconSize); @@ -144,7 +142,6 @@ ChatWidget::ChatWidget(QWidget *parent) : connect(ui->actionSearchWithoutLimit, SIGNAL(triggered()), this, SLOT(toogle_SeachWithoutLimit())); connect(ui->searchButton, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuSearchButton(QPoint))); - notify=NULL; ui->notifyButton->setVisible(false); ui->markButton->setToolTip(tr("Mark this selected text
Ctrl+M")); @@ -194,6 +191,9 @@ ChatWidget::ChatWidget(QWidget *parent) : fontmenu->addAction(ui->actionResetFont); fontmenu->addAction(ui->actionNoEmbed); fontmenu->addAction(ui->actionSendAsPlainText); + #ifdef USE_CMARK + fontmenu->addAction(ui->actionSend_as_CommonMark); + #endif QMenu *menu = new QMenu(); menu->addAction(ui->actionClearChatHistory); @@ -207,6 +207,12 @@ ChatWidget::ChatWidget(QWidget *parent) : ui->chatTextEdit->setOnlyPlainText(ui->actionSendAsPlainText->isChecked()); connect(ui->actionSendAsPlainText, SIGNAL(toggled(bool)), ui->chatTextEdit, SLOT(setOnlyPlainText(bool)) ); +#ifdef USE_CMARK + connect(ui->actionSend_as_CommonMark, SIGNAL(toggled(bool)), this, SLOT(setUseCMark(bool)) ); + connect(ui->chatTextEdit, SIGNAL(textChanged()), this, SLOT(updateCMPreview()) ); +#endif + ui->cmPreview->setVisible(false); + ui->textBrowser->resetImagesStatus(Settings->getChatLoadEmbeddedImages()); ui->textBrowser->installEventFilter(this); ui->textBrowser->viewport()->installEventFilter(this); @@ -981,6 +987,13 @@ void ChatWidget::addChatMsg(bool incoming, const QString &name, const RsGxsId gx formatTextFlag |= RSHTML_FORMATTEXT_EMBED_SMILEYS; } +#ifdef USE_CMARK + //Use CommonMark + if (message.contains("CMark=\"true\"")) { + formatTextFlag |= RSHTML_FORMATTEXT_USE_CMARK; + } +#endif + // Always fix colors formatTextFlag |= RSHTML_FORMATTEXT_FIX_COLORS; qreal desiredContrast = Settings->valueFromGroup("Chat", "MinimumContrast", 4.5).toDouble(); @@ -1229,7 +1242,9 @@ void ChatWidget::sendChat() text = chatWidget->toPlainText(); text.replace(QChar(-4),"");//Char used when image on text. } else { - RsHtml::optimizeHtml(chatWidget, text, (ui->actionNoEmbed->isChecked() ? RSHTML_FORMATTEXT_NO_EMBED : 0)); + RsHtml::optimizeHtml(chatWidget, text, + (ui->actionNoEmbed->isChecked() ? RSHTML_FORMATTEXT_NO_EMBED : 0) + + (ui->actionSend_as_CommonMark->isChecked() ? RSHTML_FORMATTEXT_USE_CMARK : 0) ); } std::string msg = text.toUtf8().constData(); @@ -1823,6 +1838,22 @@ bool ChatWidget::setStyle() return false; } +void ChatWidget::setUseCMark(const bool bUseCMark) +{ + useCMark = bUseCMark; + ui->cmPreview->setVisible(useCMark); + updateCMPreview(); +} + +void ChatWidget::updateCMPreview() +{ + if (!useCMark) return; + + QString message = ui->chatTextEdit->toHtml(); + QString formattedMessage = RsHtml().formatText(ui->cmPreview->document(), message, RSHTML_FORMATTEXT_USE_CMARK); + ui->cmPreview->setHtml(formattedMessage); +} + void ChatWidget::quote() { QString text = ui->textBrowser->textCursor().selection().toPlainText(); diff --git a/retroshare-gui/src/gui/chat/ChatWidget.h b/retroshare-gui/src/gui/chat/ChatWidget.h index 8de38620e..127575d73 100644 --- a/retroshare-gui/src/gui/chat/ChatWidget.h +++ b/retroshare-gui/src/gui/chat/ChatWidget.h @@ -128,6 +128,8 @@ public: public slots: void updateStatus(const QString &peer_id, int status); + void setUseCMark(const bool bUseCMark); + void updateCMPreview(); private slots: //void pasteCreateMsgLink() ; @@ -222,7 +224,8 @@ private: bool typing; int peerStatus; - bool sendingBlocked; + bool sendingBlocked; + bool useCMark; time_t lastStatusSendTime; diff --git a/retroshare-gui/src/gui/chat/ChatWidget.ui b/retroshare-gui/src/gui/chat/ChatWidget.ui index 9ea7277ef..16a411eb5 100644 --- a/retroshare-gui/src/gui/chat/ChatWidget.ui +++ b/retroshare-gui/src/gui/chat/ChatWidget.ui @@ -268,22 +268,34 @@ border-image: url(:/images/closepressed.png) - - - - 0 - 0 - + + + Qt::Horizontal - - - 0 - 30 - + + 2 - - Type a message here + + false + + + + 0 + 0 + + + + + 0 + 30 + + + + Type a message here + + + @@ -915,6 +927,21 @@ border-image: url(:/images/closepressed.png) Show Hidden Images + + + true + + + + :/icons/png/markdown-mark.png:/icons/png/markdown-mark.png + + + Send as CommonMark + + + Text will be formatted using CommonMark. + + @@ -945,8 +972,8 @@ border-image: url(:/images/closepressed.png) - + diff --git a/retroshare-gui/src/gui/chat/CreateLobbyDialog.cpp b/retroshare-gui/src/gui/chat/CreateLobbyDialog.cpp index a9871ab77..b0e5da106 100644 --- a/retroshare-gui/src/gui/chat/CreateLobbyDialog.cpp +++ b/retroshare-gui/src/gui/chat/CreateLobbyDialog.cpp @@ -106,7 +106,7 @@ void CreateLobbyDialog::checkTextFields() break ; } - RsIdentityDetails(idd) ; + RsIdentityDetails idd; rsIdentity->getIdDetails(id,idd) ; diff --git a/retroshare-gui/src/gui/chat/CreateLobbyDialog.ui b/retroshare-gui/src/gui/chat/CreateLobbyDialog.ui index 1d2340e08..77aab56ea 100644 --- a/retroshare-gui/src/gui/chat/CreateLobbyDialog.ui +++ b/retroshare-gui/src/gui/chat/CreateLobbyDialog.ui @@ -11,17 +11,26 @@ - Create Chat Lobby + Create Chat Room :/images/logo/logo_32.png:/images/logo/logo_32.png - + 0 - + + 0 + + + 0 + + + 0 + + 0 @@ -29,11 +38,11 @@ - + - A chat lobby is a decentralized and anonymous chat group. All participants receive all messages. Once the lobby is created you can invite other friends from the Friends tab. + A chat room is a decentralized and anonymous chat group. All participants receive all messages. Once the room is created you can invite other friend nodes with invite button on top right. true @@ -41,16 +50,16 @@ - + - - + + - + - + - Lobby name: + Room name: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -61,9 +70,9 @@ - + - Lobby topic: + Room topic: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -74,7 +83,7 @@ - + Identity to use: @@ -84,7 +93,7 @@ - + Visibility: @@ -113,7 +122,7 @@ - <html><head/><body><p>If you check this, only PGP-signed ids can be used to join and talk in this lobby. This limitation prevents anonymous spamming as it becomes possible for at least some people in the lobby to locate the spammer's node.</p></body></html> + <html><head/><body><p>If you check this, only PGP-signed ids can be used to join and talk in this room. This limitation prevents anonymous spamming as it becomes possible for at least some people in the room to locate the spammer's node.</p></body></html> require PGP-signed identities @@ -121,7 +130,7 @@ - + Qt::LeftToRight @@ -136,7 +145,7 @@ - + Qt::Vertical @@ -152,34 +161,37 @@ - + - + Select the Friends with which you want to group chat. - - - true - + - + 0 - 0 + 4 + + + 20 + 0 + + - 52487 - 524287 + 1677215 + 16777215 - 220 + 0 0 @@ -189,59 +201,6 @@ 0 - - false - - - QDockWidget::NoDockWidgetFeatures - - - Invited friends - - - - - 0 - - - 0 - - - - - - 0 - 4 - - - - - 20 - 0 - - - - - 1677215 - 16777215 - - - - - 0 - 0 - - - - - 0 - 0 - - - - - - @@ -249,7 +208,7 @@ - + QLayout::SetDefaultConstraint diff --git a/retroshare-gui/src/gui/common/FriendSelectionWidget.ui b/retroshare-gui/src/gui/common/FriendSelectionWidget.ui index 23d98c9b6..d3682f014 100644 --- a/retroshare-gui/src/gui/common/FriendSelectionWidget.ui +++ b/retroshare-gui/src/gui/common/FriendSelectionWidget.ui @@ -10,19 +10,21 @@ 320 - - + + + 0 + + + 0 + + + 0 + + 0 - - - Search : - - - - - + diff --git a/retroshare-gui/src/gui/common/GroupTreeWidget.cpp b/retroshare-gui/src/gui/common/GroupTreeWidget.cpp index fd927983a..87be83e91 100644 --- a/retroshare-gui/src/gui/common/GroupTreeWidget.cpp +++ b/retroshare-gui/src/gui/common/GroupTreeWidget.cpp @@ -18,6 +18,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. ****************************************************************/ +#include + #include "GroupTreeWidget.h" #include "ui_GroupTreeWidget.h" @@ -58,6 +60,8 @@ #define ROLE_SUBSCRIBE_FLAGS Qt::UserRole + 8 #define ROLE_COLOR Qt::UserRole + 9 #define ROLE_SAVED_ICON Qt::UserRole + 10 +#define ROLE_SEARCH_STRING Qt::UserRole + 11 +#define ROLE_REQUEST_ID Qt::UserRole + 12 #define FILTER_NAME_INDEX 0 #define FILTER_DESC_INDEX 1 @@ -132,6 +136,10 @@ GroupTreeWidget::GroupTreeWidget(QWidget *parent) : ui->filterLineEdit->addFilter(QIcon(), tr("Description"), FILTER_DESC_INDEX , tr("Search Description")); ui->filterLineEdit->setCurrentFilter(FILTER_NAME_INDEX); + ui->distantSearchLineEdit->setPlaceholderText(tr("Search entire network...")) ; + + connect(ui->distantSearchLineEdit,SIGNAL(returnPressed()),this,SLOT(distantSearch())) ; + /* Initialize display button */ initDisplayMenu(ui->displayButton); @@ -407,6 +415,54 @@ QTreeWidgetItem *GroupTreeWidget::addCategoryItem(const QString &name, const QIc return item; } +void GroupTreeWidget::removeSearchItem(QTreeWidgetItem *item) +{ + ui->treeWidget->takeTopLevelItem(ui->treeWidget->indexOfTopLevelItem(item)) ; +} + +QTreeWidgetItem *GroupTreeWidget::addSearchItem(const QString& search_string, uint32_t id, const QIcon& icon) +{ + QTreeWidgetItem *item = addCategoryItem(search_string,icon,true); + + item->setData(COLUMN_DATA,ROLE_SEARCH_STRING,search_string) ; + item->setData(COLUMN_DATA,ROLE_REQUEST_ID ,id) ; + + return item; +} + +void GroupTreeWidget::setDistSearchVisible(bool visible) +{ + ui->distantSearchLineEdit->setVisible(visible); +} + +bool GroupTreeWidget::isSearchRequestResult(QPoint &point,QString& group_id,uint32_t& search_req_id) +{ + QTreeWidgetItem *item = ui->treeWidget->itemAt(point); + if (item == NULL) + return false; + + QTreeWidgetItem *parent = item->parent(); + + if(parent == NULL) + return false ; + + search_req_id = parent->data(COLUMN_DATA, ROLE_REQUEST_ID).toUInt(); + group_id = itemId(item) ; + + return search_req_id > 0; +} + +bool GroupTreeWidget::isSearchRequestItem(QPoint &point,uint32_t& search_req_id) +{ + QTreeWidgetItem *item = ui->treeWidget->itemAt(point); + if (item == NULL) + return false; + + search_req_id = item->data(COLUMN_DATA, ROLE_REQUEST_ID).toUInt(); + + return search_req_id > 0; +} + QString GroupTreeWidget::itemId(QTreeWidgetItem *item) { if (item == NULL) { @@ -770,6 +826,13 @@ void GroupTreeWidget::resort(QTreeWidgetItem *categoryItem) } } +void GroupTreeWidget::distantSearch() +{ + emit distantSearchRequested(ui->distantSearchLineEdit->text()); + + ui->distantSearchLineEdit->clear(); +} + void GroupTreeWidget::sort() { resort(NULL); diff --git a/retroshare-gui/src/gui/common/GroupTreeWidget.h b/retroshare-gui/src/gui/common/GroupTreeWidget.h index acd2948f0..59e0ae261 100644 --- a/retroshare-gui/src/gui/common/GroupTreeWidget.h +++ b/retroshare-gui/src/gui/common/GroupTreeWidget.h @@ -82,6 +82,11 @@ public: // Add a new category item QTreeWidgetItem *addCategoryItem(const QString &name, const QIcon &icon, bool expand); + // Add a new search item + void setDistSearchVisible(bool) ; // shows/hides distant search UI parts. + QTreeWidgetItem *addSearchItem(const QString& search_string, uint32_t id, const QIcon &icon) ; + void removeSearchItem(QTreeWidgetItem *item); + // Get id of item QString itemId(QTreeWidgetItem *item); QString itemIdAt(QPoint &point); @@ -90,6 +95,9 @@ public: // Set the unread count of an item void setUnreadCount(QTreeWidgetItem *item, int unreadCount); + bool isSearchRequestItem(QPoint &point,uint32_t& search_req_id); + bool isSearchRequestResult(QPoint &point, QString &group_id, uint32_t& search_req_id); + QTreeWidgetItem *getItemFromId(const QString &id); QTreeWidgetItem *activateId(const QString &id, bool focus); @@ -110,6 +118,7 @@ signals: void treeCustomContextMenuRequested(const QPoint &pos); void treeCurrentItemChanged(const QString &id); void treeItemActivated(const QString &id); + void distantSearchRequested(const QString&) ; protected: void changeEvent(QEvent *e); @@ -119,6 +128,7 @@ private slots: void currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous); void itemActivated(QTreeWidgetItem *item, int column); void filterChanged(); + void distantSearch(); void sort(); diff --git a/retroshare-gui/src/gui/common/GroupTreeWidget.ui b/retroshare-gui/src/gui/common/GroupTreeWidget.ui index c4d3948b1..26167dcd7 100644 --- a/retroshare-gui/src/gui/common/GroupTreeWidget.ui +++ b/retroshare-gui/src/gui/common/GroupTreeWidget.ui @@ -124,6 +124,13 @@ + + + + <html><head/><body><p>Searches a single keyword into the reachable network.</p><p>Objects already provided by friend nodes are not reported.</p></body></html> + + + diff --git a/retroshare-gui/src/gui/common/RSTextBrowser.cpp b/retroshare-gui/src/gui/common/RSTextBrowser.cpp index 8c59c815c..4d58e07d7 100644 --- a/retroshare-gui/src/gui/common/RSTextBrowser.cpp +++ b/retroshare-gui/src/gui/common/RSTextBrowser.cpp @@ -107,7 +107,7 @@ QVariant RSTextBrowser::loadResource(int type, const QUrl &name) if(fi.exists() && fi.isFile()) { QString cpath = fi.canonicalFilePath(); if (cpath.startsWith(QDir(QString::fromUtf8(RsAccounts::ConfigDirectory().c_str())).canonicalPath(),Qt::CaseInsensitive) - || cpath.startsWith(QDir(QString::fromUtf8(RsAccounts::DataDirectory().c_str())).canonicalPath(),Qt::CaseInsensitive)) + || cpath.startsWith(QDir(QString::fromUtf8(RsAccounts::systemDataDirectory().c_str())).canonicalPath(),Qt::CaseInsensitive)) return QTextBrowser::loadResource(type, name); }} @@ -251,53 +251,22 @@ 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 (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; + if (!cursor.selectedText().isEmpty()){ + QRegExp rx("" tags, converts "\n" to "
" and converts "\n\n" diff --git a/retroshare-gui/src/gui/common/html.h b/retroshare-gui/src/gui/common/rshtml.h similarity index 95% rename from retroshare-gui/src/gui/common/html.h rename to retroshare-gui/src/gui/common/rshtml.h index bb217d220..627b81a59 100644 --- a/retroshare-gui/src/gui/common/html.h +++ b/retroshare-gui/src/gui/common/rshtml.h @@ -1,7 +1,7 @@ /**************************************************************** - * This file is distributed under the following license: - * - * Copyright (c) 2008, defnax + * This file is distributed under the following license: + * + * Copyright (c) 2008, defnax * Copyright (c) 2008, Matt Edman, Justin Hipple * * This program is free software; you can redistribute it and/or @@ -21,8 +21,8 @@ ****************************************************************/ /* -** \file html.h -** \version $Id: html.h 2362 2008-02-29 04:30:11Z edmanm $ +** \file rshtml.h +** \version $Id: rshtml.h 2362 2008-02-29 04:30:11Z edmanm $ ** \brief HTML formatting functions */ diff --git a/retroshare-gui/src/gui/common/vmessagebox.cpp b/retroshare-gui/src/gui/common/vmessagebox.cpp index 933310acd..f1465fa4f 100644 --- a/retroshare-gui/src/gui/common/vmessagebox.cpp +++ b/retroshare-gui/src/gui/common/vmessagebox.cpp @@ -1,7 +1,7 @@ /**************************************************************** - * This file is distributed under the following license: - * - * Copyright (c) 2008, defnax + * This file is distributed under the following license: + * + * Copyright (c) 2008, defnax * Copyright (c) 2008, Matt Edman, Justin Hipple * * This program is free software; you can redistribute it and/or @@ -26,7 +26,7 @@ ** \brief Provides a custom Vidalia mesage box */ -#include "html.h" +#include "rshtml.h" #include "vmessagebox.h" diff --git a/retroshare-gui/src/gui/elastic/arrow.cpp b/retroshare-gui/src/gui/elastic/arrow.cpp index 8ef0991d4..f9fc8a95b 100644 --- a/retroshare-gui/src/gui/elastic/arrow.cpp +++ b/retroshare-gui/src/gui/elastic/arrow.cpp @@ -37,7 +37,7 @@ #include #include "arrow.h" -#include "node.h" +#include "elnode.h" #include diff --git a/retroshare-gui/src/gui/elastic/edge.cpp b/retroshare-gui/src/gui/elastic/edge.cpp index e9e60f06b..cee1e1e88 100644 --- a/retroshare-gui/src/gui/elastic/edge.cpp +++ b/retroshare-gui/src/gui/elastic/edge.cpp @@ -42,7 +42,7 @@ #include #include "edge.h" -#include "node.h" +#include "elnode.h" #include diff --git a/retroshare-gui/src/gui/elastic/node.cpp b/retroshare-gui/src/gui/elastic/elnode.cpp similarity index 96% rename from retroshare-gui/src/gui/elastic/node.cpp rename to retroshare-gui/src/gui/elastic/elnode.cpp index 6a3020b21..99bbfd310 100644 --- a/retroshare-gui/src/gui/elastic/node.cpp +++ b/retroshare-gui/src/gui/elastic/elnode.cpp @@ -54,7 +54,7 @@ #include #include "edge.h" -#include "node.h" +#include "elnode.h" #include "graphwidget.h" #define IMAGE_AUTHED ":/images/accepted16.png" diff --git a/retroshare-gui/src/gui/elastic/node.h b/retroshare-gui/src/gui/elastic/elnode.h similarity index 96% rename from retroshare-gui/src/gui/elastic/node.h rename to retroshare-gui/src/gui/elastic/elnode.h index e43fa3521..6e59cf43d 100644 --- a/retroshare-gui/src/gui/elastic/node.h +++ b/retroshare-gui/src/gui/elastic/elnode.h @@ -39,8 +39,8 @@ ** ****************************************************************************/ -#ifndef NODE_H -#define NODE_H +#ifndef ELNODE_H +#define ELNODE_H #include #if QT_VERSION >= 0x040600 diff --git a/retroshare-gui/src/gui/elastic/graphwidget.cpp b/retroshare-gui/src/gui/elastic/graphwidget.cpp index 9aeebbeda..aa8cbf241 100644 --- a/retroshare-gui/src/gui/elastic/graphwidget.cpp +++ b/retroshare-gui/src/gui/elastic/graphwidget.cpp @@ -41,7 +41,7 @@ #include "graphwidget.h" #include "edge.h" -#include "node.h" +#include "elnode.h" #include "fft.h" #include diff --git a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp index 33c6a04e5..473b26e7d 100644 --- a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp +++ b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp @@ -46,6 +46,8 @@ #define IMAGE_EDIT ":/images/edit_16.png" #define IMAGE_SHARE ":/images/share-icon-16.png" #define IMAGE_TABNEW ":/images/tab-new.png" +#define IMAGE_DELETE ":/images/delete.png" +#define IMAGE_RETRIEVE ":/images/edit_add24.png" #define IMAGE_COMMENT "" #define TOKEN_TYPE_GROUP_SUMMARY 1 @@ -65,7 +67,7 @@ */ /** Constructor */ -GxsGroupFrameDialog::GxsGroupFrameDialog(RsGxsIfaceHelper *ifaceImpl, QWidget *parent) +GxsGroupFrameDialog::GxsGroupFrameDialog(RsGxsIfaceHelper *ifaceImpl, QWidget *parent,bool allow_dist_sync) : RsGxsUpdateBroadcastPage(ifaceImpl, parent) { /* Invoke the Qt Designer generated object setup routine */ @@ -73,6 +75,7 @@ GxsGroupFrameDialog::GxsGroupFrameDialog(RsGxsIfaceHelper *ifaceImpl, QWidget *p ui->setupUi(this); mInitialized = false; + mDistSyncAllowed = allow_dist_sync; mInFill = false; mCountChildMsgs = false; mYourGroups = NULL; @@ -92,13 +95,18 @@ GxsGroupFrameDialog::GxsGroupFrameDialog(RsGxsIfaceHelper *ifaceImpl, QWidget *p mStateHelper->addWidget(TOKEN_TYPE_GROUP_SUMMARY, ui->loadingLabel, UISTATE_LOADING_VISIBLE); connect(ui->groupTreeWidget, SIGNAL(treeCustomContextMenuRequested(QPoint)), this, SLOT(groupTreeCustomPopupMenu(QPoint))); - connect(ui->groupTreeWidget, SIGNAL(treeCurrentItemChanged(QString)), this, SLOT(changedGroup(QString))); + connect(ui->groupTreeWidget, SIGNAL(treeCurrentItemChanged(QString)), this, SLOT(changedCurrentGroup(QString))); connect(ui->groupTreeWidget->treeWidget(), SIGNAL(signalMouseMiddleButtonClicked(QTreeWidgetItem*)), this, SLOT(groupTreeMiddleButtonClicked(QTreeWidgetItem*))); connect(ui->messageTabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(messageTabCloseRequested(int))); connect(ui->messageTabWidget, SIGNAL(currentChanged(int)), this, SLOT(messageTabChanged(int))); connect(ui->todoPushButton, SIGNAL(clicked()), this, SLOT(todo())); + ui->groupTreeWidget->setDistSearchVisible(allow_dist_sync) ; + + if(allow_dist_sync) + connect(ui->groupTreeWidget, SIGNAL(distantSearchRequested(const QString&)), this, SLOT(searchNetwork(const QString&))); + /* Set initial size the splitter */ ui->splitter->setStretchFactor(0, 0); ui->splitter->setStretchFactor(1, 1); @@ -121,7 +129,7 @@ GxsGroupFrameDialog::~GxsGroupFrameDialog() delete(ui); } -void GxsGroupFrameDialog::getGroupList(std::list& group_list) +void GxsGroupFrameDialog::getGroupList(std::map &group_list) { group_list = mCachedGroupMetas ; @@ -243,6 +251,56 @@ void GxsGroupFrameDialog::updateDisplay(bool complete) updateMessageSummaryList(msgIt->first); } } + + updateSearchResults() ; +} + +void GxsGroupFrameDialog::updateSearchResults() +{ + const std::set& reqs = getSearchResults(); + + for(auto it(reqs.begin());it!=reqs.end();++it) + { + std::cerr << "updating search ID " << std::hex << *it << std::dec << std::endl; + + std::map group_infos; + + getDistantSearchResults(*it,group_infos) ; + + std::cerr << "retrieved " << std::endl; + + auto it2 = mSearchGroupsItems.find(*it); + + if(mSearchGroupsItems.end() == it2) + { + std::cerr << "GxsGroupFrameDialog::updateSearchResults(): received result notification for req " << std::hex << *it << std::dec << " but no item present!" << std::endl; + continue ; // we could create the item just as well but since this situation is not supposed to happen, I prefer to make this a failure case. + } + + QList group_items ; + + for(auto it3(group_infos.begin());it3!=group_infos.end();++it3) + if(mCachedGroupMetas.find(it3->first) == mCachedGroupMetas.end()) + { + std::cerr << " adding new group " << it3->first << " " + << it3->second.mGroupId << " \"" + << it3->second.mGroupName << "\"" << std::endl; + + GroupItemInfo i; + i.id = QString(it3->second.mGroupId.toStdString().c_str()); + i.name = QString::fromUtf8(it3->second.mGroupName.c_str()); + i.popularity = 0; // could be set to the number of hits + i.lastpost = QDateTime::fromTime_t(it3->second.mLastMessageTs); + i.subscribeFlags = 0; // irrelevant here + i.publishKey = false ; // IS_GROUP_PUBLISHER(groupInfo.mSubscribeFlags); + i.adminKey = false ; // IS_GROUP_ADMIN(groupInfo.mSubscribeFlags); + i.max_visible_posts = it3->second.mNumberOfMessages; + + group_items.push_back(i); + } + + ui->groupTreeWidget->fillGroupItems(it2->second, group_items); + } } void GxsGroupFrameDialog::todo() @@ -250,98 +308,149 @@ void GxsGroupFrameDialog::todo() QMessageBox::information(this, "Todo", text(TEXT_TODO)); } +void GxsGroupFrameDialog::removeCurrentSearch() +{ + QAction *action = dynamic_cast(sender()) ; + + if(!action) + return ; + + TurtleRequestId search_request_id = action->data().toUInt(); + + auto it = mSearchGroupsItems.find(search_request_id) ; + + if(it == mSearchGroupsItems.end()) + return ; + + ui->groupTreeWidget->removeSearchItem(it->second) ; + mSearchGroupsItems.erase(it); + + mKnownGroups.erase(search_request_id); +} + +void GxsGroupFrameDialog::removeAllSearches() +{ + for(auto it(mSearchGroupsItems.begin());it!=mSearchGroupsItems.end();++it) + ui->groupTreeWidget->removeSearchItem(it->second) ; + + mSearchGroupsItems.clear(); + mKnownGroups.clear(); +} void GxsGroupFrameDialog::groupTreeCustomPopupMenu(QPoint point) { - QMenu contextMnu(this); + // First separately handle the case of search top level items + + TurtleRequestId search_request_id = 0 ; + + if(ui->groupTreeWidget->isSearchRequestItem(point,search_request_id)) + { + QMenu contextMnu(this); + + contextMnu.addAction(QIcon(IMAGE_DELETE), tr("Remove this search"), this, SLOT(removeCurrentSearch()))->setData(search_request_id); + contextMnu.addAction(QIcon(IMAGE_DELETE), tr("Remove all searches"), this, SLOT(removeAllSearches())); + contextMnu.exec(QCursor::pos()); + return ; + } + + // Then check whether we have a searched item, or a normal group + + QString group_id_s ; + + if(ui->groupTreeWidget->isSearchRequestResult(point,group_id_s,search_request_id)) + { + QMenu contextMnu(this); + + contextMnu.addAction(QIcon(IMAGE_RETRIEVE), tr("Request data"), this, SLOT(distantRequestGroupData()))->setData(group_id_s); + contextMnu.exec(QCursor::pos()); + return ; + } QString id = ui->groupTreeWidget->itemIdAt(point); - if (!id.isEmpty()) - { + if (id.isEmpty()) return; - mGroupId = RsGxsGroupId(id.toStdString()); - int subscribeFlags = ui->groupTreeWidget->subscribeFlags(QString::fromStdString(mGroupId.toStdString())); + mGroupId = RsGxsGroupId(id.toStdString()); + int subscribeFlags = ui->groupTreeWidget->subscribeFlags(QString::fromStdString(mGroupId.toStdString())); - bool isAdmin = IS_GROUP_ADMIN(subscribeFlags); - bool isPublisher = IS_GROUP_PUBLISHER(subscribeFlags); - bool isSubscribed = IS_GROUP_SUBSCRIBED(subscribeFlags); + bool isAdmin = IS_GROUP_ADMIN(subscribeFlags); + bool isPublisher = IS_GROUP_PUBLISHER(subscribeFlags); + bool isSubscribed = IS_GROUP_SUBSCRIBED(subscribeFlags); + QMenu contextMnu(this); + QAction *action; - QAction *action; - - if (mMessageWidget) { - action = contextMnu.addAction(QIcon(IMAGE_TABNEW), tr("Open in new tab"), this, SLOT(openInNewTab())); - if (mGroupId.isNull() || messageWidget(mGroupId, true)) { - action->setEnabled(false); - } + if (mMessageWidget) { + action = contextMnu.addAction(QIcon(IMAGE_TABNEW), tr("Open in new tab"), this, SLOT(openInNewTab())); + if (mGroupId.isNull() || messageWidget(mGroupId, true)) { + action->setEnabled(false); } + } - if (isSubscribed) { - action = contextMnu.addAction(QIcon(IMAGE_UNSUBSCRIBE), tr("Unsubscribe"), this, SLOT(unsubscribeGroup())); - action->setEnabled (!mGroupId.isNull() && IS_GROUP_SUBSCRIBED(subscribeFlags)); - } else { - action = contextMnu.addAction(QIcon(IMAGE_SUBSCRIBE), tr("Subscribe"), this, SLOT(subscribeGroup())); - action->setDisabled (mGroupId.isNull() || IS_GROUP_SUBSCRIBED(subscribeFlags)); - } + if (isSubscribed) { + action = contextMnu.addAction(QIcon(IMAGE_UNSUBSCRIBE), tr("Unsubscribe"), this, SLOT(unsubscribeGroup())); + action->setEnabled (!mGroupId.isNull() && IS_GROUP_SUBSCRIBED(subscribeFlags)); + } else { + action = contextMnu.addAction(QIcon(IMAGE_SUBSCRIBE), tr("Subscribe"), this, SLOT(subscribeGroup())); + action->setDisabled (mGroupId.isNull() || IS_GROUP_SUBSCRIBED(subscribeFlags)); + } + contextMnu.addSeparator(); + + contextMnu.addAction(QIcon(icon(ICON_NEW)), text(TEXT_NEW), this, SLOT(newGroup())); + + action = contextMnu.addAction(QIcon(IMAGE_INFO), tr("Show Details"), this, SLOT(showGroupDetails())); + action->setEnabled (!mGroupId.isNull()); + + action = contextMnu.addAction(QIcon(IMAGE_EDIT), tr("Edit Details"), this, SLOT(editGroupDetails())); + action->setEnabled (!mGroupId.isNull() && isAdmin); + + uint32_t current_store_time = mInterface->getStoragePeriod(mGroupId)/86400 ; + uint32_t current_sync_time = mInterface->getSyncPeriod(mGroupId)/86400 ; + + std::cerr << "Got sync=" << current_sync_time << ". store=" << current_store_time << std::endl; + QAction *actnn = NULL; + + QMenu *ctxMenu2 = contextMnu.addMenu(tr("Synchronise posts of last...")) ; + actnn = ctxMenu2->addAction(tr(" 5 days" ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant( 5)) ; if(current_sync_time == 5) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));} + actnn = ctxMenu2->addAction(tr(" 2 weeks" ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant( 15)) ; if(current_sync_time == 15) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));} + actnn = ctxMenu2->addAction(tr(" 1 month" ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant( 30)) ; if(current_sync_time == 30) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));} + actnn = ctxMenu2->addAction(tr(" 3 months" ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant( 90)) ; if(current_sync_time == 90) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));} + actnn = ctxMenu2->addAction(tr(" 6 months" ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant(180)) ; if(current_sync_time ==180) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));} + actnn = ctxMenu2->addAction(tr(" 1 year " ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant(372)) ; if(current_sync_time ==372) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));} + actnn = ctxMenu2->addAction(tr(" Indefinitly"),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant( 0)) ; if(current_sync_time == 0) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));} + + ctxMenu2 = contextMnu.addMenu(tr("Store posts for at most...")) ; + actnn = ctxMenu2->addAction(tr(" 5 days" ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant( 5)) ; if(current_store_time == 5) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));} + actnn = ctxMenu2->addAction(tr(" 2 weeks" ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant( 15)) ; if(current_store_time == 15) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));} + actnn = ctxMenu2->addAction(tr(" 1 month" ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant( 30)) ; if(current_store_time == 30) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));} + actnn = ctxMenu2->addAction(tr(" 3 months" ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant( 90)) ; if(current_store_time == 90) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));} + actnn = ctxMenu2->addAction(tr(" 6 months" ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant(180)) ; if(current_store_time ==180) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));} + actnn = ctxMenu2->addAction(tr(" 1 year " ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant(372)) ; if(current_store_time ==372) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));} + actnn = ctxMenu2->addAction(tr(" Indefinitly"),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant( 0)) ; if(current_store_time == 0) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));} + + if (shareKeyType()) { + action = contextMnu.addAction(QIcon(IMAGE_SHARE), tr("Share publish permissions"), this, SLOT(sharePublishKey())); + action->setEnabled(!mGroupId.isNull() && isPublisher); + } + + if (getLinkType() != RetroShareLink::TYPE_UNKNOWN) { + action = contextMnu.addAction(QIcon(IMAGE_COPYLINK), tr("Copy RetroShare Link"), this, SLOT(copyGroupLink())); + action->setEnabled(!mGroupId.isNull()); + } + + contextMnu.addSeparator(); + + action = contextMnu.addAction(QIcon(":/images/message-mail-read.png"), tr("Mark all as read"), this, SLOT(markMsgAsRead())); + action->setEnabled (!mGroupId.isNull() && isSubscribed); + + action = contextMnu.addAction(QIcon(":/images/message-mail.png"), tr("Mark all as unread"), this, SLOT(markMsgAsUnread())); + action->setEnabled (!mGroupId.isNull() && isSubscribed); + + /* Add special actions */ + QList actions; + groupTreeCustomActions(mGroupId, subscribeFlags, actions); + if (!actions.isEmpty()) { contextMnu.addSeparator(); - - contextMnu.addAction(QIcon(icon(ICON_NEW)), text(TEXT_NEW), this, SLOT(newGroup())); - - action = contextMnu.addAction(QIcon(IMAGE_INFO), tr("Show Details"), this, SLOT(showGroupDetails())); - action->setEnabled (!mGroupId.isNull()); - - action = contextMnu.addAction(QIcon(IMAGE_EDIT), tr("Edit Details"), this, SLOT(editGroupDetails())); - action->setEnabled (!mGroupId.isNull() && isAdmin); - - uint32_t current_store_time = mInterface->getStoragePeriod(mGroupId)/86400 ; - uint32_t current_sync_time = mInterface->getSyncPeriod(mGroupId)/86400 ; - - std::cerr << "Got sync=" << current_sync_time << ". store=" << current_store_time << std::endl; - QAction *actnn = NULL; - - QMenu *ctxMenu2 = contextMnu.addMenu(tr("Synchronise posts of last...")) ; - actnn = ctxMenu2->addAction(tr(" 5 days" ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant( 5)) ; if(current_sync_time == 5) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));} - actnn = ctxMenu2->addAction(tr(" 2 weeks" ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant( 15)) ; if(current_sync_time == 15) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));} - actnn = ctxMenu2->addAction(tr(" 1 month" ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant( 30)) ; if(current_sync_time == 30) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));} - actnn = ctxMenu2->addAction(tr(" 3 months" ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant( 90)) ; if(current_sync_time == 90) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));} - actnn = ctxMenu2->addAction(tr(" 6 months" ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant(180)) ; if(current_sync_time ==180) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));} - actnn = ctxMenu2->addAction(tr(" 1 year " ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant(372)) ; if(current_sync_time ==372) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));} - actnn = ctxMenu2->addAction(tr(" Indefinitly"),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant( 0)) ; if(current_sync_time == 0) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));} - - ctxMenu2 = contextMnu.addMenu(tr("Store posts for at most...")) ; - actnn = ctxMenu2->addAction(tr(" 5 days" ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant( 5)) ; if(current_store_time == 5) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));} - actnn = ctxMenu2->addAction(tr(" 2 weeks" ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant( 15)) ; if(current_store_time == 15) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));} - actnn = ctxMenu2->addAction(tr(" 1 month" ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant( 30)) ; if(current_store_time == 30) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));} - actnn = ctxMenu2->addAction(tr(" 3 months" ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant( 90)) ; if(current_store_time == 90) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));} - actnn = ctxMenu2->addAction(tr(" 6 months" ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant(180)) ; if(current_store_time ==180) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));} - actnn = ctxMenu2->addAction(tr(" 1 year " ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant(372)) ; if(current_store_time ==372) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));} - actnn = ctxMenu2->addAction(tr(" Indefinitly"),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant( 0)) ; if(current_store_time == 0) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));} - - if (shareKeyType()) { - action = contextMnu.addAction(QIcon(IMAGE_SHARE), tr("Share publish permissions"), this, SLOT(sharePublishKey())); - action->setEnabled(!mGroupId.isNull() && isPublisher); - } - - if (getLinkType() != RetroShareLink::TYPE_UNKNOWN) { - action = contextMnu.addAction(QIcon(IMAGE_COPYLINK), tr("Copy RetroShare Link"), this, SLOT(copyGroupLink())); - action->setEnabled(!mGroupId.isNull()); - } - - contextMnu.addSeparator(); - - action = contextMnu.addAction(QIcon(":/images/message-mail-read.png"), tr("Mark all as read"), this, SLOT(markMsgAsRead())); - action->setEnabled (!mGroupId.isNull() && isSubscribed); - - action = contextMnu.addAction(QIcon(":/images/message-mail.png"), tr("Mark all as unread"), this, SLOT(markMsgAsUnread())); - action->setEnabled (!mGroupId.isNull() && isSubscribed); - - /* Add special actions */ - QList actions; - groupTreeCustomActions(mGroupId, subscribeFlags, actions); - if (!actions.isEmpty()) { - contextMnu.addSeparator(); - contextMnu.addActions(actions); - } + contextMnu.addActions(actions); } //Add Standard Menu @@ -594,7 +703,7 @@ bool GxsGroupFrameDialog::navigate(const RsGxsGroupId &groupId, const RsGxsMessa return false; } - changedGroup(groupIdString); + changedCurrentGroup(groupIdString); /* search exisiting tab */ GxsMessageFrameWidget *msgWidget = messageWidget(mGroupId, false); @@ -655,7 +764,7 @@ GxsCommentDialog *GxsGroupFrameDialog::commentWidget(const RsGxsMessageId& msgId return NULL; } -void GxsGroupFrameDialog::changedGroup(const QString &groupId) +void GxsGroupFrameDialog::changedCurrentGroup(const QString &groupId) { if (mInFill) { return; @@ -798,7 +907,7 @@ void GxsGroupFrameDialog::groupInfoToGroupItemInfo(const RsGroupMetaData &groupI } } -void GxsGroupFrameDialog::insertGroupsData(const std::list &groupList, const RsUserdata *userdata) +void GxsGroupFrameDialog::insertGroupsData(const std::map &groupList, const RsUserdata *userdata) { if (!mInitialized) { return; @@ -806,20 +915,18 @@ void GxsGroupFrameDialog::insertGroupsData(const std::list &gro mInFill = true; - std::list::const_iterator it; - QList adminList; QList subList; QList popList; QList otherList; std::multimap popMap; - for (it = groupList.begin(); it != groupList.end(); ++it) { + for (auto it = groupList.begin(); it != groupList.end(); ++it) { /* sort it into Publish (Own), Subscribed, Popular and Other */ - uint32_t flags = it->mSubscribeFlags; + uint32_t flags = it->second.mSubscribeFlags; GroupItemInfo groupItemInfo; - groupInfoToGroupItemInfo(*it, groupItemInfo, userdata); + groupInfoToGroupItemInfo(it->second, groupItemInfo, userdata); if (IS_GROUP_SUBSCRIBED(flags)) { @@ -836,7 +943,7 @@ void GxsGroupFrameDialog::insertGroupsData(const std::list &gro else { //popMap.insert(std::make_pair(it->mPop, groupItemInfo)); /* rate the others by popularity */ - popMap.insert(std::make_pair(it->mLastPost, groupItemInfo)); /* rate the others by time of last post */ + popMap.insert(std::make_pair(it->second.mLastPost, groupItemInfo)); /* rate the others by time of last post */ } } @@ -947,9 +1054,12 @@ void GxsGroupFrameDialog::loadGroupSummary(const uint32_t &token) RsUserdata *userdata = NULL; loadGroupSummaryToken(token, groupInfo, userdata); - mCachedGroupMetas = groupInfo ; + mCachedGroupMetas.clear(); + for(auto it(groupInfo.begin());it!=groupInfo.end();++it) + mCachedGroupMetas[(*it).mGroupId] = *it; - insertGroupsData(groupInfo, userdata); + insertGroupsData(mCachedGroupMetas, userdata); + updateSearchResults(); mStateHelper->setLoading(TOKEN_TYPE_GROUP_SUMMARY, false); @@ -1083,3 +1193,41 @@ void GxsGroupFrameDialog::loadRequest(const TokenQueue *queue, const TokenReques } } } + +TurtleRequestId GxsGroupFrameDialog::distantSearch(const QString& search_string) // this should be overloaded in the child class +{ + std::cerr << "Searching for \"" << search_string.toStdString() << "\". Function is not overloaded, so nothing will happen." << std::endl; + return 0; +} + +void GxsGroupFrameDialog::searchNetwork(const QString& search_string) +{ + if(search_string.isNull()) + return ; + + uint32_t request_id = distantSearch(search_string); + + if(request_id == 0) + return ; + + mSearchGroupsItems[request_id] = ui->groupTreeWidget->addSearchItem(tr("Search for")+ " \"" + search_string + "\"",(uint32_t)request_id,QIcon(icon(ICON_SEARCH))); +} + +void GxsGroupFrameDialog::distantRequestGroupData() +{ + QAction *action = dynamic_cast(sender()) ; + + if(!action) + return ; + + RsGxsGroupId group_id(action->data().toString().toStdString()); + + if(group_id.isNull()) + { + std::cerr << "Cannot retrieve group! Group id is null!" << std::endl; + } + + std::cerr << "Explicit request for group " << group_id << std::endl; + checkRequestGroup(group_id) ; +} + diff --git a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.h b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.h index 2c0dca594..46ff05ec3 100644 --- a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.h +++ b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.h @@ -67,11 +67,12 @@ public: ICON_SUBSCRIBED_GROUP, ICON_POPULAR_GROUP, ICON_OTHER_GROUP, + ICON_SEARCH, ICON_DEFAULT }; public: - GxsGroupFrameDialog(RsGxsIfaceHelper *ifaceImpl, QWidget *parent = 0); + GxsGroupFrameDialog(RsGxsIfaceHelper *ifaceImpl, QWidget *parent = 0,bool allow_dist_sync=false); virtual ~GxsGroupFrameDialog(); bool navigate(const RsGxsGroupId &groupId, const RsGxsMessageId& msgId); @@ -81,7 +82,7 @@ public: virtual QString getHelpString() const =0; - virtual void getGroupList(std::list& groups) ; + virtual void getGroupList(std::map &groups) ; protected: virtual void showEvent(QShowEvent *event); @@ -94,6 +95,7 @@ protected: virtual RetroShareLink::enumType getLinkType() = 0; virtual GroupFrameSettings::Type groupFrameSettingsType() { return GroupFrameSettings::Nothing; } virtual void groupInfoToGroupItemInfo(const RsGroupMetaData &groupInfo, GroupItemInfo &groupItemInfo, const RsUserdata *userdata); + virtual void checkRequestGroup(const RsGxsGroupId& /* grpId */) {} // overload this one in order to retrieve full group data when the group is browsed private slots: void todo(); @@ -106,8 +108,9 @@ private slots: void restoreGroupKeys(); void newGroup(); + void distantRequestGroupData(); - void changedGroup(const QString &groupId); + void changedCurrentGroup(const QString &groupId); void groupTreeMiddleButtonClicked(QTreeWidgetItem *item); void openInNewTab(); void messageTabCloseRequested(int index); @@ -130,10 +133,15 @@ private slots: void loadComment(const RsGxsGroupId &grpId, const QVector& msg_versions,const RsGxsMessageId &most_recent_msgId, const QString &title); + void searchNetwork(const QString &search_string) ; + void removeAllSearches(); + void removeCurrentSearch(); + private: virtual QString text(TextType type) = 0; virtual QString icon(IconType type) = 0; virtual QString settingsGroupName() = 0; + virtual TurtleRequestId distantSearch(const QString& search_string) ; virtual GxsGroupDialog *createNewGroupDialog(TokenQueue *tokenQueue) = 0; virtual GxsGroupDialog *createGroupDialog(TokenQueue *tokenQueue, RsTokenService *tokenService, GxsGroupDialog::Mode mode, RsGxsGroupId groupId) = 0; @@ -142,10 +150,12 @@ private: virtual void groupTreeCustomActions(RsGxsGroupId /*grpId*/, int /*subscribeFlags*/, QList &/*actions*/) {} virtual RsGxsCommentService *getCommentService() { return NULL; } virtual QWidget *createCommentHeaderWidget(const RsGxsGroupId &/*grpId*/, const RsGxsMessageId &/*msgId*/) { return NULL; } + virtual bool getDistantSearchResults(TurtleRequestId /* id */, std::map& /* group_infos */){ return false ;} void initUi(); void updateMessageSummaryList(RsGxsGroupId groupId); + void updateSearchResults(); void openGroupInNewTab(const RsGxsGroupId &groupId); void groupSubscribe(bool subscribe); @@ -153,7 +163,7 @@ private: void processSettings(bool load); // New Request/Response Loading Functions. - void insertGroupsData(const std::list &groupList, const RsUserdata *userdata); + void insertGroupsData(const std::map &groupList, const RsUserdata *userdata); void requestGroupSummary(); void loadGroupSummary(const uint32_t &token); @@ -180,6 +190,7 @@ protected: private: bool mInitialized; bool mInFill; + bool mDistSyncAllowed; QString mSettingsName; RsGxsGroupId mGroupId; RsGxsIfaceHelper *mInterface; @@ -200,7 +211,10 @@ private: /** Qt Designer generated object */ Ui::GxsGroupFrameDialog *ui; - std::list mCachedGroupMetas; + std::map mCachedGroupMetas; + + std::map mSearchGroupsItems ; + std::map > mKnownGroups; }; #endif diff --git a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.ui b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.ui index 274207b5c..7431deb97 100644 --- a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.ui +++ b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.ui @@ -7,7 +7,7 @@ 0 0 619 - 420 + 493
@@ -38,7 +38,16 @@ QFrame::Sunken - + + 2 + + + 2 + + + 2 + + 2 diff --git a/retroshare-gui/src/gui/gxs/GxsMessageFramePostWidget.h b/retroshare-gui/src/gui/gxs/GxsMessageFramePostWidget.h index 2a42cb772..bebdae7cc 100644 --- a/retroshare-gui/src/gui/gxs/GxsMessageFramePostWidget.h +++ b/retroshare-gui/src/gui/gxs/GxsMessageFramePostWidget.h @@ -57,6 +57,7 @@ protected: virtual void groupNameChanged(const QString &/*name*/) {} virtual void clearPosts() = 0; + virtual void blank() = 0; virtual bool navigatePostItem(const RsGxsMessageId& msgId) = 0; /* Thread functions */ diff --git a/retroshare-gui/src/gui/gxs/GxsMessageFrameWidget.cpp b/retroshare-gui/src/gui/gxs/GxsMessageFrameWidget.cpp index e3b4f3cfe..18db60fa2 100644 --- a/retroshare-gui/src/gui/gxs/GxsMessageFrameWidget.cpp +++ b/retroshare-gui/src/gui/gxs/GxsMessageFrameWidget.cpp @@ -72,21 +72,26 @@ bool GxsMessageFrameWidget::isWaiting() void GxsMessageFrameWidget::setGroupId(const RsGxsGroupId &groupId) { - if (mGroupId == groupId) { - if (!groupId.isNull()) { - return; + if (mGroupId == groupId && !groupId.isNull()) + return; + + if(!groupId.isNull()) + { + mAcknowledgeReadStatusToken = 0; + if (mStateHelper->isLoading(mTokenTypeAcknowledgeReadStatus)) { + mStateHelper->setLoading(mTokenTypeAcknowledgeReadStatus, false); + + emit waitingChanged(this); } + + mGroupId = groupId; + groupIdChanged(); } - - mAcknowledgeReadStatusToken = 0; - if (mStateHelper->isLoading(mTokenTypeAcknowledgeReadStatus)) { - mStateHelper->setLoading(mTokenTypeAcknowledgeReadStatus, false); - - emit waitingChanged(this); - } - - mGroupId = groupId; - groupIdChanged(); + else + { + mGroupId.clear(); + blank(); // clear the displayed data, because no group is selected. + } } void GxsMessageFrameWidget::setAllMessagesRead(bool read) diff --git a/retroshare-gui/src/gui/gxs/GxsMessageFrameWidget.h b/retroshare-gui/src/gui/gxs/GxsMessageFrameWidget.h index 71d0ae2a1..a99aada3c 100644 --- a/retroshare-gui/src/gui/gxs/GxsMessageFrameWidget.h +++ b/retroshare-gui/src/gui/gxs/GxsMessageFrameWidget.h @@ -43,6 +43,7 @@ public: virtual void groupIdChanged() = 0; virtual QString groupName(bool withUnreadCount) = 0; virtual QIcon groupIcon() = 0; + virtual void blank() =0; virtual bool navigate(const RsGxsMessageId& msgId) = 0; virtual bool isLoading(); virtual bool isWaiting(); diff --git a/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastBase.cpp b/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastBase.cpp index ffbd6147e..76274b27a 100644 --- a/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastBase.cpp +++ b/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastBase.cpp @@ -16,12 +16,19 @@ RsGxsUpdateBroadcastBase::RsGxsUpdateBroadcastBase(RsGxsIfaceHelper *ifaceImpl, connect(mUpdateBroadcast, SIGNAL(changed()), this, SLOT(updateBroadcastChanged())); connect(mUpdateBroadcast, SIGNAL(grpsChanged(std::list, std::list)), this, SLOT(updateBroadcastGrpsChanged(std::list,std::list))); connect(mUpdateBroadcast, SIGNAL(msgsChanged(std::map >, std::map >)), this, SLOT(updateBroadcastMsgsChanged(std::map >,std::map >))); + connect(mUpdateBroadcast, SIGNAL(distantSearchResultsChanged(const std::list&)), this, SLOT(updateBroadcastDistantSearchResultsChanged(const std::list&))); } RsGxsUpdateBroadcastBase::~RsGxsUpdateBroadcastBase() { } +void RsGxsUpdateBroadcastBase::updateBroadcastDistantSearchResultsChanged(const std::list& ids) +{ + for(auto it(ids.begin());it!=ids.end();++it) + mTurtleResults.insert(*it); +} + void RsGxsUpdateBroadcastBase::fillComplete() { mFillComplete = true; @@ -37,6 +44,9 @@ void RsGxsUpdateBroadcastBase::securedUpdateDisplay() return; } + // This is *bad* because if the connection is done asynchronously the client will call mGrpIds, mGrpIdsMeta, etc without the guarranty that the + // the structed havnt' been cleared in the mean time. + emit fillDisplay(mFillComplete); mFillComplete = false; @@ -75,7 +85,7 @@ void RsGxsUpdateBroadcastBase::updateBroadcastChanged() // 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()) + if (!mGrpIds.empty() || !mGrpIdsMeta.empty() /*|| !mMsgIds.empty()*/ || !mMsgIdsMeta.empty() || !mTurtleResults.empty()) mFillComplete = true ; securedUpdateDisplay(); diff --git a/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastBase.h b/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastBase.h index 90dd3f507..704ff2157 100644 --- a/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastBase.h +++ b/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastBase.h @@ -7,6 +7,8 @@ class QShowEvent; class RsGxsIfaceHelper; class RsGxsUpdateBroadcast; +typedef uint32_t TurtleRequestId ; + class RsGxsUpdateBroadcastBase : public QObject { friend class RsGxsUpdateBroadcastPage; @@ -25,6 +27,7 @@ public: const std::map > &getMsgIds() { return mMsgIds; } const std::map > &getMsgIdsMeta() { return mMsgIdsMeta; } void getAllMsgIds(std::map > &msgIds); + const std::set& getSearchResults() { return mTurtleResults ; } protected: void fillComplete(); @@ -39,6 +42,7 @@ private slots: void updateBroadcastChanged(); void updateBroadcastGrpsChanged(const std::list& grpIds, const std::list &grpIdsMeta); void updateBroadcastMsgsChanged(const std::map >& msgIds, const std::map >& msgIdsMeta); + void updateBroadcastDistantSearchResultsChanged(const std::list& ids); void securedUpdateDisplay(); private: @@ -49,4 +53,5 @@ private: std::set mGrpIdsMeta; std::map > mMsgIds; std::map > mMsgIdsMeta; + std::set mTurtleResults; }; diff --git a/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastPage.cpp b/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastPage.cpp index 629148688..c0d19c56f 100644 --- a/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastPage.cpp +++ b/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastPage.cpp @@ -22,6 +22,11 @@ void RsGxsUpdateBroadcastPage::setUpdateWhenInvisible(bool update) mBase->setUpdateWhenInvisible(update); } +const std::set& RsGxsUpdateBroadcastPage::getSearchResults() +{ + return mBase->getSearchResults(); +} + const std::set &RsGxsUpdateBroadcastPage::getGrpIdsMeta() { return mBase->getGrpIdsMeta(); diff --git a/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastPage.h b/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastPage.h index 0c67f58ff..e3e9a4563 100644 --- a/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastPage.h +++ b/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastPage.h @@ -13,6 +13,7 @@ class RsGxsIfaceHelper; class RsGxsUpdateBroadcastBase; +typedef uint32_t TurtleRequestId ; class RsGxsUpdateBroadcastPage : public MainPage { @@ -30,6 +31,7 @@ public: const std::map > &getMsgIds(); const std::map > &getMsgIdsMeta(); void getAllMsgIds(std::map > &msgIds); + const std::set& getSearchResults(); protected: virtual void showEvent(QShowEvent *event); diff --git a/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastWidget.cpp b/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastWidget.cpp index c20809937..d3d1c5ec9 100644 --- a/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastWidget.cpp +++ b/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastWidget.cpp @@ -29,6 +29,10 @@ const std::set &RsGxsUpdateBroadcastWidget::getGrpIds() return mBase->getGrpIds(); } +const std::set& RsGxsUpdateBroadcastWidget::getSearchResults() +{ + return mBase->getSearchResults(); +} const std::set &RsGxsUpdateBroadcastWidget::getGrpIdsMeta() { return mBase->getGrpIdsMeta(); diff --git a/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastWidget.h b/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastWidget.h index f0ab07742..f99a34d04 100644 --- a/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastWidget.h +++ b/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastWidget.h @@ -13,6 +13,7 @@ class RsGxsIfaceHelper; class RsGxsUpdateBroadcastBase; +typedef uint32_t TurtleRequestId; class RsGxsUpdateBroadcastWidget : public QWidget { @@ -30,6 +31,7 @@ public: const std::map > &getMsgIds(); const std::map > &getMsgIdsMeta(); void getAllMsgIds(std::map > &msgIds); + const std::set& getSearchResults() ; RsGxsIfaceHelper *interfaceHelper() { return mInterfaceHelper; } diff --git a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp index b4470ac5c..6d8105531 100644 --- a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp +++ b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp @@ -31,6 +31,7 @@ #include "gui/RetroShareLink.h" #include "util/HandleRichText.h" #include "util/misc.h" +#include "util/rsdir.h" #include @@ -449,11 +450,10 @@ void CreateGxsChannelMsg::addAttachment(const std::string &path) } FileInfo fInfo; - std::string filename; + std::string filename = RsDirUtil::getTopDir(path); uint64_t size = 0; RsFileHash hash ; - - rsGxsChannels->ExtraFileHash(path, filename); + rsGxsChannels->ExtraFileHash(path); // Only path and filename are valid. // Destroyed when fileFrame (this subfileitem) is destroyed diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.cpp index 4bff7528b..8090dc353 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.cpp @@ -47,7 +47,7 @@ public: /** Constructor */ GxsChannelDialog::GxsChannelDialog(QWidget *parent) - : GxsGroupFrameDialog(rsGxsChannels, parent) + : GxsGroupFrameDialog(rsGxsChannels, parent,true) { } @@ -137,6 +137,8 @@ QString GxsChannelDialog::icon(IconType type) return ":/images/folder_green.png"; case ICON_OTHER_GROUP: return ":/images/folder_yellow.png"; + case ICON_SEARCH: + return ":/images/find.png"; case ICON_DEFAULT: return ":/images/channels.png"; } @@ -334,3 +336,24 @@ void GxsChannelDialog::groupInfoToGroupItemInfo(const RsGroupMetaData &groupInfo groupItemInfo.icon = iconIt.value(); } } + +TurtleRequestId GxsChannelDialog::distantSearch(const QString& search_string) +{ + return rsGxsChannels->turtleSearchRequest(search_string.toStdString()) ; +} + +bool GxsChannelDialog::getDistantSearchResults(TurtleRequestId id, std::map& group_infos) +{ + return rsGxsChannels->retrieveDistantSearchResults(id,group_infos); +} + +void GxsChannelDialog::checkRequestGroup(const RsGxsGroupId& grpId) +{ + RsGxsChannelGroup distant_group; + + if( rsGxsChannels->retrieveDistantGroup(grpId,distant_group)) // normally we should also check that the group meta is not already here. + { + std::cerr << "GxsChannelDialog::checkRequestGroup() sending turtle request for group data for group " << grpId << std::endl; + rsGxsChannels->turtleGroupRequest(grpId); + } +} diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.h b/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.h index e1f3c75d0..43a81aca5 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.h +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.h @@ -50,6 +50,10 @@ protected: virtual GroupFrameSettings::Type groupFrameSettingsType() { return GroupFrameSettings::Channel; } virtual QString getHelpString() const ; virtual void groupInfoToGroupItemInfo(const RsGroupMetaData &groupInfo, GroupItemInfo &groupItemInfo, const RsUserdata *userdata); + virtual bool getDistantSearchResults(TurtleRequestId id, std::map& group_infos); + + virtual TurtleRequestId distantSearch(const QString& search_string) ; + virtual void checkRequestGroup(const RsGxsGroupId& grpId) ; private slots: void toggleAutoDownload(); diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp index b3f5662b4..d238c7007 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp @@ -596,6 +596,20 @@ void GxsChannelPostsWidget::clearPosts() ui->fileWidget->clear(); } +void GxsChannelPostsWidget::blank() +{ + mStateHelper->setWidgetEnabled(ui->postButton, false); + mStateHelper->setWidgetEnabled(ui->subscribeToolButton, false); + + clearPosts(); + + groupNameChanged(QString()); + + ui->infoWidget->hide(); + ui->feedWidget->show(); + ui->fileWidget->hide(); +} + bool GxsChannelPostsWidget::navigatePostItem(const RsGxsMessageId &msgId) { FeedItem *feedItem = ui->feedWidget->findGxsFeedItem(groupId(), msgId); @@ -643,12 +657,22 @@ bool GxsChannelPostsWidget::insertGroupData(const uint32_t &token, RsGroupMetaDa std::vector groups; rsGxsChannels->getGroupData(token, groups); - if (groups.size() == 1) + if(groups.size() == 1) { insertChannelDetails(groups[0]); metaData = groups[0].mMeta; return true; } + else + { + RsGxsChannelGroup distant_group; + if(rsGxsChannels->retrieveDistantGroup(groupId(),distant_group)) + { + insertChannelDetails(distant_group); + metaData = distant_group.mMeta; + return true ; + } + } return false; } diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.h b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.h index ddeb474a0..cfd442973 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.h +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.h @@ -73,6 +73,7 @@ protected: virtual bool useThread() { return mUseThread; } virtual void fillThreadCreatePost(const QVariant &post, bool related, int current, int count); virtual bool navigatePostItem(const RsGxsMessageId& msgId); + virtual void blank() ; /* GxsMessageFrameWidget */ virtual void setAllMessagesReadDo(bool read, uint32_t &token); diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp index 28d0a3289..d4aee173f 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp @@ -299,6 +299,28 @@ GxsForumThreadWidget::GxsForumThreadWidget(const RsGxsGroupId &forumId, QWidget } +void GxsForumThreadWidget::blank() +{ + ui->progressBar->hide(); + ui->progressText->hide(); + ui->postText->clear() ; + ui->by_label->setId(RsGxsId()) ; + ui->time_label->clear(); + ui->lineRight->hide(); + ui->lineLeft->hide(); + ui->by_text_label->hide(); + ui->by_label->hide(); + ui->postText->setImageBlockWidget(ui->imageBlockWidget) ; + ui->postText->resetImagesStatus(Settings->getForumLoadEmbeddedImages()); + ui->threadTreeWidget->clear(); + ui->forumName->setText(""); + + mStateHelper->setWidgetEnabled(ui->newthreadButton, false); + mStateHelper->setWidgetEnabled(ui->previousButton, false); + mStateHelper->setWidgetEnabled(ui->nextButton, false); + ui->versions_CB->hide(); +} + GxsForumThreadWidget::~GxsForumThreadWidget() { if (mFillThread) { diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h index 43a90fb15..87b6ec445 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h @@ -58,6 +58,7 @@ public: // Callback for all Loads. virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req); + virtual void blank(); protected: bool eventFilter(QObject *obj, QEvent *ev); diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumsFillThread.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumsFillThread.cpp index 0d72838d9..6e33fab09 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumsFillThread.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumsFillThread.cpp @@ -114,17 +114,17 @@ void GxsForumsFillThread::run() service->requestMsgInfo(msg_token, RS_TOKREQ_ANSTYPE_DATA, opts, grpIds); /* wait for the answer */ - uint32_t requestStatus = RsTokenService::GXS_REQUEST_V2_STATUS_PENDING; + uint32_t requestStatus = RsTokenService::PENDING; while (!wasStopped()) { requestStatus = service->requestStatus(msg_token); - if (requestStatus == RsTokenService::GXS_REQUEST_V2_STATUS_FAILED || - requestStatus == RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) { + if (requestStatus == RsTokenService::FAILED || + requestStatus == RsTokenService::COMPLETE) { break; } msleep(200); } - if (requestStatus == RsTokenService::GXS_REQUEST_V2_STATUS_FAILED) + if (requestStatus == RsTokenService::FAILED) return; } @@ -143,17 +143,17 @@ void GxsForumsFillThread::run() service->requestGroupInfo(grp_token, RS_TOKREQ_ANSTYPE_DATA, opts, grpIds); /* wait for the answer */ - uint32_t requestStatus = RsTokenService::GXS_REQUEST_V2_STATUS_PENDING; + uint32_t requestStatus = RsTokenService::PENDING; while (!wasStopped()) { requestStatus = service->requestStatus(grp_token); - if (requestStatus == RsTokenService::GXS_REQUEST_V2_STATUS_FAILED || - requestStatus == RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) { + if (requestStatus == RsTokenService::FAILED || + requestStatus == RsTokenService::COMPLETE) { break; } msleep(200); } - if (requestStatus == RsTokenService::GXS_REQUEST_V2_STATUS_FAILED) + if (requestStatus == RsTokenService::FAILED) return; } @@ -221,11 +221,11 @@ void GxsForumsFillThread::run() // and tries to establish parenthood relationships between them, given that we only know the // immediate parent of a message and now its children. Some messages have a missing parent and for them // a fake top level parent is generated. - + // In order to be efficient, we first create a structure that lists the children of every mesage ID in the list. // Then the hierarchy of message is build by attaching the kids to every message until all of them have been processed. // The messages with missing parents will be the last ones remaining in the list. - + std::list > threadStack; std::map > kids_array ; std::set missing_parents; @@ -333,7 +333,7 @@ void GxsForumsFillThread::run() // The next step is to find the top level thread messages. These are defined as the messages without // any parent message ID. - + // this trick is needed because while we remove messages, the parents a given msg may already have been removed // and wrongly understand as a missing parent. @@ -434,7 +434,7 @@ void GxsForumsFillThread::run() { // We iterate through the top level thread items, and look for which message has the current item as parent. // When found, the item is put in the thread list itself, as a potential new parent. - + std::map::iterator mit = msgs.find(*it2) ; if(mit == msgs.end()) diff --git a/retroshare-gui/src/gui/help/browser/helptextbrowser.cpp b/retroshare-gui/src/gui/help/browser/helptextbrowser.cpp index 60d4ed427..f6b445e1c 100644 --- a/retroshare-gui/src/gui/help/browser/helptextbrowser.cpp +++ b/retroshare-gui/src/gui/help/browser/helptextbrowser.cpp @@ -30,7 +30,7 @@ #include #include #include "gui/common/vmessagebox.h" -#include "gui/common/html.h" +#include "gui/common/rshtml.h" #include #include "helptextbrowser.h" diff --git a/retroshare-gui/src/gui/icons.qrc b/retroshare-gui/src/gui/icons.qrc index aab1afb40..31e3f816a 100644 --- a/retroshare-gui/src/gui/icons.qrc +++ b/retroshare-gui/src/gui/icons.qrc @@ -241,5 +241,6 @@ icons/warning_yellow_128.png icons/yahoo.png icons/yandex.png + icons/png/markdown-mark.png diff --git a/retroshare-gui/src/gui/icons/png/markdown-mark.png b/retroshare-gui/src/gui/icons/png/markdown-mark.png new file mode 100644 index 000000000..da4bb7123 Binary files /dev/null and b/retroshare-gui/src/gui/icons/png/markdown-mark.png differ diff --git a/retroshare-gui/src/gui/msgs/MessageWidget.cpp b/retroshare-gui/src/gui/msgs/MessageWidget.cpp index 8fbf30039..cf359199e 100644 --- a/retroshare-gui/src/gui/msgs/MessageWidget.cpp +++ b/retroshare-gui/src/gui/msgs/MessageWidget.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include "gui/notifyqt.h" #include "gui/RetroShareLink.h" @@ -756,18 +757,19 @@ void MessageWidget::anchorClicked(const QUrl &url) { RetroShareLink link(url); - if (link.valid() == false) { - return; + if(link.valid()) + { + if (link.type() == RetroShareLink::TYPE_CERTIFICATE && currMsgFlags & RS_MSG_USER_REQUEST) { + std::cerr << "(WW) Calling some disabled code in MessageWidget::anchorClicked(). Please contact the developpers." << std::endl; + // link.setSubType(RSLINK_SUBTYPE_CERTIFICATE_USER_REQUEST); + } + + QList links; + links.append(link); + RetroShareLink::process(links); } - - if (link.type() == RetroShareLink::TYPE_CERTIFICATE && currMsgFlags & RS_MSG_USER_REQUEST) { - std::cerr << "(WW) Calling some disabled code in MessageWidget::anchorClicked(). Please contact the developpers." << std::endl; - // link.setSubType(RSLINK_SUBTYPE_CERTIFICATE_USER_REQUEST); - } - - QList links; - links.append(link); - RetroShareLink::process(links); + else + QDesktopServices::openUrl(url) ; } void MessageWidget::loadImagesAlways() diff --git a/retroshare-gui/src/gui/notifyqt.cpp b/retroshare-gui/src/gui/notifyqt.cpp index 3810fefc3..fa7bb4c82 100644 --- a/retroshare-gui/src/gui/notifyqt.cpp +++ b/retroshare-gui/src/gui/notifyqt.cpp @@ -563,7 +563,12 @@ void NotifyQt::notifyChatCleared(const ChatId& chat_id) emit chatCleared(chat_id); } -void NotifyQt::notifyTurtleSearchResult(uint32_t search_id,const std::list& files) +void NotifyQt::notifyTurtleSearchResult(uint32_t search_id,const std::list& found_groups) +{ + std::cerr << "(EE) missing code to handle GXS turtle search result." << std::endl; +} + +void NotifyQt::notifyTurtleSearchResult(const RsPeerId& pid,uint32_t search_id,const std::list& files) { { QMutexLocker m(&_mutex) ; @@ -583,7 +588,7 @@ void NotifyQt::notifyTurtleSearchResult(uint32_t search_id,const std::list& found_files); + virtual void notifyTurtleSearchResult(const RsPeerId &pid, uint32_t search_id, const std::list& found_files); + virtual void notifyTurtleSearchResult(uint32_t search_id,const std::list& found_groups); virtual void notifyPeerHasNewAvatar(std::string peer_id) ; virtual void notifyOwnAvatarChanged() ; virtual void notifyChatLobbyEvent(uint64_t /* lobby id */, uint32_t /* event type */, const RsGxsId & /*nickname*/, const std::string& /* any string */) ; diff --git a/retroshare-gui/src/gui/qss/stylesheet/Standard.qss b/retroshare-gui/src/gui/qss/stylesheet/Standard.qss index 7d518d4c2..2996d4ee5 100644 --- a/retroshare-gui/src/gui/qss/stylesheet/Standard.qss +++ b/retroshare-gui/src/gui/qss/stylesheet/Standard.qss @@ -186,7 +186,7 @@ ChatLobbyDialog QListWidget#participantsList { background: white; } -CreateLobbyDialog QFrame#lobbyFrame { +CreateLobbyDialog QFrame#roomFrame { border: 2px solid #CCCCCC; border-radius:6px; background: white; diff --git a/retroshare-gui/src/gui/settings/PluginsPage.cpp b/retroshare-gui/src/gui/settings/PluginsPage.cpp index cdc326ec0..4be141c6e 100644 --- a/retroshare-gui/src/gui/settings/PluginsPage.cpp +++ b/retroshare-gui/src/gui/settings/PluginsPage.cpp @@ -33,7 +33,7 @@ #include "../MainWindow.h" -PluginsPage::PluginsPage(QWidget * parent, Qt::WindowFlags flags) +settings::PluginsPage::PluginsPage(QWidget * parent, Qt::WindowFlags flags) : ConfigPage(parent, flags) { ui.setupUi(this); @@ -123,7 +123,7 @@ PluginsPage::PluginsPage(QWidget * parent, Qt::WindowFlags flags) if(plugin == NULL || plugin->qt_config_panel() == NULL) item->_configure_PB->hide() ; - + if(plugin != NULL){ item->enableButton->hide(); @@ -159,7 +159,7 @@ PluginsPage::PluginsPage(QWidget * parent, Qt::WindowFlags flags) QObject::connect(ui.enableAll,SIGNAL(toggled(bool)),this,SLOT(toggleEnableAll(bool))) ; } -QString PluginsPage::helpText() const +QString settings::PluginsPage::helpText() const { return tr("

  Plugins

\

Plugins are loaded from the directories listed in the bottom list.

\ @@ -171,11 +171,11 @@ QString PluginsPage::helpText() const

If you want to develop your own plugins, contact the developpers team \ they will be happy to help you out!

") ; } -void PluginsPage::toggleEnableAll(bool b) +void settings::PluginsPage::toggleEnableAll(bool b) { rsPlugins->allowAllPlugins(b) ; } -void PluginsPage::aboutPlugin(int i) +void settings::PluginsPage::aboutPlugin(int i) { std::cerr << "Launching about window for plugin " << i << std::endl; @@ -183,7 +183,7 @@ void PluginsPage::aboutPlugin(int i) if(rsPlugins->plugin(i) != NULL && (dialog = rsPlugins->plugin(i)->qt_about_page()) != NULL) dialog->exec() ; } -void PluginsPage::configurePlugin(int i) +void settings::PluginsPage::configurePlugin(int i) { std::cerr << "Launching configuration window for plugin " << i << std::endl; @@ -191,14 +191,14 @@ void PluginsPage::configurePlugin(int i) rsPlugins->plugin(i)->qt_config_panel()->show() ; } -void PluginsPage::enablePlugin(const QString& hash) +void settings::PluginsPage::enablePlugin(const QString& hash) { std::cerr << "Switching status of plugin " << hash.toStdString() << " to enable" << std::endl; rsPlugins->enablePlugin(RsFileHash(hash.toStdString()) ); } -void PluginsPage::disablePlugin(const QString& hash) +void settings::PluginsPage::disablePlugin(const QString& hash) { std::cerr << "Switching status of plugin " << hash.toStdString() << " to disable " << std::endl; @@ -206,11 +206,11 @@ void PluginsPage::disablePlugin(const QString& hash) } -PluginsPage::~PluginsPage() +settings::PluginsPage::~PluginsPage() { } /** Loads the settings for this page */ -void PluginsPage::load() +void settings::PluginsPage::load() { } diff --git a/retroshare-gui/src/gui/settings/PluginsPage.h b/retroshare-gui/src/gui/settings/PluginsPage.h index 0d8f72dac..0151592af 100644 --- a/retroshare-gui/src/gui/settings/PluginsPage.h +++ b/retroshare-gui/src/gui/settings/PluginsPage.h @@ -24,6 +24,8 @@ #include #include "ui_PluginsPage.h" +namespace settings { + class PluginsPage : public ConfigPage { Q_OBJECT @@ -52,3 +54,4 @@ class PluginsPage : public ConfigPage Ui::PluginsPage ui; }; +} // namespace settings diff --git a/retroshare-gui/src/gui/settings/ServerPage.cpp b/retroshare-gui/src/gui/settings/ServerPage.cpp index dcfe29426..b2ffd555b 100755 --- a/retroshare-gui/src/gui/settings/ServerPage.cpp +++ b/retroshare-gui/src/gui/settings/ServerPage.cpp @@ -29,11 +29,12 @@ #include -#include -#include -#include -#include -#include +#include "retroshare/rsbanlist.h" +#include "retroshare/rsconfig.h" +#include "retroshare/rsdht.h" +#include "retroshare/rspeers.h" +#include "retroshare/rsturtle.h" +#include "retroshare/rsinit.h" #include #include @@ -62,23 +63,14 @@ /// // Tabs numbers *after* non relevant tabs are removed. So do not use them to add/remove tabs!! -#ifdef RETROTOR -static const uint32_t TAB_HIDDEN_SERVICE_OUTGOING = 0; -static const uint32_t TAB_HIDDEN_SERVICE_INCOMING = 1; - -static const uint32_t TAB_NETWORK = 0; -static const uint32_t TAB_HIDDEN_SERVICE = 1; -static const uint32_t TAB_IP_FILTERS = 99; // This is a trick: these tabs do not exist, so enabling/disabling them has no effect -static const uint32_t TAB_RELAYS = 99; -#else const static uint32_t TAB_HIDDEN_SERVICE_OUTGOING = 0; -const static uint32_t TAB_HIDDEN_SERVICE_INCOMING = 2; +const static uint32_t TAB_HIDDEN_SERVICE_INCOMING = 1; +const static uint32_t TAB_HIDDEN_SERVICE_I2P_BOB = 2; const static uint32_t TAB_NETWORK = 0; -const static uint32_t TAB_IP_FILTERS = 1; -const static uint32_t TAB_HIDDEN_SERVICE = 2; +const static uint32_t TAB_HIDDEN_SERVICE = 1; +const static uint32_t TAB_IP_FILTERS = 2; const static uint32_t TAB_RELAYS = 3; -#endif //#define SERVER_DEBUG 1 @@ -90,13 +82,15 @@ ServerPage::ServerPage(QWidget * parent, Qt::WindowFlags flags) manager = NULL ; -#ifdef RETROTOR + if(RsAccounts::isTorAuto()) + { // Here we use absolute numbers instead of consts defined above, because the consts correspond to the tab number *after* this tab removal. - ui.tabWidget->removeTab(3) ; // remove relays. Not useful in Tor mode. - ui.tabWidget->removeTab(1) ; // remove IP filters. Not useful in Tor mode. + ui.tabWidget->removeTab(TAB_RELAYS) ; // remove relays. Not useful in Tor mode. + ui.tabWidget->removeTab(TAB_IP_FILTERS) ; // remove IP filters. Not useful in Tor mode. + + ui.hiddenServiceTab->removeTab(TAB_HIDDEN_SERVICE_I2P_BOB) ; // remove the Automatic I2P/BOB tab - ui.hiddenServiceTab->removeTab(1) ; // remove the Automatic I2P/BOB tab ui.hiddenpage_proxyAddress_i2p->hide() ; ui.hiddenpage_proxyLabel_i2p->hide() ; ui.hiddenpage_proxyPort_i2p->hide() ; @@ -109,7 +103,8 @@ ServerPage::ServerPage(QWidget * parent, Qt::WindowFlags flags) ui.hiddenpage_outHeader->setText(tr("Tor has been automatically configured by Retroshare. You shouldn't need to change anything here.")) ; ui.hiddenpage_inHeader->setText(tr("Tor has been automatically configured by Retroshare. You shouldn't need to change anything here.")) ; -#endif + } + ui.filteredIpsTable->setHorizontalHeaderItem(COLUMN_RANGE,new QTableWidgetItem(tr("IP Range"))) ; ui.filteredIpsTable->setHorizontalHeaderItem(COLUMN_STATUS,new QTableWidgetItem(tr("Status"))) ; ui.filteredIpsTable->setHorizontalHeaderItem(COLUMN_ORIGIN,new QTableWidgetItem(tr("Origin"))) ; @@ -137,7 +132,6 @@ ServerPage::ServerPage(QWidget * parent, Qt::WindowFlags flags) for(std::list::const_iterator it(ip_servers.begin());it!=ip_servers.end();++it) ui.IPServersLV->addItem(QString::fromStdString(*it)) ; - ui.hiddenServiceTab->setTabEnabled(TAB_HIDDEN_SERVICE_INCOMING, false); ui.gbBob->setEnabled(false); ui.swBobAdvanced->setCurrentIndex(0); @@ -197,7 +191,6 @@ ServerPage::ServerPage(QWidget * parent, Qt::WindowFlags flags) std::cerr << std::endl; #endif - connect(ui.discComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(saveAddresses())); connect(ui.netModeComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(saveAddresses())); connect(ui.localAddress, SIGNAL(textChanged(QString)),this,SLOT(saveAddresses())); @@ -237,6 +230,10 @@ ServerPage::ServerPage(QWidget * parent, Qt::WindowFlags flags) QObject::connect(ui.enableCheckBox,SIGNAL(toggled(bool)),this,SLOT(updateRelayMode())); QObject::connect(ui.serverCheckBox,SIGNAL(toggled(bool)),this,SLOT(updateRelayMode())); + + // when the network menu is opened and the hidden service tab is already selected updateOutProxyIndicator() won't be called and thus resulting in wrong proxy indicators. + if (ui.tabWidget->currentIndex() == TAB_HIDDEN_SERVICE) + updateOutProxyIndicator(); } void ServerPage::saveAndTestInProxy() @@ -340,8 +337,8 @@ void ServerPage::load() if (mIsHiddenNode) { mHiddenType = detail.hiddenType; - ui.tabWidget->setTabEnabled(TAB_IP_FILTERS,false) ; // ip filter - ui.tabWidget->setTabEnabled(TAB_RELAYS,false) ; // relay + //ui.tabWidget->setTabEnabled(TAB_IP_FILTERS,false) ; // ip filter + //ui.tabWidget->setTabEnabled(TAB_RELAYS,false) ; // relay loadHiddenNode(); return; } diff --git a/retroshare-gui/src/gui/settings/ServerPage.ui b/retroshare-gui/src/gui/settings/ServerPage.ui index f8f55423f..b4315a704 100755 --- a/retroshare-gui/src/gui/settings/ServerPage.ui +++ b/retroshare-gui/src/gui/settings/ServerPage.ui @@ -26,7 +26,7 @@ - 0 + 1 @@ -525,277 +525,6 @@ behind a firewall or a VPN.
IPServersLV ipAddressList - - - IP Filters - - - - - - Activate IP filtering - - - - - - - 0 - - - - IP blacklist - - - - - - Qt::CustomContextMenu - - - <html><head/><body><p>This list gets automatically filled with information gathered at multiple sources: masquerading peers reported by the DHT, IP ranges entered by you, and IP ranges reported by your friends. Default settings should protect you against large scale traffic relaying.</p><p>Automatically guessing masquerading IPs can put your friends IPs in the blacklist. In this case, use the context menu to whitelist them.</p></body></html> - - - true - - - QAbstractItemView::SingleSelection - - - false - - - true - - - - IP range - - - - - Status - - - - - Origin - - - - - Reason - - - - - Comment - - - - - - - - <html><head/><body><p>This is very drastic, be careful. Since masquerading IPs might be actual real IPs, this option might cause disconnection, and will probably force you to add your friends' IPs into the whitelist.</p></body></html> - - - Ban every IP reported by your friends - - - - - - - <html><head/><body><p>Another drastic option. If you use it, be prepared to add your friends' IPs into the whitelist when needed.</p></body></html> - - - Ban every masquerading IP reported by your DHT - - - - - - - - - <html><head/><body><p>If used alone, this option protects you quite well from large scale IP masquerading.</p></body></html> - - - Automatically ban ranges of DHT masquerading IPs starting at - - - - - - - IPs - - - 2 - - - 255 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - IP whitelist - - - - - - Qt::CustomContextMenu - - - <html><head/><body><p>White listed IPs are gathered from the following sources: IPs coming inside a manually exchanged certificate, IP ranges entered by you in this window, or in the security feed items.</p><p>The default behavior for Retroshare is to (1) always allow connection to peers with IP in the whitelist, even if that IP is also blacklisted; (2) optionally require IPs to be in the whitelist. You can change this behavior for each peer in the &quot;Details&quot; window of each Retroshare node. </p></body></html> - - - true - - - QAbstractItemView::SingleSelection - - - false - - - true - - - - IP range - - - - - Status - - - - - Origin - - - - - Reason - - - - - Comment - - - - - - - - - - - - Manual input - - - - - - - - - 0 - 0 - - - - <html><head/><body><p>Enter an IP range. Accepted formats:</p><p>193.190.209.15</p><p>193.190.209.15/24</p><p>193.190.209.15/16</p></body></html> - - - - - - - 16 - - - 32 - - - 8 - - - 24 - - - - - - - - 0 - 0 - - - - <html><head/><body><p>Enter any comment you'd like</p></body></html> - - - - - - - Add to blacklist - - - - - - - Add to whitelist - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - Hidden Service Configuration @@ -810,7 +539,7 @@ behind a firewall or a VPN.
- 0 + 1 @@ -981,6 +710,204 @@ You can connect to Hidden Nodes, even if you are running a standard Node, so why + + + Incoming + + + + + + <html><head/><body><p>Setup your hidden address (and port if needed)</p></body></html> + + + + + + + + + 10 + + + 65535 + + + + + + + + + <html><head/><body><p>This button simulates a SSL connection to your hidden address using the corresponding proxy. If your hidden node is reachable, it should cause a SSL handshake error, which RS will interpret as a valid connection state. This operation might also cause several &quot;security warning&quot; about connections from your local host IP (127.0.0.1) in the News Feed if you enabled it, which you should interpret as a sign of good communication.</p></body></html> + + + Test + + + + + + + + + 10 + + + 65535 + + + + + + + Service Address + + + + + + + Local Address + + + + + + + <html><head/><body><p>This is your hidden address. It should look like <span style=" font-weight:600;">[something].onion</span> or <span style=" font-weight:600;">[something].b32.i2p. </span>If you configured a hidden service with Tor, the onion address is generated automatically by Tor. You can get it in e.g. <span style=" font-weight:600;">/var/lib/tor/[service name]/hostname</span>. For I2P: Setup a server tunnel ( http://127.0.0.1:7657/i2ptunnelmgr ) and copy it's base32 address when it is started (should end with .b32.i2p)</p></body></html> + + + + + + + <html><head/><body><p>This is the local address to which the hidden service points at your localhost. Most of the time, <span style=" font-weight:600;">127.0.0.1</span> is the right answer.</p></body></html> + + + + + + + + + + 16 + 16 + + + + + + + :/images/ledoff1.png + + + + + + + <html><head/><body><p>This led turns green only if you launch an active test using the above button. </p><p>When it does, it means that your hidden node can be reached from anywhere, using the Tor (resp. I2P) </p><p>network. Congratulations!</p></body></html> + + + incoming ok + + + + + + + + + + + + + Expected Configuration: + + + + + + + + 0 + 0 + + + + + 0 + 10 + + + + + 16777215 + 50 + + + + Qt::ScrollBarAlwaysOff + + + true + + + Please fill in a service address + + + + + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + true + + + To Receive Connections, you must first setup a Tor/I2P Hidden Service. + +For Tor: See torrc and documentation for HOWTO details. + +For I2P: See http://127.0.0.1:7657/i2ptunnelmgr for setting up a server tunnel: +Tunnel Wizard -> Server Tunnel -> Standard -> enter a name -> enter the address and port your RS is using (see Local Address above) -> check 'Auto Start' -> finish! + +Once this is done, paste the Onion/I2P (Base32) Address in the box above. +This is your external address on the Tor/I2P network. +Finally make sure that the Ports match the configuration. + +If you have issues connecting over Tor check the Tor logs too. + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + Automatic I2P/BOB @@ -1456,204 +1383,277 @@ You can connect to Hidden Nodes, even if you are running a standard Node, so why - + + + + + + + IP Filters + + + + + + Activate IP filtering + + + + + + + 0 + + - Incoming + IP blacklist - + - - - <html><head/><body><p>Setup your hidden address (and port if needed)</p></body></html> + + + Qt::CustomContextMenu - - - - - - - - 10 - - - 65535 - - - - - - - - - <html><head/><body><p>This button simulates a SSL connection to your hidden address using the corresponding proxy. If your hidden node is reachable, it should cause a SSL handshake error, which RS will interpret as a valid connection state. This operation might also cause several &quot;security warning&quot; about connections from your local host IP (127.0.0.1) in the News Feed if you enabled it, which you should interpret as a sign of good communication.</p></body></html> - - - Test - - - - - - - - - 10 - - - 65535 - - - - - - - Service Address - - - - - - - Local Address - - - - - - - <html><head/><body><p>This is your hidden address. It should look like <span style=" font-weight:600;">[something].onion</span> or <span style=" font-weight:600;">[something].b32.i2p. </span>If you configured a hidden service with Tor, the onion address is generated automatically by Tor. You can get it in e.g. <span style=" font-weight:600;">/var/lib/tor/[service name]/hostname</span>. For I2P: Setup a server tunnel ( http://127.0.0.1:7657/i2ptunnelmgr ) and copy it's base32 address when it is started (should end with .b32.i2p)</p></body></html> - - - - - - - <html><head/><body><p>This is the local address to which the hidden service points at your localhost. Most of the time, <span style=" font-weight:600;">127.0.0.1</span> is the right answer.</p></body></html> - - - - - - - - - - 16 - 16 - - - - - - - :/images/ledoff1.png - - - - - - - <html><head/><body><p>This led turns green only if you launch an active test using the above button. </p><p>When it does, it means that your hidden node can be reached from anywhere, using the Tor (resp. I2P) </p><p>network. Congratulations!</p></body></html> - - - incoming ok - - - - - - - - - - - - - Expected Configuration: - - - - - - - - 0 - 0 - - - - - 0 - 10 - - - - - 16777215 - 50 - - - - Qt::ScrollBarAlwaysOff - - - true - - - Please fill in a service address - - - - - - - - - - 0 - 0 - + + <html><head/><body><p>This list gets automatically filled with information gathered at multiple sources: masquerading peers reported by the DHT, IP ranges entered by you, and IP ranges reported by your friends. Default settings should protect you against large scale traffic relaying.</p><p>Automatically guessing masquerading IPs can put your friends IPs in the blacklist. In this case, use the context menu to whitelist them.</p></body></html> - - - 16777215 - 16777215 - - - + true - - To Receive Connections, you must first setup a Tor/I2P Hidden Service. - -For Tor: See torrc and documentation for HOWTO details. - -For I2P: See http://127.0.0.1:7657/i2ptunnelmgr for setting up a server tunnel: -Tunnel Wizard -> Server Tunnel -> Standard -> enter a name -> enter the address and port your RS is using (see Local Address above) -> check 'Auto Start' -> finish! - -Once this is done, paste the Onion/I2P (Base32) Address in the box above. -This is your external address on the Tor/I2P network. -Finally make sure that the Ports match the configuration. - -If you have issues connecting over Tor check the Tor logs too. + + QAbstractItemView::SingleSelection + + + false + + + true + + + + IP range + + + + + Status + + + + + Origin + + + + + Reason + + + + + Comment + + + + + + + + <html><head/><body><p>This is very drastic, be careful. Since masquerading IPs might be actual real IPs, this option might cause disconnection, and will probably force you to add your friends' IPs into the whitelist.</p></body></html> + + + Ban every IP reported by your friends - - - Qt::Vertical + + + <html><head/><body><p>Another drastic option. If you use it, be prepared to add your friends' IPs into the whitelist when needed.</p></body></html> - - - 20 - 40 - + + Ban every masquerading IP reported by your DHT - + + + + + + + + <html><head/><body><p>If used alone, this option protects you quite well from large scale IP masquerading.</p></body></html> + + + Automatically ban ranges of DHT masquerading IPs starting at + + + + + + + IPs + + + 2 + + + 255 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + IP whitelist + + + + + + Qt::CustomContextMenu + + + <html><head/><body><p>White listed IPs are gathered from the following sources: IPs coming inside a manually exchanged certificate, IP ranges entered by you in this window, or in the security feed items.</p><p>The default behavior for Retroshare is to (1) always allow connection to peers with IP in the whitelist, even if that IP is also blacklisted; (2) optionally require IPs to be in the whitelist. You can change this behavior for each peer in the &quot;Details&quot; window of each Retroshare node. </p></body></html> + + + true + + + QAbstractItemView::SingleSelection + + + false + + + true + + + + IP range + + + + + Status + + + + + Origin + + + + + Reason + + + + + Comment + + + + + + + + + + + + Manual input + + + + + + + + + 0 + 0 + + + + <html><head/><body><p>Enter an IP range. Accepted formats:</p><p>193.190.209.15</p><p>193.190.209.15/24</p><p>193.190.209.15/16</p></body></html> + + + + + + + 16 + + + 32 + + + 8 + + + 24 + + + + + + + + 0 + 0 + + + + <html><head/><body><p>Enter any comment you'd like</p></body></html> + + + + + + + Add to blacklist + + + + + + + Add to whitelist + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + diff --git a/retroshare-gui/src/gui/settings/TransferPage.ui b/retroshare-gui/src/gui/settings/TransferPage.ui index 529a6e260..2f6dd0dae 100644 --- a/retroshare-gui/src/gui/settings/TransferPage.ui +++ b/retroshare-gui/src/gui/settings/TransferPage.ui @@ -447,6 +447,13 @@ + + + + Trust friend nodes with banned files + + + diff --git a/retroshare-gui/src/gui/settings/WebuiPage.cpp b/retroshare-gui/src/gui/settings/WebuiPage.cpp index aea611312..1d2dd6013 100644 --- a/retroshare-gui/src/gui/settings/WebuiPage.cpp +++ b/retroshare-gui/src/gui/settings/WebuiPage.cpp @@ -22,6 +22,9 @@ resource_api::ApiServerMHD* WebuiPage::apiServerMHD = 0; resource_api::ApiServerLocal* WebuiPage::apiServerLocal = 0; #endif resource_api::RsControlModule* WebuiPage::controlModule = 0; +#ifdef RS_JSONAPI +JsonApiServer* WebuiPage::jsonApiServer = nullptr; +#endif WebuiPage::WebuiPage(QWidget */*parent*/, Qt::WindowFlags /*flags*/) { @@ -105,6 +108,11 @@ QString WebuiPage::helpText() const // TODO: LIBRESAPI_LOCAL_SERVER Move in appropriate place #ifdef LIBRESAPI_LOCAL_SERVER apiServerLocal = new resource_api::ApiServerLocal(apiServer, resource_api::ApiServerLocal::serverPath()); +#endif +#ifdef RS_JSONAPI + // Use same port of libresapi + 2 + jsonApiServer = new JsonApiServer(Settings->getWebinterfacePort() + 2); + jsonApiServer->start("WebuiPage::jsonApiServer"); #endif return ok; } @@ -126,6 +134,10 @@ QString WebuiPage::helpText() const delete controlModule; controlModule = 0; } +#ifdef RS_JSONAPI + delete jsonApiServer; + jsonApiServer = nullptr; +#endif } /*static*/ void WebuiPage::showWebui() diff --git a/retroshare-gui/src/gui/settings/WebuiPage.h b/retroshare-gui/src/gui/settings/WebuiPage.h index 66af0327b..78961c98d 100644 --- a/retroshare-gui/src/gui/settings/WebuiPage.h +++ b/retroshare-gui/src/gui/settings/WebuiPage.h @@ -3,6 +3,10 @@ #include #include "ui_WebuiPage.h" +#ifdef RS_JSONAPI +# include "jsonapi/jsonapi.h" +#endif + namespace resource_api{ class ApiServer; class ApiServerMHD; @@ -55,4 +59,7 @@ private: static resource_api::ApiServerLocal* apiServerLocal; #endif static resource_api::RsControlModule* controlModule; +#ifdef RS_JSONAPI + static JsonApiServer* jsonApiServer; +#endif }; diff --git a/retroshare-gui/src/gui/settings/rsettingswin.cpp b/retroshare-gui/src/gui/settings/rsettingswin.cpp index 0a2b348f0..7f2dcf115 100644 --- a/retroshare-gui/src/gui/settings/rsettingswin.cpp +++ b/retroshare-gui/src/gui/settings/rsettingswin.cpp @@ -158,7 +158,7 @@ SettingsPage::initStackedWidget() addPage(new ForumPage()); // FORUMS addPage(new PostedPage()); // POSTED RENAME TO LINKS addPage(new NotifyPage()); // NOTIFY - addPage(new PluginsPage() ); // PLUGINS + addPage(new settings::PluginsPage() ); // PLUGINS addPage(new AppearancePage()); // APPEARENCE addPage(new SoundPage() ); // SOUND addPage(new ServicePermissionsPage() ); // PERMISSIONS diff --git a/retroshare-gui/src/gui/settings/rsharesettings.h b/retroshare-gui/src/gui/settings/rsharesettings.h index 99e33b5f2..0dfd3dc7f 100644 --- a/retroshare-gui/src/gui/settings/rsharesettings.h +++ b/retroshare-gui/src/gui/settings/rsharesettings.h @@ -187,9 +187,7 @@ public: /** Sets whether the bandwidth graph is always on top. */ void setBWGraphAlwaysOnTop(bool alwaysOnTop); -#ifdef RETROTOR void setHiddenServiceKey() ; -#endif uint getNewsFeedFlags(); void setNewsFeedFlags(uint flags); diff --git a/retroshare-gui/src/gui/statistics/BandwidthStatsWidget.cpp b/retroshare-gui/src/gui/statistics/BandwidthStatsWidget.cpp index 8c04ed9d0..9e7a063f5 100644 --- a/retroshare-gui/src/gui/statistics/BandwidthStatsWidget.cpp +++ b/retroshare-gui/src/gui/statistics/BandwidthStatsWidget.cpp @@ -117,7 +117,7 @@ void BandwidthStatsWidget::updateComboBoxes() { if(*it != ui.service_CB->itemData(indx).toInt()) { - QString sname = QString::fromUtf8(service_info_map.mServiceList[ ((*it)<<8) + 0x02000000].mServiceName.c_str()) ; + QString sname = QString::fromUtf8(service_info_map.mServiceList[RsServiceInfo::RsServiceInfoUIn16ToFullServiceId(*it)].mServiceName.c_str()) ; if(ui.service_CB->count() <= indx) ui.service_CB->addItem(sname + " (0x"+QString::number(*it,16)+")",QVariant(*it)) ; diff --git a/retroshare-gui/src/gui/statistics/TurtleRouterDialog.cpp b/retroshare-gui/src/gui/statistics/TurtleRouterDialog.cpp index 7572bdfae..522b5115e 100644 --- a/retroshare-gui/src/gui/statistics/TurtleRouterDialog.cpp +++ b/retroshare-gui/src/gui/statistics/TurtleRouterDialog.cpp @@ -1,11 +1,16 @@ #include +#include #include #include #include +#include +#include +#include #include "TurtleRouterDialog.h" #include #include #include // for sort +#include #include "gui/settings/rsharesettings.h" @@ -240,19 +245,14 @@ QTreeWidgetItem *TurtleRouterDialog::findParentHashItem(const std::string& hash) else return items.front() ; } + //=======================================================================================================================// - -GxsTunnelsDialog::GxsTunnelsDialog(QWidget *parent) +TunnelStatisticsDialog::TunnelStatisticsDialog(QWidget *parent) : RsAutoUpdatePage(2000,parent) { -// setupUi(this) ; - m_bProcessSettings = false; - //float fontHeight = QFontMetricsF(font()).height(); - //float fact = fontHeight/14.0; - maxWidth = 200 ; maxHeight = 200 ; @@ -260,14 +260,13 @@ GxsTunnelsDialog::GxsTunnelsDialog(QWidget *parent) processSettings(true); } -GxsTunnelsDialog::~GxsTunnelsDialog() +TunnelStatisticsDialog::~TunnelStatisticsDialog() { - // save settings processSettings(false); } -void GxsTunnelsDialog::processSettings(bool bLoad) +void TunnelStatisticsDialog::processSettings(bool bLoad) { m_bProcessSettings = true; @@ -284,7 +283,77 @@ void GxsTunnelsDialog::processSettings(bool bLoad) m_bProcessSettings = false; } -void GxsTunnelsDialog::updateDisplay() +QString TunnelStatisticsDialog::getPeerName(const RsPeerId &peer_id) +{ + static std::map names ; + + std::map::const_iterator it = names.find(peer_id) ; + + if( it != names.end()) + return it->second ; + else + { + RsPeerDetails detail ; + if(!rsPeers->getPeerDetails(peer_id,detail)) + return tr("Unknown Peer"); + + return (names[peer_id] = QString::fromUtf8(detail.name.c_str())) ; + } +} + +QString TunnelStatisticsDialog::getPeerName(const RsGxsId& gxs_id) +{ + static std::map names ; + + std::map::const_iterator it = names.find(gxs_id) ; + + if( it != names.end()) + return it->second ; + else + { + RsIdentityDetails detail ; + + if(!rsIdentity->getIdDetails(gxs_id,detail)) + return tr("Unknown Peer"); + + return (names[gxs_id] = QString::fromUtf8(detail.mNickname.c_str())) ; + } +} + + +QString TunnelStatisticsDialog::speedString(float f) +{ + if(f < 1.0f) + return QString("0 B/s") ; + if(f < 1024.0f) + return QString::number((int)f)+" B/s" ; + + return QString::number(f/1024.0,'f',2) + " KB/s"; +} + +void TunnelStatisticsDialog::paintEvent(QPaintEvent */*event*/) +{ + QStylePainter(this).drawPixmap(0, 0, pixmap); +} + +void TunnelStatisticsDialog::resizeEvent(QResizeEvent *event) +{ + QRect TaskGraphRect = geometry(); + + maxWidth = TaskGraphRect.width(); + maxHeight = TaskGraphRect.height() ; + + QWidget::resizeEvent(event); + update(); +} +//=======================================================================================================================// + +GxsAuthenticatedTunnelsDialog::GxsAuthenticatedTunnelsDialog(QWidget *parent) + : TunnelStatisticsDialog(parent) +{ +} + +void GxsAuthenticatedTunnelsDialog::updateDisplay() { // Request info about ongoing tunnels @@ -334,8 +403,8 @@ void GxsTunnelsDialog::updateDisplay() // draw... painter.drawText(ox+4*cellx,oy+celly,tr("Tunnel ID: %1").arg(QString::fromStdString(tunnel_infos[i].tunnel_id.toStdString()))) ; oy += celly ; - painter.drawText(ox+6*cellx,oy+celly,tr("from: %1").arg(QString::fromStdString(tunnel_infos[i].source_gxs_id.toStdString()))) ; oy += celly ; - painter.drawText(ox+6*cellx,oy+celly,tr("to: %1").arg(QString::fromStdString(tunnel_infos[i].destination_gxs_id.toStdString()))) ; oy += celly ; + painter.drawText(ox+6*cellx,oy+celly,tr("from: %1 (%2)").arg(QString::fromStdString(tunnel_infos[i].source_gxs_id.toStdString())).arg(getPeerName(tunnel_infos[i].source_gxs_id))) ; oy += celly ; + painter.drawText(ox+6*cellx,oy+celly,tr("to: %1 (%2)").arg(QString::fromStdString(tunnel_infos[i].destination_gxs_id.toStdString())).arg(getPeerName(tunnel_infos[i].destination_gxs_id))) ; oy += celly ; painter.drawText(ox+6*cellx,oy+celly,tr("status: %1").arg(QString::number(tunnel_infos[i].tunnel_status))) ; oy += celly ; painter.drawText(ox+6*cellx,oy+celly,tr("total sent: %1 bytes").arg(QString::number(tunnel_infos[i].total_size_sent))) ; oy += celly ; painter.drawText(ox+6*cellx,oy+celly,tr("total recv: %1 bytes").arg(QString::number(tunnel_infos[i].total_size_received))) ; oy += celly ; @@ -350,46 +419,197 @@ void GxsTunnelsDialog::updateDisplay() maxHeight = std::max(oy,10*celly); } -QString GxsTunnelsDialog::getPeerName(const RsPeerId &peer_id) +//=======================================================================================================================// + +GxsNetTunnelsDialog::GxsNetTunnelsDialog(QWidget *parent) + : TunnelStatisticsDialog(parent) { - static std::map names ; +} - std::map::const_iterator it = names.find(peer_id) ; +static QString getGroupStatusString(RsGxsNetTunnelGroupInfo::GroupStatus group_status) +{ + switch(group_status) + { + default: + case RsGxsNetTunnelGroupInfo::RS_GXS_NET_TUNNEL_GRP_STATUS_UNKNOWN : return QObject::tr("Unknown") ; + case RsGxsNetTunnelGroupInfo::RS_GXS_NET_TUNNEL_GRP_STATUS_IDLE : return QObject::tr("Idle"); + case RsGxsNetTunnelGroupInfo::RS_GXS_NET_TUNNEL_GRP_STATUS_VPIDS_AVAILABLE : return QObject::tr("Virtual peers available"); + } + return QString(); +} - if( it != names.end()) - return it->second ; - else +static QString getGroupPolicyString(RsGxsNetTunnelGroupInfo::GroupPolicy group_policy) +{ + switch(group_policy) + { + default: + case RsGxsNetTunnelGroupInfo::RS_GXS_NET_TUNNEL_GRP_POLICY_UNKNOWN : return QObject::tr("Unknown") ; + case RsGxsNetTunnelGroupInfo::RS_GXS_NET_TUNNEL_GRP_POLICY_PASSIVE : return QObject::tr("Passive") ; + case RsGxsNetTunnelGroupInfo::RS_GXS_NET_TUNNEL_GRP_POLICY_ACTIVE : return QObject::tr("Active") ; + case RsGxsNetTunnelGroupInfo::RS_GXS_NET_TUNNEL_GRP_POLICY_REQUESTING : return QObject::tr("Requesting peers") ; + } + return QString(); +} + +static QString getLastContactString(time_t last_contact) +{ + time_t now = time(NULL); + + if(last_contact == 0) + return QObject::tr("Never"); + + return QString::number(now - last_contact) + " secs ago" ; +} + +static QString getServiceNameString(uint16_t service_id) +{ + static RsPeerServiceInfo ownServices; + + if(ownServices.mServiceList.find(service_id) == ownServices.mServiceList.end()) + rsServiceControl->getOwnServices(ownServices); + + return QString::fromUtf8(ownServices.mServiceList[RsServiceInfo::RsServiceInfoUIn16ToFullServiceId(service_id)].mServiceName.c_str()) ; +} + +static QString getVirtualPeerStatusString(uint8_t status) +{ + switch(status) { - RsPeerDetails detail ; - if(!rsPeers->getPeerDetails(peer_id,detail)) - return tr("Unknown Peer"); - - return (names[peer_id] = QString::fromUtf8(detail.name.c_str())) ; + default: + case RsGxsNetTunnelVirtualPeerInfo::RS_GXS_NET_TUNNEL_VP_STATUS_UNKNOWN : return QObject::tr("Unknown") ; + case RsGxsNetTunnelVirtualPeerInfo::RS_GXS_NET_TUNNEL_VP_STATUS_TUNNEL_OK : return QObject::tr("Tunnel OK") ; + case RsGxsNetTunnelVirtualPeerInfo::RS_GXS_NET_TUNNEL_VP_STATUS_ACTIVE : return QObject::tr("Tunnel active") ; } + return QString(); } -QString GxsTunnelsDialog::speedString(float f) +static QString getSideString(uint8_t side) { - if(f < 1.0f) - return QString("0 B/s") ; - if(f < 1024.0f) - return QString::number((int)f)+" B/s" ; - - return QString::number(f/1024.0,'f',2) + " KB/s"; + return side?QObject::tr("Client"):QObject::tr("Server") ; } -void GxsTunnelsDialog::paintEvent(QPaintEvent */*event*/) +static QString getMasterKeyString(const uint8_t *key,uint32_t size) { - QStylePainter(this).drawPixmap(0, 0, pixmap); + return QString::fromStdString(RsUtil::BinToHex(key,size,10)); } -void GxsTunnelsDialog::resizeEvent(QResizeEvent *event) +void GxsNetTunnelsDialog::updateDisplay() { - QRect TaskGraphRect = geometry(); - - maxWidth = TaskGraphRect.width(); - maxHeight = TaskGraphRect.height() ; + // Request info about ongoing tunnels - QWidget::resizeEvent(event); - update(); + std::map groups; // groups on the client and server side + std::map turtle2gxsnettunnel; // convertion table from turtle to net tunnel virtual peer id + std::map virtual_peers; // current virtual peers, which group they provide, and how to talk to them through turtle + Bias20Bytes bias; + + rsGxsDistSync->getStatistics(groups,virtual_peers,turtle2gxsnettunnel,bias) ; + + // RsGxsNetTunnelGroupInfo: + // + // enum GroupStatus { + // RS_GXS_NET_TUNNEL_GRP_STATUS_UNKNOWN = 0x00, // unknown status + // RS_GXS_NET_TUNNEL_GRP_STATUS_IDLE = 0x01, // no virtual peers requested, just waiting + // RS_GXS_NET_TUNNEL_GRP_STATUS_VPIDS_AVAILABLE = 0x02 // some virtual peers are available. Data can be read/written + // }; + // enum GroupPolicy { + // RS_GXS_NET_TUNNEL_GRP_POLICY_UNKNOWN = 0x00, // nothing has been set + // RS_GXS_NET_TUNNEL_GRP_POLICY_PASSIVE = 0x01, // group is available for server side tunnels, but does not explicitely request tunnels + // RS_GXS_NET_TUNNEL_GRP_POLICY_ACTIVE = 0x02, // group will only explicitely request tunnels if none available + // RS_GXS_NET_TUNNEL_GRP_POLICY_REQUESTING = 0x03, // group explicitely requests tunnels + // }; + // + // RsGxsNetTunnelGroupInfo() : group_policy(RS_GXS_NET_TUNNEL_GRP_POLICY_PASSIVE),group_status(RS_GXS_NET_TUNNEL_GRP_STATUS_IDLE),last_contact(0) {} + // + // GroupPolicy group_policy ; + // GroupStatus group_status ; + // time_t last_contact ; + // RsFileHash hash ; + // uint16_t service_id ; + // std::set virtual_peers ; + // + // struct RsGxsNetTunnelVirtualPeerInfo: + // + // enum { RS_GXS_NET_TUNNEL_VP_STATUS_UNKNOWN = 0x00, // unknown status. + // RS_GXS_NET_TUNNEL_VP_STATUS_TUNNEL_OK = 0x01, // tunnel has been established and we're waiting for virtual peer id + // RS_GXS_NET_TUNNEL_VP_STATUS_ACTIVE = 0x02 // virtual peer id is known. Data can transfer. + // }; + // + // RsGxsNetTunnelVirtualPeerInfo() : vpid_status(RS_GXS_NET_TUNNEL_VP_STATUS_UNKNOWN), last_contact(0),side(0) { memset(encryption_master_key,0,32) ; } + // virtual ~RsGxsNetTunnelVirtualPeerInfo(){} + // + // uint8_t vpid_status ; // status of the peer + // time_t last_contact ; // last time some data was sent/recvd + // uint8_t side ; // client/server + // uint8_t encryption_master_key[32]; + // + // RsPeerId turtle_virtual_peer_id ; // turtle peer to use when sending data to this vpid. + // + // RsGxsGroupId group_id ; // group that virtual peer is providing + // uint16_t service_id ; // this is used for checkng consistency of the incoming data + + // update the pixmap + // + + // now draw the shit + QPixmap tmppixmap(maxWidth, maxHeight); + tmppixmap.fill(Qt::transparent); + //setFixedHeight(maxHeight); + + QPainter painter(&tmppixmap); + painter.initFrom(this); + + // extracts the height of the fonts in pixels. This is used to calibrate the size of the objects to draw. + + float fontHeight = QFontMetricsF(font()).height(); + float fact = fontHeight/14.0; + + int cellx = 6*fact ; + int celly = (10+4)*fact ; + int ox=5*fact,oy=5*fact ; + + painter.setPen(QColor::fromRgb(0,0,0)) ; + painter.drawText(ox+2*cellx,oy+celly,tr("Random Bias: %1").arg(getMasterKeyString(bias.toByteArray(),20))) ; oy += celly ; + painter.drawText(ox+2*cellx,oy+celly,tr("GXS Groups:")) ; oy += celly ; + + for(auto it(groups.begin());it!=groups.end();++it) + { + painter.drawText(ox+4*cellx,oy+celly,tr("Service: %1 (%2) - Group ID: %3,\t policy: %4, \tstatus: %5, \tlast contact: %6") + .arg("0x" + QString::number(it->second.service_id, 16)) + .arg(getServiceNameString(it->second.service_id)) + .arg(QString::fromStdString(it->first.toStdString())) + .arg(getGroupPolicyString(it->second.group_policy)) + .arg(getGroupStatusString(it->second.group_status)) + .arg(getLastContactString(it->second.last_contact)) + ),oy+=celly ; + + + for(auto it2(it->second.virtual_peers.begin());it2!=it->second.virtual_peers.end();++it2) + { + auto it4 = turtle2gxsnettunnel.find(*it2) ; + + if(it4 != turtle2gxsnettunnel.end()) + { + auto it3 = virtual_peers.find(it4->second) ; + + if(virtual_peers.end() != it3) + painter.drawText(ox+6*cellx,oy+celly,tr("Peer: %1:\tstatus: %2/%3, \tlast contact: %4, \tMaster key: %5.") + .arg(QString::fromStdString((*it2).toStdString())) + .arg(getVirtualPeerStatusString(it3->second.vpid_status)) + .arg(getSideString(it3->second.side)) + .arg(getLastContactString(it3->second.last_contact)) + .arg(getMasterKeyString(it3->second.encryption_master_key,32)) + ),oy+=celly ; + } + else + painter.drawText(ox+6*cellx,oy+celly,tr("Peer: %1: no information available") + .arg(QString::fromStdString((*it2).toStdString())) + ),oy+=celly; + + } + } + + oy += celly ; + + pixmap = tmppixmap; + maxHeight = std::max(oy,10*celly); } diff --git a/retroshare-gui/src/gui/statistics/TurtleRouterDialog.h b/retroshare-gui/src/gui/statistics/TurtleRouterDialog.h index 22bc6dd56..d51e69c68 100644 --- a/retroshare-gui/src/gui/statistics/TurtleRouterDialog.h +++ b/retroshare-gui/src/gui/statistics/TurtleRouterDialog.h @@ -37,29 +37,55 @@ class TurtleRouterDialog: public RsAutoUpdatePage, public Ui::TurtleRouterDialog } ; -class GxsTunnelsDialog: public RsAutoUpdatePage +class TunnelStatisticsDialog: public RsAutoUpdatePage { Q_OBJECT public: - GxsTunnelsDialog(QWidget *parent = NULL) ; - ~GxsTunnelsDialog(); + TunnelStatisticsDialog(QWidget *parent = NULL) ; + ~TunnelStatisticsDialog(); // Cache for peer names. static QString getPeerName(const RsPeerId &peer_id) ; + static QString getPeerName(const RsGxsId& gxs_id); protected: virtual void paintEvent(QPaintEvent *); virtual void resizeEvent(QResizeEvent *event); + + int maxWidth ; + int maxHeight ; + + QPixmap pixmap; + private: void processSettings(bool bLoad); bool m_bProcessSettings; static QString speedString(float f); - virtual void updateDisplay() ; - - int maxWidth ; - int maxHeight ; - - QPixmap pixmap; + virtual void updateDisplay() =0; +} ; + +class GxsAuthenticatedTunnelsDialog: public TunnelStatisticsDialog +{ + Q_OBJECT + +public: + GxsAuthenticatedTunnelsDialog(QWidget *parent = NULL) ; + ~GxsAuthenticatedTunnelsDialog() {} + +private: + virtual void updateDisplay() ; +} ; + +class GxsNetTunnelsDialog: public TunnelStatisticsDialog +{ + Q_OBJECT + +public: + GxsNetTunnelsDialog(QWidget *parent = NULL) ; + ~GxsNetTunnelsDialog() {} + +private: + virtual void updateDisplay() ; } ; diff --git a/retroshare-gui/src/gui/statistics/TurtleRouterStatistics.cpp b/retroshare-gui/src/gui/statistics/TurtleRouterStatistics.cpp index d3e912bbf..ce983f8b5 100644 --- a/retroshare-gui/src/gui/statistics/TurtleRouterStatistics.cpp +++ b/retroshare-gui/src/gui/statistics/TurtleRouterStatistics.cpp @@ -195,11 +195,13 @@ TurtleRouterStatistics::TurtleRouterStatistics(QWidget *parent) _tunnel_statistics_F->setFrameStyle(QFrame::NoFrame); _tunnel_statistics_F->setFocusPolicy(Qt::NoFocus); - routertabWidget->addTab(new TurtleRouterDialog(),QString(tr("Anonymous tunnels"))); - routertabWidget->addTab(new GxsTunnelsDialog(),QString(tr("Authenticated tunnels"))); + routertabWidget->addTab(new TurtleRouterDialog(), QString(tr("File transfer tunnels"))); + routertabWidget->addTab(new GxsAuthenticatedTunnelsDialog(),QString(tr("Authenticated tunnels"))); + routertabWidget->addTab(new GxsNetTunnelsDialog(), QString(tr("GXS sync tunnels") )); + + float fontHeight = QFontMetricsF(font()).height(); + float fact = fontHeight/14.0; - float fontHeight = QFontMetricsF(font()).height(); - float fact = fontHeight/14.0; frmGraph->setMinimumHeight(200*fact); // load settings diff --git a/retroshare-gui/src/gui/statusbar/torstatus.cpp b/retroshare-gui/src/gui/statusbar/torstatus.cpp index 399243ac4..26c9a896a 100644 --- a/retroshare-gui/src/gui/statusbar/torstatus.cpp +++ b/retroshare-gui/src/gui/statusbar/torstatus.cpp @@ -26,12 +26,11 @@ #include #include "retroshare/rsconfig.h" +#include "retroshare/rsinit.h" #include "util/misc.h" -#ifdef RETROTOR #include "TorControl/TorManager.h" #include "TorControl/TorControl.h" -#endif #include @@ -86,53 +85,56 @@ void TorStatus::getTorStatus() int S = QFontMetricsF(torstatusLabel->font()).height(); -#ifdef RETROTOR - // get Tor status - int tor_control_status = Tor::TorManager::instance()->control()->status(); - int torstatus = Tor::TorManager::instance()->control()->torStatus(); - - QString tor_control_status_str,torstatus_str ; - bool tor_control_ok ; - - switch(tor_control_status) + if(RsAccounts::isTorAuto()) { - default: - case Tor::TorControl::Error : tor_control_ok = false ; tor_control_status_str = "Error" ; break ; - case Tor::TorControl::NotConnected: tor_control_ok = false ; tor_control_status_str = "Not connected" ; break ; - case Tor::TorControl::Connecting: tor_control_ok = false ; tor_control_status_str = "Connecting" ; break ; - case Tor::TorControl::Authenticating: tor_control_ok = false ; tor_control_status_str = "Authenticating" ; break ; - case Tor::TorControl::Connected: tor_control_ok = true ; tor_control_status_str = "Connected" ; break ; - } + // get Tor status + int tor_control_status = Tor::TorManager::instance()->control()->status(); + int torstatus = Tor::TorManager::instance()->control()->torStatus(); - switch(torstatus) - { - default: - case Tor::TorControl::TorUnknown: torstatus_str = "Unknown" ; break ; - case Tor::TorControl::TorOffline: torstatus_str = "Tor offline" ; break ; - case Tor::TorControl::TorReady: torstatus_str = "Tor ready" ; break ; - } + QString tor_control_status_str,torstatus_str ; + bool tor_control_ok ; + + switch(tor_control_status) + { + default: + case Tor::TorControl::Error : tor_control_ok = false ; tor_control_status_str = "Error" ; break ; + case Tor::TorControl::NotConnected: tor_control_ok = false ; tor_control_status_str = "Not connected" ; break ; + case Tor::TorControl::Connecting: tor_control_ok = false ; tor_control_status_str = "Connecting" ; break ; + case Tor::TorControl::Authenticating: tor_control_ok = false ; tor_control_status_str = "Authenticating" ; break ; + case Tor::TorControl::Connected: tor_control_ok = true ; tor_control_status_str = "Connected" ; break ; + } + + switch(torstatus) + { + default: + case Tor::TorControl::TorUnknown: torstatus_str = "Unknown" ; break ; + case Tor::TorControl::TorOffline: torstatus_str = "Tor offline" ; break ; + case Tor::TorControl::TorReady: torstatus_str = "Tor ready" ; break ; + } #define MIN_RS_NET_SIZE 10 - if(torstatus == Tor::TorControl::TorOffline || !online || !tor_control_ok) + if(torstatus == Tor::TorControl::TorOffline || !online || !tor_control_ok) + { + // RED - some issue. + torstatusLabel->setPixmap(QPixmap(":/icons/tor-stopping.png").scaledToHeight(1.5*S,Qt::SmoothTransformation)); + torstatusLabel->setToolTip( text + tr("Tor is currently offline")); + } + else if(torstatus == Tor::TorControl::TorReady && online && tor_control_ok) + { + torstatusLabel->setPixmap(QPixmap(":/icons/tor-on.png").scaledToHeight(1.5*S,Qt::SmoothTransformation)); + torstatusLabel->setToolTip( text + tr("Tor is OK")); + } + else // torstatus == Tor::TorControl::TorUnknown + { + // GRAY. + torstatusLabel->setPixmap(QPixmap(":/icons/no-tor.png").scaledToHeight(1.5*S,Qt::SmoothTransformation)); + torstatusLabel->setToolTip( text + tr("No tor configuration")); + } + } + else { - // RED - some issue. - torstatusLabel->setPixmap(QPixmap(":/icons/tor-stopping.png").scaledToHeight(1.5*S,Qt::SmoothTransformation)); + torstatusLabel->setPixmap(QPixmap(":/icons/tor-stopping.png").scaledToHeight(S,Qt::SmoothTransformation)); torstatusLabel->setToolTip( text + tr("Tor is currently offline")); } - else if(torstatus == Tor::TorControl::TorReady && online && tor_control_ok) - { - torstatusLabel->setPixmap(QPixmap(":/icons/tor-on.png").scaledToHeight(1.5*S,Qt::SmoothTransformation)); - torstatusLabel->setToolTip( text + tr("Tor is OK")); - } - else // torstatus == Tor::TorControl::TorUnknown - { - // GRAY. - torstatusLabel->setPixmap(QPixmap(":/icons/no-tor.png").scaledToHeight(1.5*S,Qt::SmoothTransformation)); - torstatusLabel->setToolTip( text + tr("No tor configuration")); - } -#else - torstatusLabel->setPixmap(QPixmap(":/icons/tor-stopping.png").scaledToHeight(S,Qt::SmoothTransformation)); - torstatusLabel->setToolTip( text + tr("Tor is currently offline")); -#endif } diff --git a/retroshare-gui/src/lang/languagesupport.cpp b/retroshare-gui/src/lang/languagesupport.cpp index 27f720050..a2f6b9ed8 100644 --- a/retroshare-gui/src/lang/languagesupport.cpp +++ b/retroshare-gui/src/lang/languagesupport.cpp @@ -31,7 +31,7 @@ static QMap translatorPlugins; -#define EXTERNAL_TRANSLATION_DIR QString::fromUtf8(RsAccounts::DataDirectory().c_str()) +#define EXTERNAL_TRANSLATION_DIR QString::fromUtf8(RsAccounts::systemDataDirectory().c_str()) /** Initializes the list of available languages. */ QMap diff --git a/retroshare-gui/src/main.cpp b/retroshare-gui/src/main.cpp index acd56d9ef..17c8ee507 100644 --- a/retroshare-gui/src/main.cpp +++ b/retroshare-gui/src/main.cpp @@ -51,10 +51,8 @@ # include "gui/settings/WebuiPage.h" #endif -#ifdef RETROTOR -# include "TorControl/TorManager.h" -# include "TorControl/TorControlWindow.h" -#endif +#include "TorControl/TorManager.h" +#include "TorControl/TorControlWindow.h" #include "retroshare/rsidentity.h" #include "retroshare/rspeers.h" @@ -349,51 +347,58 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO); SoundManager::create(); -#ifdef RETROTOR - // Now that we know the Tor service running, and we know the SSL id, we can make sure it provides a viable hidden service + bool is_hidden_node = false; + bool is_auto_tor = false ; + bool is_first_time = false ; - QString tor_hidden_service_dir = QString::fromStdString(RsAccounts::AccountDirectory()) + QString("/hidden_service/") ; + RsAccounts::getCurrentAccountOptions(is_hidden_node,is_auto_tor,is_first_time); - Tor::TorManager *torManager = Tor::TorManager::instance(); - torManager->setDataDirectory(Rshare::dataDirectory() + QString("/tor/")); - torManager->setHiddenServiceDirectory(tor_hidden_service_dir); // re-set it, because now it's changed to the specific location that is run - - RsDirUtil::checkCreateDirectory(std::string(tor_hidden_service_dir.toUtf8())) ; - - torManager->setupHiddenService(); - - if(! torManager->start() || torManager->hasError()) + if(is_auto_tor) { - QMessageBox::critical(NULL,QObject::tr("Cannot start Tor Manager!"),QObject::tr("Tor cannot be started on your system: \n\n")+torManager->errorMessage()) ; - return 1 ; - } + // Now that we know the Tor service running, and we know the SSL id, we can make sure it provides a viable hidden service - { - TorControlDialog tcd(torManager) ; - QString error_msg ; - tcd.show(); + QString tor_hidden_service_dir = QString::fromStdString(RsAccounts::AccountDirectory()) + QString("/hidden_service/") ; - while(tcd.checkForTor(error_msg) != TorControlDialog::TOR_STATUS_OK || tcd.checkForHiddenService() != TorControlDialog::HIDDEN_SERVICE_STATUS_OK) // runs until some status is reached: either tor works, or it fails. + Tor::TorManager *torManager = Tor::TorManager::instance(); + torManager->setTorDataDirectory(Rshare::dataDirectory() + QString("/tor/")); + torManager->setHiddenServiceDirectory(tor_hidden_service_dir); // re-set it, because now it's changed to the specific location that is run + + RsDirUtil::checkCreateDirectory(std::string(tor_hidden_service_dir.toUtf8())) ; + + torManager->setupHiddenService(); + + if(! torManager->start() || torManager->hasError()) { - QCoreApplication::processEvents(); - rstime::rs_usleep(0.2*1000*1000) ; - - if(!error_msg.isNull()) - { - QMessageBox::critical(NULL,QObject::tr("Cannot start Tor"),QObject::tr("Sorry but Tor cannot be started on your system!\n\nThe error reported is:\"")+error_msg+"\"") ; - return 1; - } - } - - tcd.hide(); - - if(tcd.checkForHiddenService() != TorControlDialog::HIDDEN_SERVICE_STATUS_OK) - { - QMessageBox::critical(NULL,QObject::tr("Cannot start a hidden tor service!"),QObject::tr("It was not possible to start a hidden service.")) ; + QMessageBox::critical(NULL,QObject::tr("Cannot start Tor Manager!"),QObject::tr("Tor cannot be started on your system: \n\n")+torManager->errorMessage()) ; return 1 ; } + + { + TorControlDialog tcd(torManager) ; + QString error_msg ; + tcd.show(); + + while(tcd.checkForTor(error_msg) != TorControlDialog::TOR_STATUS_OK || tcd.checkForHiddenService() != TorControlDialog::HIDDEN_SERVICE_STATUS_OK) // runs until some status is reached: either tor works, or it fails. + { + QCoreApplication::processEvents(); + rstime::rs_usleep(0.2*1000*1000) ; + + if(!error_msg.isNull()) + { + QMessageBox::critical(NULL,QObject::tr("Cannot start Tor"),QObject::tr("Sorry but Tor cannot be started on your system!\n\nThe error reported is:\"")+error_msg+"\"") ; + return 1; + } + } + + tcd.hide(); + + if(tcd.checkForHiddenService() != TorControlDialog::HIDDEN_SERVICE_STATUS_OK) + { + QMessageBox::critical(NULL,QObject::tr("Cannot start a hidden tor service!"),QObject::tr("It was not possible to start a hidden service.")) ; + return 1 ; + } + } } -#endif QSplashScreen splashScreen(QPixmap(":/images/logo/logo_splash.png")/* , Qt::WindowStaysOnTopHint*/); @@ -409,33 +414,35 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO); return 1; } -#ifdef RETROTOR - // Tor works with viable hidden service. Let's use it! + if(is_auto_tor) + { + // Tor works with viable hidden service. Let's use it! - QString service_id ; - QString onion_address ; - uint16_t service_port ; - uint16_t service_target_port ; - uint16_t proxy_server_port ; - QHostAddress service_target_address ; - QHostAddress proxy_server_address ; + QString service_id ; + QString onion_address ; + uint16_t service_port ; + uint16_t service_target_port ; + uint16_t proxy_server_port ; + QHostAddress service_target_address ; + QHostAddress proxy_server_address ; - torManager->getHiddenServiceInfo(service_id,onion_address,service_port,service_target_address,service_target_port); - torManager->getProxyServerInfo(proxy_server_address,proxy_server_port) ; + Tor::TorManager *torManager = Tor::TorManager::instance(); + torManager->getHiddenServiceInfo(service_id,onion_address,service_port,service_target_address,service_target_port); + torManager->getProxyServerInfo(proxy_server_address,proxy_server_port) ; - std::cerr << "Got hidden service info: " << std::endl; - std::cerr << " onion address : " << onion_address.toStdString() << std::endl; - std::cerr << " service_id : " << service_id.toStdString() << std::endl; - std::cerr << " service port : " << service_port << std::endl; - std::cerr << " target port : " << service_target_port << std::endl; - std::cerr << " target address : " << service_target_address.toString().toStdString() << std::endl; + std::cerr << "Got hidden service info: " << std::endl; + std::cerr << " onion address : " << onion_address.toStdString() << std::endl; + std::cerr << " service_id : " << service_id.toStdString() << std::endl; + std::cerr << " service port : " << service_port << std::endl; + std::cerr << " target port : " << service_target_port << std::endl; + std::cerr << " target address : " << service_target_address.toString().toStdString() << std::endl; - std::cerr << "Setting proxy server to " << service_target_address.toString().toStdString() << ":" << service_target_port << std::endl; + std::cerr << "Setting proxy server to " << service_target_address.toString().toStdString() << ":" << service_target_port << std::endl; - rsPeers->setLocalAddress(rsPeers->getOwnId(), service_target_address.toString().toStdString(), service_target_port); - rsPeers->setHiddenNode(rsPeers->getOwnId(), onion_address.toStdString(), service_port); - rsPeers->setProxyServer(RS_HIDDEN_TYPE_TOR, proxy_server_address.toString().toStdString(),proxy_server_port) ; -#endif + rsPeers->setLocalAddress(rsPeers->getOwnId(), service_target_address.toString().toStdString(), service_target_port); + rsPeers->setHiddenNode(rsPeers->getOwnId(), onion_address.toStdString(), service_port); + rsPeers->setProxyServer(RS_HIDDEN_TYPE_TOR, proxy_server_address.toString().toStdString(),proxy_server_port) ; + } Rshare::initPlugins(); diff --git a/retroshare-gui/src/retroshare-gui.pro b/retroshare-gui/src/retroshare-gui.pro index 30b2af946..b5b17d159 100644 --- a/retroshare-gui/src/retroshare-gui.pro +++ b/retroshare-gui/src/retroshare-gui.pro @@ -2,7 +2,7 @@ TEMPLATE = app QT += network xml -CONFIG += qt gui uic qrc resources idle +CONFIG += qt gui uic qrc resources idle CONFIG += console TARGET = retroshare DEFINES += TARGET=\\\"$${TARGET}\\\" @@ -19,11 +19,9 @@ libresapihttpserver { !include("../../libretroshare/src/use_libretroshare.pri"):error("Including") -retrotor { - FORMS += TorControl/TorControlWindow.ui - SOURCES += TorControl/TorControlWindow.cpp - HEADERS += TorControl/TorControlWindow.h -} +FORMS += TorControl/TorControlWindow.ui +SOURCES += TorControl/TorControlWindow.cpp +HEADERS += TorControl/TorControlWindow.h #QMAKE_CFLAGS += -fmudflap #LIBS *= /usr/lib/gcc/x86_64-linux-gnu/4.4/libmudflap.a /usr/lib/gcc/x86_64-linux-gnu/4.4/libmudflapth.a @@ -285,7 +283,8 @@ wikipoos { LIBS *= $$OUT_PWD/../../supportlibs/pegmarkdown/lib/libpegmarkdown.a } -retrotor { +# Tor controller + HEADERS += TorControl/AddOnionCommand.h \ TorControl/AuthenticateCommand.h \ TorControl/GetConfCommand.h \ @@ -324,7 +323,6 @@ SOURCES += TorControl/AddOnionCommand.cpp \ TorControl/SecureRNG.cpp \ TorControl/Settings.cpp \ TorControl/StrUtil.cpp -} # Input HEADERS += rshare.h \ @@ -367,6 +365,7 @@ HEADERS += rshare.h \ gui/FileTransfer/DLListDelegate.h \ gui/FileTransfer/ULListDelegate.h \ gui/FileTransfer/TransfersDialog.h \ + gui/FileTransfer/BannedFilesDialog.h \ gui/statistics/TurtleRouterDialog.h \ gui/statistics/TurtleRouterStatistics.h \ gui/statistics/dhtgraph.h \ @@ -478,7 +477,7 @@ HEADERS += rshare.h \ gui/common/RsUrlHandler.h \ gui/common/RsCollectionDialog.h \ gui/common/rwindow.h \ - gui/common/html.h \ + gui/common/rshtml.h \ gui/common/AvatarDefs.h \ gui/common/GroupFlagsWidget.h \ gui/common/GroupSelectionBox.h \ @@ -546,7 +545,7 @@ HEADERS += rshare.h \ gui/elastic/graphwidget.h \ gui/elastic/edge.h \ gui/elastic/arrow.h \ - gui/elastic/node.h \ + gui/elastic/elnode.h \ gui/NewsFeed.h \ gui/feeds/FeedItem.h \ gui/feeds/FeedHolder.h \ @@ -599,6 +598,7 @@ FORMS += gui/StartDialog.ui \ gui/FileTransfer/DetailsDialog.ui \ gui/FileTransfer/SearchDialog.ui \ gui/FileTransfer/SharedFilesDialog.ui \ + gui/FileTransfer/BannedFilesDialog.ui \ gui/MainWindow.ui \ gui/NetworkView.ui \ gui/MessengerWindow.ui \ @@ -745,6 +745,7 @@ SOURCES += main.cpp \ gui/FileTransfer/xprogressbar.cpp \ gui/FileTransfer/DetailsDialog.cpp \ gui/FileTransfer/TransferUserNotify.cpp \ + gui/FileTransfer/BannedFilesDialog.cpp \ gui/MainPage.cpp \ gui/HelpDialog.cpp \ gui/LogoBar.cpp \ @@ -796,7 +797,7 @@ SOURCES += main.cpp \ gui/common/RsCollectionDialog.cpp \ gui/common/RsUrlHandler.cpp \ gui/common/rwindow.cpp \ - gui/common/html.cpp \ + gui/common/rshtml.cpp \ gui/common/AvatarDefs.cpp \ gui/common/AvatarDialog.cpp \ gui/common/GroupFlagsWidget.cpp \ @@ -897,7 +898,7 @@ SOURCES += main.cpp \ gui/elastic/graphwidget.cpp \ gui/elastic/edge.cpp \ gui/elastic/arrow.cpp \ - gui/elastic/node.cpp \ + gui/elastic/elnode.cpp \ gui/NewsFeed.cpp \ gui/feeds/FeedItem.cpp \ gui/feeds/FeedHolder.cpp \ @@ -1369,3 +1370,44 @@ gxsgui { } + +cmark { + DEFINES *= USE_CMARK + + HEADERS += \ + ../../supportlibs/cmark/src/buffer.h \ + ../../supportlibs/cmark/src/chunk.h \ + ../../supportlibs/cmark/src/cmark.h \ + ../../supportlibs/cmark/src/cmark_ctype.h \ + ../../supportlibs/cmark/src/houdini.h \ + ../../supportlibs/cmark/src/inlines.h \ + ../../supportlibs/cmark/src/iterator.h \ + ../../supportlibs/cmark/src/node.h \ + ../../supportlibs/cmark/src/parser.h \ + ../../supportlibs/cmark/src/references.h \ + ../../supportlibs/cmark/src/render.h \ + ../../supportlibs/cmark/src/scanners.h \ + ../../supportlibs/cmark/src/utf8.h \ + + SOURCES += \ + ../../supportlibs/cmark/src/blocks.c \ + ../../supportlibs/cmark/src/buffer.c \ + ../../supportlibs/cmark/src/cmark.c \ + ../../supportlibs/cmark/src/cmark_ctype.c \ + ../../supportlibs/cmark/src/commonmark.c \ + ../../supportlibs/cmark/src/houdini_href_e.c \ + ../../supportlibs/cmark/src/houdini_html_e.c \ + ../../supportlibs/cmark/src/houdini_html_u.c \ + ../../supportlibs/cmark/src/html.c \ + ../../supportlibs/cmark/src/inlines.c \ + ../../supportlibs/cmark/src/iterator.c \ + ../../supportlibs/cmark/src/latex.c \ + ../../supportlibs/cmark/src/man.c \ + ../../supportlibs/cmark/src/node.c \ + ../../supportlibs/cmark/src/references.c \ + ../../supportlibs/cmark/src/render.c \ + ../../supportlibs/cmark/src/scanners.c \ + ../../supportlibs/cmark/src/utf8.c \ + ../../supportlibs/cmark/src/xml.c \ + +} diff --git a/retroshare-gui/src/rshare.cpp b/retroshare-gui/src/rshare.cpp index ff6038de0..f1b08396a 100644 --- a/retroshare-gui/src/rshare.cpp +++ b/retroshare-gui/src/rshare.cpp @@ -41,7 +41,7 @@ #include #include -#include +#include #include #include #include @@ -360,7 +360,7 @@ QString Rshare::retroshareVersion(bool withRevision) { QString version = QString("%1.%2.%3%4").arg(RS_MAJOR_VERSION).arg(RS_MINOR_VERSION).arg(RS_BUILD_NUMBER).arg(RS_BUILD_NUMBER_ADD); if (withRevision) { - version += QString(" %1 %2").arg(tr("Revision")).arg(QString::number(RS_REVISION_NUMBER,16)); + version += QString(" %1 %2").arg(tr("Revision")).arg(RS_REVISION_NUMBER,8,16,QChar('0')); } return version; @@ -748,7 +748,7 @@ void Rshare::loadStyleSheet(const QString &sheetName) /* external stylesheet */ file.setFileName(QString("%1/qss/%2%3.qss").arg(QString::fromUtf8(RsAccounts::ConfigDirectory().c_str()), name, sheetName)); if (!file.exists()) { - file.setFileName(QString("%1/qss/%2%3.qss").arg(QString::fromUtf8(RsAccounts::DataDirectory().c_str()), name, sheetName)); + file.setFileName(QString("%1/qss/%2%3.qss").arg(QString::fromUtf8(RsAccounts::systemDataDirectory().c_str()), name, sheetName)); } } if (file.open(QFile::ReadOnly)) { @@ -787,7 +787,7 @@ void Rshare::getAvailableStyleSheets(QMap &styleSheets) styleSheets.insert(name, name); } } - fileInfoList = QDir(QString::fromUtf8(RsAccounts::DataDirectory().c_str()) + "/qss/").entryInfoList(QStringList("*.qss")); + fileInfoList = QDir(QString::fromUtf8(RsAccounts::systemDataDirectory().c_str()) + "/qss/").entryInfoList(QStringList("*.qss")); foreach (fileInfo, fileInfoList) { if (fileInfo.isFile()) { QString name = fileInfo.baseName(); diff --git a/retroshare-gui/src/util/HandleRichText.cpp b/retroshare-gui/src/util/HandleRichText.cpp index 2b3e75b35..fad9ea8f9 100644 --- a/retroshare-gui/src/util/HandleRichText.cpp +++ b/retroshare-gui/src/util/HandleRichText.cpp @@ -38,6 +38,13 @@ #include "util/imageutil.h" #include "util/rstime.h" +#ifdef USE_CMARK +//Include for CMark +// This needs to be fixed: use system library if available, etc. +#include +#include +#endif + #include /** @@ -582,6 +589,31 @@ QString RsHtml::formatText(QTextDocument *textDocument, const QString &text, ulo // Save Space and Tab because doc loose it. formattedText=saveSpace(formattedText); +#ifdef USE_CMARK + if (flag & RSHTML_FORMATTEXT_USE_CMARK) { + // Transform html to plain text + QTextBrowser textBrowser; + textBrowser.setHtml(text); + formattedText = textBrowser.toPlainText(); + // Parse CommonMark + int options = CMARK_OPT_DEFAULT; + cmark_parser *parser = cmark_parser_new(options); + cmark_parser_feed(parser, formattedText.toStdString().c_str(),formattedText.length()); + cmark_node *document = cmark_parser_finish(parser); + cmark_parser_free(parser); + char *result; + result = cmark_render_html(document, options); + // Get result as html + formattedText = QString::fromUtf8(result); + //Clean + cmark_node_mem(document)->free(result); + cmark_node_free(document); + //Get document formed HTML + textBrowser.setHtml(formattedText); + formattedText=textBrowser.toHtml(); + } +#endif + QString errorMsg; int errorLine; int errorColumn; QDomDocument doc; @@ -981,6 +1013,12 @@ static void styleCreate(QDomDocument& doc noEmbedAttr.setValue("true"); styleElem.attributes().setNamedItem(noEmbedAttr); } + if (flag & RSHTML_FORMATTEXT_USE_CMARK) { + QDomAttr cMarkAttr; + cMarkAttr = doc.createAttribute("CMark"); + cMarkAttr.setValue("true"); + styleElem.attributes().setNamedItem(cMarkAttr); + } } while(styleElem.childNodes().count()>0) { diff --git a/retroshare-gui/src/util/HandleRichText.h b/retroshare-gui/src/util/HandleRichText.h index a8f8d66ef..afa91f091 100644 --- a/retroshare-gui/src/util/HandleRichText.h +++ b/retroshare-gui/src/util/HandleRichText.h @@ -44,6 +44,7 @@ #define RSHTML_FORMATTEXT_REMOVE_FONT (RSHTML_FORMATTEXT_REMOVE_FONT_WEIGHT | RSHTML_FORMATTEXT_REMOVE_FONT_STYLE | RSHTML_FORMATTEXT_REMOVE_FONT_FAMILY | RSHTML_FORMATTEXT_REMOVE_FONT_SIZE) #define RSHTML_FORMATTEXT_CLEANSTYLE (RSHTML_FORMATTEXT_REMOVE_FONT | RSHTML_FORMATTEXT_REMOVE_COLOR) #define RSHTML_FORMATTEXT_NO_EMBED 0x0400//1024 +#define RSHTML_FORMATTEXT_USE_CMARK 0x0800//2048 /* Flags for RsHtml::optimizeHtml */ #define RSHTML_OPTIMIZEHTML_MASK (RSHTML_FORMATTEXT_CLEANSTYLE | RSHTML_FORMATTEXT_FIX_COLORS | RSHTML_FORMATTEXT_OPTIMIZE) diff --git a/retroshare-gui/src/util/RsGxsUpdateBroadcast.cpp b/retroshare-gui/src/util/RsGxsUpdateBroadcast.cpp index 0fdf63d65..6b6295e2e 100644 --- a/retroshare-gui/src/util/RsGxsUpdateBroadcast.cpp +++ b/retroshare-gui/src/util/RsGxsUpdateBroadcast.cpp @@ -79,5 +79,8 @@ void RsGxsUpdateBroadcast::onChangesReceived(const RsGxsChanges& changes) emit grpsChanged(changes.mGrps, changes.mGrpsMeta); } + if(!changes.mDistantSearchReqs.empty()) + emit distantSearchResultsChanged(changes.mDistantSearchReqs) ; + emit changed(); } diff --git a/retroshare-gui/src/util/RsGxsUpdateBroadcast.h b/retroshare-gui/src/util/RsGxsUpdateBroadcast.h index 1622ca606..e08a866c7 100644 --- a/retroshare-gui/src/util/RsGxsUpdateBroadcast.h +++ b/retroshare-gui/src/util/RsGxsUpdateBroadcast.h @@ -8,6 +8,8 @@ class RsGxsIfaceHelper; class RsGxsChanges; +typedef uint32_t TurtleRequestId ; + class RsGxsUpdateBroadcast : public QObject { Q_OBJECT @@ -21,6 +23,7 @@ signals: void changed(); void msgsChanged(const std::map >& msgIds, const std::map >& msgIdsMeta); void grpsChanged(const std::list& grpIds, const std::list& grpIdsMeta); + void distantSearchResultsChanged(const std::list& reqs); private slots: void onChangesReceived(const RsGxsChanges& changes); diff --git a/retroshare-gui/src/util/TokenQueue.cpp b/retroshare-gui/src/util/TokenQueue.cpp index 3fa5e7ced..2fc453aa7 100644 --- a/retroshare-gui/src/util/TokenQueue.cpp +++ b/retroshare-gui/src/util/TokenQueue.cpp @@ -164,8 +164,8 @@ bool TokenQueue::checkForRequest(uint32_t token) { /* check token */ uint32_t status = mService->requestStatus(token); - return ( (RsTokenService::GXS_REQUEST_V2_STATUS_FAILED == status) || - (RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE == status) ); + return ( (RsTokenService::FAILED == status) || + (RsTokenService::COMPLETE == status) ); } bool TokenQueue::activeRequestExist(const uint32_t& userType) const diff --git a/retroshare-nogui/src/notifytxt.cc b/retroshare-nogui/src/notifytxt.cc index 18212b17e..d6d4741c4 100644 --- a/retroshare-nogui/src/notifytxt.cc +++ b/retroshare-nogui/src/notifytxt.cc @@ -219,7 +219,7 @@ void NotifyTxt::displayTransfers() /******************* Turtle Search Interface **********/ -void NotifyTxt::notifyTurtleSearchResult(uint32_t search_id,const std::list& found_files) +void NotifyTxt::notifyTurtleSearchResult(const RsPeerId &pid, uint32_t search_id, const std::list& found_files) { // std::cerr << "NotifyTxt::notifyTurtleSearchResult() " << found_files.size(); // std::cerr << " new results for Id: " << search_id; diff --git a/retroshare-nogui/src/notifytxt.h b/retroshare-nogui/src/notifytxt.h index 508bfd7fd..17dcbc409 100644 --- a/retroshare-nogui/src/notifytxt.h +++ b/retroshare-nogui/src/notifytxt.h @@ -44,7 +44,7 @@ class NotifyTxt: public NotifyClient virtual bool askForPassword(const std::string& title, const std::string& question, bool prev_is_bad, std::string& password,bool& cancel); virtual bool askForPluginConfirmation(const std::string& plugin_file, const std::string& plugin_hash,bool first_time); - virtual void notifyTurtleSearchResult(uint32_t search_id,const std::list& found_files); + virtual void notifyTurtleSearchResult(const RsPeerId& pid,uint32_t search_id,const std::list& found_files); /* interface for handling SearchResults */ void getSearchIds(std::list &searchIds); diff --git a/retroshare-nogui/src/retroshare.cc b/retroshare-nogui/src/retroshare.cc index 65d8c6168..527c480df 100644 --- a/retroshare-nogui/src/retroshare.cc +++ b/retroshare-nogui/src/retroshare.cc @@ -48,6 +48,11 @@ #include "TerminalApiClient.h" #endif +#ifdef RS_JSONAPI +# include +# include "jsonapi/jsonapi.h" +#endif // RS_JSONAPI + /* Basic instructions for running libretroshare as background thread. * ******************************************************************* * * This allows your program to communicate with authenticated peers. @@ -60,6 +65,32 @@ int main(int argc, char **argv) { +#ifdef RS_JSONAPI + JsonApiServer* jsonApiServer = nullptr; + uint16_t jsonApiPort = 0; + + { + argstream jsonApiArgs(argc, argv); + jsonApiArgs >> parameter( + "jsonApiPort", jsonApiPort, "jsonApiPort", + "Enable JSON API on the specified port", false ); + jsonApiArgs >> help('h', "help", "Display this Help"); + + if (jsonApiArgs.helpRequested()) + std::cerr << jsonApiArgs.usage() << std::endl; + } + + if(jsonApiPort) + { + jsonApiServer = new JsonApiServer( jsonApiPort, [](int /*ec*/) + { + std::raise(SIGTERM); + } ); + + jsonApiServer->start("JSON API Server"); + } +#endif // RS_JSONAPI + #ifdef ENABLE_WEBUI std::string docroot = resource_api::getDefaultDocroot(); diff --git a/retroshare.pri b/retroshare.pri index 111530a39..f622bed80 100644 --- a/retroshare.pri +++ b/retroshare.pri @@ -1,3 +1,21 @@ +################################################################################ +# retroshare.pri # +# Copyright (C) 2018, Retroshare team # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU Lesser 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 Lesser General Public License for more details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with this program. If not, see . # +################################################################################ + ################################################################################ ## Documented build options (CONFIG) goes here as all the rest depend on them ## ## CONFIG must not be edited in other .pro files, aka if CONFIG need do be ##### @@ -10,11 +28,21 @@ CONFIG *= retroshare_gui no_retroshare_gui:CONFIG -= retroshare_gui +CONFIG *= gxsdistsync + +# disabled by the time we fix compilation +CONFIG *= no_cmark + # To disable RetroShare-nogui append the following # assignation to qmake command line "CONFIG+=no_retroshare_nogui" CONFIG *= retroshare_nogui no_retroshare_nogui:CONFIG -= retroshare_nogui +# To disable cmark append the following +# assignation to qmake command line "CONFIG+=no_cmark" +CONFIG *= cmark +no_cmark:CONFIG -= cmark + # To enable RetroShare plugins append the following # assignation to qmake command line "CONFIG+=retroshare_plugins" CONFIG *= no_retroshare_plugins @@ -63,15 +91,6 @@ no_sqlcipher:CONFIG -= sqlcipher CONFIG *= no_rs_autologin rs_autologin:CONFIG -= no_rs_autologin -# To build RetroShare Tor only version with automatic hidden node setup append -# the following assignation to qmake command line "CONFIG+=retrotor" -CONFIG *= no_retrotor -retrotor { - CONFIG -= no_retrotor - CONFIG *= rs_onlyhiddennode - DEFINES *= RETROTOR -} - # To have only hidden node generation append the following assignation # to qmake command line "CONFIG+=rs_onlyhiddennode" CONFIG *= no_rs_onlyhiddennode @@ -115,6 +134,16 @@ rs_macos10.9:CONFIG -= rs_macos10.11 rs_macos10.10:CONFIG -= rs_macos10.11 rs_macos10.12:CONFIG -= rs_macos10.11 +# To enable JSON API append the following assignation to qmake command line +# "CONFIG+=rs_jsonapi" +CONFIG *= no_rs_jsonapi +rs_jsonapi:CONFIG -= no_rs_jsonapi + +# To disable deep search append the following assignation to qmake command line +CONFIG+=no_rs_deep_search +CONFIG *= rs_deep_search +no_rs_deep_search:CONFIG -= rs_deep_search + ########################################################################################################################################################### # # V07_NON_BACKWARD_COMPATIBLE_CHANGE_001: @@ -157,7 +186,7 @@ rs_v07_changes { } ################################################################################ -## RetroShare qmake functions goes here as all the rest may use them ########### +## RetroShare qmake functions goes here as all the rest may use them. ########## ################################################################################ ## Qt versions older the 5 are not supported anymore, check if the user is @@ -254,6 +283,7 @@ defineReplace(linkDynamicLibs) { ## RS_THREAD_LIB String viariable containing the name of the multi threading ## library to use (pthread, "") it usually depend on platform. +gxsdistsync:DEFINES *= RS_USE_GXS_DISTANT_SYNC wikipoos:DEFINES *= RS_USE_WIKI rs_gxs:DEFINES *= RS_ENABLE_GXS libresapilocalserver:DEFINES *= LIBRESAPI_LOCAL_SERVER @@ -273,7 +303,12 @@ no_sqlcipher { rs_autologin { DEFINES *= RS_AUTOLOGIN - warning("You have enabled RetroShare auto-login, this is discouraged. The usage of auto-login on some linux distributions may allow someone having access to your session to steal the SSL keys of your node location and therefore compromise your security") + RS_AUTOLOGIN_WARNING_MSG = \ + You have enabled RetroShare auto-login, this is discouraged. The usage \ + of auto-login on some linux distributions may allow someone having \ + access to your session to steal the SSL keys of your node location and \ + therefore compromise your security + warning("$${RS_AUTOLOGIN_WARNING_MSG}") } rs_onlyhiddennode { @@ -313,6 +348,20 @@ rs_chatserver { DEFINES *= RS_CHATSERVER } +rs_jsonapi { + DEFINES *= RS_JSONAPI +} + +rs_deep_search { + DEFINES *= RS_DEEP_SEARCH + + linux { + exists("/usr/include/xapian-1.3") { + INCLUDEPATH += /usr/include/xapian-1.3 + } + } +} + debug { QMAKE_CXXFLAGS -= -O2 -fomit-frame-pointer QMAKE_CFLAGS -= -O2 -fomit-frame-pointer @@ -476,6 +525,7 @@ macx-* { RS_UPNP_LIB = miniupnpc } + ## Retrocompatibility assignations, get rid of this ASAP isEmpty(BIN_DIR) : BIN_DIR = $${RS_BIN_DIR} isEmpty(INC_DIR) : INC_DIR = $${RS_INCLUDE_DIR} diff --git a/supportlibs/cmark b/supportlibs/cmark new file mode 160000 index 000000000..b9c7a496b --- /dev/null +++ b/supportlibs/cmark @@ -0,0 +1 @@ +Subproject commit b9c7a496ba7dd9c3495bae2ff2855899e47b245d diff --git a/supportlibs/restbed b/supportlibs/restbed new file mode 160000 index 000000000..c27c6726d --- /dev/null +++ b/supportlibs/restbed @@ -0,0 +1 @@ +Subproject commit c27c6726d28c42e2e1b7537ba63eeb23e944789d diff --git a/tests/unittests/libretroshare/gxs/gen_exchange/genexchangetester.cc b/tests/unittests/libretroshare/gxs/gen_exchange/genexchangetester.cc index 6fb4cae2a..9d000d443 100644 --- a/tests/unittests/libretroshare/gxs/gen_exchange/genexchangetester.cc +++ b/tests/unittests/libretroshare/gxs/gen_exchange/genexchangetester.cc @@ -42,7 +42,7 @@ void GenExchangeTest::pollForToken(uint32_t token, const RsTokReqOptions &opts, Sleep((int) (timeDelta * 1000)); #endif - if((RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE == mTokenService->requestStatus(token))) + if((RsTokenService::COMPLETE == mTokenService->requestStatus(token))) { switch(opts.mReqType) { @@ -81,7 +81,7 @@ void GenExchangeTest::pollForToken(uint32_t token, const RsTokReqOptions &opts, } break; } - else if(RsTokenService::GXS_REQUEST_V2_STATUS_FAILED == mTokenService->requestStatus(token)) + else if(RsTokenService::FAILED == mTokenService->requestStatus(token)) { mTokenService->cancelRequest(token); break; @@ -108,12 +108,12 @@ bool GenExchangeTest::pollForMsgAcknowledgement(uint32_t token, Sleep((int) (timeDelta * 1000)); #endif - if((RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE == mTokenService->requestStatus(token))) + if((RsTokenService::COMPLETE == mTokenService->requestStatus(token))) { mTestService->acknowledgeTokenMsg(token, msgId); return true; } - else if(RsTokenService::GXS_REQUEST_V2_STATUS_FAILED == mTokenService->requestStatus(token)) + else if(RsTokenService::FAILED == mTokenService->requestStatus(token)) { mTokenService->cancelRequest(token); return false; @@ -146,12 +146,12 @@ bool GenExchangeTest::pollForGrpAcknowledgement(uint32_t token, Sleep((int) (timeDelta * 1000)); #endif - if((RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE == mTokenService->requestStatus(token))) + if((RsTokenService::COMPLETE == mTokenService->requestStatus(token))) { mTestService->acknowledgeTokenGrp(token, grpId); return true; } - else if(RsTokenService::GXS_REQUEST_V2_STATUS_FAILED == mTokenService->requestStatus(token)) + else if(RsTokenService::FAILED == mTokenService->requestStatus(token)) { mTokenService->cancelRequest(token); return false; diff --git a/tests/unittests/libretroshare/services/gxs/GxsPeerNode.cc b/tests/unittests/libretroshare/services/gxs/GxsPeerNode.cc index 5e8439af8..3be7cd392 100644 --- a/tests/unittests/libretroshare/services/gxs/GxsPeerNode.cc +++ b/tests/unittests/libretroshare/services/gxs/GxsPeerNode.cc @@ -242,7 +242,7 @@ bool GxsPeerNode::createIdentity(const std::string &name, return false; } - while(tokenService->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) + while(tokenService->requestStatus(token) != RsTokenService::COMPLETE) { tick(); sleep(1); @@ -316,7 +316,7 @@ bool GxsPeerNode::createCircle(const std::string &name, uint32_t token; mGxsCircles->createGroup(token, grp1) ; - while(tokenService->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) + while(tokenService->requestStatus(token) != RsTokenService::COMPLETE) { tick(); sleep(1); @@ -371,7 +371,7 @@ bool GxsPeerNode::createGroup(const std::string &name, return false; } - while(tokenService->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) + while(tokenService->requestStatus(token) != RsTokenService::COMPLETE) { tick(); sleep(1); @@ -402,7 +402,7 @@ bool GxsPeerNode::createMsg(const std::string &msgstr, return false; } - while(tokenService->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) + while(tokenService->requestStatus(token) != RsTokenService::COMPLETE) { tick(); sleep(1); @@ -430,7 +430,7 @@ bool GxsPeerNode::subscribeToGroup(const RsGxsGroupId &groupId, bool subscribe) return false; } - while(tokenService->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) + while(tokenService->requestStatus(token) != RsTokenService::COMPLETE) { tick(); sleep(1); @@ -453,7 +453,7 @@ bool GxsPeerNode::getGroups(std::vector &groups) uint32_t token; tokenService->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts); - while(tokenService->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) + while(tokenService->requestStatus(token) != RsTokenService::COMPLETE) { tick(); sleep(1); @@ -475,7 +475,7 @@ bool GxsPeerNode::getGroupList(std::list &groups) uint32_t token; tokenService->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_LIST, opts); - while(tokenService->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) + while(tokenService->requestStatus(token) != RsTokenService::COMPLETE) { tick(); sleep(1); @@ -500,7 +500,7 @@ bool GxsPeerNode::getMsgList(const RsGxsGroupId &id, std::list & grpIds.push_back(id); tokenService->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_LIST, opts, grpIds); - while(tokenService->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) + while(tokenService->requestStatus(token) != RsTokenService::COMPLETE) { tick(); sleep(1); @@ -533,7 +533,7 @@ bool GxsPeerNode::getIdentities(std::vector &groups) uint32_t token; tokenService->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts); - while(tokenService->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) + while(tokenService->requestStatus(token) != RsTokenService::COMPLETE) { tick(); sleep(1); @@ -553,7 +553,7 @@ bool GxsPeerNode::getIdentitiesList(std::list &groups) uint32_t token; tokenService->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_LIST, opts); - while(tokenService->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) + while(tokenService->requestStatus(token) != RsTokenService::COMPLETE) { tick(); sleep(1); @@ -575,7 +575,7 @@ bool GxsPeerNode::getCircles(std::vector &groups) uint32_t token; tokenService->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts); - while(tokenService->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) + while(tokenService->requestStatus(token) != RsTokenService::COMPLETE) { tick(); sleep(1); @@ -595,7 +595,7 @@ bool GxsPeerNode::getCirclesList(std::list &groups) uint32_t token; tokenService->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_LIST, opts); - while(tokenService->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) + while(tokenService->requestStatus(token) != RsTokenService::COMPLETE) { tick(); sleep(1); diff --git a/tests/unittests/libretroshare/services/gxs/nxsbasic_test.cc b/tests/unittests/libretroshare/services/gxs/nxsbasic_test.cc index 078eba249..9c4069c80 100644 --- a/tests/unittests/libretroshare/services/gxs/nxsbasic_test.cc +++ b/tests/unittests/libretroshare/services/gxs/nxsbasic_test.cc @@ -118,14 +118,14 @@ TEST(libretroshare_services, DISABLED_GXS_nxs_basic2) uint32_t token2; ASSERT_TRUE(testService->submitTestGroup(token1, grp1)); - while(tokenService->requestStatus(token1) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) + while(tokenService->requestStatus(token1) != RsTokenService::COMPLETE) { tester.tick(); sleep(1); } ASSERT_TRUE(testService->submitTestGroup(token2, grp2)); - while(tokenService->requestStatus(token2) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) + while(tokenService->requestStatus(token2) != RsTokenService::COMPLETE) { tester.tick(); sleep(1);