aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog11
-rw-r--r--camel/camel-data-wrapper.c8
-rw-r--r--camel/camel-data-wrapper.h4
-rw-r--r--camel/camel-mime-part.c37
-rw-r--r--tests/test2.c25
5 files changed, 56 insertions, 29 deletions
diff --git a/ChangeLog b/ChangeLog
index c6e1f88707..3b584fd623 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
1999-06-28 bertrand <Bertrand.Guiheneuf@inria.fr>
+ * tests/test2.c (main): now use
+ CamelDataWrapper::contruct_form_stream to test
+ message parsing
+
+ * camel/camel-data-wrapper.c:
+ * camel/camel-data-wrapper.h:
+ construct_from_stream no longer has maximimum size arg.
+
+ * camel/camel-mime-part.c (_construct_from_stream): new.
+ Construct the mime_part from a stream.
+
* camel/camel-mime-part.c:
new field (content_type) and associated methods.
(camel_mime_part_init): initialize content_type field.
diff --git a/camel/camel-data-wrapper.c b/camel/camel-data-wrapper.c
index 38d91b13e9..05d97d415d 100644
--- a/camel/camel-data-wrapper.c
+++ b/camel/camel-data-wrapper.c
@@ -31,7 +31,7 @@ static GtkObjectClass *parent_class=NULL;
/* Returns the class for a CamelDataWrapper */
#define CDW_CLASS(so) CAMEL_DATA_WRAPPER_CLASS (GTK_OBJECT(so)->klass)
-static void _construct_from_stream (CamelDataWrapper *data_wrapper, CamelStream *stream, guint size);
+static void _construct_from_stream (CamelDataWrapper *data_wrapper, CamelStream *stream);
static void _write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream);
static void _set_mime_type (CamelDataWrapper *data_wrapper, GString *mime_type);
static GString *_get_mime_type (CamelDataWrapper *data_wrapper);
@@ -133,15 +133,15 @@ camel_data_wrapper_write_to_stream (CamelDataWrapper *data_wrapper, CamelStream
static void
-_construct_from_stream (CamelDataWrapper *data_wrapper, CamelStream *stream, guint size)
+_construct_from_stream (CamelDataWrapper *data_wrapper, CamelStream *stream)
{
/* nothing */
}
void
-camel_data_wrapper_construct_from_stream (CamelDataWrapper *data_wrapper, CamelStream *stream, guint size)
+camel_data_wrapper_construct_from_stream (CamelDataWrapper *data_wrapper, CamelStream *stream)
{
- CDW_CLASS(data_wrapper)->construct_from_stream (data_wrapper, stream, size);
+ CDW_CLASS(data_wrapper)->construct_from_stream (data_wrapper, stream);
}
diff --git a/camel/camel-data-wrapper.h b/camel/camel-data-wrapper.h
index d0881ebe6e..365852d5ce 100644
--- a/camel/camel-data-wrapper.h
+++ b/camel/camel-data-wrapper.h
@@ -58,7 +58,7 @@ typedef struct {
/* Virtual methods */
void (*write_to_stream) (CamelDataWrapper *data_wrapper, CamelStream *stream);
- void (*construct_from_stream) (CamelDataWrapper *data_wrapper, CamelStream *stream, guint size);
+ void (*construct_from_stream) (CamelDataWrapper *data_wrapper, CamelStream *stream);
void (*set_mime_type) (CamelDataWrapper *data_wrapper, GString *content_type);
GString * (*get_mime_type) (CamelDataWrapper *data_wrapper);
@@ -73,7 +73,7 @@ GtkType camel_data_wrapper_get_type (void);
/* public methods */
void camel_data_wrapper_write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream);
-void camel_data_wrapper_construct_from_stream (CamelDataWrapper *data_wrapper, CamelStream *stream, guint size);
+void camel_data_wrapper_construct_from_stream (CamelDataWrapper *data_wrapper, CamelStream *stream);
void camel_data_wrapper_set_mime_type (CamelDataWrapper *data_wrapper, GString *mime_type);
static GString *camel_data_wrapper_get_mime_type (CamelDataWrapper *data_wrapper);
diff --git a/camel/camel-mime-part.c b/camel/camel-mime-part.c
index 5bba86f54a..0fdf749d38 100644
--- a/camel/camel-mime-part.c
+++ b/camel/camel-mime-part.c
@@ -27,6 +27,7 @@
#include "gmime-content-field.h"
#include "gstring-util.h"
#include "camel-log.h"
+#include "gmime-utils.h"
typedef enum {
@@ -75,6 +76,7 @@ static CamelDataWrapper *_get_content_object(CamelMimePart *mime_part);
static void _write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream);
static gboolean _parse_header_pair (CamelMimePart *mime_part, GString *header_name, GString *header_value);
+void _construct_from_stream (CamelDataWrapper *data_wrapper, CamelStream *stream);
/* loads in a hash table the set of header names we */
@@ -130,6 +132,7 @@ camel_mime_part_class_init (CamelMimePartClass *camel_mime_part_class)
/* virtual method overload */
camel_data_wrapper_class->write_to_stream = _write_to_stream;
+ camel_data_wrapper_class->construct_from_stream = _construct_from_stream;
}
static void
@@ -675,3 +678,37 @@ _parse_header_pair (CamelMimePart *mime_part, GString *header_name, GString *hea
} else return FALSE;
}
+
+/* calls _parse_header_pair, but can be called
+ in a g_hash_table_for_each */
+void
+_parse_hash_table_pair (gpointer key, gpointer value, gpointer user_data)
+{
+ GString *header_name = (GString *)key;
+ GString *header_value = (GString *)value;
+ CamelMimePart *mime_part = (CamelMimePart *) user_data;
+
+
+ CAMEL_LOG (FULL_DEBUG,"\n--------- New Header ----------\n");
+ if ((header_name) && (header_name->str))
+ CAMEL_LOG (FULL_DEBUG, "header name :%s\n", header_name->str);
+ if ((header_value) && (header_value->str))
+ CAMEL_LOG (FULL_DEBUG, "header value :%s\n", header_value->str);
+
+ camel_mime_part_add_header (mime_part, header_name, header_value);
+ CAMEL_LOG (FULL_DEBUG, "--------- End -----------------\n");
+}
+
+void
+_construct_from_stream (CamelDataWrapper *data_wrapper, CamelStream *stream)
+{
+ GHashTable *header_table;
+ CamelMimePart *mime_part = CAMEL_MIME_PART (data_wrapper);
+
+ header_table = get_header_table_from_stream (stream);
+ if (header_table) {
+ g_hash_table_foreach (header_table, _parse_hash_table_pair, (gpointer)mime_part);
+ }
+ g_hash_table_destroy (header_table);
+}
+
diff --git a/tests/test2.c b/tests/test2.c
index 6f4ef3fdc6..03f03a105c 100644
--- a/tests/test2.c
+++ b/tests/test2.c
@@ -8,25 +8,6 @@
#include "camel-stream.h"
#include "camel-stream-fs.h"
-void print_header_pair (gpointer key, gpointer value, gpointer user_data)
-{
- GString *header_name = (GString *)key;
- GString *header_value = (GString *)value;
- CamelMimeMessage *message = (CamelMimeMessage *) user_data;
-
-
- printf("\n--------- New Header ----------\n");
- if ((header_name) && (header_name->str))
- printf("header name :%s\n", header_name->str);
- if ((header_value) && (header_value->str))
- printf("header value :%s\n", header_value->str);
-
- camel_mime_part_add_header ( CAMEL_MIME_PART (message), header_name, header_value);
-
- printf("--------- End -----------------\n");
-
-}
-
void
main (int argc, char**argv)
{
@@ -45,11 +26,9 @@ main (int argc, char**argv)
exit(2);
}
- header_table = get_header_table_from_stream (input_stream);
-
- if (header_table) g_hash_table_foreach (header_table, print_header_pair, (gpointer)message);
- else printf("header is empty, no header line present\n");
+ camel_data_wrapper_construct_from_stream ( CAMEL_DATA_WRAPPER (message), input_stream);
+
camel_stream_close (input_stream);
output_stream = camel_stream_fs_new_with_name (g_string_new ("mail2.test"), CAMEL_STREAM_FS_WRITE);