From 63c2d62b0bc5879e23cd09371872396f6bb78556 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Fri, 20 Jul 2012 14:36:05 +0000 Subject: [PATCH] Monotone-Parent: 3fdbf80f4c1de08138ff9435f54fd9f663ef5b8f Monotone-Revision: 3bc92406543042dce09f1c096eb8a19107b42eb2 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2012-07-20T14:36:05 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 12 ++++++++++++ OpenChange/MAPIStoreCalendarMessage.m | 16 ++++++++++++++++ OpenChange/MAPIStoreObject.m | 13 +++++++++++-- OpenChange/NSObject+MAPIStore.h | 3 +++ OpenChange/NSObject+MAPIStore.m | 24 ++++++++++++++++++++++++ 5 files changed, 66 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 04c5e2a2e..eca66124c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,17 @@ 2012-07-20 Wolfgang Sourdeau + * OpenChange/NSObject+MAPIStore.m + (+fillAvailableProperties:withExclusions:): new method that fills + an existing array of properties with properties existing in + another class, as long as they are not listed in the array of + exclusions. + + * OpenChange/MAPIStoreObject.m (-init): assigned a mutable array + to "proxies" + (-canGetProperty:): test the proxies for the availability of + properties so that -getAvailableProperties:inMemCtx: can return an + accurate result. + * OpenChange/MAPIStoreMessage.m (-getPidTagSubject:inMemCtx:): now compute the return value based on PidTagNormalizedSubject and PidTagSubjectPrefix as PidTagSubject is never actually set from diff --git a/OpenChange/MAPIStoreCalendarMessage.m b/OpenChange/MAPIStoreCalendarMessage.m index a4b4b33ca..904887098 100644 --- a/OpenChange/MAPIStoreCalendarMessage.m +++ b/OpenChange/MAPIStoreCalendarMessage.m @@ -87,6 +87,22 @@ @implementation MAPIStoreCalendarMessage ++ (enum mapistore_error) getAvailableProperties: (struct SPropTagArray **) propertiesP + inMemCtx: (TALLOC_CTX *) memCtx +{ + BOOL listedProperties[65536]; + NSUInteger count; + + memset (listedProperties, NO, 65536 * sizeof (BOOL)); + [super getAvailableProperties: propertiesP inMemCtx: memCtx]; + for (count = 0; count < (*propertiesP)->cValues; count++) + listedProperties[(*propertiesP)->aulPropTag[count] >> 16] = YES; + [MAPIStoreAppointmentWrapper fillAvailableProperties: *propertiesP + withExclusions: listedProperties]; + + return MAPISTORE_SUCCESS; +} + - (id) initWithSOGoObject: (id) newSOGoObject inContainer: (MAPIStoreObject *) newFolder { diff --git a/OpenChange/MAPIStoreObject.m b/OpenChange/MAPIStoreObject.m index 0204f3a2d..eba69c966 100644 --- a/OpenChange/MAPIStoreObject.m +++ b/OpenChange/MAPIStoreObject.m @@ -76,6 +76,7 @@ static Class NSExceptionK, MAPIStoreFolderK; parentContainersBag = [NSMutableArray new]; container = nil; properties = [NSMutableDictionary new]; + proxies = [NSMutableArray new]; } // [self logWithFormat: @"-init"]; @@ -96,6 +97,7 @@ static Class NSExceptionK, MAPIStoreFolderK; - (void) dealloc { // [self logWithFormat: @"-dealloc"]; + [proxies release]; [properties release]; [parentContainersBag release]; [container release]; @@ -203,11 +205,18 @@ static Class NSExceptionK, MAPIStoreFolderK; - (BOOL) canGetProperty: (enum MAPITAGS) propTag { uint16_t propValue; + BOOL canGetProperty; + NSUInteger count, max; propValue = (propTag & 0xffff0000) >> 16; - return (classGetters[propValue] - || [properties objectForKey: MAPIPropertyKey (propTag)]); + canGetProperty = (classGetters[propValue] + || [properties objectForKey: MAPIPropertyKey (propTag)]); + max = [proxies count]; + for (count = 0; !canGetProperty && count < max; count++) + canGetProperty = [[proxies objectAtIndex: count] canGetProperty: propTag]; + + return canGetProperty; } - (int) getProperties: (struct mapistore_property_data *) data diff --git a/OpenChange/NSObject+MAPIStore.h b/OpenChange/NSObject+MAPIStore.h index c5c95c26c..e73a983a0 100644 --- a/OpenChange/NSObject+MAPIStore.h +++ b/OpenChange/NSObject+MAPIStore.h @@ -63,6 +63,9 @@ struct MAPIStoreTallocWrapper + (enum mapistore_error) getAvailableProperties: (struct SPropTagArray **) propertiesP inMemCtx: (TALLOC_CTX *) memCtx; ++ (void) fillAvailableProperties: (struct SPropTagArray *) properties + withExclusions: (BOOL *) exclusions; + - (enum mapistore_error) getAvailableProperties: (struct SPropTagArray **) propertiesP inMemCtx: (TALLOC_CTX *) memCtx; - (BOOL) canGetProperty: (enum MAPITAGS) propTag; diff --git a/OpenChange/NSObject+MAPIStore.m b/OpenChange/NSObject+MAPIStore.m index a25a65758..2c35521b3 100644 --- a/OpenChange/NSObject+MAPIStore.m +++ b/OpenChange/NSObject+MAPIStore.m @@ -201,6 +201,30 @@ MAPIStoreTallocWrapperDestroy (void *data) return MAPISTORE_SUCCESS; } ++ (void) fillAvailableProperties: (struct SPropTagArray *) properties + withExclusions: (BOOL *) exclusions +{ + TALLOC_CTX *localMemCtx; + struct SPropTagArray *subProperties; + uint16_t propId; + NSUInteger count; + + localMemCtx = talloc_zero (NULL, TALLOC_CTX); + [self getAvailableProperties: &subProperties inMemCtx: localMemCtx]; + for (count = 0; count < subProperties->cValues; count++) + { + propId = (subProperties->aulPropTag[count] >> 16); + if (!exclusions[propId]) + { + properties->aulPropTag[properties->cValues] + = subProperties->aulPropTag[count]; + properties->cValues++; + exclusions[propId] = YES; + } + } + talloc_free (localMemCtx); +} + - (enum mapistore_error) getAvailableProperties: (struct SPropTagArray **) propertiesP inMemCtx: (TALLOC_CTX *) memCtx {