From: helge Date: Thu, 11 Nov 2004 16:38:06 +0000 (+0000) Subject: added methods to retrieve full folder hierarchy X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f6ad4ee380b0fd47dc14939b58cc793f51cf7e7f;p=scalable-opengroupware.org added methods to retrieve full folder hierarchy git-svn-id: http://svn.opengroupware.org/SOGo/trunk@452 d1b88da0-ebda-0310-925b-ed51d893ca5b --- diff --git a/SOGo/SoObjects/Mailer/ChangeLog b/SOGo/SoObjects/Mailer/ChangeLog index 1554c9e2..f8130ddd 100644 --- a/SOGo/SoObjects/Mailer/ChangeLog +++ b/SOGo/SoObjects/Mailer/ChangeLog @@ -1,3 +1,12 @@ +2004-11-11 Helge Hess + + * v0.9.53 + + * SOGoMailAccounts.m: added -allFolderPathes methods to retrieve the + names of all folders associated with the account + + * SOGoMailManager.m: added -allFoldersForURL:password: method + 2004-11-09 Helge Hess * added support for toggling mail flags (v0.9.52) diff --git a/SOGo/SoObjects/Mailer/SOGoMailAccount.h b/SOGo/SoObjects/Mailer/SOGoMailAccount.h index 9d17b5e6..809e20a5 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailAccount.h +++ b/SOGo/SoObjects/Mailer/SOGoMailAccount.h @@ -34,10 +34,14 @@ password, etc) */ +@class NSArray; + @interface SOGoMailAccount : SOGoMailBaseObject { } +- (NSArray *)allFolderPathes; + @end #endif /* __Mailer_SOGoMailAccount_H__ */ diff --git a/SOGo/SoObjects/Mailer/SOGoMailAccount.m b/SOGo/SoObjects/Mailer/SOGoMailAccount.m index 9b2a52d2..f038287d 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailAccount.m +++ b/SOGo/SoObjects/Mailer/SOGoMailAccount.m @@ -22,6 +22,7 @@ #include "SOGoMailAccount.h" #include "SOGoMailFolder.h" +#include "SOGoMailManager.h" #include "SOGoDraftsFolder.h" #include "common.h" @@ -40,6 +41,15 @@ return self; } +- (NSArray *)allFolderPathes { + NSArray *pathes; + + pathes = [[self mailManager] allFoldersForURL:[self imap4URL] + password:[self imap4Password]]; + pathes = [pathes sortedArrayUsingSelector:@selector(compare:)]; + return pathes; +} + /* IMAP4 */ - (BOOL)useSSL { diff --git a/SOGo/SoObjects/Mailer/SOGoMailManager.h b/SOGo/SoObjects/Mailer/SOGoMailManager.h index ce9803f9..0c7d0a95 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailManager.h +++ b/SOGo/SoObjects/Mailer/SOGoMailManager.h @@ -53,6 +53,7 @@ - (NSString *)imap4Separator; - (NSString *)imap4FolderNameForURL:(NSURL *)_url; - (NSArray *)subfoldersForURL:(NSURL *)_url password:(NSString *)_pwd; +- (NSArray *)allFoldersForURL:(NSURL *)_url password:(NSString *)_pwd; /* messages */ diff --git a/SOGo/SoObjects/Mailer/SOGoMailManager.m b/SOGo/SoObjects/Mailer/SOGoMailManager.m index 58b62fb3..8616d275 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailManager.m +++ b/SOGo/SoObjects/Mailer/SOGoMailManager.m @@ -211,6 +211,10 @@ static NSString *imap4Separator = nil; /* folder hierarchy */ - (NSArray *)_getDirectChildren:(NSArray *)_array folderName:(NSString *)_fn { + /* + Scans string '_array' for strings which start with the string in '_fn'. + Then split on '/'. + */ NSMutableArray *ma; unsigned i, count, prefixlen; @@ -310,8 +314,12 @@ static NSString *imap4Separator = nil; return names; } +- (NSArray *)extractFoldersFromResultSet:(NSDictionary *)_result { + /* Note: the result is normalized, that is, it contains / as the separator */ + return [[_result valueForKey:@"list"] allKeys]; +} + - (NSArray *)subfoldersForURL:(NSURL *)_url password:(NSString *)_pwd { - // TODO: add caching SOGoMailConnectionEntry *entry; NSDictionary *result; @@ -326,7 +334,7 @@ static NSString *imap4Separator = nil; /* check hierarchy cache */ if ((result = [entry cachedHierarchyResults]) != nil) - return [self extractSubfoldersForURL:_url fromResultSet:result]; + return [self extractSubfoldersForURL:_url fromResultSet:result]; [self debugWithFormat:@" no folders cached yet .."]; @@ -356,6 +364,50 @@ static NSString *imap4Separator = nil; return [self extractSubfoldersForURL:_url fromResultSet:result]; } +- (NSArray *)allFoldersForURL:(NSURL *)_url password:(NSString *)_pwd { + SOGoMailConnectionEntry *entry; + NSDictionary *result; + + if (debugKeys) + [self debugWithFormat:@"folders for URL: %@ ...",[_url absoluteString]]; + + /* check connection cache */ + + if ((entry = [self entryForURL:_url password:_pwd]) == nil) + return nil; + + /* check hierarchy cache */ + + if ((result = [entry cachedHierarchyResults]) != nil) + return [self extractFoldersFromResultSet:result]; + + [self debugWithFormat:@" no folders cached yet .."]; + + /* fetch _all_ folders */ + + result = [[entry client] list:@"INBOX" pattern:@"*"]; + if (![[result valueForKey:@"result"] boolValue]) { + [self logWithFormat:@"ERROR: listing of folder failed!"]; + return nil; + } + + /* cache results */ + + if ([result isNotNull]) { + if (entry == nil) /* required in case the entry was not setup */ + entry = [self entryForURL:_url]; + + [entry cacheHierarchyResults:result]; + if (debugCache) { + [self logWithFormat:@"cached results in entry %@: 0x%08X(%d)", + entry, result, [result count]]; + } + } + + /* extract list */ + return [self extractFoldersFromResultSet:result]; +} + /* messages */ - (NSArray *)fetchUIDsInURL:(NSURL *)_url qualifier:(id)_qualifier diff --git a/SOGo/SoObjects/Mailer/Version b/SOGo/SoObjects/Mailer/Version index 1841728a..2f8d1724 100644 --- a/SOGo/SoObjects/Mailer/Version +++ b/SOGo/SoObjects/Mailer/Version @@ -1,6 +1,6 @@ # Version file -SUBMINOR_VERSION:=52 +SUBMINOR_VERSION:=53 # v0.9.44 requires NGMime v4.3.194 # v0.9.41 requires NGMime v4.3.190 diff --git a/SOGo/UI/Mailer/ChangeLog b/SOGo/UI/Mailer/ChangeLog index 3e65ac0c..c3317bce 100644 --- a/SOGo/UI/Mailer/ChangeLog +++ b/SOGo/UI/Mailer/ChangeLog @@ -1,3 +1,7 @@ +2004-11-11 Helge Hess + + * UIxMailListView.wox: added sample move popup (v0.9.62) + 2004-11-09 Helge Hess * UIxMailListView.m: added support for toggling read/unread flags diff --git a/SOGo/UI/Mailer/UIxMailListView.wox b/SOGo/UI/Mailer/UIxMailListView.wox index 1b035790..7ec09272 100644 --- a/SOGo/UI/Mailer/UIxMailListView.wox +++ b/SOGo/UI/Mailer/UIxMailListView.wox @@ -184,18 +184,22 @@ - + ---> + diff --git a/SOGo/UI/Mailer/UIxMailMoveToPopUp.wox b/SOGo/UI/Mailer/UIxMailMoveToPopUp.wox index bf1de0ca..ec331caa 100644 --- a/SOGo/UI/Mailer/UIxMailMoveToPopUp.wox +++ b/SOGo/UI/Mailer/UIxMailMoveToPopUp.wox @@ -14,11 +14,13 @@ checked="1" read="1" > + + \ No newline at end of file diff --git a/SOGo/UI/Mailer/Version b/SOGo/UI/Mailer/Version index be4c90df..04380832 100644 --- a/SOGo/UI/Mailer/Version +++ b/SOGo/UI/Mailer/Version @@ -1,6 +1,6 @@ # $Id$ -SUBMINOR_VERSION:=61 +SUBMINOR_VERSION:=62 # v0.9.50 requires NGMime v4.3.190 # v0.9.43 requires NGObjWeb v4.3.73