diff options
Diffstat (limited to 'camel')
43 files changed, 0 insertions, 6361 deletions
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 1d35a897a6..0000000000 --- a/camel/Makefile.am +++ /dev/null @@ -1,54 +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-log.c \ - camel-data-wrapper.c \ - camel-simple-data-wrapper.c \ - camel-folder.c \ - camel-mime-message.c \ - camel-mime-part.c \ - camel-provider.c \ - camel-service.c \ - camel-session.c \ - camel-store.c \ - camel-stream.c \ - camel-stream-fs.c \ - gmime-content-field.c \ - gmime-utils.c \ - gstring-util.c \ - url-util.c - -libcamelinclude_HEADERS = \ - camel-log.h \ - camel-data-wrapper.h \ - camel-simple-data-wrapper.h \ - camel-folder.h \ - camel-mime-message.h \ - camel-mime-part.h \ - camel-provider.h \ - camel-service.h \ - camel-session.h \ - camel-store.h \ - camel-stream.h \ - camel-stream-fs.h \ - gmime-content-field.h \ - gmime-utils.h \ - gstring-util.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 f885e8a0a6..0000000000 --- a/camel/camel-data-wrapper.c +++ /dev/null @@ -1,175 +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 <Bertrand.Guiheneuf@inria.fr> . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#include "camel-data-wrapper.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, guint size); -static void _write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream); -static void _set_content_type (CamelDataWrapper *data_wrapper, GString *content_type); -static GString *_get_content_type (CamelDataWrapper *data_wrapper); - -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_content_type = _set_content_type; - camel_data_wrapper_class->get_content_type = _get_content_type; - - /* virtual method overload */ -} - - - - - -static void -camel_data_wrapper_init (gpointer object, gpointer klass) -{ - CamelDataWrapper *camel_data_wrapper = CAMEL_DATA_WRAPPER (object); - - camel_data_wrapper->content_type = gmime_content_field_new (NULL, NULL); -} - - - -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_wrapper: 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) -{ - CDW_CLASS(data_wrapper)->write_to_stream (data_wrapper, stream); -} - - - - - - -static void -_construct_from_stream (CamelDataWrapper *data_wrapper, CamelStream *stream, guint size) -{ - /* nothing */ -} - -void -camel_data_wrapper_construct_from_stream (CamelDataWrapper *data_wrapper, CamelStream *stream, guint size) -{ - CDW_CLASS(data_wrapper)->construct_from_stream (data_wrapper, stream, size); -} - - - -static void -_set_content_type (CamelDataWrapper *data_wrapper, GString *content_type) -{ - g_assert (content_type); - gmime_content_field_construct_from_string (data_wrapper->content_type, content_type); -} - -void -camel_data_wrapper_set_content_type (CamelDataWrapper *data_wrapper, GString *content_type) -{ - CDW_CLASS(data_wrapper)->set_content_type (data_wrapper, content_type); -} - -static GString * -_get_content_type (CamelDataWrapper *data_wrapper) -{ - GString *mime_type; - - mime_type = gmime_content_field_get_mime_type (data_wrapper->content_type); - return mime_type; -} - -static GString * -camel_data_wrapper_get_content_type (CamelDataWrapper *data_wrapper) -{ - return CDW_CLASS(data_wrapper)->get_content_type (data_wrapper); -} diff --git a/camel/camel-data-wrapper.h b/camel/camel-data-wrapper.h deleted file mode 100644 index a0bb859f3b..0000000000 --- a/camel/camel-data-wrapper.h +++ /dev/null @@ -1,85 +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 <Bertrand.Guiheneuf@inria.fr> . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#ifndef CAMEL_DATA_WRAPPER_H -#define CAMEL_DATA_WRAPPER_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include <gtk/gtk.h> -#include <stdio.h> -#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 *content_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, guint size); - void (*set_content_type) (CamelDataWrapper *data_wrapper, GString *content_type); - GString * (*get_content_type) (CamelDataWrapper *data_wrapper); - -} 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, guint size); -void camel_data_wrapper_set_content_type (CamelDataWrapper *data_wrapper, GString *content_type); -static GString *camel_data_wrapper_get_content_type (CamelDataWrapper *data_wrapper); - -#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 d7b54075be..0000000000 --- a/camel/camel-folder.c +++ /dev/null @@ -1,658 +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 <Bertrand.Guiheneuf@inria.fr> . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#include "camel-folder.h" -#include "gstring-util.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, GString *name_); -static void _set_full_name (CamelFolder *folder, GString *name); -static GString *_get_name (CamelFolder *folder); -static GString *_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, GString *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: - * @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. - * The old name object is freed. - * - **/ -static void -_set_name(CamelFolder *folder, GString *name) -{ - if (folder->name) g_string_free(folder->name, 0);; - folder->name = 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. - * The old name object is freed. - * - **/ -static void -_set_full_name(CamelFolder *folder, GString *name) -{ - if (folder->full_name) g_string_free(folder->full_name, 0);; - folder->full_name = 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 GString * -_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 GString * -_get_full_name(CamelFolder *folder) -{ - return folder->full_name; -} - - - -/** - * _can_hold_folders: tests if the folder can contain other folders - * @folder: - * - * - * - * 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: - * - * - * - * Return value: - **/ -static gboolean -_can_hold_messages(CamelFolder *folder) -{ - return folder->can_hold_messages; -} - - - -/** - * _exists: tests if the folder object exists on the store. - * @folder: - * - * - * - * Return value: - **/ -static gboolean -_exists(CamelFolder *folder) -{ - return folder->exists_on_store; -} - - - -/** - * _is_open: - * @folder: - * - * - * - * Return value: - **/ -static gboolean -_is_open(CamelFolder *folder) -{ - return (folder->open_state==FOLDER_OPEN); -} - - - - -/** - * _get_folder: return the (sub)folder object that - * is specified. - * - * 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. - * - * @folder : the folder - * @folderName: subfolder path. NULL if the subfolder object - * could not be created - **/ -static CamelFolder * -_get_folder(CamelFolder *folder, GString *folder_name) -{ - g_warning("getFolder called on the abstract CamelFolder class\n"); - return NULL; -} - -/** - * camel_folder_get_folder: return the (sub)folder object that - * is specified. - * - * 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. - * - * @folder : the folder - * @folderName: subfolder path. NULL if the subfolder object - * could not be created - **/ -CamelFolder * -camel_folder_get_folder(CamelFolder *folder, GString *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) -{ - GString *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 = g_string_dichotomy(folder->full_name, sep, &prefix, NULL, DICHOTOMY_STRIP_TRAILING | 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 8d4a9f4aef..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 <Bertrand.Guiheneuf@inria.fr> . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#ifndef CAMEL_FOLDER_H -#define CAMEL_FOLDER_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include <gtk/gtk.h> - -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; - GString *name; - GString *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, GString *name); - void (*set_full_name) (CamelFolder *folder, GString *name); - GString * (*get_name) (CamelFolder *folder); - GString * (*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, GString *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, GString *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 59ce5573b2..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 <Bertrand.Guiheneuf@inria.fr> . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#include "camel-log.h" - -int camel_debug_level = 10; -FILE *camel_log_file_descriptor = NULL; - -void -camel_log(CamelLogLevel level, const gchar *format, ... ) -{ - va_list args; - if (camel_log_file_descriptor == NULL) - camel_log_file_descriptor = stderr; - - 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 5ab9f8f405..0000000000 --- a/camel/camel-log.h +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * - * Copyright (C) 1999 Bertrand Guiheneuf <Bertrand.Guiheneuf@inria.fr> . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#ifndef CAMEL_LOG_H -#define CAMEL_LOG_H - - -#include <stdarg.h> -#include <glib.h> -#include <stdio.h> - -extern int camel_debug_level; -extern FILE *camel_log_file_descriptor; - -typedef enum { - NO_LOG = 0, - STRANGE = 5, - WARNING = 6, - TRACE = 8, - FULL_DEBUG = 10 -} CamelLogLevel; - -#define HARD_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). For the moment, only -soft level is implmented, but one day, when performance -become important, I will set the hard one too */ - - -#define CAMEL_LOG(level, args...) camel_log(level,##args) - -extern void camel_log(CamelLogLevel level, const gchar *format, ... ); - -#endif /* CAMEL_LOG_H */ diff --git a/camel/camel-mime-message.c b/camel/camel-mime-message.c deleted file mode 100644 index df65c127f6..0000000000 --- a/camel/camel-mime-message.c +++ /dev/null @@ -1,648 +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 <Bertrand.Guiheneuf@inria.fr> . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#include "camel-mime-message.h" -#include <stdio.h> -#include "gmime-content-field.h" -#include "gstring-util.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 GString *received_date_str; -static GString *sent_date_str; -static GString *reply_to_str; -static GString *subject_str; -static GString *from_str; - -static void _set_received_date (CamelMimeMessage *mime_message, GString *received_date); -static GString *_get_received_date (CamelMimeMessage *mime_message); -static GString *_get_sent_date (CamelMimeMessage *mime_message); -static void _set_reply_to (CamelMimeMessage *mime_message, GString *reply_to); -static GString *_get_reply_to (CamelMimeMessage *mime_message); -static void _set_subject (CamelMimeMessage *mime_message, GString *subject); -static GString *_get_subject (CamelMimeMessage *mime_message); -static void _set_from (CamelMimeMessage *mime_message, GString *from); -static GString *_get_from (CamelMimeMessage *mime_message); - -static void _add_recipient (CamelMimeMessage *mime_message, GString *recipient_type, GString *recipient); -static void _remove_recipient (CamelMimeMessage *mime_message, GString *recipient_type, GString *recipient); -static GList *_get_recipients (CamelMimeMessage *mime_message, GString *recipient_type); - -static void _set_flag (CamelMimeMessage *mime_message, GString *flag, gboolean value); -static gboolean _get_flag (CamelMimeMessage *mime_message, GString *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, GString *header_name, GString *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_string_hash, g_string_equal_for_hash); - g_hash_table_insert (header_name_table, g_string_new ("From"), (gpointer)HEADER_FROM); - g_hash_table_insert (header_name_table, g_string_new ("Reply-To"), (gpointer)HEADER_REPLY_TO); - g_hash_table_insert (header_name_table, g_string_new ("Subject"), (gpointer)HEADER_SUBJECT); - g_hash_table_insert (header_name_table, g_string_new ("To"), (gpointer)HEADER_TO); - g_hash_table_insert (header_name_table, g_string_new ("Cc"), (gpointer)HEADER_CC); - g_hash_table_insert (header_name_table, g_string_new ("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 = g_string_new(""); - sent_date_str = g_string_new(""); - reply_to_str = g_string_new("Reply-To"); - subject_str = g_string_new("Subject"); - from_str = g_string_new("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_string_hash, g_string_equal_for_hash); - camel_mime_message->flags = g_hash_table_new(g_string_hash, g_string_equal_for_hash); - -} - - - - - -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, GString *name, GString *value, GString **variable) -{ - if (variable) { - if (*variable) g_string_free (*variable, FALSE); - *variable = value; - } -} - -static GString * -_get_field (CamelMimeMessage *mime_message, GString *name, GString *variable) -{ - return variable; -} - - - - - -static void -_set_received_date (CamelMimeMessage *mime_message, GString *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, GString *received_date) -{ - CMM_CLASS (mime_message)->set_received_date (mime_message, received_date); -} - - -static GString * -_get_received_date (CamelMimeMessage *mime_message) -{ - return _get_field (mime_message, received_date_str, mime_message->received_date); -} - -GString * -camel_mime_message_get_received_date (CamelMimeMessage *mime_message) -{ - return CMM_CLASS (mime_message)->get_received_date (mime_message); -} - - - - - - -static GString * -_get_sent_date (CamelMimeMessage *mime_message) -{ - return _get_field (mime_message, sent_date_str, mime_message->sent_date); -} - -GString * -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, GString *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, GString *reply_to) -{ - CMM_CLASS (mime_message)->set_reply_to (mime_message, reply_to); -} - - -static GString * -_get_reply_to (CamelMimeMessage *mime_message) -{ - return _get_field (mime_message, reply_to_str, mime_message->reply_to); -} - -GString * -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, GString *subject) -{ - _set_field (mime_message, subject_str, subject, &(mime_message->subject)); -} - -void -camel_mime_message_set_subject (CamelMimeMessage *mime_message, GString *subject) -{ - CMM_CLASS (mime_message)->set_subject (mime_message, subject); -} - - -static GString * -_get_subject (CamelMimeMessage *mime_message) -{ - return _get_field (mime_message, subject_str, mime_message->subject); -} - -GString * -camel_mime_message_get_subject (CamelMimeMessage *mime_message) -{ - return CMM_CLASS (mime_message)->get_subject (mime_message); -} - - - - -static void -_set_from (CamelMimeMessage *mime_message, GString *from) -{ - _set_field (mime_message, from_str, from, &(mime_message->from)); -} - -void -camel_mime_message_set_from (CamelMimeMessage *mime_message, GString *from) -{ - CMM_CLASS (mime_message)->set_from (mime_message, from); -} - - -static GString * -_get_from (CamelMimeMessage *mime_message) -{ - return _get_field (mime_message, from_str, mime_message->from); -} - -GString * -camel_mime_message_get_from (CamelMimeMessage *mime_message) -{ - return CMM_CLASS (mime_message)->get_from (mime_message); -} - - - - - - -static void -_add_recipient (CamelMimeMessage *mime_message, GString *recipient_type, GString *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, g_string_equal_for_glist) ) { - g_string_free (recipient_type, FALSE); - g_string_free (recipient, FALSE); - 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_string_free (recipient_type, FALSE); -} - - -/** - * 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, GString *recipient_type, GString *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, GString *recipient_type, GString *recipient) -{ - GList *recipients_list; - GList *new_recipients_list; - GList *old_element; - GString *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 */ - old_element = g_list_find_custom (recipients_list, recipient, g_string_equal_for_hash); - 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_string_free( (GString *)(old_element->data), FALSE); - g_list_free_1(old_element); - } -} - - -void -camel_mime_message_remove_recipient (CamelMimeMessage *mime_message, GString *recipient_type, GString *recipient) -{ - CMM_CLASS (mime_message)->remove_recipient (mime_message, recipient_type, recipient); -} - - - - -static GList * -_get_recipients (CamelMimeMessage *mime_message, GString *recipient_type) -{ - return (GList *)g_hash_table_lookup (mime_message->recipients, recipient_type); -} - -GList * -camel_mime_message_get_recipients (CamelMimeMessage *mime_message, GString *recipient_type) -{ - return CMM_CLASS (mime_message)->get_recipients (mime_message, recipient_type); -} - - - - -static void -_set_flag (CamelMimeMessage *mime_message, GString *flag, gboolean value) -{ - GString 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_string_free (flag, FALSE); - } - *ptr_value = value; - -} - -void -camel_mime_message_set_flag (CamelMimeMessage *mime_message, GString *flag, gboolean value) -{ - CMM_CLASS (mime_message)->set_flag (mime_message, flag, value); -} - - - -static gboolean -_get_flag (CamelMimeMessage *mime_message, GString *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, GString *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) -{ - GString *recipient_type = (GString *)key; - GList *recipients = (GList *)value; - // GString *current; - CamelStream *stream = (CamelStream *)user_data; - if ( (recipient_type) && (recipient_type->str) ) - write_header_with_glist_to_stream (stream, recipient_type->str, 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, "Writing \"From\"\n"); - WHPT (stream, "From", mm->from); - CAMEL_LOG (FULL_DEBUG, "Writing \"Reply-To\"\n"); - WHPT (stream, "Reply-To", mm->reply_to); - CAMEL_LOG (FULL_DEBUG, "Writing recipients\n"); - _write_recipients_to_stream (mm, stream); - CAMEL_LOG (FULL_DEBUG, "Writing \"Date\"\n"); - WHPT (stream, "Date", mm->received_date); - CAMEL_LOG (FULL_DEBUG, "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, GString *recipient_type, GString *recipients_string) -{ - GList *recipients_list; - CAMEL_LOG (FULL_DEBUG,"CamelMimeMessage::_set_recipient_list_from_string parsing ##%s##\n", recipients_string->str); - recipients_list = g_string_split (recipients_string, ',', "\t ", TRIM_STRIP_TRAILING | TRIM_STRIP_LEADING); - g_hash_table_insert (message->recipients, recipient_type, recipients_list); - -} - -static gboolean -_parse_header_pair (CamelMimePart *mime_part, GString *header_name, GString *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->str ); - - 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->str ); - - 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->str ); - - 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->str ); - - _set_recipient_list_from_string (message, g_string_new ("To"), header_value); - g_string_free (header_value, TRUE); - header_handled = TRUE; - break; - - case HEADER_CC: - CAMEL_LOG (FULL_DEBUG, - "CamelMimeMessage::parse_header_pair found HEADER_CC : %s\n", - header_value->str ); - - _set_recipient_list_from_string (message, g_string_new ("Cc"), header_value); - g_string_free (header_value, TRUE); - header_handled = TRUE; - break; - - case HEADER_BCC: - CAMEL_LOG (FULL_DEBUG, - "CamelMimeMessage::parse_header_pair found HEADER_BCC : %s\n", - header_value->str ); - - _set_recipient_list_from_string (message, g_string_new ("Bcc"), header_value); - g_string_free (header_value, TRUE); - header_handled = TRUE; - break; - - - } - if (header_handled) { - g_string_free (header_name, TRUE); - 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 73d1cb9388..0000000000 --- a/camel/camel-mime-message.h +++ /dev/null @@ -1,137 +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 <Bertrand.Guiheneuf@inria.fr> . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#ifndef CAMEL_MIME_MESSAGE_H -#define CAMEL_MIME_MESSAGE_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include <gtk/gtk.h> -#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 */ - GString *received_date; - GString *sent_date; - - GString *subject; - GString *reply_to; - - GString *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, GString *received_date); - GString * (*get_received_date) (CamelMimeMessage *mime_message); - GString * (*get_sent_date) (CamelMimeMessage *mime_message); - void (*set_reply_to) (CamelMimeMessage *mime_message, GString *reply_to); - GString * (*get_reply_to) (CamelMimeMessage *mime_message); - void (*set_subject) (CamelMimeMessage *mime_message, GString *subject); - GString * (*get_subject) (CamelMimeMessage *mime_message); - void (*set_from) (CamelMimeMessage *mime_message, GString *from); - GString * (*get_from) (CamelMimeMessage *mime_message); - void (*add_recipient) (CamelMimeMessage *mime_message, GString *recipient_type, GString *recipient); - void (*remove_recipient) (CamelMimeMessage *mime_message, GString *recipient_type, GString *recipient); - GList * (*get_recipients) (CamelMimeMessage *mime_message, GString *recipient_type); - void (*set_flag) (CamelMimeMessage *mime_message, GString *flag, gboolean value); - gboolean (*get_flag) (CamelMimeMessage *mime_message, GString *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, GString *received_date); -GString *camel_mime_message_get_received_date (CamelMimeMessage *mime_message); -GString *camel_mime_message_get_sent_date (CamelMimeMessage *mime_message); -void camel_mime_message_set_reply_to (CamelMimeMessage *mime_message, GString *reply_to); -GString *camel_mime_message_get_reply_to (CamelMimeMessage *mime_message); -void camel_mime_message_set_subject (CamelMimeMessage *mime_message, GString *subject); -GString *camel_mime_message_get_subject (CamelMimeMessage *mime_message); -void camel_mime_message_set_from (CamelMimeMessage *mime_message, GString *from); -GString *camel_mime_message_get_from (CamelMimeMessage *mime_message); - -void camel_mime_message_add_recipient (CamelMimeMessage *mime_message, GString *recipient_type, GString *recipient); -void camel_mime_message_remove_recipient (CamelMimeMessage *mime_message, GString *recipient_type, GString *recipient); -GList *camel_mime_message_get_recipients (CamelMimeMessage *mime_message, GString *recipient_type); - -void camel_mime_message_set_flag (CamelMimeMessage *mime_message, GString *flag, gboolean value); -gboolean camel_mime_message_get_flag (CamelMimeMessage *mime_message, GString *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 89eb85b35f..0000000000 --- a/camel/camel-mime-part.c +++ /dev/null @@ -1,642 +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 <Bertrand.Guiheneuf@inria.fr> . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#include "camel-mime-part.h" -#include <stdio.h> -#include "gmime-content-field.h" -#include "gstring-util.h" -#include "camel-log.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, GString *header_name, GString *header_value); -static void _remove_header (CamelMimePart *mime_part, GString *header_name); -static GString *_get_header (CamelMimePart *mime_part, GString *header_name); -static void _set_description (CamelMimePart *mime_part, GString *description); -static GString *_get_description (CamelMimePart *mime_part); -static void _set_disposition (CamelMimePart *mime_part, GString *disposition); -static GString *_get_disposition (CamelMimePart *mime_part); -static void _set_filename (CamelMimePart *mime_part, GString *filename); -static GString *_get_filename (CamelMimePart *mime_part); -static void _set_content_id (CamelMimePart *mime_part, GString *content_id); -static GString *_get_content_id (CamelMimePart *mime_part); -static void _set_content_MD5 (CamelMimePart *mime_part, GString *content_MD5); -static GString *_get_content_MD5 (CamelMimePart *mime_part); -static void _set_encoding (CamelMimePart *mime_part, GString *encoding); -static GString *_get_encoding (CamelMimePart *mime_part); -static void _set_content_languages (CamelMimePart *mime_part, GList *content_languages); -static GList *_get_content_languages (CamelMimePart *mime_part); -static void _set_header_lines (CamelMimePart *mime_part, GList *header_lines); -static GList *_get_header_lines (CamelMimePart *mime_part); - -static CamelDataWrapper *_get_content_object(CamelMimePart *mime_part); -static void _write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream); - -static gboolean _parse_header_pair (CamelMimePart *mime_part, GString *header_name, GString *header_value); - - -/* 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_string_hash, g_string_equal_for_hash); - g_hash_table_insert (header_name_table, g_string_new ("Content-Description"), (gpointer)HEADER_DESCRIPTION); - g_hash_table_insert (header_name_table, g_string_new ("Content-Disposition"), (gpointer)HEADER_DISPOSITION); - g_hash_table_insert (header_name_table, g_string_new ("Content-id"), (gpointer)HEADER_CONTENT_ID); - g_hash_table_insert (header_name_table, g_string_new ("Content-Transfer-Encoding"), (gpointer)HEADER_ENCODING); - g_hash_table_insert (header_name_table, g_string_new ("Content-MD5"), (gpointer)HEADER_CONTENT_MD5); - g_hash_table_insert (header_name_table, g_string_new ("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->parse_header_pair = _parse_header_pair; - camel_mime_part_class->get_content_object = _get_content_object; - - - - /* virtual method overload */ - camel_data_wrapper_class->write_to_stream = _write_to_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_string_hash, g_string_equal_for_hash); - -} - - - - -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, GString *header_name, GString *header_value) -{ - gboolean header_exists; - GString *old_header_name; - GString *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_string_free (old_header_name, TRUE); - g_string_free (old_header_value, TRUE); - } - - g_hash_table_insert (mime_part->headers, header_name, header_value); -} - - -void -camel_mime_part_add_header (CamelMimePart *mime_part, GString *header_name, GString *header_value) -{ - CMP_CLASS(mime_part)->add_header(mime_part, header_name, header_value); -} - - - -static void -_remove_header (CamelMimePart *mime_part, GString *header_name) -{ - - gboolean header_exists; - GString *old_header_name; - GString *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_string_free (old_header_name, TRUE); - g_string_free (old_header_value, TRUE); - } - - g_hash_table_remove (mime_part->headers, header_name); - -} - -void -camel_mime_part_remove_header (CamelMimePart *mime_part, GString *header_name) -{ - CMP_CLASS(mime_part)->remove_header(mime_part, header_name); -} - - - -static GString * -_get_header (CamelMimePart *mime_part, GString *header_name) -{ - - GString *old_header_name; - GString *old_header_value; - GString *header_value; - - header_value = (GString *)g_hash_table_lookup (mime_part->headers, header_name); - return header_value; -} - -GString * -camel_mime_part_get_header (CamelMimePart *mime_part, GString *header_name) -{ - return CMP_CLASS(mime_part)->get_header (mime_part, header_name); -} - - - -static void -_set_description (CamelMimePart *mime_part, GString *description) -{ - if (mime_part->description) g_free(mime_part->description); - mime_part->description = description; -} - -void -camel_mime_part_set_description (CamelMimePart *mime_part, GString *description) -{ - CMP_CLASS(mime_part)->set_description (mime_part, description); -} - - - - -static GString * -_get_description (CamelMimePart *mime_part) -{ - return mime_part->description; -} - -GString * -camel_mime_part_get_description (CamelMimePart *mime_part) -{ - return CMP_CLASS(mime_part)->get_description (mime_part); -} - - - -static void -_set_disposition (CamelMimePart *mime_part, GString *disposition) -{ - //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, GString *disposition) -{ - CMP_CLASS(mime_part)->set_disposition (mime_part, disposition); -} - - - -static GString * -_get_disposition (CamelMimePart *mime_part) -{ - if (!mime_part->disposition) return NULL; - return (mime_part->disposition)->type; -} - - -GString * -camel_mime_part_get_disposition (CamelMimePart *mime_part) -{ - return CMP_CLASS(mime_part)->get_disposition (mime_part); -} - - - -static void -_set_filename (CamelMimePart *mime_part, GString *filename) -{ - if (mime_part->filename) g_free(mime_part->filename); - mime_part->filename = filename; -} - - -void -camel_mime_part_set_filename (CamelMimePart *mime_part, GString *filename) -{ - CMP_CLASS(mime_part)->set_filename (mime_part, filename); -} - - - -static GString * -_get_filename (CamelMimePart *mime_part) -{ - return mime_part->filename; -} - - -GString * -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, GString *content_id) -{ - if (mime_part->content_id) g_free(mime_part->content_id); - mime_part->content_id = content_id; -} - - -static GString * -_get_content_id (CamelMimePart *mime_part) -{ - return mime_part->content_id; -} - - -GString * -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, GString *content_MD5) -{ - if (mime_part->content_MD5) g_free(mime_part->content_MD5); - mime_part->content_MD5 = content_MD5; -} - - -static GString * -_get_content_MD5 (CamelMimePart *mime_part) -{ - return mime_part->content_MD5; -} - -GString * -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, GString *encoding) -{ - if (mime_part->encoding) g_free(mime_part->encoding); - mime_part->encoding = encoding; -} - -void -camel_mime_part_set_encoding (CamelMimePart *mime_part, GString *encoding) -{ - CMP_CLASS(mime_part)->set_encoding (mime_part, encoding); -} - - - -static GString * -_get_encoding (CamelMimePart *mime_part) -{ - return mime_part->encoding; -} - -GString * -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) g_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 GList * -_get_content_languages (CamelMimePart *mime_part) -{ - return mime_part->content_languages; -} - - -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) g_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 GList * -_get_header_lines (CamelMimePart *mime_part) -{ - return mime_part->header_lines; -} - - - -GList * -camel_mime_part_get_header_lines (CamelMimePart *mime_part) -{ - return CMP_CLASS(mime_part)->get_header_lines (mime_part); -} - - - - -static CamelDataWrapper * -_get_content_object(CamelMimePart *mime_part) -{ - return mime_part->content; - -} -CamelDataWrapper * -camel_mime_part_get_content_object(CamelMimePart *mime_part) -{ - return CMP_CLASS(mime_part)->get_content_object (mime_part); -} - - - - -/**********************************************************************/ -#ifdef WHPT -#warning : WHPT is already defined !!!!!! -#endif -#define WHPT gmime_write_header_pair_to_stream - - -/* This is not used for the moment */ -static void -_write_content_to_stream (CamelMimePart *mime_part, CamelStream *stream) -{ - guint buffer_size; - gchar *buffer; - gchar *encoded_buffer; - - CamelDataWrapper *content = mime_part->content; - // 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); -} - - - - - -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(data_wrapper->content_type, stream); - - camel_stream_write_string(stream,"\n"); - if (mp->content) camel_data_wrapper_write_to_stream (mp->content, stream); - -} - - - -/*******************************/ -/* mime part parsing */ - -static gboolean -_parse_header_pair (CamelMimePart *mime_part, GString *header_name, GString *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->str ); - - 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->str ); - - 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->str ); - - 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->str ); - - 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->str ); - - CMP_CLASS(mime_part)->set_content_MD5 (mime_part, header_value); - header_handled = TRUE; - break; - - case HEADER_CONTENT_TYPE: /**** * WARNING THIS IS BROKEN * *****/ - CAMEL_LOG (FULL_DEBUG, - "CamelMimePart::parse_header_pair found HEADER_CONTENT_TYPE: %s\n", - header_value->str ); - - gmime_content_field_construct_from_string (CAMEL_DATA_WRAPPER(mime_part)->content_type, header_value); - header_handled = TRUE; - break; - - - } - - - if (header_handled) { - g_string_free (header_name, TRUE); - return TRUE; - } else return FALSE; - -} diff --git a/camel/camel-mime-part.h b/camel/camel-mime-part.h deleted file mode 100644 index eadf65ce68..0000000000 --- a/camel/camel-mime-part.h +++ /dev/null @@ -1,126 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camelMimePart.h : class for a mime part */ - -/* - * - * Copyright (C) 1999 Bertrand Guiheneuf <Bertrand.Guiheneuf@inria.fr> . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#ifndef CAMEL_MIME_PART_H -#define CAMEL_MIME_PART_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include <gtk/gtk.h> -#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; - GString *description; - GMimeContentField *disposition; - GString *content_id; - GString *content_MD5; - GList *content_languages; - GString *encoding; - GString *filename; - GList *header_lines; - - CamelDataWrapper *content; /* part real content */ - -} CamelMimePart; - - - -typedef struct { - CamelDataWrapperClass parent_class; - - /* Virtual methods */ - void (*add_header) (CamelMimePart *mime_part, GString *header_name, GString *header_value); - void (*remove_header) (CamelMimePart *mime_part, GString *header_name); - GString * (*get_header) (CamelMimePart *mime_part, GString *header_name); - void (*set_description) (CamelMimePart *mime_part, GString *description); - GString * (*get_description) (CamelMimePart *mime_part); - void (*set_disposition) (CamelMimePart *mime_part, GString *disposition); - GString * (*get_disposition) (CamelMimePart *mime_part); - void (*set_filename) (CamelMimePart *mime_part, GString *filename); - GString * (*get_filename) (CamelMimePart *mime_part); - void (*set_content_id) (CamelMimePart *mime_part, GString *content_id); - GString * (*get_content_id) (CamelMimePart *mime_part); - void (*set_content_MD5) (CamelMimePart *mime_part, GString *content_MD5); - GString * (*get_content_MD5) (CamelMimePart *mime_part); - void (*set_encoding) (CamelMimePart *mime_part, GString *encoding); - GString * (*get_encoding) (CamelMimePart *mime_part); - void (*set_content_languages) (CamelMimePart *mime_part, GList *content_languages); - GList * (*get_content_languages) (CamelMimePart *mime_part); - void (*set_header_lines) (CamelMimePart *mime_part, GList *header_lines); - GList * (*get_header_lines) (CamelMimePart *mime_part); - - gboolean (*parse_header_pair) (CamelMimePart *mime_part, GString *header_name, GString *header_value); - - CamelDataWrapper * (*get_content_object) (CamelMimePart *mime_part); -} CamelMimePartClass; - - - -/* Standard Gtk function */ -GtkType camel_mime_part_get_type (void); - - -/* public methods */ -void camel_mime_part_add_header (CamelMimePart *mime_part, GString *header_name, GString *header_value); -void camel_mime_part_remove_header (CamelMimePart *mime_part, GString *header_name); -GString *camel_mime_part_get_header (CamelMimePart *mime_part, GString *header_name); -void camel_mime_part_set_description (CamelMimePart *mime_part, GString *description); -GString *camel_mime_part_get_description (CamelMimePart *mime_part); -void camel_mime_part_set_disposition (CamelMimePart *mime_part, GString *disposition); -GString *camel_mime_part_get_disposition (CamelMimePart *mime_part); -void camel_mime_part_set_filename (CamelMimePart *mime_part, GString *filename); -GString *camel_mime_part_get_filename (CamelMimePart *mime_part); -GString *camel_mime_part_get_content_id (CamelMimePart *mime_part); -GString *camel_mime_part_get_content_MD5 (CamelMimePart *mime_part); -void camel_mime_part_set_encoding (CamelMimePart *mime_part, GString *encoding); -GString *camel_mime_part_get_encoding (CamelMimePart *mime_part); -void camel_mime_part_set_content_languages (CamelMimePart *mime_part, GList *content_languages); -GList *camel_mime_part_get_content_languages (CamelMimePart *mime_part); -void camel_mime_part_set_header_lines (CamelMimePart *mime_part, GList *header_lines); -GList *camel_mime_part_get_header_lines (CamelMimePart *mime_part); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* CAMEL_MIME_PART_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 <Bertrand.Guiheneuf@inria.fr> . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - - -/* - - 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 <Bertrand.Guiheneuf@inria.fr> . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#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 2ca3d6f352..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 <Bertrand.Guiheneuf@inria.fr> . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#include "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, GString *host, GString *login, GString *passwd); -static void _connect_to_with_login_passwd_port(CamelService *service, GString *host, GString *login, GString *passwd, guint port); -static gboolean _is_connected(CamelService *service); -static void _set_connected(CamelService *service, gboolean state); -static GString *_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, GString *host, GString *login, GString *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, GString *host, GString *login, GString *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, GString *host, GString *login, GString *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, GString *host, GString *login, GString *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 GString * -_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 - **/ -GString * -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 d22f97a6bc..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 <Bertrand.Guiheneuf@inria.fr> . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#ifndef CAMEL_SERVICE_H -#define CAMEL_SERVICE_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include <gtk/gtk.h> - -#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; - GString *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, GString *host, GString *login, GString *passwd); - void (*connect_to_with_login_passwd_port) (CamelService *service, GString *host, GString *login, GString *passwd, guint port); - gboolean (*is_connected) (CamelService *service); - void (*set_connected) (CamelService *service, gboolean state); - GString * (*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, GString *host, GString *login, GString *passwd); -void camel_service_connect_to_with_login_passwd_port (CamelService *service, GString *host, GString *login, GString *passwd, guint port); -GString *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 42f681f626..0000000000 --- a/camel/camel-session.c +++ /dev/null @@ -1,132 +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 <Bertrand.Guiheneuf@inria.fr> . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#include "camel-session.h" -#include "gstring-util.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 <Bertrand.Guiheneuf@inria.fr> . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#ifndef CAMEL_SESSION_H -#define CAMEL_SESSION_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include <gtk/gtk.h> - -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 2d81fa62a9..0000000000 --- a/camel/camel-simple-data-wrapper.c +++ /dev/null @@ -1,132 +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 <Bertrand.Guiheneuf@inria.fr> . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#include "camel-simple-data-wrapper.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, guint size); -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 = - { - "CamelDataWrapper", - sizeof (CamelDataWrapper), - sizeof (CamelDataWrapperClass), - (GtkClassInitFunc) camel_simple_data_wrapper_class_init, - (GtkObjectInitFunc) NULL, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_simple_data_wrapper_type = gtk_type_unique (camel_data_wrapper_get_type (), &camel_simple_data_wrapper_info); - } - - return camel_simple_data_wrapper_type; -} - - - -static void -_write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream) -{ - CamelSimpleDataWrapper *simple_data_wrapper = CAMEL_SIMPLE_DATA_WRAPPER (data_wrapper); - GByteArray *array; - - 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); - - return; -} - - - - -#define _CMSDW_TMP_BUF_SIZE 100 -static void -_construct_from_stream (CamelDataWrapper *data_wrapper, CamelStream *stream, guint size) -{ - 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; - - - g_assert (data_wrapper); - g_assert (stream); - - if (!size) return; - 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(); - nb_bytes_left = size; - do { - - nb_bytes_read = camel_stream_read (stream, tmp_buf, - MIN (_CMSDW_TMP_BUF_SIZE, nb_bytes_left)); - nb_bytes_left -= nb_bytes_read; - if (nb_bytes_read) g_byte_array_append (array, tmp_buf, nb_bytes_read); - - } while (nb_bytes_read && (nb_bytes_left>0)); - -} diff --git a/camel/camel-simple-data-wrapper.h b/camel/camel-simple-data-wrapper.h deleted file mode 100644 index ce84906bc3..0000000000 --- a/camel/camel-simple-data-wrapper.h +++ /dev/null @@ -1,77 +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 <Bertrand.Guiheneuf@inria.fr> . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#ifndef CAMEL_SIMPLE_DATA_WRAPPER_H -#define CAMEL_SIMPLE_DATA_WRAPPER_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include <gtk/gtk.h> -#include <stdio.h> -#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 */ - - -#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 61c5216780..0000000000 --- a/camel/camel-store.c +++ /dev/null @@ -1,220 +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 <Bertrand.Guiheneuf@inria.fr> . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#include "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, GString *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, GString *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. - * - **/ -static void -_init(CamelStore *store, CamelSession *session, GString *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, GString *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 df8409f92e..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 <Bertrand.Guiheneuf@inria.fr> . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#ifndef CAMEL_STORE_H -#define CAMEL_STORE_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include <gtk/gtk.h> - -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; - GString *url_name; - gchar separator; -}; - - - -typedef struct { - CamelServiceClass parent_class; - - void (*init) (CamelStore *store, CamelSession *session, GString *url_name); - void (*set_separator) (CamelStore *store, gchar sep); - gchar (*get_separator) (CamelStore *store); - CamelFolder * (*get_folder) (CamelStore *store, GString *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, GString *url_name); -CamelFolder *camel_store_get_folder(CamelStore *store, GString *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 09b193b229..0000000000 --- a/camel/camel-stream-fs.c +++ /dev/null @@ -1,250 +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 <Bertrand.Guiheneuf@inria.fr> . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#include "camel-stream-fs.h" -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <errno.h> -#include "camel-log.h" - -static CamelStreamClass *parent_class=NULL; - - -/* Returns the class for a CamelMimeMessage */ -#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, 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 void -camel_stream_fs_class_init (CamelStreamClass *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; - -} - - - -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 (GString *name, CamelStreamFsMode mode) -{ - struct stat s; - int v, fd; - int flags; - CamelStreamFs *stream_fs; - - g_assert (name); - g_assert (name->str); - CAMEL_LOG (FULL_DEBUG, "Entering CamelStream::new_with_name, name=\"%s\", mode=%d\n", name->str, mode); - v = stat (name->str, &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->str, flags, 0600); - if (fd==-1) { - CAMEL_LOG (FULL_DEBUG, "CamelStreamFs::new_with_name can not obtain fd for file \"%s\"\n", name->str); - 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, 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); -} diff --git a/camel/camel-stream-fs.h b/camel/camel-stream-fs.h deleted file mode 100644 index 046e90d26c..0000000000 --- a/camel/camel-stream-fs.h +++ /dev/null @@ -1,81 +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 <Bertrand.Guiheneuf@inria.fr> . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#ifndef CAMEL_STREAM_FS_H -#define CAMEL_STREAM_FS_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include <gtk/gtk.h> -#include <stdio.h> -#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; - GString *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 (GString *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.c b/camel/camel-stream.c deleted file mode 100644 index 9f9e912bd8..0000000000 --- a/camel/camel-stream.c +++ /dev/null @@ -1,216 +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 <Bertrand.Guiheneuf@inria.fr> . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#include "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 gint _read (CamelStream *stream, gchar *buffer, gint n); -static gint _write (CamelStream *stream, 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 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 = _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; - - /* 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; -} - - - -/** - * _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) -{ - -} - -gint -camel_stream_read (CamelStream *stream, gchar *buffer, gint n) -{ - CS_CLASS (stream)->read (stream, buffer, n); -} - -/** - * _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, gchar *buffer, gint n) -{ - -} - -gint -camel_stream_write (CamelStream *stream, gchar *buffer, gint n) -{ - CS_CLASS (stream)->write (stream, buffer, n); -} - - - -/** - * _flush: flush pending changes - * @stream: the stream - * - * - **/ -static void -_flush (CamelStream *stream) -{ - -} - - - -/** - * _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) -{ - -} - - -/** - * _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) -{ - -} - - -/** - * _close: close a stream - * @stream: the stream - * - * - **/ -static void -_close (CamelStream *stream) -{ - -} - -void -camel_stream_close (CamelStream *stream) -{ - CS_CLASS (stream)->close (stream); -} - - - - - -/***************** Utility functions ********************/ - -void -camel_stream_write_strings (CamelStream *stream, ... ) -{ - va_list args; - char *string; - - va_start(args, stream); - string = va_arg (args, 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 5fff22a24a..0000000000 --- a/camel/camel-stream.h +++ /dev/null @@ -1,84 +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 <Bertrand.Guiheneuf@inria.fr> . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#ifndef CAMEL_STREAM_H -#define CAMEL_STREAM_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include <gtk/gtk.h> - -#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 struct -{ - GtkObject parent_object; - -} CamelStream; - - - -typedef struct { - GtkObjectClass parent_class; - - /* Virtual methods */ -gint (*read) (CamelStream *stream, gchar *buffer, gint n); -gint (*write) (CamelStream *stream, gchar *buffer, gint n); -void (*flush) (CamelStream *stream); -gint (*available) (CamelStream *stream); -gboolean (*eos) (CamelStream *stream); -void (*close) (CamelStream *stream); - -} 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, gchar *buffer, gint n); -void camel_stream_close (CamelStream *stream); - -/* 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/gmime-content-field.c b/camel/gmime-content-field.c deleted file mode 100644 index 06e4384437..0000000000 --- a/camel/gmime-content-field.c +++ /dev/null @@ -1,211 +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 <Bertrand.Guiheneuf@inria.fr> . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - - - -#include "gmime-content-field.h" -#include "gstring-util.h" -#include "camel-log.h" - - -GMimeContentField * -gmime_content_field_new (GString *type, GString *subtype) -{ - GMimeContentField *ctf; - - ctf = g_new (GMimeContentField,1); - ctf->type = type; - ctf->subtype = subtype; - ctf->parameters = g_hash_table_new(g_string_hash, g_string_equal_for_hash); - - return ctf; -} - - -void -gmime_content_field_set_parameter (GMimeContentField *content_field, GString *attribute, GString *value) -{ - gboolean attribute_exists; - GString *old_attribute; - GString *old_value; - - attribute_exists = g_hash_table_lookup_extended (content_field->parameters, - attribute, - (gpointer *) &old_attribute, - (gpointer *) &old_value); - if (attribute_exists) { - g_string_assign(old_value, value->str); - g_string_free (value, TRUE); - g_string_free (attribute, TRUE); - } else - g_hash_table_insert (content_field->parameters, attribute, value); -} - - -static void -_print_parameter (gpointer name, gpointer value, gpointer user_data) -{ - CamelStream *stream = (CamelStream *)user_data; - - camel_stream_write_strings (stream, - "; \n ", - ((GString *)name)->str, - "=", - ((GString *)value)->str, - NULL); - -} - -/** - * gmime_content_field_write_to: 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; - if ((content_field->type) && ((content_field->type)->str)) { - camel_stream_write_strings (stream, "Content-Type: ", content_field->type->str, NULL); - if ((content_field->subtype) && ((content_field->subtype)->str)) { - camel_stream_write_strings (stream, "/", content_field->subtype->str, NULL); - } - /* print all parameters */ - g_hash_table_foreach (content_field->parameters, _print_parameter, stream); - camel_stream_write_string (stream, "\n"); - } -} - -GString * -gmime_content_field_get_mime_type (GMimeContentField *content_field) -{ - GString *mime_type; - - if (!content_field->type) return NULL; - mime_type = g_string_clone (content_field->type); - if (content_field->subtype) { - g_string_append_c (mime_type, '/'); - g_string_append_g_string (mime_type, content_field->subtype); - } - return mime_type; -} - - -void -gmime_content_field_construct_from_string (GMimeContentField *content_field, GString *string) -{ - gint first, len; - gchar *str; - gint i=0; - GString *type, *subtype; - GString *param_name, *param_value; - gboolean param_end; - - CAMEL_LOG (TRACE, "Entering gmime_content_field_construct_from_string\n"); - g_assert (string); - g_assert (string->str); - g_assert (content_field); - - if (content_field->type) { - CAMEL_LOG (FULL_DEBUG, "Freeing old mime type string\n"); - g_string_free (content_field->type, FALSE); - } - if (content_field->subtype) { - CAMEL_LOG (FULL_DEBUG, "Freeing old mime type substring\n"); - g_string_free (content_field->subtype, FALSE); - } - - str = string->str; - first = 0; - len = string->len; - if (!len) return; - CAMEL_LOG (TRACE, "All checks done\n"); - - /* find the type */ - while ( (i<len) && (!strchr ("/;", str[i])) ) i++; - - if (i == 0) return; - - type = g_string_new (g_strndup (str, i)); - content_field->type = type; - CAMEL_LOG (TRACE, "Found mime type : %s\n", type->str); - if (i == len) { - content_field->subtype = NULL; - return; - } - - first = i+1; - /* find the subtype, if any */ - if (str[i++] == '/') { - while ( (i<len) && (str[i] != ';') ) i++; - if (i != first) { - subtype = g_string_new (g_strndup (str+first, i-first)); - content_field->subtype = subtype; - if (i == len) return; - } - } - first = i+1; - - /* parse parameters list */ - param_end = FALSE; - do { - while ( (i<len) && (str[i] != '=') ) i++; - if ((i == len) || (i==first)) param_end = TRUE; - else { - /* we have found parameter name */ - param_name = g_string_new (g_strndup (str+first, i-first)); - i++; - first = i; - /* Let's find parameter value */ - while ( (i<len) && (str[i] != ';') ) i++; - if (i != first) param_value = g_string_new (g_strndup (str+first, i-first)); - else param_value = g_string_new (""); - gmime_content_field_set_parameter (content_field, param_name, param_value); - i++; - first = i; - } - } while ((!param_end) && (first < len)); - - -} - - -static void -_free_parameter (gpointer name, gpointer value, gpointer user_data) -{ - g_string_free (name, FALSE); - g_string_free (value, FALSE); -} - -void -gmime_content_field_free (GMimeContentField *content_field) -{ - g_hash_table_foreach (content_field->parameters, _free_parameter, NULL); - g_string_free (content_field->type, FALSE); - g_string_free (content_field->subtype, FALSE); - 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 7fe66bf7a9..0000000000 --- a/camel/gmime-content-field.h +++ /dev/null @@ -1,58 +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 <Bertrand.Guiheneuf@inria.fr> . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#ifndef GMIME_CONTENT_FIELD_H -#define GMIME_CONTENT_FIELD_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include <glib.h> -#include <stdio.h> -#include "camel-stream.h" - -typedef struct { - - GString *type; - GString *subtype; - GHashTable *parameters; - -} GMimeContentField; - -GMimeContentField *gmime_content_field_new (GString *type, GString *subtype); -void gmime_content_field_set_parameter(GMimeContentField *content_field, GString *attribute, GString *value); -void gmime_content_field_write_to_stream (GMimeContentField *content_field, CamelStream *stream); -void gmime_content_field_construct_from_string (GMimeContentField *content_field, GString *string); -void gmime_content_field_free (GMimeContentField *content_field); -GString * gmime_content_field_get_mime_type (GMimeContentField *content_field); - - -#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 1555d27e7b..0000000000 --- a/camel/gmime-utils.c +++ /dev/null @@ -1,191 +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 <Bertrand.Guiheneuf@inria.fr> . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - - -#include "gmime-utils.h" -#include "gstring-util.h" -#include "camel-log.h" -#include "camel-stream.h" - -void -gmime_write_header_pair_to_stream (CamelStream *stream, gchar* name, GString *value) -{ - - GString *strtmp; - guint len; - - g_assert(name); - - if (!value || !(value->str)) return; - len = strlen (name) + strlen (value->str) +3; - /* 3 is for ": " and "\n" */ - strtmp = g_string_sized_new (len); - - sprintf(strtmp->str, "%s: %s\n", name, value->str); - camel_stream_write (stream, strtmp->str, len); - CAMEL_LOG (FULL_DEBUG, "gmime_write_header_pair_to_stream:\n writing %s\n", strtmp->str); - g_string_free (strtmp, FALSE); -} - - -static void -_write_one_header_to_stream (gpointer key, gpointer value, gpointer user_data) -{ - GString *header_name = (GString *)key; - GString *header_value = (GString *)value; - CamelStream *stream = (CamelStream *)user_data; - - if ( (header_name) && (header_name->str) && - (header_value) && (header_value->str) ) - gmime_write_header_pair_to_stream (stream, header_name->str, header_value); -} - -void -write_header_table_to_stream (CamelStream *stream, GHashTable *header_table) -{ - g_hash_table_foreach (header_table, - _write_one_header_to_stream, - (gpointer)stream); -} - - -void -write_header_with_glist_to_stream (CamelStream *stream, gchar *header_name, GList *header_values, gchar *separator) -{ - - GString *current; - - 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 = (GString *)header_values->data; - if ( (current) && (current->str) ) { - if (!first) camel_stream_write_string (stream, separator); - else first = FALSE; - camel_stream_write (stream, current->str, strlen (current->str)); - } - header_values = g_list_next(header_values); - } - camel_stream_write (stream, "\n", 1); - } - -} - - - - - -/* * * * * * * * * * * */ -/* scanning functions */ - -static void -_store_header_pair_from_gstring (GHashTable *header_table, GString *header_line) -{ - gchar dich_result; - GString *header_name, *header_value; - - g_assert (header_table); - if ( (header_line) && (header_line->str) ) { - dich_result = g_string_dichotomy(header_line, ':', &header_name, &header_value, DICHOTOMY_NONE); - if (dich_result != 'o') - camel_log(WARNING, - "store_header_pair_from_gstring : dichotomy result is %c" - "header line is :\n--\n%s\n--\n"); - - else { - g_string_trim (header_value, " \t", TRIM_STRIP_LEADING | TRIM_STRIP_TRAILING); - g_hash_table_insert (header_table, header_name, header_value); - } - } - -} - - - - -GHashTable * -get_header_table_from_stream (CamelStream *stream) -{ - 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; - GHashTable *header_table; - - header_table = g_hash_table_new (g_string_hash, g_string_equal_for_hash); - 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) ) - _store_header_pair_from_gstring (header_table, header_line); - g_string_free (header_line, FALSE); - - } while ( (!end_of_headers) && (!end_of_file) ); - - return header_table; -} - - diff --git a/camel/gmime-utils.h b/camel/gmime-utils.h deleted file mode 100644 index a8ff6094e9..0000000000 --- a/camel/gmime-utils.h +++ /dev/null @@ -1,50 +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 <Bertrand.Guiheneuf@inria.fr> . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#ifndef GMIME_UTILS_H -#define GMIME_UTILS_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include <glib.h> -#include <stdio.h> -#include <camel-stream.h> - -void gmime_write_header_pair_to_stream (CamelStream *stream, gchar* name, GString *value); -void write_header_table_to_stream (CamelStream *stream, GHashTable *header_table); -void write_header_with_glist_to_stream (CamelStream *stream, gchar *header_name, GList *header_values, gchar *separator); - -GHashTable *get_header_table_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 c48a98d410..0000000000 --- a/camel/gstring-util.c +++ /dev/null @@ -1,331 +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 <Bertrand.Guiheneuf@inria.fr> . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - - - -#include "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 : 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' - * - * @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 Value : result of the operation ('o', 'l' or 'n') - * - **/ -gchar -g_string_dichotomy (GString *string, gchar sep, GString **prefix, GString **suffix, DichotomyOption 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 & DICHOTOMY_STRIP_LEADING ) && (tmp[first] == sep) ) - do {first++;} while ( (first<len) && (tmp[first] == sep) ); - - if (options & DICHOTOMY_STRIP_TRAILING ) - while (tmp[len-1] == sep) - len--; - - if (first==len) { - if (prefix) *prefix=NULL; - if (suffix) *suffix=NULL; - CAMEL_LOG(FULL_DEBUG,"string_dichotomy: after stripping, string is empty\n"); - return 'n'; - } - - if (options & DICHOTOMY_RIGHT_DIR) { - pos = len; - - do { - pos--; - } while ((pos>=first) && (tmp[pos]!=sep)); - } else { - pos = first; - do { - pos++; - } while ((pos<len) && (tmp[pos]!=sep)); - - } - - if ( (pos<first) || (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, TrimOption 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, TrimOption 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 & TRIM_STRIP_LEADING) - while ( (first_ok <= last_ok) && (strchr (chars, str[first_ok])) ) - first_ok++; - - if (options & 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 419895831c..0000000000 --- a/camel/gstring-util.h +++ /dev/null @@ -1,70 +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 <Bertrand.Guiheneuf@inria.fr> . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - - -#ifndef GSTRING_UTIL_H -#define GSTRING_UTIL_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include <glib.h> - -typedef enum { - DICHOTOMY_NONE = 0, - DICHOTOMY_RIGHT_DIR = 1, - DICHOTOMY_STRIP_TRAILING = 2, - DICHOTOMY_STRIP_LEADING = 4, - -} DichotomyOption; - -typedef enum { - TRIM_NONE = 0, - TRIM_STRIP_TRAILING = 1, - TRIM_STRIP_LEADING = 2, - -} TrimOption; - - -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, DichotomyOption 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, TrimOption trim_options); -void g_string_trim (GString *string, gchar *chars, TrimOption 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 <Bertrand.Guiheneuf@inria.fr> . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#include "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 <Bertrand.Guiheneuf@inria.fr> . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#ifndef CAMEL_MH_FOLDER_H -#define CAMEL_MH_FOLDER_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include <gtk/gtk.h> -#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 <Bertrand.Guiheneuf@inria.fr> . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#include "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 <Bertrand.Guiheneuf@inria.fr> . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#ifndef CAMEL_MH_STORE_H -#define CAMEL_MH_STORE_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include <gtk/gtk.h> -#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/url-util.c b/camel/url-util.c deleted file mode 100644 index 1b784385f5..0000000000 --- a/camel/url-util.c +++ /dev/null @@ -1,405 +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 <Bertrand.Guiheneuf@inria.fr> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - - -/* - 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 "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(GString *url, GString **item, guint *position, gboolean *error); - -/* used to find one item (protocol, then user .... */ -typedef struct { - char *item_name; /* item name : for debug only */ - GString **item_value; /* where the item value will go */ - find_item_func *find_func; /* item finder */ -} FindStepStruct; - -static gboolean find_protocol(GString *url, GString **item, guint *position, gboolean *error); -static gboolean find_user(GString *url, GString **item, guint *position, gboolean *error); -static gboolean find_passwd(GString *url, GString **item, guint *position, gboolean *error); -static gboolean find_host(GString *url, GString **item, guint *position, gboolean *error); -static gboolean find_port(GString *url, GString **item, guint *position, gboolean *error); -static gboolean find_path(GString *url, GString **item, guint *position, gboolean *error); - - - -/** - * new_g_url: create an Gurl object from a string - * @url_string: The string containing the URL to scan - * - * This routine takes a GString 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 - * - * Return value: a Gurl structure containng the URL items. - **/ -Gurl *g_url_new(GString* url_string) -{ - Gurl *g_url; - - GString *protocol; - GString *user; - GString *passwd; - GString *host; - GString *port; - GString *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<NB_STEP_URL; i++) { - found = step[i].find_func(url_string, - step[i].item_value, - &position, - &error); - } - } - - return g_url; -} - - - - - -/** So, yes, I must admit there would have been more elegant - ways to do this, but it works, and quite well :) */ - - -static gboolean -find_protocol(GString *url, GString **item, guint *position, gboolean *error) -{ - - guint i; - gchar *str_url; - gint len_url; - gchar *str_protocol; - - str_url = url->str; - len_url = url->len; - - *item = NULL; - *error = FALSE; - i=*position; - - /* find a ':' */ - while ( (i<len_url) && (str_url[i] != ':') ) i++; - - if (i==len_url) return FALSE; - i++; - - /* check if it is followed by a "//" */ - if ((i<len_url) && (str_url[i++] == '/')) - if ((i<len_url) && (str_url[i++] == '/')) - { - - str_protocol = g_strndup(str_url, i-3); - *item = g_string_new(str_protocol); - *position=i; - return TRUE; - } - - return FALSE; -} - - - - -static gboolean -find_user(GString *url, GString **item, guint *position, gboolean *error) -{ - guint i; - guint at_pos; - - gchar *str_url; - gint len_url; - gchar *str_user; - - str_url = url->str; - len_url = url->len; - - *item = NULL; - i=*position; - - - /* find a '@' */ - while ((i<len_url) && (str_url[i] != '@')) i++; - - if (i==len_url) return FALSE; - at_pos = i; - i = *position; - - /* find a ':' */ - while ( (i<at_pos) && (str_url[i] != ':') ) i++; - - /* now if i has not been incremented at all, there is no user */ - if (i == *position) { - (*position)++; - return FALSE; - } - - str_user = g_strndup(str_url+ *position, i - *position); - *item = g_string_new(str_user); - if (i<at_pos) *position=i+1; /* there was a ':', skip it */ - else *position=i; - - return TRUE; -} - -static gboolean -find_passwd(GString *url, GString **item, guint *position, gboolean *error) -{ - guint i; - - gchar *str_url; - gint len_url; - gchar *str_passwd; - - str_url = url->str; - len_url = url->len; - - *item = NULL; - i=*position; - - - /* find a '@' */ - while ((i<len_url) && (str_url[i] != '@')) i++; - - if (i==len_url) return FALSE; - /*i has not been incremented at all, there is no passwd */ - if (i == *position) { - *position = i+1; - return FALSE; - } - - str_passwd = g_strndup(str_url+ *position, i - *position); - *item = g_string_new(str_passwd); - *position=i+1; /* skip it the '@' */ - - return TRUE; -} - - - -static gboolean -find_host(GString *url, GString **item, guint *position, gboolean *error) -{ - guint i; - guint slash_pos; - - gchar *str_url; - gint len_url; - gchar *str_host; - - str_url = url->str; - len_url = url->len; - - *item = NULL; - i=*position; - - - /* find a '/' */ - while ((i<len_url) && (str_url[i] != '/')) i++; - - slash_pos = i; - i = *position; - - /* find a ':' */ - while ( (i<slash_pos) && (str_url[i] != ':') ) i++; - - /* at this point if i has not been incremented at all, - there is no host */ - if (i == *position) { - (*position)++; - return FALSE; - } - - str_host = g_strndup(str_url+ *position, i - *position); - *item = g_string_new(str_host); - if (i<slash_pos) *position=i+1; /* there was a ':', skip it */ - else *position=i; - - return TRUE; -} - - -static gboolean -find_port(GString *url, GString **item, guint *position, gboolean *error) -{ - guint i; - guint slash_pos; - - gchar *str_url; - gint len_url; - gchar *str_port; - - str_url = url->str; - len_url = url->len; - - *item = NULL; - i=*position; - - - /* find a '/' */ - while ((i<len_url) && (str_url[i] != '/')) i++; - - slash_pos = i; - i = *position; - - /* find a ':' */ - while ( (i<slash_pos) && (str_url[i] != ':') ) i++; - - /* at this point if i has not been incremented at all, - there is no port */ - if (i == *position) return FALSE; - - str_port = g_strndup(str_url+ *position, i - *position); - *item = g_string_new(str_port); - *position = i; - return TRUE; -} - - -static gboolean -find_path(GString *url, GString **item, guint *position, gboolean *error) -{ - guint i; - - gchar *str_url; - gint len_url; - gchar *str_path; - - str_url = url->str; - len_url = url->len; - - *item = NULL; - i=*position; - - - /* find a '#' */ - while ((i<len_url) && (str_url[i] != '#') && (str_url[i] != '?')) i++; - - /*i has not been incremented at all, there is no path */ - if (i == *position) return FALSE; - - str_path = g_strndup(str_url+ *position, i - *position); - *item = g_string_new(str_path); - *position=i; - - - return TRUE; -} - - -/* to tests this file : - gcc -o test_url_util `glib-config --cflags` -DTEST_URL_UTIL url-util.c `glib-config --libs` - ./test_url_util URL -*/ -#ifdef TEST_URL_UTIL - - - -int -main (int argc, char **argv) -{ - - GString *url; - GString *protocol; - GString *user; - GString *passwd; - GString *host; - GString *port; - GString *path; - guint position=0; - gboolean error; - gboolean found; - guint i; - guint i_pos; - -#define NB_STEP_TEST 6 - FindStepStruct test_step[NB_STEP_TEST] = { - { "protocol", &protocol, find_protocol}, - { "user", &user, find_user}, - { "password", &passwd, find_passwd}, - { "host", &host, find_host}, - { "port", &port, find_port}, - { "path", &path, find_path} - }; - url = g_string_new(argv[1]); - printf("URL to test : %s\n\n", url->str); - for (i=0; i<NB_STEP_TEST; i++) { - found = test_step[i].find_func(url, - test_step[i].item_value, - &position, - &error); - if (found) { - printf("\t\t\t\t** %s found : %s\n", - test_step[i].item_name, - (*test_step[i].item_value)->str); - } else printf("** %s not found in URL\n", test_step[i].item_name); - printf("next item position:\n"); - printf("%s\n", url->str); - for(i_pos=0; i_pos<position; i_pos++) printf(" "); - printf("^\n"); - - } - -} - -#endif /* TEST_URL_UTIL */ diff --git a/camel/url-util.h b/camel/url-util.h deleted file mode 100644 index 74dab30b14..0000000000 --- a/camel/url-util.h +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* url-util.h : utility functions to parse URLs */ - -/* - * Copyright (C) Bertrand Guiheneuf <Bertrand.Guiheneuf@inria.fr> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#ifndef URL_UTIL_H -#define URL_UTIL_H 1 - -#include <glib.h> - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -typedef struct { - GString *protocol; - GString *user; - GString *passwd; - GString *host; - GString *port; - GString *path; -} Gurl; - -Gurl *g_url_new(GString* url_string); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* URL_UTIL_H */ |