| 1 | /* | 
|---|
| 2 | * synergy -- mouse and keyboard sharing utility | 
|---|
| 3 | * Copyright (C) 2002 Chris Schoeneman | 
|---|
| 4 | * | 
|---|
| 5 | * This package is free software; you can redistribute it and/or | 
|---|
| 6 | * modify it under the terms of the GNU General Public License | 
|---|
| 7 | * found in the file COPYING that should have accompanied this file. | 
|---|
| 8 | * | 
|---|
| 9 | * This package is distributed in the hope that it will be useful, | 
|---|
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|---|
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|---|
| 12 | * GNU General Public License for more details. | 
|---|
| 13 | */ | 
|---|
| 14 |  | 
|---|
| 15 | #include "CClientProxy.h" | 
|---|
| 16 | #include "CProtocolUtil.h" | 
|---|
| 17 | #include "IStream.h" | 
|---|
| 18 | #include "CLog.h" | 
|---|
| 19 |  | 
|---|
| 20 | // | 
|---|
| 21 | // CClientProxy | 
|---|
| 22 | // | 
|---|
| 23 |  | 
|---|
| 24 | CEvent::Type                    CClientProxy::s_readyEvent           = CEvent::kUnknown; | 
|---|
| 25 | CEvent::Type                    CClientProxy::s_disconnectedEvent    = CEvent::kUnknown; | 
|---|
| 26 | CEvent::Type                    CClientProxy::s_clipboardChangedEvent= CEvent::kUnknown; | 
|---|
| 27 |  | 
|---|
| 28 | CClientProxy::CClientProxy(const CString& name, IStream* stream) : | 
|---|
| 29 | CBaseClientProxy(name), | 
|---|
| 30 | m_stream(stream) | 
|---|
| 31 | { | 
|---|
| 32 | // do nothing | 
|---|
| 33 | } | 
|---|
| 34 |  | 
|---|
| 35 | CClientProxy::~CClientProxy() | 
|---|
| 36 | { | 
|---|
| 37 | delete m_stream; | 
|---|
| 38 | } | 
|---|
| 39 |  | 
|---|
| 40 | void | 
|---|
| 41 | CClientProxy::close(const char* msg) | 
|---|
| 42 | { | 
|---|
| 43 | LOG((CLOG_DEBUG1 "send close \"%s\" to \"%s\"", msg, getName().c_str())); | 
|---|
| 44 | CProtocolUtil::writef(getStream(), msg); | 
|---|
| 45 |  | 
|---|
| 46 | // force the close to be sent before we return | 
|---|
| 47 | getStream()->flush(); | 
|---|
| 48 | } | 
|---|
| 49 |  | 
|---|
| 50 | IStream* | 
|---|
| 51 | CClientProxy::getStream() const | 
|---|
| 52 | { | 
|---|
| 53 | return m_stream; | 
|---|
| 54 | } | 
|---|
| 55 |  | 
|---|
| 56 | CEvent::Type | 
|---|
| 57 | CClientProxy::getReadyEvent() | 
|---|
| 58 | { | 
|---|
| 59 | return CEvent::registerTypeOnce(s_readyEvent, | 
|---|
| 60 | "CClientProxy::ready"); | 
|---|
| 61 | } | 
|---|
| 62 |  | 
|---|
| 63 | CEvent::Type | 
|---|
| 64 | CClientProxy::getDisconnectedEvent() | 
|---|
| 65 | { | 
|---|
| 66 | return CEvent::registerTypeOnce(s_disconnectedEvent, | 
|---|
| 67 | "CClientProxy::disconnected"); | 
|---|
| 68 | } | 
|---|
| 69 |  | 
|---|
| 70 | CEvent::Type | 
|---|
| 71 | CClientProxy::getClipboardChangedEvent() | 
|---|
| 72 | { | 
|---|
| 73 | return CEvent::registerTypeOnce(s_clipboardChangedEvent, | 
|---|
| 74 | "CClientProxy::clipboardChanged"); | 
|---|
| 75 | } | 
|---|
| 76 |  | 
|---|
| 77 | void* | 
|---|
| 78 | CClientProxy::getEventTarget() const | 
|---|
| 79 | { | 
|---|
| 80 | return static_cast<IScreen*>(const_cast<CClientProxy*>(this)); | 
|---|
| 81 | } | 
|---|