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(IScreen)
|
||||
EVENT_TYPE_ACCESSOR(Clipboard)
|
||||
EVENT_TYPE_ACCESSOR(File)
|
||||
|
||||
// interrupt handler. this just adds a quit event to the queue.
|
||||
static
|
||||
|
@ -84,6 +85,7 @@ EventQueue::EventQueue() :
|
|||
m_typesForIPrimaryScreen(NULL),
|
||||
m_typesForIScreen(NULL),
|
||||
m_typesForClipboard(NULL),
|
||||
m_typesForFile(NULL),
|
||||
m_readyMutex(new Mutex),
|
||||
m_readyCondVar(new CondVar<bool>(m_readyMutex, false))
|
||||
{
|
||||
|
|
|
@ -158,6 +158,7 @@ public:
|
|||
IPrimaryScreenEvents& forIPrimaryScreen();
|
||||
IScreenEvents& forIScreen();
|
||||
ClipboardEvents& forClipboard();
|
||||
FileEvents& forFile();
|
||||
|
||||
private:
|
||||
ClientEvents* m_typesForClient;
|
||||
|
@ -179,6 +180,7 @@ private:
|
|||
IPrimaryScreenEvents* m_typesForIPrimaryScreen;
|
||||
IScreenEvents* m_typesForIScreen;
|
||||
ClipboardEvents* m_typesForClipboard;
|
||||
FileEvents* m_typesForFile;
|
||||
Mutex* m_readyMutex;
|
||||
CondVar<bool>* m_readyCondVar;
|
||||
std::queue<Event> m_pending;
|
||||
|
|
|
@ -176,8 +176,6 @@ REGISTER_EVENT(IScreen, error)
|
|||
REGISTER_EVENT(IScreen, shapeChanged)
|
||||
REGISTER_EVENT(IScreen, suspend)
|
||||
REGISTER_EVENT(IScreen, resume)
|
||||
REGISTER_EVENT(IScreen, fileChunkSending)
|
||||
REGISTER_EVENT(IScreen, fileRecieveCompleted)
|
||||
|
||||
//
|
||||
// IpcServer
|
||||
|
@ -192,4 +190,12 @@ REGISTER_EVENT(IpcServer, messageReceived)
|
|||
|
||||
REGISTER_EVENT(Clipboard, clipboardGrabbed)
|
||||
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_shapeChanged(Event::kUnknown),
|
||||
m_suspend(Event::kUnknown),
|
||||
m_resume(Event::kUnknown),
|
||||
m_fileChunkSending(Event::kUnknown),
|
||||
m_fileRecieveCompleted(Event::kUnknown) { }
|
||||
m_resume(Event::kUnknown) { }
|
||||
|
||||
//! @name accessors
|
||||
//@{
|
||||
|
@ -660,12 +658,6 @@ public:
|
|||
*/
|
||||
Event::Type resume();
|
||||
|
||||
//! Sending a file chunk
|
||||
Event::Type fileChunkSending();
|
||||
|
||||
//! Completed receiving a file
|
||||
Event::Type fileRecieveCompleted();
|
||||
|
||||
//@}
|
||||
|
||||
private:
|
||||
|
@ -673,8 +665,6 @@ private:
|
|||
Event::Type m_shapeChanged;
|
||||
Event::Type m_suspend;
|
||||
Event::Type m_resume;
|
||||
Event::Type m_fileChunkSending;
|
||||
Event::Type m_fileRecieveCompleted;
|
||||
};
|
||||
|
||||
class ClipboardEvents : public EventTypes {
|
||||
|
@ -717,3 +707,30 @@ private:
|
|||
Event::Type m_clipboardChanged;
|
||||
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 IScreenEvents;
|
||||
class ClipboardEvents;
|
||||
class FileEvents;
|
||||
|
||||
//! Event queue interface
|
||||
/*!
|
||||
|
@ -246,4 +247,5 @@ public:
|
|||
virtual IPrimaryScreenEvents& forIPrimaryScreen() = 0;
|
||||
virtual IScreenEvents& forIScreen() = 0;
|
||||
virtual ClipboardEvents& forClipboard() = 0;
|
||||
virtual FileEvents& forFile() = 0;
|
||||
};
|
||||
|
|
|
@ -96,11 +96,11 @@ Client::Client(
|
|||
&Client::handleResume));
|
||||
|
||||
if (m_args.m_enableDragDrop) {
|
||||
m_events->adoptHandler(m_events->forIScreen().fileChunkSending(),
|
||||
m_events->adoptHandler(m_events->forFile().fileChunkSending(),
|
||||
this,
|
||||
new TMethodEventJob<Client>(this,
|
||||
&Client::handleFileChunkSending));
|
||||
m_events->adoptHandler(m_events->forIScreen().fileRecieveCompleted(),
|
||||
m_events->adoptHandler(m_events->forFile().fileRecieveCompleted(),
|
||||
this,
|
||||
new TMethodEventJob<Client>(this,
|
||||
&Client::handleFileRecieveCompleted));
|
||||
|
|
|
@ -868,7 +868,7 @@ ServerProxy::fileChunkReceived()
|
|||
m_client->getExpectedFileSize());
|
||||
|
||||
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) {
|
||||
String filename = m_client->getDragFileList().at(0).getFilename();
|
||||
|
|
|
@ -184,11 +184,11 @@ Server::Server(
|
|||
&Server::handleFakeInputEndEvent));
|
||||
|
||||
if (m_enableDragDrop) {
|
||||
m_events->adoptHandler(m_events->forIScreen().fileChunkSending(),
|
||||
m_events->adoptHandler(m_events->forFile().fileChunkSending(),
|
||||
this,
|
||||
new TMethodEventJob<Server>(this,
|
||||
&Server::handleFileChunkSendingEvent));
|
||||
m_events->adoptHandler(m_events->forIScreen().fileRecieveCompleted(),
|
||||
m_events->adoptHandler(m_events->forFile().fileRecieveCompleted(),
|
||||
this,
|
||||
new TMethodEventJob<Server>(this,
|
||||
&Server::handleFileRecieveCompletedEvent));
|
||||
|
|
|
@ -147,7 +147,7 @@ TEST_F(NetworkTests, sendToClient_mockData)
|
|||
Client client(&m_events, "stub", serverAddress, clientSocketFactory, &clientScreen, args);
|
||||
|
||||
m_events.adoptHandler(
|
||||
m_events.forIScreen().fileRecieveCompleted(), &client,
|
||||
m_events.forFile().fileRecieveCompleted(), &client,
|
||||
new TMethodEventJob<NetworkTests>(
|
||||
this, &NetworkTests::sendToClient_mockData_fileRecieveCompleted));
|
||||
|
||||
|
@ -156,7 +156,7 @@ TEST_F(NetworkTests, sendToClient_mockData)
|
|||
m_events.initQuitTimeout(10);
|
||||
m_events.loop();
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -203,7 +203,7 @@ TEST_F(NetworkTests, sendToClient_mockFile)
|
|||
Client client(&m_events, "stub", serverAddress, clientSocketFactory, &clientScreen, args);
|
||||
|
||||
m_events.adoptHandler(
|
||||
m_events.forIScreen().fileRecieveCompleted(), &client,
|
||||
m_events.forFile().fileRecieveCompleted(), &client,
|
||||
new TMethodEventJob<NetworkTests>(
|
||||
this, &NetworkTests::sendToClient_mockFile_fileRecieveCompleted));
|
||||
|
||||
|
@ -212,7 +212,7 @@ TEST_F(NetworkTests, sendToClient_mockFile)
|
|||
m_events.initQuitTimeout(10);
|
||||
m_events.loop();
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -257,7 +257,7 @@ TEST_F(NetworkTests, sendToServer_mockData)
|
|||
this, &NetworkTests::sendToServer_mockData_handleClientConnected, &client));
|
||||
|
||||
m_events.adoptHandler(
|
||||
m_events.forIScreen().fileRecieveCompleted(), &server,
|
||||
m_events.forFile().fileRecieveCompleted(), &server,
|
||||
new TMethodEventJob<NetworkTests>(
|
||||
this, &NetworkTests::sendToServer_mockData_fileRecieveCompleted));
|
||||
|
||||
|
@ -266,7 +266,7 @@ TEST_F(NetworkTests, sendToServer_mockData)
|
|||
m_events.initQuitTimeout(10);
|
||||
m_events.loop();
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -312,7 +312,7 @@ TEST_F(NetworkTests, sendToServer_mockFile)
|
|||
this, &NetworkTests::sendToServer_mockFile_handleClientConnected, &client));
|
||||
|
||||
m_events.adoptHandler(
|
||||
m_events.forIScreen().fileRecieveCompleted(), &server,
|
||||
m_events.forFile().fileRecieveCompleted(), &server,
|
||||
new TMethodEventJob<NetworkTests>(
|
||||
this, &NetworkTests::sendToServer_mockFile_fileRecieveCompleted));
|
||||
|
||||
|
@ -321,7 +321,7 @@ TEST_F(NetworkTests, sendToServer_mockFile)
|
|||
m_events.initQuitTimeout(10);
|
||||
m_events.loop();
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -418,7 +418,7 @@ NetworkTests::sendMockData(void* eventTarget)
|
|||
String size = synergy::string::sizeTypeToString(kMockDataSize);
|
||||
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
|
||||
size_t lastSize = 0;
|
||||
|
@ -433,7 +433,7 @@ NetworkTests::sendMockData(void* eventTarget)
|
|||
|
||||
// first byte is the chunk mark, last is \0
|
||||
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;
|
||||
lastSize = dataSize;
|
||||
|
@ -446,7 +446,7 @@ NetworkTests::sendMockData(void* eventTarget)
|
|||
|
||||
// send last message
|
||||
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*
|
||||
|
|
|
@ -62,5 +62,6 @@ public:
|
|||
MOCK_METHOD0(forIPrimaryScreen, IPrimaryScreenEvents&());
|
||||
MOCK_METHOD0(forIScreen, IScreenEvents&());
|
||||
MOCK_METHOD0(forClipboard, ClipboardEvents&());
|
||||
MOCK_METHOD0(forFile, FileEvents&());
|
||||
MOCK_CONST_METHOD0(waitForReady, void());
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue