Merge pull request #2324 from RetroPooh/torstatus

Torstatus icon fixed for no-auto mode plus i2p icon
This commit is contained in:
csoler 2021-02-15 22:04:00 +01:00 committed by GitHub
commit 20c34998b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 60 additions and 2 deletions

View File

@ -1232,6 +1232,8 @@ void MainWindow::toggleVisibility(QSystemTrayIcon::ActivationReason e)
}
raise();
activateWindow();
if(torstatus)
torstatus->reset();
} else {
hide();
}

View File

@ -243,6 +243,7 @@
<file>icons/no-tor.png</file>
<file>icons/tor-starting.png</file>
<file>icons/tor-stopping.png</file>
<file>icons/i2p-128.png</file>
<file>icons/user-away_64.png</file>
<file>icons/user-away-extended_64.png</file>
<file>icons/user-busy_64.png</file>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1010 B

View File

@ -27,6 +27,8 @@
#include "retroshare/rsconfig.h"
#include "retroshare/rsinit.h"
#include "retroshare/rspeers.h"
#include <QTcpSocket>
#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("<strong>" + tr("I2P") + ":</strong>");
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;
}
}
}

View File

@ -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;
};