static void
uoa_initial_identity_store_cb (SignonIdentity *identity,
    guint32 id,
    const GError *error,
    gpointer user_data)
{
  UoaChangePasswordData *data = user_data;
  AgAccount *account = ag_account_service_get_account (data->service);
  GValue value = G_VALUE_INIT;

  if (error != NULL)
    {
      g_simple_async_result_set_from_error (data->result, error);
      /* libaccounts-glib API does not guarantee the callback happens after
       * reentering mainloop */
      g_simple_async_result_complete_in_idle (data->result);
      uoa_change_password_data_free (data);
      g_object_unref (identity);
      return;
    }

  g_value_init (&value, G_TYPE_UINT);
  g_value_set_uint (&value, id);
  ag_account_select_service (account, NULL);
  ag_account_set_value (account, "CredentialsId", &value);
  g_value_unset (&value);

  ag_account_store (account, uoa_initial_account_store_cb, data);

  g_object_unref (identity);
}
static void
uoa_identity_query_info_cb (SignonIdentity *identity,
    const SignonIdentityInfo *info,
    const GError *error,
    gpointer user_data)
{
  UoaChangePasswordData *data = user_data;

  if (error != NULL)
    {
      g_simple_async_result_set_from_error (data->result, error);
      /* libaccounts-glib API does not guarantee the callback happens after
       * reentering mainloop */
      g_simple_async_result_complete_in_idle (data->result);
      uoa_change_password_data_free (data);
      g_object_unref (identity);
      return;
    }

  /* const SignonIdentityInfo is a lie, cast it! - Mardy */
  signon_identity_info_set_secret ((SignonIdentityInfo *) info,
      data->password, data->remember);

  signon_identity_store_credentials_with_info (identity, info,
      uoa_identity_store_cb, data);
}
static void
uoa_initial_account_store_cb (AgAccount *account,
    const GError *error,
    gpointer user_data)
{
  UoaChangePasswordData *data = user_data;

  if (error != NULL)
    g_simple_async_result_set_from_error (data->result, error);

      /* libaccounts-glib API does not guarantee the callback happens after
       * reentering mainloop */
  g_simple_async_result_complete_in_idle (data->result);
  uoa_change_password_data_free (data);
}
static void
uoa_identity_store_cb (SignonIdentity *identity,
    guint32 id,
    const GError *error,
    gpointer user_data)
{
  UoaChangePasswordData *data = user_data;

  if (error != NULL)
    g_simple_async_result_set_from_error (data->result, error);

  g_simple_async_result_complete (data->result);
  uoa_change_password_data_free (data);
  g_object_unref (identity);
}
static void
uoa_initial_account_store_cb (GObject *source,
    GAsyncResult *result,
    gpointer user_data)
{
  AgAccount *account = (AgAccount *) source;
  UoaChangePasswordData *data = user_data;
  GError *error = NULL;

  if (!ag_account_store_finish (account, result, &error))
    g_simple_async_result_take_error (data->result, error);

  g_simple_async_result_complete (data->result);
  uoa_change_password_data_free (data);
}