From 79e676edbe646ea3c8f3257ffbbd335437310208 Mon Sep 17 00:00:00 2001 From: csoler Date: Mon, 18 Jun 2018 22:27:05 +0200 Subject: [PATCH 1/3] fixed re-load of GXS groups (forums/channels) when the read flag is changed --- libretroshare/src/gxs/rsgenexchange.cc | 2 +- libretroshare/src/services/p3gxschannels.cc | 3 +-- .../src/gui/gxs/RsGxsUpdateBroadcastBase.cpp | 8 +++++++- retroshare-gui/src/util/RsGxsUpdateBroadcast.cpp | 13 +++++++------ 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/libretroshare/src/gxs/rsgenexchange.cc b/libretroshare/src/gxs/rsgenexchange.cc index 15d0aa9e9..e219821f2 100644 --- a/libretroshare/src/gxs/rsgenexchange.cc +++ b/libretroshare/src/gxs/rsgenexchange.cc @@ -2010,7 +2010,7 @@ void RsGenExchange::processMsgMetaChanges() if (!msgIds.empty()) { RS_STACK_MUTEX(mGenMtx); - RsGxsMsgChange* c = new RsGxsMsgChange(RsGxsNotify::TYPE_PROCESSED, true); + RsGxsMsgChange* c = new RsGxsMsgChange(RsGxsNotify::TYPE_PROCESSED, false); c->msgChangeMap = msgIds; mNotifications.push_back(c); } diff --git a/libretroshare/src/services/p3gxschannels.cc b/libretroshare/src/services/p3gxschannels.cc index e70769c7a..beb828fdf 100644 --- a/libretroshare/src/services/p3gxschannels.cc +++ b/libretroshare/src/services/p3gxschannels.cc @@ -218,8 +218,7 @@ RsGenExchange::ServiceCreate_Return p3GxsChannels::service_CreateGroup(RsGxsGrpI void p3GxsChannels::notifyChanges(std::vector &changes) { #ifdef GXSCHANNELS_DEBUG - std::cerr << "p3GxsChannels::notifyChanges()"; - std::cerr << std::endl; + std::cerr << "p3GxsChannels::notifyChanges() : " << changes.size() << "changes to notify" << std::endl; #endif p3Notify *notify = NULL; diff --git a/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastBase.cpp b/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastBase.cpp index bf092c3cc..a657959a9 100644 --- a/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastBase.cpp +++ b/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastBase.cpp @@ -68,7 +68,13 @@ void RsGxsUpdateBroadcastBase::updateBroadcastChanged() /* Update only update when the widget is visible. */ if (mUpdateWhenInvisible || !widget || widget->isVisible()) { - if (!mGrpIds.empty() || !mGrpIdsMeta.empty() || !mMsgIds.empty() || !mMsgIdsMeta.empty()) + // (cyril) Re-load the entire group is new messages are here, or if group metadata has changed (e.g. visibility permissions, admin rights, etc). + // Do not re-load if Msg data has changed, which means basically the READ flag has changed, because this action is done in the UI in the + // first place so there's no need to re-update the UI once this is done. + // + // The question to whether we should re=load when mGrpIds is not empty is still open. It's not harmful anyway. + + if (!mGrpIds.empty() || !mGrpIdsMeta.empty() /*|| !mMsgIds.empty()*/ || !mMsgIdsMeta.empty()) mFillComplete = true ; securedUpdateDisplay(); diff --git a/retroshare-gui/src/util/RsGxsUpdateBroadcast.cpp b/retroshare-gui/src/util/RsGxsUpdateBroadcast.cpp index cbda167cb..35da468da 100644 --- a/retroshare-gui/src/util/RsGxsUpdateBroadcast.cpp +++ b/retroshare-gui/src/util/RsGxsUpdateBroadcast.cpp @@ -45,20 +45,21 @@ RsGxsUpdateBroadcast *RsGxsUpdateBroadcast::get(RsGxsIfaceHelper *ifaceImpl) void RsGxsUpdateBroadcast::onChangesReceived(const RsGxsChanges& changes) { -#ifdef DEBUG_GXS_BROADCAST +#ifndef DEBUG_GXS_BROADCAST std::cerr << "onChangesReceived()" << std::endl; { std::cerr << "Received changes for service " << (void*)changes.mService << ", expecting service " << (void*)mIfaceImpl->getTokenService() << std::endl; - std::cerr << " changes content: " << std::endl; - for(std::list::const_iterator it(changes.mGrps.begin());it!=changes.mGrps.end();++it) std::cerr << " grp id: " << *it << std::endl; - for(std::list::const_iterator it(changes.mGrpsMeta.begin());it!=changes.mGrpsMeta.end();++it) std::cerr << " grp meta: " << *it << std::endl; + for(std::list::const_iterator it(changes.mGrps.begin());it!=changes.mGrps.end();++it) + std::cerr << "[GRP CHANGE] grp id: " << *it << std::endl; + for(std::list::const_iterator it(changes.mGrpsMeta.begin());it!=changes.mGrpsMeta.end();++it) + std::cerr << "[GRP CHANGE] grp meta: " << *it << std::endl; for(std::map >::const_iterator it(changes.mMsgs.begin());it!=changes.mMsgs.end();++it) for(uint32_t i=0;isecond.size();++i) - std::cerr << " grp id: " << it->first << ". Msg ID " << it->second[i] << std::endl; + std::cerr << "[MSG CHANGE] grp id: " << it->first << ". Msg ID " << it->second[i] << std::endl; for(std::map >::const_iterator it(changes.mMsgsMeta.begin());it!=changes.mMsgsMeta.end();++it) for(uint32_t i=0;isecond.size();++i) - std::cerr << " grp id: " << it->first << ". Msg Meta " << it->second[i] << std::endl; + std::cerr << "[MSG CHANGE] grp id: " << it->first << ". Msg Meta " << it->second[i] << std::endl; } #endif if(changes.mService != mIfaceImpl->getTokenService()) From 2e7398ac9bbbf94aad1df46a53dcd304a039cbe7 Mon Sep 17 00:00:00 2001 From: csoler Date: Mon, 18 Jun 2018 22:35:22 +0200 Subject: [PATCH 2/3] removed debug info --- .../src/util/RsGxsUpdateBroadcast.cpp | 166 +++++++++--------- 1 file changed, 83 insertions(+), 83 deletions(-) diff --git a/retroshare-gui/src/util/RsGxsUpdateBroadcast.cpp b/retroshare-gui/src/util/RsGxsUpdateBroadcast.cpp index 35da468da..48c13d6db 100644 --- a/retroshare-gui/src/util/RsGxsUpdateBroadcast.cpp +++ b/retroshare-gui/src/util/RsGxsUpdateBroadcast.cpp @@ -1,83 +1,83 @@ -#include - -#include "RsGxsUpdateBroadcast.h" -#include "gui/notifyqt.h" - -#include - -//#define DEBUG_GXS_BROADCAST 1 - -// previously gxs allowed only one event consumer to poll for changes -// this required a single broadcast instance per service -// now the update notify works through rsnotify and notifyqt -// so the single instance per service is not really needed anymore - -QMap updateBroadcastMap; - -RsGxsUpdateBroadcast::RsGxsUpdateBroadcast(RsGxsIfaceHelper *ifaceImpl) : - QObject(NULL), mIfaceImpl(ifaceImpl) -{ - connect(NotifyQt::getInstance(), SIGNAL(gxsChange(RsGxsChanges)), this, SLOT(onChangesReceived(RsGxsChanges))); -} - -void RsGxsUpdateBroadcast::cleanup() -{ - QMap::iterator it; - for (it = updateBroadcastMap.begin(); it != updateBroadcastMap.end(); ++it) { - delete(it.value()); - } - - updateBroadcastMap.clear(); -} - -RsGxsUpdateBroadcast *RsGxsUpdateBroadcast::get(RsGxsIfaceHelper *ifaceImpl) -{ - QMap::iterator it = updateBroadcastMap.find(ifaceImpl); - if (it != updateBroadcastMap.end()) { - return it.value(); - } - - RsGxsUpdateBroadcast *updateBroadcast = new RsGxsUpdateBroadcast(ifaceImpl); - updateBroadcastMap.insert(ifaceImpl, updateBroadcast); - - return updateBroadcast; -} - -void RsGxsUpdateBroadcast::onChangesReceived(const RsGxsChanges& changes) -{ -#ifndef DEBUG_GXS_BROADCAST - std::cerr << "onChangesReceived()" << std::endl; - - { - std::cerr << "Received changes for service " << (void*)changes.mService << ", expecting service " << (void*)mIfaceImpl->getTokenService() << std::endl; - for(std::list::const_iterator it(changes.mGrps.begin());it!=changes.mGrps.end();++it) - std::cerr << "[GRP CHANGE] grp id: " << *it << std::endl; - for(std::list::const_iterator it(changes.mGrpsMeta.begin());it!=changes.mGrpsMeta.end();++it) - std::cerr << "[GRP CHANGE] grp meta: " << *it << std::endl; - for(std::map >::const_iterator it(changes.mMsgs.begin());it!=changes.mMsgs.end();++it) - for(uint32_t i=0;isecond.size();++i) - std::cerr << "[MSG CHANGE] grp id: " << it->first << ". Msg ID " << it->second[i] << std::endl; - for(std::map >::const_iterator it(changes.mMsgsMeta.begin());it!=changes.mMsgsMeta.end();++it) - for(uint32_t i=0;isecond.size();++i) - std::cerr << "[MSG CHANGE] grp id: " << it->first << ". Msg Meta " << it->second[i] << std::endl; - } -#endif - if(changes.mService != mIfaceImpl->getTokenService()) - { - // std::cerr << "(EE) Incorrect service. Dropping." << std::endl; - - return; - } - - if (!changes.mMsgs.empty() || !changes.mMsgsMeta.empty()) - { - emit msgsChanged(changes.mMsgs, changes.mMsgsMeta); - } - - if (!changes.mGrps.empty() || !changes.mGrpsMeta.empty()) - { - emit grpsChanged(changes.mGrps, changes.mGrpsMeta); - } - - emit changed(); -} +#include + +#include "RsGxsUpdateBroadcast.h" +#include "gui/notifyqt.h" + +#include + +//#define DEBUG_GXS_BROADCAST 1 + +// previously gxs allowed only one event consumer to poll for changes +// this required a single broadcast instance per service +// now the update notify works through rsnotify and notifyqt +// so the single instance per service is not really needed anymore + +QMap updateBroadcastMap; + +RsGxsUpdateBroadcast::RsGxsUpdateBroadcast(RsGxsIfaceHelper *ifaceImpl) : + QObject(NULL), mIfaceImpl(ifaceImpl) +{ + connect(NotifyQt::getInstance(), SIGNAL(gxsChange(RsGxsChanges)), this, SLOT(onChangesReceived(RsGxsChanges))); +} + +void RsGxsUpdateBroadcast::cleanup() +{ + QMap::iterator it; + for (it = updateBroadcastMap.begin(); it != updateBroadcastMap.end(); ++it) { + delete(it.value()); + } + + updateBroadcastMap.clear(); +} + +RsGxsUpdateBroadcast *RsGxsUpdateBroadcast::get(RsGxsIfaceHelper *ifaceImpl) +{ + QMap::iterator it = updateBroadcastMap.find(ifaceImpl); + if (it != updateBroadcastMap.end()) { + return it.value(); + } + + RsGxsUpdateBroadcast *updateBroadcast = new RsGxsUpdateBroadcast(ifaceImpl); + updateBroadcastMap.insert(ifaceImpl, updateBroadcast); + + return updateBroadcast; +} + +void RsGxsUpdateBroadcast::onChangesReceived(const RsGxsChanges& changes) +{ +#ifdef DEBUG_GXS_BROADCAST + std::cerr << "onChangesReceived()" << std::endl; + + { + std::cerr << "Received changes for service " << (void*)changes.mService << ", expecting service " << (void*)mIfaceImpl->getTokenService() << std::endl; + for(std::list::const_iterator it(changes.mGrps.begin());it!=changes.mGrps.end();++it) + std::cerr << "[GRP CHANGE] grp id: " << *it << std::endl; + for(std::list::const_iterator it(changes.mGrpsMeta.begin());it!=changes.mGrpsMeta.end();++it) + std::cerr << "[GRP CHANGE] grp meta: " << *it << std::endl; + for(std::map >::const_iterator it(changes.mMsgs.begin());it!=changes.mMsgs.end();++it) + for(uint32_t i=0;isecond.size();++i) + std::cerr << "[MSG CHANGE] grp id: " << it->first << ". Msg ID " << it->second[i] << std::endl; + for(std::map >::const_iterator it(changes.mMsgsMeta.begin());it!=changes.mMsgsMeta.end();++it) + for(uint32_t i=0;isecond.size();++i) + std::cerr << "[MSG CHANGE] grp id: " << it->first << ". Msg Meta " << it->second[i] << std::endl; + } +#endif + if(changes.mService != mIfaceImpl->getTokenService()) + { + // std::cerr << "(EE) Incorrect service. Dropping." << std::endl; + + return; + } + + if (!changes.mMsgs.empty() || !changes.mMsgsMeta.empty()) + { + emit msgsChanged(changes.mMsgs, changes.mMsgsMeta); + } + + if (!changes.mGrps.empty() || !changes.mGrpsMeta.empty()) + { + emit grpsChanged(changes.mGrps, changes.mGrpsMeta); + } + + emit changed(); +} From 6139632378b59091ef67ec4438b748d718f0c77d Mon Sep 17 00:00:00 2001 From: csoler Date: Mon, 18 Jun 2018 22:37:31 +0200 Subject: [PATCH 3/3] changed back RsGxsUpdateBroadCast.cpp to dos line ending --- .../src/util/RsGxsUpdateBroadcast.cpp | 166 +++++++++--------- 1 file changed, 83 insertions(+), 83 deletions(-) diff --git a/retroshare-gui/src/util/RsGxsUpdateBroadcast.cpp b/retroshare-gui/src/util/RsGxsUpdateBroadcast.cpp index 48c13d6db..0fdf63d65 100644 --- a/retroshare-gui/src/util/RsGxsUpdateBroadcast.cpp +++ b/retroshare-gui/src/util/RsGxsUpdateBroadcast.cpp @@ -1,83 +1,83 @@ -#include - -#include "RsGxsUpdateBroadcast.h" -#include "gui/notifyqt.h" - -#include - -//#define DEBUG_GXS_BROADCAST 1 - -// previously gxs allowed only one event consumer to poll for changes -// this required a single broadcast instance per service -// now the update notify works through rsnotify and notifyqt -// so the single instance per service is not really needed anymore - -QMap updateBroadcastMap; - -RsGxsUpdateBroadcast::RsGxsUpdateBroadcast(RsGxsIfaceHelper *ifaceImpl) : - QObject(NULL), mIfaceImpl(ifaceImpl) -{ - connect(NotifyQt::getInstance(), SIGNAL(gxsChange(RsGxsChanges)), this, SLOT(onChangesReceived(RsGxsChanges))); -} - -void RsGxsUpdateBroadcast::cleanup() -{ - QMap::iterator it; - for (it = updateBroadcastMap.begin(); it != updateBroadcastMap.end(); ++it) { - delete(it.value()); - } - - updateBroadcastMap.clear(); -} - -RsGxsUpdateBroadcast *RsGxsUpdateBroadcast::get(RsGxsIfaceHelper *ifaceImpl) -{ - QMap::iterator it = updateBroadcastMap.find(ifaceImpl); - if (it != updateBroadcastMap.end()) { - return it.value(); - } - - RsGxsUpdateBroadcast *updateBroadcast = new RsGxsUpdateBroadcast(ifaceImpl); - updateBroadcastMap.insert(ifaceImpl, updateBroadcast); - - return updateBroadcast; -} - -void RsGxsUpdateBroadcast::onChangesReceived(const RsGxsChanges& changes) -{ -#ifdef DEBUG_GXS_BROADCAST - std::cerr << "onChangesReceived()" << std::endl; - - { - std::cerr << "Received changes for service " << (void*)changes.mService << ", expecting service " << (void*)mIfaceImpl->getTokenService() << std::endl; - for(std::list::const_iterator it(changes.mGrps.begin());it!=changes.mGrps.end();++it) - std::cerr << "[GRP CHANGE] grp id: " << *it << std::endl; - for(std::list::const_iterator it(changes.mGrpsMeta.begin());it!=changes.mGrpsMeta.end();++it) - std::cerr << "[GRP CHANGE] grp meta: " << *it << std::endl; - for(std::map >::const_iterator it(changes.mMsgs.begin());it!=changes.mMsgs.end();++it) - for(uint32_t i=0;isecond.size();++i) - std::cerr << "[MSG CHANGE] grp id: " << it->first << ". Msg ID " << it->second[i] << std::endl; - for(std::map >::const_iterator it(changes.mMsgsMeta.begin());it!=changes.mMsgsMeta.end();++it) - for(uint32_t i=0;isecond.size();++i) - std::cerr << "[MSG CHANGE] grp id: " << it->first << ". Msg Meta " << it->second[i] << std::endl; - } -#endif - if(changes.mService != mIfaceImpl->getTokenService()) - { - // std::cerr << "(EE) Incorrect service. Dropping." << std::endl; - - return; - } - - if (!changes.mMsgs.empty() || !changes.mMsgsMeta.empty()) - { - emit msgsChanged(changes.mMsgs, changes.mMsgsMeta); - } - - if (!changes.mGrps.empty() || !changes.mGrpsMeta.empty()) - { - emit grpsChanged(changes.mGrps, changes.mGrpsMeta); - } - - emit changed(); -} +#include + +#include "RsGxsUpdateBroadcast.h" +#include "gui/notifyqt.h" + +#include + +//#define DEBUG_GXS_BROADCAST 1 + +// previously gxs allowed only one event consumer to poll for changes +// this required a single broadcast instance per service +// now the update notify works through rsnotify and notifyqt +// so the single instance per service is not really needed anymore + +QMap updateBroadcastMap; + +RsGxsUpdateBroadcast::RsGxsUpdateBroadcast(RsGxsIfaceHelper *ifaceImpl) : + QObject(NULL), mIfaceImpl(ifaceImpl) +{ + connect(NotifyQt::getInstance(), SIGNAL(gxsChange(RsGxsChanges)), this, SLOT(onChangesReceived(RsGxsChanges))); +} + +void RsGxsUpdateBroadcast::cleanup() +{ + QMap::iterator it; + for (it = updateBroadcastMap.begin(); it != updateBroadcastMap.end(); ++it) { + delete(it.value()); + } + + updateBroadcastMap.clear(); +} + +RsGxsUpdateBroadcast *RsGxsUpdateBroadcast::get(RsGxsIfaceHelper *ifaceImpl) +{ + QMap::iterator it = updateBroadcastMap.find(ifaceImpl); + if (it != updateBroadcastMap.end()) { + return it.value(); + } + + RsGxsUpdateBroadcast *updateBroadcast = new RsGxsUpdateBroadcast(ifaceImpl); + updateBroadcastMap.insert(ifaceImpl, updateBroadcast); + + return updateBroadcast; +} + +void RsGxsUpdateBroadcast::onChangesReceived(const RsGxsChanges& changes) +{ +#ifdef DEBUG_GXS_BROADCAST + std::cerr << "onChangesReceived()" << std::endl; + + { + std::cerr << "Received changes for service " << (void*)changes.mService << ", expecting service " << (void*)mIfaceImpl->getTokenService() << std::endl; + for(std::list::const_iterator it(changes.mGrps.begin());it!=changes.mGrps.end();++it) + std::cerr << "[GRP CHANGE] grp id: " << *it << std::endl; + for(std::list::const_iterator it(changes.mGrpsMeta.begin());it!=changes.mGrpsMeta.end();++it) + std::cerr << "[GRP CHANGE] grp meta: " << *it << std::endl; + for(std::map >::const_iterator it(changes.mMsgs.begin());it!=changes.mMsgs.end();++it) + for(uint32_t i=0;isecond.size();++i) + std::cerr << "[MSG CHANGE] grp id: " << it->first << ". Msg ID " << it->second[i] << std::endl; + for(std::map >::const_iterator it(changes.mMsgsMeta.begin());it!=changes.mMsgsMeta.end();++it) + for(uint32_t i=0;isecond.size();++i) + std::cerr << "[MSG CHANGE] grp id: " << it->first << ". Msg Meta " << it->second[i] << std::endl; + } +#endif + if(changes.mService != mIfaceImpl->getTokenService()) + { + // std::cerr << "(EE) Incorrect service. Dropping." << std::endl; + + return; + } + + if (!changes.mMsgs.empty() || !changes.mMsgsMeta.empty()) + { + emit msgsChanged(changes.mMsgs, changes.mMsgsMeta); + } + + if (!changes.mGrps.empty() || !changes.mGrpsMeta.empty()) + { + emit grpsChanged(changes.mGrps, changes.mGrpsMeta); + } + + emit changed(); +}