From 99b16334b55f2b195b0718db6b08ee4ca009a223 Mon Sep 17 00:00:00 2001 From: walker0643 <> Date: Sat, 27 Jan 2018 20:21:44 -0500 Subject: [PATCH] remove activation, serial, trial garbage. shame on you all! --- src/cmd/barrierd/CMakeLists.txt | 2 +- src/gui/CMakeLists.txt | 2 +- src/gui/src/ActivationDialog.cpp | 123 --------- src/gui/src/ActivationDialog.h | 35 --- src/gui/src/ActivationDialog.ui | 163 ------------ src/gui/src/ActivationNotifier.cpp | 60 ----- src/gui/src/ActivationNotifier.h | 47 ---- src/gui/src/AppConfig.cpp | 59 +---- src/gui/src/AppConfig.h | 23 +- src/gui/src/CancelActivationDialog.cpp | 14 - src/gui/src/CancelActivationDialog.h | 22 -- src/gui/src/CancelActivationDialog.ui | 89 ------- src/gui/src/FailedLoginDialog.cpp | 15 -- src/gui/src/FailedLoginDialog.h | 23 -- src/gui/src/FailedLoginDialog.ui | 108 -------- src/gui/src/LicenseManager.cpp | 168 ------------ src/gui/src/LicenseManager.h | 54 ---- src/gui/src/MainWindow.cpp | 174 +----------- src/gui/src/MainWindow.h | 16 +- src/gui/src/MainWindowBase.ui | 59 ----- src/gui/src/SettingsDialog.cpp | 1 - src/gui/src/SettingsDialogBase.ui | 3 - src/gui/src/SetupWizard.cpp | 2 - src/gui/src/main.cpp | 5 +- src/lib/CMakeLists.txt | 1 - src/lib/barrier/ArgParser.cpp | 3 - src/lib/barrier/ServerArgs.cpp | 1 - src/lib/barrier/ServerArgs.h | 2 - src/lib/barrier/ToolApp.cpp | 1 - src/lib/server/CMakeLists.txt | 2 +- src/lib/server/Server.cpp | 7 - src/lib/shared/CMakeLists.txt | 26 -- src/lib/shared/EditionType.h | 30 --- src/lib/shared/SerialKey.cpp | 265 ------------------- src/lib/shared/SerialKey.h | 84 ------ src/test/unittests/CMakeLists.txt | 2 +- src/test/unittests/shared/SerialKeyTests.cpp | 147 ---------- 37 files changed, 19 insertions(+), 1819 deletions(-) delete mode 100644 src/gui/src/ActivationDialog.cpp delete mode 100644 src/gui/src/ActivationDialog.h delete mode 100644 src/gui/src/ActivationDialog.ui delete mode 100644 src/gui/src/ActivationNotifier.cpp delete mode 100644 src/gui/src/ActivationNotifier.h delete mode 100644 src/gui/src/CancelActivationDialog.cpp delete mode 100644 src/gui/src/CancelActivationDialog.h delete mode 100644 src/gui/src/CancelActivationDialog.ui delete mode 100644 src/gui/src/FailedLoginDialog.cpp delete mode 100644 src/gui/src/FailedLoginDialog.h delete mode 100644 src/gui/src/FailedLoginDialog.ui delete mode 100644 src/gui/src/LicenseManager.cpp delete mode 100644 src/gui/src/LicenseManager.h delete mode 100644 src/lib/shared/CMakeLists.txt delete mode 100644 src/lib/shared/EditionType.h delete mode 100644 src/lib/shared/SerialKey.cpp delete mode 100644 src/lib/shared/SerialKey.h delete mode 100644 src/test/unittests/shared/SerialKeyTests.cpp diff --git a/src/cmd/barrierd/CMakeLists.txt b/src/cmd/barrierd/CMakeLists.txt index a8b070c3..aeae94cd 100644 --- a/src/cmd/barrierd/CMakeLists.txt +++ b/src/cmd/barrierd/CMakeLists.txt @@ -24,4 +24,4 @@ else() endif() target_link_libraries (barrierd - arch base common io ipc mt net platform synlib shared ${libs} ${OPENSSL_LIBS}) + arch base common io ipc mt net platform synlib ${libs} ${OPENSSL_LIBS}) diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index bfdd53ea..70daa566 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -21,7 +21,7 @@ add_executable (barrier WIN32 ) include_directories (./src) -target_link_libraries (barrier shared) +target_link_libraries (barrier) if (WIN32) include_directories ($ENV{BONJOUR_SDK_HOME}/Include) diff --git a/src/gui/src/ActivationDialog.cpp b/src/gui/src/ActivationDialog.cpp deleted file mode 100644 index 95571e71..00000000 --- a/src/gui/src/ActivationDialog.cpp +++ /dev/null @@ -1,123 +0,0 @@ -#include "ActivationDialog.h" -#include "ui_ActivationDialog.h" -#include "CancelActivationDialog.h" -#include "AppConfig.h" -#include "WebClient.h" -#include -#include "ActivationNotifier.h" -#include "MainWindow.h" -#include "QUtility.h" -#include "LicenseManager.h" -#include "FailedLoginDialog.h" - -#include -#include -#include - -ActivationDialog::ActivationDialog(QWidget* parent, AppConfig& appConfig, - LicenseManager& licenseManager) : - QDialog(parent), - ui(new Ui::ActivationDialog), - m_appConfig(&appConfig), - m_LicenseManager (&licenseManager) -{ - ui->setupUi(this); - refreshSerialKey(); - time_t currentTime = ::time(0); - if (!m_LicenseManager->serialKey().isExpired(currentTime)) { - ui->m_trialWidget->hide(); - } -} - -void ActivationDialog::refreshSerialKey() -{ - ui->m_pTextEditSerialKey->setText(m_appConfig->serialKey()); - ui->m_pTextEditSerialKey->setFocus(); - ui->m_pTextEditSerialKey->moveCursor(QTextCursor::End); - ui->m_trialLabel->setText(tr("

Your trial has " - "expired. Buy now!" - "

