Added sending clipboard chunks handling #4601
This commit is contained in:
parent
6e7b3d87c5
commit
eaff6f50f8
|
@ -116,6 +116,7 @@ REGISTER_EVENT(ClientListener, connected)
|
||||||
REGISTER_EVENT(ClientProxy, ready)
|
REGISTER_EVENT(ClientProxy, ready)
|
||||||
REGISTER_EVENT(ClientProxy, disconnected)
|
REGISTER_EVENT(ClientProxy, disconnected)
|
||||||
REGISTER_EVENT(ClientProxy, clipboardChanged)
|
REGISTER_EVENT(ClientProxy, clipboardChanged)
|
||||||
|
REGISTER_EVENT(ClientProxy, clipboardSending)
|
||||||
|
|
||||||
//
|
//
|
||||||
// ClientProxyUnknown
|
// ClientProxyUnknown
|
||||||
|
|
|
@ -351,7 +351,8 @@ public:
|
||||||
ClientProxyEvents() :
|
ClientProxyEvents() :
|
||||||
m_ready(Event::kUnknown),
|
m_ready(Event::kUnknown),
|
||||||
m_disconnected(Event::kUnknown),
|
m_disconnected(Event::kUnknown),
|
||||||
m_clipboardChanged(Event::kUnknown) { }
|
m_clipboardChanged(Event::kUnknown),
|
||||||
|
m_clipboardSending(Event::kUnknown) { }
|
||||||
|
|
||||||
//! @name accessors
|
//! @name accessors
|
||||||
//@{
|
//@{
|
||||||
|
@ -379,12 +380,20 @@ public:
|
||||||
*/
|
*/
|
||||||
Event::Type clipboardChanged();
|
Event::Type clipboardChanged();
|
||||||
|
|
||||||
|
//! Clipboard sending event type
|
||||||
|
/*!
|
||||||
|
Returns the clipboard sending event type. This is used to send
|
||||||
|
clipboard chunks.
|
||||||
|
*/
|
||||||
|
Event::Type clipboardSending();
|
||||||
|
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Event::Type m_ready;
|
Event::Type m_ready;
|
||||||
Event::Type m_disconnected;
|
Event::Type m_disconnected;
|
||||||
Event::Type m_clipboardChanged;
|
Event::Type m_clipboardChanged;
|
||||||
|
Event::Type m_clipboardSending;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ClientProxyUnknownEvents : public EventTypes {
|
class ClientProxyUnknownEvents : public EventTypes {
|
||||||
|
|
|
@ -18,8 +18,11 @@
|
||||||
#include "server/ClientProxy1_6.h"
|
#include "server/ClientProxy1_6.h"
|
||||||
|
|
||||||
#include "server/Server.h"
|
#include "server/Server.h"
|
||||||
|
#include "synergy/ProtocolUtil.h"
|
||||||
#include "synergy/StreamChunker.h"
|
#include "synergy/StreamChunker.h"
|
||||||
|
#include "synergy/ClipboardChunk.h"
|
||||||
#include "io/IStream.h"
|
#include "io/IStream.h"
|
||||||
|
#include "base/TMethodEventJob.h"
|
||||||
#include "base/Log.h"
|
#include "base/Log.h"
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -30,6 +33,10 @@ ClientProxy1_6::ClientProxy1_6(const String& name, synergy::IStream* stream, Ser
|
||||||
ClientProxy1_5(name, stream, server, events),
|
ClientProxy1_5(name, stream, server, events),
|
||||||
m_events(events)
|
m_events(events)
|
||||||
{
|
{
|
||||||
|
m_events->adoptHandler(m_events->forClientProxy().clipboardSending(),
|
||||||
|
this,
|
||||||
|
new TMethodEventJob<ClientProxy1_6>(this,
|
||||||
|
&ClientProxy1_6::handleClipboardSendingEvent));
|
||||||
}
|
}
|
||||||
|
|
||||||
ClientProxy1_6::~ClientProxy1_6()
|
ClientProxy1_6::~ClientProxy1_6()
|
||||||
|
@ -67,3 +74,35 @@ ClientProxy1_6::setClipboard(ClipboardID id, const IClipboard* clipboard)
|
||||||
StreamChunker::sendClipboard(data, size, id, 0, m_events, this);
|
StreamChunker::sendClipboard(data, size, id, 0, m_events, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ClientProxy1_6::handleClipboardSendingEvent(const Event& event, void*)
|
||||||
|
{
|
||||||
|
void* data = event.getData();
|
||||||
|
ClipboardChunk* clipboardData = reinterpret_cast<ClipboardChunk*>(data);
|
||||||
|
|
||||||
|
LOG((CLOG_DEBUG1 "sending clipboard chunk"));
|
||||||
|
|
||||||
|
char* chunk = clipboardData->m_chunk;
|
||||||
|
ClipboardID id = chunk[0];
|
||||||
|
UInt32* seq = reinterpret_cast<UInt32*>(&chunk[1]);
|
||||||
|
UInt32 sequence = *seq;
|
||||||
|
UInt8 mark = chunk[5];
|
||||||
|
String dataChunk(&chunk[6], clipboardData->m_dataSize);
|
||||||
|
|
||||||
|
switch (mark) {
|
||||||
|
case kDataStart:
|
||||||
|
LOG((CLOG_DEBUG2 "file sending start: size=%s", dataChunk.c_str()));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case kDataChunk:
|
||||||
|
LOG((CLOG_DEBUG2 "file chunk sending: size=%i", dataChunk.size()));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case kDataEnd:
|
||||||
|
LOG((CLOG_DEBUG2 "file sending finished"));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
ProtocolUtil::writef(getStream(), kMsgDClipboard, id, sequence, mark, &dataChunk);
|
||||||
|
}
|
||||||
|
|
|
@ -31,6 +31,9 @@ public:
|
||||||
virtual bool parseMessage(const UInt8* code);
|
virtual bool parseMessage(const UInt8* code);
|
||||||
virtual void setClipboard(ClipboardID id, const IClipboard* clipboard);
|
virtual void setClipboard(ClipboardID id, const IClipboard* clipboard);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void handleClipboardSendingEvent(const Event&, void*);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
IEventQueue* m_events;
|
IEventQueue* m_events;
|
||||||
};
|
};
|
||||||
|
|
|
@ -112,7 +112,7 @@ StreamChunker::sendClipboard(
|
||||||
String dataSize = synergy::string::intToString(size);
|
String dataSize = synergy::string::intToString(size);
|
||||||
ClipboardChunk* sizeMessage = ClipboardChunk::start(id, sequence, dataSize);
|
ClipboardChunk* sizeMessage = ClipboardChunk::start(id, sequence, dataSize);
|
||||||
|
|
||||||
events->addEvent(Event(events->forIScreen().fileChunkSending(), eventTarget, sizeMessage));
|
events->addEvent(Event(events->forClientProxy().clipboardSending(), eventTarget, sizeMessage));
|
||||||
|
|
||||||
// send clipboard chunk with a fixed size
|
// send clipboard chunk with a fixed size
|
||||||
// TODO: 4096 fails and this shouldn't a magic number
|
// TODO: 4096 fails and this shouldn't a magic number
|
||||||
|
@ -130,7 +130,7 @@ StreamChunker::sendClipboard(
|
||||||
String chunk(data.substr(sentLength, chunkSize).c_str(), chunkSize);
|
String chunk(data.substr(sentLength, chunkSize).c_str(), chunkSize);
|
||||||
ClipboardChunk* dataChunk = ClipboardChunk::data(id, sequence, chunk);
|
ClipboardChunk* dataChunk = ClipboardChunk::data(id, sequence, chunk);
|
||||||
|
|
||||||
events->addEvent(Event(events->forIScreen().fileChunkSending(), eventTarget, dataChunk));
|
events->addEvent(Event(events->forClientProxy().clipboardSending(), eventTarget, dataChunk));
|
||||||
|
|
||||||
sentLength += chunkSize;
|
sentLength += chunkSize;
|
||||||
|
|
||||||
|
@ -145,5 +145,5 @@ StreamChunker::sendClipboard(
|
||||||
// send last message
|
// send last message
|
||||||
ClipboardChunk* end = ClipboardChunk::end(id, sequence);
|
ClipboardChunk* end = ClipboardChunk::end(id, sequence);
|
||||||
|
|
||||||
events->addEvent(Event(events->forIScreen().fileChunkSending(), eventTarget, end));
|
events->addEvent(Event(events->forClientProxy().clipboardSending(), eventTarget, end));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue