* mu-msg-part: don't use g_mime_part_iter_*: it's gmime 2.6 only
This commit is contained in:
@ -34,9 +34,9 @@
|
|||||||
#include "mu-msg-crypto.h"
|
#include "mu-msg-crypto.h"
|
||||||
#endif /*BUILD_CRYPTO*/
|
#endif /*BUILD_CRYPTO*/
|
||||||
|
|
||||||
static gboolean handle_children (MuMsg *msg, GMimeObject *mobj,
|
static gboolean handle_children (MuMsg *msg,
|
||||||
MuMsgOptions opts, unsigned index,
|
GMimeMessage *mime_msg, MuMsgOptions opts,
|
||||||
MuMsgPartForeachFunc func,
|
unsigned index, MuMsgPartForeachFunc func,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
|
|
||||||
struct _DoData {
|
struct _DoData {
|
||||||
@ -161,6 +161,7 @@ mu_msg_part_get_text (MuMsg *msg, MuMsgPart *self, MuMsgOptions opts,
|
|||||||
gboolean *err)
|
gboolean *err)
|
||||||
{
|
{
|
||||||
GMimeObject *mobj;
|
GMimeObject *mobj;
|
||||||
|
GMimeMessage *mime_msg;
|
||||||
|
|
||||||
g_return_val_if_fail (msg, NULL);
|
g_return_val_if_fail (msg, NULL);
|
||||||
g_return_val_if_fail (self && self->data, NULL);
|
g_return_val_if_fail (self && self->data, NULL);
|
||||||
@ -168,17 +169,31 @@ mu_msg_part_get_text (MuMsg *msg, MuMsgPart *self, MuMsgOptions opts,
|
|||||||
|
|
||||||
mobj = (GMimeObject*)self->data;
|
mobj = (GMimeObject*)self->data;
|
||||||
|
|
||||||
if (GMIME_IS_PART (mobj) &&
|
if (GMIME_IS_PART (mobj)) {
|
||||||
(strcasecmp (self->type, "text") == 0) &&
|
if (self->part_type & MU_MSG_PART_TYPE_TEXT_PLAIN)
|
||||||
(strcasecmp (self->subtype, "plain") == 0))
|
|
||||||
return mu_msg_mime_part_to_string ((GMimePart*)mobj, err);
|
return mu_msg_mime_part_to_string ((GMimePart*)mobj, err);
|
||||||
else {
|
else
|
||||||
|
return NULL; /* non-text MimePart */
|
||||||
|
}
|
||||||
|
|
||||||
|
mime_msg = NULL;
|
||||||
|
if (GMIME_IS_MESSAGE_PART (mobj))
|
||||||
|
mime_msg = g_mime_message_part_get_message
|
||||||
|
((GMimeMessagePart*)mobj);
|
||||||
|
else if (GMIME_IS_MESSAGE (mobj))
|
||||||
|
mime_msg = (GMimeMessage*)mobj;
|
||||||
|
|
||||||
|
if (mime_msg) {
|
||||||
GString *gstr;
|
GString *gstr;
|
||||||
gstr = g_string_sized_new (4096);
|
gstr = g_string_sized_new (4096);
|
||||||
handle_children (msg, mobj, opts, self->index,
|
handle_children (msg, mime_msg, opts, self->index,
|
||||||
(MuMsgPartForeachFunc)accumulate_text,
|
(MuMsgPartForeachFunc)accumulate_text,
|
||||||
&gstr);
|
&gstr);
|
||||||
return g_string_free (gstr, FALSE);
|
return g_string_free (gstr, FALSE);
|
||||||
|
} else {
|
||||||
|
g_warning ("%s: cannot get text for %s",
|
||||||
|
__FUNCTION__, G_OBJECT_TYPE_NAME (mobj));
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -363,10 +378,6 @@ get_disposition (GMimeObject *mobj)
|
|||||||
return MU_MSG_PART_TYPE_NONE;
|
return MU_MSG_PART_TYPE_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
|
||||||
handle_children (MuMsg *msg, GMimeObject *mobj, MuMsgOptions opts,
|
|
||||||
unsigned index, MuMsgPartForeachFunc func, gpointer user_data);
|
|
||||||
|
|
||||||
/* call 'func' with information about this MIME-part */
|
/* call 'func' with information about this MIME-part */
|
||||||
static gboolean
|
static gboolean
|
||||||
handle_signed_part (MuMsg *msg,
|
handle_signed_part (MuMsg *msg,
|
||||||
@ -446,13 +457,11 @@ handle_message_part (MuMsg *msg, GMimeMessagePart *mmsg, GMimeObject *parent,
|
|||||||
|
|
||||||
func (msg, &msgpart, user_data);
|
func (msg, &msgpart, user_data);
|
||||||
|
|
||||||
if (opts & MU_MSG_OPTION_RECURSE_RFC822) {
|
if (opts & MU_MSG_OPTION_RECURSE_RFC822)
|
||||||
GMimeObject *mobj;
|
|
||||||
mobj = g_mime_message_get_mime_part
|
|
||||||
(g_mime_message_part_get_message (mmsg));
|
|
||||||
return handle_children
|
return handle_children
|
||||||
(msg, mobj, opts, index, func, user_data);
|
(msg, g_mime_message_part_get_message (mmsg),
|
||||||
}
|
opts, index, func, user_data);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -482,38 +491,58 @@ handle_mime_object (MuMsg *msg,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct _ForeachData {
|
||||||
|
MuMsgPartForeachFunc func;
|
||||||
|
gpointer user_data;
|
||||||
|
MuMsg *msg;
|
||||||
|
unsigned index;
|
||||||
|
MuMsgOptions opts;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct _ForeachData ForeachData;
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
each_child (GMimeObject *parent, GMimeObject *part,
|
||||||
|
ForeachData *fdata)
|
||||||
|
{
|
||||||
|
handle_mime_object (fdata->msg,
|
||||||
|
part,
|
||||||
|
parent,
|
||||||
|
fdata->opts,
|
||||||
|
fdata->index++,
|
||||||
|
fdata->func,
|
||||||
|
fdata->user_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
handle_children (MuMsg *msg,
|
handle_children (MuMsg *msg,
|
||||||
GMimeObject *mobj, MuMsgOptions opts,
|
GMimeMessage *mime_msg, MuMsgOptions opts,
|
||||||
unsigned index, MuMsgPartForeachFunc func,
|
unsigned index, MuMsgPartForeachFunc func,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
gboolean rv;
|
ForeachData fdata;
|
||||||
GMimePartIter *iter;
|
|
||||||
|
|
||||||
/* the children */
|
fdata.func = func;
|
||||||
iter = g_mime_part_iter_new (mobj);
|
fdata.user_data = user_data;
|
||||||
|
fdata.opts = opts;
|
||||||
|
fdata.msg = msg;
|
||||||
|
fdata.index = 0;
|
||||||
|
|
||||||
if (!iter)
|
g_mime_message_foreach (mime_msg, (GMimeObjectForeachFunc)each_child,
|
||||||
return FALSE;
|
&fdata);
|
||||||
for (rv = TRUE; rv && g_mime_part_iter_is_valid (iter);
|
|
||||||
g_mime_part_iter_next (iter), index++)
|
|
||||||
rv = handle_mime_object (
|
|
||||||
msg, g_mime_part_iter_get_current (iter),
|
|
||||||
g_mime_part_iter_get_parent (iter),
|
|
||||||
opts, index, func, user_data);
|
|
||||||
|
|
||||||
g_mime_part_iter_free (iter);
|
return TRUE;
|
||||||
|
|
||||||
return rv;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
mu_msg_part_foreach (MuMsg *msg, MuMsgOptions opts,
|
mu_msg_part_foreach (MuMsg *msg, MuMsgOptions opts,
|
||||||
MuMsgPartForeachFunc func, gpointer user_data)
|
MuMsgPartForeachFunc func, gpointer user_data)
|
||||||
{
|
{
|
||||||
GMimeObject *toplevel;
|
GMimeMessage *mime_msg;
|
||||||
unsigned idx;
|
unsigned idx;
|
||||||
|
|
||||||
g_return_val_if_fail (msg, FALSE);
|
g_return_val_if_fail (msg, FALSE);
|
||||||
@ -522,14 +551,9 @@ mu_msg_part_foreach (MuMsg *msg, MuMsgOptions opts,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
idx = 0;
|
idx = 0;
|
||||||
toplevel = g_mime_message_get_mime_part
|
mime_msg = GMIME_MESSAGE(msg->_file->_mime_msg);
|
||||||
(GMIME_MESSAGE(msg->_file->_mime_msg));
|
|
||||||
if (!toplevel || !handle_mime_object
|
|
||||||
(msg, toplevel, NULL, opts, idx++, func, user_data))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
return handle_children (msg, toplevel, opts, idx, func,
|
return handle_children (msg, mime_msg, opts, idx, func, user_data);
|
||||||
user_data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user