aboutsummaryrefslogtreecommitdiffstats
path: root/camel
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2001-03-22 06:20:29 +0800
committerDan Winship <danw@src.gnome.org>2001-03-22 06:20:29 +0800
commit5d562c3d3d879d05c75ecb300c53e0b5ae0120fc (patch)
tree6ca10894c653240c1be004faf130ffddf6511b9b /camel
parent0ec6ccc4dfc136dd7347e49e4dc2b309126706a9 (diff)
downloadgsoc2013-evolution-5d562c3d3d879d05c75ecb300c53e0b5ae0120fc.tar
gsoc2013-evolution-5d562c3d3d879d05c75ecb300c53e0b5ae0120fc.tar.gz
gsoc2013-evolution-5d562c3d3d879d05c75ecb300c53e0b5ae0120fc.tar.bz2
gsoc2013-evolution-5d562c3d3d879d05c75ecb300c53e0b5ae0120fc.tar.lz
gsoc2013-evolution-5d562c3d3d879d05c75ecb300c53e0b5ae0120fc.tar.xz
gsoc2013-evolution-5d562c3d3d879d05c75ecb300c53e0b5ae0120fc.tar.zst
gsoc2013-evolution-5d562c3d3d879d05c75ecb300c53e0b5ae0120fc.zip
add a "GList *authtypes", so you can get the list of authtypes used by a
* camel-provider.h: (CamelProvider) add a "GList *authtypes", so you can get the list of authtypes used by a provider without needing to have an actual CamelService object handy. (Will be needed by the new config druid.) (CAMEL_PROVIDER_ALLOWS, CAMEL_PROVIDER_NEEDS): New macros to test the URL part stuff, since the way it works is too complicated and everyone always does it wrong. * camel-service.c (camel_service_query_auth_types): Remove the @connected arg again: if you don't want to connect, you can just get the list of authtypes off the provider. (camel_service_free_auth_types): Remove this. All existing implementations do authtypes the same way, so just say the caller should "g_list_free" the list. (Oh, look, removing this function doesn't actually cause the mailer to not build. How 'bout that.) (construct, get_path): Use the new URL part macros. * camel-remote-store.c (remote_query_auth_types): Update (remote_free_auth_types): Nuke (camel_remote_store_authtype_list): New function for use by subclasses. * providers/imap/camel-imap-provider.c: * providers/pop3/camel-pop3-provider.c: * providers/smtp/camel-smtp-provider.c: Update CamelProvider structures. (camel_provider_module_init): Put all the SSL parts together so there's only 1 #ifdef. Set up the provider authtypes field using the SASL, CamelRemoteStore, and standard authtypes, as appropriate. Copy that from the normal provider to the SSL provider. * providers/local/camel-local-provider.c: * providers/sendmail/camel-sendmail-provider.c: * camel-session.c: Update CamelProvider structures. * providers/imap/camel-imap-store.c (query_auth_types): * providers/pop3/camel-pop3-store.c (query_auth_types): Update * providers/smtp/camel-smtp-store.c (query_auth_types): Update. Remove the no_authtype, because that's what "ALLOW_AUTH" rather than "NEED_AUTH" means. (free_auth_types): Nuke. svn path=/trunk/; revision=8872
Diffstat (limited to 'camel')
-rw-r--r--camel/ChangeLog46
-rw-r--r--camel/camel-provider.h45
-rw-r--r--camel/camel-remote-store.c29
-rw-r--r--camel/camel-remote-store.h2
-rw-r--r--camel/camel-service.c68
-rw-r--r--camel/camel-service.h6
-rw-r--r--camel/camel-session.c8
-rw-r--r--camel/providers/imap/camel-imap-provider.c37
-rw-r--r--camel/providers/imap/camel-imap-store.c37
-rw-r--r--camel/providers/local/camel-local-provider.c9
-rw-r--r--camel/providers/pop3/camel-pop3-provider.c60
-rw-r--r--camel/providers/pop3/camel-pop3-store.c115
-rw-r--r--camel/providers/sendmail/camel-sendmail-provider.c8
-rw-r--r--camel/providers/smtp/camel-smtp-provider.c25
-rw-r--r--camel/providers/smtp/camel-smtp-transport.c44
15 files changed, 257 insertions, 282 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index e55967a224..750038f303 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,3 +1,49 @@
+2001-03-21 Dan Winship <danw@ximian.com>
+
+ * camel-provider.h: (CamelProvider) add a "GList *authtypes", so
+ you can get the list of authtypes used by a provider without
+ needing to have an actual CamelService object handy. (Will be
+ needed by the new config druid.)
+ (CAMEL_PROVIDER_ALLOWS, CAMEL_PROVIDER_NEEDS): New macros to test
+ the URL part stuff, since the way it works is too complicated and
+ everyone always does it wrong.
+
+ * camel-service.c (camel_service_query_auth_types): Remove the
+ @connected arg again: if you don't want to connect, you can just
+ get the list of authtypes off the provider.
+ (camel_service_free_auth_types): Remove this. All existing
+ implementations do authtypes the same way, so just say the caller
+ should "g_list_free" the list. (Oh, look, removing this function
+ doesn't actually cause the mailer to not build. How 'bout that.)
+ (construct, get_path): Use the new URL part macros.
+
+ * camel-remote-store.c (remote_query_auth_types): Update
+ (remote_free_auth_types): Nuke
+ (camel_remote_store_authtype_list): New function for use by
+ subclasses.
+
+ * providers/imap/camel-imap-provider.c:
+ * providers/pop3/camel-pop3-provider.c:
+ * providers/smtp/camel-smtp-provider.c: Update CamelProvider
+ structures.
+ (camel_provider_module_init): Put all the SSL parts together so
+ there's only 1 #ifdef. Set up the provider authtypes field using
+ the SASL, CamelRemoteStore, and standard authtypes, as
+ appropriate. Copy that from the normal provider to the SSL
+ provider.
+
+ * providers/local/camel-local-provider.c:
+ * providers/sendmail/camel-sendmail-provider.c:
+ * camel-session.c: Update CamelProvider structures.
+
+ * providers/imap/camel-imap-store.c (query_auth_types):
+ * providers/pop3/camel-pop3-store.c (query_auth_types): Update
+
+ * providers/smtp/camel-smtp-store.c (query_auth_types): Update.
+ Remove the no_authtype, because that's what "ALLOW_AUTH" rather
+ than "NEED_AUTH" means.
+ (free_auth_types): Nuke.
+
2001-03-21 Jeffrey Stedfast <fejj@ximian.com>
* camel-filter-driver.c (camel_filter_driver_filter_message):
diff --git a/camel/camel-provider.h b/camel/camel-provider.h
index 07d62106ea..4936a77a0e 100644
--- a/camel/camel-provider.h
+++ b/camel/camel-provider.h
@@ -62,22 +62,37 @@ extern char *camel_provider_type_name[CAMEL_NUM_PROVIDER_TYPES];
* for which it has set the NEED flag will be set when the service
* is created.
*/
-#define CAMEL_URL_ALLOW_USER (1 << 0)
-#define CAMEL_URL_ALLOW_AUTH (1 << 1)
-#define CAMEL_URL_ALLOW_PASSWORD (1 << 2)
-#define CAMEL_URL_ALLOW_HOST (1 << 3)
-#define CAMEL_URL_ALLOW_PORT (1 << 4)
-#define CAMEL_URL_ALLOW_PATH (1 << 5)
-
-#define CAMEL_URL_NEED_USER (1 << 6 | 1 << 0)
-#define CAMEL_URL_NEED_AUTH (1 << 7 | 1 << 1)
-#define CAMEL_URL_NEED_PASSWORD (1 << 8 | 1 << 2)
-#define CAMEL_URL_NEED_HOST (1 << 9 | 1 << 3)
-#define CAMEL_URL_NEED_PORT (1 << 10 | 1 << 4)
-#define CAMEL_URL_NEED_PATH (1 << 11 | 1 << 5)
+#define CAMEL_URL_PART_USER (1 << 0)
+#define CAMEL_URL_PART_AUTH (1 << 1)
+#define CAMEL_URL_PART_PASSWORD (1 << 2)
+#define CAMEL_URL_PART_HOST (1 << 3)
+#define CAMEL_URL_PART_PORT (1 << 4)
+#define CAMEL_URL_PART_PATH (1 << 5)
+
+#define CAMEL_URL_PART_NEED 6
+
+/* Use these macros to test a provider's url_flags */
+#define CAMEL_PROVIDER_ALLOWS(prov, flags) (prov->url_flags & (flags | (flags << CAMEL_URL_PART_NEED)))
+#define CAMEL_PROVIDER_NEEDS(prov, flags) (prov->url_flags & (flags << CAMEL_URL_PART_NEED))
+
+/* Providers use these macros to actually define their url_flags */
+#define CAMEL_URL_ALLOW_USER (CAMEL_URL_PART_USER)
+#define CAMEL_URL_ALLOW_AUTH (CAMEL_URL_PART_AUTH)
+#define CAMEL_URL_ALLOW_PASSWORD (CAMEL_URL_PART_PASSWORD)
+#define CAMEL_URL_ALLOW_HOST (CAMEL_URL_PART_HOST)
+#define CAMEL_URL_ALLOW_PORT (CAMEL_URL_PART_PORT)
+#define CAMEL_URL_ALLOW_PATH (CAMEL_URL_PART_PATH)
+
+#define CAMEL_URL_NEED_USER (CAMEL_URL_PART_USER << CAMEL_URL_PART_NEED)
+#define CAMEL_URL_NEED_AUTH (CAMEL_URL_PART_AUTH << CAMEL_URL_PART_NEED)
+#define CAMEL_URL_NEED_PASSWORD (CAMEL_URL_PART_PASSWORD << CAMEL_URL_PART_NEED)
+#define CAMEL_URL_NEED_HOST (CAMEL_URL_PART_HOST << CAMEL_URL_PART_NEED)
+#define CAMEL_URL_NEED_PORT (CAMEL_URL_PART_PORT << CAMEL_URL_PART_NEED)
+#define CAMEL_URL_NEED_PATH (CAMEL_URL_PART_PATH << CAMEL_URL_PART_NEED)
#define CAMEL_URL_PATH_IS_ABSOLUTE (1 << 12)
+
typedef struct {
/* Provider name used in CamelURLs. */
char *protocol;
@@ -99,10 +114,14 @@ typedef struct {
*/
char *domain;
+ /* Flags describing the provider, flags describing its URLs */
int flags, url_flags;
CamelType object_types [CAMEL_NUM_PROVIDER_TYPES];
+ /* GList of CamelServiceAuthTypes the provider supports */
+ GList *authtypes;
+
GHashTable *service_cache;
} CamelProvider;
diff --git a/camel/camel-remote-store.c b/camel/camel-remote-store.c
index 856bcf120f..552c630883 100644
--- a/camel/camel-remote-store.c
+++ b/camel/camel-remote-store.c
@@ -67,8 +67,7 @@ static CamelStoreClass *store_class = NULL;
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, gboolean connect, CamelException *ex);
-static void remote_free_auth_types (CamelService *service, GList *authtypes);
+static GList *remote_query_auth_types(CamelService *service, CamelException *ex);
static char *remote_get_name (CamelService *service, gboolean brief);
static gint remote_send_string (CamelRemoteStore *store, CamelException *ex,
char *fmt, va_list ap);
@@ -90,7 +89,6 @@ camel_remote_store_class_init (CamelRemoteStoreClass *camel_remote_store_class)
camel_service_class->connect = remote_connect;
camel_service_class->disconnect = remote_disconnect;
camel_service_class->query_auth_types = remote_query_auth_types;
- camel_service_class->free_auth_types = remote_free_auth_types;
camel_service_class->get_name = remote_get_name;
camel_remote_store_class->send_string = remote_send_string;
@@ -148,32 +146,23 @@ camel_remote_store_get_type (void)
return camel_remote_store_type;
}
-/* Auth stuff */
-
-/*
-static CamelServiceAuthType password_authtype = {
- N_("SSH Tunneling"),
-
- N_("This option will connect to the server using a "
- "SSH tunnel."),
-
- "",
- TRUE
-};
-*/
+/* Auth stuff... for now, nothing, but eventually SSL at least should
+ * be handled through here, and SSH tunnelling if we ever implement it.
+ */
static GList *
-remote_query_auth_types (CamelService *service, gboolean connect, CamelException *ex)
+remote_query_auth_types (CamelService *service, CamelException *ex)
{
return NULL;
}
-static void
-remote_free_auth_types (CamelService *service, GList *authtypes)
+GList *
+camel_remote_store_authtype_list (void)
{
- g_list_free (authtypes);
+ return NULL;
}
+
static char *
remote_get_name (CamelService *service, gboolean brief)
{
diff --git a/camel/camel-remote-store.h b/camel/camel-remote-store.h
index 1f34eb5a6e..8200c0cf16 100644
--- a/camel/camel-remote-store.h
+++ b/camel/camel-remote-store.h
@@ -68,6 +68,8 @@ CamelType camel_remote_store_get_type (void);
any other functions, anywhere in the world ... */
/* Extra public functions */
+GList *camel_remote_store_authtype_list (void);
+
gint camel_remote_store_send_string (CamelRemoteStore *store, CamelException *ex,
char *fmt, ...);
gint camel_remote_store_send_stream (CamelRemoteStore *store, CamelStream *stream,
diff --git a/camel/camel-service.c b/camel/camel-service.c
index bdaa807572..af9d659688 100644
--- a/camel/camel-service.c
+++ b/camel/camel-service.c
@@ -45,8 +45,7 @@ static gboolean service_connect(CamelService *service, CamelException *ex);
static gboolean service_disconnect(CamelService *service, gboolean clean,
CamelException *ex);
/*static gboolean is_connected (CamelService *service);*/
-static GList * query_auth_types (CamelService *service, gboolean connect, CamelException *ex);
-static void free_auth_types (CamelService *service, GList *authtypes);
+static GList * query_auth_types (CamelService *service, CamelException *ex);
static char * get_name (CamelService *service, gboolean brief);
static char * get_path (CamelService *service);
@@ -61,7 +60,6 @@ camel_service_class_init (CamelServiceClass *camel_service_class)
camel_service_class->connect = service_connect;
camel_service_class->disconnect = service_disconnect;
camel_service_class->query_auth_types = query_auth_types;
- camel_service_class->free_auth_types = free_auth_types;
camel_service_class->get_name = get_name;
camel_service_class->get_path = get_path;
}
@@ -134,8 +132,7 @@ construct (CamelService *service, CamelSession *session,
{
char *url_string;
- if (((provider->url_flags & CAMEL_URL_NEED_USER)
- == CAMEL_URL_NEED_USER) &&
+ if (CAMEL_PROVIDER_NEEDS (provider, CAMEL_URL_PART_USER) &&
(url->user == NULL || url->user[0] == '\0')) {
url_string = camel_url_to_string (url, FALSE);
camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_URL_INVALID,
@@ -143,8 +140,7 @@ construct (CamelService *service, CamelSession *session,
url_string);
g_free (url_string);
return;
- } else if (((provider->url_flags & CAMEL_URL_NEED_HOST)
- == CAMEL_URL_NEED_HOST) &&
+ } else if (CAMEL_PROVIDER_NEEDS (provider, CAMEL_URL_PART_HOST) &&
(url->host == NULL || url->host[0] == '\0')) {
url_string = camel_url_to_string (url, FALSE);
camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_URL_INVALID,
@@ -152,8 +148,7 @@ construct (CamelService *service, CamelSession *session,
url_string);
g_free (url_string);
return;
- } else if (((provider->url_flags & CAMEL_URL_NEED_PATH)
- == CAMEL_URL_NEED_PATH) &&
+ } else if (CAMEL_PROVIDER_NEEDS (provider, CAMEL_URL_PART_PATH) &&
(url->path == NULL || url->path[0] == '\0')) {
url_string = camel_url_to_string (url, FALSE);
camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_URL_INVALID,
@@ -335,29 +330,29 @@ get_path (CamelService *service)
GString *gpath;
char *path;
CamelURL *url = service->url;
- int flags = service->provider->url_flags;
+ CamelProvider *prov = service->provider;
/* A sort of ad-hoc default implementation that works for our
* current set of services.
*/
gpath = g_string_new (service->provider->protocol);
- if (flags & CAMEL_URL_ALLOW_USER) {
- if (flags & CAMEL_URL_ALLOW_HOST) {
+ if (CAMEL_PROVIDER_ALLOWS (prov, CAMEL_URL_PART_USER)) {
+ if (CAMEL_PROVIDER_ALLOWS (prov, CAMEL_URL_PART_HOST)) {
g_string_sprintfa (gpath, "/%s@%s",
url->user ? url->user : "",
url->host ? url->host : "");
} else {
g_string_sprintfa (gpath, "/%s%s",
- url->user ? url->user : "",
- ((flags & CAMEL_URL_NEED_USER) == CAMEL_URL_NEED_USER) ? "" : "@");
+ url->user ? url->user : "",
+ CAMEL_PROVIDER_NEEDS (prov, CAMEL_URL_PART_USER) ? "" : "@");
}
- } else if (flags & CAMEL_URL_ALLOW_HOST) {
+ } else if (CAMEL_PROVIDER_ALLOWS (prov, CAMEL_URL_PART_HOST)) {
g_string_sprintfa (gpath, "/%s%s",
- ((flags & CAMEL_URL_NEED_HOST) == CAMEL_URL_NEED_HOST) ? "" : "@",
- url->host ? url->host : "");
+ CAMEL_PROVIDER_NEEDS (prov, CAMEL_URL_PART_HOST) ? "" : "@",
+ url->host ? url->host : "");
}
- if ((flags & CAMEL_URL_NEED_PATH) == CAMEL_URL_NEED_PATH) {
+ if (CAMEL_PROVIDER_NEEDS (prov, CAMEL_URL_PART_PATH)) {
g_string_sprintfa (gpath, "%s%s",
*url->path == '/' ? "" : "/",
url->path);
@@ -419,7 +414,7 @@ camel_service_get_provider (CamelService *service)
}
static GList *
-query_auth_types (CamelService *service, gboolean connect, CamelException *ex)
+query_auth_types (CamelService *service, CamelException *ex)
{
return NULL;
}
@@ -427,58 +422,29 @@ query_auth_types (CamelService *service, gboolean connect, CamelException *ex)
/**
* camel_service_query_auth_types:
* @service: a CamelService
- * @connect: specifies whether or not to connect
* @ex: a CamelException
*
* This is used by the mail source wizard to get the list of
* authentication types supported by the protocol, and information
* about them.
*
- * This may be called on a service with or without an associated URL.
- * If there is no URL, the routine must return a generic answer. If
- * the service does have a URL, the routine should connect to the
- * server and query what authentication mechanisms it supports only if
- * @connect is TRUE. If it cannot do that for any reason, it should
- * set @ex accordingly.
- *
* Return value: a list of CamelServiceAuthType records. The caller
- * must free the list by calling camel_service_free_auth_types when
- * it is done.
+ * must free the list with g_list_free() when it is done with it.
**/
GList *
-camel_service_query_auth_types (CamelService *service, gboolean connect, CamelException *ex)
+camel_service_query_auth_types (CamelService *service, CamelException *ex)
{
GList *ret;
/* note that we get the connect lock here, which means the callee
must not call the connect functions itself */
CAMEL_SERVICE_LOCK(service, connect_lock);
- ret = CSERV_CLASS (service)->query_auth_types (service, connect, ex);
+ ret = CSERV_CLASS (service)->query_auth_types (service, ex);
CAMEL_SERVICE_UNLOCK(service, connect_lock);
return ret;
}
-static void
-free_auth_types (CamelService *service, GList *authtypes)
-{
- ;
-}
-
-/**
- * camel_service_free_auth_types:
- * @service: the service
- * @authtypes: the list of authtypes
- *
- * This frees the data allocated by camel_service_query_auth_types().
- **/
-void
-camel_service_free_auth_types (CamelService *service, GList *authtypes)
-{
- CSERV_CLASS (service)->free_auth_types (service, authtypes);
-}
-
-
/* URL utility routines */
/**
diff --git a/camel/camel-service.h b/camel/camel-service.h
index aeb71c933d..77b8a542d8 100644
--- a/camel/camel-service.h
+++ b/camel/camel-service.h
@@ -72,10 +72,7 @@ typedef struct {
CamelException *ex);
GList * (*query_auth_types) (CamelService *service,
- gboolean connect,
CamelException *ex);
- void (*free_auth_types) (CamelService *service,
- GList *authtypes);
char * (*get_name) (CamelService *service,
gboolean brief);
@@ -109,10 +106,7 @@ char * camel_service_get_path (CamelService *service);
CamelSession * camel_service_get_session (CamelService *service);
CamelProvider * camel_service_get_provider (CamelService *service);
GList * camel_service_query_auth_types (CamelService *service,
- gboolean connect,
CamelException *ex);
-void camel_service_free_auth_types (CamelService *service,
- GList *authtypes);
/* convenience functions */
struct hostent * camel_service_gethost (CamelService *service,
diff --git a/camel/camel-session.c b/camel/camel-session.c
index cb402a3526..6ec2c5f1cf 100644
--- a/camel/camel-session.c
+++ b/camel/camel-session.c
@@ -57,13 +57,11 @@ static CamelProvider vee_provider = {
"vfolder",
- 0,
+ 0, /* flags */
- 0,
+ 0, /* url_flags */
- { 0, 0 },
-
- NULL
+ /* ... */
};
static void
diff --git a/camel/providers/imap/camel-imap-provider.c b/camel/providers/imap/camel-imap-provider.c
index ea41a2ece8..593231a56e 100644
--- a/camel/providers/imap/camel-imap-provider.c
+++ b/camel/providers/imap/camel-imap-provider.c
@@ -28,6 +28,7 @@
#include "camel-provider.h"
#include "camel-session.h"
#include "camel-url.h"
+#include "camel-sasl.h"
static void add_hash (guint *hash, char *s);
static guint imap_url_hash (gconstpointer key);
@@ -48,9 +49,7 @@ static CamelProvider imap_provider = {
CAMEL_URL_NEED_USER | CAMEL_URL_NEED_HOST |
CAMEL_URL_ALLOW_PATH | CAMEL_URL_ALLOW_AUTH,
- { 0, 0 },
-
- NULL
+ /* ... */
};
#if defined (HAVE_NSS) || defined (HAVE_OPENSSL)
@@ -68,30 +67,38 @@ static CamelProvider simap_provider = {
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 */
+CamelServiceAuthType camel_imap_password_authtype = {
+ N_("Password"),
+
+ N_("This option will connect to the IMAP server using a "
+ "plaintext password."),
+
+ "",
+ TRUE
+};
+
void
camel_provider_module_init (CamelSession *session)
{
imap_provider.object_types[CAMEL_PROVIDER_STORE] =
camel_imap_store_get_type ();
+ imap_provider.service_cache = g_hash_table_new (imap_url_hash, imap_url_equal);
+ imap_provider.authtypes = g_list_concat (camel_remote_store_authtype_list (),
+ camel_sasl_authtype_list ());
+ imap_provider.authtypes = g_list_prepend (imap_provider.authtypes,
+ &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 ();
-#endif
-
- imap_provider.service_cache = g_hash_table_new (imap_url_hash, imap_url_equal);
-
-#if defined (HAVE_NSS) || defined (HAVE_OPENSSL)
simap_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)
+ simap_provider.authtypes = g_list_copy (imap_provider.authtypes);
camel_session_register_provider (session, &simap_provider);
#endif
}
diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c
index 21eb673945..f5dd7ba089 100644
--- a/camel/providers/imap/camel-imap-store.c
+++ b/camel/providers/imap/camel-imap-store.c
@@ -63,7 +63,7 @@ static void construct (CamelService *service, CamelSession *session,
CamelException *ex);
static gboolean imap_connect (CamelService *service, CamelException *ex);
static gboolean imap_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 guint hash_folder_name (gconstpointer key);
static gint compare_folder_name (gconstpointer a, gconstpointer b);
static CamelFolder *get_folder (CamelStore *store, const char *folder_name, guint32 flags, CamelException *ex);
@@ -301,42 +301,35 @@ connect_to_server (CamelService *service, CamelException *ex)
return TRUE;
}
-static CamelServiceAuthType password_authtype = {
- N_("Password"),
-
- N_("This option will connect to the IMAP server using a "
- "plaintext password."),
-
- "",
- TRUE
-};
+extern CamelServiceAuthType camel_imap_password_authtype;
static GList *
-query_auth_types (CamelService *service, gboolean connect, CamelException *ex)
+query_auth_types (CamelService *service, CamelException *ex)
{
CamelImapStore *store = CAMEL_IMAP_STORE (service);
CamelServiceAuthType *authtype;
- GList *types, *sasl_types, *t;
+ GList *types, *sasl_types, *t, *next;
- if (connect && !connect_to_server (service, ex))
+ if (!connect_to_server (service, ex))
return NULL;
- types = CAMEL_SERVICE_CLASS (remote_store_class)->query_auth_types (service, connect, ex);
+ types = CAMEL_SERVICE_CLASS (remote_store_class)->query_auth_types (service, ex);
+ if (camel_exception_is_set (ex))
+ return types;
sasl_types = camel_sasl_authtype_list ();
- if (connect) {
- for (t = types; t; t = t->next) {
- authtype = t->data;
+ for (t = sasl_types; t; t = next) {
+ authtype = t->data;
+ next = t->next;
- if (!g_hash_table_lookup (store->authtypes, authtype->authproto)) {
- g_list_remove_link (types, t);
- g_list_free_1 (t);
- }
+ if (!g_hash_table_lookup (store->authtypes, authtype->authproto)) {
+ sasl_types = g_list_remove_link (sasl_types, t);
+ g_list_free_1 (t);
}
}
types = g_list_concat (types, sasl_types);
- return g_list_prepend (types, &password_authtype);
+ return g_list_prepend (types, &camel_imap_password_authtype);
}
/* call refresh folder directly, bypassing the folder lock */
diff --git a/camel/providers/local/camel-local-provider.c b/camel/providers/local/camel-local-provider.c
index 2d66d59503..59c2982ace 100644
--- a/camel/providers/local/camel-local-provider.c
+++ b/camel/providers/local/camel-local-provider.c
@@ -38,8 +38,7 @@ static CamelProvider mh_provider = {
"mail",
CAMEL_PROVIDER_IS_STORAGE,
CAMEL_URL_NEED_PATH | CAMEL_URL_PATH_IS_ABSOLUTE,
- {0, 0},
- NULL
+ /* ... */
};
static CamelProvider mbox_provider = {
@@ -49,8 +48,7 @@ static CamelProvider mbox_provider = {
"mail",
CAMEL_PROVIDER_IS_SOURCE | CAMEL_PROVIDER_IS_STORAGE,
CAMEL_URL_NEED_PATH | CAMEL_URL_PATH_IS_ABSOLUTE,
- { 0, 0 },
- NULL
+ /* ... */
};
static CamelProvider maildir_provider = {
@@ -60,8 +58,7 @@ static CamelProvider maildir_provider = {
"mail",
CAMEL_PROVIDER_IS_SOURCE | CAMEL_PROVIDER_IS_STORAGE,
CAMEL_URL_NEED_PATH | CAMEL_URL_PATH_IS_ABSOLUTE,
- { 0, 0 },
- NULL
+ /* ... */
};
void camel_provider_module_init(CamelSession * session)
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;
}
diff --git a/camel/providers/sendmail/camel-sendmail-provider.c b/camel/providers/sendmail/camel-sendmail-provider.c
index d0e40b4cf8..5a7cfb82db 100644
--- a/camel/providers/sendmail/camel-sendmail-provider.c
+++ b/camel/providers/sendmail/camel-sendmail-provider.c
@@ -38,13 +38,11 @@ static CamelProvider sendmail_provider = {
"mail",
- 0,
+ 0, /* flags */
- 0,
+ 0, /* url_flags */
- { 0, 0 },
-
- NULL
+ /* ... */
};
void
diff --git a/camel/providers/smtp/camel-smtp-provider.c b/camel/providers/smtp/camel-smtp-provider.c
index ec173ac5e8..a3905daa02 100644
--- a/camel/providers/smtp/camel-smtp-provider.c
+++ b/camel/providers/smtp/camel-smtp-provider.c
@@ -28,6 +28,7 @@
#include "camel-provider.h"
#include "camel-session.h"
#include "camel-url.h"
+#include "camel-sasl.h"
static CamelProvider smtp_provider = {
"smtp",
@@ -42,9 +43,7 @@ static CamelProvider smtp_provider = {
CAMEL_URL_NEED_HOST | CAMEL_URL_ALLOW_AUTH,
- { 0, 0 },
-
- NULL
+ /* ... */
};
#if defined (HAVE_NSS) || defined (HAVE_OPENSSL)
@@ -61,9 +60,7 @@ static CamelProvider ssmtp_provider = {
CAMEL_URL_NEED_HOST | CAMEL_URL_ALLOW_AUTH,
- { 0, 0 },
-
- NULL
+ /* ... */
};
#endif
@@ -72,19 +69,17 @@ camel_provider_module_init (CamelSession *session)
{
smtp_provider.object_types[CAMEL_PROVIDER_TRANSPORT] =
camel_smtp_transport_get_type ();
-#if defined (HAVE_NSS) || defined (HAVE_OPENSSL)
- ssmtp_provider.object_types[CAMEL_PROVIDER_TRANSPORT] =
- camel_smtp_transport_get_type ();
-#endif
-
+ smtp_provider.authtypes = camel_sasl_authtype_list ();
smtp_provider.service_cache = g_hash_table_new (camel_url_hash, camel_url_equal);
-#if defined (HAVE_NSS) || defined (HAVE_OPENSSL)
- ssmtp_provider.service_cache = g_hash_table_new (camel_url_hash, camel_url_equal);
-#endif
-
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 9d60891f04..9a6ae102bf 100644
--- a/camel/providers/smtp/camel-smtp-transport.c
+++ b/camel/providers/smtp/camel-smtp-transport.c
@@ -70,8 +70,7 @@ static gboolean smtp_send_to (CamelTransport *transport, CamelMedium *message, G
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);
-static GList *query_auth_types (CamelService *service, gboolean connect, CamelException *ex);
-static void free_auth_types (CamelService *service, GList *authtypes);
+static GList *query_auth_types (CamelService *service, CamelException *ex);
static char *get_name (CamelService *service, gboolean brief);
static gboolean smtp_helo (CamelSmtpTransport *transport, CamelException *ex);
@@ -101,7 +100,6 @@ camel_smtp_transport_class_init (CamelSmtpTransportClass *camel_smtp_transport_c
camel_service_class->connect = smtp_connect;
camel_service_class->disconnect = smtp_disconnect;
camel_service_class->query_auth_types = query_auth_types;
- camel_service_class->free_auth_types = free_auth_types;
camel_service_class->get_name = get_name;
camel_transport_class->can_send = smtp_can_send;
@@ -465,46 +463,28 @@ esmtp_get_authtypes (char *buffer)
return table;
}
-static CamelServiceAuthType no_authtype = {
- N_("No authentication required"),
-
- N_("This option will connect to the SMTP server without using any "
- "kind of authentication. This should be fine for connecting to "
- "most SMTP servers."),
-
- "",
- FALSE
-};
-
static GList *
-query_auth_types (CamelService *service, gboolean connect, CamelException *ex)
+query_auth_types (CamelService *service, CamelException *ex)
{
CamelSmtpTransport *transport = CAMEL_SMTP_TRANSPORT (service);
CamelServiceAuthType *authtype;
- GList *types, *t;
+ GList *types, *t, *next;
- if (connect && !smtp_connect (service, ex))
+ if (!smtp_connect (service, ex))
return NULL;
types = camel_sasl_authtype_list ();
- if (connect) {
- for (t = types; t; t = t->next) {
- authtype = t->data;
-
- if (!g_hash_table_lookup (transport->authtypes, authtype->authproto)) {
- g_list_remove_link (types, t);
- g_list_free_1 (t);
- }
+ for (t = types; t; t = next) {
+ authtype = t->data;
+ next = t->next;
+
+ if (!g_hash_table_lookup (transport->authtypes, authtype->authproto)) {
+ types = g_list_remove_link (types, t);
+ g_list_free_1 (t);
}
}
- return g_list_prepend (types, &no_authtype);
-}
-
-static void
-free_auth_types (CamelService *service, GList *authtypes)
-{
- g_list_free (authtypes);
+ return types;
}
static char *