Adding tny_camel_account_get_supported_secure_authentication().
- From: Murray Cumming <murrayc murrayc com>
- To: tinymail-devel-list <tinymail-devel-list gnome org>
- Subject: Adding tny_camel_account_get_supported_secure_authentication().
- Date: Mon, 14 May 2007 22:35:08 +0200
This patch adds a
tny_camel_account_get_supported_secure_authentication() that uses camel
to query the server for supported secure authentication mechanisms. It
seems to work, though I'm not sure if I have used the lock properly, or
if I need to.
This needs to be async, so I guess I should change the signature to
something like this:
typedef void (TnyCamelGetSupportedSecureAuthCallback)
(TnyCamelAccount *self, GList *auth_types, GError **err, gpointer
user_data);
void tny_camel_account_get_supported_secure_authentication(
TnyCamelAccount *self,
TnyCamelGetSupportedSecureAuthCallback callback,
TnyStatusCallback status_callback,
gpointer user_data);
I'm just looking for confirmation that that's sensible and appropriate.
--
Murray Cumming
murrayc murrayc com
www.murrayc.com
www.openismus.com
Index: libtinymail-camel/tny-camel-account-priv.h
===================================================================
--- libtinymail-camel/tny-camel-account-priv.h (revision 1954)
+++ libtinymail-camel/tny-camel-account-priv.h (working copy)
@@ -27,8 +27,12 @@
struct _TnyCamelAccountPriv
{
TnySessionCamel *session;
+
GStaticRecMutex *service_lock;
+
+ /* Set in tny_camel_store_account_prepare(). */
CamelService *service;
+
CamelException *ex;
gchar *url_string, *id, *user, *host, *proto, *mech;
TnyGetPassFunc get_pass_func;
Index: libtinymail-camel/tny-camel-store-account.c
===================================================================
--- libtinymail-camel/tny-camel-store-account.c (revision 1954)
+++ libtinymail-camel/tny-camel-store-account.c (working copy)
@@ -91,8 +91,11 @@
GList *options = apriv->options;
gchar *proto;
- if (apriv->proto == NULL)
+ if (apriv->proto == NULL) {
+ g_warning ("%s: apriv->proto is NULL. "
+ "You might need to call tny_account_set_proto().", __FUNCTION__);
return;
+ }
proto = g_strdup_printf ("%s://", apriv->proto);
Index: libtinymail-camel/tny-camel-account.c
===================================================================
--- libtinymail-camel/tny-camel-account.c (revision 1954)
+++ libtinymail-camel/tny-camel-account.c (working copy)
@@ -1109,3 +1109,48 @@
return type;
}
+
+/* tny_camel_account_get_supported_secure_authentication:
+ * @self: a #TnyCamelAccount object.
+ * @result: A GSList of gchar* secure authentication mechanisms. This
+ * should be freed with g_slist_free() after calling g_free() on each
+ * item's data.
+ *
+ * Query the server for the list of supported secure authentication mechanisms.
+ * The #TnyCamelAccount must have a valid hostname and the port number
+ * must be set if appropriate.
+ * The returned strings may be used as parameters to
+ * tny_account_set_secure_auth_mech().
+ */
+GList *tny_camel_account_get_supported_secure_authentication(TnyCamelAccount *self)
+{
+ TnyCamelAccountPriv *priv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (self);
+
+ g_return_val_if_fail (priv->session, NULL);
+
+ GList * result = NULL;
+
+ g_static_rec_mutex_lock (priv->service_lock);
+
+ GList *authtypes= camel_service_query_auth_types (priv->service, priv->ex);
+ GList *iter = authtypes;
+ while (iter) {
+ CamelServiceAuthType *item = (CamelServiceAuthType *)iter->data;
+ if (item) {
+ /* Get the name of the auth method:
+ * Note that, at least for IMAP, authproto=NULL when
+ * name=Password. */
+ /* printf ("DEBUG: %s: authproto =%s, name=%s\n", __FUNCTION__,
+ * item->authproto, item->name); */
+ result = g_list_append (result, g_strdup (item->authproto));
+ }
+
+ iter = g_list_next (iter);
+ }
+ g_list_free (authtypes);
+
+ g_static_rec_mutex_unlock (priv->service_lock);
+
+ return result;
+}
+
Index: libtinymail-camel/tny-camel-account.h
===================================================================
--- libtinymail-camel/tny-camel-account.h (revision 1954)
+++ libtinymail-camel/tny-camel-account.h (working copy)
@@ -88,6 +88,8 @@
void tny_camel_account_set_session (TnyCamelAccount *self, TnySessionCamel *session);
void tny_camel_account_set_online (TnyCamelAccount *self, gboolean online, GError **err);
+GList* tny_camel_account_get_supported_secure_authentication(TnyCamelAccount *self);
+
G_END_DECLS
#endif
Index: ChangeLog
===================================================================
--- ChangeLog (revision 1954)
+++ ChangeLog (working copy)
@@ -1,3 +1,11 @@
+2007-05-14 Murray Cumming <murrayc murrayc com>
+
+ * libtinymail-camel/tny-camel-account.h:
+ * libtinymail-camel/tny-camel-account.c:
+ Added tny_camel_account_get_supported_secure_authentication(),
+ to get a list of strings for use with tny_account_set_secure_auth_mech(),
+ by querying the server.
+
2007-05-14 Philip Van Hoof <pvanhoof gnome org>
* Waiting for the + continuation after IDLE
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]