From 27793627e3a8652f7a7ee15b2fb688c43e74352a Mon Sep 17 00:00:00 2001 From: csoler Date: Mon, 9 Dec 2019 22:19:03 +0100 Subject: [PATCH] moved GxsChanges to rsEvents --- libretroshare/src/gxs/rsgenexchange.cc | 17 ++--------------- libretroshare/src/pqi/p3notify.cc | 1 - libretroshare/src/pqi/p3notify.h | 1 - libretroshare/src/retroshare/rsnotify.h | 1 - retroshare-gui/src/gui/notifyqt.cpp | 2 ++ retroshare-gui/src/gui/notifyqt.h | 2 -- .../src/util/RsGxsUpdateBroadcast.cpp | 9 ++++++++- retroshare-gui/src/util/RsGxsUpdateBroadcast.h | 2 ++ 8 files changed, 14 insertions(+), 21 deletions(-) diff --git a/libretroshare/src/gxs/rsgenexchange.cc b/libretroshare/src/gxs/rsgenexchange.cc index 2ac0736e5..bdc83792c 100644 --- a/libretroshare/src/gxs/rsgenexchange.cc +++ b/libretroshare/src/gxs/rsgenexchange.cc @@ -1118,38 +1118,25 @@ void RsGenExchange::receiveChanges(std::vector& changes) if((mc = dynamic_cast(n)) != nullptr) { if (mc->metaChange()) - { addMessageChanged(out.mMsgsMeta, mc->msgChangeMap); - } else - { addMessageChanged(out.mMsgs, mc->msgChangeMap); - } } else if((gc = dynamic_cast(n)) != nullptr) { if(gc->metaChange()) - { out.mGrpsMeta.splice(out.mGrpsMeta.end(), gc->mGrpIdList); - } else - { out.mGrps.splice(out.mGrps.end(), gc->mGrpIdList); - } } - else if(( gt = - dynamic_cast(n) ) != nullptr) - { + else if(( gt = dynamic_cast(n) ) != nullptr) out.mDistantSearchReqs.push_back(gt->mRequestId); - } else - RsErr() << __PRETTY_FUNCTION__ << " Unknown changes type!" - << std::endl; + RsErr() << __PRETTY_FUNCTION__ << " Unknown changes type!" << std::endl; delete n; } changes.clear() ; - RsServer::notify()->notifyGxsChange(out); if(rsEvents) rsEvents->postEvent(std::move(evt)); } diff --git a/libretroshare/src/pqi/p3notify.cc b/libretroshare/src/pqi/p3notify.cc index 95486f1a4..7a5dc8c45 100644 --- a/libretroshare/src/pqi/p3notify.cc +++ b/libretroshare/src/pqi/p3notify.cc @@ -233,7 +233,6 @@ void p3Notify::notifyOwnAvatarChanged () void p3Notify::notifyOwnStatusMessageChanged() { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyOwnStatusMessageChanged() ; } void p3Notify::notifyDiskFull (uint32_t location , uint32_t size_limit_in_MB ) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyDiskFull (location,size_limit_in_MB) ; } void p3Notify::notifyPeerStatusChanged (const std::string& peer_id , uint32_t status ) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyPeerStatusChanged (peer_id,status) ; } -void p3Notify::notifyGxsChange (const RsGxsChanges& changes) {FOR_ALL_NOTIFY_CLIENTS (*it)->notifyGxsChange(changes) ;} void p3Notify::notifyPeerStatusChangedSummary () { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyPeerStatusChangedSummary() ; } void p3Notify::notifyDiscInfoChanged () { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyDiscInfoChanged () ; } diff --git a/libretroshare/src/pqi/p3notify.h b/libretroshare/src/pqi/p3notify.h index d288091c3..46fb69c8e 100644 --- a/libretroshare/src/pqi/p3notify.h +++ b/libretroshare/src/pqi/p3notify.h @@ -109,7 +109,6 @@ class p3Notify: public RsNotify void notifyOwnStatusMessageChanged () ; void notifyDiskFull (uint32_t /* location */, uint32_t /* size limit in MB */) ; void notifyPeerStatusChanged (const std::string& /* peer_id */, uint32_t /* status */) ; - void notifyGxsChange (const RsGxsChanges& /* changes */); void notifyConnectionWithoutCert (); void notifyPeerStatusChangedSummary () ; diff --git a/libretroshare/src/retroshare/rsnotify.h b/libretroshare/src/retroshare/rsnotify.h index 6f882215f..6cb55dd66 100644 --- a/libretroshare/src/retroshare/rsnotify.h +++ b/libretroshare/src/retroshare/rsnotify.h @@ -229,7 +229,6 @@ public: virtual void notifyOwnStatusMessageChanged () {} virtual void notifyDiskFull (uint32_t /* location */, uint32_t /* size limit in MB */) {} virtual void notifyPeerStatusChanged (const std::string& /* peer_id */, uint32_t /* status */) {} - virtual void notifyGxsChange (const RsGxsChanges& /* changes */) {} /* one or more peers has changed the states */ virtual void notifyPeerStatusChangedSummary () {} diff --git a/retroshare-gui/src/gui/notifyqt.cpp b/retroshare-gui/src/gui/notifyqt.cpp index e13ed610d..27a81546a 100644 --- a/retroshare-gui/src/gui/notifyqt.cpp +++ b/retroshare-gui/src/gui/notifyqt.cpp @@ -422,6 +422,7 @@ void NotifyQt::notifyPeerStatusChangedSummary() emit peerStatusChangedSummary(); } +#ifdef TO_REMOVE void NotifyQt::notifyGxsChange(const RsGxsChanges& changes) { { @@ -436,6 +437,7 @@ void NotifyQt::notifyGxsChange(const RsGxsChanges& changes) emit gxsChange(changes); } +#endif void NotifyQt::notifyOwnStatusMessageChanged() { diff --git a/retroshare-gui/src/gui/notifyqt.h b/retroshare-gui/src/gui/notifyqt.h index 91fb1edbf..dd09bf4ea 100644 --- a/retroshare-gui/src/gui/notifyqt.h +++ b/retroshare-gui/src/gui/notifyqt.h @@ -82,8 +82,6 @@ class NotifyQt: public QObject, public NotifyClient /* one or more peers has changed the states */ virtual void notifyPeerStatusChangedSummary(); - virtual void notifyGxsChange(const RsGxsChanges& change); - virtual void notifyHistoryChanged(uint32_t msgId, int type); virtual void notifyDiscInfoChanged() ; diff --git a/retroshare-gui/src/util/RsGxsUpdateBroadcast.cpp b/retroshare-gui/src/util/RsGxsUpdateBroadcast.cpp index 5dbbf1c5a..bd2d647f5 100644 --- a/retroshare-gui/src/util/RsGxsUpdateBroadcast.cpp +++ b/retroshare-gui/src/util/RsGxsUpdateBroadcast.cpp @@ -37,7 +37,14 @@ QMap updateBroadcastMap; RsGxsUpdateBroadcast::RsGxsUpdateBroadcast(RsGxsIfaceHelper *ifaceImpl) : QObject(NULL), mIfaceImpl(ifaceImpl) { - connect(NotifyQt::getInstance(), SIGNAL(gxsChange(RsGxsChanges)), this, SLOT(onChangesReceived(RsGxsChanges))); + mEventHandlerId = 0; // forces initialization in registerEventsHandler() + + rsEvents->registerEventsHandler( [this](std::shared_ptr event) + { + if(event->mType == RsEventType::GXS_CHANGES) + onChangesReceived(*dynamic_cast(event.get())); + + }, mEventHandlerId ); } void RsGxsUpdateBroadcast::cleanup() diff --git a/retroshare-gui/src/util/RsGxsUpdateBroadcast.h b/retroshare-gui/src/util/RsGxsUpdateBroadcast.h index 1a776f2c4..1383c18dd 100644 --- a/retroshare-gui/src/util/RsGxsUpdateBroadcast.h +++ b/retroshare-gui/src/util/RsGxsUpdateBroadcast.h @@ -24,6 +24,7 @@ #include #include +#include struct RsGxsIfaceHelper; struct RsGxsChanges; @@ -53,6 +54,7 @@ private: private: RsGxsIfaceHelper* mIfaceImpl; + RsEventsHandlerId_t mEventHandlerId ; }; #endif // RSGXSUPDATEBROADCAST_H