diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2003-08-14 00:30:35 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2003-08-14 00:30:35 +0800 |
commit | 3c7a8efeadf4c7ced34a16249d0876b6d09a3dbb (patch) | |
tree | e5292e5467acdaca8aa89b232d199e4fd0c81af1 | |
parent | a8ef795eb902d073b6975529106de3dd830b32fc (diff) | |
download | gsoc2013-evolution-3c7a8efeadf4c7ced34a16249d0876b6d09a3dbb.tar gsoc2013-evolution-3c7a8efeadf4c7ced34a16249d0876b6d09a3dbb.tar.gz gsoc2013-evolution-3c7a8efeadf4c7ced34a16249d0876b6d09a3dbb.tar.bz2 gsoc2013-evolution-3c7a8efeadf4c7ced34a16249d0876b6d09a3dbb.tar.lz gsoc2013-evolution-3c7a8efeadf4c7ced34a16249d0876b6d09a3dbb.tar.xz gsoc2013-evolution-3c7a8efeadf4c7ced34a16249d0876b6d09a3dbb.tar.zst gsoc2013-evolution-3c7a8efeadf4c7ced34a16249d0876b6d09a3dbb.zip |
This needs to use camel_data_wrapper_decode_to_stream() rather than
2003-08-13 Jeffrey Stedfast <fejj@ximian.com>
* e-msg-composer-attachment-bar.c (update): This needs to use
camel_data_wrapper_decode_to_stream() rather than
write_to_stream(). Also simplify a bit - no sense looping to load
the pixbuf data into the gdk-pixbuf loader 4K at a time when we
have the whole thing in a memory buffer already. Once done, unref
the stream instead of closing it so we don't leak.
(attach_to_multipart): Use decode_to_stream().
* e-msg-composer-attachment.c (e_msg_composer_attachment_new):
Avoid constructing thwe data-wrapper from the stream twice for
message/rfc822 parts.
svn path=/trunk/; revision=22213
-rw-r--r-- | composer/ChangeLog | 14 | ||||
-rw-r--r-- | composer/e-msg-composer-attachment-bar.c | 40 | ||||
-rw-r--r-- | composer/e-msg-composer-attachment.c | 17 |
3 files changed, 32 insertions, 39 deletions
diff --git a/composer/ChangeLog b/composer/ChangeLog index 425bcfe462..6c183d7f46 100644 --- a/composer/ChangeLog +++ b/composer/ChangeLog @@ -1,3 +1,17 @@ +2003-08-13 Jeffrey Stedfast <fejj@ximian.com> + + * e-msg-composer-attachment-bar.c (update): This needs to use + camel_data_wrapper_decode_to_stream() rather than + write_to_stream(). Also simplify a bit - no sense looping to load + the pixbuf data into the gdk-pixbuf loader 4K at a time when we + have the whole thing in a memory buffer already. Once done, unref + the stream instead of closing it so we don't leak. + (attach_to_multipart): Use decode_to_stream(). + + * e-msg-composer-attachment.c (e_msg_composer_attachment_new): + Avoid constructing thwe data-wrapper from the stream twice for + message/rfc822 parts. + 2003-07-16 Jeffrey Stedfast <fejj@ximian.com> * e-msg-composer-attachment-bar.c (attach_to_multipart): don't set diff --git a/composer/e-msg-composer-attachment-bar.c b/composer/e-msg-composer-attachment-bar.c index 4cc893ec1a..7e7d9227c3 100644 --- a/composer/e-msg-composer-attachment-bar.c +++ b/composer/e-msg-composer-attachment-bar.c @@ -235,42 +235,23 @@ update (EMsgComposerAttachmentBar *bar) if (image && attachment->pixbuf_cache == NULL) { CamelDataWrapper *wrapper; - CamelStream *mstream; + CamelStreamMem *mstream; GdkPixbufLoader *loader; gboolean error = TRUE; - char tmp[4096]; - int t; wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (attachment->body)); - mstream = camel_stream_mem_new (); + mstream = (CamelStreamMem *) camel_stream_mem_new (); - camel_data_wrapper_write_to_stream (wrapper, mstream); - - camel_stream_reset (mstream); + camel_data_wrapper_decode_to_stream (wrapper, (CamelStream *) mstream); /* Stream image into pixbuf loader */ loader = gdk_pixbuf_loader_new (); - do { - t = camel_stream_read (mstream, tmp, 4096); - if (t > 0) { - error = !gdk_pixbuf_loader_write (loader, tmp, t, NULL); - if (error) { - break; - } - } else { - if (camel_stream_eos (mstream)) - break; - error = TRUE; - break; - } - - } while (!camel_stream_eos (mstream)); + error = !gdk_pixbuf_loader_write (loader, mstream->buffer->data, mstream->buffer->len, NULL); + gdk_pixbuf_loader_close (loader, NULL); if (!error) { int ratio, width, height; - - gdk_pixbuf_loader_close (loader, NULL); - + /* Shrink pixbuf */ pixbuf = gdk_pixbuf_loader_get_pixbuf (loader); width = gdk_pixbuf_get_width (pixbuf); @@ -300,9 +281,8 @@ update (EMsgComposerAttachmentBar *bar) } /* Destroy everything */ - gdk_pixbuf_loader_close (loader, NULL); g_object_unref (loader); - camel_stream_close (mstream); + camel_object_unref (mstream); } desc = camel_mime_part_get_description (attachment->body); @@ -531,7 +511,7 @@ destroy (GtkObject *object) static void -popup_menu_placement_callback (GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer user_data) +popup_menu_placement_callback (GtkMenu *menu, int *x, int *y, gboolean *push_in, gpointer user_data) { EMsgComposerAttachmentBar *bar; GnomeIconList *icon_list; @@ -576,7 +556,7 @@ popup_menu_event (GtkWidget *widget) } -static gint +static int button_press_event (GtkWidget *widget, GdkEventButton *event) { @@ -761,7 +741,7 @@ attach_to_multipart (CamelMultipart *multipart, camel_stream_filter_add (filter_stream, CAMEL_MIME_FILTER (bestenc)); camel_object_unref (stream); - camel_data_wrapper_write_to_stream (content, CAMEL_STREAM (filter_stream)); + camel_data_wrapper_decode_to_stream (content, CAMEL_STREAM (filter_stream)); camel_object_unref (filter_stream); encoding = camel_mime_filter_bestenc_get_best_encoding (bestenc, CAMEL_BESTENC_8BIT); diff --git a/composer/e-msg-composer-attachment.c b/composer/e-msg-composer-attachment.c index 3d790eb2f2..fb7fe46073 100644 --- a/composer/e-msg-composer-attachment.c +++ b/composer/e-msg-composer-attachment.c @@ -186,23 +186,22 @@ e_msg_composer_attachment_new (const char *file_name, return NULL; } - wrapper = camel_data_wrapper_new (); - camel_data_wrapper_construct_from_stream (wrapper, stream); - mime_type = e_msg_composer_guess_mime_type (file_name); if (mime_type) { if (!strcasecmp (mime_type, "message/rfc822")) { - camel_object_unref (wrapper); wrapper = (CamelDataWrapper *) camel_mime_message_new (); - - camel_stream_reset (stream); - camel_data_wrapper_construct_from_stream (wrapper, stream); + } else { + wrapper = camel_data_wrapper_new (); } + camel_data_wrapper_construct_from_stream (wrapper, stream); camel_data_wrapper_set_mime_type (wrapper, mime_type); g_free (mime_type); - } else + } else { + wrapper = camel_data_wrapper_new (); + camel_data_wrapper_construct_from_stream (wrapper, stream); camel_data_wrapper_set_mime_type (wrapper, "application/octet-stream"); + } camel_object_unref (stream); @@ -211,7 +210,7 @@ e_msg_composer_attachment_new (const char *file_name, camel_object_unref (wrapper); camel_mime_part_set_disposition (part, disposition); - filename = g_path_get_basename(file_name); + filename = g_path_get_basename (file_name); camel_mime_part_set_filename (part, filename); g_free (filename); |