diff options
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | camel/Makefile.am | 2 | ||||
-rw-r--r-- | camel/camel-mime-part.c | 4 | ||||
-rw-r--r-- | camel/camel-simple-data-wrapper.c | 132 | ||||
-rw-r--r-- | camel/camel-simple-data-wrapper.h | 77 |
5 files changed, 222 insertions, 2 deletions
@@ -1,3 +1,12 @@ +1999-06-24 root <guiheneu@jean.joudboeuf.fr> + + * camel/camel-simple-data-wrapper.[ch]: + new class. Simple implementation of a data wrapper: + simply keeps the stream result in a byte array. + + * camel/camel-mime-part.c (_parse_header_pair): added a warning. + Have to think about the correct way to store content type stuff. + 1999-06-24 bertrand <Bertrand.Guiheneuf@inria.fr> * camel/camel-mime-message.c (_write_one_recipient_to_stream): diff --git a/camel/Makefile.am b/camel/Makefile.am index 9a88729c2e..1d35a897a6 100644 --- a/camel/Makefile.am +++ b/camel/Makefile.am @@ -14,6 +14,7 @@ INCLUDES = -I.. -I$(srcdir)/.. -I$(includedir) \ libcamel_la_SOURCES = \ camel-log.c \ camel-data-wrapper.c \ + camel-simple-data-wrapper.c \ camel-folder.c \ camel-mime-message.c \ camel-mime-part.c \ @@ -31,6 +32,7 @@ libcamel_la_SOURCES = \ libcamelinclude_HEADERS = \ camel-log.h \ camel-data-wrapper.h \ + camel-simple-data-wrapper.h \ camel-folder.h \ camel-mime-message.h \ camel-mime-part.h \ diff --git a/camel/camel-mime-part.c b/camel/camel-mime-part.c index 8e187a8eac..89eb85b35f 100644 --- a/camel/camel-mime-part.c +++ b/camel/camel-mime-part.c @@ -621,11 +621,11 @@ _parse_header_pair (CamelMimePart *mime_part, GString *header_name, GString *hea header_handled = TRUE; break; - case HEADER_CONTENT_TYPE: + case HEADER_CONTENT_TYPE: /**** * WARNING THIS IS BROKEN * *****/ CAMEL_LOG (FULL_DEBUG, "CamelMimePart::parse_header_pair found HEADER_CONTENT_TYPE: %s\n", header_value->str ); - + gmime_content_field_construct_from_string (CAMEL_DATA_WRAPPER(mime_part)->content_type, header_value); header_handled = TRUE; break; diff --git a/camel/camel-simple-data-wrapper.c b/camel/camel-simple-data-wrapper.c new file mode 100644 index 0000000000..2d81fa62a9 --- /dev/null +++ b/camel/camel-simple-data-wrapper.c @@ -0,0 +1,132 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* camel-simple-data-wrapper.c : simple implementation of a data wrapper */ +/* store the data in a glib byte array */ + +/* + * + * Copyright (C) 1999 Bertrand Guiheneuf <Bertrand.Guiheneuf@inria.fr> . + * + * 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 "camel-simple-data-wrapper.h" + +static CamelDataWrapperClass *parent_class=NULL; + +/* Returns the class for a CamelDataWrapper */ +#define CSDW_CLASS(so) CAMEL_SIMPLE_DATA_WRAPPER_CLASS (GTK_OBJECT(so)->klass) + +static void _construct_from_stream (CamelDataWrapper *data_wrapper, CamelStream *stream, guint size); +static void _write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream); + +static void +camel_simple_data_wrapper_class_init (CamelSimpleDataWrapperClass *camel_simple_data_wrapper_class) +{ + CamelDataWrapperClass *camel_data_wrapper_class = CAMEL_DATA_WRAPPER_CLASS (camel_simple_data_wrapper_class); + + parent_class = gtk_type_class (camel_data_wrapper_get_type ()); + /* virtual method definition */ + + /* virtual method overload */ + camel_data_wrapper_class->write_to_stream = _write_to_stream; + camel_data_wrapper_class->construct_from_stream = _construct_from_stream; +} + + + + + + +GtkType +camel_simple_data_wrapper_get_type (void) +{ + static GtkType camel_simple_data_wrapper_type = 0; + + if (!camel_simple_data_wrapper_type) { + GtkTypeInfo camel_simple_data_wrapper_info = + { + "CamelDataWrapper", + sizeof (CamelDataWrapper), + sizeof (CamelDataWrapperClass), + (GtkClassInitFunc) camel_simple_data_wrapper_class_init, + (GtkObjectInitFunc) NULL, + /* reserved_1 */ NULL, + /* reserved_2 */ NULL, + (GtkClassInitFunc) NULL, + }; + + camel_simple_data_wrapper_type = gtk_type_unique (camel_data_wrapper_get_type (), &camel_simple_data_wrapper_info); + } + + return camel_simple_data_wrapper_type; +} + + + +static void +_write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream) +{ + CamelSimpleDataWrapper *simple_data_wrapper = CAMEL_SIMPLE_DATA_WRAPPER (data_wrapper); + GByteArray *array; + + g_assert (data_wrapper); + g_assert (stream); + g_assert (simple_data_wrapper->byte_array); + + array = simple_data_wrapper->byte_array; + if (array->len) + camel_stream_write (stream, (gchar *)array->data, array->len); + + return; +} + + + + +#define _CMSDW_TMP_BUF_SIZE 100 +static void +_construct_from_stream (CamelDataWrapper *data_wrapper, CamelStream *stream, guint size) +{ + CamelSimpleDataWrapper *simple_data_wrapper = CAMEL_SIMPLE_DATA_WRAPPER (data_wrapper); + guint current_index; + guint nb_bytes_read; + guint nb_bytes_left; + static gchar *tmp_buf; + GByteArray *array; + + + g_assert (data_wrapper); + g_assert (stream); + + if (!size) return; + if (!tmp_buf) tmp_buf = g_new (gchar, _CMSDW_TMP_BUF_SIZE); + + array = simple_data_wrapper->byte_array; + if (array) + g_byte_array_free (array, FALSE); + + array = g_byte_array_new(); + nb_bytes_left = size; + do { + + nb_bytes_read = camel_stream_read (stream, tmp_buf, + MIN (_CMSDW_TMP_BUF_SIZE, nb_bytes_left)); + nb_bytes_left -= nb_bytes_read; + if (nb_bytes_read) g_byte_array_append (array, tmp_buf, nb_bytes_read); + + } while (nb_bytes_read && (nb_bytes_left>0)); + +} diff --git a/camel/camel-simple-data-wrapper.h b/camel/camel-simple-data-wrapper.h new file mode 100644 index 0000000000..ce84906bc3 --- /dev/null +++ b/camel/camel-simple-data-wrapper.h @@ -0,0 +1,77 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* camel-simple-data-wrapper.c : simple implementation of a data wrapper */ +/* store the data in a glib byte array */ + +/* + * + * Copyright (C) 1999 Bertrand Guiheneuf <Bertrand.Guiheneuf@inria.fr> . + * + * 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 + */ + + +#ifndef CAMEL_SIMPLE_DATA_WRAPPER_H +#define CAMEL_SIMPLE_DATA_WRAPPER_H 1 + + +#ifdef __cplusplus +extern "C" { +#pragma } +#endif /* __cplusplus }*/ + +#include <gtk/gtk.h> +#include <stdio.h> +#include "camel-stream.h" +#include "camel-data-wrapper.h" + + + +#define CAMEL_SIMPLE_DATA_WRAPPER_TYPE (camel_simple_data_wrapper_get_type ()) +#define CAMEL_SIMPLE_DATA_WRAPPER(obj) (GTK_CHECK_CAST((obj), CAMEL_SIMPLE_DATA_WRAPPER_TYPE, CamelSimpleDataWrapper)) +#define CAMEL_SIMPLE_DATA_WRAPPER_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_SIMPLE_DATA_WRAPPER_TYPE, CamelSimpleDataWrapperClass)) +#define IS_CAMEL_SIMPLE_DATA_WRAPPER(o) (GTK_CHECK_TYPE((o), CAMEL_SIMPLE_DATA_WRAPPER_TYPE)) + + +typedef struct +{ + CamelDataWrapper parent_object; + + GByteArray *byte_array; + +} CamelSimpleDataWrapper; + + + +typedef struct { + CamelDataWrapperClass parent_class; + + +} CamelSimpleDataWrapperClass; + + + +/* Standard Gtk function */ +GtkType camel_simple_data_wrapper_get_type (void); + + +/* public methods */ + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* CAMEL_SIMPLE_DATA_WRAPPER_H */ |