aboutsummaryrefslogtreecommitdiffstats
path: root/camel/providers
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/providers
parente1de51e60e715983d1063810ac0cbfd80f99cc2c (diff)
downloadgsoc2013-evolution-cd157eecb933748212bf87b41dcf5fa863e75fd5.tar.gz
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/providers')
-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
7 files changed, 59 insertions, 170 deletions
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) {