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.

480 lines
9.1 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1995 - 1999
  6. //
  7. // File: viewrow.cpp
  8. //
  9. // Contents: IEnumCERTVIEWROW IDispatch helper functions
  10. //
  11. //--------------------------------------------------------------------------
  12. #include <pch.cpp>
  13. #pragma hdrstop
  14. #include <stdlib.h>
  15. #include "csdisp.h"
  16. #include "csprop.h"
  17. //+------------------------------------------------------------------------
  18. // IEnumCERTVIEWROW dispatch support
  19. //+------------------------------------
  20. // OpenConnection method:
  21. static OLECHAR *_apszNext[] = {
  22. TEXT("Next"),
  23. };
  24. //+------------------------------------
  25. // EnumCertViewColumn method:
  26. static OLECHAR *_apszEnumCertViewColumn[] = {
  27. TEXT("EnumCertViewColumn"),
  28. };
  29. //+------------------------------------
  30. // EnumCertViewAttribute method:
  31. static OLECHAR *_apszEnumCertViewAttribute[] = {
  32. TEXT("EnumCertViewAttribute"),
  33. TEXT("Flags"),
  34. };
  35. //+------------------------------------
  36. // EnumCertViewExtension method:
  37. static OLECHAR *_apszEnumCertViewExtension[] = {
  38. TEXT("EnumCertViewExtension"),
  39. TEXT("Flags"),
  40. };
  41. //+------------------------------------
  42. // Skip method:
  43. static OLECHAR *_apszSkip[] = {
  44. TEXT("Skip"),
  45. TEXT("celt"),
  46. };
  47. //+------------------------------------
  48. // Reset method:
  49. static OLECHAR *_apszReset[] = {
  50. TEXT("Reset"),
  51. };
  52. //+------------------------------------
  53. // Clone method:
  54. static OLECHAR *_apszClone[] = {
  55. TEXT("Clone"),
  56. };
  57. //+------------------------------------
  58. // GetMaxIndex method:
  59. static OLECHAR *_apszGetMaxIndex[] = {
  60. TEXT("GetMaxIndex"),
  61. };
  62. //+------------------------------------
  63. // Dispatch Table:
  64. DISPATCHTABLE g_adtViewRow[] =
  65. {
  66. #define VIEWROW_NEXT 0
  67. DECLARE_DISPATCH_ENTRY(_apszNext)
  68. #define VIEWROW_ENUMCERTVIEWCOLUMN 1
  69. DECLARE_DISPATCH_ENTRY(_apszEnumCertViewColumn)
  70. #define VIEWROW_ENUMCERTVIEWATTRIBUTE 2
  71. DECLARE_DISPATCH_ENTRY(_apszEnumCertViewAttribute)
  72. #define VIEWROW_ENUMCERTVIEWEXTENSION 3
  73. DECLARE_DISPATCH_ENTRY(_apszEnumCertViewExtension)
  74. #define VIEWROW_SKIP 4
  75. DECLARE_DISPATCH_ENTRY(_apszSkip)
  76. #define VIEWROW_RESET 5
  77. DECLARE_DISPATCH_ENTRY(_apszReset)
  78. #define VIEWROW_CLONE 6
  79. DECLARE_DISPATCH_ENTRY(_apszClone)
  80. #define VIEWROW_GETMAXINDEX 7
  81. DECLARE_DISPATCH_ENTRY(_apszGetMaxIndex)
  82. };
  83. #define CVIEWROWDISPATCH (ARRAYSIZE(g_adtViewRow))
  84. HRESULT
  85. ViewRow_Init2(
  86. IN BOOL fIDispatch,
  87. IN IEnumCERTVIEWROW *pEnumRow,
  88. OUT DISPATCHINTERFACE *pdiViewRow)
  89. {
  90. HRESULT hr;
  91. IDispatch *pDispatch = NULL;
  92. pdiViewRow->pDispatchTable = NULL;
  93. pdiViewRow->pDispatch = NULL;
  94. pdiViewRow->pUnknown = NULL;
  95. if (fIDispatch)
  96. {
  97. hr = pEnumRow->QueryInterface(
  98. IID_IDispatch,
  99. (VOID **) &pDispatch);
  100. _JumpIfError(hr, error, "QueryInterface");
  101. hr = DispatchGetIds(
  102. pDispatch,
  103. CVIEWROWDISPATCH,
  104. g_adtViewRow,
  105. pdiViewRow);
  106. _JumpIfError(hr, error, "DispatchGetIds");
  107. pdiViewRow->pDispatch = pDispatch;
  108. pDispatch = NULL;
  109. }
  110. else
  111. {
  112. pEnumRow->AddRef();
  113. pdiViewRow->pUnknown = (IUnknown *) pEnumRow;
  114. hr = S_OK;
  115. }
  116. pdiViewRow->pDispatchTable = g_adtViewRow;
  117. error:
  118. if (NULL != pDispatch)
  119. {
  120. pDispatch->Release();
  121. }
  122. return(hr);
  123. }
  124. VOID
  125. ViewRow_Release(
  126. IN OUT DISPATCHINTERFACE *pdiViewRow)
  127. {
  128. DispatchRelease(pdiViewRow);
  129. }
  130. HRESULT
  131. ViewRow_Next(
  132. IN DISPATCHINTERFACE *pdiViewRow,
  133. OUT LONG *pIndex)
  134. {
  135. HRESULT hr;
  136. CSASSERT(NULL != pdiViewRow && NULL != pdiViewRow->pDispatchTable);
  137. if (NULL != pdiViewRow->pDispatch)
  138. {
  139. hr = DispatchInvoke(
  140. pdiViewRow,
  141. VIEWROW_NEXT,
  142. 0,
  143. NULL,
  144. VT_I4,
  145. pIndex);
  146. _JumpIfError2(hr, error, "Invoke(Next)", S_FALSE);
  147. }
  148. else
  149. {
  150. hr = ((IEnumCERTVIEWROW *) pdiViewRow->pUnknown)->Next(pIndex);
  151. _JumpIfError2(hr, error, "Next", S_FALSE);
  152. }
  153. error:
  154. return(hr);
  155. }
  156. HRESULT
  157. ViewRow_EnumCertViewColumn(
  158. IN DISPATCHINTERFACE *pdiViewRow,
  159. OUT DISPATCHINTERFACE *pdiViewColumn)
  160. {
  161. HRESULT hr;
  162. IEnumCERTVIEWCOLUMN *pEnumColumn = NULL;
  163. CSASSERT(NULL != pdiViewRow && NULL != pdiViewRow->pDispatchTable);
  164. if (NULL != pdiViewRow->pDispatch)
  165. {
  166. hr = DispatchInvoke(
  167. pdiViewRow,
  168. VIEWROW_ENUMCERTVIEWCOLUMN,
  169. 0,
  170. NULL,
  171. VT_DISPATCH,
  172. &pEnumColumn);
  173. _JumpIfError(hr, error, "Invoke(EnumCertViewColumn)");
  174. }
  175. else
  176. {
  177. hr = ((IEnumCERTVIEWROW *) pdiViewRow->pUnknown)->EnumCertViewColumn(
  178. &pEnumColumn);
  179. _JumpIfError(hr, error, "EnumCertViewColumn");
  180. }
  181. hr = ViewColumn_Init2(
  182. NULL != pdiViewRow->pDispatch,
  183. pEnumColumn,
  184. pdiViewColumn);
  185. _JumpIfError(hr, error, "ViewColumn_Init2");
  186. error:
  187. if (NULL != pEnumColumn)
  188. {
  189. pEnumColumn->Release();
  190. }
  191. return(hr);
  192. }
  193. HRESULT
  194. ViewRow_EnumCertViewAttribute(
  195. IN DISPATCHINTERFACE *pdiViewRow,
  196. IN LONG Flags,
  197. OUT DISPATCHINTERFACE *pdiViewAttribute)
  198. {
  199. HRESULT hr;
  200. IEnumCERTVIEWATTRIBUTE *pEnumAttribute = NULL;
  201. CSASSERT(NULL != pdiViewRow && NULL != pdiViewRow->pDispatchTable);
  202. if (NULL != pdiViewRow->pDispatch)
  203. {
  204. VARIANT avar[1];
  205. avar[0].vt = VT_I4;
  206. avar[0].lVal = Flags;
  207. hr = DispatchInvoke(
  208. pdiViewRow,
  209. VIEWROW_ENUMCERTVIEWATTRIBUTE,
  210. ARRAYSIZE(avar),
  211. avar,
  212. VT_DISPATCH,
  213. &pEnumAttribute);
  214. _JumpIfError(hr, error, "Invoke(EnumCertViewAttribute)");
  215. }
  216. else
  217. {
  218. hr = ((IEnumCERTVIEWROW *) pdiViewRow->pUnknown)->EnumCertViewAttribute(
  219. Flags,
  220. &pEnumAttribute);
  221. _JumpIfError(hr, error, "EnumCertViewAttribute");
  222. }
  223. hr = ViewAttribute_Init2(
  224. NULL != pdiViewRow->pDispatch,
  225. pEnumAttribute,
  226. pdiViewAttribute);
  227. _JumpIfError(hr, error, "ViewAttribute_Init2");
  228. error:
  229. if (NULL != pEnumAttribute)
  230. {
  231. pEnumAttribute->Release();
  232. }
  233. return(hr);
  234. }
  235. HRESULT
  236. ViewRow_EnumCertViewExtension(
  237. IN DISPATCHINTERFACE *pdiViewRow,
  238. IN LONG Flags,
  239. OUT DISPATCHINTERFACE *pdiViewExtension)
  240. {
  241. HRESULT hr;
  242. IEnumCERTVIEWEXTENSION *pEnumExtension = NULL;
  243. CSASSERT(NULL != pdiViewRow && NULL != pdiViewRow->pDispatchTable);
  244. if (NULL != pdiViewRow->pDispatch)
  245. {
  246. VARIANT avar[1];
  247. avar[0].vt = VT_I4;
  248. avar[0].lVal = Flags;
  249. hr = DispatchInvoke(
  250. pdiViewRow,
  251. VIEWROW_ENUMCERTVIEWEXTENSION,
  252. ARRAYSIZE(avar),
  253. avar,
  254. VT_DISPATCH,
  255. &pEnumExtension);
  256. _JumpIfError(hr, error, "Invoke(EnumCertViewExtension)");
  257. }
  258. else
  259. {
  260. hr = ((IEnumCERTVIEWROW *) pdiViewRow->pUnknown)->EnumCertViewExtension(
  261. Flags,
  262. &pEnumExtension);
  263. _JumpIfError(hr, error, "EnumCertViewExtension");
  264. }
  265. hr = ViewExtension_Init2(
  266. NULL != pdiViewRow->pDispatch,
  267. pEnumExtension,
  268. pdiViewExtension);
  269. _JumpIfError(hr, error, "ViewExtension_Init2");
  270. error:
  271. if (NULL != pEnumExtension)
  272. {
  273. pEnumExtension->Release();
  274. }
  275. return(hr);
  276. }
  277. HRESULT
  278. ViewRow_Skip(
  279. IN DISPATCHINTERFACE *pdiViewRow,
  280. IN LONG celt)
  281. {
  282. HRESULT hr;
  283. CSASSERT(NULL != pdiViewRow && NULL != pdiViewRow->pDispatchTable);
  284. if (NULL != pdiViewRow->pDispatch)
  285. {
  286. VARIANT avar[1];
  287. avar[0].vt = VT_I4;
  288. avar[0].lVal = celt;
  289. hr = DispatchInvoke(
  290. pdiViewRow,
  291. VIEWROW_SKIP,
  292. ARRAYSIZE(avar),
  293. avar,
  294. 0,
  295. NULL);
  296. _JumpIfError(hr, error, "Invoke(Skip)");
  297. }
  298. else
  299. {
  300. hr = ((IEnumCERTVIEWROW *) pdiViewRow->pUnknown)->Skip(celt);
  301. _JumpIfError(hr, error, "Skip");
  302. }
  303. error:
  304. return(hr);
  305. }
  306. HRESULT
  307. ViewRow_Reset(
  308. IN DISPATCHINTERFACE *pdiViewRow)
  309. {
  310. HRESULT hr;
  311. CSASSERT(NULL != pdiViewRow && NULL != pdiViewRow->pDispatchTable);
  312. if (NULL != pdiViewRow->pDispatch)
  313. {
  314. hr = DispatchInvoke(
  315. pdiViewRow,
  316. VIEWROW_RESET,
  317. 0,
  318. NULL,
  319. 0,
  320. NULL);
  321. _JumpIfError(hr, error, "Invoke(Reset)");
  322. }
  323. else
  324. {
  325. hr = ((IEnumCERTVIEWROW *) pdiViewRow->pUnknown)->Reset();
  326. _JumpIfError(hr, error, "Reset");
  327. }
  328. error:
  329. return(hr);
  330. }
  331. HRESULT
  332. ViewRow_Clone(
  333. IN DISPATCHINTERFACE *pdiViewRow,
  334. OUT DISPATCHINTERFACE *pdiViewRowClone)
  335. {
  336. HRESULT hr;
  337. IEnumCERTVIEWROW *pEnumRow = NULL;
  338. CSASSERT(NULL != pdiViewRow && NULL != pdiViewRow->pDispatchTable);
  339. if (NULL != pdiViewRow->pDispatch)
  340. {
  341. hr = DispatchInvoke(
  342. pdiViewRow,
  343. VIEWROW_CLONE,
  344. 0,
  345. NULL,
  346. VT_DISPATCH,
  347. &pEnumRow);
  348. _JumpIfError(hr, error, "Invoke(Clone)");
  349. }
  350. else
  351. {
  352. hr = ((IEnumCERTVIEWROW *) pdiViewRow->pUnknown)->Clone(&pEnumRow);
  353. _JumpIfError(hr, error, "Clone");
  354. }
  355. hr = ViewRow_Init2(
  356. NULL != pdiViewRow->pDispatch,
  357. pEnumRow,
  358. pdiViewRowClone);
  359. _JumpIfError(hr, error, "ViewRow_Init2");
  360. error:
  361. if (NULL != pEnumRow)
  362. {
  363. pEnumRow->Release();
  364. }
  365. return(hr);
  366. }
  367. HRESULT
  368. ViewRow_GetMaxIndex(
  369. IN DISPATCHINTERFACE *pdiViewRow,
  370. OUT LONG *pIndex)
  371. {
  372. HRESULT hr;
  373. CSASSERT(NULL != pdiViewRow && NULL != pdiViewRow->pDispatchTable);
  374. if (NULL != pdiViewRow->pDispatch)
  375. {
  376. hr = DispatchInvoke(
  377. pdiViewRow,
  378. VIEWROW_GETMAXINDEX,
  379. 0,
  380. NULL,
  381. VT_I4,
  382. pIndex);
  383. _JumpIfError2(hr, error, "Invoke(GetMaxIndex)", E_UNEXPECTED);
  384. }
  385. else
  386. {
  387. hr = ((IEnumCERTVIEWROW *) pdiViewRow->pUnknown)->GetMaxIndex(pIndex);
  388. _JumpIfError2(hr, error, "GetMaxIndex", E_UNEXPECTED);
  389. }
  390. error:
  391. return(hr);
  392. }