From: helge Date: Sun, 3 Oct 2004 19:29:13 +0000 (+0000) Subject: minor cleanups X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ed42489a83e407c3453d56066ac4cb18ab85482b;p=sope minor cleanups git-svn-id: http://svn.opengroupware.org/SOPE/trunk@221 e4a50df8-12e2-0310-a44c-efbce7f8a7e3 --- diff --git a/sope-mime/NGImap4/NGImap4Folder.m b/sope-mime/NGImap4/NGImap4Folder.m index 75fd1741..45259d70 100644 --- a/sope-mime/NGImap4/NGImap4Folder.m +++ b/sope-mime/NGImap4/NGImap4Folder.m @@ -780,6 +780,9 @@ static int FetchNewUnseenMessagesInSubFoldersOnDemand = -1; } - (NSData *)blobForUid:(unsigned)_mUid part:(NSString *)_part { + /* + called by NGImap4Message -contentsOfPart: + */ NSDictionary *result; NSArray *fetchResults; NSString *bodyKey; diff --git a/sope-mime/NGImap4/NGImap4Message+BodyStructure.h b/sope-mime/NGImap4/NGImap4Message+BodyStructure.h index caa2eb73..388cca8e 100644 --- a/sope-mime/NGImap4/NGImap4Message+BodyStructure.h +++ b/sope-mime/NGImap4/NGImap4Message+BodyStructure.h @@ -18,12 +18,10 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - // $Id$ #ifndef __NGImap4Message_BodyStructure_H__ #define __NGImap4Message_BodyStructure_H__ - @interface NSCalendarDate(RFC822Dates) + (NSCalendarDate *)calendarDateWithRfc822DateString:(NSString *)_str; @end /* NSString(RFC822Dates) */ diff --git a/sope-mime/NGImap4/NGImap4Message.h b/sope-mime/NGImap4/NGImap4Message.h index 2a6d1034..ac911928 100644 --- a/sope-mime/NGImap4/NGImap4Message.h +++ b/sope-mime/NGImap4/NGImap4Message.h @@ -18,7 +18,6 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -// $Id$ #ifndef __Database_NGImap4_NGImap4Message_H__ #define __Database_NGImap4_NGImap4Message_H__ diff --git a/sope-mime/NGImap4/NGImap4Message.m b/sope-mime/NGImap4/NGImap4Message.m index 71c1b059..91e7dfa5 100644 --- a/sope-mime/NGImap4/NGImap4Message.m +++ b/sope-mime/NGImap4/NGImap4Message.m @@ -18,7 +18,6 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -// $Id$ #include "NGImap4Message.h" #include "NGImap4Folder.h" @@ -197,13 +196,14 @@ static BOOL ImapDebugEnabled = NO; if (_part == nil) _part = @""; + /* apparently caches the data for a part ID like "1.2.3" */ if (self->bodyStructureContent == nil) { self->bodyStructureContent = [[NSMutableDictionary alloc] initWithCapacity:8]; } if ((result = [self->bodyStructureContent objectForKey:_part]) == nil) { - if ((result = [self->folder blobForUid:self->uid part:_part])) + if ((result = [self->folder blobForUid:self->uid part:_part]) != nil) [self->bodyStructureContent setObject:result forKey:_part]; } return result; diff --git a/sope-mime/NGImap4/NGImap4ResponseNormalizer.m b/sope-mime/NGImap4/NGImap4ResponseNormalizer.m index 2f4f2e83..6605ee6a 100644 --- a/sope-mime/NGImap4/NGImap4ResponseNormalizer.m +++ b/sope-mime/NGImap4/NGImap4ResponseNormalizer.m @@ -279,7 +279,7 @@ static int LogImapEnabled = -1; 'uid' - UID 'msn' - message sequence number 'message' - RFC822 - 'body ' - (dictionary with bodystructure) + 'body' - (dictionary with bodystructure) This walks over all 'fetch' responses in the map and adds a 'normalized' dictionary for each response to the 'fetch' key of the normalized response diff --git a/sope-mime/NGImap4/NGImap4ResponseParser.m b/sope-mime/NGImap4/NGImap4ResponseParser.m index f40d8cd1..5c90312a 100644 --- a/sope-mime/NGImap4/NGImap4ResponseParser.m +++ b/sope-mime/NGImap4/NGImap4ResponseParser.m @@ -1205,6 +1205,7 @@ static BOOL _parseThreadResponse(NGImap4ResponseParser *self, } - (BOOL)_parseNumberUntaggedResponse:(NGMutableHashMap *)result_ { + NSMutableDictionary *fetch; NSNumber *number; NSString *key = nil; @@ -1212,97 +1213,104 @@ static BOOL _parseThreadResponse(NGImap4ResponseParser *self, return NO; _consumeIfMatch(self, ' '); + + if (!_matchesString(self, "FETCH ")) { + /* got a number request from select like exists or recent */ + key = _parseUntil(self, '\n'); + [result_ addObject:number forKey:[key lowercaseString]]; + return YES; + } - if (_matchesString(self, "FETCH ")) { - /* eg: "FETCH (FLAGS (\Seen) UID 5 RFC822.HEADER {2903}" */ - NSMutableDictionary *fetch; - - fetch = [[NSMutableDictionary alloc] initWithCapacity:10]; + /* eg: "FETCH (FLAGS (\Seen) UID 5 RFC822.HEADER {2903}" */ + fetch = [[NSMutableDictionary alloc] initWithCapacity:10]; - _consume(self, 6); /* "FETCH " */ - _consumeIfMatch(self, '('); - while (_la(self, 0) != ')') { /* until closing parent */ - NSString *key; + _consume(self, 6); /* "FETCH " */ + _consumeIfMatch(self, '('); + while (_la(self, 0) != ')') { /* until closing parent */ + NSString *key; - key = [_parseUntil(self, ' ') lowercaseString]; + key = [_parseUntil(self, ' ') lowercaseString]; #if 0 - [self logWithFormat:@"PARSE KEY: %@", key]; + [self logWithFormat:@"PARSE KEY: %@", key]; #endif - if ([key hasPrefix:@"body["]) { - NSDictionary *content; + if ([key hasPrefix:@"body["]) { + NSDictionary *content; - if ((content = [self _parseBodyContent]) != nil) - [fetch setObject:content forKey:key]; - else - [self logWithFormat:@"ERROR: got no body content for key: '%@'",key]; - } - else if ([key isEqualToString:@"body"]) { - [fetch setObject:_parseBody(self) forKey:key]; - } - else if ([key isEqualToString:@"flags"]) { - [fetch setObject:_parseFlagArray(self) forKey:key]; - } - else if ([key isEqualToString:@"uid"]) { - [fetch setObject:_parseUnsigned(self) forKey:key]; - } - else if ([key isEqualToString:@"rfc822.size"]) { - [fetch setObject:_parseUnsigned(self) forKey:key]; - } - else if ([key hasPrefix:@"rfc822"]) { - NSData *data; - - if (_la(self, 0) == '"') { - NSString *str; - _consume(self,1); - - str = _parseUntil(self, '"'); - data = [str dataUsingEncoding:defCStringEncoding]; - } - else - data = [self _parseData]; + if ((content = [self _parseBodyContent]) != nil) + [fetch setObject:content forKey:key]; + else + [self logWithFormat:@"ERROR: got no body content for key: '%@'",key]; + } + else if ([key isEqualToString:@"body"]) { + [fetch setObject:_parseBody(self) forKey:key]; + } + else if ([key isEqualToString:@"flags"]) { + [fetch setObject:_parseFlagArray(self) forKey:key]; + } + else if ([key isEqualToString:@"uid"]) { + [fetch setObject:_parseUnsigned(self) forKey:key]; + } + else if ([key isEqualToString:@"rfc822.size"]) { + [fetch setObject:_parseUnsigned(self) forKey:key]; + } + else if ([key hasPrefix:@"rfc822"]) { + NSData *data; + + if (_la(self, 0) == '"') { + NSString *str; + _consume(self,1); - if (data != nil) [fetch setObject:data forKey:key]; + str = _parseUntil(self, '"'); + data = [str dataUsingEncoding:defCStringEncoding]; } - else if ([key isEqualToString:@"envelope"]) { - id envelope; + else + data = [self _parseData]; - if ((envelope = [self _parseEnvelope]) != nil) - [fetch setObject:envelope forKey:key]; - else - [self logWithFormat:@"ERROR: could not parse envelope!"]; - } - else { - NSException *e; - - e = [[NGImap4ParserException alloc] initWithFormat: - @"unsupported fetch key: %@", - key]; - [self setLastException:[e autorelease]]; - return NO; - } - if (_la(self, 0) == ' ') - _consume(self, 1); + if (data != nil) [fetch setObject:data forKey:key]; } - if (fetch != nil) { - [fetch setObject:number forKey:@"msn"]; - [result_ addObject:fetch forKey:@"fetch"]; - _consume(self, 1); /* consume ')' */ - _consumeIfMatch(self, '\n'); + else if ([key isEqualToString:@"envelope"]) { + id envelope; + + if ((envelope = [self _parseEnvelope]) != nil) + [fetch setObject:envelope forKey:key]; + else + [self logWithFormat:@"ERROR: could not parse envelope!"]; } - else { /* no correct fetch line */ - _parseUntil(self, '\n'); + else if ([key isEqualToString:@"bodystructure"]) { + // TODO: implement! + NSException *e; + + e = [[NGImap4ParserException alloc] + initWithFormat:@"bodystructure not yet supported!"]; + [self setLastException:[e autorelease]]; + return NO; + } + else { + NSException *e; + + e = [[NGImap4ParserException alloc] initWithFormat: + @"unsupported fetch key: %@", + key]; + [self setLastException:[e autorelease]]; + return NO; } - [fetch release]; fetch = nil; - return YES; + if (_la(self, 0) == ' ') + _consume(self, 1); } - - { /* got a number request from select like exists or recent */ - key = _parseUntil(self, '\n'); - [result_ addObject:number forKey:[key lowercaseString]]; + if (fetch != nil) { + [fetch setObject:number forKey:@"msn"]; + [result_ addObject:fetch forKey:@"fetch"]; + _consume(self, 1); /* consume ')' */ + _consumeIfMatch(self, '\n'); + } + else { /* no correct fetch line */ + _parseUntil(self, '\n'); } + + [fetch release]; fetch = nil; return YES; -} + } static BOOL _parseGreetingsSieveResponse(NGImap4ResponseParser *self, NGMutableHashMap *result_)