mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-12-17 01:24:15 -05:00
Expose libresapi for GXS contacts import/export
To import contact
/identity/import_key
{"radix":"AgIRBAAABd..."}
To export contact
/identity/export_key
{"gxs_id":"ffffffffffffffffffffffffffffffff"}
In both cases if everithing went fine the answer is something like
{"data":{"radix":"AgIRBAAABd...", "gxs_id":"fff..."}, "returncode":"ok"}
Some retrocompatible adaptations were necessary to libretroshare
RsGenExchange::deserializeGroupData
p3IdService::deserialiseIdentityFromMemory
Now accept an extra optional pointer parameter to return the id of the
key so we can return it back from libresapi too and can be used to
request more information about the key to the API.
This commit is contained in:
parent
17edf3c8de
commit
5ee517b64f
7 changed files with 184 additions and 74 deletions
|
|
@ -1270,7 +1270,9 @@ bool RsGenExchange::getMsgRelatedMeta(const uint32_t &token, GxsMsgRelatedMetaMa
|
|||
return ok;
|
||||
}
|
||||
|
||||
bool RsGenExchange::getSerializedGroupData(const uint32_t &token, RsGxsGroupId& id,unsigned char *& data,uint32_t& size)
|
||||
bool RsGenExchange::getSerializedGroupData(uint32_t token, RsGxsGroupId& id,
|
||||
unsigned char *& data,
|
||||
uint32_t& size)
|
||||
{
|
||||
RS_STACK_MUTEX(mGenMtx) ;
|
||||
|
||||
|
|
@ -1303,24 +1305,30 @@ bool RsGenExchange::getSerializedGroupData(const uint32_t &token, RsGxsGroupId&
|
|||
return nxs_grp->serialise(data,size) ;
|
||||
}
|
||||
|
||||
bool RsGenExchange::deserializeGroupData(unsigned char *data,uint32_t size)
|
||||
bool RsGenExchange::deserializeGroupData(unsigned char *data, uint32_t size,
|
||||
RsGxsGroupId* gId /*= nullptr*/)
|
||||
{
|
||||
RS_STACK_MUTEX(mGenMtx) ;
|
||||
|
||||
RsItem *item = RsNxsSerialiser(mServType).deserialise(data, &size);
|
||||
|
||||
RsNxsGrp *nxs_grp = dynamic_cast<RsNxsGrp*>(item) ;
|
||||
RsNxsGrp *nxs_grp = dynamic_cast<RsNxsGrp*>(item);
|
||||
|
||||
if(item == NULL)
|
||||
{
|
||||
std::cerr << "(EE) RsGenExchange::deserializeGroupData(): cannot deserialise this data. Something's wrong." << std::endl;
|
||||
delete item ;
|
||||
return false ;
|
||||
}
|
||||
if(item == NULL)
|
||||
{
|
||||
std::cerr << "(EE) RsGenExchange::deserializeGroupData(): cannot "
|
||||
<< "deserialise this data. Something's wrong." << std::endl;
|
||||
delete item;
|
||||
return false;
|
||||
}
|
||||
|
||||
mReceivedGrps.push_back( GxsPendingItem<RsNxsGrp*, RsGxsGroupId>(nxs_grp, nxs_grp->grpId,time(NULL)) );
|
||||
mReceivedGrps.push_back(
|
||||
GxsPendingItem<RsNxsGrp*, RsGxsGroupId>(
|
||||
nxs_grp, nxs_grp->grpId,time(NULL)) );
|
||||
|
||||
return true ;
|
||||
if(gId) *gId = nxs_grp->grpId;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RsGenExchange::getGroupData(const uint32_t &token, std::vector<RsGxsGrpItem *>& grpItem)
|
||||
|
|
|
|||
|
|
@ -299,8 +299,10 @@ protected:
|
|||
* \return
|
||||
*/
|
||||
|
||||
bool getSerializedGroupData(const uint32_t &token, RsGxsGroupId &id, unsigned char *& data, uint32_t& size);
|
||||
bool deserializeGroupData(unsigned char *data, uint32_t size);
|
||||
bool getSerializedGroupData(uint32_t token, RsGxsGroupId &id,
|
||||
unsigned char *& data, uint32_t& size);
|
||||
bool deserializeGroupData(unsigned char *data, uint32_t size,
|
||||
RsGxsGroupId* gId = nullptr);
|
||||
|
||||
template<class GrpType>
|
||||
bool getGroupDataT(const uint32_t &token, std::vector<GrpType*>& grpItem)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue