diff --git a/ChangeLog b/ChangeLog index 3a60e3085..5c8705471 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2011-07-26 Wolfgang Sourdeau + + * OpenChange/MAPIStoreObject.m (-lookupChild:): removed method as + it was too generic. Each subclass has now its own set of + specialized methods. + + * OpenChange/MAPIStoreMessage.m (-lookupAttachment:): new method, + replacing -[MAPIStoreObject lookupChild:]. + + * OpenChange/MAPIStoreFolder.m (-lookupFolder:, -lookupMessage:) + (-lookupFAIMessage:): new methods, replacing -[MAPIStoreObject + lookupChild:]. + 2011-07-26 Francis Lachapelle * UI/MailerUI/UIxMailListActions.m diff --git a/OpenChange/MAPIStoreCalendarMessage.m b/OpenChange/MAPIStoreCalendarMessage.m index 024a4c50d..502bf410c 100644 --- a/OpenChange/MAPIStoreCalendarMessage.m +++ b/OpenChange/MAPIStoreCalendarMessage.m @@ -475,7 +475,7 @@ return attachmentKeys; } -- (id) lookupChild: (NSString *) childKey +- (id) lookupAttachment: (NSString *) childKey { return [attachmentParts objectForKey: childKey]; } diff --git a/OpenChange/MAPIStoreDraftsMessage.m b/OpenChange/MAPIStoreDraftsMessage.m index a05afe5a3..b55666492 100644 --- a/OpenChange/MAPIStoreDraftsMessage.m +++ b/OpenChange/MAPIStoreDraftsMessage.m @@ -167,7 +167,7 @@ e) [self _saveAttachment: [attachmentKeys objectAtIndex: count]]; } -- (id) lookupChild: (NSString *) childKey +- (id) lookupAttachment: (NSString *) childKey { return [attachmentParts objectForKey: childKey]; } diff --git a/OpenChange/MAPIStoreFSFolder.m b/OpenChange/MAPIStoreFSFolder.m index 81de081f6..5dd763154 100644 --- a/OpenChange/MAPIStoreFSFolder.m +++ b/OpenChange/MAPIStoreFSFolder.m @@ -153,9 +153,9 @@ static Class MAPIStoreFSMessageK; return folderKeys; } -- (id) lookupChild: (NSString *) childKey +- (id) lookupFolder: (NSString *) childKey { - id childObject; + id childObject = nil; SOGoMAPIFSFolder *childFolder; [self folderKeys]; @@ -166,8 +166,6 @@ static Class MAPIStoreFSMessageK; childObject = [MAPIStoreFSFolder mapiStoreObjectWithSOGoObject: childFolder inContainer: self]; } - else - childObject = [super lookupChild: childKey]; return childObject; } @@ -191,7 +189,7 @@ static Class MAPIStoreFSMessageK; max = [messageKeys count]; for (count = 0; count < max; count++) { - msg = [self lookupChild: [messageKeys objectAtIndex: count]]; + msg = [self lookupMessage: [messageKeys objectAtIndex: count]]; fileDate = [msg lastModificationTime]; if ([date laterDate: fileDate] == fileDate) { diff --git a/OpenChange/MAPIStoreFolder.h b/OpenChange/MAPIStoreFolder.h index 3185ef1a3..cd22ec93e 100644 --- a/OpenChange/MAPIStoreFolder.h +++ b/OpenChange/MAPIStoreFolder.h @@ -65,6 +65,7 @@ - (id) lookupFolder: (NSString *) folderKey; - (id) lookupFolderByURL: (NSString *) folderURL; - (id) lookupMessage: (NSString *) messageKey; +- (id) lookupFAIMessage: (NSString *) messageKey; - (id) lookupMessageByURL: (NSString *) messageURL; - (NSArray *) activeMessageTables; diff --git a/OpenChange/MAPIStoreFolder.m b/OpenChange/MAPIStoreFolder.m index 7c8e568d6..9fc0827c1 100644 --- a/OpenChange/MAPIStoreFolder.m +++ b/OpenChange/MAPIStoreFolder.m @@ -190,6 +190,25 @@ Class NSExceptionK, MAPIStoreFAIMessageK, MAPIStoreMessageTableK, MAPIStoreFAIMe MAPIStoreObject *childMessage = nil; SOGoObject *msgObject; + if (messageKey) + { + msgObject = [sogoObject lookupName: messageKey + inContext: nil + acquire: NO]; + if (msgObject && ![msgObject isKindOfClass: NSExceptionK]) + childMessage + = [[self messageClass] mapiStoreObjectWithSOGoObject: msgObject + inContainer: self]; + } + + return childMessage; +} + +- (id) lookupFAIMessage: (NSString *) messageKey +{ + MAPIStoreObject *childMessage = nil; + SOGoObject *msgObject; + if (messageKey) { [self faiMessageKeys]; @@ -202,16 +221,6 @@ Class NSExceptionK, MAPIStoreFAIMessageK, MAPIStoreMessageTableK, MAPIStoreFAIMe = [MAPIStoreFAIMessageK mapiStoreObjectWithSOGoObject: msgObject inContainer: self]; } - else - { - msgObject = [sogoObject lookupName: messageKey - inContext: nil - acquire: NO]; - if (msgObject && ![msgObject isKindOfClass: NSExceptionK]) - childMessage - = [[self messageClass] mapiStoreObjectWithSOGoObject: msgObject - inContainer: self]; - } } return childMessage; @@ -220,7 +229,7 @@ Class NSExceptionK, MAPIStoreFAIMessageK, MAPIStoreMessageTableK, MAPIStoreFAIMe - (id) lookupMessageByURL: (NSString *) childURL { MAPIStoreObject *foundObject = nil; - NSString *baseURL, *subURL; + NSString *baseURL, *subURL, *key; NSArray *parts; NSUInteger partsCount; @@ -235,7 +244,12 @@ Class NSExceptionK, MAPIStoreFAIMessageK, MAPIStoreMessageTableK, MAPIStoreFAIMe parts = [subURL componentsSeparatedByString: @"/"]; partsCount = [parts count]; if (partsCount == 1) - foundObject = [self lookupMessage: [parts objectAtIndex: 0]]; + { + key = [parts objectAtIndex: 0]; + foundObject = [self lookupFAIMessage: key]; + if (!foundObject) + foundObject = [self lookupMessage: key]; + } } } @@ -659,11 +673,6 @@ Class NSExceptionK, MAPIStoreFAIMessageK, MAPIStoreMessageTableK, MAPIStoreFAIMe folderKeys = nil; } -- (id) lookupChild: (NSString *) childKey -{ - return [self lookupMessage: childKey]; -} - - (int) getPrParentFid: (void **) data inMemCtx: (TALLOC_CTX *) memCtx { diff --git a/OpenChange/MAPIStoreMailFolder.m b/OpenChange/MAPIStoreMailFolder.m index 392e13734..550f5272c 100644 --- a/OpenChange/MAPIStoreMailFolder.m +++ b/OpenChange/MAPIStoreMailFolder.m @@ -250,9 +250,9 @@ static Class SOGoMailFolderK; return [MAPIStoreMailFolderTable tableForContainer: self]; } -- (id) lookupChild: (NSString *) childKey +- (id) lookupFolder: (NSString *) childKey { - id childObject; + id childObject = nil; SOGoMailFolder *childFolder; [self folderKeys]; @@ -263,8 +263,6 @@ static Class SOGoMailFolderK; childObject = [MAPIStoreMailFolder mapiStoreObjectWithSOGoObject: childFolder inContainer: self]; } - else - childObject = [super lookupChild: childKey]; return childObject; } diff --git a/OpenChange/MAPIStoreMailMessage.m b/OpenChange/MAPIStoreMailMessage.m index 3d58668d8..3037a55bd 100644 --- a/OpenChange/MAPIStoreMailMessage.m +++ b/OpenChange/MAPIStoreMailMessage.m @@ -1151,7 +1151,7 @@ _compareBodyKeysByPriority (id entry1, id entry2, void *data) andSortOrderings: sortOrderings]; } -- (id) lookupChild: (NSString *) childKey +- (id) lookupAttachment: (NSString *) childKey { MAPIStoreMailAttachment *attachment; SOGoMailBodyPart *currentPart; diff --git a/OpenChange/MAPIStoreMessage.h b/OpenChange/MAPIStoreMessage.h index b7a2dc254..15c3bb785 100644 --- a/OpenChange/MAPIStoreMessage.h +++ b/OpenChange/MAPIStoreMessage.h @@ -46,7 +46,9 @@ - (int) modifyRecipientsWithRows: (struct ModifyRecipientRow *) rows andCount: (NSUInteger) max; +- (id) lookupAttachment: (NSString *) childKey; +/* backend methods */ - (int) createAttachment: (MAPIStoreAttachment **) attachmentPtr inAID: (uint32_t *) aidPtr; - (int) getAttachment: (MAPIStoreAttachment **) attachmentPtr diff --git a/OpenChange/MAPIStoreMessage.m b/OpenChange/MAPIStoreMessage.m index 4257dc778..ebe537f73 100644 --- a/OpenChange/MAPIStoreMessage.m +++ b/OpenChange/MAPIStoreMessage.m @@ -271,6 +271,13 @@ return rc; } +- (id) lookupAttachment: (NSString *) childKey +{ + [self subclassResponsibility: _cmd]; + + return nil; +} + - (int) getAttachment: (MAPIStoreAttachment **) attachmentPtr withAID: (uint32_t) aid { @@ -282,7 +289,7 @@ andSortOrderings: nil]; if (aid < [keys count]) { - attachment = [self lookupChild: [keys objectAtIndex: aid]]; + attachment = [self lookupAttachment: [keys objectAtIndex: aid]]; if (attachment) { *attachmentPtr = attachment; diff --git a/OpenChange/MAPIStoreObject.h b/OpenChange/MAPIStoreObject.h index d7e784cd1..f54e8d7ad 100644 --- a/OpenChange/MAPIStoreObject.h +++ b/OpenChange/MAPIStoreObject.h @@ -126,7 +126,6 @@ - (NSDate *) creationTime; - (NSDate *) lastModificationTime; -- (id) lookupChild: (NSString *) childKey; - (NSArray *) childKeysMatchingQualifier: (EOQualifier *) qualifier andSortOrderings: (NSArray *) sortOrderings; diff --git a/OpenChange/MAPIStoreObject.m b/OpenChange/MAPIStoreObject.m index e153b3eb9..0ca52aef1 100644 --- a/OpenChange/MAPIStoreObject.m +++ b/OpenChange/MAPIStoreObject.m @@ -440,13 +440,6 @@ static Class NSExceptionK, MAPIStoreFolderK; return nil; } -- (id) lookupChild: (NSString *) childKey -{ - [self subclassResponsibility: _cmd]; - - return nil; -} - - (NSArray *) childKeysMatchingQualifier: (EOQualifier *) qualifier andSortOrderings: (NSArray *) sortOrderings {