aboutsummaryrefslogtreecommitdiffstats
path: root/camel
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2000-05-18 09:00:25 +0800
committerDan Winship <danw@src.gnome.org>2000-05-18 09:00:25 +0800
commit0cd1c1934c5a366a8d506c177c859d65075fb942 (patch)
tree34553076f5f83d2087fdf55b3ba807f42f6f3f36 /camel
parent844e27e365aa00a3d49055d316e5848c03118895 (diff)
downloadgsoc2013-evolution-0cd1c1934c5a366a8d506c177c859d65075fb942.tar.gz
gsoc2013-evolution-0cd1c1934c5a366a8d506c177c859d65075fb942.tar.zst
gsoc2013-evolution-0cd1c1934c5a366a8d506c177c859d65075fb942.zip
remove get/set_output_stream operations. They're redundant with
* camel-data-wrapper.c: remove get/set_output_stream operations. They're redundant with write_to_stream, and CamelMimePart and CamelMimeMessage only implement the latter, meaning that trying to get_output_stream on a CamelMimeMessage that was built from pieces rather than being parsed from a stream doesn't work. Anything that uses get_output_stream can be rewritten to use write_to_stream, so we'll standardize on that. (camel_data_wrapper_new): remove this: CamelDataWrapper is supposed to be an abstract class. (write_to_stream): remove default implementation. (Moved to CamelSimpleDataWrapper) * camel-simple-data-wrapper.c: resurrect, although it's not really the same thing it was before. A simple data wrapper, which is backed by a CamelStream. * camel-mime-part-utils.c (simple_data_wrapper_construct_from_parser): Use construct_from_stream rather than set_output_stream. (camel_mime_part_construct_content_from_parser): Change camel_data_wrapper_new to camel_simple_data_wrapper_new. * camel-mime-part.c (camel_mime_part_set_content): Change camel_data_wrapper_new to camel_simple_data_wrapper_new. svn path=/trunk/; revision=3112
Diffstat (limited to 'camel')
-rw-r--r--camel/ChangeLog28
-rw-r--r--camel/Makefile.am2
-rw-r--r--camel/camel-data-wrapper.c114
-rw-r--r--camel/camel-data-wrapper.h11
-rw-r--r--camel/camel-mime-part-utils.c8
-rw-r--r--camel/camel-mime-part.c2
-rw-r--r--camel/camel-simple-data-wrapper.c137
-rw-r--r--camel/camel-simple-data-wrapper.h71
-rw-r--r--camel/camel-types.h1
-rw-r--r--camel/camel.h1
10 files changed, 254 insertions, 121 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index a78b7fc5f1..9fbb0f6de7 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,3 +1,31 @@
+2000-05-17 Dan Winship <danw@helixcode.com>
+
+ * camel-data-wrapper.c: remove get/set_output_stream operations.
+ They're redundant with write_to_stream, and CamelMimePart and
+ CamelMimeMessage only implement the latter, meaning that trying to
+ get_output_stream on a CamelMimeMessage that was built from pieces
+ rather than being parsed from a stream doesn't work. Anything that
+ uses get_output_stream can be rewritten to use write_to_stream, so
+ we'll standardize on that.
+ (camel_data_wrapper_new): remove this: CamelDataWrapper is
+ supposed to be an abstract class.
+ (write_to_stream): remove default implementation. (Moved to
+ CamelSimpleDataWrapper)
+
+ * camel-simple-data-wrapper.c: resurrect, although it's not really
+ the same thing it was before. A simple data wrapper, which is
+ backed by a CamelStream.
+
+ * camel-mime-part-utils.c
+ (simple_data_wrapper_construct_from_parser): Use
+ construct_from_stream rather than set_output_stream.
+ (camel_mime_part_construct_content_from_parser): Change
+ camel_data_wrapper_new to camel_simple_data_wrapper_new.
+
+ * camel-mime-part.c (camel_mime_part_set_content): Change
+ camel_data_wrapper_new to camel_simple_data_wrapper_new.
+
+
2000-05-17 Darin Adler <darin@eazel.com>
* camel-folder-summary.c: (message_info_load):
diff --git a/camel/Makefile.am b/camel/Makefile.am
index f98325a5a2..a1b672ab13 100644
--- a/camel/Makefile.am
+++ b/camel/Makefile.am
@@ -33,6 +33,7 @@ libcamel_la_SOURCES = \
camel-seekable-substream.c \
camel-service.c \
camel-session.c \
+ camel-simple-data-wrapper.c \
camel-store.c \
camel-stream.c \
camel-stream-buffer.c \
@@ -76,6 +77,7 @@ libcamelinclude_HEADERS = \
camel-seekable-substream.h \
camel-service.h \
camel-session.h \
+ camel-simple-data-wrapper.h \
camel-store.h \
camel-stream.h \
camel-stream-buffer.h \
diff --git a/camel/camel-data-wrapper.c b/camel/camel-data-wrapper.c
index fcd7abb812..61cee59a51 100644
--- a/camel/camel-data-wrapper.c
+++ b/camel/camel-data-wrapper.c
@@ -36,10 +36,6 @@ static CamelObjectClass *parent_class = NULL;
#define CDW_CLASS(so) CAMEL_DATA_WRAPPER_CLASS (GTK_OBJECT (so)->klass)
-static void set_output_stream (CamelDataWrapper *data_wrapper,
- CamelStream *stream);
-static CamelStream *get_output_stream (CamelDataWrapper *data_wrapper);
-
static int construct_from_stream(CamelDataWrapper *, CamelStream *);
static int write_to_stream (CamelDataWrapper *data_wrapper,
CamelStream *stream, CamelException *ex);
@@ -66,9 +62,6 @@ camel_data_wrapper_class_init (CamelDataWrapperClass *camel_data_wrapper_class)
camel_data_wrapper_class->get_mime_type_field = get_mime_type_field;
camel_data_wrapper_class->set_mime_type_field = set_mime_type_field;
- camel_data_wrapper_class->set_output_stream = set_output_stream;
- camel_data_wrapper_class->get_output_stream = get_output_stream;
-
camel_data_wrapper_class->construct_from_stream = construct_from_stream;
/* virtual method overload */
@@ -118,107 +111,16 @@ finalize (GtkObject *object)
if (camel_data_wrapper->mime_type)
gmime_content_field_unref (camel_data_wrapper->mime_type);
- if (camel_data_wrapper->input_stream)
- gtk_object_unref (GTK_OBJECT (camel_data_wrapper->input_stream));
-
- if (camel_data_wrapper->output_stream)
- gtk_object_unref (GTK_OBJECT (camel_data_wrapper->output_stream));
-
GTK_OBJECT_CLASS (parent_class)->finalize (object);
}
-/**
- * camel_data_wrapper_new:
- *
- * Create a new camel data wrapper object.
- *
- * Return value:
- **/
-CamelDataWrapper *
-camel_data_wrapper_new(void)
-{
- return gtk_type_new(camel_data_wrapper_get_type());
-}
-
-
-static void
-set_output_stream (CamelDataWrapper *data_wrapper, CamelStream *stream)
-{
- if (data_wrapper->output_stream)
- gtk_object_unref (GTK_OBJECT (data_wrapper->output_stream));
-
- data_wrapper->output_stream = stream;
- if (stream)
- gtk_object_ref (GTK_OBJECT (stream));
- d(printf("data_wrapper:: set_output_stream(%p)\n", stream));
-}
-
-/**
- * camel_data_wrapper_set_output_stream:
- * @data_wrapper: a data wrapper
- * @stream: a stream that can be read from
- *
- * This is an internal function to be used by implementors of
- * the camel-data-wrapper to set their contents as a stream.
- *
- * The output stream should theoretically be a stream that, if read
- * from, produces the data wrapper's contents. However, while certain
- * pieces of code assume this, nothing enforces it.
- *
- **/
-void
-camel_data_wrapper_set_output_stream (CamelDataWrapper *data_wrapper,
- CamelStream *stream)
-{
- g_return_if_fail (CAMEL_IS_DATA_WRAPPER (data_wrapper));
- g_return_if_fail (CAMEL_IS_STREAM (stream));
-
- CDW_CLASS (data_wrapper)->set_output_stream (data_wrapper, stream);
-}
-
-
-static CamelStream *
-get_output_stream (CamelDataWrapper *data_wrapper)
-{
- d(printf("data_wrapper:: get_output_stream(%p) = %p\n", data_wrapper, data_wrapper->output_stream));
- return data_wrapper->output_stream;
-}
-
-/**
- * camel_data_wrapper_get_output_stream:
- * @data_wrapper: a data wrapper
- *
- * If the data wrapper has contents, this will return a stream representing
- * the data wrappers contents. Currently only the body of a simple
- * mime part may be read in this way, although conceivably a whole
- * mime message or partial mime message could be processed this way.
- *
- * Return value: @data_wrapper's output stream
- **/
-CamelStream *
-camel_data_wrapper_get_output_stream (CamelDataWrapper *data_wrapper)
-{
- g_return_val_if_fail (CAMEL_IS_DATA_WRAPPER (data_wrapper), NULL);
-
- return CDW_CLASS (data_wrapper)->get_output_stream (data_wrapper);
-}
-
-
static int
write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream,
CamelException *ex)
{
- CamelStream *output_stream;
-
- d(printf("data_wrapper::write_to_stream\n"));
-
- output_stream = camel_data_wrapper_get_output_stream (data_wrapper);
- g_return_val_if_fail (CAMEL_IS_STREAM (output_stream), -1);
-
- camel_stream_reset (output_stream, ex);
- if (camel_exception_is_set (ex))
- return -1;
- return camel_stream_write_to_stream (output_stream, stream, ex);
+ g_warning ("CamelDataWrapper::write_to_stream not implemented for "
+ "`%s'", gtk_type_name (GTK_OBJECT_TYPE (data_wrapper)));
+ return -1;
}
/**
@@ -246,11 +148,11 @@ camel_data_wrapper_write_to_stream (CamelDataWrapper *data_wrapper,
}
static int
-construct_from_stream(CamelDataWrapper *data_wrapper,
- CamelStream *stream)
+construct_from_stream (CamelDataWrapper *data_wrapper, CamelStream *stream)
{
- camel_data_wrapper_set_output_stream (data_wrapper, stream);
- return 0;
+ g_warning ("CamelDataWrapper::construct_from_stream not implemented "
+ "for `%s'", gtk_type_name (GTK_OBJECT_TYPE (data_wrapper)));
+ return -1;
}
/**
@@ -262,6 +164,8 @@ construct_from_stream(CamelDataWrapper *data_wrapper,
* supplied @stream.
*
* This could fail, but you can't know if it did.
+ *
+ * Return value: Who knows. FIXME
**/
int
camel_data_wrapper_construct_from_stream (CamelDataWrapper *data_wrapper,
diff --git a/camel/camel-data-wrapper.h b/camel/camel-data-wrapper.h
index da44a60233..d6e9e754cf 100644
--- a/camel/camel-data-wrapper.h
+++ b/camel/camel-data-wrapper.h
@@ -1,5 +1,5 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* camelDataWrapper.h : Abstract class for a data wrapper */
+/* camel-data-wrapper.h : Abstract class for a data wrapper */
/*
*
@@ -47,9 +47,6 @@ struct _CamelDataWrapper
{
CamelObject parent_object;
- CamelStream *input_stream;
- CamelStream *output_stream;
-
GMimeContentField *mime_type;
};
@@ -85,8 +82,6 @@ GtkType camel_data_wrapper_get_type (void);
/* public methods */
-CamelDataWrapper *camel_data_wrapper_new (void);
-
int camel_data_wrapper_write_to_stream (CamelDataWrapper *data_wrapper,
CamelStream *stream,
CamelException *ex);
@@ -97,10 +92,6 @@ GMimeContentField * camel_data_wrapper_get_mime_type_field (CamelDataWrappe
void camel_data_wrapper_set_mime_type_field (CamelDataWrapper *data_wrapper,
GMimeContentField *mime_type);
-void camel_data_wrapper_set_output_stream (CamelDataWrapper *data_wrapper,
- CamelStream *stream);
-CamelStream * camel_data_wrapper_get_output_stream (CamelDataWrapper *data_wrapper);
-
int camel_data_wrapper_construct_from_stream (CamelDataWrapper *data_wrapper,
CamelStream *stream);
diff --git a/camel/camel-mime-part-utils.c b/camel/camel-mime-part-utils.c
index fc11665623..e361335392 100644
--- a/camel/camel-mime-part-utils.c
+++ b/camel/camel-mime-part-utils.c
@@ -125,7 +125,7 @@ simple_data_wrapper_construct_from_parser(CamelDataWrapper *dw, CamelMimeParser
CamelStream *mem;
d(printf("Small message part, kept in memory!\n"));
mem = camel_stream_mem_new_with_byte_array(buffer);
- camel_data_wrapper_set_output_stream (dw, mem);
+ camel_data_wrapper_construct_from_stream (dw, mem);
gtk_object_unref ((GtkObject *)mem);
} else {
CamelStream *sub;
@@ -145,10 +145,10 @@ simple_data_wrapper_construct_from_parser(CamelDataWrapper *dw, CamelMimeParser
camel_mime_filter_reset(fch);
camel_stream_filter_add(filter, fch);
}
- camel_data_wrapper_set_output_stream (dw, (CamelStream *)filter);
+ camel_data_wrapper_construct_from_stream (dw, (CamelStream *)filter);
gtk_object_unref ((GtkObject *)filter);
} else {
- camel_data_wrapper_set_output_stream (dw, sub);
+ camel_data_wrapper_construct_from_stream (dw, sub);
}
gtk_object_unref ((GtkObject *)sub);
}
@@ -176,7 +176,7 @@ camel_mime_part_construct_content_from_parser(CamelMimePart *dw, CamelMimeParser
switch (camel_mime_parser_state(mp)) {
case HSCAN_HEADER:
d(printf("Creating body part\n"));
- content = camel_data_wrapper_new();
+ content = camel_simple_data_wrapper_new();
simple_data_wrapper_construct_from_parser(content, mp);
break;
case HSCAN_MESSAGE:
diff --git a/camel/camel-mime-part.c b/camel/camel-mime-part.c
index af5b5cf6aa..e79edaa3dd 100644
--- a/camel/camel-mime-part.c
+++ b/camel/camel-mime-part.c
@@ -692,7 +692,7 @@ camel_mime_part_set_content (CamelMimePart *camel_mime_part,
CamelDataWrapper *dw;
CamelStream *stream;
- dw = camel_data_wrapper_new ();
+ dw = camel_simple_data_wrapper_new ();
camel_data_wrapper_set_mime_type (dw, type);
stream = camel_stream_mem_new_with_buffer (data, length);
camel_data_wrapper_construct_from_stream (dw, stream);
diff --git a/camel/camel-simple-data-wrapper.c b/camel/camel-simple-data-wrapper.c
new file mode 100644
index 0000000000..cc6bbc6771
--- /dev/null
+++ b/camel/camel-simple-data-wrapper.c
@@ -0,0 +1,137 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* camel-simple-data-wrapper.c: a simple stream-backed data wrapper */
+
+/*
+ * Author:
+ * Dan Winship <danw@helixcode.com>
+ *
+ * Copyright 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 "camel-simple-data-wrapper.h"
+#include "camel-exception.h"
+
+#include <errno.h>
+
+static CamelDataWrapperClass *parent_class = NULL;
+
+/* Returns the class for a CamelDataWrapper */
+#define CDW_CLASS(so) CAMEL_DATA_WRAPPER_CLASS (GTK_OBJECT (so)->klass)
+
+
+static int construct_from_stream (CamelDataWrapper *, CamelStream *);
+static int write_to_stream (CamelDataWrapper *data_wrapper,
+ CamelStream *stream, CamelException *ex);
+
+static void finalize (GtkObject *object);
+
+static void
+camel_simple_data_wrapper_class_init (CamelSimpleDataWrapperClass *camel_simple_data_wrapper_class)
+{
+ GtkObjectClass *gtk_object_class =
+ GTK_OBJECT_CLASS (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 overload */
+ camel_data_wrapper_class->write_to_stream = write_to_stream;
+ camel_data_wrapper_class->construct_from_stream =
+ construct_from_stream;
+
+ gtk_object_class->finalize = finalize;
+}
+
+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 =
+ {
+ "CamelSimpleDataWrapper",
+ sizeof (CamelSimpleDataWrapper),
+ sizeof (CamelSimpleDataWrapperClass),
+ (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
+finalize (GtkObject *object)
+{
+ CamelSimpleDataWrapper *simple_data_wrapper =
+ CAMEL_SIMPLE_DATA_WRAPPER (object);
+
+ if (simple_data_wrapper->content)
+ gtk_object_unref (GTK_OBJECT (simple_data_wrapper->content));
+
+ GTK_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+/**
+ * camel_simple_data_wrapper_new:
+ *
+ * Create a new camel data wrapper object.
+ *
+ * Return value:
+ **/
+CamelDataWrapper *
+camel_simple_data_wrapper_new (void)
+{
+ return gtk_type_new (camel_simple_data_wrapper_get_type ());
+}
+
+
+static int
+construct_from_stream (CamelDataWrapper *wrapper, CamelStream *stream)
+{
+ CamelSimpleDataWrapper *simple_data_wrapper =
+ CAMEL_SIMPLE_DATA_WRAPPER (wrapper);
+
+ simple_data_wrapper->content = stream;
+ gtk_object_ref (GTK_OBJECT (stream));
+ return 0;
+}
+
+
+static int
+write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream,
+ CamelException *ex)
+{
+ CamelSimpleDataWrapper *simple_data_wrapper =
+ CAMEL_SIMPLE_DATA_WRAPPER (data_wrapper);
+
+ camel_stream_reset (simple_data_wrapper->content, ex);
+ if (camel_exception_is_set (ex))
+ return -1;
+ return camel_stream_write_to_stream (simple_data_wrapper->content,
+ stream, ex);
+}
diff --git a/camel/camel-simple-data-wrapper.h b/camel/camel-simple-data-wrapper.h
new file mode 100644
index 0000000000..5346cd969d
--- /dev/null
+++ b/camel/camel-simple-data-wrapper.h
@@ -0,0 +1,71 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* camel-simple-data-wrapper.h: a simple stream-backed data wrapper */
+
+/*
+ * Author:
+ * Dan Winship <danw@helixcode.com>
+ *
+ * Copyright 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
+ */
+
+
+#ifndef CAMEL_SIMPLE_DATA_WRAPPER_H
+#define CAMEL_SIMPLE_DATA_WRAPPER_H 1
+
+
+#ifdef __cplusplus
+extern "C" {
+#pragma }
+#endif /* __cplusplus }*/
+
+#include <camel/camel-data-wrapper.h>
+
+#define CAMEL_SIMPLE_DATA_WRAPPER_TYPE (camel_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 CAMEL_IS_SIMPLE_DATA_WRAPPER(o) (GTK_CHECK_TYPE((o), CAMEL_SIMPLE_DATA_WRAPPER_TYPE))
+
+
+struct _CamelSimpleDataWrapper
+{
+ CamelDataWrapper parent_object;
+
+ CamelStream *content;
+};
+
+
+typedef struct {
+ CamelDataWrapperClass parent_class;
+
+} CamelSimpleDataWrapperClass;
+
+
+
+/* Standard Gtk function */
+GtkType camel_simple_data_wrapper_get_type (void);
+
+
+/* convenience functions */
+CamelDataWrapper *camel_simple_data_wrapper_new (void);
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* CAMEL_SIMPLE_DATA_WRAPPER_H */
diff --git a/camel/camel-types.h b/camel/camel-types.h
index c8bbc874b4..706440b64d 100644
--- a/camel/camel-types.h
+++ b/camel/camel-types.h
@@ -51,7 +51,6 @@ typedef struct _CamelSeekableSubstream CamelSeekableSubstream;
typedef struct _CamelService CamelService;
typedef struct _CamelSession CamelSession;
typedef struct _CamelSimpleDataWrapper CamelSimpleDataWrapper;
-typedef struct _CamelSimpleDataWrapperStream CamelSimpleDataWrapperStream;
typedef struct _CamelStore CamelStore;
typedef struct _CamelStream CamelStream;
typedef struct _CamelStreamBuffer CamelStreamBuffer;
diff --git a/camel/camel.h b/camel/camel.h
index d3a65b1312..ac314ac656 100644
--- a/camel/camel.h
+++ b/camel/camel.h
@@ -54,6 +54,7 @@ extern "C" {
#include <camel/camel-seekable-substream.h>
#include <camel/camel-service.h>
#include <camel/camel-session.h>
+#include <camel/camel-simple-data-wrapper.h>
#include <camel/camel-store.h>
#include <camel/camel-stream-buffer.h>
#include <camel/camel-stream-filter.h>