From 79f8fbc5d9a7df3f76701f69bf81db8bfc9239ec Mon Sep 17 00:00:00 2001 From: Serhii Hadzhilov Date: Thu, 13 May 2021 14:44:28 +0300 Subject: [PATCH 1/3] SYNERGY-694 Handle client name duplication --- src/gui/src/ClientConnection.cpp | 29 ++++++++++++++++++----------- src/gui/src/ClientConnection.h | 4 ++-- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/gui/src/ClientConnection.cpp b/src/gui/src/ClientConnection.cpp index e7e487760..530520645 100644 --- a/src/gui/src/ClientConnection.cpp +++ b/src/gui/src/ClientConnection.cpp @@ -37,7 +37,7 @@ void ClientConnection::update(const QString& line) m_checkConnection = false; if (!line.contains("server refused client with our name")) { - showMessage(); + showMessage(getMessage(line)); } } else if (line.contains("connected to server")) @@ -61,26 +61,33 @@ bool ClientConnection::checkMainWindow() return result; } -QString ClientConnection::getMessage() const +QString ClientConnection::getMessage(const QString& line) 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()) + if (line.contains("server already has a connected client with our name")) { - 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()); + message = QObject::tr("Connection failed.\nYou can’t name 2 computers the same"); + } + else + { + 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; } -void ClientConnection::showMessage() +void ClientConnection::showMessage(const QString& message) const { - QMessageBox message(&m_parent); - message.addButton(QObject::tr("Close"), QMessageBox::RejectRole); - message.setText(getMessage()); - message.exec(); + QMessageBox dialog(&m_parent); + dialog.addButton(QObject::tr("Close"), QMessageBox::RejectRole); + dialog.setText(message); + dialog.exec(); } void ClientConnection::setCheckConnection(bool checkConnection) diff --git a/src/gui/src/ClientConnection.h b/src/gui/src/ClientConnection.h index 1a2ec6252..abe5ba3a1 100644 --- a/src/gui/src/ClientConnection.h +++ b/src/gui/src/ClientConnection.h @@ -34,9 +34,9 @@ public: void setCheckConnection(bool checkConnection); private: - QString getMessage() const; + QString getMessage(const QString& line) const; bool checkMainWindow(); - void showMessage(); + void showMessage(const QString& message) const; }; #endif // CLIENTCONNECTION_H From 07edadc2e340cada85abeb33e900b5863de723a4 Mon Sep 17 00:00:00 2001 From: Serhii Hadzhilov Date: Thu, 13 May 2021 16:20:54 +0300 Subject: [PATCH 2/3] SYNERGY-694 Reduce connection timeout to 2 seconds --- src/lib/client/Client.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/client/Client.cpp b/src/lib/client/Client.cpp index 0f287125f..f4385ae04 100644 --- a/src/lib/client/Client.cpp +++ b/src/lib/client/Client.cpp @@ -534,7 +534,7 @@ Client::setupTimer() { assert(m_timer == NULL); - m_timer = m_events->newOneShotTimer(15.0, NULL); + m_timer = m_events->newOneShotTimer(2.0, NULL); m_events->adoptHandler(Event::kTimer, m_timer, new TMethodEventJob(this, &Client::handleConnectTimeout)); From f16750d7774d2d4d05d42354bd5ea57af7b76e6a Mon Sep 17 00:00:00 2001 From: Serhii Hadzhilov Date: Thu, 13 May 2021 17:33:15 +0300 Subject: [PATCH 3/3] Update ChangeLog --- ChangeLog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 67cfd0cdd..33c8ac1aa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -23,7 +23,7 @@ Enhancements: - #6973 Update synergy UI. Main window - #6977 Update synergy UI. Configure server - #6978 Update synergy UI. Settings window -- #6981 | #6987 | #6988 Update synergy UI. Setup client configuration +- #6981 | #6987 | #6988 | #6996 Update synergy UI. Setup client configuration - #6984 Update synergy UI. Client error messages - #6962 | #6965 Add macOS 10.13 builder - #6990 Change VersionChecker URL and include system language in the header