From 0237531322b3c5f8bbb16d9f0846eb2ca83e0ecc Mon Sep 17 00:00:00 2001 From: sehraf Date: Sun, 9 Feb 2020 18:23:48 +0100 Subject: [PATCH 01/24] convert RSNET_NETWORK to enum class --- libretroshare/src/dht/connectstatebox.cc | 13 ++-- libretroshare/src/dht/connectstatebox.h | 8 +- libretroshare/src/pqi/p3netmgr.cc | 2 +- libretroshare/src/pqi/p3netmgr.h | 4 +- libretroshare/src/pqi/pqinetstatebox.cc | 75 ++++++------------- libretroshare/src/pqi/pqinetstatebox.h | 8 +- libretroshare/src/retroshare/rsconfig.h | 18 +++-- libretroshare/src/rsserver/p3serverconfig.cc | 8 +- libretroshare/src/rsserver/p3serverconfig.h | 2 +- .../src/gui/statistics/DhtWindow.cpp | 15 ++-- 10 files changed, 68 insertions(+), 85 deletions(-) diff --git a/libretroshare/src/dht/connectstatebox.cc b/libretroshare/src/dht/connectstatebox.cc index 1d30be3cb..06c155391 100644 --- a/libretroshare/src/dht/connectstatebox.cc +++ b/libretroshare/src/dht/connectstatebox.cc @@ -21,7 +21,6 @@ *******************************************************************************/ #include "dht/connectstatebox.h" -#include "retroshare/rsconfig.h" #include "util/rsrandom.h" #include "util/rsstring.h" @@ -260,11 +259,11 @@ std::string PeerConnectStateBox::connectState() const } -uint32_t convertNetStateToInternal(uint32_t netmode, uint32_t nathole, uint32_t nattype) +uint32_t convertNetStateToInternal(RsNetworkMode netmode, uint32_t nathole, uint32_t nattype) { uint32_t connNet = CSB_NETSTATE_UNKNOWN; - if (netmode == RSNET_NETWORK_EXTERNALIP) + if (netmode == RsNetworkMode::EXTERNALIP) { connNet = CSB_NETSTATE_FORWARD; } @@ -272,7 +271,7 @@ uint32_t convertNetStateToInternal(uint32_t netmode, uint32_t nathole, uint32_t { connNet = CSB_NETSTATE_FORWARD; } - else if (netmode == RSNET_NETWORK_BEHINDNAT) + else if (netmode == RsNetworkMode::BEHINDNAT) { if ((nattype == RSNET_NATTYPE_RESTRICTED_CONE) || (nattype == RSNET_NATTYPE_FULL_CONE)) @@ -300,20 +299,20 @@ bool shouldUseProxyPortInternal(uint32_t netstate) return true; } -bool PeerConnectStateBox::shouldUseProxyPort(uint32_t netmode, uint32_t nathole, uint32_t nattype) +bool PeerConnectStateBox::shouldUseProxyPort(RsNetworkMode netmode, uint32_t nathole, uint32_t nattype) { uint32_t netstate = convertNetStateToInternal(netmode, nathole, nattype); return shouldUseProxyPortInternal(netstate); } -uint32_t PeerConnectStateBox::calcNetState(uint32_t netmode, uint32_t nathole, uint32_t nattype) +uint32_t PeerConnectStateBox::calcNetState(RsNetworkMode netmode, uint32_t nathole, uint32_t nattype) { uint32_t netstate = convertNetStateToInternal(netmode, nathole, nattype); return netstate; } -uint32_t PeerConnectStateBox::connectCb(uint32_t cbtype, uint32_t netmode, uint32_t nathole, uint32_t nattype) +uint32_t PeerConnectStateBox::connectCb(uint32_t cbtype, RsNetworkMode netmode, uint32_t nathole, uint32_t nattype) { uint32_t netstate = convertNetStateToInternal(netmode, nathole, nattype); diff --git a/libretroshare/src/dht/connectstatebox.h b/libretroshare/src/dht/connectstatebox.h index b50c50683..f50d6d0a4 100644 --- a/libretroshare/src/dht/connectstatebox.h +++ b/libretroshare/src/dht/connectstatebox.h @@ -75,17 +75,19 @@ #include "util/rstime.h" #include +#include + class PeerConnectStateBox { public: PeerConnectStateBox(); - uint32_t connectCb(uint32_t cbtype, uint32_t netmode, uint32_t nathole, uint32_t nattype); + uint32_t connectCb(uint32_t cbtype, RsNetworkMode netmode, uint32_t nathole, uint32_t nattype); uint32_t updateCb(uint32_t updateType); - bool shouldUseProxyPort(uint32_t netmode, uint32_t nathole, uint32_t nattype); + bool shouldUseProxyPort(RsNetworkMode netmode, uint32_t nathole, uint32_t nattype); - uint32_t calcNetState(uint32_t netmode, uint32_t nathole, uint32_t nattype); + uint32_t calcNetState(RsNetworkMode netmode, uint32_t nathole, uint32_t nattype); std::string connectState() const; std::string mPeerId; diff --git a/libretroshare/src/pqi/p3netmgr.cc b/libretroshare/src/pqi/p3netmgr.cc index 8eebd4c1e..78ee89c68 100644 --- a/libretroshare/src/pqi/p3netmgr.cc +++ b/libretroshare/src/pqi/p3netmgr.cc @@ -1633,7 +1633,7 @@ uint32_t p3NetMgrIMPL::getNetStateMode() return mNetStateBox.getNetStateMode(); } -uint32_t p3NetMgrIMPL::getNetworkMode() +RsNetworkMode p3NetMgrIMPL::getNetworkMode() { RsStackMutex stack(mNetMtx); /****** STACK LOCK MUTEX *******/ return mNetStateBox.getNetworkMode(); diff --git a/libretroshare/src/pqi/p3netmgr.h b/libretroshare/src/pqi/p3netmgr.h index f7775757d..76829feca 100644 --- a/libretroshare/src/pqi/p3netmgr.h +++ b/libretroshare/src/pqi/p3netmgr.h @@ -104,7 +104,7 @@ virtual bool netAssistStatusUpdate(const RsPeerId &id, int mode) = 0; /* Get Network State */ virtual uint32_t getNetStateMode() = 0; -virtual uint32_t getNetworkMode() = 0; +virtual RsNetworkMode getNetworkMode() = 0; virtual uint32_t getNatTypeMode() = 0; virtual uint32_t getNatHoleMode() = 0; virtual uint32_t getConnectModes() = 0; @@ -155,7 +155,7 @@ virtual bool netAssistStatusUpdate(const RsPeerId &id, int mode); /* Get Network State */ virtual uint32_t getNetStateMode(); -virtual uint32_t getNetworkMode(); +virtual RsNetworkMode getNetworkMode(); virtual uint32_t getNatTypeMode(); virtual uint32_t getNatHoleMode(); virtual uint32_t getConnectModes(); diff --git a/libretroshare/src/pqi/pqinetstatebox.cc b/libretroshare/src/pqi/pqinetstatebox.cc index c570440c6..4dae013c8 100644 --- a/libretroshare/src/pqi/pqinetstatebox.cc +++ b/libretroshare/src/pqi/pqinetstatebox.cc @@ -20,7 +20,6 @@ * * *******************************************************************************/ -#include "retroshare/rsconfig.h" #include "util/rsnet.h" #include "pqi/pqinetstatebox.h" #include "util/rstime.h" @@ -147,7 +146,7 @@ void pqiNetStateBox::setDhtState(bool on, bool active) /* Extract Net State */ -uint32_t pqiNetStateBox::getNetworkMode() +RsNetworkMode pqiNetStateBox::getNetworkMode() { updateNetState(); return mNetworkMode; @@ -193,7 +192,7 @@ void pqiNetStateBox::reset() mStatusOkay = false; //rstime_t mStatusTS; - mNetworkMode = RSNET_NETWORK_UNKNOWN; + mNetworkMode = RsNetworkMode::UNKNOWN; mNatTypeMode = RSNET_NATTYPE_UNKNOWN; mNatHoleMode = RSNET_NATHOLE_UNKNOWN; mConnectModes = RSNET_CONNECT_NONE; @@ -302,7 +301,7 @@ void pqiNetStateBox::determineNetworkState() /* firstly lets try to identify OFFLINE / UNKNOWN */ if ((!mStunProxySet) || (!mStunDhtSet)) { - mNetworkMode = RSNET_NETWORK_UNKNOWN; + mNetworkMode = RsNetworkMode::UNKNOWN; // Assume these. mNatTypeMode = RSNET_NATTYPE_UNKNOWN; mNatHoleMode = RSNET_NATHOLE_NONE; @@ -335,7 +334,7 @@ void pqiNetStateBox::determineNetworkState() * */ - mNetworkMode = RSNET_NETWORK_BEHINDNAT; + mNetworkMode = RsNetworkMode::BEHINDNAT; mNatTypeMode = RSNET_NATTYPE_DETERM_SYM; mNatHoleMode = RSNET_NATHOLE_NONE; mNetStateMode = RSNET_NETSTATE_WARNING_NATTED; @@ -344,7 +343,7 @@ void pqiNetStateBox::determineNetworkState() else if (!mStunProxyStable) { /* both unstable, Symmetric NAT, Firewalled, No UDP Hole */ - mNetworkMode = RSNET_NETWORK_BEHINDNAT; + mNetworkMode = RsNetworkMode::BEHINDNAT; mNatTypeMode = RSNET_NATTYPE_SYMMETRIC; mNatHoleMode = RSNET_NATHOLE_NONE; mNetStateMode = RSNET_NETSTATE_BAD_NATSYM; @@ -366,7 +365,7 @@ void pqiNetStateBox::determineNetworkState() * but that label is really fully accurate. (gray area). */ - mNetworkMode = RSNET_NETWORK_BEHINDNAT; + mNetworkMode = RsNetworkMode::BEHINDNAT; mNatTypeMode = RSNET_NATTYPE_RESTRICTED_CONE; mNatHoleMode = RSNET_NATHOLE_NONE; mNetStateMode = RSNET_NETSTATE_WARNING_NATTED; @@ -392,7 +391,7 @@ void pqiNetStateBox::determineNetworkState() if (mStunProxySemiStable) { /* must be a forwarded port/ext or something similar */ - mNetworkMode = RSNET_NETWORK_BEHINDNAT; + mNetworkMode = RsNetworkMode::BEHINDNAT; mNatTypeMode = RSNET_NATTYPE_DETERM_SYM; mNatHoleMode = RSNET_NATHOLE_FORWARDED; mNetStateMode = RSNET_NETSTATE_GOOD; @@ -400,7 +399,7 @@ void pqiNetStateBox::determineNetworkState() else if (!mStunProxyStable) { /* must be a forwarded port/ext or something similar */ - mNetworkMode = RSNET_NETWORK_BEHINDNAT; + mNetworkMode = RsNetworkMode::BEHINDNAT; mNatTypeMode = RSNET_NATTYPE_SYMMETRIC; mNatHoleMode = RSNET_NATHOLE_FORWARDED; mNetStateMode = RSNET_NETSTATE_GOOD; @@ -408,7 +407,7 @@ void pqiNetStateBox::determineNetworkState() else { /* fallback is FULL CONE NAT */ - mNetworkMode = RSNET_NETWORK_BEHINDNAT; + mNetworkMode = RsNetworkMode::BEHINDNAT; mNatTypeMode = RSNET_NATTYPE_FULL_CONE; mNatHoleMode = RSNET_NATHOLE_NONE; mNetStateMode = RSNET_NETSTATE_WARNING_NATTED; @@ -417,7 +416,7 @@ void pqiNetStateBox::determineNetworkState() if (mUPnPActive) { // This Mode is OKAY. - mNetworkMode = RSNET_NETWORK_BEHINDNAT; + mNetworkMode = RsNetworkMode::BEHINDNAT; // Use Fallback Guess. //mNatTypeMode = RSNET_NATTYPE_UNKNOWN; mNatHoleMode = RSNET_NATHOLE_UPNP; @@ -428,7 +427,7 @@ void pqiNetStateBox::determineNetworkState() else if (mNatPMPActive) { // This Mode is OKAY. - mNetworkMode = RSNET_NETWORK_BEHINDNAT; + mNetworkMode = RsNetworkMode::BEHINDNAT; // Use Fallback Guess. //mNatTypeMode = RSNET_NATTYPE_UNKNOWN; mNatHoleMode = RSNET_NATHOLE_NATPMP; @@ -442,7 +441,7 @@ void pqiNetStateBox::determineNetworkState() if (isExtAddress) { - mNetworkMode = RSNET_NETWORK_EXTERNALIP; + mNetworkMode = RsNetworkMode::EXTERNALIP; mNatTypeMode = RSNET_NATTYPE_NONE; mNatHoleMode = RSNET_NATHOLE_NONE; mNetStateMode = RSNET_NETSTATE_GOOD; @@ -451,7 +450,7 @@ void pqiNetStateBox::determineNetworkState() } else if (mPortForwardSet) { - mNetworkMode = RSNET_NETWORK_BEHINDNAT; + mNetworkMode = RsNetworkMode::BEHINDNAT; // Use Fallback Guess. //mNatTypeMode = RSNET_NATTYPE_UNKNOWN; mNatHoleMode = RSNET_NATHOLE_FORWARDED; @@ -479,7 +478,7 @@ void pqiNetStateBox::determineNetworkState() if (mUPnPActive) { // This Mode is OKAY. - mNetworkMode = RSNET_NETWORK_BEHINDNAT; + mNetworkMode = RsNetworkMode::BEHINDNAT; mNatTypeMode = RSNET_NATTYPE_UNKNOWN; mNatHoleMode = RSNET_NATHOLE_UPNP; //mExtAddress = ... from UPnP. @@ -489,7 +488,7 @@ void pqiNetStateBox::determineNetworkState() else if (mNatPMPActive) { // This Mode is OKAY. - mNetworkMode = RSNET_NETWORK_BEHINDNAT; + mNetworkMode = RsNetworkMode::BEHINDNAT; mNatTypeMode = RSNET_NATTYPE_UNKNOWN; mNatHoleMode = RSNET_NATHOLE_NATPMP; //mExtAddress = ... from NatPMP. @@ -506,7 +505,7 @@ void pqiNetStateBox::determineNetworkState() if (isExtAddress) { - mNetworkMode = RSNET_NETWORK_EXTERNALIP; + mNetworkMode = RsNetworkMode::EXTERNALIP; mNatTypeMode = RSNET_NATTYPE_NONE; mNatHoleMode = RSNET_NATHOLE_NONE; @@ -515,7 +514,7 @@ void pqiNetStateBox::determineNetworkState() } else if (mPortForwardSet) { - mNetworkMode = RSNET_NETWORK_BEHINDNAT; + mNetworkMode = RsNetworkMode::BEHINDNAT; mNatTypeMode = RSNET_NATTYPE_UNKNOWN; mNatHoleMode = RSNET_NATHOLE_FORWARDED; @@ -528,7 +527,7 @@ void pqiNetStateBox::determineNetworkState() * These people have destroyed the possibility of making connections ;( * Should WARN about this. */ - mNetworkMode = RSNET_NETWORK_BEHINDNAT; + mNetworkMode = RsNetworkMode::BEHINDNAT; mNatTypeMode = RSNET_NATTYPE_UNKNOWN; mNatHoleMode = RSNET_NATHOLE_NONE; mNetStateMode = RSNET_NETSTATE_BAD_NODHT_NAT; @@ -556,12 +555,13 @@ void pqiNetStateBox::workoutNetworkMode() mConnectModes = RSNET_CONNECT_NONE; switch(mNetworkMode) { - case RSNET_NETWORK_UNKNOWN: - case RSNET_NETWORK_OFFLINE: - case RSNET_NETWORK_LOCALNET: + case RsNetworkMode::UNKNOWN: + case RsNetworkMode::OFFLINE: + case RsNetworkMode::LOCALNET: + case RsNetworkMode::RESTARTING: /* nothing here */ break; - case RSNET_NETWORK_EXTERNALIP: + case RsNetworkMode::EXTERNALIP: mConnectModes = RSNET_CONNECT_OUTGOING_TCP; mConnectModes |= RSNET_CONNECT_ACCEPT_TCP; @@ -577,7 +577,7 @@ void pqiNetStateBox::workoutNetworkMode() //mConnectModes |= RSNET_CONNECT_RELAY_UDP; } break; - case RSNET_NETWORK_BEHINDNAT: + case RsNetworkMode::BEHINDNAT: mConnectModes = RSNET_CONNECT_OUTGOING_TCP; /* we're okay if there's a NAT HOLE */ @@ -616,33 +616,6 @@ void pqiNetStateBox::workoutNetworkMode() } - - -std::string NetStateNetworkModeString(uint32_t netMode) -{ - std::string str; - switch(netMode) - { - default: - case RSNET_NETWORK_UNKNOWN: - str = "Unknown NetState"; - break; - case RSNET_NETWORK_OFFLINE: - str = "Offline"; - break; - case RSNET_NETWORK_LOCALNET: - str = "Local Net"; - break; - case RSNET_NETWORK_BEHINDNAT: - str = "Behind NAT"; - break; - case RSNET_NETWORK_EXTERNALIP: - str = "External IP"; - break; - } - return str; -} - std::string NetStateNatTypeString(uint32_t natType) { std::string str; diff --git a/libretroshare/src/pqi/pqinetstatebox.h b/libretroshare/src/pqi/pqinetstatebox.h index d4d86afee..38d399024 100644 --- a/libretroshare/src/pqi/pqinetstatebox.h +++ b/libretroshare/src/pqi/pqinetstatebox.h @@ -27,6 +27,9 @@ #include #include +#include +#include + /*** Network state * Want this to be all encompassing. * @@ -52,7 +55,7 @@ class pqiNetStateBox void setDhtState(bool dhtOn, bool dhtActive); uint32_t getNetStateMode(); - uint32_t getNetworkMode(); + RsNetworkMode getNetworkMode(); uint32_t getNatTypeMode(); uint32_t getNatHoleMode(); uint32_t getConnectModes(); @@ -71,7 +74,7 @@ class pqiNetStateBox bool mStatusOkay; rstime_t mStatusTS; - uint32_t mNetworkMode; + RsNetworkMode mNetworkMode; uint32_t mNatTypeMode; uint32_t mNatHoleMode; uint32_t mConnectModes; @@ -120,7 +123,6 @@ std::string NetStateNetStateString(uint32_t netstate); std::string NetStateConnectModesString(uint32_t connect); std::string NetStateNatHoleString(uint32_t natHole); std::string NetStateNatTypeString(uint32_t natType); -std::string NetStateNetworkModeString(uint32_t netMode); #endif diff --git a/libretroshare/src/retroshare/rsconfig.h b/libretroshare/src/retroshare/rsconfig.h index b1522330a..f8239e2f1 100644 --- a/libretroshare/src/retroshare/rsconfig.h +++ b/libretroshare/src/retroshare/rsconfig.h @@ -37,12 +37,16 @@ class RsServerConfig; */ extern RsServerConfig *rsConfig; -#define RSNET_NETWORK_UNKNOWN 1 -#define RSNET_NETWORK_RESTARTING 2 -#define RSNET_NETWORK_OFFLINE 3 -#define RSNET_NETWORK_LOCALNET 4 -#define RSNET_NETWORK_BEHINDNAT 5 -#define RSNET_NETWORK_EXTERNALIP 6 +enum class RsNetworkMode : uint8_t +{ + UNKNOWN = 1, + RESTARTING = 2, + OFFLINE = 3, + LOCALNET = 4, + BEHINDNAT = 5, + EXTERNALIP = 6 +}; + // WHAT TYPE OF FIREWALL? #define RSNET_NATTYPE_NONE 1 @@ -351,7 +355,7 @@ public: virtual uint32_t getUserLevel() = 0; virtual uint32_t getNetState() = 0; - virtual uint32_t getNetworkMode() = 0; + virtual RsNetworkMode getNetworkMode() = 0; virtual uint32_t getNatTypeMode() = 0; virtual uint32_t getNatHoleMode() = 0; virtual uint32_t getConnectModes() = 0; diff --git a/libretroshare/src/rsserver/p3serverconfig.cc b/libretroshare/src/rsserver/p3serverconfig.cc index f31529fa3..0f97a6f03 100644 --- a/libretroshare/src/rsserver/p3serverconfig.cc +++ b/libretroshare/src/rsserver/p3serverconfig.cc @@ -305,11 +305,11 @@ uint32_t p3ServerConfig::getUserLevel() { /* check that the firewall is open */ - uint32_t netMode = mNetMgr->getNetworkMode(); + RsNetworkMode netMode = mNetMgr->getNetworkMode(); uint32_t firewallMode = mNetMgr->getNatHoleMode(); - if ((RSNET_NETWORK_EXTERNALIP == netMode) || - ((RSNET_NETWORK_BEHINDNAT == netMode) && + if ((RsNetworkMode::EXTERNALIP == netMode) || + ((RsNetworkMode::BEHINDNAT == netMode) && ((RSNET_NATHOLE_UPNP == firewallMode) || (RSNET_NATHOLE_NATPMP == firewallMode) || (RSNET_NATHOLE_FORWARDED == firewallMode)))) @@ -334,7 +334,7 @@ uint32_t p3ServerConfig::getNetState() return mNetMgr->getNetStateMode(); } -uint32_t p3ServerConfig::getNetworkMode() +RsNetworkMode p3ServerConfig::getNetworkMode() { return mNetMgr->getNetworkMode(); } diff --git a/libretroshare/src/rsserver/p3serverconfig.h b/libretroshare/src/rsserver/p3serverconfig.h index bcc0e587e..48edc8bd1 100644 --- a/libretroshare/src/rsserver/p3serverconfig.h +++ b/libretroshare/src/rsserver/p3serverconfig.h @@ -75,7 +75,7 @@ virtual std::string getRetroshareDataDirectory(); virtual uint32_t getUserLevel(); virtual uint32_t getNetState(); -virtual uint32_t getNetworkMode(); +virtual RsNetworkMode getNetworkMode(); virtual uint32_t getNatTypeMode(); virtual uint32_t getNatHoleMode(); virtual uint32_t getConnectModes(); diff --git a/retroshare-gui/src/gui/statistics/DhtWindow.cpp b/retroshare-gui/src/gui/statistics/DhtWindow.cpp index 648c25409..c365fd4a3 100644 --- a/retroshare-gui/src/gui/statistics/DhtWindow.cpp +++ b/retroshare-gui/src/gui/statistics/DhtWindow.cpp @@ -137,24 +137,27 @@ void DhtWindow::updateNetStatus() ui.peerAddressLabel->setText(status); } - uint32_t netMode = rsConfig->getNetworkMode(); + RsNetworkMode netMode = rsConfig->getNetworkMode(); QLabel *label = ui.networkLabel; switch(netMode) { - case RSNET_NETWORK_UNKNOWN: + case RsNetworkMode::UNKNOWN: label->setText(tr("Unknown NetState")); break; - case RSNET_NETWORK_OFFLINE: + case RsNetworkMode::RESTARTING: + label->setText(tr("Restarting")); + break; + case RsNetworkMode::OFFLINE: label->setText(tr("Offline")); break; - case RSNET_NETWORK_LOCALNET: + case RsNetworkMode::LOCALNET: label->setText(tr("Local Net")); break; - case RSNET_NETWORK_BEHINDNAT: + case RsNetworkMode::BEHINDNAT: label->setText(tr("Behind NAT")); break; - case RSNET_NETWORK_EXTERNALIP: + case RsNetworkMode::EXTERNALIP: label->setText(tr("External IP")); break; } From f81755e320da3dfa2f7770c4a23bd18fda57f976 Mon Sep 17 00:00:00 2001 From: sehraf Date: Sun, 9 Feb 2020 21:11:49 +0100 Subject: [PATCH 02/24] convert RSNET_NATTYPE to enum class --- libretroshare/src/dht/connectstatebox.cc | 14 ++-- libretroshare/src/dht/connectstatebox.h | 6 +- libretroshare/src/pqi/p3netmgr.cc | 36 +++++----- libretroshare/src/pqi/p3netmgr.h | 6 +- libretroshare/src/pqi/pqinetstatebox.cc | 74 ++++++-------------- libretroshare/src/pqi/pqinetstatebox.h | 5 +- libretroshare/src/retroshare/rsconfig.h | 20 +++--- libretroshare/src/rsserver/p3serverconfig.cc | 2 +- libretroshare/src/rsserver/p3serverconfig.h | 2 +- 9 files changed, 67 insertions(+), 98 deletions(-) diff --git a/libretroshare/src/dht/connectstatebox.cc b/libretroshare/src/dht/connectstatebox.cc index 06c155391..9d7d6ed5b 100644 --- a/libretroshare/src/dht/connectstatebox.cc +++ b/libretroshare/src/dht/connectstatebox.cc @@ -259,7 +259,7 @@ std::string PeerConnectStateBox::connectState() const } -uint32_t convertNetStateToInternal(RsNetworkMode netmode, uint32_t nathole, uint32_t nattype) +uint32_t convertNetStateToInternal(RsNetworkMode netmode, uint32_t nathole, RsNatTypeMode nattype) { uint32_t connNet = CSB_NETSTATE_UNKNOWN; @@ -273,12 +273,12 @@ uint32_t convertNetStateToInternal(RsNetworkMode netmode, uint32_t nathole, uint } else if (netmode == RsNetworkMode::BEHINDNAT) { - if ((nattype == RSNET_NATTYPE_RESTRICTED_CONE) || - (nattype == RSNET_NATTYPE_FULL_CONE)) + if ((nattype == RsNatTypeMode::RESTRICTED_CONE) || + (nattype == RsNatTypeMode::FULL_CONE)) { connNet = CSB_NETSTATE_STABLENAT; } - else if (nattype == RSNET_NATTYPE_DETERM_SYM) + else if (nattype == RsNatTypeMode::DETERM_SYM) { connNet = CSB_NETSTATE_EXCLUSIVENAT; } @@ -299,20 +299,20 @@ bool shouldUseProxyPortInternal(uint32_t netstate) return true; } -bool PeerConnectStateBox::shouldUseProxyPort(RsNetworkMode netmode, uint32_t nathole, uint32_t nattype) +bool PeerConnectStateBox::shouldUseProxyPort(RsNetworkMode netmode, uint32_t nathole, RsNatTypeMode nattype) { uint32_t netstate = convertNetStateToInternal(netmode, nathole, nattype); return shouldUseProxyPortInternal(netstate); } -uint32_t PeerConnectStateBox::calcNetState(RsNetworkMode netmode, uint32_t nathole, uint32_t nattype) +uint32_t PeerConnectStateBox::calcNetState(RsNetworkMode netmode, uint32_t nathole, RsNatTypeMode nattype) { uint32_t netstate = convertNetStateToInternal(netmode, nathole, nattype); return netstate; } -uint32_t PeerConnectStateBox::connectCb(uint32_t cbtype, RsNetworkMode netmode, uint32_t nathole, uint32_t nattype) +uint32_t PeerConnectStateBox::connectCb(uint32_t cbtype, RsNetworkMode netmode, uint32_t nathole, RsNatTypeMode nattype) { uint32_t netstate = convertNetStateToInternal(netmode, nathole, nattype); diff --git a/libretroshare/src/dht/connectstatebox.h b/libretroshare/src/dht/connectstatebox.h index f50d6d0a4..7b4c39535 100644 --- a/libretroshare/src/dht/connectstatebox.h +++ b/libretroshare/src/dht/connectstatebox.h @@ -82,12 +82,12 @@ class PeerConnectStateBox public: PeerConnectStateBox(); - uint32_t connectCb(uint32_t cbtype, RsNetworkMode netmode, uint32_t nathole, uint32_t nattype); + uint32_t connectCb(uint32_t cbtype, RsNetworkMode netmode, uint32_t nathole, RsNatTypeMode nattype); uint32_t updateCb(uint32_t updateType); - bool shouldUseProxyPort(RsNetworkMode netmode, uint32_t nathole, uint32_t nattype); + bool shouldUseProxyPort(RsNetworkMode netmode, uint32_t nathole, RsNatTypeMode nattype); - uint32_t calcNetState(RsNetworkMode netmode, uint32_t nathole, uint32_t nattype); + uint32_t calcNetState(RsNetworkMode netmode, uint32_t nathole, RsNatTypeMode nattype); std::string connectState() const; std::string mPeerId; diff --git a/libretroshare/src/pqi/p3netmgr.cc b/libretroshare/src/pqi/p3netmgr.cc index 78ee89c68..3203dfa7f 100644 --- a/libretroshare/src/pqi/p3netmgr.cc +++ b/libretroshare/src/pqi/p3netmgr.cc @@ -124,7 +124,7 @@ p3NetMgrIMPL::p3NetMgrIMPL() : mPeerMgr(nullptr), mLinkMgr(nullptr), mNetFlags = pqiNetStatus(); mOldNetFlags = pqiNetStatus(); - mOldNatType = RSNET_NATTYPE_UNKNOWN; + mOldNatType = RsNatTypeMode::UNKNOWN; mOldNatHole = RSNET_NATHOLE_UNKNOWN; sockaddr_storage_clear(mLocalAddr); sockaddr_storage_clear(mExtAddr); @@ -1639,7 +1639,7 @@ RsNetworkMode p3NetMgrIMPL::getNetworkMode() return mNetStateBox.getNetworkMode(); } -uint32_t p3NetMgrIMPL::getNatTypeMode() +RsNatTypeMode p3NetMgrIMPL::getNatTypeMode() { RsStackMutex stack(mNetMtx); /****** STACK LOCK MUTEX *******/ return mNetStateBox.getNatTypeMode(); @@ -1766,7 +1766,7 @@ void p3NetMgrIMPL::updateNetStateBox_temporal() void p3NetMgrIMPL::updateNatSetting() { bool updateRefreshRate = false; - uint32_t natType = RSNET_NATTYPE_UNKNOWN; + RsNatTypeMode natType = RsNatTypeMode::UNKNOWN; uint32_t natHole = RSNET_NATHOLE_UNKNOWN; { RsStackMutex stack(mNetMtx); /****** STACK LOCK MUTEX *******/ @@ -1803,7 +1803,7 @@ void p3NetMgrIMPL::updateNatSetting() #ifdef RS_USE_DHT_STUNNER switch(natType) { - case RSNET_NATTYPE_RESTRICTED_CONE: + case RsNatTypeMode::RESTRICTED_CONE: { if ((natHole == RSNET_NATHOLE_NONE) || (natHole == RSNET_NATHOLE_UNKNOWN)) { @@ -1815,12 +1815,12 @@ void p3NetMgrIMPL::updateNatSetting() } break; } - case RSNET_NATTYPE_NONE: - case RSNET_NATTYPE_UNKNOWN: - case RSNET_NATTYPE_SYMMETRIC: - case RSNET_NATTYPE_DETERM_SYM: - case RSNET_NATTYPE_FULL_CONE: - case RSNET_NATTYPE_OTHER: + case RsNatTypeMode::NONE: + case RsNatTypeMode::UNKNOWN: + case RsNatTypeMode::SYMMETRIC: + case RsNatTypeMode::DETERM_SYM: + case RsNatTypeMode::FULL_CONE: + case RsNatTypeMode::OTHER: mProxyStunner->setRefreshPeriod(NET_STUNNER_PERIOD_SLOW); break; @@ -1837,17 +1837,17 @@ void p3NetMgrIMPL::updateNatSetting() switch(natType) { /* switch to attach mode if we have a bad firewall */ - case RSNET_NATTYPE_UNKNOWN: - case RSNET_NATTYPE_SYMMETRIC: - case RSNET_NATTYPE_RESTRICTED_CONE: - case RSNET_NATTYPE_DETERM_SYM: - case RSNET_NATTYPE_OTHER: + case RsNatTypeMode::UNKNOWN: + case RsNatTypeMode::SYMMETRIC: + case RsNatTypeMode::RESTRICTED_CONE: + case RsNatTypeMode::DETERM_SYM: + case RsNatTypeMode::OTHER: netAssistAttach(true); break; /* switch off attach mode if we have a nice firewall */ - case RSNET_NATTYPE_NONE: - case RSNET_NATTYPE_FULL_CONE: + case RsNatTypeMode::NONE: + case RsNatTypeMode::FULL_CONE: netAssistAttach(false); break; } @@ -1967,7 +1967,7 @@ void p3NetMgrIMPL::updateNetStateBox_reset() mNetStateBox.reset(); mOldNatHole = RSNET_NATHOLE_UNKNOWN; - mOldNatType = RSNET_NATTYPE_UNKNOWN; + mOldNatType = RsNatTypeMode::UNKNOWN; } } diff --git a/libretroshare/src/pqi/p3netmgr.h b/libretroshare/src/pqi/p3netmgr.h index 76829feca..5a0ffbce2 100644 --- a/libretroshare/src/pqi/p3netmgr.h +++ b/libretroshare/src/pqi/p3netmgr.h @@ -105,7 +105,7 @@ virtual bool netAssistStatusUpdate(const RsPeerId &id, int mode) = 0; /* Get Network State */ virtual uint32_t getNetStateMode() = 0; virtual RsNetworkMode getNetworkMode() = 0; -virtual uint32_t getNatTypeMode() = 0; +virtual RsNatTypeMode getNatTypeMode() = 0; virtual uint32_t getNatHoleMode() = 0; virtual uint32_t getConnectModes() = 0; @@ -156,7 +156,7 @@ virtual bool netAssistStatusUpdate(const RsPeerId &id, int mode); /* Get Network State */ virtual uint32_t getNetStateMode(); virtual RsNetworkMode getNetworkMode(); -virtual uint32_t getNatTypeMode(); +virtual RsNatTypeMode getNatTypeMode(); virtual uint32_t getNatHoleMode(); virtual uint32_t getConnectModes(); @@ -323,7 +323,7 @@ void netStatusReset_locked(); pqiNetStateBox mNetStateBox; rstime_t mDoNotNetCheckUntilTs; - uint32_t mOldNatType; + RsNatTypeMode mOldNatType; uint32_t mOldNatHole; RS_SET_CONTEXT_DEBUG_LEVEL(2) diff --git a/libretroshare/src/pqi/pqinetstatebox.cc b/libretroshare/src/pqi/pqinetstatebox.cc index 4dae013c8..3a79d6e33 100644 --- a/libretroshare/src/pqi/pqinetstatebox.cc +++ b/libretroshare/src/pqi/pqinetstatebox.cc @@ -152,7 +152,7 @@ RsNetworkMode pqiNetStateBox::getNetworkMode() return mNetworkMode; } -uint32_t pqiNetStateBox::getNatTypeMode() +RsNatTypeMode pqiNetStateBox::getNatTypeMode() { updateNetState(); return mNatTypeMode; @@ -193,7 +193,7 @@ void pqiNetStateBox::reset() //rstime_t mStatusTS; mNetworkMode = RsNetworkMode::UNKNOWN; - mNatTypeMode = RSNET_NATTYPE_UNKNOWN; + mNatTypeMode = RsNatTypeMode::UNKNOWN; mNatHoleMode = RSNET_NATHOLE_UNKNOWN; mConnectModes = RSNET_CONNECT_NONE; mNetStateMode = RSNET_NETSTATE_BAD_UNKNOWN; @@ -303,7 +303,7 @@ void pqiNetStateBox::determineNetworkState() { mNetworkMode = RsNetworkMode::UNKNOWN; // Assume these. - mNatTypeMode = RSNET_NATTYPE_UNKNOWN; + mNatTypeMode = RsNatTypeMode::UNKNOWN; mNatHoleMode = RSNET_NATHOLE_NONE; mNetStateMode = RSNET_NETSTATE_BAD_UNKNOWN; @@ -335,7 +335,7 @@ void pqiNetStateBox::determineNetworkState() */ mNetworkMode = RsNetworkMode::BEHINDNAT; - mNatTypeMode = RSNET_NATTYPE_DETERM_SYM; + mNatTypeMode = RsNatTypeMode::DETERM_SYM; mNatHoleMode = RSNET_NATHOLE_NONE; mNetStateMode = RSNET_NETSTATE_WARNING_NATTED; @@ -344,7 +344,7 @@ void pqiNetStateBox::determineNetworkState() { /* both unstable, Symmetric NAT, Firewalled, No UDP Hole */ mNetworkMode = RsNetworkMode::BEHINDNAT; - mNatTypeMode = RSNET_NATTYPE_SYMMETRIC; + mNatTypeMode = RsNatTypeMode::SYMMETRIC; mNatHoleMode = RSNET_NATHOLE_NONE; mNetStateMode = RSNET_NETSTATE_BAD_NATSYM; } @@ -366,7 +366,7 @@ void pqiNetStateBox::determineNetworkState() */ mNetworkMode = RsNetworkMode::BEHINDNAT; - mNatTypeMode = RSNET_NATTYPE_RESTRICTED_CONE; + mNatTypeMode = RsNatTypeMode::RESTRICTED_CONE; mNatHoleMode = RSNET_NATHOLE_NONE; mNetStateMode = RSNET_NETSTATE_WARNING_NATTED; } @@ -392,7 +392,7 @@ void pqiNetStateBox::determineNetworkState() { /* must be a forwarded port/ext or something similar */ mNetworkMode = RsNetworkMode::BEHINDNAT; - mNatTypeMode = RSNET_NATTYPE_DETERM_SYM; + mNatTypeMode = RsNatTypeMode::DETERM_SYM; mNatHoleMode = RSNET_NATHOLE_FORWARDED; mNetStateMode = RSNET_NETSTATE_GOOD; } @@ -400,7 +400,7 @@ void pqiNetStateBox::determineNetworkState() { /* must be a forwarded port/ext or something similar */ mNetworkMode = RsNetworkMode::BEHINDNAT; - mNatTypeMode = RSNET_NATTYPE_SYMMETRIC; + mNatTypeMode = RsNatTypeMode::SYMMETRIC; mNatHoleMode = RSNET_NATHOLE_FORWARDED; mNetStateMode = RSNET_NETSTATE_GOOD; } @@ -408,7 +408,7 @@ void pqiNetStateBox::determineNetworkState() { /* fallback is FULL CONE NAT */ mNetworkMode = RsNetworkMode::BEHINDNAT; - mNatTypeMode = RSNET_NATTYPE_FULL_CONE; + mNatTypeMode = RsNatTypeMode::FULL_CONE; mNatHoleMode = RSNET_NATHOLE_NONE; mNetStateMode = RSNET_NETSTATE_WARNING_NATTED; } @@ -418,7 +418,7 @@ void pqiNetStateBox::determineNetworkState() // This Mode is OKAY. mNetworkMode = RsNetworkMode::BEHINDNAT; // Use Fallback Guess. - //mNatTypeMode = RSNET_NATTYPE_UNKNOWN; + //mNatTypeMode = RsNatTypeMode::UNKNOWN; mNatHoleMode = RSNET_NATHOLE_UPNP; mNetStateMode = RSNET_NETSTATE_GOOD; //mExtAddress = ... from UPnP, should match StunDht. @@ -429,7 +429,7 @@ void pqiNetStateBox::determineNetworkState() // This Mode is OKAY. mNetworkMode = RsNetworkMode::BEHINDNAT; // Use Fallback Guess. - //mNatTypeMode = RSNET_NATTYPE_UNKNOWN; + //mNatTypeMode = RsNatTypeMode::UNKNOWN; mNatHoleMode = RSNET_NATHOLE_NATPMP; mNetStateMode = RSNET_NETSTATE_GOOD; //mExtAddress = ... from NatPMP, should match NatPMP @@ -442,7 +442,7 @@ void pqiNetStateBox::determineNetworkState() if (isExtAddress) { mNetworkMode = RsNetworkMode::EXTERNALIP; - mNatTypeMode = RSNET_NATTYPE_NONE; + mNatTypeMode = RsNatTypeMode::NONE; mNatHoleMode = RSNET_NATHOLE_NONE; mNetStateMode = RSNET_NETSTATE_GOOD; @@ -452,7 +452,7 @@ void pqiNetStateBox::determineNetworkState() { mNetworkMode = RsNetworkMode::BEHINDNAT; // Use Fallback Guess. - //mNatTypeMode = RSNET_NATTYPE_UNKNOWN; + //mNatTypeMode = RsNatTypeMode::UNKNOWN; mNatHoleMode = RSNET_NATHOLE_FORWARDED; mNetStateMode = RSNET_NETSTATE_ADV_FORWARD; @@ -479,7 +479,7 @@ void pqiNetStateBox::determineNetworkState() { // This Mode is OKAY. mNetworkMode = RsNetworkMode::BEHINDNAT; - mNatTypeMode = RSNET_NATTYPE_UNKNOWN; + mNatTypeMode = RsNatTypeMode::UNKNOWN; mNatHoleMode = RSNET_NATHOLE_UPNP; //mExtAddress = ... from UPnP. //mExtAddrStable = true; @@ -489,7 +489,7 @@ void pqiNetStateBox::determineNetworkState() { // This Mode is OKAY. mNetworkMode = RsNetworkMode::BEHINDNAT; - mNatTypeMode = RSNET_NATTYPE_UNKNOWN; + mNatTypeMode = RsNatTypeMode::UNKNOWN; mNatHoleMode = RSNET_NATHOLE_NATPMP; //mExtAddress = ... from NatPMP. //mExtAddrStable = true; @@ -506,7 +506,7 @@ void pqiNetStateBox::determineNetworkState() if (isExtAddress) { mNetworkMode = RsNetworkMode::EXTERNALIP; - mNatTypeMode = RSNET_NATTYPE_NONE; + mNatTypeMode = RsNatTypeMode::NONE; mNatHoleMode = RSNET_NATHOLE_NONE; //mExtAddrStable = true; @@ -515,7 +515,7 @@ void pqiNetStateBox::determineNetworkState() else if (mPortForwardSet) { mNetworkMode = RsNetworkMode::BEHINDNAT; - mNatTypeMode = RSNET_NATTYPE_UNKNOWN; + mNatTypeMode = RsNatTypeMode::UNKNOWN; mNatHoleMode = RSNET_NATHOLE_FORWARDED; //mExtAddrStable = true; // Probably, makin assumption. @@ -528,7 +528,7 @@ void pqiNetStateBox::determineNetworkState() * Should WARN about this. */ mNetworkMode = RsNetworkMode::BEHINDNAT; - mNatTypeMode = RSNET_NATTYPE_UNKNOWN; + mNatTypeMode = RsNatTypeMode::UNKNOWN; mNatHoleMode = RSNET_NATHOLE_NONE; mNetStateMode = RSNET_NETSTATE_BAD_NODHT_NAT; @@ -603,9 +603,9 @@ void pqiNetStateBox::workoutNetworkMode() mConnectModes |= RSNET_CONNECT_DIRECT_UDP; mConnectModes |= RSNET_CONNECT_RELAY_UDP; - if ((mNatTypeMode == RSNET_NATTYPE_RESTRICTED_CONE) || - (mNatTypeMode == RSNET_NATTYPE_FULL_CONE) || - (mNatTypeMode == RSNET_NATTYPE_DETERM_SYM)) + if ((mNatTypeMode == RsNatTypeMode::RESTRICTED_CONE) || + (mNatTypeMode == RsNatTypeMode::FULL_CONE) || + (mNatTypeMode == RsNatTypeMode::DETERM_SYM)) { mConnectModes |= RSNET_CONNECT_PROXY_UDP; } @@ -615,38 +615,6 @@ void pqiNetStateBox::workoutNetworkMode() } } - -std::string NetStateNatTypeString(uint32_t natType) -{ - std::string str; - switch(natType) - { - default: - case RSNET_NATTYPE_UNKNOWN: - str = "UNKNOWN NAT STATE"; - break; - case RSNET_NATTYPE_SYMMETRIC: - str = "SYMMETRIC NAT"; - break; - case RSNET_NATTYPE_DETERM_SYM: - str = "DETERMINISTIC SYM NAT"; - break; - case RSNET_NATTYPE_RESTRICTED_CONE: - str = "RESTRICTED CONE NAT"; - break; - case RSNET_NATTYPE_FULL_CONE: - str = "FULL CONE NAT"; - break; - case RSNET_NATTYPE_OTHER: - str = "OTHER NAT"; - break; - case RSNET_NATTYPE_NONE: - str = "NO NAT"; - break; - } - return str; -} - std::string NetStateNatHoleString(uint32_t natHole) { diff --git a/libretroshare/src/pqi/pqinetstatebox.h b/libretroshare/src/pqi/pqinetstatebox.h index 38d399024..0c48416e5 100644 --- a/libretroshare/src/pqi/pqinetstatebox.h +++ b/libretroshare/src/pqi/pqinetstatebox.h @@ -56,7 +56,7 @@ class pqiNetStateBox uint32_t getNetStateMode(); RsNetworkMode getNetworkMode(); - uint32_t getNatTypeMode(); + RsNatTypeMode getNatTypeMode(); uint32_t getNatHoleMode(); uint32_t getConnectModes(); @@ -75,7 +75,7 @@ class pqiNetStateBox rstime_t mStatusTS; RsNetworkMode mNetworkMode; - uint32_t mNatTypeMode; + RsNatTypeMode mNatTypeMode; uint32_t mNatHoleMode; uint32_t mConnectModes; uint32_t mNetStateMode; @@ -122,7 +122,6 @@ class pqiNetStateBox std::string NetStateNetStateString(uint32_t netstate); std::string NetStateConnectModesString(uint32_t connect); std::string NetStateNatHoleString(uint32_t natHole); -std::string NetStateNatTypeString(uint32_t natType); #endif diff --git a/libretroshare/src/retroshare/rsconfig.h b/libretroshare/src/retroshare/rsconfig.h index f8239e2f1..91df4d059 100644 --- a/libretroshare/src/retroshare/rsconfig.h +++ b/libretroshare/src/retroshare/rsconfig.h @@ -48,14 +48,16 @@ enum class RsNetworkMode : uint8_t }; -// WHAT TYPE OF FIREWALL? -#define RSNET_NATTYPE_NONE 1 -#define RSNET_NATTYPE_UNKNOWN 2 -#define RSNET_NATTYPE_SYMMETRIC 3 -#define RSNET_NATTYPE_DETERM_SYM 4 -#define RSNET_NATTYPE_RESTRICTED_CONE 5 -#define RSNET_NATTYPE_FULL_CONE 6 -#define RSNET_NATTYPE_OTHER 7 +enum class RsNatTypeMode : uint8_t +{ + NONE = 1, + UNKNOWN = 2, + SYMMETRIC = 3, + DETERM_SYM = 4, + RESTRICTED_CONE = 5, + FULL_CONE = 6, + OTHER = 7 +}; // WHAT TYPE OF HOLE? #define RSNET_NATHOLE_UNKNOWN 0 @@ -356,7 +358,7 @@ public: virtual uint32_t getNetState() = 0; virtual RsNetworkMode getNetworkMode() = 0; - virtual uint32_t getNatTypeMode() = 0; + virtual RsNatTypeMode getNatTypeMode() = 0; virtual uint32_t getNatHoleMode() = 0; virtual uint32_t getConnectModes() = 0; diff --git a/libretroshare/src/rsserver/p3serverconfig.cc b/libretroshare/src/rsserver/p3serverconfig.cc index 0f97a6f03..d6c88816d 100644 --- a/libretroshare/src/rsserver/p3serverconfig.cc +++ b/libretroshare/src/rsserver/p3serverconfig.cc @@ -339,7 +339,7 @@ RsNetworkMode p3ServerConfig::getNetworkMode() return mNetMgr->getNetworkMode(); } -uint32_t p3ServerConfig::getNatTypeMode() +RsNatTypeMode p3ServerConfig::getNatTypeMode() { return mNetMgr->getNatTypeMode(); } diff --git a/libretroshare/src/rsserver/p3serverconfig.h b/libretroshare/src/rsserver/p3serverconfig.h index 48edc8bd1..7aacff13f 100644 --- a/libretroshare/src/rsserver/p3serverconfig.h +++ b/libretroshare/src/rsserver/p3serverconfig.h @@ -76,7 +76,7 @@ virtual uint32_t getUserLevel(); virtual uint32_t getNetState(); virtual RsNetworkMode getNetworkMode(); -virtual uint32_t getNatTypeMode(); +virtual RsNatTypeMode getNatTypeMode(); virtual uint32_t getNatHoleMode(); virtual uint32_t getConnectModes(); From d3101028087c79836aaf5353753fc89d72c11995 Mon Sep 17 00:00:00 2001 From: sehraf Date: Sun, 9 Feb 2020 21:25:19 +0100 Subject: [PATCH 03/24] convert RSNET_NATHOLE to enum class --- libretroshare/src/dht/connectstatebox.cc | 10 +-- libretroshare/src/dht/connectstatebox.h | 6 +- libretroshare/src/pqi/p3netmgr.cc | 12 ++-- libretroshare/src/pqi/p3netmgr.h | 6 +- libretroshare/src/pqi/pqinetstatebox.cc | 68 ++++++------------- libretroshare/src/pqi/pqinetstatebox.h | 5 +- libretroshare/src/retroshare/rsconfig.h | 17 ++--- libretroshare/src/rsserver/p3serverconfig.cc | 10 +-- libretroshare/src/rsserver/p3serverconfig.h | 2 +- .../src/gui/statistics/DhtWindow.cpp | 28 ++++---- 10 files changed, 69 insertions(+), 95 deletions(-) diff --git a/libretroshare/src/dht/connectstatebox.cc b/libretroshare/src/dht/connectstatebox.cc index 9d7d6ed5b..c1a0c4ff2 100644 --- a/libretroshare/src/dht/connectstatebox.cc +++ b/libretroshare/src/dht/connectstatebox.cc @@ -259,7 +259,7 @@ std::string PeerConnectStateBox::connectState() const } -uint32_t convertNetStateToInternal(RsNetworkMode netmode, uint32_t nathole, RsNatTypeMode nattype) +uint32_t convertNetStateToInternal(RsNetworkMode netmode, RsNatHoleMode nathole, RsNatTypeMode nattype) { uint32_t connNet = CSB_NETSTATE_UNKNOWN; @@ -267,7 +267,7 @@ uint32_t convertNetStateToInternal(RsNetworkMode netmode, uint32_t nathole, RsNa { connNet = CSB_NETSTATE_FORWARD; } - else if ((nathole != RSNET_NATHOLE_UNKNOWN) && (nathole != RSNET_NATHOLE_NONE)) + else if ((nathole != RsNatHoleMode::UNKNOWN) && (nathole != RsNatHoleMode::NONE)) { connNet = CSB_NETSTATE_FORWARD; } @@ -299,20 +299,20 @@ bool shouldUseProxyPortInternal(uint32_t netstate) return true; } -bool PeerConnectStateBox::shouldUseProxyPort(RsNetworkMode netmode, uint32_t nathole, RsNatTypeMode nattype) +bool PeerConnectStateBox::shouldUseProxyPort(RsNetworkMode netmode, RsNatHoleMode nathole, RsNatTypeMode nattype) { uint32_t netstate = convertNetStateToInternal(netmode, nathole, nattype); return shouldUseProxyPortInternal(netstate); } -uint32_t PeerConnectStateBox::calcNetState(RsNetworkMode netmode, uint32_t nathole, RsNatTypeMode nattype) +uint32_t PeerConnectStateBox::calcNetState(RsNetworkMode netmode, RsNatHoleMode nathole, RsNatTypeMode nattype) { uint32_t netstate = convertNetStateToInternal(netmode, nathole, nattype); return netstate; } -uint32_t PeerConnectStateBox::connectCb(uint32_t cbtype, RsNetworkMode netmode, uint32_t nathole, RsNatTypeMode nattype) +uint32_t PeerConnectStateBox::connectCb(uint32_t cbtype, RsNetworkMode netmode, RsNatHoleMode nathole, RsNatTypeMode nattype) { uint32_t netstate = convertNetStateToInternal(netmode, nathole, nattype); diff --git a/libretroshare/src/dht/connectstatebox.h b/libretroshare/src/dht/connectstatebox.h index 7b4c39535..20c6fdb20 100644 --- a/libretroshare/src/dht/connectstatebox.h +++ b/libretroshare/src/dht/connectstatebox.h @@ -82,12 +82,12 @@ class PeerConnectStateBox public: PeerConnectStateBox(); - uint32_t connectCb(uint32_t cbtype, RsNetworkMode netmode, uint32_t nathole, RsNatTypeMode nattype); + uint32_t connectCb(uint32_t cbtype, RsNetworkMode netmode, RsNatHoleMode nathole, RsNatTypeMode nattype); uint32_t updateCb(uint32_t updateType); - bool shouldUseProxyPort(RsNetworkMode netmode, uint32_t nathole, RsNatTypeMode nattype); + bool shouldUseProxyPort(RsNetworkMode netmode, RsNatHoleMode nathole, RsNatTypeMode nattype); - uint32_t calcNetState(RsNetworkMode netmode, uint32_t nathole, RsNatTypeMode nattype); + uint32_t calcNetState(RsNetworkMode netmode, RsNatHoleMode nathole, RsNatTypeMode nattype); std::string connectState() const; std::string mPeerId; diff --git a/libretroshare/src/pqi/p3netmgr.cc b/libretroshare/src/pqi/p3netmgr.cc index 3203dfa7f..f8ba2963b 100644 --- a/libretroshare/src/pqi/p3netmgr.cc +++ b/libretroshare/src/pqi/p3netmgr.cc @@ -125,7 +125,7 @@ p3NetMgrIMPL::p3NetMgrIMPL() : mPeerMgr(nullptr), mLinkMgr(nullptr), mOldNetFlags = pqiNetStatus(); mOldNatType = RsNatTypeMode::UNKNOWN; - mOldNatHole = RSNET_NATHOLE_UNKNOWN; + mOldNatHole = RsNatHoleMode::UNKNOWN; sockaddr_storage_clear(mLocalAddr); sockaddr_storage_clear(mExtAddr); @@ -1645,7 +1645,7 @@ RsNatTypeMode p3NetMgrIMPL::getNatTypeMode() return mNetStateBox.getNatTypeMode(); } -uint32_t p3NetMgrIMPL::getNatHoleMode() +RsNatHoleMode p3NetMgrIMPL::getNatHoleMode() { RsStackMutex stack(mNetMtx); /****** STACK LOCK MUTEX *******/ return mNetStateBox.getNatHoleMode(); @@ -1767,7 +1767,7 @@ void p3NetMgrIMPL::updateNatSetting() { bool updateRefreshRate = false; RsNatTypeMode natType = RsNatTypeMode::UNKNOWN; - uint32_t natHole = RSNET_NATHOLE_UNKNOWN; + RsNatHoleMode natHole = RsNatHoleMode::UNKNOWN; { RsStackMutex stack(mNetMtx); /****** STACK LOCK MUTEX *******/ @@ -1805,7 +1805,7 @@ void p3NetMgrIMPL::updateNatSetting() { case RsNatTypeMode::RESTRICTED_CONE: { - if ((natHole == RSNET_NATHOLE_NONE) || (natHole == RSNET_NATHOLE_UNKNOWN)) + if ((natHole == RsNatHoleMode::NONE) || (natHole == RsNatHoleMode::UNKNOWN)) { mProxyStunner->setRefreshPeriod(NET_STUNNER_PERIOD_FAST); } @@ -1832,7 +1832,7 @@ void p3NetMgrIMPL::updateNatSetting() * So that messages can get through. * We only want to be attached - if we don't have a stable DHT port. */ - if ((natHole == RSNET_NATHOLE_NONE) || (natHole == RSNET_NATHOLE_UNKNOWN)) + if ((natHole == RsNatHoleMode::NONE) || (natHole == RsNatHoleMode::UNKNOWN)) { switch(natType) { @@ -1966,7 +1966,7 @@ void p3NetMgrIMPL::updateNetStateBox_reset() mNetStateBox.reset(); - mOldNatHole = RSNET_NATHOLE_UNKNOWN; + mOldNatHole = RsNatHoleMode::UNKNOWN; mOldNatType = RsNatTypeMode::UNKNOWN; } diff --git a/libretroshare/src/pqi/p3netmgr.h b/libretroshare/src/pqi/p3netmgr.h index 5a0ffbce2..513080351 100644 --- a/libretroshare/src/pqi/p3netmgr.h +++ b/libretroshare/src/pqi/p3netmgr.h @@ -106,7 +106,7 @@ virtual bool netAssistStatusUpdate(const RsPeerId &id, int mode) = 0; virtual uint32_t getNetStateMode() = 0; virtual RsNetworkMode getNetworkMode() = 0; virtual RsNatTypeMode getNatTypeMode() = 0; -virtual uint32_t getNatHoleMode() = 0; +virtual RsNatHoleMode getNatHoleMode() = 0; virtual uint32_t getConnectModes() = 0; /* Shut It Down! */ @@ -157,7 +157,7 @@ virtual bool netAssistStatusUpdate(const RsPeerId &id, int mode); virtual uint32_t getNetStateMode(); virtual RsNetworkMode getNetworkMode(); virtual RsNatTypeMode getNatTypeMode(); -virtual uint32_t getNatHoleMode(); +virtual RsNatHoleMode getNatHoleMode(); virtual uint32_t getConnectModes(); /* Shut It Down! */ @@ -324,7 +324,7 @@ void netStatusReset_locked(); rstime_t mDoNotNetCheckUntilTs; RsNatTypeMode mOldNatType; - uint32_t mOldNatHole; + RsNatHoleMode mOldNatHole; RS_SET_CONTEXT_DEBUG_LEVEL(2) }; diff --git a/libretroshare/src/pqi/pqinetstatebox.cc b/libretroshare/src/pqi/pqinetstatebox.cc index 3a79d6e33..a392f0f74 100644 --- a/libretroshare/src/pqi/pqinetstatebox.cc +++ b/libretroshare/src/pqi/pqinetstatebox.cc @@ -158,7 +158,7 @@ RsNatTypeMode pqiNetStateBox::getNatTypeMode() return mNatTypeMode; } -uint32_t pqiNetStateBox::getNatHoleMode() +RsNatHoleMode pqiNetStateBox::getNatHoleMode() { updateNetState(); return mNatHoleMode; @@ -194,7 +194,7 @@ void pqiNetStateBox::reset() mNetworkMode = RsNetworkMode::UNKNOWN; mNatTypeMode = RsNatTypeMode::UNKNOWN; - mNatHoleMode = RSNET_NATHOLE_UNKNOWN; + mNatHoleMode = RsNatHoleMode::UNKNOWN; mConnectModes = RSNET_CONNECT_NONE; mNetStateMode = RSNET_NETSTATE_BAD_UNKNOWN; @@ -304,7 +304,7 @@ void pqiNetStateBox::determineNetworkState() mNetworkMode = RsNetworkMode::UNKNOWN; // Assume these. mNatTypeMode = RsNatTypeMode::UNKNOWN; - mNatHoleMode = RSNET_NATHOLE_NONE; + mNatHoleMode = RsNatHoleMode::NONE; mNetStateMode = RSNET_NETSTATE_BAD_UNKNOWN; //mExtAddress = .... unknown; @@ -336,7 +336,7 @@ void pqiNetStateBox::determineNetworkState() mNetworkMode = RsNetworkMode::BEHINDNAT; mNatTypeMode = RsNatTypeMode::DETERM_SYM; - mNatHoleMode = RSNET_NATHOLE_NONE; + mNatHoleMode = RsNatHoleMode::NONE; mNetStateMode = RSNET_NETSTATE_WARNING_NATTED; } @@ -345,7 +345,7 @@ void pqiNetStateBox::determineNetworkState() /* both unstable, Symmetric NAT, Firewalled, No UDP Hole */ mNetworkMode = RsNetworkMode::BEHINDNAT; mNatTypeMode = RsNatTypeMode::SYMMETRIC; - mNatHoleMode = RSNET_NATHOLE_NONE; + mNatHoleMode = RsNatHoleMode::NONE; mNetStateMode = RSNET_NETSTATE_BAD_NATSYM; } else @@ -367,7 +367,7 @@ void pqiNetStateBox::determineNetworkState() mNetworkMode = RsNetworkMode::BEHINDNAT; mNatTypeMode = RsNatTypeMode::RESTRICTED_CONE; - mNatHoleMode = RSNET_NATHOLE_NONE; + mNatHoleMode = RsNatHoleMode::NONE; mNetStateMode = RSNET_NETSTATE_WARNING_NATTED; } } @@ -393,7 +393,7 @@ void pqiNetStateBox::determineNetworkState() /* must be a forwarded port/ext or something similar */ mNetworkMode = RsNetworkMode::BEHINDNAT; mNatTypeMode = RsNatTypeMode::DETERM_SYM; - mNatHoleMode = RSNET_NATHOLE_FORWARDED; + mNatHoleMode = RsNatHoleMode::FORWARDED; mNetStateMode = RSNET_NETSTATE_GOOD; } else if (!mStunProxyStable) @@ -401,7 +401,7 @@ void pqiNetStateBox::determineNetworkState() /* must be a forwarded port/ext or something similar */ mNetworkMode = RsNetworkMode::BEHINDNAT; mNatTypeMode = RsNatTypeMode::SYMMETRIC; - mNatHoleMode = RSNET_NATHOLE_FORWARDED; + mNatHoleMode = RsNatHoleMode::FORWARDED; mNetStateMode = RSNET_NETSTATE_GOOD; } else @@ -409,7 +409,7 @@ void pqiNetStateBox::determineNetworkState() /* fallback is FULL CONE NAT */ mNetworkMode = RsNetworkMode::BEHINDNAT; mNatTypeMode = RsNatTypeMode::FULL_CONE; - mNatHoleMode = RSNET_NATHOLE_NONE; + mNatHoleMode = RsNatHoleMode::NONE; mNetStateMode = RSNET_NETSTATE_WARNING_NATTED; } @@ -419,7 +419,7 @@ void pqiNetStateBox::determineNetworkState() mNetworkMode = RsNetworkMode::BEHINDNAT; // Use Fallback Guess. //mNatTypeMode = RsNatTypeMode::UNKNOWN; - mNatHoleMode = RSNET_NATHOLE_UPNP; + mNatHoleMode = RsNatHoleMode::UPNP; mNetStateMode = RSNET_NETSTATE_GOOD; //mExtAddress = ... from UPnP, should match StunDht. //mExtAddrStable = true; @@ -430,7 +430,7 @@ void pqiNetStateBox::determineNetworkState() mNetworkMode = RsNetworkMode::BEHINDNAT; // Use Fallback Guess. //mNatTypeMode = RsNatTypeMode::UNKNOWN; - mNatHoleMode = RSNET_NATHOLE_NATPMP; + mNatHoleMode = RsNatHoleMode::NATPMP; mNetStateMode = RSNET_NETSTATE_GOOD; //mExtAddress = ... from NatPMP, should match NatPMP //mExtAddrStable = true; @@ -443,7 +443,7 @@ void pqiNetStateBox::determineNetworkState() { mNetworkMode = RsNetworkMode::EXTERNALIP; mNatTypeMode = RsNatTypeMode::NONE; - mNatHoleMode = RSNET_NATHOLE_NONE; + mNatHoleMode = RsNatHoleMode::NONE; mNetStateMode = RSNET_NETSTATE_GOOD; //mExtAddrStable = true; @@ -453,7 +453,7 @@ void pqiNetStateBox::determineNetworkState() mNetworkMode = RsNetworkMode::BEHINDNAT; // Use Fallback Guess. //mNatTypeMode = RsNatTypeMode::UNKNOWN; - mNatHoleMode = RSNET_NATHOLE_FORWARDED; + mNatHoleMode = RsNatHoleMode::FORWARDED; mNetStateMode = RSNET_NETSTATE_ADV_FORWARD; //mExtAddrStable = true; // Probably, makin assumption. @@ -480,7 +480,7 @@ void pqiNetStateBox::determineNetworkState() // This Mode is OKAY. mNetworkMode = RsNetworkMode::BEHINDNAT; mNatTypeMode = RsNatTypeMode::UNKNOWN; - mNatHoleMode = RSNET_NATHOLE_UPNP; + mNatHoleMode = RsNatHoleMode::UPNP; //mExtAddress = ... from UPnP. //mExtAddrStable = true; mNetStateMode = RSNET_NETSTATE_WARNING_NODHT; @@ -490,7 +490,7 @@ void pqiNetStateBox::determineNetworkState() // This Mode is OKAY. mNetworkMode = RsNetworkMode::BEHINDNAT; mNatTypeMode = RsNatTypeMode::UNKNOWN; - mNatHoleMode = RSNET_NATHOLE_NATPMP; + mNatHoleMode = RsNatHoleMode::NATPMP; //mExtAddress = ... from NatPMP. //mExtAddrStable = true; mNetStateMode = RSNET_NETSTATE_WARNING_NODHT; @@ -507,7 +507,7 @@ void pqiNetStateBox::determineNetworkState() { mNetworkMode = RsNetworkMode::EXTERNALIP; mNatTypeMode = RsNatTypeMode::NONE; - mNatHoleMode = RSNET_NATHOLE_NONE; + mNatHoleMode = RsNatHoleMode::NONE; //mExtAddrStable = true; mNetStateMode = RSNET_NETSTATE_WARNING_NODHT; @@ -516,7 +516,7 @@ void pqiNetStateBox::determineNetworkState() { mNetworkMode = RsNetworkMode::BEHINDNAT; mNatTypeMode = RsNatTypeMode::UNKNOWN; - mNatHoleMode = RSNET_NATHOLE_FORWARDED; + mNatHoleMode = RsNatHoleMode::FORWARDED; //mExtAddrStable = true; // Probably, makin assumption. mNetStateMode = RSNET_NETSTATE_WARNING_NODHT; @@ -529,7 +529,7 @@ void pqiNetStateBox::determineNetworkState() */ mNetworkMode = RsNetworkMode::BEHINDNAT; mNatTypeMode = RsNatTypeMode::UNKNOWN; - mNatHoleMode = RSNET_NATHOLE_NONE; + mNatHoleMode = RsNatHoleMode::NONE; mNetStateMode = RSNET_NETSTATE_BAD_NODHT_NAT; //mExtAddrStable = false; // Unlikely to be stable. @@ -581,9 +581,9 @@ void pqiNetStateBox::workoutNetworkMode() mConnectModes = RSNET_CONNECT_OUTGOING_TCP; /* we're okay if there's a NAT HOLE */ - if ((mNatHoleMode == RSNET_NATHOLE_UPNP) || - (mNatHoleMode == RSNET_NATHOLE_NATPMP) || - (mNatHoleMode == RSNET_NATHOLE_FORWARDED)) + if ((mNatHoleMode == RsNatHoleMode::UPNP) || + (mNatHoleMode == RsNatHoleMode::NATPMP) || + (mNatHoleMode == RsNatHoleMode::FORWARDED)) { mConnectModes |= RSNET_CONNECT_ACCEPT_TCP; if (mDhtActive) @@ -615,32 +615,6 @@ void pqiNetStateBox::workoutNetworkMode() } } - -std::string NetStateNatHoleString(uint32_t natHole) -{ - std::string str; - switch(natHole) - { - default: - case RSNET_NATHOLE_UNKNOWN: - str = "UNKNOWN NAT HOLE STATUS"; - break; - case RSNET_NATHOLE_NONE: - str = "NO NAT HOLE"; - break; - case RSNET_NATHOLE_UPNP: - str = "UPNP FORWARD"; - break; - case RSNET_NATHOLE_NATPMP: - str = "NATPMP FORWARD"; - break; - case RSNET_NATHOLE_FORWARDED: - str = "MANUAL FORWARD"; - break; - } - return str; -} - std::string NetStateConnectModesString(uint32_t connect) { diff --git a/libretroshare/src/pqi/pqinetstatebox.h b/libretroshare/src/pqi/pqinetstatebox.h index 0c48416e5..777534aa7 100644 --- a/libretroshare/src/pqi/pqinetstatebox.h +++ b/libretroshare/src/pqi/pqinetstatebox.h @@ -57,7 +57,7 @@ class pqiNetStateBox uint32_t getNetStateMode(); RsNetworkMode getNetworkMode(); RsNatTypeMode getNatTypeMode(); - uint32_t getNatHoleMode(); + RsNatHoleMode getNatHoleMode(); uint32_t getConnectModes(); private: @@ -76,7 +76,7 @@ class pqiNetStateBox RsNetworkMode mNetworkMode; RsNatTypeMode mNatTypeMode; - uint32_t mNatHoleMode; + RsNatHoleMode mNatHoleMode; uint32_t mConnectModes; uint32_t mNetStateMode; @@ -121,7 +121,6 @@ class pqiNetStateBox std::string NetStateNetStateString(uint32_t netstate); std::string NetStateConnectModesString(uint32_t connect); -std::string NetStateNatHoleString(uint32_t natHole); #endif diff --git a/libretroshare/src/retroshare/rsconfig.h b/libretroshare/src/retroshare/rsconfig.h index 91df4d059..6ce03c7e3 100644 --- a/libretroshare/src/retroshare/rsconfig.h +++ b/libretroshare/src/retroshare/rsconfig.h @@ -47,7 +47,6 @@ enum class RsNetworkMode : uint8_t EXTERNALIP = 6 }; - enum class RsNatTypeMode : uint8_t { NONE = 1, @@ -59,12 +58,14 @@ enum class RsNatTypeMode : uint8_t OTHER = 7 }; -// WHAT TYPE OF HOLE? -#define RSNET_NATHOLE_UNKNOWN 0 -#define RSNET_NATHOLE_NONE 1 -#define RSNET_NATHOLE_UPNP 2 -#define RSNET_NATHOLE_NATPMP 3 -#define RSNET_NATHOLE_FORWARDED 4 +enum class RsNatHoleMode : uint8_t +{ + UNKNOWN = 0, + NONE = 1, + UPNP = 2, + NATPMP = 3, + FORWARDED = 4 +}; // Types of Connections. #define RSNET_CONNECT_NONE 0x0000 @@ -359,7 +360,7 @@ public: virtual uint32_t getNetState() = 0; virtual RsNetworkMode getNetworkMode() = 0; virtual RsNatTypeMode getNatTypeMode() = 0; - virtual uint32_t getNatHoleMode() = 0; + virtual RsNatHoleMode getNatHoleMode() = 0; virtual uint32_t getConnectModes() = 0; virtual bool getConfigurationOption(uint32_t key, std::string &opt) = 0; diff --git a/libretroshare/src/rsserver/p3serverconfig.cc b/libretroshare/src/rsserver/p3serverconfig.cc index d6c88816d..fa3e4e0b6 100644 --- a/libretroshare/src/rsserver/p3serverconfig.cc +++ b/libretroshare/src/rsserver/p3serverconfig.cc @@ -306,13 +306,13 @@ uint32_t p3ServerConfig::getUserLevel() /* check that the firewall is open */ RsNetworkMode netMode = mNetMgr->getNetworkMode(); - uint32_t firewallMode = mNetMgr->getNatHoleMode(); + RsNatHoleMode firewallMode = mNetMgr->getNatHoleMode(); if ((RsNetworkMode::EXTERNALIP == netMode) || ((RsNetworkMode::BEHINDNAT == netMode) && - ((RSNET_NATHOLE_UPNP == firewallMode) || - (RSNET_NATHOLE_NATPMP == firewallMode) || - (RSNET_NATHOLE_FORWARDED == firewallMode)))) + (RsNatHoleMode::UPNP == firewallMode || + (RsNatHoleMode::NATPMP == firewallMode) || + (RsNatHoleMode::FORWARDED == firewallMode)))) { userLevel = RSCONFIG_USER_LEVEL_POWER; } @@ -344,7 +344,7 @@ RsNatTypeMode p3ServerConfig::getNatTypeMode() return mNetMgr->getNatTypeMode(); } -uint32_t p3ServerConfig::getNatHoleMode() +RsNatHoleMode p3ServerConfig::getNatHoleMode() { return mNetMgr->getNatHoleMode(); } diff --git a/libretroshare/src/rsserver/p3serverconfig.h b/libretroshare/src/rsserver/p3serverconfig.h index 7aacff13f..f629ee821 100644 --- a/libretroshare/src/rsserver/p3serverconfig.h +++ b/libretroshare/src/rsserver/p3serverconfig.h @@ -77,7 +77,7 @@ virtual uint32_t getUserLevel(); virtual uint32_t getNetState(); virtual RsNetworkMode getNetworkMode(); virtual RsNatTypeMode getNatTypeMode(); -virtual uint32_t getNatHoleMode(); +virtual RsNatHoleMode getNatHoleMode(); virtual uint32_t getConnectModes(); virtual bool getConfigurationOption(uint32_t key, std::string &opt); diff --git a/retroshare-gui/src/gui/statistics/DhtWindow.cpp b/retroshare-gui/src/gui/statistics/DhtWindow.cpp index c365fd4a3..7a2048f83 100644 --- a/retroshare-gui/src/gui/statistics/DhtWindow.cpp +++ b/retroshare-gui/src/gui/statistics/DhtWindow.cpp @@ -164,28 +164,28 @@ void DhtWindow::updateNetStatus() label = ui.natTypeLabel; - uint32_t natType = rsConfig->getNatTypeMode(); + RsNatTypeMode natType = rsConfig->getNatTypeMode(); switch(natType) { - case RSNET_NATTYPE_UNKNOWN: + case RsNatTypeMode::UNKNOWN: label->setText(tr("UNKNOWN NAT STATE")); break; - case RSNET_NATTYPE_SYMMETRIC: + case RsNatTypeMode::SYMMETRIC: label->setText(tr("SYMMETRIC NAT")); break; - case RSNET_NATTYPE_DETERM_SYM: + case RsNatTypeMode::DETERM_SYM: label->setText(tr("DETERMINISTIC SYM NAT")); break; - case RSNET_NATTYPE_RESTRICTED_CONE: + case RsNatTypeMode::RESTRICTED_CONE: label->setText(tr("RESTRICTED CONE NAT")); break; - case RSNET_NATTYPE_FULL_CONE: + case RsNatTypeMode::FULL_CONE: label->setText(tr("FULL CONE NAT")); break; - case RSNET_NATTYPE_OTHER: + case RsNatTypeMode::OTHER: label->setText(tr("OTHER NAT")); break; - case RSNET_NATTYPE_NONE: + case RsNatTypeMode::NONE: label->setText(tr("NO NAT")); break; } @@ -193,23 +193,23 @@ void DhtWindow::updateNetStatus() label = ui.natHoleLabel; - uint32_t natHole = rsConfig->getNatHoleMode(); + RsNatHoleMode natHole = rsConfig->getNatHoleMode(); switch(natHole) { - case RSNET_NATHOLE_UNKNOWN: + case RsNatHoleMode::UNKNOWN: label->setText(tr("UNKNOWN NAT HOLE STATUS")); break; - case RSNET_NATHOLE_NONE: + case RsNatHoleMode::NONE: label->setText(tr("NO NAT HOLE")); break; - case RSNET_NATHOLE_UPNP: + case RsNatHoleMode::UPNP: label->setText(tr("UPNP FORWARD")); break; - case RSNET_NATHOLE_NATPMP: + case RsNatHoleMode::NATPMP: label->setText(tr("NATPMP FORWARD")); break; - case RSNET_NATHOLE_FORWARDED: + case RsNatHoleMode::FORWARDED: label->setText(tr("MANUAL FORWARD")); break; } From acda7b8cc4ce66c339b0e6f933dff67e29fba252 Mon Sep 17 00:00:00 2001 From: sehraf Date: Sun, 9 Feb 2020 21:45:45 +0100 Subject: [PATCH 04/24] convert RSNET_CONNECT to enum class --- libretroshare/src/pqi/p3netmgr.cc | 2 +- libretroshare/src/pqi/p3netmgr.h | 4 +- libretroshare/src/pqi/pqinetstatebox.cc | 56 +++++-------------- libretroshare/src/pqi/pqinetstatebox.h | 6 +- libretroshare/src/retroshare/rsconfig.h | 19 ++++--- libretroshare/src/rsserver/p3serverconfig.cc | 2 +- libretroshare/src/rsserver/p3serverconfig.h | 2 +- .../src/gui/statistics/DhtWindow.cpp | 12 ++-- 8 files changed, 38 insertions(+), 65 deletions(-) diff --git a/libretroshare/src/pqi/p3netmgr.cc b/libretroshare/src/pqi/p3netmgr.cc index f8ba2963b..7e60a9da9 100644 --- a/libretroshare/src/pqi/p3netmgr.cc +++ b/libretroshare/src/pqi/p3netmgr.cc @@ -1651,7 +1651,7 @@ RsNatHoleMode p3NetMgrIMPL::getNatHoleMode() return mNetStateBox.getNatHoleMode(); } -uint32_t p3NetMgrIMPL::getConnectModes() +RsConnectModes p3NetMgrIMPL::getConnectModes() { RsStackMutex stack(mNetMtx); /****** STACK LOCK MUTEX *******/ return mNetStateBox.getConnectModes(); diff --git a/libretroshare/src/pqi/p3netmgr.h b/libretroshare/src/pqi/p3netmgr.h index 513080351..cf9455347 100644 --- a/libretroshare/src/pqi/p3netmgr.h +++ b/libretroshare/src/pqi/p3netmgr.h @@ -107,7 +107,7 @@ virtual uint32_t getNetStateMode() = 0; virtual RsNetworkMode getNetworkMode() = 0; virtual RsNatTypeMode getNatTypeMode() = 0; virtual RsNatHoleMode getNatHoleMode() = 0; -virtual uint32_t getConnectModes() = 0; +virtual RsConnectModes getConnectModes() = 0; /* Shut It Down! */ virtual bool shutdown() = 0; /* blocking shutdown call */ @@ -158,7 +158,7 @@ virtual uint32_t getNetStateMode(); virtual RsNetworkMode getNetworkMode(); virtual RsNatTypeMode getNatTypeMode(); virtual RsNatHoleMode getNatHoleMode(); -virtual uint32_t getConnectModes(); +virtual RsConnectModes getConnectModes(); /* Shut It Down! */ virtual bool shutdown(); /* blocking shutdown call */ diff --git a/libretroshare/src/pqi/pqinetstatebox.cc b/libretroshare/src/pqi/pqinetstatebox.cc index a392f0f74..cc14375f3 100644 --- a/libretroshare/src/pqi/pqinetstatebox.cc +++ b/libretroshare/src/pqi/pqinetstatebox.cc @@ -164,7 +164,7 @@ RsNatHoleMode pqiNetStateBox::getNatHoleMode() return mNatHoleMode; } -uint32_t pqiNetStateBox::getConnectModes() +RsConnectModes pqiNetStateBox::getConnectModes() { updateNetState(); return mConnectModes; @@ -195,7 +195,7 @@ void pqiNetStateBox::reset() mNetworkMode = RsNetworkMode::UNKNOWN; mNatTypeMode = RsNatTypeMode::UNKNOWN; mNatHoleMode = RsNatHoleMode::UNKNOWN; - mConnectModes = RSNET_CONNECT_NONE; + mConnectModes = RsConnectModes::NONE; mNetStateMode = RSNET_NETSTATE_BAD_UNKNOWN; /* Parameters set externally */ @@ -552,7 +552,7 @@ void pqiNetStateBox::determineNetworkState() void pqiNetStateBox::workoutNetworkMode() { /* connectModes are dependent on the other modes */ - mConnectModes = RSNET_CONNECT_NONE; + mConnectModes = RsConnectModes::NONE; switch(mNetworkMode) { case RsNetworkMode::UNKNOWN: @@ -562,33 +562,33 @@ void pqiNetStateBox::workoutNetworkMode() /* nothing here */ break; case RsNetworkMode::EXTERNALIP: - mConnectModes = RSNET_CONNECT_OUTGOING_TCP; - mConnectModes |= RSNET_CONNECT_ACCEPT_TCP; + mConnectModes = RsConnectModes::OUTGOING_TCP; + mConnectModes |= RsConnectModes::ACCEPT_TCP; if (mDhtActive) { - mConnectModes |= RSNET_CONNECT_DIRECT_UDP; + mConnectModes |= RsConnectModes::DIRECT_UDP; /* if open port. don't want PROXY or RELAY connect * because we should be able to do direct with EVERYONE. * Ability to do Proxy is dependent on FIREWALL status. * Technically could do RELAY, but disable both. */ - //mConnectModes |= RSNET_CONNECT_PROXY_UDP; - //mConnectModes |= RSNET_CONNECT_RELAY_UDP; + //mConnectModes |= RsConnectModes::PROXY_UDP; + //mConnectModes |= RsConnectModes::RELAY_UDP; } break; case RsNetworkMode::BEHINDNAT: - mConnectModes = RSNET_CONNECT_OUTGOING_TCP; + mConnectModes = RsConnectModes::OUTGOING_TCP; /* we're okay if there's a NAT HOLE */ if ((mNatHoleMode == RsNatHoleMode::UPNP) || (mNatHoleMode == RsNatHoleMode::NATPMP) || (mNatHoleMode == RsNatHoleMode::FORWARDED)) { - mConnectModes |= RSNET_CONNECT_ACCEPT_TCP; + mConnectModes |= RsConnectModes::ACCEPT_TCP; if (mDhtActive) { - mConnectModes |= RSNET_CONNECT_DIRECT_UDP; + mConnectModes |= RsConnectModes::DIRECT_UDP; /* dont want PROXY | RELAY with open ports */ } } @@ -600,14 +600,14 @@ void pqiNetStateBox::workoutNetworkMode() */ if (mDhtActive) { - mConnectModes |= RSNET_CONNECT_DIRECT_UDP; - mConnectModes |= RSNET_CONNECT_RELAY_UDP; + mConnectModes |= RsConnectModes::DIRECT_UDP; + mConnectModes |= RsConnectModes::RELAY_UDP; if ((mNatTypeMode == RsNatTypeMode::RESTRICTED_CONE) || (mNatTypeMode == RsNatTypeMode::FULL_CONE) || (mNatTypeMode == RsNatTypeMode::DETERM_SYM)) { - mConnectModes |= RSNET_CONNECT_PROXY_UDP; + mConnectModes |= RsConnectModes::PROXY_UDP; } } } @@ -616,34 +616,6 @@ void pqiNetStateBox::workoutNetworkMode() } -std::string NetStateConnectModesString(uint32_t connect) -{ - std::string connOut; - if (connect & RSNET_CONNECT_OUTGOING_TCP) - { - connOut += "TCP_OUT "; - } - if (connect & RSNET_CONNECT_ACCEPT_TCP) - { - connOut += "TCP_IN "; - } - if (connect & RSNET_CONNECT_DIRECT_UDP) - { - connOut += "DIRECT_UDP "; - } - if (connect & RSNET_CONNECT_PROXY_UDP) - { - connOut += "PROXY_UDP "; - } - if (connect & RSNET_CONNECT_RELAY_UDP) - { - connOut += "RELAY_UDP "; - } - return connOut; -} - - - std::string NetStateNetStateString(uint32_t netstate) { std::string str; diff --git a/libretroshare/src/pqi/pqinetstatebox.h b/libretroshare/src/pqi/pqinetstatebox.h index 777534aa7..bbda9a135 100644 --- a/libretroshare/src/pqi/pqinetstatebox.h +++ b/libretroshare/src/pqi/pqinetstatebox.h @@ -58,7 +58,7 @@ class pqiNetStateBox RsNetworkMode getNetworkMode(); RsNatTypeMode getNatTypeMode(); RsNatHoleMode getNatHoleMode(); - uint32_t getConnectModes(); + RsConnectModes getConnectModes(); private: @@ -77,7 +77,7 @@ class pqiNetStateBox RsNetworkMode mNetworkMode; RsNatTypeMode mNatTypeMode; RsNatHoleMode mNatHoleMode; - uint32_t mConnectModes; + RsConnectModes mConnectModes; uint32_t mNetStateMode; /* Parameters set externally */ @@ -120,7 +120,5 @@ class pqiNetStateBox std::string NetStateNetStateString(uint32_t netstate); -std::string NetStateConnectModesString(uint32_t connect); - #endif diff --git a/libretroshare/src/retroshare/rsconfig.h b/libretroshare/src/retroshare/rsconfig.h index 6ce03c7e3..b9d7a5dae 100644 --- a/libretroshare/src/retroshare/rsconfig.h +++ b/libretroshare/src/retroshare/rsconfig.h @@ -67,13 +67,16 @@ enum class RsNatHoleMode : uint8_t FORWARDED = 4 }; -// Types of Connections. -#define RSNET_CONNECT_NONE 0x0000 -#define RSNET_CONNECT_ACCEPT_TCP 0x0001 -#define RSNET_CONNECT_OUTGOING_TCP 0x0002 -#define RSNET_CONNECT_DIRECT_UDP 0x0100 -#define RSNET_CONNECT_PROXY_UDP 0x0200 -#define RSNET_CONNECT_RELAY_UDP 0x0400 +enum class RsConnectModes : uint16_t +{ + NONE = 0x0000, + ACCEPT_TCP = 0x0001, + OUTGOING_TCP= 0x0002, + DIRECT_UDP = 0x0100, + PROXY_UDP = 0x0200, + RELAY_UDP = 0x0400 +}; +RS_REGISTER_ENUM_FLAGS_TYPE(RsConnectModes) // net state (good, okay, bad) // BAD. (RED) @@ -361,7 +364,7 @@ public: virtual RsNetworkMode getNetworkMode() = 0; virtual RsNatTypeMode getNatTypeMode() = 0; virtual RsNatHoleMode getNatHoleMode() = 0; - virtual uint32_t getConnectModes() = 0; + virtual RsConnectModes getConnectModes() = 0; virtual bool getConfigurationOption(uint32_t key, std::string &opt) = 0; virtual bool setConfigurationOption(uint32_t key, const std::string &opt) = 0; diff --git a/libretroshare/src/rsserver/p3serverconfig.cc b/libretroshare/src/rsserver/p3serverconfig.cc index fa3e4e0b6..7411eb038 100644 --- a/libretroshare/src/rsserver/p3serverconfig.cc +++ b/libretroshare/src/rsserver/p3serverconfig.cc @@ -349,7 +349,7 @@ RsNatHoleMode p3ServerConfig::getNatHoleMode() return mNetMgr->getNatHoleMode(); } -uint32_t p3ServerConfig::getConnectModes() +RsConnectModes p3ServerConfig::getConnectModes() { return mNetMgr->getConnectModes(); } diff --git a/libretroshare/src/rsserver/p3serverconfig.h b/libretroshare/src/rsserver/p3serverconfig.h index f629ee821..39a3b5138 100644 --- a/libretroshare/src/rsserver/p3serverconfig.h +++ b/libretroshare/src/rsserver/p3serverconfig.h @@ -78,7 +78,7 @@ virtual uint32_t getNetState(); virtual RsNetworkMode getNetworkMode(); virtual RsNatTypeMode getNatTypeMode(); virtual RsNatHoleMode getNatHoleMode(); -virtual uint32_t getConnectModes(); +virtual RsConnectModes getConnectModes(); virtual bool getConfigurationOption(uint32_t key, std::string &opt); virtual bool setConfigurationOption(uint32_t key, const std::string &opt); diff --git a/retroshare-gui/src/gui/statistics/DhtWindow.cpp b/retroshare-gui/src/gui/statistics/DhtWindow.cpp index 7a2048f83..cb0c77a5f 100644 --- a/retroshare-gui/src/gui/statistics/DhtWindow.cpp +++ b/retroshare-gui/src/gui/statistics/DhtWindow.cpp @@ -214,27 +214,27 @@ void DhtWindow::updateNetStatus() break; } - uint32_t connect = rsConfig->getConnectModes(); + RsConnectModes connect = rsConfig->getConnectModes(); label = ui.connectLabel; QString connOut; - if (connect & RSNET_CONNECT_OUTGOING_TCP) + if (!!(connect & RsConnectModes::OUTGOING_TCP)) { connOut += "TCP_OUT "; } - if (connect & RSNET_CONNECT_ACCEPT_TCP) + if (!!(connect & RsConnectModes::ACCEPT_TCP)) { connOut += "TCP_IN "; } - if (connect & RSNET_CONNECT_DIRECT_UDP) + if (!!(connect & RsConnectModes::DIRECT_UDP)) { connOut += "DIRECT_UDP "; } - if (connect & RSNET_CONNECT_PROXY_UDP) + if (!!(connect & RsConnectModes::PROXY_UDP)) { connOut += "PROXY_UDP "; } - if (connect & RSNET_CONNECT_RELAY_UDP) + if (!!(connect & RsConnectModes::RELAY_UDP)) { connOut += "RELAY_UDP "; } From 3f5dcecc4d34ac8c7f963f8d568fa09049680b8f Mon Sep 17 00:00:00 2001 From: sehraf Date: Sun, 9 Feb 2020 21:58:56 +0100 Subject: [PATCH 05/24] convert RSNET_NETSTATE to enum class --- libretroshare/src/pqi/p3netmgr.cc | 2 +- libretroshare/src/pqi/p3netmgr.h | 4 +- libretroshare/src/pqi/pqinetstatebox.cc | 81 +++++-------------- libretroshare/src/pqi/pqinetstatebox.h | 8 +- libretroshare/src/retroshare/rsconfig.h | 39 ++++----- libretroshare/src/rsserver/p3serverconfig.cc | 2 +- libretroshare/src/rsserver/p3serverconfig.h | 2 +- .../src/gui/connect/ConnectProgressDialog.cpp | 22 ++--- .../src/gui/statistics/DhtWindow.cpp | 22 ++--- .../src/gui/statusbar/natstatus.cpp | 20 ++--- .../src/gui/statusbar/torstatus.cpp | 20 ++--- 11 files changed, 87 insertions(+), 135 deletions(-) diff --git a/libretroshare/src/pqi/p3netmgr.cc b/libretroshare/src/pqi/p3netmgr.cc index 7e60a9da9..8c0a736c4 100644 --- a/libretroshare/src/pqi/p3netmgr.cc +++ b/libretroshare/src/pqi/p3netmgr.cc @@ -1627,7 +1627,7 @@ void p3NetMgrIMPL::setIPServersEnabled(bool b) ************************************** NetStateBox ****************************************** **********************************************************************************************/ -uint32_t p3NetMgrIMPL::getNetStateMode() +RsNetState p3NetMgrIMPL::getNetStateMode() { RsStackMutex stack(mNetMtx); /****** STACK LOCK MUTEX *******/ return mNetStateBox.getNetStateMode(); diff --git a/libretroshare/src/pqi/p3netmgr.h b/libretroshare/src/pqi/p3netmgr.h index cf9455347..bfcafca2a 100644 --- a/libretroshare/src/pqi/p3netmgr.h +++ b/libretroshare/src/pqi/p3netmgr.h @@ -103,7 +103,7 @@ virtual bool netAssistBadPeer(const struct sockaddr_storage &addr, uint32_t reas virtual bool netAssistStatusUpdate(const RsPeerId &id, int mode) = 0; /* Get Network State */ -virtual uint32_t getNetStateMode() = 0; +virtual RsNetState getNetStateMode() = 0; virtual RsNetworkMode getNetworkMode() = 0; virtual RsNatTypeMode getNatTypeMode() = 0; virtual RsNatHoleMode getNatHoleMode() = 0; @@ -154,7 +154,7 @@ virtual bool netAssistBadPeer(const struct sockaddr_storage &addr, uint32_t reas virtual bool netAssistStatusUpdate(const RsPeerId &id, int mode); /* Get Network State */ -virtual uint32_t getNetStateMode(); +virtual RsNetState getNetStateMode(); virtual RsNetworkMode getNetworkMode(); virtual RsNatTypeMode getNatTypeMode(); virtual RsNatHoleMode getNatHoleMode(); diff --git a/libretroshare/src/pqi/pqinetstatebox.cc b/libretroshare/src/pqi/pqinetstatebox.cc index cc14375f3..67d1fcef1 100644 --- a/libretroshare/src/pqi/pqinetstatebox.cc +++ b/libretroshare/src/pqi/pqinetstatebox.cc @@ -171,7 +171,7 @@ RsConnectModes pqiNetStateBox::getConnectModes() } -uint32_t pqiNetStateBox::getNetStateMode() +RsNetState pqiNetStateBox::getNetStateMode() { updateNetState(); return mNetStateMode; @@ -196,7 +196,7 @@ void pqiNetStateBox::reset() mNatTypeMode = RsNatTypeMode::UNKNOWN; mNatHoleMode = RsNatHoleMode::UNKNOWN; mConnectModes = RsConnectModes::NONE; - mNetStateMode = RSNET_NETSTATE_BAD_UNKNOWN; + mNetStateMode = RsNetState::BAD_UNKNOWN; /* Parameters set externally */ @@ -305,7 +305,7 @@ void pqiNetStateBox::determineNetworkState() // Assume these. mNatTypeMode = RsNatTypeMode::UNKNOWN; mNatHoleMode = RsNatHoleMode::NONE; - mNetStateMode = RSNET_NETSTATE_BAD_UNKNOWN; + mNetStateMode = RsNetState::BAD_UNKNOWN; //mExtAddress = .... unknown; //mExtAddrStable = false; @@ -337,7 +337,7 @@ void pqiNetStateBox::determineNetworkState() mNetworkMode = RsNetworkMode::BEHINDNAT; mNatTypeMode = RsNatTypeMode::DETERM_SYM; mNatHoleMode = RsNatHoleMode::NONE; - mNetStateMode = RSNET_NETSTATE_WARNING_NATTED; + mNetStateMode = RsNetState::WARNING_NATTED; } else if (!mStunProxyStable) @@ -346,7 +346,7 @@ void pqiNetStateBox::determineNetworkState() mNetworkMode = RsNetworkMode::BEHINDNAT; mNatTypeMode = RsNatTypeMode::SYMMETRIC; mNatHoleMode = RsNatHoleMode::NONE; - mNetStateMode = RSNET_NETSTATE_BAD_NATSYM; + mNetStateMode = RsNetState::BAD_NATSYM; } else { @@ -368,7 +368,7 @@ void pqiNetStateBox::determineNetworkState() mNetworkMode = RsNetworkMode::BEHINDNAT; mNatTypeMode = RsNatTypeMode::RESTRICTED_CONE; mNatHoleMode = RsNatHoleMode::NONE; - mNetStateMode = RSNET_NETSTATE_WARNING_NATTED; + mNetStateMode = RsNetState::WARNING_NATTED; } } else // Dht Stable. @@ -394,7 +394,7 @@ void pqiNetStateBox::determineNetworkState() mNetworkMode = RsNetworkMode::BEHINDNAT; mNatTypeMode = RsNatTypeMode::DETERM_SYM; mNatHoleMode = RsNatHoleMode::FORWARDED; - mNetStateMode = RSNET_NETSTATE_GOOD; + mNetStateMode = RsNetState::GOOD; } else if (!mStunProxyStable) { @@ -402,7 +402,7 @@ void pqiNetStateBox::determineNetworkState() mNetworkMode = RsNetworkMode::BEHINDNAT; mNatTypeMode = RsNatTypeMode::SYMMETRIC; mNatHoleMode = RsNatHoleMode::FORWARDED; - mNetStateMode = RSNET_NETSTATE_GOOD; + mNetStateMode = RsNetState::GOOD; } else { @@ -410,7 +410,7 @@ void pqiNetStateBox::determineNetworkState() mNetworkMode = RsNetworkMode::BEHINDNAT; mNatTypeMode = RsNatTypeMode::FULL_CONE; mNatHoleMode = RsNatHoleMode::NONE; - mNetStateMode = RSNET_NETSTATE_WARNING_NATTED; + mNetStateMode = RsNetState::WARNING_NATTED; } if (mUPnPActive) @@ -420,7 +420,7 @@ void pqiNetStateBox::determineNetworkState() // Use Fallback Guess. //mNatTypeMode = RsNatTypeMode::UNKNOWN; mNatHoleMode = RsNatHoleMode::UPNP; - mNetStateMode = RSNET_NETSTATE_GOOD; + mNetStateMode = RsNetState::GOOD; //mExtAddress = ... from UPnP, should match StunDht. //mExtAddrStable = true; } @@ -431,7 +431,7 @@ void pqiNetStateBox::determineNetworkState() // Use Fallback Guess. //mNatTypeMode = RsNatTypeMode::UNKNOWN; mNatHoleMode = RsNatHoleMode::NATPMP; - mNetStateMode = RSNET_NETSTATE_GOOD; + mNetStateMode = RsNetState::GOOD; //mExtAddress = ... from NatPMP, should match NatPMP //mExtAddrStable = true; } @@ -444,7 +444,7 @@ void pqiNetStateBox::determineNetworkState() mNetworkMode = RsNetworkMode::EXTERNALIP; mNatTypeMode = RsNatTypeMode::NONE; mNatHoleMode = RsNatHoleMode::NONE; - mNetStateMode = RSNET_NETSTATE_GOOD; + mNetStateMode = RsNetState::GOOD; //mExtAddrStable = true; } @@ -454,7 +454,7 @@ void pqiNetStateBox::determineNetworkState() // Use Fallback Guess. //mNatTypeMode = RsNatTypeMode::UNKNOWN; mNatHoleMode = RsNatHoleMode::FORWARDED; - mNetStateMode = RSNET_NETSTATE_ADV_FORWARD; + mNetStateMode = RsNetState::ADV_FORWARD; //mExtAddrStable = true; // Probably, makin assumption. } @@ -483,7 +483,7 @@ void pqiNetStateBox::determineNetworkState() mNatHoleMode = RsNatHoleMode::UPNP; //mExtAddress = ... from UPnP. //mExtAddrStable = true; - mNetStateMode = RSNET_NETSTATE_WARNING_NODHT; + mNetStateMode = RsNetState::WARNING_NODHT; } else if (mNatPMPActive) { @@ -493,7 +493,7 @@ void pqiNetStateBox::determineNetworkState() mNatHoleMode = RsNatHoleMode::NATPMP; //mExtAddress = ... from NatPMP. //mExtAddrStable = true; - mNetStateMode = RSNET_NETSTATE_WARNING_NODHT; + mNetStateMode = RsNetState::WARNING_NODHT; } else { @@ -510,7 +510,7 @@ void pqiNetStateBox::determineNetworkState() mNatHoleMode = RsNatHoleMode::NONE; //mExtAddrStable = true; - mNetStateMode = RSNET_NETSTATE_WARNING_NODHT; + mNetStateMode = RsNetState::WARNING_NODHT; } else if (mPortForwardSet) { @@ -519,7 +519,7 @@ void pqiNetStateBox::determineNetworkState() mNatHoleMode = RsNatHoleMode::FORWARDED; //mExtAddrStable = true; // Probably, makin assumption. - mNetStateMode = RSNET_NETSTATE_WARNING_NODHT; + mNetStateMode = RsNetState::WARNING_NODHT; } else { @@ -530,7 +530,7 @@ void pqiNetStateBox::determineNetworkState() mNetworkMode = RsNetworkMode::BEHINDNAT; mNatTypeMode = RsNatTypeMode::UNKNOWN; mNatHoleMode = RsNatHoleMode::NONE; - mNetStateMode = RSNET_NETSTATE_BAD_NODHT_NAT; + mNetStateMode = RsNetState::BAD_NODHT_NAT; //mExtAddrStable = false; // Unlikely to be stable. } @@ -614,48 +614,3 @@ void pqiNetStateBox::workoutNetworkMode() break; } } - - -std::string NetStateNetStateString(uint32_t netstate) -{ - std::string str; - switch(netstate) - { - case RSNET_NETSTATE_BAD_UNKNOWN: - str = "NET BAD: Unknown State"; - break; - case RSNET_NETSTATE_BAD_OFFLINE: - str = "NET BAD: Offline"; - break; - case RSNET_NETSTATE_BAD_NATSYM: - str = "NET BAD: Behind Symmetric NAT"; - break; - case RSNET_NETSTATE_BAD_NODHT_NAT: - str = "NET BAD: Behind NAT & No DHT"; - break; - case RSNET_NETSTATE_WARNING_RESTART: - str = "NET WARNING: NET Restart"; - break; - case RSNET_NETSTATE_WARNING_NATTED: - str = "NET WARNING: Behind NAT"; - break; - case RSNET_NETSTATE_WARNING_NODHT: - str = "NET WARNING: No DHT"; - break; - case RSNET_NETSTATE_GOOD: - str = "NET STATE GOOD!"; - break; - case RSNET_NETSTATE_ADV_FORWARD: - str = "CAUTION: UNVERIFABLE FORWARD!"; - break; - case RSNET_NETSTATE_ADV_DARK_FORWARD: - str = "CAUTION: UNVERIFABLE FORWARD & NO DHT"; - break; - } - return str; -} - - - - - diff --git a/libretroshare/src/pqi/pqinetstatebox.h b/libretroshare/src/pqi/pqinetstatebox.h index bbda9a135..26b85345a 100644 --- a/libretroshare/src/pqi/pqinetstatebox.h +++ b/libretroshare/src/pqi/pqinetstatebox.h @@ -54,7 +54,7 @@ class pqiNetStateBox void setDhtState(bool dhtOn, bool dhtActive); - uint32_t getNetStateMode(); + RsNetState getNetStateMode(); RsNetworkMode getNetworkMode(); RsNatTypeMode getNatTypeMode(); RsNatHoleMode getNatHoleMode(); @@ -78,7 +78,7 @@ class pqiNetStateBox RsNatTypeMode mNatTypeMode; RsNatHoleMode mNatHoleMode; RsConnectModes mConnectModes; - uint32_t mNetStateMode; + RsNetState mNetStateMode; /* Parameters set externally */ @@ -117,8 +117,4 @@ class pqiNetStateBox uint16_t mPortForwarded; }; - - -std::string NetStateNetStateString(uint32_t netstate); - #endif diff --git a/libretroshare/src/retroshare/rsconfig.h b/libretroshare/src/retroshare/rsconfig.h index b9d7a5dae..65c61b4fd 100644 --- a/libretroshare/src/retroshare/rsconfig.h +++ b/libretroshare/src/retroshare/rsconfig.h @@ -78,27 +78,28 @@ enum class RsConnectModes : uint16_t }; RS_REGISTER_ENUM_FLAGS_TYPE(RsConnectModes) -// net state (good, okay, bad) -// BAD. (RED) -#define RSNET_NETSTATE_BAD_UNKNOWN 1 -#define RSNET_NETSTATE_BAD_OFFLINE 2 -#define RSNET_NETSTATE_BAD_NATSYM 3 -#define RSNET_NETSTATE_BAD_NODHT_NAT 4 +enum class RsNetState : uint8_t +{ + // BAD. (RED) + BAD_UNKNOWN = 1, + BAD_OFFLINE = 2, + BAD_NATSYM = 3, + BAD_NODHT_NAT = 4, -// CAUTION. (ORANGE) -#define RSNET_NETSTATE_WARNING_RESTART 5 -#define RSNET_NETSTATE_WARNING_NATTED 6 -#define RSNET_NETSTATE_WARNING_NODHT 7 + // CAUTION. (ORANGE) + WARNING_RESTART = 5, + WARNING_NATTED = 6, + WARNING_NODHT = 7, -// GOOD (GREEN) -// NAT with forwarded port, or EXT port. -#define RSNET_NETSTATE_GOOD 8 - -// ADVANCED MODE (BLUE) -// If the user knows what they are doing... we cannot confirm this. -#define RSNET_NETSTATE_ADV_FORWARD 9 -#define RSNET_NETSTATE_ADV_DARK_FORWARD 10 + // GOOD (GREEN) + // NAT with forwarded port, or EXT port. + GOOD = 8, + // ADVANCED MODE (BLUE) + // If the user knows what they are doing... we cannot confirm this. + ADV_FORWARD = 9, + ADV_DARK_FORWARD= 10 +}; /* matched to the uPnP states */ #define UPNP_STATE_UNINITIALISED 0 @@ -360,7 +361,7 @@ public: virtual uint32_t getUserLevel() = 0; - virtual uint32_t getNetState() = 0; + virtual RsNetState getNetState() = 0; virtual RsNetworkMode getNetworkMode() = 0; virtual RsNatTypeMode getNatTypeMode() = 0; virtual RsNatHoleMode getNatHoleMode() = 0; diff --git a/libretroshare/src/rsserver/p3serverconfig.cc b/libretroshare/src/rsserver/p3serverconfig.cc index 7411eb038..d562034c7 100644 --- a/libretroshare/src/rsserver/p3serverconfig.cc +++ b/libretroshare/src/rsserver/p3serverconfig.cc @@ -329,7 +329,7 @@ uint32_t p3ServerConfig::getUserLevel() } -uint32_t p3ServerConfig::getNetState() +RsNetState p3ServerConfig::getNetState() { return mNetMgr->getNetStateMode(); } diff --git a/libretroshare/src/rsserver/p3serverconfig.h b/libretroshare/src/rsserver/p3serverconfig.h index 39a3b5138..fbd9c1fc9 100644 --- a/libretroshare/src/rsserver/p3serverconfig.h +++ b/libretroshare/src/rsserver/p3serverconfig.h @@ -74,7 +74,7 @@ virtual std::string getRetroshareDataDirectory(); virtual uint32_t getUserLevel(); -virtual uint32_t getNetState(); +virtual RsNetState getNetState(); virtual RsNetworkMode getNetworkMode(); virtual RsNatTypeMode getNatTypeMode(); virtual RsNatHoleMode getNatHoleMode(); diff --git a/retroshare-gui/src/gui/connect/ConnectProgressDialog.cpp b/retroshare-gui/src/gui/connect/ConnectProgressDialog.cpp index 8f039f911..a3040ab93 100755 --- a/retroshare-gui/src/gui/connect/ConnectProgressDialog.cpp +++ b/retroshare-gui/src/gui/connect/ConnectProgressDialog.cpp @@ -281,39 +281,39 @@ void ConnectProgressDialog::stopAndClose() void ConnectProgressDialog::updateNetworkStatus() { - uint32_t netState = rsConfig->getNetState(); + RsNetState netState = rsConfig->getNetState(); QLabel *label = ui->NetResult; switch(netState) { - case RSNET_NETSTATE_BAD_UNKNOWN: + case RsNetState::BAD_UNKNOWN: label->setText(tr("Unknown State")); break; - case RSNET_NETSTATE_BAD_OFFLINE: + case RsNetState::BAD_OFFLINE: label->setText(tr("Offline")); break; - case RSNET_NETSTATE_BAD_NATSYM: + case RsNetState::BAD_NATSYM: label->setText(tr("Behind Symmetric NAT")); break; - case RSNET_NETSTATE_BAD_NODHT_NAT: + case RsNetState::BAD_NODHT_NAT: label->setText(tr("Behind NAT & No DHT")); break; - case RSNET_NETSTATE_WARNING_RESTART: + case RsNetState::WARNING_RESTART: label->setText(tr("NET Restart")); break; - case RSNET_NETSTATE_WARNING_NATTED: + case RsNetState::WARNING_NATTED: label->setText(tr("Behind NAT")); break; - case RSNET_NETSTATE_WARNING_NODHT: + case RsNetState::WARNING_NODHT: label->setText(tr("No DHT")); break; - case RSNET_NETSTATE_GOOD: + case RsNetState::GOOD: label->setText(tr("NET STATE GOOD!")); break; - case RSNET_NETSTATE_ADV_FORWARD: + case RsNetState::ADV_FORWARD: label->setText(tr("UNVERIFIABLE FORWARD!")); break; - case RSNET_NETSTATE_ADV_DARK_FORWARD: + case RsNetState::ADV_DARK_FORWARD: label->setText(tr("UNVERIFIABLE FORWARD & NO DHT")); break; } diff --git a/retroshare-gui/src/gui/statistics/DhtWindow.cpp b/retroshare-gui/src/gui/statistics/DhtWindow.cpp index cb0c77a5f..b947ba07a 100644 --- a/retroshare-gui/src/gui/statistics/DhtWindow.cpp +++ b/retroshare-gui/src/gui/statistics/DhtWindow.cpp @@ -241,39 +241,39 @@ void DhtWindow::updateNetStatus() label->setText(connOut); - uint32_t netState = rsConfig->getNetState(); + RsNetState netState = rsConfig->getNetState(); label = ui.netStatusLabel; switch(netState) { - case RSNET_NETSTATE_BAD_UNKNOWN: + case RsNetState::BAD_UNKNOWN: label->setText(tr("NET BAD: Unknown State")); break; - case RSNET_NETSTATE_BAD_OFFLINE: + case RsNetState::BAD_OFFLINE: label->setText(tr("NET BAD: Offline")); break; - case RSNET_NETSTATE_BAD_NATSYM: + case RsNetState::BAD_NATSYM: label->setText(tr("NET BAD: Behind Symmetric NAT")); break; - case RSNET_NETSTATE_BAD_NODHT_NAT: + case RsNetState::BAD_NODHT_NAT: label->setText(tr("NET BAD: Behind NAT & No DHT")); break; - case RSNET_NETSTATE_WARNING_RESTART: + case RsNetState::WARNING_RESTART: label->setText(tr("NET WARNING: NET Restart")); break; - case RSNET_NETSTATE_WARNING_NATTED: + case RsNetState::WARNING_NATTED: label->setText(tr("NET WARNING: Behind NAT")); break; - case RSNET_NETSTATE_WARNING_NODHT: + case RsNetState::WARNING_NODHT: label->setText(tr("NET WARNING: No DHT")); break; - case RSNET_NETSTATE_GOOD: + case RsNetState::GOOD: label->setText(tr("NET STATE GOOD!")); break; - case RSNET_NETSTATE_ADV_FORWARD: + case RsNetState::ADV_FORWARD: label->setText(tr("CAUTION: UNVERIFIABLE FORWARD!")); break; - case RSNET_NETSTATE_ADV_DARK_FORWARD: + case RsNetState::ADV_DARK_FORWARD: label->setText(tr("CAUTION: UNVERIFIABLE FORWARD & NO DHT")); break; } diff --git a/retroshare-gui/src/gui/statusbar/natstatus.cpp b/retroshare-gui/src/gui/statusbar/natstatus.cpp index 9539defaa..b8e4a7d7a 100644 --- a/retroshare-gui/src/gui/statusbar/natstatus.cpp +++ b/retroshare-gui/src/gui/statusbar/natstatus.cpp @@ -51,7 +51,7 @@ NATStatus::NATStatus(QWidget *parent) void NATStatus::getNATStatus() { - uint32_t netState = rsConfig -> getNetState(); + RsNetState netState = rsConfig -> getNetState(); statusNAT->setVisible(!_compactMode); QString text = _compactMode?statusNAT->text():""; @@ -60,14 +60,14 @@ void NATStatus::getNATStatus() switch(netState) { default: - case RSNET_NETSTATE_BAD_UNKNOWN: + case RsNetState::BAD_UNKNOWN: { iconLabel->setPixmap(QPixmap(":/icons/bullet_yellow_128.png").scaledToHeight(S,Qt::SmoothTransformation)) ; iconLabel->setToolTip( text + tr("Network Status Unknown")) ; } break ; - case RSNET_NETSTATE_BAD_OFFLINE: + case RsNetState::BAD_OFFLINE: { iconLabel->setPixmap(QPixmap(":/icons/bullet_grey_129.png").scaledToHeight(S,Qt::SmoothTransformation)) ; iconLabel->setToolTip( text + tr("Offline")) ; @@ -75,14 +75,14 @@ void NATStatus::getNATStatus() break ; // BAD. (RED) - case RSNET_NETSTATE_BAD_NATSYM: + case RsNetState::BAD_NATSYM: { iconLabel->setPixmap(QPixmap(":/icons/bullet_red_128.png").scaledToHeight(S,Qt::SmoothTransformation)) ; iconLabel->setToolTip( text + tr("Nasty Firewall")) ; } break ; - case RSNET_NETSTATE_BAD_NODHT_NAT: + case RsNetState::BAD_NODHT_NAT: { iconLabel->setPixmap(QPixmap(":/icons/bullet_red_128.png").scaledToHeight(S,Qt::SmoothTransformation)) ; iconLabel->setToolTip( text + tr("DHT Disabled and Firewalled")) ; @@ -90,21 +90,21 @@ void NATStatus::getNATStatus() break ; // CAUTION. (ORANGE) - case RSNET_NETSTATE_WARNING_RESTART: + case RsNetState::WARNING_RESTART: { iconLabel->setPixmap(QPixmap(":/icons/bullet_yellow_128.png").scaledToHeight(S,Qt::SmoothTransformation)) ; iconLabel->setToolTip( text + tr("Network Restarting")) ; } break ; - case RSNET_NETSTATE_WARNING_NATTED: + case RsNetState::WARNING_NATTED: { iconLabel->setPixmap(QPixmap(":/icons/bullet_yellow_128.png").scaledToHeight(S,Qt::SmoothTransformation)) ; iconLabel->setToolTip( text + tr("Behind Firewall")) ; } break ; - case RSNET_NETSTATE_WARNING_NODHT: + case RsNetState::WARNING_NODHT: { iconLabel->setPixmap(QPixmap(":/icons/bullet_yellow_128.png").scaledToHeight(S,Qt::SmoothTransformation)) ; iconLabel->setToolTip( text + tr("DHT Disabled")) ; @@ -112,14 +112,14 @@ void NATStatus::getNATStatus() break ; // GOOD (GREEN) - case RSNET_NETSTATE_GOOD: + case RsNetState::GOOD: { iconLabel->setPixmap(QPixmap(":/icons/bullet_green_128.png").scaledToHeight(S,Qt::SmoothTransformation)) ; iconLabel->setToolTip( text + tr("RetroShare Server")) ; } break ; - case RSNET_NETSTATE_ADV_FORWARD: + case RsNetState::ADV_FORWARD: { iconLabel->setPixmap(QPixmap(":/icons/bullet_green_128.png").scaledToHeight(S,Qt::SmoothTransformation)) ; iconLabel->setToolTip( text + tr("Forwarded Port")) ; diff --git a/retroshare-gui/src/gui/statusbar/torstatus.cpp b/retroshare-gui/src/gui/statusbar/torstatus.cpp index f41ea30d3..cef3636a0 100644 --- a/retroshare-gui/src/gui/statusbar/torstatus.cpp +++ b/retroshare-gui/src/gui/statusbar/torstatus.cpp @@ -60,24 +60,24 @@ void TorStatus::getTorStatus() QString text = _compactMode?statusTor->text():""; /* check local network state. We cannot make sure that Tor is running yet. */ - uint32_t netState = rsConfig -> getNetState(); + RsNetState netState = rsConfig -> getNetState(); bool online ; switch(netState) { default: - case RSNET_NETSTATE_BAD_UNKNOWN: - case RSNET_NETSTATE_BAD_OFFLINE: online = false ; + case RsNetState::BAD_UNKNOWN: + case RsNetState::BAD_OFFLINE: online = false ; break ; - case RSNET_NETSTATE_WARNING_RESTART: + case RsNetState::WARNING_RESTART: - case RSNET_NETSTATE_BAD_NATSYM: - case RSNET_NETSTATE_BAD_NODHT_NAT: - case RSNET_NETSTATE_WARNING_NATTED: - case RSNET_NETSTATE_WARNING_NODHT: - case RSNET_NETSTATE_GOOD: - case RSNET_NETSTATE_ADV_FORWARD: online = true ; + case RsNetState::BAD_NATSYM: + case RsNetState::BAD_NODHT_NAT: + case RsNetState::WARNING_NATTED: + case RsNetState::WARNING_NODHT: + case RsNetState::GOOD: + case RsNetState::ADV_FORWARD: online = true ; break ; } From c285bb0ab8879c6c933062b05f30f197cd0ff3f7 Mon Sep 17 00:00:00 2001 From: sehraf Date: Sun, 9 Feb 2020 22:11:25 +0100 Subject: [PATCH 06/24] convert RSCONFIG_USER_LEVEL to enum class --- libretroshare/src/retroshare/rsconfig.h | 24 ++++++++------------ libretroshare/src/rsserver/p3serverconfig.cc | 22 +++++++++--------- libretroshare/src/rsserver/p3serverconfig.h | 4 ++-- retroshare-gui/src/gui/GetStartedDialog.cpp | 16 ++++++------- 4 files changed, 30 insertions(+), 36 deletions(-) diff --git a/libretroshare/src/retroshare/rsconfig.h b/libretroshare/src/retroshare/rsconfig.h index 65c61b4fd..9650b056f 100644 --- a/libretroshare/src/retroshare/rsconfig.h +++ b/libretroshare/src/retroshare/rsconfig.h @@ -101,24 +101,18 @@ enum class RsNetState : uint8_t ADV_DARK_FORWARD= 10 }; -/* matched to the uPnP states */ -#define UPNP_STATE_UNINITIALISED 0 -#define UPNP_STATE_UNAVAILABILE 1 -#define UPNP_STATE_READY 2 -#define UPNP_STATE_FAILED_TCP 3 -#define UPNP_STATE_FAILED_UDP 4 -#define UPNP_STATE_ACTIVE 5 - - /************************** Indicate How experienced the RsUser is... based on Friends / Firewall status ******/ -#define RSCONFIG_USER_LEVEL_NEW 0x0001 /* no friends */ -#define RSCONFIG_USER_LEVEL_BASIC 0x0002 /* no connections */ -#define RSCONFIG_USER_LEVEL_CASUAL 0x0003 /* firewalled */ -#define RSCONFIG_USER_LEVEL_POWER 0x0004 /* good! */ -#define RSCONFIG_USER_LEVEL_OVERRIDE 0x0005 /* forced to POWER level */ +enum class RsConfigUserLvl : uint8_t +{ + NEW = 1, /* no friends */ + BASIC = 2, /* no connections */ + CASUAL = 3, /* firewalled */ + POWER = 4, /* good! */ + OVERRIDE= 5 /* forced to POWER level */ +}; @@ -359,7 +353,7 @@ public: /* New Stuff */ - virtual uint32_t getUserLevel() = 0; + virtual RsConfigUserLvl getUserLevel() = 0; virtual RsNetState getNetState() = 0; virtual RsNetworkMode getNetworkMode() = 0; diff --git a/libretroshare/src/rsserver/p3serverconfig.cc b/libretroshare/src/rsserver/p3serverconfig.cc index d562034c7..d7c14ae76 100644 --- a/libretroshare/src/rsserver/p3serverconfig.cc +++ b/libretroshare/src/rsserver/p3serverconfig.cc @@ -48,7 +48,7 @@ p3ServerConfig::p3ServerConfig(p3PeerMgr *peerMgr, p3LinkMgr *linkMgr, p3NetMgr RsStackMutex stack(configMtx); /******* LOCKED MUTEX *****/ - mUserLevel = RSCONFIG_USER_LEVEL_NEW; /* START LEVEL */ + mUserLevel = RsConfigUserLvl::NEW; /* START LEVEL */ mRateDownload = DEFAULT_DOWNLOAD_KB_RATE; mRateUpload = DEFAULT_UPLOAD_KB_RATE; @@ -264,9 +264,9 @@ std::string p3ServerConfig::getRetroshareDataDirectory() /* New Stuff */ -uint32_t p3ServerConfig::getUserLevel() +RsConfigUserLvl p3ServerConfig::getUserLevel() { - uint32_t userLevel = RSCONFIG_USER_LEVEL_NEW; + RsConfigUserLvl userLevel = RsConfigUserLvl::NEW; { RsStackMutex stack(configMtx); /******* LOCKED MUTEX *****/ userLevel = mUserLevel; @@ -274,33 +274,33 @@ uint32_t p3ServerConfig::getUserLevel() switch(userLevel) { - case RSCONFIG_USER_LEVEL_OVERRIDE: + case RsConfigUserLvl::OVERRIDE: break; #define MIN_BASIC_FRIENDS 2 // FALL THROUGH EVERYTHING. default: - case RSCONFIG_USER_LEVEL_NEW: + case RsConfigUserLvl::NEW: { if (mPeerMgr->getFriendCount(true, false) > MIN_BASIC_FRIENDS) { - userLevel = RSCONFIG_USER_LEVEL_BASIC; + userLevel = RsConfigUserLvl::BASIC; } } /* fallthrough */ - case RSCONFIG_USER_LEVEL_BASIC: + case RsConfigUserLvl::BASIC: { /* check that we have some lastConnect > 0 */ if (mPeerMgr->haveOnceConnected()) { - userLevel = RSCONFIG_USER_LEVEL_CASUAL; + userLevel = RsConfigUserLvl::CASUAL; } } /* fallthrough */ - case RSCONFIG_USER_LEVEL_CASUAL: - case RSCONFIG_USER_LEVEL_POWER: + case RsConfigUserLvl::CASUAL: + case RsConfigUserLvl::POWER: { /* check that the firewall is open */ @@ -314,7 +314,7 @@ uint32_t p3ServerConfig::getUserLevel() (RsNatHoleMode::NATPMP == firewallMode) || (RsNatHoleMode::FORWARDED == firewallMode)))) { - userLevel = RSCONFIG_USER_LEVEL_POWER; + userLevel = RsConfigUserLvl::POWER; } } break; /* for all */ diff --git a/libretroshare/src/rsserver/p3serverconfig.h b/libretroshare/src/rsserver/p3serverconfig.h index fbd9c1fc9..199a09e05 100644 --- a/libretroshare/src/rsserver/p3serverconfig.h +++ b/libretroshare/src/rsserver/p3serverconfig.h @@ -72,7 +72,7 @@ virtual std::string getRetroshareDataDirectory(); /* New Stuff */ -virtual uint32_t getUserLevel(); +virtual RsConfigUserLvl getUserLevel(); virtual RsNetState getNetState(); virtual RsNetworkMode getNetworkMode(); @@ -108,7 +108,7 @@ bool findConfigurationOption(uint32_t key, std::string &keystr); p3GeneralConfig *mGeneralConfig; RsMutex configMtx; - uint32_t mUserLevel; // store last one... will later be a config Item too. + RsConfigUserLvl mUserLevel; // store last one... will later be a config Item too. float mRateDownload; float mRateUpload; diff --git a/retroshare-gui/src/gui/GetStartedDialog.cpp b/retroshare-gui/src/gui/GetStartedDialog.cpp index 3c4c14cf5..7357ffb2f 100644 --- a/retroshare-gui/src/gui/GetStartedDialog.cpp +++ b/retroshare-gui/src/gui/GetStartedDialog.cpp @@ -105,7 +105,7 @@ void GetStartedDialog::showEvent ( QShowEvent * /*event*/ ) void GetStartedDialog::updateFromUserLevel() { - uint32_t userLevel = RSCONFIG_USER_LEVEL_NEW; + RsConfigUserLvl userLevel = RsConfigUserLvl::NEW; userLevel = rsConfig->getUserLevel(); ui.inviteCheckBox->setChecked(false); @@ -116,19 +116,19 @@ void GetStartedDialog::updateFromUserLevel() switch(userLevel) { // FALLS THROUGH EVERYWHERE. - case RSCONFIG_USER_LEVEL_POWER: - case RSCONFIG_USER_LEVEL_OVERRIDE: + case RsConfigUserLvl::POWER: + case RsConfigUserLvl::OVERRIDE: ui.firewallCheckBox->setChecked(true); /* fallthrough */ - case RSCONFIG_USER_LEVEL_CASUAL: + case RsConfigUserLvl::CASUAL: ui.connectCheckBox->setChecked(true); /* fallthrough */ - case RSCONFIG_USER_LEVEL_BASIC: + case RsConfigUserLvl::BASIC: ui.addCheckBox->setChecked(true); ui.inviteCheckBox->setChecked(true); default: - case RSCONFIG_USER_LEVEL_NEW: + case RsConfigUserLvl::NEW: break; } @@ -325,7 +325,7 @@ void GetStartedDialog::emailSupport() return; } - uint32_t userLevel; + RsConfigUserLvl userLevel; { RsAutoUpdatePage::lockAllEvents(); @@ -427,7 +427,7 @@ void GetStartedDialog::emailSupport() sysVersion = "Linux"; #endif #endif - text += QString("My RetroShare Configuration is: (%1, %2, 0x60%3)").arg(Rshare::retroshareVersion(true)).arg(sysVersion).arg(userLevel) + "\n"; + text += QString("My RetroShare Configuration is: (%1, %2, %3)").arg(Rshare::retroshareVersion(true)).arg(sysVersion).arg(static_cast::type>(userLevel)) + "\n"; text += "\n"; text += QString("I am having trouble with RetroShare."); From 1a7510b2c912dcd2dcd8b41cfefa795618e79a29 Mon Sep 17 00:00:00 2001 From: sehraf Date: Sun, 9 Feb 2020 23:12:38 +0100 Subject: [PATCH 07/24] convert RS_OPMODE to enum class --- libretroshare/src/retroshare/rsconfig.h | 15 +++--- libretroshare/src/rsserver/p3serverconfig.cc | 48 +++++++++---------- libretroshare/src/rsserver/p3serverconfig.h | 8 ++-- retroshare-gui/src/gui/MainWindow.cpp | 8 ++-- .../src/gui/statusbar/OpModeStatus.cpp | 28 +++++------ 5 files changed, 55 insertions(+), 52 deletions(-) diff --git a/libretroshare/src/retroshare/rsconfig.h b/libretroshare/src/retroshare/rsconfig.h index 9650b056f..918372b79 100644 --- a/libretroshare/src/retroshare/rsconfig.h +++ b/libretroshare/src/retroshare/rsconfig.h @@ -120,10 +120,13 @@ enum class RsConfigUserLvl : uint8_t #define RS_CONFIG_ADVANCED 0x0101 -#define RS_OPMODE_FULL 0x0001 -#define RS_OPMODE_NOTURTLE 0x0002 -#define RS_OPMODE_GAMING 0x0003 -#define RS_OPMODE_MINIMAL 0x0004 +enum class RsOpMode : uint8_t +{ + FULL = 1, + NOTURTLE= 2, + GAMING = 3, + MINIMAL = 4 +}; class RsConfigStartup @@ -371,7 +374,7 @@ public: * @jsonapi{development} * @return return the current operating mode */ - virtual uint32_t getOperatingMode() = 0; + virtual RsOpMode getOperatingMode() = 0; /** * @brief setOperatingMode set the current oprating mode @@ -379,7 +382,7 @@ public: * @param[in] opMode new opearting mode * @return */ - virtual bool setOperatingMode(uint32_t opMode) = 0; + virtual bool setOperatingMode(RsOpMode opMode) = 0; /** * @brief setOperatingMode set the current operating mode from string diff --git a/libretroshare/src/rsserver/p3serverconfig.cc b/libretroshare/src/rsserver/p3serverconfig.cc index d7c14ae76..6d3343dc7 100644 --- a/libretroshare/src/rsserver/p3serverconfig.cc +++ b/libretroshare/src/rsserver/p3serverconfig.cc @@ -52,7 +52,7 @@ p3ServerConfig::p3ServerConfig(p3PeerMgr *peerMgr, p3LinkMgr *linkMgr, p3NetMgr mRateDownload = DEFAULT_DOWNLOAD_KB_RATE; mRateUpload = DEFAULT_UPLOAD_KB_RATE; - mOpMode = RS_OPMODE_FULL; + mOpMode = RsOpMode::FULL; rsConfig = this; } @@ -86,7 +86,7 @@ void p3ServerConfig::load_config() } /* enable operating mode */ - uint32_t opMode = getOperatingMode(); + RsOpMode opMode = getOperatingMode(); switchToOperatingMode(opMode); } @@ -357,27 +357,27 @@ RsConnectModes p3ServerConfig::getConnectModes() /* Operating Mode */ #define RS_CONFIG_OPERATING_STRING "OperatingMode" -uint32_t p3ServerConfig::getOperatingMode() +RsOpMode p3ServerConfig::getOperatingMode() { #ifdef SAVE_OPERATING_MODE std::string modestr = mGeneralConfig->getSetting(RS_CONFIG_OPERATING_STRING); - uint32_t mode = RS_OPMODE_FULL; + uint32_t mode = RsOpMode::FULL; if (modestr == "FULL") { - mode = RS_OPMODE_FULL; + mode = RsOpMode::FULL; } else if (modestr == "NOTURTLE") { - mode = RS_OPMODE_NOTURTLE; + mode = RsOpMode::NOTURTLE; } else if (modestr == "GAMING") { - mode = RS_OPMODE_GAMING; + mode = RsOpMode::GAMING; } else if (modestr == "MINIMAL") { - mode = RS_OPMODE_MINIMAL; + mode = RsOpMode::MINIMAL; } return mode; #else @@ -387,24 +387,24 @@ uint32_t p3ServerConfig::getOperatingMode() } -bool p3ServerConfig::setOperatingMode(uint32_t opMode) +bool p3ServerConfig::setOperatingMode(RsOpMode opMode) { #ifdef SAVE_OPERATING_MODE std::string modestr = "FULL"; switch(opMode) { - case RS_OPMODE_FULL: + case RsOpMode::FULL: modestr = "FULL"; break; - case RS_OPMODE_NOTURTLE: + case RsOpMode::NOTURTLE: modestr = "NOTURTLE"; break; - case RS_OPMODE_GAMING: + case RsOpMode::GAMING: modestr = "GAMING"; break; - case RS_OPMODE_MINIMAL: + case RsOpMode::MINIMAL: modestr = "MINIMAL"; break; } @@ -420,31 +420,31 @@ bool p3ServerConfig::setOperatingMode(uint32_t opMode) bool p3ServerConfig::setOperatingMode(const std::string &opModeStr) { - uint32_t opMode = RS_OPMODE_FULL; + RsOpMode opMode = RsOpMode::FULL; std::string upper; stringToUpperCase(opModeStr, upper); if (upper == "NOTURTLE") { - opMode = RS_OPMODE_NOTURTLE; + opMode = RsOpMode::NOTURTLE; } else if (upper == "GAMING") { - opMode = RS_OPMODE_GAMING; + opMode = RsOpMode::GAMING; } else if (upper == "MINIMAL") { - opMode = RS_OPMODE_MINIMAL; + opMode = RsOpMode::MINIMAL; } else // "FULL" by default { - opMode = RS_OPMODE_FULL; + opMode = RsOpMode::FULL; } return setOperatingMode(opMode); } -bool p3ServerConfig::switchToOperatingMode(uint32_t opMode) +bool p3ServerConfig::switchToOperatingMode(RsOpMode opMode) { float dl_rate = 0; float ul_rate = 0; @@ -456,13 +456,13 @@ bool p3ServerConfig::switchToOperatingMode(uint32_t opMode) ul_rate = mRateUpload; } - std::cerr << "p3ServerConfig::switchToOperatingMode(" << opMode << ")"; + std::cerr << "p3ServerConfig::switchToOperatingMode(" << static_cast::type>(opMode) << ")"; std::cerr << std::endl; switch (opMode) { default: - case RS_OPMODE_FULL: + case RsOpMode::FULL: /* switch on all transfers */ /* 100% bandwidth */ /* switch on popups, enable hashing */ @@ -470,14 +470,14 @@ bool p3ServerConfig::switchToOperatingMode(uint32_t opMode) //setMaxRate(false, mro); // Out / Upload. turtle_enabled = true; break; - case RS_OPMODE_NOTURTLE: + case RsOpMode::NOTURTLE: /* switch on all transfers - except turtle, enable hashing */ /* 100% bandwidth */ /* switch on popups, enable hashing */ turtle_enabled = false; break; - case RS_OPMODE_GAMING: + case RsOpMode::GAMING: /* switch on all transfers */ /* reduce bandwidth to 25% */ /* switch off popups, enable hashing */ @@ -486,7 +486,7 @@ bool p3ServerConfig::switchToOperatingMode(uint32_t opMode) dl_rate *= 0.25; ul_rate *= 0.25; break; - case RS_OPMODE_MINIMAL: + case RsOpMode::MINIMAL: /* switch off all transfers */ /* reduce bandwidth to 10%, but make sure there is enough for VoIP */ /* switch on popups, enable hashing */ diff --git a/libretroshare/src/rsserver/p3serverconfig.h b/libretroshare/src/rsserver/p3serverconfig.h index 199a09e05..c197aa1b0 100644 --- a/libretroshare/src/rsserver/p3serverconfig.h +++ b/libretroshare/src/rsserver/p3serverconfig.h @@ -84,8 +84,8 @@ virtual bool getConfigurationOption(uint32_t key, std::string &opt); virtual bool setConfigurationOption(uint32_t key, const std::string &opt); /* Operating Mode */ -virtual uint32_t getOperatingMode(); -virtual bool setOperatingMode(uint32_t opMode); +virtual RsOpMode getOperatingMode(); +virtual bool setOperatingMode(RsOpMode opMode); virtual bool setOperatingMode(const std::string &opModeStr); virtual int SetMaxDataRates( int downKb, int upKb ); @@ -97,7 +97,7 @@ virtual int GetTrafficSum( uint64_t &inb, uint64_t &outb ); private: -bool switchToOperatingMode(uint32_t opMode); +bool switchToOperatingMode(RsOpMode opMode); bool findConfigurationOption(uint32_t key, std::string &keystr); @@ -112,7 +112,7 @@ bool findConfigurationOption(uint32_t key, std::string &keystr); float mRateDownload; float mRateUpload; - uint32_t mOpMode; + RsOpMode mOpMode; }; #endif diff --git a/retroshare-gui/src/gui/MainWindow.cpp b/retroshare-gui/src/gui/MainWindow.cpp index 63a563dc4..cdb0fceb4 100644 --- a/retroshare-gui/src/gui/MainWindow.cpp +++ b/retroshare-gui/src/gui/MainWindow.cpp @@ -1548,13 +1548,13 @@ void MainWindow::processLastArgs() if (opModeStatus) { QString opmode = Rshare::opmode().toLower(); if (opmode == "noturtle") { - opModeStatus->setCurrentIndex(RS_OPMODE_NOTURTLE - 1); + opModeStatus->setCurrentIndex(static_cast::type>(RsOpMode::NOTURTLE) - 1); } else if (opmode == "gaming") { - opModeStatus->setCurrentIndex(RS_OPMODE_GAMING - 1); + opModeStatus->setCurrentIndex(static_cast::type>(RsOpMode::GAMING) - 1); } else if (opmode == "minimal") { - opModeStatus->setCurrentIndex(RS_OPMODE_MINIMAL - 1); + opModeStatus->setCurrentIndex(static_cast::type>(RsOpMode::MINIMAL) - 1); } else if (opmode != "") { - opModeStatus->setCurrentIndex(RS_OPMODE_FULL - 1); + opModeStatus->setCurrentIndex(static_cast::type>(RsOpMode::FULL) - 1); } opModeStatus->setOpMode(); } else { diff --git a/retroshare-gui/src/gui/statusbar/OpModeStatus.cpp b/retroshare-gui/src/gui/statusbar/OpModeStatus.cpp index 67ab527e9..f44f6d29c 100644 --- a/retroshare-gui/src/gui/statusbar/OpModeStatus.cpp +++ b/retroshare-gui/src/gui/statusbar/OpModeStatus.cpp @@ -39,13 +39,13 @@ OpModeStatus::OpModeStatus(QWidget *parent) opMode_Minimal_Color = QColor("#FFCCCC"); /* add the options */ - addItem(tr("Normal Mode"), RS_OPMODE_FULL); + addItem(tr("Normal Mode"), static_cast::type>(RsOpMode::FULL)); setItemData(0, opMode_Full_Color, Qt::BackgroundRole); - addItem(tr("No Anon D/L"), RS_OPMODE_NOTURTLE); + addItem(tr("No Anon D/L"), static_cast::type>(RsOpMode::NOTURTLE)); setItemData(1, opMode_NoTurtle_Color, Qt::BackgroundRole); - addItem(tr("Gaming Mode"), RS_OPMODE_GAMING); + addItem(tr("Gaming Mode"), static_cast::type>(RsOpMode::GAMING)); setItemData(2, opMode_Gaming_Color, Qt::BackgroundRole); - addItem(tr("Low Traffic"), RS_OPMODE_MINIMAL); + addItem(tr("Low Traffic"), static_cast::type>(RsOpMode::MINIMAL)); setItemData(3, opMode_Minimal_Color, Qt::BackgroundRole); connect(this, SIGNAL(activated( int )), this, SLOT(setOpMode())); @@ -59,23 +59,23 @@ OpModeStatus::OpModeStatus(QWidget *parent) void OpModeStatus::getOpMode() { - int opMode = rsConfig->getOperatingMode(); + RsOpMode opMode = rsConfig->getOperatingMode(); switch(opMode) { default: - case RS_OPMODE_FULL: + case RsOpMode::FULL: setCurrentIndex(0); setProperty("opMode", "Full"); break; - case RS_OPMODE_NOTURTLE: + case RsOpMode::NOTURTLE: setCurrentIndex(1); setProperty("opMode", "NoTurtle"); break; - case RS_OPMODE_GAMING: + case RsOpMode::GAMING: setCurrentIndex(2); setProperty("opMode", "Gaming"); break; - case RS_OPMODE_MINIMAL: + case RsOpMode::MINIMAL: setCurrentIndex(3); setProperty("opMode", "Minimal"); break; @@ -94,19 +94,19 @@ void OpModeStatus::setOpMode() int idx = currentIndex(); QVariant var = itemData(idx); - uint32_t opMode = var.toUInt(); + RsOpMode opMode = static_cast(var.toUInt()); QString message = tr("

Warning: This Operating mode disables the tunneling service. This means you can use distant chat not anonymously download files and the mail service will be slower.

This state will be saved after restart, so do not forget that you changed it!

"); - if(opMode == RS_OPMODE_NOTURTLE && ! Settings->getPageAlreadyDisplayed(QString("RS_OPMODE_NO_TURTLE"))) + if(opMode == RsOpMode::NOTURTLE && ! Settings->getPageAlreadyDisplayed(QString("RsOpMode::NO_TURTLE"))) { QMessageBox::warning(NULL,tr("Turtle routing disabled!"),message); - Settings->setPageAlreadyDisplayed(QString("RS_OPMODE_NO_TURTLE"),true) ; + Settings->setPageAlreadyDisplayed(QString("RsOpMode::NO_TURTLE"),true) ; } - if( (opMode == RS_OPMODE_MINIMAL && ! Settings->getPageAlreadyDisplayed(QString("RS_OPMODE_MINIMAL")))) + if( (opMode == RsOpMode::MINIMAL && ! Settings->getPageAlreadyDisplayed(QString("RsOpMode::MINIMAL")))) { QMessageBox::warning(NULL,tr("Turtle routing disabled!"),message); - Settings->setPageAlreadyDisplayed(QString("RS_OPMODE_MINIMAL"),true) ; + Settings->setPageAlreadyDisplayed(QString("RsOpMode::MINIMAL"),true) ; } rsConfig->setOperatingMode(opMode); From dfc7212c2332616cb37a3c2f4dfba433fb8a1239 Mon Sep 17 00:00:00 2001 From: sehraf Date: Mon, 10 Feb 2020 18:04:34 +0100 Subject: [PATCH 08/24] document how to convert enum class flags to boolean and fix RsFlags << operator --- libretroshare/src/retroshare/rsflags.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/libretroshare/src/retroshare/rsflags.h b/libretroshare/src/retroshare/rsflags.h index cdea3f5be..8adcc8e4f 100644 --- a/libretroshare/src/retroshare/rsflags.h +++ b/libretroshare/src/retroshare/rsflags.h @@ -36,7 +36,13 @@ using rs_is_scoped_enum = std::integral_constant< bool, * it as flags type passing it as parameter of this macro. * The result will be type safe flags, that cannot be mixed up with flag of a * different type, but that are very comfortable to operate like plain old - * integers. + * integers. All commom operation like &, | or ! can be used. To convert + * the result of such operation to boolean use !!: +@code{.cpp} +RsConnectModes connect = rsConfig->getConnectModes(); +if (!!(connect & RsConnectModes::OUTGOING_TCP)) +@endcode + * * This macro support flag fields of different lenght depending on what * underlining type (usually from uint8_t up to uint64_t) has been declared for * the enum class. @@ -44,6 +50,7 @@ using rs_is_scoped_enum = std::integral_constant< bool, * underlining type of the enum otherwise different compilers may serialize a * flag variable with different lenght, potentially causing interoperability * issues between differents builds. + * * Usage example: @code{.cpp} enum class RsGrouterItemFlags : uint32_t @@ -129,9 +136,9 @@ operator <<(std::ostream& stream, EFT flags) { using u_t = typename std::underlying_type::type; - for(int i = sizeof(u_t); i>=0; --i) + for(int i = sizeof(u_t) << 3; i>=0; --i) { - stream << (flags & ( 1 << i ) ? "1" : "0"); + stream << ((static_cast(flags) & ( 1 << i )) ? "1" : "0"); if( i % 8 == 0 ) stream << " "; } return stream; From 1b29e81e899506b4a8a87e2325e35b7a14899a82 Mon Sep 17 00:00:00 2001 From: sehraf Date: Wed, 19 Feb 2020 18:57:28 +0100 Subject: [PATCH 09/24] convert RSDHT_RELAY_MODE_ to enum class --- libretroshare/src/dht/p3bitdht.h | 6 ++--- libretroshare/src/dht/p3bitdht_relay.cc | 20 ++++++++--------- libretroshare/src/retroshare/rsdht.h | 22 ++++++++++--------- .../src/gui/settings/ServerPage.cpp | 16 +++++++------- 4 files changed, 33 insertions(+), 31 deletions(-) diff --git a/libretroshare/src/dht/p3bitdht.h b/libretroshare/src/dht/p3bitdht.h index c1ebf378c..b71f0893e 100644 --- a/libretroshare/src/dht/p3bitdht.h +++ b/libretroshare/src/dht/p3bitdht.h @@ -294,8 +294,8 @@ public: virtual int addRelayServer(std::string ids); virtual int removeRelayServer(std::string ids); - virtual uint32_t getRelayMode(); - virtual int setRelayMode(uint32_t mode); + virtual RsDhtRelayMode getRelayMode(); + virtual int setRelayMode(RsDhtRelayMode mode); virtual int getRelayAllowance(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(); std::list mRelayServerList; - uint32_t mRelayMode; + RsDhtRelayMode mRelayMode; protected: /*****************************************************************/ diff --git a/libretroshare/src/dht/p3bitdht_relay.cc b/libretroshare/src/dht/p3bitdht_relay.cc index 1fb2ed699..2011530b1 100644 --- a/libretroshare/src/dht/p3bitdht_relay.cc +++ b/libretroshare/src/dht/p3bitdht_relay.cc @@ -35,7 +35,7 @@ int p3BitDht::setupRelayDefaults() { - uint32_t mode = RSDHT_RELAY_ENABLED | RSDHT_RELAY_MODE_OFF; + RsDhtRelayMode mode = RsDhtRelayMode::ENABLED | RsDhtRelayMode::OFF; setRelayMode(mode); return 1; @@ -111,19 +111,19 @@ int p3BitDht::pushRelayServers() } -uint32_t p3BitDht::getRelayMode() +RsDhtRelayMode p3BitDht::getRelayMode() { RsStackMutex stack(dhtMtx); /*********** LOCKED **********/ return mRelayMode; } -int p3BitDht::setRelayMode(uint32_t mode) +int p3BitDht::setRelayMode(RsDhtRelayMode mode) { std::cerr << "p3BitDht::setRelayMode(" << mode << ")"; std::cerr << std::endl; - if (mode & RSDHT_RELAY_ENABLED) + if (!!(mode & RsDhtRelayMode::ENABLED)) { mUdpBitDht->ConnectionOptions( 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); } - int relaymode = mode & RSDHT_RELAY_MODE_MASK; + RsDhtRelayMode relaymode = mode & RsDhtRelayMode::MASK; switch(relaymode) { - case RSDHT_RELAY_MODE_OFF: + case RsDhtRelayMode::OFF: mUdpBitDht->setDhtMode(BITDHT_MODE_RELAYSERVERS_IGNORED); break; - case RSDHT_RELAY_MODE_ON: + case RsDhtRelayMode::ON: pushRelayServers(); mUdpBitDht->setDhtMode(BITDHT_MODE_RELAYSERVERS_FLAGGED); break; - case RSDHT_RELAY_MODE_SERVER: + case RsDhtRelayMode::SERVER: pushRelayServers(); mUdpBitDht->setDhtMode(BITDHT_MODE_RELAYSERVERS_SERVER); break; @@ -306,7 +306,7 @@ bool p3BitDht::loadList(std::list& load) int bandwidth[RSDHT_RELAY_NUM_CLASS] = {0}; bool haveMode = false; - int mode = 0; + RsDhtRelayMode mode = static_cast(0); std::list::iterator it; for(it = config->tlvkvs.pairs.begin(); it != config->tlvkvs.pairs.end(); ++it) @@ -322,7 +322,7 @@ bool p3BitDht::loadList(std::list& load) } else if (0 == strncmp(key.c_str(), "RELAY_MODE", 10)) { - mode = atoi(value.c_str()); + mode = static_cast(atoi(value.c_str())); haveMode = true; //std::cerr << "p3BitDht::loadList() Found Mode: " << mode; diff --git a/libretroshare/src/retroshare/rsdht.h b/libretroshare/src/retroshare/rsdht.h index 309e851b9..434e04328 100644 --- a/libretroshare/src/retroshare/rsdht.h +++ b/libretroshare/src/retroshare/rsdht.h @@ -27,6 +27,7 @@ #include #include #include "util/rsnet.h" +#include "retroshare/rsflags.h" /* The Main Interface Class - for information about your Peers */ class RsDht; @@ -75,15 +76,16 @@ extern RsDht *rsDht; #define RSDHT_RELAY_CLASS_FOF 2 #define RSDHT_RELAY_CLASS_FRIENDS 3 +enum class RsDhtRelayMode : uint16_t +{ + ENABLED = 0x0001, -#define RSDHT_RELAY_MODE_MASK 0x00f0 - -#define RSDHT_RELAY_ENABLED 0x0001 - -#define RSDHT_RELAY_MODE_OFF 0x0010 -#define RSDHT_RELAY_MODE_ON 0x0020 -#define RSDHT_RELAY_MODE_SERVER 0x0040 - + MASK = 0x00f0, + OFF = 0x0010, + ON = 0x0020, + SERVER = 0x0040 +}; +RS_REGISTER_ENUM_FLAGS_TYPE(RsDhtRelayMode) class RsDhtPeer { @@ -188,8 +190,8 @@ virtual int getRelayServerList(std::list &ids) = 0; virtual int addRelayServer(std::string ids) = 0; virtual int removeRelayServer(std::string ids) = 0; -virtual uint32_t getRelayMode() = 0; -virtual int setRelayMode(uint32_t mode) = 0; +virtual RsDhtRelayMode getRelayMode() = 0; +virtual int setRelayMode(RsDhtRelayMode mode) = 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; diff --git a/retroshare-gui/src/gui/settings/ServerPage.cpp b/retroshare-gui/src/gui/settings/ServerPage.cpp index 1f178405d..b041e1f31 100755 --- a/retroshare-gui/src/gui/settings/ServerPage.cpp +++ b/retroshare-gui/src/gui/settings/ServerPage.cpp @@ -461,11 +461,11 @@ void ServerPage::load() updateTotals(); - uint32_t relayMode = rsDht->getRelayMode(); - if (relayMode & RSDHT_RELAY_ENABLED) + RsDhtRelayMode relayMode = rsDht->getRelayMode(); + if (!!(relayMode & RsDhtRelayMode::ENABLED)) { 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); } @@ -1894,23 +1894,23 @@ void ServerPage::updateTotals() void ServerPage::updateRelayMode() { - uint32_t relayMode = 0; + RsDhtRelayMode relayMode = static_cast(0); if (ui.enableCheckBox->isChecked()) { - relayMode |= RSDHT_RELAY_ENABLED; + relayMode |= RsDhtRelayMode::ENABLED; if (ui.serverCheckBox->isChecked()) { - relayMode |= RSDHT_RELAY_MODE_ON; + relayMode |= RsDhtRelayMode::ON; } else { - relayMode |= RSDHT_RELAY_MODE_OFF; + relayMode |= RsDhtRelayMode::OFF; } } else { - relayMode |= RSDHT_RELAY_MODE_OFF; + relayMode |= RsDhtRelayMode::OFF; } rsDht->setRelayMode(relayMode); From 7599b7ad9c8b1b776f63da89d86f42ebfe20adee Mon Sep 17 00:00:00 2001 From: sehraf Date: Wed, 19 Feb 2020 18:58:04 +0100 Subject: [PATCH 10/24] remove unused RS_DHT_NETSTART_* --- libretroshare/src/retroshare/rsdht.h | 8 -------- 1 file changed, 8 deletions(-) diff --git a/libretroshare/src/retroshare/rsdht.h b/libretroshare/src/retroshare/rsdht.h index 434e04328..1d1397703 100644 --- a/libretroshare/src/retroshare/rsdht.h +++ b/libretroshare/src/retroshare/rsdht.h @@ -36,14 +36,6 @@ extern RsDht *rsDht; //std::ostream &operator<<(std::ostream &out, const RsPhotoShowDetails &detail); //std::ostream &operator<<(std::ostream &out, const RsPhotoDetails &detail); -#define RSDHT_NETSTART_NETWORKMODE 0x0001 -#define RSDHT_NETSTART_NATTYPE 0x0002 -#define RSDHT_NETSTART_NATHOLE 0x0003 -#define RSDHT_NETSTART_CONNECTMODES 0x0004 -#define RSDHT_NETSTART_NETSTATE 0x0005 - - - #define RSDHT_PEERTYPE_ANY 0x0000 #define RSDHT_PEERTYPE_OTHER 0x0001 #define RSDHT_PEERTYPE_FOF 0x0002 From 1b1b09217a9c82c9e277e1fb3fc7dc9cf20dd67e Mon Sep 17 00:00:00 2001 From: sehraf Date: Wed, 19 Feb 2020 19:29:37 +0100 Subject: [PATCH 11/24] convert RSDHT_PEERTYPE_ to enum class --- libretroshare/src/dht/p3bitdht.h | 6 ++-- libretroshare/src/dht/p3bitdht_peernet.cc | 42 +++++++++++------------ libretroshare/src/dht/p3bitdht_peers.cc | 36 +++++++++---------- libretroshare/src/retroshare/rsdht.h | 13 ++++--- 4 files changed, 50 insertions(+), 47 deletions(-) diff --git a/libretroshare/src/dht/p3bitdht.h b/libretroshare/src/dht/p3bitdht.h index b71f0893e..f615da760 100644 --- a/libretroshare/src/dht/p3bitdht.h +++ b/libretroshare/src/dht/p3bitdht.h @@ -45,7 +45,7 @@ class DhtPeerDetails DhtPeerDetails(); - uint32_t mPeerType; + RsDhtPeerType mPeerType; bdId mDhtId; RsPeerId mRsId; @@ -348,9 +348,9 @@ public: private: - DhtPeerDetails *addInternalPeer_locked(const RsPeerId& pid, uint32_t type); + DhtPeerDetails *addInternalPeer_locked(const RsPeerId& pid, RsDhtPeerType type); int removeInternalPeer_locked(const RsPeerId& pid); - DhtPeerDetails *findInternalDhtPeer_locked(const bdNodeId *id, uint32_t type); + DhtPeerDetails *findInternalDhtPeer_locked(const bdNodeId *id, RsDhtPeerType type); DhtPeerDetails *findInternalRsPeer_locked(const RsPeerId &pid); bool havePeerTranslation_locked(const RsPeerId &pid); diff --git a/libretroshare/src/dht/p3bitdht_peernet.cc b/libretroshare/src/dht/p3bitdht_peernet.cc index f0ef22b89..b0fb9c735 100644 --- a/libretroshare/src/dht/p3bitdht_peernet.cc +++ b/libretroshare/src/dht/p3bitdht_peernet.cc @@ -83,7 +83,7 @@ int p3BitDht::InfoCallback(const bdId *id, uint32_t /*type*/, uint32_t /*flags*/ { RsStackMutex stack(dhtMtx); /********** LOCKED MUTEX ***************/ - DhtPeerDetails *dpd = findInternalDhtPeer_locked(&(id->id), RSDHT_PEERTYPE_ANY); + DhtPeerDetails *dpd = findInternalDhtPeer_locked(&(id->id), RsDhtPeerType::ANY); if (dpd) { @@ -204,7 +204,7 @@ int p3BitDht::PeerCallback(const bdId *id, uint32_t status) RsStackMutex stack(dhtMtx); /********** LOCKED MUTEX ***************/ - DhtPeerDetails *dpd = findInternalDhtPeer_locked(&(id->id), RSDHT_PEERTYPE_FRIEND); + DhtPeerDetails *dpd = findInternalDhtPeer_locked(&(id->id), RsDhtPeerType::FRIEND); if (!dpd) { @@ -717,7 +717,7 @@ int p3BitDht::ConnectCallback(const bdId *srcId, const bdId *proxyId, const bdId std::cerr << std::endl; #endif - DhtPeerDetails *dpd = findInternalDhtPeer_locked(&(peerId.id), RSDHT_PEERTYPE_FRIEND); + DhtPeerDetails *dpd = findInternalDhtPeer_locked(&(peerId.id), RsDhtPeerType::FRIEND); if (dpd) { proxyPort = dpd->mConnectLogic.shouldUseProxyPort( @@ -811,7 +811,7 @@ int p3BitDht::ConnectCallback(const bdId *srcId, const bdId *proxyId, const bdId std::cerr << std::endl; #endif - DhtPeerDetails *dpd = findInternalDhtPeer_locked(&(peerId.id), RSDHT_PEERTYPE_FRIEND); + DhtPeerDetails *dpd = findInternalDhtPeer_locked(&(peerId.id), RsDhtPeerType::FRIEND); if (dpd) { dpd->mExclusiveProxyLock = true; @@ -939,7 +939,7 @@ int p3BitDht::ConnectCallback(const bdId *srcId, const bdId *proxyId, const bdId RsStackMutex stack(dhtMtx); /********** LOCKED MUTEX ***************/ - DhtPeerDetails *dpd = findInternalDhtPeer_locked(&(peerId.id), RSDHT_PEERTYPE_FRIEND); + DhtPeerDetails *dpd = findInternalDhtPeer_locked(&(peerId.id), RsDhtPeerType::FRIEND); if (dpd) { dpd->mPeerCbMsg = "ERROR : "; @@ -980,7 +980,7 @@ int p3BitDht::ConnectCallback(const bdId *srcId, const bdId *proxyId, const bdId RsStackMutex stack(dhtMtx); /********** LOCKED MUTEX ***************/ - DhtPeerDetails *dpd = findInternalDhtPeer_locked(&(peerId.id), RSDHT_PEERTYPE_FRIEND); + DhtPeerDetails *dpd = findInternalDhtPeer_locked(&(peerId.id), RsDhtPeerType::FRIEND); if (dpd) { if (errcode) @@ -1232,7 +1232,7 @@ int p3BitDht::doActions() { RsStackMutex stack(dhtMtx); /********** LOCKED MUTEX ***************/ - DhtPeerDetails *dpd = findInternalDhtPeer_locked(&(action.mDestId.id), RSDHT_PEERTYPE_FRIEND); + DhtPeerDetails *dpd = findInternalDhtPeer_locked(&(action.mDestId.id), RsDhtPeerType::FRIEND); if (dpd) { connectOk = true; @@ -1387,7 +1387,7 @@ int p3BitDht::doActions() #endif - DhtPeerDetails *dpd = findInternalDhtPeer_locked(&(action.mDestId.id), RSDHT_PEERTYPE_FRIEND); + DhtPeerDetails *dpd = findInternalDhtPeer_locked(&(action.mDestId.id), RsDhtPeerType::FRIEND); if (dpd) { dpd->mPeerReqStatusMsg = "Connect Request"; @@ -1428,7 +1428,7 @@ int p3BitDht::doActions() //} RsStackMutex stack(dhtMtx); /********** LOCKED MUTEX ***************/ - DhtPeerDetails *dpd = findInternalDhtPeer_locked(&(action.mDestId.id), RSDHT_PEERTYPE_FRIEND); + DhtPeerDetails *dpd = findInternalDhtPeer_locked(&(action.mDestId.id), RsDhtPeerType::FRIEND); if (dpd) { dpd->mConnectLogic.updateCb(failReason); @@ -1496,7 +1496,7 @@ int p3BitDht::doActions() { RsStackMutex stack(dhtMtx); /********** LOCKED MUTEX ***************/ - DhtPeerDetails *dpd = findInternalDhtPeer_locked(&(action.mSrcId.id), RSDHT_PEERTYPE_ANY); + DhtPeerDetails *dpd = findInternalDhtPeer_locked(&(action.mSrcId.id), RsDhtPeerType::ANY); if (dpd) { if (action.mAnswer) @@ -1604,7 +1604,7 @@ int p3BitDht::doActions() { RsStackMutex stack(dhtMtx); /********** LOCKED MUTEX ***************/ - DhtPeerDetails *dpd = findInternalDhtPeer_locked(&(action.mDestId.id), RSDHT_PEERTYPE_ANY); + DhtPeerDetails *dpd = findInternalDhtPeer_locked(&(action.mDestId.id), RsDhtPeerType::ANY); if (dpd) { peerRsId = dpd->mRsId; @@ -1730,7 +1730,7 @@ int p3BitDht::checkConnectionAllowed(const bdId *peerId, int mode) rstime_t now = time(NULL); /* check if they are in our friend list */ - DhtPeerDetails *dpd = findInternalDhtPeer_locked(&(peerId->id), RSDHT_PEERTYPE_FRIEND); + DhtPeerDetails *dpd = findInternalDhtPeer_locked(&(peerId->id), RsDhtPeerType::FRIEND); if (!dpd) { #ifdef DEBUG_PEERNET @@ -1752,7 +1752,7 @@ int p3BitDht::checkConnectionAllowed(const bdId *peerId, int mode) it->second.mDhtState = RSDHT_PEERDHT_NOT_ACTIVE; it->second.mDhtUpdateTS = now; - it->second.mPeerType = RSDHT_PEERTYPE_OTHER; + it->second.mPeerType = RsDhtPeerType::OTHER; it->second.mPeerCbMsg = "Denied Non-Friend"; it->second.mPeerReqStatusMsg = "Denied Non-Friend"; @@ -1979,7 +1979,7 @@ void p3BitDht::initiateConnection(const bdId *srcId, const bdId *proxyId, const { RsStackMutex stack(dhtMtx); /********** LOCKED MUTEX ***************/ - DhtPeerDetails *dpd = findInternalDhtPeer_locked(&(peerConnectId.id), RSDHT_PEERTYPE_FRIEND); + DhtPeerDetails *dpd = findInternalDhtPeer_locked(&(peerConnectId.id), RsDhtPeerType::FRIEND); /* grab a socket */ if (!dpd) { @@ -2092,22 +2092,22 @@ int p3BitDht::installRelayConnection(const bdId *srcId, const bdId *destId, uint #endif /* grab a socket */ - DhtPeerDetails *dpd_src = findInternalDhtPeer_locked(&(srcId->id), RSDHT_PEERTYPE_ANY); - DhtPeerDetails *dpd_dest = findInternalDhtPeer_locked(&(destId->id), RSDHT_PEERTYPE_ANY); + DhtPeerDetails *dpd_src = findInternalDhtPeer_locked(&(srcId->id), RsDhtPeerType::ANY); + DhtPeerDetails *dpd_dest = findInternalDhtPeer_locked(&(destId->id), RsDhtPeerType::ANY); - if ((dpd_src) && (dpd_src->mPeerType == RSDHT_PEERTYPE_FRIEND)) + if ((dpd_src) && (dpd_src->mPeerType == RsDhtPeerType::FRIEND)) { relayClass = UDP_RELAY_CLASS_FRIENDS; } - else if ((dpd_dest) && (dpd_dest->mPeerType == RSDHT_PEERTYPE_FRIEND)) + else if ((dpd_dest) && (dpd_dest->mPeerType == RsDhtPeerType::FRIEND)) { relayClass = UDP_RELAY_CLASS_FRIENDS; } - else if ((dpd_src) && (dpd_src->mPeerType == RSDHT_PEERTYPE_FOF)) + else if ((dpd_src) && (dpd_src->mPeerType == RsDhtPeerType::FOF)) { relayClass = UDP_RELAY_CLASS_FOF; } - else if ((dpd_dest) && (dpd_dest->mPeerType == RSDHT_PEERTYPE_FOF)) + else if ((dpd_dest) && (dpd_dest->mPeerType == RsDhtPeerType::FOF)) { relayClass = UDP_RELAY_CLASS_FOF; } @@ -2178,7 +2178,7 @@ void p3BitDht::monitorConnections() for(it = mPeers.begin(); it != mPeers.end(); ++it) { /* ignore ones which aren't friends */ - if (it->second.mPeerType != RSDHT_PEERTYPE_FRIEND) + if (it->second.mPeerType != RsDhtPeerType::FRIEND) { continue; } diff --git a/libretroshare/src/dht/p3bitdht_peers.cc b/libretroshare/src/dht/p3bitdht_peers.cc index 8c6e7d071..2b047753f 100644 --- a/libretroshare/src/dht/p3bitdht_peers.cc +++ b/libretroshare/src/dht/p3bitdht_peers.cc @@ -64,7 +64,7 @@ bool p3BitDht::findPeer(const RsPeerId& pid) DhtPeerDetails *dpd = findInternalRsPeer_locked(pid); if (!dpd) { - dpd = addInternalPeer_locked(pid, RSDHT_PEERTYPE_FRIEND); + dpd = addInternalPeer_locked(pid, RsDhtPeerType::FRIEND); if (!dpd) { /* ERROR */ @@ -150,7 +150,7 @@ bool p3BitDht::dropPeer(const RsPeerId& pid) #endif //addFriend(pid); - dpd = addInternalPeer_locked(pid, RSDHT_PEERTYPE_FOF); + dpd = addInternalPeer_locked(pid, RsDhtPeerType::FOF); return false; } @@ -242,7 +242,7 @@ int p3BitDht::addKnownPeer( const RsPeerId &pid, addrv4.sin_addr = ap->sin_addr; addrv4.sin_port = ap->sin_port; - int p3type = 0; + RsDhtPeerType p3type = static_cast(0); int bdflags = 0; bdId id; bool isOwnId = false; @@ -253,27 +253,27 @@ int p3BitDht::addKnownPeer( const RsPeerId &pid, return 0; break; case NETASSIST_KNOWN_PEER_WHITELIST: - p3type = RSDHT_PEERTYPE_OTHER; + p3type = RsDhtPeerType::OTHER; bdflags = BITDHT_PEER_STATUS_DHT_WHITELIST; break; case NETASSIST_KNOWN_PEER_FOF: - p3type = RSDHT_PEERTYPE_FOF; + p3type = RsDhtPeerType::FOF; bdflags = BITDHT_PEER_STATUS_DHT_FOF; break; case NETASSIST_KNOWN_PEER_FRIEND: - p3type = RSDHT_PEERTYPE_FRIEND; + p3type = RsDhtPeerType::FRIEND; bdflags = BITDHT_PEER_STATUS_DHT_FRIEND; break; case NETASSIST_KNOWN_PEER_RELAY: - p3type = RSDHT_PEERTYPE_OTHER; + p3type = RsDhtPeerType::OTHER; bdflags = BITDHT_PEER_STATUS_DHT_RELAY_SERVER; break; case NETASSIST_KNOWN_PEER_SELF: - p3type = RSDHT_PEERTYPE_OTHER; + p3type = RsDhtPeerType::OTHER; bdflags = BITDHT_PEER_STATUS_DHT_SELF; isOwnId = true; @@ -364,7 +364,7 @@ int p3BitDht::addFriend(const std::string pid) { RsStackMutex stack(dhtMtx); /********* LOCKED *********/ - return (NULL != addInternalPeer_locked(pid, RSDHT_PEERTYPE_FRIEND)); + return (NULL != addInternalPeer_locked(pid, RsDhtPeerType::FRIEND)); } @@ -372,7 +372,7 @@ int p3BitDht::addFriendOfFriend(const std::string pid) { RsStackMutex stack(dhtMtx); /********* LOCKED *********/ - return (NULL != addInternalPeer_locked(pid, RSDHT_PEERTYPE_FOF)); + return (NULL != addInternalPeer_locked(pid, RsDhtPeerType::FOF)); } @@ -380,7 +380,7 @@ int p3BitDht::addOther(const std::string pid) { RsStackMutex stack(dhtMtx); /********* LOCKED *********/ - return (NULL != addInternalPeer_locked(pid, RSDHT_PEERTYPE_OTHER)); + return (NULL != addInternalPeer_locked(pid, RsDhtPeerType::OTHER)); } #endif @@ -397,7 +397,7 @@ int p3BitDht::removePeer(const RsPeerId& pid) ********************************* Basic Peer Details ************************************* ******************************************************************************************/ -DhtPeerDetails *p3BitDht::addInternalPeer_locked(const RsPeerId& pid, uint32_t type) +DhtPeerDetails *p3BitDht::addInternalPeer_locked(const RsPeerId& pid, RsDhtPeerType type) { /* create the data structure */ if (!havePeerTranslation_locked(pid)) @@ -411,7 +411,7 @@ DhtPeerDetails *p3BitDht::addInternalPeer_locked(const RsPeerId& pid, uint32_t t return 0; } - DhtPeerDetails *dpd = findInternalDhtPeer_locked(&id, RSDHT_PEERTYPE_ANY); + DhtPeerDetails *dpd = findInternalDhtPeer_locked(&id, RsDhtPeerType::ANY); if (!dpd) { DhtPeerDetails newdpd; @@ -419,10 +419,10 @@ DhtPeerDetails *p3BitDht::addInternalPeer_locked(const RsPeerId& pid, uint32_t t newdpd.mDhtId.id = id; newdpd.mRsId = pid; newdpd.mDhtState = RSDHT_PEERDHT_NOT_ACTIVE; - newdpd.mPeerType = RSDHT_PEERTYPE_ANY; + newdpd.mPeerType = RsDhtPeerType::ANY; mPeers[id] = newdpd; - dpd = findInternalDhtPeer_locked(&id, RSDHT_PEERTYPE_ANY); + dpd = findInternalDhtPeer_locked(&id, RsDhtPeerType::ANY); if(dpd == NULL) { @@ -462,14 +462,14 @@ int p3BitDht::removeInternalPeer_locked(const RsPeerId& pid) /* indexed by bdNodeId, as this is the more used call interface */ -DhtPeerDetails *p3BitDht::findInternalDhtPeer_locked(const bdNodeId *id, uint32_t type) +DhtPeerDetails *p3BitDht::findInternalDhtPeer_locked(const bdNodeId *id, RsDhtPeerType type) { std::map::iterator it = mPeers.find(*id); if (it == mPeers.end()) { return NULL; } - if (type) + if (type != static_cast(0)) { if (it->second.mPeerType != type) { @@ -495,7 +495,7 @@ DhtPeerDetails *p3BitDht::findInternalRsPeer_locked(const RsPeerId &pid) return NULL; } - DhtPeerDetails *dpd = findInternalDhtPeer_locked(&id,RSDHT_PEERTYPE_ANY); + DhtPeerDetails *dpd = findInternalDhtPeer_locked(&id,RsDhtPeerType::ANY); return dpd; } diff --git a/libretroshare/src/retroshare/rsdht.h b/libretroshare/src/retroshare/rsdht.h index 1d1397703..18de826b9 100644 --- a/libretroshare/src/retroshare/rsdht.h +++ b/libretroshare/src/retroshare/rsdht.h @@ -36,10 +36,13 @@ extern RsDht *rsDht; //std::ostream &operator<<(std::ostream &out, const RsPhotoShowDetails &detail); //std::ostream &operator<<(std::ostream &out, const RsPhotoDetails &detail); -#define RSDHT_PEERTYPE_ANY 0x0000 -#define RSDHT_PEERTYPE_OTHER 0x0001 -#define RSDHT_PEERTYPE_FOF 0x0002 -#define RSDHT_PEERTYPE_FRIEND 0x0003 +enum class RsDhtPeerType : uint8_t +{ + ANY = 0, + OTHER = 1, + FOF = 2, + FRIEND = 3 +}; #define RSDHT_PEERDHT_NOT_ACTIVE 0x0000 #define RSDHT_PEERDHT_SEARCHING 0x0001 @@ -102,7 +105,7 @@ class RsDhtNetPeer std::string mDhtId; RsPeerId mRsId; - uint32_t mPeerType; + RsDhtPeerType mPeerType; uint32_t mDhtState; std::string mConnectState; // connectLogic. From 8d0a352b534c01672f84bdbc8bbfa7e2e775de9d Mon Sep 17 00:00:00 2001 From: sehraf Date: Wed, 19 Feb 2020 19:35:34 +0100 Subject: [PATCH 12/24] convert RSDHT_PEERDHT_ to enum class --- libretroshare/src/dht/p3bitdht.h | 2 +- libretroshare/src/dht/p3bitdht_peernet.cc | 12 ++++++------ libretroshare/src/dht/p3bitdht_peers.cc | 14 +++++++------- libretroshare/src/retroshare/rsdht.h | 17 ++++++++++------- .../src/gui/connect/ConnectProgressDialog.cpp | 12 ++++++------ retroshare-gui/src/gui/statistics/DhtWindow.cpp | 12 ++++++------ 6 files changed, 36 insertions(+), 33 deletions(-) diff --git a/libretroshare/src/dht/p3bitdht.h b/libretroshare/src/dht/p3bitdht.h index f615da760..8ddc1cea0 100644 --- a/libretroshare/src/dht/p3bitdht.h +++ b/libretroshare/src/dht/p3bitdht.h @@ -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 */ diff --git a/libretroshare/src/dht/p3bitdht_peernet.cc b/libretroshare/src/dht/p3bitdht_peernet.cc index b0fb9c735..fa14dd8b5 100644 --- a/libretroshare/src/dht/p3bitdht_peernet.cc +++ b/libretroshare/src/dht/p3bitdht_peernet.cc @@ -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; diff --git a/libretroshare/src/dht/p3bitdht_peers.cc b/libretroshare/src/dht/p3bitdht_peers.cc index 2b047753f..4e023e3d4 100644 --- a/libretroshare/src/dht/p3bitdht_peers.cc +++ b/libretroshare/src/dht/p3bitdht_peers.cc @@ -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"; diff --git a/libretroshare/src/retroshare/rsdht.h b/libretroshare/src/retroshare/rsdht.h index 18de826b9..abd546adb 100644 --- a/libretroshare/src/retroshare/rsdht.h +++ b/libretroshare/src/retroshare/rsdht.h @@ -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. diff --git a/retroshare-gui/src/gui/connect/ConnectProgressDialog.cpp b/retroshare-gui/src/gui/connect/ConnectProgressDialog.cpp index a3040ab93..3de28c8d2 100755 --- a/retroshare-gui/src/gui/connect/ConnectProgressDialog.cpp +++ b/retroshare-gui/src/gui/connect/ConnectProgressDialog.cpp @@ -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; diff --git a/retroshare-gui/src/gui/statistics/DhtWindow.cpp b/retroshare-gui/src/gui/statistics/DhtWindow.cpp index b947ba07a..c2e0264f7 100644 --- a/retroshare-gui/src/gui/statistics/DhtWindow.cpp +++ b/retroshare-gui/src/gui/statistics/DhtWindow.cpp @@ -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; From fcaabb19224c1a4372d0e34c31e3e41bc4d31f3e Mon Sep 17 00:00:00 2001 From: sehraf Date: Wed, 19 Feb 2020 19:54:37 +0100 Subject: [PATCH 13/24] convert RSDHT_PEERCONN_ to enum class --- libretroshare/src/dht/p3bitdht.h | 2 +- libretroshare/src/dht/p3bitdht_peernet.cc | 24 +++++++++---------- libretroshare/src/dht/p3bitdht_peers.cc | 2 +- libretroshare/src/retroshare/rsdht.h | 11 +++++---- .../src/gui/statistics/DhtWindow.cpp | 8 +++---- 5 files changed, 25 insertions(+), 22 deletions(-) diff --git a/libretroshare/src/dht/p3bitdht.h b/libretroshare/src/dht/p3bitdht.h index 8ddc1cea0..9a84bf51d 100644 --- a/libretroshare/src/dht/p3bitdht.h +++ b/libretroshare/src/dht/p3bitdht.h @@ -58,7 +58,7 @@ class DhtPeerDetails PeerConnectStateBox mConnectLogic; /* Actual Connection Status */ - uint32_t mPeerConnectState; // One of RSDHT_PEERCONN_ + RsDhtPeerConnectState mPeerConnectState; std::string mPeerConnectMsg; uint32_t mPeerConnectMode; bdId mPeerConnectPeerId; diff --git a/libretroshare/src/dht/p3bitdht_peernet.cc b/libretroshare/src/dht/p3bitdht_peernet.cc index fa14dd8b5..12226584e 100644 --- a/libretroshare/src/dht/p3bitdht_peernet.cc +++ b/libretroshare/src/dht/p3bitdht_peernet.cc @@ -262,7 +262,7 @@ int p3BitDht::OnlinePeerCallback_locked(const bdId *id, uint32_t /*status*/, Dht /* remove unused parameter warnings */ (void) id; - if ((dpd->mPeerConnectState != RSDHT_PEERCONN_DISCONNECTED) || + if ((dpd->mPeerConnectState != RsDhtPeerConnectState::DISCONNECTED) || (dpd->mPeerReqState == RSDHT_PEERREQ_RUNNING)) { @@ -367,7 +367,7 @@ int p3BitDht::OnlinePeerCallback_locked(const bdId *id, uint32_t /*status*/, Dht int p3BitDht::UnreachablePeerCallback_locked(const bdId *id, uint32_t /*status*/, DhtPeerDetails *dpd) { - if ((dpd->mPeerConnectState != RSDHT_PEERCONN_DISCONNECTED) || + if ((dpd->mPeerConnectState != RsDhtPeerConnectState::DISCONNECTED) || (dpd->mPeerReqState == RSDHT_PEERREQ_RUNNING)) { @@ -1765,7 +1765,7 @@ int p3BitDht::checkConnectionAllowed(const bdId *peerId, int mode) it->second.mPeerCbMsg = "Denied Non-Friend"; it->second.mPeerConnectMsg = "Denied Non-Friend"; - it->second.mPeerConnectState = RSDHT_PEERCONN_DISCONNECTED; + it->second.mPeerConnectState = RsDhtPeerConnectState::DISCONNECTED; return 0; @@ -1774,7 +1774,7 @@ int p3BitDht::checkConnectionAllowed(const bdId *peerId, int mode) /* are a friend */ - if (dpd->mPeerConnectState == RSDHT_PEERCONN_CONNECTED) + if (dpd->mPeerConnectState == RsDhtPeerConnectState::CONNECTED) { std::cerr << "p3BitDht::checkConnectionAllowed() ERROR Peer Already Connected, DENIED"; std::cerr << std::endl; @@ -1988,7 +1988,7 @@ void p3BitDht::initiateConnection(const bdId *srcId, const bdId *proxyId, const return; } - if (dpd->mPeerConnectState != RSDHT_PEERCONN_DISCONNECTED) + if (dpd->mPeerConnectState != RsDhtPeerConnectState::DISCONNECTED) { std::cerr << "p3BitDht::initiateConnection() ERROR Peer is not Disconnected"; std::cerr << std::endl; @@ -2047,7 +2047,7 @@ void p3BitDht::initiateConnection(const bdId *srcId, const bdId *proxyId, const /* store results in Status */ dpd->mPeerConnectMsg = "UDP started"; - dpd->mPeerConnectState = RSDHT_PEERCONN_UDP_STARTED; + dpd->mPeerConnectState = RsDhtPeerConnectState::UDP_STARTED; dpd->mPeerConnectUdpTS = time(NULL); dpd->mPeerConnectMode = mode; dpd->mPeerConnectPoint = loc; @@ -2183,7 +2183,7 @@ void p3BitDht::monitorConnections() continue; } - if (it->second.mPeerConnectState == RSDHT_PEERCONN_UDP_STARTED) + if (it->second.mPeerConnectState == RsDhtPeerConnectState::UDP_STARTED) { #ifdef DEBUG_PEERNET std::cerr << "p3BitDht::monitorConnections() Connection in progress to: "; @@ -2225,7 +2225,7 @@ void p3BitDht::Feedback_Connected(const RsPeerId& pid) } /* sanity checking */ - if (dpd->mPeerConnectState != RSDHT_PEERCONN_UDP_STARTED) + if (dpd->mPeerConnectState != RsDhtPeerConnectState::UDP_STARTED) { /* ERROR */ std::cerr << "p3BitDht::Feedback_Connected() ERROR not in UDP_STARTED mode for: "; @@ -2242,7 +2242,7 @@ void p3BitDht::Feedback_Connected(const RsPeerId& pid) #endif /* switch state! */ - dpd->mPeerConnectState = RSDHT_PEERCONN_CONNECTED; + dpd->mPeerConnectState = RsDhtPeerConnectState::CONNECTED; dpd->mPeerConnectTS = time(NULL); dpd->mConnectLogic.updateCb(CSB_UPDATE_CONNECTED); @@ -2334,7 +2334,7 @@ void p3BitDht::Feedback_ConnectionClosed(const RsPeerId& pid) void p3BitDht::UdpConnectionFailed_locked(DhtPeerDetails *dpd) { - if (dpd->mPeerConnectState == RSDHT_PEERCONN_UDP_STARTED) + if (dpd->mPeerConnectState == RsDhtPeerConnectState::UDP_STARTED) { #ifdef DEBUG_PEERNET std::cerr << "p3BitDht::UdpConnectionFailed_locked() UDP Connection Failed: "; @@ -2349,7 +2349,7 @@ void p3BitDht::UdpConnectionFailed_locked(DhtPeerDetails *dpd) { dpd->mConnectLogic.updateCb(CSB_UPDATE_FAILED_ATTEMPT); } - dpd->mPeerConnectState = RSDHT_PEERCONN_DISCONNECTED; + dpd->mPeerConnectState = RsDhtPeerConnectState::DISCONNECTED; dpd->mPeerConnectMsg = "UDP Failed"; } @@ -2363,7 +2363,7 @@ void p3BitDht::UdpConnectionFailed_locked(DhtPeerDetails *dpd) dpd->mConnectLogic.updateCb(CSB_UPDATE_DISCONNECTED); - dpd->mPeerConnectState = RSDHT_PEERCONN_DISCONNECTED; + dpd->mPeerConnectState = RsDhtPeerConnectState::DISCONNECTED; dpd->mPeerConnectClosedTS = time(NULL); rs_sprintf(dpd->mPeerConnectMsg, "Closed, Alive for: %ld secs", dpd->mPeerConnectClosedTS - dpd->mPeerConnectTS); } diff --git a/libretroshare/src/dht/p3bitdht_peers.cc b/libretroshare/src/dht/p3bitdht_peers.cc index 4e023e3d4..3c313a58c 100644 --- a/libretroshare/src/dht/p3bitdht_peers.cc +++ b/libretroshare/src/dht/p3bitdht_peers.cc @@ -737,7 +737,7 @@ DhtPeerDetails::DhtPeerDetails() //mPeerCbDestId = 0; mPeerCbTS = 0; - mPeerConnectState = RSDHT_PEERCONN_DISCONNECTED; + mPeerConnectState = RsDhtPeerConnectState::DISCONNECTED; mPeerConnectMsg = "Disconnected"; mPeerConnectMode = 0; //dpd->mPeerConnectProxyId; diff --git a/libretroshare/src/retroshare/rsdht.h b/libretroshare/src/retroshare/rsdht.h index abd546adb..358e9d529 100644 --- a/libretroshare/src/retroshare/rsdht.h +++ b/libretroshare/src/retroshare/rsdht.h @@ -54,9 +54,12 @@ enum class RsDhtPeerDht : uint8_t ONLINE = 5 }; -#define RSDHT_PEERCONN_DISCONNECTED 1 -#define RSDHT_PEERCONN_UDP_STARTED 2 -#define RSDHT_PEERCONN_CONNECTED 3 +enum class RsDhtPeerConnectState : uint8_t +{ + DISCONNECTED = 1, + UDP_STARTED = 2, + CONNECTED = 3 +}; #define RSDHT_PEERREQ_STOPPED 1 #define RSDHT_PEERREQ_RUNNING 2 @@ -113,7 +116,7 @@ class RsDhtNetPeer std::string mConnectState; // connectLogic. - uint32_t mPeerConnectState; // connect Status + RsDhtPeerConnectState mPeerConnectState; // connect Status uint32_t mPeerConnectMode; // connect mode bool mExclusiveProxyLock; diff --git a/retroshare-gui/src/gui/statistics/DhtWindow.cpp b/retroshare-gui/src/gui/statistics/DhtWindow.cpp index c2e0264f7..e3fe0bc5a 100644 --- a/retroshare-gui/src/gui/statistics/DhtWindow.cpp +++ b/retroshare-gui/src/gui/statistics/DhtWindow.cpp @@ -430,14 +430,14 @@ void DhtWindow::updateNetPeers() switch(status.mPeerConnectState) { default: - case RSDHT_PEERCONN_DISCONNECTED: + case RsDhtPeerConnectState::DISCONNECTED: cpsstr = tr("Disconnected"); ++nDisconnPeers; break; - case RSDHT_PEERCONN_UDP_STARTED: + case RsDhtPeerConnectState::UDP_STARTED: cpsstr = tr("Udp Started"); break; - case RSDHT_PEERCONN_CONNECTED: + case RsDhtPeerConnectState::CONNECTED: { cpsstr = tr("Connected"); @@ -460,7 +460,7 @@ void DhtWindow::updateNetPeers() peer_item -> setData(PTW_COL_PEER_CONNECT_STATUS, Qt::DisplayRole, cpsstr); - if (status.mPeerConnectState == RSDHT_PEERCONN_DISCONNECTED) + if (status.mPeerConnectState == RsDhtPeerConnectState::DISCONNECTED) { peer_item -> setData(PTW_COL_PEER_CONNECT_MODE, Qt::DisplayRole, ""); } From 46d77bfe7a1d238232b839d2e3dde02b972960b4 Mon Sep 17 00:00:00 2001 From: sehraf Date: Wed, 19 Feb 2020 19:57:46 +0100 Subject: [PATCH 14/24] convert RSDHT_PEERREQ_ to enum class --- libretroshare/src/dht/p3bitdht.h | 2 +- libretroshare/src/dht/p3bitdht_peernet.cc | 20 +++++++++---------- libretroshare/src/dht/p3bitdht_peers.cc | 2 +- libretroshare/src/retroshare/rsdht.h | 9 ++++++--- .../src/gui/statistics/DhtWindow.cpp | 4 ++-- 5 files changed, 20 insertions(+), 17 deletions(-) diff --git a/libretroshare/src/dht/p3bitdht.h b/libretroshare/src/dht/p3bitdht.h index 9a84bf51d..277054494 100644 --- a/libretroshare/src/dht/p3bitdht.h +++ b/libretroshare/src/dht/p3bitdht.h @@ -77,7 +77,7 @@ class DhtPeerDetails /* Connection Request Status */ std::string mPeerReqStatusMsg; - uint32_t mPeerReqState; + RsDhtPeerRequest mPeerReqState; uint32_t mPeerReqMode; bdId mPeerReqProxyId; rstime_t mPeerReqTS; diff --git a/libretroshare/src/dht/p3bitdht_peernet.cc b/libretroshare/src/dht/p3bitdht_peernet.cc index 12226584e..635a12bd8 100644 --- a/libretroshare/src/dht/p3bitdht_peernet.cc +++ b/libretroshare/src/dht/p3bitdht_peernet.cc @@ -263,7 +263,7 @@ int p3BitDht::OnlinePeerCallback_locked(const bdId *id, uint32_t /*status*/, Dht (void) id; if ((dpd->mPeerConnectState != RsDhtPeerConnectState::DISCONNECTED) || - (dpd->mPeerReqState == RSDHT_PEERREQ_RUNNING)) + (dpd->mPeerReqState == RsDhtPeerRequest::RUNNING)) { #ifdef DEBUG_PEERNET @@ -368,7 +368,7 @@ int p3BitDht::UnreachablePeerCallback_locked(const bdId *id, uint32_t /*status*/ { if ((dpd->mPeerConnectState != RsDhtPeerConnectState::DISCONNECTED) || - (dpd->mPeerReqState == RSDHT_PEERREQ_RUNNING)) + (dpd->mPeerReqState == RsDhtPeerRequest::RUNNING)) { #ifdef DEBUG_PEERNET @@ -989,7 +989,7 @@ int p3BitDht::ConnectCallback(const bdId *srcId, const bdId *proxyId, const bdId dpd->mPeerReqStatusMsg = "STOPPED: "; dpd->mPeerReqStatusMsg += decodeConnectionError(errcode); - dpd->mPeerReqState = RSDHT_PEERREQ_STOPPED; + dpd->mPeerReqState = RsDhtPeerRequest::STOPPED; dpd->mPeerReqTS = now; int updatecode = CSB_UPDATE_FAILED_ATTEMPT; @@ -1048,7 +1048,7 @@ int p3BitDht::ConnectCallback(const bdId *srcId, const bdId *proxyId, const bdId else // a new connection attempt. { dpd->mPeerReqStatusMsg = "Connect Attempt"; - dpd->mPeerReqState = RSDHT_PEERREQ_RUNNING; + dpd->mPeerReqState = RsDhtPeerRequest::RUNNING; dpd->mPeerReqMode = mode; dpd->mPeerReqProxyId = *proxyId; dpd->mPeerReqTS = now; @@ -1391,7 +1391,7 @@ int p3BitDht::doActions() if (dpd) { dpd->mPeerReqStatusMsg = "Connect Request"; - dpd->mPeerReqState = RSDHT_PEERREQ_RUNNING; + dpd->mPeerReqState = RsDhtPeerRequest::RUNNING; dpd->mPeerReqMode = action.mMode; dpd->mPeerReqTS = now; @@ -1434,7 +1434,7 @@ int p3BitDht::doActions() dpd->mConnectLogic.updateCb(failReason); dpd->mPeerReqStatusMsg = "Req Mode Unavailable"; - dpd->mPeerReqState = RSDHT_PEERREQ_STOPPED; + dpd->mPeerReqState = RsDhtPeerRequest::STOPPED; dpd->mPeerReqMode = action.mMode; dpd->mPeerReqTS = now; @@ -1756,7 +1756,7 @@ int p3BitDht::checkConnectionAllowed(const bdId *peerId, int mode) it->second.mPeerCbMsg = "Denied Non-Friend"; it->second.mPeerReqStatusMsg = "Denied Non-Friend"; - it->second.mPeerReqState = RSDHT_PEERREQ_STOPPED; + it->second.mPeerReqState = RsDhtPeerRequest::STOPPED; it->second.mPeerReqTS = now; it->second.mPeerReqMode = 0; //it->second.mPeerProxyId; @@ -2250,7 +2250,7 @@ void p3BitDht::Feedback_Connected(const RsPeerId& pid) rs_sprintf(dpd->mPeerConnectMsg, "Connected in %ld secs", dpd->mPeerConnectTS - dpd->mPeerConnectUdpTS); // Remove the Connection Request. - if (dpd->mPeerReqState == RSDHT_PEERREQ_RUNNING) + if (dpd->mPeerReqState == RsDhtPeerRequest::RUNNING) { #ifdef DEBUG_PEERNET std::cerr << "p3BitDht::monitorConnections() Request Active, Stopping Request"; @@ -2345,7 +2345,7 @@ void p3BitDht::UdpConnectionFailed_locked(DhtPeerDetails *dpd) /* shut it down */ /* ONLY need to update ConnectLogic - if it was our Attempt Running */ - if (dpd->mPeerReqState == RSDHT_PEERREQ_RUNNING) + if (dpd->mPeerReqState == RsDhtPeerRequest::RUNNING) { dpd->mConnectLogic.updateCb(CSB_UPDATE_FAILED_ATTEMPT); } @@ -2370,7 +2370,7 @@ void p3BitDht::UdpConnectionFailed_locked(DhtPeerDetails *dpd) - if (dpd->mPeerReqState == RSDHT_PEERREQ_RUNNING) + if (dpd->mPeerReqState == RsDhtPeerRequest::RUNNING) { #ifdef DEBUG_PEERNET std::cerr << "p3BitDht::UdpConnectionFailed_locked() "; diff --git a/libretroshare/src/dht/p3bitdht_peers.cc b/libretroshare/src/dht/p3bitdht_peers.cc index 3c313a58c..bf8e87f11 100644 --- a/libretroshare/src/dht/p3bitdht_peers.cc +++ b/libretroshare/src/dht/p3bitdht_peers.cc @@ -723,7 +723,7 @@ DhtPeerDetails::DhtPeerDetails() mDhtUpdateTS = time(NULL); mPeerReqStatusMsg = "Just Added"; - mPeerReqState = RSDHT_PEERREQ_STOPPED; + mPeerReqState = RsDhtPeerRequest::STOPPED; mPeerReqMode = 0; //mPeerReqProxyId; mPeerReqTS = time(NULL); diff --git a/libretroshare/src/retroshare/rsdht.h b/libretroshare/src/retroshare/rsdht.h index 358e9d529..be0776759 100644 --- a/libretroshare/src/retroshare/rsdht.h +++ b/libretroshare/src/retroshare/rsdht.h @@ -61,8 +61,11 @@ enum class RsDhtPeerConnectState : uint8_t CONNECTED = 3 }; -#define RSDHT_PEERREQ_STOPPED 1 -#define RSDHT_PEERREQ_RUNNING 2 +enum class RsDhtPeerRequest : uint8_t +{ + STOPPED = 1, + RUNNING = 2 +}; #define RSDHT_TOU_MODE_NONE 0 #define RSDHT_TOU_MODE_DIRECT 1 @@ -122,7 +125,7 @@ class RsDhtNetPeer std::string mPeerConnectProxyId; - uint32_t mPeerReqState; // Req Status. + RsDhtPeerRequest mPeerReqState; std::string mCbPeerMsg; // Peer Cb Mgs. }; diff --git a/retroshare-gui/src/gui/statistics/DhtWindow.cpp b/retroshare-gui/src/gui/statistics/DhtWindow.cpp index e3fe0bc5a..bf721d7d7 100644 --- a/retroshare-gui/src/gui/statistics/DhtWindow.cpp +++ b/retroshare-gui/src/gui/statistics/DhtWindow.cpp @@ -477,10 +477,10 @@ void DhtWindow::updateNetPeers() } switch(status.mPeerReqState) { - case RSDHT_PEERREQ_RUNNING: + case RsDhtPeerRequest::RUNNING: reqstr += tr("Request Active"); break; - case RSDHT_PEERREQ_STOPPED: + case RsDhtPeerRequest::STOPPED: reqstr += tr("No Request"); break; default: From bc1ba3654d67d6ee76c0fee44633f98c7f3c1239 Mon Sep 17 00:00:00 2001 From: sehraf Date: Wed, 19 Feb 2020 20:00:18 +0100 Subject: [PATCH 15/24] convert RSDHT_TOU_MODE_ to enum class --- libretroshare/src/dht/p3bitdht_interface.cc | 8 ++++---- libretroshare/src/dht/p3bitdht_peernet.cc | 8 ++++---- libretroshare/src/retroshare/rsdht.h | 16 +++++++++------- retroshare-gui/src/gui/statistics/DhtWindow.cpp | 14 +++++++------- 4 files changed, 24 insertions(+), 22 deletions(-) diff --git a/libretroshare/src/dht/p3bitdht_interface.cc b/libretroshare/src/dht/p3bitdht_interface.cc index b67ab8f53..b31bbd03c 100644 --- a/libretroshare/src/dht/p3bitdht_interface.cc +++ b/libretroshare/src/dht/p3bitdht_interface.cc @@ -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; } diff --git a/libretroshare/src/dht/p3bitdht_peernet.cc b/libretroshare/src/dht/p3bitdht_peernet.cc index 635a12bd8..a37678728 100644 --- a/libretroshare/src/dht/p3bitdht_peernet.cc +++ b/libretroshare/src/dht/p3bitdht_peernet.cc @@ -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; diff --git a/libretroshare/src/retroshare/rsdht.h b/libretroshare/src/retroshare/rsdht.h index be0776759..4aa3cc5c8 100644 --- a/libretroshare/src/retroshare/rsdht.h +++ b/libretroshare/src/retroshare/rsdht.h @@ -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; diff --git a/retroshare-gui/src/gui/statistics/DhtWindow.cpp b/retroshare-gui/src/gui/statistics/DhtWindow.cpp index bf721d7d7..27ea76e63 100644 --- a/retroshare-gui/src/gui/statistics/DhtWindow.cpp +++ b/retroshare-gui/src/gui/statistics/DhtWindow.cpp @@ -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; } From 0678226a932909950ad3977ce26a405ee84ccb0d Mon Sep 17 00:00:00 2001 From: sehraf Date: Wed, 19 Feb 2020 20:17:21 +0100 Subject: [PATCH 16/24] convert RSDHT_RELAY_CLASS_ to enum class --- libretroshare/src/dht/p3bitdht.h | 4 ++-- libretroshare/src/dht/p3bitdht_relay.cc | 24 +++++++++---------- libretroshare/src/retroshare/rsdht.h | 17 +++++++------ libretroshare/src/tcponudp/udprelay.cc | 12 +++++----- libretroshare/src/tcponudp/udprelay.h | 12 ++++++---- .../src/gui/settings/ServerPage.cpp | 14 +++++------ 6 files changed, 44 insertions(+), 39 deletions(-) diff --git a/libretroshare/src/dht/p3bitdht.h b/libretroshare/src/dht/p3bitdht.h index 277054494..844a7d051 100644 --- a/libretroshare/src/dht/p3bitdht.h +++ b/libretroshare/src/dht/p3bitdht.h @@ -297,8 +297,8 @@ public: virtual RsDhtRelayMode getRelayMode(); virtual int setRelayMode(RsDhtRelayMode mode); - virtual int getRelayAllowance(int classIdx, uint32_t &count, uint32_t &bandwidth); - virtual int setRelayAllowance(int classIdx, uint32_t count, uint32_t bandwidth); + virtual int getRelayAllowance(RsDhtRelayClass classIdx, uint32_t &count, uint32_t &bandwidth); + virtual int setRelayAllowance(RsDhtRelayClass classIdx, uint32_t count, uint32_t bandwidth); private: diff --git a/libretroshare/src/dht/p3bitdht_relay.cc b/libretroshare/src/dht/p3bitdht_relay.cc index 2011530b1..e5afd4b31 100644 --- a/libretroshare/src/dht/p3bitdht_relay.cc +++ b/libretroshare/src/dht/p3bitdht_relay.cc @@ -163,13 +163,13 @@ int p3BitDht::setRelayMode(RsDhtRelayMode mode) return 1; } -int p3BitDht::getRelayAllowance(int classIdx, uint32_t &count, uint32_t &bandwidth) +int p3BitDht::getRelayAllowance(RsDhtRelayClass classIdx, uint32_t &count, uint32_t &bandwidth) { - std::cerr << "p3BitDht::getRelayAllowance(" << classIdx << "): "; - if ((classIdx >= 0) && (classIdx < RSDHT_RELAY_NUM_CLASS)) + std::cerr << "p3BitDht::getRelayAllowance(" << static_cast::type>(classIdx) << "): "; + if ((classIdx >= static_cast(0)) && (classIdx < RsDhtRelayClass::NUM_CLASS)) { - count = mRelay->getRelayClassMax(classIdx); - bandwidth = mRelay->getRelayClassBandwidth(classIdx); + count = mRelay->getRelayClassMax(static_cast::type>(classIdx)); + bandwidth = mRelay->getRelayClassBandwidth(static_cast::type>(classIdx)); std::cerr << " count: " << count << " bandwidth: " << bandwidth; std::cerr << std::endl; @@ -181,13 +181,13 @@ int p3BitDht::getRelayAllowance(int classIdx, uint32_t &count, uint32_t &bandwid return 0; } -int p3BitDht::setRelayAllowance(int classIdx, uint32_t count, uint32_t bandwidth) +int p3BitDht::setRelayAllowance(RsDhtRelayClass classIdx, uint32_t count, uint32_t bandwidth) { - std::cerr << "p3BitDht::getRelayAllowance(" << classIdx << ", "; + std::cerr << "p3BitDht::getRelayAllowance(" << static_cast::type>(classIdx) << ", "; std::cerr << ", " << count << ", " << bandwidth << ")"; std::cerr << std::endl; - int retval = mRelay->setRelayClassMax(classIdx, count, bandwidth); + int retval = mRelay->setRelayClassMax(static_cast::type>(classIdx), count, bandwidth); IndicateConfigChanged(); return retval; @@ -224,7 +224,7 @@ bool p3BitDht::saveList(bool &cleanup, std::list &saveList) /* Push Relay Class Stuff */ int i; - for(i = 0; i < RSDHT_RELAY_NUM_CLASS; ++i) + for(i = 0; i < static_cast::type>(RsDhtRelayClass::NUM_CLASS); ++i) { rs_sprintf(kv.key, "RELAY_CLASS%d_COUNT", i); rs_sprintf(kv.value, "%d", mRelay->getRelayClassMax(i)); @@ -302,8 +302,8 @@ bool p3BitDht::loadList(std::list& load) //config->print(std::cerr, 0); std::list servers; - int peers[RSDHT_RELAY_NUM_CLASS] = {0}; - int bandwidth[RSDHT_RELAY_NUM_CLASS] = {0}; + int peers[static_cast::type>(RsDhtRelayClass::NUM_CLASS)] = {0}; + int bandwidth[static_cast::type>(RsDhtRelayClass::NUM_CLASS)] = {0}; bool haveMode = false; RsDhtRelayMode mode = static_cast(0); @@ -386,7 +386,7 @@ bool p3BitDht::loadList(std::list& load) } int i; - for(i = 0; i < RSDHT_RELAY_NUM_CLASS; ++i) + for(i = 0; i < static_cast::type>(RsDhtRelayClass::NUM_CLASS); ++i) { mRelay->setRelayClassMax(i, peers[i], bandwidth[i]); } diff --git a/libretroshare/src/retroshare/rsdht.h b/libretroshare/src/retroshare/rsdht.h index 4aa3cc5c8..b52e2ba73 100644 --- a/libretroshare/src/retroshare/rsdht.h +++ b/libretroshare/src/retroshare/rsdht.h @@ -75,12 +75,15 @@ enum class RsDhtTouMode : uint8_t RELAY = 3 }; -#define RSDHT_RELAY_NUM_CLASS 4 +enum class RsDhtRelayClass : uint8_t +{ + ALL = 0, + GENERAL = 1, + FOF = 2, + FRIENDS = 3, -#define RSDHT_RELAY_CLASS_ALL 0 -#define RSDHT_RELAY_CLASS_GENERAL 1 -#define RSDHT_RELAY_CLASS_FOF 2 -#define RSDHT_RELAY_CLASS_FRIENDS 3 + NUM_CLASS = 4 +}; enum class RsDhtRelayMode : uint16_t { @@ -199,8 +202,8 @@ virtual int removeRelayServer(std::string ids) = 0; virtual RsDhtRelayMode getRelayMode() = 0; virtual int setRelayMode(RsDhtRelayMode mode) = 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 getRelayAllowance(RsDhtRelayClass classIdx, uint32_t &count, uint32_t &bandwidth) = 0; +virtual int setRelayAllowance(RsDhtRelayClass classIdx, uint32_t count, uint32_t bandwidth) = 0; // So we can provide to clients. virtual bool getOwnDhtId(std::string &ownDhtId) = 0; diff --git a/libretroshare/src/tcponudp/udprelay.cc b/libretroshare/src/tcponudp/udprelay.cc index fa988ec09..68062b860 100644 --- a/libretroshare/src/tcponudp/udprelay.cc +++ b/libretroshare/src/tcponudp/udprelay.cc @@ -298,13 +298,13 @@ int UdpRelayReceiver::checkRelays() switch(rit->second.mRelayClass) { default: - case UDP_RELAY_CLASS_GENERAL: + case UDP_RELAY_CLASS_GENERAL: lifetime = UDP_RELAY_LIFETIME_GENERAL; break; - case UDP_RELAY_CLASS_FOF: + case UDP_RELAY_CLASS_FOF: lifetime = UDP_RELAY_LIFETIME_FOF; break; - case UDP_RELAY_CLASS_FRIENDS: + case UDP_RELAY_CLASS_FRIENDS: lifetime = UDP_RELAY_LIFETIME_FRIENDS; break; } @@ -1048,13 +1048,13 @@ UdpRelayProxy::UdpRelayProxy(UdpRelayAddrSet *addrSet, int relayClass, uint32_t switch(relayClass) { default: - case UDP_RELAY_CLASS_GENERAL: + case UDP_RELAY_CLASS_GENERAL: mBandwidthLimit = RELAY_MAX_BANDWIDTH; break; - case UDP_RELAY_CLASS_FOF: + case UDP_RELAY_CLASS_FOF: mBandwidthLimit = RELAY_MAX_BANDWIDTH; break; - case UDP_RELAY_CLASS_FRIENDS: + case UDP_RELAY_CLASS_FRIENDS: mBandwidthLimit = RELAY_MAX_BANDWIDTH; break; } diff --git a/libretroshare/src/tcponudp/udprelay.h b/libretroshare/src/tcponudp/udprelay.h index ecc65834b..ba412ac5a 100644 --- a/libretroshare/src/tcponudp/udprelay.h +++ b/libretroshare/src/tcponudp/udprelay.h @@ -101,12 +101,14 @@ std::ostream &operator<<(std::ostream &out, const UdpRelayEnd &ure); /**** DEFINED IN EXTERNAL HEADER FILE ***/ -#define UDP_RELAY_NUM_CLASS RSDHT_RELAY_NUM_CLASS +// sehraf: this is a bit ugly but since the int is used as an integer i'lll stick to this hack for now +/// TODO fix me! +#define UDP_RELAY_NUM_CLASS static_cast::type>(RsDhtRelayClass::NUM_CLASS) -#define UDP_RELAY_CLASS_ALL RSDHT_RELAY_CLASS_ALL -#define UDP_RELAY_CLASS_GENERAL RSDHT_RELAY_CLASS_GENERAL -#define UDP_RELAY_CLASS_FOF RSDHT_RELAY_CLASS_FOF -#define UDP_RELAY_CLASS_FRIENDS RSDHT_RELAY_CLASS_FRIENDS +#define UDP_RELAY_CLASS_ALL static_cast::type>(RsDhtRelayClass::ALL) +#define UDP_RELAY_CLASS_GENERAL static_cast::type>(RsDhtRelayClass::GENERAL) +#define UDP_RELAY_CLASS_FOF static_cast::type>(RsDhtRelayClass::FOF) +#define UDP_RELAY_CLASS_FRIENDS static_cast::type>(RsDhtRelayClass::FRIENDS) // Just for some testing fun! //#define UDP_RELAY_LIFETIME_GENERAL 180 // 3 minutes diff --git a/retroshare-gui/src/gui/settings/ServerPage.cpp b/retroshare-gui/src/gui/settings/ServerPage.cpp index b041e1f31..6cc23cb38 100755 --- a/retroshare-gui/src/gui/settings/ServerPage.cpp +++ b/retroshare-gui/src/gui/settings/ServerPage.cpp @@ -446,15 +446,15 @@ void ServerPage::load() //Relay Tab uint32_t count; uint32_t bandwidth; - rsDht->getRelayAllowance(RSDHT_RELAY_CLASS_FRIENDS, count, bandwidth); + rsDht->getRelayAllowance(RsDhtRelayClass::FRIENDS, count, bandwidth); whileBlocking(ui.noFriendSpinBox)->setValue(count); whileBlocking(ui.bandFriendSpinBox)->setValue(bandwidth / 1024); - rsDht->getRelayAllowance(RSDHT_RELAY_CLASS_FOF, count, bandwidth); + rsDht->getRelayAllowance(RsDhtRelayClass::FOF, count, bandwidth); whileBlocking(ui.noFOFSpinBox)->setValue(count); whileBlocking(ui.bandFOFSpinBox)->setValue(bandwidth / 1024); - rsDht->getRelayAllowance(RSDHT_RELAY_CLASS_GENERAL, count, bandwidth); + rsDht->getRelayAllowance(RsDhtRelayClass::GENERAL, count, bandwidth); whileBlocking(ui.noGeneralSpinBox)->setValue(count); whileBlocking(ui.bandGeneralSpinBox)->setValue(bandwidth / 1024); @@ -1884,10 +1884,10 @@ void ServerPage::updateTotals() int total = nFriends + nFOF + nGeneral; - rsDht->setRelayAllowance(RSDHT_RELAY_CLASS_ALL, total, 0); - rsDht->setRelayAllowance(RSDHT_RELAY_CLASS_FRIENDS, nFriends, 1024 * friendBandwidth); - rsDht->setRelayAllowance(RSDHT_RELAY_CLASS_FOF, nFOF, 1024 * fofBandwidth); - rsDht->setRelayAllowance(RSDHT_RELAY_CLASS_GENERAL, nGeneral, 1024 * genBandwidth); + rsDht->setRelayAllowance(RsDhtRelayClass::ALL, total, 0); + rsDht->setRelayAllowance(RsDhtRelayClass::FRIENDS, nFriends, 1024 * friendBandwidth); + rsDht->setRelayAllowance(RsDhtRelayClass::FOF, nFOF, 1024 * fofBandwidth); + rsDht->setRelayAllowance(RsDhtRelayClass::GENERAL, nGeneral, 1024 * genBandwidth); } /** Saves the changes on this page */ From 7097a22781ee1141da0acdb711ed656c4d0a806c Mon Sep 17 00:00:00 2001 From: sehraf Date: Wed, 19 Feb 2020 20:34:52 +0100 Subject: [PATCH 17/24] [ATTEMPT] fix for inconsitency in p3linkmgr.cc --- libretroshare/src/pqi/p3linkmgr.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libretroshare/src/pqi/p3linkmgr.cc b/libretroshare/src/pqi/p3linkmgr.cc index a63054093..4ea635c78 100644 --- a/libretroshare/src/pqi/p3linkmgr.cc +++ b/libretroshare/src/pqi/p3linkmgr.cc @@ -1063,8 +1063,12 @@ void p3LinkMgrIMPL::peerStatus(const RsPeerId& id, const pqiIpAddrSet &addrs, uint32_t peer_vs_dht = 0; uint32_t peerNetMode = 0; - uint32_t ownNetMode = mNetMgr->getNetworkMode(); - + int ownNetMode; + { + peerState ps; + mPeerMgr->getOwnNetStatus(ps); + ownNetMode = ps.netMode; + } { RsStackMutex stack(mLinkMtx); /****** STACK LOCK MUTEX *******/ From 76511479af8dbc56947a4c44370aa5e5edd6cd6a Mon Sep 17 00:00:00 2001 From: csoler Date: Wed, 19 Aug 2020 16:19:42 +0200 Subject: [PATCH 18/24] switched all explicit pixmap from files to shared FilesDefs::getPixmapFromQtResourcePath() --- .../src/gui/Circles/CreateCircleDialog.cpp | 3 +- .../FileTransfer/FileTransferInfoWidget.cpp | 15 ++--- .../gui/FileTransfer/SharedFilesDialog.cpp | 4 +- retroshare-gui/src/gui/GenCertDialog.cpp | 7 ++- .../src/gui/Identity/IdDetailsDialog.cpp | 3 +- retroshare-gui/src/gui/Identity/IdDialog.cpp | 6 +- .../src/gui/Identity/IdEditDialog.cpp | 5 +- retroshare-gui/src/gui/LogoBar.cpp | 17 +++--- .../src/gui/PhotoShare/AlbumDialog.cpp | 4 +- .../src/gui/PhotoShare/AlbumGroupDialog.cpp | 4 +- .../src/gui/PhotoShare/AlbumItem.cpp | 2 +- .../src/gui/PhotoShare/PhotoItem.cpp | 2 +- .../src/gui/Posted/PostedCreatePostDialog.cpp | 3 +- .../src/gui/Posted/PostedGroupDialog.cpp | 5 +- retroshare-gui/src/gui/Posted/PostedItem.cpp | 2 +- .../src/gui/Posted/PostedListWidget.cpp | 3 +- retroshare-gui/src/gui/QuickStartWizard.cpp | 3 +- .../src/gui/ServicePermissionDialog.cpp | 3 +- retroshare-gui/src/gui/ShareManager.cpp | 3 +- .../src/gui/TheWire/PulseAddDialog.cpp | 2 +- .../src/gui/TheWire/PulseTopLevel.cpp | 4 +- .../src/gui/TheWire/PulseViewGroup.cpp | 2 +- .../src/gui/TheWire/PulseViewItem.cpp | 4 +- .../src/gui/TheWire/WireGroupDialog.cpp | 4 +- .../src/gui/TheWire/WireGroupItem.cpp | 2 +- .../src/gui/WikiPoos/WikiEditDialog.cpp | 4 +- .../src/gui/chat/ChatLobbyDialog.cpp | 8 +-- retroshare-gui/src/gui/chat/ChatWidget.cpp | 2 +- .../src/gui/chat/CreateLobbyDialog.cpp | 3 +- retroshare-gui/src/gui/common/AvatarDefs.cpp | 9 +-- .../src/gui/common/AvatarDialog.cpp | 3 +- retroshare-gui/src/gui/common/Emoticons.cpp | 4 +- retroshare-gui/src/gui/common/FilesDefs.cpp | 2 +- retroshare-gui/src/gui/common/FriendList.cpp | 24 ++++---- .../src/gui/common/NewFriendList.cpp | 4 +- .../src/gui/common/RSTextBrowser.cpp | 3 +- .../src/gui/common/RSTreeWidget.cpp | 3 +- .../src/gui/common/RsCollectionDialog.cpp | 2 +- .../src/gui/connect/ConfCertDialog.cpp | 3 +- .../src/gui/connect/ConnectFriendWizard.cpp | 14 ++--- .../src/gui/connect/ConnectProgressDialog.cpp | 3 +- .../src/gui/connect/PGPKeyDialog.cpp | 2 +- .../src/gui/feeds/GxsChannelGroupItem.cpp | 2 +- .../src/gui/feeds/GxsForumGroupItem.cpp | 4 +- .../src/gui/feeds/GxsForumMsgItem.cpp | 4 +- .../src/gui/feeds/PostedGroupItem.cpp | 6 +- retroshare-gui/src/gui/groups/CreateGroup.cpp | 5 +- .../src/gui/gxs/GxsGroupFrameDialog.cpp | 2 +- .../src/gui/gxs/GxsGroupShareKey.cpp | 9 +-- .../src/gui/gxs/GxsIdTreeWidgetItem.cpp | 2 +- .../src/gui/gxs/WikiGroupDialog.cpp | 2 +- .../gui/gxschannels/CreateGxsChannelMsg.cpp | 2 +- .../gui/gxschannels/GxsChannelGroupDialog.cpp | 5 +- .../gui/gxschannels/GxsChannelPostsWidget.cpp | 8 +-- .../GxsChannelPostsWidgetWithModel.cpp | 8 +-- .../src/gui/gxsforums/CreateGxsForumMsg.cpp | 3 +- .../src/gui/gxsforums/GxsForumGroupDialog.cpp | 3 +- .../src/gui/im_history/ImHistoryBrowser.cpp | 3 +- .../src/gui/profile/ProfileManager.cpp | 2 +- retroshare-gui/src/gui/settings/AboutPage.h | 5 +- .../src/gui/settings/AppearancePage.h | 5 +- retroshare-gui/src/gui/settings/ChannelPage.h | 5 +- retroshare-gui/src/gui/settings/ChatPage.h | 5 +- retroshare-gui/src/gui/settings/CryptoPage.h | 5 +- .../src/gui/settings/FileAssociationsPage.h | 5 +- retroshare-gui/src/gui/settings/ForumPage.h | 5 +- retroshare-gui/src/gui/settings/GeneralPage.h | 5 +- retroshare-gui/src/gui/settings/JsonApiPage.h | 2 +- retroshare-gui/src/gui/settings/MessagePage.h | 5 +- retroshare-gui/src/gui/settings/NotifyPage.h | 3 +- retroshare-gui/src/gui/settings/PeoplePage.h | 5 +- retroshare-gui/src/gui/settings/PluginsPage.h | 5 +- retroshare-gui/src/gui/settings/PostedPage.h | 5 +- .../src/gui/settings/ServerPage.cpp | 60 +++++++++---------- retroshare-gui/src/gui/settings/ServerPage.h | 7 ++- .../src/gui/settings/ServicePermissionsPage.h | 3 +- retroshare-gui/src/gui/settings/SoundPage.h | 5 +- .../src/gui/settings/TransferPage.h | 5 +- retroshare-gui/src/gui/settings/WebuiPage.h | 2 +- .../src/gui/statusbar/ToasterDisable.cpp | 3 +- .../src/gui/statusbar/dhtstatus.cpp | 13 ++-- .../src/gui/statusbar/discstatus.cpp | 5 +- .../src/gui/statusbar/hashingstatus.cpp | 3 +- .../src/gui/statusbar/natstatus.cpp | 21 +++---- .../src/gui/statusbar/peerstatus.cpp | 7 ++- .../src/gui/statusbar/ratesstatus.cpp | 5 +- .../src/gui/statusbar/torstatus.cpp | 11 ++-- retroshare-gui/src/gui/style/StyleDialog.cpp | 3 +- retroshare-gui/src/main.cpp | 2 +- retroshare-gui/src/util/misc.cpp | 5 +- 90 files changed, 275 insertions(+), 225 deletions(-) diff --git a/retroshare-gui/src/gui/Circles/CreateCircleDialog.cpp b/retroshare-gui/src/gui/Circles/CreateCircleDialog.cpp index 3733c0f1a..40340605b 100644 --- a/retroshare-gui/src/gui/Circles/CreateCircleDialog.cpp +++ b/retroshare-gui/src/gui/Circles/CreateCircleDialog.cpp @@ -30,6 +30,7 @@ #include #include "gui/common/AvatarDefs.h" +#include "gui/common/FilesDefs.h" #include "util/qtthreadsutils.h" #include "gui/Circles/CreateCircleDialog.h" #include "gui/gxs/GxsIdDetails.h" @@ -53,7 +54,7 @@ CreateCircleDialog::CreateCircleDialog() ui.setupUi(this); /* Setup Queue */ - ui.headerFrame->setHeaderImage(QPixmap(":/icons/png/circles.png")); + ui.headerFrame->setHeaderImage(FilesDefs::getPixmapFromQtResourcePath(":/icons/png/circles.png")); // connect up the buttons. connect(ui.addButton, SIGNAL(clicked()), this, SLOT(addMember())); diff --git a/retroshare-gui/src/gui/FileTransfer/FileTransferInfoWidget.cpp b/retroshare-gui/src/gui/FileTransfer/FileTransferInfoWidget.cpp index e7aef654b..6adb61a68 100644 --- a/retroshare-gui/src/gui/FileTransfer/FileTransferInfoWidget.cpp +++ b/retroshare-gui/src/gui/FileTransfer/FileTransferInfoWidget.cpp @@ -23,11 +23,12 @@ #include #include #include -#include -#include +#include "retroshare/rsfiles.h" +#include "retroshare/rstypes.h" #include "util/misc.h" #include "FileTransferInfoWidget.h" -#include +#include "gui/RetroShareLink.h" +#include "gui/common/FilesDefs.h" // Variables to decide of display behaviour. All variables are expressed as a factor of font height // @@ -49,10 +50,10 @@ FileTransferInfoWidget::FileTransferInfoWidget(QWidget * /*parent*/, Qt::WindowF int S = 0.9*QFontMetricsF(font()).height(); - downloadedPixmap = QPixmap(":/icons/tile_downloaded_48.png").scaledToHeight(S,Qt::SmoothTransformation); - downloadingPixmap = QPixmap(":/icons/tile_downloading_48.png").scaledToHeight(S,Qt::SmoothTransformation); - notDownloadPixmap = QPixmap(":/icons/tile_inactive_48.png").scaledToHeight(S,Qt::SmoothTransformation); - checkingPixmap = QPixmap(":/icons/tile_checking_48.png").scaledToHeight(S,Qt::SmoothTransformation); + downloadedPixmap = FilesDefs::getPixmapFromQtResourcePath(":/icons/tile_downloaded_48.png").scaledToHeight(S,Qt::SmoothTransformation); + downloadingPixmap = FilesDefs::getPixmapFromQtResourcePath(":/icons/tile_downloading_48.png").scaledToHeight(S,Qt::SmoothTransformation); + notDownloadPixmap = FilesDefs::getPixmapFromQtResourcePath(":/icons/tile_inactive_48.png").scaledToHeight(S,Qt::SmoothTransformation); + checkingPixmap = FilesDefs::getPixmapFromQtResourcePath(":/icons/tile_checking_48.png").scaledToHeight(S,Qt::SmoothTransformation); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); } diff --git a/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp b/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp index 90860ff2c..617e7fabc 100644 --- a/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp +++ b/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp @@ -266,7 +266,7 @@ LocalSharedFilesDialog::LocalSharedFilesDialog(QWidget *parent) openfolderAct = new QAction(QIcon(IMAGE_OPENFOLDER), tr("Open Folder"), this) ; connect(openfolderAct, SIGNAL(triggered()), this, SLOT(openfolder())) ; - ui.titleBarPixmap->setPixmap(QPixmap(IMAGE_MYFILES)) ; + ui.titleBarPixmap->setPixmap(FilesDefs::getPixmapFromQtResourcePath(IMAGE_MYFILES)) ; ui.dirTreeView->setItemDelegateForColumn(COLUMN_FRIEND_ACCESS,new ShareFlagsItemDelegate()) ; } @@ -498,7 +498,7 @@ void LocalSharedFilesDialog::checkUpdate() else { ui.checkButton->setText(tr("Check files")); - ui.hashLabel->setPixmap(QPixmap(IMAGE_HASH_DONE)); + ui.hashLabel->setPixmap(FilesDefs::getPixmapFromQtResourcePath(IMAGE_HASH_DONE)); ui.hashLabel->setToolTip("") ; } diff --git a/retroshare-gui/src/gui/GenCertDialog.cpp b/retroshare-gui/src/gui/GenCertDialog.cpp index aae80b753..71691f07e 100644 --- a/retroshare-gui/src/gui/GenCertDialog.cpp +++ b/retroshare-gui/src/gui/GenCertDialog.cpp @@ -35,6 +35,7 @@ #include "gui/settings/rsharesettings.h" #include "TorControl/TorManager.h" #include "util/misc.h" +#include "gui/common/FilesDefs.h" #include #include @@ -132,7 +133,7 @@ GenCertDialog::GenCertDialog(bool onlyGenerateIdentity, QWidget *parent) /* Invoke Qt Designer generated QObject setup routine */ ui.setupUi(this); - //ui.headerFrame->setHeaderImage(QPixmap(":/icons/svg/profile.svg")); + //ui.headerFrame->setHeaderImage(FilesDefs::getPixmapFromQtResourcePath(":/icons/svg/profile.svg")); //ui.headerFrame->setHeaderText(tr("Create a new profile")); connect(ui.reuse_existing_node_CB, SIGNAL(triggered()), this, SLOT(switchReuseExistingNode())); @@ -432,9 +433,9 @@ void GenCertDialog::updateCheckLabels() } if(mEntropyOk) - ui.randomness_check_LB->setPixmap(QPixmap(IMAGE_GOOD)) ; + ui.randomness_check_LB->setPixmap(FilesDefs::getPixmapFromQtResourcePath(IMAGE_GOOD)) ; else - ui.randomness_check_LB->setPixmap(QPixmap(IMAGE_BAD)) ; + ui.randomness_check_LB->setPixmap(FilesDefs::getPixmapFromQtResourcePath(IMAGE_BAD)) ; setupState(); } diff --git a/retroshare-gui/src/gui/Identity/IdDetailsDialog.cpp b/retroshare-gui/src/gui/Identity/IdDetailsDialog.cpp index ea1f0ceeb..9056b5f31 100644 --- a/retroshare-gui/src/gui/Identity/IdDetailsDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDetailsDialog.cpp @@ -25,6 +25,7 @@ #include "util/qtthreadsutils.h" #include "gui/settings/rsharesettings.h" #include "gui/common/UIStateHelper.h" +#include "gui/common/FilesDefs.h" #include "gui/msgs/MessageComposer.h" #include "gui/RetroShareLink.h" @@ -82,7 +83,7 @@ IdDetailsDialog::IdDetailsDialog(const RsGxsGroupId& id, QWidget *parent) : Settings->loadWidgetInformation(this); - ui->headerFrame->setHeaderImage(QPixmap(":/icons/png/person.png")); + ui->headerFrame->setHeaderImage(FilesDefs::getPixmapFromQtResourcePath(":/icons/png/person.png")); ui->headerFrame->setHeaderText(tr("Person Details")); //connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(changeGroup())); diff --git a/retroshare-gui/src/gui/Identity/IdDialog.cpp b/retroshare-gui/src/gui/Identity/IdDialog.cpp index f66f9d6af..604f4defa 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDialog.cpp @@ -255,7 +255,7 @@ IdDialog::IdDialog(QWidget *parent) : MainPage(parent), ui(new Ui::IdDialog) this, &IdDialog::chatIdentityItem ); - ui->avlabel_Circles->setPixmap(QPixmap(":/icons/png/circles.png")); + ui->avlabel_Circles->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/icons/png/circles.png")); ui->headerTextLabel_Circles->setText(tr("Circles")); @@ -459,7 +459,7 @@ void IdDialog::clearPerson() { QFontMetricsF f(ui->avLabel_Person->font()) ; - ui->avLabel_Person->setPixmap(QPixmap(":/icons/png/people.png").scaled(f.height()*4,f.height()*4,Qt::IgnoreAspectRatio,Qt::SmoothTransformation)); + ui->avLabel_Person->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/icons/png/people.png").scaled(f.height()*4,f.height()*4,Qt::IgnoreAspectRatio,Qt::SmoothTransformation)); ui->headerTextLabel_Person->setText(tr("People")); ui->inviteFrame->hide(); @@ -2174,7 +2174,7 @@ void IdDialog::IdListCustomPopupMenu( QPoint ) hbox->setSpacing(6); QLabel *iconLabel = new QLabel(widget); - QPixmap pix = QPixmap(":/images/user/friends24.png").scaledToHeight(QFontMetricsF(iconLabel->font()).height()*1.5); + QPixmap pix = FilesDefs::getPixmapFromQtResourcePath(":/images/user/friends24.png").scaledToHeight(QFontMetricsF(iconLabel->font()).height()*1.5); iconLabel->setPixmap(pix); iconLabel->setMaximumSize(iconLabel->frameSize().height() + pix.height(), pix.width()); hbox->addWidget(iconLabel); diff --git a/retroshare-gui/src/gui/Identity/IdEditDialog.cpp b/retroshare-gui/src/gui/Identity/IdEditDialog.cpp index 0f432ba2d..b4c855c1d 100644 --- a/retroshare-gui/src/gui/Identity/IdEditDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdEditDialog.cpp @@ -32,6 +32,7 @@ #include #include +#include "gui/common/FilesDefs.h" #include @@ -47,7 +48,7 @@ IdEditDialog::IdEditDialog(QWidget *parent) : ui->setupUi(this); - ui->headerFrame->setHeaderImage(QPixmap(":/icons/png/person.png")); + ui->headerFrame->setHeaderImage(FilesDefs::getPixmapFromQtResourcePath(":/icons/png/person.png")); ui->headerFrame->setHeaderText(tr("Create New Identity")); /* Setup UI helper */ @@ -199,7 +200,7 @@ void IdEditDialog::setAvatar(const QPixmap &avatar) void IdEditDialog::setupExistingId(const RsGxsGroupId& keyId) { setWindowTitle(tr("Edit identity")); - ui->headerFrame->setHeaderImage(QPixmap(":/icons/png/person.png")); + ui->headerFrame->setHeaderImage(FilesDefs::getPixmapFromQtResourcePath(":/icons/png/person.png")); ui->headerFrame->setHeaderText(tr("Edit identity")); mStateHelper->setLoading(IDEDITDIALOG_LOADID, true); diff --git a/retroshare-gui/src/gui/LogoBar.cpp b/retroshare-gui/src/gui/LogoBar.cpp index 176152f1b..081eb2c31 100644 --- a/retroshare-gui/src/gui/LogoBar.cpp +++ b/retroshare-gui/src/gui/LogoBar.cpp @@ -20,8 +20,9 @@ #include "LogoBar.h" -#include -#include +#include "util/RetroStyleLabel.h" +#include "util/MouseEventFilter.h" +#include "gui/common/FilesDefs.h" #include @@ -42,11 +43,11 @@ void LogoBar::init() { //LogoButton _logoButton = new RetroStyleLabel(this); _logoButton->setPixmaps( - QPixmap(":/images/logobar/rslogo2.png"), //Start + FilesDefs::getPixmapFromQtResourcePath(":/images/logobar/rslogo2.png"), //Start QPixmap(), //End QPixmap(), //Fill - QPixmap(":/images/logobar/rslogo2.png"), //Start + FilesDefs::getPixmapFromQtResourcePath(":/images/logobar/rslogo2.png"), //Start QPixmap(), //End QPixmap() //Fill ); @@ -59,11 +60,11 @@ void LogoBar::init() { FillLabel1->setPixmaps( QPixmap(), //Start QPixmap(), //End - QPixmap(":/images/logobar/logo_bar_fill.png"), //Fill + FilesDefs::getPixmapFromQtResourcePath(":/images/logobar/logo_bar_fill.png"), //Fill QPixmap(), //Start QPixmap(), //End - QPixmap(":/images/logobar/logo_bar_fill.png") //Fill + FilesDefs::getPixmapFromQtResourcePath(":/images/logobar/logo_bar_fill.png") //Fill ); //FillLabel2 @@ -71,11 +72,11 @@ void LogoBar::init() { FillLabel2->setPixmaps( QPixmap(), //Start QPixmap(), //End - QPixmap(":/images/logobar/logo_bar_fill.png"), //Fill + FilesDefs::getPixmapFromQtResourcePath(":/images/logobar/logo_bar_fill.png"), //Fill QPixmap(), //Start QPixmap(), //End - QPixmap(":/images/logobar/logo_bar_fill.png") //Fill + FilesDefs::getPixmapFromQtResourcePath(":/images/logobar/logo_bar_fill.png") //Fill ); QGridLayout * layout = new QGridLayout(this); diff --git a/retroshare-gui/src/gui/PhotoShare/AlbumDialog.cpp b/retroshare-gui/src/gui/PhotoShare/AlbumDialog.cpp index e163e7104..f8d00f425 100644 --- a/retroshare-gui/src/gui/PhotoShare/AlbumDialog.cpp +++ b/retroshare-gui/src/gui/PhotoShare/AlbumDialog.cpp @@ -31,7 +31,7 @@ AlbumDialog::AlbumDialog(const RsPhotoAlbum& album, TokenQueue* photoQueue, RsPh { ui->setupUi(this); - ui->headerFrame->setHeaderImage(QPixmap(":/images/kview_64.png")); + ui->headerFrame->setHeaderImage(FilesDefs::getPixmapFromQtResourcePath(":/images/kview_64.png")); ui->headerFrame->setHeaderText(tr("Album")); connect(ui->pushButton_PublishPhotos, SIGNAL(clicked()), this, SLOT(updateAlbumPhotos())); @@ -69,7 +69,7 @@ void AlbumDialog::setUp() else { // display a default Album icon when album has no Thumbnail - ui->label_thumbNail->setPixmap(QPixmap(":/images/album_default_128.png")); + ui->label_thumbNail->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/images/album_default_128.png")); } } diff --git a/retroshare-gui/src/gui/PhotoShare/AlbumGroupDialog.cpp b/retroshare-gui/src/gui/PhotoShare/AlbumGroupDialog.cpp index 4bd03b2ad..f58d658c6 100644 --- a/retroshare-gui/src/gui/PhotoShare/AlbumGroupDialog.cpp +++ b/retroshare-gui/src/gui/PhotoShare/AlbumGroupDialog.cpp @@ -99,7 +99,7 @@ void AlbumGroupDialog::initUi() QPixmap AlbumGroupDialog::serviceImage() { - return QPixmap(":/images/album_create_64.png"); + return FilesDefs::getPixmapFromQtResourcePath(":/images/album_create_64.png"); } void AlbumGroupDialog::prepareAlbumGroup(RsPhotoAlbum &group, const RsGroupMetaData &meta) @@ -175,7 +175,7 @@ bool AlbumGroupDialog::service_loadGroup(const RsGxsGenericGroupData *data, Mode setLogo(pixmap); } } else { - setLogo(QPixmap(":/images/album_create_64.png")); + setLogo(FilesDefs::getPixmapFromQtResourcePath(":/images/album_create_64.png")); } // Load additional data.... diff --git a/retroshare-gui/src/gui/PhotoShare/AlbumItem.cpp b/retroshare-gui/src/gui/PhotoShare/AlbumItem.cpp index 1eb79dd98..e5dfac387 100644 --- a/retroshare-gui/src/gui/PhotoShare/AlbumItem.cpp +++ b/retroshare-gui/src/gui/PhotoShare/AlbumItem.cpp @@ -51,7 +51,7 @@ void AlbumItem::setUp() else { // display a default Album icon when album has no Thumbnail - ui->label_Thumbnail->setPixmap(QPixmap(":/images/album_default_128.png")); + ui->label_Thumbnail->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/images/album_default_128.png")); } } diff --git a/retroshare-gui/src/gui/PhotoShare/PhotoItem.cpp b/retroshare-gui/src/gui/PhotoShare/PhotoItem.cpp index e30c321dd..75f553290 100644 --- a/retroshare-gui/src/gui/PhotoShare/PhotoItem.cpp +++ b/retroshare-gui/src/gui/PhotoShare/PhotoItem.cpp @@ -59,7 +59,7 @@ PhotoItem::PhotoItem(PhotoShareItemHolder *holder, const QString& path, uint32_t mPhotoDetails.mOrder = order; - QPixmap qtn = QPixmap(path); + QPixmap qtn = FilesDefs::getPixmapFromQtResourcePath(path); mLowResImage = qtn.scaled(512,512, Qt::KeepAspectRatio, Qt::SmoothTransformation); ui->label_Thumbnail->setPixmap(qtn.scaled(128, 128, Qt::KeepAspectRatio, Qt::SmoothTransformation)); diff --git a/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.cpp b/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.cpp index fada00020..a9edea275 100644 --- a/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.cpp +++ b/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.cpp @@ -38,6 +38,7 @@ #include #include #include +#include "gui/common/FilesDefs.h" /* View Page */ #define VIEW_POST 1 @@ -56,7 +57,7 @@ PostedCreatePostDialog::PostedCreatePostDialog(RsPosted *posted, const RsGxsGrou connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(close())); connect(ui->addPicButton, SIGNAL(clicked() ), this , SLOT(addPicture())); - ui->headerFrame->setHeaderImage(QPixmap(":/icons/png/postedlinks.png")); + ui->headerFrame->setHeaderImage(FilesDefs::getPixmapFromQtResourcePath(":/icons/png/postedlinks.png")); ui->headerFrame->setHeaderText(tr("Create a new Post")); setAttribute ( Qt::WA_DeleteOnClose, true ); diff --git a/retroshare-gui/src/gui/Posted/PostedGroupDialog.cpp b/retroshare-gui/src/gui/Posted/PostedGroupDialog.cpp index 957abfc0d..c516f7520 100644 --- a/retroshare-gui/src/gui/Posted/PostedGroupDialog.cpp +++ b/retroshare-gui/src/gui/Posted/PostedGroupDialog.cpp @@ -21,6 +21,7 @@ #include "PostedGroupDialog.h" #include "gui/gxs/GxsIdDetails.h" +#include "gui/common/FilesDefs.h" #include #include @@ -89,7 +90,7 @@ void PostedGroupDialog::initUi() QPixmap PostedGroupDialog::serviceImage() { - return QPixmap(":/icons/png/posted.png"); + return FilesDefs::getPixmapFromQtResourcePath(":/icons/png/posted.png"); } void PostedGroupDialog::preparePostedGroup(RsPostedGroup &group, const RsGroupMetaData &meta) @@ -159,7 +160,7 @@ bool PostedGroupDialog::service_loadGroup(const RsGxsGenericGroupData *data, Mod } else - setLogo(QPixmap(":/icons/png/posted.png")); + setLogo(FilesDefs::getPixmapFromQtResourcePath(":/icons/png/posted.png")); return true; } diff --git a/retroshare-gui/src/gui/Posted/PostedItem.cpp b/retroshare-gui/src/gui/Posted/PostedItem.cpp index b4cfa2d4a..6f9bc1cc3 100644 --- a/retroshare-gui/src/gui/Posted/PostedItem.cpp +++ b/retroshare-gui/src/gui/Posted/PostedItem.cpp @@ -490,7 +490,7 @@ void PostedItem::fill() ui->voteUpButton->setDisabled(true); ui->voteDownButton->setDisabled(true); - ui->thumbnailLabel->setPixmap( QPixmap(":/images/thumb-default.png")); + ui->thumbnailLabel->setPixmap( FilesDefs::getPixmapFromQtResourcePath(":/images/thumb-default.png")); ui->fromLabel->setId(mPost.mMeta.mAuthorId); ui->titleLabel->setText(tr( "

The author of this message (with ID %1) is banned.").arg(QString::fromStdString(mPost.mMeta.mAuthorId.toStdString()))) ; QDateTime qtime; diff --git a/retroshare-gui/src/gui/Posted/PostedListWidget.cpp b/retroshare-gui/src/gui/Posted/PostedListWidget.cpp index 92b322c8b..a88a1d6b5 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidget.cpp +++ b/retroshare-gui/src/gui/Posted/PostedListWidget.cpp @@ -30,6 +30,7 @@ #include "gui/settings/rsharesettings.h" #include "PostedItem.h" #include "PostedCardView.h" +#include "gui/common/FilesDefs.h" #include "gui/common/UIStateHelper.h" #include "gui/RetroShareLink.h" #include "util/HandleRichText.h" @@ -406,7 +407,7 @@ void PostedListWidget::insertPostedDetails(const RsPostedGroup &group) if (group.mGroupImage.mData != NULL) { GxsIdDetails::loadPixmapFromData(group.mGroupImage.mData, group.mGroupImage.mSize, boardImage,GxsIdDetails::ORIGINAL); } else { - boardImage = QPixmap(BOARD_DEFAULT_IMAGE); + boardImage = FilesDefs::getPixmapFromQtResourcePath(BOARD_DEFAULT_IMAGE); } ui->logoLabel->setPixmap(boardImage); ui->namelabel->setText(QString::fromUtf8(group.mMeta.mGroupName.c_str())); diff --git a/retroshare-gui/src/gui/QuickStartWizard.cpp b/retroshare-gui/src/gui/QuickStartWizard.cpp index d7ba25941..f442d2f1b 100644 --- a/retroshare-gui/src/gui/QuickStartWizard.cpp +++ b/retroshare-gui/src/gui/QuickStartWizard.cpp @@ -33,13 +33,14 @@ #include #include "settings/rsharesettings.h" #include "util/QtVersion.h" +#include "gui/common/FilesDefs.h" QuickStartWizard::QuickStartWizard(QWidget *parent) : QDialog(parent) { ui.setupUi(this); - ui.headerFrame->setHeaderImage(QPixmap(":/images/rs_wizard.png")); + ui.headerFrame->setHeaderImage(FilesDefs::getPixmapFromQtResourcePath(":/images/rs_wizard.png")); ui.headerFrame->setHeaderText("RetroShare"); ui.pagesWizard->setCurrentIndex(0); diff --git a/retroshare-gui/src/gui/ServicePermissionDialog.cpp b/retroshare-gui/src/gui/ServicePermissionDialog.cpp index e90f08f63..9eb898058 100644 --- a/retroshare-gui/src/gui/ServicePermissionDialog.cpp +++ b/retroshare-gui/src/gui/ServicePermissionDialog.cpp @@ -23,6 +23,7 @@ #include "ServicePermissionDialog.h" #include "ui_ServicePermissionDialog.h" #include "settings/rsharesettings.h" +#include "gui/common/FilesDefs.h" static ServicePermissionDialog *servicePermissionDialog = NULL; @@ -36,7 +37,7 @@ ServicePermissionDialog::ServicePermissionDialog() : Settings->loadWidgetInformation(this); - ui->headerFrame->setHeaderImage(QPixmap(":/images/user/servicepermissions64.png")); + ui->headerFrame->setHeaderImage(FilesDefs::getPixmapFromQtResourcePath(":/images/user/servicepermissions64.png")); ui->headerFrame->setHeaderText(tr("Service Permissions")); connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(setPermissions())); diff --git a/retroshare-gui/src/gui/ShareManager.cpp b/retroshare-gui/src/gui/ShareManager.cpp index 7ebb67b3b..c3da3d1d1 100644 --- a/retroshare-gui/src/gui/ShareManager.cpp +++ b/retroshare-gui/src/gui/ShareManager.cpp @@ -38,6 +38,7 @@ #include "gui/notifyqt.h" #include "util/QtVersion.h" #include "util/misc.h" +#include "gui/common/FilesDefs.h" /* Images for context menu icons */ #define IMAGE_CANCEL ":/images/delete.png" @@ -57,7 +58,7 @@ ShareManager::ShareManager() /* Invoke Qt Designer generated QObject setup routine */ ui.setupUi(this); - ui.headerFrame->setHeaderImage(QPixmap(":/images/fileshare64.png")); + ui.headerFrame->setHeaderImage(FilesDefs::getPixmapFromQtResourcePath(":/images/fileshare64.png")); ui.headerFrame->setHeaderText(tr("Share Manager")); isLoading = false; diff --git a/retroshare-gui/src/gui/TheWire/PulseAddDialog.cpp b/retroshare-gui/src/gui/TheWire/PulseAddDialog.cpp index dc09a11f1..0bdd3c338 100644 --- a/retroshare-gui/src/gui/TheWire/PulseAddDialog.cpp +++ b/retroshare-gui/src/gui/TheWire/PulseAddDialog.cpp @@ -409,7 +409,7 @@ void PulseAddDialog::addImage(const QString &path) std::cerr << "PulseAddDialog::addImage() loading image from: " << path.toStdString(); std::cerr << std::endl; - QPixmap qtn = QPixmap(path); + QPixmap qtn = FilesDefs::getPixmapFromQtResourcePath(path); if (qtn.isNull()) { std::cerr << "PulseAddDialog::addImage() Invalid Image"; std::cerr << std::endl; diff --git a/retroshare-gui/src/gui/TheWire/PulseTopLevel.cpp b/retroshare-gui/src/gui/TheWire/PulseTopLevel.cpp index 859a4d735..c8e26d987 100644 --- a/retroshare-gui/src/gui/TheWire/PulseTopLevel.cpp +++ b/retroshare-gui/src/gui/TheWire/PulseTopLevel.cpp @@ -126,9 +126,9 @@ void PulseTopLevel::setReferenceString(QString ref) // set ref icon if (mPulse->mPulseType & WIRE_PULSE_TYPE_REPUBLISH) { - label_reficon->setPixmap(QPixmap(":/images/retweet.png")); + label_reficon->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/images/retweet.png")); } else { - label_reficon->setPixmap(QPixmap(":/images/reply.png")); + label_reficon->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/images/reply.png")); } } diff --git a/retroshare-gui/src/gui/TheWire/PulseViewGroup.cpp b/retroshare-gui/src/gui/TheWire/PulseViewGroup.cpp index 25d393295..27b085a01 100644 --- a/retroshare-gui/src/gui/TheWire/PulseViewGroup.cpp +++ b/retroshare-gui/src/gui/TheWire/PulseViewGroup.cpp @@ -67,7 +67,7 @@ void PulseViewGroup::setup() else { // default. - QPixmap pixmap = QPixmap(":/icons/png/posted.png").scaled(50,50); + QPixmap pixmap = FilesDefs::getPixmapFromQtResourcePath(":/icons/png/posted.png").scaled(50,50); label_headshot->setPixmap(pixmap); } diff --git a/retroshare-gui/src/gui/TheWire/PulseViewItem.cpp b/retroshare-gui/src/gui/TheWire/PulseViewItem.cpp index 12568dc49..2025baf85 100644 --- a/retroshare-gui/src/gui/TheWire/PulseViewItem.cpp +++ b/retroshare-gui/src/gui/TheWire/PulseViewItem.cpp @@ -281,7 +281,7 @@ void PulseDataItem::showPulse() if (!headshotOkay) { // default. - QPixmap pixmap = QPixmap(":/icons/png/posted.png").scaled(50,50); + QPixmap pixmap = FilesDefs::getPixmapFromQtResourcePath(":/icons/png/posted.png").scaled(50,50); setHeadshot(pixmap); } @@ -346,7 +346,7 @@ void PulseDataItem::showPulse() if (!headshotOkay) { // default. - QPixmap pixmap = QPixmap(":/icons/png/posted.png").scaled(50,50); + QPixmap pixmap = FilesDefs::getPixmapFromQtResourcePath(":/icons/png/posted.png").scaled(50,50); setHeadshot(pixmap); // QPixmap(":/icons/png/posted.png")); } diff --git a/retroshare-gui/src/gui/TheWire/WireGroupDialog.cpp b/retroshare-gui/src/gui/TheWire/WireGroupDialog.cpp index 210a05b92..f29aee712 100644 --- a/retroshare-gui/src/gui/TheWire/WireGroupDialog.cpp +++ b/retroshare-gui/src/gui/TheWire/WireGroupDialog.cpp @@ -94,7 +94,7 @@ void WireGroupDialog::initUi() QPixmap WireGroupDialog::serviceImage() { - return QPixmap(":/icons/wire-circle.png"); + return FilesDefs::getPixmapFromQtResourcePath(":/icons/wire-circle.png"); } void WireGroupDialog::prepareWireGroup(RsWireGroup &group, const RsGroupMetaData &meta) @@ -178,7 +178,7 @@ bool WireGroupDialog::service_loadGroup(const RsGxsGenericGroupData *data, Mode setLogo(pixmap); } } else { - setLogo(QPixmap(":/images/album_create_64.png")); + setLogo(FilesDefs::getPixmapFromQtResourcePath(":/images/album_create_64.png")); } #endif diff --git a/retroshare-gui/src/gui/TheWire/WireGroupItem.cpp b/retroshare-gui/src/gui/TheWire/WireGroupItem.cpp index 5c7a00fea..81df64dd2 100644 --- a/retroshare-gui/src/gui/TheWire/WireGroupItem.cpp +++ b/retroshare-gui/src/gui/TheWire/WireGroupItem.cpp @@ -66,7 +66,7 @@ void WireGroupItem::setup() else { // default. - QPixmap pixmap = QPixmap(":/icons/wire.png").scaled(32,32); + QPixmap pixmap = FilesDefs::getPixmapFromQtResourcePath(":/icons/wire.png").scaled(32,32); label_headshot->setPixmap(pixmap); } diff --git a/retroshare-gui/src/gui/WikiPoos/WikiEditDialog.cpp b/retroshare-gui/src/gui/WikiPoos/WikiEditDialog.cpp index 4658bf875..246df55e3 100644 --- a/retroshare-gui/src/gui/WikiPoos/WikiEditDialog.cpp +++ b/retroshare-gui/src/gui/WikiPoos/WikiEditDialog.cpp @@ -414,7 +414,7 @@ void WikiEditDialog::setNewPage() ui.groupBox_History->hide(); ui.pushButton_History->setText(tr("Show Edit History")); - ui.headerFrame->setHeaderImage(QPixmap(":/images/addpage.png")); + ui.headerFrame->setHeaderImage(FilesDefs::getPixmapFromQtResourcePath(":/images/addpage.png")); ui.headerFrame->setHeaderText(tr("Create New Wiki Page")); setWindowTitle(tr("Create New Wiki Page")); @@ -569,7 +569,7 @@ void WikiEditDialog::setupData(const RsGxsGroupId &groupId, const RsGxsMessageId requestPage(msgId); } - ui.headerFrame->setHeaderImage(QPixmap(":/images/editpage.png")); + ui.headerFrame->setHeaderImage(FilesDefs::getPixmapFromQtResourcePath(":/images/editpage.png")); ui.headerFrame->setHeaderText(tr("Edit Wiki Page")); setWindowTitle(tr("Edit Wiki Page")); diff --git a/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp b/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp index bfd2ad379..66ebb8e9e 100644 --- a/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp +++ b/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp @@ -154,7 +154,7 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::Wi { QIcon icon ; - icon.addPixmap(QPixmap(":/icons/png/invite.png")) ; + icon.addPixmap(FilesDefs::getPixmapFromQtResourcePath(":/icons/png/invite.png")) ; inviteFriendsButton->setIcon(icon) ; inviteFriendsButton->setIconSize(icon_size); } @@ -196,7 +196,7 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::Wi { QIcon icon ; - icon.addPixmap(QPixmap(":/icons/png/leave.png")) ; + icon.addPixmap(FilesDefs::getPixmapFromQtResourcePath(":/icons/png/leave.png")) ; unsubscribeButton->setIcon(icon) ; unsubscribeButton->setIconSize(icon_size); } @@ -994,7 +994,7 @@ void ChatLobbyDialog::setWindowed(bool windowed) mPCWindow->addDialog(this); undockButton->setToolTip(tr("Redock to Main window")); - icon.addPixmap(QPixmap(":/icons/png/dock.png")) ; + icon.addPixmap(FilesDefs::getPixmapFromQtResourcePath(":/icons/png/dock.png")) ; undockButton->setIcon(icon) ; undockButton->setIconSize(icon_size); } @@ -1009,7 +1009,7 @@ void ChatLobbyDialog::setWindowed(bool windowed) chatLobbyPage->addChatPage(this); undockButton->setToolTip(tr("Undock to a new window")); - icon.addPixmap(QPixmap(":/icons/png/undock.png")) ; + icon.addPixmap(FilesDefs::getPixmapFromQtResourcePath(":/icons/png/undock.png")) ; undockButton->setIcon(icon) ; undockButton->setIconSize(icon_size); } diff --git a/retroshare-gui/src/gui/chat/ChatWidget.cpp b/retroshare-gui/src/gui/chat/ChatWidget.cpp index 5506dedfb..7b8c532d0 100644 --- a/retroshare-gui/src/gui/chat/ChatWidget.cpp +++ b/retroshare-gui/src/gui/chat/ChatWidget.cpp @@ -1863,7 +1863,7 @@ void ChatWidget::updatePeersCustomStateString(const QString& /*peer_id*/, const void ChatWidget::updateStatusString(const QString &statusMask, const QString &statusString, bool permanent) { ui->typingLabel->setText(QString(statusMask).arg(trUtf8(statusString.toUtf8()))); // displays info for 5 secs. - ui->typingPixmapLabel->setPixmap(QPixmap(":icons/png/typing.png") ); + ui->typingPixmapLabel->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":icons/png/typing.png") ); if (statusString == "is typing...") { typing = true; diff --git a/retroshare-gui/src/gui/chat/CreateLobbyDialog.cpp b/retroshare-gui/src/gui/chat/CreateLobbyDialog.cpp index 1aeb96366..41cb8d3bf 100644 --- a/retroshare-gui/src/gui/chat/CreateLobbyDialog.cpp +++ b/retroshare-gui/src/gui/chat/CreateLobbyDialog.cpp @@ -33,6 +33,7 @@ #include "gui/common/PeerDefs.h" #include "ChatDialog.h" #include "gui/ChatLobbyWidget.h" +#include "gui/common/FilesDefs.h" CreateLobbyDialog::CreateLobbyDialog(const std::set& peer_list, int privacyLevel, QWidget *parent) : QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint) @@ -40,7 +41,7 @@ CreateLobbyDialog::CreateLobbyDialog(const std::set& peer_list, int pr ui = new Ui::CreateLobbyDialog() ; ui->setupUi(this); - ui->headerFrame->setHeaderImage(QPixmap(":/icons/png/chat-lobbies.png")); + ui->headerFrame->setHeaderImage(FilesDefs::getPixmapFromQtResourcePath(":/icons/png/chat-lobbies.png")); ui->headerFrame->setHeaderText(tr("Create Chat Room")); RsGxsId default_identity ; diff --git a/retroshare-gui/src/gui/common/AvatarDefs.cpp b/retroshare-gui/src/gui/common/AvatarDefs.cpp index 0332f50d0..ccca08707 100644 --- a/retroshare-gui/src/gui/common/AvatarDefs.cpp +++ b/retroshare-gui/src/gui/common/AvatarDefs.cpp @@ -26,6 +26,7 @@ #include #include "AvatarDefs.h" +#include "gui/common/FilesDefs.h" void AvatarDefs::getOwnAvatar(QPixmap &avatar, const QString& defaultImage) { @@ -36,7 +37,7 @@ void AvatarDefs::getOwnAvatar(QPixmap &avatar, const QString& defaultImage) rsMsgs->getOwnAvatarData(data, size); if (size == 0) { - avatar = QPixmap(defaultImage); + avatar = FilesDefs::getPixmapFromQtResourcePath(defaultImage); return; } @@ -53,7 +54,7 @@ bool AvatarDefs::getAvatarFromSslId(const RsPeerId& sslId, QPixmap &avatar, cons /* get avatar */ rsMsgs->getAvatarData(RsPeerId(sslId), data, size); if (size == 0) { - avatar = QPixmap(defaultImage); + avatar = FilesDefs::getPixmapFromQtResourcePath(defaultImage); return false; } @@ -72,7 +73,7 @@ bool AvatarDefs::getAvatarFromGxsId(const RsGxsId& gxsId, QPixmap &avatar, const if(!rsIdentity->getIdDetails(gxsId, details)) { - avatar = QPixmap(defaultImage); + avatar = FilesDefs::getPixmapFromQtResourcePath(defaultImage); return false; } @@ -107,7 +108,7 @@ bool AvatarDefs::getAvatarFromGpgId(const RsPgpId& gpgId, QPixmap &avatar, const } if (size == 0) { - avatar = QPixmap(defaultImage); + avatar = FilesDefs::getPixmapFromQtResourcePath(defaultImage); return false; } diff --git a/retroshare-gui/src/gui/common/AvatarDialog.cpp b/retroshare-gui/src/gui/common/AvatarDialog.cpp index 4cd9ce049..2a5d92cac 100644 --- a/retroshare-gui/src/gui/common/AvatarDialog.cpp +++ b/retroshare-gui/src/gui/common/AvatarDialog.cpp @@ -24,6 +24,7 @@ #include "ui_AvatarDialog.h" #include "AvatarDefs.h" #include "util/misc.h" +#include "gui/common/FilesDefs.h" /** Constructor */ AvatarDialog::AvatarDialog(QWidget *parent) : @@ -33,7 +34,7 @@ AvatarDialog::AvatarDialog(QWidget *parent) : /* Invoke Qt Designer generated QObject setup routine */ ui->setupUi(this); - ui->headerFrame->setHeaderImage(QPixmap(":/images/no_avatar_70.png")); + ui->headerFrame->setHeaderImage(FilesDefs::getPixmapFromQtResourcePath(":/images/no_avatar_70.png")); ui->headerFrame->setHeaderText(tr("Set your Avatar picture")); connect(ui->avatarButton, SIGNAL(clicked(bool)), this, SLOT(changeAvatar())); diff --git a/retroshare-gui/src/gui/common/Emoticons.cpp b/retroshare-gui/src/gui/common/Emoticons.cpp index 47a1d67bf..d6bb17e4a 100644 --- a/retroshare-gui/src/gui/common/Emoticons.cpp +++ b/retroshare-gui/src/gui/common/Emoticons.cpp @@ -238,7 +238,7 @@ void Emoticons::showSmileyWidget(QWidget *parent, QWidget *button, const char *s QPushButton *button = new QPushButton("", tabGrpWidget); button->setIconSize(QSize(buttonWidth, buttonHeight)); button->setFixedSize(QSize(buttonWidth, buttonHeight)); - button->setIcon(QPixmap(group.value(key))); + button->setIcon(FilesDefs::getIconFromQtResourcePath(group.value(key))); button->setToolTip(key); button->setStyleSheet("QPushButton:hover {border: 3px solid #0099cc; border-radius: 3px;}"); button->setFlat(true); @@ -402,7 +402,7 @@ void Emoticons::showStickerWidget(QWidget *parent, QWidget *button, const char * button->setFixedSize(QSize(buttonWidth, buttonHeight)); if(!iconcache.contains(fi.absoluteFilePath())) { - iconcache.insert(fi.absoluteFilePath(), QPixmap(fi.absoluteFilePath()).scaled(buttonWidth, buttonHeight, Qt::KeepAspectRatio)); + iconcache.insert(fi.absoluteFilePath(), FilesDefs::getPixmapFromQtResourcePath(fi.absoluteFilePath()).scaled(buttonWidth, buttonHeight, Qt::KeepAspectRatio)); } button->setIcon(iconcache[fi.absoluteFilePath()]); button->setToolTip(fi.fileName()); diff --git a/retroshare-gui/src/gui/common/FilesDefs.cpp b/retroshare-gui/src/gui/common/FilesDefs.cpp index a87b507b7..b7f0192a4 100644 --- a/retroshare-gui/src/gui/common/FilesDefs.cpp +++ b/retroshare-gui/src/gui/common/FilesDefs.cpp @@ -102,7 +102,7 @@ QPixmap FilesDefs::getPixmapFromQtResourcePath(const QString& resource_path) #ifdef DEBUG_FILESDEFS std::cerr << " Not in cache. Creating new one." << std::endl; #endif - pixmap = QPixmap(resource_path); + pixmap = QPixmap(resource_path); mPixmapCache[resource_path] = pixmap; } else diff --git a/retroshare-gui/src/gui/common/FriendList.cpp b/retroshare-gui/src/gui/common/FriendList.cpp index 257a0349a..68d18ddc1 100644 --- a/retroshare-gui/src/gui/common/FriendList.cpp +++ b/retroshare-gui/src/gui/common/FriendList.cpp @@ -306,7 +306,7 @@ void FriendList::peerTreeWidgetCustomPopupMenu() hbox->setSpacing(6); QLabel *iconLabel = new QLabel(widget); - QPixmap pix = QPixmap(":/images/user/friends24.png").scaledToHeight(QFontMetricsF(iconLabel->font()).height()*1.5); + QPixmap pix = FilesDefs::getPixmapFromQtResourcePath(":/images/user/friends24.png").scaledToHeight(QFontMetricsF(iconLabel->font()).height()*1.5); iconLabel->setPixmap(pix); iconLabel->setMaximumSize(iconLabel->frameSize().height() + pix.height(), pix.width()); hbox->addWidget(iconLabel); @@ -1006,7 +1006,7 @@ void FriendList::insertPeers() sslItem->setHidden(false); gpg_connected = true; - sslOverlayIcon = QPixmap(StatusDefs::imageStatus(bestRSState)); + sslOverlayIcon = FilesDefs::getPixmapFromQtResourcePath(StatusDefs::imageStatus(bestRSState)); connectStateString = StatusDefs::name(rsState); @@ -1024,9 +1024,9 @@ void FriendList::insertPeers() peerState = PEER_STATE_AVAILABLE; if (sslDetail.connectState) { - sslOverlayIcon = QPixmap(":/images/connect_creating.png"); + sslOverlayIcon = FilesDefs::getPixmapFromQtResourcePath(":/images/connect_creating.png"); } else { - sslOverlayIcon = QPixmap(StatusDefs::imageStatus(RS_STATUS_ONLINE)); + sslOverlayIcon = FilesDefs::getPixmapFromQtResourcePath(StatusDefs::imageStatus(RS_STATUS_ONLINE)); } connectStateString = StatusDefs::name(RS_STATUS_ONLINE); @@ -1037,9 +1037,9 @@ void FriendList::insertPeers() peerState = PEER_STATE_OFFLINE; sslItem->setHidden(mHideUnconnected); if (sslDetail.connectState) { - sslOverlayIcon = QPixmap(":/images/connect_creating.png"); + sslOverlayIcon = FilesDefs::getPixmapFromQtResourcePath(":/images/connect_creating.png"); } else { - sslOverlayIcon = QPixmap(StatusDefs::imageStatus(RS_STATUS_OFFLINE)); + sslOverlayIcon = FilesDefs::getPixmapFromQtResourcePath(StatusDefs::imageStatus(RS_STATUS_OFFLINE)); } connectStateString = StatusDefs::connectStateWithoutTransportTypeString(sslDetail); @@ -1099,7 +1099,7 @@ void FriendList::insertPeers() if (std::find(privateChatIds.begin(), privateChatIds.end(), sslDetail.id) != privateChatIds.end()) { // private chat is available - sslOverlayIcon = QPixmap(":/images/chat.png"); + sslOverlayIcon = FilesDefs::getPixmapFromQtResourcePath(":/images/chat.png"); gpg_hasPrivateChat = true; } sslItem->setIcon(COLUMN_NAME, createAvatar(sslAvatar, sslOverlayIcon)); @@ -1138,7 +1138,7 @@ void FriendList::insertPeers() gpgFont = StatusDefs::font(bestRSState); if (showInfoAtGpgItem) { - gpgOverlayIcon = QPixmap(StatusDefs::imageStatus(bestRSState)); + gpgOverlayIcon = FilesDefs::getPixmapFromQtResourcePath(StatusDefs::imageStatus(bestRSState)); if (mShowState) { gpgText = StatusDefs::name(bestRSState); @@ -1164,7 +1164,7 @@ void FriendList::insertPeers() gpgText += tr("Available"); } - gpgOverlayIcon = QPixmap(IMAGE_AVAILABLE); + gpgOverlayIcon = FilesDefs::getPixmapFromQtResourcePath(IMAGE_AVAILABLE); } } else { bestPeerState = PEER_STATE_OFFLINE; @@ -1178,15 +1178,15 @@ void FriendList::insertPeers() gpgText += StatusDefs::name(RS_STATUS_OFFLINE); } - gpgOverlayIcon = QPixmap(StatusDefs::imageStatus(RS_STATUS_OFFLINE)); + gpgOverlayIcon = FilesDefs::getPixmapFromQtResourcePath(StatusDefs::imageStatus(RS_STATUS_OFFLINE)); } } if (gpg_hasPrivateChat) { - gpgOverlayIcon = QPixmap(":/images/chat.png"); + gpgOverlayIcon = FilesDefs::getPixmapFromQtResourcePath(":/images/chat.png"); } - gpgItem->setIcon(COLUMN_NAME, createAvatar(bestAvatar.isNull() ? QPixmap(AVATAR_DEFAULT_IMAGE) : bestAvatar, gpgOverlayIcon)); + gpgItem->setIcon(COLUMN_NAME, createAvatar(bestAvatar.isNull() ? FilesDefs::getPixmapFromQtResourcePath(AVATAR_DEFAULT_IMAGE) : bestAvatar, gpgOverlayIcon)); /* Create or get gpg label */ ElidedLabel *gpgNameLabel = NULL; diff --git a/retroshare-gui/src/gui/common/NewFriendList.cpp b/retroshare-gui/src/gui/common/NewFriendList.cpp index 2dd216383..4264710ea 100644 --- a/retroshare-gui/src/gui/common/NewFriendList.cpp +++ b/retroshare-gui/src/gui/common/NewFriendList.cpp @@ -307,7 +307,7 @@ void NewFriendList::headerContextMenuRequested(QPoint p) hbox->setSpacing(6); QLabel *iconLabel = new QLabel(widget); - QPixmap pix = QPixmap(":/images/user/friends24.png").scaledToHeight(QFontMetricsF(iconLabel->font()).height()*1.5); + QPixmap pix = FilesDefs::getPixmapFromQtResourcePath(":/images/user/friends24.png").scaledToHeight(QFontMetricsF(iconLabel->font()).height()*1.5); iconLabel->setPixmap(pix); iconLabel->setMaximumSize(iconLabel->frameSize().height() + pix.height(), pix.width()); hbox->addWidget(iconLabel); @@ -533,7 +533,7 @@ void NewFriendList::peerTreeWidgetCustomPopupMenu() hbox->setSpacing(6); QLabel *iconLabel = new QLabel(widget); - QPixmap pix = QPixmap(":/images/user/friends24.png").scaledToHeight(QFontMetricsF(iconLabel->font()).height()*1.5); + QPixmap pix = FilesDefs::getPixmapFromQtResourcePath(":/images/user/friends24.png").scaledToHeight(QFontMetricsF(iconLabel->font()).height()*1.5); iconLabel->setPixmap(pix); iconLabel->setMaximumSize(iconLabel->frameSize().height() + pix.height(), pix.width()); hbox->addWidget(iconLabel); diff --git a/retroshare-gui/src/gui/common/RSTextBrowser.cpp b/retroshare-gui/src/gui/common/RSTextBrowser.cpp index 46053bb66..552369a77 100644 --- a/retroshare-gui/src/gui/common/RSTextBrowser.cpp +++ b/retroshare-gui/src/gui/common/RSTextBrowser.cpp @@ -27,6 +27,7 @@ #include "RSTextBrowser.h" #include "RSImageBlockWidget.h" +#include "gui/common/FilesDefs.h" #include //To get RsAccounts @@ -149,7 +150,7 @@ QVariant RSTextBrowser::loadResource(int type, const QUrl &name) QPixmap RSTextBrowser::getBlockedImage() { - return QPixmap(":/images/imageblocked_24.png"); + return FilesDefs::getPixmapFromQtResourcePath(":/images/imageblocked_24.png"); } void RSTextBrowser::setImageBlockWidget(RSImageBlockWidget *widget) diff --git a/retroshare-gui/src/gui/common/RSTreeWidget.cpp b/retroshare-gui/src/gui/common/RSTreeWidget.cpp index 9322535fe..bcd8eef53 100644 --- a/retroshare-gui/src/gui/common/RSTreeWidget.cpp +++ b/retroshare-gui/src/gui/common/RSTreeWidget.cpp @@ -29,6 +29,7 @@ #include #include "gui/settings/rsharesettings.h" +#include "gui/common/FilesDefs.h" RSTreeWidget::RSTreeWidget(QWidget *parent) : QTreeWidget(parent) { @@ -259,7 +260,7 @@ QMenu *RSTreeWidget::createStandardContextMenu(QMenu *contextMenu) hbox->setSpacing(6); QLabel *iconLabel = new QLabel(widget); - QPixmap pix = QPixmap(":/images/settings.png").scaledToHeight(QFontMetricsF(iconLabel->font()).height()*1.5); + QPixmap pix = FilesDefs::getPixmapFromQtResourcePath(":/images/settings.png").scaledToHeight(QFontMetricsF(iconLabel->font()).height()*1.5); iconLabel->setPixmap(pix); iconLabel->setMaximumSize(iconLabel->frameSize().height() + pix.height(), pix.width()); hbox->addWidget(iconLabel); diff --git a/retroshare-gui/src/gui/common/RsCollectionDialog.cpp b/retroshare-gui/src/gui/common/RsCollectionDialog.cpp index 89976f6e8..b3f53a220 100644 --- a/retroshare-gui/src/gui/common/RsCollectionDialog.cpp +++ b/retroshare-gui/src/gui/common/RsCollectionDialog.cpp @@ -143,7 +143,7 @@ RsCollectionDialog::RsCollectionDialog(const QString& collectionFileName setWindowTitle(QString("%1 - %2").arg(windowTitle()).arg(QFileInfo(_fileName).completeBaseName())); - ui.headerFrame->setHeaderImage(QPixmap(":/icons/collections.png")); + ui.headerFrame->setHeaderImage(FilesDefs::getPixmapFromQtResourcePath(":/icons/collections.png")); if(creation) { diff --git a/retroshare-gui/src/gui/connect/ConfCertDialog.cpp b/retroshare-gui/src/gui/connect/ConfCertDialog.cpp index fc56ebef5..851bf72fd 100644 --- a/retroshare-gui/src/gui/connect/ConfCertDialog.cpp +++ b/retroshare-gui/src/gui/connect/ConfCertDialog.cpp @@ -38,6 +38,7 @@ #include "gui/RetroShareLink.h" #include "gui/notifyqt.h" #include "gui/common/AvatarDefs.h" +#include "gui/common/FilesDefs.h" #include "gui/MainWindow.h" #include "mainpage.h" #include "util/DateTime.h" @@ -83,7 +84,7 @@ ConfCertDialog::ConfCertDialog(const RsPeerId& id, const RsPgpId &pgp_id, QWidge /* Invoke Qt Designer generated QObject setup routine */ ui.setupUi(this); Settings->loadWidgetInformation(this); - ui.headerFrame->setHeaderImage(QPixmap(":/images/user/identityinfo64.png")); + ui.headerFrame->setHeaderImage(FilesDefs::getPixmapFromQtResourcePath(":/images/user/identityinfo64.png")); //ui.headerFrame->setHeaderText(tr("Friend node details")); //ui._chat_CB->hide() ; diff --git a/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp b/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp index c225d3eac..e822499a1 100755 --- a/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp +++ b/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp @@ -95,10 +95,10 @@ ConnectFriendWizard::ConnectFriendWizard(QWidget *parent) : // setOption(HaveHelpButton, true); // connect(this, SIGNAL(helpRequested()), this, SLOT(showHelp())); - setPixmap(QWizard::LogoPixmap, QPixmap(":/icons/invite64.png")); + setPixmap(QWizard::LogoPixmap, FilesDefs::getPixmapFromQtResourcePath(":/icons/invite64.png")); // we have no good pictures for watermarks -// setPixmap(QWizard::WatermarkPixmap, QPixmap(":/images/connectFriendWatermark.png")); +// setPixmap(QWizard::WatermarkPixmap, FilesDefs::getPixmapFromQtResourcePath(":/images/connectFriendWatermark.png")); /* register global fields */ ui->ErrorMessagePage->registerField("errorMessage", ui->messageLabel, "text"); @@ -563,7 +563,7 @@ void ConnectFriendWizard::initializePage(int id) ui->_addIPToWhiteList_ComboBox_2->addItem("(Hidden node)") ; int S = QFontMetricsF(ui->ipEdit->font()).height() ; ui->ipEdit->setToolTip("This is a Hidden node - you need tor/i2p proxy to connect"); - ui->ipLabel->setPixmap(QPixmap(":/images/anonymous_128_blue.png").scaledToHeight(S*2,Qt::SmoothTransformation)); + ui->ipLabel->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/images/anonymous_128_blue.png").scaledToHeight(S*2,Qt::SmoothTransformation)); ui->ipLabel->setToolTip("This is a Hidden node - you need tor/i2p proxy to connect"); } if(mIsShortInvite) @@ -813,7 +813,7 @@ void ConnectFriendWizard::cleanFriendCert() std::string cert = ui->friendCertEdit->toPlainText().toUtf8().constData(); if (cert.empty()) { - ui->friendCertCleanLabel->setPixmap(QPixmap(":/images/delete.png")); + ui->friendCertCleanLabel->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/images/delete.png")); ui->friendCertCleanLabel->setToolTip(""); ui->friendCertCleanLabel->setStyleSheet(""); errorMsg = tr(""); @@ -837,7 +837,7 @@ void ConnectFriendWizard::cleanFriendCert() } errorMsg = tr("Valid certificate") + (mIsShortInvite?" (Short format)":" (plain format with profile key)"); - ui->friendCertCleanLabel->setPixmap(QPixmap(":/images/accepted16.png")); + ui->friendCertCleanLabel->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/images/accepted16.png")); } else { if (error_code > 0) { switch (error_code) { @@ -856,11 +856,11 @@ void ConnectFriendWizard::cleanFriendCert() ui->friendCertCleanLabel->setStyleSheet("QLabel#friendCertCleanLabel {border: 2px solid red; border-radius: 6px;}"); } } - ui->friendCertCleanLabel->setPixmap(QPixmap(":/images/delete.png")); + ui->friendCertCleanLabel->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/images/delete.png")); } } - ui->friendCertCleanLabel->setPixmap(certValid ? QPixmap(":/images/accepted16.png") : QPixmap(":/images/delete.png")); + ui->friendCertCleanLabel->setPixmap(certValid ? FilesDefs::getPixmapFromQtResourcePath(":/images/accepted16.png") : FilesDefs::getPixmapFromQtResourcePath(":/images/delete.png")); ui->friendCertCleanLabel->setToolTip(errorMsg); ui->friendCertCleanLabel->setText(errorMsg); diff --git a/retroshare-gui/src/gui/connect/ConnectProgressDialog.cpp b/retroshare-gui/src/gui/connect/ConnectProgressDialog.cpp index 8f039f911..5f0ad637d 100755 --- a/retroshare-gui/src/gui/connect/ConnectProgressDialog.cpp +++ b/retroshare-gui/src/gui/connect/ConnectProgressDialog.cpp @@ -29,6 +29,7 @@ #include #include "gui/common/StatusDefs.h" +#include "gui/common/FilesDefs.h" /* maintain one static dialog per SSL ID */ @@ -56,7 +57,7 @@ ConnectProgressDialog::ConnectProgressDialog(const RsPeerId& id, QWidget *parent ui->setupUi(this); setAttribute(Qt::WA_DeleteOnClose, true); - ui->headerFrame->setHeaderImage(QPixmap(":/images/user/identityinfo64.png")); + ui->headerFrame->setHeaderImage(FilesDefs::getPixmapFromQtResourcePath(":/images/user/identityinfo64.png")); ui->headerFrame->setHeaderText(tr("Connection Assistant")); connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(stopAndClose())); diff --git a/retroshare-gui/src/gui/connect/PGPKeyDialog.cpp b/retroshare-gui/src/gui/connect/PGPKeyDialog.cpp index 5dde6822c..342bac2a2 100644 --- a/retroshare-gui/src/gui/connect/PGPKeyDialog.cpp +++ b/retroshare-gui/src/gui/connect/PGPKeyDialog.cpp @@ -74,7 +74,7 @@ PGPKeyDialog::PGPKeyDialog(const RsPeerId& id, const RsPgpId &pgp_id, QWidget *p // ui._useOldFormat_CB->setEnabled(false) ; // } - ui.headerFrame->setHeaderImage(QPixmap(":/images/user/identityinfo64.png")); + ui.headerFrame->setHeaderImage(FilesDefs::getPixmapFromQtResourcePath(":/images/user/identityinfo64.png")); ui.headerFrame->setHeaderText(tr("Retroshare profile")); //ui._chat_CB->hide() ; diff --git a/retroshare-gui/src/gui/feeds/GxsChannelGroupItem.cpp b/retroshare-gui/src/gui/feeds/GxsChannelGroupItem.cpp index 8f53b5fe4..41c61d896 100644 --- a/retroshare-gui/src/gui/feeds/GxsChannelGroupItem.cpp +++ b/retroshare-gui/src/gui/feeds/GxsChannelGroupItem.cpp @@ -148,7 +148,7 @@ void GxsChannelGroupItem::fill() if (mGroup.mImage.mData != NULL) { QPixmap chanImage; GxsIdDetails::loadPixmapFromData(mGroup.mImage.mData, mGroup.mImage.mSize, chanImage,GxsIdDetails::ORIGINAL); - ui->logoLabel->setPixmap(QPixmap(chanImage)); + ui->logoLabel->setPixmap(chanImage); } if (IS_GROUP_SUBSCRIBED(mGroup.mMeta.mSubscribeFlags)) { diff --git a/retroshare-gui/src/gui/feeds/GxsForumGroupItem.cpp b/retroshare-gui/src/gui/feeds/GxsForumGroupItem.cpp index 5df1a8906..1d61bb98b 100644 --- a/retroshare-gui/src/gui/feeds/GxsForumGroupItem.cpp +++ b/retroshare-gui/src/gui/feeds/GxsForumGroupItem.cpp @@ -159,9 +159,9 @@ void GxsForumGroupItem::fill() ui->descLabel->setText(QString::fromUtf8(mGroup.mDescription.c_str())); if (IS_GROUP_PUBLISHER(mGroup.mMeta.mSubscribeFlags)) { - ui->forumlogo_label->setPixmap(QPixmap(":/icons/png/forums.png")); + ui->forumlogo_label->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/icons/png/forums.png")); } else { - ui->forumlogo_label->setPixmap(QPixmap(":/icons/png/forums-default.png")); + ui->forumlogo_label->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/icons/png/forums-default.png")); } if (IS_GROUP_SUBSCRIBED(mGroup.mMeta.mSubscribeFlags)) { diff --git a/retroshare-gui/src/gui/feeds/GxsForumMsgItem.cpp b/retroshare-gui/src/gui/feeds/GxsForumMsgItem.cpp index 4d4bdd661..de9dceb79 100644 --- a/retroshare-gui/src/gui/feeds/GxsForumMsgItem.cpp +++ b/retroshare-gui/src/gui/feeds/GxsForumMsgItem.cpp @@ -335,9 +335,9 @@ void GxsForumMsgItem::fill() } if (IS_GROUP_PUBLISHER(mGroup.mMeta.mSubscribeFlags)) { - ui->iconLabel->setPixmap(QPixmap(":/icons/png/forums.png")); + ui->iconLabel->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/icons/png/forums.png")); } else { - ui->iconLabel->setPixmap(QPixmap(":/icons/png/forums-default.png")); + ui->iconLabel->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/icons/png/forums-default.png")); } if (!mIsHome) { diff --git a/retroshare-gui/src/gui/feeds/PostedGroupItem.cpp b/retroshare-gui/src/gui/feeds/PostedGroupItem.cpp index 90d766bc2..4ed8a95c4 100644 --- a/retroshare-gui/src/gui/feeds/PostedGroupItem.cpp +++ b/retroshare-gui/src/gui/feeds/PostedGroupItem.cpp @@ -157,15 +157,15 @@ void PostedGroupItem::fill() GxsIdDetails::loadPixmapFromData(mGroup.mGroupImage.mData, mGroup.mGroupImage.mSize, postedImage,GxsIdDetails::ORIGINAL); ui->logoLabel->setPixmap(QPixmap(postedImage)); } else { - ui->logoLabel->setPixmap(QPixmap(":/icons/png/posted.png")); + ui->logoLabel->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/icons/png/posted.png")); } //TODO - nice icon for subscribed group // if (IS_GROUP_PUBLISHER(mGroup.mMeta.mSubscribeFlags)) { -// ui->logoLabel->setPixmap(QPixmap(":/icons/png/posted.png")); +// ui->logoLabel->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/icons/png/posted.png")); // } else { -// ui->logoLabel->setPixmap(QPixmap(":/icons/png/posted.png")); +// ui->logoLabel->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/icons/png/posted.png")); // } if (IS_GROUP_SUBSCRIBED(mGroup.mMeta.mSubscribeFlags)) { diff --git a/retroshare-gui/src/gui/groups/CreateGroup.cpp b/retroshare-gui/src/gui/groups/CreateGroup.cpp index b7c01564d..91380f98b 100644 --- a/retroshare-gui/src/gui/groups/CreateGroup.cpp +++ b/retroshare-gui/src/gui/groups/CreateGroup.cpp @@ -26,6 +26,7 @@ #include "gui/common/GroupDefs.h" #include "gui/settings/rsharesettings.h" #include "util/misc.h" +#include "gui/common/FilesDefs.h" #include @@ -40,7 +41,7 @@ CreateGroup::CreateGroup(const RsNodeGroupId &groupId, QWidget *parent) mIsStandard = false; - ui.headerFrame->setHeaderImage(QPixmap(":/images/user/add_group256.png")); + ui.headerFrame->setHeaderImage(FilesDefs::getPixmapFromQtResourcePath(":/images/user/add_group256.png")); mGroupId = groupId; @@ -68,7 +69,7 @@ CreateGroup::CreateGroup(const RsNodeGroupId &groupId, QWidget *parent) } setWindowTitle(tr("Edit Group")); - ui.headerFrame->setHeaderImage(QPixmap(":/images/user/edit_group64.png")); + ui.headerFrame->setHeaderImage(FilesDefs::getPixmapFromQtResourcePath(":/images/user/edit_group64.png")); ui.headerFrame->setHeaderText(tr("Edit Group")); ui.groupName->setDisabled(mIsStandard); diff --git a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp index 1021a3937..77b2275cd 100644 --- a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp +++ b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp @@ -146,7 +146,7 @@ void GxsGroupFrameDialog::initUi() { registerHelpButton(ui->helpButton, getHelpString(),pageName()) ; - ui->titleBarPixmap->setPixmap(QPixmap(icon(ICON_NAME))); + ui->titleBarPixmap->setPixmap(FilesDefs::getPixmapFromQtResourcePath(icon(ICON_NAME))); ui->titleBarLabel->setText(text(TEXT_NAME)); /* Initialize group tree */ diff --git a/retroshare-gui/src/gui/gxs/GxsGroupShareKey.cpp b/retroshare-gui/src/gui/gxs/GxsGroupShareKey.cpp index a11b7b788..dfcafaaf2 100644 --- a/retroshare-gui/src/gui/gxs/GxsGroupShareKey.cpp +++ b/retroshare-gui/src/gui/gxs/GxsGroupShareKey.cpp @@ -29,6 +29,7 @@ #include #include "gui/common/PeerDefs.h" +#include "gui/common/FilesDefs.h" GroupShareKey::GroupShareKey(QWidget *parent, const RsGxsGroupId &grpId, int grpType) : QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint), mGrpId(grpId), mGrpType(grpType) @@ -36,7 +37,7 @@ GroupShareKey::GroupShareKey(QWidget *parent, const RsGxsGroupId &grpId, int grp ui = new Ui::ShareKey(); ui->setupUi(this); - ui->headerFrame->setHeaderImage(QPixmap(":/images/user/agt_forum64.png")); + ui->headerFrame->setHeaderImage(FilesDefs::getPixmapFromQtResourcePath(":/images/user/agt_forum64.png")); ui->headerFrame->setHeaderText(tr("Share")); connect( ui->buttonBox, SIGNAL(accepted()), this, SLOT(shareKey())); @@ -76,14 +77,14 @@ void GroupShareKey::setTyp() if (!rsGxsChannels) return; - ui->headerFrame->setHeaderImage(QPixmap(":/icons/png/channels.png")); + ui->headerFrame->setHeaderImage(FilesDefs::getPixmapFromQtResourcePath(":/icons/png/channels.png")); ui->headerFrame->setHeaderText(tr("Share channel publish permissions")); ui->sharekeyinfo_label->setText(tr("You can allow your friends to publish in your channel, or send the publish permissions to another Retroshare instance of yours. Select the friends which you want to be allowed to publish in this channel. Note: it is currently not possible to revoke channel publish permissions.")); } else if(mGrpType == FORUM_KEY_SHARE) { - ui->headerFrame->setHeaderImage(QPixmap(":/icons/png/forums.png")); + ui->headerFrame->setHeaderImage(FilesDefs::getPixmapFromQtResourcePath(":/icons/png/forums.png")); ui->headerFrame->setHeaderText(tr("Share forum admin permissions")); ui->sharekeyinfo_label->setText(tr("You can let your friends know about your forum by sharing it with them. Select the friends with which you want to share your forum.")); @@ -93,7 +94,7 @@ void GroupShareKey::setTyp() if (!rsPosted) return; - ui->headerFrame->setHeaderImage(QPixmap(":/icons/png/posted.png")); + ui->headerFrame->setHeaderImage(FilesDefs::getPixmapFromQtResourcePath(":/icons/png/posted.png")); ui->headerFrame->setHeaderText(tr("Share board admin permissions")); ui->sharekeyinfo_label->setText(tr("You can allow your friends to edit the board. Select them in the list below. Note: it is not possible to revoke Board admin permissions.")); diff --git a/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.cpp b/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.cpp index aa9201e95..0a8b9271b 100644 --- a/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.cpp +++ b/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.cpp @@ -161,7 +161,7 @@ QVariant GxsIdRSTreeWidgetItem::data(int column, int role) const if(mId.isNull()) return RSTreeWidgetItem::data(column, role); else if( rsReputations->overallReputationLevel(mId) == RsReputationLevel::LOCALLY_NEGATIVE ) - pix = QPixmap(BANNED_IMAGE); + pix = FilesDefs::getPixmapFromQtResourcePath(BANNED_IMAGE); else if ( mAvatar.mSize == 0 || !GxsIdDetails::loadPixmapFromData(mAvatar.mData, mAvatar.mSize, pix,GxsIdDetails::LARGE) ) pix = GxsIdDetails::makeDefaultIcon(mId,GxsIdDetails::LARGE); diff --git a/retroshare-gui/src/gui/gxs/WikiGroupDialog.cpp b/retroshare-gui/src/gui/gxs/WikiGroupDialog.cpp index a502c79bf..1935f171e 100644 --- a/retroshare-gui/src/gui/gxs/WikiGroupDialog.cpp +++ b/retroshare-gui/src/gui/gxs/WikiGroupDialog.cpp @@ -87,7 +87,7 @@ void WikiGroupDialog::initUi() QPixmap WikiGroupDialog::serviceImage() { - return QPixmap(":/icons/png/wiki.png"); + return FilesDefs::getPixmapFromQtResourcePath(":/icons/png/wiki.png"); } diff --git a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp index 177289f09..98c326d38 100644 --- a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp +++ b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp @@ -56,7 +56,7 @@ CreateGxsChannelMsg::CreateGxsChannelMsg(const RsGxsGroupId &cId, RsGxsMessageId setupUi(this); Settings->loadWidgetInformation(this); - headerFrame->setHeaderImage(QPixmap(":/icons/png/channel.png")); + headerFrame->setHeaderImage(FilesDefs::getPixmapFromQtResourcePath(":/icons/png/channel.png")); if(!existing_post.isNull()) headerFrame->setHeaderText(tr("Edit Channel Post")); diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelGroupDialog.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelGroupDialog.cpp index 25ad04c30..ef5f03e9a 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelGroupDialog.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelGroupDialog.cpp @@ -21,6 +21,7 @@ #include #include "gui/gxs/GxsIdDetails.h" +#include "gui/common/FilesDefs.h" #include "GxsChannelGroupDialog.h" #include @@ -99,11 +100,9 @@ QPixmap GxsChannelGroupDialog::serviceImage() switch (mode()) { case MODE_CREATE: - return QPixmap(":/icons/png/channel.png"); case MODE_SHOW: - return QPixmap(":/icons/png/channel.png"); case MODE_EDIT: - return QPixmap(":/icons/png/channel.png"); + return FilesDefs::getPixmapFromQtResourcePath(":/icons/png/channel.png"); } return QPixmap(); diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp index a393b1d38..16a8fb72f 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp @@ -116,8 +116,8 @@ GxsChannelPostsWidget::GxsChannelPostsWidget(const RsGxsGroupId &channelId, QWid /* Initialize subscribe button */ QIcon icon; - icon.addPixmap(QPixmap(":/images/redled.png"), QIcon::Normal, QIcon::On); - icon.addPixmap(QPixmap(":/images/start.png"), QIcon::Normal, QIcon::Off); + icon.addPixmap(FilesDefs::getPixmapFromQtResourcePath(":/images/redled.png"), QIcon::Normal, QIcon::On); + icon.addPixmap(FilesDefs::getPixmapFromQtResourcePath(":/images/start.png"), QIcon::Normal, QIcon::Off); mAutoDownloadAction = new QAction(icon, "", this); mAutoDownloadAction->setCheckable(true); connect(mAutoDownloadAction, SIGNAL(triggered()), this, SLOT(toggleAutoDownload())); @@ -211,7 +211,7 @@ void GxsChannelPostsWidget::groupNameChanged(const QString &name) { if (groupId().isNull()) { ui->nameLabel->setText(tr("No Channel Selected")); - ui->logoLabel->setPixmap(QPixmap(":/icons/png/channels.png")); + ui->logoLabel->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/icons/png/channels.png")); } else { ui->nameLabel->setText(name); } @@ -280,7 +280,7 @@ void GxsChannelPostsWidget::insertChannelDetails(const RsGxsChannelGroup &group) if (group.mImage.mData != NULL) { GxsIdDetails::loadPixmapFromData(group.mImage.mData, group.mImage.mSize, chanImage,GxsIdDetails::ORIGINAL); } else { - chanImage = QPixmap(CHAN_DEFAULT_IMAGE); + chanImage = FilesDefs::getPixmapFromQtResourcePath(CHAN_DEFAULT_IMAGE); } ui->logoLabel->setPixmap(chanImage); diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp index 093c5b12c..a485783d0 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp @@ -309,8 +309,8 @@ GxsChannelPostsWidgetWithModel::GxsChannelPostsWidgetWithModel(const RsGxsGroupI /* Initialize subscribe button */ QIcon icon; - icon.addPixmap(QPixmap(":/images/redled.png"), QIcon::Normal, QIcon::On); - icon.addPixmap(QPixmap(":/images/start.png"), QIcon::Normal, QIcon::Off); + icon.addPixmap(FilesDefs::getPixmapFromQtResourcePath(":/images/redled.png"), QIcon::Normal, QIcon::On); + icon.addPixmap(FilesDefs::getPixmapFromQtResourcePath(":/images/start.png"), QIcon::Normal, QIcon::Off); mAutoDownloadAction = new QAction(icon, "", this); mAutoDownloadAction->setCheckable(true); connect(mAutoDownloadAction, SIGNAL(triggered()), this, SLOT(toggleAutoDownload())); @@ -695,7 +695,7 @@ void GxsChannelPostsWidgetWithModel::groupNameChanged(const QString &name) { // if (groupId().isNull()) { // ui->nameLabel->setText(tr("No Channel Selected")); -// ui->logoLabel->setPixmap(QPixmap(":/icons/png/channels.png")); +// ui->logoLabel->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/icons/png/channels.png")); // } else { // ui->nameLabel->setText(name); // } @@ -749,7 +749,7 @@ void GxsChannelPostsWidgetWithModel::insertChannelDetails(const RsGxsChannelGrou if (group.mImage.mData != NULL) { GxsIdDetails::loadPixmapFromData(group.mImage.mData, group.mImage.mSize, chanImage,GxsIdDetails::ORIGINAL); } else { - chanImage = QPixmap(ChannelPostThumbnailView::CHAN_DEFAULT_IMAGE); + chanImage = FilesDefs::getPixmapFromQtResourcePath(ChannelPostThumbnailView::CHAN_DEFAULT_IMAGE); } if(group.mMeta.mGroupName.empty()) ui->channelName_LB->setText(tr("[No name]")); diff --git a/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.cpp b/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.cpp index 2ba83a31a..dd9a242b6 100644 --- a/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.cpp +++ b/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.cpp @@ -35,6 +35,7 @@ #include "gui/common/Emoticons.h" #include "gui/common/UIStateHelper.h" #include "gui/Identity/IdEditDialog.h" +#include "gui/common/FilesDefs.h" #include "util/HandleRichText.h" #include "util/misc.h" @@ -89,7 +90,7 @@ CreateGxsForumMsg::CreateGxsForumMsg(const RsGxsGroupId &fId, const RsGxsMessage ui.forumMessage->setPlaceholderText(tr ("Text")); - ui.headerFrame->setHeaderImage(QPixmap(":/icons/png/forums.png")); + ui.headerFrame->setHeaderImage(FilesDefs::getPixmapFromQtResourcePath(":/icons/png/forums.png")); ui.headerFrame->setHeaderText(text); ui.generateSpinBox->setEnabled(false); diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumGroupDialog.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumGroupDialog.cpp index 966115905..424091867 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumGroupDialog.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumGroupDialog.cpp @@ -19,6 +19,7 @@ *******************************************************************************/ #include "GxsForumGroupDialog.h" +#include "gui/common/FilesDefs.h" #include #include @@ -96,7 +97,7 @@ void GxsForumGroupDialog::initUi() QPixmap GxsForumGroupDialog::serviceImage() { - return QPixmap(":/icons/png/forums.png"); + return FilesDefs::getPixmapFromQtResourcePath(":/icons/png/forums.png"); } bool GxsForumGroupDialog::service_createGroup(RsGroupMetaData& meta) diff --git a/retroshare-gui/src/gui/im_history/ImHistoryBrowser.cpp b/retroshare-gui/src/gui/im_history/ImHistoryBrowser.cpp index 9adcd3d22..70b5b4b0d 100644 --- a/retroshare-gui/src/gui/im_history/ImHistoryBrowser.cpp +++ b/retroshare-gui/src/gui/im_history/ImHistoryBrowser.cpp @@ -32,6 +32,7 @@ #include "IMHistoryItemDelegate.h" #include "IMHistoryItemPainter.h" #include "util/HandleRichText.h" +#include "gui/common/FilesDefs.h" #include "rshare.h" #include @@ -96,7 +97,7 @@ ImHistoryBrowser::ImHistoryBrowser(const ChatId &chatId, QTextEdit *edit, QWidge /* Invoke Qt Designer generated QObject setup routine */ ui.setupUi(this); - ui.headerFrame->setHeaderImage(QPixmap(":/images/user/agt_forum64.png")); + ui.headerFrame->setHeaderImage(FilesDefs::getPixmapFromQtResourcePath(":/images/user/agt_forum64.png")); ui.headerFrame->setHeaderText(tr("Message History")); m_chatId = chatId; diff --git a/retroshare-gui/src/gui/profile/ProfileManager.cpp b/retroshare-gui/src/gui/profile/ProfileManager.cpp index 7041f7201..c0a63229e 100644 --- a/retroshare-gui/src/gui/profile/ProfileManager.cpp +++ b/retroshare-gui/src/gui/profile/ProfileManager.cpp @@ -51,7 +51,7 @@ ProfileManager::ProfileManager(QWidget *parent) /* Invoke Qt Designer generated QObject setup routine */ ui.setupUi(this); - ui.headerFrame->setHeaderImage(QPixmap(":/icons/png/profile.png")); + ui.headerFrame->setHeaderImage(FilesDefs::getPixmapFromQtResourcePath(":/icons/png/profile.png")); ui.headerFrame->setHeaderText(tr("Profile Manager")); connect(ui.identityTreeWidget, SIGNAL( customContextMenuRequested(QPoint)), this, SLOT( identityTreeWidgetCostumPopupMenu(QPoint))); diff --git a/retroshare-gui/src/gui/settings/AboutPage.h b/retroshare-gui/src/gui/settings/AboutPage.h index 5c9be1be9..4881ca730 100644 --- a/retroshare-gui/src/gui/settings/AboutPage.h +++ b/retroshare-gui/src/gui/settings/AboutPage.h @@ -22,8 +22,9 @@ #include -#include +#include "retroshare-gui/configpage.h" #include "ui_AboutPage.h" +#include "gui/common/FilesDefs.h" class AboutPage : public ConfigPage { @@ -38,7 +39,7 @@ public: /** Loads the settings for this page */ virtual void load(); - virtual QPixmap iconPixmap() const { return QPixmap(":/icons/svg/info.svg") ; } + virtual QPixmap iconPixmap() const { return FilesDefs::getPixmapFromQtResourcePath(":/icons/svg/info.svg") ; } virtual QString pageName() const { return tr("About") ; } virtual QString helpText() const { return ""; } diff --git a/retroshare-gui/src/gui/settings/AppearancePage.h b/retroshare-gui/src/gui/settings/AppearancePage.h index 9700d6ca3..897563753 100755 --- a/retroshare-gui/src/gui/settings/AppearancePage.h +++ b/retroshare-gui/src/gui/settings/AppearancePage.h @@ -21,9 +21,10 @@ #ifndef _APPERARANCEPAGE_H #define _APPERARANCEPAGE_H -#include +#include "retroshare-gui/configpage.h" #include "gui/MainWindow.h" #include "ui_AppearancePage.h" +#include "gui/common/FilesDefs.h" class AppearancePage : public ConfigPage { @@ -36,7 +37,7 @@ public: /** Loads the settings for this page */ virtual void load(); - virtual QPixmap iconPixmap() const { return QPixmap(":/icons/settings/appearance.svg") ; } + virtual QPixmap iconPixmap() const { return FilesDefs::getPixmapFromQtResourcePath(":/icons/settings/appearance.svg") ; } virtual QString pageName() const { return tr("Appearance") ; } virtual QString helpText() const { return ""; } diff --git a/retroshare-gui/src/gui/settings/ChannelPage.h b/retroshare-gui/src/gui/settings/ChannelPage.h index 6e684ead0..eea79d89c 100644 --- a/retroshare-gui/src/gui/settings/ChannelPage.h +++ b/retroshare-gui/src/gui/settings/ChannelPage.h @@ -21,8 +21,9 @@ #ifndef CHANNELPAGE_H #define CHANNELPAGE_H -#include +#include "retroshare-gui/configpage.h" #include "ui_ChannelPage.h" +#include "gui/common/FilesDefs.h" class ChannelPage : public ConfigPage { @@ -35,7 +36,7 @@ public: /** Loads the settings for this page */ virtual void load(); - virtual QPixmap iconPixmap() const { return QPixmap(":/icons/settings/channels.svg") ; } + virtual QPixmap iconPixmap() const { return FilesDefs::getPixmapFromQtResourcePath(":/icons/settings/channels.svg") ; } virtual QString pageName() const { return tr("Channels") ; } virtual QString helpText() const { return ""; } diff --git a/retroshare-gui/src/gui/settings/ChatPage.h b/retroshare-gui/src/gui/settings/ChatPage.h index 24ddc570d..6c79f7ed7 100644 --- a/retroshare-gui/src/gui/settings/ChatPage.h +++ b/retroshare-gui/src/gui/settings/ChatPage.h @@ -21,9 +21,10 @@ #ifndef _CHATPAGE_H #define _CHATPAGE_H -#include +#include "retroshare-gui/configpage.h" #include "gui/chat/ChatStyle.h" #include "ui_ChatPage.h" +#include "gui/common/FilesDefs.h" class ChatPage : public ConfigPage { @@ -38,7 +39,7 @@ class ChatPage : public ConfigPage /** Loads the settings for this page */ virtual void load(); - virtual QPixmap iconPixmap() const { return QPixmap(":/icons/settings/chat.svg") ; } + virtual QPixmap iconPixmap() const { return FilesDefs::getPixmapFromQtResourcePath(":/icons/settings/chat.svg") ; } virtual QString pageName() const { return tr("Chats") ; } virtual QString helpText() const { return ""; } diff --git a/retroshare-gui/src/gui/settings/CryptoPage.h b/retroshare-gui/src/gui/settings/CryptoPage.h index 6db7cde4f..abd8bcb6c 100755 --- a/retroshare-gui/src/gui/settings/CryptoPage.h +++ b/retroshare-gui/src/gui/settings/CryptoPage.h @@ -21,8 +21,9 @@ #ifndef _CRYPTOPAGE_H #define _CRYPTOPAGE_H -#include +#include "retroshare-gui/configpage.h" #include "ui_CryptoPage.h" +#include "gui/common/FilesDefs.h" class CryptoPage : public ConfigPage { @@ -36,7 +37,7 @@ class CryptoPage : public ConfigPage /** Loads the settings for this page */ - virtual QPixmap iconPixmap() const { return QPixmap(":/icons/settings/profile.svg") ; } + virtual QPixmap iconPixmap() const { return FilesDefs::getPixmapFromQtResourcePath(":/icons/settings/profile.svg") ; } virtual QString pageName() const { return tr("Node") ; } virtual QString helpText() const { return ""; } diff --git a/retroshare-gui/src/gui/settings/FileAssociationsPage.h b/retroshare-gui/src/gui/settings/FileAssociationsPage.h index 91c9ca573..721c29969 100755 --- a/retroshare-gui/src/gui/settings/FileAssociationsPage.h +++ b/retroshare-gui/src/gui/settings/FileAssociationsPage.h @@ -22,7 +22,8 @@ #ifndef __FileAssociationsPage__ #define __FileAssociationsPage__ -#include +#include "retroshare-gui/configpage.h" +#include "gui/common/FilesDefs.h" class QToolBar; class QAction; @@ -52,7 +53,7 @@ public: virtual ~FileAssociationsPage(); virtual void load(); - virtual QPixmap iconPixmap() const { return QPixmap(":/images/filetype-association.png") ; } + virtual QPixmap iconPixmap() const { return FilesDefs::getPixmapFromQtResourcePath(":/images/filetype-association.png") ; } virtual QString pageName() const { return tr("Associations") ; } protected: diff --git a/retroshare-gui/src/gui/settings/ForumPage.h b/retroshare-gui/src/gui/settings/ForumPage.h index 880f66f04..3827df0e4 100644 --- a/retroshare-gui/src/gui/settings/ForumPage.h +++ b/retroshare-gui/src/gui/settings/ForumPage.h @@ -21,8 +21,9 @@ #ifndef FORUMPAGE_H #define FORUMPAGE_H -#include +#include "retroshare-gui/configpage.h" #include "ui_ForumPage.h" +#include "gui/common/FilesDefs.h" class ForumPage : public ConfigPage { @@ -35,7 +36,7 @@ public: /** Loads the settings for this page */ virtual void load(); - virtual QPixmap iconPixmap() const { return QPixmap(":/icons/settings/forums.svg") ; } + virtual QPixmap iconPixmap() const { return FilesDefs::getPixmapFromQtResourcePath(":/icons/settings/forums.svg") ; } virtual QString pageName() const { return tr("Forums") ; } virtual QString helpText() const { return ""; } diff --git a/retroshare-gui/src/gui/settings/GeneralPage.h b/retroshare-gui/src/gui/settings/GeneralPage.h index b03871bf4..b36471cbe 100755 --- a/retroshare-gui/src/gui/settings/GeneralPage.h +++ b/retroshare-gui/src/gui/settings/GeneralPage.h @@ -22,8 +22,9 @@ #ifndef _GENERALPAGE_H #define _GENERALPAGE_H -#include +#include "retroshare-gui/configpage.h" #include "ui_GeneralPage.h" +#include "gui/common/FilesDefs.h" class GeneralPage : public ConfigPage { @@ -39,7 +40,7 @@ public: /** Loads the settings for this page */ virtual void load(); - virtual QPixmap iconPixmap() const { return QPixmap(":/icons/settings/general.svg") ; } + virtual QPixmap iconPixmap() const { return FilesDefs::getPixmapFromQtResourcePath(":/icons/settings/general.svg") ; } virtual QString pageName() const { return tr("General") ; } virtual QString helpText() const { return ""; } diff --git a/retroshare-gui/src/gui/settings/JsonApiPage.h b/retroshare-gui/src/gui/settings/JsonApiPage.h index 646016662..f516a541d 100644 --- a/retroshare-gui/src/gui/settings/JsonApiPage.h +++ b/retroshare-gui/src/gui/settings/JsonApiPage.h @@ -35,7 +35,7 @@ public: /** Loads the settings for this page */ virtual QPixmap iconPixmap() const - { return QPixmap(":/icons/svg/empty-circle.svg"); } + { return FilesDefs::getPixmapFromQtResourcePath(":/icons/svg/empty-circle.svg"); } virtual QString pageName() const { return tr("JSON API"); } virtual QString helpText() const; diff --git a/retroshare-gui/src/gui/settings/MessagePage.h b/retroshare-gui/src/gui/settings/MessagePage.h index 6dd6f87df..f3a4c12a7 100644 --- a/retroshare-gui/src/gui/settings/MessagePage.h +++ b/retroshare-gui/src/gui/settings/MessagePage.h @@ -23,10 +23,11 @@ #include -#include +#include "retroshare-gui/configpage.h" #include "ui_MessagePage.h" #include "gui/msgs/MessageInterface.h" +#include "gui/common/FilesDefs.h" class MessagePage : public ConfigPage { @@ -39,7 +40,7 @@ public: /** Loads the settings for this page */ virtual void load(); - virtual QPixmap iconPixmap() const { return QPixmap(":/icons/settings/messages.svg") ; } + virtual QPixmap iconPixmap() const { return FilesDefs::getPixmapFromQtResourcePath(":/icons/settings/messages.svg") ; } virtual QString pageName() const { return tr("Mail") ; } virtual QString helpText() const { return ""; } diff --git a/retroshare-gui/src/gui/settings/NotifyPage.h b/retroshare-gui/src/gui/settings/NotifyPage.h index ca6aa83be..f78c188a0 100755 --- a/retroshare-gui/src/gui/settings/NotifyPage.h +++ b/retroshare-gui/src/gui/settings/NotifyPage.h @@ -25,6 +25,7 @@ #include "ui_NotifyPage.h" #include "gui/chat/ChatLobbyUserNotify.h" +#include "gui/common/FilesDefs.h" class UserNotify; class FeedNotify; @@ -78,7 +79,7 @@ public: /** Loads the settings for this page */ virtual void load(); - virtual QPixmap iconPixmap() const { return QPixmap(":/icons/settings/notify.svg") ; } + virtual QPixmap iconPixmap() const { return FilesDefs::getPixmapFromQtResourcePath(":/icons/settings/notify.svg") ; } virtual QString pageName() const { return tr("Notify") ; } virtual QString helpText() const ; diff --git a/retroshare-gui/src/gui/settings/PeoplePage.h b/retroshare-gui/src/gui/settings/PeoplePage.h index 68a7c0415..ec0af7927 100644 --- a/retroshare-gui/src/gui/settings/PeoplePage.h +++ b/retroshare-gui/src/gui/settings/PeoplePage.h @@ -21,8 +21,9 @@ #ifndef PEOPLEPAGE_H #define PEOPLEPAGE_H -#include +#include "retroshare-gui/configpage.h" #include "ui_PeoplePage.h" +#include "gui/common/FilesDefs.h" class PeoplePage : public ConfigPage { @@ -35,7 +36,7 @@ public: /** Loads the settings for this page */ virtual void load(); - virtual QPixmap iconPixmap() const { return QPixmap(":/icons/settings/people.svg") ; } + virtual QPixmap iconPixmap() const { return FilesDefs::getPixmapFromQtResourcePath(":/icons/settings/people.svg") ; } virtual QString pageName() const { return tr("People") ; } virtual QString helpText() const { return ""; } diff --git a/retroshare-gui/src/gui/settings/PluginsPage.h b/retroshare-gui/src/gui/settings/PluginsPage.h index 02c4290a0..00a63070a 100644 --- a/retroshare-gui/src/gui/settings/PluginsPage.h +++ b/retroshare-gui/src/gui/settings/PluginsPage.h @@ -20,8 +20,9 @@ #pragma once -#include +#include "retroshare-gui/configpage.h" #include "ui_PluginsPage.h" +#include "gui/common/FilesDefs.h" namespace settings { @@ -36,7 +37,7 @@ class PluginsPage : public ConfigPage /** Loads the settings for this page */ virtual void load(); - virtual QPixmap iconPixmap() const { return QPixmap(":/icons/settings/plugins.svg") ; } + virtual QPixmap iconPixmap() const { return FilesDefs::getPixmapFromQtResourcePath(":/icons/settings/plugins.svg") ; } virtual QString pageName() const { return tr("Plugins") ; } virtual QString helpText() const ; diff --git a/retroshare-gui/src/gui/settings/PostedPage.h b/retroshare-gui/src/gui/settings/PostedPage.h index ba6515d8c..b3c31c6ba 100644 --- a/retroshare-gui/src/gui/settings/PostedPage.h +++ b/retroshare-gui/src/gui/settings/PostedPage.h @@ -21,7 +21,8 @@ #ifndef POSTEDPAGE_H #define POSTEDPAGE_H -#include +#include "retroshare-gui/configpage.h" +#include "gui/common/FilesDefs.h" namespace Ui { class PostedPage; @@ -38,7 +39,7 @@ public: /** Loads the settings for this page */ virtual void load(); - virtual QPixmap iconPixmap() const { return QPixmap(":/icons/settings/posted.svg") ; } + virtual QPixmap iconPixmap() const { return FilesDefs::getPixmapFromQtResourcePath(":/icons/settings/posted.svg") ; } virtual QString pageName() const { return tr("Boards") ; } virtual QString helpText() const { return ""; } diff --git a/retroshare-gui/src/gui/settings/ServerPage.cpp b/retroshare-gui/src/gui/settings/ServerPage.cpp index 64392aa08..ec9ec5df9 100755 --- a/retroshare-gui/src/gui/settings/ServerPage.cpp +++ b/retroshare-gui/src/gui/settings/ServerPage.cpp @@ -884,19 +884,19 @@ void ServerPage::updateStatus() /******* Network Status Tab *******/ if(net_status.netUpnpOk) - ui.iconlabel_upnp->setPixmap(QPixmap(":/images/ledon1.png")); + ui.iconlabel_upnp->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/images/ledon1.png")); else - ui.iconlabel_upnp->setPixmap(QPixmap(":/images/ledoff1.png")); + ui.iconlabel_upnp->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/images/ledoff1.png")); if (net_status.netLocalOk) - ui.iconlabel_netLimited->setPixmap(QPixmap(":/images/ledon1.png")); + ui.iconlabel_netLimited->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/images/ledon1.png")); else - ui.iconlabel_netLimited->setPixmap(QPixmap(":/images/ledoff1.png")); + ui.iconlabel_netLimited->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/images/ledoff1.png")); if (net_status.netExtAddressOk) - ui.iconlabel_ext->setPixmap(QPixmap(":/images/ledon1.png")); + ui.iconlabel_ext->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/images/ledon1.png")); else - ui.iconlabel_ext->setPixmap(QPixmap(":/images/ledoff1.png")); + ui.iconlabel_ext->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/images/ledoff1.png")); } @@ -1080,7 +1080,7 @@ void ServerPage::loadHiddenNode() ui.textlabel_hiddenMode->show(); ui.iconlabel_hiddenMode->show() ; - ui.iconlabel_hiddenMode->setPixmap(QPixmap(":/images/ledon1.png")); + ui.iconlabel_hiddenMode->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/images/ledon1.png")); // CHANGE OPTIONS ON whileBlocking(ui.discComboBox)->removeItem(3); @@ -1129,9 +1129,9 @@ void ServerPage::loadHiddenNode() for(std::list::const_iterator it(detail.ipAddressList.begin());it!=detail.ipAddressList.end();++it) whileBlocking(ui.ipAddressList)->addItem(QString::fromStdString(*it)); - ui.iconlabel_upnp->setPixmap(QPixmap(":/images/ledoff1.png")); - ui.iconlabel_netLimited->setPixmap(QPixmap(":/images/ledoff1.png")); - ui.iconlabel_ext->setPixmap(QPixmap(":/images/ledoff1.png")); + ui.iconlabel_upnp->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/images/ledoff1.png")); + ui.iconlabel_netLimited->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/images/ledoff1.png")); + ui.iconlabel_ext->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/images/ledoff1.png")); whileBlocking(ui.allowIpDeterminationCB)->setChecked(false); whileBlocking(ui.allowIpDeterminationCB)->setEnabled(false); @@ -1235,19 +1235,19 @@ void ServerPage::updateStatusHiddenNode() /******* Network Status Tab *******/ if(net_status.netUpnpOk) - ui.iconlabel_upnp->setPixmap(QPixmap(":/images/ledon1.png")); + ui.iconlabel_upnp->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/images/ledon1.png")); else - ui.iconlabel_upnp->setPixmap(QPixmap(":/images/ledoff1.png")); + ui.iconlabel_upnp->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/images/ledoff1.png")); if (net_status.netLocalOk) - ui.iconlabel_netLimited->setPixmap(QPixmap(":/images/ledon1.png")); + ui.iconlabel_netLimited->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/images/ledon1.png")); else - ui.iconlabel_netLimited->setPixmap(QPixmap(":/images/ledoff1.png")); + ui.iconlabel_netLimited->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/images/ledoff1.png")); if (net_status.netExtAddressOk) - ui.iconlabel_ext->setPixmap(QPixmap(":/images/ledon1.png")); + ui.iconlabel_ext->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/images/ledon1.png")); else - ui.iconlabel_ext->setPixmap(QPixmap(":/images/ledoff1.png")); + ui.iconlabel_ext->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/images/ledoff1.png")); #endif } @@ -1306,12 +1306,12 @@ void ServerPage::updateOutProxyIndicator() if(socket.waitForConnected(500)) { socket.disconnectFromHost(); - ui.iconlabel_tor_outgoing->setPixmap(QPixmap(ICON_STATUS_OK)) ; + ui.iconlabel_tor_outgoing->setPixmap(FilesDefs::getPixmapFromQtResourcePath(ICON_STATUS_OK)) ; ui.iconlabel_tor_outgoing->setToolTip(tr("Proxy seems to work.")) ; } else { - ui.iconlabel_tor_outgoing->setPixmap(QPixmap(ICON_STATUS_UNKNOWN)) ; + ui.iconlabel_tor_outgoing->setPixmap(FilesDefs::getPixmapFromQtResourcePath(ICON_STATUS_UNKNOWN)) ; ui.iconlabel_tor_outgoing->setToolTip(tr("Tor proxy is not enabled")) ; } @@ -1320,12 +1320,12 @@ void ServerPage::updateOutProxyIndicator() if(socket.waitForConnected(500)) { socket.disconnectFromHost(); - ui.iconlabel_i2p_outgoing->setPixmap(QPixmap(ICON_STATUS_OK)) ; + ui.iconlabel_i2p_outgoing->setPixmap(FilesDefs::getPixmapFromQtResourcePath(ICON_STATUS_OK)) ; ui.iconlabel_i2p_outgoing->setToolTip(tr("Proxy seems to work.")) ; } else { - ui.iconlabel_i2p_outgoing->setPixmap(QPixmap(ICON_STATUS_UNKNOWN)) ; + ui.iconlabel_i2p_outgoing->setPixmap(FilesDefs::getPixmapFromQtResourcePath(ICON_STATUS_UNKNOWN)) ; ui.iconlabel_i2p_outgoing->setToolTip(tr("I2P proxy is not enabled")) ; } @@ -1334,12 +1334,12 @@ void ServerPage::updateOutProxyIndicator() if(true == (mBobAccessible = socket.waitForConnected(500))) { socket.disconnectFromHost(); - ui.iconlabel_i2p_outgoing_2->setPixmap(QPixmap(ICON_STATUS_OK)) ; + ui.iconlabel_i2p_outgoing_2->setPixmap(FilesDefs::getPixmapFromQtResourcePath(ICON_STATUS_OK)) ; ui.iconlabel_i2p_outgoing_2->setToolTip(tr("BOB is running and accessible")) ; } else { - ui.iconlabel_i2p_outgoing_2->setPixmap(QPixmap(ICON_STATUS_UNKNOWN)) ; + ui.iconlabel_i2p_outgoing_2->setPixmap(FilesDefs::getPixmapFromQtResourcePath(ICON_STATUS_UNKNOWN)) ; ui.iconlabel_i2p_outgoing_2->setToolTip(tr("BOB is not accessible! Is it running?")) ; } } @@ -1351,7 +1351,7 @@ void ServerPage::updateInProxyIndicator() if(!mIsHiddenNode) return ; - //ui.iconlabel_tor_incoming->setPixmap(QPixmap(ICON_STATUS_UNKNOWN)) ; + //ui.iconlabel_tor_incoming->setPixmap(FilesDefs::getPixmapFromQtResourcePath(ICON_STATUS_UNKNOWN)) ; //ui.testIncomingTor_PB->setIcon(FilesDefs::getIconFromQtResourcePath(":/loader/circleball-16.gif")) ; QMovie *movie = new QMovie(":/images/loader/circleball-16.gif"); ui.iconlabel_service_incoming->setMovie(movie); @@ -1674,7 +1674,7 @@ void ServerPage::updateStatusBob() case csConnected: case csDoDisconnect: case csWaitForBob: - ui.iconlabel_i2p_bob->setPixmap(QPixmap(ICON_STATUS_WORKING)); + ui.iconlabel_i2p_bob->setPixmap(FilesDefs::getPixmapFromQtResourcePath(ICON_STATUS_WORKING)); ui.iconlabel_i2p_bob->setToolTip(tr("BOB is processing a request")); enableBobElements(false); @@ -1707,7 +1707,7 @@ void ServerPage::updateStatusBob() // get error msg from bob rsAutoProxyMonitor::taskSync(autoProxyType::I2PBOB, autoProxyTask::getErrorInfo, &errorString); - ui.iconlabel_i2p_bob->setPixmap(QPixmap(ICON_STATUS_ERROR)); + ui.iconlabel_i2p_bob->setPixmap(FilesDefs::getPixmapFromQtResourcePath(ICON_STATUS_ERROR)); ui.iconlabel_i2p_bob->setToolTip(tr("BOB is broken\n") + QString::fromStdString(errorString)); enableBobElements(false); @@ -1723,7 +1723,7 @@ void ServerPage::updateStatusBob() case csIdel: switch (bs.ct) { case ctRunSetUp: - ui.iconlabel_i2p_bob->setPixmap(QPixmap(ICON_STATUS_OK)); + ui.iconlabel_i2p_bob->setPixmap(FilesDefs::getPixmapFromQtResourcePath(ICON_STATUS_OK)); ui.iconlabel_i2p_bob->setToolTip(tr("BOB tunnel is running")); enableBobElements(false); @@ -1736,7 +1736,7 @@ void ServerPage::updateStatusBob() break; case ctRunCheck: case ctRunGetKeys: - ui.iconlabel_i2p_bob->setPixmap(QPixmap(ICON_STATUS_WORKING)); + ui.iconlabel_i2p_bob->setPixmap(FilesDefs::getPixmapFromQtResourcePath(ICON_STATUS_WORKING)); ui.iconlabel_i2p_bob->setToolTip(tr("BOB is processing a request")); enableBobElements(false); @@ -1749,7 +1749,7 @@ void ServerPage::updateStatusBob() break; case ctRunShutDown: case ctIdle: - ui.iconlabel_i2p_bob->setPixmap(QPixmap(ICON_STATUS_UNKNOWN)); + ui.iconlabel_i2p_bob->setPixmap(FilesDefs::getPixmapFromQtResourcePath(ICON_STATUS_UNKNOWN)); ui.iconlabel_i2p_bob->setToolTip(tr("BOB tunnel is not running")); enableBobElements(true); @@ -1844,14 +1844,14 @@ void ServerPage::updateInProxyIndicatorResult(bool success) if (success) { std::cerr <<"Connected!" << std::endl; - ui.iconlabel_service_incoming->setPixmap(QPixmap(ICON_STATUS_OK)) ; + ui.iconlabel_service_incoming->setPixmap(FilesDefs::getPixmapFromQtResourcePath(ICON_STATUS_OK)) ; ui.iconlabel_service_incoming->setToolTip(tr("You are reachable through the hidden service.")) ; //ui.testIncomingTor_PB->setIcon(FilesDefs::getIconFromQtResourcePath(ICON_STATUS_OK)) ; } else { std::cerr <<"Failed!" << std::endl; //ui.testIncomingTor_PB->setIcon(FilesDefs::getIconFromQtResourcePath(ICON_STATUS_UNKNOWN)) ; - ui.iconlabel_service_incoming->setPixmap(QPixmap(ICON_STATUS_UNKNOWN)) ; + ui.iconlabel_service_incoming->setPixmap(FilesDefs::getPixmapFromQtResourcePath(ICON_STATUS_UNKNOWN)) ; ui.iconlabel_service_incoming->setToolTip(tr("The proxy is not enabled or broken.\nAre all services up and running fine??\nAlso check your ports!")) ; } // delete movie diff --git a/retroshare-gui/src/gui/settings/ServerPage.h b/retroshare-gui/src/gui/settings/ServerPage.h index 247a72c8c..de4751d5e 100755 --- a/retroshare-gui/src/gui/settings/ServerPage.h +++ b/retroshare-gui/src/gui/settings/ServerPage.h @@ -36,8 +36,9 @@ #include #include -#include -#include +#include "retroshare-gui/configpage.h" +#include "retroshare-gui/RsAutoUpdatePage.h" +#include "gui/common/FilesDefs.h" class QNetworkReply; @@ -55,7 +56,7 @@ public: /** Loads the settings for this page */ virtual void load(); - virtual QPixmap iconPixmap() const { return QPixmap(":/icons/png/network.png") ; } + virtual QPixmap iconPixmap() const { return FilesDefs::getPixmapFromQtResourcePath(":/icons/png/network.png") ; } virtual QString pageName() const { return tr("Network") ; } virtual QString helpText() const { return ""; } diff --git a/retroshare-gui/src/gui/settings/ServicePermissionsPage.h b/retroshare-gui/src/gui/settings/ServicePermissionsPage.h index 5c98aae1e..94c22f9b0 100644 --- a/retroshare-gui/src/gui/settings/ServicePermissionsPage.h +++ b/retroshare-gui/src/gui/settings/ServicePermissionsPage.h @@ -25,6 +25,7 @@ #include #include "ui_ServicePermissionsPage.h" +#include "gui/common/FilesDefs.h" class ServicePermissionsPage: public ConfigPage { @@ -37,7 +38,7 @@ public: /** Loads the settings for this page */ virtual void load() {} - virtual QPixmap iconPixmap() const { return QPixmap(":/icons/settings/permissions.svg") ; } + virtual QPixmap iconPixmap() const { return FilesDefs::getPixmapFromQtResourcePath(":/icons/settings/permissions.svg") ; } virtual QString pageName() const { return tr("Permissions") ; } virtual QString helpText() const ; diff --git a/retroshare-gui/src/gui/settings/SoundPage.h b/retroshare-gui/src/gui/settings/SoundPage.h index a8c2d9acd..d20426d83 100644 --- a/retroshare-gui/src/gui/settings/SoundPage.h +++ b/retroshare-gui/src/gui/settings/SoundPage.h @@ -23,8 +23,9 @@ #include -#include +#include "retroshare-gui/configpage.h" #include "ui_SoundPage.h" +#include "gui/common/FilesDefs.h" class SoundPage : public ConfigPage { @@ -39,7 +40,7 @@ public: /** Loads the settings for this page */ virtual void load(); - virtual QPixmap iconPixmap() const { return QPixmap(":/icons/settings/sound.svg") ; } + virtual QPixmap iconPixmap() const { return FilesDefs::getPixmapFromQtResourcePath(":/icons/settings/sound.svg") ; } virtual QString pageName() const { return tr("Sound") ; } virtual QString helpText() const { return ""; } diff --git a/retroshare-gui/src/gui/settings/TransferPage.h b/retroshare-gui/src/gui/settings/TransferPage.h index 8f4c8f0dd..19ceedfca 100644 --- a/retroshare-gui/src/gui/settings/TransferPage.h +++ b/retroshare-gui/src/gui/settings/TransferPage.h @@ -23,8 +23,9 @@ # include -#include +#include "retroshare-gui/configpage.h" #include "ui_TransferPage.h" +#include "gui/common/FilesDefs.h" class TransferPage: public ConfigPage { @@ -37,7 +38,7 @@ class TransferPage: public ConfigPage /** Loads the settings for this page */ virtual void load() ; - virtual QPixmap iconPixmap() const { return QPixmap(":/icons/settings/filesharing.svg") ; } + virtual QPixmap iconPixmap() const { return FilesDefs::getPixmapFromQtResourcePath(":/icons/settings/filesharing.svg") ; } virtual QString pageName() const { return tr("Files") ; } virtual QString helpText() const { return ""; } diff --git a/retroshare-gui/src/gui/settings/WebuiPage.h b/retroshare-gui/src/gui/settings/WebuiPage.h index ebbf0045c..f38662f5e 100644 --- a/retroshare-gui/src/gui/settings/WebuiPage.h +++ b/retroshare-gui/src/gui/settings/WebuiPage.h @@ -43,7 +43,7 @@ public: /** Loads the settings for this page */ virtual void load(); - virtual QPixmap iconPixmap() const { return QPixmap(":/icons/settings/webinterface.svg") ; } + virtual QPixmap iconPixmap() const { return FilesDefs::getPixmapFromQtResourcePath(":/icons/settings/webinterface.svg") ; } virtual QString pageName() const { return tr("Webinterface") ; } virtual QString helpText() const; diff --git a/retroshare-gui/src/gui/statusbar/ToasterDisable.cpp b/retroshare-gui/src/gui/statusbar/ToasterDisable.cpp index f59c5e29e..273245972 100644 --- a/retroshare-gui/src/gui/statusbar/ToasterDisable.cpp +++ b/retroshare-gui/src/gui/statusbar/ToasterDisable.cpp @@ -23,6 +23,7 @@ #include "ToasterDisable.h" #include "gui/notifyqt.h" +#include "gui/common/FilesDefs.h" #define IMAGE_TOASTERDISABLE ":/images/toasterDisable.png" #define IMAGE_TOASTERENABLE ":/images/toasterEnable.png" @@ -57,7 +58,7 @@ ToasterDisable::ToasterDisable(QWidget *parent) void ToasterDisable::disable(bool isDisable) { - imageButton->setIcon(QPixmap(isDisable ? IMAGE_TOASTERDISABLE : IMAGE_TOASTERENABLE)); + imageButton->setIcon(FilesDefs::getPixmapFromQtResourcePath(isDisable ? IMAGE_TOASTERDISABLE : IMAGE_TOASTERENABLE)); imageButton->setToolTip(isDisable ? tr("All Toasters are disabled") : tr("Toasters are enabled")); imageButton->setChecked(isDisable); } diff --git a/retroshare-gui/src/gui/statusbar/dhtstatus.cpp b/retroshare-gui/src/gui/statusbar/dhtstatus.cpp index 209399157..9d998137f 100644 --- a/retroshare-gui/src/gui/statusbar/dhtstatus.cpp +++ b/retroshare-gui/src/gui/statusbar/dhtstatus.cpp @@ -27,6 +27,7 @@ #include "retroshare/rsconfig.h" #include "retroshare/rspeers.h" +#include "gui/common/FilesDefs.h" #include "util/misc.h" @@ -46,7 +47,7 @@ DHTStatus::DHTStatus(QWidget *parent) hbox->addWidget(statusDHT); dhtstatusLabel = new QLabel( this ); - dhtstatusLabel->setPixmap(QPixmap(":/icons/bullet_grey_128.png")); + dhtstatusLabel->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/icons/bullet_grey_128.png")); hbox->addWidget(dhtstatusLabel); spaceLabel = new QLabel( "|", this ); @@ -56,7 +57,7 @@ DHTStatus::DHTStatus(QWidget *parent) dhtnetworkLabel = new QLabel( this ); dhtnetworkLabel->setVisible(false); int S = QFontMetricsF(dhtnetworkLabel->font()).height(); - dhtnetworkLabel->setPixmap(QPixmap(":/images/dht32.png").scaledToHeight(S,Qt::SmoothTransformation)); + dhtnetworkLabel->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/images/dht32.png").scaledToHeight(S,Qt::SmoothTransformation)); hbox->addWidget(dhtnetworkLabel); dhtnetworksizeLabel = new QLabel( "0 (0) ",this ); @@ -84,7 +85,7 @@ void DHTStatus::getDHTStatus() if (!(config.DHTActive)) { // GRAY. - dhtstatusLabel->setPixmap(QPixmap(":/icons/bullet_grey_128.png").scaledToHeight(S,Qt::SmoothTransformation)); + dhtstatusLabel->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/icons/bullet_grey_128.png").scaledToHeight(S,Qt::SmoothTransformation)); dhtstatusLabel->setToolTip( text + tr("DHT Off")); spaceLabel->setVisible(false); @@ -102,7 +103,7 @@ void DHTStatus::getDHTStatus() // YELLOW or GREEN. if (config.netDhtRsNetSize < MIN_RS_NET_SIZE) { - dhtstatusLabel->setPixmap(QPixmap(":/icons/bullet_yellow_128.png").scaledToHeight(S,Qt::SmoothTransformation)); + dhtstatusLabel->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/icons/bullet_yellow_128.png").scaledToHeight(S,Qt::SmoothTransformation)); dhtstatusLabel->setToolTip( text + tr("DHT Searching for RetroShare Peers")); spaceLabel->setVisible(true); @@ -114,7 +115,7 @@ void DHTStatus::getDHTStatus() } else { - dhtstatusLabel->setPixmap(QPixmap(":/icons/bullet_green_128.png").scaledToHeight(S,Qt::SmoothTransformation)); + dhtstatusLabel->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/icons/bullet_green_128.png").scaledToHeight(S,Qt::SmoothTransformation)); dhtstatusLabel->setToolTip( text + tr("DHT Good")); spaceLabel->setVisible(true); @@ -128,7 +129,7 @@ void DHTStatus::getDHTStatus() else { // RED - some issue. - dhtstatusLabel->setPixmap(QPixmap(":/icons/bullet_red_128.png").scaledToHeight(S,Qt::SmoothTransformation)); + dhtstatusLabel->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/icons/bullet_red_128.png").scaledToHeight(S,Qt::SmoothTransformation)); dhtstatusLabel->setToolTip( text + tr("No peer found in DHT")); spaceLabel->setVisible(false); diff --git a/retroshare-gui/src/gui/statusbar/discstatus.cpp b/retroshare-gui/src/gui/statusbar/discstatus.cpp index 71f59d041..64ac7813e 100644 --- a/retroshare-gui/src/gui/statusbar/discstatus.cpp +++ b/retroshare-gui/src/gui/statusbar/discstatus.cpp @@ -23,6 +23,7 @@ #include "discstatus.h" #include "gui/settings/rsharesettings.h" +#include "gui/common/FilesDefs.h" #include @@ -36,7 +37,7 @@ DiscStatus::DiscStatus(QWidget *parent) hbox->setSpacing(6); QLabel *iconLabel = new QLabel(this); - iconLabel->setPixmap(QPixmap(":/images/uploads.png")); + iconLabel->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/images/uploads.png")); iconLabel->setToolTip(tr("Waiting outgoing discovery operations")); hbox->addWidget(iconLabel); @@ -45,7 +46,7 @@ DiscStatus::DiscStatus(QWidget *parent) hbox->addWidget(sendLabel); iconLabel = new QLabel(this); - iconLabel->setPixmap(QPixmap(":/images/download.png")); + iconLabel->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/images/download.png")); iconLabel->setToolTip(tr("Waiting incoming discovery operations")); hbox->addWidget(iconLabel); diff --git a/retroshare-gui/src/gui/statusbar/hashingstatus.cpp b/retroshare-gui/src/gui/statusbar/hashingstatus.cpp index 563c8385a..6d85935f1 100644 --- a/retroshare-gui/src/gui/statusbar/hashingstatus.cpp +++ b/retroshare-gui/src/gui/statusbar/hashingstatus.cpp @@ -27,6 +27,7 @@ #include "hashingstatus.h" #include "gui/common/ElidedLabel.h" #include "gui/notifyqt.h" +#include "gui/common/FilesDefs.h" HashingStatus::HashingStatus(QWidget *parent) : QWidget(parent) @@ -124,7 +125,7 @@ void HashingStatus::mousePressEvent(QMouseEvent *) if(rsFiles->hashingProcessPaused()) { movie->stop() ; - hashloader->setPixmap(QPixmap(":/images/resume.png")) ; + hashloader->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/images/resume.png")) ; mLastText = statusHashing->text(); statusHashing->setText(QObject::tr("[Hashing is paused]")); diff --git a/retroshare-gui/src/gui/statusbar/natstatus.cpp b/retroshare-gui/src/gui/statusbar/natstatus.cpp index 9539defaa..5911bdee6 100644 --- a/retroshare-gui/src/gui/statusbar/natstatus.cpp +++ b/retroshare-gui/src/gui/statusbar/natstatus.cpp @@ -25,6 +25,7 @@ #include "retroshare/rsiface.h" #include "retroshare/rsconfig.h" +#include "gui/common/FilesDefs.h" NATStatus::NATStatus(QWidget *parent) : QWidget(parent) @@ -38,7 +39,7 @@ NATStatus::NATStatus(QWidget *parent) hbox->addWidget(statusNAT); iconLabel = new QLabel(this); - iconLabel->setPixmap(QPixmap(":/images/grayled.png")); + iconLabel->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/images/grayled.png")); // iconLabel doesn't change over time, so we didn't need a minimum size hbox->addWidget(iconLabel); @@ -62,14 +63,14 @@ void NATStatus::getNATStatus() default: case RSNET_NETSTATE_BAD_UNKNOWN: { - iconLabel->setPixmap(QPixmap(":/icons/bullet_yellow_128.png").scaledToHeight(S,Qt::SmoothTransformation)) ; + iconLabel->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/icons/bullet_yellow_128.png").scaledToHeight(S,Qt::SmoothTransformation)) ; iconLabel->setToolTip( text + tr("Network Status Unknown")) ; } break ; case RSNET_NETSTATE_BAD_OFFLINE: { - iconLabel->setPixmap(QPixmap(":/icons/bullet_grey_129.png").scaledToHeight(S,Qt::SmoothTransformation)) ; + iconLabel->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/icons/bullet_grey_129.png").scaledToHeight(S,Qt::SmoothTransformation)) ; iconLabel->setToolTip( text + tr("Offline")) ; } break ; @@ -77,14 +78,14 @@ void NATStatus::getNATStatus() // BAD. (RED) case RSNET_NETSTATE_BAD_NATSYM: { - iconLabel->setPixmap(QPixmap(":/icons/bullet_red_128.png").scaledToHeight(S,Qt::SmoothTransformation)) ; + iconLabel->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/icons/bullet_red_128.png").scaledToHeight(S,Qt::SmoothTransformation)) ; iconLabel->setToolTip( text + tr("Nasty Firewall")) ; } break ; case RSNET_NETSTATE_BAD_NODHT_NAT: { - iconLabel->setPixmap(QPixmap(":/icons/bullet_red_128.png").scaledToHeight(S,Qt::SmoothTransformation)) ; + iconLabel->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/icons/bullet_red_128.png").scaledToHeight(S,Qt::SmoothTransformation)) ; iconLabel->setToolTip( text + tr("DHT Disabled and Firewalled")) ; } break ; @@ -92,21 +93,21 @@ void NATStatus::getNATStatus() // CAUTION. (ORANGE) case RSNET_NETSTATE_WARNING_RESTART: { - iconLabel->setPixmap(QPixmap(":/icons/bullet_yellow_128.png").scaledToHeight(S,Qt::SmoothTransformation)) ; + iconLabel->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/icons/bullet_yellow_128.png").scaledToHeight(S,Qt::SmoothTransformation)) ; iconLabel->setToolTip( text + tr("Network Restarting")) ; } break ; case RSNET_NETSTATE_WARNING_NATTED: { - iconLabel->setPixmap(QPixmap(":/icons/bullet_yellow_128.png").scaledToHeight(S,Qt::SmoothTransformation)) ; + iconLabel->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/icons/bullet_yellow_128.png").scaledToHeight(S,Qt::SmoothTransformation)) ; iconLabel->setToolTip( text + tr("Behind Firewall")) ; } break ; case RSNET_NETSTATE_WARNING_NODHT: { - iconLabel->setPixmap(QPixmap(":/icons/bullet_yellow_128.png").scaledToHeight(S,Qt::SmoothTransformation)) ; + iconLabel->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/icons/bullet_yellow_128.png").scaledToHeight(S,Qt::SmoothTransformation)) ; iconLabel->setToolTip( text + tr("DHT Disabled")) ; } break ; @@ -114,14 +115,14 @@ void NATStatus::getNATStatus() // GOOD (GREEN) case RSNET_NETSTATE_GOOD: { - iconLabel->setPixmap(QPixmap(":/icons/bullet_green_128.png").scaledToHeight(S,Qt::SmoothTransformation)) ; + iconLabel->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/icons/bullet_green_128.png").scaledToHeight(S,Qt::SmoothTransformation)) ; iconLabel->setToolTip( text + tr("RetroShare Server")) ; } break ; case RSNET_NETSTATE_ADV_FORWARD: { - iconLabel->setPixmap(QPixmap(":/icons/bullet_green_128.png").scaledToHeight(S,Qt::SmoothTransformation)) ; + iconLabel->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/icons/bullet_green_128.png").scaledToHeight(S,Qt::SmoothTransformation)) ; iconLabel->setToolTip( text + tr("Forwarded Port")) ; } break ; diff --git a/retroshare-gui/src/gui/statusbar/peerstatus.cpp b/retroshare-gui/src/gui/statusbar/peerstatus.cpp index 322109b05..4f1c9811f 100644 --- a/retroshare-gui/src/gui/statusbar/peerstatus.cpp +++ b/retroshare-gui/src/gui/statusbar/peerstatus.cpp @@ -22,6 +22,7 @@ #include #include "peerstatus.h" +#include "gui/common/FilesDefs.h" PeerStatus::PeerStatus(QWidget *parent) : QWidget(parent) @@ -33,7 +34,7 @@ PeerStatus::PeerStatus(QWidget *parent) iconLabel = new QLabel( this ); int S = QFontMetricsF(iconLabel->font()).height(); - iconLabel->setPixmap(QPixmap(":/icons/avatar_grey_128.png").scaledToHeight(S,Qt::SmoothTransformation)); + iconLabel->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/icons/avatar_grey_128.png").scaledToHeight(S,Qt::SmoothTransformation)); hbox->addWidget(iconLabel); statusPeers = new QLabel( tr("Friends: 0/0"), this ); @@ -59,7 +60,7 @@ void PeerStatus::getPeerStatus(unsigned int nFriendCount, unsigned int nOnlineCo int S = QFontMetricsF(iconLabel->font()).height(); if (nOnlineCount > 0) - iconLabel->setPixmap(QPixmap(":/icons/avatar_128.png").scaledToHeight(S,Qt::SmoothTransformation)); + iconLabel->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/icons/avatar_128.png").scaledToHeight(S,Qt::SmoothTransformation)); else - iconLabel->setPixmap(QPixmap(":/icons/avatar_grey_128.png").scaledToHeight(S,Qt::SmoothTransformation)); + iconLabel->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/icons/avatar_grey_128.png").scaledToHeight(S,Qt::SmoothTransformation)); } diff --git a/retroshare-gui/src/gui/statusbar/ratesstatus.cpp b/retroshare-gui/src/gui/statusbar/ratesstatus.cpp index edec6608e..8e4f606f7 100644 --- a/retroshare-gui/src/gui/statusbar/ratesstatus.cpp +++ b/retroshare-gui/src/gui/statusbar/ratesstatus.cpp @@ -24,6 +24,7 @@ #include "ratesstatus.h" #include #include "util/misc.h" +#include "gui/common/FilesDefs.h" #include @@ -35,7 +36,7 @@ RatesStatus::RatesStatus(QWidget *parent) hbox->setSpacing(6); iconLabel = new QLabel( this ); - iconLabel->setPixmap(QPixmap(":/images/up0down0.png")); + iconLabel->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/images/up0down0.png")); // iconLabel doesn't change over time, so we didn't need a minimum size hbox->addWidget(iconLabel); @@ -64,7 +65,7 @@ void RatesStatus::getRatesStatus(float downKb, uint64_t down, float upKb, uint64 QString up = (upKb > 0)?"1":"0"; QString dw = (downKb > 0)?"1":"0"; - iconLabel->setPixmap(QPixmap(QString(":/images/") + iconLabel->setPixmap(FilesDefs::getPixmapFromQtResourcePath(QString(":/images/") + "up" + up + "down" + dw + ".png")); diff --git a/retroshare-gui/src/gui/statusbar/torstatus.cpp b/retroshare-gui/src/gui/statusbar/torstatus.cpp index f41ea30d3..a69cb3beb 100644 --- a/retroshare-gui/src/gui/statusbar/torstatus.cpp +++ b/retroshare-gui/src/gui/statusbar/torstatus.cpp @@ -31,6 +31,7 @@ #include "TorControl/TorManager.h" #include "TorControl/TorControl.h" +#include "gui/common/FilesDefs.h" #include @@ -46,7 +47,7 @@ TorStatus::TorStatus(QWidget *parent) hbox->addWidget(statusTor); torstatusLabel = new QLabel( this ); - torstatusLabel->setPixmap(QPixmap(":/icons/no-tor.png")); + torstatusLabel->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/icons/no-tor.png")); hbox->addWidget(torstatusLabel); _compactMode = false; @@ -117,24 +118,24 @@ void TorStatus::getTorStatus() if(torstatus == Tor::TorControl::TorOffline || !online || !tor_control_ok) { // RED - some issue. - torstatusLabel->setPixmap(QPixmap(":/icons/tor-stopping.png").scaledToHeight(1.5*S,Qt::SmoothTransformation)); + torstatusLabel->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/icons/tor-stopping.png").scaledToHeight(1.5*S,Qt::SmoothTransformation)); torstatusLabel->setToolTip( text + tr("Tor is currently offline")); } else if(torstatus == Tor::TorControl::TorReady && online && tor_control_ok) { - torstatusLabel->setPixmap(QPixmap(":/icons/tor-on.png").scaledToHeight(1.5*S,Qt::SmoothTransformation)); + torstatusLabel->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/icons/tor-on.png").scaledToHeight(1.5*S,Qt::SmoothTransformation)); torstatusLabel->setToolTip( text + tr("Tor is OK")); } else // torstatus == Tor::TorControl::TorUnknown { // GRAY. - torstatusLabel->setPixmap(QPixmap(":/icons/no-tor.png").scaledToHeight(1.5*S,Qt::SmoothTransformation)); + torstatusLabel->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/icons/no-tor.png").scaledToHeight(1.5*S,Qt::SmoothTransformation)); torstatusLabel->setToolTip( text + tr("No tor configuration")); } } else { - torstatusLabel->setPixmap(QPixmap(":/icons/tor-stopping.png").scaledToHeight(S,Qt::SmoothTransformation)); + torstatusLabel->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/icons/tor-stopping.png").scaledToHeight(S,Qt::SmoothTransformation)); torstatusLabel->setToolTip( text + tr("Tor is currently offline")); } } diff --git a/retroshare-gui/src/gui/style/StyleDialog.cpp b/retroshare-gui/src/gui/style/StyleDialog.cpp index 31e33c730..7d7d5c1b7 100644 --- a/retroshare-gui/src/gui/style/StyleDialog.cpp +++ b/retroshare-gui/src/gui/style/StyleDialog.cpp @@ -24,6 +24,7 @@ #include "StyleDialog.h" #include "gui/style/RSStyle.h" +#include "gui/common/FilesDefs.h" /** Default constructor */ StyleDialog::StyleDialog(RSStyle &style, QWidget *parent) @@ -32,7 +33,7 @@ StyleDialog::StyleDialog(RSStyle &style, QWidget *parent) /* Invoke Qt Designer generated QObject setup routine */ ui.setupUi(this); - ui.headerFrame->setHeaderImage(QPixmap(":/icons/collections.png")); + ui.headerFrame->setHeaderImage(FilesDefs::getPixmapFromQtResourcePath(":/icons/collections.png")); ui.headerFrame->setHeaderText(tr("Define Style")); /* Load window postion */ diff --git a/retroshare-gui/src/main.cpp b/retroshare-gui/src/main.cpp index 4c427d289..b550749b1 100644 --- a/retroshare-gui/src/main.cpp +++ b/retroshare-gui/src/main.cpp @@ -441,7 +441,7 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO); } } - QSplashScreen splashScreen(QPixmap(":/images/logo/logo_splash.png")/* , Qt::WindowStaysOnTopHint*/); + QSplashScreen splashScreen(FilesDefs::getPixmapFromQtResourcePath(":/images/logo/logo_splash.png")/* , Qt::WindowStaysOnTopHint*/); splashScreen.show(); splashScreen.showMessage(rshare.translate("SplashScreen", "Load configuration"), Qt::AlignHCenter | Qt::AlignBottom); diff --git a/retroshare-gui/src/util/misc.cpp b/retroshare-gui/src/util/misc.cpp index 9539ebd5a..08ff3eaa3 100644 --- a/retroshare-gui/src/util/misc.cpp +++ b/retroshare-gui/src/util/misc.cpp @@ -29,6 +29,7 @@ #include "misc.h" #include "util/rsdebug.h" +#include "gui/common/FilesDefs.h" // return best userfriendly storage unit (B, KiB, MiB, GiB, TiB) // use Binary prefix standards from IEC 60027-2 @@ -307,8 +308,8 @@ QPixmap misc::getOpenThumbnailedPicture(QWidget *parent, const QString &caption, if (!getOpenFileName(parent, RshareSettings::LASTDIR_IMAGES, caption, tr("Pictures (*.png *.jpeg *.xpm *.jpg *.tiff *.gif)"), fileName)) return QPixmap(); - return QPixmap(fileName).scaledToHeight(height, Qt::SmoothTransformation).copy( 0, 0, width, height); - //return QPixmap(fileName).scaledToHeight(width, height, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation); + return FilesDefs::getPixmapFromQtResourcePath(fileName).scaledToHeight(height, Qt::SmoothTransformation).copy( 0, 0, width, height); + //return FilesDefs::getPixmapFromQtResourcePath(fileName).scaledToHeight(width, height, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation); } bool misc::getOpenFileName(QWidget *parent, RshareSettings::enumLastDir type From 56f3df6737dfc385ffaaf14463b96241c3db94cf Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 26 Sep 2020 17:47:09 +0200 Subject: [PATCH 19/24] removed "0 files" mention --- retroshare-gui/src/gui/common/RSTreeView.cpp | 3 +++ .../gxschannels/GxsChannelPostsWidgetWithModel.cpp | 11 ++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/retroshare-gui/src/gui/common/RSTreeView.cpp b/retroshare-gui/src/gui/common/RSTreeView.cpp index d54987c3e..72b191fe2 100644 --- a/retroshare-gui/src/gui/common/RSTreeView.cpp +++ b/retroshare-gui/src/gui/common/RSTreeView.cpp @@ -30,7 +30,10 @@ RSTreeView::RSTreeView(QWidget *parent) : QTreeView(parent) void RSTreeView::wheelEvent(QWheelEvent *e) { if(e->modifiers() == Qt::ControlModifier) + { emit zoomRequested(e->delta() > 0); + return; + } else QTreeView::wheelEvent(e); } diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp index 91ab7ab0a..9e04c5af0 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp @@ -130,6 +130,7 @@ void ChannelPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem & uint32_t flags = (mUseGrid)?(ChannelPostThumbnailView::FLAG_SHOW_TEXT | ChannelPostThumbnailView::FLAG_SCALE_FONT):0; ChannelPostThumbnailView w(post,flags); + w.setBackgroundRole(QPalette::AlternateBase); w.setAspectRatio(mAspectRatio); w.updateGeometry(); w.adjustSize(); @@ -198,8 +199,11 @@ void ChannelPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem & painter->drawText(QPoint(p.x()+0.5*font_height,y),QDateTime::fromSecsSinceEpoch(post.mMeta.mPublishTs).toString(Qt::DefaultLocaleShortDate)); y += font_height; - painter->drawText(QPoint(p.x()+0.5*font_height,y),QString::number(post.mCount)+ " " +((post.mCount>1)?tr("files"):tr("file")) + " (" + QString::number(post.mSize) + " " + tr("bytes") + ")" ); - y += font_height; + if(post.mCount > 0) + { + painter->drawText(QPoint(p.x()+0.5*font_height,y),QString::number(post.mCount)+ " " +((post.mCount>1)?tr("files"):tr("file")) + " (" + QString::number(post.mSize) + " " + tr("bytes") + ")" ); + y += font_height; + } painter->restore(); } @@ -285,7 +289,7 @@ void ChannelPostFilesDelegate::paint(QPainter * painter, const QStyleOptionViewI w.setFixedHeight(option.rect.height()); QPixmap pixmap(w.size()); - pixmap.fill(QRgb(0x00ffffff)); // choose a fully transparent background + pixmap.fill(QRgb(0x00ffffff)); // choose a fully transparent background w.render(&pixmap,QPoint(),QRegion(),QWidget::DrawChildren );// draw the widgets, not the background painter->drawPixmap(option.rect.topLeft(),pixmap); @@ -335,6 +339,7 @@ GxsChannelPostsWidgetWithModel::GxsChannelPostsWidgetWithModel(const RsGxsGroupI ui->showUnread_TB->setToolTip(tr("Show unread posts only")); connect(ui->showUnread_TB,SIGNAL(toggled(bool)),this,SLOT(switchOnlyUnread(bool))); + ui->postsTree->setAlternatingRowColors(true); ui->postsTree->setModel(mChannelPostsModel = new RsGxsChannelPostsModel()); ui->postsTree->setItemDelegate(mChannelPostsDelegate = new ChannelPostDelegate()); ui->postsTree->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); // prevents bug on w10, since row size depends on widget width From e389c01571ba0280f6e045f7d19d95436b9b579f Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 26 Sep 2020 18:50:51 +0200 Subject: [PATCH 20/24] fixed alternating row colors, and removed explicit background color --- .../GxsChannelPostsWidgetWithModel.cpp | 228 ++---------------- .../GxsChannelPostsWidgetWithModel.h | 3 - 2 files changed, 22 insertions(+), 209 deletions(-) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp index 9e04c5af0..5d7aa8762 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp @@ -121,7 +121,11 @@ void ChannelPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem & RsGxsChannelPost post = index.data(Qt::UserRole).value() ; - painter->fillRect( option.rect, option.backgroundBrush); + if(index.row() & 0x01) + painter->fillRect( option.rect, option.palette.alternateBase().color()); + else + painter->fillRect( option.rect, option.palette.base().color()); + painter->restore(); if(mUseGrid || index.column()==0) @@ -140,7 +144,14 @@ void ChannelPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem & if((option.state & QStyle::State_Selected) && post.mMeta.mPublishTs > 0) // check if post is selected and is not empty (end of last row) pixmap.fill(SelectedColor); // I dont know how to grab the backgroud color for selected objects automatically. else - pixmap.fill(QRgb(0x00ffffff)); // choose a fully transparent background + { + // we need to do the alternate color manually + + if(index.row() & 0x01) + pixmap.fill(option.palette.alternateBase().color()); + else + pixmap.fill(option.palette.base().color()); + } w.render(&pixmap,QPoint(),QRegion(),QWidget::DrawChildren );// draw the widgets, not the background @@ -289,8 +300,14 @@ void ChannelPostFilesDelegate::paint(QPainter * painter, const QStyleOptionViewI w.setFixedHeight(option.rect.height()); QPixmap pixmap(w.size()); - pixmap.fill(QRgb(0x00ffffff)); // choose a fully transparent background - w.render(&pixmap,QPoint(),QRegion(),QWidget::DrawChildren );// draw the widgets, not the background + + // apparently we need to do the alternate colors manually + if(index.row() & 0x01) + pixmap.fill(option.palette.alternateBase().color()); + else + pixmap.fill(option.palette.base().color()); + + w.render(&pixmap,QPoint(),QRegion(),QWidget::DrawChildren );// draw the widgets, not the background painter->drawPixmap(option.rect.topLeft(),pixmap); } @@ -356,6 +373,7 @@ GxsChannelPostsWidgetWithModel::GxsChannelPostsWidgetWithModel(const RsGxsGroupI ui->channelPostFiles_TV->setPlaceholderText(tr("No files in this post, or no post selected")); ui->channelPostFiles_TV->setSortingEnabled(true); ui->channelPostFiles_TV->sortByColumn(0, Qt::AscendingOrder); + ui->channelPostFiles_TV->setAlternatingRowColors(true); ui->channelFiles_TV->setModel(mChannelFilesModel = new RsGxsChannelPostFilesModel()); ui->channelFiles_TV->setItemDelegate(mFilesDelegate = new ChannelPostFilesDelegate()); @@ -899,15 +917,7 @@ void GxsChannelPostsWidgetWithModel::processSettings(bool load) Settings->beginGroup(QString("ChannelPostsWidget")); if (load) { -#ifdef TO_REMOVE - // load settings - /* Filter */ - //ui->filterLineEdit->setCurrentFilter(Settings->value("filter", FILTER_TITLE).toInt()); - - /* View mode */ - //setViewMode(Settings->value("viewMode", VIEW_MODE_FEEDS).toInt()); -#endif // state of files tree channelpostfilesheader->restoreState(Settings->value("PostFilesTree").toByteArray()); channelfilesheader->restoreState(Settings->value("FilesTree").toByteArray()); @@ -915,15 +925,6 @@ void GxsChannelPostsWidgetWithModel::processSettings(bool load) // state of splitter ui->splitter->restoreState(Settings->value("SplitterChannelPosts").toByteArray()); } else { -#ifdef TO_REMOVE - // save settings - - /* Filter */ - //Settings->setValue("filter", ui->filterLineEdit->currentFilter()); - - /* View mode */ - //Settings->setValue("viewMode", viewMode()); -#endif // state of files tree Settings->setValue("PostFilesTree", channelpostfilesheader->saveState()); Settings->setValue("FilesTree", channelfilesheader->saveState()); @@ -1111,47 +1112,6 @@ void GxsChannelPostsWidgetWithModel::insertChannelDetails(const RsGxsChannelGrou showPostDetails(); } -#ifdef TODO -int GxsChannelPostsWidgetWithModel::viewMode() -{ - if (ui->feedToolButton->isChecked()) { - return VIEW_MODE_FEEDS; - } else if (ui->fileToolButton->isChecked()) { - return VIEW_MODE_FILES; - } - - /* Default */ - return VIEW_MODE_FEEDS; -} -#endif - -void GxsChannelPostsWidgetWithModel::setViewMode(int viewMode) -{ -#ifdef TODO - switch (viewMode) { - case VIEW_MODE_FEEDS: - ui->feedWidget->show(); - ui->fileWidget->hide(); - - ui->feedToolButton->setChecked(true); - ui->fileToolButton->setChecked(false); - - break; - case VIEW_MODE_FILES: - ui->feedWidget->hide(); - ui->fileWidget->show(); - - ui->feedToolButton->setChecked(false); - ui->fileToolButton->setChecked(true); - - break; - default: - setViewMode(VIEW_MODE_FEEDS); - return; - } -#endif -} - void GxsChannelPostsWidgetWithModel::switchOnlyUnread(bool) { filterChanged(ui->filterLineEdit->text()); @@ -1165,150 +1125,6 @@ void GxsChannelPostsWidgetWithModel::filterChanged(QString s) mChannelFilesModel->setFilter(ql,count); } -#ifdef TODO -/*static*/ bool GxsChannelPostsWidgetWithModel::filterItem(FeedItem *feedItem, const QString &text, int filter) -{ - GxsChannelPostItem *item = dynamic_cast(feedItem); - if (!item) { - return true; - } - - bool bVisible = text.isEmpty(); - - if (!bVisible) - { - switch(filter) - { - case FILTER_TITLE: - bVisible = item->getTitleLabel().contains(text,Qt::CaseInsensitive); - break; - case FILTER_MSG: - bVisible = item->getMsgLabel().contains(text,Qt::CaseInsensitive); - break; - case FILTER_FILE_NAME: - { - std::list fileItems = item->getFileItems(); - std::list::iterator lit; - for(lit = fileItems.begin(); lit != fileItems.end(); ++lit) - { - SubFileItem *fi = *lit; - QString fileName = QString::fromUtf8(fi->FileName().c_str()); - bVisible = (bVisible || fileName.contains(text,Qt::CaseInsensitive)); - } - break; - } - default: - bVisible = true; - break; - } - } - - return bVisible; -} - -void GxsChannelPostsWidget::createPostItemFromMetaData(const RsGxsMsgMetaData& meta,bool related) -{ - GxsChannelPostItem *item = NULL; - RsGxsChannelPost post; - - if(!meta.mOrigMsgId.isNull()) - { - FeedItem *feedItem = ui->feedWidget->findFeedItem(GxsChannelPostItem::computeIdentifier(meta.mOrigMsgId)) ; - item = dynamic_cast(feedItem); - - if(item) - { - post = feedItem->post(); - ui->feedWidget->removeFeedItem(item) ; - - post.mOlderVersions.insert(post.mMeta.mMsgId); - - GxsChannelPostItem *item = new GxsChannelPostItem(this, 0, post, true, false,post.mOlderVersions); - ui->feedWidget->addFeedItem(item, ROLE_PUBLISH, QDateTime::fromTime_t(post.mMeta.mPublishTs)); - - return ; - } - } - - if (related) - { - FeedItem *feedItem = ui->feedWidget->findFeedItem(GxsChannelPostItem::computeIdentifier(meta.mMsgId)) ; - item = dynamic_cast(feedItem); - } - if (item) - { - item->setPost(post); - ui->feedWidget->setSort(item, ROLE_PUBLISH, QDateTime::fromTime_t(meta.mPublishTs)); - } - else - { - GxsChannelPostItem *item = new GxsChannelPostItem(this, 0, meta.mGroupId,meta.mMsgId, true, true); - ui->feedWidget->addFeedItem(item, ROLE_PUBLISH, QDateTime::fromTime_t(post.mMeta.mPublishTs)); - } -#ifdef TODO - ui->fileWidget->addFiles(post, related); -#endif -} - -void GxsChannelPostsWidget::createPostItem(const RsGxsChannelPost& post, bool related) -{ - GxsChannelPostItem *item = NULL; - - const RsMsgMetaData& meta(post.mMeta); - - if(!meta.mOrigMsgId.isNull()) - { - FeedItem *feedItem = ui->feedWidget->findFeedItem(GxsChannelPostItem::computeIdentifier(meta.mOrigMsgId)) ; - item = dynamic_cast(feedItem); - - if(item) - { - std::set older_versions(item->olderVersions()); // we make a copy because the item will be deleted - ui->feedWidget->removeFeedItem(item) ; - - older_versions.insert(meta.mMsgId); - - GxsChannelPostItem *item = new GxsChannelPostItem(this, 0, mGroup.mMeta,meta.mMsgId, true, false,older_versions); - ui->feedWidget->addFeedItem(item, ROLE_PUBLISH, QDateTime::fromTime_t(meta.mPublishTs)); - - return ; - } - } - - if (related) - { - FeedItem *feedItem = ui->feedWidget->findFeedItem(GxsChannelPostItem::computeIdentifier(meta.mMsgId)) ; - item = dynamic_cast(feedItem); - } - if (item) - { - item->setPost(post); - ui->feedWidget->setSort(item, ROLE_PUBLISH, QDateTime::fromTime_t(meta.mPublishTs)); - } - else - { - GxsChannelPostItem *item = new GxsChannelPostItem(this, 0, mGroup.mMeta,meta.mMsgId, true, true); - ui->feedWidget->addFeedItem(item, ROLE_PUBLISH, QDateTime::fromTime_t(meta.mPublishTs)); - } - - ui->fileWidget->addFiles(post, related); -} - -void GxsChannelPostsWidget::fillThreadCreatePost(const QVariant &post, bool related, int current, int count) -{ - /* show fill progress */ - if (count) { - ui->progressBar->setValue(current * ui->progressBar->maximum() / count); - } - - if (!post.canConvert()) { - return; - } - - createPostItem(post.value(), related); -} -#endif - void GxsChannelPostsWidgetWithModel::blank() { ui->postButton->setEnabled(false); diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h index daf2aedfb..36e3d7f5e 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h @@ -147,7 +147,6 @@ private slots: void toggleAutoDownload(); void subscribeGroup(bool subscribe); void filterChanged(QString); - void setViewMode(int viewMode); void settingsChanged(); void handlePostsTreeSizeChange(QSize s, bool force=false); void postChannelPostLoad(); @@ -172,8 +171,6 @@ private: void setAutoDownload(bool autoDl); static bool filterItem(FeedItem *feedItem, const QString &text, int filter); - int viewMode(); - void insertChannelDetails(const RsGxsChannelGroup &group); void handleEvent_main_thread(std::shared_ptr event); From 1dddff9e5b93d105f4dce0940cfc8f9c933554fb Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 27 Sep 2020 20:08:36 +0200 Subject: [PATCH 21/24] added back links to posts in channel feeditems --- .../src/gui/feeds/GxsChannelPostItem.cpp | 44 +++++++-------- .../src/gui/feeds/GxsChannelPostItem.h | 2 +- .../src/gui/feeds/GxsChannelPostItem.ui | 56 ++++++------------- 3 files changed, 41 insertions(+), 61 deletions(-) diff --git a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp index aa35fc0cc..560cbfa10 100644 --- a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp +++ b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp @@ -156,7 +156,7 @@ void GxsChannelPostItem::setup() // memory. ui->logoLabel->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/images/thumb-default-video.png")); - ui->warn_image_label->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/images/status_unknown.png")); + //ui->warn_image_label->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/images/status_unknown.png")); ui->readButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/message-state-unread.png")); ui->voteUpButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/vote_up.png")); ui->voteDownButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/vote_down.png")); @@ -211,12 +211,12 @@ void GxsChannelPostItem::setup() ui->downloadButton->hide(); ui->playButton->hide(); - ui->warn_image_label->hide(); - ui->warning_label->hide(); + //ui->warn_image_label->hide(); + //ui->warning_label->hide(); ui->titleLabel->setMinimumWidth(100); //ui->subjectLabel->setMinimumWidth(100); - ui->warning_label->setMinimumWidth(100); + //ui->warning_label->setMinimumWidth(100); ui->mainFrame->setProperty("new", false); ui->mainFrame->style()->unpolish(ui->mainFrame); @@ -466,7 +466,7 @@ void GxsChannelPostItem::fill() ui->titleLabel->setText(title); RetroShareLink msgLink = RetroShareLink::createGxsMessageLink(RetroShareLink::TYPE_CHANNEL, mPost.mMeta.mGroupId, mPost.mMeta.mMsgId, messageName()); - //ui->subjectLabel->setText(msgLink.toHtml()); + ui->subjectLabel->setText(msgLink.toHtml()); if (IS_GROUP_SUBSCRIBED(mGroupMeta.mSubscribeFlags) || IS_GROUP_ADMIN(mGroupMeta.mSubscribeFlags)) { @@ -489,12 +489,12 @@ void GxsChannelPostItem::fill() /* subject */ ui->titleLabel->setText(QString::fromUtf8(mPost.mMeta.mMsgName.c_str())); - //uint32_t autorized_lines = (int)floor((ui->logoLabel->height() - ui->titleLabel->height() - ui->buttonHLayout->sizeHint().height())/QFontMetricsF(ui->subjectLabel->font()).height()); + uint32_t autorized_lines = (int)floor((ui->logoLabel->height() - ui->titleLabel->height() - ui->buttonHLayout->sizeHint().height())/QFontMetricsF(ui->subjectLabel->font()).height()); // fill first 4 lines of message. (csoler) Disabled the replacement of smileys and links, because the cost is too crazy //ui->subjectLabel->setText(RsHtml().formatText(NULL, RsStringUtil::CopyLines(QString::fromUtf8(mPost.mMsg.c_str()), autorized_lines), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS)); - //ui->subjectLabel->setText(RsStringUtil::CopyLines(QString::fromUtf8(mPost.mMsg.c_str()), 2)) ; + ui->subjectLabel->setText(RsStringUtil::CopyLines(QString::fromUtf8(mPost.mMsg.c_str()), 2)) ; //QString score = QString::number(post.mTopScore); // scoreLabel->setText(score); @@ -654,21 +654,21 @@ void GxsChannelPostItem::setReadStatus(bool isNew, bool isUnread) ui->mainFrame->style()->polish( ui->mainFrame); } -void GxsChannelPostItem::setFileCleanUpWarning(uint32_t time_left) -{ - int hours = (int)time_left/3600; - int minutes = (time_left - hours*3600)%60; - - ui->warning_label->setText(tr("Warning! You have less than %1 hours and %2 minute before this file is deleted Consider saving it.").arg( - QString::number(hours)).arg(QString::number(minutes))); - - QFont warnFont = ui->warning_label->font(); - warnFont.setBold(true); - ui->warning_label->setFont(warnFont); - - ui->warn_image_label->setVisible(true); - ui->warning_label->setVisible(true); -} +// void GxsChannelPostItem::setFileCleanUpWarning(uint32_t time_left) +// { +// int hours = (int)time_left/3600; +// int minutes = (time_left - hours*3600)%60; +// +// ui->warning_label->setText(tr("Warning! You have less than %1 hours and %2 minute before this file is deleted Consider saving it.").arg( +// QString::number(hours)).arg(QString::number(minutes))); +// +// QFont warnFont = ui->warning_label->font(); +// warnFont.setBold(true); +// ui->warning_label->setFont(warnFont); +// +// ui->warn_image_label->setVisible(true); +// ui->warning_label->setVisible(true); +// } void GxsChannelPostItem::updateItem() { diff --git a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.h b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.h index 315972bb1..8370b885e 100644 --- a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.h +++ b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.h @@ -56,7 +56,7 @@ public: bool setGroup(const RsGxsChannelGroup& group, bool doFill = true); bool setPost(const RsGxsChannelPost& post, bool doFill = true); - void setFileCleanUpWarning(uint32_t time_left); + //void setFileCleanUpWarning(uint32_t time_left); QString getTitleLabel(); QString getMsgLabel(); diff --git a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.ui b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.ui index 3c524b1d6..2188df912 100644 --- a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.ui +++ b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.ui @@ -6,8 +6,8 @@ 0 0 - 922 - 187 + 1092 + 231 @@ -124,6 +124,16 @@ + + + + TextLabel + + + true + + + @@ -137,33 +147,6 @@ - - - - - - - - - - 24 - 16777215 - - - - - - - - - - - TextLabel - - - - - @@ -486,21 +469,18 @@ + + StyledElidedLabel + QLabel +

gui/common/StyledElidedLabel.h
+ ElidedLabel QLabel
gui/common/ElidedLabel.h
1
- - StyledElidedLabel - QLabel -
gui/common/StyledElidedLabel.h
-
- - - - + From 07e93471226d0fadda13f56dc3238d933bc82072 Mon Sep 17 00:00:00 2001 From: csoler Date: Fri, 2 Oct 2020 17:56:59 +0200 Subject: [PATCH 22/24] removed alternate row colors. Added a tooltip about zooming --- .../GxsChannelPostsWidgetWithModel.cpp | 22 +++++++++---------- .../GxsChannelPostsWidgetWithModel.ui | 21 ++++++++++-------- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp index 5d7aa8762..c663c3125 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp @@ -121,9 +121,9 @@ void ChannelPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem & RsGxsChannelPost post = index.data(Qt::UserRole).value() ; - if(index.row() & 0x01) - painter->fillRect( option.rect, option.palette.alternateBase().color()); - else + // if(index.row() & 0x01) + // painter->fillRect( option.rect, option.palette.alternateBase().color()); + // else painter->fillRect( option.rect, option.palette.base().color()); painter->restore(); @@ -147,9 +147,9 @@ void ChannelPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem & { // we need to do the alternate color manually - if(index.row() & 0x01) - pixmap.fill(option.palette.alternateBase().color()); - else + //if(index.row() & 0x01) + // pixmap.fill(option.palette.alternateBase().color()); + //else pixmap.fill(option.palette.base().color()); } @@ -302,9 +302,9 @@ void ChannelPostFilesDelegate::paint(QPainter * painter, const QStyleOptionViewI QPixmap pixmap(w.size()); // apparently we need to do the alternate colors manually - if(index.row() & 0x01) - pixmap.fill(option.palette.alternateBase().color()); - else + //if(index.row() & 0x01) + // pixmap.fill(option.palette.alternateBase().color()); + //else pixmap.fill(option.palette.base().color()); w.render(&pixmap,QPoint(),QRegion(),QWidget::DrawChildren );// draw the widgets, not the background @@ -356,7 +356,7 @@ GxsChannelPostsWidgetWithModel::GxsChannelPostsWidgetWithModel(const RsGxsGroupI ui->showUnread_TB->setToolTip(tr("Show unread posts only")); connect(ui->showUnread_TB,SIGNAL(toggled(bool)),this,SLOT(switchOnlyUnread(bool))); - ui->postsTree->setAlternatingRowColors(true); + ui->postsTree->setAlternatingRowColors(false); ui->postsTree->setModel(mChannelPostsModel = new RsGxsChannelPostsModel()); ui->postsTree->setItemDelegate(mChannelPostsDelegate = new ChannelPostDelegate()); ui->postsTree->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); // prevents bug on w10, since row size depends on widget width @@ -373,7 +373,7 @@ GxsChannelPostsWidgetWithModel::GxsChannelPostsWidgetWithModel(const RsGxsGroupI ui->channelPostFiles_TV->setPlaceholderText(tr("No files in this post, or no post selected")); ui->channelPostFiles_TV->setSortingEnabled(true); ui->channelPostFiles_TV->sortByColumn(0, Qt::AscendingOrder); - ui->channelPostFiles_TV->setAlternatingRowColors(true); + ui->channelPostFiles_TV->setAlternatingRowColors(false); ui->channelFiles_TV->setModel(mChannelFilesModel = new RsGxsChannelPostFilesModel()); ui->channelFiles_TV->setItemDelegate(mFilesDelegate = new ChannelPostFilesDelegate()); diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui index 38b7c4902..46683b31c 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui @@ -393,6 +393,9 @@ p, li { white-space: pre-wrap; } Qt::CustomContextMenu + + <html><head/><body><p>Click to view post. </p><p>Use Ctrl+mouse wheel </p><p>to zoom/unzoom.</p></body></html> + QAbstractScrollArea::AdjustToContents @@ -428,7 +431,7 @@ p, li { white-space: pre-wrap; }
- 0 + 1 @@ -593,16 +596,16 @@ p, li { white-space: pre-wrap; } QToolButton
gui/common/SubscribeToolButton.h
- - StyledElidedLabel - QLabel -
gui/common/StyledElidedLabel.h
-
RSTreeView QTreeView
gui/common/RSTreeView.h
+ + LineEditClear + QLineEdit +
gui/common/LineEditClear.h
+
GxsCommentDialog QWidget @@ -610,9 +613,9 @@ p, li { white-space: pre-wrap; } 1 - LineEditClear - QLineEdit -
gui/common/LineEditClear.h
+ StyledElidedLabel + QLabel +
gui/common/StyledElidedLabel.h
From 26d0443ff97a0f05252889899251043f8f254328 Mon Sep 17 00:00:00 2001 From: sehraf Date: Sun, 4 Oct 2020 20:41:34 +0200 Subject: [PATCH 23/24] fixed Cyrils remarks --- libretroshare/src/dht/p3bitdht_peers.cc | 4 ++-- libretroshare/src/dht/p3bitdht_relay.cc | 4 ++-- libretroshare/src/retroshare/rsdht.h | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/libretroshare/src/dht/p3bitdht_peers.cc b/libretroshare/src/dht/p3bitdht_peers.cc index bf8e87f11..013a9b47c 100644 --- a/libretroshare/src/dht/p3bitdht_peers.cc +++ b/libretroshare/src/dht/p3bitdht_peers.cc @@ -242,7 +242,7 @@ int p3BitDht::addKnownPeer( const RsPeerId &pid, addrv4.sin_addr = ap->sin_addr; addrv4.sin_port = ap->sin_port; - RsDhtPeerType p3type = static_cast(0); + RsDhtPeerType p3type = RsDhtPeerType::ANY; int bdflags = 0; bdId id; bool isOwnId = false; @@ -469,7 +469,7 @@ DhtPeerDetails *p3BitDht::findInternalDhtPeer_locked(const bdNodeId *id, RsDhtPe { return NULL; } - if (type != static_cast(0)) + if (type != RsDhtPeerType::ANY) { if (it->second.mPeerType != type) { diff --git a/libretroshare/src/dht/p3bitdht_relay.cc b/libretroshare/src/dht/p3bitdht_relay.cc index e5afd4b31..2d2845c83 100644 --- a/libretroshare/src/dht/p3bitdht_relay.cc +++ b/libretroshare/src/dht/p3bitdht_relay.cc @@ -166,7 +166,7 @@ int p3BitDht::setRelayMode(RsDhtRelayMode mode) int p3BitDht::getRelayAllowance(RsDhtRelayClass classIdx, uint32_t &count, uint32_t &bandwidth) { std::cerr << "p3BitDht::getRelayAllowance(" << static_cast::type>(classIdx) << "): "; - if ((classIdx >= static_cast(0)) && (classIdx < RsDhtRelayClass::NUM_CLASS)) + if ((classIdx >= RsDhtRelayClass::ALL) && (classIdx < RsDhtRelayClass::NUM_CLASS)) { count = mRelay->getRelayClassMax(static_cast::type>(classIdx)); bandwidth = mRelay->getRelayClassBandwidth(static_cast::type>(classIdx)); @@ -306,7 +306,7 @@ bool p3BitDht::loadList(std::list& load) int bandwidth[static_cast::type>(RsDhtRelayClass::NUM_CLASS)] = {0}; bool haveMode = false; - RsDhtRelayMode mode = static_cast(0); + RsDhtRelayMode mode = RsDhtRelayMode::DISABLED; std::list::iterator it; for(it = config->tlvkvs.pairs.begin(); it != config->tlvkvs.pairs.end(); ++it) diff --git a/libretroshare/src/retroshare/rsdht.h b/libretroshare/src/retroshare/rsdht.h index b52e2ba73..f62d029eb 100644 --- a/libretroshare/src/retroshare/rsdht.h +++ b/libretroshare/src/retroshare/rsdht.h @@ -87,6 +87,7 @@ enum class RsDhtRelayClass : uint8_t enum class RsDhtRelayMode : uint16_t { + DISABLED= 0x0000, ENABLED = 0x0001, MASK = 0x00f0, From eca11d0885b07b8c2733040499ed9d221271a912 Mon Sep 17 00:00:00 2001 From: Gioacchino Mazzurco Date: Wed, 7 Oct 2020 10:58:52 +0200 Subject: [PATCH 24/24] retroshare-gui: fix missing include in jsonapipage Fix compile error, warnings and typo --- libretroshare/src/retroshare/rsgxsforums.h | 2 +- retroshare-gui/src/gui/settings/JsonApiPage.h | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/libretroshare/src/retroshare/rsgxsforums.h b/libretroshare/src/retroshare/rsgxsforums.h index da79a03a5..a5908c902 100644 --- a/libretroshare/src/retroshare/rsgxsforums.h +++ b/libretroshare/src/retroshare/rsgxsforums.h @@ -38,7 +38,7 @@ class RsGxsForums; /** - * Pointer to global instance of RsGxsChannels service implementation + * Pointer to global instance of RsGxsForums service implementation * @jsonapi{development} */ extern RsGxsForums* rsGxsForums; diff --git a/retroshare-gui/src/gui/settings/JsonApiPage.h b/retroshare-gui/src/gui/settings/JsonApiPage.h index f516a541d..04bb9e669 100644 --- a/retroshare-gui/src/gui/settings/JsonApiPage.h +++ b/retroshare-gui/src/gui/settings/JsonApiPage.h @@ -1,7 +1,7 @@ /******************************************************************************* * gui/settings/JsonApiPage.h * * * - * Copyright (C) 2018 Gioacchino Mazzurco * + * Copyright (C) 2018-2020 Gioacchino Mazzurco * * * * This program is free software: you can redistribute it and/or modify * * it under the terms of the GNU Affero General Public License as * @@ -20,7 +20,8 @@ #pragma once -#include +#include "retroshare-gui/configpage.h" +#include "gui/common/FilesDefs.h" #include "ui_JsonApiPage.h" class JsonApiPage : public ConfigPage @@ -30,14 +31,16 @@ class JsonApiPage : public ConfigPage public: JsonApiPage(QWidget * parent = nullptr, Qt::WindowFlags flags = 0); - ~JsonApiPage() {} + ~JsonApiPage() override = default; - /** Loads the settings for this page */ + virtual QPixmap iconPixmap() const override + { + return FilesDefs::getPixmapFromQtResourcePath( + ":/icons/svg/empty-circle.svg" ); + } - virtual QPixmap iconPixmap() const - { return FilesDefs::getPixmapFromQtResourcePath(":/icons/svg/empty-circle.svg"); } - virtual QString pageName() const { return tr("JSON API"); } - virtual QString helpText() const; + virtual QString pageName() const override { return tr("JSON API"); } + virtual QString helpText() const override; /** Call this after start of libretroshare/Retroshare * checks the settings and starts JSON API if required */