diff --git a/ChangeLog b/ChangeLog index 3beb9b626..7ee21810d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2012-07-19 Wolfgang Sourdeau + + * OpenChange/NSObject+MAPIStore.m + (+getAvailableProperties:inMemCtx:) + (-getAvailableProperties:inMemCtx:, canGetProperty:): methods + moved from MAPIStoreObject.m + 2012-07-18 Wolfgang Sourdeau * OpenChange/MAPIStoreCalendarFolder.m (-createMessage): attach a diff --git a/OpenChange/MAPIStoreObject.h b/OpenChange/MAPIStoreObject.h index 709396e9f..6db864de4 100644 --- a/OpenChange/MAPIStoreObject.h +++ b/OpenChange/MAPIStoreObject.h @@ -50,8 +50,6 @@ + (id) mapiStoreObjectInContainer: (MAPIStoreObject *) newContainer; - (id) initInContainer: (MAPIStoreObject *) newContainer; -+ (int) getAvailableProperties: (struct SPropTagArray **) propertiesP - inMemCtx: (TALLOC_CTX *) memCtx; - (MAPIStoreObject *) container; @@ -61,14 +59,10 @@ /* properties */ -- (BOOL) canGetProperty: (enum MAPITAGS) propTag; - - (void) addProperties: (NSDictionary *) newProperties; - (NSMutableDictionary *) properties; /* ops */ -- (int) getAvailableProperties: (struct SPropTagArray **) propertiesP - inMemCtx: (TALLOC_CTX *) localMemCtx; - (int) getProperties: (struct mapistore_property_data *) data withTags: (enum MAPITAGS *) tags andCount: (uint16_t) columnCount diff --git a/OpenChange/MAPIStoreObject.m b/OpenChange/MAPIStoreObject.m index ac782cdc8..994a74893 100644 --- a/OpenChange/MAPIStoreObject.m +++ b/OpenChange/MAPIStoreObject.m @@ -68,35 +68,6 @@ static Class NSExceptionK, MAPIStoreFolderK; return newObject; } -+ (int) getAvailableProperties: (struct SPropTagArray **) propertiesP - inMemCtx: (TALLOC_CTX *) memCtx -{ - struct SPropTagArray *properties; - const MAPIStorePropertyGetter *classGetters; - NSUInteger count; - enum MAPITAGS propTag; - uint16_t propValue; - - properties = talloc_zero (memCtx, struct SPropTagArray); - properties->aulPropTag = talloc_array (properties, enum MAPITAGS, - MAPIStoreSupportedPropertiesCount); - classGetters = MAPIStorePropertyGettersForClass (self); - for (count = 0; count < MAPIStoreSupportedPropertiesCount; count++) - { - propTag = MAPIStoreSupportedProperties[count]; - propValue = (propTag & 0xffff0000) >> 16; - if (classGetters[propValue]) - { - properties->aulPropTag[properties->cValues] = propTag; - properties->cValues++; - } - } - - *propertiesP = properties; - - return MAPISTORE_SUCCESS; -} - - (id) init { if ((self = [super init])) @@ -204,31 +175,6 @@ static Class NSExceptionK, MAPIStoreFolderK; return MAPISTORE_SUCCESS; } -- (int) getAvailableProperties: (struct SPropTagArray **) propertiesP - inMemCtx: (TALLOC_CTX *) memCtx -{ - NSUInteger count; - struct SPropTagArray *availableProps; - enum MAPITAGS propTag; - - availableProps = talloc_zero (memCtx, struct SPropTagArray); - availableProps->aulPropTag = talloc_array (availableProps, enum MAPITAGS, - MAPIStoreSupportedPropertiesCount); - for (count = 0; count < MAPIStoreSupportedPropertiesCount; count++) - { - propTag = MAPIStoreSupportedProperties[count]; - if ([self canGetProperty: propTag]) - { - availableProps->aulPropTag[availableProps->cValues] = propTag; - availableProps->cValues++; - } - } - - *propertiesP = availableProps; - - return MAPISTORE_SUCCESS; -} - - (BOOL) canGetProperty: (enum MAPITAGS) propTag { uint16_t propValue; diff --git a/OpenChange/NSObject+MAPIStore.h b/OpenChange/NSObject+MAPIStore.h index 2e532eb8d..c5c95c26c 100644 --- a/OpenChange/NSObject+MAPIStore.h +++ b/OpenChange/NSObject+MAPIStore.h @@ -26,6 +26,7 @@ #import #include +#include struct MAPIStoreTallocWrapper { @@ -58,4 +59,14 @@ struct MAPIStoreTallocWrapper @end +@interface NSObject (MAPIStoreProperties) + ++ (enum mapistore_error) getAvailableProperties: (struct SPropTagArray **) propertiesP + inMemCtx: (TALLOC_CTX *) memCtx; +- (enum mapistore_error) getAvailableProperties: (struct SPropTagArray **) propertiesP + inMemCtx: (TALLOC_CTX *) memCtx; +- (BOOL) canGetProperty: (enum MAPITAGS) propTag; + +@end + #endif /* NSOBJECT_MAPISTORE_H */ diff --git a/OpenChange/NSObject+MAPIStore.m b/OpenChange/NSObject+MAPIStore.m index c291990f4..a25a65758 100644 --- a/OpenChange/NSObject+MAPIStore.m +++ b/OpenChange/NSObject+MAPIStore.m @@ -25,6 +25,7 @@ #import #import +#import "MAPIStorePropertySelectors.h" #import "MAPIStoreTypes.h" #import "NSArray+MAPIStore.h" #import "NSData+MAPIStore.h" @@ -168,3 +169,72 @@ MAPIStoreTallocWrapperDestroy (void *data) } @end + +@implementation NSObject (MAPIStoreProperties) + ++ (enum mapistore_error) getAvailableProperties: (struct SPropTagArray **) propertiesP + inMemCtx: (TALLOC_CTX *) memCtx +{ + struct SPropTagArray *properties; + const MAPIStorePropertyGetter *classGetters; + NSUInteger count; + enum MAPITAGS propTag; + uint16_t propValue; + + properties = talloc_zero (memCtx, struct SPropTagArray); + properties->aulPropTag = talloc_array (properties, enum MAPITAGS, + MAPIStoreSupportedPropertiesCount); + classGetters = MAPIStorePropertyGettersForClass (self); + for (count = 0; count < MAPIStoreSupportedPropertiesCount; count++) + { + propTag = MAPIStoreSupportedProperties[count]; + propValue = (propTag & 0xffff0000) >> 16; + if (classGetters[propValue]) + { + properties->aulPropTag[properties->cValues] = propTag; + properties->cValues++; + } + } + + *propertiesP = properties; + + return MAPISTORE_SUCCESS; +} + +- (enum mapistore_error) getAvailableProperties: (struct SPropTagArray **) propertiesP + inMemCtx: (TALLOC_CTX *) memCtx +{ + NSUInteger count; + struct SPropTagArray *availableProps; + enum MAPITAGS propTag; + + availableProps = talloc_zero (memCtx, struct SPropTagArray); + availableProps->aulPropTag = talloc_array (availableProps, enum MAPITAGS, + MAPIStoreSupportedPropertiesCount); + for (count = 0; count < MAPIStoreSupportedPropertiesCount; count++) + { + propTag = MAPIStoreSupportedProperties[count]; + if ([self canGetProperty: propTag]) + { + availableProps->aulPropTag[availableProps->cValues] = propTag; + availableProps->cValues++; + } + } + + *propertiesP = availableProps; + + return MAPISTORE_SUCCESS; +} + +- (BOOL) canGetProperty: (enum MAPITAGS) propTag +{ + uint16_t propValue; + const IMP *classGetters; + + classGetters = (IMP *) MAPIStorePropertyGettersForClass (isa); + propValue = (propTag & 0xffff0000) >> 16; + + return (classGetters[propValue] != NULL); +} + +@end