aboutsummaryrefslogtreecommitdiffstats
path: root/camel
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2000-06-16 06:19:44 +0800
committerDan Winship <danw@src.gnome.org>2000-06-16 06:19:44 +0800
commitcd157eecb933748212bf87b41dcf5fa863e75fd5 (patch)
tree29dc32794de0449c4a7e5fb544150e57ea4183bb /camel
parente1de51e60e715983d1063810ac0cbfd80f99cc2c (diff)
downloadgsoc2013-evolution-cd157eecb933748212bf87b41dcf5fa863e75fd5.tar
gsoc2013-evolution-cd157eecb933748212bf87b41dcf5fa863e75fd5.tar.gz
gsoc2013-evolution-cd157eecb933748212bf87b41dcf5fa863e75fd5.tar.bz2
gsoc2013-evolution-cd157eecb933748212bf87b41dcf5fa863e75fd5.tar.lz
gsoc2013-evolution-cd157eecb933748212bf87b41dcf5fa863e75fd5.tar.xz
gsoc2013-evolution-cd157eecb933748212bf87b41dcf5fa863e75fd5.tar.zst
gsoc2013-evolution-cd157eecb933748212bf87b41dcf5fa863e75fd5.zip
Kill. Folders are now always open, and handle "closing" sorts of
* camel-folder.c: (camel_folder_open, camel_folder_is_open, camel_folder_get_mode): Kill. Folders are now always open, and handle "closing" sorts of operations at sync or finalize time. (camel_folder_sync): renamed from camel_folder_close. Syncs state to the store but doesn't necessarily close/disconnect. * providers/*/camel-*-folder.c: Merge "open" methods into "init" methods. Rename close to sync and update appropriately. * providers/imap/camel-imap-store.c: Remove camel_imap_store_open and camel_imap_store_close, which should not have been copied from the POP provider (where the exist to work around limitations of the POP protocol). svn path=/trunk/; revision=3581
Diffstat (limited to 'camel')
-rw-r--r--camel/ChangeLog14
-rw-r--r--camel/camel-folder.c122
-rw-r--r--camel/camel-folder.h37
-rw-r--r--camel/providers/imap/camel-imap-folder.c56
-rw-r--r--camel/providers/imap/camel-imap-store.c22
-rw-r--r--camel/providers/mbox/camel-mbox-folder.c26
-rw-r--r--camel/providers/pop3/camel-pop3-folder.c23
-rw-r--r--camel/providers/pop3/camel-pop3-store.c57
-rw-r--r--camel/providers/pop3/camel-pop3-store.h4
-rw-r--r--camel/providers/vee/camel-vee-folder.c41
10 files changed, 86 insertions, 316 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index fbe956b644..f49ba73abe 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,5 +1,19 @@
2000-06-15 Dan Winship <danw@helixcode.com>
+ * camel-folder.c: (camel_folder_open, camel_folder_is_open,
+ camel_folder_get_mode): Kill. Folders are now always open, and
+ handle "closing" sorts of operations at sync or finalize time.
+ (camel_folder_sync): renamed from camel_folder_close. Syncs state
+ to the store but doesn't necessarily close/disconnect.
+
+ * providers/*/camel-*-folder.c: Merge "open" methods into "init"
+ methods. Rename close to sync and update appropriately.
+
+ * providers/imap/camel-imap-store.c: Remove camel_imap_store_open
+ and camel_imap_store_close, which should not have been copied from
+ the POP provider (where the exist to work around limitations of
+ the POP protocol).
+
* providers/mbox/camel-mbox-summary.c: fix a bug. (don't expunge
deleted messages if called with expunge == FALSE)
diff --git a/camel/camel-folder.c b/camel/camel-folder.c
index d988ba6b4d..6fda77d5d1 100644
--- a/camel/camel-folder.c
+++ b/camel/camel-folder.c
@@ -53,10 +53,8 @@ static void init (CamelFolder *folder, CamelStore *parent_store,
static void finalize (GtkObject *object);
-static void folder_open (CamelFolder *folder, CamelFolderOpenMode mode,
+static void folder_sync (CamelFolder *folder, gboolean expunge,
CamelException *ex);
-static void folder_close (CamelFolder *folder, gboolean expunge,
- CamelException *ex);
static const gchar *get_name (CamelFolder *folder);
static const gchar *get_full_name (CamelFolder *folder);
@@ -64,9 +62,7 @@ static const gchar *get_full_name (CamelFolder *folder);
static gboolean can_hold_folders (CamelFolder *folder);
static gboolean can_hold_messages (CamelFolder *folder);
-static gboolean is_open (CamelFolder *folder);
static guint32 get_permanent_flags (CamelFolder *folder, CamelException *ex);
-static CamelFolderOpenMode get_mode (CamelFolder *folder, CamelException *ex);
static GPtrArray *get_subfolder_names (CamelFolder *folder,
@@ -126,17 +122,14 @@ camel_folder_class_init (CamelFolderClass *camel_folder_class)
/* virtual method definition */
camel_folder_class->init = init;
- camel_folder_class->open = folder_open;
- camel_folder_class->close = folder_close;
+ camel_folder_class->sync = folder_sync;
camel_folder_class->get_name = get_name;
camel_folder_class->get_full_name = get_full_name;
camel_folder_class->can_hold_folders = can_hold_folders;
camel_folder_class->can_hold_messages = can_hold_messages;
- camel_folder_class->is_open = is_open;
camel_folder_class->get_subfolder = get_subfolder;
camel_folder_class->get_parent_folder = get_parent_folder;
camel_folder_class->get_parent_store = get_parent_store;
- camel_folder_class->get_mode = get_mode;
camel_folder_class->get_subfolder_names = get_subfolder_names;
camel_folder_class->free_subfolder_names = free_uids;
camel_folder_class->expunge = expunge;
@@ -246,8 +239,6 @@ init (CamelFolder *folder, CamelStore *parent_store,
if (parent_folder)
gtk_object_ref (GTK_OBJECT (parent_folder));
- folder->open_mode = FOLDER_OPEN_UNKNOWN;
- folder->open_state = FOLDER_CLOSE;
folder->separator = separator;
folder->path_begins_with_sep = path_begins_with_sep;
@@ -279,60 +270,28 @@ init (CamelFolder *folder, CamelStore *parent_store,
static void
-folder_open (CamelFolder *folder, CamelFolderOpenMode mode, CamelException *ex)
+folder_sync (CamelFolder *folder, gboolean expunge, CamelException *ex)
{
- if (folder->open_state == FOLDER_OPEN) {
- camel_exception_set (ex, CAMEL_EXCEPTION_FOLDER_INVALID_STATE,
- "folder is already open");
- return;
- }
-
- folder->open_state = FOLDER_OPEN;
- folder->open_mode = mode;
-}
-
-/**
- * camel_folder_open:
- * @folder: The folder object
- * @mode: open mode (R/W/RW ?)
- * @ex: exception object
- *
- * Open a folder in a given mode.
- **/
-void
-camel_folder_open (CamelFolder *folder, CamelFolderOpenMode mode,
- CamelException *ex)
-{
- g_return_if_fail (CAMEL_IS_FOLDER (folder));
- g_return_if_fail (!camel_folder_is_open (folder));
-
- CF_CLASS (folder)->open (folder, mode, ex);
-}
-
-
-static void
-folder_close (CamelFolder *folder, gboolean expunge, CamelException *ex)
-{
- folder->open_state = FOLDER_CLOSE;
+ g_warning ("CamelFolder::sync not implemented for `%s'",
+ gtk_type_name (GTK_OBJECT_TYPE (folder)));
}
/**
- * camel_folder_close:
+ * camel_folder_sync:
* @folder: The folder object
* @expunge: whether or not to expunge deleted messages
* @ex: exception object
*
- * Put a folder in its closed state, and possibly expunge the messages
- * flagged for deletion.
+ * Sync changes made to a folder to its backing store, possibly expunging
+ * deleted messages as well.
**/
void
-camel_folder_close (CamelFolder *folder, gboolean expunge,
- CamelException *ex)
+camel_folder_sync (CamelFolder *folder, gboolean expunge,
+ CamelException *ex)
{
g_return_if_fail (CAMEL_IS_FOLDER (folder));
- g_return_if_fail (camel_folder_is_open (folder));
- CF_CLASS (folder)->close (folder, expunge, ex);
+ CF_CLASS (folder)->sync (folder, expunge, ex);
}
@@ -396,30 +355,6 @@ can_hold_messages (CamelFolder *folder)
}
-static gboolean
-is_open (CamelFolder *folder)
-{
- return folder->open_state == FOLDER_OPEN;
-}
-
-/**
- * camel_folder_is_open:
- * @folder: a folder object
- *
- * Tests if a folder is open. If not open it can be opened with
- * CamelFolder::open
- *
- * Return value: whether or not the folder is open
- **/
-gboolean
-camel_folder_is_open (CamelFolder *folder)
-{
- g_return_val_if_fail (CAMEL_IS_FOLDER (folder), FALSE);
-
- return CF_CLASS (folder)->is_open (folder);
-}
-
-
static CamelFolder *
get_subfolder (CamelFolder *folder, const gchar *folder_name,
gboolean create, CamelException *ex)
@@ -460,7 +395,6 @@ camel_folder_get_subfolder (CamelFolder *folder, const gchar *folder_name,
gboolean create, CamelException *ex)
{
g_return_val_if_fail (CAMEL_IS_FOLDER (folder), NULL);
- g_return_val_if_fail (camel_folder_is_open (folder), NULL);
g_return_val_if_fail (folder_name != NULL, NULL);
return CF_CLASS (folder)->get_subfolder (folder, folder_name,
@@ -512,28 +446,6 @@ camel_folder_get_parent_store (CamelFolder *folder, CamelException *ex)
}
-static CamelFolderOpenMode
-get_mode (CamelFolder *folder, CamelException *ex)
-{
- return folder->open_mode;
-}
-
-/**
- * camel_folder_get_mode:
- * @folder: a folder
- * @ex: a CamelException
- *
- * Return value: the open mode of the folder
- **/
-CamelFolderOpenMode
-camel_folder_get_mode (CamelFolder *folder, CamelException *ex)
-{
- g_return_val_if_fail (CAMEL_IS_FOLDER (folder), -1);
-
- return CF_CLASS (folder)->get_mode (folder, ex);
-}
-
-
static GPtrArray *
get_subfolder_names (CamelFolder *folder, CamelException *ex)
{
@@ -555,7 +467,6 @@ GPtrArray *
camel_folder_get_subfolder_names (CamelFolder *folder, CamelException *ex)
{
g_return_val_if_fail (CAMEL_IS_FOLDER (folder), NULL);
- g_return_val_if_fail (camel_folder_is_open (folder), NULL);
return CF_CLASS (folder)->get_subfolder_names (folder, ex);
}
@@ -572,7 +483,6 @@ void
camel_folder_free_subfolder_names (CamelFolder *folder, GPtrArray *array)
{
g_return_if_fail (CAMEL_IS_FOLDER (folder));
- g_return_if_fail (camel_folder_is_open (folder));
CF_CLASS (folder)->free_subfolder_names (folder, array);
}
@@ -597,7 +507,6 @@ void
camel_folder_expunge (CamelFolder *folder, CamelException *ex)
{
g_return_if_fail (CAMEL_IS_FOLDER (folder));
- g_return_if_fail (camel_folder_is_open (folder));
return CF_CLASS (folder)->expunge (folder, ex);
}
@@ -622,7 +531,6 @@ gint
camel_folder_get_message_count (CamelFolder *folder, CamelException *ex)
{
g_return_val_if_fail (CAMEL_IS_FOLDER (folder), -1);
- g_return_val_if_fail (camel_folder_is_open (folder), -1);
return CF_CLASS (folder)->get_message_count (folder, ex);
}
@@ -652,7 +560,6 @@ camel_folder_append_message (CamelFolder *folder,
CamelException *ex)
{
g_return_if_fail (CAMEL_IS_FOLDER (folder));
- g_return_if_fail (camel_folder_is_open (folder));
CF_CLASS (folder)->append_message (folder, message, ex);
}
@@ -738,7 +645,6 @@ camel_folder_get_message_uid (CamelFolder *folder, CamelMimeMessage *message,
{
g_return_val_if_fail (CAMEL_IS_FOLDER (folder), NULL);
g_return_val_if_fail (CAMEL_IS_MIME_MESSAGE (message), NULL);
- g_return_val_if_fail (camel_folder_is_open (folder), NULL);
return CF_CLASS (folder)->get_message_uid (folder, message, ex);
}
@@ -769,7 +675,6 @@ camel_folder_get_message_by_uid (CamelFolder *folder, const gchar *uid,
CamelException *ex)
{
g_return_val_if_fail (CAMEL_IS_FOLDER (folder), NULL);
- g_return_val_if_fail (camel_folder_is_open (folder), NULL);
return CF_CLASS (folder)->get_message_by_uid (folder, uid, ex);
}
@@ -796,7 +701,6 @@ camel_folder_delete_message_by_uid (CamelFolder *folder, const gchar *uid,
CamelException *ex)
{
g_return_if_fail (CAMEL_IS_FOLDER (folder));
- g_return_if_fail (camel_folder_is_open (folder));
return CF_CLASS (folder)->delete_message_by_uid (folder, uid, ex);
}
@@ -827,7 +731,6 @@ GPtrArray *
camel_folder_get_uids (CamelFolder *folder, CamelException *ex)
{
g_return_val_if_fail (CAMEL_IS_FOLDER (folder), NULL);
- g_return_val_if_fail (camel_folder_is_open (folder), NULL);
return CF_CLASS (folder)->get_uids (folder, ex);
}
@@ -858,7 +761,6 @@ void
camel_folder_free_uids (CamelFolder *folder, GPtrArray *array)
{
g_return_if_fail (CAMEL_IS_FOLDER (folder));
- g_return_if_fail (camel_folder_is_open (folder));
CF_CLASS (folder)->free_uids (folder, array);
}
@@ -887,7 +789,6 @@ GPtrArray *
camel_folder_get_summary (CamelFolder *folder, CamelException *ex)
{
g_return_val_if_fail (CAMEL_IS_FOLDER (folder), NULL);
- g_return_val_if_fail (camel_folder_is_open (folder), NULL);
return CF_CLASS (folder)->get_summary (folder, ex);
}
@@ -911,7 +812,6 @@ void
camel_folder_free_summary (CamelFolder *folder, GPtrArray *array)
{
g_return_if_fail (CAMEL_IS_FOLDER (folder));
- g_return_if_fail (camel_folder_is_open (folder));
CF_CLASS (folder)->free_summary (folder, array);
}
diff --git a/camel/camel-folder.h b/camel/camel-folder.h
index b35edc3aa9..2412f8da2c 100644
--- a/camel/camel-folder.h
+++ b/camel/camel-folder.h
@@ -41,24 +41,10 @@ extern "C" {
#define CAMEL_FOLDER_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_FOLDER_TYPE, CamelFolderClass))
#define CAMEL_IS_FOLDER(o) (GTK_CHECK_TYPE((o), CAMEL_FOLDER_TYPE))
-typedef enum {
- FOLDER_OPEN,
- FOLDER_CLOSE
-} CamelFolderState;
-
-typedef enum {
- FOLDER_OPEN_UNKNOWN = 0, /* folder open mode is unknown */
- FOLDER_OPEN_READ = 1, /* folder is read only */
- FOLDER_OPEN_WRITE = 2, /* folder is write only */
- FOLDER_OPEN_RW = 3 /* folder is read/write */
-} CamelFolderOpenMode;
-
struct _CamelFolder
{
CamelObject parent_object;
- CamelFolderOpenMode open_mode;
- CamelFolderState open_state;
gchar *name;
gchar *full_name;
gchar *separator;
@@ -86,13 +72,8 @@ typedef struct {
gchar *separator, gboolean path_begins_with_sep,
CamelException *ex);
- void (*open) (CamelFolder *folder,
- CamelFolderOpenMode mode,
+ void (*sync) (CamelFolder *folder, gboolean expunge,
CamelException *ex);
-
- void (*close) (CamelFolder *folder,
- gboolean expunge,
- CamelException *ex);
const gchar * (*get_name) (CamelFolder *folder);
@@ -102,8 +83,6 @@ typedef struct {
gboolean (*can_hold_messages) (CamelFolder *folder);
- gboolean (*is_open) (CamelFolder *folder);
-
CamelFolder * (*get_subfolder) (CamelFolder *folder,
const gchar *folder_name,
gboolean create,
@@ -115,9 +94,6 @@ typedef struct {
CamelStore * (*get_parent_store) (CamelFolder *folder,
CamelException *ex);
- CamelFolderOpenMode (*get_mode) (CamelFolder *folder,
- CamelException *ex);
-
void (*expunge) (CamelFolder *folder,
CamelException *ex);
@@ -180,12 +156,7 @@ CamelFolder * camel_folder_get_subfolder (CamelFolder *folder,
gboolean create,
CamelException *ex);
-void camel_folder_open (CamelFolder *folder,
- CamelFolderOpenMode mode,
- CamelException *ex);
-
-
-void camel_folder_close (CamelFolder *folder,
+void camel_folder_sync (CamelFolder *folder,
gboolean expunge,
CamelException *ex);
@@ -211,10 +182,6 @@ const gchar * camel_folder_get_full_name (CamelFolder *folder);
guint32 camel_folder_get_permanent_flags (CamelFolder *folder,
CamelException *ex);
-CamelFolderOpenMode camel_folder_get_mode (CamelFolder *folder,
- CamelException *ex);
-gboolean camel_folder_is_open (CamelFolder *folder);
-
/* message manipulation */
diff --git a/camel/providers/imap/camel-imap-folder.c b/camel/providers/imap/camel-imap-folder.c
index 37e4b06d9c..860a8aed99 100644
--- a/camel/providers/imap/camel-imap-folder.c
+++ b/camel/providers/imap/camel-imap-folder.c
@@ -60,8 +60,7 @@ static void imap_init (CamelFolder *folder, CamelStore *parent_store,
gchar *separator, gboolean path_begns_with_sep,
CamelException *ex);
-static void imap_open (CamelFolder *folder, CamelFolderOpenMode mode, CamelException *ex);
-static void imap_close (CamelFolder *folder, gboolean expunge, 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);
@@ -106,8 +105,7 @@ camel_imap_folder_class_init (CamelImapFolderClass *camel_imap_folder_class)
/* virtual method overload */
camel_folder_class->init = imap_init;
- camel_folder_class->open = imap_open;
- camel_folder_class->close = imap_close;
+ camel_folder_class->sync = imap_sync;
#if 0
camel_folder_class->exists = imap_exists;
camel_folder_class->create = imap_create;
@@ -158,7 +156,7 @@ camel_imap_folder_get_type (void)
sizeof (CamelImapFolder),
sizeof (CamelImapFolderClass),
(GtkClassInitFunc) camel_imap_folder_class_init,
- (GtkObjectInitFunc) NULL,
+ (GtkObjectInitFunc) camel_imap_folder_init,
/* reserved_1 */ NULL,
/* reserved_2 */ NULL,
(GtkClassInitFunc) NULL,
@@ -191,6 +189,8 @@ imap_init (CamelFolder *folder, CamelStore *parent_store, CamelFolder *parent_fo
const gchar *name, gchar *separator, gboolean path_begins_with_sep, CamelException *ex)
{
CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder);
+ int status;
+ char *result;
/* call parent method */
parent_class->init (folder, parent_store, parent_folder, name, separator, path_begins_with_sep, ex);
@@ -218,47 +218,25 @@ imap_init (CamelFolder *folder, CamelStore *parent_store, CamelFolder *parent_fo
imap_folder->summary = NULL;
imap_folder->search = NULL;
-}
-
-static void
-imap_open (CamelFolder *folder, CamelFolderOpenMode mode, CamelException *ex)
-{
- gchar *result;
- gint status;
-
- camel_imap_store_open (CAMEL_IMAP_STORE (folder->parent_store), ex);
- if (camel_exception_get_id (ex) == CAMEL_EXCEPTION_NONE) {
- /* do we actually want to do this? probably not */
- parent_class->open (folder, mode, ex);
-
- /* SELECT the IMAP mail spool */
- status = camel_imap_command_extended (CAMEL_IMAP_STORE (folder->parent_store), folder,
- &result, "SELECT %s", folder->full_name);
-
- 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");
- g_free (result);
- return;
- }
- g_free(result);
+ /* SELECT the IMAP mail spool */
+ status = camel_imap_command_extended (CAMEL_IMAP_STORE (folder->parent_store), folder,
+ &result, "SELECT %s", folder->full_name);
+ 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");
}
+ g_free(result);
}
static void
-imap_close (CamelFolder *folder, gboolean expunge, CamelException *ex)
+imap_sync (CamelFolder *folder, gboolean expunge, CamelException *ex)
{
/* TODO: actually code this method */
- camel_imap_store_close (CAMEL_IMAP_STORE (folder->parent_store), expunge, ex);
- if (camel_exception_get_id (ex) == CAMEL_EXCEPTION_NONE)
- parent_class->close (folder, expunge, ex);
-
}
static void
diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c
index 65290336c4..a02ff639d0 100644
--- a/camel/providers/imap/camel-imap-store.c
+++ b/camel/providers/imap/camel-imap-store.c
@@ -584,25 +584,3 @@ camel_imap_command_extended (CamelImapStore *store, CamelFolder *folder, char **
return status;
}
-
-void
-camel_imap_store_open (CamelImapStore *store, CamelException *ex)
-{
- CamelService *service = CAMEL_SERVICE (store);
-
- if (!camel_service_is_connected (service))
- imap_connect (service, ex);
-}
-
-void
-camel_imap_store_close (CamelImapStore *store, gboolean expunge, CamelException *ex)
-{
- /*
- if (expunge)
- camel_imap_command (store, NULL, "QUIT");
- else
- camel_imap_command (store, NULL, "RSET");
- */
-
- imap_disconnect (CAMEL_SERVICE (store), ex);
-}
diff --git a/camel/providers/mbox/camel-mbox-folder.c b/camel/providers/mbox/camel-mbox-folder.c
index 0aa2f90f26..3c8de8dfcf 100644
--- a/camel/providers/mbox/camel-mbox-folder.c
+++ b/camel/providers/mbox/camel-mbox-folder.c
@@ -61,8 +61,7 @@ static void mbox_init (CamelFolder *folder, CamelStore *parent_store,
gchar *separator, gboolean path_begins_with_sep,
CamelException *ex);
-static void mbox_open (CamelFolder *folder, CamelFolderOpenMode mode, CamelException *ex);
-static void mbox_close (CamelFolder *folder, gboolean expunge, CamelException *ex);
+static void mbox_sync (CamelFolder *folder, gboolean expunge, 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);
@@ -97,8 +96,7 @@ camel_mbox_folder_class_init (CamelMboxFolderClass *camel_mbox_folder_class)
/* virtual method overload */
camel_folder_class->init = mbox_init;
- camel_folder_class->open = mbox_open;
- camel_folder_class->close = mbox_close;
+ camel_folder_class->sync = mbox_sync;
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;
@@ -162,6 +160,8 @@ mbox_init (CamelFolder *folder, CamelStore *parent_store,
{
CamelMboxFolder *mbox_folder = (CamelMboxFolder *)folder;
const gchar *root_dir_path;
+ int forceindex;
+ struct stat st;
/* call parent method */
parent_class->init (folder, parent_store, parent_folder,
@@ -197,19 +197,6 @@ mbox_init (CamelFolder *folder, CamelStore *parent_store,
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;
@@ -237,13 +224,10 @@ mbox_open (CamelFolder *folder, CamelFolderOpenMode mode, CamelException *ex)
}
static void
-mbox_close (CamelFolder *folder, gboolean expunge, CamelException *ex)
+mbox_sync (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);
else
diff --git a/camel/providers/pop3/camel-pop3-folder.c b/camel/providers/pop3/camel-pop3-folder.c
index 807a810d06..9a2d982fcd 100644
--- a/camel/providers/pop3/camel-pop3-folder.c
+++ b/camel/providers/pop3/camel-pop3-folder.c
@@ -38,10 +38,8 @@ static CamelFolderClass *parent_class;
static void finalize (GtkObject *object);
-static void pop3_open (CamelFolder *folder, CamelFolderOpenMode mode,
+static void pop3_sync (CamelFolder *folder, gboolean expunge,
CamelException *ex);
-static void pop3_close (CamelFolder *folder, gboolean expunge,
- CamelException *ex);
static gint get_message_count (CamelFolder *folder, CamelException *ex);
static GPtrArray *get_uids (CamelFolder *folder, CamelException *ex);
@@ -64,8 +62,7 @@ camel_pop3_folder_class_init (CamelPop3FolderClass *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->sync = pop3_sync;
camel_folder_class->get_message_count = get_message_count;
camel_folder_class->get_uids = get_uids;
@@ -138,20 +135,10 @@ camel_pop3_folder_new (CamelStore *parent, CamelException *ex)
}
static void
-pop3_open (CamelFolder *folder, CamelFolderOpenMode mode, CamelException *ex)
+pop3_sync (CamelFolder *folder, gboolean expunge, 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);
+ if (expunge)
+ camel_pop3_store_expunge (CAMEL_POP3_STORE (folder->parent_store), ex);
}
diff --git a/camel/providers/pop3/camel-pop3-store.c b/camel/providers/pop3/camel-pop3-store.c
index c915b0916f..b465faa499 100644
--- a/camel/providers/pop3/camel-pop3-store.c
+++ b/camel/providers/pop3/camel-pop3-store.c
@@ -372,44 +372,18 @@ free_auth_types (CamelService *service, GList *authtypes)
}
/**
- * camel_pop3_store_open: Connect to the server if we are currently
- * disconnected.
+ * camel_pop3_store_expunge:
* @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.
- *
+ * Expunge messages from the store. This will result in the connection
+ * being closed, which may cause later commands to fail if they can't
+ * reconnect.
**/
void
-camel_pop3_store_open (CamelPop3Store *store, CamelException *ex)
+camel_pop3_store_expunge (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");
+ camel_pop3_command (store, NULL, "QUIT");
pop3_disconnect (CAMEL_SERVICE (store), ex);
}
@@ -539,6 +513,12 @@ static CamelFolder *
get_folder (CamelStore *store, const char *folder_name,
gboolean create, CamelException *ex)
{
+ CamelService *service = CAMEL_SERVICE (store);
+
+ if (!camel_service_is_connected (service)) {
+ if (!camel_service_connect (service, ex))
+ return NULL;
+ }
return camel_pop3_folder_new (store, ex);
}
@@ -585,10 +565,23 @@ get_root_folder_name (CamelStore *store, CamelException *ex)
int
camel_pop3_command (CamelPop3Store *store, char **ret, char *fmt, ...)
{
+ CamelService *service = CAMEL_SERVICE (store);
char *cmdbuf, *respbuf;
va_list ap;
int status;
+ if (!store->ostream) {
+ CamelException ex;
+
+ camel_exception_init (&ex);
+ if (!camel_service_connect (service, &ex)) {
+ if (ret)
+ *ret = g_strdup (camel_exception_get_description (&ex));
+ camel_exception_clear (&ex);
+ return CAMEL_POP3_FAIL;
+ }
+ }
+
va_start (ap, fmt);
cmdbuf = g_strdup_vprintf (fmt, ap);
va_end (ap);
diff --git a/camel/providers/pop3/camel-pop3-store.h b/camel/providers/pop3/camel-pop3-store.h
index 97d65741f9..74174a32f2 100644
--- a/camel/providers/pop3/camel-pop3-store.h
+++ b/camel/providers/pop3/camel-pop3-store.h
@@ -62,9 +62,7 @@ typedef struct {
/* public methods */
-void camel_pop3_store_open (CamelPop3Store *store, CamelException *ex);
-void camel_pop3_store_close (CamelPop3Store *store, gboolean expunge,
- CamelException *ex);
+void camel_pop3_store_expunge (CamelPop3Store *store, CamelException *ex);
/* support functions */
enum { CAMEL_POP3_OK, CAMEL_POP3_ERR, CAMEL_POP3_FAIL };
diff --git a/camel/providers/vee/camel-vee-folder.c b/camel/providers/vee/camel-vee-folder.c
index 8bb7ec6ab1..0b7b02d2e2 100644
--- a/camel/providers/vee/camel-vee-folder.c
+++ b/camel/providers/vee/camel-vee-folder.c
@@ -43,9 +43,6 @@ static void vee_init (CamelFolder *folder, CamelStore *parent_store,
gchar *separator, gboolean path_begins_with_sep,
CamelException *ex);
-static void vee_open (CamelFolder *folder, CamelFolderOpenMode mode, CamelException *ex);
-static void vee_close (CamelFolder *folder, gboolean expunge, 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);
@@ -107,8 +104,6 @@ camel_vee_folder_class_init (CamelVeeFolderClass *klass)
printf("vfolder class init\n");
folder_class->init = vee_init;
- folder_class->open = vee_open;
- folder_class->close = vee_close;
folder_class->get_uids = vee_get_uids;
folder_class->get_summary = vee_get_summary;
@@ -185,21 +180,18 @@ void
camel_vee_folder_add_folder(CamelVeeFolder *vf, CamelFolder *sub)
{
struct _CamelVeeFolderPrivate *p = _PRIVATE(vf);
+ CamelException *ex;
gtk_object_ref((GtkObject *)sub);
p->folders = g_list_append(p->folders, sub);
gtk_signal_connect((GtkObject *)sub, "folder_changed", folder_changed, vf);
- /* if we're open, do the search and update too */
- if (camel_folder_is_open((CamelFolder *)vf)) {
- CamelException *ex;
- ex = camel_exception_new();
- vee_folder_build_folder(vf, sub, ex);
- camel_exception_free(ex);
- /* FIXME: should only raise follow-on event if the result changed */
- gtk_signal_emit_by_name((GtkObject *)vf, "folder_changed", 0);
- }
+ ex = camel_exception_new();
+ vee_folder_build_folder(vf, sub, ex);
+ camel_exception_free(ex);
+ /* FIXME: should only raise follow-on event if the result changed */
+ gtk_signal_emit_by_name((GtkObject *)vf, "folder_changed", 0);
}
@@ -246,27 +238,10 @@ static void vee_init (CamelFolder *folder, CamelStore *parent_store,
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? */
-}
-
static void vee_append_message (CamelFolder *folder, CamelMimeMessage *message, CamelException *ex)
{
CamelVeeFolder *vf = (CamelVeeFolder *)folder;
@@ -444,10 +419,6 @@ vee_folder_build(CamelVeeFolder *vf, CamelException *ex)
gtk_type_name(((GtkObject *)f)->klass->type),
camel_folder_get_full_name(f));
- /* ugh, make sure the folder is open? */
- if (!camel_folder_is_open(f))
- camel_folder_open (f, FOLDER_OPEN_RW, ex);
-
matches = camel_folder_search_by_expression(f, vf->expression, ex);
match = matches;
while (match) {