Bug fix for ES_GXS_MSG_COMMENTS option

Fix for run thread loop of RsGenExchange (was using logic rather than isRunning, which led to some crashes on rs close

Added request and get MsgRelated function for ids, meta and data 
added template function to ease getting meta data from back end;

Updated Nxs tests, tests passed (failed initially because of change option requirements)
Added test for msgrelated Ids, still need to add test for all msgRelated functions (bug with mask, not filtering correctly)

Made changes for forum and wiki gui to use new API but gui needs to call correct get functions now (Bob).

git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs-b1@5817 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
chrisparker126 2012-11-13 22:36:06 +00:00
parent 8d556955c5
commit f74a328d61
27 changed files with 872 additions and 310 deletions

View File

@ -76,6 +76,7 @@ public:
};
typedef std::map<RsGxsGroupId, std::vector<RsNxsMsg*> > NxsMsgDataResult;
typedef std::map<RsGxsGrpMsgIdPair, std::vector<RsNxsMsg*> > NxsMsgRelatedDataResult;
typedef std::map<RsGxsGroupId, std::vector<RsNxsMsg*> > GxsMsgResult; // <grpId, msgs>
/*!

View File

@ -75,7 +75,7 @@ void RsGenExchange::run()
double timeDelta = 0.1; // slow tick
while(true)
while(isRunning())
{
tick();
@ -303,7 +303,7 @@ bool RsGenExchange::createMsgSignatures(RsTlvKeySignatureSet& signSet, RsTlvBina
const RsGxsMsgMetaData& msgMeta, RsGxsGrpMetaData& grpMeta)
{
bool isParent = false;
bool needPublishSign, needIdentitySign;
bool needPublishSign = false, needIdentitySign = false;
bool ok = true;
uint32_t grpFlag = grpMeta.mGroupFlags;
@ -452,6 +452,7 @@ bool RsGenExchange::createMsgSignatures(RsTlvKeySignatureSet& signSet, RsTlvBina
#ifdef GEN_EXHANGE_DEBUG
std::cerr << "Gixs not enabled while request identity signature validation!" << std::endl;
#endif
ok = false;
}
}
@ -694,6 +695,11 @@ bool RsGenExchange::getMsgList(const uint32_t &token,
return mDataAccess->getMsgList(token, msgIds);
}
bool RsGenExchange::getMsgRelatedList(const uint32_t &token, MsgRelatedIdResult &msgIds)
{
return mDataAccess->getMsgRelatedList(token, msgIds);
}
bool RsGenExchange::getGroupMeta(const uint32_t &token, std::list<RsGroupMetaData> &groupInfo)
{
std::list<RsGxsGrpMetaData*> metaL;
@ -744,6 +750,36 @@ bool RsGenExchange::getMsgMeta(const uint32_t &token,
return ok;
}
bool RsGenExchange::getMsgRelatedMeta(const uint32_t &token, GxsMsgRelatedMetaMap &msgMeta)
{
MsgRelatedMetaResult result;
bool ok = mDataAccess->getMsgRelatedSummary(token, result);
MsgRelatedMetaResult::iterator mit = result.begin();
for(; mit != result.end(); mit++)
{
std::vector<RsGxsMsgMetaData*>& metaV = mit->second;
msgMeta[mit->first] = std::vector<RsMsgMetaData>();
std::vector<RsMsgMetaData>& msgInfoV = msgMeta[mit->first];
std::vector<RsGxsMsgMetaData*>::iterator vit = metaV.begin();
RsMsgMetaData meta;
for(; vit != metaV.end(); vit++)
{
RsGxsMsgMetaData& m = *(*vit);
meta = m;
msgInfoV.push_back(meta);
delete *vit;
}
metaV.clear();
}
return ok;
}
bool RsGenExchange::getGroupData(const uint32_t &token, std::vector<RsGxsGrpItem *>& grpItem)
{
@ -814,6 +850,46 @@ bool RsGenExchange::getMsgData(const uint32_t &token,
return ok;
}
bool RsGenExchange::getMsgRelatedData(const uint32_t &token, GxsMsgRelatedDataMap &msgItems)
{
RsStackMutex stack(mGenMtx);
NxsMsgRelatedDataResult msgResult;
bool ok = mDataAccess->getMsgRelatedData(token, msgResult);
NxsMsgRelatedDataResult::iterator mit = msgResult.begin();
if(ok)
{
for(; mit != msgResult.end(); mit++)
{
std::vector<RsGxsMsgItem*> gxsMsgItems;
const RsGxsGrpMsgIdPair& msgId = mit->first;
std::vector<RsNxsMsg*>& nxsMsgsV = mit->second;
std::vector<RsNxsMsg*>::iterator vit
= nxsMsgsV.begin();
for(; vit != nxsMsgsV.end(); vit++)
{
RsNxsMsg*& msg = *vit;
RsItem* item = mSerialiser->deserialise(msg->msg.bin_data,
&msg->msg.bin_len);
RsGxsMsgItem* mItem = dynamic_cast<RsGxsMsgItem*>(item);
if(mItem != NULL)
{
mItem->meta = *((*vit)->metaData); // get meta info from nxs msg
gxsMsgItems.push_back(mItem);
}
delete msg;
}
msgItems[msgId] = gxsMsgItems;
}
}
return ok;
}
RsTokenService* RsGenExchange::getTokenService()
{

View File

@ -39,7 +39,9 @@
typedef std::map<RsGxsGroupId, std::vector<RsGxsMsgItem*> > GxsMsgDataMap;
typedef std::map<RsGxsGroupId, RsGxsGrpItem*> GxsGroupDataMap;
typedef std::map<RsGxsGrpMsgIdPair, std::vector<RsGxsMsgItem*> > GxsMsgRelatedDataMap;
typedef std::map<RsGxsGroupId, std::vector<RsMsgMetaData> > GxsMsgMetaMap;
typedef std::map<RsGxsGrpMsgIdPair, std::vector<RsMsgMetaData> > GxsMsgRelatedMetaMap;
/*!
* This should form the parent class to \n
@ -151,14 +153,24 @@ public:
* Retrieve msg list for a given token sectioned by group Ids
* @param token token to be redeemed
* @param msgIds a map of grpId -> msgList (vector)
* @return false if could not redeem token
*/
bool getMsgList(const uint32_t &token, GxsMsgIdResult &msgIds);
/*!
* Retrieve msg list for a given token for message related info
* @param token token to be redeemed
* @param msgIds a map of RsGxsGrpMsgIdPair -> msgList (vector)
* @return false if could not redeem token
*/
bool getMsgRelatedList(const uint32_t &token, MsgRelatedIdResult& msgIds);
/*!
* retrieve group meta data associated to a request token
* @param token
* @param groupInfo
* @return false if could not redeem token
*/
bool getGroupMeta(const uint32_t &token, std::list<RsGroupMetaData> &groupInfo);
@ -169,6 +181,14 @@ public:
*/
bool getMsgMeta(const uint32_t &token, GxsMsgMetaMap &msgInfo);
/*!
* Retrieve msg meta for a given token for message related info
* @param token token to be redeemed
* @param msgIds a map of RsGxsGrpMsgIdPair -> msgList (vector)
* @return false if could not redeem token
*/
bool getMsgRelatedMeta(const uint32_t &token, GxsMsgRelatedMetaMap& msgMeta);
@ -194,6 +214,63 @@ protected:
*/
bool getMsgData(const uint32_t &token, GxsMsgDataMap& msgItems);
/*!
* retrieves message related data associated to a request token
* @param token token to be redeemed for message item retrieval
* @param msgItems
*/
bool getMsgRelatedData(const uint32_t &token, GxsMsgRelatedDataMap& msgItems);
/*!
* Convenience template function for retrieve
* msg related data from
* @param GxsMsgType This represent derived msg class type of the service (i.e. msg type that derives from RsGxsMsgItem
* @param MsgType Represents the final type the core data is converted to
* @param token token to be redeemed
*/
template <class GxsMsgType, class MsgType>
bool getMsgRelatedDataT(const uint32_t &token, std::map<RsGxsGrpMsgIdPair, std::vector<MsgType> > &msgItems)
{
RsStackMutex stack(mGenMtx);
NxsMsgRelatedDataResult msgResult;
bool ok = mDataAccess->getMsgRelatedData(token, msgResult);
NxsMsgRelatedDataResult::iterator mit = msgResult.begin();
if(ok)
{
for(; mit != msgResult.end(); mit++)
{
std::vector<MsgType> gxsMsgItems;
const RsGxsGrpMsgIdPair& msgId = mit->first;
std::vector<RsNxsMsg*>& nxsMsgsV = mit->second;
std::vector<RsNxsMsg*>::iterator vit
= nxsMsgsV.begin();
for(; vit != nxsMsgsV.end(); vit++)
{
RsNxsMsg*& msg = *vit;
RsItem* item = mSerialiser->deserialise(msg->msg.bin_data,
&msg->msg.bin_len);
GxsMsgType* mItem = dynamic_cast<GxsMsgType*>(item);
if(mItem == NULL){
delete msg;
continue;
}
mItem->meta = *((*vit)->metaData); // get meta info from nxs msg
// GxsMsgType m = (*mItem); // doesn't work! don't know why, even with overloading done.
MsgType theServMsg = (MsgType)*mItem;
gxsMsgItems.push_back(theServMsg);
delete msg;
}
msgItems[msgId] = gxsMsgItems;
}
}
return ok;
}
/*!
* Assigns a token value to passed integer
* The status of the token can still be queried from request status feature

View File

@ -40,6 +40,10 @@ typedef std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > GxsMsgReq;
typedef std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > GxsMsgIdResult;
typedef std::map<RsGxsGroupId, std::vector<RsGxsMsgMetaData*> > GxsMsgMetaResult;
typedef std::map<RsGxsGroupId, std::vector<RsMsgMetaData> > MsgMetaResult;
typedef std::map<RsGxsGrpMsgIdPair, std::vector<RsGxsMsgMetaData*> > MsgRelatedMetaResult;
typedef std::map<RsGxsGrpMsgIdPair, std::vector<RsGxsMessageId> > MsgRelatedIdResult;
class RsGxsService
{

View File

@ -270,11 +270,11 @@ bool RsGxsDataAccess::requestMsgInfo(uint32_t &token, uint32_t ansType,
}
bool RsGxsDataAccess::requestMsgRelatedInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts,
const RsGxsGrpMsgIdPair &msgIds)
const std::vector<RsGxsGrpMsgIdPair> &msgIds)
{
MsgRelatedInfoReq* req = new MsgRelatedInfoReq();
req->mMsgId = msgIds;
req->mMsgIds = msgIds;
generateToken(token);
@ -422,13 +422,15 @@ bool RsGxsDataAccess::getMsgData(const uint32_t& token, NxsMsgDataResult& msgDat
return false;
}else if(req->status == GXS_REQUEST_V2_STATUS_COMPLETE){
MsgDataReq* mdreq = dynamic_cast<MsgDataReq*>(req);
MsgDataReq* mdreq = dynamic_cast<MsgDataReq*>(req);
if(mdreq)
{
msgData = mdreq->mMsgData;
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE);
}else{
msgData = mdreq->mMsgData;
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE);
}
else
{
std::cerr << "RsGxsDataAccess::getMsgData() Req found, failed caste" << std::endl;
return false;
}
@ -440,6 +442,42 @@ bool RsGxsDataAccess::getMsgData(const uint32_t& token, NxsMsgDataResult& msgDat
return true;
}
bool RsGxsDataAccess::getMsgRelatedData(const uint32_t &token, NxsMsgRelatedDataResult &msgData)
{
RsStackMutex stack(mDataMutex);
GxsRequest* req = locked_retrieveRequest(token);
if(req == NULL){
std::cerr << "RsGxsDataAccess::getMsgRelatedData() Unable to retrieve group data" << std::endl;
return false;
}else if(req->status == GXS_REQUEST_V2_STATUS_COMPLETE){
MsgRelatedInfoReq* mrireq = dynamic_cast<MsgRelatedInfoReq*>(req);
if(req->Options.mReqType != GXS_REQUEST_TYPE_MSG_RELATED_DATA)
return false;
if(mrireq)
{
msgData = mrireq->mMsgDataResult;
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE);
}
else
{
std::cerr << "RsGxsDataAccess::getMsgRelatedData() Req found, failed caste" << std::endl;
return false;
}
}else{
std::cerr << "RsGxsDataAccess::getMsgRelatedData() Req not ready" << std::endl;
return false;
}
return true;
}
bool RsGxsDataAccess::getMsgSummary(const uint32_t& token, GxsMsgMetaResult& msgInfo)
{
@ -457,10 +495,12 @@ bool RsGxsDataAccess::getMsgSummary(const uint32_t& token, GxsMsgMetaResult& msg
if(mmreq)
{
msgInfo = mmreq->mMsgMetaData;
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE);
msgInfo = mmreq->mMsgMetaData;
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE);
}else{
}
else
{
std::cerr << "RsGxsDataAccess::getMsgSummary() Req found, failed caste" << std::endl;
return false;
}
@ -472,6 +512,83 @@ bool RsGxsDataAccess::getMsgSummary(const uint32_t& token, GxsMsgMetaResult& msg
return true;
}
bool RsGxsDataAccess::getMsgRelatedSummary(const uint32_t &token, MsgRelatedMetaResult &msgMeta)
{
RsStackMutex stack(mDataMutex);
GxsRequest* req = locked_retrieveRequest(token);
if(req == NULL){
std::cerr << "RsGxsDataAccess::getMsgRelatedSummary() Unable to retrieve message summary" << std::endl;
return false;
}else if(req->status == GXS_REQUEST_V2_STATUS_COMPLETE){
if(req->Options.mReqType != GXS_REQUEST_TYPE_MSG_RELATED_META)
return false;
MsgRelatedInfoReq* mrireq = dynamic_cast<MsgRelatedInfoReq*>(req);
if(mrireq)
{
msgMeta = mrireq->mMsgMetaResult;
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE);
}
else
{
std::cerr << "RsGxsDataAccess::getMsgRelatedSummary() Req found, failed caste" << std::endl;
return false;
}
}
else
{
std::cerr << "RsGxsDataAccess::getMsgRelatedSummary() Req not ready" << std::endl;
return false;
}
return true;
}
bool RsGxsDataAccess::getMsgRelatedList(const uint32_t &token, MsgRelatedIdResult &msgIds)
{
RsStackMutex stack(mDataMutex);
GxsRequest* req = locked_retrieveRequest(token);
if(req == NULL){
std::cerr << "RsGxsDataAccess::getMsgRelatedList() Unable to retrieve message data" << std::endl;
return false;
}else if(req->status == GXS_REQUEST_V2_STATUS_COMPLETE){
if(req->Options.mReqType != GXS_REQUEST_TYPE_MSG_RELATED_IDS)
return false;
MsgRelatedInfoReq* mrireq = dynamic_cast<MsgRelatedInfoReq*>(req);
if(mrireq)
{
msgIds = mrireq->mMsgIdResult;
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE);
}
else{
std::cerr << "RsGxsDataAccess::getMsgRelatedList() Req found, failed caste" << std::endl;
return false;
}
}
else
{
std::cerr << "RsGxsDataAccess::getMsgRelatedList() Req not ready" << std::endl;
return false;
}
return true;
}
bool RsGxsDataAccess::getMsgList(const uint32_t& token, GxsMsgIdResult& msgIds)
{
RsStackMutex stack(mDataMutex);
@ -480,23 +597,17 @@ bool RsGxsDataAccess::getMsgList(const uint32_t& token, GxsMsgIdResult& msgIds)
if(req == NULL){
std::cerr << "RsGxsDataAccess::getMsgList() Unable to retrieve group data" << std::endl;
std::cerr << "RsGxsDataAccess::getMsgList() Unable to retrieve msg Ids" << std::endl;
return false;
}else if(req->status == GXS_REQUEST_V2_STATUS_COMPLETE){
MsgIdReq* mireq = dynamic_cast<MsgIdReq*>(req);
MsgRelatedInfoReq* mrireq = dynamic_cast<MsgRelatedInfoReq*>(req);
MsgIdReq* mireq = dynamic_cast<MsgIdReq*>(req);
if(mireq)
{
msgIds = mireq->mMsgIdResult;
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE);
}
else if(mrireq)
{
msgIds = mrireq->mMsgIdResult;
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE);
}
else{
std::cerr << "RsGxsDataAccess::getMsgList() Req found, failed caste" << std::endl;
return false;
@ -517,7 +628,7 @@ bool RsGxsDataAccess::getGroupList(const uint32_t& token, std::list<RsGxsGroupId
if(req == NULL){
std::cerr << "RsGxsDataAccess::getGroupList() Unable to retrieve group data,"
std::cerr << "RsGxsDataAccess::getGroupList() Unable to retrieve group Ids,"
"\nRequest does not exist" << std::endl;
return false;
}else if(req->status == GXS_REQUEST_V2_STATUS_COMPLETE){
@ -1007,159 +1118,185 @@ bool RsGxsDataAccess::getMsgRelatedInfo(MsgRelatedInfoReq *req)
return true;
}
MsgMetaFilter filterMap;
std::vector<RsGxsGrpMsgIdPair>::iterator vit_msgIds = req->mMsgIds.begin();
// get meta data for all in group
GxsMsgMetaResult result;
GxsMsgReq msgIds;
msgIds.insert(std::make_pair(req->mMsgId.first, std::vector<RsGxsMessageId>()));
mDataStore->retrieveGxsMsgMetaData(msgIds, result);
std::vector<RsGxsMsgMetaData*>& metaV = result[req->mMsgId.first];
std::vector<RsGxsMsgMetaData*>::iterator vit_meta;
// msg id to relate to
const RsGxsMessageId& msgId = req->mMsgId.second;
const RsGxsGroupId& grpId = req->mMsgId.first;
std::vector<RsGxsMessageId> outMsgIds;
RsGxsMsgMetaData* origMeta = NULL;
for(vit_meta = metaV.begin(); vit_meta != metaV.end(); vit_meta++)
for(; vit_msgIds != req->mMsgIds.end(); vit_msgIds++)
{
RsGxsMsgMetaData* meta = *vit_meta;
MsgMetaFilter filterMap;
if(msgId == meta->mMsgId)
const RsGxsGrpMsgIdPair& grpMsgIdPair = *vit_msgIds;
// get meta data for all in group
GxsMsgMetaResult result;
GxsMsgReq msgIds;
msgIds.insert(std::make_pair(grpMsgIdPair.first, std::vector<RsGxsMessageId>()));
mDataStore->retrieveGxsMsgMetaData(msgIds, result);
std::vector<RsGxsMsgMetaData*>& metaV = result[grpMsgIdPair.first];
std::vector<RsGxsMsgMetaData*>::iterator vit_meta;
// msg id to relate to
const RsGxsMessageId& msgId = grpMsgIdPair.second;
const RsGxsGroupId& grpId = grpMsgIdPair.first;
std::vector<RsGxsMessageId> outMsgIds;
RsGxsMsgMetaData* origMeta = NULL;
for(vit_meta = metaV.begin(); vit_meta != metaV.end(); vit_meta++)
{
origMeta = meta;
break;
}
}
RsGxsMsgMetaData* meta = *vit_meta;
if(!origMeta)
{
std::cerr << "RsGxsDataAccess::getMsgRelatedInfo(): Cannot find meta of msgId (to relate to)!"
<< std::endl;
cleanseMsgMetaMap(result);
return false;
}
const RsGxsMessageId& origMsgId = origMeta->mOrigMsgId;
std::map<RsGxsMessageId, RsGxsMsgMetaData*>& metaMap = filterMap[grpId];
if (onlyLatestMsgs)
{
if (onlyChildMsgs || onlyThreadMsgs)
{
// RUN THROUGH ALL MSGS... in map origId -> TS.
std::map<std::string, std::pair<std::string, time_t> > origMsgTs;
std::map<std::string, std::pair<std::string, time_t> >::iterator oit;
for(vit_meta = metaV.begin(); vit_meta != metaV.end(); vit_meta++)
if(msgId == meta->mMsgId)
{
origMeta = meta;
break;
}
}
RsGxsMsgMetaData* meta = *vit_meta;
if(!origMeta)
{
std::cerr << "RsGxsDataAccess::getMsgRelatedInfo(): Cannot find meta of msgId (to relate to)!"
<< std::endl;
cleanseMsgMetaMap(result);
return false;
}
// skip msgs that aren't children.
if (onlyChildMsgs)
const RsGxsMessageId& origMsgId = origMeta->mOrigMsgId;
std::map<RsGxsMessageId, RsGxsMsgMetaData*>& metaMap = filterMap[grpId];
if (onlyLatestMsgs)
{
if (onlyChildMsgs || onlyThreadMsgs)
{
// RUN THROUGH ALL MSGS... in map origId -> TS.
std::map<std::string, std::pair<std::string, time_t> > origMsgTs;
std::map<std::string, std::pair<std::string, time_t> >::iterator oit;
for(vit_meta = metaV.begin(); vit_meta != metaV.end(); vit_meta++)
{
if (meta->mParentId != origMsgId)
RsGxsMsgMetaData* meta = *vit_meta;
// skip msgs that aren't children.
if (onlyChildMsgs)
{
continue;
if (meta->mParentId != origMsgId)
{
continue;
}
}
}
else /* onlyThreadMsgs */
{
if (meta->mThreadId != msgId)
else /* onlyThreadMsgs */
{
continue;
if (meta->mThreadId != msgId)
{
continue;
}
}
oit = origMsgTs.find(meta->mOrigMsgId);
bool addMsg = false;
if (oit == origMsgTs.end())
{
std::cerr << "RsGxsDataAccess::getMsgRelatedList() Found New OrigMsgId: ";
std::cerr << meta->mOrigMsgId;
std::cerr << " MsgId: " << meta->mMsgId;
std::cerr << " TS: " << meta->mPublishTs;
std::cerr << std::endl;
addMsg = true;
}
// check timestamps.
else if (oit->second.second < meta->mPublishTs)
{
std::cerr << "RsGxsDataAccess::getMsgRelatedList() Found Later Msg. OrigMsgId: ";
std::cerr << meta->mOrigMsgId;
std::cerr << " MsgId: " << meta->mMsgId;
std::cerr << " TS: " << meta->mPublishTs;
addMsg = true;
}
if (addMsg)
{
// add as latest. (overwriting if necessary)
origMsgTs[meta->mOrigMsgId] = std::make_pair(meta->mMsgId, meta->mPublishTs);
metaMap.insert(std::make_pair(meta->mOrigMsgId, meta));
}
}
oit = origMsgTs.find(meta->mOrigMsgId);
bool addMsg = false;
if (oit == origMsgTs.end())
// Add the discovered Latest Msgs.
for(oit = origMsgTs.begin(); oit != origMsgTs.end(); oit++)
{
std::cerr << "RsGxsDataAccess::getMsgRelatedList() Found New OrigMsgId: ";
std::cerr << meta->mOrigMsgId;
std::cerr << " MsgId: " << meta->mMsgId;
std::cerr << " TS: " << meta->mPublishTs;
std::cerr << std::endl;
addMsg = true;
}
// check timestamps.
else if (oit->second.second < meta->mPublishTs)
{
std::cerr << "RsGxsDataAccess::getMsgRelatedList() Found Later Msg. OrigMsgId: ";
std::cerr << meta->mOrigMsgId;
std::cerr << " MsgId: " << meta->mMsgId;
std::cerr << " TS: " << meta->mPublishTs;
addMsg = true;
}
if (addMsg)
{
// add as latest. (overwriting if necessary)
origMsgTs[meta->mOrigMsgId] = std::make_pair(meta->mMsgId, meta->mPublishTs);
metaMap.insert(std::make_pair(meta->mOrigMsgId, meta));
outMsgIds.push_back(oit->second.first);
}
}
// Add the discovered Latest Msgs.
for(oit = origMsgTs.begin(); oit != origMsgTs.end(); oit++)
else
{
outMsgIds.push_back(oit->second.first);
/* first guess is potentially better than Orig (can't be worse!) */
time_t latestTs = 0;
RsGxsMessageId latestMsgId;
RsGxsMsgMetaData* latestMeta;
for(vit_meta = metaV.begin(); vit_meta != metaV.end(); vit_meta++)
{
RsGxsMsgMetaData* meta = *vit_meta;
if (meta->mOrigMsgId == origMsgId)
{
if (meta->mPublishTs > latestTs)
{
latestTs = meta->mPublishTs;
latestMsgId = meta->mMsgId;
latestMeta = meta;
}
}
}
outMsgIds.push_back(latestMsgId);
metaMap.insert(std::make_pair(latestMsgId, latestMeta));
}
}
else
else if (onlyAllVersions)
{
/* first guess is potentially better than Orig (can't be worse!) */
time_t latestTs = 0;
RsGxsMessageId latestMsgId;
RsGxsMsgMetaData* latestMeta;
for(vit_meta = metaV.begin(); vit_meta != metaV.end(); vit_meta++)
{
RsGxsMsgMetaData* meta = *vit_meta;
if (meta->mOrigMsgId == origMsgId)
{
if (meta->mPublishTs > latestTs)
{
latestTs = meta->mPublishTs;
latestMsgId = meta->mMsgId;
latestMeta = meta;
}
outMsgIds.push_back(meta->mMsgId);
metaMap.insert(std::make_pair(meta->mMsgId, meta));
}
}
outMsgIds.push_back(latestMsgId);
metaMap.insert(std::make_pair(latestMsgId, latestMeta));
}
}
else if (onlyAllVersions)
{
for(vit_meta = metaV.begin(); vit_meta != metaV.end(); vit_meta++)
GxsMsgIdResult filteredOutMsgIds;
filteredOutMsgIds[grpId] = outMsgIds;
filterMsgList(filteredOutMsgIds, opts, filterMap);
if(req->Options.mReqType == GXS_REQUEST_TYPE_MSG_RELATED_IDS)
{
RsGxsMsgMetaData* meta = *vit_meta;
if (meta->mOrigMsgId == origMsgId)
{
outMsgIds.push_back(meta->mMsgId);
metaMap.insert(std::make_pair(meta->mOrigMsgId, meta));
}
req->mMsgIdResult[grpMsgIdPair] = filteredOutMsgIds[grpId];
}
else if(req->Options.mReqType == GXS_REQUEST_TYPE_MSG_RELATED_META)
{
GxsMsgMetaResult metaResult;
mDataStore->retrieveGxsMsgMetaData(filteredOutMsgIds, metaResult);
req->mMsgMetaResult[grpMsgIdPair] = metaResult[grpId];
}
else if(req->Options.mReqType == GXS_REQUEST_TYPE_MSG_RELATED_DATA)
{
GxsMsgResult msgResult;
mDataStore->retrieveNxsMsgs(filteredOutMsgIds, msgResult, false, true);
req->mMsgDataResult[grpMsgIdPair] = msgResult[grpId];
}
outMsgIds.clear();
filteredOutMsgIds.clear();
cleanseMsgMetaMap(result);
}
req->mMsgIdResult[grpId] = outMsgIds;
filterMsgList(req->mMsgIdResult, opts, filterMap);
cleanseMsgMetaMap(result);
return true;
}

