From 0e18c8941664e86ae2264bbef072df68cab07751 Mon Sep 17 00:00:00 2001 From: Serhii Hadzhilov Date: Fri, 15 Jul 2022 16:17:17 +0300 Subject: [PATCH] Add decoded serial key into the request --- src/gui/src/LicenseRegistry.cpp | 1 + src/lib/shared/SerialKey.cpp | 6 ++++++ src/lib/shared/SerialKey.h | 1 + src/lib/shared/SerialKeyData.h | 1 + src/lib/shared/SerialKeyParser.cpp | 8 ++++++++ src/lib/shared/SerialKeyParser.h | 6 ++++++ 6 files changed, 23 insertions(+) diff --git a/src/gui/src/LicenseRegistry.cpp b/src/gui/src/LicenseRegistry.cpp index a7f72863aa..5343cffe12 100644 --- a/src/gui/src/LicenseRegistry.cpp +++ b/src/gui/src/LicenseRegistry.cpp @@ -77,6 +77,7 @@ QByteArray LicenseRegistry::getRequestData() const const SerialKey key(m_config.serialKey().toStdString()); data["email"] = key.getEmail().c_str(); data["key"] = key.toString().c_str(); + data["key_decoded"] = key.getDecodedKey().c_str(); data["is_server"] = m_config.getServerGroupChecked(); diff --git a/src/lib/shared/SerialKey.cpp b/src/lib/shared/SerialKey.cpp index dc4be31652..80df3a6698 100644 --- a/src/lib/shared/SerialKey.cpp +++ b/src/lib/shared/SerialKey.cpp @@ -161,3 +161,9 @@ SerialKey::getEmail() const { return m_data.email; } + +const std::string& +SerialKey::getDecodedKey() const +{ + return m_data.key_decoded; +} diff --git a/src/lib/shared/SerialKey.h b/src/lib/shared/SerialKey.h index db10c1761f..1a0353360b 100644 --- a/src/lib/shared/SerialKey.h +++ b/src/lib/shared/SerialKey.h @@ -40,6 +40,7 @@ public: const std::string& getEmail() const; Edition edition() const; const std::string& toString() const; + const std::string& getDecodedKey() const; private: SerialKeyData m_data; diff --git a/src/lib/shared/SerialKeyData.h b/src/lib/shared/SerialKeyData.h index 4744504bda..c11f7f21b2 100644 --- a/src/lib/shared/SerialKeyData.h +++ b/src/lib/shared/SerialKeyData.h @@ -26,6 +26,7 @@ */ struct SerialKeyData { std::string key; // Encoded serial key as a string + std::string key_decoded; // Decoded serial key std::string email; // Email from the serial key SerialKeyEdition edition; // Serial key edition SerialKeyType keyType; // Serial key type diff --git a/src/lib/shared/SerialKeyParser.cpp b/src/lib/shared/SerialKeyParser.cpp index f9a8f80c40..c57aa7e9e7 100644 --- a/src/lib/shared/SerialKeyParser.cpp +++ b/src/lib/shared/SerialKeyParser.cpp @@ -23,6 +23,12 @@ SerialKeyParser::setKey(const std::string& key) m_data.key = key; } +void +SerialKeyParser::setDecodedKey(const std::string& key) +{ + m_data.key_decoded = key; +} + void SerialKeyParser::setEmail(const std::string& email) { @@ -97,11 +103,13 @@ SerialKeyParser::parse(const std::string& plainSerial) if ((parts.size() == 8) && (parts.at(0).find("v1") != std::string::npos)) { setKey(plainSerial); + setDecodedKey(key); parseV1(parts); valid = true; } else if ((parts.size() == 9) && (parts.at(0).find("v2") != std::string::npos)) { setKey(plainSerial); + setDecodedKey(key); parseV2(parts); valid = true; } diff --git a/src/lib/shared/SerialKeyParser.h b/src/lib/shared/SerialKeyParser.h index 728a599105..2a5c889e39 100644 --- a/src/lib/shared/SerialKeyParser.h +++ b/src/lib/shared/SerialKeyParser.h @@ -46,6 +46,12 @@ public: */ void setKey(const std::string& key); + /** + * @brief setKey setter to set decoded key + * @param key decoded serial key + */ + void setDecodedKey(const std::string& key); + /** * @brief setEmail setter to set encoded email * @param email encoded email from the key