#define __Mailer_SOGoMailManager_H__
#import <Foundation/NSObject.h>
+#import <Foundation/NSRange.h>
/*
SOGoMailManager
- (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__ */
static BOOL debugOn = YES;
static BOOL debugCache = NO;
+static BOOL debugKeys = NO;
static BOOL poolingOff = NO;
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;
}
NGImap4Client *client;
NSDictionary *result;
- if (debugOn)
+ if (debugKeys)
[self debugWithFormat:@"subfolders for URL: %@ ...",[_url absoluteString]];
/* check cache */
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 {
@end
#include "common.h"
+#include <NGImap4/NGImap4Client.h>
+#include <SOGo/SoObjects/Mailer/SOGoMailFolder.h>
@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 */