diff --git a/src/lib/server/ClientProxy1_5.cpp b/src/lib/server/ClientProxy1_5.cpp index a0d082eb..5c01b5d5 100644 --- a/src/lib/server/ClientProxy1_5.cpp +++ b/src/lib/server/ClientProxy1_5.cpp @@ -20,9 +20,7 @@ #include "server/Server.h" #include "synergy/FileChunker.h" #include "synergy/ProtocolUtil.h" -#include "mt/Thread.h" #include "io/IStream.h" -#include "base/TMethodJob.h" #include "base/Log.h" #include @@ -124,11 +122,6 @@ ClientProxy1_5::setClipboard(ClipboardID id, const IClipboard* clipboard) // send last message ProtocolUtil::writef(getStream(), kMsgDClipboard, id, 0, kDataEnd, "\0"); - -// m_sendFileThread = new Thread( -// new TMethodJob( -// this, &ClientProxy1_5::sendClipboardThread, -// reinterpret_cast(id))); } } @@ -209,52 +202,3 @@ ClientProxy1_5::dragInfoReceived() m_server->dragInfoReceived(fileNum, content); } - -void -ClientProxy1_5::sendClipboardThread(void* data) -{ - //size_t id = reinterpret_cast(data); - //String clipboardData = m_clipboardData.at(id); - //int size = clipboardData.size(); - //LOG((CLOG_DEBUG "sending clipboard %d to \"%s\" size=%d", id, getName().c_str(), size)); - - ////TODO: refactor FileChunker - //// send first message (file size) - //std::stringstream ss; - //ss << size; - //String dataSize = ss.str(); - //ProtocolUtil::writef(getStream(), kMsgDClipboard, id, 0, kDataStart, &dataSize); - - //// send chunk messages with a fixed chunk size - //size_t sentLength = 0; - //size_t chunkSize = 2048; - //Stopwatch stopwatch; - //stopwatch.start(); - //while (true) { - // if (stopwatch.getTime() > 0.1f) { - // // make sure we don't read too much from the mock data. - // if (sentLength + chunkSize > size) { - // chunkSize = size - sentLength; - // } - - // char* chunk = new char[chunkSize]; - // memcpy(chunk, clipboardData.substr(sentLength, chunkSize).c_str(), chunkSize); - // //String chunk(clipboardData.substr(sentLength, chunkSize).c_str(), chunkSize); - // //int sizetest = chunk.size(); - // //sizetest++; - // //sizetest--; - // ProtocolUtil::writef(getStream(), kMsgDClipboard, id, 0, kDataChunk, chunk); - - // sentLength += chunkSize; - - // if (sentLength == size) { - // break; - // } - - // stopwatch.reset(); - // } - //} - - //// send last message - //ProtocolUtil::writef(getStream(), kMsgDClipboard, id, 0, kDataEnd, "\0"); -} diff --git a/src/lib/server/ClientProxy1_5.h b/src/lib/server/ClientProxy1_5.h index 8301d3be..3705b85c 100644 --- a/src/lib/server/ClientProxy1_5.h +++ b/src/lib/server/ClientProxy1_5.h @@ -23,7 +23,6 @@ class Server; class IEventQueue; -class Thread; //! Proxy for client implementing protocol version 1.5 class ClientProxy1_5 : public ClientProxy1_4 { @@ -38,10 +37,6 @@ public: void fileChunkReceived(); void dragInfoReceived(); -private: - // thread funciton for sending clipboard - void sendClipboardThread(void*); - private: IEventQueue* m_events; @@ -49,5 +44,4 @@ private: double m_elapsedTime; size_t m_receivedDataSize; static const UInt16 m_intervalThreshold; - //Thread* m_sendFileThread; }; diff --git a/src/lib/server/Server.cpp b/src/lib/server/Server.cpp index 0bea6aa9..999a97b4 100644 --- a/src/lib/server/Server.cpp +++ b/src/lib/server/Server.cpp @@ -91,7 +91,8 @@ Server::Server( m_ignoreFileTransfer(false), m_enableDragDrop(enableDragDrop), m_getDragInfoThread(NULL), - m_waitDragInfoThread(true) + m_waitDragInfoThread(true), + m_dataTransmissionThread(NULL) { // must have a primary client and it must have a canonical name assert(m_primaryClient != NULL); @@ -505,9 +506,10 @@ Server::switchScreen(BaseClientProxy* dst, forScreensaver); // send the clipboard data to new active screen - for (ClipboardID id = 0; id < kClipboardEnd; ++id) { - m_active->setClipboard(id, &m_clipboards[id].m_clipboard); - } + m_dataTransmissionThread = new Thread( + new TMethodJob( + this, &Server::clipboardTransmissionThread, + NULL)); Server::SwitchToScreenInfo* info = Server::SwitchToScreenInfo::alloc(m_active->getName()); @@ -1849,6 +1851,14 @@ Server::sendDragInfo(BaseClientProxy* newScreen) } } +void +Server::clipboardTransmissionThread(void*) +{ + for (ClipboardID id = 0; id < kClipboardEnd; ++id) { + m_active->setClipboard(id, &m_clipboards[id].m_clipboard); + } +} + void Server::onMouseMoveSecondary(SInt32 dx, SInt32 dy) { diff --git a/src/lib/server/Server.h b/src/lib/server/Server.h index 742a0a9c..8cc700b4 100644 --- a/src/lib/server/Server.h +++ b/src/lib/server/Server.h @@ -370,6 +370,9 @@ private: // send drag info to new client screen void sendDragInfo(BaseClientProxy* newScreen); + // thread funciton for sending clipboard + void clipboardTransmissionThread(void*); + public: bool m_mock; @@ -480,4 +483,6 @@ private: bool m_waitDragInfoThread; ClientListener* m_clientListener; + + Thread* m_dataTransmissionThread; };