From d2ef2248c6c37cb1be19a5254cb75c1f258f0984 Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 4 Dec 2016 23:26:48 +0100 Subject: [PATCH] added entry in rsgxsnetservice to change sync params --- libretroshare/src/gxs/rsgxsnetservice.cc | 22 ++++++++++++++++++- libretroshare/src/gxs/rsgxsnetservice.h | 8 +++---- libretroshare/src/gxs/rsnxs.h | 5 +++-- retroshare-gui/src/gui/gxs/GxsGroupDialog.cpp | 4 +++- .../gxs/gen_exchange/rsdummyservices.h | 3 ++- 5 files changed, 33 insertions(+), 9 deletions(-) diff --git a/libretroshare/src/gxs/rsgxsnetservice.cc b/libretroshare/src/gxs/rsgxsnetservice.cc index 19aa1bb4c..66249dac5 100644 --- a/libretroshare/src/gxs/rsgxsnetservice.cc +++ b/libretroshare/src/gxs/rsgxsnetservice.cc @@ -4406,9 +4406,29 @@ void RsGxsNetService::pauseSynchronisation(bool /* enabled */) } -void RsGxsNetService::setSyncAge(uint32_t /* age */) +void RsGxsNetService::setSyncAge(const RsGxsGroupId &grpId, uint32_t age_in_secs) { + RS_STACK_MUTEX(mNxsMutex) ; + RsGxsGrpConfig& conf(mServerGrpConfigMap[grpId]) ; + + if(conf.msg_req_delay != age_in_secs) + { + conf.msg_req_delay = age_in_secs; + IndicateConfigChanged(); + } +} +void RsGxsNetService::setKeepAge(const RsGxsGroupId &grpId, uint32_t age_in_secs) +{ + RS_STACK_MUTEX(mNxsMutex) ; + + RsGxsGrpConfig& conf(mServerGrpConfigMap[grpId]) ; + + if(conf.msg_keep_delay != age_in_secs) + { + conf.msg_keep_delay = age_in_secs; + IndicateConfigChanged(); + } } int RsGxsNetService::requestGrp(const std::list& grpId, const RsPeerId& peerId) diff --git a/libretroshare/src/gxs/rsgxsnetservice.h b/libretroshare/src/gxs/rsgxsnetservice.h index 227dc73eb..28f001de8 100644 --- a/libretroshare/src/gxs/rsgxsnetservice.h +++ b/libretroshare/src/gxs/rsgxsnetservice.h @@ -103,11 +103,11 @@ public: /*! - * Use this to set how far back synchronisation of messages should take place - * @param age the max age a sync item can to be allowed in a synchronisation + * Use this to set how far back synchronisation and storage of messages should take place + * @param age the max age a sync/storage item can to be allowed in a synchronisation */ - // NOT IMPLEMENTED - virtual void setSyncAge(uint32_t age); + virtual void setSyncAge(const RsGxsGroupId& grpId,uint32_t age_in_secs); + virtual void setKeepAge(const RsGxsGroupId& grpId,uint32_t age_in_secs); /*! * pauses synchronisation of subscribed groups and request for group id diff --git a/libretroshare/src/gxs/rsnxs.h b/libretroshare/src/gxs/rsnxs.h index 13eb6fedb..6c4fbba0c 100644 --- a/libretroshare/src/gxs/rsnxs.h +++ b/libretroshare/src/gxs/rsnxs.h @@ -65,9 +65,10 @@ public: /*! * Use this to set how far back synchronisation of messages should take place - * @param age the max age a sync item can to be allowed in a synchronisation + * @param age in seconds the max age a sync/store item can to be allowed in a synchronisation */ - virtual void setSyncAge(uint32_t age) = 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; /*! * Initiates a search through the network diff --git a/retroshare-gui/src/gui/gxs/GxsGroupDialog.cpp b/retroshare-gui/src/gui/gxs/GxsGroupDialog.cpp index 7e7cbc88d..376d04bd6 100644 --- a/retroshare-gui/src/gui/gxs/GxsGroupDialog.cpp +++ b/retroshare-gui/src/gui/gxs/GxsGroupDialog.cpp @@ -347,7 +347,6 @@ void GxsGroupDialog::setupVisibility() ui.commentGroupBox->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_COMMENTS); ui.commentsLabel->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_COMMENTS); ui.commentsValueLabel->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_COMMENTS); - //ui.commentslabel->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_COMMENTS); ui.extraFrame->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_EXTRA); } @@ -577,6 +576,9 @@ bool GxsGroupDialog::prepareGroupMetaData(RsGroupMetaData &meta) meta.mGroupFlags = flags; meta.mSignFlags = getGroupSignFlags(); + meta.mGrpDistribution_MaxStorageAge = ui.keepLimit_SB->value() * 86400 ; + meta.mGrpDistribution_MaxRequestAge = ui.syncLimit_SB->value() * 86400 ; + if (!setCircleParameters(meta)){ std::cerr << "GxsGroupDialog::prepareGroupMetaData()"; std::cerr << " Invalid Circles"; diff --git a/tests/unittests/libretroshare/gxs/gen_exchange/rsdummyservices.h b/tests/unittests/libretroshare/gxs/gen_exchange/rsdummyservices.h index a422cd03f..3bb951410 100644 --- a/tests/unittests/libretroshare/gxs/gen_exchange/rsdummyservices.h +++ b/tests/unittests/libretroshare/gxs/gen_exchange/rsdummyservices.h @@ -15,7 +15,8 @@ public: RsDummyNetService(){ return;} virtual ~RsDummyNetService() { } - void setSyncAge(uint32_t age){} + void setSyncAge(const RsGxsGroupId& id,uint32_t age_in_secs){} + void setKeepAge(const RsGxsGroupId& id,uint32_t age_in_secs){} void requestGroupsOfPeer(const std::string& peerId){}