aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/objc/abstract/MCOHTMLRendererDelegate.h
blob: eb62cb75046b394b5831a7bca54707abe4eaf6e9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
//
//  MCOHTMLRendererDelegate.h
//  mailcore2
//
//  Created by DINH Viêt Hoà on 3/23/13.
//  Copyright (c) 2013 MailCore. All rights reserved.
//

#ifndef MAILCORE_MCOHTMLRENDERERDELEGATE_H

#define MAILCORE_MCOHTMLRENDERERDELEGATE_H

#import <Foundation/Foundation.h>

/** This delegate protocol is used to help rendering of the message.

 It will be used for the following methods.

 [MCOMessageParser htmlRenderingWithDelegate:],

 [MCOMessageBuilder htmlRenderingWithDelegate:]

 -[MCOIMAPMessage htmlRenderingWithFolder:delegate:]
*/

@class MCOAbstractPart;
@class MCOAbstractMessage;
@class MCOMessageHeader;
@class MCOAbstractMessagePart;

@protocol MCOHTMLRendererDelegate <NSObject>

/** All methods are optional.*/
@optional

/** This delegate method should return YES if it can render a preview of the attachment as an image.
 part is always a single part.

If the attachment can be previewed, it will be rendered using the image template.
If not, the attachment template will be used.*/
- (BOOL) MCOAbstractMessage:(MCOAbstractMessage *)msg canPreviewPart:(MCOAbstractPart *)part;

/** This delegate method should return YES if the part should be rendered.*/
- (BOOL) MCOAbstractMessage:(MCOAbstractMessage *)msg shouldShowPart:(MCOAbstractPart *)part;

/** This delegate method returns the values to be applied to the template for the given header.
 See the content of MCHTMLRendererCallback.cpp for the default values of the header.*/
- (NSDictionary *) MCOAbstractMessage:(MCOAbstractMessage *)msg templateValuesForHeader:(MCOMessageHeader *)header;

/** This delegate method returns the values to be applied to the template for the given attachment.
 See the content of MCHTMLRendererCallback.cpp for the default values of the attachment.*/
- (NSDictionary *) MCOAbstractMessage:(MCOAbstractMessage *)msg templateValuesForPart:(MCOAbstractPart *)part;

/** @name Template Methods 
 The following methods returns templates. They will match the syntax of ctemplate.
 See https://code.google.com/p/ctemplate/ */

/** This delegate method returns the template for the main header of the message.
 See the content of MCHTMLRendererCallback.cpp for the default values of the template.*/
- (NSString *) MCOAbstractMessage:(MCOAbstractMessage *)msg templateForMainHeader:(MCOMessageHeader *)header;

/** This delegate method returns the template an image attachment.*/
- (NSString *) MCOAbstractMessage:(MCOAbstractMessage *)msg templateForImage:(MCOAbstractPart *)header;

/** This delegate method returns the template attachment other than images.
 See the content of MCHTMLRendererCallback.cpp for the default values of the template.*/
- (NSString *) MCOAbstractMessage:(MCOAbstractMessage *)msg templateForAttachment:(MCOAbstractPart *)part;

/** This delegate method returns the template of the main message.
 It should include HEADER and a BODY values.
 See the content of MCHTMLRendererCallback.cpp for the default values of the template.*/
- (NSString *) MCOAbstractMessage_templateForMessage:(MCOAbstractMessage *)msg;

/** This delegate method returns the template of an embedded message (included as attachment).
 It should include HEADER and a BODY values.
 See the content of MCHTMLRendererCallback.cpp for the default values of the template.*/
- (NSString *) MCOAbstractMessage:(MCOAbstractMessage *)msg templateForEmbeddedMessage:(MCOAbstractMessagePart *)part;

/** This delegate method returns the template for the header of an embedded message.
 See the content of MCHTMLRendererCallback.cpp for the default values of the template.*/
- (NSString *) MCOAbstractMessage:(MCOAbstractMessage *)msg templateForEmbeddedMessageHeader:(MCOMessageHeader *)header;

/** This delegate method returns the separator between the text of the message and the attachments.*/
- (NSString *) MCOAbstractMessage_templateForAttachmentSeparator:(MCOAbstractMessage *)msg;

/** This delegate method cleans HTML content.
 For example, it could fix broken tags, add missing <html>, <body> tags.
 Default implementation uses HTMLCleaner::cleanHTML to clean HTML content. */
- (NSString *) MCOAbstractMessage:(MCOAbstractMessage *)msg cleanHTMLForPart:(NSString *)html;

/** @name Filters
   
 The following methods will filter the HTML content and may apply some filters to
 change how to display the message.*/

/** This delegate method will apply the filter to HTML rendered content of a given text part.
 For example, it could filter the CSS content.*/
- (NSString *) MCOAbstractMessage:(MCOAbstractMessage *)msg filterHTMLForPart:(NSString *)html;

/** This delegate method will apply a filter to the whole HTML content.
 For example, it could collapse the quoted messages.*/
- (NSString *) MCOAbstractMessage:(MCOAbstractMessage *)msg filterHTMLForMessage:(NSString *)html;

@end

#endif