SYNERGY-324 Update behaviour when unregistered
This commit is contained in:
parent
19160b94fd
commit
05a66271a1
8 changed files with 58 additions and 28 deletions
|
|
@ -43,16 +43,15 @@ ActivationDialog::~ActivationDialog()
|
||||||
|
|
||||||
void ActivationDialog::reject()
|
void ActivationDialog::reject()
|
||||||
{
|
{
|
||||||
if (m_LicenseManager->activeEdition() == kUnregistered) {
|
if (m_LicenseManager->activeEdition() == kUnregistered) {
|
||||||
CancelActivationDialog cancelActivationDialog(this);
|
CancelActivationDialog cancelActivationDialog(this);
|
||||||
if (QDialog::Accepted == cancelActivationDialog.exec()) {
|
if (QDialog::Accepted == cancelActivationDialog.exec()) {
|
||||||
m_LicenseManager->skipActivation();
|
m_LicenseManager->skipActivation();
|
||||||
m_appConfig->activationHasRun(true);
|
} else {
|
||||||
} else {
|
return;
|
||||||
return;
|
}
|
||||||
}
|
}
|
||||||
}
|
QDialog::reject();
|
||||||
QDialog::reject();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActivationDialog::accept()
|
void ActivationDialog::accept()
|
||||||
|
|
|
||||||
|
|
@ -47,8 +47,8 @@ LicenseManager::setSerialKey(SerialKey serialKey, bool acceptExpired)
|
||||||
emit serialKeyChanged(m_serialKey);
|
emit serialKeyChanged(m_serialKey);
|
||||||
|
|
||||||
emit showLicenseNotice(getLicenseNotice());
|
emit showLicenseNotice(getLicenseNotice());
|
||||||
if (m_serialKey.isExpired(currentTime)) {
|
if (m_serialKey.isValid()) {
|
||||||
emit LicenseExpired();
|
emit InvalidLicense();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_serialKey.edition() != serialKey.edition()) {
|
if (m_serialKey.edition() != serialKey.edition()) {
|
||||||
|
|
@ -112,8 +112,8 @@ LicenseManager::refresh()
|
||||||
m_AppConfig->clearSerialKey();
|
m_AppConfig->clearSerialKey();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (m_serialKey.isExpired(::time(0))) {
|
if (m_serialKey.isValid()) {
|
||||||
emit LicenseExpired();
|
emit InvalidLicense();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ private:
|
||||||
signals:
|
signals:
|
||||||
void serialKeyChanged (SerialKey) const;
|
void serialKeyChanged (SerialKey) const;
|
||||||
void editionChanged (Edition) const;
|
void editionChanged (Edition) const;
|
||||||
void LicenseExpired () const;
|
void InvalidLicense () const;
|
||||||
void showLicenseNotice(const QString& notice) const;
|
void showLicenseNotice(const QString& notice) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
||||||
|
|
@ -174,8 +174,8 @@ MainWindow::MainWindow (AppConfig& appConfig,
|
||||||
connect (m_LicenseManager, SIGNAL(showLicenseNotice(QString)),
|
connect (m_LicenseManager, SIGNAL(showLicenseNotice(QString)),
|
||||||
this, SLOT(showLicenseNotice(QString)), Qt::QueuedConnection);
|
this, SLOT(showLicenseNotice(QString)), Qt::QueuedConnection);
|
||||||
|
|
||||||
connect (m_LicenseManager, SIGNAL(LicenseExpired()),
|
connect (m_LicenseManager, SIGNAL(InvalidLicense()),
|
||||||
this, SLOT(LicenseExpired()), Qt::QueuedConnection);
|
this, SLOT(InvalidLicense()), Qt::QueuedConnection);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
connect (m_AppConfig, SIGNAL(sslToggled(bool)),
|
connect (m_AppConfig, SIGNAL(sslToggled(bool)),
|
||||||
|
|
@ -613,8 +613,7 @@ void MainWindow::startSynergy()
|
||||||
{
|
{
|
||||||
#ifndef SYNERGY_ENTERPRISE
|
#ifndef SYNERGY_ENTERPRISE
|
||||||
SerialKey serialKey = m_LicenseManager->serialKey();
|
SerialKey serialKey = m_LicenseManager->serialKey();
|
||||||
time_t currentTime = ::time(0);
|
if (!serialKey.isValid()) {
|
||||||
if (serialKey.isExpired(currentTime)) {
|
|
||||||
if (QDialog::Rejected == raiseActivationDialog()) {
|
if (QDialog::Rejected == raiseActivationDialog()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -1152,7 +1151,7 @@ void MainWindow::setEdition(Edition edition)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef SYNERGY_ENTERPRISE
|
#ifndef SYNERGY_ENTERPRISE
|
||||||
void MainWindow::LicenseExpired()
|
void MainWindow::InvalidLicense()
|
||||||
{
|
{
|
||||||
stopSynergy();
|
stopSynergy();
|
||||||
m_AppConfig->activationHasRun(false);
|
m_AppConfig->activationHasRun(false);
|
||||||
|
|
@ -1379,12 +1378,11 @@ int MainWindow::raiseActivationDialog()
|
||||||
void MainWindow::on_windowShown()
|
void MainWindow::on_windowShown()
|
||||||
{
|
{
|
||||||
#ifndef SYNERGY_ENTERPRISE
|
#ifndef SYNERGY_ENTERPRISE
|
||||||
time_t currentTime = ::time(0);
|
if (!m_AppConfig->activationHasRun()){
|
||||||
if (!m_AppConfig->activationHasRun()
|
if (!m_LicenseManager->serialKey().isValid()) {
|
||||||
&& ((m_AppConfig->edition() == kUnregistered) ||
|
raiseActivationDialog();
|
||||||
(m_LicenseManager->serialKey().isExpired(currentTime)))) {
|
}
|
||||||
raiseActivationDialog();
|
}
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -132,7 +132,7 @@ class MainWindow : public QMainWindow, public Ui::MainWindowBase
|
||||||
public slots:
|
public slots:
|
||||||
void setEdition(Edition edition);
|
void setEdition(Edition edition);
|
||||||
#ifndef SYNERGY_ENTERPRISE
|
#ifndef SYNERGY_ENTERPRISE
|
||||||
void LicenseExpired();
|
void InvalidLicense();
|
||||||
void showLicenseNotice(const QString& message);
|
void showLicenseNotice(const QString& message);
|
||||||
#endif
|
#endif
|
||||||
void appendLogRaw(const QString& text);
|
void appendLogRaw(const QString& text);
|
||||||
|
|
|
||||||
|
|
@ -96,6 +96,19 @@ SerialKey::isTemporary() const
|
||||||
return m_KeyType.isTemporary();
|
return m_KeyType.isTemporary();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
SerialKey::isValid() const
|
||||||
|
{
|
||||||
|
bool Valid = true;
|
||||||
|
|
||||||
|
if (m_edition.getType() == kUnregistered || isExpired(::time(0)))
|
||||||
|
{
|
||||||
|
Valid = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Valid;
|
||||||
|
}
|
||||||
|
|
||||||
Edition
|
Edition
|
||||||
SerialKey::edition() const
|
SerialKey::edition() const
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ public:
|
||||||
bool isExpired(time_t currentTime) const;
|
bool isExpired(time_t currentTime) const;
|
||||||
bool isTrial() const;
|
bool isTrial() const;
|
||||||
bool isTemporary() const;
|
bool isTemporary() const;
|
||||||
|
bool isValid() const;
|
||||||
time_t daysLeft(time_t currentTime) const;
|
time_t daysLeft(time_t currentTime) const;
|
||||||
std::string email() const;
|
std::string email() const;
|
||||||
Edition edition() const;
|
Edition edition() const;
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ TEST(SerialKeyTests, parse_validV2Serial_valid)
|
||||||
bool r = serial.parse("{v2;trial;pro;Bob;1;email;company name;0;86400}");
|
bool r = serial.parse("{v2;trial;pro;Bob;1;email;company name;0;86400}");
|
||||||
EXPECT_EQ(true, r);
|
EXPECT_EQ(true, r);
|
||||||
EXPECT_EQ(kPro, serial.edition());
|
EXPECT_EQ(kPro, serial.edition());
|
||||||
EXPECT_FALSE(serial.isExpired(0));
|
EXPECT_FALSE(serial.isExpired(0));
|
||||||
EXPECT_EQ(true, serial.daysLeft(0));
|
EXPECT_EQ(true, serial.daysLeft(0));
|
||||||
EXPECT_EQ(true, serial.isExpiring(1));
|
EXPECT_EQ(true, serial.isExpiring(1));
|
||||||
EXPECT_EQ(true, serial.isTrial());
|
EXPECT_EQ(true, serial.isTrial());
|
||||||
|
|
@ -207,4 +207,23 @@ TEST(SerialKeyTests, toStringV1BasicSerialKey)
|
||||||
EXPECT_EQ(Expected, serial.toString());
|
EXPECT_EQ(Expected, serial.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(SerialKeyTests, IsValidKey_false)
|
||||||
|
{
|
||||||
|
//{v1;basic;Bob;1;email;company name;0;0}
|
||||||
|
SerialKey serial(kUnregistered);
|
||||||
|
EXPECT_EQ(false, serial.isValid());
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(SerialKeyTests, IsValidKey_true)
|
||||||
|
{
|
||||||
|
SerialKey serial(kBasic);
|
||||||
|
EXPECT_EQ(true, serial.isValid());
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(SerialKeyTests, IsValidExpiredKey_false)
|
||||||
|
{
|
||||||
|
SerialKey serial("7B76323B737562736372697074696F6E3B62617369633B426F623B313B656D61696C3B636F6D70616E79206E616D653B303B38363430307D");
|
||||||
|
EXPECT_EQ(false, serial.isValid());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue