00001 /* 00002 * synergy -- mouse and keyboard sharing utility 00003 * Copyright (C) 2002 Chris Schoeneman 00004 * 00005 * This package is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU General Public License 00007 * found in the file COPYING that should have accompanied this file. 00008 * 00009 * This package is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 */ 00014 00015 #include "CClientProxy.h" 00016 #include "CProtocolUtil.h" 00017 #include "IStream.h" 00018 #include "CLog.h" 00019 00020 // 00021 // CClientProxy 00022 // 00023 00024 CEvent::Type CClientProxy::s_readyEvent = CEvent::kUnknown; 00025 CEvent::Type CClientProxy::s_disconnectedEvent = CEvent::kUnknown; 00026 CEvent::Type CClientProxy::s_clipboardChangedEvent= CEvent::kUnknown; 00027 00028 CClientProxy::CClientProxy(const CString& name, IStream* stream) : 00029 CBaseClientProxy(name), 00030 m_stream(stream) 00031 { 00032 // do nothing 00033 } 00034 00035 CClientProxy::~CClientProxy() 00036 { 00037 delete m_stream; 00038 } 00039 00040 void 00041 CClientProxy::close(const char* msg) 00042 { 00043 LOG((CLOG_DEBUG1 "send close \"%s\" to \"%s\"", msg, getName().c_str())); 00044 CProtocolUtil::writef(getStream(), msg); 00045 00046 // force the close to be sent before we return 00047 getStream()->flush(); 00048 } 00049 00050 IStream* 00051 CClientProxy::getStream() const 00052 { 00053 return m_stream; 00054 } 00055 00056 CEvent::Type 00057 CClientProxy::getReadyEvent() 00058 { 00059 return CEvent::registerTypeOnce(s_readyEvent, 00060 "CClientProxy::ready"); 00061 } 00062 00063 CEvent::Type 00064 CClientProxy::getDisconnectedEvent() 00065 { 00066 return CEvent::registerTypeOnce(s_disconnectedEvent, 00067 "CClientProxy::disconnected"); 00068 } 00069 00070 CEvent::Type 00071 CClientProxy::getClipboardChangedEvent() 00072 { 00073 return CEvent::registerTypeOnce(s_clipboardChangedEvent, 00074 "CClientProxy::clipboardChanged"); 00075 } 00076 00077 void* 00078 CClientProxy::getEventTarget() const 00079 { 00080 return static_cast<IScreen*>(const_cast<CClientProxy*>(this)); 00081 }