mirror of https://github.com/djcb/mu.git
* mu-msg-part: cleanups & fixes, added mu_msg_part_looks_like_attachment
This commit is contained in:
parent
fb5cda1665
commit
81fe752515
|
@ -275,7 +275,7 @@ typedef struct _MatchData MatchData;
|
|||
static void
|
||||
part_match_foreach_cb (GMimeObject *parent, GMimeObject *part, MatchData *mdata)
|
||||
{
|
||||
if (mdata->_found_idx >= 0)
|
||||
if (mdata->_found_idx < 0)
|
||||
if (mdata->_matcher (part, mdata->_user_data))
|
||||
mdata->_found_idx = mdata->_idx;
|
||||
|
||||
|
@ -304,20 +304,44 @@ msg_part_find_idx (GMimeMessage *msg, MatchFunc func, gpointer user_data)
|
|||
|
||||
|
||||
static gboolean
|
||||
match_content_id (GMimeObject *part, const char *sought_cid)
|
||||
match_content_id (GMimeObject *part, const char *cid)
|
||||
{
|
||||
return g_strcmp0 (g_mime_object_get_content_id (part),
|
||||
sought_cid) == 0;
|
||||
cid) == 0 ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
int
|
||||
mu_msg_part_find_cid (MuMsg *msg, const char* content_id)
|
||||
mu_msg_part_find_cid (MuMsg *msg, const char* sought_cid)
|
||||
{
|
||||
const char* cid;
|
||||
|
||||
g_return_val_if_fail (msg, -1L);
|
||||
g_return_val_if_fail (content_id, -1);
|
||||
g_return_val_if_fail (sought_cid, -1);
|
||||
|
||||
cid = g_str_has_prefix (sought_cid, "cid:") ?
|
||||
sought_cid + 4 : sought_cid;
|
||||
|
||||
return msg_part_find_idx (msg->_mime_msg, (MatchFunc)match_content_id,
|
||||
(gpointer)content_id);
|
||||
(gpointer)cid);
|
||||
}
|
||||
|
||||
|
||||
gboolean
|
||||
mu_msg_part_looks_like_attachment (MuMsgPart *part, gboolean include_inline)
|
||||
{
|
||||
g_return_val_if_fail (part, FALSE);
|
||||
|
||||
if (!part->disposition)
|
||||
return FALSE;
|
||||
|
||||
if (g_ascii_strcasecmp (part->disposition,
|
||||
GMIME_DISPOSITION_ATTACHMENT) == 0)
|
||||
return TRUE;
|
||||
|
||||
if (include_inline &&
|
||||
g_ascii_strcasecmp (part->disposition,
|
||||
GMIME_DISPOSITION_INLINE) == 0)
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -39,9 +39,7 @@ struct _MuMsgPart {
|
|||
/* the file name (if any) */
|
||||
char *file_name;
|
||||
|
||||
/* usually, "attachment" or "inline"; use
|
||||
* mu_msg_part_is_(attachment|inline)
|
||||
* to test */
|
||||
/* usually, "attachment" or "inline" */
|
||||
char *disposition;
|
||||
|
||||
/* size of the part; or 0 if unknown */
|
||||
|
@ -84,6 +82,16 @@ typedef struct _MuMsgPart MuMsgPart;
|
|||
#define mu_msg_part_content_id(pi) ((pi)->content_id)
|
||||
|
||||
|
||||
/**
|
||||
* does this msg part look like an attachment?
|
||||
*
|
||||
* @param part a message part
|
||||
* @param include_inline consider 'inline' parts also as attachments
|
||||
*
|
||||
* @return TRUE if it looks like an attachment, FALSE otherwise
|
||||
*/
|
||||
gboolean mu_msg_part_looks_like_attachment (MuMsgPart *part,
|
||||
gboolean include_inline);
|
||||
|
||||
/**
|
||||
* save a specific attachment to some targetdir
|
||||
|
|
Loading…
Reference in New Issue