From 78037a66be2c53405642dba24a0dbd56c7470ae0 Mon Sep 17 00:00:00 2001 From: RetroPooh Date: Mon, 23 Oct 2017 11:42:03 +0300 Subject: [PATCH] disable nat/dht indicators for hidden mode, hide irrelevant network options elements --- retroshare-gui/src/gui/MainWindow.cpp | 23 +++++++++++++++---- retroshare-gui/src/gui/MainWindow.h | 2 ++ .../src/gui/settings/AppearancePage.cpp | 11 +++++++-- .../src/gui/settings/ServerPage.cpp | 19 +++++++++++++-- retroshare-gui/src/gui/settings/ServerPage.ui | 4 ++-- .../src/gui/statistics/StatisticsWindow.cpp | 15 +++++++++--- 6 files changed, 60 insertions(+), 14 deletions(-) diff --git a/retroshare-gui/src/gui/MainWindow.cpp b/retroshare-gui/src/gui/MainWindow.cpp index 0933f8e7b..8012d5be2 100644 --- a/retroshare-gui/src/gui/MainWindow.cpp +++ b/retroshare-gui/src/gui/MainWindow.cpp @@ -141,6 +141,7 @@ #define IMAGE_BLOGS ":/images/kblogger.png" #define IMAGE_DHT ":/images/dht16.png" +/*static*/ bool MainWindow::hiddenmode = false; /*static*/ MainWindow *MainWindow::_instance = NULL; @@ -182,8 +183,10 @@ MainWindow::MainWindow(QWidget* parent, Qt::WindowFlags flags) RsPeerDetails pd; if (rsPeers->getPeerDetails(rsPeers->getOwnId(), pd)) { nameAndLocation = QString("%1 (%2)").arg(QString::fromUtf8(pd.name.c_str())).arg(QString::fromUtf8(pd.location.c_str())); + if(pd.netMode == RS_NETMODE_HIDDEN) + hiddenmode = true; } - + setWindowTitle(tr("RetroShare %1 a secure decentralized communication platform").arg(Rshare::retroshareVersion(true)) + " - " + nameAndLocation); connect(rApp, SIGNAL(newArgsReceived(QStringList)), this, SLOT(receiveNewArgs(QStringList))); @@ -241,13 +244,17 @@ MainWindow::MainWindow(QWidget* parent, Qt::WindowFlags flags) statusBar()->addWidget(peerstatus); natstatus = new NATStatus(); - natstatus->setVisible(Settings->valueFromGroup("StatusBar", "ShowNAT", QVariant(true)).toBool()); + if(hiddenmode) natstatus->setVisible(false); + else natstatus->setVisible(Settings->valueFromGroup("StatusBar", "ShowNAT", QVariant(true)).toBool()); statusBar()->addWidget(natstatus); - + natstatus->getNATStatus(); + dhtstatus = new DHTStatus(); - dhtstatus->setVisible(Settings->valueFromGroup("StatusBar", "ShowDHT", QVariant(true)).toBool()); + if(hiddenmode) dhtstatus->setVisible(false); + else dhtstatus->setVisible(Settings->valueFromGroup("StatusBar", "ShowDHT", QVariant(true)).toBool()); statusBar()->addWidget(dhtstatus); - + dhtstatus->getDHTStatus(); + hashingstatus = new HashingStatus(); hashingstatus->setVisible(Settings->valueFromGroup("StatusBar", "ShowHashing", QVariant(true)).toBool()); statusBar()->addPermanentWidget(hashingstatus, 1); @@ -702,11 +709,14 @@ void MainWindow::updateStatus() if (ratesstatus) ratesstatus->getRatesStatus(downKb, upKb); + if(!hiddenmode) + { if (natstatus) natstatus->getNATStatus(); if (dhtstatus) dhtstatus->getDHTStatus(); + } if (discstatus) { discstatus->update(); @@ -1576,10 +1586,13 @@ void MainWindow::setCompactStatusMode(bool compact) //statusComboBox: TODO Show only icon peerstatus->setCompactMode(compact); updateFriends(); + if(!hiddenmode) + { natstatus->setCompactMode(compact); natstatus->getNATStatus(); dhtstatus->setCompactMode(compact); dhtstatus->getDHTStatus(); + } hashingstatus->setCompactMode(compact); ratesstatus->setCompactMode(compact); //opModeStatus: TODO Show only ??? diff --git a/retroshare-gui/src/gui/MainWindow.h b/retroshare-gui/src/gui/MainWindow.h index 0297690ae..b3fc246dc 100644 --- a/retroshare-gui/src/gui/MainWindow.h +++ b/retroshare-gui/src/gui/MainWindow.h @@ -184,6 +184,8 @@ public: ToasterDisable *toasterDisableInstance(); SysTrayStatus *sysTrayStatusInstance(); + static bool hiddenmode; + public slots: void receiveNewArgs(QStringList args); void displayErrorMessage(int,int,const QString&) ; diff --git a/retroshare-gui/src/gui/settings/AppearancePage.cpp b/retroshare-gui/src/gui/settings/AppearancePage.cpp index e5e742c72..5ffa7e10a 100755 --- a/retroshare-gui/src/gui/settings/AppearancePage.cpp +++ b/retroshare-gui/src/gui/settings/AppearancePage.cpp @@ -301,8 +301,15 @@ void AppearancePage::load() whileBlocking(ui.checkBoxDisableSysTrayToolTip)->setChecked(Settings->valueFromGroup("StatusBar", "DisableSysTrayToolTip", QVariant(false)).toBool()); whileBlocking(ui.checkBoxShowStatusStatus)-> setChecked(Settings->valueFromGroup("StatusBar", "ShowStatus", QVariant(true)).toBool()); whileBlocking(ui.checkBoxShowPeerStatus)-> setChecked(Settings->valueFromGroup("StatusBar", "ShowPeer", QVariant(true)).toBool()); - whileBlocking(ui.checkBoxShowNATStatus)-> setChecked(Settings->valueFromGroup("StatusBar", "ShowNAT", QVariant(true)).toBool()); - whileBlocking(ui.checkBoxShowDHTStatus)-> setChecked(Settings->valueFromGroup("StatusBar", "ShowDHT", QVariant(true)).toBool()); + if(MainWindow::hiddenmode) { + whileBlocking(ui.checkBoxShowNATStatus)-> setChecked(0); + whileBlocking(ui.checkBoxShowDHTStatus)-> setChecked(0); + ui.checkBoxShowNATStatus->setVisible(false); + ui.checkBoxShowDHTStatus->setVisible(false); + } else { + whileBlocking(ui.checkBoxShowNATStatus)-> setChecked(Settings->valueFromGroup("StatusBar", "ShowNAT", QVariant(true)).toBool()); + whileBlocking(ui.checkBoxShowDHTStatus)-> setChecked(Settings->valueFromGroup("StatusBar", "ShowDHT", QVariant(true)).toBool()); + } whileBlocking(ui.checkBoxShowHashingStatus)-> setChecked(Settings->valueFromGroup("StatusBar", "ShowHashing", QVariant(true)).toBool()); whileBlocking(ui.checkBoxShowDiscStatus)-> setChecked(Settings->valueFromGroup("StatusBar", "ShowDisc", QVariant(true)).toBool()); whileBlocking(ui.checkBoxShowRateStatus)-> setChecked(Settings->valueFromGroup("StatusBar", "ShowRate", QVariant(true)).toBool()); diff --git a/retroshare-gui/src/gui/settings/ServerPage.cpp b/retroshare-gui/src/gui/settings/ServerPage.cpp index ae7411c4f..9ff71dcb5 100755 --- a/retroshare-gui/src/gui/settings/ServerPage.cpp +++ b/retroshare-gui/src/gui/settings/ServerPage.cpp @@ -303,7 +303,8 @@ void ServerPage::load() if (mIsHiddenNode) { mHiddenType = detail.hiddenType; - ui.tabWidget->setTabEnabled(1,false) ; + ui.tabWidget->setTabEnabled(1,false) ; // ip filter + ui.tabWidget->setTabEnabled(3,false) ; // relay loadHiddenNode(); return; } @@ -1004,10 +1005,24 @@ void ServerPage::loadHiddenNode() ui.iconlabel_upnp->hide(); ui.label_nat->hide(); + ui.label_warningBandwidth->hide(); + ui.iconlabel_netLimited->hide(); + ui.textlabel_netLimited->hide(); + ui.iconlabel_ext->hide(); + ui.textlabel_ext->hide(); + ui.extPortLabel->hide(); + + ui.ipAddressLabel->hide(); + ui.cleanKnownIPs_PB->hide(); + + ui.ipAddressList->hide(); + ui.allowIpDeterminationCB->hide(); + ui.IPServersLV->hide(); + ui.textlabel_hiddenMode->show(); ui.iconlabel_hiddenMode->show() ; ui.iconlabel_hiddenMode->setPixmap(QPixmap(":/images/ledon1.png")); - + // CHANGE OPTIONS ON whileBlocking(ui.discComboBox)->removeItem(3); whileBlocking(ui.discComboBox)->removeItem(2); diff --git a/retroshare-gui/src/gui/settings/ServerPage.ui b/retroshare-gui/src/gui/settings/ServerPage.ui index 0adb576c6..6ff4723ab 100755 --- a/retroshare-gui/src/gui/settings/ServerPage.ui +++ b/retroshare-gui/src/gui/settings/ServerPage.ui @@ -831,7 +831,7 @@ behind a firewall or a VPN. - <html><head/><body><p>Outgoing Connctions</p><p>Configure your Tor and I2P SOCKS proxy here. <br/>If you prefer to use BOB to automatically manage I2P check the other tab.</p></body></html> + <html><head/><body><p>Configure your Tor and I2P SOCKS proxy here. <br/>If you prefer to use BOB to automatically manage I2P check the other tab.</p></body></html> @@ -1475,7 +1475,7 @@ You can connect to Hidden Nodes, even if you are running a standard Node, so why - <html><head/><body><p>Incoming Connection</p><p>Setup your hidden address (and port if needed)</p></body></html> + <html><head/><body><p>Setup your hidden address (and port if needed)</p></body></html> diff --git a/retroshare-gui/src/gui/statistics/StatisticsWindow.cpp b/retroshare-gui/src/gui/statistics/StatisticsWindow.cpp index 597cf6320..d4abdc4f3 100644 --- a/retroshare-gui/src/gui/statistics/StatisticsWindow.cpp +++ b/retroshare-gui/src/gui/statistics/StatisticsWindow.cpp @@ -98,7 +98,6 @@ StatisticsWindow::StatisticsWindow(QWidget *parent) : initStackedPage(); connect(ui->stackPages, SIGNAL(currentChanged(int)), this, SLOT(setNewPage(int))); ui->stackPages->setCurrentIndex(0); - int toolSize = Settings->getToolButtonSize(); ui->toolBar->setToolButtonStyle(Settings->getToolButtonStyle()); ui->toolBar->setIconSize(QSize(toolSize,toolSize)); @@ -147,9 +146,19 @@ void StatisticsWindow::initStackedPage() ui->stackPages->add(rttdlg = new RttStatistics(ui->stackPages), action = createPageAction(QIcon(IMAGE_RTT), tr("RTT Statistics"), grp)); - ui->stackPages->add(dhtw = new DhtWindow(ui->stackPages), + bool showdht = true; + RsPeerDetails detail; + if (rsPeers->getPeerDetails(rsPeers->getOwnId(), detail)) + { + if(detail.netMode == RS_NETMODE_HIDDEN) + showdht = false; + } + if(showdht) + { + ui->stackPages->add(dhtw = new DhtWindow(ui->stackPages), action = createPageAction(QIcon(IMAGE_DHT), tr("DHT"), grp)); - + } + /*std::cerr << "Looking for interfaces in existing plugins:" << std::endl; for(int i = 0;inbPlugins();++i) {