From dbddf7166f2d6000b21b4711f3a80f17bdf08d11 Mon Sep 17 00:00:00 2001 From: PYRET1C <88980503+PYRET1C@users.noreply.github.com> Date: Tue, 2 May 2023 23:50:37 +0530 Subject: [PATCH 1/6] This is the gui part of the commit where the wire feed is refreshed if there is any event published. --- retroshare-gui/src/gui/TheWire/WireDialog.cpp | 42 ++++++++++++++++++- retroshare-gui/src/gui/TheWire/WireDialog.h | 3 ++ 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/retroshare-gui/src/gui/TheWire/WireDialog.cpp b/retroshare-gui/src/gui/TheWire/WireDialog.cpp index 23031d6ec..98225cf7e 100644 --- a/retroshare-gui/src/gui/TheWire/WireDialog.cpp +++ b/retroshare-gui/src/gui/TheWire/WireDialog.cpp @@ -59,7 +59,7 @@ WireDialog::WireDialog(QWidget *parent) : MainPage(parent), mGroupSet(GROUP_SET_ALL) , mAddDialog(nullptr), mGroupSelected(nullptr), mWireQueue(nullptr) - , mHistoryIndex(-1) + , mHistoryIndex(-1), mEventHandlerId(0) { ui.setupUi(this); @@ -89,6 +89,42 @@ WireDialog::WireDialog(QWidget *parent) // load settings processSettings(true); + + // Needs to be asynced because this function is called by another thread! + rsEvents->registerEventsHandler( + [this](std::shared_ptr event) + { RsQThreadUtils::postToObject([=]() { handleEvent_main_thread(event); }, this ); }, + mEventHandlerId, RsEventType::WIRE ); +} + +void WireDialog::handleEvent_main_thread(std::shared_ptr event) +{ + const RsWireEvent *e = dynamic_cast(event.get()); + + if(e) + switch(e->mWireEventCode) + { + case RsWireEventCode::NEW_POST: // [[fallthrough]]; + refreshGroups(); + break; + case RsWireEventCode::NEW_REPLY: // [[fallthrough]]; + refreshGroups(); + break; + case RsWireEventCode::NEW_LIKE: // [[fallthrough]]; + refreshGroups(); + break; + case RsWireEventCode::NEW_REPUBLISH: // [[fallthrough]]; + refreshGroups(); + break; + case RsWireEventCode::NEW_WIRE: // [[fallthrough]]; + refreshGroups(); + break; + case RsWireEventCode::FOLLOW_STATUS_CHANGED: // [[fallthrough]]; + refreshGroups(); + break; + default: + break; + } } WireDialog::~WireDialog() @@ -97,7 +133,9 @@ WireDialog::~WireDialog() processSettings(false); clearTwitterView(); - delete(mWireQueue); + delete(mWireQueue); + + rsEvents->unregisterEventsHandler(mEventHandlerId); } void WireDialog::processSettings(bool load) diff --git a/retroshare-gui/src/gui/TheWire/WireDialog.h b/retroshare-gui/src/gui/TheWire/WireDialog.h index 8ccf13377..1ac7faebc 100644 --- a/retroshare-gui/src/gui/TheWire/WireDialog.h +++ b/retroshare-gui/src/gui/TheWire/WireDialog.h @@ -164,6 +164,9 @@ private: std::map mAllGroups; std::vector mOwnGroups; + void handleEvent_main_thread(std::shared_ptr event); + RsEventsHandlerId_t mEventHandlerId; + int32_t mHistoryIndex; std::vector mHistory; From 726c42852c29c7edda428d67b35a086656159a74 Mon Sep 17 00:00:00 2001 From: PYRET1C <88980503+PYRET1C@users.noreply.github.com> Date: Tue, 9 May 2023 23:18:34 +0530 Subject: [PATCH 2/6] This commit removed the refresh button and edited some events for the retro share wire. --- retroshare-gui/src/gui/TheWire/WireDialog.cpp | 22 +++++++++++++------ retroshare-gui/src/gui/TheWire/WireDialog.h | 1 + retroshare-gui/src/gui/TheWire/WireDialog.ui | 16 ++++---------- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/retroshare-gui/src/gui/TheWire/WireDialog.cpp b/retroshare-gui/src/gui/TheWire/WireDialog.cpp index 13390e782..ea63e933e 100644 --- a/retroshare-gui/src/gui/TheWire/WireDialog.cpp +++ b/retroshare-gui/src/gui/TheWire/WireDialog.cpp @@ -67,7 +67,6 @@ WireDialog::WireDialog(QWidget *parent) connect( ui.toolButton_createAccount, SIGNAL(clicked()), this, SLOT(createGroup())); connect( ui.toolButton_createPulse, SIGNAL(clicked()), this, SLOT(createPulse())); - connect( ui.toolButton_refresh, SIGNAL(clicked()), this, SLOT(refreshGroups())); connect(ui.comboBox_groupSet, SIGNAL(currentIndexChanged(int)), this, SLOT(selectGroupSet(int))); connect(ui.comboBox_filterTime, SIGNAL(currentIndexChanged(int)), this, SLOT(selectFilterTime(int))); @@ -104,29 +103,38 @@ void WireDialog::handleEvent_main_thread(std::shared_ptr event) const RsWireEvent *e = dynamic_cast(event.get()); if(e) + { + +#ifdef GXSWIRE_DEBUG + RsDbg() << " Refreshing the feed if there is a matching event. "<< std::endl; +#endif + + // The following switch statements refresh the wire feed whenever there is a new event switch(e->mWireEventCode) { - case RsWireEventCode::NEW_POST: // [[fallthrough]]; + case RsWireEventCode::NEW_POST: refreshGroups(); break; - case RsWireEventCode::NEW_REPLY: // [[fallthrough]]; + case RsWireEventCode::NEW_REPLY: refreshGroups(); break; - case RsWireEventCode::NEW_LIKE: // [[fallthrough]]; + case RsWireEventCode::NEW_LIKE: refreshGroups(); break; - case RsWireEventCode::NEW_REPUBLISH: // [[fallthrough]]; + case RsWireEventCode::NEW_REPUBLISH: refreshGroups(); break; - case RsWireEventCode::NEW_WIRE: // [[fallthrough]]; + case RsWireEventCode::POST_UPDATED: refreshGroups(); break; - case RsWireEventCode::FOLLOW_STATUS_CHANGED: // [[fallthrough]]; + case RsWireEventCode::FOLLOW_STATUS_CHANGED: refreshGroups(); break; default: break; + } + } } WireDialog::~WireDialog() diff --git a/retroshare-gui/src/gui/TheWire/WireDialog.h b/retroshare-gui/src/gui/TheWire/WireDialog.h index 1ac7faebc..a55369fc0 100644 --- a/retroshare-gui/src/gui/TheWire/WireDialog.h +++ b/retroshare-gui/src/gui/TheWire/WireDialog.h @@ -164,6 +164,7 @@ private: std::map mAllGroups; std::vector mOwnGroups; + // This function and variable below it handle the events for the wire void handleEvent_main_thread(std::shared_ptr event); RsEventsHandlerId_t mEventHandlerId; diff --git a/retroshare-gui/src/gui/TheWire/WireDialog.ui b/retroshare-gui/src/gui/TheWire/WireDialog.ui index 23eb87a78..b794a96e0 100644 --- a/retroshare-gui/src/gui/TheWire/WireDialog.ui +++ b/retroshare-gui/src/gui/TheWire/WireDialog.ui @@ -100,13 +100,6 @@ - - - - Refresh - - - @@ -189,7 +182,6 @@ 10 - 75 true @@ -208,8 +200,8 @@ 0 0 - 220 - 444 + 224 + 465 @@ -387,8 +379,8 @@ 0 0 - 521 - 437 + 523 + 462 From b40e5e34bc491d31cf08ba27aebda45fbbd4a3ab Mon Sep 17 00:00:00 2001 From: PYRET1C <88980503+PYRET1C@users.noreply.github.com> Date: Fri, 19 May 2023 17:00:50 +0530 Subject: [PATCH 3/6] name changes name changes --- build_scripts/OBS | 2 +- libretroshare | 2 +- retroshare-gui/src/gui/TheWire/WireDialog.cpp | 12 ++++++++---- supportlibs/cmark | 2 +- supportlibs/rapidjson | 2 +- supportlibs/restbed | 2 +- 6 files changed, 13 insertions(+), 9 deletions(-) diff --git a/build_scripts/OBS b/build_scripts/OBS index df16cb915..9be56feec 160000 --- a/build_scripts/OBS +++ b/build_scripts/OBS @@ -1 +1 @@ -Subproject commit df16cb915465d058c75277678799ce4dadeae287 +Subproject commit 9be56feec49aa36deda5044bf6a118dcf100bff0 diff --git a/libretroshare b/libretroshare index 74cd958cf..77eae86fa 160000 --- a/libretroshare +++ b/libretroshare @@ -1 +1 @@ -Subproject commit 74cd958cf8a3c8b3e2d3f8a22657b5e16bdad476 +Subproject commit 77eae86faf647c47e6d215f2f309d9a4aa93bdd9 diff --git a/retroshare-gui/src/gui/TheWire/WireDialog.cpp b/retroshare-gui/src/gui/TheWire/WireDialog.cpp index ea63e933e..6904f0c40 100644 --- a/retroshare-gui/src/gui/TheWire/WireDialog.cpp +++ b/retroshare-gui/src/gui/TheWire/WireDialog.cpp @@ -127,7 +127,7 @@ void WireDialog::handleEvent_main_thread(std::shared_ptr event) case RsWireEventCode::POST_UPDATED: refreshGroups(); break; - case RsWireEventCode::FOLLOW_STATUS_CHANGED: + case RsWireEventCode::NEW_WIRE: refreshGroups(); break; default: @@ -1058,12 +1058,16 @@ void WireDialog::postGroupsPulses(std::list pulses) std::cerr << std::endl; continue; } + std::cerr << "This is mMeta.mMsgId : " << reply->mMeta.mMsgId; + std::cerr << std::endl; + std::cerr << "This is mMeta.mMsgName : " << reply->mMeta.mMsgName; + std::cerr << std::endl; PulseReply *firstReply = new PulseReply(this, reply); - addTwitterView(firstReply); - firstReply->showReplyLine(false); + addTwitterView(firstReply); + firstReply->showReplyLine(false); - addTwitterView(new PulseReplySeperator()); + addTwitterView(new PulseReplySeperator()); } } diff --git a/supportlibs/cmark b/supportlibs/cmark index b9c7a496b..7195c6735 160000 --- a/supportlibs/cmark +++ b/supportlibs/cmark @@ -1 +1 @@ -Subproject commit b9c7a496ba7dd9c3495bae2ff2855899e47b245d +Subproject commit 7195c6735f29be947ddc41f86c9ddfc8621d33b9 diff --git a/supportlibs/rapidjson b/supportlibs/rapidjson index f54b0e47a..949c771b0 160000 --- a/supportlibs/rapidjson +++ b/supportlibs/rapidjson @@ -1 +1 @@ -Subproject commit f54b0e47a08782a6131cc3d60f94d038fa6e0a51 +Subproject commit 949c771b03de448bdedea80c44a4a5f65284bfeb diff --git a/supportlibs/restbed b/supportlibs/restbed index c27c6726d..0c99284fb 160000 --- a/supportlibs/restbed +++ b/supportlibs/restbed @@ -1 +1 @@ -Subproject commit c27c6726d28c42e2e1b7537ba63eeb23e944789d +Subproject commit 0c99284fba4f37a89de24972e48b8154abc5dc75 From d3233dbc037aa0d35162c10d95d7834e5db22167 Mon Sep 17 00:00:00 2001 From: PYRET1C <88980503+PYRET1C@users.noreply.github.com> Date: Fri, 19 May 2023 17:06:10 +0530 Subject: [PATCH 4/6] Revert "name changes" This reverts commit b40e5e34bc491d31cf08ba27aebda45fbbd4a3ab. bad commit --- build_scripts/OBS | 2 +- libretroshare | 2 +- retroshare-gui/src/gui/TheWire/WireDialog.cpp | 12 ++++-------- supportlibs/cmark | 2 +- supportlibs/rapidjson | 2 +- supportlibs/restbed | 2 +- 6 files changed, 9 insertions(+), 13 deletions(-) diff --git a/build_scripts/OBS b/build_scripts/OBS index 9be56feec..df16cb915 160000 --- a/build_scripts/OBS +++ b/build_scripts/OBS @@ -1 +1 @@ -Subproject commit 9be56feec49aa36deda5044bf6a118dcf100bff0 +Subproject commit df16cb915465d058c75277678799ce4dadeae287 diff --git a/libretroshare b/libretroshare index 77eae86fa..74cd958cf 160000 --- a/libretroshare +++ b/libretroshare @@ -1 +1 @@ -Subproject commit 77eae86faf647c47e6d215f2f309d9a4aa93bdd9 +Subproject commit 74cd958cf8a3c8b3e2d3f8a22657b5e16bdad476 diff --git a/retroshare-gui/src/gui/TheWire/WireDialog.cpp b/retroshare-gui/src/gui/TheWire/WireDialog.cpp index 6904f0c40..ea63e933e 100644 --- a/retroshare-gui/src/gui/TheWire/WireDialog.cpp +++ b/retroshare-gui/src/gui/TheWire/WireDialog.cpp @@ -127,7 +127,7 @@ void WireDialog::handleEvent_main_thread(std::shared_ptr event) case RsWireEventCode::POST_UPDATED: refreshGroups(); break; - case RsWireEventCode::NEW_WIRE: + case RsWireEventCode::FOLLOW_STATUS_CHANGED: refreshGroups(); break; default: @@ -1058,16 +1058,12 @@ void WireDialog::postGroupsPulses(std::list pulses) std::cerr << std::endl; continue; } - std::cerr << "This is mMeta.mMsgId : " << reply->mMeta.mMsgId; - std::cerr << std::endl; - std::cerr << "This is mMeta.mMsgName : " << reply->mMeta.mMsgName; - std::cerr << std::endl; PulseReply *firstReply = new PulseReply(this, reply); - addTwitterView(firstReply); - firstReply->showReplyLine(false); + addTwitterView(firstReply); + firstReply->showReplyLine(false); - addTwitterView(new PulseReplySeperator()); + addTwitterView(new PulseReplySeperator()); } } diff --git a/supportlibs/cmark b/supportlibs/cmark index 7195c6735..b9c7a496b 160000 --- a/supportlibs/cmark +++ b/supportlibs/cmark @@ -1 +1 @@ -Subproject commit 7195c6735f29be947ddc41f86c9ddfc8621d33b9 +Subproject commit b9c7a496ba7dd9c3495bae2ff2855899e47b245d diff --git a/supportlibs/rapidjson b/supportlibs/rapidjson index 949c771b0..f54b0e47a 160000 --- a/supportlibs/rapidjson +++ b/supportlibs/rapidjson @@ -1 +1 @@ -Subproject commit 949c771b03de448bdedea80c44a4a5f65284bfeb +Subproject commit f54b0e47a08782a6131cc3d60f94d038fa6e0a51 diff --git a/supportlibs/restbed b/supportlibs/restbed index 0c99284fb..c27c6726d 160000 --- a/supportlibs/restbed +++ b/supportlibs/restbed @@ -1 +1 @@ -Subproject commit 0c99284fba4f37a89de24972e48b8154abc5dc75 +Subproject commit c27c6726d28c42e2e1b7537ba63eeb23e944789d From 87282618a4b17bf6092c7cf74eaf63dbfc826795 Mon Sep 17 00:00:00 2001 From: PYRET1C <88980503+PYRET1C@users.noreply.github.com> Date: Tue, 23 May 2023 00:27:30 +0530 Subject: [PATCH 5/6] Changed the follow status changed to new wire --- retroshare-gui/src/gui/TheWire/WireDialog.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/retroshare-gui/src/gui/TheWire/WireDialog.cpp b/retroshare-gui/src/gui/TheWire/WireDialog.cpp index ea63e933e..90121b613 100644 --- a/retroshare-gui/src/gui/TheWire/WireDialog.cpp +++ b/retroshare-gui/src/gui/TheWire/WireDialog.cpp @@ -127,6 +127,9 @@ void WireDialog::handleEvent_main_thread(std::shared_ptr event) case RsWireEventCode::POST_UPDATED: refreshGroups(); break; + case RsWireEventCode::NEW_WIRE: + refreshGroups(); + break; case RsWireEventCode::FOLLOW_STATUS_CHANGED: refreshGroups(); break; From 852ec16c6acf889472d13dda876072c2865a8edf Mon Sep 17 00:00:00 2001 From: PYRET1C <88980503+PYRET1C@users.noreply.github.com> Date: Fri, 26 May 2023 22:20:05 +0530 Subject: [PATCH 6/6] Removed extra refresh function calls and break statements. --- retroshare-gui/src/gui/TheWire/WireDialog.cpp | 22 +++++++------------ 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/retroshare-gui/src/gui/TheWire/WireDialog.cpp b/retroshare-gui/src/gui/TheWire/WireDialog.cpp index 90121b613..38ea1b398 100644 --- a/retroshare-gui/src/gui/TheWire/WireDialog.cpp +++ b/retroshare-gui/src/gui/TheWire/WireDialog.cpp @@ -113,27 +113,21 @@ void WireDialog::handleEvent_main_thread(std::shared_ptr event) switch(e->mWireEventCode) { case RsWireEventCode::NEW_POST: - refreshGroups(); - break; + case RsWireEventCode::NEW_REPLY: - refreshGroups(); - break; + case RsWireEventCode::NEW_LIKE: - refreshGroups(); - break; + case RsWireEventCode::NEW_REPUBLISH: - refreshGroups(); - break; + case RsWireEventCode::POST_UPDATED: - refreshGroups(); - break; + case RsWireEventCode::NEW_WIRE: - refreshGroups(); - break; + case RsWireEventCode::FOLLOW_STATUS_CHANGED: - refreshGroups(); - break; + default: + refreshGroups(); break; }