aboutsummaryrefslogtreecommitdiffstats
path: root/camel
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2000-11-01 07:44:46 +0800
committerDan Winship <danw@src.gnome.org>2000-11-01 07:44:46 +0800
commit517db3b21fece8d8616620ff299689699b62b277 (patch)
tree0417ff14f0fa20967aba0580e48d8668050ad07b /camel
parent1d60c5cc024dd69b2f0d776bd0f48d1af7fef08b (diff)
downloadgsoc2013-evolution-517db3b21fece8d8616620ff299689699b62b277.tar.gz
gsoc2013-evolution-517db3b21fece8d8616620ff299689699b62b277.tar.zst
gsoc2013-evolution-517db3b21fece8d8616620ff299689699b62b277.zip
Add a new argument, clean, that says whether or not to try to disconnect
* camel-service.c (service_disconnect): Add a new argument, clean, that says whether or not to try to disconnect cleanly. * camel-remote-store.c (remote_send_string, remote_send_stream, remote_recv_line): disconnect uncleanly on failure to prevent infinite loops when providers would normally send commands from disconnect(). Remove some unneeded CamelException goo. * providers/smtp/camel-smtp-transport.c (smtp_disconnect): * providers/pop3/camel-pop3-store.c (pop3_disconnect): * providers/nntp/camel-nntp-store.c (nntp_store_disconnect): * providers/imap/camel-imap-store.c (imap_disconnect): Don't send QUIT/LOGOUT if !clean. svn path=/trunk/; revision=6303
Diffstat (limited to 'camel')
-rw-r--r--camel/ChangeLog16
-rw-r--r--camel/camel-remote-store.c33
-rw-r--r--camel/camel-service.c39
-rw-r--r--camel/camel-service.h6
-rw-r--r--camel/providers/imap/camel-imap-store.c14
-rw-r--r--camel/providers/nntp/camel-nntp-store.c7
-rw-r--r--camel/providers/pop3/camel-pop3-store.c13
-rw-r--r--camel/providers/smtp/camel-smtp-transport.c14
8 files changed, 62 insertions, 80 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index f0b0752b9f..7eea9494ef 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,3 +1,19 @@
+2000-10-31 Dan Winship <danw@helixcode.com>
+
+ * camel-service.c (service_disconnect): Add a new argument, clean,
+ that says whether or not to try to disconnect cleanly.
+
+ * camel-remote-store.c (remote_send_string, remote_send_stream,
+ remote_recv_line): disconnect uncleanly on failure to prevent
+ infinite loops when providers would normally send commands from
+ disconnect(). Remove some unneeded CamelException goo.
+
+ * providers/smtp/camel-smtp-transport.c (smtp_disconnect):
+ * providers/pop3/camel-pop3-store.c (pop3_disconnect):
+ * providers/nntp/camel-nntp-store.c (nntp_store_disconnect):
+ * providers/imap/camel-imap-store.c (imap_disconnect): Don't send
+ QUIT/LOGOUT if !clean.
+
2000-10-30 Dan Winship <danw@helixcode.com>
* providers/imap/camel-imap-auth.c: New file with code for IMAP
diff --git a/camel/camel-remote-store.c b/camel/camel-remote-store.c
index 9d4081e344..a0129763a0 100644
--- a/camel/camel-remote-store.c
+++ b/camel/camel-remote-store.c
@@ -59,7 +59,7 @@ extern gboolean camel_verbose_debug;
static CamelStoreClass *store_class = NULL;
static gboolean remote_connect (CamelService *service, CamelException *ex);
-static gboolean remote_disconnect (CamelService *service, CamelException *ex);
+static gboolean remote_disconnect (CamelService *service, gboolean clean, CamelException *ex);
static GList *remote_query_auth_types_generic (CamelService *service, CamelException *ex);
static GList *remote_query_auth_types_connected (CamelService *service, CamelException *ex);
static void remote_free_auth_types (CamelService *service, GList *authtypes);
@@ -246,15 +246,6 @@ remote_connect (CamelService *service, CamelException *ex)
/* Okay, good enough for us */
CAMEL_SERVICE (store)->connected = TRUE;
- if (camel_exception_is_set (ex)) {
- CamelException dex;
-
- camel_exception_init (&dex);
- camel_service_disconnect (CAMEL_SERVICE (store), &dex);
- camel_exception_clear (&dex);
- return FALSE;
- }
-
/* Add a timeout so that we can hopefully prevent getting disconnected */
/* (Only if the implementation supports it) */
if (CRSC (store)->keepalive) {
@@ -269,7 +260,7 @@ remote_connect (CamelService *service, CamelException *ex)
}
static gboolean
-remote_disconnect (CamelService *service, CamelException *ex)
+remote_disconnect (CamelService *service, gboolean clean, CamelException *ex)
{
CamelRemoteStore *store = CAMEL_REMOTE_STORE (service);
@@ -279,7 +270,7 @@ remote_disconnect (CamelService *service, CamelException *ex)
store->timeout_id = 0;
}
- if (!CAMEL_SERVICE_CLASS (store_class)->disconnect (service, ex))
+ if (!CAMEL_SERVICE_CLASS (store_class)->disconnect (service, clean, ex))
return FALSE;
if (store->istream) {
@@ -331,15 +322,11 @@ remote_send_string (CamelRemoteStore *store, CamelException *ex, char *fmt, va_l
#endif
if (camel_stream_printf (store->ostream, "%s", cmdbuf) == -1) {
- CamelException dex;
-
g_free (cmdbuf);
camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
g_strerror (errno));
- camel_exception_init (&dex);
- camel_service_disconnect (CAMEL_SERVICE (store), &dex);
- camel_exception_clear (&dex);
+ camel_service_disconnect (CAMEL_SERVICE (store), FALSE, NULL);
return -1;
}
g_free (cmdbuf);
@@ -391,14 +378,10 @@ remote_send_stream (CamelRemoteStore *store, CamelStream *stream, CamelException
d(fprintf (stderr, "(sending stream)\n"));
if (camel_stream_write_to_stream (stream, store->ostream) < 0) {
- CamelException dex;
-
camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
g_strerror (errno));
- camel_exception_init (&dex);
- camel_service_disconnect (CAMEL_SERVICE (store), &dex);
- camel_exception_clear (&dex);
+ camel_service_disconnect (CAMEL_SERVICE (store), FALSE, NULL);
return -1;
}
@@ -451,14 +434,10 @@ remote_recv_line (CamelRemoteStore *store, char **dest, CamelException *ex)
*dest = camel_stream_buffer_read_line (stream);
if (!*dest) {
- CamelException dex;
-
camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
g_strerror (errno));
- camel_exception_init (&dex);
- camel_service_disconnect (CAMEL_SERVICE (store), &dex);
- camel_exception_clear (&dex);
+ camel_service_disconnect (CAMEL_SERVICE (store), FALSE, NULL);
return -1;
}
diff --git a/camel/camel-service.c b/camel/camel-service.c
index 14d086653b..5eb78dcaa6 100644
--- a/camel/camel-service.c
+++ b/camel/camel-service.c
@@ -37,7 +37,8 @@ static CamelObjectClass *parent_class = NULL;
#define CSERV_CLASS(so) CAMEL_SERVICE_CLASS (CAMEL_OBJECT_GET_CLASS(so))
static gboolean service_connect(CamelService *service, CamelException *ex);
-static gboolean service_disconnect(CamelService *service, CamelException *ex);
+static gboolean service_disconnect(CamelService *service, gboolean clean,
+ CamelException *ex);
/*static gboolean is_connected (CamelService *service);*/
static GList * query_auth_types_func (CamelService *service, CamelException *ex);
static void free_auth_types (CamelService *service, GList *authtypes);
@@ -72,7 +73,7 @@ camel_service_finalize (CamelObject *object)
/*g_warning ("camel_service_finalize: finalizing while still connected!");*/
camel_exception_init (&ex);
- CSERV_CLASS (camel_service)->disconnect (camel_service, &ex);
+ CSERV_CLASS (camel_service)->disconnect (camel_service, FALSE, &ex);
if (camel_exception_is_set (&ex)) {
g_warning ("camel_service_finalize: silent disconnect failure: %s",
camel_exception_get_description(&ex));
@@ -240,7 +241,7 @@ camel_service_connect (CamelService *service, CamelException *ex)
}
static gboolean
-service_disconnect (CamelService *service, CamelException *ex)
+service_disconnect (CamelService *service, gboolean clean, CamelException *ex)
{
/*service->connect_level--;*/
@@ -254,48 +255,28 @@ service_disconnect (CamelService *service, CamelException *ex)
/**
* camel_service_disconnect:
* @service: CamelService object
+ * @clean: whether or not to try to disconnect cleanly.
* @ex: a CamelException
*
- * Disconnect from the service.
+ * Disconnect from the service. If @clean is %FALSE, it should not
+ * try to do any synchronizing or other cleanup of the connection.
*
* Return value: whether or not the disconnection succeeded without
* errors. (Consult @ex if %FALSE.)
**/
-
gboolean
-camel_service_disconnect (CamelService *service, CamelException *ex)
+camel_service_disconnect (CamelService *service, gboolean clean,
+ CamelException *ex)
{
gboolean res;
g_return_val_if_fail (service->connected, FALSE);
- res = CSERV_CLASS (service)->disconnect (service, ex);
+ res = CSERV_CLASS (service)->disconnect (service, clean, ex);
service->connected = FALSE;
return res;
}
/**
- *static gboolean
- *is_connected (CamelService *service)
- *{
- * return (service->connect_level > 0);
- *}
- **/
-
-/**
- * camel_service_is_connected:
- * @service: object to test
- *
- * Return value: whether or not the service is connected
- **/
-/**
- *gboolean
- *camel_service_is_connected (CamelService *service)
- *{
- * return CSERV_CLASS (service)->is_connected (service);
- *}
- **/
-
-/**
* camel_service_get_url:
* @service: a service
*
diff --git a/camel/camel-service.h b/camel/camel-service.h
index aa52e31755..3666ab71bc 100644
--- a/camel/camel-service.h
+++ b/camel/camel-service.h
@@ -61,7 +61,8 @@ typedef struct {
gboolean (*connect) (CamelService *service,
CamelException *ex);
- gboolean (*disconnect) (CamelService *service,
+ gboolean (*disconnect) (CamelService *service,
+ gboolean clean,
CamelException *ex);
/*gboolean (*is_connected) (CamelService *service);*/
@@ -117,7 +118,8 @@ CamelService * camel_service_new (CamelType type,
CamelException *ex);
gboolean camel_service_connect (CamelService *service,
CamelException *ex);
-gboolean camel_service_disconnect (CamelService *service,
+gboolean camel_service_disconnect (CamelService *service,
+ gboolean clean,
CamelException *ex);
char * camel_service_get_url (CamelService *service);
char * camel_service_get_name (CamelService *service,
diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c
index 749785b724..8d53f7579c 100644
--- a/camel/providers/imap/camel-imap-store.c
+++ b/camel/providers/imap/camel-imap-store.c
@@ -55,7 +55,7 @@
static CamelRemoteStoreClass *remote_store_class = NULL;
static gboolean imap_connect (CamelService *service, CamelException *ex);
-static gboolean imap_disconnect (CamelService *service, CamelException *ex);
+static gboolean imap_disconnect (CamelService *service, gboolean clean, CamelException *ex);
static GList *query_auth_types_generic (CamelService *service, CamelException *ex);
static GList *query_auth_types_connected (CamelService *service, CamelException *ex);
static CamelFolder *get_folder (CamelStore *store, const char *folder_name, guint32 flags, CamelException *ex);
@@ -303,13 +303,13 @@ imap_connect (CamelService *service, CamelException *ex)
"authentication type %s",
service->url->host,
service->url->authmech);
- camel_service_disconnect (service, NULL);
+ camel_service_disconnect (service, TRUE, NULL);
return FALSE;
}
authenticated = imap_try_kerberos_v4_auth (store, ex);
if (camel_exception_is_set (ex)) {
- camel_service_disconnect (service, NULL);
+ camel_service_disconnect (service, TRUE, NULL);
return FALSE;
}
}
@@ -344,7 +344,7 @@ imap_connect (CamelService *service, CamelException *ex)
if (!service->url->passwd) {
camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL,
"You didn\'t enter a password.");
- camel_service_disconnect (service, NULL);
+ camel_service_disconnect (service, TRUE, NULL);
return FALSE;
}
}
@@ -422,12 +422,12 @@ imap_connect (CamelService *service, CamelException *ex)
}
static gboolean
-imap_disconnect (CamelService *service, CamelException *ex)
+imap_disconnect (CamelService *service, gboolean clean, CamelException *ex)
{
CamelImapStore *store = CAMEL_IMAP_STORE (service);
CamelImapResponse *response;
- if (store->connected) {
+ if (store->connected && clean) {
/* send the logout command */
response = camel_imap_command (store, NULL, ex, "LOGOUT");
camel_imap_response_free (response);
@@ -435,7 +435,7 @@ imap_disconnect (CamelService *service, CamelException *ex)
store->current_folder = NULL;
- return CAMEL_SERVICE_CLASS (remote_store_class)->disconnect (service, ex);
+ return CAMEL_SERVICE_CLASS (remote_store_class)->disconnect (service, clean, ex);
}
static gboolean
diff --git a/camel/providers/nntp/camel-nntp-store.c b/camel/providers/nntp/camel-nntp-store.c
index dbba4356be..41466fe06c 100644
--- a/camel/providers/nntp/camel-nntp-store.c
+++ b/camel/providers/nntp/camel-nntp-store.c
@@ -263,16 +263,17 @@ nntp_store_connect (CamelService *service, CamelException *ex)
}
static gboolean
-nntp_store_disconnect (CamelService *service, CamelException *ex)
+nntp_store_disconnect (CamelService *service, gboolean clean, CamelException *ex)
{
CamelNNTPStore *store = CAMEL_NNTP_STORE (service);
- camel_nntp_command (store, ex, NULL, "QUIT");
+ if (clean)
+ camel_nntp_command (store, ex, NULL, "QUIT");
if (store->newsrc)
camel_nntp_newsrc_write (store->newsrc);
- if (!service_class->disconnect (service, ex))
+ if (!service_class->disconnect (service, clean, ex))
return FALSE;
return TRUE;
diff --git a/camel/providers/pop3/camel-pop3-store.c b/camel/providers/pop3/camel-pop3-store.c
index 4932974c16..67d32da796 100644
--- a/camel/providers/pop3/camel-pop3-store.c
+++ b/camel/providers/pop3/camel-pop3-store.c
@@ -69,7 +69,7 @@ static CamelRemoteStoreClass *parent_class = NULL;
static void finalize (CamelObject *object);
static gboolean pop3_connect (CamelService *service, CamelException *ex);
-static gboolean pop3_disconnect (CamelService *service, CamelException *ex);
+static gboolean pop3_disconnect (CamelService *service, gboolean clean, CamelException *ex);
static GList *query_auth_types_connected (CamelService *service, CamelException *ex);
static GList *query_auth_types_generic (CamelService *service, CamelException *ex);
@@ -308,7 +308,7 @@ query_auth_types_connected (CamelService *service, CamelException *ex)
/* should we check apop too? */
apop = store->apop_timestamp != NULL;
if (passwd)
- camel_service_disconnect (service, ex);
+ camel_service_disconnect (service, TRUE, ex);
camel_exception_clear (ex);
#ifdef HAVE_KRB4
@@ -321,7 +321,7 @@ query_auth_types_connected (CamelService *service, CamelException *ex)
/*return NULL;*/
if (kpop)
- camel_service_disconnect (service, ex);
+ camel_service_disconnect (service, TRUE, ex);
camel_exception_clear (ex);
#endif
@@ -526,13 +526,14 @@ pop3_connect (CamelService *service, CamelException *ex)
}
static gboolean
-pop3_disconnect (CamelService *service, CamelException *ex)
+pop3_disconnect (CamelService *service, gboolean clean, CamelException *ex)
{
CamelPop3Store *store = CAMEL_POP3_STORE (service);
- camel_pop3_command (store, NULL, ex, "QUIT");
+ if (clean)
+ camel_pop3_command (store, NULL, ex, "QUIT");
- if (!CAMEL_SERVICE_CLASS (parent_class)->disconnect (service, ex))
+ if (!CAMEL_SERVICE_CLASS (parent_class)->disconnect (service, clean, ex))
return FALSE;
return TRUE;
diff --git a/camel/providers/smtp/camel-smtp-transport.c b/camel/providers/smtp/camel-smtp-transport.c
index 91693bd1f7..62cd0b7525 100644
--- a/camel/providers/smtp/camel-smtp-transport.c
+++ b/camel/providers/smtp/camel-smtp-transport.c
@@ -61,7 +61,7 @@ static gboolean _send_to (CamelTransport *transport, CamelMedium *message, GList
/* support prototypes */
static gboolean smtp_connect (CamelService *service, CamelException *ex);
-static gboolean smtp_disconnect (CamelService *service, CamelException *ex);
+static gboolean smtp_disconnect (CamelService *service, gboolean clean, CamelException *ex);
static GList *esmtp_get_authtypes(gchar *buffer);
static GList *query_auth_types_connected (CamelService *service, CamelException *ex);
static GList *query_auth_types_generic (CamelService *service, CamelException *ex);
@@ -230,18 +230,20 @@ smtp_connect (CamelService *service, CamelException *ex)
}
static gboolean
-smtp_disconnect (CamelService *service, CamelException *ex)
+smtp_disconnect (CamelService *service, gboolean clean, CamelException *ex)
{
CamelSmtpTransport *transport = CAMEL_SMTP_TRANSPORT (service);
/*if (!service->connected)
* return TRUE;
*/
+
+ if (clean) {
+ /* send the QUIT command to the SMTP server */
+ smtp_quit (transport, ex);
+ }
- /* send the QUIT command to the SMTP server */
- smtp_quit (transport, ex);
-
- if (!service_class->disconnect (service, ex))
+ if (!service_class->disconnect (service, clean, ex))
return FALSE;
g_free (transport->esmtp_supported_authtypes);