From 925bc6a15cc40f5a52c7f3a21e3d96b207e98d96 Mon Sep 17 00:00:00 2001 From: "Foivos S. Zakkak" Date: Wed, 15 Oct 2014 03:12:29 +0300 Subject: [PATCH] Fix forwarding of gpg encrypted mails (#186) --- mu/mu-cmd-server.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/mu/mu-cmd-server.c b/mu/mu-cmd-server.c index 40a9f0be..8d195426 100644 --- a/mu/mu-cmd-server.c +++ b/mu/mu-cmd-server.c @@ -415,8 +415,14 @@ cmd_add (ServerContext *ctx, GHashTable *args, GError **err) } +struct _PartInfo { + GSList *attlist; + MuMsgOptions opts; +}; +typedef struct _PartInfo PartInfo; + static void -each_part (MuMsg *msg, MuMsgPart *part, GSList **attlist) +each_part (MuMsg *msg, MuMsgPart *part, PartInfo *pinfo) { char *att, *cachefile; GError *err; @@ -427,7 +433,8 @@ each_part (MuMsg *msg, MuMsgPart *part, GSList **attlist) return; err = NULL; - cachefile = mu_msg_part_save_temp (msg, MU_MSG_OPTION_OVERWRITE, + cachefile = mu_msg_part_save_temp (msg, + pinfo->opts|MU_MSG_OPTION_OVERWRITE, part->index, &err); if (!cachefile) { print_and_clear_g_error (&err); @@ -437,7 +444,7 @@ each_part (MuMsg *msg, MuMsgPart *part, GSList **attlist) att = g_strdup_printf ( "(:file-name \"%s\" :mime-type \"%s/%s\")", cachefile, part->type, part->subtype); - *attlist = g_slist_append (*attlist, att); + pinfo->attlist = g_slist_append (pinfo->attlist, att); g_free (cachefile); } @@ -450,23 +457,25 @@ each_part (MuMsg *msg, MuMsgPart *part, GSList **attlist) * */ static gchar* -include_attachments (MuMsg *msg) +include_attachments (MuMsg *msg, MuMsgOptions opts) { - GSList *attlist, *cur; + GSList *cur; GString *gstr; + PartInfo pinfo; - attlist = NULL; - mu_msg_part_foreach (msg, MU_MSG_OPTION_NONE, + pinfo.attlist = NULL; + pinfo.opts = opts; + mu_msg_part_foreach (msg, opts, (MuMsgPartForeachFunc)each_part, - &attlist); + &pinfo); gstr = g_string_sized_new (512); gstr = g_string_append_c (gstr, '('); - for (cur = attlist; cur; cur = g_slist_next (cur)) + for (cur = pinfo.attlist; cur; cur = g_slist_next (cur)) g_string_append (gstr, (gchar*)cur->data); gstr = g_string_append_c (gstr, ')'); - mu_str_free_list (attlist); + mu_str_free_list (pinfo.attlist); return g_string_free (gstr, FALSE); } @@ -542,7 +551,7 @@ cmd_compose (ServerContext *ctx, GHashTable *args, GError **err) return MU_OK; } sexp = mu_msg_to_sexp (msg, atoi(docidstr), NULL, opts); - atts = (ctype == FORWARD) ? include_attachments (msg) : NULL; + atts = (ctype == FORWARD) ? include_attachments (msg, opts) : NULL; mu_msg_unref (msg); } else atts = sexp = NULL;