text stringlengths 0 357 |
|---|
{ |
if (field->fld_type==wanted_fld_type) { |
return field; |
} |
} |
} |
return NULL; |
} |
struct mailimf_optional_field* mailimf_find_optional_field(struct mailimf_fields* header, const char* wanted_fld_name) |
{ |
/* Note: the function does not return fields with no value set! */ |
if (header==NULL || header->fld_list==NULL) { |
return NULL; |
} |
for (clistiter* cur1 = clist_begin(header->fld_list); cur1!=NULL ; cur1=clist_next(cur1)) |
{ |
struct mailimf_field* field = (struct mailimf_field*)clist_content(cur1); |
if (field && field->fld_type==MAILIMF_FIELD_OPTIONAL_FIELD) |
{ |
struct mailimf_optional_field* optional_field = field->fld_data.fld_optional_field; |
if (optional_field && optional_field->fld_name && optional_field->fld_value && strcasecmp(optional_field->fld_name, wanted_fld_name)==0) { |
return optional_field; |
} |
} |
} |
return NULL; |
} |
static int mailmime_is_attachment_disposition(struct mailmime* mime) |
{ |
if (mime->mm_mime_fields!=NULL) { |
for (clistiter* cur = clist_begin(mime->mm_mime_fields->fld_list); cur!=NULL; cur = clist_next(cur)) { |
struct mailmime_field* field = (struct mailmime_field*)clist_content(cur); |
if (field && field->fld_type==MAILMIME_FIELD_DISPOSITION && field->fld_data.fld_disposition) { |
if (field->fld_data.fld_disposition->dsp_type |
&& field->fld_data.fld_disposition->dsp_type->dsp_type==MAILMIME_DISPOSITION_TYPE_ATTACHMENT) |
{ |
return 1; |
} |
} |
} |
} |
return 0; |
} |
static void reconcat_mime(char** raw_mime, const char* type, const char* subtype) |
{ |
if (raw_mime) { |
*raw_mime = dc_mprintf("%s/%s", |
type? type : "application", |
subtype? subtype : "octet-stream"); |
} |
} |
static int mailmime_get_mime_type(struct mailmime* mime, int* msg_type, |
char** raw_mime /*set only for discrete types with attachments*/) |
{ |
#define DC_MIMETYPE_MP_ALTERNATIVE 10 |
#define DC_MIMETYPE_MP_RELATED 20 |
#define DC_MIMETYPE_MP_MIXED 30 |
#define DC_MIMETYPE_MP_NOT_DECRYPTABLE 40 |
#define DC_MIMETYPE_MP_REPORT 45 |
#define DC_MIMETYPE_MP_SIGNED 46 |
#define DC_MIMETYPE_MP_OTHER 50 |
#define DC_MIMETYPE_TEXT_PLAIN 60 |
#define DC_MIMETYPE_TEXT_HTML 70 |
#define DC_MIMETYPE_IMAGE 80 |
#define DC_MIMETYPE_AUDIO 90 |
#define DC_MIMETYPE_VIDEO 100 |
#define DC_MIMETYPE_FILE 110 |
#define DC_MIMETYPE_AC_SETUP_FILE 111 |
struct mailmime_content* c = mime->mm_content_type; |
int dummy = 0; if (msg_type==NULL) { msg_type = &dummy; } |
*msg_type = 0; |
if (c==NULL || c->ct_type==NULL) { |
return 0; |
} |
switch (c->ct_type->tp_type) |
{ |
case MAILMIME_TYPE_DISCRETE_TYPE: |
switch (c->ct_type->tp_data.tp_discrete_type->dt_type) |
{ |
case MAILMIME_DISCRETE_TYPE_TEXT: |
if (mailmime_is_attachment_disposition(mime)) { |
; /* DC_MIMETYPE_FILE is returned below - we leave text attachments as attachments as they may be too large to display as a normal message, eg. complete books. */ |
} |
else if (strcmp(c->ct_subtype, "plain")==0) { |
*msg_type = DC_MSG_TEXT; |
return DC_MIMETYPE_TEXT_PLAIN; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.