[empathy] Stop using deprecated libaccounts-glib functions



commit d3646aa06b78b80ab9389ae03ac21554339b2746
Author: Xavier Claessens <xavier claessens collabora co uk>
Date:   Fri Sep 13 17:01:19 2013 -0400

    Stop using deprecated libaccounts-glib functions

 configure.ac                                       |    2 +-
 libempathy/empathy-uoa-auth-handler.c              |   64 ++++++++++++-------
 telepathy-account-widgets                          |    2 +-
 .../account-plugins/empathy-accounts-plugin.c      |   12 ++--
 4 files changed, 49 insertions(+), 31 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index dbe8684..2618063 100644
--- a/configure.ac
+++ b/configure.ac
@@ -77,7 +77,7 @@ NETWORK_MANAGER_REQUIRED=0.7.0
 CHAMPLAIN_REQUIRED=0.12.1
 CHEESE_GTK_REQUIRED=3.4.0
 LIBACCOUNTS_REQUIRED=1.4
-LIBSIGNON_REQUIRED=1.1
+LIBSIGNON_REQUIRED=1.8
 MC_PLUGINS_REQUIRED=5.13.1
 
 # Use --enable-maintainer-mode to disable deprecated symbols,
diff --git a/libempathy/empathy-uoa-auth-handler.c b/libempathy/empathy-uoa-auth-handler.c
index ae7ad34..692be2d 100644
--- a/libempathy/empathy-uoa-auth-handler.c
+++ b/libempathy/empathy-uoa-auth-handler.c
@@ -145,44 +145,48 @@ auth_context_done (AuthContext *ctx)
 }
 
 static void
