aboutsummaryrefslogtreecommitdiffstats
path: root/camel/providers/imap
diff options
context:
space:
mode:
authornobody <nobody@localhost>2000-06-24 18:47:21 +0800
committernobody <nobody@localhost>2000-06-24 18:47:21 +0800
commit98a8e41c8a585b2773fd91bff188346c24477c01 (patch)
tree957251da2611d83c08b2ff201fec4f0f3941c628 /camel/providers/imap
parent5d0f34b4eefc1f57757e23e4583394742dca1dc8 (diff)
downloadgsoc2013-evolution-WITH_LIBEFS.tar.gz
gsoc2013-evolution-WITH_LIBEFS.tar.zst
gsoc2013-evolution-WITH_LIBEFS.zip
This commit was manufactured by cvs2svn to create tag 'WITH_LIBEFS'.WITH_LIBEFS
svn path=/tags/WITH_LIBEFS/; revision=3727
Diffstat (limited to 'camel/providers/imap')
-rw-r--r--camel/providers/imap/.cvsignore7
-rw-r--r--camel/providers/imap/Makefile.am45
-rw-r--r--camel/providers/imap/camel-imap-folder.c1245
-rw-r--r--camel/providers/imap/camel-imap-folder.h74
-rw-r--r--camel/providers/imap/camel-imap-provider.c109
-rw-r--r--camel/providers/imap/camel-imap-store.c672
-rw-r--r--camel/providers/imap/camel-imap-store.h84
-rw-r--r--camel/providers/imap/camel-imap-stream.c192
-rw-r--r--camel/providers/imap/camel-imap-stream.h71
-rw-r--r--camel/providers/imap/libcamelimap.urls1
10 files changed, 0 insertions, 2500 deletions
diff --git a/camel/providers/imap/.cvsignore b/camel/providers/imap/.cvsignore
deleted file mode 100644
index fd6b811c68..0000000000
--- a/camel/providers/imap/.cvsignore
+++ /dev/null
@@ -1,7 +0,0 @@
-.deps
-Makefile
-Makefile.in
-.libs
-.deps
-*.lo
-*.la
diff --git a/camel/providers/imap/Makefile.am b/camel/providers/imap/Makefile.am
deleted file mode 100644
index 4fc2397e62..0000000000
--- a/camel/providers/imap/Makefile.am
+++ /dev/null
@@ -1,45 +0,0 @@
-## Process this file with automake to produce Makefile.in
-
-SUBDIRS =
-
-libcamelimapincludedir = $(includedir)/camel
-
-
-providerdir = $(pkglibdir)/camel-providers/$(VERSION)
-
-provider_LTLIBRARIES = libcamelimap.la
-provider_DATA = libcamelimap.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-imap-provider\"
-
-libcamelimap_la_SOURCES = \
- camel-imap-folder.c \
- camel-imap-provider.c \
- camel-imap-store.c \
- camel-imap-stream.c
-
-libcamelimapinclude_HEADERS = \
- camel-imap-folder.h \
- camel-imap-store.h \
- camel-imap-stream.h
-
-libcamelimap_la_LDFLAGS = -version-info 0:0:0
-
-libcamelimap_la_LIBADD = $(top_builddir)/e-util/libeutil.la $(UNICODE_LIBS)
-#libcamelimap_la_LIBADD = $(top_builddir)/libibex/libibex.la $(UNICODE_LIBS)
-
-EXTRA_DIST = libcamelimap.urls
-
-
-
-
-
diff --git a/camel/providers/imap/camel-imap-folder.c b/camel/providers/imap/camel-imap-folder.c
deleted file mode 100644
index 51bab59eb4..0000000000
--- a/camel/providers/imap/camel-imap-folder.c
+++ /dev/null
@@ -1,1245 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; fill-column: 160 -*- */
-/* camel-imap-folder.c : Abstract class for an email folder */
-
-/*
- * Authors: Jeffrey Stedfast <fejj@helixcode.com>
- *
- * 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 <config.h>
-
-#include <stdlib.h>
-#include <sys/types.h>
-#include <dirent.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <errno.h>
-#include <string.h>
-#include <fcntl.h>
-
-#include "camel-imap-folder.h"
-#include "camel-imap-store.h"
-#include "camel-imap-stream.h"
-#include "string-utils.h"
-#include "camel-stream.h"
-#include "camel-stream-fs.h"
-#include "camel-stream-mem.h"
-#include "camel-stream-buffer.h"
-#include "camel-data-wrapper.h"
-#include "camel-mime-message.h"
-#include "camel-stream-filter.h"
-#include "camel-mime-filter-from.h"
-#include "camel-mime-filter-crlf.h"
-#include "camel-exception.h"
-#include "camel-mime-utils.h"
-
-#define d(x)
-
-#define CF_CLASS(o) (CAMEL_FOLDER_CLASS (GTK_OBJECT (o)->klass))
-
-static CamelFolderClass *parent_class = NULL;
-
-static void imap_init (CamelFolder *folder, CamelStore *parent_store,
- CamelFolder *parent_folder, const gchar *name,
- gchar *separator, gboolean path_begns_with_sep,
- CamelException *ex);
-
-static void imap_sync (CamelFolder *folder, gboolean expunge, CamelException *ex);
-#if 0
-static gboolean imap_exists (CamelFolder *folder, CamelException *ex);
-static gboolean imap_delete (CamelFolder *folder, gboolean recurse, CamelException *ex);
-static gboolean imap_delete_messages (CamelFolder *folder, CamelException *ex);
-#endif
-static gint imap_get_message_count (CamelFolder *folder, CamelException *ex);
-static void imap_append_message (CamelFolder *folder, CamelMimeMessage *message, CamelException *ex);
-static GPtrArray *imap_get_uids (CamelFolder *folder, CamelException *ex);
-static gboolean imap_parse_subfolder_line (gchar *buf, gchar **flags, gchar **sep, gchar **folder);
-static GPtrArray *imap_get_subfolder_names (CamelFolder *folder, CamelException *ex);
-static GPtrArray *imap_get_summary (CamelFolder *folder, CamelException *ex);
-static void imap_free_summary (CamelFolder *folder, GPtrArray *array);
-static CamelMimeMessage *imap_get_message_by_uid (CamelFolder *folder, const gchar *uid,
- CamelException *ex);
-
-static void imap_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 imap_delete_message_by_uid (CamelFolder *folder, const gchar *uid, CamelException *ex);
-
-static const CamelMessageInfo *imap_summary_get_by_uid (CamelFolder *f, const char *uid);
-
-static GList *imap_search_by_expression (CamelFolder *folder, const char *expression, CamelException *ex);
-
-static void imap_finalize (GtkObject *object);
-
-/* flag methods */
-static guint32 imap_get_permanent_flags (CamelFolder *folder, CamelException *ex);
-static guint32 imap_get_message_flags (CamelFolder *folder, const char *uid, CamelException *ex);
-static void imap_set_message_flags (CamelFolder *folder, const char *uid, guint32 flags, guint32 set,
- CamelException *ex);
-static gboolean imap_get_message_user_flag (CamelFolder *folder, const char *uid, const char *name,
- CamelException *ex);
-static void imap_set_message_user_flag (CamelFolder *folder, const char *uid, const char *name,
- gboolean value, CamelException *ex);
-
-static void
-camel_imap_folder_class_init (CamelImapFolderClass *camel_imap_folder_class)
-{
- CamelFolderClass *camel_folder_class = CAMEL_FOLDER_CLASS (camel_imap_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 = imap_init;
- camel_folder_class->sync = imap_sync;
- camel_folder_class->expunge = imap_expunge;
-
- camel_folder_class->get_uids = imap_get_uids;
- camel_folder_class->get_subfolder_names = imap_get_subfolder_names;
-
- camel_folder_class->get_message_count = imap_get_message_count;
- camel_folder_class->get_message_by_uid = imap_get_message_by_uid;
- camel_folder_class->append_message = imap_append_message;
- camel_folder_class->delete_message_by_uid = imap_delete_message_by_uid;
-
- camel_folder_class->get_summary = imap_get_summary;
- camel_folder_class->summary_get_by_uid = imap_summary_get_by_uid;
- camel_folder_class->free_summary = imap_free_summary;
-
- camel_folder_class->search_by_expression = imap_search_by_expression;
-
- camel_folder_class->get_permanent_flags = imap_get_permanent_flags;
- camel_folder_class->get_message_flags = imap_get_message_flags;
- camel_folder_class->set_message_flags = imap_set_message_flags;
- /*camel_folder_class->get_message_user_flags = imap_get_message_user_flags;*/
- /*camel_folder_class->set_message_user_flags = imap_set_message_user_flags;*/
-
- gtk_object_class->finalize = imap_finalize;
-}
-
-static void
-camel_imap_folder_init (gpointer object, gpointer klass)
-{
- CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (object);
- CamelFolder *folder = CAMEL_FOLDER (object);
-
- folder->can_hold_messages = TRUE;
- folder->can_hold_folders = TRUE;
- folder->has_summary_capability = TRUE;
- folder->has_search_capability = FALSE; /* default - we have to query IMAP to know for sure */
-
- imap_folder->summary = NULL;
- imap_folder->count = -1;
-}
-
-GtkType
-camel_imap_folder_get_type (void)
-{
- static GtkType camel_imap_folder_type = 0;
-
- if (!camel_imap_folder_type) {
- GtkTypeInfo camel_imap_folder_info =
- {
- "CamelImapFolder",
- sizeof (CamelImapFolder),
- sizeof (CamelImapFolderClass),
- (GtkClassInitFunc) camel_imap_folder_class_init,
- (GtkObjectInitFunc) camel_imap_folder_init,
- /* reserved_1 */ NULL,
- /* reserved_2 */ NULL,
- (GtkClassInitFunc) NULL,
- };
-
- camel_imap_folder_type = gtk_type_unique (CAMEL_FOLDER_TYPE, &camel_imap_folder_info);
- }
-
- return camel_imap_folder_type;
-}
-
-CamelFolder *
-camel_imap_folder_new (CamelStore *parent, char *folder_name, CamelException *ex)
-{
- CamelFolder *folder = CAMEL_FOLDER (gtk_object_new (camel_imap_folder_get_type (), NULL));
-
- CF_CLASS (folder)->init (folder, parent, NULL, folder_name, "/", FALSE, ex);
-
- return folder;
-}
-
-static void
-imap_finalize (GtkObject *object)
-{
- /* TODO: do we need to do more here? */
- CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (object);
- CamelMessageInfo *info;
- gint i, max;
-
- GTK_OBJECT_CLASS (parent_class)->finalize (object);
-
- g_return_if_fail (imap_folder->summary != NULL);
-
- max = imap_folder->summary->len;
- for (i = 0; i < max; i++) {
- info = g_ptr_array_index (imap_folder->summary, i);
- g_free (info->subject);
- g_free (info->to);
- g_free (info->from);
- g_free (info->uid);
- g_free (info);
- info = NULL;
- }
-
- g_ptr_array_free (imap_folder->summary, TRUE);
- imap_folder->summary = NULL;
-}
-
-static void
-imap_init (CamelFolder *folder, CamelStore *parent_store, CamelFolder *parent_folder,
- const gchar *name, gchar *separator, gboolean path_begins_with_sep, CamelException *ex)
-{
- CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder);
- CamelStore *store = CAMEL_STORE (parent_store);
- CamelURL *url = CAMEL_SERVICE (store)->url;
- int status;
- char *result, *folder_path;
-
- /* call parent method */
- parent_class->init (folder, parent_store, parent_folder, name, separator, path_begins_with_sep, 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;
-
- /* now lets find out if we can do searches... */
- status = camel_imap_command_extended (CAMEL_IMAP_STORE (folder->parent_store), folder,
- &result, "CAPABILITY");
-
- /* ugh, I forgot that CAPABILITY doesn't have a response code */
- if (status != CAMEL_IMAP_OK) {
- CamelService *service = CAMEL_SERVICE (folder->parent_store);
-
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- "Could not get capabilities on IMAP server %s: %s.",
- service->url->host,
- status == CAMEL_IMAP_ERR ? result :
- "Unknown error");
- }
-
- if (strstrcase (result, "SEARCH"))
- folder->has_search_capability = TRUE;
- else
- folder->has_search_capability = FALSE;
-
- g_free (result);
-
- fprintf (stderr, "IMAP provider does%shave SEARCH support\n", folder->has_search_capability ? " " : "n't ");
-
- /* some IMAP daemons support user-flags *
- * I would not, however, rely on this feature as *
- * most IMAP daemons are not 100% RFC compliant */
- folder->permanent_flags = CAMEL_MESSAGE_SEEN |
- CAMEL_MESSAGE_ANSWERED |
- CAMEL_MESSAGE_FLAGGED |
- CAMEL_MESSAGE_DELETED |
- CAMEL_MESSAGE_DRAFT |
- CAMEL_MESSAGE_USER;
-
-
- imap_folder->search = NULL;
- imap_folder->summary = NULL;
-
- /* SELECT the IMAP mail spool */
- if (url && url->path && *(url->path + 1) && strcmp (folder->full_name, "INBOX"))
- folder_path = g_strdup_printf ("%s/%s", url->path + 1, folder->full_name);
- else
- folder_path = g_strdup (folder->full_name);
-
- status = camel_imap_command_extended (CAMEL_IMAP_STORE (folder->parent_store), folder,
- &result, "SELECT %s", folder_path);
- if (status != CAMEL_IMAP_OK) {
- CamelService *service = CAMEL_SERVICE (folder->parent_store);
-
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- "Could not SELECT %s on IMAP server %s: %s.",
- folder->full_name, service->url->host,
- status == CAMEL_IMAP_ERR ? result :
- "Unknown error");
- } else {
- /* parse the mode we opened it in */
- }
- g_free (result);
- g_free (folder_path);
-}
-
-static void
-imap_sync (CamelFolder *folder, gboolean expunge, CamelException *ex)
-{
-#if 0
- CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder);
- gint i, max;
-
- /* uhhh...this is kinda unsafe so we'll leave it blocked out */
- if (imap_folder->summary) {
- max = imap_folder->summary->len;
- for (i = 0; i < max; i++) {
- CamelMessageInfo *info;
-
- info = (CamelMessageInfo *) g_ptr_array_index (imap_folder->summary, i);
- if (info->flags & CAMEL_MESSAGE_FOLDER_FLAGGED) {
- char *flags;
-
- flags = g_strconcat (info->flags & CAMEL_MESSAGE_SEEN ? "\\Seen " : "",
- info->flags & CAMEL_MESSAGE_DRAFT ? "\\Draft " : "",
- info->flags & CAMEL_MESSAGE_DELETED ? "\\Deleted " : "",
- info->flags & CAMEL_MESSAGE_DELETED ? "\\Answered " : "",
- NULL);
- if (*flags) {
- gchar *result;
- gint s;
-
- *(flags + strlen (flags) - 1) = '\0';
- s = camel_imap_command_extended (CAMEL_IMAP_STORE (folder->parent_store),
- folder, &result,
- "UID STORE %s FLAGS.SILENT (%s)",
- info->uid, flags);
-
- if (s != CAMEL_IMAP_OK) {
- CamelService *service = CAMEL_SERVICE (folder->parent_store);
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- "Could not set flags on message %s on IMAP "
- "server %s: %s.", info->uid,
- service->url->host,
- status == CAMEL_IMAP_ERR ? result :
- "Unknown error");
- g_free (result);
- return;
- }
-
- g_free(result);
- }
- g_free (flags);
- }
- }
- }
-#endif
-
- if (expunge)
- imap_expunge (folder, ex);
-}
-
-static void
-imap_expunge (CamelFolder *folder, CamelException *ex)
-{
- gchar *result;
- gint status;
-
- g_return_if_fail (folder != NULL);
-
- status = camel_imap_command_extended (CAMEL_IMAP_STORE (folder->parent_store), folder,
- &result, "EXPUNGE");
-
- if (status != CAMEL_IMAP_OK) {
- CamelService *service = CAMEL_SERVICE (folder->parent_store);
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- "Could not EXPUNGE from IMAP server %s: %s.",
- service->url->host,
- status == CAMEL_IMAP_ERR ? result :
- "Unknown error");
- g_free (result);
- return;
- }
-
- g_free(result);
-}
-
-#if 0
-static gboolean
-imap_delete (CamelFolder *folder, gboolean recurse, CamelException *ex)
-{
- /* TODO: code this & what should this do? delete messages or the folder? */
- CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder);
- gboolean folder_already_exists;
-
- g_return_val_if_fail (folder != NULL, FALSE);
-
- /* 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);
- if (camel_exception_get_id (ex))
- return FALSE;
-
- if (!(folder->full_name || folder->name)) {
- camel_exception_set (ex, CAMEL_EXCEPTION_FOLDER_INVALID,
- "invalid folder path. Use set_name ?");
- return FALSE;
- }
-
- /* delete the directory - we must start with the leaves and work
- back to the root if we are to delete recursively */
-
- /* TODO: Finish this... */
-
- return TRUE;
-}
-#endif
-
-static gint
-imap_get_message_count (CamelFolder *folder, CamelException *ex)
-{
- CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder);
- CamelStore *store = CAMEL_STORE (folder->parent_store);
- CamelURL *url = CAMEL_SERVICE (store)->url;
- gchar *result, *msg_count, *folder_path;
- gint status;
-
- g_return_val_if_fail (folder != NULL, -1);
-
- /* If we already have a count, return */
- if (imap_folder->count != -1)
- return imap_folder->count;
-
- if (url && url->path && *(url->path + 1) && strcmp (folder->full_name, "INBOX"))
- folder_path = g_strdup_printf ("%s/%s", url->path + 1, folder->full_name);
- else
- folder_path = g_strdup (folder->full_name);
-
- status = camel_imap_command_extended (CAMEL_IMAP_STORE (folder->parent_store), folder,
- &result, "STATUS %s (MESSAGES)", folder_path);
-
- if (status != CAMEL_IMAP_OK) {
- CamelService *service = CAMEL_SERVICE (folder->parent_store);
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- "Could not get message count for %s from IMAP "
- "server %s: %s.", folder_path, service->url->host,
- status == CAMEL_IMAP_ERR ? result :
- "Unknown error");
- g_free (result);
- g_free (folder_path);
- return -1;
- }
- g_free (folder_path);
-
- /* parse out the message count - should come in the form: "* STATUS <folder> (MESSAGES <count>)\r\n" */
- if (result && *result == '*') {
- if ((msg_count = strstr (result, "MESSAGES")) != NULL) {
- msg_count += strlen ("MESSAGES") + 1;
-
- for ( ; *msg_count == ' '; msg_count++);
-
- /* we should now be pointing to the message count */
- imap_folder->count = atoi (msg_count);
- }
- }
- g_free (result);
-
- return imap_folder->count;
-}
-
-/* TODO: Optimize this later - there may be times when moving/copying a message from the
- same IMAP store in which case we'd want to use IMAP's COPY command */
-static void
-imap_append_message (CamelFolder *folder, CamelMimeMessage *message, CamelException *ex)
-{
- CamelStore *store = CAMEL_STORE (folder->parent_store);
- CamelURL *url = CAMEL_SERVICE (store)->url;
- CamelStreamMem *mem;
- gchar *result, *folder_path;
- gint status;
-
- g_return_if_fail (folder != NULL);
- g_return_if_fail (message != NULL);
-
- /* write the message to a CamelStreamMem so we can get it's size */
- mem = CAMEL_STREAM_MEM (camel_stream_mem_new());
- if (camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (message), CAMEL_STREAM (mem)) == -1) {
- CamelService *service = CAMEL_SERVICE (folder->parent_store);
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- "Could not APPEND message to IMAP server %s: %s.",
- service->url->host,
- g_strerror (errno));
-
- return;
- }
-
- mem->buffer = g_byte_array_append (mem->buffer, g_strdup("\r\n"), 3);
-
- if (url && url->path && *(url->path + 1) && strcmp(folder->full_name, "INBOX"))
- folder_path = g_strdup_printf ("%s/%s", url->path, folder->full_name);
- else
- folder_path = g_strdup (folder->full_name);
-
- status = camel_imap_command (CAMEL_IMAP_STORE (folder->parent_store),
- folder, &result,
- "APPEND %s (\\Seen) {%d}\r\n%s",
- folder_path,
- mem->buffer->len,
- mem->buffer->data);
-
- if (status != CAMEL_IMAP_OK) {
- CamelService *service = CAMEL_SERVICE (folder->parent_store);
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- "Could not APPEND message to IMAP server %s: %s.",
- service->url->host,
- status == CAMEL_IMAP_ERR ? result :
- "Unknown error");
- g_free (result);
- g_free (folder_path);
- return;
- }
-
- g_free (result);
- g_free (folder_path);
-}
-
-static GPtrArray *
-imap_get_uids (CamelFolder *folder, CamelException *ex)
-{
- CamelMessageInfo *info;
- GPtrArray *array, *infolist;
- gint i, count;
-
- infolist = imap_get_summary (folder, ex);
- count = infolist->len;
-
- array = g_ptr_array_new ();
- g_ptr_array_set_size (array, count);
- for (i = 0; i < count; i++) {
- info = (CamelMessageInfo *) g_ptr_array_index (infolist, i);
- array->pdata[i] = g_strdup (info->uid);
- }
-
- imap_free_summary (folder, infolist);
-
- return array;
-}
-
-static gboolean
-imap_parse_subfolder_line (gchar *buf, gchar **flags, gchar **sep, gchar **folder)
-{
- gchar *ptr, *eptr;
-
- *flags = NULL;
- *sep = NULL;
- *folder = NULL;
-
- if (strncasecmp (buf, "* LIST", 6))
- return FALSE;
-
- ptr = strstr (buf + 6, "(");
- if (!ptr)
- return FALSE;
-
- ptr++;
- eptr = strstr (ptr, ")");
- if (!eptr)
- return FALSE;
-
- *flags = g_strndup (ptr, (gint)(eptr - ptr));
-
- ptr = strstr (eptr, "\"");
- if (!ptr)
- return FALSE;
-
- ptr++;
- eptr = strstr (ptr, "\"");
- if (!eptr)
- return FALSE;
-
- *sep = g_strndup (ptr, (gint)(eptr - ptr));
-
- ptr = eptr + 1;
- *folder = g_strdup (ptr);
- g_strstrip (*folder);
-
- return TRUE;
-}
-
-static GPtrArray *
-imap_get_subfolder_names (CamelFolder *folder, CamelException *ex)
-{
- CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder);
- CamelStore *store = CAMEL_STORE (folder->parent_store);
- CamelURL *url = CAMEL_SERVICE (store)->url;
- GPtrArray *listing;
- gint status;
- gchar *result, *folder_path;
-
- g_return_val_if_fail (folder != NULL, g_ptr_array_new());
-
- if (imap_folder->count != -1)
- return g_ptr_array_new ();
-
- if (url && url->path) {
- if (!strcmp (folder->full_name, "INBOX"))
- folder_path = g_strdup (url->path + 1);
- else
- folder_path = g_strdup_printf ("%s/%s", url->path + 1, folder->full_name);
- } else {
- folder_path = g_strdup (folder->full_name);
- }
-
- status = camel_imap_command_extended (CAMEL_IMAP_STORE (folder->parent_store), folder,
- &result, "LIST \"\" \"%s%s\"", folder_path,
- *folder_path ? "/*" : "*");
-
- if (status != CAMEL_IMAP_OK) {
- CamelService *service = CAMEL_SERVICE (folder->parent_store);
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- "Could not get subfolder listing from IMAP "
- "server %s: %s.", service->url->host,
- status == CAMEL_IMAP_ERR ? result :
- "Unknown error");
- g_free (result);
- g_free (folder_path);
- return g_ptr_array_new ();
- }
-
- /* parse out the subfolders */
- listing = g_ptr_array_new ();
- if (result) {
- char *ptr = result;
-
- while (ptr && *ptr == '*') {
- gchar *flags, *sep, *folder, *buf, *end, *f;
- gboolean ret;
-
- for (end = ptr; *end && *end != '\n'; end++);
- buf = g_strndup (ptr, (gint)(end - ptr));
- ptr = end;
-
- ret = imap_parse_subfolder_line (buf, &flags, &sep, &folder);
- g_free (buf);
-
- if (!ret || (flags && strstr (flags, "NoSelect"))) {
- g_free (flags);
- g_free (sep);
- g_free (folder);
-
- if (*ptr == '\n')
- ptr++;
-
- continue;
- }
- g_free (flags);
-
- /* chop out the folder prefix */
- if (*folder_path && !strncmp (folder, folder_path, strlen (folder_path))) {
- f = folder + strlen (folder_path) + 1;
- memmove (folder, f, strlen (f) + 1);
- }
- printf ("adding folder: %s\n", folder);
-
- g_ptr_array_add (listing, folder);
-
- g_free (sep); /* TODO: decide if we really need dir_sep */
-
- if (*ptr == '\n')
- ptr++;
- }
- }
- g_free (result);
- g_free (folder_path);
-
- return listing;
-}
-
-static void
-imap_delete_message_by_uid (CamelFolder *folder, const gchar *uid, CamelException *ex)
-{
- CamelMessageInfo *info;
-
- if (!(info = (CamelMessageInfo *)imap_summary_get_by_uid (folder, uid))) {
- CamelService *service = CAMEL_SERVICE (folder->parent_store);
-
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- "Could not set flags for message %s on IMAP server %s: %s",
- uid, service->url->host, "Unknown error");
- return;
- }
-
- info->flags |= CAMEL_MESSAGE_DELETED | CAMEL_MESSAGE_FOLDER_FLAGGED;
-}
-
-static CamelMimeMessage *
-imap_get_message_by_uid (CamelFolder *folder, const gchar *uid, CamelException *ex)
-{
- CamelStream *msgstream;
- /*CamelStreamFilter *f_stream;*/
- /*CamelMimeFilter *filter;*/
- CamelMimeMessage *msg;
- /*CamelMimePart *part;*/
- gchar *result, *header, *body, *mesg, *p;
- int id, status, part_len;
-
- status = camel_imap_command_extended (CAMEL_IMAP_STORE (folder->parent_store), folder,
- &result, "UID FETCH %s BODY.PEEK[HEADER]", uid);
-
- if (!result || status != CAMEL_IMAP_OK) {
- CamelService *service = CAMEL_SERVICE (folder->parent_store);
-
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- "Could not fetch message %s on IMAP server %s: %s",
- uid, service->url->host,
- status == CAMEL_IMAP_ERR ? result :
- "Unknown error");
- g_free (result);
- return camel_mime_message_new ();
- }
-
- for (p = result; *p && *p != '{' && *p != '\n'; p++);
- if (*p != '{') {
- g_free (result);
- return camel_mime_message_new ();
- }
-
- part_len = atoi (p + 1);
- for ( ; *p && *p != '\n'; p++);
- if (*p != '\n') {
- g_free (result);
- return camel_mime_message_new ();
- }
-
- header = g_strndup (p, part_len);
- for (p = header + strlen (header) - 1; p > header && *p != ')'; p--);
- if (p != header)
- *p = '\0';
- g_free (result);
- printf ("*** We got the header ***\n");
-
- status = camel_imap_command_extended (CAMEL_IMAP_STORE (folder->parent_store), folder,
- &result, "UID FETCH %s BODY[TEXT]", uid);
-
- if (!result || status != CAMEL_IMAP_OK) {
- CamelService *service = CAMEL_SERVICE (folder->parent_store);
-
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- "Could not fetch message %s on IMAP server %s: %s",
- uid, service->url->host,
- status == CAMEL_IMAP_ERR ? result :
- "Unknown error");
- g_free (result);
- g_free (header);
- return camel_mime_message_new ();
- }
-
- for (p = result; *p && *p != '{' && *p != '\n'; p++);
- if (*p != '{') {
- g_free (result);
- g_free (header);
- return camel_mime_message_new ();
- }
-
- part_len = atoi (p + 1);
- for ( ; *p && *p != '\n'; p++);
- if (*p != '\n') {
- g_free (result);
- g_free (header);
- return camel_mime_message_new ();
- }
-
- body = g_strndup (p, part_len);
- for (p = body + strlen (body) - 1; p > body && *p != ')'; p--);
- *p = '\0';
- g_free (result);
- printf ("*** We got the body ***\n");
-
- mesg = g_strdup_printf ("%s%s", header, body);
- g_free (header);
- g_free (body);
- printf ("*** We got the mesg ***\n");
-
- fprintf (stderr, "Message:\n%s\n", mesg);
-
- msgstream = camel_stream_mem_new_with_buffer (mesg, strlen (mesg) + 1);
-#if 0
- f_stream = camel_stream_filter_new_with_stream (msgstream);
- filter = camel_mime_filter_crlf_new (CAMEL_MIME_FILTER_CRLF_DECODE, CAMEL_MIME_FILTER_CRLF_MODE_CRLF_DOTS);
- id = camel_stream_filter_add (f_stream, CAMEL_MIME_FILTER (filter));
-#endif
- msg = camel_mime_message_new ();
- printf ("*** We created the camel_mime_message ***\n");
-
- camel_data_wrapper_construct_from_stream (CAMEL_DATA_WRAPPER (msg), msgstream);
-#if 0
- camel_stream_filter_remove (f_stream, id);
- camel_stream_close (CAMEL_STREAM (f_stream));
-#endif
- gtk_object_unref (GTK_OBJECT (msgstream));
- /*gtk_object_unref (GTK_OBJECT (f_stream));*/
-
- printf ("*** We're returning... ***\n");
-
- return msg;
-
-#if 0
- CamelStream *imap_stream;
- CamelStream *msgstream;
- CamelStreamFilter *f_stream; /* will be used later w/ crlf filter */
- CamelMimeFilter *filter; /* crlf/dot filter */
- CamelMimeMessage *msg;
- CamelMimePart *part;
- CamelDataWrapper *cdw;
- gchar *cmdbuf;
- int id;
-
- /* TODO: fetch the correct part, get rid of the hard-coded stuff */
- cmdbuf = g_strdup_printf ("UID FETCH %s BODY[TEXT]", uid);
- imap_stream = camel_imap_stream_new (CAMEL_IMAP_FOLDER (folder), cmdbuf);
- g_free (cmdbuf);
-
-
- /* Temp hack - basically we read in the entire message instead of getting a part as it's needed */
- msgstream = camel_stream_mem_new ();
- camel_stream_write_to_stream (CAMEL_STREAM (imap_stream), msgstream);
- gtk_object_unref (GTK_OBJECT (imap_stream));
-
- f_stream = camel_stream_filter_new_with_stream (msgstream);
- filter = camel_mime_filter_crlf_new (CAMEL_MIME_FILTER_CRLF_DECODE, CAMEL_MIME_FILTER_CRLF_MODE_CRLF_DOTS);
- id = camel_stream_filter_add (f_stream, CAMEL_MIME_FILTER (filter));
-
- msg = camel_mime_message_new ();
-
- /*cdw = camel_data_wrapper_new ();*/
- /*camel_data_wrapper_construct_from_stream (cdw, CAMEL_STREAM (f_stream));*/
- camel_data_wrapper_construct_from_stream (CAMEL_DATA_WRAPPER (msg), CAMEL_STREAM (f_stream));
-
- camel_stream_filter_remove (f_stream, id);
- camel_stream_close (CAMEL_STREAM (f_stream));
- gtk_object_unref (GTK_OBJECT (msgstream));
- gtk_object_unref (GTK_OBJECT (f_stream));
-
- /*camel_data_wrapper_set_mime_type (cdw, "text/plain");*/
-
- /*camel_medium_set_content_object (CAMEL_MEDIUM (msg), CAMEL_DATA_WRAPPER (cdw));*/
- /*gtk_object_unref (GTK_OBJECT (cdw));*/
-
- return msg;
-#endif
-}
-
-/* This probably shouldn't go here...but it will for now */
-static gchar *
-get_header_field (gchar *header, gchar *field)
-{
- gchar *part, *index, *p, *q;
-
- index = strstrcase (header, field);
- if (index == NULL)
- return NULL;
-
- p = index + strlen (field) + 1;
- for (q = p; *q; q++)
- if (*q == '\n' && (*(q + 1) != ' ' || *(q + 1) != '\t'))
- break;
-
- part = g_strndup (p, (gint)(q - p));
-
- /* it may be wrapped on multiple lines, so lets strip out \n's */
- for (p = part; *p; ) {
- if (*p == '\r' || *p == '\n')
- memmove(p, p + 1, strlen (p) - 1);
- else
- p++;
- }
-
- return part;
-}
-
-GPtrArray *
-imap_get_summary (CamelFolder *folder, CamelException *ex)
-{
- CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder);
- GPtrArray *array = NULL;
- CamelMessageInfo *info;
- gint num, i = 0, status = 0;
- char *result, *datestr, *p, *q;
-
- if (imap_folder->summary)
- return imap_folder->summary;
-
- num = imap_get_message_count (folder, ex);
-
- array = g_ptr_array_new ();
-
- for (i = 1; i <= num; i++) {
- status = camel_imap_command_extended (CAMEL_IMAP_STORE (folder->parent_store), folder,
- &result, "FETCH %d BODY.PEEK[HEADER]", i);
-
- if (status != CAMEL_IMAP_OK) {
- CamelService *service = CAMEL_SERVICE (folder->parent_store);
-
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- "Could not get summary for %s on IMAP server %s: %s",
- folder->full_name, service->url->host,
- status == CAMEL_IMAP_ERR ? result :
- "Unknown error");
- g_free (result);
- break;
- }
-
- info = g_malloc0 (sizeof (CamelMessageInfo));
- info->subject = get_header_field (result, "\nSubject:");
- info->to = get_header_field (result, "\nTo:");
- info->from = get_header_field (result, "\nFrom:");
-
- datestr = get_header_field (result, "\nDate:");
- info->date_sent = header_decode_date (datestr, NULL);
- g_free (datestr);
- g_free (result);
-
- /* now to get the UID */
- status = camel_imap_command_extended (CAMEL_IMAP_STORE (folder->parent_store), folder,
- &result, "FETCH %d UID", i);
-
- if (status != CAMEL_IMAP_OK) {
- CamelService *service = CAMEL_SERVICE (folder->parent_store);
-
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- "Could not get summary for %s on IMAP server %s: %s",
- folder->full_name, service->url->host,
- status == CAMEL_IMAP_ERR ? result :
- "Unknown error");
- g_free (result);
-
- g_free (info->subject);
- g_free (info->to);
- g_free (info->from);
- g_free (info);
- info = NULL;
-
- break;
- }
-
- if (!result || *result != '*') {
- g_free (result);
- fprintf (stderr, "Warning: UID for message %d not found\n", i);
-
- g_free (info->subject);
- g_free (info->to);
- g_free (info->from);
- g_free (info);
- info = NULL;
-
- break;
- }
-
- p = strchr (result, '(');
- if (!p || strncasecmp (p + 1, "UID", 3)) {
- g_free (result);
- fprintf (stderr, "Warning: UID for message %d not found\n", i);
-
- g_free (info->subject);
- g_free (info->to);
- g_free (info->from);
- g_free (info);
- info = NULL;
-
- break;
- }
-
- for (p += 4; *p && (*p < '0' || *p > '9'); p++); /* advance to <uid> */
- for (q = p; *q && *q != ')' && *q != ' '; q++); /* find the end of the <uid> */
- info->uid = g_strndup (p, (gint)(q - p));
- printf ("*** info->uid = %s\n", info->uid);
- g_free (result);
-
- /* now to get the flags */
- status = camel_imap_command_extended (CAMEL_IMAP_STORE (folder->parent_store), folder,
- &result, "FETCH %d FLAGS", i);
-
- if (status != CAMEL_IMAP_OK) {
- CamelService *service = CAMEL_SERVICE (folder->parent_store);
-
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- "Could not get summary for %s on IMAP server %s: %s",
- folder->full_name, service->url->host,
- status == CAMEL_IMAP_ERR ? result :
- "Unknown error");
- g_free (result);
-
- g_free (info->subject);
- g_free (info->to);
- g_free (info->from);
- g_free (info);
- info = NULL;
-
- break;
- }
-
- if (!result || *result != '*') {
- g_free (result);
- fprintf (stderr, "Warning: FLAGS for message %d not found\n", i);
-
- g_free (info->subject);
- g_free (info->to);
- g_free (info->from);
- g_free (info);
- info = NULL;
-
- break;
- }
-
- p = strchr (result, '(') + 1;
- if (strncasecmp (p, "FLAGS", 5)) {
- g_free (result);
- fprintf (stderr, "Warning: FLAGS for message %d not found\n", i);
-
- g_free (info->subject);
- g_free (info->to);
- g_free (info->from);
- g_free (info);
- info = NULL;
-
- break;
- }
-
- /* now we gotta parse for the flags */
- info->flags = 0;
- if (strstr (p, "\\Seen"))
- info->flags |= CAMEL_MESSAGE_SEEN;
- if (strstr (p, "\\Answered"))
- info->flags |= CAMEL_MESSAGE_ANSWERED;
- if (strstr (p, "\\Flagged"))
- info->flags |= CAMEL_MESSAGE_FLAGGED;
- if (strstr (p, "\\Deleted"))
- info->flags |= CAMEL_MESSAGE_DELETED;
- if (strstr (p, "\\Draft"))
- info->flags |= CAMEL_MESSAGE_DRAFT;
-
- g_free (result);
-
- g_ptr_array_add (array, info);
- }
-
- imap_folder->summary = array;
-
- return array;
-}
-
-void
-imap_free_summary (CamelFolder *folder, GPtrArray *array)
-{
- /* no-op */
- return;
-}
-
-/* get a single message info, by uid */
-static const CamelMessageInfo *
-imap_summary_get_by_uid (CamelFolder *folder, const char *uid)
-{
- CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder);
- CamelMessageInfo *info = NULL;
- char *result, *datestr, *p;
- int status;
-
- /* lets first check to see if we have the message info cached */
- if (imap_folder->summary) {
- int max, i;
-
- max = imap_folder->summary->len;
- for (i = 0; i < max; i++) {
- info = g_ptr_array_index (imap_folder->summary, i);
- if (!strcmp(info->uid, uid))
- return info;
- }
- }
-
- /* we don't have a cached copy, so fetch it */
-
- status = camel_imap_command_extended (CAMEL_IMAP_STORE (folder->parent_store), folder,
- &result, "UID FETCH %s BODY.PEEK[HEADER]", uid);
-
- if (status != CAMEL_IMAP_OK) {
- g_free (result);
- return NULL;
- }
-
- info = g_malloc0 (sizeof (CamelMessageInfo));
- info->subject = get_header_field (result, "\nSubject:");
- info->to = get_header_field (result, "\nTo:");
- info->from = get_header_field (result, "\nFrom:");
-
- datestr = get_header_field (result, "\nDate:");
- info->date_sent = header_decode_date (datestr, NULL);
- g_free (datestr);
-
- info->uid = g_strdup (uid);
- g_free (result);
-
- /* now to get the flags */
- status = camel_imap_command_extended (CAMEL_IMAP_STORE (folder->parent_store), folder,
- &result, "UID FETCH %s FLAGS", uid);
-
- if (status != CAMEL_IMAP_OK) {
- g_free (result);
- fprintf (stderr, "Warning: Error getting FLAGS for message %s\n", uid);
-
- return info; /* I guess we should return what we got so far? */
- }
-
- if (!result || *result != '*') {
- g_free (result);
- fprintf (stderr, "Warning: FLAGS for message %s not found\n", uid);
-
- return info; /* I guess we should return what we got so far? */
- }
-
- p = strchr (result, '(') + 1;
- if (strncasecmp (p, "FLAGS", 5)) {
- g_free (result);
- fprintf (stderr, "Warning: FLAGS for message %s not found\n", uid);
-
- return info; /* I guess we should return what we got so far? */
- }
-
- /* now we gotta parse for the flags */
- info->flags = 0;
- if (strstr (p, "\\Seen"))
- info->flags |= CAMEL_MESSAGE_SEEN;
- if (strstr (p, "\\Answered"))
- info->flags |= CAMEL_MESSAGE_ANSWERED;
- if (strstr (p, "\\Flagged"))
- info->flags |= CAMEL_MESSAGE_FLAGGED;
- if (strstr (p, "\\Deleted"))
- info->flags |= CAMEL_MESSAGE_DELETED;
- if (strstr (p, "\\Draft"))
- info->flags |= CAMEL_MESSAGE_DRAFT;
-
- g_free (result);
-
- /* since we didn't have it cached, lets add it to our cache */
- if (imap_folder->summary) {
- g_ptr_array_add (imap_folder->summary, info);
- } else {
- imap_folder->summary = g_ptr_array_new ();
- g_ptr_array_add (imap_folder->summary, info);
- }
-
- return info;
-}
-
-static GList *
-imap_search_by_expression (CamelFolder *folder, const char *expression, CamelException *ex)
-{
- return NULL;
-#if 0
- /* NOTE: This is experimental code... */
- CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder);
- char *result;
- int status;
-
- if (!imap_folder->has_search_capability)
- return NULL;
-
- status = camel_imap_command_extended (CAMEL_IMAP_STORE (folder->parent_store), folder,
- &result, "SEARCH %s", expression);
-
- if (status != CAMEL_IMAP_OK) {
- CamelService *service = CAMEL_SERVICE (folder->parent_store);
-
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- "Could not get summary for %s on IMAP server %s: %s",
- folder->full_name, service->url->host,
- status == CAMEL_IMAP_ERR ? result :
- "Unknown error");
- g_free (result);
- return NULL;
- }
-
- /* now to parse @result */
-#endif
-}
-
-static guint32
-imap_get_permanent_flags (CamelFolder *folder, CamelException *ex)
-{
- /* return permamnant flags */
- return folder->permanent_flags;
-}
-
-static guint32
-imap_get_message_flags (CamelFolder *folder, const char *uid, CamelException *ex)
-{
- CamelMessageInfo *info;
-
- if (!(info = (CamelMessageInfo *)imap_summary_get_by_uid (folder, uid))) {
- CamelService *service = CAMEL_SERVICE (folder->parent_store);
-
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- "Could not get flags for message %s on IMAP server %s: %s",
- uid, service->url->host, "Unknown error");
- return 0;
- }
-
- return info->flags;
-}
-
-static void
-imap_set_message_flags (CamelFolder *folder, const char *uid, guint32 flags, guint32 set, CamelException *ex)
-{
- CamelMessageInfo *info;
-
- if (!(info = (CamelMessageInfo *)imap_summary_get_by_uid (folder, uid))) {
- CamelService *service = CAMEL_SERVICE (folder->parent_store);
-
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- "Could not set flags for message %s on IMAP server %s: %s",
- uid, service->url->host, "Unknown error");
- return;
- }
-
- info->flags = (info->flags & ~flags) | (set & flags) | CAMEL_MESSAGE_FOLDER_FLAGGED;
-}
-
-static gboolean
-imap_get_message_user_flag (CamelFolder *folder, const char *uid, const char *name, CamelException *ex)
-{
- return FALSE;
-}
-
-static void
-imap_set_message_user_flag (CamelFolder *folder, const char *uid, const char *name, gboolean value, CamelException *ex)
-{
- return;
-}
diff --git a/camel/providers/imap/camel-imap-folder.h b/camel/providers/imap/camel-imap-folder.h
deleted file mode 100644
index 17f6d505d2..0000000000
--- a/camel/providers/imap/camel-imap-folder.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* camel-imap-folder.h : Abstract class for an imap folder */
-
-/*
- * Author:
- * Jeffrey Stedfast <fejj@helixcode.com>
- *
- * 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_IMAP_FOLDER_H
-#define CAMEL_IMAP_FOLDER_H 1
-
-
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* __cplusplus }*/
-
-#include <gtk/gtk.h>
-#include "camel-folder.h"
-#include <camel/camel-folder-search.h>
-
-#define CAMEL_IMAP_FOLDER_TYPE (camel_imap_folder_get_type ())
-#define CAMEL_IMAP_FOLDER(obj) (GTK_CHECK_CAST((obj), CAMEL_IMAP_FOLDER_TYPE, CamelImapFolder))
-#define CAMEL_IMAP_FOLDER_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_IMAP_FOLDER_TYPE, CamelImapFolderClass))
-#define IS_CAMEL_IMAP_FOLDER(o) (GTK_CHECK_TYPE((o), CAMEL_IMAP_FOLDER_TYPE))
-
-typedef struct {
- CamelFolder parent_object;
-
- CamelFolderSearch *search; /* used to run searches */
- GPtrArray *summary;
- gint count;
-} CamelImapFolder;
-
-
-typedef struct {
- CamelFolderClass parent_class;
-
- /* Virtual methods */
-
-} CamelImapFolderClass;
-
-
-/* public methods */
-CamelFolder *camel_imap_folder_new (CamelStore *parent, char *folder_name,
- CamelException *ex);
-void camel_imap_folder_set_namespace (CamelFolder *folder, gchar *namespace);
-
-/* Standard Gtk function */
-GtkType camel_imap_folder_get_type (void);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* CAMEL_IMAP_FOLDER_H */
diff --git a/camel/providers/imap/camel-imap-provider.c b/camel/providers/imap/camel-imap-provider.c
deleted file mode 100644
index b9d8c74847..0000000000
--- a/camel/providers/imap/camel-imap-provider.c
+++ /dev/null
@@ -1,109 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* camel-imap-provider.c: imap provider registration code */
-
-/*
- * Authors: Jeffrey Stedfast <fejj@helixcode.com>
- *
- * Copyright 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 Street #330, Boston, MA 02111-1307, USA.
- *
- */
-
-
-#include "config.h"
-#include "camel-imap-store.h"
-#include "camel-provider.h"
-#include "camel-session.h"
-#include "camel-url.h"
-
-static void add_hash (guint *hash, char *s);
-static guint imap_url_hash (gconstpointer key);
-static gint check_equal (char *s1, char *s2);
-static gint imap_url_equal (gconstpointer a, gconstpointer b);
-
-static CamelProvider imap_provider = {
- "imap",
- "IMAPv4",
-
- "For reading and storing mail on IMAP servers.",
-
- "mail",
-
- 0,
-
- { 0, 0 },
-
- NULL
-};
-
-void
-camel_provider_module_init (CamelSession *session)
-{
- imap_provider.object_types[CAMEL_PROVIDER_STORE] =
- camel_imap_store_get_type();
-
- imap_provider.service_cache = g_hash_table_new (imap_url_hash, imap_url_equal);
-
- camel_session_register_provider (session, &imap_provider);
-}
-
-static void
-add_hash (guint *hash, char *s)
-{
- if (s)
- *hash ^= g_str_hash(s);
-}
-
-static guint
-imap_url_hash (gconstpointer key)
-{
- const CamelURL *u = (CamelURL *)key;
- guint hash = 0;
-
- add_hash (&hash, u->user);
- add_hash (&hash, u->authmech);
- add_hash (&hash, u->host);
- hash ^= u->port;
-
- return hash;
-}
-
-static gint
-check_equal (char *s1, char *s2)
-{
- if (s1 == NULL) {
- if (s2 == NULL)
- return TRUE;
- else
- return FALSE;
- }
-
- if (s2 == NULL)
- return FALSE;
-
- return strcmp (s1, s2) == 0;
-}
-
-static gint
-imap_url_equal (gconstpointer a, gconstpointer b)
-{
- const CamelURL *u1 = a, *u2 = b;
-
- return check_equal (u1->user, u2->user)
- && check_equal (u1->authmech, u2->authmech)
- && check_equal (u1->host, u2->host)
- && u1->port == u2->port;
-}
diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c
deleted file mode 100644
index f178ad8390..0000000000
--- a/camel/providers/imap/camel-imap-store.c
+++ /dev/null
@@ -1,672 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* camel-imap-store.c : class for an imap store */
-
-/*
- * Authors: Jeffrey Stedfast <fejj@helixcode.com>
- *
- * Copyright 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 Street #330, Boston, MA 02111-1307, USA.
- *
- */
-
-
-#include <config.h>
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <errno.h>
-
-
-#include "camel-imap-store.h"
-#include "camel-imap-folder.h"
-#include "camel-folder.h"
-#include "camel-exception.h"
-#include "camel-session.h"
-#include "camel-stream.h"
-#include "camel-stream-buffer.h"
-#include "camel-stream-fs.h"
-#include "camel-url.h"
-
-/* Specified in RFC 2060 */
-#define IMAP_PORT 143
-
-static CamelServiceClass *service_class = NULL;
-
-static void finalize (GtkObject *object);
-static gboolean imap_create (CamelFolder *folder, CamelException *ex);
-static gboolean imap_connect (CamelService *service, CamelException *ex);
-static gboolean imap_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, gboolean create,
- CamelException *ex);
-static char *get_folder_name (CamelStore *store, const char *folder_name, CamelException *ex);
-static int camel_imap_status (char *cmdid, char *respbuf);
-
-static void
-camel_imap_store_class_init (CamelImapStoreClass *camel_imap_store_class)
-{
- /* virtual method overload */
- GtkObjectClass *object_class =
- GTK_OBJECT_CLASS (camel_imap_store_class);
- CamelServiceClass *camel_service_class =
- CAMEL_SERVICE_CLASS (camel_imap_store_class);
- CamelStoreClass *camel_store_class =
- CAMEL_STORE_CLASS (camel_imap_store_class);
-
- service_class = gtk_type_class (camel_service_get_type ());
-
- /* virtual method overload */
- object_class->finalize = finalize;
-
- camel_service_class->connect = imap_connect;
- camel_service_class->disconnect = imap_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;
-}
-
-static void
-camel_imap_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_imap_store_get_type (void)
-{
- static GtkType camel_imap_store_type = 0;
-
- if (!camel_imap_store_type) {
- GtkTypeInfo camel_imap_store_info =
- {
- "CamelImapStore",
- sizeof (CamelImapStore),
- sizeof (CamelImapStoreClass),
- (GtkClassInitFunc) camel_imap_store_class_init,
- (GtkObjectInitFunc) camel_imap_store_init,
- /* reserved_1 */ NULL,
- /* reserved_2 */ NULL,
- (GtkClassInitFunc) NULL,
- };
-
- camel_imap_store_type = gtk_type_unique (CAMEL_STORE_TYPE, &camel_imap_store_info);
- }
-
- return camel_imap_store_type;
-}
-
-static void
-finalize (GtkObject *object)
-{
- CamelException ex;
-
- camel_exception_init (&ex);
- imap_disconnect (CAMEL_SERVICE (object), &ex);
- camel_exception_clear (&ex);
-}
-
-static CamelServiceAuthType password_authtype = {
- "Password",
-
- "This option will connect to the IMAP server using a "
- "plaintext password.",
-
- "",
- TRUE
-};
-
-static gboolean
-try_connect (CamelService *service, CamelException *ex)
-{
- struct hostent *h;
- struct sockaddr_in sin;
- gint fd;
-
- 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 : IMAP_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) {
-
- /* We don't want to set a CamelException here */
-
- 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;
-
-
- if (service->url) {
- passwd = try_connect (service, ex);
- if (camel_exception_get_id (ex) != CAMEL_EXCEPTION_NONE)
- return NULL;
- }
-
- if (passwd)
- ret = g_list_append (ret, &password_authtype);
-
- if (!ret) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- "Could not connect to IMAP server on "
- "%s.", service->url->host);
- }
-
- return ret;
-}
-
-static void
-free_auth_types (CamelService *service, GList *authtypes)
-{
- g_list_free (authtypes);
-}
-
-static gboolean
-imap_connect (CamelService *service, CamelException *ex)
-{
- struct hostent *h;
- struct sockaddr_in sin;
- gint fd, status;
- gchar *buf, *msg;
- CamelImapStore *store = CAMEL_IMAP_STORE (service);
-
-
- h = camel_service_gethost (service, ex);
- if (!h)
- return FALSE;
-
- if (!service->url->authmech && !service->url->passwd) {
- gchar *prompt = g_strdup_printf ("Please enter the IMAP password for %s@%s",
- service->url->user, h->h_name);
- service->url->passwd =
- camel_session_query_authenticator (camel_service_get_session (service),
- CAMEL_AUTHENTICATOR_ASK, 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 = htons(service->url->port);
- else
- sin.sin_port = htons(IMAP_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);
- store->command = 0;
-
- /* Read the greeting, 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 IMAP "
- "server: %s",
- camel_exception_get_description (ex));
- gtk_object_unref (GTK_OBJECT (store->ostream));
- gtk_object_unref (GTK_OBJECT (store->istream));
- return FALSE;
- }
- g_free (buf);
-
- status = camel_imap_command(store, NULL, &msg, "LOGIN \"%s\" \"%s\"",
- service->url->user,
- service->url->passwd);
-
- if (status != CAMEL_IMAP_OK) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
- "Unable to authenticate to IMAP "
- "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;
- } else {
- g_message ("IMAP Service sucessfully authenticated user %s", service->url->user);
- }
-
- service_class->connect (service, ex);
- return TRUE;
-}
-
-static gboolean
-imap_disconnect (CamelService *service, CamelException *ex)
-{
- CamelImapStore *store = CAMEL_IMAP_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;
-}
-
-const gchar *
-camel_imap_store_get_toplevel_dir (CamelImapStore *store)
-{
- CamelURL *url = CAMEL_SERVICE (store)->url;
-
- g_assert (url != NULL);
- return url->path;
-}
-
-static gboolean
-imap_folder_exists (CamelFolder *folder)
-{
- CamelStore *store = CAMEL_STORE (folder->parent_store);
- CamelURL *url = CAMEL_SERVICE (store)->url;
- gchar *result, *folder_path;
- gint status;
-
- if (url && url->path && *(url->path + 1) && strcmp (folder->full_name, "INBOX"))
- folder_path = g_strdup_printf ("%s/%s", url->path + 1, folder->full_name);
- else
- folder_path = g_strdup (folder->full_name);
-
- status = camel_imap_command_extended (CAMEL_IMAP_STORE (folder->parent_store), NULL,
- &result, "EXAMINE %s", folder_path);
-
- if (status != CAMEL_IMAP_OK) {
- g_free (result);
- g_free (folder_path);
- return FALSE;
- }
- g_free (folder_path);
- g_free (result);
-
- return TRUE;
-}
-
-static gboolean
-imap_create (CamelFolder *folder, CamelException *ex)
-{
- CamelStore *store = CAMEL_STORE (folder->parent_store);
- CamelURL *url = CAMEL_SERVICE (store)->url;
- gchar *result, *folder_path;
- gint status;
-
- g_return_val_if_fail (folder != NULL, FALSE);
-
- if (!(folder->full_name || folder->name)) {
- camel_exception_set (ex, CAMEL_EXCEPTION_FOLDER_INVALID,
- "invalid folder path. Use set_name ?");
- return FALSE;
- }
-
- if (!strcmp (folder->full_name, "INBOX"))
- return TRUE;
-
- if (imap_folder_exists (folder))
- return TRUE;
-
- /* create the directory for the subfolder */
- if (url && url->path && *(url->path + 1) && strcmp (folder->full_name, "INBOX"))
- folder_path = g_strdup_printf ("%s/%s", url->path + 1, folder->full_name);
- else
- folder_path = g_strdup (folder->full_name);
-
- status = camel_imap_command_extended (CAMEL_IMAP_STORE (folder->parent_store), NULL,
- &result, "CREATE %s", folder_path);
-
- if (status != CAMEL_IMAP_OK) {
- CamelService *service = CAMEL_SERVICE (folder->parent_store);
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- "Could not CREATE %s on IMAP server %s: %s.",
- folder_path, service->url->host,
- status == CAMEL_IMAP_ERR ? result :
- "Unknown error");
- g_free (result);
- g_free (folder_path);
- return FALSE;
- }
- g_free (folder_path);
- g_free (result);
-
- return TRUE;
-}
-
-static CamelFolder *
-get_folder (CamelStore *store, const char *folder_name, gboolean create, CamelException *ex)
-{
- CamelFolder *new_folder;
- char *folder_path;
-
- g_return_val_if_fail (store != NULL, NULL);
- g_return_val_if_fail (folder_name != NULL, NULL);
-
- if (!strcmp (folder_name, "/"))
- folder_path = g_strdup ("INBOX");
- else
- folder_path = g_strdup (folder_name);
-
- new_folder = camel_imap_folder_new (store, folder_path, ex);
-
- if (create && !imap_create (new_folder, ex)) {
- return NULL;
- }
-
- return new_folder;
-}
-
-static gchar *
-get_folder_name (CamelStore *store, const char *folder_name, CamelException *ex)
-{
- return g_strdup (folder_name);
-}
-
-static int
-camel_imap_status (char *cmdid, char *respbuf)
-{
- char *retcode;
-
- if (respbuf) {
- retcode = strstr (respbuf, cmdid);
- if (retcode) {
- retcode += strlen (cmdid) + 1;
-
- if (!strncmp (retcode, "OK", 2))
- return CAMEL_IMAP_OK;
- else if (!strncmp (retcode, "NO", 2))
- return CAMEL_IMAP_ERR;
- }
- }
-
- return CAMEL_IMAP_FAIL;
-}
-
-/**
- * camel_imap_command: Send a command to a IMAP server.
- * @store: the IMAP 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 IMAP 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_imap_command
- * will set it to point to an buffer containing the rest of the
- * response from the IMAP 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_IMAP_OK (command executed successfully),
- * CAMEL_IMAP_ERR (command encounted an error), or CAMEL_IMAP_FAIL
- * (a protocol-level error occurred, and Camel is uncertain of the
- * result of the command.)
- **/
-gint
-camel_imap_command (CamelImapStore *store, CamelFolder *folder, char **ret, char *fmt, ...)
-{
- CamelURL *url = CAMEL_SERVICE (store)->url;
- gchar *cmdbuf, *respbuf;
- gchar *cmdid;
- va_list ap;
- gint status = CAMEL_IMAP_OK;
-
- if (folder && store->current_folder != folder && strncmp (fmt, "STATUS", 6) &&
- strncmp (fmt, "CREATE", 5) && strcmp (fmt, "CAPABILITY")) {
- /* We need to select the correct mailbox first */
- char *r, *folder_path;
- int s;
-
- if (url && url->path && strcmp (folder->full_name, "INBOX"))
- folder_path = g_strdup_printf ("%s/%s", url->path + 1, folder->full_name);
- else
- folder_path = g_strdup (folder->full_name);
-
- s = camel_imap_command_extended (store, folder, &r, "SELECT %s", folder_path);
- g_free (folder_path);
- if (s != CAMEL_IMAP_OK) {
- *ret = r;
- return s;
- } else {
- /* parse the read-write mode */
-#if 0
- char *p;
-
- p = strstr (result, "\n");
- while (p) {
- if (*(p + 1) == '*')
- p = strstr (p, "\n");
- else
- break;
- }
-
- if (p) {
- if (strstrcase (p, "READ-WRITE"))
- mode =
- }
-#endif
- }
-
- store->current_folder = folder;
- }
-
- /* create the command */
- cmdid = g_strdup_printf ("A%.5d", store->command++);
- va_start (ap, fmt);
- cmdbuf = g_strdup_vprintf (fmt, ap);
- va_end (ap);
-
- fprintf (stderr, "sending : %s %s\r\n", cmdid, cmdbuf);
- fflush (stderr);
-
- if (camel_stream_printf (store->ostream, "%s %s\r\n", cmdid, cmdbuf) == -1) {
- g_free (cmdbuf);
- g_free (cmdid);
- if (*ret)
- *ret = g_strdup (strerror (errno));
- return CAMEL_IMAP_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_IMAP_FAIL;
- }
-
- fprintf (stderr, "received: %s\n", respbuf ? respbuf : "(null)");
- fflush (stderr);
-
- status = camel_imap_status (cmdid, respbuf);
- g_free (cmdid);
-
- if (ret) {
- if (status != CAMEL_IMAP_FAIL) {
- *ret = strchr (respbuf, ' ');
- if (*ret)
- *ret = g_strdup (*ret + 1);
- } else
- *ret = NULL;
- }
- g_free (respbuf);
-
- return status;
-}
-
-/**
- * camel_imap_command_extended: Send a command to a IMAP server and get
- * a multi-line response.
- * @store: the IMAP 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 IMAP store specified by @store. It then
- * reads the server's response and parses out the status code.
- * Camel_imap_command_extended will set it to point to a buffer containing the
- * response from the IMAP server. (If @ret was passed but there was The caller
- * must free this buffer when it is done with it.
- *
- * This command gets the additional data returned by "multi-line" IMAP
- * commands, such as SELECT, LIST, LSUB, and various other commands.
- * The returned data is un-byte-stuffed, and has lines termined by
- * newlines rather than CR/LF pairs.
- *
- * Return value: one of CAMEL_IMAP_OK (command executed successfully),
- * CAMEL_IMAP_ERR (command encounted an error), or CAMEL_IMAP_FAIL
- * (a protocol-level error occurred, and Camel is uncertain of the
- * result of the command.)
- **/
-
-gint
-camel_imap_command_extended (CamelImapStore *store, CamelFolder *folder, char **ret, char *fmt, ...)
-{
- CamelURL *url = CAMEL_SERVICE (CAMEL_STORE (store))->url;
- CamelStreamBuffer *stream = CAMEL_STREAM_BUFFER (store->istream);
- GPtrArray *data;
- gchar *cmdid, *cmdbuf, *respbuf;
- va_list app;
- gint status = CAMEL_IMAP_OK;
-
- if (folder && store->current_folder != folder && strncmp (fmt, "SELECT", 6) &&
- strncmp (fmt, "STATUS", 6) && strncmp (fmt, "CREATE", 5) && strcmp (fmt, "CAPABILITY")) {
- /* We need to select the correct mailbox first */
- char *r, *folder_path;
- int s;
-
- if (url && url->path && strcmp (folder->full_name, "INBOX"))
- folder_path = g_strdup_printf ("%s/%s", url->path + 1, folder->full_name);
- else
- folder_path = g_strdup (folder->full_name);
-
- s = camel_imap_command_extended (store, folder, &r, "SELECT %s", folder_path);
- g_free (folder_path);
- if (s != CAMEL_IMAP_OK) {
- *ret = r;
- return s;
- }
-
- store->current_folder = folder;
- }
-
- /* Create the command */
- cmdid = g_strdup_printf ("A%.5d", store->command++);
- va_start (app, fmt);
- cmdbuf = g_strdup_vprintf (fmt, app);
- va_end (app);
-
- fprintf (stderr, "sending : %s %s\r\n", cmdid, cmdbuf);
-
- if (camel_stream_printf (store->ostream, "%s %s\r\n", cmdid, cmdbuf) == -1) {
- g_free(cmdbuf);
- g_free(cmdid);
-
- *ret = g_strdup (strerror(errno));
-
- return CAMEL_IMAP_FAIL;
- }
- g_free (cmdbuf);
-
- data = g_ptr_array_new ();
-
- while (1) {
- respbuf = camel_stream_buffer_read_line (stream);
- if (!respbuf || !strncmp(respbuf, cmdid, strlen(cmdid)) ) {
- /* IMAP's last response starts with our command id */
- fprintf (stderr, "received: %s\n", respbuf ? respbuf : "(null)");
- break;
- }
-
- fprintf (stderr, "received: %s\n", respbuf);
-
- g_ptr_array_add (data, respbuf);
- }
-
- if (respbuf) {
- g_ptr_array_add (data, respbuf);
- status = camel_imap_status (cmdid, respbuf);
- } else {
- status = CAMEL_IMAP_FAIL;
- }
- g_free (cmdid);
-
- if (status == CAMEL_IMAP_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);
- *ret = g_strjoinv ("\n", (gchar **)data->pdata);
- } else {
- if (status != CAMEL_IMAP_FAIL && respbuf)
- *ret = g_strdup (strchr (respbuf, ' ' + 1));
- else
- *ret = NULL;
- }
-
- g_ptr_array_free (data, TRUE);
-
- return status;
-}
diff --git a/camel/providers/imap/camel-imap-store.h b/camel/providers/imap/camel-imap-store.h
deleted file mode 100644
index c8fa92eb89..0000000000
--- a/camel/providers/imap/camel-imap-store.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* camel-imap-store.h : class for an imap store */
-
-/*
- * Authors: Jeffrey Stedfast <fejj@helixcode.com>
- *
- * 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_IMAP_STORE_H
-#define CAMEL_IMAP_STORE_H 1
-
-
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* __cplusplus }*/
-
-#include <gtk/gtk.h>
-#include "camel-store.h"
-
-#define CAMEL_IMAP_STORE_TYPE (camel_imap_store_get_type ())
-#define CAMEL_IMAP_STORE(obj) (GTK_CHECK_CAST((obj), CAMEL_IMAP_STORE_TYPE, CamelImapStore))
-#define CAMEL_IMAP_STORE_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_IMAP_STORE_TYPE, CamelImapStoreClass))
-#define IS_CAMEL_IMAP_STORE(o) (GTK_CHECK_TYPE((o), CAMEL_IMAP_STORE_TYPE))
-
-
-typedef struct {
- CamelStore parent_object;
-
- CamelFolder *current_folder;
- CamelStream *istream, *ostream;
-
- guint32 command;
-
-} CamelImapStore;
-
-
-
-typedef struct {
- CamelStoreClass parent_class;
-
-} CamelImapStoreClass;
-
-
-/* public methods */
-void camel_imap_store_open (CamelImapStore *store, CamelException *ex);
-void camel_imap_store_close (CamelImapStore *store, gboolean expunge, CamelException *ex);
-
-/* support functions */
-
-enum { CAMEL_IMAP_OK, CAMEL_IMAP_ERR, CAMEL_IMAP_FAIL };
-
-gint camel_imap_command (CamelImapStore *store, CamelFolder *folder, char **ret, char *fmt, ...);
-gint camel_imap_command_extended (CamelImapStore *store, CamelFolder *folder, char **ret, char *fmt, ...);
-
-/* Standard Gtk function */
-GtkType camel_imap_store_get_type (void);
-
-const gchar *camel_imap_store_get_toplevel_dir (CamelImapStore *store);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* CAMEL_IMAP_STORE_H */
-
-
diff --git a/camel/providers/imap/camel-imap-stream.c b/camel/providers/imap/camel-imap-stream.c
deleted file mode 100644
index 43b1afb61a..0000000000
--- a/camel/providers/imap/camel-imap-stream.c
+++ /dev/null
@@ -1,192 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Authors: Jeffrey Stedfast <fejj@helixcode.com>
- *
- * Copyright 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 Street #330, Boston, MA 02111-1307, USA.
- *
- */
-
-
-#include <config.h>
-#include "camel-imap-stream.h"
-#include <sys/types.h>
-#include <errno.h>
-
-static CamelStreamClass *parent_class = NULL;
-
-/* Returns the class for a CamelImapStream */
-#define CIS_CLASS(so) CAMEL_IMAP_STREAM_CLASS (GTK_OBJECT(so)->klass)
-
-static ssize_t stream_read (CamelStream *stream, char *buffer, size_t n);
-static int stream_reset (CamelStream *stream);
-static gboolean stream_eos (CamelStream *stream);
-
-static void finalize (GtkObject *object);
-
-static void
-camel_imap_stream_class_init (CamelImapStreamClass *camel_imap_stream_class)
-{
- CamelStreamClass *camel_stream_class =
- CAMEL_STREAM_CLASS (camel_imap_stream_class);
- GtkObjectClass *gtk_object_class =
- GTK_OBJECT_CLASS (camel_imap_stream_class);
-
- parent_class = gtk_type_class (camel_stream_get_type ());
-
- /* virtual method overload */
- camel_stream_class->read = stream_read;
- camel_stream_class->reset = stream_reset;
- camel_stream_class->eos = stream_eos;
-
- gtk_object_class->finalize = finalize;
-}
-
-static void
-camel_imap_stream_init (gpointer object, gpointer klass)
-{
- CamelImapStream *imap_stream = CAMEL_IMAP_STREAM (object);
-
- imap_stream->cache = NULL;
- imap_stream->cache_ptr = NULL;
-}
-
-GtkType
-camel_imap_stream_get_type (void)
-{
- static GtkType camel_imap_stream_type = 0;
-
- if (!camel_imap_stream_type) {
- GtkTypeInfo camel_imap_stream_info =
- {
- "CamelImapStream",
- sizeof (CamelImapStream),
- sizeof (CamelImapStreamClass),
- (GtkClassInitFunc) camel_imap_stream_class_init,
- (GtkObjectInitFunc) camel_imap_stream_init,
- /* reserved_1 */ NULL,
- /* reserved_2 */ NULL,
- (GtkClassInitFunc) NULL,
- };
-
- camel_imap_stream_type = gtk_type_unique (camel_stream_get_type (), &camel_imap_stream_info);
- }
-
- return camel_imap_stream_type;
-}
-
-CamelStream *
-camel_imap_stream_new (CamelImapFolder *folder, char *command)
-{
- CamelImapStream *imap_stream;
-
- imap_stream = gtk_type_new (camel_imap_stream_get_type ());
-
- imap_stream->folder = folder;
- gtk_object_ref(GTK_OBJECT (imap_stream->folder));
-
- imap_stream->command = g_strdup(command);
-
- return CAMEL_STREAM (imap_stream);
-}
-
-static void
-finalize (GtkObject *object)
-{
- CamelImapStream *imap_stream = CAMEL_IMAP_STREAM (object);
-
- g_free(imap_stream->cache);
- g_free(imap_stream->command);
-
- if (imap_stream->folder)
- gtk_object_unref(GTK_OBJECT (imap_stream->folder));
-
- GTK_OBJECT_CLASS (parent_class)->finalize (object);
-}
-
-static ssize_t
-stream_read (CamelStream *stream, char *buffer, size_t n)
-{
- ssize_t nread;
-
- /* do we want to do any IMAP specific parsing in here? If not, maybe rename to camel-stream-cache? */
- CamelImapStream *imap_stream = CAMEL_IMAP_STREAM (stream);
-
- if (!imap_stream->cache) {
- /* We need to send the IMAP command since this is our first fetch */
- CamelFolder *folder = CAMEL_FOLDER (imap_stream->folder);
- gint status;
-
- status = camel_imap_command_extended(CAMEL_IMAP_STORE (folder->parent_store),
- CAMEL_FOLDER (imap_stream->folder),
- &imap_stream->cache, "%s",
- imap_stream->command);
-
- if (status != CAMEL_IMAP_OK) {
- /* we got an error, dump this stuff */
- g_free(imap_stream->cache);
- imap_stream->cache = NULL;
-
- return -1;
- }
-
- /* we don't need the folder anymore... */
- gtk_object_unref(GTK_OBJECT (imap_stream->folder));
-
- imap_stream->cache_ptr = imap_stream->cache;
- }
-
- /* we've already read this stream, so return whats in the cache */
- nread = MIN (n, strlen(imap_stream->cache_ptr));
-
- if (nread > 0) {
- memcpy(buffer, imap_stream->cache_ptr, nread);
- imap_stream->cache_ptr += nread;
- } else {
- nread = -1;
- }
-
- return nread;
-}
-
-static int
-stream_reset (CamelStream *stream)
-{
- CamelImapStream *imap_stream = CAMEL_IMAP_STREAM (stream);
-
- imap_stream->cache_ptr = imap_stream->cache;
-
- return 1;
-}
-
-static gboolean
-stream_eos (CamelStream *stream)
-{
- CamelImapStream *imap_stream = CAMEL_IMAP_STREAM (stream);
-
- return (imap_stream->cache_ptr && strlen(imap_stream->cache_ptr));
-}
-
-
-
-
-
-
-
-
-
-
-
diff --git a/camel/providers/imap/camel-imap-stream.h b/camel/providers/imap/camel-imap-stream.h
deleted file mode 100644
index 2a6e2fc723..0000000000
--- a/camel/providers/imap/camel-imap-stream.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Authors: Jeffrey Stedfast <fejj@helixcode.com>
- *
- * Copyright 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 Street #330, Boston, MA 02111-1307, USA.
- *
- */
-
-
-#ifndef CAMEL_IMAP_STREAM_H
-#define CAMEL_IMAP_STREAM_H
-
-
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* __cplusplus }*/
-
-#include <camel/camel-stream.h>
-#include "camel-imap-folder.h"
-#include "camel-imap-store.h"
-#include <sys/types.h>
-
-#define CAMEL_IMAP_STREAM_TYPE (camel_imap_stream_get_type ())
-#define CAMEL_IMAP_STREAM(obj) (GTK_CHECK_CAST((obj), CAMEL_IMAP_STREAM_TYPE, CamelImapStream))
-#define CAMEL_IMAP_STREAM_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_IMAP_STREAM_TYPE, CamelImapStreamClass))
-#define CAMEL_IS_IMAP_STREAM(o) (GTK_CHECK_TYPE((o), CAMEL_IMAP_STREAM_TYPE))
-
-typedef struct _CamelImapStream CamelImapStream;
-typedef struct _CamelImapStreamClass CamelImapStreamClass;
-
-struct _CamelImapStream {
- CamelStream parent_object;
-
- CamelImapFolder *folder;
- char *command;
- char *cache;
- char *cache_ptr;
-};
-
-struct _CamelImapStreamClass {
- CamelStreamClass parent_class;
-
- /* Virtual methods */
-};
-
-/* Standard Gtk function */
-GtkType camel_imap_stream_get_type (void);
-
-/* public methods */
-CamelStream *camel_imap_stream_new (CamelImapFolder *folder, char *command);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* CAMEL_IMAP_STREAM_H */
diff --git a/camel/providers/imap/libcamelimap.urls b/camel/providers/imap/libcamelimap.urls
deleted file mode 100644
index c301c0ffac..0000000000
--- a/camel/providers/imap/libcamelimap.urls
+++ /dev/null
@@ -1 +0,0 @@
-imap