@implementation SOGoMailFolder
+- (void)dealloc {
+ [self->filenames release];
+ [super dealloc];
+}
+
/* IMAP4 */
- (NSString *)relativeImap4Name {
password:[self imap4Password]];
}
- (NSArray *)toOneRelationshipKeys {
- return [[self fetchUIDsMatchingQualifier:nil sortOrdering:@"DATE"]
- valueForKey:@"stringValue"];
+ NSArray *uids;
+ unsigned count;
+
+ if (self->filenames != nil)
+ return [self->filenames isNotNull] ? self->filenames : nil;
+
+ uids = [self fetchUIDsMatchingQualifier:nil sortOrdering:@"DATE"];
+ if ([uids isKindOfClass:[NSException class]])
+ return nil;
+
+ if ((count = [uids count]) == 0) {
+ self->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]
+ stringByAppendingString:@".mail"];
+ [keys addObject:k];
+ }
+ self->filenames = [keys copy];
+ [keys release];
+ }
+ return self->filenames;
}
/* messages */
@implementation SOGoMailObject
static NSArray *coreInfoKeys = nil;
+static BOOL heavyDebug = NO;
+ (void)initialize {
/* Note: see SOGoMailManager.m for allowed IMAP4 keys */
/* Note: "BODY" actually returns the structure! */
coreInfoKeys = [[NSArray alloc] initWithObjects:
- @"FLAGS", @"ENVELOPE", @"BODY", nil];
+ @"FLAGS", @"ENVELOPE", @"BODY",
+ @"RFC822.SIZE",
+ // not yet supported: @"INTERNALDATE",
+ nil];
}
- (void)dealloc {
/* IMAP4 */
- (NSString *)relativeImap4Name {
- return [self nameInContainer];
+ return [[self nameInContainer] stringByDeletingPathExtension];
}
/* hierarchy */
ma = [NSMutableArray arrayWithCapacity:count - i];
ext = [self keyExtensionForPart:part];
- key = [[NSString alloc] initWithFormat:@"%d%@", i, ext?ext:@""];
+ key = [[NSString alloc] initWithFormat:@"%d%@", i + 1, ext?ext:@""];
[ma addObject:key];
[key release];
}
return [self->coreInfos isNotNull] ? self->coreInfos : nil;
msgs = [[self clientObject] fetchParts:coreInfoKeys]; // returns dict
- // [self logWithFormat:@"M: %@", msgs];
+ if (heavyDebug) [self logWithFormat:@"M: %@", msgs];
msgs = [msgs valueForKey:@"fetch"];
if ([msgs count] == 0)
return nil;
NSString *p;
id info;
- info = [self bodyStructure];
+ if ((info = [self bodyStructure]) == nil) {
+ [self logWithFormat:@"ERROR: got no body part structure!"];
+ return nil;
+ }
+
+ /* for each path component, eg 1,1,3 */
pe = [_path objectEnumerator];
- while ((p = [pe nextObject])) {
+ while ((p = [pe nextObject]) != nil && [info isNotNull]) {
unsigned idx;
NSArray *parts;
+ [self logWithFormat:@"check PATH: %@", p];
idx = [p intValue] - 1;
parts = [info valueForKey:@"parts"];
if (idx >= [parts count]) {
- [self logWithFormat:@"ERROR: body part index out of bounds: %d", idx+1];
+ [self logWithFormat:
+ @"ERROR: body part index out of bounds(%d vs %d): %@",
+ (idx + 1), [parts count], info];
return nil;
}
info = [parts objectAtIndex:idx];
return NO;
}
+- (id)davContentLength {
+ return [[self fetchCoreInfos] valueForKey:@"size"];
+}
+
+- (NSDate *)davCreationDate {
+ // TODO: use INTERNALDATE once NGImap4 supports that
+ return nil;
+}
+- (NSDate *)davLastModified {
+ return [self davCreationDate];
+}
+
@end /* SOGoMailObject */