From b5f82e57fa8f5cc4538d3fd5e88cef6409265e0b Mon Sep 17 00:00:00 2001 From: nobody Date: Sun, 21 May 2000 22:40:15 +0000 Subject: This commit was manufactured by cvs2svn to create tag 'GNOME_APPLETS_1_2_0'. svn path=/tags/GNOME_APPLETS_1_2_0/; revision=3153 --- camel/providers/.cvsignore | 2 - camel/providers/MH/.cvsignore | 6 - camel/providers/MH/Makefile.am | 34 - camel/providers/MH/camel-mh-folder.c | 1022 -------------------- camel/providers/MH/camel-mh-folder.h | 72 -- camel/providers/MH/camel-mh-provider.c | 46 - camel/providers/MH/camel-mh-store.c | 153 --- camel/providers/MH/camel-mh-store.h | 72 -- camel/providers/MH/mh-summary.c | 290 ------ camel/providers/MH/mh-summary.h | 33 - camel/providers/MH/mh-uid.c | 220 ----- camel/providers/MH/mh-uid.h | 40 - camel/providers/MH/mh-utils.c | 50 - camel/providers/MH/mh-utils.h | 30 - camel/providers/Makefile.am | 6 - camel/providers/maildir/.cvsignore | 6 - camel/providers/maildir/Makefile.am | 24 - camel/providers/maildir/camel-maildir-folder.c | 802 --------------- camel/providers/maildir/camel-maildir-folder.h | 66 -- camel/providers/maildir/camel-maildir-provider.c | 46 - camel/providers/maildir/camel-maildir-store.c | 124 --- camel/providers/maildir/camel-maildir-store.h | 69 -- camel/providers/mbox/.cvsignore | 7 - camel/providers/mbox/Makefile.am | 41 - camel/providers/mbox/camel-mbox-folder.c | 855 ---------------- camel/providers/mbox/camel-mbox-folder.h | 81 -- camel/providers/mbox/camel-mbox-provider.c | 50 - camel/providers/mbox/camel-mbox-store.c | 129 --- camel/providers/mbox/camel-mbox-store.h | 69 -- camel/providers/mbox/camel-mbox-summary.c | 740 -------------- camel/providers/mbox/camel-mbox-summary.h | 78 -- camel/providers/mbox/libcamelmbox.urls | 1 - camel/providers/nntp/.cvsignore | 7 - camel/providers/nntp/Makefile.am | 31 - camel/providers/nntp/camel-nntp-folder.c | 617 ------------ camel/providers/nntp/camel-nntp-folder.h | 73 -- camel/providers/nntp/camel-nntp-provider.c | 69 -- camel/providers/nntp/camel-nntp-store.c | 486 ---------- camel/providers/nntp/camel-nntp-store.h | 85 -- camel/providers/nntp/camel-nntp-utils.c | 211 ---- camel/providers/nntp/camel-nntp-utils.h | 42 - camel/providers/nntp/libcamelnntp.urls | 2 - camel/providers/pop3/.cvsignore | 6 - camel/providers/pop3/Makefile.am | 35 - camel/providers/pop3/camel-pop3-folder.c | 271 ------ camel/providers/pop3/camel-pop3-folder.h | 73 -- camel/providers/pop3/camel-pop3-provider.c | 51 - camel/providers/pop3/camel-pop3-store.c | 612 ------------ camel/providers/pop3/camel-pop3-store.h | 81 -- camel/providers/pop3/libcamelpop3.urls | 1 - camel/providers/sendmail/.cvsignore | 7 - camel/providers/sendmail/Makefile.am | 31 - camel/providers/sendmail/camel-sendmail-provider.c | 53 - .../providers/sendmail/camel-sendmail-transport.c | 212 ---- .../providers/sendmail/camel-sendmail-transport.h | 64 -- camel/providers/sendmail/libcamelsendmail.urls | 1 - camel/providers/smtp/.cvsignore | 6 - camel/providers/smtp/Makefile.am | 32 - camel/providers/smtp/camel-smtp-provider.c | 53 - camel/providers/smtp/camel-smtp-transport.c | 735 -------------- camel/providers/smtp/camel-smtp-transport.h | 68 -- camel/providers/smtp/libcamelsmtp.urls | 1 - camel/providers/vee/Makefile.am | 39 - camel/providers/vee/camel-vee-folder.c | 423 -------- camel/providers/vee/camel-vee-folder.h | 58 -- camel/providers/vee/camel-vee-provider.c | 45 - camel/providers/vee/camel-vee-store.c | 132 --- camel/providers/vee/camel-vee-store.h | 48 - camel/providers/vee/libcamelvee.urls | 1 - 69 files changed, 10026 deletions(-) delete mode 100644 camel/providers/.cvsignore delete mode 100644 camel/providers/MH/.cvsignore delete mode 100644 camel/providers/MH/Makefile.am delete mode 100644 camel/providers/MH/camel-mh-folder.c delete mode 100644 camel/providers/MH/camel-mh-folder.h delete mode 100644 camel/providers/MH/camel-mh-provider.c delete mode 100644 camel/providers/MH/camel-mh-store.c delete mode 100644 camel/providers/MH/camel-mh-store.h delete mode 100644 camel/providers/MH/mh-summary.c delete mode 100644 camel/providers/MH/mh-summary.h delete mode 100644 camel/providers/MH/mh-uid.c delete mode 100644 camel/providers/MH/mh-uid.h delete mode 100644 camel/providers/MH/mh-utils.c delete mode 100644 camel/providers/MH/mh-utils.h delete mode 100644 camel/providers/Makefile.am delete mode 100644 camel/providers/maildir/.cvsignore delete mode 100644 camel/providers/maildir/Makefile.am delete mode 100644 camel/providers/maildir/camel-maildir-folder.c delete mode 100644 camel/providers/maildir/camel-maildir-folder.h delete mode 100644 camel/providers/maildir/camel-maildir-provider.c delete mode 100644 camel/providers/maildir/camel-maildir-store.c delete mode 100644 camel/providers/maildir/camel-maildir-store.h delete mode 100644 camel/providers/mbox/.cvsignore delete mode 100644 camel/providers/mbox/Makefile.am delete mode 100644 camel/providers/mbox/camel-mbox-folder.c delete mode 100644 camel/providers/mbox/camel-mbox-folder.h delete mode 100644 camel/providers/mbox/camel-mbox-provider.c delete mode 100644 camel/providers/mbox/camel-mbox-store.c delete mode 100644 camel/providers/mbox/camel-mbox-store.h delete mode 100644 camel/providers/mbox/camel-mbox-summary.c delete mode 100644 camel/providers/mbox/camel-mbox-summary.h delete mode 100644 camel/providers/mbox/libcamelmbox.urls delete mode 100644 camel/providers/nntp/.cvsignore delete mode 100644 camel/providers/nntp/Makefile.am delete mode 100644 camel/providers/nntp/camel-nntp-folder.c delete mode 100644 camel/providers/nntp/camel-nntp-folder.h delete mode 100644 camel/providers/nntp/camel-nntp-provider.c delete mode 100644 camel/providers/nntp/camel-nntp-store.c delete mode 100644 camel/providers/nntp/camel-nntp-store.h delete mode 100644 camel/providers/nntp/camel-nntp-utils.c delete mode 100644 camel/providers/nntp/camel-nntp-utils.h delete mode 100644 camel/providers/nntp/libcamelnntp.urls delete mode 100644 camel/providers/pop3/.cvsignore delete mode 100644 camel/providers/pop3/Makefile.am delete mode 100644 camel/providers/pop3/camel-pop3-folder.c delete mode 100644 camel/providers/pop3/camel-pop3-folder.h delete mode 100644 camel/providers/pop3/camel-pop3-provider.c delete mode 100644 camel/providers/pop3/camel-pop3-store.c delete mode 100644 camel/providers/pop3/camel-pop3-store.h delete mode 100644 camel/providers/pop3/libcamelpop3.urls delete mode 100644 camel/providers/sendmail/.cvsignore delete mode 100644 camel/providers/sendmail/Makefile.am delete mode 100644 camel/providers/sendmail/camel-sendmail-provider.c delete mode 100644 camel/providers/sendmail/camel-sendmail-transport.c delete mode 100644 camel/providers/sendmail/camel-sendmail-transport.h delete mode 100644 camel/providers/sendmail/libcamelsendmail.urls delete mode 100644 camel/providers/smtp/.cvsignore delete mode 100644 camel/providers/smtp/Makefile.am delete mode 100644 camel/providers/smtp/camel-smtp-provider.c delete mode 100644 camel/providers/smtp/camel-smtp-transport.c delete mode 100644 camel/providers/smtp/camel-smtp-transport.h delete mode 100644 camel/providers/smtp/libcamelsmtp.urls delete mode 100644 camel/providers/vee/Makefile.am delete mode 100644 camel/providers/vee/camel-vee-folder.c delete mode 100644 camel/providers/vee/camel-vee-folder.h delete mode 100644 camel/providers/vee/camel-vee-provider.c delete mode 100644 camel/providers/vee/camel-vee-store.c delete mode 100644 camel/providers/vee/camel-vee-store.h delete mode 100644 camel/providers/vee/libcamelvee.urls (limited to 'camel/providers') diff --git a/camel/providers/.cvsignore b/camel/providers/.cvsignore deleted file mode 100644 index 3dda72986f..0000000000 --- a/camel/providers/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -Makefile.in -Makefile 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 59662a07dd..0000000000 --- a/camel/providers/MH/Makefile.am +++ /dev/null @@ -1,34 +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 \ - -DG_LOG_DOMAIN=\"camel-mh-provider\" - -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 f4ff8f305a..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 . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#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 (); - 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; (ilen) && (!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; (ilen) && (!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 (); - 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; ilen; 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 . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#ifndef CAMEL_MH_FOLDER_H -#define CAMEL_MH_FOLDER_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include -#include "camel-folder.h" -/* #include "camel-store.h" */ - -#define CAMEL_MH_FOLDER_TYPE (camel_mh_folder_get_type ()) -#define CAMEL_MH_FOLDER(obj) (GTK_CHECK_CAST((obj), CAMEL_MH_FOLDER_TYPE, CamelMhFolder)) -#define CAMEL_MH_FOLDER_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_MH_FOLDER_TYPE, CamelMhFolderClass)) -#define IS_CAMEL_MH_FOLDER(o) (GTK_CHECK_TYPE((o), CAMEL_MH_FOLDER_TYPE)) - - -typedef struct { - CamelFolder parent_object; - - 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 . - * - * 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 . - * - * 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 . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#ifndef CAMEL_MH_STORE_H -#define CAMEL_MH_STORE_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include -#include "camel-store.h" - -#define CAMEL_MH_STORE_TYPE (camel_mh_store_get_type ()) -#define CAMEL_MH_STORE(obj) (GTK_CHECK_CAST((obj), CAMEL_MH_STORE_TYPE, CamelMhStore)) -#define CAMEL_MH_STORE_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_MH_STORE_TYPE, CamelMhStoreClass)) -#define IS_CAMEL_MH_STORE(o) (GTK_CHECK_TYPE((o), CAMEL_MH_STORE_TYPE)) - - -typedef struct { - CamelStore parent_object; - - 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 . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#include - -#include "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 -#include -#include -#include -#include -#include -#include -#include - -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_filelen; 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; ilen; 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 . - * - * 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 -#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 . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#include - -#include "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 -#include -#include -#include -#include -#include -#include -#include - -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; ilen; 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 . - * - * 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 -#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 . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#include -#include "mh-utils.h" - -#include - -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 . - * - * 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 - -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 c3829d39b2..0000000000 --- a/camel/providers/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -## Process this file with automake to produce Makefile.in - -SUBDIRS = mbox pop3 sendmail vee - -# these ones are disabled for the moment. -# MH maildir nntp smtp 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 07f05d443b..0000000000 --- a/camel/providers/maildir/Makefile.am +++ /dev/null @@ -1,24 +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) \ - -DG_LOG_DOMAIN=\"camel-maildir-provider\" - -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 2cb81f3e81..0000000000 --- a/camel/providers/maildir/camel-maildir-folder.c +++ /dev/null @@ -1,802 +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 . - * - * 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#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 */ - message = camel_mime_message_new (); - 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 . - * - * 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 -#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 . - * - * 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 . - * - * 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 . - * - * 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 -#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 defd6925cc..0000000000 --- a/camel/providers/mbox/Makefile.am +++ /dev/null @@ -1,41 +0,0 @@ -## Process this file with automake to produce Makefile.in - -SUBDIRS = - -libcamelmboxincludedir = $(includedir)/camel - - -providerdir = $(pkglibdir)/camel-providers/$(VERSION) - -provider_LTLIBRARIES = libcamelmbox.la -provider_DATA = libcamelmbox.urls - -INCLUDES = -I.. \ - -I$(srcdir)/.. \ - -I$(top_srcdir)/camel \ - -I$(top_srcdir)/intl \ - -I$(top_srcdir)/libibex \ - -I$(top_srcdir)/e-util \ - -I$(top_srcdir) \ - -I$(includedir) \ - $(GTK_INCLUDEDIR) \ - -DG_LOG_DOMAIN=\"camel-mbox-provider\" - -libcamelmbox_la_SOURCES = \ - camel-mbox-folder.c \ - camel-mbox-provider.c \ - camel-mbox-store.c \ - camel-mbox-summary.c - -libcamelmboxinclude_HEADERS = \ - camel-mbox-folder.h \ - camel-mbox-store.h \ - camel-mbox-summary.h - -libcamelmbox_la_LDFLAGS = -version-info 0:0:0 -rpath $(libdir) - -libcamelmbox_la_LIBADD = $(top_builddir)/e-util/libeutil.la $(top_builddir)/libibex/libibex.la $(UNICODE_LIBS) -#libcamelmbox_la_LIBADD = $(top_builddir)/libibex/libibex.la $(UNICODE_LIBS) - -EXTRA_DIST = libcamelmbox.urls - diff --git a/camel/providers/mbox/camel-mbox-folder.c b/camel/providers/mbox/camel-mbox-folder.c deleted file mode 100644 index ccf57f02b7..0000000000 --- a/camel/providers/mbox/camel-mbox-folder.c +++ /dev/null @@ -1,855 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; fill-column: 160 -*- */ -/* camel-mbox-folder.c : Abstract class for an email folder */ - -/* - * Authors: Bertrand Guiheneuf - * Michael Zucchi - * - * Copyright (C) 1999, 2000 Helix Code Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "camel-mbox-folder.h" -#include "camel-mbox-store.h" -#include "string-utils.h" -#include "camel-stream-fs.h" -#include "camel-mbox-summary.h" -#include "camel-data-wrapper.h" -#include "camel-mime-message.h" -#include "camel-stream-filter.h" -#include "camel-mime-filter-from.h" -#include "camel-exception.h" - -#define d(x) - -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 mbox_init (CamelFolder *folder, CamelStore *parent_store, - CamelFolder *parent_folder, const gchar *name, - gchar separator, CamelException *ex); - -static void mbox_open (CamelFolder *folder, CamelFolderOpenMode mode, CamelException *ex); -static void mbox_close (CamelFolder *folder, gboolean expunge, CamelException *ex); -static gboolean mbox_exists (CamelFolder *folder, CamelException *ex); -static gboolean mbox_create(CamelFolder *folder, CamelException *ex); -static gboolean mbox_delete (CamelFolder *folder, gboolean recurse, CamelException *ex); -static gboolean mbox_delete_messages (CamelFolder *folder, CamelException *ex); -static gint mbox_get_message_count (CamelFolder *folder, CamelException *ex); -static void mbox_append_message (CamelFolder *folder, CamelMimeMessage *message, CamelException *ex); -static GPtrArray *mbox_get_uids (CamelFolder *folder, CamelException *ex); -static GPtrArray *mbox_get_subfolder_names (CamelFolder *folder, CamelException *ex); -static GPtrArray *mbox_get_summary (CamelFolder *folder, CamelException *ex); -static void mbox_free_summary (CamelFolder *folder, GPtrArray *array); -static CamelMimeMessage *mbox_get_message_by_uid (CamelFolder *folder, const gchar *uid, CamelException *ex); - -static void mbox_expunge (CamelFolder *folder, CamelException *ex); -#if 0 -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 void mbox_delete_message_by_uid(CamelFolder *folder, const gchar *uid, CamelException *ex); - -static const CamelMessageInfo *mbox_summary_get_by_uid(CamelFolder *f, const char *uid); - -static GList *mbox_search_by_expression(CamelFolder *folder, const char *expression, CamelException *ex); - -static void mbox_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 = mbox_init; - camel_folder_class->open = mbox_open; - camel_folder_class->close = mbox_close; - camel_folder_class->exists = mbox_exists; - camel_folder_class->create = mbox_create; - camel_folder_class->delete = mbox_delete; - camel_folder_class->delete_messages = mbox_delete_messages; - camel_folder_class->get_message_count = mbox_get_message_count; - camel_folder_class->append_message = mbox_append_message; - camel_folder_class->get_uids = mbox_get_uids; - camel_folder_class->get_subfolder_names = mbox_get_subfolder_names; - camel_folder_class->get_summary = mbox_get_summary; - camel_folder_class->free_summary = mbox_free_summary; - camel_folder_class->expunge = mbox_expunge; - - camel_folder_class->get_message_by_uid = mbox_get_message_by_uid; - camel_folder_class->delete_message_by_uid = mbox_delete_message_by_uid; - - camel_folder_class->search_by_expression = mbox_search_by_expression; - - camel_folder_class->summary_get_by_uid = mbox_summary_get_by_uid; - - gtk_object_class->finalize = mbox_finalize; - -} - -static void -mbox_finalize (GtkObject *object) -{ - CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER (object); - - g_free (mbox_folder->folder_file_path); - g_free (mbox_folder->folder_dir_path); - - GTK_OBJECT_CLASS (parent_class)->finalize (object); -} - -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 -mbox_init (CamelFolder *folder, CamelStore *parent_store, - CamelFolder *parent_folder, const gchar *name, gchar separator, - CamelException *ex) -{ - CamelMboxFolder *mbox_folder = (CamelMboxFolder *)folder; - const gchar *root_dir_path; - - /* call parent method */ - parent_class->init (folder, parent_store, parent_folder, - name, separator, ex); - if (camel_exception_get_id (ex)) - return; - - /* we assume that the parent init - method checks for the existance of @folder */ - folder->can_hold_messages = TRUE; - folder->can_hold_folders = TRUE; - folder->has_summary_capability = TRUE; - folder->has_search_capability = TRUE; - - folder->permanent_flags = CAMEL_MESSAGE_ANSWERED | - CAMEL_MESSAGE_DELETED | - CAMEL_MESSAGE_DRAFT | - CAMEL_MESSAGE_FLAGGED | - CAMEL_MESSAGE_SEEN | - CAMEL_MESSAGE_USER; - - mbox_folder->summary = NULL; - mbox_folder->search = NULL; - - /* now set the name info */ - g_free (mbox_folder->folder_file_path); - g_free (mbox_folder->folder_dir_path); - g_free (mbox_folder->index_file_path); - - root_dir_path = camel_mbox_store_get_toplevel_dir (CAMEL_MBOX_STORE(folder->parent_store)); - - mbox_folder->folder_file_path = g_strdup_printf ("%s/%s", root_dir_path, folder->full_name); - mbox_folder->summary_file_path = g_strdup_printf ("%s/%s-ev-summary", root_dir_path, folder->full_name); - mbox_folder->folder_dir_path = g_strdup_printf ("%s/%s.sdb", root_dir_path, folder->full_name); - mbox_folder->index_file_path = g_strdup_printf ("%s/%s.ibex", root_dir_path, folder->full_name); -} - -static void -mbox_open (CamelFolder *folder, CamelFolderOpenMode mode, CamelException *ex) -{ - CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER (folder); - int forceindex; - struct stat st; - - /* call parent class */ - parent_class->open (folder, mode, ex); - if (camel_exception_get_id(ex)) - return; - - /* if we have no index file, force it */ - forceindex = stat(mbox_folder->index_file_path, &st) == -1; - - printf("loading ibex\n"); - mbox_folder->index = ibex_open(mbox_folder->index_file_path, O_CREAT|O_RDWR, 0600); - printf("loaded ibex\n"); - if (mbox_folder->index == NULL) { - /* yes, this isn't fatal at all */ - g_warning("Could not open/create index file: %s: indexing not performed", - strerror(errno)); - } - - /* no summary (disk or memory), and we're proverbially screwed */ - printf("loading summary\n"); - mbox_folder->summary = camel_mbox_summary_new(mbox_folder->summary_file_path, mbox_folder->folder_file_path, mbox_folder->index); - if (mbox_folder->summary == NULL - || camel_mbox_summary_load(mbox_folder->summary, forceindex) == -1) { - camel_exception_set (ex, - CAMEL_EXCEPTION_FOLDER_INVALID, /* FIXME: right error code */ - "Could not create summary"); - return; - } - printf("summary loaded\n"); -} - -static void -mbox_close (CamelFolder *folder, gboolean expunge, CamelException *ex) -{ - CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER (folder); - - /* call parent implementation */ - parent_class->close (folder, expunge, ex); - - if (expunge) { - mbox_expunge(folder, ex); - } - - /* save index */ - if (mbox_folder->index) { - ibex_close(mbox_folder->index); - mbox_folder->index = NULL; - } - if (mbox_folder->summary) { - camel_folder_summary_save ((CamelFolderSummary *)mbox_folder->summary); - gtk_object_unref((GtkObject *)mbox_folder->summary); - mbox_folder->summary = NULL; - } - if (mbox_folder->search) { - gtk_object_unref((GtkObject *)mbox_folder->search); - mbox_folder->search = NULL; - } -} - -static void -mbox_expunge (CamelFolder *folder, CamelException *ex) -{ - CamelMboxFolder *mbox = (CamelMboxFolder *)folder; - - if (camel_mbox_summary_expunge(mbox->summary) == -1) { - camel_exception_setv (ex, CAMEL_EXCEPTION_FOLDER_INVALID, /* FIXME: right error code */ - "Could not expunge: %s", strerror(errno)); - } - - /* TODO: check it actually changed */ - gtk_signal_emit_by_name((GtkObject *)folder, "folder_changed", 0); -} - -/* FIXME: clean up this snot */ -static gboolean -mbox_exists (CamelFolder *folder, CamelException *ex) -{ - CamelMboxFolder *mbox_folder; - struct stat stat_buf; - gint stat_error; - gboolean exists; - - g_assert(folder != NULL); - - mbox_folder = CAMEL_MBOX_FOLDER (folder); - - /* 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_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_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 */ - - return exists; -} - -/* FIXME: clean up this snot */ -static gboolean -mbox_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; - - g_assert(folder != NULL); - - /* 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_dir_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 */ - creat_fd = open (folder_file_path, - O_WRONLY | O_CREAT | O_APPEND, - 0600); - if (creat_fd == -1) - goto io_error; - - close (creat_fd); - - return TRUE; - - /* exception handling for io errors */ - io_error : - 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; - } -} - - -/* FIXME: cleanup */ -static gboolean -mbox_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; - - g_assert(folder != NULL); - - /* check if the folder object exists */ - - /* 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 */ - 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; -} - -/* TODO: remove this */ -gboolean -mbox_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; - g_assert(folder!=NULL); - - /* 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 */ - creat_fd = open (folder_file_path, - O_WRONLY | O_TRUNC, - 0600); - if (creat_fd == -1) - goto io_error; - close (creat_fd); - - return TRUE; - - /* exception handling for io errors */ - io_error : - 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 gint -mbox_get_message_count (CamelFolder *folder, CamelException *ex) -{ - CamelMboxFolder *mbox_folder = (CamelMboxFolder *)folder; - - g_assert (folder); - g_assert (mbox_folder->summary); - - return camel_folder_summary_count((CamelFolderSummary *)mbox_folder->summary); -} - -/* FIXME: this may need some tweaking for performance? */ -static void -mbox_append_message (CamelFolder *folder, CamelMimeMessage *message, CamelException *ex) -{ - CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER (folder); - CamelStream *output_stream = NULL, *filter_stream = NULL; - CamelMimeFilter *filter_from; - struct stat st; - off_t seek = -1; - char *xev; - guint32 uid; - - if (stat(mbox_folder->folder_file_path, &st) != 0) - goto fail; - - output_stream = camel_stream_fs_new_with_name (mbox_folder->folder_file_path, O_RDWR, 0600); - if (output_stream == NULL) - goto fail; - - seek = camel_seekable_stream_seek((CamelSeekableStream *)output_stream, st.st_size, SEEK_SET); - if (seek != st.st_size) - goto fail; - - /* assign a new x-evolution header/uid */ - camel_medium_remove_header((CamelMedium *)message, "X-Evolution"); - uid = camel_folder_summary_next_uid((CamelFolderSummary *)mbox_folder->summary); - xev = g_strdup_printf("%08x-%04x", uid, message->flags & 0xffff); - camel_medium_add_header((CamelMedium *)message, "X-Evolution", xev); - g_free(xev); - - /* we must write this to the non-filtered stream ... */ - if (camel_stream_write_string (output_stream, "From - \n") == -1) - goto fail; - - /* and write the content to the filtering stream, that translated '\nFrom' into '\n>From' */ - filter_stream = (CamelStream *)camel_stream_filter_new_with_stream(output_stream); - filter_from = (CamelMimeFilter *)camel_mime_filter_from_new(); - camel_stream_filter_add((CamelStreamFilter *)filter_stream, filter_from); - if (camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (message), filter_stream) == -1) - goto fail; - - if (camel_stream_close (filter_stream) == -1) - goto fail; - - /* filter stream ref's the output stream itself, so we need to unref it too */ - gtk_object_unref (GTK_OBJECT (filter_from)); - gtk_object_unref (GTK_OBJECT (filter_stream)); - gtk_object_unref (GTK_OBJECT (output_stream)); - - /* force a summary update - will only update from the new position, if it can */ - camel_mbox_summary_update(mbox_folder->summary, seek); - return; - -fail: - if (camel_exception_is_set (ex)) { - camel_exception_setv (ex, camel_exception_get_id (ex), - "Cannot append message to mbox file: %s", - camel_exception_get_description (ex)); - } else { - camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, - "Cannot append message to mbox file: %s", - g_strerror (errno)); - } - if (filter_stream) { - /*camel_stream_close (filter_stream);*/ - gtk_object_unref ((GtkObject *)filter_stream); - } - if (output_stream) - gtk_object_unref ((GtkObject *)output_stream); - - if (filter_from) - gtk_object_unref ((GtkObject *)filter_from); - - /* make sure the file isn't munged by us */ - if (seek != -1) { - int fd = open(mbox_folder->folder_file_path, O_WRONLY, 0600); - if (fd != -1) { - ftruncate(fd, st.st_size); - close(fd); - } - } -} - -static GPtrArray * -mbox_get_uids (CamelFolder *folder, CamelException *ex) -{ - GPtrArray *array; - CamelMboxFolder *mbox_folder = (CamelMboxFolder *)folder; - int i, count; - - count = camel_folder_summary_count((CamelFolderSummary *)mbox_folder->summary); - array = g_ptr_array_new (); - g_ptr_array_set_size (array, count); - for (i=0;isummary, i); - array->pdata[i] = g_strdup(info->info.uid); - } - - return array; -} - -static GPtrArray * -mbox_get_subfolder_names (CamelFolder *folder, CamelException *ex) -{ - /* No subfolders. */ - return g_ptr_array_new (); -} - -static void -mbox_delete_message_by_uid(CamelFolder *folder, const gchar *uid, CamelException *ex) -{ - CamelMessageInfo *info; - CamelMboxFolder *mf = (CamelMboxFolder *)folder; - - info = camel_folder_summary_uid((CamelFolderSummary *)mf->summary, uid); - if (info) { - info->flags |= CAMEL_MESSAGE_DELETED | CAMEL_MESSAGE_FOLDER_FLAGGED; - camel_folder_summary_touch((CamelFolderSummary *)mf->summary); - } -} - -/* track flag changes in the summary */ -static void -message_changed(CamelMimeMessage *m, int type, CamelMboxFolder *mf) -{ - CamelMessageInfo *info; - CamelFlag *flag; - - printf("Message changed: %s: %d\n", m->message_uid, type); - switch (type) { - case MESSAGE_FLAGS_CHANGED: - info = camel_folder_summary_uid((CamelFolderSummary *)mf->summary, m->message_uid); - if (info) { - info->flags = m->flags | CAMEL_MESSAGE_FOLDER_FLAGGED; - camel_flag_list_free(&info->user_flags); - flag = m->user_flags; - while (flag) { - camel_flag_set(&info->user_flags, flag->name, TRUE); - flag = flag->next; - } - camel_folder_summary_touch((CamelFolderSummary *)mf->summary); - } else - g_warning("Message changed event on message not in summary: %s", m->message_uid); - break; - default: - printf("Unhandled message change event: %d\n", type); - break; - } -} - -static CamelMimeMessage * -mbox_get_message_by_uid (CamelFolder *folder, const gchar *uid, CamelException *ex) -{ - CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER (folder); - CamelStream *message_stream = NULL; - CamelMimeMessage *message = NULL; - CamelMboxMessageInfo *info; - CamelMimeParser *parser = NULL; - char *buffer; - int len; - - /* get the message summary info */ - info = (CamelMboxMessageInfo *)camel_folder_summary_uid((CamelFolderSummary *)mbox_folder->summary, uid); - - if (info == NULL) { - errno = ENOENT; - goto fail; - } - - /* if this has no content, its an error in the library */ - g_assert(info->info.content); - g_assert(info->frompos != -1); - - /* where we read from */ - message_stream = camel_stream_fs_new_with_name (mbox_folder->folder_file_path, O_RDONLY, 0); - if (message_stream == NULL) - goto fail; - - /* we use a parser to verify the message is correct, and in the correct position */ - parser = camel_mime_parser_new(); - camel_mime_parser_init_with_stream(parser, message_stream); - gtk_object_unref((GtkObject *)message_stream); - camel_mime_parser_scan_from(parser, TRUE); - - camel_mime_parser_seek(parser, info->frompos, SEEK_SET); - if (camel_mime_parser_step(parser, &buffer, &len) != HSCAN_FROM) { - g_warning("File appears truncated"); - goto fail; - } - - if (camel_mime_parser_tell_start_from(parser) != info->frompos) { - g_warning("Summary doesn't match the folder contents! eek!"); - errno = EINVAL; - goto fail; - } - - message = camel_mime_message_new(); - if (camel_mime_part_construct_from_parser((CamelMimePart *)message, parser) == -1) { - g_warning("Construction failed"); - goto fail; - } - - /* we're constructed, finish setup and clean up */ - message->folder = folder; - gtk_object_ref((GtkObject *)folder); - message->message_uid = g_strdup(uid); - message->flags = info->info.flags; - gtk_signal_connect((GtkObject *)message, "message_changed", message_changed, folder); - - gtk_object_unref((GtkObject *)parser); - - return message; - -fail: - camel_exception_setv (ex, CAMEL_EXCEPTION_FOLDER_INVALID_UID, - "Cannot get message: %s", - g_strerror(errno)); - - if (parser) - gtk_object_unref((GtkObject *)parser); - if (message) - gtk_object_unref((GtkObject *)message); - - return NULL; -} - -GPtrArray * -mbox_get_summary (CamelFolder *folder, CamelException *ex) -{ - CamelMboxFolder *mbox_folder = (CamelMboxFolder *)folder; - - return ((CamelFolderSummary *)mbox_folder->summary)->messages; -} - -void -mbox_free_summary (CamelFolder *folder, GPtrArray *array) -{ - /* no-op */ -} - -/* get a single message info, by uid */ -static const CamelMessageInfo * -mbox_summary_get_by_uid(CamelFolder *f, const char *uid) -{ - CamelMboxFolder *mbox_folder = (CamelMboxFolder *)f; - - return camel_folder_summary_uid((CamelFolderSummary *)mbox_folder->summary, uid); -} - -static GList * -mbox_search_by_expression(CamelFolder *folder, const char *expression, CamelException *ex) -{ - CamelMboxFolder *mbox_folder = (CamelMboxFolder *)folder; - - if (mbox_folder->search == NULL) { - mbox_folder->search = camel_folder_search_new(); - } - - camel_folder_search_set_folder(mbox_folder->search, folder); - if (mbox_folder->summary) - /* FIXME: dont access summary array directly? */ - camel_folder_search_set_summary(mbox_folder->search, ((CamelFolderSummary *)mbox_folder->summary)->messages); - camel_folder_search_set_body_index(mbox_folder->search, mbox_folder->index); - - return camel_folder_search_execute_expression(mbox_folder->search, expression, ex); -} diff --git a/camel/providers/mbox/camel-mbox-folder.h b/camel/providers/mbox/camel-mbox-folder.h deleted file mode 100644 index d7dc361f14..0000000000 --- a/camel/providers/mbox/camel-mbox-folder.h +++ /dev/null @@ -1,81 +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 - * - * 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 -#include -#include -#include -#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; - - 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 */ - - ibex *index; /* index for this folder */ - CamelMboxSummary *summary; - CamelFolderSearch *search; /* used to run searches, we just use the real thing (tm) */ -} 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-provider.c b/camel/providers/mbox/camel-mbox-provider.c deleted file mode 100644 index 04ce88de12..0000000000 --- a/camel/providers/mbox/camel-mbox-provider.c +++ /dev/null @@ -1,50 +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 - * - * 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-session.h" - -static CamelProvider mbox_provider = { - "mbox", - "UNIX mbox-format mail files", - - "For reading mail delivered by the local system, and for " - "storing mail on local disk.", - - 0, - - { 0, 0 } -}; - -void -camel_provider_module_init (CamelSession *session) -{ - mbox_provider.object_types[CAMEL_PROVIDER_STORE] = - camel_mbox_store_get_type(); - - camel_session_register_provider (session, &mbox_provider); -} diff --git a/camel/providers/mbox/camel-mbox-store.c b/camel/providers/mbox/camel-mbox-store.c deleted file mode 100644 index 8db2f9338e..0000000000 --- a/camel/providers/mbox/camel-mbox-store.c +++ /dev/null @@ -1,129 +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 Helix Code, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#include - -#include "camel-mbox-store.h" -#include "camel-mbox-folder.h" -#include "camel-exception.h" -#include "camel-url.h" - -/* 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 CamelFolder *get_folder (CamelStore *store, const char *folder_name, - CamelException *ex); -static char *get_folder_name (CamelStore *store, const char *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); - - /* virtual method overload */ - camel_store_class->get_folder = get_folder; - camel_store_class->get_folder_name = get_folder_name; -} - - - -static void -camel_mbox_store_init (gpointer object, gpointer klass) -{ - CamelService *service = CAMEL_SERVICE (object); - CamelStore *store = CAMEL_STORE (object); - - service->url_flags = CAMEL_SERVICE_URL_NEED_PATH; - - /* mbox names are filenames, so they are case-sensitive. */ - store->folders = g_hash_table_new (g_str_hash, g_str_equal); -} - - - - -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; -} - - -const gchar * -camel_mbox_store_get_toplevel_dir (CamelMboxStore *store) -{ - CamelURL *url = CAMEL_SERVICE (store)->url; - - g_assert(url != NULL); - return url->path; -} - - - -static CamelFolder * -get_folder (CamelStore *store, const char *folder_name, CamelException *ex) -{ - CamelMboxFolder *new_mbox_folder; - CamelFolder *new_folder; - - new_mbox_folder = gtk_type_new (CAMEL_MBOX_FOLDER_TYPE); - new_folder = CAMEL_FOLDER (new_mbox_folder); - - /* XXX We shouldn't be passing NULL here, but it's equivalent to - * what was there before, and there's no - * CamelMboxFolder::get_subfolder yet anyway... - */ - CF_CLASS (new_folder)->init (new_folder, store, NULL, - folder_name, '/', ex); - - return new_folder; -} - -static char * -get_folder_name (CamelStore *store, const char *folder_name, - CamelException *ex) -{ - return g_strdup (folder_name); -} diff --git a/camel/providers/mbox/camel-mbox-store.h b/camel/providers/mbox/camel-mbox-store.h deleted file mode 100644 index 06a971ada4..0000000000 --- a/camel/providers/mbox/camel-mbox-store.h +++ /dev/null @@ -1,69 +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 Helix Code, Inc. - * - * 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 -#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; - -} CamelMboxStore; - - - -typedef struct { - CamelStoreClass parent_class; - -} CamelMboxStoreClass; - - -/* public methods */ - -/* Standard Gtk function */ -GtkType camel_mbox_store_get_type (void); - -const gchar *camel_mbox_store_get_toplevel_dir (CamelMboxStore *store); - -#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 46b180e999..0000000000 --- a/camel/providers/mbox/camel-mbox-summary.c +++ /dev/null @@ -1,740 +0,0 @@ -/* - * Copyright (C) 2000 Helix Code Inc. - * - * Authors: Michael Zucchi - * - * 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-summary.h" -#include - -#include -#include -#include -#include -#include -#include - -#define io(x) -#define d(x) - -#define CAMEL_MBOX_SUMMARY_VERSION (0x1000) - -struct _CamelMboxSummaryPrivate { -}; - -#define _PRIVATE(o) (((CamelMboxSummary *)(o))->priv) - -static int summary_header_load(CamelFolderSummary *, FILE *); -static int summary_header_save(CamelFolderSummary *, FILE *); - -static CamelMessageInfo * message_info_new(CamelFolderSummary *, struct _header_raw *); -static CamelMessageInfo * message_info_new_from_parser(CamelFolderSummary *, CamelMimeParser *); -static CamelMessageInfo * message_info_load(CamelFolderSummary *, FILE *); -static int message_info_save(CamelFolderSummary *, FILE *, CamelMessageInfo *); -/*static void message_info_free(CamelFolderSummary *, CamelMessageInfo *);*/ - -static void camel_mbox_summary_class_init (CamelMboxSummaryClass *klass); -static void camel_mbox_summary_init (CamelMboxSummary *obj); -static void camel_mbox_summary_finalise (GtkObject *obj); - -static CamelFolderSummaryClass *camel_mbox_summary_parent; - -enum SIGNALS { - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -guint -camel_mbox_summary_get_type (void) -{ - static guint type = 0; - - if (!type) { - GtkTypeInfo type_info = { - "CamelMboxSummary", - sizeof (CamelMboxSummary), - sizeof (CamelMboxSummaryClass), - (GtkClassInitFunc) camel_mbox_summary_class_init, - (GtkObjectInitFunc) camel_mbox_summary_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL - }; - - type = gtk_type_unique (camel_folder_summary_get_type (), &type_info); - } - - return type; -} - -static void -camel_mbox_summary_class_init (CamelMboxSummaryClass *klass) -{ - GtkObjectClass *object_class = (GtkObjectClass *) klass; - CamelFolderSummaryClass *sklass = (CamelFolderSummaryClass *) klass; - - camel_mbox_summary_parent = gtk_type_class (camel_folder_summary_get_type ()); - - object_class->finalize = camel_mbox_summary_finalise; - - sklass->summary_header_load = summary_header_load; - sklass->summary_header_save = summary_header_save; - - sklass->message_info_new = message_info_new; - sklass->message_info_new_from_parser = message_info_new_from_parser; - sklass->message_info_load = message_info_load; - sklass->message_info_save = message_info_save; - /*sklass->message_info_free = message_info_free;*/ - - gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL); -} - -static void -camel_mbox_summary_init (CamelMboxSummary *obj) -{ - struct _CamelMboxSummaryPrivate *p; - struct _CamelFolderSummary *s = (CamelFolderSummary *)obj; - - p = _PRIVATE(obj) = g_malloc0(sizeof(*p)); - - /* subclasses need to set the right instance data sizes */ - s->message_info_size = sizeof(CamelMboxMessageInfo); - s->content_info_size = sizeof(CamelMboxMessageContentInfo); - - /* and a unique file version */ - s->version += CAMEL_MBOX_SUMMARY_VERSION; -} - -static void -camel_mbox_summary_finalise (GtkObject *obj) -{ - CamelMboxSummary *mbs = (CamelMboxSummary *)obj; - - g_free(mbs->folder_path); - - ((GtkObjectClass *)(camel_mbox_summary_parent))->finalize((GtkObject *)obj); -} - -/** - * camel_mbox_summary_new: - * - * Create a new CamelMboxSummary object. - * - * Return value: A new CamelMboxSummary widget. - **/ -CamelMboxSummary * -camel_mbox_summary_new (const char *filename, const char *mbox_name, ibex *index) -{ - CamelMboxSummary *new = CAMEL_MBOX_SUMMARY ( gtk_type_new (camel_mbox_summary_get_type ())); - if (new) { - /* ?? */ - camel_folder_summary_set_build_content((CamelFolderSummary *)new, TRUE); - camel_folder_summary_set_filename((CamelFolderSummary *)new, filename); - new->folder_path = g_strdup(mbox_name); - new->index = index; - } - return new; -} - - -static int summary_header_load(CamelFolderSummary *s, FILE *in) -{ - CamelMboxSummary *mbs = (CamelMboxSummary *)s; - - if (((CamelFolderSummaryClass *)camel_mbox_summary_parent)->summary_header_load(s, in) == -1) - return -1; - - return camel_folder_summary_decode_uint32(in, &mbs->folder_size); -} - -static int summary_header_save(CamelFolderSummary *s, FILE *out) -{ - CamelMboxSummary *mbs = (CamelMboxSummary *)s; - - if (((CamelFolderSummaryClass *)camel_mbox_summary_parent)->summary_header_save(s, out) == -1) - return -1; - - return camel_folder_summary_encode_uint32(out, mbs->folder_size); -} - -static int -header_evolution_decode(const char *in, guint32 *uid, guint32 *flags) -{ - char *header; - if (in - && (header = header_token_decode(in))) { - if (strlen(header) == strlen("00000000-0000") - && sscanf(header, "%08x-%04x", uid, flags) == 2) { - g_free(header); - return *uid; - } - g_free(header); - } - - return -1; -} - -static char * -header_evolution_encode(guint32 uid, guint32 flags) -{ - return g_strdup_printf("%08x-%04x", uid, flags & 0xffff); -} - -static CamelMessageInfo * message_info_new(CamelFolderSummary *s, struct _header_raw *h) -{ - CamelMessageInfo *mi; - - mi = ((CamelFolderSummaryClass *)camel_mbox_summary_parent)->message_info_new(s, h); - if (mi) { - const char *xev; - guint32 uid, flags; - CamelMboxMessageInfo *mbi = (CamelMboxMessageInfo *)mi; - - xev = header_raw_find(&h, "X-Evolution", NULL); - if (xev - && header_evolution_decode(xev, &uid, &flags) != -1) { - g_free(mi->uid); - mi->uid = g_strdup_printf("%u", uid); - mi->flags = flags; - } else { - /* to indicate it has no xev header? */ - mi->flags |= CAMEL_MESSAGE_FOLDER_FLAGGED|CAMEL_MESSAGE_FOLDER_NOXEV; - mi->uid = g_strdup_printf("%u", camel_folder_summary_next_uid(s)); - } - mbi->frompos = -1; - } - return mi; -} - -static CamelMessageInfo * message_info_new_from_parser(CamelFolderSummary *s, CamelMimeParser *mp) -{ - CamelMessageInfo *mi; - CamelMboxSummary *mbs = (CamelMboxSummary *)s; - - mi = ((CamelFolderSummaryClass *)camel_mbox_summary_parent)->message_info_new_from_parser(s, mp); - if (mi) { - CamelMboxMessageInfo *mbi = (CamelMboxMessageInfo *)mi; - - mbi->frompos = camel_mime_parser_tell_start_from(mp); - - /* do we want to index this message as we add it, as well? */ - if (mbs->index_force - || (mi->flags & CAMEL_MESSAGE_FOLDER_FLAGGED) != 0 - || !ibex_contains_name(mbs->index, mi->uid)) { - camel_folder_summary_set_index(s, mbs->index); - } else { - camel_folder_summary_set_index(s, NULL); - } - } - return mi; -} - -static CamelMessageInfo * message_info_load(CamelFolderSummary *s, FILE *in) -{ - CamelMessageInfo *mi; - - io(printf("loading mbox message info\n")); - - mi = ((CamelFolderSummaryClass *)camel_mbox_summary_parent)->message_info_load(s, in); - if (mi) { - CamelMboxMessageInfo *mbi = (CamelMboxMessageInfo *)mi; - - camel_folder_summary_decode_uint32(in, &mbi->frompos); - } - return mi; -} - -static int message_info_save(CamelFolderSummary *s, FILE *out, CamelMessageInfo *mi) -{ - CamelMboxMessageInfo *mbi = (CamelMboxMessageInfo *)mi; - - io(printf("saving mbox message info\n")); - - ((CamelFolderSummaryClass *)camel_mbox_summary_parent)->message_info_save(s, out, mi); - - return camel_folder_summary_encode_uint32(out, mbi->frompos); -} - -static int -summary_rebuild(CamelMboxSummary *mbs, off_t offset) -{ - CamelMimeParser *mp; - int fd; - int ok = 0; - - printf("(re)Building summary from %d (%s)\n", (int)offset, mbs->folder_path); - - fd = open(mbs->folder_path, O_RDONLY); - mp = camel_mime_parser_new(); - camel_mime_parser_init_with_fd(mp, fd); - camel_mime_parser_scan_from(mp, TRUE); - camel_mime_parser_seek(mp, offset, SEEK_SET); - - if (offset > 0) { - if (camel_mime_parser_step(mp, NULL, NULL) == HSCAN_FROM) { - if (camel_mime_parser_tell_start_from(mp) != offset) { - g_warning("The next message didn't start where I expected\nbuilding summary from start"); - camel_mime_parser_drop_step(mp); - offset = 0; - camel_mime_parser_seek(mp, offset, SEEK_SET); - camel_folder_summary_clear((CamelFolderSummary *)mbs); - } else { - camel_mime_parser_unstep(mp); - } - } else { - gtk_object_unref((GtkObject *)mp); - /* end of file - no content? */ - printf("We radn out of file?\n"); - return 0; - } - } - - while (camel_mime_parser_step(mp, NULL, NULL) == HSCAN_FROM) { - CamelMessageInfo *info; - - info = camel_folder_summary_add_from_parser((CamelFolderSummary *)mbs, mp); - if (info == NULL) { - printf("Could not build info from file?\n"); - ok = -1; - break; - } - - g_assert(camel_mime_parser_step(mp, NULL, NULL) == HSCAN_FROM_END); - } - - /* update the file size in the summary */ - if (ok != -1) - mbs->folder_size = camel_mime_parser_seek(mp, 0, SEEK_CUR); - printf("updating folder size = %d\n", mbs->folder_size); - gtk_object_unref((GtkObject *)mp); - - return ok; -} - -int -camel_mbox_summary_update(CamelMboxSummary *mbs, off_t offset) -{ - int ret; - - mbs->index_force = FALSE; - ret = summary_rebuild(mbs, offset); - -#if 0 -#warning "Saving full summary and index after every summarisation is slow ..." - if (ret != -1) { - if (camel_folder_summary_save((CamelFolderSummary *)mbs) == -1) - g_warning("Could not save summary: %s", strerror(errno)); - printf("summary saved\n"); - if (mbs->index) - ibex_save(mbs->index); - printf("ibex saved\n"); - } -#endif - return ret; -} - -int -camel_mbox_summary_load(CamelMboxSummary *mbs, int forceindex) -{ - CamelFolderSummary *s = (CamelFolderSummary *)mbs; - struct stat st; - int ret = 0; - off_t minstart; - - mbs->index_force = forceindex; - - /* is the summary out of date? */ - if (stat(mbs->folder_path, &st) == -1) { - camel_folder_summary_clear(s); - printf("Cannot summarise folder: '%s': %s\n", mbs->folder_path, strerror(errno)); - return -1; - } - - if (forceindex || camel_folder_summary_load(s) == -1) { - camel_folder_summary_clear(s); - ret = summary_rebuild(mbs, 0); - } else { - minstart = st.st_size; -#if 0 - /* find out the first unindexed message ... */ - /* TODO: For this to work, it has to check that the message is - indexable, and contains content ... maybe it cannot be done - properly? */ - for (i=0;iindex, mi->uid)) { - minstart = ((CamelMboxMessageInfo *)mi)->frompos; - printf("Found unindexed message: %s\n", mi->uid); - break; - } - } -#endif - /* is the summary uptodate? */ - if (st.st_size == mbs->folder_size && st.st_mtime == s->time) { - printf("Summary time and date match mbox\n"); - if (minstart < st.st_size) { - /* FIXME: Only clear the messages and reindex from this point forward */ - camel_folder_summary_clear(s); - ret = summary_rebuild(mbs, 0); - } - } else { - if (mbs->folder_size < st.st_size) { - printf("Index is for a smaller mbox\n"); - if (minstart < mbs->folder_size) { - /* FIXME: only make it rebuild as necessary */ - camel_folder_summary_clear(s); - ret = summary_rebuild(mbs, 0); - } else { - ret = summary_rebuild(mbs, mbs->folder_size); - } - } else { - printf("index is for a bigger mbox\n"); - camel_folder_summary_clear(s); - ret = summary_rebuild(mbs, 0); - } - } - } - - if (ret != -1) { - mbs->folder_size = st.st_size; - s->time = st.st_mtime; - printf("saving summary\n"); - if (camel_folder_summary_save(s) == -1) - g_warning("Could not save summary: %s", strerror(errno)); - printf("summary saved\n"); - if (mbs->index) - ibex_save(mbs->index); - printf("ibex saved\n"); - } - - return ret; -} - -static int -header_write(int fd, struct _header_raw *header, char *xevline) -{ - struct iovec iv[4]; - int outlen = 0, len; - - iv[1].iov_base = ":"; - iv[1].iov_len = 1; - iv[3].iov_base = "\n"; - iv[3].iov_len = 1; - - while (header) { - if (strcasecmp(header->name, "X-Evolution")) { - iv[0].iov_base = header->name; - iv[0].iov_len = strlen(header->name); - iv[2].iov_base = header->value; - iv[2].iov_len = strlen(header->value); - - do { - len = writev(fd, iv, 4); - } while (len == -1 && errno == EINTR); - - if (len == -1) - return -1; - outlen += len; - } - header = header->next; - } - - iv[0].iov_base = "X-Evolution: "; - iv[0].iov_len = strlen(iv[0].iov_base); - iv[1].iov_base = xevline; - iv[1].iov_len = strlen(xevline); - iv[2].iov_base = "\n\n"; - iv[2].iov_len = 2; - - do { - len = writev(fd, iv, 3); - } while (len == -1 && errno == EINTR); - - if (len == -1) - return -1; - - outlen += 1; - - d(printf("Wrote %d bytes of headers\n", outlen)); - - return outlen; -} - -static int -copy_block(int fromfd, int tofd, off_t start, size_t bytes) -{ - char buffer[4096]; - int written = 0; - - d(printf("writing %d bytes ... ", bytes)); - - if (lseek(fromfd, start, SEEK_SET) != start) - return -1; - - while (bytes>0) { - int toread, towrite; - - toread = bytes; - if (bytes>4096) - toread = 4096; - else - toread = bytes; - do { - towrite = read(fromfd, buffer, toread); - } while (towrite == -1 && errno == EINTR); - - if (towrite == -1) - return -1; - - /* check for 'end of file' */ - if (towrite == 0) { - d(printf("end of file?\n")); - break; - } - - do { - toread = write(tofd, buffer, towrite); - } while (toread == -1 && errno == EINTR); - - if (toread == -1) - return -1; - - written += toread; - bytes -= toread; - } - - d(printf("written %d bytes\n", written)); - - return written; -} - -int -camel_mbox_summary_expunge(CamelMboxSummary *mbs) -{ - CamelMimeParser *mp=NULL; - int i, count; - CamelMboxMessageInfo *info; - CamelFolderSummary *s = (CamelFolderSummary *)mbs; - - int fd=-1, fdout=-1; - off_t offset = 0; - char *tmpname=0; - char *buffer, *xevnew = NULL; - const char *xev; - int len; - guint32 uid, flags; - int quick = TRUE, work = FALSE; - - /* make sure we're in sync */ - count = camel_folder_summary_count(s); - if (count>0) { - CamelMessageInfo *mi = camel_folder_summary_index(s, count-1); - camel_mbox_summary_update(mbs, mi->content->endpos); - } else { - camel_mbox_summary_update(mbs, 0); - } - - /* check if we have any work to do */ - d(printf("Performing expunge, %d messages in inbox\n", count)); - for (i=0;quick && iinfo.flags & (CAMEL_MESSAGE_DELETED|CAMEL_MESSAGE_FOLDER_NOXEV)) - quick = FALSE; - else - work |= (info->info.flags & CAMEL_MESSAGE_FOLDER_FLAGGED) != 0; - } - - d(printf("Options: %s %s\n", quick?"quick":"", work?"Work":"")); - - if (quick && !work) - return 0; - - fd = open(mbs->folder_path, O_RDWR); - if (fd == -1) - return -1; - - mp = camel_mime_parser_new(); - camel_mime_parser_scan_from(mp, TRUE); - camel_mime_parser_init_with_fd(mp, fd); - - if (!quick) { - tmpname = alloca(strlen(mbs->folder_path)+5); - sprintf(tmpname, "%s.tmp", mbs->folder_path); - d(printf("Writing tmp file to %s\n", tmpname)); - retry_out: - fdout = open(tmpname, O_WRONLY|O_CREAT|O_EXCL, 0600); - if (fdout == -1) { - if (errno == EEXIST) - if (unlink(tmpname) != -1) - goto retry_out; - tmpname = 0; - goto error; - } - } - - for (i=0;iinfo.uid)); - - if (info->info.flags & CAMEL_MESSAGE_DELETED) { - d(printf("Deleting %s\n", info->info.uid)); - - g_assert(!quick); - offset -= (info->info.content->endpos - info->frompos); - if (mbs->index) - ibex_unindex(mbs->index, info->info.uid); - camel_folder_summary_remove(s, (CamelMessageInfo *)info); - count--; - i--; - info = NULL; - } else if (info->info.flags & (CAMEL_MESSAGE_FOLDER_NOXEV|CAMEL_MESSAGE_FOLDER_FLAGGED)) { - int xevok = FALSE; - - d(printf("Updating header for %s flags = %08x\n", info->info.uid, info->info.flags)); - - /* find the next message, header parts */ - camel_mime_parser_seek(mp, info->frompos, SEEK_SET); - if (camel_mime_parser_step(mp, &buffer, &len) != HSCAN_FROM) - goto error; - - if (camel_mime_parser_tell_start_from(mp) != info->frompos) { - g_error("Summary/mbox mismatch, aborting expunge"); - goto error; - } - - if (camel_mime_parser_step(mp, &buffer, &len) == HSCAN_FROM_END) - goto error; - - xev = camel_mime_parser_header(mp, "X-Evolution", (int *)&xevoffset); - if (xev && header_evolution_decode(xev, &uid, &flags) != -1) { - char name[64]; - - sprintf(name, "%u", uid); - if (strcmp(name, info->info.uid)) { - d(printf("Summary mismatch, aborting leaving mailbox intact\n")); - goto error; - } - xevok = TRUE; - } - xevnew = header_evolution_encode(strtoul(info->info.uid, NULL, 10), info->info.flags & 0xffff); - if (quick) { - if (!xevok) { - g_error("The summary told me I had an X-Evolution header, but i dont!"); - goto error; - } - buffer = g_strdup_printf("X-Evolution: %s", xevnew); - do { - len = write(fd, buffer, strlen(buffer)); - } while (len == -1 && errno == EINTR); - g_free(buffer); - if (len == -1) { - goto error; - } - } else { - frompos = lseek(fdout, 0, SEEK_CUR); - write(fdout, "From -\n", strlen("From -\n")); - if (header_write(fdout, camel_mime_parser_headers_raw(mp), xevnew) == -1) { - d(printf("Error writing to tmp mailbox\n")); - goto error; - } - bodypos = lseek(fdout, 0, SEEK_CUR); - d(printf("pos = %d, endpos = %d, bodypos = %d\n", - info->info.content->pos, - info->info.content->endpos, - info->info.content->bodypos)); - if (copy_block(fd, fdout, info->info.content->bodypos, info->info.content->endpos - info->info.content->bodypos) == -1) { - g_warning("Cannot copy data to output fd"); - goto error; - } - info->frompos = frompos; - offset = bodypos - info->info.content->bodypos; - } - info->info.flags &= 0xffff; - g_free(xevnew); xevnew = NULL; - camel_mime_parser_drop_step(mp); - camel_mime_parser_drop_step(mp); - } else { - d(printf("Nothing to do for this message\n")); - } - if (!quick && info!=NULL && offset!=0) { - camel_folder_summary_offset_content(info->info.content, offset); - d(printf("pos = %d, endpos = %d, bodypos = %d\n", - info->info.content->pos, - info->info.content->endpos, - info->info.content->bodypos)); - } - } - - d(printf("Closing folders\n")); - - if (close(fd) == -1) { - g_warning("Cannot close source folder: %s", strerror(errno)); - goto error; - } - - if (!quick) { - struct stat st; - - if (close(fdout) == -1) { - g_warning("Cannot close tmp folder: %s", strerror(errno)); - goto error; - } - - if (rename(tmpname, mbs->folder_path) == -1) { - g_warning("Cannot rename folder: %s", strerror(errno)); - goto error; - } - tmpname = 0; - - if (stat(mbs->folder_path, &st) == -1) - goto error; - - camel_folder_summary_touch(s); - s->time = st.st_mtime; - mbs->folder_size = st.st_size; - camel_folder_summary_save(s); - if (mbs->index) - ibex_save(mbs->index); - } - - gtk_object_unref((GtkObject *)mp); - - return 0; -error: - d(printf("Error occured: %s\n", strerror(errno))); - count = errno; - - close(fd); - close(fdout); - - g_free(xevnew); - - if (tmpname) - unlink(tmpname); - if (mp) - gtk_object_unref((GtkObject *)mp); - - errno = count; - return -1; -} diff --git a/camel/providers/mbox/camel-mbox-summary.h b/camel/providers/mbox/camel-mbox-summary.h deleted file mode 100644 index 6d98fd051d..0000000000 --- a/camel/providers/mbox/camel-mbox-summary.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (C) 2000 Helix Code Inc. - * - * Authors: Michael Zucchi - * - * 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_SUMMARY_H -#define _CAMEL_MBOX_SUMMARY_H - -#include -#include -#include - -#define CAMEL_MBOX_SUMMARY(obj) GTK_CHECK_CAST (obj, camel_mbox_summary_get_type (), CamelMboxSummary) -#define CAMEL_MBOX_SUMMARY_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, camel_mbox_summary_get_type (), CamelMboxSummaryClass) -#define IS_CAMEL_MBOX_SUMMARY(obj) GTK_CHECK_TYPE (obj, camel_mbox_summary_get_type ()) - -typedef struct _CamelMboxSummary CamelMboxSummary; -typedef struct _CamelMboxSummaryClass CamelMboxSummaryClass; - -/* extra summary flags */ -enum { - CAMEL_MESSAGE_FOLDER_NOXEV = 1<<16, -/* CAMEL_MESSAGE_FOLDER_FLAGGED = 1<<17,*/ -}; - -typedef struct _CamelMboxMessageContentInfo { - CamelMessageContentInfo info; -} CamelMboxMessageContentInfo; - -typedef struct _CamelMboxMessageInfo { - CamelMessageInfo info; - - off_t frompos; -} CamelMboxMessageInfo; - -struct _CamelMboxSummary { - CamelFolderSummary parent; - - struct _CamelMboxSummaryPrivate *priv; - - char *folder_path; /* name of matching folder */ - size_t folder_size; /* size of the mbox file, last sync */ - - ibex *index; - int index_force; /* do we force index during creation? */ -}; - -struct _CamelMboxSummaryClass { - CamelFolderSummaryClass parent_class; -}; - -guint camel_mbox_summary_get_type (void); -CamelMboxSummary *camel_mbox_summary_new (const char *filename, const char *mbox_name, ibex *index); - -/* load/check the summary */ -int camel_mbox_summary_load(CamelMboxSummary *mbs, int forceindex); -/* incremental update */ -int camel_mbox_summary_update(CamelMboxSummary *mbs, off_t offset); -/* perform a folder expunge */ -int camel_mbox_summary_expunge(CamelMboxSummary *mbs); - -#endif /* ! _CAMEL_MBOX_SUMMARY_H */ diff --git a/camel/providers/mbox/libcamelmbox.urls b/camel/providers/mbox/libcamelmbox.urls deleted file mode 100644 index e021190356..0000000000 --- a/camel/providers/mbox/libcamelmbox.urls +++ /dev/null @@ -1 +0,0 @@ -mbox diff --git a/camel/providers/nntp/.cvsignore b/camel/providers/nntp/.cvsignore deleted file mode 100644 index fd6b811c68..0000000000 --- a/camel/providers/nntp/.cvsignore +++ /dev/null @@ -1,7 +0,0 @@ -.deps -Makefile -Makefile.in -.libs -.deps -*.lo -*.la diff --git a/camel/providers/nntp/Makefile.am b/camel/providers/nntp/Makefile.am deleted file mode 100644 index 6c37e2112f..0000000000 --- a/camel/providers/nntp/Makefile.am +++ /dev/null @@ -1,31 +0,0 @@ -## Process this file with automake to produce Makefile.in - -SUBDIRS = - -libcamelnntpincludedir = $(includedir)/camel - -providerdir = $(pkglibdir)/camel-providers/$(VERSION) - -provider_LTLIBRARIES = libcamelnntp.la -provider_DATA = libcamelnntp.urls - -INCLUDES = -I.. -I$(srcdir)/.. -I$(includedir) \ - -I$(top_srcdir)/intl \ - $(GTK_INCLUDEDIR) -I$(top_srcdir)/camel \ - -I$(srcdir)/../mbox \ - -DG_LOG_DOMAIN=\"camel-nntp-provider\" - -libcamelnntp_la_SOURCES = \ - camel-nntp-folder.c \ - camel-nntp-provider.c \ - camel-nntp-store.c \ - camel-nntp-utils.c - -libcamelnntpinclude_HEADERS = \ - camel-nntp-folder.h \ - camel-nntp-store.h - - -libcamelnntp_la_LDFLAGS = -version-info 0:0:0 -rpath $(libdir) - -EXTRA_DIST = libcamelnntp.urls diff --git a/camel/providers/nntp/camel-nntp-folder.c b/camel/providers/nntp/camel-nntp-folder.c deleted file mode 100644 index 8bc623add7..0000000000 --- a/camel/providers/nntp/camel-nntp-folder.c +++ /dev/null @@ -1,617 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-nntp-folder.c : Abstract class for an email folder */ - -/* - * Author : Chris Toshok - * - * Copyright (C) 2000 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 - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "camel-folder-summary.h" -#include "camel-nntp-store.h" -#include "camel-nntp-folder.h" -#include "camel-nntp-store.h" -#include "camel-nntp-utils.h" - -#include "string-utils.h" -#include "camel-stream-mem.h" -#include "camel-stream-buffer.h" -#include "camel-data-wrapper.h" -#include "camel-mime-message.h" -#include "camel-folder-summary.h" - -#include "camel-exception.h" - -static CamelFolderClass *parent_class=NULL; - -/* Returns the class for a CamelNNTPFolder */ -#define CNNTPF_CLASS(so) CAMEL_NNTP_FOLDER_CLASS (GTK_OBJECT(so)->klass) -#define CF_CLASS(so) CAMEL_FOLDER_CLASS (GTK_OBJECT(so)->klass) -#define CNNTPS_CLASS(so) CAMEL_STORE_CLASS (GTK_OBJECT(so)->klass) - - -static void _init (CamelFolder *folder, CamelStore *parent_store, - CamelFolder *parent_folder, const gchar *name, - gchar separator, 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 void _append_message (CamelFolder *folder, CamelMimeMessage *message, CamelException *ex); -static GPtrArray *_get_uid_array (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); -#endif -static const gchar *_get_message_uid (CamelFolder *folder, CamelMimeMessage *message, CamelException *ex); - -static void _finalize (GtkObject *object); - -static void -camel_nntp_folder_class_init (CamelNNTPFolderClass *camel_nntp_folder_class) -{ - CamelFolderClass *camel_folder_class = CAMEL_FOLDER_CLASS (camel_nntp_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 = _init; - 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_count = _get_message_count; - camel_folder_class->get_uid_array = _get_uid_array; - camel_folder_class->get_message_by_uid = _get_message_by_uid; -#if 0 - camel_folder_class->append_message = _append_message; - camel_folder_class->expunge = _expunge; - camel_folder_class->copy_message_to = _copy_message_to; - camel_folder_class->get_message_uid = _get_message_uid; -#endif - - gtk_object_class->finalize = _finalize; - -} - -static void -_finalize (GtkObject *object) -{ - CamelNNTPFolder *nntp_folder = CAMEL_NNTP_FOLDER (object); - - g_free (nntp_folder->summary_file_path); - - GTK_OBJECT_CLASS (parent_class)->finalize (object); -} - -GtkType -camel_nntp_folder_get_type (void) -{ - static GtkType camel_nntp_folder_type = 0; - - if (!camel_nntp_folder_type) { - GtkTypeInfo camel_nntp_folder_info = - { - "CamelNNTPFolder", - sizeof (CamelNNTPFolder), - sizeof (CamelNNTPFolderClass), - (GtkClassInitFunc) camel_nntp_folder_class_init, - (GtkObjectInitFunc) NULL, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_nntp_folder_type = gtk_type_unique (CAMEL_FOLDER_TYPE, &camel_nntp_folder_info); - } - - return camel_nntp_folder_type; -} - -static void -_init (CamelFolder *folder, CamelStore *parent_store, - CamelFolder *parent_folder, const gchar *name, gchar separator, - CamelException *ex) -{ - /* call parent method */ - parent_class->init (folder, parent_store, parent_folder, - name, separator, ex); - if (camel_exception_get_id (ex)) return; - - /* we assume that the parent init - method checks for the existance of @folder */ - - if (!strcmp(name, "/")) - { - folder->has_summary_capability = FALSE; - folder->can_hold_messages = FALSE; - folder->can_hold_folders = TRUE; - } - else - { - folder->has_summary_capability = TRUE; - folder->can_hold_messages = TRUE; - folder->can_hold_folders = TRUE; - } - - folder->has_uid_capability = TRUE; - folder->has_search_capability = FALSE; -} - -/* internal method used to : - - test for the existence of a summary file - - test the sync between the summary and the newsgroup - - load the summary or create it if necessary -*/ -static void -_check_get_or_maybe_generate_summary_file (CamelNNTPFolder *nntp_folder, - CamelException *ex) -{ - CamelFolder *folder = CAMEL_FOLDER (nntp_folder); - - nntp_folder->summary = camel_folder_summary_new (); - camel_folder_summary_set_filename (nntp_folder->summary, nntp_folder->summary_file_path); - - if (-1 == camel_folder_summary_load (nntp_folder->summary)) { - /* Bad or nonexistant summary file */ - camel_nntp_get_headers (CAMEL_FOLDER( folder )->parent_store, nntp_folder, ex); - if (camel_exception_get_id (ex)) - return; - - /* XXX check return value */ - camel_folder_summary_save (nntp_folder->summary); - } -} - - -static void -_open (CamelFolder *folder, CamelFolderOpenMode mode, CamelException *ex) -{ - CamelNNTPFolder *nntp_folder = CAMEL_NNTP_FOLDER (folder); - const gchar *root_dir_path; - - /* call parent class */ - parent_class->open (folder, mode, ex); - if (camel_exception_get_id(ex)) - return; - -#if 0 - /* get (or create) uid list */ - if (!(nntp_load_uid_list (nntp_folder) > 0)) - nntp_generate_uid_list (nntp_folder); -#endif - - root_dir_path = camel_nntp_store_get_toplevel_dir (CAMEL_NNTP_STORE(folder->parent_store)); - - nntp_folder->summary_file_path = g_strdup_printf ("%s/%s-ev-summary", root_dir_path, folder->name); - - _check_get_or_maybe_generate_summary_file (nntp_folder, ex); -} - - -static void -_close (CamelFolder *folder, gboolean expunge, CamelException *ex) -{ - CamelNNTPFolder *nntp_folder = CAMEL_NNTP_FOLDER (folder); - CamelFolderSummary *summary = nntp_folder->summary; - - /* call parent implementation */ - parent_class->close (folder, expunge, ex); - - /* XXX only if dirty? */ - camel_folder_summary_save (summary); -} - -static gboolean -_exists (CamelFolder *folder, CamelException *ex) -{ -#if 0 - CamelNNTPFolder *nntp_folder; - struct stat stat_buf; - gint stat_error; - gboolean exists; - - g_assert(folder != NULL); - - nntp_folder = CAMEL_NNTP_FOLDER (folder); - - /* check if the nntp summary path is determined */ - if (!nntp_folder->summary_file_path) { - camel_exception_set (ex, - CAMEL_EXCEPTION_FOLDER_INVALID, - "undetermined folder summary path. Maybe use set_name ?"); - return FALSE; - } - - /* check if the nntp file exists */ - stat_error = stat (nntp_folder->summary_file_path, &stat_buf); - if (stat_error == -1) - return FALSE; - - exists = S_ISREG (stat_buf.st_mode); - /* we should check the rights here */ - - return exists; -#endif - return TRUE; -} - -static gboolean -_create (CamelFolder *folder, CamelException *ex) -{ -#if 0 - CamelNNTPSummary *summary; - g_assert(folder != NULL); - - /* call default implementation */ - parent_class->create (folder, ex); - - /* create the summary object */ - summary = CAMEL_NNTP_SUMMARY (gtk_object_new (camel_nntp_summary_get_type (), NULL)); - summary->nb_message = 0; - summary->next_uid = 1; - summary->nntp_file_size = 0; - summary->message_info = g_array_new (FALSE, FALSE, sizeof (CamelNNTPSummaryInformation)); -#endif - - return TRUE; -} - -static gboolean -_delete (CamelFolder *folder, gboolean recurse, CamelException *ex) -{ -#if 0 - gboolean folder_already_exists; - - g_assert(folder != NULL); - - /* check if the folder object exists */ - - /* 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); -#endif - return TRUE; -} - -gboolean -_delete_messages (CamelFolder *folder, CamelException *ex) -{ - - gboolean folder_already_exists; - - g_assert(folder!=NULL); - - /* 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; - - return TRUE; -} - -static GList * -_list_subfolders (CamelFolder *folder, CamelException *ex) -{ - /* newsgroups don't have subfolders */ - return NULL; -} - -static gint -_get_message_count (CamelFolder *folder, CamelException *ex) -{ - CamelNNTPFolder *nntp_folder = CAMEL_NNTP_FOLDER(folder); - - g_assert (folder); - g_assert (nntp_folder->summary); - - return camel_folder_summary_count(nntp_folder->summary); -} - -#if 0 -static void -_append_message (CamelFolder *folder, CamelMimeMessage *message, CamelException *ex) -{ - CamelNNTPFolder *nntp_folder = CAMEL_NNTP_FOLDER (folder); -#if 0 - CamelNNTPSummary *summary = CAMEL_NNTP_SUMMARY (folder->summary); -#endif - CamelStream *output_stream; - guint32 tmp_file_size; - guint32 next_uid; - gint tmp_file_fd; - GArray *message_info_array; -#if 0 - GArray *nntp_summary_info; -#endif - gchar *tmp_message_filename; - gint fd1, fd2; - int i; - - /* 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_flush (output_stream); - gtk_object_unref (GTK_OBJECT (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 */ - - /* - First : parse the nntp file, but only from the - position where the message has been added, - wich happens to be the last postion in the - nntp file before we added the message. - This position is still stored in the summary - for the moment - */ - next_uid = summary->next_uid; - tmp_file_fd = open (tmp_message_filename, O_RDONLY); - message_info_array = - camel_nntp_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, again */ - next_uid = summary->next_uid; - - /* make sure all our of message info's have 0 uid - ignore any - set elsewhere */ - for (i=0;ilen;i++) { - g_array_index(message_info_array, CamelNNTPParserMessageInfo, i).uid = 0; - } - - /* - 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 - */ -#if 0 - next_uid = camel_nntp_write_xev (nntp_folder, tmp_message_filename, - message_info_array, &tmp_file_size, next_uid, ex); - -#endif - if (camel_exception_get_id (ex)) { - /* ** FIXME : free the preparsed information */ - return; - } - -#if 0 - nntp_summary_info = - parsed_information_to_nntp_summary (message_info_array); -#endif - - /* store the number of messages as well as the summary array */ - summary->nb_message += 1; - summary->next_uid = next_uid; - - ((CamelNNTPSummaryInformation *)(nntp_summary_info->data))->position += - summary->nntp_file_size; - summary->nntp_file_size += tmp_file_size; - - camel_nntp_summary_append_entries (summary, nntp_summary_info); - g_array_free (nntp_summary_info, TRUE); - - - /* append the temporary file message to the nntp file */ - fd1 = open (tmp_message_filename, O_RDONLY); - fd2 = open (nntp_folder->folder_file_path, - O_WRONLY | O_CREAT | O_APPEND, - 0600); - - if (fd2 == -1) { - camel_exception_setv (ex, - CAMEL_EXCEPTION_FOLDER_INSUFFICIENT_PERMISSION, - "could not open the nntp folder file for appending the message\n" - "\t%s\n" - "Full error is : %s\n", - nntp_folder->folder_file_path, - strerror (errno)); - return; - } - - camel_nntp_copy_file_chunk (fd1, - fd2, - tmp_file_size, - ex); - close (fd1); - close (fd2); - - /* remove the temporary file */ - unlink (tmp_message_filename); - - g_free (tmp_message_filename); -} -#endif - - - -static GPtrArray * -_get_uid_array (CamelFolder *folder, CamelException *ex) -{ - CamelNNTPFolder *nntp_folder = CAMEL_NNTP_FOLDER (folder); - GPtrArray *message_info_array, *out; - CamelMessageInfo *message_info; - int i; - - message_info_array = nntp_folder->summary->messages; - - out = g_ptr_array_new (); - g_ptr_array_set_size (out, message_info_array->len); - - for (i=0; ilen; i++) { - message_info = (CamelMessageInfo *)(message_info_array->pdata) + i; - out->pdata[i] = g_strdup (message_info->uid); - } - - return out; -} - -static CamelMimeMessage * -_get_message_by_uid (CamelFolder *folder, const gchar *uid, CamelException *ex) -{ - CamelStream *nntp_istream; - CamelStream *message_stream; - CamelMimeMessage *message = NULL; - CamelStore *parent_store; - char *buf; - int buf_len; - int buf_alloc; - int status; - gboolean done; - - /* get the parent store */ - parent_store = camel_folder_get_parent_store (folder, ex); - if (camel_exception_get_id (ex)) { - return NULL; - } - - status = camel_nntp_command (CAMEL_NNTP_STORE( parent_store ), NULL, "ARTICLE %s", uid); - - nntp_istream = CAMEL_NNTP_STORE (parent_store)->istream; - - /* if the uid was not found, raise an exception and return */ - if (status != CAMEL_NNTP_OK) { - camel_exception_setv (ex, - CAMEL_EXCEPTION_FOLDER_INVALID_UID, - "message %s not found.", - uid); - return NULL; - } - - /* XXX ick ick ick. read the entire message into a buffer and - then create a stream_mem for it. */ - buf_alloc = 2048; - buf_len = 0; - buf = malloc(buf_alloc); - done = FALSE; - - buf[0] = 0; - - while (!done) { - char *line = camel_stream_buffer_read_line ( CAMEL_STREAM_BUFFER ( nntp_istream ), ex); - int line_length; - - /* XXX check exception */ - - line_length = strlen ( line ); - - if (!strcmp(line, ".")) { - done = TRUE; - g_free (line); - } - else { - if (buf_len + line_length > buf_alloc) { - buf_alloc *= 2; - buf = realloc (buf, buf_alloc); - } - strcat(buf, line); - strcat(buf, "\n"); - buf_len += strlen(line) + 1; - g_free (line); - } - } - - /* create a stream bound to the message */ - message_stream = camel_stream_mem_new_with_buffer(buf, buf_len); - - message = camel_mime_message_new (); - if (camel_data_wrapper_construct_from_stream ((CamelDataWrapper *)message, message_stream) == -1) { - gtk_object_unref ((GtkObject *)message); - gtk_object_unref ((GtkObject *)message_stream); - camel_exception_setv (ex, - CAMEL_EXCEPTION_FOLDER_INVALID_UID, /* XXX */ - "Could not create message for uid %s.", uid); - - return NULL; - } - gtk_object_unref ((GtkObject *)message_stream); - - /* init other fields? */ - message->folder = folder; - gtk_object_ref((GtkObject *)folder); - message->message_uid = g_strdup(uid); - -#if 0 - gtk_signal_connect((GtkObject *)message, "message_changed", message_changed, folder); -#endif - - return message; -} - -/* get message info for a range of messages */ -static GPtrArray * -summary_get_message_info (CamelFolder *folder, int first, int count) -{ - GPtrArray *array = g_ptr_array_new(); - int i, maxcount; - CamelNNTPFolder *nntp_folder = (CamelNNTPFolder *)folder; - - maxcount = camel_folder_summary_count(nntp_folder->summary); - maxcount = MIN(first + count, maxcount); - for (i=first;isummary->messages, i)); - - return array; -} diff --git a/camel/providers/nntp/camel-nntp-folder.h b/camel/providers/nntp/camel-nntp-folder.h deleted file mode 100644 index 7a445d697f..0000000000 --- a/camel/providers/nntp/camel-nntp-folder.h +++ /dev/null @@ -1,73 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-nntp-folder.h : NNTP group (folder) support. */ - -/* - * - * Author : Chris Toshok - * - * Copyright (C) 2000 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_NNTP_FOLDER_H -#define CAMEL_NNTP_FOLDER_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include -#include "camel-folder.h" - -/* #include "camel-store.h" */ - -#define CAMEL_NNTP_FOLDER_TYPE (camel_nntp_folder_get_type ()) -#define CAMEL_NNTP_FOLDER(obj) (GTK_CHECK_CAST((obj), CAMEL_NNTP_FOLDER_TYPE, CamelNNTPFolder)) -#define CAMEL_NNTP_FOLDER_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_NNTP_FOLDER_TYPE, CamelNNTPFolderClass)) -#define IS_CAMEL_NNTP_FOLDER(o) (GTK_CHECK_TYPE((o), CAMEL_NNTP_FOLDER_TYPE)) - - -typedef struct { - CamelFolder parent_object; - - gchar *summary_file_path; /* contains the messages summary */ - CamelFolderSummary *summary; -} CamelNNTPFolder; - - - -typedef struct { - CamelFolderClass parent_class; - - /* Virtual methods */ - -} CamelNNTPFolderClass; - - -/* public methods */ - -/* Standard Gtk function */ -GtkType camel_nntp_folder_get_type (void); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* CAMEL_NNTP_FOLDER_H */ diff --git a/camel/providers/nntp/camel-nntp-provider.c b/camel/providers/nntp/camel-nntp-provider.c deleted file mode 100644 index fe50a1f952..0000000000 --- a/camel/providers/nntp/camel-nntp-provider.c +++ /dev/null @@ -1,69 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-nntp-provider.c: nntp provider registration code */ - -/* - * Authors : - * Chris Toshok - * - * Copyright (C) 2000 Helix Code, Inc. (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-nntp-store.h" -#include "camel-provider.h" -#include "camel-session.h" - -static CamelProvider news_provider = { - "news", - "USENET news", - - "This is a read-only provider for USENET newsgroups.", - - CAMEL_PROVIDER_IS_REMOTE, - - { 0, 0 } -}; - -static CamelProvider nntp_provider = { - "nntp", - "USENET news via NNTP", - - "This is a provider for reading from and posting to" - "USENET newsgroups.", - - CAMEL_PROVIDER_IS_REMOTE, - - { 0, 0 } -}; - -void -camel_provider_module_init (CamelSession *session) -{ - news_provider.object_types[CAMEL_PROVIDER_STORE] = - camel_nntp_store_get_type(); -#ifdef NOTYET - nntp_provider.object_types[CAMEL_PROVIDER_TRANSPORT] = - camel_nntp_transport_get_type(); -#endif - - camel_session_register_provider (session, &news_provider); - camel_session_register_provider (session, &nntp_provider); -} - - - diff --git a/camel/providers/nntp/camel-nntp-store.c b/camel/providers/nntp/camel-nntp-store.c deleted file mode 100644 index 2a0084eee2..0000000000 --- a/camel/providers/nntp/camel-nntp-store.c +++ /dev/null @@ -1,486 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-nntp-store.c : class for an nntp store */ - -/* - * - * Copyright (C) 2000 Helix Code, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "libgnome/libgnome.h" - -#include "camel-folder-summary.h" -#include "camel-nntp-store.h" -#include "camel-nntp-folder.h" -#include "camel-stream-buffer.h" -#include "camel-stream-fs.h" -#include "camel-exception.h" -#include "camel-url.h" -#include "string-utils.h" - -#define NNTP_PORT 119 - -static CamelServiceClass *service_class = NULL; - -/* Returns the class for a CamelNNTPStore */ -#define CNNTPS_CLASS(so) CAMEL_NNTP_STORE_CLASS (GTK_OBJECT(so)->klass) -#define CF_CLASS(so) CAMEL_FOLDER_CLASS (GTK_OBJECT(so)->klass) -#define CNNTPF_CLASS(so) CAMEL_NNTP_FOLDER_CLASS (GTK_OBJECT(so)->klass) - -static CamelFolder *_get_folder (CamelStore *store, const gchar *folder_name, CamelException *ex); -static char *_get_folder_name (CamelStore *store, const char *folder_name, - CamelException *ex); - -static gboolean nntp_connect (CamelService *service, CamelException *ex); -static gboolean nntp_disconnect (CamelService *service, CamelException *ex); - -static void -camel_nntp_store_class_init (CamelNNTPStoreClass *camel_nntp_store_class) -{ - CamelStoreClass *camel_store_class = CAMEL_STORE_CLASS (camel_nntp_store_class); - - service_class = gtk_type_class (camel_service_get_type ()); - - /* virtual method overload */ - camel_store_class->get_folder = _get_folder; - camel_store_class->get_folder_name = _get_folder_name; -} - - - -static void -camel_nntp_store_init (gpointer object, gpointer klass) -{ - CamelService *service = CAMEL_SERVICE (object); - - service->url_flags = CAMEL_SERVICE_URL_NEED_HOST; -} - -GtkType -camel_nntp_store_get_type (void) -{ - static GtkType camel_nntp_store_type = 0; - - if (!camel_nntp_store_type) { - GtkTypeInfo camel_nntp_store_info = - { - "CamelNNTPStore", - sizeof (CamelNNTPStore), - sizeof (CamelNNTPStoreClass), - (GtkClassInitFunc) camel_nntp_store_class_init, - (GtkObjectInitFunc) camel_nntp_store_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_nntp_store_type = gtk_type_unique (CAMEL_STORE_TYPE, &camel_nntp_store_info); - } - - return camel_nntp_store_type; -} - -static CamelFolder * -_get_folder (CamelStore *store, const gchar *folder_name, CamelException *ex) -{ - CamelNNTPFolder *new_nntp_folder; - CamelFolder *new_folder; - - /* check if folder has already been created */ - /* call the standard routine for that when */ - /* it is done ... */ - - new_nntp_folder = gtk_type_new (CAMEL_NNTP_FOLDER_TYPE); - new_folder = CAMEL_FOLDER (new_nntp_folder); - - /* XXX We shouldn't be passing NULL here, but it's equivalent to - * what was there before, and there's no - * CamelNNTPFolder::get_subfolder yet anyway... - */ - CF_CLASS (new_folder)->init (new_folder, store, NULL, - folder_name, '/', ex); - - return new_folder; -} - - -static char * -_get_folder_name (CamelStore *store, const char *folder_name, - CamelException *ex) -{ - return g_strdup (folder_name); -} - -/** - * camel_nntp_store_open: Connect to the server if we are currently - * disconnected. - * @store: the store - * @ex: a CamelException - * - **/ -void -camel_nntp_store_open (CamelNNTPStore *store, CamelException *ex) -{ - CamelService *service = CAMEL_SERVICE (store); - if (!camel_service_is_connected (service)) - nntp_connect (service, ex); -} - -/** - * camel_nntp_store_close: Close the connection to the server - * @store: the store - * @ex: a CamelException - * - **/ -void -camel_nntp_store_close (CamelNNTPStore *store, gboolean expunge, - CamelException *ex) -{ - camel_nntp_command (store, NULL, "QUIT"); - - nntp_disconnect (CAMEL_SERVICE (store), ex); -} - -static gboolean -nntp_connect (CamelService *service, CamelException *ex) -{ - struct hostent *h; - struct sockaddr_in sin; - int fd; - char *buf; - CamelNNTPStore *store = CAMEL_NNTP_STORE (service); - - if (!service_class->connect (service, ex)) - return FALSE; - - h = camel_service_gethost (service, ex); - if (!h) - return FALSE; - - sin.sin_family = h->h_addrtype; - sin.sin_port = htons (service->url->port ? service->url->port : NNTP_PORT); - memcpy (&sin.sin_addr, h->h_addr, sizeof (sin.sin_addr)); - - fd = socket (h->h_addrtype, SOCK_STREAM, 0); - if (fd == -1 || - connect (fd, (struct sockaddr *)&sin, sizeof(sin)) == -1) { - camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE, - "Could not connect to %s (port %s): %s", - service->url->host, service->url->port, - strerror(errno)); - if (fd > -1) - close (fd); - return FALSE; - } - - store->ostream = camel_stream_fs_new_with_fd (fd); - store->istream = camel_stream_buffer_new (store->ostream, - CAMEL_STREAM_BUFFER_READ); - - /* Read the greeting */ - buf = camel_stream_buffer_read_line (CAMEL_STREAM_BUFFER (store->istream), ex /* XX check this */); - if (!buf) { - return -1; - } - - g_free (buf); - - /* get a list of extensions that the server supports */ - if (CAMEL_NNTP_OK == camel_nntp_command (store, NULL, "LIST EXTENSIONS")) { - char *ext_response = camel_nntp_command_get_additional_data(store); - - g_free (ext_response); - } - - return TRUE; -} - -static gboolean -nntp_disconnect (CamelService *service, CamelException *ex) -{ - CamelNNTPStore *store = CAMEL_NNTP_STORE (service); - - if (!service->connected) - return TRUE; - - if (!service_class->disconnect (service, ex)) - return FALSE; - - gtk_object_unref (GTK_OBJECT (store->ostream)); - gtk_object_unref (GTK_OBJECT (store->istream)); - store->ostream = NULL; - store->istream = NULL; - return TRUE; -} - -/** - * camel_nntp_command: Send a command to a NNTP server. - * @store: the NNTP store - * @ret: a pointer to return the full server response in - * @fmt: a printf-style format string, followed by arguments - * - * This command sends the command specified by @fmt and the following - * arguments to the connected NNTP store specified by @store. It then - * reads the server's response and parses out the status code. If - * the caller passed a non-NULL pointer for @ret, camel_nntp_command - * will set it to point to an buffer containing the rest of the - * response from the NNTP server. (If @ret was passed but there was - * no extended response, @ret will be set to NULL.) The caller must - * free this buffer when it is done with it. - * - * Return value: one of CAMEL_NNTP_OK (command executed successfully), - * CAMEL_NNTP_ERR (command encounted an error), or CAMEL_NNTP_FAIL - * (a protocol-level error occurred, and Camel is uncertain of the - * result of the command.) - **/ -int -camel_nntp_command (CamelNNTPStore *store, char **ret, char *fmt, ...) -{ - char *cmdbuf, *respbuf; - va_list ap; - int status; - int resp_code; - CamelException *ex; - - va_start (ap, fmt); - cmdbuf = g_strdup_vprintf (fmt, ap); - va_end (ap); - - ex = camel_exception_new(); - - /* make sure we're connected */ - if (store->ostream == NULL) - nntp_connect (CAMEL_SERVICE (store), ex); - - if (camel_exception_get_id (ex)) { - camel_exception_free (ex); - return CAMEL_NNTP_FAIL; - } - - /* Send the command */ - camel_stream_write (store->ostream, cmdbuf, strlen (cmdbuf), ex /* XXX */); - g_free (cmdbuf); - camel_stream_write (store->ostream, "\r\n", 2, ex /* XXX */); - - /* Read the response */ - respbuf = camel_stream_buffer_read_line (CAMEL_STREAM_BUFFER (store->istream), ex /* XXX */); - resp_code = atoi (respbuf); - - if (resp_code < 400) - status = CAMEL_NNTP_OK; - else if (resp_code < 500) - status = CAMEL_NNTP_ERR; - else - status = CAMEL_NNTP_FAIL; - - if (ret) { - *ret = strchr (respbuf, ' '); - if (*ret) - *ret = g_strdup (*ret + 1); - } - g_free (respbuf); - - return status; -} - -/** - * camel_nntp_command_get_additional_data: get "additional data" from - * a NNTP command. - * @store: the NNTP store - * - * This command gets the additional data returned by - * This command gets the additional data returned by "multi-line" POP - * commands, such as LIST, RETR, TOP, and UIDL. This command _must_ - * be called after a successful (CAMEL_NNTP_OK) call to - * camel_nntp_command for a command that has a multi-line response. - * The returned data is un-byte-stuffed, and has lines termined by - * newlines rather than CR/LF pairs. - * - * Return value: the data, which the caller must free. - **/ -char * -camel_nntp_command_get_additional_data (CamelNNTPStore *store) -{ - CamelStreamBuffer *stream = CAMEL_STREAM_BUFFER (store->istream); - GPtrArray *data; - char *buf; - int i, status = CAMEL_NNTP_OK; - CamelException *ex = camel_exception_new(); - - data = g_ptr_array_new (); - while (1) { - buf = camel_stream_buffer_read_line (stream, ex /* XXX */); - if (!buf) { - status = CAMEL_NNTP_FAIL; - break; - } - - if (!strcmp (buf, ".")) - break; - if (*buf == '.') - memmove (buf, buf + 1, strlen (buf)); - g_ptr_array_add (data, buf); - } - - if (status == CAMEL_NNTP_OK) { - /* Append an empty string to the end of the array - * so when we g_strjoinv it, we get a "\n" after - * the last real line. - */ - g_ptr_array_add (data, ""); - g_ptr_array_add (data, NULL); - buf = g_strjoinv ("\n", (char **)data->pdata); - } else - buf = NULL; - - for (i = 0; i < data->len - 2; i++) - g_free (data->pdata[i]); - g_ptr_array_free (data, TRUE); - - return buf; -} - -void -camel_nntp_store_subscribe_group (CamelStore *store, - const gchar *group_name) -{ - gchar *root_dir = camel_nntp_store_get_toplevel_dir(CAMEL_NNTP_STORE(store)); - char *ret = NULL; - CamelException *ex = camel_exception_new(); - - camel_nntp_store_open(CAMEL_NNTP_STORE(store), ex); - - if (camel_exception_get_id (ex)) { - g_free (root_dir); - camel_exception_free (ex); - return; - } - - if (CAMEL_NNTP_OK == camel_nntp_command ( CAMEL_NNTP_STORE (store), - &ret, "GROUP %s", group_name)) { - /* we create an empty summary file here, so that when - the group is opened we'll know we need to build it. */ - gchar *summary_file; - int fd; - summary_file = g_strdup_printf ("%s/%s-ev-summary", root_dir, group_name); - - fd = open (summary_file, O_CREAT | O_RDWR, 0666); - close (fd); - - g_free (summary_file); - } - if (ret) g_free (ret); - - g_free (root_dir); - camel_exception_free (ex); -} - -void -camel_nntp_store_unsubscribe_group (CamelStore *store, - const gchar *group_name) -{ - gchar *root_dir = camel_nntp_store_get_toplevel_dir(CAMEL_NNTP_STORE(store)); - gchar *summary_file; - - summary_file = g_strdup_printf ("%s/%s-ev-summary", root_dir, group_name); - if (g_file_exists (summary_file)) - unlink (summary_file); - g_free (summary_file); - - g_free (root_dir); -} - -GList * -camel_nntp_store_list_subscribed_groups(CamelStore *store) -{ - GList *group_name_list = NULL; - struct stat stat_buf; - gint stat_error = 0; - gchar *entry_name; - gchar *full_entry_name; - gchar *real_group_name; - struct dirent *dir_entry; - DIR *dir_handle; - gchar *root_dir = camel_nntp_store_get_toplevel_dir(CAMEL_NNTP_STORE(store)); - - dir_handle = opendir (root_dir); - g_return_val_if_fail (dir_handle, NULL); - - /* 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", root_dir, entry_name); - stat_error = stat (full_entry_name, &stat_buf); - g_free (full_entry_name); - - /* is it a normal file ending in -ev-summary ? */ - if ((stat_error != -1) && S_ISREG (stat_buf.st_mode)) { - gboolean summary_suffix_found; - - real_group_name = string_prefix (entry_name, "-ev-summary", - &summary_suffix_found); - - if (summary_suffix_found) - /* add the folder name to the list */ - group_name_list = g_list_append (group_name_list, - real_group_name); - } - /* read next entry */ - dir_entry = readdir (dir_handle); - } - - closedir (dir_handle); - - return group_name_list; -} - -gchar * -camel_nntp_store_get_toplevel_dir (CamelNNTPStore *store) -{ - CamelURL *url = CAMEL_SERVICE (store)->url; - char *news_dir; - char *top_dir; - - g_assert(url != NULL); - - news_dir = gnome_util_prepend_user_home ("evolution/news"); - - top_dir = g_strdup_printf( "%s/%s", - news_dir, - url->host ); - - g_free (news_dir); - - return top_dir; -} diff --git a/camel/providers/nntp/camel-nntp-store.h b/camel/providers/nntp/camel-nntp-store.h deleted file mode 100644 index 257772d7cb..0000000000 --- a/camel/providers/nntp/camel-nntp-store.h +++ /dev/null @@ -1,85 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-nntp-store.h : class for an nntp store */ - -/* - * - * Copyright (C) 2000 Helix Code, Inc. - * - * 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_NNTP_STORE_H -#define CAMEL_NNTP_STORE_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include -#include "camel-store.h" - -#define CAMEL_NNTP_STORE_TYPE (camel_nntp_store_get_type ()) -#define CAMEL_NNTP_STORE(obj) (GTK_CHECK_CAST((obj), CAMEL_NNTP_STORE_TYPE, CamelNNTPStore)) -#define CAMEL_NNTP_STORE_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_NNTP_STORE_TYPE, CamelNNTPStoreClass)) -#define IS_CAMEL_NNTP_STORE(o) (GTK_CHECK_TYPE((o), CAMEL_NNTP_STORE_TYPE)) - - -typedef struct { - CamelStore parent_object; - -#define CAMEL_NNTP_EXT_XOVER 0x01 - guint32 extensions; - - CamelStream *istream, *ostream; -} CamelNNTPStore; - - - -typedef struct { - CamelStoreClass parent_class; - -} CamelNNTPStoreClass; - - -/* public methods */ -void camel_nntp_store_open (CamelNNTPStore *store, CamelException *ex); -void camel_nntp_store_close (CamelNNTPStore *store, gboolean expunge, - CamelException *ex); - -void camel_nntp_store_subscribe_group (CamelStore *store, const gchar *group_name); -void camel_nntp_store_unsubscribe_group (CamelStore *store, const gchar *group_name); -GList *camel_nntp_store_list_subscribed_groups(CamelStore *store); - -gchar *camel_nntp_store_get_toplevel_dir (CamelNNTPStore *store); - -/* support functions */ -enum { CAMEL_NNTP_OK, CAMEL_NNTP_ERR, CAMEL_NNTP_FAIL }; -int camel_nntp_command (CamelNNTPStore *store, char **ret, char *fmt, ...); -char *camel_nntp_command_get_additional_data (CamelNNTPStore *store); - -/* Standard Gtk function */ -GtkType camel_nntp_store_get_type (void); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* CAMEL_NNTP_STORE_H */ - - diff --git a/camel/providers/nntp/camel-nntp-utils.c b/camel/providers/nntp/camel-nntp-utils.c deleted file mode 100644 index 7100be0aed..0000000000 --- a/camel/providers/nntp/camel-nntp-utils.c +++ /dev/null @@ -1,211 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-nntp-utils.c : utilities used by the nntp code. */ - -/* - * Author : Chris Toshok - * - * Copyright (C) 2000 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 "camel-folder-summary.h" -#include "camel-nntp-folder.h" -#include "camel-nntp-store.h" -#include "camel-nntp-utils.h" -#include "camel-stream-buffer.h" -#include "camel-stream-mem.h" - -#include -#include - -static void -get_XOVER_headers(CamelNNTPStore *nntp_store, CamelFolder *folder, - int first_message, int last_message, CamelException *ex) -{ - int status; - CamelNNTPFolder *nntp_folder = CAMEL_NNTP_FOLDER (folder); - - status = camel_nntp_command (nntp_store, NULL, - "XOVER %d-%d", - first_message, - last_message); - - if (status == CAMEL_NNTP_OK) { - CamelStream *nntp_istream = nntp_store->istream; - gboolean done = FALSE; - - while (!done) { - char *line; - - line = camel_stream_buffer_read_line ( - CAMEL_STREAM_BUFFER ( nntp_istream ), ex /* XXX */); - - if (*line == '.') { - done = TRUE; - } - else { - CamelMessageInfo *new_info = g_new0(CamelMessageInfo, 1); - char **split_line = g_strsplit (line, "\t", 7); - - new_info->subject = g_strdup(split_line[1]); - new_info->from = g_strdup(split_line[2]); - new_info->to = g_strdup(folder->name); -#if 0 - new_info->date_sent = g_strdup(split_line[3]); - /* XXX do we need to fill in both dates? */ - new_info->headers.date_received = g_strdup(split_line[3]); -#endif - new_info->size = atoi(split_line[5]); - new_info->uid = g_strdup(split_line[4]); - g_strfreev (split_line); - - camel_folder_summary_add (nntp_folder->summary, new_info); - } - g_free (line); - } - } -} - -#if 0 -static GArray* -get_HEAD_headers(CamelNNTPStore *nntp_store, CamelFolder *folder, - int first_message, int last_message, CamelException *ex) -{ - int i; - int status; - GArray *array; - CamelMessageInfo info; - - array = g_array_new(FALSE, FALSE, sizeof(CamelMessageInfo)); - - for (i = first_message; i < last_message; i ++) { - status = camel_nntp_command (nntp_store, NULL, - "HEAD %d", i); - - if (status == CAMEL_NNTP_OK) { - gboolean done = FALSE; - char *buf; - int buf_len; - int buf_alloc; - int h; - CamelStream *header_stream; - GArray *header_array; - CamelStream *nntp_istream; - - buf_alloc = 2048; - buf_len = 0; - buf = malloc(buf_alloc); - done = FALSE; - - buf[0] = 0; - - nntp_istream = nntp_store->istream; - - while (!done) { - char *line; - int line_length; - - line = camel_stream_buffer_read_line ( - CAMEL_STREAM_BUFFER ( nntp_istream )); - line_length = strlen ( line ); - - if (*line == '.') { - done = TRUE; - } - else { - if (buf_len + line_length > buf_alloc) { - buf_alloc *= 2; - buf = realloc (buf, buf_alloc); - } - strcat(buf, line); - strcat(buf, "\n"); - buf_len += strlen(line); - g_free (line); - } - } - - /* create a stream from which to parse the headers */ - header_stream = camel_stream_mem_new_with_buffer(buf, - buf_len, - CAMEL_STREAM_MEM_READ); - - header_array = get_header_array_from_stream (header_stream); - - memset (&info, 0, sizeof(info)); - - for (h = 0; h < header_array->len; h ++) { - Rfc822Header *header = &((Rfc822Header*)header_array->data)[h]; - if (!g_strcasecmp(header->name, "From")) - info.from = g_strdup(header->value); - else if (!g_strcasecmp(header->name, "To")) - info.to = g_strdup(header->value); - else if (!g_strcasecmp(header->name, "Subject")) - info.subject = g_strdup(header->value); - else if (!g_strcasecmp(header->name, "Message-ID")) - info.uid = g_strdup(header->value); - else if (!g_strcasecmp(header->name, "Date")) { -#if 0 - info.date_sent = g_strdup(header->value); - info.date_received = g_strdup(header->value); -#endif - } - } - g_array_append_val(array, info); - } - else if (status == CAMEL_NNTP_FAIL) { - /* nasty things are afoot */ - g_warning ("failure doing HEAD\n"); - break; - } - } - return array; -} -#endif - -void -camel_nntp_get_headers (CamelStore *store, - CamelNNTPFolder *nntp_folder, - CamelException *ex) -{ - CamelNNTPStore *nntp_store = CAMEL_NNTP_STORE (store); - CamelFolder *folder = CAMEL_FOLDER (nntp_folder); - char *ret; - int first_message, nb_message, last_message; - int status; - - status = camel_nntp_command (nntp_store, &ret, - "GROUP %s", folder->name); - - sscanf (ret, "%d %d %d", &nb_message, &first_message, &last_message); - g_free (ret); - - if (status != CAMEL_NNTP_OK) { - /* XXX throw invalid group exception */ - printf ("invalid group\n"); - return; - } - - if (nntp_store->extensions & CAMEL_NNTP_EXT_XOVER) { - get_XOVER_headers (nntp_store, folder, first_message, last_message, ex); - } - else { -#if 0 - get_HEAD_headers (nntp_store, folder, first_message, last_message, ex); -#endif - } -} - diff --git a/camel/providers/nntp/camel-nntp-utils.h b/camel/providers/nntp/camel-nntp-utils.h deleted file mode 100644 index f28697c744..0000000000 --- a/camel/providers/nntp/camel-nntp-utils.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-nntp-utils.h : Utilities for the NNTP provider */ - -/* - * - * Author : Chris Toshok - * - * 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_NNTP_UTILS_H -#define CAMEL_NNTP_UTILS_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -void camel_nntp_get_headers (CamelStore *store, CamelNNTPFolder *nntp_folder, CamelException *ex); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* CAMEL_NNTP_UTILS_H */ diff --git a/camel/providers/nntp/libcamelnntp.urls b/camel/providers/nntp/libcamelnntp.urls deleted file mode 100644 index dee2e70f14..0000000000 --- a/camel/providers/nntp/libcamelnntp.urls +++ /dev/null @@ -1,2 +0,0 @@ -news -nntp diff --git a/camel/providers/pop3/.cvsignore b/camel/providers/pop3/.cvsignore deleted file mode 100644 index 7d926a5545..0000000000 --- a/camel/providers/pop3/.cvsignore +++ /dev/null @@ -1,6 +0,0 @@ -Makefile -Makefile.in -.libs -.deps -*.lo -*.la diff --git a/camel/providers/pop3/Makefile.am b/camel/providers/pop3/Makefile.am deleted file mode 100644 index f30d73e736..0000000000 --- a/camel/providers/pop3/Makefile.am +++ /dev/null @@ -1,35 +0,0 @@ -## Process this file with automake to produce Makefile.in - -SUBDIRS = - -libcamelpop3includedir = $(includedir)/camel - -providerdir = $(pkglibdir)/camel-providers/$(VERSION) - -provider_LTLIBRARIES = libcamelpop3.la -provider_DATA = libcamelpop3.urls - -INCLUDES = \ - -I.. \ - -I$(srcdir)/.. \ - -I$(srcdir)/../../.. \ - -I$(includedir) \ - -I$(top_srcdir)/intl \ - $(GTK_INCLUDEDIR) \ - -I$(top_srcdir)/camel \ - $(KRB4_CFLAGS) \ - -DG_LOG_DOMAIN=\"camel-pop3-provider\" - -libcamelpop3_la_SOURCES = \ - camel-pop3-folder.c \ - camel-pop3-provider.c \ - camel-pop3-store.c - -libcamelpop3include_HEADERS = \ - camel-pop3-folder.h \ - camel-pop3-store.h - - -libcamelpop3_la_LDFLAGS = $(KRB4_LDFLAGS) -version-info 0:0:0 -rpath $(libdir) - -EXTRA_DIST = libcamelpop3.urls diff --git a/camel/providers/pop3/camel-pop3-folder.c b/camel/providers/pop3/camel-pop3-folder.c deleted file mode 100644 index 45687e4f33..0000000000 --- a/camel/providers/pop3/camel-pop3-folder.c +++ /dev/null @@ -1,271 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-pop3-folder.c : class for a pop3 folder */ - -/* - * Authors: - * Dan Winship - * - * Copyright (C) 2000 Helix Code, Inc. (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 "camel-pop3-folder.h" -#include "camel-pop3-store.h" -#include "camel-exception.h" -#include "camel-stream-mem.h" -#include "camel-mime-message.h" - -#include -#include - -#define CF_CLASS(o) (CAMEL_FOLDER_CLASS (GTK_OBJECT (o)->klass)) -static CamelFolderClass *parent_class; - -static void pop3_open (CamelFolder *folder, CamelFolderOpenMode mode, - CamelException *ex); -static void pop3_close (CamelFolder *folder, gboolean expunge, - CamelException *ex); -static gboolean delete_messages (CamelFolder *folder, CamelException *ex); - -static gint get_message_count (CamelFolder *folder, CamelException *ex); -static GPtrArray *get_uids (CamelFolder *folder, CamelException *ex); -static CamelMimeMessage *get_message_by_uid (CamelFolder *folder, - const char *uid, - CamelException *ex); -static void delete_message_by_uid (CamelFolder *folder, const char *uid, - CamelException *ex); - - -static void -camel_pop3_folder_class_init (CamelPop3FolderClass *camel_pop3_folder_class) -{ - CamelFolderClass *camel_folder_class = - CAMEL_FOLDER_CLASS (camel_pop3_folder_class); - - parent_class = gtk_type_class (camel_folder_get_type ()); - - /* virtual method overload */ - camel_folder_class->open = pop3_open; - camel_folder_class->close = pop3_close; - camel_folder_class->delete_messages = delete_messages; - - camel_folder_class->get_message_count = get_message_count; - camel_folder_class->get_uids = get_uids; - - camel_folder_class->get_message_by_uid = get_message_by_uid; - camel_folder_class->delete_message_by_uid = delete_message_by_uid; -} - - -static void -camel_pop3_folder_init (gpointer object, gpointer klass) -{ - CamelPop3Folder *pop3_folder = CAMEL_POP3_FOLDER (object); - CamelFolder *folder = CAMEL_FOLDER (object); - - folder->can_hold_messages = TRUE; - folder->can_hold_folders = FALSE; - folder->has_summary_capability = FALSE; - folder->has_search_capability = FALSE; - - pop3_folder->count = -1; -} - - -GtkType -camel_pop3_folder_get_type (void) -{ - static GtkType camel_pop3_folder_type = 0; - - if (!camel_pop3_folder_type) { - GtkTypeInfo camel_pop3_folder_info = - { - "CamelPop3Folder", - sizeof (CamelPop3Folder), - sizeof (CamelPop3FolderClass), - (GtkClassInitFunc) camel_pop3_folder_class_init, - (GtkObjectInitFunc) camel_pop3_folder_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_pop3_folder_type = gtk_type_unique (CAMEL_FOLDER_TYPE, &camel_pop3_folder_info); - } - - return camel_pop3_folder_type; -} - - -CamelFolder *camel_pop3_folder_new (CamelStore *parent, CamelException *ex) -{ - CamelFolder *folder = - CAMEL_FOLDER (gtk_object_new (camel_pop3_folder_get_type (), - NULL)); - - CF_CLASS (folder)->init (folder, parent, NULL, "inbox", '/', ex); - return folder; -} - -static void -pop3_open (CamelFolder *folder, CamelFolderOpenMode mode, CamelException *ex) -{ - camel_pop3_store_open (CAMEL_POP3_STORE (folder->parent_store), ex); - if (camel_exception_get_id (ex) == CAMEL_EXCEPTION_NONE) - parent_class->open (folder, mode, ex); -} - -static void -pop3_close (CamelFolder *folder, gboolean expunge, CamelException *ex) -{ - camel_pop3_store_close (CAMEL_POP3_STORE (folder->parent_store), - expunge, ex); - if (camel_exception_get_id (ex) == CAMEL_EXCEPTION_NONE) - parent_class->close (folder, expunge, ex); -} - -static gboolean -delete_messages (CamelFolder *folder, CamelException *ex) -{ - int msgs; - gboolean status; - - msgs = get_message_count (folder, ex); - if (camel_exception_get_id (ex) != CAMEL_EXCEPTION_NONE) - return FALSE; - - status = TRUE; - for (; msgs > 0; msgs--) { - status = status && - (camel_pop3_command (CAMEL_POP3_STORE (folder->parent_store), - NULL, "DELE %d", msgs) == - CAMEL_POP3_OK); - } - - if (!status) { - camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE, - "Unable to delete all messages."); - } - - return status; -} - - -static CamelMimeMessage * -get_message_by_uid (CamelFolder *folder, const char *uid, CamelException *ex) -{ - int status; - char *result, *body; - CamelStream *msgstream; - CamelMimeMessage *msg; - - status = camel_pop3_command (CAMEL_POP3_STORE (folder->parent_store), - &result, "RETR %d", atoi (uid)); - if (status != CAMEL_POP3_OK) { - CamelService *service = CAMEL_SERVICE (folder->parent_store); - camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE, - "Could not retrieve message from POP " - "server %s: %s.", service->url->host, - status == CAMEL_POP3_ERR ? result : - "Unknown error"); - g_free (result); - return NULL; - } - g_free (result); - - body = camel_pop3_command_get_additional_data (CAMEL_POP3_STORE (folder->parent_store), ex); - if (!body) { - CamelService *service = CAMEL_SERVICE (folder->parent_store); - camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE, - "Could not retrieve message from POP " - "server %s: %s", service->url->host, - camel_exception_get_description (ex)); - return NULL; - } - - msgstream = camel_stream_mem_new_with_buffer (body, strlen (body)); - msg = camel_mime_message_new (); - camel_data_wrapper_construct_from_stream (CAMEL_DATA_WRAPPER (msg), - msgstream); - gtk_object_unref (GTK_OBJECT (msgstream)); - - return msg; -} - -static void -delete_message_by_uid (CamelFolder *folder, const char *uid, - CamelException *ex) -{ - int status; - char *resp; - - status = camel_pop3_command (CAMEL_POP3_STORE (folder->parent_store), - &resp, "DELE %d", atoi (uid)); - if (status != CAMEL_POP3_OK) { - camel_exception_setv (ex, CAMEL_EXCEPTION_FOLDER_INVALID_UID, - "Unable to delete message %s%s%s", - uid, resp ? ": " : "", - resp ? resp : ""); - } - g_free (resp); -} - -static gint -get_message_count (CamelFolder *folder, CamelException *ex) -{ - CamelPop3Folder *pop3_folder = CAMEL_POP3_FOLDER (folder); - int status; - char *result; - - if (pop3_folder->count != -1) - return pop3_folder->count; - - status = camel_pop3_command (CAMEL_POP3_STORE (folder->parent_store), - &result, "STAT"); - if (status != CAMEL_POP3_OK) { - CamelService *service = CAMEL_SERVICE (folder->parent_store); - camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE, - "Could not get message count from POP " - "server %s: %s.", service->url->host, - status == CAMEL_POP3_ERR ? result : - "Unknown error"); - g_free (result); - return -1; - } - - pop3_folder->count = atoi (result); - g_free (result); - return pop3_folder->count; -} - -static GPtrArray * -get_uids (CamelFolder *folder, CamelException *ex) -{ - int count, i; - GPtrArray *array; - - count = get_message_count (folder, ex); - if (count == -1) - return NULL; - - array = g_ptr_array_new (); - g_ptr_array_set_size (array, count); - for (i = 0; i < count; i++) - array->pdata[i] = g_strdup_printf ("%d", i + 1); - - return array; -} diff --git a/camel/providers/pop3/camel-pop3-folder.h b/camel/providers/pop3/camel-pop3-folder.h deleted file mode 100644 index 2a478dc283..0000000000 --- a/camel/providers/pop3/camel-pop3-folder.h +++ /dev/null @@ -1,73 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-pop3-folder.h : Class for a POP3 folder */ - -/* - * Author: - * Dan Winship - * - * Copyright (C) 2000 Helix Code, Inc. (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 CAMEL_POP3_FOLDER_H -#define CAMEL_POP3_FOLDER_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include -#include "camel-folder.h" - -#define CAMEL_POP3_FOLDER_TYPE (camel_pop3_folder_get_type ()) -#define CAMEL_POP3_FOLDER(obj) (GTK_CHECK_CAST((obj), CAMEL_POP3_FOLDER_TYPE, CamelPop3Folder)) -#define CAMEL_POP3_FOLDER_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_POP3_FOLDER_TYPE, CamelPop3FolderClass)) -#define IS_CAMEL_POP3_FOLDER(o) (GTK_CHECK_TYPE((o), CAMEL_POP3_FOLDER_TYPE)) - - -typedef struct { - CamelFolder parent_object; - - CamelMessageInfo *msg_info; - int count; - -} CamelPop3Folder; - - - -typedef struct { - CamelFolderClass parent_class; - - /* Virtual methods */ - -} CamelPop3FolderClass; - - -/* public methods */ -CamelFolder *camel_pop3_folder_new (CamelStore *parent, CamelException *ex); - -/* Standard Gtk function */ -GtkType camel_pop3_folder_get_type (void); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* CAMEL_POP3_FOLDER_H */ diff --git a/camel/providers/pop3/camel-pop3-provider.c b/camel/providers/pop3/camel-pop3-provider.c deleted file mode 100644 index dc6e2b9442..0000000000 --- a/camel/providers/pop3/camel-pop3-provider.c +++ /dev/null @@ -1,51 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-pop3-provider.c: pop3 provider registration code */ - -/* - * Authors : - * Dan Winship - * - * Copyright (C) 2000 Helix Code, Inc. (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-pop3-store.h" -#include "camel-provider.h" -#include "camel-session.h" - -static CamelProvider pop3_provider = { - "pop", - "POP", - - "For connecting to POP servers. The POP protocol can also be used " - "to retrieve mail from certain web mail providers and proprietary " - "email systems.", - - CAMEL_PROVIDER_IS_REMOTE, - - { 0, 0 } -}; - -void -camel_provider_module_init (CamelSession *session) -{ - pop3_provider.object_types[CAMEL_PROVIDER_STORE] = - camel_pop3_store_get_type(); - - camel_session_register_provider (session, &pop3_provider); -} diff --git a/camel/providers/pop3/camel-pop3-store.c b/camel/providers/pop3/camel-pop3-store.c deleted file mode 100644 index bc39d4ab2b..0000000000 --- a/camel/providers/pop3/camel-pop3-store.c +++ /dev/null @@ -1,612 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-pop3-store.c : class for a pop3 store */ - -/* - * Authors: - * Dan Winship - * - * Copyright (C) 2000 Helix Code, Inc. (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 -#include -#include -#include -#include -#include -#include -#include -#include - -#include "camel-pop3-store.h" -#include "camel-pop3-folder.h" -#include "camel-stream-buffer.h" -#include "camel-stream-fs.h" -#include "camel-session.h" -#include "camel-exception.h" -#include "camel-url.h" -#include "md5-utils.h" - -/* Specified in RFC 1939 */ -#define POP3_PORT 110 - -#ifdef HAVE_KRB4 -/* Specified nowhere */ -#define KPOP_PORT 1109 - -#include -#endif - -static CamelServiceClass *service_class = NULL; - -static void finalize (GtkObject *object); - -static gboolean pop3_connect (CamelService *service, CamelException *ex); -static gboolean pop3_disconnect (CamelService *service, CamelException *ex); -static GList *query_auth_types (CamelService *service, CamelException *ex); -static void free_auth_types (CamelService *service, GList *authtypes); - -static CamelFolder *get_folder (CamelStore *store, const char *folder_name, - CamelException *ex); -static char *get_folder_name (CamelStore *store, const char *folder_name, - CamelException *ex); -static char *get_root_folder_name (CamelStore *store, CamelException *ex); - - -static void -camel_pop3_store_class_init (CamelPop3StoreClass *camel_pop3_store_class) -{ - GtkObjectClass *object_class = - GTK_OBJECT_CLASS (camel_pop3_store_class); - CamelServiceClass *camel_service_class = - CAMEL_SERVICE_CLASS (camel_pop3_store_class); - CamelStoreClass *camel_store_class = - CAMEL_STORE_CLASS (camel_pop3_store_class); - - service_class = gtk_type_class (camel_service_get_type ()); - - /* virtual method overload */ - object_class->finalize = finalize; - - camel_service_class->connect = pop3_connect; - camel_service_class->disconnect = pop3_disconnect; - camel_service_class->query_auth_types = query_auth_types; - camel_service_class->free_auth_types = free_auth_types; - - camel_store_class->get_folder = get_folder; - camel_store_class->get_folder_name = get_folder_name; - camel_store_class->get_root_folder_name = get_root_folder_name; -} - - - -static void -camel_pop3_store_init (gpointer object, gpointer klass) -{ - CamelService *service = CAMEL_SERVICE (object); - CamelStore *store = CAMEL_STORE (object); - - service->url_flags = ( CAMEL_SERVICE_URL_NEED_USER | - CAMEL_SERVICE_URL_NEED_HOST ); - store->folders = g_hash_table_new (g_str_hash, g_str_equal); -} - - - - -GtkType -camel_pop3_store_get_type (void) -{ - static GtkType camel_pop3_store_type = 0; - - if (!camel_pop3_store_type) { - GtkTypeInfo camel_pop3_store_info = - { - "CamelPop3Store", - sizeof (CamelPop3Store), - sizeof (CamelPop3StoreClass), - (GtkClassInitFunc) camel_pop3_store_class_init, - (GtkObjectInitFunc) camel_pop3_store_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_pop3_store_type = gtk_type_unique (CAMEL_STORE_TYPE, &camel_pop3_store_info); - } - - return camel_pop3_store_type; -} - -static void -finalize (GtkObject *object) -{ - CamelException ex; - - camel_exception_init (&ex); - pop3_disconnect (CAMEL_SERVICE (object), &ex); - camel_exception_clear (&ex); -} - - -static CamelServiceAuthType password_authtype = { - "Password", - - "This option will connect to the POP server using the APOP " - "protocol if possible, or a plaintext password if not.", - - "", - TRUE -}; - -#ifdef HAVE_KRB4 -static CamelServiceAuthType kpop_authtype = { - "Kerberos 4 (KPOP)", - - "This will connect to the POP server and use Kerberos 4 " - "to authenticate to it.", - - "+KPOP", - FALSE -}; -#endif - -static gboolean -try_connect (CamelService *service, CamelException *ex) -{ - struct hostent *h; - struct sockaddr_in sin; - int fd; - - h = camel_service_gethost (service, ex); - if (!h) - return FALSE; - - sin.sin_family = h->h_addrtype; - if (service->url->port) - sin.sin_port = htons (service->url->port); - else - sin.sin_port = htons (POP3_PORT); - memcpy (&sin.sin_addr, h->h_addr, sizeof (sin.sin_addr)); - - fd = socket (h->h_addrtype, SOCK_STREAM, 0); - if (fd == -1 || - connect (fd, (struct sockaddr *)&sin, sizeof(sin)) == -1) { - if (fd > -1) - close (fd); - return FALSE; - } - - close (fd); - return TRUE; -} - -static GList * -query_auth_types (CamelService *service, CamelException *ex) -{ - GList *ret = NULL; - gboolean passwd = TRUE; -#ifdef HAVE_KRB4 - gboolean kpop = TRUE; - int saved_port; -#endif - - if (service->url) { - passwd = try_connect (service, ex); - if (camel_exception_get_id (ex) != CAMEL_EXCEPTION_NONE) - return NULL; -#ifdef HAVE_KRB4 - saved_port = service->url->port; - service->url->port = KPOP_PORT; - kpop = try_connect (service, ex); - service->url->port = saved_port; - if (camel_exception_get_id (ex) != CAMEL_EXCEPTION_NONE) - return NULL; -#endif - } - - if (passwd) - ret = g_list_append (ret, &password_authtype); -#ifdef HAVE_KRB4 - if (kpop) - ret = g_list_append (ret, &kpop_authtype); -#endif - - if (!ret) { - camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE, - "Could not connect to POP server on " - "%s.", service->url->host); - } - - return ret; -} - -static void -free_auth_types (CamelService *service, GList *authtypes) -{ - g_list_free (authtypes); -} - -/** - * camel_pop3_store_open: Connect to the server if we are currently - * disconnected. - * @store: the store - * @ex: a CamelException - * - * The POP protocol does not allow deleted messages to be expunged - * except by closing the connection. Thus, camel_pop3_folder_{open,close} - * sometimes need to connect to or disconnect from the server. This - * routine reconnects to the server if we have disconnected. - * - **/ -void -camel_pop3_store_open (CamelPop3Store *store, CamelException *ex) -{ - CamelService *service = CAMEL_SERVICE (store); - - if (!camel_service_is_connected (service)) - pop3_connect (service, ex); -} - -/** - * camel_pop3_store_close: Close the connection to the server and - * possibly expunge deleted messages. - * @store: the store - * @expunge: whether or not to expunge deleted messages - * @ex: a CamelException - * - * See camel_pop3_store_open for an explanation of why this is needed. - * - **/ -void -camel_pop3_store_close (CamelPop3Store *store, gboolean expunge, - CamelException *ex) -{ - if (expunge) - camel_pop3_command (store, NULL, "QUIT"); - else - camel_pop3_command (store, NULL, "RSET"); - pop3_disconnect (CAMEL_SERVICE (store), ex); -} - -static gboolean -pop3_connect (CamelService *service, CamelException *ex) -{ - struct hostent *h; - struct sockaddr_in sin; - int fd, status; - char *buf, *apoptime, *apopend, *msg; - CamelPop3Store *store = CAMEL_POP3_STORE (service); -#ifdef HAVE_KRB4 - gboolean kpop = (service->url->authmech && - !strcmp (service->url->authmech, "+KPOP")); -#endif - - h = camel_service_gethost (service, ex); - if (!h) - return FALSE; - - if (!service->url->authmech && !service->url->passwd) { - char *prompt = g_strdup_printf ("Please enter the POP3 password for %s@%s", - service->url->user, h->h_name); - service->url->passwd = - camel_session_query_authenticator (camel_service_get_session (service), - prompt, TRUE, - service, "password", - ex); - g_free (prompt); - if (!service->url->passwd) - return FALSE; - } - - sin.sin_family = h->h_addrtype; - if (service->url->port) - sin.sin_port = service->url->port; -#ifdef HAVE_KRB4 - else if (kpop) - sin.sin_port = KPOP_PORT; -#endif - else - sin.sin_port = POP3_PORT; - sin.sin_port = htons (sin.sin_port); - memcpy (&sin.sin_addr, h->h_addr, sizeof (sin.sin_addr)); - - fd = socket (h->h_addrtype, SOCK_STREAM, 0); - if (fd == -1 || - connect (fd, (struct sockaddr *)&sin, sizeof(sin)) == -1) { - camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE, - "Could not connect to %s (port %s): %s", - service->url->host, service->url->port, - strerror(errno)); - if (fd > -1) - close (fd); - return FALSE; - } - -#ifdef HAVE_KRB4 - if (kpop) { - KTEXT_ST ticket_st; - MSG_DAT msg_data; - CREDENTIALS cred; - Key_schedule schedule; - char *hostname; - - /* Need to copy hostname, because krb_realmofhost will - * call gethostbyname as well, and gethostbyname uses - * static storage. - */ - hostname = g_strdup (h->h_name); - status = krb_sendauth (0, fd, &ticket_st, "pop", hostname, - krb_realmofhost (hostname), 0, - &msg_data, &cred, schedule, - NULL, NULL, "KPOPV0.1"); - g_free (hostname); - if (status != KSUCCESS) { - camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE, - "Could not authenticate to KPOP " - "server: %s", - krb_err_txt[status]); - close (fd); - return FALSE; - } - - if (!service->url->passwd) - service->url->passwd = g_strdup (service->url->user); - } -#endif /* HAVE_KRB4 */ - - store->ostream = camel_stream_fs_new_with_fd (fd); - store->istream = camel_stream_buffer_new (store->ostream, - CAMEL_STREAM_BUFFER_READ); - - /* Read the greeting, note APOP timestamp, if any. */ - buf = camel_stream_buffer_read_line (CAMEL_STREAM_BUFFER (store->istream)); - if (!buf) { - camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE, - "Could not read greeting from POP " - "server: %s", - camel_exception_get_description (ex)); - gtk_object_unref (GTK_OBJECT (store->ostream)); - gtk_object_unref (GTK_OBJECT (store->istream)); - return FALSE; - } - apoptime = strchr (buf, '<'); - apopend = apoptime ? strchr (apoptime, '>') : NULL; - if (apoptime && apopend) - apoptime = g_strndup (apoptime, apopend - apoptime + 1); - else - apoptime = NULL; - g_free (buf); - - /* Authenticate via APOP if we can, USER/PASS if we can't. */ - if (apoptime) { - char *secret, md5asc[32], *d; - unsigned char md5sum[16], *s; - - secret = g_strdup_printf ("%s%s", apoptime, - service->url->passwd); - md5_get_digest (secret, strlen (secret), md5sum); - g_free (apoptime); - g_free (secret); - - for (s = md5sum, d = md5asc; d < md5asc + 32; s++, d += 2) - sprintf (d, "%.2x", *s); - - status = camel_pop3_command (store, &msg, "APOP %s %s", - service->url->user, md5asc); - } else { - status = camel_pop3_command (store, &msg, "USER %s", - service->url->user); - if (status != CAMEL_POP3_OK) { - camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE, - "Unable to connect to POP " - "server. Error sending username:" - " %s", msg ? msg : "(Unknown)"); - g_free (msg); - gtk_object_unref (GTK_OBJECT (store->ostream)); - gtk_object_unref (GTK_OBJECT (store->istream)); - return FALSE; - } - - status = camel_pop3_command(store, &msg, "PASS %s", - service->url->passwd); - } - - if (status != CAMEL_POP3_OK) { - camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE, - "Unable to authenticate to POP " - "server. Error sending password:" - " %s", msg ? msg : "(Unknown)"); - g_free (msg); - gtk_object_unref (GTK_OBJECT (store->ostream)); - gtk_object_unref (GTK_OBJECT (store->istream)); - return FALSE; - } - - service_class->connect (service, ex); - return TRUE; -} - -static gboolean -pop3_disconnect (CamelService *service, CamelException *ex) -{ - CamelPop3Store *store = CAMEL_POP3_STORE (service); - - if (!service->connected) - return TRUE; - - if (!service_class->disconnect (service, ex)) - return FALSE; - - gtk_object_unref (GTK_OBJECT (store->ostream)); - gtk_object_unref (GTK_OBJECT (store->istream)); - store->ostream = NULL; - store->istream = NULL; - return TRUE; -} - -static CamelFolder * -get_folder (CamelStore *store, const char *folder_name, CamelException *ex) -{ - return camel_pop3_folder_new (store, ex); -} - -static char * -get_folder_name (CamelStore *store, const char *folder_name, - CamelException *ex) -{ - if (!g_strcasecmp (folder_name, "inbox")) - return g_strdup ("inbox"); - else { - camel_exception_setv (ex, CAMEL_EXCEPTION_FOLDER_INVALID, - "No such folder `%s'.", folder_name); - return NULL; - } -} - -static char * -get_root_folder_name (CamelStore *store, CamelException *ex) -{ - return g_strdup ("inbox"); -} - - -/** - * camel_pop3_command: Send a command to a POP3 server. - * @store: the POP3 store - * @ret: a pointer to return the full server response in - * @fmt: a printf-style format string, followed by arguments - * - * This command sends the command specified by @fmt and the following - * arguments to the connected POP3 store specified by @store. It then - * reads the server's response and parses out the status code. If - * the caller passed a non-NULL pointer for @ret, camel_pop3_command - * will set it to point to an buffer containing the rest of the - * response from the POP3 server. (If @ret was passed but there was - * no extended response, @ret will be set to NULL.) The caller must - * free this buffer when it is done with it. - * - * Return value: one of CAMEL_POP3_OK (command executed successfully), - * CAMEL_POP3_ERR (command encounted an error), or CAMEL_POP3_FAIL - * (a protocol-level error occurred, and Camel is uncertain of the - * result of the command.) - **/ -int -camel_pop3_command (CamelPop3Store *store, char **ret, char *fmt, ...) -{ - char *cmdbuf, *respbuf; - va_list ap; - int status; - - va_start (ap, fmt); - cmdbuf = g_strdup_vprintf (fmt, ap); - va_end (ap); - - /* Send the command */ - if (camel_stream_printf (store->ostream, "%s\r\n", cmdbuf) == -1) { - g_free (cmdbuf); - if (*ret) - *ret = g_strdup(strerror(errno)); - return CAMEL_POP3_FAIL; - } - g_free (cmdbuf); - - /* Read the response */ - respbuf = camel_stream_buffer_read_line (CAMEL_STREAM_BUFFER (store->istream)); - if (respbuf == NULL) { - if (*ret) - *ret = g_strdup(strerror(errno)); - return CAMEL_POP3_FAIL; - } - if (!strncmp (respbuf, "+OK", 3)) - status = CAMEL_POP3_OK; - else if (!strncmp (respbuf, "-ERR", 4)) - status = CAMEL_POP3_ERR; - else - status = CAMEL_POP3_FAIL; - - if (ret) { - if (status != CAMEL_POP3_FAIL) { - *ret = strchr (respbuf, ' '); - if (*ret) - *ret = g_strdup (*ret + 1); - } else - *ret = NULL; - } - g_free (respbuf); - - return status; -} - -/** - * camel_pop3_command_get_additional_data: get "additional data" from - * a POP3 command. - * @store: the POP3 store - * - * This command gets the additional data returned by "multi-line" POP - * commands, such as LIST, RETR, TOP, and UIDL. This command _must_ - * be called after a successful (CAMEL_POP3_OK) call to - * camel_pop3_command for a command that has a multi-line response. - * The returned data is un-byte-stuffed, and has lines termined by - * newlines rather than CR/LF pairs. - * - * Return value: the data, which the caller must free. - **/ -char * -camel_pop3_command_get_additional_data (CamelPop3Store *store, - CamelException *ex) -{ - CamelStreamBuffer *stream = CAMEL_STREAM_BUFFER (store->istream); - GPtrArray *data; - char *buf; - int i, status = CAMEL_POP3_OK; - - data = g_ptr_array_new (); - while (1) { - buf = camel_stream_buffer_read_line (stream); - if (!buf) { - status = CAMEL_POP3_FAIL; - break; - } - - if (!strcmp (buf, ".")) - break; - if (*buf == '.') - memmove (buf, buf + 1, strlen (buf)); - g_ptr_array_add (data, buf); - } - - if (status == CAMEL_POP3_OK) { - /* Append an empty string to the end of the array - * so when we g_strjoinv it, we get a "\n" after - * the last real line. - */ - g_ptr_array_add (data, ""); - g_ptr_array_add (data, NULL); - buf = g_strjoinv ("\n", (char **)data->pdata); - } else - buf = NULL; - - for (i = 0; i < data->len - 2; i++) - g_free (data->pdata[i]); - g_ptr_array_free (data, TRUE); - - return buf; -} diff --git a/camel/providers/pop3/camel-pop3-store.h b/camel/providers/pop3/camel-pop3-store.h deleted file mode 100644 index e68f0fd142..0000000000 --- a/camel/providers/pop3/camel-pop3-store.h +++ /dev/null @@ -1,81 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-pop3-store.h : class for an pop3 store */ - -/* - * Authors: - * Dan Winship - * - * Copyright (C) 2000 Helix Code, Inc. (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 CAMEL_POP3_STORE_H -#define CAMEL_POP3_STORE_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include -#include "camel-types.h" -#include "camel-store.h" - -#define CAMEL_POP3_STORE_TYPE (camel_pop3_store_get_type ()) -#define CAMEL_POP3_STORE(obj) (GTK_CHECK_CAST((obj), CAMEL_POP3_STORE_TYPE, CamelPop3Store)) -#define CAMEL_POP3_STORE_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_POP3_STORE_TYPE, CamelPop3StoreClass)) -#define IS_CAMEL_POP3_STORE(o) (GTK_CHECK_TYPE((o), CAMEL_POP3_STORE_TYPE)) - - -typedef struct { - CamelStore parent_object; - - CamelStream *istream, *ostream; - -} CamelPop3Store; - - - -typedef struct { - CamelStoreClass parent_class; - -} CamelPop3StoreClass; - - -/* public methods */ -void camel_pop3_store_open (CamelPop3Store *store, CamelException *ex); -void camel_pop3_store_close (CamelPop3Store *store, gboolean expunge, - CamelException *ex); - -/* support functions */ -enum { CAMEL_POP3_OK, CAMEL_POP3_ERR, CAMEL_POP3_FAIL }; -int camel_pop3_command (CamelPop3Store *store, char **ret, char *fmt, ...); -char *camel_pop3_command_get_additional_data (CamelPop3Store *store, - CamelException *ex); - -/* Standard Gtk function */ -GtkType camel_pop3_store_get_type (void); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* CAMEL_POP3_STORE_H */ - - diff --git a/camel/providers/pop3/libcamelpop3.urls b/camel/providers/pop3/libcamelpop3.urls deleted file mode 100644 index 7fffa4d861..0000000000 --- a/camel/providers/pop3/libcamelpop3.urls +++ /dev/null @@ -1 +0,0 @@ -pop diff --git a/camel/providers/sendmail/.cvsignore b/camel/providers/sendmail/.cvsignore deleted file mode 100644 index cacc3c5d5f..0000000000 --- a/camel/providers/sendmail/.cvsignore +++ /dev/null @@ -1,7 +0,0 @@ -Makefile -Makefile.in -.deps -.libs -*.lo -*.la -*.o diff --git a/camel/providers/sendmail/Makefile.am b/camel/providers/sendmail/Makefile.am deleted file mode 100644 index 511c860315..0000000000 --- a/camel/providers/sendmail/Makefile.am +++ /dev/null @@ -1,31 +0,0 @@ -## Process this file with automake to produce Makefile.in - -SUBDIRS = - -libcamelsendmailincludedir = $(includedir)/camel - - -providerdir = $(pkglibdir)/camel-providers/$(VERSION) - -provider_LTLIBRARIES = libcamelsendmail.la -provider_DATA = libcamelsendmail.urls - -INCLUDES = \ - -I.. \ - -I$(srcdir)/.. \ - -I$(srcdir)/../../.. \ - -I$(includedir) \ - -I$(top_srcdir)/intl \ - $(GTK_INCLUDEDIR) -I$(top_srcdir)/camel \ - -DG_LOG_DOMAIN=\"camel-sendmail-provider\" - -libcamelsendmail_la_SOURCES = \ - camel-sendmail-provider.c \ - camel-sendmail-transport.c - -libcamelsendmailinclude_HEADERS = \ - camel-sendmail-transport.h - -libcamelsendmail_la_LDFLAGS = -version-info 0:0:0 -rpath $(libdir) - -EXTRA_DIST = libcamelsendmail.urls diff --git a/camel/providers/sendmail/camel-sendmail-provider.c b/camel/providers/sendmail/camel-sendmail-provider.c deleted file mode 100644 index 16ebce8b12..0000000000 --- a/camel/providers/sendmail/camel-sendmail-provider.c +++ /dev/null @@ -1,53 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-sendmail-provider.c: sendmail provider registration code */ - -/* - * Authors : - * Dan Winship - * - * Copyright (C) 2000 Helix Code, Inc. (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-provider.h" -#include "camel-sendmail-transport.h" -#include "camel-session.h" - -static CamelProvider sendmail_provider = { - "sendmail", - "Sendmail", - - "For delivering mail by passing it to the \"sendmail\" program " - "on the local system.", - - 0, - - { 0, 0 } -}; - -void -camel_provider_module_init (CamelSession *session) -{ - sendmail_provider.object_types[CAMEL_PROVIDER_TRANSPORT] = - camel_sendmail_transport_get_type(); - - camel_session_register_provider (session, &sendmail_provider); -} - - - diff --git a/camel/providers/sendmail/camel-sendmail-transport.c b/camel/providers/sendmail/camel-sendmail-transport.c deleted file mode 100644 index 3b84d5cb90..0000000000 --- a/camel/providers/sendmail/camel-sendmail-transport.c +++ /dev/null @@ -1,212 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-sendmail-transport.c: Sendmail-based transport class. */ - -/* - * - * Author : - * Dan Winship - * - * Copyright 2000 Helix Code, Inc. (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 - */ - -#include - -#include -#include -#include -#include -#include -#include - -#include "camel-sendmail-transport.h" -#include "camel-mime-message.h" -#include "camel-data-wrapper.h" -#include "camel-stream-fs.h" -#include "camel-exception.h" - -static gboolean _can_send (CamelTransport *transport, CamelMedium *message); -static gboolean _send (CamelTransport *transport, CamelMedium *message, - CamelException *ex); -static gboolean _send_to (CamelTransport *transport, CamelMedium *message, - GList *recipients, CamelException *ex); - - -static void -camel_sendmail_transport_class_init (CamelSendmailTransportClass *camel_sendmail_transport_class) -{ - CamelTransportClass *camel_transport_class = - CAMEL_TRANSPORT_CLASS (camel_sendmail_transport_class); - - /* virtual method overload */ - camel_transport_class->can_send = _can_send; - camel_transport_class->send = _send; - camel_transport_class->send_to = _send_to; -} - -GtkType -camel_sendmail_transport_get_type (void) -{ - static GtkType camel_sendmail_transport_type = 0; - - if (!camel_sendmail_transport_type) { - GtkTypeInfo camel_sendmail_transport_info = - { - "CamelSendmailTransport", - sizeof (CamelSendmailTransport), - sizeof (CamelSendmailTransportClass), - (GtkClassInitFunc) camel_sendmail_transport_class_init, - (GtkObjectInitFunc) NULL, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_sendmail_transport_type = gtk_type_unique (CAMEL_TRANSPORT_TYPE, &camel_sendmail_transport_info); - } - - return camel_sendmail_transport_type; -} - - -static gboolean -_can_send (CamelTransport *transport, CamelMedium *message) -{ - return CAMEL_IS_MIME_MESSAGE (message); -} - - -static gboolean -_send_internal (CamelMedium *message, char **argv, CamelException *ex) -{ - int fd[2], nullfd, wstat; - sigset_t mask, omask; - CamelStream *out; - pid_t pid; - - g_assert (CAMEL_IS_MIME_MESSAGE (message)); - - if (pipe (fd) == -1) { - camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, - "Could not create pipe to sendmail: " - "%s: mail not sent", - g_strerror (errno)); - return FALSE; - } - - /* Block SIGCHLD so the calling application doesn't notice - * sendmail exiting before we do. - */ - sigemptyset (&mask); - sigaddset (&mask, SIGCHLD); - sigprocmask (SIG_BLOCK, &mask, &omask); - - pid = fork (); - switch (pid) { - case -1: - camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, - "Could not fork sendmail: " - "%s: mail not sent", g_strerror (errno)); - sigprocmask (SIG_SETMASK, &omask, NULL); - return FALSE; - - case 0: - /* Child process */ - nullfd = open ("/dev/null", O_RDWR); - dup2 (fd[0], STDIN_FILENO); - dup2 (nullfd, STDOUT_FILENO); - dup2 (nullfd, STDERR_FILENO); - close (nullfd); - close (fd[1]); - - execv (SENDMAIL_PATH, argv); - _exit (255); - } - - /* Parent process. Write the message out. */ - close (fd[0]); - out = camel_stream_fs_new_with_fd (fd[1]); - if (camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (message), out) == -1 - || camel_stream_close(out) == -1) { - gtk_object_unref (GTK_OBJECT (out)); - camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, - "Could not send message: %s", - strerror(errno)); - return FALSE; - } - gtk_object_unref (GTK_OBJECT (out)); - - /* Wait for sendmail to exit. */ - while (waitpid (pid, &wstat, 0) == -1 && errno == EINTR) - ; - sigprocmask (SIG_SETMASK, &omask, NULL); - - if (!WIFEXITED (wstat)) { - camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, - "sendmail exited with signal %s: " - "mail not sent.", - g_strsignal (WTERMSIG (wstat))); - return FALSE; - } else if (WEXITSTATUS (wstat) != 0) { - if (WEXITSTATUS (wstat) == 255) { - camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, - "Could not execute " - SENDMAIL_PATH ": mail not sent."); - } else { - camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, - "sendmail exited with status " - "%d: mail not sent.", - WEXITSTATUS (wstat)); - } - return FALSE; - } - - return TRUE; -} - -static gboolean -_send_to (CamelTransport *transport, CamelMedium *message, - GList *recipients, CamelException *ex) -{ - GList *r; - char **argv; - int i, len; - gboolean status; - - len = g_list_length (recipients); - argv = g_malloc ((len + 4) * sizeof (char *)); - argv[0] = "sendmail"; - argv[1] = "-i"; - argv[2] = "--"; - - for (i = 1, r = recipients; i <= len; i++, r = r->next) - argv[i + 2] = r->data; - argv[i + 2] = NULL; - - status = _send_internal (message, argv, ex); - g_free (argv); - return status; -} - -static gboolean -_send (CamelTransport *transport, CamelMedium *message, - CamelException *ex) -{ - char *argv[4] = { "sendmail", "-t", "-i", NULL }; - - return _send_internal (message, argv, ex); -} diff --git a/camel/providers/sendmail/camel-sendmail-transport.h b/camel/providers/sendmail/camel-sendmail-transport.h deleted file mode 100644 index 3f3714584a..0000000000 --- a/camel/providers/sendmail/camel-sendmail-transport.h +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-sendmail-transport.h: Sendmail-based transport class */ - -/* - * - * Author : - * Dan Winship - * - * Copyright 2000 Helix Code, Inc. (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 CAMEL_SENDMAIL_TRANSPORT_H -#define CAMEL_SENDMAIL_TRANSPORT_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include "camel-transport.h" - -#define CAMEL_SENDMAIL_TRANSPORT_TYPE (camel_sendmail_transport_get_type ()) -#define CAMEL_SENDMAIL_TRANSPORT(obj) (GTK_CHECK_CAST((obj), CAMEL_SENDMAIL_TRANSPORT_TYPE, CamelSendmailTransport)) -#define CAMEL_SENDMAIL_TRANSPORT_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_SENDMAIL_TRANSPORT_TYPE, CamelSendmailTransportClass)) -#define CAMEL_IS_SENDMAIL_TRANSPORT(o) (GTK_CHECK_TYPE((o), CAMEL_SENDMAIL_TRANSPORT_TYPE)) - - -typedef struct { - CamelTransport parent_object; - -} CamelSendmailTransport; - - -typedef struct { - CamelTransportClass parent_class; - -} CamelSendmailTransportClass; - - -/* Standard Gtk function */ -GtkType camel_sendmail_transport_get_type (void); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* CAMEL_SENDMAIL_TRANSPORT_H */ diff --git a/camel/providers/sendmail/libcamelsendmail.urls b/camel/providers/sendmail/libcamelsendmail.urls deleted file mode 100644 index ccad52828e..0000000000 --- a/camel/providers/sendmail/libcamelsendmail.urls +++ /dev/null @@ -1 +0,0 @@ -sendmail diff --git a/camel/providers/smtp/.cvsignore b/camel/providers/smtp/.cvsignore deleted file mode 100644 index 09980ae6ba..0000000000 --- a/camel/providers/smtp/.cvsignore +++ /dev/null @@ -1,6 +0,0 @@ -.deps -.libs -Makefile -Makefile.in -*.lo -*.la diff --git a/camel/providers/smtp/Makefile.am b/camel/providers/smtp/Makefile.am deleted file mode 100644 index b14375bfc0..0000000000 --- a/camel/providers/smtp/Makefile.am +++ /dev/null @@ -1,32 +0,0 @@ -## Process this file with automake to produce Makefile.in - -SUBDIRS = - -libcamelsmtpincludedir = $(includedir)/camel - -providerdir = $(pkglibdir)/camel-providers/$(VERSION) - -provider_LTLIBRARIES = libcamelsmtp.la -provider_DATA = libcamelsmtp.urls - -INCLUDES = \ - -I.. \ - -I$(srcdir)/.. \ - -I$(srcdir)/../../.. \ - -I$(includedir) \ - -I$(top_srcdir)/intl \ - $(GTK_INCLUDEDIR) \ - -I$(top_srcdir)/camel \ - -DG_LOG_DOMAIN=\"camel-smtp-provider\" - -libcamelsmtp_la_SOURCES = \ - camel-smtp-provider.c \ - camel-smtp-transport.c - -libcamelsmtpinclude_HEADERS = \ - camel-smtp-transport.h - - -libcamelsmtp_la_LDFLAGS = -version-info 0:0:0 -rpath $(libdir) - -EXTRA_DIST = libcamelsmtp.urls diff --git a/camel/providers/smtp/camel-smtp-provider.c b/camel/providers/smtp/camel-smtp-provider.c deleted file mode 100644 index c82755d481..0000000000 --- a/camel/providers/smtp/camel-smtp-provider.c +++ /dev/null @@ -1,53 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-smtp-provider.c: smtp provider registration code */ - -/* - * Authors : - * Jeffrey Stedfast - * - * Copyright (C) 2000 Helix Code, Inc. (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-smtp-transport.h" -#include "camel-provider.h" -#include "camel-session.h" - -static CamelProvider smtp_provider = { - "smtp", - "SMTP", - - "For delivering mail by connecting to a remote mailhub using SMTP." - "(NOT YET TESTED!)", - - 0, - - { 0, 0 } -}; - -void -camel_provider_module_init (CamelSession *session) -{ - smtp_provider.object_types[CAMEL_PROVIDER_TRANSPORT] = - camel_smtp_transport_get_type(); - - camel_session_register_provider (session, &smtp_provider); -} - - - diff --git a/camel/providers/smtp/camel-smtp-transport.c b/camel/providers/smtp/camel-smtp-transport.c deleted file mode 100644 index b7af97674e..0000000000 --- a/camel/providers/smtp/camel-smtp-transport.c +++ /dev/null @@ -1,735 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-smtp-transport.c : class for a smtp transport */ - -/* - * Authors: - * Jeffrey Stedfast - * - * Copyright (C) 2000 Helix Code, Inc. (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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#undef MIN -#undef MAX -#include "camel-smtp-transport.h" -#include "camel-mime-message.h" -#include "camel-stream-buffer.h" -#include "camel-stream-fs.h" -#include "camel-session.h" -#include "camel-exception.h" -#include "md5-utils.h" - -/* Specified in RFC 821 */ -#define SMTP_PORT 25 - -/* camel smtp transport class prototypes */ -static gboolean _can_send (CamelTransport *transport, CamelMedium *message); -static gboolean _send (CamelTransport *transport, CamelMedium *message, CamelException *ex); -static gboolean _send_to (CamelTransport *transport, CamelMedium *message, GList *recipients, CamelException *ex); - -/* support prototypes */ -static gboolean smtp_connect (CamelService *service, CamelException *ex); -static gboolean smtp_disconnect (CamelService *service, CamelException *ex); -static GList *esmtp_get_authtypes(gchar *buffer); -static GList *query_auth_types (CamelService *service, CamelException *ex); -static void free_auth_types (CamelService *service, GList *authtypes); -static gchar *smtp_get_email_addr_from_text (gchar *text); -static gboolean smtp_helo (CamelSmtpTransport *transport, CamelException *ex); -static gboolean smtp_mail (CamelSmtpTransport *transport, gchar *sender, CamelException *ex); -static gboolean smtp_rcpt (CamelSmtpTransport *transport, gchar *recipient, CamelException *ex); -static gboolean smtp_data (CamelSmtpTransport *transport, CamelMedium *message, CamelException *ex); -static gboolean smtp_rset (CamelSmtpTransport *transport, CamelException *ex); -static gboolean smtp_quit (CamelSmtpTransport *transport, CamelException *ex); - -/* private data members */ -static CamelServiceClass *service_class = NULL; -static gboolean smtp_is_esmtp = FALSE; -static struct sockaddr_in localaddr; -static GList *esmtp_supported_authtypes = NULL; - -static void -camel_smtp_transport_class_init (CamelSmtpTransportClass *camel_smtp_transport_class) -{ - CamelTransportClass *camel_transport_class = - CAMEL_TRANSPORT_CLASS (camel_smtp_transport_class); - CamelServiceClass *camel_service_class = - CAMEL_SERVICE_CLASS (camel_smtp_transport_class); - - service_class = gtk_type_class (camel_service_get_type ()); - - /* virtual method overload */ - camel_service_class->connect = smtp_connect; - camel_service_class->disconnect = smtp_disconnect; - camel_service_class->query_auth_types = query_auth_types; - camel_service_class->free_auth_types = free_auth_types; - - camel_transport_class->can_send = _can_send; - camel_transport_class->send = _send; - camel_transport_class->send_to = _send_to; -} - -static void -camel_smtp_transport_init (gpointer object, gpointer klass) -{ - CamelService *service = CAMEL_SERVICE (object); - - service->url_flags = CAMEL_SERVICE_URL_NEED_HOST; -} - -GtkType -camel_smtp_transport_get_type (void) -{ - static GtkType camel_smtp_transport_type = 0; - - if (!camel_smtp_transport_type) { - GtkTypeInfo camel_smtp_transport_info = - { - "CamelSmtpTransport", - sizeof (CamelSmtpTransport), - sizeof (CamelSmtpTransportClass), - (GtkClassInitFunc) camel_smtp_transport_class_init, - (GtkObjectInitFunc) camel_smtp_transport_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_smtp_transport_type = gtk_type_unique (CAMEL_TRANSPORT_TYPE, &camel_smtp_transport_info); - } - - return camel_smtp_transport_type; -} - -static gboolean -smtp_connect (CamelService *service, CamelException *ex) -{ - struct hostent *h; - struct sockaddr_in sin; - gint fd, num, i; - guint32 addrlen; - gchar *pass = NULL, *respbuf = NULL; - CamelSmtpTransport *transport = CAMEL_SMTP_TRANSPORT (service); - - if (!service_class->connect (service, ex)) - return FALSE; - - h = camel_service_gethost (service, ex); - if (!h) - return FALSE; - - sin.sin_family = h->h_addrtype; - sin.sin_port = htons (service->url->port ? service->url->port : SMTP_PORT); - memcpy (&sin.sin_addr, h->h_addr, sizeof (sin.sin_addr)); - - fd = socket (h->h_addrtype, SOCK_STREAM, 0); - if (fd == -1 || connect (fd, (struct sockaddr *)&sin, sizeof(sin)) == -1) { - camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE, - "Could not connect to %s (port %s): %s", - service->url->host, service->url->port, - strerror(errno)); - if (fd > -1) - close (fd); - g_free (pass); - return FALSE; - } - - /* get the localaddr - needed later by smtp_helo */ - addrlen = sizeof(localaddr); - getsockname(fd, (struct sockaddr*)&localaddr, &addrlen); - - transport->ostream = camel_stream_fs_new_with_fd (fd); - transport->istream = camel_stream_buffer_new (transport->ostream, - CAMEL_STREAM_BUFFER_READ); - - /* Read the greeting, note whether the server is ESMTP and if it requests AUTH. */ - do { - /* Check for "220" */ - g_free(respbuf); - respbuf = camel_stream_buffer_read_line (CAMEL_STREAM_BUFFER (transport->istream), ex); - if ( !respbuf || strncmp(respbuf, "220", 3) ) { - camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, - "Welcome response error: " - "%s: possibly non-fatal", - g_strerror (errno)); - return FALSE; - } - if (strstr(respbuf, "ESMTP")) - smtp_is_esmtp = TRUE; - } while ( *(respbuf+3) == '-' ); /* if we got "220-" then loop again */ - g_free(respbuf); - - /* send HELO (or EHLO, depending on the service type) */ - smtp_helo(transport, ex); - - /* check to see if AUTH is required, if so...then AUTH ourselves */ - if (smtp_is_esmtp && esmtp_supported_authtypes) { - /* not really supported yet, but we can at least show what auth types are supported */ - fprintf(stderr, "camel-smtp-transport: %s requires AUTH\n", service->url->host); - num = g_list_length(esmtp_supported_authtypes); - for (i = 0; i < num; i++) - fprintf(stderr, "Supported AUTH: %s\n", (gchar *) g_list_nth_data(esmtp_supported_authtypes, i)); - g_list_free(esmtp_supported_authtypes); - esmtp_supported_authtypes = NULL; - } - - return TRUE; -} - -static gboolean -smtp_disconnect (CamelService *service, CamelException *ex) -{ - CamelSmtpTransport *transport = CAMEL_SMTP_TRANSPORT (service); - - if (!service->connected) - return TRUE; - - /* send the QUIT command to the SMTP server */ - smtp_quit(transport, ex); - - if (!service_class->disconnect (service, ex)) - return FALSE; - - gtk_object_unref (GTK_OBJECT (transport->ostream)); - gtk_object_unref (GTK_OBJECT (transport->istream)); - transport->ostream = NULL; - transport->istream = NULL; - - return TRUE; -} - -static GList -*esmtp_get_authtypes(gchar *buffer) -{ - GList *ret = NULL; - gchar *start, *end; - - if (!(start = strstr(buffer, " AUTH "))) - return NULL; - - /* advance to the first token */ - for (start += 6; *start && *start != ' '; start++); - - for ( ; *start; ) { - /* advance to the end of the token */ - for (end = start; *end && *end != ' '; end++); - - ret = g_list_append(ret, g_strndup(start, end - start)); - - /* advance to the next token */ - for (start = end; *start && *start != ' '; start++); - } - - return ret; -} - -static CamelServiceAuthType no_authtype = { - "No authentication required", - - "This option will connect to the SMTP server without using any " - "kind of authentication. This should be fine for connecting to " - "most SMTP servers." - - "", - FALSE -}; - -static CamelServiceAuthType cram_md5_authtype = { - "CRAM-MD5", - - "This option will connect to the SMTP server using CRAM-MD5 " - "authentication.", - - "CRAM-MD5", - TRUE -}; - -static GList -*query_auth_types (CamelService *service, CamelException *ex) -{ - /* FIXME: Re-enable this when auth types are actually - * implemented. - */ - - return NULL; -} - -static void -free_auth_types (CamelService *service, GList *authtypes) -{ - g_list_free (authtypes); -} - -static gboolean -_can_send (CamelTransport *transport, CamelMedium *message) -{ - return CAMEL_IS_MIME_MESSAGE (message); -} - -static gboolean -_send_to (CamelTransport *transport, CamelMedium *message, - GList *recipients, CamelException *ex) -{ - GList *r; - gchar *recipient, *s, *sender; - guint i, len; - CamelService *service = CAMEL_SERVICE (transport); - CamelSmtpTransport *smtp_transport = CAMEL_SMTP_TRANSPORT(transport); - - if (!camel_service_is_connected (service)) - smtp_connect (service, ex); - - s = g_strdup(camel_mime_message_get_from (CAMEL_MIME_MESSAGE(message))); - if (!s) { - camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, - "Cannot send message: " - "sender address not defined."); - return FALSE; - } - - sender = smtp_get_email_addr_from_text(s); - smtp_mail(smtp_transport, sender, ex); - g_free(sender); - g_free(s); - - if (!(len = g_list_length(recipients))) { - camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, - "Cannot send message: " - "no recipients defined."); - return FALSE; - } - for (i = 0, r = recipients; i < len; i++, r = r->next) { - recipient = smtp_get_email_addr_from_text(r->data); - if (!smtp_rcpt(smtp_transport, recipient, ex)) { - g_free(recipient); - return FALSE; - } - g_free(recipient); - } - - if (!smtp_data(smtp_transport, message, ex)) - return FALSE; - - /* reset the service for our next transfer session */ - smtp_rset(smtp_transport, ex); - - return TRUE; -} - -static gboolean -_send (CamelTransport *transport, CamelMedium *message, - CamelException *ex) -{ - const CamelInternetAddress *to, *cc, *bcc; - GList *recipients = NULL; - guint index, len; - - to = camel_mime_message_get_recipients ((CamelMimeMessage *) message, CAMEL_RECIPIENT_TYPE_TO); - cc = camel_mime_message_get_recipients ((CamelMimeMessage *) message, CAMEL_RECIPIENT_TYPE_CC); - bcc = camel_mime_message_get_recipients ((CamelMimeMessage *) message, CAMEL_RECIPIENT_TYPE_BCC); - - /* get all of the To addresses into our recipient list */ - len = ((CamelAddress *)to)->addresses->len; - for (index = 0; index < len; index++) { - const char *addr; - - if (camel_internet_address_get(to, index, NULL, &addr)) - recipients = g_list_append(recipients, g_strdup(addr)); - } - - /* get all of the Cc addresses into our recipient list */ - len = ((CamelAddress *)cc)->addresses->len; - for (index = 0; index < len; index++) { - const char *addr; - - if (camel_internet_address_get(cc, index, NULL, &addr)) - recipients = g_list_append(recipients, g_strdup(addr)); - } - - /* get all of the Bcc addresses into our recipient list */ - len = ((CamelAddress *)bcc)->addresses->len; - for (index = 0; index < len; index++) { - const char *addr; - - if (camel_internet_address_get(bcc, index, NULL, &addr)) - recipients = g_list_append(recipients, g_strdup(addr)); - } - - return _send_to (transport, message, recipients, ex); -} - -static gchar -*smtp_get_email_addr_from_text (gchar *text) -{ - /* get the actual email address from the string passed and place it in addr - * we can assume the address will be in one of the following forms: - * 1) The Name - * 2) - * 3) person@host.com - * 4) person@host.com (The Name) - */ - - gchar *tmp, *addr = NULL; - gchar *addr_strt; /* points to start of addr */ - gchar *addr_end; /* points to end of addr */ - gchar *ptr1; - - - /* check the incoming args */ - if (!text || !*text) - return NULL; - - /* scan the string for an open brace */ - for (addr_strt = text; *addr_strt; addr_strt++) - if (*addr_strt == '<') - break; - - if (*addr_strt) { - /* we found an open brace, let's look for it's counterpart */ - for (addr_end = addr_strt; *addr_end; addr_end++) - if (*addr_end == '>') - break; - - /* if we didn't find it, or braces are empty... */ - if (!(*addr_end) || (addr_strt == addr_end - 1)) - return NULL; - - /* addr_strt points to '<' and addr_end points to '>'. - * Now let's adjust 'em slightly to point to the beginning - * and ending of the email addy - */ - addr_strt++; - addr_end--; - } else { - /* no open brace...assume type 3 or 4? */ - addr_strt = text; - - /* find the end of the email addr/string */ - for (addr_end = addr_strt; *addr_end || *addr_end == ' '; addr_end++); - - addr_end--; /* points to NULL, move it back one char */ - } - - /* now addr_strt & addr_end point to the beginning & ending of the email addy */ - - /* copy the string into addr */ - addr = g_strndup(addr_strt, (gint)(addr_end - addr_strt + 1)); - - for (ptr1 = addr_strt; ptr1 <= addr_end; ptr1++) /* look for an '@' sign */ - if (*ptr1 == '@') - break; - - if (*ptr1 != '@') { - /* here we found out the name doesn't have an '@' part - * let's figure out what machine we're on & stick it on the end - */ - gchar hostname[MAXHOSTNAMELEN]; - - if (gethostname(hostname, MAXHOSTNAMELEN)) { - g_free(addr); - return NULL; - } - tmp = addr; - addr = g_strconcat(tmp, "@", hostname, NULL); - g_free(tmp); - } - - return addr; -} - -static gboolean -smtp_helo (CamelSmtpTransport *transport, CamelException *ex) -{ - /* say hello to the server */ - gchar *cmdbuf, *respbuf = NULL; - struct hostent *host; - - /* get the local host name */ - host = gethostbyaddr((gchar *)&localaddr.sin_addr, sizeof(localaddr.sin_addr), AF_INET); - - /* hiya server! how are you today? */ - if (smtp_is_esmtp) - cmdbuf = g_strdup_printf ("EHLO %s\r\n", host && host->h_name ? host->h_name : inet_ntoa(localaddr.sin_addr)); - else - cmdbuf = g_strdup_printf ("HELO %s\r\n", host && host->h_name ? host->h_name : inet_ntoa(localaddr.sin_addr)); - if ( camel_stream_write (transport->ostream, cmdbuf, strlen(cmdbuf), ex) == -1) { - g_free(cmdbuf); - camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, - "HELO request timed out: " - "%s: non-fatal", - g_strerror (errno)); - return FALSE; - } - g_free(cmdbuf); - - do { - /* Check for "250" */ - g_free(respbuf); - respbuf = camel_stream_buffer_read_line (CAMEL_STREAM_BUFFER (transport->istream), ex); - if ( !respbuf || strncmp(respbuf, "250", 3) ) { - camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, - "HELO response error: " - "%s: non-fatal", - g_strerror (errno)); - return FALSE; - } - - if (smtp_is_esmtp && strstr(respbuf, "AUTH")) { - /* parse for supported AUTH types */ - g_strchomp(respbuf); - esmtp_supported_authtypes = esmtp_get_authtypes(respbuf); - } - } while ( *(respbuf+3) == '-' ); /* if we got "250-" then loop again */ - g_free(respbuf); - - return TRUE; -} - -static gboolean -smtp_mail (CamelSmtpTransport *transport, gchar *sender, CamelException *ex) -{ - /* we gotta tell the smtp server who we are. (our email addy) */ - gchar *cmdbuf, *respbuf = NULL; - - /* enclose address in <>'s since some SMTP daemons *require* that */ - cmdbuf = g_strdup_printf("MAIL FROM: <%s>\r\n", sender); - if ( camel_stream_write (transport->ostream, cmdbuf, strlen(cmdbuf), ex) == -1) { - g_free(cmdbuf); - camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, - "MAIL FROM request timed out: " - "%s: mail not sent", - g_strerror (errno)); - return FALSE; - } - g_free(cmdbuf); - - do { - /* Check for "250 Sender OK..." */ - g_free(respbuf); - respbuf = camel_stream_buffer_read_line (CAMEL_STREAM_BUFFER (transport->istream), ex); - if ( !respbuf || strncmp(respbuf, "250", 3) ) { - camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, - "MAIL FROM response error: " - "%s: mail not sent", - g_strerror (errno)); - return FALSE; - } - } while ( *(respbuf+3) == '-' ); /* if we got "250-" then loop again */ - g_free(respbuf); - - return TRUE; -} - -static gboolean -smtp_rcpt (CamelSmtpTransport *transport, gchar *recipient, CamelException *ex) -{ - /* we gotta tell the smtp server who we are going to be sending - * our email to */ - gchar *cmdbuf, *respbuf = NULL; - - /* enclose address in <>'s since some SMTP daemons *require* that */ - cmdbuf = g_strdup_printf("RCPT TO: <%s>\r\n", recipient); - if ( camel_stream_write (transport->ostream, cmdbuf, strlen(cmdbuf), ex) == -1) { - g_free(cmdbuf); - camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, - "RCPT TO request timed out: " - "%s: mail not sent", - g_strerror (errno)); - return FALSE; - } - g_free(cmdbuf); - - do { - /* Check for "250 Sender OK..." */ - g_free(respbuf); - respbuf = camel_stream_buffer_read_line (CAMEL_STREAM_BUFFER (transport->istream), ex); - if ( !respbuf || strncmp(respbuf, "250", 3) ) { - camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, - "RCPT TO response error: " - "%s: mail not sent", - g_strerror (errno)); - return FALSE; - } - } while ( *(respbuf+3) == '-' ); /* if we got "250-" then loop again */ - g_free(respbuf); - - return TRUE; -} - -static gboolean -smtp_data (CamelSmtpTransport *transport, CamelMedium *message, CamelException *ex) -{ - /* now we can actually send what's important :p */ - gchar *cmdbuf, *respbuf = NULL; - gchar *buf, *chunk; - CamelStream *message_stream; - - /* enclose address in <>'s since some SMTP daemons *require* that */ - cmdbuf = g_strdup("DATA\r\n"); - if ( camel_stream_write (transport->ostream, cmdbuf, strlen(cmdbuf), ex) == -1) { - g_free(cmdbuf); - camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, - "DATA request timed out: " - "%s: mail not sent", - g_strerror (errno)); - return FALSE; - } - g_free(cmdbuf); - - respbuf = camel_stream_buffer_read_line (CAMEL_STREAM_BUFFER (transport->istream), ex); - if ( !respbuf || strncmp(respbuf, "354", 3) ) { - /* we should have gotten instructions on how to use the DATA command: - * 354 Enter mail, end with "." on a line by itself - */ - g_free(respbuf); - camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, - "DATA response error: " - "%s: mail not sent", - g_strerror (errno)); - return FALSE; - } - - /* now to send the actual data */ - message_stream = camel_stream_buffer_new(camel_data_wrapper_get_output_stream (CAMEL_DATA_WRAPPER (message)), CAMEL_STREAM_BUFFER_READ); - while (1) { - /* send 1 line at a time */ - buf = camel_stream_buffer_read_line (CAMEL_STREAM_BUFFER(message_stream), ex); - if (!buf) - break; - - /* check for a lone '.' */ - if (!strcmp(buf, ".")) - chunk = g_strconcat(buf, ".\r\n", NULL); - else - chunk = g_strconcat(buf, "\r\n", NULL); - - /* write the line */ - if ( camel_stream_write (transport->ostream, chunk, strlen(chunk), ex) == -1) { - g_free(chunk); - camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, - "DATA send timed out: message body: " - "%s: mail not sent", - g_strerror (errno)); - return FALSE; - } - g_free(chunk); - } - - /* terminate the message body */ - if ( camel_stream_write (transport->ostream, "\r\n.\r\n", 5, ex) == -1) { - camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, - "DATA send timed out: message termination: " - "%s: mail not sent", - g_strerror (errno)); - return FALSE; - } - - do { - /* Check for "250 Sender OK..." */ - g_free(respbuf); - respbuf = camel_stream_buffer_read_line (CAMEL_STREAM_BUFFER (transport->istream), ex); - if ( !respbuf || strncmp(respbuf, "250", 3) ) { - camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, - "DATA response error: message termination: " - "%s: mail not sent", - g_strerror (errno)); - return FALSE; - } - } while ( *(respbuf+3) == '-' ); /* if we got "250-" then loop again */ - g_free(respbuf); - - return TRUE; -} - -static gboolean -smtp_rset (CamelSmtpTransport *transport, CamelException *ex) -{ - /* we are going to reset the smtp server (just to be nice) */ - gchar *cmdbuf, *respbuf = NULL; - - cmdbuf = g_strdup ("RSET\r\n"); - if ( camel_stream_write (transport->ostream, cmdbuf, strlen(cmdbuf), ex) == -1) { - g_free(cmdbuf); - camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, - "RSET request timed out: " - "%s", - g_strerror (errno)); - return FALSE; - } - g_free(cmdbuf); - - do { - /* Check for "250" */ - g_free(respbuf); - respbuf = camel_stream_buffer_read_line (CAMEL_STREAM_BUFFER (transport->istream), ex); - if ( !respbuf || strncmp(respbuf, "250", 3) ) { - camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, - "RSET response error: " - "%s", - g_strerror (errno)); - return FALSE; - } - } while ( *(respbuf+3) == '-' ); /* if we got "250-" then loop again */ - g_free(respbuf); - - return TRUE; -} - -static gboolean -smtp_quit (CamelSmtpTransport *transport, CamelException *ex) -{ - /* we are going to reset the smtp server (just to be nice) */ - gchar *cmdbuf, *respbuf = NULL; - - cmdbuf = g_strdup ("QUIT\r\n"); - if ( camel_stream_write (transport->ostream, cmdbuf, strlen(cmdbuf), ex) == -1) { - g_free(cmdbuf); - camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, - "QUIT request timed out: " - "%s: non-fatal", - g_strerror (errno)); - return FALSE; - } - g_free(cmdbuf); - - do { - /* Check for "221" */ - g_free(respbuf); - respbuf = camel_stream_buffer_read_line (CAMEL_STREAM_BUFFER (transport->istream), ex); - if ( !respbuf || strncmp(respbuf, "221", 3) ) { - camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, - "QUIT response error: " - "%s: non-fatal", - g_strerror (errno)); - return FALSE; - } - } while ( *(respbuf+3) == '-' ); /* if we got "221-" then loop again */ - g_free(respbuf); - - return TRUE; -} diff --git a/camel/providers/smtp/camel-smtp-transport.h b/camel/providers/smtp/camel-smtp-transport.h deleted file mode 100644 index 54343e59d8..0000000000 --- a/camel/providers/smtp/camel-smtp-transport.h +++ /dev/null @@ -1,68 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-smtp-transport.h : class for an smtp transfer */ - -/* - * Authors: - * Jeffrey Stedfast - * - * Copyright (C) 2000 Helix Code, Inc. (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 CAMEL_SMTP_TRANSPORT_H -#define CAMEL_SMTP_TRANSPORT_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include "camel-transport.h" - -#define CAMEL_SMTP_TRANSPORT_TYPE (camel_smtp_transport_get_type ()) -#define CAMEL_SMTP_TRANSPORT(obj) (GTK_CHECK_CAST((obj), CAMEL_SMTP_TRANSPORT_TYPE, CamelSmtpTransport)) -#define CAMEL_SMTP_TRANSPORT_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_SMTP_TRANSPORT_TYPE, CamelSmtpTransportClass)) -#define IS_CAMEL_SMTP_TRANSPORT(o) (GTK_CHECK_TYPE((o), CAMEL_SMTP_TRANSPORT_TYPE)) - - -typedef struct { - CamelTransport parent_object; - - CamelStream *istream, *ostream; - -} CamelSmtpTransport; - - - -typedef struct { - CamelTransportClass parent_class; - -} CamelSmtpTransportClass; - - -/* Standard Gtk function */ -GtkType camel_smtp_transport_get_type (void); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* CAMEL_SMTP_TRANSPORT_H */ - - diff --git a/camel/providers/smtp/libcamelsmtp.urls b/camel/providers/smtp/libcamelsmtp.urls deleted file mode 100644 index ec2fc0fc16..0000000000 --- a/camel/providers/smtp/libcamelsmtp.urls +++ /dev/null @@ -1 +0,0 @@ -smtp diff --git a/camel/providers/vee/Makefile.am b/camel/providers/vee/Makefile.am deleted file mode 100644 index 601defcb80..0000000000 --- a/camel/providers/vee/Makefile.am +++ /dev/null @@ -1,39 +0,0 @@ -## Process this file with automake to produce Makefile.in - -SUBDIRS = - -libcamelveeincludedir = $(includedir)/camel - - -providerdir = $(pkglibdir)/camel-providers/$(VERSION) - -provider_LTLIBRARIES = libcamelvee.la -provider_DATA = libcamelvee.urls - -INCLUDES = -I.. \ - -I$(srcdir)/.. \ - -I$(top_srcdir)/camel \ - -I$(top_srcdir)/intl \ - -I$(top_srcdir)/libibex \ - -I$(top_srcdir)/e-util \ - -I$(top_srcdir) \ - -I$(includedir) \ - $(GTK_INCLUDEDIR) \ - -DG_LOG_DOMAIN=\"camel-vee-provider\" - -libcamelvee_la_SOURCES = \ - camel-vee-folder.c \ - camel-vee-provider.c \ - camel-vee-store.c - -libcamelveeinclude_HEADERS = \ - camel-vee-folder.h \ - camel-vee-store.h - -libcamelvee_la_LDFLAGS = -version-info 0:0:0 -rpath $(libdir) - -libcamelvee_la_LIBADD = $(top_builddir)/e-util/libeutil.la $(top_builddir)/libibex/libibex.la $(UNICODE_LIBS) -#libcamelvee_la_LIBADD = $(top_builddir)/libibex/libibex.la $(UNICODE_LIBS) - -EXTRA_DIST = libcamelvee.urls - diff --git a/camel/providers/vee/camel-vee-folder.c b/camel/providers/vee/camel-vee-folder.c deleted file mode 100644 index 3d4050cf19..0000000000 --- a/camel/providers/vee/camel-vee-folder.c +++ /dev/null @@ -1,423 +0,0 @@ -/* - * Copyright (C) 2000 Helix Code Inc. - * - * Authors: Michael Zucchi - * - * 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-exception.h" -#include "camel-vee-folder.h" -#include "camel-folder-summary.h" -#include "camel-mime-message.h" - -#include - -/* our message info includes the parent folder */ -typedef struct _CamelVeeMessageInfo { - CamelMessageInfo info; - CamelFolder *folder; -} CamelVeeMessageInfo; - -struct _CamelVeeFolderPrivate { - GList *folders; -}; - -#define _PRIVATE(o) (((CamelVeeFolder *)(o))->priv) - -static void vee_init (CamelFolder *folder, CamelStore *parent_store, - CamelFolder *parent_folder, const gchar *name, - gchar separator, CamelException *ex); - -static void vee_open (CamelFolder *folder, CamelFolderOpenMode mode, CamelException *ex); -static void vee_close (CamelFolder *folder, gboolean expunge, CamelException *ex); -static gboolean vee_exists (CamelFolder *folder, CamelException *ex); - -static GPtrArray *vee_get_uids (CamelFolder *folder, CamelException *ex); -GPtrArray *vee_get_summary (CamelFolder *folder, CamelException *ex); -void vee_free_summary (CamelFolder *folder, GPtrArray *array); - -static gint vee_get_message_count (CamelFolder *folder, CamelException *ex); -static CamelMimeMessage *vee_get_message_by_uid (CamelFolder *folder, const gchar *uid, CamelException *ex); - -static void vee_append_message (CamelFolder *folder, CamelMimeMessage *message, CamelException *ex); - -static const CamelMessageInfo *vee_summary_get_by_uid(CamelFolder *f, const char *uid); -static GList *vee_search_by_expression(CamelFolder *folder, const char *expression, CamelException *ex); - - -static void camel_vee_folder_class_init (CamelVeeFolderClass *klass); -static void camel_vee_folder_init (CamelVeeFolder *obj); -static void camel_vee_folder_finalise (GtkObject *obj); - -static void vee_folder_build(CamelVeeFolder *vf, CamelException *ex); - -static CamelFolderClass *camel_vee_folder_parent; - -enum SIGNALS { - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -guint -camel_vee_folder_get_type (void) -{ - static guint type = 0; - - if (!type) { - GtkTypeInfo type_info = { - "CamelVeeFolder", - sizeof (CamelVeeFolder), - sizeof (CamelVeeFolderClass), - (GtkClassInitFunc) camel_vee_folder_class_init, - (GtkObjectInitFunc) camel_vee_folder_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL - }; - - type = gtk_type_unique (camel_folder_get_type (), &type_info); - } - - return type; -} - -static void -camel_vee_folder_class_init (CamelVeeFolderClass *klass) -{ - GtkObjectClass *object_class = (GtkObjectClass *) klass; - CamelFolderClass *folder_class = (CamelFolderClass *) klass; - - camel_vee_folder_parent = gtk_type_class (camel_folder_get_type ()); - - printf("vfolder class init\n"); - - folder_class->init = vee_init; - folder_class->open = vee_open; - folder_class->close = vee_close; - folder_class->exists = vee_exists; - - folder_class->get_uids = vee_get_uids; - folder_class->get_summary = vee_get_summary; - folder_class->free_summary = vee_free_summary; - folder_class->get_message_by_uid = vee_get_message_by_uid; - folder_class->append_message = vee_append_message; - - folder_class->summary_get_by_uid = vee_summary_get_by_uid; - - folder_class->get_message_count = vee_get_message_count; - folder_class->search_by_expression = vee_search_by_expression; - - object_class->finalize = camel_vee_folder_finalise; - - gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL); -} - -static void -camel_vee_folder_init (CamelVeeFolder *obj) -{ - struct _CamelVeeFolderPrivate *p; - - printf("vfolder init\n"); - - p = _PRIVATE(obj) = g_malloc0(sizeof(*p)); -} - -static void -camel_vee_folder_finalise (GtkObject *obj) -{ - CamelVeeFolder *vf = (CamelVeeFolder *)obj; - struct _CamelVeeFolderPrivate *p = _PRIVATE(vf); - GList *node; - - node = p->folders; - while (node) { - CamelFolder *f = node->data; - gtk_object_unref((GtkObject *)f); - node = g_list_next(node); - } - - ((GtkObjectClass *)(camel_vee_folder_parent))->finalize((GtkObject *)obj); -} - -/** - * camel_vee_folder_new: - * - * Create a new CamelVeeFolder object. - * - * Return value: A new CamelVeeFolder widget. - **/ -CamelVeeFolder * -camel_vee_folder_new (void) -{ - CamelVeeFolder *new = CAMEL_VEE_FOLDER ( gtk_type_new (camel_vee_folder_get_type ())); - return new; -} - - -void -camel_vee_folder_add_folder(CamelVeeFolder *vf, CamelFolder *sub) -{ - struct _CamelVeeFolderPrivate *p = _PRIVATE(vf); - - gtk_object_ref((GtkObject *)sub); - p->folders = g_list_append(p->folders, sub); -} - - -static void vee_init (CamelFolder *folder, CamelStore *parent_store, - CamelFolder *parent_folder, const gchar *name, - gchar separator, CamelException *ex) -{ - CamelVeeFolder *vf = (CamelVeeFolder *)folder; - char *namepart, *searchpart; - - namepart = g_strdup(name); - searchpart = strchr(namepart, '?'); - if (searchpart == NULL) { - /* no search, no result! */ - searchpart = "(body-contains \"=some-invalid_string-sequence=xx\")"; - } else { - *searchpart++ = 0; - } - - camel_vee_folder_parent->init (folder, parent_store, parent_folder, name, separator, ex); - if (camel_exception_get_id (ex)) - return; - - folder->can_hold_messages = TRUE; - folder->can_hold_folders = FALSE; - folder->has_summary_capability = TRUE; - folder->has_search_capability = TRUE; - - /* FIXME: what to do about user flags if the subfolder doesn't support them? */ - folder->permanent_flags = CAMEL_MESSAGE_ANSWERED | - CAMEL_MESSAGE_DELETED | - CAMEL_MESSAGE_DRAFT | - CAMEL_MESSAGE_FLAGGED | - CAMEL_MESSAGE_SEEN; - - vf->messages = g_ptr_array_new(); - vf->messages_uid = g_hash_table_new(g_str_hash, g_str_equal); - - vf->expression = g_strdup_printf("(or\n (match-all (user-flag \"%s\"))\n %s\n)", namepart, searchpart); - vf->vname = g_strdup(namepart); - - printf("VFolder expression is %s\n", vf->expression); - printf("VFolder full name = %s\n", camel_folder_get_full_name(folder)); - - g_free(namepart); -} - -static void vee_open (CamelFolder *folder, CamelFolderOpenMode mode, CamelException *ex) -{ - CamelVeeFolder *vf = (CamelVeeFolder *)folder; - - camel_vee_folder_parent->open (folder, mode, ex); - if (camel_exception_get_id(ex)) - return; - - /* perform search on folders to be searched ... */ - vee_folder_build(vf, ex); -} - -static void vee_close (CamelFolder *folder, gboolean expunge, CamelException *ex) -{ - camel_vee_folder_parent->close (folder, expunge, ex); - - /* FIXME: close vfolder? */ -} - -/* vfolders always exist? */ -static gboolean vee_exists (CamelFolder *folder, CamelException *ex) -{ - return TRUE; -} - -static void vee_append_message (CamelFolder *folder, CamelMimeMessage *message, CamelException *ex) -{ - CamelVeeFolder *vf = (CamelVeeFolder *)folder; - - if (message->folder && message->folder->permanent_flags & CAMEL_MESSAGE_USER) { - /* set the flag on the message ... */ - camel_mime_message_set_user_flag(message, vf->vname, TRUE); - } else { - /* FIXME: error code */ - camel_exception_setv(ex, 1, "Cannot append this message to virtual folder"); - } -} - -static gint vee_get_message_count (CamelFolder *folder, CamelException *ex) -{ - CamelVeeFolder *vf = (CamelVeeFolder *)folder; - - return vf->messages->len; -} - -static CamelMimeMessage *vee_get_message_by_uid (CamelFolder *folder, const gchar *uid, CamelException *ex) -{ - CamelVeeMessageInfo *mi; - - mi = (CamelVeeMessageInfo *)vee_summary_get_by_uid(folder, uid); - if (mi == NULL) { - camel_exception_setv(ex, 1, "Failed"); - return NULL; - } - return camel_folder_get_message_by_uid(mi->folder, strchr(mi->info.uid, ':')+1, ex); -} - -GPtrArray *vee_get_summary (CamelFolder *folder, CamelException *ex) -{ - CamelVeeFolder *vf = (CamelVeeFolder *)folder; - - return vf->messages; -} - -void vee_free_summary (CamelFolder *folder, GPtrArray *array) -{ - /* no op */ -} - -static const CamelMessageInfo *vee_summary_get_by_uid(CamelFolder *f, const char *uid) -{ - CamelVeeFolder *vf = (CamelVeeFolder *)f; - - return g_hash_table_lookup(vf->messages_uid, uid); -} - -static GPtrArray *vee_get_uids (CamelFolder *folder, CamelException *ex) -{ - GPtrArray *result; - int i; - CamelVeeFolder *vf = (CamelVeeFolder *)folder; - - result = g_ptr_array_new (); - g_ptr_array_set_size (result, vf->messages->len); - for (i=0;imessages->len;i++) { - CamelMessageInfo *mi = g_ptr_array_index(vf->messages, i); - result->pdata[i] = g_strdup(mi->uid); - } - - return result; -} - -static GList * -vee_search_by_expression(CamelFolder *folder, const char *expression, CamelException *ex) -{ - GList *result = NULL, *node; - char *expr; - CamelVeeFolder *vf = (CamelVeeFolder *)folder; - struct _CamelVeeFolderPrivate *p = _PRIVATE(vf); - - expr = g_strdup_printf("(and %s %s)", vf->expression, expression); - node = p->folders; - while (node) { - CamelFolder *f = node->data; - GList *matches, *match; - matches = camel_folder_search_by_expression(f, vf->expression, ex); - match = matches; - while (match) { - char *uid = match->data; - result = g_list_prepend(result, g_strdup_printf("%p:%s", f, uid)); - match = g_list_next(match); - } - g_list_free(matches); - node = g_list_next(node); - } - return result; -} - -/* - need incremental update, based on folder. - Need to watch folders for changes and update accordingly. -*/ - -/* this does most of the vfolder magic */ -static void -vee_folder_build(CamelVeeFolder *vf, CamelException *ex) -{ - struct _CamelVeeFolderPrivate *p = _PRIVATE(vf); - GList *node; - - GPtrArray *messages; - GHashTable *messages_uid; - - { - int i; - - for (i=0;imessages->len;i++) { - CamelVeeMessageInfo *mi = g_ptr_array_index(vf->messages, i); - g_free(mi->info.subject); - g_free(mi->info.to); - g_free(mi->info.from); - g_free(mi->info.uid); - camel_flag_list_free(&mi->info.user_flags); - } - } - - messages = g_ptr_array_new(); - messages_uid = g_hash_table_new(g_str_hash, g_str_equal); - - node = p->folders; - while (node) { - GList *matches, *match; - CamelFolder *f = node->data; - CamelVeeMessageInfo *mi; - const CamelMessageInfo *info; - CamelFlag *flag; - - matches = camel_folder_search_by_expression(f, vf->expression, ex); - match = matches; - while (match) { - info = camel_folder_summary_get_by_uid(f, match->data); - if (info) { - mi = g_malloc0(sizeof(*mi)); - mi->info.subject = g_strdup(info->subject); - mi->info.to = g_strdup(info->to); - mi->info.from = g_strdup(info->from); - mi->info.uid = g_strdup_printf("%p:%s", f, info->uid); - mi->info.flags = info->flags; - mi->info.size = info->size; - mi->info.date_sent = info->date_sent; - mi->info.date_received = info->date_received; - flag = info->user_flags; - while (flag) { - camel_flag_set(&mi->info.user_flags, flag->name, TRUE); - flag = flag->next; - } - mi->info.content = NULL; - mi->folder = f; - g_ptr_array_add(messages, mi); - g_hash_table_insert(messages_uid, mi->info.uid, mi); - } - match = g_list_next(match); - } - g_list_free(matches); - node = g_list_next(node); - } - - g_ptr_array_free(vf->messages, TRUE); - vf->messages = messages; - g_hash_table_destroy(vf->messages_uid); - vf->messages_uid = messages_uid; -} - - -/* - - (match-folder "folder1" "folder2") - - */ diff --git a/camel/providers/vee/camel-vee-folder.h b/camel/providers/vee/camel-vee-folder.h deleted file mode 100644 index ea2a82a25b..0000000000 --- a/camel/providers/vee/camel-vee-folder.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2000 Helix Code Inc. - * - * Authors: Michael Zucchi - * - * 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_VEE_FOLDER_H -#define _CAMEL_VEE_FOLDER_H - -#include -#include - -#define CAMEL_VEE_FOLDER(obj) GTK_CHECK_CAST (obj, camel_vee_folder_get_type (), CamelVeeFolder) -#define CAMEL_VEE_FOLDER_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, camel_vee_folder_get_type (), CamelVeeFolderClass) -#define IS_CAMEL_VEE_FOLDER(obj) GTK_CHECK_TYPE (obj, camel_vee_folder_get_type ()) - -typedef struct _CamelVeeFolder CamelVeeFolder; -typedef struct _CamelVeeFolderClass CamelVeeFolderClass; - -struct _CamelVeeFolder { - CamelFolder parent; - - struct _CamelVeeFolderPrivate *priv; - - char *expression; /* query expression */ - char *vname; /* local name */ - CamelFolder *local; /* local storage for folder */ - - /* FIXME: Move this to a summary object??? */ - GPtrArray *messages; /* message info's */ - GHashTable *messages_uid; -}; - -struct _CamelVeeFolderClass { - CamelFolderClass parent_class; -}; - -guint camel_vee_folder_get_type (void); -CamelVeeFolder *camel_vee_folder_new (void); - -void camel_vee_folder_add_folder(CamelVeeFolder *vf, CamelFolder *sub); - -#endif /* ! _CAMEL_VEE_FOLDER_H */ diff --git a/camel/providers/vee/camel-vee-provider.c b/camel/providers/vee/camel-vee-provider.c deleted file mode 100644 index b9c20b4561..0000000000 --- a/camel/providers/vee/camel-vee-provider.c +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2000 Helix Code Inc. - * - * Authors: Michael Zucchi - * - * 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-vee-store.h" -#include "camel-provider.h" -#include "camel-session.h" - -static CamelProvider vee_provider = { - "vfolder", - "Virtual folder email provider", - - "For reading mail as a query of another set of folders", - - 0, - - { 0, 0 } -}; - -void -camel_provider_module_init (CamelSession *session) -{ - vee_provider.object_types[CAMEL_PROVIDER_STORE] = - camel_vee_store_get_type(); - - camel_session_register_provider (session, &vee_provider); -} diff --git a/camel/providers/vee/camel-vee-store.c b/camel/providers/vee/camel-vee-store.c deleted file mode 100644 index b62a6b9fab..0000000000 --- a/camel/providers/vee/camel-vee-store.c +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (C) 2000 Helix Code Inc. - * - * Authors: Michael Zucchi - * - * 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-vee-store.h" -#include "camel-vee-folder.h" - -static CamelFolder *vee_get_folder (CamelStore *store, const char *folder_name, CamelException *ex); -static char *vee_get_folder_name (CamelStore *store, const char *folder_name, CamelException *ex); - -struct _CamelVeeStorePrivate { -}; - -#define _PRIVATE(o) (((CamelVeeStore *)(o))->priv) - -static void camel_vee_store_class_init (CamelVeeStoreClass *klass); -static void camel_vee_store_init (CamelVeeStore *obj); -static void camel_vee_store_finalise (GtkObject *obj); - -static CamelStoreClass *camel_vee_store_parent; - -enum SIGNALS { - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -guint -camel_vee_store_get_type (void) -{ - static guint type = 0; - - if (!type) { - GtkTypeInfo type_info = { - "CamelVeeStore", - sizeof (CamelVeeStore), - sizeof (CamelVeeStoreClass), - (GtkClassInitFunc) camel_vee_store_class_init, - (GtkObjectInitFunc) camel_vee_store_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL - }; - - type = gtk_type_unique (camel_store_get_type (), &type_info); - } - - return type; -} - -static void - -camel_vee_store_class_init (CamelVeeStoreClass *klass) -{ - GtkObjectClass *object_class = (GtkObjectClass *) klass; - CamelStoreClass *store_class = (CamelStoreClass *) klass; - - camel_vee_store_parent = gtk_type_class (camel_store_get_type ()); - - /* virtual method overload */ - store_class->get_folder = vee_get_folder; - store_class->get_folder_name = vee_get_folder_name; - - object_class->finalize = camel_vee_store_finalise; - - gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL); -} - -static void -camel_vee_store_init (CamelVeeStore *obj) -{ - struct _CamelVeeStorePrivate *p; - - p = _PRIVATE(obj) = g_malloc0(sizeof(*p)); -} - -static void -camel_vee_store_finalise (GtkObject *obj) -{ - ((GtkObjectClass *)(camel_vee_store_parent))->finalize((GtkObject *)obj); -} - -/** - * camel_vee_store_new: - * - * Create a new CamelVeeStore object. - * - * Return value: A new CamelVeeStore widget. - **/ -CamelVeeStore * -camel_vee_store_new (void) -{ - CamelVeeStore *new = CAMEL_VEE_STORE ( gtk_type_new (camel_vee_store_get_type ())); - return new; -} - -static CamelFolder * -vee_get_folder (CamelStore *store, const char *folder_name, CamelException *ex) -{ - CamelFolder *folder; - - folder = gtk_type_new (camel_vee_folder_get_type()); - - printf("my type is: %s\n", gtk_type_name(((GtkObject *)folder)->klass->type)); - - ((CamelFolderClass *)((GtkObject *)folder)->klass)->init (folder, store, NULL, folder_name, '/', ex); - return folder; -} - -static char * -vee_get_folder_name (CamelStore *store, const char *folder_name, CamelException *ex) -{ -#warning "What purpose does this function serve?" - return g_strdup(folder_name); -} - diff --git a/camel/providers/vee/camel-vee-store.h b/camel/providers/vee/camel-vee-store.h deleted file mode 100644 index 848769296a..0000000000 --- a/camel/providers/vee/camel-vee-store.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (C) 2000 Helix Code Inc. - * - * Authors: Michael Zucchi - * - * 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_VEE_STORE_H -#define _CAMEL_VEE_STORE_H - -#include -#include - -#define CAMEL_VEE_STORE(obj) GTK_CHECK_CAST (obj, camel_vee_store_get_type (), CamelVeeStore) -#define CAMEL_VEE_STORE_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, camel_vee_store_get_type (), CamelVeeStoreClass) -#define IS_CAMEL_VEE_STORE(obj) GTK_CHECK_TYPE (obj, camel_vee_store_get_type ()) - -typedef struct _CamelVeeStore CamelVeeStore; -typedef struct _CamelVeeStoreClass CamelVeeStoreClass; - -struct _CamelVeeStore { - CamelStore parent; - - struct _CamelVeeStorePrivate *priv; -}; - -struct _CamelVeeStoreClass { - CamelStoreClass parent_class; -}; - -guint camel_vee_store_get_type (void); -CamelVeeStore *camel_vee_store_new (void); - -#endif /* ! _CAMEL_VEE_STORE_H */ diff --git a/camel/providers/vee/libcamelvee.urls b/camel/providers/vee/libcamelvee.urls deleted file mode 100644 index 6fa58dadb5..0000000000 --- a/camel/providers/vee/libcamelvee.urls +++ /dev/null @@ -1 +0,0 @@ -vfolder -- cgit v1.2.3