Send clipboard data in a thread #4601
This commit is contained in:
parent
44089d55e8
commit
4c36c08099
|
@ -20,9 +20,7 @@
|
||||||
#include "server/Server.h"
|
#include "server/Server.h"
|
||||||
#include "synergy/FileChunker.h"
|
#include "synergy/FileChunker.h"
|
||||||
#include "synergy/ProtocolUtil.h"
|
#include "synergy/ProtocolUtil.h"
|
||||||
#include "mt/Thread.h"
|
|
||||||
#include "io/IStream.h"
|
#include "io/IStream.h"
|
||||||
#include "base/TMethodJob.h"
|
|
||||||
#include "base/Log.h"
|
#include "base/Log.h"
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
@ -124,11 +122,6 @@ ClientProxy1_5::setClipboard(ClipboardID id, const IClipboard* clipboard)
|
||||||
|
|
||||||
// send last message
|
// send last message
|
||||||
ProtocolUtil::writef(getStream(), kMsgDClipboard, id, 0, kDataEnd, "\0");
|
ProtocolUtil::writef(getStream(), kMsgDClipboard, id, 0, kDataEnd, "\0");
|
||||||
|
|
||||||
// m_sendFileThread = new Thread(
|
|
||||||
// new TMethodJob<ClientProxy1_5>(
|
|
||||||
// this, &ClientProxy1_5::sendClipboardThread,
|
|
||||||
// reinterpret_cast<void*>(id)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,52 +202,3 @@ ClientProxy1_5::dragInfoReceived()
|
||||||
|
|
||||||
m_server->dragInfoReceived(fileNum, content);
|
m_server->dragInfoReceived(fileNum, content);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
ClientProxy1_5::sendClipboardThread(void* data)
|
|
||||||
{
|
|
||||||
//size_t id = reinterpret_cast<size_t>(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");
|
|
||||||
}
|
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
|
|
||||||
class Server;
|
class Server;
|
||||||
class IEventQueue;
|
class IEventQueue;
|
||||||
class Thread;
|
|
||||||
|
|
||||||
//! Proxy for client implementing protocol version 1.5
|
//! Proxy for client implementing protocol version 1.5
|
||||||
class ClientProxy1_5 : public ClientProxy1_4 {
|
class ClientProxy1_5 : public ClientProxy1_4 {
|
||||||
|
@ -38,10 +37,6 @@ public:
|
||||||
void fileChunkReceived();
|
void fileChunkReceived();
|
||||||
void dragInfoReceived();
|
void dragInfoReceived();
|
||||||
|
|
||||||
private:
|
|
||||||
// thread funciton for sending clipboard
|
|
||||||
void sendClipboardThread(void*);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
IEventQueue* m_events;
|
IEventQueue* m_events;
|
||||||
|
|
||||||
|
@ -49,5 +44,4 @@ private:
|
||||||
double m_elapsedTime;
|
double m_elapsedTime;
|
||||||
size_t m_receivedDataSize;
|
size_t m_receivedDataSize;
|
||||||
static const UInt16 m_intervalThreshold;
|
static const UInt16 m_intervalThreshold;
|
||||||
//Thread* m_sendFileThread;
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -91,7 +91,8 @@ Server::Server(
|
||||||
m_ignoreFileTransfer(false),
|
m_ignoreFileTransfer(false),
|
||||||
m_enableDragDrop(enableDragDrop),
|
m_enableDragDrop(enableDragDrop),
|
||||||
m_getDragInfoThread(NULL),
|
m_getDragInfoThread(NULL),
|
||||||
m_waitDragInfoThread(true)
|
m_waitDragInfoThread(true),
|
||||||
|
m_dataTransmissionThread(NULL)
|
||||||
{
|
{
|
||||||
// must have a primary client and it must have a canonical name
|
// must have a primary client and it must have a canonical name
|
||||||
assert(m_primaryClient != NULL);
|
assert(m_primaryClient != NULL);
|
||||||
|
@ -505,9 +506,10 @@ Server::switchScreen(BaseClientProxy* dst,
|
||||||
forScreensaver);
|
forScreensaver);
|
||||||
|
|
||||||
// send the clipboard data to new active screen
|
// send the clipboard data to new active screen
|
||||||
for (ClipboardID id = 0; id < kClipboardEnd; ++id) {
|
m_dataTransmissionThread = new Thread(
|
||||||
m_active->setClipboard(id, &m_clipboards[id].m_clipboard);
|
new TMethodJob<Server>(
|
||||||
}
|
this, &Server::clipboardTransmissionThread,
|
||||||
|
NULL));
|
||||||
|
|
||||||
Server::SwitchToScreenInfo* info =
|
Server::SwitchToScreenInfo* info =
|
||||||
Server::SwitchToScreenInfo::alloc(m_active->getName());
|
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
|
void
|
||||||
Server::onMouseMoveSecondary(SInt32 dx, SInt32 dy)
|
Server::onMouseMoveSecondary(SInt32 dx, SInt32 dy)
|
||||||
{
|
{
|
||||||
|
|
|
@ -370,6 +370,9 @@ private:
|
||||||
// send drag info to new client screen
|
// send drag info to new client screen
|
||||||
void sendDragInfo(BaseClientProxy* newScreen);
|
void sendDragInfo(BaseClientProxy* newScreen);
|
||||||
|
|
||||||
|
// thread funciton for sending clipboard
|
||||||
|
void clipboardTransmissionThread(void*);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool m_mock;
|
bool m_mock;
|
||||||
|
|
||||||
|
@ -480,4 +483,6 @@ private:
|
||||||
bool m_waitDragInfoThread;
|
bool m_waitDragInfoThread;
|
||||||
|
|
||||||
ClientListener* m_clientListener;
|
ClientListener* m_clientListener;
|
||||||
|
|
||||||
|
Thread* m_dataTransmissionThread;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue