mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-28 00:07:09 -05:00
convert RSDHT_RELAY_MODE_ to enum class
This commit is contained in:
parent
dfc7212c23
commit
1b29e81e89
@ -294,8 +294,8 @@ public:
|
|||||||
virtual int addRelayServer(std::string ids);
|
virtual int addRelayServer(std::string ids);
|
||||||
virtual int removeRelayServer(std::string ids);
|
virtual int removeRelayServer(std::string ids);
|
||||||
|
|
||||||
virtual uint32_t getRelayMode();
|
virtual RsDhtRelayMode getRelayMode();
|
||||||
virtual int setRelayMode(uint32_t mode);
|
virtual int setRelayMode(RsDhtRelayMode mode);
|
||||||
|
|
||||||
virtual int getRelayAllowance(int classIdx, uint32_t &count, uint32_t &bandwidth);
|
virtual int getRelayAllowance(int classIdx, uint32_t &count, uint32_t &bandwidth);
|
||||||
virtual int setRelayAllowance(int classIdx, uint32_t count, uint32_t bandwidth);
|
virtual int setRelayAllowance(int classIdx, uint32_t count, uint32_t bandwidth);
|
||||||
@ -307,7 +307,7 @@ private:
|
|||||||
int pushRelayServers();
|
int pushRelayServers();
|
||||||
|
|
||||||
std::list<std::string> mRelayServerList;
|
std::list<std::string> mRelayServerList;
|
||||||
uint32_t mRelayMode;
|
RsDhtRelayMode mRelayMode;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/*****************************************************************/
|
/*****************************************************************/
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
|
|
||||||
int p3BitDht::setupRelayDefaults()
|
int p3BitDht::setupRelayDefaults()
|
||||||
{
|
{
|
||||||
uint32_t mode = RSDHT_RELAY_ENABLED | RSDHT_RELAY_MODE_OFF;
|
RsDhtRelayMode mode = RsDhtRelayMode::ENABLED | RsDhtRelayMode::OFF;
|
||||||
setRelayMode(mode);
|
setRelayMode(mode);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
@ -111,19 +111,19 @@ int p3BitDht::pushRelayServers()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint32_t p3BitDht::getRelayMode()
|
RsDhtRelayMode p3BitDht::getRelayMode()
|
||||||
{
|
{
|
||||||
RsStackMutex stack(dhtMtx); /*********** LOCKED **********/
|
RsStackMutex stack(dhtMtx); /*********** LOCKED **********/
|
||||||
|
|
||||||
return mRelayMode;
|
return mRelayMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
int p3BitDht::setRelayMode(uint32_t mode)
|
int p3BitDht::setRelayMode(RsDhtRelayMode mode)
|
||||||
{
|
{
|
||||||
std::cerr << "p3BitDht::setRelayMode(" << mode << ")";
|
std::cerr << "p3BitDht::setRelayMode(" << mode << ")";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
|
||||||
if (mode & RSDHT_RELAY_ENABLED)
|
if (!!(mode & RsDhtRelayMode::ENABLED))
|
||||||
{
|
{
|
||||||
mUdpBitDht->ConnectionOptions(
|
mUdpBitDht->ConnectionOptions(
|
||||||
BITDHT_CONNECT_MODE_DIRECT | BITDHT_CONNECT_MODE_PROXY | BITDHT_CONNECT_MODE_RELAY,
|
BITDHT_CONNECT_MODE_DIRECT | BITDHT_CONNECT_MODE_PROXY | BITDHT_CONNECT_MODE_RELAY,
|
||||||
@ -136,18 +136,18 @@ int p3BitDht::setRelayMode(uint32_t mode)
|
|||||||
BITDHT_CONNECT_OPTION_AUTOPROXY);
|
BITDHT_CONNECT_OPTION_AUTOPROXY);
|
||||||
}
|
}
|
||||||
|
|
||||||
int relaymode = mode & RSDHT_RELAY_MODE_MASK;
|
RsDhtRelayMode relaymode = mode & RsDhtRelayMode::MASK;
|
||||||
|
|
||||||
switch(relaymode)
|
switch(relaymode)
|
||||||
{
|
{
|
||||||
case RSDHT_RELAY_MODE_OFF:
|
case RsDhtRelayMode::OFF:
|
||||||
mUdpBitDht->setDhtMode(BITDHT_MODE_RELAYSERVERS_IGNORED);
|
mUdpBitDht->setDhtMode(BITDHT_MODE_RELAYSERVERS_IGNORED);
|
||||||
break;
|
break;
|
||||||
case RSDHT_RELAY_MODE_ON:
|
case RsDhtRelayMode::ON:
|
||||||
pushRelayServers();
|
pushRelayServers();
|
||||||
mUdpBitDht->setDhtMode(BITDHT_MODE_RELAYSERVERS_FLAGGED);
|
mUdpBitDht->setDhtMode(BITDHT_MODE_RELAYSERVERS_FLAGGED);
|
||||||
break;
|
break;
|
||||||
case RSDHT_RELAY_MODE_SERVER:
|
case RsDhtRelayMode::SERVER:
|
||||||
pushRelayServers();
|
pushRelayServers();
|
||||||
mUdpBitDht->setDhtMode(BITDHT_MODE_RELAYSERVERS_SERVER);
|
mUdpBitDht->setDhtMode(BITDHT_MODE_RELAYSERVERS_SERVER);
|
||||||
break;
|
break;
|
||||||
@ -306,7 +306,7 @@ bool p3BitDht::loadList(std::list<RsItem *>& load)
|
|||||||
int bandwidth[RSDHT_RELAY_NUM_CLASS] = {0};
|
int bandwidth[RSDHT_RELAY_NUM_CLASS] = {0};
|
||||||
|
|
||||||
bool haveMode = false;
|
bool haveMode = false;
|
||||||
int mode = 0;
|
RsDhtRelayMode mode = static_cast<RsDhtRelayMode>(0);
|
||||||
|
|
||||||
std::list<RsTlvKeyValue>::iterator it;
|
std::list<RsTlvKeyValue>::iterator it;
|
||||||
for(it = config->tlvkvs.pairs.begin(); it != config->tlvkvs.pairs.end(); ++it)
|
for(it = config->tlvkvs.pairs.begin(); it != config->tlvkvs.pairs.end(); ++it)
|
||||||
@ -322,7 +322,7 @@ bool p3BitDht::loadList(std::list<RsItem *>& load)
|
|||||||
}
|
}
|
||||||
else if (0 == strncmp(key.c_str(), "RELAY_MODE", 10))
|
else if (0 == strncmp(key.c_str(), "RELAY_MODE", 10))
|
||||||
{
|
{
|
||||||
mode = atoi(value.c_str());
|
mode = static_cast<RsDhtRelayMode>(atoi(value.c_str()));
|
||||||
haveMode = true;
|
haveMode = true;
|
||||||
|
|
||||||
//std::cerr << "p3BitDht::loadList() Found Mode: " << mode;
|
//std::cerr << "p3BitDht::loadList() Found Mode: " << mode;
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include <list>
|
#include <list>
|
||||||
#include <retroshare/rstypes.h>
|
#include <retroshare/rstypes.h>
|
||||||
#include "util/rsnet.h"
|
#include "util/rsnet.h"
|
||||||
|
#include "retroshare/rsflags.h"
|
||||||
|
|
||||||
/* The Main Interface Class - for information about your Peers */
|
/* The Main Interface Class - for information about your Peers */
|
||||||
class RsDht;
|
class RsDht;
|
||||||
@ -75,15 +76,16 @@ extern RsDht *rsDht;
|
|||||||
#define RSDHT_RELAY_CLASS_FOF 2
|
#define RSDHT_RELAY_CLASS_FOF 2
|
||||||
#define RSDHT_RELAY_CLASS_FRIENDS 3
|
#define RSDHT_RELAY_CLASS_FRIENDS 3
|
||||||
|
|
||||||
|
enum class RsDhtRelayMode : uint16_t
|
||||||
|
{
|
||||||
|
ENABLED = 0x0001,
|
||||||
|
|
||||||
#define RSDHT_RELAY_MODE_MASK 0x00f0
|
MASK = 0x00f0,
|
||||||
|
OFF = 0x0010,
|
||||||
#define RSDHT_RELAY_ENABLED 0x0001
|
ON = 0x0020,
|
||||||
|
SERVER = 0x0040
|
||||||
#define RSDHT_RELAY_MODE_OFF 0x0010
|
};
|
||||||
#define RSDHT_RELAY_MODE_ON 0x0020
|
RS_REGISTER_ENUM_FLAGS_TYPE(RsDhtRelayMode)
|
||||||
#define RSDHT_RELAY_MODE_SERVER 0x0040
|
|
||||||
|
|
||||||
|
|
||||||
class RsDhtPeer
|
class RsDhtPeer
|
||||||
{
|
{
|
||||||
@ -188,8 +190,8 @@ virtual int getRelayServerList(std::list<std::string> &ids) = 0;
|
|||||||
virtual int addRelayServer(std::string ids) = 0;
|
virtual int addRelayServer(std::string ids) = 0;
|
||||||
virtual int removeRelayServer(std::string ids) = 0;
|
virtual int removeRelayServer(std::string ids) = 0;
|
||||||
|
|
||||||
virtual uint32_t getRelayMode() = 0;
|
virtual RsDhtRelayMode getRelayMode() = 0;
|
||||||
virtual int setRelayMode(uint32_t mode) = 0;
|
virtual int setRelayMode(RsDhtRelayMode mode) = 0;
|
||||||
|
|
||||||
virtual int getRelayAllowance(int classIdx, uint32_t &count, uint32_t &bandwidth) = 0;
|
virtual int getRelayAllowance(int classIdx, uint32_t &count, uint32_t &bandwidth) = 0;
|
||||||
virtual int setRelayAllowance(int classIdx, uint32_t count, uint32_t bandwidth) = 0;
|
virtual int setRelayAllowance(int classIdx, uint32_t count, uint32_t bandwidth) = 0;
|
||||||
|
@ -461,11 +461,11 @@ void ServerPage::load()
|
|||||||
updateTotals();
|
updateTotals();
|
||||||
|
|
||||||
|
|
||||||
uint32_t relayMode = rsDht->getRelayMode();
|
RsDhtRelayMode relayMode = rsDht->getRelayMode();
|
||||||
if (relayMode & RSDHT_RELAY_ENABLED)
|
if (!!(relayMode & RsDhtRelayMode::ENABLED))
|
||||||
{
|
{
|
||||||
whileBlocking(ui.enableCheckBox)->setCheckState(Qt::Checked);
|
whileBlocking(ui.enableCheckBox)->setCheckState(Qt::Checked);
|
||||||
if ((relayMode & RSDHT_RELAY_MODE_MASK) == RSDHT_RELAY_MODE_OFF)
|
if ((relayMode & RsDhtRelayMode::MASK) == RsDhtRelayMode::OFF)
|
||||||
{
|
{
|
||||||
whileBlocking(ui.serverCheckBox)->setCheckState(Qt::Unchecked);
|
whileBlocking(ui.serverCheckBox)->setCheckState(Qt::Unchecked);
|
||||||
}
|
}
|
||||||
@ -1894,23 +1894,23 @@ void ServerPage::updateTotals()
|
|||||||
|
|
||||||
void ServerPage::updateRelayMode()
|
void ServerPage::updateRelayMode()
|
||||||
{
|
{
|
||||||
uint32_t relayMode = 0;
|
RsDhtRelayMode relayMode = static_cast<RsDhtRelayMode>(0);
|
||||||
if (ui.enableCheckBox->isChecked())
|
if (ui.enableCheckBox->isChecked())
|
||||||
{
|
{
|
||||||
relayMode |= RSDHT_RELAY_ENABLED;
|
relayMode |= RsDhtRelayMode::ENABLED;
|
||||||
|
|
||||||
if (ui.serverCheckBox->isChecked())
|
if (ui.serverCheckBox->isChecked())
|
||||||
{
|
{
|
||||||
relayMode |= RSDHT_RELAY_MODE_ON;
|
relayMode |= RsDhtRelayMode::ON;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
relayMode |= RSDHT_RELAY_MODE_OFF;
|
relayMode |= RsDhtRelayMode::OFF;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
relayMode |= RSDHT_RELAY_MODE_OFF;
|
relayMode |= RsDhtRelayMode::OFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
rsDht->setRelayMode(relayMode);
|
rsDht->setRelayMode(relayMode);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user