diff --git a/ChangeLog b/ChangeLog index 5a96d8b58..e8954ac1a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2011-10-25 Wolfgang Sourdeau + * OpenChange/EOQualifier+MAPIFS.[hm]: now evaluates + SOGoMAPIMemMessage. + + * OpenChange/SOGoMAPIFSMessage.[hm]: now a subclass of + SOGoMAPIMemMessage. + * OpenChange/MAPIStoreDraftsMessage.m (_saveAttachment:): make use of MAPIStoreMIME. diff --git a/OpenChange/EOQualifier+MAPIFS.h b/OpenChange/EOQualifier+MAPIMem.h similarity index 79% rename from OpenChange/EOQualifier+MAPIFS.h rename to OpenChange/EOQualifier+MAPIMem.h index 54b4a79fd..baabc6609 100644 --- a/OpenChange/EOQualifier+MAPIFS.h +++ b/OpenChange/EOQualifier+MAPIMem.h @@ -1,4 +1,4 @@ -/* EOQualifier+MAPIFS.h - this file is part of SOGo +/* EOQualifier+MAPIMem.h - this file is part of SOGo * * Copyright (C) 2010 Inverse inc. * @@ -20,17 +20,17 @@ * Boston, MA 02111-1307, USA. */ -#ifndef EOQUALIFIER_MAPIFS_H -#define EOQUALIFIER_MAPIFS_H +#ifndef EOQUALIFIER_MAPIMEM_H +#define EOQUALIFIER_MAPIMEM_H #import -@class SOGoMAPIFSMessage; +@class SOGoMAPIMemMessage; @interface EOQualifier (MAPIStoreRestrictions) -- (BOOL) evaluateMAPIFSMessage: (SOGoMAPIFSMessage *) message; +- (BOOL) evaluateMAPIMemMessage: (SOGoMAPIMemMessage *) message; @end -#endif /* EOQUALIFIER_MAPIFS_H */ +#endif /* EOQUALIFIER_MAPIMEM_H */ diff --git a/OpenChange/EOQualifier+MAPIFS.m b/OpenChange/EOQualifier+MAPIMem.m similarity index 78% rename from OpenChange/EOQualifier+MAPIFS.m rename to OpenChange/EOQualifier+MAPIMem.m index cf5ba75a3..d6d612bb1 100644 --- a/OpenChange/EOQualifier+MAPIFS.m +++ b/OpenChange/EOQualifier+MAPIMem.m @@ -1,4 +1,4 @@ -/* EOQualifier+MAPIFS.m - this file is part of SOGo +/* EOQualifier+MAPIMem.m - this file is part of SOGo * * Copyright (C) 2010 Inverse inc. * @@ -28,20 +28,20 @@ #import -#import "SOGoMAPIFSMessage.h" +#import "SOGoMAPIMemMessage.h" -#import "EOQualifier+MAPIFS.h" +#import "EOQualifier+MAPIMem.h" #import "EOBitmaskQualifier.h" @implementation EOQualifier (MAPIStoreRestrictions) -- (BOOL) _evaluateMAPIFSMessageProperties: (NSDictionary *) properties +- (BOOL) _evaluateMAPIMemMessageProperties: (NSDictionary *) properties { [self subclassResponsibility: _cmd]; return NO; } -- (BOOL) evaluateMAPIFSMessage: (SOGoMAPIFSMessage *) message +- (BOOL) evaluateMAPIMemMessage: (SOGoMAPIMemMessage *) message { NSDictionary *properties; BOOL rc; @@ -49,7 +49,7 @@ [self logWithFormat: @"evaluating message '%@'", message]; properties = [message properties]; - rc = [self _evaluateMAPIFSMessageProperties: properties]; + rc = [self _evaluateMAPIMemMessageProperties: properties]; [self logWithFormat: @" evaluation result: %d", rc]; @@ -60,7 +60,7 @@ @implementation EOAndQualifier (MAPIStoreRestrictionsPrivate) -- (BOOL) _evaluateMAPIFSMessageProperties: (NSDictionary *) properties +- (BOOL) _evaluateMAPIMemMessageProperties: (NSDictionary *) properties { NSUInteger i; BOOL rc; @@ -69,7 +69,7 @@ for (i = 0; rc && i < count; i++) rc = [[qualifiers objectAtIndex: i] - _evaluateMAPIFSMessageProperties: properties]; + _evaluateMAPIMemMessageProperties: properties]; return rc; } @@ -78,7 +78,7 @@ @implementation EOOrQualifier (MAPIStoreRestrictionsPrivate) -- (BOOL) _evaluateMAPIFSMessageProperties: (NSDictionary *) properties +- (BOOL) _evaluateMAPIMemMessageProperties: (NSDictionary *) properties { NSUInteger i; BOOL rc; @@ -87,7 +87,7 @@ for (i = 0; !rc && i < count; i++) rc = [[qualifiers objectAtIndex: i] - _evaluateMAPIFSMessageProperties: properties]; + _evaluateMAPIMemMessageProperties: properties]; return rc; } @@ -96,9 +96,9 @@ @implementation EONotQualifier (MAPIStoreRestrictionsPrivate) -- (BOOL) _evaluateMAPIFSMessageProperties: (NSDictionary *) properties +- (BOOL) _evaluateMAPIMemMessageProperties: (NSDictionary *) properties { - return ![qualifier _evaluateMAPIFSMessageProperties: properties]; + return ![qualifier _evaluateMAPIMemMessageProperties: properties]; } @end @@ -107,7 +107,7 @@ typedef BOOL (*EOComparator) (id, SEL, id); -- (BOOL) _evaluateMAPIFSMessageProperties: (NSDictionary *) properties +- (BOOL) _evaluateMAPIMemMessageProperties: (NSDictionary *) properties { id finalKey; id propValue; @@ -136,7 +136,7 @@ typedef BOOL (*EOComparator) (id, SEL, id); @implementation EOBitmaskQualifier (MAPIStoreRestrictionsPrivate) -- (BOOL) _evaluateMAPIFSMessageProperties: (NSDictionary *) properties +- (BOOL) _evaluateMAPIMemMessageProperties: (NSDictionary *) properties { NSNumber *propTag; id propValue; diff --git a/OpenChange/GNUmakefile b/OpenChange/GNUmakefile index 86ad9ab7d..9a62a65cd 100644 --- a/OpenChange/GNUmakefile +++ b/OpenChange/GNUmakefile @@ -34,6 +34,7 @@ $(SOGOBACKEND)_OBJC_FILES += \ MAPIStoreTypes.m \ MAPIStorePropertySelectors.m \ \ + SOGoMAPIMemMessage.m \ SOGoMAPIFSFolder.m \ SOGoMAPIFSMessage.m \ \ @@ -113,9 +114,8 @@ $(SOGOBACKEND)_OBJC_FILES += \ NSValue+MAPIStore.m \ \ EOBitmaskQualifier.m \ - EOQualifier+MAPIFS.m \ + EOQualifier+MAPIMem.m \ \ - SOGoMemMessage.m \ MAPIStoreMemMailMessage.m \ diff --git a/OpenChange/MAPIStoreFSFolder.m b/OpenChange/MAPIStoreFSFolder.m index 12c7db253..11344f291 100644 --- a/OpenChange/MAPIStoreFSFolder.m +++ b/OpenChange/MAPIStoreFSFolder.m @@ -27,7 +27,7 @@ #import #import #import -#import "EOQualifier+MAPIFS.h" +#import "EOQualifier+MAPIMem.h" #import "MAPIStoreFSFolderTable.h" #import "MAPIStoreFSMessage.h" #import "MAPIStoreFSMessageTable.h" @@ -138,7 +138,7 @@ static Class EOKeyValueQualifierK; subfolderKey = [entries objectAtIndex: count]; subfolder = [self lookupFolder: subfolderKey]; propertiesMessage = [subfolder propertiesMessage]; - if ([qualifier evaluateMAPIFSMessage: propertiesMessage]) + if ([qualifier evaluateMAPIMemMessage: propertiesMessage]) [filteredEntries addObject: subfolderKey]; } entries = filteredEntries; diff --git a/OpenChange/MAPIStoreMailFolder.m b/OpenChange/MAPIStoreMailFolder.m index 1c4c338fd..bfce3f5e1 100644 --- a/OpenChange/MAPIStoreMailFolder.m +++ b/OpenChange/MAPIStoreMailFolder.m @@ -58,7 +58,7 @@ /* Those are parts of a hack that enables creating mails to IMAP folders from Exchange properties */ -#import "SOGoMemMessage.h" +#import "SOGoMAPIMemMessage.h" #import "MAPIStoreMemMailMessage.h" #import "MAPIStoreMailFolder.h" @@ -995,9 +995,9 @@ _parseCOPYUID (NSString *line, NSArray **destUIDsP) - (MAPIStoreMessage *) createMessage { MAPIStoreDraftsMessage *newMessage; - SOGoMemMessage *newObject; + SOGoMAPIMemMessage *newObject; - newObject = [SOGoMemMessage + newObject = [SOGoMAPIMemMessage objectWithName: [SOGoObject globallyUniqueObjectId] inContainer: sogoObject]; newMessage diff --git a/OpenChange/MAPIStoreMemMailMessage.m b/OpenChange/MAPIStoreMemMailMessage.m index c6e5281b0..920835dd1 100644 --- a/OpenChange/MAPIStoreMemMailMessage.m +++ b/OpenChange/MAPIStoreMemMailMessage.m @@ -43,7 +43,7 @@ #import "MAPIStoreTypes.h" #import "NSObject+MAPIStore.h" #import "NSString+MAPIStore.h" -#import "SOGoMemMessage.h" +#import "SOGoMAPIMemMessage.h" #import "MAPIStoreMemMailMessage.h" diff --git a/OpenChange/SOGoMAPIFSFolder.m b/OpenChange/SOGoMAPIFSFolder.m index 7fa78ef67..3e584a115 100644 --- a/OpenChange/SOGoMAPIFSFolder.m +++ b/OpenChange/SOGoMAPIFSFolder.m @@ -29,7 +29,7 @@ #import -#import "EOQualifier+MAPIFS.h" +#import "EOQualifier+MAPIMem.h" #import "SOGoMAPIFSMessage.h" #import "SOGoMAPIFSFolder.h" @@ -242,7 +242,7 @@ static NSString *privateDir = nil; message = [self lookupName: messageKey inContext: nil acquire: NO]; - if ([qualifier evaluateMAPIFSMessage: message]) + if ([qualifier evaluateMAPIMemMessage: message]) [keys addObject: messageKey]; } } diff --git a/OpenChange/SOGoMAPIFSMessage.h b/OpenChange/SOGoMAPIFSMessage.h index d31d1cf28..7238eaaf7 100644 --- a/OpenChange/SOGoMAPIFSMessage.h +++ b/OpenChange/SOGoMAPIFSMessage.h @@ -23,19 +23,17 @@ #ifndef SOGOMAPIFSMESSAGE_H #define SOGOMAPIFSMESSAGE_H -#import +#import "SOGoMAPIMemMessage.h" -@class NSDictionary; -@class NSMutableDictionary; +@class NSCalendarDate; +@class NSString; -@interface SOGoMAPIFSMessage : SOGoObject +@interface SOGoMAPIFSMessage : SOGoMAPIMemMessage { - NSMutableDictionary *properties; + BOOL propertiesLoaded; NSString *completeFilename; } -- (NSDictionary *) properties; -- (void) appendProperties: (NSDictionary *) newProperties; - (void) save; - (NSString *) completeFilename; diff --git a/OpenChange/SOGoMAPIFSMessage.m b/OpenChange/SOGoMAPIFSMessage.m index bc2377121..971e6ba99 100644 --- a/OpenChange/SOGoMAPIFSMessage.m +++ b/OpenChange/SOGoMAPIFSMessage.m @@ -40,7 +40,7 @@ { if ((self = [super init])) { - properties = nil; + propertiesLoaded = NO; completeFilename = nil; } @@ -49,7 +49,6 @@ - (void) dealloc { - [properties release]; [completeFilename release]; [super dealloc]; } @@ -85,13 +84,13 @@ return completeFilename; } -- (NSDictionary *) properties +- (NSMutableDictionary *) properties { NSData *content; NSString *error; NSPropertyListFormat format; - if (!properties) + if (!propertiesLoaded) { content = [NSData dataWithContentsOfFile: [self completeFilename]]; if (content) @@ -105,22 +104,11 @@ [self logWithFormat: @"an error occurred during deserialization" @" of message: '%@'", error]; } - else - properties = nil; - if (!properties) - properties = [NSMutableDictionary new]; + + propertiesLoaded = YES; } - return properties; -} - -- (void) appendProperties: (NSDictionary *) newProperties -{ - // We ensure the current properties are loaded - [self properties]; - - // We merge the changes - [properties addEntriesFromDictionary: newProperties]; + return [super properties]; } - (void) save @@ -129,15 +117,16 @@ [container ensureDirectory]; - [self logWithFormat: @"%d props in whole dict", [properties count]]; + // [self logWithFormat: @"%d props in whole dict", [properties count]]; - content = [NSPropertyListSerialization dataFromPropertyList: properties - format: NSPropertyListBinaryFormat_v1_0 - errorDescription: NULL]; + content = [NSPropertyListSerialization + dataFromPropertyList: [self properties] + format: NSPropertyListBinaryFormat_v1_0 + errorDescription: NULL]; if (![content writeToFile: [self completeFilename] atomically: NO]) [NSException raise: @"MAPIStoreIOException" format: @"could not save message"]; - [self logWithFormat: @"fs message written to '%@'", [self completeFilename]]; + // [self logWithFormat: @"fs message written to '%@'", [self completeFilename]]; } - (NSString *) davEntityTag @@ -167,8 +156,8 @@ NSDictionary *attributes; attributes = [[NSFileManager defaultManager] - fileAttributesAtPath: [self completeFilename] - traverseLink: NO]; + fileAttributesAtPath: [self completeFilename] + traverseLink: NO]; return [attributes objectForKey: key]; } diff --git a/OpenChange/SOGoMemMessage.h b/OpenChange/SOGoMAPIMemMessage.h similarity index 77% rename from OpenChange/SOGoMemMessage.h rename to OpenChange/SOGoMAPIMemMessage.h index a24892533..0dca31586 100644 --- a/OpenChange/SOGoMemMessage.h +++ b/OpenChange/SOGoMAPIMemMessage.h @@ -1,4 +1,4 @@ -/* SOGoMemMessage.h - this file is part of SOGo +/* SOGoMAPIMemMessage.h - this file is part of SOGo * * Copyright (C) 2011 Inverse inc * @@ -20,19 +20,22 @@ * Boston, MA 02111-1307, USA. */ -#ifndef SOGOMEMMESSAGE_H -#define SOGOMEMMESSAGE_H +#ifndef SOGOMAPIMEMMESSAGE_H +#define SOGOMAPIMEMMESSAGE_H #import -@interface SOGoMemMessage : SOGoObject +@class NSDictionary; +@class NSMutableDictionary; + +@interface SOGoMAPIMemMessage : SOGoObject { NSMutableDictionary *properties; } -- (NSDictionary *) properties; +- (NSMutableDictionary *) properties; - (void) appendProperties: (NSDictionary *) newProperties; @end -#endif /* SOGOMEMMESSAGE_H */ +#endif /* SOGOMAPIMEMMESSAGE_H */ diff --git a/OpenChange/SOGoMemMessage.m b/OpenChange/SOGoMAPIMemMessage.m similarity index 78% rename from OpenChange/SOGoMemMessage.m rename to OpenChange/SOGoMAPIMemMessage.m index 1ad26e3b1..0ad83c259 100644 --- a/OpenChange/SOGoMemMessage.m +++ b/OpenChange/SOGoMAPIMemMessage.m @@ -1,4 +1,4 @@ -/* SOGoMemMessage.m - this file is part of SOGo +/* SOGoMAPIMemMessage.m - this file is part of SOGo * * Copyright (C) 2011 Inverse inc * @@ -22,15 +22,15 @@ #import -#import "SOGoMemMessage.h" +#import "SOGoMAPIMemMessage.h" -@implementation SOGoMemMessage +@implementation SOGoMAPIMemMessage - (id) init { if ((self = [super init])) { - properties = [NSMutableDictionary new]; + properties = nil; } return self; @@ -42,15 +42,17 @@ [super dealloc]; } -- (NSDictionary *) properties +- (NSMutableDictionary *) properties { + if (!properties) + properties = [NSMutableDictionary new]; + return properties; } - (void) appendProperties: (NSDictionary *) newProperties { - [properties addEntriesFromDictionary: newProperties]; + [[self properties] addEntriesFromDictionary: newProperties]; } - @end