diff --git a/libretroshare/src/gxs/rsdataservice.h b/libretroshare/src/gxs/rsdataservice.h index 8af15dc4e..3ef293c95 100644 --- a/libretroshare/src/gxs/rsdataservice.h +++ b/libretroshare/src/gxs/rsdataservice.h @@ -29,6 +29,7 @@ #include "gxs/rsgds.h" #include "util/retrodb.h" + class RsDataService : public RsGeneralDataService { public: diff --git a/libretroshare/src/gxs/rsgds.h b/libretroshare/src/gxs/rsgds.h index 1ea61233b..2abf2c982 100644 --- a/libretroshare/src/gxs/rsgds.h +++ b/libretroshare/src/gxs/rsgds.h @@ -151,7 +151,7 @@ public: * @param cache whether to store retrieval in mem for faster later retrieval * @return error code */ - virtual int retrieveGxsMsgMetaData(GxsMsgReq& grpIds, GxsMsgMetaResult& msgMeta) = 0; + virtual int retrieveGxsMsgMetaData(GxsMsgReq& msgIds, GxsMsgMetaResult& msgMeta) = 0; /*! * remove msgs in data store listed in msgIds param diff --git a/libretroshare/src/gxs/rsgenexchange.cc b/libretroshare/src/gxs/rsgenexchange.cc index afe021242..ff39da0ff 100644 --- a/libretroshare/src/gxs/rsgenexchange.cc +++ b/libretroshare/src/gxs/rsgenexchange.cc @@ -32,6 +32,7 @@ #include "rsgenexchange.h" #include "gxssecurity.h" #include "util/contentvalue.h" +#include "rsgxsflags.h" RsGenExchange::RsGenExchange(RsGeneralDataService *gds, RsNetworkExchangeService *ns, RsSerialType *serviceSerialiser, uint16_t servType) diff --git a/libretroshare/src/gxs/rsgxs.h b/libretroshare/src/gxs/rsgxs.h index 14d3cce77..4bb9a4cdf 100644 --- a/libretroshare/src/gxs/rsgxs.h +++ b/libretroshare/src/gxs/rsgxs.h @@ -32,6 +32,7 @@ #include #include #include +#include /* data types used throughout Gxs from netservice to genexchange */ diff --git a/libretroshare/src/gxs/rsgxsdataaccess.cc b/libretroshare/src/gxs/rsgxsdataaccess.cc index b00454fd1..6166f23e5 100644 --- a/libretroshare/src/gxs/rsgxsdataaccess.cc +++ b/libretroshare/src/gxs/rsgxsdataaccess.cc @@ -65,43 +65,88 @@ RsGxsDataAccess::RsGxsDataAccess(RsGeneralDataService* ds) bool RsGxsDataAccess::requestGroupInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptionsV2 &opts, const std::list &groupIds) { - GxsRequest* req = NULL; - uint32_t reqType = opts.mReqType; + if(groupIds.empty()) + { + std::cerr << "Group Id list is empty" << std::endl; + return false; + } - if(reqType & GXS_REQUEST_TYPE_GROUP_META) - { - GroupMetaReq* gmr = new GroupMetaReq(); - gmr->mGroupIds = groupIds; - req = gmr; - } - else if(reqType & GXS_REQUEST_TYPE_GROUP_DATA) - { - GroupDataReq* gdr = new GroupDataReq(); - gdr->mGroupIds = groupIds; - req = gdr; - } - else if(reqType & GXS_REQUEST_TYPE_GROUP_IDS) - { - GroupIdReq* gir = new GroupIdReq(); - gir->mGroupIds = groupIds; - req = gir; - } + GxsRequest* req = NULL; + uint32_t reqType = opts.mReqType; - if(req == NULL) - { - std::cerr << "RsGxsDataAccess::requestMsgInfo() request type not recognised, type " - << reqType << std::endl; - return false; - }else - { - generateToken(token); - std::cerr << "RsGxsDataAccess::requestMsgInfo() gets Token: " << token << std::endl; - } + if(reqType & GXS_REQUEST_TYPE_GROUP_META) + { + GroupMetaReq* gmr = new GroupMetaReq(); + gmr->mGroupIds = groupIds; + req = gmr; + } + else if(reqType & GXS_REQUEST_TYPE_GROUP_DATA) + { + GroupDataReq* gdr = new GroupDataReq(); + gdr->mGroupIds = groupIds; + req = gdr; + } + else if(reqType & GXS_REQUEST_TYPE_GROUP_IDS) + { + GroupIdReq* gir = new GroupIdReq(); + gir->mGroupIds = groupIds; + req = gir; + } - setReq(req, token, ansType, opts); - storeRequest(req); + if(req == NULL) + { + std::cerr << "RsGxsDataAccess::requestMsgInfo() request type not recognised, type " + << reqType << std::endl; + return false; + }else + { + generateToken(token); + std::cerr << "RsGxsDataAccess::requestMsgInfo() gets Token: " << token << std::endl; + } - return true; + setReq(req, token, ansType, opts); + storeRequest(req); + + return true; +} + +bool RsGxsDataAccess::requestGroupInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptionsV2 &opts) +{ + + GxsRequest* req = NULL; + uint32_t reqType = opts.mReqType; + + if(reqType & GXS_REQUEST_TYPE_GROUP_META) + { + GroupMetaReq* gmr = new GroupMetaReq(); + req = gmr; + } + else if(reqType & GXS_REQUEST_TYPE_GROUP_DATA) + { + GroupDataReq* gdr = new GroupDataReq(); + req = gdr; + } + else if(reqType & GXS_REQUEST_TYPE_GROUP_IDS) + { + GroupIdReq* gir = new GroupIdReq(); + req = gir; + } + + if(req == NULL) + { + std::cerr << "RsGxsDataAccess::requestMsgInfo() request type not recognised, type " + << reqType << std::endl; + return false; + }else + { + generateToken(token); + std::cerr << "RsGxsDataAccess::requestMsgInfo() gets Token: " << token << std::endl; + } + + setReq(req, token, ansType, opts); + storeRequest(req); + + return true; } void RsGxsDataAccess::generateToken(uint32_t &token) @@ -121,21 +166,41 @@ bool RsGxsDataAccess::requestMsgInfo(uint32_t &token, uint32_t ansType, GxsRequest* req = NULL; uint32_t reqType = opts.mReqType; + // remove all empty grpId entries + GxsMsgReq::const_iterator mit = msgIds.begin(); + std::vector toRemove; + + for(; mit != msgIds.end(); mit++) + { + if(mit->second.empty()) + toRemove.push_back(mit->first); + } + + std::vector::const_iterator vit = toRemove.begin(); + + GxsMsgReq filteredMsgIds = msgIds; + + for(; vit != toRemove.end(); vit++) + filteredMsgIds.erase(*vit); + if(reqType & GXS_REQUEST_TYPE_MSG_META) { MsgMetaReq* mmr = new MsgMetaReq(); - mmr->mMsgIds = msgIds; + mmr->mMsgIds = filteredMsgIds; req = mmr; + }else if(reqType & GXS_REQUEST_TYPE_MSG_DATA) { MsgDataReq* mdr = new MsgDataReq(); - mdr->mMsgIds = msgIds; + mdr->mMsgIds = filteredMsgIds; req = mdr; + }else if(reqType & GXS_REQUEST_TYPE_MSG_IDS) { MsgIdReq* mir = new MsgIdReq(); - mir->mMsgIds = msgIds; + mir->mMsgIds = filteredMsgIds; req = mir; + } if(req == NULL) @@ -154,8 +219,58 @@ bool RsGxsDataAccess::requestMsgInfo(uint32_t &token, uint32_t ansType, return true; } +bool RsGxsDataAccess::requestMsgInfo(uint32_t &token, uint32_t ansType, + const RsTokReqOptionsV2 &opts, const std::list& grpIds) +{ + GxsRequest* req = NULL; + uint32_t reqType = opts.mReqType; -bool RsGxsDataAccess::requestMsgRelatedInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptionsV2 &opts, const GxsMsgReq& msgIds) + std::list::const_iterator lit = grpIds.begin(); + + if(reqType & GXS_REQUEST_TYPE_MSG_META) + { + MsgMetaReq* mmr = new MsgMetaReq(); + + for(; lit != grpIds.end(); lit++) + mmr->mMsgIds[*lit] = std::vector(); + + req = mmr; + }else if(reqType & GXS_REQUEST_TYPE_MSG_DATA) + { + MsgDataReq* mdr = new MsgDataReq(); + + for(; lit != grpIds.end(); lit++) + mdr->mMsgIds[*lit] = std::vector(); + + req = mdr; + }else if(reqType & GXS_REQUEST_TYPE_MSG_IDS) + { + MsgIdReq* mir = new MsgIdReq(); + + for(; lit != grpIds.end(); lit++) + mir->mMsgIds[*lit] = std::vector(); + + req = mir; + } + + if(req == NULL) + { + std::cerr << "RsGxsDataAccess::requestMsgInfo() request type not recognised, type " + << reqType << std::endl; + return false; + }else + { + generateToken(token); + std::cerr << "RsGxsDataAccess::requestMsgInfo() gets Token: " << token << std::endl; + } + + setReq(req, token, ansType, opts); + storeRequest(req); + return true; +} + +bool RsGxsDataAccess::requestMsgRelatedInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptionsV2 &opts, + const GxsMsgReq& msgIds) { MsgRelatedInfoReq* req = new MsgRelatedInfoReq(); @@ -166,7 +281,6 @@ bool RsGxsDataAccess::requestMsgRelatedInfo(uint32_t &token, uint32_t ansType, c setReq(req, token, ansType, opts); storeRequest(req); - return true; } diff --git a/libretroshare/src/gxs/rsgxsdataaccess.h b/libretroshare/src/gxs/rsgxsdataaccess.h index 94c5d4403..c1261ff55 100644 --- a/libretroshare/src/gxs/rsgxsdataaccess.h +++ b/libretroshare/src/gxs/rsgxsdataaccess.h @@ -44,24 +44,43 @@ public: /** S: RsTokenService **/ /*! - * - * @param token - * @param ansType - * @param opts - * @param groupIds + * Use this to request group related information + * @param token The token returned for the request, store this value to pool for request completion + * @param ansType The type of result (e.g. group data, meta, ids) + * @param opts Additional option that affect outcome of request. Please see specific services, for valid values + * @param groupIds group id to request info for * @return */ bool requestGroupInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptionsV2 &opts, const std::list &groupIds); /*! - * For requesting info on all messages of one or more groups - * @param token - * @param ansType - * @param opts - * @param groupIds + * Use this to request all group related info + * @param token The token returned for the request, store this value to pool for request completion + * @param ansType The type of result (e.g. group data, meta, ids) + * @param opts Additional option that affect outcome of request. Please see specific services, for valid values * @return */ - bool requestMsgInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptionsV2 &opts, const GxsMsgReq&); + bool requestGroupInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptionsV2 &opts); + + /*! + * Use this to get msg related information, store this value to pole for request completion + * @param token The token returned for the request + * @param ansType The type of result wanted + * @param opts Additional option that affect outcome of request. Please see specific services, for valid values + * @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 requestMsgInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptionsV2 &opts, const GxsMsgReq& msgIds); + + /*! + * Use this to get msg related information, store this value to pole for request completion + * @param token The token returned for the request + * @param ansType The type of result wanted + * @param opts Additional option that affect outcome of request. Please see specific services, for valid values + * @param groupIds The ids of the groups to get, this retrieve all the msgs info for each grpId in list + * @return true if request successful false otherwise + */ + bool requestMsgInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptionsV2 &opts, const std::list& grpIds); /*! * For requesting msgs related to a given msg id within a group @@ -71,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 RsTokReqOptionsV2 &opts, const GxsMsgReq&); + bool requestMsgRelatedInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptionsV2 &opts, const GxsMsgReq& msgIds); /* Poll */ uint32_t requestStatus(const uint32_t token); diff --git a/libretroshare/src/gxs/rsgxsflags.h b/libretroshare/src/gxs/rsgxsflags.h index c85d7a033..d124bde5f 100644 --- a/libretroshare/src/gxs/rsgxsflags.h +++ b/libretroshare/src/gxs/rsgxsflags.h @@ -3,6 +3,8 @@ #include "inttypes.h" +// this serves a single point of call for definining grp and msg modes +// GXS. These modes say namespace GXS_SERV { @@ -10,30 +12,30 @@ namespace GXS_SERV { /* type of group */ - static const uint32_t FLAG_GRP_TYPE_MASK; + static const uint32_t FLAG_GRP_TYPE_MASK = 0; // pub key encrypted - static const uint32_t FLAG_GRP_TYPE_PRIVATE; + static const uint32_t FLAG_GRP_TYPE_PRIVATE = 0; // single publisher, read only - static const uint32_t FLAG_GRP_TYPE_RESTRICTED; + static const uint32_t FLAG_GRP_TYPE_RESTRICTED = 0; // anyone can publish - static const uint32_t FLAG_GRP_TYPE_PUBLIC; + static const uint32_t FLAG_GRP_TYPE_PUBLIC = 0; /* type of msgs allowed */ - static const uint32_t FLAG_MSG_TYPE_MASK; + static const uint32_t FLAG_MSG_TYPE_MASK = 0; // only signee can edit, and sign required - static const uint32_t FLAG_MSG_TYPE_SIGNED; + static const uint32_t FLAG_MSG_TYPE_SIGNED = 0; // no sign required, but signee can edit if signed - static const uint32_t FLAG_MSG_TYPE_ANON; + static const uint32_t FLAG_MSG_TYPE_ANON = 0; // anyone can mod but sign must be provided (needed for wikis) - static const uint32_t FLAG_MSG_TYPE_SIGNED_SHARED; + static const uint32_t FLAG_MSG_TYPE_SIGNED_SHARED = 0; /*** GROUP FLAGS ***/ @@ -42,13 +44,22 @@ namespace GXS_SERV { /*** MESSAGE FLAGS ***/ // indicates message edits an existing message - static const uint32_t FLAG_MSG_EDIT; + static const uint32_t FLAG_MSG_EDIT = 0; // indicates msg is id signed - static const uint32_t FLAG_MSG_ID_SIGNED; + static const uint32_t FLAG_MSG_ID_SIGNED = 0; /*** MESSAGE FLAGS ***/ + + // Subscription Flags. (LOCAL) + + static const uint32_t RSGXS_GROUP_SUBSCRIBE_ADMIN = 0x00000001; + static const uint32_t RSGXS_GROUP_SUBSCRIBE_PUBLISH = 0x00000002; + static const uint32_t RSGXS_GROUP_SUBSCRIBE_SUBSCRIBED = 0x00000004; + static const uint32_t RSGXS_GROUP_SUBSCRIBE_MONITOR = 0x00000008; + static const uint32_t RSGXS_GROUP_SUBSCRIBE_MASK = 0x0000000f; + } diff --git a/libretroshare/src/gxs/rsgxsnetservice.cc b/libretroshare/src/gxs/rsgxsnetservice.cc index 5becd34ec..875f42b48 100644 --- a/libretroshare/src/gxs/rsgxsnetservice.cc +++ b/libretroshare/src/gxs/rsgxsnetservice.cc @@ -25,6 +25,7 @@ */ #include "rsgxsnetservice.h" +#include "rsgxsflags.h" #define NXS_NET_DEBUG @@ -85,24 +86,40 @@ void RsGxsNetService::syncWithPeers() sendItem(grp); } + std::map grpMeta; + mDataStore->retrieveGxsGrpMetaData(grpMeta); + + std::map::iterator + mit = grpMeta.begin(); + + std::vector grpIds; + + for(; mit != grpMeta.end(); mit++) + { + RsGxsGrpMetaData* meta = mit->second; + + if(meta->mSubscribeFlags & GXS_SERV::RSGXS_GROUP_SUBSCRIBE_MASK) + grpIds.push_back(mit->first); + } + sit = peers.begin(); + // TODO msgs for(; sit != peers.end(); sit++) { RsStackMutex stack(mNxsMutex); - std::set::iterator sit_grp = mGroupSubscribedTo.begin(); + std::vector::iterator vit = grpIds.begin(); - for(; sit_grp != mGroupSubscribedTo.end(); sit_grp++) + for(; vit != grpIds.end(); vit++) { RsNxsSyncMsg* msg = new RsNxsSyncMsg(mServType); msg->clear(); - msg->PeerId(*sit); - msg->grpId = *sit_grp; + msg->PeerId(*sit); + msg->grpId = *vit; sendItem(msg); } } - } bool RsGxsNetService::loadList(std::list& load) @@ -600,10 +617,6 @@ void RsGxsNetService::locked_processCompletedIncomingTrans(NxsTransaction* tr) { tr->mItems.pop_front(); grps.push_back(grp); - - //TODO: remove subscription should be handled - // outside netservice - mGroupSubscribedTo.insert(grp->grpId); } else { diff --git a/libretroshare/src/gxs/rsgxsnetservice.h b/libretroshare/src/gxs/rsgxsnetservice.h index 096e5c8c7..fc1f9bf38 100644 --- a/libretroshare/src/gxs/rsgxsnetservice.h +++ b/libretroshare/src/gxs/rsgxsnetservice.h @@ -290,44 +290,44 @@ private: * of msgs received from peer stored in passed transaction * @param tr transaction responsible for generating msg request */ - void locked_genReqMsgTransaction(NxsTransaction* tr); + void locked_genReqMsgTransaction(NxsTransaction* tr); /*! * Generates new transaction to send grp requests based on list * of grps received from peer stored in passed transaction * @param tr transaction responsible for generating grp request */ - void locked_genReqGrpTransaction(NxsTransaction* tr); + void locked_genReqGrpTransaction(NxsTransaction* tr); - /*! - * Generates new transaction to send msg data based on list - * of grpids received from peer stored in passed transaction - * @param tr transaction responsible for generating grp request - */ - void locked_genSendMsgsTransaction(NxsTransaction* tr); + /*! + * Generates new transaction to send msg data based on list + * of grpids received from peer stored in passed transaction + * @param tr transaction responsible for generating grp request + */ + void locked_genSendMsgsTransaction(NxsTransaction* tr); - /*! - * Generates new transaction to send grp data based on list - * of grps received from peer stored in passed transaction - * @param tr transaction responsible for generating grp request - */ - void locked_genSendGrpsTransaction(NxsTransaction* tr); + /*! + * Generates new transaction to send grp data based on list + * of grps received from peer stored in passed transaction + * @param tr transaction responsible for generating grp request + */ + void locked_genSendGrpsTransaction(NxsTransaction* tr); - /*! - * convenience function to add a transaction to list - * @param tr transaction to add - */ - bool locked_addTransaction(NxsTransaction* tr); + /*! + * convenience function to add a transaction to list + * @param tr transaction to add + */ + bool locked_addTransaction(NxsTransaction* tr); - void cleanTransactionItems(NxsTransaction* tr) const; + void cleanTransactionItems(NxsTransaction* tr) const; - /*! - * @param tr the transaction to check for timeout - * @return false if transaction has timed out, true otherwise - */ - bool locked_checkTransacTimedOut(NxsTransaction* tr); + /*! + * @param tr the transaction to check for timeout + * @return false if transaction has timed out, true otherwise + */ + bool locked_checkTransacTimedOut(NxsTransaction* tr); - /** E: Transaction processing **/ + /** E: Transaction processing **/ /** S: item handlers **/ @@ -395,9 +395,7 @@ private: RsMutex mNxsMutex; uint32_t mSyncTs; - // TODO: remove, temp, for testing. - // subscription handled outside netservice - std::set mGroupSubscribedTo; + const uint32_t mSYNC_PERIOD; }; diff --git a/libretroshare/src/gxs/rstokenservice.h b/libretroshare/src/gxs/rstokenservice.h index d0e562dc6..ec86e3814 100644 --- a/libretroshare/src/gxs/rstokenservice.h +++ b/libretroshare/src/gxs/rstokenservice.h @@ -114,18 +114,27 @@ public: RsTokenServiceV2() { return; } virtual ~RsTokenServiceV2() { return; } - /* Data Requests */ + /* Data Requests */ /*! * Use this to request group related information * @param token The token returned for the request, store this value to pool for request completion * @param ansType The type of result (e.g. group data, meta, ids) * @param opts Additional option that affect outcome of request. Please see specific services, for valid values - * @param groupIds group id to request info for. Leave empty to get info on all groups, + * @param groupIds group id to request info for * @return */ virtual bool requestGroupInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptionsV2 &opts, const std::list &groupIds) = 0; + /*! + * Use this to request all group related info + * @param token The token returned for the request, store this value to pool for request completion + * @param ansType The type of result (e.g. group data, meta, ids) + * @param opts Additional option that affect outcome of request. Please see specific services, for valid values + * @return + */ + virtual bool requestGroupInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptionsV2 &opts) = 0; + /*! * Use this to get msg related information, store this value to pole for request completion * @param token The token returned for the request @@ -136,6 +145,16 @@ public: */ virtual bool requestMsgInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptionsV2 &opts, const GxsMsgReq& msgIds) = 0; + /*! + * Use this to get msg related information, store this value to pole for request completion + * @param token The token returned for the request + * @param ansType The type of result wanted + * @param opts Additional option that affect outcome of request. Please see specific services, for valid values + * @param groupIds The ids of the groups to get, this retrieve all the msgs info for each grpId in list + * @return true if request successful false otherwise + */ + virtual bool requestMsgInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptionsV2 &opts, const std::list& msgIds) = 0; + /*! * For requesting msgs related to a given msg id within a group * @param token The token returned for the request @@ -147,7 +166,7 @@ public: virtual bool requestMsgRelatedInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptionsV2 &opts, const GxsMsgReq& msgIds) = 0; - /* Poll */ + /* Poll */ /*! * Request the status of ongoing request. diff --git a/libretroshare/src/rsserver/rsinit.cc b/libretroshare/src/rsserver/rsinit.cc index ebc9241bb..c708eb0de 100644 --- a/libretroshare/src/rsserver/rsinit.cc +++ b/libretroshare/src/rsserver/rsinit.cc @@ -2274,6 +2274,8 @@ int RsServer::StartupRetroShare() RsGeneralDataService* photo_ds = new RsDataService("./", "photoV2_db", RS_SERVICE_TYPE_PHOTO, NULL); + photo_ds->resetDataStore(); + // TODO need net manager //RsGxsNetService* photo_ns = new RsGxsNetService( // RS_SERVICE_TYPE_PHOTO, photo_ds, NULL, mPhotoV2); diff --git a/libretroshare/src/tests/gxs/genexchangetester.cpp b/libretroshare/src/tests/gxs/genexchangetester.cpp index 4434a4ab8..5f41f2022 100644 --- a/libretroshare/src/tests/gxs/genexchangetester.cpp +++ b/libretroshare/src/tests/gxs/genexchangetester.cpp @@ -175,7 +175,7 @@ bool GenExchangeTester::testGrpSubmissionRetrieval() opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA; std::list grpIds; - mTokenService->requestGroupInfo(token, 0, opts, grpIds); + mTokenService->requestGroupInfo(token, 0, opts); pollForToken(token, opts); @@ -272,7 +272,7 @@ bool GenExchangeTester::testGrpMetaRetrieval() opts.mReqType = GXS_REQUEST_TYPE_GROUP_META; std::list grpIds; - mTokenService->requestGroupInfo(token, 0, opts, grpIds); + mTokenService->requestGroupInfo(token, 0, opts); pollForToken(token, opts); @@ -319,7 +319,7 @@ bool GenExchangeTester::testGrpIdRetrieval() opts.mReqType = GXS_REQUEST_TYPE_GROUP_IDS; uint32_t token; std::list grpIds; - mTokenService->requestGroupInfo(token, 0, opts, grpIds); + mTokenService->requestGroupInfo(token, 0, opts); pollForToken(token, opts); @@ -676,13 +676,13 @@ bool GenExchangeTester::testMsgIdRetrieval() // now do ask of all msg ids - GxsMsgReq req; + std::list req; opts.mReqType = GXS_REQUEST_TYPE_MSG_IDS; // use empty grp ids request types, non specific msgs ids for(int i=0; i < mRandGrpIds.size(); i++) { - req[mRandGrpIds[i]] = std::vector(); + req.push_back(mRandGrpIds[i]); } mTokenService->requestMsgInfo(token, 0, opts, req); diff --git a/libretroshare/src/tests/gxs/nxsnet_test.pro b/libretroshare/src/tests/gxs/nxsnet_test.pro new file mode 100644 index 000000000..054938374 --- /dev/null +++ b/libretroshare/src/tests/gxs/nxsnet_test.pro @@ -0,0 +1,92 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2012-05-06T09:19:26 +# +#------------------------------------------------- + +QT += core network + +QT -= gui + +TARGET = rs_test +CONFIG += console +CONFIG -= app_bundle + +TEMPLATE = app + +CONFIG += debug + +debug { +# DEFINES *= DEBUG +# DEFINES *= OPENDHT_DEBUG DHT_DEBUG CONN_DEBUG DEBUG_UDP_SORTER P3DISC_DEBUG DEBUG_UDP_LAYER FT_DEBUG EXTADDRSEARCH_DEBUG +# DEFINES *= CONTROL_DEBUG FT_DEBUG DEBUG_FTCHUNK P3TURTLE_DEBUG +# DEFINES *= P3TURTLE_DEBUG +# DEFINES *= NET_DEBUG +# DEFINES *= DISTRIB_DEBUG +# DEFINES *= P3TURTLE_DEBUG FT_DEBUG DEBUG_FTCHUNK MPLEX_DEBUG +# DEFINES *= STATUS_DEBUG SERV_DEBUG RSSERIAL_DEBUG #CONN_DEBUG + + QMAKE_CXXFLAGS -= -O2 -fomit-frame-pointer + QMAKE_CXXFLAGS *= -g -fno-omit-frame-pointer +} +################################# Linux ########################################## +# Put lib dir in QMAKE_LFLAGS so it appears before -L/usr/lib +linux-* { + #CONFIG += version_detail_bash_script + QMAKE_CXXFLAGS *= -D_FILE_OFFSET_BITS=64 + + system(which gpgme-config >/dev/null 2>&1) { + INCLUDEPATH += $$system(gpgme-config --cflags | sed -e "s/-I//g") + } else { + message(Could not find gpgme-config on your system, assuming gpgme.h is in /usr/include) + } + + PRE_TARGETDEPS *= /home/crispy/workspace/v0.5-gxs-b1/libretroshare/src/lib/libretroshare.a + + LIBS += /home/crispy/workspace/v0.5-gxs-b1/libretroshare/src/lib/libretroshare.a + LIBS += /home/crispy/workspace/v0.5-gxs-b1/libbitdht/src/lib/libbitdht.a + LIBS += /home/crispy/workspace/v0.5-gxs-b1/openpgpsdk/src/lib/libops.a + LIBS += -lssl -lgpgme -lupnp -lixml -lgnome-keyring -lsqlite3 -lbz2 + LIBS *= -rdynamic -frtti + DEFINES *= HAVE_XSS # for idle time, libx screensaver extensions + DEFINES *= UBUNTU +} + +linux-g++ { + OBJECTS_DIR = temp/linux-g++/obj +} + +linux-g++-64 { + OBJECTS_DIR = temp/linux-g++-64/obj +} + +version_detail_bash_script { + DEFINES += ADD_LIBRETROSHARE_VERSION_INFO + QMAKE_EXTRA_TARGETS += write_version_detail + PRE_TARGETDEPS = write_version_detail + write_version_detail.commands = ./version_detail.sh +} + +install_rs { + INSTALLS += binary_rs + binary_rs.path = $$(PREFIX)/usr/bin + binary_rs.files = ./RetroShare +} + + +SOURCES += \ + /home/crispy/workspace/v0.5-gxs-b1/libretroshare/src/tests/gxs/data_support.cc \ + /home/crispy/workspace/v0.5-gxs-b1/libretroshare/src/tests/gxs/nxstesthub.cc \ + /home/crispy/workspace/v0.5-gxs-b1/libretroshare/src/tests/gxs/nxstestscenario.cc \ + /home/crispy/workspace/v0.5-gxs-b1/libretroshare/src/tests/gxs/rsgxsnetservice_test.cc \ + /home/crispy/workspace/v0.5-gxs-b1/libretroshare/src/tests/gxs/support.cc + + +HEADERS += \ + /home/crispy/workspace/v0.5-gxs-b1/libretroshare/src/tests/gxs/data_support.h \ + /home/crispy/workspace/v0.5-gxs-b1/libretroshare/src/tests/gxs/nxstesthub.h \ + /home/crispy/workspace/v0.5-gxs-b1/libretroshare/src/tests/gxs/nxstestscenario.h \ + /home/crispy/workspace/v0.5-gxs-b1/libretroshare/src/tests/gxs/support.h + +INCLUDEPATH += /home/crispy/workspace/v0.5-gxs-b1/libretroshare/src + diff --git a/libretroshare/src/tests/gxs/rsdataservice_test.cc b/libretroshare/src/tests/gxs/rsdataservice_test.cc index 790a265c2..af5155773 100644 --- a/libretroshare/src/tests/gxs/rsdataservice_test.cc +++ b/libretroshare/src/tests/gxs/rsdataservice_test.cc @@ -2,6 +2,7 @@ #include "support.h" #include "data_support.h" #include "rsdataservice_test.h" +#include "gxs/rsgds.h" #include "gxs/rsdataservice.h" #define DATA_BASE_NAME "msg_grp_Store" @@ -57,9 +58,9 @@ void test_groupStoreAndRetrieve(){ dStore->storeGroup(grps); - std::map gR; - std::map grpMetaR; - dStore->retrieveNxsGrps(gR, false); + std::map gR; + std::map grpMetaR; + dStore->retrieveNxsGrps(gR, false, false); dStore->retrieveGxsGrpMetaData(grpMetaR); std::map::iterator mit = grps.begin(); @@ -164,7 +165,7 @@ void test_messageStoresAndRetrieve() const std::string& grpId = grpV[chosen]; if(chosen) - req[grpId].insert(msg->msgId); + req[grpId].push_back(msg->msgId); msgMeta->mMsgId = msg->msgId; msgMeta->mGroupId = msg->grpId = grpId; @@ -189,7 +190,7 @@ void test_messageStoresAndRetrieve() msgs.insert(p); } - req[grpV[0]] = std::set(); // assign empty list for other + req[grpV[0]] = std::vector(); // assign empty list for other dStore->storeMessage(msgs); @@ -199,7 +200,8 @@ void test_messageStoresAndRetrieve() GxsMsgResult msgResult; GxsMsgMetaResult msgMetaResult; dStore->retrieveNxsMsgs(req, msgResult, false); - dStore->retrieveGxsMsgMetaData(grpV, msgMetaResult); + + dStore->retrieveGxsMsgMetaData(req, msgMetaResult); // now look at result for grpId 1 std::vector& result0 = msgResult[grpId0]; diff --git a/libretroshare/src/tests/gxs/rsdummyservices.h b/libretroshare/src/tests/gxs/rsdummyservices.h index 854c6b4c8..e727b9767 100644 --- a/libretroshare/src/tests/gxs/rsdummyservices.h +++ b/libretroshare/src/tests/gxs/rsdummyservices.h @@ -69,7 +69,7 @@ public: RsDummySerialiser() - :RsSerialType(RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_DUMMY) + : RsSerialType(RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_DUMMY) { return; } virtual ~RsDummySerialiser() { return; }