From 8f083466d947c2e87368290f95d75bb08faed4b4 Mon Sep 17 00:00:00 2001 From: helge Date: Mon, 7 Feb 2005 01:07:03 +0000 Subject: [PATCH] improved special mail folders git-svn-id: http://svn.opengroupware.org/SOGo/trunk@520 d1b88da0-ebda-0310-925b-ed51d893ca5b --- SOGo/SoObjects/Mailer/ChangeLog | 10 +++++ SOGo/SoObjects/Mailer/SOGoMailAccount.h | 6 +++ SOGo/SoObjects/Mailer/SOGoMailAccount.m | 49 +++++++++++++++++++++++-- SOGo/SoObjects/Mailer/SOGoMailFolder.h | 3 +- SOGo/SoObjects/Mailer/SOGoMailFolder.m | 24 +++++++++++- SOGo/SoObjects/Mailer/Version | 2 +- 6 files changed, 86 insertions(+), 8 deletions(-) diff --git a/SOGo/SoObjects/Mailer/ChangeLog b/SOGo/SoObjects/Mailer/ChangeLog index 2578a09a..2d9d7440 100644 --- a/SOGo/SoObjects/Mailer/ChangeLog +++ b/SOGo/SoObjects/Mailer/ChangeLog @@ -1,3 +1,13 @@ +2005-02-07 Helge Hess + + * v0.9.67 + + * SOGoMailFolder.m: detect special folder names and return proper + folder type + + * SOGoMailAccount.m: made Sent/Trash folder name configurable using the + 'SOGoSentFolderName'/'SOGoTrashFolderName' defaults + 2005-02-06 Helge Hess * SOGoMailFolder.m, SOGoDraftsFolder.m: added proper folder classes diff --git a/SOGo/SoObjects/Mailer/SOGoMailAccount.h b/SOGo/SoObjects/Mailer/SOGoMailAccount.h index 20c30d6d..1c3b4ae6 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailAccount.h +++ b/SOGo/SoObjects/Mailer/SOGoMailAccount.h @@ -47,6 +47,12 @@ /* special folders */ +- (NSString *)inboxFolderNameInContext:(id)_ctx; +- (NSString *)draftsFolderNameInContext:(id)_ctx; +- (NSString *)sieveFolderNameInContext:(id)_ctx; +- (NSString *)sentFolderNameInContext:(id)_ctx; +- (NSString *)trashFolderNameInContext:(id)_ctx; + - (SOGoMailFolder *)inboxFolderInContext:(id)_ctx; - (SOGoMailFolder *)sentFolderInContext:(id)_ctx; - (SOGoMailFolder *)trashFolderInContext:(id)_ctx; diff --git a/SOGo/SoObjects/Mailer/SOGoMailAccount.m b/SOGo/SoObjects/Mailer/SOGoMailAccount.m index 658af71e..68c6ca8e 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailAccount.m +++ b/SOGo/SoObjects/Mailer/SOGoMailAccount.m @@ -27,10 +27,10 @@ @implementation SOGoMailAccount +static NSArray *rootFolderNames = nil; static NSString *inboxFolderName = @"INBOX"; static NSString *draftsFolderName = @"Drafts"; static NSString *sieveFolderName = @"Filters"; -static NSArray *rootFolderNames = nil; + (void)initialize { NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; @@ -159,6 +159,44 @@ static NSArray *rootFolderNames = nil; /* special folders */ +- (NSString *)inboxFolderNameInContext:(id)_ctx { + return inboxFolderName; /* cannot be changed in Cyrus ? */ +} +- (NSString *)draftsFolderNameInContext:(id)_ctx { + return draftsFolderName; /* SOGo managed folder */ +} +- (NSString *)sieveFolderNameInContext:(id)_ctx { + return sieveFolderName; /* SOGo managed folder */ +} +- (NSString *)sentFolderNameInContext:(id)_ctx { + /* OGo issue #1225 */ + static NSString *s = nil; + + if (s == nil) { + NSUserDefaults *ud; + + ud = [NSUserDefaults standardUserDefaults]; + s = [[ud stringForKey:@"SOGoSentFolderName"] copy]; + if ([s length] == 0) s = @"Sent"; + NSLog(@"Note: using SOGoSentFolderName: '%@'", s); + } + return s; +} +- (NSString *)trashFolderNameInContext:(id)_ctx { + /* OGo issue #1225 */ + static NSString *s = nil; + + if (s == nil) { + NSUserDefaults *ud; + + ud = [NSUserDefaults standardUserDefaults]; + s = [[ud stringForKey:@"SOGoTrashFolderName"] copy]; + if ([s length] == 0) s = @"Trash"; + NSLog(@"Note: using SOGoTrashFolderName: '%@'", s); + } + return s; +} + - (SOGoMailFolder *)inboxFolderInContext:(id)_ctx { // TODO: use some profile to determine real location, use a -traverse lookup SOGoMailFolder *folder; @@ -166,7 +204,8 @@ static NSArray *rootFolderNames = nil; if (self->inboxFolder != nil) return self->inboxFolder; - folder = [self lookupName:inboxFolderName inContext:_ctx acquire:NO]; + folder = [self lookupName:[self inboxFolderNameInContext:_ctx] + inContext:_ctx acquire:NO]; if ([folder isKindOfClass:[NSException class]]) return folder; return ((self->inboxFolder = [folder retain])); @@ -182,7 +221,8 @@ static NSArray *rootFolderNames = nil; folder = [self inboxFolderInContext:_ctx]; if ([folder isKindOfClass:[NSException class]]) return folder; - folder = [folder lookupName:@"Sent" inContext:_ctx acquire:NO]; + folder = [folder lookupName:[self sentFolderNameInContext:_ctx] + inContext:_ctx acquire:NO]; if ([folder isKindOfClass:[NSException class]]) return folder; if (![folder isNotNull]) { @@ -203,7 +243,8 @@ static NSArray *rootFolderNames = nil; folder = [self inboxFolderInContext:_ctx]; if ([folder isKindOfClass:[NSException class]]) return folder; - folder = [folder lookupName:@"Trash" inContext:_ctx acquire:NO]; + folder = [folder lookupName:[self trashFolderNameInContext:_ctx] + inContext:_ctx acquire:NO]; if ([folder isKindOfClass:[NSException class]]) return folder; if (![folder isNotNull]) { diff --git a/SOGo/SoObjects/Mailer/SOGoMailFolder.h b/SOGo/SoObjects/Mailer/SOGoMailFolder.h index ddb014d1..ffdd06f6 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailFolder.h +++ b/SOGo/SoObjects/Mailer/SOGoMailFolder.h @@ -37,7 +37,8 @@ @interface SOGoMailFolder : SOGoMailBaseObject { - NSArray *filenames; + NSArray *filenames; + NSString *folderType; } /* messages */ diff --git a/SOGo/SoObjects/Mailer/SOGoMailFolder.m b/SOGo/SoObjects/Mailer/SOGoMailFolder.m index 43a0e61a..2e559125 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailFolder.m +++ b/SOGo/SoObjects/Mailer/SOGoMailFolder.m @@ -21,13 +21,15 @@ #include "SOGoMailFolder.h" #include "SOGoMailObject.h" +#include "SOGoMailAccount.h" #include "SOGoMailManager.h" #include "common.h" @implementation SOGoMailFolder - (void)dealloc { - [self->filenames release]; + [self->filenames release]; + [self->folderType release]; [super dealloc]; } @@ -165,7 +167,25 @@ - (NSString *)outlookFolderClass { // TODO: detect Trash/Sent/Drafts folders - return @"IPF.Folder"; + SOGoMailAccount *account; + NSString *n; + + if (self->folderType != nil) + return self->folderType; + + account = [self mailAccountFolder]; + n = [self nameInContainer]; + + if ([n isEqualToString:[account trashFolderNameInContext:nil]]) + self->folderType = @"IPF.Trash"; + else if ([n isEqualToString:[account inboxFolderNameInContext:nil]]) + self->folderType = @"IPF.Inbox"; + else if ([n isEqualToString:[account sentFolderNameInContext:nil]]) + self->folderType = @"IPF.Sent"; + else + self->folderType = @"IPF.Folder"; + + return self->folderType; } /* operations */ diff --git a/SOGo/SoObjects/Mailer/Version b/SOGo/SoObjects/Mailer/Version index 37ff74e8..c5364fcf 100644 --- a/SOGo/SoObjects/Mailer/Version +++ b/SOGo/SoObjects/Mailer/Version @@ -1,6 +1,6 @@ # Version file -SUBMINOR_VERSION:=66 +SUBMINOR_VERSION:=67 # v0.9.55 requires NGExtensions v4.5.136 # v0.9.44 requires libNGMime v4.3.194 -- 2.39.5