Modified server to use correct clipboard format #4601

This commit is contained in:
Xinyu Hou 2015-05-20 19:54:56 +01:00
parent 490667e21b
commit 3e9fc89d96
1 changed files with 36 additions and 18 deletions

View File

@ -452,31 +452,49 @@ bool
ClientProxy1_0::recvClipboard() ClientProxy1_0::recvClipboard()
{ {
// parse message // parse message
static String dataCached;
static size_t expectedSize;
ClipboardID id; ClipboardID id;
UInt8 mark;
UInt32 seqNum; UInt32 seqNum;
String data; String data;
if (!ProtocolUtil::readf(getStream(), if (!ProtocolUtil::readf(getStream(),
kMsgDClipboard + 4, &id, &seqNum, &data)) { kMsgDClipboard + 4, &id, &seqNum, &mark, &data)) {
return false; return false;
} }
LOG((CLOG_DEBUG "received client \"%s\" clipboard %d seqnum=%d, size=%d", getName().c_str(), id, seqNum, data.size()));
if (mark == kDataStart) {
// validate expectedSize = synergy::string::stringToSizeType(data);
if (id >= kClipboardEnd) { LOG((CLOG_DEBUG "start receiving clipboard data"));
return false; dataCached.clear();
} }
else if (mark == kDataChunk) {
// save clipboard dataCached.append(data);
m_clipboard[id].m_clipboard.unmarshall(data, 0); }
m_clipboard[id].m_sequenceNumber = seqNum; else if (mark == kDataEnd) {
LOG((CLOG_DEBUG "received client \"%s\" clipboard %d seqnum=%d, size=%d", getName().c_str(), id, seqNum, dataCached.size()));
// notify
ClipboardInfo* info = new ClipboardInfo; // validate
info->m_id = id; if (id >= kClipboardEnd) {
info->m_sequenceNumber = seqNum; return false;
m_events->addEvent(Event(m_events->forClipboard().clipboardChanged(), }
getEventTarget(), info)); else if (expectedSize != dataCached.size()) {
LOG((CLOG_ERR "corrupted clipboard data, expected size=%d actual size=%d", expectedSize, dataCached.size()));
return false;
}
// save clipboard
m_clipboard[id].m_clipboard.unmarshall(dataCached, 0);
m_clipboard[id].m_sequenceNumber = seqNum;
// notify
ClipboardInfo* info = new ClipboardInfo;
info->m_id = id;
info->m_sequenceNumber = seqNum;
m_events->addEvent(Event(m_events->forClipboard().clipboardChanged(),
getEventTarget(), info));
}
return true; return true;
} }