View File

@ -90,7 +90,7 @@ public:
* @param groupIds The ids of the groups to get, second entry of map empty to query for all msgs
* @return true if request successful false otherwise
*/
bool requestMsgRelatedInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const RsGxsGrpMsgIdPair &msgIds);
bool requestMsgRelatedInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::vector<RsGxsGrpMsgIdPair> &msgIds);
/* Poll */
uint32_t requestStatus(const uint32_t token);
@ -143,6 +143,14 @@ public:
*/
bool getMsgList(const uint32_t &token, GxsMsgIdResult &msgIds);
/*!
* Retrieve msg list for a given token for message related info
* @param token token to be redeemed
* @param msgIds a map of RsGxsGrpMsgIdPair -> msgList (vector)
* @return false if could not redeem token
*/
bool getMsgRelatedList(const uint32_t &token, MsgRelatedIdResult& msgIds);
/*!
* @param token request token to be redeemed
@ -157,6 +165,15 @@ public:
*/
bool getMsgSummary(const uint32_t &token, GxsMsgMetaResult &msgInfo);
/*!
* Retrieve msg meta for a given token for message related info
* @param token token to be redeemed
* @param msgIds a map of RsGxsGrpMsgIdPair -> msgList (vector)
* @return false if could not redeem token
*/
bool getMsgRelatedSummary(const uint32_t &token, MsgRelatedMetaResult& msgMeta);
/*!
*
* @param token request token to be redeemed
@ -172,6 +189,14 @@ public:
*/
bool getMsgData(const uint32_t &token, NxsMsgDataResult& msgData);
/*!
*
* @param token request token to be redeemed
* @param msgData
* @return false if data cannot be found for token
*/
bool getMsgRelatedData(const uint32_t &token, NxsMsgRelatedDataResult& msgData);
private:
/** helper functions to implement token service **/

