text
stringlengths
0
357
}
else if (strcmp(c->ct_subtype, "html")==0) {
*msg_type = DC_MSG_TEXT;
return DC_MIMETYPE_TEXT_HTML;
}
*msg_type = DC_MSG_FILE;
reconcat_mime(raw_mime, "text", c->ct_subtype);
return DC_MIMETYPE_FILE;
case MAILMIME_DISCRETE_TYPE_IMAGE:
if (strcmp(c->ct_subtype, "gif")==0) {
*msg_type = DC_MSG_GIF;
}
else if (strcmp(c->ct_subtype, "svg+xml")==0) {
*msg_type = DC_MSG_FILE;
reconcat_mime(raw_mime, "image", c->ct_subtype);
return DC_MIMETYPE_FILE;
}
else {
*msg_type = DC_MSG_IMAGE;
}
reconcat_mime(raw_mime, "image", c->ct_subtype);
return DC_MIMETYPE_IMAGE;
case MAILMIME_DISCRETE_TYPE_AUDIO:
*msg_type = DC_MSG_AUDIO; /* we correct this later to DC_MSG_VOICE, currently, this is not possible as we do not know the main header */
reconcat_mime(raw_mime, "audio", c->ct_subtype);
return DC_MIMETYPE_AUDIO;
case MAILMIME_DISCRETE_TYPE_VIDEO:
*msg_type = DC_MSG_VIDEO;
reconcat_mime(raw_mime, "video", c->ct_subtype);
return DC_MIMETYPE_VIDEO;
default:
*msg_type = DC_MSG_FILE;
if (c->ct_type->tp_data.tp_discrete_type->dt_type==MAILMIME_DISCRETE_TYPE_APPLICATION
&& strcmp(c->ct_subtype, "autocrypt-setup")==0) {
reconcat_mime(raw_mime, "application", c->ct_subtype);
return DC_MIMETYPE_AC_SETUP_FILE; /* application/autocrypt-setup */
}
reconcat_mime(raw_mime, c->ct_type->tp_data.tp_discrete_type->dt_extension, c->ct_subtype);
return DC_MIMETYPE_FILE;
}
break;
case MAILMIME_TYPE_COMPOSITE_TYPE:
if (c->ct_type->tp_data.tp_composite_type->ct_type==MAILMIME_COMPOSITE_TYPE_MULTIPART)
{
if (strcmp(c->ct_subtype, "alternative")==0) {
return DC_MIMETYPE_MP_ALTERNATIVE;
}
else if (strcmp(c->ct_subtype, "related")==0) {
return DC_MIMETYPE_MP_RELATED;
}
else if (strcmp(c->ct_subtype, "encrypted")==0) {
return DC_MIMETYPE_MP_NOT_DECRYPTABLE; /* decryptable parts are already converted to other mime parts in dc_e2ee_decrypt() */
}
else if (strcmp(c->ct_subtype, "signed")==0) {
return DC_MIMETYPE_MP_SIGNED;
}
else if (strcmp(c->ct_subtype, "mixed")==0) {
return DC_MIMETYPE_MP_MIXED;
}
else if (strcmp(c->ct_subtype, "report")==0) {
return DC_MIMETYPE_MP_REPORT;
}
else {
return DC_MIMETYPE_MP_OTHER;
}
}
else if (c->ct_type->tp_data.tp_composite_type->ct_type==MAILMIME_COMPOSITE_TYPE_MESSAGE)
{
/* Enacapsulated messages, see https://www.w3.org/Protocols/rfc1341/7_3_Message.html
Also used as part "message/disposition-notification" of "multipart/report", which, however, will be handled separatedly.
I've not seen any messages using this, so we do not attach these parts (maybe they're used to attach replies, which are unwanted at all).
For now, we skip these parts at all; if desired, we could return DC_MIMETYPE_FILE/DC_MSG_FILE for selected and known subparts. */
return 0;
}
break;
default:
break;
}
return 0; /* unknown */
}
/*******************************************************************************
* a MIME part
******************************************************************************/
static dc_mimepart_t* dc_mimepart_new(void)
{
dc_mimepart_t* mimepart = NULL;
if ((mimepart=calloc(1, sizeof(dc_mimepart_t)))==NULL) {