") - .arg (m_appConfig->serialKey())); -} - -ActivationDialog::~ActivationDialog() -{ - delete ui; -} - -void ActivationDialog::reject() -{ - if (m_LicenseManager->activeEdition() == kUnregistered) { - CancelActivationDialog cancelActivationDialog(this); - if (QDialog::Accepted == cancelActivationDialog.exec()) { - m_LicenseManager->skipActivation(); - m_appConfig->activationHasRun(true); - m_appConfig->saveSettings(); - } else { - return; - } - } - QDialog::reject(); -} - -void ActivationDialog::accept() -{ - QMessageBox message; - m_appConfig->activationHasRun(true); - m_appConfig->saveSettings(); - - std::pair result; - try { - SerialKey serialKey (ui->m_pTextEditSerialKey->toPlainText(). - trimmed().toStdString()); - result = m_LicenseManager->setSerialKey(serialKey); - } - catch (std::exception& e) { - message.critical(this, "Unknown Error", - tr("An error occurred while trying to activate Barrier. " - "Please contact the helpdesk, and provide the " - "following information:\n\n%1").arg(e.what())); - refreshSerialKey(); - return; - } - - if (!result.first) { - message.critical(this, "Activation failed", - tr("%1").arg(result.second)); - refreshSerialKey(); - return; - } - - m_LicenseManager->notifyActivation("serial:" + m_appConfig->serialKey()); - Edition edition = m_LicenseManager->activeEdition(); - time_t daysLeft = m_LicenseManager->serialKey().daysLeft(::time(0)); - if (edition != kUnregistered) { - QString thanksMessage = tr("Thanks for trying %1! %5\n\n%2 day%3 of " - "your trial remain%4"). - arg (m_LicenseManager->getEditionName(edition)). - arg (daysLeft). - arg ((daysLeft == 1) ? "" : "s"). - arg ((daysLeft == 1) ? "s" : ""); - - if (edition == kPro) { - thanksMessage = thanksMessage.arg("If you're using SSL, " - "remember to activate all of your devices."); - } else { - thanksMessage = thanksMessage.arg(""); - } - - if (m_LicenseManager->serialKey().isTrial()) { - message.information(this, "Thanks!", thanksMessage); - } - else { - message.information(this, "Activated!", - tr("Thanks for activating %1!").arg - (m_LicenseManager->getEditionName(edition))); - } - } - - QDialog::accept(); -} diff --git a/src/gui/src/ActivationDialog.h b/src/gui/src/ActivationDialog.h deleted file mode 100644 index 0644bfc9..00000000 --- a/src/gui/src/ActivationDialog.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef ACTIVATIONDIALOG_H -#define ACTIVATIONDIALOG_H - -#include -#include - -namespace Ui { -class ActivationDialog; -} - -class AppConfig; - -class ActivationDialog : public QDialog -{ - Q_OBJECT - -public: - ActivationDialog(QWidget *parent, AppConfig& appConfig, - LicenseManager& licenseManager); - ~ActivationDialog(); - -public slots: - void reject(); - void accept(); - -protected: - void refreshSerialKey(); - -private: - Ui::ActivationDialog *ui; - AppConfig* m_appConfig; - LicenseManager* m_LicenseManager; -}; - -#endif // ACTIVATIONDIALOG_H diff --git a/src/gui/src/ActivationDialog.ui b/src/gui/src/ActivationDialog.ui deleted file mode 100644 index 6d33eddf..00000000 --- a/src/gui/src/ActivationDialog.ui +++ /dev/null @@ -1,163 +0,0 @@ - - - ActivationDialog - - - - 0 - 0 - 410 - 211 - - - - Activate Barrier - - - - - - - 75 - true - - - - Serial key - - - - - - - <html><head/><body><p>This can be found on your <a href="https://symless.com/account/?source=gui"><span style=" text-decoration: underline; color:#0000ff;">account</span></a> page.</p></body></html> - - - true - - - - - - - true - - - true - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html> - - - false - - - - - - - - 2 - - - 0 - - - 0 - - - 8 - - - - - - - - :/res/icons/16x16/money.png - - - - - - - <html><head/><body><p>Your trial has expired. <a href="http://symless.com/pricing?src=gui"><span style=" text-decoration: underline; color:#0000ff;">Buy now!</span></a></p></body></html> - - - true - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - m_pTextEditSerialKey - - - - - - - buttonBox - accepted() - ActivationDialog - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - ActivationDialog - reject() - - - 316 - 260 - - - 286 - 274 - - - - - diff --git a/src/gui/src/ActivationNotifier.cpp b/src/gui/src/ActivationNotifier.cpp deleted file mode 100644 index 9147fbe2..00000000 --- a/src/gui/src/ActivationNotifier.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/* - * barrier -- mouse and keyboard sharing utility - * Copyright (C) 2015 Barrier Seamless Inc. - * - * This package is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * found in the file LICENSE that should have accompanied this file. - * - * This package is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "ActivationNotifier.h" - -#include "CoreInterface.h" - -ActivationNotifier::ActivationNotifier(QObject *parent) : - QObject(parent) -{ -} - -void ActivationNotifier::setIdentity(QString identity) -{ - m_Identity = identity; -} - -void ActivationNotifier::setUpdateInfo(QString const& fromVersion, - QString const& toVersion, - QString const& serialKey) -{ - m_fromVersion = fromVersion; - m_toVersion = toVersion; - m_serialKey = serialKey; -} - -void ActivationNotifier::notify() -{ - CoreInterface coreInterface; - try { - coreInterface.notifyActivation(m_Identity); - } - catch (...) { - // catch all exceptions and fails silently - } -} - -void ActivationNotifier::notifyUpdate() -{ - try { - CoreInterface coreInterface; - coreInterface.notifyUpdate(m_fromVersion, m_toVersion, - m_serialKey); - } catch (...) { - } -} diff --git a/src/gui/src/ActivationNotifier.h b/src/gui/src/ActivationNotifier.h deleted file mode 100644 index 2c0a0cd8..00000000 --- a/src/gui/src/ActivationNotifier.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * barrier -- mouse and keyboard sharing utility - * Copyright (C) 2015 Barrier Seamless Inc. - * - * This package is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * found in the file LICENSE that should have accompanied this file. - * - * This package is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef ACTIVATIONNOTIFIER_H -#define ACTIVATIONNOTIFIER_H - -#include - -class ActivationNotifier : public QObject -{ -Q_OBJECT -public: - explicit ActivationNotifier(QObject *parent = 0); - - void setIdentity(QString identity); - void setUpdateInfo(QString const& fromVersion, - QString const& toVersion, QString const& serialKey); - -public slots: - void notify(); - void notifyUpdate(); - -signals: - void finished(); - -private: - QString m_Identity; - QString m_fromVersion; - QString m_toVersion; - QString m_serialKey; -}; - -#endif // ACTIVATIONNOTIFIER_H diff --git a/src/gui/src/AppConfig.cpp b/src/gui/src/AppConfig.cpp index ab674306..23374fe7 100644 --- a/src/gui/src/AppConfig.cpp +++ b/src/gui/src/AppConfig.cpp @@ -59,8 +59,7 @@ AppConfig::AppConfig(QSettings* settings) : m_ElevateMode(defaultElevateMode), m_AutoConfigPrompted(false), m_CryptoEnabled(false), - m_AutoHide(false), - m_LastExpiringWarningTime(0) + m_AutoHide(false) { Q_ASSERT(m_pSettings); @@ -156,14 +155,8 @@ void AppConfig::loadSettings() } m_ElevateMode = static_cast(elevateMode.toInt()); m_AutoConfigPrompted = settings().value("autoConfigPrompted", false).toBool(); - m_Edition = static_cast(settings().value("edition", kUnregistered).toInt()); - m_ActivateEmail = settings().value("activateEmail", "").toString(); m_CryptoEnabled = settings().value("cryptoEnabled", true).toBool(); m_AutoHide = settings().value("autoHide", false).toBool(); - m_Serialkey = settings().value("serialKey", "").toString().trimmed(); - m_lastVersion = settings().value("lastVersion", "Unknown").toString(); - m_LastExpiringWarningTime = settings().value("lastExpiringWarningTime", 0).toInt(); - m_ActivationHasRun = settings().value("activationHasRun", false).toBool(); } void AppConfig::saveSettings() @@ -183,36 +176,11 @@ void AppConfig::saveSettings() settings().setValue("elevateMode", m_ElevateMode == ElevateAlways); settings().setValue("elevateModeEnum", static_cast(m_ElevateMode)); settings().setValue("autoConfigPrompted", m_AutoConfigPrompted); - settings().setValue("edition", m_Edition); settings().setValue("cryptoEnabled", m_CryptoEnabled); settings().setValue("autoHide", m_AutoHide); - settings().setValue("serialKey", m_Serialkey); - settings().setValue("lastVersion", m_lastVersion); - settings().setValue("lastExpiringWarningTime", m_LastExpiringWarningTime); - settings().setValue("activationHasRun", m_ActivationHasRun); settings().sync(); } -bool AppConfig::activationHasRun() const -{ - return m_ActivationHasRun; -} - -AppConfig& AppConfig::activationHasRun(bool value) -{ - m_ActivationHasRun = value; - return *this; -} - -QString AppConfig::lastVersion() const -{ - return m_lastVersion; -} - -void AppConfig::setLastVersion(QString version) { - m_lastVersion = version; -} - QSettings &AppConfig::settings() { return *m_pSettings; } void AppConfig::setScreenName(const QString &s) { m_ScreenName = s; } @@ -247,29 +215,6 @@ void AppConfig::setAutoConfigPrompted(bool prompted) m_AutoConfigPrompted = prompted; } -void AppConfig::setEdition(Edition e) { - m_Edition = e; -} - -Edition AppConfig::edition() const { return m_Edition; } - -QString AppConfig::setSerialKey(QString serial) { - using std::swap; - swap (serial, m_Serialkey); - return serial; -} - -void AppConfig::clearSerialKey() -{ - m_Serialkey.clear(); -} - -QString AppConfig::serialKey() { return m_Serialkey; } - -int AppConfig::lastExpiringWarningTime() const { return m_LastExpiringWarningTime; } - -void AppConfig::setLastExpiringWarningTime(int t) { m_LastExpiringWarningTime = t; } - QString AppConfig::barriersName() const { return m_BarriersName; } QString AppConfig::barriercName() const { return m_BarriercName; } @@ -285,7 +230,7 @@ void AppConfig::setCryptoEnabled(bool e) { } bool AppConfig::getCryptoEnabled() const { - return (edition() == kPro) && m_CryptoEnabled; + return m_CryptoEnabled; } void AppConfig::setAutoHide(bool b) { m_AutoHide = b; } diff --git a/src/gui/src/AppConfig.h b/src/gui/src/AppConfig.h index c9fbda0e..fd4c298a 100644 --- a/src/gui/src/AppConfig.h +++ b/src/gui/src/AppConfig.h @@ -23,7 +23,6 @@ #include #include #include "ElevateMode.h" -#include // this should be incremented each time a new page is added. this is // saved to settings when the user finishes running the wizard. if @@ -39,8 +38,9 @@ // 6: ssl plugin 'ns' v1.2 // 7: serial key activation // 8: Visual Studio 2015 support +// 9: synergy->barrier and de-commercialized // -const int kWizardVersion = 8; +const int kWizardVersion = 9; class QSettings; class SettingsDialog; @@ -79,13 +79,6 @@ class AppConfig: public QObject void setAutoConfig(bool autoConfig); bool autoConfigPrompted(); void setAutoConfigPrompted(bool prompted); - void setEdition(Edition); - Edition edition() const; - QString setSerialKey(QString serial); - void clearSerialKey(); - QString serialKey(); - int lastExpiringWarningTime() const; - void setLastExpiringWarningTime(int t); QString barriersName() const; QString barriercName() const; @@ -102,13 +95,7 @@ class AppConfig: public QObject void setAutoHide(bool b); bool getAutoHide(); - bool activationHasRun() const; - AppConfig& activationHasRun(bool value); - - QString lastVersion() const; - void saveSettings(); - void setLastVersion(QString version); protected: QSettings& settings(); @@ -139,14 +126,8 @@ protected: bool m_AutoConfig; ElevateMode m_ElevateMode; bool m_AutoConfigPrompted; - Edition m_Edition; - QString m_ActivateEmail; bool m_CryptoEnabled; bool m_AutoHide; - QString m_Serialkey; - QString m_lastVersion; - int m_LastExpiringWarningTime; - bool m_ActivationHasRun; static const char m_BarriersName[]; static const char m_BarriercName[]; diff --git a/src/gui/src/CancelActivationDialog.cpp b/src/gui/src/CancelActivationDialog.cpp deleted file mode 100644 index 3397309e..00000000 --- a/src/gui/src/CancelActivationDialog.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include "CancelActivationDialog.h" -#include "ui_CancelActivationDialog.h" - -CancelActivationDialog::CancelActivationDialog(QWidget *parent) : - QDialog(parent), - ui(new Ui::CancelActivationDialog) -{ - ui->setupUi(this); -} - -CancelActivationDialog::~CancelActivationDialog() -{ - delete ui; -} diff --git a/src/gui/src/CancelActivationDialog.h b/src/gui/src/CancelActivationDialog.h deleted file mode 100644 index bd387186..00000000 --- a/src/gui/src/CancelActivationDialog.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef CANCELACTIVATIONDIALOG_H -#define CANCELACTIVATIONDIALOG_H - -#include - -namespace Ui { -class CancelActivationDialog; -} - -class CancelActivationDialog : public QDialog -{ - Q_OBJECT - -public: - explicit CancelActivationDialog(QWidget *parent = 0); - ~CancelActivationDialog(); - -private: - Ui::CancelActivationDialog *ui; -}; - -#endif // CANCELACTIVATIONDIALOG_H diff --git a/src/gui/src/CancelActivationDialog.ui b/src/gui/src/CancelActivationDialog.ui deleted file mode 100644 index 397913c3..00000000 --- a/src/gui/src/CancelActivationDialog.ui +++ /dev/null @@ -1,89 +0,0 @@ - - - CancelActivationDialog - - - - 0 - 0 - 400 - 165 - - - - Cancel Activation - - - - - - Are you sure? - -If you don't activate Barrier you'll be missing out on some great features. - - - true - - - true - - - - - - - <html><head/><body><p><a href="https://symless.com/pricing?source=gui"><span style=" text-decoration: underline; color:#0000ff;">Buy now</span></a></p></body></html> - - - true - - - - - - - Qt::Horizontal - - - QDialogButtonBox::No|QDialogButtonBox::Yes - - - - - - - - - buttonBox - accepted() - CancelActivationDialog - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - CancelActivationDialog - reject() - - - 316 - 260 - - - 286 - 274 - - - - - diff --git a/src/gui/src/FailedLoginDialog.cpp b/src/gui/src/FailedLoginDialog.cpp deleted file mode 100644 index ba53ce45..00000000 --- a/src/gui/src/FailedLoginDialog.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include "FailedLoginDialog.h" -#include "ui_FailedLoginDialog.h" - -FailedLoginDialog::FailedLoginDialog(QWidget *parent, QString message): - QDialog(parent), - ui(new Ui::FailedLoginDialog) -{ - ui->setupUi(this); - ui->messageLabel->setText(ui->messageLabel->text().arg(message)); -} - -FailedLoginDialog::~FailedLoginDialog() -{ - delete ui; -} diff --git a/src/gui/src/FailedLoginDialog.h b/src/gui/src/FailedLoginDialog.h deleted file mode 100644 index d15bd706..00000000 --- a/src/gui/src/FailedLoginDialog.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef FAILEDLOGINDIALOG_H -#define FAILEDLOGINDIALOG_H - -#include -#include - -namespace Ui { -class FailedLoginDialog; -} - -class FailedLoginDialog : public QDialog -{ - Q_OBJECT - -public: - explicit FailedLoginDialog(QWidget *parent = 0, QString message = ""); - ~FailedLoginDialog(); - -private: - Ui::FailedLoginDialog *ui; -}; - -#endif // FAILEDLOGINDIALOG_H diff --git a/src/gui/src/FailedLoginDialog.ui b/src/gui/src/FailedLoginDialog.ui deleted file mode 100644 index 526d1781..00000000 --- a/src/gui/src/FailedLoginDialog.ui +++ /dev/null @@ -1,108 +0,0 @@ - - - FailedLoginDialog - - - - 0 - 0 - 400 - 165 - - - - Activation Error - - - - - 50 - 120 - 341 - 32 - - - - Qt::Horizontal - - - QDialogButtonBox::Close - - - - - - 10 - 90 - 382 - 30 - - - - <html><head/><body><p><a href="https://symless.com/account/reset/?source=gui"><span style=" text-decoration: underline; color:#0000ff;">Forgotten your password?</span></a></p></body></html> - - - true - - - - - - 10 - 10 - 382 - 72 - - - - An error occurred while trying to activate Barrier. The Symless server returned the following error: - -%1 - - - true - - - true - - - label_2 - messageLabel - buttonBox - - - - - buttonBox - accepted() - FailedLoginDialog - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - FailedLoginDialog - reject() - - - 316 - 260 - - - 286 - 274 - - - - - diff --git a/src/gui/src/LicenseManager.cpp b/src/gui/src/LicenseManager.cpp deleted file mode 100644 index 30262ff3..00000000 --- a/src/gui/src/LicenseManager.cpp +++ /dev/null @@ -1,168 +0,0 @@ -/* - * barrier -- mouse and keyboard sharing utility - * Copyright (C) 2015 Barrier Seamless Inc. - * - * This package is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * found in the file LICENSE that should have accompanied this file. - * - * This package is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "LicenseManager.h" -#include "AppConfig.h" -#include -#include -#include -#include - -LicenseManager::LicenseManager(AppConfig* appConfig) : - m_AppConfig(appConfig), - m_serialKey(appConfig->edition()) { -} - -std::pair -LicenseManager::setSerialKey(SerialKey serialKey, bool acceptExpired) -{ - std::pair ret (true, ""); - time_t currentTime = ::time(0); - - if (!acceptExpired && serialKey.isExpired(currentTime)) { - ret.first = false; - ret.second = "Serial key expired"; - return ret; - } - - if (serialKey != m_serialKey) { - using std::swap; - swap (serialKey, m_serialKey); - m_AppConfig->setSerialKey(QString::fromStdString - (m_serialKey.toString())); - emit serialKeyChanged(m_serialKey); - - if (serialKey.isTrial()) { - emit endTrial(false); - } - - if (m_serialKey.edition() != serialKey.edition()) { - m_AppConfig->setEdition(m_serialKey.edition()); - emit editionChanged(m_serialKey.edition()); - } - - if (m_serialKey.isTrial()) { - if (m_serialKey.isExpired(currentTime)) { - emit endTrial(true); - } else { - emit beginTrial(m_serialKey.isExpiring(currentTime)); - } - } - - m_AppConfig->saveSettings(); - } - - return ret; -} - -void -LicenseManager::notifyUpdate(QString fromVersion, QString toVersion) { - if ((fromVersion == "Unknown") - && (m_serialKey == SerialKey(kUnregistered))) { - return; - } - - ActivationNotifier* notifier = new ActivationNotifier(); - notifier->setUpdateInfo (fromVersion, toVersion, - QString::fromStdString(m_serialKey.toString())); - - QThread* thread = new QThread(); - connect(notifier, SIGNAL(finished()), thread, SLOT(quit())); - connect(notifier, SIGNAL(finished()), notifier, SLOT(deleteLater())); - connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater())); - - notifier->moveToThread(thread); - thread->start(); - - QMetaObject::invokeMethod(notifier, "notifyUpdate", - Qt::QueuedConnection); -} - -Edition -LicenseManager::activeEdition() const -{ - return m_serialKey.edition(); -} - -QString -LicenseManager::activeEditionName() const -{ - return getEditionName(activeEdition(), m_serialKey.isTrial()); -} - -SerialKey -LicenseManager::serialKey() const -{ - return m_serialKey; -} - -void LicenseManager::refresh() -{ - if (!m_AppConfig->serialKey().isEmpty()) { - try { - SerialKey serialKey (m_AppConfig->serialKey().toStdString()); - setSerialKey(serialKey, true); - } catch (...) { - m_AppConfig->clearSerialKey(); - m_AppConfig->saveSettings(); - } - } - if (m_serialKey.isExpired(::time(0))) { - emit endTrial(true); - } -} - -void LicenseManager::skipActivation() -{ - notifyActivation ("skip:unknown"); -} - -QString -LicenseManager::getEditionName(Edition const edition, bool trial) -{ - std::string name ("Barrier"); - switch (edition) { - case kUnregistered: - name += " (UNREGISTERED)"; - return QString::fromUtf8 (name.c_str(), name.size()); - case kBasic: - name += " Basic"; - break; - default: - name += " Pro"; - } - if (trial) { - name += " (Trial)"; - } - return QString::fromUtf8 (name.c_str(), name.size()); -} - -void LicenseManager::notifyActivation(QString identity) -{ - ActivationNotifier* notifier = new ActivationNotifier(); - notifier->setIdentity(identity); - - QThread* thread = new QThread(); - connect(notifier, SIGNAL(finished()), thread, SLOT(quit())); - connect(notifier, SIGNAL(finished()), notifier, SLOT(deleteLater())); - connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater())); - - notifier->moveToThread(thread); - thread->start(); - - QMetaObject::invokeMethod(notifier, "notify", Qt::QueuedConnection); -} diff --git a/src/gui/src/LicenseManager.h b/src/gui/src/LicenseManager.h deleted file mode 100644 index 8cf931c7..00000000 --- a/src/gui/src/LicenseManager.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * barrier -- mouse and keyboard sharing utility - * Copyright (C) 2015 Barrier Seamless Inc. - * - * This package is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * found in the file LICENSE that should have accompanied this file. - * - * This package is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once - -#include -#include -#include -#include -#include - -class AppConfig; - -class LicenseManager: public QObject -{ - Q_OBJECT - -public: - LicenseManager(AppConfig* appConfig); - std::pair setSerialKey(SerialKey serialKey, - bool acceptExpired = false); - void refresh(); - Edition activeEdition() const; - QString activeEditionName() const; - SerialKey serialKey() const; - void skipActivation(); - void notifyUpdate(QString fromVersion, QString toVersion); - static QString getEditionName(Edition edition, bool trial = false); - void notifyActivation(QString identity); - -private: - AppConfig* m_AppConfig; - SerialKey m_serialKey; - -signals: - void serialKeyChanged (SerialKey) const; - void editionChanged (Edition) const; - void beginTrial (bool expiring) const; - void endTrial (bool expired) const; -}; diff --git a/src/gui/src/MainWindow.cpp b/src/gui/src/MainWindow.cpp index cb858b24..68d7063d 100644 --- a/src/gui/src/MainWindow.cpp +++ b/src/gui/src/MainWindow.cpp @@ -26,12 +26,9 @@ #include "AboutDialog.h" #include "ServerConfigDialog.h" #include "SettingsDialog.h" -#include "ActivationDialog.h" #include "ZeroconfService.h" #include "DataDownloader.h" #include "CommandProcess.h" -#include "LicenseManager.h" -#include #include "QUtility.h" #include "ProcessorArch.h" #include "SslCertificate.h" @@ -76,11 +73,9 @@ static const char* barrierIconFiles[] = ":/res/icons/16x16/barrier-transfering.png" }; -MainWindow::MainWindow(QSettings& settings, AppConfig& appConfig, - LicenseManager& licenseManager) : +MainWindow::MainWindow(QSettings& settings, AppConfig& appConfig) : m_Settings(settings), m_AppConfig(&appConfig), - m_LicenseManager(&licenseManager), m_pBarrier(NULL), m_BarrierState(barrierDisconnected), m_ServerConfig(&m_Settings, 5, 3, m_AppConfig->screenName(), this), @@ -101,8 +96,7 @@ MainWindow::MainWindow(QSettings& settings, AppConfig& appConfig, m_BonjourInstall(NULL), m_SuppressEmptyServerWarning(false), m_ExpectedRunningState(kStopped), - m_pSslCertificate(NULL), - m_ActivationDialogRunning(false) + m_pSslCertificate(NULL) { setupUi(this); @@ -138,33 +132,12 @@ MainWindow::MainWindow(QSettings& settings, AppConfig& appConfig, m_pComboServerList->hide(); m_pLabelPadlock->hide(); - m_trialWidget->hide(); connect (this, SIGNAL(windowShown()), this, SLOT(on_windowShown()), Qt::QueuedConnection); - connect (m_LicenseManager, SIGNAL(editionChanged(Edition)), - this, SLOT(setEdition(Edition)), Qt::QueuedConnection); - - connect (m_LicenseManager, SIGNAL(beginTrial(bool)), - this, SLOT(beginTrial(bool)), Qt::QueuedConnection); - - connect (m_LicenseManager, SIGNAL(endTrial(bool)), - this, SLOT(endTrial(bool)), Qt::QueuedConnection); - connect (m_AppConfig, SIGNAL(sslToggled(bool)), this, SLOT(sslToggled(bool)), Qt::QueuedConnection); - - setWindowTitle (m_LicenseManager->activeEditionName()); - m_LicenseManager->refresh(); - - QString lastVersion = m_AppConfig->lastVersion(); - QString currentVersion = m_VersionChecker.getVersion(); - if (lastVersion != currentVersion) { - m_AppConfig->setLastVersion (currentVersion); - m_AppConfig->saveSettings(); - m_LicenseManager->notifyUpdate (lastVersion, currentVersion); - } } MainWindow::~MainWindow() @@ -291,8 +264,6 @@ void MainWindow::createMenuBar() m_pMenuFile->addAction(m_pActionStartBarrier); m_pMenuFile->addAction(m_pActionStopBarrier); m_pMenuFile->addSeparator(); - m_pMenuFile->addAction(m_pActivate); - m_pMenuFile->addSeparator(); m_pMenuFile->addAction(m_pActionSave); m_pMenuFile->addSeparator(); m_pMenuFile->addAction(m_pActionQuit); @@ -431,7 +402,6 @@ void MainWindow::updateFromLogLine(const QString &line) // TODO: this code makes Andrew cry checkConnected(line); checkFingerprint(line); - checkLicense(line); } void MainWindow::checkConnected(const QString& line) @@ -456,14 +426,6 @@ void MainWindow::checkConnected(const QString& line) } } -void MainWindow::checkLicense(const QString &line) -{ - if (line.contains("trial has expired")) { - licenseManager().refresh(); - raiseActivationDialog(); - } -} - void MainWindow::checkFingerprint(const QString& line) { QRegExp fingerprintRegex(".*server fingerprint: ([A-F0-9:]+)"); @@ -532,8 +494,12 @@ void MainWindow::restartBarrier() void MainWindow::proofreadInfo() { - setEdition(m_AppConfig->edition()); // Why is this here? - + if (m_AppConfig->getCryptoEnabled()) { + m_pSslCertificate = new SslCertificate(this); + m_pSslCertificate->generateCertificate(); + } + updateLocalFingerprint(); + saveSettings(); int oldState = m_BarrierState; m_BarrierState = barrierDisconnected; setBarrierState((qBarrierState)oldState); @@ -552,14 +518,6 @@ void MainWindow::clearLog() void MainWindow::startBarrier() { - SerialKey serialKey = m_LicenseManager->serialKey(); - time_t currentTime = ::time(0); - if (serialKey.isExpired(currentTime)) { - if (QDialog::Rejected == raiseActivationDialog()) { - return; - } - } - bool desktopMode = appConfig().processMode() == Desktop; bool serviceMode = appConfig().processMode() == Service; @@ -804,10 +762,6 @@ bool MainWindow::serverArgs(QStringList& args, QString& app) #endif args << "-c" << configFilename << "--address" << address(); - if (!appConfig().serialKey().isEmpty()) { - args << "--serial-key" << appConfig().serialKey(); - } - return true; } @@ -1054,68 +1008,6 @@ void MainWindow::serverDetected(const QString name) } } -void MainWindow::setEdition(Edition edition) -{ - setWindowTitle(m_LicenseManager->getEditionName (edition)); - if (m_AppConfig->getCryptoEnabled()) { - m_pSslCertificate = new SslCertificate(this); - m_pSslCertificate->generateCertificate(); - } - updateLocalFingerprint(); - saveSettings(); -} - -void MainWindow::beginTrial(bool isExpiring) -{ - //Hack - //if (isExpiring) { - time_t daysLeft = m_LicenseManager->serialKey().daysLeft(::time(0)); - QString expiringNotice ("

