#5722 Make LicenseManager accept SerialKey object instead of string
This commit is contained in:
parent
6a7703f229
commit
1a7920f80d
|
@ -71,7 +71,8 @@ void ActivationDialog::accept()
|
||||||
|
|
||||||
std::pair<bool, QString> result;
|
std::pair<bool, QString> result;
|
||||||
try {
|
try {
|
||||||
QString serialKey = ui->m_pTextEditSerialKey->toPlainText().trimmed();
|
SerialKey serialKey (ui->m_pTextEditSerialKey->toPlainText().
|
||||||
|
trimmed().toStdString());
|
||||||
result = m_LicenseManager->setSerialKey(serialKey);
|
result = m_LicenseManager->setSerialKey(serialKey);
|
||||||
}
|
}
|
||||||
catch (std::exception& e) {
|
catch (std::exception& e) {
|
||||||
|
|
|
@ -29,11 +29,10 @@ LicenseManager::LicenseManager(AppConfig* appConfig) :
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<bool, QString>
|
std::pair<bool, QString>
|
||||||
LicenseManager::setSerialKey(QString serialKeyString, bool acceptExpired)
|
LicenseManager::setSerialKey(SerialKey serialKey, bool acceptExpired)
|
||||||
{
|
{
|
||||||
std::pair<bool, QString> ret (true, "");
|
std::pair<bool, QString> ret (true, "");
|
||||||
time_t currentTime = ::time(0);
|
time_t currentTime = ::time(0);
|
||||||
SerialKey serialKey (serialKeyString.toStdString());
|
|
||||||
|
|
||||||
if (!acceptExpired && serialKey.isExpired(currentTime)) {
|
if (!acceptExpired && serialKey.isExpired(currentTime)) {
|
||||||
ret.first = false;
|
ret.first = false;
|
||||||
|
@ -44,7 +43,8 @@ LicenseManager::setSerialKey(QString serialKeyString, bool acceptExpired)
|
||||||
if (serialKey != m_serialKey) {
|
if (serialKey != m_serialKey) {
|
||||||
using std::swap;
|
using std::swap;
|
||||||
swap (serialKey, m_serialKey);
|
swap (serialKey, m_serialKey);
|
||||||
m_AppConfig->setSerialKey(serialKeyString);
|
m_AppConfig->setSerialKey(QString::fromStdString
|
||||||
|
(serialKey.toString()));
|
||||||
emit serialKeyChanged(m_serialKey);
|
emit serialKeyChanged(m_serialKey);
|
||||||
|
|
||||||
if (serialKey.isTrial()) {
|
if (serialKey.isTrial()) {
|
||||||
|
@ -114,7 +114,13 @@ LicenseManager::serialKey() const
|
||||||
void LicenseManager::refresh()
|
void LicenseManager::refresh()
|
||||||
{
|
{
|
||||||
if (!m_AppConfig->serialKey().isEmpty()) {
|
if (!m_AppConfig->serialKey().isEmpty()) {
|
||||||
setSerialKey(m_AppConfig->serialKey(), true);
|
try {
|
||||||
|
SerialKey serialKey (m_AppConfig->serialKey().toStdString());
|
||||||
|
setSerialKey(serialKey, true);
|
||||||
|
} catch (...) {
|
||||||
|
m_AppConfig->setSerialKey("");
|
||||||
|
m_AppConfig->saveSettings();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (m_serialKey.isExpired(::time(0))) {
|
if (m_serialKey.isExpired(::time(0))) {
|
||||||
emit endTrial(true);
|
emit endTrial(true);
|
||||||
|
|
|
@ -30,7 +30,8 @@ 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(SerialKey serialKey,
|
||||||
|
bool acceptExpired = false);
|
||||||
void refresh();
|
void refresh();
|
||||||
Edition activeEdition() const;
|
Edition activeEdition() const;
|
||||||
QString activeEditionName() const;
|
QString activeEditionName() const;
|
||||||
|
|
Loading…
Reference in New Issue