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.

391 lines
7.8 KiB

  1. /*
  2. * WRAP.C
  3. *
  4. * Wrapped IProp
  5. */
  6. #include "_apipch.h"
  7. /*********************************************************************
  8. *
  9. * The actual Wrapped IMAPIProp methods
  10. *
  11. */
  12. //
  13. // Wrapped IMAPIProp jump table is defined here...
  14. // Try to use as much of IAB as possible.
  15. //
  16. WRAP_Vtbl vtblWRAP_OOP = {
  17. VTABLE_FILL
  18. (WRAP_QueryInterface_METHOD *) IAB_QueryInterface,
  19. WRAP_AddRef,
  20. WRAP_Release,
  21. (WRAP_GetLastError_METHOD *) IAB_GetLastError,
  22. WRAP_SaveChanges,
  23. WRAP_GetProps,
  24. WRAP_GetPropList,
  25. WRAP_OpenProperty,
  26. WRAP_SetProps,
  27. WRAP_DeleteProps,
  28. WRAP_CopyTo,
  29. WRAP_CopyProps,
  30. WRAP_GetNamesFromIDs,
  31. WRAP_GetIDsFromNames,
  32. };
  33. /**************************************************
  34. *
  35. * WRAP_AddRef
  36. * Increment lcInit
  37. *
  38. */
  39. STDMETHODIMP_(ULONG) WRAP_AddRef(LPWRAP lpWRAP)
  40. {
  41. #ifdef PARAMETER_VALIDATION
  42. // Check to see if it has a jump table
  43. if (IsBadReadPtr(lpWRAP, sizeof(LPVOID))) {
  44. //No jump table found
  45. return(1);
  46. }
  47. // Check to see if the jump table has at least sizeof IUnknown
  48. if (IsBadReadPtr(lpWRAP->lpVtbl, 3 * sizeof(LPVOID))) {
  49. // Jump table not derived from IUnknown
  50. return(1);
  51. }
  52. // Check to see if the method is the same
  53. if (WRAP_AddRef != lpWRAP->lpVtbl->AddRef) {
  54. // Wrong object - the object passed doesn't have this
  55. // method.
  56. return(1);
  57. }
  58. #endif // PARAMETER_VALIDATION
  59. EnterCriticalSection(&lpWRAP->cs);
  60. ++lpWRAP->lcInit;
  61. LeaveCriticalSection(&lpWRAP->cs);
  62. return(lpWRAP->lcInit);
  63. }
  64. STDMETHODIMP_(ULONG)
  65. WRAP_Release (LPWRAP lpWRAP)
  66. {
  67. #if !defined(NO_VALIDATION)
  68. // Make sure the object is valid.
  69. if (BAD_STANDARD_OBJ(lpWRAP, WRAP_, Release, lpVtbl)) {
  70. return(1);
  71. }
  72. #endif
  73. EnterCriticalSection(&lpWRAP->cs);
  74. --lpWRAP->lcInit;
  75. if (lpWRAP->lcInit == 0) {
  76. UlRelease(lpWRAP->lpPropData);
  77. //
  78. // Need to free the object
  79. //
  80. LeaveCriticalSection(&lpWRAP->cs);
  81. DeleteCriticalSection(&lpWRAP->cs);
  82. FreeBufferAndNull(&lpWRAP);
  83. return(0);
  84. }
  85. LeaveCriticalSection(&lpWRAP->cs);
  86. return(lpWRAP->lcInit);
  87. }
  88. // IProperty
  89. STDMETHODIMP
  90. WRAP_SaveChanges (LPWRAP lpWRAP,
  91. ULONG ulFlags)
  92. {
  93. #if !defined(NO_VALIDATION)
  94. /* Make sure the object is valid.
  95. */
  96. if (BAD_STANDARD_OBJ(lpWRAP, WRAP_, SaveChanges, lpVtbl))
  97. {
  98. return ResultFromScode(MAPI_E_INVALID_PARAMETER);
  99. }
  100. #endif
  101. return lpWRAP->lpPropData->lpVtbl->SaveChanges(
  102. lpWRAP->lpPropData,
  103. ulFlags);
  104. }
  105. STDMETHODIMP
  106. WRAP_GetProps (LPWRAP lpWRAP,
  107. LPSPropTagArray lpPropTagArray,
  108. ULONG ulFlags,
  109. ULONG * lpcValues,
  110. LPSPropValue * lppPropArray)
  111. {
  112. #if !defined(NO_VALIDATION)
  113. /* Make sure the object is valid.
  114. */
  115. if (BAD_STANDARD_OBJ(lpWRAP, WRAP_, GetProps, lpVtbl))
  116. {
  117. return ResultFromScode(MAPI_E_INVALID_PARAMETER);
  118. }
  119. #endif
  120. return lpWRAP->lpPropData->lpVtbl->GetProps(
  121. lpWRAP->lpPropData,
  122. lpPropTagArray,
  123. ulFlags,
  124. lpcValues,
  125. lppPropArray);
  126. }
  127. STDMETHODIMP
  128. WRAP_GetPropList (LPWRAP lpWRAP,
  129. ULONG ulFlags,
  130. LPSPropTagArray * lppPropTagArray)
  131. {
  132. #if !defined(NO_VALIDATION)
  133. /* Make sure the object is valid.
  134. */
  135. if (BAD_STANDARD_OBJ(lpWRAP, WRAP_, GetPropList, lpVtbl))
  136. {
  137. return ResultFromScode(MAPI_E_INVALID_PARAMETER);
  138. }
  139. #endif
  140. return lpWRAP->lpPropData->lpVtbl->GetPropList(
  141. lpWRAP->lpPropData,
  142. ulFlags,
  143. lppPropTagArray);
  144. }
  145. STDMETHODIMP
  146. WRAP_OpenProperty (LPWRAP lpWRAP,
  147. ULONG ulPropTag,
  148. LPCIID lpiid,
  149. ULONG ulInterfaceOptions,
  150. ULONG ulFlags,
  151. LPUNKNOWN * lppUnk)
  152. {
  153. #if !defined(NO_VALIDATION)
  154. /* Make sure the object is valid.
  155. */
  156. if (BAD_STANDARD_OBJ(lpWRAP, WRAP_, OpenProperty, lpVtbl))
  157. {
  158. return ResultFromScode(MAPI_E_INVALID_PARAMETER);
  159. }
  160. #endif
  161. return lpWRAP->lpPropData->lpVtbl->OpenProperty(
  162. lpWRAP->lpPropData,
  163. ulPropTag,
  164. lpiid,
  165. ulInterfaceOptions,
  166. ulFlags,
  167. lppUnk);
  168. }
  169. STDMETHODIMP
  170. WRAP_SetProps (LPWRAP lpWRAP,
  171. ULONG cValues,
  172. LPSPropValue lpPropArray,
  173. LPSPropProblemArray * lppProblems)
  174. {
  175. #if !defined(NO_VALIDATION)
  176. /* Make sure the object is valid.
  177. */
  178. if (BAD_STANDARD_OBJ(lpWRAP, WRAP_, SetProps, lpVtbl))
  179. {
  180. return ResultFromScode(MAPI_E_INVALID_PARAMETER);
  181. }
  182. #endif
  183. return lpWRAP->lpPropData->lpVtbl->SetProps(
  184. lpWRAP->lpPropData,
  185. cValues,
  186. lpPropArray,
  187. lppProblems);
  188. }
  189. STDMETHODIMP
  190. WRAP_DeleteProps (LPWRAP lpWRAP,
  191. LPSPropTagArray lpPropTagArray,
  192. LPSPropProblemArray * lppProblems)
  193. {
  194. #if !defined(NO_VALIDATION)
  195. /* Make sure the object is valid.
  196. */
  197. if (BAD_STANDARD_OBJ(lpWRAP, WRAP_, DeleteProps, lpVtbl))
  198. {
  199. return ResultFromScode(MAPI_E_INVALID_PARAMETER);
  200. }
  201. #endif
  202. return lpWRAP->lpPropData->lpVtbl->DeleteProps(
  203. lpWRAP->lpPropData,
  204. lpPropTagArray,
  205. lppProblems);
  206. }
  207. STDMETHODIMP
  208. WRAP_CopyTo ( LPWRAP lpWRAP,
  209. ULONG ciidExclude,
  210. LPCIID rgiidExclude,
  211. LPSPropTagArray lpExcludeProps,
  212. ULONG_PTR ulUIParam,
  213. LPMAPIPROGRESS lpProgress,
  214. LPCIID lpInterface,
  215. LPVOID lpDestObj,
  216. ULONG ulFlags,
  217. LPSPropProblemArray * lppProblems)
  218. {
  219. #if !defined(NO_VALIDATION)
  220. /* Make sure the object is valid.
  221. */
  222. if (BAD_STANDARD_OBJ(lpWRAP, WRAP_, CopyTo, lpVtbl))
  223. {
  224. return ResultFromScode(MAPI_E_INVALID_PARAMETER);
  225. }
  226. #endif
  227. // Make sure we're not copying to ourselves
  228. if ((LPVOID)lpWRAP == (LPVOID)lpDestObj)
  229. {
  230. DebugTrace( TEXT("OOP WRAP_CopyTo(): Copying to self is not supported\n"));
  231. return ResultFromScode(MAPI_E_NO_ACCESS);
  232. }
  233. return lpWRAP->lpPropData->lpVtbl->CopyTo(
  234. lpWRAP->lpPropData,
  235. ciidExclude,
  236. rgiidExclude,
  237. lpExcludeProps,
  238. ulUIParam,
  239. lpProgress,
  240. lpInterface,
  241. lpDestObj,
  242. ulFlags,
  243. lppProblems);
  244. }
  245. STDMETHODIMP
  246. WRAP_CopyProps ( LPWRAP lpWRAP,
  247. LPSPropTagArray lpIncludeProps,
  248. ULONG_PTR ulUIParam,
  249. LPMAPIPROGRESS lpProgress,
  250. LPCIID lpInterface,
  251. LPVOID lpDestObj,
  252. ULONG ulFlags,
  253. LPSPropProblemArray * lppProblems)
  254. {
  255. #if !defined(NO_VALIDATION)
  256. /* Make sure the object is valid.
  257. */
  258. if (BAD_STANDARD_OBJ(lpWRAP, WRAP_, CopyProps, lpVtbl))
  259. {
  260. return ResultFromScode(MAPI_E_INVALID_PARAMETER);
  261. }
  262. #endif
  263. return lpWRAP->lpPropData->lpVtbl->CopyProps(
  264. lpWRAP->lpPropData,
  265. lpIncludeProps,
  266. ulUIParam,
  267. lpProgress,
  268. lpInterface,
  269. lpDestObj,
  270. ulFlags,
  271. lppProblems);
  272. }
  273. STDMETHODIMP
  274. WRAP_GetNamesFromIDs ( LPWRAP lpWRAP,
  275. LPSPropTagArray * lppPropTags,
  276. LPGUID lpPropSetGuid,
  277. ULONG ulFlags,
  278. ULONG * lpcPropNames,
  279. LPMAPINAMEID ** lpppPropNames)
  280. {
  281. #if !defined(NO_VALIDATION)
  282. /* Make sure the object is valid.
  283. */
  284. if (BAD_STANDARD_OBJ(lpWRAP, WRAP_, GetNamesFromIDs, lpVtbl))
  285. {
  286. return ResultFromScode(MAPI_E_INVALID_PARAMETER);
  287. }
  288. #endif
  289. return lpWRAP->lpPropData->lpVtbl->GetNamesFromIDs(
  290. lpWRAP->lpPropData,
  291. lppPropTags,
  292. lpPropSetGuid,
  293. ulFlags,
  294. lpcPropNames,
  295. lpppPropNames);
  296. }
  297. STDMETHODIMP
  298. WRAP_GetIDsFromNames ( LPWRAP lpWRAP,
  299. ULONG cPropNames,
  300. LPMAPINAMEID * lppPropNames,
  301. ULONG ulFlags,
  302. LPSPropTagArray * lppPropTags)
  303. {
  304. #if !defined(NO_VALIDATION)
  305. /* Make sure the object is valid.
  306. */
  307. if (BAD_STANDARD_OBJ(lpWRAP, WRAP_, GetIDsFromNames, lpVtbl))
  308. {
  309. return ResultFromScode(MAPI_E_INVALID_PARAMETER);
  310. }
  311. #endif
  312. return lpWRAP->lpPropData->lpVtbl->GetIDsFromNames(
  313. lpWRAP->lpPropData,
  314. cPropNames,
  315. lppPropNames,
  316. ulFlags,
  317. lppPropTags);
  318. }