Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

322 lines
7.5 KiB

  1. /*++
  2. Copyright (c) 1999-2000 Microsoft Corporation
  3. Module Name:
  4. ClientDataChannelMgr.h
  5. Abstract:
  6. This module implements the CClientDataChannelMgr class, a
  7. Salem client-side data channel manager ... that abstracts
  8. access to the underlying protocol, so it can
  9. be switched out at run-time.
  10. Author:
  11. Tad Brockway 06/00
  12. Revision History:
  13. --*/
  14. #ifndef __CLIENTDATACHANNELMGR_H__
  15. #define __CLIENTDATACHANNELMGR_H__
  16. #include <DataChannelMgr.h>
  17. #include "resource.h"
  18. #include <atlctl.h>
  19. #include <rdchost.h>
  20. #include <rdschan.h>
  21. #include "ClientDataChannelMgrP.h"
  22. #define IDC_EVENT_SOURCE_OBJ 1
  23. //
  24. // Info for all the event functions is entered here
  25. // there is a way to have ATL do this automatically using typelib's
  26. // but it is slower.
  27. //
  28. static _ATL_FUNC_INFO DCEventFuncNoParamsInfo =
  29. {
  30. CC_STDCALL, // Calling convention.
  31. VT_EMPTY, // Return type.
  32. 0, // Number of arguments.
  33. {VT_EMPTY} // Argument types.
  34. };
  35. static _ATL_FUNC_INFO DCEventFuncLongParamInfo =
  36. {
  37. CC_STDCALL, // Calling convention.
  38. VT_EMPTY, // Return type.
  39. 1, // Number of arguments.
  40. {VT_I4} // Argument types.
  41. };
  42. static _ATL_FUNC_INFO DCEventFuncOneStringParamInfo =
  43. {
  44. CC_STDCALL, // Calling convention.
  45. VT_EMPTY, // Return type.
  46. 1, // Number of arguments.
  47. {VT_BSTR} // Argument types
  48. };
  49. ///////////////////////////////////////////////////////
  50. //
  51. // CClientChannelEventSink
  52. //
  53. class CClientDataChannelMgr;
  54. class CClientChannelEventSink :
  55. public IDispEventSimpleImpl<IDC_EVENT_SOURCE_OBJ, CClientChannelEventSink,
  56. &DIID__IDataChannelIOEvents>,
  57. public CRemoteDesktopTopLevelObject
  58. {
  59. public:
  60. CClientDataChannelMgr *m_Obj;
  61. public:
  62. CClientChannelEventSink()
  63. {
  64. m_Obj = NULL;
  65. }
  66. ~CClientChannelEventSink();
  67. BEGIN_SINK_MAP(CClientChannelEventSink)
  68. SINK_ENTRY_INFO(IDC_EVENT_SOURCE_OBJ, DIID__IDataChannelIOEvents,
  69. DISPID_DATACHANNELEVEVENTS_DATAREADY,
  70. DataReady,
  71. &DCEventFuncOneStringParamInfo)
  72. END_SINK_MAP()
  73. void __stdcall DataReady(BSTR data);
  74. //
  75. // Return the name of this class.
  76. //
  77. virtual const LPTSTR ClassName() {
  78. return TEXT("CClientChannelEventSink");
  79. }
  80. };
  81. ///////////////////////////////////////////////////////
  82. //
  83. // ClientDataChannel
  84. //
  85. // Client-Specific Subclass of CRemoteDesktopDataChannel.
  86. //
  87. class ATL_NO_VTABLE ClientDataChannel :
  88. public CRemoteDesktopDataChannel,
  89. public CComObjectRootEx<CComSingleThreadModel>,
  90. public CComCoClass<ClientDataChannel, &CLSID_ClientDataChannel>,
  91. public IConnectionPointContainerImpl<ClientDataChannel>,
  92. public IDispatchImpl<ISAFRemoteDesktopDataChannel, &IID_ISAFRemoteDesktopDataChannel, &LIBID_RDCCLIENTHOSTLib>,
  93. public IProvideClassInfo2Impl<&CLSID_ClientDataChannel, NULL, &LIBID_RDCCLIENTHOSTLib>,
  94. public CProxy_ISAFRemoteDesktopDataChannelEvents< ClientDataChannel >
  95. {
  96. protected:
  97. //
  98. // Scriptable Event Callback Object
  99. //
  100. CComPtr<IDispatch> m_OnChannelDataReady;
  101. //
  102. // Back pointer to the channel manager.
  103. //
  104. CClientDataChannelMgr *m_ChannelMgr;
  105. public:
  106. //
  107. // Constructor/Destructor
  108. //
  109. ClientDataChannel();
  110. virtual ~ClientDataChannel();
  111. //
  112. // Initialize an instance of this class.
  113. //
  114. virtual void Initialize(
  115. CClientDataChannelMgr *mgr,
  116. BSTR channelName
  117. );
  118. DECLARE_REGISTRY_RESOURCEID(IDR_CLIENTDATACHANNEL)
  119. DECLARE_PROTECT_FINAL_CONSTRUCT()
  120. BEGIN_COM_MAP(ClientDataChannel)
  121. COM_INTERFACE_ENTRY(ISAFRemoteDesktopDataChannel)
  122. COM_INTERFACE_ENTRY2(IDispatch, ISAFRemoteDesktopDataChannel)
  123. COM_INTERFACE_ENTRY(IProvideClassInfo)
  124. COM_INTERFACE_ENTRY(IProvideClassInfo2)
  125. COM_INTERFACE_ENTRY(IConnectionPointContainer)
  126. COM_INTERFACE_ENTRY_IMPL(IConnectionPointContainer)
  127. END_COM_MAP()
  128. BEGIN_CONNECTION_POINT_MAP(ClientDataChannel)
  129. CONNECTION_POINT_ENTRY(DIID__ISAFRemoteDesktopDataChannelEvents)
  130. END_CONNECTION_POINT_MAP()
  131. //
  132. // ISAFRemoteDesktopDataChannel Methods
  133. //
  134. // The parent class handles the details of these methods.
  135. //
  136. STDMETHOD(ReceiveChannelData)(/*[out, retval]*/BSTR *data);
  137. STDMETHOD(SendChannelData)(BSTR data);
  138. STDMETHOD(put_OnChannelDataReady)(/*[in]*/ IDispatch * newVal);
  139. STDMETHOD(get_ChannelName)(/*[out, retval]*/ BSTR *pVal);
  140. //
  141. // Called to return our ISAFRemoteDesktopDataChannel interface.
  142. //
  143. virtual HRESULT GetISAFRemoteDesktopDataChannel(
  144. ISAFRemoteDesktopDataChannel **channel
  145. ) {
  146. HRESULT hr;
  147. hr = this->QueryInterface(
  148. IID_ISAFRemoteDesktopDataChannel, (PVOID*)channel
  149. );
  150. return hr;
  151. }
  152. //
  153. // Called by the data channel manager when data is ready on our channel.
  154. //
  155. virtual VOID DataReady();
  156. //
  157. // Return this class name.
  158. //
  159. virtual const LPTSTR ClassName() { return TEXT("ClientDataChannel"); }
  160. };
  161. ///////////////////////////////////////////////////////
  162. //
  163. // CClientDataChannelMgr
  164. //
  165. class CClientDataChannelMgr :
  166. public CRemoteDesktopChannelMgr,
  167. public CComObjectRootEx<CComSingleThreadModel>,
  168. public CComCoClass<CClientDataChannelMgr, &CLSID_ClientRemoteDesktopChannelMgr>,
  169. public IDispatchImpl<ISAFRemoteDesktopChannelMgr, &IID_ISAFRemoteDesktopChannelMgr, &LIBID_RDCCLIENTHOSTLib>
  170. {
  171. protected:
  172. CComPtr<IDataChannelIO> m_IOInterface;
  173. CClientChannelEventSink m_EventSink;
  174. //
  175. // Send Function Invoked by Parent Class
  176. //
  177. // The underlying data storage for the msg is a BSTR so that it is compatible
  178. // with COM methods.
  179. //
  180. virtual HRESULT SendData(PREMOTEDESKTOP_CHANNELBUFHEADER msg);
  181. //
  182. // Help the parent class out by opening the right channel object
  183. // for the platform.
  184. //
  185. virtual CRemoteDesktopDataChannel *OpenPlatformSpecificDataChannel(
  186. BSTR channelName,
  187. ISAFRemoteDesktopDataChannel **channel
  188. )
  189. {
  190. CComObject<ClientDataChannel> *obj;
  191. obj = new CComObject<ClientDataChannel>();
  192. if (obj != NULL) {
  193. obj->Initialize(this, channelName);
  194. obj->QueryInterface(
  195. __uuidof(ISAFRemoteDesktopDataChannel),
  196. (PVOID *)channel
  197. );
  198. }
  199. return obj;
  200. }
  201. public:
  202. //
  203. // Constructor/Destructor
  204. //
  205. CClientDataChannelMgr();
  206. ~CClientDataChannelMgr();
  207. DECLARE_REGISTRY_RESOURCEID(IDR_CLIENTREMOTEDESTKOPCHANNELMGR)
  208. DECLARE_PROTECT_FINAL_CONSTRUCT()
  209. BEGIN_COM_MAP(CClientDataChannelMgr)
  210. COM_INTERFACE_ENTRY(ISAFRemoteDesktopChannelMgr)
  211. COM_INTERFACE_ENTRY(IDispatch)
  212. END_COM_MAP()
  213. //
  214. // ISAFRemoteDesktopChannelMgr Methods
  215. //
  216. STDMETHOD(OpenDataChannel)(BSTR name, ISAFRemoteDesktopDataChannel **channel)
  217. {
  218. //
  219. // Let the parent handle it.
  220. //
  221. return OpenDataChannel_(name, channel);
  222. }
  223. //
  224. // Set the Data Channel IO Interface. This is implemented by the protocol-
  225. // specific layer.
  226. //
  227. VOID SetIOInterface(IDataChannelIO *val);
  228. //
  229. // Initialize an instance of this class.
  230. //
  231. virtual HRESULT Initialize();
  232. //
  233. // Called on new channel data.
  234. //
  235. HRESULT __stdcall OnChannelsReceivedDataChange(
  236. BSTR data
  237. ) {
  238. //
  239. // Forward to the parent class.
  240. //
  241. DataReady(data);
  242. return S_OK;
  243. }
  244. //
  245. // Return this class name.
  246. //
  247. virtual const LPTSTR ClassName()
  248. { return TEXT("CClientDataChannelMgr"); }
  249. };
  250. #endif //__CLIENTDATACHANNELMGR_H__