From 5c7d7aa062ebb1cfb88224af34867f704020e364 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Tue, 22 Nov 2011 19:43:46 +0000 Subject: [PATCH] Monotone-Parent: 56370c6160c963011c084c7793dbe96aef748e92 Monotone-Revision: 3a115c300e05230d3e0392a7aa86ccee296f50cc Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2011-11-22T19:43:46 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 1 + OpenChange/NSArray+MAPIStore.h | 1 + OpenChange/NSArray+MAPIStore.m | 22 ++++++++++++++++++++++ OpenChange/NSObject+MAPIStore.m | 3 +++ 4 files changed, 27 insertions(+) diff --git a/ChangeLog b/ChangeLog index bbf182b98..77f90043c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,7 @@ * OpenChange/NSArray+MAPIStore.m (-asMVUnicodeInMemCtx:) renamed from "asArrayOfUnicodeStringsInCtx". + (-asMVUnicodeInMemCtx:): new conversion method. * OpenChange/MAPIStoreTypes.m (NSObjectFromValuePointer): simplified method by using set_SPropValue_proptag and diff --git a/OpenChange/NSArray+MAPIStore.h b/OpenChange/NSArray+MAPIStore.h index 782594e05..7558d7137 100644 --- a/OpenChange/NSArray+MAPIStore.h +++ b/OpenChange/NSArray+MAPIStore.h @@ -41,6 +41,7 @@ + (id) arrayFromMVUnicode: (const struct WStringArray_r *) mvUnicode; - (struct WStringArray_r *) asMVUnicodeInMemCtx: (void *) memCtx; + (id) arrayFromMVBinary: (const struct BinaryArray_r *) mvBinary; +- (struct BinaryArray_r *) asMVBinaryInMemCtx: (void *) memCtx; + (id) arrayFromMVGuid: (const struct FlatUIDArray_r *) mvGuid; + (id) arrayFromMVFileTime: (const struct DateTimeArray_r *) mvGuid; diff --git a/OpenChange/NSArray+MAPIStore.m b/OpenChange/NSArray+MAPIStore.m index c0cf8d1ee..c72ecc0ec 100644 --- a/OpenChange/NSArray+MAPIStore.m +++ b/OpenChange/NSArray+MAPIStore.m @@ -230,6 +230,28 @@ return mvResult; } +- (struct BinaryArray_r *) asMVBinaryInMemCtx: (void *) memCtx +{ + struct BinaryArray_r *list; + NSData *data; + NSInteger count, max; + + max = [self count]; + + list = talloc_zero(memCtx,struct BinaryArray_r); + list->cValues = max; + list->lpbin = talloc_array(list, struct Binary_r, max); + + for (count = 0; count < max; count++) + { + data = [self objectAtIndex: count]; + list->lpbin[count].cb = [data length]; + list->lpbin[count].lpb = talloc_memdup (list->lpbin, [data bytes], list->lpbin[count].cb); + } + + return list; +} + + (id) arrayFromMVGuid: (const struct FlatUIDArray_r *) mvGuid { NSUInteger count; diff --git a/OpenChange/NSObject+MAPIStore.m b/OpenChange/NSObject+MAPIStore.m index f2b9e8297..e74e84708 100644 --- a/OpenChange/NSObject+MAPIStore.m +++ b/OpenChange/NSObject+MAPIStore.m @@ -115,6 +115,9 @@ static int MAPIStoreTallocWrapperDestroy (void *data) case PT_MV_UNICODE: *data = [(NSArray *) self asMVUnicodeInMemCtx: memCtx]; break; + case PT_MV_BINARY: + *data = [(NSArray *) self asMVBinaryInMemCtx: memCtx]; + break; default: [self errorWithFormat: @"object type not handled: %d (0x%.4x)",