[telepathy-mission-control/master] McdAccount: inline mcd_account_unset_parameters into _mcd_account_set_parameters

Simon McVittie simon.mcvittie at collabora.co.uk
Thu Apr 16 07:53:07 PDT 2009


Otherwise, we might reconnect before we've actually unset those parameters.
---
 src/mcd-account-manager.c |    2 +-
 src/mcd-account-priv.h    |    1 +
 src/mcd-account.c         |   27 ++++++++++++---------------
 3 files changed, 14 insertions(+), 16 deletions(-)

diff --git a/src/mcd-account-manager.c b/src/mcd-account-manager.c
index 2eab452..d43b3a3 100644
--- a/src/mcd-account-manager.c
+++ b/src/mcd-account-manager.c
@@ -333,7 +333,7 @@ complete_account_creation (McdAccount *account,
         return;
     }
 
-    ok = _mcd_account_set_parameters (account, cad->parameters, &error);
+    ok = _mcd_account_set_parameters (account, cad->parameters, NULL, &error);
     if (ok)
     {
 	add_account (account_manager, account);
diff --git a/src/mcd-account-priv.h b/src/mcd-account-priv.h
index 6d9151b..89b878c 100644
--- a/src/mcd-account-priv.h
+++ b/src/mcd-account-priv.h
@@ -38,6 +38,7 @@ G_GNUC_INTERNAL void _mcd_account_connect (McdAccount *account,
 
 G_GNUC_INTERNAL gboolean _mcd_account_set_parameters (McdAccount *account,
                                                       GHashTable *params,
+                                                      const gchar **unset,
                                                       GError **error);
 G_GNUC_INTERNAL void _mcd_account_set_parameter (McdAccount *account,
                                                  const gchar *name,
diff --git a/src/mcd-account.c b/src/mcd-account.c
index 0d589fe..c1e5339 100644
--- a/src/mcd-account.c
+++ b/src/mcd-account.c
@@ -1221,7 +1221,7 @@ _mcd_account_set_parameter (McdAccount *account, const gchar *name,
 
 gboolean
 _mcd_account_set_parameters (McdAccount *account, GHashTable *params,
-                             GError **error)
+                             const gchar ** unset, GError **error)
 {
     McdAccountPrivate *priv = account->priv;
     const TpConnectionManagerParam *param;
@@ -1308,6 +1308,16 @@ _mcd_account_set_parameters (McdAccount *account, GHashTable *params,
         _mcd_account_set_parameter (account, name, value);
     }
 
+    if (unset != NULL)
+    {
+        const gchar **unset_iter;
+
+        for (unset_iter = unset; *unset_iter != NULL; unset_iter++)
+        {
+            _mcd_account_set_parameter (account, *unset_iter, NULL);
+        }
+    }
+
     if (mcd_account_get_connection_status (account) ==
         TP_CONNECTION_STATUS_CONNECTED)
     {
@@ -1336,17 +1346,6 @@ _mcd_account_set_parameters (McdAccount *account, GHashTable *params,
     return TRUE;
 }
 
-static inline void
-mcd_account_unset_parameters (McdAccount *account, const gchar **params)
-{
-    const gchar **param;
-
-    for (param = params; *param != NULL; param++)
-    {
-        _mcd_account_set_parameter (account, *param, NULL);
-    }
-}
-
 static void
 account_update_parameters (McSvcAccount *self, GHashTable *set,
 			   const gchar **unset, DBusGMethodInvocation *context)
@@ -1359,7 +1358,7 @@ account_update_parameters (McSvcAccount *self, GHashTable *set,
 
     DEBUG ("called for %s", priv->unique_name);
 
-    if (!_mcd_account_set_parameters (account, set, &error))
+    if (!_mcd_account_set_parameters (account, set, unset, &error))
     {
 	if (!error)
 	    g_set_error (&error, TP_ERRORS, TP_ERROR_NOT_AVAILABLE,
@@ -1369,8 +1368,6 @@ account_update_parameters (McSvcAccount *self, GHashTable *set,
 	return;
     }
 
-    mcd_account_unset_parameters (account, unset);
-
     /* emit the PropertiesChanged signal */
     parameters = _mcd_account_dup_parameters (account);
     g_value_init (&value, TP_HASH_TYPE_STRING_VARIANT_MAP);
-- 
1.5.6.5




More information about the telepathy-commits mailing list