Add ability to manage canceled token in Gxs.

This commit is contained in:
Phenom 2020-11-30 09:08:29 +01:00
parent d0b8c7dd69
commit ec32ec9983
15 changed files with 154 additions and 128 deletions

View File

@ -50,9 +50,10 @@ void GxsTokenQueue::checkRequests()
for(it = mQueue.begin(); it != mQueue.end();) for(it = mQueue.begin(); it != mQueue.end();)
{ {
uint32_t token = it->mToken; 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); toload.push_back(*it);
it = mQueue.erase(it); it = mQueue.erase(it);
@ -64,7 +65,7 @@ void GxsTokenQueue::checkRequests()
#endif #endif
++it; ++it;
} }
else if (status == RsTokenService::FAILED) else if (it->mStatus == RsTokenService::FAILED)
{ {
// maybe we should do alternative callback? // maybe we should do alternative callback?
std::cerr << __PRETTY_FUNCTION__ << " ERROR Request Failed! " std::cerr << __PRETTY_FUNCTION__ << " ERROR Request Failed! "
@ -87,7 +88,7 @@ void GxsTokenQueue::checkRequests()
{ {
for(it = toload.begin(); it != toload.end(); ++it) for(it = toload.begin(); it != toload.end(); ++it)
{ {
handleResponse(it->mToken, it->mReqType); handleResponse(it->mToken, it->mReqType, it->mStatus);
} }
} }
} }

View File

@ -23,19 +23,22 @@
#define R_GXS_TOKEN_QUEUE_H #define R_GXS_TOKEN_QUEUE_H
#include "gxs/rsgenexchange.h" #include "gxs/rsgenexchange.h"
#include "retroshare/rsservicecontrol.h"
#include "util/rsthreads.h" #include "util/rsthreads.h"
struct GxsTokenQueueItem struct GxsTokenQueueItem
{ {
public:
GxsTokenQueueItem(const uint32_t token, const uint32_t req_type) : 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 mToken;
uint32_t mReqType; uint32_t mReqType;
RsTokenService::GxsRequestStatus mStatus;
}; };
@ -54,7 +57,8 @@ public:
protected: protected:
/// This must be overloaded to complete the functionality. /// 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: private:
RsGenExchange *mGenExchange; RsGenExchange *mGenExchange;

View File

