aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--camel/camel-mime-message.c34
-rw-r--r--camel/camel-mime-message.h35
-rw-r--r--camel/camel-mime-part.c2
-rw-r--r--camel/gmime-content-field.c2
-rw-r--r--tests/test1.c26
6 files changed, 63 insertions, 43 deletions
diff --git a/ChangeLog b/ChangeLog
index b20fd6b125..1fd0535fd0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,9 @@
-1999-05-19 root <guiheneu@linoleum.inria.fr>
+1999-05-19 bertrand <Bertrand.Guiheneuf@inria.fr>
+
+ * camel/camel-mime-part.c (_write_to_file): test if content
+ exists before calling its write_to method.
+
+ * camel/camel-mime-message.c (_write_to_file): bugs fix.
* camel/camel-mime-message.c (camel_mime_message_new_with_session):
new func. Creates a message with the session field set
diff --git a/camel/camel-mime-message.c b/camel/camel-mime-message.c
index 2c0a4e638d..5f7689eab5 100644
--- a/camel/camel-mime-message.c
+++ b/camel/camel-mime-message.c
@@ -61,6 +61,7 @@ static void _write_to_file(CamelDataWrapper *data_wrapper, FILE *file);
/* Returns the class for a CamelMimeMessage */
#define CMM_CLASS(so) CAMEL_MIME_MESSAGE_CLASS (GTK_OBJECT(so)->klass)
+#define CDW_CLASS(so) CAMEL_DATA_WRAPPER_CLASS (GTK_OBJECT(so)->klass)
@@ -183,7 +184,7 @@ _set_received_date (CamelMimeMessage *mime_message, GString *received_date)
}
void
-set_received_date (CamelMimeMessage *mime_message, GString *received_date)
+camel_mime_message_set_received_date (CamelMimeMessage *mime_message, GString *received_date)
{
CMM_CLASS (mime_message)->set_received_date (mime_message, received_date);
}
@@ -196,7 +197,7 @@ _get_received_date (CamelMimeMessage *mime_message)
}
GString *
-get_received_date (CamelMimeMessage *mime_message)
+camel_mime_message_get_received_date (CamelMimeMessage *mime_message)
{
return CMM_CLASS (mime_message)->get_received_date (mime_message);
}
@@ -213,7 +214,7 @@ _get_sent_date (CamelMimeMessage *mime_message)
}
GString *
-get_sent_date (CamelMimeMessage *mime_message)
+camel_mime_message_get_sent_date (CamelMimeMessage *mime_message)
{
return CMM_CLASS (mime_message)->get_sent_date (mime_message);
}
@@ -229,7 +230,7 @@ _set_reply_to (CamelMimeMessage *mime_message, GString *reply_to)
}
void
-set_reply_to (CamelMimeMessage *mime_message, GString *reply_to)
+camel_mime_message_set_reply_to (CamelMimeMessage *mime_message, GString *reply_to)
{
CMM_CLASS (mime_message)->set_reply_to (mime_message, reply_to);
}
@@ -242,7 +243,7 @@ _get_reply_to (CamelMimeMessage *mime_message)
}
GString *
-get_reply_to (CamelMimeMessage *mime_message)
+camel_mime_message_get_reply_to (CamelMimeMessage *mime_message)
{
return CMM_CLASS (mime_message)->get_reply_to (mime_message);
}
@@ -257,7 +258,7 @@ _set_subject (CamelMimeMessage *mime_message, GString *subject)
}
void
-set_subject (CamelMimeMessage *mime_message, GString *subject)
+camel_mime_message_set_subject (CamelMimeMessage *mime_message, GString *subject)
{
CMM_CLASS (mime_message)->set_subject (mime_message, subject);
}
@@ -270,7 +271,7 @@ _get_subject (CamelMimeMessage *mime_message)
}
GString *
-get_subject (CamelMimeMessage *mime_message)
+camel_mime_message_get_subject (CamelMimeMessage *mime_message)
{
return CMM_CLASS (mime_message)->get_subject (mime_message);
}
@@ -285,7 +286,7 @@ _set_from (CamelMimeMessage *mime_message, GString *from)
}
void
-set_from (CamelMimeMessage *mime_message, GString *from)
+camel_mime_message_set_from (CamelMimeMessage *mime_message, GString *from)
{
CMM_CLASS (mime_message)->set_from (mime_message, from);
}
@@ -298,7 +299,7 @@ _get_from (CamelMimeMessage *mime_message)
}
GString *
-get_from (CamelMimeMessage *mime_message)
+camel_mime_message_get_from (CamelMimeMessage *mime_message)
{
return CMM_CLASS (mime_message)->get_from (mime_message);
}
@@ -346,7 +347,7 @@ _add_recipient (CamelMimeMessage *mime_message, GString *recipient_type, GString
* @recipient may be freed within this func
**/
void
-add_recipient (CamelMimeMessage *mime_message, GString *recipient_type, GString *recipient)
+camel_mime_message_add_recipient (CamelMimeMessage *mime_message, GString *recipient_type, GString *recipient)
{
CMM_CLASS (mime_message)->add_recipient (mime_message, recipient_type, recipient);
}
@@ -394,7 +395,7 @@ _remove_recipient (CamelMimeMessage *mime_message, GString *recipient_type, GStr
void
-remove_recipient (CamelMimeMessage *mime_message, GString *recipient_type, GString *recipient)
+camel_mime_message_remove_recipient (CamelMimeMessage *mime_message, GString *recipient_type, GString *recipient)
{
CMM_CLASS (mime_message)->remove_recipient (mime_message, recipient_type, recipient);
}
@@ -409,7 +410,7 @@ _get_recipients (CamelMimeMessage *mime_message, GString *recipient_type)
}
GList *
-get_recipients (CamelMimeMessage *mime_message, GString *recipient_type)
+camel_mime_message_get_recipients (CamelMimeMessage *mime_message, GString *recipient_type)
{
return CMM_CLASS (mime_message)->get_recipients (mime_message, recipient_type);
}
@@ -437,7 +438,7 @@ _set_flag (CamelMimeMessage *mime_message, GString *flag, gboolean value)
}
void
-set_flag (CamelMimeMessage *mime_message, GString *flag, gboolean value)
+camel_mime_message_set_flag (CamelMimeMessage *mime_message, GString *flag, gboolean value)
{
CMM_CLASS (mime_message)->set_flag (mime_message, flag, value);
}
@@ -453,7 +454,7 @@ _get_flag (CamelMimeMessage *mime_message, GString *flag)
}
gboolean
-get_flag (CamelMimeMessage *mime_message, GString *flag)
+camel_mime_message_get_flag (CamelMimeMessage *mime_message, GString *flag)
{
return CMM_CLASS (mime_message)->get_flag (mime_message, flag);
}
@@ -476,7 +477,7 @@ _get_message_number (CamelMimeMessage *mime_message)
guint
-get_message_number (CamelMimeMessage *mime_message)
+camel_mime_message_get_message_number (CamelMimeMessage *mime_message)
{
return CMM_CLASS (mime_message)->get_message_number (mime_message);
}
@@ -497,7 +498,8 @@ _write_to_file(CamelDataWrapper *data_wrapper, FILE *file)
{
CamelMimeMessage *mm = CAMEL_MIME_MESSAGE (data_wrapper);
- WHPTF ("Date", mm->sent_date);
+ WHPTF (file, "Date", mm->received_date);
CAMEL_DATA_WRAPPER_CLASS (parent_class)->write_to_file (data_wrapper, file);
}
+
diff --git a/camel/camel-mime-message.h b/camel/camel-mime-message.h
index d582841e4f..6bb0a789b9 100644
--- a/camel/camel-mime-message.h
+++ b/camel/camel-mime-message.h
@@ -47,7 +47,7 @@ extern "C" {
typedef struct
{
- CamelMimePart *parent_class;
+ CamelMimePart parent_object;
/* header fields */
GString *received_date;
@@ -74,7 +74,7 @@ typedef struct
typedef struct {
- CamelDataWrapperClass parent_class;
+ CamelMimePartClass parent_class;
/* Virtual methods */
void (*set_received_date) (CamelMimeMessage *mime_message, GString *received_date);
@@ -106,25 +106,24 @@ GtkType camel_mime_message_get_type (void);
/* public methods */
CamelMimeMessage *camel_mime_message_new_with_session (CamelSession *session);
-void set_received_date (CamelMimeMessage *mime_message, GString *received_date);
-GString *get_received_date (CamelMimeMessage *mime_message);
-GString *get_sent_date (CamelMimeMessage *mime_message);
-void set_reply_to (CamelMimeMessage *mime_message, GString *reply_to);
-GString *get_reply_to (CamelMimeMessage *mime_message);
-void set_subject (CamelMimeMessage *mime_message, GString *subject);
-GString *get_subject (CamelMimeMessage *mime_message);
-void set_from (CamelMimeMessage *mime_message, GString *from);
-GString *get_from (CamelMimeMessage *mime_message);
+void camel_mime_message_set_received_date (CamelMimeMessage *mime_message, GString *received_date);
+GString *camel_mime_message_get_received_date (CamelMimeMessage *mime_message);
+GString *camel_mime_message_get_sent_date (CamelMimeMessage *mime_message);
+void camel_mime_message_set_reply_to (CamelMimeMessage *mime_message, GString *reply_to);
+GString *camel_mime_message_get_reply_to (CamelMimeMessage *mime_message);
+void camel_mime_message_set_subject (CamelMimeMessage *mime_message, GString *subject);
+GString *camel_mime_message_get_subject (CamelMimeMessage *mime_message);
+void camel_mime_message_set_from (CamelMimeMessage *mime_message, GString *from);
+GString *camel_mime_message_get_from (CamelMimeMessage *mime_message);
-void add_recipient (CamelMimeMessage *mime_message, GString *recipient_type, GString *recipient);
-void remove_recipient (CamelMimeMessage *mime_message, GString *recipient_type, GString *recipient);
-GList *get_recipients (CamelMimeMessage *mime_message, GString *recipient_type);
+void camel_mime_message_add_recipient (CamelMimeMessage *mime_message, GString *recipient_type, GString *recipient);
+void camel_mime_message_remove_recipient (CamelMimeMessage *mime_message, GString *recipient_type, GString *recipient);
+GList *camel_mime_message_get_recipients (CamelMimeMessage *mime_message, GString *recipient_type);
-void set_flag (CamelMimeMessage *mime_message, GString *flag, gboolean value);
-gboolean get_flag (CamelMimeMessage *mime_message, GString *flag);
-
-guint get_message_number (CamelMimeMessage *mime_message);
+void camel_mime_message_set_flag (CamelMimeMessage *mime_message, GString *flag, gboolean value);
+gboolean camel_mime_message_get_flag (CamelMimeMessage *mime_message, GString *flag);
+guint camel_mime_message_get_message_number (CamelMimeMessage *mime_message);
#ifdef __cplusplus
}
diff --git a/camel/camel-mime-part.c b/camel/camel-mime-part.c
index 416244ead9..02932214b9 100644
--- a/camel/camel-mime-part.c
+++ b/camel/camel-mime-part.c
@@ -496,7 +496,7 @@ _write_to_file(CamelDataWrapper *data_wrapper, FILE *file)
WHPTF (file, "Content-MD5", mp->content_MD5);
WHPTF (file, "Content-id", mp->content_id);
fprintf(file,"\n");
- camel_data_wrapper_write_to_file (mp->content, file);
+ if (mp->content) camel_data_wrapper_write_to_file (mp->content, file);
}
diff --git a/camel/gmime-content-field.c b/camel/gmime-content-field.c
index e5eb81155e..29c5fb61ec 100644
--- a/camel/gmime-content-field.c
+++ b/camel/gmime-content-field.c
@@ -78,7 +78,7 @@ _print_parameter (gpointer name, gpointer value, gpointer user_data)
void
gmime_content_field_write_to_file(GMimeContentField *content_field, FILE *file)
{
- g_assert(content_field);
+ if (!content_field) return;
if ((content_field->type) && ((content_field->type)->str)) {
fprintf (file, "Content-Type: %s", content_field->type->str);
if ((content_field->subtype) && ((content_field->subtype)->str)) {
diff --git a/tests/test1.c b/tests/test1.c
index c19da0ff7c..90004cfd5c 100644
--- a/tests/test1.c
+++ b/tests/test1.c
@@ -1,14 +1,28 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
#include "camel-mime-message.h"
-
+#include "stdio.h"
void
main (int argc, char**argv)
{
- CamelMimeMessage *message;
+ CamelMimeMessage *message;
+ FILE *output_file;
+
+ gtk_init (&argc, &argv);
+ message = camel_mime_message_new_with_session( (CamelSession *)NULL);
+ camel_mime_part_set_description (CAMEL_MIME_PART (message), g_string_new ("a test"));
+ camel_mime_message_set_received_date (message, g_string_new ("a date"));
- gtk_init (&argc, &argv);
- message = camel_mime_message_new_with_session (CAMEL_SESSION (NULL));
-
- gtk_main();
+ output_file = fopen ("mail.test", "w");
+ if (!output_file) {
+ perror("could not open output file");
+ exit(2);
+ }
+ camel_data_wrapper_write_to_file (CAMEL_DATA_WRAPPER (message), output_file);
+ fclose (output_file);
+
+
+
+ gtk_main();
}