Monotone-Parent: 6e98c1d612fcf5ba72a09cf9a2722a77ce287f05

Monotone-Revision: be2302dd882ba3fed4477d650f3f6d39f0eccad7

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2007-07-30T15:55:28
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Wolfgang Sourdeau
2007-07-30 15:55:28 +00:00
parent d5d47357fb
commit a66d823e76
7 changed files with 993 additions and 1010 deletions
+23 -18
View File
@@ -235,29 +235,34 @@ static BOOL useAltNamespace = NO;
inContext:_ctx];
}
- (id)lookupName:(NSString *)_key inContext:(id)_ctx acquire:(BOOL)_flag {
- (id) lookupName: (NSString *) _key
inContext: (id)_ctx
acquire: (BOOL) _flag
{
NSString *folderName;
id obj;
/* first check attributes directly bound to the application */
if ((obj = [super lookupName:_key inContext:_ctx acquire:NO]) != nil)
return obj;
if ([_key hasPrefix: @"folder"])
{
folderName = [_key substringFromIndex: 6];
// TODO: those should be product.plist bindings? (can't be class bindings
// though because they are 'per-account')
if ([_key isEqualToString: draftsFolderName]) {
if ((obj = [self lookupDraftsFolder:_key inContext:_ctx]) != nil)
return obj;
}
if ([_key isEqualToString: sieveFolderName]) {
if ((obj = [self lookupFiltersFolder:_key inContext:_ctx]) != nil)
return obj;
}
if ((obj = [self lookupImap4Folder:_key inContext:_ctx]) != nil)
return obj;
if ([folderName isEqualToString: draftsFolderName])
obj = [self lookupDraftsFolder: folderName inContext: _ctx];
else if ([folderName isEqualToString: sieveFolderName])
obj = [self lookupFiltersFolder: folderName inContext: _ctx];
else
obj = [self lookupImap4Folder: folderName inContext: _ctx];
}
else
obj = [super lookupName: _key inContext: _ctx acquire: NO];
/* return 404 to stop acquisition */
return [NSException exceptionWithHTTPStatus:404 /* Not Found */];
if (!obj)
obj = [NSException exceptionWithHTTPStatus: 404 /* Not Found */];
return obj;
}
/* special folders */
+3 -3
View File
@@ -33,13 +33,13 @@
The SOGoMailFolder maps to an IMAP4 folder from NGImap4.
*/
@class NSData, NSArray, NSException;
@class NSData, NSArray, NSException, NSMutableArray;
@class NGImap4MailboxInfo;
@interface SOGoMailFolder : SOGoMailBaseObject
{
NSArray *filenames;
NSString *folderType;
NSMutableArray *filenames;
NSString *folderType;
}
/* messages */
+33 -68
View File
@@ -151,34 +151,26 @@ static BOOL useAltNamespace = NO;
- (NSArray *) toOneRelationshipKeys
{
NSArray *uids;
unsigned count;
if (filenames != nil)
return [filenames isNotNull] ? filenames : nil;
NSArray *uids;
unsigned int count, max;
NSString *filename;
uids = [self fetchUIDsMatchingQualifier:nil sortOrdering:@"DATE"];
if ([uids isKindOfClass:[NSException class]])
return nil;
if ((count = [uids count]) == 0) {
filenames = [[NSArray alloc] init];
}
else {
NSMutableArray *keys;
unsigned i;
keys = [[NSMutableArray alloc] initWithCapacity:count];
for (i = 0; i < count; i++) {
NSString *k;
k = [[uids objectAtIndex:i] stringValue];
k = [k stringByAppendingString:@".mail"];
[keys addObject:k];
if (!filenames)
{
filenames = [NSMutableArray new];
uids = [self fetchUIDsMatchingQualifier: nil sortOrdering: @"DATE"];
if (![uids isKindOfClass: [NSException class]])
{
max = [uids count];
for (count = 0; count < max; count++)
{
filename = [NSString stringWithFormat: @"%@.mail",
[uids objectAtIndex: count]];
[filenames addObject: filename];
}
}
}
filenames = [keys copy];
[keys release];
}
return filenames;
}
@@ -230,27 +222,6 @@ static BOOL useAltNamespace = NO;
/* name lookup */
- (BOOL) isMessageKey: (NSString *) _key
inContext: (id) _ctx
{
/*
Every key starting with a digit is consider an IMAP4 message key. This is
not entirely correct since folders could also start with a number.
If we want to support folders beginning with numbers, we would need to
scan the folder list for the _key, which would make everything quite a bit
slower.
TODO: support this mode using a default.
*/
if ([_key length] == 0)
return NO;
if (isdigit([_key characterAtIndex:0]))
return YES;
return NO;
}
- (id) lookupImap4Folder: (NSString *) _key
inContext: (id) _ctx
{
@@ -291,28 +262,22 @@ static BOOL useAltNamespace = NO;
acquire: (BOOL) _acquire
{
id obj;
if ([self isMessageKey:_key inContext:_ctx]) {
/*
We assume here that _key is a number and methods are not and this is
moved above the super lookup since the super checks the
-toOneRelationshipKeys which in turn loads the message ids.
*/
return [self lookupImap4Message:_key inContext:_ctx];
}
obj = [self lookupImap4Folder:_key inContext:_ctx];
if (obj != nil)
return obj;
/* check attributes directly bound to the app */
if ((obj = [super lookupName:_key inContext:_ctx acquire:NO]))
return obj;
/* return 404 to stop acquisition */
return _acquire
? [NSException exceptionWithHTTPStatus:404 /* Not Found */]
: nil; /* hack to work with WebDAV move */
if ([_key hasPrefix: @"folder"])
obj = [self lookupImap4Folder: [_key substringFromIndex: 6]
inContext: _ctx];
else
{
if (isdigit ([_key characterAtIndex: 0]))
obj = [self lookupImap4Message: _key inContext: _ctx];
else
obj = [super lookupName: _key inContext: _ctx acquire: NO];
}
if (!obj && _acquire)
obj = [NSException exceptionWithHTTPStatus: 404 /* Not Found */];
return obj;
}
/* WebDAV */