mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-13 03:22:34 -04:00
added machinery to allow to set/get sync and store periods for GXS groups
This commit is contained in:
parent
d2ef2248c6
commit
7afb91d1db
13 changed files with 188 additions and 34 deletions
|
@ -1608,6 +1608,54 @@ void RsGenExchange::publishMsg(uint32_t& token, RsGxsMsgItem *msgItem)
|
|||
|
||||
}
|
||||
|
||||
uint32_t RsGenExchange::getDefaultSyncPeriod()
|
||||
{
|
||||
RS_STACK_MUTEX(mGenMtx) ;
|
||||
|
||||
if(mNetService != NULL)
|
||||
return mNetService->getDefaultSyncAge();
|
||||
else
|
||||
{
|
||||
std::cerr << "(EE) No network service available. Cannot get default sync period. " << std::endl;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t RsGenExchange::getSyncPeriod(const RsGxsGroupId& grpId)
|
||||
{
|
||||
RS_STACK_MUTEX(mGenMtx) ;
|
||||
|
||||
if(mNetService != NULL)
|
||||
return mNetService->getSyncAge(grpId);
|
||||
else
|
||||
return mNetService->getDefaultSyncAge();
|
||||
}
|
||||
|
||||
void RsGenExchange::setSyncPeriod(const RsGxsGroupId& grpId,uint32_t age_in_secs)
|
||||
{
|
||||
if(mNetService != NULL)
|
||||
return mNetService->setKeepAge(grpId,age_in_secs) ;
|
||||
else
|
||||
std::cerr << "(EE) No network service available. Cannot set storage period. " << std::endl;
|
||||
}
|
||||
|
||||
uint32_t RsGenExchange::getStoragePeriod(const RsGxsGroupId& grpId)
|
||||
{
|
||||
RS_STACK_MUTEX(mGenMtx) ;
|
||||
|
||||
if(mNetService != NULL)
|
||||
return mNetService->getKeepAge(grpId,MESSAGE_STORE_PERIOD) ;
|
||||
else
|
||||
return MESSAGE_STORE_PERIOD;
|
||||
}
|
||||
void RsGenExchange::setStoragePeriod(const RsGxsGroupId& grpId,uint32_t age_in_secs)
|
||||
{
|
||||
if(mNetService != NULL)
|
||||
return mNetService->setKeepAge(grpId,age_in_secs) ;
|
||||
else
|
||||
std::cerr << "(EE) No network service available. Cannot set storage period. " << std::endl;
|
||||
}
|
||||
|
||||
void RsGenExchange::setGroupSubscribeFlags(uint32_t& token, const RsGxsGroupId& grpId, const uint32_t& flag, const uint32_t& mask)
|
||||
{
|
||||
/* TODO APPLY MASK TO FLAGS */
|
||||
|
|
|
@ -611,11 +611,6 @@ public:
|
|||
*/
|
||||
void updateGroupLastMsgTimeStamp(uint32_t& token, const RsGxsGroupId& grpId);
|
||||
|
||||
/*!
|
||||
* @return storage time of messages in months
|
||||
*/
|
||||
int getStoragePeriod(){ return MESSAGE_STORE_PERIOD/(60*60*24*31);}
|
||||
|
||||
/*!
|
||||
* sets the msg status flag
|
||||
* @param token this is set to token value associated to this request
|
||||
|
@ -647,6 +642,19 @@ public:
|
|||
*/
|
||||
bool getGroupServerUpdateTS(const RsGxsGroupId& gid,time_t& grp_server_update_TS,time_t& msg_server_update_TS) ;
|
||||
|
||||
/*!
|
||||
* \brief getDefaultStoragePeriod. All times in seconds.
|
||||
* \return
|
||||
*/
|
||||
virtual uint32_t getDefaultStoragePeriod() { return MESSAGE_STORE_PERIOD; }
|
||||
|
||||
virtual uint32_t getStoragePeriod(const RsGxsGroupId& grpId) ;
|
||||
virtual void setStoragePeriod(const RsGxsGroupId& grpId,uint32_t age_in_secs) ;
|
||||
|
||||
virtual uint32_t getDefaultSyncPeriod();
|
||||
virtual uint32_t getSyncPeriod(const RsGxsGroupId& grpId) ;
|
||||
virtual void setSyncPeriod(const RsGxsGroupId& grpId,uint32_t age_in_secs) ;
|
||||
|
||||
protected:
|
||||
|
||||
/** Notifications **/
|
||||
|
@ -860,7 +868,6 @@ private:
|
|||
std::vector<GxsPendingItem<RsNxsMsg*, RsGxsGrpMsgIdPair> > mMsgPendingValidate;
|
||||
typedef std::vector<GxsPendingItem<RsNxsMsg*, RsGxsGrpMsgIdPair> > NxsMsgPendingVect;
|
||||
|
||||
|
||||
const uint32_t MESSAGE_STORE_PERIOD;
|
||||
|
||||
bool mCleaning;
|
||||
|
|
|
@ -4431,6 +4431,29 @@ void RsGxsNetService::setKeepAge(const RsGxsGroupId &grpId, uint32_t age_in_secs
|
|||
}
|
||||
}
|
||||
|
||||
uint32_t RsGxsNetService::getSyncAge(const RsGxsGroupId& grpId)
|
||||
{
|
||||
RS_STACK_MUTEX(mNxsMutex) ;
|
||||
|
||||
GrpConfigMap::const_iterator it = mServerGrpConfigMap.find(grpId) ;
|
||||
|
||||
if(it == mServerGrpConfigMap.end())
|
||||
return mSYNC_PERIOD ;
|
||||
else
|
||||
return it->second.msg_keep_delay ;
|
||||
}
|
||||
uint32_t RsGxsNetService::getKeepAge(const RsGxsGroupId& grpId,uint32_t default_value)
|
||||
{
|
||||
RS_STACK_MUTEX(mNxsMutex) ;
|
||||
|
||||
GrpConfigMap::const_iterator it = mServerGrpConfigMap.find(grpId) ;
|
||||
|
||||
if(it == mServerGrpConfigMap.end())
|
||||
return default_value ;
|
||||
else
|
||||
return it->second.msg_req_delay ;
|
||||
}
|
||||
|
||||
int RsGxsNetService::requestGrp(const std::list<RsGxsGroupId>& grpId, const RsPeerId& peerId)
|
||||
{
|
||||
RS_STACK_MUTEX(mNxsMutex) ;
|
||||
|
|
|
@ -109,6 +109,11 @@ public:
|
|||
virtual void setSyncAge(const RsGxsGroupId& grpId,uint32_t age_in_secs);
|
||||
virtual void setKeepAge(const RsGxsGroupId& grpId,uint32_t age_in_secs);
|
||||
|
||||
virtual uint32_t getSyncAge(const RsGxsGroupId& id);
|
||||
virtual uint32_t getKeepAge(const RsGxsGroupId& id,uint32_t default_value);
|
||||
|
||||
virtual uint32_t getDefaultSyncAge() { return mSYNC_PERIOD ; }
|
||||
|
||||
/*!
|
||||
* pauses synchronisation of subscribed groups and request for group id
|
||||
* from peers
|
||||
|
|
|
@ -67,8 +67,13 @@ public:
|
|||
* Use this to set how far back synchronisation of messages should take place
|
||||
* @param age in seconds the max age a sync/store item can to be allowed in a synchronisation
|
||||
*/
|
||||
virtual void setSyncAge(const RsGxsGroupId& id,uint32_t age_in_secs) = 0;
|
||||
virtual void setKeepAge(const RsGxsGroupId& id,uint32_t age_in_secs) = 0;
|
||||
virtual void setSyncAge(const RsGxsGroupId& id,uint32_t age_in_secs) =0;
|
||||
virtual void setKeepAge(const RsGxsGroupId& id,uint32_t age_in_secs) =0;
|
||||
|
||||
virtual uint32_t getSyncAge(const RsGxsGroupId& id) =0;
|
||||
virtual uint32_t getKeepAge(const RsGxsGroupId& id,uint32_t default_value) =0;
|
||||
|
||||
virtual uint32_t getDefaultSyncAge() =0;
|
||||
|
||||
/*!
|
||||
* Initiates a search through the network
|
||||
|
|
|
@ -172,9 +172,15 @@ public:
|
|||
virtual void setGroupReputationCutOff(uint32_t& token, const RsGxsGroupId& grpId, int CutOff) = 0;
|
||||
|
||||
/*!
|
||||
* @return storage time of messages in months
|
||||
* @return storage/sync time of messages in secs
|
||||
*/
|
||||
virtual int getStoragePeriod() = 0;
|
||||
virtual uint32_t getDefaultStoragePeriod() = 0;
|
||||
virtual uint32_t getStoragePeriod(const RsGxsGroupId& grpId) = 0;
|
||||
virtual void setStoragePeriod(const RsGxsGroupId& grpId,uint32_t age_in_secs) = 0;
|
||||
|
||||
virtual uint32_t getDefaultSyncPeriod() = 0;
|
||||
virtual uint32_t getSyncPeriod(const RsGxsGroupId& grpId) = 0;
|
||||
virtual void setSyncPeriod(const RsGxsGroupId& grpId,uint32_t age_in_secs) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -209,11 +209,31 @@ public:
|
|||
}
|
||||
|
||||
/*!
|
||||
* @return storage time of messages in months
|
||||
* @return storage/sync time of messages in secs
|
||||
*/
|
||||
int getStoragePeriod()
|
||||
uint32_t getDefaultStoragePeriod()
|
||||
{
|
||||
return mGxs->getStoragePeriod();
|
||||
return mGxs->getDefaultStoragePeriod();
|
||||
}
|
||||
uint32_t getStoragePeriod(const RsGxsGroupId& grpId)
|
||||
{
|
||||
return mGxs->getStoragePeriod(grpId);
|
||||
}
|
||||
void setStoragePeriod(const RsGxsGroupId& grpId,uint32_t age_in_secs)
|
||||
{
|
||||
mGxs->setStoragePeriod(grpId,age_in_secs);
|
||||
}
|
||||
uint32_t getDefaultSyncPeriod()
|
||||
{
|
||||
return mGxs->getDefaultSyncPeriod();
|
||||
}
|
||||
uint32_t getSyncPeriod(const RsGxsGroupId& grpId)
|
||||
{
|
||||
return mGxs->getSyncPeriod(grpId);
|
||||
}
|
||||
void setSyncPeriod(const RsGxsGroupId& grpId,uint32_t age_in_secs)
|
||||
{
|
||||
mGxs->setSyncPeriod(grpId,age_in_secs);
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue