mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-11 23:49:38 -05:00
Merge pull request #1363 from G10h4ck/jsonapi
New cross-platform target retroshare-service
This commit is contained in:
commit
03cdd6c7b6
@ -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?]
|
||||
|
@ -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
|
||||
|
378
build_scripts/Android/prepare-toolchain-clang.sh
Executable file
378
build_scripts/Android/prepare-toolchain-clang.sh
Executable file
@ -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 <cmath> 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}
|
@ -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
|
45
build_scripts/ArchLinuxAndDerivatives_OBS/PKGBUILD
Normal file
45
build_scripts/ArchLinuxAndDerivatives_OBS/PKGBUILD
Normal file
@ -0,0 +1,45 @@
|
||||
# Maintainer: Gioacchino Mazzurco <gio@eigenlab.org>
|
||||
# Contributor: AsamK
|
||||
# Contributor: sehraf
|
||||
# Contributor: stqn
|
||||
# Contributor: JHeaton <jheaton at archlinux dot us>
|
||||
# Contributor: Tristero <tristero at online dot de>
|
||||
# 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
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
retroshare-service-git (0.6.9999) stable; urgency=low
|
||||
|
||||
Add retroshare-service-git package
|
||||
|
||||
-- Gioacchino Mazzurco <gio@eigenlab.org> Tue, 08 Oct 2018 15:40:00 +0100
|
@ -0,0 +1 @@
|
||||
7
|
@ -0,0 +1,18 @@
|
||||
Source: retroshare-service-git
|
||||
Section: devel
|
||||
Priority: standard
|
||||
Maintainer: Cyril Soler <csoler@users.sourceforge.net>
|
||||
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.
|
@ -0,0 +1,2 @@
|
||||
debian/tmp/usr/bin/retroshare-service
|
||||
debian/tmp/usr/share/retroshare/bdboot.txt
|
@ -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
|
@ -0,0 +1,11 @@
|
||||
Format: 1.0
|
||||
Source: retroshare-service-git
|
||||
Binary: retroshare-service-git
|
||||
Architecture: any
|
||||
Version: 0.6.9999
|
||||
Maintainer: Cyril Soler <csoler@users.sourceforge.net>
|
||||
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
|
120
build_scripts/RpmBased_OBS/retroshare-service-git.spec
Normal file
120
build_scripts/RpmBased_OBS/retroshare-service-git.spec
Normal file
@ -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
|
263
data/retroshare.svg
Normal file
263
data/retroshare.svg
Normal file
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 67 KiB |
@ -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<QString> cppApiIncludesSet;
|
||||
|
||||
auto fatalError = [&](
|
||||
std::initializer_list<QVariant> errors, int ernum = EINVAL )
|
||||
std::initializer_list<QVariant> 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("
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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<uint32_t*>(&p) & ENTRY_INDEX_BIT_MASK_32BITS ) ;
|
||||
friend_index = (*reinterpret_cast<uint32_t*>(&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<uint64_t*>(&p) & ENTRY_INDEX_BIT_MASK_64BITS ) ;
|
||||
friend_index = (*reinterpret_cast<uint64_t*>(&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<real hash, BannedFileEntry>
|
||||
|
||||
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) ;
|
||||
|
@ -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<uint64_t>(j,ctx, entry.size ,"entry.size") ;
|
||||
RsTypeSerializer::serial_process<rstime_t> (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)
|
||||
|
@ -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<void*>(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) ;
|
||||
|
@ -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) ;
|
||||
|
||||
|
@ -41,6 +41,26 @@
|
||||
|
||||
/*extern*/ JsonApiServer* jsonApiServer = nullptr;
|
||||
|
||||
/*static*/ const std::multimap<std::string, std::string>
|
||||
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<std::string, std::string>
|
||||
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<std::string, std::string> 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<restbed::Session> session)
|
||||
@ -141,10 +159,10 @@ JsonApiServer::JsonApiServer(uint16_t port, const std::string& bindAddress,
|
||||
}, false);
|
||||
|
||||
registerHandler("/rsControl/rsGlobalShutDown",
|
||||
[this](const std::shared_ptr<rb::Session> session)
|
||||
[](const std::shared_ptr<rb::Session> session)
|
||||
{
|
||||
size_t reqSize = session->get_request()->get_header("Content-Length", 0);
|
||||
session->fetch( reqSize, [this](
|
||||
session->fetch( reqSize, [](
|
||||
const std::shared_ptr<rb::Session> 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<RsItem*>& loadList)
|
||||
|
||||
void JsonApiServer::saveDone() { configMutex.unlock(); }
|
||||
|
||||
void JsonApiServer::handleCorsOptions(
|
||||
const std::shared_ptr<restbed::Session> session )
|
||||
{ session->close(rb::NO_CONTENT, corsOptionsHeaders); }
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <memory>
|
||||
#include <restbed>
|
||||
#include <cstdint>
|
||||
#include <map>
|
||||
|
||||
#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<std::string, std::string> corsHeaders;
|
||||
static const std::multimap<std::string, std::string> corsOptionsHeaders;
|
||||
static void handleCorsOptions(const std::shared_ptr<rb::Session> session);
|
||||
|
||||
static bool checkRsServicePtrReady(
|
||||
void* serviceInstance, const std::string& serviceName,
|
||||
RsGenericSerializer::SerializeContext& ctx,
|
||||
const std::shared_ptr<restbed::Session> session );
|
||||
};
|
||||
|
||||
|
@ -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"
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include <pgp/pgpkeyutil.h>
|
||||
#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
|
||||
{
|
||||
|
@ -47,76 +47,98 @@
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
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<RsUrl>& 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<RsUrl>& 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<RsUrl> 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<RsUrl> mLocators;
|
||||
|
||||
bool only_pgp ; /// does the cert contain only pgp info?
|
||||
bool hidden_node; /// IP or hidden Node Address.
|
||||
};
|
||||
|
||||
|
@ -38,7 +38,7 @@
|
||||
|
||||
#define MAX_GPG_SIGNATURE_SIZE 4096
|
||||
|
||||
class RsPeerDetails;
|
||||
struct RsPeerDetails;
|
||||
|
||||
/*!
|
||||
* gpgcert is the identifier for a person.
|
||||
|
@ -129,7 +129,7 @@ class peerConnectState
|
||||
|
||||
class p3tunnel;
|
||||
class RsPeerGroupItem_deprecated;
|
||||
class RsGroupInfo;
|
||||
struct RsGroupInfo;
|
||||
|
||||
class p3PeerMgr;
|
||||
class p3NetMgr;
|
||||
|
@ -103,7 +103,7 @@ class peerState
|
||||
};
|
||||
|
||||
class RsNodeGroupItem;
|
||||
class RsGroupInfo;
|
||||
struct RsGroupInfo;
|
||||
|
||||
std::string textPeerState(peerState &state);
|
||||
|
||||
|
@ -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
|
||||
/*!
|
||||
|
@ -32,7 +32,7 @@
|
||||
#include "util/rsthreads.h" // for RsStackMutex, RsMutex
|
||||
|
||||
class PQInterface;
|
||||
class RSTrafficClue;
|
||||
struct RSTrafficClue;
|
||||
class RsBwRates;
|
||||
struct RsItem;
|
||||
class RsRawItem;
|
||||
|
@ -30,7 +30,7 @@
|
||||
#include <list>
|
||||
|
||||
class pqiperson;
|
||||
class RsPeerCryptoParams ;
|
||||
struct RsPeerCryptoParams;
|
||||
|
||||
static const int CONNECT_RECEIVED = 1;
|
||||
static const int CONNECT_SUCCESS = 2;
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -76,7 +76,7 @@ class cert;
|
||||
|
||||
class pqissllistener;
|
||||
class p3LinkMgr;
|
||||
class RsPeerCryptoParams ;
|
||||
struct RsPeerCryptoParams;
|
||||
|
||||
class pqissl: public NetBinInterface
|
||||
{
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include "pqi/pqipersongrp.h"
|
||||
|
||||
class p3PeerMgr;
|
||||
class RsPeerCryptoParams;
|
||||
struct RsPeerCryptoParams;
|
||||
class pqissl ;
|
||||
|
||||
class pqisslpersongrp: public pqipersongrp
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include <string>
|
||||
#include <functional>
|
||||
#include <chrono>
|
||||
#include <cstdint>
|
||||
|
||||
#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<DirDetails> &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<RsFileHash,BannedFileEntry>& 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<RsFileHash,BannedFileEntry>& 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;
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
template<int n> 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<n> operator| (const t_RsFlags32<n>& f) const { return t_RsFlags32<n>(_bits | f._bits) ; }
|
||||
|
@ -4,7 +4,7 @@
|
||||
* *
|
||||
* libretroshare: retroshare core library *
|
||||
* *
|
||||
* Copyright 2012-2012 by Robert Fernie <retroshare@lunamutt.com> *
|
||||
* Copyright (C) 2012 Robert Fernie <retroshare@lunamutt.com> *
|
||||
* Copyright (C) 2018 Gioacchino Mazzurco <gio@eigenlab.org> *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
@ -137,6 +137,23 @@ public:
|
||||
std::vector<RsGxsChannelPost>& posts,
|
||||
std::vector<RsGxsComment>& 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
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
class RsServer;
|
||||
class RsInit;
|
||||
class RsPeerCryptoParams;
|
||||
struct RsPeerCryptoParams;
|
||||
class RsControl;
|
||||
|
||||
/// RsInit -> Configuration Parameters for RetroShare Startup
|
||||
|
@ -33,7 +33,7 @@
|
||||
|
||||
class ChatId;
|
||||
class ChatMessage;
|
||||
class RsGxsChanges;
|
||||
struct RsGxsChanges;
|
||||
|
||||
class RsNotify;
|
||||
extern RsNotify *rsNotify;
|
||||
|
@ -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;
|
||||
|
@ -65,7 +65,7 @@ class ToasterNotify;
|
||||
class ChatWidget;
|
||||
class ChatWidgetHolder;
|
||||
// for gxs based plugins
|
||||
class RsIdentity;
|
||||
struct RsIdentity;
|
||||
class RsNxsNetMgr;
|
||||
class RsGxsIdExchange;
|
||||
class RsGcxs;
|
||||
|
@ -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<std::uintptr_t&>(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<DirStub> children;
|
||||
std::list<RsNodeGroupId> 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<std::uintptr_t&>(ref));
|
||||
RS_SERIAL_PROCESS(handle);
|
||||
std::uintptr_t& parentHandle(reinterpret_cast<std::uintptr_t&>(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);
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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<N>(f);
|
||||
&& from_JSON(memberName, f, ctx.mJson)
|
||||
&& (v = t_RsFlags32<N>(f), true);
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
|
@ -3,7 +3,8 @@
|
||||
* *
|
||||
* libretroshare: retroshare core library *
|
||||
* *
|
||||
* Copyright 2012-2012 Robert Fernie <retroshare@lunamutt.com> *
|
||||
* Copyright (C) 2012 Robert Fernie <retroshare@lunamutt.com> *
|
||||
* Copyright (C) 2018 Gioacchino Mazzurco <gio@eigenlab.org> *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
@ -34,17 +35,22 @@
|
||||
#include "rsserver/p3face.h"
|
||||
#include "retroshare/rsnotify.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <cstdio>
|
||||
|
||||
// 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<RsGroupMetaData> 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<RsGxsGroupId> chanIds; chanIds.push_back(post.mMeta.mGroupId);
|
||||
std::vector<RsGxsChannelPost> posts;
|
||||
std::vector<RsGxsComment> 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
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -3,7 +3,8 @@
|
||||
* *
|
||||
* libretroshare: retroshare core library *
|
||||
* *
|
||||
* Copyright 2012-2012 Robert Fernie <retroshare@lunamutt.com> *
|
||||
* Copyright (C) 2012 Robert Fernie <retroshare@lunamutt.com> *
|
||||
* Copyright (C) 2018 Gioacchino Mazzurco <gio@eigenlab.org> *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
@ -33,10 +34,6 @@
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
class SSGxsChannelGroup
|
||||
{
|
||||
@ -182,6 +179,12 @@ virtual bool ExtraFileRemove(const RsFileHash &hash);
|
||||
std::vector<RsGxsChannelPost>& posts,
|
||||
std::vector<RsGxsComment>& 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);
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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__)
|
||||
|
@ -16,7 +16,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
//#include "util/rsurl.h"
|
||||
|
||||
#include "rsurl.h"
|
||||
|
||||
#include <cstdio>
|
||||
@ -245,7 +245,7 @@ RsUrl& RsUrl::setFragment(const std::string& fragment)
|
||||
|
||||
if(str[i] == '%' && i < boundary)
|
||||
{
|
||||
decoded << static_cast<char>(stoi(str.substr(++i, 2), 0, 16));
|
||||
decoded << static_cast<char>(std::stoi(str.substr(++i, 2), 0, 16));
|
||||
++i;
|
||||
}
|
||||
else decoded << str[i];
|
||||
|
@ -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()));
|
||||
|
||||
|
@ -33,9 +33,9 @@
|
||||
#include <iostream>
|
||||
|
||||
#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() ;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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"),
|
||||
|
@ -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()
|
||||
|
10
retroshare-service/data/retroshare-service.desktop
Normal file
10
retroshare-service/data/retroshare-service.desktop
Normal file
@ -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;
|
188
retroshare-service/data/retroshare-service.svg
Normal file
188
retroshare-service/data/retroshare-service.svg
Normal file
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 66 KiB |
BIN
retroshare-service/data/retroshare-service_128x128.png
Normal file
BIN
retroshare-service/data/retroshare-service_128x128.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.0 KiB |
BIN
retroshare-service/data/retroshare-service_48x48.png
Normal file
BIN
retroshare-service/data/retroshare-service_48x48.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.9 KiB |
3
retroshare-service/src/android/.gitignore
vendored
Normal file
3
retroshare-service/src/android/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
*~
|
||||
gradle.properties
|
||||
local.properties
|
85
retroshare-service/src/android/AndroidManifest.xml
Normal file
85
retroshare-service/src/android/AndroidManifest.xml
Normal file
@ -0,0 +1,85 @@
|
||||
<?xml version="1.0"?>
|
||||
<manifest
|
||||
package="org.retroshare.service"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:versionName="0.6.4" android:versionCode="1"
|
||||
android:installLocation="auto">
|
||||
<application android:name="org.qtproject.qt5.android.bindings.QtApplication" android:hardwareAccelerated="true" android:label="RetroShare" android:icon="@drawable/retroshare_service_128x128">
|
||||
<activity
|
||||
android:name=".RetroShareServiceControlActivity"
|
||||
android:label="RetroShare" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<receiver android:name=".BootCompletedReceiver" android:enabled="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.BOOT_COMPLETED"/>
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<receiver android:name=".AppUpdatedReceiver" android:enabled="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MY_PACKAGE_REPLACED"/>
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<!-- For adding service(s) please check:
|
||||
++ https://wiki.qt.io/AndroidServices -->
|
||||
<service android:name=".RetroShareServiceAndroid" android:process=":rs" android:label="RetroShare Service" android:exported="true">
|
||||
<!-- android:exported="true" Added to be able to run the service
|
||||
++ from adb shell
|
||||
++ android:process=":rs" is needed to force the service to run on
|
||||
++ a separate process than the Activity -->
|
||||
|
||||
<!-- Qt Application to launch -->
|
||||
<meta-data android:name="android.app.lib_name" android:value="retroshare-service"/>
|
||||
|
||||
<!-- Ministro -->
|
||||
<meta-data android:name="android.app.qt_sources_resource_id" android:resource="@array/qt_sources"/>
|
||||
<meta-data android:name="android.app.repository" android:value="default"/>
|
||||
<meta-data android:name="android.app.qt_libs_resource_id" android:resource="@array/qt_libs"/>
|
||||
<meta-data android:name="android.app.bundled_libs_resource_id" android:resource="@array/bundled_libs"/>
|
||||
<!-- Deploy Qt libs as part of package -->
|
||||
<meta-data android:name="android.app.bundle_local_qt_libs" android:value="-- %%BUNDLE_LOCAL_QT_LIBS%% --"/>
|
||||
<meta-data android:name="android.app.bundled_in_lib_resource_id" android:resource="@array/bundled_in_lib"/>
|
||||
<meta-data android:name="android.app.bundled_in_assets_resource_id" android:resource="@array/bundled_in_assets"/>
|
||||
<!-- Run with local libs -->
|
||||
<meta-data android:name="android.app.use_local_qt_libs" android:value="-- %%USE_LOCAL_QT_LIBS%% --"/>
|
||||
<meta-data android:name="android.app.libs_prefix" android:value="/data/local/tmp/qt/"/>
|
||||
<meta-data android:name="android.app.load_local_libs" android:value="-- %%INSERT_LOCAL_LIBS%% --"/>
|
||||
<meta-data android:name="android.app.load_local_jars" android:value="-- %%INSERT_LOCAL_JARS%% --"/>
|
||||
<meta-data android:name="android.app.static_init_classes" android:value="-- %%INSERT_INIT_CLASSES%% --"/>
|
||||
<!-- Messages maps -->
|
||||
<meta-data android:value="@string/ministro_not_found_msg" android:name="android.app.ministro_not_found_msg"/>
|
||||
<meta-data android:value="@string/ministro_needed_msg" android:name="android.app.ministro_needed_msg"/>
|
||||
<meta-data android:value="@string/fatal_error_msg" android:name="android.app.fatal_error_msg"/>
|
||||
<!-- Messages maps -->
|
||||
|
||||
<!-- Background running -->
|
||||
<meta-data android:name="android.app.background_running" android:value="true"/>
|
||||
<!-- Background running -->
|
||||
</service>
|
||||
</application>
|
||||
|
||||
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="18"/>
|
||||
<supports-screens android:largeScreens="true" android:normalScreens="true" android:anyDensity="true" android:smallScreens="true"/>
|
||||
|
||||
<!-- The following comment will be replaced upon deployment with default
|
||||
++ permissions based on the dependencies of the application.
|
||||
++ Remove the comment if you do not require these default permissions. -->
|
||||
<!-- %%INSERT_PERMISSIONS -->
|
||||
|
||||
<!-- The following comment will be replaced upon deployment with default
|
||||
++ features based on the dependencies of the application.
|
||||
++ Remove the comment if you do not require these default features. -->
|
||||
<!-- %%INSERT_FEATURES -->
|
||||
|
||||
<!-- Added by G10h4ck: Needed permission for autostart at boot -->
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
|
||||
<!-- Added by Angesoc: used to access files shared by other apps -->
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
||||
</manifest>
|
57
retroshare-service/src/android/build.gradle
Normal file
57
retroshare-service/src/android/build.gradle
Normal file
@ -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
|
||||
}
|
||||
}
|
BIN
retroshare-service/src/android/gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
BIN
retroshare-service/src/android/gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
Binary file not shown.
5
retroshare-service/src/android/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
5
retroshare-service/src/android/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@ -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
|
172
retroshare-service/src/android/gradlew
vendored
Executable file
172
retroshare-service/src/android/gradlew
vendored
Executable file
@ -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" "$@"
|
84
retroshare-service/src/android/gradlew.bat
vendored
Normal file
84
retroshare-service/src/android/gradlew.bat
vendored
Normal file
@ -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
|
@ -0,0 +1 @@
|
||||
../../../../data/retroshare-service_128x128.png
|
@ -0,0 +1 @@
|
||||
../../../../data/retroshare-service_48x48.png
|
@ -0,0 +1,11 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<Button
|
||||
android:id="@+id/startStopButton" android:text="Stop"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</LinearLayout>
|
25
retroshare-service/src/android/res/values/libs.xml
Normal file
25
retroshare-service/src/android/res/values/libs.xml
Normal file
@ -0,0 +1,25 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<resources>
|
||||
<array name="qt_sources">
|
||||
<item>https://download.qt.io/ministro/android/qt5/qt-5.9</item>
|
||||
</array>
|
||||
|
||||
<!-- The following is handled automatically by the deployment tool. It should
|
||||
not be edited manually. -->
|
||||
|
||||
<array name="bundled_libs">
|
||||
<!-- %%INSERT_EXTRA_LIBS%% -->
|
||||
</array>
|
||||
|
||||
<array name="qt_libs">
|
||||
<!-- %%INSERT_QT_LIBS%% -->
|
||||
</array>
|
||||
|
||||
<array name="bundled_in_lib">
|
||||
<!-- %%INSERT_BUNDLED_IN_LIB%% -->
|
||||
</array>
|
||||
<array name="bundled_in_assets">
|
||||
<!-- %%INSERT_BUNDLED_IN_ASSETS%% -->
|
||||
</array>
|
||||
|
||||
</resources>
|
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* RetroShare
|
||||
* Copyright (C) 2016-2018 Gioacchino Mazzurco <gio@eigenlab.org>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.retroshare.service;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.util.Log;
|
||||
|
||||
public class AppUpdatedReceiver extends BroadcastReceiver
|
||||
{
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent)
|
||||
{
|
||||
Log.i("AppUpdatedReceiver", "onReceive() Restarting RetroShare Service After Update");
|
||||
RetroShareServiceAndroid.stop(context);
|
||||
RetroShareServiceAndroid.start(context);
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* RetroShare
|
||||
* Copyright (C) 2016-2018 Gioacchino Mazzurco <gio@eigenlab.org>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.retroshare.service;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.util.Log;
|
||||
|
||||
public class BootCompletedReceiver extends BroadcastReceiver
|
||||
{
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent)
|
||||
{
|
||||
Log.i("BootCompletedReceiver", "onReceive() Starting RetroShare Service on boot");
|
||||
RetroShareServiceAndroid.start(context);
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* RetroShare
|
||||
* Copyright (C) 2016-2018 Gioacchino Mazzurco <gio@eigenlab.org>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.retroshare.service;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import org.qtproject.qt5.android.bindings.QtService;
|
||||
|
||||
public class RetroShareServiceAndroid extends QtService
|
||||
{
|
||||
public static void start(Context ctx)
|
||||
{
|
||||
ctx.startService(new Intent(ctx, RetroShareServiceAndroid.class));
|
||||
}
|
||||
|
||||
public static void stop(Context ctx)
|
||||
{
|
||||
ctx.stopService(new Intent(ctx, RetroShareServiceAndroid.class));
|
||||
}
|
||||
|
||||
public static boolean isRunning(Context ctx)
|
||||
{
|
||||
ActivityManager manager = (ActivityManager) ctx.getSystemService(Context.ACTIVITY_SERVICE);
|
||||
for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE))
|
||||
if (RetroShareServiceAndroid.class.getName().equals(service.service.getClassName()))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* RetroShare
|
||||
* Copyright (C) 2016-2018 Gioacchino Mazzurco <gio@eigenlab.org>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.retroshare.service;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import org.retroshare.service.R;
|
||||
|
||||
|
||||
public class RetroShareServiceControlActivity extends Activity
|
||||
{
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState)
|
||||
{
|
||||
setContentView(R.layout.retroshare_service_control_layout);
|
||||
|
||||
final Button button = (Button) findViewById(R.id.startStopButton);
|
||||
button.setOnClickListener(new View.OnClickListener()
|
||||
{
|
||||
public void onClick(View v)
|
||||
{
|
||||
if (RetroShareServiceAndroid.isRunning(RetroShareServiceControlActivity.this))
|
||||
{
|
||||
RetroShareServiceAndroid.stop(RetroShareServiceControlActivity.this);
|
||||
button.setText("Start");
|
||||
}
|
||||
else
|
||||
{
|
||||
RetroShareServiceAndroid.start(RetroShareServiceControlActivity.this);
|
||||
button.setText("Stop");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume()
|
||||
{
|
||||
super.onResume();
|
||||
|
||||
final Button button = (Button) findViewById(R.id.startStopButton);
|
||||
button.setText(RetroShareServiceAndroid.isRunning(this) ? "Stop" : "Start");
|
||||
}
|
||||
}
|
78
retroshare-service/src/retroshare-service.cc
Normal file
78
retroshare-service/src/retroshare-service.cc
Normal file
@ -0,0 +1,78 @@
|
||||
/*
|
||||
* RetroShare Service
|
||||
* Copyright (C) 2016-2018 Gioacchino Mazzurco <gio@eigenlab.org>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <csignal>
|
||||
#include <QObject>
|
||||
#include <QStringList>
|
||||
|
||||
#ifdef __ANDROID__
|
||||
# include <QAndroidService>
|
||||
#endif // def __ANDROID__
|
||||
|
||||
#include "retroshare/rsinit.h"
|
||||
#include "retroshare/rsiface.h"
|
||||
|
||||
#ifdef __ANDROID__
|
||||
# include "util/androiddebug.h"
|
||||
#endif
|
||||
|
||||
#ifndef RS_JSONAPI
|
||||
# error Inconsistent build configuration retroshare_service needs rs_jsonapi
|
||||
#endif
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
#ifdef __ANDROID__
|
||||
AndroidStdIOCatcher dbg; (void) dbg;
|
||||
QAndroidService app(argc, argv);
|
||||
#else // def __ANDROID__
|
||||
QCoreApplication app(argc, argv);
|
||||
#endif // def __ANDROID__
|
||||
|
||||
signal(SIGINT, QCoreApplication::exit);
|
||||
signal(SIGTERM, QCoreApplication::exit);
|
||||
#ifdef SIGBREAK
|
||||
signal(SIGBREAK, QCoreApplication::exit);
|
||||
#endif // ifdef SIGBREAK
|
||||
|
||||
RsInit::InitRsConfig();
|
||||
|
||||
// clumsy way to enable JSON API by default
|
||||
if(!QCoreApplication::arguments().contains("--jsonApiPort"))
|
||||
{
|
||||
int argc2 = argc + 2;
|
||||
char* argv2[argc2]; for (int i = 0; i < argc; ++i ) argv2[i] = argv[i];
|
||||
char opt[] = "--jsonApiPort";
|
||||
char val[] = "9092";
|
||||
argv2[argc] = opt;
|
||||
argv2[argc+1] = val;
|
||||
RsInit::InitRetroShare(argc2, argv2, true);
|
||||
}
|
||||
else RsInit::InitRetroShare(argc, argv, true);
|
||||
|
||||
RsControl::earlyInitNotificationSystem();
|
||||
rsControl->setShutdownCallback(QCoreApplication::exit);
|
||||
QObject::connect(
|
||||
&app, &QCoreApplication::aboutToQuit,
|
||||
[](){
|
||||
if(RsControl::instance()->isReady())
|
||||
RsControl::instance()->rsGlobalShutDown(); } );
|
||||
|
||||
return app.exec();
|
||||
}
|
241
retroshare-service/src/retroshare-service.inkscape.svg
Normal file
241
retroshare-service/src/retroshare-service.inkscape.svg
Normal file
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 68 KiB |
42
retroshare-service/src/retroshare-service.pro
Normal file
42
retroshare-service/src/retroshare-service.pro
Normal file
@ -0,0 +1,42 @@
|
||||
!include("../../retroshare.pri"): error("Could not include file ../../retroshare.pri")
|
||||
|
||||
TARGET = retroshare-service
|
||||
|
||||
QT += core
|
||||
QT -= gui
|
||||
|
||||
!include("../../libretroshare/src/use_libretroshare.pri"):error("Including")
|
||||
|
||||
SOURCES += retroshare-service.cc
|
||||
|
||||
android-* {
|
||||
QT += androidextras
|
||||
|
||||
ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android
|
||||
|
||||
DISTFILES += android/AndroidManifest.xml \
|
||||
android/res/drawable/retroshare_128x128.png \
|
||||
android/res/drawable/retroshare_retroshare_48x48.png \
|
||||
android/gradle/wrapper/gradle-wrapper.jar \
|
||||
android/gradlew \
|
||||
android/res/values/libs.xml \
|
||||
android/build.gradle \
|
||||
android/gradle/wrapper/gradle-wrapper.properties \
|
||||
android/gradlew.bat
|
||||
}
|
||||
|
||||
|
||||
appimage {
|
||||
icon_files.path = "$${PREFIX}/share/icons/hicolor/scalable/"
|
||||
icon_files.files = ../data/retroshare-service.svg
|
||||
INSTALLS += icon_files
|
||||
|
||||
desktop_files.path = "$${PREFIX}/share/applications"
|
||||
desktop_files.files = ../data/retroshare-service.desktop
|
||||
INSTALLS += desktop_files
|
||||
}
|
||||
|
||||
unix {
|
||||
target.path = "$${RS_BIN_DIR}"
|
||||
INSTALLS += target
|
||||
}
|
@ -64,6 +64,16 @@ retroshare_android_notify_service:CONFIG -= no_retroshare_android_notify_service
|
||||
CONFIG *= no_retroshare_qml_app
|
||||
retroshare_qml_app:CONFIG -= no_retroshare_qml_app
|
||||
|
||||
# To enable RetroShare service append the following assignation to
|
||||
# qmake command line "CONFIG+=retroshare_service"
|
||||
CONFIG *= no_retroshare_service
|
||||
retroshare_service:CONFIG -= no_retroshare_service
|
||||
|
||||
# To disable libresapi append the following assignation to qmake command line
|
||||
#"CONFIG+=no_libresapi"
|
||||
CONFIG *= libresapi
|
||||
no_libresapi:CONFIG -= libresapi
|
||||
|
||||
# To enable libresapi via local socket (unix domain socket or windows named
|
||||
# pipes) append the following assignation to qmake command line
|
||||
#"CONFIG+=libresapilocalserver"
|
||||
@ -140,9 +150,14 @@ CONFIG *= no_rs_jsonapi
|
||||
rs_jsonapi:CONFIG -= no_rs_jsonapi
|
||||
|
||||
# To disable deep search append the following assignation to qmake command line
|
||||
CONFIG+=no_rs_deep_search
|
||||
CONFIG *= rs_deep_search
|
||||
no_rs_deep_search:CONFIG -= rs_deep_search
|
||||
CONFIG *= no_rs_deep_search
|
||||
rs_deep_search:CONFIG -= no_rs_deep_search
|
||||
|
||||
# Specify host precompiled jsonapi-generator path, appending the following
|
||||
# assignation to qmake command line
|
||||
# 'JSONAPI_GENERATOR_EXE=/myBuildDir/jsonapi-generator'. Required for JSON API
|
||||
# cross-compiling
|
||||
#JSONAPI_GENERATOR_EXE=/myBuildDir/jsonapi-generator
|
||||
|
||||
# Specify RetroShare major version appending the following assignation to qmake
|
||||
# command line 'RS_MAJOR_VERSION=0'
|
||||
@ -299,6 +314,18 @@ defineReplace(linkDynamicLibs) {
|
||||
## RS_THREAD_LIB String viariable containing the name of the multi threading
|
||||
## library to use (pthread, "") it usually depend on platform.
|
||||
|
||||
isEmpty(QMAKE_HOST_SPEC):QMAKE_HOST_SPEC=$$[QMAKE_SPEC]
|
||||
isEmpty(QMAKE_TARGET_SPEC):QMAKE_TARGET_SPEC=$$[QMAKE_XSPEC]
|
||||
equals(QMAKE_HOST_SPEC, $$QMAKE_TARGET_SPEC) {
|
||||
CONFIG *= no_rs_cross_compiling
|
||||
CONFIG -= rs_cross_compiling
|
||||
} else {
|
||||
CONFIG *= rs_cross_compiling
|
||||
CONFIG -= no_rs_cross_compiling
|
||||
message(Cross-compiling detected QMAKE_HOST_SPEC: $$QMAKE_HOST_SPEC \
|
||||
QMAKE_TARGET_SPEC: $$QMAKE_TARGET_SPEC)
|
||||
}
|
||||
|
||||
defined(RS_MAJOR_VERSION,var):\
|
||||
defined(RS_MINOR_VERSION,var):\
|
||||
defined(RS_MINI_VERSION,var):\
|
||||
@ -408,6 +435,10 @@ rs_chatserver {
|
||||
}
|
||||
|
||||
rs_jsonapi {
|
||||
rs_cross_compiling:!exists($$JSONAPI_GENERATOR_EXE):error("Inconsistent \
|
||||
build configuration, cross-compiling JSON API requires JSONAPI_GENERATOR_EXE \
|
||||
to contain the path to an host executable jsonapi-generator")
|
||||
|
||||
DEFINES *= RS_JSONAPI
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user