aboutsummaryrefslogtreecommitdiffstats
path: root/camel/providers
diff options
context:
space:
mode:
authornobody <nobody@localhost>2000-02-17 07:51:01 +0800
committernobody <nobody@localhost>2000-02-17 07:51:01 +0800
commit2b80feefead30f2b24a3c51c4b52373c5faacbac (patch)
tree646d019769a1d66081bd13dc9cab96c4417d8843 /camel/providers
parent5a80143a526ddc84b31e8458c525d40580c06810 (diff)
downloadgsoc2013-evolution-GNOME_CORE_1_1_4.tar
gsoc2013-evolution-GNOME_CORE_1_1_4.tar.gz
gsoc2013-evolution-GNOME_CORE_1_1_4.tar.bz2
gsoc2013-evolution-GNOME_CORE_1_1_4.tar.lz
gsoc2013-evolution-GNOME_CORE_1_1_4.tar.xz
gsoc2013-evolution-GNOME_CORE_1_1_4.tar.zst
gsoc2013-evolution-GNOME_CORE_1_1_4.zip
This commit was manufactured by cvs2svn to create tagGNOME_CORE_1_1_4
'GNOME_CORE_1_1_4'. svn path=/tags/GNOME_CORE_1_1_4/; revision=1807
Diffstat (limited to 'camel/providers')
-rw-r--r--camel/providers/.cvsignore2
-rw-r--r--camel/providers/MH/.cvsignore6
-rw-r--r--camel/providers/MH/Makefile.am33
-rw-r--r--camel/providers/MH/camel-mh-folder.c1022
-rw-r--r--camel/providers/MH/camel-mh-folder.h72
-rw-r--r--camel/providers/MH/camel-mh-provider.c46
-rw-r--r--camel/providers/MH/camel-mh-store.c153
-rw-r--r--camel/providers/MH/camel-mh-store.h72
-rw-r--r--camel/providers/MH/mh-summary.c290
-rw-r--r--camel/providers/MH/mh-summary.h33
-rw-r--r--camel/providers/MH/mh-uid.c220
-rw-r--r--camel/providers/MH/mh-uid.h40
-rw-r--r--camel/providers/MH/mh-utils.c50
-rw-r--r--camel/providers/MH/mh-utils.h30
-rw-r--r--camel/providers/Makefile.am5
-rw-r--r--camel/providers/maildir/.cvsignore6
-rw-r--r--camel/providers/maildir/Makefile.am23
-rw-r--r--camel/providers/maildir/camel-maildir-folder.c803
-rw-r--r--camel/providers/maildir/camel-maildir-folder.h66
-rw-r--r--camel/providers/maildir/camel-maildir-provider.c46
-rw-r--r--camel/providers/maildir/camel-maildir-store.c124
-rw-r--r--camel/providers/maildir/camel-maildir-store.h69
-rw-r--r--camel/providers/mbox/.cvsignore7
-rw-r--r--camel/providers/mbox/Makefile.am38
-rw-r--r--camel/providers/mbox/camel-mbox-folder.c1131
-rw-r--r--camel/providers/mbox/camel-mbox-folder.h83
-rw-r--r--camel/providers/mbox/camel-mbox-parser.c901
-rw-r--r--camel/providers/mbox/camel-mbox-parser.h66
-rw-r--r--camel/providers/mbox/camel-mbox-provider.c49
-rw-r--r--camel/providers/mbox/camel-mbox-search.c857
-rw-r--r--camel/providers/mbox/camel-mbox-search.h10
-rw-r--r--camel/providers/mbox/camel-mbox-store.c153
-rw-r--r--camel/providers/mbox/camel-mbox-store.h72
-rw-r--r--camel/providers/mbox/camel-mbox-summary.c305
-rw-r--r--camel/providers/mbox/camel-mbox-summary.h81
-rw-r--r--camel/providers/mbox/camel-mbox-utils.c385
-rw-r--r--camel/providers/mbox/camel-mbox-utils.h69
37 files changed, 0 insertions, 7418 deletions
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 dab6bec199..0000000000
--- a/camel/providers/MH/Makefile.am
+++ /dev/null
@@ -1,33 +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-provider.c \
- camel-mh-store.c \
- mh-summary.c \
- mh-uid.c \
- mh-utils.c
-
-libcamelmhinclude_HEADERS = \
- camel-mh-folder.h \
- camel-mh-store.h \
- mh-summary.c \
- mh-uid.h \
- mh-utils.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 86bbab46ba..0000000000
--- a/camel/providers/MH/camel-mh-folder.c
+++ /dev/null
@@ -1,1022 +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@aful.org> .
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-#include <config.h>
-#include <sys/stat.h>
-#include <sys/param.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <fcntl.h>
-#include <dirent.h>
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include "camel-mh-folder.h"
-#include "camel-mh-store.h"
-#include "gstring-util.h"
-#include "camel-log.h"
-#include "camel-stream-fs.h"
-#include "camel-stream-buffered-fs.h"
-#include "camel-folder-summary.h"
-#include "gmime-utils.h"
-#include "mh-utils.h"
-#include "mh-uid.h"
-#include "mh-summary.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 _set_name(CamelFolder *folder, const gchar *name, CamelException *ex);
-static void _init_with_store (CamelFolder *folder, CamelStore *parent_store, CamelException *ex);
-static gboolean _exists (CamelFolder *folder, CamelException *ex);
-static gboolean _create(CamelFolder *folder, CamelException *ex);
-static gboolean _delete (CamelFolder *folder, gboolean recurse, CamelException *ex);
-static gboolean _delete_messages (CamelFolder *folder, CamelException *ex);
-static GList *_list_subfolders (CamelFolder *folder, CamelException *ex);
-static CamelMimeMessage *_get_message (CamelFolder *folder, gint number, CamelException *ex);
-static gint _get_message_count (CamelFolder *folder, CamelException *ex);
-static gint _append_message (CamelFolder *folder, CamelMimeMessage *message, CamelException *ex);
-static void _expunge (CamelFolder *folder, CamelException *ex);
-static void _copy_message_to (CamelFolder *folder, CamelMimeMessage *message, CamelFolder *dest_folder, CamelException *ex);
-static void _open (CamelFolder *folder, CamelFolderOpenMode mode, CamelException *ex);
-static void _close (CamelFolder *folder, gboolean expunge, CamelException *ex);
-
-static const gchar *_get_message_uid (CamelFolder *folder, CamelMimeMessage *message, CamelException *ex);
-static CamelMimeMessage *_get_message_by_uid (CamelFolder *folder, const gchar *uid, CamelException *ex);
-static GList *_get_uid_list (CamelFolder *folder, CamelException *ex);
-
-/* some utility functions */
-static int copy_reg (const char *src_path, const char *dst_path, CamelException *ex);
-
-static void
-camel_mh_folder_class_init (CamelMhFolderClass *camel_mh_folder_class)
-{
- CamelFolderClass *camel_folder_class = CAMEL_FOLDER_CLASS (camel_mh_folder_class);
-
- parent_class = gtk_type_class (camel_folder_get_type ());
-
- /* virtual method definition */
- /* virtual method overload */
- camel_folder_class->init_with_store = _init_with_store;
- camel_folder_class->set_name = _set_name;
- camel_folder_class->exists = _exists;
- camel_folder_class->delete = _delete;
- camel_folder_class->delete_messages = _delete_messages;
- camel_folder_class->list_subfolders = _list_subfolders;
- camel_folder_class->get_message = _get_message;
- camel_folder_class->get_message_count = _get_message_count;
- camel_folder_class->append_message = _append_message;
- camel_folder_class->expunge = _expunge;
- camel_folder_class->copy_message_to = _copy_message_to;
- camel_folder_class->open = _open;
- camel_folder_class->close = _close;
- camel_folder_class->get_message_uid = _get_message_uid;
- camel_folder_class->get_message_by_uid = _get_message_by_uid;
- camel_folder_class->get_uid_list = _get_uid_list;
-
-}
-
-
-
-
-
-
-
-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;
-}
-
-
-
-static gint
-_message_name_compare (gconstpointer a, gconstpointer b)
-{
- gchar *m1 = (gchar *)a;
- gchar *m2 = (gchar *)b;
- gint len_diff;
-
- return (atoi (m1) - atoi (m2));
-}
-
-
-static void
-_init_with_store (CamelFolder *folder, CamelStore *parent_store, CamelException *ex)
-{
- /* call parent method */
- parent_class->init_with_store (folder, parent_store, ex);
-
- folder->can_hold_messages = TRUE;
- folder->can_hold_folders = TRUE;
- folder->has_summary_capability = TRUE;
- folder->has_uid_capability = TRUE;
-
- folder->summary = NULL;
-
-}
-
-
-
-static void
-_open (CamelFolder *folder, CamelFolderOpenMode mode, CamelException *ex)
-{
- CamelMhFolder *mh_folder = CAMEL_MH_FOLDER (folder);
- struct dirent *dir_entry;
- DIR *dir_handle;
-
-
- if (folder->open_state == FOLDER_OPEN) return;
-
-
- /* create message list */
- /* read the whole folder and sort message names */
- dir_handle = opendir (mh_folder->directory_path);
- /* read first entry in the directory */
- dir_entry = readdir (dir_handle);
- while (dir_entry != NULL) {
- /* tests if the entry correspond to a message file */
- if (mh_is_a_message_file (dir_entry->d_name, mh_folder->directory_path))
- /* add the file name to the list */
- mh_folder->file_name_list = g_list_insert_sorted (mh_folder->file_name_list,
- g_strdup (dir_entry->d_name),
- _message_name_compare);
- /* read next entry */
- dir_entry = readdir (dir_handle);
- }
-
- closedir (dir_handle);
-
- /* get (or create) uid list */
- if (!(mh_load_uid_list (mh_folder) > 0))
- mh_generate_uid_list (mh_folder);
-
- /* get or create summary */
- /* it is important that it comes after uid list reading/generation */
- if (!(mh_load_summary (mh_folder) > 0))
- mh_generate_summary (folder);
- printf ("**** summary = %p\n", folder->summary);
-
-}
-
-
-
-static void
-_close (CamelFolder *folder, gboolean expunge, CamelException *ex)
-{
- CamelMhFolder *mh_folder = CAMEL_MH_FOLDER (folder);
-
- /* save uid list, if any */
- if (mh_folder->uid_array)
- mh_save_uid_list (mh_folder);
-
- /* save summary, if any */
- if (folder->summary)
- mh_save_summary (mh_folder);
-
- /* call parent implementation */
- parent_class->close (folder, expunge, ex);
-}
-
-
-
-
-
-/**
- * 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
-_set_name (CamelFolder *folder, const gchar *name, CamelException *ex)
-{
- CamelMhFolder *mh_folder = CAMEL_MH_FOLDER (folder);
- const gchar *root_dir_path;
- gchar *full_name;
- const gchar *parent_full_name;
- gchar separator;
-
- CAMEL_LOG_FULL_DEBUG ("Entering CamelMhFolder::set_name\n");
- g_assert (folder);
- g_assert (name);
- g_assert (folder->parent_store);
-
- /* call default implementation */
- parent_class->set_name (folder, name, ex);
-
- if (mh_folder->directory_path) g_free (mh_folder->directory_path);
-
- separator = camel_store_get_separator (folder->parent_store);
- root_dir_path = camel_mh_store_get_toplevel_dir (CAMEL_MH_STORE(folder->parent_store));
-
- CAMEL_LOG_FULL_DEBUG ("CamelMhFolder::set_name full_name is %s\n", folder->full_name);
- CAMEL_LOG_FULL_DEBUG ("CamelMhFolder::set_name root_dir_path is %s\n", root_dir_path);
- CAMEL_LOG_FULL_DEBUG ("CamelMhFolder::separator is %c\n", separator);
-
- mh_folder->directory_path = g_strdup_printf ("%s%c%s", root_dir_path, separator, folder->full_name);
-
- if (!camel_folder_exists (folder, ex)) return;
-
-
- CAMEL_LOG_FULL_DEBUG ("CamelMhFolder::set_name mh_folder->directory_path is %s\n",
- mh_folder->directory_path);
- CAMEL_LOG_FULL_DEBUG ("Leaving CamelMhFolder::set_name\n");
-}
-
-
-
-static gboolean
-_exists (CamelFolder *folder, CamelException *ex)
-{
- CamelMhFolder *mh_folder = CAMEL_MH_FOLDER(folder);
- struct stat stat_buf;
- gint stat_error;
- gboolean exists;
-
- CAMEL_LOG_FULL_DEBUG ("Entering CamelMhFolder::exists\n");
- g_assert (folder);
-
- if (!mh_folder->directory_path) return FALSE;
-
- stat_error = stat (mh_folder->directory_path, &stat_buf);
- if (stat_error == -1) {
- CAMEL_LOG_FULL_DEBUG ("CamelMhFolder::exists when executing stat on %s, stat_error = %d\n",
- mh_folder->directory_path, stat_error);
- CAMEL_LOG_FULL_DEBUG (" Full error text is : %s\n", strerror(errno));
- return FALSE;
- }
- exists = S_ISDIR (stat_buf.st_mode);
-
- CAMEL_LOG_FULL_DEBUG ("Leaving CamelMhFolder::exists\n");
- return exists;
-}
-
-
-static gboolean
-_create (CamelFolder *folder, CamelException *ex)
-{
- CamelMhFolder *mh_folder = CAMEL_MH_FOLDER(folder);
- const gchar *directory_path;
- mode_t dir_mode = S_IRWXU;
- gint mkdir_error;
-
- g_assert(folder);
-
- /* call default implementation */
- parent_class->create (folder, ex);
-
- directory_path = mh_folder->directory_path;
- if (!directory_path) return FALSE;
-
- if (camel_folder_exists (folder, ex)) return TRUE;
-
- mkdir_error = mkdir (directory_path, dir_mode);
- return (mkdir_error == -1);
-}
-
-
-
-static gboolean
-_delete (CamelFolder *folder, gboolean recurse, CamelException *ex)
-{
-
- CamelMhFolder *mh_folder = CAMEL_MH_FOLDER(folder);
- const gchar *directory_path;
- gint rmdir_error = 0;
-
- g_assert(folder);
-
- /* call default implementation */
- parent_class->delete (folder, recurse, ex);
- /* the default implementation will care about deleting
- messages first and recursing the operation if
- necessary */
-
- directory_path = mh_folder->directory_path;
- if (!directory_path) return FALSE;
-
- if (!camel_folder_exists (folder, ex)) return TRUE;
-
- /* physically delete the directory */
- CAMEL_LOG_FULL_DEBUG ("CamelMhFolder::delete removing directory %s\n", directory_path);
- rmdir_error = rmdir (directory_path);
- if (rmdir_error == -1) {
- CAMEL_LOG_WARNING ("CamelMhFolder::delete Error when removing directory %s\n", directory_path);
- CAMEL_LOG_FULL_DEBUG ( " Full error text is : %s\n", strerror(errno));
- }
-
- return (rmdir_error != -1);
-}
-
-
-static gboolean
-_delete_messages (CamelFolder *folder, CamelException *ex)
-{
-
- CamelMhFolder *mh_folder = CAMEL_MH_FOLDER(folder);
- const gchar *directory_path;
- struct stat stat_buf;
- gint stat_error = 0;
- gchar *entry_name;
- struct dirent *dir_entry;
- gint unlink_error = 0;
- DIR *dir_handle;
-
- g_assert(folder);
-
- /* call default implementation */
- parent_class->delete_messages (folder, ex);
-
- directory_path = mh_folder->directory_path;
- if (!directory_path) return FALSE;
-
- if (!camel_folder_exists (folder, ex)) return TRUE;
-
- dir_handle = opendir (directory_path);
-
- /* read first entry in the directory */
- dir_entry = readdir (dir_handle);
- while ((stat_error != -1) && (unlink_error != -1) && (dir_entry != NULL)) {
-
- /* get the name of the next entry in the dir */
- entry_name = dir_entry->d_name;
- stat_error = stat (mh_folder->directory_path, &stat_buf);
-
- /* is it a regular file ? */
- if ((stat_error != -1) && S_ISREG(stat_buf.st_mode)) {
- /* yes, delete it */
- CAMEL_LOG_FULL_DEBUG ("CamelMhFolder::delete_messages removing file %s\n", entry_name);
- unlink_error = unlink(entry_name);
-
- if (unlink_error == -1) {
- CAMEL_LOG_WARNING ("CamelMhFolder::delete_messages Error when deleting file %s\n",
- entry_name);
- CAMEL_LOG_FULL_DEBUG ( " Full error text is : %s\n", strerror(errno));
- }
- }
- /* read next entry */
- dir_entry = readdir (dir_handle);
- }
-
- closedir (dir_handle);
-
- return ((stat_error != -1) && (unlink_error != -1));
-
-}
-
-
-
-static GList *
-_list_subfolders (CamelFolder *folder, CamelException *ex)
-{
- GList *subfolder_name_list = NULL;
-
- CamelMhFolder *mh_folder = CAMEL_MH_FOLDER(folder);
- const gchar *directory_path;
- struct stat stat_buf;
- gint stat_error = 0;
- GList *file_list;
- gchar *entry_name;
- gchar *full_entry_name;
- struct dirent *dir_entry;
- DIR *dir_handle;
-
- g_assert(folder);
-
- /* call default implementation */
- parent_class->delete_messages (folder, ex);
-
- directory_path = mh_folder->directory_path;
- if (!directory_path) return NULL;
-
- if (!camel_folder_exists (folder, ex)) return NULL;
-
- dir_handle = opendir (directory_path);
-
- /* read first entry in the directory */
- dir_entry = readdir (dir_handle);
- while ((stat_error != -1) && (dir_entry != NULL)) {
-
- /* get the name of the next entry in the dir */
- entry_name = dir_entry->d_name;
- full_entry_name = g_strdup_printf ("%s/%s", mh_folder->directory_path, entry_name);
- stat_error = stat (full_entry_name, &stat_buf);
- g_free (full_entry_name);
-
- /* is it a directory ? */
- if ((stat_error != -1) && S_ISDIR (stat_buf.st_mode)) {
- /* yes, add it to the list */
- if (entry_name[0] != '.') {
- CAMEL_LOG_FULL_DEBUG ("CamelMhFolder::list_subfolders adding %s\n", entry_name);
- subfolder_name_list = g_list_append (subfolder_name_list, g_strdup (entry_name));
- }
- }
- /* read next entry */
- dir_entry = readdir (dir_handle);
- }
-
- closedir (dir_handle);
-
- return subfolder_name_list;
-}
-
-
-
-
-
-static void
-_filename_free (gpointer data)
-{
- g_free ((gchar *)data);
-}
-
-
-/* slow routine, may be optimixed, or we should use
- caches if users complain */
-static CamelMimeMessage *
-_get_message (CamelFolder *folder, gint number, CamelException *ex)
-{
- CamelMhFolder *mh_folder = CAMEL_MH_FOLDER(folder);
- const gchar *directory_path;
- gchar *message_name;
- gchar *message_file_name;
- CamelStream *input_stream = NULL;
- CamelMimeMessage *message = NULL;
- GList *message_list = NULL;
-
- g_assert(folder);
-
-
- directory_path = mh_folder->directory_path;
- if (!directory_path) return NULL;
-
-
-
- message_name = g_list_nth_data (mh_folder->file_name_list, number);
-
- if (message_name != NULL) {
- CAMEL_LOG_FULL_DEBUG ("CanelMhFolder::get_message message number = %d, name = %s\n",
- number, message_name);
- message_file_name = g_strdup_printf ("%s/%s", directory_path, message_name);
- input_stream = camel_stream_buffered_fs_new_with_name (message_file_name, CAMEL_STREAM_BUFFERED_FS_READ);
-
- if (input_stream != NULL) {
-#warning use session field here
- message = camel_mime_message_new_with_session ( (CamelSession *)NULL);
- camel_data_wrapper_construct_from_stream ( CAMEL_DATA_WRAPPER (message), input_stream);
- gtk_object_unref (GTK_OBJECT (input_stream));
- message->message_number = number;
- gtk_object_set_data_full (GTK_OBJECT (message), "filename",
- g_strdup (message_name), _filename_free);
-
-#warning Set flags and all this stuff here
- }
- g_free (message_file_name);
- } else
- CAMEL_LOG_FULL_DEBUG ("CanelMhFolder::get_message message number = %d, not found\n", number);
-
-
- return message;
-}
-
-
-
-static gint
-_get_message_count (CamelFolder *folder, CamelException *ex)
-{
-
- CamelMhFolder *mh_folder = CAMEL_MH_FOLDER(folder);
- const gchar *directory_path;
- struct dirent *dir_entry;
- DIR *dir_handle;
- guint message_count = 0;
-
- g_assert(folder);
-
- directory_path = mh_folder->directory_path;
- if (!directory_path) return -1;
-
- if (!camel_folder_exists (folder, ex)) return 0;
-
- dir_handle = opendir (directory_path);
-
- /* read first entry in the directory */
- dir_entry = readdir (dir_handle);
- while (dir_entry != NULL) {
- /* tests if the entry correspond to a message file */
- if (mh_is_a_message_file (dir_entry->d_name, directory_path))
- message_count++;
- /* read next entry */
- dir_entry = readdir (dir_handle);
- }
-
- closedir (dir_handle);
- CAMEL_LOG_FULL_DEBUG ("CamelMhFolder::get_message_count found %d messages\n", message_count);
- return message_count;
-}
-
-
-
-static gboolean
-_find_next_free_message_file (CamelFolder *folder, gint *new_msg_number, gchar **new_msg_filename, CamelException *ex)
-{
- CamelMhFolder *mh_folder = CAMEL_MH_FOLDER(folder);
- const gchar *directory_path;
- struct dirent *dir_entry;
- DIR *dir_handle;
- gint last_max_message_number = 0;
- gint current_message_number;
-
- g_assert(folder);
-
- directory_path = mh_folder->directory_path;
- if (!directory_path) return FALSE;
-
- if (!camel_folder_exists (folder, ex)) return FALSE;
-
- dir_handle = opendir (directory_path);
-
- /* read first entry in the directory */
- dir_entry = readdir (dir_handle);
- while (dir_entry != NULL) {
- /* tests if the entry correspond to a message file */
- if (mh_is_a_message_file (dir_entry->d_name, directory_path)) {
- /* see if the message number is the biggest found */
- current_message_number = atoi (dir_entry->d_name);
- if (current_message_number > last_max_message_number)
- last_max_message_number = current_message_number;
- }
- /* read next entry */
- dir_entry = readdir (dir_handle);
- }
- closedir (dir_handle);
-
- *new_msg_number = last_max_message_number + 1;
- *new_msg_filename = g_strdup_printf ("%s/%d", directory_path, *new_msg_number);
- CAMEL_LOG_FULL_DEBUG ("CamelMhFolder::find_next_free_message_file new message path is %s\n",
- *new_msg_filename);
- return TRUE;
-
-
-}
-static gint
-_append_message (CamelFolder *folder, CamelMimeMessage *message, CamelException *ex)
-{
- guint new_msg_number;
- gchar *new_msg_filename;
- CamelStream *output_stream;
- gboolean error;
-
- CAMEL_LOG_FULL_DEBUG ("Entering CamelMhFolder::append_message\n");
- if (!_find_next_free_message_file (folder, &new_msg_number, &new_msg_filename, ex))
- return -1;
-
- output_stream = camel_stream_fs_new_with_name (new_msg_filename, CAMEL_STREAM_FS_WRITE);
- if (output_stream != NULL) {
- camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (message), output_stream);
- camel_stream_close (output_stream);
- } else {
- CAMEL_LOG_WARNING ("CamelMhFolder::append_message could not open %s for writing\n",
- new_msg_filename);
- CAMEL_LOG_FULL_DEBUG (" Full error text is : %s\n", strerror(errno));
- error = TRUE;
- }
-
- g_free (new_msg_filename);
- CAMEL_LOG_FULL_DEBUG ("Leaving CamelMhFolder::append_message\n");
- if (error) return -1;
- else return new_msg_number;
-}
-
-
-
-
-
-static void
-_expunge (CamelFolder *folder, CamelException *ex)
-{
- /* For the moment, we look in the folder active message
- * list. I did not make my mind for the moment, should
- * the gtk_object->destroy signal be used to expunge
- * freed messages objects marked DELETED ?
- */
- CamelMhFolder *mh_folder = CAMEL_MH_FOLDER(folder);
- CamelMimeMessage *message;
- GList *message_node;
- gchar *fullpath;
- gchar *filename;
- gint unlink_error;
- const gchar *directory_path;
-
- CAMEL_LOG_FULL_DEBUG ("Entering CamelFolder::expunge\n");
-
- message_node = folder->message_list;
-
- directory_path = mh_folder->directory_path;
- if (!directory_path) return;
-
- /* look in folder message list which messages
- * need to be expunged */
- while ( message_node) {
- message = CAMEL_MIME_MESSAGE (message_node->data);
-
- if (message && camel_mime_message_get_flag (message, "DELETED")) {
- CAMEL_LOG_FULL_DEBUG ("CamelMhFolder::expunge, expunging message %d\n", message->message_number);
- /* expunge the message */
- filename = gtk_object_get_data (GTK_OBJECT (message), "filename");
- fullpath = g_strdup_printf ("%s/%s", directory_path, filename);
- CAMEL_LOG_FULL_DEBUG ("CamelMhFolder::expunge, message fullpath is %s\n",
- fullpath);
- unlink_error = unlink(fullpath);
- if (unlink_error != -1) {
- message->expunged = TRUE;
- } else {
- CAMEL_LOG_WARNING ("CamelMhFolder:: could not unlink %s (message %d)\n",
- fullpath, message->message_number);
- CAMEL_LOG_FULL_DEBUG (" Full error text is : %s\n", strerror(errno));
- }
- }
- message_node = message_node->next;
- CAMEL_LOG_FULL_DEBUG ("CamelFolder::expunge, examined message node %p\n", message_node);
- }
-
- CAMEL_LOG_FULL_DEBUG ("Leaving CamelFolder::expunge\n");
-}
-
-
-static void
-_copy_message_to (CamelFolder *folder, CamelMimeMessage *message, CamelFolder *dest_folder, CamelException *ex)
-{
- gchar *src_msg_filename;
- guint dest_msg_number;
- gchar *dest_msg_filename;
-
- if (IS_CAMEL_MH_FOLDER (dest_folder)) {
- /*g_return_if_fail (message->parent_folder == folder);*/
-
- if (!_find_next_free_message_file (dest_folder, &dest_msg_number, &dest_msg_filename, ex))
- return;
- src_msg_filename = gtk_object_get_data (GTK_OBJECT (message), "fullpath");
- CAMEL_LOG_FULL_DEBUG ("CamelMhFolder::copy_to copy file %s to %s\n", src_msg_filename, dest_msg_filename);
- copy_reg (src_msg_filename, dest_msg_filename, ex);
-
- } else
- parent_class->copy_message_to (folder, message, dest_folder, ex);
-}
-
-
-
-/** UID **/
-
-static const gchar *
-_get_message_uid (CamelFolder *folder, CamelMimeMessage *message, CamelException *ex)
-{
- CamelMhFolder *mh_folder = CAMEL_MH_FOLDER (folder);
- GArray *uid_array;
- gboolean found = FALSE;
- MhUidCouple *uid_couple;
- gchar *filename;
- guint file_number;
- gint i;
-
- /* if the message already has its uid stored,
- return it */
- if (message->message_uid)
- return (message->message_uid);
-
- /* else, it has a filename associated to it */
- filename = gtk_object_get_data (GTK_OBJECT (message), "filename");
- file_number = atoi (file_number);
-
- uid_array = mh_folder->uid_array;
- uid_couple = (MhUidCouple *)uid_array->data;
-
- /* look in the uid array for the file number */
- found = (uid_couple->file_number == file_number);
- for (i=0; (i<uid_array->len) && (!found); i++) {
- uid_couple++;
- found = (uid_couple->file_number == file_number);
- }
-
- if (found) return uid_couple->uid;
- else return NULL;
-
-}
-
-
-static CamelMimeMessage *
-_get_message_by_uid (CamelFolder *folder, const gchar *uid, CamelException *ex)
-{
- CamelMhFolder *mh_folder = CAMEL_MH_FOLDER (folder);
- GArray *uid_array;
- gboolean found = FALSE;
- MhUidCouple *uid_couple;
- gint file_number;
- gchar *filename;
- CamelMimeMessage *message = NULL;
- CamelStream *input_stream;
- int i;
-
- /*
- * because they are constructed with md5
- * signatures, all MH uids are 16 bytes long
- */
- if (strlen (uid) != 16) return NULL;
-
- uid_array = mh_folder->uid_array;
- uid_couple = (MhUidCouple *)uid_array->data;
-
- found = !strncmp (uid, uid_couple->uid, 16 * sizeof (guchar));
- for (i=0; (i<uid_array->len) && (!found); i++) {
- uid_couple++;
- found = !strncmp (uid, uid_couple->uid, 16 * sizeof (guchar));
- }
- if (found) {
- /* physically retrieve the message */
- file_number = uid_couple->file_number;
- filename = g_strdup_printf ("%d", file_number);
- input_stream = camel_stream_buffered_fs_new_with_name (filename, CAMEL_STREAM_BUFFERED_FS_READ);
-
- if (input_stream != NULL) {
-#warning use session field here
- message = camel_mime_message_new_with_session ( (CamelSession *)NULL);
- camel_data_wrapper_construct_from_stream ( CAMEL_DATA_WRAPPER (message), input_stream);
- gtk_object_unref (GTK_OBJECT (input_stream));
-
- /* set message UID in CamelMimeMessage */
- message->message_uid = g_strdup (uid);
-
- }
- g_free (filename);
- }
-
- return message;
-
-}
-
-static GList *
-_get_uid_list (CamelFolder *folder, CamelException *ex)
-{
- CamelMhFolder *mh_folder = CAMEL_MH_FOLDER (folder);
- GList *uid_list;
- GArray *uid_array;
- MhUidCouple *uid_couple;
- int i;
-
- uid_array = mh_folder->uid_array;
- uid_couple = (MhUidCouple *)uid_array->data;
-
- for (i=0; i<uid_array->len; i++) {
- uid_list = g_list_prepend (uid_list, uid_couple->uid);
- uid_couple++;
- }
-
- return uid_list;
-}
-
-
-
-
-
-
-
-
-/************************************************************************/
-
-/*** Took directly from GNU fileutils-4.0 ***/
-/* Copyright (C) 89, 90, 91, 95, 96, 97, 1998 Free Software Foundation. */
-/* This may be rwritten soon. -Bertrand */
-
-
-/* Write LEN bytes at PTR to descriptor DESC, retrying if interrupted.
- Return LEN upon success, write's (negative) error code otherwise. */
-int
-full_write (int desc, const char *ptr, size_t len)
-{
- int total_written;
-
- total_written = 0;
- while (len > 0)
- {
- int written = write (desc, ptr, len);
- if (written < 0)
- {
- if (errno == EINTR)
- continue;
- return written;
- }
- total_written += written;
- ptr += written;
- len -= written;
- }
- return total_written;
-}
-
-
-
-
-static int
-copy_reg (const char *src_path, const char *dst_path, CamelException *ex)
-{
- char *buf;
- int buf_size;
- int dest_desc;
- int source_desc;
- int n_read;
- struct stat sb;
- char *cp;
- int *ip;
- int return_val = 0;
- off_t n_read_total = 0;
- int last_write_made_hole = 0;
- int make_holes = TRUE;
-
- source_desc = open (src_path, O_RDONLY);
- if (source_desc < 0)
- {
- /* If SRC_PATH doesn't exist, then chances are good that the
- user did something like this `cp --backup foo foo': and foo
- existed to start with, but copy_internal renamed DST_PATH
- with the backup suffix, thus also renaming SRC_PATH. */
- if (errno == ENOENT)
- error (0, 0, "`%s' and `%s' are the same file",
- src_path, dst_path);
- else
- error (0, errno, "%s", src_path);
-
- return -1;
- }
-
- /* Create the new regular file with small permissions initially,
- to not create a security hole. */
-
- dest_desc = open (dst_path, O_WRONLY | O_CREAT | O_TRUNC, 0600);
- if (dest_desc < 0)
- {
- error (0, errno, "cannot create regular file `%s'", dst_path);
- return_val = -1;
- goto ret2;
- }
-
- /* Find out the optimal buffer size. */
-
- if (fstat (dest_desc, &sb))
- {
- error (0, errno, "%s", dst_path);
- return_val = -1;
- goto ret;
- }
-
- buf_size = 8192;
-
-
-
- /* Make a buffer with space for a sentinel at the end. */
-
- buf = (char *) alloca (buf_size + sizeof (int));
-
- for (;;)
- {
- n_read = read (source_desc, buf, buf_size);
- if (n_read < 0)
- {
- if (errno == EINTR)
- continue;
- error (0, errno, "%s", src_path);
- return_val = -1;
- goto ret;
- }
- if (n_read == 0)
- break;
-
- n_read_total += n_read;
-
- ip = 0;
- if (make_holes)
- {
- buf[n_read] = 1; /* Sentinel to stop loop. */
-
- /* Find first nonzero *word*, or the word with the sentinel. */
-
- ip = (int *) buf;
- while (*ip++ == 0)
- ;
-
- /* Find the first nonzero *byte*, or the sentinel. */
-
- cp = (char *) (ip - 1);
- while (*cp++ == 0)
- ;
-
- /* If we found the sentinel, the whole input block was zero,
- and we can make a hole. */
-
- if (cp > buf + n_read)
- {
- /* Make a hole. */
- if (lseek (dest_desc, (off_t) n_read, SEEK_CUR) < 0L)
- {
- error (0, errno, "%s", dst_path);
- return_val = -1;
- goto ret;
- }
- last_write_made_hole = 1;
- }
- else
- /* Clear to indicate that a normal write is needed. */
- ip = 0;
- }
- if (ip == 0)
- {
- if (full_write (dest_desc, buf, n_read) < 0)
- {
- error (0, errno, "%s", dst_path);
- return_val = -1;
- goto ret;
- }
- last_write_made_hole = 0;
- }
- }
-
- /* If the file ends with a `hole', something needs to be written at
- the end. Otherwise the kernel would truncate the file at the end
- of the last write operation. */
-
- if (last_write_made_hole)
- {
-#if HAVE_FTRUNCATE
- /* Write a null character and truncate it again. */
- if (full_write (dest_desc, "", 1) < 0
- || ftruncate (dest_desc, n_read_total) < 0)
-#else
- /* Seek backwards one character and write a null. */
- if (lseek (dest_desc, (off_t) -1, SEEK_CUR) < 0L
- || full_write (dest_desc, "", 1) < 0)
-#endif
- {
- error (0, errno, "%s", dst_path);
- return_val = -1;
- }
- }
-
-ret:
- if (close (dest_desc) < 0)
- {
- error (0, errno, "%s", dst_path);
- return_val = -1;
- }
-ret2:
- if (close (source_desc) < 0)
- {
- error (0, errno, "%s", src_path);
- return_val = -1;
- }
-
- return return_val;
-}
diff --git a/camel/providers/MH/camel-mh-folder.h b/camel/providers/MH/camel-mh-folder.h
deleted file mode 100644
index 40800375eb..0000000000
--- a/camel/providers/MH/camel-mh-folder.h
+++ /dev/null
@@ -1,72 +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@aful.org> .
- *
- * 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;
-
- gchar *directory_path;
- GList *file_name_list;
- GArray *uid_array;
-
-} 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-provider.c b/camel/providers/MH/camel-mh-provider.c
deleted file mode 100644
index 316b8a0797..0000000000
--- a/camel/providers/MH/camel-mh-provider.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* camel-mh-provider.c: mh provider registration code */
-
-/*
- *
- * Copyright (C) 1999 Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> .
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-
-#include "config.h"
-#include "camel-mh-store.h"
-#include "camel-provider.h"
-#include "camel-log.h"
-
-
-static CamelProvider _mh_provider = {
- (GtkType) 0,
- PROVIDER_STORE,
- "mh",
- "Camel default mh provider",
- "This is a very simple provider, mh is a bad protocol anyway",
- (GModule *) NULL
-};
-
-
-
-CamelProvider *
-camel_provider_module_init ()
-{
- _mh_provider.object_type = camel_mh_store_get_type();
- return &_mh_provider;
-}
diff --git a/camel/providers/MH/camel-mh-store.c b/camel/providers/MH/camel-mh-store.c
deleted file mode 100644
index 60ba07f47b..0000000000
--- a/camel/providers/MH/camel-mh-store.c
+++ /dev/null
@@ -1,153 +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@aful.org> .
- *
- * 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"
-#include "url-util.h"
-
-static CamelStoreClass *parent_class=NULL;
-
-/* Returns the class for a CamelMhStore */
-#define CMHS_CLASS(so) CAMEL_MH_STORE_CLASS (GTK_OBJECT(so)->klass)
-#define CF_CLASS(so) CAMEL_FOLDER_CLASS (GTK_OBJECT(so)->klass)
-#define CMHF_CLASS(so) CAMEL_MH_FOLDER_CLASS (GTK_OBJECT(so)->klass)
-
-static void _init (CamelStore *store, CamelSession *session, const gchar *url_name);
-static CamelFolder *_get_folder (CamelStore *store, const gchar *folder_name);
-
-
-static void
-camel_mh_store_class_init (CamelMhStoreClass *camel_mh_store_class)
-{
- CamelStoreClass *camel_store_class = CAMEL_STORE_CLASS (camel_mh_store_class);
-
- parent_class = gtk_type_class (camel_store_get_type ());
-
- /* virtual method definition */
- /* virtual method overload */
- camel_store_class->init = _init;
- camel_store_class->get_folder = _get_folder;
-}
-
-
-
-static void
-camel_mh_store_init (gpointer object, gpointer klass)
-{
- CamelMhStore *mh_store = CAMEL_MH_STORE (object);
- CamelStore *store = CAMEL_STORE (object);
-
- store->separator = '/';
-}
-
-
-
-
-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) camel_mh_store_init,
- /* reserved_1 */ NULL,
- /* reserved_2 */ NULL,
- (GtkClassInitFunc) NULL,
- };
-
- camel_mh_store_type = gtk_type_unique (CAMEL_STORE_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, const gchar *toplevel)
-{
- store->toplevel_dir = g_strdup (toplevel);
- CAMEL_STORE(store)->separator = '/';
-}
-
-
-const gchar *
-camel_mh_store_get_toplevel_dir (CamelMhStore *store)
-{
- return store->toplevel_dir;
-}
-
-
-
-static void
-_init (CamelStore *store, CamelSession *session, const gchar *url_name)
-{
- CamelMhStore *mh_store = CAMEL_MH_STORE (store);
- Gurl *store_url;
-
- g_assert (url_name);
- /* call parent implementation */
- parent_class->init (store, session, url_name);
-
-
- /* find the path in the URL*/
- store_url = g_url_new (url_name);
-
- g_return_if_fail (store_url);
- g_return_if_fail (store_url->path);
-
- mh_store->toplevel_dir = g_strdup (store_url->path);
- g_url_free (store_url);
-
-
-
-}
-
-
-static CamelFolder *
-_get_folder (CamelStore *store, const gchar *folder_name)
-{
- CamelMhFolder *new_mh_folder;
- CamelFolder *new_folder;
-
- /* check if folder has already been created */
- /* call the standard routine for that when */
- /* it is done ... */
-
- new_mh_folder = gtk_type_new (CAMEL_MH_FOLDER_TYPE);
- new_folder = CAMEL_FOLDER (new_mh_folder);
-
- CF_CLASS (new_folder)->init_with_store (new_folder, store, NULL);
- CF_CLASS (new_folder)->set_name (new_folder, folder_name, NULL);
-
-
- return new_folder;
-}
diff --git a/camel/providers/MH/camel-mh-store.h b/camel/providers/MH/camel-mh-store.h
deleted file mode 100644
index 924a5a6fc5..0000000000
--- a/camel/providers/MH/camel-mh-store.h
+++ /dev/null
@@ -1,72 +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@aful.org> .
- *
- * 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;
-
- gchar *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, const gchar *toplevel);
-const gchar *camel_mh_store_get_toplevel_dir (CamelMhStore *store);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* CAMEL_MH_STORE_H */
-
-
diff --git a/camel/providers/MH/mh-summary.c b/camel/providers/MH/mh-summary.c
deleted file mode 100644
index 5a964696e0..0000000000
--- a/camel/providers/MH/mh-summary.c
+++ /dev/null
@@ -1,290 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-/*
- *
- * Copyright (C) 1999 Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> .
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-
-
-#include <config.h>
-
-#include "mh-uid.h"
-#include "camel-log.h"
-#include "camel-stream.h"
-#include "camel-stream-fs.h"
-#include "camel-stream-buffered-fs.h"
-#include "gmime-utils.h"
-#include "mh-utils.h"
-
-#include <sys/stat.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <fcntl.h>
-#include <dirent.h>
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-
-void
-mh_generate_summary (CamelFolder *folder)
-{
- CamelMhFolder *mh_folder = CAMEL_MH_FOLDER (folder);
- CamelFolderSummary *summary;
- CamelMessageInfo *message_info;
- CamelFolderInfo *subfolder_info;
- CamelStream *message_stream;
- guint file_number;
- gchar *message_fullpath;
- gchar *directory_path;
- GArray *header_array;
- MhUidCouple *uid_couple;
- Rfc822Header *cur_header;
- int i;
- int n_file;
- GArray *uid_array;
-
- CAMEL_LOG_FULL_DEBUG ("CamelMhFolder::generate_summary entering \n");
-
- g_assert (folder);
-
- directory_path = mh_folder->directory_path;
- if (!directory_path) {
- CAMEL_LOG_FULL_DEBUG ("CamelMhFolder::generate_summary folder has no directory path\n");
- return;
- }
-
- summary = camel_folder_summary_new ();
- folder->summary = summary;
-
- uid_array = mh_folder->uid_array;
-
- if (!uid_array) {
- CAMEL_LOG_FULL_DEBUG ("CamelMhFolder::generate_summary "
- "no uid list, that probably means there is "
- "no message in this folder, exiting \n");
- return;
- }
- uid_couple = (MhUidCouple *)uid_array->data;
-
- for (n_file=0; n_file<uid_array->len; n_file++) {
-
- file_number = uid_couple->file_number;
-
- message_info = g_new0 (CamelMessageInfo, 1);
- message_info->uid = g_new0 (guchar, 17);
- strncpy (message_info->uid, uid_couple->uid, 16);
-
-
- message_fullpath = g_strdup_printf ("%s/%d", directory_path, file_number);
- message_stream = camel_stream_buffered_fs_new_with_name (message_fullpath,
- CAMEL_STREAM_BUFFERED_FS_READ);
- if (!message_stream) {
- CAMEL_LOG_FULL_DEBUG ("CamelMhFolder::generate_summary "
- "could not open %d for reading\n", message_fullpath);
- g_free (message_fullpath);
- return;
- }
- g_free (message_fullpath);
-
- header_array = get_header_array_from_stream (message_stream);
- gtk_object_unref (GTK_OBJECT (message_stream));
-
- for (i=0; i<header_array->len; i++) {
- cur_header = (Rfc822Header *)header_array->data + i;
- if (!g_strcasecmp (cur_header->name, "subject")) {
- message_info->subject = cur_header->value;
- g_free (cur_header->name);
- } else if (!g_strcasecmp (cur_header->name, "sender")) {
- message_info->date = cur_header->value;
- g_free (cur_header->name);
- } else if (!g_strcasecmp (cur_header->name, "date")) {
- message_info->date = cur_header->value;
- g_free (cur_header->name);
- } else {
- g_free (cur_header->name);
- g_free (cur_header->value);
- }
- }
- g_array_free (header_array, TRUE);
-
- summary->message_info_list = g_list_append (summary->message_info_list, message_info);
-
- /* next message in the uid list */
- uid_couple++;
- }
- CAMEL_LOG_FULL_DEBUG ("CamelMhFolder::generate_summary leaving \n");
-
-}
-
-
-void
-mh_save_summary (CamelMhFolder *mh_folder)
-{
- GArray *uid_array;
- MhUidCouple *first_uid_couple;
- CamelFolderSummary *summary;
- GList *msg_info_list;
- CamelMessageInfo *msg_info;
- gchar *directory_path = mh_folder->directory_path;
- gchar *summary_file_path;
- gint fd;
- gint i;
- gint field_lgth;
-
- CAMEL_LOG_FULL_DEBUG ("CamelMhFolder::save_summary entering \n");
-
- summary = CAMEL_FOLDER (mh_folder)->summary;
- if (!summary) return;
-
- summary_file_path = g_strdup_printf ("%s/%s", directory_path, ".camel-summary");
- CAMEL_LOG_FULL_DEBUG ("In the process of writing %s\n", summary_file_path);
- fd = open (summary_file_path, O_WRONLY | O_CREAT );
-
- if (!fd) {
- CAMEL_LOG_FULL_DEBUG ("could not open file %s for writing. Exiting.\n", summary_file_path);
- g_free (summary_file_path);
- return;
- }
- g_free (summary_file_path);
-
- msg_info_list = summary->message_info_list;
- while (msg_info_list) {
- msg_info = msg_info_list->data;
- /* write subject */
- field_lgth = msg_info->subject ? strlen (msg_info->subject) : 0;
- write (fd, &field_lgth, sizeof (gint));
- if (field_lgth)
- write (fd, msg_info->subject, field_lgth);
-
- /* write uid */
- field_lgth = msg_info->uid ? strlen (msg_info->uid) : 0;
- write (fd, &field_lgth, sizeof (gint));
- if (field_lgth)
- write (fd, msg_info->uid, field_lgth);
-
- /* write date */
- field_lgth = msg_info->date ? strlen (msg_info->date) : 0;
- write (fd, &field_lgth, sizeof (gint));
- if (field_lgth)
- write (fd, msg_info->date, field_lgth);
-
- /* write sender */
- field_lgth = msg_info->sender ? strlen (msg_info->sender) : 0;
- write (fd, &field_lgth, sizeof (gint));
- if (field_lgth)
- write (fd, msg_info->sender, field_lgth);
-
- msg_info_list = msg_info_list->next;
-
- }
-
- close (fd);
-
- CAMEL_LOG_FULL_DEBUG ("CamelMhFolder::save_summary leaving \n");
-
-}
-
-
-
-
-
-gint
-mh_load_summary (CamelMhFolder *mh_folder)
-{
- GArray *uid_array;
- MhUidCouple *first_uid_couple;
- CamelFolderSummary *summary;
- CamelMessageInfo *msg_info;
- gchar *directory_path = mh_folder->directory_path;
- gchar *summary_file_path;
- gint fd;
- gint i;
- gint field_lgth;
- gboolean file_eof;
- gint stat_error;
- struct stat stat_buf;
-
- summary = CAMEL_FOLDER (mh_folder)->summary;
- if (summary) return 1; /* should we regenerate it ? */
-
- summary_file_path = g_strdup_printf ("%s/%s", directory_path, ".camel-summary");
- CAMEL_LOG_FULL_DEBUG ("In the process of reading %s\n", summary_file_path);
- fd = open (summary_file_path, O_RDONLY);
- /* tests if file exists */
- stat_error = stat (summary_file_path, &stat_buf);
-
- if (!((stat_error != -1) && S_ISREG (stat_buf.st_mode))) {
- CAMEL_LOG_FULL_DEBUG ("could not open file %s for reading. Exiting.\n", summary_file_path);
- g_free (summary_file_path);
- return -1;
- }
- g_free (summary_file_path);
-
- for (;;) {
- /* read subject */
- file_eof = (read (fd, &field_lgth, sizeof (gint)) <= 0);
- if (file_eof) break;
-
-
- /* allcate a summary if needed */
- if (!summary)
- summary = camel_folder_summary_new ();
- /* allocate a message info struct */
- msg_info = g_new0 (CamelMessageInfo, 1);
-
- if (!file_eof && (field_lgth > 0)) {
- msg_info->subject = g_new0 (gchar, field_lgth + 1);
- read (fd, msg_info->subject, field_lgth);
- } else
- msg_info->subject = NULL;
-
- /* read uid */
- if (!file_eof) file_eof = (read (fd, &field_lgth, sizeof (gint)) <= 0);
- if (!file_eof && (field_lgth > 0)) {
- msg_info->uid = g_new0 (gchar, field_lgth + 1);
- read (fd, msg_info->uid, field_lgth);
- } else
- msg_info->uid = NULL;
-
- /* read date */
- if (!file_eof) file_eof = (read (fd, &field_lgth, sizeof (gint)) <= 0);
- if (!file_eof && (field_lgth > 0)) {
- msg_info->date = g_new0 (gchar, field_lgth + 1);
- read (fd, msg_info->date, field_lgth);
- } else
- msg_info->date = NULL;
-
- /* read sender */
- if (!file_eof) file_eof = (read (fd, &field_lgth, sizeof (gint)) <= 0);
- if (!file_eof && (field_lgth > 0)) {
- msg_info->sender = g_new0 (gchar, field_lgth + 1);
- read (fd, msg_info->sender, field_lgth);
- } else
- msg_info->sender = NULL;
-
- summary->message_info_list = g_list_prepend (summary->message_info_list,
- msg_info);
- }
-
- CAMEL_FOLDER (mh_folder)->summary = summary;
-
- close (fd);
- return 1;
-}
-
-
diff --git a/camel/providers/MH/mh-summary.h b/camel/providers/MH/mh-summary.h
deleted file mode 100644
index 27c9a21f60..0000000000
--- a/camel/providers/MH/mh-summary.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-/*
- *
- * Copyright (C) 1999 Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> .
- *
- * 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 MH_SUMMARY_H
-#define MH_SUMMARY_H 1
-
-#include <glib.h>
-#include "camel-mh-folder.h"
-
-void mh_generate_summary (CamelFolder *folder);
-void mh_save_summary (CamelMhFolder *mh_folder);
-gint mh_load_summary (CamelMhFolder *mh_folder);
-
-#endif /* MH_SUMMARY_H */
diff --git a/camel/providers/MH/mh-uid.c b/camel/providers/MH/mh-uid.c
deleted file mode 100644
index ebcccacd23..0000000000
--- a/camel/providers/MH/mh-uid.c
+++ /dev/null
@@ -1,220 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-/*
- *
- * Copyright (C) 1999 Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> .
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-
-
-#include <config.h>
-
-#include "mh-uid.h"
-#include "camel-log.h"
-#include "camel-stream.h"
-#include "camel-stream-fs.h"
-#include "camel-stream-buffered-fs.h"
-#include "gmime-utils.h"
-#include "md5-utils.h"
-#include "mh-utils.h"
-
-#include <sys/stat.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <fcntl.h>
-#include <dirent.h>
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-
-void
-mh_uid_get_for_file (gchar *filename, guchar uid[16])
-{
- CamelStream *message_stream;
- GArray *header_array;
- Rfc822Header *cur_header;
- int i;
- MD5Context ctx;
-
-
- message_stream = camel_stream_buffered_fs_new_with_name (filename,
- CAMEL_STREAM_BUFFERED_FS_READ);
- header_array = get_header_array_from_stream (message_stream);
- gtk_object_unref (GTK_OBJECT (message_stream));
-
- md5_init (&ctx);
- for (i=0; i<header_array->len; i++) {
- cur_header = (Rfc822Header *)header_array->data + i;
- if (!g_strcasecmp (cur_header->name, "subject")) {
- md5_update (&ctx, cur_header->value, strlen (cur_header->value));
- } else if (!g_strcasecmp (cur_header->name, "sender")) {
- md5_update (&ctx, cur_header->value, strlen (cur_header->value));
- } else if (!g_strcasecmp (cur_header->name, "date")) {
- md5_update (&ctx, cur_header->value, strlen (cur_header->value));
- }
-
- g_free (cur_header->name);
- g_free (cur_header->value);
-
- }
-
- g_array_free (header_array, TRUE);
-
- md5_final (&ctx, uid);
-}
-
-
-
-
-void
-mh_save_uid_list (CamelMhFolder *mh_folder)
-{
- GArray *uid_array;
- MhUidCouple *first_uid_couple;
- gchar *directory_path = mh_folder->directory_path;
- gchar *uidfile_path;
- int fd;
- int i;
-
-
- uidfile_path = g_strdup_printf ("%s/%s", directory_path, ".camel-uid-list");
- CAMEL_LOG_FULL_DEBUG ("In the process of writing %s\n", uidfile_path);
- fd = open (uidfile_path, O_WRONLY | O_CREAT );
-
- if (!fd) {
- CAMEL_LOG_FULL_DEBUG ("could not open file %s for writing. Exiting.\n", uidfile_path);
- g_free (uidfile_path);
- return;
- }
- g_free (uidfile_path);
-
- uid_array = mh_folder->uid_array;
- first_uid_couple = (MhUidCouple *)uid_array->data;
-
- /* write the number of uid contained in the file */
- write (fd, &(uid_array->len), sizeof (guint));
- CAMEL_LOG_FULL_DEBUG ("%d entrie present in the list\n", uid_array->len);
- /* now write the array of uid self */
- write (fd, first_uid_couple, sizeof (MhUidCouple) * uid_array->len);
-
- close (fd);
-}
-
-
-gint
-mh_load_uid_list (CamelMhFolder *mh_folder)
-{
- GArray *new_uid_array;
- MhUidCouple *first_uid_couple;
- gchar *directory_path = mh_folder->directory_path;
- gchar *uidfile_path;
- int fd;
- guint uid_nb;
- struct stat stat_buf;
- gint stat_error = 0;
-
- uidfile_path = g_strdup_printf ("%s/%s", directory_path, ".camel-uid-list");
-
- /* tests if file exists */
- stat_error = stat (uidfile_path, &stat_buf);
-
-
- if (!((stat_error != -1) && S_ISREG (stat_buf.st_mode))) {
- CAMEL_LOG_FULL_DEBUG ("CamelMhFolder::load_uid_list "
- "file %s does not exist. Exiting.\n", uidfile_path);
- g_free (uidfile_path);
- return -1;
- }
-
- fd = open (uidfile_path, O_RDONLY);
- g_free (uidfile_path);
- if (!fd) return -1;
-
- if (mh_folder->uid_array) g_array_free (mh_folder->uid_array, FALSE);
-
- /* read the number of uids in the file */
- read (fd, &uid_nb, sizeof (guint));
- CAMEL_LOG_FULL_DEBUG ("reading %d uid_entries\n", uid_nb);
- new_uid_array = g_array_new (FALSE, FALSE, sizeof (MhUidCouple));
- new_uid_array = g_array_set_size (new_uid_array, uid_nb);
- first_uid_couple = (MhUidCouple *)new_uid_array->data;
-
-
- read (fd, first_uid_couple, sizeof (MhUidCouple) * uid_nb);
-
- mh_folder->uid_array = new_uid_array;
-
- return 1;
-}
-
-
-gint
-mh_generate_uid_list (CamelMhFolder *mh_folder)
-{
- GArray *new_uid_array;
- const gchar *directory_path;
- struct dirent *dir_entry;
- DIR *dir_handle;
- gchar *msg_path;
- guint msg_count;
- MhUidCouple *uid_couple;
- guint file_number;
-
- g_assert (mh_folder);
- CAMEL_LOG_FULL_DEBUG ("in the process of creating uid list \n");
- directory_path = mh_folder->directory_path;
- if (!directory_path) {
- CAMEL_LOG_FULL_DEBUG ("folder has no directory path. Exiting\n");
- return -1;
- }
-
- msg_count = camel_folder_get_message_count (CAMEL_FOLDER (mh_folder), NULL);
- if (!msg_count) {
- CAMEL_LOG_FULL_DEBUG ("no message in %s. Exiting\n", directory_path);
- return -1;
- }
-
- new_uid_array = g_array_new (FALSE, FALSE, sizeof (MhUidCouple));
- new_uid_array = g_array_set_size (new_uid_array, msg_count);
- uid_couple = (MhUidCouple *)new_uid_array->data;
-
- dir_handle = opendir (directory_path);
-
- /* read first entry in the directory */
- dir_entry = readdir (dir_handle);
- while (dir_entry != NULL) {
-
- /* tests if the entry correspond to a message file */
- if (mh_is_a_message_file (dir_entry->d_name, directory_path)) {
-
- /* get the uid for this message */
- msg_path = g_strdup_printf ("%s/%s", directory_path, dir_entry->d_name);
- mh_uid_get_for_file (msg_path, uid_couple->uid);
- g_free (msg_path);
-
- /* convert filename into file number */
- uid_couple->file_number = atoi (dir_entry->d_name);
- uid_couple++;
- }
-
- /* read next entry */
- dir_entry = readdir (dir_handle);
- }
-
- closedir (dir_handle);
- mh_folder->uid_array = new_uid_array;
-}
diff --git a/camel/providers/MH/mh-uid.h b/camel/providers/MH/mh-uid.h
deleted file mode 100644
index 63dfe5b159..0000000000
--- a/camel/providers/MH/mh-uid.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-/*
- *
- * Copyright (C) 1999 Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> .
- *
- * 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 MH_UID_H
-#define MH_UID_H 1
-
-#include <glib.h>
-#include "camel-mh-folder.h"
-
-
-typedef struct {
- gchar uid[16];
- guint file_number;
-} MhUidCouple;
-
-void mh_uid_get_for_file (gchar *filename, guchar uid[16]);
-void mh_save_uid_list (CamelMhFolder *mh_folder);
-gint mh_load_uid_list (CamelMhFolder *mh_folder);
-gint mh_generate_uid_list (CamelMhFolder *mh_folder);
-
-#endif /* MH_UID_H */
diff --git a/camel/providers/MH/mh-utils.c b/camel/providers/MH/mh-utils.c
deleted file mode 100644
index 51bb84bc65..0000000000
--- a/camel/providers/MH/mh-utils.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-/*
- *
- * Copyright (C) 1999 Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> .
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-
-#include <config.h>
-#include "mh-utils.h"
-
-#include <sys/stat.h>
-
-gboolean
-mh_is_a_message_file (const gchar *file_name, const gchar *file_path)
-{
- struct stat stat_buf;
- gint stat_error = 0;
- gboolean ok;
- gchar *full_file_name;
- int i;
-
- /* test if the name is a number */
- i=0;
- while ((file_name[i] != '\0') && (file_name[i] >= '0') && (file_name[i] <= '9'))
- i++;
- if ((i==0) || (file_name[i] != '\0')) return FALSE;
-
- /* is it a regular file ? */
- full_file_name = g_strdup_printf ("%s/%s", file_path, file_name);
- stat_error = stat (full_file_name, &stat_buf);
- g_free (full_file_name);
-
- return ((stat_error != -1) && S_ISREG (stat_buf.st_mode));
-}
-
diff --git a/camel/providers/MH/mh-utils.h b/camel/providers/MH/mh-utils.h
deleted file mode 100644
index 968228b0a3..0000000000
--- a/camel/providers/MH/mh-utils.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-/*
- *
- * Copyright (C) 1999 Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> .
- *
- * 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 MH_UTILS_H
-#define MH_UTILS_H 1
-
-#include <glib.h>
-
-gboolean mh_is_a_message_file (const gchar *file_name, const gchar *file_path);
-
-#endif /* MH_UTILS_H */
diff --git a/camel/providers/Makefile.am b/camel/providers/Makefile.am
deleted file mode 100644
index cf43b07714..0000000000
--- a/camel/providers/Makefile.am
+++ /dev/null
@@ -1,5 +0,0 @@
-## Process this file with automake to produce Makefile.in
-
-SUBDIRS = mbox
-# this ones are disabled for the moment.
-# MH maildir
diff --git a/camel/providers/maildir/.cvsignore b/camel/providers/maildir/.cvsignore
deleted file mode 100644
index 2e7b174532..0000000000
--- a/camel/providers/maildir/.cvsignore
+++ /dev/null
@@ -1,6 +0,0 @@
-Makefile.in
-Makefile
-.deps
-*.lo
-*.la
-.libs
diff --git a/camel/providers/maildir/Makefile.am b/camel/providers/maildir/Makefile.am
deleted file mode 100644
index 51a0d7327b..0000000000
--- a/camel/providers/maildir/Makefile.am
+++ /dev/null
@@ -1,23 +0,0 @@
-## Process this file with automake to produce Makefile.in
-
-SUBDIRS =
-
-libcamelmaildirincludedir = $(includedir)/camel
-
-lib_LTLIBRARIES = libcamelmaildir.la
-
-INCLUDES = -I.. -I$(srcdir)/.. -I$(top_srcdir)/intl -I$(top_srcdir)/camel \
- $(GTK_INCLUDEDIR) -I$(includedir)
-
-libcamelmaildir_la_SOURCES = \
- camel-maildir-folder.c \
- camel-maildir-provider.c \
- camel-maildir-store.c
-
-libcamelmaildirinclude_HEADERS = \
- camel-maildir-folder.h \
- camel-maildir-store.h
-
-libcamelmaildir_la_LDFLAGS = -version-info 0:0:0 -rpath $(libdir)
-
-EXTRA_DIST =
diff --git a/camel/providers/maildir/camel-maildir-folder.c b/camel/providers/maildir/camel-maildir-folder.c
deleted file mode 100644
index 4ad5409658..0000000000
--- a/camel/providers/maildir/camel-maildir-folder.c
+++ /dev/null
@@ -1,803 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* camel-maildir-folder.c : camel-folder subclass for maildir folders */
-
-/*
- *
- * 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
- */
-
-/*
- * AUTHORS : Jukka Zitting
- *
- */
-
-
-#include <config.h>
-#include <sys/stat.h>
-#include <sys/param.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <fcntl.h>
-#include <dirent.h>
-#include <stdio.h>
-#include <errno.h>
-#include <time.h>
-#include <string.h>
-#include "camel-maildir-folder.h"
-#include "camel-maildir-store.h"
-#include "camel-stream-fs.h"
-#include "camel-log.h"
-
-static CamelFolderClass *parent_class=NULL;
-
-/* Returns the class for a CamelMaildirFolder */
-#define CMAILDIRF_CLASS(so) CAMEL_MAILDIR_FOLDER_CLASS (GTK_OBJECT(so)->klass)
-#define CF_CLASS(so) CAMEL_FOLDER_CLASS (GTK_OBJECT(so)->klass)
-#define CMAILDIRS_CLASS(so) CAMEL_STORE_CLASS (GTK_OBJECT(so)->klass)
-
-static void _init_with_store (CamelFolder *folder, CamelStore *parent_store, CamelException *ex);
-static void _set_name (CamelFolder *folder, const gchar *name, CamelException *ex);
-static gboolean _exists (CamelFolder *folder, CamelException *ex);
-static gboolean _create (CamelFolder *folder, CamelException *ex);
-static gboolean _delete (CamelFolder *folder, gboolean recurse, CamelException *ex);
-static gboolean _delete_messages (CamelFolder *folder, CamelException *ex);
-static CamelMimeMessage *_get_message (CamelFolder *folder, gint number, CamelException *ex);
-static gint _get_message_count (CamelFolder *folder, CamelException *ex);
-static void _expunge (CamelFolder *folder, CamelException *ex);
-static GList *_list_subfolders (CamelFolder *folder, CamelException *ex);
-
-/* fs utility functions */
-static DIR * _xopendir (const gchar *path);
-static gboolean _xstat (const gchar *path, struct stat *buf);
-static gboolean _xmkdir (const gchar *path);
-static gboolean _xrename (const gchar *from, const gchar *to);
-static gboolean _xunlink (const gchar *path);
-static gboolean _xrmdir (const gchar *path);
-/* ** */
-
-static void
-camel_maildir_folder_class_init (CamelMaildirFolderClass *camel_maildir_folder_class)
-{
- CamelFolderClass *camel_folder_class =
- CAMEL_FOLDER_CLASS (camel_maildir_folder_class);
-
- parent_class = gtk_type_class (camel_folder_get_type ());
-
- /* virtual method definition */
- /* virtual method overload */
- camel_folder_class->init_with_store = _init_with_store;
- camel_folder_class->set_name = _set_name;
- camel_folder_class->exists = _exists;
- camel_folder_class->create = _create;
- camel_folder_class->delete = _delete;
- camel_folder_class->delete_messages = _delete_messages;
- camel_folder_class->expunge = _expunge;
- camel_folder_class->get_message = _get_message;
- camel_folder_class->get_message_count = _get_message_count;
- camel_folder_class->list_subfolders = _list_subfolders;
-}
-
-GtkType
-camel_maildir_folder_get_type (void)
-{
- static GtkType camel_maildir_folder_type = 0;
-
- if (!camel_maildir_folder_type) {
- GtkTypeInfo camel_maildir_folder_info =
- {
- "CamelMaildirFolder",
- sizeof (CamelMaildirFolder),
- sizeof (CamelMaildirFolderClass),
- (GtkClassInitFunc) camel_maildir_folder_class_init,
- (GtkObjectInitFunc) NULL,
- /* reserved_1 */ NULL,
- /* reserved_2 */ NULL,
- (GtkClassInitFunc) NULL,
- };
-
- camel_maildir_folder_type =
- gtk_type_unique (CAMEL_FOLDER_TYPE, &camel_maildir_folder_info);
- }
-
- return camel_maildir_folder_type;
-}
-
-
-
-
-
-
-/**
- * CamelMaildirFolder::init_with_store: initializes the folder object
- * @folder: folder object to initialize
- * @parent_store: parent store object of the folder
- *
- * Simply tells that the folder can contain messages but not subfolders.
- * Perhaps we'll later implement subfolders too...
- */
-static void
-_init_with_store (CamelFolder *folder, CamelStore *parent_store, CamelException *ex)
-{
- CAMEL_LOG_FULL_DEBUG ("Entering CamelMaildirFolder::init_with_store\n");
- g_assert (folder);
- g_assert (parent_store);
-
- /* call parent method */
- parent_class->init_with_store (folder, parent_store, ex);
-
- folder->can_hold_messages = TRUE;
- folder->can_hold_folders = TRUE;
- folder->has_summary_capability = FALSE;
-
- CAMEL_LOG_FULL_DEBUG ("Leaving CamelMaildirFolder::init_with_store\n");
-}
-
-/**
- * CamelMaildirFolder::set_name: sets the name of the folder
- * @folder: folder object
- * @name: name of the folder
- *
- * Sets the name of the folder object. The existence of a folder with
- * the given name is not checked in this function.
- */
-static void
-_set_name (CamelFolder *folder, const gchar *name, CamelException *ex)
-{
- CamelMaildirFolder *maildir_folder;
- CamelMaildirStore *maildir_store;
-
- CAMEL_LOG_FULL_DEBUG ("Entering CamelMaildirFolder::set_name\n");
- g_assert (folder);
- g_assert (name);
- g_assert (folder->parent_store);
-
- maildir_folder = CAMEL_MAILDIR_FOLDER (folder);
- maildir_store = CAMEL_MAILDIR_STORE (folder->parent_store);
-
- /* call default implementation */
- parent_class->set_name (folder, name, ex);
-
- if (maildir_folder->directory_path)
- g_free (maildir_folder->directory_path);
-
- CAMEL_LOG_FULL_DEBUG ("CamelMaildirFolder::set_name full_name is %s\n", folder->full_name);
- CAMEL_LOG_FULL_DEBUG ("CamelMaildirFolder::set_name toplevel_dir is %s\n", maildir_store->toplevel_dir);
- CAMEL_LOG_FULL_DEBUG ("CamelMaildirFolder::set_name separator is %c\n", camel_store_get_separator (folder->parent_store));
-
- if (folder->full_name && folder->full_name[0])
- maildir_folder->directory_path =
- g_strconcat (maildir_store->toplevel_dir, G_DIR_SEPARATOR_S,
- folder->full_name, NULL);
- else
- maildir_folder->directory_path = g_strdup (maildir_store->toplevel_dir);
-
- CAMEL_LOG_FULL_DEBUG ("CamelMaildirFolder::set_name: name set to %s\n", name);
- CAMEL_LOG_FULL_DEBUG ("Leaving CamelMaildirFolder::set_name\n");
-}
-
-/**
- * CamelMaildirFolder::exists: tests whether the named maildir exists
- * @folder: folder object
- *
- * A created maildir folder object doesn't necessarily exist yet in the
- * filesystem. This function checks whether the maildir exists.
- * The structure of the maildir is stated in the maildir.5 manpage.
- *
- * maildir.5:
- * A directory in maildir format has three subdirectories,
- * all on the same filesystem: tmp, new, and cur.
- *
- * Return value: TRUE if the maildir exists, FALSE otherwise
- */
-static gboolean
-_exists (CamelFolder *folder, CamelException *ex)
-{
- CamelMaildirFolder *maildir_folder = CAMEL_MAILDIR_FOLDER (folder);
- static const gchar *dir[3] = { "new", "cur", "tmp" };
- gint i;
- struct stat statbuf;
- const gchar *maildir;
- gchar *path;
- gboolean rv = TRUE;
-
- CAMEL_LOG_FULL_DEBUG ("Entering CamelMaildirFolder::exists\n");
- g_assert (folder);
- g_return_val_if_fail (maildir_folder->directory_path, FALSE);
-
- maildir = maildir_folder->directory_path;
-
- CAMEL_LOG_FULL_DEBUG ("CamelMailFolder::exists: checking maildir %s\n",
- maildir);
-
- /* check whether the toplevel directory exists */
- rv = _xstat (maildir, &statbuf) && S_ISDIR (statbuf.st_mode);
-
- /* check whether the maildir subdirectories exist */
- for (i = 0; rv && i < 3; i++) {
- path = g_strconcat (maildir, G_DIR_SEPARATOR_S, dir[i], NULL);
-
- rv = _xstat (path, &statbuf) && S_ISDIR (statbuf.st_mode);
-
- g_free (path);
- }
-
- CAMEL_LOG_FULL_DEBUG ("CamelMaildirFolder::exists: %s\n",
- (rv) ? "maildir found" : "maildir not found");
- CAMEL_LOG_FULL_DEBUG ("Leaving CamelMaildirFolder::exists\n");
- return rv;
-}
-
-/**
- * CamelMaildirFolder::create: creates the named maildir
- * @folder: folder object
- *
- * A created maildir folder object doesn't necessarily exist yet in the
- * filesystem. This function creates the maildir if it doesn't yet exist.
- * The structure of the maildir is stated in the maildir.5 manpage.
- *
- * maildir.5:
- * A directory in maildir format has three subdirectories,
- * all on the same filesystem: tmp, new, and cur.
- *
- * Return value: TRUE if the maildir existed already or was created,
- * FALSE otherwise
- */
-static gboolean
-_create (CamelFolder *folder, CamelException *ex)
-{
- CamelMaildirFolder *maildir_folder = CAMEL_MAILDIR_FOLDER (folder);
- static const gchar *dir[3] = { "new", "cur", "tmp" };
- gint i;
- const gchar *maildir;
- gchar *path;
- gboolean rv = TRUE;
-
- CAMEL_LOG_FULL_DEBUG ("Entering CamelMaildirFolder::create\n");
- g_assert (folder);
-
- /* check whether the maildir already exists */
- if (camel_folder_exists (folder, ex)) return TRUE;
-
- maildir = maildir_folder->directory_path;
-
- CAMEL_LOG_FULL_DEBUG ("CamelMailFolder::create: creating maildir %s\n",
- maildir);
-
- /* create the toplevel directory */
- rv = _xmkdir (maildir);
-
- /* create the maildir subdirectories */
- for (i = 0; rv && i < 3; i++) {
- path = g_strconcat (maildir, G_DIR_SEPARATOR_S, dir[i], NULL);
-
- rv = _xmkdir (path);
-
- g_free (path);
- }
-
- CAMEL_LOG_FULL_DEBUG ("CamelMaildirFolder::create: %s\n",
- rv ? "maildir created" : "an error occurred");
- CAMEL_LOG_FULL_DEBUG ("Leaving CamelMaildirFolder::create\n");
- return rv;
-}
-
-/**
- * CamelMaildirFolder::delete: delete the maildir folder
- * @folder: the folder object
- * @recurse:
- *
- * This function empties and deletes the maildir folder. The subdirectories
- * "tmp", "cur", and "new" are removed first and then the toplevel maildir
- * directory is deleted. All files from the directories are deleted as well,
- * so you should be careful when using this function. If a subdirectory cannot
- * be deleted, then the operation it is stopped. Thus if an error occurs, the
- * maildir directory won't be removed, but it might no longer be a valid maildir.
- */
-static gboolean
-_delete (CamelFolder *folder, gboolean recurse, CamelException *ex)
-{
- CamelMaildirFolder *maildir_folder = CAMEL_MAILDIR_FOLDER (folder);
- static const gchar *dir[3] = { "new", "cur", "tmp" };
- gint i;
- const gchar *maildir;
- gchar *path;
- gboolean rv = TRUE;
-
- CAMEL_LOG_FULL_DEBUG ("Entering CamelMaildirFolder::create\n");
- g_assert (folder);
-
- /* check whether the maildir already exists */
- if (!camel_folder_exists (folder, ex)) return TRUE;
-
- maildir = maildir_folder->directory_path;
-
- CAMEL_LOG_FULL_DEBUG ("CamelMailFolder::delete: deleting maildir %s\n",
- maildir);
-
- /* delete the maildir subdirectories */
- for (i = 0; rv && i < 3; i++) {
- path = g_strconcat (maildir, G_DIR_SEPARATOR_S, dir[i], NULL);
-
- rv = _xrmdir (path);
-
- g_free (path);
- }
-
- /* create the toplevel directory */
- if (rv)
- rv = _xrmdir (maildir);
-
- CAMEL_LOG_FULL_DEBUG ("CamelMaildirFolder::delete: %s\n",
- rv ? "maildir deleted" : "an error occurred");
- CAMEL_LOG_FULL_DEBUG ("Leaving CamelMaildirFolder::delete\n");
- return rv;
-}
-
-/**
- * CamelMaildirFolder::delete_messages: empty the maildir folder
- * @folder: the folder object
- *
- * This function empties the maildir folder. All messages from the
- * "cur" subdirectory are deleted. If a message cannot be deleted, then
- * it is just skipped and the rest of the messages are still deleted.
- * Files with names starting with a dot are skipped as described in the
- * maildir.5 manpage.
- *
- * maildir.5:
- * It is a good idea for readers to skip all filenames in new
- * and cur starting with a dot. Other than this, readers
- * should not attempt to parse filenames.
- *
- * Return value: FALSE on error and if some messages could not be deleted.
- * TRUE otherwise.
- */
-static gboolean
-_delete_messages (CamelFolder *folder, CamelException *ex)
-{
- CamelMaildirFolder *maildir_folder = CAMEL_MAILDIR_FOLDER (folder);
- const gchar *maildir;
- gchar *curdir, *file;
- DIR *dir_handle;
- struct dirent *dir_entry;
- gboolean rv = TRUE;
-
- CAMEL_LOG_FULL_DEBUG ("Entering CamelMaildirFolder::delete_messages\n");
- g_assert (folder);
-
- /* call default implementation */
- parent_class->delete_messages (folder, ex);
-
- /* Check if the folder didn't exist */
- if (!camel_folder_exists (folder, ex)) return TRUE;
-
- maildir = maildir_folder->directory_path;
-
- CAMEL_LOG_FULL_DEBUG ("CamelMaildirFolder::delete_messages: "
- "deleting messages from %s\n", maildir);
-
- /* delete messages from the maildir subdirectory "cur" */
- curdir = g_strconcat (maildir, G_DIR_SEPARATOR_S, "cur", NULL);
-
- dir_handle = _xopendir (curdir);
- if (dir_handle) {
- while ((dir_entry = readdir (dir_handle))) {
- if (dir_entry->d_name[0] == '.') continue;
- file = g_strconcat (curdir, G_DIR_SEPARATOR_S,
- dir_entry->d_name, NULL);
-
- if (!_xunlink (file)) rv = FALSE;
-
- g_free (file);
- }
- closedir (dir_handle);
- } else
- rv = FALSE;
-
- g_free (curdir);
-
- CAMEL_LOG_FULL_DEBUG ("CamelMaildirFolder::delete_messages: %s\n",
- rv ? "messages deleted" : "an error occurred");
- CAMEL_LOG_FULL_DEBUG ("Leaving CamelMaildirFolder::delete_messages\n");
- return rv;
-}
-
-/**
- * CamelMaildirFolder::get_message: get a message from maildir
- * @folder: the folder object
- * @number: number of the message within the folder
- *
- * Return value: the message, NULL on error
- */
-static CamelMimeMessage *
-_get_message (CamelFolder *folder, gint number, CamelException *ex)
-{
- CamelMaildirFolder *maildir_folder = CAMEL_MAILDIR_FOLDER(folder);
- DIR *dir_handle;
- struct dirent *dir_entry;
- CamelStream *stream;
- CamelMimeMessage *message = NULL;
- const gchar *maildir;
- gchar *curdir, *file = NULL;
- gint count = -1;
-
- CAMEL_LOG_FULL_DEBUG ("Entering CamelMaildirFolder::get_message\n");
- g_assert(folder);
-
- /* Check if the folder exists */
- if (!camel_folder_exists (folder, ex)) return NULL;
-
- maildir = maildir_folder->directory_path;
-
- CAMEL_LOG_FULL_DEBUG ("CamelMaildirFolder::get_message: "
- "getting message #%d from %s\n", number, maildir);
-
- /* Count until the desired message is reached */
- curdir = g_strconcat (maildir, G_DIR_SEPARATOR_S, "cur", NULL);
- if ((dir_handle = _xopendir (curdir))) {
- while ((count < number) && (dir_entry = readdir (dir_handle)))
- if (dir_entry->d_name[0] != '.') count++;
-
- if (count == number)
- file = g_strconcat (curdir, G_DIR_SEPARATOR_S,
- dir_entry->d_name, NULL);
-
- closedir (dir_handle);
- }
- g_free (curdir);
- if (!file) return NULL;
-
- /* Create the message object */
-#warning use session field here
- message = camel_mime_message_new_with_session ((CamelSession *) NULL);
- stream = camel_stream_fs_new_with_name (file, CAMEL_STREAM_FS_READ);
-
- if (!message || !stream) {
- g_free (file);
- if (stream) gtk_object_unref (GTK_OBJECT (stream));
- if (message) gtk_object_unref (GTK_OBJECT (message));
- return NULL;
- }
-
- camel_data_wrapper_construct_from_stream (CAMEL_DATA_WRAPPER (message),
- stream);
- gtk_object_unref (GTK_OBJECT (stream));
- gtk_object_set_data_full (GTK_OBJECT (message),
- "fullpath", file, g_free);
-
- CAMEL_LOG_FULL_DEBUG ("CamelMaildirFolder::get_message: "
- "message %p created from %s\n", message, file);
- CAMEL_LOG_FULL_DEBUG ("Leaving CamelMaildirFolder::get_message\n");
- return message;
-}
-
-/**
- * CamelMaildirFolder::get_message_count: count messages in maildir
- * @folder: the folder object
- *
- * Returns the number of messages in the maildir folder. New messages
- * are included in this count.
- *
- * Return value: number of messages in the maildir, -1 on error
- */
-static gint
-_get_message_count (CamelFolder *folder, CamelException *ex)
-{
- CamelMaildirFolder *maildir_folder = CAMEL_MAILDIR_FOLDER(folder);
- const gchar *maildir;
- gchar *newdir, *curdir, *newfile, *curfile;
- DIR *dir_handle;
- struct dirent *dir_entry;
- guint count = 0;
-
- CAMEL_LOG_FULL_DEBUG ("Entering "
- "CamelMaildirFolder::get_message_count\n");
- g_assert(folder);
-
- /* check if the maildir exists */
- if (!camel_folder_exists (folder, ex)) return -1;
-
- maildir = maildir_folder->directory_path;
-
- newdir = g_strconcat (maildir, G_DIR_SEPARATOR_S, "new", NULL);
- curdir = g_strconcat (maildir, G_DIR_SEPARATOR_S, "cur", NULL);
-
- /* Check new messages */
- CAMEL_LOG_FULL_DEBUG ("CamelMaildirFolder::get_message_count: "
- "getting new messages from %s\n", newdir);
- if ((dir_handle = _xopendir (newdir))) {
- while ((dir_entry = readdir (dir_handle))) {
- if (dir_entry->d_name[0] == '.') continue;
- newfile = g_strconcat (newdir, G_DIR_SEPARATOR_S,
- dir_entry->d_name, NULL);
- curfile = g_strconcat (curdir, G_DIR_SEPARATOR_S,
- dir_entry->d_name, ":2,", NULL);
-
- _xrename (newfile, curfile);
-
- g_free (curfile);
- g_free (newfile);
- }
- closedir (dir_handle);
- }
-
- /* Count messages */
- CAMEL_LOG_FULL_DEBUG ("CamelMaildirFolder::get_message_count: "
- "counting messages in %s\n", curdir);
- if ((dir_handle = _xopendir (curdir))) {
- while ((dir_entry = readdir (dir_handle)))
- if (dir_entry->d_name[0] != '.') count++;
- closedir (dir_handle);
- }
-
- g_free (curdir);
- g_free (newdir);
-
- CAMEL_LOG_FULL_DEBUG ("CamelMaildirFolder::get_message_count: "
- " found %d messages\n", count);
- CAMEL_LOG_FULL_DEBUG ("Leaving "
- "CamelMaildirFolder::get_message_count\n");
- return count;
-}
-
-
-
-
-/**
- * CamelMaildirFolder::expunge: expunge messages marked as deleted
- * @folder: the folder object
- *
- * Physically deletes the messages marked as deleted in the folder.
- */
-static void
-_expunge (CamelFolder *folder, CamelException *ex)
-{
- CamelMimeMessage *message;
- GList *node;
- gchar *fullpath;
-
- CAMEL_LOG_FULL_DEBUG ("Entering CamelMaildirFolder::expunge\n");
- g_assert(folder);
-
- /* expunge messages marked for deletion */
- for (node = folder->message_list; node; node = g_list_next(node)) {
- message = CAMEL_MIME_MESSAGE (node->data);
- if (!message) {
- CAMEL_LOG_WARNING ("CamelMaildirFolder::expunge: "
- "null message in node %p\n", node);
- continue;
- }
-
- if (camel_mime_message_get_flag (message, "DELETED")) {
- CAMEL_LOG_FULL_DEBUG ("CamelMaildirFolder::expunge: "
- "expunging message #%d\n",
- message->message_number);
-
- /* expunge the message */
- fullpath = gtk_object_get_data (GTK_OBJECT (message),
- "fullpath");
- CAMEL_LOG_FULL_DEBUG ("CamelMaildirFolder::expunge: "
- "message fullpath is %s\n",
- fullpath);
-
- if (_xunlink (fullpath))
- message->expunged = TRUE;
- } else {
- CAMEL_LOG_FULL_DEBUG ("CamelMaildirFolder::expunge: "
- "skipping message #%d\n",
- message->message_number);
- }
- }
-
- CAMEL_LOG_FULL_DEBUG ("Leaving CamelMaildirFolder::expunge\n");
-}
-
-
-
-
-/**
- * CamelMaildirFolder::list_subfolders: return a list of subfolders
- * @folder: the folder object
- *
- * Returns the names of the maildir subfolders in a list.
- *
- * Return value: list of subfolder names
- */
-static GList *
-_list_subfolders (CamelFolder *folder, CamelException *ex)
-{
- CamelMaildirFolder *maildir_folder = CAMEL_MAILDIR_FOLDER (folder);
- const gchar *maildir;
- gchar *subdir;
- struct stat statbuf;
- struct dirent *dir_entry;
- DIR *dir_handle;
- GList *subfolders = NULL;
-
- CAMEL_LOG_FULL_DEBUG ("Entering CamelMaildirFolder::list_subfolders\n");
- g_assert (folder);
-
- /* check if the maildir exists */
- if (!camel_folder_exists (folder, ex)) return NULL;
-
- /* scan through the maildir toplevel directory */
- maildir = maildir_folder->directory_path;
- if ((dir_handle = _xopendir (maildir))) {
- while ((dir_entry = readdir (dir_handle))) {
- if (dir_entry->d_name[0] == '.') continue;
- if (strcmp (dir_entry->d_name, "new") == 0) continue;
- if (strcmp (dir_entry->d_name, "cur") == 0) continue;
- if (strcmp (dir_entry->d_name, "tmp") == 0) continue;
-
- subdir = g_strconcat (maildir, G_DIR_SEPARATOR_S,
- dir_entry->d_name, NULL);
-
- if (_xstat (subdir, &statbuf)
- && S_ISDIR (statbuf.st_mode))
- subfolders =
- g_list_append (
- subfolders,
- g_strdup (dir_entry->d_name));
-
- g_free (subdir);
- }
- closedir (dir_handle);
- }
-
- CAMEL_LOG_FULL_DEBUG ("Leaving CamelMaildirFolder::list_subfolders\n");
- return subfolders;
-}
-
-
-
-
-
-
-
-/*
- * fs utility function
- *
- */
-
-static DIR *
-_xopendir (const gchar *path)
-{
- DIR *handle;
- g_assert (path);
-
- handle = opendir (path);
- if (!handle) {
- CAMEL_LOG_WARNING ("ERROR: opendir (%s);\n", path);
- CAMEL_LOG_FULL_DEBUG (" Full error text is: (%d) %s\n",
- errno, strerror(errno));
- }
-
- return handle;
-}
-
-static gboolean
-_xstat (const gchar *path, struct stat *buf)
-{
- gint stat_error;
- g_assert (path);
- g_assert (buf);
-
- stat_error = stat (path, buf);
- if (stat_error == 0) {
- return TRUE;
- } else if (errno == ENOENT) {
- buf->st_mode = 0;
- return TRUE;
- } else {
- CAMEL_LOG_WARNING ("ERROR: stat (%s, %p);\n", path, buf);
- CAMEL_LOG_FULL_DEBUG (" Full error text is: (%d) %s\n",
- errno, strerror(errno));
- return FALSE;
- }
-}
-
-static gboolean
-_xmkdir (const gchar *path)
-{
- g_assert (path);
-
- if (mkdir (path, S_IRWXU) == -1) {
- CAMEL_LOG_WARNING ("ERROR: mkdir (%s, S_IRWXU);\n", path);
- CAMEL_LOG_FULL_DEBUG (" Full error text is: (%d) %s\n",
- errno, strerror(errno));
- return FALSE;
- }
-
- return TRUE;
-}
-
-static gboolean
-_xrename (const gchar *from, const gchar *to)
-{
- g_assert (from);
- g_assert (to);
-
- if (rename (from, to) == 0) {
- return TRUE;
- } else {
- CAMEL_LOG_WARNING ("ERROR: rename (%s, %s);\n", from, to);
- CAMEL_LOG_FULL_DEBUG (" Full error text is: (%d) %s\n",
- errno, strerror(errno));
- return FALSE;
- }
-}
-
-static gboolean
-_xunlink (const gchar *path)
-{
- g_assert (path);
-
- if (unlink (path) == 0) {
- return TRUE;
- } else if (errno == ENOENT) {
- return TRUE;
- } else {
- CAMEL_LOG_WARNING ("ERROR: unlink (%s);\n", path);
- CAMEL_LOG_FULL_DEBUG (" Full error text is: (%d) %s\n",
- errno, strerror(errno));
- return FALSE;
- }
-}
-
-static gboolean
-_xrmdir (const gchar *path)
-{
- DIR *dir_handle;
- struct dirent *dir_entry;
- gchar *file;
- struct stat statbuf;
- g_assert (path);
-
- dir_handle = opendir (path);
- if (!dir_handle && errno == ENOENT) {
- return TRUE;
- } else if (!dir_handle) {
- CAMEL_LOG_WARNING ("ERROR: opendir (%s);\n", path);
- CAMEL_LOG_FULL_DEBUG (" Full error text is: (%d) %s\n",
- errno, strerror(errno));
- return FALSE;
- }
-
- while ((dir_entry = readdir (dir_handle))) {
- file = g_strconcat (path, G_DIR_SEPARATOR_S, dir_entry->d_name,
- NULL);
- if (_xstat (file, &statbuf) && S_ISREG (statbuf.st_mode))
- _xunlink (file);
- g_free (file);
- }
-
- closedir (dir_handle);
-
- if (rmdir (path) == 0) {
- return TRUE;
- } else if (errno == ENOENT) {
- return TRUE;
- } else {
- CAMEL_LOG_WARNING ("ERROR: rmdir (%s);\n", path);
- CAMEL_LOG_FULL_DEBUG (" Full error text is: (%d) %s\n",
- errno, strerror(errno));
- return FALSE;
- }
-}
-
-/** *** **/
-
diff --git a/camel/providers/maildir/camel-maildir-folder.h b/camel/providers/maildir/camel-maildir-folder.h
deleted file mode 100644
index 5997da2011..0000000000
--- a/camel/providers/maildir/camel-maildir-folder.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* camel-maildir-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_MAILDIR_FOLDER_H
-#define CAMEL_MAILDIR_FOLDER_H 1
-
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* __cplusplus }*/
-
-#include <gtk/gtk.h>
-#include "camel-folder.h"
-/* #include "camel-store.h" */
-
-#define CAMEL_MAILDIR_FOLDER_TYPE (camel_maildir_folder_get_type ())
-#define CAMEL_MAILDIR_FOLDER(obj) (GTK_CHECK_CAST((obj), CAMEL_MAILDIR_FOLDER_TYPE, CamelMaildirFolder))
-#define CAMEL_MAILDIR_FOLDER_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_MAILDIR_FOLDER_TYPE, CamelMaildirFolderClass))
-#define IS_CAMEL_MAILDIR_FOLDER(o) (GTK_CHECK_TYPE((o), CAMEL_MAILDIR_FOLDER_TYPE))
-
-
-typedef struct {
- CamelFolder parent_object;
-
- gchar *directory_path;
-} CamelMaildirFolder;
-
-
-
-typedef struct {
- CamelFolderClass parent_class;
-
- /* Virtual methods */
-
-} CamelMaildirFolderClass;
-
-
-/* public methods */
-
-/* Standard Gtk function */
-GtkType camel_maildir_folder_get_type (void);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* CAMEL_MAILDIR_FOLDER_H */
diff --git a/camel/providers/maildir/camel-maildir-provider.c b/camel/providers/maildir/camel-maildir-provider.c
deleted file mode 100644
index cd5521adc0..0000000000
--- a/camel/providers/maildir/camel-maildir-provider.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* camel-maildir-provider.c: maildir provider registration code */
-
-/*
- *
- * Copyright (C) 1999 Bertrand Guiheneuf <Bertrand.Guiheneuf@inria.fr> .
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-
-#include "config.h"
-#include "camel-maildir-store.h"
-#include "camel-provider.h"
-#include "camel-log.h"
-
-
-static CamelProvider _maildir_provider = {
- (GtkType) 0,
- PROVIDER_STORE,
- "maildir",
- "Maildir provider for Camel",
- "This maildir provider is based on the default MH provider of Camel",
- (GModule *) NULL
-};
-
-
-
-CamelProvider *
-camel_provider_module_init ()
-{
- _maildir_provider.object_type = camel_maildir_store_get_type();
- return &_maildir_provider;
-}
diff --git a/camel/providers/maildir/camel-maildir-store.c b/camel/providers/maildir/camel-maildir-store.c
deleted file mode 100644
index 8f37494003..0000000000
--- a/camel/providers/maildir/camel-maildir-store.c
+++ /dev/null
@@ -1,124 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* camel-maildir-store.c : class for an maildir 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-maildir-store.h"
-#include "camel-maildir-folder.h"
-#include "url-util.h"
-
-static CamelStoreClass *parent_class=NULL;
-
-/* Returns the class for a CamelMaildirStore */
-#define CMAILDIRS_CLASS(so) CAMEL_MAILDIR_STORE_CLASS (GTK_OBJECT(so)->klass)
-#define CF_CLASS(so) CAMEL_FOLDER_CLASS (GTK_OBJECT(so)->klass)
-#define CMAILDIRF_CLASS(so) CAMEL_MAILDIR_FOLDER_CLASS (GTK_OBJECT(so)->klass)
-
-static void _init (CamelStore *store, CamelSession *session,
- const gchar *url_name);
-static CamelFolder *_get_folder (CamelStore *store, const gchar *folder_name);
-
-static void
-camel_maildir_store_class_init (
- CamelMaildirStoreClass *camel_maildir_store_class)
-{
- CamelStoreClass *camel_store_class =
- CAMEL_STORE_CLASS (camel_maildir_store_class);
-
- parent_class = gtk_type_class (camel_store_get_type ());
-
- /* virtual method definition */
- /* virtual method overload */
- camel_store_class->init = _init;
- camel_store_class->get_folder = _get_folder;
-}
-
-static void
-camel_maildir_store_init (gpointer object, gpointer klass)
-{
- CamelMaildirStore *maildir_store = CAMEL_MAILDIR_STORE (object);
- CamelStore *store = CAMEL_STORE (object);
-
- store->separator = G_DIR_SEPARATOR;
-}
-
-GtkType
-camel_maildir_store_get_type (void)
-{
- static GtkType camel_maildir_store_type = 0;
-
- if (!camel_maildir_store_type) {
- GtkTypeInfo camel_maildir_store_info =
- {
- "CamelMaildirStore",
- sizeof (CamelMaildirStore),
- sizeof (CamelMaildirStoreClass),
- (GtkClassInitFunc) camel_maildir_store_class_init,
- (GtkObjectInitFunc) camel_maildir_store_init,
- /* reserved_1 */ NULL,
- /* reserved_2 */ NULL,
- (GtkClassInitFunc) NULL,
- };
-
- camel_maildir_store_type =
- gtk_type_unique (CAMEL_STORE_TYPE,
- &camel_maildir_store_info);
- }
-
- return camel_maildir_store_type;
-}
-
-static void
-_init (CamelStore *store, CamelSession *session, const gchar *url_name)
-{
- CamelMaildirStore *maildir_store = CAMEL_MAILDIR_STORE (store);
- Gurl *store_url;
- g_assert (url_name);
-
- /* call parent implementation */
- parent_class->init (store, session, url_name);
-
- /* find the path in the URL*/
- store_url = g_url_new (url_name);
-
- g_return_if_fail (store_url);
- g_return_if_fail (store_url->path);
-
- maildir_store->toplevel_dir = g_strdup (store_url->path);
-
- g_url_free (store_url);
-}
-
-static CamelFolder *
-_get_folder (CamelStore *store, const gchar *folder_name)
-{
- CamelMaildirStore *maildir_store = CAMEL_MAILDIR_STORE (store);
- CamelMaildirFolder *new_maildir_folder;
- CamelFolder *new_folder;
-
- new_maildir_folder = gtk_type_new (CAMEL_MAILDIR_FOLDER_TYPE);
- new_folder = CAMEL_FOLDER (new_maildir_folder);
-
- CF_CLASS (new_folder)->init_with_store (new_folder, store, NULL);
- CF_CLASS (new_folder)->set_name (new_folder, folder_name, NULL);
-
- return new_folder;
-}
diff --git a/camel/providers/maildir/camel-maildir-store.h b/camel/providers/maildir/camel-maildir-store.h
deleted file mode 100644
index 1a95ed1436..0000000000
--- a/camel/providers/maildir/camel-maildir-store.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* camel-maildirstore.h : class for an maildir 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_MAILDIR_STORE_H
-#define CAMEL_MAILDIR_STORE_H 1
-
-
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* __cplusplus }*/
-
-#include <gtk/gtk.h>
-#include "camel-store.h"
-
-#define CAMEL_MAILDIR_STORE_TYPE (camel_maildir_store_get_type ())
-#define CAMEL_MAILDIR_STORE(obj) (GTK_CHECK_CAST((obj), CAMEL_MAILDIR_STORE_TYPE, CamelMaildirStore))
-#define CAMEL_MAILDIR_STORE_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_MAILDIR_STORE_TYPE, CamelMaildirStoreClass))
-#define IS_CAMEL_MAILDIR_STORE(o) (GTK_CHECK_TYPE((o), CAMEL_MAILDIR_STORE_TYPE))
-
-
-typedef struct {
- CamelStore parent_object;
-
- gchar *toplevel_dir;
-} CamelMaildirStore;
-
-
-
-typedef struct {
- CamelStoreClass parent_class;
-
-
-} CamelMaildirStoreClass;
-
-
-/* public methods */
-
-/* Standard Gtk function */
-GtkType camel_maildir_store_get_type (void);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* CAMEL_MAILDIR_STORE_H */
-
-
diff --git a/camel/providers/mbox/.cvsignore b/camel/providers/mbox/.cvsignore
deleted file mode 100644
index fd6b811c68..0000000000
--- a/camel/providers/mbox/.cvsignore
+++ /dev/null
@@ -1,7 +0,0 @@
-.deps
-Makefile
-Makefile.in
-.libs
-.deps
-*.lo
-*.la
diff --git a/camel/providers/mbox/Makefile.am b/camel/providers/mbox/Makefile.am
deleted file mode 100644
index c258f3d747..0000000000
--- a/camel/providers/mbox/Makefile.am
+++ /dev/null
@@ -1,38 +0,0 @@
-## Process this file with automake to produce Makefile.in
-
-SUBDIRS =
-
-libcamelmboxincludedir = $(includedir)/camel
-
-
-provider_LTLIBRARIES = libcamelmbox.la
-
-INCLUDES = -I.. -I$(srcdir)/.. -I$(includedir) \
- -I$(top_srcdir)/intl \
- $(GTK_INCLUDEDIR) -I$(top_srcdir)/camel \
- -I$(top_srcdir)/libibex
-
-libcamelmbox_la_SOURCES = \
- camel-mbox-folder.c \
- camel-mbox-parser.c \
- camel-mbox-provider.c \
- camel-mbox-store.c \
- camel-mbox-summary.c \
- camel-mbox-search.c \
- camel-mbox-utils.c
-
-libcamelmboxinclude_HEADERS = \
- camel-mbox-folder.h \
- camel-mbox-parser.h \
- camel-mbox-store.h \
- camel-mbox-summary.h \
- camel-mbox-search.h \
- camel-mbox-utils.h
-
-
-libcamelmbox_la_LDFLAGS = -version-info 0:0:0 -rpath $(libdir)
-
-#libcamelmbox_la_LIBADD = -L$(top_srcdir)/libibex -libex
-libcamelmbox_la_LIBADD = $(top_srcdir)/libibex/libibex.la $(UNICODE_LIBS)
-
-EXTRA_DIST =
diff --git a/camel/providers/mbox/camel-mbox-folder.c b/camel/providers/mbox/camel-mbox-folder.c
deleted file mode 100644
index 64d559c00a..0000000000
--- a/camel/providers/mbox/camel-mbox-folder.c
+++ /dev/null
@@ -1,1131 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* camel-mbox-folder.c : Abstract class for an email folder */
-
-/*
- * Author : Bertrand Guiheneuf <bertrand@helixcode.com>
- *
- * Copyright (C) 1999 Helix Code .
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-
-
-#include <config.h>
-
-#include <stdlib.h>
-#include <sys/types.h>
-#include <dirent.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <errno.h>
-#include <string.h>
-#include <fcntl.h>
-
-#include "camel-mbox-folder.h"
-#include "camel-mbox-store.h"
-#include "string-utils.h"
-#include "camel-log.h"
-#include "camel-stream-buffered-fs.h"
-#include "camel-folder-summary.h"
-#include "camel-mbox-summary.h"
-#include "camel-mbox-parser.h"
-#include "camel-mbox-utils.h"
-#include "md5-utils.h"
-#include "gmime-utils.h"
-#include "camel-mbox-search.h"
-
-#include "camel-exception.h"
-
-static CamelFolderClass *parent_class=NULL;
-
-/* Returns the class for a CamelMboxFolder */
-#define CMBOXF_CLASS(so) CAMEL_MBOX_FOLDER_CLASS (GTK_OBJECT(so)->klass)
-#define CF_CLASS(so) CAMEL_FOLDER_CLASS (GTK_OBJECT(so)->klass)
-#define CMBOXS_CLASS(so) CAMEL_STORE_CLASS (GTK_OBJECT(so)->klass)
-
-
-static void _init_with_store (CamelFolder *folder, CamelStore *parent_store, CamelException *ex);
-static void _set_name(CamelFolder *folder, const gchar *name, CamelException *ex);
-
-
-static void _open (CamelFolder *folder, CamelFolderOpenMode mode, CamelException *ex);
-static void _close (CamelFolder *folder, gboolean expunge, CamelException *ex);
-static gboolean _exists (CamelFolder *folder, CamelException *ex);
-static gboolean _create(CamelFolder *folder, CamelException *ex);
-static gboolean _delete (CamelFolder *folder, gboolean recurse, CamelException *ex);
-static gboolean _delete_messages (CamelFolder *folder, CamelException *ex);
-static GList *_list_subfolders (CamelFolder *folder, CamelException *ex);
-/* static CamelMimeMessage *_get_message_by_number (CamelFolder *folder, gint number, CamelException *ex);*/
-static gint _get_message_count (CamelFolder *folder, CamelException *ex);
-static gint _append_message (CamelFolder *folder, CamelMimeMessage *message, CamelException *ex);
-static GList *_get_uid_list (CamelFolder *folder, CamelException *ex);
-static CamelMimeMessage *_get_message_by_uid (CamelFolder *folder, const gchar *uid, CamelException *ex);
-#if 0
-static void _expunge (CamelFolder *folder, CamelException *ex);
-static void _copy_message_to (CamelFolder *folder, CamelMimeMessage *message, CamelFolder *dest_folder, CamelException *ex);
-static const gchar *_get_message_uid (CamelFolder *folder, CamelMimeMessage *message, CamelException *ex);
-#endif
-
-static CamelFolderSummary *search_by_expression(CamelFolder *folder, const char *expression, CamelException *ex);
-
-static void _finalize (GtkObject *object);
-
-static void
-camel_mbox_folder_class_init (CamelMboxFolderClass *camel_mbox_folder_class)
-{
- CamelFolderClass *camel_folder_class = CAMEL_FOLDER_CLASS (camel_mbox_folder_class);
- GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (camel_folder_class);
-
- parent_class = gtk_type_class (camel_folder_get_type ());
-
- /* virtual method definition */
-
- /* virtual method overload */
- camel_folder_class->init_with_store = _init_with_store;
- camel_folder_class->set_name = _set_name;
- camel_folder_class->open = _open;
- camel_folder_class->close = _close;
- camel_folder_class->exists = _exists;
- camel_folder_class->create = _create;
- camel_folder_class->delete = _delete;
- camel_folder_class->delete_messages = _delete_messages;
- camel_folder_class->list_subfolders = _list_subfolders;
- /* camel_folder_class->get_message_by_number = _get_message_by_number; */
- camel_folder_class->get_message_count = _get_message_count;
- camel_folder_class->append_message = _append_message;
- camel_folder_class->get_uid_list = _get_uid_list;
-#if 0
- camel_folder_class->expunge = _expunge;
- camel_folder_class->copy_message_to = _copy_message_to;
- camel_folder_class->get_message_uid = _get_message_uid;
-#endif
- camel_folder_class->get_message_by_uid = _get_message_by_uid;
-
- camel_folder_class->search_by_expression = search_by_expression;
-
- gtk_object_class->finalize = _finalize;
-
-}
-
-
-
-static void
-_finalize (GtkObject *object)
-{
- CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER (object);
-
- CAMEL_LOG_FULL_DEBUG ("Entering CamelFolder::finalize\n");
-
-
- g_free (mbox_folder->folder_file_path);
- g_free (mbox_folder->folder_dir_path);
-
- GTK_OBJECT_CLASS (parent_class)->finalize (object);
- CAMEL_LOG_FULL_DEBUG ("Leaving CamelFolder::finalize\n");
-}
-
-
-
-
-
-GtkType
-camel_mbox_folder_get_type (void)
-{
- static GtkType camel_mbox_folder_type = 0;
-
- if (!camel_mbox_folder_type) {
- GtkTypeInfo camel_mbox_folder_info =
- {
- "CamelMboxFolder",
- sizeof (CamelMboxFolder),
- sizeof (CamelMboxFolderClass),
- (GtkClassInitFunc) camel_mbox_folder_class_init,
- (GtkObjectInitFunc) NULL,
- /* reserved_1 */ NULL,
- /* reserved_2 */ NULL,
- (GtkClassInitFunc) NULL,
- };
-
- camel_mbox_folder_type = gtk_type_unique (CAMEL_FOLDER_TYPE, &camel_mbox_folder_info);
- }
-
- return camel_mbox_folder_type;
-}
-
-
-
-
-
-
-static void
-_init_with_store (CamelFolder *folder, CamelStore *parent_store, CamelException *ex)
-{
- CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER (folder);
-
-
- CAMEL_LOG_FULL_DEBUG ("Entering CamelMboxFolder::init_with_store\n");
-
- /* call parent method */
- parent_class->init_with_store (folder, parent_store, ex);
- if (camel_exception_get_id (ex)) return;
-
- /* we assume that the parent init_with_store
- method checks for the existance of @folder */
-
- folder->can_hold_messages = TRUE;
- folder->can_hold_folders = TRUE;
- folder->has_summary_capability = TRUE;
- folder->has_uid_capability = TRUE;
- folder->summary = camel_folder_summary_new ();
-
- mbox_folder->folder_file_path = NULL;
- mbox_folder->summary_file_path = NULL;
- mbox_folder->folder_dir_path = NULL;
- mbox_folder->index_file_path = NULL;
- mbox_folder->internal_summary = NULL;
- mbox_folder->uid_array = NULL;
-
- CAMEL_LOG_FULL_DEBUG ("Leaving CamelMhFolder::init_with_store\n");
-}
-
-
-
-/* internal method used to :
- - test for the existence of a summary file
- - test the sync between the summary and the mbox file
- - load the summary or create it if necessary
-*/
-static void
-_check_get_or_maybe_generate_summary_file (CamelMboxFolder *mbox_folder, CamelException *ex)
-{
- CamelFolder *folder = CAMEL_FOLDER (mbox_folder);
- GArray *message_info_array;
- gboolean summary_file_exists;
- gboolean summary_file_is_sync;
- GArray *mbox_summary_info;
- gint mbox_file_fd;
- guint32 next_uid;
- guint32 file_size;
-
- /* test for the existence of the summary file */
- summary_file_exists = (access (mbox_folder->summary_file_path, F_OK) == 0);
-
- /* if the summary file exists, test if the
- md5 of the mbox file is still in sync
- with the one we had computed the last time
- we saved the summary file */
- if (summary_file_exists) {
-
- summary_file_is_sync =
- camel_mbox_check_summary_sync (mbox_folder->summary_file_path,
- mbox_folder->folder_file_path,
- ex);
- if (camel_exception_get_id (ex)) return;
- }
-
-
- /* in the case where the summary does not exist
- or is not in sync with the mbox file
- regenerate it */
- if ( !(summary_file_exists && summary_file_is_sync)) {
-
- /* parse the mbox folder and get some
- information about the messages */
-
- mbox_file_fd = open (mbox_folder->folder_file_path, O_RDONLY);
- message_info_array = camel_mbox_parse_file (mbox_file_fd,
- "From ",
- 0,
- &file_size,
- &next_uid,
- TRUE,
- NULL,
- 0,
- ex);
-
- close (mbox_file_fd);
- if (camel_exception_get_id (ex)) {
- return;
- }
-
-
- next_uid = camel_mbox_write_xev (mbox_folder->folder_file_path,
- message_info_array, &file_size, next_uid, ex);
-
- if (camel_exception_get_id (ex)) {
- /* ** FIXME : free the preparsed information */
- return;
- }
-
- mbox_summary_info =
- parsed_information_to_mbox_summary (message_info_array);
-
- /* **FIXME : Free the parsed information structure */
-
- /* allocate an internal summary object */
- mbox_folder->internal_summary = g_new (CamelMboxSummary, 1);
-
- /* generate the folder md5 signature */
- md5_get_digest_from_file (mbox_folder->folder_file_path, mbox_folder->internal_summary->md5_digest);
-
- /* store the number of messages as well as the summary array */
- mbox_folder->internal_summary->nb_message = mbox_summary_info->len;
- mbox_folder->internal_summary->next_uid = next_uid;
- mbox_folder->internal_summary->mbox_file_size = file_size;
- mbox_folder->internal_summary->message_info = mbox_summary_info;
-
- } else {
- /* every thing seems ok, just read the summary file from disk */
- mbox_folder->internal_summary = camel_mbox_load_summary (mbox_folder->summary_file_path, ex);
- }
-
- /* copy the internal summary information to the external
- folder summary used by the display engines */
- camel_mbox_summary_append_internal_to_external (mbox_folder->internal_summary, folder->summary, 0);
-}
-
-
-
-static void
-_open (CamelFolder *folder, CamelFolderOpenMode mode, CamelException *ex)
-{
- CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER (folder);
- //struct dirent *dir_entry;
- //struct stat stat_buf;
-
-
- if (folder->open_state == FOLDER_OPEN) {
- camel_exception_set (ex,
- CAMEL_EXCEPTION_FOLDER_INVALID_STATE,
- "folder is already open");
- return;
- }
-
-
-
- /* get (or create) uid list */
- //if (!(mbox_load_uid_list (mbox_folder) > 0))
- // mbox_generate_uid_list (mbox_folder);
-
- _check_get_or_maybe_generate_summary_file (mbox_folder, ex);
-}
-
-
-static void
-_close (CamelFolder *folder, gboolean expunge, CamelException *ex)
-{
- CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER (folder);
-
-
- /* call parent implementation */
- parent_class->close (folder, expunge, ex);
-
- /* save the folder summary on disc */
- camel_mbox_save_summary (mbox_folder->internal_summary, mbox_folder->summary_file_path, ex);
-}
-
-
-
-
-static void
-_set_name (CamelFolder *folder, const gchar *name, CamelException *ex)
-{
- CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER (folder);
- const gchar *root_dir_path;
- //gchar *full_name;
- //const gchar *parent_full_name;
- gchar separator;
-
- CAMEL_LOG_FULL_DEBUG ("Entering CamelMboxFolder::set_name\n");
-
- /* call default implementation */
- parent_class->set_name (folder, name, ex);
- if (camel_exception_get_id (ex)) return;
-
- g_free (mbox_folder->folder_file_path);
- g_free (mbox_folder->folder_dir_path);
- g_free (mbox_folder->index_file_path);
-
- separator = camel_store_get_separator (folder->parent_store, ex);
- root_dir_path = camel_mbox_store_get_toplevel_dir (CAMEL_MBOX_STORE(folder->parent_store), ex);
-
- CAMEL_LOG_FULL_DEBUG ("CamelMboxFolder::set_name full_name is %s\n", folder->full_name);
- CAMEL_LOG_FULL_DEBUG ("CamelMboxFolder::set_name root_dir_path is %s\n", root_dir_path);
- CAMEL_LOG_FULL_DEBUG ("CamelMboxFolder::separator is %c\n", separator);
-
- mbox_folder->folder_file_path = g_strdup_printf ("%s%c%s", root_dir_path, separator, folder->full_name);
- mbox_folder->summary_file_path = g_strdup_printf ("%s%c%s-ev-summary", root_dir_path, separator, folder->full_name);
- mbox_folder->folder_dir_path = g_strdup_printf ("%s%c%s.sdb", root_dir_path, separator, folder->full_name);
- mbox_folder->index_file_path = g_strdup_printf ("%s%c%s.ibex", root_dir_path, separator, folder->full_name);
-
- CAMEL_LOG_FULL_DEBUG ("CamelMboxFolder::set_name mbox_folder->folder_file_path is %s\n",
- mbox_folder->folder_file_path);
- CAMEL_LOG_FULL_DEBUG ("CamelMboxFolder::set_name mbox_folder->folder_dir_path is %s\n",
- mbox_folder->folder_dir_path);
- CAMEL_LOG_FULL_DEBUG ("Leaving CamelMboxFolder::set_name\n");
-}
-
-
-
-
-
-
-static gboolean
-_exists (CamelFolder *folder, CamelException *ex)
-{
- CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER(folder);
- struct stat stat_buf;
- gint stat_error;
- gboolean exists;
-
- CAMEL_LOG_FULL_DEBUG ("Entering CamelMboxFolder::exists\n");
-
- /* check if the folder object exists */
- if (!folder) {
- camel_exception_set (ex,
- CAMEL_EXCEPTION_FOLDER_NULL,
- "folder object is NULL");
- return FALSE;
- }
-
- /* check if the mbox file path is determined */
- if (!mbox_folder->folder_file_path) {
- camel_exception_set (ex,
- CAMEL_EXCEPTION_FOLDER_INVALID,
- "undetermined folder file path. Maybe use set_name ?");
- return FALSE;
- }
-
- /* check if the mbox dir path is determined */
- if (!mbox_folder->folder_dir_path) {
- camel_exception_set (ex,
- CAMEL_EXCEPTION_FOLDER_INVALID,
- "undetermined folder directory path. Maybe use set_name ?");
- return FALSE;
- }
-
-
- /* we should not check for that here */
-#if 0
- /* check if the mbox directory exists */
- access_result = access (mbox_folder->folder_dir_path, F_OK);
- if (access_result < 0) {
- CAMEL_LOG_FULL_DEBUG ("CamelMboxFolder::exists errot when executing access on %s\n",
- mbox_folder->folder_dir_path);
- CAMEL_LOG_FULL_DEBUG (" Full error text is : %s\n", strerror(errno));
- camel_exception_set (ex,
- CAMEL_EXCEPTION_SYSTEM,
- strerror(errno));
- return FALSE;
- }
- stat_error = stat (mbox_folder->folder_dir_path, &stat_buf);
- if (stat_error == -1) {
- CAMEL_LOG_FULL_DEBUG ("CamelMboxFolder::exists when executing stat on %s, stat_error = %d\n",
- mbox_folder->folder_dir_path, stat_error);
- CAMEL_LOG_FULL_DEBUG (" Full error text is : %s\n", strerror(errno));
- camel_exception_set (ex,
- CAMEL_EXCEPTION_SYSTEM,
- strerror(errno));
- return FALSE;
- }
- exists = S_ISDIR (stat_buf.st_mode);
- if (!exists) return FALSE;
-#endif
-
-
- /* check if the mbox file exists */
- stat_error = stat (mbox_folder->folder_file_path, &stat_buf);
- if (stat_error == -1)
- return FALSE;
-
- exists = S_ISREG (stat_buf.st_mode);
- /* we should check the rights here */
-
- CAMEL_LOG_FULL_DEBUG ("Leaving CamelMboxFolder::exists\n");
- return exists;
-}
-
-
-
-
-
-
-
-
-static gboolean
-_create (CamelFolder *folder, CamelException *ex)
-{
- CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER(folder);
- const gchar *folder_file_path, *folder_dir_path;
- mode_t dir_mode = S_IRWXU;
- gint mkdir_error;
- gboolean folder_already_exists;
- int creat_fd;
- mode_t old_umask;
-
- /* check if the folder object exists */
- if (!folder) {
- camel_exception_set (ex,
- CAMEL_EXCEPTION_FOLDER_NULL,
- "folder object is NULL");
- return FALSE;
- }
-
-
- /* call default implementation */
- parent_class->create (folder, ex);
-
- /* get the paths of what we need to create */
- folder_file_path = mbox_folder->folder_file_path;
- folder_dir_path = mbox_folder->folder_file_path;
-
- if (!(folder_file_path || folder_dir_path)) {
- camel_exception_set (ex,
- CAMEL_EXCEPTION_FOLDER_INVALID,
- "invalid folder path. Use set_name ?");
- return FALSE;
- }
-
-
- /* if the folder already exists, simply return */
- folder_already_exists = camel_folder_exists (folder,ex);
- if (camel_exception_get_id (ex)) return FALSE;
-
- if (folder_already_exists) return TRUE;
-
-
- /* create the directory for the subfolders */
- mkdir_error = mkdir (folder_dir_path, dir_mode);
- if (mkdir_error == -1) goto io_error;
-
-
- /* create the mbox file */
- /* it must be rw for the user and none for the others */
- old_umask = umask (0700);
- creat_fd = open (folder_file_path,
- O_WRONLY | O_CREAT | O_APPEND,
- S_IRUSR | S_IWUSR);
- umask (old_umask);
- if (creat_fd == -1) goto io_error;
- close (creat_fd);
-
- /* create the summary object */
- mbox_folder->internal_summary = g_new (CamelMboxSummary, 1);
- mbox_folder->internal_summary->nb_message = 0;
- mbox_folder->internal_summary->next_uid = 1;
- mbox_folder->internal_summary->mbox_file_size = 0;
- mbox_folder->internal_summary->message_info = g_array_new (FALSE, FALSE, sizeof (CamelMboxSummaryInformation));
-
- return TRUE;
-
- /* exception handling for io errors */
- io_error :
-
- CAMEL_LOG_WARNING ("CamelMboxFolder::create, error when creating %s and %s\n",
- folder_dir_path, folder_file_path);
- CAMEL_LOG_FULL_DEBUG ( " Full error text is : %s\n", strerror(errno));
-
- if (errno == EACCES) {
- camel_exception_set (ex,
- CAMEL_EXCEPTION_FOLDER_INSUFFICIENT_PERMISSION,
- "You don't have the permission to create the mbox file.");
- return FALSE;
- } else {
- camel_exception_set (ex,
- CAMEL_EXCEPTION_SYSTEM,
- "Unable to create the mbox file.");
- return FALSE;
- }
-}
-
-
-
-
-
-
-
-
-static gboolean
-_delete (CamelFolder *folder, gboolean recurse, CamelException *ex)
-{
- CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER(folder);
- const gchar *folder_file_path, *folder_dir_path;
- gint rmdir_error = 0;
- gint unlink_error = 0;
- gboolean folder_already_exists;
-
- /* check if the folder object exists */
- if (!folder) {
- camel_exception_set (ex,
- CAMEL_EXCEPTION_FOLDER_NULL,
- "folder object is NULL");
- return FALSE;
- }
-
-
- /* in the case where the folder does not exist,
- return immediatly */
- folder_already_exists = camel_folder_exists (folder, ex);
- if (camel_exception_get_id (ex)) return FALSE;
-
- if (!folder_already_exists) return TRUE;
-
-
- /* call default implementation.
- It should delete the messages in the folder
- and recurse the operation to subfolders */
- parent_class->delete (folder, recurse, ex);
-
-
- /* get the paths of what we need to be deleted */
- folder_file_path = mbox_folder->folder_file_path;
- folder_dir_path = mbox_folder->folder_file_path;
-
- if (!(folder_file_path || folder_dir_path)) {
- camel_exception_set (ex,
- CAMEL_EXCEPTION_FOLDER_INVALID,
- "invalid folder path. Use set_name ?");
- return FALSE;
- }
-
-
- /* physically delete the directory */
- CAMEL_LOG_FULL_DEBUG ("CamelMboxFolder::delete removing directory %s\n", folder_dir_path);
- rmdir_error = rmdir (folder_dir_path);
- if (rmdir_error == -1)
- switch errno {
- case EACCES :
- camel_exception_set (ex,
- CAMEL_EXCEPTION_FOLDER_INSUFFICIENT_PERMISSION,
- "Not enough permission to delete the mbox folder");
- return FALSE;
- break;
-
- case ENOTEMPTY :
- camel_exception_set (ex,
- CAMEL_EXCEPTION_FOLDER_NON_EMPTY,
- "mbox folder not empty. Cannot delete it. Maybe use recurse flag ?");
- return FALSE;
- break;
- default :
- camel_exception_set (ex,
- CAMEL_EXCEPTION_SYSTEM,
- "Unable to delete the mbox folder.");
- return FALSE;
- }
-
- /* physically delete the file */
- unlink_error = unlink (folder_dir_path);
- if (unlink_error == -1)
- switch errno {
- case EACCES :
- case EPERM :
- case EROFS :
- camel_exception_set (ex,
- CAMEL_EXCEPTION_FOLDER_INSUFFICIENT_PERMISSION,
- "Not enough permission to delete the mbox file");
- return FALSE;
- break;
-
- case EFAULT :
- case ENOENT :
- case ENOTDIR :
- case EISDIR :
- camel_exception_set (ex,
- CAMEL_EXCEPTION_FOLDER_INVALID_PATH,
- "Invalid mbox file");
- return FALSE;
- break;
-
- default :
- camel_exception_set (ex,
- CAMEL_EXCEPTION_SYSTEM,
- "Unable to delete the mbox folder.");
- return FALSE;
- }
-
-
- return TRUE;
-}
-
-
-
-
-gboolean
-_delete_messages (CamelFolder *folder, CamelException *ex)
-{
-
- CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER(folder);
- const gchar *folder_file_path;
- gboolean folder_already_exists;
- int creat_fd;
- mode_t old_umask;
-
-
- /* check if the folder object exists */
- if (!folder) {
- camel_exception_set (ex,
- CAMEL_EXCEPTION_FOLDER_NULL,
- "folder object is NULL");
- return FALSE;
- }
-
- /* in the case where the folder does not exist,
- return immediatly */
- folder_already_exists = camel_folder_exists (folder, ex);
- if (camel_exception_get_id (ex)) return FALSE;
-
- if (!folder_already_exists) return TRUE;
-
-
-
- /* get the paths of the mbox file we need to delete */
- folder_file_path = mbox_folder->folder_file_path;
-
- if (!folder_file_path) {
- camel_exception_set (ex,
- CAMEL_EXCEPTION_FOLDER_INVALID,
- "invalid folder path. Use set_name ?");
- return FALSE;
- }
-
-
- /* create the mbox file */
- /* it must be rw for the user and none for the others */
- old_umask = umask (0700);
- creat_fd = open (folder_file_path,
- O_WRONLY | O_TRUNC,
- S_IRUSR | S_IWUSR);
- umask (old_umask);
- if (creat_fd == -1) goto io_error;
- close (creat_fd);
-
- return TRUE;
-
- /* exception handling for io errors */
- io_error :
-
- CAMEL_LOG_WARNING ("CamelMboxFolder::create, error when deleting files %s\n",
- folder_file_path);
- CAMEL_LOG_FULL_DEBUG ( " Full error text is : %s\n", strerror(errno));
-
- if (errno == EACCES) {
- camel_exception_set (ex,
- CAMEL_EXCEPTION_FOLDER_INSUFFICIENT_PERMISSION,
- "You don't have the permission to write in the mbox file.");
- return FALSE;
- } else {
- camel_exception_set (ex,
- CAMEL_EXCEPTION_SYSTEM,
- "Unable to write in the mbox file.");
- return FALSE;
- }
-
-
-}
-
-
-
-
-
-
-
-
-
-static GList *
-_list_subfolders (CamelFolder *folder, CamelException *ex)
-{
- GList *subfolder_name_list = NULL;
-
- CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER(folder);
- const gchar *folder_dir_path;
- gboolean folder_exists;
-
- struct stat stat_buf;
- gint stat_error = 0;
- //GList *file_list;
- gchar *entry_name;
- gchar *full_entry_name;
- gchar *real_folder_name;
- struct dirent *dir_entry;
- DIR *dir_handle;
- gboolean folder_suffix_found;
-
- //gchar *io_error_text;
-
-
-
- /* check if the folder object exists */
- if (!folder) {
- camel_exception_set (ex,
- CAMEL_EXCEPTION_FOLDER_NULL,
- "folder object is NULL");
- return FALSE;
- }
-
-
- /* in the case the folder does not exist,
- raise an exception */
- folder_exists = camel_folder_exists (folder, ex);
- if (camel_exception_get_id (ex)) return FALSE;
-
- if (!folder_exists) {
- camel_exception_set (ex,
- CAMEL_EXCEPTION_FOLDER_INVALID,
- "Inexistant folder.");
- return FALSE;
- }
-
-
- /* get the mbox subfolders directories */
- folder_dir_path = mbox_folder->folder_file_path;
- if (!folder_dir_path) {
- camel_exception_set (ex,
- CAMEL_EXCEPTION_FOLDER_INVALID,
- "Invalid folder path. Use set_name ?");
- return FALSE;
- }
-
-
- dir_handle = opendir (folder_dir_path);
-
- /* read the first entry in the directory */
- dir_entry = readdir (dir_handle);
- while ((stat_error != -1) && (dir_entry != NULL)) {
-
- /* get the name of the next entry in the dir */
- entry_name = dir_entry->d_name;
- full_entry_name = g_strdup_printf ("%s/%s", folder_dir_path, entry_name);
- stat_error = stat (full_entry_name, &stat_buf);
- g_free (full_entry_name);
-
- /* is it a directory ? */
- if ((stat_error != -1) && S_ISDIR (stat_buf.st_mode)) {
- /* yes, add it to the list */
- if (entry_name[0] != '.') {
- CAMEL_LOG_FULL_DEBUG ("CamelMboxFolder::list_subfolders adding "
- "%s\n", entry_name);
-
- /* if the folder is a netscape folder, remove the
- ".sdb" from the name */
- real_folder_name = string_prefix (entry_name, ".sdb", &folder_suffix_found);
- /* stick here the tests for other folder suffixes if any */
-
- if (!folder_suffix_found) real_folder_name = g_strdup (entry_name);
-
- /* add the folder name to the list */
- subfolder_name_list = g_list_append (subfolder_name_list,
- real_folder_name);
- }
- }
- /* read next entry */
- dir_entry = readdir (dir_handle);
- }
-
- closedir (dir_handle);
-
- return subfolder_name_list;
-
-
-
- /* io exception handling */
- io_error :
-
- switch errno {
- case EACCES :
-
- camel_exception_setv (ex,
- CAMEL_EXCEPTION_FOLDER_INSUFFICIENT_PERMISSION,
- "Unable to list the directory. Full Error text is : %s ",
- strerror (errno));
- break;
-
- case ENOENT :
- case ENOTDIR :
- camel_exception_setv (ex,
- CAMEL_EXCEPTION_FOLDER_INVALID_PATH,
- "Invalid mbox folder path. Full Error text is : %s ",
- strerror (errno));
- break;
-
- default :
- camel_exception_set (ex,
- CAMEL_EXCEPTION_SYSTEM,
- "Unable to delete the mbox folder.");
-
- }
-
- g_list_free (subfolder_name_list);
- return NULL;
-}
-
-
-
-
-static gint
-_get_message_count (CamelFolder *folder, CamelException *ex)
-{
-
- CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER(folder);
- gint message_count;
-
- g_assert (folder);
- g_assert (mbox_folder->internal_summary);
-
- message_count = mbox_folder->internal_summary->nb_message;
-
- CAMEL_LOG_FULL_DEBUG ("CamelMboxFolder::get_message_count found %d messages\n", message_count);
- return message_count;
-}
-
-
-static gint
-_append_message (CamelFolder *folder, CamelMimeMessage *message, CamelException *ex)
-{
- CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER(folder);
- //guint new_msg_number;
- CamelStream *output_stream;
- guint32 tmp_file_size;
- guint32 next_uid;
- gint tmp_file_fd;
- GArray *message_info_array;
- GArray *mbox_summary_info;
- gchar *tmp_message_filename;
- gint fd1, fd2;
-
-
- CAMEL_LOG_FULL_DEBUG ("Entering CamelMboxFolder::append_message\n");
-
- tmp_message_filename = g_strdup_printf ("%s.tmp", mbox_folder->folder_file_path);
- /* write the message itself */
- output_stream = camel_stream_fs_new_with_name (tmp_message_filename, CAMEL_STREAM_FS_WRITE);
- if (output_stream != NULL) {
- camel_stream_write_string (output_stream, "From - \n");
- camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (message), output_stream);
- }
- camel_stream_close (output_stream);
-
- /* at this point we have saved the message to a
- temporary file, now, we have to add the x-evolution
- field and also update the main summary summary */
-
- /*
- First : parse the mbox file, but only from the
- position where the message has been added,
- wich happens to be the last postion in the
- mbox file before we added the message.
- This position is still stored in the summary
- for the moment
- */
- next_uid = mbox_folder->internal_summary->next_uid;
- tmp_file_fd = open (tmp_message_filename, O_RDONLY);
- message_info_array = camel_mbox_parse_file (tmp_file_fd,
- "From - ",
- 0,
- &tmp_file_size,
- &next_uid,
- TRUE,
- NULL,
- 0,
- ex);
-
- close (tmp_file_fd);
-
- /* get the value of the last available UID
- as saved in the summary file */
- next_uid = mbox_folder->internal_summary->next_uid;
-
- /*
- OK, this is not very efficient, we should not use the same
- method as for parsing an entire mail file,
- but I have no time to write a simpler parser
- */
- next_uid = camel_mbox_write_xev (tmp_message_filename,
- message_info_array, &tmp_file_size, next_uid, ex);
-
- if (camel_exception_get_id (ex)) {
- /* ** FIXME : free the preparsed information */
- return -1;
- }
-
- mbox_summary_info =
- parsed_information_to_mbox_summary (message_info_array);
-
-
-
-
- /* store the number of messages as well as the summary array */
- mbox_folder->internal_summary->nb_message += 1;
- mbox_folder->internal_summary->next_uid = next_uid;
-
- ((CamelMboxSummaryInformation *)(mbox_summary_info->data))->position += mbox_folder->internal_summary->mbox_file_size;
- mbox_folder->internal_summary->mbox_file_size += tmp_file_size;
-
- camel_mbox_summary_append_entries (mbox_folder->internal_summary, mbox_summary_info);
-
- /* append the new entry of the internal summary to
- the external summary */
- camel_mbox_summary_append_internal_to_external (mbox_folder->internal_summary,
- folder->summary,
- mbox_folder->internal_summary->nb_message-1);
-
- g_array_free (mbox_summary_info, TRUE);
-
-
- /* append the temporary file message to the mbox file */
- fd1 = open (tmp_message_filename, O_RDONLY);
- fd2 = open (mbox_folder->folder_file_path,
- O_WRONLY | O_CREAT | O_APPEND,
- S_IRUSR | S_IWUSR);
-
- if (fd2 == -1) {
- camel_exception_setv (ex,
- CAMEL_EXCEPTION_FOLDER_INSUFFICIENT_PERMISSION,
- "could not open the mbox folder file for appending the message\n"
- "\t%s\n"
- "Full error is : %s\n",
- mbox_folder->folder_file_path,
- strerror (errno));
- return -1;
- }
-
- camel_mbox_copy_file_chunk (fd1,
- fd2,
- tmp_file_size,
- ex);
- close (fd1);
- close (fd2);
-
- /* remove the temporary file */
- unlink (tmp_message_filename);
-
- /* generate the folder md5 signature */
- md5_get_digest_from_file (mbox_folder->folder_file_path, mbox_folder->internal_summary->md5_digest);
-
-
- g_free (tmp_message_filename);
- CAMEL_LOG_FULL_DEBUG ("Leaving CamelMboxFolder::append_message\n");
-
- return -1;
-}
-
-
-
-
-static GList *
-_get_uid_list (CamelFolder *folder, CamelException *ex)
-{
- CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER(folder);
- GArray *message_info_array;
- CamelMboxSummaryInformation *message_info;
- GList *uid_list = NULL;
- int i;
-
- CAMEL_LOG_FULL_DEBUG ("Entering CamelMboxFolder::get_uid_list\n");
-
- message_info_array = mbox_folder->internal_summary->message_info;
-
- for (i=0; i<message_info_array->len; i++) {
-
- message_info = (CamelMboxSummaryInformation *)(message_info_array->data) + i;
- uid_list = g_list_prepend (uid_list, g_strdup_printf ("%u", message_info->uid));
- }
-
- CAMEL_LOG_FULL_DEBUG ("Leaving CamelMboxFolder::get_uid_list\n");
-
- return uid_list;
-}
-
-
-
-
-
-
-
-
-static CamelMimeMessage *
-_get_message_by_uid (CamelFolder *folder, const gchar *uid, CamelException *ex)
-{
-
- CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER(folder);
- GArray *message_info_array;
- CamelMboxSummaryInformation *message_info;
- guint32 searched_uid;
- int i;
- gboolean uid_found;
- CamelStreamFs *message_stream;
- CamelMimeMessage *message = NULL;
- CamelStore *parent_store;
-
- CAMEL_LOG_FULL_DEBUG ("Entering CamelMboxFolder::get_uid_list\n");
-
- searched_uid = strtoul(uid, (char **)NULL, 10);
-
- message_info_array = mbox_folder->internal_summary->message_info;
- i=0;
- uid_found = FALSE;
-
- /* first, look for the message that has the searched uid */
- while ((i<message_info_array->len) && (!uid_found)) {
- message_info = (CamelMboxSummaryInformation *)(message_info_array->data) + i;
- uid_found = (message_info->uid == searched_uid);
- i++;
- }
-
- /* if the uid was not found, raise an exception and return */
- if (!uid_found) {
- camel_exception_setv (ex,
- CAMEL_EXCEPTION_FOLDER_INVALID_UID,
- "uid %s not found in the folder",
- uid);
- CAMEL_LOG_FULL_DEBUG ("Leaving CamelMboxFolder::get_uid_list\n");
- return NULL;
- }
-
- /* at this point, the message_info structure
- contains the informations concerning the
- message that was searched for */
-
- /* create a stream bound to the message */
- message_stream = camel_stream_fs_new_with_name_and_bounds (mbox_folder->folder_file_path,
- CAMEL_STREAM_FS_READ,
- message_info->position,
- message_info->position + message_info->size);
-
-
- /* get the parent store */
- parent_store = camel_folder_get_parent_store (folder, ex);
- if (camel_exception_get_id (ex)) {
- gtk_object_unref (GTK_OBJECT (message_stream));
- return NULL;
- }
-
-
- message = camel_mime_message_new_with_session (camel_store_get_session (parent_store, ex));
- camel_data_wrapper_construct_from_stream (CAMEL_DATA_WRAPPER (message), CAMEL_STREAM (message_stream));
-
-
-
-
- CAMEL_LOG_FULL_DEBUG ("Leaving CamelMboxFolder::get_uid_list\n");
- return message;
-}
-
-static CamelFolderSummary *
-search_by_expression(CamelFolder *folder, const char *expression, CamelException *ex)
-{
- return camel_mbox_folder_search_by_expression(folder, expression);
-}
diff --git a/camel/providers/mbox/camel-mbox-folder.h b/camel/providers/mbox/camel-mbox-folder.h
deleted file mode 100644
index 76288d5c3c..0000000000
--- a/camel/providers/mbox/camel-mbox-folder.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* camel-mbox-folder.h : Abstract class for an email folder */
-
-/*
- *
- * Author : Bertrand Guiheneuf <bertrand@helixcode.com>
- *
- * Copyright (C) 1999 Helix Code .
- *
- * 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_MBOX_FOLDER_H
-#define CAMEL_MBOX_FOLDER_H 1
-
-
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* __cplusplus }*/
-
-#include <gtk/gtk.h>
-#include "camel-folder.h"
-#include "camel-mbox-summary.h"
-
-/* #include "camel-store.h" */
-
-#define CAMEL_MBOX_FOLDER_TYPE (camel_mbox_folder_get_type ())
-#define CAMEL_MBOX_FOLDER(obj) (GTK_CHECK_CAST((obj), CAMEL_MBOX_FOLDER_TYPE, CamelMboxFolder))
-#define CAMEL_MBOX_FOLDER_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_MBOX_FOLDER_TYPE, CamelMboxFolderClass))
-#define IS_CAMEL_MBOX_FOLDER(o) (GTK_CHECK_TYPE((o), CAMEL_MBOX_FOLDER_TYPE))
-
-
-typedef struct {
- CamelFolder parent_object;
-
- CamelFolderSummary *external_summary;
- /* the external summary is intended to be read by callers */
-
- gchar *folder_file_path; /* contains the messages */
- gchar *summary_file_path; /* contains the messages summary */
- gchar *folder_dir_path; /* contains the subfolders */
- gchar *index_file_path; /* index of body contents */
-
- CamelMboxSummary *internal_summary; /* internal summary object */
- GList *uid_array;
-
-} CamelMboxFolder;
-
-
-
-typedef struct {
- CamelFolderClass parent_class;
-
- /* Virtual methods */
-
-} CamelMboxFolderClass;
-
-
-/* public methods */
-
-/* Standard Gtk function */
-GtkType camel_mbox_folder_get_type (void);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* CAMEL_MBOX_FOLDER_H */
diff --git a/camel/providers/mbox/camel-mbox-parser.c b/camel/providers/mbox/camel-mbox-parser.c
deleted file mode 100644
index d730c07aa6..0000000000
--- a/camel/providers/mbox/camel-mbox-parser.c
+++ /dev/null
@@ -1,901 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* camel-mbox-parser.c : mbox folder parser */
-
-/*
- *
- * Author : Bertrand Guiheneuf <bertrand@helixcode.com>
- *
- * Copyright (C) 1999 Helix Code .
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-
-
-#include <config.h>
-#include "camel-mbox-parser.h"
-#include "camel-mbox-utils.h"
-#include "camel-log.h"
-#include "camel-exception.h"
-#include <sys/types.h>
-#include <unistd.h>
-#include <errno.h>
-#include <string.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-
-
-
-#define MBOX_PARSER_BUF_SIZE 10000
-
-#define MBOX_PARSER_FROM_KW "from:"
-#define MBOX_PARSER_FROM_KW_SZ 5
-
-#define MBOX_PARSER_DATE_KW "date:"
-#define MBOX_PARSER_DATE_KW_SZ 5
-
-#define MBOX_PARSER_SUBJECT_KW "subject:"
-#define MBOX_PARSER_SUBJECT_KW_SZ 8
-
-#define MBOX_PARSER_TO_KW "to:"
-#define MBOX_PARSER_TO_KW_SZ 3
-
-#define MBOX_PARSER_X_EVOLUTION_KW "x-evolution:"
-#define MBOX_PARSER_X_EVOLUTION_KW_SZ 12
-
-/* the maximum lentgh of all the previous keywords */
-#define MBOX_PARSER_MAX_KW_SIZE 12
-
-
-#define MBOX_PARSER_SUMMARY_SIZE 150
-
-
-
-
-
-
-typedef struct {
-
- int fd; /* file descriptor of the mbox file */
- glong real_position; /* real position in the file */
-
-
- gchar *message_delimiter; /* message delimiter string */
- guint message_delimiter_length;
-
- guint message_summary_size; /* how many characters from the begining of the
- mail to put into the message summary */
-
- GArray *preparsed_messages; /* array of MessagePreParsingInfo */
- CamelMboxParserMessageInfo current_message_info; /* used to store curent info */
- gboolean is_pending_message; /* is there some message information pending ? */
-
- /* buffer info */
- gchar *buffer; /* temporary buffer */
- guint left_chunk_size; /* size of the left chunk in the temp buffer */
- guint last_position; /* last position that can be compared to a keyword */
- guint current_position; /* current position in the temp buffer */
-
- /* other */
- GString *tmp_string; /* temporary string to fill the headers in */
-
-
-
-} CamelMboxPreParser;
-
-
-/* clear a preparsing info structure */
-static void
-clear_message_info (CamelMboxParserMessageInfo *preparsing_info)
-{
-
- CAMEL_LOG_FULL_DEBUG ("Entering CamelMboxParser::clear_message_info\n");
-
- preparsing_info->message_position = 0;
- preparsing_info->size = 0;
- preparsing_info->from = NULL;
- preparsing_info->date = NULL;
- preparsing_info->subject = NULL;
- preparsing_info->priority = NULL;
- preparsing_info->references = NULL;
- preparsing_info->body_summary = NULL;
- preparsing_info->end_of_headers_offset = 0;
-
- preparsing_info->x_evolution_offset = 0;
- preparsing_info->status = 0;
- preparsing_info->uid = 0;
-
- CAMEL_LOG_FULL_DEBUG ("Leaving CamelMboxParser::clear_message_info\n");
-}
-
-
-
-/**
- * new_parser: create a new parser object
- * @fd: file descriptor opened on the mbox file
- * @message_delimiter: the string that announce the start of a new message.
- *
- * Create a new parser object. This object is the place where are
- * stored all the information concerning the parsing process.
- *
- * Return value: The newly created parser object.
- **/
-static CamelMboxPreParser *
-new_parser (int fd,
- const gchar *message_delimiter)
-{
- CamelMboxPreParser *parser;
-
- CAMEL_LOG_FULL_DEBUG ("Entering CamelMboxParser::ew_parser\n");
-
- parser = g_new0 (CamelMboxPreParser, 1);
-
- parser->fd = fd;
- parser->buffer = g_new (gchar, MBOX_PARSER_BUF_SIZE);
- parser->current_position = 0;
- parser->message_delimiter = g_strdup (message_delimiter);
- parser->message_delimiter_length = strlen (message_delimiter);
- parser->real_position = 0;
- parser->preparsed_messages = g_array_new (FALSE, FALSE, sizeof (CamelMboxParserMessageInfo));
- parser->message_summary_size = MBOX_PARSER_SUMMARY_SIZE;
-
- parser->left_chunk_size = MAX (parser->message_delimiter_length, MBOX_PARSER_MAX_KW_SIZE);
-
- parser->tmp_string = g_string_sized_new (1000);
-
- CAMEL_LOG_FULL_DEBUG ("Leaving CamelMboxParser::ew_parser\n");
-
- return parser;
-}
-
-
-
-/**
- * parser_free: free the parser object
- * @parser: the parser objet to free.
- *
- * it is important to notice that all structures allocated
- * in new_parser () are freed ** EXCEPT ** the message
- * information array, i.e. the preparsed_messages
- * field.
- **/
-static void
-parser_free (CamelMboxPreParser *parser)
-{
- CAMEL_LOG_FULL_DEBUG ("Entering CamelMboxParser::parser_free\n");
-
- g_free (parser->buffer);
- g_free (parser->message_delimiter);
- g_string_free (parser->tmp_string, TRUE);
- g_free (parser);
-
- CAMEL_LOG_FULL_DEBUG ("Leaving CamelMboxParser::parser_free\n");
-}
-
-
-
-
-/* ** handle exceptions here */
-/**
- * initialize_buffer: read the first chunk of data in the buffer
- * @parser: parser object to fill
- * @first_position: position to start the read at
- *
- * read the first chunk of data from the mbox file.
- *
- **/
-static void
-initialize_buffer (CamelMboxPreParser *parser,
- glong first_position)
-{
- gint seek_res;
- gint buf_nb_read;
-
- CAMEL_LOG_FULL_DEBUG ("Entering CamelMboxParser::intialize_buffer\n");
-
- g_assert (parser);
-
- /* set the search start position */
- seek_res = lseek (parser->fd, first_position, SEEK_SET);
- //if (seek_res == (off_t)-1) goto io_error;
-
-
- /* the first part of the buffer is filled with newlines,
- but the next time a chunk of buffer is read, it will
- be filled with the last bytes of the previous chunk.
- This allows simple g_strcasecmp to test for the presence of
- the keyword */
- memset (parser->buffer, '\n', parser->left_chunk_size);
- do {
- buf_nb_read = read (parser->fd, parser->buffer + parser->left_chunk_size,
- MBOX_PARSER_BUF_SIZE - parser->left_chunk_size);
- } while ((buf_nb_read == -1) && (errno == EINTR));
- /* ** check for an error here */
-
- if (buf_nb_read < MBOX_PARSER_BUF_SIZE - parser->left_chunk_size) {
- /* fill the end of the buffer with 0\ */
- memset (parser->buffer + buf_nb_read + parser->left_chunk_size, '\0',
- MIN (parser->left_chunk_size, MBOX_PARSER_BUF_SIZE - buf_nb_read - parser->left_chunk_size));
- };
-
- parser->last_position = MIN (buf_nb_read + parser->left_chunk_size + 1,
- MBOX_PARSER_BUF_SIZE - parser->left_chunk_size);
- parser->current_position = parser->left_chunk_size;
-
- CAMEL_LOG_FULL_DEBUG ("Leaving CamelMboxParser::intialize_buffer\n");
-
-}
-
-
-
-
-/**
- * read_next_buffer_chunk: read the next chunk of data in the mbox file
- * @parser: parser object
- *
- * read the next chunk of data in the mbox file.
- * Routine copies the last part of the buffer at
- * the begining are concatenate the read data to
- * it. This allows strcmp of keywords in the buffer,
- * until the last postion. That means you can
- * do a strcmp (buffer, keyword) for any of the
- * keyword defined at the begining of this file.
- *
- **/
-static void
-read_next_buffer_chunk (CamelMboxPreParser *parser)
-{
- gint buf_nb_read;
-
- g_assert (parser);
-
- CAMEL_LOG_FULL_DEBUG ("Leaving CamelMboxParser::intialize_buffer\n");
-
- /* read the next chunk of data in the folder file : */
- /* - first, copy the last bytes from the previous
- chunk at the begining of the new one. */
- memcpy (parser->buffer,
- parser->buffer + MBOX_PARSER_BUF_SIZE - parser->left_chunk_size,
- parser->left_chunk_size);
-
- /* - then read the next chunk on disk */
- do {
- buf_nb_read = read (parser->fd,
- parser->buffer + parser->left_chunk_size,
- MBOX_PARSER_BUF_SIZE - parser->left_chunk_size);
- } while ((buf_nb_read == -1) && (errno == EINTR));
- /* ** check for an error here */
-
- if (buf_nb_read < MBOX_PARSER_BUF_SIZE - parser->left_chunk_size) {
- /* fill the end of the buffer with 0\ */
- memset (parser->buffer + buf_nb_read + parser->left_chunk_size, '\0',
- MIN (parser->left_chunk_size, MBOX_PARSER_BUF_SIZE - buf_nb_read - parser->left_chunk_size));
- };
-
- parser->last_position = MIN (buf_nb_read + parser->left_chunk_size + 1,
- MBOX_PARSER_BUF_SIZE - parser->left_chunk_size);
-
- parser->current_position = 0;
- CAMEL_LOG_FULL_DEBUG ("Leaving CamelMboxParser::intialize_buffer\n");
-
-}
-
-
-
-/**
- * goto_next_char: go one postion forward in the buffer
- * @parser: parser object
- *
- * goto one position forward in the buffer. If necessary,
- * read the next chunk of data in the file.
- *
- **/
-static void
-goto_next_char (CamelMboxPreParser *parser)
-{
-
- if (parser->current_position < parser->last_position - 1)
- parser->current_position++;
- else
- read_next_buffer_chunk (parser);
-
- parser->real_position++;
-
-}
-
-
-
-
-
-
-
-/**
- * advance_n_chars: go n positions forward in the buffer.
- * @parser: parser object
- * @n: number of characters to advance.
- *
- **/
-static void
-advance_n_chars (CamelMboxPreParser *parser, guint n)
-{
-
- gint position_to_the_end;
-
- CAMEL_LOG_FULL_DEBUG ("Entering CamelMboxParser::advnce_n_chars\n");
-
- position_to_the_end = parser->last_position - parser->current_position;
-
- if (n < position_to_the_end)
- parser->current_position += n;
- else {
- read_next_buffer_chunk (parser);
- parser->current_position = n - position_to_the_end;
- }
-
- parser->real_position += n;
-
- CAMEL_LOG_FULL_DEBUG ("Leaving CamelMboxParser::advance_n_chars\n");
-}
-
-
-
-
-
-
-/* called when the buffer has detected the begining of
- a new message. This routine is supposed to simply
- store the previous message information and
- clean the temporary structure used to store
- the informations */
-
-
-/**
- * new_message_detected: routine to call when a new message has been detected
- * @parser: parser object.
- *
- * this routine must be called when the keyword determining the
- * begining of a new message has been detected. It pushes the
- * information fetched for the last message into the message information
- * array. Also, it gets the parser to the end of the line.
- **/
-static void
-new_message_detected (CamelMboxPreParser *parser)
-{
-
- gchar c;
-
- CAMEL_LOG_FULL_DEBUG ("Entering CamelMboxParser::new_message_detected\n");
-
- /* if we were filling a message information
- save it in the message information array */
-
- if (parser->is_pending_message) {
- parser->current_message_info.size =
- parser->real_position - parser->current_message_info.message_position;
- g_array_append_vals (parser->preparsed_messages, (gchar *)parser +
- G_STRUCT_OFFSET (CamelMboxPreParser, current_message_info), 1);
- }
-
- clear_message_info ( &(parser->current_message_info));
-
- /* go to the end of the line */
- do {
-
- c = parser->buffer[parser->current_position];
- goto_next_char (parser);
-
- } while (c != '\n');
-
- /* save message position in the message information structure */
- (parser->current_message_info).message_position = parser->real_position;
-
- parser->is_pending_message = TRUE;
-
- CAMEL_LOG_FULL_DEBUG ("Leaving CamelMboxParser::new_message_detected\n");
-}
-
-
-
-
-
-
-
-/**
- * read_header: read the header content contained after the current position.
- * @parser: the parser object.
- * @header_content: a pointer on a (char *) variable to feed with the obtained header string.
- *
- * This routine must be called when the parser has detected a header
- * and it wants the header content to be stored. The parser current position
- * must EXACTLY be located at the begining of the header content line.
- * For example, if the file contains the line :
- * from:Bertrand Guiheneuf <bertrand@helixcode.com>
- *
- * When this routine is called, the parser must be located
- * on the "B" of "Bertrand".
- *
- * When this routine returns, the parser is located just
- * after the "\n" at the end of the header content.
- *
- **/
-static void
-read_header (CamelMboxPreParser *parser, gchar **header_content)
-{
- gboolean space = FALSE;
- gboolean newline = FALSE;
- gboolean header_end = FALSE;
- gchar *buffer;
- gchar c;
-
-
- CAMEL_LOG_FULL_DEBUG ("Entering CamelMboxParser::read_header\n");
-
- g_assert (parser);
-
- /* reset the header buffer string */
- parser->tmp_string = g_string_truncate (parser->tmp_string, 0);
-
- buffer = parser->buffer;
-
- /* read the current character */
- c = buffer[parser->current_position];
-
- while (! ((c == '\0') || header_end )) {
-
- if (space) {
- if (c == ' ' && c == '\t')
- goto next_char;
- else
- space = FALSE;
- }
-
- if (newline) {
- if (c == ' ' && c == '\t') {
-
- space = TRUE;
- newline = FALSE;
- goto next_char;
- } else {
-
- header_end = TRUE;
- continue;
- }
- }
-
- if (c == '\n') {
- newline = TRUE;
- goto next_char;
- }
-
- /* feed the header content */
- parser->tmp_string = g_string_append_c (parser->tmp_string, c);
-
- next_char: /* read next char in the buffer */
- goto_next_char (parser);
- /* read the current character */
- c = buffer[parser->current_position];
- }
-
-
- /* copy the buffer in the preparsing information structure */
- *header_content = g_strndup (parser->tmp_string->str, parser->tmp_string->len);
- CAMEL_LOG_FULL_DEBUG ("Leaving CamelMboxParser::read_header\n");
-
-}
-
-
-
-
-
-
-
-/**
- * read_message_begining: read the first characters of a message body
- * @parser: parser object
- * @message_summary: a pointer on a (gchar *) variable where the obtained string will be stored.
- *
- * Read the first lines of a message. When calling this routine, the
- * parser must be located at the begining of the message body.
- *
- * Return value: if the parsing inside this routine last read a newline, then %TRUE is returned, otherwise %FALSE is returned
- **/
-static gboolean
-read_message_begining (CamelMboxPreParser *parser, gchar **message_summary)
-{
- guint nb_read = 0;
- gchar *buffer;
- gboolean new_message = FALSE;
- guint nb_line = 0;
- g_assert (parser);
-
- CAMEL_LOG_FULL_DEBUG ("Entering CamelMboxParser::read_message_begining\n");
-
- /* reset the header buffer string */
- parser->tmp_string = g_string_truncate (parser->tmp_string, 0);
-
- buffer = parser->buffer;
- /* the message should not be filled character by
- character but there is no g_string_n_append
- function, so for the moment, this is a lazy
- implementation */
- while (! (buffer[parser->current_position] != '\0') &&
- (nb_line <2) && (nb_read<parser->message_summary_size) &&
- (!new_message)) {
-
-
- /* test if we are not at the end of the message */
- if (buffer[parser->current_position] == '\n') {
-
- nb_line++;
- goto_next_char (parser);
- if ((buffer[parser->current_position] == '\0') ||
- (g_strncasecmp (parser->buffer + parser->current_position,
- parser->message_delimiter,
- parser->message_delimiter_length) == 0)) {
- new_message = TRUE;
- continue;
- } else {
- /* we're not at the end, so let's just add the cr to the summary */
- parser->tmp_string = g_string_append_c (parser->tmp_string,
- '\n');
- nb_read++;
- continue;
- }
-
-
- }
-
- parser->tmp_string = g_string_append_c (parser->tmp_string,
- buffer[parser->current_position]);
- nb_read++;
- goto_next_char (parser);
- }
-
- *message_summary = g_strndup (parser->tmp_string->str, parser->tmp_string->len);
-
- CAMEL_LOG_FULL_DEBUG ("Leaving CamelMboxParser::read_message_begining\n");
-
- return new_message;
-}
-
-
-
-
-
-
-
-
-
-
-/**
- * camel_mbox_parse_file: read an mbox file and parse it.
- * @fd: file descriptor opened on the mbox file.
- * @message_delimiter: character string delimiting the beginig of a new message
- * @start_position: poition in the file where to start the parsing.
- * @get_message_summary: should the parser retrieve the begining of the messages
- * @status_callback: function to call peridically to indicate the progress of the parser
- * @status_interval: floating value between 0 and 1 indicate how often to call @status_callback.
- * @user_data: user data that will be passed to the callback function
- *
- * This routine parses an mbox file and retreives both the message starting positions and
- * some of the informations contained in the message. Those informations are mainly
- * some RFC822 headers values but also (optionally) the first characters of the mail
- * body. The @get_message_summary parameter allows to enable or disable this option.
- *
- *
- * Return value: An array of CamelMboxParserMessageInfo containing the informations on each message parsed in the file
- **/
-GArray *
-camel_mbox_parse_file (int fd,
- const gchar *message_delimiter,
- glong start_position,
- guint32 *file_size,
- guint32 *next_uid,
- gboolean get_message_summary,
- camel_mbox_preparser_status_callback *status_callback,
- double status_interval,
- gpointer user_data)
-{
- CamelMboxPreParser *parser;
- gboolean is_parsing_a_message = FALSE;
- gchar c;
- struct stat stat_buf;
- gint fstat_result;
- glong total_file_size;
- int last_status = 0;
- int real_interval;
- gboolean newline;
- GArray *return_value;
- gchar *x_ev_header_content;
- guint32 next_available_uid = 1;
-
-
- g_assert (next_uid);
-
- CAMEL_LOG_FULL_DEBUG ("Entering CamelMboxParser::parse_file\n");
-
- /* get file size */
- fstat_result = fstat (fd, &stat_buf);
- if (fstat_result == -1) {
- g_warning ("Manage exception here \n");
- }
-
- total_file_size = stat_buf.st_size;
- real_interval = status_interval * total_file_size;
-
-
- /* create the parser */
- parser = new_parser (fd, message_delimiter);
-
- /* initialize the temporary char buffer */
- initialize_buffer (parser, start_position);
-
- /* the first line is indeed at the begining of a new line ... */
- newline = TRUE;
-
- while (parser->buffer[parser->current_position] != '\0') {
-
-
-
-
- /* read the current character */
- if (!newline) {
- c = parser->buffer[parser->current_position];
- newline = (c == '\n');
- goto_next_char (parser);
- }
-
- if (newline) {
-
- /* check if we reached a status milestone */
- if ( status_callback && ((parser->real_position - last_status) > real_interval)) {
- last_status += real_interval;
- status_callback ((double)last_status / (double)total_file_size,
- user_data);
- }
-
- /* is the next part a message delimiter ? */
- if (strncmp (parser->buffer + parser->current_position,
- parser->message_delimiter,
- parser->message_delimiter_length) == 0) {
-
- is_parsing_a_message = TRUE;
- new_message_detected (parser);
- newline = TRUE;
- continue;
- }
-
-
- if (is_parsing_a_message) {
- /* we could find the headers in a clever way, like
- storing them in a list of pair
- [keyword, offset_in_CamelMboxParserMessageInfo]
- I am too busy for now. Contribution welcome */
-
- /* is the next part a "from" header ? */
- if (g_strncasecmp (parser->buffer + parser->current_position,
- MBOX_PARSER_FROM_KW,
- MBOX_PARSER_FROM_KW_SZ) == 0) {
-
- advance_n_chars (parser, MBOX_PARSER_FROM_KW_SZ);
- read_header (parser, (gchar **) ((gchar *)parser +
- G_STRUCT_OFFSET (CamelMboxPreParser, current_message_info) +
- G_STRUCT_OFFSET (CamelMboxParserMessageInfo, from)));
-
- newline = TRUE;
- continue;
- }
-
- /* is the next part a "Date" header ? */
- if (g_strncasecmp (parser->buffer + parser->current_position,
- MBOX_PARSER_DATE_KW,
- MBOX_PARSER_DATE_KW_SZ) == 0) {
-
- advance_n_chars (parser, MBOX_PARSER_DATE_KW_SZ);
- read_header (parser, (gchar **) ((gchar *)parser +
- G_STRUCT_OFFSET (CamelMboxPreParser, current_message_info) +
- G_STRUCT_OFFSET (CamelMboxParserMessageInfo, date)));
-
- newline = TRUE;
- continue;
- }
-
-
- /* is the next part a "Subject" header ? */
- if (g_strncasecmp (parser->buffer + parser->current_position,
- MBOX_PARSER_SUBJECT_KW,
- MBOX_PARSER_SUBJECT_KW_SZ) == 0) {
-
- advance_n_chars (parser, MBOX_PARSER_SUBJECT_KW_SZ);
- read_header (parser, (gchar **) ((gchar *)parser +
- G_STRUCT_OFFSET (CamelMboxPreParser, current_message_info) +
- G_STRUCT_OFFSET (CamelMboxParserMessageInfo, subject)));
-
- newline = TRUE;
- continue;
- }
-
-
- /* is the next part a "To" header ? */
- if (g_strncasecmp (parser->buffer + parser->current_position,
- MBOX_PARSER_TO_KW,
- MBOX_PARSER_TO_KW_SZ) == 0) {
-
- advance_n_chars (parser, MBOX_PARSER_TO_KW_SZ);
- read_header (parser, (gchar **) ((gchar *)parser +
- G_STRUCT_OFFSET (CamelMboxPreParser, current_message_info) +
- G_STRUCT_OFFSET (CamelMboxParserMessageInfo, to)));
-
- newline = TRUE;
- continue;
- }
-
-
- /* is the next part a "X-evolution" header ? */
- if (g_strncasecmp (parser->buffer + parser->current_position,
- MBOX_PARSER_X_EVOLUTION_KW,
- MBOX_PARSER_X_EVOLUTION_KW_SZ) == 0) {
-
- /* in the case of the evolution private field, we store
- the field position as well as its length because
- we will have to change them */
- parser->current_message_info.x_evolution_offset = parser->real_position
- - parser->current_message_info.message_position;
- advance_n_chars (parser, MBOX_PARSER_X_EVOLUTION_KW_SZ);
-
- /* read the header */
- read_header (parser, &x_ev_header_content);
-
- /* parse it and put the result in the uid and status fields */
- camel_mbox_xev_parse_header_content (x_ev_header_content,
- (guint32 *) ((gchar *)parser +
- G_STRUCT_OFFSET (CamelMboxPreParser, current_message_info) +
- G_STRUCT_OFFSET (CamelMboxParserMessageInfo, uid)),
- (guchar *) ((gchar *)parser +
- G_STRUCT_OFFSET (CamelMboxPreParser, current_message_info) +
- G_STRUCT_OFFSET (CamelMboxParserMessageInfo, status)));
- g_free (x_ev_header_content);
- next_available_uid = MAX (next_available_uid, parser->current_message_info.uid);
-
- newline = TRUE;
- continue;
- }
-
-
-
-
- /* is it an empty line ? */
- if (parser->buffer[parser->current_position] == '\n') {
-
- parser->current_message_info.end_of_headers_offset =
- parser->real_position - parser->current_message_info.message_position;
-
- goto_next_char (parser);
- if (get_message_summary)
- newline = read_message_begining (parser, (gchar **) ((gchar *)parser +
- G_STRUCT_OFFSET (CamelMboxPreParser, current_message_info) +
- G_STRUCT_OFFSET (CamelMboxParserMessageInfo, body_summary)));
-
- is_parsing_a_message = FALSE;
- continue;
- }
- }
- newline = FALSE;
- }
-
- }
-
- /* if there is a pending message information put it in the array */
- if (parser->is_pending_message) {
- parser->current_message_info.size =
- parser->real_position - parser->current_message_info.message_position;
- g_array_append_vals (parser->preparsed_messages, (gchar *)parser +
- G_STRUCT_OFFSET (CamelMboxPreParser, current_message_info), 1);
- }
-
- return_value = parser->preparsed_messages;
- *file_size = parser->real_position;
- *next_uid = next_available_uid;
- /* free the parser */
- parser_free (parser);
-
- CAMEL_LOG_FULL_DEBUG ("Entering CamelMboxParser::parse_file\n");
-
- return return_value;
-}
-
-
-
-
-
-
-
-
-
-
-#ifdef MBOX_PARSER_TEST
-/* to build the test :
-
- gcc -O3 -I/opt/gnome/lib/glib/include `glib-config --cflags` -o test_parser -DMBOX_PARSER_TEST -I ../.. -I ../../.. -I /usr/lib/glib/include camel-mbox-parser.c `glib-config --libs` -lm
-
-
- */
-
-
-#include <math.h>
-
-static void
-status (double done, gpointer user_data)
-{
- printf ("%d %% done\n", (int)floor (done * 100));
-}
-int
-main (int argc, char **argv)
-{
- int test_file_fd;
- int i;
- int file_size;
- int next_uid;
- GArray *message_positions;
- CamelMboxParserMessageInfo *message_info;
- gchar tmp_buffer[50];
-
- tmp_buffer[49] = '\0';
-
- if (argc<2) {
- printf("usage: %s mbox\n", argv[0]);
- return 1;
- }
-
- test_file_fd = open (argv[1], O_RDONLY);
- message_positions = camel_mbox_parse_file (test_file_fd,
- "From ",
- 0,
- &file_size,
- &next_uid,
- TRUE,
- status,
- 0.05,
- NULL);
-
- printf ("Found %d messages \n", message_positions->len);
-
-
- for (i=0; i<message_positions->len; i++) {
-
- message_info = ((CamelMboxParserMessageInfo *)(message_positions->data)) + i;
- printf ("\n\n** Message %d : \n", i);
- printf ("Size : %d\n", message_info->size);
- printf ("From: %s\n", message_info->from);
- printf ("Date: %s\n", message_info->date);
- printf ("Subject: %s\n", message_info->subject);
- printf ("Summary: %s\n", message_info->body_summary) ;
-
-
- lseek (test_file_fd, message_info->message_position, SEEK_SET);
- read (test_file_fd, tmp_buffer, 49);
- printf ("File content at position %d : \n===\n%s\n===\n", message_info->message_position, tmp_buffer);
-
- }
-
-
-
- return 0;
-}
-
-
-
-
-#endif /* MBOX_PARSER_TEST */
diff --git a/camel/providers/mbox/camel-mbox-parser.h b/camel/providers/mbox/camel-mbox-parser.h
deleted file mode 100644
index 1c49ea55c6..0000000000
--- a/camel/providers/mbox/camel-mbox-parser.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* camel-mbox-parser.c : mbox folder parser */
-
-/*
- *
- * Author : Bertrand Guiheneuf <bertrand@helixcode.com>
- *
- * Copyright (C) 1999 Helix Code .
- *
- * 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 <glib.h>
-#include "camel-log.h"
-#include "camel-exception.h"
-
-
-typedef struct {
-
- glong message_position;
- glong size;
-
- gchar *from;
- gchar *to;
- gchar *date;
- gchar *subject;
- gchar *priority;
- gchar *references;
- gchar *body_summary;
- gshort end_of_headers_offset;
-
- gchar *x_evolution;
- gshort x_evolution_offset;
- guint32 uid;
- guchar status;
-
-} CamelMboxParserMessageInfo;
-
-
-typedef void camel_mbox_preparser_status_callback (double percentage_done, gpointer user_data);
-
-
-GArray *
-camel_mbox_parse_file (int fd,
- const gchar *message_delimiter,
- glong start_position,
- guint32 *file_size,
- guint32 *next_uid,
- gboolean get_message_summary,
- camel_mbox_preparser_status_callback *status_callback,
- double status_interval,
- gpointer user_data);
-
diff --git a/camel/providers/mbox/camel-mbox-provider.c b/camel/providers/mbox/camel-mbox-provider.c
deleted file mode 100644
index 873dca0954..0000000000
--- a/camel/providers/mbox/camel-mbox-provider.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* camel-mbox-provider.c: mbox provider registration code */
-
-/*
- * Authors :
- * Bertrand Guiheneuf <bertrand@helixcode.com>
- *
- * Copyright (C) 2000 HelixCode (www.helixcode.com).
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-
-#include "config.h"
-#include "camel-mbox-store.h"
-#include "camel-provider.h"
-#include "camel-log.h"
-
-
-static CamelProvider _mbox_provider = {
- (GtkType) 0,
- PROVIDER_STORE,
- "mbox",
- "Camel default mbox provider",
- "This the first full fledged local mail provider",
- (GModule *) NULL
-};
-
-CamelProvider *
-camel_provider_module_init ()
-{
- _mbox_provider.object_type = camel_mbox_store_get_type();
- return &_mbox_provider;
-}
-
-
-
diff --git a/camel/providers/mbox/camel-mbox-search.c b/camel/providers/mbox/camel-mbox-search.c
deleted file mode 100644
index b46c046b6d..0000000000
--- a/camel/providers/mbox/camel-mbox-search.c
+++ /dev/null
@@ -1,857 +0,0 @@
-/*
- * Copyright 2000 HelixCode (http://www.helixcode.com).
- *
- * Author :
- * Michael Zucchi <notzed@helixcode.com>
-
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-
-#include <glib.h>
-#include <stdio.h>
-#include <time.h>
-#include <string.h>
-
-#include <camel/gmime-utils.h>
-#include <camel/camel-log.h>
-#include "camel/camel-mime-message.h"
-#include "camel/camel-mime-part.h"
-#include "camel/camel-stream.h"
-#include "camel/camel-stream-fs.h"
-#include "camel/camel.h"
-#include "camel-mbox-folder.h"
-
-#define HAVE_IBEX
-#ifdef HAVE_IBEX
-#include "ibex.h"
-#endif
-
-#define p(x) /* parse debug */
-#define r(x) /* run debug */
-#define d(x) /* general debug */
-
-
-/*
-
- This is not yet complete.
-
- The following s-exp's are supported:
-
- list = (and list*)
- perform an intersection of a number of lists, and return that.
-
- bool = (and bool*)
- perform a boolean AND of boolean values.
-
- list = (or list*)
- perform a union of a number of lists, returning the new list.
-
- bool = (or bool*)
- perform a boolean OR of boolean values.
-
- Comparison operators:
-
- bool = (lt int int)
- bool = (gt int int)
- bool = (eq int int)
-
- bool = (lt string string)
- bool = (gt string string)
- bool = (eq string string)
- Perform a comparision of 2 integers, or 2 string values.
-
- Matching operators:
-
- list = (contains string)
- Returns a list of all messages containing the string in their body.
-
- list = (match-all bool-expr)
- Returns a list of all messages for which the bool expression is true.
- The bool-expr is evaluated for each message in turn.
- It is more efficient not to perform body-content comparisons inside a
- match-all operator.
-
- int = (date-sent)
- Returns a time_t of the date-sent of the message.
-
- bool = (header-contains string1 string2)
- Returns true if the current message (inside a match-all operator)
- has a header 'string1', which contains 'string2'
-*/
-
-static GScannerConfig scanner_config =
-{
- (
- " \t\r\n"
- ) /* cset_skip_characters */,
- (
- G_CSET_a_2_z
- "_"
- G_CSET_A_2_Z
- ) /* cset_identifier_first */,
- (
- G_CSET_a_2_z
- "_0123456789-"
- G_CSET_A_2_Z
- G_CSET_LATINS
- G_CSET_LATINC
- ) /* cset_identifier_nth */,
- ( "#\n" ) /* cpair_comment_single */,
-
- FALSE /* case_sensitive */,
-
- TRUE /* skip_comment_multi */,
- TRUE /* skip_comment_single */,
- TRUE /* scan_comment_multi */,
- TRUE /* scan_identifier */,
- FALSE /* scan_identifier_1char */,
- FALSE /* scan_identifier_NULL */,
- TRUE /* scan_symbols */,
- FALSE /* scan_binary */,
- TRUE /* scan_octal */,
- TRUE /* scan_float */,
- TRUE /* scan_hex */,
- FALSE /* scan_hex_dollar */,
- TRUE /* scan_string_sq */,
- TRUE /* scan_string_dq */,
- TRUE /* numbers_2_int */,
- FALSE /* int_2_float */,
- FALSE /* identifier_2_string */,
- TRUE /* char_2_token */,
- FALSE /* symbol_2_token */,
- FALSE /* scope_0_fallback */,
-};
-
-
-enum _searchtermtype_t {
- SEARCH_AND,
- SEARCH_OR,
- SEARCH_LT,
- SEARCH_GT,
- SEARCH_EQ,
- SEARCH_CONTAINS,
- SEARCH_DATESENT,
- SEARCH_STRING,
- SEARCH_INT,
- SEARCH_FUNC,
-};
-
-struct _searchterm {
- enum _searchtermtype_t type;
- union {
- char *string;
- int number;
- struct {
- struct _searchterm_symbol *sym;
- struct _searchterm **terms;
- int termcount;
- } func;
- } value;
-};
-
-struct _searchcontext {
- int whatever;
-
- CamelFolder *folder;
-
-#ifdef HAVE_IBEX
- ibex *index; /* index of content for this folder */
-#endif
-
- CamelFolderSummary *summary;
- const GArray *message_info;
-
- CamelMessageInfo *message_current; /* when performing a (match operation */
-};
-
-enum _searchresulttype_t {
- RESULT_ARRAY_PTR=0,
- RESULT_INT,
- RESULT_STRING,
- RESULT_BOOL,
- RESULT_UNDEFINED
-};
-
-struct _searchresult {
- enum _searchresulttype_t type;
- union {
- GPtrArray *ptrarray;
- int number;
- char *string;
- int bool;
- } value;
-};
-
-/* function callbacks */
-static struct _searchresult *search_contains(struct _searchcontext *ctx, struct _searchterm *t);
-static struct _searchresult *search_matches(struct _searchcontext *ctx, struct _searchterm *t);
-static struct _searchresult *search_date_sent(struct _searchcontext *ctx, struct _searchterm *t);
-static struct _searchresult *header_contains(struct _searchcontext *ctx, struct _searchterm *t);
-
-struct _searchterm_symbol {
- char *name;
- int type;
- int argtype;
- struct _searchresult * (*func)(struct _searchcontext *ctx, struct _searchterm *t);
-} symbols[] = {
- { "and", SEARCH_AND, 0, NULL },
- { "or", SEARCH_OR, 0, NULL },
- { "lt", SEARCH_LT, 1, NULL },
- { "gt", SEARCH_GT, 1, NULL },
- { "eq", SEARCH_EQ, 1, NULL },
- { "contains", SEARCH_FUNC, 1, search_contains },
- { "match-all", SEARCH_FUNC, 1, search_matches },
- { "date-sent", SEARCH_FUNC, 1, search_date_sent },
- { "header-contains", SEARCH_FUNC, 1, header_contains },
-};
-
-static struct _searchterm * parse_list(GScanner *gs, int gotbrace);
-static struct _searchterm * parse_value(GScanner *gs);
-
-static struct _searchresult *term_eval(struct _searchcontext *ctx, struct _searchterm *t);
-static void parse_dump_term(struct _searchterm *t, int depth);
-
-/* can you tell, i dont like glib? */
-struct _glib_sux_donkeys {
- int count;
- GPtrArray *uids;
-};
-
-
-/* ok, store any values that are in all sets */
-static void
-g_lib_sux_htand(char *key, int value, struct _glib_sux_donkeys *fuckup)
-{
- if (value == fuckup->count) {
- g_ptr_array_add(fuckup->uids, key);
- }
-}
-
-/* or, store all unique values */
-static void
-g_lib_sux_htor(char *key, int value, struct _glib_sux_donkeys *fuckup)
-{
- g_ptr_array_add(fuckup->uids, key);
-}
-
-static struct _searchresult *
-result_new(int type)
-{
- struct _searchresult *r = g_malloc0(sizeof(*r));
- r->type = type;
- return r;
-}
-
-static void
-result_free(struct _searchresult *t)
-{
- switch(t->type) {
- case RESULT_ARRAY_PTR:
- g_ptr_array_free(t->value.ptrarray, TRUE);
- break;
- case RESULT_BOOL:
- case RESULT_INT:
- break;
- case RESULT_STRING:
- g_free(t->value.string);
- break;
- case RESULT_UNDEFINED:
- break;
- }
- g_free(t);
-}
-
-static struct _searchresult *search_contains(struct _searchcontext *ctx, struct _searchterm *t)
-{
- struct _searchresult *r, *r1;
-
- r = result_new(RESULT_UNDEFINED);
-
- if (t->value.func.termcount>0) {
- if (t->value.func.termcount!=1) {
- printf("warning, only looking for first string in contains clause\n");
- }
- r1 = term_eval(ctx, t->value.func.terms[0]);
- if (r1->type == RESULT_STRING) {
- if (ctx->message_current) {
- int truth = FALSE;
-#ifdef HAVE_IBEX
- int i;
- GPtrArray *array;
-
- if (ctx->index) {
- array = ibex_find(ctx->index, r1->value.string);
-
- for (i=0;i<array->len;i++) {
- if (!strcmp(g_ptr_array_index(array, i), ctx->message_current->uid)) {
- truth = TRUE;
- break;
- }
- }
- g_ptr_array_free(array, TRUE);
- }
-#endif
- r->type = RESULT_BOOL;
- r->value.bool = truth;
- } else {
- r->type = RESULT_ARRAY_PTR;
-#ifdef HAVE_IBEX
- if (ctx->index) {
- /* blah, this should probably copy the index strings? */
- r->value.ptrarray = ibex_find(ctx->index, r1->value.string);
- } else {
- r->value.ptrarray = g_ptr_array_new();
- }
-#endif
- }
- } else {
- printf("you can't search for a contents of a non-string, fool\n");
- }
- result_free(r1);
- }
- return r;
-}
-
-/* run a sub-tree of commands which match on header fields etc */
-static struct _searchresult *search_matches(struct _searchcontext *ctx, struct _searchterm *t)
-{
- int i;
- struct _searchresult *r, *r1;
-
- if (t->value.func.termcount == 1) {
- r = result_new(RESULT_ARRAY_PTR);
- r->value.ptrarray = g_ptr_array_new();
-
- for (i=0;i<ctx->message_info->len;i++) {
- ctx->message_current = &g_array_index(ctx->message_info, CamelMessageInfo, i);
- r1 = term_eval(ctx, t->value.func.terms[0]);
- if (r1->type == RESULT_BOOL) {
- if (r1->value.bool) {
- r(printf("adding message %s\n", ctx->message_current->uid));
- g_ptr_array_add(r->value.ptrarray, ctx->message_current->uid);
- }
- } else {
- printf("invalid syntax, matches require a single bool result\n");
- }
- result_free(r1);
- }
- ctx->message_current = NULL;
- } else {
- r = result_new(RESULT_UNDEFINED);
- printf("invalid syntax, matches only allows a single bool arg\n");
- }
- return r;
-}
-
-/* these variable-getting things could be put into 1 function */
-static struct _searchresult *search_date_sent(struct _searchcontext *ctx, struct _searchterm *t)
-{
- struct _searchresult *r;
-
- if (ctx->message_current) {
- r = result_new(RESULT_INT);
- r->value.number = time(0);
- /* r->value.number = ctx->current_message->date_sent;*/
- } else {
- r = result_new(RESULT_UNDEFINED);
- }
- return r;
-}
-
-/* header contains - can only be used inside a match-all construct */
-/* all headers should be inside a lookup table, so this can search
- all header types */
-static struct _searchresult *header_contains(struct _searchcontext *ctx, struct _searchterm *t)
-{
- struct _searchresult *r;
-
- r(printf("executing header-contains\n"));
-
- /* are we inside a match-all? */
- if (ctx->message_current
- && t->value.func.termcount == 2) {
- char *header, *substring;
- int truth = FALSE;
- struct _searchresult *r1, *r2;
-
- r1 = term_eval(ctx, t->value.func.terms[0]);
- r2 = term_eval(ctx, t->value.func.terms[1]);
-
- if (r1->type == RESULT_STRING
- && r2->type == RESULT_STRING) {
-
- header = r1->value.string;
- substring = r2->value.string;
- if (!strcasecmp(header, "subject")) {
- r(printf("comparing subject: %s\n", ctx->message_current->subject));
- if (ctx->message_current->subject)
- truth = (strstr(ctx->message_current->subject, substring)) != NULL;
- else
- printf("Warning: no subject line in message?\n");
- }
- r(printf("header-contains %s %s = %s\n", header, substring, truth?"TRUE":"FALSE"));
- }
-
- result_free(r1);
- result_free(r2);
-
- r = result_new(RESULT_BOOL);
- r->value.number = truth;
- } else {
- r = result_new(RESULT_UNDEFINED);
- }
- return r;
-}
-
-
-static struct _searchresult *
-term_eval(struct _searchcontext *ctx, struct _searchterm *t)
-{
- struct _searchresult *r, *r1, *r2;
- int i;
-
- r(printf("eval term :\n"));
- r(parse_dump_term(t, 0));
-
- r = g_malloc0(sizeof(*r));
- r->type = RESULT_UNDEFINED;
-
- switch (t->type) {
- case SEARCH_AND: {
- GHashTable *ht = g_hash_table_new(g_str_hash, g_str_equal);
- struct _glib_sux_donkeys lambdafoo;
- int type=-1;
- int bool = TRUE;
-
- r(printf("( and\n"));
-
- for (i=0;bool && i<t->value.func.termcount;i++) {
- r1 = term_eval(ctx, t->value.func.terms[i]);
- if (type == -1)
- type = r1->type;
- if (type != r1->type) {
- printf("invalid types in and operation, all types must be the same\n");
- } else if ( r1->type == RESULT_ARRAY_PTR ) {
- char **a1;
- int l1, j;
-
- a1 = (char **)r1->value.ptrarray->pdata;
- l1 = r1->value.ptrarray->len;
- for (j=0;i<l1;j++) {
- int n;
- n = (int)g_hash_table_lookup(ht, a1[i]);
- g_hash_table_insert(ht, a1[i], (void *)n+1);
- }
- } else if ( r1->type == RESULT_BOOL ) {
- bool &= r1->value.bool;
- }
- result_free(r1);
- }
-
- if (type == RESULT_ARRAY_PTR) {
- lambdafoo.count = t->value.func.termcount;
- lambdafoo.uids = g_ptr_array_new();
- g_hash_table_foreach(ht, (GHFunc)g_lib_sux_htand, &lambdafoo);
- r->type = RESULT_ARRAY_PTR;
- r->value.ptrarray = lambdafoo.uids;
- } else if (type == RESULT_BOOL) {
- r->type = RESULT_BOOL;
- r->value.bool = bool;
- }
-
- g_hash_table_destroy(ht);
-
- break; }
- case SEARCH_OR: {
- GHashTable *ht = g_hash_table_new(g_str_hash, g_str_equal);
- struct _glib_sux_donkeys lambdafoo;
- int type = -1;
- int bool = FALSE;
-
- r(printf("(or \n"));
-
- for (i=0;!bool && i<t->value.func.termcount;i++) {
- r1 = term_eval(ctx, t->value.func.terms[i]);
- if (type == -1)
- type = r1->type;
- if (r1->type != type) {
- printf("wrong types in or operation\n");
- } else if (r1->type == RESULT_ARRAY_PTR) {
- char **a1;
- int l1, j;
-
- a1 = (char **)r1->value.ptrarray->pdata;
- l1 = r1->value.ptrarray->len;
- for (j=0;i<l1;j++) {
- g_hash_table_insert(ht, a1[j], (void *)1);
- }
- } else if (r1->type == RESULT_BOOL) {
- bool |= r1->value.bool;
- }
- result_free(r1);
- }
-
- if (type == RESULT_ARRAY_PTR) {
- lambdafoo.count = t->value.func.termcount;
- lambdafoo.uids = g_ptr_array_new();
- g_hash_table_foreach(ht, (GHFunc)g_lib_sux_htor, &lambdafoo);
- r->type = RESULT_ARRAY_PTR;
- r->value.ptrarray = lambdafoo.uids;
- } else if (type == RESULT_BOOL) {
- r->type = RESULT_BOOL;
- r->value.bool = bool;
- }
- g_hash_table_destroy(ht);
-
- break; }
- case SEARCH_LT:
- r(printf("(lt \n"));
- if (t->value.func.termcount == 2) {
- r1 = term_eval(ctx, t->value.func.terms[0]);
- r2 = term_eval(ctx, t->value.func.terms[1]);
- if (r1->type != r2->type) {
- printf("error, invalid types in compare\n");
- } else if (r1->type == RESULT_INT) {
- r->type = RESULT_BOOL;
- r->value.bool = r1->value.number < r2->value.number;
- } else if (r1->type == RESULT_STRING) {
- r->type = RESULT_BOOL;
- r->value.bool = strcmp(r1->value.string, r2->value.string) < 0;
- }
- }
- break;
- case SEARCH_GT:
- r(printf("(gt \n"));
- if (t->value.func.termcount == 2) {
- r1 = term_eval(ctx, t->value.func.terms[0]);
- r2 = term_eval(ctx, t->value.func.terms[1]);
- if (r1->type != r2->type) {
- printf("error, invalid types in compare\n");
- } else if (r1->type == RESULT_INT) {
- r->type = RESULT_BOOL;
- r->value.bool = r1->value.number > r2->value.number;
- } else if (r1->type == RESULT_STRING) {
- r->type = RESULT_BOOL;
- r->value.bool = strcmp(r1->value.string, r2->value.string) > 0;
- }
- }
- break;
- case SEARCH_STRING:
- r(printf(" (string \"%s\")\n", t->value.string));
- r->type = RESULT_STRING;
- /* erk, this shoul;dn't need to strdup this ... */
- r->value.string = g_strdup(t->value.string);
- break;
- case SEARCH_INT:
- r(printf(" (int %d)\n", t->value.number));
- r->type = RESULT_INT;
- r->value.number = t->value.number;
- break;
- case SEARCH_FUNC:
- g_free(r); /* <---- FIXME: ICK !! */
- r(printf("function '%s'\n", t->value.func.sym->name));
- return t->value.func.sym->func(ctx, t);
- default:
- printf("Warning: Unknown type encountered in parse tree: %d\n", t->type);
- r->type = RESULT_UNDEFINED;
- }
-
- return r;
-}
-
-
-static void
-parse_dump_term(struct _searchterm *t, int depth)
-{
- int dumpvals = FALSE;
- int i;
-
- if (t==NULL) {
- printf("null term??\n");
- return;
- }
-
- for (i=0;i<depth;i++)
- printf(" ");
-
- switch (t->type) {
- case SEARCH_AND:
- printf("(and \n");
- dumpvals = 1;
- break;
- case SEARCH_OR:
- printf("(or \n");
- dumpvals = 1;
- break;
- case SEARCH_LT:
- printf("(lt \n");
- dumpvals = 1;
- break;
- case SEARCH_GT:
- printf("(gt \n");
- dumpvals = 1;
- break;
- case SEARCH_STRING:
- printf(" \"%s\"", t->value.string);
- break;
- case SEARCH_INT:
- printf(" %d", t->value.number);
- break;
- case SEARCH_FUNC:
- printf(" (function %s", t->value.func.sym->name);
- dumpvals = 1;
- break;
- default:
- printf("unknown type: %d\n", t->type);
- }
-
- if (dumpvals) {
- /*printf(" [%d] ", t->value.func.termcount);*/
- for (i=0;i<t->value.func.termcount;i++) {
- parse_dump_term(t->value.func.terms[i], depth+1);
- }
- for (i=0;i<depth;i++)
- printf(" ");
- printf(")\n");
- }
- printf("\n");
-}
-
-/*
- PARSER
-*/
-
-static struct _searchterm *
-parse_new_term(int type)
-{
- struct _searchterm *s = g_malloc0(sizeof(*s));
- s->type = type;
- return s;
-}
-
-static void
-parse_term_free(struct _searchterm *t)
-{
- int i;
-
- if (t==NULL) {
- return;
- }
-
- switch (t->type) {
- case SEARCH_AND:
- case SEARCH_OR:
- case SEARCH_LT:
- case SEARCH_GT:
- case SEARCH_FUNC:
- for (i=0;i<t->value.func.termcount;i++) {
- parse_term_free(t->value.func.terms[i]);
- }
- g_free(t->value.func.terms);
- break;
- case SEARCH_STRING:
- g_free(t->value.string);
- break;
- case SEARCH_INT:
- break;
- default:
- printf("parse_term_free: unknown type: %d\n", t->type);
- }
- g_free(t);
-}
-
-static struct _searchterm **
-parse_lists(GScanner *gs, int *len)
-{
- int token;
- struct _searchterm **terms;
- int i=0;
-
- p(printf("parsing lists\n"));
-
- terms = g_malloc0(20*sizeof(*terms));
-
- while ( (token = g_scanner_peek_next_token(gs)) != G_TOKEN_EOF
- && token != ')') {
- terms[i]=parse_list(gs, FALSE);
- i++;
- }
-
- if (len)
- *len = i;
-
- p(printf("found %d subterms\n", i));
-
- p(printf("done parsing lists, token= %d %c\n", token, token));
- return terms;
-}
-
-static struct _searchterm **
-parse_values(GScanner *gs, int *len)
-{
- int token;
- struct _searchterm **terms;
- int i=0;
-
- p(printf("parsing values\n"));
-
- terms = g_malloc0(20*sizeof(*terms));
-
- while ( (token = g_scanner_peek_next_token(gs)) != G_TOKEN_EOF
- && token != ')') {
- terms[i]=parse_value(gs);
- i++;
- }
-
- p(printf("found %d subterms\n", i));
- *len = i;
-
- p(printf("dont parsing values\n"));
- return terms;
-}
-
-static struct _searchterm *
-parse_value(GScanner *gs)
-{
- int token;
- struct _searchterm *t = NULL;
-
- p(printf("parsing value\n"));
-
- token = g_scanner_get_next_token(gs);
- switch(token) {
- case G_TOKEN_LEFT_PAREN:
- p(printf("got brace, its a list!\n"));
- return parse_list(gs, TRUE);
- case G_TOKEN_STRING:
- p(printf("got string\n"));
- t = parse_new_term(SEARCH_STRING);
- t->value.string = g_strdup(g_scanner_cur_value(gs).v_string);
- break;
- case G_TOKEN_INT:
- t = parse_new_term(SEARCH_INT);
- t->value.number = g_scanner_cur_value(gs).v_int;
- p(printf("got int\n"));
- break;
- default:
- printf("Innvalid token trying to parse a list of values\n");
- }
- p(printf("done parsing value\n"));
- return t;
-}
-
-/* FIXME: this needs some robustification */
-static struct _searchterm *
-parse_list(GScanner *gs, int gotbrace)
-{
- int token;
- struct _searchterm *t = NULL;
-
- p(printf("parsing list\n"));
- if (gotbrace)
- token = '(';
- else
- token = g_scanner_get_next_token(gs);
- if (token =='(') {
- token = g_scanner_get_next_token(gs);
- if (token == G_TOKEN_SYMBOL) {
- struct _searchterm_symbol *s;
-
- s = g_scanner_cur_value(gs).v_symbol;
- p(printf("got funciton: %s\n", s->name));
- t = parse_new_term(s->type);
- t->value.func.sym = s;
- p(printf("created new list %p\n", t));
- switch(s->argtype) {
- case 0: /* it MUST be a list of lists */
- t->value.func.terms = parse_lists(gs, &t->value.func.termcount);
- break;
- case 1:
- t->value.func.terms = parse_values(gs, &t->value.func.termcount);
- break;
- default:
- printf("Error, internal error parsing symbols\n");
- }
- } else {
- printf("unknown sequence encountered, type = %d\n", token);
- }
- token = g_scanner_get_next_token(gs);
- if (token != ')') {
- printf("Error, expected ')' not found\n");
- }
- } else {
- printf("Error, list term without opening (\n");
- }
-
- p(printf("returning list %p\n", t));
- return t;
-}
-
-GList *
-camel_mbox_folder_search_by_expression(CamelFolder *folder, char *expression, CamelException *ex)
-{
- GScanner *gs;
- int i;
- struct _searchterm *t;
- struct _searchcontext *ctx;
- struct _searchresult *r;
- GList *matches = NULL;
-
- gs = g_scanner_new(&scanner_config);
- for(i=0;i<sizeof(symbols)/sizeof(symbols[0]);i++)
- g_scanner_scope_add_symbol(gs, 0, symbols[i].name, &symbols[i]);
-
- g_scanner_input_text(gs, expression, strlen(expression));
- t = parse_list(gs, 0);
-
- if (t) {
- ctx = g_malloc0(sizeof(*ctx));
- ctx->folder = folder;
- ctx->summary = camel_folder_get_summary(folder, ex);
- ctx->message_info = camel_folder_summary_get_message_info_list(ctx->summary);
-#ifdef HAVE_IBEX
- ctx->index = ibex_open(CAMEL_MBOX_FOLDER(folder)->index_file_path, FALSE);
- if (!ctx->index) {
- perror("Cannot open index file, body searches will be ignored\n");
- }
-#endif
- r = term_eval(ctx, t);
-
- /* now create a folder summary to return?? */
- if (r
- && r->type == RESULT_ARRAY_PTR) {
- d(printf("got result ...\n"));
- for (i=0;i<r->value.ptrarray->len;i++) {
- d(printf("adding match: %s\n", (char *)g_ptr_array_index(r->value.ptrarray, i)));
- matches = g_list_prepend(matches, g_strdup(g_ptr_array_index(r->value.ptrarray, i)));
- }
- result_free(r);
- }
-
- if (ctx->index)
- ibex_close(ctx->index);
-
- gtk_object_unref((GtkObject *)ctx->summary);
- g_free(ctx);
- parse_term_free(t);
- } else {
- printf("Warning, Could not parse expression!\n %s\n", expression);
- }
-
- g_scanner_destroy(gs);
-
- return matches;
-}
diff --git a/camel/providers/mbox/camel-mbox-search.h b/camel/providers/mbox/camel-mbox-search.h
deleted file mode 100644
index 16efd4a023..0000000000
--- a/camel/providers/mbox/camel-mbox-search.h
+++ /dev/null
@@ -1,10 +0,0 @@
-
-#ifndef _CAMEL_MBOX_SEARCH_H
-#define _CAMEL_MBOX_SEARCH_H
-
-#include "camel-mbox-folder.h"
-
-GList *camel_mbox_folder_search_by_expression(CamelFolder *folder, const char *expression);
-
-#endif /* ! _CAMEL_MBOX_SEARCH_H */
-
diff --git a/camel/providers/mbox/camel-mbox-store.c b/camel/providers/mbox/camel-mbox-store.c
deleted file mode 100644
index f8b3b62718..0000000000
--- a/camel/providers/mbox/camel-mbox-store.c
+++ /dev/null
@@ -1,153 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* camel-mbox-store.c : class for an mbox store */
-
-/*
- *
- * Copyright (C) 2000 HelixCode <bertrand@helixcode.com> .
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-
-#include "camel-mbox-store.h"
-#include "camel-mbox-folder.h"
-#include "url-util.h"
-
-static CamelStoreClass *parent_class=NULL;
-
-/* Returns the class for a CamelMboxStore */
-#define CMBOXS_CLASS(so) CAMEL_MBOX_STORE_CLASS (GTK_OBJECT(so)->klass)
-#define CF_CLASS(so) CAMEL_FOLDER_CLASS (GTK_OBJECT(so)->klass)
-#define CMBOXF_CLASS(so) CAMEL_MBOX_FOLDER_CLASS (GTK_OBJECT(so)->klass)
-
-static void _init (CamelStore *store, CamelSession *session, const gchar *url_name, CamelException *ex);
-static CamelFolder *_get_folder (CamelStore *store, const gchar *folder_name, CamelException *ex);
-
-
-static void
-camel_mbox_store_class_init (CamelMboxStoreClass *camel_mbox_store_class)
-{
- CamelStoreClass *camel_store_class = CAMEL_STORE_CLASS (camel_mbox_store_class);
-
- parent_class = gtk_type_class (camel_store_get_type ());
-
- /* virtual method definition */
- /* virtual method overload */
- camel_store_class->init = _init;
- camel_store_class->get_folder = _get_folder;
-}
-
-
-
-static void
-camel_mbox_store_init (gpointer object, gpointer klass)
-{
- CamelMboxStore *mbox_store = CAMEL_MBOX_STORE (object);
- CamelStore *store = CAMEL_STORE (object);
-
- store->separator = '/';
-}
-
-
-
-
-GtkType
-camel_mbox_store_get_type (void)
-{
- static GtkType camel_mbox_store_type = 0;
-
- if (!camel_mbox_store_type) {
- GtkTypeInfo camel_mbox_store_info =
- {
- "CamelMboxStore",
- sizeof (CamelMboxStore),
- sizeof (CamelMboxStoreClass),
- (GtkClassInitFunc) camel_mbox_store_class_init,
- (GtkObjectInitFunc) camel_mbox_store_init,
- /* reserved_1 */ NULL,
- /* reserved_2 */ NULL,
- (GtkClassInitFunc) NULL,
- };
-
- camel_mbox_store_type = gtk_type_unique (CAMEL_STORE_TYPE, &camel_mbox_store_info);
- }
-
- return camel_mbox_store_type;
-}
-
-
-
-
-/* These evil public functions are here for test only */
-void
-camel_mbox_store_set_toplevel_dir (CamelMboxStore *store, const gchar *toplevel, CamelException *ex)
-{
- store->toplevel_dir = g_strdup (toplevel);
- CAMEL_STORE(store)->separator = '/';
-}
-
-
-const gchar *
-camel_mbox_store_get_toplevel_dir (CamelMboxStore *store, CamelException *ex)
-{
- return store->toplevel_dir;
-}
-
-
-
-static void
-_init (CamelStore *store, CamelSession *session, const gchar *url_name, CamelException *ex)
-{
- CamelMboxStore *mbox_store = CAMEL_MBOX_STORE (store);
- Gurl *store_url;
-
- g_assert (url_name);
- /* call parent implementation */
- parent_class->init (store, session, url_name, ex);
-
-
- /* find the path in the URL*/
- store_url = g_url_new (url_name);
-
- g_return_if_fail (store_url);
- g_return_if_fail (store_url->path);
-
- mbox_store->toplevel_dir = g_strdup (store_url->path);
- g_url_free (store_url);
-
-
-
-}
-
-
-static CamelFolder *
-_get_folder (CamelStore *store, const gchar *folder_name, CamelException *ex)
-{
- CamelMboxFolder *new_mbox_folder;
- CamelFolder *new_folder;
-
- /* check if folder has already been created */
- /* call the standard routine for that when */
- /* it is done ... */
-
- new_mbox_folder = gtk_type_new (CAMEL_MBOX_FOLDER_TYPE);
- new_folder = CAMEL_FOLDER (new_mbox_folder);
-
- CF_CLASS (new_folder)->init_with_store (new_folder, store, ex);
- CF_CLASS (new_folder)->set_name (new_folder, folder_name, ex);
-
-
- return new_folder;
-}
diff --git a/camel/providers/mbox/camel-mbox-store.h b/camel/providers/mbox/camel-mbox-store.h
deleted file mode 100644
index a5aea965e2..0000000000
--- a/camel/providers/mbox/camel-mbox-store.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* camel-mbox-store.h : class for an mbox store */
-
-/*
- *
- * Copyright (C) 2000 HelixCode <bertrand@helixcode.com> .
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-
-
-#ifndef CAMEL_MBOX_STORE_H
-#define CAMEL_MBOX_STORE_H 1
-
-
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* __cplusplus }*/
-
-#include <gtk/gtk.h>
-#include "camel-store.h"
-
-#define CAMEL_MBOX_STORE_TYPE (camel_mbox_store_get_type ())
-#define CAMEL_MBOX_STORE(obj) (GTK_CHECK_CAST((obj), CAMEL_MBOX_STORE_TYPE, CamelMboxStore))
-#define CAMEL_MBOX_STORE_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_MBOX_STORE_TYPE, CamelMboxStoreClass))
-#define IS_CAMEL_MBOX_STORE(o) (GTK_CHECK_TYPE((o), CAMEL_MBOX_STORE_TYPE))
-
-
-typedef struct {
- CamelStore parent_object;
-
- gchar *toplevel_dir;
-} CamelMboxStore;
-
-
-
-typedef struct {
- CamelStoreClass parent_class;
-
-
-} CamelMboxStoreClass;
-
-
-/* public methods */
-
-/* Standard Gtk function */
-GtkType camel_mbox_store_get_type (void);
-
-void camel_mbox_store_set_toplevel_dir (CamelMboxStore *store, const gchar *toplevel, CamelException *ex);
-const gchar *camel_mbox_store_get_toplevel_dir (CamelMboxStore *store, CamelException *ex);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* CAMEL_MBOX_STORE_H */
-
-
diff --git a/camel/providers/mbox/camel-mbox-summary.c b/camel/providers/mbox/camel-mbox-summary.c
deleted file mode 100644
index 244fe34073..0000000000
--- a/camel/providers/mbox/camel-mbox-summary.c
+++ /dev/null
@@ -1,305 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-/*
- * Author : Bertrand Guiheneuf <bertrand@helixcode.com>
- *
- * Copyright (C) 1999 Helix Code .
-
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-
-
-#include <config.h>
-
-#include "camel-log.h"
-#include "camel-mbox-folder.h"
-#include "camel-mbox-summary.h"
-#include "md5-utils.h"
-
-
-#include <sys/stat.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <fcntl.h>
-#include <dirent.h>
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-
-
-void
-camel_mbox_save_summary (CamelMboxSummary *summary, const gchar *filename, CamelException *ex)
-{
- CamelMboxSummaryInformation *msg_info;
- guint cur_msg;
- guint field_lgth;
- gint fd;
- gint write_result;
-
- CAMEL_LOG_FULL_DEBUG ("CamelMboxFolder::save_summary entering \n");
-
- fd = open (filename,
- O_WRONLY | O_CREAT | O_TRUNC,
- S_IRUSR | S_IWUSR);
- if (fd == -1) {
- camel_exception_setv (ex,
- CAMEL_EXCEPTION_FOLDER_INSUFFICIENT_PERMISSION,
- "could not create the mbox summary file\n"
- "\t%s\n"
- "Full error is : %s\n",
- filename,
- strerror (errno));
- return;
- }
-
- /* compute and write the mbox file md5 signature */
- //md5_get_digest_from_file (filename, summary->md5_digest);
-
- /* write the number of messages + the md5 signatures
- + next UID + mbox file size */
- write_result = write (fd, summary, G_STRUCT_OFFSET (CamelMboxSummary, message_info));
-
-
- for (cur_msg=0; cur_msg < summary->nb_message; cur_msg++) {
-
- msg_info = (CamelMboxSummaryInformation *)(summary->message_info->data) + cur_msg;
-
- /* write message position + message size
- + x-evolution offset + uid + status */
- write (fd, (gchar *)msg_info,
- sizeof (guint32) + 2 * sizeof (guint) +
- sizeof (guint32) + sizeof (guchar));
-
- /* write subject */
- field_lgth = msg_info->subject ? strlen (msg_info->subject) : 0;
- write (fd, &field_lgth, sizeof (guint));
- if (field_lgth)
- write (fd, msg_info->subject, field_lgth);
- /* write sender */
- field_lgth = msg_info->sender ? strlen (msg_info->sender) : 0;
- write (fd, &field_lgth, sizeof (gint));
- if (field_lgth)
- write (fd, msg_info->sender, field_lgth);
-
- /* write to */
- field_lgth = msg_info->to ? strlen (msg_info->to) : 0;
- write (fd, &field_lgth, sizeof (gint));
- if (field_lgth)
- write (fd, msg_info->to, field_lgth);
-
- /* write date */
- field_lgth = msg_info->date ? strlen (msg_info->date) : 0;
- write (fd, &field_lgth, sizeof (guint));
- if (field_lgth)
- write (fd, msg_info->date, field_lgth);
-
-
- }
-
- close (fd);
-
- CAMEL_LOG_FULL_DEBUG ("CamelMboxFolder::save_summary leaving \n");
-}
-
-
-
-
-
-CamelMboxSummary *
-camel_mbox_load_summary (const gchar *filename, CamelException *ex)
-{
- CamelMboxSummaryInformation *msg_info;
- guint cur_msg;
- guint field_lgth;
- gint fd;
- CamelMboxSummary *summary;
- gint read_result;
-
- CAMEL_LOG_FULL_DEBUG ("CamelMboxFolder::save_summary entering \n");
-
- fd = open (filename, O_RDONLY);
- if (fd == -1) {
- camel_exception_setv (ex,
- CAMEL_EXCEPTION_FOLDER_INSUFFICIENT_PERMISSION,
- "could not open the mbox summary file\n"
- "\t%s\n"
- "Full error is : %s\n",
- filename,
- strerror (errno));
- return NULL;
- }
- summary = g_new0 (CamelMboxSummary, 1);
-
- /* read the message number, the md5 signature
- and the next available UID + mbox file size */
- read_result = read (fd, summary, G_STRUCT_OFFSET (CamelMboxSummary, message_info));
-
-
- summary->message_info = g_array_new (FALSE, FALSE, sizeof (CamelMboxSummaryInformation));
- summary->message_info = g_array_set_size (summary->message_info, summary->nb_message);
-
-
- for (cur_msg=0; cur_msg < summary->nb_message; cur_msg++) {
-
- msg_info = (CamelMboxSummaryInformation *)(summary->message_info->data) + cur_msg;
-
- /* read message position + message size
- + x-evolution offset + uid + status */
- read (fd, (gchar *)msg_info,
- sizeof (guint32) + 2 * sizeof (guint) +
- sizeof (guint32) + sizeof (guchar));
-
-
- /* read the subject */
- read (fd, &field_lgth, sizeof (gint));
- if (field_lgth > 0) {
- msg_info->subject = g_new0 (gchar, field_lgth + 1);
- read (fd, msg_info->subject, field_lgth);
- } else
- msg_info->subject = NULL;
-
- /* read the sender */
- read (fd, &field_lgth, sizeof (gint));
- if (field_lgth > 0) {
- msg_info->sender = g_new0 (gchar, field_lgth + 1);
- read (fd, msg_info->sender, field_lgth);
- } else
- msg_info->sender = NULL;
-
- /* read the "to" field */
- read (fd, &field_lgth, sizeof (gint));
- if (field_lgth > 0) {
- msg_info->to = g_new0 (gchar, field_lgth + 1);
- read (fd, msg_info->to, field_lgth);
- } else
- msg_info->to = NULL;
-
- /* read the "date" field */
- read (fd, &field_lgth, sizeof (gint));
- if (field_lgth > 0) {
- msg_info->date = g_new0 (gchar, field_lgth + 1);
- read (fd, msg_info->date, field_lgth);
- } else
- msg_info->date = NULL;
-
-
-
-
- }
-
- close (fd);
- return summary;
-}
-
-
-
-
-
-
-
-
-
-gboolean
-camel_mbox_check_summary_sync (gchar *summary_filename,
- gchar *mbox_filename,
- CamelException *ex)
-
-{
- gint fd;
- guchar summary_md5[16];
- guchar real_md5[16];
-
-
- CAMEL_LOG_FULL_DEBUG ("CamelMboxFolder::save_summary entering \n");
-
- fd = open (summary_filename, O_RDONLY);
- if (fd == -1) {
- camel_exception_setv (ex,
- CAMEL_EXCEPTION_FOLDER_INSUFFICIENT_PERMISSION,
- "could not open the mbox summary file\n"
- "\t%s\n"
- "Full error is : %s\n",
- summary_filename,
- strerror (errno));
- return FALSE;
- }
-
- /* skip the message number field */
- lseek (fd, sizeof (guint), SEEK_SET);
-
- /* read the md5 signature stored in the summary file */
- read (fd, summary_md5, sizeof (guchar) * 16);
- close (fd);
- /* ** FIXME : check for exception in all these operations */
-
- /* compute the actual md5 signature on the
- mbox file */
- md5_get_digest_from_file (mbox_filename, real_md5);
-
- return (strncmp (real_md5, summary_md5, 16) == 0);
-}
-
-
-
-
-
-void
-camel_mbox_summary_append_entries (CamelMboxSummary *summary, GArray *entries)
-{
-
- summary->message_info = g_array_append_vals (summary->message_info, entries->data, entries->len);
-
-}
-
-
-
-
-
-void
-camel_mbox_summary_append_internal_to_external (CamelMboxSummary *internal,
- CamelFolderSummary *external,
- guint first_entry)
-{
- GArray *internal_array;
- GArray *external_array;
-
- CamelMessageInfo external_entry;
- CamelMboxSummaryInformation *internal_entry;
-
- int i;
-
-
- internal_array = internal->message_info;
- external_array = external->message_info_list;
-
- /* we don't set any extra fields */
- external_entry.extended_fields = NULL;
-
-
- for (i=first_entry; i<internal_array->len; i++) {
- internal_entry = (CamelMboxSummaryInformation *)(internal_array->data) + i;
-
- external_entry.subject = internal_entry->subject ? strdup (internal_entry->subject) : NULL;
- external_entry.uid = g_strdup_printf ("%u", internal_entry->uid);
- external_entry.date = internal_entry->date ? strdup (internal_entry->date) : NULL;
- external_entry.sender = internal_entry->sender ? strdup (internal_entry->sender) : NULL;
-
- g_array_append_vals (external_array, &external_entry, 1);
-
- }
-
-
-}
diff --git a/camel/providers/mbox/camel-mbox-summary.h b/camel/providers/mbox/camel-mbox-summary.h
deleted file mode 100644
index af64ff7cf5..0000000000
--- a/camel/providers/mbox/camel-mbox-summary.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-/*
- *
- * Author : Bertrand Guiheneuf <bertrand@helixcode.com>
- *
- * Copyright (C) 1999 Helix Code (http://www.helixcode.com).
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-
-#ifndef MBOX_SUMMARY_H
-#define MBOX_SUMMARY_H 1
-
-#include <glib.h>
-
-
-
-typedef struct {
-
- guint32 position;
- guint size;
- guint x_evolution_offset;
- guint32 uid;
- guchar status;
- gchar *subject;
- gchar *sender;
- gchar *to;
- gchar *date;
-
-} CamelMboxSummaryInformation;
-
-
-typedef struct {
-
- guint nb_message; /* number of messages in the summary */
- guchar md5_digest[16]; /* md5 signature of the mbox file */
- guint32 next_uid;
- guint32 mbox_file_size;
-
- GArray *message_info; /* array of CamelMboxSummaryInformation */
-
-} CamelMboxSummary;
-
-
-void
-camel_mbox_save_summary (CamelMboxSummary *summary, const gchar *filename, CamelException *ex);
-
-CamelMboxSummary *
-camel_mbox_load_summary (const gchar *filename, CamelException *ex);
-
-gboolean
-camel_mbox_check_summary_sync (gchar *summary_filename,
- gchar *mbox_filename,
- CamelException *ex);
-
-void
-camel_mbox_summary_append_entries (CamelMboxSummary *summary, GArray *entries);
-
-
-
-void
-camel_mbox_summary_append_internal_to_external (CamelMboxSummary *internal,
- CamelFolderSummary *external,
- guint first_entry);
-
-
-#endif /* MH_SUMMARY_H */
diff --git a/camel/providers/mbox/camel-mbox-utils.c b/camel/providers/mbox/camel-mbox-utils.c
deleted file mode 100644
index 64fb4cb283..0000000000
--- a/camel/providers/mbox/camel-mbox-utils.c
+++ /dev/null
@@ -1,385 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* Various utilities for the mbox provider */
-
-/*
- * Authors :
- * Bertrand Guiheneuf <bertrand@helixcode.com>
- *
- * Copyright (C) 1999 Helix Code.
- *
- * 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
- */
-
-
-/* "xev" stands for x-evolution, which is the name of the
- * evolution specific header where are stored informations
- * like :
- * - mail status
- * - mail uid
- * ...
- *
- *
- * The evolution line has the following format :
- *
- * X-Evolution:XXXXX-X
- * \___/ \/
- * UID ---' `- Status
- *
- * the UID is internally used as a 32 bits long integer, but only the first 24 bits are
- * used. The UID is coded as a string on 4 characters. Each character is a 6 bits
- * integer coded using the b64 alphabet.
- *
- */
-
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <errno.h>
-#include <string.h>
-
-
-#include <glib.h>
-#include "camel-mbox-utils.h"
-#include "camel-mbox-parser.h"
-#include "camel-folder-summary.h"
-#include "camel-mbox-summary.h"
-
-
-
-static gchar b64_alphabet[64] =
-"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
-
-
-
-static void
-uid_to_string (guint32 uid, gchar string[4])
-{
-
- string [0] = b64_alphabet [(uid >> 18) & 0x3f];
- string [1] = b64_alphabet [(uid >> 12) & 0x3f];
- string [2] = b64_alphabet [(uid >> 6) & 0x3f];
- string [3] = b64_alphabet [(uid ) & 0x3f];
-}
-
-
-static guint32
-string_to_uid (gchar *string)
-{
- guint32 i;
-
- i =
- (((string [0] >= 97) ? ( string [0] - 71 ) :
- ((string [0] >= 65) ? ( string [0] - 65 ) :
- ((string [0] >= 48) ? ( string [0] + 4 ) :
- ((string [0] == 43) ? 62 : 63 )))) << 18)
-
- + (((string [1] >= 97) ? ( string [1] - 71 ) :
- ((string [1] >= 65) ? ( string [1] - 65 ) :
- ((string [1] >= 48) ? ( string [1] + 4 ) :
- ((string [1] == 43) ? 62 : 63 )))) << 12)
-
-
- + ((((string [2] >= 97) ? ( string [2] - 71 ) :
- ((string [2] >= 65) ? ( string [2] - 65 ) :
- ((string [2] >= 48) ? ( string [2] + 4 ) :
- ((string [2] == 43) ? 62 : 63 ))))) << 6)
-
-
- + (((string [3] >= 97) ? ( string [3] - 71 ) :
- ((string [3] >= 65) ? ( string [3] - 65 ) :
- ((string [3] >= 48) ? ( string [3] + 4 ) :
- ((string [3] == 43) ? 62 : 63 )))));
-
- return i;
-
-}
-
-
-static gchar
-flag_to_string (guchar status)
-{
- return b64_alphabet [status & 0x3f];
-}
-
-
-static guchar
-string_to_flag (gchar string)
-{
- return (string >= 97) ? ( string - 71 ) :
- ((string >= 65) ? ( string - 65 ) :
- ((string >= 48) ? ( string + 4 ) :
- ((string == 43) ? 62 : 63 )));
-}
-
-
-
-
-
-void
-camel_mbox_xev_parse_header_content (gchar header_content[6],
- guint32 *uid,
- guchar *status)
-{
-
- /* we assume that the first 4 characters of the header content
- are actually the uid stuff. If somebody messed with it ...
- toooo bad.
- */
- *uid = string_to_uid (header_content);
- *status = string_to_flag (header_content[5]);
-}
-
-void
-camel_mbox_xev_write_header_content (gchar header_content[6],
- guint32 uid,
- guchar status)
-{
- uid_to_string (uid, header_content);
- header_content[5] = flag_to_string (status);
- header_content[4] = '-';
-}
-
-
-
-
-
-
-void
-camel_mbox_copy_file_chunk (gint fd_src,
- gint fd_dest,
- glong nb_bytes,
- CamelException *ex)
-{
- gchar buffer [1000];
- glong nb_to_read;
- glong nb_read, v;
-
- nb_to_read = nb_bytes;
- while (nb_to_read > 0) {
-
- do {
- nb_read = read (fd_src, buffer, MIN (1000, nb_to_read));
- } while (nb_read == -1 && errno == EINTR);
-
- if (nb_read == -1) {
- camel_exception_set (ex,
- CAMEL_EXCEPTION_FOLDER_INSUFFICIENT_PERMISSION,
- "could read from the mbox file");
- return;
- }
-
-
- nb_to_read -= nb_read;
-
- do {
- v = write (fd_dest, buffer, nb_read);
- } while (v == -1 && errno == EINTR);
-
- if (v == -1) {
- camel_exception_setv (ex,
- CAMEL_EXCEPTION_FOLDER_INSUFFICIENT_PERMISSION,
- "could not write to the mbox copy file\n"
- "Full error is : %s\n",
- strerror (errno));
- return;
- }
-
-
- }
-
-
-
-}
-
-
-guint32
-camel_mbox_write_xev (gchar *mbox_file_name,
- GArray *summary_information,
- guint32 *file_size,
- guint32 next_uid,
- CamelException *ex)
-{
- gint cur_msg;
- CamelMboxParserMessageInfo *cur_msg_info;
- gint fd1, fd2;
- guint bytes_to_copy = 0;
- glong cur_pos = 0;
- glong cur_offset = 0;
- glong end_of_last_message;
- glong next_free_uid;
- gchar xev_header[20] = "X-Evolution:XXXX-X\n";
- gchar *tmp_file_name;
- gchar *tmp_file_name_secure;
- gint rename_result;
- gint unlink_result;
-
- tmp_file_name = g_strdup_printf ("%s__.ev_tmp", mbox_file_name);
- tmp_file_name_secure = g_strdup_printf ("%s__.ev_tmp_secure", mbox_file_name);
-
- fd1 = open (mbox_file_name, O_RDONLY);
- fd2 = open (tmp_file_name,
- O_WRONLY | O_CREAT | O_TRUNC ,
- S_IRUSR | S_IWUSR);
-
- if (fd2 == -1) {
- camel_exception_setv (ex,
- CAMEL_EXCEPTION_FOLDER_INSUFFICIENT_PERMISSION,
- "could not create the temporary mbox copy file\n"
- "\t%s\n"
- "Full error is : %s\n",
- tmp_file_name,
- strerror (errno));
- return next_uid;
- }
-
- next_free_uid = next_uid;
- for (cur_msg = 0; cur_msg < summary_information->len; cur_msg++) {
-
- cur_msg_info = (CamelMboxParserMessageInfo *)(summary_information->data) + cur_msg;
- end_of_last_message = cur_msg_info->message_position + cur_msg_info->size;
-
- if (cur_msg_info->uid == 0) {
-
- bytes_to_copy = cur_msg_info->message_position
- + cur_msg_info->end_of_headers_offset
- - cur_pos;
-
- cur_pos = cur_msg_info->message_position
- + cur_msg_info->end_of_headers_offset;
-
- camel_mbox_copy_file_chunk (fd1, fd2, bytes_to_copy, ex);
- if (camel_exception_get_id (ex)) {
- close (fd1);
- close (fd2);
- goto end;
- }
-
- cur_msg_info->uid = next_free_uid;
- cur_msg_info->status = 0;
- camel_mbox_xev_write_header_content (xev_header + 12, next_free_uid, 0);
- next_free_uid++;
- write (fd2, xev_header, 19);
- cur_offset += 19;
- cur_msg_info->size += 19;
- cur_msg_info->x_evolution_offset = cur_msg_info->end_of_headers_offset;
- cur_msg_info->x_evolution = g_strdup_printf ("%.6s", xev_header + 12);
- cur_msg_info->end_of_headers_offset += 19;
- *file_size += 19;
- }
- cur_msg_info->message_position += cur_offset;
- }
-
-
- bytes_to_copy = end_of_last_message - cur_pos;
- camel_mbox_copy_file_chunk (fd1, fd2, bytes_to_copy, ex);
-
-
- /* close the original file as well as the
- newly created one */
- close (fd1);
- close (fd2);
-
-
-
- /* replace the mbox file with the temporary
- file we just created */
-
- /* first rename the old mbox file to a temporary file */
- rename_result = rename (mbox_file_name, tmp_file_name_secure);
- if (rename_result == -1) {
- camel_exception_set (ex,
- CAMEL_EXCEPTION_FOLDER_INSUFFICIENT_PERMISSION,
- "could not rename the mbox file to a temporary file");
- goto end;
- }
-
- /* then rename the newly created mbox file to the name
- of the original one */
- rename_result = rename (tmp_file_name, mbox_file_name);
- if (rename_result == -1) {
- camel_exception_set (ex,
- CAMEL_EXCEPTION_FOLDER_INSUFFICIENT_PERMISSION,
- "could not rename the X-Evolution fed file to the mbox file");
- goto end;
- }
-
- /* finally, remove the old renamed mbox file */
- unlink_result = unlink (tmp_file_name_secure);
- if (unlink_result == -1) {
- camel_exception_set (ex,
- CAMEL_EXCEPTION_FOLDER_INSUFFICIENT_PERMISSION,
- "could not remove the saved original mbox file");
- goto end;
- }
-
-
- end: /* free everything and return */
-
- g_free (tmp_file_name);
- g_free (tmp_file_name_secure);
- return next_free_uid;
-}
-
-
-
-
-
-
-GArray *
-parsed_information_to_mbox_summary (GArray *parsed_information)
-{
- guint cur_msg;
- CamelMboxParserMessageInfo *cur_msg_info;
- GArray *mbox_summary;
- CamelMboxSummaryInformation *cur_sum_info;
-
- mbox_summary = g_array_new (FALSE, FALSE, sizeof (CamelMboxSummaryInformation));
- mbox_summary = g_array_set_size (mbox_summary, parsed_information->len);
-
- for (cur_msg = 0; cur_msg < parsed_information->len; cur_msg++) {
-
- cur_msg_info = (CamelMboxParserMessageInfo *)(parsed_information->data) + cur_msg;
- cur_sum_info = (CamelMboxSummaryInformation *)(mbox_summary->data) + cur_msg;
-
- cur_sum_info->position = cur_msg_info->message_position;
-
- cur_sum_info->size = cur_msg_info->size;
-
- cur_sum_info->x_evolution_offset = cur_msg_info->x_evolution_offset;
-
- cur_sum_info->uid = cur_msg_info->uid;
-
- cur_sum_info->status = cur_msg_info->status;
-
- cur_sum_info->subject = cur_msg_info->subject;
- cur_msg_info->subject = NULL;
-
- cur_sum_info->sender = cur_msg_info->from;
- cur_msg_info->from = NULL;
-
- cur_sum_info->to = cur_msg_info->to;
- cur_msg_info->to = NULL;
-
- cur_sum_info->date = cur_msg_info->date;
- cur_msg_info->date = NULL;
-
- }
-
- return mbox_summary;
-}
diff --git a/camel/providers/mbox/camel-mbox-utils.h b/camel/providers/mbox/camel-mbox-utils.h
deleted file mode 100644
index 062a284b03..0000000000
--- a/camel/providers/mbox/camel-mbox-utils.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* Various utilities for the mbox provider */
-
-/*
- * Authors :
- * Bertrand Guiheneuf <bertrand@helixcode.com>
- *
- * Copyright (C) 1999 Helix Code.
- *
- * 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_MBOX_UTILS_H
-#define CAMEL_MBOX_UTILS_H 1
-
-
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* __cplusplus }*/
-
-
-#include "camel-exception.h"
-
-void
-camel_mbox_xev_parse_header_content (gchar header_content[6],
- guint32 *uid,
- guchar *status);
-
-void
-camel_mbox_xev_write_header_content (gchar header_content[6],
- guint32 uid,
- guchar status);
-
-guint32
-camel_mbox_write_xev (gchar *mbox_file_name,
- GArray *summary_information,
- guint32 *file_size,
- guint32 last_uid,
- CamelException *ex);
-
-GArray *
-parsed_information_to_mbox_summary (GArray *parsed_information);
-
-void
-camel_mbox_copy_file_chunk (gint fd_src,
- gint fd_dest,
- glong nb_bytes,
- CamelException *ex);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* CAMEL_MBOX_UTILS_H */