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
30 #include "wine/list.h"
31 #include "wine/debug.h"
32 #include "wine/unicode.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(mapi
);
37 BOOL WINAPI
FBadRglpszA(LPSTR
*,ULONG
);
39 /* Internal: Check if a property value array is invalid */
40 static inline ULONG
PROP_BadArray(LPSPropValue lpProp
, size_t elemSize
)
42 return IsBadReadPtr(lpProp
->Value
.MVi
.lpi
, lpProp
->Value
.MVi
.cValues
* elemSize
);
45 /*************************************************************************
46 * PropCopyMore@16 (MAPI32.76)
48 * Copy a property value.
51 * lpDest [O] Destination for the copied value
52 * lpSrc [I] Property value to copy to lpDest
53 * lpMore [I] Linked memory allocation function (pass MAPIAllocateMore())
54 * lpOrig [I] Original allocation to which memory will be linked
57 * Success: S_OK. lpDest contains a deep copy of lpSrc.
58 * Failure: MAPI_E_INVALID_PARAMETER, if any parameter is invalid,
59 * MAPI_E_NOT_ENOUGH_MEMORY, if memory allocation fails.
62 * Any elements within the property returned should not be individually
63 * freed, as they will be freed when lpOrig is.
65 SCODE WINAPI
PropCopyMore(LPSPropValue lpDest
, LPSPropValue lpSrc
,
66 ALLOCATEMORE
*lpMore
, LPVOID lpOrig
)
71 TRACE("(%p,%p,%p,%p)\n", lpDest
, lpSrc
, lpMore
, lpOrig
);
73 if (!lpDest
|| IsBadWritePtr(lpDest
, sizeof(SPropValue
)) ||
74 FBadProp(lpSrc
) || !lpMore
)
75 return MAPI_E_INVALID_PARAMETER
;
77 /* Shallow copy first, this is sufficient for properties without pointers */
80 switch (PROP_TYPE(lpSrc
->ulPropTag
))
83 scode
= lpMore(sizeof(GUID
), lpOrig
, (LPVOID
*)&lpDest
->Value
.lpguid
);
85 *lpDest
->Value
.lpguid
= *lpSrc
->Value
.lpguid
;
88 ulLen
= lstrlenA(lpSrc
->Value
.lpszA
) + 1u;
89 scode
= lpMore(ulLen
, lpOrig
, (LPVOID
*)&lpDest
->Value
.lpszA
);
91 memcpy(lpDest
->Value
.lpszA
, lpSrc
->Value
.lpszA
, ulLen
);
94 ulLen
= (strlenW(lpSrc
->Value
.lpszW
) + 1u) * sizeof(WCHAR
);
95 scode
= lpMore(ulLen
, lpOrig
, (LPVOID
*)&lpDest
->Value
.lpszW
);
97 memcpy(lpDest
->Value
.lpszW
, lpSrc
->Value
.lpszW
, ulLen
);
100 scode
= lpMore(lpSrc
->Value
.bin
.cb
, lpOrig
, (LPVOID
*)&lpDest
->Value
.bin
.lpb
);
101 if (SUCCEEDED(scode
))
102 memcpy(lpDest
->Value
.bin
.lpb
, lpSrc
->Value
.bin
.lpb
, lpSrc
->Value
.bin
.cb
);
105 if (lpSrc
->ulPropTag
& MV_FLAG
)
107 ulLen
= UlPropSize(lpSrc
);
109 if (PROP_TYPE(lpSrc
->ulPropTag
) == PT_MV_STRING8
||
110 PROP_TYPE(lpSrc
->ulPropTag
) == PT_MV_UNICODE
)
112 /* UlPropSize doesn't account for the string pointers */
113 ulLen
+= lpSrc
->Value
.MVszA
.cValues
* sizeof(char*);
115 else if (PROP_TYPE(lpSrc
->ulPropTag
) == PT_MV_BINARY
)
117 /* UlPropSize doesn't account for the SBinary structs */
118 ulLen
+= lpSrc
->Value
.MVbin
.cValues
* sizeof(SBinary
);
121 lpDest
->Value
.MVi
.cValues
= lpSrc
->Value
.MVi
.cValues
;
122 scode
= lpMore(ulLen
, lpOrig
, (LPVOID
*)&lpDest
->Value
.MVi
.lpi
);
126 /* Note that we could allocate the memory for each value in a
127 * multi-value property separately, however if an allocation failed
128 * we would be left with a bunch of allocated memory, which (while
129 * not really leaked) is unusable until lpOrig is freed. So for
130 * strings and binary arrays we make a single allocation for all
131 * of the data. This is consistent since individual elements can't
135 switch (PROP_TYPE(lpSrc
->ulPropTag
))
139 char *lpNextStr
= (char*)(lpDest
->Value
.MVszA
.lppszA
+
140 lpDest
->Value
.MVszA
.cValues
);
142 for (i
= 0; i
< lpSrc
->Value
.MVszA
.cValues
; i
++)
144 ULONG ulStrLen
= lstrlenA(lpSrc
->Value
.MVszA
.lppszA
[i
]) + 1u;
146 lpDest
->Value
.MVszA
.lppszA
[i
] = lpNextStr
;
147 memcpy(lpNextStr
, lpSrc
->Value
.MVszA
.lppszA
[i
], ulStrLen
);
148 lpNextStr
+= ulStrLen
;
154 WCHAR
*lpNextStr
= (WCHAR
*)(lpDest
->Value
.MVszW
.lppszW
+
155 lpDest
->Value
.MVszW
.cValues
);
157 for (i
= 0; i
< lpSrc
->Value
.MVszW
.cValues
; i
++)
159 ULONG ulStrLen
= strlenW(lpSrc
->Value
.MVszW
.lppszW
[i
]) + 1u;
161 lpDest
->Value
.MVszW
.lppszW
[i
] = lpNextStr
;
162 memcpy(lpNextStr
, lpSrc
->Value
.MVszW
.lppszW
[i
], ulStrLen
* sizeof(WCHAR
));
163 lpNextStr
+= ulStrLen
;
169 LPBYTE lpNext
= (LPBYTE
)(lpDest
->Value
.MVbin
.lpbin
+
170 lpDest
->Value
.MVbin
.cValues
);
172 for (i
= 0; i
< lpSrc
->Value
.MVszW
.cValues
; i
++)
174 lpDest
->Value
.MVbin
.lpbin
[i
].cb
= lpSrc
->Value
.MVbin
.lpbin
[i
].cb
;
175 lpDest
->Value
.MVbin
.lpbin
[i
].lpb
= lpNext
;
176 memcpy(lpNext
, lpSrc
->Value
.MVbin
.lpbin
[i
].lpb
, lpDest
->Value
.MVbin
.lpbin
[i
].cb
);
177 lpNext
+= lpDest
->Value
.MVbin
.lpbin
[i
].cb
;
182 /* No embedded pointers, just copy the data over */
183 memcpy(lpDest
->Value
.MVi
.lpi
, lpSrc
->Value
.MVi
.lpi
, ulLen
);
192 /*************************************************************************
193 * UlPropSize@4 (MAPI32.77)
195 * Determine the size of a property in bytes.
198 * lpProp [I] Property to determine the size of
201 * Success: The size of the value in lpProp.
202 * Failure: 0, if a multi-value (array) property is invalid or the type of lpProp
206 * - The size returned does not include the size of the SPropValue struct
207 * or the size of the array of pointers for multi-valued properties that
208 * contain pointers (such as PT_MV_STRING8 or PT-MV_UNICODE).
209 * - MSDN incorrectly states that this function returns MAPI_E_CALL_FAILED if
210 * lpProp is invalid. In reality no checking is performed and this function
211 * will crash if passed an invalid property, or return 0 if the property
212 * type is PT_OBJECT or is unknown.
214 ULONG WINAPI
UlPropSize(LPSPropValue lpProp
)
218 TRACE("(%p)\n", lpProp
);
220 switch (PROP_TYPE(lpProp
->ulPropTag
))
222 case PT_MV_I2
: ulRet
= lpProp
->Value
.MVi
.cValues
;
225 case PT_I2
: ulRet
*= sizeof(USHORT
);
227 case PT_MV_I4
: ulRet
= lpProp
->Value
.MVl
.cValues
;
230 case PT_I4
: ulRet
*= sizeof(LONG
);
232 case PT_MV_I8
: ulRet
= lpProp
->Value
.MVli
.cValues
;
234 case PT_I8
: ulRet
*= sizeof(LONG64
);
236 case PT_MV_R4
: ulRet
= lpProp
->Value
.MVflt
.cValues
;
238 case PT_R4
: ulRet
*= sizeof(float);
241 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
;
248 case PT_CURRENCY
: ulRet
*= sizeof(CY
);
250 case PT_MV_SYSTIME
: ulRet
= lpProp
->Value
.MVft
.cValues
;
252 case PT_SYSTIME
: ulRet
*= sizeof(FILETIME
);
254 case PT_MV_CLSID
: ulRet
= lpProp
->Value
.MVguid
.cValues
;
256 case PT_CLSID
: ulRet
*= sizeof(GUID
);
258 case PT_MV_STRING8
: ulRet
= 0u;
259 for (i
= 0; i
< lpProp
->Value
.MVszA
.cValues
; i
++)
260 ulRet
+= (lstrlenA(lpProp
->Value
.MVszA
.lppszA
[i
]) + 1u);
262 case PT_STRING8
: ulRet
= lstrlenA(lpProp
->Value
.lpszA
) + 1u;
264 case PT_MV_UNICODE
: ulRet
= 0u;
265 for (i
= 0; i
< lpProp
->Value
.MVszW
.cValues
; i
++)
266 ulRet
+= (strlenW(lpProp
->Value
.MVszW
.lppszW
[i
]) + 1u);
267 ulRet
*= sizeof(WCHAR
);
269 case PT_UNICODE
: ulRet
= (lstrlenW(lpProp
->Value
.lpszW
) + 1u) * sizeof(WCHAR
);
271 case PT_MV_BINARY
: ulRet
= 0u;
272 for (i
= 0; i
< lpProp
->Value
.MVbin
.cValues
; i
++)
273 ulRet
+= lpProp
->Value
.MVbin
.lpbin
[i
].cb
;
275 case PT_BINARY
: ulRet
= lpProp
->Value
.bin
.cb
;
285 /*************************************************************************
286 * FPropContainsProp@12 (MAPI32.78)
288 * Find a property with a given property tag in a property array.
291 * lpHaystack [I] Property to match to
292 * lpNeedle [I] Property to find in lpHaystack
293 * ulFuzzy [I] Flags controlling match type and strictness (FL_* flags from "mapidefs.h")
296 * TRUE, if lpNeedle matches lpHaystack according to the criteria of ulFuzzy.
299 * Only property types of PT_STRING8 and PT_BINARY are handled by this function.
301 BOOL WINAPI
FPropContainsProp(LPSPropValue lpHaystack
, LPSPropValue lpNeedle
, ULONG ulFuzzy
)
303 TRACE("(%p,%p,0x%08x)\n", lpHaystack
, lpNeedle
, ulFuzzy
);
305 if (FBadProp(lpHaystack
) || FBadProp(lpNeedle
) ||
306 PROP_TYPE(lpHaystack
->ulPropTag
) != PROP_TYPE(lpNeedle
->ulPropTag
))
309 /* FIXME: Do later versions support Unicode as well? */
311 if (PROP_TYPE(lpHaystack
->ulPropTag
) == PT_STRING8
)
313 DWORD dwFlags
= 0, dwNeedleLen
, dwHaystackLen
;
315 if (ulFuzzy
& FL_IGNORECASE
)
316 dwFlags
|= NORM_IGNORECASE
;
317 if (ulFuzzy
& FL_IGNORENONSPACE
)
318 dwFlags
|= NORM_IGNORENONSPACE
;
319 if (ulFuzzy
& FL_LOOSE
)
320 dwFlags
|= (NORM_IGNORECASE
|NORM_IGNORENONSPACE
|NORM_IGNORESYMBOLS
);
322 dwNeedleLen
= lstrlenA(lpNeedle
->Value
.lpszA
);
323 dwHaystackLen
= lstrlenA(lpHaystack
->Value
.lpszA
);
325 if ((ulFuzzy
& (FL_SUBSTRING
|FL_PREFIX
)) == FL_PREFIX
)
327 if (dwNeedleLen
<= dwHaystackLen
&&
328 CompareStringA(LOCALE_USER_DEFAULT
, dwFlags
,
329 lpHaystack
->Value
.lpszA
, dwNeedleLen
,
330 lpNeedle
->Value
.lpszA
, dwNeedleLen
) == CSTR_EQUAL
)
331 return TRUE
; /* needle is a prefix of haystack */
333 else if ((ulFuzzy
& (FL_SUBSTRING
|FL_PREFIX
)) == FL_SUBSTRING
)
335 LPSTR (WINAPI
*pStrChrFn
)(LPCSTR
,WORD
) = StrChrA
;
336 LPSTR lpStr
= lpHaystack
->Value
.lpszA
;
338 if (dwFlags
& NORM_IGNORECASE
)
339 pStrChrFn
= StrChrIA
;
341 while ((lpStr
= pStrChrFn(lpStr
, *lpNeedle
->Value
.lpszA
)) != NULL
)
343 dwHaystackLen
-= (lpStr
- lpHaystack
->Value
.lpszA
);
344 if (dwNeedleLen
<= dwHaystackLen
&&
345 CompareStringA(LOCALE_USER_DEFAULT
, dwFlags
,
347 lpNeedle
->Value
.lpszA
, dwNeedleLen
) == CSTR_EQUAL
)
348 return TRUE
; /* needle is a substring of haystack */
352 else if (CompareStringA(LOCALE_USER_DEFAULT
, dwFlags
,
353 lpHaystack
->Value
.lpszA
, dwHaystackLen
,
354 lpNeedle
->Value
.lpszA
, dwNeedleLen
) == CSTR_EQUAL
)
355 return TRUE
; /* full string match */
357 else if (PROP_TYPE(lpHaystack
->ulPropTag
) == PT_BINARY
)
359 if ((ulFuzzy
& (FL_SUBSTRING
|FL_PREFIX
)) == FL_PREFIX
)
361 if (lpNeedle
->Value
.bin
.cb
<= lpHaystack
->Value
.bin
.cb
&&
362 !memcmp(lpNeedle
->Value
.bin
.lpb
, lpHaystack
->Value
.bin
.lpb
,
363 lpNeedle
->Value
.bin
.cb
))
364 return TRUE
; /* needle is a prefix of haystack */
366 else if ((ulFuzzy
& (FL_SUBSTRING
|FL_PREFIX
)) == FL_SUBSTRING
)
368 ULONG ulLen
= lpHaystack
->Value
.bin
.cb
;
369 LPBYTE lpb
= lpHaystack
->Value
.bin
.lpb
;
371 while ((lpb
= memchr(lpb
, *lpNeedle
->Value
.bin
.lpb
, ulLen
)) != NULL
)
373 ulLen
= lpHaystack
->Value
.bin
.cb
- (lpb
- lpHaystack
->Value
.bin
.lpb
);
374 if (lpNeedle
->Value
.bin
.cb
<= ulLen
&&
375 !memcmp(lpNeedle
->Value
.bin
.lpb
, lpb
, lpNeedle
->Value
.bin
.cb
))
376 return TRUE
; /* needle is a substring of haystack */
380 else if (!LPropCompareProp(lpHaystack
, lpNeedle
))
381 return TRUE
; /* needle is an exact match with haystack */
387 /*************************************************************************
388 * FPropCompareProp@12 (MAPI32.79)
390 * Compare two properties.
393 * lpPropLeft [I] Left hand property to compare to lpPropRight
394 * ulOp [I] Comparison operator (RELOP_* enum from "mapidefs.h")
395 * lpPropRight [I] Right hand property to compare to lpPropLeft
398 * TRUE, if the comparison is true, FALSE otherwise.
400 BOOL WINAPI
FPropCompareProp(LPSPropValue lpPropLeft
, ULONG ulOp
, LPSPropValue lpPropRight
)
404 TRACE("(%p,%d,%p)\n", lpPropLeft
, ulOp
, lpPropRight
);
406 if (ulOp
> RELOP_RE
|| FBadProp(lpPropLeft
) || FBadProp(lpPropRight
))
409 if (ulOp
== RELOP_RE
)
411 FIXME("Comparison operator RELOP_RE not yet implemented!\n");
415 iCmp
= LPropCompareProp(lpPropLeft
, lpPropRight
);
419 case RELOP_LT
: return iCmp
< 0;
420 case RELOP_LE
: return iCmp
<= 0;
421 case RELOP_GT
: return iCmp
> 0;
422 case RELOP_GE
: return iCmp
>= 0;
423 case RELOP_EQ
: return iCmp
== 0;
424 case RELOP_NE
: return iCmp
!= 0;
429 /*************************************************************************
430 * LPropCompareProp@8 (MAPI32.80)
432 * Compare two properties.
435 * lpPropLeft [I] Left hand property to compare to lpPropRight
436 * lpPropRight [I] Right hand property to compare to lpPropLeft
439 * An integer less than, equal to or greater than 0, indicating that
440 * lpszStr is less than, the same, or greater than lpszComp.
442 LONG WINAPI
LPropCompareProp(LPSPropValue lpPropLeft
, LPSPropValue lpPropRight
)
446 TRACE("(%p->0x%08x,%p->0x%08x)\n", lpPropLeft
, lpPropLeft
->ulPropTag
,
447 lpPropRight
, lpPropRight
->ulPropTag
);
449 /* If the properties are not the same, sort by property type */
450 if (PROP_TYPE(lpPropLeft
->ulPropTag
) != PROP_TYPE(lpPropRight
->ulPropTag
))
451 return (LONG
)PROP_TYPE(lpPropLeft
->ulPropTag
) - (LONG
)PROP_TYPE(lpPropRight
->ulPropTag
);
453 switch (PROP_TYPE(lpPropLeft
->ulPropTag
))
457 return 0; /* NULLs are equal */
459 return lpPropLeft
->Value
.i
- lpPropRight
->Value
.i
;
461 return lpPropLeft
->Value
.l
- lpPropRight
->Value
.l
;
463 if (lpPropLeft
->Value
.li
.QuadPart
> lpPropRight
->Value
.li
.QuadPart
)
465 if (lpPropLeft
->Value
.li
.QuadPart
== lpPropRight
->Value
.li
.QuadPart
)
469 if (lpPropLeft
->Value
.flt
> lpPropRight
->Value
.flt
)
471 if (lpPropLeft
->Value
.flt
== lpPropRight
->Value
.flt
)
476 if (lpPropLeft
->Value
.dbl
> lpPropRight
->Value
.dbl
)
478 if (lpPropLeft
->Value
.dbl
== lpPropRight
->Value
.dbl
)
482 if (lpPropLeft
->Value
.cur
.int64
> lpPropRight
->Value
.cur
.int64
)
484 if (lpPropLeft
->Value
.cur
.int64
== lpPropRight
->Value
.cur
.int64
)
488 return CompareFileTime(&lpPropLeft
->Value
.ft
, &lpPropRight
->Value
.ft
);
490 return (lpPropLeft
->Value
.b
? 1 : 0) - (lpPropRight
->Value
.b
? 1 : 0);
492 if (lpPropLeft
->Value
.bin
.cb
== lpPropRight
->Value
.bin
.cb
)
493 iRet
= memcmp(lpPropLeft
->Value
.bin
.lpb
, lpPropRight
->Value
.bin
.lpb
,
494 lpPropLeft
->Value
.bin
.cb
);
497 iRet
= memcmp(lpPropLeft
->Value
.bin
.lpb
, lpPropRight
->Value
.bin
.lpb
,
498 min(lpPropLeft
->Value
.bin
.cb
, lpPropRight
->Value
.bin
.cb
));
501 iRet
= lpPropLeft
->Value
.bin
.cb
- lpPropRight
->Value
.bin
.cb
;
505 return lstrcmpA(lpPropLeft
->Value
.lpszA
, lpPropRight
->Value
.lpszA
);
507 return strcmpW(lpPropLeft
->Value
.lpszW
, lpPropRight
->Value
.lpszW
);
509 if (lpPropLeft
->Value
.err
> lpPropRight
->Value
.err
)
511 if (lpPropLeft
->Value
.err
== lpPropRight
->Value
.err
)
515 return memcmp(lpPropLeft
->Value
.lpguid
, lpPropRight
->Value
.lpguid
,
518 FIXME("Unhandled property type %d\n", PROP_TYPE(lpPropLeft
->ulPropTag
));
522 /*************************************************************************
523 * HrGetOneProp@8 (MAPI32.135)
525 * Get a property value from an IMAPIProp object.
528 * lpIProp [I] IMAPIProp object to get the property value in
529 * ulPropTag [I] Property tag of the property to get
530 * lppProp [O] Destination for the returned property
533 * Success: S_OK. *lppProp contains the property value requested.
534 * Failure: MAPI_E_NOT_FOUND, if no property value has the tag given by ulPropTag.
536 HRESULT WINAPI
HrGetOneProp(LPMAPIPROP lpIProp
, ULONG ulPropTag
, LPSPropValue
*lppProp
)
542 TRACE("(%p,%d,%p)\n", lpIProp
, ulPropTag
, lppProp
);
545 pta
.aulPropTag
[0] = ulPropTag
;
546 hRet
= IMAPIProp_GetProps(lpIProp
, &pta
, 0u, &ulCount
, lppProp
);
547 if (hRet
== MAPI_W_ERRORS_RETURNED
)
549 MAPIFreeBuffer(*lppProp
);
551 hRet
= MAPI_E_NOT_FOUND
;
556 /*************************************************************************
557 * HrSetOneProp@8 (MAPI32.136)
559 * Set a property value in an IMAPIProp object.
562 * lpIProp [I] IMAPIProp object to set the property value in
563 * lpProp [I] Property value to set
566 * Success: S_OK. The value in lpProp is set in lpIProp.
567 * Failure: An error result from IMAPIProp_SetProps().
569 HRESULT WINAPI
HrSetOneProp(LPMAPIPROP lpIProp
, LPSPropValue lpProp
)
571 TRACE("(%p,%p)\n", lpIProp
, lpProp
);
573 return IMAPIProp_SetProps(lpIProp
, 1u, lpProp
, NULL
);
576 /*************************************************************************
577 * FPropExists@8 (MAPI32.137)
579 * Find a property with a given property tag in an IMAPIProp object.
582 * lpIProp [I] IMAPIProp object to find the property tag in
583 * ulPropTag [I] Property tag to find
586 * TRUE, if ulPropTag matches a property held in lpIProp,
590 * if ulPropTag has a property type of PT_UNSPECIFIED, then only the property
591 * Ids need to match for a successful match to occur.
593 BOOL WINAPI
FPropExists(LPMAPIPROP lpIProp
, ULONG ulPropTag
)
597 TRACE("(%p,%d)\n", lpIProp
, ulPropTag
);
601 LPSPropTagArray lpTags
;
604 if (FAILED(IMAPIProp_GetPropList(lpIProp
, 0u, &lpTags
)))
607 for (i
= 0; i
< lpTags
->cValues
; i
++)
609 if (!FBadPropTag(lpTags
->aulPropTag
[i
]) &&
610 (lpTags
->aulPropTag
[i
] == ulPropTag
||
611 (PROP_TYPE(ulPropTag
) == PT_UNSPECIFIED
&&
612 PROP_ID(lpTags
->aulPropTag
[i
]) == lpTags
->aulPropTag
[i
])))
618 MAPIFreeBuffer(lpTags
);
623 /*************************************************************************
624 * PpropFindProp@12 (MAPI32.138)
626 * Find a property with a given property tag in a property array.
629 * lpProps [I] Property array to search
630 * cValues [I] Number of properties in lpProps
631 * ulPropTag [I] Property tag to find
634 * A pointer to the matching property, or NULL if none was found.
637 * if ulPropTag has a property type of PT_UNSPECIFIED, then only the property
638 * Ids need to match for a successful match to occur.
640 LPSPropValue WINAPI
PpropFindProp(LPSPropValue lpProps
, ULONG cValues
, ULONG ulPropTag
)
642 TRACE("(%p,%d,%d)\n", lpProps
, cValues
, ulPropTag
);
644 if (lpProps
&& cValues
)
647 for (i
= 0; i
< cValues
; i
++)
649 if (!FBadPropTag(lpProps
[i
].ulPropTag
) &&
650 (lpProps
[i
].ulPropTag
== ulPropTag
||
651 (PROP_TYPE(ulPropTag
) == PT_UNSPECIFIED
&&
652 PROP_ID(lpProps
[i
].ulPropTag
) == PROP_ID(ulPropTag
))))
659 /*************************************************************************
660 * FreePadrlist@4 (MAPI32.139)
662 * Free the memory used by an address book list.
665 * lpAddrs [I] Address book list to free
670 VOID WINAPI
FreePadrlist(LPADRLIST lpAddrs
)
672 TRACE("(%p)\n", lpAddrs
);
674 /* Structures are binary compatible; use the same implementation */
675 FreeProws((LPSRowSet
)lpAddrs
);
678 /*************************************************************************
679 * FreeProws@4 (MAPI32.140)
681 * Free the memory used by a row set.
684 * lpRowSet [I] Row set to free
689 VOID WINAPI
FreeProws(LPSRowSet lpRowSet
)
691 TRACE("(%p)\n", lpRowSet
);
697 for (i
= 0; i
< lpRowSet
->cRows
; i
++)
698 MAPIFreeBuffer(lpRowSet
->aRow
[i
].lpProps
);
700 MAPIFreeBuffer(lpRowSet
);
704 /*************************************************************************
705 * ScCountProps@12 (MAPI32.170)
707 * Validate and determine the length of an array of properties.
710 * iCount [I] Length of the lpProps array
711 * lpProps [I] Array of properties to validate/size
712 * pcBytes [O] If non-NULL, destination for the size of the property array
715 * Success: S_OK. If pcBytes is non-NULL, it contains the size of the
717 * Failure: MAPI_E_INVALID_PARAMETER, if any parameter is invalid or validation
718 * of the property array fails.
720 SCODE WINAPI
ScCountProps(INT iCount
, LPSPropValue lpProps
, ULONG
*pcBytes
)
722 ULONG i
, ulCount
= iCount
, ulBytes
= 0;
724 TRACE("(%d,%p,%p)\n", iCount
, lpProps
, pcBytes
);
726 if (iCount
<= 0 || !lpProps
||
727 IsBadReadPtr(lpProps
, iCount
* sizeof(SPropValue
)))
728 return MAPI_E_INVALID_PARAMETER
;
730 for (i
= 0; i
< ulCount
; i
++)
732 ULONG ulPropSize
= 0;
734 if (FBadProp(&lpProps
[i
]) || lpProps
[i
].ulPropTag
== PROP_ID_NULL
||
735 lpProps
[i
].ulPropTag
== PROP_ID_INVALID
)
736 return MAPI_E_INVALID_PARAMETER
;
738 if (PROP_TYPE(lpProps
[i
].ulPropTag
) != PT_OBJECT
)
740 ulPropSize
= UlPropSize(&lpProps
[i
]);
742 return MAPI_E_INVALID_PARAMETER
;
745 switch (PROP_TYPE(lpProps
[i
].ulPropTag
))
759 ulPropSize
+= sizeof(SPropValue
);
762 ulPropSize
+= lpProps
[i
].Value
.MVszA
.cValues
* sizeof(char*) + sizeof(SPropValue
);
766 ulPropSize
+= lpProps
[i
].Value
.MVszA
.cValues
* sizeof(char*) + sizeof(SPropValue
);
769 ulPropSize
+= lpProps
[i
].Value
.MVbin
.cValues
* sizeof(SBinary
) + sizeof(SPropValue
);
772 ulPropSize
= sizeof(SPropValue
);
775 ulBytes
+= ulPropSize
;
783 /*************************************************************************
784 * ScCopyProps@16 (MAPI32.171)
786 * Copy an array of property values into a buffer suited for serialisation.
789 * cValues [I] Number of properties in lpProps
790 * lpProps [I] Property array to copy
791 * lpDst [O] Destination for the serialised data
792 * lpCount [O] If non-NULL, destination for the number of bytes of data written to lpDst
795 * Success: S_OK. lpDst contains the serialised data from lpProps.
796 * Failure: MAPI_E_INVALID_PARAMETER, if any parameter is invalid.
799 * The resulting property value array is stored in a contiguous block starting at lpDst.
801 SCODE WINAPI
ScCopyProps(int cValues
, LPSPropValue lpProps
, LPVOID lpDst
, ULONG
*lpCount
)
803 LPSPropValue lpDest
= (LPSPropValue
)lpDst
;
804 char *lpDataDest
= (char *)(lpDest
+ cValues
);
808 TRACE("(%d,%p,%p,%p)\n", cValues
, lpProps
, lpDst
, lpCount
);
810 if (!lpProps
|| cValues
< 0 || !lpDest
)
811 return MAPI_E_INVALID_PARAMETER
;
813 memcpy(lpDst
, lpProps
, cValues
* sizeof(SPropValue
));
815 for (iter
= 0; iter
< cValues
; iter
++)
817 switch (PROP_TYPE(lpProps
->ulPropTag
))
820 lpDest
->Value
.lpguid
= (LPGUID
)lpDataDest
;
821 *lpDest
->Value
.lpguid
= *lpProps
->Value
.lpguid
;
822 lpDataDest
+= sizeof(GUID
);
825 ulLen
= lstrlenA(lpProps
->Value
.lpszA
) + 1u;
826 lpDest
->Value
.lpszA
= lpDataDest
;
827 memcpy(lpDest
->Value
.lpszA
, lpProps
->Value
.lpszA
, ulLen
);
831 ulLen
= (strlenW(lpProps
->Value
.lpszW
) + 1u) * sizeof(WCHAR
);
832 lpDest
->Value
.lpszW
= (LPWSTR
)lpDataDest
;
833 memcpy(lpDest
->Value
.lpszW
, lpProps
->Value
.lpszW
, ulLen
);
837 lpDest
->Value
.bin
.lpb
= (LPBYTE
)lpDataDest
;
838 memcpy(lpDest
->Value
.bin
.lpb
, lpProps
->Value
.bin
.lpb
, lpProps
->Value
.bin
.cb
);
839 lpDataDest
+= lpProps
->Value
.bin
.cb
;
842 if (lpProps
->ulPropTag
& MV_FLAG
)
844 lpDest
->Value
.MVi
.cValues
= lpProps
->Value
.MVi
.cValues
;
845 /* Note: Assignment uses lppszA but covers all cases by union aliasing */
846 lpDest
->Value
.MVszA
.lppszA
= (char**)lpDataDest
;
848 switch (PROP_TYPE(lpProps
->ulPropTag
))
852 lpDataDest
+= lpProps
->Value
.MVszA
.cValues
* sizeof(char *);
854 for (i
= 0; i
< lpProps
->Value
.MVszA
.cValues
; i
++)
856 ULONG ulStrLen
= lstrlenA(lpProps
->Value
.MVszA
.lppszA
[i
]) + 1u;
858 lpDest
->Value
.MVszA
.lppszA
[i
] = lpDataDest
;
859 memcpy(lpDataDest
, lpProps
->Value
.MVszA
.lppszA
[i
], ulStrLen
);
860 lpDataDest
+= ulStrLen
;
866 lpDataDest
+= lpProps
->Value
.MVszW
.cValues
* sizeof(WCHAR
*);
868 for (i
= 0; i
< lpProps
->Value
.MVszW
.cValues
; i
++)
870 ULONG ulStrLen
= (strlenW(lpProps
->Value
.MVszW
.lppszW
[i
]) + 1u) * sizeof(WCHAR
);
872 lpDest
->Value
.MVszW
.lppszW
[i
] = (LPWSTR
)lpDataDest
;
873 memcpy(lpDataDest
, lpProps
->Value
.MVszW
.lppszW
[i
], ulStrLen
);
874 lpDataDest
+= ulStrLen
;
880 lpDataDest
+= lpProps
->Value
.MVszW
.cValues
* sizeof(SBinary
);
882 for (i
= 0; i
< lpProps
->Value
.MVszW
.cValues
; i
++)
884 lpDest
->Value
.MVbin
.lpbin
[i
].cb
= lpProps
->Value
.MVbin
.lpbin
[i
].cb
;
885 lpDest
->Value
.MVbin
.lpbin
[i
].lpb
= (LPBYTE
)lpDataDest
;
886 memcpy(lpDataDest
, lpProps
->Value
.MVbin
.lpbin
[i
].lpb
, lpDest
->Value
.MVbin
.lpbin
[i
].cb
);
887 lpDataDest
+= lpDest
->Value
.MVbin
.lpbin
[i
].cb
;
892 /* No embedded pointers, just copy the data over */
893 ulLen
= UlPropSize(lpProps
);
894 memcpy(lpDest
->Value
.MVi
.lpi
, lpProps
->Value
.MVi
.lpi
, ulLen
);
905 *lpCount
= lpDataDest
- (char *)lpDst
;
910 /*************************************************************************
911 * ScRelocProps@20 (MAPI32.172)
913 * Relocate the pointers in an array of property values after it has been copied.
916 * cValues [I] Number of properties in lpProps
917 * lpProps [O] Property array to relocate the pointers in.
918 * lpOld [I] Position where the data was copied from
919 * lpNew [I] Position where the data was copied to
920 * lpCount [O] If non-NULL, destination for the number of bytes of data at lpDst
923 * Success: S_OK. Any pointers in lpProps are relocated.
924 * Failure: MAPI_E_INVALID_PARAMETER, if any parameter is invalid.
927 * MSDN states that this function can be used for serialisation by passing
928 * NULL as either lpOld or lpNew, thus converting any pointers in lpProps
929 * between offsets and pointers. This does not work in native (it crashes),
930 * and cannot be made to work in Wine because the original interface design
931 * is deficient. The only use left for this function is to remap pointers
932 * in a contiguous property array that has been copied with memcpy() to
933 * another memory location.
935 SCODE WINAPI
ScRelocProps(int cValues
, LPSPropValue lpProps
, LPVOID lpOld
,
936 LPVOID lpNew
, ULONG
*lpCount
)
938 static const BOOL bBadPtr
= TRUE
; /* Windows bug - Assumes source is bad */
939 LPSPropValue lpDest
= lpProps
;
940 ULONG ulCount
= cValues
* sizeof(SPropValue
);
944 TRACE("(%d,%p,%p,%p,%p)\n", cValues
, lpProps
, lpOld
, lpNew
, lpCount
);
946 if (!lpProps
|| cValues
< 0 || !lpOld
|| !lpNew
)
947 return MAPI_E_INVALID_PARAMETER
;
949 /* The reason native doesn't work as MSDN states is that it assumes that
950 * the lpProps pointer contains valid pointers. This is obviously not
951 * true if the array is being read back from serialisation (the pointers
952 * are just offsets). Native can't actually work converting the pointers to
953 * offsets either, because it converts any array pointers to offsets then
954 * _dereferences the offset_ in order to convert the array elements!
956 * The code below would handle both cases except that the design of this
957 * function makes it impossible to know when the pointers in lpProps are
958 * valid. If both lpOld and lpNew are non-NULL, native reads the pointers
959 * after converting them, so we must do the same. It seems this
960 * functionality was never tested by MS.
963 #define RELOC_PTR(p) (((char*)(p)) - (char*)lpOld + (char*)lpNew)
965 for (iter
= 0; iter
< cValues
; iter
++)
967 switch (PROP_TYPE(lpDest
->ulPropTag
))
970 lpDest
->Value
.lpguid
= (LPGUID
)RELOC_PTR(lpDest
->Value
.lpguid
);
971 ulCount
+= sizeof(GUID
);
974 ulLen
= bBadPtr
? 0 : lstrlenA(lpDest
->Value
.lpszA
) + 1u;
975 lpDest
->Value
.lpszA
= RELOC_PTR(lpDest
->Value
.lpszA
);
977 ulLen
= lstrlenA(lpDest
->Value
.lpszA
) + 1u;
981 ulLen
= bBadPtr
? 0 : (lstrlenW(lpDest
->Value
.lpszW
) + 1u) * sizeof(WCHAR
);
982 lpDest
->Value
.lpszW
= (LPWSTR
)RELOC_PTR(lpDest
->Value
.lpszW
);
984 ulLen
= (strlenW(lpDest
->Value
.lpszW
) + 1u) * sizeof(WCHAR
);
988 lpDest
->Value
.bin
.lpb
= (LPBYTE
)RELOC_PTR(lpDest
->Value
.bin
.lpb
);
989 ulCount
+= lpDest
->Value
.bin
.cb
;
992 if (lpDest
->ulPropTag
& MV_FLAG
)
994 /* Since we have to access the array elements, don't map the
995 * array unless it is invalid (otherwise, map it at the end)
998 lpDest
->Value
.MVszA
.lppszA
= (LPSTR
*)RELOC_PTR(lpDest
->Value
.MVszA
.lppszA
);
1000 switch (PROP_TYPE(lpProps
->ulPropTag
))
1004 ulCount
+= lpDest
->Value
.MVszA
.cValues
* sizeof(char *);
1006 for (i
= 0; i
< lpDest
->Value
.MVszA
.cValues
; i
++)
1008 ULONG ulStrLen
= bBadPtr
? 0 : lstrlenA(lpDest
->Value
.MVszA
.lppszA
[i
]) + 1u;
1010 lpDest
->Value
.MVszA
.lppszA
[i
] = RELOC_PTR(lpDest
->Value
.MVszA
.lppszA
[i
]);
1012 ulStrLen
= lstrlenA(lpDest
->Value
.MVszA
.lppszA
[i
]) + 1u;
1013 ulCount
+= ulStrLen
;
1019 ulCount
+= lpDest
->Value
.MVszW
.cValues
* sizeof(WCHAR
*);
1021 for (i
= 0; i
< lpDest
->Value
.MVszW
.cValues
; i
++)
1023 ULONG ulStrLen
= bBadPtr
? 0 : (strlenW(lpDest
->Value
.MVszW
.lppszW
[i
]) + 1u) * sizeof(WCHAR
);
1025 lpDest
->Value
.MVszW
.lppszW
[i
] = (LPWSTR
)RELOC_PTR(lpDest
->Value
.MVszW
.lppszW
[i
]);
1027 ulStrLen
= (strlenW(lpDest
->Value
.MVszW
.lppszW
[i
]) + 1u) * sizeof(WCHAR
);
1028 ulCount
+= ulStrLen
;
1034 ulCount
+= lpDest
->Value
.MVszW
.cValues
* sizeof(SBinary
);
1036 for (i
= 0; i
< lpDest
->Value
.MVszW
.cValues
; i
++)
1038 lpDest
->Value
.MVbin
.lpbin
[i
].lpb
= (LPBYTE
)RELOC_PTR(lpDest
->Value
.MVbin
.lpbin
[i
].lpb
);
1039 ulCount
+= lpDest
->Value
.MVbin
.lpbin
[i
].cb
;
1044 ulCount
+= UlPropSize(lpDest
);
1048 lpDest
->Value
.MVszA
.lppszA
= (LPSTR
*)RELOC_PTR(lpDest
->Value
.MVszA
.lppszA
);
1060 /*************************************************************************
1061 * LpValFindProp@12 (MAPI32.173)
1063 * Find a property with a given property id in a property array.
1066 * ulPropTag [I] Property tag containing property id to find
1067 * cValues [I] Number of properties in lpProps
1068 * lpProps [I] Property array to search
1071 * A pointer to the matching property, or NULL if none was found.
1074 * This function matches only on the property id and does not care if the
1075 * property types differ.
1077 LPSPropValue WINAPI
LpValFindProp(ULONG ulPropTag
, ULONG cValues
, LPSPropValue lpProps
)
1079 TRACE("(%d,%d,%p)\n", ulPropTag
, cValues
, lpProps
);
1081 if (lpProps
&& cValues
)
1084 for (i
= 0; i
< cValues
; i
++)
1086 if (PROP_ID(ulPropTag
) == PROP_ID(lpProps
[i
].ulPropTag
))
1093 /*************************************************************************
1094 * ScDupPropset@16 (MAPI32.174)
1096 * Duplicate a property value array into a contiguous block of memory.
1099 * cValues [I] Number of properties in lpProps
1100 * lpProps [I] Property array to duplicate
1101 * lpAlloc [I] Memory allocation function, use MAPIAllocateBuffer()
1102 * lpNewProp [O] Destination for the newly duplicated property value array
1105 * Success: S_OK. *lpNewProp contains the duplicated array.
1106 * Failure: MAPI_E_INVALID_PARAMETER, if any parameter is invalid,
1107 * MAPI_E_NOT_ENOUGH_MEMORY, if memory allocation fails.
1109 SCODE WINAPI
ScDupPropset(int cValues
, LPSPropValue lpProps
,
1110 LPALLOCATEBUFFER lpAlloc
, LPSPropValue
*lpNewProp
)
1115 TRACE("(%d,%p,%p,%p)\n", cValues
, lpProps
, lpAlloc
, lpNewProp
);
1117 sc
= ScCountProps(cValues
, lpProps
, &ulCount
);
1120 sc
= lpAlloc(ulCount
, (LPVOID
*)lpNewProp
);
1122 sc
= ScCopyProps(cValues
, lpProps
, *lpNewProp
, &ulCount
);
1127 /*************************************************************************
1128 * FBadRglpszA@8 (MAPI32.175)
1130 * Determine if an array of strings is invalid
1133 * lppszStrs [I] Array of strings to check
1134 * ulCount [I] Number of strings in lppszStrs
1137 * TRUE, if lppszStrs is invalid, FALSE otherwise.
1139 BOOL WINAPI
FBadRglpszA(LPSTR
*lppszStrs
, ULONG ulCount
)
1143 TRACE("(%p,%d)\n", lppszStrs
, ulCount
);
1148 if (!lppszStrs
|| IsBadReadPtr(lppszStrs
, ulCount
* sizeof(LPWSTR
)))
1151 for (i
= 0; i
< ulCount
; i
++)
1153 if (!lppszStrs
[i
] || IsBadStringPtrA(lppszStrs
[i
], -1))
1159 /*************************************************************************
1160 * FBadRglpszW@8 (MAPI32.176)
1164 BOOL WINAPI
FBadRglpszW(LPWSTR
*lppszStrs
, ULONG ulCount
)
1168 TRACE("(%p,%d)\n", lppszStrs
, ulCount
);
1173 if (!lppszStrs
|| IsBadReadPtr(lppszStrs
, ulCount
* sizeof(LPWSTR
)))
1176 for (i
= 0; i
< ulCount
; i
++)
1178 if (!lppszStrs
[i
] || IsBadStringPtrW(lppszStrs
[i
], -1))
1184 /*************************************************************************
1185 * FBadRowSet@4 (MAPI32.177)
1187 * Determine if a row is invalid
1190 * lpRow [I] Row to check
1193 * TRUE, if lpRow is invalid, FALSE otherwise.
1195 BOOL WINAPI
FBadRowSet(LPSRowSet lpRowSet
)
1198 TRACE("(%p)\n", lpRowSet
);
1200 if (!lpRowSet
|| IsBadReadPtr(lpRowSet
, CbSRowSet(lpRowSet
)))
1203 for (i
= 0; i
< lpRowSet
->cRows
; i
++)
1205 if (FBadRow(&lpRowSet
->aRow
[i
]))
1211 /*************************************************************************
1212 * FBadPropTag@4 (MAPI32.179)
1214 * Determine if a property tag is invalid
1217 * ulPropTag [I] Property tag to check
1220 * TRUE, if ulPropTag is invalid, FALSE otherwise.
1222 ULONG WINAPI
FBadPropTag(ULONG ulPropTag
)
1224 TRACE("(0x%08x)\n", ulPropTag
);
1226 switch (ulPropTag
& (~MV_FLAG
& PROP_TYPE_MASK
))
1228 case PT_UNSPECIFIED
:
1250 /*************************************************************************
1251 * FBadRow@4 (MAPI32.180)
1253 * Determine if a row is invalid
1256 * lpRow [I] Row to check
1259 * TRUE, if lpRow is invalid, FALSE otherwise.
1261 ULONG WINAPI
FBadRow(LPSRow lpRow
)
1264 TRACE("(%p)\n", lpRow
);
1266 if (!lpRow
|| IsBadReadPtr(lpRow
, sizeof(SRow
)) || !lpRow
->lpProps
||
1267 IsBadReadPtr(lpRow
->lpProps
, lpRow
->cValues
* sizeof(SPropValue
)))
1270 for (i
= 0; i
< lpRow
->cValues
; i
++)
1272 if (FBadProp(&lpRow
->lpProps
[i
]))
1278 /*************************************************************************
1279 * FBadProp@4 (MAPI32.181)
1281 * Determine if a property is invalid
1284 * lpProp [I] Property to check
1287 * TRUE, if lpProp is invalid, FALSE otherwise.
1289 ULONG WINAPI
FBadProp(LPSPropValue lpProp
)
1291 if (!lpProp
|| IsBadReadPtr(lpProp
, sizeof(SPropValue
)) ||
1292 FBadPropTag(lpProp
->ulPropTag
))
1295 switch (PROP_TYPE(lpProp
->ulPropTag
))
1297 /* Single value properties containing pointers */
1299 if (!lpProp
->Value
.lpszA
|| IsBadStringPtrA(lpProp
->Value
.lpszA
, -1))
1303 if (!lpProp
->Value
.lpszW
|| IsBadStringPtrW(lpProp
->Value
.lpszW
, -1))
1307 if (IsBadReadPtr(lpProp
->Value
.bin
.lpb
, lpProp
->Value
.bin
.cb
))
1311 if (IsBadReadPtr(lpProp
->Value
.lpguid
, sizeof(GUID
)))
1315 /* Multiple value properties (arrays) containing no pointers */
1317 return PROP_BadArray(lpProp
, sizeof(SHORT
));
1319 return PROP_BadArray(lpProp
, sizeof(LONG
));
1320 case PT_MV_LONGLONG
:
1321 return PROP_BadArray(lpProp
, sizeof(LONG64
));
1323 return PROP_BadArray(lpProp
, sizeof(float));
1325 return PROP_BadArray(lpProp
, sizeof(FILETIME
));
1328 return PROP_BadArray(lpProp
, sizeof(double));
1329 case PT_MV_CURRENCY
:
1330 return PROP_BadArray(lpProp
, sizeof(CY
));
1332 return PROP_BadArray(lpProp
, sizeof(GUID
));
1334 /* Multiple value properties containing pointers */
1336 return FBadRglpszA(lpProp
->Value
.MVszA
.lppszA
,
1337 lpProp
->Value
.MVszA
.cValues
);
1339 return FBadRglpszW(lpProp
->Value
.MVszW
.lppszW
,
1340 lpProp
->Value
.MVszW
.cValues
);
1342 return FBadEntryList(&lpProp
->Value
.MVbin
);
1347 /*************************************************************************
1348 * FBadColumnSet@4 (MAPI32.182)
1350 * Determine if an array of property tags is invalid
1353 * lpCols [I] Property tag array to check
1356 * TRUE, if lpCols is invalid, FALSE otherwise.
1358 ULONG WINAPI
FBadColumnSet(LPSPropTagArray lpCols
)
1360 ULONG ulRet
= FALSE
, i
;
1362 TRACE("(%p)\n", lpCols
);
1364 if (!lpCols
|| IsBadReadPtr(lpCols
, CbSPropTagArray(lpCols
)))
1368 for (i
= 0; i
< lpCols
->cValues
; i
++)
1370 if ((lpCols
->aulPropTag
[i
] & PROP_TYPE_MASK
) == PT_ERROR
||
1371 FBadPropTag(lpCols
->aulPropTag
[i
]))
1378 TRACE("Returning %s\n", ulRet
? "TRUE" : "FALSE");
1383 /**************************************************************************
1384 * IPropData {MAPI32}
1386 * A default Mapi interface to provide manipulation of object properties.
1389 * This object provides a default interface suitable in some cases as an
1390 * implementation of the IMAPIProp interface (which has no default
1391 * implementation). In addition to the IMAPIProp() methods inherited, this
1392 * interface allows read/write control over access to the object and its
1393 * individual properties.
1395 * To obtain the default implementation of this interface from Mapi, call
1401 /* A single property in a property data collection */
1405 ULONG ulAccess
; /* The property value access level */
1406 LPSPropValue value
; /* The property value */
1407 } IPropDataItem
, *LPIPropDataItem
;
1409 /* The main property data collection structure */
1412 IPropData IPropData_iface
;
1413 LONG lRef
; /* Reference count */
1414 ALLOCATEBUFFER
*lpAlloc
; /* Memory allocation routine */
1415 ALLOCATEMORE
*lpMore
; /* Linked memory allocation routine */
1416 FREEBUFFER
*lpFree
; /* Memory free routine */
1417 ULONG ulObjAccess
; /* Object access level */
1418 ULONG ulNumValues
; /* Number of items in values list */
1419 struct list values
; /* List of property values */
1420 CRITICAL_SECTION cs
; /* Lock for thread safety */
1423 static inline IPropDataImpl
*impl_from_IPropData(IPropData
*iface
)
1425 return CONTAINING_RECORD(iface
, IPropDataImpl
, IPropData_iface
);
1428 /* Internal - Get a property value, assumes lock is held */
1429 static IPropDataItem
*IMAPIPROP_GetValue(IPropDataImpl
*This
, ULONG ulPropTag
)
1431 struct list
*cursor
;
1433 LIST_FOR_EACH(cursor
, &This
->values
)
1435 LPIPropDataItem current
= LIST_ENTRY(cursor
, IPropDataItem
, entry
);
1436 /* Note that property types don't have to match, just Id's */
1437 if (PROP_ID(current
->value
->ulPropTag
) == PROP_ID(ulPropTag
))
1443 /* Internal - Add a new property value, assumes lock is held */
1444 static IPropDataItem
*IMAPIPROP_AddValue(IPropDataImpl
*This
,
1445 LPSPropValue lpProp
)
1448 LPIPropDataItem lpNew
;
1451 hRet
= This
->lpAlloc(sizeof(IPropDataItem
), &lpMem
);
1453 if (SUCCEEDED(hRet
))
1456 lpNew
->ulAccess
= IPROP_READWRITE
;
1458 /* Allocate the value separately so we can update it easily */
1460 hRet
= This
->lpAlloc(sizeof(SPropValue
), &lpMem
);
1461 if (SUCCEEDED(hRet
))
1463 lpNew
->value
= lpMem
;
1465 hRet
= PropCopyMore(lpNew
->value
, lpProp
, This
->lpMore
, lpMem
);
1466 if (SUCCEEDED(hRet
))
1468 list_add_tail(&This
->values
, &lpNew
->entry
);
1469 This
->ulNumValues
++;
1472 This
->lpFree(lpNew
->value
);
1474 This
->lpFree(lpNew
);
1479 /* Internal - Lock an IPropData object */
1480 static inline void IMAPIPROP_Lock(IPropDataImpl
*This
)
1482 EnterCriticalSection(&This
->cs
);
1485 /* Internal - Unlock an IPropData object */
1486 static inline void IMAPIPROP_Unlock(IPropDataImpl
*This
)
1488 LeaveCriticalSection(&This
->cs
);
1491 /* This one seems to be missing from mapidefs.h */
1492 #define CbNewSPropProblemArray(c) \
1493 (offsetof(SPropProblemArray,aProblem)+(c)*sizeof(SPropProblem))
1495 /**************************************************************************
1496 * IPropData_QueryInterface {MAPI32}
1498 * Inherited method from the IUnknown Interface.
1499 * See IUnknown_QueryInterface.
1501 static WINAPI HRESULT
IPropData_fnQueryInterface(LPPROPDATA iface
, REFIID riid
, LPVOID
*ppvObj
)
1503 IPropDataImpl
*This
= impl_from_IPropData(iface
);
1505 TRACE("(%p,%s,%p)\n", This
, debugstr_guid(riid
), ppvObj
);
1507 if (!ppvObj
|| !riid
)
1508 return MAPI_E_INVALID_PARAMETER
;
1512 if(IsEqualIID(riid
, &IID_IUnknown
) ||
1513 IsEqualIID(riid
, &IID_IMAPIProp
) ||
1514 IsEqualIID(riid
, &IID_IMAPIPropData
))
1517 IPropData_AddRef(iface
);
1518 TRACE("returning %p\n", *ppvObj
);
1522 TRACE("returning E_NOINTERFACE\n");
1523 return MAPI_E_INTERFACE_NOT_SUPPORTED
;
1526 /**************************************************************************
1527 * IPropData_AddRef {MAPI32}
1529 * Inherited method from the IUnknown Interface.
1530 * See IUnknown_AddRef.
1532 static ULONG WINAPI
IPropData_fnAddRef(LPPROPDATA iface
)
1534 IPropDataImpl
*This
= impl_from_IPropData(iface
);
1536 TRACE("(%p)->(count before=%u)\n", This
, This
->lRef
);
1538 return InterlockedIncrement(&This
->lRef
);
1541 /**************************************************************************
1542 * IPropData_Release {MAPI32}
1544 * Inherited method from the IUnknown Interface.
1545 * See IUnknown_Release.
1547 static ULONG WINAPI
IPropData_fnRelease(LPPROPDATA iface
)
1549 IPropDataImpl
*This
= impl_from_IPropData(iface
);
1552 TRACE("(%p)->(count before=%u)\n", This
, This
->lRef
);
1554 lRef
= InterlockedDecrement(&This
->lRef
);
1557 TRACE("Destroying IPropData (%p)\n",This
);
1559 /* Note: No need to lock, since no other thread is referencing iface */
1560 while (!list_empty(&This
->values
))
1562 struct list
*head
= list_head(&This
->values
);
1563 LPIPropDataItem current
= LIST_ENTRY(head
, IPropDataItem
, entry
);
1565 This
->lpFree(current
->value
);
1566 This
->lpFree(current
);
1568 This
->cs
.DebugInfo
->Spare
[0] = 0;
1569 DeleteCriticalSection(&This
->cs
);
1575 /**************************************************************************
1576 * IPropData_GetLastError {MAPI32}
1578 * Get information about the last error that occurred in an IMAPIProp object.
1581 * iface [I] IMAPIProp object that experienced the error
1582 * hRes [I] Result of the call that returned an error
1583 * ulFlags [I] 0=return Ascii strings, MAPI_UNICODE=return Unicode strings
1584 * lppError [O] Destination for detailed error information
1587 * Success: S_OK. *lppError contains details about the last error.
1588 * Failure: MAPI_E_INVALID_PARAMETER, if any parameter is invalid,
1589 * MAPI_E_NOT_ENOUGH_MEMORY, if memory allocation fails.
1592 * - If this function succeeds, the returned information in *lppError must be
1593 * freed using MAPIFreeBuffer() once the caller is finished with it.
1594 * - It is possible for this function to succeed and set *lppError to NULL,
1595 * if there is no further information to report about hRes.
1597 static HRESULT WINAPI
IPropData_fnGetLastError(LPPROPDATA iface
, HRESULT hRes
, ULONG ulFlags
,
1598 LPMAPIERROR
*lppError
)
1600 TRACE("(%p,0x%08X,0x%08X,%p)\n", iface
, hRes
, ulFlags
, lppError
);
1602 if (!lppError
|| SUCCEEDED(hRes
) || (ulFlags
& ~MAPI_UNICODE
))
1603 return MAPI_E_INVALID_PARAMETER
;
1609 /**************************************************************************
1610 * IPropData_SaveChanges {MAPI32}
1612 * Update any changes made to a transactional IMAPIProp object.
1615 * iface [I] IMAPIProp object to update
1616 * ulFlags [I] Flags controlling the update.
1619 * Success: S_OK. Any outstanding changes are committed to the object.
1620 * Failure: An HRESULT error code describing the error.
1622 static HRESULT WINAPI
IPropData_fnSaveChanges(LPPROPDATA iface
, ULONG ulFlags
)
1624 TRACE("(%p,0x%08X)\n", iface
, ulFlags
);
1626 /* Since this object is not transacted we do not need to implement this */
1627 /* FIXME: Should we set the access levels to clean? */
1631 /**************************************************************************
1632 * IPropData_GetProps {MAPI32}
1634 * Get property values from an IMAPIProp object.
1637 * iface [I] IMAPIProp object to get the property values from
1638 * lpTags [I] Property tage of property values to be retrieved
1639 * ulFlags [I] Return 0=Ascii MAPI_UNICODE=Unicode strings for
1641 * lpCount [O] Destination for number of properties returned
1642 * lppProps [O] Destination for returned property values
1645 * Success: S_OK. *lppProps and *lpCount are updated.
1646 * Failure: MAPI_E_INVALID_PARAMETER, if any parameter is invalid.
1647 * MAPI_E_NOT_ENOUGH_MEMORY, if memory allocation fails, or
1648 * MAPI_W_ERRORS_RETURNED if not all properties were retrieved
1651 * - If MAPI_W_ERRORS_RETURNED is returned, any properties that could not be
1652 * retrieved from iface are present in lppProps with their type
1653 * changed to PT_ERROR and Id unchanged.
1655 static HRESULT WINAPI
IPropData_fnGetProps(LPPROPDATA iface
, LPSPropTagArray lpTags
, ULONG ulFlags
,
1656 ULONG
*lpCount
, LPSPropValue
*lppProps
)
1658 IPropDataImpl
*This
= impl_from_IPropData(iface
);
1660 HRESULT hRet
= S_OK
;
1662 TRACE("(%p,%p,0x%08x,%p,%p) stub\n", iface
, lpTags
, ulFlags
,
1665 if (!iface
|| ulFlags
& ~MAPI_UNICODE
|| !lpTags
|| *lpCount
|| !lppProps
)
1666 return MAPI_E_INVALID_PARAMETER
;
1668 FIXME("semi-stub, flags not supported\n");
1670 *lpCount
= lpTags
->cValues
;
1675 hRet
= MAPIAllocateBuffer(*lpCount
* sizeof(SPropValue
), (LPVOID
*)lppProps
);
1679 IMAPIPROP_Lock(This
);
1681 for (i
= 0; i
< lpTags
->cValues
; i
++)
1683 HRESULT hRetTmp
= E_INVALIDARG
;
1684 LPIPropDataItem item
;
1686 item
= IMAPIPROP_GetValue(This
, lpTags
->aulPropTag
[i
]);
1689 hRetTmp
= PropCopyMore(&(*lppProps
)[i
], item
->value
,
1690 This
->lpMore
, *lppProps
);
1691 if (FAILED(hRetTmp
))
1693 hRet
= MAPI_W_ERRORS_RETURNED
;
1694 (*lppProps
)[i
].ulPropTag
=
1695 CHANGE_PROP_TYPE(lpTags
->aulPropTag
[i
], PT_ERROR
);
1699 IMAPIPROP_Unlock(This
);
1704 /**************************************************************************
1705 * MAPIProp_GetPropList {MAPI32}
1707 * Get the list of property tags for all values in an IMAPIProp object.
1710 * iface [I] IMAPIProp object to get the property tag list from
1711 * ulFlags [I] Return 0=Ascii MAPI_UNICODE=Unicode strings for
1713 * lppTags [O] Destination for the retrieved property tag list
1716 * Success: S_OK. *lppTags contains the tags for all available properties.
1717 * Failure: MAPI_E_INVALID_PARAMETER, if any parameter is invalid.
1718 * MAPI_E_BAD_CHARWIDTH, if Ascii or Unicode strings are requested
1719 * and that type of string is not supported.
1721 static HRESULT WINAPI
IPropData_fnGetPropList(LPPROPDATA iface
, ULONG ulFlags
,
1722 LPSPropTagArray
*lppTags
)
1724 IPropDataImpl
*This
= impl_from_IPropData(iface
);
1728 TRACE("(%p,0x%08x,%p) stub\n", iface
, ulFlags
, lppTags
);
1730 if (!iface
|| ulFlags
& ~MAPI_UNICODE
|| !lppTags
)
1731 return MAPI_E_INVALID_PARAMETER
;
1733 FIXME("semi-stub, flags not supported\n");
1737 IMAPIPROP_Lock(This
);
1739 hRet
= MAPIAllocateBuffer(CbNewSPropTagArray(This
->ulNumValues
),
1741 if (SUCCEEDED(hRet
))
1743 struct list
*cursor
;
1746 LIST_FOR_EACH(cursor
, &This
->values
)
1748 LPIPropDataItem current
= LIST_ENTRY(cursor
, IPropDataItem
, entry
);
1749 (*lppTags
)->aulPropTag
[i
] = current
->value
->ulPropTag
;
1752 (*lppTags
)->cValues
= This
->ulNumValues
;
1755 IMAPIPROP_Unlock(This
);
1759 /**************************************************************************
1760 * IPropData_OpenProperty {MAPI32}
1762 * Not documented at this time.
1765 * An HRESULT success/failure code.
1767 static HRESULT WINAPI
IPropData_fnOpenProperty(LPPROPDATA iface
, ULONG ulPropTag
, LPCIID iid
,
1768 ULONG ulOpts
, ULONG ulFlags
, LPUNKNOWN
*lpUnk
)
1770 FIXME("(%p,%u,%s,%u,0x%08x,%p) stub\n", iface
, ulPropTag
,
1771 debugstr_guid(iid
), ulOpts
, ulFlags
, lpUnk
);
1772 return MAPI_E_NO_SUPPORT
;
1776 /**************************************************************************
1777 * IPropData_SetProps {MAPI32}
1779 * Add or edit the property values in an IMAPIProp object.
1782 * iface [I] IMAPIProp object to get the property tag list from
1783 * ulValues [I] Number of properties in lpProps
1784 * lpProps [I] Property values to set
1785 * lppProbs [O] Optional destination for any problems that occurred
1788 * Success: S_OK. The properties in lpProps are added to iface if they don't
1789 * exist, or changed to the values in lpProps if they do
1790 * Failure: An HRESULT error code describing the error
1792 static HRESULT WINAPI
IPropData_fnSetProps(LPPROPDATA iface
, ULONG ulValues
, LPSPropValue lpProps
,
1793 LPSPropProblemArray
*lppProbs
)
1795 IPropDataImpl
*This
= impl_from_IPropData(iface
);
1796 HRESULT hRet
= S_OK
;
1799 TRACE("(%p,%u,%p,%p)\n", iface
, ulValues
, lpProps
, lppProbs
);
1801 if (!iface
|| !lpProps
)
1802 return MAPI_E_INVALID_PARAMETER
;
1804 for (i
= 0; i
< ulValues
; i
++)
1806 if (FBadProp(&lpProps
[i
]) ||
1807 PROP_TYPE(lpProps
[i
].ulPropTag
) == PT_OBJECT
||
1808 PROP_TYPE(lpProps
[i
].ulPropTag
) == PT_NULL
)
1809 return MAPI_E_INVALID_PARAMETER
;
1812 IMAPIPROP_Lock(This
);
1814 /* FIXME: Under what circumstances is lpProbs created? */
1815 for (i
= 0; i
< ulValues
; i
++)
1817 LPIPropDataItem item
= IMAPIPROP_GetValue(This
, lpProps
[i
].ulPropTag
);
1822 LPVOID lpMem
= NULL
;
1824 /* Found, so update the existing value */
1825 if (item
->value
->ulPropTag
!= lpProps
[i
].ulPropTag
)
1826 FIXME("semi-stub, overwriting type (not coercing)\n");
1828 hRetTmp
= This
->lpAlloc(sizeof(SPropValue
), &lpMem
);
1829 if (SUCCEEDED(hRetTmp
))
1831 hRetTmp
= PropCopyMore(lpMem
, &lpProps
[i
], This
->lpMore
, lpMem
);
1832 if (SUCCEEDED(hRetTmp
))
1834 This
->lpFree(item
->value
);
1835 item
->value
= lpMem
;
1838 This
->lpFree(lpMem
);
1845 if (!IMAPIPROP_AddValue(This
, &lpProps
[i
]))
1846 hRet
= MAPI_E_NOT_ENOUGH_MEMORY
;
1850 IMAPIPROP_Unlock(This
);
1854 /**************************************************************************
1855 * IPropData_DeleteProps {MAPI32}
1857 * Delete one or more property values from an IMAPIProp object.
1860 * iface [I] IMAPIProp object to remove property values from.
1861 * lpTags [I] Collection of property Id's to remove from iface.
1862 * lppProbs [O] Destination for problems encountered, if any.
1865 * Success: S_OK. Any properties in iface matching property Id's in lpTags have
1866 * been deleted. If lppProbs is non-NULL it contains details of any
1867 * errors that occurred.
1868 * Failure: MAPI_E_INVALID_PARAMETER, if any parameter is invalid.
1869 * E_ACCESSDENIED, if this object was created using CreateIProp() and
1870 * a subsequent call to IPropData_SetObjAccess() was made specifying
1871 * IPROP_READONLY as the access type.
1874 * - lppProbs will not be populated for cases where a property Id is present
1875 * in lpTags but not in iface.
1876 * - lppProbs should be deleted with MAPIFreeBuffer() if returned.
1878 static HRESULT WINAPI
IPropData_fnDeleteProps(LPPROPDATA iface
, LPSPropTagArray lpTags
,
1879 LPSPropProblemArray
*lppProbs
)
1881 IPropDataImpl
*This
= impl_from_IPropData(iface
);
1882 ULONG i
, numProbs
= 0;
1883 HRESULT hRet
= S_OK
;
1885 TRACE("(%p,%p,%p)\n", iface
, lpTags
, lppProbs
);
1887 if (!iface
|| !lpTags
)
1888 return MAPI_E_INVALID_PARAMETER
;
1893 for (i
= 0; i
< lpTags
->cValues
; i
++)
1895 if (FBadPropTag(lpTags
->aulPropTag
[i
]) ||
1896 PROP_TYPE(lpTags
->aulPropTag
[i
]) == PT_OBJECT
||
1897 PROP_TYPE(lpTags
->aulPropTag
[i
]) == PT_NULL
)
1898 return MAPI_E_INVALID_PARAMETER
;
1901 IMAPIPROP_Lock(This
);
1903 if (This
->ulObjAccess
!= IPROP_READWRITE
)
1905 IMAPIPROP_Unlock(This
);
1906 return E_ACCESSDENIED
;
1909 for (i
= 0; i
< lpTags
->cValues
; i
++)
1911 LPIPropDataItem item
= IMAPIPROP_GetValue(This
, lpTags
->aulPropTag
[i
]);
1915 if (item
->ulAccess
& IPROP_READWRITE
)
1917 /* Everything hunky-dory, remove the item */
1918 list_remove(&item
->entry
);
1919 This
->lpFree(item
->value
); /* Also frees value pointers */
1921 This
->ulNumValues
--;
1925 /* Can't write the value. Create/populate problems array */
1928 /* Create problems array */
1929 ULONG ulSize
= CbNewSPropProblemArray(lpTags
->cValues
- i
);
1930 HRESULT hRetTmp
= MAPIAllocateBuffer(ulSize
, (LPVOID
*)lppProbs
);
1931 if (FAILED(hRetTmp
))
1936 LPSPropProblem lpProb
= &(*lppProbs
)->aProblem
[numProbs
];
1937 lpProb
->ulIndex
= i
;
1938 lpProb
->ulPropTag
= lpTags
->aulPropTag
[i
];
1939 lpProb
->scode
= E_ACCESSDENIED
;
1945 if (lppProbs
&& *lppProbs
)
1946 (*lppProbs
)->cProblem
= numProbs
;
1948 IMAPIPROP_Unlock(This
);
1953 /**************************************************************************
1954 * IPropData_CopyTo {MAPI32}
1956 * Not documented at this time.
1959 * An HRESULT success/failure code.
1961 static HRESULT WINAPI
IPropData_fnCopyTo(LPPROPDATA iface
, ULONG niids
, LPCIID lpiidExcl
,
1962 LPSPropTagArray lpPropsExcl
, ULONG ulParam
,
1963 LPMAPIPROGRESS lpIProgress
, LPCIID lpIfaceIid
,
1964 LPVOID lpDstObj
, ULONG ulFlags
,
1965 LPSPropProblemArray
*lppProbs
)
1967 FIXME("(%p,%u,%p,%p,%x,%p,%s,%p,0x%08X,%p) stub\n", iface
, niids
,
1968 lpiidExcl
, lpPropsExcl
, ulParam
, lpIProgress
,
1969 debugstr_guid(lpIfaceIid
), lpDstObj
, ulFlags
, lppProbs
);
1970 return MAPI_E_NO_SUPPORT
;
1973 /**************************************************************************
1974 * IPropData_CopyProps {MAPI32}
1976 * Not documented at this time.
1979 * An HRESULT success/failure code.
1981 static HRESULT WINAPI
IPropData_fnCopyProps(LPPROPDATA iface
, LPSPropTagArray lpInclProps
,
1982 ULONG ulParam
, LPMAPIPROGRESS lpIProgress
,
1983 LPCIID lpIface
, LPVOID lpDstObj
, ULONG ulFlags
,
1984 LPSPropProblemArray
*lppProbs
)
1986 FIXME("(%p,%p,%x,%p,%s,%p,0x%08X,%p) stub\n", iface
, lpInclProps
,
1987 ulParam
, lpIProgress
, debugstr_guid(lpIface
), lpDstObj
, ulFlags
,
1989 return MAPI_E_NO_SUPPORT
;
1992 /**************************************************************************
1993 * IPropData_GetNamesFromIDs {MAPI32}
1995 * Get the names of properties from their identifiers.
1998 * iface [I] IMAPIProp object to operate on
1999 * lppPropTags [I/O] Property identifiers to get the names for, or NULL to
2001 * iid [I] Property set identifier, or NULL
2002 * ulFlags [I] MAPI_NO_IDS=Don't return numeric named properties,
2003 * or MAPI_NO_STRINGS=Don't return strings
2004 * lpCount [O] Destination for number of properties returned
2005 * lpppNames [O] Destination for returned names
2008 * Success: S_OK. *lppPropTags and lpppNames contain the returned
2010 * Failure: MAPI_E_NO_SUPPORT, if the object does not support named properties,
2011 * MAPI_E_NOT_ENOUGH_MEMORY, if memory allocation fails, or
2012 * MAPI_W_ERRORS_RETURNED if not all properties were retrieved
2015 static HRESULT WINAPI
IPropData_fnGetNamesFromIDs(LPPROPDATA 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 * IPropData_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 HRESULT WINAPI
IPropData_fnGetIDsFromNames(LPPROPDATA iface
, ULONG ulNames
,
2046 LPMAPINAMEID
*lppNames
, ULONG ulFlags
,
2047 LPSPropTagArray
*lppPropTags
)
2049 FIXME("(%p,%d,%p,0x%08X,%p) stub\n",
2050 iface
, ulNames
, lppNames
, ulFlags
, lppPropTags
);
2051 return MAPI_E_NO_SUPPORT
;
2054 /**************************************************************************
2055 * IPropData_HrSetObjAccess {MAPI32}
2057 * Set the access level of an IPropData object.
2060 * iface [I] IPropData object to set the access on
2061 * ulAccess [I] Either IPROP_READONLY or IPROP_READWRITE for read or
2062 * read/write access respectively.
2065 * Success: S_OK. The objects access level is changed.
2066 * Failure: MAPI_E_INVALID_PARAMETER, if any parameter is invalid.
2068 static HRESULT WINAPI
2069 IPropData_fnHrSetObjAccess(LPPROPDATA iface
, ULONG ulAccess
)
2071 IPropDataImpl
*This
= impl_from_IPropData(iface
);
2073 TRACE("(%p,%x)\n", iface
, ulAccess
);
2075 if (!iface
|| ulAccess
< IPROP_READONLY
|| ulAccess
> IPROP_READWRITE
)
2076 return MAPI_E_INVALID_PARAMETER
;
2078 IMAPIPROP_Lock(This
);
2080 This
->ulObjAccess
= ulAccess
;
2082 IMAPIPROP_Unlock(This
);
2086 /* Internal - determine if an access value is bad */
2087 static inline BOOL
PROP_IsBadAccess(ULONG ulAccess
)
2091 case IPROP_READONLY
|IPROP_CLEAN
:
2092 case IPROP_READONLY
|IPROP_DIRTY
:
2093 case IPROP_READWRITE
|IPROP_CLEAN
:
2094 case IPROP_READWRITE
|IPROP_DIRTY
:
2100 /**************************************************************************
2101 * IPropData_HrSetPropAccess {MAPI32}
2103 * Set the access levels for a group of property values in an IPropData object.
2106 * iface [I] IPropData object to set access levels in.
2107 * lpTags [I] List of property Id's to set access for.
2108 * lpAccess [O] Access level for each property in lpTags.
2111 * Success: S_OK. The access level of each property value in lpTags that is
2112 * present in iface is changed.
2113 * Failure: MAPI_E_INVALID_PARAMETER, if any parameter is invalid.
2116 * - Each access level in lpAccess must contain at least one of IPROP_READONLY
2117 * or IPROP_READWRITE, but not both, and also IPROP_CLEAN or IPROP_DIRTY,
2118 * but not both. No other bits should be set.
2119 * - If a property Id in lpTags is not present in iface, it is ignored.
2121 static HRESULT WINAPI
2122 IPropData_fnHrSetPropAccess(LPPROPDATA iface
, LPSPropTagArray lpTags
,
2125 IPropDataImpl
*This
= impl_from_IPropData(iface
);
2128 TRACE("(%p,%p,%p)\n", iface
, lpTags
, lpAccess
);
2130 if (!iface
|| !lpTags
|| !lpAccess
)
2131 return MAPI_E_INVALID_PARAMETER
;
2133 for (i
= 0; i
< lpTags
->cValues
; i
++)
2135 if (FBadPropTag(lpTags
->aulPropTag
[i
]) || PROP_IsBadAccess(lpAccess
[i
]))
2136 return MAPI_E_INVALID_PARAMETER
;
2139 IMAPIPROP_Lock(This
);
2141 for (i
= 0; i
< lpTags
->cValues
; i
++)
2143 LPIPropDataItem item
= IMAPIPROP_GetValue(This
, lpTags
->aulPropTag
[i
]);
2146 item
->ulAccess
= lpAccess
[i
];
2149 IMAPIPROP_Unlock(This
);
2153 /**************************************************************************
2154 * IPropData_HrGetPropAccess {MAPI32}
2156 * Get the access levels for a group of property values in an IPropData object.
2159 * iface [I] IPropData object to get access levels from.
2160 * lppTags [O] Destination for the list of property Id's in iface.
2161 * lppAccess [O] Destination for access level for each property in lppTags.
2164 * Success: S_OK. lppTags and lppAccess contain the property Id's and the
2165 * Access level of each property value in iface.
2166 * Failure: MAPI_E_INVALID_PARAMETER, if any parameter is invalid, or
2167 * MAPI_E_NOT_ENOUGH_MEMORY if memory allocation fails.
2170 * - *lppTags and *lppAccess should be freed with MAPIFreeBuffer() by the caller.
2172 static HRESULT WINAPI
2173 IPropData_fnHrGetPropAccess(LPPROPDATA iface
, LPSPropTagArray
*lppTags
,
2176 IPropDataImpl
*This
= impl_from_IPropData(iface
);
2181 TRACE("(%p,%p,%p) stub\n", iface
, lppTags
, lppAccess
);
2183 if (!iface
|| !lppTags
|| !lppAccess
)
2184 return MAPI_E_INVALID_PARAMETER
;
2189 IMAPIPROP_Lock(This
);
2191 hRet
= This
->lpAlloc(CbNewSPropTagArray(This
->ulNumValues
), &lpMem
);
2192 if (SUCCEEDED(hRet
))
2196 hRet
= This
->lpAlloc(This
->ulNumValues
* sizeof(ULONG
), &lpMem
);
2197 if (SUCCEEDED(hRet
))
2199 struct list
*cursor
;
2202 (*lppTags
)->cValues
= This
->ulNumValues
;
2205 LIST_FOR_EACH(cursor
, &This
->values
)
2207 LPIPropDataItem item
= LIST_ENTRY(cursor
, IPropDataItem
, entry
);
2208 (*lppTags
)->aulPropTag
[i
] = item
->value
->ulPropTag
;
2209 (*lppAccess
)[i
] = item
->ulAccess
;
2212 IMAPIPROP_Unlock(This
);
2215 This
->lpFree(*lppTags
);
2218 IMAPIPROP_Unlock(This
);
2219 return MAPI_E_NOT_ENOUGH_MEMORY
;
2222 /**************************************************************************
2223 * IPropData_HrAddObjProps {MAPI32}
2225 * Not documented at this time.
2228 * An HRESULT success/failure code.
2230 static HRESULT WINAPI
2231 IPropData_fnHrAddObjProps(LPPROPDATA iface
, LPSPropTagArray lpTags
,
2232 LPSPropProblemArray
*lppProbs
)
2237 LPSPropValue lpValues
;
2240 FIXME("(%p,%p,%p) stub\n", iface
, lpTags
, lppProbs
);
2242 if (!iface
|| !lpTags
)
2243 return MAPI_E_INVALID_PARAMETER
;
2245 /* FIXME: Below is the obvious implementation, adding all the properties
2246 * in lpTags to the object. However, it doesn't appear that this
2247 * is what this function does.
2251 if (!lpTags
->cValues
)
2254 lpValues
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
,
2255 lpTags
->cValues
* sizeof(SPropValue
));
2257 return MAPI_E_NOT_ENOUGH_MEMORY
;
2259 for (i
= 0; i
< lpTags
->cValues
; i
++)
2260 lpValues
[i
].ulPropTag
= lpTags
->aulPropTag
[i
];
2262 hRet
= IPropData_SetProps(iface
, lpTags
->cValues
, lpValues
, lppProbs
);
2263 HeapFree(GetProcessHeap(), 0, lpValues
);
2268 static const IPropDataVtbl IPropDataImpl_vtbl
=
2270 IPropData_fnQueryInterface
,
2272 IPropData_fnRelease
,
2273 IPropData_fnGetLastError
,
2274 IPropData_fnSaveChanges
,
2275 IPropData_fnGetProps
,
2276 IPropData_fnGetPropList
,
2277 IPropData_fnOpenProperty
,
2278 IPropData_fnSetProps
,
2279 IPropData_fnDeleteProps
,
2281 IPropData_fnCopyProps
,
2282 IPropData_fnGetNamesFromIDs
,
2283 IPropData_fnGetIDsFromNames
,
2284 IPropData_fnHrSetObjAccess
,
2285 IPropData_fnHrSetPropAccess
,
2286 IPropData_fnHrGetPropAccess
,
2287 IPropData_fnHrAddObjProps
2290 /*************************************************************************
2291 * CreateIProp@24 (MAPI32.60)
2293 * Create an IPropData object.
2296 * iid [I] GUID of the object to create. Use &IID_IMAPIPropData or NULL
2297 * lpAlloc [I] Memory allocation function. Use MAPIAllocateBuffer()
2298 * lpMore [I] Linked memory allocation function. Use MAPIAllocateMore()
2299 * lpFree [I] Memory free function. Use MAPIFreeBuffer()
2300 * lpReserved [I] Reserved, set to NULL
2301 * lppPropData [O] Destination for created IPropData object
2304 * Success: S_OK. *lppPropData contains the newly created object.
2305 * Failure: MAPI_E_INTERFACE_NOT_SUPPORTED, if iid is non-NULL and not supported,
2306 * MAPI_E_INVALID_PARAMETER, if any parameter is invalid
2308 SCODE WINAPI
CreateIProp(LPCIID iid
, ALLOCATEBUFFER
*lpAlloc
,
2309 ALLOCATEMORE
*lpMore
, FREEBUFFER
*lpFree
,
2310 LPVOID lpReserved
, LPPROPDATA
*lppPropData
)
2312 IPropDataImpl
*lpPropData
;
2315 TRACE("(%s,%p,%p,%p,%p,%p)\n", debugstr_guid(iid
), lpAlloc
, lpMore
, lpFree
,
2316 lpReserved
, lppPropData
);
2319 *lppPropData
= NULL
;
2321 if (iid
&& !IsEqualGUID(iid
, &IID_IMAPIPropData
))
2322 return MAPI_E_INTERFACE_NOT_SUPPORTED
;
2324 if (!lpAlloc
|| !lpMore
|| !lpFree
|| lpReserved
|| !lppPropData
)
2325 return MAPI_E_INVALID_PARAMETER
;
2327 scode
= lpAlloc(sizeof(IPropDataImpl
), (LPVOID
*)&lpPropData
);
2329 if (SUCCEEDED(scode
))
2331 lpPropData
->IPropData_iface
.lpVtbl
= &IPropDataImpl_vtbl
;
2332 lpPropData
->lRef
= 1;
2333 lpPropData
->lpAlloc
= lpAlloc
;
2334 lpPropData
->lpMore
= lpMore
;
2335 lpPropData
->lpFree
= lpFree
;
2336 lpPropData
->ulObjAccess
= IPROP_READWRITE
;
2337 lpPropData
->ulNumValues
= 0;
2338 list_init(&lpPropData
->values
);
2339 InitializeCriticalSection(&lpPropData
->cs
);
2340 lpPropData
->cs
.DebugInfo
->Spare
[0] = (DWORD_PTR
)(__FILE__
": IPropDataImpl.cs");
2341 *lppPropData
= &lpPropData
->IPropData_iface
;