#5657 Stop service and refresh license when trial expires

This commit is contained in:
Andrew Nelless 2016-10-25 16:27:12 +01:00
parent b66043e000
commit 492df1f3fd
3 changed files with 8 additions and 4 deletions

View File

@ -89,10 +89,13 @@ LicenseManager::serialKey() const
return m_serialKey; return m_serialKey;
} }
void LicenseManager::refresh(bool acceptExpired) void LicenseManager::refresh()
{ {
if (!m_AppConfig->serialKey().isEmpty()) { if (!m_AppConfig->serialKey().isEmpty()) {
setSerialKey(m_AppConfig->serialKey(), acceptExpired); setSerialKey(m_AppConfig->serialKey(), true);
}
if (m_serialKey.isExpired(::time(0))) {
emit endTrial(true);
} }
} }

View File

@ -31,7 +31,7 @@ class LicenseManager: public QObject
public: public:
LicenseManager(AppConfig* appConfig); LicenseManager(AppConfig* appConfig);
std::pair<bool, QString> setSerialKey(QString serialKey, bool acceptExpired = false); std::pair<bool, QString> setSerialKey(QString serialKey, bool acceptExpired = false);
void refresh(bool acceptExpired = false); void refresh();
Edition activeEdition() const; Edition activeEdition() const;
QString activeEditionName() const; QString activeEditionName() const;
SerialKey serialKey() const; SerialKey serialKey() const;

View File

@ -156,7 +156,7 @@ MainWindow::MainWindow(QSettings& settings, AppConfig& appConfig,
this, SLOT(sslToggled(bool)), Qt::QueuedConnection); this, SLOT(sslToggled(bool)), Qt::QueuedConnection);
setWindowTitle (m_LicenseManager->activeEditionName()); setWindowTitle (m_LicenseManager->activeEditionName());
m_LicenseManager->refresh(true); m_LicenseManager->refresh();
} }
MainWindow::~MainWindow() MainWindow::~MainWindow()
@ -451,6 +451,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")) {
licenseManager().refresh();
raiseActivationDialog(); raiseActivationDialog();
} }
} }