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