diff --git a/ChangeLog b/ChangeLog index e99f7f173..a2ec7f339 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,30 @@ 2007-10-31 Wolfgang Sourdeau + * SoObjects/Mailer/SOGoMailFolder.[hm]: added a new subclass of + SOGoMailFolder: SOGoMailSpecialFolder. + + * SoObjects/Mailer/SOGoMailAccount.m ([SOGoMailAccount + -traversalFromMailAccount]): overridden method that returns the + initialized mutable string. + ([SOGoMailAccount -allFolderPaths]): take the special folder paths + with -traversalFromMailAccount and reposition them at the + beginning of the list. By creating the special folders during that + request, we also make sure that the folder exists thanks to the + new initialisation method of the new "SOGoSpecialMailFolder" + class. + ([SOGoMailAccount -lookupSentFolder:_keyinContext:_ctx]): new + method. + ([SOGoMailAccount -lookupTrashFolder:_keyinContext:_ctx]): new + method. + ([SOGoMailAccount -lookupName:_keyinContext:acquire:_flag]): no + longer use lookupImap4Folder. + ([SOGoMailAccount -lookupImap4Folder:_keyinContext:_ctx]): removed + method. + + * SoObjects/Mailer/SOGoMailBaseObject.m ([SOGoMailBaseObject + -traversalFromMailAccount]): new method that returns the full + IMAP4 path to the object. + * SoObjects/SOGo/SOGoUser.m ([SOGoUser +initialize]): retain "superUsernames" after fetching it from the ud. diff --git a/SoObjects/Mailer/GNUmakefile b/SoObjects/Mailer/GNUmakefile index bd94d2e0e..82e9dfb1f 100644 --- a/SoObjects/Mailer/GNUmakefile +++ b/SoObjects/Mailer/GNUmakefile @@ -18,7 +18,10 @@ Mailer_OBJC_FILES += \ SOGoMailFolder.m \ SOGoSharedInboxFolder.m \ SOGoMailObject.m \ + SOGoDraftObject.m \ SOGoMailObject+Draft.m \ + SOGoSentFolder.m \ + SOGoDraftsFolder.m \ SOGoTrashFolder.m \ \ SOGoMailBodyPart.m \ @@ -27,9 +30,6 @@ Mailer_OBJC_FILES += \ SOGoCalendarMailBodyPart.m \ SOGoVCardMailBodyPart.m \ \ - SOGoDraftsFolder.m \ - SOGoDraftObject.m \ - \ SOGoMailForward.m \ \ NSData+Mail.m \ diff --git a/SoObjects/Mailer/SOGoDraftsFolder.h b/SoObjects/Mailer/SOGoDraftsFolder.h index ea97a6f61..4c260d12f 100644 --- a/SoObjects/Mailer/SOGoDraftsFolder.h +++ b/SoObjects/Mailer/SOGoDraftsFolder.h @@ -24,7 +24,7 @@ @class SOGoDraftObject; -@interface SOGoDraftsFolder : SOGoMailFolder +@interface SOGoDraftsFolder : SOGoSpecialMailFolder - (SOGoDraftObject *) newDraft; - (BOOL) isInDraftsFolder; diff --git a/SoObjects/Mailer/SOGoMailAccount.m b/SoObjects/Mailer/SOGoMailAccount.m index aa2f1d05c..25b99b70b 100644 --- a/SoObjects/Mailer/SOGoMailAccount.m +++ b/SoObjects/Mailer/SOGoMailAccount.m @@ -32,6 +32,7 @@ #import #import +#import #import #import "SOGoMailFolder.h" @@ -163,7 +164,7 @@ static NSString *otherUsersFolderName = @""; // TODO: add English default [folders removeObjectsInArray: additionalFolders]; [folders addObjectsFromArray: additionalFolders]; } - + return folders; } @@ -178,13 +179,21 @@ static NSString *otherUsersFolderName = @""; // TODO: add English default { NSMutableArray *newFolders; NSArray *rawFolders, *mainFolders; + NSString *realDraftsFolderName, *realSentFolderName, *realTrashFolderName; - rawFolders = [[self imap4Connection] - allFoldersForURL: [self imap4URL]]; + rawFolders = [[self imap4Connection] allFoldersForURL: [self imap4URL]]; -#warning FIXME: the folder names should be prefixed - mainFolders = [NSArray arrayWithObjects: inboxFolderName, draftsFolderName, - sentFolder, trashFolder, nil]; + realDraftsFolderName + = [[self draftsFolderInContext: context] traversalFromMailAccount]; + realSentFolderName + = [[self sentFolderInContext: context] traversalFromMailAccount]; + realTrashFolderName + = [[self trashFolderInContext: context] traversalFromMailAccount]; + + mainFolders = [NSArray arrayWithObjects: inboxFolderName, + realDraftsFolderName, + realSentFolderName, + realTrashFolderName, nil]; newFolders = [NSMutableArray arrayWithArray: rawFolders]; [newFolders removeObjectsInArray: mainFolders]; [newFolders sortUsingSelector: @selector (caseInsensitiveCompare:)]; @@ -247,6 +256,11 @@ static NSString *otherUsersFolderName = @""; // TODO: add English default return urlString; } +- (NSMutableString *) traversalFromMailAccount +{ + return [NSMutableString string]; +} + - (NSString *) imap4Login { return [[self imap4URL] user]; @@ -274,15 +288,11 @@ static NSString *otherUsersFolderName = @""; // TODO: add English default return folder; } -- (id) lookupImap4Folder: (NSString *) _key - inContext: (id) _cx +- (id) lookupSentFolder: (NSString *) _key + inContext: (id) _ctx { - NSString *s; - - s = [_key isEqualToString: [self trashFolderNameInContext:_cx]] - ? @"SOGoTrashFolder" : @"SOGoMailFolder"; - - return [self lookupFolder:_key ofClassNamed:s inContext:_cx]; + return [self lookupFolder: _key ofClassNamed: @"SOGoSentFolder" + inContext: _ctx]; } - (id) lookupDraftsFolder: (NSString *) _key @@ -292,6 +302,13 @@ static NSString *otherUsersFolderName = @""; // TODO: add English default inContext: _ctx]; } +- (id) lookupTrashFolder: (NSString *) _key + inContext: (id) _ctx +{ + return [self lookupFolder: _key ofClassNamed: @"SOGoTrashFolder" + inContext: _ctx]; +} + - (id) lookupFiltersFolder: (NSString *) _key inContext: (id) _ctx { return [self lookupFolder:_key ofClassNamed:@"SOGoSieveScriptsFolder" @@ -308,12 +325,17 @@ static NSString *otherUsersFolderName = @""; // TODO: add English default { // TODO: those should be product.plist bindings? (can't be class bindings // though because they are 'per-account') - if ([_key isEqualToString: [self draftsFolderNameInContext: _ctx]]) + if ([_key isEqualToString: [self sentFolderNameInContext: _ctx]]) + obj = [self lookupSentFolder: _key inContext: _ctx]; + else if ([_key isEqualToString: [self draftsFolderNameInContext: _ctx]]) obj = [self lookupDraftsFolder: _key inContext: _ctx]; - else if ([_key isEqualToString: [self sieveFolderNameInContext: _ctx]]) - obj = [self lookupFiltersFolder: _key inContext: _ctx]; + else if ([_key isEqualToString: [self trashFolderNameInContext: _ctx]]) + obj = [self lookupTrashFolder: _key inContext: _ctx]; +// else if ([_key isEqualToString: [self sieveFolderNameInContext: _ctx]]) +// obj = [self lookupFiltersFolder: _key inContext: _ctx]; else - obj = [self lookupImap4Folder: _key inContext: _ctx]; + obj = [self lookupFolder: _key ofClassNamed: @"SOGoMailFolder" + inContext: _ctx]; } else obj = [super lookupName: _key inContext: _ctx acquire: NO]; diff --git a/SoObjects/Mailer/SOGoMailBaseObject.h b/SoObjects/Mailer/SOGoMailBaseObject.h index ec2d8baaa..1faecb77f 100644 --- a/SoObjects/Mailer/SOGoMailBaseObject.h +++ b/SoObjects/Mailer/SOGoMailBaseObject.h @@ -64,6 +64,7 @@ - (NSString *) relativeImap4Name; - (NSMutableString *) imap4URLString; +- (NSMutableString *) traversalFromMailAccount; - (NSURL *) imap4URL; - (NSString *) imap4Login; diff --git a/SoObjects/Mailer/SOGoMailBaseObject.m b/SoObjects/Mailer/SOGoMailBaseObject.m index e6c2260d4..60d6c22ae 100644 --- a/SoObjects/Mailer/SOGoMailBaseObject.m +++ b/SoObjects/Mailer/SOGoMailBaseObject.m @@ -186,6 +186,16 @@ static BOOL debugOn = YES; return [[self authenticatorInContext: context] passwordInContext: context]; } +- (NSMutableString *) traversalFromMailAccount +{ + NSMutableString *currentTraversal; + + currentTraversal = [container traversalFromMailAccount]; + [currentTraversal appendFormat: @"/%@", [self relativeImap4Name]]; + + return currentTraversal; +} + - (void)flushMailCaches { [[self mailManager] flushCachesForURL:[self imap4URL]]; } diff --git a/SoObjects/Mailer/SOGoMailFolder.h b/SoObjects/Mailer/SOGoMailFolder.h index 3de6f3ee8..6ad7defa9 100644 --- a/SoObjects/Mailer/SOGoMailFolder.h +++ b/SoObjects/Mailer/SOGoMailFolder.h @@ -67,9 +67,17 @@ - (NSArray *) subfolders; +- (BOOL) isSpecialFolder; + - (NSArray *) allFolderPaths; - (NSArray *) allFolderURLs; @end +@interface SOGoSpecialMailFolder : SOGoMailFolder + +- (BOOL) isSpecialFolder; + +@end + #endif /* __Mailer_SOGoMailFolder_H__ */ diff --git a/SoObjects/Mailer/SOGoMailFolder.m b/SoObjects/Mailer/SOGoMailFolder.m index ec66e3669..15f5b660b 100644 --- a/SoObjects/Mailer/SOGoMailFolder.m +++ b/SoObjects/Mailer/SOGoMailFolder.m @@ -133,6 +133,11 @@ static NSString *defaultUserID = @"anyone"; return [[self imap4Connection] subfoldersForURL: [self imap4URL]]; } +- (BOOL) isSpecialFolder +{ + return NO; +} + - (NSArray *) allFolderPaths { NSMutableArray *deepSubfolders; @@ -688,3 +693,26 @@ static NSString *defaultUserID = @"anyone"; } @end /* SOGoMailFolder */ + +@implementation SOGoSpecialMailFolder + +- (id) initWithName: (NSString *) newName + inContainer: (id) newContainer +{ + if ((self = [super initWithName: newName + inContainer: newContainer])) + { + if (![[self imap4Connection] doesMailboxExistAtURL: [self imap4URL]]) + [imap4 createMailbox: [self relativeImap4Name] + atURL: [newContainer imap4URL]]; + } + + return self; +} + +- (BOOL) isSpecialFolder +{ + return YES; +} + +@end diff --git a/SoObjects/Mailer/SOGoSentFolder.h b/SoObjects/Mailer/SOGoSentFolder.h new file mode 100644 index 000000000..18c360fe0 --- /dev/null +++ b/SoObjects/Mailer/SOGoSentFolder.h @@ -0,0 +1,30 @@ +/* + Copyright (C) 2005 SKYRIX Software AG + + This file is part of OpenGroupware.org. + + OGo is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. + + OGo is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with OGo; see the file COPYING. If not, write to the + Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. +*/ + +#ifndef __Mailer_SOGoSentFolder_H__ +#define __Mailer_SOGoSentFolder_H__ + +#import "SOGoMailFolder.h" + +@interface SOGoSentFolder : SOGoSpecialMailFolder +@end + +#endif /* __Mailer_SOGoSentFolder_H__ */ diff --git a/SoObjects/Mailer/SOGoSentFolder.m b/SoObjects/Mailer/SOGoSentFolder.m new file mode 100644 index 000000000..92648a793 --- /dev/null +++ b/SoObjects/Mailer/SOGoSentFolder.m @@ -0,0 +1,34 @@ +/* + Copyright (C) 2005 SKYRIX Software AG + + This file is part of OpenGroupware.org. + + OGo is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. + + OGo is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with OGo; see the file COPYING. If not, write to the + Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. +*/ + +#import + +#import "SOGoSentFolder.h" + +@implementation SOGoSentFolder + +/* folder type */ + +- (NSString *)outlookFolderClass { + return @"IPF.Sent"; +} + +@end /* SOGoSentFolder */ diff --git a/SoObjects/Mailer/SOGoTrashFolder.h b/SoObjects/Mailer/SOGoTrashFolder.h index d097490a4..5d14947f1 100644 --- a/SoObjects/Mailer/SOGoTrashFolder.h +++ b/SoObjects/Mailer/SOGoTrashFolder.h @@ -24,7 +24,7 @@ #import "SOGoMailFolder.h" -@interface SOGoTrashFolder : SOGoMailFolder +@interface SOGoTrashFolder : SOGoSpecialMailFolder @end #endif /* __Mailer_SOGoTrashFolder_H__ */