%1 day%3 of " - "your %2 trial remain%5. " - "Buy now!" - "

"); - expiringNotice = expiringNotice - .arg (daysLeft) - .arg (LicenseManager::getEditionName - (m_LicenseManager->activeEdition())) - .arg ((daysLeft == 1) ? "" : "s") - .arg (QString::fromStdString - (m_LicenseManager->serialKey().toString())) - .arg ((daysLeft == 1) ? "s" : ""); - this->m_trialLabel->setText(expiringNotice); - this->m_trialWidget->show(); - //} - setWindowTitle (m_LicenseManager->activeEditionName()); -} - -void MainWindow::endTrial(bool isExpired) -{ - if (isExpired) { - QString expiredNotice ( - "

Your %1 trial has expired. " - "" - "Buy now!

" - ); - expiredNotice = expiredNotice - .arg(LicenseManager::getEditionName - (m_LicenseManager->activeEdition())) - .arg(QString::fromStdString - (m_LicenseManager->serialKey().toString())); - - this->m_trialLabel->setText(expiredNotice); - this->m_trialWidget->show(); - stopBarrier(); - m_AppConfig->activationHasRun(false); - } else { - this->m_trialWidget->hide(); - } - setWindowTitle (m_LicenseManager->activeEditionName()); -} - void MainWindow::updateLocalFingerprint() { if (m_AppConfig->getCryptoEnabled() && Fingerprint::local().fileExists()) { @@ -1129,12 +1021,6 @@ void MainWindow::updateLocalFingerprint() } } -LicenseManager& -MainWindow::licenseManager() const -{ - return *m_LicenseManager; -} - void MainWindow::on_m_pGroupClient_toggled(bool on) { m_pGroupServer->setChecked(!on); @@ -1199,14 +1085,6 @@ void MainWindow::on_m_pActionSettings_triggered() void MainWindow::autoAddScreen(const QString name) { if (!m_ServerConfig.ignoreAutoConfigClient()) { - if (m_ActivationDialogRunning) { - // TODO: refactor this code - // add this screen to the pending list and check this list until - // users finish activation dialog - m_PendingClientNames.append(name); - return; - } - int r = m_ServerConfig.autoAddScreen(name); if (r != kAutoAddScreenOk) { switch (r) { @@ -1242,11 +1120,6 @@ void MainWindow::on_m_pButtonConfigureServer_clicked() showConfigureServer(); } -void MainWindow::on_m_pActivate_triggered() -{ - raiseActivationDialog(); -} - void MainWindow::on_m_pButtonApply_clicked() { restartBarrier(); @@ -1456,38 +1329,9 @@ void MainWindow::bonjourInstallFinished() m_pCheckBoxAutoConfig->setChecked(true); } -int MainWindow::raiseActivationDialog() -{ - if (m_ActivationDialogRunning) { - return QDialog::Rejected; - } - ActivationDialog activationDialog (this, appConfig(), licenseManager()); - m_ActivationDialogRunning = true; - connect (&activationDialog, SIGNAL(finished(int)), - this, SLOT(on_activationDialogFinish()), Qt::QueuedConnection); - int result = activationDialog.exec(); - m_ActivationDialogRunning = false; - if (!m_PendingClientNames.empty()) { - foreach (const QString& name, m_PendingClientNames) { - autoAddScreen(name); - } - - m_PendingClientNames.clear(); - } - if (result == QDialog::Accepted) { - restartBarrier(); - } - return result; -} - void MainWindow::on_windowShown() { - time_t currentTime = ::time(0); - if (!m_AppConfig->activationHasRun() - && ((m_AppConfig->edition() == kUnregistered) || - (m_LicenseManager->serialKey().isExpired(currentTime)))) { - raiseActivationDialog(); - } + // removed activation garbage; leaving stub to be optimized out } QString MainWindow::getProfileRootForArg() diff --git a/src/gui/src/MainWindow.h b/src/gui/src/MainWindow.h index def85fe3..92de8c78 100644 --- a/src/gui/src/MainWindow.h +++ b/src/gui/src/MainWindow.h @@ -33,7 +33,6 @@ #include "VersionChecker.h" #include "IpcClient.h" #include "Ipc.h" -#include "ActivationDialog.h" #include @@ -58,7 +57,6 @@ class ZeroconfService; class DataDownloader; class CommandProcess; class SslCertificate; -class LicenseManager; class MainWindow : public QMainWindow, public Ui::MainWindowBase { @@ -66,7 +64,6 @@ class MainWindow : public QMainWindow, public Ui::MainWindowBase friend class QBarrierApplication; friend class SetupWizard; - friend class ActivationDialog; friend class SettingsDialog; public: @@ -95,8 +92,7 @@ class MainWindow : public QMainWindow, public Ui::MainWindowBase }; public: - MainWindow(QSettings& settings, AppConfig& appConfig, - LicenseManager& licenseManager); + MainWindow(QSettings& settings, AppConfig& appConfig); ~MainWindow(); public: @@ -118,14 +114,8 @@ class MainWindow : public QMainWindow, public Ui::MainWindowBase void updateZeroconfService(); void serverDetected(const QString name); void updateLocalFingerprint(); - LicenseManager& licenseManager() const; - - int raiseActivationDialog(); public slots: - void setEdition(Edition edition); - void beginTrial(bool isExpiring); - void endTrial(bool isExpired); void appendLogRaw(const QString& text); void appendLogInfo(const QString& text); void appendLogDebug(const QString& text); @@ -141,7 +131,6 @@ public slots: bool on_m_pActionSave_triggered(); void on_m_pActionAbout_triggered(); void on_m_pActionSettings_triggered(); - void on_m_pActivate_triggered(); void barrierFinished(int exitCode, QProcess::ExitStatus); void trayActivated(QSystemTrayIcon::ActivationReason reason); void stopBarrier(); @@ -185,7 +174,6 @@ public slots: void promptAutoConfig(); QString getProfileRootForArg(); void checkConnected(const QString& line); - void checkLicense(const QString& line); void checkFingerprint(const QString& line); bool autoHide(); QString getTimeStamp(); @@ -197,7 +185,6 @@ public slots: private: QSettings& m_Settings; AppConfig* m_AppConfig; - LicenseManager* m_LicenseManager; QProcess* m_pBarrier; int m_BarrierState; ServerConfig m_ServerConfig; @@ -223,7 +210,6 @@ public slots: qRuningState m_ExpectedRunningState; QMutex m_StopDesktopMutex; SslCertificate* m_pSslCertificate; - bool m_ActivationDialogRunning; QStringList m_PendingClientNames; private slots: diff --git a/src/gui/src/MainWindowBase.ui b/src/gui/src/MainWindowBase.ui index 36a93d24..16f85dfe 100644 --- a/src/gui/src/MainWindowBase.ui +++ b/src/gui/src/MainWindowBase.ui @@ -27,57 +27,6 @@ - - - - - 2 - - - 0 - - - 0 - - - 8 - - - - - - - - :/res/icons/16x16/warning.png - - - - - - - <html><head/><body><p><span style=" font-weight:600;">%1</span> days of your Barrier Pro trial remain. <a href="http://symless.com/pricing?src=gui"><span style=" text-decoration: underline; color:#0000ff;">Buy now!</span></a></p></body></html> - - - true - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - @@ -532,14 +481,6 @@ - - - Activate - - - Activate - - diff --git a/src/gui/src/SettingsDialog.cpp b/src/gui/src/SettingsDialog.cpp index 491959a9..38c31f75 100644 --- a/src/gui/src/SettingsDialog.cpp +++ b/src/gui/src/SettingsDialog.cpp @@ -63,7 +63,6 @@ SettingsDialog::SettingsDialog(QWidget* parent, AppConfig& config) : #endif m_pCheckBoxEnableCrypto->setChecked(m_appConfig.getCryptoEnabled()); - m_pCheckBoxEnableCrypto->setEnabled(m_appConfig.edition() == kPro); } void SettingsDialog::accept() diff --git a/src/gui/src/SettingsDialogBase.ui b/src/gui/src/SettingsDialogBase.ui index 634b7375..1b2ea388 100644 --- a/src/gui/src/SettingsDialogBase.ui +++ b/src/gui/src/SettingsDialogBase.ui @@ -176,9 +176,6 @@ - - false - Use &SSL encryption diff --git a/src/gui/src/SetupWizard.cpp b/src/gui/src/SetupWizard.cpp index 680aa716..313e48b6 100644 --- a/src/gui/src/SetupWizard.cpp +++ b/src/gui/src/SetupWizard.cpp @@ -18,8 +18,6 @@ #include "SetupWizard.h" #include "MainWindow.h" #include "WebClient.h" -#include "ActivationNotifier.h" -#include "LicenseManager.h" #include "QBarrierApplication.h" #include "QUtility.h" diff --git a/src/gui/src/main.cpp b/src/gui/src/main.cpp index 738892f6..23e5afbe 100644 --- a/src/gui/src/main.cpp +++ b/src/gui/src/main.cpp @@ -20,7 +20,6 @@ #define TRAY_RETRY_WAIT 2000 #include "QBarrierApplication.h" -#include "LicenseManager.h" #include "MainWindow.h" #include "AppConfig.h" #include "SetupWizard.h" @@ -91,12 +90,10 @@ int main(int argc, char* argv[]) QSettings settings; AppConfig appConfig (&settings); - qRegisterMetaType("Edition"); - LicenseManager licenseManager (&appConfig); app.switchTranslator(appConfig.language()); - MainWindow mainWindow(settings, appConfig, licenseManager); + MainWindow mainWindow(settings, appConfig); SetupWizard setupWizard(mainWindow, true); if (appConfig.wizardShouldRun()) diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index db6bf187..922e3237 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -25,7 +25,6 @@ add_subdirectory(net) add_subdirectory(platform) add_subdirectory(server) add_subdirectory(barrier) -add_subdirectory(shared) if (WIN32) add_subdirectory(synwinhk) diff --git a/src/lib/barrier/ArgParser.cpp b/src/lib/barrier/ArgParser.cpp index 9d5cb71e..88906542 100644 --- a/src/lib/barrier/ArgParser.cpp +++ b/src/lib/barrier/ArgParser.cpp @@ -61,9 +61,6 @@ ArgParser::parseServerArgs(ServerArgs& args, int argc, const char* const* argv) // save configuration file path args.m_configFile = argv[++i]; } - else if (isArg(i, argc, argv, "", "--serial-key", 1)) { - args.m_serial = SerialKey(argv[++i]); - } else { LOG((CLOG_PRINT "%s: unrecognized option `%s'" BYE, args.m_pname, argv[i], args.m_pname)); return false; diff --git a/src/lib/barrier/ServerArgs.cpp b/src/lib/barrier/ServerArgs.cpp index 91e50916..49832f2a 100644 --- a/src/lib/barrier/ServerArgs.cpp +++ b/src/lib/barrier/ServerArgs.cpp @@ -19,7 +19,6 @@ ServerArgs::ServerArgs() : m_configFile(), - m_serial(), m_config(NULL) { } diff --git a/src/lib/barrier/ServerArgs.h b/src/lib/barrier/ServerArgs.h index b0146468..9c6e5687 100644 --- a/src/lib/barrier/ServerArgs.h +++ b/src/lib/barrier/ServerArgs.h @@ -18,7 +18,6 @@ #pragma once #include "barrier/ArgsBase.h" -#include "shared/SerialKey.h" class NetworkAddress; class Config; @@ -29,6 +28,5 @@ public: public: String m_configFile; - SerialKey m_serial; Config* m_config; }; diff --git a/src/lib/barrier/ToolApp.cpp b/src/lib/barrier/ToolApp.cpp index f76786b7..ae85e6dc 100644 --- a/src/lib/barrier/ToolApp.cpp +++ b/src/lib/barrier/ToolApp.cpp @@ -151,7 +151,6 @@ ToolApp::notifyUpdate() ss << JSON_URL << "notify/update"; ss << "?from=" << parts[0]; ss << "&to=" << parts[1]; - ss << "&serial=" << parts[2]; std::cout << ARCH->internet().get(ss.str()) << std::endl; } diff --git a/src/lib/server/CMakeLists.txt b/src/lib/server/CMakeLists.txt index 94e1d68a..5242d6dc 100644 --- a/src/lib/server/CMakeLists.txt +++ b/src/lib/server/CMakeLists.txt @@ -23,7 +23,7 @@ endif() add_library(server STATIC ${sources}) -target_link_libraries(server shared) +target_link_libraries(server) if (UNIX) target_link_libraries(server synlib) diff --git a/src/lib/server/Server.cpp b/src/lib/server/Server.cpp index 80481551..cbc4e1c1 100644 --- a/src/lib/server/Server.cpp +++ b/src/lib/server/Server.cpp @@ -44,7 +44,6 @@ #include "base/Log.h" #include "base/TMethodEventJob.h" #include "common/stdexcept.h" -#include "shared/SerialKey.h" #include #include @@ -453,12 +452,6 @@ Server::switchScreen(BaseClientProxy* dst, { assert(dst != NULL); - // if trial is expired, exit the process - if (m_args.m_serial.isExpired(std::time(0))) { - LOG((CLOG_ERR "trial has expired, aborting server")); - exit(kExitSuccess); - } - #ifndef NDEBUG { SInt32 dx, dy, dw, dh; diff --git a/src/lib/shared/CMakeLists.txt b/src/lib/shared/CMakeLists.txt deleted file mode 100644 index 7439ae2c..00000000 --- a/src/lib/shared/CMakeLists.txt +++ /dev/null @@ -1,26 +0,0 @@ -# barrier -- mouse and keyboard sharing utility -# Copyright (C) 2016 Symless Ltd. -# -# This package is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# found in the file LICENSE that should have accompanied this file. -# -# This package is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -file(GLOB headers "*.h") -file(GLOB sources "*.cpp") - -if (BARRIER_ADD_HEADERS) - list(APPEND sources ${headers}) -endif() - -add_library(shared STATIC ${sources}) - -target_link_libraries(shared arch base) - diff --git a/src/lib/shared/EditionType.h b/src/lib/shared/EditionType.h deleted file mode 100644 index 57a94d59..00000000 --- a/src/lib/shared/EditionType.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * barrier -- mouse and keyboard sharing utility - * Copyright (C) 2015-2016 Symless Ltd. - * - * This package is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * found in the file LICENSE that should have accompanied this file. - * - * This package is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef EDITIONTYPE_H -#define EDITIONTYPE_H - -/* Do not reorder these! */ - -enum Edition { - kBasic, - kPro, - Trial_DO_NOT_USE_OR_THERE_WILL_BE_PAIN, - kUnregistered -}; - -#endif // EDITIONTYPE_H diff --git a/src/lib/shared/SerialKey.cpp b/src/lib/shared/SerialKey.cpp deleted file mode 100644 index 4b15b09d..00000000 --- a/src/lib/shared/SerialKey.cpp +++ /dev/null @@ -1,265 +0,0 @@ -/* - * barrier -- mouse and keyboard sharing utility - * Copyright (C) 2016 Symless Ltd. - * - * This package is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * found in the file LICENSE that should have accompanied this file. - * - * This package is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "SerialKey.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace std; - -SerialKey::SerialKey(Edition edition): - m_userLimit(1), - m_warnTime(ULLONG_MAX), - m_expireTime(ULLONG_MAX), - m_edition(edition), - m_trial(false) -{ -} - -SerialKey::SerialKey(std::string serial) : - m_userLimit(1), - m_warnTime(0), - m_expireTime(0), - m_edition(kBasic), - m_trial(true) -{ - string plainText = decode(serial); - bool valid = false; - if (!plainText.empty()) { - valid = parse(plainText); - } - if (!valid) { - throw std::runtime_error ("Invalid serial key"); - } -} - -bool -SerialKey::isExpiring(time_t currentTime) const -{ - bool result = false; - - if (m_trial) { - if (m_warnTime <= currentTime && currentTime < m_expireTime) { - result = true; - } - } - - return result; -} - -bool -SerialKey::isExpired(time_t currentTime) const -{ - bool result = false; - - if (m_trial) { - if (m_expireTime <= currentTime) { - result = true; - } - } - - return result; -} - -bool -SerialKey::isTrial() const -{ - return m_trial; -} - -Edition -SerialKey::edition() const -{ - return m_edition; -} - -std::string -SerialKey::editionString() const -{ - switch (edition()) { - case kBasic: - return "basic"; - case kPro: - return "pro"; - default: { - std::ostringstream oss; - oss << static_cast(edition()); - return oss.str(); - } - } -} - -static std::string -hexEncode (std::string const& str) { - std::ostringstream oss; - for (size_t i = 0; i < str.size(); ++i) { - unsigned c = str[i]; - c %= 256; - oss << std::setfill('0') << std::hex << std::setw(2) - << std::uppercase; - oss << c; - } - return oss.str(); -} - -std::string -SerialKey::toString() const -{ - std::ostringstream oss; - oss << "{"; - if (isTrial()) { - oss << "v2;trial;"; - } else { - oss << "v1;"; - } - oss << editionString() << ";"; - oss << m_name << ";"; - oss << m_userLimit << ";"; - oss << m_email << ";"; - oss << m_company << ";"; - oss << (isTrial() ? m_warnTime : 0) << ";"; - oss << (isTrial() ? m_expireTime : 0); - oss << "}"; - return hexEncode(oss.str()); -} - -time_t -SerialKey::daysLeft(time_t currentTime) const -{ - unsigned long long timeLeft = 0; - unsigned long long const day = 60 * 60 * 24; - - if (currentTime < m_expireTime) { - timeLeft = m_expireTime - currentTime; - } - - unsigned long long daysLeft = 0; - daysLeft = timeLeft % day != 0 ? 1 : 0; - - return timeLeft / day + daysLeft; -} - -std::string -SerialKey::email() const -{ - return m_email; -} - -std::string -SerialKey::decode(const std::string& serial) -{ - static const char* const lut = "0123456789ABCDEF"; - string output; - size_t len = serial.length(); - if (len & 1) { - return output; - } - - output.reserve(len / 2); - for (size_t i = 0; i < len; i += 2) { - - char a = serial[i]; - char b = serial[i + 1]; - - const char* p = std::lower_bound(lut, lut + 16, a); - const char* q = std::lower_bound(lut, lut + 16, b); - - if (*q != b || *p != a) { - return output; - } - - output.push_back(static_cast(((p - lut) << 4) | (q - lut))); - } - - return output; -} - -bool -SerialKey::parse(std::string plainSerial) -{ - string parityStart = plainSerial.substr(0, 1); - string parityEnd = plainSerial.substr(plainSerial.length() - 1, 1); - - bool valid = false; - - // check for parity chars { and }, record parity result, then remove them. - if (parityStart == "{" && parityEnd == "}") { - plainSerial = plainSerial.substr(1, plainSerial.length() - 2); - - // tokenize serialised subscription. - vector parts; - std::string::size_type pos = 0; - bool look = true; - while (look) { - std::string::size_type start = pos; - pos = plainSerial.find(";", pos); - if (pos == string::npos) { - pos = plainSerial.length(); - look = false; - } - parts.push_back(plainSerial.substr(start, pos - start)); - pos += 1; - } - - if ((parts.size() == 8) - && (parts.at(0).find("v1") != string::npos)) { - // e.g.: {v1;basic;Bob;1;email;company name;1398297600;1398384000} - m_edition = parseEdition(parts.at(1)); - m_name = parts.at(2); - m_trial = false; - sscanf(parts.at(3).c_str(), "%d", &m_userLimit); - m_email = parts.at(4); - m_company = parts.at(5); - sscanf(parts.at(6).c_str(), "%lld", &m_warnTime); - sscanf(parts.at(7).c_str(), "%lld", &m_expireTime); - valid = true; - } - else if ((parts.size() == 9) - && (parts.at(0).find("v2") != string::npos)) { - // e.g.: {v2;trial;basic;Bob;1;email;company name;1398297600;1398384000} - m_trial = parts.at(1) == "trial" ? true : false; - m_edition = parseEdition(parts.at(2)); - m_name = parts.at(3); - sscanf(parts.at(4).c_str(), "%d", &m_userLimit); - m_email = parts.at(5); - m_company = parts.at(6); - sscanf(parts.at(7).c_str(), "%lld", &m_warnTime); - sscanf(parts.at(8).c_str(), "%lld", &m_expireTime); - valid = true; - } - } - - return valid; -} - -Edition -SerialKey::parseEdition(std::string const& editionStr) -{ - Edition e = kBasic; - if (editionStr == "pro") { - e = kPro; - } - - return e; -} diff --git a/src/lib/shared/SerialKey.h b/src/lib/shared/SerialKey.h deleted file mode 100644 index ac01f4ea..00000000 --- a/src/lib/shared/SerialKey.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - * barrier -- mouse and keyboard sharing utility - * Copyright (C) 2016 Symless Ltd. - * - * This package is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * found in the file LICENSE that should have accompanied this file. - * - * This package is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once - -#include -#include -#include "EditionType.h" - -#ifdef TEST_ENV -#include -#endif - -class SerialKey { - friend bool operator== (SerialKey const&, SerialKey const&); -public: - explicit SerialKey(Edition edition = kUnregistered); - explicit SerialKey(std::string serial); - - bool isExpiring(time_t currentTime) const; - bool isExpired(time_t currentTime) const; - bool isTrial() const; - time_t daysLeft(time_t currentTime) const; - std::string email() const; - Edition edition() const; - std::string toString() const; - - static std::string decode(const std::string& serial); - static Edition parseEdition(const std::string& editionStr); - -private: - bool parse(std::string plainSerial); - std::string editionString() const; - -#ifdef TEST_ENV -private: - FRIEND_TEST(SerialKeyTests, parse_noParty_invalid); - FRIEND_TEST(SerialKeyTests, parse_invalidPartsLenghth_invalid); - FRIEND_TEST(SerialKeyTests, parse_validV1Serial_valid); - FRIEND_TEST(SerialKeyTests, parse_validV2Serial_valid); -#endif - -private: - std::string m_name; - std::string m_email; - std::string m_company; - unsigned m_userLimit; - unsigned long long m_warnTime; - unsigned long long m_expireTime; - Edition m_edition; - bool m_trial; -}; - - -inline bool -operator== (SerialKey const& lhs, SerialKey const& rhs) { - return (lhs.m_name == rhs.m_name) && - (lhs.m_email == rhs.m_email) && - (lhs.m_company == rhs.m_company) && - (lhs.m_userLimit == rhs.m_userLimit) && - (lhs.m_warnTime == rhs.m_warnTime) && - (lhs.m_expireTime == rhs.m_expireTime) && - (lhs.m_edition == rhs.m_edition) && - (lhs.m_trial == rhs.m_trial); -} - -inline bool -operator!= (SerialKey const& lhs, SerialKey const& rhs) { - return !(lhs == rhs); -} diff --git a/src/test/unittests/CMakeLists.txt b/src/test/unittests/CMakeLists.txt index 91c31555..3d21a2b8 100644 --- a/src/test/unittests/CMakeLists.txt +++ b/src/test/unittests/CMakeLists.txt @@ -68,4 +68,4 @@ endif() add_executable(unittests ${sources}) target_link_libraries(unittests - arch base client server common io net platform server barrier mt ipc gtest gmock shared ${libs} ${OPENSSL_LIBS}) + arch base client server common io net platform server barrier mt ipc gtest gmock ${libs} ${OPENSSL_LIBS}) diff --git a/src/test/unittests/shared/SerialKeyTests.cpp b/src/test/unittests/shared/SerialKeyTests.cpp deleted file mode 100644 index c4af0cec..00000000 --- a/src/test/unittests/shared/SerialKeyTests.cpp +++ /dev/null @@ -1,147 +0,0 @@ -/* - * barrier -- mouse and keyboard sharing utility - * Copyright (C) 2016 Symless Inc. - * - * This package is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * found in the file LICENSE that should have accompanied this file. - * - * This package is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#define TEST_ENV - -#include "shared/SerialKey.h" - -#include "test/global/gtest.h" - -TEST(SerialKeyTests, decode_empty_returnEmptyString) -{ - std::string plainText = SerialKey::decode(""); - EXPECT_EQ(0, plainText.size()); -} - -TEST(SerialKeyTests, decode_invalidDigit_returnEmptyString) -{ - std::string plainText = SerialKey::decode("MOCKZ"); - EXPECT_EQ(0, plainText.size()); -} - -TEST(SerialKeyTests, decode_validSerial_returnPlainText) -{ - std::string plainText = SerialKey::decode("53796E6572677920726F636B7321"); - EXPECT_EQ("Barrier rocks!", plainText); -} - -TEST(SerialKeyTests, parse_noParty_invalid) -{ - SerialKey serial; - bool r = serial.parse("MOCK"); - EXPECT_FALSE(r); -} - -TEST(SerialKeyTests, parse_invalidPartsLenghth_invalid) -{ - SerialKey serial; - bool r = serial.parse("{Barrier;Rocks}"); - EXPECT_FALSE(r); -} - -TEST(SerialKeyTests, parse_validV1Serial_valid) -{ - SerialKey serial; - bool r = serial.parse("{v1;basic;Bob;1;email;company name;0;86400}"); - EXPECT_EQ(true, r); - EXPECT_EQ(kBasic, serial.edition()); - EXPECT_FALSE(serial.isExpired(0)); - EXPECT_EQ(true, serial.daysLeft(0)); - EXPECT_FALSE(serial.isExpiring(1)); -} - -TEST(SerialKeyTests, parse_validV2Serial_valid) -{ - SerialKey serial; - bool r = serial.parse("{v2;trial;pro;Bob;1;email;company name;0;86400}"); - EXPECT_EQ(true, r); - EXPECT_EQ(kPro, serial.edition()); - EXPECT_FALSE(serial.isExpired(0)); - EXPECT_EQ(true, serial.daysLeft(0)); - EXPECT_EQ(true, serial.isExpiring(1)); - EXPECT_EQ(true, serial.isTrial()); -} - -TEST(SerialKeyTests, isExpiring_validV2TrialBasicSerial_returnFalse) -{ - // {v2;trial;basic;Bob;1;email;company name;1;86400} - SerialKey serial("7B76323B747269616C3B62617369633B426F623B313B656D61696C3B636F6D70616E79206E616D653B313B38363430307D"); - EXPECT_EQ(true, serial.isTrial()); - EXPECT_FALSE(serial.isExpiring(0)); - EXPECT_EQ(kBasic, serial.edition()); -} - -TEST(SerialKeyTests, isExpiring_expiringV2TrialBasicSerial_returnTrue) -{ - // {v2;trial;basic;Bob;1;email;company name;0;86400} - SerialKey serial("7B76323B747269616C3B62617369633B426F623B313B656D61696C3B636F6D70616E79206E616D653B303B38363430307D"); - EXPECT_EQ(true, serial.isTrial()); - EXPECT_EQ(true, serial.isExpiring(1)); -} - -TEST(SerialKeyTests, isExpiring_expiredV2TrialBasicSerial_returnFalse) -{ - // {v2;trial;basic;Bob;1;email;company name;0;86400} - SerialKey serial("7B76323B747269616C3B62617369633B426F623B313B656D61696C3B636F6D70616E79206E616D653B303B38363430307D"); - EXPECT_EQ(true, serial.isTrial()); - EXPECT_FALSE(serial.isExpiring(86401)); -} - -TEST(SerialKeyTests, isExpired_validV2TrialBasicSerial_returnFalse) -{ - // {v2;trial;basic;Bob;1;email;company name;0;86400} - SerialKey serial("7B76323B747269616C3B62617369633B426F623B313B656D61696C3B636F6D70616E79206E616D653B303B38363430307D"); - EXPECT_EQ(true, serial.isTrial()); - EXPECT_FALSE(serial.isExpired(0)); -} - -TEST(SerialKeyTests, isExpired_expiringV2TrialBasicSerial_returnFalse) -{ - // {v2;trial;basic;Bob;1;email;company name;0;86400} - SerialKey serial("7B76323B747269616C3B62617369633B426F623B313B656D61696C3B636F6D70616E79206E616D653B303B38363430307D"); - EXPECT_EQ(true, serial.isTrial()); - EXPECT_FALSE(serial.isExpired(1)); -} - -TEST(SerialKeyTests, isExpired_expiredV2TrialBasicSerial_returnTrue) -{ - // {v2;trial;basic;Bob;1;email;company name;0;86400} - SerialKey serial("7B76323B747269616C3B62617369633B426F623B313B656D61696C3B636F6D70616E79206E616D653B303B38363430307D"); - EXPECT_EQ(true, serial.isTrial()); - EXPECT_EQ(true, serial.isExpired(86401)); -} - -TEST(SerialKeyTests, daysLeft_validExactlyOneDayV2TrialBasicSerial_returnOne) -{ - // {v2;trial;basic;Bob;1;email;company name;0;86400} - SerialKey serial("7B76323B747269616C3B62617369633B426F623B313B656D61696C3B636F6D70616E79206E616D653B303B38363430307D"); - EXPECT_EQ(1, serial.daysLeft(0)); -} - -TEST(SerialKeyTests, daysLeft_validWithinOneDayV2TrialBasicSerial_returnOne) -{ - // {v2;trial;basic;Bob;1;email;company name;0;86400} - SerialKey serial("7B76323B747269616C3B62617369633B426F623B313B656D61696C3B636F6D70616E79206E616D653B303B38363430307D"); - EXPECT_EQ(1, serial.daysLeft(1)); -} - -TEST(SerialKeyTests, daysLeft_expiredV2TrialBasicSerial_returnZero) -{ - // {v2;trial;basic;Bob;1;email;company name;0;86400} - SerialKey serial("7B76323B747269616C3B62617369633B426F623B313B656D61696C3B636F6D70616E79206E616D653B303B38363430307D"); - EXPECT_EQ(0, serial.daysLeft(86401)); -}