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.
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);
}
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);
#define CAMEL_URL_PATH_IS_ABSOLUTE (1 << 12)
-#define CAMEL_URL_ALLOW_SSL (1 << 13)
-
typedef struct {
/* Provider name used in CamelURLs. */
char *protocol;
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;
#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 */
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
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);
#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);
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