remove activation, serial, trial garbage. shame on you all!

This commit is contained in:
walker0643 2018-01-27 20:21:44 -05:00
parent 2169eb679b
commit 99b16334b5
37 changed files with 19 additions and 1819 deletions

View File

@ -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})

View File

@ -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)

View File

@ -1,123 +0,0 @@
#include "ActivationDialog.h"
#include "ui_ActivationDialog.h"
#include "CancelActivationDialog.h"
#include "AppConfig.h"
#include "WebClient.h"
#include <shared/EditionType.h>
#include "ActivationNotifier.h"
#include "MainWindow.h"
#include "QUtility.h"
#include "LicenseManager.h"
#include "FailedLoginDialog.h"
#include <QMessageBox>
#include <QThread>
#include <iostream>
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("<html><head/><body><p>Your trial has "
"expired. <a href=\"https://symless.com/"
"barrier/trial/thanks?id=%1\"><span "
"style=\"text-decoration: underline; "
"color:#0000ff;\">Buy now!</span></a>"
"</p></body></html>")
.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<bool, QString> 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();
}

View File

@ -1,35 +0,0 @@
#ifndef ACTIVATIONDIALOG_H
#define ACTIVATIONDIALOG_H
#include <QDialog>
#include <LicenseManager.h>
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

View File

@ -1,163 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ActivationDialog</class>
<widget class="QDialog" name="ActivationDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>410</width>
<height>211</height>
</rect>
</property>
<property name="windowTitle">
<string>Activate Barrier</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Serial key</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;This can be found on your &lt;a href=&quot;https://symless.com/account/?source=gui&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;account&lt;/span&gt;&lt;/a&gt; page.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QTextEdit" name="m_pTextEditSerialKey">
<property name="enabled">
<bool>true</bool>
</property>
<property name="tabChangesFocus">
<bool>true</bool>
</property>
<property name="html">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="acceptRichText">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="m_trialWidget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_5">
<property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>8</number>
</property>
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="Barrier.qrc">:/res/icons/16x16/money.png</pixmap>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="m_trialLabel">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Your trial has expired. &lt;a href=&quot;http://symless.com/pricing?src=gui&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;Buy now!&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>m_pTextEditSerialKey</tabstop>
</tabstops>
<resources>
<include location="Barrier.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>ActivationDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>ActivationDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#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 (...) {
}
}

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#ifndef ACTIVATIONNOTIFIER_H
#define ACTIVATIONNOTIFIER_H
#include <QObject>
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

View File

@ -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>(elevateMode.toInt());
m_AutoConfigPrompted = settings().value("autoConfigPrompted", false).toBool();
m_Edition = static_cast<Edition>(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<int>(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; }

View File

@ -23,7 +23,6 @@
#include <QObject>
#include <QString>
#include "ElevateMode.h"
#include <shared/EditionType.h>
// 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[];

View File

@ -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;
}

View File

@ -1,22 +0,0 @@
#ifndef CANCELACTIVATIONDIALOG_H
#define CANCELACTIVATIONDIALOG_H
#include <QDialog>
namespace Ui {
class CancelActivationDialog;
}
class CancelActivationDialog : public QDialog
{
Q_OBJECT
public:
explicit CancelActivationDialog(QWidget *parent = 0);
~CancelActivationDialog();
private:
Ui::CancelActivationDialog *ui;
};
#endif // CANCELACTIVATIONDIALOG_H

View File

@ -1,89 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CancelActivationDialog</class>
<widget class="QDialog" name="CancelActivationDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>165</height>
</rect>
</property>
<property name="windowTitle">
<string>Cancel Activation</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Are you sure?
If you don't activate Barrier you'll be missing out on some great features.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;a href=&quot;https://symless.com/pricing?source=gui&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;Buy now&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::No|QDialogButtonBox::Yes</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>CancelActivationDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>CancelActivationDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -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;
}

View File

@ -1,23 +0,0 @@
#ifndef FAILEDLOGINDIALOG_H
#define FAILEDLOGINDIALOG_H
#include <QDialog>
#include <QString>
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

View File

