mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-29 00:27:27 -04:00
fixed conflicts with master
This commit is contained in:
commit
da6e7f9e9b
50 changed files with 1735 additions and 771 deletions
|
@ -21,6 +21,7 @@
|
|||
* *
|
||||
*******************************************************************************/
|
||||
#include <unistd.h>
|
||||
#include <algorithm>
|
||||
|
||||
#include "pqi/pqihash.h"
|
||||
#include "rsgenexchange.h"
|
||||
|
@ -38,8 +39,7 @@
|
|||
#include "rsgxsutil.h"
|
||||
#include "rsserver/p3face.h"
|
||||
#include "retroshare/rsevents.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include "util/radix64.h"
|
||||
|
||||
#define PUB_GRP_MASK 0x000f
|
||||
#define RESTR_GRP_MASK 0x00f0
|
||||
|
@ -3432,6 +3432,71 @@ bool RsGenExchange::localSearch( const std::string& matchString,
|
|||
return mNetService->search(matchString, results);
|
||||
}
|
||||
|
||||
bool RsGenExchange::exportGroupBase64(
|
||||
std::string& radix, const RsGxsGroupId& groupId, std::string& errMsg )
|
||||
{
|
||||
constexpr auto fname = __PRETTY_FUNCTION__;
|
||||
const auto failure = [&](const std::string& err)
|
||||
{
|
||||
errMsg = err;
|
||||
RsErr() << fname << " " << err << std::endl;
|
||||
return false;
|
||||
};
|
||||
|
||||
if(groupId.isNull()) return failure("groupId cannot be null");
|
||||
|
||||
const std::list<RsGxsGroupId> groupIds({groupId});
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
|
||||
uint32_t token;
|
||||
mDataAccess->requestGroupInfo(
|
||||
token, RS_TOKREQ_ANSTYPE_DATA, opts, groupIds);
|
||||
RsTokenService::GxsRequestStatus wtStatus = mDataAccess->waitToken(token);
|
||||
if(wtStatus != RsTokenService::COMPLETE)
|
||||
return failure( "waitToken(...) failed with: " +
|
||||
std::to_string(wtStatus) );
|
||||
|
||||
uint8_t* buf = nullptr;
|
||||
uint32_t size;
|
||||
RsGxsGroupId grpId;
|
||||
if(!getSerializedGroupData(token, grpId, buf, size))
|
||||
return failure("failed retrieving GXS data");
|
||||
|
||||
Radix64::encode(buf, static_cast<int>(size), radix);
|
||||
free(buf);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RsGenExchange::importGroupBase64(
|
||||
const std::string& radix, RsGxsGroupId& groupId,
|
||||
std::string& errMsg )
|
||||
{
|
||||
constexpr auto fname = __PRETTY_FUNCTION__;
|
||||
const auto failure = [&](const std::string& err)
|
||||
{
|
||||
errMsg = err;
|
||||
RsErr() << fname << " " << err << std::endl;
|
||||
return false;
|
||||
};
|
||||
|
||||
if(radix.empty()) return failure("radix is empty");
|
||||
|
||||
std::vector<uint8_t> mem = Radix64::decode(radix);
|
||||
if(mem.empty()) return failure("radix seems corrupted");
|
||||
|
||||
// On success this also import the group as pending validation
|
||||
if(!deserializeGroupData(
|
||||
mem.data(), static_cast<uint32_t>(mem.size()),
|
||||
reinterpret_cast<RsGxsGroupId*>(&groupId) ))
|
||||
return failure("failed deserializing group");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
RsGxsChanges::RsGxsChanges() :
|
||||
RsEvent(RsEventType::GXS_CHANGES), mServiceType(RsServiceType::NONE),
|
||||
mService(nullptr) {}
|
||||
|
||||
RsGxsIface::~RsGxsIface() = default;
|
||||
RsGxsGroupSummary::~RsGxsGroupSummary() = default;
|
||||
|
|
|
@ -95,7 +95,8 @@ typedef std::map<RsGxsGrpMsgIdPair, std::vector<RsGxsMsgItem*> > GxsMsgRelatedDa
|
|||
|
||||
class RsGixs;
|
||||
|
||||
class RsGenExchange : public RsNxsObserver, public RsTickingThread, public RsGxsIface
|
||||
class RsGenExchange : public RsNxsObserver, public RsTickingThread,
|
||||
public RsGxsIface
|
||||
{
|
||||
public:
|
||||
|
||||
|
@ -325,6 +326,19 @@ public:
|
|||
bool localSearch( const std::string& matchString,
|
||||
std::list<RsGxsGroupSummary>& results );
|
||||
|
||||
/// @see RsGxsIface
|
||||
bool exportGroupBase64(
|
||||
std::string& radix, const RsGxsGroupId& groupId,
|
||||
std::string& errMsg = RS_DEFAULT_STORAGE_PARAM(std::string)
|
||||
) override;
|
||||
|
||||
/// @see RsGxsIface
|
||||
bool importGroupBase64(
|
||||
const std::string& radix,
|
||||
RsGxsGroupId& groupId = RS_DEFAULT_STORAGE_PARAM(RsGxsGroupId),
|
||||
std::string& errMsg = RS_DEFAULT_STORAGE_PARAM(std::string)
|
||||
) override;
|
||||
|
||||
protected:
|
||||
|
||||
bool messagePublicationTest(const RsGxsMsgMetaData&) ;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue