86
86
/* Sanity checks */
87
87
OPENCHANGE_RETVAL_IF(!mem_ctx, MAPI_E_NOT_INITIALIZED, NULL);
88
88
OPENCHANGE_RETVAL_IF(!SPropTagArray, MAPI_E_INVALID_PARAMETER, NULL);
89
OPENCHANGE_RETVAL_IF(!SPropTagArray->cValues, MAPI_E_INVALID_PARAMETER, NULL);
89
OPENCHANGE_RETVAL_IF(!SPropTagArray->aulPropTag, MAPI_E_INVALID_PARAMETER, NULL);
91
91
SPropTagArray->cValues += 1;
92
92
SPropTagArray->aulPropTag = (enum MAPITAGS *) talloc_realloc(mem_ctx, SPropTagArray->aulPropTag,
97
97
return MAPI_E_SUCCESS;
101
\details Delete a property tag from an existing properties array
103
\param mem_ctx talloc memory context to use for allocation
104
\param SPropTagArray existing properties array to remove from
105
\param aulPropTag the property tag to remove
107
\return MAPI_E_SUCCESS on success, otherwise MAPI error.
109
\note Possible MAPI error codes are:
110
- MAPI_E_NOT_INITIALIZED: MAPI subsystem has not been initialized
111
- MAPI_E_INVALID_PARAMETER: SPropTagArray parameter is not correctly set
113
_PUBLIC_ enum MAPISTATUS SPropTagArray_delete(TALLOC_CTX *mem_ctx,
114
struct SPropTagArray *SPropTagArray,
117
uint32_t i, removed = 0;
120
OPENCHANGE_RETVAL_IF(!mem_ctx, MAPI_E_NOT_INITIALIZED, NULL);
121
OPENCHANGE_RETVAL_IF(!SPropTagArray, MAPI_E_INVALID_PARAMETER, NULL);
122
OPENCHANGE_RETVAL_IF(!SPropTagArray->cValues, MAPI_E_INVALID_PARAMETER, NULL);
124
for (i = 0; i < SPropTagArray->cValues; i++) {
125
if (SPropTagArray->aulPropTag[i] == aulPropTag) {
128
else if (removed > 0) {
129
SPropTagArray->aulPropTag[i-removed] = SPropTagArray->aulPropTag[i];
133
SPropTagArray->cValues -= removed;
134
SPropTagArray->aulPropTag = (enum MAPITAGS *) talloc_realloc(mem_ctx, SPropTagArray->aulPropTag,
135
uint32_t, SPropTagArray->cValues + 1);
136
SPropTagArray->aulPropTag[SPropTagArray->cValues] = (enum MAPITAGS) 0;
138
return MAPI_E_SUCCESS;
142
\details Return the index of a property tag in an existing properties array
144
\param SPropTagArray existing properties array to remove from
145
\param aulPropTag the property tag to find
146
\param propIdx the index of the found property (undefined when MAPI_E_NOT_FOUND is returned)
148
\return MAPI_E_SUCCESS on success, otherwise MAPI error.
150
\note Possible MAPI error codes are:
151
- MAPI_E_NOT_INITIALIZED: MAPI subsystem has not been initialized
152
- MAPI_E_INVALID_PARAMETER: SPropTagArray parameter is not correctly set
154
_PUBLIC_ enum MAPISTATUS SPropTagArray_find(struct SPropTagArray SPropTagArray,
155
enum MAPITAGS aulPropTag,
161
OPENCHANGE_RETVAL_IF(!propIdx, MAPI_E_INVALID_PARAMETER, NULL);
163
for (i = 0; i < SPropTagArray.cValues; i++) {
164
if (SPropTagArray.aulPropTag[i] == aulPropTag) {
166
return MAPI_E_SUCCESS;
170
return MAPI_E_NOT_FOUND;
100
173
_PUBLIC_ const void *get_SPropValue(struct SPropValue *lpProps,
101
174
enum MAPITAGS ulPropTag)
380
TODO: should this be public?
460
_PUBLIC_ bool set_mapi_SPropValue(TALLOC_CTX *mem_ctx, struct mapi_SPropValue *lpProps, const void *data)
463
lpProps->ulPropTag = (lpProps->ulPropTag & 0xffff0000) | PT_ERROR;
464
lpProps->value.err = MAPI_E_NOT_FOUND;
467
switch (lpProps->ulPropTag & 0xFFFF) {
469
lpProps->value.i = *((const uint16_t *)data);
472
lpProps->value.l = *((const uint32_t *)data);
475
memcpy(&lpProps->value.dbl, (uint8_t *)data, 8);
478
lpProps->value.d = *((const uint64_t *)data);
481
lpProps->value.b = *((const uint8_t *)data);
484
lpProps->value.lpszA = (const char *) data;
488
struct Binary_r *bin;
490
bin = (struct Binary_r *)data;
491
lpProps->value.bin.cb = (uint16_t)bin->cb;
492
lpProps->value.bin.lpb = (void *)bin->lpb;
496
lpProps->value.lpszW = (const char *) data;
499
lpProps->value.lpguid = *((struct GUID *) data);
502
lpProps->value.ft = *((const struct FILETIME *) data);
505
lpProps->value.err = *((const uint32_t *)data);
508
lpProps->value.MVl = *((const struct mapi_MV_LONG_STRUCT *)data);
511
lpProps->value.MVszA = *((const struct mapi_SLPSTRArray *)data);
514
lpProps->value.MVbin = *((const struct mapi_SBinaryArray *)data);
517
lpProps->value.MVguid = *((const struct mapi_SGuidArray *)data);
520
lpProps->value.MVszW = *((const struct mapi_SLPSTRArrayW *)data);
523
lpProps->ulPropTag = (lpProps->ulPropTag & 0xffff0000) | PT_ERROR;
524
lpProps->value.err = MAPI_E_NOT_FOUND;
532
_PUBLIC_ bool set_mapi_SPropValue_proptag(TALLOC_CTX *mem_ctx, struct mapi_SPropValue *lpProps, uint32_t aulPropTag, const void *data)
534
lpProps->ulPropTag = aulPropTag;
536
return (set_mapi_SPropValue(mem_ctx, lpProps, data));
539
_PUBLIC_ struct mapi_SPropValue *add_mapi_SPropValue(TALLOC_CTX *mem_ctx, struct mapi_SPropValue *lpProps, uint16_t *cValues, uint32_t aulPropTag, const void *data)
541
lpProps = talloc_realloc(mem_ctx, lpProps, struct mapi_SPropValue, *cValues + 2);
542
DEBUG(0, ("%d: setting value for 0x%.8x\n", *cValues, aulPropTag));
543
set_mapi_SPropValue_proptag(mem_ctx, &lpProps[*cValues], aulPropTag, data);
544
*cValues = *cValues + 1;
382
549
_PUBLIC_ bool set_SPropValue(struct SPropValue *lpProps, const void *data)
384
551
if (data == NULL) {
552
lpProps->ulPropTag = (lpProps->ulPropTag & 0xffff0000) | PT_ERROR;
385
553
lpProps->value.err = MAPI_E_NOT_FOUND;
656
\details Convenience function to copy an array of struct SPropValue or a
657
part thereof into another array, by duplicating and properly parenting
658
pointer data. The destination array is considered to be preallocated.
660
_PUBLIC_ void mapi_copy_spropvalues(TALLOC_CTX *mem_ctx, struct SPropValue *source_values, struct SPropValue *dest_values, uint32_t count)
663
struct SPropValue *source_value, *dest_value;
666
for (i = 0; i < count; i++) {
667
source_value = source_values + i;
668
dest_value = dest_values + i;
669
*dest_value = *source_value;
671
prop_type = (source_value->ulPropTag & 0xFFFF);
672
if ((prop_type & MV_FLAG)) {
673
DEBUG(5, ("multivalues not handled\n"));
679
dest_value->value.lpszA = talloc_strdup(mem_ctx, source_value->value.lpszA);
682
dest_value->value.lpszW = talloc_strdup(mem_ctx, source_value->value.lpszW);
685
dest_value->value.bin.cb = source_value->value.bin.cb;
686
dest_value->value.bin.lpb = talloc_memdup(mem_ctx, source_value->value.bin.lpb, sizeof(uint8_t) * source_value->value.bin.cb);
689
*dest_value = *source_value;
486
696
\details Convenience function to convert a SPropValue structure
487
697
into a mapi_SPropValue structure and return the associated size.
607
817
return sizeof(mapi_sprop->value.MVl.cValues) + (mapi_sprop->value.MVl.cValues * sizeof (uint32_t));
824
mapi_sprop->value.MVguid.cValues = sprop->value.MVguid.cValues;
825
mapi_sprop->value.MVguid.lpguid = talloc_array (mem_ctx, struct GUID, mapi_sprop->value.MVguid.cValues);
826
for (i = 0; i < mapi_sprop->value.MVguid.cValues; i++) {
827
b.data = sprop->value.MVguid.lpguid[i]->ab;
830
GUID_from_ndr_blob(&b, &(mapi_sprop->value.MVguid.lpguid[i]));
832
return sizeof(mapi_sprop->value.MVguid.cValues) + (mapi_sprop->value.MVguid.cValues * sizeof (struct GUID));
610
835
printf("unhandled conversion case in cast_mapi_SPropValue(): 0x%x\n", (sprop->ulPropTag & 0xFFFF));
611
836
OPENCHANGE_ASSERT();
1007
1232
return RecurrencePattern;
1235
_PUBLIC_ size_t set_RecurrencePattern_size(const struct RecurrencePattern *rp)
1237
size_t size = SIZE_DFLT_RECURRENCEPATTERN;
1239
switch (rp->PatternType) {
1240
case PatternType_MonthNth:
1241
case PatternType_HjMonthNth:
1242
size += sizeof(uint32_t);
1243
case PatternType_Week:
1244
case PatternType_Month:
1245
case PatternType_MonthEnd:
1246
case PatternType_HjMonth:
1247
case PatternType_HjMonthEnd:
1248
size += sizeof(uint32_t);
1249
case PatternType_Day:
1252
DEBUG(0, ("%s: unrecognized pattern type: %d", __PRETTY_FUNCTION__, rp->PatternType));
1255
size += rp->DeletedInstanceCount * sizeof(uint32_t);
1256
size += rp->ModifiedInstanceCount * sizeof(uint32_t);
1261
_PUBLIC_ struct Binary_r *set_RecurrencePattern(TALLOC_CTX *mem_ctx, const struct RecurrencePattern *rp)
1263
struct Binary_r *bin = NULL;
1264
struct ndr_push *ndr;
1265
enum ndr_err_code ndr_err_code;
1269
if (!rp) return NULL;
1271
bin_size = set_RecurrencePattern_size(rp);
1272
bin = talloc_zero(mem_ctx, struct Binary_r);
1274
bin->lpb = talloc_array(bin, uint8_t, bin_size);
1276
ndr = talloc_zero(mem_ctx, struct ndr_push);
1278
ndr->data = bin->lpb;
1280
ndr_err_code = ndr_push_RecurrencePattern(ndr, NDR_SCALARS, rp);
1284
if (ndr_err_code != NDR_ERR_SUCCESS) {
1009
1292
_PUBLIC_ struct AppointmentRecurrencePattern *get_AppointmentRecurrencePattern(TALLOC_CTX *mem_ctx,
1010
struct Binary_r *bin)
1293
struct Binary_r *bin)
1012
1295
struct AppointmentRecurrencePattern *arp = NULL;
1013
1296
struct ndr_pull *ndr;
1049
1332
arp->RecurrencePattern.DeletedInstanceDates = talloc_reference(arp,arp->RecurrencePattern.DeletedInstanceDates);
1050
1333
arp->RecurrencePattern.ModifiedInstanceDates = talloc_reference(arp, arp->RecurrencePattern.ModifiedInstanceDates);
1338
_PUBLIC_ size_t set_AppointmentRecurrencePattern_size(const struct AppointmentRecurrencePattern *arp)
1340
size_t size = SIZE_DFLT_APPOINTMENTRECURRENCEPATTERN;
1343
size += set_RecurrencePattern_size(&arp->RecurrencePattern);
1344
for (i = 0; i < arp->ExceptionCount; i++) {
1345
size += set_ExceptionInfo_size(arp->ExceptionInfo + i);
1346
/* size += set_ExtendedException_size(arp->ExtendedException +
1349
size += arp->ReservedBlock1Size * sizeof(uint32_t);
1350
/* size += arp->ReservedBlock2Size * sizeof(uint32_t); */
1355
_PUBLIC_ struct Binary_r *set_AppointmentRecurrencePattern(TALLOC_CTX *mem_ctx, const struct AppointmentRecurrencePattern *arp)
1357
struct Binary_r *bin = NULL;
1358
struct ndr_push *ndr;
1359
enum ndr_err_code ndr_err_code;
1363
if (!arp) return NULL;
1365
ndr = ndr_push_init_ctx(mem_ctx);
1366
ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
1368
bin_size = set_AppointmentRecurrencePattern_size(arp);
1369
talloc_free(ndr->data);
1370
ndr->data = talloc_array(ndr, uint8_t, bin_size);
1372
ndr_err_code = ndr_push_AppointmentRecurrencePattern(ndr, NDR_SCALARS, arp);
1373
if (ndr_err_code != NDR_ERR_SUCCESS) {
1377
bin = talloc_zero(mem_ctx, struct Binary_r);
1379
bin->lpb = ndr->data;
1380
talloc_steal(bin, bin->lpb);
1387
_PUBLIC_ size_t set_ExceptionInfo_size(const struct ExceptionInfo *exc_info)
1389
size_t size = SIZE_DFLT_EXCEPTIONINFO;
1391
if ((exc_info->OverrideFlags & ARO_SUBJECT)) {
1392
size += 3 * sizeof(uint16_t); /* SubjectLength + SubjectLength2 + Subject */
1394
if ((exc_info->OverrideFlags & ARO_MEETINGTYPE)) {
1395
size += sizeof(uint32_t);
1397
if ((exc_info->OverrideFlags & ARO_REMINDERDELTA)) {
1398
size += sizeof(uint32_t);
1400
if ((exc_info->OverrideFlags & ARO_REMINDER)) {
1401
size += sizeof(uint32_t);
1403
if ((exc_info->OverrideFlags & ARO_LOCATION)) {
1404
size += 2 * sizeof(uint16_t); /* LocationLength + LocationLength2 */
1405
size += sizeof(uint32_t); /* Location */
1407
if ((exc_info->OverrideFlags & ARO_BUSYSTATUS)) {
1408
size += sizeof(uint32_t);
1410
if ((exc_info->OverrideFlags & ARO_ATTACHMENT)) {
1411
size += sizeof(uint32_t);
1413
if ((exc_info->OverrideFlags & ARO_SUBTYPE)) {
1414
size += sizeof(uint32_t);
1416
if ((exc_info->OverrideFlags & ARO_APPTCOLOR)) {
1417
size += sizeof(uint32_t);
1060
1424
\details Retrieve a TimeZoneStruct structure from a binary blob
1469
\details Retrieve a PtypServerId structure from a binary blob
1471
\param mem_ctx pointer to the memory context
1472
\param bin pointer to the Binary_r structure with raw PtypServerId data
1474
\return Allocated PtypServerId structure on success, otherwise
1477
\note Developers must free the allocated PtypServerId when
1480
_PUBLIC_ struct PtypServerId *get_PtypServerId(TALLOC_CTX *mem_ctx, struct Binary_r *bin)
1482
struct PtypServerId *PtypServerId = NULL;
1483
struct ndr_pull *ndr;
1484
enum ndr_err_code ndr_err_code;
1487
if (!bin) return NULL;
1488
if (!bin->cb) return NULL;
1489
if (!bin->lpb) return NULL;
1491
ndr = talloc_zero(mem_ctx, struct ndr_pull);
1493
ndr->data = bin->lpb;
1494
ndr->data_size = bin->cb;
1496
ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
1497
PtypServerId = talloc_zero(mem_ctx, struct PtypServerId);
1498
ndr_err_code = ndr_pull_PtypServerId(ndr, NDR_SCALARS, PtypServerId);
1502
if (ndr_err_code != NDR_ERR_SUCCESS) {
1503
talloc_free(PtypServerId);
1507
return PtypServerId;
1105
1511
\details Retrieve a GlobalObjectId structure from a binary blob
1107
1513
\param mem_ctx pointer to the memory context
1555
\details Retrieve a MessageEntryId structure from a binary blob
1557
\param mem_ctx pointer to the memory context
1558
\param bin pointer to the Binary_r structure with raw
1561
\return Allocated MessageEntryId structure on success, otherwise
1564
\note Developers must free the allocated MessageEntryId when
1567
_PUBLIC_ struct MessageEntryId *get_MessageEntryId(TALLOC_CTX *mem_ctx, struct Binary_r *bin)
1569
struct MessageEntryId *MessageEntryId = NULL;
1570
struct ndr_pull *ndr;
1571
enum ndr_err_code ndr_err_code;
1574
if (!bin) return NULL;
1575
if (!bin->cb) return NULL;
1576
if (!bin->lpb) return NULL;
1578
ndr = talloc_zero(mem_ctx, struct ndr_pull);
1580
ndr->data = bin->lpb;
1581
ndr->data_size = bin->cb;
1583
ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
1584
MessageEntryId = talloc_zero(mem_ctx, struct MessageEntryId);
1585
ndr_err_code = ndr_pull_MessageEntryId(ndr, NDR_SCALARS, MessageEntryId);
1589
if (ndr_err_code != NDR_ERR_SUCCESS) {
1590
talloc_free(MessageEntryId);
1594
return MessageEntryId;
1598
\details Retrieve a FolderEntryId structure from a binary blob
1600
\param mem_ctx pointer to the memory context
1601
\param bin pointer to the Binary_r structure with raw FolderEntryId data
1603
\return Allocated FolderEntryId structure on success, otherwise
1606
\note Developers must free the allocated FolderEntryId when
1609
_PUBLIC_ struct FolderEntryId *get_FolderEntryId(TALLOC_CTX *mem_ctx, struct Binary_r *bin)
1611
struct FolderEntryId *FolderEntryId = NULL;
1612
struct ndr_pull *ndr;
1613
enum ndr_err_code ndr_err_code;
1616
if (!bin) return NULL;
1617
if (!bin->cb) return NULL;
1618
if (!bin->lpb) return NULL;
1620
ndr = talloc_zero(mem_ctx, struct ndr_pull);
1622
ndr->data = bin->lpb;
1623
ndr->data_size = bin->cb;
1625
ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
1626
FolderEntryId = talloc_zero(mem_ctx, struct FolderEntryId);
1627
ndr_err_code = ndr_pull_FolderEntryId(ndr, NDR_SCALARS, FolderEntryId);
1631
if (ndr_err_code != NDR_ERR_SUCCESS) {
1632
talloc_free(FolderEntryId);
1636
return FolderEntryId;
1640
\details Retrieve a AddressBookEntryId structure from a binary blob
1642
\param mem_ctx pointer to the memory context
1643
\param bin pointer to the Binary_r structure with raw AddressBookEntryId data
1645
\return Allocated AddressBookEntryId structure on success, otherwise NULL
1647
\note Developers must free the allocated AddressBookEntryId when finished.
1649
_PUBLIC_ struct AddressBookEntryId *get_AddressBookEntryId(TALLOC_CTX *mem_ctx, struct Binary_r *bin)
1651
struct AddressBookEntryId *AddressBookEntryId = NULL;
1652
struct ndr_pull *ndr;
1653
enum ndr_err_code ndr_err_code;
1656
if (!bin) return NULL;
1657
if (!bin->cb) return NULL;
1658
if (!bin->lpb) return NULL;
1660
ndr = talloc_zero(mem_ctx, struct ndr_pull);
1662
ndr->data = bin->lpb;
1663
ndr->data_size = bin->cb;
1665
ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
1666
AddressBookEntryId = talloc_zero(mem_ctx, struct AddressBookEntryId);
1667
ndr_err_code = ndr_pull_AddressBookEntryId(ndr, NDR_SCALARS, AddressBookEntryId);
1671
if (ndr_err_code != NDR_ERR_SUCCESS) {
1672
talloc_free(AddressBookEntryId);
1676
return AddressBookEntryId;
1149
1680
\details Return the effective value used in a TypedString