Allow software to be time limited with serial key #4716
This commit is contained in:
parent
75adb5aa8d
commit
19835b6aaa
|
@ -109,7 +109,8 @@ HEADERS += src/MainWindow.h \
|
|||
src/Plugin.h \
|
||||
src/WebClient.h \
|
||||
../lib/common/PluginVersion.h \
|
||||
src/SubscriptionManager.h
|
||||
src/SubscriptionManager.h \
|
||||
src/SubscriptionState.h
|
||||
RESOURCES += res/Synergy.qrc
|
||||
RC_FILE = res/win/Synergy.rc
|
||||
macx {
|
||||
|
|
|
@ -51,6 +51,12 @@ QString CoreInterface::getArch()
|
|||
return run(args);
|
||||
}
|
||||
|
||||
QString CoreInterface::getSubscriptionFilename()
|
||||
{
|
||||
QStringList args("--get-subscription-filename");
|
||||
return run(args);
|
||||
}
|
||||
|
||||
QString CoreInterface::activateSerial(const QString& serial)
|
||||
{
|
||||
QStringList args("--subscription-serial");
|
||||
|
|
|
@ -28,6 +28,7 @@ public:
|
|||
QString getProfileDir();
|
||||
QString getInstalledDir();
|
||||
QString getArch();
|
||||
QString getSubscriptionFilename();
|
||||
QString activateSerial(const QString& serial);
|
||||
QString checkSubscription();
|
||||
QString run(const QStringList& args, const QString& input = "");
|
||||
|
|
|
@ -31,6 +31,8 @@
|
|||
#include "ZeroconfService.h"
|
||||
#include "DataDownloader.h"
|
||||
#include "CommandProcess.h"
|
||||
#include "SubscriptionManager.h"
|
||||
#include "SubscriptionState.h"
|
||||
#include "EditionType.h"
|
||||
#include "QUtility.h"
|
||||
#include "ProcessorArch.h"
|
||||
|
@ -553,11 +555,8 @@ void MainWindow::startSynergy()
|
|||
if ((synergyType() == synergyClient && !clientArgs(args, app))
|
||||
|| (synergyType() == synergyServer && !serverArgs(args, app)))
|
||||
{
|
||||
if (desktopMode)
|
||||
{
|
||||
stopSynergy();
|
||||
return;
|
||||
}
|
||||
stopSynergy();
|
||||
return;
|
||||
}
|
||||
|
||||
if (desktopMode)
|
||||
|
@ -699,6 +698,22 @@ QString MainWindow::appPath(const QString& name)
|
|||
|
||||
bool MainWindow::serverArgs(QStringList& args, QString& app)
|
||||
{
|
||||
SubscriptionManager subscriptionManager;
|
||||
if (subscriptionManager.checkSubscriptionExist())
|
||||
{
|
||||
int edition;
|
||||
int state = subscriptionManager.checkSubscription(edition);
|
||||
|
||||
if (state == kInvalid) {
|
||||
return false;
|
||||
}
|
||||
else if (state == kExpired) {
|
||||
QMessageBox::warning(this, tr("Subscription is expired"),
|
||||
tr("Your subscription is expired. Please purchase."));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
app = appPath(appConfig().synergysName());
|
||||
|
||||
if (!QFile::exists(app))
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "WebClient.h"
|
||||
#include "SubscriptionManager.h"
|
||||
#include "EditionType.h"
|
||||
#include "SubscriptionState.h"
|
||||
#include "QSynergyApplication.h"
|
||||
#include "QUtility.h"
|
||||
|
||||
|
@ -127,19 +128,19 @@ bool SetupWizard::validateCurrentPage()
|
|||
else {
|
||||
// create subscription file in profile directory
|
||||
SubscriptionManager subscriptionManager;
|
||||
bool r = subscriptionManager.activateSerial(m_pLineEditSerialKey->text());
|
||||
bool r = subscriptionManager.activateSerial(m_pLineEditSerialKey->text(), m_Edition);
|
||||
if (!r) {
|
||||
message.setText(tr("An error occurred while trying to activate using a serial key. "
|
||||
"Please contact the helpdesk, and provide the "
|
||||
"following details.\n\n%1").arg(subscriptionManager.getLastError()));
|
||||
message.exec();
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
// check if the serial is valid
|
||||
r = subscriptionManager.checkSubscription(m_Edition);
|
||||
m_pPluginPage->setEdition(m_Edition);
|
||||
|
||||
if (r) {
|
||||
m_pPluginPage->setEdition(m_Edition);
|
||||
}
|
||||
|
||||
return r;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -19,31 +19,37 @@
|
|||
|
||||
#include "CoreInterface.h"
|
||||
#include "EditionType.h"
|
||||
#include "SubscriptionState.h"
|
||||
|
||||
#include <QMessageBox>
|
||||
#include <QFile>
|
||||
|
||||
SubscriptionManager::SubscriptionManager()
|
||||
{
|
||||
}
|
||||
|
||||
bool SubscriptionManager::activateSerial(const QString& serial)
|
||||
bool SubscriptionManager::activateSerial(const QString& serial, int& edition)
|
||||
{
|
||||
edition = Unknown;
|
||||
CoreInterface coreInterface;
|
||||
QString output;
|
||||
|
||||
try
|
||||
{
|
||||
coreInterface.activateSerial(serial);
|
||||
output = coreInterface.activateSerial(serial);
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
showErrorDialog(e.what());
|
||||
m_ErrorMessage = e.what();
|
||||
return false;
|
||||
}
|
||||
|
||||
edition = getEditionType(output);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SubscriptionManager::checkSubscription(int& edition)
|
||||
int SubscriptionManager::checkSubscription(int& edition)
|
||||
{
|
||||
edition = Unknown;
|
||||
CoreInterface coreInterface;
|
||||
|
@ -54,28 +60,30 @@ bool SubscriptionManager::checkSubscription(int& edition)
|
|||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
showErrorDialog(e.what());
|
||||
return false;
|
||||
m_ErrorMessage = e.what();
|
||||
|
||||
if (m_ErrorMessage.contains("subscription has expired")) {
|
||||
return kExpired;
|
||||
}
|
||||
|
||||
return kInvalid;
|
||||
}
|
||||
|
||||
if (output.contains("subscription will expire soon")) {
|
||||
QMessageBox::warning(
|
||||
this, tr("Activate Subscription"),
|
||||
tr("Your subscription will be expired soon."));
|
||||
return kExpiredSoon;
|
||||
}
|
||||
|
||||
edition = getEditionType(output);
|
||||
|
||||
return true;
|
||||
return kValid;
|
||||
}
|
||||
|
||||
void SubscriptionManager::showErrorDialog(const QString& errorMsg)
|
||||
bool SubscriptionManager::checkSubscriptionExist()
|
||||
{
|
||||
QMessageBox::critical(
|
||||
this, "Activate Subscription",
|
||||
tr("An error occurred while trying to activate using a serial key. "
|
||||
"Please contact the helpdesk, and provide the "
|
||||
"following details.\n\n%1").arg(errorMsg));
|
||||
CoreInterface coreInterface;
|
||||
QString subscriptionFilename = coreInterface.getSubscriptionFilename();
|
||||
|
||||
return QFile::exists(subscriptionFilename);
|
||||
}
|
||||
|
||||
int SubscriptionManager::getEditionType(QString& string)
|
||||
|
|
|
@ -24,10 +24,14 @@ class SubscriptionManager : public QWidget
|
|||
public:
|
||||
SubscriptionManager();
|
||||
|
||||
bool activateSerial(const QString& serial);
|
||||
bool checkSubscription(int& edition);
|
||||
bool activateSerial(const QString& serial, int& edition);
|
||||
int checkSubscription(int& edition);
|
||||
bool checkSubscriptionExist();
|
||||
QString getLastError(){ return m_ErrorMessage; }
|
||||
|
||||
private:
|
||||
void showErrorDialog(const QString& errorMsg);
|
||||
int getEditionType(QString& string);
|
||||
|
||||
private:
|
||||
QString m_ErrorMessage;
|
||||
};
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* synergy -- mouse and keyboard sharing utility
|
||||
* Copyright (C) 2015 Synergy Seamless Inc.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#ifndef SUBSCRIPTIONSTATE_H
|
||||
#define SUBSCRIPTIONSTATE_H
|
||||
|
||||
enum qSubscriptionState {
|
||||
kValid,
|
||||
kInvalid,
|
||||
kExpiredSoon,
|
||||
kExpired
|
||||
};
|
||||
|
||||
#endif // SUBSCRIPTIONSTATE_H
|
Loading…
Reference in New Issue