View File

@ -120,6 +120,11 @@ bool RsGxsIfaceImpl::getMsgList(const uint32_t &token,
return mGxs->getMsgList(token, msgIds);
}
bool RsGxsIfaceImpl::getMsgRelatedList(const uint32_t &token, MsgRelatedIdResult &msgIds)
{
return mGxs->getMsgRelatedList(token, msgIds);
}
/* Generic Summary */
bool RsGxsIfaceImpl::getGroupSummary(const uint32_t &token,
std::list<RsGroupMetaData> &groupInfo)
@ -135,6 +140,13 @@ bool RsGxsIfaceImpl::getMsgSummary(const uint32_t &token,
return mGxs->getMsgMeta(token, msgInfo);
}
bool RsGxsIfaceImpl::getMsgrelatedSummary(const uint32_t &token, GxsMsgRelatedMetaMap &msgInfo)
{
return mGxs->getMsgRelatedMeta(token, msgInfo);
}
bool RsGxsIfaceImpl::subscribeToGroup(uint32_t& token, const RsGxsGroupId& grpId, bool subscribe)
{
if(subscribe)

View File

@ -108,6 +108,15 @@ public:
bool getMsgList(const uint32_t &token,
GxsMsgIdResult& msgIds);
/*!
* Retrieves list of msg related ids associated to a request token
* @param token token to be redeemed for this request
* @param msgIds the ids return for given request token
* @return false if request token is invalid, check token status for error report
*/
bool getMsgRelatedList(const uint32_t &token,
MsgRelatedIdResult& msgIds);
/*!
* @param token token to be redeemed for group summary request
* @param groupInfo the ids returned for given request token
@ -124,6 +133,14 @@ public:
bool getMsgSummary(const uint32_t &token,
GxsMsgMetaMap &msgInfo);
/*!
* @param token token to be redeemed for message related summary request
* @param msgInfo the message metadata returned for given request token
* @return false if request token is invalid, check token status for error report
*/
bool getMsgrelatedSummary(const uint32_t &token,
GxsMsgRelatedMetaMap &msgInfo);
/*!
* subscribes to group, and returns token which can be used
* to be acknowledged to get group Id

View File

@ -100,8 +100,10 @@ class MsgRelatedInfoReq : public GxsRequest
{
public:
RsGxsGrpMsgIdPair mMsgId;
GxsMsgIdResult mMsgIdResult;
std::vector<RsGxsGrpMsgIdPair> mMsgIds;
MsgRelatedIdResult mMsgIdResult;
MsgRelatedMetaResult mMsgMetaResult;
NxsMsgRelatedDataResult mMsgDataResult;
};
class GroupSetFlagReq : public GxsRequest

View File

@ -40,6 +40,10 @@
#define GXS_REQUEST_TYPE_MSG_META 0x00100000
#define GXS_REQUEST_TYPE_MSG_IDS 0x00200000
#define GXS_REQUEST_TYPE_MSG_RELATED_DATA 0x00400000
#define GXS_REQUEST_TYPE_MSG_RELATED_META 0x00800000
#define GXS_REQUEST_TYPE_MSG_RELATED_IDS 0x01000000
// This bit will be filled out over time.
@ -171,7 +175,7 @@ public:
* @param groupIds The ids of the groups to get, second entry of map empty to query for all msgs
* @return true if request successful false otherwise
*/
virtual bool requestMsgRelatedInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const RsGxsGrpMsgIdPair& msgIds) = 0;
virtual bool requestMsgRelatedInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::vector<RsGxsGrpMsgIdPair>& msgIds) = 0;
/* Poll */