@ -1,108 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>FailedLoginDialog</class>
<widget class="QDialog" name="FailedLoginDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>165</height>
</rect>
</property>
<property name="windowTitle">
<string>Activation Error</string>
</property>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="geometry">
<rect>
<x>50</x>
<y>120</y>
<width>341</width>
<height>32</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Close</set>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>10</x>
<y>90</y>
<width>382</width>
<height>30</height>
</rect>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;a href=&quot;https://symless.com/account/reset/?source=gui&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;Forgotten your password?&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
<widget class="QLabel" name="messageLabel">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>382</width>
<height>72</height>
</rect>
</property>
<property name="text">
<string>An error occurred while trying to activate Barrier. The Symless server returned the following error:
%1</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
<zorder>label_2</zorder>
<zorder>messageLabel</zorder>
<zorder>buttonBox</zorder>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>FailedLoginDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>FailedLoginDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#include "LicenseManager.h"
#include "AppConfig.h"
#include <ctime>
#include <stdexcept>
#include <utility>
#include <QThread>
LicenseManager::LicenseManager(AppConfig* appConfig) :
m_AppConfig(appConfig),
m_serialKey(appConfig->edition()) {
}
std::pair<bool, QString>
LicenseManager::setSerialKey(SerialKey serialKey, bool acceptExpired)
{
std::pair<bool, QString> 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);
}

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <QObject>
#include <shared/EditionType.h>
#include <shared/SerialKey.h>
#include <ActivationNotifier.h>
#include <utility>
class AppConfig;
class LicenseManager: public QObject
{
Q_OBJECT
public:
LicenseManager(AppConfig* appConfig);
std::pair<bool, QString> 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;
};

View File

@ -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 <shared/EditionType.h>
#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 ("<html><head/><body><p><span style=\""
"font-weight:600;\">%1</span> day%3 of "
"your %2 trial remain%5. <a href="
"\"https://symless.com/barrier/trial/thanks?id=%4\">"
"<span style=\"text-decoration: underline;"
" color:#0000ff;\">Buy now!</span></a>"
"</p></body></html>");
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 (
"<html><head/><body><p>Your %1 trial has expired. <a href="
"\"https://symless.com/barrier/trial/thanks?id=%2\">"
"<span style=\"text-decoration: underline;color:#0000ff;\">"
"Buy now!</span></a></p></body></html>"
);
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()

View File

@ -33,7 +33,6 @@
#include "VersionChecker.h"
#include "IpcClient.h"
#include "Ipc.h"
#include "ActivationDialog.h"
#include <QMutex>
@ -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:

View File

@ -27,57 +27,6 @@
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QWidget" name="m_trialWidget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_5">
<property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>8</number>
</property>
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="Barrier.qrc">:/res/icons/16x16/warning.png</pixmap>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="m_trialLabel">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;%1&lt;/span&gt; days of your Barrier Pro trial remain. &lt;a href=&quot;http://symless.com/pricing?src=gui&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;Buy now!&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="m_pWidgetUpdate" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_2">
@ -532,14 +481,6 @@
<string notr="true"/>
</property>
</action>
<action name="m_pActivate">
<property name="text">
<string>Activate</string>
</property>
<property name="toolTip">
<string>Activate</string>
</property>
</action>
</widget>
<resources>
<include location="Barrier.qrc"/>

View File

@ -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()

View File

@ -176,9 +176,6 @@
</property>
<item row="0" column="0">
<widget class="QCheckBox" name="m_pCheckBoxEnableCrypto">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Use &amp;SSL encryption</string>
</property>

View File

@ -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"

View File

@ -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>("Edition");
LicenseManager licenseManager (&appConfig);
app.switchTranslator(appConfig.language());
MainWindow mainWindow(settings, appConfig, licenseManager);
MainWindow mainWindow(settings, appConfig);
SetupWizard setupWizard(mainWindow, true);
if (appConfig.wizardShouldRun())

View File

@ -25,7 +25,6 @@ add_subdirectory(net)
add_subdirectory(platform)
add_subdirectory(server)
add_subdirectory(barrier)
add_subdirectory(shared)
if (WIN32)
add_subdirectory(synwinhk)

View File

@ -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;

View File

@ -19,7 +19,6 @@
ServerArgs::ServerArgs() :
m_configFile(),
m_serial(),
m_config(NULL)
{
}

View File

@ -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;
};

View File

@ -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;
}

View File

@ -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)

View File

@ -44,7 +44,6 @@
#include "base/Log.h"
#include "base/TMethodEventJob.h"
#include "common/stdexcept.h"
#include "shared/SerialKey.h"
#include <cstring>
#include <cstdlib>
@ -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;

View File

@ -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 <http://www.gnu.org/licenses/>.
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)

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#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

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#include "SerialKey.h"
#include <fstream>
#include <iostream>
#include <algorithm>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <stdexcept>
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<int>(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<char>(((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<string> 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;
}

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <string>
#include <ctime>
#include "EditionType.h"
#ifdef TEST_ENV
#include <gtest/gtest_prod.h>
#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);
}

View File

@ -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})

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#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));
}