From 9e4c1149491495cc61aef1135fbe50706a256fd0 Mon Sep 17 00:00:00 2001 From: Serhii Hadzhilov Date: Thu, 22 Apr 2021 17:00:42 +0300 Subject: [PATCH 1/2] SYNERGY-799 Client connection errors --- src/gui/src/ClientConnection.cpp | 57 ++++++++++++++++++++++++++++++++ src/gui/src/ClientConnection.h | 38 +++++++++++++++++++++ src/gui/src/MainWindow.cpp | 4 ++- src/gui/src/MainWindow.h | 3 ++ 4 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 src/gui/src/ClientConnection.cpp create mode 100644 src/gui/src/ClientConnection.h diff --git a/src/gui/src/ClientConnection.cpp b/src/gui/src/ClientConnection.cpp new file mode 100644 index 0000000000..c28a8eeec4 --- /dev/null +++ b/src/gui/src/ClientConnection.cpp @@ -0,0 +1,57 @@ +/* + * synergy -- mouse and keyboard sharing utility + * Copyright (C) 2012-2021 Symless Ltd. + * Copyright (C) 2008 Volker Lanz (vl@fidra.de) + * + * 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 "ClientConnection.h" + +#include "MainWindow.h" + +#include +#include + +ClientConnection::ClientConnection(MainWindow& parent) : + m_parent(parent) +{ +} + +void ClientConnection::update(const QString& line) const +{ + if (m_parent.isActiveWindow() && + line.contains("failed to connect to server") ) + { + m_parent.stopSynergy(); + + QMessageBox message(&m_parent); + message.addButton(QObject::tr("Close"), QMessageBox::RejectRole); + message.setText(getMessage()); + message.exec(); + } +} + +QString ClientConnection::getMessage() const +{ + QString message(QObject::tr("We can’t connect to the server IP address.\nCheck your IP on your server and your firewall settings.")); + + QHostAddress address(m_parent.appConfig().getServerHostname()); + if (address.isNull()) + { + message = QObject::tr("We can’t connect to the server \"%1\" try to connect using the server IP address and check your firewall settings.") + .arg(m_parent.appConfig().getServerHostname()); + } + + return message; +} diff --git a/src/gui/src/ClientConnection.h b/src/gui/src/ClientConnection.h new file mode 100644 index 0000000000..72ea28d087 --- /dev/null +++ b/src/gui/src/ClientConnection.h @@ -0,0 +1,38 @@ +/* + * synergy -- mouse and keyboard sharing utility + * Copyright (C) 2012-2021 Symless Ltd. + * Copyright (C) 2008 Volker Lanz (vl@fidra.de) + * + * This package is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * found in the file LICENSE that should have accompanied this file. + * + * This package is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef CLIENTCONNECTION_H +#define CLIENTCONNECTION_H + +#include + +class MainWindow; + +class ClientConnection +{ + MainWindow& m_parent; + +public: + explicit ClientConnection(MainWindow& parent); + void update(const QString& line) const; + +private: + QString getMessage() const; +}; + +#endif // CLIENTCONNECTION_H diff --git a/src/gui/src/MainWindow.cpp b/src/gui/src/MainWindow.cpp index 423ae21141..f02ca2462a 100644 --- a/src/gui/src/MainWindow.cpp +++ b/src/gui/src/MainWindow.cpp @@ -113,7 +113,8 @@ MainWindow::MainWindow (AppConfig& appConfig, m_pCancelButton(NULL), m_ExpectedRunningState(kStopped), m_SecureSocket(false), - m_serverConnection(*this) + m_serverConnection(*this), + m_clientConnection(*this) { #if !defined(SYNERGY_ENTERPRISE) && defined(SYNERGY_AUTOCONFIG) m_pZeroconf = new Zeroconf(this); @@ -456,6 +457,7 @@ void MainWindow::checkConnected(const QString& line) } else { + m_clientConnection.update(line); m_pLabelClientState->updateClientState(line); } diff --git a/src/gui/src/MainWindow.h b/src/gui/src/MainWindow.h index 18e11416f2..d3a444eec8 100644 --- a/src/gui/src/MainWindow.h +++ b/src/gui/src/MainWindow.h @@ -29,6 +29,7 @@ #include "ServerConfig.h" #include "ServerConnection.h" +#include "ClientConnection.h" #include "AppConfig.h" #include "VersionChecker.h" #include "IpcClient.h" @@ -69,6 +70,7 @@ class MainWindow : public QMainWindow, public Ui::MainWindowBase friend class ActivationDialog; friend class SettingsDialog; friend class ServerConnection; + friend class ClientConnection; public: enum qSynergyState @@ -241,6 +243,7 @@ public slots: bool m_SecureSocket; // brief Is the program running a secure socket protocol (SSL/TLS) QString m_SecureSocketVersion; // brief Contains the version of the Secure Socket currently active ServerConnection m_serverConnection; + ClientConnection m_clientConnection; void updateAutoConfigWidgets(); From fa2ad60a5ba571e4b313e9e472951507d309e72a Mon Sep 17 00:00:00 2001 From: Serhii Hadzhilov Date: Thu, 22 Apr 2021 17:59:01 +0300 Subject: [PATCH 2/2] SYNERGY-799 Show message even if parent is hidden or minimized --- ChangeLog | 1 + src/gui/src/ClientConnection.cpp | 20 +++++++++++++++++--- src/gui/src/ClientConnection.h | 3 ++- src/gui/src/ServerConnection.cpp | 5 ++++- 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7bd5edc964..5ce6afcf72 100644 --- a/ChangeLog +++ b/ChangeLog @@ -19,6 +19,7 @@ Enhancements: - #6977 Update synergy UI. Configure server - #6978 Update synergy UI. Settings window - #6981 Update synergy UI. Setup client configuration +- #6984 Update synergy UI. Client error messages - #6962 | #6965 Add macOS 10.13 builder =========== diff --git a/src/gui/src/ClientConnection.cpp b/src/gui/src/ClientConnection.cpp index c28a8eeec4..71207a5c44 100644 --- a/src/gui/src/ClientConnection.cpp +++ b/src/gui/src/ClientConnection.cpp @@ -28,10 +28,10 @@ ClientConnection::ClientConnection(MainWindow& parent) : { } -void ClientConnection::update(const QString& line) const +void ClientConnection::update(const QString& line) { - if (m_parent.isActiveWindow() && - line.contains("failed to connect to server") ) + if (line.contains("failed to connect to server") && + checkMainWindow()) { m_parent.stopSynergy(); @@ -42,6 +42,20 @@ void ClientConnection::update(const QString& line) const } } +bool ClientConnection::checkMainWindow() +{ + bool result = m_parent.isActiveWindow(); + + if (m_parent.isMinimized() || m_parent.isHidden()) + { + m_parent.showNormal(); + m_parent.activateWindow(); + result = true; + } + + return result; +} + QString ClientConnection::getMessage() const { QString message(QObject::tr("We can’t connect to the server IP address.\nCheck your IP on your server and your firewall settings.")); diff --git a/src/gui/src/ClientConnection.h b/src/gui/src/ClientConnection.h index 72ea28d087..0d52e95a7d 100644 --- a/src/gui/src/ClientConnection.h +++ b/src/gui/src/ClientConnection.h @@ -29,10 +29,11 @@ class ClientConnection public: explicit ClientConnection(MainWindow& parent); - void update(const QString& line) const; + void update(const QString& line); private: QString getMessage() const; + bool checkMainWindow(); }; #endif // CLIENTCONNECTION_H diff --git a/src/gui/src/ServerConnection.cpp b/src/gui/src/ServerConnection.cpp index 03a2a9d0bb..fba9b62c44 100644 --- a/src/gui/src/ServerConnection.cpp +++ b/src/gui/src/ServerConnection.cpp @@ -45,13 +45,16 @@ void ServerConnection::update(const QString& line) bool ServerConnection::checkMainWindow() { + bool result = m_parent.isActiveWindow(); + if (m_parent.isMinimized() || m_parent.isHidden()) { m_parent.showNormal(); m_parent.activateWindow(); + result = true; } - return m_parent.isActiveWindow(); + return result; } void ServerConnection::addClient(const QString& clientName)