View File

@ -153,11 +153,16 @@ class RsPhotoAlbum
uint32_t mModFlags;
};
class RsGxsPhotoCommentItem;
class RsPhotoComment
{
public:
RsPhotoComment();
RsPhotoComment(const RsGxsPhotoCommentItem& comment);
RsPhotoComment& operator=(const RsGxsPhotoCommentItem& comment);
RsMsgMetaData mMeta;
std::string mComment;
@ -169,6 +174,7 @@ std::ostream &operator<<(std::ostream &out, const RsPhotoAlbum &album);
typedef std::map<RsGxsGroupId, std::vector<RsPhotoPhoto> > PhotoResult;
typedef std::map<RsGxsGroupId, std::vector<RsPhotoComment> > PhotoCommentResult;
typedef std::map<RsGxsGrpMsgIdPair, std::vector<RsPhotoComment> > PhotoRelatedCommentResult;
class RsPhotoV2
{
@ -273,6 +279,12 @@ public:
*/
virtual bool getPhotoComment(const uint32_t &token,
PhotoCommentResult& comments) = 0;
/*!
* @param token token to be redeemed for photo request
* @param photo the photo returned for given request token
* @return false if request token is invalid, check token status for error report
*/
virtual bool getPhotoRelatedComment(const uint32_t &token, PhotoRelatedCommentResult &comments) = 0;
/*!
* submits album, which returns a token that needs

View File

@ -62,6 +62,13 @@ RsPhotoComment::RsPhotoComment()
}
RsPhotoComment::RsPhotoComment(const RsGxsPhotoCommentItem &comment)
: mComment(""), mCommentFlag(0) {
*this = comment.comment;
(*this).mMeta = comment.meta;
}
std::ostream &operator<<(std::ostream &out, const RsPhotoPhoto &photo)
{
out << "RsPhotoPhoto [ ";
@ -247,39 +254,52 @@ bool p3PhotoServiceV2::getPhoto(const uint32_t& token, PhotoResult& photos)
bool p3PhotoServiceV2::getPhotoComment(const uint32_t &token, PhotoCommentResult &comments)
{
GxsMsgDataMap msgData;
bool ok = RsGenExchange::getMsgData(token, msgData);
GxsMsgDataMap msgData;
bool ok = RsGenExchange::getMsgData(token, msgData);
if(ok)
if(ok)
{
GxsMsgDataMap::iterator mit = msgData.begin();
for(; mit != msgData.end(); mit++)
{
GxsMsgDataMap::iterator mit = msgData.begin();
RsGxsGroupId grpId = mit->first;
std::vector<RsGxsMsgItem*>& msgItems = mit->second;
std::vector<RsGxsMsgItem*>::iterator vit = msgItems.begin();
for(; mit != msgData.end(); mit++)
for(; vit != msgItems.end(); vit++)
{
RsGxsPhotoCommentItem* item = dynamic_cast<RsGxsPhotoCommentItem*>(*vit);
if(item)
{
RsGxsGroupId grpId = mit->first;
std::vector<RsGxsMsgItem*>& msgItems = mit->second;
std::vector<RsGxsMsgItem*>::iterator vit = msgItems.begin();
for(; vit != msgItems.end(); vit++)
{
RsGxsPhotoCommentItem* item = dynamic_cast<RsGxsPhotoCommentItem*>(*vit);
if(item)
{
RsPhotoComment comment = item->comment;
comment.mMeta = item->meta;
comments[grpId].push_back(comment);
delete item;
}else
{
std::cerr << "Not a comment Item, deleting!" << std::endl;
delete *vit;
}
}
RsPhotoComment comment = item->comment;
comment.mMeta = item->meta;
comments[grpId].push_back(comment);
delete item;
}else
{
std::cerr << "Not a comment Item, deleting!" << std::endl;
delete *vit;
}
}
}
}
return ok;
}
RsPhotoComment& RsPhotoComment::operator=(const RsGxsPhotoCommentItem& comment)
{
*this = comment.comment;
return *this;
}
bool p3PhotoServiceV2::getPhotoRelatedComment(const uint32_t &token, PhotoRelatedCommentResult &comments)
{
return RsGenExchange::getMsgRelatedDataT<RsGxsPhotoCommentItem, RsPhotoComment>(token, comments);
return ok;
}
bool p3PhotoServiceV2::submitAlbumDetails(uint32_t& token, RsPhotoAlbum& album)

View File

@ -29,7 +29,6 @@
#include "gxs/rsgenexchange.h"
#include "retroshare/rsphotoV2.h"
class p3PhotoServiceV2 : public RsPhotoV2, public RsGenExchange
{
public:
@ -80,6 +79,7 @@ public:
bool getAlbum(const uint32_t &token, std::vector<RsPhotoAlbum> &albums);
bool getPhoto(const uint32_t &token, PhotoResult &photos);
bool getPhotoComment(const uint32_t &token, PhotoCommentResult &comments);
bool getPhotoRelatedComment(const uint32_t &token, PhotoRelatedCommentResult &comments);
public:

View File

@ -3,7 +3,6 @@
#include "gxs/rsdataservice.h"
#include "gxs/rsgxsflags.h"
GenExchangeTester::GenExchangeTester()
: mGenTestMutex("genTest")
{
@ -15,24 +14,28 @@ void GenExchangeTester::setUp()
{
mDataStore = new RsDataService("./", "testServiceDb", RS_SERVICE_TYPE_DUMMY, NULL);
mNxs = new RsDummyNetService();
mTestService = new GenExchangeTestService(mDataStore, mNxs);
mGxsCore.addService(mTestService);
RsGixsDummy* gixsDummy = new RsGixsDummy("incoming", "outgoing");
mTestService = new GenExchangeTestService(mDataStore, mNxs, gixsDummy, 0);
mTokenService = mTestService->getTokenService();
mGxsCore.start();
mTestService->start();
}
void GenExchangeTester::setUpGrps()
void GenExchangeTester::setUpGrps(uint32_t grpFlags)
{
// create some random grps to allow msg testing
RsDummyGrp* dgrp1 = new RsDummyGrp();
RsDummyGrp* dgrp2 = new RsDummyGrp();
RsDummyGrp* dgrp3 = new RsDummyGrp();
init(dgrp1);
dgrp1->meta.mGroupFlags = grpFlags;
uint32_t token;
mTestService->publishDummyGrp(token, dgrp1);
RsTokReqOptionsV2 opts;
RsTokReqOptions opts;
opts.mReqType = 45000;
pollForToken(token, opts);
@ -40,11 +43,15 @@ void GenExchangeTester::setUpGrps()
mTestService->acknowledgeTokenGrp(token, grpId);
mRandGrpIds.push_back(grpId);
init(dgrp2);
dgrp2->meta.mGroupFlags = grpFlags;
mTestService->publishDummyGrp(token, dgrp2);
pollForToken(token, opts);
mTestService->acknowledgeTokenGrp(token, grpId);
mRandGrpIds.push_back(grpId);
init(dgrp3);
dgrp3->meta.mGroupFlags = grpFlags;
mTestService->publishDummyGrp(token, dgrp3);
pollForToken(token, opts);
mTestService->acknowledgeTokenGrp(token, grpId);
@ -54,10 +61,8 @@ void GenExchangeTester::setUpGrps()
void GenExchangeTester::breakDown()
{
mTestService->join();
mGxsCore.join(); // indicate server to stop
mGxsCore.removeService(mTestService);
delete mTestService;
// a bit protracted, but start a new db and use to clear up junk
@ -147,7 +152,7 @@ bool GenExchangeTester::testGrpSubmissionRetrieval()
init(dgrp2);
init(dgrp3);
RsTokReqOptionsV2 opts;
RsTokReqOptions opts;
opts.mReqType = 45000;
uint32_t token;
RsGxsGroupId grpId;
@ -240,7 +245,7 @@ bool GenExchangeTester::testGrpMetaRetrieval()
init(dgrp2);
init(dgrp3);
RsTokReqOptionsV2 opts;
RsTokReqOptions opts;
opts.mReqType = 45000;
uint32_t token;
RsGxsGroupId grpId;
@ -316,7 +321,7 @@ bool GenExchangeTester::testGrpIdRetrieval()
setUpLargeGrps(30); // create a large amount of grps
RsTokReqOptionsV2 opts;
RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_GROUP_IDS;
uint32_t token;
std::list<RsGxsGroupId> grpIds;
@ -369,7 +374,7 @@ bool GenExchangeTester::testGrpMetaModRequest()
init(dgrp3);
uint32_t token;
RsTokReqOptionsV2 opts;
RsTokReqOptions opts;
opts.mReqType = 45000;
std::vector<RsGxsGroupId> grpIds;
RsGxsGroupId grpId;
@ -449,7 +454,7 @@ void GenExchangeTester::setUpLargeGrps(uint32_t nGrps)
RsGxsGroupId grpId;
uint32_t token;
init(dgrp);
RsTokReqOptionsV2 opts;
RsTokReqOptions opts;
opts.mReqType = 4000;
mTestService->publishDummyGrp(token, dgrp);
pollForToken(token, opts);
@ -473,7 +478,7 @@ bool GenExchangeTester::testMsgMetaModRequest()
mTestService->publishDummyMsg(token, msg);
// poll will block until found
RsTokReqOptionsV2 opts;
RsTokReqOptions opts;
opts.mReqType = 4200;
pollForToken(token, opts);
RsGxsGrpMsgIdPair msgId;
@ -554,7 +559,7 @@ bool GenExchangeTester::testMsgSubmissionRetrieval()
// start up
setUp();
setUpGrps();
setUpGrps(GXS_SERV::FLAG_PRIVACY_PUBLIC);
/********************/
@ -568,8 +573,8 @@ bool GenExchangeTester::testMsgSubmissionRetrieval()
mTestService->publishDummyMsg(token, msg);
// poll will block until found
RsTokReqOptionsV2 opts;
opts.mReqType = 4200;
RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
pollForToken(token, opts);
RsGxsGrpMsgIdPair msgId;
@ -644,7 +649,7 @@ bool GenExchangeTester::testMsgIdRetrieval()
// start up
setUp();
setUpGrps();
setUpGrps(GXS_SERV::FLAG_PRIVACY_PUBLIC);
/********************/
@ -656,7 +661,7 @@ bool GenExchangeTester::testMsgIdRetrieval()
int nMsgs = (rand()%121)+2; // test a large number of msgs
std::vector<RsDummyMsg*> msgs;
createMsgs(msgs, nMsgs);
RsTokReqOptionsV2 opts;
RsTokReqOptions opts;
opts.mReqType = 4000;
uint32_t token;
@ -725,14 +730,13 @@ bool GenExchangeTester::testMsgIdRetrieval()
return true;
}
bool GenExchangeTester::testMsgChildRetrieval()
bool GenExchangeTester::testMsgAllVersions()
{
// start up
setUp();
setUpGrps();
setUpGrps(GXS_SERV::FLAG_PRIVACY_PUBLIC);
/********************/
// want to create several msgs of the same version (i.e. same origMsgId)
// create msgs
@ -741,31 +745,27 @@ bool GenExchangeTester::testMsgChildRetrieval()
int nMsgs = (rand()%50)+2; // test a large number of msgs
std::vector<RsDummyMsg*> msgs;
createMsgs(msgs, nMsgs);
RsTokReqOptionsV2 opts;
RsTokReqOptions opts;
opts.mReqType = 4000;
uint32_t token;
bool first = true;
RsGxsGrpMsgIdPair firstMsgId;
// everyone is parent of first msg
// everyone is a version of first msg
for(int i=0; i < nMsgs; i++)
{
RsDummyMsg* msg = msgs[i];
int j = rand()%5;
if(first){
msg->meta.mParentId = "";
msg->meta.mOrigMsgId = "";
msg->meta.mOrigMsgId = ""; // don't worry GXS sets origid to first
}
else
{
msg->meta.mParentId = firstMsgId.second;
msg->meta.mParentId = "";
msg->meta.mGroupId = firstMsgId.first;
msg->meta.mOrigMsgId = "";
msg->meta.mOrigMsgId = firstMsgId.second;
}
mTestService->publishDummyMsg(token, msg);
@ -773,13 +773,6 @@ bool GenExchangeTester::testMsgChildRetrieval()
RsGxsGrpMsgIdPair msgId;
mTestService->acknowledgeTokenMsg(token, msgId);
// less than half have no parents
if(first){
firstMsgId.second = msgId.second;
firstMsgId.first = msgId.first;
}
if(msgId.first.empty() || msgId.second.empty())
{
breakDown();
@ -787,23 +780,30 @@ bool GenExchangeTester::testMsgChildRetrieval()
return false;
}
if(!first)
{
mMsgIdsOut[msgId.first].push_back(msgId.second);
// less than half have no parents
if(first){
firstMsgId.second = msgId.second;
firstMsgId.first = msgId.first;
first = false;
}
mMsgRelatedIdsOut[firstMsgId].push_back(msgId.second);
}
opts.mReqType = GXS_REQUEST_TYPE_MSG_IDS;
opts.mOptions = RS_TOKREQOPT_MSG_PARENT | RS_TOKREQOPT_MSG_LATEST;
mTokenService->requestMsgRelatedInfo(token, 0, opts, firstMsgId);
opts.mReqType = GXS_REQUEST_TYPE_MSG_RELATED_IDS;
opts.mOptions = RS_TOKREQOPT_MSG_VERSIONS;
std::vector<RsGxsGrpMsgIdPair> msgIdList;
msgIdList.push_back(firstMsgId);
mTokenService->requestMsgRelatedInfo(token, 0, opts, msgIdList);
pollForToken(token, opts);
GxsMsgIdResult::iterator mit = mMsgIdsOut.begin();
for(; mit != mMsgIdsOut.end(); mit++)
MsgRelatedIdResult::iterator mit = mMsgRelatedIdsOut.begin();
for(; mit != mMsgRelatedIdsOut.end(); mit++)
{
std::vector<RsGxsMessageId> msgIdsOut, msgIdsIn;
msgIdsOut = mit->second;
@ -813,7 +813,7 @@ bool GenExchangeTester::testMsgChildRetrieval()
for(; vit_out != msgIdsOut.end(); vit_out++)
{
bool found = false;
msgIdsIn = mMsgIdsIn[mit->first];
msgIdsIn = mMsgRelatedIdsIn[mit->first];
vit_in = msgIdsIn.begin();
for(; vit_in != msgIdsIn.end(); vit_in++)
@ -830,21 +830,129 @@ bool GenExchangeTester::testMsgChildRetrieval()
}
}
/********************/
// complete
breakDown();
return true;
}
bool GenExchangeTester::testMsgChildRetrieval()
{
// // start up
// setUp();
// setUpGrps(GXS_SERV::FLAG_PRIVACY_PUBLIC);
// /********************/
// // create msgs
// // then make all requests immediately then poll afterwards for each and run outbound test
// // we want only latest for now
// int nMsgs = (rand()%50)+2; // test a large number of msgs
// std::vector<RsDummyMsg*> msgs;
// createMsgs(msgs, nMsgs);
// RsTokReqOptions opts;
// opts.mReqType = 4000;
// uint32_t token;
// bool first = true;
// RsGxsGrpMsgIdPair firstMsgId;
// // everyone is parent of first msg
// for(int i=0; i < nMsgs; i++)
// {
// RsDummyMsg* msg = msgs[i];
// if(first){
// msg->meta.mParentId = "";
// msg->meta.mOrigMsgId = "";
// }
// else
// {
// msg->meta.mParentId = firstMsgId.second;
// msg->meta.mGroupId = firstMsgId.first;
// msg->meta.mOrigMsgId = "";
// }
// mTestService->publishDummyMsg(token, msg);
// pollForToken(token, opts);
// RsGxsGrpMsgIdPair msgId;
// mTestService->acknowledgeTokenMsg(token, msgId);
// if(msgId.first.empty() || msgId.second.empty())
// {
// breakDown();
// std::cerr << "serious error: Acknowledgement failed! " << std::endl;
// return false;
// }
// if(!first)
// {
// mMsgIdsOut[msgId.first].push_back(msgId.second);
// }
// if(first){
// firstMsgId.second = msgId.second;
// firstMsgId.first = msgId.first;
// first = false;
// }
// }
// opts.mReqType = GXS_REQUEST_TYPE_MSG_IDS;
// opts.mOptions = RS_TOKREQOPT_MSG_PARENT | RS_TOKREQOPT_MSG_LATEST;
// std::vector<RsGxsGrpMsgIdPair> msgIdList;
// msgIdList.push_back(firstMsgId);
// mTokenService->requestMsgRelatedInfo(token, 0, opts, msgIdList);
// pollForToken(token, opts);
// GxsMsgIdResult::iterator mit = mMsgIdsOut.begin();
// for(; mit != mMsgIdsOut.end(); mit++)
// {
// std::vector<RsGxsMessageId> msgIdsOut, msgIdsIn;
// msgIdsOut = mit->second;
// std::vector<RsGxsMessageId>::iterator vit_out = msgIdsOut.begin(), vit_in;
// for(; vit_out != msgIdsOut.end(); vit_out++)
// {
// bool found = false;
// msgIdsIn = mMsgIdsIn[mit->first];
// vit_in = msgIdsIn.begin();
// for(; vit_in != msgIdsIn.end(); vit_in++)
// {
// if(*vit_in == *vit_out)
// found = true;
// }
// if(!found){
// breakDown();
// return false;
// }
// }
// }
// /********************/
// // complete
// breakDown();
// return true;
}
bool GenExchangeTester::testSpecificMsgMetaRetrieval()
{
// start up
setUp();
setUpGrps();
setUpGrps(GXS_SERV::FLAG_PRIVACY_PUBLIC);
/********************/
@ -858,7 +966,7 @@ bool GenExchangeTester::testSpecificMsgMetaRetrieval()
mTestService->publishDummyMsg(token, msg);
// poll will block until found
RsTokReqOptionsV2 opts;
RsTokReqOptions opts;
opts.mReqType = 4200;
pollForToken(token, opts);
RsGxsGrpMsgIdPair msgId;
@ -955,7 +1063,7 @@ bool GenExchangeTester::testMsgIdRetrieval_OptParents()
int nMsgs = (rand()%50)+2; // test a large number of msgs
std::vector<RsDummyMsg*> msgs;
createMsgs(msgs, nMsgs);
RsTokReqOptionsV2 opts;
RsTokReqOptions opts;
opts.mReqType = 4000;
uint32_t token;
@ -1053,7 +1161,7 @@ bool GenExchangeTester::testMsgIdRetrieval_OptOrigMsgId()
int nMsgs = (rand()%50)+2; // test a large number of msgs
std::vector<RsDummyMsg*> msgs;
createMsgs(msgs, nMsgs);
RsTokReqOptionsV2 opts;
RsTokReqOptions opts;
opts.mReqType = 4000;
uint32_t token;
@ -1153,7 +1261,7 @@ bool GenExchangeTester::testMsgIdRetrieval_OptLatest()
int nMsgs = (rand()%50)+2; // test a large number of msgs
std::vector<RsDummyMsg*> msgs;
createMsgs(msgs, nMsgs);
RsTokReqOptionsV2 opts;
RsTokReqOptions opts;
opts.mReqType = 4000;
uint32_t token;
@ -1499,7 +1607,7 @@ void GenExchangeTester::init(RsDummyMsg *msgItem) const
init(msgItem->meta);
}
void GenExchangeTester::pollForToken(uint32_t token, const RsTokReqOptionsV2 &opts)
void GenExchangeTester::pollForToken(uint32_t token, const RsTokReqOptions &opts)
{
double timeDelta = 0.2;
@ -1511,8 +1619,8 @@ void GenExchangeTester::pollForToken(uint32_t token, const RsTokReqOptionsV2 &op
Sleep((int) (timeDelta * 1000));
#endif
if(RsTokenServiceV2::GXS_REQUEST_V2_STATUS_COMPLETE ==
mTokenService->requestStatus(token))
if((RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE == mTokenService->requestStatus(token))
|| (RsTokenService::GXS_REQUEST_V2_STATUS_FAILED == mTokenService->requestStatus(token)))
{
switch(opts.mReqType)
{
@ -1534,6 +1642,9 @@ void GenExchangeTester::pollForToken(uint32_t token, const RsTokReqOptionsV2 &op
case GXS_REQUEST_TYPE_MSG_IDS:
mTestService->getMsgListTS(token, mMsgIdsIn);
break;
case GXS_REQUEST_TYPE_MSG_RELATED_IDS:
mTestService->getMsgRelatedListTS(token, mMsgRelatedIdsIn);
break;
}
break;
}

View File

@ -21,10 +21,11 @@ class GenExchangeTester
{
public:
void pollForToken(uint32_t, const RsTokReqOptionsV2& opts);
void pollForToken(uint32_t, const RsTokReqOptions& opts);
GenExchangeTester();
// message tests
bool testMsgSubmissionRetrieval();
bool testMsgIdRetrieval();
bool testMsgIdRetrieval_OptParents();
@ -32,9 +33,12 @@ public:
bool testMsgIdRetrieval_OptLatest();
bool testSpecificMsgMetaRetrieval();
// request msg related tests
bool testMsgChildRetrieval();
bool testMsgAllVersions();
// group tests
bool testGrpSubmissionRetrieval();
bool testSpecificGrpRetrieval();
bool testGrpIdRetrieval();
@ -52,7 +56,7 @@ private:
void breakDown();
void setUpGrps(); // to be called at start of msg tests
void setUpGrps(uint32_t grpFlag=0); // to be called at start of msg tests
/*!
* Can be called at start grpId or grpMeta test
@ -92,17 +96,18 @@ private:
GxsMsgMetaMap mMsgMetaDataOut, mMsgMetaDataIn;
GxsMsgIdResult mMsgIdsOut, mMsgIdsIn;
MsgRelatedIdResult mMsgRelatedIdsOut, mMsgRelatedIdsIn;
std::vector<RsGxsGroupId> mRandGrpIds; // ids that exist to help group testing
private:
GenExchangeTestService* mTestService;
RsTokenServiceV2* mTokenService;
RsTokenService* mTokenService;
RsNetworkExchangeService* mNxs;
RsGeneralDataService* mDataStore;
GxsCoreServer mGxsCore;
};

View File

@ -1,7 +1,8 @@
#include "genexchangetestservice.h"
GenExchangeTestService::GenExchangeTestService(RsGeneralDataService *dataServ, RsNetworkExchangeService * netService)
: RsGenExchange(dataServ, netService, new RsDummySerialiser(), RS_SERVICE_TYPE_DUMMY)
GenExchangeTestService::GenExchangeTestService(RsGeneralDataService *dataServ, RsNetworkExchangeService * netService,
RsGixs* gixs, uint32_t authenPolicy)
: RsGenExchange(dataServ, netService, new RsDummySerialiser(), RS_SERVICE_TYPE_DUMMY, gixs, authenPolicy)
{
}
@ -51,6 +52,11 @@ bool GenExchangeTestService::getMsgListTS(const uint32_t &token, GxsMsgIdResult
return getMsgList(token, msgIds);
}
bool GenExchangeTestService::getMsgRelatedListTS(const uint32_t &token, MsgRelatedIdResult &msgIds)
{
return getMsgRelatedList(token, msgIds);
}
void GenExchangeTestService::setGroupServiceStringTS(uint32_t &token, const RsGxsGroupId &grpId, const std::string &servString)
{
RsGenExchange::setGroupServiceString(token, grpId, servString);
@ -58,12 +64,12 @@ void GenExchangeTestService::setGroupServiceStringTS(uint32_t &token, const RsGx
void GenExchangeTestService::setGroupStatusFlagTS(uint32_t &token, const RsGxsGroupId &grpId, const uint32_t &status)
{
RsGenExchange::setGroupStatusFlag(token, grpId, status);
RsGenExchange::setGroupStatusFlags(token, grpId, status, 0xff);
}
void GenExchangeTestService::setGroupSubscribeFlagTS(uint32_t &token, const RsGxsGroupId &grpId, const uint32_t &status)
{
RsGenExchange::setGroupSubscribeFlag(token, grpId, status);
RsGenExchange::setGroupSubscribeFlags(token, grpId, status, 0xff);
}
void GenExchangeTestService::setMsgServiceStringTS(uint32_t &token, const RsGxsGrpMsgIdPair &msgId, const std::string &servString)
@ -73,6 +79,10 @@ void GenExchangeTestService::setMsgServiceStringTS(uint32_t &token, const RsGxsG
void GenExchangeTestService::setMsgStatusFlagTS(uint32_t &token, const RsGxsGrpMsgIdPair &msgId, const uint32_t &status)
{
RsGenExchange::setMsgStatusFlag(token, msgId, status);
RsGenExchange::setMsgStatusFlags(token, msgId, status, 0xff);
}
void GenExchangeTestService::service_tick()
{
}

View File

@ -2,12 +2,13 @@
#define GENEXCHANGETESTSERVICE_H
#include "gxs/rsgenexchange.h"
#include "gxs/rsgxsifaceimpl.h"
#include "rsdummyservices.h"
class GenExchangeTestService : public RsGenExchange
{
public:
GenExchangeTestService(RsGeneralDataService* dataServ, RsNetworkExchangeService*);
GenExchangeTestService(RsGeneralDataService* dataServ, RsNetworkExchangeService*, RsGixs* gixs, uint32_t authenPolicy);
void notifyChanges(std::vector<RsGxsNotify*>& changes);
@ -59,6 +60,13 @@ public:
*/
bool getMsgDataTS(const uint32_t &token, GxsMsgDataMap& msgItems);
/*!
* Retrieve msg related list for a given token sectioned by group Ids
* @param token token to be redeemed
* @param msgIds a map of grpMsgIdPair -> msgList (vector)
*/
bool getMsgRelatedListTS(const uint32_t &token, MsgRelatedIdResult &msgIds);
void setGroupSubscribeFlagTS(uint32_t& token, const RsGxsGroupId& grpId, const uint32_t& status);
@ -70,6 +78,8 @@ public:
void setMsgServiceStringTS(uint32_t& token, const RsGxsGrpMsgIdPair& msgId, const std::string& servString );
void service_tick();
};
#endif // GENEXCHANGETESTSERVICE_H

View File

@ -15,13 +15,13 @@ CONFIG += gen_exchange_target
#CONFIG += dstore_target
#CONFIG += gxsdata_target
CONFIG += bitdht
gen_exchange_target {
TARGET = gen_exchange_test
#TARGET = gen_exchange_test
}
@ -33,7 +33,7 @@ TARGET = nxs_net_test
gxsdata_target {
TARGET = gxsdata_test
#TARGET = gxsdata_test
}
@ -130,7 +130,10 @@ win32 {
GPGME_DIR = ../../../../gpgme-1.1.8
GPG_ERROR_DIR = ../../../../lib/libgpg-error-1.7
GPGME_DIR = ../../../../lib/gpgme-1.1.8
INCLUDEPATH += . $${GPGME_DIR}/src $${GPG_ERROR_DIR}/src
SSL_DIR = ../../../../../OpenSSL
OPENPGPSDK_DIR = ../../../../openpgpsdk/src
INCLUDEPATH += . $${SSL_DIR}/include $${GPGME_DIR}/src $${GPG_ERROR_DIR}/src \
$${OPENPGPSDK_DIR}
SQLITE_DIR = ../../../../../../Libraries/sqlite/sqlite-autoconf-3070900
INCLUDEPATH += . \
@ -186,48 +189,6 @@ gen_exchange_target {
}
nxs_net_test {
SOURCES += \
support.cc \
nxstesthub.cc \
rsgxsnetservice_test.cc \
nxstestscenario.cc \
data_support.cc
HEADERS += support.h \
nxstesthub.h \
rsgxsnetservice_test.h \
nxstestscenario.h \
data_support.h
}
dstore_target {
TARGET = rs_dstore_test
SOURCES += \
support.cc \
rsdataservice_test.cc \
data_support.cc
HEADERS += support.h \
rsdataservice_test.h \
data_support.h
}
gxsdata_target {
SOURCES += \
support.cc \
data_support.cc \
rsgxsdata_test.cc
HEADERS += \
support.h \
rsgxsdata_test.h
}
INCLUDEPATH += ../../

View File

@ -5,6 +5,7 @@
// dummy services to make
#include "gxs/rsnxs.h"
#include "gxs/rsgixs.h"
#include "serialiser/rsgxsitems.h"
class RsDummyNetService: public RsNetworkExchangeService
@ -90,7 +91,75 @@ public:
};
/*!
* Dummy implementation of Gixs service for
* testing
* Limited to creating two ids upon construction which can be used
* for signing data
*/
class RsGixsDummy : public RsGixs
{
public:
/*!
* constructs keys for both incoming and outgoing id (no private keys for incoming id)
* @param
* @param dummyId This is is the only id thats exists in this dummy interface
*/
RsGixsDummy(const RsGxsId& incomingId, const RsGxsId& outgoingId){}
/*!
*
* @return id used for signing incoming data (should have both public and private components)
*/
const RsGxsId& getOutgoing(){ return mOutgoingId; }
/*!
*
* @return id used for signing outgoing data(only have public parts)
*/
const RsGxsId& getIncoming(){ return mIncomingId; }
// Key related interface - used for validating msgs and groups.
/*!
* Use to query a whether given key is available by its key reference
* @param keyref the keyref of key that is being checked for
* @return true if available, false otherwise
*/
bool haveKey(const RsGxsId &id){ return false;}
/*!
* Use to query whether private key member of the given key reference is available
* @param keyref the KeyRef of the key being checked for
* @return true if private key is held here, false otherwise
*/
bool havePrivateKey(const RsGxsId &id){ return false; }
// The fetchKey has an optional peerList.. this is people that had the msg with the signature.
// These same people should have the identity - so we ask them first.
/*!
* Use to request a given key reference
* @param keyref the KeyRef of the key being requested
* @return will
*/
bool requestKey(const RsGxsId &id, const std::list<PeerId> &peers){ return false ;}
bool requestPrivateKey(const RsGxsId &id){ return false;}
/*!
* Retrieves a key identity
* @param keyref
* @return a pointer to a valid profile if successful, otherwise NULL
*
*/
int getKey(const RsGxsId &id, RsTlvSecurityKey &key){ return false; }
int getPrivateKey(const RsGxsId &id, RsTlvSecurityKey &key){ return false; } // For signing outgoing messages.
private:
RsGxsId mIncomingId, mOutgoingId;
};
#endif // RSDUMMYSERVICES_H

View File

@ -14,19 +14,20 @@ int main()
{
GenExchangeTester tester;
CHECK(tester.testMsgSubmissionRetrieval()); REPORT("testMsgSubmissionRetrieval()");
// CHECK(tester.testMsgSubmissionRetrieval()); REPORT("testMsgSubmissionRetrieval()");
// CHECK(tester.testSpecificMsgMetaRetrieval()); REPORT("testSpecificMsgMetaRetrieval()");
// CHECK(tester.testMsgIdRetrieval()); REPORT("tester.testMsgIdRetrieval()");
// CHECK(tester.testMsgIdRetrieval()); REPORT("tester.testMsgIdRetrieval()");
// CHECK(tester.testMsgIdRetrieval_OptParents()); REPORT("tester.testRelatedMsgIdRetrieval_Parents()");
// CHECK(tester.testMsgIdRetrieval_OptOrigMsgId()); REPORT("tester.testRelatedMsgIdRetrieval_OrigMsgId()");
// CHECK(tester.testMsgIdRetrieval_OptLatest()); REPORT("tester.testRelatedMsgIdRetrieval_Latest()");
CHECK(tester.testMsgIdRetrieval_OptOrigMsgId()); REPORT("tester.testRelatedMsgIdRetrieval_OrigMsgId()");
CHECK(tester.testMsgIdRetrieval_OptLatest()); REPORT("tester.testRelatedMsgIdRetrieval_Latest()");
CHECK(tester.testMsgMetaModRequest()); REPORT("tester.testMsgMetaModRequest()");
CHECK(tester.testMsgChildRetrieval()); REPORT("tester.testMsgMetaModRequest()");
// CHECK(tester.testMsgChildRetrieval()); REPORT("tester.testMsgMetaModRequest()");
CHECK(tester.testMsgAllVersions()); REPORT("tester.testMsgAllVersions()");
CHECK(tester.testGrpSubmissionRetrieval()); REPORT("tester.testGrpSubmissionRetrieval()");
CHECK(tester.testGrpMetaRetrieval()); REPORT("tester.testGrpMetaRetrieval()");
CHECK(tester.testGrpIdRetrieval()); REPORT("tester.testGrpIdRetrieval()");
CHECK(tester.testGrpMetaModRequest()); REPORT("tester.testGrpMetaModRequest()");
// CHECK(tester.testGrpSubmissionRetrieval()); REPORT("tester.testGrpSubmissionRetrieval()");
// CHECK(tester.testGrpMetaRetrieval()); REPORT("tester.testGrpMetaRetrieval()");
// CHECK(tester.testGrpIdRetrieval()); REPORT("tester.testGrpIdRetrieval()");
// CHECK(tester.testGrpMetaModRequest()); REPORT("tester.testGrpMetaModRequest()");
FINALREPORT("RsGenExchangeTest");

View File

@ -2148,7 +2148,7 @@ void ForumsV2Dialog::requestChildData_InsertThreads(uint32_t &token, const std::
std::cerr << "ForumsV2Dialog::requestChildData_InsertThreads(" << parentId << ")";
std::cerr << std::endl;
mForumQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, FORUMSV2DIALOG_INSERTCHILD);
//mForumQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, FORUMSV2DIALOG_INSERTCHILD);
}
@ -2264,7 +2264,7 @@ void ForumsV2Dialog::requestMsgData_InsertPost(const std::string &msgId)
uint32_t token;
mForumQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, FORUMV2DIALOG_INSERT_POST);
//mForumQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, FORUMV2DIALOG_INSERT_POST);
}

View File

@ -2157,7 +2157,9 @@ void GxsForumsDialog::requestChildData_InsertThreads(uint32_t &token, const RsGx
std::cerr << "GxsForumsDialog::requestChildData_InsertThreads(" << parentId.first << "," << parentId.second << ")";
std::cerr << std::endl;
mForumQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, parentId, FORUMSV2DIALOG_INSERTCHILD);
std::vector<RsGxsGrpMsgIdPair> msgIds;
msgIds.push_back(parentId);
mForumQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, FORUMSV2DIALOG_INSERTCHILD);
}
@ -2270,9 +2272,10 @@ void GxsForumsDialog::requestMsgData_InsertPost(const RsGxsGrpMsgIdPair &msgId)
std::cerr << "GxsForumsDialog::requestMsgData_InsertPost(" << msgId.first << "," << msgId.second << ")";
std::cerr << std::endl;
std::vector<RsGxsGrpMsgIdPair> msgIds;
msgIds.push_back(msgId);
uint32_t token;
mForumQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgId, FORUMV2DIALOG_INSERT_POST);
mForumQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, FORUMV2DIALOG_INSERT_POST);
}
@ -2310,8 +2313,10 @@ void GxsForumsDialog::requestMsgData_ReplyMessage(const RsGxsGrpMsgIdPair &msgId
std::cerr << "GxsForumsDialog::requestMsgData_ReplyMessage(" << msgId.first << "," << msgId.second << ")";
std::cerr << std::endl;
std::vector<RsGxsGrpMsgIdPair> msgIds;
msgIds.push_back(msgId);
uint32_t token;
mForumQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgId, FORUMV2DIALOG_REPLY_MESSAGE);
mForumQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, FORUMV2DIALOG_REPLY_MESSAGE);
}

