diff options
author | nobody <nobody@localhost> | 2000-04-24 03:19:31 +0800 |
---|---|---|
committer | nobody <nobody@localhost> | 2000-04-24 03:19:31 +0800 |
commit | 1d2905c71fce6565f5cda0a34c63fa67634dc01a (patch) | |
tree | 99a4d80d9f1acb9f56cf26e221bf13a312e97890 /camel/camel-mime-part-utils.c | |
parent | 49c2cb5af1a58b24fc08d2ce351307a4cfad96f5 (diff) | |
download | gsoc2013-evolution-GNOME_UTILS_1_1_0.tar gsoc2013-evolution-GNOME_UTILS_1_1_0.tar.gz gsoc2013-evolution-GNOME_UTILS_1_1_0.tar.bz2 gsoc2013-evolution-GNOME_UTILS_1_1_0.tar.lz gsoc2013-evolution-GNOME_UTILS_1_1_0.tar.xz gsoc2013-evolution-GNOME_UTILS_1_1_0.tar.zst gsoc2013-evolution-GNOME_UTILS_1_1_0.zip |
This commit was manufactured by cvs2svn to create tagGNOME_UTILS_1_1_0
'GNOME_UTILS_1_1_0'.
svn path=/tags/GNOME_UTILS_1_1_0/; revision=2567
Diffstat (limited to 'camel/camel-mime-part-utils.c')
-rw-r--r-- | camel/camel-mime-part-utils.c | 165 |
1 files changed, 0 insertions, 165 deletions
diff --git a/camel/camel-mime-part-utils.c b/camel/camel-mime-part-utils.c deleted file mode 100644 index a4392d5f88..0000000000 --- a/camel/camel-mime-part-utils.c +++ /dev/null @@ -1,165 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-mime-part-utils : Utility for mime parsing and so on */ - - -/* - * - * Author : - * Bertrand Guiheneuf <bertrand@helixcode.com> - * - * Copyright 1999, 2000 Helix Code, Inc. (http://www.helixcode.com) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ -#include <config.h> -#include "gmime-content-field.h" -#include "string-utils.h" -#include "gmime-utils.h" -#include "camel-simple-data-wrapper.h" -#include "data-wrapper-repository.h" - -#include "camel-mime-part-utils.h" - - - -/* declare this function because it is public - but it must not be called except here */ -void camel_mime_part_set_content_type (CamelMimePart *mime_part, - gchar *content_type); - - -void -camel_mime_part_construct_headers_from_stream (CamelMimePart *mime_part, - CamelStream *stream) -{ - GArray *header_array; - Rfc822Header *cur_header; - int i; - - g_assert (stream); - /* - * parse all header lines - */ - header_array = get_header_array_from_stream (stream); - if (header_array) { - for (i=0; i<header_array->len; i++) { - cur_header = (Rfc822Header *)header_array->data + i; - camel_medium_add_header ( CAMEL_MEDIUM (mime_part), - cur_header->name, - cur_header->value); - g_free (cur_header->name); - g_free (cur_header->value); - } - - g_array_free (header_array, TRUE); - - } -} - - - - - -void -camel_mime_part_construct_content_from_stream (CamelMimePart *mime_part, - CamelStream *stream) -{ - GMimeContentField *content_type = NULL; - gchar *mime_type = NULL; - GtkType content_object_type; - CamelDataWrapper *content_object = NULL; - - - /* - * find content mime type - */ - content_type = camel_mime_part_get_content_type (mime_part); - /* here we should have a mime type */ - if (content_type) - mime_type = gmime_content_field_get_mime_type (content_type); - - /* - * no mime type found for the content, - * using text/plain is the default - */ - if (!mime_type) { - mime_type = g_strdup ("text/plain"); - camel_mime_part_set_content_type (mime_part, mime_type); - } - - /* - * find in the repository what particular data wrapper is - * associated to this mime type - */ - content_object_type = - data_wrapper_repository_get_data_wrapper_type (mime_type); - - g_free (mime_type); - - /* - * create the content object data wrapper with the type - * returned by the data wrapper repository - */ - content_object = CAMEL_DATA_WRAPPER (gtk_type_new (content_object_type)); - camel_data_wrapper_set_mime_type_field (content_object, - camel_mime_part_get_content_type (mime_part)); - camel_medium_set_content_object ( CAMEL_MEDIUM (mime_part), content_object); - - /* set the input stream for the content object */ - camel_data_wrapper_set_input_stream (content_object, stream); - - /* - * the object is referenced in the set_content_object method, - * so unref it here - */ - gtk_object_unref (GTK_OBJECT (content_object)); -} - - - -void -camel_mime_part_store_stream_in_buffer (CamelMimePart *mime_part, - CamelStream *stream) -{ - gint nb_bytes_read_total = 0; - gint nb_bytes_read_chunk; - GByteArray *buffer; -#define STREAM_READ_CHUNK_SZ 100 - - if (mime_part->temp_message_buffer == NULL) - mime_part->temp_message_buffer = g_byte_array_new (); - - buffer = mime_part->temp_message_buffer; - - g_byte_array_set_size (buffer, nb_bytes_read_total + STREAM_READ_CHUNK_SZ); - nb_bytes_read_chunk = camel_stream_read (stream, - buffer->data + nb_bytes_read_total, - STREAM_READ_CHUNK_SZ); - - if (nb_bytes_read_chunk>0) { - nb_bytes_read_total += nb_bytes_read_chunk; - - while (nb_bytes_read_chunk >0) { - g_byte_array_set_size (buffer, nb_bytes_read_total + STREAM_READ_CHUNK_SZ); - nb_bytes_read_chunk = camel_stream_read (stream, - buffer->data + nb_bytes_read_total, - STREAM_READ_CHUNK_SZ); - nb_bytes_read_total += nb_bytes_read_chunk; - } - } - - g_byte_array_set_size (buffer, nb_bytes_read_total); -} |