diff options
author | Not Zed <NotZed@Ximian.com> | 2004-09-24 10:50:45 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2004-09-24 10:50:45 +0800 |
commit | 2223bc36fa7b6b16ff7ea83e39e64e9375e3ebc1 (patch) | |
tree | 47094ce1777a4c6fe98bfc81e70a07a6f9f5414a /camel/providers/imap | |
parent | 6883c5737127983d776b7071c258ae74c9bfb4c1 (diff) | |
download | gsoc2013-evolution-2223bc36fa7b6b16ff7ea83e39e64e9375e3ebc1.tar gsoc2013-evolution-2223bc36fa7b6b16ff7ea83e39e64e9375e3ebc1.tar.gz gsoc2013-evolution-2223bc36fa7b6b16ff7ea83e39e64e9375e3ebc1.tar.bz2 gsoc2013-evolution-2223bc36fa7b6b16ff7ea83e39e64e9375e3ebc1.tar.lz gsoc2013-evolution-2223bc36fa7b6b16ff7ea83e39e64e9375e3ebc1.tar.xz gsoc2013-evolution-2223bc36fa7b6b16ff7ea83e39e64e9375e3ebc1.tar.zst gsoc2013-evolution-2223bc36fa7b6b16ff7ea83e39e64e9375e3ebc1.zip |
** See bug #47821.
2004-09-13 Not Zed <NotZed@Ximian.com>
** See bug #47821.
* camel-service.c: removed the old hostent based hostname interfaces.
* camel-sasl-kerberos4.c (krb4_challenge): new hostname interfaces.
* camel-sasl-gssapi.c (gssapi_challenge): new hostname interfaces.
* camel-sasl-digest-md5.c (digest_md5_challenge): use new hostname
interfaces.
(generate_response): just take hostname directly, not hostent.
* camel-mime-utils.c (camel_header_msgid_generate): use new
hostname interfaces.
* providers/smtp/camel-smtp-transport.c (connect_to_server): fixed
to use new addrinfo apis.
* providers/pop3/camel-pop3-store.c (connect_to_server): fixed to
use new addrinfo apis.
* camel-tcp-stream-ssl.c (stream_connect): try all addresses
supplied.
* camel-tcp-stream.c (camel_tcp_stream_get_remote_address)
(camel_tcp_stream_get_local_address): return a sockaddr now, and
also the address length. Fixed all implementations and callers.
(camel_tcp_stream_connect): use addrinfo rather than hostent for
host AND port info. Fixed all implementations and callers.
svn path=/trunk/; revision=27352
Diffstat (limited to 'camel/providers/imap')
-rw-r--r-- | camel/providers/imap/camel-imap-store.c | 47 |
1 files changed, 28 insertions, 19 deletions
diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c index 85e8b8fc04..54340ca783 100644 --- a/camel/providers/imap/camel-imap-store.c +++ b/camel/providers/imap/camel-imap-store.c @@ -519,51 +519,60 @@ connect_to_server (CamelService *service, int ssl_mode, int try_starttls, CamelE CamelStream *tcp_stream; CamelSockOptData sockopt; gboolean force_imap4 = FALSE; - struct hostent *h; int clean_quit; - int port, ret; + int ret; char *buf; - - if (!(h = camel_service_gethost (service, ex))) - return FALSE; - - port = service->url->port ? service->url->port : 143; + struct addrinfo *ai, hints = { 0 }; + char *serv; + + /* FIXME: this connect stuff is duplicated everywhere */ + + if (service->url->port) { + serv = g_alloca(16); + sprintf(serv, "%d", service->url->port); + } else + serv = "imap"; if (ssl_mode != USE_SSL_NEVER) { #ifdef HAVE_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 : 993; + if (service->url->port == 0) + serv = "imaps"; tcp_stream = camel_tcp_stream_ssl_new (service->session, service->url->host, SSL_PORT_FLAGS); } #else - if (!try_starttls) - port = service->url->port ? service->url->port : 993; + if (!try_starttls && service->url->port == 0) + serv = "imaps"; camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE, - _("Could not connect to %s (port %d): %s"), - service->url->host, port, + _("Could not connect to %s (port %s): %s"), + service->url->host, serv, _("SSL unavailable")); - - camel_free_host (h); - return FALSE; #endif /* HAVE_SSL */ } else { tcp_stream = camel_tcp_stream_raw_new (); } + + hints.ai_socktype = SOCK_STREAM; + ai = camel_getaddrinfo(service->url->host, serv, &hints, ex); + if (ai == NULL) { + camel_object_unref(tcp_stream); + return FALSE; + } - ret = camel_tcp_stream_connect (CAMEL_TCP_STREAM (tcp_stream), h, port); - camel_free_host (h); + ret = camel_tcp_stream_connect(CAMEL_TCP_STREAM(tcp_stream), ai); + camel_freeaddrinfo(ai); if (ret == -1) { if (errno == EINTR) camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL, _("Connection cancelled")); else camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE, - _("Could not connect to %s (port %d): %s"), - service->url->host, port, g_strerror (errno)); + _("Could not connect to %s (port %s): %s"), + service->url->host, serv, g_strerror (errno)); camel_object_unref (tcp_stream); |