#5659 Move activation notification to SubscriptionManager
This commit is contained in:
parent
540882056f
commit
727fc5c220
|
@ -31,27 +31,11 @@ ActivationDialog::~ActivationDialog()
|
|||
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()
|
||||
{
|
||||
CancelActivationDialog cancelActivationDialog(this);
|
||||
if (QDialog::Accepted == cancelActivationDialog.exec()) {
|
||||
notifyActivation("skip:unknown");
|
||||
m_subscriptionManager->notifySkip();
|
||||
m_appConfig->activationHasRun(true);
|
||||
m_appConfig->saveSettings();
|
||||
QDialog::reject();
|
||||
|
@ -69,10 +53,7 @@ void ActivationDialog::accept()
|
|||
|
||||
try {
|
||||
QString serialKey = ui->m_pTextEditSerialKey->toPlainText();
|
||||
SubscriptionManager subscriptionManager (m_appConfig);
|
||||
subscriptionManager.setSerialKey (serialKey);
|
||||
notifyActivation("serial:" + m_appConfig->serialKey());
|
||||
|
||||
m_subscriptionManager->setSerialKey(serialKey);
|
||||
}
|
||||
catch (std::exception& e) {
|
||||
message.critical(this, "Unknown Error",
|
||||
|
|
|
@ -23,9 +23,6 @@ public slots:
|
|||
void reject();
|
||||
void accept();
|
||||
|
||||
protected:
|
||||
void notifyActivation (QString identity);
|
||||
|
||||
private:
|
||||
Ui::ActivationDialog *ui;
|
||||
AppConfig* m_appConfig;
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "EditionType.h"
|
||||
#include "AppConfig.h"
|
||||
#include <ctime>
|
||||
#include <QThread>
|
||||
|
||||
SubscriptionManager::SubscriptionManager(AppConfig* appConfig) :
|
||||
m_AppConfig(appConfig) {
|
||||
|
@ -30,6 +31,28 @@ SubscriptionManager::setSerialKey(QString serialKeyString)
|
|||
SerialKey serialKey (serialKeyString.toStdString());
|
||||
if (serialKey.isValid (::time(0)) && (serialKey != m_serialKey)) {
|
||||
m_AppConfig->setSerialKey (serialKeyString);
|
||||
notifyActivation ("serial:" + serialKeyString);
|
||||
emit serialKeyChanged (serialKey);
|
||||
}
|
||||
}
|
||||
|
||||
void SubscriptionManager::notifySkip()
|
||||
{
|
||||
notifyActivation ("skip:unknown");
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
#include <QObject>
|
||||
#include <SerialKey.h>
|
||||
#include <ActivationNotifier.h>
|
||||
|
||||
class AppConfig;
|
||||
|
||||
|
@ -29,6 +30,10 @@ class SubscriptionManager: public QObject
|
|||
public:
|
||||
SubscriptionManager (AppConfig* appConfig);
|
||||
void setSerialKey (QString serialKey);
|
||||
void notifySkip ();
|
||||
|
||||
private:
|
||||
void notifyActivation (QString identity);
|
||||
|
||||
private:
|
||||
AppConfig* m_AppConfig;
|
||||
|
@ -36,4 +41,5 @@ private:
|
|||
|
||||
signals:
|
||||
void serialKeyChanged (SerialKey);
|
||||
void editionChanged (Edition);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue