mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-02 06:06:10 -04:00
Moved strings of RsPeerDetails::autoconnect for translation to the GUI side and added integer constants for it.
Fixed sorting of available friends in MessengerWindow. Recompile of the GUI needed. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3952 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
13ab90e14b
commit
dd55b2bf74
10 changed files with 313 additions and 196 deletions
|
@ -61,6 +61,15 @@ const uint32_t RS_PEER_STATE_ONLINE = 0x0002;
|
|||
const uint32_t RS_PEER_STATE_CONNECTED = 0x0004;
|
||||
const uint32_t RS_PEER_STATE_UNREACHABLE= 0x0008;
|
||||
|
||||
/* Connect state */
|
||||
const uint32_t RS_PEER_CONNECTSTATE_TRYING_TUNNEL = 1;
|
||||
const uint32_t RS_PEER_CONNECTSTATE_TRYING_TCP = 2;
|
||||
const uint32_t RS_PEER_CONNECTSTATE_TRYING_UDP = 3;
|
||||
const uint32_t RS_PEER_CONNECTSTATE_CONNECTED_TCP = 4;
|
||||
const uint32_t RS_PEER_CONNECTSTATE_CONNECTED_UDP = 5;
|
||||
const uint32_t RS_PEER_CONNECTSTATE_CONNECTED_TUNNEL = 6;
|
||||
const uint32_t RS_PEER_CONNECTSTATE_CONNECTED_UNKNOWN = 7;
|
||||
|
||||
/* Groups */
|
||||
#define RS_GROUP_ID_FRIENDS "Friends"
|
||||
#define RS_GROUP_ID_FAMILY "Family"
|
||||
|
@ -73,7 +82,6 @@ const uint32_t RS_GROUP_FLAG_STANDARD = 0x0001;
|
|||
/* A couple of helper functions for translating the numbers games */
|
||||
|
||||
std::string RsPeerTrustString(uint32_t trustLvl);
|
||||
std::string RsPeerStateString(uint32_t state);
|
||||
std::string RsPeerNetModeString(uint32_t netModel);
|
||||
std::string RsPeerLastConnectString(uint32_t lastConnect);
|
||||
|
||||
|
@ -86,9 +94,9 @@ class RsPeerDetails
|
|||
RsPeerDetails();
|
||||
|
||||
/* Auth details */
|
||||
bool isOnlyGPGdetail;
|
||||
bool isOnlyGPGdetail;
|
||||
std::string id;
|
||||
std::string gpg_id;
|
||||
std::string gpg_id;
|
||||
std::string name;
|
||||
std::string email;
|
||||
std::string location;
|
||||
|
@ -98,24 +106,24 @@ class RsPeerDetails
|
|||
|
||||
std::string fpr; /* pgp fingerprint */
|
||||
std::string authcode;
|
||||
std::list<std::string> gpgSigners;
|
||||
std::list<std::string> gpgSigners;
|
||||
|
||||
uint32_t trustLvl;
|
||||
uint32_t validLvl;
|
||||
|
||||
bool ownsign; /* we have signed the remote peer GPG key */
|
||||
bool hasSignedMe; /* the remote peer has signed my GPG key */
|
||||
bool ownsign; /* we have signed the remote peer GPG key */
|
||||
bool hasSignedMe; /* the remote peer has signed my GPG key */
|
||||
|
||||
bool accept_connection;
|
||||
bool accept_connection;
|
||||
|
||||
/* Network details (only valid if friend) */
|
||||
uint32_t state;
|
||||
|
||||
std::string localAddr;
|
||||
uint16_t localPort;
|
||||
std::string extAddr;
|
||||
uint16_t extPort;
|
||||
std::string dyndns;
|
||||
std::string localAddr;
|
||||
uint16_t localPort;
|
||||
std::string extAddr;
|
||||
uint16_t extPort;
|
||||
std::string dyndns;
|
||||
std::list<std::string> ipAddressList;
|
||||
|
||||
uint32_t netMode;
|
||||
|
@ -124,8 +132,10 @@ class RsPeerDetails
|
|||
|
||||
/* basic stats */
|
||||
uint32_t lastConnect; /* how long ago */
|
||||
std::string autoconnect;
|
||||
uint32_t connectPeriod;
|
||||
uint32_t connectState; /* RS_PEER_CONNECTSTATE_... */
|
||||
std::string connectStateString; /* Additional string like ip address */
|
||||
uint32_t connectPeriod;
|
||||
bool foundDHT;
|
||||
};
|
||||
|
||||
class RsGroupInfo
|
||||
|
|
|
@ -88,34 +88,6 @@ std::string RsPeerTrustString(uint32_t trustLvl)
|
|||
return str;
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::string RsPeerStateString(uint32_t state)
|
||||
{
|
||||
std::string str;
|
||||
if (state & RS_PEER_STATE_CONNECTED)
|
||||
{
|
||||
str = "Connected";
|
||||
}
|
||||
else if (state & RS_PEER_STATE_UNREACHABLE)
|
||||
{
|
||||
str = "Unreachable";
|
||||
}
|
||||
else if (state & RS_PEER_STATE_ONLINE)
|
||||
{
|
||||
str = "Available";
|
||||
}
|
||||
else if (state & RS_PEER_STATE_FRIEND)
|
||||
{
|
||||
str = "Offline";
|
||||
}
|
||||
else
|
||||
{
|
||||
str = "Neighbour";
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
std::string RsPeerNetModeString(uint32_t netModel)
|
||||
{
|
||||
std::string str;
|
||||
|
@ -337,10 +309,8 @@ bool p3Peers::getPeerDetails(const std::string &id, RsPeerDetails &d)
|
|||
d.ipAddressList.push_back("E:" + std::string(rs_inet_ntoa(it->mAddr.sin_addr)) + ":" + toto.str());
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Translate */
|
||||
|
||||
|
||||
d.state = 0;
|
||||
if (pcs.state & RS_PEER_S_FRIEND)
|
||||
d.state |= RS_PEER_STATE_FRIEND;
|
||||
|
@ -395,56 +365,49 @@ bool p3Peers::getPeerDetails(const std::string &id, RsPeerDetails &d)
|
|||
|
||||
|
||||
/* Finally determine AutoConnect Status */
|
||||
std::ostringstream autostr;
|
||||
d.foundDHT = pcs.dht.found;
|
||||
|
||||
d.connectState = 0;
|
||||
d.connectStateString.clear();
|
||||
|
||||
/* HACK to display DHT Status info too */
|
||||
if (pcs.dht.found)
|
||||
{
|
||||
autostr << "DHT:CONTACT!!! ";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!(pcs.state & RS_PEER_S_CONNECTED))
|
||||
{
|
||||
autostr << "DHT:SEARCHING ";
|
||||
}
|
||||
}
|
||||
|
||||
if (pcs.inConnAttempt)
|
||||
{
|
||||
if (pcs.currentConnAddrAttempt.type & RS_NET_CONN_TUNNEL) {
|
||||
autostr << "Trying tunnel connection";
|
||||
} else if (pcs.currentConnAddrAttempt.type & RS_NET_CONN_TCP_ALL) {
|
||||
autostr << "Trying TCP : " << rs_inet_ntoa(pcs.currentConnAddrAttempt.addr.sin_addr) << ":" << ntohs(pcs.currentConnAddrAttempt.addr.sin_port);
|
||||
} else if (pcs.currentConnAddrAttempt.type & RS_NET_CONN_UDP_ALL) {
|
||||
autostr << "Trying UDP : " << rs_inet_ntoa(pcs.currentConnAddrAttempt.addr.sin_addr) << ":" << ntohs(pcs.currentConnAddrAttempt.addr.sin_port);
|
||||
}
|
||||
if (pcs.currentConnAddrAttempt.type & RS_NET_CONN_TUNNEL) {
|
||||
d.connectState = RS_PEER_CONNECTSTATE_TRYING_TUNNEL;
|
||||
} else if (pcs.currentConnAddrAttempt.type & RS_NET_CONN_TCP_ALL) {
|
||||
d.connectState = RS_PEER_CONNECTSTATE_TRYING_TCP;
|
||||
|
||||
std::ostringstream str;
|
||||
str << rs_inet_ntoa(pcs.currentConnAddrAttempt.addr.sin_addr) << ":" << ntohs(pcs.currentConnAddrAttempt.addr.sin_port);
|
||||
d.connectStateString = str.str();
|
||||
} else if (pcs.currentConnAddrAttempt.type & RS_NET_CONN_UDP_ALL) {
|
||||
d.connectState = RS_PEER_CONNECTSTATE_TRYING_UDP;
|
||||
|
||||
std::ostringstream str;
|
||||
str << rs_inet_ntoa(pcs.currentConnAddrAttempt.addr.sin_addr) << ":" << ntohs(pcs.currentConnAddrAttempt.addr.sin_port);
|
||||
d.connectStateString = str.str();
|
||||
}
|
||||
}
|
||||
else if (pcs.state & RS_PEER_S_CONNECTED)
|
||||
{
|
||||
if (pcs.connecttype == RS_NET_CONN_TCP_ALL)
|
||||
{
|
||||
autostr << "Connected: TCP";
|
||||
d.connectState = RS_PEER_CONNECTSTATE_CONNECTED_TCP;
|
||||
}
|
||||
else if (pcs.connecttype == RS_NET_CONN_UDP_ALL)
|
||||
{
|
||||
autostr << "Connected: UDP";
|
||||
d.connectState = RS_PEER_CONNECTSTATE_CONNECTED_UDP;
|
||||
}
|
||||
else if (pcs.connecttype == RS_NET_CONN_TUNNEL)
|
||||
{
|
||||
autostr << "Connected: Tunnel";
|
||||
d.connectState = RS_PEER_CONNECTSTATE_CONNECTED_TUNNEL;
|
||||
}
|
||||
else
|
||||
{
|
||||
autostr << "Connected: Unknown";
|
||||
d.connectState = RS_PEER_CONNECTSTATE_CONNECTED_UNKNOWN;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
autostr << RsPeerStateString(pcs.state);
|
||||
}
|
||||
|
||||
d.autoconnect = autostr.str();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1314,7 +1277,7 @@ RsPeerDetails::RsPeerDetails()
|
|||
trustLvl(0), validLvl(0),ownsign(false),
|
||||
hasSignedMe(false),accept_connection(false),
|
||||
state(0),localAddr(""),localPort(0),extAddr(""),extPort(0),netMode(0),visState(0),
|
||||
lastConnect(0),autoconnect(""),connectPeriod(0)
|
||||
lastConnect(0),connectState(0),connectStateString(""),connectPeriod(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue