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();)
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
@ -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
|
||||||
|
|
||||||
@ -1123,7 +1124,6 @@ bool RsGxsDataAccess::getMsgMetaDataList( const GxsMsgReq& msgIds, const RsTokRe
|
|||||||
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())
|
||||||
|
@ -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)
|
||||||
|
@ -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,7 +327,7 @@ 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 ;
|
||||||
|
|
||||||
|
@ -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)
|
||||||
|
@ -178,15 +178,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
|
||||||
@ -277,7 +277,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(
|
||||||
@ -295,7 +295,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)
|
||||||
@ -316,7 +316,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:
|
||||||
|
@ -585,7 +585,7 @@ 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)
|
||||||
@ -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)
|
||||||
|
@ -318,7 +318,8 @@ protected:
|
|||||||
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;
|
||||||
|
@ -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)
|
||||||
|
@ -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:
|
||||||
|
|
||||||
|
@ -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;
|
|
||||||
mBgSchedule_Active = false;
|
|
||||||
mLastKeyCleaningTime = time(NULL) - int(MAX_DELAY_BEFORE_CLEANING * 0.9) ;
|
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: "
|
||||||
|
@ -408,7 +408,8 @@ protected:
|
|||||||
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);
|
||||||
|
@ -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)
|
||||||
|
@ -77,7 +77,8 @@ 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;
|
||||||
|
Loading…
Reference in New Issue
Block a user