mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-13 08:29:32 -05:00
added a function to check keep/req times for consistency
This commit is contained in:
parent
7afb91d1db
commit
661038d9b2
@ -37,8 +37,8 @@ typedef std::map<RsGxsGrpMsgIdPair, std::vector<RsGxsMsgMetaData*> > MsgRelatedM
|
||||
|
||||
// Default values that are used throughout GXS code
|
||||
|
||||
static const uint32_t RS_GXS_DEFAULT_MSG_STORE_PERIOD = 86400 * 31 * 6 ; // six months. Default time for which messages are keps in the database.
|
||||
static const uint32_t RS_GXS_DEFAULT_MSG_SEND_PERIOD = 86400 * 31 * 1 ; // one months. Default delay after which we don't send messages
|
||||
static const uint32_t RS_GXS_DEFAULT_MSG_REQ_PERIOD = 86400 * 31 * 1 ; // one months. Default Delay after which we don't request messages
|
||||
static const uint32_t RS_GXS_DEFAULT_MSG_STORE_PERIOD = 86400 * 30 * 6 ; // six months. Default time for which messages are keps in the database.
|
||||
static const uint32_t RS_GXS_DEFAULT_MSG_SEND_PERIOD = 86400 * 30 * 1 ; // one month. Default delay after which we don't send messages
|
||||
static const uint32_t RS_GXS_DEFAULT_MSG_REQ_PERIOD = 86400 * 30 * 1 ; // one month. Default Delay after which we don't request messages
|
||||
|
||||
#endif // RSGXS_H
|
||||
|
@ -1401,11 +1401,27 @@ bool RsGxsNetService::loadList(std::list<RsItem *> &load)
|
||||
// Actual suppliers will come back automatically.
|
||||
|
||||
it->second.suppliers.ids.clear() ;
|
||||
|
||||
// also make sure that values stored for keep and req delays correspond to the canonical values
|
||||
|
||||
locked_checkDelay(it->second.msg_req_delay);
|
||||
locked_checkDelay(it->second.msg_keep_delay);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void RsGxsNetService::locked_checkDelay(uint32_t& time_in_secs)
|
||||
{
|
||||
if(time_in_secs < 1 * 86400) { time_in_secs = 0 ; return ; }
|
||||
if(time_in_secs <= 10 * 86400) { time_in_secs = 5 * 86400; return ; }
|
||||
if(time_in_secs <= 20 * 86400) { time_in_secs = 15 * 86400; return ; }
|
||||
if(time_in_secs <= 60 * 86400) { time_in_secs = 30 * 86400; return ; }
|
||||
if(time_in_secs <= 120 * 86400) { time_in_secs = 90 * 86400; return ; }
|
||||
if(time_in_secs <= 250 * 86400) { time_in_secs = 180 * 86400; return ; }
|
||||
time_in_secs = 365 * 86400;
|
||||
}
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
template <typename UpdateMap,class ItemClass>
|
||||
@ -4410,6 +4426,8 @@ void RsGxsNetService::setSyncAge(const RsGxsGroupId &grpId, uint32_t age_in_secs
|
||||
{
|
||||
RS_STACK_MUTEX(mNxsMutex) ;
|
||||
|
||||
locked_checkDelay(age_in_secs) ;
|
||||
|
||||
RsGxsGrpConfig& conf(mServerGrpConfigMap[grpId]) ;
|
||||
|
||||
if(conf.msg_req_delay != age_in_secs)
|
||||
@ -4422,6 +4440,8 @@ void RsGxsNetService::setKeepAge(const RsGxsGroupId &grpId, uint32_t age_in_secs
|
||||
{
|
||||
RS_STACK_MUTEX(mNxsMutex) ;
|
||||
|
||||
locked_checkDelay(age_in_secs) ;
|
||||
|
||||
RsGxsGrpConfig& conf(mServerGrpConfigMap[grpId]) ;
|
||||
|
||||
if(conf.msg_keep_delay != age_in_secs)
|
||||
@ -4438,7 +4458,7 @@ uint32_t RsGxsNetService::getSyncAge(const RsGxsGroupId& grpId)
|
||||
GrpConfigMap::const_iterator it = mServerGrpConfigMap.find(grpId) ;
|
||||
|
||||
if(it == mServerGrpConfigMap.end())
|
||||
return mSYNC_PERIOD ;
|
||||
return RS_GXS_DEFAULT_MSG_REQ_PERIOD ;
|
||||
else
|
||||
return it->second.msg_keep_delay ;
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ public:
|
||||
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 ; }
|
||||
virtual uint32_t getDefaultSyncAge() { return RS_GXS_DEFAULT_MSG_REQ_PERIOD ; }
|
||||
|
||||
/*!
|
||||
* pauses synchronisation of subscribed groups and request for group id
|
||||
@ -487,6 +487,7 @@ private:
|
||||
|
||||
private:
|
||||
|
||||
static void locked_checkDelay(uint32_t& time_in_secs);
|
||||
|
||||
/*** transactions ***/
|
||||
|
||||
|
@ -285,23 +285,29 @@ void GxsGroupFrameDialog::groupTreeCustomPopupMenu(QPoint point)
|
||||
action = contextMnu.addAction(QIcon(IMAGE_EDIT), tr("Edit Details"), this, SLOT(editGroupDetails()));
|
||||
action->setEnabled (!mGroupId.isNull() && isAdmin);
|
||||
|
||||
QMenu *ctxMenu2 = contextMnu.addMenu(tr("Store posts for at most...")) ;
|
||||
ctxMenu2->addAction(tr("5 days" ),this,SLOT(setStorePostDelay()))->setData(QVariant( 5 * 86400)) ;
|
||||
ctxMenu2->addAction(tr("2 weeks" ),this,SLOT(setStorePostDelay()))->setData(QVariant( 15 * 86400)) ;
|
||||
ctxMenu2->addAction(tr("1 month" ),this,SLOT(setStorePostDelay()))->setData(QVariant( 30 * 86400)) ;
|
||||
ctxMenu2->addAction(tr("3 months"),this,SLOT(setStorePostDelay()))->setData(QVariant( 90 * 86400)) ;
|
||||
ctxMenu2->addAction(tr("6 months"),this,SLOT(setStorePostDelay()))->setData(QVariant(180 * 86400)) ;
|
||||
ctxMenu2->addAction(tr("1 year" ),this,SLOT(setStorePostDelay()))->setData(QVariant( 0 * 86400)) ;
|
||||
ctxMenu2->addAction(tr("Indefinitely")) ;
|
||||
uint32_t current_store_time = mInterface->getStoragePeriod(mGroupId)/86400 ;
|
||||
uint32_t current_sync_time = mInterface->getSyncPeriod(mGroupId)/86400 ;
|
||||
|
||||
ctxMenu2 = contextMnu.addMenu(tr("Synchronise posts of last...")) ;
|
||||
ctxMenu2->addAction(tr("5 days" ),this,SLOT(setSyncPostDelay()))->setData(QVariant( 5 * 86400)) ;
|
||||
ctxMenu2->addAction(tr("2 weeks" ),this,SLOT(setSyncPostDelay()))->setData(QVariant( 15 * 86400)) ;
|
||||
ctxMenu2->addAction(tr("1 month" ),this,SLOT(setSyncPostDelay()))->setData(QVariant( 30 * 86400)) ;
|
||||
ctxMenu2->addAction(tr("3 months"),this,SLOT(setSyncPostDelay()))->setData(QVariant( 90 * 86400)) ;
|
||||
ctxMenu2->addAction(tr("6 months"),this,SLOT(setSyncPostDelay()))->setData(QVariant(180 * 86400)) ;
|
||||
ctxMenu2->addAction(tr("1 year" ),this,SLOT(setSyncPostDelay()))->setData(QVariant( 0 * 86400)) ;
|
||||
ctxMenu2->addAction(tr("Indefinitely")) ;
|
||||
std::cerr << "Got sync=" << current_sync_time << ". store=" << current_store_time << std::endl;
|
||||
QAction *actnn = NULL;
|
||||
|
||||
QMenu *ctxMenu2 = contextMnu.addMenu(tr("Synchronise posts of last...")) ;
|
||||
actnn = ctxMenu2->addAction(tr(" 5 days" ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant( 5)) ; if(current_sync_time == 5) actnn->setIcon(QIcon(":/images/start.png"));
|
||||
actnn = ctxMenu2->addAction(tr(" 2 weeks" ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant( 15)) ; if(current_sync_time == 15) actnn->setIcon(QIcon(":/images/start.png"));
|
||||
actnn = ctxMenu2->addAction(tr(" 1 month" ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant( 30)) ; if(current_sync_time == 30) actnn->setIcon(QIcon(":/images/start.png"));
|
||||
actnn = ctxMenu2->addAction(tr(" 3 months" ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant( 90)) ; if(current_sync_time == 90) actnn->setIcon(QIcon(":/images/start.png"));
|
||||
actnn = ctxMenu2->addAction(tr(" 6 months" ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant(180)) ; if(current_sync_time ==180) actnn->setIcon(QIcon(":/images/start.png"));
|
||||
actnn = ctxMenu2->addAction(tr(" 1 year " ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant(365)) ; if(current_sync_time ==365) actnn->setIcon(QIcon(":/images/start.png"));
|
||||
actnn = ctxMenu2->addAction(tr(" Indefinitly"),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant( 0)) ; if(current_sync_time == 0) actnn->setIcon(QIcon(":/images/start.png"));
|
||||
|
||||
ctxMenu2 = contextMnu.addMenu(tr("Store posts for at most...")) ;
|
||||
actnn = ctxMenu2->addAction(tr(" 5 days" ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant( 5)) ; if(current_store_time == 5) actnn->setIcon(QIcon(":/images/start.png"));
|
||||
actnn = ctxMenu2->addAction(tr(" 2 weeks" ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant( 15)) ; if(current_store_time == 15) actnn->setIcon(QIcon(":/images/start.png"));
|
||||
actnn = ctxMenu2->addAction(tr(" 1 month" ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant( 30)) ; if(current_store_time == 30) actnn->setIcon(QIcon(":/images/start.png"));
|
||||
actnn = ctxMenu2->addAction(tr(" 3 months" ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant( 90)) ; if(current_store_time == 90) actnn->setIcon(QIcon(":/images/start.png"));
|
||||
actnn = ctxMenu2->addAction(tr(" 6 months" ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant(180)) ; if(current_store_time ==180) actnn->setIcon(QIcon(":/images/start.png"));
|
||||
actnn = ctxMenu2->addAction(tr(" 1 year " ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant(365)) ; if(current_store_time ==365) actnn->setIcon(QIcon(":/images/start.png"));
|
||||
actnn = ctxMenu2->addAction(tr(" Indefinitly"),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant( 0)) ; if(current_store_time == 0) actnn->setIcon(QIcon(":/images/start.png"));
|
||||
|
||||
if (shareKeyType()) {
|
||||
action = contextMnu.addAction(QIcon(IMAGE_SHARE), tr("Share publish permissions"), this, SLOT(sharePublishKey()));
|
||||
@ -346,7 +352,7 @@ void GxsGroupFrameDialog::setStorePostsDelay()
|
||||
|
||||
std::cerr << "Data is " << duration << std::endl;
|
||||
|
||||
mInterface->setStoragePeriod(mGroupId,duration) ;
|
||||
mInterface->setStoragePeriod(mGroupId,duration * 86400) ;
|
||||
}
|
||||
|
||||
|
||||
@ -364,7 +370,7 @@ void GxsGroupFrameDialog::setSyncPostsDelay()
|
||||
|
||||
std::cerr << "Data is " << duration << std::endl;
|
||||
|
||||
mInterface->setSyncPeriod(mGroupId,duration) ;
|
||||
mInterface->setSyncPeriod(mGroupId,duration * 86400) ;
|
||||
}
|
||||
|
||||
void GxsGroupFrameDialog::restoreGroupKeys(void)
|
||||
|
Loading…
Reference in New Issue
Block a user