CreateMsgInfo *info = (CreateMsgInfo *) thread_data;
TnyMsg *new_msg = NULL;
ModestMailOperationPrivate *priv;
+ gint attached = 0;
priv = MODEST_MAIL_OPERATION_GET_PRIVATE(info->mail_op);
if (info->html_body == NULL) {
new_msg = modest_tny_msg_new (info->to, info->from, info->cc,
info->bcc, info->subject, info->plain_body,
- info->attachments_list,
+ info->attachments_list, &attached,
&(priv->error));
} else {
new_msg = modest_tny_msg_new_html_plain (info->to, info->from, info->cc,
info->bcc, info->subject, info->html_body,
info->plain_body, info->attachments_list,
- info->images_list,
+ info->images_list, &attached,
&(priv->error));
}
tny_header_set_flag (header, info->priority_flags);
/* Set attachment flags in message */
- if (info->attachments_list != NULL)
+ if (info->attachments_list != NULL && attached > 0)
tny_header_set_flag (header, TNY_HEADER_FLAG_ATTACHMENTS);
g_object_unref (G_OBJECT(header));
static TnyMimePart * add_body_part (TnyMsg *msg, const gchar *body,
const gchar *content_type);
static TnyMimePart * add_html_body_part (TnyMsg *msg, const gchar *body);
-static void add_attachments (TnyMimePart *part, GList *attachments_list, gboolean add_inline, GError **err);
+static gint add_attachments (TnyMimePart *part, GList *attachments_list, gboolean add_inline, GError **err);
static void add_images (TnyMsg *msg, GList *attachments_list, GError **err);
static char * get_content_type(const gchar *s);
static gboolean is_ascii(const gchar *s);
TnyMsg*
modest_tny_msg_new (const gchar* mailto, const gchar* from, const gchar *cc,
const gchar *bcc, const gchar* subject, const gchar *body,
- GList *attachments, GError **err)
+ GList *attachments, gint *attached, GError **err)
{
TnyMsg *new_msg;
TnyHeader *header;
gchar *content_type;
+ gint tmp_attached = 0;
/* Create new msg */
new_msg = modest_formatter_create_message (NULL, TRUE, (attachments != NULL), FALSE);
/* Add attachments */
if (attachments)
- add_attachments (TNY_MIME_PART (new_msg), attachments, FALSE, err);
+ tmp_attached = add_attachments (TNY_MIME_PART (new_msg), attachments, FALSE, err);
+ if (attached)
+ *attached = tmp_attached;
if (header)
g_object_unref(header);
modest_tny_msg_new_html_plain (const gchar* mailto, const gchar* from, const gchar *cc,
const gchar *bcc, const gchar* subject,
const gchar *html_body, const gchar *plain_body,
- GList *attachments, GList *images, GError **err)
+ GList *attachments, GList *images, gint *attached, GError **err)
{
TnyMsg *new_msg;
TnyHeader *header;
gchar *content_type;
+ gint tmp_attached;
/* Create new msg */
new_msg = modest_formatter_create_message (NULL, FALSE, (attachments != NULL), (images != NULL));
g_free (content_type);
/* Add attachments */
- add_attachments (TNY_MIME_PART (new_msg), attachments, FALSE, err);
+ tmp_attached = add_attachments (TNY_MIME_PART (new_msg), attachments, FALSE, err);
+ if (attached)
+ *attached = tmp_attached;
add_images (new_msg, images, err);
if (header)
g_object_unref(header);
return result;
}
-static void
+static gint
add_attachments (TnyMimePart *part, GList *attachments_list, gboolean add_inline, GError **err)
{
GList *pos;
TnyMimePart *attachment_part, *old_attachment;
gint ret;
+ gint attached = 0;
for (pos = (GList *)attachments_list; pos; pos = pos->next) {
}
tny_mime_part_set_transfer_encoding (TNY_MIME_PART (attachment_part), "base64");
ret = tny_mime_part_add_part (TNY_MIME_PART (part), attachment_part);
+ attached++;
if (old_cid)
tny_mime_part_set_content_id (attachment_part, old_cid);
g_object_unref (attachment_part);
}
}
}
+ return attached;
}
static void
* @subject: subject for the messdage
* @body: body for the message
* @attachments: a list of attachments (local URIs)
+ * @attached: a #gint pointer, returns the number of attachments really included.
* @error: a pointer for errors in message creation
*
* create a new TnyMsg with the given parameters
*/
TnyMsg* modest_tny_msg_new (const gchar* mailto, const gchar* mailfrom, const gchar *cc,
const gchar *bcc, const gchar* subject, const gchar *body,
- GList *attachments, GError **err);
+ GList *attachments, gint *attached, GError **err);
/**
* modest_tny_msg_new_html_plain:
* @html_body: body for the message in HTML
* @plain_body: body for the message in plain text
* @attachments: a list of attachments (mime parts)
- * @attachments: a list of images (mime parts)
+ * @images: a list of images (mime parts)
+ * @attached: a #gint pointer, returns the number of attachments really included.
* @error: a pointer for errors in message creation
*
* create a new TnyMsg with the given parameters
TnyMsg* modest_tny_msg_new_html_plain (const gchar* mailto, const gchar* mailfrom, const gchar *cc,
const gchar *bcc, const gchar* subject,
const gchar *html_body, const gchar *plain_body,
- GList *attachments, GList *images, GError **err);
+ GList *attachments, GList *images, gint *attached, GError **err);
/**
* modest_tny_msg_find_body_part:
body = use_signature ? g_strconcat("\n", signature, NULL) : g_strdup("");
}
- msg = modest_tny_msg_new (to_str, from_str, cc_str, bcc_str, subject_str, body, NULL, NULL);
+ msg = modest_tny_msg_new (to_str, from_str, cc_str, bcc_str, subject_str, body, NULL, NULL, NULL);
if (!msg) {
g_printerr ("modest: failed to create new msg\n");
goto cleanup;