diff --git a/libretroshare/src/dht/p3bitdht.h b/libretroshare/src/dht/p3bitdht.h index 9a84bf51d..277054494 100644 --- a/libretroshare/src/dht/p3bitdht.h +++ b/libretroshare/src/dht/p3bitdht.h @@ -77,7 +77,7 @@ class DhtPeerDetails /* Connection Request Status */ std::string mPeerReqStatusMsg; - uint32_t mPeerReqState; + RsDhtPeerRequest mPeerReqState; uint32_t mPeerReqMode; bdId mPeerReqProxyId; rstime_t mPeerReqTS; diff --git a/libretroshare/src/dht/p3bitdht_peernet.cc b/libretroshare/src/dht/p3bitdht_peernet.cc index 12226584e..635a12bd8 100644 --- a/libretroshare/src/dht/p3bitdht_peernet.cc +++ b/libretroshare/src/dht/p3bitdht_peernet.cc @@ -263,7 +263,7 @@ int p3BitDht::OnlinePeerCallback_locked(const bdId *id, uint32_t /*status*/, Dht (void) id; if ((dpd->mPeerConnectState != RsDhtPeerConnectState::DISCONNECTED) || - (dpd->mPeerReqState == RSDHT_PEERREQ_RUNNING)) + (dpd->mPeerReqState == RsDhtPeerRequest::RUNNING)) { #ifdef DEBUG_PEERNET @@ -368,7 +368,7 @@ int p3BitDht::UnreachablePeerCallback_locked(const bdId *id, uint32_t /*status*/ { if ((dpd->mPeerConnectState != RsDhtPeerConnectState::DISCONNECTED) || - (dpd->mPeerReqState == RSDHT_PEERREQ_RUNNING)) + (dpd->mPeerReqState == RsDhtPeerRequest::RUNNING)) { #ifdef DEBUG_PEERNET @@ -989,7 +989,7 @@ int p3BitDht::ConnectCallback(const bdId *srcId, const bdId *proxyId, const bdId dpd->mPeerReqStatusMsg = "STOPPED: "; dpd->mPeerReqStatusMsg += decodeConnectionError(errcode); - dpd->mPeerReqState = RSDHT_PEERREQ_STOPPED; + dpd->mPeerReqState = RsDhtPeerRequest::STOPPED; dpd->mPeerReqTS = now; int updatecode = CSB_UPDATE_FAILED_ATTEMPT; @@ -1048,7 +1048,7 @@ int p3BitDht::ConnectCallback(const bdId *srcId, const bdId *proxyId, const bdId else // a new connection attempt. { dpd->mPeerReqStatusMsg = "Connect Attempt"; - dpd->mPeerReqState = RSDHT_PEERREQ_RUNNING; + dpd->mPeerReqState = RsDhtPeerRequest::RUNNING; dpd->mPeerReqMode = mode; dpd->mPeerReqProxyId = *proxyId; dpd->mPeerReqTS = now; @@ -1391,7 +1391,7 @@ int p3BitDht::doActions() if (dpd) { dpd->mPeerReqStatusMsg = "Connect Request"; - dpd->mPeerReqState = RSDHT_PEERREQ_RUNNING; + dpd->mPeerReqState = RsDhtPeerRequest::RUNNING; dpd->mPeerReqMode = action.mMode; dpd->mPeerReqTS = now; @@ -1434,7 +1434,7 @@ int p3BitDht::doActions() dpd->mConnectLogic.updateCb(failReason); dpd->mPeerReqStatusMsg = "Req Mode Unavailable"; - dpd->mPeerReqState = RSDHT_PEERREQ_STOPPED; + dpd->mPeerReqState = RsDhtPeerRequest::STOPPED; dpd->mPeerReqMode = action.mMode; dpd->mPeerReqTS = now; @@ -1756,7 +1756,7 @@ int p3BitDht::checkConnectionAllowed(const bdId *peerId, int mode) it->second.mPeerCbMsg = "Denied Non-Friend"; it->second.mPeerReqStatusMsg = "Denied Non-Friend"; - it->second.mPeerReqState = RSDHT_PEERREQ_STOPPED; + it->second.mPeerReqState = RsDhtPeerRequest::STOPPED; it->second.mPeerReqTS = now; it->second.mPeerReqMode = 0; //it->second.mPeerProxyId; @@ -2250,7 +2250,7 @@ void p3BitDht::Feedback_Connected(const RsPeerId& pid) rs_sprintf(dpd->mPeerConnectMsg, "Connected in %ld secs", dpd->mPeerConnectTS - dpd->mPeerConnectUdpTS); // Remove the Connection Request. - if (dpd->mPeerReqState == RSDHT_PEERREQ_RUNNING) + if (dpd->mPeerReqState == RsDhtPeerRequest::RUNNING) { #ifdef DEBUG_PEERNET std::cerr << "p3BitDht::monitorConnections() Request Active, Stopping Request"; @@ -2345,7 +2345,7 @@ void p3BitDht::UdpConnectionFailed_locked(DhtPeerDetails *dpd) /* shut it down */ /* ONLY need to update ConnectLogic - if it was our Attempt Running */ - if (dpd->mPeerReqState == RSDHT_PEERREQ_RUNNING) + if (dpd->mPeerReqState == RsDhtPeerRequest::RUNNING) { dpd->mConnectLogic.updateCb(CSB_UPDATE_FAILED_ATTEMPT); } @@ -2370,7 +2370,7 @@ void p3BitDht::UdpConnectionFailed_locked(DhtPeerDetails *dpd) - if (dpd->mPeerReqState == RSDHT_PEERREQ_RUNNING) + if (dpd->mPeerReqState == RsDhtPeerRequest::RUNNING) { #ifdef DEBUG_PEERNET std::cerr << "p3BitDht::UdpConnectionFailed_locked() "; diff --git a/libretroshare/src/dht/p3bitdht_peers.cc b/libretroshare/src/dht/p3bitdht_peers.cc index 3c313a58c..bf8e87f11 100644 --- a/libretroshare/src/dht/p3bitdht_peers.cc +++ b/libretroshare/src/dht/p3bitdht_peers.cc @@ -723,7 +723,7 @@ DhtPeerDetails::DhtPeerDetails() mDhtUpdateTS = time(NULL); mPeerReqStatusMsg = "Just Added"; - mPeerReqState = RSDHT_PEERREQ_STOPPED; + mPeerReqState = RsDhtPeerRequest::STOPPED; mPeerReqMode = 0; //mPeerReqProxyId; mPeerReqTS = time(NULL); diff --git a/libretroshare/src/retroshare/rsdht.h b/libretroshare/src/retroshare/rsdht.h index 358e9d529..be0776759 100644 --- a/libretroshare/src/retroshare/rsdht.h +++ b/libretroshare/src/retroshare/rsdht.h @@ -61,8 +61,11 @@ enum class RsDhtPeerConnectState : uint8_t CONNECTED = 3 }; -#define RSDHT_PEERREQ_STOPPED 1 -#define RSDHT_PEERREQ_RUNNING 2 +enum class RsDhtPeerRequest : uint8_t +{ + STOPPED = 1, + RUNNING = 2 +}; #define RSDHT_TOU_MODE_NONE 0 #define RSDHT_TOU_MODE_DIRECT 1 @@ -122,7 +125,7 @@ class RsDhtNetPeer std::string mPeerConnectProxyId; - uint32_t mPeerReqState; // Req Status. + RsDhtPeerRequest mPeerReqState; std::string mCbPeerMsg; // Peer Cb Mgs. }; diff --git a/retroshare-gui/src/gui/statistics/DhtWindow.cpp b/retroshare-gui/src/gui/statistics/DhtWindow.cpp index e3fe0bc5a..bf721d7d7 100644 --- a/retroshare-gui/src/gui/statistics/DhtWindow.cpp +++ b/retroshare-gui/src/gui/statistics/DhtWindow.cpp @@ -477,10 +477,10 @@ void DhtWindow::updateNetPeers() } switch(status.mPeerReqState) { - case RSDHT_PEERREQ_RUNNING: + case RsDhtPeerRequest::RUNNING: reqstr += tr("Request Active"); break; - case RSDHT_PEERREQ_STOPPED: + case RsDhtPeerRequest::STOPPED: reqstr += tr("No Request"); break; default: