convert RSDHT_TOU_MODE_ to enum class

This commit is contained in:
sehraf 2020-02-19 20:00:18 +01:00
parent 46d77bfe7a
commit bc1ba3654d
No known key found for this signature in database
GPG Key ID: DF09F6EAE356B2C6
4 changed files with 24 additions and 22 deletions

View File

@ -302,16 +302,16 @@ void convertDhtPeerDetailsToRsDhtNetPeer(RsDhtNetPeer &status, const DhtPeerDeta
switch(details.mPeerConnectMode) switch(details.mPeerConnectMode)
{ {
default: default:
status.mPeerConnectMode = RSDHT_TOU_MODE_NONE; status.mPeerConnectMode = RsDhtTouMode::NONE;
break; break;
case BITDHT_CONNECT_MODE_DIRECT: case BITDHT_CONNECT_MODE_DIRECT:
status.mPeerConnectMode = RSDHT_TOU_MODE_DIRECT; status.mPeerConnectMode = RsDhtTouMode::DIRECT;
break; break;
case BITDHT_CONNECT_MODE_PROXY: case BITDHT_CONNECT_MODE_PROXY:
status.mPeerConnectMode = RSDHT_TOU_MODE_PROXY; status.mPeerConnectMode = RsDhtTouMode::PROXY;
break; break;
case BITDHT_CONNECT_MODE_RELAY: case BITDHT_CONNECT_MODE_RELAY:
status.mPeerConnectMode = RSDHT_TOU_MODE_RELAY; status.mPeerConnectMode = RsDhtTouMode::RELAY;
break; break;
} }

View File

@ -2003,7 +2003,7 @@ void p3BitDht::initiateConnection(const bdId *srcId, const bdId *proxyId, const
{ {
default: default:
case BITDHT_CONNECT_MODE_DIRECT: case BITDHT_CONNECT_MODE_DIRECT:
// touConnectMode = RSDHT_TOU_MODE_DIRECT; // touConnectMode = RsDhtTouMode::DIRECT;
connectFlags |= RS_CB_FLAG_MODE_UDP_DIRECT; connectFlags |= RS_CB_FLAG_MODE_UDP_DIRECT;
delay = delayOrBandwidth; delay = delayOrBandwidth;
break; break;
@ -2021,12 +2021,12 @@ void p3BitDht::initiateConnection(const bdId *srcId, const bdId *proxyId, const
delay = delayOrBandwidth; delay = delayOrBandwidth;
if (useProxyPort) if (useProxyPort)
{ {
// touConnectMode = RSDHT_TOU_MODE_PROXY; // touConnectMode = RsDhtTouMode::PROXY;
connectFlags |= RS_CB_FLAG_MODE_UDP_PROXY; connectFlags |= RS_CB_FLAG_MODE_UDP_PROXY;
} }
else else
{ {
// touConnectMode = RSDHT_TOU_MODE_DIRECT; // touConnectMode = RsDhtTouMode::DIRECT;
connectFlags |= RS_CB_FLAG_MODE_UDP_DIRECT; connectFlags |= RS_CB_FLAG_MODE_UDP_DIRECT;
} }
@ -2034,7 +2034,7 @@ void p3BitDht::initiateConnection(const bdId *srcId, const bdId *proxyId, const
break; break;
case BITDHT_CONNECT_MODE_RELAY: case BITDHT_CONNECT_MODE_RELAY:
// touConnectMode = RSDHT_TOU_MODE_RELAY; // touConnectMode = RsDhtTouMode::RELAY;
connectFlags |= RS_CB_FLAG_MODE_UDP_RELAY; connectFlags |= RS_CB_FLAG_MODE_UDP_RELAY;
bandwidth = delayOrBandwidth; bandwidth = delayOrBandwidth;
break; break;

View File

@ -67,11 +67,13 @@ enum class RsDhtPeerRequest : uint8_t
RUNNING = 2 RUNNING = 2
}; };
#define RSDHT_TOU_MODE_NONE 0 enum class RsDhtTouMode : uint8_t
#define RSDHT_TOU_MODE_DIRECT 1 {
#define RSDHT_TOU_MODE_PROXY 2 NONE = 0,
#define RSDHT_TOU_MODE_RELAY 3 DIRECT = 1,
PROXY = 2,
RELAY = 3
};
#define RSDHT_RELAY_NUM_CLASS 4 #define RSDHT_RELAY_NUM_CLASS 4
@ -119,8 +121,8 @@ class RsDhtNetPeer
std::string mConnectState; // connectLogic. std::string mConnectState; // connectLogic.
RsDhtPeerConnectState mPeerConnectState; // connect Status RsDhtPeerConnectState mPeerConnectState;
uint32_t mPeerConnectMode; // connect mode RsDhtTouMode mPeerConnectMode;
bool mExclusiveProxyLock; bool mExclusiveProxyLock;
std::string mPeerConnectProxyId; std::string mPeerConnectProxyId;

View File

@ -410,17 +410,17 @@ void DhtWindow::updateNetPeers()
QString cpmstr; QString cpmstr;
switch(status.mPeerConnectMode) switch(status.mPeerConnectMode)
{ {
case RSDHT_TOU_MODE_DIRECT: case RsDhtTouMode::DIRECT:
cpmstr = tr("Direct"); cpmstr = tr("Direct");
break; break;
case RSDHT_TOU_MODE_PROXY: case RsDhtTouMode::PROXY:
cpmstr = tr("Proxy VIA")+" " + QString::fromStdString(status.mPeerConnectProxyId); cpmstr = tr("Proxy VIA")+" " + QString::fromStdString(status.mPeerConnectProxyId);
break; break;
case RSDHT_TOU_MODE_RELAY: case RsDhtTouMode::RELAY:
cpmstr = tr("Relay VIA")+" " + QString::fromStdString(status.mPeerConnectProxyId); cpmstr = tr("Relay VIA")+" " + QString::fromStdString(status.mPeerConnectProxyId);
break; break;
default: default:
case RSDHT_TOU_MODE_NONE: case RsDhtTouMode::NONE:
cpmstr = tr("None"); cpmstr = tr("None");
break; break;
} }
@ -444,13 +444,13 @@ void DhtWindow::updateNetPeers()
switch(status.mPeerConnectMode) switch(status.mPeerConnectMode)
{ {
default: default:
case RSDHT_TOU_MODE_DIRECT: case RsDhtTouMode::DIRECT:
++nDirectPeers; ++nDirectPeers;
break; break;
case RSDHT_TOU_MODE_PROXY: case RsDhtTouMode::PROXY:
++nProxyPeers; ++nProxyPeers;
break; break;
case RSDHT_TOU_MODE_RELAY: case RsDhtTouMode::RELAY:
++nRelayPeers; ++nRelayPeers;
break; break;
} }