attachment_part = copy_mime_part (old_attachment);
tny_mime_part_set_header_pair (attachment_part, "Content-Disposition",
add_inline?"inline":"attachment");
+ tny_mime_part_set_transfer_encoding (TNY_MIME_PART (attachment_part), "base64");
tny_mime_part_add_part (TNY_MIME_PART (part), attachment_part);
if (old_cid)
tny_mime_part_set_content_id (attachment_part, old_cid);
g_return_val_if_fail (msg && TNY_IS_MSG(msg), NULL);
- /* Add attachments */
- if (msg != NULL) {
- parts = TNY_LIST (tny_simple_list_new());
- tny_mime_part_get_parts (TNY_MIME_PART (msg), parts);
- tny_list_foreach (parts, add_if_attachment, &attachments_list);
- }
+ parts = TNY_LIST (tny_simple_list_new());
+ tny_mime_part_get_parts (TNY_MIME_PART (msg), parts);
+ tny_list_foreach (parts, add_if_attachment, &attachments_list);
new_msg = create_reply_forward_mail (msg, header, from, signature, TRUE, reply_type,
attachments_list);
}
return g_string_free(type, FALSE);
}
+
+guint64
+modest_tny_msg_estimate_size (const gchar *plain_body, const gchar *html_body,
+ guint64 parts_count,
+ guint64 parts_size)
+{
+ guint64 result;
+
+ /* estimation of headers size */
+ result = 1024;
+
+ /* We add a 20% of size due to the increase in 7bit encoding */
+ if (plain_body) {
+ result += strlen (plain_body) * 120 / 100;
+ }
+ if (html_body) {
+ result += strlen (html_body) * 120 / 100;
+ }
+
+ /* 256 bytes per additional part because of their headers */
+ result += parts_count * 256;
+
+ /* 150% of increase per encoding */
+ result += parts_size * 3 / 2;
+
+ return result;
+}