Used a thread to send clipboard data #4601
This commit is contained in:
parent
8c82996fc4
commit
220b6befab
|
@ -282,6 +282,7 @@ ClientProxy1_0::setClipboard(ClipboardID id, const IClipboard* clipboard)
|
|||
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);
|
||||
}
|
||||
|
@ -505,7 +506,6 @@ ClientProxy1_0::recvGrabClipboard()
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// ClientProxy1_0::ClientClipboard
|
||||
//
|
||||
|
|
|
@ -84,8 +84,7 @@ private:
|
|||
bool recvClipboard();
|
||||
bool recvGrabClipboard();
|
||||
|
||||
private:
|
||||
typedef bool (ClientProxy1_0::*MessageParser)(const UInt8*);
|
||||
protected:
|
||||
struct ClientClipboard {
|
||||
public:
|
||||
ClientClipboard();
|
||||
|
@ -96,8 +95,12 @@ private:
|
|||
bool m_dirty;
|
||||
};
|
||||
|
||||
ClientInfo m_info;
|
||||
ClientClipboard m_clipboard[kClipboardEnd];
|
||||
|
||||
private:
|
||||
typedef bool (ClientProxy1_0::*MessageParser)(const UInt8*);
|
||||
|
||||
ClientInfo m_info;
|
||||
double m_heartbeatAlarm;
|
||||
EventQueueTimer* m_heartbeatTimer;
|
||||
MessageParser m_parser;
|
||||
|
|
|
@ -19,7 +19,9 @@
|
|||
|
||||
#include "server/Server.h"
|
||||
#include "synergy/ProtocolUtil.h"
|
||||
#include "mt/Thread.h"
|
||||
#include "io/IStream.h"
|
||||
#include "base/TMethodJob.h"
|
||||
#include "base/Log.h"
|
||||
|
||||
//
|
||||
|
@ -71,6 +73,24 @@ ClientProxy1_5::fileChunkSending(UInt8 mark, char* data, size_t dataSize)
|
|||
ProtocolUtil::writef(getStream(), kMsgDFileTransfer, mark, &chunk);
|
||||
}
|
||||
|
||||
void
|
||||
ClientProxy1_5::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);
|
||||
|
||||
m_clipboardData = m_clipboard[id].m_clipboard.marshall();
|
||||
|
||||
m_sendFileThread = new Thread(
|
||||
new TMethodJob<ClientProxy1_5>(
|
||||
this, &ClientProxy1_5::sendClipboardThread,
|
||||
reinterpret_cast<void*>(id)));
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
ClientProxy1_5::parseMessage(const UInt8* code)
|
||||
{
|
||||
|
@ -148,3 +168,11 @@ ClientProxy1_5::dragInfoReceived()
|
|||
|
||||
m_server->dragInfoReceived(fileNum, content);
|
||||
}
|
||||
|
||||
void
|
||||
ClientProxy1_5::sendClipboardThread(void* data)
|
||||
{
|
||||
ClipboardID id = reinterpret_cast<ClipboardID>(data);\
|
||||
LOG((CLOG_DEBUG "sending clipboard %d to \"%s\" size=%d", id, getName().c_str(), m_clipboardData.size()));
|
||||
ProtocolUtil::writef(getStream(), kMsgDClipboard, id, 0, &m_clipboardData);
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
class Server;
|
||||
class IEventQueue;
|
||||
class Thread;
|
||||
|
||||
//! Proxy for client implementing protocol version 1.5
|
||||
class ClientProxy1_5 : public ClientProxy1_4 {
|
||||
|
@ -31,10 +32,15 @@ public:
|
|||
|
||||
virtual void sendDragInfo(UInt32 fileCount, const char* info, size_t size);
|
||||
virtual void fileChunkSending(UInt8 mark, char* data, size_t dataSize);
|
||||
virtual void setClipboard(ClipboardID id, const IClipboard* clipboard);
|
||||
virtual bool parseMessage(const UInt8* code);
|
||||
void fileChunkReceived();
|
||||
void dragInfoReceived();
|
||||
|
||||
private:
|
||||
// thread funciton for sending clipboard
|
||||
void sendClipboardThread(void*);
|
||||
|
||||
private:
|
||||
IEventQueue* m_events;
|
||||
|
||||
|
@ -42,4 +48,6 @@ private:
|
|||
double m_elapsedTime;
|
||||
size_t m_receivedDataSize;
|
||||
static const UInt16 m_intervalThreshold;
|
||||
Thread* m_sendFileThread;
|
||||
String m_clipboardData;
|
||||
};
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
// 1.3: adds keep alive and deprecates heartbeats,
|
||||
// adds horizontal mouse scrolling
|
||||
// 1.4: adds crypto support
|
||||
// 1.5: adds file transfer and removes home brew crypto
|
||||
// 1.5: adds file/clipboard transfer and removes home brew crypto
|
||||
// NOTE: with new version, synergy minor version should increment
|
||||
static const SInt16 kProtocolMajorVersion = 1;
|
||||
static const SInt16 kProtocolMinorVersion = 5;
|
||||
|
|
Loading…
Reference in New Issue