Parse date numbers as long instead of int (#7429)
* Fixed menus * Parse string to long for date * Change time limited logic * Restore time limit logic * Remove qglobal.h includes * Remove warning * Fixed tests to work with 0 value * Update ChangeLog
This commit is contained in:
parent
de21030892
commit
a686f19ca2
14 changed files with 65 additions and 40 deletions
|
|
@ -72,6 +72,7 @@ Enhancements:
|
||||||
- #7426 Fixed warnings and enable errors as warnings
|
- #7426 Fixed warnings and enable errors as warnings
|
||||||
- #7427 More reliable button click detection for add client dialog
|
- #7427 More reliable button click detection for add client dialog
|
||||||
- #7428 Refactor settings dialog to simplify enable/disable logic
|
- #7428 Refactor settings dialog to simplify enable/disable logic
|
||||||
|
- #7429 Parse date numbers as long instead of int
|
||||||
|
|
||||||
# 1.14.6
|
# 1.14.6
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@
|
||||||
"macdeployqt",
|
"macdeployqt",
|
||||||
"msvc",
|
"msvc",
|
||||||
"noquote",
|
"noquote",
|
||||||
|
"NOSONAR",
|
||||||
"notarytool",
|
"notarytool",
|
||||||
"Oleksandr",
|
"Oleksandr",
|
||||||
"Olena",
|
"Olena",
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
|
#include <exception>
|
||||||
|
|
||||||
using namespace synergy::gui;
|
using namespace synergy::gui;
|
||||||
using namespace synergy::license;
|
using namespace synergy::license;
|
||||||
|
|
@ -102,8 +103,11 @@ void ActivationDialog::accept() {
|
||||||
showResultDialog(result);
|
showResultDialog(result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} catch (const SerialKeyParseError &e) {
|
} catch (const std::exception &e) { // NOSONAR
|
||||||
showErrorDialog(e.what());
|
qCritical("failed to change serial key: %s", e.what());
|
||||||
|
return;
|
||||||
|
} catch (...) { // NOSONAR
|
||||||
|
qCritical("failed to change serial key");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -154,6 +154,13 @@ void MainWindow::setupControls() {
|
||||||
updateWindowTitle();
|
updateWindowTitle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!kLicensedProduct) {
|
||||||
|
m_pActionHelp->setText("Report a bug");
|
||||||
|
m_pActionActivate->setText("Purchase");
|
||||||
|
} else if (!kEnableActivation) {
|
||||||
|
m_pActionActivate->setVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
createMenuBar();
|
createMenuBar();
|
||||||
secureSocket(false);
|
secureSocket(false);
|
||||||
|
|
||||||
|
|
@ -170,10 +177,6 @@ void MainWindow::setupControls() {
|
||||||
m_AppConfig.setLastVersion(SYNERGY_VERSION);
|
m_AppConfig.setLastVersion(SYNERGY_VERSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (kEnableActivation) {
|
|
||||||
m_pActivate->setVisible(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(Q_OS_MAC)
|
#if defined(Q_OS_MAC)
|
||||||
|
|
||||||
m_pRadioGroupServer->setAttribute(Qt::WA_MacShowFocusRect, 0);
|
m_pRadioGroupServer->setAttribute(Qt::WA_MacShowFocusRect, 0);
|
||||||
|
|
@ -412,8 +415,12 @@ void MainWindow::on_m_pActionAbout_triggered() {
|
||||||
about.exec();
|
about.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_m_pActionHelp_triggered() {
|
void MainWindow::on_m_pActionHelp_triggered() const {
|
||||||
QDesktopServices::openUrl(QUrl(kUrlHelp));
|
if (kLicensedProduct) {
|
||||||
|
QDesktopServices::openUrl(QUrl(kUrlHelp));
|
||||||
|
} else {
|
||||||
|
QDesktopServices::openUrl(QUrl(kUrlBugReport));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_m_pActionSettings_triggered() {
|
void MainWindow::on_m_pActionSettings_triggered() {
|
||||||
|
|
@ -437,7 +444,13 @@ void MainWindow::on_m_pButtonConfigureServer_clicked() {
|
||||||
showConfigureServer();
|
showConfigureServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_m_pActivate_triggered() { showActivationDialog(); }
|
void MainWindow::on_m_pActionActivate_triggered() {
|
||||||
|
if (kLicensedProduct) {
|
||||||
|
showActivationDialog();
|
||||||
|
} else {
|
||||||
|
QDesktopServices::openUrl(QUrl(kUrlPurchase));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::on_m_pLineEditHostname_returnPressed() {
|
void MainWindow::on_m_pLineEditHostname_returnPressed() {
|
||||||
m_pButtonConnect->click();
|
m_pButtonConnect->click();
|
||||||
|
|
@ -572,7 +585,7 @@ void MainWindow::createMenuBar() {
|
||||||
m_pMenuFile->addAction(m_pActionStartCore);
|
m_pMenuFile->addAction(m_pActionStartCore);
|
||||||
m_pMenuFile->addAction(m_pActionStopCore);
|
m_pMenuFile->addAction(m_pActionStopCore);
|
||||||
m_pMenuFile->addSeparator();
|
m_pMenuFile->addSeparator();
|
||||||
m_pMenuFile->addAction(m_pActivate);
|
m_pMenuFile->addAction(m_pActionActivate);
|
||||||
m_pMenuFile->addSeparator();
|
m_pMenuFile->addSeparator();
|
||||||
m_pMenuFile->addAction(m_pActionSave);
|
m_pMenuFile->addAction(m_pActionSave);
|
||||||
m_pMenuFile->addSeparator();
|
m_pMenuFile->addSeparator();
|
||||||
|
|
@ -1012,6 +1025,10 @@ void MainWindow::showConfigureServer(const QString &message) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int MainWindow::showActivationDialog() {
|
int MainWindow::showActivationDialog() {
|
||||||
|
if (!kEnableActivation) {
|
||||||
|
qFatal("cannot show activation dialog when activation is disabled");
|
||||||
|
}
|
||||||
|
|
||||||
if (m_ActivationDialogRunning) {
|
if (m_ActivationDialogRunning) {
|
||||||
return QDialog::Rejected;
|
return QDialog::Rejected;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -89,6 +89,10 @@ public slots:
|
||||||
void onAppAboutToQuit();
|
void onAppAboutToQuit();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
//
|
||||||
|
// Manual slots
|
||||||
|
//
|
||||||
|
|
||||||
void onCreated();
|
void onCreated();
|
||||||
void onShown();
|
void onShown();
|
||||||
void onConfigScopesSaving();
|
void onConfigScopesSaving();
|
||||||
|
|
@ -109,7 +113,9 @@ private slots:
|
||||||
void onWindowSaveTimerTimeout();
|
void onWindowSaveTimerTimeout();
|
||||||
void onServerConnectionConfigureClient(const QString &clientName);
|
void onServerConnectionConfigureClient(const QString &clientName);
|
||||||
|
|
||||||
// autoconnect slots
|
//
|
||||||
|
// Auto-connect slots
|
||||||
|
//
|
||||||
void on_m_pButtonApply_clicked();
|
void on_m_pButtonApply_clicked();
|
||||||
void on_m_pLabelComputerName_linkActivated(const QString &link);
|
void on_m_pLabelComputerName_linkActivated(const QString &link);
|
||||||
void on_m_pLabelFingerprint_linkActivated(const QString &link);
|
void on_m_pLabelFingerprint_linkActivated(const QString &link);
|
||||||
|
|
@ -120,9 +126,9 @@ private slots:
|
||||||
void on_m_pButtonConfigureServer_clicked();
|
void on_m_pButtonConfigureServer_clicked();
|
||||||
bool on_m_pActionSave_triggered();
|
bool on_m_pActionSave_triggered();
|
||||||
void on_m_pActionAbout_triggered();
|
void on_m_pActionAbout_triggered();
|
||||||
void on_m_pActionHelp_triggered();
|
void on_m_pActionHelp_triggered() const;
|
||||||
void on_m_pActionSettings_triggered();
|
void on_m_pActionSettings_triggered();
|
||||||
void on_m_pActivate_triggered();
|
void on_m_pActionActivate_triggered();
|
||||||
void on_m_pLineEditHostname_returnPressed();
|
void on_m_pLineEditHostname_returnPressed();
|
||||||
void on_m_pLineEditClientIp_returnPressed();
|
void on_m_pLineEditClientIp_returnPressed();
|
||||||
void on_m_pLineEditHostname_textChanged(const QString &text);
|
void on_m_pLineEditHostname_textChanged(const QString &text);
|
||||||
|
|
|
||||||
|
|
@ -651,7 +651,7 @@
|
||||||
<string notr="true"/>
|
<string notr="true"/>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="m_pActivate">
|
<action name="m_pActionActivate">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Activate</string>
|
<string>Activate</string>
|
||||||
</property>
|
</property>
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,6 @@
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QtCore>
|
#include <QtCore>
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
#include <qglobal.h>
|
|
||||||
|
|
||||||
using namespace synergy::license;
|
using namespace synergy::license;
|
||||||
using namespace synergy::gui;
|
using namespace synergy::gui;
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,6 @@
|
||||||
#include "constants.h"
|
#include "constants.h"
|
||||||
#include "gui/config/IAppConfig.h"
|
#include "gui/config/IAppConfig.h"
|
||||||
#include "gui/core/CoreTool.h"
|
#include "gui/core/CoreTool.h"
|
||||||
#include <qglobal.h>
|
|
||||||
#include <qmutex.h>
|
|
||||||
|
|
||||||
#if defined(Q_OS_MAC)
|
#if defined(Q_OS_MAC)
|
||||||
#include "OSXHelpers.h"
|
#include "OSXHelpers.h"
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,9 @@ bool License::isSubscription() const {
|
||||||
return m_serialKey.type.isSubscription();
|
return m_serialKey.type.isSubscription();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool License::isTimeLimited() const { return m_serialKey.type.isTimeLimited(); }
|
bool License::isTimeLimited() const {
|
||||||
|
return m_serialKey.type.isSubscription() || m_serialKey.type.isTrial();
|
||||||
|
}
|
||||||
|
|
||||||
bool License::isTlsAvailable() const {
|
bool License::isTlsAvailable() const {
|
||||||
return m_serialKey.product.isTlsAvailable();
|
return m_serialKey.product.isTlsAvailable();
|
||||||
|
|
@ -53,7 +55,7 @@ Edition License::productEdition() const {
|
||||||
return m_serialKey.product.edition();
|
return m_serialKey.product.edition();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool License::isExpiring() const {
|
bool License::isExpiringSoon() const {
|
||||||
if (!isTimeLimited()) {
|
if (!isTimeLimited()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isValid() const { return m_serialKey.isValid; }
|
bool isValid() const { return m_serialKey.isValid; }
|
||||||
bool isExpiring() const;
|
bool isExpiringSoon() const;
|
||||||
bool isExpired() const;
|
bool isExpired() const;
|
||||||
bool isTrial() const;
|
bool isTrial() const;
|
||||||
bool isSubscription() const;
|
bool isSubscription() const;
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,3 @@ void SerialKeyType::setType(const std::string_view &type) {
|
||||||
bool SerialKeyType::isTrial() const { return m_isTrial; }
|
bool SerialKeyType::isTrial() const { return m_isTrial; }
|
||||||
|
|
||||||
bool SerialKeyType::isSubscription() const { return m_isSubscription; }
|
bool SerialKeyType::isSubscription() const { return m_isSubscription; }
|
||||||
|
|
||||||
bool SerialKeyType::isTimeLimited() const {
|
|
||||||
return m_isTrial || m_isSubscription;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,6 @@ public:
|
||||||
void setType(const std::string_view &type);
|
void setType(const std::string_view &type);
|
||||||
bool isTrial() const;
|
bool isTrial() const;
|
||||||
bool isSubscription() const;
|
bool isSubscription() const;
|
||||||
bool isTimeLimited() const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_isTrial = false;
|
bool m_isTrial = false;
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@
|
||||||
#include "utils/trim.h"
|
#include "utils/trim.h"
|
||||||
|
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
|
#include <exception>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
@ -130,12 +131,13 @@ std::optional<time_point> parseDate(const std::string &unixTimeString) {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
auto seconds = std::stoi(clean);
|
auto seconds = std::stol(clean);
|
||||||
if (seconds < 0) {
|
if (seconds <= 0) {
|
||||||
throw InvalidSerialKeyDate(unixTimeString);
|
return std::nullopt;
|
||||||
|
} else {
|
||||||
|
return time_point{std::chrono::seconds{seconds}};
|
||||||
}
|
}
|
||||||
return time_point{std::chrono::seconds{seconds}};
|
} catch (const std::exception &) {
|
||||||
} catch (const std::invalid_argument &) {
|
|
||||||
throw InvalidSerialKeyDate(unixTimeString);
|
throw InvalidSerialKeyDate(unixTimeString);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ TEST_F(LicenseTests, isExpiring_validV2TrialBasicSerial_isExpiring) {
|
||||||
"F6D70616E79206E616D653B313B38363430307D");
|
"F6D70616E79206E616D653B313B38363430307D");
|
||||||
setNow(license, 0);
|
setNow(license, 0);
|
||||||
|
|
||||||
EXPECT_FALSE(license.isExpiring());
|
EXPECT_FALSE(license.isExpiringSoon());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(LicenseTests, isExpiring_validV2TrialBasicSerial_isBasicEdition) {
|
TEST_F(LicenseTests, isExpiring_validV2TrialBasicSerial_isBasicEdition) {
|
||||||
|
|
@ -83,13 +83,13 @@ TEST_F(LicenseTests, isExpiring_validV2TrialBasicSerial_isBasicEdition) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(LicenseTests, isExpiring_expiringV2TrialBasicSerial_returnTrue) {
|
TEST_F(LicenseTests, isExpiring_expiringV2TrialBasicSerial_returnTrue) {
|
||||||
// {v2;trial;basic;Bob;1;email;company name;0;86400}
|
// {v2;trial;basic;Bob;1;email;company name;86400;0}
|
||||||
License license("7B76323B747269616C3B62617369633B426F623B313B656D61696C3B636"
|
License license("7B76323B747269616C3B62617369633B426F623B313B656D61696C3B636"
|
||||||
"F6D70616E79206E616D653B303B38363430307D");
|
"F6D70616E79206E616D653B38363430303B307D");
|
||||||
setNow(license, 1);
|
setNow(license, 86401);
|
||||||
|
|
||||||
EXPECT_TRUE(license.isTrial());
|
EXPECT_TRUE(license.isTrial());
|
||||||
EXPECT_TRUE(license.isExpiring());
|
EXPECT_TRUE(license.isExpiringSoon());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(LicenseTests, isExpired_validV2TrialBasicSerial_returnFalse) {
|
TEST_F(LicenseTests, isExpired_validV2TrialBasicSerial_returnFalse) {
|
||||||
|
|
@ -157,18 +157,18 @@ TEST_F(LicenseTests, isExpiring_validV2SubscriptionBasicSerial_returnFalse) {
|
||||||
setNow(license, 0);
|
setNow(license, 0);
|
||||||
|
|
||||||
EXPECT_TRUE(license.isSubscription());
|
EXPECT_TRUE(license.isSubscription());
|
||||||
EXPECT_FALSE(license.isExpiring());
|
EXPECT_FALSE(license.isExpiringSoon());
|
||||||
EXPECT_EQ(kBasic, license.productEdition());
|
EXPECT_EQ(kBasic, license.productEdition());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(LicenseTests, isExpiring_expiringV2SubscriptionBasicSerial_returnTrue) {
|
TEST_F(LicenseTests, isExpiring_expiringV2SubscriptionBasicSerial_returnTrue) {
|
||||||
// {v2;subscription;basic;Bob;1;email;company name;0;86400}
|
// {v2;subscription;basic;Bob;1;email;company name;86400;0}
|
||||||
License license("7B76323B737562736372697074696F6E3B62617369633B426F623B313B6"
|
License license("7B76323B737562736372697074696F6E3B62617369633B426F623B313B6"
|
||||||
"56D61696C3B636F6D70616E79206E616D653B303B38363430307D");
|
"56D61696C3B636F6D70616E79206E616D653B38363430303B307D");
|
||||||
setNow(license, 1);
|
setNow(license, 86401);
|
||||||
|
|
||||||
EXPECT_TRUE(license.isSubscription());
|
EXPECT_TRUE(license.isSubscription());
|
||||||
EXPECT_TRUE(license.isExpiring());
|
EXPECT_TRUE(license.isExpiringSoon());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(LicenseTests, isExpired_expiredV2SubscriptionBasicSerial_returnTrue) {
|
TEST_F(LicenseTests, isExpired_expiredV2SubscriptionBasicSerial_returnTrue) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue