aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-medium.c
diff options
context:
space:
mode:
authorbertrand <Bertrand.Guiheneuf@aful.org>1999-08-25 05:01:10 +0800
committerBertrand Guiheneuf <bertrand@src.gnome.org>1999-08-25 05:01:10 +0800
commit6881fd1bf710f0ce0bd55f9975855bb23622077a (patch)
treeb9a41edaab9742dbd6de39cf868b86905e6d26a7 /camel/camel-medium.c
parent86159a122623b0ef936f60e5040981bf0ab5d74e (diff)
downloadgsoc2013-evolution-6881fd1bf710f0ce0bd55f9975855bb23622077a.tar
gsoc2013-evolution-6881fd1bf710f0ce0bd55f9975855bb23622077a.tar.gz
gsoc2013-evolution-6881fd1bf710f0ce0bd55f9975855bb23622077a.tar.bz2
gsoc2013-evolution-6881fd1bf710f0ce0bd55f9975855bb23622077a.tar.lz
gsoc2013-evolution-6881fd1bf710f0ce0bd55f9975855bb23622077a.tar.xz
gsoc2013-evolution-6881fd1bf710f0ce0bd55f9975855bb23622077a.tar.zst
gsoc2013-evolution-6881fd1bf710f0ce0bd55f9975855bb23622077a.zip
new class. Will handle all sort of information media (Mime mail messages,
1999-08-24 bertrand <Bertrand.Guiheneuf@aful.org> * camel/camel-medium.c (camel_medium_class_init): new class. Will handle all sort of information media (Mime mail messages, Lotus Notes mail messages, postit notes, faxes, who knows .... :) CamelMimePart will inherit from it. * camel/camel-mime-part.c (_set_disposition): (_set_description): description and disposition parameters are now const. * camel/gmime-content-field.c (gmime_content_field_free): added assertion code. * camel/providers/MH/camel-mh-folder.c (_get_message): uses buffered stream. * camel/camel-stream-buffered-fs.c: new stream to accelerate file ops. Thanks to jwz, I've decided to add a level of abstraction to Camel. In the future, it should be able to handle other mail systems, but also non-mail information vehicles. Enough for today. Roller time! svn path=/trunk/; revision=1140
Diffstat (limited to 'camel/camel-medium.c')
-rw-r--r--camel/camel-medium.c197
1 files changed, 197 insertions, 0 deletions
diff --git a/camel/camel-medium.c b/camel/camel-medium.c
new file mode 100644
index 0000000000..8414432a07
--- /dev/null
+++ b/camel/camel-medium.c
@@ -0,0 +1,197 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* camelMedium.c : Abstract class for a medium */
+
+
+/*
+ *
+ * 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 <config.h>
+#include "camel-medium.h"
+#include <stdio.h>
+#include "gmime-content-field.h"
+#include "string-utils.h"
+#include "camel-log.h"
+#include "gmime-utils.h"
+#include "camel-simple-data-wrapper.h"
+
+
+
+
+
+static CamelDataWrapperClass *parent_class=NULL;
+
+/* Returns the class for a CamelMedium */
+#define CMP_CLASS(so) CAMEL_MEDIUM_CLASS (GTK_OBJECT(so)->klass)
+
+static void _add_header (CamelMedium *medium, gchar *header_name, gchar *header_value);
+static void _remove_header (CamelMedium *medium, const gchar *header_name);
+static const gchar *_get_header (CamelMedium *medium, const gchar *header_name);
+
+
+static void _finalize (GtkObject *object);
+
+static void
+camel_medium_class_init (CamelMediumClass *camel_medium_class)
+{
+ CamelDataWrapperClass *camel_data_wrapper_class = CAMEL_DATA_WRAPPER_CLASS (camel_medium_class);
+ GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (camel_data_wrapper_class);
+
+ parent_class = gtk_type_class (camel_data_wrapper_get_type ());
+
+ /* virtual method definition */
+ camel_medium_class->add_header = _add_header;
+ camel_medium_class->remove_header = _remove_header;
+ camel_medium_class->get_header = _get_header;
+
+
+
+ /* 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;
+}
+
+static void
+camel_medium_init (gpointer object, gpointer klass)
+{
+ CamelMedium *camel_medium = CAMEL_MEDIUM (object);
+
+ camel_medium->headers = g_hash_table_new (g_str_hash, g_str_equal);
+}
+
+
+
+
+GtkType
+camel_medium_get_type (void)
+{
+ static GtkType camel_medium_type = 0;
+
+ if (!camel_medium_type) {
+ GtkTypeInfo camel_medium_info =
+ {
+ "CamelMedium",
+ sizeof (CamelMedium),
+ sizeof (CamelMediumClass),
+ (GtkClassInitFunc) camel_medium_class_init,
+ (GtkObjectInitFunc) camel_medium_init,
+ /* reserved_1 */ NULL,
+ /* reserved_2 */ NULL,
+ (GtkClassInitFunc) NULL,
+ };
+
+ camel_medium_type = gtk_type_unique (camel_data_wrapper_get_type (), &camel_medium_info);
+ }
+
+ return camel_medium_type;
+}
+
+
+static void
+_finalize (GtkObject *object)
+{
+ CamelMedium *medium = CAMEL_MEDIUM (object);
+
+
+ CAMEL_LOG_FULL_DEBUG ("Entering CamelMedium::finalize\n");
+
+ if (medium->headers) {
+ g_hash_table_destroy (medium->headers);
+ }
+
+ GTK_OBJECT_CLASS (parent_class)->finalize (object);
+ CAMEL_LOG_FULL_DEBUG ("Leaving CamelMedium::finalize\n");
+}
+
+
+static void
+_add_header (CamelMedium *medium, gchar *header_name, gchar *header_value)
+{
+ gboolean header_exists;
+ gchar *old_header_name;
+ gchar *old_header_value;
+
+
+ header_exists = g_hash_table_lookup_extended (medium->headers, header_name,
+ (gpointer *) &old_header_name,
+ (gpointer *) &old_header_value);
+ if (header_exists) {
+ g_free (old_header_name);
+ g_free (old_header_value);
+ }
+
+ g_hash_table_insert (medium->headers, header_name, header_value);
+}
+
+
+void
+camel_medium_add_header (CamelMedium *medium, gchar *header_name, gchar *header_value)
+{
+ CMP_CLASS(medium)->add_header(medium, header_name, header_value);
+}
+
+
+
+static void
+_remove_header (CamelMedium *medium, const gchar *header_name)
+{
+
+ gboolean header_exists;
+ gchar *old_header_name;
+ gchar *old_header_value;
+
+ header_exists = g_hash_table_lookup_extended (medium->headers, header_name,
+ (gpointer *) &old_header_name,
+ (gpointer *) &old_header_value);
+ if (header_exists) {
+ g_free (old_header_name);
+ g_free (old_header_value);
+ }
+
+ g_hash_table_remove (medium->headers, header_name);
+
+}
+
+void
+camel_medium_remove_header (CamelMedium *medium, const gchar *header_name)
+{
+ CMP_CLASS(medium)->remove_header(medium, header_name);
+}
+
+
+
+static const gchar *
+_get_header (CamelMedium *medium, const gchar *header_name)
+{
+
+ gchar *old_header_name;
+ gchar *old_header_value;
+ gchar *header_value;
+
+ header_value = (gchar *)g_hash_table_lookup (medium->headers, header_name);
+ return header_value;
+}
+
+const gchar *
+camel_medium_get_header (CamelMedium *medium, const gchar *header_name)
+{
+ return CMP_CLASS(medium)->get_header (medium, header_name);
+}
+