#5657 Rename SubscriptionManager to LicenseManager
This commit is contained in:
parent
5a34da3ce0
commit
fc67cdf56e
|
@ -61,12 +61,12 @@ SOURCES += src/main.cpp \
|
||||||
src/Fingerprint.cpp \
|
src/Fingerprint.cpp \
|
||||||
src/SslCertificate.cpp \
|
src/SslCertificate.cpp \
|
||||||
src/WebClient.cpp \
|
src/WebClient.cpp \
|
||||||
src/SubscriptionManager.cpp \
|
|
||||||
src/ActivationNotifier.cpp \
|
src/ActivationNotifier.cpp \
|
||||||
src/ActivationDialog.cpp \
|
src/ActivationDialog.cpp \
|
||||||
src/CancelActivationDialog.cpp \
|
src/CancelActivationDialog.cpp \
|
||||||
src/FailedLoginDialog.cpp \
|
src/FailedLoginDialog.cpp \
|
||||||
../lib/shared/SerialKey.cpp
|
../lib/shared/SerialKey.cpp \
|
||||||
|
src/LicenseManager.cpp
|
||||||
HEADERS += src/MainWindow.h \
|
HEADERS += src/MainWindow.h \
|
||||||
src/AboutDialog.h \
|
src/AboutDialog.h \
|
||||||
src/ServerConfig.h \
|
src/ServerConfig.h \
|
||||||
|
@ -108,14 +108,14 @@ HEADERS += src/MainWindow.h \
|
||||||
src/Fingerprint.h \
|
src/Fingerprint.h \
|
||||||
src/SslCertificate.h \
|
src/SslCertificate.h \
|
||||||
src/WebClient.h \
|
src/WebClient.h \
|
||||||
src/SubscriptionManager.h \
|
|
||||||
src/ActivationNotifier.h \
|
src/ActivationNotifier.h \
|
||||||
src/ElevateMode.h \
|
src/ElevateMode.h \
|
||||||
src/ActivationDialog.h \
|
src/ActivationDialog.h \
|
||||||
src/CancelActivationDialog.h \
|
src/CancelActivationDialog.h \
|
||||||
src/FailedLoginDialog.h \
|
src/FailedLoginDialog.h \
|
||||||
../lib/shared/EditionType.h \
|
../lib/shared/EditionType.h \
|
||||||
../lib/shared/SerialKey.h
|
../lib/shared/SerialKey.h \
|
||||||
|
src/LicenseManager.h
|
||||||
RESOURCES += res/Synergy.qrc
|
RESOURCES += res/Synergy.qrc
|
||||||
RC_FILE = res/win/Synergy.rc
|
RC_FILE = res/win/Synergy.rc
|
||||||
macx {
|
macx {
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#include "ActivationNotifier.h"
|
#include "ActivationNotifier.h"
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
#include "QUtility.h"
|
#include "QUtility.h"
|
||||||
#include "SubscriptionManager.h"
|
#include "LicenseManager.h"
|
||||||
#include "FailedLoginDialog.h"
|
#include "FailedLoginDialog.h"
|
||||||
|
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
@ -15,11 +15,11 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
ActivationDialog::ActivationDialog(QWidget* parent, AppConfig& appConfig,
|
ActivationDialog::ActivationDialog(QWidget* parent, AppConfig& appConfig,
|
||||||
SubscriptionManager& subscriptionManager) :
|
LicenseManager& licenseManager) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
ui(new Ui::ActivationDialog),
|
ui(new Ui::ActivationDialog),
|
||||||
m_appConfig(&appConfig),
|
m_appConfig(&appConfig),
|
||||||
m_subscriptionManager (&subscriptionManager)
|
m_LicenseManager (&licenseManager)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
refreshSerialKey();
|
refreshSerialKey();
|
||||||
|
@ -39,10 +39,10 @@ ActivationDialog::~ActivationDialog()
|
||||||
|
|
||||||
void ActivationDialog::reject()
|
void ActivationDialog::reject()
|
||||||
{
|
{
|
||||||
if (m_subscriptionManager->activeEdition() == kUnregistered) {
|
if (m_LicenseManager->activeEdition() == kUnregistered) {
|
||||||
CancelActivationDialog cancelActivationDialog(this);
|
CancelActivationDialog cancelActivationDialog(this);
|
||||||
if (QDialog::Accepted == cancelActivationDialog.exec()) {
|
if (QDialog::Accepted == cancelActivationDialog.exec()) {
|
||||||
m_subscriptionManager->skipActivation();
|
m_LicenseManager->skipActivation();
|
||||||
m_appConfig->activationHasRun(true);
|
m_appConfig->activationHasRun(true);
|
||||||
m_appConfig->saveSettings();
|
m_appConfig->saveSettings();
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ void ActivationDialog::accept()
|
||||||
std::pair<bool, QString> result;
|
std::pair<bool, QString> result;
|
||||||
try {
|
try {
|
||||||
QString serialKey = ui->m_pTextEditSerialKey->toPlainText();
|
QString serialKey = ui->m_pTextEditSerialKey->toPlainText();
|
||||||
result = m_subscriptionManager->setSerialKey(serialKey);
|
result = m_LicenseManager->setSerialKey(serialKey);
|
||||||
}
|
}
|
||||||
catch (std::exception& e) {
|
catch (std::exception& e) {
|
||||||
message.critical(this, "Unknown Error",
|
message.critical(this, "Unknown Error",
|
||||||
|
@ -77,17 +77,17 @@ void ActivationDialog::accept()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Edition edition = m_subscriptionManager->activeEdition();
|
Edition edition = m_LicenseManager->activeEdition();
|
||||||
if (edition != kUnregistered) {
|
if (edition != kUnregistered) {
|
||||||
if (m_subscriptionManager->serialKey().isTrial()) {
|
if (m_LicenseManager->serialKey().isTrial()) {
|
||||||
message.information(this, "Thanks!",
|
message.information(this, "Thanks!",
|
||||||
tr("Thanks for trying %1!").arg
|
tr("Thanks for trying %1!").arg
|
||||||
(m_subscriptionManager->getEditionName(edition)));
|
(m_LicenseManager->getEditionName(edition)));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
message.information(this, "Activated!",
|
message.information(this, "Activated!",
|
||||||
tr("Thanks for activating %1!").arg
|
tr("Thanks for activating %1!").arg
|
||||||
(m_subscriptionManager->getEditionName(edition)));
|
(m_LicenseManager->getEditionName(edition)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#define ACTIVATIONDIALOG_H
|
#define ACTIVATIONDIALOG_H
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <SubscriptionManager.h>
|
#include <LicenseManager.h>
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class ActivationDialog;
|
class ActivationDialog;
|
||||||
|
@ -13,23 +13,23 @@ class AppConfig;
|
||||||
class ActivationDialog : public QDialog
|
class ActivationDialog : public QDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ActivationDialog(QWidget *parent, AppConfig& appConfig,
|
ActivationDialog(QWidget *parent, AppConfig& appConfig,
|
||||||
SubscriptionManager& subscriptionManager);
|
LicenseManager& licenseManager);
|
||||||
~ActivationDialog();
|
~ActivationDialog();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void reject();
|
void reject();
|
||||||
void accept();
|
void accept();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void refreshSerialKey();
|
void refreshSerialKey();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::ActivationDialog *ui;
|
Ui::ActivationDialog *ui;
|
||||||
AppConfig* m_appConfig;
|
AppConfig* m_appConfig;
|
||||||
SubscriptionManager* m_subscriptionManager;
|
LicenseManager* m_LicenseManager;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ACTIVATIONDIALOG_H
|
#endif // ACTIVATIONDIALOG_H
|
||||||
|
|
|
@ -0,0 +1,144 @@
|
||||||
|
/*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "LicenseManager.h"
|
||||||
|
#include "EditionType.h"
|
||||||
|
#include "AppConfig.h"
|
||||||
|
#include <ctime>
|
||||||
|
#include <stdexcept>
|
||||||
|
#include <utility>
|
||||||
|
#include <QThread>
|
||||||
|
|
||||||
|
LicenseManager::LicenseManager(AppConfig* appConfig) :
|
||||||
|
m_AppConfig(appConfig),
|
||||||
|
m_serialKey(appConfig->edition()) {
|
||||||
|
try {
|
||||||
|
setSerialKey(m_AppConfig->serialKey());
|
||||||
|
} catch (...) {
|
||||||
|
/* Remove garbage serial keys from the registry */
|
||||||
|
m_AppConfig->setSerialKey("");
|
||||||
|
m_AppConfig->setEdition(kUnregistered);
|
||||||
|
m_AppConfig->saveSettings();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::pair<bool, QString>
|
||||||
|
LicenseManager::setSerialKey(QString serialKeyString)
|
||||||
|
{
|
||||||
|
std::pair<bool, QString> ret (true, "");
|
||||||
|
|
||||||
|
SerialKey serialKey (serialKeyString.toStdString());
|
||||||
|
if (serialKey.isExpired(::time(0))) {
|
||||||
|
ret.first = false;
|
||||||
|
ret.second = "Serial key expired";
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (serialKey != m_serialKey) {
|
||||||
|
using std::swap;
|
||||||
|
swap (serialKey, m_serialKey);
|
||||||
|
|
||||||
|
m_AppConfig->setSerialKey (serialKeyString);
|
||||||
|
notifyActivation ("serial:" + serialKeyString);
|
||||||
|
emit serialKeyChanged (m_serialKey);
|
||||||
|
|
||||||
|
if (m_serialKey.edition() != serialKey.edition()) {
|
||||||
|
m_AppConfig->setEdition (m_serialKey.edition());
|
||||||
|
emit editionChanged (m_serialKey.edition());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (serialKey.isTrial()) {
|
||||||
|
emit endTrial(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_serialKey.isTrial()) {
|
||||||
|
emit beginTrial(m_serialKey.isExpiring(::time(0)));
|
||||||
|
}
|
||||||
|
|
||||||
|
m_AppConfig->saveSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
Edition
|
||||||
|
LicenseManager::activeEdition() const
|
||||||
|
{
|
||||||
|
return m_serialKey.edition();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString
|
||||||
|
LicenseManager::activeEditionName() const
|
||||||
|
{
|
||||||
|
return getEditionName(activeEdition(), m_serialKey.isTrial());
|
||||||
|
}
|
||||||
|
|
||||||
|
SerialKey
|
||||||
|
LicenseManager::serialKey() const
|
||||||
|
{
|
||||||
|
return m_serialKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LicenseManager::refresh() const
|
||||||
|
{
|
||||||
|
emit serialKeyChanged (m_serialKey);
|
||||||
|
emit editionChanged (m_serialKey.edition());
|
||||||
|
if (m_serialKey.isTrial()) {
|
||||||
|
emit beginTrial(m_serialKey.isExpiring(::time(0)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void LicenseManager::skipActivation()
|
||||||
|
{
|
||||||
|
notifyActivation ("skip:unknown");
|
||||||
|
}
|
||||||
|
|
||||||
|
QString
|
||||||
|
LicenseManager::getEditionName(Edition const edition, bool trial)
|
||||||
|
{
|
||||||
|
std::string name ("Synergy ");
|
||||||
|
switch (edition) {
|
||||||
|
case kUnregistered:
|
||||||
|
name += "(UNREGISTERED)";
|
||||||
|
return QString::fromUtf8 (name.c_str(), name.size());
|
||||||
|
case kBasic:
|
||||||
|
name += "Basic";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
name += "Pro";
|
||||||
|
}
|
||||||
|
if (trial) {
|
||||||
|
name += " (Trial)";
|
||||||
|
}
|
||||||
|
return QString::fromUtf8 (name.c_str(), name.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
void LicenseManager::notifyActivation(QString identity)
|
||||||
|
{
|
||||||
|
ActivationNotifier* notifier = new ActivationNotifier();
|
||||||
|
notifier->setIdentity(identity);
|
||||||
|
|
||||||
|
QThread* thread = new QThread();
|
||||||
|
connect(notifier, SIGNAL(finished()), thread, SLOT(quit()));
|
||||||
|
connect(notifier, SIGNAL(finished()), notifier, SLOT(deleteLater()));
|
||||||
|
connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
|
||||||
|
|
||||||
|
notifier->moveToThread(thread);
|
||||||
|
thread->start();
|
||||||
|
|
||||||
|
QMetaObject::invokeMethod(notifier, "notify", Qt::QueuedConnection);
|
||||||
|
}
|
|
@ -24,30 +24,30 @@
|
||||||
|
|
||||||
class AppConfig;
|
class AppConfig;
|
||||||
|
|
||||||
class SubscriptionManager: public QObject
|
class LicenseManager: public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SubscriptionManager(AppConfig* appConfig);
|
LicenseManager(AppConfig* appConfig);
|
||||||
std::pair<bool, QString> setSerialKey(QString serialKey);
|
std::pair<bool, QString> setSerialKey(QString serialKey);
|
||||||
void refresh() const;
|
void refresh() const;
|
||||||
Edition activeEdition() const;
|
Edition activeEdition() const;
|
||||||
QString activeEditionName() const;
|
QString activeEditionName() const;
|
||||||
SerialKey serialKey() const;
|
SerialKey serialKey() const;
|
||||||
void skipActivation();
|
void skipActivation();
|
||||||
static QString getEditionName(Edition edition, bool trial = false);
|
static QString getEditionName(Edition edition, bool trial = false);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void notifyActivation(QString identity);
|
void notifyActivation(QString identity);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AppConfig* m_AppConfig;
|
AppConfig* m_AppConfig;
|
||||||
SerialKey m_serialKey;
|
SerialKey m_serialKey;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void serialKeyChanged (SerialKey) const;
|
void serialKeyChanged (SerialKey) const;
|
||||||
void editionChanged (Edition) const;
|
void editionChanged (Edition) const;
|
||||||
void beginTrial (bool expiring) const;
|
void beginTrial (bool expiring) const;
|
||||||
void endTrial (bool expired) const;
|
void endTrial (bool expired) const;
|
||||||
};
|
};
|
|
@ -30,7 +30,7 @@
|
||||||
#include "ZeroconfService.h"
|
#include "ZeroconfService.h"
|
||||||
#include "DataDownloader.h"
|
#include "DataDownloader.h"
|
||||||
#include "CommandProcess.h"
|
#include "CommandProcess.h"
|
||||||
#include "SubscriptionManager.h"
|
#include "LicenseManager.h"
|
||||||
#include "EditionType.h"
|
#include "EditionType.h"
|
||||||
#include "QUtility.h"
|
#include "QUtility.h"
|
||||||
#include "ProcessorArch.h"
|
#include "ProcessorArch.h"
|
||||||
|
@ -77,10 +77,10 @@ static const char* synergyIconFiles[] =
|
||||||
};
|
};
|
||||||
|
|
||||||
MainWindow::MainWindow(QSettings& settings, AppConfig& appConfig,
|
MainWindow::MainWindow(QSettings& settings, AppConfig& appConfig,
|
||||||
SubscriptionManager& subscriptionManager) :
|
LicenseManager& licenseManager) :
|
||||||
m_Settings(settings),
|
m_Settings(settings),
|
||||||
m_AppConfig(&appConfig),
|
m_AppConfig(&appConfig),
|
||||||
m_SubscriptionManager(&subscriptionManager),
|
m_LicenseManager(&licenseManager),
|
||||||
m_pSynergy(NULL),
|
m_pSynergy(NULL),
|
||||||
m_SynergyState(synergyDisconnected),
|
m_SynergyState(synergyDisconnected),
|
||||||
m_ServerConfig(&m_Settings, 5, 3, m_AppConfig->screenName(), this),
|
m_ServerConfig(&m_Settings, 5, 3, m_AppConfig->screenName(), this),
|
||||||
|
@ -142,19 +142,19 @@ MainWindow::MainWindow(QSettings& settings, AppConfig& appConfig,
|
||||||
connect (this, SIGNAL(windowShown()),
|
connect (this, SIGNAL(windowShown()),
|
||||||
this, SLOT(on_windowShown()), Qt::QueuedConnection);
|
this, SLOT(on_windowShown()), Qt::QueuedConnection);
|
||||||
|
|
||||||
connect (m_SubscriptionManager, SIGNAL(editionChanged(Edition)),
|
connect (m_LicenseManager, SIGNAL(editionChanged(Edition)),
|
||||||
this, SLOT(setEdition(Edition)), Qt::QueuedConnection);
|
this, SLOT(setEdition(Edition)), Qt::QueuedConnection);
|
||||||
|
|
||||||
connect (m_SubscriptionManager, SIGNAL(beginTrial(bool)),
|
connect (m_LicenseManager, SIGNAL(beginTrial(bool)),
|
||||||
this, SLOT(beginTrial(bool)), Qt::QueuedConnection);
|
this, SLOT(beginTrial(bool)), Qt::QueuedConnection);
|
||||||
|
|
||||||
connect (m_SubscriptionManager, SIGNAL(endTrial(bool)),
|
connect (m_LicenseManager, SIGNAL(endTrial(bool)),
|
||||||
this, SLOT(endTrial(bool)), Qt::QueuedConnection);
|
this, SLOT(endTrial(bool)), Qt::QueuedConnection);
|
||||||
|
|
||||||
connect (m_AppConfig, SIGNAL(sslToggled(bool)),
|
connect (m_AppConfig, SIGNAL(sslToggled(bool)),
|
||||||
this, SLOT(sslToggled(bool)), Qt::QueuedConnection);
|
this, SLOT(sslToggled(bool)), Qt::QueuedConnection);
|
||||||
|
|
||||||
m_SubscriptionManager->refresh();
|
m_LicenseManager->refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
|
@ -447,7 +447,7 @@ void MainWindow::checkConnected(const QString& line)
|
||||||
void MainWindow::checkLicense(const QString &line)
|
void MainWindow::checkLicense(const QString &line)
|
||||||
{
|
{
|
||||||
if (line.contains("trial has expired")) {
|
if (line.contains("trial has expired")) {
|
||||||
m_SubscriptionManager->refresh();
|
m_LicenseManager->refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1049,7 +1049,7 @@ void MainWindow::serverDetected(const QString name)
|
||||||
|
|
||||||
void MainWindow::setEdition(Edition edition)
|
void MainWindow::setEdition(Edition edition)
|
||||||
{
|
{
|
||||||
setWindowTitle(m_SubscriptionManager->getEditionName (edition));
|
setWindowTitle(m_LicenseManager->getEditionName (edition));
|
||||||
if (m_AppConfig->getCryptoEnabled()) {
|
if (m_AppConfig->getCryptoEnabled()) {
|
||||||
m_pSslCertificate = new SslCertificate(this);
|
m_pSslCertificate = new SslCertificate(this);
|
||||||
m_pSslCertificate->generateCertificate();
|
m_pSslCertificate->generateCertificate();
|
||||||
|
@ -1069,11 +1069,11 @@ void MainWindow::beginTrial(bool isExpiring)
|
||||||
" color:#0000ff;\">Buy now!</span></a>"
|
" color:#0000ff;\">Buy now!</span></a>"
|
||||||
"</p></body></html>";
|
"</p></body></html>";
|
||||||
expiringNotice = expiringNotice.arg
|
expiringNotice = expiringNotice.arg
|
||||||
(m_SubscriptionManager->serialKey().daysLeft(::time(0)));
|
(m_LicenseManager->serialKey().daysLeft(::time(0)));
|
||||||
this->m_trialLabel->setText(expiringNotice);
|
this->m_trialLabel->setText(expiringNotice);
|
||||||
this->m_trialWidget->show();
|
this->m_trialWidget->show();
|
||||||
}
|
}
|
||||||
setWindowTitle (m_SubscriptionManager->activeEditionName());
|
setWindowTitle (m_LicenseManager->activeEditionName());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::endTrial(bool isExpired)
|
void MainWindow::endTrial(bool isExpired)
|
||||||
|
@ -1081,7 +1081,7 @@ void MainWindow::endTrial(bool isExpired)
|
||||||
if (!isExpired) {
|
if (!isExpired) {
|
||||||
this->m_trialWidget->hide();
|
this->m_trialWidget->hide();
|
||||||
}
|
}
|
||||||
setWindowTitle (m_SubscriptionManager->activeEditionName());
|
setWindowTitle (m_LicenseManager->activeEditionName());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::updateLocalFingerprint()
|
void MainWindow::updateLocalFingerprint()
|
||||||
|
@ -1097,10 +1097,10 @@ void MainWindow::updateLocalFingerprint()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SubscriptionManager&
|
LicenseManager&
|
||||||
MainWindow::subscriptionManager() const
|
MainWindow::licenseManager() const
|
||||||
{
|
{
|
||||||
return *m_SubscriptionManager;
|
return *m_LicenseManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_m_pGroupClient_toggled(bool on)
|
void MainWindow::on_m_pGroupClient_toggled(bool on)
|
||||||
|
@ -1204,7 +1204,7 @@ void MainWindow::on_m_pButtonConfigureServer_clicked()
|
||||||
|
|
||||||
void MainWindow::on_m_pActivate_triggered()
|
void MainWindow::on_m_pActivate_triggered()
|
||||||
{
|
{
|
||||||
ActivationDialog activationDialog(this, appConfig(), subscriptionManager());
|
ActivationDialog activationDialog(this, appConfig(), licenseManager());
|
||||||
activationDialog.exec();
|
activationDialog.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1423,7 +1423,7 @@ void MainWindow::bonjourInstallFinished()
|
||||||
void MainWindow::on_windowShown()
|
void MainWindow::on_windowShown()
|
||||||
{
|
{
|
||||||
if (!m_AppConfig->activationHasRun() && (m_AppConfig->edition() == kUnregistered)) {
|
if (!m_AppConfig->activationHasRun() && (m_AppConfig->edition() == kUnregistered)) {
|
||||||
ActivationDialog activationDialog (this, appConfig(), subscriptionManager());
|
ActivationDialog activationDialog (this, appConfig(), licenseManager());
|
||||||
activationDialog.exec();
|
activationDialog.exec();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ class ZeroconfService;
|
||||||
class DataDownloader;
|
class DataDownloader;
|
||||||
class CommandProcess;
|
class CommandProcess;
|
||||||
class SslCertificate;
|
class SslCertificate;
|
||||||
class SubscriptionManager;
|
class LicenseManager;
|
||||||
|
|
||||||
class MainWindow : public QMainWindow, public Ui::MainWindowBase
|
class MainWindow : public QMainWindow, public Ui::MainWindowBase
|
||||||
{
|
{
|
||||||
|
@ -96,7 +96,7 @@ class MainWindow : public QMainWindow, public Ui::MainWindowBase
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MainWindow(QSettings& settings, AppConfig& appConfig,
|
MainWindow(QSettings& settings, AppConfig& appConfig,
|
||||||
SubscriptionManager& subscriptionManager);
|
LicenseManager& licenseManager);
|
||||||
~MainWindow();
|
~MainWindow();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -118,7 +118,7 @@ class MainWindow : public QMainWindow, public Ui::MainWindowBase
|
||||||
void updateZeroconfService();
|
void updateZeroconfService();
|
||||||
void serverDetected(const QString name);
|
void serverDetected(const QString name);
|
||||||
void updateLocalFingerprint();
|
void updateLocalFingerprint();
|
||||||
SubscriptionManager& subscriptionManager() const;
|
LicenseManager& licenseManager() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setEdition(Edition edition);
|
void setEdition(Edition edition);
|
||||||
|
@ -195,7 +195,7 @@ class MainWindow : public QMainWindow, public Ui::MainWindowBase
|
||||||
private:
|
private:
|
||||||
QSettings& m_Settings;
|
QSettings& m_Settings;
|
||||||
AppConfig* m_AppConfig;
|
AppConfig* m_AppConfig;
|
||||||
SubscriptionManager* m_SubscriptionManager;
|
LicenseManager* m_LicenseManager;
|
||||||
QProcess* m_pSynergy;
|
QProcess* m_pSynergy;
|
||||||
int m_SynergyState;
|
int m_SynergyState;
|
||||||
ServerConfig m_ServerConfig;
|
ServerConfig m_ServerConfig;
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
#include "WebClient.h"
|
#include "WebClient.h"
|
||||||
#include "ActivationNotifier.h"
|
#include "ActivationNotifier.h"
|
||||||
#include "SubscriptionManager.h"
|
#include "LicenseManager.h"
|
||||||
#include "EditionType.h"
|
#include "EditionType.h"
|
||||||
#include "QSynergyApplication.h"
|
#include "QSynergyApplication.h"
|
||||||
#include "QUtility.h"
|
#include "QUtility.h"
|
||||||
|
|
|
@ -1,144 +0,0 @@
|
||||||
/*
|
|
||||||
* 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/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "SubscriptionManager.h"
|
|
||||||
#include "EditionType.h"
|
|
||||||
#include "AppConfig.h"
|
|
||||||
#include <ctime>
|
|
||||||
#include <stdexcept>
|
|
||||||
#include <utility>
|
|
||||||
#include <QThread>
|
|
||||||
|
|
||||||
SubscriptionManager::SubscriptionManager(AppConfig* appConfig) :
|
|
||||||
m_AppConfig(appConfig),
|
|
||||||
m_serialKey(appConfig->edition()) {
|
|
||||||
try {
|
|
||||||
setSerialKey(m_AppConfig->serialKey());
|
|
||||||
} catch (...) {
|
|
||||||
/* Remove garbage serial keys from the registry */
|
|
||||||
m_AppConfig->setSerialKey("");
|
|
||||||
m_AppConfig->setEdition(kUnregistered);
|
|
||||||
m_AppConfig->saveSettings();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::pair<bool, QString>
|
|
||||||
SubscriptionManager::setSerialKey(QString serialKeyString)
|
|
||||||
{
|
|
||||||
std::pair<bool, QString> ret (true, "");
|
|
||||||
|
|
||||||
SerialKey serialKey (serialKeyString.toStdString());
|
|
||||||
if (serialKey.isExpired(::time(0))) {
|
|
||||||
ret.first = false;
|
|
||||||
ret.second = "Serial key expired";
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (serialKey != m_serialKey) {
|
|
||||||
using std::swap;
|
|
||||||
swap (serialKey, m_serialKey);
|
|
||||||
|
|
||||||
m_AppConfig->setSerialKey (serialKeyString);
|
|
||||||
notifyActivation ("serial:" + serialKeyString);
|
|
||||||
emit serialKeyChanged (m_serialKey);
|
|
||||||
|
|
||||||
if (m_serialKey.edition() != serialKey.edition()) {
|
|
||||||
m_AppConfig->setEdition (m_serialKey.edition());
|
|
||||||
emit editionChanged (m_serialKey.edition());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (serialKey.isTrial()) {
|
|
||||||
emit endTrial(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_serialKey.isTrial()) {
|
|
||||||
emit beginTrial(m_serialKey.isExpiring(::time(0)));
|
|
||||||
}
|
|
||||||
|
|
||||||
m_AppConfig->saveSettings();
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
Edition
|
|
||||||
SubscriptionManager::activeEdition() const
|
|
||||||
{
|
|
||||||
return m_serialKey.edition();
|
|
||||||
}
|
|
||||||
|
|
||||||
QString
|
|
||||||
SubscriptionManager::activeEditionName() const
|
|
||||||
{
|
|
||||||
return getEditionName(activeEdition(), m_serialKey.isTrial());
|
|
||||||
}
|
|
||||||
|
|
||||||
SerialKey
|
|
||||||
SubscriptionManager::serialKey() const
|
|
||||||
{
|
|
||||||
return m_serialKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SubscriptionManager::refresh() const
|
|
||||||
{
|
|
||||||
emit serialKeyChanged (m_serialKey);
|
|
||||||
emit editionChanged (m_serialKey.edition());
|
|
||||||
if (m_serialKey.isTrial()) {
|
|
||||||
emit beginTrial(m_serialKey.isExpiring(::time(0)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void SubscriptionManager::skipActivation()
|
|
||||||
{
|
|
||||||
notifyActivation ("skip:unknown");
|
|
||||||
}
|
|
||||||
|
|
||||||
QString
|
|
||||||
SubscriptionManager::getEditionName(Edition const edition, bool trial)
|
|
||||||
{
|
|
||||||
std::string name ("Synergy ");
|
|
||||||
switch (edition) {
|
|
||||||
case kUnregistered:
|
|
||||||
name += "(UNREGISTERED)";
|
|
||||||
return QString::fromUtf8 (name.c_str(), name.size());
|
|
||||||
case kBasic:
|
|
||||||
name += "Basic";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
name += "Pro";
|
|
||||||
}
|
|
||||||
if (trial) {
|
|
||||||
name += " (Trial)";
|
|
||||||
}
|
|
||||||
return QString::fromUtf8 (name.c_str(), name.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
void SubscriptionManager::notifyActivation(QString identity)
|
|
||||||
{
|
|
||||||
ActivationNotifier* notifier = new ActivationNotifier();
|
|
||||||
notifier->setIdentity(identity);
|
|
||||||
|
|
||||||
QThread* thread = new QThread();
|
|
||||||
connect(notifier, SIGNAL(finished()), thread, SLOT(quit()));
|
|
||||||
connect(notifier, SIGNAL(finished()), notifier, SLOT(deleteLater()));
|
|
||||||
connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
|
|
||||||
|
|
||||||
notifier->moveToThread(thread);
|
|
||||||
thread->start();
|
|
||||||
|
|
||||||
QMetaObject::invokeMethod(notifier, "notify", Qt::QueuedConnection);
|
|
||||||
}
|
|
|
@ -2,11 +2,11 @@
|
||||||
* synergy -- mouse and keyboard sharing utility
|
* synergy -- mouse and keyboard sharing utility
|
||||||
* Copyright (C) 2012-2016 Symless Ltd.
|
* Copyright (C) 2012-2016 Symless Ltd.
|
||||||
* Copyright (C) 2008 Volker Lanz (vl@fidra.de)
|
* Copyright (C) 2008 Volker Lanz (vl@fidra.de)
|
||||||
*
|
*
|
||||||
* This package is free software; you can redistribute it and/or
|
* This package is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
* found in the file LICENSE that should have accompanied this file.
|
* found in the file LICENSE that should have accompanied this file.
|
||||||
*
|
*
|
||||||
* This package is distributed in the hope that it will be useful,
|
* This package is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
#define TRAY_RETRY_WAIT 2000
|
#define TRAY_RETRY_WAIT 2000
|
||||||
|
|
||||||
#include "QSynergyApplication.h"
|
#include "QSynergyApplication.h"
|
||||||
#include "SubscriptionManager.h"
|
#include "LicenseManager.h"
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
#include "AppConfig.h"
|
#include "AppConfig.h"
|
||||||
#include "SetupWizard.h"
|
#include "SetupWizard.h"
|
||||||
|
@ -66,7 +66,7 @@ int main(int argc, char* argv[])
|
||||||
"Please drag Synergy to the Applications folder, and open it from there.");
|
"Please drag Synergy to the Applications folder, and open it from there.");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!checkMacAssistiveDevices())
|
if (!checkMacAssistiveDevices())
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -85,11 +85,11 @@ int main(int argc, char* argv[])
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
AppConfig appConfig (&settings);
|
AppConfig appConfig (&settings);
|
||||||
qRegisterMetaType<Edition>("Edition");
|
qRegisterMetaType<Edition>("Edition");
|
||||||
SubscriptionManager subscriptionManager (&appConfig);
|
LicenseManager licenseManager (&appConfig);
|
||||||
|
|
||||||
app.switchTranslator(appConfig.language());
|
app.switchTranslator(appConfig.language());
|
||||||
|
|
||||||
MainWindow mainWindow(settings, appConfig, subscriptionManager);
|
MainWindow mainWindow(settings, appConfig, licenseManager);
|
||||||
SetupWizard setupWizard(mainWindow, true);
|
SetupWizard setupWizard(mainWindow, true);
|
||||||
|
|
||||||
if (appConfig.wizardShouldRun())
|
if (appConfig.wizardShouldRun())
|
||||||
|
|
Loading…
Reference in New Issue