View File

@ -88,13 +88,15 @@ void PhotoDialog::requestComments()
opts.mMsgFlagFilter = RsPhotoV2::FLAG_MSG_TYPE_PHOTO_COMMENT;
opts.mReqType = GXS_REQUEST_TYPE_MSG_IDS;
opts.mReqType = GXS_REQUEST_TYPE_MSG_RELATED_DATA;
opts.mOptions = RS_TOKREQOPT_MSG_PARENT | RS_TOKREQOPT_MSG_LATEST;
RsGxsGrpMsgIdPair msgId;
uint32_t token;
msgId.first = mPhotoDetails.mMeta.mGroupId;
msgId.second = mPhotoDetails.mMeta.mMsgId;
uint32_t anstype = RS_TOKREQ_ANSTYPE_LIST;
mPhotoQueue->requestMsgRelatedInfo(token, anstype, opts, msgId, 0);
std::vector<RsGxsGrpMsgIdPair> msgIdV;
msgIdV.push_back(msgId);
mPhotoQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIdV, 0);
}
void PhotoDialog::createComment()
@ -163,10 +165,10 @@ void PhotoDialog::loadComment(uint32_t token)
clearComments();
PhotoCommentResult results;
mRsPhoto->getPhotoComment(token, results);
PhotoRelatedCommentResult results;
mRsPhoto->getPhotoRelatedComment(token, results);
PhotoCommentResult::iterator mit = results.begin();
PhotoRelatedCommentResult::iterator mit = results.begin();
for(; mit != results.end(); mit++)
{

View File

@ -606,9 +606,10 @@ void WikiDialog::requestModPageList(const RsGxsGrpMsgIdPair &origMsgId)
RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_MSG_IDS;
opts.mOptions = RS_TOKREQOPT_MSG_VERSIONS;
std::vector<RsGxsGrpMsgIdPair> msgIds;
msgIds.push_back(origMsgId);
uint32_t token;
mWikiQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_LIST, opts, origMsgId, WIKIDIALOG_MOD_LIST);
mWikiQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_LIST, opts, msgIds, WIKIDIALOG_MOD_LIST);
}

