[empathy] account-settings: use TpProtocol's API to get TpConnectionManagerParam



commit 505305a0bc8f02ca770014682f0794b8c9353aef
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date:   Tue Jun 5 15:00:44 2012 +0200

    account-settings: use TpProtocol's API to get TpConnectionManagerParam
    
    https://bugzilla.gnome.org/show_bug.cgi?id=677465

 libempathy-gtk/empathy-account-widget.c |    9 ++++--
 libempathy/empathy-account-settings.c   |   39 +++++++-----------------------
 libempathy/empathy-account-settings.h   |    2 +-
 3 files changed, 16 insertions(+), 34 deletions(-)
---
diff --git a/libempathy-gtk/empathy-account-widget.c b/libempathy-gtk/empathy-account-widget.c
index 1082a9e..d5a925b 100644
--- a/libempathy-gtk/empathy-account-widget.c
+++ b/libempathy-gtk/empathy-account-widget.c
@@ -728,13 +728,14 @@ accounts_widget_generic_setup (EmpathyAccountWidget *self,
     GtkWidget *grid_common_settings,
     GtkWidget *grid_advanced_settings)
 {
-  TpConnectionManagerParam *params, *param;
+  GList *params, *l;
   guint row_common = 0, row_advanced = 0;
 
-  params = empathy_account_settings_get_tp_params (self->priv->settings);
+  params = empathy_account_settings_dup_tp_params (self->priv->settings);
 
-  for (param = params; param != NULL && param->name != NULL; param++)
+  for (l = params; l != NULL; l = g_list_next (l))
     {
+      TpConnectionManagerParam *param = l->data;
       GtkWidget       *grid_settings;
       guint           row;
       GtkWidget       *widget = NULL;
@@ -848,6 +849,8 @@ accounts_widget_generic_setup (EmpathyAccountWidget *self,
 
       g_free (param_name_formatted);
     }
+
+  g_list_free_full (params, (GDestroyNotify) tp_connection_manager_param_free);
 }
 
 static void
diff --git a/libempathy/empathy-account-settings.c b/libempathy/empathy-account-settings.c
index f88ff3d..7e31297 100644
--- a/libempathy/empathy-account-settings.c
+++ b/libempathy/empathy-account-settings.c
@@ -689,25 +689,14 @@ empathy_account_settings_new_for_account (TpAccount *account)
       NULL);
 }
 
-TpConnectionManagerParam *
-empathy_account_settings_get_tp_params (EmpathyAccountSettings *settings)
+GList *
+empathy_account_settings_dup_tp_params (EmpathyAccountSettings *settings)
 {
   EmpathyAccountSettingsPriv *priv = GET_PRIV (settings);
-  const TpConnectionManagerProtocol *tp_protocol;
 
-  g_return_val_if_fail (priv->manager != NULL, NULL);
-  g_return_val_if_fail (priv->protocol != NULL, NULL);
+  g_return_val_if_fail (priv->protocol_obj != NULL, NULL);
 
-  tp_protocol = tp_connection_manager_get_protocol (priv->manager,
-     priv->protocol);
-  if (tp_protocol == NULL)
-    {
-      DEBUG ("Can't retrieve TpConnectionManagerProtocol for protocol '%s'",
-          priv->protocol);
-      return NULL;
-    }
-
-  return tp_protocol->params;
+  return tp_protocol_dup_params (priv->protocol_obj);
 }
 
 gboolean
@@ -800,23 +789,13 @@ empathy_account_settings_is_unset (EmpathyAccountSettings *settings,
   return FALSE;
 }
 
-static TpConnectionManagerParam *
+static const TpConnectionManagerParam *
 empathy_account_settings_get_tp_param (EmpathyAccountSettings *settings,
     const gchar *param)
 {
-  TpConnectionManagerParam *tp_params =
-      empathy_account_settings_get_tp_params (settings);
-  TpConnectionManagerParam *p;
-
-  for (p = tp_params; p != NULL && p->name != NULL; p++)
-    {
-      if (tp_strdiff (p->name, param))
-        continue;
-
-      return p;
-    }
+  EmpathyAccountSettingsPriv *priv = GET_PRIV (settings);
 
-  return NULL;
+  return tp_protocol_get_param (priv->protocol_obj, param);
 }
 
 gboolean
@@ -853,7 +832,7 @@ const GValue *
 empathy_account_settings_get_default (EmpathyAccountSettings *settings,
     const gchar *param)
 {
-  TpConnectionManagerParam *p;
+  const TpConnectionManagerParam *p;
 
   p = empathy_account_settings_get_tp_param (settings, param);
 
@@ -867,7 +846,7 @@ const gchar *
 empathy_account_settings_get_dbus_signature (EmpathyAccountSettings *settings,
     const gchar *param)
 {
-  TpConnectionManagerParam *p;
+  const TpConnectionManagerParam *p;
 
   p = empathy_account_settings_get_tp_param (settings, param);
 
diff --git a/libempathy/empathy-account-settings.h b/libempathy/empathy-account-settings.h
index 2581613..baa0ad7 100644
--- a/libempathy/empathy-account-settings.h
+++ b/libempathy/empathy-account-settings.h
@@ -87,7 +87,7 @@ TpAccount *empathy_account_settings_get_account (
 gboolean empathy_account_settings_has_account (
     EmpathyAccountSettings *settings, TpAccount *account);
 
-TpConnectionManagerParam *empathy_account_settings_get_tp_params (
+GList * empathy_account_settings_dup_tp_params (
     EmpathyAccountSettings *settings);
 
 gboolean empathy_account_settings_have_tp_param (



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