MCPcopy Create free account
hub / github.com/MailCore/mailcore2 / templateValuesForPart

Method templateValuesForPart

src/core/renderer/MCHTMLRendererCallback.cpp:159–202  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

157}
158
159mailcore::HashMap * HTMLRendererTemplateCallback::templateValuesForPart(mailcore::AbstractPart * part)
160{
161 mailcore::HashMap * result = mailcore::HashMap::hashMap();
162 mailcore::String * filename = NULL;
163
164 if (part->filename() != NULL) {
165 filename = part->filename()->lastPathComponent();
166 }
167
168 if (filename != NULL) {
169 result->setObjectForKey(MCSTR("FILENAME"), filename->htmlEncodedString());
170 result->setObjectForKey(MCSTR("HASFILENAME"), mailcore::HashMap::hashMap());
171 }
172 else {
173 result->setObjectForKey(MCSTR("NOFILENAME"), mailcore::HashMap::hashMap());
174 }
175
176 if (part->className()->isEqual(MCSTR("mailcore::IMAPPart"))) {
177 mailcore::IMAPPart * imapPart = (mailcore::IMAPPart *) part;
178 mailcore::String * value = mailcore::SizeFormatter::stringWithSize(imapPart->decodedSize());
179 result->setObjectForKey(MCSTR("SIZE"), value);
180 result->setObjectForKey(MCSTR("HASSIZE"), mailcore::HashMap::hashMap());
181 }
182 else if (part->className()->isEqual(MCSTR("mailcore::Attachment"))) {
183 mailcore::Attachment * attachment = (mailcore::Attachment *) part;
184 if (attachment->data() != NULL) {
185 mailcore::String * value = mailcore::SizeFormatter::stringWithSize(attachment->data()->length());
186 result->setObjectForKey(MCSTR("SIZE"), value);
187 result->setObjectForKey(MCSTR("HASSIZE"), mailcore::HashMap::hashMap());
188 }
189 }
190 else {
191 result->setObjectForKey(MCSTR("NOSIZE"), mailcore::HashMap::hashMap());
192 }
193
194 if (part->contentID() != NULL) {
195 result->setObjectForKey(MCSTR("CONTENTID"), part->contentID());
196 }
197 if (part->uniqueID() != NULL) {
198 result->setObjectForKey(MCSTR("UNIQUEID"), part->uniqueID());
199 }
200
201 return result;
202}
203
204mailcore::String * HTMLRendererTemplateCallback::templateForMainHeader(MessageHeader * header)
205{

Callers

nothing calls this directly

Calls 11

lastPathComponentMethod · 0.80
setObjectForKeyMethod · 0.80
htmlEncodedStringMethod · 0.80
classNameMethod · 0.80
filenameMethod · 0.45
isEqualMethod · 0.45
decodedSizeMethod · 0.45
dataMethod · 0.45
lengthMethod · 0.45
contentIDMethod · 0.45
uniqueIDMethod · 0.45

Tested by

no test coverage detected