mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Merge pull request #2137 from PhenomRetroShare/Add_HandleTokenStatus
Add ability to manage canceled token in Gxs.
This commit is contained in:
commit
3decd2b768
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;i<metaV.size();++i)
|
||||
if(metaV[i] != nullptr)
|
||||
{
|
||||
const auto& msgMeta = metaV[i];
|
||||
bool add = false;
|
||||
const auto& msgMeta = metaV[i];
|
||||
|
||||
/* if we are grabbing thread Head... then parentId == empty. */
|
||||
if (onlyThreadHeadMsgs && !msgMeta->mParentId.isNull())
|
||||
|
@ -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)
|
||||
|
@ -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<RsGxsNotify *> &changes)
|
||||
void notifyChanges(std::vector<RsGxsNotify *> &changes);
|
||||
void notifyChanges(std::vector<RsGxsNotify *> &changes) override;
|
||||
|
||||
/// @see p3Config::setupSerialiser()
|
||||
virtual RsSerialiser* setupSerialiser();
|
||||
virtual RsSerialiser* setupSerialiser() override;
|
||||
|
||||
/// @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()
|
||||
void saveDone();
|
||||
void saveDone() override;
|
||||
|
||||
/// @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.
|
||||
bool requestGroupsData(const std::list<RsGxsGroupId>* 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.
|
||||
|
||||
|
@ -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)
|
||||
|
@ -178,15 +178,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
|
||||
@ -277,7 +277,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(
|
||||
@ -295,7 +295,7 @@ virtual bool ExtraFileRemove(const RsFileHash &hash);
|
||||
) override;
|
||||
|
||||
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
|
||||
RS_DEPRECATED_FOR(createChannelV2)
|
||||
@ -316,7 +316,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:
|
||||
|
@ -434,13 +434,13 @@ bool p3GxsCircles::revokeIdsFromCircle( const std::set<RsGxsId>& 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<RsGxsId> new_invited_members;
|
||||
for(auto& gxs_id: circleGrp.mInvitedMembers)
|
||||
if(identities.find(gxs_id) == identities.end())
|
||||
new_invited_members.insert(gxs_id);
|
||||
std::set<RsGxsId> 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<RsGxsNotify *> &changes)
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
p3Notify *notify = RsServer::notify();
|
||||
std::set<RsGxsCircleId> circles_to_reload;
|
||||
//p3Notify *notify = RsServer::notify();
|
||||
std::set<RsGxsCircleId> 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)
|
||||
|
@ -250,10 +250,10 @@ public:
|
||||
bool revokeIdsFromCircle( const std::set<RsGxsId>& 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<RsGxsCircleId> &circleIds) override;
|
||||
virtual bool getCircleDetails(const RsGxsCircleId &id, RsGxsCircleDetails &details) override;
|
||||
virtual bool getCircleExternalIdList(std::set<RsGxsCircleId> &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<RsPgpId> &friendlist) 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 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<RsPgpId> &friendlist) 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 getGroupData(const uint32_t &token, std::vector<RsGxsCircleGroup> &groups) override;
|
||||
virtual bool getMsgData(const uint32_t &token, std::vector<RsGxsCircleMsg> &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<RsGxsCircleGroup> &groups) override;
|
||||
virtual bool getMsgData(const uint32_t &token, std::vector<RsGxsCircleMsg> &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<RsItem *>&saveList) override;
|
||||
virtual bool loadList(std::list<RsItem *>& loadList) override;
|
||||
virtual RsSerialiser *setupSerialiser() override;
|
||||
// overloads p3Config
|
||||
virtual bool saveList(bool &cleanup, std::list<RsItem *>&saveList) override;
|
||||
virtual bool loadList(std::list<RsItem *>& 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<RsGxsNotify*>& changes) override;
|
||||
virtual void notifyChanges(std::vector<RsGxsNotify*>& 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:
|
||||
|
||||
|
@ -199,7 +199,7 @@ bool p3GxsCommentService::getGxsCommentData(const uint32_t &token, std::vector<R
|
||||
|
||||
for(; mit != msgData.end(); ++mit)
|
||||
{
|
||||
RsGxsGroupId grpId = mit->first;
|
||||
//RsGxsGroupId grpId = mit->first;
|
||||
std::vector<RsGxsMsgItem*>& msgItems = mit->second;
|
||||
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.
|
||||
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)
|
||||
|
@ -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:
|
||||
|
||||
|
@ -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<RsGxsIface&>(*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<RsGxsIface&>(*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: "
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
|
@ -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<RsGxsNotify*>& changes) override;
|
||||
virtual void notifyChanges(std::vector<RsGxsNotify*>& 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()
|
||||
|
Loading…
Reference in New Issue
Block a user