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)
{
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;
}

View File

@ -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;

View File

@ -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;

View File

@ -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;
}