*/
#include "config.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include <telepathy-glib/account-manager.h>
-#include <telepathy-glib/util.h>
-#include <telepathy-glib/interfaces.h>
-#include <telepathy-glib/gtypes.h>
-
#include "empathy-account-settings.h"
+
#include "empathy-connection-managers.h"
#include "empathy-keyring.h"
-#include "empathy-utils.h"
#include "empathy-presence-manager.h"
+#include "empathy-utils.h"
#define DEBUG_FLAG EMPATHY_DEBUG_ACCOUNT
-#include <libempathy/empathy-debug.h>
+#include "empathy-debug.h"
#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyAccountSettings)
gchar *service;
gchar *display_name;
gchar *icon_name;
+ gchar *storage_provider;
gboolean display_name_overridden;
gboolean ready;
gboolean supports_sasl;
- gboolean password_changed;
+ gboolean remember_password;
gchar *password;
gchar *password_original;
g_free (priv->service);
priv->cm_name =
- g_strdup (tp_account_get_connection_manager (priv->account));
+ g_strdup (tp_account_get_cm_name (priv->account));
priv->protocol =
- g_strdup (tp_account_get_protocol (priv->account));
+ g_strdup (tp_account_get_protocol_name (priv->account));
priv->service =
g_strdup (tp_account_get_service (priv->account));
priv->icon_name = g_strdup
g_free (priv->icon_name);
g_free (priv->password);
g_free (priv->password_original);
+ g_free (priv->storage_provider);
if (priv->required_params != NULL)
{
g_signal_emit (self, signals[PASSWORD_RETRIEVED], 0);
}
-static void
-empathy_account_settings_migrate_password_cb (GObject *source,
- GAsyncResult *result,
- gpointer user_data)
-{
- TpAccount *account = TP_ACCOUNT (source);
- GError *error = NULL;
- EmpathyAccountSettings *self = user_data;
- EmpathyAccountSettingsPriv *priv = GET_PRIV (self);
- GHashTable *empty;
- const gchar *unset[] = { "password", NULL };
-
- if (!empathy_keyring_set_account_password_finish (account, result, &error))
- {
- DEBUG ("Failed to set password: %s", error->message);
- g_clear_error (&error);
- return;
- }
-
- /* Now clear the password MC has stored. */
- empty = tp_asv_new (NULL, NULL);
- tp_account_update_parameters_async (priv->account,
- empty, unset, NULL, NULL);
-
- g_hash_table_remove (priv->parameters, "password");
-
- g_hash_table_unref (empty);
-}
-
static GVariant * empathy_account_settings_dup (
EmpathyAccountSettings *settings,
const gchar *param);
-static void
-empathy_account_settings_try_migrating_password (EmpathyAccountSettings *self)
-{
- EmpathyAccountSettingsPriv *priv = GET_PRIV (self);
- GVariant *v;
- const gchar *password;
-
- v = empathy_account_settings_dup (self, "password");
- if (v == NULL)
- return;
-
- if (!priv->supports_sasl)
- goto out;
-
- /* mission-control still has our password, although the CM
- * supports SASL. Let's try migrating it. */
-
- DEBUG ("Trying to migrate password parameter from MC to the "
- "keyring ourselves for account %s",
- tp_account_get_path_suffix (priv->account));
-
- /* I can't imagine why this would fail. */
- if (!g_variant_is_of_type (v, G_VARIANT_TYPE_STRING))
- goto out;
-
- password = g_variant_get_string (v, NULL);
-
- if (EMP_STR_EMPTY (password))
- goto out;
-
- empathy_keyring_set_account_password_async (priv->account, password,
- empathy_account_settings_migrate_password_cb, self);
-
- /* We don't want to request the password again, we
- * already know it. */
- priv->password_requested = TRUE;
-
- priv->password = g_strdup (password);
- priv->password_original = g_strdup (password);
-
-out:
- g_variant_unref (v);
-}
-
static void
empathy_account_settings_check_readyness (EmpathyAccountSettings *self)
{
(GDestroyNotify) tp_connection_manager_param_free);
}
- /* NOTE: When removing MC migration code, remove this call, and the
- * function it's calling. That's it. */
- empathy_account_settings_try_migrating_password (self);
-
/* priv->account won't be a proper account if it's the account
* assistant showing this widget. */
if (priv->supports_sasl && !priv->password_requested
{
g_free (priv->password);
priv->password = NULL;
- priv->password_changed = TRUE;
return;
}
g_hash_table_remove_all (priv->parameters);
empathy_account_settings_free_unset_parameters (settings);
- priv->password_changed = FALSE;
g_free (priv->password);
priv->password = g_strdup (priv->password_original);
{
g_free (priv->password);
priv->password = g_variant_dup_string (v, NULL);
- priv->password_changed = TRUE;
}
else
{
goto out;
}
- /* Only set the password in the keyring if the CM supports SASL and
- * it's changed. */
- if (priv->supports_sasl && priv->password_changed)
+ update_account_uri_schemes (settings);
+ update_account_service (settings);
+
+ g_simple_async_result_set_op_res_gboolean (priv->apply_result,
+ g_strv_length (reconnect_required) > 0);
+
+ /* Only set the password in the keyring if the CM supports SASL. */
+ if (priv->supports_sasl)
{
if (priv->password != NULL)
{
/* FIXME: we shouldn't save the password if we
* can't (MaySaveResponse=False) but we don't have API to check that
* at this point (fdo #35382). */
- empathy_keyring_set_account_password_async (priv->account, priv->password,
+ empathy_keyring_set_account_password_async (priv->account,
+ priv->password, priv->remember_password,
empathy_account_settings_set_password_cb, settings);
}
else
return;
}
- update_account_uri_schemes (settings);
- update_account_service (settings);
-
- g_simple_async_result_set_op_res_gboolean (priv->apply_result,
- g_strv_length (reconnect_required) > 0);
-
out:
empathy_account_settings_discard_changes (settings);
* can't (MaySaveResponse=False) but we don't have API to check that
* at this point (fdo #35382). */
empathy_keyring_set_account_password_async (priv->account,
- priv->password, empathy_account_settings_set_password_cb,
+ priv->password, priv->remember_password,
+ empathy_account_settings_set_password_cb,
settings);
return;
}
tp_account_request_set_parameter (account_req, key, value);
}
+ if (priv->storage_provider != NULL)
+ {
+ tp_account_request_set_storage_provider (account_req,
+ priv->storage_provider);
+ }
+
tp_account_request_create_account_async (account_req,
empathy_account_settings_created_cb, self);
}
return priv->uri_scheme_tel;
}
+
+void
+empathy_account_settings_set_storage_provider (EmpathyAccountSettings *self,
+ const gchar *storage)
+{
+ EmpathyAccountSettingsPriv *priv = GET_PRIV (self);
+
+ g_free (priv->storage_provider);
+ priv->storage_provider = g_strdup (storage);
+}
+
+void
+empathy_account_settings_set_remember_password (EmpathyAccountSettings *self,
+ gboolean remember)
+{
+ EmpathyAccountSettingsPriv *priv = GET_PRIV (self);
+
+ priv->remember_password = remember;
+}