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
|
|
|
|
2010-08-06 05:40:23 -04:00
|
|
|
#include <retroshare/rsiface.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-09 14:35:34 -04:00
|
|
|
setLayout(hbox);
|
2009-05-01 08:45:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void NATStatus::getNATStatus()
|
|
|
|
{
|
|
|
|
rsiface->lockData(); /* Lock Interface */
|
|
|
|
|
|
|
|
/* now the extra bit .... switch on check boxes */
|
|
|
|
const RsConfig &config = rsiface->getConfig();
|
|
|
|
|
2009-10-29 20:36:33 -04:00
|
|
|
// if(config.netUpnpOk)
|
|
|
|
// {
|
|
|
|
// iconLabel->setPixmap(QPixmap::QPixmap(":/images/greenled.png"));
|
|
|
|
// iconLabel->setToolTip(tr("UPNP is active."));
|
|
|
|
// }
|
|
|
|
// else
|
|
|
|
// {
|
|
|
|
// iconLabel->setPixmap(QPixmap::QPixmap(":/images/yellowled.png"));
|
|
|
|
// iconLabel->setToolTip(tr("UPNP NOT FOUND."));
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// if(config.netExtOk)
|
|
|
|
// {
|
|
|
|
// iconLabel->setPixmap(QPixmap::QPixmap(":/images/greenled.png"));
|
|
|
|
// iconLabel->setToolTip(tr("Stable External IP Address"));
|
|
|
|
// }
|
|
|
|
// else
|
|
|
|
// {
|
|
|
|
// iconLabel->setPixmap(QPixmap::QPixmap(":/images/yellowled.png"));
|
|
|
|
// iconLabel->setToolTip(tr("Not Found External Address"));
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// if(config.netUdpOk)
|
|
|
|
// {
|
|
|
|
// iconLabel->setPixmap(QPixmap::QPixmap(":/images/yellowled.png"));
|
|
|
|
// iconLabel->setToolTip(tr("UDP Port is reachable"));
|
|
|
|
// }
|
|
|
|
// else
|
|
|
|
// {
|
|
|
|
// iconLabel->setPixmap(QPixmap::QPixmap(":/images/grayled.png"));
|
|
|
|
// iconLabel->setToolTip(tr("UDP Port is not reachable"));
|
|
|
|
// }
|
2009-05-01 08:45:27 -04:00
|
|
|
|
2009-10-29 20:41:24 -04:00
|
|
|
if (config.netUpnpOk)
|
2009-05-01 08:45:27 -04:00
|
|
|
{
|
2010-10-09 14:35:34 -04:00
|
|
|
iconLabel->setPixmap(QPixmap(":/images/greenled.png"));
|
|
|
|
iconLabel->setToolTip(tr("OK | RetroShare Server"));
|
2009-05-01 08:45:27 -04:00
|
|
|
}
|
2009-10-29 20:41:24 -04:00
|
|
|
else if (config.netStunOk || config.netExtraAddressOk)
|
2009-05-01 08:45:27 -04:00
|
|
|
{
|
2010-10-09 14:35:34 -04:00
|
|
|
iconLabel->setPixmap(QPixmap(":/images/greenled.png"));
|
|
|
|
iconLabel->setToolTip(tr("Internet connection"));
|
2009-10-29 20:41:24 -04:00
|
|
|
}
|
|
|
|
else if (config.netLocalOk)
|
|
|
|
{
|
2010-10-09 14:35:34 -04:00
|
|
|
iconLabel->setPixmap(QPixmap(":/images/grayled.png"));
|
|
|
|
iconLabel->setToolTip(tr("No internet connection"));
|
2009-05-01 08:45:27 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-10-09 14:35:34 -04:00
|
|
|
iconLabel->setPixmap(QPixmap(":/images/redled.png"));
|
|
|
|
iconLabel->setToolTip(tr("No local network"));
|
2009-05-01 08:45:27 -04:00
|
|
|
}
|
2010-10-09 14:35:34 -04:00
|
|
|
|
2009-05-01 08:45:27 -04:00
|
|
|
rsiface->unlockData(); /* UnLock Interface */
|
|
|
|
|
|
|
|
}
|