#5629 Complete activation support for activation dialog
This commit is contained in:
parent
60a4e62779
commit
0f95c6e941
|
@ -11,7 +11,7 @@
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Dialog</string>
|
<string>Activate Synergy</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
|
@ -51,17 +51,11 @@
|
||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<widget class="QLineEdit" name="m_pLineEditEmail">
|
<widget class="QLineEdit" name="m_pLineEditEmail">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>200</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="echoMode">
|
<property name="echoMode">
|
||||||
<enum>QLineEdit::Normal</enum>
|
<enum>QLineEdit::Normal</enum>
|
||||||
</property>
|
</property>
|
||||||
|
@ -77,17 +71,11 @@
|
||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="QLineEdit" name="m_pLineEditPassword">
|
<widget class="QLineEdit" name="m_pLineEditPassword">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>200</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="echoMode">
|
<property name="echoMode">
|
||||||
<enum>QLineEdit::Password</enum>
|
<enum>QLineEdit::Password</enum>
|
||||||
</property>
|
</property>
|
||||||
|
@ -120,6 +108,9 @@
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTextEdit" name="m_pTextEditSerialKey">
|
<widget class="QTextEdit" name="m_pTextEditSerialKey">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
<property name="html">
|
<property name="html">
|
||||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||||
|
@ -127,6 +118,9 @@ p, li { white-space: pre-wrap; }
|
||||||
</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;">
|
</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;">
|
||||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html></string>
|
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html></string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="acceptRichText">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>400</width>
|
<width>400</width>
|
||||||
<height>156</height>
|
<height>165</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
|
|
@ -1,12 +1,44 @@
|
||||||
#include "ActivationDialog.h"
|
#include "ActivationDialog.h"
|
||||||
#include "ui_ActivationDialog.h"
|
#include "ui_ActivationDialog.h"
|
||||||
#include "CancelActivationDialog.h"
|
#include "CancelActivationDialog.h"
|
||||||
|
#include "AppConfig.h"
|
||||||
|
#include "WebClient.h"
|
||||||
|
#include "EditionType.h"
|
||||||
|
#include "ActivationNotifier.h"
|
||||||
|
#include "MainWindow.h"
|
||||||
|
#include "QUtility.h"
|
||||||
|
#include "SubscriptionManager.h"
|
||||||
|
|
||||||
ActivationDialog::ActivationDialog(QWidget *parent) :
|
#include <QMessageBox>
|
||||||
|
#include <QThread>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
ActivationDialog::ActivationDialog(QWidget* parent, AppConfig& appConfig) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
ui(new Ui::ActivationDialog)
|
ui(new Ui::ActivationDialog),
|
||||||
|
m_appConfig (&appConfig)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
ui->m_pLineEditEmail->setText(appConfig.activateEmail());
|
||||||
|
ui->m_pTextEditSerialKey->setText(appConfig.serialKey());
|
||||||
|
|
||||||
|
if (!appConfig.serialKey().isEmpty()) {
|
||||||
|
ui->m_pRadioButtonActivate->setAutoExclusive(false);
|
||||||
|
ui->m_pRadioButtonSubscription->setAutoExclusive(false);
|
||||||
|
ui->m_pRadioButtonActivate->setChecked(false);
|
||||||
|
ui->m_pRadioButtonSubscription->setChecked(true);
|
||||||
|
ui->m_pRadioButtonActivate->setAutoExclusive(true);
|
||||||
|
ui->m_pRadioButtonSubscription->setAutoExclusive(true);
|
||||||
|
ui->m_pTextEditSerialKey->setFocus();
|
||||||
|
ui->m_pTextEditSerialKey->moveCursor(QTextCursor::End);
|
||||||
|
} else {
|
||||||
|
if (ui->m_pLineEditEmail->text().isEmpty()) {
|
||||||
|
ui->m_pLineEditEmail->setFocus();
|
||||||
|
} else {
|
||||||
|
ui->m_pLineEditPassword->setFocus();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ActivationDialog::~ActivationDialog()
|
ActivationDialog::~ActivationDialog()
|
||||||
|
@ -14,10 +46,121 @@ ActivationDialog::~ActivationDialog()
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ActivationDialog::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);
|
||||||
|
}
|
||||||
|
|
||||||
void ActivationDialog::reject()
|
void ActivationDialog::reject()
|
||||||
{
|
{
|
||||||
CancelActivationDialog cancelActivationDialog(this);
|
CancelActivationDialog cancelActivationDialog(this);
|
||||||
if (QDialog::Accepted == cancelActivationDialog.exec()) {
|
if (QDialog::Accepted == cancelActivationDialog.exec()) {
|
||||||
|
notifyActivation("skip:unknown");
|
||||||
QDialog::reject();
|
QDialog::reject();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ActivationDialog::on_m_pRadioButtonSubscription_toggled(bool checked)
|
||||||
|
{
|
||||||
|
if (checked) {
|
||||||
|
ui->m_pLineEditEmail->setEnabled(false);
|
||||||
|
ui->m_pLineEditPassword->setEnabled(false);
|
||||||
|
ui->m_pTextEditSerialKey->setEnabled(true);
|
||||||
|
ui->m_pTextEditSerialKey->setFocus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ActivationDialog::on_m_pRadioButtonActivate_toggled(bool checked)
|
||||||
|
{
|
||||||
|
if (checked) {
|
||||||
|
ui->m_pLineEditEmail->setEnabled(true);
|
||||||
|
ui->m_pLineEditPassword->setEnabled(true);
|
||||||
|
ui->m_pTextEditSerialKey->setEnabled(false);
|
||||||
|
if (ui->m_pLineEditEmail->text().isEmpty()) {
|
||||||
|
ui->m_pLineEditEmail->setFocus();
|
||||||
|
} else {
|
||||||
|
ui->m_pLineEditPassword->setFocus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ActivationDialog::accept()
|
||||||
|
{
|
||||||
|
QMessageBox message;
|
||||||
|
QString error;
|
||||||
|
int edition = Unregistered;
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (ui->m_pRadioButtonActivate->isChecked()) {
|
||||||
|
WebClient webClient;
|
||||||
|
QString email = ui->m_pLineEditEmail->text();
|
||||||
|
QString password = ui->m_pLineEditPassword->text();
|
||||||
|
|
||||||
|
if (!webClient.setEmail (email, error)) {
|
||||||
|
message.critical (this, "Invalid Email Address", tr("%1").arg(error));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (!webClient.setPassword (password, error)) {
|
||||||
|
message.critical (this, "Invalid Password", tr("%1").arg(error));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (!webClient.getEdition (edition, error)) {
|
||||||
|
message.critical (this, "Activation Error",
|
||||||
|
tr("An error occurred while trying to activate Synergy. "
|
||||||
|
"The Symless server returned the following error:\n\n%1").arg(error));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_appConfig->setActivateEmail (email);
|
||||||
|
m_appConfig->clearSerialKey();
|
||||||
|
ui->m_pTextEditSerialKey->clear();
|
||||||
|
notifyActivation ("login:" + m_appConfig->activateEmail());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
QString serialKey = ui->m_pTextEditSerialKey->toPlainText();
|
||||||
|
|
||||||
|
if (!m_appConfig->setSerialKey (serialKey, error)) {
|
||||||
|
message.critical (this, "Invalid Serial Key", tr("%1").arg(error));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SubscriptionManager subscriptionManager (this, *m_appConfig, edition);
|
||||||
|
if (!subscriptionManager.activateSerial (serialKey)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_appConfig->setActivateEmail("");
|
||||||
|
notifyActivation ("serial:" + m_appConfig->serialKey());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (std::exception& e) {
|
||||||
|
message.critical (this, "Unknown Error",
|
||||||
|
tr("An error occurred while trying to activate Synergy. "
|
||||||
|
"Please contact the helpdesk, and provide the "
|
||||||
|
"following details.\n\n%1").arg(e.what()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_appConfig->setEdition(edition);
|
||||||
|
m_appConfig->saveSettings();
|
||||||
|
|
||||||
|
message.information (this, "Activated!",
|
||||||
|
tr("Thanks for activating %1!").arg
|
||||||
|
(getEditionName (edition)));
|
||||||
|
MainWindow& mainWindow = dynamic_cast<MainWindow&>(*this->parent());
|
||||||
|
mainWindow.setEdition(edition);
|
||||||
|
mainWindow.updateLocalFingerprint();
|
||||||
|
mainWindow.settings().sync();
|
||||||
|
|
||||||
|
QDialog::accept();
|
||||||
|
}
|
||||||
|
|
|
@ -7,19 +7,30 @@ namespace Ui {
|
||||||
class ActivationDialog;
|
class ActivationDialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class AppConfig;
|
||||||
|
|
||||||
class ActivationDialog : public QDialog
|
class ActivationDialog : public QDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ActivationDialog(QWidget *parent = 0);
|
explicit ActivationDialog(QWidget *parent, AppConfig& appConfig);
|
||||||
~ActivationDialog();
|
~ActivationDialog();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void reject();
|
void reject();
|
||||||
|
void accept();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void notifyActivation (QString identity);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::ActivationDialog *ui;
|
Ui::ActivationDialog *ui;
|
||||||
|
AppConfig* m_appConfig;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void on_m_pRadioButtonSubscription_toggled(bool checked);
|
||||||
|
void on_m_pRadioButtonActivate_toggled(bool checked);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ACTIVATIONDIALOG_H
|
#endif // ACTIVATIONDIALOG_H
|
||||||
|
|
|
@ -73,6 +73,18 @@ AppConfig::~AppConfig()
|
||||||
saveSettings();
|
saveSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QString &AppConfig::screenName() const { return m_ScreenName; }
|
||||||
|
|
||||||
|
int AppConfig::port() const { return m_Port; }
|
||||||
|
|
||||||
|
const QString &AppConfig::interface() const { return m_Interface; }
|
||||||
|
|
||||||
|
int AppConfig::logLevel() const { return m_LogLevel; }
|
||||||
|
|
||||||
|
bool AppConfig::logToFile() const { return m_LogToFile; }
|
||||||
|
|
||||||
|
const QString &AppConfig::logFilename() const { return m_LogFilename; }
|
||||||
|
|
||||||
QString AppConfig::synergyLogDir() const
|
QString AppConfig::synergyLogDir() const
|
||||||
{
|
{
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
|
@ -116,6 +128,16 @@ QString AppConfig::logLevelText() const
|
||||||
return logLevelNames[logLevel()];
|
return logLevelNames[logLevel()];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ProcessMode AppConfig::processMode() const { return m_ProcessMode; }
|
||||||
|
|
||||||
|
bool AppConfig::wizardShouldRun() const { return m_WizardLastRun < kWizardVersion; }
|
||||||
|
|
||||||
|
const QString &AppConfig::language() const { return m_Language; }
|
||||||
|
|
||||||
|
bool AppConfig::startedBefore() const { return m_StartedBefore; }
|
||||||
|
|
||||||
|
bool AppConfig::autoConfig() const { return m_AutoConfig; }
|
||||||
|
|
||||||
void AppConfig::loadSettings()
|
void AppConfig::loadSettings()
|
||||||
{
|
{
|
||||||
m_ScreenName = settings().value("screenName", QHostInfo::localHostName()).toString();
|
m_ScreenName = settings().value("screenName", QHostInfo::localHostName()).toString();
|
||||||
|
@ -135,7 +157,7 @@ void AppConfig::loadSettings()
|
||||||
}
|
}
|
||||||
m_ElevateMode = static_cast<ElevateMode>(elevateMode.toInt());
|
m_ElevateMode = static_cast<ElevateMode>(elevateMode.toInt());
|
||||||
m_AutoConfigPrompted = settings().value("autoConfigPrompted", false).toBool();
|
m_AutoConfigPrompted = settings().value("autoConfigPrompted", false).toBool();
|
||||||
m_Edition = settings().value("edition", Unknown).toInt();
|
m_Edition = settings().value("edition", Unregistered).toInt();
|
||||||
m_ActivateEmail = settings().value("activateEmail", "").toString();
|
m_ActivateEmail = settings().value("activateEmail", "").toString();
|
||||||
m_CryptoEnabled = settings().value("cryptoEnabled", false).toBool();
|
m_CryptoEnabled = settings().value("cryptoEnabled", false).toBool();
|
||||||
m_AutoHide = settings().value("autoHide", false).toBool();
|
m_AutoHide = settings().value("autoHide", false).toBool();
|
||||||
|
@ -168,17 +190,84 @@ void AppConfig::saveSettings()
|
||||||
settings().setValue("lastExpiringWarningTime", m_LastExpiringWarningTime);
|
settings().setValue("lastExpiringWarningTime", m_LastExpiringWarningTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QSettings &AppConfig::settings() { return *m_pSettings; }
|
||||||
|
|
||||||
|
void AppConfig::setScreenName(const QString &s) { m_ScreenName = s; }
|
||||||
|
|
||||||
|
void AppConfig::setPort(int i) { m_Port = i; }
|
||||||
|
|
||||||
|
void AppConfig::setInterface(const QString &s) { m_Interface = s; }
|
||||||
|
|
||||||
|
void AppConfig::setLogLevel(int i) { m_LogLevel = i; }
|
||||||
|
|
||||||
|
void AppConfig::setLogToFile(bool b) { m_LogToFile = b; }
|
||||||
|
|
||||||
|
void AppConfig::setLogFilename(const QString &s) { m_LogFilename = s; }
|
||||||
|
|
||||||
|
void AppConfig::setWizardHasRun() { m_WizardLastRun = kWizardVersion; }
|
||||||
|
|
||||||
|
void AppConfig::setLanguage(const QString language) { m_Language = language; }
|
||||||
|
|
||||||
|
void AppConfig::setStartedBefore(bool b) { m_StartedBefore = b; }
|
||||||
|
|
||||||
|
void AppConfig::setElevateMode(ElevateMode em) { m_ElevateMode = em; }
|
||||||
|
|
||||||
void AppConfig::setAutoConfig(bool autoConfig)
|
void AppConfig::setAutoConfig(bool autoConfig)
|
||||||
{
|
{
|
||||||
m_AutoConfig = autoConfig;
|
m_AutoConfig = autoConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool AppConfig::autoConfigPrompted() { return m_AutoConfigPrompted; }
|
||||||
|
|
||||||
void AppConfig::setAutoConfigPrompted(bool prompted)
|
void AppConfig::setAutoConfigPrompted(bool prompted)
|
||||||
{
|
{
|
||||||
m_AutoConfigPrompted = prompted;
|
m_AutoConfigPrompted = prompted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AppConfig::setEdition(int e) { m_Edition = e; }
|
||||||
|
|
||||||
|
int AppConfig::edition() { return m_Edition; }
|
||||||
|
|
||||||
|
bool AppConfig::setActivateEmail(QString e) {
|
||||||
|
m_ActivateEmail = e;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString AppConfig::activateEmail() { return m_ActivateEmail; }
|
||||||
|
|
||||||
|
bool AppConfig::setSerialKey(QString serial, QString& errorOut) {
|
||||||
|
if (serial.isEmpty()) {
|
||||||
|
errorOut = "Your serial key cannot be blank.";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
m_Serialkey = serial;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppConfig::clearSerialKey()
|
||||||
|
{
|
||||||
|
m_Serialkey.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString AppConfig::serialKey() { return m_Serialkey; }
|
||||||
|
|
||||||
|
int AppConfig::lastExpiringWarningTime() const { return m_LastExpiringWarningTime; }
|
||||||
|
|
||||||
|
void AppConfig::setLastExpiringWarningTime(int t) { m_LastExpiringWarningTime = t; }
|
||||||
|
|
||||||
|
QString AppConfig::synergysName() const { return m_SynergysName; }
|
||||||
|
|
||||||
|
QString AppConfig::synergycName() const { return m_SynergycName; }
|
||||||
|
|
||||||
ElevateMode AppConfig::elevateMode()
|
ElevateMode AppConfig::elevateMode()
|
||||||
{
|
{
|
||||||
return m_ElevateMode;
|
return m_ElevateMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AppConfig::setCryptoEnabled(bool e) { m_CryptoEnabled = e; }
|
||||||
|
|
||||||
|
bool AppConfig::getCryptoEnabled() { return m_CryptoEnabled; }
|
||||||
|
|
||||||
|
void AppConfig::setAutoHide(bool b) { m_AutoHide = b; }
|
||||||
|
|
||||||
|
bool AppConfig::getAutoHide() { return m_AutoHide; }
|
||||||
|
|
|
@ -58,33 +58,34 @@ class AppConfig
|
||||||
~AppConfig();
|
~AppConfig();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
const QString& screenName() const { return m_ScreenName; }
|
const QString& screenName() const;
|
||||||
int port() const { return m_Port; }
|
int port() const;
|
||||||
const QString& interface() const { return m_Interface; }
|
const QString& interface() const;
|
||||||
int logLevel() const { return m_LogLevel; }
|
int logLevel() const;
|
||||||
bool logToFile() const { return m_LogToFile; }
|
bool logToFile() const;
|
||||||
const QString& logFilename() const { return m_LogFilename; }
|
const QString& logFilename() const;
|
||||||
const QString logFilenameCmd() const;
|
const QString logFilenameCmd() const;
|
||||||
QString logLevelText() const;
|
QString logLevelText() const;
|
||||||
ProcessMode processMode() const { return m_ProcessMode; }
|
ProcessMode processMode() const;
|
||||||
bool wizardShouldRun() const { return m_WizardLastRun < kWizardVersion; }
|
bool wizardShouldRun() const;
|
||||||
const QString& language() const { return m_Language; }
|
const QString& language() const;
|
||||||
bool startedBefore() const { return m_StartedBefore; }
|
bool startedBefore() const;
|
||||||
bool autoConfig() const { return m_AutoConfig; }
|
bool autoConfig() const;
|
||||||
void setAutoConfig(bool autoConfig);
|
void setAutoConfig(bool autoConfig);
|
||||||
bool autoConfigPrompted() { return m_AutoConfigPrompted; }
|
bool autoConfigPrompted();
|
||||||
void setAutoConfigPrompted(bool prompted);
|
void setAutoConfigPrompted(bool prompted);
|
||||||
void setEdition(int e) { m_Edition = e; }
|
void setEdition(int e);
|
||||||
int edition() { return m_Edition; }
|
int edition();
|
||||||
void setActivateEmail(QString e) { m_ActivateEmail = e; }
|
bool setActivateEmail(QString e);
|
||||||
QString activateEmail() { return m_ActivateEmail; }
|
QString activateEmail();
|
||||||
void setSerialKey(QString serial) { m_Serialkey = serial; }
|
bool setSerialKey(QString serial, QString& error);
|
||||||
QString serialKey() { return m_Serialkey; }
|
void clearSerialKey();
|
||||||
int lastExpiringWarningTime() const { return m_LastExpiringWarningTime; }
|
QString serialKey();
|
||||||
void setLastExpiringWarningTime(int t) { m_LastExpiringWarningTime = t; }
|
int lastExpiringWarningTime() const;
|
||||||
|
void setLastExpiringWarningTime(int t);
|
||||||
|
|
||||||
QString synergysName() const { return m_SynergysName; }
|
QString synergysName() const;
|
||||||
QString synergycName() const { return m_SynergycName; }
|
QString synergycName() const;
|
||||||
QString synergyProgramDir() const;
|
QString synergyProgramDir() const;
|
||||||
QString synergyLogDir() const;
|
QString synergyLogDir() const;
|
||||||
|
|
||||||
|
@ -92,25 +93,25 @@ class AppConfig
|
||||||
void persistLogDir();
|
void persistLogDir();
|
||||||
ElevateMode elevateMode();
|
ElevateMode elevateMode();
|
||||||
|
|
||||||
void setCryptoEnabled(bool e) { m_CryptoEnabled = e; }
|
void setCryptoEnabled(bool e);
|
||||||
bool getCryptoEnabled() { return m_CryptoEnabled; }
|
bool getCryptoEnabled();
|
||||||
void setAutoHide(bool b) { m_AutoHide = b; }
|
void setAutoHide(bool b);
|
||||||
bool getAutoHide() { return m_AutoHide; }
|
bool getAutoHide();
|
||||||
|
|
||||||
void saveSettings();
|
void saveSettings();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QSettings& settings() { return *m_pSettings; }
|
QSettings& settings();
|
||||||
void setScreenName(const QString& s) { m_ScreenName = s; }
|
void setScreenName(const QString& s);
|
||||||
void setPort(int i) { m_Port = i; }
|
void setPort(int i);
|
||||||
void setInterface(const QString& s) { m_Interface = s; }
|
void setInterface(const QString& s);
|
||||||
void setLogLevel(int i) { m_LogLevel = i; }
|
void setLogLevel(int i);
|
||||||
void setLogToFile(bool b) { m_LogToFile = b; }
|
void setLogToFile(bool b);
|
||||||
void setLogFilename(const QString& s) { m_LogFilename = s; }
|
void setLogFilename(const QString& s);
|
||||||
void setWizardHasRun() { m_WizardLastRun = kWizardVersion; }
|
void setWizardHasRun();
|
||||||
void setLanguage(const QString language) { m_Language = language; }
|
void setLanguage(const QString language);
|
||||||
void setStartedBefore(bool b) { m_StartedBefore = b; }
|
void setStartedBefore(bool b);
|
||||||
void setElevateMode(ElevateMode em) { m_ElevateMode = em; }
|
void setElevateMode(ElevateMode em);
|
||||||
|
|
||||||
void loadSettings();
|
void loadSettings();
|
||||||
|
|
||||||
|
|
|
@ -18,11 +18,13 @@
|
||||||
#ifndef EDITIONTYPE_H
|
#ifndef EDITIONTYPE_H
|
||||||
#define EDITIONTYPE_H
|
#define EDITIONTYPE_H
|
||||||
|
|
||||||
enum qEditionType {
|
/* Do not reorder these! */
|
||||||
|
|
||||||
|
enum EditionType {
|
||||||
Basic,
|
Basic,
|
||||||
Pro,
|
Pro,
|
||||||
Trial,
|
Trial,
|
||||||
Unknown
|
Unregistered
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // EDITIONTYPE_H
|
#endif // EDITIONTYPE_H
|
||||||
|
|
|
@ -1015,23 +1015,9 @@ void MainWindow::serverDetected(const QString name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::setEdition(int type)
|
void MainWindow::setEdition(int edition)
|
||||||
{
|
{
|
||||||
QString title;
|
setWindowTitle(getEditionName(edition));
|
||||||
if (type == Basic) {
|
|
||||||
title = "Synergy Basic";
|
|
||||||
}
|
|
||||||
else if (type == Pro) {
|
|
||||||
title = "Synergy Pro";
|
|
||||||
}
|
|
||||||
else if (type == Trial) {
|
|
||||||
title = "Synergy Trial";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
title = "Synergy (UNREGISTERED)";
|
|
||||||
}
|
|
||||||
|
|
||||||
setWindowTitle(title);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::updateLocalFingerprint()
|
void MainWindow::updateLocalFingerprint()
|
||||||
|
@ -1154,7 +1140,7 @@ void MainWindow::on_m_pActionWizard_triggered()
|
||||||
|
|
||||||
void MainWindow::on_m_pActivate_triggered()
|
void MainWindow::on_m_pActivate_triggered()
|
||||||
{
|
{
|
||||||
ActivationDialog activationDialog (this);
|
ActivationDialog activationDialog (this, this->appConfig());
|
||||||
activationDialog.exec();
|
activationDialog.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
#include "VersionChecker.h"
|
#include "VersionChecker.h"
|
||||||
#include "IpcClient.h"
|
#include "IpcClient.h"
|
||||||
#include "Ipc.h"
|
#include "Ipc.h"
|
||||||
|
#include "ActivationDialog.h"
|
||||||
|
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
|
|
||||||
|
@ -63,6 +64,7 @@ class MainWindow : public QMainWindow, public Ui::MainWindowBase
|
||||||
|
|
||||||
friend class QSynergyApplication;
|
friend class QSynergyApplication;
|
||||||
friend class SetupWizard;
|
friend class SetupWizard;
|
||||||
|
friend class ActivationDialog;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum qSynergyState
|
enum qSynergyState
|
||||||
|
@ -111,7 +113,7 @@ class MainWindow : public QMainWindow, public Ui::MainWindowBase
|
||||||
void autoAddScreen(const QString name);
|
void autoAddScreen(const QString name);
|
||||||
void updateZeroconfService();
|
void updateZeroconfService();
|
||||||
void serverDetected(const QString name);
|
void serverDetected(const QString name);
|
||||||
void setEdition(int type);
|
void setEdition(int edition);
|
||||||
void updateLocalFingerprint();
|
void updateLocalFingerprint();
|
||||||
public slots:
|
public slots:
|
||||||
void appendLogRaw(const QString& text);
|
void appendLogRaw(const QString& text);
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
#include "ProcessorArch.h"
|
#include "ProcessorArch.h"
|
||||||
#include "CommandProcess.h"
|
#include "CommandProcess.h"
|
||||||
|
#include "EditionType.h"
|
||||||
|
|
||||||
#if defined(Q_OS_LINUX)
|
#if defined(Q_OS_LINUX)
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
|
@ -42,6 +43,22 @@ void setIndexFromItemData(QComboBox* comboBox, const QVariant& itemData)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString
|
||||||
|
getEditionName (int edition) {
|
||||||
|
if (edition == Basic) {
|
||||||
|
return "Synergy Basic";
|
||||||
|
}
|
||||||
|
else if (edition == Pro) {
|
||||||
|
return "Synergy Pro";
|
||||||
|
}
|
||||||
|
else if (edition == Trial) {
|
||||||
|
return "Synergy Trial";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return "Synergy (UNREGISTERED)";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QString hash(const QString& string)
|
QString hash(const QString& string)
|
||||||
{
|
{
|
||||||
QByteArray data = string.toUtf8();
|
QByteArray data = string.toUtf8();
|
||||||
|
|
|
@ -29,3 +29,4 @@ QString hash(const QString& string);
|
||||||
QString getFirstMacAddress();
|
QString getFirstMacAddress();
|
||||||
qProcessorArch getProcessorArch();
|
qProcessorArch getProcessorArch();
|
||||||
QString getOSInformation();
|
QString getOSInformation();
|
||||||
|
QString getEditionName (int edition);
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
SetupWizard::SetupWizard(MainWindow& mainWindow, bool startMain) :
|
SetupWizard::SetupWizard(MainWindow& mainWindow, bool startMain) :
|
||||||
m_MainWindow(mainWindow),
|
m_MainWindow(mainWindow),
|
||||||
m_StartMain(startMain),
|
m_StartMain(startMain),
|
||||||
m_Edition(Unknown),
|
m_Edition(Unregistered),
|
||||||
m_LoginAttemps(0)
|
m_LoginAttemps(0)
|
||||||
{
|
{
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
|
@ -76,7 +76,7 @@ bool SetupWizard::validateCurrentPage()
|
||||||
message.setWindowTitle(tr("Setup Synergy"));
|
message.setWindowTitle(tr("Setup Synergy"));
|
||||||
message.setIcon(QMessageBox::Information);
|
message.setIcon(QMessageBox::Information);
|
||||||
|
|
||||||
if (currentPage() == m_pActivatePage)
|
/*if (currentPage() == m_pActivatePage)
|
||||||
{
|
{
|
||||||
if (m_pRadioButtonActivate->isChecked()) {
|
if (m_pRadioButtonActivate->isChecked()) {
|
||||||
if (m_pLineEditEmail->text().isEmpty() ||
|
if (m_pLineEditEmail->text().isEmpty() ||
|
||||||
|
@ -136,7 +136,8 @@ bool SetupWizard::validateCurrentPage()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (currentPage() == m_pNodePage)
|
else */
|
||||||
|
if (currentPage() == m_pNodePage)
|
||||||
{
|
{
|
||||||
bool result = m_pClientRadioButton->isChecked() ||
|
bool result = m_pClientRadioButton->isChecked() ||
|
||||||
m_pServerRadioButton->isChecked();
|
m_pServerRadioButton->isChecked();
|
||||||
|
@ -201,7 +202,7 @@ void SetupWizard::accept()
|
||||||
|
|
||||||
if (m_pRadioButtonSubscription->isChecked())
|
if (m_pRadioButtonSubscription->isChecked())
|
||||||
{
|
{
|
||||||
appConfig.setSerialKey(m_pTextEditSerialKey->toPlainText());
|
//appConfig.setSerialKey(m_pTextEditSerialKey->toPlainText());
|
||||||
|
|
||||||
notifyActivation("serial:" + m_pTextEditSerialKey->toPlainText());
|
notifyActivation("serial:" + m_pTextEditSerialKey->toPlainText());
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ SubscriptionManager::SubscriptionManager(QWidget* parent, AppConfig& appConfig,
|
||||||
|
|
||||||
bool SubscriptionManager::activateSerial(const QString& serial)
|
bool SubscriptionManager::activateSerial(const QString& serial)
|
||||||
{
|
{
|
||||||
m_Edition = Unknown;
|
m_Edition = Unregistered;
|
||||||
persistDirectory();
|
persistDirectory();
|
||||||
CoreInterface coreInterface;
|
CoreInterface coreInterface;
|
||||||
QString output;
|
QString output;
|
||||||
|
@ -62,7 +62,7 @@ bool SubscriptionManager::activateSerial(const QString& serial)
|
||||||
|
|
||||||
bool SubscriptionManager::checkSubscription()
|
bool SubscriptionManager::checkSubscription()
|
||||||
{
|
{
|
||||||
m_Edition = Unknown;
|
m_Edition = Unregistered;
|
||||||
persistDirectory();
|
persistDirectory();
|
||||||
CoreInterface coreInterface;
|
CoreInterface coreInterface;
|
||||||
QString output;
|
QString output;
|
||||||
|
|
|
@ -25,76 +25,60 @@
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
int WebClient::getEdition(
|
bool
|
||||||
const QString& email,
|
WebClient::getEdition (int& edition, QString& errorOut) {
|
||||||
const QString& password,
|
QString responseJson = request();
|
||||||
QMessageBox& message,
|
|
||||||
QWidget* w)
|
/* TODO: This is horrible and should be ripped out as soon as we move
|
||||||
{
|
* to Qt 5. See issue #5630
|
||||||
QString responseJson;
|
*/
|
||||||
int edition = Unknown;
|
|
||||||
try {
|
|
||||||
responseJson = request(email, password);
|
|
||||||
}
|
|
||||||
catch (std::exception& e)
|
|
||||||
{
|
|
||||||
message.critical(
|
|
||||||
w, "Error",
|
|
||||||
tr("An error occurred while trying to sign in. "
|
|
||||||
"Please contact the helpdesk, and provide the "
|
|
||||||
"following details.\n\n%1").arg(e.what()));
|
|
||||||
return edition;
|
|
||||||
}
|
|
||||||
|
|
||||||
QRegExp resultRegex(".*\"result\".*:.*(true|false).*");
|
QRegExp resultRegex(".*\"result\".*:.*(true|false).*");
|
||||||
if (resultRegex.exactMatch(responseJson)) {
|
if (resultRegex.exactMatch (responseJson)) {
|
||||||
QString boolString = resultRegex.cap(1);
|
QString boolString = resultRegex.cap(1);
|
||||||
if (boolString == "true") {
|
if (boolString == "true") {
|
||||||
QRegExp editionRegex(".*\"edition\".*:.*\"([^\"]+)\".*");
|
QRegExp editionRegex(".*\"edition\".*:.*\"([^\"]+)\".*");
|
||||||
if (editionRegex.exactMatch(responseJson)) {
|
if (editionRegex.exactMatch(responseJson)) {
|
||||||
QString e = editionRegex.cap(1);
|
QString e = editionRegex.cap(1);
|
||||||
edition = e.toInt();
|
edition = e.toInt();
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
throw std::runtime_error ("Unrecognised server response.");
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
return edition;
|
errorOut = tr("Login failed. Invalid email or password.");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
else if (boolString == "false") {
|
} else {
|
||||||
message.critical(
|
|
||||||
w, "Error",
|
|
||||||
tr("Login failed, invalid email or password."));
|
|
||||||
|
|
||||||
return edition;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
QRegExp errorRegex(".*\"error\".*:.*\"([^\"]+)\".*");
|
QRegExp errorRegex(".*\"error\".*:.*\"([^\"]+)\".*");
|
||||||
if (errorRegex.exactMatch(responseJson)) {
|
if (errorRegex.exactMatch (responseJson)) {
|
||||||
|
errorOut = errorRegex.cap(1).replace("\\n", "\n");
|
||||||
// replace "\n" with real new lines.
|
return false;
|
||||||
QString error = errorRegex.cap(1).replace("\\n", "\n");
|
} else {
|
||||||
message.critical(
|
throw std::runtime_error ("Unrecognised server response.");
|
||||||
w, "Error",
|
|
||||||
tr("Login failed, an error occurred.\n\n%1").arg(error));
|
|
||||||
|
|
||||||
return edition;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
message.critical(
|
|
||||||
w, "Error",
|
|
||||||
tr("Login failed, an error occurred.\n\nServer response:\n\n%1")
|
|
||||||
.arg(responseJson));
|
|
||||||
|
|
||||||
return edition;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString WebClient::request(
|
bool
|
||||||
const QString& email,
|
WebClient::setEmail (QString email, QString& errorOut) {
|
||||||
const QString& password)
|
if (email.isEmpty()) {
|
||||||
{
|
errorOut = tr("Your email address cannot be left blank.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
m_Email = email;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
WebClient::setPassword (QString password, QString&) {
|
||||||
|
m_Password = password;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString
|
||||||
|
WebClient::request() {
|
||||||
QStringList args("--login-auth");
|
QStringList args("--login-auth");
|
||||||
// hash password in case it contains interesting chars.
|
QString credentials (m_Email + ":" + hash(m_Password) + "\n");
|
||||||
QString credentials(email + ":" + hash(password) + "\n");
|
return m_CoreInterface.run (args, credentials);
|
||||||
|
|
||||||
return m_CoreInterface.run(args, credentials);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,21 +32,15 @@ class WebClient : public QObject
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int getEdition(const QString& email,
|
bool getEdition (int& edition, QString& errorOut);
|
||||||
const QString& password,
|
bool setEmail (QString email, QString& errorOut);
|
||||||
QMessageBox& message,
|
bool setPassword (QString password, QString& errorOut);
|
||||||
QWidget* w);
|
|
||||||
void setEmail(QString& e) { m_Email = e; }
|
|
||||||
void setPassword(QString& p) { m_Password = p; }
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void error(QString e);
|
void error(QString e);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString request(const QString& email,
|
QString request();
|
||||||
const QString& password);
|
|
||||||
|
|
||||||
private:
|
|
||||||
QString m_Email;
|
QString m_Email;
|
||||||
QString m_Password;
|
QString m_Password;
|
||||||
CoreInterface m_CoreInterface;
|
CoreInterface m_CoreInterface;
|
||||||
|
|
Loading…
Reference in New Issue