* Added methods for getting estimation of parts size in message.
* src/modest-window-mgr.c:
* If save to drafts fails because of disk being full, then
we don't close the editor window.
* src/widgets/modest-attachment-view.[ch]:
* Added methods to set the size externally, and be able to avoid
counting the size going through the full stream.
* src/widgets/modest-window.c:
* Close from escape shortcut only on view window, not only on
edit window. This was really not working properly, as press
was processed and release was processed after the dialog, if
more than one second was spent, then the press was considered
a force close.
* src/widgets/modest-attachments-view.[ch]:
* Added methods to get the size of attachments inside.
* src/modest-tny-msg.[ch]:
* Added method to estimate the storage size of a message, using
simply the size of the attachments and the body parts.
* src/modest-ui-actions.[ch]:
* On saving to drafts or sending new mails, we estimate the size
the message will have on device disk. If it's too big, we
cancel the save operation, and show a banner (fixes NB#77528).
* src/maemo/modest-msg-edit-window.c:
* Methods to estimate file size of attachments added (using vfs)
and the full message space (offering size of attachmetns and
images).
* src/modest-utils.c:
* New method to get the available space on device disk.
* src/modest-mail-operation.c:
* If there's an error in create msg, notify operation failed.
pmo-trunk-r4079
gint last_cid;
TnyList *attachments;
TnyList *images;
+ guint64 images_size;
+ gint images_count;
TnyHeaderFlags priority_flags;
priv->subject_field = NULL;
priv->attachments = TNY_LIST (tny_simple_list_new ());
priv->images = TNY_LIST (tny_simple_list_new ());
+ priv->images_size = 0;
+ priv->images_count = 0;
priv->last_cid = 0;
priv->cc_caption = NULL;
}
static GdkPixbuf *
-pixbuf_from_stream (TnyStream *stream, const gchar *mime_type)
+pixbuf_from_stream (TnyStream *stream, const gchar *mime_type, guint64 *stream_size)
{
GdkPixbufLoader *loader;
GdkPixbuf *pixbuf;
+ guint64 size;
+
+ size = 0;
loader = gdk_pixbuf_loader_new_with_mime_type (mime_type, NULL);
- if (loader == NULL)
+ if (loader == NULL) {
+ if (stream_size)
+ *stream_size = 0;
return NULL;
+ }
tny_stream_reset (TNY_STREAM (stream));
while (!tny_stream_is_eos (TNY_STREAM (stream))) {
unsigned char read_buffer[128];
gint readed;
readed = tny_stream_read (TNY_STREAM (stream), (char *) read_buffer, 128);
+ size += readed;
if (!gdk_pixbuf_loader_write (loader, read_buffer, readed, NULL))
break;
}
pixbuf = new_pixbuf;
}
+ if (stream_size)
+ *stream_size = size;
+
return pixbuf;
}
const gchar *cid = tny_mime_part_get_content_id (part);
const gchar *mime_type = tny_mime_part_get_content_type (part);
if ((cid != NULL)&&(mime_type != NULL)) {
+ guint64 stream_size;
TnyStream *stream = tny_mime_part_get_stream (part);
- GdkPixbuf *pixbuf = pixbuf_from_stream (stream, mime_type);
+ GdkPixbuf *pixbuf = pixbuf_from_stream (stream, mime_type, &stream_size);
+
+
g_object_unref (stream);
if (pixbuf != NULL) {
+ priv->images_count ++;
+ priv->images_size += stream_size;
wp_text_buffer_replace_image (WP_TEXT_BUFFER (priv->text_buffer), cid, pixbuf);
g_object_unref (pixbuf);
}
wp_text_buffer_save_document (WP_TEXT_BUFFER(priv->text_buffer), get_formatted_data_cb, &string_buffer);
+ gtk_text_buffer_set_modified (priv->text_buffer, TRUE);
+
return g_string_free (string_buffer, FALSE);
}
g_slice_free (MsgData, data);
}
+void
+modest_msg_edit_window_get_parts_size (ModestMsgEditWindow *window,
+ gint *parts_count,
+ guint64 *parts_size)
+{
+ ModestMsgEditWindowPrivate *priv;
+
+ priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (window);
+
+ modest_attachments_view_get_sizes (MODEST_ATTACHMENTS_VIEW (priv->attachments_view), parts_count, parts_size);
+
+ /* TODO: add images */
+ *parts_size += priv->images_size;
+ *parts_count += priv->images_count;
+
+}
+
ModestMsgEditFormat
modest_msg_edit_window_get_format (ModestMsgEditWindow *self)
{
gchar *content_id;
const gchar *mime_type = NULL;
GnomeVFSURI *vfs_uri;
+ guint64 stream_size;
vfs_uri = gnome_vfs_uri_new (uri);
tny_mime_part_set_filename (mime_part, basename);
g_free (basename);
- pixbuf = pixbuf_from_stream (stream, mime_type);
+ pixbuf = pixbuf_from_stream (stream, mime_type, &stream_size);
if (pixbuf != NULL) {
+ priv->images_size += stream_size;
+ priv->images_count ++;
insert_mark = gtk_text_buffer_get_insert (GTK_TEXT_BUFFER (priv->text_buffer));
gtk_text_buffer_get_iter_at_mark (GTK_TEXT_BUFFER (priv->text_buffer), &position, insert_mark);
wp_text_buffer_insert_image (WP_TEXT_BUFFER (priv->text_buffer), &position, g_strdup (tny_mime_part_get_content_id (mime_part)), pixbuf);
tny_list_prepend (priv->attachments, (GObject *) mime_part);
modest_attachments_view_add_attachment (MODEST_ATTACHMENTS_VIEW (priv->attachments_view),
- mime_part);
+ mime_part,
+ info.size == 0, info.size);
gtk_widget_set_no_show_all (priv->attachments_caption, FALSE);
gtk_widget_show_all (priv->attachments_caption);
gtk_text_buffer_set_modified (priv->text_buffer, TRUE);
g_return_if_fail (TNY_IS_MIME_PART (part));
tny_list_prepend (priv->attachments, (GObject *) part);
- modest_attachments_view_add_attachment (MODEST_ATTACHMENTS_VIEW (priv->attachments_view), part);
+ modest_attachments_view_add_attachment (MODEST_ATTACHMENTS_VIEW (priv->attachments_view), part, TRUE, 0);
gtk_widget_set_no_show_all (priv->attachments_caption, FALSE);
gtk_widget_show_all (priv->attachments_caption);
gtk_text_buffer_set_modified (priv->text_buffer, TRUE);
#include "modest-marshal.h"
#include "modest-error.h"
#include "modest-mail-operation.h"
+#include <modest-count-stream.h>
+#include <libgnomevfs/gnome-vfs.h>
+#include "modest-utils.h"
#define KB 1024
return NULL;
}
+
void
modest_mail_operation_create_msg (ModestMailOperation *self,
const gchar *from, const gchar *to,
ModestMailOperationCreateMsgCallback callback,
gpointer userdata)
{
+ ModestMailOperationPrivate *priv;
CreateMsgInfo *info = NULL;
+ priv = MODEST_MAIL_OPERATION_GET_PRIVATE(self);
+
info = g_slice_new0 (CreateMsgInfo);
info->mail_op = g_object_ref (self);
TnyMsg *msg,
gpointer userdata)
{
+ ModestMailOperationPrivate *priv = NULL;
SendNewMailInfo *info = (SendNewMailInfo *) userdata;
TnyFolder *draft_folder = NULL;
TnyFolder *outbox_folder = NULL;
goto end;
}
+ priv = MODEST_MAIL_OPERATION_GET_PRIVATE (self);
+
+ if (priv->error) {
+ priv->status = MODEST_MAIL_OPERATION_STATUS_FAILED;
+ modest_mail_operation_notify_end (self);
+ goto end;
+ }
+
/* Call mail operation */
modest_mail_operation_send_mail (self, info->transport_account, msg);
}
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;
+}
const gchar* modest_tny_msg_get_parent_uid (TnyMsg *msg);
-
+/**
+ * modest_tny_msg_estimate_size:
+ * @plain_body: a string
+ * @html_body: a string
+ * @parts_number: a gint (number of additional parts)
+ * @parts_size: a guint64 (sum of size of the additional parts)
+ *
+ * Estimates the size of the resulting message obtained from the size of the body
+ * parts, and adding the estimation of size headers.
+ */
+guint64
+modest_tny_msg_estimate_size (const gchar *plain_body, const gchar *html_body,
+ guint64 parts_count,
+ guint64 parts_size);
#endif /* __MODEST_TNY_MSG_H__ */
g_object_unref(edit_window);
}
-void
+gboolean
modest_ui_actions_on_save_to_drafts (GtkWidget *widget, ModestMsgEditWindow *edit_window)
{
TnyTransportAccount *transport_account;
gchar *account_name, *from;
ModestAccountMgr *account_mgr;
char *info_text;
+ gboolean had_error = FALSE;
+ guint64 available_disk, expected_size;
+ gint parts_count;
+ guint64 parts_size;
- g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW(edit_window));
+ g_return_val_if_fail (MODEST_IS_MSG_EDIT_WINDOW(edit_window), FALSE);
data = modest_msg_edit_window_get_msg_data (edit_window);
+ /* Check size */
+ available_disk = modest_folder_available_space (NULL);
+ modest_msg_edit_window_get_parts_size (edit_window, &parts_count, &parts_size);
+ expected_size = modest_tny_msg_estimate_size (data->plain_body,
+ data->html_body,
+ parts_count,
+ parts_size);
+
+ if ((available_disk != -1) && expected_size > available_disk) {
+ modest_msg_edit_window_free_msg_data (edit_window, data);
+
+ modest_platform_information_banner (NULL, NULL, dgettext("ke-recv", "cerm_device_memory_full"));
+ return FALSE;
+ }
+
account_name = g_strdup (data->account_name);
account_mgr = modest_runtime_get_account_mgr();
if (!account_name)
if (!account_name) {
g_printerr ("modest: no account found\n");
modest_msg_edit_window_free_msg_data (edit_window, data);
- return;
+ return FALSE;
}
if (!strcmp (account_name, MODEST_LOCAL_FOLDERS_ACCOUNT_ID)) {
g_printerr ("modest: no transport account found for '%s'\n", account_name);
g_free (account_name);
modest_msg_edit_window_free_msg_data (edit_window, data);
- return;
+ return FALSE;
}
from = modest_account_mgr_get_from_string (account_mgr, account_name);
data->priority_flags,
on_save_to_drafts_cb,
g_object_ref(edit_window));
+
info_text = g_strdup_printf (_("mail_va_saved_to_drafts"), _("mcen_me_folder_drafts"));
modest_platform_information_banner (NULL, NULL, info_text);
+ g_free (info_text);
+ modest_msg_edit_window_reset_modified (edit_window);
/* Frees */
- g_free (info_text);
g_free (from);
g_free (account_name);
g_object_unref (G_OBJECT (transport_account));
g_object_unref (G_OBJECT (mail_operation));
modest_msg_edit_window_free_msg_data (edit_window, data);
- modest_msg_edit_window_reset_modified (edit_window);
/* ** FIXME **
* If the drafts folder is selected then make the header view
*/
ModestMainWindow *win = MODEST_MAIN_WINDOW(modest_window_mgr_get_main_window(
modest_runtime_get_window_mgr(), FALSE));
- if (win != NULL) {
+ if (!had_error && win != NULL) {
ModestFolderView *view = MODEST_FOLDER_VIEW(modest_main_window_get_child_widget(
win, MODEST_MAIN_WINDOW_WIDGET_TYPE_FOLDER_VIEW));
if (view != NULL) {
if (folder != NULL) g_object_unref(folder);
}
}
+
+ return !had_error;
}
/* For instance, when clicking the Send toolbar button when editing a message: */
-void
+gboolean
modest_ui_actions_on_send (GtkWidget *widget, ModestMsgEditWindow *edit_window)
{
TnyTransportAccount *transport_account = NULL;
+ gboolean had_error = FALSE;
+ guint64 available_disk, expected_size;
+ gint parts_count;
+ guint64 parts_size;
- g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW(edit_window));
+ g_return_val_if_fail (MODEST_IS_MSG_EDIT_WINDOW(edit_window), TRUE);
if (!modest_msg_edit_window_check_names (edit_window, TRUE))
- return;
+ return TRUE;
/* FIXME: Code added just for testing. The final version will
use the send queue provided by tinymail and some
classifier */
MsgData *data = modest_msg_edit_window_get_msg_data (edit_window);
+ /* Check size */
+ available_disk = modest_folder_available_space (NULL);
+ modest_msg_edit_window_get_parts_size (edit_window, &parts_count, &parts_size);
+ expected_size = modest_tny_msg_estimate_size (data->plain_body,
+ data->html_body,
+ parts_count,
+ parts_size);
+
+ if ((available_disk != -1) && expected_size > available_disk) {
+ modest_msg_edit_window_free_msg_data (edit_window, data);
+
+ modest_platform_information_banner (NULL, NULL, dgettext("ke-recv", "cerm_device_memory_full"));
+ return FALSE;
+ }
+
ModestAccountMgr *account_mgr = modest_runtime_get_account_mgr();
gchar *account_name = g_strdup (data->account_name);
if (!account_name)
modest_msg_edit_window_free_msg_data (edit_window, data);
/* Run account setup wizard */
if (!modest_ui_actions_run_account_setup_wizard (MODEST_WINDOW(edit_window))) {
- return;
+ return TRUE;
}
}
modest_msg_edit_window_free_msg_data (edit_window, data);
/* Run account setup wizard */
if (!modest_ui_actions_run_account_setup_wizard(MODEST_WINDOW(edit_window)))
- return;
+ return TRUE;
}
gchar *from = modest_account_mgr_get_from_string (account_mgr, account_name);
if (modest_mail_operation_get_status (mail_operation) == MODEST_MAIL_OPERATION_STATUS_IN_PROGRESS)
modest_platform_information_banner (NULL, NULL, _("mcen_ib_outbox_waiting_to_be_sent"));
+
+ if (modest_mail_operation_get_error (mail_operation) != NULL) {
+ const GError *error = modest_mail_operation_get_error (mail_operation);
+ if (error->code == MODEST_MAIL_OPERATION_ERROR_INSTANCE_CREATION_FAILED) {
+ g_warning ("%s failed: %s\n", __FUNCTION__, (modest_mail_operation_get_error (mail_operation))->message);
+ modest_platform_information_banner (NULL, NULL, _CS("sfil_ni_not_enough_memory"));
+ had_error = TRUE;
+ }
+ }
/* Free data: */
g_free (from);
g_object_unref (G_OBJECT (mail_operation));
modest_msg_edit_window_free_msg_data (edit_window, data);
- modest_msg_edit_window_set_sent (edit_window, TRUE);
- /* Save settings and close the window: */
- modest_ui_actions_on_close_window (NULL, MODEST_WINDOW (edit_window));
+ if (!had_error) {
+ modest_msg_edit_window_set_sent (edit_window, TRUE);
+
+ /* Save settings and close the window: */
+ modest_ui_actions_on_close_window (NULL, MODEST_WINDOW (edit_window));
+ }
+
+ return !had_error;
}
void
void modest_ui_actions_on_msg_recpt_activated (ModestMsgView *msgview, const gchar *address,
ModestWindow *win);
-void modest_ui_actions_on_send (GtkWidget *widget,
+gboolean modest_ui_actions_on_send (GtkWidget *widget,
ModestMsgEditWindow *edit_window);
-void modest_ui_actions_on_save_to_drafts (GtkWidget *widget,
+gboolean modest_ui_actions_on_save_to_drafts (GtkWidget *widget,
ModestMsgEditWindow *edit_window);
#include <modest-defs.h>
#include "modest-utils.h"
#include "modest-platform.h"
+#include <modest-local-folder-info.h>
GQuark
modest_utils_get_supported_secure_authentication_error_quark (void)
g_object_unref (iter);
return index;
}
+
+guint64
+modest_folder_available_space (const gchar *maildir_path)
+{
+ gchar *folder;
+ gchar *uri_string;
+ GnomeVFSURI *uri;
+ GnomeVFSFileSize size;
+
+ folder = modest_local_folder_info_get_maildir_path (maildir_path);
+ uri_string = gnome_vfs_get_uri_from_local_path (folder);
+ uri = gnome_vfs_uri_new (uri_string);
+ g_free (folder);
+ g_free (uri_string);
+
+ if (uri) {
+ if (gnome_vfs_get_volume_free_space (uri, &size) != GNOME_VFS_OK)
+ size = -1;
+ gnome_vfs_uri_unref (uri);
+ } else {
+ size = -1;
+ }
+
+ return (guint64) size;
+}
*/
gint modest_list_index (TnyList *list, GObject *object);
+/**
+ * modest_folder_available_space:
+ * @maildir_path: the path of the maildir folder, or %NULL to
+ * get the space available in local folders
+ *
+ * Obtains the space available in the local folder.
+ *
+ * Returns: a #guint64
+ */
+guint64 modest_folder_available_space (const gchar *maildir_path);
+
#endif /*__MODEST_MAEMO_UTILS_H__*/
GtkWidget *filename_view;
GtkWidget *size_view;
- guint get_size_idle_id;
+ gboolean detect_size;
TnyStream *get_size_stream;
guint64 size;
static void update_filename_request (ModestAttachmentView *self);
+static void update_size_label (ModestAttachmentView *self)
+{
+ ModestAttachmentViewPrivate *priv = MODEST_ATTACHMENT_VIEW_GET_PRIVATE (self);
+ gchar *size_str;
+ gchar *label_text;
+
+ size_str = modest_text_utils_get_display_size (priv->size);
+ label_text = g_strdup_printf (" (%s)", size_str);
+ g_free (size_str);
+ gtk_label_set_text (GTK_LABEL (priv->size_view), label_text);
+ g_free (label_text);
+}
static gboolean
idle_get_mime_part_size_cb (gpointer userdata)
{
ModestAttachmentView *view = (ModestAttachmentView *) userdata;
- ModestAttachmentViewPrivate *priv = MODEST_ATTACHMENT_VIEW_GET_PRIVATE (view);
- gchar *size_str;
- gchar *label_text;
gdk_threads_enter ();
if (GTK_WIDGET_VISIBLE (view)) {
- size_str = modest_text_utils_get_display_size (priv->size);
- label_text = g_strdup_printf (" (%s)", size_str);
- g_free (size_str);
- gtk_label_set_text (GTK_LABEL (priv->size_view), label_text);
- g_free (label_text);
+ update_size_label (view);
}
gdk_threads_leave ();
return NULL;
}
+void
+modest_attachment_view_set_detect_size (ModestAttachmentView *self, gboolean detect_size)
+{
+ ModestAttachmentViewPrivate *priv = MODEST_ATTACHMENT_VIEW_GET_PRIVATE (self);
+
+ priv->detect_size = detect_size;
+
+}
+
+void
+modest_attachment_view_set_size (ModestAttachmentView *self, guint64 size)
+{
+ ModestAttachmentViewPrivate *priv;
+
+ g_return_if_fail (MODEST_IS_ATTACHMENT_VIEW (self));
+ priv = MODEST_ATTACHMENT_VIEW_GET_PRIVATE (self);
+
+ if (!priv->detect_size) {
+ priv->size = size;
+ update_size_label (self);
+ } else {
+ g_assert ("Shouldn't set the size of the attachment view if detect size is enabled");
+ }
+}
+
+guint64
+modest_attachment_view_get_size (ModestAttachmentView *self)
+{
+ ModestAttachmentViewPrivate *priv;
+
+ g_return_val_if_fail (MODEST_IS_ATTACHMENT_VIEW (self), 0);
+ priv = MODEST_ATTACHMENT_VIEW_GET_PRIVATE (self);
+
+ return priv->size;
+}
+
static TnyMimePart *
modest_attachment_view_get_part (TnyMimePartView *self)
{
gtk_label_set_text (GTK_LABEL (priv->size_view), "");
- if (show_size) {
+ if (show_size && priv->detect_size) {
tny_camel_mem_stream_get_type ();
g_object_ref (self);
g_thread_create (get_mime_part_size_thread, self, FALSE, NULL);
priv->mime_part = NULL;
}
- if (priv->get_size_idle_id != 0) {
- g_source_remove (priv->get_size_idle_id);
- priv->get_size_idle_id = 0;
- }
-
if (priv->get_size_stream != NULL) {
g_object_unref (priv->get_size_stream);
priv->get_size_stream = NULL;
* Return value: a new #ModestAttachmentView instance implemented for Gtk+
**/
GtkWidget*
-modest_attachment_view_new (TnyMimePart *mime_part)
+modest_attachment_view_new (TnyMimePart *mime_part, gboolean detect_size)
{
ModestAttachmentView *self = g_object_new (MODEST_TYPE_ATTACHMENT_VIEW,
NULL);
+ modest_attachment_view_set_detect_size (self, detect_size);
+
modest_attachment_view_set_part (TNY_MIME_PART_VIEW (self), mime_part);
return GTK_WIDGET (self);
gtk_misc_set_alignment (GTK_MISC (priv->size_view), 0.0, 0.5);
gtk_misc_set_alignment (GTK_MISC (priv->filename_view), 0.0, 0.5);
- priv->get_size_idle_id = 0;
priv->get_size_stream = NULL;
priv->size = 0;
+ priv->detect_size = TRUE;
box = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (box), priv->icon, FALSE, FALSE, 0);
{
ModestAttachmentViewPrivate *priv = MODEST_ATTACHMENT_VIEW_GET_PRIVATE (object);
- if (priv->get_size_idle_id) {
- g_source_remove (priv->get_size_idle_id);
- priv->get_size_idle_id = 0;
- }
-
if (priv->get_size_stream != NULL) {
g_object_unref (priv->get_size_stream);
priv->get_size_stream = NULL;
GType modest_attachment_view_get_type (void);
-GtkWidget* modest_attachment_view_new (TnyMimePart *mime_part);
+GtkWidget* modest_attachment_view_new (TnyMimePart *mime_part, gboolean detect_size);
+void modest_attachment_view_set_detect_size (ModestAttachmentView *self, gboolean detect_size);
+void modest_attachment_view_set_size (ModestAttachmentView *self, guint64 size);
+guint64 modest_attachment_view_get_size (ModestAttachmentView *self);
+
+
G_END_DECLS
part = TNY_MIME_PART (tny_iterator_get_current (iter));
if (part && (modest_tny_mime_part_is_attachment_for_modest (part)))
- modest_attachments_view_add_attachment (attachments_view, part);
+ modest_attachments_view_add_attachment (attachments_view, part, TRUE, 0);
if (part)
g_object_unref (part);
}
void
-modest_attachments_view_add_attachment (ModestAttachmentsView *attachments_view, TnyMimePart *part)
+modest_attachments_view_add_attachment (ModestAttachmentsView *attachments_view, TnyMimePart *part,
+ gboolean detect_size, guint64 size)
{
GtkWidget *att_view = NULL;
ModestAttachmentsViewPrivate *priv = NULL;
priv = MODEST_ATTACHMENTS_VIEW_GET_PRIVATE (attachments_view);
- att_view = modest_attachment_view_new (part);
+ att_view = modest_attachment_view_new (part, detect_size);
+ if (!detect_size)
+ modest_attachment_view_set_size (MODEST_ATTACHMENT_VIEW (att_view), size);
gtk_box_pack_end (GTK_BOX (priv->box), att_view, FALSE, FALSE, 0);
gtk_widget_show_all (att_view);
}
return result;
}
+void
+modest_attachments_view_get_sizes (ModestAttachmentsView *attachments_view,
+ gint *attachments_count,
+ guint64 *attachments_size)
+{
+ ModestAttachmentsViewPrivate *priv;
+ GList *children, *node;
+
+ g_return_if_fail (MODEST_IS_ATTACHMENTS_VIEW (attachments_view));
+ g_return_if_fail (attachments_count != NULL && attachments_size != NULL);
+
+ *attachments_count = 0;
+ *attachments_size = 0;
+
+ priv = MODEST_ATTACHMENTS_VIEW_GET_PRIVATE (attachments_view);
+
+ children = gtk_container_get_children (GTK_CONTAINER (priv->box));
+ for (node = children; node != NULL; node = g_list_next (node)) {
+ GtkWidget *att_view = (GtkWidget *) node->data;
+ TnyMimePart *part = tny_mime_part_view_get_part (TNY_MIME_PART_VIEW (att_view));
+
+ if (!tny_mime_part_is_purged (part)) {
+ guint64 size;
+ *attachments_count ++;
+ size = modest_attachment_view_get_size (MODEST_ATTACHMENT_VIEW (att_view));
+ if (size == 0) {
+ /* we do a random estimation of the size of an attachment */
+ size = 32768;
+ }
+ *attachments_size += size;
+
+ }
+ g_object_unref (part);
+ }
+ g_list_free (children);
+}
+
static void
own_clipboard (ModestAttachmentsView *atts_view)
{
GtkWidget* modest_attachments_view_new (TnyMsg *msg);
void modest_attachments_view_set_message (ModestAttachmentsView *attachments_view, TnyMsg *msg);
-void modest_attachments_view_add_attachment (ModestAttachmentsView *attachments_view, TnyMimePart *part);
+void modest_attachments_view_add_attachment (ModestAttachmentsView *attachments_view, TnyMimePart *part,
+ gboolean detect_size, guint64 size);
void modest_attachments_view_remove_attachment (ModestAttachmentsView *attachments_view, TnyMimePart *part);
void modest_attachments_view_remove_attachment_by_id (ModestAttachmentsView *attachments_view, const gchar *att_id);
TnyList *modest_attachments_view_get_attachments (ModestAttachmentsView *attachments_view);
gboolean modest_attachments_view_has_attachments (ModestAttachmentsView *attachments_view);
+void modest_attachments_view_get_sizes (ModestAttachmentsView *attachments_view,
+ gint *attachments_count,
+ guint64 *attachments_size);
+
G_END_DECLS
#endif
TnyList *att_list);
/**
+ * modest_msg_edit_window_get_parts_size:
+ * @window: a #ModestMsgEditWindow
+ * @parts_count: number of attachments and images attached to the message
+ * @parts_size: sum of sizes of attachments and images
+ */
+void modest_msg_edit_window_get_parts_size (ModestMsgEditWindow *window,
+ gint *parts_count,
+ guint64 *parts_size);
+/**
* modest_msg_edit_window_add_part:
* @self: a #ModestMsgEditWindow
* @part: a #TnyMimePart
_("mcen_nc_no_email_message_modified_save_changes"));
/* Save to drafts */
if (response != GTK_RESPONSE_CANCEL)
- modest_ui_actions_on_save_to_drafts (NULL, MODEST_MSG_EDIT_WINDOW (window));
+ if (!modest_ui_actions_on_save_to_drafts (NULL, MODEST_MSG_EDIT_WINDOW (window)))
+ return TRUE;
}
}
}
case GDK_Escape:
if (modest_window_mgr_get_fullscreen_mode (mgr))
modest_ui_actions_on_change_fullscreen (NULL, MODEST_WINDOW(self));
- else if (MODEST_IS_MSG_VIEW_WINDOW (self)||MODEST_IS_MSG_EDIT_WINDOW (self))
+ else if (MODEST_IS_MSG_VIEW_WINDOW (self))
modest_ui_actions_on_close_window (NULL, MODEST_WINDOW (self));
break;
}