/*
- Copyright (C) 2000-2005 SKYRIX Software AG
+ Copyright (C) 2000-2007 SKYRIX Software AG
This file is part of SOPE.
return YES;
}
-static NSDictionary *_parseBody(NGImap4ResponseParser *self);
+static NSDictionary *_parseBody(NGImap4ResponseParser *self,
+ BOOL isBodyStructure);
+static NSDictionary *_parseSingleBody(NGImap4ResponseParser *self,
+ BOOL isBodyStructure);
+static NSDictionary *_parseMultipartBody(NGImap4ResponseParser *self,
+ BOOL isBodyStructure);
+
static NSString *_parseBodyString(NGImap4ResponseParser *self,
BOOL _convertString);
static NSString *_parseBodyDecodeString(NGImap4ResponseParser *self,
BOOL _convertString,
BOOL _decode);
static NSDictionary *_parseBodyParameterList(NGImap4ResponseParser *self);
+static NSDictionary *_parseContentDisposition(NGImap4ResponseParser *self);
static NSArray *_parseAddressStructure(NGImap4ResponseParser *self);
static NSArray *_parseParenthesizedAddressList(NGImap4ResponseParser *self);
-static NSDictionary *_parseSingleBody(NGImap4ResponseParser *self);
-static NSDictionary *_parseMultipartBody(NGImap4ResponseParser *self);
static int _parseTaggedResponse(NGImap4ResponseParser *self,
NGMutableHashMap *result_);
static void _parseUntaggedResponse(NGImap4ResponseParser *self,
[self logWithFormat:@"ERROR: got no body content for key: '%@'",key];
}
else if ([key isEqualToString:@"body"]) {
- [fetch setObject:_parseBody(self) forKey:key];
+ [fetch setObject:_parseBody(self, NO) forKey:key];
+ }
+ else if ([key isEqualToString:@"bodystructure"]) {
+ [fetch setObject:_parseBody(self, YES) forKey:key];
}
else if ([key isEqualToString:@"flags"]) {
[fetch setObject:_parseFlagArray(self) forKey:key];
else
[self logWithFormat:@"ERROR: could not parse envelope!"];
}
- else if ([key isEqualToString:@"bodystructure"]) {
- // TODO: implement!
- NSException *e;
+// else if ([key isEqualToString:@"bodystructure"]) {
+// // TODO: implement!
+// NSException *e;
- e = [[NGImap4ParserException alloc]
- initWithFormat:@"bodystructure fetch result not yet supported!"];
- [self setLastException:[e autorelease]];
- return NO;
- }
+// e = [[NGImap4ParserException alloc]
+// initWithFormat:@"bodystructure fetch result not yet supported!"];
+// [self setLastException:[e autorelease]];
+// return NO;
+// }
else if ([key isEqualToString:@"internaldate"]) {
// TODO: implement!
NSException *e;
return list;
}
+static NSDictionary *_parseContentDisposition(NGImap4ResponseParser *self)
+{
+ NSMutableDictionary *disposition;
+ NSString *type;
+
+ disposition = [NSMutableDictionary dictionary];
+
+ if (_la(self, 0) == '(') {
+ _consume(self, 1);
+ type = _parseBodyString(self, YES);
+ [disposition setObject: type forKey: @"type"];
+ if (_la(self, 0) != ')') {
+ _consume(self, 1);
+ [disposition setObject: _parseBodyParameterList(self)
+ forKey: @"parameterList"];
+ }
+ _consume(self, 1);
+ }
+ else
+ _parseBodyString(self, YES);
+
+ return disposition;
+}
+
static NSArray *_parseAddressStructure(NGImap4ResponseParser *self) {
NSString *personalName, *sourceRoute, *mailboxName, *hostName;
return result;
}
-static NSDictionary *_parseSingleBody(NGImap4ResponseParser *self) {
+static NSDictionary *_parseSingleBody(NGImap4ResponseParser *self,
+ BOOL isBodyStructure) {
NSString *type, *subtype, *bodyId, *description,
- *encoding, *bodysize;
+ *encoding, *bodysize;
NSDictionary *parameterList;
NSMutableDictionary *dict;
[dict setObject:_parseBodyString(self, YES) forKey:@"messageId"];
_consumeIfMatch(self, ')');
_consumeIfMatch(self, ' ');
- [dict setObject:_parseBody(self) forKey:@"body"];
+ [dict setObject:_parseBody(self, isBodyStructure) forKey:@"body"];
_consumeIfMatch(self, ' ');
[dict setObject:_parseBodyString(self, YES) forKey:@"bodyLines"];
}
}
+
+ if (isBodyStructure) {
+ if (_la(self, 0) != ')') {
+ _consume(self,1);
+ [dict setObject: _parseBodyString(self, YES)
+ forKey: @"md5"];
+ if (_la(self, 0) != ')') {
+ _consume(self,1);
+ [dict setObject: _parseContentDisposition(self)
+ forKey: @"disposition"];
+ if (_la(self, 0) != ')') {
+ _consume(self,1);
+ if (_la(self, 0) == '(') {
+ [dict setObject: _parseBodyParameterList(self)
+ forKey: @"language"];
+ }
+ else {
+ [dict setObject: _parseBodyString(self, YES)
+ forKey: @"language"];
+ }
+ if (_la(self, 0) != ')') {
+ _consume(self,1);
+ [dict setObject: _parseBodyString(self, YES)
+ forKey: @"location"];
+ };
+ };
+ };
+ };
+ }
+
return dict;
}
-static NSDictionary *_parseMultipartBody(NGImap4ResponseParser *self) {
+static NSDictionary *_parseMultipartBody(NGImap4ResponseParser *self,
+ BOOL isBodyStructure) {
NSMutableArray *parts;
NSString *kind;
+ NSMutableDictionary *dict;
parts = [NSMutableArray arrayWithCapacity:4];
while (_la(self, 0) == '(') {
- [parts addObject:_parseBody(self)];
+ [parts addObject:_parseBody(self, isBodyStructure)];
}
_consumeIfMatch(self, ' ');
kind = _parseBodyString(self, YES);
- return [NSDictionary dictionaryWithObjectsAndKeys:
- parts, @"parts",
- @"multipart", @"type",
- kind , @"subtype", nil];
+ dict = [NSMutableDictionary dictionaryWithObjectsAndKeys:
+ parts, @"parts",
+ @"multipart", @"type",
+ kind , @"subtype", nil];
+ if (isBodyStructure) {
+ if (_la(self, 0) != ')') {
+ _consume(self,1);
+ [dict setObject: _parseBodyParameterList(self)
+ forKey: @"parameterList"];
+ if (_la(self, 0) != ')') {
+ _consume(self,1);
+ [dict setObject: _parseContentDisposition(self)
+ forKey: @"disposition"];
+ if (_la(self, 0) != ')') {
+ _consume(self,1);
+ if (_la(self, 0) == '(') {
+ [dict setObject: _parseBodyParameterList(self)
+ forKey: @"language"];
+ }
+ else {
+ [dict setObject: _parseBodyString(self, YES)
+ forKey: @"language"];
+ }
+ if (_la(self, 0) != ')') {
+ _consume(self,1);
+ [dict setObject: _parseBodyString(self, YES)
+ forKey: @"location"];
+ };
+ };
+ };
+ };
+ }
+
+ return dict;
}
-static NSDictionary *_parseBody(NGImap4ResponseParser *self) {
+static NSDictionary *_parseBody(NGImap4ResponseParser *self, BOOL isBodyStructure) {
NSDictionary *result;
_consumeIfMatch(self, '(');
if (_la(self, 0) == '(') {
- result = _parseMultipartBody(self);
+ result = _parseMultipartBody(self, isBodyStructure);
}
else {
- result = _parseSingleBody(self);
+ result = _parseSingleBody(self, isBodyStructure);
}
if (_la(self,0) != ')') {
NSString *str;