diff options
Diffstat (limited to 'camel')
-rw-r--r-- | camel/ChangeLog | 58 | ||||
-rw-r--r-- | camel/camel-provider.h | 22 | ||||
-rw-r--r-- | camel/camel-remote-store.c | 23 | ||||
-rw-r--r-- | camel/camel-remote-store.h | 2 | ||||
-rw-r--r-- | camel/providers/imap/camel-imap-provider.c | 52 | ||||
-rw-r--r-- | camel/providers/imap/camel-imap-store.c | 122 | ||||
-rw-r--r-- | camel/providers/imap/camel-imap-store.h | 6 | ||||
-rw-r--r-- | camel/providers/imap/libcamelimap.urls | 1 | ||||
-rw-r--r-- | camel/providers/pop3/camel-pop3-provider.c | 42 | ||||
-rw-r--r-- | camel/providers/pop3/camel-pop3-store.c | 10 | ||||
-rw-r--r-- | camel/providers/pop3/libcamelpop3.urls | 1 | ||||
-rw-r--r-- | camel/providers/smtp/camel-smtp-provider.c | 31 | ||||
-rw-r--r-- | camel/providers/smtp/camel-smtp-transport.c | 31 | ||||
-rw-r--r-- | camel/providers/smtp/camel-smtp-transport.h | 2 | ||||
-rw-r--r-- | camel/providers/smtp/libcamelsmtp.urls | 1 |
15 files changed, 242 insertions, 162 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog index adbea47d31..07580c4848 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,3 +1,61 @@ +2001-03-27 Dan Winship <danw@ximian.com> + + * camel-provider.h: Add an "extra_conf" field to CamelProvider + with structures and defines and stuff, for providers to specify + additional configuration options that they want. Also add a + "supports ssl" flag to the provider flags. + + * camel-url.c (camel_url_new_with_base): Fix parsing of params. + (output_param): And unparsing... + + * camel-remote-store.c: add a "default_ssl_port" field. + (remote_construct): If the URL has the "use_ssl" parameter, set + the store's use_ssl flag. + (remote_connect): If using SSL and no port specified, use the + default_ssl_port rather than the default_port. + + * providers/smtp/camel-smtp-provider.c (smtp_provider): add + CAMEL_PROVIDER_SUPPORTS_SSL and CAMEL_URL_ALLOW_USER. (The config + gui code knows that the ALLOW_USER and ALLOW_AUTH go together.) + (ssmtp_provider): gone + + * providers/smtp/camel-smtp-transport.c (smtp_construct): Set a + flag if "use_ssl" param is set. + (smtp_connect): Check the CamelSmtpTransport use_ssl flag rather + than checking if this is smtp or ssmtp. + + * providers/imap/camel-imap-provider.c (imap_conf_entries): Add a + bunch of IMAP-specific configuration options, like "check for new + mail in all folders" (default TRUE), "show only subscribed + folders" (default TRUE), "ignore server-supplied namespace", and + "apply filters to INBOX" (not yet implemented). + (imap_provider): We support SSL and we no longer allow a path in + the URL. (namespace is handled via extra_conf) + (simap_provider): Gone + + * providers/imap/camel-imap-store.c (camel_imap_store_init): Set + default_ssl_port, don't set CAMEL_STORE_SUBSCRIPTIONS here + (construct): remove simap stuff, deal with "use_lsub", + "namespace", "check_all", and "filter" parameters. Set base_url + to not include params. + (imap_store_setup_online): Don't ask for the namespace if it was + set explicitly. Don't get subscribed folders if !use_lsub. + (imap_concat): Fix a bug. + (get_folder_info): Support for not checking all folders. + + * providers/imap/camel-imap-folder.c (imap_get_full_name): Rewrite + to use imap_store->namespace, not service->url->path + + * providers/pop3/camel-pop3-provider.c (pop3_conf_entries): "keep + on server" (currently still implemented by the mailer code, not + here), "delete after N days" (not yet implemented). + (pop3_provider): we support SSL + (spop_provider): gone + + * providers/pop3/camel-pop3-store.c (camel_pop3_store_init): Set + default_ssl_port + (pop3_connect): Remove spop code + 2001-03-26 Jeffrey Stedfast <fejj@ximian.com> * camel-vee-folder.c (vee_folder_construct): Move all of the diff --git a/camel/camel-provider.h b/camel/camel-provider.h index 4936a77a0e..e8bad9618d 100644 --- a/camel/camel-provider.h +++ b/camel/camel-provider.h @@ -54,6 +54,7 @@ extern char *camel_provider_type_name[CAMEL_NUM_PROVIDER_TYPES]; #define CAMEL_PROVIDER_IS_REMOTE (1 << 0) #define CAMEL_PROVIDER_IS_SOURCE (1 << 1) #define CAMEL_PROVIDER_IS_STORAGE (1 << 2) +#define CAMEL_PROVIDER_SUPPORTS_SSL (1 << 3) /* Flags for url_flags. "ALLOW" means the config dialog will let @@ -93,6 +94,24 @@ extern char *camel_provider_type_name[CAMEL_NUM_PROVIDER_TYPES]; #define CAMEL_URL_PATH_IS_ABSOLUTE (1 << 12) +/* Generic extra config stuff */ +typedef enum { + CAMEL_PROVIDER_CONF_END, + CAMEL_PROVIDER_CONF_SECTION_START, + CAMEL_PROVIDER_CONF_SECTION_END, + CAMEL_PROVIDER_CONF_CHECKBOX, + CAMEL_PROVIDER_CONF_CHECKSPIN, + CAMEL_PROVIDER_CONF_ENTRY, +} CamelProviderConfType; + +typedef struct { + CamelProviderConfType type; + char *name, *depname; + char *text, *value; +} CamelProviderConfEntry; + + + typedef struct { /* Provider name used in CamelURLs. */ char *protocol; @@ -117,6 +136,9 @@ typedef struct { /* Flags describing the provider, flags describing its URLs */ int flags, url_flags; + /* Extra configuration information */ + CamelProviderConfEntry *extra_conf; + CamelType object_types [CAMEL_NUM_PROVIDER_TYPES]; /* GList of CamelServiceAuthTypes the provider supports */ diff --git a/camel/camel-remote-store.c b/camel/camel-remote-store.c index 552c630883..396f216574 100644 --- a/camel/camel-remote-store.c +++ b/camel/camel-remote-store.c @@ -65,6 +65,9 @@ extern gboolean camel_verbose_debug; static CamelStoreClass *store_class = NULL; +static void remote_construct (CamelService *service, CamelSession *session, + CamelProvider *provider, CamelURL *url, + CamelException *ex); static gboolean remote_connect (CamelService *service, CamelException *ex); static gboolean remote_disconnect (CamelService *service, gboolean clean, CamelException *ex); static GList *remote_query_auth_types(CamelService *service, CamelException *ex); @@ -86,6 +89,7 @@ camel_remote_store_class_init (CamelRemoteStoreClass *camel_remote_store_class) store_class = CAMEL_STORE_CLASS (camel_type_get_global_classfuncs (camel_store_get_type ())); /* virtual method overload */ + camel_service_class->construct = remote_construct; camel_service_class->connect = remote_connect; camel_service_class->disconnect = remote_disconnect; camel_service_class->query_auth_types = remote_query_auth_types; @@ -146,8 +150,21 @@ camel_remote_store_get_type (void) return camel_remote_store_type; } -/* Auth stuff... for now, nothing, but eventually SSL at least should - * be handled through here, and SSH tunnelling if we ever implement it. +static void +remote_construct (CamelService *service, CamelSession *session, + CamelProvider *provider, CamelURL *url, + CamelException *ex) +{ + CamelRemoteStore *remote_store = CAMEL_REMOTE_STORE (service); + + CAMEL_SERVICE_CLASS (store_class)->construct (service, session, provider, url, ex); + + if (camel_url_get_param (url, "use_ssl")) + remote_store->use_ssl = TRUE; +} + + +/* Auth stuff... for now, nothing, but might eventually add SSH tunneling */ static GList * @@ -202,6 +219,8 @@ remote_connect (CamelService *service, CamelException *ex) if (service->url->port) port = service->url->port; + else if (store->use_ssl) + port = store->default_ssl_port; else port = store->default_port; diff --git a/camel/camel-remote-store.h b/camel/camel-remote-store.h index 8200c0cf16..ab22c0e86b 100644 --- a/camel/camel-remote-store.h +++ b/camel/camel-remote-store.h @@ -43,7 +43,7 @@ typedef struct { struct _CamelRemoteStorePrivate *priv; CamelStream *istream, *ostream; - guint timeout_id, default_port; + guint timeout_id, default_port, default_ssl_port; gboolean use_ssl; } CamelRemoteStore; diff --git a/camel/providers/imap/camel-imap-provider.c b/camel/providers/imap/camel-imap-provider.c index 593231a56e..768c97901d 100644 --- a/camel/providers/imap/camel-imap-provider.c +++ b/camel/providers/imap/camel-imap-provider.c @@ -35,6 +35,26 @@ static guint imap_url_hash (gconstpointer key); static gint check_equal (char *s1, char *s2); static gint imap_url_equal (gconstpointer a, gconstpointer b); +CamelProviderConfEntry imap_conf_entries[] = { + { CAMEL_PROVIDER_CONF_SECTION_START, "mailcheck", NULL, + N_("Checking for new mail") }, + { CAMEL_PROVIDER_CONF_CHECKBOX, "check_all", NULL, + N_("Check for new messages in all folders"), "1" }, + { CAMEL_PROVIDER_CONF_SECTION_END }, + { CAMEL_PROVIDER_CONF_SECTION_START, "folders", NULL, + N_("Folders") }, + { CAMEL_PROVIDER_CONF_CHECKBOX, "use_lsub", NULL, + N_("Show only subscribed folders"), "1" }, + { CAMEL_PROVIDER_CONF_CHECKBOX, "override_namespace", NULL, + N_("Override server-supplied folder namespace"), "0" }, + { CAMEL_PROVIDER_CONF_ENTRY, "namespace", "override_namespace", + N_("Namespace") }, + { CAMEL_PROVIDER_CONF_SECTION_END }, + { CAMEL_PROVIDER_CONF_CHECKBOX, "filter", "UNIMPLEMENTED", + N_("Apply filters to new messages in INBOX on this server"), "0" }, + { CAMEL_PROVIDER_CONF_END } +}; + static CamelProvider imap_provider = { "imap", N_("IMAPv4"), @@ -44,32 +64,14 @@ static CamelProvider imap_provider = { "mail", CAMEL_PROVIDER_IS_REMOTE | CAMEL_PROVIDER_IS_SOURCE | - CAMEL_PROVIDER_IS_STORAGE, + CAMEL_PROVIDER_IS_STORAGE | CAMEL_PROVIDER_SUPPORTS_SSL, - CAMEL_URL_NEED_USER | CAMEL_URL_NEED_HOST | - CAMEL_URL_ALLOW_PATH | CAMEL_URL_ALLOW_AUTH, + CAMEL_URL_NEED_USER | CAMEL_URL_NEED_HOST | CAMEL_URL_ALLOW_AUTH, - /* ... */ -}; - -#if defined (HAVE_NSS) || defined (HAVE_OPENSSL) -static CamelProvider simap_provider = { - "simap", - 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, + imap_conf_entries, /* ... */ }; -#endif /* HAVE_NSS or HAVE_OPENSSL */ CamelServiceAuthType camel_imap_password_authtype = { N_("Password"), @@ -93,14 +95,6 @@ camel_provider_module_init (CamelSession *session) &camel_imap_password_authtype); camel_session_register_provider (session, &imap_provider); - -#if defined (HAVE_NSS) || defined (HAVE_OPENSSL) - simap_provider.object_types[CAMEL_PROVIDER_STORE] = - camel_imap_store_get_type (); - simap_provider.service_cache = g_hash_table_new (imap_url_hash, imap_url_equal); - simap_provider.authtypes = g_list_copy (imap_provider.authtypes); - camel_session_register_provider (session, &simap_provider); -#endif } static void diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c index de68eebbca..7f303e51fb 100644 --- a/camel/providers/imap/camel-imap-store.c +++ b/camel/providers/imap/camel-imap-store.c @@ -156,16 +156,13 @@ 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); remote_store->default_port = 143; - remote_store->use_ssl = FALSE; + remote_store->default_ssl_port = 993; imap_store->dir_sep = '\0'; imap_store->current_folder = NULL; - store->flags = CAMEL_STORE_SUBSCRIPTIONS; - imap_store->connected = FALSE; imap_store->subscribed_folders = NULL; @@ -199,33 +196,38 @@ construct (CamelService *service, CamelSession *session, CamelProvider *provider, CamelURL *url, CamelException *ex) { - CamelImapStore *store = CAMEL_IMAP_STORE (service); - int len; + CamelImapStore *imap_store = CAMEL_IMAP_STORE (service); + CamelStore *store = CAMEL_STORE (service); + CamelURL *base_url; CAMEL_SERVICE_CLASS (remote_store_class)->construct (service, session, provider, url, ex); if (camel_exception_is_set (ex)) return; - if (!g_strcasecmp (service->url->protocol, "simap")) { - CamelRemoteStore *rstore = CAMEL_REMOTE_STORE (service); - - rstore->default_port = 993; - rstore->use_ssl = TRUE; - } - - store->storage_path = camel_session_get_storage_path (session, service, ex); + imap_store->storage_path = camel_session_get_storage_path (session, service, ex); if (camel_exception_is_set (ex)) return; - store->base_url = camel_url_to_string (service->url, FALSE); - len = strlen (store->base_url); - if (service->url->path) - store->base_url[len - strlen (service->url->path) + 1] = '\0'; - else { - store->base_url = g_realloc (store->base_url, len + 2); - store->base_url[len] = '/'; - store->base_url[len + 1] = '\0'; + base_url = g_new0 (CamelURL, 1); + camel_url_set_protocol (base_url, service->url->protocol); + camel_url_set_user (base_url, service->url->user); + camel_url_set_host (base_url, service->url->host); + camel_url_set_port (base_url, service->url->port); + camel_url_set_path (base_url, "/"); + imap_store->base_url = camel_url_to_string (base_url, FALSE); + camel_url_free (base_url); + + imap_store->parameters = 0; + if (camel_url_get_param (url, "use_lsub")) + store->flags |= CAMEL_STORE_SUBSCRIPTIONS; + if (camel_url_get_param (url, "namespace")) { + imap_store->parameters |= IMAP_PARAM_OVERRIDE_NAMESPACE; + imap_store->namespace = g_strdup (camel_url_get_param (url, "namespace")); } + if (camel_url_get_param (url, "check_all")) + imap_store->parameters |= IMAP_PARAM_CHECK_ALL; + if (camel_url_get_param (url, "filter")) + imap_store->parameters |= IMAP_PARAM_FILTER_INBOX; } static struct { @@ -556,7 +558,6 @@ imap_connect (CamelService *service, CamelException *ex) static gboolean imap_store_setup_online (CamelImapStore *store, CamelException *ex) { - CamelService *service; CamelImapResponse *response; int i, flags, len; char *result, *name, *path; @@ -573,10 +574,8 @@ imap_store_setup_online (CamelImapStore *store, CamelException *ex) camel_folder_summary_encode_uint32 (storeinfo, store->capabilities); /* Get namespace and hierarchy separator */ - service = CAMEL_SERVICE (store); - if (service->url->path && strlen (service->url->path) > 1) - store->namespace = g_strdup (service->url->path + 1); - else if (store->capabilities & IMAP_CAPABILITY_NAMESPACE) { + if ((store->capabilities & IMAP_CAPABILITY_NAMESPACE) && + !(store->parameters & IMAP_PARAM_OVERRIDE_NAMESPACE)) { CAMEL_IMAP_STORE_LOCK (store, command_lock); response = camel_imap_command (store, NULL, ex, "NAMESPACE"); CAMEL_IMAP_STORE_UNLOCK (store, command_lock); @@ -642,30 +641,32 @@ imap_store_setup_online (CamelImapStore *store, CamelException *ex) camel_folder_summary_encode_string (storeinfo, store->namespace); camel_folder_summary_encode_uint32 (storeinfo, store->dir_sep); - /* Get subscribed folders */ - CAMEL_IMAP_STORE_LOCK (store, command_lock); - response = camel_imap_command (store, NULL, ex, "LSUB \"\" \"*\""); - CAMEL_IMAP_STORE_UNLOCK (store, command_lock); - if (!response) - return FALSE; - store->subscribed_folders = g_hash_table_new (g_str_hash, g_str_equal); - for (i = 0; i < response->untagged->len; i++) { - result = response->untagged->pdata[i]; - if (!imap_parse_list_response (result, &flags, NULL, &name)) - continue; - if (flags & (IMAP_LIST_FLAG_MARKED | IMAP_LIST_FLAG_UNMARKED)) - store->useful_lsub = TRUE; - if (flags & IMAP_LIST_FLAG_NOSELECT) { - g_free (name); - continue; + if (CAMEL_STORE (store)->flags & CAMEL_STORE_SUBSCRIPTIONS) { + /* Get subscribed folders */ + CAMEL_IMAP_STORE_LOCK (store, command_lock); + response = camel_imap_command (store, NULL, ex, "LSUB \"\" \"*\""); + CAMEL_IMAP_STORE_UNLOCK (store, command_lock); + if (!response) + return FALSE; + store->subscribed_folders = g_hash_table_new (g_str_hash, g_str_equal); + for (i = 0; i < response->untagged->len; i++) { + result = response->untagged->pdata[i]; + if (!imap_parse_list_response (result, &flags, NULL, &name)) + continue; + if (flags & (IMAP_LIST_FLAG_MARKED | IMAP_LIST_FLAG_UNMARKED)) + store->useful_lsub = TRUE; + if (flags & IMAP_LIST_FLAG_NOSELECT) { + g_free (name); + continue; + } + g_hash_table_insert (store->subscribed_folders, name, + GINT_TO_POINTER (1)); + camel_folder_summary_encode_string (storeinfo, result); } - g_hash_table_insert (store->subscribed_folders, name, - GINT_TO_POINTER (1)); - camel_folder_summary_encode_string (storeinfo, result); + camel_imap_response_free (response); } - camel_imap_response_free (response); - fclose (storeinfo); + fclose (storeinfo); return TRUE; } @@ -738,7 +739,7 @@ imap_disconnect (CamelService *service, gboolean clean, CamelException *ex) store->subscribed_folders = NULL; } - if (store->namespace) { + if (store->namespace && !(store->parameters & IMAP_PARAM_OVERRIDE_NAMESPACE)) { g_free (store->namespace); store->namespace = NULL; } @@ -891,7 +892,7 @@ imap_concat (CamelImapStore *imap_store, const char *prefix, const char *suffix) int len; len = strlen (prefix); - if (len > 0 && prefix[len - 1] == imap_store->dir_sep) + if (len == 0 || prefix[len - 1] == imap_store->dir_sep) return g_strdup_printf ("%s%s", prefix, suffix); else return g_strdup_printf ("%s%c%s", prefix, imap_store->dir_sep, suffix); @@ -1140,10 +1141,17 @@ get_folder_info (CamelStore *store, const char *top, gboolean fast, g_ptr_array_remove_index (folders, 0); } - if (subscribed_only && !imap_store->useful_lsub) + /* If we want to look at only subscribed folders AND + * check if any of them have new mail, AND the server + * doesn't return Marked/UnMarked with LSUB, then + * use get_subscribed_folders_by_hand. In all other + * cases, use a single LIST or LSUB command. + */ + if (subscribed_only && !imap_store->useful_lsub && + (imap_store->parameters & IMAP_PARAM_CHECK_ALL)) { get_subscribed_folders_by_hand (imap_store, name, folders, ex); - else { + } else { pattern = imap_concat (imap_store, name, recursive ? "*" : "%"); get_folders_online (imap_store, pattern, folders, @@ -1188,8 +1196,18 @@ get_folder_info (CamelStore *store, const char *top, gboolean fast, camel_store_sync (store, NULL); for (i = 0; i < folders->len; i++) { fi = folders->pdata[i]; + + /* Don't check if it doesn't contain messages + * or if it was \UnMarked. + */ if (!fi->url || fi->unread_message_count != -1) continue; + /* Don't check if it's not INBOX and we're only + * checking INBOX. + */ + if ((!(imap_store->parameters & IMAP_PARAM_CHECK_ALL)) + && (g_strcasecmp (fi->name, "INBOX") != 0)) + continue; /* UW will give cached data for the currently * selected folder. Grr. Well, I guess this diff --git a/camel/providers/imap/camel-imap-store.h b/camel/providers/imap/camel-imap-store.h index 8cc186655c..fb4be047c2 100644 --- a/camel/providers/imap/camel-imap-store.h +++ b/camel/providers/imap/camel-imap-store.h @@ -53,6 +53,10 @@ typedef enum { #define IMAP_CAPABILITY_UIDPLUS (1 << 4) #define IMAP_CAPABILITY_LITERALPLUS (1 << 5) +#define IMAP_PARAM_OVERRIDE_NAMESPACE (1 << 0) +#define IMAP_PARAM_CHECK_ALL (1 << 1) +#define IMAP_PARAM_FILTER_INBOX (1 << 2) + struct _CamelImapStore { CamelRemoteStore parent_object; struct _CamelImapStorePrivate *priv; @@ -62,7 +66,7 @@ struct _CamelImapStore { guint32 command; CamelImapServerLevel server_level; - guint32 capabilities; + guint32 capabilities, parameters; GHashTable *authtypes; char *namespace, dir_sep, *storage_path, *base_url; diff --git a/camel/providers/imap/libcamelimap.urls b/camel/providers/imap/libcamelimap.urls index 3d22d610b2..c301c0ffac 100644 --- a/camel/providers/imap/libcamelimap.urls +++ b/camel/providers/imap/libcamelimap.urls @@ -1,2 +1 @@ imap -simap diff --git a/camel/providers/pop3/camel-pop3-provider.c b/camel/providers/pop3/camel-pop3-provider.c index 1cfecde700..6dae1f6edb 100644 --- a/camel/providers/pop3/camel-pop3-provider.c +++ b/camel/providers/pop3/camel-pop3-provider.c @@ -29,6 +29,17 @@ #include "camel-session.h" #include "camel-url.h" +CamelProviderConfEntry pop3_conf_entries[] = { + { CAMEL_PROVIDER_CONF_SECTION_START, NULL, NULL, + N_("Message storage") }, + { CAMEL_PROVIDER_CONF_CHECKBOX, "keep_on_server", NULL, + N_("Leave messages on server"), "0" }, + { CAMEL_PROVIDER_CONF_CHECKSPIN, "delete_after", "UNIMPLEMENTED", + N_("Delete after %s day(s)"), "0:1:7:365" }, + { CAMEL_PROVIDER_CONF_SECTION_END }, + { CAMEL_PROVIDER_CONF_END } +}; + static CamelProvider pop3_provider = { "pop", N_("POP"), @@ -39,31 +50,15 @@ static CamelProvider pop3_provider = { "mail", - CAMEL_PROVIDER_IS_REMOTE | CAMEL_PROVIDER_IS_SOURCE, + CAMEL_PROVIDER_IS_REMOTE | CAMEL_PROVIDER_IS_SOURCE | + CAMEL_PROVIDER_SUPPORTS_SSL, CAMEL_URL_NEED_USER | CAMEL_URL_NEED_HOST | CAMEL_URL_ALLOW_AUTH, - /* ... */ -}; - -#if defined (HAVE_NSS) || defined (HAVE_OPENSSL) -static CamelProvider spop_provider = { - "spop", - N_("Secure POP"), - - N_("For connecting to POP servers over an SSL connection. The POP " - "protocol can also be used to retrieve mail from certain web " - "mail providers and proprietary email systems."), - - "mail", - - CAMEL_PROVIDER_IS_REMOTE | CAMEL_PROVIDER_IS_SOURCE, - - CAMEL_URL_NEED_USER | CAMEL_URL_NEED_HOST | CAMEL_URL_ALLOW_AUTH, + pop3_conf_entries, /* ... */ }; -#endif CamelServiceAuthType camel_pop3_password_authtype = { N_("Password"), @@ -112,13 +107,4 @@ camel_provider_module_init (CamelSession *session) pop3_provider.authtypes = g_list_prepend (pop3_provider.authtypes, &camel_pop3_password_authtype); camel_session_register_provider (session, &pop3_provider); - -#if defined (HAVE_NSS) || defined (HAVE_OPENSSL) - spop_provider.object_types[CAMEL_PROVIDER_STORE] = - camel_pop3_store_get_type (); - spop_provider.service_cache = g_hash_table_new (camel_url_hash, camel_url_equal); - spop_provider.authtypes = g_list_copy (pop3_provider.authtypes); - - camel_session_register_provider (session, &spop_provider); -#endif } diff --git a/camel/providers/pop3/camel-pop3-store.c b/camel/providers/pop3/camel-pop3-store.c index e38141d624..558d8a8b38 100644 --- a/camel/providers/pop3/camel-pop3-store.c +++ b/camel/providers/pop3/camel-pop3-store.c @@ -112,6 +112,8 @@ camel_pop3_store_init (gpointer object, gpointer klass) CamelRemoteStore *remote_store = CAMEL_REMOTE_STORE (object); remote_store->default_port = 110; + /* FIXME: what should this port be?? */ + remote_store->default_ssl_port = 995; } CamelType @@ -419,14 +421,6 @@ pop3_connect (CamelService *service, CamelException *ex) } #endif - if (!g_strcasecmp (service->url->protocol, "spop")) { - CamelRemoteStore *rstore = CAMEL_REMOTE_STORE (service); - - /* FIXME: what should this port be?? */ - rstore->default_port = 995; - rstore->use_ssl = TRUE; - } - res = CAMEL_SERVICE_CLASS (parent_class)->connect (service, ex); #ifdef HAVE_KRB4 diff --git a/camel/providers/pop3/libcamelpop3.urls b/camel/providers/pop3/libcamelpop3.urls index 789e1d7db1..7fffa4d861 100644 --- a/camel/providers/pop3/libcamelpop3.urls +++ b/camel/providers/pop3/libcamelpop3.urls @@ -1,2 +1 @@ pop -spop diff --git a/camel/providers/smtp/camel-smtp-provider.c b/camel/providers/smtp/camel-smtp-provider.c index a3905daa02..bcdc1bc3e0 100644 --- a/camel/providers/smtp/camel-smtp-provider.c +++ b/camel/providers/smtp/camel-smtp-provider.c @@ -39,31 +39,13 @@ static CamelProvider smtp_provider = { "mail", - CAMEL_PROVIDER_IS_REMOTE, + CAMEL_PROVIDER_IS_REMOTE | CAMEL_PROVIDER_SUPPORTS_SSL, - CAMEL_URL_NEED_HOST | CAMEL_URL_ALLOW_AUTH, + CAMEL_URL_NEED_HOST | CAMEL_URL_ALLOW_AUTH | CAMEL_URL_ALLOW_USER, /* ... */ }; -#if defined (HAVE_NSS) || defined (HAVE_OPENSSL) -static CamelProvider ssmtp_provider = { - "ssmtp", - N_("Secure SMTP"), - - N_("For delivering mail by connecting to a remote mailhub " - "using SMTP over an SSL connection.\n"), - - "mail", - - CAMEL_PROVIDER_IS_REMOTE, - - CAMEL_URL_NEED_HOST | CAMEL_URL_ALLOW_AUTH, - - /* ... */ -}; -#endif - void camel_provider_module_init (CamelSession *session) { @@ -73,15 +55,6 @@ camel_provider_module_init (CamelSession *session) smtp_provider.service_cache = g_hash_table_new (camel_url_hash, camel_url_equal); camel_session_register_provider (session, &smtp_provider); - -#if defined (HAVE_NSS) || defined (HAVE_OPENSSL) - ssmtp_provider.object_types[CAMEL_PROVIDER_TRANSPORT] = - camel_smtp_transport_get_type (); - ssmtp_provider.authtypes = camel_sasl_authtype_list (); - ssmtp_provider.service_cache = g_hash_table_new (camel_url_hash, camel_url_equal); - - camel_session_register_provider (session, &ssmtp_provider); -#endif } diff --git a/camel/providers/smtp/camel-smtp-transport.c b/camel/providers/smtp/camel-smtp-transport.c index 9a6ae102bf..1e345e3371 100644 --- a/camel/providers/smtp/camel-smtp-transport.c +++ b/camel/providers/smtp/camel-smtp-transport.c @@ -67,6 +67,9 @@ static gboolean smtp_send (CamelTransport *transport, CamelMedium *message, Came static gboolean smtp_send_to (CamelTransport *transport, CamelMedium *message, GList *recipients, CamelException *ex); /* support prototypes */ +static void smtp_construct (CamelService *service, CamelSession *session, + CamelProvider *provider, CamelURL *url, + CamelException *ex); static gboolean smtp_connect (CamelService *service, CamelException *ex); static gboolean smtp_disconnect (CamelService *service, gboolean clean, CamelException *ex); static GHashTable *esmtp_get_authtypes (gchar *buffer); @@ -84,7 +87,7 @@ static gboolean smtp_rset (CamelSmtpTransport *transport, CamelException *ex); static gboolean smtp_quit (CamelSmtpTransport *transport, CamelException *ex); /* private data members */ -static CamelServiceClass *service_class = NULL; +static CamelTransportClass *parent_class = NULL; static void camel_smtp_transport_class_init (CamelSmtpTransportClass *camel_smtp_transport_class) @@ -94,9 +97,10 @@ camel_smtp_transport_class_init (CamelSmtpTransportClass *camel_smtp_transport_c CamelServiceClass *camel_service_class = CAMEL_SERVICE_CLASS (camel_smtp_transport_class); - service_class = CAMEL_SERVICE_CLASS (camel_type_get_global_classfuncs (camel_service_get_type ())); + parent_class = CAMEL_TRANSPORT_CLASS (camel_type_get_global_classfuncs (camel_transport_get_type ())); /* virtual method overload */ + camel_service_class->construct = smtp_construct; camel_service_class->connect = smtp_connect; camel_service_class->disconnect = smtp_disconnect; camel_service_class->query_auth_types = query_auth_types; @@ -134,6 +138,19 @@ camel_smtp_transport_get_type (void) return camel_smtp_transport_type; } +static void +smtp_construct (CamelService *service, CamelSession *session, + CamelProvider *provider, CamelURL *url, + CamelException *ex) +{ + CamelSmtpTransport *smtp_transport = CAMEL_SMTP_TRANSPORT (service); + + CAMEL_SERVICE_CLASS (parent_class)->construct (service, session, provider, url, ex); + + if (camel_url_get_param (url, "use_ssl")) + smtp_transport->use_ssl = TRUE; +} + static const char * get_smtp_error_string (int error) { @@ -206,12 +223,11 @@ smtp_connect (CamelService *service, CamelException *ex) CamelSmtpTransport *transport = CAMEL_SMTP_TRANSPORT (service); CamelStream *tcp_stream; gchar *respbuf = NULL; - gboolean use_ssl = FALSE; struct hostent *h; guint32 addrlen; int port, ret; - if (!service_class->connect (service, ex)) + if (!CAMEL_SERVICE_CLASS (parent_class)->connect (service, ex)) return FALSE; h = camel_service_gethost (service, ex); @@ -226,8 +242,7 @@ smtp_connect (CamelService *service, CamelException *ex) port = service->url->port ? service->url->port : SMTP_PORT; #ifdef HAVE_NSS - if (!g_strcasecmp (service->url->protocol, "ssmtp")) { - use_ssl = TRUE; + if (transport->use_ssl) { port = service->url->port ? service->url->port : 465; tcp_stream = camel_tcp_stream_ssl_new (service, service->url->host); } else { @@ -250,7 +265,7 @@ smtp_connect (CamelService *service, CamelException *ex) /* get the localaddr - needed later by smtp_helo */ addrlen = sizeof (transport->localaddr); #ifdef HAVE_NSS - if (use_ssl) { + if (transport->use_ssl) { PRFileDesc *sockfd = camel_tcp_stream_get_socket (CAMEL_TCP_STREAM (tcp_stream)); PRNetAddr addr; char hname[1024]; @@ -416,7 +431,7 @@ smtp_disconnect (CamelService *service, gboolean clean, CamelException *ex) smtp_quit (transport, ex); } - if (!service_class->disconnect (service, clean, ex)) + if (!CAMEL_SERVICE_CLASS (parent_class)->disconnect (service, clean, ex)) return FALSE; if (transport->authtypes) { diff --git a/camel/providers/smtp/camel-smtp-transport.h b/camel/providers/smtp/camel-smtp-transport.h index b15f0319df..4515fe1f07 100644 --- a/camel/providers/smtp/camel-smtp-transport.h +++ b/camel/providers/smtp/camel-smtp-transport.h @@ -53,7 +53,7 @@ typedef struct { CamelStream *istream, *ostream; - gboolean is_esmtp; + gboolean use_ssl, is_esmtp; struct sockaddr_in localaddr; diff --git a/camel/providers/smtp/libcamelsmtp.urls b/camel/providers/smtp/libcamelsmtp.urls index d786e01295..ec2fc0fc16 100644 --- a/camel/providers/smtp/libcamelsmtp.urls +++ b/camel/providers/smtp/libcamelsmtp.urls @@ -1,2 +1 @@ smtp -ssmtp |