[empathy/next] use new TpAccount API



commit 72bcb73f659954284d8269e39ba6859e2b8e161a
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date:   Fri Feb 21 12:12:58 2014 +0100

    use new TpAccount API

 libempathy/empathy-goa-auth-handler.c |    7 +++--
 libempathy/empathy-utils.c            |   18 +++++++++------
 src/empathy-import-widget.c           |   28 ++++++++++++++---------
 src/empathy-roster-window.c           |    6 +++-
 src/empathy-sanity-cleaning.c         |   39 +++++++++++++++++----------------
 5 files changed, 56 insertions(+), 42 deletions(-)
---
diff --git a/libempathy/empathy-goa-auth-handler.c b/libempathy/empathy-goa-auth-handler.c
index 3797300..9864b3f 100644
--- a/libempathy/empathy-goa-auth-handler.c
+++ b/libempathy/empathy-goa-auth-handler.c
@@ -283,13 +283,13 @@ static void
 start_auth (AuthData *data)
 {
   EmpathyGoaAuthHandler *self = data->self;
-  const GValue *id_value;
+  GVariant *id_variant;
   const gchar *id;
   GList *goa_accounts, *l;
   gboolean found = FALSE;
 
-  id_value = tp_account_get_storage_identifier (data->account);
-  id = g_value_get_string (id_value);
+  id_variant = tp_account_dup_storage_identifier (data->account);
+  id = g_variant_get_string (id_variant, NULL);
 
   goa_accounts = goa_client_get_accounts (self->priv->client);
   for (l = goa_accounts; l != NULL && !found; l = l->next)
@@ -314,6 +314,7 @@ start_auth (AuthData *data)
       g_object_unref (goa_account);
     }
   g_list_free_full (goa_accounts, g_object_unref);
