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.

346 lines
8.9 KiB

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