diff --git a/ChangeLog b/ChangeLog index d705117c8..60cc5865f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,10 @@ -2010-11-24 Wolfgang Sourdeau +2010-11-26 Wolfgang Sourdeau + + * OpenChange/MAPIStoreTypes.m (NSObjectFromStreamData): new + function for returning an NSObject from a property tag and a data + pointer. + +2010-11-24 Wolfgang Sourdeau * OpenChange/SOGoDraftObject+MAPIStore.m: new category module. (-setMAPIProperties,-MAPISubmit,-MAPISave): implemented the MAPI diff --git a/OpenChange/MAPIStoreTypes.h b/OpenChange/MAPIStoreTypes.h index a4149835f..f19180aaa 100644 --- a/OpenChange/MAPIStoreTypes.h +++ b/OpenChange/MAPIStoreTypes.h @@ -28,6 +28,7 @@ #include #include +@class NSData; @class NSDictionary; uint8_t *MAPIBoolValue (void *memCtx, BOOL value); @@ -35,6 +36,7 @@ uint32_t *MAPILongValue (void *memCtx, uint32_t value); uint64_t *MAPILongLongValue (void *memCtx, uint64_t value); id NSObjectFromSPropValue (const struct SPropValue *); +id NSObjectFromStreamData (enum MAPITAGS property, NSData *streamData); #if (GS_SIZEOF_LONG == 4) static inline NSNumber * diff --git a/OpenChange/MAPIStoreTypes.m b/OpenChange/MAPIStoreTypes.m index af786b878..d2bd7f593 100644 --- a/OpenChange/MAPIStoreTypes.m +++ b/OpenChange/MAPIStoreTypes.m @@ -29,6 +29,7 @@ #import #import +#import #import #import @@ -129,6 +130,33 @@ NSObjectFromSPropValue (const struct SPropValue *value) return result; } +id NSObjectFromStreamData (enum MAPITAGS property, NSData* streamData) +{ + short int valueType; + id result; + + valueType = (property & 0xffff); + switch (valueType) + { + case PT_UNICODE: + case PT_STRING8: + result = [NSString stringWithUTF8String: [streamData bytes]]; + break; + case PT_BINARY: + result = streamData; + break; + case PT_OBJECT: + result = [NSNull null]; + NSLog (@"object type not handled: %d (0x.4x)", valueType, valueType); + break; + default: + [NSException raise: @"MAPIStoreStreamTypeException" + format: @"invalid data type"]; + } + + return result; +} + void MAPIStoreDumpMessageProperties (NSDictionary *properties) {