X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=src%2Fwidgets%2Fmodest-attachment-view.c;h=a5b6aa4f5bfa6f41e3b069f0c56106f027a44abd;hb=a8c98320eac2c32a0427101113a3b9f134290771;hp=7960fb0b4c2e801b320144bcc27160d530da7a06;hpb=0c46a692d7b9a41ff219874752172b6f7aa3a804;p=modest diff --git a/src/widgets/modest-attachment-view.c b/src/widgets/modest-attachment-view.c index 7960fb0..a5b6aa4 100644 --- a/src/widgets/modest-attachment-view.c +++ b/src/widgets/modest-attachment-view.c @@ -42,6 +42,7 @@ #include #include #include +#include #define GET_SIZE_BUFFER_SIZE 128 @@ -122,25 +123,18 @@ get_mime_part_size_thread (gpointer thr_user_data) { ModestAttachmentView *view = (ModestAttachmentView *) thr_user_data; ModestAttachmentViewPrivate *priv = MODEST_ATTACHMENT_VIEW_GET_PRIVATE (view); - gchar read_buffer[GET_SIZE_BUFFER_SIZE]; TnyStream *stream; - gssize readed_size; - gssize total = 0; + gsize total = 0; - stream = tny_camel_mem_stream_new (); + stream = modest_count_stream_new(); tny_mime_part_decode_to_stream (priv->mime_part, stream); - tny_stream_reset (stream); - if (tny_stream_is_eos (stream)) { - tny_stream_close (stream); - stream = tny_mime_part_get_stream (priv->mime_part); + total = modest_count_stream_get_count(MODEST_COUNT_STREAM (stream)); + if (total == 0) { + modest_count_stream_reset_count(MODEST_COUNT_STREAM (stream)); + tny_mime_part_write_to_stream (priv->mime_part, stream); + total = modest_count_stream_get_count(MODEST_COUNT_STREAM (stream)); } - - while (!tny_stream_is_eos (stream)) { - readed_size = tny_stream_read (stream, read_buffer, GET_SIZE_BUFFER_SIZE); - total += readed_size; - } - - priv->size = total; + priv->size = (guint64)total; g_idle_add (idle_get_mime_part_size_cb, g_object_ref (view)); @@ -212,7 +206,7 @@ modest_attachment_view_set_part_default (TnyMimePartView *self, TnyMimePart *mim TnyHeader *header = tny_msg_get_header (TNY_MSG (mime_part)); if (TNY_IS_HEADER (header)) { filename = g_strdup (tny_header_get_subject (header)); - if (filename == NULL) + if (filename == NULL || filename[0] == '\0') filename = g_strdup (_("mail_va_no_subject")); if (priv->is_purged) file_icon_name = modest_platform_get_file_icon_name (NULL, NULL, NULL);