From 988d4b6d0e60d1bfb375db9e22cd46e35cdb1757 Mon Sep 17 00:00:00 2001 From: nobody Date: Mon, 2 Aug 1999 04:57:30 +0000 Subject: This commit was manufactured by cvs2svn to create tag 'GNOME_PYTHON_1_0_4'. svn path=/tags/GNOME_PYTHON_1_0_4/; revision=1061 --- camel/.cvsignore | 7 - camel/Makefile.am | 66 --- camel/README | 57 --- camel/camel-data-wrapper.c | 218 ---------- camel/camel-data-wrapper.h | 87 ---- camel/camel-folder.c | 672 ----------------------------- camel/camel-folder.h | 126 ------ camel/camel-log.c | 42 -- camel/camel-log.h | 75 ---- camel/camel-mime-body-part.c | 123 ------ camel/camel-mime-body-part.h | 82 ---- camel/camel-mime-message.c | 632 --------------------------- camel/camel-mime-message.h | 136 ------ camel/camel-mime-part.c | 806 ----------------------------------- camel/camel-mime-part.h | 141 ------ camel/camel-multipart.c | 466 -------------------- camel/camel-multipart.h | 105 ----- camel/camel-provider.c | 29 -- camel/camel-provider.h | 54 --- camel/camel-service.c | 277 ------------ camel/camel-service.h | 82 ---- camel/camel-session.c | 131 ------ camel/camel-session.h | 82 ---- camel/camel-simple-data-wrapper.c | 181 -------- camel/camel-simple-data-wrapper.h | 79 ---- camel/camel-store.c | 221 ---------- camel/camel-store.h | 85 ---- camel/camel-stream-fs.c | 276 ------------ camel/camel-stream-fs.h | 80 ---- camel/camel-stream-mem.c | 235 ---------- camel/camel-stream-mem.h | 80 ---- camel/camel-stream.c | 223 ---------- camel/camel-stream.h | 93 ---- camel/camel.c | 30 -- camel/camel.h | 43 -- camel/data-wrapper-repository.c | 124 ------ camel/data-wrapper-repository.h | 53 --- camel/gmime-content-field.c | 324 -------------- camel/gmime-content-field.h | 59 --- camel/gmime-utils.c | 243 ----------- camel/gmime-utils.h | 51 --- camel/gstring-util.c | 340 --------------- camel/gstring-util.h | 74 ---- camel/providers/.cvsignore | 2 - camel/providers/MH/.cvsignore | 6 - camel/providers/MH/Makefile.am | 26 -- camel/providers/MH/camel-mh-folder.c | 115 ----- camel/providers/MH/camel-mh-folder.h | 70 --- camel/providers/MH/camel-mh-store.c | 89 ---- camel/providers/MH/camel-mh-store.h | 71 --- camel/providers/Makefile.am | 3 - camel/string-utils.c | 251 ----------- camel/string-utils.h | 67 --- camel/url-util.c | 398 ----------------- camel/url-util.h | 53 --- 55 files changed, 8541 deletions(-) delete mode 100644 camel/.cvsignore delete mode 100644 camel/Makefile.am delete mode 100644 camel/README delete mode 100644 camel/camel-data-wrapper.c delete mode 100644 camel/camel-data-wrapper.h delete mode 100644 camel/camel-folder.c delete mode 100644 camel/camel-folder.h delete mode 100644 camel/camel-log.c delete mode 100644 camel/camel-log.h delete mode 100644 camel/camel-mime-body-part.c delete mode 100644 camel/camel-mime-body-part.h delete mode 100644 camel/camel-mime-message.c delete mode 100644 camel/camel-mime-message.h delete mode 100644 camel/camel-mime-part.c delete mode 100644 camel/camel-mime-part.h delete mode 100644 camel/camel-multipart.c delete mode 100644 camel/camel-multipart.h delete mode 100644 camel/camel-provider.c delete mode 100644 camel/camel-provider.h delete mode 100644 camel/camel-service.c delete mode 100644 camel/camel-service.h delete mode 100644 camel/camel-session.c delete mode 100644 camel/camel-session.h delete mode 100644 camel/camel-simple-data-wrapper.c delete mode 100644 camel/camel-simple-data-wrapper.h delete mode 100644 camel/camel-store.c delete mode 100644 camel/camel-store.h delete mode 100644 camel/camel-stream-fs.c delete mode 100644 camel/camel-stream-fs.h delete mode 100644 camel/camel-stream-mem.c delete mode 100644 camel/camel-stream-mem.h delete mode 100644 camel/camel-stream.c delete mode 100644 camel/camel-stream.h delete mode 100644 camel/camel.c delete mode 100644 camel/camel.h delete mode 100644 camel/data-wrapper-repository.c delete mode 100644 camel/data-wrapper-repository.h delete mode 100644 camel/gmime-content-field.c delete mode 100644 camel/gmime-content-field.h delete mode 100644 camel/gmime-utils.c delete mode 100644 camel/gmime-utils.h delete mode 100644 camel/gstring-util.c delete mode 100644 camel/gstring-util.h delete mode 100644 camel/providers/.cvsignore delete mode 100644 camel/providers/MH/.cvsignore delete mode 100644 camel/providers/MH/Makefile.am delete mode 100644 camel/providers/MH/camel-mh-folder.c delete mode 100644 camel/providers/MH/camel-mh-folder.h delete mode 100644 camel/providers/MH/camel-mh-store.c delete mode 100644 camel/providers/MH/camel-mh-store.h delete mode 100644 camel/providers/Makefile.am delete mode 100644 camel/string-utils.c delete mode 100644 camel/string-utils.h delete mode 100644 camel/url-util.c delete mode 100644 camel/url-util.h (limited to 'camel') diff --git a/camel/.cvsignore b/camel/.cvsignore deleted file mode 100644 index fd6b811c68..0000000000 --- a/camel/.cvsignore +++ /dev/null @@ -1,7 +0,0 @@ -.deps -Makefile -Makefile.in -.libs -.deps -*.lo -*.la diff --git a/camel/Makefile.am b/camel/Makefile.am deleted file mode 100644 index fc3f155726..0000000000 --- a/camel/Makefile.am +++ /dev/null @@ -1,66 +0,0 @@ -## Process this file with automake to produce Makefile.in - -SUBDIRS = providers - -libcamelincludedir = $(includedir)/camel - - -lib_LTLIBRARIES = libcamel.la - -INCLUDES = -I.. -I$(srcdir)/.. -I$(includedir) \ - -I$(top_srcdir)/intl \ - $(GTK_INCLUDEDIR) - -libcamel_la_SOURCES = \ - camel.c \ - camel-log.c \ - camel-data-wrapper.c \ - camel-simple-data-wrapper.c \ - camel-folder.c \ - camel-mime-body-part.c \ - camel-mime-message.c \ - camel-mime-part.c \ - camel-multipart.c \ - camel-provider.c \ - camel-service.c \ - camel-session.c \ - camel-store.c \ - camel-stream.c \ - camel-stream-fs.c \ - camel-stream-mem.c \ - data-wrapper-repository.c \ - gmime-content-field.c \ - gmime-utils.c \ - gstring-util.c \ - string-utils.c \ - url-util.c - -libcamelinclude_HEADERS = \ - camel.h \ - camel-log.h \ - camel-data-wrapper.h \ - camel-simple-data-wrapper.h \ - camel-folder.h \ - camel-mime-body-part.h \ - camel-mime-message.h \ - camel-mime-part.h \ - camel-multipart.h \ - camel-provider.h \ - camel-service.h \ - camel-session.h \ - camel-store.h \ - camel-stream.h \ - camel-stream-fs.h \ - camel-stream-mem.h \ - data-wrapper-repository.h \ - gmime-content-field.h \ - gmime-utils.h \ - gstring-util.h \ - string-utils.h \ - url-util.h - - -libcamel_la_LDFLAGS = -version-info 0:0:0 -rpath $(libdir) - - -EXTRA_DIST = README diff --git a/camel/README b/camel/README deleted file mode 100644 index 44f93fa6d8..0000000000 --- a/camel/README +++ /dev/null @@ -1,57 +0,0 @@ - - CAMEL - - - A generic Messaging Library - - - ---- - - -Introduction: -------------- - -Camel will be a generic messaging library. It will evntually support -the standard messaging system for receiving and sending messages. -It aims at being the backend for the future gnome-mailer system. - -The name "camel" stands for ... nothing. Open area of developpement there. -You know, that "bazaar" thing. Maybe could we organize a big contest on -gnome-list to find the best signification :) - -Camel draws heacily from JavaMail and the IMAP4rev1 RFC. -people wanting to hack on a provider are recommended to read the JavaMail -API specification but CMC and MAPI are of interest too. - -Please, before starting anything, wait for me to finish the abstract classes. -Some parts are not definitive yet. - - -Organization: -------------- - -The library is roughly a set of abstract classes, some kind of generic -"interfaces" (idl interfaces, not java interfaces ). - -Particular implementations are called providers. - -Here are the basic objects: - -* CamelService : an abstract class representing an access to a server. -Handles the connection and authentication to any server. - -* CamelStore (CamelService): A hierarchy of folders on a server. - -* CamelFolder : An object containing messages. A folder is always associated -to a store. - -* CamelMessage : An object contained in folders. Is defined by a set of -attribute and a content. (Attributes are generally: The date it was received, -the sender address, .....) - -* CamelTransport (CamelService): A way to send messages. - -.... -... - - diff --git a/camel/camel-data-wrapper.c b/camel/camel-data-wrapper.c deleted file mode 100644 index b6a9f9ea3e..0000000000 --- a/camel/camel-data-wrapper.c +++ /dev/null @@ -1,218 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camelDataWrapper.c : Abstract class for a data_wrapper */ - -/** THIS IS MOSTLY AN ABSTRACT CLASS THAT SHOULD HAVE BEEN AN - INTERFACE. **/ - -/* - * - * 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 -#include "camel-data-wrapper.h" -#include "camel-log.h" - -static GtkObjectClass *parent_class=NULL; - -/* Returns the class for a CamelDataWrapper */ -#define CDW_CLASS(so) CAMEL_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 _set_mime_type (CamelDataWrapper *data_wrapper, gchar *mime_type); -static gchar *_get_mime_type (CamelDataWrapper *data_wrapper); -static GMimeContentField *_get_mime_type_field (CamelDataWrapper *data_wrapper); -static void _set_mime_type_field (CamelDataWrapper *data_wrapper, GMimeContentField *mime_type); - - -static void -camel_data_wrapper_class_init (CamelDataWrapperClass *camel_data_wrapper_class) -{ - parent_class = gtk_type_class (gtk_object_get_type ()); - - /* virtual method definition */ - 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_mime_type = _set_mime_type; - camel_data_wrapper_class->get_mime_type = _get_mime_type; - camel_data_wrapper_class->get_mime_type_field = _get_mime_type_field; - camel_data_wrapper_class->set_mime_type_field = _set_mime_type_field; - /* virtual method overload */ -} - - - - - -static void -camel_data_wrapper_init (gpointer object, gpointer klass) -{ - CamelDataWrapper *camel_data_wrapper = CAMEL_DATA_WRAPPER (object); - - CAMEL_LOG_FULL_DEBUG ( "camel_data_wrapper_init:: Entering\n"); - camel_data_wrapper->mime_type = gmime_content_field_new (NULL, NULL); - CAMEL_LOG_FULL_DEBUG ( "camel_data_wrapper_init:: Leaving\n"); -} - - - -GtkType -camel_data_wrapper_get_type (void) -{ - static GtkType camel_data_wrapper_type = 0; - - if (!camel_data_wrapper_type) { - GtkTypeInfo camel_data_wrapper_info = - { - "CamelDataWrapper", - sizeof (CamelDataWrapper), - sizeof (CamelDataWrapperClass), - (GtkClassInitFunc) camel_data_wrapper_class_init, - (GtkObjectInitFunc) camel_data_wrapper_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_data_wrapper_type = gtk_type_unique (gtk_object_get_type (), &camel_data_wrapper_info); - } - - return camel_data_wrapper_type; -} - - - -/** - * _write_to_stream: write data content in a byte stream - * @data_wrapper: the data wrapper object - * @stre:m byte stream where data will be written - * - * This method must be overriden by subclasses - * Data must be written in the bytes stream - * in a architecture independant fashion. - * If data is a standard data (for example an jpg image) - * it must be serialized in the strea exactly as it - * would be saved on disk. A simple dump of the stream in - * a file should be sufficient for the data to be - * re-read by a foreign application. - * - **/ -static void -_write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream) -{ - /* nothing */ -} - - -/** - * camel_data_wrapper_write_to_stream: write data in a stream - * @data_wrappewr: the data wrapper object - * @stream: byte stream where data will be written - * - * Write data content in a stream. Data is stored in a machine - * independant format. - * - **/ -void -camel_data_wrapper_write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream) -{ - CAMEL_LOG_FULL_DEBUG ( "camel_data_wrapper_write_to_stream:: Entering\n"); - CDW_CLASS(data_wrapper)->write_to_stream (data_wrapper, stream); - CAMEL_LOG_FULL_DEBUG ( "camel_data_wrapper_write_to_stream:: Leaving\n"); -} - - - - - - -static void -_construct_from_stream (CamelDataWrapper *data_wrapper, CamelStream *stream) -{ - /* nothing */ -} - -void -camel_data_wrapper_construct_from_stream (CamelDataWrapper *data_wrapper, CamelStream *stream) -{ - CAMEL_LOG_FULL_DEBUG ( "camel_data_wrapper_construct_from_stream:: Entering\n"); - CDW_CLASS(data_wrapper)->construct_from_stream (data_wrapper, stream); - CAMEL_LOG_FULL_DEBUG ( "camel_data_wrapper_construct_from_stream:: Leaving\n"); -} - - - -static void -_set_mime_type (CamelDataWrapper *data_wrapper, gchar *mime_type) -{ - CAMEL_LOG_FULL_DEBUG ( "CamelDataWrapper::set_mime_type Entering\n"); - g_assert (mime_type); - gmime_content_field_construct_from_string (data_wrapper->mime_type, mime_type); - CAMEL_LOG_FULL_DEBUG ( "CamelDataWrapper::set_mime_type Leaving\n"); -} - -void -camel_data_wrapper_set_mime_type (CamelDataWrapper *data_wrapper, gchar *mime_type) -{ - CDW_CLASS(data_wrapper)->set_mime_type (data_wrapper, mime_type); -} - -static gchar * -_get_mime_type (CamelDataWrapper *data_wrapper) -{ - gchar *mime_type; - - mime_type = gmime_content_field_get_mime_type (data_wrapper->mime_type); - return mime_type; -} - -gchar * -camel_data_wrapper_get_mime_type (CamelDataWrapper *data_wrapper) -{ - CAMEL_LOG_FULL_DEBUG ( "camel_data_wrapper_get_mime_type:: Entering before returning\n"); - return CDW_CLASS(data_wrapper)->get_mime_type (data_wrapper); -} - - -static GMimeContentField * -_get_mime_type_field (CamelDataWrapper *data_wrapper) -{ - return data_wrapper->mime_type; -} - -GMimeContentField * -camel_data_wrapper_get_mime_type_field (CamelDataWrapper *data_wrapper) -{ - return CDW_CLASS(data_wrapper)->get_mime_type_field (data_wrapper); -} - - -static void -_set_mime_type_field (CamelDataWrapper *data_wrapper, GMimeContentField *mime_type) -{ - if (data_wrapper->mime_type) gmime_content_field_free (data_wrapper->mime_type); - data_wrapper->mime_type = mime_type; -} - -void -camel_data_wrapper_set_mime_type_field (CamelDataWrapper *data_wrapper, GMimeContentField *mime_type) -{ - CDW_CLASS(data_wrapper)->set_mime_type_field (data_wrapper, mime_type); -} - - diff --git a/camel/camel-data-wrapper.h b/camel/camel-data-wrapper.h deleted file mode 100644 index bee6df1c16..0000000000 --- a/camel/camel-data-wrapper.h +++ /dev/null @@ -1,87 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camelDataWrapper.h : Abstract class for a data wrapper */ - -/* - * - * 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_DATA_WRAPPER_H -#define CAMEL_DATA_WRAPPER_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include -#include -#include "gmime-content-field.h" -#include "camel-stream.h" - - - -#define CAMEL_DATA_WRAPPER_TYPE (camel_data_wrapper_get_type ()) -#define CAMEL_DATA_WRAPPER(obj) (GTK_CHECK_CAST((obj), CAMEL_DATA_WRAPPER_TYPE, CamelDataWrapper)) -#define CAMEL_DATA_WRAPPER_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_DATA_WRAPPER_TYPE, CamelDataWrapperClass)) -#define IS_CAMEL_DATA_WRAPPER(o) (GTK_CHECK_TYPE((o), CAMEL_DATA_WRAPPER_TYPE)) - - -typedef struct -{ - GtkObject parent_object; - - GMimeContentField *mime_type; -} CamelDataWrapper; - - - -typedef struct { - GtkObjectClass parent_class; - - /* Virtual methods */ - void (*write_to_stream) (CamelDataWrapper *data_wrapper, CamelStream *stream); - void (*construct_from_stream) (CamelDataWrapper *data_wrapper, CamelStream *stream); - void (*set_mime_type) (CamelDataWrapper *data_wrapper, gchar * mime_type); - gchar * (*get_mime_type) (CamelDataWrapper *data_wrapper); - GMimeContentField * (*get_mime_type_field) (CamelDataWrapper *data_wrapper); - void (*set_mime_type_field) (CamelDataWrapper *data_wrapper, GMimeContentField *mime_type_field); -} CamelDataWrapperClass; - - - -/* Standard Gtk function */ -GtkType camel_data_wrapper_get_type (void); - - -/* public methods */ - -void camel_data_wrapper_write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream); -void camel_data_wrapper_construct_from_stream (CamelDataWrapper *data_wrapper, CamelStream *stream); -void camel_data_wrapper_set_mime_type (CamelDataWrapper *data_wrapper, gchar *mime_type); -static gchar *camel_data_wrapper_get_mime_type (CamelDataWrapper *data_wrapper); -GMimeContentField *camel_data_wrapper_get_mime_type_field (CamelDataWrapper *data_wrapper); -void camel_data_wrapper_set_mime_type_field (CamelDataWrapper *data_wrapper, GMimeContentField *mime_type); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* CAMEL_DATA_WRAPPER_H */ diff --git a/camel/camel-folder.c b/camel/camel-folder.c deleted file mode 100644 index 7211ba63f6..0000000000 --- a/camel/camel-folder.c +++ /dev/null @@ -1,672 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camelFolder.c : Abstract class for an email folder */ - -/* - * - * 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 -#include "camel-folder.h" -#include "string-utils.h" - -static GtkObjectClass *parent_class=NULL; - -/* Returns the class for a CamelFolder */ -#define CF_CLASS(so) CAMEL_FOLDER_CLASS (GTK_OBJECT(so)->klass) - -static void _init_with_store (CamelFolder *folder, CamelStore *parent_store); -static void _open (CamelFolder *folder, CamelFolderOpenMode mode); -static void _close (CamelFolder *folder, gboolean expunge); -static void _set_name (CamelFolder *folder, const gchar *name); -static void _set_full_name (CamelFolder *folder, const gchar *name); -static const gchar *_get_name (CamelFolder *folder); -static const gchar *_get_full_name (CamelFolder *folder); -static gboolean _can_hold_folders (CamelFolder *folder); -static gboolean _can_hold_messages(CamelFolder *folder); -static gboolean _exists (CamelFolder *folder); -static gboolean _is_open (CamelFolder *folder); -static CamelFolder *_get_folder (CamelFolder *folder, const gchar *folder_name); -static gboolean _create (CamelFolder *folder); -static gboolean _delete (CamelFolder *folder, gboolean recurse); -static gboolean _delete_messages (CamelFolder *folder); -static CamelFolder *_get_parent_folder (CamelFolder *folder); -static CamelStore *_get_parent_store (CamelFolder *folder); -static CamelFolderOpenMode _get_mode (CamelFolder *folder); -static GList *_list_subfolders (CamelFolder *folder); -static GList *_expunge (CamelFolder *folder); - -static void -camel_folder_class_init (CamelFolderClass *camel_folder_class) -{ - parent_class = gtk_type_class (gtk_object_get_type ()); - - /* virtual method definition */ - camel_folder_class->init_with_store = _init_with_store; - camel_folder_class->open = _open; - camel_folder_class->close = _close; - camel_folder_class->set_name = _set_name; - camel_folder_class->get_name = _get_name; - camel_folder_class->can_hold_folders = _can_hold_folders; - camel_folder_class->can_hold_messages = _can_hold_messages; - camel_folder_class->exists = _exists; - camel_folder_class->is_open = _is_open; - camel_folder_class->get_folder = _get_folder; - camel_folder_class->create = _create; - camel_folder_class->delete = _delete; - camel_folder_class->delete_messages = _delete_messages; - camel_folder_class->get_parent_folder = _get_parent_folder; - camel_folder_class->get_parent_store = _get_parent_store; - camel_folder_class->get_mode = _get_mode; - camel_folder_class->list_subfolders = _list_subfolders; - camel_folder_class->expunge = _expunge; - /* virtual method overload */ -} - - - - - - - -GtkType -camel_folder_get_type (void) -{ - static GtkType camel_folder_type = 0; - - if (!camel_folder_type) { - GtkTypeInfo camel_folder_info = - { - "CamelFolder", - sizeof (CamelFolder), - sizeof (CamelFolderClass), - (GtkClassInitFunc) camel_folder_class_init, - (GtkObjectInitFunc) NULL, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_folder_type = gtk_type_unique (gtk_object_get_type (), &camel_folder_info); - } - - return camel_folder_type; -} - - - - -/** - * _init_with_store: init the folder by setting its parent store. - * @folder: folder object to initialize - * @parent_store: parent store object of the folder - * - * - **/ -static void -_init_with_store (CamelFolder *folder, CamelStore *parent_store) -{ - g_assert(folder); - g_assert(parent_store); - - folder->parent_store = parent_store; -} - - - - -/** - * _open: Open a folder - * @folder: The folder object - * @mode: open mode (R/W/RW ?) - * - * - **/ -static void -_open( CamelFolder *folder, CamelFolderOpenMode mode) -{ - folder->open_state = FOLDER_OPEN; - folder->open_mode = mode; -} - - -/** - * _close:Close a folder. - * @folder: - * @expunge: if TRUE, the flagged message are deleted. - * - * Put a folder in its closed state, and possibly - * expunge the flagged messages. - **/ -static void -_close (CamelFolder *folder, gboolean expunge) -{ - if (expunge) CF_CLASS(folder)->expunge(folder); - folder->open_state = FOLDER_CLOSE; -} - - - - -/** - * _set_name:set the (short) name of the folder - * @folder: folder - * @name: new name of the folder - * - * set the name of the folder. - * - * - **/ -static void -_set_name(CamelFolder *folder, const gchar *name) -{ - if (folder->name) g_free(folder->name); - folder->name = g_strdup (name); -} - - - -/** - * _set_full_name:set the (full) name of the folder - * @folder: folder - * @name: new name of the folder - * - * set the name of the folder. - * - **/ -static void -_set_full_name (CamelFolder *folder, const gchar *name) -{ - if (folder->full_name) g_free(folder->full_name); - folder->full_name = g_strdup (name); -} - - - - -/** - * _get_name: get the (short) name of the folder - * @folder: - * - * get the name of the folder. The fully qualified name - * can be obtained with the get_full_ame method (not implemented) - * - * Return value: name of the folder - **/ -static const gchar * -_get_name (CamelFolder *folder) -{ - return folder->name; -} - - -/** - * _get_full_name:get the (full) name of the folder - * @folder: folder to get the name - * - * get the name of the folder. - * - * Return value: full name of the folder - **/ -static const gchar * -_get_full_name (CamelFolder *folder) -{ - return folder->full_name; -} - - - -/** - * _can_hold_folders: tests if the folder can contain other folders - * @folder: The folder object - * - * Tests if a folder can contain other folder - * (as for example MH folders) - * - * Return value: - **/ -static gboolean -_can_hold_folders (CamelFolder *folder) -{ - return folder->can_hold_folders; -} - - - - -/** - * _can_hold_messages: tests if the folder can contain messages - * @folder: The folder object - * - * Tests if a folder object can contain messages. - * In the case it can not, it most surely can only - * contain folders (rare). - * - * Return value: true if it can contain messages false otherwise - **/ -static gboolean -_can_hold_messages (CamelFolder *folder) -{ - return folder->can_hold_messages; -} - - - -/** - * _exists: tests if the folder object exists in its parent store. - * @folder: folder object - * - * Test if a folder exists on a store. A folder can be - * created without physically on a store. In that case, - * use CamelFolder::create to create it - * - * Return value: true if the folder exists on the store false otherwise - **/ -static gboolean -_exists (CamelFolder *folder) -{ - return folder->exists_on_store; -} - - - -/** - * _is_open: test if the folder is open - * @folder: The folder object - * - * Tests if a folder is open. If not open it can be opened - * CamelFolder::open - * - * Return value: true if the folder exists, false otherwise - **/ -static gboolean -_is_open (CamelFolder *folder) -{ - return (folder->open_state==FOLDER_OPEN); -} - - - - -/** - * _get_folder: return the (sub)folder object that is specified. - * - * @folder : the folder - * @folder_name: subfolder path. - * - * This method returns a folder objects. This folder - * is necessarily a subfolder of the current folder. - * It is an error to ask a folder begining with the - * folder separator character. - * - * - * Return value: Required folder. NULL if the subfolder object - * could not be obtained - **/ -static CamelFolder * -_get_folder (CamelFolder *folder, const gchar *folder_name) -{ - g_warning("getFolder called on the abstract CamelFolder class\n"); - return NULL; -} - -/** - * _get_folder: return the (sub)folder object that is specified. - * - * @folder : the folder - * @folder_name: subfolder path. - * - * This method returns a folder objects. This folder - * is necessarily a subfolder of the current folder. - * It is an error to ask a folder begining with the - * folder separator character. - * - * Return value: Required folder. NULL if the subfolder object - * could not be obtained - **/ -CamelFolder * -camel_folder_get_folder(CamelFolder *folder, gchar *folder_name) -{ - return (CF_CLASS(folder)->get_folder(folder,folder_name)); -} - - - - -/** - * _create: - * @folder: - * - * this routine handles the recursion mechanism. - * Children classes have to implement the actual - * creation mechanism. They must call this method - * before physically creating the folder in order - * to be sure the parent folder exists. - * - * Return value: - **/ -static gboolean -_create(CamelFolder *folder) -{ - gchar *prefix; - gchar dich_result; - CamelFolder *parent; - gchar sep; - - - g_assert(folder->parent_store); - g_assert(folder->name); - - if (CF_CLASS(folder)->exists (folder)) - return TRUE; - - sep = camel_store_get_separator (folder->parent_store); - if (folder->parent_folder) - camel_folder_create (folder->parent_folder); - else { - if (folder->full_name) { - dich_result = string_dichotomy ( - folder->full_name, sep, &prefix, NULL, - STRING_DICHOTOMY_STRIP_TRAILING | STRING_DICHOTOMY_RIGHT_DIR); - if (dich_result!='o') { - g_warning("I have to handle the case where the path is not OK\n"); - return FALSE; - } else { - parent = camel_store_get_folder (folder->parent_store, prefix); - camel_folder_create (parent); - gtk_object_unref (GTK_OBJECT (parent)); - } - } - } - return TRUE; -} - - -/** - * camel_folder_create: create the folder object on the physical store - * @folder: folder object to create - * - * This routine physically creates the folder object on - * the store. Having created the object does not - * mean the folder physically exists. If it does not - * exists, this routine will create it. - * if the folder full name contains more than one level - * of hierarchy, all folders between the current folder - * and the last folder name will be created if not existing. - * - * Return value: - **/ -gboolean -camel_folder_create(CamelFolder *folder) -{ - return (CF_CLASS(folder)->create(folder)); -} - - - - - -/** - * _delete: delete folder - * @folder: folder to delete - * @recurse: true is subfolders must also be deleted - * - * Delete a folder and its subfolders (if recurse is TRUE). - * The scheme is the following: - * 1) delete all messages in the folder - * 2) if recurse is FALSE, and if there are subfolders - * return FALSE, else delete current folder and retuen TRUE - * if recurse is TRUE, delete subfolders, delete - * current folder and return TRUE - * - * subclasses implementing a protocol with a different - * deletion behaviour must emulate this one or implement - * empty folders deletion and call this routine which - * will do all the works for them. - * Opertions must be done in the folllowing order: - * - call this routine - * - delete empty folder - * - * Return value: true if the folder has been deleted - **/ -static gboolean -_delete (CamelFolder *folder, gboolean recurse) -{ - GList *subfolders=NULL; - GList *sf; - gboolean ok; - - g_assert(folder); - - /* method valid only on closed folders */ - if (folder->open_state != FOLDER_CLOSE) return FALSE; - - /* delete all messages in the folder */ - CF_CLASS(folder)->delete_messages(folder); - - subfolders = CF_CLASS(folder)->list_subfolders(folder); - if (recurse) { /* delete subfolders */ - if (subfolders) { - sf = subfolders; - do { - CF_CLASS(sf->data)->delete(sf->data, TRUE);; - } while (sf = sf->next); - } - } else if (subfolders) return FALSE; - - - return TRUE; -} - - - -/** - * camel_folder_delete: delete a folder - * @folder: folder to delete - * @recurse: TRUE if subfolders must be deleted - * - * Delete a folder. All messages in the folder - * are deleted before the folder is deleted. - * When recurse is true, all subfolders are - * deleted too. When recurse is FALSE and folder - * contains subfolders, all messages are deleted, - * but folder deletion fails. - * - * Return value: TRUE if deletion was successful - **/ -gboolean camel_folder_delete (CamelFolder *folder, gboolean recurse) -{ - return CF_CLASS(folder)->delete(folder, recurse); -} - - - - - -/** - * _delete_messages: delete all messages in the folder - * @folder: - * - * - * - * Return value: - **/ -static gboolean -_delete_messages(CamelFolder *folder) -{ - return TRUE; -} - - -/** - * camel_folder_delete_messages: delete all messages in the folder - * @folder: folder - * - * delete all messages stored in a folder - * - * Return value: TRUE if the messages could be deleted - **/ -gboolean -camel_folder_delete_messages (CamelFolder *folder) -{ - return CF_CLASS(folder)->delete_messages(folder); -} - - - - - - -/** - * _get_parent_folder: return parent folder - * @folder: folder to get the parent - * - * - * - * Return value: - **/ -static CamelFolder * -_get_parent_folder (CamelFolder *folder) -{ - return folder->parent_folder; -} - - -/** - * camel_folder_get_parent_folder:return parent folder - * @folder: folder to get the parent - * - * - * - * Return value: - **/ -CamelFolder * -camel_folder_get_parent_folder (CamelFolder *folder) -{ - return CF_CLASS(folder)->get_parent_folder(folder); -} - - -/** - * _get_parent_store: return parent store - * @folder: folder to get the parent - * - * - * - * Return value: - **/ -static CamelStore * -_get_parent_store (CamelFolder *folder) -{ - return folder->parent_store; -} - - -/** - * camel_folder_get_parent_store:return parent store - * @folder: folder to get the parent - * - * - * - * Return value: - **/ -CamelStore * -camel_folder_get_parent_store (CamelFolder *folder) -{ - return CF_CLASS(folder)->get_parent_store(folder); -} - - - -/** - * _get_mode: return the open mode of a folder - * @folder: - * - * - * - * Return value: open mode of the folder - **/ -static CamelFolderOpenMode -_get_mode(CamelFolder *folder) -{ - return folder->open_mode; -} - - -/** - * camel_folder_get_mode: return the open mode of a folder - * @folder: - * - * - * - * Return value: open mode of the folder - **/ -CamelFolderOpenMode -camel_folder_get_mode(CamelFolder *folder) -{ - return CF_CLASS(folder)->get_mode(folder); -} - - - - -static GList * -_list_subfolders(CamelFolder *folder) -{ - return NULL; -} - - -/** - * camel_folder_list_subfolders: list subfolders in a folder - * @folder: the folder - * - * List subfolders in a folder. - * - * Return value: list of subfolders - **/ -GList * -camel_folder_list_subfolders (CamelFolder *folder) -{ - return CF_CLASS(folder)->list_subfolders(folder); -} - - - - -static GList * -_expunge (CamelFolder *folder) -{ - return NULL; -} - - -/** - * camel_folder_expunge: physically delete messages marked as DELETED - * @folder: the folder - * - * Delete messages which have been marked as deleted. - * - * - * Return value: list of expunged message objects. - **/ -GList * -camel_folder_expunge (CamelFolder *folder) -{ - return CF_CLASS (folder)->expunge (folder); -} - diff --git a/camel/camel-folder.h b/camel/camel-folder.h deleted file mode 100644 index 2e6eaf2f85..0000000000 --- a/camel/camel-folder.h +++ /dev/null @@ -1,126 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camelFolder.h : Abstract class for an email folder */ - -/* - * - * 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_FOLDER_H -#define CAMEL_FOLDER_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include - -typedef struct _CamelFolder CamelFolder; - -#include "camel-store.h" - -#define CAMEL_FOLDER_TYPE (camel_folder_get_type ()) -#define CAMEL_FOLDER(obj) (GTK_CHECK_CAST((obj), CAMEL_FOLDER_TYPE, CamelFolder)) -#define CAMEL_FOLDER_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_FOLDER_TYPE, CamelFolderClass)) -#define IS_CAMEL_FOLDER(o) (GTK_CHECK_TYPE((o), CAMEL_FOLDER_TYPE)) - -typedef enum { - FOLDER_OPEN, - FOLDER_CLOSE -} CamelFolderState; - -typedef enum { - FOLDER_OPEN_UNKNOWN, /* folder open mode is unknown */ - FOLDER_OPEN_READ, /* folder is read only */ - FOLDER_OPEN_READ_WRITE /* folder is read/write */ -} CamelFolderOpenMode; - - - -struct _CamelFolder -{ - GtkObject parent_object; - - GList *message_list; - gboolean can_hold_folders; - gboolean can_hold_messages; - gboolean exists_on_store; - CamelFolderOpenMode open_mode; - CamelFolderState open_state; - gchar *name; - gchar *full_name; - CamelStore *parent_store; - CamelFolder *parent_folder; - -}; - - - -typedef struct { - GtkObjectClass parent_class; - - /* Virtual methods */ - void (*init_with_store) (CamelFolder *folder, CamelStore *parent_store); - void (*open) (CamelFolder *object, CamelFolderOpenMode mode); - void (*close) (CamelFolder *folder, gboolean expunge); - void (*set_name) (CamelFolder *folder, const gchar *name); - void (*set_full_name) (CamelFolder *folder, const gchar *name); - const gchar * (*get_name) (CamelFolder *folder); - const gchar * (*get_full_name) (CamelFolder *folder); - gboolean (*can_hold_folders) (CamelFolder *folder); - gboolean (*can_hold_messages) (CamelFolder *folder); - gboolean (*exists) (CamelFolder *folder); - gboolean (*is_open) (CamelFolder *folder); - CamelFolder * (*get_folder) (CamelFolder *folder, const gchar *folder_name); - gboolean (*create) (CamelFolder *folder); - gboolean (*delete) (CamelFolder *folder, gboolean recurse); - gboolean (*delete_messages) (CamelFolder *folder); - CamelFolder * (*get_parent_folder) (CamelFolder *folder); - CamelStore * (*get_parent_store) (CamelFolder *folder); - CamelFolderOpenMode (*get_mode) (CamelFolder *folder); - GList * (*list_subfolders) (CamelFolder *folder); - GList * (*expunge) (CamelFolder *folder); -} CamelFolderClass; - - - -/* Standard Gtk function */ -GtkType camel_folder_get_type (void); - - -/* public methods */ -CamelFolder *camel_folder_get_folder(CamelFolder *folder, gchar *folder_name); -gboolean camel_folder_create(CamelFolder *folder); -gboolean camel_folder_delete (CamelFolder *folder, gboolean recurse); -gboolean camel_folder_delete_messages (CamelFolder *folder); -CamelFolder *camel_folder_get_parent_folder (CamelFolder *folder); -CamelStore *camel_folder_get_parent_store (CamelFolder *folder); -CamelFolderOpenMode camel_folder_get_mode(CamelFolder *folder); -GList *camel_folder_list_subfolders(CamelFolder *folder); -GList *camel_folder_expunge(CamelFolder *folder); - - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* CAMEL_FOLDER_H */ diff --git a/camel/camel-log.c b/camel/camel-log.c deleted file mode 100644 index 1e6a3cdae6..0000000000 --- a/camel/camel-log.c +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * - * 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 -#include "camel-log.h" - -int camel_debug_level = CAMEL_LOG_LEVEL_FULL_DEBUG; -FILE *camel_log_file_descriptor = NULL; - -void -camel_log(guint level, const gchar *format, ... ) -{ - va_list args; - if (camel_log_file_descriptor == NULL) - camel_log_file_descriptor = stdout; - - if (level<=camel_debug_level) - { - va_start(args, format); - vfprintf(camel_log_file_descriptor, format, args); - va_end (args); - } -} diff --git a/camel/camel-log.h b/camel/camel-log.h deleted file mode 100644 index 82fb430719..0000000000 --- a/camel/camel-log.h +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * - * 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_LOG_H -#define CAMEL_LOG_H - - -#include -#include -#include - -extern int camel_debug_level; -extern FILE *camel_log_file_descriptor; - -#define CAMEL_LOG_LEVEL_NO_LOG 0 -#define CAMEL_LOG_LEVEL_STRANGE 5 -#define CAMEL_LOG_LEVEL_WARNING 6 -#define CAMEL_LOG_LEVEL_TRACE 8 -#define CAMEL_LOG_LEVEL_FULL_DEBUG 10 - -/* #define CAMEL_HARD_LOG_LEVEL CAMEL_LOG_LEVEL_TRACE */ - -/* the idea here is to be able to have a hard maximum log -level, given at compilation time, and a soft one, given at -runtime (with camel_debug_level) */ - -#if CAMEL_HARD_LOG_LEVEL>=CAMEL_LOG_LEVEL_STRANGE -#define CAMEL_LOG_STRANGE(args...) camel_log(CAMEL_LOG_LEVEL_STRANGE, ##args) -#else /* CAMEL_LOG_LEVEL_STRANGE */ -#define CAMEL_LOG_STRANGE(args...) -#endif /* CAMEL_LOG_LEVEL_STRANGE */ - -#if CAMEL_HARD_LOG_LEVEL>=CAMEL_LOG_LEVEL_WARNING -#define CAMEL_LOG_WARNING(args...) camel_log(CAMEL_LOG_LEVEL_WARNING, ##args) -#else /* CAMEL_LOG_LEVEL_WARNING */ -#define CAMEL_LOG_WARNING(args...) -#endif /* CAMEL_LOG_LEVEL_WARNING */ - -#if CAMEL_HARD_LOG_LEVEL>=CAMEL_LOG_LEVEL_TRACE -#define CAMEL_LOG_TRACE(args...) camel_log(CAMEL_LOG_LEVEL_TRACE, ##args) -#else /* CAMEL_LOG_LEVEL_TRACE */ -#define CAMEL_LOG_TRACE(args...) -#endif /* CAMEL_LOG_LEVEL_TRACE */ - -#if CAMEL_HARD_LOG_LEVEL>=CAMEL_LOG_LEVEL_FULL_DEBUG -#define CAMEL_LOG_FULL_DEBUG(args...) camel_log(CAMEL_LOG_LEVEL_FULL_DEBUG, ##args) -#else /* CAMEL_LOG_LEVEL_FULL_DEBUG */ -#define CAMEL_LOG_FULL_DEBUG(args...) -#endif /* CAMEL_LOG_LEVEL_FULL_DEBUG */ - - - - -extern void camel_log(guint level, const gchar *format, ... ); - -#endif /* CAMEL_LOG_H */ diff --git a/camel/camel-mime-body-part.c b/camel/camel-mime-body-part.c deleted file mode 100644 index 3b0c547bfa..0000000000 --- a/camel/camel-mime-body-part.c +++ /dev/null @@ -1,123 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-mime-body-part.c : Abstract class for a mime body part */ - - -/* - * - * 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 -#include "camel-mime-body-part.h" -#include "camel-log.h" - - -static void _set_parent (CamelMimeBodyPart *mime_body_part, CamelMultipart *multipart); -static const CamelMultipart *_get_parent (CamelMimeBodyPart *mime_body_part); - - -static CamelMimePartClass *parent_class=NULL; - -/* Returns the class for a CamelMimeBodyPart */ -#define CMBP_CLASS(so) CAMEL_MIME_BODY_PART_CLASS (GTK_OBJECT(so)->klass) - - - -static void -camel_mime_body_part_class_init (CamelMimeBodyPartClass *camel_mime_body_part_class) -{ - CamelMimePartClass *camel_mime_part_class = CAMEL_MIME_PART_CLASS (camel_mime_body_part_class); - parent_class = gtk_type_class (camel_mime_part_get_type ()); - - /* virtual method definition */ - camel_mime_body_part_class->set_parent = _set_parent; - camel_mime_body_part_class->get_parent = _get_parent; -} - -static void -camel_mime_body_part_init (gpointer object, gpointer klass) -{ - CamelMimeBodyPart *camel_mime_body_part = CAMEL_MIME_BODY_PART (object); -} - - - - -GtkType -camel_mime_body_part_get_type (void) -{ - static GtkType camel_mime_body_part_type = 0; - - if (!camel_mime_body_part_type) { - GtkTypeInfo camel_mime_body_part_info = - { - "CamelMimeBodyPart", - sizeof (CamelMimeBodyPart), - sizeof (CamelMimeBodyPartClass), - (GtkClassInitFunc) camel_mime_body_part_class_init, - (GtkObjectInitFunc) camel_mime_body_part_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_mime_body_part_type = gtk_type_unique (camel_mime_part_get_type (), &camel_mime_body_part_info); - } - - return camel_mime_body_part_type; -} - -CamelMimeBodyPart * -camel_mime_body_part_new () -{ - CamelMimeBodyPart *mime_body_part; - CAMEL_LOG_FULL_DEBUG ("CamelMimeBodyPart:: Entering new()\n"); - - mime_body_part = (CamelMimeBodyPart *)gtk_type_new (CAMEL_MIME_BODY_PART_TYPE); - CAMEL_LOG_FULL_DEBUG ("CamelMimeBodyPart:: Leaving new()\n"); - return mime_body_part; -} - - -static void -_set_parent (CamelMimeBodyPart *mime_body_part, CamelMultipart *multipart) -{ - mime_body_part->parent = multipart; -} - - -void -camel_mime_body_part_set_parent (CamelMimeBodyPart *mime_body_part, CamelMultipart *multipart) -{ - CMBP_CLASS (mime_body_part)->set_parent (mime_body_part, multipart); -} - - -static const CamelMultipart * -_get_parent (CamelMimeBodyPart *mime_body_part) -{ - return mime_body_part->parent; -} - - -const CamelMultipart * -camel_mime_body_part_get_parent (CamelMimeBodyPart *mime_body_part) -{ - return CMBP_CLASS (mime_body_part)->get_parent (mime_body_part); -} - - diff --git a/camel/camel-mime-body-part.h b/camel/camel-mime-body-part.h deleted file mode 100644 index eb721f3b60..0000000000 --- a/camel/camel-mime-body-part.h +++ /dev/null @@ -1,82 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-mime-body-part.h : class for a mime body part */ - -/* - * - * 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_BODY_PART_H -#define CAMEL_MIME_BODY_PART_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -typedef struct _CamelMimeBodyPart CamelMimeBodyPart; - -#include -#include "camel-mime-part.h" -#include "camel-multipart.h" - - - -#define CAMEL_MIME_BODY_PART_TYPE (camel_mime_body_part_get_type ()) -#define CAMEL_MIME_BODY_PART(obj) (GTK_CHECK_CAST((obj), CAMEL_MIME_BODY_PART_TYPE, CamelMimeBodyPart)) -#define CAMEL_MIME_BODY_PART_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_MIME_BODY_PART_TYPE, CamelMimeBodyPartClass)) -#define IS_CAMEL_MIME_BODY_PART(o) (GTK_CHECK_TYPE((o), CAMEL_MIME_BODY_PART_TYPE)) - - -struct _CamelMimeBodyPart -{ - CamelMimePart parent_object; - CamelMultipart *parent; - -}; - - - -typedef struct { - CamelMimePartClass parent_class; - - /* Virtual methods */ - void (*set_parent) (CamelMimeBodyPart *mime_body_part, CamelMultipart *multipart); - const CamelMultipart * (*get_parent) (CamelMimeBodyPart *mime_body_part); - -} CamelMimeBodyPartClass; - - -/* Standard Gtk function */ -GtkType camel_mime_body_part_get_type (void); - - -/* public methods */ -CamelMimeBodyPart *camel_mime_body_part_new (); -void camel_mime_body_part_set_parent (CamelMimeBodyPart *mime_body_part, CamelMultipart *multipart); -const CamelMultipart *camel_mime_body_part_get_parent (CamelMimeBodyPart *mime_body_part); - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* CAMEL_MIME_BODY_PART_H */ - diff --git a/camel/camel-mime-message.c b/camel/camel-mime-message.c deleted file mode 100644 index 5b608a6076..0000000000 --- a/camel/camel-mime-message.c +++ /dev/null @@ -1,632 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camelMimeMessage.c : class for a mime_message */ - - -/* - * - * 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 -#include "camel-mime-message.h" -#include -#include "gmime-content-field.h" -#include "string-utils.h" -#include "camel-log.h" -#include "gmime-utils.h" - -typedef enum { - HEADER_UNKNOWN, - HEADER_FROM, - HEADER_REPLY_TO, - HEADER_SUBJECT, - HEADER_TO, - HEADER_CC, - HEADER_BCC -} CamelHeaderType; - -static GHashTable *header_name_table; - - - -static CamelMimePartClass *parent_class=NULL; - -static gchar *received_date_str; -static gchar *sent_date_str; -static gchar *reply_to_str; -static gchar *subject_str; -static gchar *from_str; - -static void _set_received_date (CamelMimeMessage *mime_message, gchar *received_date); -static const gchar *_get_received_date (CamelMimeMessage *mime_message); -static const gchar *_get_sent_date (CamelMimeMessage *mime_message); -static void _set_reply_to (CamelMimeMessage *mime_message, gchar *reply_to); -static const gchar *_get_reply_to (CamelMimeMessage *mime_message); -static void _set_subject (CamelMimeMessage *mime_message, gchar *subject); -static const gchar *_get_subject (CamelMimeMessage *mime_message); -static void _set_from (CamelMimeMessage *mime_message, gchar *from); -static const gchar *_get_from (CamelMimeMessage *mime_message); - -static void _add_recipient (CamelMimeMessage *mime_message, gchar *recipient_type, gchar *recipient); -static void _remove_recipient (CamelMimeMessage *mime_message, const gchar *recipient_type, const gchar *recipient); -static const GList *_get_recipients (CamelMimeMessage *mime_message, const gchar *recipient_type); - -static void _set_flag (CamelMimeMessage *mime_message, gchar *flag, gboolean value); -static gboolean _get_flag (CamelMimeMessage *mime_message, gchar *flag); - -static void _set_message_number (CamelMimeMessage *mime_message, guint number); -static guint _get_message_number (CamelMimeMessage *mime_message); - -static void _write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream); -static gboolean _parse_header_pair (CamelMimePart *mime_part, gchar *header_name, gchar *header_value); - -/* 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) - - -static void -_init_header_name_table() -{ - header_name_table = g_hash_table_new (g_str_hash, g_str_equal); - g_hash_table_insert (header_name_table, "From", (gpointer)HEADER_FROM); - g_hash_table_insert (header_name_table, "Reply-To", (gpointer)HEADER_REPLY_TO); - g_hash_table_insert (header_name_table, "Subject", (gpointer)HEADER_SUBJECT); - g_hash_table_insert (header_name_table, "To", (gpointer)HEADER_TO); - g_hash_table_insert (header_name_table, "Cc", (gpointer)HEADER_CC); - g_hash_table_insert (header_name_table, "Bcc", (gpointer)HEADER_BCC); - -} - -static void -camel_mime_message_class_init (CamelMimeMessageClass *camel_mime_message_class) -{ - CamelDataWrapperClass *camel_data_wrapper_class = CAMEL_DATA_WRAPPER_CLASS (camel_mime_message_class); - CamelMimePartClass *camel_mime_part_class = CAMEL_MIME_PART_CLASS (camel_mime_message_class); - - parent_class = gtk_type_class (camel_mime_part_get_type ()); - _init_header_name_table(); - - received_date_str = ""; - sent_date_str = ""; - reply_to_str = "Reply-To"; - subject_str = "Subject"; - from_str = "From"; - - /* virtual method definition */ - camel_mime_message_class->set_received_date = _set_received_date; - camel_mime_message_class->get_received_date = _get_received_date; - camel_mime_message_class->get_sent_date = _get_sent_date; - camel_mime_message_class->set_reply_to = _set_reply_to; - camel_mime_message_class->get_reply_to = _get_reply_to; - camel_mime_message_class->set_subject = _set_subject; - camel_mime_message_class->get_subject = _get_subject; - camel_mime_message_class->set_from = _set_from; - camel_mime_message_class->get_from = _get_from; - camel_mime_message_class->add_recipient = _add_recipient; - camel_mime_message_class->remove_recipient = _remove_recipient; - camel_mime_message_class->get_recipients = _get_recipients; - camel_mime_message_class->set_flag = _set_flag; - camel_mime_message_class->get_flag = _get_flag; - camel_mime_message_class->set_message_number = _set_message_number; - camel_mime_message_class->get_message_number = _get_message_number; - - /* virtual method overload */ - camel_data_wrapper_class->write_to_stream = _write_to_stream; - camel_mime_part_class->parse_header_pair = _parse_header_pair; - -} - - - - -static void -camel_mime_message_init (gpointer object, gpointer klass) -{ - CamelMimeMessage *camel_mime_message = CAMEL_MIME_MESSAGE (object); - - camel_mime_message->recipients = g_hash_table_new(g_str_hash, g_str_equal); - camel_mime_message->flags = g_hash_table_new(g_str_hash, g_str_equal); -} - -GtkType -camel_mime_message_get_type (void) -{ - static GtkType camel_mime_message_type = 0; - - if (!camel_mime_message_type) { - GtkTypeInfo camel_mime_message_info = - { - "CamelMimeMessage", - sizeof (CamelMimeMessage), - sizeof (CamelMimeMessageClass), - (GtkClassInitFunc) camel_mime_message_class_init, - (GtkObjectInitFunc) camel_mime_message_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_mime_message_type = gtk_type_unique (camel_mime_part_get_type (), &camel_mime_message_info); - } - - return camel_mime_message_type; -} - - -CamelMimeMessage * -camel_mime_message_new_with_session (CamelSession *session) -{ - CamelMimeMessage *mime_message; - mime_message = gtk_type_new (CAMEL_MIME_MESSAGE_TYPE); - mime_message->session = session; - return mime_message; -} - - -/* two utils func */ - -static void -_set_field (CamelMimeMessage *mime_message, gchar *name, gchar *value, gchar **variable) -{ - if (variable) { - if (*variable) g_free (*variable); - *variable = value; - } -} - -/* for future use */ -/* for the moment, only @variable is used */ -static gchar * -_get_field (CamelMimeMessage *mime_message, gchar *name, gchar *variable) -{ - return variable; -} -/* * */ - - -static void -_set_received_date (CamelMimeMessage *mime_message, gchar *received_date) -{ - _set_field (mime_message, received_date_str, received_date, &(mime_message->received_date)); -} - -void -camel_mime_message_set_received_date (CamelMimeMessage *mime_message, gchar *received_date) -{ - CMM_CLASS (mime_message)->set_received_date (mime_message, received_date); -} - - -static const gchar * -_get_received_date (CamelMimeMessage *mime_message) -{ - return _get_field (mime_message, received_date_str, mime_message->received_date); -} - -const gchar * -camel_mime_message_get_received_date (CamelMimeMessage *mime_message) -{ - return CMM_CLASS (mime_message)->get_received_date (mime_message); -} - - -static const gchar * -_get_sent_date (CamelMimeMessage *mime_message) -{ - return _get_field (mime_message, sent_date_str, mime_message->sent_date); -} - -const gchar * -camel_mime_message_get_sent_date (CamelMimeMessage *mime_message) -{ - return CMM_CLASS (mime_message)->get_sent_date (mime_message); -} - - -static void -_set_reply_to (CamelMimeMessage *mime_message, gchar *reply_to) -{ - _set_field (mime_message, reply_to_str, reply_to, &(mime_message->reply_to)); -} - -void -camel_mime_message_set_reply_to (CamelMimeMessage *mime_message, gchar *reply_to) -{ - CMM_CLASS (mime_message)->set_reply_to (mime_message, reply_to); -} - - -static const gchar * -_get_reply_to (CamelMimeMessage *mime_message) -{ - return _get_field (mime_message, reply_to_str, mime_message->reply_to); -} - -const gchar * -camel_mime_message_get_reply_to (CamelMimeMessage *mime_message) -{ - return CMM_CLASS (mime_message)->get_reply_to (mime_message); -} - - - - -static void -_set_subject (CamelMimeMessage *mime_message, gchar *subject) -{ - _set_field (mime_message, subject_str, subject, &(mime_message->subject)); -} - -void -camel_mime_message_set_subject (CamelMimeMessage *mime_message, gchar *subject) -{ - CMM_CLASS (mime_message)->set_subject (mime_message, subject); -} - - -static const gchar * -_get_subject (CamelMimeMessage *mime_message) -{ - return _get_field (mime_message, subject_str, mime_message->subject); -} - -const gchar * -camel_mime_message_get_subject (CamelMimeMessage *mime_message) -{ - return CMM_CLASS (mime_message)->get_subject (mime_message); -} - - - - -static void -_set_from (CamelMimeMessage *mime_message, gchar *from) -{ - _set_field (mime_message, from_str, from, &(mime_message->from)); -} - -void -camel_mime_message_set_from (CamelMimeMessage *mime_message, gchar *from) -{ - CMM_CLASS (mime_message)->set_from (mime_message, from); -} - - -static const gchar * -_get_from (CamelMimeMessage *mime_message) -{ - return _get_field (mime_message, from_str, mime_message->from); -} - -const gchar * -camel_mime_message_get_from (CamelMimeMessage *mime_message) -{ - return CMM_CLASS (mime_message)->get_from (mime_message); -} - - - - - - -static void -_add_recipient (CamelMimeMessage *mime_message, gchar *recipient_type, gchar *recipient) -{ - /* be careful, recipient_type and recipient may be freed within this func */ - GList *recipients_list; - GList *existent_list; - - /* see if there is already a list for this recipient type */ - existent_list = (GList *)g_hash_table_lookup (mime_message->recipients, recipient_type); - - /* if the recipient is already in this list, do nothing */ - if ( existent_list && g_list_find_custom (existent_list, (gpointer)recipient, string_equal_for_glist) ) { - g_free (recipient_type); - g_free (recipient); - return; - } - /* append the new recipient to the recipient list - if the existent_list is NULL, then a new GList is - automagically created */ - recipients_list = g_list_append (existent_list, (gpointer)recipient); - - if (!existent_list) /* if there was no recipient of this type create the section */ - g_hash_table_insert (mime_message->recipients, recipient_type, recipients_list); - else - g_free (recipient_type); -} - - -/** - * add_recipient: - * @mime_message: - * @recipient_type: - * @recipient: - * - * Have to write the doc. IMPORTANT : @recipient_type and - * @recipient may be freed within this func - **/ -void -camel_mime_message_add_recipient (CamelMimeMessage *mime_message, gchar *recipient_type, gchar *recipient) -{ - CMM_CLASS (mime_message)->add_recipient (mime_message, recipient_type, recipient); -} - - -/** - * _remove_recipient: remove a recipient from the list of recipients - * @mime_message: the message - * @recipient_type: recipient type from which the recipient should be removed - * @recipient: recipient to remove - * - * Be careful, recipient and recipient_type are not freed. - * calling programns must free them themselves. They can free - * them just after remove_recipient returns. - **/ -static void -_remove_recipient (CamelMimeMessage *mime_message, const gchar *recipient_type, const gchar *recipient) -{ - GList *recipients_list; - GList *new_recipients_list; - GList *old_element; - gchar *old_recipient_type; - - /* if the recipient type section does not exist, do nothing */ - if (! g_hash_table_lookup_extended (mime_message->recipients, - recipient_type, - (gpointer)&(old_recipient_type), - (gpointer)&(recipients_list)) - ) return; - - /* look for the recipient to remove */ - /* g_list_find_custom does use "const" for recipient, is it a mistake ? */ - old_element = g_list_find_custom (recipients_list, recipient, g_str_equal); - if (old_element) { - /* if recipient exists, remove it */ - new_recipients_list = g_list_remove_link (recipients_list, old_element); - - /* if glist head has changed, fix up hash table */ - if (new_recipients_list != recipients_list) - g_hash_table_insert (mime_message->recipients, old_recipient_type, new_recipients_list); - - g_free( (gchar *)(old_element->data)); - g_list_free_1 (old_element); - } -} - - -void -camel_mime_message_remove_recipient (CamelMimeMessage *mime_message, const gchar *recipient_type, const gchar *recipient) -{ - CMM_CLASS (mime_message)->remove_recipient (mime_message, recipient_type, recipient); -} - - -static const GList * -_get_recipients (CamelMimeMessage *mime_message, const gchar *recipient_type) -{ - return (GList *)g_hash_table_lookup (mime_message->recipients, recipient_type); -} - -const GList * -camel_mime_message_get_recipients (CamelMimeMessage *mime_message, const gchar *recipient_type) -{ - return CMM_CLASS (mime_message)->get_recipients (mime_message, recipient_type); -} - - -static void -_set_flag (CamelMimeMessage *mime_message, gchar *flag, gboolean value) -{ - gchar old_flags; - gboolean *ptr_value; - if (! g_hash_table_lookup_extended (mime_message->flags, - flag, - (gpointer)&(old_flags), - (gpointer)&(ptr_value)) ) { - - ptr_value = g_new (gboolean, 1); - g_hash_table_insert (mime_message->flags, flag, ptr_value); - } else { - g_free (flag); - } - *ptr_value = value; - -} - -void -camel_mime_message_set_flag (CamelMimeMessage *mime_message, gchar *flag, gboolean value) -{ - CMM_CLASS (mime_message)->set_flag (mime_message, flag, value); -} - - - -static gboolean -_get_flag (CamelMimeMessage *mime_message, gchar *flag) -{ - gboolean *value; - value = (gboolean *)g_hash_table_lookup (mime_message->flags, flag); - return ( (value) && (*value)); -} - -gboolean -camel_mime_message_get_flag (CamelMimeMessage *mime_message, gchar *flag) -{ - return CMM_CLASS (mime_message)->get_flag (mime_message, flag); -} - - - - -static void -_set_message_number (CamelMimeMessage *mime_message, guint number) -{ - mime_message->message_number = number; -} - -static guint -_get_message_number (CamelMimeMessage *mime_message) -{ - return mime_message->message_number; -} - - - -guint -camel_mime_message_get_message_number (CamelMimeMessage *mime_message) -{ - return CMM_CLASS (mime_message)->get_message_number (mime_message); -} - - - - -#ifdef WHPT -#warning : WHPT is already defined !!!!!! -#endif -#define WHPT gmime_write_header_pair_to_stream - -static void -_write_one_recipient_to_stream (gpointer key, gpointer value, gpointer user_data) -{ - gchar *recipient_type = (gchar *)key; - GList *recipients = (GList *)value; - // gchar *current; - CamelStream *stream = (CamelStream *)user_data; - if (recipient_type) - write_header_with_glist_to_stream (stream, recipient_type, recipients, ", "); -} - -static void -_write_recipients_to_stream (CamelMimeMessage *mime_message, CamelStream *stream) -{ - g_hash_table_foreach (mime_message->recipients, _write_one_recipient_to_stream, (gpointer)stream); -} - -static void -_write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream) -{ - CamelMimeMessage *mm = CAMEL_MIME_MESSAGE (data_wrapper); - CAMEL_LOG_FULL_DEBUG ( "CamelMimeMessage::write_to_stream\n"); - CAMEL_LOG_FULL_DEBUG ( "CamelMimeMessage:: Writing \"From\"\n"); - WHPT (stream, "From", mm->from); - CAMEL_LOG_FULL_DEBUG ( "CamelMimeMessage:: Writing \"Reply-To\"\n"); - WHPT (stream, "Reply-To", mm->reply_to); - CAMEL_LOG_FULL_DEBUG ( "CamelMimeMessage:: Writing recipients\n"); - _write_recipients_to_stream (mm, stream); - CAMEL_LOG_FULL_DEBUG ( "CamelMimeMessage:: Writing \"Date\"\n"); - WHPT (stream, "Date", mm->received_date); - CAMEL_LOG_FULL_DEBUG ( "CamelMimeMessage:: Writing \"Subject\"\n"); - WHPT (stream, "Subject", mm->subject); - CAMEL_DATA_WRAPPER_CLASS (parent_class)->write_to_stream (data_wrapper, stream); - -} - -/*******************************/ -/* mime message header parsing */ - -static void -_set_recipient_list_from_string (CamelMimeMessage *message, gchar *recipient_type, gchar *recipients_string) -{ - GList *recipients_list; - CAMEL_LOG_FULL_DEBUG ("CamelMimeMessage::_set_recipient_list_from_string parsing ##%s##\n", recipients_string); - recipients_list = string_split ( - recipients_string, ',', "\t ", - STRING_TRIM_STRIP_TRAILING | STRING_TRIM_STRIP_LEADING); - g_hash_table_insert (message->recipients, recipient_type, recipients_list); - -} - -static gboolean -_parse_header_pair (CamelMimePart *mime_part, gchar *header_name, gchar *header_value) -{ - CamelHeaderType header_type; - CamelMimeMessage *message = CAMEL_MIME_MESSAGE (mime_part); - gboolean header_handled = FALSE; - - - header_type = (CamelHeaderType) g_hash_table_lookup (header_name_table, header_name); - switch (header_type) { - - case HEADER_FROM: - CAMEL_LOG_FULL_DEBUG ( - "CamelMimeMessage::parse_header_pair found HEADER_FROM : %s\n", - header_value ); - - camel_mime_message_set_from (message, header_value); - header_handled = TRUE; - break; - - case HEADER_REPLY_TO: - CAMEL_LOG_FULL_DEBUG ( - "CamelMimeMessage::parse_header_pair found HEADER_REPLY_YO : %s\n", - header_value ); - - camel_mime_message_set_reply_to (message, header_value); - header_handled = TRUE; - break; - - case HEADER_SUBJECT: - CAMEL_LOG_FULL_DEBUG ( - "CamelMimeMessage::parse_header_pair found HEADER_SUBJECT : %s\n", - header_value ); - - camel_mime_message_set_subject (message, header_value); - header_handled = TRUE; - break; - - case HEADER_TO: - CAMEL_LOG_FULL_DEBUG ( - "CamelMimeMessage::parse_header_pair found HEADER_TO : %s\n", - header_value ); - - _set_recipient_list_from_string (message, "To", header_value); - g_free (header_value); - header_handled = TRUE; - break; - - case HEADER_CC: - CAMEL_LOG_FULL_DEBUG ( - "CamelMimeMessage::parse_header_pair found HEADER_CC : %s\n", - header_value ); - - _set_recipient_list_from_string (message, "Cc", header_value); - g_free (header_value); - header_handled = TRUE; - break; - - case HEADER_BCC: - CAMEL_LOG_FULL_DEBUG ( - "CamelMimeMessage::parse_header_pair found HEADER_BCC : %s\n", - header_value ); - - _set_recipient_list_from_string (message, "Bcc", header_value); - g_free (header_value); - header_handled = TRUE; - break; - - - } - if (header_handled) { - g_free (header_name); - return TRUE; - } else - return parent_class->parse_header_pair (mime_part, header_name, header_value); - -} diff --git a/camel/camel-mime-message.h b/camel/camel-mime-message.h deleted file mode 100644 index 617286b0c1..0000000000 --- a/camel/camel-mime-message.h +++ /dev/null @@ -1,136 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camelMimeMessage.h : class for a mime message */ - -/* - * - * 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_MESSAGE_H -#define CAMEL_MIME_MESSAGE_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include -#include "camel-mime-part.h" -#include "camel-folder.h" -#include "camel-session.h" - - -#define RECIPIENT_TYPE_TO "To" -#define RECIPIENT_TYPE_CC "Cc" -#define RECIPIENT_TYPE_BCC "Bcc" - - -#define CAMEL_MIME_MESSAGE_TYPE (camel_mime_message_get_type ()) -#define CAMEL_MIME_MESSAGE(obj) (GTK_CHECK_CAST((obj), CAMEL_MIME_MESSAGE_TYPE, CamelMimeMessage)) -#define CAMEL_MIME_MESSAGE_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_MIME_MESSAGE_TYPE, CamelMimeMessageClass)) -#define IS_CAMEL_MIME_MESSAGE(o) (GTK_CHECK_TYPE((o), CAMEL_MIME_MESSAGE_TYPE)) - - - -typedef struct -{ - CamelMimePart parent_object; - - /* header fields */ - gchar *received_date; - gchar *sent_date; - - gchar *subject; - gchar *reply_to; - - gchar *from; - GHashTable *recipients; - /* -> each value is a GList of address strings */ - /* each key is a recipient type string in lower-case */ - - /* other fields */ - GHashTable *flags; /* boolean values */ - /* gboolean expunged; - Will be enabled if proves necessary in the future */ - guint message_number; /* set by folder object when retrieving message */ - CamelFolder *folder; - CamelSession *session; - -} CamelMimeMessage; - - - -typedef struct { - CamelMimePartClass parent_class; - - /* Virtual methods */ - void (*set_received_date) (CamelMimeMessage *mime_message, gchar *received_date); - const gchar * (*get_received_date) (CamelMimeMessage *mime_message); - const gchar * (*get_sent_date) (CamelMimeMessage *mime_message); - void (*set_reply_to) (CamelMimeMessage *mime_message, gchar *reply_to); - const gchar * (*get_reply_to) (CamelMimeMessage *mime_message); - void (*set_subject) (CamelMimeMessage *mime_message, gchar *subject); - const gchar * (*get_subject) (CamelMimeMessage *mime_message); - void (*set_from) (CamelMimeMessage *mime_message, gchar *from); - const gchar * (*get_from) (CamelMimeMessage *mime_message); - void (*add_recipient) (CamelMimeMessage *mime_message, gchar *recipient_type, gchar *recipient); - void (*remove_recipient) (CamelMimeMessage *mime_message, const gchar *recipient_type, const gchar *recipient); - const GList * (*get_recipients) (CamelMimeMessage *mime_message, const gchar *recipient_type); - void (*set_flag) (CamelMimeMessage *mime_message, gchar *flag, gboolean value); - gboolean (*get_flag) (CamelMimeMessage *mime_message, gchar *flag); - - void (*set_message_number)(CamelMimeMessage *mime_message, guint number); - guint (*get_message_number)(CamelMimeMessage *mime_message); -} CamelMimeMessageClass; - - - -/* Standard Gtk function */ -GtkType camel_mime_message_get_type (void); - - -/* public methods */ -CamelMimeMessage *camel_mime_message_new_with_session (CamelSession *session); - - -void camel_mime_message_set_received_date (CamelMimeMessage *mime_message, gchar *received_date); -const gchar *camel_mime_message_get_received_date (CamelMimeMessage *mime_message); -const gchar *camel_mime_message_get_sent_date (CamelMimeMessage *mime_message); -void camel_mime_message_set_reply_to (CamelMimeMessage *mime_message, gchar *reply_to); -const gchar *camel_mime_message_get_reply_to (CamelMimeMessage *mime_message); -void camel_mime_message_set_subject (CamelMimeMessage *mime_message, gchar *subject); -const gchar *camel_mime_message_get_subject (CamelMimeMessage *mime_message); -void camel_mime_message_set_from (CamelMimeMessage *mime_message, gchar *from); -const gchar *camel_mime_message_get_from (CamelMimeMessage *mime_message); - -void camel_mime_message_add_recipient (CamelMimeMessage *mime_message, gchar *recipient_type, gchar *recipient); -void camel_mime_message_remove_recipient (CamelMimeMessage *mime_message, const gchar *recipient_type, const gchar *recipient); -const GList *camel_mime_message_get_recipients (CamelMimeMessage *mime_message, const gchar *recipient_type); - -void camel_mime_message_set_flag (CamelMimeMessage *mime_message, gchar *flag, gboolean value); -gboolean camel_mime_message_get_flag (CamelMimeMessage *mime_message, gchar *flag); - -guint camel_mime_message_get_message_number (CamelMimeMessage *mime_message); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* CAMEL_MIME_MESSAGE_H */ diff --git a/camel/camel-mime-part.c b/camel/camel-mime-part.c deleted file mode 100644 index 913ab31e63..0000000000 --- a/camel/camel-mime-part.c +++ /dev/null @@ -1,806 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camelMimePart.c : Abstract class for a mime_part */ - - -/* - * - * 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 -#include "camel-mime-part.h" -#include -#include "gmime-content-field.h" -#include "string-utils.h" -#include "camel-log.h" -#include "gmime-utils.h" -#include "camel-simple-data-wrapper.h" - - -typedef enum { - HEADER_UNKNOWN, - HEADER_DESCRIPTION, - HEADER_DISPOSITION, - HEADER_CONTENT_ID, - HEADER_ENCODING, - HEADER_CONTENT_MD5, - HEADER_CONTENT_LANGUAGES, - HEADER_CONTENT_TYPE -} CamelHeaderType; - - -static GHashTable *header_name_table; - - -static CamelDataWrapperClass *parent_class=NULL; - -/* Returns the class for a CamelMimePart */ -#define CMP_CLASS(so) CAMEL_MIME_PART_CLASS (GTK_OBJECT(so)->klass) - -static void _add_header (CamelMimePart *mime_part, gchar *header_name, gchar *header_value); -static void _remove_header (CamelMimePart *mime_part, const gchar *header_name); -static const gchar *_get_header (CamelMimePart *mime_part, const gchar *header_name); -static void _set_description (CamelMimePart *mime_part, gchar *description); -static const gchar *_get_description (CamelMimePart *mime_part); -static void _set_disposition (CamelMimePart *mime_part, 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, gchar *encoding); -static const gchar *_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 const CamelDataWrapper *_get_content_object(CamelMimePart *mime_part); -static void _set_content_object(CamelMimePart *mime_part, CamelDataWrapper *content); - -static void _write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream); -static gboolean _parse_header_pair (CamelMimePart *mime_part, gchar *header_name, gchar *header_value); -void _construct_from_stream (CamelDataWrapper *data_wrapper, CamelStream *stream); - - -/* loads in a hash table the set of header names we */ -/* recognize and associate them with a unique enum */ -/* identifier (see CamelHeaderType above) */ -static void -_init_header_name_table() -{ - header_name_table = g_hash_table_new (g_str_hash, g_str_equal); - g_hash_table_insert (header_name_table, "Content-Description", (gpointer)HEADER_DESCRIPTION); - g_hash_table_insert (header_name_table, "Content-Disposition", (gpointer)HEADER_DISPOSITION); - g_hash_table_insert (header_name_table, "Content-id", (gpointer)HEADER_CONTENT_ID); - g_hash_table_insert (header_name_table, "Content-Transfer-Encoding", (gpointer)HEADER_ENCODING); - g_hash_table_insert (header_name_table, "Content-MD5", (gpointer)HEADER_CONTENT_MD5); - g_hash_table_insert (header_name_table, "Content-Type", (gpointer)HEADER_CONTENT_TYPE); - -} - -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 ()); - _init_header_name_table(); - - /* virtual method definition */ - camel_mime_part_class->add_header = _add_header; - camel_mime_part_class->remove_header = _remove_header; - camel_mime_part_class->get_header = _get_header; - 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->parse_header_pair = _parse_header_pair; - camel_mime_part_class->get_content_object = _get_content_object; - camel_mime_part_class->set_content_object = _set_content_object; - - - - /* virtual method overload */ - camel_data_wrapper_class->write_to_stream = _write_to_stream; - camel_data_wrapper_class->construct_from_stream = _construct_from_stream; -} - -static void -camel_mime_part_init (gpointer object, gpointer klass) -{ - CamelMimePart *camel_mime_part = CAMEL_MIME_PART (object); - - camel_mime_part->headers = g_hash_table_new (g_str_hash, g_str_equal); - camel_mime_part->content_type = gmime_content_field_new (NULL, NULL); -} - - - - -GtkType -camel_mime_part_get_type (void) -{ - static GtkType camel_mime_part_type = 0; - - if (!camel_mime_part_type) { - GtkTypeInfo camel_mime_part_info = - { - "CamelMimePart", - sizeof (CamelMimePart), - sizeof (CamelMimePartClass), - (GtkClassInitFunc) camel_mime_part_class_init, - (GtkObjectInitFunc) camel_mime_part_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_mime_part_type = gtk_type_unique (camel_data_wrapper_get_type (), &camel_mime_part_info); - } - - return camel_mime_part_type; -} - - - - -static void -_add_header (CamelMimePart *mime_part, gchar *header_name, gchar *header_value) -{ - gboolean header_exists; - gchar *old_header_name; - gchar *old_header_value; - - /* Try to parse the header pair. If it corresponds to something */ - /* known, the job is done in the parsing routine. If not, */ - /* we simply add the header in a raw fashion */ - if (CMP_CLASS(mime_part)->parse_header_pair (mime_part, header_name, header_value)) - return; - header_exists = g_hash_table_lookup_extended (mime_part->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 (mime_part->headers, header_name, header_value); -} - - -void -camel_mime_part_add_header (CamelMimePart *mime_part, gchar *header_name, gchar *header_value) -{ - CMP_CLASS(mime_part)->add_header(mime_part, header_name, header_value); -} - - - -static void -_remove_header (CamelMimePart *mime_part, const gchar *header_name) -{ - - gboolean header_exists; - gchar *old_header_name; - gchar *old_header_value; - - header_exists = g_hash_table_lookup_extended (mime_part->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 (mime_part->headers, header_name); - -} - -void -camel_mime_part_remove_header (CamelMimePart *mime_part, const gchar *header_name) -{ - CMP_CLASS(mime_part)->remove_header(mime_part, header_name); -} - - - -static const gchar * -_get_header (CamelMimePart *mime_part, const gchar *header_name) -{ - - gchar *old_header_name; - gchar *old_header_value; - gchar *header_value; - - header_value = (gchar *)g_hash_table_lookup (mime_part->headers, header_name); - return header_value; -} - -const gchar * -camel_mime_part_get_header (CamelMimePart *mime_part, const gchar *header_name) -{ - return CMP_CLASS(mime_part)->get_header (mime_part, header_name); -} - - - -static void -_set_description (CamelMimePart *mime_part, gchar *description) -{ - if (mime_part->description) g_free (mime_part->description); - mime_part->description = description; -} - -void -camel_mime_part_set_description (CamelMimePart *mime_part, gchar *description) -{ - CMP_CLASS(mime_part)->set_description (mime_part, description); -} - - - - -static const gchar * -_get_description (CamelMimePart *mime_part) -{ - return mime_part->description; -} - -const gchar * -camel_mime_part_get_description (CamelMimePart *mime_part) -{ - return CMP_CLASS(mime_part)->get_description (mime_part); -} - - - -static void -_set_disposition (CamelMimePart *mime_part, gchar *disposition) -{ -#warning Do not use MimeContentfield here !!! - //if (mime_part->disposition) g_free(mime_part->disposition); - if (!mime_part->disposition) - mime_part->disposition = g_new (GMimeContentField,1); - if ((mime_part->disposition)->type) g_free ((mime_part->disposition)->type); - (mime_part->disposition)->type = disposition; -} - - -void -camel_mime_part_set_disposition (CamelMimePart *mime_part, gchar *disposition) -{ - CMP_CLASS(mime_part)->set_disposition (mime_part, disposition); -} - - - -static const gchar * -_get_disposition (CamelMimePart *mime_part) -{ - if (!mime_part->disposition) return NULL; - return (mime_part->disposition)->type; -} - - -const gchar * -camel_mime_part_get_disposition (CamelMimePart *mime_part) -{ - return CMP_CLASS(mime_part)->get_disposition (mime_part); -} - - - -static void -_set_filename (CamelMimePart *mime_part, gchar *filename) -{ - if (mime_part->filename) g_free(mime_part->filename); - mime_part->filename = filename; -} - - -void -camel_mime_part_set_filename (CamelMimePart *mime_part, gchar *filename) -{ - CMP_CLASS(mime_part)->set_filename (mime_part, filename); -} - - - -static const gchar * -_get_filename (CamelMimePart *mime_part) -{ - return mime_part->filename; -} - - -const gchar * -camel_mime_part_get_filename (CamelMimePart *mime_part) -{ - return CMP_CLASS(mime_part)->get_filename (mime_part); -} - - -/* this routine must not be public */ -static void -_set_content_id (CamelMimePart *mime_part, gchar *content_id) -{ - if (mime_part->content_id) g_free(mime_part->content_id); - mime_part->content_id = content_id; -} - - -static const gchar * -_get_content_id (CamelMimePart *mime_part) -{ - return mime_part->content_id; -} - - -const gchar * -camel_mime_part_get_content_id (CamelMimePart *mime_part) -{ - return CMP_CLASS(mime_part)->get_content_id (mime_part); -} - - -/* this routine must not be public */ -static void -_set_content_MD5 (CamelMimePart *mime_part, gchar *content_MD5) -{ - if (mime_part->content_MD5) g_free(mime_part->content_MD5); - mime_part->content_MD5 = content_MD5; -} - - -static const gchar * -_get_content_MD5 (CamelMimePart *mime_part) -{ - return mime_part->content_MD5; -} - -const gchar * -camel_mime_part_get_content_MD5 (CamelMimePart *mime_part) -{ - return CMP_CLASS(mime_part)->get_content_MD5 (mime_part); -} - - - -static void -_set_encoding (CamelMimePart *mime_part, gchar *encoding) -{ - if (mime_part->encoding) g_free(mime_part->encoding); - mime_part->encoding = encoding; -} - -void -camel_mime_part_set_encoding (CamelMimePart *mime_part, gchar *encoding) -{ - CMP_CLASS(mime_part)->set_encoding (mime_part, encoding); -} - - - -static const gchar * -_get_encoding (CamelMimePart *mime_part) -{ - return mime_part->encoding; -} - -const gchar * -camel_mime_part_get_encoding (CamelMimePart *mime_part) -{ - return CMP_CLASS(mime_part)->get_encoding (mime_part); -} - - - - -static void -_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; -} - -void -camel_mime_part_set_content_languages (CamelMimePart *mime_part, GList *content_languages) -{ - CMP_CLASS(mime_part)->set_content_languages (mime_part, content_languages); -} - - - -static const GList * -_get_content_languages (CamelMimePart *mime_part) -{ - return mime_part->content_languages; -} - - -const GList * -camel_mime_part_get_content_languages (CamelMimePart *mime_part) -{ - return CMP_CLASS(mime_part)->get_content_languages (mime_part); -} - - - -static void -_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; -} - -void -camel_mime_part_set_header_lines (CamelMimePart *mime_part, GList *header_lines) -{ - CMP_CLASS(mime_part)->set_header_lines (mime_part, header_lines); -} - - - -static const GList * -_get_header_lines (CamelMimePart *mime_part) -{ - return mime_part->header_lines; -} - - - -const GList * -camel_mime_part_get_header_lines (CamelMimePart *mime_part) -{ - return CMP_CLASS(mime_part)->get_header_lines (mime_part); -} - - - -/*********/ -static void -_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); -} - -void -camel_mime_part_set_content_type (CamelMimePart *mime_part, gchar *content_type) -{ - CMP_CLASS(mime_part)->set_content_type (mime_part, content_type); -} - -static GMimeContentField * -_get_content_type (CamelMimePart *mime_part) -{ - return mime_part->content_type; -} - -GMimeContentField * -camel_mime_part_get_content_type (CamelMimePart *mime_part) -{ - return CMP_CLASS(mime_part)->get_content_type (mime_part); -} - -/*********/ - - -static const CamelDataWrapper * -_get_content_object(CamelMimePart *mime_part) -{ - return mime_part->content; - -} -const CamelDataWrapper * -camel_mime_part_get_content_object(CamelMimePart *mime_part) -{ - return CMP_CLASS(mime_part)->get_content_object (mime_part); -} - - -static void -_set_content_object(CamelMimePart *mime_part, CamelDataWrapper *content) -{ - CAMEL_LOG_FULL_DEBUG ("Entering CamelMimePart::set_content_object\n"); - if (mime_part->content) { - CAMEL_LOG_FULL_DEBUG ("CamelMimePart::set_content_object unreferencing old content object\n"); - gtk_object_unref (GTK_OBJECT (mime_part->content)); - } - gtk_object_ref (GTK_OBJECT (content)); - mime_part->content = content; - if (mime_part->content_type) gmime_content_field_free (mime_part->content_type); - mime_part->content_type = camel_data_wrapper_get_mime_type_field (content); - CAMEL_LOG_FULL_DEBUG ("Leaving CamelMimePart::set_content_object\n"); - -} - -void -camel_mime_part_set_content_object(CamelMimePart *mime_part, CamelDataWrapper *content) -{ - CMP_CLASS(mime_part)->set_content_object (mime_part, content); -} - - - - -/**********************************************************************/ -#ifdef WHPT -#warning : WHPT is already defined !!!!!! -#endif -#define WHPT gmime_write_header_pair_to_stream - - -static void -_write_content_to_stream (CamelMimePart *mime_part, CamelStream *stream) -{ - guint buffer_size; - gchar *buffer; - gchar *encoded_buffer; - - CamelDataWrapper *content = mime_part->content; - CAMEL_LOG_FULL_DEBUG ( "Entering CamelMimePart::_write_content_to_stream\n"); - CAMEL_LOG_FULL_DEBUG ( "CamelMimePart::_write_content_to_stream, content=%p\n", content); - if (!content) return; - // buffer_size = camel_data_wrapper_size (content); - //buffer = g_malloc (buffer_size); - camel_data_wrapper_write_to_stream (content, stream); - - //if (mime_part->encoding) { - // encoded_buffer_size = gmime_encoded_size(buffer, buffer_size, encoding); - // encoded_buffer = g_malloc (encoded_buffer_size); - // gmime_encode_buffer (buffer, encoded_buffer, encoding); - // camel_stream_write (stream, encoded_buffer, encoded_buffer_size); - // g_free (encoded_buffer); - //} else - //fwrite (buffer, buffer_size, 1, file); - //camel_stream_write (stream, buffer, buffer_size); - //g_free (buffer); - CAMEL_LOG_FULL_DEBUG ( "Leaving CamelMimePart::_write_content_to_stream\n"); -} - - - - - -static void -_write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream) -{ - CamelMimePart *mp = CAMEL_MIME_PART (data_wrapper); - - CAMEL_LOG_FULL_DEBUG ( "Entering CamelMimePart::write_to_stream\n"); - - CAMEL_LOG_FULL_DEBUG ( "CamelMimePart::write_to_stream writing content-disposition\n"); - gmime_content_field_write_to_stream(mp->disposition, stream); - CAMEL_LOG_FULL_DEBUG ( "CamelMimePart::write_to_stream writing content-transfer-encoding\n"); - WHPT (stream, "Content-Transfer-Encoding", mp->encoding); - CAMEL_LOG_FULL_DEBUG ( "CamelMimePart::write_to_stream writing content-description\n"); - WHPT (stream, "Content-Description", mp->description); - CAMEL_LOG_FULL_DEBUG ( "CamelMimePart::write_to_stream writing content-MD5\n"); - WHPT (stream, "Content-MD5", mp->content_MD5); - CAMEL_LOG_FULL_DEBUG ( "CamelMimePart::write_to_stream writing content-id\n"); - WHPT (stream, "Content-id", mp->content_id); - CAMEL_LOG_FULL_DEBUG ( "CamelMimePart::write_to_stream writing content-languages\n"); - write_header_with_glist_to_stream (stream, "Content-Language", mp->content_languages,", "); - - CAMEL_LOG_FULL_DEBUG ( "CamelMimePart::write_to_stream writing other headers\n"); - write_header_table_to_stream (stream, mp->headers); - - CAMEL_LOG_FULL_DEBUG ( "CamelMimePart::write_to_stream writing content-type\n"); - gmime_content_field_write_to_stream(mp->content_type, stream); - - camel_stream_write_string(stream,"\n"); - _write_content_to_stream (mp, stream); - -} - - - -/*******************************/ -/* mime part parsing */ - -static gboolean -_parse_header_pair (CamelMimePart *mime_part, gchar *header_name, gchar *header_value) -{ - CamelHeaderType header_type; - gboolean header_handled = FALSE; - - - header_type = (CamelHeaderType) g_hash_table_lookup (header_name_table, header_name); - switch (header_type) { - - case HEADER_DESCRIPTION: - CAMEL_LOG_FULL_DEBUG ( - "CamelMimePart::parse_header_pair found HEADER_DESCRIPTION: %s\n", - header_value ); - - camel_mime_part_set_description (mime_part, header_value); - header_handled = TRUE; - break; - - case HEADER_DISPOSITION: - CAMEL_LOG_FULL_DEBUG ( - "CamelMimePart::parse_header_pair found HEADER_DISPOSITION: %s\n", - header_value); - - camel_mime_part_set_disposition (mime_part, header_value); - header_handled = TRUE; - break; - - case HEADER_CONTENT_ID: - CAMEL_LOG_FULL_DEBUG ( - "CamelMimePart::parse_header_pair found HEADER_CONTENT_ID: %s\n", - header_value); - - CMP_CLASS(mime_part)->set_content_id (mime_part, header_value); - header_handled = TRUE; - break; - - case HEADER_ENCODING: - CAMEL_LOG_FULL_DEBUG ( - "CamelMimePart::parse_header_pair found HEADER_ENCODING: %s\n", - header_value); - - camel_mime_part_set_encoding (mime_part, header_value); - header_handled = TRUE; - break; - - case HEADER_CONTENT_MD5: - CAMEL_LOG_FULL_DEBUG ( - "CamelMimePart::parse_header_pair found HEADER_CONTENT_MD5: %s\n", - header_value ); - - CMP_CLASS(mime_part)->set_content_MD5 (mime_part, header_value); - header_handled = TRUE; - break; - - case HEADER_CONTENT_TYPE: - CAMEL_LOG_FULL_DEBUG ( - "CamelMimePart::parse_header_pair found HEADER_CONTENT_TYPE: %s\n", - header_value ); - - gmime_content_field_construct_from_string (mime_part->content_type, header_value); - header_handled = TRUE; - break; - - - } - - - if (header_handled) { - g_free (header_name); - return TRUE; - } else return FALSE; - -} - -/* calls _parse_header_pair, but can be called - in a g_hash_table_for_each */ -void -_parse_hash_table_pair (gpointer key, gpointer value, gpointer user_data) -{ - gchar *header_name = (gchar *)key; - gchar *header_value = (gchar *)value; - CamelMimePart *mime_part = (CamelMimePart *) user_data; - - - CAMEL_LOG_FULL_DEBUG ("\n--------- New Header ----------\n"); - if (header_name) - CAMEL_LOG_FULL_DEBUG ( "header name :%s\n", header_name); - if (header_value) - CAMEL_LOG_FULL_DEBUG ( "header value :%s\n", header_value); - - camel_mime_part_add_header (mime_part, header_name, header_value); - CAMEL_LOG_FULL_DEBUG ( "--------- End -----------------\n"); -} - -void -_construct_from_stream (CamelDataWrapper *data_wrapper, CamelStream *stream) -{ - GHashTable *header_table; - CamelMimePart *mime_part = CAMEL_MIME_PART (data_wrapper); - GMimeContentField *content_type; - gchar *mime_type; - GtkType content_object_type; - CamelDataWrapper *content_object; - - CAMEL_LOG_FULL_DEBUG ("CamelMimePart:: Entering _construct_from_stream\n"); - g_assert (stream); - CAMEL_LOG_FULL_DEBUG ("CamelMimePart::construct_from_stream parsing headers\n"); - /* parse all header lines */ - header_table = get_header_table_from_stream (stream); - if (header_table) { - g_hash_table_foreach (header_table, _parse_hash_table_pair, (gpointer)mime_part); - } - g_hash_table_destroy (header_table); - CAMEL_LOG_FULL_DEBUG ("CamelMimePart::construct_from_stream headers parsed \n"); - - /* now parse the content */ - /* find its mime type */ - CAMEL_LOG_FULL_DEBUG ("CamelMimePart::construct_from_stream parsing content\n"); - content_type = camel_mime_part_get_content_type (mime_part); - mime_type = gmime_content_field_get_mime_type (content_type); - if (mime_type) { - content_object_type = data_wrapper_get_data_wrapper_type (mime_type); - CAMEL_LOG_FULL_DEBUG ("CamelMimePart::construct_from_stream content type object type used: %s\n", gtk_type_name (content_object_type)); - g_free (mime_type); - content_object = CAMEL_DATA_WRAPPER (gtk_type_new (content_object_type)); - camel_mime_part_set_content_object (mime_part, content_object); - camel_data_wrapper_construct_from_stream (content_object, stream); - - } else - CAMEL_LOG_FULL_DEBUG ("CamelMimePart::construct_from_stream content type field not found\n"); - CAMEL_LOG_FULL_DEBUG ("CamelMimePart::construct_from_stream content parsed\n"); - - - CAMEL_LOG_FULL_DEBUG ("CamelMimePart:: Leaving _construct_from_stream\n"); -} - - -/******************************/ -/** Misc utility functions **/ - - -/** - * camel_mime_part_set_text: set the content to be some text - * @camel_mime_part: Mime part - * @text: the text - * - * Utility function used to set the content of a mime part object to - * be a text string. When @text is NULL, this routine can be used as - * a way to remove old text content. - * - **/ -void -camel_mime_part_set_text (CamelMimePart *camel_mime_part, gchar *text) -{ - CamelSimpleDataWrapper *simple_data_wrapper; - CAMEL_LOG_FULL_DEBUG ("CamelMimePart:: Entering set_text\n"); - CAMEL_LOG_TRACE ("CamelMimePart::set_text, setting text as a mime part content\n"); - if (camel_mime_part->content) { - CAMEL_LOG_FULL_DEBUG ("CamelMimePart::set_text unreferencing old content object\n"); - gtk_object_unref (GTK_OBJECT (camel_mime_part->content)); - } - if (text) { - simple_data_wrapper = camel_simple_data_wrapper_new (); - camel_mime_part->content = CAMEL_DATA_WRAPPER (simple_data_wrapper); - CAMEL_LOG_FULL_DEBUG ("CamelMimePart::set_text calling CamelSimpleDataWrapper:set_text with %d chars\n", strlen (text)); - camel_simple_data_wrapper_set_text ( simple_data_wrapper, text); - } else camel_mime_part->content = NULL; - - CAMEL_LOG_FULL_DEBUG ("CamelMimePart:: Leaving camel_mime_part_set_text\n"); -} - diff --git a/camel/camel-mime-part.h b/camel/camel-mime-part.h deleted file mode 100644 index 5b07491dcf..0000000000 --- a/camel/camel-mime-part.h +++ /dev/null @@ -1,141 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-mime-part.h : class for a mime part */ - -/* - * - * 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_PART_H -#define CAMEL_MIME_PART_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include -#include "camel-data-wrapper.h" -#include "camel-stream.h" - - -#define CAMEL_MIME_PART_TYPE (camel_mime_part_get_type ()) -#define CAMEL_MIME_PART(obj) (GTK_CHECK_CAST((obj), CAMEL_MIME_PART_TYPE, CamelMimePart)) -#define CAMEL_MIME_PART_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_MIME_PART_TYPE, CamelMimePartClass)) -#define IS_CAMEL_MIME_PART(o) (GTK_CHECK_TYPE((o), CAMEL_MIME_PART_TYPE)) - - -/* Do not change these values directly, you - would regret it one day */ -typedef struct -{ - CamelDataWrapper parent_object; - - GHashTable *headers; - gchar *description; - GMimeContentField *disposition; - gchar *content_id; - gchar *content_MD5; - GList *content_languages; - gchar *encoding; - gchar *filename; - GList *header_lines; - - GMimeContentField *content_type; - CamelDataWrapper *content; /* part real content */ - -} CamelMimePart; - - - -typedef struct { - CamelDataWrapperClass parent_class; - - /* Virtual methods */ - void (*add_header) (CamelMimePart *mime_part, gchar *header_name, gchar *header_value); - void (*remove_header) (CamelMimePart *mime_part, const gchar *header_name); - const gchar * (*get_header) (CamelMimePart *mime_part, const gchar *header_name); - void (*set_description) (CamelMimePart *mime_part, gchar *description); - const gchar * (*get_description) (CamelMimePart *mime_part); - void (*set_disposition) (CamelMimePart *mime_part, gchar *disposition); - const gchar * (*get_disposition) (CamelMimePart *mime_part); - void (*set_filename) (CamelMimePart *mime_part, gchar *filename); - const gchar * (*get_filename) (CamelMimePart *mime_part); - void (*set_content_id) (CamelMimePart *mime_part, gchar *content_id); - const gchar * (*get_content_id) (CamelMimePart *mime_part); - void (*set_content_MD5) (CamelMimePart *mime_part, gchar *content_MD5); - const gchar * (*get_content_MD5) (CamelMimePart *mime_part); - void (*set_encoding) (CamelMimePart *mime_part, gchar *encoding); - const gchar * (*get_encoding) (CamelMimePart *mime_part); - void (*set_content_languages) (CamelMimePart *mime_part, GList *content_languages); - const GList * (*get_content_languages) (CamelMimePart *mime_part); - void (*set_header_lines) (CamelMimePart *mime_part, GList *header_lines); - const GList * (*get_header_lines) (CamelMimePart *mime_part); - void (*set_content_type) (CamelMimePart *mime_part, const gchar *content_type); - GMimeContentField * (*get_content_type) (CamelMimePart *mime_part); - - gboolean (*parse_header_pair) (CamelMimePart *mime_part, gchar *header_name, gchar *header_value); - - const CamelDataWrapper * (*get_content_object) (CamelMimePart *mime_part); - void (*set_content_object) (CamelMimePart *mime_part, CamelDataWrapper *content); - -} CamelMimePartClass; - - - -/* Standard Gtk function */ -GtkType camel_mime_part_get_type (void); - - -/* public methods */ -void camel_mime_part_add_header (CamelMimePart *mime_part, gchar *header_name, gchar *header_value); -void camel_mime_part_remove_header (CamelMimePart *mime_part, const gchar *header_name); -const gchar *camel_mime_part_get_header (CamelMimePart *mime_part, const gchar *header_name); -void camel_mime_part_set_description (CamelMimePart *mime_part, gchar *description); -const gchar *camel_mime_part_get_description (CamelMimePart *mime_part); -void camel_mime_part_set_disposition (CamelMimePart *mime_part, gchar *disposition); -const gchar *camel_mime_part_get_disposition (CamelMimePart *mime_part); -void camel_mime_part_set_filename (CamelMimePart *mime_part, gchar *filename); -const gchar *camel_mime_part_get_filename (CamelMimePart *mime_part); -const gchar *camel_mime_part_get_content_id (CamelMimePart *mime_part); -const gchar *camel_mime_part_get_content_MD5 (CamelMimePart *mime_part); -void camel_mime_part_set_encoding (CamelMimePart *mime_part, gchar *encoding); -const gchar *camel_mime_part_get_encoding (CamelMimePart *mime_part); -void camel_mime_part_set_content_languages (CamelMimePart *mime_part, GList *content_languages); -const GList *camel_mime_part_get_content_languages (CamelMimePart *mime_part); -void camel_mime_part_set_header_lines (CamelMimePart *mime_part, GList *header_lines); -const GList *camel_mime_part_get_header_lines (CamelMimePart *mime_part); - -const CamelDataWrapper *camel_mime_part_get_content_object (CamelMimePart *mime_part); -void camel_mime_part_set_content_object (CamelMimePart *mime_part, CamelDataWrapper *content); - - -/* utility functions */ -void camel_mime_part_set_text (CamelMimePart *camel_mime_part, gchar *text); - - - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* CAMEL_MIME_PART_H */ - diff --git a/camel/camel-multipart.c b/camel/camel-multipart.c deleted file mode 100644 index 490f80e4c0..0000000000 --- a/camel/camel-multipart.c +++ /dev/null @@ -1,466 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-multipart.c : Abstract class for a multipart */ - - -/* - * - * 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 -#include "camel-multipart.h" -#include "camel-log.h" -#include "gmime-content-field.h" -#include "gmime-utils.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 _construct_from_stream (CamelDataWrapper *data_wrapper, CamelStream *stream); - -static CamelDataWrapperClass *parent_class=NULL; - -/* Returns the class for a CamelMultipart */ -#define CMP_CLASS(so) CAMEL_MULTIPART_CLASS (GTK_OBJECT(so)->klass) - -/* Returns the class for a CamelDataWrapper */ -#define CDW_CLASS(so) CAMEL_DATA_WRAPPER_CLASS (GTK_OBJECT(so)->klass) - - -static void -camel_multipart_class_init (CamelMultipartClass *camel_multipart_class) -{ - CamelDataWrapperClass *camel_data_wrapper_class = CAMEL_DATA_WRAPPER_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; - - /* virtual method overload */ - camel_data_wrapper_class->write_to_stream = _write_to_stream; - camel_data_wrapper_class->construct_from_stream = _construct_from_stream; -} - -static void -camel_multipart_init (gpointer object, gpointer klass) -{ - CamelMultipart *multipart = CAMEL_MULTIPART (object); - camel_data_wrapper_set_mime_type ( CAMEL_DATA_WRAPPER (multipart), "multipart"); - camel_multipart_set_boundary (multipart, "__camel_boundary__"); - -} - - - - -GtkType -camel_multipart_get_type (void) -{ - static GtkType camel_multipart_type = 0; - - if (!camel_multipart_type) { - GtkTypeInfo camel_multipart_info = - { - "CamelMultipart", - sizeof (CamelMultipart), - sizeof (CamelMultipartClass), - (GtkClassInitFunc) camel_multipart_class_init, - (GtkObjectInitFunc) camel_multipart_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_multipart_type = gtk_type_unique (camel_data_wrapper_get_type (), &camel_multipart_info); - } - - return camel_multipart_type; -} - - -CamelMultipart * -camel_multipart_new () -{ - CamelMultipart *multipart; - CAMEL_LOG_FULL_DEBUG ("CamelMultipart:: Entering new()\n"); - - 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) -{ - multipart->parts = g_list_append (multipart->parts, part); -} - -void -camel_multipart_add_part (CamelMultipart *multipart, CamelMimeBodyPart *part) -{ - CMP_CLASS (multipart)->add_part (multipart, part); -} - - -static void -_add_part_at (CamelMultipart *multipart, CamelMimeBodyPart *part, guint index) -{ - multipart->parts = g_list_insert (multipart->parts, part, index); -} - -void -camel_multipart_add_part_at (CamelMultipart *multipart, CamelMimeBodyPart *part, guint index) -{ - CMP_CLASS (multipart)->add_part_at (multipart, part, index); -} - -static void -_remove_part (CamelMultipart *multipart, CamelMimeBodyPart *part) -{ - if (!multipart->parts) { - CAMEL_LOG_FULL_DEBUG ("CamelMultipart::remove_part part list id void\n"); - return; - } - multipart->parts = g_list_remove (multipart->parts, part); -} - -void -camel_multipart_remove_part (CamelMultipart *multipart, CamelMimeBodyPart *part) -{ - CMP_CLASS (multipart)->remove_part (multipart, part); -} - - -static CamelMimeBodyPart * -_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; - } - - parts_list = multipart->parts; - part_to_remove = g_list_nth (parts_list, index); - if (!part_to_remove) { - CAMEL_LOG_WARNING ("CamelMultipart::remove_part_at : part to remove is NULL\n"); - CAMEL_LOG_FULL_DEBUG ("CamelMultipart::remove_part_at : index = %d, number of parts=%d\n", - index, g_list_length (parts_list)); - return NULL; - } - removed_body_part = CAMEL_MIME_BODY_PART (part_to_remove->data); - - multipart->parts = g_list_remove_link (parts_list, part_to_remove); - g_list_free_1 (part_to_remove); - - CAMEL_LOG_FULL_DEBUG ("CamelMultipart:: Leaving remove_part_at\n"); - return removed_body_part; - -} - -CamelMimeBodyPart * -camel_multipart_remove_part_at (CamelMultipart *multipart, guint index) -{ - return CMP_CLASS (multipart)->remove_part_at (multipart, index); -} - - -static CamelMimeBodyPart * -_get_part (CamelMultipart *multipart, guint index) -{ - GList *part; - if (!(multipart->parts)) { - CAMEL_LOG_FULL_DEBUG ("CamelMultipart::get_part part list is void \n"); - return NULL; - } - - part = g_list_nth (multipart->parts, index); - if (part) return CAMEL_MIME_BODY_PART (part->data); - else { - CAMEL_LOG_FULL_DEBUG ("CamelMultipart::get_part part number %d not found\n", index); - return NULL; - } -} - -CamelMimeBodyPart * -camel_multipart_get_part (CamelMultipart *multipart, guint index) -{ - return CMP_CLASS (multipart)->get_part (multipart, index); -} - - -static guint -_get_number (CamelMultipart *multipart) -{ - return g_list_length (multipart->parts); -} - -guint -camel_multipart_get_number (CamelMultipart *multipart) -{ - return CMP_CLASS (multipart)->get_number (multipart); -} - - -static void -_set_parent (CamelMultipart *multipart, CamelMimePart *parent) -{ - multipart->parent = parent; -} - -void -camel_multipart_set_parent (CamelMultipart *multipart, CamelMimePart *parent) -{ - CMP_CLASS (multipart)->set_parent (multipart, parent); -} - - -static CamelMimePart * -_get_parent (CamelMultipart *multipart) -{ - return multipart->parent; -} - - -CamelMimePart * -camel_multipart_get_parent (CamelMultipart *multipart) -{ - return CMP_CLASS (multipart)->get_parent (multipart); -} - - - - - -static void -_set_boundary (CamelMultipart *multipart, gchar *boundary) -{ - gmime_content_field_set_parameter (CAMEL_DATA_WRAPPER (multipart)->mime_type, "boundary", boundary); -} - -void -camel_multipart_set_boundary (CamelMultipart *multipart, gchar *boundary) -{ - CMP_CLASS (multipart)->set_boundary (multipart, boundary); -} - - -static const gchar * -_get_boundary (CamelMultipart *multipart) -{ - const gchar *boundary; - CAMEL_LOG_FULL_DEBUG ("Entering CamelMultipart::_get_boundary\n"); - if (!CAMEL_DATA_WRAPPER (multipart)->mime_type) { - CAMEL_LOG_WARNING ("CamelMultipart::_get_boundary CAMEL_DATA_WRAPPER (multipart)->mime_type is NULL\n"); - return; - } - boundary = gmime_content_field_get_parameter (CAMEL_DATA_WRAPPER (multipart)->mime_type, "boundary"); - CAMEL_LOG_FULL_DEBUG ("Leaving CamelMultipart::_get_boundary\n"); - return boundary; -} - - -const gchar * -camel_multipart_get_boundary (CamelMultipart *multipart) -{ - return CMP_CLASS (multipart)->get_boundary (multipart); -} - - -struct _print_part_user_data { - CamelStream *stream; - const gchar *boundary; -}; - - - -static void -_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; - - 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) -{ - CamelMultipart *multipart = CAMEL_MULTIPART (data_wrapper); - struct _print_part_user_data ud; - const gchar *boundary; - - CAMEL_LOG_FULL_DEBUG ("Entering CamelMultipart::_write_to_stream entering\n"); - boundary = camel_multipart_get_boundary (multipart); - CAMEL_LOG_FULL_DEBUG ("Entering CamelMultipart::_write_to_stream, boundary = %s\n", boundary); - g_return_if_fail (boundary); - 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); - camel_stream_write_strings (stream, "\n--", boundary, "--\n", NULL); - if (multipart->postface) camel_stream_write_strings (stream, multipart->postface, NULL); - CAMEL_LOG_FULL_DEBUG ("Leaving CamelMultipart::_write_to_stream leaving \n"); -} - - - - -/** - * _read_part: read one part in a multipart environement. - * @part: GString to add the part to - * @stream: the stream to read the lines from. - * @normal_boundary: end of part bundary. - * @end_boundary: end of multipart boundary. - * - * This routine is a bit special: RFC 2046 says that, in a multipart - * environment, the last crlf before a boundary belongs to the boundary. - * Thus, if there is no blank line before the boundary, the last crlf - * of the last line of the part is removed. - * - * Return value: true if the last boundary element has been found or if no more data was available from the stream, flase otherwise - **/ - -static gboolean -_read_part (GString *new_part, CamelStream *stream, gchar *normal_boundary, gchar *end_boundary) -{ - gchar *new_line; - gboolean end_of_part = FALSE; - gboolean last_part = FALSE; - - /* RFC 2046 precises that when parsing the content of a multipart - * element, the program should not think it will find the last bounndary, - * and in particular, the message could have been damaged during - * transport, the parsing should be OK */ - CAMEL_LOG_FULL_DEBUG ("CamelMultipart:: Entering _read_part\n"); -#if 0 - do { - new_line = gmime_read_line_from_stream (stream); - printf ("++ new line = \"%s\"\n", new_line); - if (new_line) { - end_of_part = (strcmp (new_line, normal_boundary) == 0); - last_part = (strcmp (new_line, end_boundary) == 0); - if (!end_of_part && !last_part) { - if (pending_crlf) { - new_part = g_string_append_c (new_part, '\n'); - pending_crlf = FALSE; - } - line_length = strlen (new_line); - if (new_line[line_length-1]='\n') { - pending_crlf = TRUE; - new_line[line_length-1]='\0'; - } - new_part = g_string_append (new_part, new_line); - } - } - - } ; -#endif - new_line = gmime_read_line_from_stream (stream); - printf ("== new line = \"%s\"\n", new_line); - while (new_line && !end_of_part && !last_part) { - printf ("++ new line = \"%s\"\n", new_line); - end_of_part = (strcmp (new_line, normal_boundary) == 0); - last_part = (strcmp (new_line, end_boundary) == 0); - if (!end_of_part && !last_part) - new_part = g_string_append (new_part, new_line); - new_line = gmime_read_line_from_stream (stream); - } - CAMEL_LOG_FULL_DEBUG ("CamelMultipart:: Leaving _read_part\n"); - return (last_part && !new_line); -} - -static void -_construct_from_stream (CamelDataWrapper *data_wrapper, CamelStream *stream) -{ - CamelMultipart *multipart = CAMEL_MULTIPART (data_wrapper); - const gchar *boundary; - gchar *real_boundary_line; - gchar *end_boundary_line; - GString *new_part; - gboolean end_of_multipart; - CamelMimeBodyPart *body_part; - - CAMEL_LOG_FULL_DEBUG ("Entering CamelMultipart::_construct_from_stream\n"); - 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); - - new_part = g_string_new (""); - - /* read the prefix if any */ - end_of_multipart = _read_part (new_part, stream, real_boundary_line, end_boundary_line); - 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) { - CAMEL_LOG_FULL_DEBUG ("CamelMultipart::construct_from_stream, detected a new part\n"); - g_string_assign (new_part, ""); - body_part = camel_mime_body_part_new (); - //camel_data_wrapper_construct_from_stream (); - camel_multipart_add_part (multipart, body_part); - end_of_multipart = _read_part (new_part, stream, real_boundary_line, end_boundary_line); - } - - g_string_assign (new_part, ""); - _read_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::_construct_from_stream\n"); -} diff --git a/camel/camel-multipart.h b/camel/camel-multipart.h deleted file mode 100644 index 64f98d0c65..0000000000 --- a/camel/camel-multipart.h +++ /dev/null @@ -1,105 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-multipart.h : class for a multipart */ - -/* - * - * 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_MULTIPART_H -#define CAMEL_MULTIPART_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -typedef struct _CamelMultipart CamelMultipart; - -#include -#include "camel-mime-part.h" -#include "camel-mime-body-part.h" - - -#define CAMEL_MULTIPART_TYPE (camel_multipart_get_type ()) -#define CAMEL_MULTIPART(obj) (GTK_CHECK_CAST((obj), CAMEL_MULTIPART_TYPE, CamelMultipart)) -#define CAMEL_MULTIPART_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_MULTIPART_TYPE, CamelMultipartClass)) -#define IS_CAMEL_MULTIPART(o) (GTK_CHECK_TYPE((o), CAMEL_MULTIPART_TYPE)) - - -struct _CamelMultipart -{ - CamelDataWrapper parent_object; - - CamelMimePart *parent; - GList *parts; - gchar *boundary; - gchar *preface; - gchar *postface; - -}; - - - -typedef struct { - CamelDataWrapperClass parent_class; - - /* Virtual methods */ - void (*add_part) (CamelMultipart *multipart, CamelMimeBodyPart *part); - void (*add_part_at) (CamelMultipart *multipart, CamelMimeBodyPart *part, guint index); - void (*remove_part) (CamelMultipart *multipart, CamelMimeBodyPart *part); - CamelMimeBodyPart * (*remove_part_at) (CamelMultipart *multipart, guint index); - CamelMimeBodyPart * (*get_part) (CamelMultipart *multipart, guint index); - guint (*get_number) (CamelMultipart *multipart); - void (*set_parent) (CamelMultipart *multipart, CamelMimePart *parent); - CamelMimePart * (*get_parent) (CamelMultipart *multipart); - void (*set_boundary) (CamelMultipart *multipart, gchar *boundary); - const gchar * (*get_boundary) (CamelMultipart *multipart); - -} CamelMultipartClass; - - -/* Standard Gtk function */ -GtkType camel_multipart_get_type (void); - - -/* public methods */ -CamelMultipart *camel_multipart_new (); -void camel_multipart_add_part (CamelMultipart *multipart, CamelMimeBodyPart *part); -void camel_multipart_add_part_at (CamelMultipart *multipart, CamelMimeBodyPart *part, guint index); -void camel_multipart_remove_part (CamelMultipart *multipart, CamelMimeBodyPart *part); -CamelMimeBodyPart *camel_multipart_remove_part_at (CamelMultipart *multipart, guint index); -CamelMimeBodyPart *camel_multipart_get_part (CamelMultipart *multipart, guint index); -guint camel_multipart_get_number (CamelMultipart *multipart); -void camel_multipart_set_parent (CamelMultipart *multipart, CamelMimePart *parent); -CamelMimePart *camel_multipart_get_parent (CamelMultipart *multipart); -void camel_multipart_set_boundary (CamelMultipart *multipart, gchar *boundary); -const gchar *camel_multipart_get_boundary (CamelMultipart *multipart); - - - - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* CAMEL_MULTIPART_H */ - diff --git a/camel/camel-provider.c b/camel/camel-provider.c deleted file mode 100644 index 238b83ce29..0000000000 --- a/camel/camel-provider.c +++ /dev/null @@ -1,29 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-provider.c : provider management */ - -/* - * - * 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 - */ - - - -/* - - Here will be the routine to load providers (plugins) - and register them */ diff --git a/camel/camel-provider.h b/camel/camel-provider.h deleted file mode 100644 index 54b9ef2a2a..0000000000 --- a/camel/camel-provider.h +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-provider.h : provider management */ - -/* - * - * 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_PROVIDER_H -#define CAMEL_PROVIDER_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -typedef enum { - PROVIDER_STORE, - PROVIDER_TRANSPORT -} ProviderType; - - -typedef struct { - GtkType object_type; /* used to create instance of the provider */ - ProviderType provider_type; /* is a store or a transport */ - gchar *protocol; /* name of the protocol ("imap"/"smtp"/"mh" ...) */ - gchar *provider_name; /* name of the provider ("Raymond the imap provider") */ - gchar *description; /* Useful when multiple providers are available for a same protocol */ -} CamelProvider; - - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* CAMEL_PROVIDER_H */ diff --git a/camel/camel-service.c b/camel/camel-service.c deleted file mode 100644 index c0f436bb89..0000000000 --- a/camel/camel-service.c +++ /dev/null @@ -1,277 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camelService.c : Abstract class for an email service */ - -/* - * - * 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 -#include "camel-service.h" - -static GtkObjectClass *parent_class=NULL; - -/* Returns the class for a CamelService */ -#define CSERV_CLASS(so) CAMEL_SERVICE_CLASS (GTK_OBJECT(so)->klass) - -static void _connect(CamelService *service); -static void _connect_to_with_login_passwd (CamelService *service, gchar *host, gchar *login, gchar *passwd); -static void _connect_to_with_login_passwd_port (CamelService *service, gchar *host, gchar *login, gchar *passwd, guint port); -static gboolean _is_connected (CamelService *service); -static void _set_connected (CamelService *service, gboolean state); -static const gchar *_get_url (CamelService *service); - -static void -camel_service_class_init (CamelServiceClass *camel_service_class) -{ - parent_class = gtk_type_class (gtk_object_get_type ()); - - /* virtual method definition */ - camel_service_class->connect = _connect; - camel_service_class->connect_to_with_login_passwd = _connect_to_with_login_passwd; - camel_service_class->connect_to_with_login_passwd_port = _connect_to_with_login_passwd_port; - camel_service_class->is_connected = _is_connected; - camel_service_class->set_connected = _set_connected; - camel_service_class->get_url = _get_url; - - /* virtual method overload */ -} - - - - - - - -GtkType -camel_service_get_type (void) -{ - static GtkType camel_service_type = 0; - - if (!camel_service_type) { - GtkTypeInfo camel_service_info = - { - "CamelService", - sizeof (CamelService), - sizeof (CamelServiceClass), - (GtkClassInitFunc) camel_service_class_init, - (GtkObjectInitFunc) NULL, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_service_type = gtk_type_unique (gtk_object_get_type (), &camel_service_info); - } - - return camel_service_type; -} - - - - - -/** - * _connect : connect to a service - * - * connect to the service using the parameters - * stored in the session it is initialized with - * WARNING: session not implemented for the moment - * - * @service: object to connect - **/ -static void -_connect (CamelService *service) -{ - CSERV_CLASS(service)->set_connected(service, TRUE); -} - - -/** - * camel_service_connect : connect to a service - * - * connect to the service using the parameters - * stored in the session it is initialized with - * WARNING: session not implemented for the moment - * - * @service: object to connect to - **/ -void -camel_service_connect (CamelService *service) -{ - CSERV_CLASS(service)->connect(service); -} - - - -/** - * _connect_to: connect to the specified address - * - * Connect to the service, but do not use the session - * default parameters to retrieve server's address - * - * @service: object to connect - * @host: host to connect to - * @login: user name used to log in - * @passwd: password used to log in - **/ -static void -_connect_to_with_login_passwd (CamelService *service, gchar *host, gchar *login, gchar *passwd) -{ - CSERV_CLASS(service)->set_connected(service, TRUE); -} - -/** - * camel_service_connect_to_with_login_passwd: connect a service - * @service: the service to connect - * @host: host to connect to - * @login: login to connect with - * @passwd: password to connect with - * - * Connect to a service, but do not use the session - * default parameters to retrieve server's address - * - **/ -void -camel_service_connect_to_with_login_passwd (CamelService *service, gchar *host, gchar *login, gchar *passwd) -{ - CSERV_CLASS(service)->connect_to_with_login_passwd (service, host, login, passwd); -} - - - -/** - * _connect_to:login:password : connect to the specified address - * - * Connect to the service, but do not use the session - * default parameters to retrieve server's address - * - * @service: object to connect - * @host: host to connect to - * @login: user name used to log in - * @passwd: password used to log in - * @port: port to connect to - * - **/ -static void -_connect_to_with_login_passwd_port(CamelService *service, gchar *host, gchar *login, gchar *passwd, guint port) -{ - CSERV_CLASS(service)->set_connected(service, TRUE); -} - - -/** - * camel_service_connect_to_with_login_passwd_port: connect a service - * @service: the service to connect - * @host: host to connect to - * @login: login to connect with - * @passwd: password to connect with - * @port: port to connect to - * - * Connect to a service, but do not use the session - * default parameters to retrieve server's address - * - **/ -void -camel_service_connect_to_with_login_passwd_port (CamelService *service, gchar *host, gchar *login, gchar *passwd, guint port) -{ - CSERV_CLASS(service)->connect_to_with_login_passwd_port (service, host, login, passwd, port); -} - - - - -/** - * _is_connected: test if the service object is connected - * - * - * @service: object to test - * - **/ -static gboolean -_is_connected (CamelService *service) -{ - return service->connected; -} - - -/** - * camel_service_is_connected: test if a service object is connected - * - * @service: the service - * - * - * - * Return value: TRUE is the service is connected - **/ -gboolean -camel_service_is_connected (CamelService *service) -{ - return CSERV_CLASS(service)->is_connected(service); -} - - -/** - * _set_connected: set the connected state - * - * This routine has to be called by providers to set the - * connection state, mainly when the service is disconnected - * wheras the close() method has not been called. - * - * @service: object to set the state of - * @state: connected/disconnected - * - **/ -static void -_set_connected (CamelService *service, gboolean state) -{ - service->connected = state; -} - - - -/** - * _get_url: get url representing a service - * @service: the service - * - * This method merely returns the "url" field. Subclasses - * may provide more active implementations. - * - * Return value: - **/ -static const gchar * -_get_url (CamelService *service) -{ - return service->url; -} - -/** - * camel_service_get_url: get the url representing a service - * @service: the service - * - * returns the URL representing a service. For security reasons - * This routine may not always return the password. - * - * Return value: the url name - **/ -const gchar * -camel_service_get_url (CamelService *service) -{ - return CSERV_CLASS(service)->get_url(service); -} - - diff --git a/camel/camel-service.h b/camel/camel-service.h deleted file mode 100644 index 7831699bbf..0000000000 --- a/camel/camel-service.h +++ /dev/null @@ -1,82 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-service.h : Abstract class for an email service */ - -/* - * - * 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_SERVICE_H -#define CAMEL_SERVICE_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include - -#define CAMEL_SERVICE_TYPE (camel_service_get_type ()) -#define CAMEL_SERVICE(obj) (GTK_CHECK_CAST((obj), CAMEL_SERVICE_TYPE, CamelService)) -#define CAMEL_SERVICE_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_SERVICE_TYPE, CamelServiceClass)) -#define IS_CAMEL_SERVICE(o) (GTK_CHECK_TYPE((o), CAMEL_SERVICE_TYPE)) - - - -typedef struct { - GtkObject parent_object; - - gboolean connected; - gchar *url; /* This may be a full object ? */ - -} CamelService; - - - -typedef struct { - GtkObjectClass parent_class; - - void (*connect) (CamelService *service); - void (*connect_to_with_login_passwd) (CamelService *service, gchar *host, gchar *login, gchar *passwd); - void (*connect_to_with_login_passwd_port) (CamelService *service, gchar *host, gchar *login, gchar *passwd, guint port); - gboolean (*is_connected) (CamelService *service); - void (*set_connected) (CamelService *service, gboolean state); - const gchar * (*get_url) (CamelService *service); - -} CamelServiceClass; - - - - -/* public methods */ -void camel_service_connect (CamelService *service); -gboolean camel_service_is_connected (CamelService *service); -void camel_service_connect_to_with_login_passwd (CamelService *service, gchar *host, gchar *login, gchar *passwd); -void camel_service_connect_to_with_login_passwd_port (CamelService *service, gchar *host, gchar *login, gchar *passwd, guint port); -const gchar *camel_service_get_url (CamelService *service); -/* Standard Gtk function */ -GtkType camel_service_get_type (void); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* CAMEL_SERVICE_H */ - diff --git a/camel/camel-session.c b/camel/camel-session.c deleted file mode 100644 index f9916df6f6..0000000000 --- a/camel/camel-session.c +++ /dev/null @@ -1,131 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-session.c : Abstract class for an email session */ - -/* - * - * 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 -#include "camel-session.h" - -static GtkObjectClass *parent_class=NULL; - -/* Returns the class for a CamelSession */ -#define CSS_CLASS(so) CAMEL_SESSION_CLASS (GTK_OBJECT(so)->klass) - - -static void -camel_session_class_init (CamelSessionClass *camel_session_class) -{ - parent_class = gtk_type_class (gtk_object_get_type ()); - - /* virtual method definition */ - /* virtual method overload */ -} - - - - - -static void -camel_session_init (CamelSession *session) -{ - session->store_provider_list = g_hash_table_new (g_str_hash, g_str_equal); - session->transport_provider_list = g_hash_table_new (g_str_hash, g_str_equal); -} - - - -GtkType -camel_session_get_type (void) -{ - static GtkType camel_session_type = 0; - - if (!camel_session_type) { - GtkTypeInfo camel_session_info = - { - "CamelSession", - sizeof (CamelSession), - sizeof (CamelSessionClass), - (GtkClassInitFunc) camel_session_class_init, - (GtkObjectInitFunc) camel_session_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_session_type = gtk_type_unique (gtk_object_get_type (), &camel_session_info); - } - - return camel_session_type; -} - - -/** - * camel_session_set_provider: set the default provider for a protocol - * @session: session object for wich the provider will the default - * @provider: provider object - * - * Set the default implementation for a protocol. The protocol - * is determined by provider->protocol field (See CamelProtocol). - * It overrides the default provider for this protocol. - * - **/ -void -camel_session_set_provider (CamelSession *session, CamelProvider *provider) -{ - GHashTable *table; - - g_assert(session); - g_assert(provider); - - if (provider->provider_type == PROVIDER_STORE) - table = session->store_provider_list; - else - table = session->transport_provider_list; - - g_hash_table_insert (table, (gpointer)(provider->protocol), (gpointer)(provider)); - -} - - - - - -/** - * camel_session_get_store_from_provider: create a folder instance for a given provider - * @session: session object the folder will be initialized with - * @provider: provider folder to instantiate - * - * - * - * Return value: the newly instantiated folder - **/ -CamelStore * -camel_session_get_store_from_provider (CamelSession *session, CamelProvider *provider) -{ - CamelStore *store; - - g_assert(session); - g_assert(provider); - - store = CAMEL_STORE (gtk_object_new (provider->object_type, NULL)); -#warning set the url to a useful value. - camel_store_init(store, session, NULL); - return store; -} diff --git a/camel/camel-session.h b/camel/camel-session.h deleted file mode 100644 index 0fb881ea72..0000000000 --- a/camel/camel-session.h +++ /dev/null @@ -1,82 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-session.h : Abstract class for an email session */ - -/* - * - * 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_SESSION_H -#define CAMEL_SESSION_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include - -typedef struct _CamelSession CamelSession; - -#include "camel-provider.h" -#include "camel-store.h" - -#define CAMEL_SESSION_TYPE (camel_session_get_type ()) -#define CAMEL_SESSION(obj) (GTK_CHECK_CAST((obj), CAMEL_SESSION_TYPE, CamelSession)) -#define CAMEL_SESSION_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_SESSION_TYPE, CamelSessionClass)) -#define IS_CAMEL_SESSION(o) (GTK_CHECK_TYPE((o), CAMEL_SESSION_TYPE)) - - - - -struct _CamelSession -{ - GtkObject parent_object; - GHashTable *store_provider_list; /* providers are identified by their protocol */ - GHashTable *transport_provider_list; - - -}; - - - -typedef struct { - GtkObjectClass parent_class; - - /* Virtual methods */ - -} CamelSessionClass; - - -/* public methods */ - -/* Standard Gtk function */ -GtkType camel_session_get_type (void); - - - -void camel_session_set_provider (CamelSession *session, CamelProvider *provider); - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* CAMEL_SESSION_H */ diff --git a/camel/camel-simple-data-wrapper.c b/camel/camel-simple-data-wrapper.c deleted file mode 100644 index eaf62bb0a7..0000000000 --- a/camel/camel-simple-data-wrapper.c +++ /dev/null @@ -1,181 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-simple-data-wrapper.c : simple implementation of a data wrapper */ -/* store the data in a glib byte array */ - -/* - * - * 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 -#include "camel-simple-data-wrapper.h" -#include "camel-log.h" - -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 -camel_simple_data_wrapper_class_init (CamelSimpleDataWrapperClass *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 definition */ - - /* virtual method overload */ - camel_data_wrapper_class->write_to_stream = _write_to_stream; - camel_data_wrapper_class->construct_from_stream = _construct_from_stream; -} - - - - - - -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; -} - - - -/** - * camel_simple_data_wrapper_new: create a new CamelSimpleDataWrapper object - * - * - * - * Return value: - **/ -CamelSimpleDataWrapper * -camel_simple_data_wrapper_new () -{ - CamelSimpleDataWrapper *simple_data_wrapper; - CAMEL_LOG_FULL_DEBUG ("CamelSimpleDataWrapper:: Entering new()\n"); - - simple_data_wrapper = (CamelSimpleDataWrapper *)gtk_type_new (CAMEL_SIMPLE_DATA_WRAPPER_TYPE); - CAMEL_LOG_FULL_DEBUG ("CamelSimpleDataWrapper:: Leaving new()\n"); - return simple_data_wrapper; -} - - - -static void -_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"); - - g_assert (data_wrapper); - g_assert (stream); - g_assert (simple_data_wrapper->byte_array); - array = simple_data_wrapper->byte_array; - if (array->len) - camel_stream_write (stream, (gchar *)array->data, array->len); - - CAMEL_LOG_FULL_DEBUG ("CamelSimpleDataWrapper:: Leaving _write_to_stream\n"); -} - - - - -#define _CMSDW_TMP_BUF_SIZE 100 -static void -_construct_from_stream (CamelDataWrapper *data_wrapper, CamelStream *stream) -{ - CamelSimpleDataWrapper *simple_data_wrapper = CAMEL_SIMPLE_DATA_WRAPPER (data_wrapper); - guint current_index; - guint nb_bytes_read; - guint nb_bytes_left; - static gchar *tmp_buf; - GByteArray *array; - CAMEL_LOG_FULL_DEBUG ("CamelSimpleDataWrapper:: Entering _construct_from_stream\n"); - - g_assert (data_wrapper); - g_assert (stream); - - if (!tmp_buf) tmp_buf = g_new (gchar, _CMSDW_TMP_BUF_SIZE); - - array = simple_data_wrapper->byte_array; - if (array) - g_byte_array_free (array, FALSE); - - array = g_byte_array_new(); - simple_data_wrapper->byte_array = array; - do { - nb_bytes_read = camel_stream_read (stream, tmp_buf, _CMSDW_TMP_BUF_SIZE); - if (nb_bytes_read) g_byte_array_append (array, tmp_buf, nb_bytes_read); - } while (nb_bytes_read); - - CAMEL_LOG_FULL_DEBUG ("CamelSimpleDataWrapper:: Leaving _construct_from_stream\n"); -} - - - - -/** - * camel_simple_data_wrapper_set_text: set some text as data wrapper content - * @simple_data_wrapper: SimpleDataWrapper object - * @text: the text to use - * - * Utility routine used to set up the content of a SimpleDataWrapper object - * to be a character string. - **/ -void -camel_simple_data_wrapper_set_text (CamelSimpleDataWrapper *simple_data_wrapper, const gchar *text) -{ - GByteArray *array; - CAMEL_LOG_FULL_DEBUG ("CamelSimpleDataWrapper:: Entering set_text\n"); - - array = simple_data_wrapper->byte_array; - if (array) { - CAMEL_LOG_FULL_DEBUG ("CamelSimpleDataWrapper::set_text freeing old byte array\n"); - g_byte_array_free (array, FALSE); - } - - array = g_byte_array_new (); - simple_data_wrapper->byte_array = array; - - g_byte_array_append (array, text, strlen (text)); - - CAMEL_LOG_FULL_DEBUG ("CamelSimpleDataWrapper:: Entering set_text\n"); -} - diff --git a/camel/camel-simple-data-wrapper.h b/camel/camel-simple-data-wrapper.h deleted file mode 100644 index eeefb48921..0000000000 --- a/camel/camel-simple-data-wrapper.h +++ /dev/null @@ -1,79 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-simple-data-wrapper.c : simple implementation of a data wrapper */ -/* store the data in a glib byte array */ - -/* - * - * 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_SIMPLE_DATA_WRAPPER_H -#define CAMEL_SIMPLE_DATA_WRAPPER_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include -#include -#include "camel-stream.h" -#include "camel-data-wrapper.h" - - - -#define CAMEL_SIMPLE_DATA_WRAPPER_TYPE (camel_simple_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 IS_CAMEL_SIMPLE_DATA_WRAPPER(o) (GTK_CHECK_TYPE((o), CAMEL_SIMPLE_DATA_WRAPPER_TYPE)) - - -typedef struct -{ - CamelDataWrapper parent_object; - - GByteArray *byte_array; - -} CamelSimpleDataWrapper; - - - -typedef struct { - CamelDataWrapperClass parent_class; - - -} CamelSimpleDataWrapperClass; - - - -/* Standard Gtk function */ -GtkType camel_simple_data_wrapper_get_type (void); - - -/* public methods */ - -CamelSimpleDataWrapper *camel_simple_data_wrapper_new (); -void camel_simple_data_wrapper_set_text (CamelSimpleDataWrapper *simple_data_wrapper, const gchar *text); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* CAMEL_SIMPLE_DATA_WRAPPER_H */ diff --git a/camel/camel-store.c b/camel/camel-store.c deleted file mode 100644 index c58f14c110..0000000000 --- a/camel/camel-store.c +++ /dev/null @@ -1,221 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camelStore.c : Abstract class for an email store */ - -/* - * - * 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 -#include "camel-store.h" - -static GtkObjectClass *parent_class=NULL; - -/* Returns the class for a CamelStore */ -#define CS_CLASS(so) CAMEL_STORE_CLASS (GTK_OBJECT(so)->klass) - -static void _set_separator(CamelStore *store, gchar sep); -static CamelFolder *_get_root_folder(CamelStore *store); -static CamelFolder *_get_default_folder(CamelStore *store); -static void _init(CamelStore *store, CamelSession *session, gchar *url_name); - - - -static void -camel_store_class_init (CamelStoreClass *camel_store_class) -{ - parent_class = gtk_type_class (camel_service_get_type ()); - - /* virtual method definition */ - camel_store_class->init = _init; - camel_store_class->set_separator = _set_separator; - camel_store_class->get_separator = camel_store_get_separator; - camel_store_class->get_folder = camel_store_get_folder; - camel_store_class->get_root_folder = _get_root_folder; - camel_store_class->get_default_folder = _get_default_folder; - /* virtual method overload */ -} - - - - - - - -GtkType -camel_store_get_type (void) -{ - static GtkType camel_store_type = 0; - - if (!camel_store_type) { - GtkTypeInfo camel_store_info = - { - "CamelStore", - sizeof (CamelStore), - sizeof (CamelStoreClass), - (GtkClassInitFunc) camel_store_class_init, - (GtkObjectInitFunc) NULL, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_store_type = gtk_type_unique (CAMEL_SERVICE_TYPE, &camel_store_info); - } - - return camel_store_type; -} - - - - - -/** - * camel_store_init: call store's init method - * @store: the store to initialize - * @session: session which instantiates the store - * @url_name: URL defining the store - * - * This routine is called by the session object from which this - * store is created. It must not be called directly. - * - **/ -void -camel_store_init(CamelStore *store, CamelSession *session, gchar *url_name) -{ - g_assert(store); - CS_CLASS(store)->init (store, session, url_name); -} - - -/** - * init: method called by a session object to - * initialize a store object - * @store: the store to initialize - * @session: session which instantiates the store - * @url_name: URL defining the store - * - * This routine is called by the session object from which this - * store is created. Be careful, @url_name is used as a private field - * of the store object. - * - **/ -static void -_init (CamelStore *store, CamelSession *session, gchar *url_name) -{ - - - g_assert(session); - g_assert(url_name); - - store->session = session; - store->url_name = url_name; -} - - - -/** - * camel_store_set_separator: set the character which separates this folder - * path from the folders names in a lower level of hierarchy. - * - * @store: - * @sep: - * - **/ -static void -_set_separator (CamelStore *store, gchar sep) -{ - store->separator = sep; -} - - - -/** - * camel_store_get_separator: return the character which separates this folder - * path from the folders names in a lower level of hierarchy. - * - * @store: store - * - **/ -gchar -camel_store_get_separator (CamelStore *store) -{ - g_assert(store); - return store->separator; -} - - - - -/** - * camel_store_get_folder: return the folder corresponding to a path. - * - * Returns the folder corresponding to the path "name". - * If the path begins with the separator caracter, it - * is relative to the root folder. Otherwise, it is - * relative to the default folder. - * The folder does not necessarily exist on the store. - * To make sure it already exists, use its "exists" method. - * If it does not exist, you can create it with its - * "create" method. - * - * @store: store - * @folder_name: name of the folder to get - * - * Return value: the folder - **/ -CamelFolder * -camel_store_get_folder (CamelStore *store, gchar *folder_name) -{ - -#warning fill this part in. - return NULL; -} - - -/** - * camel_store_get_root_folder : return the toplevel folder - * - * Returns the folder which is at the top of the folder - * hierarchy. This folder is generally different from - * the default folder. - * - * @Return value: the tolevel folder. - **/ -static CamelFolder * -_get_root_folder (CamelStore *store) -{ - return NULL; -} - -/** - * camel_store_get_default_folder : return the store default folder - * - * The default folder is the folder which is presented - * to the user in the default configuration. The default - * is often the root folder. - * - * @Return value: the default folder. - **/ -static CamelFolder * -_get_default_folder (CamelStore *store) -{ - return NULL; -} - - - diff --git a/camel/camel-store.h b/camel/camel-store.h deleted file mode 100644 index 38fb0f10f7..0000000000 --- a/camel/camel-store.h +++ /dev/null @@ -1,85 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-store.h : Abstract class for an email store */ - -/* - * - * 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_STORE_H -#define CAMEL_STORE_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include - -typedef struct _CamelStore CamelStore; - -#include "camel-folder.h" -#include "camel-service.h" -#include "camel-session.h" - -#define CAMEL_STORE_TYPE (camel_store_get_type ()) -#define CAMEL_STORE(obj) (GTK_CHECK_CAST((obj), CAMEL_STORE_TYPE, CamelStore)) -#define CAMEL_STORE_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_STORE_TYPE, CamelStoreClass)) -#define IS_CAMEL_STORE(o) (GTK_CHECK_TYPE((o), CAMEL_STORE_TYPE)) - - -struct _CamelStore -{ - CamelService parent_object; - - CamelSession *session; - gchar *url_name; - gchar separator; -}; - - - -typedef struct { - CamelServiceClass parent_class; - - void (*init) (CamelStore *store, CamelSession *session, gchar *url_name); - void (*set_separator) (CamelStore *store, gchar sep); - gchar (*get_separator) (CamelStore *store); - CamelFolder * (*get_folder) (CamelStore *store, gchar *folder_name); - CamelFolder * (*get_root_folder) (CamelStore *store); - CamelFolder * (*get_default_folder) (CamelStore *store); - -} CamelStoreClass; - - -/* public methods */ - -/* Standard Gtk function */ -GtkType camel_store_get_type (void); - -void camel_store_init(CamelStore *store, CamelSession *session, gchar *url_name); -CamelFolder *camel_store_get_folder(CamelStore *store, gchar *folder_name); -gchar camel_store_get_separator(CamelStore *store); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* CAMEL_STORE_H */ diff --git a/camel/camel-stream-fs.c b/camel/camel-stream-fs.c deleted file mode 100644 index 0e006a28f3..0000000000 --- a/camel/camel-stream-fs.c +++ /dev/null @@ -1,276 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-stream-fs.c : file system based stream */ - -/* inspired by gnome-stream-fs.c in bonobo by Miguel de Icaza */ -/* - * - * 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 -#include "camel-stream-fs.h" -#include -#include -#include -#include -#include "camel-log.h" - -static CamelStreamClass *parent_class=NULL; - - -/* Returns the class for a CamelStreamFS */ -#define CS_CLASS(so) CAMEL_STREAM_FS_CLASS (GTK_OBJECT(so)->klass) - -static gint _read (CamelStream *stream, gchar *buffer, gint n); -static gint _write (CamelStream *stream, const gchar *buffer, gint n); -static void _flush (CamelStream *stream); -static gint _available (CamelStream *stream); -static gboolean _eos (CamelStream *stream); -static void _close (CamelStream *stream); -static gint _seek (CamelStream *stream, gint offset, CamelStreamSeekPolicy policy); - - -static void -camel_stream_fs_class_init (CamelStreamFsClass *camel_stream_fs_class) -{ - CamelStreamClass *camel_stream_class = CAMEL_STREAM_CLASS (camel_stream_fs_class); - parent_class = gtk_type_class (gtk_object_get_type ()); - - /* virtual method definition */ - - /* virtual method overload */ - camel_stream_class->read = _read; - camel_stream_class->write = _write; - camel_stream_class->flush = _flush; - camel_stream_class->available = _available; - camel_stream_class->eos = _eos; - camel_stream_class->close = _close; - camel_stream_class->seek = _seek; - -} - - - -GtkType -camel_stream_fs_get_type (void) -{ - static GtkType camel_stream_fs_type = 0; - - if (!camel_stream_fs_type) { - GtkTypeInfo camel_stream_fs_info = - { - "CamelStreamFs", - sizeof (CamelStreamFs), - sizeof (CamelStreamFsClass), - (GtkClassInitFunc) camel_stream_fs_class_init, - (GtkObjectInitFunc) NULL, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_stream_fs_type = gtk_type_unique (camel_stream_get_type (), &camel_stream_fs_info); - } - - return camel_stream_fs_type; -} - - -CamelStream * -camel_stream_fs_new_with_name (gchar *name, CamelStreamFsMode mode) -{ - struct stat s; - int v, fd; - int flags; - CamelStreamFs *stream_fs; - - g_assert (name); - CAMEL_LOG_FULL_DEBUG ( "Entering CamelStream::new_with_name, name=\"%s\", mode=%d\n", name, mode); - v = stat (name, &s); - - if (mode & CAMEL_STREAM_FS_READ){ - if (mode & CAMEL_STREAM_FS_WRITE) - flags = O_RDWR | O_CREAT; - else - flags = O_RDONLY; - } else { - if (mode & CAMEL_STREAM_FS_WRITE) - flags = O_WRONLY | O_CREAT; - else - return NULL; - } - if ( (mode & CAMEL_STREAM_FS_READ) && !(mode & CAMEL_STREAM_FS_WRITE) ) - if (v == -1) return NULL; - - fd = open (name, flags, 0600); - if (fd==-1) { - CAMEL_LOG_FULL_DEBUG ( "CamelStreamFs::new_with_name can not obtain fd for file \"%s\"\n", name); - CAMEL_LOG_FULL_DEBUG ( " Full error text is : %s\n", strerror(errno)); - return NULL; - } - - stream_fs = CAMEL_STREAM_FS (camel_stream_fs_new_with_fd (fd)); - stream_fs->name = name; - - return CAMEL_STREAM (stream_fs); - -} - -CamelStream * -camel_stream_fs_new_with_fd (int fd) -{ - CamelStreamFs *stream_fs; - - CAMEL_LOG_FULL_DEBUG ( "Entering CamelStream::new_with_fd fd=%d\n",fd); - stream_fs = gtk_type_new (camel_stream_fs_get_type ()); - stream_fs->fd = fd; - return CAMEL_STREAM (stream_fs); -} - -/** - * _read: read bytes from a stream - * @stream: stream - * @buffer: buffer where bytes are stored - * @n: max number of bytes to read - * - * - * - * Return value: number of bytes actually read. - **/ -static gint -_read (CamelStream *stream, gchar *buffer, gint n) -{ - int v; - do { - v = read ( (CAMEL_STREAM_FS (stream))->fd, buffer, n); - } while (v == -1 && errno == EINTR); - return v; -} - - -/** - * _write: read bytes to a stream - * @stream: the stream - * @buffer: byte buffer - * @n: number of bytes to write - * - * - * - * Return value: the number of bytes actually written - * in the stream. - **/ -static gint -_write (CamelStream *stream, const gchar *buffer, gint n) -{ - int v; - g_assert (stream); - g_assert ((CAMEL_STREAM_FS (stream))->fd); - CAMEL_LOG_FULL_DEBUG ( "CamelStreamFs:: entering write. n=%d\n", n); - do { - v = write ( (CAMEL_STREAM_FS (stream))->fd, buffer, n); - } while (v == -1 && errno == EINTR); - -#if HARD_LOG_LEVEL >= FULL_DEBUG - if (v==-1) { - perror(""); - CAMEL_LOG_FULL_DEBUG ( "CamelStreamFs::write could not write bytes in stream\n"); - } -#endif - return v; - -} - - - -/** - * _flush: flush pending changes - * @stream: the stream - * - * - **/ -static void -_flush (CamelStream *stream) -{ - fsync ((CAMEL_STREAM_FS (stream))->fd); -} - - - -/** - * _available: return the number of bytes available for reading - * @stream: the stream - * - * Return the number of bytes available without blocking. - * - * Return value: the number of bytes available - **/ -static gint -_available (CamelStream *stream) -{ - g_warning ("Not implemented yet"); -} - - -/** - * _eos: test if there are bytes left to read - * @stream: the stream - * - * - * - * Return value: true if all stream has been read - **/ -static gboolean -_eos (CamelStream *stream) -{ - g_warning ("Not implemented yet"); -} - - -/** - * _close: close a stream - * @stream: the stream - * - * - **/ -static void -_close (CamelStream *stream) -{ - close ((CAMEL_STREAM_FS (stream))->fd); -} - - -static gint -_seek (CamelStream *stream, gint offset, CamelStreamSeekPolicy policy) -{ - int whence; - switch (policy) { - case CAMEL_STREAM_SET: - whence = SEEK_SET; - break; - case CAMEL_STREAM_CUR: - whence = SEEK_CUR; - break; - case CAMEL_STREAM_END: - whence = SEEK_END; - break; - default: - return -1; - } - - - return lseek ((CAMEL_STREAM_FS (stream))->fd, offset, whence); -} diff --git a/camel/camel-stream-fs.h b/camel/camel-stream-fs.h deleted file mode 100644 index 9f295cdb4a..0000000000 --- a/camel/camel-stream-fs.h +++ /dev/null @@ -1,80 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-stream-fs.h :stream based on unix filesystem */ - -/* - * - * 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_STREAM_FS_H -#define CAMEL_STREAM_FS_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include -#include -#include "camel-stream.h" - -#define CAMEL_STREAM_FS_TYPE (camel_stream_fs_get_type ()) -#define CAMEL_STREAM_FS(obj) (GTK_CHECK_CAST((obj), CAMEL_STREAM_FS_TYPE, CamelStreamFs)) -#define CAMEL_STREAM_FS_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_STREAM_FS_TYPE, CamelStreamFsClass)) -#define IS_CAMEL_STREAM_FS(o) (GTK_CHECK_TYPE((o), CAMEL_STREAM_FS_TYPE)) - -typedef enum -{ - CAMEL_STREAM_FS_READ = 1, - CAMEL_STREAM_FS_WRITE = 2 -} CamelStreamFsMode; - - -typedef struct -{ - CamelStream parent_object; - gchar *name; - int fd; -} CamelStreamFs; - - - -typedef struct { - CamelStreamClass parent_class; - - /* Virtual methods */ - -} CamelStreamFsClass; - - - -/* Standard Gtk function */ -GtkType camel_stream_fs_get_type (void); - - -/* public methods */ -CamelStream *camel_stream_fs_new_with_name (gchar *name, CamelStreamFsMode mode); -CamelStream *camel_stream_fs_new_with_fd (int fd); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* CAMEL_STREAM_FS_H */ diff --git a/camel/camel-stream-mem.c b/camel/camel-stream-mem.c deleted file mode 100644 index 14eb9ec625..0000000000 --- a/camel/camel-stream-mem.c +++ /dev/null @@ -1,235 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-ofmemet: 8 -*- */ -/* camel-stream-mem.c : memory buffer based stream */ - -/* inspired by gnome-stream-mem.c in bonobo by Miguel de Icaza */ -/* - * - * 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 -#include "camel-stream-mem.h" -#include -#include -#include -#include -#include "camel-log.h" - -static CamelStreamClass *parent_class=NULL; - - -/* Returns the class for a CamelStreamMEM */ -#define CS_CLASS(so) CAMEL_STREAM_MEM_CLASS (GTK_OBJECT(so)->klass) - -static gint _read (CamelStream *stream, gchar *buffer, gint n); -static gint _write (CamelStream *stream, const gchar *buffer, gint n); -static void _flush (CamelStream *stream); -static gint _available (CamelStream *stream); -static gboolean _eos (CamelStream *stream); -static void _close (CamelStream *stream); -static gint _seek (CamelStream *stream, gint offset, CamelStreamSeekPolicy policy); - - -static void -camel_stream_mem_class_init (CamelStreamMemClass *camel_stream_mem_class) -{ - CamelStreamClass *camel_stream_class = CAMEL_STREAM_CLASS (camel_stream_mem_class); - parent_class = gtk_type_class (gtk_object_get_type ()); - - /* virtual method definition */ - - /* virtual method overload */ - camel_stream_class->read = _read; - camel_stream_class->write = _write; - camel_stream_class->flush = _flush; - camel_stream_class->available = _available; - camel_stream_class->eos = _eos; - camel_stream_class->close = _close; - camel_stream_class->seek = _seek; - -} - -static void -camel_stream_mem_init (gpointer object, gpointer klass) -{ - CamelStreamMem *camel_stream_mem = CAMEL_STREAM_MEM (object); - camel_stream_mem->buffer = g_byte_array_new (); - camel_stream_mem->position = 0; -} - -GtkType -camel_stream_mem_get_type (void) -{ - static GtkType camel_stream_mem_type = 0; - - if (!camel_stream_mem_type) { - GtkTypeInfo camel_stream_mem_info = - { - "CamelStreamMem", - sizeof (CamelStreamMem), - sizeof (CamelStreamMemClass), - (GtkClassInitFunc) camel_stream_mem_class_init, - (GtkObjectInitFunc) camel_stream_mem_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_stream_mem_type = gtk_type_unique (camel_stream_get_type (), &camel_stream_mem_info); - } - - return camel_stream_mem_type; -} - - - - -/** - * _read: read bytes from a stream - * @stream: stream - * @buffer: buffer where bytes are stored - * @n: max number of bytes to read - * - * - * - * Return value: number of bytes actually read. - **/ -static gint -_read (CamelStream *stream, gchar *buffer, gint n) -{ - CamelStreamMem *camel_stream_mem = CAMEL_STREAM_MEM (stream); - gint nb_bytes_to_read; - - g_assert (stream); - nb_bytes_to_read = MIN (n, (camel_stream_mem->buffer)->len - camel_stream_mem->position); - if (nb_bytes_to_read) { - memcpy (buffer, (camel_stream_mem->buffer)->data + camel_stream_mem->position, nb_bytes_to_read); - camel_stream_mem->position += nb_bytes_to_read; - } - return nb_bytes_to_read; -} - - -/** - * _write: read bytes to a stream - * @stream: the stream - * @buffer: byte buffer - * @n: number of bytes to write - * - * - * - * Return value: the number of bytes actually written - * in the stream. - **/ -static gint -_write (CamelStream *stream, const gchar *buffer, gint n) -{ - CamelStreamMem *camel_stream_mem = CAMEL_STREAM_MEM (stream); - - g_assert (stream); - camel_stream_mem->buffer = g_byte_array_append (camel_stream_mem->buffer, (const guint8 *)buffer, n); - camel_stream_mem->position += n; - -} - - - -/** - * _flush: flush pending changes - * @stream: the stream - * - * - **/ -static void -_flush (CamelStream *stream) -{ - g_warning ("Not implemented yet"); -} - - - -/** - * _available: return the number of bytes available for reading - * @stream: the stream - * - * Return the number of bytes available without blocking. - * - * Return value: the number of bytes available - **/ -static gint -_available (CamelStream *stream) -{ - g_warning ("Not implemented yet"); -} - - -/** - * _eos: test if there are bytes left to read - * @stream: the stream - * - * - * - * Return value: true if all stream has been read - **/ -static gboolean -_eos (CamelStream *stream) -{ - g_warning ("Not implemented yet"); -} - - -/** - * _close: close a stream - * @stream: the stream - * - * - **/ -static void -_close (CamelStream *stream) -{ - g_warning ("Not implemented yet"); -} - - - -static gint -_seek (CamelStream *stream, gint offset, CamelStreamSeekPolicy policy) -{ - gint position; - CamelStreamMem *camel_stream_mem = CAMEL_STREAM_MEM (stream); - - switch (policy) { - case CAMEL_STREAM_SET: - position = offset; - break; - case CAMEL_STREAM_CUR: - position = camel_stream_mem->position + offset; - break; - case CAMEL_STREAM_END: - position = (camel_stream_mem->buffer)->len + offset; - break; - default: - return -1; - } - - position = MIN (position, (camel_stream_mem->buffer)->len); - position = MAX (position, 0); - - camel_stream_mem->position = position; - - return position; -} diff --git a/camel/camel-stream-mem.h b/camel/camel-stream-mem.h deleted file mode 100644 index 1864512868..0000000000 --- a/camel/camel-stream-mem.h +++ /dev/null @@ -1,80 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-stream-mem.h :stream based on memory buffer */ - -/* - * - * 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_STREAM_MEM_H -#define CAMEL_STREAM_MEM_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include -#include -#include "camel-stream.h" - -#define CAMEL_STREAM_MEM_TYPE (camel_stream_mem_get_type ()) -#define CAMEL_STREAM_MEM(obj) (GTK_CHECK_CAST((obj), CAMEL_STREAM_MEM_TYPE, CamelStreamMem)) -#define CAMEL_STREAM_MEM_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_STREAM_MEM_TYPE, CamelStreamMemClass)) -#define IS_CAMEL_STREAM_MEM(o) (GTK_CHECK_TYPE((o), CAMEL_STREAM_MEM_TYPE)) - -typedef enum -{ - CAMEL_STREAM_MEM_READ = 1, - CAMEL_STREAM_MEM_WRITE = 2 -} CamelStreamMemMode; - - -typedef struct -{ - CamelStream parent_object; - - GByteArray *buffer; - gint position; - CamelStreamMemMode mode; -} CamelStreamMem; - - - -typedef struct { - CamelStreamClass parent_class; - - /* Virtual methods */ - -} CamelStreamMemClass; - - - -/* Standard Gtk function */ -GtkType camel_stream_mem_get_type (void); - - -/* public methods */ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* CAMEL_STREAM_MEM_H */ diff --git a/camel/camel-stream.c b/camel/camel-stream.c deleted file mode 100644 index b63a64ddb7..0000000000 --- a/camel/camel-stream.c +++ /dev/null @@ -1,223 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-stream.c : abstract class for a stream */ - - -/* - * - * 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 -#include "camel-stream.h" - -static CamelStreamClass *parent_class = NULL; - - -/* Returns the class for a CamelMimeMessage */ -#define CS_CLASS(so) CAMEL_STREAM_CLASS (GTK_OBJECT(so)->klass) - -static void -default_camel_flush (CamelStream *stream) -{ - /* nothing */ -} - -static void -default_camel_close (CamelStream *stream) -{ - /* nothing */ -} - -static gint -default_camel_seek (CamelStream *stream, gint offset, CamelStreamSeekPolicy policy) -{ - /* nothing */ -} - -static void -camel_stream_class_init (CamelStreamClass *camel_stream_class) -{ - - parent_class = gtk_type_class (gtk_object_get_type ()); - - /* virtual method definition */ - camel_stream_class->read = NULL; - camel_stream_class->write = NULL; - camel_stream_class->flush = default_camel_flush; - camel_stream_class->available = NULL; - camel_stream_class->eos = NULL; - camel_stream_class->close = default_camel_close; - camel_stream_class->seek = default_camel_seek; - - /* virtual method overload */ -} - -GtkType -camel_stream_get_type (void) -{ - static GtkType camel_stream_type = 0; - - if (!camel_stream_type) { - GtkTypeInfo camel_stream_info = - { - "CamelStream", - sizeof (CamelStream), - sizeof (CamelStreamClass), - (GtkClassInitFunc) camel_stream_class_init, - (GtkObjectInitFunc) NULL, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_stream_type = gtk_type_unique (gtk_object_get_type (), &camel_stream_info); - } - - return camel_stream_type; -} - -/** - * camel_stream_read: - * @stream: a CamelStream. - * @buffer: buffer where bytes pulled from the stream are stored. - * @n: max number of bytes to read. - * - * Read at most @n bytes from the @stream object and stores them - * in the buffer pointed at by @buffer. - * - * Return value: number of bytes actually read. - **/ -gint -camel_stream_read (CamelStream *stream, gchar *buffer, gint n) -{ - CS_CLASS (stream)->read (stream, buffer, n); -} - -/** - * camel_stream_write: - * @stream: a CamelStream object. - * @buffer: buffer to write. - * @n: number of bytes to write - * - * Write @n bytes from the buffer pointed at by @buffer into @stream. - * - * Return value: the number of bytes actually written - * in the stream. - **/ -gint -camel_stream_write (CamelStream *stream, const gchar *buffer, gint n) -{ - return CS_CLASS (stream)->write (stream, buffer, n); -} - -/** - * camel_stream_flush: - * @stream: a CamelStream object - * - * Flushes the contents of the stream to its backing store. - **/ -void -camel_stream_flush (CamelStream *stream) -{ - return CS_CLASS (stream)->flush (stream); -} - -/** - * camel_stream_available: - * @stream: a CamelStream object - * - * Return value: the number of bytes available. - **/ -gint -camel_stream_available (CamelStream *stream) -{ - return CS_CLASS (stream)->available (stream); -} - -/** - * camel_stream_eos: - * @stream: a CamelStream object - * - * Test if there are bytes left to read on the @stream object. - * - * Return value: %TRUE if all the contents on the stream has been read, or - * %FALSE if information is still available. - **/ -gboolean -camel_stream_eos (CamelStream *stream) -{ - return CS_CLASS (stream)->eos (stream); -} - - -/** - * camel_stram_close: - * @stream: a CamelStream object. - * - * Close the @stream object. - **/ -void -camel_stream_close (CamelStream *stream) -{ - CS_CLASS (stream)->close (stream); -} - - -/** - * camel_stream_seek: - * @stream: a CamelStream object. - * @offset: offset value - * @policy: what to do with the offset - * - * - * - * Return value: new position, -1 if operation failed. - **/ -gint -camel_stream_seek (CamelStream *stream, gint offset, CamelStreamSeekPolicy policy) -{ - return CS_CLASS (stream)->seek (stream, offset, policy); -} - - - - -/***************** Utility functions ********************/ - -/** - * came_stream_write_strings: - * @stream: a CamelStream object. - * @...: A %NULL terminated list of strings. - * - * This is a utility function that writes the list of - * strings into the @stream object. - */ -void -camel_stream_write_strings (CamelStream *stream, ... ) -{ - va_list args; - const char *string; - - va_start(args, stream); - string = va_arg (args, const char *); - - while (string) { - camel_stream_write_string (stream, string); - string = va_arg (args, char *); - } - va_end (args); -} diff --git a/camel/camel-stream.h b/camel/camel-stream.h deleted file mode 100644 index 4b4ea50b5b..0000000000 --- a/camel/camel-stream.h +++ /dev/null @@ -1,93 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-stream.h : class for an abstract stream */ - -/* - * - * 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_STREAM_H -#define CAMEL_STREAM_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include - -#define CAMEL_STREAM_TYPE (camel_stream_get_type ()) -#define CAMEL_STREAM(obj) (GTK_CHECK_CAST((obj), CAMEL_STREAM_TYPE, CamelStream)) -#define CAMEL_STREAM_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_STREAM_TYPE, CamelStreamClass)) -#define IS_CAMEL_STREAM(o) (GTK_CHECK_TYPE((o), CAMEL_STREAM_TYPE)) - -typedef enum -{ - CAMEL_STREAM_SET, - CAMEL_STREAM_CUR, - CAMEL_STREAM_END -} CamelStreamSeekPolicy; - -typedef struct -{ - GtkObject parent_object; - -} CamelStream; - - - -typedef struct { - GtkObjectClass parent_class; - - /* Virtual methods */ - gint (*read) (CamelStream *stream, gchar *buffer, gint n); - gint (*write) (CamelStream *stream, const gchar *buffer, gint n); - void (*flush) (CamelStream *stream); - gint (*available) (CamelStream *stream); - gboolean (*eos) (CamelStream *stream); - void (*close) (CamelStream *stream); - gint (*seek) (CamelStream *stream, gint offset, CamelStreamSeekPolicy policy); -} CamelStreamClass; - - - -/* Standard Gtk function */ -GtkType camel_stream_get_type (void); - - -/* public methods */ -gint camel_stream_read (CamelStream *stream, gchar *buffer, gint n); -gint camel_stream_write (CamelStream *stream, const gchar *buffer, gint n); -void camel_stream_flush (CamelStream *stream); -gint camel_stream_available (CamelStream *stream); -gboolean camel_stream_eos (CamelStream *stream); -void camel_stream_close (CamelStream *stream); -gint camel_stream_seek (CamelStream *stream, gint offset, CamelStreamSeekPolicy policy); - -/* utility macros and funcs */ -#define camel_stream_write_string(stream, string) camel_stream_write ((stream), (string), strlen (string)) - -void camel_stream_write_strings (CamelStream *stream, ... ); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* CAMEL_STREAM_H */ diff --git a/camel/camel.c b/camel/camel.c deleted file mode 100644 index 706041879f..0000000000 --- a/camel/camel.c +++ /dev/null @@ -1,30 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * - * 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.h" - -gint -camel_init() -{ - return data_wrapper_repository_init (); - -} diff --git a/camel/camel.h b/camel/camel.h deleted file mode 100644 index c0548f5e10..0000000000 --- a/camel/camel.h +++ /dev/null @@ -1,43 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * - * 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_H -#define CAMEL_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include -#include -#include - -gint camel_init (); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* CAMEL_H */ diff --git a/camel/data-wrapper-repository.c b/camel/data-wrapper-repository.c deleted file mode 100644 index 147a92b831..0000000000 --- a/camel/data-wrapper-repository.c +++ /dev/null @@ -1,124 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * - * 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 "data-wrapper-repository.h" -#include "camel-multipart.h" - - - -static DataWrapperRepository _repository; -static _initialized = -1; -GMimeContentField *_content_field; - - - -/** - * data_wrapper_repository_init: initialize data wrapper repository - * - * initialize the data wrapper repository. When the repository has - * already been initialized, returns -1. - * - * Return value: 1 if correctly initialized returns -1. - **/ -gint -data_wrapper_repository_init () -{ - if (_initialized != -1) return -1; - _repository.mime_links = g_hash_table_new (g_str_hash, g_str_equal); - data_wrapper_set_data_wrapper_type ("multipart", camel_multipart_get_type()); - _content_field = gmime_content_field_new (NULL, NULL); - _initialized = 1; - return 1; -} - -/** - * data_wrapper_set_data_wrapper_type: associate a data wrapper object type to a mime type - * @mime_type: mime type - * @object_type: object type - * - * Associate an object type to a mime type. - **/ -void -data_wrapper_set_data_wrapper_type (const gchar *mime_type, GtkType object_type) -{ - gboolean already_exists; - gchar *old_mime_type; - GtkType old_gtk_type; - - already_exists = g_hash_table_lookup_extended (_repository.mime_links, (gpointer)mime_type, - (gpointer)&old_mime_type, (gpointer)&old_gtk_type); - if (already_exists) - g_hash_table_insert (_repository.mime_links, (gpointer)old_mime_type, (gpointer)object_type); - else - g_hash_table_insert (_repository.mime_links, (gpointer)g_strdup (mime_type), (gpointer)object_type); -} - - - -/** - * data_wrapper_get_data_wrapper_type: get the gtk type object associated to a mime type - * @mime_type: mime type - * - * returns the GtkType of the data wrapper object associated to - * a particular mime type. The mime type must be a character string - * of the form "type/subtype" or simply "type". When the complete - * mime type ("type/subtype") is not associated to any particular - * data wrapper object, this routine looks for a default data wrapper - * for the main mime type ("type"). When no particular association is - * found for this mime type, the type of the SimpleDataWrapper is - * returned. - * - * - * Return value: the associated data wrapper object type. - **/ -GtkType -data_wrapper_get_data_wrapper_type (const gchar *mime_type) -{ - gboolean exists; - gchar *old_mime_type; - GtkType gtk_type; - - /* find if the complete mime type exists */ - exists = g_hash_table_lookup_extended (_repository.mime_links, (gpointer)mime_type, - (gpointer)&old_mime_type, (gpointer)>k_type); - if (exists) /* the complete mime type exists, return it */ - return gtk_type; - else { - /* the complete mime type association does not exists */ - /* is there an association for the main mime type ? */ - gmime_content_field_construct_from_string (_content_field, mime_type); - exists = g_hash_table_lookup_extended (_repository.mime_links, (gpointer)(_content_field->type), - (gpointer)&old_mime_type, (gpointer)>k_type); - - if (exists) /* the main mime type association exists */ - return gtk_type; - else return camel_simple_data_wrapper_get_type(); - } - - - - -} - diff --git a/camel/data-wrapper-repository.h b/camel/data-wrapper-repository.h deleted file mode 100644 index 06738db585..0000000000 --- a/camel/data-wrapper-repository.h +++ /dev/null @@ -1,53 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * - * 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 DATA_WRAPPER_REPOSITORY_H -#define DATA_WRAPPER_REPOSITORY_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include -#include -#include "camel-data-wrapper.h" - - - -typedef struct { - GHashTable *mime_links; -} DataWrapperRepository; - - -gint data_wrapper_repository_init (); -void data_wrapper_set_data_wrapper_type (const gchar *mime_type, GtkType object_type); -GtkType data_wrapper_get_data_wrapper_type (const gchar *mime_type); - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* DATA_WRAPPER_REPOSITORY_H */ diff --git a/camel/gmime-content-field.c b/camel/gmime-content-field.c deleted file mode 100644 index b4c8496083..0000000000 --- a/camel/gmime-content-field.c +++ /dev/null @@ -1,324 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* mime-content_field.c : mime content type field utilities */ - -/* - * - * 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 -#include "gmime-content-field.h" -#include "string-utils.h" -#include "camel-log.h" - - - -/** - * gmime_content_field_new: Creates a new GMimeContentField object - * @type: mime type - * @subtype: mime subtype - * - * Creates a GMimeContentField object and initialize it with - * a mime type and a mime subtype. For example, - * gmime_content_field_new ("application", "postcript"); - * will create a content field with complete mime type - * "application/postscript" - * - * Return value: The newly created GMimeContentField object - **/ -GMimeContentField * -gmime_content_field_new (const gchar *type, const gchar *subtype) -{ - GMimeContentField *ctf; - - ctf = g_new (GMimeContentField, 1); - ctf->type = g_strdup (type); - ctf->subtype = g_strdup (subtype); - ctf->parameters = g_hash_table_new (g_str_hash, g_str_equal); - - return ctf; -} - - -/** - * gmime_content_field_set_parameter: set a parameter for a GMimeContentField object - * @content_field: content field - * @attribute: parameter name - * @value: paramteter value - * - * set a parameter (called attribute in RFC 2045) of a content field. Meaningfull - * or valid parameters name depend on the content type object. For example, - * gmime_content_field_set_parameter (cf, "charset", "us-ascii"); - * will make sense for a "text/plain" content field but not for a - * "image/gif". This routine does not check parameter validuty. - **/ -void -gmime_content_field_set_parameter (GMimeContentField *content_field, const gchar *attribute, const gchar *value) -{ - gboolean attribute_exists; - gchar *old_attribute; - gchar *old_value; - CAMEL_LOG_FULL_DEBUG ("GMimeContentField:: Entering set_parameter\n"); - CAMEL_LOG_FULL_DEBUG ("GMimeContentField:: set_parameter content_field=%p name=%s, value=%s\n", content_field, attribute, value); - attribute_exists = g_hash_table_lookup_extended (content_field->parameters, - attribute, - (gpointer *) &old_attribute, - (gpointer *) &old_value); - /** CHECK THAT : is normal to free pointers before insertion ? **/ - if (attribute_exists) { - g_free (old_value); - g_free (old_attribute); - } - - g_hash_table_insert (content_field->parameters, g_strdup (attribute), g_strdup (value)); - CAMEL_LOG_FULL_DEBUG ("GMimeContentField:: Leaving set_parameter\n"); -} - - -/** - * _print_parameter: print a parameter/value pair to a stream as - * described in RFC 2045 - * @name: name of the parameter - * @value: value of the parameter - * @user_data: CamelStream object to write the text to. - * - * - **/ -static void -_print_parameter (gpointer name, gpointer value, gpointer user_data) -{ - CamelStream *stream = (CamelStream *)user_data; - - camel_stream_write_strings (stream, - "; \n ", - (gchar *)name, - "=", - (gchar *)value, - NULL); - -} - -/** - * gmime_content_field_write_to_stream: write a mime content type to a stream - * @content_field: content type object - * @stream: the stream - * - * - **/ -void -gmime_content_field_write_to_stream (GMimeContentField *content_field, CamelStream *stream) -{ - if (!content_field) return; - - g_assert (stream); - if (content_field->type) { - camel_stream_write_strings (stream, "Content-Type: ", content_field->type, NULL); - if (content_field->subtype) { - camel_stream_write_strings (stream, "/", content_field->subtype, NULL); - } - /* print all parameters */ - g_hash_table_foreach (content_field->parameters, _print_parameter, stream); - camel_stream_write_string (stream, "\n"); - } -} - -/** - * gmime_content_field_get_mime_type: return the mime type of the content field object - * @content_field: content field object - * - * A RFC 2045 content type field contains the mime type in the - * form "type/subtype" (example : "application/postscript") and some - * parameters (attribute/value pairs). This routine returns the mime type - * in a gchar object. - * - * Return value: the mime type in the form "type/subtype" or NULL if not defined. - **/ -gchar * -gmime_content_field_get_mime_type (GMimeContentField *content_field) -{ - gchar *mime_type; - - if (!content_field->type) return NULL; - - if (content_field->subtype) - mime_type = g_strdup_printf ("%s/%s", content_field->type, content_field->subtype); - else - mime_type = g_strdup (content_field->type); - return mime_type; -} - -static void -___debug_print_parameter (gpointer name, gpointer value, gpointer user_data) -{ - - printf ("****** parameter \"%s\"=\"%s\"\n", (gchar *)name, (gchar *)value); - -} - -/** - * gmime_content_field_get_parameter: return the value of a mime type parameter - * @content_field: content field object - * @name: name of the parameter - * - * Returns the value of a parameter contained in the content field - * object. The content type is formed of a mime type, a mime subtype, - * and a parameter list. Each parameter is a name/value pair. This - * routine returns the value assiciated to a given name. - * When the parameter does not exist, NULL is returned. - * - * Return value: parameter value, or NULL if not found. - **/ -const gchar * -gmime_content_field_get_parameter (GMimeContentField *content_field, const gchar *name) -{ - const gchar *parameter; - const gchar *old_name; - gboolean parameter_exists; - - CAMEL_LOG_FULL_DEBUG ("Entering GMimeContentField::get_parameter content_field =%p\n", content_field); - g_assert (content_field->parameters); - g_assert (name); - CAMEL_LOG_FULL_DEBUG ("GMimeContentField::get_parameter looking for parameter \"%s\"\n", name); - //parameter = (const gchar *)g_hash_table_lookup (content_field->parameters, name); - parameter_exists = g_hash_table_lookup_extended (content_field->parameters, - name, - (gpointer *) &old_name, - (gpointer *) ¶meter); - if (!parameter_exists) { - CAMEL_LOG_FULL_DEBUG ("GMimeContentField::get_parameter, parameter not found\n"); - g_hash_table_foreach (content_field->parameters, ___debug_print_parameter, NULL); - return NULL; - } - CAMEL_LOG_FULL_DEBUG ("Leaving GMimeContentField::get_parameter\n"); - return parameter; -} - - - - -/** - * gmime_content_field_construct_from_string: construct a ContentType object - * by parsing a string. - * - * @content_field: content type object to construct - * @string: string containing the content type field - * - * Parse a string containing a content type field as defined in - * RFC 2045, and construct the corresponding ContentType object. - * The string is not modified and not used in the ContentType - * object. It can and must be freed by the calling part. - **/ -void -gmime_content_field_construct_from_string (GMimeContentField *content_field, const gchar *string) -{ - gint first, len; - gchar *str; - gint i=0; - gchar *type, *subtype; - gchar *param_name, *param_value; - gboolean param_end; - - CAMEL_LOG_TRACE ( "GMimeContentField::construct_from_string, entering\n"); - g_assert (string); - g_assert (content_field); - - if (content_field->type) { - CAMEL_LOG_FULL_DEBUG ( "GMimeContentField::construct_from_string, Freeing old mime type string\n"); - g_free (content_field->type); - } - if (content_field->subtype) { - CAMEL_LOG_FULL_DEBUG ( "GMimeContentField::construct_from_string, Freeing old mime type substring\n"); - g_free (content_field->subtype); - } - - first = 0; - len = strlen (string); - if (!len) return; - CAMEL_LOG_FULL_DEBUG ("GMimeContentField::construct_from_string, All checks done\n"); - - /* find the type */ - while ( (itype = type; - CAMEL_LOG_TRACE ( "GMimeContentField::construct_from_string, Found mime type : \"%s\"\n", type); - if (i >= len-1) { - content_field->subtype = NULL; - return; - } - - first = i+1; - /* find the subtype, if any */ - if (string[i++] == '/') { - while ( (isubtype = subtype; - CAMEL_LOG_TRACE ( "GMimeContentField::construct_from_string, Found mime subtype: \"%s\"\n", subtype); - if (i >= len-1) return; - } - } - first = i+1; - - /* parse parameters list */ - param_end = FALSE; - do { - while ( (iparameters, _free_parameter, NULL); - g_free (content_field->type); - g_free (content_field->subtype); - g_hash_table_destroy (content_field->parameters); - g_free (content_field); -} diff --git a/camel/gmime-content-field.h b/camel/gmime-content-field.h deleted file mode 100644 index 663c747291..0000000000 --- a/camel/gmime-content-field.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* mime-content_field.h : mime content type field utilities */ - -/* - * - * 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 GMIME_CONTENT_FIELD_H -#define GMIME_CONTENT_FIELD_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include -#include -#include "camel-stream.h" - -typedef struct { - - gchar *type; - gchar *subtype; - GHashTable *parameters; - -} GMimeContentField; - -GMimeContentField *gmime_content_field_new (const gchar *type, const gchar *subtype); -void gmime_content_field_set_parameter (GMimeContentField *content_field, const gchar *attribute, const gchar *value); -void gmime_content_field_write_to_stream (GMimeContentField *content_field, CamelStream *stream); -void gmime_content_field_construct_from_string (GMimeContentField *content_field, const gchar *string); -void gmime_content_field_free (GMimeContentField *content_field); -gchar * gmime_content_field_get_mime_type (GMimeContentField *content_field); -const gchar *gmime_content_field_get_parameter (GMimeContentField *content_field, const gchar *name); - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* GMIME_CONTENT_FIELD_H */ diff --git a/camel/gmime-utils.c b/camel/gmime-utils.c deleted file mode 100644 index 359f96380b..0000000000 --- a/camel/gmime-utils.c +++ /dev/null @@ -1,243 +0,0 @@ -/* -*- 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 -#include "gmime-utils.h" -#include "string-utils.h" -#include "camel-log.h" -#include "camel-stream.h" - -void -gmime_write_header_pair_to_stream (CamelStream *stream, const gchar* name, const gchar *value) -{ - - gchar *strtmp; - guint len; - CAMEL_LOG_FULL_DEBUG ( "gmime_write_header_pair_to_stream:: Entering\n"); - g_assert(name); -#warning use g_strdup_printf instead - - if (!value) return; - len = strlen (name) + strlen (value) +3; - /* 3 is for ": " and "\n" */ - strtmp = g_new (gchar, len); - - sprintf (strtmp, "%s: %s\n", name, value); - camel_stream_write (stream, strtmp, len); - CAMEL_LOG_FULL_DEBUG ( "gmime_write_header_pair_to_stream:\n writing %s\n", strtmp); - g_free (strtmp); - CAMEL_LOG_FULL_DEBUG ( "gmime_write_header_pair_to_stream:: Leaving\n"); - -} - - -static void -_write_one_header_to_stream (gpointer key, gpointer value, gpointer user_data) -{ - gchar *header_name = (gchar *)key; - gchar *header_value = (gchar *)value; - CamelStream *stream = (CamelStream *)user_data; - - CAMEL_LOG_FULL_DEBUG ( "_write_one_header_to_stream:: Entering\n"); - if ((header_name) && (header_value)) - gmime_write_header_pair_to_stream (stream, header_name, header_value); - CAMEL_LOG_FULL_DEBUG ( "_write_one_header_to_stream:: Leaving\n"); -} - -void -write_header_table_to_stream (CamelStream *stream, GHashTable *header_table) -{ - CAMEL_LOG_FULL_DEBUG ( "write_header_table_to_stream:: Entering\n"); - g_hash_table_foreach (header_table, - _write_one_header_to_stream, - (gpointer)stream); - CAMEL_LOG_FULL_DEBUG ( "write_header_table_to_stream:: Leaving\n"); -} - - -void -write_header_with_glist_to_stream (CamelStream *stream, const gchar *header_name, GList *header_values, const gchar *separator) -{ - - gchar *current; - - CAMEL_LOG_FULL_DEBUG ( "write_header_with_glist_to_stream:: entering\n"); - if ( (header_name) && (header_values) ) - { - gboolean first; - - camel_stream_write (stream, header_name, strlen (header_name) ); - camel_stream_write (stream, ": ", 2); - first = TRUE; - while (header_values) { - current = (gchar *)header_values->data; - if (current) { - if (!first) camel_stream_write_string (stream, separator); - else first = FALSE; - camel_stream_write (stream, current, strlen (current)); - } - header_values = g_list_next(header_values); - } - camel_stream_write (stream, "\n", 1); - } - CAMEL_LOG_FULL_DEBUG ( "write_header_with_glist_to_stream:: leaving\n"); - -} - - - - - -/* * * * * * * * * * * */ -/* scanning functions */ - -static void -_store_header_pair_from_string (GHashTable *header_table, gchar *header_line) -{ - gchar dich_result; - gchar *header_name, *header_value; - - CAMEL_LOG_FULL_DEBUG ( "_store_header_pair_from_string:: Entering\n"); - g_assert (header_table); - g_assert (header_line); - if (header_line) { - dich_result = string_dichotomy ( header_line, ':', - &header_name, &header_value, - STRING_DICHOTOMY_NONE); - if (dich_result != 'o') - CAMEL_LOG_WARNING ( - "store_header_pair_from_string : dichotomy result is %c" - "header line is :\n--\n%s\n--\n"); - else { - string_trim (header_value, " \t", - STRING_TRIM_STRIP_LEADING | STRING_TRIM_STRIP_TRAILING); - g_hash_table_insert (header_table, header_name, header_value); - } - } - CAMEL_LOG_FULL_DEBUG ( "_store_header_pair_from_string:: Leaving\n"); - -} - - - - -GHashTable * -get_header_table_from_stream (CamelStream *stream) -{ -#warning Correct Lazy Implementation - /* should not use GString. */ - /* should read the header line by line */ - /* and not char by char */ - gchar next_char; - - gboolean crlf = FALSE; - gboolean end_of_header_line = FALSE; - gboolean end_of_headers = FALSE; - gboolean end_of_file = FALSE; - GString *header_line=NULL; - gchar *str_header_line; - GHashTable *header_table; -#warning Correct a bug here. Should use return value of camel_stream_read instead of looking for next_char!=-1 - CAMEL_LOG_FULL_DEBUG ( "gmime-utils:: Entering get_header_table_from_stream\n"); - header_table = g_hash_table_new (g_str_hash, g_str_equal); - camel_stream_read (stream, &next_char, 1); - do { - header_line = g_string_new (""); - end_of_header_line = FALSE; - crlf = FALSE; - - /* read a whole header line */ - do { - switch (next_char) { - case -1: - end_of_file=TRUE; - end_of_header_line = TRUE; - break; - case '\n': /* a blank line means end of headers */ - if (crlf) { - end_of_headers=TRUE; - end_of_header_line = TRUE; - } - else crlf = TRUE; - break; - case ' ': - case '\t': - if (crlf) { - crlf = FALSE; - next_char = ' '; - } - - default: - if (!crlf) header_line = g_string_append_c (header_line, next_char); - else end_of_header_line = TRUE; - } - /* if we have read a whole header line, we have also read - the first character of the next line to be sure the - crlf was not followed by a space or a tab char */ - if (!end_of_header_line) camel_stream_read (stream, &next_char, 1); - - } while ( !end_of_header_line ); - if ( strlen(header_line->str) ) { - str_header_line = g_strdup (header_line->str); - _store_header_pair_from_string (header_table, str_header_line); - } - g_string_free (header_line, FALSE); - - } while ( (!end_of_headers) && (!end_of_file) ); - - CAMEL_LOG_FULL_DEBUG ( "gmime-utils:: Leaving get_header_table_from_stream\n"); - return header_table; -} - - -gchar * -gmime_read_line_from_stream (CamelStream *stream) -{ - GString *new_line; - gchar *result; - gchar next_char; - gboolean end_of_line = FALSE; - gboolean end_of_stream = FALSE; - gint nb_char_read; - - new_line = g_string_new (""); - do { - nb_char_read = camel_stream_read (stream, &next_char, 1); - if (nb_char_read>0) { - switch (next_char) { - case '\n': - end_of_line = TRUE; - /* g_string_append_c (new_line, next_char); */ - break; - default: - g_string_append_c (new_line, next_char); - } - } else end_of_stream = TRUE; - } while (!end_of_line && !end_of_stream); - - if (!end_of_stream) - result = g_strdup (new_line->str); - else result=NULL; - g_string_free (new_line, TRUE); - return result; -} diff --git a/camel/gmime-utils.h b/camel/gmime-utils.h deleted file mode 100644 index 5c99ca3d66..0000000000 --- a/camel/gmime-utils.h +++ /dev/null @@ -1,51 +0,0 @@ -/* -*- 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 GMIME_UTILS_H -#define GMIME_UTILS_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include -#include -#include - -void gmime_write_header_pair_to_stream (CamelStream *stream, const gchar* name, const gchar *value); -void write_header_table_to_stream (CamelStream *stream, GHashTable *header_table); -void write_header_with_glist_to_stream (CamelStream *stream, const gchar *header_name, GList *header_values, const gchar *separator); - -GHashTable *get_header_table_from_stream (CamelStream *stream); -gchar *gmime_read_line_from_stream (CamelStream *stream); - - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* GMIME_UTILS_H */ diff --git a/camel/gstring-util.c b/camel/gstring-util.c deleted file mode 100644 index 8b89d1d9b4..0000000000 --- a/camel/gstring-util.c +++ /dev/null @@ -1,340 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* gstring-util : utilities for gstring object */ - -/* - * - * 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 -#include "gstring-util.h" -#include "camel-log.h" - - -/** - * g_string_equals : test if two string are equal - * - * @string1 : first string - * @string2 : second string - * - * @Return Value : true if the strings equal, false otherwise - **/ -gboolean -g_string_equals (GString *string1, GString *string2) -{ - g_assert(string1); - g_assert(string2); - return !strcmp(string1->str, string2->str); -} - - - - -/** - * g_string_clone : clone a GString - * - * @string : the string to clone - * - * @Return Value : the clone ... - **/ -GString * -g_string_clone(GString *string) -{ - return g_string_new( g_strdup(string->str) ); -} - - - - -/** - * g_string_dichotomy: - * @sep : separator - * @prefix: pointer to be field by the prefix object - * the prefix is not returned when the given pointer is NULL - * @suffix: pointer to be field by the suffix object - * the suffix is not returned when the given pointer is NULL - * - * Return the strings before and/or after - * the last occurence of the specified separator - * - * This routine returns the string before and/or after - * a character given as an argument. - * if the separator is the last character, prefix and/or - * suffix is set to NULL and result is set to 'l' - * if the separator is not in the list, prefix and/or - * suffix is set to NULL and result is set to 'n' - * When the operation succedeed, the return value is 'o' - * - * @Return Value : result of the operation ('o', 'l' or 'n') - * - **/ -gchar -g_string_dichotomy (GString *string, gchar sep, GString **prefix, GString **suffix, - GStringDichotomyOption options) -{ - gchar *str, *tmp; - gint pos, len, first; - - CAMEL_LOG_FULL_DEBUG (\ - "Entering string_dichotomy: \n\tseparator=%c \n\tprefix=%p \n\tsuffix=%p \n\toptions=%ld\n",\ - sep, prefix, suffix, options); - g_assert( tmp=string->str ); - len = strlen(tmp); - if (!len) { - if (prefix) - *prefix=NULL; - if (suffix) - *suffix=NULL; - CAMEL_LOG_FULL_DEBUG ("string_dichotomy: string is empty\n"); - return 'n'; - } - first = 0; - - if ( (options & GSTRING_DICHOTOMY_STRIP_LEADING ) && (tmp[first] == sep) ) - do {first++;} while ( (first=first) && (tmp[pos]!=sep)); - } else { - pos = first; - do { - pos++; - } while ((pos=len) ) - { - if (suffix) *suffix=NULL; - if (prefix) *prefix=NULL; - CAMEL_LOG_FULL_DEBUG ("string_dichotomy: separator not found\n"); - return 'n'; - } - - /* if we have stripped trailing separators, we should */ - /* never enter here */ - if (pos==len-1) - { - if (suffix) *suffix=NULL; - if (prefix) *prefix=NULL; - CAMEL_LOG_FULL_DEBUG ("string_dichotomy: separator is last character\n"); - return 'l'; - } - /* if we have stripped leading separators, we should */ - /* never enter here */ - if (pos==first) - { - if (suffix) *suffix=NULL; - if (prefix) *prefix=NULL; - CAMEL_LOG_FULL_DEBUG ("string_dichotomy: separator is first character\n"); - return 'l'; - } - - if (prefix) /* return the prefix */ - { - str = g_strndup(tmp,pos); - *prefix = g_string_new(str); - g_free(str); - } - if (suffix) /* return the suffix */ - { - str = g_strdup(tmp+pos+1); - *suffix = g_string_new(str); - g_free(str); - } - - return 'o'; -} - - -/** - * g_string_append_g_string : append a GString to another GString - * - * @dest_string : string which will be appended - * @other_string : string to append - * - **/ -void -g_string_append_g_string(GString *dest_string, GString *other_string) -{ - g_assert(other_string); - g_assert(dest_string); - g_assert(other_string->str); - - g_string_append(dest_string, other_string->str); -} - - - -/** - * g_string_equal_for_hash: test equality of two GStrings for hash tables - * @v: string 1 - * @v2: string 2 - * - * - * - * Return value: - **/ -g_string_equal_for_hash (gconstpointer v, gconstpointer v2) -{ - return strcmp ( ((const GString*)v)->str, ((const GString*)v2)->str) == 0; -} - -g_string_equal_for_glist (gconstpointer v, gconstpointer v2) -{ - return !strcmp ( ((const GString*)v)->str, ((const GString*)v2)->str) == 0; -} - - -/** - * g_string_hash: computes a hash value for a Gstring - * @v: Gstring object - * - * - * - * Return value: - **/ -guint -g_string_hash (gconstpointer v) -{ - return g_str_hash(((const GString*)v)->str); -} - - - - -/* utility func : frees a GString element in a GList */ -static void -__g_string_list_free_string (gpointer data, gpointer user_data) -{ - GString *string = (GString *)data; - g_string_free(string, TRUE); -} - - -void -g_string_list_free (GList *string_list) -{ - g_list_foreach(string_list, __g_string_list_free_string, NULL); - g_list_free(string_list); -} - - - - - - -GList * -g_string_split (GString *string, char sep, gchar *trim_chars, GStringTrimOption trim_options) -{ - GList *result = NULL; - gint first, last, pos; - gchar *str; - gchar *new_str; - GString *new_gstring; - - g_assert (string); - str = string->str; - if (!str) return NULL; - - first = 0; - last = strlen(str) - 1; - - /* strip leading and trailing separators */ - while ( (first<=last) && (str[first]==sep) ) - first++; - while ( (first<=last) && (str[last]==sep) ) - last--; - - - CAMEL_LOG_FULL_DEBUG ("g_string_split:: trim options: %d\n", trim_options); - - while (first<=last) { - pos = first; - /* find next separator */ - while ((pos<=last) && (str[pos]!=sep)) pos++; - if (first != pos) { - new_str = g_strndup (str+first, pos-first); - new_gstring = g_string_new (new_str); - g_free (new_str); - /* could do trimming in line to speed up this code */ - if (trim_chars) g_string_trim (new_gstring, trim_chars, trim_options); - result = g_list_append (result, new_gstring); - } - first = pos + 1; - } - - return result; -} - - -void -g_string_trim (GString *string, gchar *chars, GStringTrimOption options) -{ - gint first_ok; - gint last_ok; - guint length; - gchar *str; - - CAMEL_LOG_FULL_DEBUG ("**\nentering g_string_trim::\n"); - - if ((!string) || (!string->str)) - return; - str = string->str; - length = strlen (str); - if (!length) - return; - - first_ok = 0; - last_ok = length - 1; - - CAMEL_LOG_FULL_DEBUG ("g_string_trim:: trim_options:%d\n", options); - if (options & GSTRING_TRIM_STRIP_LEADING) - while ( (first_ok <= last_ok) && (strchr (chars, str[first_ok])) ) - first_ok++; - - if (options & GSTRING_TRIM_STRIP_TRAILING) - while ( (first_ok <= last_ok) && (strchr (chars, str[last_ok])) ) - last_ok++; - CAMEL_LOG_FULL_DEBUG ("g_string_trim::\n\t\"%s\":first ok:%d last_ok:%d\n", - string->str, first_ok, last_ok); - - if (first_ok > 0) - g_string_erase (string, 0, first_ok); - - if (last_ok < length-1) - g_string_truncate (string, last_ok - first_ok +1); - -} diff --git a/camel/gstring-util.h b/camel/gstring-util.h deleted file mode 100644 index 7a82f9ab01..0000000000 --- a/camel/gstring-util.h +++ /dev/null @@ -1,74 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* gstring-util : utilities for gstring object */ - -/* - * - * 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 GSTRING_UTIL_H -#define GSTRING_UTIL_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include - -typedef enum { - GSTRING_DICHOTOMY_NONE = 0, - GSTRING_DICHOTOMY_RIGHT_DIR = 1, - GSTRING_DICHOTOMY_STRIP_TRAILING = 2, - GSTRING_DICHOTOMY_STRIP_LEADING = 4, - -} GStringDichotomyOption; - -typedef enum { - GSTRING_TRIM_NONE = 0, - GSTRING_TRIM_STRIP_TRAILING = 1, - GSTRING_TRIM_STRIP_LEADING = 2, -} GStringTrimOption; - - -gboolean g_string_equals (GString *string1, GString *string2); -GString *g_string_clone (GString *string); -gchar g_string_dichotomy (GString *string, gchar sep, - GString **prefix, GString **suffix, - GStringDichotomyOption options); -void g_string_append_g_string (GString *dest_string, - GString *other_string); - -gboolean g_string_equal_for_hash (gconstpointer v, gconstpointer v2); -gboolean g_string_equal_for_glist (gconstpointer v, gconstpointer v2); -guint g_string_hash (gconstpointer v); -void g_string_list_free (GList *string_list); - -GList *g_string_split (GString *string, char sep, - gchar *trim_chars, GStringTrimOption trim_options); -void g_string_trim (GString *string, gchar *chars, - GStringTrimOption options); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* GSTRING_UTIL_H */ diff --git a/camel/providers/.cvsignore b/camel/providers/.cvsignore deleted file mode 100644 index b840c21800..0000000000 --- a/camel/providers/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -Makefile.in -Makefile \ No newline at end of file diff --git a/camel/providers/MH/.cvsignore b/camel/providers/MH/.cvsignore deleted file mode 100644 index 2e7b174532..0000000000 --- a/camel/providers/MH/.cvsignore +++ /dev/null @@ -1,6 +0,0 @@ -Makefile.in -Makefile -.deps -*.lo -*.la -.libs diff --git a/camel/providers/MH/Makefile.am b/camel/providers/MH/Makefile.am deleted file mode 100644 index 0f52c9fb40..0000000000 --- a/camel/providers/MH/Makefile.am +++ /dev/null @@ -1,26 +0,0 @@ -## Process this file with automake to produce Makefile.in - -SUBDIRS = - -libcamelmhincludedir = $(includedir)/camel - - -lib_LTLIBRARIES = libcamelmh.la - -INCLUDES = -I.. -I$(srcdir)/.. -I$(includedir) \ - -I$(top_srcdir)/intl \ - $(GTK_INCLUDEDIR) -I$(top_srcdir)/camel - -libcamelmh_la_SOURCES = \ - camel-mh-folder.c \ - camel-mh-store.c - -libcamelmhinclude_HEADERS = \ - camel-mh-folder.h \ - camel-mh-store.h - - -libcamelmh_la_LDFLAGS = -version-info 0:0:0 -rpath $(libdir) - - -EXTRA_DIST = diff --git a/camel/providers/MH/camel-mh-folder.c b/camel/providers/MH/camel-mh-folder.c deleted file mode 100644 index e4fe3c5bd2..0000000000 --- a/camel/providers/MH/camel-mh-folder.c +++ /dev/null @@ -1,115 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-mh-folder.c : Abstract class for an email folder */ - -/* - * - * 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-mh-folder.h" -#include "camel-mh-store.h" -#include "gstring-util.h" - - -static CamelFolderClass *parent_class=NULL; - -/* Returns the class for a CamelMhFolder */ -#define CMHF_CLASS(so) CAMEL_MH_FOLDER_CLASS (GTK_OBJECT(so)->klass) -#define CF_CLASS(so) CAMEL_FOLDER_CLASS (GTK_OBJECT(so)->klass) -#define CMHS_CLASS(so) CAMEL_STORE_CLASS (GTK_OBJECT(so)->klass) - -static void camel_mh_folder_set_name(CamelFolder *folder, GString *name); - - -static void -camel_mh_folder_class_init (CamelMhFolderClass *camel_mh_folder_class) -{ - parent_class = gtk_type_class (camel_folder_get_type ()); - - /* virtual method definition */ - /* virtual method overload */ - CAMEL_FOLDER_CLASS(camel_mh_folder_class)->set_name = camel_mh_folder_set_name; -} - - - - - - - -GtkType -camel_mh_folder_get_type (void) -{ - static GtkType camel_mh_folder_type = 0; - - if (!camel_mh_folder_type) { - GtkTypeInfo camel_mh_folder_info = - { - "CamelMhFolder", - sizeof (CamelMhFolder), - sizeof (CamelMhFolderClass), - (GtkClassInitFunc) camel_mh_folder_class_init, - (GtkObjectInitFunc) NULL, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_mh_folder_type = gtk_type_unique (CAMEL_FOLDER_TYPE, &camel_mh_folder_info); - } - - return camel_mh_folder_type; -} - - -/** - * camel_mh_folder_set_name: set the name of an MH folder - * @folder: the folder to set the name - * @name: a string representing the (short) name - * - * - * - **/ -static void -camel_mh_folder_set_name(CamelFolder *folder, GString *name) -{ - GString *root_dir_path; - GString *full_dir_path; - CamelMhFolder *mh_folder = CAMEL_MH_FOLDER(folder); - gchar separator; - - g_assert(folder); - g_assert(name); - g_assert(folder->parent_store); - - /* call default implementation */ - parent_class->set_name (folder, name); - - if (mh_folder->directory_path) g_string_free (mh_folder->directory_path, 0); - - separator = camel_store_get_separator (folder->parent_store); - - - root_dir_path = camel_mh_store_get_toplevel_dir (CAMEL_MH_STORE(folder->parent_store)); - full_dir_path = g_string_clone(root_dir_path); - g_string_append_c(full_dir_path, separator); - g_string_append_g_string(full_dir_path, name); - mh_folder->directory_path = full_dir_path; - - -} diff --git a/camel/providers/MH/camel-mh-folder.h b/camel/providers/MH/camel-mh-folder.h deleted file mode 100644 index 2e9fbb47f0..0000000000 --- a/camel/providers/MH/camel-mh-folder.h +++ /dev/null @@ -1,70 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-mh-folder.h : Abstract class for an email folder */ - -/* - * - * 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_MH_FOLDER_H -#define CAMEL_MH_FOLDER_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include -#include "camel-folder.h" -/* #include "camel-store.h" */ - -#define CAMEL_MH_FOLDER_TYPE (camel_mh_folder_get_type ()) -#define CAMEL_MH_FOLDER(obj) (GTK_CHECK_CAST((obj), CAMEL_MH_FOLDER_TYPE, CamelMhFolder)) -#define CAMEL_MH_FOLDER_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_MH_FOLDER_TYPE, CamelMhFolderClass)) -#define IS_CAMEL_MH_FOLDER(o) (GTK_CHECK_TYPE((o), CAMEL_MH_FOLDER_TYPE)) - - -typedef struct { - CamelFolder parent_object; - - GString *directory_path; - -} CamelMhFolder; - - - -typedef struct { - CamelFolderClass parent_class; - - /* Virtual methods */ - -} CamelMhFolderClass; - - -/* public methods */ - -/* Standard Gtk function */ -GtkType camel_mh_folder_get_type (void); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* CAMEL_MH_FOLDER_H */ diff --git a/camel/providers/MH/camel-mh-store.c b/camel/providers/MH/camel-mh-store.c deleted file mode 100644 index 2a1258a7b9..0000000000 --- a/camel/providers/MH/camel-mh-store.c +++ /dev/null @@ -1,89 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-mh-store.c : class for an mh store */ - -/* - * - * 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-mh-store.h" -#include "camel-mh-folder.h" - -static GtkObjectClass *parent_class=NULL; - -/* Returns the class for a CamelMhStore */ -#define CS_CLASS(so) CAMEL_MH_STORE_CLASS (GTK_OBJECT(so)->klass) - - - -static void -camel_mh_store_class_init (CamelMhStoreClass *camel_mh_store_class) -{ - parent_class = gtk_type_class (camel_store_get_type ()); - - /* virtual method definition */ - /* virtual method overload */ -} - - - - - - - -GtkType -camel_mh_store_get_type (void) -{ - static GtkType camel_mh_store_type = 0; - - if (!camel_mh_store_type) { - GtkTypeInfo camel_mh_store_info = - { - "CamelMhStore", - sizeof (CamelMhStore), - sizeof (CamelMhStoreClass), - (GtkClassInitFunc) camel_mh_store_class_init, - (GtkObjectInitFunc) NULL, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_mh_store_type = gtk_type_unique (CAMEL_FOLDER_TYPE, &camel_mh_store_info); - } - - return camel_mh_store_type; -} - - - - -/** These evil public functions are here for test only **/ -void -camel_mh_store_set_toplevel_dir(CamelMhStore *store, GString *toplevel) -{ - store->toplevel_dir = toplevel; - CAMEL_STORE(store)->separator = '/'; -} - - -GString * -camel_mh_store_get_toplevel_dir(CamelMhStore *store) -{ - return store->toplevel_dir; -} diff --git a/camel/providers/MH/camel-mh-store.h b/camel/providers/MH/camel-mh-store.h deleted file mode 100644 index 058eb48c64..0000000000 --- a/camel/providers/MH/camel-mh-store.h +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-mhstore.h : class for an mh store */ - -/* - * - * 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_MH_STORE_H -#define CAMEL_MH_STORE_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include -#include "camel-store.h" - -#define CAMEL_MH_STORE_TYPE (camel_mh_store_get_type ()) -#define CAMEL_MH_STORE(obj) (GTK_CHECK_CAST((obj), CAMEL_MH_STORE_TYPE, CamelMhStore)) -#define CAMEL_MH_STORE_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_MH_STORE_TYPE, CamelMhStoreClass)) -#define IS_CAMEL_MH_STORE(o) (GTK_CHECK_TYPE((o), CAMEL_MH_STORE_TYPE)) - - -typedef struct { - CamelStore parent_object; - - GString *toplevel_dir; - -} CamelMhStore; - - - -typedef struct { - CamelStoreClass parent_class; - - -} CamelMhStoreClass; - - -/* public methods */ - -/* Standard Gtk function */ -GtkType camel_mh_store_get_type (void); - -void camel_mh_store_set_toplevel_dir(CamelMhStore *store, GString *toplevel); -GString *camel_mh_store_get_toplevel_dir(CamelMhStore *store); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* CAMEL_MH_STORE_H */ diff --git a/camel/providers/Makefile.am b/camel/providers/Makefile.am deleted file mode 100644 index 7bdc7a7eab..0000000000 --- a/camel/providers/Makefile.am +++ /dev/null @@ -1,3 +0,0 @@ -## Process this file with automake to produce Makefile.in - -SUBDIRS = MH diff --git a/camel/string-utils.c b/camel/string-utils.c deleted file mode 100644 index 7cfd07e6d8..0000000000 --- a/camel/string-utils.c +++ /dev/null @@ -1,251 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* string-util : utilities for gchar* strings */ - -/* - * - * 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 -#include "string-utils.h" -#include "camel-log.h" - - - -gboolean -string_equal_for_glist (gconstpointer v, gconstpointer v2) -{ - return (!strcmp ( ((const gchar *)v), ((const gchar*)v2))) == 0; -} - -/** - * string_dichotomy: - * @sep : separator - * @prefix: pointer to be field by the prefix object - * the prefix is not returned when the given pointer is NULL - * @suffix: pointer to be field by the suffix object - * the suffix is not returned when the given pointer is NULL - * - * Return the strings before and/or after - * the last occurence of the specified separator - * - * This routine returns the string before and/or after - * a character given as an argument. - * if the separator is the last character, prefix and/or - * suffix is set to NULL and result is set to 'l' - * if the separator is not in the list, prefix and/or - * suffix is set to NULL and result is set to 'n' - * When the operation succedeed, the return value is 'o' - * - * @Return Value : result of the operation ('o', 'l' or 'n') - * - **/ -gchar -string_dichotomy (const gchar *string, gchar sep, gchar **prefix, gchar **suffix, - StringDichotomyOption options) -{ - gchar *tmp_str; - gint sep_pos, first, last, len; - - g_assert (string); - CAMEL_LOG_FULL_DEBUG (\ - "string_dichotomy:: string=\"%s\"\n\tseparator=\"%c\" \n\tprefix=%p \n\tsuffix=%p \n\toptions=%ld\n",\ - string, sep, prefix, suffix, options); - len = strlen (string); - if (!len) { - if (prefix) - *prefix=NULL; - if (suffix) - *suffix=NULL; - CAMEL_LOG_FULL_DEBUG ("string_dichotomy:: input string is empty\n"); - return 'n'; - } - first = 0; - last = len-1; - - if ( (options & STRING_DICHOTOMY_STRIP_LEADING ) && (string[first] == sep) ) - do {first++;} while ( (firstfirst)) - last--; - - if (first==last) { - if (prefix) *prefix=NULL; - if (suffix) *suffix=NULL; - CAMEL_LOG_FULL_DEBUG ("string_dichotomy: after stripping, string is empty\n"); - return 'n'; - } - - if (options & STRING_DICHOTOMY_RIGHT_DIR) { - sep_pos = last; - while ((sep_pos>=first) && (string[sep_pos]!=sep)) { - sep_pos--; - } - } else { - sep_pos = first; - while ((sep_pos<=last) && (string[sep_pos]!=sep)) { - sep_pos++; - } - - } - - if ( (sep_poslast) ) - { - if (suffix) *suffix=NULL; - if (prefix) *prefix=NULL; - CAMEL_LOG_FULL_DEBUG ("string_dichotomy: separator not found\n"); - return 'n'; - } - - /* if we have stripped trailing separators, we should */ - /* never enter here */ - if (sep_pos==last) - { - if (suffix) *suffix=NULL; - if (prefix) *prefix=NULL; - CAMEL_LOG_FULL_DEBUG ("string_dichotomy: separator is last character\n"); - return 'l'; - } - /* if we have stripped leading separators, we should */ - /* never enter here */ - if (sep_pos==first) - { - if (suffix) *suffix=NULL; - if (prefix) *prefix=NULL; - CAMEL_LOG_FULL_DEBUG ("string_dichotomy: separator is first character\n"); - return 'l'; - } - CAMEL_LOG_FULL_DEBUG ("string_dichotomy: separator found at :%d\n", sep_pos); - if (prefix) { /* return the prefix */ - *prefix = g_strndup(string+first,sep_pos-first); - CAMEL_LOG_FULL_DEBUG ( "string_dichotomy:: prefix:\"%s\"\n", *prefix); - } - if (suffix) { /* return the suffix */ - *suffix = g_strndup(string+sep_pos+1, last-sep_pos); - CAMEL_LOG_FULL_DEBUG ( "string_dichotomy:: suffix:\"%s\"\n", *suffix); - } - - return 'o'; -} - - - - - - -/* utility func : frees a gchar element in a GList */ -static void -__string_list_free_string (gpointer data, gpointer user_data) -{ - gchar *string = (gchar *)data; - g_free(string); -} - - -void -string_list_free (GList *string_list) -{ - g_list_foreach (string_list, __string_list_free_string, NULL); - g_list_free (string_list); -} - - - - - - -GList * -string_split (const gchar *string, char sep, const gchar *trim_chars, StringTrimOption trim_options) -{ - GList *result = NULL; - gint first, last, pos; - gchar *new_string; - - g_assert (string); - - first = 0; - last = strlen(string) - 1; - - /* strip leading and trailing separators */ - while ( (first<=last) && (string[first]==sep) ) - first++; - while ( (first<=last) && (string[last]==sep) ) - last--; - - - CAMEL_LOG_FULL_DEBUG ("string_split:: trim options: %d\n", trim_options); - - while (first<=last) { - pos = first; - /* find next separator */ - while ((pos<=last) && (string[pos]!=sep)) pos++; - if (first != pos) { - new_string = g_strndup (string+first, pos-first); - /* could do trimming in line to speed up this code */ - if (trim_chars) string_trim (new_string, trim_chars, trim_options); - result = g_list_append (result, new_string); - } - first = pos + 1; - } - - return result; -} - - -void -string_trim (gchar *string, const gchar *trim_chars, StringTrimOption options) -{ - gint first_ok; - gint last_ok; - guint length; - - CAMEL_LOG_FULL_DEBUG ("string-utils:: Entering string_trim::\n"); - CAMEL_LOG_FULL_DEBUG ("string_trim:: trim_chars:\"%s\"", trim_chars); - CAMEL_LOG_FULL_DEBUG ("string_trim:: trim_options:%d\n", options); - - g_return_if_fail (string); - length = strlen (string); - g_return_if_fail (length > 0); - - first_ok = 0; - last_ok = length - 1; - - if (options & STRING_TRIM_STRIP_LEADING) - while ( (first_ok <= last_ok) && (strchr (trim_chars, string[first_ok])!=NULL) ) - first_ok++; - - if (options & STRING_TRIM_STRIP_TRAILING) - while ( (first_ok <= last_ok) && (strchr (trim_chars, string[last_ok])!=NULL) ) - last_ok--; - CAMEL_LOG_FULL_DEBUG ("string_trim::\n\t\"%s\":first ok:%d last_ok:%d\n", - string, first_ok, last_ok); - - if (first_ok > 0) - memmove (string, string+first_ok, last_ok - first_ok +2); - -} - - - - - - - diff --git a/camel/string-utils.h b/camel/string-utils.h deleted file mode 100644 index 9805861daf..0000000000 --- a/camel/string-utils.h +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* string-util : utilities for normal gchar * strings */ - -/* - * - * 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 STRING_UTIL_H -#define STRING_UTIL_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include - -typedef enum { - STRING_DICHOTOMY_NONE = 0, - STRING_DICHOTOMY_RIGHT_DIR = 1, - STRING_DICHOTOMY_STRIP_TRAILING = 2, - STRING_DICHOTOMY_STRIP_LEADING = 4, - -} StringDichotomyOption; - -typedef enum { - STRING_TRIM_NONE = 0, - STRING_TRIM_STRIP_TRAILING = 1, - STRING_TRIM_STRIP_LEADING = 2, -} StringTrimOption; - -gboolean string_equal_for_glist (gconstpointer v, gconstpointer v2); - -gchar string_dichotomy (const gchar *string, gchar sep, - gchar **prefix, gchar **suffix, - StringDichotomyOption options); -void string_list_free (GList *string_list); - -GList *string_split (const gchar *string, char sep, - const gchar *trim_chars, StringTrimOption trim_options); -void string_trim (gchar *string, const gchar *chars, - StringTrimOption options); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* STRING_UTIL_H */ diff --git a/camel/url-util.c b/camel/url-util.c deleted file mode 100644 index cf2425fdc3..0000000000 --- a/camel/url-util.c +++ /dev/null @@ -1,398 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* url-util.c : utility functions to parse URLs */ - - -/* - * 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 - */ - - - -/* - Here we deal with URL following the general scheme: - protocol://user:password@host:port/name - where name is a path-like string (ie dir1/dir2/....) - See rfc1738 for the complete description of - Uniform Ressource Locators - - Bertrand. */ -/* - XXX TODO: recover the words between #'s or ?'s after the path */ - -#include -#include "url-util.h" - -/* general item finder */ -/* it begins the search at position @position in @url, - returns true when the item is found, amd set position after the item */ -typedef gboolean find_item_func(gchar *url, gchar **item, guint *position, gboolean *error); - -/* used to find one item (protocol, then user .... */ -typedef struct { - char *item_name; /* item name : for debug only */ - gchar **item_value; /* where the item value will go */ - find_item_func *find_func; /* item finder */ -} FindStepStruct; - -static gboolean find_protocol (gchar *url, gchar **item, guint *position, gboolean *error); -static gboolean find_user (gchar *url, gchar **item, guint *position, gboolean *error); -static gboolean find_passwd (gchar *url, gchar **item, guint *position, gboolean *error); -static gboolean find_host (gchar *url, gchar **item, guint *position, gboolean *error); -static gboolean find_port (gchar *url, gchar **item, guint *position, gboolean *error); -static gboolean find_path (gchar *url, gchar **item, guint *position, gboolean *error); - - - -/** - * g_url_new: create an Gurl object from a string - * - * @url_string: The string containing the URL to scan - * - * This routine takes a gchar and parses it as an - * URL of the form: - * protocol://user:password@host:port/path - * there is no test on the values. For example, - * "port" can be a string, not only a number ! - * The Gurl structure fields ar filled with - * the scan results. When a member of the - * general URL can not be found, the corresponding - * Gurl member is NULL - * Fields filled in the Gurl structure are allocated - * and url_string is not modified. - * - * Return value: a Gurl structure containing the URL items. - **/ -Gurl *g_url_new (gchar* url_string) -{ - Gurl *g_url; - - gchar *protocol; - gchar *user; - gchar *passwd; - gchar *host; - gchar *port; - gchar *path; - - guint position=0; - gboolean error; - gboolean found; - guint i; - - g_url = g_new(Gurl,1); - -#define NB_STEP_URL 6 - { - FindStepStruct step[NB_STEP_URL] = { - { "protocol", &(g_url->protocol), find_protocol}, - { "user", &(g_url->user), find_user}, - { "password", &(g_url->passwd), find_passwd}, - { "host", &(g_url->host), find_host}, - { "port", &(g_url->port), find_port}, - { "path", &(g_url->path), find_path} - }; - - for (i=0; i - * - * 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 URL_UTIL_H -#define URL_UTIL_H 1 - -#include - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -typedef struct { - gchar *protocol; - gchar *user; - gchar *passwd; - gchar *host; - gchar *port; - gchar *path; - - /* used only as a cache */ - gchar *url_string; -} Gurl; - -Gurl *g_url_new (gchar *url_string); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* URL_UTIL_H */ -- cgit v1.2.3