From bdc34487d7041757b5644103fcd2aad389d399c4 Mon Sep 17 00:00:00 2001 From: bertrand Date: Tue, 11 May 1999 21:20:28 +0000 Subject: overload wrapper class method. (_write_to_file): start to write some text 1999-05-11 bertrand * camel/camel-mime-part.c (_write_to_file): overload wrapper class method. (_write_to_file): start to write some text in file. svn path=/trunk/; revision=904 --- camel/Makefile.am | 2 ++ camel/camel-data-wrapper.h | 2 ++ camel/camel-mime-part.c | 36 +++++++++++++++++++++++++++++++++++- camel/camel-mime-part.h | 1 + camel/camel-mime-utils.c | 36 ++++++++++++++++++++++++++++++++++++ camel/camel-mime-utils.h | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 122 insertions(+), 1 deletion(-) create mode 100644 camel/camel-mime-utils.c create mode 100644 camel/camel-mime-utils.h (limited to 'camel') diff --git a/camel/Makefile.am b/camel/Makefile.am index a67ccbd766..bf82c40452 100644 --- a/camel/Makefile.am +++ b/camel/Makefile.am @@ -16,6 +16,7 @@ libcamel_la_SOURCES = \ camel-data-wrapper.c \ camel-folder.c \ camel-mime-part.c \ + camel-mime-utils.c \ camel-provider.c \ camel-service.c \ camel-session.c \ @@ -28,6 +29,7 @@ libcamelinclude_HEADERS = \ camel-data-wrapper.h \ camel-folder.h \ camel-mime-part.h \ + camel-mime-utils.c \ camel-provider.h \ camel-service.h \ camel-session.h \ diff --git a/camel/camel-data-wrapper.h b/camel/camel-data-wrapper.h index e6b0b2a18a..a4ec0220e2 100644 --- a/camel/camel-data-wrapper.h +++ b/camel/camel-data-wrapper.h @@ -46,6 +46,8 @@ extern "C" { typedef struct { GtkObject parent_object; + + GString *mime_type; } CamelDataWrapper; diff --git a/camel/camel-mime-part.c b/camel/camel-mime-part.c index 5bcd99332f..3427dccf8f 100644 --- a/camel/camel-mime-part.c +++ b/camel/camel-mime-part.c @@ -25,6 +25,8 @@ */ #include "camel-mime-part.h" +#include + static CamelDataWrapperClass *parent_class=NULL; @@ -51,6 +53,8 @@ static GList *_get_content_languages (CamelMimePart *mime_part); static void _set_header_lines (CamelMimePart *mime_part, GList *header_lines); static GList *_get_header_lines (CamelMimePart *mime_part); +static CamelDataWrapper *_get_content_object(CamelMimePart *mime_part); +static void _write_to_file(CamelDataWrapper *data_wrapper, FILE *file); @@ -58,6 +62,7 @@ static GList *_get_header_lines (CamelMimePart *mime_part); static void camel_mime_part_class_init (CamelMimePartClass *camel_mime_part_class) { + CamelDataWrapperClass *camel_data_wrapper_class = CAMEL_DATA_WRAPPER_CLASS (camel_mime_part_class); parent_class = gtk_type_class (camel_data_wrapper_get_type ()); /* virtual method definition */ @@ -81,8 +86,10 @@ camel_mime_part_class_init (CamelMimePartClass *camel_mime_part_class) camel_mime_part_class->set_header_lines=_set_header_lines; camel_mime_part_class->get_header_lines=_get_header_lines; - + camel_mime_part_class->get_content_object = _get_content_object; + /* virtual method overload */ + camel_data_wrapper_class->write_to_file = _write_to_file; } @@ -421,3 +428,30 @@ camel_mime_part_get_header_lines (CamelMimePart *mime_part) + +static CamelDataWrapper * +_get_content_object(CamelMimePart *mime_part) +{ + return mime_part->content; + +} +CamelDataWrapper * +camel_mime_part_get_content_object(CamelMimePart *mime_part) +{ + return CMP_CLASS(mime_part)->get_content_object (mime_part); +} + +#ifdef WHPTF +#warning : WHPTF is already defined !!!!!! +#endif +#define WHPTF camel_mime_utils_write_header_pair_to_file + +static void +_write_to_file(CamelDataWrapper *data_wrapper, FILE *file) +{ + CamelMimePart *mp = CAMEL_MIME_PART (data_wrapper); + WHPTF (file, "Content-type", CAMEL_DATA_WRAPPER(mp)->mime_type); + WHPTF (file, "Content-Description", mp->description); + +} + diff --git a/camel/camel-mime-part.h b/camel/camel-mime-part.h index ecf1928691..8f067fd403 100644 --- a/camel/camel-mime-part.h +++ b/camel/camel-mime-part.h @@ -87,6 +87,7 @@ typedef struct { void (*set_header_lines) (CamelMimePart *mime_part, GList *header_lines); GList * (*get_header_lines) (CamelMimePart *mime_part); + CamelDataWrapper * (*get_content_object) (CamelMimePart *mime_part); } CamelMimePartClass; diff --git a/camel/camel-mime-utils.c b/camel/camel-mime-utils.c new file mode 100644 index 0000000000..fde9202730 --- /dev/null +++ b/camel/camel-mime-utils.c @@ -0,0 +1,36 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* mime-utils.c : misc utilities for mime */ + +/* + * + * Copyright (C) 1999 Bertrand Guiheneuf . + * + * 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 "camel-mime-utils.h" +void +camel_mime_utils_write_header_pair_to_file(FILE* file, gchar* name, GString *value) +{ + g_assert(name); + + if ((value) && (value->str)) + fprintf(file, "%s: %s\n", name, value->str); +} + + diff --git a/camel/camel-mime-utils.h b/camel/camel-mime-utils.h new file mode 100644 index 0000000000..acc86de26e --- /dev/null +++ b/camel/camel-mime-utils.h @@ -0,0 +1,46 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* mime-utils.h : misc utilities for mime */ + +/* + * + * Copyright (C) 1999 Bertrand Guiheneuf . + * + * 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_MIME_UTILS_H +#define CAMEL_MIME_UTILS_H 1 + + +#ifdef __cplusplus +extern "C" { +#pragma } +#endif /* __cplusplus }*/ + +#include +#include + +void camel_mime_utils_write_header_pair_to_file(FILE* file, gchar* name, GString *value); + + + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* CAMEL_MIME_UTILS_H */ -- cgit v1.2.3