mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-27 00:19:25 -05:00
convert RSDHT_PEERCONN_ to enum class
This commit is contained in:
parent
8d0a352b53
commit
fcaabb1922
@ -58,7 +58,7 @@ class DhtPeerDetails
|
||||
PeerConnectStateBox mConnectLogic;
|
||||
|
||||
/* Actual Connection Status */
|
||||
uint32_t mPeerConnectState; // One of RSDHT_PEERCONN_
|
||||
RsDhtPeerConnectState mPeerConnectState;
|
||||
std::string mPeerConnectMsg;
|
||||
uint32_t mPeerConnectMode;
|
||||
bdId mPeerConnectPeerId;
|
||||
|
@ -262,7 +262,7 @@ int p3BitDht::OnlinePeerCallback_locked(const bdId *id, uint32_t /*status*/, Dht
|
||||
/* remove unused parameter warnings */
|
||||
(void) id;
|
||||
|
||||
if ((dpd->mPeerConnectState != RSDHT_PEERCONN_DISCONNECTED) ||
|
||||
if ((dpd->mPeerConnectState != RsDhtPeerConnectState::DISCONNECTED) ||
|
||||
(dpd->mPeerReqState == RSDHT_PEERREQ_RUNNING))
|
||||
{
|
||||
|
||||
@ -367,7 +367,7 @@ int p3BitDht::OnlinePeerCallback_locked(const bdId *id, uint32_t /*status*/, Dht
|
||||
int p3BitDht::UnreachablePeerCallback_locked(const bdId *id, uint32_t /*status*/, DhtPeerDetails *dpd)
|
||||
{
|
||||
|
||||
if ((dpd->mPeerConnectState != RSDHT_PEERCONN_DISCONNECTED) ||
|
||||
if ((dpd->mPeerConnectState != RsDhtPeerConnectState::DISCONNECTED) ||
|
||||
(dpd->mPeerReqState == RSDHT_PEERREQ_RUNNING))
|
||||
{
|
||||
|
||||
@ -1765,7 +1765,7 @@ int p3BitDht::checkConnectionAllowed(const bdId *peerId, int mode)
|
||||
it->second.mPeerCbMsg = "Denied Non-Friend";
|
||||
|
||||
it->second.mPeerConnectMsg = "Denied Non-Friend";
|
||||
it->second.mPeerConnectState = RSDHT_PEERCONN_DISCONNECTED;
|
||||
it->second.mPeerConnectState = RsDhtPeerConnectState::DISCONNECTED;
|
||||
|
||||
|
||||
return 0;
|
||||
@ -1774,7 +1774,7 @@ int p3BitDht::checkConnectionAllowed(const bdId *peerId, int mode)
|
||||
|
||||
/* are a friend */
|
||||
|
||||
if (dpd->mPeerConnectState == RSDHT_PEERCONN_CONNECTED)
|
||||
if (dpd->mPeerConnectState == RsDhtPeerConnectState::CONNECTED)
|
||||
{
|
||||
std::cerr << "p3BitDht::checkConnectionAllowed() ERROR Peer Already Connected, DENIED";
|
||||
std::cerr << std::endl;
|
||||
@ -1988,7 +1988,7 @@ void p3BitDht::initiateConnection(const bdId *srcId, const bdId *proxyId, const
|
||||
return;
|
||||
}
|
||||
|
||||
if (dpd->mPeerConnectState != RSDHT_PEERCONN_DISCONNECTED)
|
||||
if (dpd->mPeerConnectState != RsDhtPeerConnectState::DISCONNECTED)
|
||||
{
|
||||
std::cerr << "p3BitDht::initiateConnection() ERROR Peer is not Disconnected";
|
||||
std::cerr << std::endl;
|
||||
@ -2047,7 +2047,7 @@ void p3BitDht::initiateConnection(const bdId *srcId, const bdId *proxyId, const
|
||||
|
||||
/* store results in Status */
|
||||
dpd->mPeerConnectMsg = "UDP started";
|
||||
dpd->mPeerConnectState = RSDHT_PEERCONN_UDP_STARTED;
|
||||
dpd->mPeerConnectState = RsDhtPeerConnectState::UDP_STARTED;
|
||||
dpd->mPeerConnectUdpTS = time(NULL);
|
||||
dpd->mPeerConnectMode = mode;
|
||||
dpd->mPeerConnectPoint = loc;
|
||||
@ -2183,7 +2183,7 @@ void p3BitDht::monitorConnections()
|
||||
continue;
|
||||
}
|
||||
|
||||
if (it->second.mPeerConnectState == RSDHT_PEERCONN_UDP_STARTED)
|
||||
if (it->second.mPeerConnectState == RsDhtPeerConnectState::UDP_STARTED)
|
||||
{
|
||||
#ifdef DEBUG_PEERNET
|
||||
std::cerr << "p3BitDht::monitorConnections() Connection in progress to: ";
|
||||
@ -2225,7 +2225,7 @@ void p3BitDht::Feedback_Connected(const RsPeerId& pid)
|
||||
}
|
||||
|
||||
/* sanity checking */
|
||||
if (dpd->mPeerConnectState != RSDHT_PEERCONN_UDP_STARTED)
|
||||
if (dpd->mPeerConnectState != RsDhtPeerConnectState::UDP_STARTED)
|
||||
{
|
||||
/* ERROR */
|
||||
std::cerr << "p3BitDht::Feedback_Connected() ERROR not in UDP_STARTED mode for: ";
|
||||
@ -2242,7 +2242,7 @@ void p3BitDht::Feedback_Connected(const RsPeerId& pid)
|
||||
#endif
|
||||
|
||||
/* switch state! */
|
||||
dpd->mPeerConnectState = RSDHT_PEERCONN_CONNECTED;
|
||||
dpd->mPeerConnectState = RsDhtPeerConnectState::CONNECTED;
|
||||
dpd->mPeerConnectTS = time(NULL);
|
||||
|
||||
dpd->mConnectLogic.updateCb(CSB_UPDATE_CONNECTED);
|
||||
@ -2334,7 +2334,7 @@ void p3BitDht::Feedback_ConnectionClosed(const RsPeerId& pid)
|
||||
|
||||
void p3BitDht::UdpConnectionFailed_locked(DhtPeerDetails *dpd)
|
||||
{
|
||||
if (dpd->mPeerConnectState == RSDHT_PEERCONN_UDP_STARTED)
|
||||
if (dpd->mPeerConnectState == RsDhtPeerConnectState::UDP_STARTED)
|
||||
{
|
||||
#ifdef DEBUG_PEERNET
|
||||
std::cerr << "p3BitDht::UdpConnectionFailed_locked() UDP Connection Failed: ";
|
||||
@ -2349,7 +2349,7 @@ void p3BitDht::UdpConnectionFailed_locked(DhtPeerDetails *dpd)
|
||||
{
|
||||
dpd->mConnectLogic.updateCb(CSB_UPDATE_FAILED_ATTEMPT);
|
||||
}
|
||||
dpd->mPeerConnectState = RSDHT_PEERCONN_DISCONNECTED;
|
||||
dpd->mPeerConnectState = RsDhtPeerConnectState::DISCONNECTED;
|
||||
dpd->mPeerConnectMsg = "UDP Failed";
|
||||
|
||||
}
|
||||
@ -2363,7 +2363,7 @@ void p3BitDht::UdpConnectionFailed_locked(DhtPeerDetails *dpd)
|
||||
|
||||
dpd->mConnectLogic.updateCb(CSB_UPDATE_DISCONNECTED);
|
||||
|
||||
dpd->mPeerConnectState = RSDHT_PEERCONN_DISCONNECTED;
|
||||
dpd->mPeerConnectState = RsDhtPeerConnectState::DISCONNECTED;
|
||||
dpd->mPeerConnectClosedTS = time(NULL);
|
||||
rs_sprintf(dpd->mPeerConnectMsg, "Closed, Alive for: %ld secs", dpd->mPeerConnectClosedTS - dpd->mPeerConnectTS);
|
||||
}
|
||||
|
@ -737,7 +737,7 @@ DhtPeerDetails::DhtPeerDetails()
|
||||
//mPeerCbDestId = 0;
|
||||
mPeerCbTS = 0;
|
||||
|
||||
mPeerConnectState = RSDHT_PEERCONN_DISCONNECTED;
|
||||
mPeerConnectState = RsDhtPeerConnectState::DISCONNECTED;
|
||||
mPeerConnectMsg = "Disconnected";
|
||||
mPeerConnectMode = 0;
|
||||
//dpd->mPeerConnectProxyId;
|
||||
|
@ -54,9 +54,12 @@ enum class RsDhtPeerDht : uint8_t
|
||||
ONLINE = 5
|
||||
};
|
||||
|
||||
#define RSDHT_PEERCONN_DISCONNECTED 1
|
||||
#define RSDHT_PEERCONN_UDP_STARTED 2
|
||||
#define RSDHT_PEERCONN_CONNECTED 3
|
||||
enum class RsDhtPeerConnectState : uint8_t
|
||||
{
|
||||
DISCONNECTED = 1,
|
||||
UDP_STARTED = 2,
|
||||
CONNECTED = 3
|
||||
};
|
||||
|
||||
#define RSDHT_PEERREQ_STOPPED 1
|
||||
#define RSDHT_PEERREQ_RUNNING 2
|
||||
@ -113,7 +116,7 @@ class RsDhtNetPeer
|
||||
|
||||
std::string mConnectState; // connectLogic.
|
||||
|
||||
uint32_t mPeerConnectState; // connect Status
|
||||
RsDhtPeerConnectState mPeerConnectState; // connect Status
|
||||
uint32_t mPeerConnectMode; // connect mode
|
||||
bool mExclusiveProxyLock;
|
||||
|
||||
|
@ -430,14 +430,14 @@ void DhtWindow::updateNetPeers()
|
||||
switch(status.mPeerConnectState)
|
||||
{
|
||||
default:
|
||||
case RSDHT_PEERCONN_DISCONNECTED:
|
||||
case RsDhtPeerConnectState::DISCONNECTED:
|
||||
cpsstr = tr("Disconnected");
|
||||
++nDisconnPeers;
|
||||
break;
|
||||
case RSDHT_PEERCONN_UDP_STARTED:
|
||||
case RsDhtPeerConnectState::UDP_STARTED:
|
||||
cpsstr = tr("Udp Started");
|
||||
break;
|
||||
case RSDHT_PEERCONN_CONNECTED:
|
||||
case RsDhtPeerConnectState::CONNECTED:
|
||||
{
|
||||
cpsstr = tr("Connected");
|
||||
|
||||
@ -460,7 +460,7 @@ void DhtWindow::updateNetPeers()
|
||||
|
||||
peer_item -> setData(PTW_COL_PEER_CONNECT_STATUS, Qt::DisplayRole, cpsstr);
|
||||
|
||||
if (status.mPeerConnectState == RSDHT_PEERCONN_DISCONNECTED)
|
||||
if (status.mPeerConnectState == RsDhtPeerConnectState::DISCONNECTED)
|
||||
{
|
||||
peer_item -> setData(PTW_COL_PEER_CONNECT_MODE, Qt::DisplayRole, "");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user