aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/renderer
diff options
context:
space:
mode:
authorGravatar Hoa V. DINH <dinh.viet.hoa@gmail.com>2013-05-18 11:30:40 -0700
committerGravatar Hoa V. DINH <dinh.viet.hoa@gmail.com>2013-05-18 11:30:40 -0700
commit6e0b88498cf83995ac40dbebc2f4709e8e457eb5 (patch)
tree7858d352569c48c172e3f953645c7dad1c5c5d29 /src/core/renderer
parent8a140c39942d380c3612b94b5ea84c11d1e4a2f8 (diff)
Changed delegate prototype to make it easier to use the renderer and customize it.
Diffstat (limited to 'src/core/renderer')
-rw-r--r--src/core/renderer/MCHTMLRenderer.cc12
-rw-r--r--src/core/renderer/MCHTMLRendererCallback.cc16
-rw-r--r--src/core/renderer/MCHTMLRendererCallback.h12
3 files changed, 20 insertions, 20 deletions
diff --git a/src/core/renderer/MCHTMLRenderer.cc b/src/core/renderer/MCHTMLRenderer.cc
index 0e52587f..5cffa106 100644
--- a/src/core/renderer/MCHTMLRenderer.cc
+++ b/src/core/renderer/MCHTMLRenderer.cc
@@ -198,12 +198,12 @@ static String * htmlForAbstractMessage(String * folder, AbstractMessage * messag
content = htmlCallback->filterHTMLForMessage(content);
HashMap * values = htmlCallback->templateValuesForHeader(message->header());
- String * headerString = renderTemplate(htmlCallback->templateForMainHeader(), values);
+ String * headerString = renderTemplate(htmlCallback->templateForMainHeader(message->header()), values);
HashMap * msgValues = new HashMap();
msgValues->setObjectForKey(MCSTR("HEADER"), headerString);
msgValues->setObjectForKey(MCSTR("BODY"), content);
- String * result = renderTemplate(htmlCallback->templateForMessage(), msgValues);
+ String * result = renderTemplate(htmlCallback->templateForMessage(message), msgValues);
msgValues->release();
return result;
@@ -330,14 +330,14 @@ static String * htmlForAbstractSinglePart(AbstractPart * part, htmlRendererConte
part->uniqueID()->UTF8Characters());
HashMap * values = context->htmlCallback->templateValuesForPart(part);
values->setObjectForKey(MCSTR("URL"), url);
- content = renderTemplate(context->htmlCallback->templateForImage(), values);
+ content = renderTemplate(context->htmlCallback->templateForImage(part), values);
}
else {
if (part->className()->isEqual(MCSTR("mailcore::IMAPPart"))) {
context->dataCallback->prefetchAttachmentIMAPPart(context->folder, (IMAPPart *) part);
}
HashMap * values = context->htmlCallback->templateValuesForPart(part);
- content = renderTemplate(context->htmlCallback->templateForAttachment(), values);
+ content = renderTemplate(context->htmlCallback->templateForAttachment(part), values);
}
result->appendString(separatorString);
@@ -360,12 +360,12 @@ static String * htmlForAbstractMessagePart(AbstractMessagePart * part, htmlRende
MCAssert(substring != NULL);
HashMap * values = context->htmlCallback->templateValuesForHeader(part->header());
- String * headerString = renderTemplate(context->htmlCallback->templateForEmbeddedMessageHeader(), values);
+ String * headerString = renderTemplate(context->htmlCallback->templateForEmbeddedMessageHeader(part->header()), values);
HashMap * msgValues = new HashMap();
msgValues->setObjectForKey(MCSTR("HEADER"), headerString);
msgValues->setObjectForKey(MCSTR("BODY"), substring);
- String * result = renderTemplate(context->htmlCallback->templateForEmbeddedMessage(), msgValues);
+ String * result = renderTemplate(context->htmlCallback->templateForEmbeddedMessage(part), msgValues);
msgValues->release();
return result;
diff --git a/src/core/renderer/MCHTMLRendererCallback.cc b/src/core/renderer/MCHTMLRendererCallback.cc
index 0d086e2b..5147e934 100644
--- a/src/core/renderer/MCHTMLRendererCallback.cc
+++ b/src/core/renderer/MCHTMLRendererCallback.cc
@@ -178,7 +178,7 @@ mailcore::HashMap * HTMLRendererTemplateCallback::templateValuesForPart(mailcore
return result;
}
-mailcore::String * HTMLRendererTemplateCallback::templateForMainHeader()
+mailcore::String * HTMLRendererTemplateCallback::templateForMainHeader(MessageHeader * header)
{
return MCSTR("<div style=\"background-color:#eee\">\
{{#HASFROM}}\
@@ -206,17 +206,17 @@ mailcore::String * HTMLRendererTemplateCallback::templateForMainHeader()
</div>");
}
-mailcore::String * HTMLRendererTemplateCallback::templateForEmbeddedMessageHeader()
+mailcore::String * HTMLRendererTemplateCallback::templateForEmbeddedMessageHeader(MessageHeader * header)
{
- return templateForMainHeader();
+ return templateForMainHeader(header);
}
-mailcore::String * HTMLRendererTemplateCallback::templateForImage()
+mailcore::String * HTMLRendererTemplateCallback::templateForImage(AbstractPart * part)
{
return MCSTR("");
}
-mailcore::String * HTMLRendererTemplateCallback::templateForAttachment()
+mailcore::String * HTMLRendererTemplateCallback::templateForAttachment(AbstractPart * part)
{
return MCSTR("{{#HASSIZE}}\
<div>- {{FILENAME}}, {{SIZE}}</div>\
@@ -227,15 +227,15 @@ mailcore::String * HTMLRendererTemplateCallback::templateForAttachment()
");
}
-mailcore::String * HTMLRendererTemplateCallback::templateForMessage()
+mailcore::String * HTMLRendererTemplateCallback::templateForMessage(AbstractMessage * message)
{
return MCSTR("<div style=\"padding-bottom: 20px;\">{{HEADER}}</div><div>{{BODY}}</div>");
}
-mailcore::String * HTMLRendererTemplateCallback::templateForEmbeddedMessage()
+mailcore::String * HTMLRendererTemplateCallback::templateForEmbeddedMessage(AbstractMessagePart * part)
{
- return templateForMessage();
+ return MCSTR("<div style=\"padding-bottom: 20px;\">{{HEADER}}</div><div>{{BODY}}</div>");
}
mailcore::String * HTMLRendererTemplateCallback::templateForAttachmentSeparator()
diff --git a/src/core/renderer/MCHTMLRendererCallback.h b/src/core/renderer/MCHTMLRendererCallback.h
index 3cd584a6..84292dad 100644
--- a/src/core/renderer/MCHTMLRendererCallback.h
+++ b/src/core/renderer/MCHTMLRendererCallback.h
@@ -34,12 +34,12 @@ namespace mailcore {
virtual HashMap * templateValuesForHeader(MessageHeader * header);
virtual HashMap * templateValuesForPart(AbstractPart * part);
- virtual String * templateForMainHeader();
- virtual String * templateForImage();
- virtual String * templateForAttachment();
- virtual String * templateForMessage();
- virtual String * templateForEmbeddedMessage();
- virtual String * templateForEmbeddedMessageHeader();
+ virtual String * templateForMainHeader(MessageHeader * header);
+ virtual String * templateForImage(AbstractPart * part);
+ virtual String * templateForAttachment(AbstractPart * part);
+ virtual String * templateForMessage(AbstractMessage * message);
+ virtual String * templateForEmbeddedMessage(AbstractMessagePart * part);
+ virtual String * templateForEmbeddedMessageHeader(MessageHeader * header);
virtual String * templateForAttachmentSeparator();
// Can be used to filter some HTML tags.