diff options
author | Milan Crha <mcrha@redhat.com> | 2012-04-13 22:18:01 +0800 |
---|---|---|
committer | Milan Crha <mcrha@redhat.com> | 2012-04-13 22:18:01 +0800 |
commit | 7c1a7df115abbfe389d224c9adc3261c3eb771da (patch) | |
tree | d99baba02409f79ec33068dff683f36300443196 | |
parent | 2f530637b15a2a07bd1df1aabef91ffc4f26ddee (diff) | |
download | gsoc2013-evolution-7c1a7df115abbfe389d224c9adc3261c3eb771da.tar gsoc2013-evolution-7c1a7df115abbfe389d224c9adc3261c3eb771da.tar.gz gsoc2013-evolution-7c1a7df115abbfe389d224c9adc3261c3eb771da.tar.bz2 gsoc2013-evolution-7c1a7df115abbfe389d224c9adc3261c3eb771da.tar.lz gsoc2013-evolution-7c1a7df115abbfe389d224c9adc3261c3eb771da.tar.xz gsoc2013-evolution-7c1a7df115abbfe389d224c9adc3261c3eb771da.tar.zst gsoc2013-evolution-7c1a7df115abbfe389d224c9adc3261c3eb771da.zip |
Bug #600860 - Opening IMAP message with large attachment blocks UI
-rw-r--r-- | modules/calendar/e-cal-attachment-handler.c | 4 | ||||
-rw-r--r-- | modules/mail/e-mail-attachment-handler.c | 5 | ||||
-rw-r--r-- | widgets/misc/e-attachment.c | 34 |
3 files changed, 36 insertions, 7 deletions
diff --git a/modules/calendar/e-cal-attachment-handler.c b/modules/calendar/e-cal-attachment-handler.c index 604bc737da..3b18f426aa 100644 --- a/modules/calendar/e-cal-attachment-handler.c +++ b/modules/calendar/e-cal-attachment-handler.c @@ -75,6 +75,10 @@ attachment_handler_get_component (EAttachment *attachment) if (component != NULL) return component; + if (e_attachment_get_loading (attachment) || + e_attachment_get_saving (attachment)) + return NULL; + mime_part = e_attachment_get_mime_part (attachment); if (!CAMEL_IS_MIME_PART (mime_part)) return NULL; diff --git a/modules/mail/e-mail-attachment-handler.c b/modules/mail/e-mail-attachment-handler.c index 00f416c564..b3e14328e4 100644 --- a/modules/mail/e-mail-attachment-handler.c +++ b/modules/mail/e-mail-attachment-handler.c @@ -444,6 +444,11 @@ mail_attachment_handler_update_actions (EAttachmentView *view, goto exit; attachment = E_ATTACHMENT (selected->data); + + if (e_attachment_get_loading (attachment) || + e_attachment_get_saving (attachment)) + goto exit; + mime_part = e_attachment_get_mime_part (attachment); if (!CAMEL_IS_MIME_PART (mime_part)) diff --git a/widgets/misc/e-attachment.c b/widgets/misc/e-attachment.c index 0678296767..31e0abf330 100644 --- a/widgets/misc/e-attachment.c +++ b/widgets/misc/e-attachment.c @@ -1751,17 +1751,27 @@ attachment_load_query_info_cb (GFile *file, attachment_load_file_read_cb, load_context); } +#define ATTACHMENT_LOAD_CONTEXT "attachment-load-context-data" + static void -attachment_load_from_mime_part (LoadContext *load_context) +attachment_load_from_mime_part_thread (GSimpleAsyncResult *simple, + GObject *object, + GCancellable *cancellable) { + LoadContext *load_context; GFileInfo *file_info; EAttachment *attachment; - GSimpleAsyncResult *simple; CamelContentType *content_type; CamelMimePart *mime_part; const gchar *attribute; const gchar *string; gchar *allocated; + CamelStream *null; + CamelDataWrapper *dw; + + load_context = g_object_get_data (G_OBJECT (simple), ATTACHMENT_LOAD_CONTEXT); + g_return_if_fail (load_context != NULL); + g_object_set_data (G_OBJECT (simple), ATTACHMENT_LOAD_CONTEXT, NULL); attachment = load_context->attachment; mime_part = e_attachment_get_mime_part (attachment); @@ -1819,6 +1829,13 @@ attachment_load_from_mime_part (LoadContext *load_context) g_file_info_set_attribute_string ( file_info, attribute, string); + dw = camel_medium_get_content (CAMEL_MEDIUM (mime_part)); + null = camel_stream_null_new (); + /* this actually downloads the part and makes it available later */ + camel_data_wrapper_decode_to_stream_sync (dw, null, attachment->priv->cancellable, NULL); + g_file_info_set_size (file_info, CAMEL_STREAM_NULL (null)->written); + g_object_unref (null); + string = camel_mime_part_get_disposition (mime_part); e_attachment_set_disposition (attachment, string); @@ -1826,11 +1843,9 @@ attachment_load_from_mime_part (LoadContext *load_context) g_object_ref (mime_part); - simple = load_context->simple; g_simple_async_result_set_op_res_gpointer ( simple, mime_part, (GDestroyNotify) g_object_unref); - g_simple_async_result_complete (simple); attachment_load_context_free (load_context); } @@ -1873,16 +1888,21 @@ e_attachment_load_async (EAttachment *attachment, cancellable = attachment->priv->cancellable; g_cancellable_reset (cancellable); - if (file != NULL) + if (file != NULL) { g_file_query_info_async ( file, ATTACHMENT_QUERY, G_FILE_QUERY_INFO_NONE,G_PRIORITY_DEFAULT, cancellable, (GAsyncReadyCallback) attachment_load_query_info_cb, load_context); - else if (mime_part != NULL) - attachment_load_from_mime_part (load_context); + } else if (mime_part != NULL) { + g_object_set_data (G_OBJECT (load_context->simple), ATTACHMENT_LOAD_CONTEXT, load_context); + g_simple_async_result_run_in_thread (load_context->simple, + attachment_load_from_mime_part_thread, + G_PRIORITY_DEFAULT, + cancellable); + } } gboolean |