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.

351 lines
8.2 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation, 1997 - 1999
  3. Module Name:
  4. cimpsens.cxx
  5. Abstract:
  6. The core implementation for the ISensNetwork interface.
  7. Author:
  8. Gopal Parupudi <GopalP>
  9. [Notes:]
  10. optional-notes
  11. Revision History:
  12. GopalP 11/17/1997 Start.
  13. --*/
  14. #include <common.hxx>
  15. #include <ole2.h>
  16. #include <oleauto.h>
  17. #include "sinkcomn.hxx"
  18. #include "cimpsens.hxx"
  19. #include "sensevts.h"
  20. extern ITypeInfo *gpITypeInfo;
  21. //
  22. // Constructors and Destructors
  23. //
  24. CImpISensNetwork::CImpISensNetwork(
  25. void
  26. ) : m_cRef(0L), m_pfnDestroy(NULL)
  27. {
  28. }
  29. CImpISensNetwork::CImpISensNetwork(
  30. LPFNDESTROYED pfnDestroy
  31. ) : m_cRef(0L), m_pfnDestroy(pfnDestroy)
  32. {
  33. }
  34. CImpISensNetwork::~CImpISensNetwork(
  35. void
  36. )
  37. {
  38. // Empty destructor
  39. }
  40. //
  41. // Standard QueryInterface
  42. //
  43. STDMETHODIMP
  44. CImpISensNetwork::QueryInterface(
  45. REFIID riid,
  46. LPVOID *ppv
  47. )
  48. {
  49. DebugTraceGuid("CImpISensNetwork::QueryInterface()", riid);
  50. HRESULT hr = S_OK;
  51. *ppv = NULL; // To handle failure cases
  52. // IUnknown
  53. if (IsEqualIID(riid, IID_IUnknown))
  54. {
  55. *ppv = (LPUNKNOWN) this;
  56. }
  57. else
  58. // IDispatch
  59. if (IsEqualIID(riid, IID_IDispatch))
  60. {
  61. *ppv = (IDispatch *) this;
  62. }
  63. else
  64. // ISensNetwork
  65. if (IsEqualIID(riid, IID_ISensNetwork))
  66. {
  67. *ppv = (ISensNetwork *) this;
  68. }
  69. else
  70. {
  71. hr = E_NOINTERFACE;
  72. }
  73. if (NULL != *ppv)
  74. {
  75. ((LPUNKNOWN)*ppv)->AddRef();
  76. }
  77. return hr;
  78. }
  79. //
  80. // Standard AddRef and Release
  81. //
  82. STDMETHODIMP_(ULONG)
  83. CImpISensNetwork::AddRef(
  84. void
  85. )
  86. {
  87. return InterlockedIncrement((PLONG) &m_cRef);
  88. }
  89. STDMETHODIMP_(ULONG)
  90. CImpISensNetwork::Release(
  91. void
  92. )
  93. {
  94. ULONG cRefT;
  95. cRefT = InterlockedDecrement((PLONG) &m_cRef);
  96. if (0 == m_cRef)
  97. {
  98. // Invoke the callback function.
  99. if (NULL != m_pfnDestroy)
  100. {
  101. (*m_pfnDestroy)();
  102. }
  103. delete this;
  104. }
  105. return cRefT;
  106. }
  107. //
  108. // IDispatch member function implementations.
  109. //
  110. STDMETHODIMP
  111. CImpISensNetwork::GetTypeInfoCount(
  112. UINT *pCountITypeInfo
  113. )
  114. {
  115. SensPrintA(SENS_INFO, ("\t| CImpISensNetwork::GetTypeInfoCount() called.\n"));
  116. // We implement GetTypeInfo, so return 1.
  117. *pCountITypeInfo = 1;
  118. return NOERROR;
  119. }
  120. STDMETHODIMP
  121. CImpISensNetwork::GetTypeInfo(
  122. UINT iTypeInfo,
  123. LCID lcid,
  124. ITypeInfo **ppITypeInfo
  125. )
  126. {
  127. SensPrintA(SENS_INFO, ("\t| CImpISensNetwork::GetTypeInfo() called.\n"));
  128. *ppITypeInfo = NULL;
  129. if (iTypeInfo != 0)
  130. {
  131. return DISP_E_BADINDEX;
  132. }
  133. // Call AddRef and return the pointer.
  134. gpITypeInfo->AddRef();
  135. *ppITypeInfo = gpITypeInfo;
  136. return S_OK;
  137. }
  138. STDMETHODIMP
  139. CImpISensNetwork::GetIDsOfNames(
  140. REFIID riid,
  141. LPOLESTR *arrNames,
  142. UINT cNames,
  143. LCID lcid,
  144. DISPID *arrDispIDs)
  145. {
  146. HRESULT hr;
  147. SensPrintA(SENS_INFO, ("\t| CImpISensNetwork::GetIDsOfNames() called.\n"));
  148. if (riid != IID_NULL)
  149. {
  150. return DISP_E_UNKNOWNINTERFACE;
  151. }
  152. hr = gpITypeInfo->GetIDsOfNames(
  153. arrNames,
  154. cNames,
  155. arrDispIDs
  156. );
  157. return hr;
  158. }
  159. STDMETHODIMP
  160. CImpISensNetwork::Invoke(
  161. DISPID dispID,
  162. REFIID riid,
  163. LCID lcid,
  164. WORD wFlags,
  165. DISPPARAMS *pDispParams,
  166. VARIANT *pvarResult,
  167. EXCEPINFO *pExecpInfo,
  168. UINT *puArgErr
  169. )
  170. {
  171. HRESULT hr;
  172. SensPrintA(SENS_INFO, ("\t| CImpISensNetwork::Invoke() called.\n"));
  173. if (riid != IID_NULL)
  174. {
  175. return DISP_E_UNKNOWNINTERFACE;
  176. }
  177. hr = gpITypeInfo->Invoke(
  178. (IDispatch*) this,
  179. dispID,
  180. wFlags,
  181. pDispParams,
  182. pvarResult,
  183. pExecpInfo,
  184. puArgErr
  185. );
  186. return hr;
  187. }
  188. STDMETHODIMP_(void)
  189. CImpISensNetwork::ConnectionMade(
  190. BSTR bstrConnection,
  191. ULONG ulType,
  192. SENS_QOCINFO QOCInfo
  193. )
  194. {
  195. SensPrintA(SENS_INFO, ("---------------------------------------------------------\n"));
  196. SensPrintA(SENS_INFO, ("CImpISensNetwork::ConnectionMade() called\n\n"));
  197. SensPrintW(SENS_INFO, (L" bstrConnection - %s\n", bstrConnection));
  198. SensPrintA(SENS_INFO, (" ulType - 0x%x\n", ulType));
  199. SensPrintA(SENS_INFO, (" QOCInfo - 0x%x\n", QOCInfo));
  200. SensPrintA(SENS_INFO, ("---------------------------------------------------------\n"));
  201. }
  202. STDMETHODIMP_(void)
  203. CImpISensNetwork::ConnectionMadeNoQOCInfo(
  204. BSTR bstrConnection,
  205. ULONG ulType
  206. )
  207. {
  208. SensPrintA(SENS_INFO, ("---------------------------------------------------------\n"));
  209. SensPrintA(SENS_INFO, ("CImpISensNetwork::ConnectionMadeNoQOCInfo() called\n\n"));
  210. SensPrintW(SENS_INFO, (L" bstrConnection - %s\n", bstrConnection));
  211. SensPrintA(SENS_INFO, (" ulType - 0x%x\n", ulType));
  212. SensPrintA(SENS_INFO, ("---------------------------------------------------------\n"));
  213. }
  214. STDMETHODIMP_(void)
  215. CImpISensNetwork::ConnectionLost(
  216. BSTR bstrConnection,
  217. ULONG ulType
  218. )
  219. {
  220. SensPrintA(SENS_INFO, ("---------------------------------------------------------\n"));
  221. SensPrintA(SENS_INFO, ("CImpISensNetwork::ConnectionLost() called\n\n"));
  222. SensPrintW(SENS_INFO, (L" bstrConnection - %s\n", bstrConnection));
  223. SensPrintA(SENS_INFO, (" ulType - 0x%x\n", ulType));
  224. SensPrintA(SENS_INFO, ("---------------------------------------------------------\n"));
  225. }
  226. STDMETHODIMP_(void)
  227. CImpISensNetwork::BeforeDisconnect(
  228. BSTR bstrConnection,
  229. ULONG ulType
  230. )
  231. {
  232. SensPrintA(SENS_INFO, ("---------------------------------------------------------\n"));
  233. SensPrintA(SENS_INFO, ("CImpISensNetwork::BeforeDisconnect() called\n\n"));
  234. SensPrintW(SENS_INFO, (L" bstrConnection - %s\n", bstrConnection));
  235. SensPrintA(SENS_INFO, (" ulType - 0x%x\n", ulType));
  236. SensPrintA(SENS_INFO, ("---------------------------------------------------------\n"));
  237. }
  238. STDMETHODIMP_(void)
  239. CImpISensNetwork::DestinationReachable(
  240. BSTR bstrDestination,
  241. BSTR bstrConnection,
  242. ULONG ulType,
  243. SENS_QOCINFO QOCInfo
  244. )
  245. {
  246. SensPrintA(SENS_INFO, ("---------------------------------------------------------\n"));
  247. SensPrintA(SENS_INFO, ("CImpISensNetwork::DestinationReachable() called\n\n"));
  248. SensPrintW(SENS_INFO, (L" bstrDestination - %s\n", bstrDestination));
  249. SensPrintW(SENS_INFO, (L" bstrConnection - %s\n", bstrConnection));
  250. SensPrintA(SENS_INFO, (" ulType - 0x%x\n", ulType));
  251. SensPrintA(SENS_INFO, (" QOCInfo - 0x%x\n", QOCInfo));
  252. SensPrintA(SENS_INFO, ("---------------------------------------------------------\n"));
  253. }
  254. STDMETHODIMP_(void)
  255. CImpISensNetwork::DestinationReachableNoQOCInfo(
  256. BSTR bstrDestination,
  257. BSTR bstrConnection,
  258. ULONG ulType
  259. )
  260. {
  261. SensPrintA(SENS_INFO, ("---------------------------------------------------------\n"));
  262. SensPrintA(SENS_INFO, ("CImpISensNetwork::DestinationReachableNoQOCInfo() called\n\n"));
  263. SensPrintW(SENS_INFO, (L" bstrDestination - %s\n", bstrDestination));
  264. SensPrintW(SENS_INFO, (L" bstrConnection - %s\n", bstrConnection));
  265. SensPrintA(SENS_INFO, (" ulType - 0x%x\n", ulType));
  266. SensPrintA(SENS_INFO, ("---------------------------------------------------------\n"));
  267. }
  268. STDMETHODIMP_(void)
  269. CImpISensNetwork::FooFunc(
  270. BSTR bstrConnection
  271. )
  272. {
  273. SensPrintA(SENS_INFO, ("---------------------------------------------------------\n"));
  274. SensPrintA(SENS_INFO, ("CImpISensNetwork::FooFunc() called\n\n"));
  275. SensPrintW(SENS_INFO, (L" bstrConnection - %s\n", bstrConnection));
  276. SensPrintA(SENS_INFO, ("---------------------------------------------------------\n"));
  277. }