aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbertrand <bertrand@helixcode.com>2000-03-03 10:54:25 +0800
committerBertrand Guiheneuf <bertrand@src.gnome.org>2000-03-03 10:54:25 +0800
commit2392d67981785dac17f56305f8ee3fc0b5884694 (patch)
tree40b56668dd5c95dbe50fd6f1b70c67d7ac2dac73
parent9cf31d6b063eacf768ea835fad15377aaddf6dc1 (diff)
downloadgsoc2013-evolution-2392d67981785dac17f56305f8ee3fc0b5884694.tar.gz
gsoc2013-evolution-2392d67981785dac17f56305f8ee3fc0b5884694.tar.zst
gsoc2013-evolution-2392d67981785dac17f56305f8ee3fc0b5884694.zip
don't forget to set the state to 0 after 3. (my_read_encode): don't forget
2000-03-02 bertrand <bertrand@helixcode.com> * camel-stream-b64.c (my_read_encode): don't forget to set the state to 0 after 3. (my_read_encode): don't forget to encode, even in state 3. * camel-simple-data-wrapper.c: static functions are prefixed with my_ instead of _ * camel-multipart.c: static functions are prefixed with my_ instead of _ (my_write_to_stream): commented. (my_write_to_stream): warning in case the boudary is set but is a zero length string. * camel-mime-part.c (camel_mime_part_encoding_from_string): remove debug trace. * camel-mime-part.c: Replaced all static functions with name begining with _ by the same name begining with "my_" to prevent the possible conflicts with system symbols Dan warned us about. Mime mail generation works now, at least with b64 encoding. QP needs to be done now. svn path=/trunk/; revision=2016
-rw-r--r--camel/ChangeLog20
-rw-r--r--camel/camel-data-wrapper.c5
-rw-r--r--camel/camel-mime-part.c213
-rw-r--r--camel/camel-multipart.c248
-rw-r--r--camel/camel-simple-data-wrapper.c86
-rw-r--r--camel/camel-simple-data-wrapper.h2
-rw-r--r--camel/camel-stream-b64.c9
-rw-r--r--camel/camel-stream-fs.c21
-rw-r--r--tests/test1.c20
9 files changed, 347 insertions, 277 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index 862a84656b..04d158b4f6 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,5 +1,25 @@
2000-03-02 bertrand <bertrand@helixcode.com>
+ * camel-stream-b64.c (my_read_encode): don't forget to
+ set the state to 0 after 3.
+ (my_read_encode): don't forget to encode, even in state 3.
+
+ * camel-simple-data-wrapper.c: static functions are prefixed
+ with my_ instead of _
+ * camel-multipart.c: static functions are prefixed
+ with my_ instead of _
+ (my_write_to_stream): commented.
+ (my_write_to_stream): warning in case the boudary is set
+ but is a zero length string.
+
+ * camel-mime-part.c (camel_mime_part_encoding_from_string):
+ remove debug trace.
+
+ * camel-mime-part.c: Replaced all static functions
+ with name begining with _ by the same name begining
+ with "my_" to prevent the possible conflicts
+ with system symbols Dan warned us about.
+
* camel-stream-b64.c (camel_stream_b64_write_to_stream):
use CamelStreamB64 type for the input stream.
diff --git a/camel/camel-data-wrapper.c b/camel/camel-data-wrapper.c
index 7110adcc60..cd4fcce7de 100644
--- a/camel/camel-data-wrapper.c
+++ b/camel/camel-data-wrapper.c
@@ -146,6 +146,9 @@ my_set_input_stream (CamelDataWrapper *data_wrapper, CamelStream *stream)
{
g_assert (data_wrapper);
data_wrapper->input_stream = stream;
+ if (!data_wrapper->output_stream && stream)
+ data_wrapper->output_stream = stream;
+
if (stream)
gtk_object_ref (GTK_OBJECT (stream));
}
@@ -252,7 +255,7 @@ my_write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream)
nb_read = camel_stream_read (output_stream, tmp_buf, 4096);
nb_written = 0;
while (nb_written < nb_read)
- nb_written += camel_stream_write (stream, tmp_buf, nb_read);
+ nb_written += camel_stream_write (stream, tmp_buf + nb_written, nb_read - nb_written);
}
}
diff --git a/camel/camel-mime-part.c b/camel/camel-mime-part.c
index 7244ab3c0d..57b2659ffb 100644
--- a/camel/camel-mime-part.c
+++ b/camel/camel-mime-part.c
@@ -67,61 +67,61 @@ static CamelMediumClass *parent_class=NULL;
#define CDW_CLASS(so) CAMEL_DATA_WRAPPER_CLASS (GTK_OBJECT(so)->klass)
/* from GtkObject */
-static void _finalize (GtkObject *object);
+static void my_finalize (GtkObject *object);
/* from CamelDataWrapper */
-static void _write_to_stream (CamelDataWrapper *data_wrapper,
- CamelStream *stream);
-static void _construct_from_stream (CamelDataWrapper *data_wrapper,
- CamelStream *stream);
-static void _set_input_stream (CamelDataWrapper *data_wrapper,
- CamelStream *stream);
-static CamelStream * _get_output_stream (CamelDataWrapper *data_wrapper);
+static void my_write_to_stream (CamelDataWrapper *data_wrapper,
+ CamelStream *stream);
+static void my_construct_from_stream (CamelDataWrapper *data_wrapper,
+ CamelStream *stream);
+static void my_set_input_stream (CamelDataWrapper *data_wrapper,
+ CamelStream *stream);
+static CamelStream * my_get_output_stream (CamelDataWrapper *data_wrapper);
/* from CamelMedia */
-static void _add_header (CamelMedium *medium,
- gchar *header_name,
- gchar *header_value);
+static void my_add_header (CamelMedium *medium,
+ gchar *header_name,
+ gchar *header_value);
-static void _set_content_object (CamelMedium *medium,
- CamelDataWrapper *content);
-static CamelDataWrapper *_get_content_object (CamelMedium *medium);
+static void my_set_content_object (CamelMedium *medium,
+ CamelDataWrapper *content);
+static CamelDataWrapper *my_get_content_object (CamelMedium *medium);
/* from CamelMimePart */
-static void _set_description (CamelMimePart *mime_part,
- const gchar *description);
-static const gchar * _get_description (CamelMimePart *mime_part);
-static void _set_disposition (CamelMimePart *mime_part,
- const gchar *disposition);
-static const gchar * _get_disposition (CamelMimePart *mime_part);
-static void _set_filename (CamelMimePart *mime_part,
- gchar *filename);
-static const gchar * _get_filename (CamelMimePart *mime_part);
-static void _set_content_id (CamelMimePart *mime_part,
- gchar *content_id);
-static const gchar * _get_content_id (CamelMimePart *mime_part);
-static void _set_content_MD5 (CamelMimePart *mime_part,
- gchar *content_MD5);
-static const gchar * _get_content_MD5 (CamelMimePart *mime_part);
-static void _set_encoding (CamelMimePart *mime_part,
- CamelMimePartEncodingType encoding);
-static CamelMimePartEncodingType _get_encoding (CamelMimePart *mime_part);
-static void _set_content_languages (CamelMimePart *mime_part,
- GList *content_languages);
-static const GList * _get_content_languages (CamelMimePart *mime_part);
-static void _set_header_lines (CamelMimePart *mime_part,
- GList *header_lines);
-static const GList * _get_header_lines (CamelMimePart *mime_part);
-static void _set_content_type (CamelMimePart *mime_part,
- const gchar *content_type);
-static GMimeContentField *_get_content_type (CamelMimePart *mime_part);
-
-static gboolean _parse_header_pair (CamelMimePart *mime_part,
- gchar *header_name,
- gchar *header_value);
+static void my_set_description (CamelMimePart *mime_part,
+ const gchar *description);
+static const gchar * my_get_description (CamelMimePart *mime_part);
+static void my_set_disposition (CamelMimePart *mime_part,
+ const gchar *disposition);
+static const gchar * my_get_disposition (CamelMimePart *mime_part);
+static void my_set_filename (CamelMimePart *mime_part,
+ gchar *filename);
+static const gchar * my_get_filename (CamelMimePart *mime_part);
+static void my_set_content_id (CamelMimePart *mime_part,
+ gchar *content_id);
+static const gchar * my_get_content_id (CamelMimePart *mime_part);
+static void my_set_content_MD5 (CamelMimePart *mime_part,
+ gchar *content_MD5);
+static const gchar * my_get_content_MD5 (CamelMimePart *mime_part);
+static void my_set_encoding (CamelMimePart *mime_part,
+ CamelMimePartEncodingType encoding);
+static CamelMimePartEncodingType my_get_encoding (CamelMimePart *mime_part);
+static void my_set_content_languages (CamelMimePart *mime_part,
+ GList *content_languages);
+static const GList * my_get_content_languages (CamelMimePart *mime_part);
+static void my_set_header_lines (CamelMimePart *mime_part,
+ GList *header_lines);
+static const GList * my_get_header_lines (CamelMimePart *mime_part);
+static void my_set_content_type (CamelMimePart *mime_part,
+ const gchar *content_type);
+static GMimeContentField *my_get_content_type (CamelMimePart *mime_part);
+
+static gboolean my_parse_header_pair (CamelMimePart *mime_part,
+ gchar *header_name,
+ gchar *header_value);
@@ -129,7 +129,7 @@ static gboolean _parse_header_pair (CamelMimePart *mime_part,
/* recognize and associate them with a unique enum */
/* identifier (see CamelHeaderType above) */
static void
-_init_header_name_table()
+my_init_header_name_table()
{
header_name_table = g_hash_table_new (g_strcase_hash, g_strcase_equal);
g_hash_table_insert (header_name_table, "Content-Description", (gpointer)HEADER_DESCRIPTION);
@@ -149,41 +149,41 @@ camel_mime_part_class_init (CamelMimePartClass *camel_mime_part_class)
GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (camel_data_wrapper_class);
parent_class = gtk_type_class (camel_medium_get_type ());
- _init_header_name_table();
+ my_init_header_name_table();
/* virtual method definition */
- camel_mime_part_class->set_description = _set_description;
- camel_mime_part_class->get_description = _get_description;
- camel_mime_part_class->set_disposition = _set_disposition;
- camel_mime_part_class->get_disposition = _get_disposition;
- camel_mime_part_class->set_filename = _set_filename;
- camel_mime_part_class->get_filename = _get_filename;
- camel_mime_part_class->set_content_id = _set_content_id;
- camel_mime_part_class->get_content_id = _get_content_id;
- camel_mime_part_class->set_content_MD5 = _set_content_MD5;
- camel_mime_part_class->get_content_MD5 = _get_content_MD5;
- camel_mime_part_class->set_encoding = _set_encoding;
- camel_mime_part_class->get_encoding = _get_encoding;
- camel_mime_part_class->set_content_languages = _set_content_languages;
- camel_mime_part_class->get_content_languages = _get_content_languages;
- camel_mime_part_class->set_header_lines = _set_header_lines;
- camel_mime_part_class->get_header_lines = _get_header_lines;
- camel_mime_part_class->set_content_type = _set_content_type;
- camel_mime_part_class->get_content_type = _get_content_type;
+ camel_mime_part_class->set_description = my_set_description;
+ camel_mime_part_class->get_description = my_get_description;
+ camel_mime_part_class->set_disposition = my_set_disposition;
+ camel_mime_part_class->get_disposition = my_get_disposition;
+ camel_mime_part_class->set_filename = my_set_filename;
+ camel_mime_part_class->get_filename = my_get_filename;
+ camel_mime_part_class->set_content_id = my_set_content_id;
+ camel_mime_part_class->get_content_id = my_get_content_id;
+ camel_mime_part_class->set_content_MD5 = my_set_content_MD5;
+ camel_mime_part_class->get_content_MD5 = my_get_content_MD5;
+ camel_mime_part_class->set_encoding = my_set_encoding;
+ camel_mime_part_class->get_encoding = my_get_encoding;
+ camel_mime_part_class->set_content_languages = my_set_content_languages;
+ camel_mime_part_class->get_content_languages = my_get_content_languages;
+ camel_mime_part_class->set_header_lines = my_set_header_lines;
+ camel_mime_part_class->get_header_lines = my_get_header_lines;
+ camel_mime_part_class->set_content_type = my_set_content_type;
+ camel_mime_part_class->get_content_type = my_get_content_type;
- camel_mime_part_class->parse_header_pair = _parse_header_pair;
+ camel_mime_part_class->parse_header_pair = my_parse_header_pair;
/* virtual method overload */
- camel_medium_class->add_header = _add_header;
- camel_medium_class->set_content_object = _set_content_object;
- camel_medium_class->get_content_object = _get_content_object;
+ camel_medium_class->add_header = my_add_header;
+ camel_medium_class->set_content_object = my_set_content_object;
+ camel_medium_class->get_content_object = my_get_content_object;
- camel_data_wrapper_class->write_to_stream = _write_to_stream;
- camel_data_wrapper_class->construct_from_stream = _construct_from_stream;
- camel_data_wrapper_class->set_input_stream = _set_input_stream;
- camel_data_wrapper_class->get_output_stream = _get_output_stream;
+ camel_data_wrapper_class->write_to_stream = my_write_to_stream;
+ camel_data_wrapper_class->construct_from_stream = my_construct_from_stream;
+ camel_data_wrapper_class->set_input_stream = my_set_input_stream;
+ camel_data_wrapper_class->get_output_stream = my_get_output_stream;
- gtk_object_class->finalize = _finalize;
+ gtk_object_class->finalize = my_finalize;
}
static void
@@ -234,7 +234,7 @@ camel_mime_part_get_type (void)
static void
-_finalize (GtkObject *object)
+my_finalize (GtkObject *object)
{
CamelMimePart *mime_part = CAMEL_MIME_PART (object);
@@ -261,7 +261,7 @@ _finalize (GtkObject *object)
/* **** */
static void
-_add_header (CamelMedium *medium, gchar *header_name, gchar *header_value)
+my_add_header (CamelMedium *medium, gchar *header_name, gchar *header_value)
{
CamelMimePart *mime_part = CAMEL_MIME_PART (medium);
@@ -278,7 +278,7 @@ _add_header (CamelMedium *medium, gchar *header_name, gchar *header_value)
static void
-_set_description (CamelMimePart *mime_part, const gchar *description)
+my_set_description (CamelMimePart *mime_part, const gchar *description)
{
g_free (mime_part->description);
mime_part->description = g_strdup (description);
@@ -297,7 +297,7 @@ camel_mime_part_set_description (CamelMimePart *mime_part, const gchar *descript
static const gchar *
-_get_description (CamelMimePart *mime_part)
+my_get_description (CamelMimePart *mime_part)
{
return mime_part->description;
}
@@ -314,7 +314,7 @@ camel_mime_part_get_description (CamelMimePart *mime_part)
static void
-_set_disposition (CamelMimePart *mime_part, const gchar *disposition)
+my_set_disposition (CamelMimePart *mime_part, const gchar *disposition)
{
#warning Do not use MimeContentfield here !!!
@@ -338,7 +338,7 @@ camel_mime_part_set_disposition (CamelMimePart *mime_part, const gchar *disposit
static const gchar *
-_get_disposition (CamelMimePart *mime_part)
+my_get_disposition (CamelMimePart *mime_part)
{
if (!mime_part->disposition) return NULL;
return (mime_part->disposition)->type;
@@ -354,7 +354,7 @@ camel_mime_part_get_disposition (CamelMimePart *mime_part)
static void
-_set_filename (CamelMimePart *mime_part, gchar *filename)
+my_set_filename (CamelMimePart *mime_part, gchar *filename)
{
g_free(mime_part->filename);
mime_part->filename = filename;
@@ -373,7 +373,7 @@ camel_mime_part_set_filename (CamelMimePart *mime_part, gchar *filename)
static const gchar *
-_get_filename (CamelMimePart *mime_part)
+my_get_filename (CamelMimePart *mime_part)
{
return mime_part->filename;
}
@@ -391,7 +391,7 @@ camel_mime_part_get_filename (CamelMimePart *mime_part)
/* this routine must not be public */
static void
-_set_content_id (CamelMimePart *mime_part, gchar *content_id)
+my_set_content_id (CamelMimePart *mime_part, gchar *content_id)
{
g_free(mime_part->content_id);
mime_part->content_id = content_id;
@@ -399,7 +399,7 @@ _set_content_id (CamelMimePart *mime_part, gchar *content_id)
static const gchar *
-_get_content_id (CamelMimePart *mime_part)
+my_get_content_id (CamelMimePart *mime_part)
{
return mime_part->content_id;
}
@@ -417,7 +417,7 @@ camel_mime_part_get_content_id (CamelMimePart *mime_part)
/* this routine must not be public */
static void
-_set_content_MD5 (CamelMimePart *mime_part, gchar *content_MD5)
+my_set_content_MD5 (CamelMimePart *mime_part, gchar *content_MD5)
{
g_free(mime_part->content_MD5);
mime_part->content_MD5 = content_MD5;
@@ -428,7 +428,7 @@ _set_content_MD5 (CamelMimePart *mime_part, gchar *content_MD5)
static const gchar *
-_get_content_MD5 (CamelMimePart *mime_part)
+my_get_content_MD5 (CamelMimePart *mime_part)
{
return mime_part->content_MD5;
}
@@ -445,7 +445,7 @@ camel_mime_part_get_content_MD5 (CamelMimePart *mime_part)
static void
-_set_encoding (CamelMimePart *mime_part, CamelMimePartEncodingType encoding)
+my_set_encoding (CamelMimePart *mime_part, CamelMimePartEncodingType encoding)
{
mime_part->encoding = encoding;
}
@@ -463,7 +463,7 @@ camel_mime_part_set_encoding (CamelMimePart *mime_part,
static CamelMimePartEncodingType
-_get_encoding (CamelMimePart *mime_part)
+my_get_encoding (CamelMimePart *mime_part)
{
return mime_part->encoding;
}
@@ -481,7 +481,7 @@ camel_mime_part_get_encoding (CamelMimePart *mime_part)
static void
-_set_content_languages (CamelMimePart *mime_part, GList *content_languages)
+my_set_content_languages (CamelMimePart *mime_part, GList *content_languages)
{
if (mime_part->content_languages) string_list_free (mime_part->content_languages);
mime_part->content_languages = content_languages;
@@ -499,7 +499,7 @@ camel_mime_part_set_content_languages (CamelMimePart *mime_part, GList *content_
static const GList *
-_get_content_languages (CamelMimePart *mime_part)
+my_get_content_languages (CamelMimePart *mime_part)
{
return mime_part->content_languages;
}
@@ -517,7 +517,7 @@ camel_mime_part_get_content_languages (CamelMimePart *mime_part)
static void
-_set_header_lines (CamelMimePart *mime_part, GList *header_lines)
+my_set_header_lines (CamelMimePart *mime_part, GList *header_lines)
{
if (mime_part->header_lines) string_list_free (mime_part->header_lines);
mime_part->header_lines = header_lines;
@@ -535,7 +535,7 @@ camel_mime_part_set_header_lines (CamelMimePart *mime_part, GList *header_lines)
static const GList *
-_get_header_lines (CamelMimePart *mime_part)
+my_get_header_lines (CamelMimePart *mime_part)
{
return mime_part->header_lines;
}
@@ -554,7 +554,7 @@ camel_mime_part_get_header_lines (CamelMimePart *mime_part)
static void
-_set_content_type (CamelMimePart *mime_part, const gchar *content_type)
+my_set_content_type (CamelMimePart *mime_part, const gchar *content_type)
{
g_assert (content_type);
gmime_content_field_construct_from_string (mime_part->content_type, content_type);
@@ -570,7 +570,7 @@ camel_mime_part_set_content_type (CamelMimePart *mime_part, gchar *content_type)
static GMimeContentField *
-_get_content_type (CamelMimePart *mime_part)
+my_get_content_type (CamelMimePart *mime_part)
{
return mime_part->content_type;
}
@@ -586,7 +586,7 @@ camel_mime_part_get_content_type (CamelMimePart *mime_part)
static void
-_set_content_object (CamelMedium *medium, CamelDataWrapper *content)
+my_set_content_object (CamelMedium *medium, CamelDataWrapper *content)
{
CamelMimePart *mime_part = CAMEL_MIME_PART (medium);
GMimeContentField *object_content_field;
@@ -603,7 +603,7 @@ _set_content_object (CamelMedium *medium, CamelDataWrapper *content)
}
static CamelDataWrapper *
-_get_content_object (CamelMedium *medium)
+my_get_content_object (CamelMedium *medium)
{
CamelMimePart *mime_part = CAMEL_MIME_PART (medium);
CamelStream *stream;
@@ -657,7 +657,7 @@ _get_content_object (CamelMedium *medium)
static void
-_write_content_to_stream (CamelMimePart *mime_part, CamelStream *stream)
+my_write_content_to_stream (CamelMimePart *mime_part, CamelStream *stream)
{
CamelMedium *medium = CAMEL_MEDIUM (mime_part);
CamelStream *wrapper_stream;
@@ -700,7 +700,7 @@ _write_content_to_stream (CamelMimePart *mime_part, CamelStream *stream)
static void
-_write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream)
+my_write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream)
{
CamelMimePart *mp = CAMEL_MIME_PART (data_wrapper);
CamelMedium *medium = CAMEL_MEDIUM (data_wrapper);
@@ -728,7 +728,7 @@ _write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream)
gmime_content_field_write_to_stream (mp->content_type, stream);
camel_stream_write_string(stream,"\n");
- _write_content_to_stream (mp, stream);
+ my_write_content_to_stream (mp, stream);
}
@@ -738,7 +738,7 @@ _write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream)
/* mime part parsing */
static gboolean
-_parse_header_pair (CamelMimePart *mime_part, gchar *header_name, gchar *header_value)
+my_parse_header_pair (CamelMimePart *mime_part, gchar *header_name, gchar *header_value)
{
CamelHeaderType header_type;
gboolean header_handled = FALSE;
@@ -817,7 +817,7 @@ _parse_header_pair (CamelMimePart *mime_part, gchar *header_name, gchar *header_
static void
-_construct_from_stream (CamelDataWrapper *data_wrapper, CamelStream *stream)
+my_construct_from_stream (CamelDataWrapper *data_wrapper, CamelStream *stream)
{
CamelMimePart *mime_part = CAMEL_MIME_PART (data_wrapper);
@@ -834,7 +834,7 @@ _construct_from_stream (CamelDataWrapper *data_wrapper, CamelStream *stream)
static void
-_set_input_stream (CamelDataWrapper *data_wrapper, CamelStream *stream)
+my_set_input_stream (CamelDataWrapper *data_wrapper, CamelStream *stream)
{
CamelMimePart *mime_part = CAMEL_MIME_PART (data_wrapper);
CamelSeekableStream *seekable_stream;
@@ -866,13 +866,19 @@ _set_input_stream (CamelDataWrapper *data_wrapper, CamelStream *stream)
static CamelStream *
-_get_output_stream (CamelDataWrapper *data_wrapper)
+my_get_output_stream (CamelDataWrapper *data_wrapper)
{
CamelMimePart *mime_part = CAMEL_MIME_PART (data_wrapper);
CamelStream *input_stream;
CamelStream *output_stream;
/* ** FIXME : bogus bogus bogus - test test test */
+ return NULL;
+
+ /*
+ * For the moment, we do not use this routine on
+ * mime parts. Maybe later.
+ */
CAMEL_LOG_FULL_DEBUG ("CamelMimePart::get_output_stream leaving\n");
input_stream = camel_data_wrapper_get_input_stream (data_wrapper);
@@ -925,7 +931,6 @@ camel_mime_part_encoding_to_string (CamelMimePartEncodingType encoding)
CamelMimePartEncodingType
camel_mime_part_encoding_from_string (const gchar *string)
{
- printf ("*************** encoding string : _%s_\n", string);
if (strcmp (string, "7bit") == 0)
return CAMEL_MIME_PART_ENCODING_7BIT;
else if (strcmp (string, "8bit") == 0)
diff --git a/camel/camel-multipart.c b/camel/camel-multipart.c
index c44eaacb09..d5c8f383aa 100644
--- a/camel/camel-multipart.c
+++ b/camel/camel-multipart.c
@@ -35,30 +35,30 @@
#include "camel-multipart.h"
-static void _add_part (CamelMultipart *multipart,
- CamelMimeBodyPart *part);
-static void _add_part_at (CamelMultipart *multipart,
- CamelMimeBodyPart *part,
- guint index);
-static void _remove_part (CamelMultipart *multipart,
- CamelMimeBodyPart *part);
-static CamelMimeBodyPart * _remove_part_at (CamelMultipart *multipart,
- guint index);
-static CamelMimeBodyPart * _get_part (CamelMultipart *multipart,
- guint index);
-static guint _get_number (CamelMultipart *multipart);
-static void _set_parent (CamelMultipart *multipart,
- CamelMimePart *parent);
-static CamelMimePart * _get_parent (CamelMultipart *multipart);
-static void _set_boundary (CamelMultipart *multipart,
- gchar *boundary);
-static const gchar * _get_boundary (CamelMultipart *multipart);
-static void _write_to_stream (CamelDataWrapper *data_wrapper,
- CamelStream *stream);
-static void _set_input_stream (CamelDataWrapper *data_wrapper,
- CamelStream *stream);
-
-static void _finalize (GtkObject *object);
+static void my_add_part (CamelMultipart *multipart,
+ CamelMimeBodyPart *part);
+static void my_add_part_at (CamelMultipart *multipart,
+ CamelMimeBodyPart *part,
+ guint index);
+static void my_remove_part (CamelMultipart *multipart,
+ CamelMimeBodyPart *part);
+static CamelMimeBodyPart * my_remove_part_at (CamelMultipart *multipart,
+ guint index);
+static CamelMimeBodyPart * my_get_part (CamelMultipart *multipart,
+ guint index);
+static guint my_get_number (CamelMultipart *multipart);
+static void my_set_parent (CamelMultipart *multipart,
+ CamelMimePart *parent);
+static CamelMimePart * my_get_parent (CamelMultipart *multipart);
+static void my_set_boundary (CamelMultipart *multipart,
+ gchar *boundary);
+static const gchar * my_get_boundary (CamelMultipart *multipart);
+static void my_write_to_stream (CamelDataWrapper *data_wrapper,
+ CamelStream *stream);
+static void my_set_input_stream (CamelDataWrapper *data_wrapper,
+ CamelStream *stream);
+
+static void my_finalize (GtkObject *object);
static CamelDataWrapperClass *parent_class=NULL;
@@ -76,26 +76,26 @@ camel_multipart_class_init (CamelMultipartClass *camel_multipart_class)
{
CamelDataWrapperClass *camel_data_wrapper_class = CAMEL_DATA_WRAPPER_CLASS (camel_multipart_class);
GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (camel_multipart_class);
-
+
parent_class = gtk_type_class (camel_data_wrapper_get_type ());
-
+
/* virtual method definition */
- camel_multipart_class->add_part = _add_part;
- camel_multipart_class->add_part_at = _add_part_at;
- camel_multipart_class->remove_part = _remove_part;
- camel_multipart_class->remove_part_at = _remove_part_at;
- camel_multipart_class->get_part = _get_part;
- camel_multipart_class->get_number = _get_number;
- camel_multipart_class->set_parent = _set_parent;
- camel_multipart_class->get_parent = _get_parent;
- camel_multipart_class->set_boundary = _set_boundary;
- camel_multipart_class->get_boundary = _get_boundary;
-
+ camel_multipart_class->add_part = my_add_part;
+ camel_multipart_class->add_part_at = my_add_part_at;
+ camel_multipart_class->remove_part = my_remove_part;
+ camel_multipart_class->remove_part_at = my_remove_part_at;
+ camel_multipart_class->get_part = my_get_part;
+ camel_multipart_class->get_number = my_get_number;
+ camel_multipart_class->set_parent = my_set_parent;
+ camel_multipart_class->get_parent = my_get_parent;
+ camel_multipart_class->set_boundary = my_set_boundary;
+ camel_multipart_class->get_boundary = my_get_boundary;
+
/* virtual method overload */
- camel_data_wrapper_class->write_to_stream = _write_to_stream;
- camel_data_wrapper_class->set_input_stream = _set_input_stream;
-
- gtk_object_class->finalize = _finalize;
+ camel_data_wrapper_class->write_to_stream = my_write_to_stream;
+ camel_data_wrapper_class->set_input_stream = my_set_input_stream;
+
+ gtk_object_class->finalize = my_finalize;
}
static void
@@ -137,7 +137,7 @@ camel_multipart_get_type (void)
}
static void
-_unref_part (gpointer data, gpointer user_data)
+my_unref_part (gpointer data, gpointer user_data)
{
GtkObject *body_part = GTK_OBJECT (data);
@@ -145,20 +145,20 @@ _unref_part (gpointer data, gpointer user_data)
}
static void
-_finalize (GtkObject *object)
+my_finalize (GtkObject *object)
{
CamelMultipart *multipart = CAMEL_MULTIPART (object);
-
+
CAMEL_LOG_FULL_DEBUG ("Entering CamelMultipart::finalize\n");
-
+
if (multipart->parent) gtk_object_unref (GTK_OBJECT (multipart->parent));
-
- g_list_foreach (multipart->parts, _unref_part, NULL);
+
+ g_list_foreach (multipart->parts, my_unref_part, NULL);
if (multipart->boundary) g_free (multipart->boundary);
if (multipart->preface) g_free (multipart->preface);
if (multipart->postface) g_free (multipart->postface);
-
+
GTK_OBJECT_CLASS (parent_class)->finalize (object);
CAMEL_LOG_FULL_DEBUG ("Leaving CamelMultipart::finalize\n");
}
@@ -174,15 +174,15 @@ camel_multipart_new (void)
multipart = (CamelMultipart *)gtk_type_new (CAMEL_MULTIPART_TYPE);
multipart->preface = NULL;
multipart->postface = NULL;
-
-
+
+
CAMEL_LOG_FULL_DEBUG ("CamelMultipart:: Leaving new()\n");
return multipart;
}
static void
-_add_part (CamelMultipart *multipart, CamelMimeBodyPart *part)
+my_add_part (CamelMultipart *multipart, CamelMimeBodyPart *part)
{
multipart->parts = g_list_append (multipart->parts, part);
if (part) gtk_object_ref (GTK_OBJECT (part));
@@ -196,7 +196,7 @@ camel_multipart_add_part (CamelMultipart *multipart, CamelMimeBodyPart *part)
static void
-_add_part_at (CamelMultipart *multipart, CamelMimeBodyPart *part, guint index)
+my_add_part_at (CamelMultipart *multipart, CamelMimeBodyPart *part, guint index)
{
multipart->parts = g_list_insert (multipart->parts, part, index);
if (part) gtk_object_ref (GTK_OBJECT (part));
@@ -209,7 +209,7 @@ camel_multipart_add_part_at (CamelMultipart *multipart, CamelMimeBodyPart *part,
}
static void
-_remove_part (CamelMultipart *multipart, CamelMimeBodyPart *part)
+my_remove_part (CamelMultipart *multipart, CamelMimeBodyPart *part)
{
if (!multipart->parts) {
CAMEL_LOG_FULL_DEBUG ("CamelMultipart::remove_part part list id void\n");
@@ -227,20 +227,20 @@ camel_multipart_remove_part (CamelMultipart *multipart, CamelMimeBodyPart *part)
static CamelMimeBodyPart *
-_remove_part_at (CamelMultipart *multipart, guint index)
+my_remove_part_at (CamelMultipart *multipart, guint index)
{
GList *parts_list;
GList *part_to_remove;
CamelMimeBodyPart *removed_body_part;
-
+
CAMEL_LOG_FULL_DEBUG ("CamelMultipart:: Entering remove_part_at\n");
CAMEL_LOG_TRACE ("CamelMultipart::remove_part_at : Removing part number %d\n", index);
-
+
if (!(multipart->parts)) {
CAMEL_LOG_FULL_DEBUG ("CamelMultipart::remove_part_at part list is void \n");
return NULL;
}
-
+
parts_list = multipart->parts;
part_to_remove = g_list_nth (parts_list, index);
if (!part_to_remove) {
@@ -250,7 +250,7 @@ _remove_part_at (CamelMultipart *multipart, guint index)
return NULL;
}
removed_body_part = CAMEL_MIME_BODY_PART (part_to_remove->data);
-
+
multipart->parts = g_list_remove_link (parts_list, part_to_remove);
if (part_to_remove->data) gtk_object_unref (GTK_OBJECT (part_to_remove->data));
g_list_free_1 (part_to_remove);
@@ -268,7 +268,7 @@ camel_multipart_remove_part_at (CamelMultipart *multipart, guint index)
static CamelMimeBodyPart *
-_get_part (CamelMultipart *multipart, guint index)
+my_get_part (CamelMultipart *multipart, guint index)
{
GList *part;
if (!(multipart->parts)) {
@@ -292,7 +292,7 @@ camel_multipart_get_part (CamelMultipart *multipart, guint index)
static guint
-_get_number (CamelMultipart *multipart)
+my_get_number (CamelMultipart *multipart)
{
return g_list_length (multipart->parts);
}
@@ -305,7 +305,7 @@ camel_multipart_get_number (CamelMultipart *multipart)
static void
-_set_parent (CamelMultipart *multipart, CamelMimePart *parent)
+my_set_parent (CamelMultipart *multipart, CamelMimePart *parent)
{
multipart->parent = parent;
if (parent) gtk_object_ref (GTK_OBJECT (parent));
@@ -319,7 +319,7 @@ camel_multipart_set_parent (CamelMultipart *multipart, CamelMimePart *parent)
static CamelMimePart *
-_get_parent (CamelMultipart *multipart)
+my_get_parent (CamelMultipart *multipart)
{
return multipart->parent;
}
@@ -336,7 +336,7 @@ camel_multipart_get_parent (CamelMultipart *multipart)
static void
-_set_boundary (CamelMultipart *multipart, gchar *boundary)
+my_set_boundary (CamelMultipart *multipart, gchar *boundary)
{
gmime_content_field_set_parameter (CAMEL_DATA_WRAPPER (multipart)->mime_type, "boundary", boundary);
}
@@ -349,7 +349,7 @@ camel_multipart_set_boundary (CamelMultipart *multipart, gchar *boundary)
static const gchar *
-_get_boundary (CamelMultipart *multipart)
+my_get_boundary (CamelMultipart *multipart)
{
const gchar *boundary;
CAMEL_LOG_FULL_DEBUG ("Entering CamelMultipart::_get_boundary\n");
@@ -371,7 +371,7 @@ camel_multipart_get_boundary (CamelMultipart *multipart)
}
-struct _print_part_user_data {
+struct my_print_part_user_data {
CamelStream *stream;
const gchar *boundary;
};
@@ -379,37 +379,60 @@ struct _print_part_user_data {
static void
-_print_part (gpointer data, gpointer user_data)
+my_print_part (gpointer data, gpointer user_data)
{
CamelMimeBodyPart *body_part = CAMEL_MIME_BODY_PART (data);
- struct _print_part_user_data *ud = (struct _print_part_user_data *)user_data;
+ struct my_print_part_user_data *ud = (struct my_print_part_user_data *)user_data;
if (ud->boundary) camel_stream_write_strings (ud->stream, "\n--", ud->boundary, "\n", NULL);
else camel_stream_write_strings (ud->stream, "\n--\n", NULL);
camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (body_part), ud->stream);
-
+
}
-
+
static void
-_write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream)
+my_write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream)
{
CamelMultipart *multipart = CAMEL_MULTIPART (data_wrapper);
- struct _print_part_user_data ud;
+ struct my_print_part_user_data ud;
const gchar *boundary;
-
+
CAMEL_LOG_FULL_DEBUG ("Entering CamelMultipart::_write_to_stream entering\n");
+
+ /* get the bundary text */
boundary = camel_multipart_get_boundary (multipart);
CAMEL_LOG_FULL_DEBUG ("Entering CamelMultipart::_write_to_stream, boundary = %s\n", boundary);
+
+ /* we cannot write a multipart without a boundary string */
g_return_if_fail (boundary);
+
+ /*
+ * write the preface text (usually something like
+ * "This is a mime message, if you see this, then
+ * your mail client probably doesn't support ...."
+ */
+ if (multipart->preface) camel_stream_write_strings (stream, multipart->preface, NULL);
+
+ /*
+ * Now, write all the parts, separated by the boundary
+ * delimiter
+ */
ud.boundary = boundary;
ud.stream = stream;
- if (multipart->preface) camel_stream_write_strings (stream, multipart->preface, NULL);
- g_list_foreach (multipart->parts, _print_part, (gpointer)&ud);
+ if (boundary && (boundary[0] == '\0'))
+ g_warning ("Multipart boundary is zero length\n");
+ g_list_foreach (multipart->parts, my_print_part, (gpointer)&ud);
+
+ /* write the terminating boudary delimiter */
camel_stream_write_strings (stream, "\n--", boundary, "--\n", NULL);
+
+ /* and finally the postface */
if (multipart->postface) camel_stream_write_strings (stream, multipart->postface, NULL);
+
+
CAMEL_LOG_FULL_DEBUG ("Leaving CamelMultipart::_write_to_stream leaving \n");
}
@@ -424,7 +447,7 @@ _write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream)
/**
- * _localize_part: localize one part in a multipart environement.
+ * my_localize_part: localize one part in a multipart environement.
* @stream: the stream to read the lines from.
* @normal_boundary: end of part bundary.
* @end_boundary: end of multipart boundary.
@@ -439,28 +462,28 @@ _write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream)
**/
static gboolean
-_localize_part (CamelStream *stream,
- gchar *normal_boundary,
- gchar *end_boundary,
- guint32 *end_position)
+my_localize_part (CamelStream *stream,
+ gchar *normal_boundary,
+ gchar *end_boundary,
+ guint32 *end_position)
{
gchar *new_line = NULL;
gboolean end_of_part = FALSE;
gboolean last_part = FALSE;
guint32 last_position;
-
+
/* Note for future enhancements */
/* RFC 2046 precises that when parsing the content of a multipart
* element, the program should not think it will find the last boundary,
* and in particular, the message could have been damaged during
* transport, the parsing should still be OK */
- CAMEL_LOG_FULL_DEBUG ("CamelMultipart:: Entering _localize_part\n");
-
+ CAMEL_LOG_FULL_DEBUG ("CamelMultipart:: Entering my_localize_part\n");
+
g_assert (CAMEL_IS_SEEKABLE_STREAM (stream));
-
+
last_position = camel_seekable_stream_get_current_position (CAMEL_SEEKABLE_STREAM (stream));
new_line = gmime_read_line_from_stream (stream);
-
+
while (new_line && !end_of_part && !last_part) {
end_of_part = (strcmp (new_line, normal_boundary) == 0);
last_part = (strcmp (new_line, end_boundary) == 0);
@@ -470,17 +493,17 @@ _localize_part (CamelStream *stream,
last_position =
camel_seekable_stream_get_current_position (CAMEL_SEEKABLE_STREAM (stream));
-
+
new_line = gmime_read_line_from_stream (stream);
}
}
if (new_line) g_free (new_line);
else last_part = TRUE;
-
+
*end_position = last_position;
-
- CAMEL_LOG_FULL_DEBUG ("CamelMultipart:: Leaving _localize_part\n");
+
+ CAMEL_LOG_FULL_DEBUG ("CamelMultipart:: Leaving my_localize_part\n");
return (last_part);
}
@@ -488,7 +511,7 @@ _localize_part (CamelStream *stream,
static void
-_set_input_stream (CamelDataWrapper *data_wrapper, CamelStream *stream)
+my_set_input_stream (CamelDataWrapper *data_wrapper, CamelStream *stream)
{
CamelMultipart *multipart = CAMEL_MULTIPART (data_wrapper);
CamelSeekableStream *seekable_stream = CAMEL_SEEKABLE_STREAM (stream);
@@ -501,40 +524,40 @@ _set_input_stream (CamelDataWrapper *data_wrapper, CamelStream *stream)
CamelSeekableSubstream *body_part_input_stream;
guint32 saved_stream_pos;
-
+
CAMEL_LOG_FULL_DEBUG ("Entering CamelMultipart::_set_input_stream\n");
-
+
/* call parent class implementation */
parent_class->set_input_stream (data_wrapper, stream);
-
+
boundary = camel_multipart_get_boundary (multipart);
g_return_if_fail (boundary);
real_boundary_line = g_strdup_printf ("--%s", boundary);
end_boundary_line = g_strdup_printf ("--%s--", boundary);
-
+
/* read the prefix if any */
- end_of_multipart = _localize_part (stream,
- real_boundary_line,
- end_boundary_line,
- &part_end);
+ end_of_multipart = my_localize_part (stream,
+ real_boundary_line,
+ end_boundary_line,
+ &part_end);
if (multipart->preface) g_free (multipart->preface);
-
+
/* if ( (new_part->str)[0] != '\0') multipart->preface = g_strdup (new_part->str); */
/* read all the real parts */
while (!end_of_multipart) {
/* determine the position of the begining of the part */
part_begining = camel_seekable_stream_get_current_position (seekable_stream);
-
+
CAMEL_LOG_FULL_DEBUG ("CamelMultipart::set_input_stream, detected a new part\n");
body_part = camel_mime_body_part_new ();
- end_of_multipart = _localize_part (stream,
- real_boundary_line,
- end_boundary_line,
- &part_end);
+ end_of_multipart = my_localize_part (stream,
+ real_boundary_line,
+ end_boundary_line,
+ &part_end);
body_part_input_stream =
camel_seekable_substream_new_with_seekable_stream_and_bounds (seekable_stream,
part_begining,
@@ -542,33 +565,34 @@ _set_input_stream (CamelDataWrapper *data_wrapper, CamelStream *stream)
CAMEL_LOG_FULL_DEBUG ("CamelMultipart::set_input_stream, use a substream,\n"
"\tbegining = %d\n"
"\tend = %d\n",part_begining, part_end);
-
+
/* the seekable substream may change the position of the stream
so we must save it before calling set_input_stream */
saved_stream_pos = camel_seekable_stream_get_current_position (seekable_stream);
-
+
camel_data_wrapper_set_input_stream (CAMEL_DATA_WRAPPER (body_part),
CAMEL_STREAM (body_part_input_stream));
CAMEL_LOG_FULL_DEBUG ("CamelMultipart::set_input_stream,"
"new body part has input stream : %p\n", body_part_input_stream);
-
+
/* restore the stream position */
camel_seekable_stream_seek (seekable_stream, saved_stream_pos, CAMEL_STREAM_SET);
-
+
/* add the body part to the multipart object */
camel_multipart_add_part (multipart, body_part);
}
-
+
/* g_string_assign (new_part, ""); */
- /* _localize_part (new_part, stream, real_boundary_line, end_boundary_line); */
-
+ /* my_localize_part (new_part, stream, real_boundary_line, end_boundary_line); */
+
if (multipart->postface) g_free (multipart->postface);
/* if ( (new_part->str)[0] != '\0') multipart->postface = g_strdup (new_part->str); */
-
+
/* g_string_free (new_part, TRUE); */
-
+
g_free (real_boundary_line);
g_free (end_boundary_line);
CAMEL_LOG_FULL_DEBUG ("Leaving CamelMultipart::_set_input_stream\n");
}
+
diff --git a/camel/camel-simple-data-wrapper.c b/camel/camel-simple-data-wrapper.c
index f4b7afd5f9..a1822e8bcf 100644
--- a/camel/camel-simple-data-wrapper.c
+++ b/camel/camel-simple-data-wrapper.c
@@ -35,13 +35,12 @@ 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);
-static void _write_to_stream (CamelDataWrapper *data_wrapper,
- CamelStream *stream);
-static void _finalize (GtkObject *object);
-static CamelStream * _get_stream (CamelDataWrapper *data_wrapper);
-static CamelStream * _get_output_stream (CamelDataWrapper *data_wrapper);
+static void my_construct_from_stream (CamelDataWrapper *data_wrapper,
+ CamelStream *stream);
+static void my_write_to_stream (CamelDataWrapper *data_wrapper,
+ CamelStream *stream);
+static void my_finalize (GtkObject *object);
+static CamelStream * my_get_output_stream (CamelDataWrapper *data_wrapper);
@@ -55,22 +54,22 @@ camel_simple_data_wrapper_class_init (CamelSimpleDataWrapperClass *camel_simple_
/* 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;
- camel_data_wrapper_class->get_output_stream = _get_output_stream;
+ camel_data_wrapper_class->write_to_stream = my_write_to_stream;
+ camel_data_wrapper_class->construct_from_stream = my_construct_from_stream;
+ camel_data_wrapper_class->get_output_stream = my_get_output_stream;
- camel_data_wrapper_class->get_stream = _get_stream;
-
- gtk_object_class->finalize = _finalize;
+ gtk_object_class->finalize = my_finalize;
}
static void
camel_simple_data_wrapper_init (CamelSimpleDataWrapper *wrapper)
{
- wrapper->stream = NULL;
+ wrapper->byte_array = NULL;
+ wrapper->has_byte_array_stream = FALSE;
}
+
GtkType
camel_simple_data_wrapper_get_type (void)
{
@@ -89,7 +88,8 @@ camel_simple_data_wrapper_get_type (void)
(GtkClassInitFunc) NULL,
};
- camel_simple_data_wrapper_type = gtk_type_unique (camel_data_wrapper_get_type (), &camel_simple_data_wrapper_info);
+ camel_simple_data_wrapper_type = gtk_type_unique (camel_data_wrapper_get_type (),
+ &camel_simple_data_wrapper_info);
}
return camel_simple_data_wrapper_type;
@@ -97,7 +97,7 @@ camel_simple_data_wrapper_get_type (void)
static void
-_finalize (GtkObject *object)
+my_finalize (GtkObject *object)
{
CamelSimpleDataWrapper *simple_data_wrapper = CAMEL_SIMPLE_DATA_WRAPPER (object);
@@ -130,11 +130,11 @@ camel_simple_data_wrapper_new (void)
static void
-_write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream)
+my_write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream)
{
CamelSimpleDataWrapper *simple_data_wrapper = CAMEL_SIMPLE_DATA_WRAPPER (data_wrapper);
GByteArray *array;
- CAMEL_LOG_FULL_DEBUG ("CamelSimpleDataWrapper:: Entering _write_to_stream\n");
+ CAMEL_LOG_FULL_DEBUG ("CamelSimpleDataWrapper:: Entering my_write_to_stream\n");
g_assert (data_wrapper);
g_assert (stream);
@@ -143,28 +143,28 @@ _write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream)
if (array->len)
camel_stream_write (stream, (gchar *)array->data, array->len);
- CAMEL_LOG_FULL_DEBUG ("CamelSimpleDataWrapper:: Leaving _write_to_stream\n");
+ CAMEL_LOG_FULL_DEBUG ("CamelSimpleDataWrapper:: Leaving my_write_to_stream\n");
}
-#define _CMSDW_TMP_BUF_SIZE 100
+#define my_CMSDW_TMP_BUF_SIZE 100
static void
-_construct_from_stream (CamelDataWrapper *data_wrapper, CamelStream *stream)
+my_construct_from_stream (CamelDataWrapper *data_wrapper, CamelStream *stream)
{
CamelSimpleDataWrapper *simple_data_wrapper = CAMEL_SIMPLE_DATA_WRAPPER (data_wrapper);
gint nb_bytes_read;
static gchar *tmp_buf;
GByteArray *array;
- CAMEL_LOG_FULL_DEBUG ("CamelSimpleDataWrapper:: Entering _construct_from_stream\n");
+ CAMEL_LOG_FULL_DEBUG ("CamelSimpleDataWrapper:: Entering my_construct_from_stream\n");
g_assert (data_wrapper);
g_assert (stream);
if (!tmp_buf) {
CAMEL_LOG_FULL_DEBUG ("CamelSimpleDataWrapper::construct_from_stream allocating new temp buffer "
- "with %d bytes\n", _CMSDW_TMP_BUF_SIZE);
- tmp_buf = g_new (gchar, _CMSDW_TMP_BUF_SIZE);
+ "with %d bytes\n", my_CMSDW_TMP_BUF_SIZE);
+ tmp_buf = g_new (gchar, my_CMSDW_TMP_BUF_SIZE);
}
array = simple_data_wrapper->byte_array;
@@ -176,14 +176,14 @@ _construct_from_stream (CamelDataWrapper *data_wrapper, CamelStream *stream)
array = g_byte_array_new ();
CAMEL_LOG_FULL_DEBUG ("CamelSimpleDataWrapper::construct_from_stream new byte array address:%p\n", array);
simple_data_wrapper->byte_array = array;
- nb_bytes_read = camel_stream_read (stream, tmp_buf, _CMSDW_TMP_BUF_SIZE);
+ nb_bytes_read = camel_stream_read (stream, tmp_buf, my_CMSDW_TMP_BUF_SIZE);
while (nb_bytes_read>0) {
CAMEL_LOG_FULL_DEBUG ("CamelSimpleDataWrapper::construct_from_stream read %d bytes from stream\n", nb_bytes_read);
if (nb_bytes_read>0) g_byte_array_append (array, tmp_buf, nb_bytes_read);
- nb_bytes_read = camel_stream_read (stream, tmp_buf, _CMSDW_TMP_BUF_SIZE);
+ nb_bytes_read = camel_stream_read (stream, tmp_buf, my_CMSDW_TMP_BUF_SIZE);
};
- CAMEL_LOG_FULL_DEBUG ("CamelSimpleDataWrapper:: Leaving _construct_from_stream\n");
+ CAMEL_LOG_FULL_DEBUG ("CamelSimpleDataWrapper:: Leaving my_construct_from_stream\n");
}
@@ -219,29 +219,27 @@ camel_simple_data_wrapper_set_text (CamelSimpleDataWrapper *simple_data_wrapper,
+
+
static CamelStream *
-_get_stream (CamelDataWrapper *data_wrapper)
+my_get_output_stream (CamelDataWrapper *data_wrapper)
{
CamelSimpleDataWrapper *simple_data_wrapper;
+ CamelStream *output_stream = NULL;
- simple_data_wrapper = CAMEL_SIMPLE_DATA_WRAPPER (data_wrapper);
- if (simple_data_wrapper->stream == NULL) {
- CamelStream *s;
-
- s = camel_simple_data_wrapper_stream_new (simple_data_wrapper);
- simple_data_wrapper->stream = s;
- }
-
- return simple_data_wrapper->stream;
-}
+ CAMEL_LOG_FULL_DEBUG ("CamelSimpleDataWrapper::get_output_stream leaving\n");
-static CamelStream *
-_get_output_stream (CamelDataWrapper *data_wrapper)
-{
+ g_assert (data_wrapper);
+ simple_data_wrapper = CAMEL_SIMPLE_DATA_WRAPPER (data_wrapper);
- CAMEL_LOG_FULL_DEBUG ("CamelSimpleDataWrapper::get_output_stream leaving\n");
- return camel_data_wrapper_get_input_stream (data_wrapper);
- CAMEL_LOG_FULL_DEBUG ("CamelSimpleDataWrapper::get_output_stream leaving\n");
+ if (simple_data_wrapper->byte_array && !(simple_data_wrapper->has_byte_array_stream)) {
+ output_stream = camel_simple_data_wrapper_stream_new (simple_data_wrapper);
+ camel_data_wrapper_set_output_stream (data_wrapper, output_stream);
+ }
+ CAMEL_LOG_FULL_DEBUG ("CamelSimpleDataWrapper::get_output_stream leaving\n");
+
+ return parent_class->get_output_stream (data_wrapper);
+
}
diff --git a/camel/camel-simple-data-wrapper.h b/camel/camel-simple-data-wrapper.h
index fe89af5545..50dfa84f64 100644
--- a/camel/camel-simple-data-wrapper.h
+++ b/camel/camel-simple-data-wrapper.h
@@ -50,7 +50,7 @@ struct _CamelSimpleDataWrapper
CamelDataWrapper parent_object;
GByteArray *byte_array;
- CamelStream *stream;
+ gboolean has_byte_array_stream;
};
diff --git a/camel/camel-stream-b64.c b/camel/camel-stream-b64.c
index df4f755fac..eb99f40058 100644
--- a/camel/camel-stream-b64.c
+++ b/camel/camel-stream-b64.c
@@ -356,7 +356,8 @@ my_read_encode (CamelStream *stream,
* read to write in the stream
*/
if (status->state == 3) {
- buffer [j++] = status->keep;
+ buffer [j++] = six_bits_to_char [status->keep];
+ status->state = 0;
status->keep = 0;
status->line_length++;
break;
@@ -418,7 +419,7 @@ my_read_encode (CamelStream *stream,
* we are at the end of the input stream
* we must pad the output with '='.
*/
-
+ printf ("%d\n", status->end_state);
while ((j<n) && (status->end_state != 6)) {
if (status->end_state == 5) {
@@ -465,7 +466,6 @@ my_read_encode (CamelStream *stream,
}
- status->end_state++;
break;
@@ -570,8 +570,9 @@ camel_stream_b64_write_to_stream (CamelStreamB64 *stream_b64,
while (!camel_stream_eos (CAMEL_STREAM (stream_b64))) {
nb_read = camel_stream_read (CAMEL_STREAM (stream_b64), tmp_buf, 4096);
nb_written = 0;
+
while (nb_written < nb_read)
- nb_written += camel_stream_write (output_stream, tmp_buf, nb_read);
+ nb_written += camel_stream_write (output_stream, tmp_buf + nb_written, nb_read - nb_written);
}
}
diff --git a/camel/camel-stream-fs.c b/camel/camel-stream-fs.c
index f2aab64910..4455c40b2b 100644
--- a/camel/camel-stream-fs.c
+++ b/camel/camel-stream-fs.c
@@ -355,6 +355,7 @@ _read (CamelStream *stream, gchar *buffer, gint n)
do {
v = read ( (CAMEL_STREAM_FS (stream))->fd, buffer, nb_to_read);
} while (v == -1 && errno == EINTR);
+
if (v<0)
CAMEL_LOG_FULL_DEBUG ("CamelStreamFs::read v=%d\n", v);
else
@@ -384,18 +385,20 @@ _write (CamelStream *stream, const gchar *buffer, gint n)
CamelStreamFs *stream_fs = CAMEL_STREAM_FS (stream);
int v;
gint nb_to_write;
+ gint nb_bytes_written = 0;
+ if (n <= 0)
+ return 0;
+
g_assert (stream);
g_assert (stream_fs->fd);
CAMEL_LOG_FULL_DEBUG ( "CamelStreamFs:: entering write. n=%d\n", n);
- if (stream_fs->sup_bound != -1)
- nb_to_write = MIN (stream_fs->sup_bound - CAMEL_SEEKABLE_STREAM (stream)->cur_pos, n);
- else
- nb_to_write = n;
-
+ /* we do not take the end bounds into account as it does not
+ really make any sense in the case of a write operation */
do {
- v = write ( stream_fs->fd, buffer, nb_to_write);
+ v = write ( stream_fs->fd, buffer, n);
+ if (v>0) nb_bytes_written += v;
} while (v == -1 && errno == EINTR);
#if HARD_LOG_LEVEL >= FULL_DEBUG
@@ -405,10 +408,10 @@ _write (CamelStream *stream, const gchar *buffer, gint n)
}
#endif
- if (v>0)
- CAMEL_SEEKABLE_STREAM (stream)->cur_pos += v;
+ if (nb_bytes_written>0)
+ CAMEL_SEEKABLE_STREAM (stream)->cur_pos += nb_bytes_written;
- return v;
+ return nb_bytes_written;
}
diff --git a/tests/test1.c b/tests/test1.c
index 048b36e1ec..d967bb3566 100644
--- a/tests/test1.c
+++ b/tests/test1.c
@@ -78,7 +78,9 @@ main (int argc, char**argv)
if (attachment_stream == NULL) {
attachment_part = NULL;
} else {
- CamelDataWrapper *stream_wrapper;
+ CamelDataWrapper *attachment_wrapper;
+
+ /*CamelDataWrapper *stream_wrapper;
stream_wrapper = camel_stream_data_wrapper_new
(attachment_stream);
@@ -90,7 +92,21 @@ main (int argc, char**argv)
stream_wrapper);
camel_multipart_add_part (multipart, attachment_part);
- gtk_object_unref (GTK_OBJECT (stream_wrapper));
+ gtk_object_unref (GTK_OBJECT (stream_wrapper));*/
+
+ attachment_wrapper = CAMEL_DATA_WRAPPER (camel_simple_data_wrapper_new ());
+ camel_data_wrapper_set_input_stream (attachment_wrapper,
+ attachment_stream);
+
+ attachment_part = camel_mime_body_part_new ();
+ camel_mime_part_set_encoding (CAMEL_MIME_PART (attachment_part),
+ CAMEL_MIME_PART_ENCODING_BASE64);
+ camel_medium_set_content_object (CAMEL_MEDIUM (attachment_part),
+ attachment_wrapper);
+ camel_multipart_add_part (multipart, attachment_part);
+
+
+
}
camel_medium_set_content_object (CAMEL_MEDIUM (message), CAMEL_DATA_WRAPPER (multipart));