View File

@ -131,7 +131,7 @@ void CreateForumV2Msg::newMsg()
std::cerr << std::endl;
uint32_t token;
mForumQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, CREATEFORUMV2MSG_PARENTMSG);
//mForumQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, CREATEFORUMV2MSG_PARENTMSG);
}
}

View File

@ -67,7 +67,7 @@ bool TokenQueue::requestMsgInfo(uint32_t &token, uint32_t anstype, const RsTokRe
}
bool TokenQueue::requestMsgRelatedInfo(uint32_t &token, uint32_t anstype, const RsTokReqOptions &opts, const RsGxsGrpMsgIdPair &msgId, uint32_t usertype)
bool TokenQueue::requestMsgRelatedInfo(uint32_t &token, uint32_t anstype, const RsTokReqOptions &opts, const std::vector<RsGxsGrpMsgIdPair> &msgId, uint32_t usertype)
{
uint32_t basictype = TOKENREQ_MSGINFO;
mService->requestMsgRelatedInfo(token, anstype, opts, msgId);

View File

@ -93,7 +93,7 @@ public:
bool requestMsgInfo(uint32_t &token, uint32_t anstype, const RsTokReqOptions &opts,
const GxsMsgReq& grpIds, uint32_t usertype);
bool requestMsgRelatedInfo(uint32_t &token, uint32_t anstype, const RsTokReqOptions &opts, const RsGxsGrpMsgIdPair& msgId, uint32_t usertype);
bool requestMsgRelatedInfo(uint32_t &token, uint32_t anstype, const RsTokReqOptions &opts, const std::vector<RsGxsGrpMsgIdPair>& msgId, uint32_t usertype);
bool cancelRequest(const uint32_t token);