diff --git a/ChangeLog b/ChangeLog index d30197a20..c4edd2f97 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2011-07-27 Wolfgang Sourdeau + * OpenChange/SOGoMAPIFSMessage.m (-save): serialize the properties + dictionary in binary plist format to avoid GNUstep bugs where + high unsigned long long values are not parsed properly. + (-properties): corrolary to the above change. + * OpenChange/NSArray+MAPIStore.m (-asArrayOfUnicodeStringsInCtx:): the return type is now "struct WStringArray_r *". diff --git a/OpenChange/SOGoMAPIFSMessage.m b/OpenChange/SOGoMAPIFSMessage.m index 428e9a9d7..10c3fe19c 100644 --- a/OpenChange/SOGoMAPIFSMessage.m +++ b/OpenChange/SOGoMAPIFSMessage.m @@ -21,9 +21,11 @@ */ #import +#import #import #import #import +#import #import #import @@ -66,10 +68,26 @@ - (NSDictionary *) properties { + NSData *content; + NSString *error; + NSPropertyListFormat format; + if (!properties) { - properties = [[NSMutableDictionary alloc] - initWithContentsOfFile: [self completeFilename]]; + content = [NSData dataWithContentsOfFile: [self completeFilename]]; + if (content) + { + properties = [NSPropertyListSerialization propertyListFromData: content + mutabilityOption: NSPropertyListMutableContainers + format: &format + errorDescription: &error]; + [properties retain]; + if (!properties) + [self logWithFormat: @"an error occurred during deserialization" + @" of message: '%@'", error]; + } + else + properties = nil; if (!properties) properties = [NSMutableDictionary new]; } @@ -88,9 +106,14 @@ - (void) save { + NSData *content; + [container ensureDirectory]; - if (![properties writeToFile: [self completeFilename] atomically: YES]) + content = [NSPropertyListSerialization dataFromPropertyList: properties + format: NSPropertyListBinaryFormat_v1_0 + errorDescription: NULL]; + if (![content writeToFile: [self completeFilename] atomically: NO]) [NSException raise: @"MAPIStoreIOException" format: @"could not save message"]; }