diff --git a/libretroshare/src/gxs/rsgxs.h b/libretroshare/src/gxs/rsgxs.h index ebbb9db4c..100a93a23 100644 --- a/libretroshare/src/gxs/rsgxs.h +++ b/libretroshare/src/gxs/rsgxs.h @@ -37,8 +37,8 @@ typedef std::map > 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 diff --git a/libretroshare/src/gxs/rsgxsnetservice.cc b/libretroshare/src/gxs/rsgxsnetservice.cc index 7505c1720..95d099d11 100644 --- a/libretroshare/src/gxs/rsgxsnetservice.cc +++ b/libretroshare/src/gxs/rsgxsnetservice.cc @@ -1401,11 +1401,27 @@ bool RsGxsNetService::loadList(std::list &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 template @@ -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 ; } diff --git a/libretroshare/src/gxs/rsgxsnetservice.h b/libretroshare/src/gxs/rsgxsnetservice.h index a29644698..9731aa010 100644 --- a/libretroshare/src/gxs/rsgxsnetservice.h +++ b/libretroshare/src/gxs/rsgxsnetservice.h @@ -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 ***/ diff --git a/libretroshare/src/serialiser/rsgxsupdateitems.h b/libretroshare/src/serialiser/rsgxsupdateitems.h index eaa794aae..4e41700ab 100644 --- a/libretroshare/src/serialiser/rsgxsupdateitems.h +++ b/libretroshare/src/serialiser/rsgxsupdateitems.h @@ -56,7 +56,7 @@ public: { msg_keep_delay = RS_GXS_DEFAULT_MSG_STORE_PERIOD ; msg_send_delay = RS_GXS_DEFAULT_MSG_SEND_PERIOD ; - msg_req_delay = RS_GXS_DEFAULT_MSG_REQ_PERIOD ; + msg_req_delay = RS_GXS_DEFAULT_MSG_REQ_PERIOD ; max_visible_count = 0 ; update_TS = 0 ; diff --git a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp index 6029fb2c1..909a04fae 100644 --- a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp +++ b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp @@ -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)