From 21655a1c7aab804d77e4f15f986a7f309b9c25c3 Mon Sep 17 00:00:00 2001 From: Nick Bolton Date: Fri, 3 Aug 2018 12:29:50 +0100 Subject: [PATCH 01/10] #6384 Attempt to remove license screen from Windows installer --- dist/wix/Product.wxs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/dist/wix/Product.wxs b/dist/wix/Product.wxs index 3bef6988..b6f91dd4 100644 --- a/dist/wix/Product.wxs +++ b/dist/wix/Product.wxs @@ -42,7 +42,6 @@ - @@ -56,6 +55,17 @@ + + 1 + 1 NOT Installed From 918571b6e2a5b66854991d8d5babf231351597f6 Mon Sep 17 00:00:00 2001 From: Nick Bolton Date: Fri, 3 Aug 2018 16:58:23 +0100 Subject: [PATCH 02/10] #6338 Part-done: Move Auto Config checkbox to settings screen Also refactored Windows Bonjour code to new class, and moved some of the Zeroconf stuff to a new class --- src/gui/src/AppConfig.cpp | 10 - src/gui/src/AppConfig.h | 3 - src/gui/src/BonjourWindows.cpp | 191 +++++++++++++++++++ src/gui/src/BonjourWindows.h | 60 ++++++ src/gui/src/MainWindow.cpp | 299 +++--------------------------- src/gui/src/MainWindow.h | 46 ++--- src/gui/src/MainWindowBase.ui | 22 +-- src/gui/src/SettingsDialog.cpp | 50 ++++- src/gui/src/SettingsDialog.h | 7 + src/gui/src/SettingsDialogBase.ui | 44 +++-- src/gui/src/SetupWizard.cpp | 3 - src/gui/src/Zeroconf.cpp | 46 +++++ src/gui/src/Zeroconf.h | 38 ++++ src/gui/src/ZeroconfService.cpp | 17 +- 14 files changed, 476 insertions(+), 360 deletions(-) create mode 100644 src/gui/src/BonjourWindows.cpp create mode 100644 src/gui/src/BonjourWindows.h create mode 100644 src/gui/src/Zeroconf.cpp create mode 100644 src/gui/src/Zeroconf.h diff --git a/src/gui/src/AppConfig.cpp b/src/gui/src/AppConfig.cpp index b4abd062..547d0866 100644 --- a/src/gui/src/AppConfig.cpp +++ b/src/gui/src/AppConfig.cpp @@ -54,7 +54,6 @@ AppConfig::AppConfig(QSettings* settings) : m_ProcessMode(DEFAULT_PROCESS_MODE), m_AutoConfig(true), m_ElevateMode(defaultElevateMode), - m_AutoConfigPrompted(false), m_CryptoEnabled(false), m_AutoHide(false), m_LastExpiringWarningTime(0) @@ -147,7 +146,6 @@ void AppConfig::loadSettings() QVariant(static_cast(defaultElevateMode))); } m_ElevateMode = static_cast(elevateMode.toInt()); - m_AutoConfigPrompted = settings().value("autoConfigPrompted", false).toBool(); m_Edition = static_cast(settings().value("edition", kUnregistered).toInt()); m_ActivateEmail = settings().value("activateEmail", "").toString(); m_CryptoEnabled = settings().value("cryptoEnabled", true).toBool(); @@ -174,7 +172,6 @@ void AppConfig::saveSettings() // flag is mapped this way settings().setValue("elevateMode", m_ElevateMode == ElevateAlways); settings().setValue("elevateModeEnum", static_cast(m_ElevateMode)); - settings().setValue("autoConfigPrompted", m_AutoConfigPrompted); settings().setValue("edition", m_Edition); settings().setValue("cryptoEnabled", m_CryptoEnabled); settings().setValue("autoHide", m_AutoHide); @@ -234,13 +231,6 @@ void AppConfig::setAutoConfig(bool autoConfig) m_AutoConfig = autoConfig; } -bool AppConfig::autoConfigPrompted() { return m_AutoConfigPrompted; } - -void AppConfig::setAutoConfigPrompted(bool prompted) -{ - m_AutoConfigPrompted = prompted; -} - #ifndef SYNERGY_ENTERPRISE void AppConfig::setEdition(Edition e) { m_Edition = e; diff --git a/src/gui/src/AppConfig.h b/src/gui/src/AppConfig.h index 39330d77..756492a6 100644 --- a/src/gui/src/AppConfig.h +++ b/src/gui/src/AppConfig.h @@ -77,8 +77,6 @@ class AppConfig: public QObject bool startedBefore() const; bool autoConfig() const; void setAutoConfig(bool autoConfig); - bool autoConfigPrompted(); - void setAutoConfigPrompted(bool prompted); #ifndef SYNERGY_ENTERPRISE void setEdition(Edition); Edition edition() const; @@ -141,7 +139,6 @@ protected: bool m_StartedBefore; bool m_AutoConfig; ElevateMode m_ElevateMode; - bool m_AutoConfigPrompted; Edition m_Edition; QString m_ActivateEmail; bool m_CryptoEnabled; diff --git a/src/gui/src/BonjourWindows.cpp b/src/gui/src/BonjourWindows.cpp new file mode 100644 index 00000000..09b82281 --- /dev/null +++ b/src/gui/src/BonjourWindows.cpp @@ -0,0 +1,191 @@ +/* + * synergy -- mouse and keyboard sharing utility + * Copyright (C) 2012-2018 Symless Ltd. + * + * This package is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * found in the file LICENSE that should have accompanied this file. + * + * This package is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "BonjourWindows.h" + +#if defined(Q_OS_WIN) + +#include "MainWindow.h" +#include "SettingsDialog.h" +#include "DataDownloader.h" +#include "QUtility.h" +#include "CommandProcess.h" + +#include +#include +#include +#include +#include + +#define WIN32_LEAN_AND_MEAN +#include + +BonjourWindows::BonjourWindows(SettingsDialog* settingsDialog, MainWindow* mainWindow) : + m_pSettingsDialog(settingsDialog), + m_pMainWindow(mainWindow), + m_pBonjourInstall(nullptr), + m_pDownloadMessageBox(nullptr), + m_pDataDownloader(nullptr) +{ +} + +BonjourWindows::~BonjourWindows() +{ + if (m_pBonjourInstall != nullptr) { + delete m_pBonjourInstall; + } + + if (m_pDownloadMessageBox != nullptr) { + delete m_pDownloadMessageBox; + } + + if (m_pDataDownloader != nullptr) { + delete m_pDataDownloader; + } +} + +void BonjourWindows::download() +{ + QUrl url; + int arch = getProcessorArch(); + if (arch == kProcessorArchWin32) { + url.setUrl(bonjourBaseUrl + bonjourFilename32); + m_pMainWindow->appendLogInfo("downloading 32-bit bonjour"); + } + else if (arch == kProcessorArchWin64) { + url.setUrl(bonjourBaseUrl + bonjourFilename64); + m_pMainWindow->appendLogInfo("downloading 64-bit bonjour"); + } + else { + QMessageBox::critical( + m_pSettingsDialog, tr("Synergy Auto Config"), + tr("Failed to detect system architecture.")); + return; + } + + if (m_pDataDownloader == nullptr) { + m_pDataDownloader = new DataDownloader(this); + connect(m_pDataDownloader, SIGNAL(isComplete()), SLOT(installBonjour())); + } + + m_pDataDownloader->download(url); + + if (m_pDownloadMessageBox != nullptr) { + delete m_pDownloadMessageBox; + m_pDownloadMessageBox = nullptr; + } + + m_pDownloadMessageBox = new QMessageBox(m_pSettingsDialog); + m_pDownloadMessageBox->setWindowTitle("Synergy"); + m_pDownloadMessageBox->setIcon(QMessageBox::Information); + m_pDownloadMessageBox->setText("Installing Bonjour, please wait..."); + QAbstractButton* cancel = m_pDownloadMessageBox->addButton( + tr("Cancel"), QMessageBox::RejectRole); + + m_pDownloadMessageBox->exec(); + + if (cancel == m_pDownloadMessageBox->clickedButton()) { + m_pDataDownloader->cancel(); + } +} + +void BonjourWindows::install() +{ + QString tempLocation = QStandardPaths::writableLocation(QStandardPaths::TempLocation); + + QString filename = tempLocation; + filename.append("\\").append(bonjourTargetFilename); + QFile file(filename); + if (!file.open(QIODevice::WriteOnly)) { + m_pDownloadMessageBox->hide(); + + QMessageBox::warning( + m_pSettingsDialog, "Synergy", + tr("Failed to download Bonjour installer to location: %1") + .arg(tempLocation)); + return; + } + + file.write(m_pDataDownloader->data()); + file.close(); + + QStringList arguments; + arguments.append("/i"); + QString winFilename = QDir::toNativeSeparators(filename); + arguments.append(winFilename); + arguments.append("/passive"); + + if (m_pBonjourInstall != nullptr) { + delete m_pBonjourInstall; + m_pBonjourInstall = nullptr; + } + + m_pBonjourInstall = new CommandProcess("msiexec", arguments); + + QThread* thread = new QThread; + connect(m_pBonjourInstall, SIGNAL(finished()), this, + SLOT(bonjourInstallFinished())); + connect(m_pBonjourInstall, SIGNAL(finished()), thread, SLOT(quit())); + connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater())); + + m_pBonjourInstall->moveToThread(thread); + thread->start(); + + QMetaObject::invokeMethod(m_pBonjourInstall, "run", Qt::QueuedConnection); + + m_pDownloadMessageBox->hide(); +} + +bool BonjourWindows::isRunning() const +{ + QString name = "Bonjour Service"; + + SC_HANDLE hSCManager; + hSCManager = OpenSCManager(nullptr, nullptr, SC_MANAGER_CONNECT); + + if (hSCManager == nullptr) { + m_pMainWindow->appendLogError( + QString("failed to open a service controller manager, error: %1").arg(GetLastError())); + return false; + } + + auto array = name.toLocal8Bit(); + SC_HANDLE hService = OpenService(hSCManager, array.data(), SERVICE_QUERY_STATUS); + + if (hService == nullptr) { + m_pMainWindow->appendLogDebug( + QString("failed to open service: %1").arg(name)); + return false; + } + + SERVICE_STATUS status; + if (QueryServiceStatus(hService, &status)) { + if (status.dwCurrentState == SERVICE_RUNNING) { + return true; + } + } + + return false; +} + +void BonjourWindows::installFinished() +{ + m_pMainWindow->appendLogInfo("bonjour install finished"); + m_pSettingsDialog->allowAutoConfig(); +} + +#endif // Q_OS_WIN diff --git a/src/gui/src/BonjourWindows.h b/src/gui/src/BonjourWindows.h new file mode 100644 index 00000000..031d0f49 --- /dev/null +++ b/src/gui/src/BonjourWindows.h @@ -0,0 +1,60 @@ +/* + * synergy -- mouse and keyboard sharing utility + * Copyright (C) 2012-2018 Symless Ltd. + * + * This package is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * found in the file LICENSE that should have accompanied this file. + * + * This package is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#pragma once + +#include + +#if defined(Q_OS_WIN) + +#include + +static QString bonjourBaseUrl = "http://binaries.symless.com/bonjour/"; +static const char bonjourFilename32[] = "Bonjour.msi"; +static const char bonjourFilename64[] = "Bonjour64.msi"; +static const char bonjourTargetFilename[] = "Bonjour.msi"; + +class SettingsDialog; +class MainWindow; +class CommandProcess; +class DataDownloader; + +class BonjourWindows : public QObject +{ + Q_OBJECT + +public: + BonjourWindows(SettingsDialog* settingsDialog, MainWindow* mainWindow); + virtual ~BonjourWindows(); + +public: + void download(); + void install(); + bool isRunning() const; + +protected slots: + void installFinished(); + +private: + SettingsDialog* m_pSettingsDialog; + MainWindow* m_pMainWindow; + CommandProcess* m_pBonjourInstall; + QMessageBox* m_pDownloadMessageBox; + DataDownloader* m_pDataDownloader; +}; + +#endif // Q_OS_WIN diff --git a/src/gui/src/MainWindow.cpp b/src/gui/src/MainWindow.cpp index 342fdee8..6b2e9051 100644 --- a/src/gui/src/MainWindow.cpp +++ b/src/gui/src/MainWindow.cpp @@ -27,7 +27,6 @@ #include "ServerConfigDialog.h" #include "SettingsDialog.h" #include "ActivationDialog.h" -#include "ZeroconfService.h" #include "DataDownloader.h" #include "CommandProcess.h" #include "LicenseManager.h" @@ -35,6 +34,7 @@ #include "QUtility.h" #include "ProcessorArch.h" #include "SslCertificate.h" +#include "Zeroconf.h" #include #include @@ -51,18 +51,9 @@ #include #endif -#if defined(Q_OS_WIN) -#define WIN32_LEAN_AND_MEAN -#include -#endif - #if defined(Q_OS_WIN) static const char synergyConfigName[] = "synergy.sgc"; static const QString synergyConfigFilter(QObject::tr("Synergy Configurations (*.sgc);;All files (*.*)")); -static QString bonjourBaseUrl = "http://binaries.symless.com/bonjour/"; -static const char bonjourFilename32[] = "Bonjour.msi"; -static const char bonjourFilename64[] = "Bonjour64.msi"; -static const char bonjourTargetFilename[] = "Bonjour.msi"; #else static const char synergyConfigName[] = "synergy.conf"; static const QString synergyConfigFilter(QObject::tr("Synergy Configurations (*.conf);;All files (*.*)")); @@ -85,11 +76,14 @@ MainWindow::MainWindow (QSettings& settings, AppConfig& appConfig) MainWindow::MainWindow (QSettings& settings, AppConfig& appConfig, LicenseManager& licenseManager) #endif -: m_Settings(settings), - m_AppConfig(&appConfig), +: #ifndef SYNERGY_ENTERPRISE m_LicenseManager(&licenseManager), + m_pZeroconf(nullptr), + m_ActivationDialogRunning(false), #endif + m_Settings(settings), + m_AppConfig(&appConfig), m_pSynergy(NULL), m_SynergyState(synergyDisconnected), m_ServerConfig(&m_Settings, 5, 3, m_AppConfig->screenName(), this), @@ -102,21 +96,12 @@ MainWindow::MainWindow (QSettings& settings, AppConfig& appConfig, m_pMenuEdit(NULL), m_pMenuWindow(NULL), m_pMenuHelp(NULL), -#ifndef SYNERGY_ENTERPRISE - m_pZeroconfService(NULL), -#endif - m_pDataDownloader(NULL), - m_DownloadMessageBox(NULL), m_pCancelButton(NULL), m_SuppressAutoConfigWarning(false), - m_BonjourInstall(NULL), m_SuppressEmptyServerWarning(false), m_ExpectedRunningState(kStopped), - m_pSslCertificate(NULL) -#ifndef SYNERGY_ENTERPRISE - , m_ActivationDialogRunning(false) -#endif - , m_SecureSocket(false) + m_pSslCertificate(NULL), + m_SecureSocket(false) { setupUi(this); @@ -147,10 +132,10 @@ MainWindow::MainWindow (QSettings& settings, AppConfig& appConfig, #endif m_SuppressAutoConfigWarning = true; - m_pCheckBoxAutoConfig->setChecked(appConfig.autoConfig()); + m_pLabelAutoDetected->setVisible(appConfig.autoConfig()); + m_pComboServerList->setVisible(appConfig.autoConfig()); m_SuppressAutoConfigWarning = false; - m_pComboServerList->hide(); m_trialWidget->hide(); // hide padlock icon @@ -191,7 +176,14 @@ MainWindow::MainWindow (QSettings& settings, AppConfig& appConfig, #ifdef SYNERGY_ENTERPRISE m_pActivate->setVisible(false); - m_pCheckBoxAutoConfig->setVisible(false); +#endif + + m_pZeroconf = new Zeroconf(this); + +#ifndef SYNERGY_ENTERPRISE + if (m_AppConfig->autoConfig()) { + m_pZeroconf->startService(); + } #endif } @@ -202,19 +194,13 @@ MainWindow::~MainWindow() stopDesktop(); } - saveSettings(); - #ifndef SYNERGY_ENTERPRISE - delete m_pZeroconfService; + if (m_AppConfig->autoConfig()) { + m_pZeroconf->stopService(); + } #endif - if (m_DownloadMessageBox != NULL) { - delete m_DownloadMessageBox; - } - - if (m_BonjourInstall != NULL) { - delete m_BonjourInstall; - } + saveSettings(); delete m_pSslCertificate; } @@ -229,12 +215,6 @@ void MainWindow::open() m_VersionChecker.checkLatest(); -#ifndef SYNERGY_ENTERPRISE - if (!appConfig().autoConfigPrompted()) { - promptAutoConfig(); - } -#endif - // only start if user has previously started. this stops the gui from // auto hiding before the user has configured synergy (which of course // confuses first time users, who think synergy has crashed). @@ -773,7 +753,7 @@ bool MainWindow::clientArgs(QStringList& args, QString& app) #ifndef SYNERGY_ENTERPRISE // check auto config first, if it is disabled or no server detected, // use line edit host name if it is not empty - if (m_pCheckBoxAutoConfig->isChecked()) { + if (appConfig().autoConfig()) { if (m_pComboServerList->count() != 0) { QString serverIp = m_pComboServerList->currentText(); args << serverIp + ":" + QString::number(appConfig().port()); @@ -1101,27 +1081,7 @@ void MainWindow::changeEvent(QEvent* event) } } -#ifndef SYNERGY_ENTERPRISE -void MainWindow::updateZeroconfService() -{ - QMutexLocker locker(&m_UpdateZeroconfMutex); - - if (isBonjourRunning()) { - if (!m_AppConfig->wizardShouldRun()) { - if (m_pZeroconfService) { - delete m_pZeroconfService; - m_pZeroconfService = NULL; - } - - if (m_AppConfig->autoConfig() || synergyType() == synergyServer) { - m_pZeroconfService = new ZeroconfService(this); - } - } - } -} -#endif - -void MainWindow::serverDetected(const QString name) +void MainWindow::zeroconfServerDetected(const QString name) { if (m_pComboServerList->findText(name) == -1) { // Note: the first added item triggers startSynergy @@ -1223,21 +1183,11 @@ MainWindow::licenseManager() const void MainWindow::on_m_pGroupClient_toggled(bool on) { m_pGroupServer->setChecked(!on); -#ifndef SYNERGY_ENTERPRISE - if (on) { - updateZeroconfService(); - } -#endif } void MainWindow::on_m_pGroupServer_toggled(bool on) { m_pGroupClient->setChecked(!on); -#ifndef SYNERGY_ENTERPRISE - if (on) { - updateZeroconfService(); - } -#endif } bool MainWindow::on_m_pButtonBrowseConfigFile_clicked() @@ -1345,211 +1295,13 @@ void MainWindow::on_m_pButtonApply_clicked() restartSynergy(); } -#if defined(Q_OS_WIN) -bool MainWindow::isServiceRunning(QString name) -{ - SC_HANDLE hSCManager; - hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_CONNECT); - if (hSCManager == NULL) { - appendLogError("failed to open a service controller manager, error: " + - GetLastError()); - return false; - } - - auto array = name.toLocal8Bit(); - SC_HANDLE hService = OpenService(hSCManager, array.data(), SERVICE_QUERY_STATUS); - - if (hService == NULL) { - appendLogDebug("failed to open service: " + name); - return false; - } - - SERVICE_STATUS status; - if (QueryServiceStatus(hService, &status)) { - if (status.dwCurrentState == SERVICE_RUNNING) { - return true; - } - } -#else -bool MainWindow::isServiceRunning() -{ -#endif - return false; -} - -#ifndef SYNERGY_ENTERPRISE -bool MainWindow::isBonjourRunning() -{ - bool result = false; - -#if defined(Q_OS_WIN) - result = isServiceRunning("Bonjour Service"); -#else - result = true; -#endif - - return result; -} - -void MainWindow::downloadBonjour() -{ -#if defined(Q_OS_WIN) - QUrl url; - int arch = getProcessorArch(); - if (arch == kProcessorArchWin32) { - url.setUrl(bonjourBaseUrl + bonjourFilename32); - appendLogInfo("downloading 32-bit Bonjour"); - } - else if (arch == kProcessorArchWin64) { - url.setUrl(bonjourBaseUrl + bonjourFilename64); - appendLogInfo("downloading 64-bit Bonjour"); - } - else { - QMessageBox::critical( - this, tr("Synergy"), - tr("Failed to detect system architecture.")); - return; - } - - if (m_pDataDownloader == NULL) { - m_pDataDownloader = new DataDownloader(this); - connect(m_pDataDownloader, SIGNAL(isComplete()), SLOT(installBonjour())); - } - - m_pDataDownloader->download(url); - - if (m_DownloadMessageBox == NULL) { - m_DownloadMessageBox = new QMessageBox(this); - m_DownloadMessageBox->setWindowTitle("Synergy"); - m_DownloadMessageBox->setIcon(QMessageBox::Information); - m_DownloadMessageBox->setText("Installing Bonjour, please wait..."); - m_DownloadMessageBox->setStandardButtons(0); - m_pCancelButton = m_DownloadMessageBox->addButton( - tr("Cancel"), QMessageBox::RejectRole); - } - - m_DownloadMessageBox->exec(); - - if (m_DownloadMessageBox->clickedButton() == m_pCancelButton) { - m_pDataDownloader->cancel(); - } -#endif -} - -void MainWindow::installBonjour() -{ -#if defined(Q_OS_WIN) -#if QT_VERSION >= 0x050000 - QString tempLocation = QStandardPaths::writableLocation(QStandardPaths::TempLocation); -#else - QString tempLocation = QDesktopServices::storageLocation( - QDesktopServices::TempLocation); -#endif - QString filename = tempLocation; - filename.append("\\").append(bonjourTargetFilename); - QFile file(filename); - if (!file.open(QIODevice::WriteOnly)) { - m_DownloadMessageBox->hide(); - - QMessageBox::warning( - this, "Synergy", - tr("Failed to download Bonjour installer to location: %1") - .arg(tempLocation)); - return; - } - - file.write(m_pDataDownloader->data()); - file.close(); - - QStringList arguments; - arguments.append("/i"); - QString winFilename = QDir::toNativeSeparators(filename); - arguments.append(winFilename); - arguments.append("/passive"); - if (m_BonjourInstall == NULL) { - m_BonjourInstall = new CommandProcess("msiexec", arguments); - } - - QThread* thread = new QThread; - connect(m_BonjourInstall, SIGNAL(finished()), this, - SLOT(bonjourInstallFinished())); - connect(m_BonjourInstall, SIGNAL(finished()), thread, SLOT(quit())); - connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater())); - - m_BonjourInstall->moveToThread(thread); - thread->start(); - - QMetaObject::invokeMethod(m_BonjourInstall, "run", Qt::QueuedConnection); - - m_DownloadMessageBox->hide(); -#endif -} - -void MainWindow::promptAutoConfig() -{ - if (!isBonjourRunning()) { - int r = QMessageBox::question( - this, tr("Synergy"), - tr("Do you want to enable auto config and install Bonjour?\n\n" - "This feature helps you establish the connection."), - QMessageBox::Yes | QMessageBox::No); - - if (r == QMessageBox::Yes) { - m_AppConfig->setAutoConfig(true); - downloadBonjour(); - } - else { - m_AppConfig->setAutoConfig(false); - m_pCheckBoxAutoConfig->setChecked(false); - } - } - - m_AppConfig->setAutoConfigPrompted(true); -} - -void MainWindow::on_m_pComboServerList_currentIndexChanged(QString ) +void MainWindow::on_m_pComboServerList_currentIndexChanged(const QString &arg1) { if (m_pComboServerList->count() != 0) { restartSynergy(); } } -void MainWindow::on_m_pCheckBoxAutoConfig_toggled(bool checked) -{ - if (!isBonjourRunning() && checked) { - if (!m_SuppressAutoConfigWarning) { - int r = QMessageBox::information( - this, tr("Synergy"), - tr("Auto config feature requires Bonjour.\n\n" - "Do you want to install Bonjour?"), - QMessageBox::Yes | QMessageBox::No); - - if (r == QMessageBox::Yes) { - downloadBonjour(); - } - } - - m_pCheckBoxAutoConfig->setChecked(false); - return; - } - - m_pLineEditHostname->setDisabled(checked); - appConfig().setAutoConfig(checked); - updateZeroconfService(); - - if (!checked) { - m_pComboServerList->clear(); - m_pComboServerList->hide(); - } -} - -void MainWindow::bonjourInstallFinished() -{ - appendLogInfo("Bonjour install finished"); - - m_pCheckBoxAutoConfig->setChecked(true); -} - int MainWindow::raiseActivationDialog() { if (m_ActivationDialogRunning) { @@ -1573,7 +1325,6 @@ int MainWindow::raiseActivationDialog() } return result; } -#endif void MainWindow::on_windowShown() { diff --git a/src/gui/src/MainWindow.h b/src/gui/src/MainWindow.h index a42a9663..69e19be1 100644 --- a/src/gui/src/MainWindow.h +++ b/src/gui/src/MainWindow.h @@ -16,9 +16,7 @@ * along with this program. If not, see . */ -#if !defined(MAINWINDOW__H) - -#define MAINWINDOW__H +#pragma once #include #include @@ -54,11 +52,11 @@ class QAbstractButton; class LogDialog; class QSynergyApplication; class SetupWizard; -class ZeroconfService; class DataDownloader; class CommandProcess; class SslCertificate; class LicenseManager; +class Zeroconf; class MainWindow : public QMainWindow, public Ui::MainWindowBase { @@ -119,10 +117,10 @@ class MainWindow : public QMainWindow, public Ui::MainWindowBase void showConfigureServer(const QString& message); void showConfigureServer() { showConfigureServer(""); } void autoAddScreen(const QString name); - void serverDetected(const QString name); + void zeroconfServerDetected(const QString name); void updateLocalFingerprint(); + Zeroconf& zeroconf() { return *m_pZeroconf; } #ifndef SYNERGY_ENTERPRISE - void updateZeroconfService(); LicenseManager& licenseManager() const; int raiseActivationDialog(); #endif @@ -155,9 +153,6 @@ public slots: void logOutput(); void logError(); void updateFound(const QString& version); -#ifndef SYNERGY_ENTERPRISE - void bonjourInstallFinished(); -#endif void saveSettings(); protected: @@ -190,11 +185,6 @@ public slots: bool isServiceRunning(); #endif -#ifndef SYNERGY_ENTERPRISE - bool isBonjourRunning(); - void downloadBonjour(); - void promptAutoConfig(); -#endif QString getProfileRootForArg(); void checkConnected(const QString& line); void checkFingerprint(const QString& line); @@ -211,9 +201,14 @@ public slots: void secureSocket(bool secureSocket); private: +#ifndef SYNERGY_ENTERPRISE + LicenseManager* m_LicenseManager; + Zeroconf* m_pZeroconf; + bool m_ActivationDialogRunning; + QStringList m_PendingClientNames; +#endif QSettings& m_Settings; AppConfig* m_AppConfig; - LicenseManager* m_LicenseManager; QProcess* m_pSynergy; int m_SynergyState; ServerConfig m_ServerConfig; @@ -228,37 +223,20 @@ public slots: QMenu* m_pMenuEdit; QMenu* m_pMenuWindow; QMenu* m_pMenuHelp; -#ifndef SYNERGY_ENTERPRISE - ZeroconfService* m_pZeroconfService; -#endif - DataDownloader* m_pDataDownloader; - QMessageBox* m_DownloadMessageBox; QAbstractButton* m_pCancelButton; - QMutex m_UpdateZeroconfMutex; bool m_SuppressAutoConfigWarning; - CommandProcess* m_BonjourInstall; bool m_SuppressEmptyServerWarning; qRuningState m_ExpectedRunningState; QMutex m_StopDesktopMutex; SslCertificate* m_pSslCertificate; -#ifndef SYNERGY_ENTERPRISE - bool m_ActivationDialogRunning; - QStringList m_PendingClientNames; -#endif bool m_SecureSocket; private slots: void on_m_pButtonApply_clicked(); -#ifndef SYNERGY_ENTERPRISE - void on_m_pCheckBoxAutoConfig_toggled(bool checked); - void on_m_pComboServerList_currentIndexChanged(QString ); - void installBonjour(); -#endif void on_windowShown(); + void on_m_pComboServerList_currentIndexChanged(const QString &arg1); + signals: void windowShown(); }; - -#endif - diff --git a/src/gui/src/MainWindowBase.ui b/src/gui/src/MainWindowBase.ui index 7069b8b2..429dfcd2 100644 --- a/src/gui/src/MainWindowBase.ui +++ b/src/gui/src/MainWindowBase.ui @@ -48,7 +48,7 @@ - :/res/icons/16x16/warning.png + :/res/icons/16x16/warning.png @@ -99,7 +99,7 @@ - :/res/icons/16x16/warning.png + :/res/icons/16x16/warning.png @@ -315,13 +315,6 @@ - - - - Auto config - - - @@ -338,6 +331,13 @@ + + + + Auto detected: + + + @@ -391,7 +391,7 @@ - :/res/icons/16x16/padlock.png + :/res/icons/16x16/padlock.png @@ -542,7 +542,7 @@ - + diff --git a/src/gui/src/SettingsDialog.cpp b/src/gui/src/SettingsDialog.cpp index 00b656ac..b7325433 100644 --- a/src/gui/src/SettingsDialog.cpp +++ b/src/gui/src/SettingsDialog.cpp @@ -25,6 +25,8 @@ #include "AppConfig.h" #include "SslCertificate.h" #include "MainWindow.h" +#include "BonjourWindows.h" +#include "Zeroconf.h" #include #include @@ -37,10 +39,14 @@ static const char networkSecurity[] = "ns"; SettingsDialog::SettingsDialog(QWidget* parent, AppConfig& config) : QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint), Ui::SettingsDialogBase(), - m_appConfig(config) + m_appConfig(config), + m_pBonjourWindows(nullptr) { setupUi(this); + // TODO: maybe just accept MainWindow type in ctor? + m_pMainWindow = dynamic_cast(parent); + m_Locale.fillLanguageComboBox(m_pComboLanguage); m_pLineEditScreenName->setText(appConfig().screenName()); @@ -53,20 +59,32 @@ SettingsDialog::SettingsDialog(QWidget* parent, AppConfig& config) : m_pCheckBoxAutoHide->setChecked(appConfig().getAutoHide()); #if defined(Q_OS_WIN) - m_pComboElevate->setCurrentIndex(static_cast(appConfig().elevateMode())); + m_pBonjourWindows = new BonjourWindows(this, m_pMainWindow); + if (m_pBonjourWindows->isRunning()) { + allowAutoConfig(); + m_pCheckBoxAutoConfig->setChecked(m_appConfig.autoConfig()); + } + + m_pComboElevate->setCurrentIndex(static_cast(appConfig().elevateMode())); m_pCheckBoxAutoHide->hide(); #else // elevate checkbox is only useful on ms windows. m_pLabelElevate->hide(); m_pComboElevate->hide(); + + // for linux and mac, allow auto config by default + allowAutoConfig(); #endif m_pCheckBoxEnableCrypto->setChecked(m_appConfig.getCryptoEnabled()); #ifdef SYNERGY_ENTERPRISE m_pCheckBoxEnableCrypto->setEnabled(true); + m_pLabelProUpgrade->hide(); #else - m_pCheckBoxEnableCrypto->setEnabled(m_appConfig.edition() == kPro); + bool isPro = m_appConfig.edition() == kPro; + m_pCheckBoxEnableCrypto->setEnabled(isPro); + m_pLabelProUpgrade->setVisible(!isPro); #endif } @@ -96,7 +114,7 @@ void SettingsDialog::reject() void SettingsDialog::changeEvent(QEvent* event) { - if (event != 0) + if (event != nullptr) { switch (event->type()) { @@ -118,6 +136,12 @@ void SettingsDialog::changeEvent(QEvent* event) } } +void SettingsDialog::allowAutoConfig() +{ + m_pLabelInstallBonjour->hide(); + m_pCheckBoxAutoConfig->setEnabled(true); +} + void SettingsDialog::on_m_pCheckBoxLogToFile_stateChanged(int i) { bool checked = i == 2; @@ -152,7 +176,21 @@ void SettingsDialog::on_m_pCheckBoxEnableCrypto_toggled(bool checked) if (checked) { SslCertificate sslCertificate; sslCertificate.generateCertificate(); - MainWindow& mainWindow = dynamic_cast (*this->parent()); - mainWindow.updateLocalFingerprint(); + m_pMainWindow->updateLocalFingerprint(); + } +} + +void SettingsDialog::on_m_pLabelInstallBonjour_linkActivated(const QString&) +{ + m_pBonjourWindows->download(); +} + +void SettingsDialog::on_m_pCheckBoxAutoConfig_toggled(bool checked) +{ + if (checked) { + m_pMainWindow->zeroconf().startService(); + } + else { + m_pMainWindow->zeroconf().stopService(); } } diff --git a/src/gui/src/SettingsDialog.h b/src/gui/src/SettingsDialog.h index 298197aa..5a524596 100644 --- a/src/gui/src/SettingsDialog.h +++ b/src/gui/src/SettingsDialog.h @@ -25,7 +25,9 @@ #include "SynergyLocale.h" #include "CoreInterface.h" +class MainWindow; class AppConfig; +class BonjourWindows; class SettingsDialog : public QDialog, public Ui::SettingsDialogBase { @@ -35,6 +37,7 @@ class SettingsDialog : public QDialog, public Ui::SettingsDialogBase SettingsDialog(QWidget* parent, AppConfig& config); static QString browseForSynergyc(QWidget* parent, const QString& programDir, const QString& synergycName); static QString browseForSynergys(QWidget* parent, const QString& programDir, const QString& synergysName); + void allowAutoConfig(); protected: void accept(); @@ -43,15 +46,19 @@ class SettingsDialog : public QDialog, public Ui::SettingsDialogBase AppConfig& appConfig() { return m_appConfig; } private: + MainWindow* m_pMainWindow; AppConfig& m_appConfig; SynergyLocale m_Locale; CoreInterface m_CoreInterface; + BonjourWindows* m_pBonjourWindows; private slots: void on_m_pCheckBoxEnableCrypto_toggled(bool checked); void on_m_pComboLanguage_currentIndexChanged(int index); void on_m_pCheckBoxLogToFile_stateChanged(int ); void on_m_pButtonBrowseLog_clicked(); + void on_m_pLabelInstallBonjour_linkActivated(const QString &link); + void on_m_pCheckBoxAutoConfig_toggled(bool checked); }; #endif diff --git a/src/gui/src/SettingsDialogBase.ui b/src/gui/src/SettingsDialogBase.ui index 476600d0..a96f29f5 100644 --- a/src/gui/src/SettingsDialogBase.ui +++ b/src/gui/src/SettingsDialogBase.ui @@ -157,7 +157,7 @@ - + true @@ -168,7 +168,7 @@ - &Network Security + &Network @@ -180,22 +180,42 @@ false - Use &TLS encryption + Enable &TLS Encryption + + + + + + + false + + + Enable Auto Config + + + + + + + <html><head/><body><p><a href="#"><span style=" text-decoration: underline; color:#007af4;">Install Bonjour</span></a></p></body></html> + + + Qt::RichText + + + true - - - Qt::Horizontal + + + <html><head/><body><p><a href="https://symless.com/account?source=gui&amp;intent=upgrade"><span style=" text-decoration: underline; color:#007af4;">Upgrade to Pro</span></a></p></body></html> - - - 40 - 20 - + + Qt::RichText - + diff --git a/src/gui/src/SetupWizard.cpp b/src/gui/src/SetupWizard.cpp index 863b2aa3..4714a965 100644 --- a/src/gui/src/SetupWizard.cpp +++ b/src/gui/src/SetupWizard.cpp @@ -126,9 +126,6 @@ void SetupWizard::accept() if (m_StartMain) { -#ifndef SYNERGY_ENTERPRISE - m_MainWindow.updateZeroconfService(); -#endif m_MainWindow.open(); } } diff --git a/src/gui/src/Zeroconf.cpp b/src/gui/src/Zeroconf.cpp new file mode 100644 index 00000000..65eb81f7 --- /dev/null +++ b/src/gui/src/Zeroconf.cpp @@ -0,0 +1,46 @@ +/* + * synergy -- mouse and keyboard sharing utility + * Copyright (C) 2012-2018 Symless Ltd. + * + * This package is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * found in the file LICENSE that should have accompanied this file. + * + * This package is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "Zeroconf.h" + +#include "ZeroconfService.h" +#include "MainWindow.h" + +Zeroconf::Zeroconf(MainWindow* mainWindow) : + m_pMainWindow(mainWindow), + m_pZeroconfService(nullptr) +{ +} + +Zeroconf::~Zeroconf() +{ + stopService(); +} + +void Zeroconf::startService() +{ + stopService(); + m_pZeroconfService = new ZeroconfService(m_pMainWindow); +} + +void Zeroconf::stopService() +{ + if (m_pZeroconfService != nullptr) { + delete m_pZeroconfService; + m_pZeroconfService = nullptr; + } +} diff --git a/src/gui/src/Zeroconf.h b/src/gui/src/Zeroconf.h new file mode 100644 index 00000000..c2e77191 --- /dev/null +++ b/src/gui/src/Zeroconf.h @@ -0,0 +1,38 @@ +/* + * synergy -- mouse and keyboard sharing utility + * Copyright (C) 2012-2018 Symless Ltd. + * + * This package is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * found in the file LICENSE that should have accompanied this file. + * + * This package is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#pragma once + +#include + +class MainWindow; +class ZeroconfService; + +class Zeroconf : public QObject +{ + Q_OBJECT + +public: + Zeroconf(MainWindow* mainWindow); + virtual ~Zeroconf(); + void startService(); + void stopService(); + +private: + MainWindow* m_pMainWindow; + ZeroconfService* m_pZeroconfService; +}; diff --git a/src/gui/src/ZeroconfService.cpp b/src/gui/src/ZeroconfService.cpp index 856fce91..e8a124f2 100644 --- a/src/gui/src/ZeroconfService.cpp +++ b/src/gui/src/ZeroconfService.cpp @@ -38,8 +38,8 @@ const char* ZeroconfService:: m_ClientServiceName = "_synergyClient._tcp"; ZeroconfService::ZeroconfService(MainWindow* mainWindow) : m_pMainWindow(mainWindow), - m_pZeroconfBrowser(0), - m_pZeroconfRegister(0), + m_pZeroconfBrowser(nullptr), + m_pZeroconfRegister(nullptr), m_ServiceRegistered(false) { if (m_pMainWindow->synergyType() == MainWindow::synergyServer) { @@ -81,7 +81,7 @@ void ZeroconfService::serverDetected(const QList& list) registerService(false); m_pMainWindow->appendLogInfo(tr("zeroconf server detected: %1").arg( record.serviceName)); - m_pMainWindow->serverDetected(record.serviceName); + m_pMainWindow->zeroconfServerDetected(record.serviceName); } } @@ -96,7 +96,8 @@ void ZeroconfService::clientDetected(const QList& list) void ZeroconfService::errorHandle(DNSServiceErrorType errorCode) { - QMessageBox::critical(0, tr("Zero configuration service"), + QMessageBox::critical( + m_pMainWindow, tr("Synergy Auto Config"), tr("Error code: %1.").arg(errorCode)); } @@ -127,8 +128,9 @@ bool ZeroconfService::registerService(bool server) if (!m_ServiceRegistered) { if (!m_zeroconfServer.listen()) { - QMessageBox::critical(0, tr("Zero configuration service"), - tr("Unable to start the zeroconf: %1.") + QMessageBox::critical( + m_pMainWindow, tr("Synergy Auto Config"), + tr("Unable to start zeroconf: %1.") .arg(m_zeroconfServer.errorString())); result = false; } @@ -137,7 +139,8 @@ bool ZeroconfService::registerService(bool server) if (server) { QString localIP = getLocalIPAddresses(); if (localIP.isEmpty()) { - QMessageBox::warning(m_pMainWindow, tr("Synergy"), + QMessageBox::warning( + m_pMainWindow, tr("Synergy Auto Config"), tr("Failed to get local IP address. " "Please manually type in server address " "on your clients")); From d2d2a5e1d9c2e634b28ffa72becf6f54a5805eda Mon Sep 17 00:00:00 2001 From: Nick Bolton Date: Fri, 3 Aug 2018 23:00:15 +0100 Subject: [PATCH 03/10] #6338 Only call Bonjour download if on Windows --- src/gui/src/SettingsDialog.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/src/SettingsDialog.cpp b/src/gui/src/SettingsDialog.cpp index b7325433..ba259849 100644 --- a/src/gui/src/SettingsDialog.cpp +++ b/src/gui/src/SettingsDialog.cpp @@ -182,7 +182,9 @@ void SettingsDialog::on_m_pCheckBoxEnableCrypto_toggled(bool checked) void SettingsDialog::on_m_pLabelInstallBonjour_linkActivated(const QString&) { +#if defined(Q_OS_WIN) m_pBonjourWindows->download(); +#endif } void SettingsDialog::on_m_pCheckBoxAutoConfig_toggled(bool checked) From c0452f0e616d90c6f1078c975442e0d46f402314 Mon Sep 17 00:00:00 2001 From: Nick Bolton Date: Fri, 3 Aug 2018 23:41:50 +0100 Subject: [PATCH 04/10] #6338 Only use Zeroconf if non-enterprise build --- src/gui/src/MainWindow.cpp | 11 +++++------ src/gui/src/MainWindow.h | 2 +- src/gui/src/SettingsDialog.cpp | 2 ++ 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/gui/src/MainWindow.cpp b/src/gui/src/MainWindow.cpp index 6b2e9051..c6a8f925 100644 --- a/src/gui/src/MainWindow.cpp +++ b/src/gui/src/MainWindow.cpp @@ -79,9 +79,9 @@ MainWindow::MainWindow (QSettings& settings, AppConfig& appConfig, : #ifndef SYNERGY_ENTERPRISE m_LicenseManager(&licenseManager), - m_pZeroconf(nullptr), m_ActivationDialogRunning(false), #endif + m_pZeroconf(nullptr), m_Settings(settings), m_AppConfig(&appConfig), m_pSynergy(NULL), @@ -178,9 +178,8 @@ MainWindow::MainWindow (QSettings& settings, AppConfig& appConfig, m_pActivate->setVisible(false); #endif - m_pZeroconf = new Zeroconf(this); - #ifndef SYNERGY_ENTERPRISE + m_pZeroconf = new Zeroconf(this); if (m_AppConfig->autoConfig()) { m_pZeroconf->startService(); } @@ -195,9 +194,7 @@ MainWindow::~MainWindow() } #ifndef SYNERGY_ENTERPRISE - if (m_AppConfig->autoConfig()) { - m_pZeroconf->stopService(); - } + delete m_pZeroconf; #endif saveSettings(); @@ -1302,6 +1299,7 @@ void MainWindow::on_m_pComboServerList_currentIndexChanged(const QString &arg1) } } +#ifndef SYNERGY_ENTERPRISE int MainWindow::raiseActivationDialog() { if (m_ActivationDialogRunning) { @@ -1325,6 +1323,7 @@ int MainWindow::raiseActivationDialog() } return result; } +#endif void MainWindow::on_windowShown() { diff --git a/src/gui/src/MainWindow.h b/src/gui/src/MainWindow.h index 69e19be1..84c1096c 100644 --- a/src/gui/src/MainWindow.h +++ b/src/gui/src/MainWindow.h @@ -203,10 +203,10 @@ public slots: private: #ifndef SYNERGY_ENTERPRISE LicenseManager* m_LicenseManager; - Zeroconf* m_pZeroconf; bool m_ActivationDialogRunning; QStringList m_PendingClientNames; #endif + Zeroconf* m_pZeroconf; QSettings& m_Settings; AppConfig* m_AppConfig; QProcess* m_pSynergy; diff --git a/src/gui/src/SettingsDialog.cpp b/src/gui/src/SettingsDialog.cpp index ba259849..690c6341 100644 --- a/src/gui/src/SettingsDialog.cpp +++ b/src/gui/src/SettingsDialog.cpp @@ -189,10 +189,12 @@ void SettingsDialog::on_m_pLabelInstallBonjour_linkActivated(const QString&) void SettingsDialog::on_m_pCheckBoxAutoConfig_toggled(bool checked) { +#ifndef SYNERGY_ENTERPRISE if (checked) { m_pMainWindow->zeroconf().startService(); } else { m_pMainWindow->zeroconf().stopService(); } +#endif } From 53d5c89851e4fe3f1fa4ee7bfdb3c38a52b0454e Mon Sep 17 00:00:00 2001 From: Nick Bolton Date: Mon, 6 Aug 2018 06:05:34 +0100 Subject: [PATCH 05/10] #6338 Hide auto config setting for Enterprise build --- src/gui/src/SettingsDialog.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/gui/src/SettingsDialog.cpp b/src/gui/src/SettingsDialog.cpp index 690c6341..5ca61c3c 100644 --- a/src/gui/src/SettingsDialog.cpp +++ b/src/gui/src/SettingsDialog.cpp @@ -78,13 +78,21 @@ SettingsDialog::SettingsDialog(QWidget* parent, AppConfig& config) : #endif m_pCheckBoxEnableCrypto->setChecked(m_appConfig.getCryptoEnabled()); + #ifdef SYNERGY_ENTERPRISE + m_pCheckBoxEnableCrypto->setEnabled(true); m_pLabelProUpgrade->hide(); + + m_pCheckBoxAutoConfig->hide(); + m_pLabelInstallBonjour->hide(); + #else + bool isPro = m_appConfig.edition() == kPro; m_pCheckBoxEnableCrypto->setEnabled(isPro); m_pLabelProUpgrade->setVisible(!isPro); + #endif } From aae43304c32d0a5c859556da8980f9fb2ea6e94e Mon Sep 17 00:00:00 2001 From: Nick Bolton Date: Mon, 6 Aug 2018 06:05:58 +0100 Subject: [PATCH 06/10] #6338 Tidy up settings screen layout --- src/gui/src/SettingsDialogBase.ui | 146 ++++++++++++++++++++---------- 1 file changed, 97 insertions(+), 49 deletions(-) diff --git a/src/gui/src/SettingsDialogBase.ui b/src/gui/src/SettingsDialogBase.ui index a96f29f5..a1d446a1 100644 --- a/src/gui/src/SettingsDialogBase.ui +++ b/src/gui/src/SettingsDialogBase.ui @@ -2,14 +2,6 @@ SettingsDialogBase - - - 0 - 0 - 368 - 446 - - Settings @@ -156,6 +148,22 @@ + + + + Qt::Vertical + + + QSizePolicy::MinimumExpanding + + + + 20 + 15 + + + + @@ -174,52 +182,90 @@ QFormLayout::AllNonFixedFieldsGrow - - - - false - - - Enable &TLS Encryption - - - - - - - false - - - Enable Auto Config - - - - - - - <html><head/><body><p><a href="#"><span style=" text-decoration: underline; color:#007af4;">Install Bonjour</span></a></p></body></html> - - - Qt::RichText - - - true - - - + + 2 + + + 12 + + + 2 + + + 12 + - - - <html><head/><body><p><a href="https://symless.com/account?source=gui&amp;intent=upgrade"><span style=" text-decoration: underline; color:#007af4;">Upgrade to Pro</span></a></p></body></html> + + + 0 - - Qt::RichText + + 12 - + + + + false + + + Enable &TLS Encryption + + + + + + + false + + + Enable Auto Config + + + + + + + <html><head/><body><p><a href="#"><span style=" text-decoration: underline; color:#007af4;">Install Bonjour</span></a></p></body></html> + + + Qt::RichText + + + true + + + + + + + <html><head/><body><p><a href="https://symless.com/account?source=gui&amp;intent=upgrade"><span style=" text-decoration: underline; color:#007af4;">Upgrade to Pro</span></a></p></body></html> + + + Qt::RichText + + + + + + + + Qt::Vertical + + + QSizePolicy::MinimumExpanding + + + + 20 + 15 + + + + @@ -310,10 +356,13 @@ Qt::Vertical + + QSizePolicy::MinimumExpanding + 20 - 40 + 15 @@ -337,7 +386,6 @@ m_pLineEditInterface m_pComboElevate m_pCheckBoxAutoHide - m_pCheckBoxEnableCrypto m_pComboLogLevel m_pCheckBoxLogToFile m_pLineEditLogFilename From 87d8fc1e14add23abf50d8ce531e81c8f6bae50b Mon Sep 17 00:00:00 2001 From: Nick Bolton Date: Wed, 8 Aug 2018 14:41:37 +0100 Subject: [PATCH 07/10] #6338 Use either manual or auto config in main window Only enable/disable auto-config when saving settings, and only start the server/client when clicking Start/Stop/Apply. --- src/gui/src/BonjourWindows.cpp | 32 ++++++++---- src/gui/src/BonjourWindows.h | 11 ++-- src/gui/src/DataDownloader.cpp | 5 +- src/gui/src/MainWindow.cpp | 83 +++++++++++++++++++++---------- src/gui/src/MainWindow.h | 8 +-- src/gui/src/MainWindowBase.ui | 14 ++++-- src/gui/src/SettingsDialog.cpp | 21 +++----- src/gui/src/SettingsDialog.h | 1 - src/gui/src/SettingsDialogBase.ui | 24 ++++++--- src/gui/src/Zeroconf.cpp | 14 +++++- 10 files changed, 139 insertions(+), 74 deletions(-) diff --git a/src/gui/src/BonjourWindows.cpp b/src/gui/src/BonjourWindows.cpp index 09b82281..b16a0c78 100644 --- a/src/gui/src/BonjourWindows.cpp +++ b/src/gui/src/BonjourWindows.cpp @@ -34,12 +34,16 @@ #define WIN32_LEAN_AND_MEAN #include -BonjourWindows::BonjourWindows(SettingsDialog* settingsDialog, MainWindow* mainWindow) : +BonjourWindows::BonjourWindows( + SettingsDialog* settingsDialog, + MainWindow* mainWindow, + AppConfig& appConfig) : m_pSettingsDialog(settingsDialog), m_pMainWindow(mainWindow), m_pBonjourInstall(nullptr), m_pDownloadMessageBox(nullptr), - m_pDataDownloader(nullptr) + m_pDataDownloader(nullptr), + m_appConfig(appConfig) { } @@ -58,17 +62,17 @@ BonjourWindows::~BonjourWindows() } } -void BonjourWindows::download() +void BonjourWindows::downloadAndInstall() { QUrl url; int arch = getProcessorArch(); if (arch == kProcessorArchWin32) { url.setUrl(bonjourBaseUrl + bonjourFilename32); - m_pMainWindow->appendLogInfo("downloading 32-bit bonjour"); + m_pMainWindow->appendLogInfo("downloading bonjour (32-bit)"); } else if (arch == kProcessorArchWin64) { url.setUrl(bonjourBaseUrl + bonjourFilename64); - m_pMainWindow->appendLogInfo("downloading 64-bit bonjour"); + m_pMainWindow->appendLogInfo("downloading bonjour (64-bit)"); } else { QMessageBox::critical( @@ -79,7 +83,7 @@ void BonjourWindows::download() if (m_pDataDownloader == nullptr) { m_pDataDownloader = new DataDownloader(this); - connect(m_pDataDownloader, SIGNAL(isComplete()), SLOT(installBonjour())); + connect(m_pDataDownloader, SIGNAL(isComplete()), SLOT(downloadFinished())); } m_pDataDownloader->download(url); @@ -90,7 +94,7 @@ void BonjourWindows::download() } m_pDownloadMessageBox = new QMessageBox(m_pSettingsDialog); - m_pDownloadMessageBox->setWindowTitle("Synergy"); + m_pDownloadMessageBox->setWindowTitle("Synergy Auto Config"); m_pDownloadMessageBox->setIcon(QMessageBox::Information); m_pDownloadMessageBox->setText("Installing Bonjour, please wait..."); QAbstractButton* cancel = m_pDownloadMessageBox->addButton( @@ -103,8 +107,16 @@ void BonjourWindows::download() } } +void BonjourWindows::downloadFinished() +{ + m_pMainWindow->appendLogInfo("bonjour downloaded"); + install(); +} + void BonjourWindows::install() { + m_pMainWindow->appendLogInfo("installing bonjour"); + QString tempLocation = QStandardPaths::writableLocation(QStandardPaths::TempLocation); QString filename = tempLocation; @@ -137,8 +149,7 @@ void BonjourWindows::install() m_pBonjourInstall = new CommandProcess("msiexec", arguments); QThread* thread = new QThread; - connect(m_pBonjourInstall, SIGNAL(finished()), this, - SLOT(bonjourInstallFinished())); + connect(m_pBonjourInstall, SIGNAL(finished()), this, SLOT(installFinished())); connect(m_pBonjourInstall, SIGNAL(finished()), thread, SLOT(quit())); connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater())); @@ -184,7 +195,8 @@ bool BonjourWindows::isRunning() const void BonjourWindows::installFinished() { - m_pMainWindow->appendLogInfo("bonjour install finished"); + m_pMainWindow->appendLogInfo("bonjour installed"); + m_appConfig.setAutoConfig(true); m_pSettingsDialog->allowAutoConfig(); } diff --git a/src/gui/src/BonjourWindows.h b/src/gui/src/BonjourWindows.h index 031d0f49..7c2cbe22 100644 --- a/src/gui/src/BonjourWindows.h +++ b/src/gui/src/BonjourWindows.h @@ -32,29 +32,34 @@ class SettingsDialog; class MainWindow; class CommandProcess; class DataDownloader; +class AppConfig; class BonjourWindows : public QObject { Q_OBJECT public: - BonjourWindows(SettingsDialog* settingsDialog, MainWindow* mainWindow); + BonjourWindows(SettingsDialog* settingsDialog, MainWindow* mainWindow, AppConfig& appConfig); virtual ~BonjourWindows(); public: - void download(); - void install(); + void downloadAndInstall(); bool isRunning() const; protected slots: + void downloadFinished(); void installFinished(); +private: + void install(); + private: SettingsDialog* m_pSettingsDialog; MainWindow* m_pMainWindow; CommandProcess* m_pBonjourInstall; QMessageBox* m_pDownloadMessageBox; DataDownloader* m_pDataDownloader; + AppConfig& m_appConfig; }; #endif // Q_OS_WIN diff --git a/src/gui/src/DataDownloader.cpp b/src/gui/src/DataDownloader.cpp index 4f778489..215adc8f 100644 --- a/src/gui/src/DataDownloader.cpp +++ b/src/gui/src/DataDownloader.cpp @@ -34,6 +34,7 @@ void DataDownloader::complete(QNetworkReply* reply) { m_Data = reply->readAll(); reply->deleteLater(); + m_pReply = nullptr; if (!m_Data.isEmpty()) { m_IsFinished = true; @@ -48,7 +49,9 @@ QByteArray DataDownloader::data() const void DataDownloader::cancel() { - m_pReply->abort(); + if (m_pReply != nullptr) { + m_pReply->abort(); + } } void DataDownloader::download(QUrl url) diff --git a/src/gui/src/MainWindow.cpp b/src/gui/src/MainWindow.cpp index c6a8f925..ce47b315 100644 --- a/src/gui/src/MainWindow.cpp +++ b/src/gui/src/MainWindow.cpp @@ -97,12 +97,14 @@ MainWindow::MainWindow (QSettings& settings, AppConfig& appConfig, m_pMenuWindow(NULL), m_pMenuHelp(NULL), m_pCancelButton(NULL), - m_SuppressAutoConfigWarning(false), - m_SuppressEmptyServerWarning(false), m_ExpectedRunningState(kStopped), m_pSslCertificate(NULL), m_SecureSocket(false) { +#ifndef SYNERGY_ENTERPRISE + m_pZeroconf = new Zeroconf(this); +#endif + setupUi(this); createMenuBar(); @@ -131,11 +133,6 @@ MainWindow::MainWindow (QSettings& settings, AppConfig& appConfig, setMinimumSize(size()); #endif - m_SuppressAutoConfigWarning = true; - m_pLabelAutoDetected->setVisible(appConfig.autoConfig()); - m_pComboServerList->setVisible(appConfig.autoConfig()); - m_SuppressAutoConfigWarning = false; - m_trialWidget->hide(); // hide padlock icon @@ -179,10 +176,8 @@ MainWindow::MainWindow (QSettings& settings, AppConfig& appConfig, #endif #ifndef SYNERGY_ENTERPRISE - m_pZeroconf = new Zeroconf(this); - if (m_AppConfig->autoConfig()) { - m_pZeroconf->startService(); - } + updateZeroconfService(); + updateAutoConfigWidgets(); #endif } @@ -216,9 +211,7 @@ void MainWindow::open() // auto hiding before the user has configured synergy (which of course // confuses first time users, who think synergy has crashed). if (appConfig().startedBefore() && appConfig().processMode() == Desktop) { - m_SuppressEmptyServerWarning = true; startSynergy(); - m_SuppressEmptyServerWarning = false; } } @@ -761,15 +754,13 @@ bool MainWindow::clientArgs(QStringList& args, QString& app) if (m_pLineEditHostname->text().isEmpty()) { show(); - if (!m_SuppressEmptyServerWarning) { - QMessageBox::warning(this, tr("Hostname is empty"), - tr("Please fill in a hostname for the synergy client to connect to.")); - } + QMessageBox::warning( + this, tr("Hostname is empty"), + tr("Please fill in a hostname for the synergy client to connect to.")); return false; } args << m_pLineEditHostname->text() + ":" + QString::number(appConfig().port()); - return true; } @@ -1080,8 +1071,12 @@ void MainWindow::changeEvent(QEvent* event) void MainWindow::zeroconfServerDetected(const QString name) { + // don't add yourself to the server list. + if (getIPAddresses().contains(name)) { + return; + } + if (m_pComboServerList->findText(name) == -1) { - // Note: the first added item triggers startSynergy m_pComboServerList->addItem(name); } @@ -1180,6 +1175,10 @@ MainWindow::licenseManager() const void MainWindow::on_m_pGroupClient_toggled(bool on) { m_pGroupServer->setChecked(!on); + + // only call in either client or server toggle, but not both + // since the toggle functions call eachother indirectly. + updateZeroconfService(); } void MainWindow::on_m_pGroupServer_toggled(bool on) @@ -1219,9 +1218,43 @@ void MainWindow::on_m_pActionAbout_triggered() dlg.exec(); } +void MainWindow::updateZeroconfService() +{ +#ifndef SYNERGY_ENTERPRISE + if (m_pZeroconf != nullptr) { + if (appConfig().autoConfig()) { + m_pZeroconf->startService(); + } + else { + m_pZeroconf->stopService(); + } + } +#endif +} + +void MainWindow::updateAutoConfigWidgets() +{ + if (appConfig().autoConfig()) { + m_pLabelAutoDetected->show(); + m_pComboServerList->show(); + + m_pLabelServerName->hide(); + m_pLineEditHostname->hide(); + + } + else { + m_pLabelServerName->show(); + m_pLineEditHostname->show(); + + m_pLabelAutoDetected->hide(); + m_pComboServerList->hide(); + } +} + void MainWindow::on_m_pActionSettings_triggered() { ProcessMode lastProcessMode = appConfig().processMode(); + bool lastAutoConfig = appConfig().autoConfig(); SettingsDialog dlg(this, appConfig()); dlg.exec(); @@ -1230,6 +1263,11 @@ void MainWindow::on_m_pActionSettings_triggered() { onModeChanged(true, true); } + + if (lastAutoConfig != appConfig().autoConfig()) { + updateAutoConfigWidgets(); + updateZeroconfService(); + } } void MainWindow::autoAddScreen(const QString name) @@ -1292,13 +1330,6 @@ void MainWindow::on_m_pButtonApply_clicked() restartSynergy(); } -void MainWindow::on_m_pComboServerList_currentIndexChanged(const QString &arg1) -{ - if (m_pComboServerList->count() != 0) { - restartSynergy(); - } -} - #ifndef SYNERGY_ENTERPRISE int MainWindow::raiseActivationDialog() { diff --git a/src/gui/src/MainWindow.h b/src/gui/src/MainWindow.h index 84c1096c..4f881073 100644 --- a/src/gui/src/MainWindow.h +++ b/src/gui/src/MainWindow.h @@ -125,6 +125,8 @@ class MainWindow : public QMainWindow, public Ui::MainWindowBase int raiseActivationDialog(); #endif + void updateZeroconfService(); + public slots: void setEdition(Edition edition); #ifndef SYNERGY_ENTERPRISE @@ -224,19 +226,17 @@ public slots: QMenu* m_pMenuWindow; QMenu* m_pMenuHelp; QAbstractButton* m_pCancelButton; - bool m_SuppressAutoConfigWarning; - bool m_SuppressEmptyServerWarning; qRuningState m_ExpectedRunningState; QMutex m_StopDesktopMutex; SslCertificate* m_pSslCertificate; bool m_SecureSocket; + void updateAutoConfigWidgets(); + private slots: void on_m_pButtonApply_clicked(); void on_windowShown(); - void on_m_pComboServerList_currentIndexChanged(const QString &arg1); - signals: void windowShown(); }; diff --git a/src/gui/src/MainWindowBase.ui b/src/gui/src/MainWindowBase.ui index 429dfcd2..b4f6bb1c 100644 --- a/src/gui/src/MainWindowBase.ui +++ b/src/gui/src/MainWindowBase.ui @@ -289,9 +289,9 @@ QFormLayout::AllNonFixedFieldsGrow - + - Screen name: + Client name: @@ -305,7 +305,7 @@ - &Server IP: + &Server: m_pLineEditHostname @@ -313,7 +313,11 @@ - + + + Hostname or IP address of the server computer. + + @@ -334,7 +338,7 @@ - Auto detected: + Server: diff --git a/src/gui/src/SettingsDialog.cpp b/src/gui/src/SettingsDialog.cpp index 5ca61c3c..50f3ab23 100644 --- a/src/gui/src/SettingsDialog.cpp +++ b/src/gui/src/SettingsDialog.cpp @@ -59,10 +59,9 @@ SettingsDialog::SettingsDialog(QWidget* parent, AppConfig& config) : m_pCheckBoxAutoHide->setChecked(appConfig().getAutoHide()); #if defined(Q_OS_WIN) - m_pBonjourWindows = new BonjourWindows(this, m_pMainWindow); + m_pBonjourWindows = new BonjourWindows(this, m_pMainWindow, m_appConfig); if (m_pBonjourWindows->isRunning()) { allowAutoConfig(); - m_pCheckBoxAutoConfig->setChecked(m_appConfig.autoConfig()); } m_pComboElevate->setCurrentIndex(static_cast(appConfig().elevateMode())); @@ -93,6 +92,8 @@ SettingsDialog::SettingsDialog(QWidget* parent, AppConfig& config) : m_pCheckBoxEnableCrypto->setEnabled(isPro); m_pLabelProUpgrade->setVisible(!isPro); + m_pCheckBoxAutoConfig->setChecked(appConfig().autoConfig()); + #endif } @@ -107,6 +108,7 @@ void SettingsDialog::accept() appConfig().setLanguage(m_pComboLanguage->itemData(m_pComboLanguage->currentIndex()).toString()); appConfig().setElevateMode(static_cast(m_pComboElevate->currentIndex())); appConfig().setAutoHide(m_pCheckBoxAutoHide->isChecked()); + appConfig().setAutoConfig(m_pCheckBoxAutoConfig->isChecked()); appConfig().saveSettings(); QDialog::accept(); } @@ -148,6 +150,7 @@ void SettingsDialog::allowAutoConfig() { m_pLabelInstallBonjour->hide(); m_pCheckBoxAutoConfig->setEnabled(true); + m_pCheckBoxAutoConfig->setChecked(m_appConfig.autoConfig()); } void SettingsDialog::on_m_pCheckBoxLogToFile_stateChanged(int i) @@ -191,18 +194,6 @@ void SettingsDialog::on_m_pCheckBoxEnableCrypto_toggled(bool checked) void SettingsDialog::on_m_pLabelInstallBonjour_linkActivated(const QString&) { #if defined(Q_OS_WIN) - m_pBonjourWindows->download(); -#endif -} - -void SettingsDialog::on_m_pCheckBoxAutoConfig_toggled(bool checked) -{ -#ifndef SYNERGY_ENTERPRISE - if (checked) { - m_pMainWindow->zeroconf().startService(); - } - else { - m_pMainWindow->zeroconf().stopService(); - } + m_pBonjourWindows->downloadAndInstall(); #endif } diff --git a/src/gui/src/SettingsDialog.h b/src/gui/src/SettingsDialog.h index 5a524596..738bb457 100644 --- a/src/gui/src/SettingsDialog.h +++ b/src/gui/src/SettingsDialog.h @@ -58,7 +58,6 @@ class SettingsDialog : public QDialog, public Ui::SettingsDialogBase void on_m_pCheckBoxLogToFile_stateChanged(int ); void on_m_pButtonBrowseLog_clicked(); void on_m_pLabelInstallBonjour_linkActivated(const QString &link); - void on_m_pCheckBoxAutoConfig_toggled(bool checked); }; #endif diff --git a/src/gui/src/SettingsDialogBase.ui b/src/gui/src/SettingsDialogBase.ui index a1d446a1..b85417c2 100644 --- a/src/gui/src/SettingsDialogBase.ui +++ b/src/gui/src/SettingsDialogBase.ui @@ -2,6 +2,14 @@ SettingsDialogBase + + + 0 + 0 + 357 + 496 + + Settings @@ -154,12 +162,12 @@ Qt::Vertical - QSizePolicy::MinimumExpanding + QSizePolicy::Minimum 20 - 15 + 10 @@ -230,9 +238,6 @@ Qt::RichText - - true - @@ -243,6 +248,9 @@ Qt::RichText + + true + @@ -256,12 +264,12 @@ Qt::Vertical - QSizePolicy::MinimumExpanding + QSizePolicy::Minimum 20 - 15 + 10 @@ -362,7 +370,7 @@ 20 - 15 + 10 diff --git a/src/gui/src/Zeroconf.cpp b/src/gui/src/Zeroconf.cpp index 65eb81f7..b2a0e6b7 100644 --- a/src/gui/src/Zeroconf.cpp +++ b/src/gui/src/Zeroconf.cpp @@ -33,14 +33,26 @@ Zeroconf::~Zeroconf() void Zeroconf::startService() { - stopService(); + if (m_pZeroconfService != nullptr) { + m_pMainWindow->appendLogInfo("restarting zeroconf service"); + delete m_pZeroconfService; + m_pZeroconfService = nullptr; + } + else { + m_pMainWindow->appendLogInfo("starting zeroconf service"); + } + m_pZeroconfService = new ZeroconfService(m_pMainWindow); + + m_pMainWindow->appendLogInfo("started zeroconf service"); } void Zeroconf::stopService() { if (m_pZeroconfService != nullptr) { + m_pMainWindow->appendLogInfo("stopping zeroconf service"); delete m_pZeroconfService; m_pZeroconfService = nullptr; + m_pMainWindow->appendLogInfo("stopped zeroconf service"); } } From aad0ac25d19a8cff8dbcae31857d38529e21a7c9 Mon Sep 17 00:00:00 2001 From: Nick Bolton Date: Wed, 8 Aug 2018 15:13:22 +0100 Subject: [PATCH 08/10] #6338 Only add server IPs when in client mode, and clear the IP list each time zeroconf restarts --- src/gui/src/MainWindow.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/gui/src/MainWindow.cpp b/src/gui/src/MainWindow.cpp index ce47b315..1dcbd632 100644 --- a/src/gui/src/MainWindow.cpp +++ b/src/gui/src/MainWindow.cpp @@ -1071,6 +1071,11 @@ void MainWindow::changeEvent(QEvent* event) void MainWindow::zeroconfServerDetected(const QString name) { + // don't add to the server combo box if not in client mode. + if (synergyType() != synergyClient) { + return; + } + // don't add yourself to the server list. if (getIPAddresses().contains(name)) { return; @@ -1221,6 +1226,11 @@ void MainWindow::on_m_pActionAbout_triggered() void MainWindow::updateZeroconfService() { #ifndef SYNERGY_ENTERPRISE + + // reset the server list in case one has gone away. + // it'll be re-added after the zeroconf service restarts. + m_pComboServerList->clear(); + if (m_pZeroconf != nullptr) { if (appConfig().autoConfig()) { m_pZeroconf->startService(); From 934824433db7e6606571dd521be57c134d41b653 Mon Sep 17 00:00:00 2001 From: Nick Bolton Date: Wed, 8 Aug 2018 16:47:45 +0100 Subject: [PATCH 09/10] #6338 Auto Config hint widget with link to open Settings dialog --- src/gui/res/Synergy.qrc | 1 + src/gui/res/icons/16x16/auto-config.png | Bin 0 -> 610 bytes src/gui/src/MainWindow.cpp | 8 ++ src/gui/src/MainWindow.h | 2 + src/gui/src/MainWindowBase.ui | 93 +++++++++++++++++++++++- 5 files changed, 101 insertions(+), 3 deletions(-) create mode 100644 src/gui/res/icons/16x16/auto-config.png diff --git a/src/gui/res/Synergy.qrc b/src/gui/res/Synergy.qrc index 8f8ac0c8..479b7a05 100644 --- a/src/gui/res/Synergy.qrc +++ b/src/gui/res/Synergy.qrc @@ -54,5 +54,6 @@ image/spinning-wheel.gif icons/16x16/padlock.png icons/16x16/synergy-transfering.png + icons/16x16/auto-config.png diff --git a/src/gui/res/icons/16x16/auto-config.png b/src/gui/res/icons/16x16/auto-config.png new file mode 100644 index 0000000000000000000000000000000000000000..88484f432f2e726ea84c16d4fcb3b393e2b815f0 GIT binary patch literal 610 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!60wlNoGJgf6SkfJR9T^xl_H+M9WCijSl0AZa z85pY67#JE_7#My5g&JNkFq9fFFuY1&V6d9Oz#v{QXIG#NP=YDR+uenMVO6iP5s=4O z;1O92wCOqsGdgL^t^f+Mmw5WRvOnVB5M&q7?X!8zz`$tW>EaloaXxo~y*IO?z|s5X zF(R7RcBp4TfM(>^BM+*1GmJ>J60Ah=g`f*T|M#qy{3o#uexUa_%!K7#)5Bm zKecJN{?l;#z&P!&;({cFEmvo-X(+1S(KNit>LYDDQKgsb&%~|A)E`;Rvn~3Xm7lZj zv*J>VUm;v`q*Q{P$vdAN*DN9x?^ocrDJn>E4W7rN%w6Zt;Ja`fjG?OgO{t z2@Fov64!{5l*E!$tK_0oAjM#0U}&Lh074;#=2iygR)%KU21Zr}2K%Ca)uL#~%}>cp ztHiD0Je$)&paw~h4Z-BuF?hQAxvXhide(); m_pLineEditHostname->hide(); + m_pWidgetAutoConfig->hide(); } else { m_pLabelServerName->show(); @@ -1258,6 +1259,8 @@ void MainWindow::updateAutoConfigWidgets() m_pLabelAutoDetected->hide(); m_pComboServerList->hide(); + + m_pWidgetAutoConfig->show(); } } @@ -1403,3 +1406,8 @@ void MainWindow::secureSocket(bool secureSocket) m_pLabelPadlock->hide(); } } + +void MainWindow::on_m_pLabelAutoConfig_linkActivated(const QString &) +{ + m_pActionSettings->trigger(); +} diff --git a/src/gui/src/MainWindow.h b/src/gui/src/MainWindow.h index 4f881073..e267ccf2 100644 --- a/src/gui/src/MainWindow.h +++ b/src/gui/src/MainWindow.h @@ -237,6 +237,8 @@ private slots: void on_m_pButtonApply_clicked(); void on_windowShown(); + void on_m_pLabelAutoConfig_linkActivated(const QString &link); + signals: void windowShown(); }; diff --git a/src/gui/src/MainWindowBase.ui b/src/gui/src/MainWindowBase.ui index b4f6bb1c..42f44dd6 100644 --- a/src/gui/src/MainWindowBase.ui +++ b/src/gui/src/MainWindowBase.ui @@ -129,6 +129,81 @@ + + + + + 0 + 28 + + + + + 2 + + + 0 + + + 0 + + + 8 + + + + + + 0 + 0 + + + + + 16 + 20 + + + + + 244 + 16777215 + + + + + + + :/res/icons/16x16/auto-config.png + + + + + + + <html><head/><body><p>Manual Config mode active, consider using Auto Config instead (<a href="#"><span style=" text-decoration: underline; color:#007af4;">Settings</span></a>)</p></body></html> + + + Qt::RichText + + + + + + + Qt::Horizontal + + + + 200 + 0 + + + + + + + @@ -314,12 +389,24 @@ + + + 0 + 0 + + + + + 200 + 0 + + Hostname or IP address of the server computer. - + @@ -329,13 +416,13 @@ - 120 + 200 0 - + Server: From 4cf1ab8a25ba67fbd0f2d0a3c8f18ea6c2f38f66 Mon Sep 17 00:00:00 2001 From: Nick Bolton Date: Wed, 8 Aug 2018 17:20:16 +0100 Subject: [PATCH 10/10] #6338 Refactor auto restart logic, fixed debug level check, added some debug logging --- src/gui/src/MainWindow.cpp | 59 ++++++++++++++++++------------------ src/gui/src/ServerConfig.cpp | 2 +- 2 files changed, 30 insertions(+), 31 deletions(-) diff --git a/src/gui/src/MainWindow.cpp b/src/gui/src/MainWindow.cpp index 53719220..624d71ba 100644 --- a/src/gui/src/MainWindow.cpp +++ b/src/gui/src/MainWindow.cpp @@ -62,6 +62,8 @@ static const QString synergyConfigFilter(QObject::tr("Synergy Configurations (*. static const char* tlsVersion = "TLS 1.2"; static const char* tlsCheckString = "network encryption protocol: TLSv1.2"; +static const int debugLogLevel = 1; + static const char* synergyIconFiles[] = { ":/res/icons/16x16/synergy-disconnected.png", @@ -408,7 +410,7 @@ void MainWindow::appendLogInfo(const QString& text) } void MainWindow::appendLogDebug(const QString& text) { - if (appConfig().logLevel() >= 4) { + if (appConfig().logLevel() >= debugLogLevel) { appendLogRaw(getTimeStamp() + " DEBUG: " + text); } } @@ -1285,36 +1287,36 @@ void MainWindow::on_m_pActionSettings_triggered() void MainWindow::autoAddScreen(const QString name) { - if (!m_ServerConfig.ignoreAutoConfigClient()) { + if (m_ServerConfig.ignoreAutoConfigClient()) { + appendLogDebug(QString("ignoring zeroconf screen: %1").arg(name)); + return; + } + #ifndef SYNERGY_ENTERPRISE - 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; - } + 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; + } #endif - int r = m_ServerConfig.autoAddScreen(name); - if (r != kAutoAddScreenOk) { - switch (r) { - case kAutoAddScreenManualServer: - showConfigureServer( - tr("Please add the server (%1) to the grid.") - .arg(appConfig().screenName())); - break; + int r = m_ServerConfig.autoAddScreen(name); + if (r != kAutoAddScreenOk) { + switch (r) { + case kAutoAddScreenManualServer: + showConfigureServer( + tr("Please add the server (%1) to the grid.") + .arg(appConfig().screenName())); + break; - case kAutoAddScreenManualClient: - showConfigureServer( - tr("Please drag the new client screen (%1) " - "to the desired position on the grid.") - .arg(name)); - break; - } - } - else { - restartSynergy(); + case kAutoAddScreenManualClient: + showConfigureServer( + tr("Please drag the new client screen (%1) " + "to the desired position on the grid.") + .arg(name)); + break; } } } @@ -1362,9 +1364,6 @@ int MainWindow::raiseActivationDialog() m_PendingClientNames.clear(); } - if (result == QDialog::Accepted) { - restartSynergy(); - } return result; } #endif diff --git a/src/gui/src/ServerConfig.cpp b/src/gui/src/ServerConfig.cpp index bddb1444..fd821e5a 100644 --- a/src/gui/src/ServerConfig.cpp +++ b/src/gui/src/ServerConfig.cpp @@ -303,7 +303,7 @@ int ServerConfig::autoAddScreen(const QString name) } } if (findScreenName(name, targetIndex)) { - // already exists. + m_pMainWindow->appendLogDebug(QString("ignoring screen already in config: %1").arg(name)); return kAutoAddScreenIgnore; }