Skip to content

Commit

Permalink
Remove obsolete code
Browse files Browse the repository at this point in the history
  • Loading branch information
nbolton committed Sep 27, 2024
1 parent c7997f7 commit 277d151
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 57 deletions.
2 changes: 1 addition & 1 deletion deskflow
Submodule deskflow updated 1 files
+1 −1 src/gui/src/main.cpp
4 changes: 2 additions & 2 deletions src/lib/synergy/gui/ActivationDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include "synergy/gui/constants.h"
#include "synergy/gui/license/LicenseHandler.h"
#include "synergy/gui/license/license_notices.h"
#include "synergy/license/ProductEdition.h"
#include "synergy/license/Product.h"
#include "synergy/license/parse_serial_key.h"
#include "ui_ActivationDialog.h"

Expand Down Expand Up @@ -85,7 +85,7 @@ ActivationDialog::~ActivationDialog() { delete m_ui; }
void ActivationDialog::reject() {
// don't show the cancel confirmation dialog if they've already registered,
// since it's not relevant to customers who are changing their serial key.
if (m_licenseHandler.productEdition() != Edition::kUnregistered) {
if (m_licenseHandler.productEdition() != Product::Edition::kUnregistered) {
QDialog::reject();
return;
}
Expand Down
21 changes: 10 additions & 11 deletions src/lib/synergy/gui/license/LicenseHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include "constants.h"
#include "dialogs/UpgradeDialog.h"
#include "synergy/gui/license/license_utils.h"
#include "synergy/license/ProductEdition.h"
#include "synergy/license/Product.h"

#include <QCheckBox>
#include <QCoreApplication>
Expand All @@ -47,8 +47,12 @@ bool LicenseHandler::handleStart(QMainWindow *parent, AppConfig *appConfig) {
m_mainWindow = parent;
m_appConfig = appConfig;

const auto serialKeyAction = parent->addAction(
"Change serial key", &LicenseHandler::onChangeSerialKey);
const auto onChangeSerialKey = [this] {
showActivationDialog(m_mainWindow, m_appConfig);
};

const auto serialKeyAction =
parent->addAction("Change serial key", onChangeSerialKey);

const auto licenseMenu = new QMenu("License");
licenseMenu->addAction(serialKeyAction);
Expand All @@ -66,10 +70,6 @@ bool LicenseHandler::handleStart(QMainWindow *parent, AppConfig *appConfig) {
return showActivationDialog(parent, appConfig);
}

void LicenseHandler::onChangeSerialKey() {
showActivationDialog(m_mainWindow, m_appConfig);
}

bool LicenseHandler::showActivationDialog(QMainWindow *parent,
AppConfig *appConfig) {
ActivationDialog dialog(parent, *appConfig, *this);
Expand All @@ -92,7 +92,7 @@ void LicenseHandler::updateMainWindow() const {
}

void LicenseHandler::handleSettings(QDialog *parent,
QCheckBox *checkBoxEnableTls) {
QCheckBox *checkBoxEnableTls) const {

const auto onTlsToggle = [this, parent, checkBoxEnableTls] {
qDebug("tls checkbox toggled");
Expand All @@ -106,7 +106,7 @@ void LicenseHandler::handleSettings(QDialog *parent,

void LicenseHandler::checkTlsCheckBox(QDialog *parent,
QCheckBox *checkBoxEnableTls,
bool showDialog) {
bool showDialog) const {
if (!m_license.isTlsAvailable() && checkBoxEnableTls->isChecked()) {
qDebug("tls not available, showing upgrade dialog");
checkBoxEnableTls->setChecked(false);
Expand Down Expand Up @@ -140,7 +140,7 @@ const synergy::license::License &LicenseHandler::license() const {
return m_license;
}

Edition LicenseHandler::productEdition() const {
Product::Edition LicenseHandler::productEdition() const {
return m_license.productEdition();
}

Expand All @@ -158,7 +158,6 @@ LicenseHandler::changeSerialKey(const QString &hexString) {

if (hexString.isEmpty()) {
qFatal("serial key is empty");
return kFatal;
}

qDebug() << "changing serial key to:" << hexString;
Expand Down
17 changes: 7 additions & 10 deletions src/lib/synergy/gui/license/LicenseHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,12 @@
#include "synergy/gui/license/LicenseSettings.h"
#include "synergy/gui/license/license_utils.h"
#include "synergy/license/License.h"
#include "synergy/license/ProductEdition.h"

#include <QCheckBox>
#include <QMainWindow>
#include <QObject>
#include <qmainwindow.h>
#include "synergy/license/Product.h"

class AppConfig;
class QMainWindow;
class QDialog;
class QCheckBox;

/**
* @brief A convenience wrapper for `License` that provides Qt signals, etc.
Expand All @@ -52,19 +50,18 @@ class LicenseHandler : public QObject {

void load();
void save();
Edition productEdition() const;
Product::Edition productEdition() const;
const License &license() const;
void validate() const;
QString productName() const;
ChangeSerialKeyResult changeSerialKey(const QString &hexString);
void setEnabled(bool enabled) { m_enabled = enabled; }
bool handleStart(QMainWindow *parent, AppConfig *appConfig);
void handleSettings(QDialog *parent, QCheckBox *checkBoxEnableTls);
void handleSettings(QDialog *parent, QCheckBox *checkBoxEnableTls) const;
void checkTlsCheckBox(QDialog *parent, QCheckBox *checkBoxEnableTls,
bool showDialog);
bool showDialog) const;
void updateMainWindow() const;
bool showActivationDialog(QMainWindow *parent, AppConfig *appConfig);
void onChangeSerialKey();

signals:
void serialKeyChanged(const QString &serialKey) const;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/synergy/gui/license/LicenseSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

#pragma once

#include <QSettings>
#include <QString>
#include <qsettings.h>

namespace synergy::gui::license {

Expand Down
2 changes: 1 addition & 1 deletion src/lib/synergy/license/License.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ bool License::isTlsAvailable() const {
return m_serialKey.product.isTlsAvailable();
}

Edition License::productEdition() const {
Product::Edition License::productEdition() const {
return m_serialKey.product.edition();
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib/synergy/license/License.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class License : public ILicense {
bool isSubscription() const;
bool isTimeLimited() const;
days daysLeft() const;
Edition productEdition() const;
Product::Edition productEdition() const;
std::string productName() const;
const SerialKey &serialKey() const { return m_serialKey; }
void invalidate() { m_serialKey = SerialKey::invalid(); }
Expand Down
23 changes: 0 additions & 23 deletions src/lib/synergy/license/ProductEdition.h

This file was deleted.

6 changes: 2 additions & 4 deletions src/lib/synergy/license/SerialKey.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@

#pragma once

#include "ProductEdition.h"
#include "Product.h"
#include "SerialKeyType.h"
#include "synergy/license/Product.h"
#include "synergy/license/ProductEdition.h"

#include <chrono>
#include <ctime>
Expand Down Expand Up @@ -54,7 +52,7 @@ struct SerialKey {
std::optional<time_point> expireTime = std::nullopt;

private:
explicit SerialKey(Edition edition) : product(edition) {}
explicit SerialKey(Product::Edition edition) : product(edition) {}
};

} // namespace synergy::license
5 changes: 2 additions & 3 deletions src/test/unittests/license/LicenseTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@
#include <chrono>
#define TEST_ENV

#include "synergy/license/ProductEdition.h"

#include "synergy/license/License.h"
#include "synergy/license/Product.h"

#include <climits>
#include <gtest/gtest.h>

using enum Edition;
using enum Product::Edition;
using namespace synergy::license;
using time_point = std::chrono::system_clock::time_point;
using seconds = std::chrono::seconds;
Expand Down

0 comments on commit 277d151

Please sign in to comment.