From 174adfa471581f0a322b4e381d9671b2b50ac9d4 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Wed, 14 Mar 2001 21:59:40 +0000 Subject: Numerous fixes to get it to build correctly with NSS enabled. 2001-03-14 Jeffrey Stedfast * camel-tcp-stream-ssl.c: Numerous fixes to get it to build correctly with NSS enabled. * camel-remote-store.c (remote_connect): Pass in the session and expected host args, oops. * camel-provider.h (CAMEL_URL_ALLOW_SSL): Defined. * providers/imap/camel-imap-store.c (camel_imap_store_init): Check to see if we are supposed to use SSL and set the options accordingly. (imap_connect): Return FALSE here instead of NULL. * providers/imap/camel-imap-provider.c: Add CAMEL_URL_ALLOW_SSL. * providers/imap/libcamelimap.urls: Add "imaps" which is the protocol for Secure IMAP. svn path=/trunk/; revision=8711 --- camel/ChangeLog | 20 ++++++++++++++++++++ camel/Makefile.am | 6 +++++- camel/camel-provider.h | 2 ++ camel/camel-remote-store.c | 2 +- camel/camel-tcp-stream-ssl.c | 19 +++++++++++-------- camel/camel-tcp-stream.c | 2 +- camel/providers/imap/camel-imap-provider.c | 3 ++- camel/providers/imap/camel-imap-store.c | 17 +++++++++++++---- camel/providers/imap/libcamelimap.urls | 1 + 9 files changed, 56 insertions(+), 16 deletions(-) diff --git a/camel/ChangeLog b/camel/ChangeLog index 29463c3f0b..43c70baec2 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,3 +1,23 @@ +2001-03-14 Jeffrey Stedfast + + * camel-tcp-stream-ssl.c: Numerous fixes to get it to build + correctly with NSS enabled. + + * camel-remote-store.c (remote_connect): Pass in the session and + expected host args, oops. + + * camel-provider.h (CAMEL_URL_ALLOW_SSL): Defined. + + * providers/imap/camel-imap-store.c (camel_imap_store_init): Check + to see if we are supposed to use SSL and set the options + accordingly. + (imap_connect): Return FALSE here instead of NULL. + + * providers/imap/camel-imap-provider.c: Add CAMEL_URL_ALLOW_SSL. + + * providers/imap/libcamelimap.urls: Add "imaps" which is the + protocol for Secure IMAP. + 2001-03-14 Jeffrey Stedfast * camel-tcp-stream-openssl.[c,h]: Added diff --git a/camel/Makefile.am b/camel/Makefile.am index cd544eb019..8c77f7fad6 100644 --- a/camel/Makefile.am +++ b/camel/Makefile.am @@ -14,6 +14,8 @@ INCLUDES = -I.. -I$(srcdir)/.. -I$(includedir) \ $(GNOME_XML_CFLAGS) \ $(UNICODE_CFLAGS) \ $(KRB4_CFLAGS) \ + $(NSPR_CFLAGS) \ + $(NSS_CFLAGS) \ -DCAMEL_PROVIDERDIR=\""$(providerdir)"\" \ -DG_LOG_DOMAIN=\"camel\" @@ -158,7 +160,9 @@ libcamel_la_LDFLAGS = -version-info 0:0:0 -rpath $(libdir) libcamel_la_LIBADD = $(top_builddir)/e-util/libeutil.la \ $(UNICODE_LIBS) \ - $(KRB4_LDFLAGS) + $(KRB4_LDFLAGS) \ + $(NSPR_LDFLAGS) \ + $(NSS_LDFLAGS) noinst_HEADERS = \ diff --git a/camel/camel-provider.h b/camel/camel-provider.h index 07d62106ea..f6c588270d 100644 --- a/camel/camel-provider.h +++ b/camel/camel-provider.h @@ -78,6 +78,8 @@ extern char *camel_provider_type_name[CAMEL_NUM_PROVIDER_TYPES]; #define CAMEL_URL_PATH_IS_ABSOLUTE (1 << 12) +#define CAMEL_URL_ALLOW_SSL (1 << 13) + typedef struct { /* Provider name used in CamelURLs. */ char *protocol; diff --git a/camel/camel-remote-store.c b/camel/camel-remote-store.c index 681aca0113..3f66d6a462 100644 --- a/camel/camel-remote-store.c +++ b/camel/camel-remote-store.c @@ -218,7 +218,7 @@ remote_connect (CamelService *service, CamelException *ex) #ifdef HAVE_NSS if (store->use_ssl) - tcp_stream = camel_tcp_stream_ssl_new (); + tcp_stream = camel_tcp_stream_ssl_new (service->session, service->url->host); else tcp_stream = camel_tcp_stream_raw_new (); #else diff --git a/camel/camel-tcp-stream-ssl.c b/camel/camel-tcp-stream-ssl.c index 8d4ac47746..42c50eccca 100644 --- a/camel/camel-tcp-stream-ssl.c +++ b/camel/camel-tcp-stream-ssl.c @@ -31,7 +31,10 @@ #include #include #include -#include +#include +#include +#include +#include #include #include @@ -194,13 +197,13 @@ stream_write (CamelStream *stream, const char *buffer, size_t n) static int stream_flush (CamelStream *stream) { - return PR_Fsync (((CamelTcpStreamSSL *)stream)->sockfd); + return PR_Sync (((CamelTcpStreamSSL *)stream)->sockfd); } static int stream_close (CamelStream *stream) { - if (PR_Close (((CamelTcpStreamSSL *)stream)->sockfd) == PR_Failure) + if (PR_Close (((CamelTcpStreamSSL *)stream)->sockfd) == PR_FAILURE) return -1; ((CamelTcpStreamSSL *)stream)->sockfd = NULL; @@ -229,7 +232,7 @@ ssl_bad_cert (void *data, PRFileDesc *fd) session = CAMEL_SESSION (data); /* FIXME: International issues here?? */ - len = PR_GetErrorTextLen (PR_GetError ()); + len = PR_GetErrorTextLength (); string = g_malloc0 (len + 1); PR_GetErrorText (string); @@ -246,7 +249,7 @@ static int stream_connect (CamelTcpStream *stream, struct hostent *host, int port) { CamelTcpStreamSSL *ssl = CAMEL_TCP_STREAM_SSL (stream); - PRIntervalTime timeout; + PRIntervalTime timeout = PR_INTERVAL_MIN; PRNetAddr netaddr; PRFileDesc *fd, *ssl_fd; @@ -255,13 +258,13 @@ stream_connect (CamelTcpStream *stream, struct hostent *host, int port) memset ((void *) &netaddr, 0, sizeof (PRNetAddr)); memcpy (&netaddr.inet.ip, host->h_addr, sizeof (netaddr.inet.ip)); - if (PR_InitializeNetAddr (PR_IpAddrNull, port, &netaddr) == PR_FAILUE) + if (PR_InitializeNetAddr (PR_IpAddrNull, port, &netaddr) == PR_FAILURE) return -1; fd = PR_OpenTCPSocket (host->h_addrtype); ssl_fd = SSL_ImportFD (NULL, fd); - SSL_SetUrl (ssl_fd, ssl->expected_host); + SSL_SetURL (ssl_fd, ssl->expected_host); if (ssl_fd == NULL || PR_Connect (ssl_fd, &netaddr, timeout) == PR_FAILURE) { if (ssl_fd != NULL) @@ -303,7 +306,7 @@ stream_setsockopt (CamelTcpStream *stream, const CamelSockOptData *data) memset ((void *) &sodata, 0, sizeof (sodata)); memcpy ((void *) &sodata, (void *) data, sizeof (CamelSockOptData)); - if (PR_SetSocketOption (((CamelTcpStreamRaw *)stream)->sockfd, &sodata) == PR_FAILURE) + if (PR_SetSocketOption (((CamelTcpStreamSSL *)stream)->sockfd, &sodata) == PR_FAILURE) return -1; return 0; diff --git a/camel/camel-tcp-stream.c b/camel/camel-tcp-stream.c index 6edd545a1f..f42fa0f1d5 100644 --- a/camel/camel-tcp-stream.c +++ b/camel/camel-tcp-stream.c @@ -40,7 +40,7 @@ camel_tcp_stream_class_init (CamelTcpStreamClass *camel_tcp_stream_class) CamelStreamClass *camel_stream_class = CAMEL_STREAM_CLASS (camel_tcp_stream_class); - parent_class = CAMEL_STREAM_CLASS( camel_type_get_global_classfuncs( CAMEL_STREAM_TYPE ) ); + parent_class = CAMEL_STREAM_CLASS (camel_type_get_global_classfuncs (CAMEL_STREAM_TYPE)); /* tcp stream methods */ camel_tcp_stream_class->connect = tcp_connect; diff --git a/camel/providers/imap/camel-imap-provider.c b/camel/providers/imap/camel-imap-provider.c index 9b962df5f4..91f397277a 100644 --- a/camel/providers/imap/camel-imap-provider.c +++ b/camel/providers/imap/camel-imap-provider.c @@ -46,7 +46,8 @@ static CamelProvider imap_provider = { CAMEL_PROVIDER_IS_STORAGE, CAMEL_URL_NEED_USER | CAMEL_URL_NEED_HOST | - CAMEL_URL_ALLOW_PATH | CAMEL_URL_ALLOW_AUTH, + CAMEL_URL_ALLOW_PATH | CAMEL_URL_ALLOW_AUTH | + CAMEL_URL_ALLOW_SSL, { 0, 0 }, diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c index c13a584a33..db1c1f9c80 100644 --- a/camel/providers/imap/camel-imap-store.c +++ b/camel/providers/imap/camel-imap-store.c @@ -144,9 +144,18 @@ camel_imap_store_init (gpointer object, gpointer klass) CamelRemoteStore *remote_store = CAMEL_REMOTE_STORE (object); CamelImapStore *imap_store = CAMEL_IMAP_STORE (object); CamelStore *store = CAMEL_STORE (object); + CamelURL *url; + + url = CAMEL_SERVICE (store)->url; + + if (!g_strcasecmp (url->protocol, "imaps")) { + remote_store->default_port = 993; + remote_store->use_ssl = TRUE; + } else { + remote_store->default_port = 143; + remote_store->use_ssl = FALSE; + } - remote_store->default_port = 143; - imap_store->dir_sep = '\0'; imap_store->current_folder = NULL; @@ -155,7 +164,7 @@ camel_imap_store_init (gpointer object, gpointer klass) imap_store->connected = FALSE; imap_store->subscribed_folders = NULL; - imap_store->priv = g_malloc0(sizeof(*imap_store->priv)); + imap_store->priv = g_malloc0 (sizeof (*imap_store->priv)); #ifdef ENABLE_THREADS imap_store->priv->command_lock = e_mutex_new(E_MUTEX_REC); #endif @@ -469,7 +478,7 @@ imap_connect (CamelService *service, CamelException *ex) * a bad password. So reconnect here. */ if (!connect_to_server (service, ex)) - return NULL; + return FALSE; } if (authtype) diff --git a/camel/providers/imap/libcamelimap.urls b/camel/providers/imap/libcamelimap.urls index c301c0ffac..cf07f4426f 100644 --- a/camel/providers/imap/libcamelimap.urls +++ b/camel/providers/imap/libcamelimap.urls @@ -1 +1,2 @@ imap +imaps -- cgit v1.2.3