diff --git a/libretroshare/src/gxs/gxstokenqueue.cc b/libretroshare/src/gxs/gxstokenqueue.cc index c9eb8ef92..227ea33fc 100644 --- a/libretroshare/src/gxs/gxstokenqueue.cc +++ b/libretroshare/src/gxs/gxstokenqueue.cc @@ -50,9 +50,10 @@ void GxsTokenQueue::checkRequests() for(it = mQueue.begin(); it != mQueue.end();) { uint32_t token = it->mToken; - uint32_t status = mGenExchange->getTokenService()->requestStatus(token); + it->mStatus = mGenExchange->getTokenService()->requestStatus(token); - if (status == RsTokenService::COMPLETE) + if ( it->mStatus == RsTokenService::COMPLETE + || it->mStatus == RsTokenService::CANCELLED ) { toload.push_back(*it); it = mQueue.erase(it); @@ -64,7 +65,7 @@ void GxsTokenQueue::checkRequests() #endif ++it; } - else if (status == RsTokenService::FAILED) + else if (it->mStatus == RsTokenService::FAILED) { // maybe we should do alternative callback? std::cerr << __PRETTY_FUNCTION__ << " ERROR Request Failed! " @@ -87,7 +88,7 @@ void GxsTokenQueue::checkRequests() { for(it = toload.begin(); it != toload.end(); ++it) { - handleResponse(it->mToken, it->mReqType); + handleResponse(it->mToken, it->mReqType, it->mStatus); } } } diff --git a/libretroshare/src/gxs/gxstokenqueue.h b/libretroshare/src/gxs/gxstokenqueue.h index c6c32262e..e4445c44a 100644 --- a/libretroshare/src/gxs/gxstokenqueue.h +++ b/libretroshare/src/gxs/gxstokenqueue.h @@ -23,19 +23,22 @@ #define R_GXS_TOKEN_QUEUE_H #include "gxs/rsgenexchange.h" +#include "retroshare/rsservicecontrol.h" #include "util/rsthreads.h" struct GxsTokenQueueItem { +public: GxsTokenQueueItem(const uint32_t token, const uint32_t req_type) : - mToken(token), mReqType(req_type) {} + mToken(token), mReqType(req_type), mStatus(RsTokenService::PENDING) {} - GxsTokenQueueItem(): mToken(0), mReqType(0) {} + GxsTokenQueueItem(): mToken(0), mReqType(0), mStatus(RsTokenService::PENDING) {} uint32_t mToken; uint32_t mReqType; + RsTokenService::GxsRequestStatus mStatus; }; @@ -54,7 +57,8 @@ public: protected: /// This must be overloaded to complete the functionality. - virtual void handleResponse(uint32_t token, uint32_t req_type) = 0; + virtual void handleResponse(uint32_t token, uint32_t req_type + , RsTokenService::GxsRequestStatus status) = 0; private: RsGenExchange *mGenExchange; diff --git a/libretroshare/src/gxs/rsgxsdataaccess.cc b/libretroshare/src/gxs/rsgxsdataaccess.cc index 3c97e065c..7fda35a62 100644 --- a/libretroshare/src/gxs/rsgxsdataaccess.cc +++ b/libretroshare/src/gxs/rsgxsdataaccess.cc @@ -693,10 +693,10 @@ bool RsGxsDataAccess::getServiceStatistic(const uint32_t &token, GxsServiceStati } GxsRequest* RsGxsDataAccess::locked_retrieveCompletedRequest(const uint32_t& token) { - auto it = mCompletedRequests.find(token) ; + auto it = mCompletedRequests.find(token) ; - if(it == mCompletedRequests.end()) - return nullptr; + if(it == mCompletedRequests.end()) + return nullptr; return it->second; } @@ -720,6 +720,7 @@ void RsGxsDataAccess::processRequests() { if(now > mRequestQueue.begin()->second->reqTime + MAX_REQUEST_AGE) { + mPublicToken[mRequestQueue.begin()->second->token] = CANCELLED; delete mRequestQueue.begin()->second; mRequestQueue.erase(mRequestQueue.begin()); continue; @@ -1024,7 +1025,7 @@ bool RsGxsDataAccess::getMsgMetaDataList( const GxsMsgReq& msgIds, const RsTokRe for(meta_it = result.begin(); meta_it != result.end(); ++meta_it) { - const RsGxsGroupId& grpId = meta_it->first; + //const RsGxsGroupId& grpId = meta_it->first; //auto& filter( metaFilter[grpId] ); // does the initialization of metaFilter[grpId] and avoids further O(log(n)) calls @@ -1122,8 +1123,7 @@ bool RsGxsDataAccess::getMsgMetaDataList( const GxsMsgReq& msgIds, const RsTokRe for(uint32_t i=0;imParentId.isNull()) diff --git a/libretroshare/src/gxstrans/p3gxstrans.cc b/libretroshare/src/gxstrans/p3gxstrans.cc index e3566b05a..354cf812f 100644 --- a/libretroshare/src/gxstrans/p3gxstrans.cc +++ b/libretroshare/src/gxstrans/p3gxstrans.cc @@ -137,11 +137,15 @@ void p3GxsTrans::registerGxsTransClient( mServClients[serviceType] = service; } -void p3GxsTrans::handleResponse(uint32_t token, uint32_t req_type) +void p3GxsTrans::handleResponse(uint32_t token, uint32_t req_type + , RsTokenService::GxsRequestStatus status) { #ifdef DEBUG_GXSTRANS - std::cout << "p3GxsTrans::handleResponse(" << token << ", " << req_type << ")" << std::endl; + std::cout << "p3GxsTrans::handleResponse(" << token << ", " << req_type << ", " << status << ")" << std::endl; #endif + if (status != RsTokenService::COMPLETE) + return; //For now, only manage Complete request + bool changed = false ; switch (req_type) diff --git a/libretroshare/src/gxstrans/p3gxstrans.h b/libretroshare/src/gxstrans/p3gxstrans.h index 307492281..688a9cd22 100644 --- a/libretroshare/src/gxstrans/p3gxstrans.h +++ b/libretroshare/src/gxstrans/p3gxstrans.h @@ -159,7 +159,7 @@ public: GxsTransClient* service ); /// @see RsGenExchange::getServiceInfo() - virtual RsServiceInfo getServiceInfo() { return RsServiceInfo( RS_SERVICE_TYPE_GXS_TRANS, "GXS Mails", 0, 1, 0, 1 ); } + virtual RsServiceInfo getServiceInfo() override { return RsServiceInfo( RS_SERVICE_TYPE_GXS_TRANS, "GXS Mails", 0, 1, 0, 1 ); } static const uint32_t GXS_STORAGE_PERIOD = 15*86400; // 15 days. static const uint32_t GXS_SYNC_PERIOD = 15*86400; @@ -230,30 +230,32 @@ private: inMap mIncomingQueue; RsMutex mIngoingMutex; - /// @see GxsTokenQueue::handleResponse(uint32_t token, uint32_t req_type) - virtual void handleResponse(uint32_t token, uint32_t req_type); + /// @see GxsTokenQueue::handleResponse(uint32_t token, uint32_t req_type + /// , RsTokenService::GxsRequestStatus status) + virtual void handleResponse(uint32_t token, uint32_t req_type + , RsTokenService::GxsRequestStatus status) override; /// @see RsGenExchange::service_tick() - virtual void service_tick(); + virtual void service_tick() override; /// @see RsGenExchange::service_CreateGroup(...) RsGenExchange::ServiceCreate_Return service_CreateGroup( - RsGxsGrpItem* grpItem, RsTlvSecurityKeySet& ); + RsGxsGrpItem* grpItem, RsTlvSecurityKeySet& ) override; /// @see RsGenExchange::notifyChanges(std::vector &changes) - void notifyChanges(std::vector &changes); + void notifyChanges(std::vector &changes) override; /// @see p3Config::setupSerialiser() - virtual RsSerialiser* setupSerialiser(); + virtual RsSerialiser* setupSerialiser() override; /// @see p3Config::saveList(bool &cleanup, std::list&) - virtual bool saveList(bool &cleanup, std::list&saveList); + virtual bool saveList(bool &cleanup, std::list&saveList) override; /// @see p3Config::saveDone() - void saveDone(); + void saveDone() override; /// @see p3Config::loadList(std::list&) - virtual bool loadList(std::list& loadList); + virtual bool loadList(std::list& loadList) override; /// Request groups list to GXS backend. Async method. bool requestGroupsData(const std::list* groupIds = NULL); @@ -325,9 +327,9 @@ private: // Overloaded from RsGenExchange. - bool acceptNewMessage(const RsGxsMsgMetaData *msgMeta, uint32_t size) ; + bool acceptNewMessage(const RsGxsMsgMetaData *msgMeta, uint32_t size) override; - GxsTransIntegrityCleanupThread *mCleanupThread ; + GxsTransIntegrityCleanupThread *mCleanupThread ; // statistics of the load across all groups, per user. diff --git a/libretroshare/src/services/p3gxschannels.cc b/libretroshare/src/services/p3gxschannels.cc index a69ddc8f6..1abc1f0e2 100644 --- a/libretroshare/src/services/p3gxschannels.cc +++ b/libretroshare/src/services/p3gxschannels.cc @@ -1130,12 +1130,14 @@ void p3GxsChannels::handleUnprocessedPost(const RsGxsChannelPost &msg) // Overloaded from GxsTokenQueue for Request callbacks. -void p3GxsChannels::handleResponse(uint32_t token, uint32_t req_type) +void p3GxsChannels::handleResponse(uint32_t token, uint32_t req_type + , RsTokenService::GxsRequestStatus status) { #ifdef GXSCHANNELS_DEBUG - std::cerr << "p3GxsChannels::handleResponse(" << token << "," << req_type << ")"; - std::cerr << std::endl; + std::cerr << "p3GxsChannels::handleResponse(" << token << "," << req_type << "," << status << ")" << std::endl; #endif // GXSCHANNELS_DEBUG + if (status != RsTokenService::COMPLETE) + return; //For now, only manage Complete request // stuff. switch(req_type) diff --git a/libretroshare/src/services/p3gxschannels.h b/libretroshare/src/services/p3gxschannels.h index e353881e2..98955254a 100644 --- a/libretroshare/src/services/p3gxschannels.h +++ b/libretroshare/src/services/p3gxschannels.h @@ -172,15 +172,15 @@ virtual bool getChannelDownloadDirectory(const RsGxsGroupId &groupId, std::strin // Overloaded from RsGxsIface. -virtual bool subscribeToGroup(uint32_t &token, const RsGxsGroupId &groupId, bool subscribe); +virtual bool subscribeToGroup(uint32_t &token, const RsGxsGroupId &groupId, bool subscribe) override; // Set Statuses. virtual void setMessageProcessedStatus(uint32_t& token, const RsGxsGrpMsgIdPair& msgId, bool processed); -virtual void setMessageReadStatus(uint32_t& token, const RsGxsGrpMsgIdPair& msgId, bool read); +virtual void setMessageReadStatus(uint32_t& token, const RsGxsGrpMsgIdPair& msgId, bool read) override; // File Interface - virtual bool ExtraFileHash(const std::string& path); -virtual bool ExtraFileRemove(const RsFileHash &hash); + virtual bool ExtraFileHash(const std::string& path) override; +virtual bool ExtraFileRemove(const RsFileHash &hash) override; /// Implementation of @see RsGxsChannels::getChannelsSummaries @@ -271,7 +271,7 @@ virtual bool ExtraFileRemove(const RsFileHash &hash); bool subscribe ) override; /// @see RsGxsChannels - virtual bool markRead(const RsGxsGrpMsgIdPair& msgId, bool read); + virtual bool markRead(const RsGxsGrpMsgIdPair& msgId, bool read) override; /// @see RsGxsChannels bool exportChannelLink( @@ -289,7 +289,7 @@ virtual bool ExtraFileRemove(const RsFileHash &hash); ) override; virtual bool shareChannelKeys( - const RsGxsGroupId& channelId, const std::set& peers ); + const RsGxsGroupId& channelId, const std::set& peers ) override; /// Implementation of @see RsGxsChannels::createChannel RS_DEPRECATED_FOR(createChannelV2) @@ -310,7 +310,8 @@ virtual bool ExtraFileRemove(const RsFileHash &hash); protected: // Overloaded from GxsTokenQueue for Request callbacks. - virtual void handleResponse(uint32_t token, uint32_t req_type); + virtual void handleResponse(uint32_t token, uint32_t req_type + , RsTokenService::GxsRequestStatus status) override; private: diff --git a/libretroshare/src/services/p3gxscircles.cc b/libretroshare/src/services/p3gxscircles.cc index 8eca7e3be..d943667cd 100644 --- a/libretroshare/src/services/p3gxscircles.cc +++ b/libretroshare/src/services/p3gxscircles.cc @@ -434,13 +434,13 @@ bool p3GxsCircles::revokeIdsFromCircle( const std::set& identities, con return false; } - // /!\ AVOID calling circleGrp.mInvitedMembers.erase(identities.begin(),identities.end()), because it is not the same set. Consequently - // STL code would corrupt the structure of mInvitedMembers. + // /!\ AVOID calling circleGrp.mInvitedMembers.erase(identities.begin(),identities.end()), because it is not the same set. Consequently + // STL code would corrupt the structure of mInvitedMembers. - std::set new_invited_members; - for(auto& gxs_id: circleGrp.mInvitedMembers) - if(identities.find(gxs_id) == identities.end()) - new_invited_members.insert(gxs_id); + std::set new_invited_members; + for(auto& gxs_id: circleGrp.mInvitedMembers) + if(identities.find(gxs_id) == identities.end()) + new_invited_members.insert(gxs_id); circleGrp.mInvitedMembers = new_invited_members; @@ -585,8 +585,8 @@ void p3GxsCircles::notifyChanges(std::vector &changes) std::cerr << std::endl; #endif - p3Notify *notify = RsServer::notify(); - std::set circles_to_reload; + //p3Notify *notify = RsServer::notify(); + std::set circles_to_reload; for(auto it = changes.begin(); it != changes.end(); ++it) { @@ -1505,8 +1505,8 @@ bool p3GxsCircles::locked_checkCircleCacheForMembershipUpdate(RsGxsCircleCache& { rstime_t now = time(NULL) ; - if(cache.mStatus < CircleEntryCacheStatus::UPDATING) - return false; + if(cache.mStatus < CircleEntryCacheStatus::UPDATING) + return false; if(cache.mLastUpdatedMembershipTS + GXS_CIRCLE_DELAY_TO_FORCE_MEMBERSHIP_UPDATE < now) { @@ -1559,8 +1559,8 @@ bool p3GxsCircles::locked_checkCircleCacheForAutoSubscribe(RsGxsCircleCache& cac return false; } - if(cache.mStatus < CircleEntryCacheStatus::UPDATING) - return false; + if(cache.mStatus < CircleEntryCacheStatus::UPDATING) + return false; /* if we appear in the group - then autosubscribe, and mark as processed. This also applies if we're the group admin */ @@ -1702,12 +1702,15 @@ bool p3GxsCircles::service_checkIfGroupIsStillUsed(const RsGxsGrpMetaData& meta) //====================================================================================// // Overloaded from GxsTokenQueue for Request callbacks. -void p3GxsCircles::handleResponse(uint32_t token, uint32_t req_type) +void p3GxsCircles::handleResponse(uint32_t token, uint32_t req_type + , RsTokenService::GxsRequestStatus status) { #ifdef DEBUG_CIRCLES - std::cerr << "p3GxsCircles::handleResponse(" << token << "," << req_type << ")"; - std::cerr << std::endl; + std::cerr << "p3GxsCircles::handleResponse(" << token << "," << req_type << "," << status << ")" << std::endl; #endif // DEBUG_CIRCLES + if (status != RsTokenService::COMPLETE) + return; //For now, only manage Complete request + // stuff. switch(req_type) diff --git a/libretroshare/src/services/p3gxscircles.h b/libretroshare/src/services/p3gxscircles.h index 178ec2aaf..305a3a1b9 100644 --- a/libretroshare/src/services/p3gxscircles.h +++ b/libretroshare/src/services/p3gxscircles.h @@ -250,10 +250,10 @@ public: bool revokeIdsFromCircle( const std::set& identities, const RsGxsCircleId& circleId ) override; - /// @see RsGxsCircles + /// @see RsGxsCircles bool getCircleRequest(const RsGxsGroupId& circleId, - const RsGxsMessageId& msgId, - RsGxsCircleMsg& msg) override; + const RsGxsMessageId& msgId, + RsGxsCircleMsg& msg) override; /// @see RsGxsCircles bool exportCircleLink( @@ -270,58 +270,59 @@ public: std::string& errMsg = RS_DEFAULT_STORAGE_PARAM(std::string) ) override; - virtual bool getCircleDetails(const RsGxsCircleId &id, RsGxsCircleDetails &details) override; - virtual bool getCircleExternalIdList(std::set &circleIds) override; + virtual bool getCircleDetails(const RsGxsCircleId &id, RsGxsCircleDetails &details) override; + virtual bool getCircleExternalIdList(std::set &circleIds) override; - virtual bool isLoaded(const RsGxsCircleId &circleId) override; - virtual bool loadCircle(const RsGxsCircleId &circleId) override; + virtual bool isLoaded(const RsGxsCircleId &circleId) override; + virtual bool loadCircle(const RsGxsCircleId &circleId) override; - virtual int canSend(const RsGxsCircleId &circleId, const RsPgpId &id, bool &should_encrypt) override; - virtual int canReceive(const RsGxsCircleId &circleId, const RsPgpId &id) override; - - virtual bool recipients(const RsGxsCircleId &circleId, std::list &friendlist) override; - virtual bool recipients(const RsGxsCircleId &circleId, const RsGxsGroupId& dest_group, std::list &gxs_ids) override; - virtual bool isRecipient(const RsGxsCircleId &circleId, const RsGxsGroupId& destination_group, const RsGxsId& id) override; + virtual int canSend(const RsGxsCircleId &circleId, const RsPgpId &id, bool &should_encrypt) override; + virtual int canReceive(const RsGxsCircleId &circleId, const RsPgpId &id) override; + + virtual bool recipients(const RsGxsCircleId &circleId, std::list &friendlist) override; + virtual bool recipients(const RsGxsCircleId &circleId, const RsGxsGroupId& dest_group, std::list &gxs_ids) override; + virtual bool isRecipient(const RsGxsCircleId &circleId, const RsGxsGroupId& destination_group, const RsGxsId& id) override; - virtual bool getGroupData(const uint32_t &token, std::vector &groups) override; - virtual bool getMsgData(const uint32_t &token, std::vector &msgs) override; - virtual void createGroup(uint32_t& token, RsGxsCircleGroup &group) override; - virtual void updateGroup(uint32_t &token, RsGxsCircleGroup &group) override; + virtual bool getGroupData(const uint32_t &token, std::vector &groups) override; + virtual bool getMsgData(const uint32_t &token, std::vector &msgs) override; + virtual void createGroup(uint32_t& token, RsGxsCircleGroup &group) override; + virtual void updateGroup(uint32_t &token, RsGxsCircleGroup &group) override; - virtual bool service_checkIfGroupIsStillUsed(const RsGxsGrpMetaData& meta) override; + virtual bool service_checkIfGroupIsStillUsed(const RsGxsGrpMetaData& meta) override; + + /* membership management for external circles */ + + virtual bool requestCircleMembership(const RsGxsId &own_gxsid, const RsGxsCircleId& circle_id) override; + virtual bool cancelCircleMembership(const RsGxsId &own_gxsid, const RsGxsCircleId& circle_id) override; - /* membership management for external circles */ - - virtual bool requestCircleMembership(const RsGxsId &own_gxsid, const RsGxsCircleId& circle_id) override; - virtual bool cancelCircleMembership(const RsGxsId &own_gxsid, const RsGxsCircleId& circle_id) override; - /**********************************************/ - // needed for background processing. - virtual void service_tick() override; + // needed for background processing. + virtual void service_tick() override; protected: - // overloads p3Config - virtual bool saveList(bool &cleanup, std::list&saveList) override; - virtual bool loadList(std::list& loadList) override; - virtual RsSerialiser *setupSerialiser() override; + // overloads p3Config + virtual bool saveList(bool &cleanup, std::list&saveList) override; + virtual bool loadList(std::list& loadList) override; + virtual RsSerialiser *setupSerialiser() override; - bool pushCircleMembershipRequest(const RsGxsId& own_gxsid, const RsGxsCircleId& circle_id, RsGxsCircleSubscriptionType request_type) ; + bool pushCircleMembershipRequest(const RsGxsId& own_gxsid, const RsGxsCircleId& circle_id, RsGxsCircleSubscriptionType request_type) ; static uint32_t circleAuthenPolicy(); /** Notifications **/ - virtual void notifyChanges(std::vector& changes) override; + virtual void notifyChanges(std::vector& changes) override; /** Overloaded to add PgpIdHash to Group Definition **/ - virtual ServiceCreate_Return service_CreateGroup(RsGxsGrpItem* grpItem, RsTlvSecurityKeySet& keySet) override; + virtual ServiceCreate_Return service_CreateGroup(RsGxsGrpItem* grpItem, RsTlvSecurityKeySet& keySet) override; // Overloaded from GxsTokenQueue for Request callbacks. - virtual void handleResponse(uint32_t token, uint32_t req_type) override; + virtual void handleResponse(uint32_t token, uint32_t req_type + , RsTokenService::GxsRequestStatus status) override; // Overloaded from RsTickEvent. - virtual void handle_event(uint32_t event_type, const std::string &elabel) override; + virtual void handle_event(uint32_t event_type, const std::string &elabel) override; private: diff --git a/libretroshare/src/services/p3gxscommon.cc b/libretroshare/src/services/p3gxscommon.cc index 38f6f3cc0..7c37bd6aa 100644 --- a/libretroshare/src/services/p3gxscommon.cc +++ b/libretroshare/src/services/p3gxscommon.cc @@ -199,7 +199,7 @@ bool p3GxsCommentService::getGxsCommentData(const uint32_t &token, std::vectorfirst; + //RsGxsGroupId grpId = mit->first; std::vector& msgItems = mit->second; std::vector::iterator vit = msgItems.begin(); @@ -697,12 +697,15 @@ bool p3GxsCommentService::acknowledgeVote(const uint32_t& token, RsGxsGrpMsgIdPa // Overloaded from GxsTokenQueue for Request callbacks. -void p3GxsCommentService::handleResponse(uint32_t token, uint32_t req_type) +void p3GxsCommentService::handleResponse(uint32_t token, uint32_t req_type + , RsTokenService::GxsRequestStatus status) { #ifdef DEBUG_GXSCOMMON - std::cerr << "p3GxsCommentService::handleResponse(" << token << "," << req_type << ")"; - std::cerr << std::endl; + std::cerr << "p3GxsCommentService::handleResponse(" << token << "," << req_type << "," << status << ")" << std::endl; #endif + if (status != RsTokenService::COMPLETE) + return; //For now, only manage Complete request + // stuff. switch(req_type) diff --git a/libretroshare/src/services/p3gxscommon.h b/libretroshare/src/services/p3gxscommon.h index 4b25c826e..fb51a0d30 100644 --- a/libretroshare/src/services/p3gxscommon.h +++ b/libretroshare/src/services/p3gxscommon.h @@ -82,7 +82,8 @@ static double calculateBestScore(int upVotes, int downVotes); protected: // Overloaded from GxsTokenQueue for Request callbacks. -virtual void handleResponse(uint32_t token, uint32_t req_type); + virtual void handleResponse(uint32_t token, uint32_t req_type + , RsTokenService::GxsRequestStatus status) override; private: diff --git a/libretroshare/src/services/p3idservice.cc b/libretroshare/src/services/p3idservice.cc index b48a25abd..8c3b18ec5 100644 --- a/libretroshare/src/services/p3idservice.cc +++ b/libretroshare/src/services/p3idservice.cc @@ -151,27 +151,26 @@ RsIdentity* rsIdentity = nullptr; /******************* Startup / Tick ******************************************/ /********************************************************************************/ -p3IdService::p3IdService( - RsGeneralDataService *gds, RsNetworkExchangeService *nes, - PgpAuxUtils *pgpUtils ) : - RsGxsIdExchange( gds, nes, new RsGxsIdSerialiser(), - RS_SERVICE_GXS_TYPE_GXSID, idAuthenPolicy() ), - RsIdentity(static_cast(*this)), GxsTokenQueue(this), - RsTickEvent(), mKeyCache(GXSID_MAX_CACHE_SIZE, "GxsIdKeyCache"), - mIdMtx("p3IdService"), mNes(nes), mPgpUtils(pgpUtils) +p3IdService::p3IdService( RsGeneralDataService *gds + , RsNetworkExchangeService *nes + , PgpAuxUtils *pgpUtils ) + : RsGxsIdExchange( gds, nes, new RsGxsIdSerialiser(), + RS_SERVICE_GXS_TYPE_GXSID, idAuthenPolicy() ) + , RsIdentity(static_cast(*this)) + , GxsTokenQueue(this), RsTickEvent(), p3Config() + , mKeyCache(GXSID_MAX_CACHE_SIZE, "GxsIdKeyCache") + , mBgSchedule_Active(false), mBgSchedule_Mode(0) + , mIdMtx("p3IdService"), mNes(nes), mPgpUtils(pgpUtils) + , mLastConfigUpdate(0), mOwnIdsLoaded(false) + , mAutoAddFriendsIdentitiesAsContacts(true) /*default*/ + , mMaxKeepKeysBanned(MAX_KEEP_KEYS_BANNED_DEFAULT) { - mBgSchedule_Mode = 0; - mBgSchedule_Active = false; - mLastKeyCleaningTime = time(NULL) - int(MAX_DELAY_BEFORE_CLEANING * 0.9) ; - mLastConfigUpdate = 0 ; - mOwnIdsLoaded = false ; - mAutoAddFriendsIdentitiesAsContacts = true; // default - mMaxKeepKeysBanned = MAX_KEEP_KEYS_BANNED_DEFAULT; + mLastKeyCleaningTime = time(NULL) - int(MAX_DELAY_BEFORE_CLEANING * 0.9) ; // Kick off Cache Testing, + Others. + RsTickEvent::schedule_now(GXSID_EVENT_CACHEOWNIDS);//First Thing to do RsTickEvent::schedule_in(GXSID_EVENT_PGPHASH, PGPHASH_PERIOD); RsTickEvent::schedule_in(GXSID_EVENT_REPUTATION, REPUTATION_PERIOD); - RsTickEvent::schedule_now(GXSID_EVENT_CACHEOWNIDS); //RsTickEvent::schedule_in(GXSID_EVENT_CACHETEST, CACHETEST_PERIOD); @@ -4427,7 +4426,7 @@ void p3IdService::generateDummy_OwnIds() /* grab all the gpg ids... and make some ids */ - RsPgpId ownId = mPgpUtils->getPGPOwnId(); + /*RsPgpId ownId = */mPgpUtils->getPGPOwnId(); #if 0 // generate some ownIds. @@ -4643,36 +4642,37 @@ void p3IdService::checkPeerForIdentities() // Overloaded from GxsTokenQueue for Request callbacks. -void p3IdService::handleResponse(uint32_t token, uint32_t req_type) +void p3IdService::handleResponse(uint32_t token, uint32_t req_type + , RsTokenService::GxsRequestStatus status) { #ifdef DEBUG_IDS - std::cerr << "p3IdService::handleResponse(" << token << "," << req_type << ")"; - std::cerr << std::endl; + std::cerr << "p3IdService::handleResponse(" << token << "," << req_type << "," << status << ")" << std::endl; #endif // DEBUG_IDS // stuff. switch(req_type) { case GXSIDREQ_CACHEOWNIDS: - cache_load_ownids(token); + if (status == RsTokenService::COMPLETE) cache_load_ownids(token); + if (status == RsTokenService::CANCELLED) RsTickEvent::schedule_now(GXSID_EVENT_CACHEOWNIDS);//Cancelled by time-out so ask a new time break; case GXSIDREQ_CACHELOAD: - cache_load_for_token(token); + if (status == RsTokenService::COMPLETE) cache_load_for_token(token); break; case GXSIDREQ_PGPHASH: - pgphash_handlerequest(token); + if (status == RsTokenService::COMPLETE) pgphash_handlerequest(token); break; case GXSIDREQ_RECOGN: - recogn_handlerequest(token); + if (status == RsTokenService::COMPLETE) recogn_handlerequest(token); break; case GXSIDREQ_CACHETEST: - cachetest_handlerequest(token); + if (status == RsTokenService::COMPLETE) cachetest_handlerequest(token); break; case GXSIDREQ_OPINION: - opinion_handlerequest(token); + if (status == RsTokenService::COMPLETE) opinion_handlerequest(token); break; case GXSIDREQ_SERIALIZE_TO_MEMORY: - handle_get_serialized_grp(token); + if (status == RsTokenService::COMPLETE) handle_get_serialized_grp(token); break; default: std::cerr << "p3IdService::handleResponse() Unknown Request Type: " diff --git a/libretroshare/src/services/p3idservice.h b/libretroshare/src/services/p3idservice.h index 9f9e03d17..2dc5e29b2 100644 --- a/libretroshare/src/services/p3idservice.h +++ b/libretroshare/src/services/p3idservice.h @@ -407,8 +407,9 @@ protected: // Overloads RsGxsGenExchange virtual bool acceptNewGroup(const RsGxsGrpMetaData *grpMeta) override ; - // Overloaded from GxsTokenQueue for Request callbacks. - virtual void handleResponse(uint32_t token, uint32_t req_type) override; + // Overloaded from GxsTokenQueue for Request callbacks. + virtual void handleResponse(uint32_t token, uint32_t req_type + , RsTokenService::GxsRequestStatus status) override; // Overloaded from RsTickEvent. virtual void handle_event(uint32_t event_type, const std::string &elabel) override; @@ -561,7 +562,7 @@ private: void cleanUnusedKeys() ; void slowIndicateConfigChanged() ; - virtual void timeStampKey(const RsGxsId& id, const RsIdentityUsage& reason) ; + virtual void timeStampKey(const RsGxsId& id, const RsIdentityUsage& reason) override; rstime_t locked_getLastUsageTS(const RsGxsId& gxs_id); std::string genRandomId(int len = 20); diff --git a/libretroshare/src/services/p3postbase.cc b/libretroshare/src/services/p3postbase.cc index 5585b256d..dd4d9f684 100644 --- a/libretroshare/src/services/p3postbase.cc +++ b/libretroshare/src/services/p3postbase.cc @@ -849,12 +849,14 @@ bool p3PostBase::background_cleanup() // Overloaded from GxsTokenQueue for Request callbacks. -void p3PostBase::handleResponse(uint32_t token, uint32_t req_type) +void p3PostBase::handleResponse(uint32_t token, uint32_t req_type + , RsTokenService::GxsRequestStatus status) { #ifdef POSTBASE_DEBUG - std::cerr << "p3PostBase::handleResponse(" << token << "," << req_type << ")"; - std::cerr << std::endl; + std::cerr << "p3PostBase::handleResponse(" << token << "," << req_type << "," << status << ")" << std::endl; #endif + if (status != RsTokenService::COMPLETE) + return; //For now, only manage Complete request // stuff. switch(req_type) diff --git a/libretroshare/src/services/p3postbase.h b/libretroshare/src/services/p3postbase.h index 864d57206..3c2f5f67f 100644 --- a/libretroshare/src/services/p3postbase.h +++ b/libretroshare/src/services/p3postbase.h @@ -70,17 +70,18 @@ public: p3PostBase(RsGeneralDataService *gds, RsNetworkExchangeService *nes, RsGixs* gixs, RsSerialType* serviceSerialiser, uint16_t serviceType); - virtual void service_tick() override; + virtual void service_tick() override; protected: - virtual void notifyChanges(std::vector& changes) override; + virtual void notifyChanges(std::vector& changes) override; // Overloaded from GxsTokenQueue for Request callbacks. - virtual void handleResponse(uint32_t token, uint32_t req_type) override; + virtual void handleResponse(uint32_t token, uint32_t req_type + , RsTokenService::GxsRequestStatus status) override; // Overloaded from RsTickEvent. - virtual void handle_event(uint32_t event_type, const std::string &elabel) override; + virtual void handle_event(uint32_t event_type, const std::string &elabel) override; // overloads p3Config virtual RsSerialiser* setupSerialiser() override; // @see p3Config::setupSerialiser()