diff --git a/retroshare-gui/src/gui/MainWindow.cpp b/retroshare-gui/src/gui/MainWindow.cpp index 28300d8b7..a4dbbe0fe 100644 --- a/retroshare-gui/src/gui/MainWindow.cpp +++ b/retroshare-gui/src/gui/MainWindow.cpp @@ -1232,6 +1232,8 @@ void MainWindow::toggleVisibility(QSystemTrayIcon::ActivationReason e) } raise(); activateWindow(); + if(torstatus) + torstatus->reset(); } else { hide(); } diff --git a/retroshare-gui/src/gui/icons.qrc b/retroshare-gui/src/gui/icons.qrc index 32c57e037..c9a4f33c8 100644 --- a/retroshare-gui/src/gui/icons.qrc +++ b/retroshare-gui/src/gui/icons.qrc @@ -243,6 +243,7 @@ icons/no-tor.png icons/tor-starting.png icons/tor-stopping.png + icons/i2p-128.png icons/user-away_64.png icons/user-away-extended_64.png icons/user-busy_64.png diff --git a/retroshare-gui/src/gui/icons/i2p-128.png b/retroshare-gui/src/gui/icons/i2p-128.png new file mode 100644 index 000000000..b052c6f4e Binary files /dev/null and b/retroshare-gui/src/gui/icons/i2p-128.png differ diff --git a/retroshare-gui/src/gui/statusbar/torstatus.cpp b/retroshare-gui/src/gui/statusbar/torstatus.cpp index 1b76f45c7..f046f09cc 100644 --- a/retroshare-gui/src/gui/statusbar/torstatus.cpp +++ b/retroshare-gui/src/gui/statusbar/torstatus.cpp @@ -27,6 +27,8 @@ #include "retroshare/rsconfig.h" #include "retroshare/rsinit.h" +#include "retroshare/rspeers.h" +#include #include "util/misc.h" #include "TorControl/TorManager.h" @@ -51,6 +53,7 @@ TorStatus::TorStatus(QWidget *parent) hbox->addWidget(torstatusLabel); _compactMode = false; + _updated = false; setLayout( hbox ); } @@ -135,7 +138,54 @@ void TorStatus::getTorStatus() } else { - torstatusLabel->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/icons/tor-stopping.png").scaledToHeight(S,Qt::SmoothTransformation)); - torstatusLabel->setToolTip( text + tr("Tor is currently offline")); + if(!_updated) + { + RsPeerDetails pd; + uint32_t hiddentype; + if (rsPeers->getPeerDetails(rsPeers->getOwnId(), pd)) { + if(pd.netMode == RS_NETMODE_HIDDEN) + { + hiddentype = pd.hiddenType; + } + } + std::string proxyaddr; + uint16_t proxyport; + uint32_t status ; + QTcpSocket socket ; + if(hiddentype == RS_HIDDEN_TYPE_TOR) + { + rsPeers->getProxyServer(RS_HIDDEN_TYPE_TOR, proxyaddr, proxyport, status); + socket.connectToHost(QString::fromStdString(proxyaddr),quint16(proxyport)); + if(socket.waitForConnected(500)) + { + socket.disconnectFromHost(); + torstatusLabel->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/icons/tor-on.png").scaledToHeight(S,Qt::SmoothTransformation)); + torstatusLabel->setToolTip( text + tr("Tor proxy is OK")); + } + else + { + torstatusLabel->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/icons/tor-off.png").scaledToHeight(S,Qt::SmoothTransformation)); + torstatusLabel->setToolTip( text + tr("Tor proxy is not available")); + } + } + if(hiddentype == RS_HIDDEN_TYPE_I2P) + { + statusTor->setText("" + tr("I2P") + ":"); + rsPeers->getProxyServer(RS_HIDDEN_TYPE_I2P, proxyaddr, proxyport, status); + socket.connectToHost(QString::fromStdString(proxyaddr),quint16(proxyport)); + if(socket.waitForConnected(500)) + { + socket.disconnectFromHost(); + torstatusLabel->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/icons/i2p-128.png").scaledToHeight(S,Qt::SmoothTransformation)); + torstatusLabel->setToolTip( text + tr("i2p proxy is OK")); + } + else + { + torstatusLabel->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/icons/tile_downloading_48.png").scaledToHeight(S,Qt::SmoothTransformation)); + torstatusLabel->setToolTip( text + tr("i2p proxy is not available")); + } + } + _updated = true; + } } } diff --git a/retroshare-gui/src/gui/statusbar/torstatus.h b/retroshare-gui/src/gui/statusbar/torstatus.h index 31c76a5ed..79314b142 100644 --- a/retroshare-gui/src/gui/statusbar/torstatus.h +++ b/retroshare-gui/src/gui/statusbar/torstatus.h @@ -32,9 +32,14 @@ public: void getTorStatus( ); void setCompactMode(bool compact) {_compactMode = compact; } + void reset() + { + _updated = false; + } private: QLabel *torstatusLabel, *statusTor; bool _compactMode; + bool _updated; };