4 * Copyright 2004 Jon Griffiths
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #define WIN32_NO_STATUS
23 #define COM_NO_WINDOWS_H
26 #define NONAMELESSUNION
27 #define NONAMELESSSTRUCT
31 //#include "winerror.h"
32 //#include "winternl.h"
33 //#include "objbase.h"
35 #include <wine/list.h>
36 #include <wine/debug.h>
37 #include <wine/unicode.h>
40 WINE_DEFAULT_DEBUG_CHANNEL(mapi
);
42 BOOL WINAPI
FBadRglpszA(LPSTR
*,ULONG
);
44 /* Internal: Check if a property value array is invalid */
45 static inline ULONG
PROP_BadArray(LPSPropValue lpProp
, size_t elemSize
)
47 return IsBadReadPtr(lpProp
->Value
.MVi
.lpi
, lpProp
->Value
.MVi
.cValues
* elemSize
);
50 /*************************************************************************
51 * PropCopyMore@16 (MAPI32.76)
53 * Copy a property value.
56 * lpDest [O] Destination for the copied value
57 * lpSrc [I] Property value to copy to lpDest
58 * lpMore [I] Linked memory allocation function (pass MAPIAllocateMore())
59 * lpOrig [I] Original allocation to which memory will be linked
62 * Success: S_OK. lpDest contains a deep copy of lpSrc.
63 * Failure: MAPI_E_INVALID_PARAMETER, if any parameter is invalid,
64 * MAPI_E_NOT_ENOUGH_MEMORY, if memory allocation fails.
67 * Any elements within the property returned should not be individually
68 * freed, as they will be freed when lpOrig is.
70 SCODE WINAPI
PropCopyMore(LPSPropValue lpDest
, LPSPropValue lpSrc
,
71 ALLOCATEMORE
*lpMore
, LPVOID lpOrig
)
76 TRACE("(%p,%p,%p,%p)\n", lpDest
, lpSrc
, lpMore
, lpOrig
);
78 if (!lpDest
|| IsBadWritePtr(lpDest
, sizeof(SPropValue
)) ||
79 FBadProp(lpSrc
) || !lpMore
)
80 return MAPI_E_INVALID_PARAMETER
;
82 /* Shallow copy first, this is sufficient for properties without pointers */
85 switch (PROP_TYPE(lpSrc
->ulPropTag
))
88 scode
= lpMore(sizeof(GUID
), lpOrig
, (LPVOID
*)&lpDest
->Value
.lpguid
);
90 *lpDest
->Value
.lpguid
= *lpSrc
->Value
.lpguid
;
93 ulLen
= lstrlenA(lpSrc
->Value
.lpszA
) + 1u;
94 scode
= lpMore(ulLen
, lpOrig
, (LPVOID
*)&lpDest
->Value
.lpszA
);
96 memcpy(lpDest
->Value
.lpszA
, lpSrc
->Value
.lpszA
, ulLen
);
99 ulLen
= (strlenW(lpSrc
->Value
.lpszW
) + 1u) * sizeof(WCHAR
);
100 scode
= lpMore(ulLen
, lpOrig
, (LPVOID
*)&lpDest
->Value
.lpszW
);
101 if (SUCCEEDED(scode
))
102 memcpy(lpDest
->Value
.lpszW
, lpSrc
->Value
.lpszW
, ulLen
);
105 scode
= lpMore(lpSrc
->Value
.bin
.cb
, lpOrig
, (LPVOID
*)&lpDest
->Value
.bin
.lpb
);
106 if (SUCCEEDED(scode
))
107 memcpy(lpDest
->Value
.bin
.lpb
, lpSrc
->Value
.bin
.lpb
, lpSrc
->Value
.bin
.cb
);
110 if (lpSrc
->ulPropTag
& MV_FLAG
)
112 ulLen
= UlPropSize(lpSrc
);
114 if (PROP_TYPE(lpSrc
->ulPropTag
) == PT_MV_STRING8
||
115 PROP_TYPE(lpSrc
->ulPropTag
) == PT_MV_UNICODE
)
117 /* UlPropSize doesn't account for the string pointers */
118 ulLen
+= lpSrc
->Value
.MVszA
.cValues
* sizeof(char*);
120 else if (PROP_TYPE(lpSrc
->ulPropTag
) == PT_MV_BINARY
)
122 /* UlPropSize doesn't account for the SBinary structs */
123 ulLen
+= lpSrc
->Value
.MVbin
.cValues
* sizeof(SBinary
);
126 lpDest
->Value
.MVi
.cValues
= lpSrc
->Value
.MVi
.cValues
;
127 scode
= lpMore(ulLen
, lpOrig
, (LPVOID
*)&lpDest
->Value
.MVi
.lpi
);
131 /* Note that we could allocate the memory for each value in a
132 * multi-value property separately, however if an allocation failed
133 * we would be left with a bunch of allocated memory, which (while
134 * not really leaked) is unusable until lpOrig is freed. So for
135 * strings and binary arrays we make a single allocation for all
136 * of the data. This is consistent since individual elements can't
140 switch (PROP_TYPE(lpSrc
->ulPropTag
))
144 char *lpNextStr
= (char*)(lpDest
->Value
.MVszA
.lppszA
+
145 lpDest
->Value
.MVszA
.cValues
);
147 for (i
= 0; i
< lpSrc
->Value
.MVszA
.cValues
; i
++)
149 ULONG ulStrLen
= lstrlenA(lpSrc
->Value
.MVszA
.lppszA
[i
]) + 1u;
151 lpDest
->Value
.MVszA
.lppszA
[i
] = lpNextStr
;
152 memcpy(lpNextStr
, lpSrc
->Value
.MVszA
.lppszA
[i
], ulStrLen
);
153 lpNextStr
+= ulStrLen
;
159 WCHAR
*lpNextStr
= (WCHAR
*)(lpDest
->Value
.MVszW
.lppszW
+
160 lpDest
->Value
.MVszW
.cValues
);
162 for (i
= 0; i
< lpSrc
->Value
.MVszW
.cValues
; i
++)
164 ULONG ulStrLen
= strlenW(lpSrc
->Value
.MVszW
.lppszW
[i
]) + 1u;
166 lpDest
->Value
.MVszW
.lppszW
[i
] = lpNextStr
;
167 memcpy(lpNextStr
, lpSrc
->Value
.MVszW
.lppszW
[i
], ulStrLen
* sizeof(WCHAR
));
168 lpNextStr
+= ulStrLen
;
174 LPBYTE lpNext
= (LPBYTE
)(lpDest
->Value
.MVbin
.lpbin
+
175 lpDest
->Value
.MVbin
.cValues
);
177 for (i
= 0; i
< lpSrc
->Value
.MVszW
.cValues
; i
++)
179 lpDest
->Value
.MVbin
.lpbin
[i
].cb
= lpSrc
->Value
.MVbin
.lpbin
[i
].cb
;
180 lpDest
->Value
.MVbin
.lpbin
[i
].lpb
= lpNext
;
181 memcpy(lpNext
, lpSrc
->Value
.MVbin
.lpbin
[i
].lpb
, lpDest
->Value
.MVbin
.lpbin
[i
].cb
);
182 lpNext
+= lpDest
->Value
.MVbin
.lpbin
[i
].cb
;
187 /* No embedded pointers, just copy the data over */
188 memcpy(lpDest
->Value
.MVi
.lpi
, lpSrc
->Value
.MVi
.lpi
, ulLen
);
197 /*************************************************************************
198 * UlPropSize@4 (MAPI32.77)
200 * Determine the size of a property in bytes.
203 * lpProp [I] Property to determine the size of
206 * Success: The size of the value in lpProp.
207 * Failure: 0, if a multi-value (array) property is invalid or the type of lpProp
211 * - The size returned does not include the size of the SPropValue struct
212 * or the size of the array of pointers for multi-valued properties that
213 * contain pointers (such as PT_MV_STRING8 or PT-MV_UNICODE).
214 * - MSDN incorrectly states that this function returns MAPI_E_CALL_FAILED if
215 * lpProp is invalid. In reality no checking is performed and this function
216 * will crash if passed an invalid property, or return 0 if the property
217 * type is PT_OBJECT or is unknown.
219 ULONG WINAPI
UlPropSize(LPSPropValue lpProp
)
223 TRACE("(%p)\n", lpProp
);
225 switch (PROP_TYPE(lpProp
->ulPropTag
))
227 case PT_MV_I2
: ulRet
= lpProp
->Value
.MVi
.cValues
;
229 case PT_I2
: ulRet
*= sizeof(USHORT
);
231 case PT_MV_I4
: ulRet
= lpProp
->Value
.MVl
.cValues
;
233 case PT_I4
: ulRet
*= sizeof(LONG
);
235 case PT_MV_I8
: ulRet
= lpProp
->Value
.MVli
.cValues
;
236 case PT_I8
: ulRet
*= sizeof(LONG64
);
238 case PT_MV_R4
: ulRet
= lpProp
->Value
.MVflt
.cValues
;
239 case PT_R4
: ulRet
*= sizeof(float);
242 case PT_MV_R8
: ulRet
= lpProp
->Value
.MVdbl
.cValues
;
244 case PT_R8
: ulRet
*= sizeof(double);
246 case PT_MV_CURRENCY
: ulRet
= lpProp
->Value
.MVcur
.cValues
;
247 case PT_CURRENCY
: ulRet
*= sizeof(CY
);
249 case PT_MV_SYSTIME
: ulRet
= lpProp
->Value
.MVft
.cValues
;
250 case PT_SYSTIME
: ulRet
*= sizeof(FILETIME
);
252 case PT_MV_CLSID
: ulRet
= lpProp
->Value
.MVguid
.cValues
;
253 case PT_CLSID
: ulRet
*= sizeof(GUID
);
255 case PT_MV_STRING8
: ulRet
= 0u;
256 for (i
= 0; i
< lpProp
->Value
.MVszA
.cValues
; i
++)
257 ulRet
+= (lstrlenA(lpProp
->Value
.MVszA
.lppszA
[i
]) + 1u);
259 case PT_STRING8
: ulRet
= lstrlenA(lpProp
->Value
.lpszA
) + 1u;
261 case PT_MV_UNICODE
: ulRet
= 0u;
262 for (i
= 0; i
< lpProp
->Value
.MVszW
.cValues
; i
++)
263 ulRet
+= (strlenW(lpProp
->Value
.MVszW
.lppszW
[i
]) + 1u);
264 ulRet
*= sizeof(WCHAR
);
266 case PT_UNICODE
: ulRet
= (lstrlenW(lpProp
->Value
.lpszW
) + 1u) * sizeof(WCHAR
);
268 case PT_MV_BINARY
: ulRet
= 0u;
269 for (i
= 0; i
< lpProp
->Value
.MVbin
.cValues
; i
++)
270 ulRet
+= lpProp
->Value
.MVbin
.lpbin
[i
].cb
;
272 case PT_BINARY
: ulRet
= lpProp
->Value
.bin
.cb
;
282 /*************************************************************************
283 * FPropContainsProp@12 (MAPI32.78)
285 * Find a property with a given property tag in a property array.
288 * lpHaystack [I] Property to match to
289 * lpNeedle [I] Property to find in lpHaystack
290 * ulFuzzy [I] Flags controlling match type and strictness (FL_* flags from "mapidefs.h")
293 * TRUE, if lpNeedle matches lpHaystack according to the criteria of ulFuzzy.
296 * Only property types of PT_STRING8 and PT_BINARY are handled by this function.
298 BOOL WINAPI
FPropContainsProp(LPSPropValue lpHaystack
, LPSPropValue lpNeedle
, ULONG ulFuzzy
)
300 TRACE("(%p,%p,0x%08x)\n", lpHaystack
, lpNeedle
, ulFuzzy
);
302 if (FBadProp(lpHaystack
) || FBadProp(lpNeedle
) ||
303 PROP_TYPE(lpHaystack
->ulPropTag
) != PROP_TYPE(lpNeedle
->ulPropTag
))
306 /* FIXME: Do later versions support Unicode as well? */
308 if (PROP_TYPE(lpHaystack
->ulPropTag
) == PT_STRING8
)
310 DWORD dwFlags
= 0, dwNeedleLen
, dwHaystackLen
;
312 if (ulFuzzy
& FL_IGNORECASE
)
313 dwFlags
|= NORM_IGNORECASE
;
314 if (ulFuzzy
& FL_IGNORENONSPACE
)
315 dwFlags
|= NORM_IGNORENONSPACE
;
316 if (ulFuzzy
& FL_LOOSE
)
317 dwFlags
|= (NORM_IGNORECASE
|NORM_IGNORENONSPACE
|NORM_IGNORESYMBOLS
);
319 dwNeedleLen
= lstrlenA(lpNeedle
->Value
.lpszA
);
320 dwHaystackLen
= lstrlenA(lpHaystack
->Value
.lpszA
);
322 if ((ulFuzzy
& (FL_SUBSTRING
|FL_PREFIX
)) == FL_PREFIX
)
324 if (dwNeedleLen
<= dwHaystackLen
&&
325 CompareStringA(LOCALE_USER_DEFAULT
, dwFlags
,
326 lpHaystack
->Value
.lpszA
, dwNeedleLen
,
327 lpNeedle
->Value
.lpszA
, dwNeedleLen
) == CSTR_EQUAL
)
328 return TRUE
; /* needle is a prefix of haystack */
330 else if ((ulFuzzy
& (FL_SUBSTRING
|FL_PREFIX
)) == FL_SUBSTRING
)
332 LPSTR (WINAPI
*pStrChrFn
)(LPCSTR
,WORD
) = StrChrA
;
333 LPSTR lpStr
= lpHaystack
->Value
.lpszA
;
335 if (dwFlags
& NORM_IGNORECASE
)
336 pStrChrFn
= StrChrIA
;
338 while ((lpStr
= pStrChrFn(lpStr
, *lpNeedle
->Value
.lpszA
)) != NULL
)
340 dwHaystackLen
-= (lpStr
- lpHaystack
->Value
.lpszA
);
341 if (dwNeedleLen
<= dwHaystackLen
&&
342 CompareStringA(LOCALE_USER_DEFAULT
, dwFlags
,
344 lpNeedle
->Value
.lpszA
, dwNeedleLen
) == CSTR_EQUAL
)
345 return TRUE
; /* needle is a substring of haystack */
349 else if (CompareStringA(LOCALE_USER_DEFAULT
, dwFlags
,
350 lpHaystack
->Value
.lpszA
, dwHaystackLen
,
351 lpNeedle
->Value
.lpszA
, dwNeedleLen
) == CSTR_EQUAL
)
352 return TRUE
; /* full string match */
354 else if (PROP_TYPE(lpHaystack
->ulPropTag
) == PT_BINARY
)
356 if ((ulFuzzy
& (FL_SUBSTRING
|FL_PREFIX
)) == FL_PREFIX
)
358 if (lpNeedle
->Value
.bin
.cb
<= lpHaystack
->Value
.bin
.cb
&&
359 !memcmp(lpNeedle
->Value
.bin
.lpb
, lpHaystack
->Value
.bin
.lpb
,
360 lpNeedle
->Value
.bin
.cb
))
361 return TRUE
; /* needle is a prefix of haystack */
363 else if ((ulFuzzy
& (FL_SUBSTRING
|FL_PREFIX
)) == FL_SUBSTRING
)
365 ULONG ulLen
= lpHaystack
->Value
.bin
.cb
;
366 LPBYTE lpb
= lpHaystack
->Value
.bin
.lpb
;
368 while ((lpb
= memchr(lpb
, *lpNeedle
->Value
.bin
.lpb
, ulLen
)) != NULL
)
370 ulLen
= lpHaystack
->Value
.bin
.cb
- (lpb
- lpHaystack
->Value
.bin
.lpb
);
371 if (lpNeedle
->Value
.bin
.cb
<= ulLen
&&
372 !memcmp(lpNeedle
->Value
.bin
.lpb
, lpb
, lpNeedle
->Value
.bin
.cb
))
373 return TRUE
; /* needle is a substring of haystack */
377 else if (!LPropCompareProp(lpHaystack
, lpNeedle
))
378 return TRUE
; /* needle is an exact match with haystack */
384 /*************************************************************************
385 * FPropCompareProp@12 (MAPI32.79)
387 * Compare two properties.
390 * lpPropLeft [I] Left hand property to compare to lpPropRight
391 * ulOp [I] Comparison operator (RELOP_* enum from "mapidefs.h")
392 * lpPropRight [I] Right hand property to compare to lpPropLeft
395 * TRUE, if the comparison is true, FALSE otherwise.
397 BOOL WINAPI
FPropCompareProp(LPSPropValue lpPropLeft
, ULONG ulOp
, LPSPropValue lpPropRight
)
401 TRACE("(%p,%d,%p)\n", lpPropLeft
, ulOp
, lpPropRight
);
403 if (ulOp
> RELOP_RE
|| FBadProp(lpPropLeft
) || FBadProp(lpPropRight
))
406 if (ulOp
== RELOP_RE
)
408 FIXME("Comparison operator RELOP_RE not yet implemented!\n");
412 iCmp
= LPropCompareProp(lpPropLeft
, lpPropRight
);
416 case RELOP_LT
: return iCmp
< 0 ? TRUE
: FALSE
;
417 case RELOP_LE
: return iCmp
<= 0 ? TRUE
: FALSE
;
418 case RELOP_GT
: return iCmp
> 0 ? TRUE
: FALSE
;
419 case RELOP_GE
: return iCmp
>= 0 ? TRUE
: FALSE
;
420 case RELOP_EQ
: return iCmp
== 0 ? TRUE
: FALSE
;
421 case RELOP_NE
: return iCmp
!= 0 ? TRUE
: FALSE
;
426 /*************************************************************************
427 * LPropCompareProp@8 (MAPI32.80)
429 * Compare two properties.
432 * lpPropLeft [I] Left hand property to compare to lpPropRight
433 * lpPropRight [I] Right hand property to compare to lpPropLeft
436 * An integer less than, equal to or greater than 0, indicating that
437 * lpszStr is less than, the same, or greater than lpszComp.
439 LONG WINAPI
LPropCompareProp(LPSPropValue lpPropLeft
, LPSPropValue lpPropRight
)
443 TRACE("(%p->0x%08x,%p->0x%08x)\n", lpPropLeft
, lpPropLeft
->ulPropTag
,
444 lpPropRight
, lpPropRight
->ulPropTag
);
446 /* If the properties are not the same, sort by property type */
447 if (PROP_TYPE(lpPropLeft
->ulPropTag
) != PROP_TYPE(lpPropRight
->ulPropTag
))
448 return (LONG
)PROP_TYPE(lpPropLeft
->ulPropTag
) - (LONG
)PROP_TYPE(lpPropRight
->ulPropTag
);
450 switch (PROP_TYPE(lpPropLeft
->ulPropTag
))
454 return 0; /* NULLs are equal */
456 return lpPropLeft
->Value
.i
- lpPropRight
->Value
.i
;
458 return lpPropLeft
->Value
.l
- lpPropRight
->Value
.l
;
460 if (lpPropLeft
->Value
.li
.QuadPart
> lpPropRight
->Value
.li
.QuadPart
)
462 if (lpPropLeft
->Value
.li
.QuadPart
== lpPropRight
->Value
.li
.QuadPart
)
466 if (lpPropLeft
->Value
.flt
> lpPropRight
->Value
.flt
)
468 if (lpPropLeft
->Value
.flt
== lpPropRight
->Value
.flt
)
473 if (lpPropLeft
->Value
.dbl
> lpPropRight
->Value
.dbl
)
475 if (lpPropLeft
->Value
.dbl
== lpPropRight
->Value
.dbl
)
479 if (lpPropLeft
->Value
.cur
.int64
> lpPropRight
->Value
.cur
.int64
)
481 if (lpPropLeft
->Value
.cur
.int64
== lpPropRight
->Value
.cur
.int64
)
485 return CompareFileTime(&lpPropLeft
->Value
.ft
, &lpPropRight
->Value
.ft
);
487 return (lpPropLeft
->Value
.b
? 1 : 0) - (lpPropRight
->Value
.b
? 1 : 0);
489 if (lpPropLeft
->Value
.bin
.cb
== lpPropRight
->Value
.bin
.cb
)
490 iRet
= memcmp(lpPropLeft
->Value
.bin
.lpb
, lpPropRight
->Value
.bin
.lpb
,
491 lpPropLeft
->Value
.bin
.cb
);
494 iRet
= memcmp(lpPropLeft
->Value
.bin
.lpb
, lpPropRight
->Value
.bin
.lpb
,
495 min(lpPropLeft
->Value
.bin
.cb
, lpPropRight
->Value
.bin
.cb
));
498 iRet
= lpPropLeft
->Value
.bin
.cb
- lpPropRight
->Value
.bin
.cb
;
502 return lstrcmpA(lpPropLeft
->Value
.lpszA
, lpPropRight
->Value
.lpszA
);
504 return strcmpW(lpPropLeft
->Value
.lpszW
, lpPropRight
->Value
.lpszW
);
506 if (lpPropLeft
->Value
.err
> lpPropRight
->Value
.err
)
508 if (lpPropLeft
->Value
.err
== lpPropRight
->Value
.err
)
512 return memcmp(lpPropLeft
->Value
.lpguid
, lpPropRight
->Value
.lpguid
,
515 FIXME("Unhandled property type %d\n", PROP_TYPE(lpPropLeft
->ulPropTag
));
519 /*************************************************************************
520 * HrGetOneProp@8 (MAPI32.135)
522 * Get a property value from an IMAPIProp object.
525 * lpIProp [I] IMAPIProp object to get the property value in
526 * ulPropTag [I] Property tag of the property to get
527 * lppProp [O] Destination for the returned property
530 * Success: S_OK. *lppProp contains the property value requested.
531 * Failure: MAPI_E_NOT_FOUND, if no property value has the tag given by ulPropTag.
533 HRESULT WINAPI
HrGetOneProp(LPMAPIPROP lpIProp
, ULONG ulPropTag
, LPSPropValue
*lppProp
)
539 TRACE("(%p,%d,%p)\n", lpIProp
, ulPropTag
, lppProp
);
542 pta
.aulPropTag
[0] = ulPropTag
;
543 hRet
= IMAPIProp_GetProps(lpIProp
, &pta
, 0u, &ulCount
, lppProp
);
544 if (hRet
== MAPI_W_ERRORS_RETURNED
)
546 MAPIFreeBuffer(*lppProp
);
548 hRet
= MAPI_E_NOT_FOUND
;
553 /*************************************************************************
554 * HrSetOneProp@8 (MAPI32.136)
556 * Set a property value in an IMAPIProp object.
559 * lpIProp [I] IMAPIProp object to set the property value in
560 * lpProp [I] Property value to set
563 * Success: S_OK. The value in lpProp is set in lpIProp.
564 * Failure: An error result from IMAPIProp_SetProps().
566 HRESULT WINAPI
HrSetOneProp(LPMAPIPROP lpIProp
, LPSPropValue lpProp
)
568 TRACE("(%p,%p)\n", lpIProp
, lpProp
);
570 return IMAPIProp_SetProps(lpIProp
, 1u, lpProp
, NULL
);
573 /*************************************************************************
574 * FPropExists@8 (MAPI32.137)
576 * Find a property with a given property tag in an IMAPIProp object.
579 * lpIProp [I] IMAPIProp object to find the property tag in
580 * ulPropTag [I] Property tag to find
583 * TRUE, if ulPropTag matches a property held in lpIProp,
587 * if ulPropTag has a property type of PT_UNSPECIFIED, then only the property
588 * Ids need to match for a successful match to occur.
590 BOOL WINAPI
FPropExists(LPMAPIPROP lpIProp
, ULONG ulPropTag
)
594 TRACE("(%p,%d)\n", lpIProp
, ulPropTag
);
598 LPSPropTagArray lpTags
;
601 if (FAILED(IMAPIProp_GetPropList(lpIProp
, 0u, &lpTags
)))
604 for (i
= 0; i
< lpTags
->cValues
; i
++)
606 if (!FBadPropTag(lpTags
->aulPropTag
[i
]) &&
607 (lpTags
->aulPropTag
[i
] == ulPropTag
||
608 (PROP_TYPE(ulPropTag
) == PT_UNSPECIFIED
&&
609 PROP_ID(lpTags
->aulPropTag
[i
]) == lpTags
->aulPropTag
[i
])))
615 MAPIFreeBuffer(lpTags
);
620 /*************************************************************************
621 * PpropFindProp@12 (MAPI32.138)
623 * Find a property with a given property tag in a property array.
626 * lpProps [I] Property array to search
627 * cValues [I] Number of properties in lpProps
628 * ulPropTag [I] Property tag to find
631 * A pointer to the matching property, or NULL if none was found.
634 * if ulPropTag has a property type of PT_UNSPECIFIED, then only the property
635 * Ids need to match for a successful match to occur.
637 LPSPropValue WINAPI
PpropFindProp(LPSPropValue lpProps
, ULONG cValues
, ULONG ulPropTag
)
639 TRACE("(%p,%d,%d)\n", lpProps
, cValues
, ulPropTag
);
641 if (lpProps
&& cValues
)
644 for (i
= 0; i
< cValues
; i
++)
646 if (!FBadPropTag(lpProps
[i
].ulPropTag
) &&
647 (lpProps
[i
].ulPropTag
== ulPropTag
||
648 (PROP_TYPE(ulPropTag
) == PT_UNSPECIFIED
&&
649 PROP_ID(lpProps
[i
].ulPropTag
) == PROP_ID(ulPropTag
))))
656 /*************************************************************************
657 * FreePadrlist@4 (MAPI32.139)
659 * Free the memory used by an address book list.
662 * lpAddrs [I] Address book list to free
667 VOID WINAPI
FreePadrlist(LPADRLIST lpAddrs
)
669 TRACE("(%p)\n", lpAddrs
);
671 /* Structures are binary compatible; use the same implementation */
672 FreeProws((LPSRowSet
)lpAddrs
);
675 /*************************************************************************
676 * FreeProws@4 (MAPI32.140)
678 * Free the memory used by a row set.
681 * lpRowSet [I] Row set to free
686 VOID WINAPI
FreeProws(LPSRowSet lpRowSet
)
688 TRACE("(%p)\n", lpRowSet
);
694 for (i
= 0; i
< lpRowSet
->cRows
; i
++)
695 MAPIFreeBuffer(lpRowSet
->aRow
[i
].lpProps
);
697 MAPIFreeBuffer(lpRowSet
);
701 /*************************************************************************
702 * ScCountProps@12 (MAPI32.170)
704 * Validate and determine the length of an array of properties.
707 * iCount [I] Length of the lpProps array
708 * lpProps [I] Array of properties to validate/size
709 * pcBytes [O] If non-NULL, destination for the size of the property array
712 * Success: S_OK. If pcBytes is non-NULL, it contains the size of the propery array.
713 * Failure: MAPI_E_INVALID_PARAMETER, if any parameter is invalid or validation
714 * of the property array fails.
716 SCODE WINAPI
ScCountProps(INT iCount
, LPSPropValue lpProps
, ULONG
*pcBytes
)
718 ULONG i
, ulCount
= iCount
, ulBytes
= 0;
720 TRACE("(%d,%p,%p)\n", iCount
, lpProps
, pcBytes
);
722 if (iCount
<= 0 || !lpProps
||
723 IsBadReadPtr(lpProps
, iCount
* sizeof(SPropValue
)))
724 return MAPI_E_INVALID_PARAMETER
;
726 for (i
= 0; i
< ulCount
; i
++)
728 ULONG ulPropSize
= 0;
730 if (FBadProp(&lpProps
[i
]) || lpProps
[i
].ulPropTag
== PROP_ID_NULL
||
731 lpProps
[i
].ulPropTag
== PROP_ID_INVALID
)
732 return MAPI_E_INVALID_PARAMETER
;
734 if (PROP_TYPE(lpProps
[i
].ulPropTag
) != PT_OBJECT
)
736 ulPropSize
= UlPropSize(&lpProps
[i
]);
738 return MAPI_E_INVALID_PARAMETER
;
741 switch (PROP_TYPE(lpProps
[i
].ulPropTag
))
755 ulPropSize
+= sizeof(SPropValue
);
758 ulPropSize
+= lpProps
[i
].Value
.MVszA
.cValues
* sizeof(char*) + sizeof(SPropValue
);
762 ulPropSize
+= lpProps
[i
].Value
.MVszA
.cValues
* sizeof(char*) + sizeof(SPropValue
);
765 ulPropSize
+= lpProps
[i
].Value
.MVbin
.cValues
* sizeof(SBinary
) + sizeof(SPropValue
);
768 ulPropSize
= sizeof(SPropValue
);
771 ulBytes
+= ulPropSize
;
779 /*************************************************************************
780 * ScCopyProps@16 (MAPI32.171)
782 * Copy an array of property values into a buffer suited for serialisation.
785 * cValues [I] Number of properties in lpProps
786 * lpProps [I] Property array to copy
787 * lpDst [O] Destination for the serialised data
788 * lpCount [O] If non-NULL, destination for the number of bytes of data written to lpDst
791 * Success: S_OK. lpDst contains the serialised data from lpProps.
792 * Failure: MAPI_E_INVALID_PARAMETER, if any parameter is invalid.
795 * The resulting property value array is stored in a contiguous block starting at lpDst.
797 SCODE WINAPI
ScCopyProps(int cValues
, LPSPropValue lpProps
, LPVOID lpDst
, ULONG
*lpCount
)
799 LPSPropValue lpDest
= (LPSPropValue
)lpDst
;
800 char *lpDataDest
= (char *)(lpDest
+ cValues
);
804 TRACE("(%d,%p,%p,%p)\n", cValues
, lpProps
, lpDst
, lpCount
);
806 if (!lpProps
|| cValues
< 0 || !lpDest
)
807 return MAPI_E_INVALID_PARAMETER
;
809 memcpy(lpDst
, lpProps
, cValues
* sizeof(SPropValue
));
811 for (iter
= 0; iter
< cValues
; iter
++)
813 switch (PROP_TYPE(lpProps
->ulPropTag
))
816 lpDest
->Value
.lpguid
= (LPGUID
)lpDataDest
;
817 *lpDest
->Value
.lpguid
= *lpProps
->Value
.lpguid
;
818 lpDataDest
+= sizeof(GUID
);
821 ulLen
= lstrlenA(lpProps
->Value
.lpszA
) + 1u;
822 lpDest
->Value
.lpszA
= lpDataDest
;
823 memcpy(lpDest
->Value
.lpszA
, lpProps
->Value
.lpszA
, ulLen
);
827 ulLen
= (strlenW(lpProps
->Value
.lpszW
) + 1u) * sizeof(WCHAR
);
828 lpDest
->Value
.lpszW
= (LPWSTR
)lpDataDest
;
829 memcpy(lpDest
->Value
.lpszW
, lpProps
->Value
.lpszW
, ulLen
);
833 lpDest
->Value
.bin
.lpb
= (LPBYTE
)lpDataDest
;
834 memcpy(lpDest
->Value
.bin
.lpb
, lpProps
->Value
.bin
.lpb
, lpProps
->Value
.bin
.cb
);
835 lpDataDest
+= lpProps
->Value
.bin
.cb
;
838 if (lpProps
->ulPropTag
& MV_FLAG
)
840 lpDest
->Value
.MVi
.cValues
= lpProps
->Value
.MVi
.cValues
;
841 /* Note: Assignment uses lppszA but covers all cases by union aliasing */
842 lpDest
->Value
.MVszA
.lppszA
= (char**)lpDataDest
;
844 switch (PROP_TYPE(lpProps
->ulPropTag
))
848 lpDataDest
+= lpProps
->Value
.MVszA
.cValues
* sizeof(char *);
850 for (i
= 0; i
< lpProps
->Value
.MVszA
.cValues
; i
++)
852 ULONG ulStrLen
= lstrlenA(lpProps
->Value
.MVszA
.lppszA
[i
]) + 1u;
854 lpDest
->Value
.MVszA
.lppszA
[i
] = lpDataDest
;
855 memcpy(lpDataDest
, lpProps
->Value
.MVszA
.lppszA
[i
], ulStrLen
);
856 lpDataDest
+= ulStrLen
;
862 lpDataDest
+= lpProps
->Value
.MVszW
.cValues
* sizeof(WCHAR
*);
864 for (i
= 0; i
< lpProps
->Value
.MVszW
.cValues
; i
++)
866 ULONG ulStrLen
= (strlenW(lpProps
->Value
.MVszW
.lppszW
[i
]) + 1u) * sizeof(WCHAR
);
868 lpDest
->Value
.MVszW
.lppszW
[i
] = (LPWSTR
)lpDataDest
;
869 memcpy(lpDataDest
, lpProps
->Value
.MVszW
.lppszW
[i
], ulStrLen
);
870 lpDataDest
+= ulStrLen
;
876 lpDataDest
+= lpProps
->Value
.MVszW
.cValues
* sizeof(SBinary
);
878 for (i
= 0; i
< lpProps
->Value
.MVszW
.cValues
; i
++)
880 lpDest
->Value
.MVbin
.lpbin
[i
].cb
= lpProps
->Value
.MVbin
.lpbin
[i
].cb
;
881 lpDest
->Value
.MVbin
.lpbin
[i
].lpb
= (LPBYTE
)lpDataDest
;
882 memcpy(lpDataDest
, lpProps
->Value
.MVbin
.lpbin
[i
].lpb
, lpDest
->Value
.MVbin
.lpbin
[i
].cb
);
883 lpDataDest
+= lpDest
->Value
.MVbin
.lpbin
[i
].cb
;
888 /* No embedded pointers, just copy the data over */
889 ulLen
= UlPropSize(lpProps
);
890 memcpy(lpDest
->Value
.MVi
.lpi
, lpProps
->Value
.MVi
.lpi
, ulLen
);
901 *lpCount
= lpDataDest
- (char *)lpDst
;
906 /*************************************************************************
907 * ScRelocProps@20 (MAPI32.172)
909 * Relocate the pointers in an array of property values after it has been copied.
912 * cValues [I] Number of properties in lpProps
913 * lpProps [O] Property array to relocate the pointers in.
914 * lpOld [I] Position where the data was copied from
915 * lpNew [I] Position where the data was copied to
916 * lpCount [O] If non-NULL, destination for the number of bytes of data at lpDst
919 * Success: S_OK. Any pointers in lpProps are relocated.
920 * Failure: MAPI_E_INVALID_PARAMETER, if any parameter is invalid.
923 * MSDN states that this function can be used for serialisation by passing
924 * NULL as either lpOld or lpNew, thus converting any pointers in lpProps
925 * between offsets and pointers. This does not work in native (it crashes),
926 * and cannot be made to work in Wine because the original interface design
927 * is deficient. The only use left for this function is to remap pointers
928 * in a contiguous property array that has been copied with memcpy() to
929 * another memory location.
931 SCODE WINAPI
ScRelocProps(int cValues
, LPSPropValue lpProps
, LPVOID lpOld
,
932 LPVOID lpNew
, ULONG
*lpCount
)
934 static const BOOL bBadPtr
= TRUE
; /* Windows bug - Assumes source is bad */
935 LPSPropValue lpDest
= lpProps
;
936 ULONG ulCount
= cValues
* sizeof(SPropValue
);
940 TRACE("(%d,%p,%p,%p,%p)\n", cValues
, lpProps
, lpOld
, lpNew
, lpCount
);
942 if (!lpProps
|| cValues
< 0 || !lpOld
|| !lpNew
)
943 return MAPI_E_INVALID_PARAMETER
;
945 /* The reason native doesn't work as MSDN states is that it assumes that
946 * the lpProps pointer contains valid pointers. This is obviously not
947 * true if the array is being read back from serialisation (the pointers
948 * are just offsets). Native can't actually work converting the pointers to
949 * offsets either, because it converts any array pointers to offsets then
950 * _dereferences the offset_ in order to convert the array elements!
952 * The code below would handle both cases except that the design of this
953 * function makes it impossible to know when the pointers in lpProps are
954 * valid. If both lpOld and lpNew are non-NULL, native reads the pointers
955 * after converting them, so we must do the same. It seems this
956 * functionality was never tested by MS.
959 #define RELOC_PTR(p) (((char*)(p)) - (char*)lpOld + (char*)lpNew)
961 for (iter
= 0; iter
< cValues
; iter
++)
963 switch (PROP_TYPE(lpDest
->ulPropTag
))
966 lpDest
->Value
.lpguid
= (LPGUID
)RELOC_PTR(lpDest
->Value
.lpguid
);
967 ulCount
+= sizeof(GUID
);
970 ulLen
= bBadPtr
? 0 : lstrlenA(lpDest
->Value
.lpszA
) + 1u;
971 lpDest
->Value
.lpszA
= RELOC_PTR(lpDest
->Value
.lpszA
);
973 ulLen
= lstrlenA(lpDest
->Value
.lpszA
) + 1u;
977 ulLen
= bBadPtr
? 0 : (lstrlenW(lpDest
->Value
.lpszW
) + 1u) * sizeof(WCHAR
);
978 lpDest
->Value
.lpszW
= (LPWSTR
)RELOC_PTR(lpDest
->Value
.lpszW
);
980 ulLen
= (strlenW(lpDest
->Value
.lpszW
) + 1u) * sizeof(WCHAR
);
984 lpDest
->Value
.bin
.lpb
= (LPBYTE
)RELOC_PTR(lpDest
->Value
.bin
.lpb
);
985 ulCount
+= lpDest
->Value
.bin
.cb
;
988 if (lpDest
->ulPropTag
& MV_FLAG
)
990 /* Since we have to access the array elements, don't map the
991 * array unless it is invalid (otherwise, map it at the end)
994 lpDest
->Value
.MVszA
.lppszA
= (LPSTR
*)RELOC_PTR(lpDest
->Value
.MVszA
.lppszA
);
996 switch (PROP_TYPE(lpProps
->ulPropTag
))
1000 ulCount
+= lpDest
->Value
.MVszA
.cValues
* sizeof(char *);
1002 for (i
= 0; i
< lpDest
->Value
.MVszA
.cValues
; i
++)
1004 ULONG ulStrLen
= bBadPtr
? 0 : lstrlenA(lpDest
->Value
.MVszA
.lppszA
[i
]) + 1u;
1006 lpDest
->Value
.MVszA
.lppszA
[i
] = RELOC_PTR(lpDest
->Value
.MVszA
.lppszA
[i
]);
1008 ulStrLen
= lstrlenA(lpDest
->Value
.MVszA
.lppszA
[i
]) + 1u;
1009 ulCount
+= ulStrLen
;
1015 ulCount
+= lpDest
->Value
.MVszW
.cValues
* sizeof(WCHAR
*);
1017 for (i
= 0; i
< lpDest
->Value
.MVszW
.cValues
; i
++)
1019 ULONG ulStrLen
= bBadPtr
? 0 : (strlenW(lpDest
->Value
.MVszW
.lppszW
[i
]) + 1u) * sizeof(WCHAR
);
1021 lpDest
->Value
.MVszW
.lppszW
[i
] = (LPWSTR
)RELOC_PTR(lpDest
->Value
.MVszW
.lppszW
[i
]);
1023 ulStrLen
= (strlenW(lpDest
->Value
.MVszW
.lppszW
[i
]) + 1u) * sizeof(WCHAR
);
1024 ulCount
+= ulStrLen
;
1030 ulCount
+= lpDest
->Value
.MVszW
.cValues
* sizeof(SBinary
);
1032 for (i
= 0; i
< lpDest
->Value
.MVszW
.cValues
; i
++)
1034 lpDest
->Value
.MVbin
.lpbin
[i
].lpb
= (LPBYTE
)RELOC_PTR(lpDest
->Value
.MVbin
.lpbin
[i
].lpb
);
1035 ulCount
+= lpDest
->Value
.MVbin
.lpbin
[i
].cb
;
1040 ulCount
+= UlPropSize(lpDest
);
1044 lpDest
->Value
.MVszA
.lppszA
= (LPSTR
*)RELOC_PTR(lpDest
->Value
.MVszA
.lppszA
);
1056 /*************************************************************************
1057 * LpValFindProp@12 (MAPI32.173)
1059 * Find a property with a given property id in a property array.
1062 * ulPropTag [I] Property tag containing property id to find
1063 * cValues [I] Number of properties in lpProps
1064 * lpProps [I] Property array to search
1067 * A pointer to the matching property, or NULL if none was found.
1070 * This function matches only on the property id and does not care if the
1071 * property types differ.
1073 LPSPropValue WINAPI
LpValFindProp(ULONG ulPropTag
, ULONG cValues
, LPSPropValue lpProps
)
1075 TRACE("(%d,%d,%p)\n", ulPropTag
, cValues
, lpProps
);
1077 if (lpProps
&& cValues
)
1080 for (i
= 0; i
< cValues
; i
++)
1082 if (PROP_ID(ulPropTag
) == PROP_ID(lpProps
[i
].ulPropTag
))
1089 /*************************************************************************
1090 * ScDupPropset@16 (MAPI32.174)
1092 * Duplicate a property value array into a contiguous block of memory.
1095 * cValues [I] Number of properties in lpProps
1096 * lpProps [I] Property array to duplicate
1097 * lpAlloc [I] Memory allocation function, use MAPIAllocateBuffer()
1098 * lpNewProp [O] Destination for the newly duplicated property value array
1101 * Success: S_OK. *lpNewProp contains the duplicated array.
1102 * Failure: MAPI_E_INVALID_PARAMETER, if any parameter is invalid,
1103 * MAPI_E_NOT_ENOUGH_MEMORY, if memory allocation fails.
1105 SCODE WINAPI
ScDupPropset(int cValues
, LPSPropValue lpProps
,
1106 LPALLOCATEBUFFER lpAlloc
, LPSPropValue
*lpNewProp
)
1111 TRACE("(%d,%p,%p,%p)\n", cValues
, lpProps
, lpAlloc
, lpNewProp
);
1113 sc
= ScCountProps(cValues
, lpProps
, &ulCount
);
1116 sc
= lpAlloc(ulCount
, (LPVOID
*)lpNewProp
);
1118 sc
= ScCopyProps(cValues
, lpProps
, *lpNewProp
, &ulCount
);
1123 /*************************************************************************
1124 * FBadRglpszA@8 (MAPI32.175)
1126 * Determine if an array of strings is invalid
1129 * lppszStrs [I] Array of strings to check
1130 * ulCount [I] Number of strings in lppszStrs
1133 * TRUE, if lppszStrs is invalid, FALSE otherwise.
1135 BOOL WINAPI
FBadRglpszA(LPSTR
*lppszStrs
, ULONG ulCount
)
1139 TRACE("(%p,%d)\n", lppszStrs
, ulCount
);
1144 if (!lppszStrs
|| IsBadReadPtr(lppszStrs
, ulCount
* sizeof(LPWSTR
)))
1147 for (i
= 0; i
< ulCount
; i
++)
1149 if (!lppszStrs
[i
] || IsBadStringPtrA(lppszStrs
[i
], -1))
1155 /*************************************************************************
1156 * FBadRglpszW@8 (MAPI32.176)
1160 BOOL WINAPI
FBadRglpszW(LPWSTR
*lppszStrs
, ULONG ulCount
)
1164 TRACE("(%p,%d)\n", lppszStrs
, ulCount
);
1169 if (!lppszStrs
|| IsBadReadPtr(lppszStrs
, ulCount
* sizeof(LPWSTR
)))
1172 for (i
= 0; i
< ulCount
; i
++)
1174 if (!lppszStrs
[i
] || IsBadStringPtrW(lppszStrs
[i
], -1))
1180 /*************************************************************************
1181 * FBadRowSet@4 (MAPI32.177)
1183 * Determine if a row is invalid
1186 * lpRow [I] Row to check
1189 * TRUE, if lpRow is invalid, FALSE otherwise.
1191 BOOL WINAPI
FBadRowSet(LPSRowSet lpRowSet
)
1194 TRACE("(%p)\n", lpRowSet
);
1196 if (!lpRowSet
|| IsBadReadPtr(lpRowSet
, CbSRowSet(lpRowSet
)))
1199 for (i
= 0; i
< lpRowSet
->cRows
; i
++)
1201 if (FBadRow(&lpRowSet
->aRow
[i
]))
1207 /*************************************************************************
1208 * FBadPropTag@4 (MAPI32.179)
1210 * Determine if a property tag is invalid
1213 * ulPropTag [I] Property tag to check
1216 * TRUE, if ulPropTag is invalid, FALSE otherwise.
1218 ULONG WINAPI
FBadPropTag(ULONG ulPropTag
)
1220 TRACE("(0x%08x)\n", ulPropTag
);
1222 switch (ulPropTag
& (~MV_FLAG
& PROP_TYPE_MASK
))
1224 case PT_UNSPECIFIED
:
1246 /*************************************************************************
1247 * FBadRow@4 (MAPI32.180)
1249 * Determine if a row is invalid
1252 * lpRow [I] Row to check
1255 * TRUE, if lpRow is invalid, FALSE otherwise.
1257 ULONG WINAPI
FBadRow(LPSRow lpRow
)
1260 TRACE("(%p)\n", lpRow
);
1262 if (!lpRow
|| IsBadReadPtr(lpRow
, sizeof(SRow
)) || !lpRow
->lpProps
||
1263 IsBadReadPtr(lpRow
->lpProps
, lpRow
->cValues
* sizeof(SPropValue
)))
1266 for (i
= 0; i
< lpRow
->cValues
; i
++)
1268 if (FBadProp(&lpRow
->lpProps
[i
]))
1274 /*************************************************************************
1275 * FBadProp@4 (MAPI32.181)
1277 * Determine if a property is invalid
1280 * lpProp [I] Property to check
1283 * TRUE, if lpProp is invalid, FALSE otherwise.
1285 ULONG WINAPI
FBadProp(LPSPropValue lpProp
)
1287 if (!lpProp
|| IsBadReadPtr(lpProp
, sizeof(SPropValue
)) ||
1288 FBadPropTag(lpProp
->ulPropTag
))
1291 switch (PROP_TYPE(lpProp
->ulPropTag
))
1293 /* Single value properties containing pointers */
1295 if (!lpProp
->Value
.lpszA
|| IsBadStringPtrA(lpProp
->Value
.lpszA
, -1))
1299 if (!lpProp
->Value
.lpszW
|| IsBadStringPtrW(lpProp
->Value
.lpszW
, -1))
1303 if (IsBadReadPtr(lpProp
->Value
.bin
.lpb
, lpProp
->Value
.bin
.cb
))
1307 if (IsBadReadPtr(lpProp
->Value
.lpguid
, sizeof(GUID
)))
1311 /* Multiple value properties (arrays) containing no pointers */
1313 return PROP_BadArray(lpProp
, sizeof(SHORT
));
1315 return PROP_BadArray(lpProp
, sizeof(LONG
));
1316 case PT_MV_LONGLONG
:
1317 return PROP_BadArray(lpProp
, sizeof(LONG64
));
1319 return PROP_BadArray(lpProp
, sizeof(float));
1321 return PROP_BadArray(lpProp
, sizeof(FILETIME
));
1324 return PROP_BadArray(lpProp
, sizeof(double));
1325 case PT_MV_CURRENCY
:
1326 return PROP_BadArray(lpProp
, sizeof(CY
));
1328 return PROP_BadArray(lpProp
, sizeof(GUID
));
1330 /* Multiple value properties containing pointers */
1332 return FBadRglpszA(lpProp
->Value
.MVszA
.lppszA
,
1333 lpProp
->Value
.MVszA
.cValues
);
1335 return FBadRglpszW(lpProp
->Value
.MVszW
.lppszW
,
1336 lpProp
->Value
.MVszW
.cValues
);
1338 return FBadEntryList(&lpProp
->Value
.MVbin
);
1343 /*************************************************************************
1344 * FBadColumnSet@4 (MAPI32.182)
1346 * Determine if an array of property tags is invalid
1349 * lpCols [I] Property tag array to check
1352 * TRUE, if lpCols is invalid, FALSE otherwise.
1354 ULONG WINAPI
FBadColumnSet(LPSPropTagArray lpCols
)
1356 ULONG ulRet
= FALSE
, i
;
1358 TRACE("(%p)\n", lpCols
);
1360 if (!lpCols
|| IsBadReadPtr(lpCols
, CbSPropTagArray(lpCols
)))
1364 for (i
= 0; i
< lpCols
->cValues
; i
++)
1366 if ((lpCols
->aulPropTag
[i
] & PROP_TYPE_MASK
) == PT_ERROR
||
1367 FBadPropTag(lpCols
->aulPropTag
[i
]))
1374 TRACE("Returning %s\n", ulRet
? "TRUE" : "FALSE");
1379 /**************************************************************************
1380 * IMAPIProp {MAPI32}
1382 * The default Mapi interface for manipulating object properties.
1385 * This object provides an interface to an objects properties. It is exposed
1386 * by several types of Mapi objects in order to simplify the querying and
1387 * modification of properties.
1392 /* A single property in a property data collection */
1396 ULONG ulAccess
; /* The property value access level */
1397 LPSPropValue value
; /* The property value */
1398 } IPropDataItem
, *LPIPropDataItem
;
1400 /* The main property data collection structure */
1403 const IPropDataVtbl
*lpVtbl
;
1404 LONG lRef
; /* Reference count */
1405 ALLOCATEBUFFER
*lpAlloc
; /* Memory allocation routine */
1406 ALLOCATEMORE
*lpMore
; /* Linked memory allocation routine */
1407 FREEBUFFER
*lpFree
; /* Memory free routine */
1408 ULONG ulObjAccess
; /* Object access level */
1409 ULONG ulNumValues
; /* Number of items in values list */
1410 struct list values
; /* List of property values */
1411 CRITICAL_SECTION cs
; /* Lock for thread safety */
1414 /* Internal - Get a property value, assumes lock is held */
1415 static IPropDataItem
*IMAPIPROP_GetValue(IPropDataImpl
*This
, ULONG ulPropTag
)
1417 struct list
*cursor
;
1419 LIST_FOR_EACH(cursor
, &This
->values
)
1421 LPIPropDataItem current
= LIST_ENTRY(cursor
, IPropDataItem
, entry
);
1422 /* Note that propery types don't have to match, just Id's */
1423 if (PROP_ID(current
->value
->ulPropTag
) == PROP_ID(ulPropTag
))
1429 /* Internal - Add a new property value, assumes lock is held */
1430 static IPropDataItem
*IMAPIPROP_AddValue(IPropDataImpl
*This
,
1431 LPSPropValue lpProp
)
1434 LPIPropDataItem lpNew
;
1437 hRet
= This
->lpAlloc(sizeof(IPropDataItem
), &lpMem
);
1439 if (SUCCEEDED(hRet
))
1442 lpNew
->ulAccess
= IPROP_READWRITE
;
1444 /* Allocate the value separately so we can update it easily */
1446 hRet
= This
->lpAlloc(sizeof(SPropValue
), &lpMem
);
1447 if (SUCCEEDED(hRet
))
1449 lpNew
->value
= lpMem
;
1451 hRet
= PropCopyMore(lpNew
->value
, lpProp
, This
->lpMore
, lpMem
);
1452 if (SUCCEEDED(hRet
))
1454 list_add_tail(&This
->values
, &lpNew
->entry
);
1455 This
->ulNumValues
++;
1458 This
->lpFree(lpNew
->value
);
1460 This
->lpFree(lpNew
);
1465 /* Internal - Lock an IPropData object */
1466 static inline void IMAPIPROP_Lock(IPropDataImpl
*This
)
1468 EnterCriticalSection(&This
->cs
);
1471 /* Internal - Unlock an IPropData object */
1472 static inline void IMAPIPROP_Unlock(IPropDataImpl
*This
)
1474 LeaveCriticalSection(&This
->cs
);
1477 /* This one seems to be missing from mapidefs.h */
1478 #define CbNewSPropProblemArray(c) \
1479 (offsetof(SPropProblemArray,aProblem)+(c)*sizeof(SPropProblem))
1481 /**************************************************************************
1482 * IMAPIProp_QueryInterface {MAPI32}
1484 * Inherited method from the IUnknown Interface.
1485 * See IUnknown_QueryInterface.
1488 * This object exposes the following interfaces:
1489 * - IUnknown() : The default interface for all COM-Objects.
1490 * - IMAPIProp() : The default Mapi interface for manipulating object properties.
1492 static inline HRESULT
IMAPIProp_fnQueryInterface(LPMAPIPROP iface
, REFIID riid
, LPVOID
*ppvObj
)
1494 IPropDataImpl
*This
= (IPropDataImpl
*)iface
;
1496 TRACE("(%p,%s,%p)\n", This
, debugstr_guid(riid
), ppvObj
);
1498 if (!ppvObj
|| !riid
)
1499 return MAPI_E_INVALID_PARAMETER
;
1503 if(IsEqualIID(riid
, &IID_IUnknown
) ||
1504 IsEqualIID(riid
, &IID_IMAPIProp
) ||
1505 IsEqualIID(riid
, &IID_IMAPIPropData
))
1508 IPropData_AddRef(iface
);
1509 TRACE("returning %p\n", *ppvObj
);
1513 TRACE("returning E_NOINTERFACE\n");
1514 return MAPI_E_INTERFACE_NOT_SUPPORTED
;
1517 /**************************************************************************
1518 * IMAPIProp_AddRef {MAPI32}
1520 * Inherited method from the IUnknown Interface.
1521 * See IUnknown_AddRef.
1523 static inline ULONG
IMAPIProp_fnAddRef(LPMAPIPROP iface
)
1525 IPropDataImpl
*This
= (IPropDataImpl
*)iface
;
1527 TRACE("(%p)->(count before=%u)\n", This
, This
->lRef
);
1529 return InterlockedIncrement(&This
->lRef
);
1532 /**************************************************************************
1533 * IMAPIProp_Release {MAPI32}
1535 * Inherited method from the IUnknown Interface.
1536 * See IUnknown_Release.
1538 static inline ULONG
IMAPIProp_fnRelease(LPMAPIPROP iface
)
1540 IPropDataImpl
*This
= (IPropDataImpl
*)iface
;
1543 TRACE("(%p)->(count before=%u)\n", This
, This
->lRef
);
1545 lRef
= InterlockedDecrement(&This
->lRef
);
1548 TRACE("Destroying IPropData (%p)\n",This
);
1550 /* Note: No need to lock, since no other thread is referencing iface */
1551 while (!list_empty(&This
->values
))
1553 struct list
*head
= list_head(&This
->values
);
1554 LPIPropDataItem current
= LIST_ENTRY(head
, IPropDataItem
, entry
);
1556 This
->lpFree(current
->value
);
1557 This
->lpFree(current
);
1559 This
->cs
.DebugInfo
->Spare
[0] = 0;
1560 DeleteCriticalSection(&This
->cs
);
1566 /**************************************************************************
1567 * IMAPIProp_GetLastError {MAPI32}
1569 * Get information about the last error that occurred in an IMAPIProp object.
1572 * iface [I] IMAPIProp object that experienced the error
1573 * hRes [I] Result of the call that returned an error
1574 * ulFlags [I] 0=return Ascii strings, MAPI_UNICODE=return Unicode strings
1575 * lppError [O] Destination for detailed error information
1578 * Success: S_OK. *lppError contains details about the last error.
1579 * Failure: MAPI_E_INVALID_PARAMETER, if any parameter is invalid,
1580 * MAPI_E_NOT_ENOUGH_MEMORY, if memory allocation fails.
1583 * - If this function succeeds, the returned information in *lppError must be
1584 * freed using MAPIFreeBuffer() once the caller is finished with it.
1585 * - It is possible for this function to succeed and set *lppError to NULL,
1586 * if there is no further information to report about hRes.
1588 static inline HRESULT
1589 IMAPIProp_fnGetLastError(LPMAPIPROP iface
, HRESULT hRes
,
1590 ULONG ulFlags
, LPMAPIERROR
*lppError
)
1592 TRACE("(%p,0x%08X,0x%08X,%p)\n", iface
, hRes
, ulFlags
, lppError
);
1594 if (!lppError
|| SUCCEEDED(hRes
) || (ulFlags
& ~MAPI_UNICODE
))
1595 return MAPI_E_INVALID_PARAMETER
;
1601 /**************************************************************************
1602 * IMAPIProp_SaveChanges {MAPI32}
1604 * Update any changes made to a transactional IMAPIProp object.
1607 * iface [I] IMAPIProp object to update
1608 * ulFlags [I] Flags controlling the update.
1611 * Success: S_OK. Any outstanding changes are committed to the object.
1612 * Failure: An HRESULT error code describing the error.
1614 static inline HRESULT
1615 IMAPIProp_fnSaveChanges(LPMAPIPROP iface
, ULONG ulFlags
)
1617 TRACE("(%p,0x%08X)\n", iface
, ulFlags
);
1619 /* Since this object is not transacted we do not need to implement this */
1620 /* FIXME: Should we set the access levels to clean? */
1624 /**************************************************************************
1625 * IMAPIProp_GetProps {MAPI32}
1627 * Get property values from an IMAPIProp object.
1630 * iface [I] IMAPIProp object to get the property values from
1631 * lpTags [I] Property tage of property values to be retrieved
1632 * ulFlags [I] Return 0=Ascii MAPI_UNICODE=Unicode strings for
1634 * lpCount [O] Destination for number of properties returned
1635 * lppProps [O] Destination for returned property values
1638 * Success: S_OK. *lppProps and *lpCount are updated.
1639 * Failure: MAPI_E_INVALID_PARAMETER, if any parameter is invalid.
1640 * MAPI_E_NOT_ENOUGH_MEMORY, if memory allocation fails, or
1641 * MAPI_W_ERRORS_RETURNED if not all properties were retrieved
1644 * - If MAPI_W_ERRORS_RETURNED is returned, any properties that could not be
1645 * retrieved from iface are present in lppProps with their type
1646 * changed to PT_ERROR and Id unchanged.
1648 static inline HRESULT
1649 IMAPIProp_fnGetProps(LPMAPIPROP iface
, LPSPropTagArray lpTags
,
1650 ULONG ulFlags
, ULONG
*lpCount
, LPSPropValue
*lppProps
)
1653 HRESULT hRet
= S_OK
;
1654 IPropDataImpl
*This
= (IPropDataImpl
*)iface
;
1656 TRACE("(%p,%p,0x%08x,%p,%p) stub\n", iface
, lpTags
, ulFlags
,
1659 if (!iface
|| ulFlags
& ~MAPI_UNICODE
|| !lpTags
|| *lpCount
|| !lppProps
)
1660 return MAPI_E_INVALID_PARAMETER
;
1662 FIXME("semi-stub, flags not supported\n");
1664 *lpCount
= lpTags
->cValues
;
1669 hRet
= MAPIAllocateBuffer(*lpCount
* sizeof(SPropValue
), (LPVOID
*)lppProps
);
1673 IMAPIPROP_Lock(This
);
1675 for (i
= 0; i
< lpTags
->cValues
; i
++)
1677 HRESULT hRetTmp
= E_INVALIDARG
;
1678 LPIPropDataItem item
;
1680 item
= IMAPIPROP_GetValue(This
, lpTags
->aulPropTag
[i
]);
1683 hRetTmp
= PropCopyMore(&(*lppProps
)[i
], item
->value
,
1684 This
->lpMore
, *lppProps
);
1685 if (FAILED(hRetTmp
))
1687 hRet
= MAPI_W_ERRORS_RETURNED
;
1688 (*lppProps
)[i
].ulPropTag
=
1689 CHANGE_PROP_TYPE(lpTags
->aulPropTag
[i
], PT_ERROR
);
1693 IMAPIPROP_Unlock(This
);
1698 /**************************************************************************
1699 * MAPIProp_GetPropList {MAPI32}
1701 * Get the list of property tags for all values in an IMAPIProp object.
1704 * iface [I] IMAPIProp object to get the property tag list from
1705 * ulFlags [I] Return 0=Ascii MAPI_UNICODE=Unicode strings for
1707 * lppTags [O] Destination for the retrieved property tag list
1710 * Success: S_OK. *lppTags contains the tags for all available properties.
1711 * Failure: MAPI_E_INVALID_PARAMETER, if any parameter is invalid.
1712 * MAPI_E_BAD_CHARWIDTH, if Ascii or Unicode strings are requested
1713 * and that type of string is not supported.
1715 static inline HRESULT
1716 IMAPIProp_fnGetPropList(LPMAPIPROP iface
, ULONG ulFlags
,
1717 LPSPropTagArray
*lppTags
)
1719 IPropDataImpl
*This
= (IPropDataImpl
*)iface
;
1723 TRACE("(%p,0x%08x,%p) stub\n", iface
, ulFlags
, lppTags
);
1725 if (!iface
|| ulFlags
& ~MAPI_UNICODE
|| !lppTags
)
1726 return MAPI_E_INVALID_PARAMETER
;
1728 FIXME("semi-stub, flags not supported\n");
1732 IMAPIPROP_Lock(This
);
1734 hRet
= MAPIAllocateBuffer(CbNewSPropTagArray(This
->ulNumValues
),
1736 if (SUCCEEDED(hRet
))
1738 struct list
*cursor
;
1741 LIST_FOR_EACH(cursor
, &This
->values
)
1743 LPIPropDataItem current
= LIST_ENTRY(cursor
, IPropDataItem
, entry
);
1744 (*lppTags
)->aulPropTag
[i
] = current
->value
->ulPropTag
;
1747 (*lppTags
)->cValues
= This
->ulNumValues
;
1750 IMAPIPROP_Unlock(This
);
1754 /**************************************************************************
1755 * IMAPIProp_OpenProperty {MAPI32}
1757 * Not documented at this time.
1760 * An HRESULT success/failure code.
1762 static inline HRESULT
1763 IMAPIProp_fnOpenProperty(LPMAPIPROP iface
, ULONG ulPropTag
, LPCIID iid
,
1764 ULONG ulOpts
, ULONG ulFlags
, LPUNKNOWN
*lpUnk
)
1766 FIXME("(%p,%u,%s,%u,0x%08x,%p) stub\n", iface
, ulPropTag
,
1767 debugstr_guid(iid
), ulOpts
, ulFlags
, lpUnk
);
1768 return MAPI_E_NO_SUPPORT
;
1772 /**************************************************************************
1773 * IMAPIProp_SetProps {MAPI32}
1775 * Add or edit the property values in an IMAPIProp object.
1778 * iface [I] IMAPIProp object to get the property tag list from
1779 * ulValues [I] Number of properties in lpProps
1780 * lpProps [I] Property values to set
1781 * lppProbs [O] Optional destination for any problems that occurred
1784 * Success: S_OK. The properties in lpProps are added to iface if they don't
1785 * exist, or changed to the values in lpProps if they do
1786 * Failure: An HRESULT error code describing the error
1788 static inline HRESULT
1789 IMAPIProp_fnSetProps(LPMAPIPROP iface
, ULONG ulValues
,
1790 LPSPropValue lpProps
, LPSPropProblemArray
*lppProbs
)
1792 IPropDataImpl
*This
= (IPropDataImpl
*)iface
;
1793 HRESULT hRet
= S_OK
;
1796 TRACE("(%p,%u,%p,%p)\n", iface
, ulValues
, lpProps
, lppProbs
);
1798 if (!iface
|| !lpProps
)
1799 return MAPI_E_INVALID_PARAMETER
;
1801 for (i
= 0; i
< ulValues
; i
++)
1803 if (FBadProp(&lpProps
[i
]) ||
1804 PROP_TYPE(lpProps
[i
].ulPropTag
) == PT_OBJECT
||
1805 PROP_TYPE(lpProps
[i
].ulPropTag
) == PT_NULL
)
1806 return MAPI_E_INVALID_PARAMETER
;
1809 IMAPIPROP_Lock(This
);
1811 /* FIXME: Under what circumstances is lpProbs created? */
1812 for (i
= 0; i
< ulValues
; i
++)
1814 LPIPropDataItem item
= IMAPIPROP_GetValue(This
, lpProps
[i
].ulPropTag
);
1819 LPVOID lpMem
= NULL
;
1821 /* Found, so update the existing value */
1822 if (item
->value
->ulPropTag
!= lpProps
[i
].ulPropTag
)
1823 FIXME("semi-stub, overwriting type (not coercing)\n");
1825 hRetTmp
= This
->lpAlloc(sizeof(SPropValue
), &lpMem
);
1826 if (SUCCEEDED(hRetTmp
))
1828 hRetTmp
= PropCopyMore(lpMem
, &lpProps
[i
], This
->lpMore
, lpMem
);
1829 if (SUCCEEDED(hRetTmp
))
1831 This
->lpFree(item
->value
);
1832 item
->value
= lpMem
;
1835 This
->lpFree(lpMem
);
1842 if (!IMAPIPROP_AddValue(This
, &lpProps
[i
]))
1843 hRet
= MAPI_E_NOT_ENOUGH_MEMORY
;
1847 IMAPIPROP_Unlock(This
);
1851 /**************************************************************************
1852 * IMAPIProp_DeleteProps {MAPI32}
1854 * Delete one or more property values from an IMAPIProp object.
1857 * iface [I] IMAPIProp object to remove property values from.
1858 * lpTags [I] Collection of property Id's to remove from iface.
1859 * lppProbs [O] Destination for problems encountered, if any.
1862 * Success: S_OK. Any properties in iface matching property Id's in lpTags have
1863 * been deleted. If lppProbs is non-NULL it contains details of any
1864 * errors that occurred.
1865 * Failure: MAPI_E_INVALID_PARAMETER, if any parameter is invalid.
1866 * E_ACCESSDENIED, if this object was created using CreateIProp() and
1867 * a subsequent call to IPropData_SetObjAcess() was made specifying
1868 * IPROP_READONLY as the access type.
1871 * - lppProbs will not be populated for cases where a property Id is present
1872 * in lpTags but not in iface.
1873 * - lppProbs should be deleted with MAPIFreeBuffer() if returned.
1875 static inline HRESULT
1876 IMAPIProp_fnDeleteProps(LPMAPIPROP iface
, LPSPropTagArray lpTags
,
1877 LPSPropProblemArray
*lppProbs
)
1879 IPropDataImpl
*This
= (IPropDataImpl
*)iface
;
1880 ULONG i
, numProbs
= 0;
1881 HRESULT hRet
= S_OK
;
1883 TRACE("(%p,%p,%p)\n", iface
, lpTags
, lppProbs
);
1885 if (!iface
|| !lpTags
)
1886 return MAPI_E_INVALID_PARAMETER
;
1891 for (i
= 0; i
< lpTags
->cValues
; i
++)
1893 if (FBadPropTag(lpTags
->aulPropTag
[i
]) ||
1894 PROP_TYPE(lpTags
->aulPropTag
[i
]) == PT_OBJECT
||
1895 PROP_TYPE(lpTags
->aulPropTag
[i
]) == PT_NULL
)
1896 return MAPI_E_INVALID_PARAMETER
;
1899 IMAPIPROP_Lock(This
);
1901 if (This
->ulObjAccess
!= IPROP_READWRITE
)
1903 IMAPIPROP_Unlock(This
);
1904 return E_ACCESSDENIED
;
1907 for (i
= 0; i
< lpTags
->cValues
; i
++)
1909 LPIPropDataItem item
= IMAPIPROP_GetValue(This
, lpTags
->aulPropTag
[i
]);
1913 if (item
->ulAccess
& IPROP_READWRITE
)
1915 /* Everything hunky-dory, remove the item */
1916 list_remove(&item
->entry
);
1917 This
->lpFree(item
->value
); /* Also frees value pointers */
1919 This
->ulNumValues
--;
1923 /* Can't write the value. Create/populate problems array */
1926 /* Create problems array */
1927 ULONG ulSize
= CbNewSPropProblemArray(lpTags
->cValues
- i
);
1928 HRESULT hRetTmp
= MAPIAllocateBuffer(ulSize
, (LPVOID
*)lppProbs
);
1929 if (FAILED(hRetTmp
))
1934 LPSPropProblem lpProb
= &(*lppProbs
)->aProblem
[numProbs
];
1935 lpProb
->ulIndex
= i
;
1936 lpProb
->ulPropTag
= lpTags
->aulPropTag
[i
];
1937 lpProb
->scode
= E_ACCESSDENIED
;
1943 if (lppProbs
&& *lppProbs
)
1944 (*lppProbs
)->cProblem
= numProbs
;
1946 IMAPIPROP_Unlock(This
);
1951 /**************************************************************************
1952 * IMAPIProp_CopyTo {MAPI32}
1954 * Not documented at this time.
1957 * An HRESULT success/failure code.
1959 static inline HRESULT
1960 IMAPIProp_fnCopyTo(LPMAPIPROP iface
, ULONG niids
, LPCIID lpiidExcl
,
1961 LPSPropTagArray lpPropsExcl
, ULONG ulParam
,
1962 LPMAPIPROGRESS lpIProgress
, LPCIID lpIfaceIid
, LPVOID lpDstObj
,
1963 ULONG ulFlags
, LPSPropProblemArray
*lppProbs
)
1965 FIXME("(%p,%u,%p,%p,%x,%p,%s,%p,0x%08X,%p) stub\n", iface
, niids
,
1966 lpiidExcl
, lpPropsExcl
, ulParam
, lpIProgress
,
1967 debugstr_guid(lpIfaceIid
), lpDstObj
, ulFlags
, lppProbs
);
1968 return MAPI_E_NO_SUPPORT
;
1971 /**************************************************************************
1972 * IMAPIProp_CopyProps {MAPI32}
1974 * Not documented at this time.
1977 * An HRESULT success/failure code.
1979 static inline HRESULT
1980 IMAPIProp_fnCopyProps(LPMAPIPROP iface
, LPSPropTagArray lpInclProps
,
1981 ULONG ulParam
, LPMAPIPROGRESS lpIProgress
, LPCIID lpIface
,
1982 LPVOID lpDstObj
, ULONG ulFlags
,
1983 LPSPropProblemArray
*lppProbs
)
1985 FIXME("(%p,%p,%x,%p,%s,%p,0x%08X,%p) stub\n", iface
, lpInclProps
,
1986 ulParam
, lpIProgress
, debugstr_guid(lpIface
), lpDstObj
, ulFlags
,
1988 return MAPI_E_NO_SUPPORT
;
1991 /**************************************************************************
1992 * IMAPIProp_GetNamesFromIDs {MAPI32}
1994 * Get the names of properties from their identifiers.
1997 * iface [I] IMAPIProp object to operate on
1998 * lppPropTags [I/O] Property identifiers to get the names for, or NULL to
2000 * iid [I] Property set identifier, or NULL
2001 * ulFlags [I] MAPI_NO_IDS=Don't return numeric named properties,
2002 * or MAPI_NO_STRINGS=Don't return strings
2003 * lpCount [O] Destination for number of properties returned
2004 * lpppNames [O] Destination for returned names
2007 * Success: S_OK. *lppPropTags and lpppNames contain the returned
2009 * Failure: MAPI_E_NO_SUPPORT, if the object does not support named properties,
2010 * MAPI_E_NOT_ENOUGH_MEMORY, if memory allocation fails, or
2011 * MAPI_W_ERRORS_RETURNED if not all properties were retrieved
2014 static inline HRESULT
2015 IMAPIProp_fnGetNamesFromIDs(LPMAPIPROP iface
, LPSPropTagArray
*lppPropTags
,
2016 LPGUID iid
, ULONG ulFlags
, ULONG
*lpCount
,
2017 LPMAPINAMEID
**lpppNames
)
2019 FIXME("(%p,%p,%s,0x%08X,%p,%p) stub\n", iface
, lppPropTags
,
2020 debugstr_guid(iid
), ulFlags
, lpCount
, lpppNames
);
2021 return MAPI_E_NO_SUPPORT
;
2024 /**************************************************************************
2025 * IMAPIProp_GetIDsFromNames {MAPI32}
2027 * Get property identifiers associated with one or more named properties.
2030 * iface [I] IMAPIProp object to operate on
2031 * ulNames [I] Number of names in lppNames
2032 * lppNames [I] Names to query or create, or NULL to query all names
2033 * ulFlags [I] Pass MAPI_CREATE to create new named properties
2034 * lppPropTags [O] Destination for queried or created property identifiers
2037 * Success: S_OK. *lppPropTags contains the property tags created or requested.
2038 * Failure: MAPI_E_NO_SUPPORT, if the object does not support named properties,
2039 * MAPI_E_TOO_BIG, if the object cannot process the number of
2040 * properties involved.
2041 * MAPI_E_NOT_ENOUGH_MEMORY, if memory allocation fails, or
2042 * MAPI_W_ERRORS_RETURNED if not all properties were retrieved
2045 static inline HRESULT
2046 IMAPIProp_fnGetIDsFromNames(LPMAPIPROP iface
, ULONG ulNames
,
2047 LPMAPINAMEID
*lppNames
, ULONG ulFlags
,
2048 LPSPropTagArray
*lppPropTags
)
2050 FIXME("(%p,%d,%p,0x%08X,%p) stub\n",
2051 iface
, ulNames
, lppNames
, ulFlags
, lppPropTags
);
2052 return MAPI_E_NO_SUPPORT
;
2055 /**************************************************************************
2056 * IPropData {MAPI32}
2058 * A default Mapi interface to provide manipulation of object properties.
2061 * This object provides a default interface suitable in some cases as an
2062 * implementation of the IMAPIProp interface (which has no default
2063 * implementation). In addition to the IMAPIProp() methods inherited, this
2064 * interface allows read/write control over access to the object and its
2065 * individual properties.
2067 * To obtain the default implementation of this interface from Mapi, call
2073 /**************************************************************************
2074 * IPropData_QueryInterface {MAPI32}
2076 * Inherited method from the IMAPIProp Interface.
2077 * See IMAPIProp_QueryInterface.
2079 static HRESULT WINAPI
2080 IPropData_fnQueryInterface(LPPROPDATA iface
, REFIID riid
, LPVOID
*ppvObj
)
2082 return IMAPIProp_fnQueryInterface((LPMAPIPROP
)iface
, riid
, ppvObj
);
2085 /**************************************************************************
2086 * IPropData_AddRef {MAPI32}
2088 * Inherited method from the IMAPIProp Interface.
2089 * See IMAPIProp_AddRef.
2092 IPropData_fnAddRef(LPPROPDATA iface
)
2094 return IMAPIProp_fnAddRef((LPMAPIPROP
)iface
);
2097 /**************************************************************************
2098 * IPropData_Release {MAPI32}
2100 * Inherited method from the IMAPIProp Interface.
2101 * See IMAPIProp_Release.
2104 IPropData_fnRelease(LPPROPDATA iface
)
2106 return IMAPIProp_fnRelease((LPMAPIPROP
)iface
);
2109 /**************************************************************************
2110 * IPropData_GetLastError {MAPI32}
2112 * Inherited method from the IMAPIProp Interface.
2113 * See IMAPIProp_GetLastError.
2115 static HRESULT WINAPI
2116 IPropData_fnGetLastError(LPPROPDATA iface
, HRESULT hRes
, ULONG ulFlags
,
2117 LPMAPIERROR
*lppError
)
2119 return IMAPIProp_fnGetLastError((LPMAPIPROP
)iface
, hRes
, ulFlags
, lppError
);
2122 /**************************************************************************
2123 * IPropData_SaveChanges {MAPI32}
2125 * Inherited method from the IMAPIProp Interface.
2126 * See IMAPIProp_SaveChanges.
2128 static HRESULT WINAPI
2129 IPropData_fnSaveChanges(LPPROPDATA iface
, ULONG ulFlags
)
2131 return IMAPIProp_fnSaveChanges((LPMAPIPROP
)iface
, ulFlags
);
2134 /**************************************************************************
2135 * IPropData_GetProps {MAPI32}
2137 * Inherited method from the IMAPIProp Interface.
2138 * See IMAPIProp_GetProps.
2140 static HRESULT WINAPI
2141 IPropData_fnGetProps(LPPROPDATA iface
, LPSPropTagArray lpPropTags
,
2142 ULONG ulFlags
, ULONG
*lpCount
, LPSPropValue
*lppProps
)
2144 return IMAPIProp_fnGetProps((LPMAPIPROP
)iface
, lpPropTags
, ulFlags
,
2148 /**************************************************************************
2149 * IPropData_GetPropList {MAPI32}
2151 * Inherited method from the IMAPIProp Interface.
2152 * See IMAPIProp_GetPropList.
2154 static HRESULT WINAPI
2155 IPropData_fnGetPropList(LPPROPDATA iface
, ULONG ulFlags
,
2156 LPSPropTagArray
*lppPropTags
)
2158 return IMAPIProp_fnGetPropList((LPMAPIPROP
)iface
, ulFlags
, lppPropTags
);
2161 /**************************************************************************
2162 * IPropData_OpenProperty {MAPI32}
2164 * Inherited method from the IMAPIProp Interface.
2165 * See IMAPIProp_OpenProperty.
2167 static HRESULT WINAPI
2168 IPropData_fnOpenProperty(LPPROPDATA iface
, ULONG ulPropTag
, LPCIID iid
,
2169 ULONG ulOpts
, ULONG ulFlags
, LPUNKNOWN
*lpUnk
)
2171 return IMAPIProp_fnOpenProperty((LPMAPIPROP
)iface
, ulPropTag
, iid
,
2172 ulOpts
, ulFlags
, lpUnk
);
2175 /**************************************************************************
2176 * IPropData_SetProps {MAPI32}
2178 * Inherited method from the IMAPIProp Interface.
2179 * See IMAPIProp_SetProps.
2181 static HRESULT WINAPI
2182 IPropData_fnSetProps(LPPROPDATA iface
, ULONG cValues
, LPSPropValue lpProps
,
2183 LPSPropProblemArray
*lppProbs
)
2185 return IMAPIProp_fnSetProps((LPMAPIPROP
)iface
, cValues
, lpProps
, lppProbs
);
2188 /**************************************************************************
2189 * IPropData_DeleteProps {MAPI32}
2191 * Inherited method from the IMAPIProp Interface.
2192 * See IMAPIProp_DeleteProps.
2194 static HRESULT WINAPI
2195 IPropData_fnDeleteProps(LPPROPDATA iface
, LPSPropTagArray lpPropTags
,
2196 LPSPropProblemArray
*lppProbs
)
2198 return IMAPIProp_fnDeleteProps((LPMAPIPROP
)iface
, lpPropTags
, lppProbs
);
2201 /**************************************************************************
2202 * IPropData_CopyTo {MAPI32}
2204 * Inherited method from the IMAPIProp Interface.
2205 * See IMAPIProp_CopyTo.
2207 static HRESULT WINAPI
2208 IPropData_fnCopyTo(LPPROPDATA iface
, ULONG ciidExclude
, LPCIID lpIid
,
2209 LPSPropTagArray lpProps
, ULONG ulParam
,
2210 LPMAPIPROGRESS lpProgress
, LPCIID lpIface
, LPVOID lpDst
,
2211 ULONG ulFlags
, LPSPropProblemArray
*lppProbs
)
2213 return IMAPIProp_fnCopyTo((LPMAPIPROP
)iface
, ciidExclude
, lpIid
, lpProps
,
2214 ulParam
, lpProgress
, lpIface
, lpDst
,
2218 /**************************************************************************
2219 * IPropData_CopyProps {MAPI32}
2221 * Inherited method from the IMAPIProp Interface.
2222 * See IMAPIProp_CopyProps.
2224 static HRESULT WINAPI
2225 IPropData_fnCopyProps(LPPROPDATA iface
, LPSPropTagArray lpProps
,
2226 ULONG ulParam
, LPMAPIPROGRESS lpProgress
, LPCIID lpIface
,
2227 LPVOID lpDst
, ULONG ulFlags
, LPSPropProblemArray
*lppProbs
)
2229 return IMAPIProp_fnCopyProps((LPMAPIPROP
)iface
, lpProps
, ulParam
,
2230 lpProgress
, lpIface
, lpDst
, ulFlags
, lppProbs
);
2233 /**************************************************************************
2234 * IPropData_GetNamesFromIDs {MAPI32}
2236 * Inherited method from the IMAPIProp Interface.
2237 * See IMAPIProp_GetNamesFromIDs.
2239 static HRESULT WINAPI
2240 IPropData_fnGetNamesFromIDs(LPPROPDATA iface
, LPSPropTagArray
*lppPropTags
,
2241 LPGUID iid
, ULONG ulFlags
, ULONG
*lpCount
,
2242 LPMAPINAMEID
**lpppNames
)
2244 return IMAPIProp_fnGetNamesFromIDs((LPMAPIPROP
)iface
, lppPropTags
, iid
,
2245 ulFlags
, lpCount
, lpppNames
);
2248 /**************************************************************************
2249 * IPropData_GetIDsFromNames {MAPI32}
2251 * Inherited method from the IMAPIProp Interface.
2252 * See IMAPIProp_GetIDsFromNames.
2254 static HRESULT WINAPI
2255 IPropData_fnGetIDsFromNames(LPPROPDATA iface
, ULONG ulNames
,
2256 LPMAPINAMEID
*lppNames
, ULONG ulFlags
,
2257 LPSPropTagArray
*lppPropTags
)
2259 return IMAPIProp_fnGetIDsFromNames((LPMAPIPROP
)iface
, ulNames
, lppNames
,
2260 ulFlags
, lppPropTags
);
2263 /**************************************************************************
2264 * IPropData_HrSetObjAccess {MAPI32}
2266 * Set the access level of an IPropData object.
2269 * iface [I] IPropData object to set the access on
2270 * ulAccess [I] Either IPROP_READONLY or IPROP_READWRITE for read or
2271 * read/write access respectively.
2274 * Success: S_OK. The objects access level is changed.
2275 * Failure: MAPI_E_INVALID_PARAMETER, if any parameter is invalid.
2277 static HRESULT WINAPI
2278 IPropData_fnHrSetObjAccess(LPPROPDATA iface
, ULONG ulAccess
)
2280 IPropDataImpl
*This
= (IPropDataImpl
*)iface
;
2282 TRACE("(%p,%x)\n", iface
, ulAccess
);
2284 if (!iface
|| ulAccess
< IPROP_READONLY
|| ulAccess
> IPROP_READWRITE
)
2285 return MAPI_E_INVALID_PARAMETER
;
2287 IMAPIPROP_Lock(This
);
2289 This
->ulObjAccess
= ulAccess
;
2291 IMAPIPROP_Unlock(This
);
2295 /* Internal - determine if an access value is bad */
2296 static inline BOOL
PROP_IsBadAccess(ULONG ulAccess
)
2300 case IPROP_READONLY
|IPROP_CLEAN
:
2301 case IPROP_READONLY
|IPROP_DIRTY
:
2302 case IPROP_READWRITE
|IPROP_CLEAN
:
2303 case IPROP_READWRITE
|IPROP_DIRTY
:
2309 /**************************************************************************
2310 * IPropData_HrSetPropAccess {MAPI32}
2312 * Set the access levels for a group of property values in an IPropData object.
2315 * iface [I] IPropData object to set access levels in.
2316 * lpTags [I] List of property Id's to set access for.
2317 * lpAccess [O] Access level for each property in lpTags.
2320 * Success: S_OK. The access level of each property value in lpTags that is
2321 * present in iface is changed.
2322 * Failure: MAPI_E_INVALID_PARAMETER, if any parameter is invalid.
2325 * - Each access level in lpAccess must contain at least one of IPROP_READONLY
2326 * or IPROP_READWRITE, but not both, and also IPROP_CLEAN or IPROP_DIRTY,
2327 * but not both. No other bits should be set.
2328 * - If a property Id in lpTags is not present in iface, it is ignored.
2330 static HRESULT WINAPI
2331 IPropData_fnHrSetPropAccess(LPPROPDATA iface
, LPSPropTagArray lpTags
,
2334 IPropDataImpl
*This
= (IPropDataImpl
*)iface
;
2338 TRACE("(%p,%p,%p)\n", iface
, lpTags
, lpAccess
);
2340 if (!iface
|| !lpTags
|| !lpAccess
)
2341 return MAPI_E_INVALID_PARAMETER
;
2343 for (i
= 0; i
< lpTags
->cValues
; i
++)
2345 if (FBadPropTag(lpTags
->aulPropTag
[i
]) || PROP_IsBadAccess(lpAccess
[i
]))
2346 return MAPI_E_INVALID_PARAMETER
;
2349 IMAPIPROP_Lock(This
);
2351 for (i
= 0; i
< lpTags
->cValues
; i
++)
2353 LPIPropDataItem item
= IMAPIPROP_GetValue(This
, lpTags
->aulPropTag
[i
]);
2356 item
->ulAccess
= lpAccess
[i
];
2359 IMAPIPROP_Unlock(This
);
2363 /**************************************************************************
2364 * IPropData_HrGetPropAccess {MAPI32}
2366 * Get the access levels for a group of property values in an IPropData object.
2369 * iface [I] IPropData object to get access levels from.
2370 * lppTags [O] Destination for the list of property Id's in iface.
2371 * lppAccess [O] Destination for access level for each property in lppTags.
2374 * Success: S_OK. lppTags and lppAccess contain the property Id's and the
2375 * Access level of each property value in iface.
2376 * Failure: MAPI_E_INVALID_PARAMETER, if any parameter is invalid, or
2377 * MAPI_E_NOT_ENOUGH_MEMORY if memory allocation fails.
2380 * - *lppTags and *lppAccess should be freed with MAPIFreeBuffer() by the caller.
2382 static HRESULT WINAPI
2383 IPropData_fnHrGetPropAccess(LPPROPDATA iface
, LPSPropTagArray
*lppTags
,
2386 IPropDataImpl
*This
= (IPropDataImpl
*)iface
;
2391 TRACE("(%p,%p,%p) stub\n", iface
, lppTags
, lppAccess
);
2393 if (!iface
|| !lppTags
|| !lppAccess
)
2394 return MAPI_E_INVALID_PARAMETER
;
2399 IMAPIPROP_Lock(This
);
2401 hRet
= This
->lpAlloc(CbNewSPropTagArray(This
->ulNumValues
), &lpMem
);
2402 if (SUCCEEDED(hRet
))
2406 hRet
= This
->lpAlloc(This
->ulNumValues
* sizeof(ULONG
), &lpMem
);
2407 if (SUCCEEDED(hRet
))
2409 struct list
*cursor
;
2412 (*lppTags
)->cValues
= This
->ulNumValues
;
2415 LIST_FOR_EACH(cursor
, &This
->values
)
2417 LPIPropDataItem item
= LIST_ENTRY(cursor
, IPropDataItem
, entry
);
2418 (*lppTags
)->aulPropTag
[i
] = item
->value
->ulPropTag
;
2419 (*lppAccess
)[i
] = item
->ulAccess
;
2422 IMAPIPROP_Unlock(This
);
2425 This
->lpFree(*lppTags
);
2428 IMAPIPROP_Unlock(This
);
2429 return MAPI_E_NOT_ENOUGH_MEMORY
;
2432 /**************************************************************************
2433 * IPropData_HrAddObjProps {MAPI32}
2435 * Not documented at this time.
2438 * An HRESULT success/failure code.
2440 static HRESULT WINAPI
2441 IPropData_fnHrAddObjProps(LPPROPDATA iface
, LPSPropTagArray lpTags
,
2442 LPSPropProblemArray
*lppProbs
)
2447 LPSPropValue lpValues
;
2450 FIXME("(%p,%p,%p) stub\n", iface
, lpTags
, lppProbs
);
2452 if (!iface
|| !lpTags
)
2453 return MAPI_E_INVALID_PARAMETER
;
2455 /* FIXME: Below is the obvious implementation, adding all the properties
2456 * in lpTags to the object. However, it doesn't appear that this
2457 * is what this function does.
2461 if (!lpTags
->cValues
)
2464 lpValues
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
,
2465 lpTags
->cValues
* sizeof(SPropValue
));
2467 return MAPI_E_NOT_ENOUGH_MEMORY
;
2469 for (i
= 0; i
< lpTags
->cValues
; i
++)
2470 lpValues
[i
].ulPropTag
= lpTags
->aulPropTag
[i
];
2472 hRet
= IPropData_SetProps(iface
, lpTags
->cValues
, lpValues
, lppProbs
);
2473 HeapFree(GetProcessHeap(), 0, lpValues
);
2478 static const IPropDataVtbl IPropDataImpl_vtbl
=
2480 IPropData_fnQueryInterface
,
2482 IPropData_fnRelease
,
2483 IPropData_fnGetLastError
,
2484 IPropData_fnSaveChanges
,
2485 IPropData_fnGetProps
,
2486 IPropData_fnGetPropList
,
2487 IPropData_fnOpenProperty
,
2488 IPropData_fnSetProps
,
2489 IPropData_fnDeleteProps
,
2491 IPropData_fnCopyProps
,
2492 IPropData_fnGetNamesFromIDs
,
2493 IPropData_fnGetIDsFromNames
,
2494 IPropData_fnHrSetObjAccess
,
2495 IPropData_fnHrSetPropAccess
,
2496 IPropData_fnHrGetPropAccess
,
2497 IPropData_fnHrAddObjProps
2500 /*************************************************************************
2501 * CreateIProp@24 (MAPI32.60)
2503 * Create an IPropData object.
2506 * iid [I] GUID of the object to create. Use &IID_IMAPIPropData or NULL
2507 * lpAlloc [I] Memory allocation function. Use MAPIAllocateBuffer()
2508 * lpMore [I] Linked memory allocation function. Use MAPIAllocateMore()
2509 * lpFree [I] Memory free function. Use MAPIFreeBuffer()
2510 * lpReserved [I] Reserved, set to NULL
2511 * lppPropData [O] Destination for created IPropData object
2514 * Success: S_OK. *lppPropData contains the newly created object.
2515 * Failure: MAPI_E_INTERFACE_NOT_SUPPORTED, if iid is non-NULL and not supported,
2516 * MAPI_E_INVALID_PARAMETER, if any parameter is invalid
2518 SCODE WINAPI
CreateIProp(LPCIID iid
, ALLOCATEBUFFER
*lpAlloc
,
2519 ALLOCATEMORE
*lpMore
, FREEBUFFER
*lpFree
,
2520 LPVOID lpReserved
, LPPROPDATA
*lppPropData
)
2522 IPropDataImpl
*lpPropData
;
2525 TRACE("(%s,%p,%p,%p,%p,%p)\n", debugstr_guid(iid
), lpAlloc
, lpMore
, lpFree
,
2526 lpReserved
, lppPropData
);
2529 *lppPropData
= NULL
;
2531 if (iid
&& !IsEqualGUID(iid
, &IID_IMAPIPropData
))
2532 return MAPI_E_INTERFACE_NOT_SUPPORTED
;
2534 if (!lpAlloc
|| !lpMore
|| !lpFree
|| lpReserved
|| !lppPropData
)
2535 return MAPI_E_INVALID_PARAMETER
;
2537 scode
= lpAlloc(sizeof(IPropDataImpl
), (LPVOID
*)&lpPropData
);
2539 if (SUCCEEDED(scode
))
2541 lpPropData
->lpVtbl
= &IPropDataImpl_vtbl
;
2542 lpPropData
->lRef
= 1;
2543 lpPropData
->lpAlloc
= lpAlloc
;
2544 lpPropData
->lpMore
= lpMore
;
2545 lpPropData
->lpFree
= lpFree
;
2546 lpPropData
->ulObjAccess
= IPROP_READWRITE
;
2547 lpPropData
->ulNumValues
= 0;
2548 list_init(&lpPropData
->values
);
2549 InitializeCriticalSection(&lpPropData
->cs
);
2550 lpPropData
->cs
.DebugInfo
->Spare
[0] = (DWORD_PTR
)(__FILE__
": IPropDataImpl.cs");
2551 *lppPropData
= (LPPROPDATA
)lpPropData
;