From 0abe1684b12ee67762693102be81362995bc0739 Mon Sep 17 00:00:00 2001 From: helge Date: Fri, 8 Oct 2004 14:27:37 +0000 Subject: [PATCH] more WebDAV tweaks git-svn-id: http://svn.opengroupware.org/SOGo/trunk@372 d1b88da0-ebda-0310-925b-ed51d893ca5b --- SOGo/SoObjects/Mailer/ChangeLog | 10 +++++++ SOGo/SoObjects/Mailer/SOGoMailFolder.h | 1 + SOGo/SoObjects/Mailer/SOGoMailFolder.m | 36 ++++++++++++++++++++++-- SOGo/SoObjects/Mailer/SOGoMailObject.m | 38 +++++++++++++++++++++----- SOGo/SoObjects/Mailer/Version | 2 +- 5 files changed, 77 insertions(+), 10 deletions(-) diff --git a/SOGo/SoObjects/Mailer/ChangeLog b/SOGo/SoObjects/Mailer/ChangeLog index 812f5849..7b0cddae 100644 --- a/SOGo/SoObjects/Mailer/ChangeLog +++ b/SOGo/SoObjects/Mailer/ChangeLog @@ -1,5 +1,15 @@ 2004-10-08 Helge Hess + * v0.9.30 + + * SOGoMailObject.m: added support for davContentLength, added + RFC822.SIZE to coreinfo attributes + + * SOGoMailFolder.m: added .mail path extensions to generated + toOneRelationshipKeys + + * SOGoMailObject.m: fixed body part id (starts with 1, not with 0) + * v0.9.29 * SOGoMailObject.m: added toOneRelationshipKeys/toManyRelationshipKeys diff --git a/SOGo/SoObjects/Mailer/SOGoMailFolder.h b/SOGo/SoObjects/Mailer/SOGoMailFolder.h index 4b622cab..3ec7f5df 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailFolder.h +++ b/SOGo/SoObjects/Mailer/SOGoMailFolder.h @@ -38,6 +38,7 @@ @interface SOGoMailFolder : SOGoMailBaseObject { + NSArray *filenames; } /* messages */ diff --git a/SOGo/SoObjects/Mailer/SOGoMailFolder.m b/SOGo/SoObjects/Mailer/SOGoMailFolder.m index b2104556..0bb25c35 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailFolder.m +++ b/SOGo/SoObjects/Mailer/SOGoMailFolder.m @@ -27,6 +27,11 @@ @implementation SOGoMailFolder +- (void)dealloc { + [self->filenames release]; + [super dealloc]; +} + /* IMAP4 */ - (NSString *)relativeImap4Name { @@ -40,8 +45,35 @@ 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 */ diff --git a/SOGo/SoObjects/Mailer/SOGoMailObject.m b/SOGo/SoObjects/Mailer/SOGoMailObject.m index d6505d28..2ea6d67c 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailObject.m +++ b/SOGo/SoObjects/Mailer/SOGoMailObject.m @@ -30,12 +30,16 @@ @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 { @@ -46,7 +50,7 @@ static NSArray *coreInfoKeys = nil; /* IMAP4 */ - (NSString *)relativeImap4Name { - return [self nameInContainer]; + return [[self nameInContainer] stringByDeletingPathExtension]; } /* hierarchy */ @@ -103,7 +107,7 @@ static NSArray *coreInfoKeys = nil; 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]; } @@ -133,7 +137,7 @@ static NSArray *coreInfoKeys = nil; 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; @@ -170,17 +174,25 @@ static NSArray *coreInfoKeys = 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]; @@ -234,4 +246,16 @@ static NSArray *coreInfoKeys = nil; 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 */ diff --git a/SOGo/SoObjects/Mailer/Version b/SOGo/SoObjects/Mailer/Version index 3631f8fc..d5906740 100644 --- a/SOGo/SoObjects/Mailer/Version +++ b/SOGo/SoObjects/Mailer/Version @@ -1,3 +1,3 @@ # $Id$ -SUBMINOR_VERSION:=29 +SUBMINOR_VERSION:=30 -- 2.39.5