diff --git a/src/gui/gui.pro b/src/gui/gui.pro index 6f5232af..73368b84 100644 --- a/src/gui/gui.pro +++ b/src/gui/gui.pro @@ -62,7 +62,8 @@ SOURCES += src/main.cpp \ src/Plugin.cpp \ src/WebClient.cpp \ ../lib/common/PluginVersion.cpp \ - src/SubscriptionManager.cpp + src/SubscriptionManager.cpp \ + src/ActivationNotifier.cpp HEADERS += src/MainWindow.h \ src/AboutDialog.h \ src/ServerConfig.h \ @@ -109,7 +110,8 @@ HEADERS += src/MainWindow.h \ src/Plugin.h \ src/WebClient.h \ ../lib/common/PluginVersion.h \ - src/SubscriptionManager.h + src/SubscriptionManager.h \ + src/ActivationNotifier.h RESOURCES += res/Synergy.qrc RC_FILE = res/win/Synergy.rc macx { diff --git a/src/gui/src/ActivationNotifier.cpp b/src/gui/src/ActivationNotifier.cpp new file mode 100644 index 00000000..7efe4e82 --- /dev/null +++ b/src/gui/src/ActivationNotifier.cpp @@ -0,0 +1,36 @@ +/* + * 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 . + */ + +#include "ActivationNotifier.h" + +#include "CoreInterface.h" + +ActivationNotifier::ActivationNotifier(QObject *parent) : + QObject(parent) +{ +} + +void ActivationNotifier::setIdentity(QString identity) +{ + m_Identity = identity; +} + +void ActivationNotifier::notify() +{ + CoreInterface coreInterface; + coreInterface.notifyActivation(m_Identity); +} diff --git a/src/gui/src/ActivationNotifier.h b/src/gui/src/ActivationNotifier.h new file mode 100644 index 00000000..d245cd27 --- /dev/null +++ b/src/gui/src/ActivationNotifier.h @@ -0,0 +1,41 @@ +/* + * 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 . + */ + +#ifndef ACTIVATIONNOTIFIER_H +#define ACTIVATIONNOTIFIER_H + +#include + +class ActivationNotifier : public QObject +{ +Q_OBJECT +public: + explicit ActivationNotifier(QObject *parent = 0); + + void setIdentity(QString identity); + +public slots: + void notify(); + +signals: + void finished(); + +private: + QString m_Identity; +}; + +#endif // ACTIVATIONNOTIFIER_H diff --git a/src/gui/src/SetupWizard.cpp b/src/gui/src/SetupWizard.cpp index e239b015..a3a081fc 100644 --- a/src/gui/src/SetupWizard.cpp +++ b/src/gui/src/SetupWizard.cpp @@ -18,6 +18,7 @@ #include "SetupWizard.h" #include "MainWindow.h" #include "WebClient.h" +#include "ActivationNotifier.h" #include "SubscriptionManager.h" #include "EditionType.h" #include "QSynergyApplication.h" @@ -200,22 +201,19 @@ void SetupWizard::accept() if (m_pRadioButtonActivate->isChecked()) { appConfig.setActivateEmail(m_pLineEditEmail->text()); - CoreInterface coreInterface; - coreInterface.notifyActivation("login:" + m_pLineEditEmail->text()); + notifyActivation("login:" + m_pLineEditEmail->text()); } if (m_pRadioButtonSubscription->isChecked()) { appConfig.setSerialKey(m_pLineEditSerialKey->text()); - CoreInterface coreInterface; - coreInterface.notifyActivation("serial:" + m_pLineEditSerialKey->text()); + notifyActivation("serial:" + m_pLineEditSerialKey->text()); } if (m_pRadioButtonSkip->isChecked()) { - CoreInterface coreInterface; - coreInterface.notifyActivation("skip:unknown"); + notifyActivation("skip:unknown"); } appConfig.setEdition(m_Edition); @@ -251,6 +249,21 @@ void SetupWizard::reject() QWizard::reject(); } +void SetupWizard::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 SetupWizard::on_m_pComboLanguage_currentIndexChanged(int index) { QString ietfCode = m_pComboLanguage->itemData(index).toString(); diff --git a/src/gui/src/SetupWizard.h b/src/gui/src/SetupWizard.h index 253ac97f..328de0ee 100644 --- a/src/gui/src/SetupWizard.h +++ b/src/gui/src/SetupWizard.h @@ -43,6 +43,7 @@ protected: void changeEvent(QEvent* event); void accept(); void reject(); + void notifyActivation(QString identity); private: MainWindow& m_MainWindow;