GSimpleAsyncResult *result;
gchar *password;
+ gboolean save_password;
GSimpleAsyncResult *async_init_res;
} EmpathyServerSASLHandlerPriv;
"client failed",
};
+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,
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);
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,
{
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))