diff --git a/libretroshare/src/gxs/gxscoreserver.cc b/libretroshare/src/gxs/gxscoreserver.cc index de27ee2f7..c4068164c 100644 --- a/libretroshare/src/gxs/gxscoreserver.cc +++ b/libretroshare/src/gxs/gxscoreserver.cc @@ -8,6 +8,7 @@ #include "gxscoreserver.h" GxsCoreServer::GxsCoreServer() +: mGxsMutex("GxsCoreServer") { } diff --git a/libretroshare/src/gxs/rsgds.h b/libretroshare/src/gxs/rsgds.h index 8d1334e9d..4a178f575 100644 --- a/libretroshare/src/gxs/rsgds.h +++ b/libretroshare/src/gxs/rsgds.h @@ -35,6 +35,7 @@ #include "serialiser/rsgxsitems.h" #include "serialiser/rsnxsitems.h" #include "gxs/rsgxsdata.h" +#include "rsgxs.h" class RsGxsSearchModule { @@ -62,9 +63,9 @@ class GrpLocMetaData { }; -typedef std::map > GxsMsgReq; // -typedef std::map > GxsMsgResult; // -typedef std::map > GxsMsgMetaResult; // +//typedef std::map > GxsMsgReq; // + +//typedef std::map > GxsMsgMetaResult; // /*! * The main role of GDS is the preparation and handing out of messages requested from diff --git a/libretroshare/src/gxs/rsgenexchange.cc b/libretroshare/src/gxs/rsgenexchange.cc index 3d3383e3a..0337ce5a9 100644 --- a/libretroshare/src/gxs/rsgenexchange.cc +++ b/libretroshare/src/gxs/rsgenexchange.cc @@ -52,14 +52,16 @@ bool RsGenExchange::getGroupMeta(const uint32_t &token, std::listgetGroupSummary(token, metaL); std::list::iterator lit = metaL.begin(); - + RsGroupMetaData m; for(; lit != metaL.end(); lit++) { - RsGroupMetaData m = *(*lit); + RsGxsGrpMetaData& gMeta = *(*lit); + m = gMeta; groupInfo.push_back(m); + delete (*lit); } - std::list::iterator cit = metaL; + std::list::iterator cit = metaL.begin(); for(; cit != metaL.end(); cit++) delete *cit; @@ -79,7 +81,7 @@ bool RsGenExchange::getMsgMeta(const uint32_t &token, for(; mit != result.end(); mit++) { std::vector& metaV = mit->second; - msgInfo[mit->first] = metaV; + //msgInfo[mit->first] = metaV; std::vector::iterator vit = metaV.begin(); @@ -147,7 +149,7 @@ bool RsGenExchange::getMsgData(const uint32_t &token, } -RsTokenService* RsGenExchange::getTokenService() +RsTokenServiceV2* RsGenExchange::getTokenService() { return mDataAccess; } @@ -256,7 +258,7 @@ void RsGenExchange::publishGrps() { grp->metaData = new RsGxsGrpMetaData(); ok = mDataAccess->addGroupData(grp); - RsGxsGroupChange* gc = RsGxsGroupChange(); + RsGxsGroupChange* gc = new RsGxsGroupChange(); mNotifications.push_back(gc); } diff --git a/libretroshare/src/gxs/rsgenexchange.h b/libretroshare/src/gxs/rsgenexchange.h index 64dbe5ec5..ad2aa7e37 100644 --- a/libretroshare/src/gxs/rsgenexchange.h +++ b/libretroshare/src/gxs/rsgenexchange.h @@ -101,7 +101,7 @@ public: * @return handle to token service handle for making * request to this gxs service */ - RsTokenService* getTokenService(); + RsTokenServiceV2* getTokenService(); protected: @@ -225,7 +225,7 @@ private: private: - std::vector mChanges; + std::vector mChanges; }; #endif // RSGENEXCHANGE_H diff --git a/libretroshare/src/gxs/rsgxs.h b/libretroshare/src/gxs/rsgxs.h index bab79b9c1..dfa565a32 100644 --- a/libretroshare/src/gxs/rsgxs.h +++ b/libretroshare/src/gxs/rsgxs.h @@ -40,7 +40,11 @@ #include "rsnxsobserver.h" - +typedef std::map > GxsMsgReq; +typedef std::map > GxsMsgIdResult; +typedef std::map > GxsMsgMetaResult; +typedef std::map > NxsMsgDataResult; +typedef std::map > GxsMsgResult; // class RsGxsService : public RsNxsObserver { diff --git a/libretroshare/src/gxs/rsgxsdataaccess.cc b/libretroshare/src/gxs/rsgxsdataaccess.cc index ab7c74f85..2ea9e7129 100644 --- a/libretroshare/src/gxs/rsgxsdataaccess.cc +++ b/libretroshare/src/gxs/rsgxsdataaccess.cc @@ -1,5 +1,3 @@ -#include "rsgxsdataaccess.h" - /* * libretroshare/src/retroshare: rsgxsdataaccess.cc * @@ -25,6 +23,8 @@ * */ +#include "rsgxsdataaccess.h" + // This bit will be filled out over time. #define RS_TOKREQOPT_MSG_VERSIONS 0x0001 // MSGRELATED: Returns All MsgIds with OrigMsgId = MsgId. #define RS_TOKREQOPT_MSG_ORIGMSG 0x0002 // MSGLIST: All Unique OrigMsgIds in a Group. @@ -51,15 +51,15 @@ #define RS_TOKREQ_ANSTYPE_SUMMARY 0x0002 #define RS_TOKREQ_ANSTYPE_DATA 0x0003 - const uint8_t RsGxsDataAccess::GXS_REQUEST_STATUS_FAILED = 0; - const uint8_t RsGxsDataAccess::GXS_REQUEST_STATUS_PENDING = 1; - const uint8_t RsGxsDataAccess::GXS_REQUEST_STATUS_PARTIAL = 2; - const uint8_t RsGxsDataAccess::GXS_REQUEST_STATUS_FINISHED_INCOMPLETE = 3; - const uint8_t RsGxsDataAccess::GXS_REQUEST_STATUS_COMPLETE = 4; - const uint8_t RsGxsDataAccess::GXS_REQUEST_STATUS_DONE = 5; // ONCE ALL DATA RETRIEVED. + const uint8_t RsTokenServiceV2::GXS_REQUEST_STATUS_FAILED = 0; + const uint8_t RsTokenServiceV2::GXS_REQUEST_STATUS_PENDING = 1; + const uint8_t RsTokenServiceV2::GXS_REQUEST_STATUS_PARTIAL = 2; + const uint8_t RsTokenServiceV2::GXS_REQUEST_STATUS_FINISHED_INCOMPLETE = 3; + const uint8_t RsTokenServiceV2::GXS_REQUEST_STATUS_COMPLETE = 4; + const uint8_t RsTokenServiceV2::GXS_REQUEST_STATUS_DONE = 5; // ONCE ALL DATA RETRIEVED. RsGxsDataAccess::RsGxsDataAccess(RsGeneralDataService* ds) - : mDataStore(ds) + : mDataStore(ds), mDataMutex("RsGxsDataAccess") { } @@ -302,7 +302,7 @@ bool RsGxsDataAccess::getGroupData(const uint32_t& token, std::list& return false; }else if(req->token == GXS_REQUEST_STATUS_COMPLETE){ - GroupDataReq* gmreq = dynamic_cast(req); + GroupDataReq* gmreq = dynamic_cast(req); if(gmreq) { @@ -330,7 +330,7 @@ bool RsGxsDataAccess::getMsgData(const uint32_t& token, NxsMsgDataResult& msgDat return false; }else if(req->token == GXS_REQUEST_STATUS_COMPLETE){ - MsgDataReq* mdreq = dynamic_cast(req); + MsgDataReq* mdreq = dynamic_cast(req); if(mdreq) { @@ -358,7 +358,7 @@ bool RsGxsDataAccess::getMsgSummary(const uint32_t& token, GxsMsgMetaResult& msg return false; }else if(req->token == GXS_REQUEST_STATUS_COMPLETE){ - MsgMetaReq* mmreq = dynamic_cast(req); + MsgMetaReq* mmreq = dynamic_cast(req); if(mmreq) { @@ -387,7 +387,7 @@ bool RsGxsDataAccess::getMsgList(const uint32_t& token, GxsMsgIdResult& msgIds) return false; }else if(req->token == GXS_REQUEST_STATUS_COMPLETE){ - MsgIdReq* mireq = dynamic_cast(req); + MsgIdReq* mireq = dynamic_cast(req); if(mireq) { @@ -417,7 +417,7 @@ bool RsGxsDataAccess::getGroupList(const uint32_t& token, std::listtoken == GXS_REQUEST_STATUS_COMPLETE){ - GroupIdReq* gireq = dynamic_cast(req); + GroupIdReq* gireq = dynamic_cast(req); if(gireq) { @@ -444,7 +444,7 @@ GxsRequest* RsGxsDataAccess::retrieveRequest(const uint32_t& token) if(mRequests.find(token) == mRequests.end()) return NULL; - GxsRequest* req = mRequests; + GxsRequest* req = mRequests[token]; return req; } @@ -692,19 +692,19 @@ bool RsGxsDataAccess::getMsgList(MsgIdReq* req) metaFilter[grpId] = std::map(); - const std::vector& metaV = meta_it->second; + const std::vector& metaV = meta_it->second; if (onlyLatestMsgs) // THIS ONE IS HARD -> LOTS OF COMP. { - std::vector::const_iterator vit = metaV.begin(); + std::vector::const_iterator vit = metaV.begin(); // RUN THROUGH ALL MSGS... in map origId -> TS. - std::map > origMsgTs; - std::map >::iterator oit; + std::map > origMsgTs; + std::map >::iterator oit; for(; vit != metaV.end(); vit++) { - RsMsgMetaData* msgMeta = *vit; + RsGxsMsgMetaData* msgMeta = *vit; /* if we are grabbing thread Head... then parentId == empty. */ if (onlyThreadHeadMsgs) @@ -750,18 +750,18 @@ bool RsGxsDataAccess::getMsgList(MsgIdReq* req) // Add the discovered Latest Msgs. for(oit = origMsgTs.begin(); oit != origMsgTs.end(); oit++) { - req->mMsgIds.insert(std::make_pair(grpId, oit->second.first)); + req->mMsgIds[grpId].push_back(oit->second.first); } } else // ALL OTHER CASES. { - std::vector::const_iterator vit = metaV.begin(); + std::vector::const_iterator vit = metaV.begin(); for(; vit != metaV.end(); vit++) { - RsMsgMetaData* msgMeta = *vit; + RsGxsMsgMetaData* msgMeta = *vit; bool add = false; /* if we are grabbing thread Head... then parentId == empty. */ @@ -788,7 +788,7 @@ bool RsGxsDataAccess::getMsgList(MsgIdReq* req) if (add) { - req->mMsgIdResult.insert(grpId,msgMeta->mMsgId); + req->mMsgIdResult[grpId].push_back(msgMeta->mMsgId); } } @@ -815,7 +815,7 @@ void RsGxsDataAccess::filterMsgList(GxsMsgIdResult& msgIds, const RsTokReqOption std::vector& msgs = mit->second; std::vector::iterator vit = msgs.begin(); const std::map& meta = cit->second; - const std::map::const_iterator cit2; + std::map::const_iterator cit2; for(; vit != msgs.end();) { diff --git a/libretroshare/src/gxs/rsgxsdataaccess.h b/libretroshare/src/gxs/rsgxsdataaccess.h index 8900f16ba..27904d749 100644 --- a/libretroshare/src/gxs/rsgxsdataaccess.h +++ b/libretroshare/src/gxs/rsgxsdataaccess.h @@ -31,9 +31,9 @@ #include "rsgds.h" -typedef std::map< RsGxsGroupId, std::map > MsgMetaFilter; +typedef std::map< RsGxsGroupId, std::map > MsgMetaFilter; -class RsGxsDataAccess : public RsTokenService +class RsGxsDataAccess : public RsTokenServiceV2 { public: RsGxsDataAccess(RsGeneralDataService* ds); diff --git a/libretroshare/src/gxs/rsgxsrequesttypes.h b/libretroshare/src/gxs/rsgxsrequesttypes.h index d187354a4..293584ab2 100644 --- a/libretroshare/src/gxs/rsgxsrequesttypes.h +++ b/libretroshare/src/gxs/rsgxsrequesttypes.h @@ -13,6 +13,9 @@ class GxsRequest { public: + + + virtual ~GxsRequest() { return; } uint32_t token; uint32_t reqTime; @@ -69,7 +72,6 @@ class MsgDataReq : public GxsRequest { public: - GxsMsgReq mMsgIds; NxsMsgDataResult mMsgData; }; diff --git a/libretroshare/src/gxs/rstokenservice.h b/libretroshare/src/gxs/rstokenservice.h index 7218fca5e..7b7acc1b6 100644 --- a/libretroshare/src/gxs/rstokenservice.h +++ b/libretroshare/src/gxs/rstokenservice.h @@ -31,11 +31,7 @@ #include #include "serialiser/rsgxsitems.h" - -typedef std::map > GxsMsgReq; -typedef std::map > GxsMsgIdResult; -typedef std::map > GxsMsgMetaResult; -typedef std::map > NxsMsgDataResult; +#include "gxs/rsgxs.h" #define GXS_REQUEST_TYPE_GROUP_DATA 0x00010000 #define GXS_REQUEST_TYPE_GROUP_META 0x00020000 @@ -79,7 +75,7 @@ time_t mAfter; * A proxy class for requesting generic service data for GXS * This seperates the request mechanism from the actual retrieval of data */ -class RsTokenService +class RsTokenServiceV2 { public: @@ -93,8 +89,8 @@ public: public: - RsTokenService() { return; } - virtual ~RsTokenService() { return; } + RsTokenServiceV2() { return; } + virtual ~RsTokenServiceV2() { return; } /* Data Requests */ diff --git a/libretroshare/src/retroshare/rsgxsservice.h b/libretroshare/src/retroshare/rsgxsservice.h index fc382e7e0..96ba495af 100644 --- a/libretroshare/src/retroshare/rsgxsservice.h +++ b/libretroshare/src/retroshare/rsgxsservice.h @@ -13,10 +13,10 @@ * enumerating all possible changes * at the interface */ -class RsGxsChange +class RsGxsNotify { public: - RsGxsChange(){ return; } + RsGxsNotify(){ return; } }; @@ -24,7 +24,7 @@ public: * Relevant to group changes * TODO: extent to indicate whether a meta change or actual data */ -class RsGxsGroupChange : RsGxsChange +class RsGxsGroupChange : public RsGxsNotify { public: std::list grpIdList; @@ -34,7 +34,7 @@ public: * Relevant to message changes * TODO: extent to indicate whether a meta change or actual data */ -class RsGxsMsgChange : RsGxsChange +class RsGxsMsgChange : public RsGxsNotify { public: std::map > msgChangeMap; diff --git a/libretroshare/src/retroshare/rsphotoV2.h b/libretroshare/src/retroshare/rsphotoV2.h index 2a7b6a330..c69c2db91 100644 --- a/libretroshare/src/retroshare/rsphotoV2.h +++ b/libretroshare/src/retroshare/rsphotoV2.h @@ -182,7 +182,7 @@ public: * * @param grpIds */ - virtual void groupsChanged(std::list& grpIds) = 0; + virtual void groupsChanged(std::list& grpIds) = 0; /*! * @@ -195,7 +195,7 @@ public: * needed to make requests to the service * @return handle to token service for this gxs service */ - virtual RsTokenService* getTokenService() = 0; + virtual RsTokenServiceV2* getTokenService() = 0; /* Generic Lists */ @@ -206,7 +206,7 @@ public: * @return false if request token is invalid, check token status for error report */ virtual bool getGroupList(const uint32_t &token, - std::list &groupIds) = 0; + std::list &groupIds) = 0; /*! * @param token token to be redeemed for this request diff --git a/libretroshare/src/serialiser/rsgxsitems.h b/libretroshare/src/serialiser/rsgxsitems.h index 72dd71748..89e18457e 100644 --- a/libretroshare/src/serialiser/rsgxsitems.h +++ b/libretroshare/src/serialiser/rsgxsitems.h @@ -53,18 +53,6 @@ class RsGroupMetaData } void operator =(const RsGxsGrpMetaData& rGxsMeta); -// { -// this->mAuthorId = rGxsMeta.mAuthorId; -// this->mGroupFlags = rGxsMeta.mGroupFlags; -// this->mGroupId = rGxsMeta.mGroupId; -// this->mGroupStatus = rGxsMeta.mGroupStatus; -// this->mLastPost = rGxsMeta.mLastPost; -// this->mMsgCount = rGxsMeta.mMsgCount; -// this->mPop = rGxsMeta.mPop; -// this->mPublishTs = rGxsMeta.mPublishTs; -// this->mSubscribeFlags = rGxsMeta.mSubscribeFlags; -// this->mGroupName = rGxsMeta.mGroupName; -// } std::string mGroupId; std::string mGroupName; diff --git a/libretroshare/src/serialiser/rsphotov2items.h b/libretroshare/src/serialiser/rsphotov2items.h index 0c4fb1d70..b44ceee62 100644 --- a/libretroshare/src/serialiser/rsphotov2items.h +++ b/libretroshare/src/serialiser/rsphotov2items.h @@ -55,6 +55,8 @@ public: class RsGxsPhotoSerialiser : public RsSerialType { +public: + RsGxsPhotoSerialiser() :RsSerialType(RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_PHOTO) { return; } diff --git a/libretroshare/src/services/p3photoserviceV2.cc b/libretroshare/src/services/p3photoserviceV2.cc index b6f5fee08..f961452e4 100644 --- a/libretroshare/src/services/p3photoserviceV2.cc +++ b/libretroshare/src/services/p3photoserviceV2.cc @@ -24,7 +24,7 @@ void p3PhotoServiceV2::msgsChanged( } -RsTokenService* p3PhotoServiceV2::getTokenService() { +RsTokenServiceV2* p3PhotoServiceV2::getTokenService() { return RsGenExchange::getTokenService(); } @@ -70,8 +70,9 @@ bool p3PhotoServiceV2::getAlbum(const uint32_t& token, std::vector for(; vit != grpData.end(); vit++) { - RsGxsGrpItem* item = *vit; - RsPhotoAlbum album = *item; + RsGxsPhotoAlbumItem* item = dynamic_cast(*vit); + RsPhotoAlbum album = item->album; + delete item; albums.push_back(album); } } @@ -80,7 +81,7 @@ bool p3PhotoServiceV2::getAlbum(const uint32_t& token, std::vector } -bool p3PhotoServiceV2::getPhoto(const uint32_t& token, PhotoResult& photo) +bool p3PhotoServiceV2::getPhoto(const uint32_t& token, PhotoResult& photos) { GxsMsgDataMap msgData; bool ok = RsGenExchange::getMsgData(token, msgData); @@ -101,8 +102,8 @@ bool p3PhotoServiceV2::getPhoto(const uint32_t& token, PhotoResult& photo) if(item) { - RsPhotoPhoto photo = *item; - photo[grpId] = photo; + RsPhotoPhoto photo = item->photo; + photos[grpId].push_back(photo); delete item; }else { @@ -121,20 +122,8 @@ bool p3PhotoServiceV2::submitAlbumDetails(RsPhotoAlbum& album) return false; } -void p3PhotoServiceV2::operator =(RsPhoto& lPhotos, - const RsGxsPhotoPhotoItem& rPhoto) -{ - lPhotos = rPhoto.photo; -} - -void p3PhotoServiceV2::operator =(RsPhotoAlbum& lAlbum, - const RsGxsPhotoAlbumItem& rAlbum) -{ - lAlbum = rAlbum.album; -} - bool p3PhotoServiceV2::submitPhoto(RsPhotoPhoto& photo) { return false; diff --git a/libretroshare/src/services/p3photoserviceV2.h b/libretroshare/src/services/p3photoserviceV2.h index 1e6ef177b..d92317c91 100644 --- a/libretroshare/src/services/p3photoserviceV2.h +++ b/libretroshare/src/services/p3photoserviceV2.h @@ -53,7 +53,7 @@ public: void msgsChanged(std::map >& msgs); - RsTokenService* getTokenService(); + RsTokenServiceV2* getTokenService(); bool getGroupList(const uint32_t &token, std::list &groupIds); @@ -71,11 +71,6 @@ public: bool getAlbum(const uint32_t &token, std::vector &albums); bool getPhoto(const uint32_t &token, PhotoResult &photos); -private: - - void operator=(RsPhoto& lPhotos, const RsGxsPhotoPhotoItem& rPhoto); - void operator=(RsPhotoAlbum& lAlbum, const RsGxsPhotoAlbumItem& rAlbum); - public: /** Modifications **/