Merge pull request #1363 from G10h4ck/jsonapi

New cross-platform target retroshare-service
This commit is contained in:
G10h4ck 2018-10-16 16:06:09 +02:00 committed by GitHub
commit 03cdd6c7b6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
80 changed files with 2758 additions and 254 deletions

View file

@ -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) ;

View file

@ -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)

View file

@ -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) ;

View file

@ -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) ;

View file

@ -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); }

View file

@ -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 );
};

View file

@ -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"

View file

@ -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
{

View file

@ -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.
};

View file

@ -38,7 +38,7 @@
#define MAX_GPG_SIGNATURE_SIZE 4096
class RsPeerDetails;
struct RsPeerDetails;
/*!
* gpgcert is the identifier for a person.

View file

@ -129,7 +129,7 @@ class peerConnectState
class p3tunnel;
class RsPeerGroupItem_deprecated;
class RsGroupInfo;
struct RsGroupInfo;
class p3PeerMgr;
class p3NetMgr;

View file

@ -103,7 +103,7 @@ class peerState
};
class RsNodeGroupItem;
class RsGroupInfo;
struct RsGroupInfo;
std::string textPeerState(peerState &state);

View file

@ -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
/*!

View file

@ -32,7 +32,7 @@
#include "util/rsthreads.h" // for RsStackMutex, RsMutex
class PQInterface;
class RSTrafficClue;
struct RSTrafficClue;
class RsBwRates;
struct RsItem;
class RsRawItem;

View file

@ -30,7 +30,7 @@
#include <list>
class pqiperson;
class RsPeerCryptoParams ;
struct RsPeerCryptoParams;
static const int CONNECT_RECEIVED = 1;
static const int CONNECT_SUCCESS = 2;

View file

@ -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
{

View file

@ -76,7 +76,7 @@ class cert;
class pqissllistener;
class p3LinkMgr;
class RsPeerCryptoParams ;
struct RsPeerCryptoParams;
class pqissl: public NetBinInterface
{

View file

@ -25,7 +25,7 @@
#include "pqi/pqipersongrp.h"
class p3PeerMgr;
class RsPeerCryptoParams;
struct RsPeerCryptoParams;
class pqissl ;
class pqisslpersongrp: public pqipersongrp

View file

@ -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;

View file

@ -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) ; }

View file

@ -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

View file

@ -29,7 +29,7 @@
class RsServer;
class RsInit;
class RsPeerCryptoParams;
struct RsPeerCryptoParams;
class RsControl;
/// RsInit -> Configuration Parameters for RetroShare Startup

View file

@ -33,7 +33,7 @@
class ChatId;
class ChatMessage;
class RsGxsChanges;
struct RsGxsChanges;
class RsNotify;
extern RsNotify *rsNotify;

View file

@ -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;

View file

@ -65,7 +65,7 @@ class ToasterNotify;
class ChatWidget;
class ChatWidgetHolder;
// for gxs based plugins
class RsIdentity;
struct RsIdentity;
class RsNxsNetMgr;
class RsGxsIdExchange;
class RsGcxs;

View file

@ -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);

View file

@ -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;

View file

@ -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,

View file

@ -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

View file

@ -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;

View file

@ -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;

View file

@ -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
////////////////////////////////////////////////////////////////////////////////

View file

@ -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);

View file

@ -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
}

View file

@ -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__)

View file

@ -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];