-request_password_session_process_cb (SignonAuthSession *session,
-    GHashTable *session_data,
-    const GError *error,
+request_password_session_process_cb (GObject *source,
+    GAsyncResult *result,
     gpointer user_data)
 {
+  SignonAuthSession *session = (SignonAuthSession *) source;
   AuthContext *ctx = user_data;
+  GVariant *variant;
+  GError *error = NULL;
 
+  variant = signon_auth_session_process_finish (session, result, &error);
   if (error != NULL)
     {
       DEBUG ("Error processing the session to request user's attention: %s",
           error->message);
+      g_clear_error (&error);
     }
 
+  g_variant_unref (variant);
+
   auth_context_done (ctx);
 }
 
 static void
 request_password (AuthContext *ctx)
 {
-  GHashTable *extra_params;
+  GVariantBuilder builder;
 
   DEBUG ("Invalid credentials, request user action");
 
   /* Inform SSO that the access token (or password) didn't work and it should
    * ask user to re-grant access (or retype password). */
-  extra_params = tp_asv_new (
-      SIGNON_SESSION_DATA_UI_POLICY, G_TYPE_INT,
-          SIGNON_POLICY_REQUEST_PASSWORD,
-      NULL);
-
-  ag_auth_data_insert_parameters (ctx->auth_data, extra_params);
-
-  signon_auth_session_process (ctx->session,
-      ag_auth_data_get_parameters (ctx->auth_data),
+  g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT);
+  g_variant_builder_add (&builder, "{sv}",
+      SIGNON_SESSION_DATA_UI_POLICY,
+      g_variant_new_int32 (SIGNON_POLICY_REQUEST_PASSWORD));
+
+  signon_auth_session_process_async (ctx->session,
+      ag_auth_data_get_login_parameters (ctx->auth_data,
+          g_variant_builder_end (&builder)),
       ag_auth_data_get_mechanism (ctx->auth_data),
+      NULL,
       request_password_session_process_cb, ctx);
-
-  g_hash_table_unref (extra_params);
 }
 
 static void
@@ -209,25 +213,34 @@ auth_cb (GObject *source,
 }
 
 static void
-session_process_cb (SignonAuthSession *session,
-    GHashTable *session_data,
-    const GError *error,
+session_process_cb (GObject *source,
+    GAsyncResult *result,
     gpointer user_data)
 {
+  SignonAuthSession *session = (SignonAuthSession *) source;
   AuthContext *ctx = user_data;
+  GVariant *session_data;
   const gchar *access_token;
   const gchar *client_id;
+  const gchar *secret;
+  GVariant *params;
+  GError *error = NULL;
 
+  session_data = signon_auth_session_process_finish (session, result, &error);
   if (error != NULL)
     {
       DEBUG ("Error processing the session: %s", error->message);
       auth_context_done (ctx);
+      g_clear_error (&error);
       return;
     }
 
-  access_token = tp_asv_get_string (session_data, "AccessToken");
-  client_id = tp_asv_get_string (ag_auth_data_get_parameters (ctx->auth_data),
-      "ClientId");
+  params = g_variant_ref_sink (
+      ag_auth_data_get_login_parameters (ctx->auth_data, NULL));
+
+  g_variant_lookup (params, "ClientId", "&s", &client_id);
+  g_variant_lookup (session_data, "AccessToken", "&s", &access_token);
+  g_variant_lookup (session_data, "Secret", "&s", &secret);
 
   switch (empathy_sasl_channel_select_mechanism (ctx->channel))
     {
@@ -251,13 +264,15 @@ session_process_cb (SignonAuthSession *session,
 
       case EMPATHY_SASL_MECHANISM_PASSWORD:
         empathy_sasl_auth_password_async (ctx->channel,
-            tp_asv_get_string (session_data, "Secret"),
+            secret,
             auth_cb, ctx);
         break;
 
       default:
         g_assert_not_reached ();
     }
+
+  g_variant_unref (params);
 }
 
 static void
@@ -277,9 +292,10 @@ identity_query_info_cb (SignonIdentity *identity,
 
   ctx->username = g_strdup (signon_identity_info_get_username (info));
 
-  signon_auth_session_process (ctx->session,
-      ag_auth_data_get_parameters (ctx->auth_data),
+  signon_auth_session_process_async (ctx->session,
+      ag_auth_data_get_login_parameters (ctx->auth_data, NULL),
       ag_auth_data_get_mechanism (ctx->auth_data),
+      NULL,
       session_process_cb,
       ctx);
 }
diff --git a/telepathy-account-widgets b/telepathy-account-widgets
index fc5e571..66c5207 160000
--- a/telepathy-account-widgets
+++ b/telepathy-account-widgets
@@ -1 +1 @@
-Subproject commit fc5e5715096bc50fea89717b07806e5364e0228d
+Subproject commit 66c5207e363eadef737f68939f22b9f4ebf6208e
diff --git a/ubuntu-online-accounts/cc-plugins/account-plugins/empathy-accounts-plugin.c 
b/ubuntu-online-accounts/cc-plugins/account-plugins/empathy-accounts-plugin.c
index 6f79f87..145aa83 100644
--- a/ubuntu-online-accounts/cc-plugins/account-plugins/empathy-accounts-plugin.c
+++ b/ubuntu-online-accounts/cc-plugins/account-plugins/empathy-accounts-plugin.c
@@ -55,18 +55,20 @@ empathy_accounts_plugin_build_widget (ApPlugin *plugin)
 }
 
 static void
-store_delete_cb (AgAccount *account,
-    const GError *error,
+store_delete_cb (GObject *source,
+    GAsyncResult *res,
     gpointer user_data)
 {
+  AgAccount *account = (AgAccount *) source;
   GSimpleAsyncResult *result = user_data;
+  GError *error = NULL;
 
-  if (error != NULL)
+  if (!ag_account_store_finish (account, res, &error))
     {
       g_debug ("Failed to delete account with ID '%u': %s",
           account->id, error->message);
 
-      g_simple_async_result_set_from_error (result, error);
+      g_simple_async_result_take_error (result, error);
     }
 
   g_simple_async_result_complete (result);
@@ -87,7 +89,7 @@ empathy_accounts_plugin_delete_account (ApPlugin *plugin,
   account = ap_plugin_get_account (plugin);
 
   ag_account_delete (account);
-  ag_account_store (account, store_delete_cb, result);
+  ag_account_store_async (account, NULL, store_delete_cb, result);
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]