aboutsummaryrefslogtreecommitdiffstats
path: root/camel/providers/pop3
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/pop3
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/pop3')
-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
3 files changed, 31 insertions, 53 deletions
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 };