Fix forwarding of gpg encrypted mails (#186)

This commit is contained in:
Foivos S. Zakkak 2014-10-15 03:12:29 +03:00
parent c5fd36a67f
commit 925bc6a15c
1 changed files with 20 additions and 11 deletions

View File

@ -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;