Merge pull request #2164 from PhenomRetroShare/Fix_ParamNetworkPageUpdate

Fix Preferences-Network page IP update.
This commit is contained in:
csoler 2020-12-14 20:59:31 +01:00 committed by GitHub
commit 71725f8be4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 40 additions and 3 deletions

View File

@ -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 <iostream>
#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 <QCheckBox>
#include <QMovie>
#include <QMenu>
#include <QTcpSocket>
#include <QNetworkProxy>
#include <QNetworkReply>
#include <QNetworkRequest>
#include <QNetworkAccessManager>
#include <QTcpSocket>
#include <QTimer>
#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<const RsEvent> event) { handleEvent(event); }, mEventHandlerId, RsEventType::NETWORK );
}
void ServerPage::handleEvent(std::shared_ptr<const RsEvent> e)
{
if(e->mType != RsEventType::NETWORK)
return;
const RsNetworkEvent *ne = dynamic_cast<const RsNetworkEvent*>(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();

View File

@ -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<const RsEvent> event);
};
#endif // !SERVERPAGE_H