convert RSDHT_PEERDHT_ to enum class

This commit is contained in:
sehraf 2020-02-19 19:35:34 +01:00
parent 1b1b09217a
commit 8d0a352b53
No known key found for this signature in database
GPG Key ID: DF09F6EAE356B2C6
6 changed files with 36 additions and 33 deletions

View File

@ -51,7 +51,7 @@ class DhtPeerDetails
RsPeerId mRsId;
/* direct from the DHT! */
uint32_t mDhtState; // One of RSDHT_PEERDHT_[...]
RsDhtPeerDht mDhtState;
rstime_t mDhtUpdateTS;
/* internal state */

View File

@ -222,26 +222,26 @@ int p3BitDht::PeerCallback(const bdId *id, uint32_t status)
switch(status)
{
default:
dpd->mDhtState = RSDHT_PEERDHT_NOT_ACTIVE;
dpd->mDhtState = RsDhtPeerDht::NOT_ACTIVE;
break;
case BITDHT_MGR_QUERY_FAILURE:
dpd->mDhtState = RSDHT_PEERDHT_FAILURE;
dpd->mDhtState = RsDhtPeerDht::FAILURE;
break;
case BITDHT_MGR_QUERY_PEER_OFFLINE:
dpd->mDhtState = RSDHT_PEERDHT_OFFLINE;
dpd->mDhtState = RsDhtPeerDht::OFFLINE;
break;
case BITDHT_MGR_QUERY_PEER_UNREACHABLE:
dpd->mDhtState = RSDHT_PEERDHT_UNREACHABLE;
dpd->mDhtState = RsDhtPeerDht::UNREACHABLE;
dpd->mDhtId = *id; // set the IP:Port of the unreachable peer.
UnreachablePeerCallback_locked(id, status, dpd);
break;
case BITDHT_MGR_QUERY_PEER_ONLINE:
dpd->mDhtState = RSDHT_PEERDHT_ONLINE;
dpd->mDhtState = RsDhtPeerDht::ONLINE;
dpd->mDhtId = *id; // set the IP:Port of the Online peer.
OnlinePeerCallback_locked(id, status, dpd);
@ -1749,7 +1749,7 @@ int p3BitDht::checkConnectionAllowed(const bdId *peerId, int mode)
/* flag as failed */
it->second.mDhtId = *peerId;
it->second.mDhtState = RSDHT_PEERDHT_NOT_ACTIVE;
it->second.mDhtState = RsDhtPeerDht::NOT_ACTIVE;
it->second.mDhtUpdateTS = now;
it->second.mPeerType = RsDhtPeerType::OTHER;

View File

@ -76,7 +76,7 @@ bool p3BitDht::findPeer(const RsPeerId& pid)
}
/* new entry... what do we need to set? */
dpd->mDhtState = RSDHT_PEERDHT_SEARCHING;
dpd->mDhtState = RsDhtPeerDht::SEARCHING;
#ifdef DEBUG_BITDHT
std::cerr << "p3BitDht::findPeer() Installed new DhtPeer with pid => NodeId: ";
@ -93,7 +93,7 @@ bool p3BitDht::findPeer(const RsPeerId& pid)
std::cerr << std::endl;
#endif
if (dpd->mDhtState != RSDHT_PEERDHT_NOT_ACTIVE)
if (dpd->mDhtState != RsDhtPeerDht::NOT_ACTIVE)
{
#ifdef DEBUG_BITDHT
std::cerr << "p3BitDht::findPeer() WARNING DhtState is Already Active!";
@ -104,7 +104,7 @@ bool p3BitDht::findPeer(const RsPeerId& pid)
else
{
/* flag as searching */
dpd->mDhtState = RSDHT_PEERDHT_SEARCHING;
dpd->mDhtState = RsDhtPeerDht::SEARCHING;
#ifdef DEBUG_BITDHT
std::cerr << "p3BitDht::findPeer() Marking Old Peer as SEARCHING";
std::cerr << std::endl;
@ -156,7 +156,7 @@ bool p3BitDht::dropPeer(const RsPeerId& pid)
}
/* flag as searching */
dpd->mDhtState = RSDHT_PEERDHT_NOT_ACTIVE;
dpd->mDhtState = RsDhtPeerDht::NOT_ACTIVE;
nid = dpd->mDhtId.id;
@ -418,7 +418,7 @@ DhtPeerDetails *p3BitDht::addInternalPeer_locked(const RsPeerId& pid, RsDhtPeerT
newdpd.mDhtId.id = id;
newdpd.mRsId = pid;
newdpd.mDhtState = RSDHT_PEERDHT_NOT_ACTIVE;
newdpd.mDhtState = RsDhtPeerDht::NOT_ACTIVE;
newdpd.mPeerType = RsDhtPeerType::ANY;
mPeers[id] = newdpd;
@ -717,9 +717,9 @@ int p3BitDht::calculateNodeId(const RsPeerId& pid, bdNodeId *id)
DhtPeerDetails::DhtPeerDetails()
{
mDhtState = RSDHT_PEERDHT_NOT_ACTIVE;
mDhtState = RsDhtPeerDht::NOT_ACTIVE;
mDhtState = RSDHT_PEERDHT_SEARCHING;
mDhtState = RsDhtPeerDht::SEARCHING;
mDhtUpdateTS = time(NULL);
mPeerReqStatusMsg = "Just Added";

View File

@ -44,12 +44,15 @@ enum class RsDhtPeerType : uint8_t
FRIEND = 3
};
#define RSDHT_PEERDHT_NOT_ACTIVE 0x0000
#define RSDHT_PEERDHT_SEARCHING 0x0001
#define RSDHT_PEERDHT_FAILURE 0x0002
#define RSDHT_PEERDHT_OFFLINE 0x0003
#define RSDHT_PEERDHT_UNREACHABLE 0x0004
#define RSDHT_PEERDHT_ONLINE 0x0005
enum class RsDhtPeerDht : uint8_t
{
NOT_ACTIVE = 0,
SEARCHING = 1,
FAILURE = 2,
OFFLINE = 3,
UNREACHABLE = 4,
ONLINE = 5
};
#define RSDHT_PEERCONN_DISCONNECTED 1
#define RSDHT_PEERCONN_UDP_STARTED 2
@ -106,7 +109,7 @@ class RsDhtNetPeer
RsPeerId mRsId;
RsDhtPeerType mPeerType;
uint32_t mDhtState;
RsDhtPeerDht mDhtState;
std::string mConnectState; // connectLogic.

View File

@ -521,30 +521,30 @@ void ConnectProgressDialog::updateLookupStatus()
switch(status.mDhtState)
{
default:
case RSDHT_PEERDHT_NOT_ACTIVE:
case RsDhtPeerDht::NOT_ACTIVE:
ui->LookupProgressBar->setValue(0);
ui->LookupResult->setText(tr("Peer DHT NOT ACTIVE"));
mLookupStatus = CONNECT_LOOKUP_NODHTCONFIG;
break;
case RSDHT_PEERDHT_SEARCHING:
case RsDhtPeerDht::SEARCHING:
ui->LookupResult->setText(tr("Searching"));
break;
case RSDHT_PEERDHT_FAILURE:
case RsDhtPeerDht::FAILURE:
ui->LookupProgressBar->setValue(0);
ui->LookupResult->setText(tr("Lookup Failure"));
mLookupStatus = CONNECT_LOOKUP_FAIL;
break;
case RSDHT_PEERDHT_OFFLINE:
case RsDhtPeerDht::OFFLINE:
ui->LookupProgressBar->setValue(100);
ui->LookupResult->setText(tr("Peer Offline"));
mLookupStatus = CONNECT_LOOKUP_OFFLINE;
break;
case RSDHT_PEERDHT_UNREACHABLE:
case RsDhtPeerDht::UNREACHABLE:
ui->LookupProgressBar->setValue(100);
ui->LookupResult->setText(tr("Peer Firewalled"));
mLookupStatus = CONNECT_LOOKUP_UNREACHABLE;
break;
case RSDHT_PEERDHT_ONLINE:
case RsDhtPeerDht::ONLINE:
ui->LookupProgressBar->setValue(100);
ui->LookupResult->setText(tr("Peer Online"));
mLookupStatus = CONNECT_LOOKUP_ONLINE;

View File

@ -381,24 +381,24 @@ void DhtWindow::updateNetPeers()
switch(status.mDhtState)
{
default:
case RSDHT_PEERDHT_NOT_ACTIVE:
case RsDhtPeerDht::NOT_ACTIVE:
dhtstate = tr("Not Active (Maybe Connected!)");
break;
case RSDHT_PEERDHT_SEARCHING:
case RsDhtPeerDht::SEARCHING:
dhtstate = tr("Searching");
break;
case RSDHT_PEERDHT_FAILURE:
case RsDhtPeerDht::FAILURE:
dhtstate = tr("Failed");
break;
case RSDHT_PEERDHT_OFFLINE:
case RsDhtPeerDht::OFFLINE:
dhtstate = tr("offline");
++nOfflinePeers;
break;
case RSDHT_PEERDHT_UNREACHABLE:
case RsDhtPeerDht::UNREACHABLE:
dhtstate = tr("Unreachable");
++nUnreachablePeers;
break;
case RSDHT_PEERDHT_ONLINE:
case RsDhtPeerDht::ONLINE:
dhtstate = tr("ONLINE");
++nOnlinePeers;
break;