Use core interface to activate subscription in wizard #4715
This commit is contained in:
parent
85ef7935cc
commit
3bc46dca2d
|
@ -61,8 +61,8 @@ SOURCES += src/main.cpp \
|
|||
src/SslCertificate.cpp \
|
||||
src/Plugin.cpp \
|
||||
src/WebClient.cpp \
|
||||
../lib/common/PluginVersion.cpp
|
||||
|
||||
../lib/common/PluginVersion.cpp \
|
||||
src/SubscriptionManager.cpp
|
||||
HEADERS += src/MainWindow.h \
|
||||
src/AboutDialog.h \
|
||||
src/ServerConfig.h \
|
||||
|
@ -108,8 +108,8 @@ HEADERS += src/MainWindow.h \
|
|||
src/SslCertificate.h \
|
||||
src/Plugin.h \
|
||||
src/WebClient.h \
|
||||
../lib/common/PluginVersion.h
|
||||
|
||||
../lib/common/PluginVersion.h \
|
||||
src/SubscriptionManager.h
|
||||
RESOURCES += res/Synergy.qrc
|
||||
RC_FILE = res/win/Synergy.rc
|
||||
macx {
|
||||
|
|
|
@ -227,7 +227,7 @@
|
|||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButton">
|
||||
<widget class="QRadioButton" name="m_pRadioButtonSubscription">
|
||||
<property name="text">
|
||||
<string>Subscription</string>
|
||||
</property>
|
||||
|
|
|
@ -51,6 +51,20 @@ QString CoreInterface::getArch()
|
|||
return run(args);
|
||||
}
|
||||
|
||||
QString CoreInterface::activateSerial(const QString& serial)
|
||||
{
|
||||
QStringList args("--subscription-serial");
|
||||
args << serial;
|
||||
|
||||
return run(args);
|
||||
}
|
||||
|
||||
QString CoreInterface::checkSubscription()
|
||||
{
|
||||
QStringList args("--check-subscription");
|
||||
return run(args);
|
||||
}
|
||||
|
||||
QString CoreInterface::run(const QStringList& args, const QString& input)
|
||||
{
|
||||
QString program(
|
||||
|
|
|
@ -28,5 +28,7 @@ public:
|
|||
QString getProfileDir();
|
||||
QString getInstalledDir();
|
||||
QString getArch();
|
||||
QString activateSerial(const QString& serial);
|
||||
QString checkSubscription();
|
||||
QString run(const QStringList& args, const QString& input = "");
|
||||
};
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "SslCertificate.h"
|
||||
#include "PluginManager.h"
|
||||
#include "MainWindow.h"
|
||||
#include "EditionType.h"
|
||||
|
||||
#include <QMovie>
|
||||
#include <QThread>
|
||||
|
@ -29,6 +30,7 @@
|
|||
PluginWizardPage::PluginWizardPage(MainWindow& mainWindow, QWidget *parent) :
|
||||
QWizardPage(parent),
|
||||
m_Finished(false),
|
||||
m_Edition(Unknown),
|
||||
m_pSslCertificate(NULL),
|
||||
m_mainWindow(mainWindow)
|
||||
{
|
||||
|
@ -62,8 +64,8 @@ void PluginWizardPage::initializePage()
|
|||
{
|
||||
QWizardPage::initializePage();
|
||||
|
||||
if (m_Email.isEmpty() ||
|
||||
m_Password.isEmpty()) {
|
||||
if (m_Edition == Unknown ||
|
||||
m_Edition == Basic) {
|
||||
updateStatus(tr("Setup complete."));
|
||||
showFinished();
|
||||
return;
|
||||
|
|
|
@ -36,8 +36,7 @@ public:
|
|||
~PluginWizardPage();
|
||||
|
||||
void setFinished(bool b) { m_Finished = b; }
|
||||
void setEmail(QString e) { m_Email = e; }
|
||||
void setPassword(QString p) { m_Password = p; }
|
||||
void setEdition(int edition) { m_Edition = edition; }
|
||||
|
||||
bool isComplete() const;
|
||||
void initializePage();
|
||||
|
@ -58,8 +57,7 @@ private:
|
|||
|
||||
private:
|
||||
bool m_Finished;
|
||||
QString m_Email;
|
||||
QString m_Password;
|
||||
int m_Edition;
|
||||
PluginManager m_PluginManager;
|
||||
SslCertificate* m_pSslCertificate;
|
||||
QThread* m_pThread;
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "SetupWizard.h"
|
||||
#include "MainWindow.h"
|
||||
#include "WebClient.h"
|
||||
#include "SubscriptionManager.h"
|
||||
#include "EditionType.h"
|
||||
#include "QSynergyApplication.h"
|
||||
#include "QUtility.h"
|
||||
|
@ -85,7 +86,7 @@ bool SetupWizard::validateCurrentPage()
|
|||
}
|
||||
else {
|
||||
WebClient webClient;
|
||||
m_Edition = webClient .getEdition(
|
||||
m_Edition = webClient.getEdition(
|
||||
m_pLineEditEmail->text(),
|
||||
m_pLineEditPassword->text(),
|
||||
message,
|
||||
|
@ -95,12 +96,36 @@ bool SetupWizard::validateCurrentPage()
|
|||
return false;
|
||||
}
|
||||
else {
|
||||
m_pPluginPage->setEmail(m_pLineEditEmail->text());
|
||||
m_pPluginPage->setPassword(m_pLineEditPassword->text());
|
||||
m_pPluginPage->setEdition(m_Edition);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (m_pRadioButtonSubscription->isChecked()) {
|
||||
if (m_pLineEditSerialKey->text().isEmpty()) {
|
||||
message.setText(tr("Please enter your subscription serial key."));
|
||||
message.exec();
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
// plugin page no longer requires email and password
|
||||
// create subscription file in profile directory
|
||||
SubscriptionManager subscriptionManager;
|
||||
bool r = subscriptionManager.activateSerial(m_pLineEditSerialKey->text());
|
||||
if (!r) {
|
||||
return r;
|
||||
}
|
||||
|
||||
// check if the serial is valid
|
||||
r = subscriptionManager.checkSubscription(m_Edition);
|
||||
|
||||
if (r) {
|
||||
m_pPluginPage->setEdition(m_Edition);
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
|
@ -170,6 +195,7 @@ void SetupWizard::accept()
|
|||
appConfig.setUserToken(hashResult);
|
||||
appConfig.setEdition(m_Edition);
|
||||
}
|
||||
|
||||
m_MainWindow.setEdition(m_Edition);
|
||||
m_MainWindow.updateLocalFingerprint();
|
||||
|
||||
|
@ -221,7 +247,7 @@ void SetupWizard::on_m_pRadioButtonActivate_toggled(bool checked)
|
|||
}
|
||||
}
|
||||
|
||||
void SetupWizard::on_radioButton_toggled(bool checked)
|
||||
void SetupWizard::on_m_pRadioButtonSubscription_toggled(bool checked)
|
||||
{
|
||||
if (checked) {
|
||||
m_pLineEditEmail->setEnabled(false);
|
||||
|
|
|
@ -47,7 +47,7 @@ private:
|
|||
PluginWizardPage* m_pPluginPage;
|
||||
|
||||
private slots:
|
||||
void on_radioButton_toggled(bool checked);
|
||||
void on_m_pRadioButtonSubscription_toggled(bool checked);
|
||||
void on_m_pRadioButtonActivate_toggled(bool checked);
|
||||
void on_m_pRadioButtonSkip_toggled(bool checked);
|
||||
void on_m_pComboLanguage_currentIndexChanged(int index);
|
||||
|
|
|
@ -0,0 +1,88 @@
|
|||
/*
|
||||
* 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 "CoreInterface.h"
|
||||
#include "EditionType.h"
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
SubscriptionManager::SubscriptionManager()
|
||||
{
|
||||
}
|
||||
|
||||
bool SubscriptionManager::activateSerial(const QString& serial)
|
||||
{
|
||||
CoreInterface coreInterface;
|
||||
|
||||
try
|
||||
{
|
||||
coreInterface.activateSerial(serial);
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
showErrorDialog(e.what());
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SubscriptionManager::checkSubscription(int& edition)
|
||||
{
|
||||
edition = Unknown;
|
||||
CoreInterface coreInterface;
|
||||
QString output;
|
||||
try
|
||||
{
|
||||
output = coreInterface.checkSubscription();
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
showErrorDialog(e.what());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (output.contains("subscription will expire soon")) {
|
||||
QMessageBox::warning(
|
||||
this, tr("Activate Subscription"),
|
||||
tr("Your subscription will be expired soon."));
|
||||
}
|
||||
|
||||
edition = getEditionType(output);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void SubscriptionManager::showErrorDialog(const QString& errorMsg)
|
||||
{
|
||||
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));
|
||||
}
|
||||
|
||||
int SubscriptionManager::getEditionType(QString& string)
|
||||
{
|
||||
if (string.contains("full subscription valid")) {
|
||||
return Pro;
|
||||
}
|
||||
|
||||
return Unknown;
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class SubscriptionManager : public QWidget
|
||||
{
|
||||
public:
|
||||
SubscriptionManager();
|
||||
|
||||
bool activateSerial(const QString& serial);
|
||||
bool checkSubscription(int& edition);
|
||||
|
||||
private:
|
||||
void showErrorDialog(const QString& errorMsg);
|
||||
int getEditionType(QString& string);
|
||||
};
|
Loading…
Reference in New Issue