From 2409d71026645028f49bfd0f745e93346cc17450 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Wed, 26 Apr 2000 20:42:22 +0000 Subject: Update for camel_mime_part_set_content. svn path=/trunk/; revision=2644 --- composer/ChangeLog | 6 +++-- composer/e-msg-composer-attachment-bar.c | 40 +++++++++++++++++--------------- composer/e-msg-composer.c | 6 ++--- 3 files changed, 27 insertions(+), 25 deletions(-) diff --git a/composer/ChangeLog b/composer/ChangeLog index 33aee5962c..2bf6f7e439 100644 --- a/composer/ChangeLog +++ b/composer/ChangeLog @@ -1,8 +1,10 @@ 2000-04-26 Dan Winship * e-msg-composer-attachment-bar.c (attach_to_multipart): add a - s/SIMPLE_// that notzed missed - * e-msg-composer.c (build_message): remove a now-unused variable + s/SIMPLE_// that notzed missed. Update to use + camel_mime_part_set_content. + * e-msg-composer.c (build_message): remove a now-unused variable. + Update for camel_mime_part_set_content. 2000-04-26 NotZed diff --git a/composer/e-msg-composer-attachment-bar.c b/composer/e-msg-composer-attachment-bar.c index 83c9088d07..b83b4e1a41 100644 --- a/composer/e-msg-composer-attachment-bar.c +++ b/composer/e-msg-composer-attachment-bar.c @@ -605,30 +605,32 @@ attach_to_multipart (CamelMultipart *multipart, EMsgComposerAttachment *attachment) { CamelMimeBodyPart *part; - CamelDataWrapper *content; - CamelStream *stream; - char *filename; + struct stat st; + int fd; part = camel_mime_body_part_new (); + fd = open (attachment->file_name, O_RDONLY); + if (fd != -1 && fstat (fd, &st) != -1) { + char *data; + + data = g_malloc (st.st_size); + read (fd, data, st.st_size); + close (fd); + + camel_mime_part_set_content (CAMEL_MIME_PART (part), data, + st.st_size, + attachment->mime_type); + } else { + g_warning ("couldn't open %s", attachment->file_name); + gtk_object_sink (GTK_OBJECT (part)); + return; + } + camel_mime_part_set_disposition (CAMEL_MIME_PART (part), "attachment"); - filename = g_basename (attachment->file_name); - camel_mime_part_set_filename (CAMEL_MIME_PART (part), filename); - g_free (filename); + camel_mime_part_set_filename (CAMEL_MIME_PART (part), + g_basename (attachment->file_name)); camel_mime_part_set_description (CAMEL_MIME_PART (part), attachment->description); - camel_mime_part_set_content_type (CAMEL_MIME_PART (part), - attachment->mime_type); - - content = CAMEL_DATA_WRAPPER (gtk_object_new (CAMEL_DATA_WRAPPER_TYPE, - NULL)); - camel_data_wrapper_set_mime_type (content, attachment->mime_type); - stream = camel_stream_fs_new_with_name (attachment->file_name, O_RDONLY, 0); - camel_data_wrapper_construct_from_stream (content, stream); - camel_stream_close (stream); - camel_medium_set_content_object (CAMEL_MEDIUM (part), content); - - /* TODO: could possibly select an appropriate encoder based on the content */ - camel_mime_part_set_encoding((CamelMimePart *)part, CAMEL_MIME_PART_ENCODING_BASE64); camel_multipart_add_part (multipart, part); } diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c index 288bd50e59..3a2decae4a 100644 --- a/composer/e-msg-composer.c +++ b/composer/e-msg-composer.c @@ -154,10 +154,8 @@ build_message (EMsgComposer *composer) body_part = camel_mime_body_part_new (); text = get_editor_text (BONOBO_WIDGET (composer->editor)); - /* set text sets text/plain */ - camel_mime_part_set_text((CamelMimePart *)body_part, text); - camel_data_wrapper_set_mime_type (CAMEL_DATA_WRAPPER (camel_medium_get_content_object((CamelMedium *)body_part)), - "text/html"); + camel_mime_part_set_content (CAMEL_MIME_PART (body_part), text, + strlen (text), "text/html"); g_free (text); camel_multipart_add_part (multipart, body_part); -- cgit