From f74a328d61c2fb481a7e3beeee01f8690d396dd0 Mon Sep 17 00:00:00 2001 From: chrisparker126 Date: Tue, 13 Nov 2012 22:36:06 +0000 Subject: [PATCH] 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 --- libretroshare/src/gxs/rsgds.h | 1 + libretroshare/src/gxs/rsgenexchange.cc | 80 +++- libretroshare/src/gxs/rsgenexchange.h | 77 ++++ libretroshare/src/gxs/rsgxs.h | 4 + libretroshare/src/gxs/rsgxsdataaccess.cc | 411 ++++++++++++------ libretroshare/src/gxs/rsgxsdataaccess.h | 27 +- libretroshare/src/gxs/rsgxsifaceimpl.cc | 12 + libretroshare/src/gxs/rsgxsifaceimpl.h | 17 + libretroshare/src/gxs/rsgxsrequesttypes.h | 6 +- libretroshare/src/gxs/rstokenservice.h | 6 +- libretroshare/src/retroshare/rsphotoV2.h | 12 + .../src/services/p3photoserviceV2.cc | 72 +-- libretroshare/src/services/p3photoserviceV2.h | 2 +- .../src/tests/gxs/genexchangetester.cpp | 229 +++++++--- .../src/tests/gxs/genexchangetester.h | 13 +- .../src/tests/gxs/genexchangetestservice.cpp | 20 +- .../src/tests/gxs/genexchangetestservice.h | 12 +- libretroshare/src/tests/gxs/nxs_tests.pro | 53 +-- libretroshare/src/tests/gxs/rsdummyservices.h | 69 +++ .../src/tests/gxs/rsgenexchange_test.cc | 19 +- retroshare-gui/src/gui/ForumsV2Dialog.cpp | 4 +- retroshare-gui/src/gui/GxsForumsDialog.cpp | 13 +- .../src/gui/PhotoShare/PhotoDialog.cpp | 12 +- .../src/gui/WikiPoos/WikiDialog.cpp | 5 +- .../src/gui/forumsv2/CreateForumV2Msg.cpp | 2 +- retroshare-gui/src/util/TokenQueue.cpp | 2 +- retroshare-gui/src/util/TokenQueue.h | 2 +- 27 files changed, 872 insertions(+), 310 deletions(-) diff --git a/libretroshare/src/gxs/rsgds.h b/libretroshare/src/gxs/rsgds.h index e80af47bc..abe39f363 100644 --- a/libretroshare/src/gxs/rsgds.h +++ b/libretroshare/src/gxs/rsgds.h @@ -76,6 +76,7 @@ public: }; typedef std::map > NxsMsgDataResult; +typedef std::map > NxsMsgRelatedDataResult; typedef std::map > GxsMsgResult; // /*! diff --git a/libretroshare/src/gxs/rsgenexchange.cc b/libretroshare/src/gxs/rsgenexchange.cc index 7096fd9dd..dbf6e5600 100644 --- a/libretroshare/src/gxs/rsgenexchange.cc +++ b/libretroshare/src/gxs/rsgenexchange.cc @@ -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 &groupInfo) { std::list 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& metaV = mit->second; + + msgMeta[mit->first] = std::vector(); + std::vector& msgInfoV = msgMeta[mit->first]; + + std::vector::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& 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 gxsMsgItems; + const RsGxsGrpMsgIdPair& msgId = mit->first; + std::vector& nxsMsgsV = mit->second; + std::vector::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(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() { diff --git a/libretroshare/src/gxs/rsgenexchange.h b/libretroshare/src/gxs/rsgenexchange.h index 73169dc58..0efd32343 100644 --- a/libretroshare/src/gxs/rsgenexchange.h +++ b/libretroshare/src/gxs/rsgenexchange.h @@ -39,7 +39,9 @@ typedef std::map > GxsMsgDataMap; typedef std::map GxsGroupDataMap; +typedef std::map > GxsMsgRelatedDataMap; typedef std::map > GxsMsgMetaMap; +typedef std::map > 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 &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 + bool getMsgRelatedDataT(const uint32_t &token, std::map > &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 gxsMsgItems; + const RsGxsGrpMsgIdPair& msgId = mit->first; + std::vector& nxsMsgsV = mit->second; + std::vector::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(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 diff --git a/libretroshare/src/gxs/rsgxs.h b/libretroshare/src/gxs/rsgxs.h index 5fef2a329..6ef240f6c 100644 --- a/libretroshare/src/gxs/rsgxs.h +++ b/libretroshare/src/gxs/rsgxs.h @@ -40,6 +40,10 @@ typedef std::map > GxsMsgReq; typedef std::map > GxsMsgIdResult; typedef std::map > GxsMsgMetaResult; typedef std::map > MsgMetaResult; +typedef std::map > MsgRelatedMetaResult; +typedef std::map > MsgRelatedIdResult; + + class RsGxsService { diff --git a/libretroshare/src/gxs/rsgxsdataaccess.cc b/libretroshare/src/gxs/rsgxsdataaccess.cc index f01a7407c..6a56b6112 100644 --- a/libretroshare/src/gxs/rsgxsdataaccess.cc +++ b/libretroshare/src/gxs/rsgxsdataaccess.cc @@ -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 &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(req); + MsgDataReq* mdreq = dynamic_cast(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(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(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(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(req); - MsgRelatedInfoReq* mrireq = dynamic_cast(req); + MsgIdReq* mireq = dynamic_cast(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::liststatus == GXS_REQUEST_V2_STATUS_COMPLETE){ @@ -1007,159 +1118,185 @@ bool RsGxsDataAccess::getMsgRelatedInfo(MsgRelatedInfoReq *req) return true; } - MsgMetaFilter filterMap; + std::vector::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())); - mDataStore->retrieveGxsMsgMetaData(msgIds, result); - std::vector& metaV = result[req->mMsgId.first]; - std::vector::iterator vit_meta; - - // msg id to relate to - const RsGxsMessageId& msgId = req->mMsgId.second; - const RsGxsGroupId& grpId = req->mMsgId.first; - - std::vector 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())); + mDataStore->retrieveGxsMsgMetaData(msgIds, result); + std::vector& metaV = result[grpMsgIdPair.first]; + std::vector::iterator vit_meta; + + // msg id to relate to + const RsGxsMessageId& msgId = grpMsgIdPair.second; + const RsGxsGroupId& grpId = grpMsgIdPair.first; + + std::vector 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& metaMap = filterMap[grpId]; - - if (onlyLatestMsgs) - { - if (onlyChildMsgs || onlyThreadMsgs) - { - // RUN THROUGH ALL MSGS... in map origId -> TS. - std::map > origMsgTs; - std::map >::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& metaMap = filterMap[grpId]; + + if (onlyLatestMsgs) + { + if (onlyChildMsgs || onlyThreadMsgs) + { + // RUN THROUGH ALL MSGS... in map origId -> TS. + std::map > origMsgTs; + std::map >::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; } diff --git a/libretroshare/src/gxs/rsgxsdataaccess.h b/libretroshare/src/gxs/rsgxsdataaccess.h index c0c3ac90f..f8703477d 100644 --- a/libretroshare/src/gxs/rsgxsdataaccess.h +++ b/libretroshare/src/gxs/rsgxsdataaccess.h @@ -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 &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 **/ diff --git a/libretroshare/src/gxs/rsgxsifaceimpl.cc b/libretroshare/src/gxs/rsgxsifaceimpl.cc index 1d79986d6..c3162f034 100644 --- a/libretroshare/src/gxs/rsgxsifaceimpl.cc +++ b/libretroshare/src/gxs/rsgxsifaceimpl.cc @@ -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 &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) diff --git a/libretroshare/src/gxs/rsgxsifaceimpl.h b/libretroshare/src/gxs/rsgxsifaceimpl.h index df105cd91..73d314259 100644 --- a/libretroshare/src/gxs/rsgxsifaceimpl.h +++ b/libretroshare/src/gxs/rsgxsifaceimpl.h @@ -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 diff --git a/libretroshare/src/gxs/rsgxsrequesttypes.h b/libretroshare/src/gxs/rsgxsrequesttypes.h index bd2723de5..7d2f6977f 100644 --- a/libretroshare/src/gxs/rsgxsrequesttypes.h +++ b/libretroshare/src/gxs/rsgxsrequesttypes.h @@ -100,8 +100,10 @@ class MsgRelatedInfoReq : public GxsRequest { public: - RsGxsGrpMsgIdPair mMsgId; - GxsMsgIdResult mMsgIdResult; + std::vector mMsgIds; + MsgRelatedIdResult mMsgIdResult; + MsgRelatedMetaResult mMsgMetaResult; + NxsMsgRelatedDataResult mMsgDataResult; }; class GroupSetFlagReq : public GxsRequest diff --git a/libretroshare/src/gxs/rstokenservice.h b/libretroshare/src/gxs/rstokenservice.h index cb6fee0b9..c2e768ade 100644 --- a/libretroshare/src/gxs/rstokenservice.h +++ b/libretroshare/src/gxs/rstokenservice.h @@ -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& msgIds) = 0; /* Poll */ diff --git a/libretroshare/src/retroshare/rsphotoV2.h b/libretroshare/src/retroshare/rsphotoV2.h index f678105d1..55880ee4a 100644 --- a/libretroshare/src/retroshare/rsphotoV2.h +++ b/libretroshare/src/retroshare/rsphotoV2.h @@ -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 > PhotoResult; typedef std::map > PhotoCommentResult; +typedef std::map > 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 diff --git a/libretroshare/src/services/p3photoserviceV2.cc b/libretroshare/src/services/p3photoserviceV2.cc index febb7e44b..ab5d48727 100644 --- a/libretroshare/src/services/p3photoserviceV2.cc +++ b/libretroshare/src/services/p3photoserviceV2.cc @@ -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& msgItems = mit->second; + std::vector::iterator vit = msgItems.begin(); - for(; mit != msgData.end(); mit++) + for(; vit != msgItems.end(); vit++) + { + RsGxsPhotoCommentItem* item = dynamic_cast(*vit); + + if(item) { - RsGxsGroupId grpId = mit->first; - std::vector& msgItems = mit->second; - std::vector::iterator vit = msgItems.begin(); - - for(; vit != msgItems.end(); vit++) - { - RsGxsPhotoCommentItem* item = dynamic_cast(*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(token, comments); - return ok; } bool p3PhotoServiceV2::submitAlbumDetails(uint32_t& token, RsPhotoAlbum& album) diff --git a/libretroshare/src/services/p3photoserviceV2.h b/libretroshare/src/services/p3photoserviceV2.h index 0ddccf4db..dc2ce80cb 100644 --- a/libretroshare/src/services/p3photoserviceV2.h +++ b/libretroshare/src/services/p3photoserviceV2.h @@ -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 &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: diff --git a/libretroshare/src/tests/gxs/genexchangetester.cpp b/libretroshare/src/tests/gxs/genexchangetester.cpp index 5826e1fcb..f86be53c3 100644 --- a/libretroshare/src/tests/gxs/genexchangetester.cpp +++ b/libretroshare/src/tests/gxs/genexchangetester.cpp @@ -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 grpIds; @@ -369,7 +374,7 @@ bool GenExchangeTester::testGrpMetaModRequest() init(dgrp3); uint32_t token; - RsTokReqOptionsV2 opts; + RsTokReqOptions opts; opts.mReqType = 45000; std::vector 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 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 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 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 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 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 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 msgIdsOut, msgIdsIn; +// msgIdsOut = mit->second; + +// std::vector::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 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 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 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; } diff --git a/libretroshare/src/tests/gxs/genexchangetester.h b/libretroshare/src/tests/gxs/genexchangetester.h index 83f6150e6..02d6c4140 100644 --- a/libretroshare/src/tests/gxs/genexchangetester.h +++ b/libretroshare/src/tests/gxs/genexchangetester.h @@ -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 mRandGrpIds; // ids that exist to help group testing private: GenExchangeTestService* mTestService; - RsTokenServiceV2* mTokenService; + RsTokenService* mTokenService; RsNetworkExchangeService* mNxs; RsGeneralDataService* mDataStore; - GxsCoreServer mGxsCore; }; diff --git a/libretroshare/src/tests/gxs/genexchangetestservice.cpp b/libretroshare/src/tests/gxs/genexchangetestservice.cpp index 7fe38add8..59e0bdbed 100644 --- a/libretroshare/src/tests/gxs/genexchangetestservice.cpp +++ b/libretroshare/src/tests/gxs/genexchangetestservice.cpp @@ -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() +{ + +} diff --git a/libretroshare/src/tests/gxs/genexchangetestservice.h b/libretroshare/src/tests/gxs/genexchangetestservice.h index 0a1249619..00657e9af 100644 --- a/libretroshare/src/tests/gxs/genexchangetestservice.h +++ b/libretroshare/src/tests/gxs/genexchangetestservice.h @@ -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& 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 diff --git a/libretroshare/src/tests/gxs/nxs_tests.pro b/libretroshare/src/tests/gxs/nxs_tests.pro index 7aabd0eb9..3bc6c4f02 100644 --- a/libretroshare/src/tests/gxs/nxs_tests.pro +++ b/libretroshare/src/tests/gxs/nxs_tests.pro @@ -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 += ../../ diff --git a/libretroshare/src/tests/gxs/rsdummyservices.h b/libretroshare/src/tests/gxs/rsdummyservices.h index e727b9767..0ba00a906 100644 --- a/libretroshare/src/tests/gxs/rsdummyservices.h +++ b/libretroshare/src/tests/gxs/rsdummyservices.h @@ -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 &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 diff --git a/libretroshare/src/tests/gxs/rsgenexchange_test.cc b/libretroshare/src/tests/gxs/rsgenexchange_test.cc index 7067e87f6..26fadd84d 100644 --- a/libretroshare/src/tests/gxs/rsgenexchange_test.cc +++ b/libretroshare/src/tests/gxs/rsgenexchange_test.cc @@ -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"); diff --git a/retroshare-gui/src/gui/ForumsV2Dialog.cpp b/retroshare-gui/src/gui/ForumsV2Dialog.cpp index 09b390e1b..62ec6061c 100644 --- a/retroshare-gui/src/gui/ForumsV2Dialog.cpp +++ b/retroshare-gui/src/gui/ForumsV2Dialog.cpp @@ -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); } diff --git a/retroshare-gui/src/gui/GxsForumsDialog.cpp b/retroshare-gui/src/gui/GxsForumsDialog.cpp index 1ff4ebaa5..e1013bad9 100644 --- a/retroshare-gui/src/gui/GxsForumsDialog.cpp +++ b/retroshare-gui/src/gui/GxsForumsDialog.cpp @@ -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 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 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 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); } diff --git a/retroshare-gui/src/gui/PhotoShare/PhotoDialog.cpp b/retroshare-gui/src/gui/PhotoShare/PhotoDialog.cpp index b97f6f8b4..b56f0b13d 100644 --- a/retroshare-gui/src/gui/PhotoShare/PhotoDialog.cpp +++ b/retroshare-gui/src/gui/PhotoShare/PhotoDialog.cpp @@ -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 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++) { diff --git a/retroshare-gui/src/gui/WikiPoos/WikiDialog.cpp b/retroshare-gui/src/gui/WikiPoos/WikiDialog.cpp index 3d79cd90a..f8350736a 100644 --- a/retroshare-gui/src/gui/WikiPoos/WikiDialog.cpp +++ b/retroshare-gui/src/gui/WikiPoos/WikiDialog.cpp @@ -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 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); } diff --git a/retroshare-gui/src/gui/forumsv2/CreateForumV2Msg.cpp b/retroshare-gui/src/gui/forumsv2/CreateForumV2Msg.cpp index 19920ac91..6ace6db7e 100644 --- a/retroshare-gui/src/gui/forumsv2/CreateForumV2Msg.cpp +++ b/retroshare-gui/src/gui/forumsv2/CreateForumV2Msg.cpp @@ -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); } } diff --git a/retroshare-gui/src/util/TokenQueue.cpp b/retroshare-gui/src/util/TokenQueue.cpp index 02d9ebee0..9184926e0 100644 --- a/retroshare-gui/src/util/TokenQueue.cpp +++ b/retroshare-gui/src/util/TokenQueue.cpp @@ -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 &msgId, uint32_t usertype) { uint32_t basictype = TOKENREQ_MSGINFO; mService->requestMsgRelatedInfo(token, anstype, opts, msgId); diff --git a/retroshare-gui/src/util/TokenQueue.h b/retroshare-gui/src/util/TokenQueue.h index d0cb4fb26..2bffd6d44 100644 --- a/retroshare-gui/src/util/TokenQueue.h +++ b/retroshare-gui/src/util/TokenQueue.h @@ -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& msgId, uint32_t usertype); bool cancelRequest(const uint32_t token);