diff --git a/retroshare-gui/src/gui/settings/ServerPage.cpp b/retroshare-gui/src/gui/settings/ServerPage.cpp index ca3144b5c..d00aef4f7 100755 --- a/retroshare-gui/src/gui/settings/ServerPage.cpp +++ b/retroshare-gui/src/gui/settings/ServerPage.cpp @@ -24,26 +24,27 @@ #include "rshare.h" #include "rsharesettings.h" #include "util/i2pcommon.h" -#include "util/RsNetUtil.h" #include "util/misc.h" +#include "util/qtthreadsutils.h" +#include "util/RsNetUtil.h" #include #include "retroshare/rsbanlist.h" #include "retroshare/rsconfig.h" #include "retroshare/rsdht.h" +#include "retroshare/rsinit.h" #include "retroshare/rspeers.h" #include "retroshare/rsturtle.h" -#include "retroshare/rsinit.h" #include #include #include -#include #include #include #include #include +#include #include #define ICON_STATUS_UNKNOWN ":/images/ledoff1.png" @@ -79,6 +80,7 @@ ServerPage::ServerPage(QWidget * parent, Qt::WindowFlags flags) , manager(NULL), mOngoingConnectivityCheck(-1) , mIsHiddenNode(false), mHiddenType(RS_HIDDEN_TYPE_NONE) , mBobAccessible(false) + , mEventHandlerId(0) { /* Invoke the Qt Designer generated object setup routine */ ui.setupUi(this); @@ -244,8 +246,38 @@ ServerPage::ServerPage(QWidget * parent, Qt::WindowFlags flags) // when the network menu is opened and the hidden service tab is already selected updateOutProxyIndicator() won't be called and thus resulting in wrong proxy indicators. if (ui.tabWidget->currentIndex() == TAB_HIDDEN_SERVICE) updateOutProxyIndicator(); + + rsEvents->registerEventsHandler( [this](std::shared_ptr event) { handleEvent(event); }, mEventHandlerId, RsEventType::NETWORK ); + } +void ServerPage::handleEvent(std::shared_ptr e) +{ + if(e->mType != RsEventType::NETWORK) + return; + + const RsNetworkEvent *ne = dynamic_cast(e.get()); + + if(!ne) + return; + + // in any case we update the IPs + + switch(ne->mNetworkEventCode) + { + case RsNetworkEventCode::LOCAL_IP_UPDATED: // [fallthrough] + case RsNetworkEventCode::EXTERNAL_IP_UPDATED: // [fallthrough] + RsQThreadUtils::postToObject( [=]() + { + updateStatus(); + },this); + break; + default: + break; + } +} + + void ServerPage::saveAndTestInProxy() { saveAddresses(); diff --git a/retroshare-gui/src/gui/settings/ServerPage.h b/retroshare-gui/src/gui/settings/ServerPage.h index de4751d5e..de971881b 100755 --- a/retroshare-gui/src/gui/settings/ServerPage.h +++ b/retroshare-gui/src/gui/settings/ServerPage.h @@ -40,6 +40,8 @@ #include "retroshare-gui/RsAutoUpdatePage.h" #include "gui/common/FilesDefs.h" +#include "retroshare/rsevents.h" + class QNetworkReply; class QNetworkAccessManager; @@ -160,6 +162,9 @@ private: uint32_t mHiddenType; bobSettings mBobSettings; bool mBobAccessible; // keeps track wether bob is accessable or not to en/disable the corresponding buttons + + RsEventsHandlerId_t mEventHandlerId; + void handleEvent(std::shared_ptr event); }; #endif // !SERVERPAGE_H