aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy/empathy-server-sasl-handler.c
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2011-09-14 22:43:25 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2011-09-14 22:43:48 +0800
commit6ac4e08359a3d5c33e2f38dcd0129b5180810bba (patch)
treeff1db62c663e723759d971b79e0b9b019ab52fc8 /libempathy/empathy-server-sasl-handler.c
parentba16c4a15b9977e61461bd9f222104eaa2204ee3 (diff)
downloadgsoc2013-empathy-6ac4e08359a3d5c33e2f38dcd0129b5180810bba.tar
gsoc2013-empathy-6ac4e08359a3d5c33e2f38dcd0129b5180810bba.tar.gz
gsoc2013-empathy-6ac4e08359a3d5c33e2f38dcd0129b5180810bba.tar.bz2
gsoc2013-empathy-6ac4e08359a3d5c33e2f38dcd0129b5180810bba.tar.lz
gsoc2013-empathy-6ac4e08359a3d5c33e2f38dcd0129b5180810bba.tar.xz
gsoc2013-empathy-6ac4e08359a3d5c33e2f38dcd0129b5180810bba.tar.zst
gsoc2013-empathy-6ac4e08359a3d5c33e2f38dcd0129b5180810bba.zip
sasl-handler: only save password if we manage to connect
https://bugzilla.gnome.org/show_bug.cgi?id=659053
Diffstat (limited to 'libempathy/empathy-server-sasl-handler.c')
-rw-r--r--libempathy/empathy-server-sasl-handler.c56
1 files changed, 34 insertions, 22 deletions
diff --git a/libempathy/empathy-server-sasl-handler.c b/libempathy/empathy-server-sasl-handler.c
index b06d7bf4c..78db431e6 100644
--- a/libempathy/empathy-server-sasl-handler.c
+++ b/libempathy/empathy-server-sasl-handler.c
@@ -50,6 +50,7 @@ typedef struct {
GSimpleAsyncResult *result;
gchar *password;
+ gboolean save_password;
GSimpleAsyncResult *async_init_res;
} EmpathyServerSASLHandlerPriv;
@@ -71,6 +72,25 @@ static const gchar *sasl_statuses[] = {
};
static void
+empathy_server_sasl_handler_set_password_cb (GObject *source,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ GError *error = NULL;
+
+ if (!empathy_keyring_set_account_password_finish (TP_ACCOUNT (source), result,
+ &error))
+ {
+ DEBUG ("Failed to set password: %s", error->message);
+ g_clear_error (&error);
+ }
+ else
+ {
+ DEBUG ("Password set successfully.");
+ }
+}
+
+static void
sasl_status_changed_cb (TpChannel *channel,
TpSASLStatus status,
const gchar *error,
@@ -91,6 +111,15 @@ sasl_status_changed_cb (TpChannel *channel,
if (status == TP_SASL_STATUS_SERVER_SUCCEEDED)
{
+ if (priv->save_password)
+ {
+ DEBUG ("Saving password in keyring");
+
+ empathy_keyring_set_account_password_async (priv->account,
+ priv->password, empathy_server_sasl_handler_set_password_cb,
+ NULL);
+ }
+
DEBUG ("Calling AcceptSASL");
tp_cli_channel_interface_sasl_authentication_call_accept_sasl (
priv->channel, -1, NULL, NULL, NULL, NULL);
@@ -369,25 +398,6 @@ start_mechanism_with_data_cb (TpChannel *proxy,
DEBUG ("Started mechanism successfully");
}
-static void
-empathy_server_sasl_handler_set_password_cb (GObject *source,
- GAsyncResult *result,
- gpointer user_data)
-{
- GError *error = NULL;
-
- if (!empathy_keyring_set_account_password_finish (TP_ACCOUNT (source), result,
- &error))
- {
- DEBUG ("Failed to set password: %s", error->message);
- g_clear_error (&error);
- }
- else
- {
- DEBUG ("Password set successfully.");
- }
-}
-
void
empathy_server_sasl_handler_provide_password (
EmpathyServerSASLHandler *handler,
@@ -433,9 +443,11 @@ empathy_server_sasl_handler_provide_password (
{
if (may_save_response)
{
- DEBUG ("Saving password in keyring");
- empathy_keyring_set_account_password_async (priv->account, password,
- empathy_server_sasl_handler_set_password_cb, NULL);
+ g_free (priv->password);
+
+ /* We'll save the password if we manage to connect */
+ priv->password = g_strdup (password);
+ priv->save_password = TRUE;
}
else if (tp_proxy_has_interface_by_id (priv->channel,
EMP_IFACE_QUARK_CHANNEL_INTERFACE_CREDENTIALS_STORAGE))