[Evolution-hackers] [PATCH 2/3] Add asynchronous camel_sasl_try_empty_password()



---
 camel/camel-sasl.c |   49 +++++++++++++++++++++++++++++++++++++++++++++++++
 camel/camel-sasl.h |    8 ++++++++
 2 files changed, 57 insertions(+), 0 deletions(-)

diff --git a/camel/camel-sasl.c b/camel/camel-sasl.c
index 58a4a2b..90b64d6 100644
--- a/camel/camel-sasl.c
+++ b/camel/camel-sasl.c
@@ -288,6 +288,53 @@ sasl_challenge_finish (CamelSasl *sasl,
 }
 
 static void
+sasl_try_empty_password_thread (GSimpleAsyncResult *simple,
+				GObject *object,
+				GCancellable *cancellable)
+{
+	gboolean res;
+
+	res = camel_sasl_try_empty_password_sync (CAMEL_SASL (object), cancellable);
+
+	g_simple_async_result_set_op_res_gboolean (simple, res);
+}
+
+static void
+sasl_try_empty_password (CamelSasl *sasl,
+			 gint io_priority,
+			 GCancellable *cancellable,
+			 GAsyncReadyCallback callback,
+			 gpointer user_data)
+{
+	GSimpleAsyncResult *simple;
+
+	simple = g_simple_async_result_new (
+		G_OBJECT (sasl), callback, user_data, sasl_try_empty_password);
+
+	g_simple_async_result_run_in_thread (
+		simple, sasl_try_empty_password_thread, io_priority, cancellable);
+
+	g_object_unref (simple);
+}
+
+static gboolean
+sasl_try_empty_password_finish (CamelSasl *sasl,
+				GAsyncResult *result)
+{
+	GSimpleAsyncResult *simple;
+	gboolean res;
+
+	g_return_val_if_fail (
+		g_simple_async_result_is_valid (
+		result, G_OBJECT (sasl), sasl_try_empty_password), FALSE);
+
+	simple = G_SIMPLE_ASYNC_RESULT (result);
+	res = g_simple_async_result_get_op_res_gboolean (simple);
+
+	return res;
+}
+
+static void
 camel_sasl_class_init (CamelSaslClass *class)
 {
 	GObjectClass *object_class;
@@ -302,6 +349,8 @@ camel_sasl_class_init (CamelSaslClass *class)
 
 	class->challenge = sasl_challenge;
 	class->challenge_finish = sasl_challenge_finish;
+	class->try_empty_password = sasl_try_empty_password;
+	class->try_empty_password_finish = sasl_try_empty_password_finish;
 
 	g_object_class_install_property (
 		object_class,
diff --git a/camel/camel-sasl.h b/camel/camel-sasl.h
index eede608..4ef9b41 100644
--- a/camel/camel-sasl.h
+++ b/camel/camel-sasl.h
@@ -82,6 +82,14 @@ struct _CamelSaslClass {
 	GByteArray *	(*challenge_finish)	(CamelSasl *sasl,
 						 GAsyncResult *result,
 						 GError **error);
+	void		(*try_empty_password)	(CamelSasl *sasl,
+						 gint io_priority,
+						 GCancellable *cancellable,
+						 GAsyncReadyCallback callback,
+						 gpointer user_data);
+	gboolean	(*try_empty_password_finish)
+						(CamelSasl *sasl,
+						 GAsyncResult *result);
 };
 
 GType		camel_sasl_get_type		(void);
-- 
1.7.4





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]