JSONify mail parts

This commit is contained in:
Francis Lachapelle
2015-05-12 22:37:58 -04:00
parent 6cd02043af
commit 9ed65e34ad
9 changed files with 215 additions and 103 deletions
+16 -4
View File
@@ -1,5 +1,5 @@
/*
Copyright (C) 2005-2014 Inverse inc.
Copyright (C) 2005-2015 Inverse inc.
This file is part of SOGo.
@@ -215,11 +215,14 @@ static NSString *mailETag = nil;
{
// TODO: I would prefer to flatten the body structure prior rendering,
// using some delegate to decide which parts to select for alternative.
id info;
id info, viewer;
info = [[self clientObject] bodyStructure];
return [[context mailRenderingContext] viewerForBodyInfo:info];
viewer = [[context mailRenderingContext] viewerForBodyInfo: info];
[viewer setBodyInfo: info];
return viewer;
}
/* actions */
@@ -232,10 +235,15 @@ static NSString *mailETag = nil;
NSArray *addresses;
SOGoMailObject *co;
UIxEnvelopeAddressFormatter *addressFormatter;
UIxMailRenderingContext *mctx;
co = [self clientObject];
addressFormatter = [context mailEnvelopeAddressFormatter];
mctx = [[UIxMailRenderingContext alloc] initWithViewer: self context: context];
[context pushMailRenderingContext: mctx];
[mctx release];
/* check etag to see whether we really must rerender */
/*
Note: There is one thing which *can* change for an existing message,
@@ -280,7 +288,7 @@ static NSString *mailETag = nil;
[self attachmentAttrs], @"attachmentAttrs",
[self shouldAskReceipt], @"shouldAskReceipt",
[NSNumber numberWithBool: [self mailIsDraft]], @"isDraft",
[[self generateResponse] contentAsString], @"content",
[[self contentViewerComponent] renderedPart], @"parts",
nil];
if ([self messageSubject])
[data setObject: [self messageSubject] forKey: @"subject"];
@@ -298,6 +306,10 @@ static NSString *mailETag = nil;
response = [self responseWithStatus: 200
andString: [data jsonRepresentation]];
[response setHeader: mailETag forKey: @"etag"];
[[context popMailRenderingContext] reset];
return response;
}