aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2002-07-26 06:11:11 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2002-07-26 06:11:11 +0800
commit16fe42c893218a56e9b7fb1cd9418f8569a0f51f (patch)
tree44ccf1c7836589c3c38e61155d72732c5c2f2712
parentcfaa972fcb46ff0d071d367084e910ec91f4f3c4 (diff)
downloadgsoc2013-evolution-16fe42c893218a56e9b7fb1cd9418f8569a0f51f.tar
gsoc2013-evolution-16fe42c893218a56e9b7fb1cd9418f8569a0f51f.tar.gz
gsoc2013-evolution-16fe42c893218a56e9b7fb1cd9418f8569a0f51f.tar.bz2
gsoc2013-evolution-16fe42c893218a56e9b7fb1cd9418f8569a0f51f.tar.lz
gsoc2013-evolution-16fe42c893218a56e9b7fb1cd9418f8569a0f51f.tar.xz
gsoc2013-evolution-16fe42c893218a56e9b7fb1cd9418f8569a0f51f.tar.zst
gsoc2013-evolution-16fe42c893218a56e9b7fb1cd9418f8569a0f51f.zip
Remove "possibly non-fatal" exception strings, all exceptions are fatal
2002-07-25 Jeffrey Stedfast <fejj@ximian.com> * providers/smtp/camel-smtp-transport.c: Remove "possibly non-fatal" exception strings, all exceptions are fatal unless their caller decides otherwise. (connect_to_server): If smtp_helo() fails due to us getting disconnected, treat the exception as fatal. (smtp_connect): Abort if smtp_helo() fails and we got disconnected. (smtp_send_to): If smtp_mail() fails, abort the send operation. (smtp_set_exception): If respbuf was NULL, then we got disconnected and so update our state accordingly. (smtp_disconnect): Only send a QUIT if we are still in the connected state (or, at least think we are). svn path=/trunk/; revision=17595
-rw-r--r--camel/ChangeLog30
-rw-r--r--camel/providers/smtp/camel-smtp-transport.c137
-rw-r--r--camel/providers/smtp/camel-smtp-transport.h1
3 files changed, 125 insertions, 43 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index 5fcb8b2e84..4234616488 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,12 +1,28 @@
+2002-07-25 Jeffrey Stedfast <fejj@ximian.com>
+
+ * providers/smtp/camel-smtp-transport.c: Remove "possibly
+ non-fatal" exception strings, all exceptions are fatal unless
+ their caller decides otherwise.
+ (connect_to_server): If smtp_helo() fails due to us getting
+ disconnected, treat the exception as fatal.
+ (smtp_connect): Abort if smtp_helo() fails and we got
+ disconnected.
+ (smtp_send_to): If smtp_mail() fails, abort the send operation.
+ (smtp_set_exception): If respbuf was NULL, then we got
+ disconnected and so update our state accordingly.
+ (smtp_disconnect): Only send a QUIT if we are still in the
+ connected state (or, at least think we are).
+
2002-07-24 Peter Williams <peterw@ximian.com>
- * providers/imap/camel-imap-folder.c (imap_expunge_uids_resyncing): It
- would help to mark the UIDs as deleted before we try to expunge them
- (in the case when no other UIDs were marked deleted this didn't happen.)
- Also fix an FMR.
- (imap_expunge_uids_offline): Trigger a folder_changed event with our
- own changeinfo because camel_imap_response_free won't be able to do that
- for us.
+ * providers/imap/camel-imap-folder.c
+ (imap_expunge_uids_resyncing): It would help to mark the UIDs as
+ deleted before we try to expunge them
+ (in the case when no other UIDs were marked deleted this didn't
+ happen.) Also fix an FMR.
+ (imap_expunge_uids_offline): Trigger a folder_changed event with
+ our own changeinfo because camel_imap_response_free won't be able
+ to do that for us.
2002-07-25 Jeffrey Stedfast <fejj@ximian.com>
diff --git a/camel/providers/smtp/camel-smtp-transport.c b/camel/providers/smtp/camel-smtp-transport.c
index 363c5ecc1f..ef7ce57fa3 100644
--- a/camel/providers/smtp/camel-smtp-transport.c
+++ b/camel/providers/smtp/camel-smtp-transport.c
@@ -118,6 +118,7 @@ camel_smtp_transport_init (gpointer object)
CamelSmtpTransport *smtp = CAMEL_SMTP_TRANSPORT (object);
smtp->flags = 0;
+ smtp->connected = FALSE;
}
CamelType
@@ -126,15 +127,14 @@ camel_smtp_transport_get_type (void)
static CamelType type = CAMEL_INVALID_TYPE;
if (type == CAMEL_INVALID_TYPE) {
- type =
- camel_type_register (CAMEL_TRANSPORT_TYPE,
- "CamelSmtpTransport",
- sizeof (CamelSmtpTransport),
- sizeof (CamelSmtpTransportClass),
- (CamelObjectClassInitFunc) camel_smtp_transport_class_init,
- NULL,
- (CamelObjectInitFunc) camel_smtp_transport_init,
- NULL);
+ type = camel_type_register (CAMEL_TRANSPORT_TYPE,
+ "CamelSmtpTransport",
+ sizeof (CamelSmtpTransport),
+ sizeof (CamelSmtpTransportClass),
+ (CamelObjectClassInitFunc) camel_smtp_transport_class_init,
+ NULL,
+ (CamelObjectInitFunc) camel_smtp_transport_init,
+ NULL);
}
return type;
@@ -282,6 +282,8 @@ connect_to_server (CamelService *service, int try_starttls, CamelException *ex)
return FALSE;
}
+ transport->connected = TRUE;
+
/* get the localaddr - needed later by smtp_helo */
transport->localaddr = camel_tcp_stream_get_local_address (CAMEL_TCP_STREAM (tcp_stream));
@@ -294,13 +296,8 @@ connect_to_server (CamelService *service, int try_starttls, CamelException *ex)
g_free (respbuf);
respbuf = camel_stream_buffer_read_line (CAMEL_STREAM_BUFFER (transport->istream));
if (!respbuf || strncmp (respbuf, "220", 3)) {
- int error;
-
- error = respbuf ? atoi (respbuf) : 0;
+ smtp_set_exception (transport, respbuf, _("Welcome response error"), ex);
g_free (respbuf);
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Welcome response error: %s: possibly non-fatal"),
- smtp_error_string (error));
return FALSE;
}
if (strstr (respbuf, "ESMTP"))
@@ -312,14 +309,20 @@ connect_to_server (CamelService *service, int try_starttls, CamelException *ex)
if (!(transport->flags & CAMEL_SMTP_TRANSPORT_IS_ESMTP)) {
/* If we did not auto-detect ESMTP, we should still send EHLO */
transport->flags |= CAMEL_SMTP_TRANSPORT_IS_ESMTP;
- if (!smtp_helo (transport, NULL)) {
+ if (!smtp_helo (transport, ex)) {
+ if (!transport->connected)
+ return FALSE;
+
/* Okay, apprently this server doesn't support ESMTP */
+ camel_exception_clear (ex);
transport->flags &= ~CAMEL_SMTP_TRANSPORT_IS_ESMTP;
- smtp_helo (transport, ex);
+ if (!smtp_helo (transport, ex) && !transport->connected)
+ return FALSE;
}
} else {
/* send EHLO */
- smtp_helo (transport, ex);
+ if (!smtp_helo (transport, ex) && !transport->connected)
+ return FALSE;
}
#ifdef HAVE_SSL
@@ -385,6 +388,8 @@ connect_to_server (CamelService *service, int try_starttls, CamelException *ex)
camel_object_unref (CAMEL_OBJECT (transport->ostream));
transport->ostream = NULL;
+ transport->connected = FALSE;
+
return FALSE;
#endif /* HAVE_SSL */
}
@@ -528,7 +533,10 @@ smtp_connect (CamelService *service, CamelException *ex)
* we won't bother to name don't want you to... so ignore
* errors.
*/
- smtp_helo (transport, NULL);
+ if (!smtp_helo (transport, ex) && !transport->connected)
+ return FALSE;
+
+ camel_exception_clear (ex);
}
return TRUE;
@@ -549,7 +557,7 @@ smtp_disconnect (CamelService *service, gboolean clean, CamelException *ex)
* return TRUE;
*/
- if (clean) {
+ if (transport->connected && clean) {
/* send the QUIT command to the SMTP server */
smtp_quit (transport, ex);
}
@@ -563,14 +571,21 @@ smtp_disconnect (CamelService *service, gboolean clean, CamelException *ex)
transport->authtypes = NULL;
}
- camel_object_unref (CAMEL_OBJECT (transport->ostream));
- camel_object_unref (CAMEL_OBJECT (transport->istream));
- transport->ostream = NULL;
- transport->istream = NULL;
+ if (transport->istream) {
+ camel_object_unref (CAMEL_OBJECT (transport->istream));
+ transport->istream = NULL;
+ }
+
+ if (transport->ostream) {
+ camel_object_unref (CAMEL_OBJECT (transport->ostream));
+ transport->ostream = NULL;
+ }
camel_tcp_address_free (transport->localaddr);
transport->localaddr = NULL;
+ transport->connected = FALSE;
+
return TRUE;
}
@@ -672,7 +687,10 @@ smtp_send_to (CamelTransport *transport, CamelMimeMessage *message,
/* rfc1652 (8BITMIME) requires that you notify the ESMTP daemon that
you'll be sending an 8bit mime message at "MAIL FROM:" time. */
- smtp_mail (smtp_transport, addr, has_8bit_parts, ex);
+ if (!smtp_mail (smtp_transport, addr, has_8bit_parts, ex)) {
+ camel_operation_end (NULL);
+ return FALSE;
+ }
if (!recipients) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
@@ -790,8 +808,7 @@ smtp_set_exception (CamelSmtpTransport *transport, const char *respbuf, const ch
if (!respbuf || !(transport->flags & CAMEL_SMTP_TRANSPORT_ENHANCEDSTATUSCODES)) {
fake_status_code:
error = respbuf ? atoi (respbuf) : 0;
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- "%s: %s", message,
+ camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, "%s: %s", message,
smtp_error_string (error));
} else {
string = g_string_new ("");
@@ -825,6 +842,11 @@ smtp_set_exception (CamelSmtpTransport *transport, const char *respbuf, const ch
g_free (buffer);
}
+
+ if (!respbuf) {
+ /* we got disconnected */
+ transport->connected = FALSE;
+ }
}
static gboolean
@@ -867,9 +889,15 @@ smtp_helo (CamelSmtpTransport *transport, CamelException *ex)
if (camel_stream_write (transport->ostream, cmdbuf, strlen (cmdbuf)) == -1) {
g_free (cmdbuf);
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("HELO request timed out: %s: non-fatal"),
+ _("HELO request timed out: %s"),
g_strerror (errno));
camel_operation_end (NULL);
+
+ camel_object_unref (transport->istream);
+ transport->istream = NULL;
+ camel_object_unref (transport->ostream);
+ transport->ostream = NULL;
+
return FALSE;
}
g_free (cmdbuf);
@@ -882,14 +910,10 @@ smtp_helo (CamelSmtpTransport *transport, CamelException *ex)
d(fprintf (stderr, "received: %s\n", respbuf ? respbuf : "(null)"));
if (!respbuf || strncmp (respbuf, "250", 3)) {
- int error;
-
- error = respbuf ? atoi (respbuf) : 0;
- g_free (respbuf);
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("HELO response error: %s: non-fatal"),
- smtp_error_string (error));
+ smtp_set_exception (transport, respbuf, _("HELO response error"), ex);
camel_operation_end (NULL);
+ g_free (respbuf);
+
return FALSE;
}
@@ -1084,6 +1108,12 @@ smtp_mail (CamelSmtpTransport *transport, const char *sender, gboolean has_8bit_
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("MAIL FROM request timed out: %s: mail not sent"),
g_strerror (errno));
+
+ camel_object_unref (transport->istream);
+ transport->istream = NULL;
+ camel_object_unref (transport->ostream);
+ transport->ostream = NULL;
+
return FALSE;
}
g_free (cmdbuf);
@@ -1122,6 +1152,12 @@ smtp_rcpt (CamelSmtpTransport *transport, const char *recipient, CamelException
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("RCPT TO request timed out: %s: mail not sent"),
g_strerror (errno));
+
+ camel_object_unref (transport->istream);
+ transport->istream = NULL;
+ camel_object_unref (transport->ostream);
+ transport->ostream = NULL;
+
return FALSE;
}
g_free (cmdbuf);
@@ -1180,6 +1216,12 @@ smtp_data (CamelSmtpTransport *transport, CamelMimeMessage *message, gboolean ha
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("DATA request timed out: %s: mail not sent"),
g_strerror (errno));
+
+ camel_object_unref (transport->istream);
+ transport->istream = NULL;
+ camel_object_unref (transport->ostream);
+ transport->ostream = NULL;
+
return FALSE;
}
g_free (cmdbuf);
@@ -1238,6 +1280,11 @@ smtp_data (CamelSmtpTransport *transport, CamelMimeMessage *message, gboolean ha
camel_object_unref (CAMEL_OBJECT (filtered_stream));
+ camel_object_unref (transport->istream);
+ transport->istream = NULL;
+ camel_object_unref (transport->ostream);
+ transport->ostream = NULL;
+
return FALSE;
}
@@ -1253,6 +1300,12 @@ smtp_data (CamelSmtpTransport *transport, CamelMimeMessage *message, gboolean ha
_("DATA send timed out: message termination: "
"%s: mail not sent"),
g_strerror (errno));
+
+ camel_object_unref (transport->istream);
+ transport->istream = NULL;
+ camel_object_unref (transport->ostream);
+ transport->ostream = NULL;
+
return FALSE;
}
@@ -1289,6 +1342,12 @@ smtp_rset (CamelSmtpTransport *transport, CamelException *ex)
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("RSET request timed out: %s"),
g_strerror (errno));
+
+ camel_object_unref (transport->istream);
+ transport->istream = NULL;
+ camel_object_unref (transport->ostream);
+ transport->ostream = NULL;
+
return FALSE;
}
g_free (cmdbuf);
@@ -1324,8 +1383,14 @@ smtp_quit (CamelSmtpTransport *transport, CamelException *ex)
if (camel_stream_write (transport->ostream, cmdbuf, strlen (cmdbuf)) == -1) {
g_free (cmdbuf);
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("QUIT request timed out: %s: non-fatal"),
+ _("QUIT request timed out: %s"),
g_strerror (errno));
+
+ camel_object_unref (transport->istream);
+ transport->istream = NULL;
+ camel_object_unref (transport->ostream);
+ transport->ostream = NULL;
+
return FALSE;
}
g_free (cmdbuf);
diff --git a/camel/providers/smtp/camel-smtp-transport.h b/camel/providers/smtp/camel-smtp-transport.h
index 0a57213c8d..9874eb09c3 100644
--- a/camel/providers/smtp/camel-smtp-transport.h
+++ b/camel/providers/smtp/camel-smtp-transport.h
@@ -62,6 +62,7 @@ typedef struct {
guint32 flags;
+ gboolean connected;
CamelTcpAddress *localaddr;
GHashTable *authtypes;