[evolution-data-server/camel-socks-proxy: 93/94] Change CamelPOP3Store to use the new API
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/camel-socks-proxy: 93/94] Change CamelPOP3Store to use the new API
- Date: Fri, 9 Jul 2010 22:54:39 +0000 (UTC)
commit 6ac81dfc11582f5a6221cdfa6cace9aacc86e778
Author: Federico Mena Quintero <federico novell com>
Date: Fri Jul 9 17:55:28 2010 -0500
Change CamelPOP3Store to use the new API
Signed-off-by: Federico Mena Quintero <federico novell com>
camel/providers/pop3/camel-pop3-store.c | 59 ++++++++++++-------------------
1 files changed, 23 insertions(+), 36 deletions(-)
---
diff --git a/camel/providers/pop3/camel-pop3-store.c b/camel/providers/pop3/camel-pop3-store.c
index 08efed9..6cde5c4 100644
--- a/camel/providers/pop3/camel-pop3-store.c
+++ b/camel/providers/pop3/camel-pop3-store.c
@@ -57,8 +57,8 @@
#endif
/* Specified in RFC 1939 */
-#define POP3_PORT "110"
-#define POP3S_PORT "995"
+#define POP3_PORT 110
+#define POP3S_PORT 995
/* defines the length of the server error message we can display in the error dialog */
#define POP3_ERROR_SIZE_LIMIT 60
@@ -170,7 +170,7 @@ get_valid_utf8_error (const gchar *text)
}
static gboolean
-connect_to_server (CamelService *service, struct addrinfo *ai, gint ssl_mode, CamelException *ex)
+connect_to_server (CamelService *service, const char *host, const char *serv, gint fallback_port, gint ssl_mode, CamelException *ex)
{
CamelPOP3Store *store = CAMEL_POP3_STORE (service);
CamelSession *session;
@@ -208,15 +208,19 @@ connect_to_server (CamelService *service, struct addrinfo *ai, gint ssl_mode, Ca
g_free (socks_host);
}
- if ((ret = camel_tcp_stream_connect ((CamelTcpStream *) tcp_stream, ai)) == -1) {
- if (errno == EINTR)
- camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL,
- _("Connection canceled"));
- else
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- _("Could not connect to %s: %s"),
- service->url->host,
- g_strerror (errno));
+ if ((ret = camel_tcp_stream_connect ((CamelTcpStream *) tcp_stream, host, serv, fallback_port, ex)) == -1) {
+ gint saved_errno;
+
+ saved_errno = errno;
+ if (!camel_exception_is_set (ex)) {
+ if (saved_errno == EINTR)
+ camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL,
+ _("Connection canceled"));
+ else
+ camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
+ _("Could not connect to %s: %s"),
+ host, g_strerror (saved_errno));
+ }
camel_object_unref (tcp_stream);
@@ -321,7 +325,7 @@ connect_to_server (CamelService *service, struct addrinfo *ai, gint ssl_mode, Ca
static struct {
const gchar *value;
const gchar *serv;
- const gchar *port;
+ gint fallback_port;
gint mode;
} ssl_options[] = {
{ "", "pop3s", POP3S_PORT, MODE_SSL }, /* really old (1.x) */
@@ -334,11 +338,10 @@ static struct {
static gboolean
connect_to_server_wrapper (CamelService *service, CamelException *ex)
{
- struct addrinfo hints, *ai;
const gchar *ssl_mode;
- gint mode, ret, i;
+ gint mode, i;
gchar *serv;
- const gchar *port;
+ gint fallback_port;
if ((ssl_mode = camel_url_get_param (service->url, "use_ssl"))) {
for (i = 0; ssl_options[i].value; i++)
@@ -346,36 +349,20 @@ connect_to_server_wrapper (CamelService *service, CamelException *ex)
break;
mode = ssl_options[i].mode;
serv = (gchar *) ssl_options[i].serv;
- port = ssl_options[i].port;
+ fallback_port = ssl_options[i].fallback_port;
} else {
mode = MODE_CLEAR;
serv = (gchar *) "pop3";
- port = POP3S_PORT;
+ fallback_port = POP3S_PORT;
}
if (service->url->port) {
serv = g_alloca (16);
sprintf (serv, "%d", service->url->port);
- port = NULL;
- }
-
- memset (&hints, 0, sizeof (hints));
- hints.ai_socktype = SOCK_STREAM;
- hints.ai_family = PF_UNSPEC;
- ai = camel_getaddrinfo(service->url->host, serv, &hints, ex);
- if (ai == NULL && port != NULL && camel_exception_get_id(ex) != CAMEL_EXCEPTION_USER_CANCEL) {
- camel_exception_clear (ex);
- ai = camel_getaddrinfo(service->url->host, port, &hints, ex);
+ fallback_port = 0;
}
- if (ai == NULL)
- return FALSE;
-
- ret = connect_to_server (service, ai, mode, ex);
-
- camel_freeaddrinfo (ai);
-
- return ret;
+ return connect_to_server (service, service->url->host, serv, fallback_port, mode, ex);
}
extern CamelServiceAuthType camel_pop3_password_authtype;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]