Leaked source code of windows server 2003
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.

249 lines
7.2 KiB

  1. /*++
  2. Copyright (c) 1999-2000 Microsoft Corporation
  3. Module Name:
  4. RDCHostCP.h
  5. Abstract:
  6. Wizard-generated code for invoking client-side event sink functions.
  7. I added the "scriptDisp" field. If it is non-NULL, then its default method
  8. will be called along with any registered interfaces. This is to accomodate
  9. script clients that need to bind their event interfaces when the script
  10. engine initializes. Our objects are dynamically retrieved by the client
  11. script or application post-init.
  12. Author:
  13. Tad Brockway 02/00
  14. Revision History:
  15. --*/
  16. #ifndef _RDCHOSTCP_H_
  17. #define _RDCHOSTCP_H_
  18. ///////////////////////////////////////////////////////
  19. //
  20. // CProxy_IRemoteDesktopClientEvents
  21. //
  22. // Proxy for IRemoteDesktopClientEvents.
  23. //
  24. template <class T>
  25. class CProxy_ISAFRemoteDesktopClientEvents : public IConnectionPointImpl<T, &DIID__ISAFRemoteDesktopClientEvents, CComDynamicUnkArray>
  26. {
  27. public:
  28. VOID Fire_Connected(IDispatch *scriptDisp=NULL)
  29. {
  30. T* pT = static_cast<T*>(this);
  31. int nConnectionIndex;
  32. int nConnections = m_vec.GetSize();
  33. for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
  34. {
  35. pT->Lock();
  36. CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
  37. pT->Unlock();
  38. IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);
  39. if (pDispatch != NULL)
  40. {
  41. DISPPARAMS disp = { NULL, NULL, 0, 0 };
  42. HRESULT hr = pDispatch->Invoke(0x2, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL);
  43. }
  44. }
  45. //
  46. // Invoke the scriptable IDispatch interface, if specified.
  47. //
  48. if (scriptDisp != NULL) {
  49. DISPPARAMS disp = { NULL, NULL, 0, 0 };
  50. HRESULT hr = scriptDisp->Invoke(0x0, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL);
  51. }
  52. }
  53. VOID Fire_Disconnected(LONG reason, IDispatch *scriptDisp=NULL)
  54. {
  55. T* pT = static_cast<T*>(this);
  56. int nConnectionIndex;
  57. CComVariant* pvars = new CComVariant[1];
  58. if (pvars) {
  59. int nConnections = m_vec.GetSize();
  60. for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
  61. {
  62. pT->Lock();
  63. CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
  64. pT->Unlock();
  65. IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);
  66. if (pDispatch != NULL)
  67. {
  68. pvars[0] = reason;
  69. DISPPARAMS disp = { pvars, NULL, 1, 0 };
  70. HRESULT hr = pDispatch->Invoke(0x3, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL);
  71. }
  72. }
  73. //
  74. // Invoke the scriptable IDispatch interface, if specified.
  75. //
  76. if (scriptDisp != NULL) {
  77. pvars[0] = reason;
  78. DISPPARAMS disp = { pvars, NULL, 1, 0 };
  79. HRESULT hr = scriptDisp->Invoke(0x0, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL);
  80. }
  81. delete[] pvars;
  82. }
  83. }
  84. VOID Fire_RemoteControlRequestComplete(LONG status, IDispatch *scriptDisp=NULL)
  85. {
  86. T* pT = static_cast<T*>(this);
  87. int nConnectionIndex;
  88. CComVariant* pvars = new CComVariant[1];
  89. if (pvars) {
  90. int nConnections = m_vec.GetSize();
  91. for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
  92. {
  93. pT->Lock();
  94. CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
  95. pT->Unlock();
  96. IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);
  97. if (pDispatch != NULL)
  98. {
  99. pvars[0] = status;
  100. DISPPARAMS disp = { pvars, NULL, 1, 0 };
  101. HRESULT hr = pDispatch->Invoke(0x4, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL);
  102. }
  103. }
  104. //
  105. //Invoke the scriptable IDispatch interface, if specified.
  106. //
  107. if (scriptDisp != NULL) {
  108. pvars[0] = status;
  109. DISPPARAMS disp = { pvars, NULL, 1, 0 };
  110. HRESULT hr = scriptDisp->Invoke(0, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL);
  111. }
  112. delete[] pvars;
  113. }
  114. }
  115. VOID Fire_ListenConnect(LONG status, IDispatch *scriptDisp=NULL)
  116. {
  117. T* pT = static_cast<T*>(this);
  118. int nConnectionIndex;
  119. CComVariant* pvars = new CComVariant[1];
  120. if (pvars) {
  121. int nConnections = m_vec.GetSize();
  122. for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
  123. {
  124. pT->Lock();
  125. CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
  126. pT->Unlock();
  127. IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);
  128. if (pDispatch != NULL)
  129. {
  130. pvars[0] = status;
  131. DISPPARAMS disp = { pvars, NULL, 1, 0 };
  132. HRESULT hr = pDispatch->Invoke(0x5, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL);
  133. }
  134. }
  135. //
  136. // Invoke the scriptable IDispatch interface, if specified.
  137. //
  138. if (scriptDisp != NULL) {
  139. pvars[0] = status;
  140. DISPPARAMS disp = { pvars, NULL, 1, 0 };
  141. HRESULT hr = scriptDisp->Invoke(0, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL);
  142. }
  143. delete[] pvars;
  144. }
  145. }
  146. VOID Fire_BeginConnect(IDispatch *scriptDisp=NULL)
  147. {
  148. T* pT = static_cast<T*>(this);
  149. int nConnectionIndex;
  150. int nConnections = m_vec.GetSize();
  151. for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
  152. {
  153. pT->Lock();
  154. CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
  155. pT->Unlock();
  156. IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);
  157. if (pDispatch != NULL)
  158. {
  159. DISPPARAMS disp = { NULL, NULL, 0, 0 };
  160. HRESULT hr = pDispatch->Invoke(0x6, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL);
  161. }
  162. }
  163. //
  164. // Invoke the scriptable IDispatch interface, if specified.
  165. //
  166. if (scriptDisp != NULL) {
  167. DISPPARAMS disp = { NULL, NULL, 0, 0 };
  168. HRESULT hr = scriptDisp->Invoke(0x0, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL);
  169. }
  170. }
  171. };
  172. ///////////////////////////////////////////////////////
  173. //
  174. // CProxy_IDataChannelIOEvents
  175. //
  176. // Proxy for IDataChannelIOEvents
  177. //
  178. template <class T>
  179. class CProxy_IDataChannelIOEvents : public IConnectionPointImpl<T, &DIID__IDataChannelIOEvents, CComDynamicUnkArray>
  180. {
  181. public:
  182. VOID Fire_DataReady(BSTR data)
  183. {
  184. T* pT = static_cast<T*>(this);
  185. int nConnectionIndex;
  186. VARIANT vars[1];
  187. int nConnections = m_vec.GetSize();
  188. for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
  189. {
  190. pT->Lock();
  191. CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
  192. pT->Unlock();
  193. IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);
  194. if (pDispatch != NULL)
  195. {
  196. vars[0].vt = VT_BSTR;
  197. vars[0].bstrVal = data;
  198. DISPPARAMS disp = { (VARIANT*)&vars, NULL, 1, 0 };
  199. HRESULT hr = pDispatch->Invoke(DISPID_DATACHANNELEVEVENTS_DATAREADY, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL);
  200. }
  201. }
  202. }
  203. };
  204. #endif