diff --git a/ChangeLog b/ChangeLog index c39ba96dd..bfa16d561 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2011-02-03 Ludovic Marcotte + * OpenChange/SOGoMAPIFSMessage.m (-delete): implemented method. + (-setMAPIProperties:): append the new properties to the existing + ones instead of replacing them. + * OpenChange/MAPIStoreTable.m (-setRestrictions:): log the old restriction when unset. diff --git a/OpenChange/SOGoMAPIFSMessage.h b/OpenChange/SOGoMAPIFSMessage.h index 04aaf0b75..012f96d10 100644 --- a/OpenChange/SOGoMAPIFSMessage.h +++ b/OpenChange/SOGoMAPIFSMessage.h @@ -29,7 +29,7 @@ @interface SOGoMAPIFSMessage : SOGoObject { - NSDictionary *properties; + NSMutableDictionary *properties; } - (NSDictionary *) properties; diff --git a/OpenChange/SOGoMAPIFSMessage.m b/OpenChange/SOGoMAPIFSMessage.m index 182b00e1a..fa886a67f 100644 --- a/OpenChange/SOGoMAPIFSMessage.m +++ b/OpenChange/SOGoMAPIFSMessage.m @@ -21,6 +21,7 @@ */ #import +#import #import #import #import @@ -57,7 +58,7 @@ { filePath = [[container directory] stringByAppendingPathComponent: nameInContainer]; - properties = [[NSDictionary alloc] + properties = [[NSMutableDictionary alloc] initWithContentsOfFile: filePath]; } @@ -66,7 +67,22 @@ - (void) setMAPIProperties: (NSDictionary *) newProperties { - ASSIGN (properties, newProperties); + NSArray *keys; + NSString *key; + int i, count; + + // We ensure the current properties are loaded + [self properties]; + + // We merge the changes + keys = [newProperties allKeys]; + count = [keys count]; + for (i = 0; i < count; i++) + { + key = [keys objectAtIndex: i]; + [properties setObject: [newProperties objectForKey: key] + forKey: key]; + } } - (void) MAPISave @@ -112,4 +128,21 @@ return [NSString stringWithFormat: @"%p", attributes]; } +- (NSException *) delete +{ + NSFileManager *fm; + NSString *filePath; + + fm = [NSFileManager defaultManager]; + + filePath = [[container directory] + stringByAppendingPathComponent: nameInContainer]; + + if (![fm removeFileAtPath: filePath handler: NULL]) + [NSException raise: @"MAPIStoreIOException" + format: @"could not delete message"]; + + return nil; +} + @end