diff --git a/src/blackmisc/network/server.cpp b/src/blackmisc/network/server.cpp index 6ac588dab..319c6e88c 100644 --- a/src/blackmisc/network/server.cpp +++ b/src/blackmisc/network/server.cpp @@ -9,6 +9,7 @@ #include "blackmisc/network/server.h" #include "blackmisc/logcategories.h" #include "blackmisc/stringutils.h" +#include "blackmisc/obfuscation.h" #include "blackmisc/propertyindexref.h" #include "blackmisc/statusmessage.h" #include "blackmisc/comparefunctions.h" @@ -32,7 +33,7 @@ namespace BlackMisc::Network CServer::CServer(const QString &name, const QString &description, const QString &address, int port, const CUser &user, const CFsdSetup &fsdSetup, const CVoiceSetup &voiceSetup, const CEcosystem &ecosytem, ServerType serverType, bool isAcceptingConnections) - : m_name(decode(name)), m_description(decode(description)), m_address(decode(address)), m_port(port), m_user(user), + : m_name(CObfuscation::decode(name)), m_description(CObfuscation::decode(description)), m_address(CObfuscation::decode(address)), m_port(port), m_user(user), m_ecosystem(ecosytem), m_serverType(serverType), m_isAcceptingConnections(isAcceptingConnections), m_fsdSetup(fsdSetup), m_voiceSetup(voiceSetup) @@ -290,4 +291,16 @@ namespace BlackMisc::Network default: return unspecified; } } + + void CServer::setAddress(const QString &address) { + m_address = CObfuscation::decode(address); + } + + void CServer::setName(const QString &name) { + m_name = CObfuscation::decode(name); + } + + void CServer::setDescription(const QString &description) { + m_description = CObfuscation::decode(description).simplified(); + } } // namespace diff --git a/src/blackmisc/network/server.h b/src/blackmisc/network/server.h index 3f2c2749a..4fdb3b1c9 100644 --- a/src/blackmisc/network/server.h +++ b/src/blackmisc/network/server.h @@ -15,7 +15,6 @@ #include "blackmisc/network/fsdsetup.h" #include "blackmisc/network/ecosystem.h" #include "blackmisc/audio/voicesetup.h" -#include "blackmisc/obfuscation.h" #include "blackmisc/blackmiscexport.h" #include "blackmisc/metaclass.h" #include "blackmisc/propertyindexref.h" @@ -33,8 +32,7 @@ namespace BlackMisc::Network //! Value object encapsulating information of a server class BLACKMISC_EXPORT CServer : public CValueObject, - public ITimestampBased, - public CObfuscation + public ITimestampBased { public: //! Properties by index @@ -93,7 +91,7 @@ namespace BlackMisc::Network const QString &getAddress() const { return m_address; } //! Set address (e.g. myserver.foo.com) - void setAddress(const QString &address) { m_address = decode(address); } + void setAddress(const QString &address); //! Get user const CUser &getUser() const { return m_user; } @@ -108,7 +106,7 @@ namespace BlackMisc::Network bool hasName() const { return !m_name.isEmpty(); } //! Set name - void setName(const QString &name) { m_name = decode(name); } + void setName(const QString &name); //! Matches server name? bool matchesName(const QString &name) const; @@ -123,7 +121,7 @@ namespace BlackMisc::Network const QString &getDescription() const { return m_description; } //! Set description - void setDescription(const QString &description) { m_description = decode(description).simplified(); } + void setDescription(const QString &description); //! Get port int getPort() const { return m_port; } diff --git a/src/blackmisc/network/user.cpp b/src/blackmisc/network/user.cpp index f2bcb2ed8..ab5482514 100644 --- a/src/blackmisc/network/user.cpp +++ b/src/blackmisc/network/user.cpp @@ -9,6 +9,7 @@ #include "blackmisc/network/user.h" #include "blackmisc/aviation/airporticaocode.h" #include "blackmisc/comparefunctions.h" +#include "blackmisc/obfuscation.h" #include "blackmisc/propertyindexref.h" #include "blackmisc/statusmessage.h" #include "blackmisc/stringutils.h" @@ -34,14 +35,14 @@ namespace BlackMisc::Network } CUser::CUser(const QString &id, const QString &realname, const CCallsign &callsign) - : m_id(decode(id)), m_realname(decode(realname)), m_callsign(callsign) + : m_id(CObfuscation::decode(id)), m_realname(CObfuscation::decode(realname)), m_callsign(callsign) { this->deriveHomeBaseFromCallsign(); this->setRealName(m_realname); // extracts homebase if this is included in real name } CUser::CUser(const QString &id, const QString &realname, const QString &email, const QString &password, const CCallsign &callsign) - : m_id(decode(id)), m_realname(decode(realname)), m_email(decode(email)), m_password(decode(password)), m_callsign(callsign) + : m_id(CObfuscation::decode(id)), m_realname(CObfuscation::decode(realname)), m_email(CObfuscation::decode(email)), m_password(CObfuscation::decode(password)), m_callsign(callsign) { this->deriveHomeBaseFromCallsign(); this->setRealName(m_realname); // extracts homebase @@ -111,7 +112,7 @@ namespace BlackMisc::Network void CUser::setRealName(const QString &realname) { - QString rn(simplifyAccents(decode(realname).simplified())); + QString rn(simplifyAccents(CObfuscation::decode(realname).simplified())); if (rn.isEmpty()) { m_realname.clear(); @@ -297,4 +298,16 @@ namespace BlackMisc::Network Q_ASSERT_X(false, Q_FUNC_INFO, "compare failed"); return 0; } + + void CUser::setPassword(const QString &pw) { + m_password = CObfuscation::decode(pw); + } + + void CUser::setEmail(const QString &email) { + m_email = CObfuscation::decode(email); + } + + void CUser::setId(const QString &id) { + m_id = CObfuscation::decode(id); + } } // namespace diff --git a/src/blackmisc/network/user.h b/src/blackmisc/network/user.h index 885b4d6ee..00764022f 100644 --- a/src/blackmisc/network/user.h +++ b/src/blackmisc/network/user.h @@ -13,7 +13,6 @@ #include "blackmisc/aviation/airporticaocode.h" #include "blackmisc/aviation/callsign.h" -#include "blackmisc/obfuscation.h" #include "blackmisc/metaclass.h" #include "blackmisc/propertyindexref.h" #include "blackmisc/statusmessagelist.h" @@ -31,8 +30,7 @@ namespace BlackMisc::Network * Value object encapsulating information of a user. */ class BLACKMISC_EXPORT CUser : - public CValueObject, - public CObfuscation + public CValueObject { public: /*! @@ -72,7 +70,7 @@ namespace BlackMisc::Network const QString &getPassword() const { return m_password; } //! Set password - void setPassword(const QString &pw) { m_password = decode(pw); } + void setPassword(const QString &pw); //! Valid user object? bool isValid() const { return !isNull(); } @@ -117,7 +115,7 @@ namespace BlackMisc::Network const QString &getEmail() const { return m_email; } //! Set email. - void setEmail(const QString &email) { m_email = decode(email); } + void setEmail(const QString &email); //! Valid email? bool hasValidEmail() const { return !m_email.isEmpty(); } @@ -135,7 +133,7 @@ namespace BlackMisc::Network bool hasNumericId() const; //! Set id - void setId(const QString &id) { m_id = decode(id); } + void setId(const QString &id); //! Homebase const Aviation::CAirportIcaoCode &getHomeBase() const { return m_homebase; } diff --git a/src/blackmisc/obfuscation.h b/src/blackmisc/obfuscation.h index 26fadb6e7..fb786895c 100644 --- a/src/blackmisc/obfuscation.h +++ b/src/blackmisc/obfuscation.h @@ -20,7 +20,7 @@ namespace BlackMisc //! \remark this is no real security, but as the name says just obfuscation. The sole purpose of this class is to remove potentially strings from the source code class BLACKMISC_EXPORT CObfuscation { - protected: + public: //! Constructor CObfuscation() {}