| @@ -0,0 +1,163 @@ | ||
| +<?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 Synergy</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><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></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><!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></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="Synergy.qrc">:/res/icons/16x16/money.png</pixmap> | ||
| + </property> | ||
| + </widget> | ||
| + </item> | ||
| + <item> | ||
| + <widget class="QLabel" name="m_trialLabel"> | ||
| + <property name="text"> | ||
| + <string><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></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="Synergy.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> |
| @@ -0,0 +1,89 @@ | ||
| +<?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 Synergy 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><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></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> |
| @@ -0,0 +1,108 @@ | ||
| +<?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><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></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 Synergy. 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> |
| @@ -1,137 +0,0 @@ | ||
| -<?xml version="1.0" encoding="UTF-8"?> | ||
| -<ui version="4.0"> | ||
| - <class>PluginWizardPage</class> | ||
| - <widget class="QWizardPage" name="PluginWizardPage"> | ||
| - <property name="geometry"> | ||
| - <rect> | ||
| - <x>0</x> | ||
| - <y>0</y> | ||
| - <width>400</width> | ||
| - <height>300</height> | ||
| - </rect> | ||
| - </property> | ||
| - <property name="windowTitle"> | ||
| - <string>Setup Synergy</string> | ||
| - </property> | ||
| - <property name="title"> | ||
| - <string/> | ||
| - </property> | ||
| - <layout class="QVBoxLayout" name="verticalLayout"> | ||
| - <item> | ||
| - <spacer name="verticalSpacer"> | ||
| - <property name="orientation"> | ||
| - <enum>Qt::Vertical</enum> | ||
| - </property> | ||
| - <property name="sizeHint" stdset="0"> | ||
| - <size> | ||
| - <width>20</width> | ||
| - <height>40</height> | ||
| - </size> | ||
| - </property> | ||
| - </spacer> | ||
| - </item> | ||
| - <item> | ||
| - <layout class="QGridLayout" name="gridLayout"> | ||
| - <item row="0" column="0"> | ||
| - <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> | ||
| - <item row="0" column="1"> | ||
| - <widget class="QLabel" name="m_pLabelSpinning"> | ||
| - <property name="text"> | ||
| - <string> </string> | ||
| - </property> | ||
| - </widget> | ||
| - </item> | ||
| - <item row="0" column="2"> | ||
| - <spacer name="horizontalSpacer_2"> | ||
| - <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> | ||
| - </item> | ||
| - <item> | ||
| - <spacer name="verticalSpacer_3"> | ||
| - <property name="orientation"> | ||
| - <enum>Qt::Vertical</enum> | ||
| - </property> | ||
| - <property name="sizeHint" stdset="0"> | ||
| - <size> | ||
| - <width>20</width> | ||
| - <height>40</height> | ||
| - </size> | ||
| - </property> | ||
| - </spacer> | ||
| - </item> | ||
| - <item> | ||
| - <layout class="QGridLayout" name="gridLayout_2"> | ||
| - <item row="0" column="0"> | ||
| - <spacer name="horizontalSpacer_3"> | ||
| - <property name="orientation"> | ||
| - <enum>Qt::Horizontal</enum> | ||
| - </property> | ||
| - <property name="sizeHint" stdset="0"> | ||
| - <size> | ||
| - <width>40</width> | ||
| - <height>20</height> | ||
| - </size> | ||
| - </property> | ||
| - </spacer> | ||
| - </item> | ||
| - <item row="0" column="1"> | ||
| - <widget class="QLabel" name="m_pLabelStatus"> | ||
| - <property name="text"> | ||
| - <string>Please wait...</string> | ||
| - </property> | ||
| - </widget> | ||
| - </item> | ||
| - <item row="0" column="2"> | ||
| - <spacer name="horizontalSpacer_4"> | ||
| - <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> | ||
| - </item> | ||
| - <item> | ||
| - <spacer name="verticalSpacer_2"> | ||
| - <property name="orientation"> | ||
| - <enum>Qt::Vertical</enum> | ||
| - </property> | ||
| - <property name="sizeHint" stdset="0"> | ||
| - <size> | ||
| - <width>20</width> | ||
| - <height>40</height> | ||
| - </size> | ||
| - </property> | ||
| - </spacer> | ||
| - </item> | ||
| - </layout> | ||
| - </widget> | ||
| - <resources/> | ||
| - <connections/> | ||
| -</ui> |
| @@ -1,20 +1,28 @@ | ||
| -<?xml version="1.0" encoding="UTF-8"?> | ||
| -<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
| +<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
| <plist version="1.0"> | ||
| -<dict> | ||
| - <key>CFBundleInfoDictionaryVersion</key> | ||
| - <string>6.0</string> | ||
| - <key>NSPrincipalClass</key> | ||
| - <string>NSApplication</string> | ||
| - <key>CFBundleIconFile</key> | ||
| - <string>Synergy.icns</string> | ||
| - <key>CFBundlePackageType</key> | ||
| - <string>APPL</string> | ||
| - <key>CFBundleSignature</key> | ||
| - <string>????</string> | ||
| - <key>CFBundleExecutable</key> | ||
| - <string>Synergy</string> | ||
| - <key>CFBundleIdentifier</key> | ||
| - <string>synergy</string> | ||
| -</dict> | ||
| + <dict> | ||
| + <key>CFBundleDevelopmentRegion</key> | ||
| + <string>English</string> | ||
| + <key>CFBundleDisplayName</key> | ||
| + <string>Synergy</string> | ||
| + <key>CFBundleExecutable</key> | ||
| + <string>Synergy</string> | ||
| + <key>CFBundleIconFile</key> | ||
| + <string>Synergy.icns</string> | ||
| + <key>CFBundleIdentifier</key> | ||
| + <string>synergy</string> | ||
| + <!-- TODO: Fix this in v2.0 //--> | ||
| + <key>CFBundleInfoDictionaryVersion</key> | ||
| + <string>6.0</string> | ||
| + <key>CFBundleName</key> | ||
| + <string>Synergy</string> | ||
| + <key>CFBundlePackageType</key> | ||
| + <string>APPL</string> | ||
| + <key>CFBundleShortVersionString</key> | ||
| + <string>1.8.8</string> | ||
| + <key>CFBundleVersion</key> | ||
| + <string>1.8.8</string> | ||
| + <key>NSHumanReadableCopyright</key> | ||
| + <string>© 2012-2016, Symless Ltd</string> | ||
| + </dict> | ||
| </plist> |
| @@ -0,0 +1,123 @@ | ||
| +#include "ActivationDialog.h" | ||
| +#include "ui_ActivationDialog.h" | ||
| +#include "CancelActivationDialog.h" | ||
| +#include "AppConfig.h" | ||
| +#include "WebClient.h" | ||
| +#include "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/" | ||
| + "synergy/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 Synergy. " | ||
| + "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(); | ||
| +} |
| @@ -0,0 +1,35 @@ | ||
| +#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 |
| @@ -0,0 +1,14 @@ | ||
| +#include "CancelActivationDialog.h" | ||
| +#include "ui_CancelActivationDialog.h" | ||
| + | ||
| +CancelActivationDialog::CancelActivationDialog(QWidget *parent) : | ||
| + QDialog(parent), | ||
| + ui(new Ui::CancelActivationDialog) | ||
| +{ | ||
| + ui->setupUi(this); | ||
| +} | ||
| + | ||
| +CancelActivationDialog::~CancelActivationDialog() | ||
| +{ | ||
| + delete ui; | ||
| +} |
| @@ -0,0 +1,22 @@ | ||
| +#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 |
| @@ -0,0 +1,15 @@ | ||
| +#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; | ||
| +} |
| @@ -0,0 +1,23 @@ | ||
| +#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 |
| @@ -0,0 +1,169 @@ | ||
| +/* | ||
| + * synergy -- mouse and keyboard sharing utility | ||
| + * Copyright (C) 2015 Synergy 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 "EditionType.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 ("Synergy"); | ||
| + 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); | ||
| +} |
| @@ -0,0 +1,53 @@ | ||
| +/* | ||
| + * synergy -- mouse and keyboard sharing utility | ||
| + * Copyright (C) 2015 Synergy 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 <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; | ||
| +}; |
| @@ -1,73 +0,0 @@ | ||
| -/* | ||
| - * synergy -- 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/>. | ||
| - */ | ||
| - | ||
| -#include "Plugin.h" | ||
| - | ||
| -#include "CoreInterface.h" | ||
| - | ||
| -static const char kBaseUrl[] = "http://symless.com/files"; | ||
| -static const char kDefaultVersion[] = "1.1"; | ||
| -static const char kWinPackagePlatform32[] = "Windows-x86"; | ||
| -static const char kWinPackagePlatform64[] = "Windows-x64"; | ||
| -static const char kMacPackagePlatform[] = "MacOSX%1-i386"; | ||
| -static const char kLinuxPackagePlatformDeb32[] = "Linux-i686-deb"; | ||
| -static const char kLinuxPackagePlatformDeb64[] = "Linux-x86_64-deb"; | ||
| -static const char kLinuxPackagePlatformRpm32[] = "Linux-i686-rpm"; | ||
| -static const char kLinuxPackagePlatformRpm64[] = "Linux-x86_64-rpm"; | ||
| - | ||
| -#if defined(Q_OS_WIN) | ||
| -static const char kWinPluginExt[] = ".dll"; | ||
| -static const char kInstallerPluginLocation[] = "Plugins"; | ||
| -#elif defined(Q_OS_MAC) | ||
| -static const char kMacPluginPrefix[] = "lib"; | ||
| -static const char kMacPluginExt[] = ".dylib"; | ||
| -static const char kInstallerPluginLocation[] = "plugins"; // TODO: Fix for mac | ||
| -#else | ||
| -static const char kLinuxPluginPrefix[] = "lib"; | ||
| -static const char kLinuxPluginExt[] = ".so"; | ||
| -// /usr/bin becomes /usr/bin/../lib/syn... | ||
| -static const char kInstallerPluginLocation[] = "../lib/synergy/plugins"; | ||
| -#endif | ||
| - | ||
| -QString Plugin::getOsSpecificExt() | ||
| -{ | ||
| - | ||
| -#if defined(Q_OS_WIN) | ||
| - return kWinPluginExt; | ||
| -#elif defined(Q_OS_MAC) | ||
| - return kMacPluginExt; | ||
| -#else | ||
| - return kLinuxPluginExt; | ||
| -#endif | ||
| -} | ||
| - | ||
| -QString Plugin::getOsSpecificName(const QString& pluginName) | ||
| -{ | ||
| - QString result = pluginName; | ||
| -#if defined(Q_OS_WIN) | ||
| - result.append(getOsSpecificExt()); | ||
| -#elif defined(Q_OS_MAC) | ||
| - result = kMacPluginPrefix + pluginName + getOsSpecificExt(); | ||
| -#else | ||
| - result = kLinuxPluginPrefix + pluginName + getOsSpecificExt(); | ||
| -#endif | ||
| - return result; | ||
| -} | ||
| - | ||
| -QString Plugin::getOsSpecificInstallerLocation() { | ||
| - return kInstallerPluginLocation; | ||
| -} |
| @@ -1,53 +0,0 @@ | ||
| -/* | ||
| - * synergy -- 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 PLUGIN_H | ||
| -#define PLUGIN_H | ||
| - | ||
| -#include <QString> | ||
| -#include <QStringList> | ||
| -#include <QObject> | ||
| - | ||
| -#include "SslCertificate.h" | ||
| -#include "CoreInterface.h" | ||
| -#include "DataDownloader.h" | ||
| - | ||
| -class Plugin : public QObject | ||
| -{ | ||
| - Q_OBJECT | ||
| - | ||
| -public: | ||
| - //Plugin(); | ||
| - //~PluginManager(); | ||
| - | ||
| - static QString getOsSpecificName(const QString& pluginName); | ||
| - static QString getOsSpecificExt(); | ||
| - static QString getOsSpecificLocation(); | ||
| - static QString getOsSpecificInstallerLocation(); | ||
| - static QString getOsSpecificUserLocation(); | ||
| - | ||
| -public slots: | ||
| - | ||
| -private: | ||
| -// CoreInterface m_CoreInterface; | ||
| - | ||
| -signals: | ||
| - | ||
| -private: | ||
| - | ||
| -}; | ||
| - | ||
| -#endif // PLUGIN_H |
| @@ -1,186 +0,0 @@ | ||
| -/* | ||
| - * synergy -- 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/>. | ||
| - */ | ||
| - | ||
| -#include "PluginManager.h" | ||
| - | ||
| -#include "CoreInterface.h" | ||
| -#include "DataDownloader.h" | ||
| -#include "QUtility.h" | ||
| -#include "ProcessorArch.h" | ||
| -#include "Fingerprint.h" | ||
| -#include "Plugin.h" | ||
| -#include "../lib/common/PluginVersion.h" | ||
| - | ||
| -#include <QTextStream> | ||
| - | ||
| -#include <QFile> | ||
| -#include <QDir> | ||
| -#include <QProcess> | ||
| -#include <QCoreApplication> | ||
| - | ||
| - | ||
| -PluginManager::PluginManager() : | ||
| - m_PluginList() | ||
| -{ | ||
| - init(); | ||
| -} | ||
| - | ||
| -PluginManager::~PluginManager() | ||
| -{ | ||
| -} | ||
| - | ||
| -void PluginManager::init() | ||
| -{ | ||
| - m_PluginDir = m_CoreInterface.getPluginDir(); | ||
| - if (m_PluginDir.isEmpty()) { | ||
| - emit error(tr("Failed to get plugin directory.")); | ||
| - } | ||
| - | ||
| - m_ProfileDir = m_CoreInterface.getProfileDir(); | ||
| - if (m_ProfileDir.isEmpty()) { | ||
| - emit error(tr("Failed to get profile directory.")); | ||
| - } | ||
| - | ||
| - m_InstalledDir = m_CoreInterface.getInstalledDir(); | ||
| - if (m_InstalledDir.isEmpty()) { | ||
| - emit error(tr("Failed to get installed directory.")); | ||
| - } | ||
| -} | ||
| - | ||
| -bool PluginManager::exist(QString name) | ||
| -{ | ||
| - CoreInterface coreInterface; | ||
| - QString PluginDir = coreInterface.getPluginDir(); | ||
| - QString pluginName = Plugin::getOsSpecificName(name); | ||
| - QString filename; | ||
| - filename.append(PluginDir); | ||
| - filename.append(QDir::separator()).append(pluginName); | ||
| - QFile file(filename); | ||
| - bool exist = false; | ||
| - if (file.exists()) { | ||
| - exist = true; | ||
| - } | ||
| - | ||
| - return exist; | ||
| -} | ||
| - | ||
| -void PluginManager::copyPlugins() | ||
| -{ | ||
| - try { | ||
| - // Get the Directory where plugins are put on installation | ||
| - // If it doesn't exist, there is nothing to do | ||
| - QString srcDirName(m_InstalledDir.append(QDir::separator()) | ||
| - .append(Plugin::getOsSpecificInstallerLocation())); | ||
| - | ||
| - QDir srcDir(srcDirName); | ||
| - if (!srcDir.exists()) { | ||
| - emit info( | ||
| - tr("No plugins found to copy from %1") | ||
| - .arg(srcDirName)); | ||
| - emit copyFinished(); | ||
| - } | ||
| - | ||
| - // Get the directory where Plugins are installed into Synergy | ||
| - // If it doesn't exist make it | ||
| - QString destDirName = m_PluginDir; | ||
| - | ||
| - QDir destDir(destDirName); | ||
| - if (!destDir.exists()) { | ||
| - destDir.mkpath("."); | ||
| - } | ||
| - // Run through the list of plugins and copy them | ||
| - for ( int i = 0 ; i < m_PluginList.size() ; i++ ) { | ||
| - // Get a file entry for the plugin using the full path | ||
| - QFile file(srcDirName + QDir::separator() + m_PluginList.at(i)); | ||
| - | ||
| - // construct the destination file name | ||
| - QString newName(destDirName + QDir::separator() + m_PluginList.at(i)); | ||
| - | ||
| - // Check to see if the plugin already exists | ||
| - QFile newFile(newName); | ||
| - if(newFile.exists()) { | ||
| - // If it does, delete it. TODO: Check to see if same and leave | ||
| - bool result = newFile.remove(); | ||
| - if( !result ) { | ||
| - emit error( | ||
| - tr( "Unable to delete plugin:\n%1\n" | ||
| - "Please stop synergy and run the wizard again.") | ||
| - .arg(newName)); | ||
| - return; | ||
| - } | ||
| - } | ||
| - // make a copy of the plugin in the new location | ||
| - #if defined(Q_OS_WIN) | ||
| - bool result = file.copy(newName); | ||
| - #else | ||
| - bool result = file.link(newName); | ||
| - #endif | ||
| - if ( !result ) { | ||
| - emit error( | ||
| - tr("Failed to copy plugin '%1' to: %2\n%3\n" | ||
| - "Please stop synergy and run the wizard again.") | ||
| - .arg(m_PluginList.at(i)) | ||
| - .arg(newName) | ||
| - .arg(file.errorString())); | ||
| - return; | ||
| - } | ||
| - else { | ||
| - emit info( | ||
| - tr("Copying '%1' plugin (%2/%3)...") | ||
| - .arg(m_PluginList.at(i)) | ||
| - .arg(i+1) | ||
| - .arg(m_PluginList.size())); | ||
| - } | ||
| - } | ||
| - } | ||
| - catch (std::exception& e) | ||
| - { | ||
| - emit error(tr( "An error occurred while trying to copy the " | ||
| - "plugin list. Please contact the help desk, and " | ||
| - "provide the following details.\n\n%1").arg(e.what())); | ||
| - } | ||
| - | ||
| - emit copyFinished(); | ||
| - return; | ||
| -} | ||
| - | ||
| -void PluginManager::queryPluginList() | ||
| -{ | ||
| - try { | ||
| - setDone(false); | ||
| - QString extension = "*" + Plugin::getOsSpecificExt(); | ||
| - QStringList nameFilter(extension); | ||
| - | ||
| - QString installDir(m_CoreInterface.getInstalledDir() | ||
| - .append(QDir::separator()) | ||
| - .append(Plugin::getOsSpecificInstallerLocation())); | ||
| - | ||
| - QString searchDirectory(installDir); | ||
| - QDir directory(searchDirectory); | ||
| - m_PluginList = directory.entryList(nameFilter); | ||
| - setDone(true); | ||
| - } | ||
| - catch (std::exception& e) | ||
| - { | ||
| - setDone(true); | ||
| - emit error(tr( "An error occurred while trying to load the " | ||
| - "plugin list. Please contact the help desk, and " | ||
| - "provide the following details.\n\n%1").arg(e.what())); | ||
| - } | ||
| - emit queryPluginDone(); | ||
| - return; | ||
| -} |
| @@ -1,75 +0,0 @@ | ||
| -/* | ||
| - * synergy -- 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 PLUGINMANAGER_H | ||
| -#define PLUGINMANAGER_H | ||
| - | ||
| -#include <QString> | ||
| -#include <QStringList> | ||
| -#include <QObject> | ||
| - | ||
| -#include "SslCertificate.h" | ||
| -#include "CoreInterface.h" | ||
| -#include "DataDownloader.h" | ||
| -#include "Plugin.h" | ||
| - | ||
| -class PluginManager : public QObject | ||
| -{ | ||
| - Q_OBJECT | ||
| - | ||
| -public: | ||
| - PluginManager(); | ||
| - ~PluginManager(); | ||
| - | ||
| - void init(); | ||
| - | ||
| - int pluginCount() { return m_PluginList.count(); } | ||
| - QStringList& getPluginList() { return m_PluginList; } | ||
| - | ||
| - bool isDone() { return done; } | ||
| - void setDone(bool b) { done = b; } | ||
| - static bool exist(QString name); | ||
| - | ||
| -public slots: | ||
| - void copyPlugins(); | ||
| - void queryPluginList(); | ||
| - | ||
| -private: | ||
| - QString getPluginUrl(const QString& pluginName); | ||
| - bool runProgram( | ||
| - const QString& program, | ||
| - const QStringList& args, | ||
| - const QStringList& env); | ||
| - | ||
| -signals: | ||
| - void error(QString e); | ||
| - void info(QString i); | ||
| - void updateCopyStatus(int); | ||
| - void copyFinished(); | ||
| - void queryPluginDone(); | ||
| - | ||
| -private: | ||
| - QStringList m_PluginList; | ||
| - QString m_PluginDir; | ||
| - QString m_ProfileDir; | ||
| - QString m_InstalledDir; | ||
| - CoreInterface m_CoreInterface; | ||
| - SslCertificate m_SslCertificate; | ||
| - bool done; | ||
| -}; | ||
| - | ||
| -#endif // PLUGINMANAGER_H |
| @@ -1,206 +0,0 @@ | ||
| -/* | ||
| - * synergy -- 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/>. | ||
| - */ | ||
| - | ||
| -#include "PluginWizardPage.h" | ||
| -#include "ui_PluginWizardPageBase.h" | ||
| - | ||
| -#include "SslCertificate.h" | ||
| -#include "PluginManager.h" | ||
| -#include "MainWindow.h" | ||
| -#include "EditionType.h" | ||
| - | ||
| -#include <QMovie> | ||
| -#include <QThread> | ||
| -#include <QTime> | ||
| - | ||
| -PluginWizardPage::PluginWizardPage(MainWindow& mainWindow, QWidget *parent) : | ||
| - QWizardPage(parent), | ||
| - m_Finished(false), | ||
| - m_Edition(Unknown), | ||
| - m_pSslCertificate(NULL), | ||
| - m_mainWindow(mainWindow) | ||
| -{ | ||
| - setupUi(this); | ||
| - | ||
| - QMovie *movie = new QMovie(":/res/image/spinning-wheel.gif"); | ||
| - m_pLabelSpinning->setMovie(movie); | ||
| - movie->start(); | ||
| - | ||
| - m_pSslCertificate = new SslCertificate(this); | ||
| -} | ||
| - | ||
| -PluginWizardPage::~PluginWizardPage() | ||
| -{ | ||
| - delete m_pSslCertificate; | ||
| -} | ||
| - | ||
| -void PluginWizardPage::changeEvent(QEvent *e) | ||
| -{ | ||
| - QWizardPage::changeEvent(e); | ||
| - switch (e->type()) { | ||
| - case QEvent::LanguageChange: | ||
| - retranslateUi(this); | ||
| - break; | ||
| - default: | ||
| - break; | ||
| - } | ||
| -} | ||
| - | ||
| -void PluginWizardPage::initializePage() | ||
| -{ | ||
| - QWizardPage::initializePage(); | ||
| - | ||
| - if (m_Edition != Pro) { | ||
| - updateStatus(tr("Setup complete.")); | ||
| - showFinished(); | ||
| - return; | ||
| - } | ||
| - | ||
| - m_pLabelSpinning->show(); | ||
| - | ||
| - QThread* thread = new QThread; | ||
| - | ||
| - connect(&m_PluginManager, | ||
| - SIGNAL(error(QString)), | ||
| - this, | ||
| - SLOT(showError(QString))); | ||
| - | ||
| - connect(&m_PluginManager, | ||
| - SIGNAL(info(QString)), | ||
| - this, | ||
| - SLOT(updateStatus(QString))); | ||
| - | ||
| - connect(&m_PluginManager, | ||
| - SIGNAL(queryPluginDone()), | ||
| - this, | ||
| - SLOT(queryPluginDone())); | ||
| - | ||
| - connect(&m_PluginManager, | ||
| - SIGNAL(queryPluginDone()), | ||
| - thread, | ||
| - SLOT(quit())); | ||
| - | ||
| - connect(&m_PluginManager, | ||
| - SIGNAL(error(QString)), | ||
| - thread, | ||
| - SLOT(quit())); | ||
| - | ||
| - connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater())); | ||
| - | ||
| - m_PluginManager.moveToThread(thread); | ||
| - thread->start(); | ||
| - | ||
| - QMetaObject::invokeMethod(&m_PluginManager, "queryPluginList", Qt::QueuedConnection); | ||
| -} | ||
| - | ||
| -void PluginWizardPage::queryPluginDone() | ||
| -{ | ||
| - QStringList pluginList = m_PluginManager.getPluginList(); | ||
| - if (pluginList.isEmpty()) { | ||
| - updateStatus(tr("Setup complete.")); | ||
| - showFinished(); | ||
| - } | ||
| - else { | ||
| - m_mainWindow.stopSynergy(); | ||
| - copyPlugins(); | ||
| - m_mainWindow.startSynergy(); | ||
| - } | ||
| -} | ||
| - | ||
| -void PluginWizardPage::copyPlugins() | ||
| -{ | ||
| - m_pThread = new QThread; | ||
| - | ||
| - connect(&m_PluginManager, | ||
| - SIGNAL(copyFinished()), | ||
| - this, | ||
| - SLOT(generateCertificate())); | ||
| - | ||
| - connect(&m_PluginManager, | ||
| - SIGNAL(error(QString)), | ||
| - m_pThread, | ||
| - SLOT(quit())); | ||
| - | ||
| - connect(m_pThread, | ||
| - SIGNAL(finished()), | ||
| - m_pThread, | ||
| - SLOT(deleteLater())); | ||
| - | ||
| - updateStatus( | ||
| - tr("Copying plugins...")); | ||
| - | ||
| - m_PluginManager.moveToThread(m_pThread); | ||
| - m_pThread->start(); | ||
| - | ||
| - QMetaObject::invokeMethod( | ||
| - &m_PluginManager, | ||
| - "copyPlugins", | ||
| - Qt::QueuedConnection); | ||
| -} | ||
| - | ||
| -void PluginWizardPage::generateCertificate() | ||
| -{ | ||
| - connect(m_pSslCertificate, | ||
| - SIGNAL(generateFinished()), | ||
| - this, | ||
| - SLOT(finished())); | ||
| - | ||
| - connect(m_pSslCertificate, | ||
| - SIGNAL(generateFinished()), | ||
| - m_pThread, | ||
| - SLOT(quit())); | ||
| - | ||
| - updateStatus(tr("Generating SSL certificate...")); | ||
| - | ||
| - QMetaObject::invokeMethod( | ||
| - m_pSslCertificate, | ||
| - "generateCertificate", | ||
| - Qt::QueuedConnection); | ||
| -} | ||
| - | ||
| -void PluginWizardPage::showError(QString error) | ||
| -{ | ||
| - updateStatus(tr("Error: %1").arg(error)); | ||
| - showFinished(); | ||
| -} | ||
| - | ||
| - | ||
| -void PluginWizardPage::updateStatus(QString info) | ||
| -{ | ||
| - m_pLabelStatus->setText(info); | ||
| -} | ||
| - | ||
| -void PluginWizardPage::finished() | ||
| -{ | ||
| - // TODO: we should check if ns plugin exists | ||
| - m_mainWindow.appConfig().setCryptoEnabled(true); | ||
| - | ||
| - updateStatus(tr("Plugins installed successfully.")); | ||
| - showFinished(); | ||
| -} | ||
| - | ||
| -void PluginWizardPage::showFinished() | ||
| -{ | ||
| - m_pLabelSpinning->hide(); | ||
| - m_Finished = true; | ||
| - emit completeChanged(); | ||
| -} | ||
| - | ||
| -bool PluginWizardPage::isComplete() const | ||
| -{ | ||
| - return m_Finished; | ||
| -} |
| @@ -1,66 +0,0 @@ | ||
| -/* | ||
| - * synergy -- 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 PLUGINWIZARDPAGE_H | ||
| -#define PLUGINWIZARDPAGE_H | ||
| - | ||
| -#include "AppConfig.h" | ||
| - | ||
| -#include "ui_PluginWizardPageBase.h" | ||
| -#include "PluginManager.h" | ||
| -#include <QWizardPage> | ||
| - | ||
| -class SslCertificate; | ||
| -class MainWindow; | ||
| - | ||
| -class PluginWizardPage : public QWizardPage, public Ui::PluginWizardPage { | ||
| - | ||
| - Q_OBJECT | ||
| - | ||
| -public: | ||
| - PluginWizardPage(MainWindow& mainWindow, QWidget *parent = 0); | ||
| - ~PluginWizardPage(); | ||
| - | ||
| - void setFinished(bool b) { m_Finished = b; } | ||
| - void setEdition(int edition) { m_Edition = edition; } | ||
| - | ||
| - bool isComplete() const; | ||
| - void initializePage(); | ||
| - | ||
| -protected: | ||
| - void changeEvent(QEvent *e); | ||
| - | ||
| -protected slots: | ||
| - void showError(QString error); | ||
| - void updateStatus(QString info); | ||
| - void queryPluginDone(); | ||
| - void generateCertificate(); | ||
| - void finished(); | ||
| - | ||
| -private: | ||
| - void copyPlugins(); | ||
| - void showFinished(); | ||
| - | ||
| -private: | ||
| - bool m_Finished; | ||
| - int m_Edition; | ||
| - PluginManager m_PluginManager; | ||
| - SslCertificate* m_pSslCertificate; | ||
| - QThread* m_pThread; | ||
| - MainWindow& m_mainWindow; | ||
| -}; | ||
| -#endif // PLUGINWIZARDPAGE_H |