SYNERGY1-1555 maintenance licences (#7190)
* SYNERGY1-1555 Remove unused files * SYNERGY1-1555 Remove unused function isPermanent * SYNERGY1-1555 Update SerialKeyType with maintenance type * SYENRGY1-1555 Add method isMaintenance into SerialKey * SYNERGY1-1555 Check maintenance licenses * SYNERGY1-1555 Replace obsolete functions * SYNERGY1-1555 Fix Linux builds * Update ChangeLog * SYNERGY1-1555 Requested changes
This commit is contained in:
parent
de48bb20b7
commit
8a509f4ba9
10 changed files with 83 additions and 68 deletions
|
|
@ -7,6 +7,7 @@ Bug fixes:
|
|||
|
||||
Enhancements:
|
||||
- #7183 Refactoring for Synergy 3 licenses
|
||||
- #7190 Maintenance license serial key support
|
||||
|
||||
1.14.4
|
||||
======
|
||||
|
|
|
|||
|
|
@ -22,6 +22,47 @@
|
|||
#include <utility>
|
||||
#include <QThread>
|
||||
#include <QTimer>
|
||||
#include <QDateTime>
|
||||
#include <QLocale>
|
||||
|
||||
namespace {
|
||||
|
||||
std::string
|
||||
getMaintenanceMessage(const SerialKey& serialKey)
|
||||
{
|
||||
auto expiration = QDateTime::fromTime_t(serialKey.getExpiration()).date();
|
||||
QString message = "The license key you used will only work with versions of Synergy released before %1."
|
||||
"<p>To use this version, you’ll need to renew your Synergy maintenance license. "
|
||||
"<a href=\"https://symless.com/synergy/account?source=gui\""
|
||||
"style=\"text-decoration: none; color: #4285F4;\">Renew today</a>.</p>";
|
||||
auto formatedDate = QLocale("en_US").toString(expiration, "MMM dd yyyy");
|
||||
return message.arg(formatedDate).toStdString();
|
||||
}
|
||||
|
||||
void
|
||||
checkSerialKey(const SerialKey& serialKey, bool acceptExpired)
|
||||
{
|
||||
if (serialKey.isMaintenance()) {
|
||||
auto buildDate = QDateTime::fromString(__TIMESTAMP__).toTime_t();
|
||||
|
||||
if (buildDate > serialKey.getExpiration()) {
|
||||
throw std::runtime_error(getMaintenanceMessage(serialKey));
|
||||
}
|
||||
}
|
||||
|
||||
if (!acceptExpired && serialKey.isExpired(::time(nullptr))) {
|
||||
throw std::runtime_error("Serial key expired");
|
||||
}
|
||||
|
||||
#ifdef SYNERGY_BUSINESS
|
||||
if (!serialKey.isValid()) {
|
||||
throw std::runtime_error("The serial key is not compatible with the business version of Synergy.");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
LicenseManager::LicenseManager(AppConfig* appConfig) :
|
||||
m_AppConfig(appConfig),
|
||||
|
|
@ -31,17 +72,7 @@ LicenseManager::LicenseManager(AppConfig* appConfig) :
|
|||
void
|
||||
LicenseManager::setSerialKey(SerialKey serialKey, bool acceptExpired)
|
||||
{
|
||||
time_t currentTime = ::time(0);
|
||||
|
||||
if (!acceptExpired && serialKey.isExpired(currentTime)) {
|
||||
throw std::runtime_error("Serial key expired");
|
||||
}
|
||||
|
||||
#ifdef SYNERGY_BUSINESS
|
||||
if (!serialKey.isValid()) {
|
||||
throw std::runtime_error("The serial key is not compatible with the business version of Synergy.");
|
||||
}
|
||||
#endif
|
||||
checkSerialKey(serialKey, acceptExpired);
|
||||
|
||||
if (serialKey != m_serialKey) {
|
||||
using std::swap;
|
||||
|
|
@ -108,6 +139,7 @@ LicenseManager::refresh()
|
|||
SerialKey serialKey (m_AppConfig->serialKey().toStdString());
|
||||
setSerialKey(serialKey, true);
|
||||
} catch (...) {
|
||||
m_serialKey = SerialKey();
|
||||
m_AppConfig->clearSerialKey();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,6 +83,12 @@ SerialKey::isTemporary() const
|
|||
return m_data.keyType.isTemporary();
|
||||
}
|
||||
|
||||
bool
|
||||
SerialKey::isMaintenance() const
|
||||
{
|
||||
return m_data.keyType.isMaintenance();
|
||||
}
|
||||
|
||||
bool
|
||||
SerialKey::isValid() const
|
||||
{
|
||||
|
|
@ -125,6 +131,12 @@ SerialKey::daysLeft(time_t currentTime) const
|
|||
return timeLeft / day + daysLeft;
|
||||
}
|
||||
|
||||
time_t
|
||||
SerialKey::getExpiration() const
|
||||
{
|
||||
return m_data.expireTime;
|
||||
}
|
||||
|
||||
int
|
||||
SerialKey::getSpanLeft(time_t time) const
|
||||
{
|
||||
|
|
|
|||
|
|
@ -32,8 +32,10 @@ public:
|
|||
bool isExpired(time_t currentTime) const;
|
||||
bool isTrial() const;
|
||||
bool isTemporary() const;
|
||||
bool isMaintenance() const;
|
||||
bool isValid() const;
|
||||
time_t daysLeft(time_t currentTime) const;
|
||||
time_t getExpiration() const;
|
||||
int getSpanLeft(time_t time = ::time(0)) const;
|
||||
Edition edition() const;
|
||||
const std::string& toString() const;
|
||||
|
|
|
|||
|
|
@ -1,8 +0,0 @@
|
|||
#include "SerialKeyParserV3.h"
|
||||
|
||||
bool
|
||||
SerialKeyParserV3::parse(const std::string& plainSerial)
|
||||
{
|
||||
setKey(plainSerial);
|
||||
return true;
|
||||
}
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
/*
|
||||
* synergy -- mouse and keyboard sharing utility
|
||||
* Copyright (C) 2022 Symless Ltd.
|
||||
*
|
||||
* This package is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* found in the file LICENSE that should have accompanied this file.
|
||||
*
|
||||
* This package is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "SerialKeyParser.h"
|
||||
|
||||
class SerialKeyParserV3 : public SerialKeyParser
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief parse serial key
|
||||
* @param plainSerial encoded serial key
|
||||
* @return true if parsed
|
||||
*/
|
||||
bool parse(const std::string& plainSerial) override;
|
||||
};
|
||||
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
const std::string SerialKeyType::TRIAL = "trial";
|
||||
const std::string SerialKeyType::SUBSCRIPTION = "subscription";
|
||||
const std::string SerialKeyType::MAINTENANCE = "maintenance";
|
||||
|
||||
SerialKeyType::SerialKeyType()
|
||||
{
|
||||
|
|
@ -28,16 +29,9 @@ SerialKeyType::SerialKeyType()
|
|||
void
|
||||
SerialKeyType::setKeyType(const std::string& Type)
|
||||
{
|
||||
m_isTrial = false;
|
||||
m_isTemporary = false;
|
||||
|
||||
if (Type == SerialKeyType::TRIAL){
|
||||
m_isTrial = true;
|
||||
m_isTemporary = true;
|
||||
}
|
||||
else if (Type == SerialKeyType::SUBSCRIPTION){
|
||||
m_isTemporary = true;
|
||||
}
|
||||
m_isTrial = (Type == SerialKeyType::TRIAL);
|
||||
m_isTemporary = (m_isTrial || (Type == SerialKeyType::SUBSCRIPTION));
|
||||
m_isMaintenance = (Type == SerialKeyType::MAINTENANCE);
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
@ -53,8 +47,8 @@ SerialKeyType::isTemporary() const
|
|||
}
|
||||
|
||||
bool
|
||||
SerialKeyType::isPermanent() const
|
||||
SerialKeyType::isMaintenance() const
|
||||
{
|
||||
return (!m_isTemporary);
|
||||
return m_isMaintenance;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,17 +25,19 @@ private:
|
|||
public:
|
||||
static const std::string TRIAL;
|
||||
static const std::string SUBSCRIPTION;
|
||||
static const std::string MAINTENANCE;
|
||||
|
||||
SerialKeyType();
|
||||
|
||||
void setKeyType(const std::string& Type);
|
||||
bool isTrial() const;
|
||||
bool isTemporary() const;
|
||||
bool isPermanent() const;
|
||||
bool isMaintenance() const;
|
||||
|
||||
private:
|
||||
bool m_isTrial = false;
|
||||
bool m_isTemporary = false;
|
||||
bool m_isMaintenance = false;
|
||||
};
|
||||
|
||||
inline bool
|
||||
|
|
|
|||
|
|
@ -116,6 +116,16 @@ TEST(SerialKeyTests, isExpiring_expiringV2SubscriptionBasicSerial_returnTrue)
|
|||
EXPECT_EQ(false, serial.isTrial());
|
||||
EXPECT_EQ(true, serial.isTemporary());
|
||||
EXPECT_EQ(true, serial.isExpiring(1));
|
||||
EXPECT_FALSE(serial.isMaintenance());
|
||||
}
|
||||
|
||||
TEST(SerialKeyTests, isExpiring_expiringV2MentenanceSerial_returnTrue)
|
||||
{
|
||||
// {v2;maintenance;basic;Bob;1;email;company name;0;86400}
|
||||
SerialKey serial("7B76323B6D61696E74656E616E63653B70726F3B736572686969206861647A68696C6F763B313B7365726869694073796D6C6573732E636F6D3B203B303B313635353132343139307D");
|
||||
EXPECT_FALSE(serial.isTrial());
|
||||
EXPECT_FALSE(serial.isTemporary());
|
||||
EXPECT_TRUE(serial.isMaintenance());
|
||||
}
|
||||
|
||||
TEST(SerialKeyTests, isExpired_expiredV2SubscriptionBasicSerial_returnTrue)
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ TEST(SerialKeyTypeTests, TrialTemporaryKeyType_false)
|
|||
SerialKeyType KeyType;
|
||||
EXPECT_EQ(false, KeyType.isTrial());
|
||||
EXPECT_EQ(false, KeyType.isTemporary());
|
||||
EXPECT_EQ(true, KeyType.isPermanent());
|
||||
EXPECT_FALSE(KeyType.isMaintenance());
|
||||
}
|
||||
|
||||
TEST(SerialKeyTypeTests, TrialTemporaryKeyType_true)
|
||||
|
|
@ -35,7 +35,7 @@ TEST(SerialKeyTypeTests, TrialTemporaryKeyType_true)
|
|||
KeyType.setKeyType("trial");
|
||||
EXPECT_EQ(true, KeyType.isTrial());
|
||||
EXPECT_EQ(true, KeyType.isTemporary());
|
||||
EXPECT_EQ(false, KeyType.isPermanent());
|
||||
EXPECT_FALSE(KeyType.isMaintenance());
|
||||
}
|
||||
|
||||
TEST(SerialKeyTypeTests, TemporaryKeyType_true)
|
||||
|
|
@ -44,14 +44,14 @@ TEST(SerialKeyTypeTests, TemporaryKeyType_true)
|
|||
KeyType.setKeyType("subscription");
|
||||
EXPECT_EQ(false, KeyType.isTrial());
|
||||
EXPECT_EQ(true, KeyType.isTemporary());
|
||||
EXPECT_EQ(false, KeyType.isPermanent());
|
||||
EXPECT_FALSE(KeyType.isMaintenance());
|
||||
}
|
||||
|
||||
TEST(SerialKeyTypeTests, PermanentKeyType_true)
|
||||
TEST(SerialKeyTypeTests, MaintanenceKeyType_true)
|
||||
{
|
||||
SerialKeyType KeyType;
|
||||
KeyType.setKeyType("");
|
||||
KeyType.setKeyType("maintenance");
|
||||
EXPECT_EQ(false, KeyType.isTrial());
|
||||
EXPECT_EQ(false, KeyType.isTemporary());
|
||||
EXPECT_EQ(true, KeyType.isPermanent());
|
||||
EXPECT_TRUE(KeyType.isMaintenance());
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue