mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-26 17:51:26 -05:00
convert RSDHT_PEERDHT_ to enum class
This commit is contained in:
parent
1b1b09217a
commit
8d0a352b53
@ -51,7 +51,7 @@ class DhtPeerDetails
|
|||||||
RsPeerId mRsId;
|
RsPeerId mRsId;
|
||||||
|
|
||||||
/* direct from the DHT! */
|
/* direct from the DHT! */
|
||||||
uint32_t mDhtState; // One of RSDHT_PEERDHT_[...]
|
RsDhtPeerDht mDhtState;
|
||||||
rstime_t mDhtUpdateTS;
|
rstime_t mDhtUpdateTS;
|
||||||
|
|
||||||
/* internal state */
|
/* internal state */
|
||||||
|
@ -222,26 +222,26 @@ int p3BitDht::PeerCallback(const bdId *id, uint32_t status)
|
|||||||
switch(status)
|
switch(status)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
dpd->mDhtState = RSDHT_PEERDHT_NOT_ACTIVE;
|
dpd->mDhtState = RsDhtPeerDht::NOT_ACTIVE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BITDHT_MGR_QUERY_FAILURE:
|
case BITDHT_MGR_QUERY_FAILURE:
|
||||||
dpd->mDhtState = RSDHT_PEERDHT_FAILURE;
|
dpd->mDhtState = RsDhtPeerDht::FAILURE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BITDHT_MGR_QUERY_PEER_OFFLINE:
|
case BITDHT_MGR_QUERY_PEER_OFFLINE:
|
||||||
dpd->mDhtState = RSDHT_PEERDHT_OFFLINE;
|
dpd->mDhtState = RsDhtPeerDht::OFFLINE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BITDHT_MGR_QUERY_PEER_UNREACHABLE:
|
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.
|
dpd->mDhtId = *id; // set the IP:Port of the unreachable peer.
|
||||||
UnreachablePeerCallback_locked(id, status, dpd);
|
UnreachablePeerCallback_locked(id, status, dpd);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BITDHT_MGR_QUERY_PEER_ONLINE:
|
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.
|
dpd->mDhtId = *id; // set the IP:Port of the Online peer.
|
||||||
OnlinePeerCallback_locked(id, status, dpd);
|
OnlinePeerCallback_locked(id, status, dpd);
|
||||||
|
|
||||||
@ -1749,7 +1749,7 @@ int p3BitDht::checkConnectionAllowed(const bdId *peerId, int mode)
|
|||||||
|
|
||||||
/* flag as failed */
|
/* flag as failed */
|
||||||
it->second.mDhtId = *peerId;
|
it->second.mDhtId = *peerId;
|
||||||
it->second.mDhtState = RSDHT_PEERDHT_NOT_ACTIVE;
|
it->second.mDhtState = RsDhtPeerDht::NOT_ACTIVE;
|
||||||
it->second.mDhtUpdateTS = now;
|
it->second.mDhtUpdateTS = now;
|
||||||
|
|
||||||
it->second.mPeerType = RsDhtPeerType::OTHER;
|
it->second.mPeerType = RsDhtPeerType::OTHER;
|
||||||
|
@ -76,7 +76,7 @@ bool p3BitDht::findPeer(const RsPeerId& pid)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* new entry... what do we need to set? */
|
/* new entry... what do we need to set? */
|
||||||
dpd->mDhtState = RSDHT_PEERDHT_SEARCHING;
|
dpd->mDhtState = RsDhtPeerDht::SEARCHING;
|
||||||
|
|
||||||
#ifdef DEBUG_BITDHT
|
#ifdef DEBUG_BITDHT
|
||||||
std::cerr << "p3BitDht::findPeer() Installed new DhtPeer with pid => NodeId: ";
|
std::cerr << "p3BitDht::findPeer() Installed new DhtPeer with pid => NodeId: ";
|
||||||
@ -93,7 +93,7 @@ bool p3BitDht::findPeer(const RsPeerId& pid)
|
|||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (dpd->mDhtState != RSDHT_PEERDHT_NOT_ACTIVE)
|
if (dpd->mDhtState != RsDhtPeerDht::NOT_ACTIVE)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_BITDHT
|
#ifdef DEBUG_BITDHT
|
||||||
std::cerr << "p3BitDht::findPeer() WARNING DhtState is Already Active!";
|
std::cerr << "p3BitDht::findPeer() WARNING DhtState is Already Active!";
|
||||||
@ -104,7 +104,7 @@ bool p3BitDht::findPeer(const RsPeerId& pid)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* flag as searching */
|
/* flag as searching */
|
||||||
dpd->mDhtState = RSDHT_PEERDHT_SEARCHING;
|
dpd->mDhtState = RsDhtPeerDht::SEARCHING;
|
||||||
#ifdef DEBUG_BITDHT
|
#ifdef DEBUG_BITDHT
|
||||||
std::cerr << "p3BitDht::findPeer() Marking Old Peer as SEARCHING";
|
std::cerr << "p3BitDht::findPeer() Marking Old Peer as SEARCHING";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
@ -156,7 +156,7 @@ bool p3BitDht::dropPeer(const RsPeerId& pid)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* flag as searching */
|
/* flag as searching */
|
||||||
dpd->mDhtState = RSDHT_PEERDHT_NOT_ACTIVE;
|
dpd->mDhtState = RsDhtPeerDht::NOT_ACTIVE;
|
||||||
|
|
||||||
nid = dpd->mDhtId.id;
|
nid = dpd->mDhtId.id;
|
||||||
|
|
||||||
@ -418,7 +418,7 @@ DhtPeerDetails *p3BitDht::addInternalPeer_locked(const RsPeerId& pid, RsDhtPeerT
|
|||||||
|
|
||||||
newdpd.mDhtId.id = id;
|
newdpd.mDhtId.id = id;
|
||||||
newdpd.mRsId = pid;
|
newdpd.mRsId = pid;
|
||||||
newdpd.mDhtState = RSDHT_PEERDHT_NOT_ACTIVE;
|
newdpd.mDhtState = RsDhtPeerDht::NOT_ACTIVE;
|
||||||
newdpd.mPeerType = RsDhtPeerType::ANY;
|
newdpd.mPeerType = RsDhtPeerType::ANY;
|
||||||
|
|
||||||
mPeers[id] = newdpd;
|
mPeers[id] = newdpd;
|
||||||
@ -717,9 +717,9 @@ int p3BitDht::calculateNodeId(const RsPeerId& pid, bdNodeId *id)
|
|||||||
|
|
||||||
DhtPeerDetails::DhtPeerDetails()
|
DhtPeerDetails::DhtPeerDetails()
|
||||||
{
|
{
|
||||||
mDhtState = RSDHT_PEERDHT_NOT_ACTIVE;
|
mDhtState = RsDhtPeerDht::NOT_ACTIVE;
|
||||||
|
|
||||||
mDhtState = RSDHT_PEERDHT_SEARCHING;
|
mDhtState = RsDhtPeerDht::SEARCHING;
|
||||||
mDhtUpdateTS = time(NULL);
|
mDhtUpdateTS = time(NULL);
|
||||||
|
|
||||||
mPeerReqStatusMsg = "Just Added";
|
mPeerReqStatusMsg = "Just Added";
|
||||||
|
@ -44,12 +44,15 @@ enum class RsDhtPeerType : uint8_t
|
|||||||
FRIEND = 3
|
FRIEND = 3
|
||||||
};
|
};
|
||||||
|
|
||||||
#define RSDHT_PEERDHT_NOT_ACTIVE 0x0000
|
enum class RsDhtPeerDht : uint8_t
|
||||||
#define RSDHT_PEERDHT_SEARCHING 0x0001
|
{
|
||||||
#define RSDHT_PEERDHT_FAILURE 0x0002
|
NOT_ACTIVE = 0,
|
||||||
#define RSDHT_PEERDHT_OFFLINE 0x0003
|
SEARCHING = 1,
|
||||||
#define RSDHT_PEERDHT_UNREACHABLE 0x0004
|
FAILURE = 2,
|
||||||
#define RSDHT_PEERDHT_ONLINE 0x0005
|
OFFLINE = 3,
|
||||||
|
UNREACHABLE = 4,
|
||||||
|
ONLINE = 5
|
||||||
|
};
|
||||||
|
|
||||||
#define RSDHT_PEERCONN_DISCONNECTED 1
|
#define RSDHT_PEERCONN_DISCONNECTED 1
|
||||||
#define RSDHT_PEERCONN_UDP_STARTED 2
|
#define RSDHT_PEERCONN_UDP_STARTED 2
|
||||||
@ -106,7 +109,7 @@ class RsDhtNetPeer
|
|||||||
RsPeerId mRsId;
|
RsPeerId mRsId;
|
||||||
|
|
||||||
RsDhtPeerType mPeerType;
|
RsDhtPeerType mPeerType;
|
||||||
uint32_t mDhtState;
|
RsDhtPeerDht mDhtState;
|
||||||
|
|
||||||
std::string mConnectState; // connectLogic.
|
std::string mConnectState; // connectLogic.
|
||||||
|
|
||||||
|
@ -521,30 +521,30 @@ void ConnectProgressDialog::updateLookupStatus()
|
|||||||
switch(status.mDhtState)
|
switch(status.mDhtState)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
case RSDHT_PEERDHT_NOT_ACTIVE:
|
case RsDhtPeerDht::NOT_ACTIVE:
|
||||||
ui->LookupProgressBar->setValue(0);
|
ui->LookupProgressBar->setValue(0);
|
||||||
ui->LookupResult->setText(tr("Peer DHT NOT ACTIVE"));
|
ui->LookupResult->setText(tr("Peer DHT NOT ACTIVE"));
|
||||||
mLookupStatus = CONNECT_LOOKUP_NODHTCONFIG;
|
mLookupStatus = CONNECT_LOOKUP_NODHTCONFIG;
|
||||||
break;
|
break;
|
||||||
case RSDHT_PEERDHT_SEARCHING:
|
case RsDhtPeerDht::SEARCHING:
|
||||||
ui->LookupResult->setText(tr("Searching"));
|
ui->LookupResult->setText(tr("Searching"));
|
||||||
break;
|
break;
|
||||||
case RSDHT_PEERDHT_FAILURE:
|
case RsDhtPeerDht::FAILURE:
|
||||||
ui->LookupProgressBar->setValue(0);
|
ui->LookupProgressBar->setValue(0);
|
||||||
ui->LookupResult->setText(tr("Lookup Failure"));
|
ui->LookupResult->setText(tr("Lookup Failure"));
|
||||||
mLookupStatus = CONNECT_LOOKUP_FAIL;
|
mLookupStatus = CONNECT_LOOKUP_FAIL;
|
||||||
break;
|
break;
|
||||||
case RSDHT_PEERDHT_OFFLINE:
|
case RsDhtPeerDht::OFFLINE:
|
||||||
ui->LookupProgressBar->setValue(100);
|
ui->LookupProgressBar->setValue(100);
|
||||||
ui->LookupResult->setText(tr("Peer Offline"));
|
ui->LookupResult->setText(tr("Peer Offline"));
|
||||||
mLookupStatus = CONNECT_LOOKUP_OFFLINE;
|
mLookupStatus = CONNECT_LOOKUP_OFFLINE;
|
||||||
break;
|
break;
|
||||||
case RSDHT_PEERDHT_UNREACHABLE:
|
case RsDhtPeerDht::UNREACHABLE:
|
||||||
ui->LookupProgressBar->setValue(100);
|
ui->LookupProgressBar->setValue(100);
|
||||||
ui->LookupResult->setText(tr("Peer Firewalled"));
|
ui->LookupResult->setText(tr("Peer Firewalled"));
|
||||||
mLookupStatus = CONNECT_LOOKUP_UNREACHABLE;
|
mLookupStatus = CONNECT_LOOKUP_UNREACHABLE;
|
||||||
break;
|
break;
|
||||||
case RSDHT_PEERDHT_ONLINE:
|
case RsDhtPeerDht::ONLINE:
|
||||||
ui->LookupProgressBar->setValue(100);
|
ui->LookupProgressBar->setValue(100);
|
||||||
ui->LookupResult->setText(tr("Peer Online"));
|
ui->LookupResult->setText(tr("Peer Online"));
|
||||||
mLookupStatus = CONNECT_LOOKUP_ONLINE;
|
mLookupStatus = CONNECT_LOOKUP_ONLINE;
|
||||||
|
@ -381,24 +381,24 @@ void DhtWindow::updateNetPeers()
|
|||||||
switch(status.mDhtState)
|
switch(status.mDhtState)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
case RSDHT_PEERDHT_NOT_ACTIVE:
|
case RsDhtPeerDht::NOT_ACTIVE:
|
||||||
dhtstate = tr("Not Active (Maybe Connected!)");
|
dhtstate = tr("Not Active (Maybe Connected!)");
|
||||||
break;
|
break;
|
||||||
case RSDHT_PEERDHT_SEARCHING:
|
case RsDhtPeerDht::SEARCHING:
|
||||||
dhtstate = tr("Searching");
|
dhtstate = tr("Searching");
|
||||||
break;
|
break;
|
||||||
case RSDHT_PEERDHT_FAILURE:
|
case RsDhtPeerDht::FAILURE:
|
||||||
dhtstate = tr("Failed");
|
dhtstate = tr("Failed");
|
||||||
break;
|
break;
|
||||||
case RSDHT_PEERDHT_OFFLINE:
|
case RsDhtPeerDht::OFFLINE:
|
||||||
dhtstate = tr("offline");
|
dhtstate = tr("offline");
|
||||||
++nOfflinePeers;
|
++nOfflinePeers;
|
||||||
break;
|
break;
|
||||||
case RSDHT_PEERDHT_UNREACHABLE:
|
case RsDhtPeerDht::UNREACHABLE:
|
||||||
dhtstate = tr("Unreachable");
|
dhtstate = tr("Unreachable");
|
||||||
++nUnreachablePeers;
|
++nUnreachablePeers;
|
||||||
break;
|
break;
|
||||||
case RSDHT_PEERDHT_ONLINE:
|
case RsDhtPeerDht::ONLINE:
|
||||||
dhtstate = tr("ONLINE");
|
dhtstate = tr("ONLINE");
|
||||||
++nOnlinePeers;
|
++nOnlinePeers;
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user