2010-10-05 09:01:26 +00: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.
|
|
|
|
****************************************************************/
|
|
|
|
#include "dhtstatus.h"
|
|
|
|
|
|
|
|
#include <QLayout>
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QIcon>
|
|
|
|
#include <QPixmap>
|
|
|
|
|
2013-08-21 21:39:40 +00:00
|
|
|
#include "retroshare/rsconfig.h"
|
2010-10-27 12:49:46 +00:00
|
|
|
#include "retroshare/rspeers.h"
|
2010-10-05 09:01:26 +00:00
|
|
|
|
2010-11-08 12:25:49 +00:00
|
|
|
#include "util/misc.h"
|
|
|
|
|
2010-10-05 09:01:26 +00:00
|
|
|
#include <iomanip>
|
|
|
|
|
|
|
|
DHTStatus::DHTStatus(QWidget *parent)
|
|
|
|
: QWidget(parent)
|
|
|
|
{
|
|
|
|
QHBoxLayout *hbox = new QHBoxLayout();
|
|
|
|
hbox->setMargin(0);
|
|
|
|
hbox->setSpacing(6);
|
|
|
|
|
2010-11-01 00:03:05 +00:00
|
|
|
statusDHT = new QLabel("<strong>" + tr("DHT") + ":</strong>", this );
|
2010-10-05 09:01:26 +00:00
|
|
|
hbox->addWidget(statusDHT);
|
|
|
|
|
2010-10-27 12:49:46 +00:00
|
|
|
dhtstatusLabel = new QLabel( this );
|
|
|
|
dhtstatusLabel->setPixmap(QPixmap(":/images/grayled.png"));
|
|
|
|
hbox->addWidget(dhtstatusLabel);
|
|
|
|
|
2010-12-02 13:21:00 +00:00
|
|
|
spaceLabel = new QLabel( "|", this );
|
2010-11-08 12:25:49 +00:00
|
|
|
spaceLabel->setVisible(false);
|
2010-10-27 12:49:46 +00:00
|
|
|
hbox->addWidget(spaceLabel);
|
2010-11-08 12:25:49 +00:00
|
|
|
|
2010-10-27 12:49:46 +00:00
|
|
|
dhtnetworkLabel = new QLabel( this );
|
2010-11-08 12:25:49 +00:00
|
|
|
dhtnetworkLabel->setVisible(false);
|
2010-10-27 12:49:46 +00:00
|
|
|
dhtnetworkLabel->setPixmap(QPixmap(":/images/dht16.png"));
|
|
|
|
hbox->addWidget(dhtnetworkLabel);
|
2010-11-08 12:25:49 +00:00
|
|
|
|
2010-10-27 12:49:46 +00:00
|
|
|
dhtnetworksizeLabel = new QLabel( "0 (0) ",this );
|
2010-11-08 12:25:49 +00:00
|
|
|
dhtnetworksizeLabel->setVisible(false);
|
2010-10-27 12:49:46 +00:00
|
|
|
hbox->addWidget(dhtnetworksizeLabel);
|
2010-10-05 09:01:26 +00:00
|
|
|
|
2010-11-01 00:03:05 +00:00
|
|
|
hbox->addSpacing(2);
|
2010-10-05 09:01:26 +00:00
|
|
|
|
2010-11-01 00:03:05 +00:00
|
|
|
setLayout( hbox );
|
2010-10-05 09:01:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DHTStatus::getDHTStatus()
|
|
|
|
{
|
2011-07-30 17:13:08 +00:00
|
|
|
|
|
|
|
/* now the extra bit .... switch on check boxes */
|
2013-08-21 21:39:40 +00:00
|
|
|
RsConfigNetStatus config;
|
|
|
|
rsConfig->getConfigNetStatus(config);
|
2011-07-30 17:13:08 +00:00
|
|
|
|
|
|
|
if (!(config.DHTActive))
|
|
|
|
{
|
|
|
|
// GRAY.
|
|
|
|
dhtstatusLabel->setPixmap(QPixmap(":/images/grayled.png"));
|
|
|
|
dhtstatusLabel->setToolTip(tr("DHT Off"));
|
|
|
|
|
|
|
|
spaceLabel->setVisible(false);
|
|
|
|
dhtnetworkLabel->setVisible(false);
|
|
|
|
dhtnetworksizeLabel->setVisible(false);
|
|
|
|
|
|
|
|
dhtnetworksizeLabel->setText("");
|
|
|
|
dhtnetworksizeLabel->setToolTip("");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (config.netDhtOk)
|
|
|
|
{
|
|
|
|
#define MIN_RS_NET_SIZE 10
|
|
|
|
// YELLOW or GREEN.
|
|
|
|
if (config.netDhtRsNetSize < MIN_RS_NET_SIZE)
|
|
|
|
{
|
|
|
|
dhtstatusLabel->setPixmap(QPixmap(":/images/yellowled.png"));
|
2012-02-05 21:05:11 +00:00
|
|
|
dhtstatusLabel->setToolTip(tr("DHT Searching for RetroShare Peers"));
|
2011-07-30 17:13:08 +00:00
|
|
|
|
|
|
|
spaceLabel->setVisible(true);
|
|
|
|
dhtnetworkLabel->setVisible(true);
|
|
|
|
dhtnetworksizeLabel->setVisible(true);
|
|
|
|
|
|
|
|
dhtnetworksizeLabel->setText(QString("%1 (%2)").arg(misc::userFriendlyUnit(config.netDhtRsNetSize, 1)).arg(misc::userFriendlyUnit(config.netDhtNetSize, 1)));
|
|
|
|
dhtnetworksizeLabel->setToolTip(tr("RetroShare users in DHT (Total DHT users)") );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dhtstatusLabel->setPixmap(QPixmap(":/images/greenled.png"));
|
|
|
|
dhtstatusLabel->setToolTip(tr("DHT Good"));
|
|
|
|
|
|
|
|
spaceLabel->setVisible(true);
|
|
|
|
dhtnetworkLabel->setVisible(true);
|
|
|
|
dhtnetworksizeLabel->setVisible(true);
|
|
|
|
|
|
|
|
dhtnetworksizeLabel->setText(QString("%1 (%2)").arg(misc::userFriendlyUnit(config.netDhtRsNetSize, 1)).arg(misc::userFriendlyUnit(config.netDhtNetSize, 1)));
|
|
|
|
dhtnetworksizeLabel->setToolTip(tr("RetroShare users in DHT (Total DHT users)") );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// RED - some issue.
|
|
|
|
dhtstatusLabel->setPixmap(QPixmap(":/images/redled.png"));
|
|
|
|
dhtstatusLabel->setToolTip(tr("DHT Error"));
|
|
|
|
|
|
|
|
spaceLabel->setVisible(false);
|
|
|
|
dhtnetworkLabel->setVisible(false);
|
|
|
|
dhtnetworksizeLabel->setVisible(false);
|
|
|
|
|
|
|
|
dhtnetworksizeLabel->setText("");
|
|
|
|
dhtnetworksizeLabel->setToolTip("");
|
|
|
|
}
|
|
|
|
}
|
2010-10-05 09:01:26 +00:00
|
|
|
}
|