diff options
Diffstat (limited to 'camel/providers/pop3')
-rw-r--r-- | camel/providers/pop3/camel-pop3-provider.c | 60 | ||||
-rw-r--r-- | camel/providers/pop3/camel-pop3-store.c | 115 |
2 files changed, 83 insertions, 92 deletions
diff --git a/camel/providers/pop3/camel-pop3-provider.c b/camel/providers/pop3/camel-pop3-provider.c index af5e530818..1cfecde700 100644 --- a/camel/providers/pop3/camel-pop3-provider.c +++ b/camel/providers/pop3/camel-pop3-provider.c @@ -43,9 +43,7 @@ static CamelProvider pop3_provider = { CAMEL_URL_NEED_USER | CAMEL_URL_NEED_HOST | CAMEL_URL_ALLOW_AUTH, - { 0, 0 }, - - NULL + /* ... */ }; #if defined (HAVE_NSS) || defined (HAVE_OPENSSL) @@ -63,9 +61,40 @@ static CamelProvider spop_provider = { CAMEL_URL_NEED_USER | CAMEL_URL_NEED_HOST | CAMEL_URL_ALLOW_AUTH, - { 0, 0 }, + /* ... */ +}; +#endif + +CamelServiceAuthType camel_pop3_password_authtype = { + N_("Password"), + + N_("This option will connect to the POP server using a plaintext " + "password. This is the only option supported by many POP servers."), + + "", + TRUE +}; + +CamelServiceAuthType camel_pop3_apop_authtype = { + "APOP", + + N_("This option will connect to the POP server using an encrypted " + "password via the APOP protocol. This may not work for all users " + "even on servers that claim to support it."), + + "+APOP", + TRUE +}; + +#ifdef HAVE_KRB4 +CamelServiceAuthType camel_pop3_kpop_authtype = { + "Kerberos 4 (KPOP)", + + N_("This will connect to the POP server and use Kerberos 4 " + "to authenticate to it."), - NULL + "+KPOP", + FALSE }; #endif @@ -74,19 +103,22 @@ camel_provider_module_init (CamelSession *session) { pop3_provider.object_types[CAMEL_PROVIDER_STORE] = camel_pop3_store_get_type (); -#if defined (HAVE_NSS) || defined (HAVE_OPENSSL) - spop_provider.object_types[CAMEL_PROVIDER_STORE] = - camel_pop3_store_get_type (); -#endif - pop3_provider.service_cache = g_hash_table_new (camel_url_hash, camel_url_equal); - -#if defined (HAVE_NSS) || defined (HAVE_OPENSSL) - spop_provider.service_cache = g_hash_table_new (camel_url_hash, camel_url_equal); + +#ifdef HAVE_KRB4 + pop3_provider.authtypes = g_list_prepend (camel_remote_store_authtype_list (), &camel_pop3_kpop_authtype); #endif - + pop3_provider.authtypes = g_list_prepend (pop3_provider.authtypes, &camel_pop3_apop_authtype); + 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 7f9cdc558b..e38141d624 100644 --- a/camel/providers/pop3/camel-pop3-store.c +++ b/camel/providers/pop3/camel-pop3-store.c @@ -72,7 +72,7 @@ static void finalize (CamelObject *object); static gboolean pop3_connect (CamelService *service, CamelException *ex); static gboolean pop3_disconnect (CamelService *service, gboolean clean, CamelException *ex); -static GList *query_auth_types (CamelService *service, gboolean connect, CamelException *ex); +static GList *query_auth_types (CamelService *service, CamelException *ex); static CamelFolder *get_folder (CamelStore *store, const char *folder_name, guint32 flags, CamelException *ex); @@ -141,41 +141,8 @@ finalize (CamelObject *object) g_free (pop3_store->apop_timestamp); } -static CamelServiceAuthType password_authtype = { - N_("Password"), - - N_("This option will connect to the POP server using a plaintext " - "password. This is the only option supported by many POP servers."), - - "", - TRUE -}; - -static CamelServiceAuthType apop_authtype = { - "APOP", - - N_("This option will connect to the POP server using an encrypted " - "password via the APOP protocol. This may not work for all users " - "even on servers that claim to support it."), - - "+APOP", - TRUE -}; - -#ifdef HAVE_KRB4 -static CamelServiceAuthType kpop_authtype = { - "Kerberos 4 (KPOP)", - - N_("This will connect to the POP server and use Kerberos 4 " - "to authenticate to it."), - - "+KPOP", - FALSE -}; -#endif - static gboolean -connect_to_server (CamelService *service, /*gboolean real, */CamelException *ex) +connect_to_server (CamelService *service, CamelException *ex) { CamelPop3Store *store = CAMEL_POP3_STORE (service); char *buf, *apoptime, *apopend; @@ -282,8 +249,14 @@ connect_to_server (CamelService *service, /*gboolean real, */CamelException *ex) return TRUE; } +extern CamelServiceAuthType camel_pop3_password_authtype; +extern CamelServiceAuthType camel_pop3_apop_authtype; +#ifdef HAVE_KRB4 +extern CamelServiceAuthType camel_pop3_kpop_authtype; +#endif + static GList * -query_auth_types (CamelService *service, gboolean connect, CamelException *ex) +query_auth_types (CamelService *service, CamelException *ex) { CamelPop3Store *store = CAMEL_POP3_STORE (service); GList *types = NULL; @@ -292,53 +265,39 @@ query_auth_types (CamelService *service, gboolean connect, CamelException *ex) gboolean kpop = TRUE; int saved_port; #endif - - types = CAMEL_SERVICE_CLASS (parent_class)->query_auth_types (service, connect, ex); - - if (connect) { - passwd = camel_service_connect (service, ex); - /*ignore the exception here; the server may just not support passwd */ - - /* should we check apop too? */ - apop = store->apop_timestamp != NULL; - if (passwd) - camel_service_disconnect (service, TRUE, ex); - camel_exception_clear (ex); - -#ifdef HAVE_KRB4 - saved_port = service->url->port; - service->url->port = KPOP_PORT; - kpop = camel_service_connect (service, ex); - service->url->port = saved_port; - /*ignore the exception here; the server may just not support kpop */ - - if (kpop) - camel_service_disconnect (service, TRUE, ex); - camel_exception_clear (ex); -#endif - - if (passwd) - types = g_list_append (types, &password_authtype); - if (apop) - types = g_list_append (types, &apop_authtype); + + types = CAMEL_SERVICE_CLASS (parent_class)->query_auth_types (service, ex); + if (camel_exception_is_set (ex)) + return types; + + passwd = camel_service_connect (service, NULL); + apop = store->apop_timestamp != NULL; + if (passwd) + camel_service_disconnect (service, TRUE, NULL); + #ifdef HAVE_KRB4 - if (kpop) - types = g_list_append (types, &kpop_authtype); + saved_port = service->url->port; + service->url->port = KPOP_PORT; + kpop = camel_service_connect (service, NULL); + service->url->port = saved_port; + if (kpop) + camel_service_disconnect (service, TRUE, NULL); #endif - - if (!types) { - camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE, - _("Could not connect to POP server on " - "%s."), service->url->host); - } - } else { - types = g_list_append (types, &password_authtype); - types = g_list_append (types, &apop_authtype); + + if (passwd) + types = g_list_append (types, &camel_pop3_password_authtype); + if (apop) + types = g_list_append (types, &camel_pop3_apop_authtype); #ifdef HAVE_KRB4 - types = g_list_append (types, &kpop_authtype); + if (kpop) + types = g_list_append (types, &camel_pop3_kpop_authtype); #endif + + if (!types) { + camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE, + _("Could not connect to POP server on " + "%s."), service->url->host); } - return types; } |