From: helge Date: Fri, 1 Oct 2004 00:11:30 +0000 (+0000) Subject: prepared message fetching X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e5582498d615f46ca1edc4db50a3210abff26c0f;p=scalable-opengroupware.org prepared message fetching git-svn-id: http://svn.opengroupware.org/SOGo/trunk@336 d1b88da0-ebda-0310-925b-ed51d893ca5b --- diff --git a/SOGo/SoObjects/Mailer/ChangeLog b/SOGo/SoObjects/Mailer/ChangeLog index 1c64918b..6d95d2ea 100644 --- a/SOGo/SoObjects/Mailer/ChangeLog +++ b/SOGo/SoObjects/Mailer/ChangeLog @@ -1,3 +1,13 @@ +2004-10-01 Helge Hess + + * v0.9.17 + + * SOGoMailFolder.m: -fetchUIDsMatchingQualifier:sortOrdering:range: was + added to retrieve message UIDs + + * SOGoMailManager.m: added method for fetching message ids with server + side sorting + 2004-09-30 Helge Hess * v0.9.16 diff --git a/SOGo/SoObjects/Mailer/SOGoMailFolder.h b/SOGo/SoObjects/Mailer/SOGoMailFolder.h index 373fbd7d..9febee95 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailFolder.h +++ b/SOGo/SoObjects/Mailer/SOGoMailFolder.h @@ -24,6 +24,7 @@ #define __Mailer_SOGoMailFolder_H__ #include +#import /* SOGoMailFolder @@ -33,10 +34,17 @@ The SOGoMailFolder maps to an IMAP4 folder from NGImap4. */ +@class NSArray; + @interface SOGoMailFolder : SOGoMailBaseObject { } +/* messages */ + +- (NSArray *)fetchUIDsMatchingQualifier:(id)_q sortOrdering:(id)_so + range:(NSRange)_r; + @end #endif /* __Mailer_SOGoMailFolder_H__ */ diff --git a/SOGo/SoObjects/Mailer/SOGoMailFolder.m b/SOGo/SoObjects/Mailer/SOGoMailFolder.m index 9f8d20c2..aae4b257 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailFolder.m +++ b/SOGo/SoObjects/Mailer/SOGoMailFolder.m @@ -40,6 +40,16 @@ password:[self imap4Password]]; } +/* messages */ + +- (NSArray *)fetchUIDsMatchingQualifier:(id)_q sortOrdering:(id)_so + range:(NSRange)_r +{ + return [[self mailManager] fetchUIDsInURL:[self imap4URL] + qualifier:_q sortOrdering:_so range:_r + password:[self imap4Password]]; +} + /* name lookup */ - (BOOL)isMessageKey:(NSString *)_key inContext:(id)_ctx { diff --git a/SOGo/SoObjects/Mailer/SOGoMailManager.h b/SOGo/SoObjects/Mailer/SOGoMailManager.h index 0cf0e229..f8ac7580 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailManager.h +++ b/SOGo/SoObjects/Mailer/SOGoMailManager.h @@ -23,6 +23,7 @@ #define __Mailer_SOGoMailManager_H__ #import +#import /* SOGoMailManager @@ -51,6 +52,11 @@ - (NSString *)imap4FolderNameForURL:(NSURL *)_url; - (NSArray *)subfoldersForURL:(NSURL *)_url password:(NSString *)_pwd; +/* messages */ + +- (NSArray *)fetchUIDsInURL:(NSURL *)_url qualifier:(id)_q + sortOrdering:(id)_so range:(NSRange)_range password:(NSString *)_pwd; + @end #endif /* __Mailer_SOGoMailManager_H__ */ diff --git a/SOGo/SoObjects/Mailer/SOGoMailManager.m b/SOGo/SoObjects/Mailer/SOGoMailManager.m index 8973495d..2912ea7f 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailManager.m +++ b/SOGo/SoObjects/Mailer/SOGoMailManager.m @@ -49,6 +49,7 @@ static BOOL debugOn = YES; static BOOL debugCache = NO; +static BOOL debugKeys = NO; static BOOL poolingOff = NO; static NSTimeInterval PoolScanInterval = 5 * 60; @@ -248,19 +249,19 @@ static NSTimeInterval PoolScanInterval = 5 * 60; /* Cyrus already tells us whether we need to check for children */ flags = [result objectForKey:folderName]; if ([flags containsObject:@"hasnochildren"]) { -#if 0 - [self debugWithFormat:@"folder %@ has no children.", folderName]; -#endif + if (debugKeys) + [self logWithFormat:@"folder %@ has no children.", folderName]; return nil; } - [self debugWithFormat:@"all keys %@: %@", folderName, [result allKeys]]; + if (debugKeys) + [self logWithFormat:@"all keys %@: %@", folderName, [result allKeys]]; names = [self _getDirectChildren:[result allKeys] folderName:folderName]; -#if 0 - [self debugWithFormat:@"subfolders of %@: %@", folderName, - [names componentsJoinedByString:@","]]; -#endif + if (debugKeys) { + [self debugWithFormat:@"subfolders of %@: %@", folderName, + [names componentsJoinedByString:@","]]; + } return names; } @@ -270,7 +271,7 @@ static NSTimeInterval PoolScanInterval = 5 * 60; NGImap4Client *client; NSDictionary *result; - if (debugOn) + if (debugKeys) [self debugWithFormat:@"subfolders for URL: %@ ...",[_url absoluteString]]; /* check cache */ @@ -327,6 +328,44 @@ static NSTimeInterval PoolScanInterval = 5 * 60; return [self extractSubfoldersForURL:_url fromResultSet:result]; } +/* messages */ + +- (NSArray *)fetchUIDsInURL:(NSURL *)_url qualifier:(id)_qualifier + sortOrdering:(id)_so range:(NSRange)_range password:(NSString *)_pwd +{ + /* + sortOrdering can be an NSString, an EOSortOrdering or an array of EOS. + */ + NGImap4Client *client; + NSDictionary *result; + NSArray *uids; + + if ((client = [self imap4ClientForURL:_url password:_pwd]) == nil) + return nil; + + result = [client select:[self imap4FolderNameForURL:_url]]; + if (![[result valueForKey:@"result"] boolValue]) { + [self logWithFormat:@"ERROR: could not select URL: %@", _url]; + return nil; + } + + result = [client sort:_so qualifier:_qualifier encoding:@"UTF-8"]; + if (![[result valueForKey:@"result"] boolValue]) { + [self logWithFormat:@"ERROR: could not sort contents of URL: %@", _url]; + return nil; + } + + uids = [result valueForKey:@"sort"]; + if (![uids isNotNull]) { + [self logWithFormat:@"ERROR: got no UIDs for URL: %@: %@", _url, result]; + return nil; + } + + // TODO: range + + return uids; +} + /* debugging */ - (BOOL)isDebuggingEnabled { diff --git a/SOGo/SoObjects/Mailer/Version b/SOGo/SoObjects/Mailer/Version index cf9e5c12..33dfbe1b 100644 --- a/SOGo/SoObjects/Mailer/Version +++ b/SOGo/SoObjects/Mailer/Version @@ -1,3 +1,3 @@ # $Id$ -SUBMINOR_VERSION:=15 +SUBMINOR_VERSION:=17 diff --git a/SOGo/UI/Mailer/UIxMailListView.m b/SOGo/UI/Mailer/UIxMailListView.m index 4816b73c..7893672e 100644 --- a/SOGo/UI/Mailer/UIxMailListView.m +++ b/SOGo/UI/Mailer/UIxMailListView.m @@ -31,7 +31,19 @@ @end #include "common.h" +#include +#include @implementation UIxMailListView -@end +- (id)defaultAction { + [self logWithFormat:@"default action ..."]; + + [self logWithFormat:@"UIDs: %@", + [[self clientObject] fetchUIDsMatchingQualifier:nil + sortOrdering:@"SUBJECT" + range:NSMakeRange(0, 1000000)]]; + return self; +} + +@end /* UIxMailListView */