@ -693,10 +693,10 @@ bool RsGxsDataAccess::getServiceStatistic(const uint32_t &token, GxsServiceStati
} }
GxsRequest* RsGxsDataAccess::locked_retrieveCompletedRequest(const uint32_t& token) GxsRequest* RsGxsDataAccess::locked_retrieveCompletedRequest(const uint32_t& token)
{ {
auto it = mCompletedRequests.find(token) ; auto it = mCompletedRequests.find(token) ;
if(it == mCompletedRequests.end()) if(it == mCompletedRequests.end())
return nullptr; return nullptr;
return it->second; return it->second;
} }
@ -720,6 +720,7 @@ void RsGxsDataAccess::processRequests()
{ {
if(now > mRequestQueue.begin()->second->reqTime + MAX_REQUEST_AGE) if(now > mRequestQueue.begin()->second->reqTime + MAX_REQUEST_AGE)
{ {
mPublicToken[mRequestQueue.begin()->second->token] = CANCELLED;
delete mRequestQueue.begin()->second; delete mRequestQueue.begin()->second;
mRequestQueue.erase(mRequestQueue.begin()); mRequestQueue.erase(mRequestQueue.begin());
continue; continue;
@ -1024,7 +1025,7 @@ bool RsGxsDataAccess::getMsgMetaDataList( const GxsMsgReq& msgIds, const RsTokRe
for(meta_it = result.begin(); meta_it != result.end(); ++meta_it) 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 //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;i<metaV.size();++i) for(uint32_t i=0;i<metaV.size();++i)
if(metaV[i] != nullptr) if(metaV[i] != nullptr)
{ {
const auto& msgMeta = metaV[i]; const auto& msgMeta = metaV[i];
bool add = false;
/* if we are grabbing thread Head... then parentId == empty. */ /* if we are grabbing thread Head... then parentId == empty. */
if (onlyThreadHeadMsgs && !msgMeta->mParentId.isNull()) if (onlyThreadHeadMsgs && !msgMeta->mParentId.isNull())

View File

@ -137,11 +137,15 @@ void p3GxsTrans::registerGxsTransClient(
mServClients[serviceType] = service; 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 #ifdef DEBUG_GXSTRANS
std::cout << "p3GxsTrans::handleResponse(" << token << ", " << req_type << ")" << std::endl; std::cout << "p3GxsTrans::handleResponse(" << token << ", " << req_type << ", " << status << ")" << std::endl;
#endif #endif
if (status != RsTokenService::COMPLETE)
return; //For now, only manage Complete request
bool changed = false ; bool changed = false ;
switch (req_type) switch (req_type)

View File

@ -159,7 +159,7 @@ public:
GxsTransClient* service ); GxsTransClient* service );
/// @see RsGenExchange::getServiceInfo() /// @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_STORAGE_PERIOD = 15*86400; // 15 days.
static const uint32_t GXS_SYNC_PERIOD = 15*86400; static const uint32_t GXS_SYNC_PERIOD = 15*86400;
@ -230,30 +230,32 @@ private:
inMap mIncomingQueue; inMap mIncomingQueue;
RsMutex mIngoingMutex; RsMutex mIngoingMutex;
/// @see GxsTokenQueue::handleResponse(uint32_t token, uint32_t req_type) /// @see GxsTokenQueue::handleResponse(uint32_t token, uint32_t req_type
virtual void 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() /// @see RsGenExchange::service_tick()
virtual void service_tick(); virtual void service_tick() override;
/// @see RsGenExchange::service_CreateGroup(...) /// @see RsGenExchange::service_CreateGroup(...)
RsGenExchange::ServiceCreate_Return service_CreateGroup( RsGenExchange::ServiceCreate_Return service_CreateGroup(
RsGxsGrpItem* grpItem, RsTlvSecurityKeySet& ); RsGxsGrpItem* grpItem, RsTlvSecurityKeySet& ) override;
/// @see RsGenExchange::notifyChanges(std::vector<RsGxsNotify *> &changes) /// @see RsGenExchange::notifyChanges(std::vector<RsGxsNotify *> &changes)
void notifyChanges(std::vector<RsGxsNotify *> &changes); void notifyChanges(std::vector<RsGxsNotify *> &changes) override;
/// @see p3Config::setupSerialiser() /// @see p3Config::setupSerialiser()
virtual RsSerialiser* setupSerialiser(); virtual RsSerialiser* setupSerialiser() override;
/// @see p3Config::saveList(bool &cleanup, std::list<RsItem *>&) /// @see p3Config::saveList(bool &cleanup, std::list<RsItem *>&)
virtual bool saveList(bool &cleanup, std::list<RsItem *>&saveList); virtual bool saveList(bool &cleanup, std::list<RsItem *>&saveList) override;
/// @see p3Config::saveDone() /// @see p3Config::saveDone()
void saveDone(); void saveDone() override;
/// @see p3Config::loadList(std::list<RsItem *>&) /// @see p3Config::loadList(std::list<RsItem *>&)
virtual bool loadList(std::list<RsItem *>& loadList); virtual bool loadList(std::list<RsItem *>& loadList) override;
/// Request groups list to GXS backend. Async method. /// Request groups list to GXS backend. Async method.
bool requestGroupsData(const std::list<RsGxsGroupId>* groupIds = NULL); bool requestGroupsData(const std::list<RsGxsGroupId>* groupIds = NULL);
@ -325,9 +327,9 @@ private:
// Overloaded from RsGenExchange. // 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. // statistics of the load across all groups, per user.

View File

@ -1130,12 +1130,14 @@ void p3GxsChannels::handleUnprocessedPost(const RsGxsChannelPost &msg)
// Overloaded from GxsTokenQueue for Request callbacks. // 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 #ifdef GXSCHANNELS_DEBUG
std::cerr << "p3GxsChannels::handleResponse(" << token << "," << req_type << ")"; std::cerr << "p3GxsChannels::handleResponse(" << token << "," << req_type << "," << status << ")" << std::endl;
std::cerr << std::endl;
#endif // GXSCHANNELS_DEBUG #endif // GXSCHANNELS_DEBUG
if (status != RsTokenService::COMPLETE)
return; //For now, only manage Complete request
// stuff. // stuff.
switch(req_type) switch(req_type)

View File

@ -172,15 +172,15 @@ virtual bool getChannelDownloadDirectory(const RsGxsGroupId &groupId, std::strin
// Overloaded from RsGxsIface. // 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. // Set Statuses.
virtual void setMessageProcessedStatus(uint32_t& token, const RsGxsGrpMsgIdPair& msgId, bool processed); 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 // File Interface
virtual bool ExtraFileHash(const std::string& path); virtual bool ExtraFileHash(const std::string& path) override;
virtual bool ExtraFileRemove(const RsFileHash &hash); virtual bool ExtraFileRemove(const RsFileHash &hash) override;
/// Implementation of @see RsGxsChannels::getChannelsSummaries /// Implementation of @see RsGxsChannels::getChannelsSummaries
@ -271,7 +271,7 @@ virtual bool ExtraFileRemove(const RsFileHash &hash);
bool subscribe ) override; bool subscribe ) override;
/// @see RsGxsChannels /// @see RsGxsChannels
virtual bool markRead(const RsGxsGrpMsgIdPair& msgId, bool read); virtual bool markRead(const RsGxsGrpMsgIdPair& msgId, bool read) override;
/// @see RsGxsChannels /// @see RsGxsChannels
bool exportChannelLink( bool exportChannelLink(
@ -289,7 +289,7 @@ virtual bool ExtraFileRemove(const RsFileHash &hash);
) override; ) override;
virtual bool shareChannelKeys( virtual bool shareChannelKeys(
const RsGxsGroupId& channelId, const std::set<RsPeerId>& peers ); const RsGxsGroupId& channelId, const std::set<RsPeerId>& peers ) override;
/// Implementation of @see RsGxsChannels::createChannel /// Implementation of @see RsGxsChannels::createChannel
RS_DEPRECATED_FOR(createChannelV2) RS_DEPRECATED_FOR(createChannelV2)
@ -310,7 +310,8 @@ virtual bool ExtraFileRemove(const RsFileHash &hash);
protected: protected:
// Overloaded from GxsTokenQueue for Request callbacks. // 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: private:

View File

@ -434,13 +434,13 @@ bool p3GxsCircles::revokeIdsFromCircle( const std::set<RsGxsId>& identities, con
return false; return false;
} }
// /!\ AVOID calling circleGrp.mInvitedMembers.erase(identities.begin(),identities.end()), because it is not the same set. Consequently // /!\ 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. // STL code would corrupt the structure of mInvitedMembers.
std::set<RsGxsId> new_invited_members; std::set<RsGxsId> new_invited_members;
for(auto& gxs_id: circleGrp.mInvitedMembers) for(auto& gxs_id: circleGrp.mInvitedMembers)
if(identities.find(gxs_id) == identities.end()) if(identities.find(gxs_id) == identities.end())
new_invited_members.insert(gxs_id); new_invited_members.insert(gxs_id);
circleGrp.mInvitedMembers = new_invited_members; circleGrp.mInvitedMembers = new_invited_members;
@ -585,8 +585,8 @@ void p3GxsCircles::notifyChanges(std::vector<RsGxsNotify *> &changes)
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
p3Notify *notify = RsServer::notify(); //p3Notify *notify = RsServer::notify();
std::set<RsGxsCircleId> circles_to_reload; std::set<RsGxsCircleId> circles_to_reload;
for(auto it = changes.begin(); it != changes.end(); ++it) for(auto it = changes.begin(); it != changes.end(); ++it)
{ {
@ -1505,8 +1505,8 @@ bool p3GxsCircles::locked_checkCircleCacheForMembershipUpdate(RsGxsCircleCache&
{ {
rstime_t now = time(NULL) ; rstime_t now = time(NULL) ;
if(cache.mStatus < CircleEntryCacheStatus::UPDATING) if(cache.mStatus < CircleEntryCacheStatus::UPDATING)
return false; return false;
if(cache.mLastUpdatedMembershipTS + GXS_CIRCLE_DELAY_TO_FORCE_MEMBERSHIP_UPDATE < now) if(cache.mLastUpdatedMembershipTS + GXS_CIRCLE_DELAY_TO_FORCE_MEMBERSHIP_UPDATE < now)
{ {
@ -1559,8 +1559,8 @@ bool p3GxsCircles::locked_checkCircleCacheForAutoSubscribe(RsGxsCircleCache& cac
return false; return false;
} }
if(cache.mStatus < CircleEntryCacheStatus::UPDATING) if(cache.mStatus < CircleEntryCacheStatus::UPDATING)
return false; return false;
/* if we appear in the group - then autosubscribe, and mark as processed. This also applies if we're the group admin */ /* 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. // 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 #ifdef DEBUG_CIRCLES
std::cerr << "p3GxsCircles::handleResponse(" << token << "," << req_type << ")"; std::cerr << "p3GxsCircles::handleResponse(" << token << "," << req_type << "," << status << ")" << std::endl;
std::cerr << std::endl;
#endif // DEBUG_CIRCLES #endif // DEBUG_CIRCLES
if (status != RsTokenService::COMPLETE)
return; //For now, only manage Complete request
// stuff. // stuff.
switch(req_type) switch(req_type)

View File

@ -250,10 +250,10 @@ public:
bool revokeIdsFromCircle( const std::set<RsGxsId>& identities, bool revokeIdsFromCircle( const std::set<RsGxsId>& identities,
const RsGxsCircleId& circleId ) override; const RsGxsCircleId& circleId ) override;
/// @see RsGxsCircles /// @see RsGxsCircles
bool getCircleRequest(const RsGxsGroupId& circleId, bool getCircleRequest(const RsGxsGroupId& circleId,
const RsGxsMessageId& msgId, const RsGxsMessageId& msgId,
RsGxsCircleMsg& msg) override; RsGxsCircleMsg& msg) override;
/// @see RsGxsCircles /// @see RsGxsCircles
bool exportCircleLink( bool exportCircleLink(
@ -270,58 +270,59 @@ public:
std::string& errMsg = RS_DEFAULT_STORAGE_PARAM(std::string) std::string& errMsg = RS_DEFAULT_STORAGE_PARAM(std::string)
) override; ) override;
virtual bool getCircleDetails(const RsGxsCircleId &id, RsGxsCircleDetails &details) override; virtual bool getCircleDetails(const RsGxsCircleId &id, RsGxsCircleDetails &details) override;
virtual bool getCircleExternalIdList(std::set<RsGxsCircleId> &circleIds) override; virtual bool getCircleExternalIdList(std::set<RsGxsCircleId> &circleIds) override;
virtual bool isLoaded(const RsGxsCircleId &circleId) override; virtual bool isLoaded(const RsGxsCircleId &circleId) override;
virtual bool loadCircle(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 canSend(const RsGxsCircleId &circleId, const RsPgpId &id, bool &should_encrypt) override;
virtual int canReceive(const RsGxsCircleId &circleId, const RsPgpId &id) override; virtual int canReceive(const RsGxsCircleId &circleId, const RsPgpId &id) override;
virtual bool recipients(const RsGxsCircleId &circleId, std::list<RsPgpId> &friendlist) override; virtual bool recipients(const RsGxsCircleId &circleId, std::list<RsPgpId> &friendlist) override;
virtual bool recipients(const RsGxsCircleId &circleId, const RsGxsGroupId& dest_group, std::list<RsGxsId> &gxs_ids) override; virtual bool recipients(const RsGxsCircleId &circleId, const RsGxsGroupId& dest_group, std::list<RsGxsId> &gxs_ids) override;
virtual bool isRecipient(const RsGxsCircleId &circleId, const RsGxsGroupId& destination_group, const RsGxsId& id) override; virtual bool isRecipient(const RsGxsCircleId &circleId, const RsGxsGroupId& destination_group, const RsGxsId& id) override;
virtual bool getGroupData(const uint32_t &token, std::vector<RsGxsCircleGroup> &groups) override; virtual bool getGroupData(const uint32_t &token, std::vector<RsGxsCircleGroup> &groups) override;
virtual bool getMsgData(const uint32_t &token, std::vector<RsGxsCircleMsg> &msgs) override; virtual bool getMsgData(const uint32_t &token, std::vector<RsGxsCircleMsg> &msgs) override;
virtual void createGroup(uint32_t& token, RsGxsCircleGroup &group) override; virtual void createGroup(uint32_t& token, RsGxsCircleGroup &group) override;
virtual void updateGroup(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 */ /* membership management for external circles */
virtual bool requestCircleMembership(const RsGxsId &own_gxsid, const RsGxsCircleId& circle_id) override; virtual bool requestCircleMembership(const RsGxsId &own_gxsid, const RsGxsCircleId& circle_id) override;
virtual bool cancelCircleMembership(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. // needed for background processing.
virtual void service_tick() override; virtual void service_tick() override;
protected: protected:
// overloads p3Config // overloads p3Config
virtual bool saveList(bool &cleanup, std::list<RsItem *>&saveList) override; virtual bool saveList(bool &cleanup, std::list<RsItem *>&saveList) override;
virtual bool loadList(std::list<RsItem *>& loadList) override; virtual bool loadList(std::list<RsItem *>& loadList) override;
virtual RsSerialiser *setupSerialiser() 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(); static uint32_t circleAuthenPolicy();
/** Notifications **/ /** Notifications **/
virtual void notifyChanges(std::vector<RsGxsNotify*>& changes) override; virtual void notifyChanges(std::vector<RsGxsNotify*>& changes) override;
/** Overloaded to add PgpIdHash to Group Definition **/ /** 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. // 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. // 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: private:

View File

@ -199,7 +199,7 @@ bool p3GxsCommentService::getGxsCommentData(const uint32_t &token, std::vector<R
for(; mit != msgData.end(); ++mit) for(; mit != msgData.end(); ++mit)
{ {
RsGxsGroupId grpId = mit->first; //RsGxsGroupId grpId = mit->first;
std::vector<RsGxsMsgItem*>& msgItems = mit->second; std::vector<RsGxsMsgItem*>& msgItems = mit->second;
std::vector<RsGxsMsgItem*>::iterator vit = msgItems.begin(); std::vector<RsGxsMsgItem*>::iterator vit = msgItems.begin();
@ -697,12 +697,15 @@ bool p3GxsCommentService::acknowledgeVote(const uint32_t& token, RsGxsGrpMsgIdPa
// Overloaded from GxsTokenQueue for Request callbacks. // 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 #ifdef DEBUG_GXSCOMMON
std::cerr << "p3GxsCommentService::handleResponse(" << token << "," << req_type << ")"; std::cerr << "p3GxsCommentService::handleResponse(" << token << "," << req_type << "," << status << ")" << std::endl;
std::cerr << std::endl;
#endif #endif
if (status != RsTokenService::COMPLETE)
return; //For now, only manage Complete request
// stuff. // stuff.
switch(req_type) switch(req_type)

View File

@ -82,7 +82,8 @@ static double calculateBestScore(int upVotes, int downVotes);
protected: protected:
// Overloaded from GxsTokenQueue for Request callbacks. // 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: private:

View File

@ -151,27 +151,26 @@ RsIdentity* rsIdentity = nullptr;
/******************* Startup / Tick ******************************************/ /******************* Startup / Tick ******************************************/
/********************************************************************************/ /********************************************************************************/
p3IdService::p3IdService( p3IdService::p3IdService( RsGeneralDataService *gds
RsGeneralDataService *gds, RsNetworkExchangeService *nes, , RsNetworkExchangeService *nes
PgpAuxUtils *pgpUtils ) : , PgpAuxUtils *pgpUtils )
RsGxsIdExchange( gds, nes, new RsGxsIdSerialiser(), : RsGxsIdExchange( gds, nes, new RsGxsIdSerialiser(),
RS_SERVICE_GXS_TYPE_GXSID, idAuthenPolicy() ), RS_SERVICE_GXS_TYPE_GXSID, idAuthenPolicy() )
RsIdentity(static_cast<RsGxsIface&>(*this)), GxsTokenQueue(this), , RsIdentity(static_cast<RsGxsIface&>(*this))
RsTickEvent(), mKeyCache(GXSID_MAX_CACHE_SIZE, "GxsIdKeyCache"), , GxsTokenQueue(this), RsTickEvent(), p3Config()
mIdMtx("p3IdService"), mNes(nes), mPgpUtils(pgpUtils) , 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; mLastKeyCleaningTime = time(NULL) - int(MAX_DELAY_BEFORE_CLEANING * 0.9) ;
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;
// Kick off Cache Testing, + Others. // 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_PGPHASH, PGPHASH_PERIOD);
RsTickEvent::schedule_in(GXSID_EVENT_REPUTATION, REPUTATION_PERIOD); RsTickEvent::schedule_in(GXSID_EVENT_REPUTATION, REPUTATION_PERIOD);
RsTickEvent::schedule_now(GXSID_EVENT_CACHEOWNIDS);
//RsTickEvent::schedule_in(GXSID_EVENT_CACHETEST, CACHETEST_PERIOD); //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 */ /* grab all the gpg ids... and make some ids */
RsPgpId ownId = mPgpUtils->getPGPOwnId(); /*RsPgpId ownId = */mPgpUtils->getPGPOwnId();
#if 0 #if 0
// generate some ownIds. // generate some ownIds.
@ -4643,36 +4642,37 @@ void p3IdService::checkPeerForIdentities()
// Overloaded from GxsTokenQueue for Request callbacks. // 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 #ifdef DEBUG_IDS
std::cerr << "p3IdService::handleResponse(" << token << "," << req_type << ")"; std::cerr << "p3IdService::handleResponse(" << token << "," << req_type << "," << status << ")" << std::endl;
std::cerr << std::endl;
#endif // DEBUG_IDS #endif // DEBUG_IDS
// stuff. // stuff.
switch(req_type) switch(req_type)
{ {
case GXSIDREQ_CACHEOWNIDS: 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; break;
case GXSIDREQ_CACHELOAD: case GXSIDREQ_CACHELOAD:
cache_load_for_token(token); if (status == RsTokenService::COMPLETE) cache_load_for_token(token);
break; break;
case GXSIDREQ_PGPHASH: case GXSIDREQ_PGPHASH:
pgphash_handlerequest(token); if (status == RsTokenService::COMPLETE) pgphash_handlerequest(token);
break; break;
case GXSIDREQ_RECOGN: case GXSIDREQ_RECOGN:
recogn_handlerequest(token); if (status == RsTokenService::COMPLETE) recogn_handlerequest(token);
break; break;
case GXSIDREQ_CACHETEST: case GXSIDREQ_CACHETEST:
cachetest_handlerequest(token); if (status == RsTokenService::COMPLETE) cachetest_handlerequest(token);
break; break;
case GXSIDREQ_OPINION: case GXSIDREQ_OPINION:
opinion_handlerequest(token); if (status == RsTokenService::COMPLETE) opinion_handlerequest(token);
break; break;
case GXSIDREQ_SERIALIZE_TO_MEMORY: case GXSIDREQ_SERIALIZE_TO_MEMORY:
handle_get_serialized_grp(token); if (status == RsTokenService::COMPLETE) handle_get_serialized_grp(token);
break; break;
default: default:
std::cerr << "p3IdService::handleResponse() Unknown Request Type: " std::cerr << "p3IdService::handleResponse() Unknown Request Type: "

View File

@ -407,8 +407,9 @@ protected:
// Overloads RsGxsGenExchange // Overloads RsGxsGenExchange
virtual bool acceptNewGroup(const RsGxsGrpMetaData *grpMeta) override ; virtual bool acceptNewGroup(const RsGxsGrpMetaData *grpMeta) override ;
// Overloaded from GxsTokenQueue for Request callbacks. // 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. // 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;
@ -561,7 +562,7 @@ private:
void cleanUnusedKeys() ; void cleanUnusedKeys() ;
void slowIndicateConfigChanged() ; 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); rstime_t locked_getLastUsageTS(const RsGxsId& gxs_id);
std::string genRandomId(int len = 20); std::string genRandomId(int len = 20);

View File

@ -849,12 +849,14 @@ bool p3PostBase::background_cleanup()
// Overloaded from GxsTokenQueue for Request callbacks. // 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 #ifdef POSTBASE_DEBUG
std::cerr << "p3PostBase::handleResponse(" << token << "," << req_type << ")"; std::cerr << "p3PostBase::handleResponse(" << token << "," << req_type << "," << status << ")" << std::endl;
std::cerr << std::endl;
#endif #endif
if (status != RsTokenService::COMPLETE)
return; //For now, only manage Complete request
// stuff. // stuff.
switch(req_type) switch(req_type)

View File

@ -70,17 +70,18 @@ public:
p3PostBase(RsGeneralDataService *gds, RsNetworkExchangeService *nes, RsGixs* gixs, p3PostBase(RsGeneralDataService *gds, RsNetworkExchangeService *nes, RsGixs* gixs,
RsSerialType* serviceSerialiser, uint16_t serviceType); RsSerialType* serviceSerialiser, uint16_t serviceType);
virtual void service_tick() override; virtual void service_tick() override;
protected: protected:
virtual void notifyChanges(std::vector<RsGxsNotify*>& changes) override; virtual void notifyChanges(std::vector<RsGxsNotify*>& changes) override;
// Overloaded from GxsTokenQueue for Request callbacks. // 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. // 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 // overloads p3Config
virtual RsSerialiser* setupSerialiser() override; // @see p3Config::setupSerialiser() virtual RsSerialiser* setupSerialiser() override; // @see p3Config::setupSerialiser()