mirror of
https://github.com/debauchee/barrier.git
synced 2026-07-08 21:06:51 +08:00
dropped "c" prefix from class names
This commit is contained in:
@@ -46,16 +46,16 @@
|
||||
#include <fstream>
|
||||
|
||||
//
|
||||
// CClient
|
||||
// Client
|
||||
//
|
||||
|
||||
CClient::CClient(
|
||||
Client::Client(
|
||||
IEventQueue* events,
|
||||
const CString& name, const CNetworkAddress& address,
|
||||
const String& name, const NetworkAddress& address,
|
||||
ISocketFactory* socketFactory,
|
||||
IStreamFilterFactory* streamFilterFactory,
|
||||
CScreen* screen,
|
||||
const CCryptoOptions& crypto,
|
||||
Screen* screen,
|
||||
const CryptoOptions& crypto,
|
||||
bool enableDragDrop) :
|
||||
m_mock(false),
|
||||
m_name(name),
|
||||
@@ -83,26 +83,26 @@ CClient::CClient(
|
||||
// register suspend/resume event handlers
|
||||
m_events->adoptHandler(m_events->forIScreen().suspend(),
|
||||
getEventTarget(),
|
||||
new TMethodEventJob<CClient>(this,
|
||||
&CClient::handleSuspend));
|
||||
new TMethodEventJob<Client>(this,
|
||||
&Client::handleSuspend));
|
||||
m_events->adoptHandler(m_events->forIScreen().resume(),
|
||||
getEventTarget(),
|
||||
new TMethodEventJob<CClient>(this,
|
||||
&CClient::handleResume));
|
||||
new TMethodEventJob<Client>(this,
|
||||
&Client::handleResume));
|
||||
|
||||
if (m_enableDragDrop) {
|
||||
m_events->adoptHandler(m_events->forIScreen().fileChunkSending(),
|
||||
this,
|
||||
new TMethodEventJob<CClient>(this,
|
||||
&CClient::handleFileChunkSending));
|
||||
new TMethodEventJob<Client>(this,
|
||||
&Client::handleFileChunkSending));
|
||||
m_events->adoptHandler(m_events->forIScreen().fileRecieveCompleted(),
|
||||
this,
|
||||
new TMethodEventJob<CClient>(this,
|
||||
&CClient::handleFileRecieveCompleted));
|
||||
new TMethodEventJob<Client>(this,
|
||||
&Client::handleFileRecieveCompleted));
|
||||
}
|
||||
}
|
||||
|
||||
CClient::~CClient()
|
||||
Client::~Client()
|
||||
{
|
||||
if (m_mock) {
|
||||
return;
|
||||
@@ -122,7 +122,7 @@ CClient::~CClient()
|
||||
}
|
||||
|
||||
void
|
||||
CClient::connect()
|
||||
Client::connect()
|
||||
{
|
||||
if (m_stream != NULL) {
|
||||
return;
|
||||
@@ -157,10 +157,10 @@ CClient::connect()
|
||||
if (m_streamFilterFactory != NULL) {
|
||||
m_stream = m_streamFilterFactory->create(m_stream, true);
|
||||
}
|
||||
m_stream = new CPacketStreamFilter(m_events, m_stream, true);
|
||||
m_stream = new PacketStreamFilter(m_events, m_stream, true);
|
||||
|
||||
if (m_crypto.m_mode != kDisabled) {
|
||||
m_cryptoStream = new CCryptoStream(
|
||||
m_cryptoStream = new CryptoStream(
|
||||
m_events, m_stream, m_crypto, true);
|
||||
m_stream = m_cryptoStream;
|
||||
}
|
||||
@@ -183,7 +183,7 @@ CClient::connect()
|
||||
}
|
||||
|
||||
void
|
||||
CClient::disconnect(const char* msg)
|
||||
Client::disconnect(const char* msg)
|
||||
{
|
||||
m_connectOnResume = false;
|
||||
cleanupTimer();
|
||||
@@ -194,20 +194,20 @@ CClient::disconnect(const char* msg)
|
||||
sendConnectionFailedEvent(msg);
|
||||
}
|
||||
else {
|
||||
sendEvent(m_events->forCClient().disconnected(), NULL);
|
||||
sendEvent(m_events->forClient().disconnected(), NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CClient::handshakeComplete()
|
||||
Client::handshakeComplete()
|
||||
{
|
||||
m_ready = true;
|
||||
m_screen->enable();
|
||||
sendEvent(m_events->forCClient().connected(), NULL);
|
||||
sendEvent(m_events->forClient().connected(), NULL);
|
||||
}
|
||||
|
||||
void
|
||||
CClient::setDecryptIv(const UInt8* iv)
|
||||
Client::setDecryptIv(const UInt8* iv)
|
||||
{
|
||||
if (m_cryptoStream != NULL) {
|
||||
m_cryptoStream->setDecryptIv(iv);
|
||||
@@ -215,49 +215,49 @@ CClient::setDecryptIv(const UInt8* iv)
|
||||
}
|
||||
|
||||
bool
|
||||
CClient::isConnected() const
|
||||
Client::isConnected() const
|
||||
{
|
||||
return (m_server != NULL);
|
||||
}
|
||||
|
||||
bool
|
||||
CClient::isConnecting() const
|
||||
Client::isConnecting() const
|
||||
{
|
||||
return (m_timer != NULL);
|
||||
}
|
||||
|
||||
CNetworkAddress
|
||||
CClient::getServerAddress() const
|
||||
NetworkAddress
|
||||
Client::getServerAddress() const
|
||||
{
|
||||
return m_serverAddress;
|
||||
}
|
||||
|
||||
void*
|
||||
CClient::getEventTarget() const
|
||||
Client::getEventTarget() const
|
||||
{
|
||||
return m_screen->getEventTarget();
|
||||
}
|
||||
|
||||
bool
|
||||
CClient::getClipboard(ClipboardID id, IClipboard* clipboard) const
|
||||
Client::getClipboard(ClipboardID id, IClipboard* clipboard) const
|
||||
{
|
||||
return m_screen->getClipboard(id, clipboard);
|
||||
}
|
||||
|
||||
void
|
||||
CClient::getShape(SInt32& x, SInt32& y, SInt32& w, SInt32& h) const
|
||||
Client::getShape(SInt32& x, SInt32& y, SInt32& w, SInt32& h) const
|
||||
{
|
||||
m_screen->getShape(x, y, w, h);
|
||||
}
|
||||
|
||||
void
|
||||
CClient::getCursorPos(SInt32& x, SInt32& y) const
|
||||
Client::getCursorPos(SInt32& x, SInt32& y) const
|
||||
{
|
||||
m_screen->getCursorPos(x, y);
|
||||
}
|
||||
|
||||
void
|
||||
CClient::enter(SInt32 xAbs, SInt32 yAbs, UInt32, KeyModifierMask mask, bool)
|
||||
Client::enter(SInt32 xAbs, SInt32 yAbs, UInt32, KeyModifierMask mask, bool)
|
||||
{
|
||||
m_active = true;
|
||||
m_screen->mouseMove(xAbs, yAbs);
|
||||
@@ -265,7 +265,7 @@ CClient::enter(SInt32 xAbs, SInt32 yAbs, UInt32, KeyModifierMask mask, bool)
|
||||
}
|
||||
|
||||
bool
|
||||
CClient::leave()
|
||||
Client::leave()
|
||||
{
|
||||
m_screen->leave();
|
||||
|
||||
@@ -282,7 +282,7 @@ CClient::leave()
|
||||
}
|
||||
|
||||
void
|
||||
CClient::setClipboard(ClipboardID id, const IClipboard* clipboard)
|
||||
Client::setClipboard(ClipboardID id, const IClipboard* clipboard)
|
||||
{
|
||||
m_screen->setClipboard(id, clipboard);
|
||||
m_ownClipboard[id] = false;
|
||||
@@ -290,7 +290,7 @@ CClient::setClipboard(ClipboardID id, const IClipboard* clipboard)
|
||||
}
|
||||
|
||||
void
|
||||
CClient::grabClipboard(ClipboardID id)
|
||||
Client::grabClipboard(ClipboardID id)
|
||||
{
|
||||
m_screen->grabClipboard(id);
|
||||
m_ownClipboard[id] = false;
|
||||
@@ -298,86 +298,86 @@ CClient::grabClipboard(ClipboardID id)
|
||||
}
|
||||
|
||||
void
|
||||
CClient::setClipboardDirty(ClipboardID, bool)
|
||||
Client::setClipboardDirty(ClipboardID, bool)
|
||||
{
|
||||
assert(0 && "shouldn't be called");
|
||||
}
|
||||
|
||||
void
|
||||
CClient::keyDown(KeyID id, KeyModifierMask mask, KeyButton button)
|
||||
Client::keyDown(KeyID id, KeyModifierMask mask, KeyButton button)
|
||||
{
|
||||
m_screen->keyDown(id, mask, button);
|
||||
}
|
||||
|
||||
void
|
||||
CClient::keyRepeat(KeyID id, KeyModifierMask mask,
|
||||
Client::keyRepeat(KeyID id, KeyModifierMask mask,
|
||||
SInt32 count, KeyButton button)
|
||||
{
|
||||
m_screen->keyRepeat(id, mask, count, button);
|
||||
}
|
||||
|
||||
void
|
||||
CClient::keyUp(KeyID id, KeyModifierMask mask, KeyButton button)
|
||||
Client::keyUp(KeyID id, KeyModifierMask mask, KeyButton button)
|
||||
{
|
||||
m_screen->keyUp(id, mask, button);
|
||||
}
|
||||
|
||||
void
|
||||
CClient::mouseDown(ButtonID id)
|
||||
Client::mouseDown(ButtonID id)
|
||||
{
|
||||
m_screen->mouseDown(id);
|
||||
}
|
||||
|
||||
void
|
||||
CClient::mouseUp(ButtonID id)
|
||||
Client::mouseUp(ButtonID id)
|
||||
{
|
||||
m_screen->mouseUp(id);
|
||||
}
|
||||
|
||||
void
|
||||
CClient::mouseMove(SInt32 x, SInt32 y)
|
||||
Client::mouseMove(SInt32 x, SInt32 y)
|
||||
{
|
||||
m_screen->mouseMove(x, y);
|
||||
}
|
||||
|
||||
void
|
||||
CClient::mouseRelativeMove(SInt32 dx, SInt32 dy)
|
||||
Client::mouseRelativeMove(SInt32 dx, SInt32 dy)
|
||||
{
|
||||
m_screen->mouseRelativeMove(dx, dy);
|
||||
}
|
||||
|
||||
void
|
||||
CClient::mouseWheel(SInt32 xDelta, SInt32 yDelta)
|
||||
Client::mouseWheel(SInt32 xDelta, SInt32 yDelta)
|
||||
{
|
||||
m_screen->mouseWheel(xDelta, yDelta);
|
||||
}
|
||||
|
||||
void
|
||||
CClient::screensaver(bool activate)
|
||||
Client::screensaver(bool activate)
|
||||
{
|
||||
m_screen->screensaver(activate);
|
||||
}
|
||||
|
||||
void
|
||||
CClient::resetOptions()
|
||||
Client::resetOptions()
|
||||
{
|
||||
m_screen->resetOptions();
|
||||
}
|
||||
|
||||
void
|
||||
CClient::setOptions(const COptionsList& options)
|
||||
Client::setOptions(const OptionsList& options)
|
||||
{
|
||||
m_screen->setOptions(options);
|
||||
}
|
||||
|
||||
CString
|
||||
CClient::getName() const
|
||||
String
|
||||
Client::getName() const
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
|
||||
void
|
||||
CClient::sendClipboard(ClipboardID id)
|
||||
Client::sendClipboard(ClipboardID id)
|
||||
{
|
||||
// note -- m_mutex must be locked on entry
|
||||
assert(m_screen != NULL);
|
||||
@@ -387,7 +387,7 @@ CClient::sendClipboard(ClipboardID id)
|
||||
// clipboard time before getting the data from the screen
|
||||
// as the screen may detect an unchanged clipboard and
|
||||
// avoid copying the data.
|
||||
CClipboard clipboard;
|
||||
Clipboard clipboard;
|
||||
if (clipboard.open(m_timeClipboard[id])) {
|
||||
clipboard.close();
|
||||
}
|
||||
@@ -400,7 +400,7 @@ CClient::sendClipboard(ClipboardID id)
|
||||
m_timeClipboard[id] = clipboard.getTime();
|
||||
|
||||
// marshall the data
|
||||
CString data = clipboard.marshall();
|
||||
String data = clipboard.marshall();
|
||||
|
||||
// save and send data if different or not yet sent
|
||||
if (!m_sentClipboard[id] || data != m_dataClipboard[id]) {
|
||||
@@ -412,24 +412,24 @@ CClient::sendClipboard(ClipboardID id)
|
||||
}
|
||||
|
||||
void
|
||||
CClient::sendEvent(CEvent::Type type, void* data)
|
||||
Client::sendEvent(Event::Type type, void* data)
|
||||
{
|
||||
m_events->addEvent(CEvent(type, getEventTarget(), data));
|
||||
m_events->addEvent(Event(type, getEventTarget(), data));
|
||||
}
|
||||
|
||||
void
|
||||
CClient::sendConnectionFailedEvent(const char* msg)
|
||||
Client::sendConnectionFailedEvent(const char* msg)
|
||||
{
|
||||
CFailInfo* info = new CFailInfo(msg);
|
||||
FailInfo* info = new FailInfo(msg);
|
||||
info->m_retry = true;
|
||||
CEvent event(m_events->forCClient().connectionFailed(), getEventTarget(), info, CEvent::kDontFreeData);
|
||||
Event event(m_events->forClient().connectionFailed(), getEventTarget(), info, Event::kDontFreeData);
|
||||
m_events->addEvent(event);
|
||||
}
|
||||
|
||||
void
|
||||
CClient::sendFileChunk(const void* data)
|
||||
Client::sendFileChunk(const void* data)
|
||||
{
|
||||
CFileChunker::CFileChunk* fileChunk = reinterpret_cast<CFileChunker::CFileChunk*>(const_cast<void*>(data));
|
||||
FileChunker::FileChunk* fileChunk = reinterpret_cast<FileChunker::FileChunk*>(const_cast<void*>(data));
|
||||
LOG((CLOG_DEBUG1 "sendFileChunk"));
|
||||
assert(m_server != NULL);
|
||||
|
||||
@@ -438,77 +438,77 @@ CClient::sendFileChunk(const void* data)
|
||||
}
|
||||
|
||||
void
|
||||
CClient::setupConnecting()
|
||||
Client::setupConnecting()
|
||||
{
|
||||
assert(m_stream != NULL);
|
||||
|
||||
m_events->adoptHandler(m_events->forIDataSocket().connected(),
|
||||
m_stream->getEventTarget(),
|
||||
new TMethodEventJob<CClient>(this,
|
||||
&CClient::handleConnected));
|
||||
new TMethodEventJob<Client>(this,
|
||||
&Client::handleConnected));
|
||||
m_events->adoptHandler(m_events->forIDataSocket().connectionFailed(),
|
||||
m_stream->getEventTarget(),
|
||||
new TMethodEventJob<CClient>(this,
|
||||
&CClient::handleConnectionFailed));
|
||||
new TMethodEventJob<Client>(this,
|
||||
&Client::handleConnectionFailed));
|
||||
}
|
||||
|
||||
void
|
||||
CClient::setupConnection()
|
||||
Client::setupConnection()
|
||||
{
|
||||
assert(m_stream != NULL);
|
||||
|
||||
m_events->adoptHandler(m_events->forISocket().disconnected(),
|
||||
m_stream->getEventTarget(),
|
||||
new TMethodEventJob<CClient>(this,
|
||||
&CClient::handleDisconnected));
|
||||
new TMethodEventJob<Client>(this,
|
||||
&Client::handleDisconnected));
|
||||
m_events->adoptHandler(m_events->forIStream().inputReady(),
|
||||
m_stream->getEventTarget(),
|
||||
new TMethodEventJob<CClient>(this,
|
||||
&CClient::handleHello));
|
||||
new TMethodEventJob<Client>(this,
|
||||
&Client::handleHello));
|
||||
m_events->adoptHandler(m_events->forIStream().outputError(),
|
||||
m_stream->getEventTarget(),
|
||||
new TMethodEventJob<CClient>(this,
|
||||
&CClient::handleOutputError));
|
||||
new TMethodEventJob<Client>(this,
|
||||
&Client::handleOutputError));
|
||||
m_events->adoptHandler(m_events->forIStream().inputShutdown(),
|
||||
m_stream->getEventTarget(),
|
||||
new TMethodEventJob<CClient>(this,
|
||||
&CClient::handleDisconnected));
|
||||
new TMethodEventJob<Client>(this,
|
||||
&Client::handleDisconnected));
|
||||
m_events->adoptHandler(m_events->forIStream().outputShutdown(),
|
||||
m_stream->getEventTarget(),
|
||||
new TMethodEventJob<CClient>(this,
|
||||
&CClient::handleDisconnected));
|
||||
new TMethodEventJob<Client>(this,
|
||||
&Client::handleDisconnected));
|
||||
}
|
||||
|
||||
void
|
||||
CClient::setupScreen()
|
||||
Client::setupScreen()
|
||||
{
|
||||
assert(m_server == NULL);
|
||||
|
||||
m_ready = false;
|
||||
m_server = new CServerProxy(this, m_stream, m_events);
|
||||
m_server = new ServerProxy(this, m_stream, m_events);
|
||||
m_events->adoptHandler(m_events->forIScreen().shapeChanged(),
|
||||
getEventTarget(),
|
||||
new TMethodEventJob<CClient>(this,
|
||||
&CClient::handleShapeChanged));
|
||||
new TMethodEventJob<Client>(this,
|
||||
&Client::handleShapeChanged));
|
||||
m_events->adoptHandler(m_events->forIScreen().clipboardGrabbed(),
|
||||
getEventTarget(),
|
||||
new TMethodEventJob<CClient>(this,
|
||||
&CClient::handleClipboardGrabbed));
|
||||
new TMethodEventJob<Client>(this,
|
||||
&Client::handleClipboardGrabbed));
|
||||
}
|
||||
|
||||
void
|
||||
CClient::setupTimer()
|
||||
Client::setupTimer()
|
||||
{
|
||||
assert(m_timer == NULL);
|
||||
|
||||
m_timer = m_events->newOneShotTimer(15.0, NULL);
|
||||
m_events->adoptHandler(CEvent::kTimer, m_timer,
|
||||
new TMethodEventJob<CClient>(this,
|
||||
&CClient::handleConnectTimeout));
|
||||
m_events->adoptHandler(Event::kTimer, m_timer,
|
||||
new TMethodEventJob<Client>(this,
|
||||
&Client::handleConnectTimeout));
|
||||
}
|
||||
|
||||
void
|
||||
CClient::cleanupConnecting()
|
||||
Client::cleanupConnecting()
|
||||
{
|
||||
if (m_stream != NULL) {
|
||||
m_events->removeHandler(m_events->forIDataSocket().connected(),
|
||||
@@ -519,7 +519,7 @@ CClient::cleanupConnecting()
|
||||
}
|
||||
|
||||
void
|
||||
CClient::cleanupConnection()
|
||||
Client::cleanupConnection()
|
||||
{
|
||||
if (m_stream != NULL) {
|
||||
m_events->removeHandler(m_events->forIStream().inputReady(),
|
||||
@@ -538,7 +538,7 @@ CClient::cleanupConnection()
|
||||
}
|
||||
|
||||
void
|
||||
CClient::cleanupScreen()
|
||||
Client::cleanupScreen()
|
||||
{
|
||||
if (m_server != NULL) {
|
||||
if (m_ready) {
|
||||
@@ -555,17 +555,17 @@ CClient::cleanupScreen()
|
||||
}
|
||||
|
||||
void
|
||||
CClient::cleanupTimer()
|
||||
Client::cleanupTimer()
|
||||
{
|
||||
if (m_timer != NULL) {
|
||||
m_events->removeHandler(CEvent::kTimer, m_timer);
|
||||
m_events->removeHandler(Event::kTimer, m_timer);
|
||||
m_events->deleteTimer(m_timer);
|
||||
m_timer = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CClient::handleConnected(const CEvent&, void*)
|
||||
Client::handleConnected(const Event&, void*)
|
||||
{
|
||||
LOG((CLOG_DEBUG1 "connected; wait for hello"));
|
||||
cleanupConnecting();
|
||||
@@ -580,10 +580,10 @@ CClient::handleConnected(const CEvent&, void*)
|
||||
}
|
||||
|
||||
void
|
||||
CClient::handleConnectionFailed(const CEvent& event, void*)
|
||||
Client::handleConnectionFailed(const Event& event, void*)
|
||||
{
|
||||
IDataSocket::CConnectionFailedInfo* info =
|
||||
reinterpret_cast<IDataSocket::CConnectionFailedInfo*>(event.getData());
|
||||
IDataSocket::ConnectionFailedInfo* info =
|
||||
reinterpret_cast<IDataSocket::ConnectionFailedInfo*>(event.getData());
|
||||
|
||||
cleanupTimer();
|
||||
cleanupConnecting();
|
||||
@@ -595,7 +595,7 @@ CClient::handleConnectionFailed(const CEvent& event, void*)
|
||||
}
|
||||
|
||||
void
|
||||
CClient::handleConnectTimeout(const CEvent&, void*)
|
||||
Client::handleConnectTimeout(const Event&, void*)
|
||||
{
|
||||
cleanupTimer();
|
||||
cleanupConnecting();
|
||||
@@ -607,37 +607,37 @@ CClient::handleConnectTimeout(const CEvent&, void*)
|
||||
}
|
||||
|
||||
void
|
||||
CClient::handleOutputError(const CEvent&, void*)
|
||||
Client::handleOutputError(const Event&, void*)
|
||||
{
|
||||
cleanupTimer();
|
||||
cleanupScreen();
|
||||
cleanupConnection();
|
||||
LOG((CLOG_WARN "error sending to server"));
|
||||
sendEvent(m_events->forCClient().disconnected(), NULL);
|
||||
sendEvent(m_events->forClient().disconnected(), NULL);
|
||||
}
|
||||
|
||||
void
|
||||
CClient::handleDisconnected(const CEvent&, void*)
|
||||
Client::handleDisconnected(const Event&, void*)
|
||||
{
|
||||
cleanupTimer();
|
||||
cleanupScreen();
|
||||
cleanupConnection();
|
||||
LOG((CLOG_DEBUG1 "disconnected"));
|
||||
sendEvent(m_events->forCClient().disconnected(), NULL);
|
||||
sendEvent(m_events->forClient().disconnected(), NULL);
|
||||
}
|
||||
|
||||
void
|
||||
CClient::handleShapeChanged(const CEvent&, void*)
|
||||
Client::handleShapeChanged(const Event&, void*)
|
||||
{
|
||||
LOG((CLOG_DEBUG "resolution changed"));
|
||||
m_server->onInfoChanged();
|
||||
}
|
||||
|
||||
void
|
||||
CClient::handleClipboardGrabbed(const CEvent& event, void*)
|
||||
Client::handleClipboardGrabbed(const Event& event, void*)
|
||||
{
|
||||
const IScreen::CClipboardInfo* info =
|
||||
reinterpret_cast<const IScreen::CClipboardInfo*>(event.getData());
|
||||
const IScreen::ClipboardInfo* info =
|
||||
reinterpret_cast<const IScreen::ClipboardInfo*>(event.getData());
|
||||
|
||||
// grab ownership
|
||||
m_server->onGrabClipboard(info->m_id);
|
||||
@@ -655,10 +655,10 @@ CClient::handleClipboardGrabbed(const CEvent& event, void*)
|
||||
}
|
||||
|
||||
void
|
||||
CClient::handleHello(const CEvent&, void*)
|
||||
Client::handleHello(const Event&, void*)
|
||||
{
|
||||
SInt16 major, minor;
|
||||
if (!CProtocolUtil::readf(m_stream, kMsgHello, &major, &minor)) {
|
||||
if (!ProtocolUtil::readf(m_stream, kMsgHello, &major, &minor)) {
|
||||
sendConnectionFailedEvent("Protocol error from server");
|
||||
cleanupTimer();
|
||||
cleanupConnection();
|
||||
@@ -677,7 +677,7 @@ CClient::handleHello(const CEvent&, void*)
|
||||
|
||||
// say hello back
|
||||
LOG((CLOG_DEBUG1 "say hello version %d.%d", kProtocolMajorVersion, kProtocolMinorVersion));
|
||||
CProtocolUtil::writef(m_stream, kMsgHelloBack,
|
||||
ProtocolUtil::writef(m_stream, kMsgHelloBack,
|
||||
kProtocolMajorVersion,
|
||||
kProtocolMinorVersion, &m_name);
|
||||
|
||||
@@ -689,13 +689,13 @@ CClient::handleHello(const CEvent&, void*)
|
||||
// receive another event for already pending messages so we fake
|
||||
// one.
|
||||
if (m_stream->isReady()) {
|
||||
m_events->addEvent(CEvent(m_events->forIStream().inputReady(),
|
||||
m_events->addEvent(Event(m_events->forIStream().inputReady(),
|
||||
m_stream->getEventTarget()));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CClient::handleSuspend(const CEvent&, void*)
|
||||
Client::handleSuspend(const Event&, void*)
|
||||
{
|
||||
LOG((CLOG_INFO "suspend"));
|
||||
m_suspended = true;
|
||||
@@ -705,7 +705,7 @@ CClient::handleSuspend(const CEvent&, void*)
|
||||
}
|
||||
|
||||
void
|
||||
CClient::handleResume(const CEvent&, void*)
|
||||
Client::handleResume(const Event&, void*)
|
||||
{
|
||||
LOG((CLOG_INFO "resume"));
|
||||
m_suspended = false;
|
||||
@@ -716,30 +716,30 @@ CClient::handleResume(const CEvent&, void*)
|
||||
}
|
||||
|
||||
void
|
||||
CClient::handleFileChunkSending(const CEvent& event, void*)
|
||||
Client::handleFileChunkSending(const Event& event, void*)
|
||||
{
|
||||
sendFileChunk(event.getData());
|
||||
}
|
||||
|
||||
void
|
||||
CClient::handleFileRecieveCompleted(const CEvent& event, void*)
|
||||
Client::handleFileRecieveCompleted(const Event& event, void*)
|
||||
{
|
||||
onFileRecieveCompleted();
|
||||
}
|
||||
|
||||
void
|
||||
CClient::onFileRecieveCompleted()
|
||||
Client::onFileRecieveCompleted()
|
||||
{
|
||||
if (isReceivedFileSizeValid()) {
|
||||
m_writeToDropDirThread = new CThread(
|
||||
new TMethodJob<CClient>(
|
||||
this, &CClient::writeToDropDirThread));
|
||||
m_writeToDropDirThread = new Thread(
|
||||
new TMethodJob<Client>(
|
||||
this, &Client::writeToDropDirThread));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CClient::writeToDropDirThread(void*)
|
||||
Client::writeToDropDirThread(void*)
|
||||
{
|
||||
LOG((CLOG_DEBUG "starting write to drop dir thread"));
|
||||
|
||||
@@ -747,63 +747,63 @@ CClient::writeToDropDirThread(void*)
|
||||
ARCH->sleep(.1f);
|
||||
}
|
||||
|
||||
CDropHelper::writeToDir(m_screen->getDropTarget(), m_dragFileList,
|
||||
DropHelper::writeToDir(m_screen->getDropTarget(), m_dragFileList,
|
||||
m_receivedFileData);
|
||||
}
|
||||
|
||||
void
|
||||
CClient::clearReceivedFileData()
|
||||
Client::clearReceivedFileData()
|
||||
{
|
||||
m_receivedFileData.clear();
|
||||
}
|
||||
|
||||
void
|
||||
CClient::setExpectedFileSize(CString data)
|
||||
Client::setExpectedFileSize(String data)
|
||||
{
|
||||
std::istringstream iss(data);
|
||||
iss >> m_expectedFileSize;
|
||||
}
|
||||
|
||||
void
|
||||
CClient::fileChunkReceived(CString data)
|
||||
Client::fileChunkReceived(String data)
|
||||
{
|
||||
m_receivedFileData += data;
|
||||
}
|
||||
|
||||
void
|
||||
CClient::dragInfoReceived(UInt32 fileNum, CString data)
|
||||
Client::dragInfoReceived(UInt32 fileNum, String data)
|
||||
{
|
||||
if (!m_enableDragDrop) {
|
||||
LOG((CLOG_DEBUG "drag drop not enabled, ignoring drag info."));
|
||||
return;
|
||||
}
|
||||
|
||||
CDragInformation::parseDragInfo(m_dragFileList, fileNum, data);
|
||||
DragInformation::parseDragInfo(m_dragFileList, fileNum, data);
|
||||
|
||||
m_screen->startDraggingFiles(m_dragFileList);
|
||||
}
|
||||
|
||||
bool
|
||||
CClient::isReceivedFileSizeValid()
|
||||
Client::isReceivedFileSizeValid()
|
||||
{
|
||||
return m_expectedFileSize == m_receivedFileData.size();
|
||||
}
|
||||
|
||||
void
|
||||
CClient::sendFileToServer(const char* filename)
|
||||
Client::sendFileToServer(const char* filename)
|
||||
{
|
||||
m_sendFileThread = new CThread(
|
||||
new TMethodJob<CClient>(
|
||||
this, &CClient::sendFileThread,
|
||||
m_sendFileThread = new Thread(
|
||||
new TMethodJob<Client>(
|
||||
this, &Client::sendFileThread,
|
||||
reinterpret_cast<void*>(const_cast<char*>(filename))));
|
||||
}
|
||||
|
||||
void
|
||||
CClient::sendFileThread(void* filename)
|
||||
Client::sendFileThread(void* filename)
|
||||
{
|
||||
try {
|
||||
char* name = reinterpret_cast<char*>(filename);
|
||||
CFileChunker::sendFileChunks(name, m_events, this);
|
||||
FileChunker::sendFileChunks(name, m_events, this);
|
||||
}
|
||||
catch (std::runtime_error error) {
|
||||
LOG((CLOG_ERR "failed sending file chunks: %s", error.what()));
|
||||
@@ -813,7 +813,7 @@ CClient::sendFileThread(void* filename)
|
||||
}
|
||||
|
||||
void
|
||||
CClient::sendDragInfo(UInt32 fileCount, CString& info, size_t size)
|
||||
Client::sendDragInfo(UInt32 fileCount, String& info, size_t size)
|
||||
{
|
||||
m_server->sendDragInfo(fileCount, info.c_str(), size);
|
||||
}
|
||||
|
||||
@@ -27,28 +27,28 @@
|
||||
#include "io/CryptoOptions.h"
|
||||
#include "base/EventTypes.h"
|
||||
|
||||
class CEventQueueTimer;
|
||||
class CScreen;
|
||||
class CServerProxy;
|
||||
class EventQueueTimer;
|
||||
class Screen;
|
||||
class ServerProxy;
|
||||
class IDataSocket;
|
||||
class ISocketFactory;
|
||||
namespace synergy { class IStream; }
|
||||
class IStreamFilterFactory;
|
||||
class IEventQueue;
|
||||
class CCryptoStream;
|
||||
class CThread;
|
||||
class CryptoStream;
|
||||
class Thread;
|
||||
|
||||
//! Synergy client
|
||||
/*!
|
||||
This class implements the top-level client algorithms for synergy.
|
||||
*/
|
||||
class CClient : public IClient, public INode {
|
||||
class Client : public IClient, public INode {
|
||||
public:
|
||||
class CFailInfo {
|
||||
class FailInfo {
|
||||
public:
|
||||
CFailInfo(const char* what) : m_retry(false), m_what(what) { }
|
||||
FailInfo(const char* what) : m_retry(false), m_what(what) { }
|
||||
bool m_retry;
|
||||
CString m_what;
|
||||
String m_what;
|
||||
};
|
||||
|
||||
public:
|
||||
@@ -57,17 +57,17 @@ public:
|
||||
as its name and \p address as the server's address and \p factory
|
||||
to create the socket. \p screen is the local screen.
|
||||
*/
|
||||
CClient(IEventQueue* events,
|
||||
const CString& name, const CNetworkAddress& address,
|
||||
Client(IEventQueue* events,
|
||||
const String& name, const NetworkAddress& address,
|
||||
ISocketFactory* socketFactory,
|
||||
IStreamFilterFactory* streamFilterFactory,
|
||||
CScreen* screen,
|
||||
const CCryptoOptions& crypto,
|
||||
Screen* screen,
|
||||
const CryptoOptions& crypto,
|
||||
bool enableDragDrop);
|
||||
~CClient();
|
||||
~Client();
|
||||
|
||||
#ifdef TEST_ENV
|
||||
CClient() : m_mock(true) { }
|
||||
Client() : m_mock(true) { }
|
||||
#endif
|
||||
|
||||
//! @name manipulators
|
||||
@@ -99,19 +99,19 @@ public:
|
||||
void clearReceivedFileData();
|
||||
|
||||
//! Set the expected size of receiving file
|
||||
void setExpectedFileSize(CString data);
|
||||
void setExpectedFileSize(String data);
|
||||
|
||||
//! Received a chunk of file data
|
||||
void fileChunkReceived(CString data);
|
||||
void fileChunkReceived(String data);
|
||||
|
||||
//! Received drag information
|
||||
void dragInfoReceived(UInt32 fileNum, CString data);
|
||||
void dragInfoReceived(UInt32 fileNum, String data);
|
||||
|
||||
//! Create a new thread and use it to send file to Server
|
||||
void sendFileToServer(const char* filename);
|
||||
|
||||
//! Send dragging file information back to server
|
||||
void sendDragInfo(UInt32 fileCount, CString& info, size_t size);
|
||||
void sendDragInfo(UInt32 fileCount, String& info, size_t size);
|
||||
|
||||
//@}
|
||||
//! @name accessors
|
||||
@@ -135,7 +135,7 @@ public:
|
||||
Returns the address of the server the client is connected (or wants
|
||||
to connect) to.
|
||||
*/
|
||||
CNetworkAddress getServerAddress() const;
|
||||
NetworkAddress getServerAddress() const;
|
||||
|
||||
//! Return true if recieved file size is valid
|
||||
bool isReceivedFileSizeValid();
|
||||
@@ -171,12 +171,12 @@ public:
|
||||
virtual void mouseWheel(SInt32 xDelta, SInt32 yDelta);
|
||||
virtual void screensaver(bool activate);
|
||||
virtual void resetOptions();
|
||||
virtual void setOptions(const COptionsList& options);
|
||||
virtual CString getName() const;
|
||||
virtual void setOptions(const OptionsList& options);
|
||||
virtual String getName() const;
|
||||
|
||||
private:
|
||||
void sendClipboard(ClipboardID);
|
||||
void sendEvent(CEvent::Type, void*);
|
||||
void sendEvent(Event::Type, void*);
|
||||
void sendConnectionFailedEvent(const char* msg);
|
||||
void sendFileChunk(const void* data);
|
||||
void sendFileThread(void*);
|
||||
@@ -189,32 +189,32 @@ private:
|
||||
void cleanupConnection();
|
||||
void cleanupScreen();
|
||||
void cleanupTimer();
|
||||
void handleConnected(const CEvent&, void*);
|
||||
void handleConnectionFailed(const CEvent&, void*);
|
||||
void handleConnectTimeout(const CEvent&, void*);
|
||||
void handleOutputError(const CEvent&, void*);
|
||||
void handleDisconnected(const CEvent&, void*);
|
||||
void handleShapeChanged(const CEvent&, void*);
|
||||
void handleClipboardGrabbed(const CEvent&, void*);
|
||||
void handleHello(const CEvent&, void*);
|
||||
void handleSuspend(const CEvent& event, void*);
|
||||
void handleResume(const CEvent& event, void*);
|
||||
void handleFileChunkSending(const CEvent&, void*);
|
||||
void handleFileRecieveCompleted(const CEvent&, void*);
|
||||
void handleConnected(const Event&, void*);
|
||||
void handleConnectionFailed(const Event&, void*);
|
||||
void handleConnectTimeout(const Event&, void*);
|
||||
void handleOutputError(const Event&, void*);
|
||||
void handleDisconnected(const Event&, void*);
|
||||
void handleShapeChanged(const Event&, void*);
|
||||
void handleClipboardGrabbed(const Event&, void*);
|
||||
void handleHello(const Event&, void*);
|
||||
void handleSuspend(const Event& event, void*);
|
||||
void handleResume(const Event& event, void*);
|
||||
void handleFileChunkSending(const Event&, void*);
|
||||
void handleFileRecieveCompleted(const Event&, void*);
|
||||
void onFileRecieveCompleted();
|
||||
|
||||
public:
|
||||
bool m_mock;
|
||||
|
||||
private:
|
||||
CString m_name;
|
||||
CNetworkAddress m_serverAddress;
|
||||
String m_name;
|
||||
NetworkAddress m_serverAddress;
|
||||
ISocketFactory* m_socketFactory;
|
||||
IStreamFilterFactory* m_streamFilterFactory;
|
||||
CScreen* m_screen;
|
||||
Screen* m_screen;
|
||||
synergy::IStream* m_stream;
|
||||
CEventQueueTimer* m_timer;
|
||||
CServerProxy* m_server;
|
||||
EventQueueTimer* m_timer;
|
||||
ServerProxy* m_server;
|
||||
bool m_ready;
|
||||
bool m_active;
|
||||
bool m_suspended;
|
||||
@@ -222,15 +222,15 @@ private:
|
||||
bool m_ownClipboard[kClipboardEnd];
|
||||
bool m_sentClipboard[kClipboardEnd];
|
||||
IClipboard::Time m_timeClipboard[kClipboardEnd];
|
||||
CString m_dataClipboard[kClipboardEnd];
|
||||
String m_dataClipboard[kClipboardEnd];
|
||||
IEventQueue* m_events;
|
||||
CCryptoStream* m_cryptoStream;
|
||||
CCryptoOptions m_crypto;
|
||||
CryptoStream* m_cryptoStream;
|
||||
CryptoOptions m_crypto;
|
||||
std::size_t m_expectedFileSize;
|
||||
CString m_receivedFileData;
|
||||
CDragFileList m_dragFileList;
|
||||
CString m_dragFileExt;
|
||||
CThread* m_sendFileThread;
|
||||
CThread* m_writeToDropDirThread;
|
||||
String m_receivedFileData;
|
||||
DragFileList m_dragFileList;
|
||||
String m_dragFileExt;
|
||||
Thread* m_sendFileThread;
|
||||
Thread* m_writeToDropDirThread;
|
||||
bool m_enableDragDrop;
|
||||
};
|
||||
|
||||
@@ -33,12 +33,12 @@
|
||||
#include <memory>
|
||||
|
||||
//
|
||||
// CServerProxy
|
||||
// ServerProxy
|
||||
//
|
||||
|
||||
const UInt16 CServerProxy::m_intervalThreshold = 1;
|
||||
const UInt16 ServerProxy::m_intervalThreshold = 1;
|
||||
|
||||
CServerProxy::CServerProxy(CClient* client, synergy::IStream* stream, IEventQueue* events) :
|
||||
ServerProxy::ServerProxy(Client* client, synergy::IStream* stream, IEventQueue* events) :
|
||||
m_client(client),
|
||||
m_stream(stream),
|
||||
m_seqNum(0),
|
||||
@@ -51,7 +51,7 @@ CServerProxy::CServerProxy(CClient* client, synergy::IStream* stream, IEventQueu
|
||||
m_ignoreMouse(false),
|
||||
m_keepAliveAlarm(0.0),
|
||||
m_keepAliveAlarmTimer(NULL),
|
||||
m_parser(&CServerProxy::parseHandshakeMessage),
|
||||
m_parser(&ServerProxy::parseHandshakeMessage),
|
||||
m_events(events),
|
||||
m_stopwatch(true),
|
||||
m_elapsedTime(0),
|
||||
@@ -67,14 +67,14 @@ CServerProxy::CServerProxy(CClient* client, synergy::IStream* stream, IEventQueu
|
||||
// handle data on stream
|
||||
m_events->adoptHandler(m_events->forIStream().inputReady(),
|
||||
m_stream->getEventTarget(),
|
||||
new TMethodEventJob<CServerProxy>(this,
|
||||
&CServerProxy::handleData));
|
||||
new TMethodEventJob<ServerProxy>(this,
|
||||
&ServerProxy::handleData));
|
||||
|
||||
// send heartbeat
|
||||
setKeepAliveRate(kKeepAliveRate);
|
||||
}
|
||||
|
||||
CServerProxy::~CServerProxy()
|
||||
ServerProxy::~ServerProxy()
|
||||
{
|
||||
setKeepAliveRate(-1.0);
|
||||
m_events->removeHandler(m_events->forIStream().inputReady(),
|
||||
@@ -82,31 +82,31 @@ CServerProxy::~CServerProxy()
|
||||
}
|
||||
|
||||
void
|
||||
CServerProxy::resetKeepAliveAlarm()
|
||||
ServerProxy::resetKeepAliveAlarm()
|
||||
{
|
||||
if (m_keepAliveAlarmTimer != NULL) {
|
||||
m_events->removeHandler(CEvent::kTimer, m_keepAliveAlarmTimer);
|
||||
m_events->removeHandler(Event::kTimer, m_keepAliveAlarmTimer);
|
||||
m_events->deleteTimer(m_keepAliveAlarmTimer);
|
||||
m_keepAliveAlarmTimer = NULL;
|
||||
}
|
||||
if (m_keepAliveAlarm > 0.0) {
|
||||
m_keepAliveAlarmTimer =
|
||||
m_events->newOneShotTimer(m_keepAliveAlarm, NULL);
|
||||
m_events->adoptHandler(CEvent::kTimer, m_keepAliveAlarmTimer,
|
||||
new TMethodEventJob<CServerProxy>(this,
|
||||
&CServerProxy::handleKeepAliveAlarm));
|
||||
m_events->adoptHandler(Event::kTimer, m_keepAliveAlarmTimer,
|
||||
new TMethodEventJob<ServerProxy>(this,
|
||||
&ServerProxy::handleKeepAliveAlarm));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CServerProxy::setKeepAliveRate(double rate)
|
||||
ServerProxy::setKeepAliveRate(double rate)
|
||||
{
|
||||
m_keepAliveAlarm = rate * kKeepAlivesUntilDeath;
|
||||
resetKeepAliveAlarm();
|
||||
}
|
||||
|
||||
void
|
||||
CServerProxy::handleData(const CEvent&, void*)
|
||||
ServerProxy::handleData(const Event&, void*)
|
||||
{
|
||||
// handle messages until there are no more. first read message code.
|
||||
UInt8 code[4];
|
||||
@@ -141,8 +141,8 @@ CServerProxy::handleData(const CEvent&, void*)
|
||||
flushCompressedMouse();
|
||||
}
|
||||
|
||||
CServerProxy::EResult
|
||||
CServerProxy::parseHandshakeMessage(const UInt8* code)
|
||||
ServerProxy::EResult
|
||||
ServerProxy::parseHandshakeMessage(const UInt8* code)
|
||||
{
|
||||
if (memcmp(code, kMsgQInfo, 4) == 0) {
|
||||
queryInfo();
|
||||
@@ -156,7 +156,7 @@ CServerProxy::parseHandshakeMessage(const UInt8* code)
|
||||
setOptions();
|
||||
|
||||
// handshake is complete
|
||||
m_parser = &CServerProxy::parseMessage;
|
||||
m_parser = &ServerProxy::parseMessage;
|
||||
m_client->handshakeComplete();
|
||||
}
|
||||
|
||||
@@ -166,7 +166,7 @@ CServerProxy::parseHandshakeMessage(const UInt8* code)
|
||||
|
||||
else if (memcmp(code, kMsgCKeepAlive, 4) == 0) {
|
||||
// echo keep alives and reset alarm
|
||||
CProtocolUtil::writef(m_stream, kMsgCKeepAlive);
|
||||
ProtocolUtil::writef(m_stream, kMsgCKeepAlive);
|
||||
resetKeepAliveAlarm();
|
||||
}
|
||||
|
||||
@@ -183,7 +183,7 @@ CServerProxy::parseHandshakeMessage(const UInt8* code)
|
||||
|
||||
else if (memcmp(code, kMsgEIncompatible, 4) == 0) {
|
||||
SInt32 major, minor;
|
||||
CProtocolUtil::readf(m_stream,
|
||||
ProtocolUtil::readf(m_stream,
|
||||
kMsgEIncompatible + 4, &major, &minor);
|
||||
LOG((CLOG_ERR "server has incompatible version %d.%d", major, minor));
|
||||
m_client->disconnect("server has incompatible version");
|
||||
@@ -214,8 +214,8 @@ CServerProxy::parseHandshakeMessage(const UInt8* code)
|
||||
return kOkay;
|
||||
}
|
||||
|
||||
CServerProxy::EResult
|
||||
CServerProxy::parseMessage(const UInt8* code)
|
||||
ServerProxy::EResult
|
||||
ServerProxy::parseMessage(const UInt8* code)
|
||||
{
|
||||
if (memcmp(code, kMsgDMouseMove, 4) == 0) {
|
||||
mouseMove();
|
||||
@@ -251,7 +251,7 @@ CServerProxy::parseMessage(const UInt8* code)
|
||||
|
||||
else if (memcmp(code, kMsgCKeepAlive, 4) == 0) {
|
||||
// echo keep alives and reset alarm
|
||||
CProtocolUtil::writef(m_stream, kMsgCKeepAlive);
|
||||
ProtocolUtil::writef(m_stream, kMsgCKeepAlive);
|
||||
resetKeepAliveAlarm();
|
||||
}
|
||||
|
||||
@@ -328,20 +328,20 @@ CServerProxy::parseMessage(const UInt8* code)
|
||||
// on a data packet. we provide that packet here. i don't
|
||||
// know why a delayed ACK should cause the server to wait since
|
||||
// TCP_NODELAY is enabled.
|
||||
CProtocolUtil::writef(m_stream, kMsgCNoop);
|
||||
ProtocolUtil::writef(m_stream, kMsgCNoop);
|
||||
|
||||
return kOkay;
|
||||
}
|
||||
|
||||
void
|
||||
CServerProxy::handleKeepAliveAlarm(const CEvent&, void*)
|
||||
ServerProxy::handleKeepAliveAlarm(const Event&, void*)
|
||||
{
|
||||
LOG((CLOG_NOTE "server is dead"));
|
||||
m_client->disconnect("server is not responding");
|
||||
}
|
||||
|
||||
void
|
||||
CServerProxy::onInfoChanged()
|
||||
ServerProxy::onInfoChanged()
|
||||
{
|
||||
// ignore mouse motion until we receive acknowledgment of our info
|
||||
// change message.
|
||||
@@ -352,23 +352,23 @@ CServerProxy::onInfoChanged()
|
||||
}
|
||||
|
||||
bool
|
||||
CServerProxy::onGrabClipboard(ClipboardID id)
|
||||
ServerProxy::onGrabClipboard(ClipboardID id)
|
||||
{
|
||||
LOG((CLOG_DEBUG1 "sending clipboard %d changed", id));
|
||||
CProtocolUtil::writef(m_stream, kMsgCClipboard, id, m_seqNum);
|
||||
ProtocolUtil::writef(m_stream, kMsgCClipboard, id, m_seqNum);
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
CServerProxy::onClipboardChanged(ClipboardID id, const IClipboard* clipboard)
|
||||
ServerProxy::onClipboardChanged(ClipboardID id, const IClipboard* clipboard)
|
||||
{
|
||||
CString data = IClipboard::marshall(clipboard);
|
||||
String data = IClipboard::marshall(clipboard);
|
||||
LOG((CLOG_DEBUG1 "sending clipboard %d seqnum=%d, size=%d", id, m_seqNum, data.size()));
|
||||
CProtocolUtil::writef(m_stream, kMsgDClipboard, id, m_seqNum, &data);
|
||||
ProtocolUtil::writef(m_stream, kMsgDClipboard, id, m_seqNum, &data);
|
||||
}
|
||||
|
||||
void
|
||||
CServerProxy::flushCompressedMouse()
|
||||
ServerProxy::flushCompressedMouse()
|
||||
{
|
||||
if (m_compressMouse) {
|
||||
m_compressMouse = false;
|
||||
@@ -383,17 +383,17 @@ CServerProxy::flushCompressedMouse()
|
||||
}
|
||||
|
||||
void
|
||||
CServerProxy::sendInfo(const CClientInfo& info)
|
||||
ServerProxy::sendInfo(const ClientInfo& info)
|
||||
{
|
||||
LOG((CLOG_DEBUG1 "sending info shape=%d,%d %dx%d", info.m_x, info.m_y, info.m_w, info.m_h));
|
||||
CProtocolUtil::writef(m_stream, kMsgDInfo,
|
||||
ProtocolUtil::writef(m_stream, kMsgDInfo,
|
||||
info.m_x, info.m_y,
|
||||
info.m_w, info.m_h, 0,
|
||||
info.m_mx, info.m_my);
|
||||
}
|
||||
|
||||
KeyID
|
||||
CServerProxy::translateKey(KeyID id) const
|
||||
ServerProxy::translateKey(KeyID id) const
|
||||
{
|
||||
static const KeyID s_translationTable[kKeyModifierIDLast][2] = {
|
||||
{ kKeyNone, kKeyNone },
|
||||
@@ -473,7 +473,7 @@ CServerProxy::translateKey(KeyID id) const
|
||||
}
|
||||
|
||||
KeyModifierMask
|
||||
CServerProxy::translateModifierMask(KeyModifierMask mask) const
|
||||
ServerProxy::translateModifierMask(KeyModifierMask mask) const
|
||||
{
|
||||
static const KeyModifierMask s_masks[kKeyModifierIDLast] = {
|
||||
0x0000,
|
||||
@@ -513,13 +513,13 @@ CServerProxy::translateModifierMask(KeyModifierMask mask) const
|
||||
}
|
||||
|
||||
void
|
||||
CServerProxy::enter()
|
||||
ServerProxy::enter()
|
||||
{
|
||||
// parse
|
||||
SInt16 x, y;
|
||||
UInt16 mask;
|
||||
UInt32 seqNum;
|
||||
CProtocolUtil::readf(m_stream, kMsgCEnter + 4, &x, &y, &seqNum, &mask);
|
||||
ProtocolUtil::readf(m_stream, kMsgCEnter + 4, &x, &y, &seqNum, &mask);
|
||||
LOG((CLOG_DEBUG1 "recv enter, %d,%d %d %04x", x, y, seqNum, mask));
|
||||
|
||||
// discard old compressed mouse motion, if any
|
||||
@@ -534,7 +534,7 @@ CServerProxy::enter()
|
||||
}
|
||||
|
||||
void
|
||||
CServerProxy::leave()
|
||||
ServerProxy::leave()
|
||||
{
|
||||
// parse
|
||||
LOG((CLOG_DEBUG1 "recv leave"));
|
||||
@@ -547,13 +547,13 @@ CServerProxy::leave()
|
||||
}
|
||||
|
||||
void
|
||||
CServerProxy::setClipboard()
|
||||
ServerProxy::setClipboard()
|
||||
{
|
||||
// parse
|
||||
ClipboardID id;
|
||||
UInt32 seqNum;
|
||||
CString data;
|
||||
CProtocolUtil::readf(m_stream, kMsgDClipboard + 4, &id, &seqNum, &data);
|
||||
String data;
|
||||
ProtocolUtil::readf(m_stream, kMsgDClipboard + 4, &id, &seqNum, &data);
|
||||
LOG((CLOG_DEBUG "recv clipboard %d size=%d", id, data.size()));
|
||||
|
||||
// validate
|
||||
@@ -562,18 +562,18 @@ CServerProxy::setClipboard()
|
||||
}
|
||||
|
||||
// forward
|
||||
CClipboard clipboard;
|
||||
Clipboard clipboard;
|
||||
clipboard.unmarshall(data, 0);
|
||||
m_client->setClipboard(id, &clipboard);
|
||||
}
|
||||
|
||||
void
|
||||
CServerProxy::grabClipboard()
|
||||
ServerProxy::grabClipboard()
|
||||
{
|
||||
// parse
|
||||
ClipboardID id;
|
||||
UInt32 seqNum;
|
||||
CProtocolUtil::readf(m_stream, kMsgCClipboard + 4, &id, &seqNum);
|
||||
ProtocolUtil::readf(m_stream, kMsgCClipboard + 4, &id, &seqNum);
|
||||
LOG((CLOG_DEBUG "recv grab clipboard %d", id));
|
||||
|
||||
// validate
|
||||
@@ -586,14 +586,14 @@ CServerProxy::grabClipboard()
|
||||
}
|
||||
|
||||
void
|
||||
CServerProxy::keyDown()
|
||||
ServerProxy::keyDown()
|
||||
{
|
||||
// get mouse up to date
|
||||
flushCompressedMouse();
|
||||
|
||||
// parse
|
||||
UInt16 id, mask, button;
|
||||
CProtocolUtil::readf(m_stream, kMsgDKeyDown + 4, &id, &mask, &button);
|
||||
ProtocolUtil::readf(m_stream, kMsgDKeyDown + 4, &id, &mask, &button);
|
||||
LOG((CLOG_DEBUG1 "recv key down id=0x%08x, mask=0x%04x, button=0x%04x", id, mask, button));
|
||||
|
||||
// translate
|
||||
@@ -609,14 +609,14 @@ CServerProxy::keyDown()
|
||||
}
|
||||
|
||||
void
|
||||
CServerProxy::keyRepeat()
|
||||
ServerProxy::keyRepeat()
|
||||
{
|
||||
// get mouse up to date
|
||||
flushCompressedMouse();
|
||||
|
||||
// parse
|
||||
UInt16 id, mask, count, button;
|
||||
CProtocolUtil::readf(m_stream, kMsgDKeyRepeat + 4,
|
||||
ProtocolUtil::readf(m_stream, kMsgDKeyRepeat + 4,
|
||||
&id, &mask, &count, &button);
|
||||
LOG((CLOG_DEBUG1 "recv key repeat id=0x%08x, mask=0x%04x, count=%d, button=0x%04x", id, mask, count, button));
|
||||
|
||||
@@ -633,14 +633,14 @@ CServerProxy::keyRepeat()
|
||||
}
|
||||
|
||||
void
|
||||
CServerProxy::keyUp()
|
||||
ServerProxy::keyUp()
|
||||
{
|
||||
// get mouse up to date
|
||||
flushCompressedMouse();
|
||||
|
||||
// parse
|
||||
UInt16 id, mask, button;
|
||||
CProtocolUtil::readf(m_stream, kMsgDKeyUp + 4, &id, &mask, &button);
|
||||
ProtocolUtil::readf(m_stream, kMsgDKeyUp + 4, &id, &mask, &button);
|
||||
LOG((CLOG_DEBUG1 "recv key up id=0x%08x, mask=0x%04x, button=0x%04x", id, mask, button));
|
||||
|
||||
// translate
|
||||
@@ -656,14 +656,14 @@ CServerProxy::keyUp()
|
||||
}
|
||||
|
||||
void
|
||||
CServerProxy::mouseDown()
|
||||
ServerProxy::mouseDown()
|
||||
{
|
||||
// get mouse up to date
|
||||
flushCompressedMouse();
|
||||
|
||||
// parse
|
||||
SInt8 id;
|
||||
CProtocolUtil::readf(m_stream, kMsgDMouseDown + 4, &id);
|
||||
ProtocolUtil::readf(m_stream, kMsgDMouseDown + 4, &id);
|
||||
LOG((CLOG_DEBUG1 "recv mouse down id=%d", id));
|
||||
|
||||
// forward
|
||||
@@ -671,14 +671,14 @@ CServerProxy::mouseDown()
|
||||
}
|
||||
|
||||
void
|
||||
CServerProxy::mouseUp()
|
||||
ServerProxy::mouseUp()
|
||||
{
|
||||
// get mouse up to date
|
||||
flushCompressedMouse();
|
||||
|
||||
// parse
|
||||
SInt8 id;
|
||||
CProtocolUtil::readf(m_stream, kMsgDMouseUp + 4, &id);
|
||||
ProtocolUtil::readf(m_stream, kMsgDMouseUp + 4, &id);
|
||||
LOG((CLOG_DEBUG1 "recv mouse up id=%d", id));
|
||||
|
||||
// forward
|
||||
@@ -686,12 +686,12 @@ CServerProxy::mouseUp()
|
||||
}
|
||||
|
||||
void
|
||||
CServerProxy::mouseMove()
|
||||
ServerProxy::mouseMove()
|
||||
{
|
||||
// parse
|
||||
bool ignore;
|
||||
SInt16 x, y;
|
||||
CProtocolUtil::readf(m_stream, kMsgDMouseMove + 4, &x, &y);
|
||||
ProtocolUtil::readf(m_stream, kMsgDMouseMove + 4, &x, &y);
|
||||
|
||||
// note if we should ignore the move
|
||||
ignore = m_ignoreMouse;
|
||||
@@ -719,12 +719,12 @@ CServerProxy::mouseMove()
|
||||
}
|
||||
|
||||
void
|
||||
CServerProxy::mouseRelativeMove()
|
||||
ServerProxy::mouseRelativeMove()
|
||||
{
|
||||
// parse
|
||||
bool ignore;
|
||||
SInt16 dx, dy;
|
||||
CProtocolUtil::readf(m_stream, kMsgDMouseRelMove + 4, &dx, &dy);
|
||||
ProtocolUtil::readf(m_stream, kMsgDMouseRelMove + 4, &dx, &dy);
|
||||
|
||||
// note if we should ignore the move
|
||||
ignore = m_ignoreMouse;
|
||||
@@ -749,14 +749,14 @@ CServerProxy::mouseRelativeMove()
|
||||
}
|
||||
|
||||
void
|
||||
CServerProxy::mouseWheel()
|
||||
ServerProxy::mouseWheel()
|
||||
{
|
||||
// get mouse up to date
|
||||
flushCompressedMouse();
|
||||
|
||||
// parse
|
||||
SInt16 xDelta, yDelta;
|
||||
CProtocolUtil::readf(m_stream, kMsgDMouseWheel + 4, &xDelta, &yDelta);
|
||||
ProtocolUtil::readf(m_stream, kMsgDMouseWheel + 4, &xDelta, &yDelta);
|
||||
LOG((CLOG_DEBUG2 "recv mouse wheel %+d,%+d", xDelta, yDelta));
|
||||
|
||||
// forward
|
||||
@@ -764,11 +764,11 @@ CServerProxy::mouseWheel()
|
||||
}
|
||||
|
||||
void
|
||||
CServerProxy::cryptoIv()
|
||||
ServerProxy::cryptoIv()
|
||||
{
|
||||
// parse
|
||||
CString s;
|
||||
CProtocolUtil::readf(m_stream, kMsgDCryptoIv + 4, &s);
|
||||
String s;
|
||||
ProtocolUtil::readf(m_stream, kMsgDCryptoIv + 4, &s);
|
||||
LOG((CLOG_DEBUG2 "recv crypto iv size=%i", s.size()));
|
||||
|
||||
// forward
|
||||
@@ -776,11 +776,11 @@ CServerProxy::cryptoIv()
|
||||
}
|
||||
|
||||
void
|
||||
CServerProxy::screensaver()
|
||||
ServerProxy::screensaver()
|
||||
{
|
||||
// parse
|
||||
SInt8 on;
|
||||
CProtocolUtil::readf(m_stream, kMsgCScreenSaver + 4, &on);
|
||||
ProtocolUtil::readf(m_stream, kMsgCScreenSaver + 4, &on);
|
||||
LOG((CLOG_DEBUG1 "recv screen saver on=%d", on));
|
||||
|
||||
// forward
|
||||
@@ -788,7 +788,7 @@ CServerProxy::screensaver()
|
||||
}
|
||||
|
||||
void
|
||||
CServerProxy::resetOptions()
|
||||
ServerProxy::resetOptions()
|
||||
{
|
||||
// parse
|
||||
LOG((CLOG_DEBUG1 "recv reset options"));
|
||||
@@ -806,11 +806,11 @@ CServerProxy::resetOptions()
|
||||
}
|
||||
|
||||
void
|
||||
CServerProxy::setOptions()
|
||||
ServerProxy::setOptions()
|
||||
{
|
||||
// parse
|
||||
COptionsList options;
|
||||
CProtocolUtil::readf(m_stream, kMsgDSetOptions + 4, &options);
|
||||
OptionsList options;
|
||||
ProtocolUtil::readf(m_stream, kMsgDSetOptions + 4, &options);
|
||||
LOG((CLOG_DEBUG1 "recv set options size=%d", options.size()));
|
||||
|
||||
// forward
|
||||
@@ -850,28 +850,28 @@ CServerProxy::setOptions()
|
||||
}
|
||||
|
||||
void
|
||||
CServerProxy::queryInfo()
|
||||
ServerProxy::queryInfo()
|
||||
{
|
||||
CClientInfo info;
|
||||
ClientInfo info;
|
||||
m_client->getShape(info.m_x, info.m_y, info.m_w, info.m_h);
|
||||
m_client->getCursorPos(info.m_mx, info.m_my);
|
||||
sendInfo(info);
|
||||
}
|
||||
|
||||
void
|
||||
CServerProxy::infoAcknowledgment()
|
||||
ServerProxy::infoAcknowledgment()
|
||||
{
|
||||
LOG((CLOG_DEBUG1 "recv info acknowledgment"));
|
||||
m_ignoreMouse = false;
|
||||
}
|
||||
|
||||
void
|
||||
CServerProxy::fileChunkReceived()
|
||||
ServerProxy::fileChunkReceived()
|
||||
{
|
||||
// parse
|
||||
UInt8 mark = 0;
|
||||
CString content;
|
||||
CProtocolUtil::readf(m_stream, kMsgDFileTransfer + 4, &mark, &content);
|
||||
String content;
|
||||
ProtocolUtil::readf(m_stream, kMsgDFileTransfer + 4, &mark, &content);
|
||||
|
||||
switch (mark) {
|
||||
case kFileStart:
|
||||
@@ -902,7 +902,7 @@ CServerProxy::fileChunkReceived()
|
||||
break;
|
||||
|
||||
case kFileEnd:
|
||||
m_events->addEvent(CEvent(m_events->forIScreen().fileRecieveCompleted(), m_client));
|
||||
m_events->addEvent(Event(m_events->forIScreen().fileRecieveCompleted(), m_client));
|
||||
if (CLOG->getFilter() >= kDEBUG2) {
|
||||
LOG((CLOG_DEBUG2 "file data transfer finished"));
|
||||
m_elapsedTime += m_stopwatch.getTime();
|
||||
@@ -916,20 +916,20 @@ CServerProxy::fileChunkReceived()
|
||||
}
|
||||
|
||||
void
|
||||
CServerProxy::dragInfoReceived()
|
||||
ServerProxy::dragInfoReceived()
|
||||
{
|
||||
// parse
|
||||
UInt32 fileNum = 0;
|
||||
CString content;
|
||||
CProtocolUtil::readf(m_stream, kMsgDDragInfo + 4, &fileNum, &content);
|
||||
String content;
|
||||
ProtocolUtil::readf(m_stream, kMsgDDragInfo + 4, &fileNum, &content);
|
||||
|
||||
m_client->dragInfoReceived(fileNum, content);
|
||||
}
|
||||
|
||||
void
|
||||
CServerProxy::fileChunkSending(UInt8 mark, char* data, size_t dataSize)
|
||||
ServerProxy::fileChunkSending(UInt8 mark, char* data, size_t dataSize)
|
||||
{
|
||||
CString chunk(data, dataSize);
|
||||
String chunk(data, dataSize);
|
||||
|
||||
switch (mark) {
|
||||
case kFileStart:
|
||||
@@ -945,12 +945,12 @@ CServerProxy::fileChunkSending(UInt8 mark, char* data, size_t dataSize)
|
||||
break;
|
||||
}
|
||||
|
||||
CProtocolUtil::writef(m_stream, kMsgDFileTransfer, mark, &chunk);
|
||||
ProtocolUtil::writef(m_stream, kMsgDFileTransfer, mark, &chunk);
|
||||
}
|
||||
|
||||
void
|
||||
CServerProxy::sendDragInfo(UInt32 fileCount, const char* info, size_t size)
|
||||
ServerProxy::sendDragInfo(UInt32 fileCount, const char* info, size_t size)
|
||||
{
|
||||
CString data(info, size);
|
||||
CProtocolUtil::writef(m_stream, kMsgDDragInfo, fileCount, &data);
|
||||
String data(info, size);
|
||||
ProtocolUtil::writef(m_stream, kMsgDDragInfo, fileCount, &data);
|
||||
}
|
||||
|
||||
@@ -24,9 +24,9 @@
|
||||
#include "base/Stopwatch.h"
|
||||
#include "base/String.h"
|
||||
|
||||
class CClient;
|
||||
class CClientInfo;
|
||||
class CEventQueueTimer;
|
||||
class Client;
|
||||
class ClientInfo;
|
||||
class EventQueueTimer;
|
||||
class IClipboard;
|
||||
namespace synergy { class IStream; }
|
||||
class IEventQueue;
|
||||
@@ -36,14 +36,14 @@ class IEventQueue;
|
||||
This class acts a proxy for the server, converting calls into messages
|
||||
to the server and messages from the server to calls on the client.
|
||||
*/
|
||||
class CServerProxy {
|
||||
class ServerProxy {
|
||||
public:
|
||||
/*!
|
||||
Process messages from the server on \p stream and forward to
|
||||
\p client.
|
||||
*/
|
||||
CServerProxy(CClient* client, synergy::IStream* stream, IEventQueue* events);
|
||||
~CServerProxy();
|
||||
ServerProxy(Client* client, synergy::IStream* stream, IEventQueue* events);
|
||||
~ServerProxy();
|
||||
|
||||
//! @name manipulators
|
||||
//@{
|
||||
@@ -61,7 +61,7 @@ public:
|
||||
void sendDragInfo(UInt32 fileCount, const char* info, size_t size);
|
||||
|
||||
#ifdef TEST_ENV
|
||||
void handleDataForTest() { handleData(CEvent(), NULL); }
|
||||
void handleDataForTest() { handleData(Event(), NULL); }
|
||||
#endif
|
||||
|
||||
protected:
|
||||
@@ -73,7 +73,7 @@ private:
|
||||
// if compressing mouse motion then send the last motion now
|
||||
void flushCompressedMouse();
|
||||
|
||||
void sendInfo(const CClientInfo&);
|
||||
void sendInfo(const ClientInfo&);
|
||||
|
||||
void resetKeepAliveAlarm();
|
||||
void setKeepAliveRate(double);
|
||||
@@ -83,8 +83,8 @@ private:
|
||||
KeyModifierMask translateModifierMask(KeyModifierMask) const;
|
||||
|
||||
// event handlers
|
||||
void handleData(const CEvent&, void*);
|
||||
void handleKeepAliveAlarm(const CEvent&, void*);
|
||||
void handleData(const Event&, void*);
|
||||
void handleKeepAliveAlarm(const Event&, void*);
|
||||
|
||||
// message handlers
|
||||
void enter();
|
||||
@@ -109,9 +109,9 @@ private:
|
||||
void dragInfoReceived();
|
||||
|
||||
private:
|
||||
typedef EResult (CServerProxy::*MessageParser)(const UInt8*);
|
||||
typedef EResult (ServerProxy::*MessageParser)(const UInt8*);
|
||||
|
||||
CClient* m_client;
|
||||
Client* m_client;
|
||||
synergy::IStream* m_stream;
|
||||
|
||||
UInt32 m_seqNum;
|
||||
@@ -126,12 +126,12 @@ private:
|
||||
KeyModifierID m_modifierTranslationTable[kKeyModifierIDLast];
|
||||
|
||||
double m_keepAliveAlarm;
|
||||
CEventQueueTimer* m_keepAliveAlarmTimer;
|
||||
EventQueueTimer* m_keepAliveAlarmTimer;
|
||||
|
||||
MessageParser m_parser;
|
||||
IEventQueue* m_events;
|
||||
|
||||
CStopwatch m_stopwatch;
|
||||
Stopwatch m_stopwatch;
|
||||
double m_elapsedTime;
|
||||
size_t m_receivedDataSize;
|
||||
static const UInt16 m_intervalThreshold;
|
||||
|
||||
Reference in New Issue
Block a user