mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-04 15:15:15 -04:00
added GUI async call to ID serialised data. Allows to copy+paste identities.
This commit is contained in:
parent
d66e653204
commit
3130ec9041
9 changed files with 168 additions and 40 deletions
|
@ -75,6 +75,12 @@ bool RsGxsDataAccess::requestGroupInfo(uint32_t &token, uint32_t ansType, const
|
|||
gir->mGroupIds = groupIds;
|
||||
req = gir;
|
||||
}
|
||||
else if(reqType & GXS_REQUEST_TYPE_GROUP_SERIALIZED_DATA)
|
||||
{
|
||||
GroupSerializedDataReq* gir = new GroupSerializedDataReq();
|
||||
gir->mGroupIds = groupIds;
|
||||
req = gir;
|
||||
}
|
||||
|
||||
if(req == NULL)
|
||||
{
|
||||
|
@ -103,34 +109,25 @@ bool RsGxsDataAccess::requestGroupInfo(uint32_t &token, uint32_t ansType, const
|
|||
uint32_t reqType = opts.mReqType;
|
||||
|
||||
if(reqType & GXS_REQUEST_TYPE_GROUP_META)
|
||||
{
|
||||
GroupMetaReq* gmr = new GroupMetaReq();
|
||||
req = gmr;
|
||||
}
|
||||
req = new GroupMetaReq();
|
||||
else if(reqType & GXS_REQUEST_TYPE_GROUP_DATA)
|
||||
{
|
||||
GroupDataReq* gdr = new GroupDataReq();
|
||||
req = gdr;
|
||||
}
|
||||
req = new GroupDataReq();
|
||||
else if(reqType & GXS_REQUEST_TYPE_GROUP_IDS)
|
||||
{
|
||||
GroupIdReq* gir = new GroupIdReq();
|
||||
req = gir;
|
||||
}
|
||||
|
||||
if(req == NULL)
|
||||
req = new GroupIdReq();
|
||||
else if(reqType & GXS_REQUEST_TYPE_GROUP_SERIALIZED_DATA)
|
||||
req = new GroupSerializedDataReq();
|
||||
else
|
||||
{
|
||||
std::cerr << "RsGxsDataAccess::requestGroupInfo() request type not recognised, type "
|
||||
<< reqType << std::endl;
|
||||
return false;
|
||||
}else
|
||||
{
|
||||
generateToken(token);
|
||||
#ifdef DATA_DEBUG
|
||||
std::cerr << "RsGxsDataAccess::requestGroupInfo() gets Token: " << token << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
generateToken(token);
|
||||
#ifdef DATA_DEBUG
|
||||
std::cerr << "RsGxsDataAccess::requestGroupInfo() gets Token: " << token << std::endl;
|
||||
#endif
|
||||
|
||||
setReq(req, token, ansType, opts);
|
||||
storeRequest(req);
|
||||
|
||||
|
@ -430,7 +427,16 @@ bool RsGxsDataAccess::getGroupData(const uint32_t& token, std::list<RsNxsGrp*>&
|
|||
else if(req->status == GXS_REQUEST_V2_STATUS_COMPLETE)
|
||||
{
|
||||
GroupDataReq* gmreq = dynamic_cast<GroupDataReq*>(req);
|
||||
if(gmreq)
|
||||
GroupSerializedDataReq* gsreq = dynamic_cast<GroupSerializedDataReq*>(req);
|
||||
|
||||
if(gsreq)
|
||||
{
|
||||
grpData.swap(gsreq->mGroupData);
|
||||
gsreq->mGroupData.clear();
|
||||
|
||||
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE);
|
||||
}
|
||||
else if(gmreq)
|
||||
{
|
||||
grpData.swap(gmreq->mGroupData);
|
||||
gmreq->mGroupData.clear();
|
||||
|
@ -804,6 +810,7 @@ void RsGxsDataAccess::processRequests()
|
|||
MsgIdReq* mir;
|
||||
MsgRelatedInfoReq* mri;
|
||||
GroupStatisticRequest* gsr;
|
||||
GroupSerializedDataReq* grr;
|
||||
ServiceStatisticRequest* ssr;
|
||||
|
||||
#ifdef DATA_DEBUG
|
||||
|
@ -851,6 +858,11 @@ void RsGxsDataAccess::processRequests()
|
|||
{
|
||||
ok = getServiceStatistic(ssr);
|
||||
}
|
||||
else if((grr = dynamic_cast<GroupSerializedDataReq*>(req)) != NULL)
|
||||
{
|
||||
ok = getGroupSerializedData(grr);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
std::cerr << "RsGxsDataAccess::processRequests() Failed to process request, token: "
|
||||
|
@ -929,7 +941,30 @@ bool RsGxsDataAccess::getServiceStatistic(const uint32_t &token, GxsServiceStati
|
|||
return true;
|
||||
}
|
||||
|
||||
bool RsGxsDataAccess::getGroupSerializedData(GroupSerializedDataReq* req)
|
||||
{
|
||||
std::map<RsGxsGroupId, RsNxsGrp*> grpData;
|
||||
std::list<RsGxsGroupId> grpIdsOut;
|
||||
|
||||
getGroupList(req->mGroupIds, req->Options, grpIdsOut);
|
||||
|
||||
if(grpIdsOut.empty())
|
||||
return true;
|
||||
|
||||
|
||||
for(std::list<RsGxsGroupId>::iterator lit = grpIdsOut.begin();lit != grpIdsOut.end();++lit)
|
||||
grpData[*lit] = NULL;
|
||||
|
||||
bool ok = mDataStore->retrieveNxsGrps(grpData, true, true);
|
||||
req->mGroupData.clear();
|
||||
|
||||
std::map<RsGxsGroupId, RsNxsGrp*>::iterator mit = grpData.begin();
|
||||
|
||||
for(; mit != grpData.end(); ++mit)
|
||||
req->mGroupData.push_back(mit->second) ;
|
||||
|
||||
return ok;
|
||||
}
|
||||
bool RsGxsDataAccess::getGroupData(GroupDataReq* req)
|
||||
{
|
||||
std::map<RsGxsGroupId, RsNxsGrp*> grpData;
|
||||
|
|
|
@ -418,6 +418,13 @@ private:
|
|||
*/
|
||||
bool getGroupStatistic(GroupStatisticRequest* req);
|
||||
|
||||
/*!
|
||||
*
|
||||
* Attempts to retrieve group data in serialized format
|
||||
* @param req Request object to satisfy
|
||||
*/
|
||||
bool getGroupSerializedData(GroupSerializedDataReq* req);
|
||||
|
||||
/*!
|
||||
*
|
||||
* Attempts to service statistic
|
||||
|
|
|
@ -61,6 +61,12 @@ public:
|
|||
std::list<RsGxsGroupId> mGroupIds;
|
||||
std::list<RsGxsGroupId> mGroupIdResult;
|
||||
};
|
||||
class GroupSerializedDataReq : public GxsRequest
|
||||
{
|
||||
public:
|
||||
std::list<RsGxsGroupId> mGroupIds;
|
||||
std::list<RsNxsGrp*> mGroupData;
|
||||
};
|
||||
|
||||
class GroupDataReq : public GxsRequest
|
||||
{
|
||||
|
|
|
@ -322,6 +322,7 @@ public:
|
|||
*/
|
||||
|
||||
virtual bool getGroupData(const uint32_t &token, std::vector<RsGxsIdGroup> &groups) = 0;
|
||||
virtual bool getGroupSerializedData(const uint32_t &token, std::map<RsGxsId,std::string>& serialized_groups)=0;
|
||||
//virtual bool getMsgData(const uint32_t &token, std::vector<RsGxsIdOpinion> &opinions) = 0;
|
||||
|
||||
};
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
|
||||
#define GXS_REQUEST_TYPE_GROUP_STATS 0x01600000
|
||||
#define GXS_REQUEST_TYPE_SERVICE_STATS 0x03200000
|
||||
#define GXS_REQUEST_TYPE_GROUP_SERIALIZED_DATA 0x04000000
|
||||
|
||||
|
||||
// TODO CLEANUP: RS_TOKREQOPT_MSG_* should be an inner enum of RsTokReqOptions
|
||||
|
|
|
@ -1474,6 +1474,28 @@ bool p3IdService::getGroupData(const uint32_t &token, std::vector<RsGxsIdGroup>
|
|||
return ok;
|
||||
}
|
||||
|
||||
bool p3IdService::getGroupSerializedData(const uint32_t &token, std::map<RsGxsId,std::string>& serialized_groups)
|
||||
{
|
||||
unsigned char *mem = NULL;
|
||||
uint32_t size;
|
||||
RsGxsGroupId id ;
|
||||
|
||||
serialized_groups.clear() ;
|
||||
|
||||
if(!RsGenExchange::getSerializedGroupData(token,id, mem,size))
|
||||
{
|
||||
std::cerr << "(EE) call to RsGenExchage::getSerializedGroupData() failed." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string radix ;
|
||||
|
||||
Radix64::encode(mem,size,radix) ;
|
||||
|
||||
serialized_groups[RsGxsId(id)] = radix ;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/********************************************************************************/
|
||||
/********************************************************************************/
|
||||
|
|
|
@ -245,6 +245,8 @@ public:
|
|||
|
||||
// These are exposed via RsIdentity.
|
||||
virtual bool getGroupData(const uint32_t &token, std::vector<RsGxsIdGroup> &groups);
|
||||
virtual bool getGroupSerializedData(const uint32_t &token, std::map<RsGxsId,std::string>& serialized_groups);
|
||||
|
||||
//virtual bool getMsgData(const uint32_t &token, std::vector<RsGxsIdOpinion> &opinions);
|
||||
|
||||
// These are local - and not exposed via RsIdentity.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue