aboutsummaryrefslogtreecommitdiffstats
path: root/composer/e-msg-composer-attachment-bar.c
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2000-04-27 04:42:22 +0800
committerDan Winship <danw@src.gnome.org>2000-04-27 04:42:22 +0800
commit2409d71026645028f49bfd0f745e93346cc17450 (patch)
tree99f977c1c2736e3a76660441674b515e5fcaf4c0 /composer/e-msg-composer-attachment-bar.c
parente751baaa7bfe2d7261e4501a8b79816dbaa3b488 (diff)
downloadgsoc2013-evolution-2409d71026645028f49bfd0f745e93346cc17450.tar
gsoc2013-evolution-2409d71026645028f49bfd0f745e93346cc17450.tar.gz
gsoc2013-evolution-2409d71026645028f49bfd0f745e93346cc17450.tar.bz2
gsoc2013-evolution-2409d71026645028f49bfd0f745e93346cc17450.tar.lz
gsoc2013-evolution-2409d71026645028f49bfd0f745e93346cc17450.tar.xz
gsoc2013-evolution-2409d71026645028f49bfd0f745e93346cc17450.tar.zst
gsoc2013-evolution-2409d71026645028f49bfd0f745e93346cc17450.zip
Update for camel_mime_part_set_content.
svn path=/trunk/; revision=2644
Diffstat (limited to 'composer/e-msg-composer-attachment-bar.c')
-rw-r--r--composer/e-msg-composer-attachment-bar.c40
1 files changed, 21 insertions, 19 deletions
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);
}