2009-05-01 08:45:27 -04:00
|
|
|
/****************************************************************
|
|
|
|
* RetroShare is distributed under the following license:
|
|
|
|
*
|
|
|
|
* Copyright (C) 2009 RetroShare Team
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
****************************************************************/
|
|
|
|
|
2010-10-09 14:35:34 -04:00
|
|
|
#include <QHBoxLayout>
|
2009-05-01 08:45:27 -04:00
|
|
|
#include <QLabel>
|
|
|
|
|
2010-07-23 14:52:58 -04:00
|
|
|
#include "natstatus.h"
|
2009-05-01 08:45:27 -04:00
|
|
|
|
2011-07-30 13:13:08 -04:00
|
|
|
#include "retroshare/rsiface.h"
|
|
|
|
#include "retroshare/rsconfig.h"
|
2009-05-01 08:45:27 -04:00
|
|
|
|
|
|
|
NATStatus::NATStatus(QWidget *parent)
|
|
|
|
: QWidget(parent)
|
|
|
|
{
|
2010-10-09 14:35:34 -04:00
|
|
|
QHBoxLayout *hbox = new QHBoxLayout(this);
|
2009-05-01 08:45:27 -04:00
|
|
|
hbox->setMargin(0);
|
|
|
|
hbox->setSpacing(6);
|
|
|
|
|
|
|
|
statusNAT = new QLabel( tr("<strong>NAT:</strong>"), this );
|
2010-10-09 14:35:34 -04:00
|
|
|
// statusDHT->setMinimumSize( statusPeers->frameSize().width() + 0, 0 );
|
2009-05-01 08:45:27 -04:00
|
|
|
hbox->addWidget(statusNAT);
|
|
|
|
|
2010-10-09 14:35:34 -04:00
|
|
|
iconLabel = new QLabel(this);
|
2010-06-14 07:57:22 -04:00
|
|
|
iconLabel->setPixmap(QPixmap(":/images/grayled.png"));
|
2009-05-01 08:45:27 -04:00
|
|
|
// iconLabel doesn't change over time, so we didn't need a minimum size
|
|
|
|
hbox->addWidget(iconLabel);
|
|
|
|
|
2010-10-31 20:03:05 -04:00
|
|
|
hbox->addSpacing(2);
|
|
|
|
|
2014-05-29 12:15:26 -04:00
|
|
|
_compactMode = false;
|
|
|
|
|
2010-10-09 14:35:34 -04:00
|
|
|
setLayout(hbox);
|
2009-05-01 08:45:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void NATStatus::getNATStatus()
|
|
|
|
{
|
2011-07-30 13:13:08 -04:00
|
|
|
uint32_t netState = rsConfig -> getNetState();
|
|
|
|
|
2014-05-29 12:15:26 -04:00
|
|
|
statusNAT->setVisible(!_compactMode);
|
|
|
|
QString text = _compactMode?statusNAT->text():"";
|
2015-06-30 12:44:58 -04:00
|
|
|
int S = QFontMetricsF(iconLabel->font()).height() ;
|
2014-05-29 12:15:26 -04:00
|
|
|
|
2011-07-30 13:13:08 -04:00
|
|
|
switch(netState)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
case RSNET_NETSTATE_BAD_UNKNOWN:
|
|
|
|
{
|
2015-06-30 12:44:58 -04:00
|
|
|
iconLabel->setPixmap(QPixmap(":/icons/bullet_yellow_64.png").scaledToHeight(S,Qt::SmoothTransformation)) ;
|
|
|
|
iconLabel->setToolTip( text + tr("Network Status Unknown")) ;
|
2011-07-30 13:13:08 -04:00
|
|
|
}
|
2014-05-29 12:15:26 -04:00
|
|
|
break ;
|
2011-07-30 13:13:08 -04:00
|
|
|
|
|
|
|
case RSNET_NETSTATE_BAD_OFFLINE:
|
|
|
|
{
|
2015-06-30 12:44:58 -04:00
|
|
|
iconLabel->setPixmap(QPixmap(":/icons/bullet_grey_64.png").scaledToHeight(S,Qt::SmoothTransformation)) ;
|
|
|
|
iconLabel->setToolTip( text + tr("Offline")) ;
|
2011-07-30 13:13:08 -04:00
|
|
|
}
|
2014-05-29 12:15:26 -04:00
|
|
|
break ;
|
2011-07-30 13:13:08 -04:00
|
|
|
|
|
|
|
// BAD. (RED)
|
|
|
|
case RSNET_NETSTATE_BAD_NATSYM:
|
|
|
|
{
|
2015-06-30 12:44:58 -04:00
|
|
|
iconLabel->setPixmap(QPixmap(":/icons/bullet_red_64.png").scaledToHeight(S,Qt::SmoothTransformation)) ;
|
|
|
|
iconLabel->setToolTip( text + tr("Nasty Firewall")) ;
|
2011-07-30 13:13:08 -04:00
|
|
|
}
|
2014-05-29 12:15:26 -04:00
|
|
|
break ;
|
2011-07-30 13:13:08 -04:00
|
|
|
|
|
|
|
case RSNET_NETSTATE_BAD_NODHT_NAT:
|
|
|
|
{
|
2015-06-30 12:44:58 -04:00
|
|
|
iconLabel->setPixmap(QPixmap(":/icons/bullet_red_64.png").scaledToHeight(S,Qt::SmoothTransformation)) ;
|
|
|
|
iconLabel->setToolTip( text + tr("DHT Disabled and Firewalled")) ;
|
2011-07-30 13:13:08 -04:00
|
|
|
}
|
2014-05-29 12:15:26 -04:00
|
|
|
break ;
|
2011-07-30 13:13:08 -04:00
|
|
|
|
|
|
|
// CAUTION. (ORANGE)
|
|
|
|
case RSNET_NETSTATE_WARNING_RESTART:
|
|
|
|
{
|
2015-06-30 12:44:58 -04:00
|
|
|
iconLabel->setPixmap(QPixmap(":/icons/bullet_yellow_64.png").scaledToHeight(S,Qt::SmoothTransformation)) ;
|
|
|
|
iconLabel->setToolTip( text + tr("Network Restarting")) ;
|
2011-07-30 13:13:08 -04:00
|
|
|
}
|
2014-05-29 12:15:26 -04:00
|
|
|
break ;
|
2011-07-30 13:13:08 -04:00
|
|
|
|
|
|
|
case RSNET_NETSTATE_WARNING_NATTED:
|
|
|
|
{
|
2015-06-30 12:44:58 -04:00
|
|
|
iconLabel->setPixmap(QPixmap(":/icons/bullet_yellow_64.png").scaledToHeight(S,Qt::SmoothTransformation)) ;
|
|
|
|
iconLabel->setToolTip( text + tr("Behind Firewall")) ;
|
2011-07-30 13:13:08 -04:00
|
|
|
}
|
2014-05-29 12:15:26 -04:00
|
|
|
break ;
|
2011-07-30 13:13:08 -04:00
|
|
|
|
|
|
|
case RSNET_NETSTATE_WARNING_NODHT:
|
|
|
|
{
|
2015-06-30 12:44:58 -04:00
|
|
|
iconLabel->setPixmap(QPixmap(":/icons/bullet_yellow_64.png").scaledToHeight(S,Qt::SmoothTransformation)) ;
|
2014-05-29 12:15:26 -04:00
|
|
|
iconLabel->setToolTip( text + tr("DHT Disabled")) ;
|
2011-07-30 13:13:08 -04:00
|
|
|
}
|
2014-05-29 12:15:26 -04:00
|
|
|
break ;
|
2011-07-30 13:13:08 -04:00
|
|
|
|
|
|
|
// GOOD (GREEN)
|
|
|
|
case RSNET_NETSTATE_GOOD:
|
|
|
|
{
|
2015-06-30 12:44:58 -04:00
|
|
|
iconLabel->setPixmap(QPixmap(":/icons/bullet_green_64.png").scaledToHeight(S,Qt::SmoothTransformation)) ;
|
2014-05-29 12:15:26 -04:00
|
|
|
iconLabel->setToolTip( text + tr("RetroShare Server")) ;
|
2011-08-02 15:07:22 -04:00
|
|
|
}
|
2014-05-29 12:15:26 -04:00
|
|
|
break ;
|
|
|
|
|
2011-08-02 15:07:22 -04:00
|
|
|
case RSNET_NETSTATE_ADV_FORWARD:
|
|
|
|
{
|
2015-06-30 12:44:58 -04:00
|
|
|
iconLabel->setPixmap(QPixmap(":/icons/bullet_green_64.png").scaledToHeight(S,Qt::SmoothTransformation)) ;
|
2014-05-29 12:15:26 -04:00
|
|
|
iconLabel->setToolTip( text + tr("Forwarded Port")) ;
|
2011-07-30 13:13:08 -04:00
|
|
|
}
|
2014-05-29 12:15:26 -04:00
|
|
|
break ;
|
2011-07-30 13:13:08 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|