added Network Status to DhtWindow.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-netupgrade@4436 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2011-07-12 14:17:06 +00:00
parent 6c5d5f6cc2
commit 42dd1826b0

View File

@ -32,6 +32,7 @@
#include "gui/RsAutoUpdatePage.h" #include "gui/RsAutoUpdatePage.h"
#include "retroshare/rsdht.h" #include "retroshare/rsdht.h"
#include "retroshare/rsconfig.h"
#include "retroshare/rspeers.h" #include "retroshare/rspeers.h"
/********************************************** STATIC WINDOW *************************************/ /********************************************** STATIC WINDOW *************************************/
@ -158,136 +159,142 @@ void DhtWindow::updateNetStatus()
{ {
ui->peerAddressLabel->setText(status); ui->peerAddressLabel->setText(status);
} }
#endif
uint32_t netMode = mPeerNet->getNetStateNetworkMode(); uint32_t netMode = rsConfig->getNetworkMode();
QLabel *label = ui->networkLabel; QLabel *label = ui->networkLabel;
switch(netMode) switch(netMode)
{ {
case PNSB_NETWORK_UNKNOWN: case RSNET_NETWORK_UNKNOWN:
label->setText("Unknown NetState"); label->setText("Unknown NetState");
break; break;
case PNSB_NETWORK_OFFLINE: case RSNET_NETWORK_OFFLINE:
label->setText("Offline"); label->setText("Offline");
break; break;
case PNSB_NETWORK_LOCALNET: case RSNET_NETWORK_LOCALNET:
label->setText("Local Net"); label->setText("Local Net");
break; break;
case PNSB_NETWORK_BEHINDNAT: case RSNET_NETWORK_BEHINDNAT:
label->setText("Behind NAT"); label->setText("Behind NAT");
break; break;
case PNSB_NETWORK_EXTERNALIP: case RSNET_NETWORK_EXTERNALIP:
label->setText("External IP"); label->setText("External IP");
break; break;
} }
label = ui->natTypeLabel; label = ui->natTypeLabel;
switch(mPeerNet->getNetStateNatTypeMode())
uint32_t natType = rsConfig->getNatTypeMode();
switch(natType)
{ {
case PNSB_NATTYPE_UNKNOWN: case RSNET_NATTYPE_UNKNOWN:
label->setText("UNKNOWN NAT STATE"); label->setText("UNKNOWN NAT STATE");
break; break;
case PNSB_NATTYPE_SYMMETRIC: case RSNET_NATTYPE_SYMMETRIC:
label->setText("SYMMETRIC NAT"); label->setText("SYMMETRIC NAT");
break; break;
case PNSB_NATTYPE_RESTRICTED_CONE: case RSNET_NATTYPE_RESTRICTED_CONE:
label->setText("RESTRICTED CONE NAT"); label->setText("RESTRICTED CONE NAT");
break; break;
case PNSB_NATTYPE_FULL_CONE: case RSNET_NATTYPE_FULL_CONE:
label->setText("FULL CONE NAT"); label->setText("FULL CONE NAT");
break; break;
case PNSB_NATTYPE_OTHER: case RSNET_NATTYPE_OTHER:
label->setText("OTHER NAT"); label->setText("OTHER NAT");
break; break;
case PNSB_NATTYPE_NONE: case RSNET_NATTYPE_NONE:
label->setText("NO NAT"); label->setText("NO NAT");
break; break;
} }
label = ui->natHoleLabel; label = ui->natHoleLabel;
switch(mPeerNet->getNetStateNatHoleMode()) uint32_t natHole = rsConfig->getNatHoleMode();
switch(natHole)
{ {
case PNSB_NATHOLE_UNKNOWN: case RSNET_NATHOLE_UNKNOWN:
label->setText("UNKNOWN NAT HOLE STATUS"); label->setText("UNKNOWN NAT HOLE STATUS");
break; break;
case PNSB_NATHOLE_NONE: case RSNET_NATHOLE_NONE:
label->setText("NO NAT HOLE"); label->setText("NO NAT HOLE");
break; break;
case PNSB_NATHOLE_UPNP: case RSNET_NATHOLE_UPNP:
label->setText("UPNP FORWARD"); label->setText("UPNP FORWARD");
break; break;
case PNSB_NATHOLE_NATPMP: case RSNET_NATHOLE_NATPMP:
label->setText("NATPMP FORWARD"); label->setText("NATPMP FORWARD");
break; break;
case PNSB_NATHOLE_FORWARDED: case RSNET_NATHOLE_FORWARDED:
label->setText("MANUAL FORWARD"); label->setText("MANUAL FORWARD");
break; break;
} }
uint32_t connect = rsConfig->getConnectModes();
label = ui->connectLabel; label = ui->connectLabel;
std::ostringstream connOut; std::ostringstream connOut;
uint32_t connect = mPeerNet->getNetStateConnectModes(); if (connect & RSNET_CONNECT_OUTGOING_TCP)
if (connect & PNSB_CONNECT_OUTGOING_TCP)
{ {
connOut << "TCP_OUT "; connOut << "TCP_OUT ";
} }
if (connect & PNSB_CONNECT_ACCEPT_TCP) if (connect & RSNET_CONNECT_ACCEPT_TCP)
{ {
connOut << "TCP_IN "; connOut << "TCP_IN ";
} }
if (connect & PNSB_CONNECT_DIRECT_UDP) if (connect & RSNET_CONNECT_DIRECT_UDP)
{ {
connOut << "DIRECT_UDP "; connOut << "DIRECT_UDP ";
} }
if (connect & PNSB_CONNECT_PROXY_UDP) if (connect & RSNET_CONNECT_PROXY_UDP)
{ {
connOut << "PROXY_UDP "; connOut << "PROXY_UDP ";
} }
if (connect & PNSB_CONNECT_RELAY_UDP) if (connect & RSNET_CONNECT_RELAY_UDP)
{ {
connOut << "RELAY_UDP "; connOut << "RELAY_UDP ";
} }
label->setText(QString::fromStdString(connOut.str())); label->setText(QString::fromStdString(connOut.str()));
uint32_t netState = rsConfig->getNetState();
label = ui->netStatusLabel; label = ui->netStatusLabel;
switch(mPeerNet->getNetStateNetStateMode()) switch(netState)
{ {
case PNSB_NETSTATE_BAD_UNKNOWN: case RSNET_NETSTATE_BAD_UNKNOWN:
label->setText("NET BAD: Unknown State"); label->setText("NET BAD: Unknown State");
break; break;
case PNSB_NETSTATE_BAD_OFFLINE: case RSNET_NETSTATE_BAD_OFFLINE:
label->setText("NET BAD: Offline"); label->setText("NET BAD: Offline");
break; break;
case PNSB_NETSTATE_BAD_NATSYM: case RSNET_NETSTATE_BAD_NATSYM:
label->setText("NET BAD: Behind Symmetric NAT"); label->setText("NET BAD: Behind Symmetric NAT");
break; break;
case PNSB_NETSTATE_BAD_NODHT_NAT: case RSNET_NETSTATE_BAD_NODHT_NAT:
label->setText("NET BAD: Behind NAT & No DHT"); label->setText("NET BAD: Behind NAT & No DHT");
break; break;
case PNSB_NETSTATE_WARNING_RESTART: case RSNET_NETSTATE_WARNING_RESTART:
label->setText("NET WARNING: NET Restart"); label->setText("NET WARNING: NET Restart");
break; break;
case PNSB_NETSTATE_WARNING_NATTED: case RSNET_NETSTATE_WARNING_NATTED:
label->setText("NET WARNING: Behind NAT"); label->setText("NET WARNING: Behind NAT");
break; break;
case PNSB_NETSTATE_WARNING_NODHT: case RSNET_NETSTATE_WARNING_NODHT:
label->setText("NET WARNING: No DHT"); label->setText("NET WARNING: No DHT");
break; break;
case PNSB_NETSTATE_GOOD: case RSNET_NETSTATE_GOOD:
label->setText("NET STATE GOOD!"); label->setText("NET STATE GOOD!");
break; break;
case PNSB_NETSTATE_ADV_FORWARD: case RSNET_NETSTATE_ADV_FORWARD:
label->setText("CAUTION: UNVERIFABLE FORWARD!"); label->setText("CAUTION: UNVERIFABLE FORWARD!");
break; break;
case PNSB_NETSTATE_ADV_DARK_FORWARD: case RSNET_NETSTATE_ADV_DARK_FORWARD:
label->setText("CAUTION: UNVERIFABLE FORWARD & NO DHT"); label->setText("CAUTION: UNVERIFABLE FORWARD & NO DHT");
break; break;
} }
#endif
} }
void DhtWindow::updateNetPeers() void DhtWindow::updateNetPeers()