From 257c19ecc4c2a23f034b3b976058b6353604c27a Mon Sep 17 00:00:00 2001 From: "Jerry (Xinyu Hou)" Date: Thu, 21 May 2015 15:34:28 -0700 Subject: [PATCH] Deprecated and moved clipboard functionality into new protocol #4601 --- src/lib/server/ClientProxy1_0.cpp | 59 ++----------------------------- src/lib/server/ClientProxy1_0.h | 3 +- src/lib/server/ClientProxy1_6.cpp | 50 ++++++++++++++++++++++++++ src/lib/server/ClientProxy1_6.h | 1 + 4 files changed, 55 insertions(+), 58 deletions(-) diff --git a/src/lib/server/ClientProxy1_0.cpp b/src/lib/server/ClientProxy1_0.cpp index a95fe2d9..c124624f 100644 --- a/src/lib/server/ClientProxy1_0.cpp +++ b/src/lib/server/ClientProxy1_0.cpp @@ -275,17 +275,7 @@ ClientProxy1_0::leave() void ClientProxy1_0::setClipboard(ClipboardID id, const IClipboard* clipboard) { - // ignore if this clipboard is already clean - if (m_clipboard[id].m_dirty) { - // this clipboard is now clean - m_clipboard[id].m_dirty = false; - Clipboard::copy(&m_clipboard[id].m_clipboard, clipboard); - - String data = m_clipboard[id].m_clipboard.marshall(); - - LOG((CLOG_DEBUG "send clipboard %d to \"%s\" size=%d", id, getName().c_str(), data.size())); - ProtocolUtil::writef(getStream(), kMsgDClipboard, id, 0, &data); - } + // ignore -- deprecated in protocol 1.0 } void @@ -451,51 +441,8 @@ ClientProxy1_0::recvInfo() bool ClientProxy1_0::recvClipboard() { - // parse message - static String dataCached; - static size_t expectedSize; - ClipboardID id; - UInt8 mark; - UInt32 seqNum; - String data; - if (!ProtocolUtil::readf(getStream(), - kMsgDClipboard + 4, &id, &seqNum, &mark, &data)) { - return false; - } - - if (mark == kDataStart) { - expectedSize = synergy::string::stringToSizeType(data); - LOG((CLOG_DEBUG "start receiving clipboard data")); - dataCached.clear(); - } - else if (mark == kDataChunk) { - dataCached.append(data); - } - else if (mark == kDataEnd) { - LOG((CLOG_DEBUG "received client \"%s\" clipboard %d seqnum=%d, size=%d", getName().c_str(), id, seqNum, dataCached.size())); - - // validate - if (id >= kClipboardEnd) { - return false; - } - 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; + // deprecated in protocol 1.0 + return false; } bool diff --git a/src/lib/server/ClientProxy1_0.h b/src/lib/server/ClientProxy1_0.h index d8dc48f6..4c7f020b 100644 --- a/src/lib/server/ClientProxy1_0.h +++ b/src/lib/server/ClientProxy1_0.h @@ -70,7 +70,7 @@ protected: virtual void resetHeartbeatTimer(); virtual void addHeartbeatTimer(); virtual void removeHeartbeatTimer(); - + virtual bool recvClipboard(); private: void disconnect(); void removeHandlers(); @@ -81,7 +81,6 @@ private: void handleFlatline(const Event&, void*); bool recvInfo(); - bool recvClipboard(); bool recvGrabClipboard(); protected: diff --git a/src/lib/server/ClientProxy1_6.cpp b/src/lib/server/ClientProxy1_6.cpp index 17e19319..eb2c86af 100644 --- a/src/lib/server/ClientProxy1_6.cpp +++ b/src/lib/server/ClientProxy1_6.cpp @@ -94,3 +94,53 @@ ClientProxy1_6::handleClipboardSendingEvent(const Event& event, void*) ProtocolUtil::writef(getStream(), kMsgDClipboard, id, sequence, mark, &dataChunk); } + +bool +ClientProxy1_6::recvClipboard() +{ + // parse message + static String dataCached; + static size_t expectedSize; + ClipboardID id; + UInt8 mark; + UInt32 seqNum; + String data; + if (!ProtocolUtil::readf(getStream(), + kMsgDClipboard + 4, &id, &seqNum, &mark, &data)) { + return false; + } + + if (mark == kDataStart) { + expectedSize = synergy::string::stringToSizeType(data); + LOG((CLOG_DEBUG "start receiving clipboard data")); + dataCached.clear(); + } + else if (mark == kDataChunk) { + dataCached.append(data); + } + else if (mark == kDataEnd) { + LOG((CLOG_DEBUG "received client \"%s\" clipboard %d seqnum=%d, size=%d", getName().c_str(), id, seqNum, dataCached.size())); + + // validate + if (id >= kClipboardEnd) { + return false; + } + 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; +} diff --git a/src/lib/server/ClientProxy1_6.h b/src/lib/server/ClientProxy1_6.h index 4963e277..d8c69b11 100644 --- a/src/lib/server/ClientProxy1_6.h +++ b/src/lib/server/ClientProxy1_6.h @@ -29,6 +29,7 @@ public: ~ClientProxy1_6(); virtual void setClipboard(ClipboardID id, const IClipboard* clipboard); + virtual bool recvClipboard(); private: void handleClipboardSendingEvent(const Event&, void*);