* update code for new mu_msg_part_for_each API

This commit is contained in:
djcb
2012-02-13 22:36:22 +02:00
parent 3bb93a401b
commit 0d08ff903d
4 changed files with 51 additions and 42 deletions

View File

@ -418,7 +418,7 @@ SCM_DEFINE_PUBLIC (get_parts, "mu:get-parts", 1, 1, 0,
attinfo.attachments_only = ATTS_ONLY == SCM_BOOL_T ? TRUE : FALSE; attinfo.attachments_only = ATTS_ONLY == SCM_BOOL_T ? TRUE : FALSE;
msgwrap = (MuMsgWrapper*) SCM_CDR(MSG); msgwrap = (MuMsgWrapper*) SCM_CDR(MSG);
mu_msg_part_foreach (msgwrap->_msg, mu_msg_part_foreach (msgwrap->_msg, FALSE,
(MuMsgPartForeachFunc)each_part, (MuMsgPartForeachFunc)each_part,
&attinfo); &attinfo);

View File

@ -39,13 +39,19 @@ save_part (MuMsg *msg, const char *targetdir, guint partidx, gboolean overwrite,
GError *err; GError *err;
gchar *filepath; gchar *filepath;
filepath = mu_msg_part_filepath (msg, targetdir, partidx); err = NULL;
filepath = mu_msg_part_filepath (msg, targetdir, partidx, &err);
if (!filepath) { if (!filepath) {
g_warning ("failed to get filepath"); if (err) {
g_warning ("failed to save MIME-part: %s",
err->message);
g_error_free (err);
}
g_free (filepath);
return FALSE; return FALSE;
} }
err = NULL;
if (!mu_msg_part_save (msg, filepath, partidx, overwrite, FALSE, &err)) { if (!mu_msg_part_save (msg, filepath, partidx, overwrite, FALSE, &err)) {
if (err) { if (err) {
g_warning ("failed to save MIME-part: %s", g_warning ("failed to save MIME-part: %s",
@ -203,17 +209,20 @@ save_part_if (MuMsg *msg, MuMsgPart *part, SaveData *sd)
rv = FALSE; rv = FALSE;
filepath = NULL; filepath = NULL;
filepath = mu_msg_part_filepath (msg, sd->targetdir, part->index);
if (!filepath)
goto leave;
err = NULL; err = NULL;
filepath = mu_msg_part_filepath (msg, sd->targetdir, part->index, &err);
if (!filepath) {
g_warning ("failed to get file path: %s",
err&&err->message ? err->message : "error");
g_clear_error (&err);
goto leave;
}
if (!mu_msg_part_save (msg, filepath, part->index, if (!mu_msg_part_save (msg, filepath, part->index,
sd->overwrite, FALSE, &err)) { sd->overwrite, FALSE, &err)) {
g_warning ("failed to save MIME-part: %s", g_warning ("failed to save MIME-part: %s",
err&&err->message ? err->message : "error"); err&&err->message ? err->message : "error");
if (err) g_clear_error (&err);
g_error_free (err);
goto leave; goto leave;
} }
@ -241,7 +250,7 @@ save_certain_parts (MuMsg *msg, gboolean attachments_only,
sd.targetdir = targetdir; sd.targetdir = targetdir;
sd.play = play; sd.play = play;
mu_msg_part_foreach (msg, mu_msg_part_foreach (msg, FALSE,
(MuMsgPartForeachFunc)save_part_if, (MuMsgPartForeachFunc)save_part_if,
&sd); &sd);
@ -344,7 +353,7 @@ show_parts (const char* path, MuConfig *opts, GError **err)
g_print ("MIME-parts in this message:\n"); g_print ("MIME-parts in this message:\n");
mu_msg_part_foreach mu_msg_part_foreach
(msg,(MuMsgPartForeachFunc)each_part_show, (msg, FALSE, (MuMsgPartForeachFunc)each_part_show,
GUINT_TO_POINTER(!opts->nocolor)); GUINT_TO_POINTER(!opts->nocolor));
mu_msg_unref (msg); mu_msg_unref (msg);

View File

@ -504,7 +504,8 @@ add_terms_values_attach (Xapian::Document& doc, MuMsg *msg,
MuMsgFieldId mfid) MuMsgFieldId mfid)
{ {
PartData pdata (doc, mfid); PartData pdata (doc, mfid);
mu_msg_part_foreach (msg, (MuMsgPartForeachFunc)each_part, &pdata); mu_msg_part_foreach (msg, TRUE,
(MuMsgPartForeachFunc)each_part, &pdata);
} }

View File

@ -286,8 +286,7 @@ mu_msg_attach_view_set_message (MuMsgAttachView *self, MuMsg *msg)
cbdata.store = store; cbdata.store = store;
cbdata.count = 0; cbdata.count = 0;
mu_msg_part_foreach (msg, (MuMsgPartForeachFunc)each_part, &cbdata); mu_msg_part_foreach (msg, FALSE, (MuMsgPartForeachFunc)each_part, &cbdata);
return cbdata.count; return cbdata.count;
} }