aboutsummaryrefslogtreecommitdiffstats
path: root/camel
diff options
context:
space:
mode:
Diffstat (limited to 'camel')
-rw-r--r--camel/ChangeLog17
-rw-r--r--camel/camel-provider.c22
-rw-r--r--camel/camel-provider.h2
-rw-r--r--camel/camel-session.c3
-rw-r--r--camel/camel.c22
-rw-r--r--camel/camel.h2
-rw-r--r--camel/providers/imap/camel-imap-provider.c41
7 files changed, 80 insertions, 29 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index 54134464a0..a1f0bcafab 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,5 +1,22 @@
2001-03-14 Jeffrey Stedfast <fejj@ximian.com>
+ * camel.c (camel_init): So it turns out that NSS_Init *isn't*
+ idempotent, so we have to protect against initializing it more
+ than once(contrary to what their design specs suggest).
+
+ * camel-session.c (camel_session_get_service): Use
+ camel_exception_is_set() - Makes no difference but it's more
+ consistant with how we normally do it.
+
+ * camel-provider.h (CAMEL_URL_ALLOW_SSL): We don't need this.
+
+ * providers/imap/camel-imap-provider.c: Define the imaps provider.
+ (camel_provider_module_init): Register the imaps provider.
+
+ * camel-provider.c (camel_provider_init): Only add the protocol to
+ the hash table if it's non empty. Also, g_strdup() the filename
+ into the hash table.
+
* providers/imap/camel-imap-store.c (camel_imap_store_init): Eek!
So the service's URL isn't set until after this is
initialized. This means we can't check for SSL here.
diff --git a/camel/camel-provider.c b/camel/camel-provider.c
index 03be7cdf1e..4549445842 100644
--- a/camel/camel-provider.c
+++ b/camel/camel-provider.c
@@ -61,8 +61,7 @@ camel_provider_init (void)
DIR *dir;
struct dirent *d;
char *p, *name, buf[80];
- FILE *f;
-
+
providers = g_hash_table_new (g_strcase_hash, g_strcase_equal);
dir = opendir (CAMEL_PROVIDERDIR);
@@ -73,30 +72,35 @@ camel_provider_init (void)
}
while ((d = readdir (dir))) {
+ FILE *fp;
+
p = strchr (d->d_name, '.');
if (!p || strcmp (p, ".urls") != 0)
continue;
name = g_strdup_printf ("%s/%s", CAMEL_PROVIDERDIR, d->d_name);
- f = fopen (name, "r");
- if (!f) {
+ fp = fopen (name, "r");
+ if (!fp) {
g_warning ("Could not read provider info file %s: %s",
name, g_strerror (errno));
g_free (name);
continue;
}
-
+
p = strrchr (name, '.');
strcpy (p, ".so");
- while ((fgets (buf, sizeof (buf), f))) {
+ while ((fgets (buf, sizeof (buf), fp))) {
buf[sizeof (buf) - 1] = '\0';
p = strchr (buf, '\n');
if (p)
*p = '\0';
-
- g_hash_table_insert (providers, g_strdup (buf), name);
+
+ if (*buf)
+ g_hash_table_insert (providers, g_strdup (buf), g_strdup (name));
}
- fclose (f);
+
+ g_free (name);
+ fclose (fp);
}
closedir (dir);
diff --git a/camel/camel-provider.h b/camel/camel-provider.h
index f6c588270d..07d62106ea 100644
--- a/camel/camel-provider.h
+++ b/camel/camel-provider.h
@@ -78,8 +78,6 @@ 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-session.c b/camel/camel-session.c
index 6fed6bfb9f..cb402a3526 100644
--- a/camel/camel-session.c
+++ b/camel/camel-session.c
@@ -308,8 +308,7 @@ camel_session_get_service (CamelSession *session, const char *url_string,
path = g_hash_table_lookup (session->modules, url->protocol);
if (path) {
camel_provider_load (session, path, ex);
- if (camel_exception_get_id (ex) !=
- CAMEL_EXCEPTION_NONE) {
+ if (camel_exception_is_set (ex)) {
camel_url_free (url);
CAMEL_SESSION_UNLOCK(session, lock);
return NULL;
diff --git a/camel/camel.c b/camel/camel.c
index 38ad4a9a09..5b102473e6 100644
--- a/camel/camel.c
+++ b/camel/camel.c
@@ -27,8 +27,8 @@
#include "camel.h"
#include <unicode.h>
#ifdef HAVE_NSS
-#include <mozilla/nspr.h>
-#include <mozilla/prthread.h>
+#include <nspr.h>
+#include <prthread.h>
#include <nss.h>
#include <ssl.h>
#endif /* HAVE_NSS */
@@ -36,7 +36,7 @@
gboolean camel_verbose_debug = FALSE;
gint
-camel_init (const char *certdb)
+camel_init (const char *certdb_dir, gboolean nss_init)
{
#ifdef ENABLE_THREADS
#ifdef G_THREADS_ENABLED
@@ -52,15 +52,17 @@ camel_init (const char *certdb)
unicode_init ();
#ifdef HAVE_NSS
- PR_Init (PR_SYSTEM_THREAD, PR_PRIORITY_NORMAL, 10);
-
- if (NSS_Init ("/home/fejj/.mozilla/default") == SECFailure) {
- g_warning ("Failed to initialize NSS");
- return -1;
+ if (nss_init) {
+ PR_Init (PR_SYSTEM_THREAD, PR_PRIORITY_NORMAL, 10);
+
+ if (NSS_Init ("/home/fejj/.mozilla/default") == SECFailure) {
+ g_warning ("Failed to initialize NSS");
+ return -1;
+ }
+
+ NSS_SetDomesticPolicy ();
}
- NSS_SetDomesticPolicy ();
-
SSL_OptionSetDefault (SSL_ENABLE_SSL2, PR_TRUE);
SSL_OptionSetDefault (SSL_ENABLE_SSL3, PR_TRUE);
SSL_OptionSetDefault (SSL_ENABLE_TLS, PR_TRUE);
diff --git a/camel/camel.h b/camel/camel.h
index fc50f3eb35..cc66090e04 100644
--- a/camel/camel.h
+++ b/camel/camel.h
@@ -68,7 +68,7 @@ extern "C" {
#include <camel/hash-table-utils.h>
#include <camel/string-utils.h>
-gint camel_init (const char *certdb);
+gint camel_init (const char *certdb_dir, gboolean nss_init);
void camel_shutdown (void);
diff --git a/camel/providers/imap/camel-imap-provider.c b/camel/providers/imap/camel-imap-provider.c
index 91f397277a..1fff8dcfd7 100644
--- a/camel/providers/imap/camel-imap-provider.c
+++ b/camel/providers/imap/camel-imap-provider.c
@@ -46,23 +46,54 @@ 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_SSL,
+ CAMEL_URL_ALLOW_PATH | CAMEL_URL_ALLOW_AUTH,
{ 0, 0 },
NULL
};
+#if defined (HAVE_NSS) || defined (HAVE_OPENSSL)
+static CamelProvider imaps_provider = {
+ "imaps",
+ N_("Secure IMAPv4"),
+
+ N_("For reading and storing mail on IMAP servers over an SSL connection."),
+
+ "mail",
+
+ CAMEL_PROVIDER_IS_REMOTE | CAMEL_PROVIDER_IS_SOURCE |
+ CAMEL_PROVIDER_IS_STORAGE,
+
+ CAMEL_URL_NEED_USER | CAMEL_URL_NEED_HOST |
+ CAMEL_URL_ALLOW_PATH | CAMEL_URL_ALLOW_AUTH,
+
+ { 0, 0 },
+
+ NULL
+};
+#endif /* HAVE_NSS or HAVE_OPENSSL */
+
void
camel_provider_module_init (CamelSession *session)
{
imap_provider.object_types[CAMEL_PROVIDER_STORE] =
- camel_imap_store_get_type();
-
+ camel_imap_store_get_type ();
+#if defined (HAVE_NSS) || defined (HAVE_OPENSSL)
+ imaps_provider.object_types[CAMEL_PROVIDER_STORE] =
+ camel_imap_store_get_type ();
+#endif
+
imap_provider.service_cache = g_hash_table_new (imap_url_hash, imap_url_equal);
-
+
+#if defined (HAVE_NSS) || defined (HAVE_OPENSSL)
+ imaps_provider.service_cache = g_hash_table_new (imap_url_hash, imap_url_equal);
+#endif
+
camel_session_register_provider (session, &imap_provider);
+#if defined (HAVE_NSS) || defined (HAVE_OPENSSL)
+ camel_session_register_provider (session, &imaps_provider);
+#endif
}
static void