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

Function htmlForAbstractSinglePart

src/core/renderer/MCHTMLRenderer.cpp:284–432  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

282}
283
284static String * htmlForAbstractSinglePart(AbstractPart * part, htmlRendererContext * context)
285{
286 String * mimeType = NULL;
287 if (part->mimeType() != NULL) {
288 mimeType = part->mimeType()->lowercaseString();
289 }
290 MCAssert(mimeType != NULL);
291
292 if (isTextPart(part, context)) {
293 if (context->pass == 0) {
294 if (context->state == RENDER_STATE_HAD_ATTACHMENT) {
295#if 0
296 if (part->className()->isEqual(MCSTR("mailcore::IMAPPart"))) {
297 if (mimeType->isEqual(MCSTR("text/plain"))) {
298 Data * data = context->dataCallback->dataForIMAPPart(context->folder, (IMAPPart *) part);
299 if (data != NULL) {
300 if (data->length() == 0) {
301 return NULL;
302 }
303 else if (data->length() == 2) {
304 if (strncmp(data->bytes(), "\r\n", 2) == 0) {
305 return NULL;
306 }
307 }
308 else if (data->length() == 1) {
309 if (strncmp(data->bytes(), "\n", 1) == 0) {
310 return NULL;
311 }
312 }
313 }
314 }
315 }
316#endif
317 context->state = RENDER_STATE_HAD_ATTACHMENT_THEN_TEXT;
318 }
319 return NULL;
320 }
321
322 context->hasTextPart = true;
323
324 if (mimeType->isEqual(MCSTR("text/plain"))) {
325 String * charset = part->charset();
326 Data * data = NULL;
327 if (part->className()->isEqual(MCSTR("mailcore::IMAPPart"))) {
328 data = context->imapDataCallback->dataForIMAPPart(context->folder, (IMAPPart *) part);
329 }
330 else if (part->className()->isEqual(MCSTR("mailcore::Attachment"))) {
331 data = ((Attachment *) part)->data();
332 if (data == NULL) {
333 // It may be NULL when mailcore::MessageParser::attachments() is invoked when
334 // when mailcore::MessageParser has been serialized/unserialized.
335 data = context->rfc822DataCallback->dataForRFC822Part(context->folder, (Attachment *) part);
336 }
337 MCAssert(data != NULL);
338 }
339 if (data == NULL)
340 return NULL;
341

Callers 1

htmlForAbstractPartFunction · 0.85

Calls 15

isTextPartFunction · 0.85
renderTemplateFunction · 0.85
lowercaseStringMethod · 0.80
classNameMethod · 0.80
bytesMethod · 0.80
dataForRFC822PartMethod · 0.80
htmlMessageContentMethod · 0.80
UTF8CharactersMethod · 0.80
setObjectForKeyMethod · 0.80
appendStringMethod · 0.80
dataForIMAPPartMethod · 0.65

Tested by

no test coverage detected