summaryrefslogtreecommitdiff
path: root/telepathy-glib/simple-password-manager.c
diff options
context:
space:
mode:
authorJonathon Jongsma <jonathon.jongsma@collabora.co.uk>2011-02-08 12:13:42 -0600
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2011-02-24 15:19:26 +0100
commit3c8778038dd11f9eb97a2ac89c439b36fe75617b (patch)
tree651ebfe55d689b6dbf3be6d6ca5db2d68be432bd /telepathy-glib/simple-password-manager.c
parent8a4d453b7c040845991c4ca900758fd7a4d37611 (diff)
downloadtelepathy-glib-3c8778038dd11f9eb97a2ac89c439b36fe75617b.tar.gz
SimplePasswordManager: add prompt_for_channel_async() API
This API allows applications to supply their own channel object to be used in the password manager. The use case for this is when an authentication channel needs to implement additional interfaces. In this case, they can inherit from TpSimplePasswordChannel and implement these custom interfaces in the subclass.
Diffstat (limited to 'telepathy-glib/simple-password-manager.c')
-rw-r--r--telepathy-glib/simple-password-manager.c72
1 files changed, 56 insertions, 16 deletions
diff --git a/telepathy-glib/simple-password-manager.c b/telepathy-glib/simple-password-manager.c
index 8bbe12395..3ced9fc8a 100644
--- a/telepathy-glib/simple-password-manager.c
+++ b/telepathy-glib/simple-password-manager.c
@@ -334,8 +334,9 @@ tp_simple_password_manager_channel_finished_cb (
}
/**
- * tp_simple_password_manager_prompt_async:
+ * tp_simple_password_manager_prompt_for_channel_async:
* @self: a #TpSimplePasswordManager
+ * @channel: a #TpSimplePasswordChannel
* @callback: a callback to call when the request is satisfied
* @user_data: data to pass to @callback
*
@@ -347,34 +348,47 @@ tp_simple_password_manager_channel_finished_cb (
* call tp_simple_password_manager_prompt_finish() to get the
* result of the request.
*
- * Since: 0.13.8
+ * Most of the time, tp_simple_password_manager_prompt_async() should be used
+ * instead. This function enables applications to provide custom channels
+ * instead of letting the password manager handle all of the channel details
+ * automatically. This may be useful if your SASL channel needs to implement
+ * additional interfaces (such as Channel.Interface.CredentialsStorage)
+ *
+ * Since: 0.13.UNRELEASED
*/
void
-tp_simple_password_manager_prompt_async (
+tp_simple_password_manager_prompt_for_channel_async (
TpSimplePasswordManager *self,
+ TpSimplePasswordChannel *channel,
GAsyncReadyCallback callback,
gpointer user_data)
{
TpSimplePasswordManagerPrivate *priv = self->priv;
TpBaseConnection *base_conn = priv->conn;
- gchar *object_path;
g_return_if_fail (TP_IS_SIMPLE_PASSWORD_MANAGER (self));
g_return_if_fail (priv->channel == NULL);
g_return_if_fail (priv->result == NULL);
- object_path = g_strdup_printf ("%s/SimplePasswordChannel",
- base_conn->object_path);
-
- priv->channel = g_object_new (TP_TYPE_SIMPLE_PASSWORD_CHANNEL,
- "connection", priv->conn,
- "object-path", object_path,
- "handle", 0,
- "requested", FALSE,
- "initiator-handle", base_conn->self_handle,
- NULL);
-
- g_free (object_path);
+ if (channel != NULL)
+ {
+ priv->channel = g_object_ref (channel);
+ }
+ else
+ {
+ gchar *object_path = g_strdup_printf ("%s/SimplePasswordChannel",
+ base_conn->object_path);
+
+ priv->channel = g_object_new (TP_TYPE_SIMPLE_PASSWORD_CHANNEL,
+ "connection", priv->conn,
+ "object-path", object_path,
+ "handle", 0,
+ "requested", FALSE,
+ "initiator-handle", base_conn->self_handle,
+ NULL);
+
+ g_free (object_path);
+ }
priv->result = G_ASYNC_RESULT (g_simple_async_result_new (G_OBJECT (self),
callback, user_data, tp_simple_password_manager_prompt_async));
@@ -392,6 +406,32 @@ tp_simple_password_manager_prompt_async (
}
/**
+ * tp_simple_password_manager_prompt_async:
+ * @self: a #TpSimplePasswordManager
+ * @callback: a callback to call when the request is satisfied
+ * @user_data: data to pass to @callback
+ *
+ * Pops up a new server authentication channel and handles the
+ * X-TELEPATHY-PASSWORD mechanism to obtain a password for the
+ * connection.
+ *
+ * When the operation is finished, @callback will be called. You must then
+ * call tp_simple_password_manager_prompt_finish() to get the
+ * result of the request.
+ *
+ * Since: 0.13.8
+ */
+void
+tp_simple_password_manager_prompt_async (
+ TpSimplePasswordManager *self,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ tp_simple_password_manager_prompt_for_channel_async (self, NULL, callback,
+ user_data);
+}
+
+/**
* tp_simple_password_manager_prompt_finish:
* @self: a #TpSimplePasswordManager
* @result: a #GAsyncResult