Added file events #4584
This commit is contained in:
parent
7795d68c21
commit
0680c33909
|
@ -47,6 +47,7 @@ EVENT_TYPE_ACCESSOR(IKeyState)
|
||||||
EVENT_TYPE_ACCESSOR(IPrimaryScreen)
|
EVENT_TYPE_ACCESSOR(IPrimaryScreen)
|
||||||
EVENT_TYPE_ACCESSOR(IScreen)
|
EVENT_TYPE_ACCESSOR(IScreen)
|
||||||
EVENT_TYPE_ACCESSOR(Clipboard)
|
EVENT_TYPE_ACCESSOR(Clipboard)
|
||||||
|
EVENT_TYPE_ACCESSOR(File)
|
||||||
|
|
||||||
// interrupt handler. this just adds a quit event to the queue.
|
// interrupt handler. this just adds a quit event to the queue.
|
||||||
static
|
static
|
||||||
|
@ -84,6 +85,7 @@ EventQueue::EventQueue() :
|
||||||
m_typesForIPrimaryScreen(NULL),
|
m_typesForIPrimaryScreen(NULL),
|
||||||
m_typesForIScreen(NULL),
|
m_typesForIScreen(NULL),
|
||||||
m_typesForClipboard(NULL),
|
m_typesForClipboard(NULL),
|
||||||
|
m_typesForFile(NULL),
|
||||||
m_readyMutex(new Mutex),
|
m_readyMutex(new Mutex),
|
||||||
m_readyCondVar(new CondVar<bool>(m_readyMutex, false))
|
m_readyCondVar(new CondVar<bool>(m_readyMutex, false))
|
||||||
{
|
{
|
||||||
|
|
|
@ -158,6 +158,7 @@ public:
|
||||||
IPrimaryScreenEvents& forIPrimaryScreen();
|
IPrimaryScreenEvents& forIPrimaryScreen();
|
||||||
IScreenEvents& forIScreen();
|
IScreenEvents& forIScreen();
|
||||||
ClipboardEvents& forClipboard();
|
ClipboardEvents& forClipboard();
|
||||||
|
FileEvents& forFile();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ClientEvents* m_typesForClient;
|
ClientEvents* m_typesForClient;
|
||||||
|
@ -179,6 +180,7 @@ private:
|
||||||
IPrimaryScreenEvents* m_typesForIPrimaryScreen;
|
IPrimaryScreenEvents* m_typesForIPrimaryScreen;
|
||||||
IScreenEvents* m_typesForIScreen;
|
IScreenEvents* m_typesForIScreen;
|
||||||
ClipboardEvents* m_typesForClipboard;
|
ClipboardEvents* m_typesForClipboard;
|
||||||
|
FileEvents* m_typesForFile;
|
||||||
Mutex* m_readyMutex;
|
Mutex* m_readyMutex;
|
||||||
CondVar<bool>* m_readyCondVar;
|
CondVar<bool>* m_readyCondVar;
|
||||||
std::queue<Event> m_pending;
|
std::queue<Event> m_pending;
|
||||||
|
|
|
@ -176,8 +176,6 @@ REGISTER_EVENT(IScreen, error)
|
||||||
REGISTER_EVENT(IScreen, shapeChanged)
|
REGISTER_EVENT(IScreen, shapeChanged)
|
||||||
REGISTER_EVENT(IScreen, suspend)
|
REGISTER_EVENT(IScreen, suspend)
|
||||||
REGISTER_EVENT(IScreen, resume)
|
REGISTER_EVENT(IScreen, resume)
|
||||||
REGISTER_EVENT(IScreen, fileChunkSending)
|
|
||||||
REGISTER_EVENT(IScreen, fileRecieveCompleted)
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// IpcServer
|
// IpcServer
|
||||||
|
@ -192,4 +190,12 @@ REGISTER_EVENT(IpcServer, messageReceived)
|
||||||
|
|
||||||
REGISTER_EVENT(Clipboard, clipboardGrabbed)
|
REGISTER_EVENT(Clipboard, clipboardGrabbed)
|
||||||
REGISTER_EVENT(Clipboard, clipboardChanged)
|
REGISTER_EVENT(Clipboard, clipboardChanged)
|
||||||
REGISTER_EVENT(Clipboard, clipboardSending)
|
REGISTER_EVENT(Clipboard, clipboardSending)
|
||||||
|
|
||||||
|
//
|
||||||
|
// File
|
||||||
|
//
|
||||||
|
|
||||||
|
REGISTER_EVENT(File, fileChunkSending)
|
||||||
|
REGISTER_EVENT(File, fileRecieveCompleted)
|
||||||
|
REGISTER_EVENT(File, keepAlive)
|
||||||
|
|
|
@ -625,9 +625,7 @@ public:
|
||||||
m_error(Event::kUnknown),
|
m_error(Event::kUnknown),
|
||||||
m_shapeChanged(Event::kUnknown),
|
m_shapeChanged(Event::kUnknown),
|
||||||
m_suspend(Event::kUnknown),
|
m_suspend(Event::kUnknown),
|
||||||
m_resume(Event::kUnknown),
|
m_resume(Event::kUnknown) { }
|
||||||
m_fileChunkSending(Event::kUnknown),
|
|
||||||
m_fileRecieveCompleted(Event::kUnknown) { }
|
|
||||||
|
|
||||||
//! @name accessors
|
//! @name accessors
|
||||||
//@{
|
//@{
|
||||||
|
@ -660,12 +658,6 @@ public:
|
||||||
*/
|
*/
|
||||||
Event::Type resume();
|
Event::Type resume();
|
||||||
|
|
||||||
//! Sending a file chunk
|
|
||||||
Event::Type fileChunkSending();
|
|
||||||
|
|
||||||
//! Completed receiving a file
|
|
||||||
Event::Type fileRecieveCompleted();
|
|
||||||
|
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -673,8 +665,6 @@ private:
|
||||||
Event::Type m_shapeChanged;
|
Event::Type m_shapeChanged;
|
||||||
Event::Type m_suspend;
|
Event::Type m_suspend;
|
||||||
Event::Type m_resume;
|
Event::Type m_resume;
|
||||||
Event::Type m_fileChunkSending;
|
|
||||||
Event::Type m_fileRecieveCompleted;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class ClipboardEvents : public EventTypes {
|
class ClipboardEvents : public EventTypes {
|
||||||
|
@ -717,3 +707,30 @@ private:
|
||||||
Event::Type m_clipboardChanged;
|
Event::Type m_clipboardChanged;
|
||||||
Event::Type m_clipboardSending;
|
Event::Type m_clipboardSending;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class FileEvents : public EventTypes {
|
||||||
|
public:
|
||||||
|
FileEvents() :
|
||||||
|
m_fileChunkSending(Event::kUnknown),
|
||||||
|
m_fileRecieveCompleted(Event::kUnknown),
|
||||||
|
m_keepAlive(Event::kUnknown) { }
|
||||||
|
|
||||||
|
//! @name accessors
|
||||||
|
//@{
|
||||||
|
|
||||||
|
//! Sending a file chunk
|
||||||
|
Event::Type fileChunkSending();
|
||||||
|
|
||||||
|
//! Completed receiving a file
|
||||||
|
Event::Type fileRecieveCompleted();
|
||||||
|
|
||||||
|
//! Send a keep alive
|
||||||
|
Event::Type keepAlive();
|
||||||
|
|
||||||
|
//@}
|
||||||
|
|
||||||
|
private:
|
||||||
|
Event::Type m_fileChunkSending;
|
||||||
|
Event::Type m_fileRecieveCompleted;
|
||||||
|
Event::Type m_keepAlive;
|
||||||
|
};
|
||||||
|
|
|
@ -49,6 +49,7 @@ class IKeyStateEvents;
|
||||||
class IPrimaryScreenEvents;
|
class IPrimaryScreenEvents;
|
||||||
class IScreenEvents;
|
class IScreenEvents;
|
||||||
class ClipboardEvents;
|
class ClipboardEvents;
|
||||||
|
class FileEvents;
|
||||||
|
|
||||||
//! Event queue interface
|
//! Event queue interface
|
||||||
/*!
|
/*!
|
||||||
|
@ -246,4 +247,5 @@ public:
|
||||||
virtual IPrimaryScreenEvents& forIPrimaryScreen() = 0;
|
virtual IPrimaryScreenEvents& forIPrimaryScreen() = 0;
|
||||||
virtual IScreenEvents& forIScreen() = 0;
|
virtual IScreenEvents& forIScreen() = 0;
|
||||||
virtual ClipboardEvents& forClipboard() = 0;
|
virtual ClipboardEvents& forClipboard() = 0;
|
||||||
|
virtual FileEvents& forFile() = 0;
|
||||||
};
|
};
|
||||||
|
|
|
@ -96,11 +96,11 @@ Client::Client(
|
||||||
&Client::handleResume));
|
&Client::handleResume));
|
||||||
|
|
||||||
if (m_args.m_enableDragDrop) {
|
if (m_args.m_enableDragDrop) {
|
||||||
m_events->adoptHandler(m_events->forIScreen().fileChunkSending(),
|
m_events->adoptHandler(m_events->forFile().fileChunkSending(),
|
||||||
this,
|
this,
|
||||||
new TMethodEventJob<Client>(this,
|
new TMethodEventJob<Client>(this,
|
||||||
&Client::handleFileChunkSending));
|
&Client::handleFileChunkSending));
|
||||||
m_events->adoptHandler(m_events->forIScreen().fileRecieveCompleted(),
|
m_events->adoptHandler(m_events->forFile().fileRecieveCompleted(),
|
||||||
this,
|
this,
|
||||||
new TMethodEventJob<Client>(this,
|
new TMethodEventJob<Client>(this,
|
||||||
&Client::handleFileRecieveCompleted));
|
&Client::handleFileRecieveCompleted));
|
||||||
|
|
|
@ -868,7 +868,7 @@ ServerProxy::fileChunkReceived()
|
||||||
m_client->getExpectedFileSize());
|
m_client->getExpectedFileSize());
|
||||||
|
|
||||||
if (result == kFinish) {
|
if (result == kFinish) {
|
||||||
m_events->addEvent(Event(m_events->forIScreen().fileRecieveCompleted(), m_client));
|
m_events->addEvent(Event(m_events->forFile().fileRecieveCompleted(), m_client));
|
||||||
}
|
}
|
||||||
else if (result == kStart) {
|
else if (result == kStart) {
|
||||||
String filename = m_client->getDragFileList().at(0).getFilename();
|
String filename = m_client->getDragFileList().at(0).getFilename();
|
||||||
|
|
|
@ -184,11 +184,11 @@ Server::Server(
|
||||||
&Server::handleFakeInputEndEvent));
|
&Server::handleFakeInputEndEvent));
|
||||||
|
|
||||||
if (m_enableDragDrop) {
|
if (m_enableDragDrop) {
|
||||||
m_events->adoptHandler(m_events->forIScreen().fileChunkSending(),
|
m_events->adoptHandler(m_events->forFile().fileChunkSending(),
|
||||||
this,
|
this,
|
||||||
new TMethodEventJob<Server>(this,
|
new TMethodEventJob<Server>(this,
|
||||||
&Server::handleFileChunkSendingEvent));
|
&Server::handleFileChunkSendingEvent));
|
||||||
m_events->adoptHandler(m_events->forIScreen().fileRecieveCompleted(),
|
m_events->adoptHandler(m_events->forFile().fileRecieveCompleted(),
|
||||||
this,
|
this,
|
||||||
new TMethodEventJob<Server>(this,
|
new TMethodEventJob<Server>(this,
|
||||||
&Server::handleFileRecieveCompletedEvent));
|
&Server::handleFileRecieveCompletedEvent));
|
||||||
|
|
|
@ -147,7 +147,7 @@ TEST_F(NetworkTests, sendToClient_mockData)
|
||||||
Client client(&m_events, "stub", serverAddress, clientSocketFactory, &clientScreen, args);
|
Client client(&m_events, "stub", serverAddress, clientSocketFactory, &clientScreen, args);
|
||||||
|
|
||||||
m_events.adoptHandler(
|
m_events.adoptHandler(
|
||||||
m_events.forIScreen().fileRecieveCompleted(), &client,
|
m_events.forFile().fileRecieveCompleted(), &client,
|
||||||
new TMethodEventJob<NetworkTests>(
|
new TMethodEventJob<NetworkTests>(
|
||||||
this, &NetworkTests::sendToClient_mockData_fileRecieveCompleted));
|
this, &NetworkTests::sendToClient_mockData_fileRecieveCompleted));
|
||||||
|
|
||||||
|
@ -156,7 +156,7 @@ TEST_F(NetworkTests, sendToClient_mockData)
|
||||||
m_events.initQuitTimeout(10);
|
m_events.initQuitTimeout(10);
|
||||||
m_events.loop();
|
m_events.loop();
|
||||||
m_events.removeHandler(m_events.forClientListener().connected(), &listener);
|
m_events.removeHandler(m_events.forClientListener().connected(), &listener);
|
||||||
m_events.removeHandler(m_events.forIScreen().fileRecieveCompleted(), &client);
|
m_events.removeHandler(m_events.forFile().fileRecieveCompleted(), &client);
|
||||||
m_events.cleanupQuitTimeout();
|
m_events.cleanupQuitTimeout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,7 +203,7 @@ TEST_F(NetworkTests, sendToClient_mockFile)
|
||||||
Client client(&m_events, "stub", serverAddress, clientSocketFactory, &clientScreen, args);
|
Client client(&m_events, "stub", serverAddress, clientSocketFactory, &clientScreen, args);
|
||||||
|
|
||||||
m_events.adoptHandler(
|
m_events.adoptHandler(
|
||||||
m_events.forIScreen().fileRecieveCompleted(), &client,
|
m_events.forFile().fileRecieveCompleted(), &client,
|
||||||
new TMethodEventJob<NetworkTests>(
|
new TMethodEventJob<NetworkTests>(
|
||||||
this, &NetworkTests::sendToClient_mockFile_fileRecieveCompleted));
|
this, &NetworkTests::sendToClient_mockFile_fileRecieveCompleted));
|
||||||
|
|
||||||
|
@ -212,7 +212,7 @@ TEST_F(NetworkTests, sendToClient_mockFile)
|
||||||
m_events.initQuitTimeout(10);
|
m_events.initQuitTimeout(10);
|
||||||
m_events.loop();
|
m_events.loop();
|
||||||
m_events.removeHandler(m_events.forClientListener().connected(), &listener);
|
m_events.removeHandler(m_events.forClientListener().connected(), &listener);
|
||||||
m_events.removeHandler(m_events.forIScreen().fileRecieveCompleted(), &client);
|
m_events.removeHandler(m_events.forFile().fileRecieveCompleted(), &client);
|
||||||
m_events.cleanupQuitTimeout();
|
m_events.cleanupQuitTimeout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -257,7 +257,7 @@ TEST_F(NetworkTests, sendToServer_mockData)
|
||||||
this, &NetworkTests::sendToServer_mockData_handleClientConnected, &client));
|
this, &NetworkTests::sendToServer_mockData_handleClientConnected, &client));
|
||||||
|
|
||||||
m_events.adoptHandler(
|
m_events.adoptHandler(
|
||||||
m_events.forIScreen().fileRecieveCompleted(), &server,
|
m_events.forFile().fileRecieveCompleted(), &server,
|
||||||
new TMethodEventJob<NetworkTests>(
|
new TMethodEventJob<NetworkTests>(
|
||||||
this, &NetworkTests::sendToServer_mockData_fileRecieveCompleted));
|
this, &NetworkTests::sendToServer_mockData_fileRecieveCompleted));
|
||||||
|
|
||||||
|
@ -266,7 +266,7 @@ TEST_F(NetworkTests, sendToServer_mockData)
|
||||||
m_events.initQuitTimeout(10);
|
m_events.initQuitTimeout(10);
|
||||||
m_events.loop();
|
m_events.loop();
|
||||||
m_events.removeHandler(m_events.forClientListener().connected(), &listener);
|
m_events.removeHandler(m_events.forClientListener().connected(), &listener);
|
||||||
m_events.removeHandler(m_events.forIScreen().fileRecieveCompleted(), &server);
|
m_events.removeHandler(m_events.forFile().fileRecieveCompleted(), &server);
|
||||||
m_events.cleanupQuitTimeout();
|
m_events.cleanupQuitTimeout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -312,7 +312,7 @@ TEST_F(NetworkTests, sendToServer_mockFile)
|
||||||
this, &NetworkTests::sendToServer_mockFile_handleClientConnected, &client));
|
this, &NetworkTests::sendToServer_mockFile_handleClientConnected, &client));
|
||||||
|
|
||||||
m_events.adoptHandler(
|
m_events.adoptHandler(
|
||||||
m_events.forIScreen().fileRecieveCompleted(), &server,
|
m_events.forFile().fileRecieveCompleted(), &server,
|
||||||
new TMethodEventJob<NetworkTests>(
|
new TMethodEventJob<NetworkTests>(
|
||||||
this, &NetworkTests::sendToServer_mockFile_fileRecieveCompleted));
|
this, &NetworkTests::sendToServer_mockFile_fileRecieveCompleted));
|
||||||
|
|
||||||
|
@ -321,7 +321,7 @@ TEST_F(NetworkTests, sendToServer_mockFile)
|
||||||
m_events.initQuitTimeout(10);
|
m_events.initQuitTimeout(10);
|
||||||
m_events.loop();
|
m_events.loop();
|
||||||
m_events.removeHandler(m_events.forClientListener().connected(), &listener);
|
m_events.removeHandler(m_events.forClientListener().connected(), &listener);
|
||||||
m_events.removeHandler(m_events.forIScreen().fileRecieveCompleted(), &server);
|
m_events.removeHandler(m_events.forFile().fileRecieveCompleted(), &server);
|
||||||
m_events.cleanupQuitTimeout();
|
m_events.cleanupQuitTimeout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -418,7 +418,7 @@ NetworkTests::sendMockData(void* eventTarget)
|
||||||
String size = synergy::string::sizeTypeToString(kMockDataSize);
|
String size = synergy::string::sizeTypeToString(kMockDataSize);
|
||||||
FileChunk* sizeMessage = FileChunk::start(size);
|
FileChunk* sizeMessage = FileChunk::start(size);
|
||||||
|
|
||||||
m_events.addEvent(Event(m_events.forIScreen().fileChunkSending(), eventTarget, sizeMessage));
|
m_events.addEvent(Event(m_events.forFile().fileChunkSending(), eventTarget, sizeMessage));
|
||||||
|
|
||||||
// send chunk messages with incrementing chunk size
|
// send chunk messages with incrementing chunk size
|
||||||
size_t lastSize = 0;
|
size_t lastSize = 0;
|
||||||
|
@ -433,7 +433,7 @@ NetworkTests::sendMockData(void* eventTarget)
|
||||||
|
|
||||||
// first byte is the chunk mark, last is \0
|
// first byte is the chunk mark, last is \0
|
||||||
FileChunk* chunk = FileChunk::data(m_mockData, dataSize);
|
FileChunk* chunk = FileChunk::data(m_mockData, dataSize);
|
||||||
m_events.addEvent(Event(m_events.forIScreen().fileChunkSending(), eventTarget, chunk));
|
m_events.addEvent(Event(m_events.forFile().fileChunkSending(), eventTarget, chunk));
|
||||||
|
|
||||||
sentLength += dataSize;
|
sentLength += dataSize;
|
||||||
lastSize = dataSize;
|
lastSize = dataSize;
|
||||||
|
@ -446,7 +446,7 @@ NetworkTests::sendMockData(void* eventTarget)
|
||||||
|
|
||||||
// send last message
|
// send last message
|
||||||
FileChunk* transferFinished = FileChunk::end();
|
FileChunk* transferFinished = FileChunk::end();
|
||||||
m_events.addEvent(Event(m_events.forIScreen().fileChunkSending(), eventTarget, transferFinished));
|
m_events.addEvent(Event(m_events.forFile().fileChunkSending(), eventTarget, transferFinished));
|
||||||
}
|
}
|
||||||
|
|
||||||
UInt8*
|
UInt8*
|
||||||
|
|
|
@ -62,5 +62,6 @@ public:
|
||||||
MOCK_METHOD0(forIPrimaryScreen, IPrimaryScreenEvents&());
|
MOCK_METHOD0(forIPrimaryScreen, IPrimaryScreenEvents&());
|
||||||
MOCK_METHOD0(forIScreen, IScreenEvents&());
|
MOCK_METHOD0(forIScreen, IScreenEvents&());
|
||||||
MOCK_METHOD0(forClipboard, ClipboardEvents&());
|
MOCK_METHOD0(forClipboard, ClipboardEvents&());
|
||||||
|
MOCK_METHOD0(forFile, FileEvents&());
|
||||||
MOCK_CONST_METHOD0(waitForReady, void());
|
MOCK_CONST_METHOD0(waitForReady, void());
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue