diff options
author | Jeffrey Stedfast <fejj@novell.com> | 2004-09-28 01:41:16 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2004-09-28 01:41:16 +0800 |
commit | e5e0149bb66b663bba92c0eb8dd7dfbe6e33d9fa (patch) | |
tree | 652e325cf8c7c28bb03682bb9021ad79f0834986 /camel/providers/imapp | |
parent | c3a9a32b59ef4fb590e8a2232177630891b46b71 (diff) | |
download | gsoc2013-evolution-e5e0149bb66b663bba92c0eb8dd7dfbe6e33d9fa.tar gsoc2013-evolution-e5e0149bb66b663bba92c0eb8dd7dfbe6e33d9fa.tar.gz gsoc2013-evolution-e5e0149bb66b663bba92c0eb8dd7dfbe6e33d9fa.tar.bz2 gsoc2013-evolution-e5e0149bb66b663bba92c0eb8dd7dfbe6e33d9fa.tar.lz gsoc2013-evolution-e5e0149bb66b663bba92c0eb8dd7dfbe6e33d9fa.tar.xz gsoc2013-evolution-e5e0149bb66b663bba92c0eb8dd7dfbe6e33d9fa.tar.zst gsoc2013-evolution-e5e0149bb66b663bba92c0eb8dd7dfbe6e33d9fa.zip |
Instead of doing a host-lookup ourselves, get it passed in to us as an
2004-09-22 Jeffrey Stedfast <fejj@novell.com>
* providers/imap/camel-imap-store.c (connect_to_server): Instead
of doing a host-lookup ourselves, get it passed in to us as an
argument. Also simplified a bit (try_starttls is no longer an
option).
(connect_to_server_wrapper): Simplified (we no longer have
fallback cases for SSL stuff). Also, perform host lookup here.
* providers/imap4/camel-imap4-store.c: Same changes as above.
* providers/pop3/camel-pop3-store.c: Same.
* providers/smtp/camel-smtp-transport.c: Same. Other changes
include making the code consistant with the other providers.
* providers/nntp/camel-nntp-store.c: Same as pop/imap.
svn path=/trunk/; revision=27398
Diffstat (limited to 'camel/providers/imapp')
-rw-r--r-- | camel/providers/imapp/camel-imapp-store.c | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/camel/providers/imapp/camel-imapp-store.c b/camel/providers/imapp/camel-imapp-store.c index 3c0dac5456..00ba0d00ce 100644 --- a/camel/providers/imapp/camel-imapp-store.c +++ b/camel/providers/imapp/camel-imapp-store.c @@ -190,29 +190,32 @@ connect_to_server (CamelService *service, int ssl_mode, int try_starttls) CamelIMAPPStore *store = CAMEL_IMAPP_STORE (service); CamelStream * volatile tcp_stream = NULL; CamelIMAPPStream * volatile imap_stream = NULL; - struct hostent *h = NULL; - int ret, port; + int ret; CamelException *ex; ex = camel_exception_new(); CAMEL_TRY { + char *serv; + struct addrinfo *ai, hints = { 0 }; + /* parent class connect initialization */ CAMEL_SERVICE_CLASS (parent_class)->connect (service, ex); if (ex->id) camel_exception_throw_ex(ex); - h = camel_service_gethost(service, ex); - if (ex->id) - camel_exception_throw_ex(ex); - - port = service->url->port ? service->url->port : IMAP_PORT; - + if (service->url->port) { + serv = g_alloca(16); + sprintf(serv, "%d", service->url->port); + } else + serv = "imap"; + #ifdef HAVE_SSL if (camel_url_get_param (service->url, "use_ssl")) { if (try_starttls) tcp_stream = camel_tcp_stream_ssl_new_raw (service->session, service->url->host, STARTTLS_FLAGS); else { - port = service->url->port ? service->url->port : 995; + if (service->url->port == 0) + serv = "imaps"; tcp_stream = camel_tcp_stream_ssl_new (service->session, service->url->host, SSL_PORT_FLAGS); } } else { @@ -221,16 +224,21 @@ connect_to_server (CamelService *service, int ssl_mode, int try_starttls) #else tcp_stream = camel_tcp_stream_raw_new (); #endif /* HAVE_SSL */ - - ret = camel_tcp_stream_connect (CAMEL_TCP_STREAM (tcp_stream), h, port); - camel_free_host (h); + + hints.ai_socktype = SOCK_STREAM; + ai = camel_getaddrinfo(service->url->host, serv, &hints, ex); + if (ex->id) + camel_exception_throw_ex(ex); + + ret = camel_tcp_stream_connect(CAMEL_TCP_STREAM(tcp_stream), ai); + camel_freeaddrinfo(ai); if (ret == -1) { if (errno == EINTR) camel_exception_throw(CAMEL_EXCEPTION_USER_CANCEL, _("Connection cancelled")); else camel_exception_throw(CAMEL_EXCEPTION_SERVICE_UNAVAILABLE, - _("Could not connect to %s (port %d): %s"), - service->url->host, port, strerror(errno)); + _("Could not connect to %s (port %s): %s"), + service->url->host, serv, strerror(errno)); } imap_stream = (CamelIMAPPStream *)camel_imapp_stream_new(tcp_stream); |