diff --git a/src/gui/src/PluginManager.cpp b/src/gui/src/PluginManager.cpp index f3883be7..b32f982c 100644 --- a/src/gui/src/PluginManager.cpp +++ b/src/gui/src/PluginManager.cpp @@ -94,7 +94,10 @@ bool PluginManager::exist(QString name) void PluginManager::downloadPlugins() { if (m_DataDownloader.isFinished()) { - savePlugin(); + if (!savePlugin()) { + return; + } + if (m_DownloadIndex != m_PluginList.size() - 1) { emit downloadNext(); } @@ -218,7 +221,7 @@ void PluginManager::generateCertificate() emit generateCertificateFinished(); } -void PluginManager::savePlugin() +bool PluginManager::savePlugin() { // create the path if not exist QDir dir(m_PluginDir); @@ -234,15 +237,19 @@ void PluginManager::savePlugin() QFile file(filename); if (!file.open(QIODevice::WriteOnly)) { emit error( - tr("Failed to download '%1' plugin to: %2") + tr("Failed to download plugin '%1' to: %2 \n %3") .arg(m_PluginList.at(m_DownloadIndex)) - .arg(m_PluginDir)); + .arg(m_PluginDir) + .arg(file.errorString())); - return; + file.close(); + return false; } file.write(m_DataDownloader.data()); file.close(); + + return true; } QString PluginManager::getPluginUrl(const QString& pluginName) diff --git a/src/gui/src/PluginManager.h b/src/gui/src/PluginManager.h index b9bdfea4..bd7fea00 100644 --- a/src/gui/src/PluginManager.h +++ b/src/gui/src/PluginManager.h @@ -42,7 +42,7 @@ public slots: void generateCertificate(); private: - void savePlugin(); + bool savePlugin(); QString getPluginUrl(const QString& pluginName); bool checkOpenSslBinary(); bool runProgram( diff --git a/src/lib/base/EventTypes.cpp b/src/lib/base/EventTypes.cpp index 5ef90e8d..d317e1d7 100644 --- a/src/lib/base/EventTypes.cpp +++ b/src/lib/base/EventTypes.cpp @@ -95,6 +95,7 @@ REGISTER_EVENT(IListenSocket, connecting) // REGISTER_EVENT(ISocket, disconnected) +REGISTER_EVENT(ISocket, stopRetry) // // OSXScreen diff --git a/src/lib/base/EventTypes.h b/src/lib/base/EventTypes.h index dc605f21..74bbed63 100644 --- a/src/lib/base/EventTypes.h +++ b/src/lib/base/EventTypes.h @@ -281,7 +281,8 @@ private: class ISocketEvents : public EventTypes { public: ISocketEvents() : - m_disconnected(Event::kUnknown) { } + m_disconnected(Event::kUnknown), + m_stopRetry(Event::kUnknown) { } //! @name accessors //@{ @@ -294,10 +295,18 @@ public: */ Event::Type disconnected(); + //! Get stop retry event type + /*! + Returns the stop retry event type. This is sent when the client + doesn't want to reconnect after it disconnects from the server. + */ + Event::Type stopRetry(); + //@} private: Event::Type m_disconnected; + Event::Type m_stopRetry; }; class OSXScreenEvents : public EventTypes { diff --git a/src/lib/client/Client.cpp b/src/lib/client/Client.cpp index 9c7d785d..3e59c942 100644 --- a/src/lib/client/Client.cpp +++ b/src/lib/client/Client.cpp @@ -60,7 +60,7 @@ Client::Client( const String& name, const NetworkAddress& address, ISocketFactory* socketFactory, synergy::Screen* screen, - ClientArgs args) : + ClientArgs& args) : m_mock(false), m_name(name), m_serverAddress(address), @@ -470,6 +470,10 @@ Client::setupConnection() m_stream->getEventTarget(), new TMethodEventJob(this, &Client::handleDisconnected)); + + m_events->adoptHandler(m_events->forISocket().stopRetry(), + m_stream->getEventTarget(), + new TMethodEventJob(this, &Client::handleStopRetry)); } void @@ -525,6 +529,8 @@ Client::cleanupConnection() m_stream->getEventTarget()); m_events->removeHandler(m_events->forISocket().disconnected(), m_stream->getEventTarget()); + m_events->removeHandler(m_events->forISocket().stopRetry(), + m_stream->getEventTarget()); cleanupStream(); } } @@ -743,6 +749,11 @@ Client::onFileRecieveCompleted() } } +void +Client::handleStopRetry(const Event&, void*) +{ + m_args.m_restartable = false; +} void Client::writeToDropDirThread(void*) diff --git a/src/lib/client/Client.h b/src/lib/client/Client.h index e50b567b..9245a825 100644 --- a/src/lib/client/Client.h +++ b/src/lib/client/Client.h @@ -60,12 +60,8 @@ public: const String& name, const NetworkAddress& address, ISocketFactory* socketFactory, synergy::Screen* screen, - ClientArgs args); + ClientArgs& args); ~Client(); - -#ifdef TEST_ENV - Client() : m_mock(true) { } -#endif //! @name manipulators //@{ @@ -196,6 +192,7 @@ private: void handleResume(const Event& event, void*); void handleFileChunkSending(const Event&, void*); void handleFileRecieveCompleted(const Event&, void*); + void handleStopRetry(const Event&, void*); void onFileRecieveCompleted(); public: @@ -226,5 +223,5 @@ private: Thread* m_writeToDropDirThread; TCPSocket* m_socket; bool m_useSecureNetwork; - ClientArgs m_args; + ClientArgs& m_args; }; diff --git a/src/lib/plugin/ns/SecureSocket.cpp b/src/lib/plugin/ns/SecureSocket.cpp index c878871d..ccc3ec01 100644 --- a/src/lib/plugin/ns/SecureSocket.cpp +++ b/src/lib/plugin/ns/SecureSocket.cpp @@ -281,10 +281,8 @@ SecureSocket::secureConnect(int socket) checkResult(r, fatal, retry); if (fatal) { - // tell user and sleep so the socket isn't hammered. LOG((CLOG_ERR "failed to connect secure socket")); LOG((CLOG_INFO "server connection may not be secure")); - disconnect(); return false; } @@ -299,6 +297,7 @@ SecureSocket::secureConnect(int socket) } else { LOG((CLOG_ERR "failed to verify server certificate fingerprint")); + sendEvent(getEvents()->forISocket().stopRetry()); disconnect(); } } diff --git a/src/lib/synergy/ClientApp.cpp b/src/lib/synergy/ClientApp.cpp index f27a8331..dd262a93 100644 --- a/src/lib/synergy/ClientApp.cpp +++ b/src/lib/synergy/ClientApp.cpp @@ -331,7 +331,6 @@ ClientApp::handleClientDisconnected(const Event&, void*) updateStatus(); } - Client* ClientApp::openClient(const String& name, const NetworkAddress& address, synergy::Screen* screen) diff --git a/src/test/mock/client/MockClient.h b/src/test/mock/client/MockClient.h deleted file mode 100644 index 427c9fe6..00000000 --- a/src/test/mock/client/MockClient.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * synergy -- mouse and keyboard sharing utility - * Copyright (C) 2012 Synergy Si Ltd. - * Copyright (C) 2011 Nick Bolton - * - * 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 COPYING 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 - -#define TEST_ENV - -#include "client/Client.h" - -#include "test/global/gmock.h" - -class IEventQueue; - -class MockClient : public Client -{ -public: - MockClient() : Client() { } - MOCK_METHOD2(mouseMove, void(SInt32, SInt32)); - MOCK_METHOD1(setOptions, void(const OptionsList&)); - MOCK_METHOD0(handshakeComplete, void()); - MOCK_METHOD1(setDecryptIv, void(const UInt8*)); -};