mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-10-11 23:07:12 +00:00
Monotone-Parent: 18f239a3de0b7ac267996e840fa462638dadaf29
Monotone-Revision: 7bd51d30db3d6ece97902530cd9a95f45334a530 Monotone-Author: flachapelle@inverse.ca Monotone-Date: 2007-12-10T22:34:12 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
1 parent
bc548c963c
commit
bb8e7c71ff
7 files changed
+55
-17
No files matched your search
@@ -41,6 +41,7 @@
|
||||
NSArray *pathToPart;
|
||||
NSString *identifier;
|
||||
id partInfo;
|
||||
BOOL asAttachment;
|
||||
}
|
||||
|
||||
/* hierarchy */
|
||||
@@ -57,6 +58,8 @@
|
||||
|
||||
- (id) partInfo;
|
||||
- (NSData *) fetchBLOB;
|
||||
- (void) setAsAttachment;
|
||||
- (BOOL) asAttachment;
|
||||
|
||||
/* factory */
|
||||
|
||||
|
||||
@@ -63,13 +63,28 @@ static BOOL debugOn = NO;
|
||||
NSLog(@"Note(SOGoMailBodyPart): etag caching disabled!");
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
- (id) init
|
||||
{
|
||||
if ((self = [super init]))
|
||||
asAttachment = NO;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
[self->partInfo release];
|
||||
[self->identifier release];
|
||||
[self->pathToPart release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void) setAsAttachment
|
||||
{
|
||||
asAttachment = YES;
|
||||
}
|
||||
|
||||
|
||||
/* hierarchy */
|
||||
|
||||
- (SOGoMailObject *)mailObject {
|
||||
@@ -178,6 +193,8 @@ static BOOL debugOn = NO;
|
||||
/* lookup body part */
|
||||
if ([self isBodyPartKey:_key inContext:_ctx])
|
||||
obj = [self lookupImap4BodyPartKey:_key inContext:_ctx];
|
||||
else if ([_key isEqualToString: @"asAttachment"])
|
||||
[self setAsAttachment];
|
||||
/* should check whether such a filename exist in the attached names */
|
||||
if (!obj)
|
||||
obj = self;
|
||||
@@ -283,14 +300,18 @@ static BOOL debugOn = NO;
|
||||
|
||||
/* try type from body structure info */
|
||||
|
||||
parts = [self contentTypeForBodyPartInfo: [self partInfo]];
|
||||
contentType = [[parts componentsSeparatedByString: @";"] objectAtIndex: 0];
|
||||
|
||||
if (![contentType length])
|
||||
{
|
||||
extension = [[self nameInContainer] pathExtension];
|
||||
contentType = [self contentTypeForPathExtension: extension];
|
||||
}
|
||||
if (asAttachment)
|
||||
contentType = @"application/octet-stream";
|
||||
else {
|
||||
parts = [self contentTypeForBodyPartInfo: [self partInfo]];
|
||||
contentType = [[parts componentsSeparatedByString: @";"] objectAtIndex: 0];
|
||||
|
||||
if (![contentType length])
|
||||
{
|
||||
extension = [[self nameInContainer] pathExtension];
|
||||
contentType = [self contentTypeForPathExtension: extension];
|
||||
}
|
||||
}
|
||||
|
||||
return contentType;
|
||||
}
|
||||
@@ -301,7 +322,7 @@ static BOOL debugOn = NO;
|
||||
NSException *error;
|
||||
WOResponse *r;
|
||||
NSData *data;
|
||||
NSString *etag, *mimeType;
|
||||
NSString *etag, *mimeType, *fileName;
|
||||
|
||||
if ((error = [self matchesRequestConditionInContext:_ctx]) != nil) {
|
||||
// TODO: currently we fetch the body structure to get here - check this!
|
||||
@@ -333,6 +354,17 @@ static BOOL debugOn = NO;
|
||||
[r setHeader: mimeType forKey:@"content-type"];
|
||||
[r setHeader: [NSString stringWithFormat:@"%d", [data length]]
|
||||
forKey: @"content-length"];
|
||||
|
||||
if (asAttachment) {
|
||||
fileName = [[[self partInfo] objectForKey: @"parameterList"] objectForKey: @"name"];
|
||||
if (!fileName)
|
||||
fileName = [[[[self partInfo] objectForKey: @"disposition"]
|
||||
objectForKey: @"parameterList"]
|
||||
objectForKey: @"filename"];
|
||||
if ([fileName length])
|
||||
[r setHeader: [NSString stringWithFormat: @"attachment; filename=%@", fileName]
|
||||
forKey: @"content-disposition"];
|
||||
}
|
||||
|
||||
if ((etag = [self davEntityTag]) != nil)
|
||||
[r setHeader:etag forKey:@"etag"];
|
||||
|
||||
Reference in new issue
Block a user