From bc1ba3654d67d6ee76c0fee44633f98c7f3c1239 Mon Sep 17 00:00:00 2001 From: sehraf Date: Wed, 19 Feb 2020 20:00:18 +0100 Subject: [PATCH] convert RSDHT_TOU_MODE_ to enum class --- libretroshare/src/dht/p3bitdht_interface.cc | 8 ++++---- libretroshare/src/dht/p3bitdht_peernet.cc | 8 ++++---- libretroshare/src/retroshare/rsdht.h | 16 +++++++++------- retroshare-gui/src/gui/statistics/DhtWindow.cpp | 14 +++++++------- 4 files changed, 24 insertions(+), 22 deletions(-) diff --git a/libretroshare/src/dht/p3bitdht_interface.cc b/libretroshare/src/dht/p3bitdht_interface.cc index b67ab8f53..b31bbd03c 100644 --- a/libretroshare/src/dht/p3bitdht_interface.cc +++ b/libretroshare/src/dht/p3bitdht_interface.cc @@ -302,16 +302,16 @@ void convertDhtPeerDetailsToRsDhtNetPeer(RsDhtNetPeer &status, const DhtPeerDeta switch(details.mPeerConnectMode) { default: - status.mPeerConnectMode = RSDHT_TOU_MODE_NONE; + status.mPeerConnectMode = RsDhtTouMode::NONE; break; case BITDHT_CONNECT_MODE_DIRECT: - status.mPeerConnectMode = RSDHT_TOU_MODE_DIRECT; + status.mPeerConnectMode = RsDhtTouMode::DIRECT; break; case BITDHT_CONNECT_MODE_PROXY: - status.mPeerConnectMode = RSDHT_TOU_MODE_PROXY; + status.mPeerConnectMode = RsDhtTouMode::PROXY; break; case BITDHT_CONNECT_MODE_RELAY: - status.mPeerConnectMode = RSDHT_TOU_MODE_RELAY; + status.mPeerConnectMode = RsDhtTouMode::RELAY; break; } diff --git a/libretroshare/src/dht/p3bitdht_peernet.cc b/libretroshare/src/dht/p3bitdht_peernet.cc index 635a12bd8..a37678728 100644 --- a/libretroshare/src/dht/p3bitdht_peernet.cc +++ b/libretroshare/src/dht/p3bitdht_peernet.cc @@ -2003,7 +2003,7 @@ void p3BitDht::initiateConnection(const bdId *srcId, const bdId *proxyId, const { default: case BITDHT_CONNECT_MODE_DIRECT: -// touConnectMode = RSDHT_TOU_MODE_DIRECT; +// touConnectMode = RsDhtTouMode::DIRECT; connectFlags |= RS_CB_FLAG_MODE_UDP_DIRECT; delay = delayOrBandwidth; break; @@ -2021,12 +2021,12 @@ void p3BitDht::initiateConnection(const bdId *srcId, const bdId *proxyId, const delay = delayOrBandwidth; if (useProxyPort) { -// touConnectMode = RSDHT_TOU_MODE_PROXY; +// touConnectMode = RsDhtTouMode::PROXY; connectFlags |= RS_CB_FLAG_MODE_UDP_PROXY; } else { -// touConnectMode = RSDHT_TOU_MODE_DIRECT; +// touConnectMode = RsDhtTouMode::DIRECT; connectFlags |= RS_CB_FLAG_MODE_UDP_DIRECT; } @@ -2034,7 +2034,7 @@ void p3BitDht::initiateConnection(const bdId *srcId, const bdId *proxyId, const break; case BITDHT_CONNECT_MODE_RELAY: -// touConnectMode = RSDHT_TOU_MODE_RELAY; +// touConnectMode = RsDhtTouMode::RELAY; connectFlags |= RS_CB_FLAG_MODE_UDP_RELAY; bandwidth = delayOrBandwidth; break; diff --git a/libretroshare/src/retroshare/rsdht.h b/libretroshare/src/retroshare/rsdht.h index be0776759..4aa3cc5c8 100644 --- a/libretroshare/src/retroshare/rsdht.h +++ b/libretroshare/src/retroshare/rsdht.h @@ -67,11 +67,13 @@ enum class RsDhtPeerRequest : uint8_t RUNNING = 2 }; -#define RSDHT_TOU_MODE_NONE 0 -#define RSDHT_TOU_MODE_DIRECT 1 -#define RSDHT_TOU_MODE_PROXY 2 -#define RSDHT_TOU_MODE_RELAY 3 - +enum class RsDhtTouMode : uint8_t +{ + NONE = 0, + DIRECT = 1, + PROXY = 2, + RELAY = 3 +}; #define RSDHT_RELAY_NUM_CLASS 4 @@ -119,8 +121,8 @@ class RsDhtNetPeer std::string mConnectState; // connectLogic. - RsDhtPeerConnectState mPeerConnectState; // connect Status - uint32_t mPeerConnectMode; // connect mode + RsDhtPeerConnectState mPeerConnectState; + RsDhtTouMode mPeerConnectMode; bool mExclusiveProxyLock; std::string mPeerConnectProxyId; diff --git a/retroshare-gui/src/gui/statistics/DhtWindow.cpp b/retroshare-gui/src/gui/statistics/DhtWindow.cpp index bf721d7d7..27ea76e63 100644 --- a/retroshare-gui/src/gui/statistics/DhtWindow.cpp +++ b/retroshare-gui/src/gui/statistics/DhtWindow.cpp @@ -410,17 +410,17 @@ void DhtWindow::updateNetPeers() QString cpmstr; switch(status.mPeerConnectMode) { - case RSDHT_TOU_MODE_DIRECT: + case RsDhtTouMode::DIRECT: cpmstr = tr("Direct"); break; - case RSDHT_TOU_MODE_PROXY: + case RsDhtTouMode::PROXY: cpmstr = tr("Proxy VIA")+" " + QString::fromStdString(status.mPeerConnectProxyId); break; - case RSDHT_TOU_MODE_RELAY: + case RsDhtTouMode::RELAY: cpmstr = tr("Relay VIA")+" " + QString::fromStdString(status.mPeerConnectProxyId); break; default: - case RSDHT_TOU_MODE_NONE: + case RsDhtTouMode::NONE: cpmstr = tr("None"); break; } @@ -444,13 +444,13 @@ void DhtWindow::updateNetPeers() switch(status.mPeerConnectMode) { default: - case RSDHT_TOU_MODE_DIRECT: + case RsDhtTouMode::DIRECT: ++nDirectPeers; break; - case RSDHT_TOU_MODE_PROXY: + case RsDhtTouMode::PROXY: ++nProxyPeers; break; - case RSDHT_TOU_MODE_RELAY: + case RsDhtTouMode::RELAY: ++nRelayPeers; break; }