- /* Create new msg */
- fact = modest_tny_platform_factory_get_instance ();
- new_msg = tny_platform_factory_new_msg (fact);
- header = tny_platform_factory_new_header (fact);
-
- /* WARNING: set the header before assign values to it */
- tny_msg_set_header (new_msg, header);
- tny_header_set_from (TNY_HEADER (header), from);
- tny_header_set_replyto (TNY_HEADER (header), from);
- tny_header_set_to (TNY_HEADER (header), to);
- tny_header_set_cc (TNY_HEADER (header), cc);
- tny_header_set_bcc (TNY_HEADER (header), bcc);
- tny_header_set_subject (TNY_HEADER (header), subject);
-
- content_type = get_content_type(body);
-
- /* Add the body of the new mail */
- add_body_part (new_msg, body, (const gchar *) content_type,
- (attachments_list == NULL) ? FALSE : TRUE);
-
- /* Add attachments */
- add_attachments (new_msg, (GList*) attachments_list);
-
- /* Send mail */
- tny_transport_account_send (transport_account, new_msg, NULL); /* FIXME */
-
- /* Clean */
- g_object_unref (header);
- g_object_unref (new_msg);
- g_free(content_type);
-}
-
-static void
-add_if_attachment (gpointer data, gpointer user_data)
-{
- TnyMimePart *part;
- GList *attachments_list;
-
- part = TNY_MIME_PART (data);
- attachments_list = (GList *) user_data;
-
- if (tny_mime_part_is_attachment (part))
- attachments_list = g_list_prepend (attachments_list, part);
-}
-
-
-static TnyMsg *
-create_reply_forward_mail (TnyMsg *msg, const gchar *from, gboolean is_reply, guint type)
-{
- TnyPlatformFactory *fact;
- TnyMsg *new_msg;
- TnyHeader *new_header, *header;
- gchar *new_subject;
- TnyMimePart *body;
- ModestFormatter *formatter;
-
- /* Get body from original msg. Always look for the text/plain
- part of the message to create the reply/forwarded mail */
- header = tny_msg_get_header (msg);
- body = modest_tny_msg_find_body_part (msg, FALSE);
-
- /* TODO: select the formatter from account prefs */
- formatter = modest_formatter_new ("text/plain");
-
- /* Format message body */
- if (is_reply) {
- switch (type) {
- case MODEST_MAIL_OPERATION_REPLY_TYPE_CITE:
- default:
- new_msg = modest_formatter_cite (formatter, body, header);
- break;
- case MODEST_MAIL_OPERATION_REPLY_TYPE_QUOTE:
- new_msg = modest_formatter_quote (formatter, body, header);
- break;
- }
- } else {
- switch (type) {
- case MODEST_MAIL_OPERATION_FORWARD_TYPE_INLINE:
- default:
- new_msg = modest_formatter_inline (formatter, body, header);
- break;
- case MODEST_MAIL_OPERATION_FORWARD_TYPE_ATTACHMENT:
- new_msg = modest_formatter_attach (formatter, body, header);
- break;
- }