Refactored duplicated code #4601
This commit is contained in:
parent
1c28444cf6
commit
1df566d241
|
@ -921,33 +921,7 @@ ServerProxy::dragInfoReceived()
|
|||
void
|
||||
ServerProxy::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(m_stream, kMsgDClipboard, id, sequence, mark, &dataChunk);
|
||||
ClipboardChunk::send(m_stream, event.getData());
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -66,33 +66,7 @@ ClientProxy1_6::setClipboard(ClipboardID id, const IClipboard* clipboard)
|
|||
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);
|
||||
ClipboardChunk::send(getStream(), event.getData());
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
@ -121,3 +121,34 @@ ClipboardChunk::assemble(synergy::IStream* stream,
|
|||
|
||||
return kError;
|
||||
}
|
||||
|
||||
void
|
||||
ClipboardChunk::send(synergy::IStream* stream, void* data)
|
||||
{
|
||||
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 "sending clipboard chunk start: size=%s", dataChunk.c_str()));
|
||||
break;
|
||||
|
||||
case kDataChunk:
|
||||
LOG((CLOG_DEBUG2 "sending clipboard chunk data: size=%i", dataChunk.size()));
|
||||
break;
|
||||
|
||||
case kDataEnd:
|
||||
LOG((CLOG_DEBUG2 "sending clipboard finished"));
|
||||
break;
|
||||
}
|
||||
|
||||
ProtocolUtil::writef(stream, kMsgDClipboard, id, sequence, mark, &dataChunk);
|
||||
}
|
||||
|
|
|
@ -56,4 +56,6 @@ public:
|
|||
String& dataCached,
|
||||
ClipboardID& id,
|
||||
UInt32& sequence);
|
||||
|
||||
static void send(synergy::IStream* stream, void* data);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue