diff --git a/README-Android.asciidoc b/README-Android.asciidoc index 40efe9c12..f64336c1c 100644 --- a/README-Android.asciidoc +++ b/README-Android.asciidoc @@ -252,3 +252,4 @@ your work-station running - link:https://source.android.com/devices/tech/debug/gdb[] - link:https://fw4spl-org.github.io/fw4spl-blog/2015/07/27/Native-debugging-on-Android-with-QtCreator.html[] - link:https://fragglet.livejournal.com/19646.html[] +- link:https://github.com/android-ndk/ndk/issues/773[How to build without using standalone toolchain?] diff --git a/RetroShare.pro b/RetroShare.pro index 4197db2e0..69f9710e0 100644 --- a/RetroShare.pro +++ b/RetroShare.pro @@ -23,7 +23,7 @@ TEMPLATE = subdirs SUBDIRS += openpgpsdk openpgpsdk.file = openpgpsdk/src/openpgpsdk.pro -rs_jsonapi { +rs_jsonapi:isEmpty(JSONAPI_GENERATOR_EXE) { SUBDIRS += jsonapi-generator jsonapi-generator.file = jsonapi-generator/src/jsonapi-generator.pro libretroshare.depends += jsonapi-generator @@ -36,22 +36,34 @@ libretroshare.depends = openpgpsdk libbitdht SUBDIRS += libretroshare libretroshare.file = libretroshare/src/libretroshare.pro -SUBDIRS += libresapi -libresapi.file = libresapi/src/libresapi.pro -libresapi.depends = libretroshare +libresapi { + SUBDIRS += libresapi + libresapi.file = libresapi/src/libresapi.pro + libresapi.depends = libretroshare +} retroshare_gui { SUBDIRS += retroshare_gui retroshare_gui.file = retroshare-gui/src/retroshare-gui.pro - retroshare_gui.depends = libretroshare libresapi retroshare_gui.target = retroshare_gui + + libresapi { + retroshare_gui.depends = libresapi + } else { + retroshare_gui.depends = libretroshare + } } retroshare_nogui { SUBDIRS += retroshare_nogui retroshare_nogui.file = retroshare-nogui/src/retroshare-nogui.pro - retroshare_nogui.depends = libretroshare libresapi retroshare_nogui.target = retroshare_nogui + + libresapi { + retroshare_nogui.depends = libresapi + } else { + retroshare_nogui.depends = libretroshare + } } retroshare_android_service { @@ -79,6 +91,13 @@ retroshare_qml_app { } } +retroshare_service { + SUBDIRS += retroshare_service + retroshare_service.file = retroshare-service/src/retroshare-service.pro + retroshare_service.depends = libretroshare + retroshare_service.target = retroshare_service +} + retroshare_plugins { SUBDIRS += plugins plugins.file = plugins/plugins.pro diff --git a/build_scripts/Android/prepare-toolchain-clang.sh b/build_scripts/Android/prepare-toolchain-clang.sh new file mode 100755 index 000000000..81f7a398d --- /dev/null +++ b/build_scripts/Android/prepare-toolchain-clang.sh @@ -0,0 +1,378 @@ +#!/bin/bash + +## Define default value for variable, take two arguments, $1 variable name, +## $2 default variable value, if the variable is not already define define it +## with default value. +function define_default_value() +{ + VAR_NAME="${1}" + DEFAULT_VALUE="${2}" + + [ -z "${!VAR_NAME}" ] && export ${VAR_NAME}="${DEFAULT_VALUE}" +} + +## You are supposed to provide the following variables according to your system setup +define_default_value ANDROID_NDK_PATH "/opt/android-ndk/" +define_default_value ANDROID_NDK_ARCH "arm" +define_default_value ANDROID_PLATFORM_VER "16" +define_default_value NATIVE_LIBS_TOOLCHAIN_PATH "${HOME}/Builds/android-toolchains/retroshare-android-${ANDROID_PLATFORM_VER}-${ANDROID_NDK_ARCH}/" +define_default_value HOST_NUM_CPU $(nproc) + +define_default_value BZIP2_SOURCE_VERSION "1.0.6" +define_default_value BZIP2_SOURCE_SHA256 a2848f34fcd5d6cf47def00461fcb528a0484d8edef8208d6d2e2909dc61d9cd + +define_default_value OPENSSL_SOURCE_VERSION "1.1.1" +define_default_value OPENSSL_SOURCE_SHA256 2836875a0f89c03d0fdf483941512613a50cfb421d6fd94b9f41d7279d586a3d + +define_default_value SQLITE_SOURCE_YEAR "2018" +define_default_value SQLITE_SOURCE_VERSION "3250200" +define_default_value SQLITE_SOURCE_SHA256 da9a1484423d524d3ac793af518cdf870c8255d209e369bd6a193e9f9d0e3181 + +define_default_value SQLCIPHER_SOURCE_VERSION "3.4.2" +define_default_value SQLCIPHER_SOURCE_SHA256 69897a5167f34e8a84c7069f1b283aba88cdfa8ec183165c4a5da2c816cfaadb + +define_default_value LIBUPNP_SOURCE_VERSION "1.6.25" +define_default_value LIBUPNP_SOURCE_SHA256 c5a300b86775435c076d58a79cc0d5a977d76027d2a7d721590729b7f369fa43 + +define_default_value INSTALL_QT_ANDROID "false" +define_default_value QT_VERSION "5.12.0" +define_default_value QT_ANDROID_INSTALLER_SHA256 a214084e2295c9a9f8727e8a0131c37255bf724bfc69e80f7012ba3abeb1f763 + +define_default_value RESTBED_SOURCE_VERSION "4.6" + +define_default_value XAPIAN_SOURCE_VERSION "1.4.7" +define_default_value XAPIAN_SOURCE_SHA256 13f08a0b649c7afa804fa0e85678d693fd6069dd394c9b9e7d41973d74a3b5d3 + +define_default_value RAPIDJSON_SOURCE_VERSION "1.1.0" +define_default_value RAPIDJSON_SOURCE_SHA256 bf7ced29704a1e696fbccf2a2b4ea068e7774fa37f6d7dd4039d0787f8bed98e + + +## $1 filename, $2 sha256 hash +function check_sha256() +{ + echo ${2} "${1}" | sha256sum -c &> /dev/null +} + +## $1 filename, $2 sha256 hash, $3 url +function verified_download() +{ + FILENAME="$1" + SHA256="$2" + URL="$3" + + check_sha256 "${FILENAME}" "${SHA256}" || + { + rm -rf "${FILENAME}" + + wget -O "${FILENAME}" "$URL" || + { + echo "Failed downloading ${FILENAME} from $URL" + exit 1 + } + + check_sha256 "${FILENAME}" "${SHA256}" || + { + echo "SHA256 mismatch for ${FILENAME} from ${URL} expected sha256 ${SHA256} got $(sha256sum ${FILENAME} | awk '{print $1}')" + exit 1 + } + } +} + + + +if [ "${ANDROID_NDK_ARCH}" == "x86" ]; then + cArch="i686" + eABI="" +else + cArch="${ANDROID_NDK_ARCH}" + eABI="eabi" +fi +export SYSROOT="${NATIVE_LIBS_TOOLCHAIN_PATH}/sysroot/" +export PREFIX="${SYSROOT}/usr/" +export CC="${NATIVE_LIBS_TOOLCHAIN_PATH}/bin/${cArch}-linux-android${eABI}-clang" +export CXX="${NATIVE_LIBS_TOOLCHAIN_PATH}/bin/${cArch}-linux-android${eABI}-clang++" +export AR="${NATIVE_LIBS_TOOLCHAIN_PATH}/bin/${cArch}-linux-android${eABI}-ar" +export RANLIB="${NATIVE_LIBS_TOOLCHAIN_PATH}/bin/${cArch}-linux-android${eABI}-ranlib" + + +## More information available at https://android.googlesource.com/platform/ndk/+/ics-mr0/docs/STANDALONE-TOOLCHAIN.html +build_toolchain() +{ + rm -rf ${NATIVE_LIBS_TOOLCHAIN_PATH} + ${ANDROID_NDK_PATH}/build/tools/make_standalone_toolchain.py --verbose \ + --arch ${ANDROID_NDK_ARCH} --install-dir ${NATIVE_LIBS_TOOLCHAIN_PATH} \ + --api ${ANDROID_PLATFORM_VER} + find "${PREFIX}/include/" -not -type d > "${NATIVE_LIBS_TOOLCHAIN_PATH}/deletefiles" +} + +## This avoid include errors due to -isystem and -I ordering issue +delete_copied_includes() +{ + cat "${NATIVE_LIBS_TOOLCHAIN_PATH}/deletefiles" | while read delFile ; do + rm "$delFile" + done +} + +## More information available at https://gitlab.com/relan/provisioners/merge_requests/1 and http://stackoverflow.com/a/34032216 +install_qt_android() +{ + QT_VERSION_CODE=$(echo $QT_VERSION | tr -d .) + QT_INSTALL_PATH=${NATIVE_LIBS_TOOLCHAIN_PATH}/Qt + QT_INSTALLER="qt-unified-linux-x64-3.0.2-online.run" + + verified_download $QT_INSTALLER $QT_ANDROID_INSTALLER_SHA256 \ + http://master.qt.io/archive/online_installers/3.0/${QT_INSTALLER} + + chmod a+x ${QT_INSTALLER} + + QT_INSTALLER_SCRIPT="qt_installer_script.js" + cat << EOF > "${QT_INSTALLER_SCRIPT}" +function Controller() { + installer.autoRejectMessageBoxes(); + installer.installationFinished.connect(function() { + gui.clickButton(buttons.NextButton); + }); + + var welcomePage = gui.pageWidgetByObjectName("WelcomePage"); + welcomePage.completeChanged.connect(function() { + if (gui.currentPageWidget().objectName == welcomePage.objectName) + gui.clickButton(buttons.NextButton); + }); +} + +Controller.prototype.WelcomePageCallback = function() { + gui.clickButton(buttons.NextButton); +} + +Controller.prototype.CredentialsPageCallback = function() { + gui.clickButton(buttons.NextButton); +} + +Controller.prototype.IntroductionPageCallback = function() { + gui.clickButton(buttons.NextButton); +} + +Controller.prototype.TargetDirectoryPageCallback = function() { + gui.currentPageWidget().TargetDirectoryLineEdit.setText("$QT_INSTALL_PATH"); + gui.clickButton(buttons.NextButton); +} + +Controller.prototype.ComponentSelectionPageCallback = function() { + var widget = gui.currentPageWidget(); + + // You can get these component names by running the installer with the + // --verbose flag. It will then print out a resource tree. + + widget.deselectComponent("qt.tools.qtcreator"); + widget.deselectComponent("qt.tools.doc"); + widget.deselectComponent("qt.tools.examples"); + + widget.selectComponent("qt.$QT_VERSION_CODE.android_armv7"); + + gui.clickButton(buttons.NextButton); +} + +Controller.prototype.LicenseAgreementPageCallback = function() { + gui.currentPageWidget().AcceptLicenseRadioButton.setChecked(true); + gui.clickButton(buttons.NextButton); +} + +Controller.prototype.StartMenuDirectoryPageCallback = function() { + gui.clickButton(buttons.NextButton); +} + +Controller.prototype.ReadyForInstallationPageCallback = function() { + gui.clickButton(buttons.NextButton); +} + +Controller.prototype.FinishedPageCallback = function() { + var checkBoxForm = gui.currentPageWidget().LaunchQtCreatorCheckBoxForm; + if (checkBoxForm && checkBoxForm.launchQtCreatorCheckBox) + checkBoxForm.launchQtCreatorCheckBox.checked = false; + gui.clickButton(buttons.FinishButton); +} +EOF + +QT_QPA_PLATFORM=minimal ./${QT_INSTALLER} --script ${QT_INSTALLER_SCRIPT} +} + +## More information available at retroshare://file?name=Android%20Native%20Development%20Kit%20Cookbook.pdf&size=29214468&hash=0123361c1b14366ce36118e82b90faf7c7b1b136 +build_bzlib() +{ + B_dir="bzip2-${BZIP2_SOURCE_VERSION}" + rm -rf $B_dir + + verified_download $B_dir.tar.gz $BZIP2_SOURCE_SHA256 \ + http://trumpetti.atm.tut.fi/gentoo/distfiles/bzip2-${BZIP2_SOURCE_VERSION}.tar.gz + + tar -xf $B_dir.tar.gz + cd $B_dir + sed -i "/^CC=.*/d" Makefile + sed -i "/^AR=.*/d" Makefile + sed -i "/^RANLIB=.*/d" Makefile + sed -i "/^LDFLAGS=.*/d" Makefile + sed -i "s/^all: libbz2.a bzip2 bzip2recover test/all: libbz2.a bzip2 bzip2recover/" Makefile + make -j${HOST_NUM_CPU} + make install PREFIX=${PREFIX} +# sed -i "/^CC=.*/d" Makefile-libbz2_so +# make -f Makefile-libbz2_so -j${HOST_NUM_CPU} +# cp libbz2.so.1.0.6 ${SYSROOT}/usr/lib/libbz2.so + cd .. +} + +## More information available at http://doc.qt.io/qt-5/opensslsupport.html +build_openssl() +{ + B_dir="openssl-${OPENSSL_SOURCE_VERSION}" + rm -rf $B_dir + + verified_download $B_dir.tar.gz $OPENSSL_SOURCE_SHA256 \ + https://www.openssl.org/source/$B_dir.tar.gz + + tar -xf $B_dir.tar.gz + cd $B_dir +## We link openssl statically to avoid android silently sneaking in his own +## version of libssl.so (we noticed this because it had some missing symbol +## that made RS crash), the crash in some android version is only one of the +## possible problems the fact that android insert his own binary libssl.so pose +## non neglegible security concerns. + oBits="32" + [[ ${ANDROID_NDK_ARCH} =~ .*64.* ]] && oBits=64 + + ANDROID_NDK="${ANDROID_NDK_PATH}" PATH="${SYSROOT}/bin/:${PATH}" \ + ./Configure linux-generic${oBits} --prefix="${PREFIX}" \ + --openssldir="${SYSROOT}/etc/ssl" +# sed -i 's/LIBNAME=$$i LIBVERSION=$(SHLIB_MAJOR).$(SHLIB_MINOR) \\/LIBNAME=$$i \\/g' Makefile +# sed -i '/LIBCOMPATVERSIONS=";$(SHLIB_VERSION_HISTORY)" \\/d' Makefile + make -j${HOST_NUM_CPU} + make install + rm -f ${PREFIX}/lib/libssl.so* + rm -f ${PREFIX}/lib/libcrypto.so* + cd .. +} + +build_sqlite() +{ + B_dir="sqlite-autoconf-${SQLITE_SOURCE_VERSION}" + + verified_download $B_dir.tar.gz $SQLITE_SOURCE_SHA256 \ + https://www.sqlite.org/${SQLITE_SOURCE_YEAR}/$B_dir.tar.gz + + tar -xf $B_dir.tar.gz + cd $B_dir + ./configure --prefix="${PREFIX}" --host=${ANDROID_NDK_ARCH}-linux + make -j${HOST_NUM_CPU} + make install + rm -f ${PREFIX}/lib/libsqlite3.so* +# ${CC} -shared -o libsqlite3.so -fPIC sqlite3.o -ldl +# cp libsqlite3.so "${SYSROOT}/usr/lib" + cd .. +} + +build_sqlcipher() +{ + B_dir="sqlcipher-${SQLCIPHER_SOURCE_VERSION}" + rm -rf $B_dir + + T_file="${B_dir}.tar.gz" + + verified_download $T_file $SQLCIPHER_SOURCE_SHA256 \ + https://github.com/sqlcipher/sqlcipher/archive/v${SQLCIPHER_SOURCE_VERSION}.tar.gz + + tar -xf $T_file + cd $B_dir + ./configure --build=$(sh ./config.guess) \ + --host=${ANDROID_NDK_ARCH}-linux \ + --prefix="${PREFIX}" --with-sysroot="${SYSROOT}" \ + --enable-tempstore=yes \ + --disable-tcl --disable-shared \ + CFLAGS="-DSQLITE_HAS_CODEC" LDFLAGS="${PREFIX}/lib/libcrypto.a" + make -j${HOST_NUM_CPU} + make install + cd .. +} + +build_libupnp() +{ + B_dir="libupnp-${LIBUPNP_SOURCE_VERSION}" + rm -rf $B_dir + + verified_download $B_dir.tar.bz2 $LIBUPNP_SOURCE_SHA256 \ + https://sourceforge.net/projects/pupnp/files/pupnp/libUPnP%20${LIBUPNP_SOURCE_VERSION}/$B_dir.tar.bz2 + + tar -xf $B_dir.tar.bz2 + cd $B_dir +## liupnp must be configured as static library because if not the linker will +## look for libthreadutils.so.6 at runtime that cannot be packaged on android +## as it supports only libname.so format for libraries, thus resulting in a +## crash at startup. + ./configure --enable-static --disable-shared --disable-samples \ + --prefix="${PREFIX}" --host=${ANDROID_NDK_ARCH}-linux + make -j${HOST_NUM_CPU} + make install + cd .. +} + +build_rapidjson() +{ + B_dir="rapidjson-${RAPIDJSON_SOURCE_VERSION}" + D_file="${B_dir}.tar.gz" + verified_download $D_file $RAPIDJSON_SOURCE_SHA256 \ + https://github.com/Tencent/rapidjson/archive/v${RAPIDJSON_SOURCE_VERSION}.tar.gz + tar -xf $D_file + cp -r "${B_dir}/include/rapidjson/" "${PREFIX}/include/rapidjson" +} + +build_restbed() +{ + [ -d restbed ] || git clone --depth=2000 https://github.com/Corvusoft/restbed.git + cd restbed + git fetch --tags + git checkout tags/${RESTBED_SOURCE_VERSION} + git submodule update --init dependency/asio + git submodule update --init dependency/catch + git submodule update --init dependency/kashmir + cd .. + + rm -rf restbed-build; mkdir restbed-build ; cd restbed-build + cmake -DBUILD_SSL=OFF -DCMAKE_INSTALL_PREFIX="${PREFIX}" -B. -H../restbed + make -j${HOST_NUM_CPU} + make install + cp "${PREFIX}/library/librestbed.a" "${PREFIX}/lib/" + cd .. +} + +build_xapian() +{ + B_dir="xapian-core-${XAPIAN_SOURCE_VERSION}" + D_file="$B_dir.tar.xz" + verified_download $D_file $XAPIAN_SOURCE_SHA256 \ + https://oligarchy.co.uk/xapian/${XAPIAN_SOURCE_VERSION}/$D_file + rm -rf $B_dir + tar -xf $D_file + cd $B_dir + B_endiannes_detection_failure_workaround="ac_cv_c_bigendian=no" + B_large_file="" + [ "${ANDROID_PLATFORM_VER}" -lt "24" ] && B_large_file="--disable-largefile" + ./configure ${B_endiannes_detection_failure_workaround} ${B_large_file} \ + --disable-backend-inmemory --disable-backend-remote \ + --disable--backend-chert --enable-backend-glass \ + --host=${ANDROID_NDK_ARCH}-linux --enable-static --disable-shared \ + --prefix="${PREFIX}" --with-sysroot="${SYSROOT}" + make -j${HOST_NUM_CPU} + make install +} + +build_toolchain +[ "${INSTALL_QT_ANDROID}X" != "trueX" ] || install_qt_android +build_bzlib +build_openssl +build_sqlite +build_sqlcipher +build_libupnp +build_rapidjson +build_restbed +build_xapian +delete_copied_includes + +echo NATIVE_LIBS_TOOLCHAIN_PATH=${NATIVE_LIBS_TOOLCHAIN_PATH} diff --git a/build_scripts/AppImage_OBS/retroshare-service-git/appimage.yml b/build_scripts/AppImage_OBS/retroshare-service-git/appimage.yml new file mode 100644 index 000000000..d49dc9eea --- /dev/null +++ b/build_scripts/AppImage_OBS/retroshare-service-git/appimage.yml @@ -0,0 +1,30 @@ +app: retroshare-service + +build: + packages: + - gcc7 + - gcc7-c++ + - libxapian-devel + - doxygen + - linuxdeployqt + - desktop-file-utils + - glib2-devel + - sqlcipher-devel + - libqt5-qtbase-devel + - libqt5-qttools-devel + - openssl-devel + - update-desktop-files + - libbz2-devel + - libupnp-devel + +script: + - cd $BUILD_SOURCE_DIR + - tar -xf RetroShare-git.tar.gz + - cd RetroShare-git + - ls $(which gcc)* + - ls $(which g++)* + - qmake-qt5 QMAKE_CC=gcc-7 QMAKE_CXX=g++-7 PREFIX=/usr CONFIG-=debug CONFIG+=release CONFIG+=no_retroshare_nogui CONFIG+=no_retroshare_plugins CONFIG+=no_retroshare_qml_app CONFIG+=no_retroshare_android_notify_service CONFIG+=no_retroshare_plugins CONFIG+=ipv6 CONFIG+=no_retroshare_nogui CONFIG+=no_tests CONFIG+=rs_jsonapi CONFIG+=no_retroshare_android_service CONFIG+=rs_deep_search CONFIG+=no_libresapilocalserver CONFIG+=no_retroshare_gui CONFIG+=no_libresapihttpserver CONFIG+=retroshare_service CONFIG+=no_libresapi CONFIG+=c++11 CONFIG+=appimage + - make -j$(nproc) || make -j$(nproc) || make + - make INSTALL_ROOT=$BUILD_APPDIR install + - unset QTDIR; unset QT_PLUGIN_PATH ; unset LD_LIBRARY_PATH + - linuxdeployqt $BUILD_APPDIR/usr/share/applications/*.desktop -bundle-non-qt-libs -verbose=3 -no-strip \ No newline at end of file diff --git a/build_scripts/ArchLinuxAndDerivatives_OBS/PKGBUILD b/build_scripts/ArchLinuxAndDerivatives_OBS/PKGBUILD new file mode 100644 index 000000000..70c970ded --- /dev/null +++ b/build_scripts/ArchLinuxAndDerivatives_OBS/PKGBUILD @@ -0,0 +1,45 @@ +# Maintainer: Gioacchino Mazzurco +# Contributor: AsamK +# Contributor: sehraf +# Contributor: stqn +# Contributor: JHeaton +# Contributor: Tristero +# Contributor: funkyou + +pkgname=retroshare-service-git +pkgver=git +pkgrel=0 +pkgdesc="Serverless encrypted instant messenger with filesharing, chatgroups, e-mail. System service version." +arch=('i686' 'x86_64' 'armv6h' 'armv7h') +url="https://retroshare.net/" +license=('AGPL' 'GPL' 'LGPL') +depends=('bzip2' 'libupnp' 'libzip' 'openssl' 'rapidjson' 'sqlcipher' 'xapian-core') +makedepends=('cmake' 'doxygen' 'git' 'pkgconf' 'qt5-tools') +provides=('retroshare-service') +conflicts=('retroshare-service') + +source=(RetroShare-${pkgver}.tar.gz) + +md5sums=('3c66108223b427d617b962aff0755378') + +prepare() { + cd "${srcdir}/RetroShare-${pkgver}" +} + +build() { + cd "${srcdir}/RetroShare-${pkgver}" + qmake-qt5 PREFIX=/usr DATA_DIR=/usr/share/retroshare CONFIG-=debug \ + CONFIG+=ipv6 CONFIG+=no_retroshare_android_service \ + CONFIG+=no_retroshare_android_notify_service \ + CONFIG+=no_retroshare_plugins CONFIG+=no_retroshare_nogui \ + CONFIG+=no_retroshare_gui CONFIG+=no_tests CONFIG+=no_libresapi \ + CONFIG+=no_libresapihttpserver CONFIG+=no_libresapilocalserver \ + CONFIG+=retroshare_service CONFIG+=rs_jsonapi CONFIG+=rs_deep_search \ + CONFIG+=release + make -j$(nproc) || make -j$(nproc) || make +} + +package() { + cd "${srcdir}/RetroShare-${pkgver}" + make INSTALL_ROOT="${pkgdir}" install +} diff --git a/build_scripts/DebianAndDerivatives_OBS/retroshare-service-git/debian.changelog b/build_scripts/DebianAndDerivatives_OBS/retroshare-service-git/debian.changelog new file mode 100644 index 000000000..92f41bd59 --- /dev/null +++ b/build_scripts/DebianAndDerivatives_OBS/retroshare-service-git/debian.changelog @@ -0,0 +1,5 @@ +retroshare-service-git (0.6.9999) stable; urgency=low + + Add retroshare-service-git package + + -- Gioacchino Mazzurco Tue, 08 Oct 2018 15:40:00 +0100 diff --git a/build_scripts/DebianAndDerivatives_OBS/retroshare-service-git/debian.compat b/build_scripts/DebianAndDerivatives_OBS/retroshare-service-git/debian.compat new file mode 100644 index 000000000..7f8f011eb --- /dev/null +++ b/build_scripts/DebianAndDerivatives_OBS/retroshare-service-git/debian.compat @@ -0,0 +1 @@ +7 diff --git a/build_scripts/DebianAndDerivatives_OBS/retroshare-service-git/debian.control b/build_scripts/DebianAndDerivatives_OBS/retroshare-service-git/debian.control new file mode 100644 index 000000000..03eb0f02a --- /dev/null +++ b/build_scripts/DebianAndDerivatives_OBS/retroshare-service-git/debian.control @@ -0,0 +1,18 @@ +Source: retroshare-service-git +Section: devel +Priority: standard +Maintainer: Cyril Soler +Standards-Version: 3.9.3 +Homepage: http://retroshare.net + +Package: retroshare-service-git +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: Secure communication with friends + RetroShare is a Free and Open Source, private and secure decentralized + communication platform. It lets you to securely chat and share files with your + friends and family, using a web-of-trust to authenticate peers and OpenSSL to + encrypt all communication. RetroShare provides filesharing, chat, messages, + forums and channels. + This package provide a headless RetroShare node that can be controlled only + using the JSON API. diff --git a/build_scripts/DebianAndDerivatives_OBS/retroshare-service-git/debian.retroshare-service-git.install b/build_scripts/DebianAndDerivatives_OBS/retroshare-service-git/debian.retroshare-service-git.install new file mode 100644 index 000000000..d1e2a398e --- /dev/null +++ b/build_scripts/DebianAndDerivatives_OBS/retroshare-service-git/debian.retroshare-service-git.install @@ -0,0 +1,2 @@ +debian/tmp/usr/bin/retroshare-service +debian/tmp/usr/share/retroshare/bdboot.txt diff --git a/build_scripts/DebianAndDerivatives_OBS/retroshare-service-git/debian.rules b/build_scripts/DebianAndDerivatives_OBS/retroshare-service-git/debian.rules new file mode 100644 index 000000000..204288931 --- /dev/null +++ b/build_scripts/DebianAndDerivatives_OBS/retroshare-service-git/debian.rules @@ -0,0 +1,59 @@ +#!/usr/bin/make -f + +configure: configure-stamp +configure-stamp: + dh_testdir + qmake --version + qmake CONFIG-=debug CONFIG+=release PREFIX=/usr LIB_DIR=/usr/lib \ + CONFIG+=no_retroshare_plugins CONFIG+=no_retroshare_nogui \ + CONFIG+=no_retroshare_gui CONFIG+=no_tests CONFIG+=no_libresapi \ + CONFIG+=no_libresapihttpserver CONFIG+=no_libresapilocalserver \ + CONFIG+=retroshare_service CONFIG+=rs_jsonapi CONFIG+=rs_deep_search \ + CONFIG+=c++11 RetroShare.pro + touch $@ + +build: build-stamp +build-stamp: configure-stamp + dh_testdir + $(MAKE) -j$(shell nproc) || $(MAKE) -j$(shell nproc) || $(MAKE) + touch $@ + +clean: + dh_testdir + dh_testroot + rm -f configure-stamp build-stamp + # Add here commands to clean up after the build process. + [ ! -f Makefile ] || $(MAKE) distclean + dh_clean + +install: build + dh_testdir + dh_testroot + dh_clean -k + #dh_installdirs + $(MAKE) INSTALL_ROOT=$(CURDIR)/debian/tmp install + +# Build architecture-independent files here. +binary-indep: build install +# We have nothing to do by default. + +# Build architecture-dependent files here. +binary-arch: build install + dh_testdir + dh_testroot + dh_install --list-missing + #dh_installdocs + #dh_installexamples + #dh_installman + dh_link + dh_strip + dh_compress + dh_fixperms + dh_installdeb + dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install configure diff --git a/build_scripts/DebianAndDerivatives_OBS/retroshare-service-git/debian.series b/build_scripts/DebianAndDerivatives_OBS/retroshare-service-git/debian.series new file mode 100644 index 000000000..e69de29bb diff --git a/build_scripts/DebianAndDerivatives_OBS/retroshare-service-git/retroshare-service-git.dsc b/build_scripts/DebianAndDerivatives_OBS/retroshare-service-git/retroshare-service-git.dsc new file mode 100644 index 000000000..b434e097d --- /dev/null +++ b/build_scripts/DebianAndDerivatives_OBS/retroshare-service-git/retroshare-service-git.dsc @@ -0,0 +1,11 @@ +Format: 1.0 +Source: retroshare-service-git +Binary: retroshare-service-git +Architecture: any +Version: 0.6.9999 +Maintainer: Cyril Soler +Homepage: https://retroshare.net +Standards-Version: 3.8.1 +Build-Depends: cmake, debhelper (>= 7), doxygen, git, libglib2.0-dev, libupnp-dev, qtbase5-dev, qt5-default, libssl-dev, libbz2-dev, libsqlcipher-dev, libxapian-dev +Files: + f562e399ef7d44ebc01362f365b4f30b 23617604 RetroShare-git.tar.gz diff --git a/build_scripts/RpmBased_OBS/retroshare-service-git.spec b/build_scripts/RpmBased_OBS/retroshare-service-git.spec new file mode 100644 index 000000000..30ab43412 --- /dev/null +++ b/build_scripts/RpmBased_OBS/retroshare-service-git.spec @@ -0,0 +1,120 @@ +Name: retroshare-service-git +Version: 0.6.9999 +Release: 0 +License: GNU AFFERO GENERAL PUBLIC LICENSE version 3 +Summary: Secure chat and file sharing +Group: Productivity/Networking/Other +Url: http://retroshare.net +#Source0: https://github.com/RetroShare/RetroShare/archive/v%{version}.tar.gz#/RetroShare-%{version}.tar.gz +Source0: RetroShare-git.tar.gz +#Patch0: various.patch +BuildRoot: %{_tmppath}/%{name} +Conflicts: retroshare-service +Requires: libupnp openssl sqlcipher +BuildRequires: cmake doxygen git libupnp-devel openssl-devel sqlcipher-devel + +%if %{defined centos_version} +BuildRequires: qt5-qtbase-devel qt5-qttools-devel qt5-qttools-static +Requires: qt5-qtbase +%endif + +%if 0%{?fedora_version} +BuildRequires: gcc-c++ +BuildRequires: fdupes xapian-core-devel +BuildRequires: qt5-qtbase-devel qt5-qttools-devel qt5-qttools-static +Requires: qt5-qtbase xapian-core +%endif + +%if %{defined mageia} +BuildRequires: gcc-c++ +BuildRequires: libzlib-devel libbzip2-devel +BuildRequires: libqt5core-devel libqt5xml-devel libxapian-devel +Requires: libqt5core libqt5xml5 libxapian +%endif + +%if 0%{?suse_version} +BuildRequires: gcc7 gcc7-c++ +BuildRequires: fdupes libbz2-devel +BuildRequires: libqt5-qtbase-devel libqt5-qttools-devel +BuildRequires: libxapian-devel update-desktop-files +Requires: libbz2 libxapian +%endif + +%if 0%{?fedora_version} >= 27 +%undefine _debugsource_packages +%undefine _debuginfo_subpackages +%endif + +%description +RetroShare is a cross-platform F2F communication platform. +It lets you share securely with your friends, using PGP +to authenticate peers and OpenSSL to encrypt all communication. +RetroShare provides filesharing, chat, messages and channels. +This package provides RetroShare system service that can be +controlled only via JSON API. + +Authors: +see http://retroshare.net/ +-------- + +%prep +%setup -n RetroShare-git +#%patch0 -p0 + +%build + +nproc +qmake --version || qmake-qt5 --version +ls $(which gcc)* +ls $(which g++)* + +BUILD_CC="" +BUILD_CXX="" +BUILD_DEEPSEARCH="CONFIG+=rs_deep_search" +QMAKE="qmake-qt5" + +%if %{defined centos_version} +# Xapian is not availabe on Centos 7 +BUILD_DEEPSEARCH="CONFIG+=no_rs_deep_search" +%endif + +%if %{defined mageia} +QMAKE="qmake" +%endif + +%if 0%{?suse_version} +BUILD_CC="QMAKE_CC=gcc-7" +BUILD_CXX="QMAKE_CXX=g++-7" +%endif + +$QMAKE $BUILD_CC $BUILD_CXX QMAKE_STRIP=echo PREFIX="%{_prefix}" \ + BIN_DIR="%{_bindir}" \ + LIB_DIR="%{_libdir}" DATA_DIR="%{_datadir}/retroshare" CONFIG-=debug \ + CONFIG+=ipv6 CONFIG+=no_retroshare_android_service \ + CONFIG+=no_retroshare_android_notify_service \ + CONFIG+=no_retroshare_plugins CONFIG+=no_retroshare_nogui \ + CONFIG+=no_retroshare_gui CONFIG+=no_tests CONFIG+=no_libresapi \ + CONFIG+=no_libresapihttpserver CONFIG+=no_libresapilocalserver \ + CONFIG+=retroshare_service CONFIG+=rs_jsonapi ${BUILD_DEEPSEARCH} \ + CONFIG+=release RetroShare.pro +make -j$(nproc) || make -j$(nproc) || make + +%install +rm -rf $RPM_BUILD_ROOT +make INSTALL_ROOT=$RPM_BUILD_ROOT install + +%if 0%{?centos_version} < 800 +%else +%fdupes %{buildroot}/%{_prefix} +%endif + +%clean +rm -rf $RPM_BUILD_ROOT + +%files +%defattr(-, root, root) +%{_bindir}/retroshare-service +%defattr(644, root, root) +%{_datadir}/retroshare + +%changelog diff --git a/data/retroshare.svg b/data/retroshare.svg new file mode 100644 index 000000000..403f4fb52 --- /dev/null +++ b/data/retroshare.svg @@ -0,0 +1,263 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jsonapi-generator/src/jsonapi-generator.cpp b/jsonapi-generator/src/jsonapi-generator.cpp index 21f2a1b93..aa20eda01 100644 --- a/jsonapi-generator/src/jsonapi-generator.cpp +++ b/jsonapi-generator/src/jsonapi-generator.cpp @@ -45,7 +45,7 @@ int main(int argc, char *argv[]) if(argc != 3) { qDebug() << "Usage: jsonapi-generator SOURCE_PATH OUTPUT_PATH"; - return EINVAL; + return -EINVAL; } QString sourcePath(argv[1]); @@ -56,17 +56,23 @@ int main(int argc, char *argv[]) QFile wrappersDefFile(wrappersDefFilePath); wrappersDefFile.remove(); if(!wrappersDefFile.open(QIODevice::WriteOnly|QIODevice::Append|QIODevice::Text)) - qFatal(QString("Can't open: " + wrappersDefFilePath).toLatin1().data()); + { + qDebug() << "Can't open: " << wrappersDefFilePath; + return -errno; + } 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()); + { + qDebug() << "Can't open: " << cppApiIncludesFilePath; + return -errno; + } QSet cppApiIncludesSet; auto fatalError = [&]( - std::initializer_list errors, int ernum = EINVAL ) + std::initializer_list errors, int ernum = -EINVAL ) { QString errorMsg; for(const QVariant& error: errors) @@ -296,7 +302,7 @@ int main(int argc, char *argv[]) const MethodParam& mp(paramsMap[pn]); paramsDeclaration += "\t\t" + mp.type + " " + mp.name; if(!mp.defval.isEmpty()) - paramsDeclaration += "(" + mp.defval + ")"; + paramsDeclaration += " = " + mp.defval; paramsDeclaration += ";\n"; if(mp.in) inputParamsDeserialization += "\t\t\tRS_SERIAL_PROCESS(" diff --git a/libresapi/src/api/PeersHandler.cpp b/libresapi/src/api/PeersHandler.cpp index 09e30e58d..27e1e458f 100644 --- a/libresapi/src/api/PeersHandler.cpp +++ b/libresapi/src/api/PeersHandler.cpp @@ -422,7 +422,9 @@ void PeersHandler::handleWildcard(Request &req, Response &resp) { if(str == "self" && !req.mPath.empty() && req.mPath.top() == "certificate") { - resp.mDataStream << makeKeyValue("cert_string", mRsPeers->GetRetroshareInvite(false)); + resp.mDataStream << makeKeyValue( + "cert_string", + mRsPeers->GetRetroshareInvite()); resp.setOk(); return; } diff --git a/libretroshare/src/file_sharing/p3filelists.cc b/libretroshare/src/file_sharing/p3filelists.cc index a4b8f2d0b..ff825f691 100644 --- a/libretroshare/src/file_sharing/p3filelists.cc +++ b/libretroshare/src/file_sharing/p3filelists.cc @@ -779,10 +779,14 @@ template<> bool p3FileDatabase::convertPointerToEntryIndex<4>(const void *p, Ent { // trust me, I can do this ;-) -#pragma GCC diagnostic ignored "-Wstrict-aliasing" +#if defined(__GNUC__) && !defined(__clang__) +# pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif // defined(__GNUC__) && !defined(__clang__) e = EntryIndex( *reinterpret_cast(&p) & ENTRY_INDEX_BIT_MASK_32BITS ) ; friend_index = (*reinterpret_cast(&p)) >> NB_ENTRY_INDEX_BITS_32BITS ; -#pragma GCC diagnostic pop +#if defined(__GNUC__) && !defined(__clang__) +# pragma GCC diagnostic pop +#endif // defined(__GNUC__) && !defined(__clang__) if(friend_index == 0) { @@ -819,10 +823,14 @@ template<> bool p3FileDatabase::convertPointerToEntryIndex<8>(const void *p, Ent { // trust me, I can do this ;-) +#if defined(__GNUC__) && !defined(__clang__) #pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif // defined(__GNUC__) && !defined(__clang__) e = EntryIndex( *reinterpret_cast(&p) & ENTRY_INDEX_BIT_MASK_64BITS ) ; friend_index = (*reinterpret_cast(&p)) >> NB_ENTRY_INDEX_BITS_64BITS ; +#if defined(__GNUC__) && !defined(__clang__) #pragma GCC diagnostic pop +#endif // defined(__GNUC__) && !defined(__clang__) if(friend_index == 0) { @@ -1184,16 +1192,6 @@ int p3FileDatabase::RequestDirDetails(void *ref, DirDetails& d, FileSearchFlags return true; } -int p3FileDatabase::RequestDirDetails(const RsPeerId &/*uid*/, const std::string &/*path*/, DirDetails &/*details*/) const -{ - NOT_IMPLEMENTED(); - return 0; -} -//int p3FileDatabase::RequestDirDetails(const std::string& path, DirDetails &details) const -//{ -// NOT_IMPLEMENTED(); -// return 0; -//} uint32_t p3FileDatabase::getType(void *ref,FileSearchFlags flags) const { RS_STACK_MUTEX(mFLSMtx) ; @@ -2027,11 +2025,11 @@ bool p3FileDatabase::banFile(const RsFileHash& real_file_hash, const std::string 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) + if(entry.mBanTimeStamp == 0) { - entry.filename = filename ; - entry.size = file_size ; - entry.ban_time_stamp = time(NULL); + entry.mFilename = filename ; + entry.mSize = file_size ; + entry.mBanTimeStamp = time(NULL); RsFileHash hash_of_hash ; ftServer::encryptHash(real_file_hash,hash_of_hash) ; diff --git a/libretroshare/src/file_sharing/rsfilelistitems.cc b/libretroshare/src/file_sharing/rsfilelistitems.cc index 9e9253915..4ac90af10 100644 --- a/libretroshare/src/file_sharing/rsfilelistitems.cc +++ b/libretroshare/src/file_sharing/rsfilelistitems.cc @@ -50,12 +50,7 @@ void RsFileListsBannedHashesConfigItem::serial_process(RsGenericSerializer::Seri { 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) diff --git a/libretroshare/src/ft/ftserver.cc b/libretroshare/src/ft/ftserver.cc index 04d55e0ef..4ea44ab6f 100644 --- a/libretroshare/src/ft/ftserver.cc +++ b/libretroshare/src/ft/ftserver.cc @@ -702,19 +702,20 @@ bool ftServer::ExtraFileMove(std::string fname, const RsFileHash& hash, uint64_t /******************** Directory Listing ************************/ /***************************************************************/ -int ftServer::RequestDirDetails(const RsPeerId& uid, const std::string& path, DirDetails &details) -{ - return mFileDatabase->RequestDirDetails(uid, path, details); -} - bool ftServer::findChildPointer(void *ref, int row, void *& result, FileSearchFlags flags) { return mFileDatabase->findChildPointer(ref,row,result,flags) ; } + +bool ftServer::requestDirDetails( + DirDetails &details, std::uintptr_t handle, FileSearchFlags flags ) +{ return RequestDirDetails(reinterpret_cast(handle), details, flags); } + int ftServer::RequestDirDetails(void *ref, DirDetails &details, FileSearchFlags flags) { return mFileDatabase->RequestDirDetails(ref,details,flags) ; } + uint32_t ftServer::getType(void *ref, FileSearchFlags flags) { return mFileDatabase->getType(ref,flags) ; diff --git a/libretroshare/src/ft/ftserver.h b/libretroshare/src/ft/ftserver.h index 5b959c3f0..d93341035 100644 --- a/libretroshare/src/ft/ftserver.h +++ b/libretroshare/src/ft/ftserver.h @@ -189,8 +189,13 @@ public: /*** * Directory Listing / Search Interface ***/ - virtual int RequestDirDetails(const RsPeerId& uid, const std::string& path, DirDetails &details); virtual int RequestDirDetails(void *ref, DirDetails &details, FileSearchFlags flags); + + /// @see RsFiles::RequestDirDetails + virtual bool requestDirDetails( + DirDetails &details, std::uintptr_t handle = 0, + FileSearchFlags flags = RS_FILE_HINTS_LOCAL ); + virtual bool findChildPointer(void *ref, int row, void *& result, FileSearchFlags flags) ; virtual uint32_t getType(void *ref,FileSearchFlags flags) ; diff --git a/libretroshare/src/jsonapi/jsonapi.cpp b/libretroshare/src/jsonapi/jsonapi.cpp index e9300b250..0a293de93 100644 --- a/libretroshare/src/jsonapi/jsonapi.cpp +++ b/libretroshare/src/jsonapi/jsonapi.cpp @@ -41,6 +41,26 @@ /*extern*/ JsonApiServer* jsonApiServer = nullptr; +/*static*/ const std::multimap +JsonApiServer::corsHeaders = +{ + { "Access-Control-Allow-Origin", "*" }, + { "Access-Control-Allow-Methods", "GET, POST, OPTIONS"}, + { "Access-Control-Allow-Headers", "DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range" }, + { "Access-Control-Expose-Headers", "Content-Length,Content-Range" } +}; + +/*static*/ const std::multimap +JsonApiServer::corsOptionsHeaders = +{ + { "Access-Control-Allow-Origin", "*" }, + { "Access-Control-Allow-Methods", "GET, POST, OPTIONS"}, + { "Access-Control-Allow-Headers", "DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range" }, + { "Access-Control-Max-Age", "1728000" }, // 20 days + { "Content-Type", "text/plain; charset=utf-8" }, + { "Content-Length", "0" } +}; + #define INITIALIZE_API_CALL_JSON_CONTEXT \ RsGenericSerializer::SerializeContext cReq( \ nullptr, 0, \ @@ -66,15 +86,13 @@ 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()) } \ - }; \ + auto headers = corsHeaders; \ + headers.insert({ "Content-Type", "text/json" }); \ + headers.insert({ "Content-Length", std::to_string(ans.length()) }); \ session->close(RET_CODE, ans, headers) -static bool checkRsServicePtrReady( +/*static*/ bool JsonApiServer::checkRsServicePtrReady( void* serviceInstance, const std::string& serviceName, RsGenericSerializer::SerializeContext& ctx, const std::shared_ptr session) @@ -141,10 +159,10 @@ JsonApiServer::JsonApiServer(uint16_t port, const std::string& bindAddress, }, false); registerHandler("/rsControl/rsGlobalShutDown", - [this](const std::shared_ptr session) + [](const std::shared_ptr session) { size_t reqSize = session->get_request()->get_header("Content-Length", 0); - session->fetch( reqSize, [this]( + session->fetch( reqSize, []( const std::shared_ptr session, const rb::Bytes& body ) { @@ -245,6 +263,7 @@ void JsonApiServer::registerHandler( resource->set_path(path); resource->set_method_handler("GET", handler); resource->set_method_handler("POST", handler); + resource->set_method_handler("OPTIONS", handleCorsOptions); if(requiresAutentication) resource->set_authentication_handler( @@ -408,3 +427,7 @@ bool JsonApiServer::loadList(std::list& loadList) void JsonApiServer::saveDone() { configMutex.unlock(); } +void JsonApiServer::handleCorsOptions( + const std::shared_ptr session ) +{ session->close(rb::NO_CONTENT, corsOptionsHeaders); } + diff --git a/libretroshare/src/jsonapi/jsonapi.h b/libretroshare/src/jsonapi/jsonapi.h index 5315054ea..6a8c3d94d 100644 --- a/libretroshare/src/jsonapi/jsonapi.h +++ b/libretroshare/src/jsonapi/jsonapi.h @@ -21,6 +21,7 @@ #include #include #include +#include #include "util/rsthreads.h" #include "pqi/p3cfgmgr.h" @@ -188,5 +189,14 @@ private: /// Encrypted persistent storage for authorized JSON API tokens JsonApiServerAuthTokenStorage mAuthTokenStorage; RsMutex configMutex; + + static const std::multimap corsHeaders; + static const std::multimap corsOptionsHeaders; + static void handleCorsOptions(const std::shared_ptr session); + + static bool checkRsServicePtrReady( + void* serviceInstance, const std::string& serviceName, + RsGenericSerializer::SerializeContext& ctx, + const std::shared_ptr session ); }; diff --git a/libretroshare/src/libretroshare.pro b/libretroshare/src/libretroshare.pro index dc56e20c2..f6094100e 100644 --- a/libretroshare/src/libretroshare.pro +++ b/libretroshare/src/libretroshare.pro @@ -857,36 +857,42 @@ rs_gxs_trans { rs_jsonapi { JSONAPI_GENERATOR_SRC=$$clean_path($${RS_SRC_PATH}/jsonapi-generator/src/) JSONAPI_GENERATOR_OUT=$$clean_path($${RS_BUILD_PATH}/jsonapi-generator/src/) - win32 { - CONFIG(release, debug|release) { - JSONAPI_GENERATOR_EXE=$$clean_path($${JSONAPI_GENERATOR_OUT}/release/jsonapi-generator.exe) + isEmpty(JSONAPI_GENERATOR_EXE) { + win32 { + CONFIG(release, debug|release) { + JSONAPI_GENERATOR_EXE=$$clean_path($${JSONAPI_GENERATOR_OUT}/release/jsonapi-generator.exe) + } + CONFIG(debug, debug|release) { + JSONAPI_GENERATOR_EXE=$$clean_path($${JSONAPI_GENERATOR_OUT}/debug/jsonapi-generator.exe) + } + } else { + JSONAPI_GENERATOR_EXE=$$clean_path($${JSONAPI_GENERATOR_OUT}/jsonapi-generator) } - CONFIG(debug, debug|release) { - JSONAPI_GENERATOR_EXE=$$clean_path($${JSONAPI_GENERATOR_OUT}/debug/jsonapi-generator.exe) - } - } else { - JSONAPI_GENERATOR_EXE=$$clean_path($${JSONAPI_GENERATOR_OUT}/jsonapi-generator) } + DOXIGEN_INPUT_DIRECTORY=$$clean_path($${PWD}) DOXIGEN_CONFIG_SRC=$$clean_path($${RS_SRC_PATH}/jsonapi-generator/src/jsonapi-generator-doxygen.conf) DOXIGEN_CONFIG_OUT=$$clean_path($${JSONAPI_GENERATOR_OUT}/jsonapi-generator-doxygen-final.conf) WRAPPERS_INCL_FILE=$$clean_path($${JSONAPI_GENERATOR_OUT}/jsonapi-includes.inl) WRAPPERS_REG_FILE=$$clean_path($${JSONAPI_GENERATOR_OUT}/jsonapi-wrappers.inl) - restbed.target = $$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$$shell_path($${RESTBED_SRC_PATH});\ - make; make install - QMAKE_EXTRA_TARGETS += restbed - libretroshare.depends += restbed - PRE_TARGETDEPS *= $${restbed.target} + no_rs_cross_compiling { + restbed.target = $$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 -DCMAKE_CXX_COMPILER=$$QMAKE_CXX -DBUILD_SSL=OFF \ + -DCMAKE_INSTALL_PREFIX=. -B. -H$$shell_path($${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} @@ -894,10 +900,11 @@ rs_jsonapi { jsonwrappersincl.target = $${WRAPPERS_INCL_FILE} jsonwrappersincl.commands = \ - cp $${DOXIGEN_CONFIG_SRC} $${DOXIGEN_CONFIG_OUT}; \ - echo OUTPUT_DIRECTORY=$$shell_path($${JSONAPI_GENERATOR_OUT}) >> $${DOXIGEN_CONFIG_OUT};\ - echo INPUT=$$shell_path($${DOXIGEN_INPUT_DIRECTORY}) >> $${DOXIGEN_CONFIG_OUT}; \ - doxygen $${DOXIGEN_CONFIG_OUT}; \ + mkdir -p $${JSONAPI_GENERATOR_OUT} && \ + cp $${DOXIGEN_CONFIG_SRC} $${DOXIGEN_CONFIG_OUT} && \ + echo OUTPUT_DIRECTORY=$$shell_path($${JSONAPI_GENERATOR_OUT}) >> $${DOXIGEN_CONFIG_OUT} && \ + echo INPUT=$$shell_path($${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 @@ -958,12 +965,9 @@ test_bitdht { ################################# Android ##################################### android-* { -## ifaddrs is missing on Android to add them don't use the one from -## https://github.com/morristech/android-ifaddrs -## because it crash, use QNetworkInterface from Qt instead - CONFIG *= qt - QT *= network - +## TODO: This probably disable largefile support and maybe is not necessary with +## __ANDROID_API__ >= 24 hence should be made conditional or moved to a +## compatibility header DEFINES *= "fopen64=fopen" DEFINES *= "fseeko64=fseeko" DEFINES *= "ftello64=ftello" diff --git a/libretroshare/src/pgp/rscertificate.cc b/libretroshare/src/pgp/rscertificate.cc index 4ead10c3e..a580f8fe8 100644 --- a/libretroshare/src/pgp/rscertificate.cc +++ b/libretroshare/src/pgp/rscertificate.cc @@ -30,6 +30,7 @@ #include #include "rscertificate.h" #include "util/rsstring.h" +#include "util/stacktrace.h" //#define DEBUG_RSCERTIFICATE @@ -88,6 +89,17 @@ void RsCertificate::addPacket(uint8_t ptag, const unsigned char *mem, size_t siz offset += size ; } +const RsCertificate&RsCertificate::operator=(const RsCertificate&) +{ + memset(ipv4_external_ip_and_port,0,6); + memset(ipv4_internal_ip_and_port,0,6); + binary_pgp_key = nullptr; + binary_pgp_key_size = 0; + only_pgp = false; + hidden_node = false; + return *this; +} + std::string RsCertificate::toStdString() const { //std::string res ; @@ -154,17 +166,21 @@ std::string RsCertificate::toStdString() const return out2 ; } -RsCertificate::RsCertificate(const std::string& str) - : - location_name(""), - pgp_version("Version: OpenPGP:SDK v0.9"), - dns_name(""),only_pgp(true) +RsCertificate::RsCertificate(const std::string& str) : + location_name(""), pgp_version("Version: OpenPGP:SDK v0.9"), + dns_name(""), only_pgp(true) { - uint32_t err_code ; - binary_pgp_key = NULL ; + uint32_t err_code; + binary_pgp_key = nullptr; - if(!initFromString(str,err_code)) - throw err_code ; + if(!initializeFromString(str, err_code)) + { + std::cerr << __PRETTY_FUNCTION__ << " is deprecated because it can " + << "miserably fail like this! str: " << str + << " err_code: " << err_code << std::endl; + print_stacktrace(); + throw err_code; + } } RsCertificate::RsCertificate(const RsPeerDetails& Detail, const unsigned char *binary_pgp_block,size_t binary_pgp_block_size) @@ -256,7 +272,7 @@ void RsCertificate::scan_ip(const std::string& ip_string, unsigned short port,un ip_and_port[5] = port & 0xff ; } -bool RsCertificate::initFromString(const std::string& instr,uint32_t& err_code) +bool RsCertificate::initializeFromString(const std::string& instr,uint32_t& err_code) { try { diff --git a/libretroshare/src/pgp/rscertificate.h b/libretroshare/src/pgp/rscertificate.h index b0fd70801..986f5922c 100644 --- a/libretroshare/src/pgp/rscertificate.h +++ b/libretroshare/src/pgp/rscertificate.h @@ -47,76 +47,98 @@ #include #include -class RsPeerDetails ; +struct RsPeerDetails; class RsCertificate { - public: - typedef enum { RS_CERTIFICATE_OLD_FORMAT, RS_CERTIFICATE_RADIX } Format ; +public: + typedef enum { RS_CERTIFICATE_OLD_FORMAT, RS_CERTIFICATE_RADIX } Format; - // Constructs from text. - // - new format: The input string should only contain radix chars and spaces/LF/tabs. - // - explicit RsCertificate(const std::string& input_string) ; + /** + * @brief Costruct an empty certificate, use toghether with + * if(initializeFromString) for safe certificate radix string parsing + */ + RsCertificate() : + ipv4_external_ip_and_port{0,0,0,0,0,0}, + ipv4_internal_ip_and_port{0,0,0,0,0,0}, + binary_pgp_key(nullptr), binary_pgp_key_size(0), + pgp_version("Version: OpenPGP:SDK v0.9"), only_pgp(true), + hidden_node(false) {} - // Constructs from binary gpg key, and RsPeerDetails. - // - RsCertificate(const RsPeerDetails& details,const unsigned char *gpg_mem_block,size_t gpg_mem_block_size) ; + /** + * @brief Initialize from certificate string + * @param[in] str radix format string + * @param[out] errCode storage for eventual error code + * @return false on failure, true otherwise + */ + bool initializeFromString(const std::string& str, uint32_t& errCode); - // Constructs + /// Constructs from binary gpg key, and RsPeerDetails. + RsCertificate( const RsPeerDetails& details, + const unsigned char *gpg_mem_block, + size_t gpg_mem_block_size ); - virtual ~RsCertificate(); + virtual ~RsCertificate(); - // Outut to text - std::string toStdString() const ; + /// Convert to certificate radix string + std::string toStdString() const; - std::string ext_ip_string() const ; - std::string loc_ip_string() const ; - std::string location_name_string() const { return location_name; } - std::string dns_string() const { return dns_name ; } - RsPeerId sslid() const { return location_id ; } - std::string hidden_node_string() const; + std::string ext_ip_string() const; + std::string loc_ip_string() const; + std::string location_name_string() const { return location_name; } + std::string dns_string() const { return dns_name ; } + RsPeerId sslid() const { return location_id ; } + std::string hidden_node_string() const; - std::string armouredPGPKey() const ; + std::string armouredPGPKey() const; - unsigned short ext_port_us() const ; - unsigned short loc_port_us() const ; + unsigned short ext_port_us() const; + unsigned short loc_port_us() const; - const unsigned char *pgp_key() const { return binary_pgp_key ; } - size_t pgp_key_size() const { return binary_pgp_key_size ; } + const unsigned char *pgp_key() const { return binary_pgp_key ; } + size_t pgp_key_size() const { return binary_pgp_key_size ; } - static bool cleanCertificate(const std::string& input, std::string& output, RsCertificate::Format& format, int& error_code, bool check_content) ; - const std::set& locators() const { return mLocators; } + static bool cleanCertificate( + const std::string& input, std::string& output, + RsCertificate::Format& format, int& error_code, bool check_content); - private: - static bool cleanCertificate(const std::string& input,std::string& output,int&) ; // new radix format - static void scan_ip(const std::string& ip_string, unsigned short port,unsigned char *destination_memory) ; + const std::set& locators() const { return mLocators; } - bool initFromString(const std::string& str,uint32_t& err_code) ; + /** + * @deprecated using this costructor may raise exception that cause + * crash if not handled, use empty constructor + if(initFromString) for a + * safer behaviour. + */ + RS_DEPRECATED explicit RsCertificate(const std::string& input_string); - static void addPacket(uint8_t ptag, const unsigned char *mem, size_t size, unsigned char *& buf, size_t& offset, size_t& buf_size) ; +private: + // new radix format + static bool cleanCertificate( const std::string& input, + std::string& output, int&); - RsCertificate(const RsCertificate&) {} // non copy-able - const RsCertificate& operator=(const RsCertificate&) - { memset(ipv4_external_ip_and_port,0,6); memset(ipv4_internal_ip_and_port,0,6); - binary_pgp_key = NULL; binary_pgp_key_size = 0; - only_pgp = false; hidden_node = false; - return *this ;} // non copy-able + static void scan_ip( const std::string& ip_string, unsigned short port, + unsigned char *destination_memory ); - unsigned char ipv4_external_ip_and_port[6] ; - unsigned char ipv4_internal_ip_and_port[6] ; + static void addPacket(uint8_t ptag, const unsigned char *mem, size_t size, + unsigned char*& buf, size_t& offset, size_t& buf_size); - unsigned char *binary_pgp_key ; - size_t binary_pgp_key_size ; + RsCertificate(const RsCertificate&) {} /// non copy-able + const RsCertificate& operator=(const RsCertificate&); /// non copy-able - std::string location_name ; - RsPeerId location_id ; - std::string pgp_version ; - std::string dns_name ; - std::string hidden_node_address; - std::set mLocators; + unsigned char ipv4_external_ip_and_port[6]; + unsigned char ipv4_internal_ip_and_port[6]; - bool only_pgp ; // does the cert contain only pgp info? - bool hidden_node; // IP or hidden Node Address. + unsigned char *binary_pgp_key; + size_t binary_pgp_key_size; + + std::string location_name; + RsPeerId location_id; + std::string pgp_version; + std::string dns_name; + std::string hidden_node_address; + std::set mLocators; + + bool only_pgp ; /// does the cert contain only pgp info? + bool hidden_node; /// IP or hidden Node Address. }; diff --git a/libretroshare/src/pqi/authgpg.h b/libretroshare/src/pqi/authgpg.h index 4d9f93ff2..11b7203dd 100644 --- a/libretroshare/src/pqi/authgpg.h +++ b/libretroshare/src/pqi/authgpg.h @@ -38,7 +38,7 @@ #define MAX_GPG_SIGNATURE_SIZE 4096 -class RsPeerDetails; +struct RsPeerDetails; /*! * gpgcert is the identifier for a person. diff --git a/libretroshare/src/pqi/p3linkmgr.h b/libretroshare/src/pqi/p3linkmgr.h index 33267d635..d10a3fbfe 100644 --- a/libretroshare/src/pqi/p3linkmgr.h +++ b/libretroshare/src/pqi/p3linkmgr.h @@ -129,7 +129,7 @@ class peerConnectState class p3tunnel; class RsPeerGroupItem_deprecated; -class RsGroupInfo; +struct RsGroupInfo; class p3PeerMgr; class p3NetMgr; diff --git a/libretroshare/src/pqi/p3peermgr.h b/libretroshare/src/pqi/p3peermgr.h index 36df3a629..781dd6115 100644 --- a/libretroshare/src/pqi/p3peermgr.h +++ b/libretroshare/src/pqi/p3peermgr.h @@ -103,7 +103,7 @@ class peerState }; class RsNodeGroupItem; -class RsGroupInfo; +struct RsGroupInfo; std::string textPeerState(peerState &state); diff --git a/libretroshare/src/pqi/pqi_base.h b/libretroshare/src/pqi/pqi_base.h index 0741df1c5..b7c2746d2 100644 --- a/libretroshare/src/pqi/pqi_base.h +++ b/libretroshare/src/pqi/pqi_base.h @@ -31,7 +31,7 @@ #include "pqi/pqinetwork.h" -class RSTrafficClue ; +struct RSTrafficClue; /*** Base DataTypes: ****/ #include "serialiser/rsserial.h" @@ -46,7 +46,7 @@ class RSTrafficClue ; int getPQIsearchId(); int fixme(char *str, int n); -class RsPeerCryptoParams ; +struct RsPeerCryptoParams; //! controlling data rates /*! diff --git a/libretroshare/src/pqi/pqihandler.h b/libretroshare/src/pqi/pqihandler.h index 31b51feed..d78c44752 100644 --- a/libretroshare/src/pqi/pqihandler.h +++ b/libretroshare/src/pqi/pqihandler.h @@ -32,7 +32,7 @@ #include "util/rsthreads.h" // for RsStackMutex, RsMutex class PQInterface; -class RSTrafficClue; +struct RSTrafficClue; class RsBwRates; struct RsItem; class RsRawItem; diff --git a/libretroshare/src/pqi/pqiperson.h b/libretroshare/src/pqi/pqiperson.h index efd57176d..759446def 100644 --- a/libretroshare/src/pqi/pqiperson.h +++ b/libretroshare/src/pqi/pqiperson.h @@ -30,7 +30,7 @@ #include class pqiperson; -class RsPeerCryptoParams ; +struct RsPeerCryptoParams; static const int CONNECT_RECEIVED = 1; static const int CONNECT_SUCCESS = 2; diff --git a/libretroshare/src/pqi/pqipersongrp.h b/libretroshare/src/pqi/pqipersongrp.h index 0afd00a78..5b57aebb1 100644 --- a/libretroshare/src/pqi/pqipersongrp.h +++ b/libretroshare/src/pqi/pqipersongrp.h @@ -40,7 +40,7 @@ const unsigned long PQIPERSON_NO_LISTENER = 0x0001; const unsigned long PQIPERSON_ALL_BW_LIMITED = 0x0010; -class RsPeerCryptoParams ; +struct RsPeerCryptoParams; class pqipersongrp: public pqihandler, public pqiMonitor, public p3ServiceServer, public pqiNetListener { diff --git a/libretroshare/src/pqi/pqissl.h b/libretroshare/src/pqi/pqissl.h index 4da1173b1..99408917c 100644 --- a/libretroshare/src/pqi/pqissl.h +++ b/libretroshare/src/pqi/pqissl.h @@ -76,7 +76,7 @@ class cert; class pqissllistener; class p3LinkMgr; -class RsPeerCryptoParams ; +struct RsPeerCryptoParams; class pqissl: public NetBinInterface { diff --git a/libretroshare/src/pqi/pqisslpersongrp.h b/libretroshare/src/pqi/pqisslpersongrp.h index aa574e617..ea94e616a 100644 --- a/libretroshare/src/pqi/pqisslpersongrp.h +++ b/libretroshare/src/pqi/pqisslpersongrp.h @@ -25,7 +25,7 @@ #include "pqi/pqipersongrp.h" class p3PeerMgr; -class RsPeerCryptoParams; +struct RsPeerCryptoParams; class pqissl ; class pqisslpersongrp: public pqipersongrp diff --git a/libretroshare/src/retroshare/rsfiles.h b/libretroshare/src/retroshare/rsfiles.h index 26aa8552c..811c172d5 100644 --- a/libretroshare/src/retroshare/rsfiles.h +++ b/libretroshare/src/retroshare/rsfiles.h @@ -26,6 +26,7 @@ #include #include #include +#include #include "rstypes.h" #include "serialiser/rsserializable.h" @@ -182,13 +183,22 @@ public: uint64_t mTotalSize ; }; -struct BannedFileEntry +struct BannedFileEntry : RsSerializable { - BannedFileEntry() : size(0),filename(""),ban_time_stamp(0) {} + BannedFileEntry() : mFilename(""), mSize(0), mBanTimeStamp(0) {} - uint64_t size ; - std::string filename ; - rstime_t ban_time_stamp; + std::string mFilename; + uint64_t mSize; + rstime_t mBanTimeStamp; + + /// @see RsSerializable::serial_process + virtual void serial_process(RsGenericSerializer::SerializeJob j, + RsGenericSerializer::SerializeContext& ctx) + { + RS_SERIAL_PROCESS(mFilename); + RS_SERIAL_PROCESS(mSize); + RS_SERIAL_PROCESS(mBanTimeStamp); + } }; class RsFiles @@ -415,13 +425,32 @@ public: virtual bool ExtraFileStatus(std::string localpath, FileInfo &info) = 0; virtual bool ExtraFileMove(std::string fname, const RsFileHash& hash, uint64_t size, std::string destpath) = 0; + /** + * @brief Request directory details, subsequent multiple call may be used to + * explore a whole directory tree. + * @jsonapi{development} + * @param[out] details Storage for directory details + * @param[in] handle element handle 0 for root, pass the content of + * DirDetails::child[x].ref after first call to explore deeper, be aware + * that is not a real pointer but an index used internally by RetroShare. + * @param[in] flags file search flags RS_FILE_HINTS_* + * @return false if error occurred, true otherwise + */ + virtual bool requestDirDetails( + DirDetails &details, std::uintptr_t handle = 0, + FileSearchFlags flags = RS_FILE_HINTS_LOCAL ) = 0; + /*** + * Directory Listing / Search Interface + */ + /** + * Kept for retrocompatibility, it was originally written for easier + * interaction with Qt. As soon as you can, you should prefer to use the + * version of this methodn which take `std::uintptr_t handle` as paramether. + */ + virtual int RequestDirDetails( + void* handle, DirDetails& details, FileSearchFlags flags ) = 0; - /*** - * Directory Listing / Search Interface - */ - virtual int RequestDirDetails(const RsPeerId& uid, const std::string& path, DirDetails &details) = 0; - virtual int RequestDirDetails(void *ref, DirDetails &details, FileSearchFlags flags) = 0; virtual bool findChildPointer(void *ref, int row, void *& result, FileSearchFlags flags) =0; virtual uint32_t getType(void *ref,FileSearchFlags flags) = 0; @@ -431,17 +460,54 @@ 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; + /** + * @brief Ban unwanted file from being, searched and forwarded by this node + * @jsonapi{development} + * @param[in] realFileHash this is what will really enforce banning + * @param[in] filename expected name of the file, for the user to read + * @param[in] fileSize expected file size, for the user to read + * @return meaningless value + */ + virtual int banFile( const RsFileHash& realFileHash, + const std::string& filename, uint64_t fileSize ) = 0; + + /** + * @brief Remove file from unwanted list + * @jsonapi{development} + * @param[in] realFileHash hash of the file + * @return meaningless value + */ + virtual int unbanFile(const RsFileHash& realFileHash) = 0; + + /** + * @brief Get list of banned files + * @jsonapi{development} + * @param[out] bannedFiles storage for banned files information + * @return meaningless value + */ + virtual bool getPrimaryBannedFilesList( + std::map& bannedFiles ) = 0; + + /** + * @brief Check if a file is on banned list + * @jsonapi{development} + * @param[in] hash hash of the file + * @return true if the hash is on the list, false otherwise + */ + virtual bool isHashBanned(const RsFileHash& hash) = 0; /*** * Utility Functions. ***/ virtual bool ConvertSharedFilePath(std::string path, std::string &fullpath) = 0; - virtual void ForceDirectoryCheck() = 0; - virtual void updateSinceGroupPermissionsChanged() = 0; + + /** + * @brief Force shared directories check + * @jsonapi{development} + */ + virtual void ForceDirectoryCheck() = 0; + + virtual void updateSinceGroupPermissionsChanged() = 0; virtual bool InDirectoryCheck() = 0; virtual bool copyFile(const std::string& source,const std::string& dest) = 0; diff --git a/libretroshare/src/retroshare/rsflags.h b/libretroshare/src/retroshare/rsflags.h index 548b1641b..f6c97de10 100644 --- a/libretroshare/src/retroshare/rsflags.h +++ b/libretroshare/src/retroshare/rsflags.h @@ -23,7 +23,7 @@ template class t_RsFlags32 { public: - inline t_RsFlags32() { _bits=0; } + inline t_RsFlags32() : _bits(0) {} inline explicit t_RsFlags32(uint32_t N) : _bits(N) {} // allows initialization from a set of uint32_t inline t_RsFlags32 operator| (const t_RsFlags32& f) const { return t_RsFlags32(_bits | f._bits) ; } diff --git a/libretroshare/src/retroshare/rsgxschannels.h b/libretroshare/src/retroshare/rsgxschannels.h index be78a8c80..cc95cf0bd 100644 --- a/libretroshare/src/retroshare/rsgxschannels.h +++ b/libretroshare/src/retroshare/rsgxschannels.h @@ -4,7 +4,7 @@ * * * libretroshare: retroshare core library * * * - * Copyright 2012-2012 by Robert Fernie * + * Copyright (C) 2012 Robert Fernie * * Copyright (C) 2018 Gioacchino Mazzurco * * * * This program is free software: you can redistribute it and/or modify * @@ -137,6 +137,23 @@ public: std::vector& posts, std::vector& comments ) = 0; + /** + * @brief Create channel. Blocking API. + * @jsonapi{development} + * @param[inout] channel Channel data (name, description...) + * @return false on error, true otherwise + */ + virtual bool createChannel(RsGxsChannelGroup& channel) = 0; + + /** + * @brief Create channel post. Blocking API. + * @jsonapi{development} + * @param[inout] post + * @return false on error, true otherwise + */ + virtual bool createPost(RsGxsChannelPost& post) = 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 @@ -225,7 +242,6 @@ public: * @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...) @@ -237,7 +253,6 @@ public: * @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 diff --git a/libretroshare/src/retroshare/rsiface.h b/libretroshare/src/retroshare/rsiface.h index 83eda2eae..1f9041d3e 100644 --- a/libretroshare/src/retroshare/rsiface.h +++ b/libretroshare/src/retroshare/rsiface.h @@ -29,7 +29,7 @@ class RsServer; class RsInit; -class RsPeerCryptoParams; +struct RsPeerCryptoParams; class RsControl; /// RsInit -> Configuration Parameters for RetroShare Startup diff --git a/libretroshare/src/retroshare/rsnotify.h b/libretroshare/src/retroshare/rsnotify.h index cf7777e9e..d2077e7f0 100644 --- a/libretroshare/src/retroshare/rsnotify.h +++ b/libretroshare/src/retroshare/rsnotify.h @@ -33,7 +33,7 @@ class ChatId; class ChatMessage; -class RsGxsChanges; +struct RsGxsChanges; class RsNotify; extern RsNotify *rsNotify; diff --git a/libretroshare/src/retroshare/rspeers.h b/libretroshare/src/retroshare/rspeers.h index 91053941d..64050a31f 100644 --- a/libretroshare/src/retroshare/rspeers.h +++ b/libretroshare/src/retroshare/rspeers.h @@ -528,13 +528,15 @@ public: /** * @brief Get RetroShare invite of the given peer * @jsonapi{development} - * @param[in] sslId Id of the peer of which we want to generate an invite + * @param[in] sslId Id of the peer of which we want to generate an invite, + * a null id (all 0) is passed, an invite for own node is returned. * @param[in] includeSignatures true to add key signatures to the invite * @param[in] includeExtraLocators false to avoid to add extra locators * @return invite string */ virtual std::string GetRetroshareInvite( - const RsPeerId& sslId, bool includeSignatures = false, + const RsPeerId& sslId = RsPeerId(), + bool includeSignatures = false, bool includeExtraLocators = true ) = 0; /** @@ -548,15 +550,6 @@ public: const std::string& invite, ServicePermissionFlags flags = RS_NODE_PERM_DEFAULT ) = 0; - /** - * @brief Get RetroShare invite of our own peer - * @param[in] includeSignatures true to add key signatures to the invite - * @param[in] includeExtraLocators false to avoid to add extra locators - * @return invite string - */ - virtual std::string GetRetroshareInvite( - bool includeSignatures = false, - bool includeExtraLocators = true ) = 0; /* Auth Stuff */ virtual std::string getPGPKey(const RsPgpId& pgp_id,bool include_signatures) = 0; diff --git a/libretroshare/src/retroshare/rsplugin.h b/libretroshare/src/retroshare/rsplugin.h index c8d3364ff..49ad98f0b 100644 --- a/libretroshare/src/retroshare/rsplugin.h +++ b/libretroshare/src/retroshare/rsplugin.h @@ -65,7 +65,7 @@ class ToasterNotify; class ChatWidget; class ChatWidgetHolder; // for gxs based plugins -class RsIdentity; +struct RsIdentity; class RsNxsNetMgr; class RsGxsIdExchange; class RsGcxs; diff --git a/libretroshare/src/retroshare/rstypes.h b/libretroshare/src/retroshare/rstypes.h index e7bed4d21..137939fc8 100644 --- a/libretroshare/src/retroshare/rstypes.h +++ b/libretroshare/src/retroshare/rstypes.h @@ -259,21 +259,49 @@ struct FileInfo : RsSerializable std::ostream &operator<<(std::ostream &out, const FileInfo& info); -class DirStub +/** + * Pointers in this class have no real meaning as pointers, they are used as + * indexes, internally by retroshare. + */ +struct DirStub : RsSerializable { - public: + DirStub() : type(DIR_TYPE_UNKNOWN), ref(nullptr) {} + uint8_t type; std::string name; void *ref; + + /// @see RsSerializable + void serial_process(RsGenericSerializer::SerializeJob j, + RsGenericSerializer::SerializeContext& ctx) + { + RS_SERIAL_PROCESS(type); + RS_SERIAL_PROCESS(name); +#if defined(__GNUC__) && !defined(__clang__) +# pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif // defined(__GNUC__) && !defined(__clang__) + std::uintptr_t& handle(reinterpret_cast(ref)); + RS_SERIAL_PROCESS(handle); +#if defined(__GNUC__) && !defined(__clang__) +# pragma GCC diagnostic pop +#endif // defined(__GNUC__) && !defined(__clang__) + } }; -class DirDetails +/** + * Pointers in this class have no real meaning as pointers, they are used as + * indexes, internally by retroshare. + */ +struct DirDetails : RsSerializable { -public: - void *parent; - int prow; /* parent row */ + DirDetails() : parent(nullptr), prow(0), ref(nullptr), + type(DIR_TYPE_UNKNOWN), count(0), mtime(0), max_mtime(0) {} - void *ref; + + void* parent; + int prow; /* parent row */ + + void* ref; uint8_t type; RsPeerId id; std::string name; @@ -286,6 +314,34 @@ public: std::vector children; std::list parent_groups; // parent groups for the shared directory + + /// @see RsSerializable + void serial_process(RsGenericSerializer::SerializeJob j, + RsGenericSerializer::SerializeContext& ctx) + { +#if defined(__GNUC__) && !defined(__clang__) +# pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif // defined(__GNUC__) && !defined(__clang__) + std::uintptr_t& handle(reinterpret_cast(ref)); + RS_SERIAL_PROCESS(handle); + std::uintptr_t& parentHandle(reinterpret_cast(parent)); + RS_SERIAL_PROCESS(parentHandle); +#if defined(__GNUC__) && !defined(__clang__) +# pragma GCC diagnostic pop +#endif // defined(__GNUC__) && !defined(__clang__) + RS_SERIAL_PROCESS(prow); + RS_SERIAL_PROCESS(type); + RS_SERIAL_PROCESS(id); + RS_SERIAL_PROCESS(name); + RS_SERIAL_PROCESS(hash); + RS_SERIAL_PROCESS(path); + RS_SERIAL_PROCESS(count); + RS_SERIAL_PROCESS(mtime); + RS_SERIAL_PROCESS(flags); + RS_SERIAL_PROCESS(max_mtime); + RS_SERIAL_PROCESS(children); + RS_SERIAL_PROCESS(parent_groups); + } }; std::ostream &operator<<(std::ostream &out, const DirDetails& details); diff --git a/libretroshare/src/rsitems/rsconfigitems.h b/libretroshare/src/rsitems/rsconfigitems.h index 376bebb78..4bb41150c 100644 --- a/libretroshare/src/rsitems/rsconfigitems.h +++ b/libretroshare/src/rsitems/rsconfigitems.h @@ -37,7 +37,7 @@ #include "serialiser/rsserializer.h" -class RsGroupInfo; +struct RsGroupInfo; const uint8_t RS_PKT_TYPE_GENERAL_CONFIG = 0x01; const uint8_t RS_PKT_TYPE_PEER_CONFIG = 0x02; diff --git a/libretroshare/src/rsserver/p3peers.cc b/libretroshare/src/rsserver/p3peers.cc index d2493d49a..8c9c29c8a 100644 --- a/libretroshare/src/rsserver/p3peers.cc +++ b/libretroshare/src/rsserver/p3peers.cc @@ -1054,12 +1054,7 @@ bool p3Peers::setProxyServer(const uint32_t type, const std::string &addr_str, c //=========================================================================== /* Auth Stuff */ -std::string p3Peers::GetRetroshareInvite( - bool include_signatures, bool includeExtraLocators ) -{ - return GetRetroshareInvite( - getOwnId(), include_signatures, includeExtraLocators ); -} + std::string p3Peers::getPGPKey(const RsPgpId& pgp_id,bool include_signatures) { unsigned char *mem_block = NULL; @@ -1176,12 +1171,13 @@ bool p3Peers::acceptInvite( const std::string& invite, } std::string p3Peers::GetRetroshareInvite( - const RsPeerId& ssl_id, bool include_signatures, + const RsPeerId& sslId, bool include_signatures, bool includeExtraLocators ) { #ifdef P3PEERS_DEBUG std::cerr << __PRETTY_FUNCTION__ << std::endl; #endif + const RsPeerId& ssl_id(sslId.isNull() ? getOwnId() : sslId); //add the sslid, location, ip local and external address after the signature RsPeerDetails detail; @@ -1217,17 +1213,27 @@ std::string p3Peers::GetRetroshareInvite( //=========================================================================== -bool p3Peers::loadCertificateFromString(const std::string& cert, RsPeerId& ssl_id, RsPgpId& gpg_id, std::string& error_string) +bool p3Peers::loadCertificateFromString( + const std::string& cert, RsPeerId& ssl_id, + RsPgpId& gpg_id, std::string& error_string ) { - RsCertificate crt(cert) ; - RsPgpId gpgid ; + RsCertificate crt; + uint32_t errNum = 0; + if(!crt.initializeFromString(cert,errNum)) + { + error_string = "RsCertificate failed with errno: " + + std::to_string(errNum) + " parsing: " + cert; + return false; + } - bool res = AuthGPG::getAuthGPG()->LoadCertificateFromString(crt.armouredPGPKey(),gpgid,error_string) ; + RsPgpId gpgid; + bool res = AuthGPG::getAuthGPG()-> + LoadCertificateFromString(crt.armouredPGPKey(), gpgid,error_string); gpg_id = gpgid; - ssl_id = crt.sslid() ; + ssl_id = crt.sslid(); - return res ; + return res; } bool p3Peers::loadDetailsFromStringCert( const std::string &certstr, diff --git a/libretroshare/src/rsserver/p3peers.h b/libretroshare/src/rsserver/p3peers.h index 3b96ab380..f5f61a43e 100644 --- a/libretroshare/src/rsserver/p3peers.h +++ b/libretroshare/src/rsserver/p3peers.h @@ -117,14 +117,10 @@ public: /* Auth Stuff */ // Get the invitation (GPG cert + local/ext address + SSL id for the given peer) virtual std::string GetRetroshareInvite( - const RsPeerId& ssl_id, bool include_signatures = false, - bool includeExtraLocators = true ); + const RsPeerId& ssl_id = RsPeerId(), + bool include_signatures = false, bool includeExtraLocators = true ); virtual std::string getPGPKey(const RsPgpId& pgp_id,bool include_signatures); - // same but for own id - virtual std::string GetRetroshareInvite( - bool include_signatures = false, - bool includeExtraLocators = true ); virtual bool GetPGPBase64StringAndCheckSum(const RsPgpId& gpg_id,std::string& gpg_base64_string,std::string& gpg_base64_checksum); /// @see RsPeers::acceptInvite diff --git a/libretroshare/src/rsserver/rsaccounts.cc b/libretroshare/src/rsserver/rsaccounts.cc index 557981dcc..17ab2d8cc 100644 --- a/libretroshare/src/rsserver/rsaccounts.cc +++ b/libretroshare/src/rsserver/rsaccounts.cc @@ -811,7 +811,7 @@ static bool checkAccount(const std::string &accountdir, AccountDetails &account, /* Use RetroShare's exe dir */ dataDirectory = "."; #elif defined(ANDROID) - dataDirectory = defaultBaseDirectory()+"/usr/share/retroshare"; + dataDirectory = PathBaseDirectory()+"/usr/share/retroshare"; #elif defined(DATA_DIR) // cppcheck-suppress ConfigurationNotChecked dataDirectory = DATA_DIR; diff --git a/libretroshare/src/serialiser/rstypeserializer.h b/libretroshare/src/serialiser/rstypeserializer.h index a71a8468c..be46adf01 100644 --- a/libretroshare/src/serialiser/rstypeserializer.h +++ b/libretroshare/src/serialiser/rstypeserializer.h @@ -655,11 +655,11 @@ struct RsTypeSerializer break; case RsGenericSerializer::FROM_JSON: { - uint32_t f; + uint32_t f = 0; ctx.mOk &= (ctx.mOk || ctx.mFlags & RsGenericSerializer::SERIALIZATION_FLAG_YIELDING) - && from_JSON(memberName, f, ctx.mJson); - v = t_RsFlags32(f); + && from_JSON(memberName, f, ctx.mJson) + && (v = t_RsFlags32(f), true); break; } default: break; diff --git a/libretroshare/src/services/p3gxschannels.cc b/libretroshare/src/services/p3gxschannels.cc index ba111ddb4..f939ccee0 100644 --- a/libretroshare/src/services/p3gxschannels.cc +++ b/libretroshare/src/services/p3gxschannels.cc @@ -3,7 +3,8 @@ * * * libretroshare: retroshare core library * * * - * Copyright 2012-2012 Robert Fernie * + * 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 * @@ -34,17 +35,22 @@ #include "rsserver/p3face.h" #include "retroshare/rsnotify.h" -#include +#include // For Dummy Msgs. #include "util/rsrandom.h" #include "util/rsstring.h" +#ifdef RS_DEEP_SEARCH +# include "deep_search/deep_search.h" +#endif // RS_DEEP_SEARCH + + /**** * #define GXSCHANNEL_DEBUG 1 ****/ -RsGxsChannels *rsGxsChannels = NULL; +/*extern*/ RsGxsChannels *rsGxsChannels = nullptr; #define GXSCHANNEL_STOREPERIOD (3600 * 24 * 30) @@ -1036,6 +1042,108 @@ bool p3GxsChannels::getChannelsContent( return getPostData(token, posts, comments); } +bool p3GxsChannels::createChannel(RsGxsChannelGroup& channel) +{ + uint32_t token; + time_t beginCreation = time(nullptr); + if( !createGroup(token, channel) + || waitToken(token) != RsTokenService::COMPLETE ) + return false; + time_t endCreation = time(nullptr); + + std::list channels; + if(!getChannelsSummaries(channels)) return false; + + /* This is ugly but after digging and doing many tries of doing it the right + * way ending always into too big refactor chain reaction, I think this is + * not that bad, moreover seems the last created group tend to end up near + * the beginning of the list so it is fast founding it. + * The shortcoming of this is that if groups with same data are created in + * a burst (more then once in a second) is that the id of another similar + * group can be returned, but this is a pointy case. + * Order of conditions in the `if` matter for performances */ + bool found = false; + for(const RsGroupMetaData& chan : channels) + { + if( IS_GROUP_ADMIN(chan.mSubscribeFlags) + && IS_GROUP_SUBSCRIBED(chan.mSubscribeFlags) + && chan.mPublishTs >= beginCreation + && chan.mPublishTs <= endCreation + && chan.mGroupFlags == channel.mMeta.mGroupFlags + && chan.mSignFlags == channel.mMeta.mSignFlags + && chan.mCircleType == channel.mMeta.mCircleType + && chan.mAuthorId == channel.mMeta.mAuthorId + && chan.mCircleId == channel.mMeta.mCircleId + && chan.mServiceString == channel.mMeta.mServiceString + && chan.mGroupName == channel.mMeta.mGroupName ) + { + channel.mMeta = chan; + found = true; + break; + } + } + +#ifdef RS_DEEP_SEARCH + if(found) DeepSearch::indexChannelGroup(channel); +#endif // RS_DEEP_SEARCH + + return found; +} + +bool p3GxsChannels::createPost(RsGxsChannelPost& post) +{ + uint32_t token; + time_t beginCreation = time(nullptr); + if( !createPost(token, post) + || waitToken(token) != RsTokenService::COMPLETE ) return false; + time_t endCreation = time(nullptr); + + std::list chanIds; chanIds.push_back(post.mMeta.mGroupId); + std::vector posts; + std::vector comments; + if(!getChannelsContent(chanIds, posts, comments)) return false; + + /* This is ugly but after digging and doing many tries of doing it the right + * way ending always into too big refactor chain reaction, I think this is + * not that bad. + * The shortcoming of this is that if posts with same data are created in + * a burst (more then once in a second) is that the id of another similar + * post could be returned, but this is a pointy case. + * Order of conditions in the `if` matter for performances */ + bool found = false; + for(const RsGxsChannelPost& itPost : posts) + { + std::cout << __PRETTY_FUNCTION__ << " " << beginCreation << " " + << itPost.mMeta.mPublishTs << " " << endCreation << " " + << itPost.mMeta.mMsgId << std::endl; + + if( itPost.mMeta.mPublishTs >= beginCreation + && itPost.mMeta.mPublishTs <= endCreation + && itPost.mMeta.mMsgFlags == post.mMeta.mMsgFlags + && itPost.mMeta.mGroupId == post.mMeta.mGroupId + && itPost.mMeta.mThreadId == post.mMeta.mThreadId + && itPost.mMeta.mParentId == post.mMeta.mParentId + && itPost.mMeta.mAuthorId == post.mMeta.mAuthorId + && itPost.mMeta.mMsgName == post.mMeta.mMsgName + && itPost.mFiles.size() == post.mFiles.size() + && itPost.mMeta.mServiceString == post.mMeta.mServiceString + && itPost.mOlderVersions == post.mOlderVersions + && itPost.mMsg == post.mMsg ) + { + post = itPost; + found = true; + break; + } + } + +#ifdef RS_DEEP_SEARCH + if(found) DeepSearch::indexChannelPost(post); +#endif // RS_DEEP_SEARCH + + return found; +} + + //////////////////////////////////////////////////////////////////////////////// /// Blocking API implementation end //////////////////////////////////////////////////////////////////////////////// diff --git a/libretroshare/src/services/p3gxschannels.h b/libretroshare/src/services/p3gxschannels.h index d4c85d9bf..bdb8123dc 100644 --- a/libretroshare/src/services/p3gxschannels.h +++ b/libretroshare/src/services/p3gxschannels.h @@ -3,7 +3,8 @@ * * * libretroshare: retroshare core library * * * - * Copyright 2012-2012 Robert Fernie * + * 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 * @@ -33,10 +34,6 @@ #include #include -/* - * - */ - class SSGxsChannelGroup { @@ -182,6 +179,12 @@ virtual bool ExtraFileRemove(const RsFileHash &hash); std::vector& posts, std::vector& comments ); + /// Implementation of @see RsGxsChannels::createChannel + virtual bool createChannel(RsGxsChannelGroup& channel); + + /// Implementation of @see RsGxsChannels::createPost + virtual bool createPost(RsGxsChannelPost& post); + protected: // Overloaded from GxsTokenQueue for Request callbacks. virtual void handleResponse(uint32_t token, uint32_t req_type); diff --git a/libretroshare/src/use_libretroshare.pri b/libretroshare/src/use_libretroshare.pri index 8129f8132..79b83ad8c 100644 --- a/libretroshare/src/use_libretroshare.pri +++ b/libretroshare/src/use_libretroshare.pri @@ -50,16 +50,17 @@ dLibs = rs_jsonapi { RS_SRC_PATH=$$clean_path($${PWD}/../../) RS_BUILD_PATH=$$clean_path($${OUT_PWD}/../../) - RESTBED_SRC_PATH=$$clean_path($${RS_SRC_PATH}/supportlibs/restbed) - RESTBED_BUILD_PATH=$$clean_path($${RS_BUILD_PATH}/supportlibs/restbed) - INCLUDEPATH *= $$clean_path($${RESTBED_BUILD_PATH}/include/) - QMAKE_LIBDIR *= $$clean_path($${RESTBED_BUILD_PATH}/library/) - # Using sLibs would fail as librestbed.a is generated at compile-time - LIBS *= -L$$clean_path($${RESTBED_BUILD_PATH}/library/) -lrestbed - win32-g++ { - LIBS += -lwsock32 - } + no_rs_cross_compiling { + RESTBED_SRC_PATH=$$clean_path($${RS_SRC_PATH}/supportlibs/restbed) + RESTBED_BUILD_PATH=$$clean_path($${RS_BUILD_PATH}/supportlibs/restbed) + INCLUDEPATH *= $$clean_path($${RESTBED_BUILD_PATH}/include/) + QMAKE_LIBDIR *= $$clean_path($${RESTBED_BUILD_PATH}/library/) + # Using sLibs would fail as librestbed.a is generated at compile-time + LIBS *= -L$$clean_path($${RESTBED_BUILD_PATH}/library/) -lrestbed + } else:sLibs *= restbed + + win32-g++:dLibs *= wsock32 } linux-* { @@ -81,3 +82,11 @@ LIBS += $$linkStaticLibs(sLibs) PRE_TARGETDEPS += $$pretargetStaticLibs(sLibs) LIBS += $$linkDynamicLibs(dLibs) + +android-* { +## ifaddrs is missing on Android to add them don't use the one from +## https://github.com/morristech/android-ifaddrs +## because it crash, use QNetworkInterface from Qt instead + CONFIG *= qt + QT *= network +} diff --git a/libretroshare/src/util/cxx11retrocompat.h b/libretroshare/src/util/cxx11retrocompat.h index 98dd998db..f210cf87b 100644 --- a/libretroshare/src/util/cxx11retrocompat.h +++ b/libretroshare/src/util/cxx11retrocompat.h @@ -21,7 +21,7 @@ *******************************************************************************/ #pragma once -#ifdef __GNUC__ +#if defined(__GNUC__) && !defined(__clang__) # define GCC_VERSION (__GNUC__*10000+__GNUC_MINOR__*100+__GNUC_PATCHLEVEL__) # if GCC_VERSION < 40700 # define override @@ -30,4 +30,4 @@ # if GCC_VERSION < 40600 # define nullptr NULL # endif // GCC_VERSION < 40600 -#endif //defined GNUC +#endif // defined(__GNUC__) && !defined(__clang__) diff --git a/libretroshare/src/util/rsurl.cc b/libretroshare/src/util/rsurl.cc index efaab9777..3775f8436 100644 --- a/libretroshare/src/util/rsurl.cc +++ b/libretroshare/src/util/rsurl.cc @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -//#include "util/rsurl.h" + #include "rsurl.h" #include @@ -245,7 +245,7 @@ RsUrl& RsUrl::setFragment(const std::string& fragment) if(str[i] == '%' && i < boundary) { - decoded << static_cast(stoi(str.substr(++i, 2), 0, 16)); + decoded << static_cast(std::stoi(str.substr(++i, 2), 0, 16)); ++i; } else decoded << str[i]; diff --git a/retroshare-gui/src/gui/FileTransfer/BannedFilesDialog.cpp b/retroshare-gui/src/gui/FileTransfer/BannedFilesDialog.cpp index ccaa456f1..d304ce5c3 100644 --- a/retroshare-gui/src/gui/FileTransfer/BannedFilesDialog.cpp +++ b/retroshare-gui/src/gui/FileTransfer/BannedFilesDialog.cpp @@ -77,10 +77,10 @@ void BannedFilesDialog::fillFilesList() 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_NAME, new QTableWidgetItem(QIcon(),QString::fromUtf8(it->second.mFilename.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->setItem(row, COLUMN_FILE_SIZE, new QTableWidgetItem(QIcon(),QString::number(it->second.mSize),0)); + ui.bannedFiles_TW->setItem(row, COLUMN_FILE_TIME, new QTableWidgetItem(QIcon(),QDateTime::fromTime_t(it->second.mBanTimeStamp).toString(),0)); ui.bannedFiles_TW->item(row, COLUMN_FILE_HASH)->setData(Qt::UserRole, QString::fromStdString(it->first.toStdString())); diff --git a/retroshare-gui/src/gui/GetStartedDialog.cpp b/retroshare-gui/src/gui/GetStartedDialog.cpp index de2c0b523..be6a86fbb 100644 --- a/retroshare-gui/src/gui/GetStartedDialog.cpp +++ b/retroshare-gui/src/gui/GetStartedDialog.cpp @@ -33,9 +33,9 @@ #include #define URL_FAQ "http://retroshare.sourceforge.net/wiki/index.php/Frequently_Asked_Questions" -#define URL_FORUM "http://retroshare.sourceforge.net/forum/" -#define URL_WEBSITE "http://retroshare.org" -#define URL_DOWNLOAD "http://retroshare.sourceforge.net/downloads.html" +#define URL_FORUM "https://github.com/RetroShare/RetroShare/issues" +#define URL_WEBSITE "http://retroshare.net" +#define URL_DOWNLOAD "http://retroshare.net/downloads.html" #define EMAIL_SUBSCRIBE "lists@retroshare.org" @@ -236,7 +236,7 @@ void GetStartedDialog::inviteFriends() { RsAutoUpdatePage::lockAllEvents(); - cert = rsPeers->GetRetroshareInvite(false); + cert = rsPeers->GetRetroshareInvite(); RsAutoUpdatePage::unlockAllEvents() ; } diff --git a/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp b/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp index 2d994917c..71f2fe5b3 100755 --- a/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp +++ b/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp @@ -127,7 +127,7 @@ ConnectFriendWizard::ConnectFriendWizard(QWidget *parent) : body = GetStartedDialog::GetInviteText(); body += "\n" + GetStartedDialog::GetCutBelowText(); - body += "\n\n" + QString::fromUtf8(rsPeers->GetRetroshareInvite(false).c_str()); + body += "\n\n" + QString::fromUtf8(rsPeers->GetRetroshareInvite().c_str()); std::string advsetting; if(rsConfig->getConfigurationOption(RS_CONFIG_ADVANCED, advsetting) && (advsetting == "YES")) @@ -436,7 +436,7 @@ void ConnectFriendWizard::initializePage(int id) QString body = ui->inviteTextEdit->toPlainText(); body += "\n" + GetStartedDialog::GetCutBelowText(); - body += "\n\n" + QString::fromUtf8(rsPeers->GetRetroshareInvite(false).c_str()); + body += "\n\n" + QString::fromUtf8(rsPeers->GetRetroshareInvite().c_str()); ui->inviteTextEdit->setPlainText(body); } @@ -797,7 +797,7 @@ bool ConnectFriendWizard::validateCurrentPage() QString body = ui->inviteTextEdit->toPlainText(); body += "\n" + GetStartedDialog::GetCutBelowText(); - body += "\n\n" + QString::fromUtf8(rsPeers->GetRetroshareInvite(false).c_str()); + body += "\n\n" + QString::fromUtf8(rsPeers->GetRetroshareInvite().c_str()); sendMail (mailaddresses, ui->subjectEdit->text(), body); } @@ -998,7 +998,8 @@ void ConnectFriendWizard::accept() void ConnectFriendWizard::updateOwnCert() { - std::string invite = rsPeers->GetRetroshareInvite(ui->userCertIncludeSignaturesButton->isChecked()); + std::string invite = rsPeers->GetRetroshareInvite( rsPeers->getOwnId(), + ui->userCertIncludeSignaturesButton->isChecked() ); std::cerr << "TextPage() getting Invite: " << invite << std::endl; @@ -1174,7 +1175,7 @@ void ConnectFriendWizard::generateCertificateCalled() std::cerr << " generateCertificateCalled" << std::endl; #endif - std::string cert = rsPeers->GetRetroshareInvite(false); + std::string cert = rsPeers->GetRetroshareInvite(); if (cert.empty()) { QMessageBox::information(this, "RetroShare", tr("Sorry, create certificate failed"), QMessageBox::Ok, QMessageBox::Ok); return; diff --git a/retroshare-gui/src/gui/profile/ProfileWidget.cpp b/retroshare-gui/src/gui/profile/ProfileWidget.cpp index cf238c7c0..81a86bc69 100644 --- a/retroshare-gui/src/gui/profile/ProfileWidget.cpp +++ b/retroshare-gui/src/gui/profile/ProfileWidget.cpp @@ -92,7 +92,7 @@ void ProfileWidget::statusmessagedlg() void ProfileWidget::copyCert() { - std::string cert = rsPeers->GetRetroshareInvite(false); + std::string cert = rsPeers->GetRetroshareInvite(); if (cert.empty()) { QMessageBox::information(this, tr("RetroShare"), tr("Sorry, create certificate failed"), diff --git a/retroshare-gui/src/gui/settings/CryptoPage.cpp b/retroshare-gui/src/gui/settings/CryptoPage.cpp index 4abe567c7..15419369b 100755 --- a/retroshare-gui/src/gui/settings/CryptoPage.cpp +++ b/retroshare-gui/src/gui/settings/CryptoPage.cpp @@ -96,8 +96,11 @@ CryptoPage::~CryptoPage() void CryptoPage::load() { - /* Loads ouer default Puplickey */ - ui.certplainTextEdit->setPlainText(QString::fromUtf8(rsPeers->GetRetroshareInvite(ui._includeSignatures_CB->isChecked()).c_str())); + ui.certplainTextEdit->setPlainText( + QString::fromUtf8( + rsPeers->GetRetroshareInvite( + rsPeers->getOwnId(), + ui._includeSignatures_CB->isChecked() ).c_str() ) ); } void CryptoPage::copyRSLink() diff --git a/retroshare-service/data/retroshare-service.desktop b/retroshare-service/data/retroshare-service.desktop new file mode 100644 index 000000000..5d077597b --- /dev/null +++ b/retroshare-service/data/retroshare-service.desktop @@ -0,0 +1,10 @@ +[Desktop Entry] +Encoding=UTF-8 +Version=1.0 +Name=RetroShare System Service +Comment=Securely share files with your friends (system service) +Exec=retroshare-service %U +Icon=retroshare-service +Terminal=false +Type=Application +Categories=Application;Network; diff --git a/retroshare-service/data/retroshare-service.svg b/retroshare-service/data/retroshare-service.svg new file mode 100644 index 000000000..74e38942a --- /dev/null +++ b/retroshare-service/data/retroshare-service.svg @@ -0,0 +1,188 @@ + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/retroshare-service/data/retroshare-service_128x128.png b/retroshare-service/data/retroshare-service_128x128.png new file mode 100644 index 000000000..84ef9e84b Binary files /dev/null and b/retroshare-service/data/retroshare-service_128x128.png differ diff --git a/retroshare-service/data/retroshare-service_48x48.png b/retroshare-service/data/retroshare-service_48x48.png new file mode 100644 index 000000000..4e35944fc Binary files /dev/null and b/retroshare-service/data/retroshare-service_48x48.png differ diff --git a/retroshare-service/src/android/.gitignore b/retroshare-service/src/android/.gitignore new file mode 100644 index 000000000..dfe00b261 --- /dev/null +++ b/retroshare-service/src/android/.gitignore @@ -0,0 +1,3 @@ +*~ +gradle.properties +local.properties diff --git a/retroshare-service/src/android/AndroidManifest.xml b/retroshare-service/src/android/AndroidManifest.xml new file mode 100644 index 000000000..7a3930f89 --- /dev/null +++ b/retroshare-service/src/android/AndroidManifest.xml @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/retroshare-service/src/android/build.gradle b/retroshare-service/src/android/build.gradle new file mode 100644 index 000000000..8affd3c0b --- /dev/null +++ b/retroshare-service/src/android/build.gradle @@ -0,0 +1,57 @@ +buildscript { + repositories { + google() + jcenter() + } + + dependencies { + classpath 'com.android.tools.build:gradle:3.0.1' + } +} + +repositories { + google() + jcenter() +} + +apply plugin: 'com.android.application' + +dependencies { + compile fileTree(dir: 'libs', include: ['*.jar']) +} + +android { + /******************************************************* + * The following variables: + * - androidBuildToolsVersion, + * - androidCompileSdkVersion + * - qt5AndroidDir - holds the path to qt android files + * needed to build any Qt application + * on Android. + * + * are defined in gradle.properties file. This file is + * updated by QtCreator and androiddeployqt tools. + * Changing them manually might break the compilation! + *******************************************************/ + + compileSdkVersion androidCompileSdkVersion.toInteger() + + buildToolsVersion androidBuildToolsVersion + + sourceSets { + main { + manifest.srcFile 'AndroidManifest.xml' + java.srcDirs = [qt5AndroidDir + '/src', 'src', 'java'] + aidl.srcDirs = [qt5AndroidDir + '/src', 'src', 'aidl'] + res.srcDirs = [qt5AndroidDir + '/res', 'res'] + resources.srcDirs = ['src'] + renderscript.srcDirs = ['src'] + assets.srcDirs = ['assets'] + jniLibs.srcDirs = ['libs'] + } + } + + lintOptions { + abortOnError false + } +} diff --git a/retroshare-service/src/android/gradle/wrapper/gradle-wrapper.jar b/retroshare-service/src/android/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 000000000..f6b961fd5 Binary files /dev/null and b/retroshare-service/src/android/gradle/wrapper/gradle-wrapper.jar differ diff --git a/retroshare-service/src/android/gradle/wrapper/gradle-wrapper.properties b/retroshare-service/src/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 000000000..bf3de2183 --- /dev/null +++ b/retroshare-service/src/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/retroshare-service/src/android/gradlew b/retroshare-service/src/android/gradlew new file mode 100755 index 000000000..cccdd3d51 --- /dev/null +++ b/retroshare-service/src/android/gradlew @@ -0,0 +1,172 @@ +#!/usr/bin/env sh + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi + +exec "$JAVACMD" "$@" diff --git a/retroshare-service/src/android/gradlew.bat b/retroshare-service/src/android/gradlew.bat new file mode 100644 index 000000000..f9553162f --- /dev/null +++ b/retroshare-service/src/android/gradlew.bat @@ -0,0 +1,84 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/retroshare-service/src/android/res/drawable/retroshare_service_128x128.png b/retroshare-service/src/android/res/drawable/retroshare_service_128x128.png new file mode 120000 index 000000000..5fc093940 --- /dev/null +++ b/retroshare-service/src/android/res/drawable/retroshare_service_128x128.png @@ -0,0 +1 @@ +../../../../data/retroshare-service_128x128.png \ No newline at end of file diff --git a/retroshare-service/src/android/res/drawable/retroshare_service_48x48.png b/retroshare-service/src/android/res/drawable/retroshare_service_48x48.png new file mode 120000 index 000000000..a05dabbff --- /dev/null +++ b/retroshare-service/src/android/res/drawable/retroshare_service_48x48.png @@ -0,0 +1 @@ +../../../../data/retroshare-service_48x48.png \ No newline at end of file diff --git a/retroshare-service/src/android/res/layout/retroshare_service_control_layout.xml b/retroshare-service/src/android/res/layout/retroshare_service_control_layout.xml new file mode 100644 index 000000000..a2a84fda8 --- /dev/null +++ b/retroshare-service/src/android/res/layout/retroshare_service_control_layout.xml @@ -0,0 +1,11 @@ + + +