This commit is contained in:
Nick Bolton 2015-04-20 16:53:34 +01:00
commit 2a2d095527
9 changed files with 40 additions and 54 deletions

View File

@ -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)

View File

@ -42,7 +42,7 @@ public slots:
void generateCertificate();
private:
void savePlugin();
bool savePlugin();
QString getPluginUrl(const QString& pluginName);
bool checkOpenSslBinary();
bool runProgram(

View File

@ -95,6 +95,7 @@ REGISTER_EVENT(IListenSocket, connecting)
//
REGISTER_EVENT(ISocket, disconnected)
REGISTER_EVENT(ISocket, stopRetry)
//
// OSXScreen

View File

@ -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 {

View File

@ -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<Client>(this,
&Client::handleDisconnected));
m_events->adoptHandler(m_events->forISocket().stopRetry(),
m_stream->getEventTarget(),
new TMethodEventJob<Client>(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*)

View File

@ -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;
};

View File

@ -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();
}
}

View File

@ -331,7 +331,6 @@ ClientApp::handleClientDisconnected(const Event&, void*)
updateStatus();
}
Client*
ClientApp::openClient(const String& name, const NetworkAddress& address,
synergy::Screen* screen)

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#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*));
};