+  g_variant_unref (id_variant);
 
   if (!found)
     {
diff --git a/libempathy/empathy-utils.c b/libempathy/empathy-utils.c
index d377233..230fe55 100644
--- a/libempathy/empathy-utils.c
+++ b/libempathy/empathy-utils.c
@@ -342,30 +342,34 @@ const gchar *
 empathy_account_get_error_message (TpAccount *account,
     gboolean *user_requested)
 {
-  const gchar *dbus_error;
+  gchar *dbus_error;
   const gchar *message;
-  const GHashTable *details = NULL;
+  GVariant *details = NULL;
   TpConnectionStatusReason reason;
 
-  dbus_error = tp_account_get_detailed_error (account, &details);
+  dbus_error = tp_account_dup_detailed_error (account, &details);
 
   if (user_requested != NULL)
     {
-      if (tp_asv_get_boolean (details, "user-requested", NULL))
-        *user_requested = TRUE;
-      else
+      if (!g_variant_lookup (details, "user-requested", "b", user_requested))
         *user_requested = FALSE;
     }
+  g_variant_unref (details);
 
   message = empathy_dbus_error_name_get_default_message (dbus_error);
   if (message != NULL)
-    return message;
+    {
+      g_free (dbus_error);
+      return message;
+    }
 
   tp_account_get_connection_status (account, &reason);
 
   DEBUG ("Don't understand error '%s'; fallback to the status reason (%u)",
     dbus_error, reason);
 
+  g_free (dbus_error);
+
   return empathy_status_reason_get_default_message (reason);
 }
 
diff --git a/src/empathy-import-widget.c b/src/empathy-import-widget.c
index 0ce490d..9b25006 100644
--- a/src/empathy-import-widget.c
+++ b/src/empathy-import-widget.c
@@ -77,12 +77,18 @@ import_widget_account_id_in_list (GList *accounts,
   for (l = accounts; l; l = l->next)
     {
       TpAccount *account = l->data;
-      const GHashTable *parameters;
-
-      parameters = tp_account_get_parameters (account);
-
-      if (!tp_strdiff (tp_asv_get_string (parameters, "account"), account_id))
-        return TRUE;
+      GVariant *parameters;
+      const gchar *acc;
+
+      parameters = tp_account_dup_parameters (account);
+
+      if (g_variant_lookup (parameters, "account", "&s", &acc) &&
+          !tp_strdiff (acc, account_id))
+        {
+          g_variant_unref (parameters);
+          return TRUE;
+        }
+      g_variant_unref (parameters);
     }
 
   return FALSE;
@@ -185,7 +191,7 @@ import_widget_add_account (EmpathyImportWidget *self,
 {
   TpAccountManager *account_manager;
   gchar *display_name = NULL;
-  GHashTable *properties;
+  GVariant *properties, *settings;
   GValue *username;
 
   account_manager = tp_account_manager_dup ();
@@ -214,15 +220,15 @@ import_widget_add_account (EmpathyImportWidget *self,
 
   DEBUG ("display name: %s\n", display_name);
 
-  properties = tp_asv_new (NULL, NULL);
-  tp_asv_set_boolean (properties, TP_IFACE_ACCOUNT ".Enabled", data->enabled);
+  properties = g_variant_new_parsed ("{ %s: <%b> }",
+      TP_IFACE_ACCOUNT ".Enabled", data->enabled);
+  settings = tp_asv_to_vardict (data->settings);
 
   tp_account_manager_create_account_async (account_manager,
       (const gchar*) data->connection_manager, data->protocol, display_name,
-      data->settings, properties, import_widget_create_account_cb,
+      settings, properties, import_widget_create_account_cb,
       g_object_ref (self));
 
-  g_hash_table_unref (properties);
   g_free (display_name);
   g_object_unref (account_manager);
 }
diff --git a/src/empathy-roster-window.c b/src/empathy-roster-window.c
index 6e4a463..a19e9c4 100644
--- a/src/empathy-roster-window.c
+++ b/src/empathy-roster-window.c
@@ -714,6 +714,7 @@ roster_window_error_display (EmpathyRosterWindow *self,
   gboolean user_requested;
   GtkWidget *info_bar;
   gchar *str;
+  gchar *err;
 
   error_message =
     empathy_account_get_error_message (account, &user_requested);
@@ -741,8 +742,8 @@ roster_window_error_display (EmpathyRosterWindow *self,
 
   gtk_widget_set_tooltip_text (self->priv->errors_vbox, error_message);
 
-  if (!tp_strdiff (TP_ERROR_STR_SOFTWARE_UPGRADE_REQUIRED,
-       tp_account_get_detailed_error (account, NULL)))
+  err = tp_account_dup_detailed_error (account, NULL);
+  if (!tp_strdiff (TP_ERROR_STR_SOFTWARE_UPGRADE_REQUIRED, err))
     {
       roster_window_error_add_stock_button (GTK_INFO_BAR (info_bar),
           GTK_STOCK_REFRESH, _("Update software…"),
@@ -758,6 +759,7 @@ roster_window_error_display (EmpathyRosterWindow *self,
           GTK_STOCK_EDIT, _("Edit Account"),
           ERROR_RESPONSE_EDIT);
     }
+  g_free (err);
 
   roster_window_error_add_stock_button (GTK_INFO_BAR (info_bar),
       GTK_STOCK_CLOSE, _("Close"),
diff --git a/src/empathy-sanity-cleaning.c b/src/empathy-sanity-cleaning.c
index 6c01158..e1783eb 100644
--- a/src/empathy-sanity-cleaning.c
+++ b/src/empathy-sanity-cleaning.c
@@ -125,31 +125,29 @@ fix_xmpp_account_priority (TpAccountManager *am)
   for (l = accounts; l != NULL; l = g_list_next (l))
     {
       TpAccount *account = l->data;
-      GHashTable *params;
-      gint priority;
+      GVariant *params;
+      gint priority = 0;
 
       if (tp_strdiff (tp_account_get_protocol_name (account), "jabber"))
         continue;
 
-      params = (GHashTable *) tp_account_get_parameters (account);
+      params = tp_account_dup_parameters (account);
       if (params == NULL)
         continue;
 
-      priority = tp_asv_get_int32 (params, "priority", NULL);
+      g_variant_lookup (params, "priority", "i", &priority);
+      g_variant_unref (params);
+
       if (priority >= 0)
         continue;
 
       DEBUG ("Resetting XMPP priority of account '%s' to 0",
           tp_account_get_path_suffix (account));
 
-      params = tp_asv_new (
-          "priority", G_TYPE_INT, 0,
-          NULL);
+      params = g_variant_new_parsed ("{ priority: <%i> }", 0);
 
       tp_account_update_parameters_async (account, params, NULL,
           account_update_parameters_cb, NULL);
-
-      g_hash_table_unref (params);
     }
 
   g_list_free_full (accounts, g_object_unref);
@@ -164,32 +162,35 @@ set_facebook_account_fallback_server (TpAccountManager *am)
   for (l = accounts; l != NULL; l = g_list_next (l))
     {
       TpAccount *account = l->data;
-      GHashTable *params;
-      gchar *fallback_servers[] = {
+      GVariant *params, *servers;
+      const gchar * const fallback_servers[] = {
           "chat.facebook.com:443",
           NULL };
 
       if (tp_strdiff (tp_account_get_service (account), "facebook"))
         continue;
 
-      params = (GHashTable *) tp_account_get_parameters (account);
+      params = tp_account_dup_parameters (account);
       if (params == NULL)
         continue;
 
-      if (tp_asv_get_strv (params, "fallback-servers") != NULL)
-        continue;
+      servers = g_variant_lookup_value (params, "fallback-servers",
+          G_VARIANT_TYPE_STRING_ARRAY);
+      g_variant_unref (params);
+
+      if (servers != NULL)
+        {
+          g_variant_unref (servers);
+          continue;
+        }
 
       DEBUG ("Setting chat.facebook.com:443 as a fallback on account '%s'",
           tp_account_get_path_suffix (account));
 
-      params = tp_asv_new (
-          "fallback-servers", G_TYPE_STRV, fallback_servers,
-          NULL);
+      params = g_variant_new_strv (fallback_servers, -1);
 
       tp_account_update_parameters_async (account, params, NULL,
           account_update_parameters_cb, NULL);
-
-      g_hash_table_unref (params);
     }
 
   g_list_free_full (accounts, g_object_unref);


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