[telepathy-glib/master] account{, -manager}: only add known features to requested

Jonny Lamb jonny.lamb at collabora.co.uk
Thu Sep 24 09:20:14 PDT 2009


Also, ignore the missing array for now, as it makes so sense right
now.

Signed-off-by: Jonny Lamb <jonny.lamb at collabora.co.uk>
---
 telepathy-glib/account-manager.c |   36 ++++++++++--------------------------
 telepathy-glib/account.c         |   36 ++++++++++--------------------------
 2 files changed, 20 insertions(+), 52 deletions(-)

diff --git a/telepathy-glib/account-manager.c b/telepathy-glib/account-manager.c
index 066abdf..d141f20 100644
--- a/telepathy-glib/account-manager.c
+++ b/telepathy-glib/account-manager.c
@@ -179,28 +179,6 @@ _tp_account_manager_feature_in_array (GQuark feature,
   return FALSE;
 }
 
-static void
-_tp_account_manager_update_feature_arrays (TpAccountManager *manager,
-    const GQuark *features)
-{
-  TpAccountManagerPrivate *priv = manager->priv;
-  const GQuark *f;
-
-  for (f = features; *f != 0; f++)
-    {
-      TpAccountManagerFeature *feature;
-
-      feature = _tp_account_manager_get_feature (manager, *f);
-
-      if (feature == NULL
-          && !_tp_account_manager_feature_in_array (*f, priv->missing_features))
-        g_array_append_val (priv->missing_features, feature);
-
-      if (!_tp_account_manager_feature_in_array (*f, priv->requested_features))
-        g_array_append_val (priv->requested_features, *f);
-    }
-}
-
 static gboolean
 _tp_account_manager_check_features (TpAccountManager *self,
     const GQuark *features)
@@ -240,9 +218,7 @@ _tp_account_manager_become_ready (TpAccountManager *self,
 
   f->ready = TRUE;
 
-  /* Possibly a useless check -- should never get this far with
-   * this expression evaluating to false. */
-  if (!_tp_account_manager_feature_in_array (feature, priv->missing_features))
+  if (!_tp_account_manager_feature_in_array (feature, priv->actual_features))
     g_array_append_val (priv->actual_features, feature);
 
   for (l = priv->callbacks; l != NULL; l = l->next)
@@ -1383,11 +1359,19 @@ tp_account_manager_prepare_async (TpAccountManager *manager,
 {
   TpAccountManagerPrivate *priv = manager->priv;
   GSimpleAsyncResult *result;
+  const GQuark *f;
 
   /* In this object, there are no features which are activatable (core is
    * forced on you). They'd be activated here though. */
 
-  _tp_account_manager_update_feature_arrays (manager, features);
+  for (f = features; *f != 0; f++)
+    {
+      /* Only add features to requested which exist on this object and are not
+       * already in the list. */
+      if (_tp_account_manager_get_feature (manager, *f) != NULL
+          && _tp_account_manager_feature_in_array (*f, priv->requested_features))
+        g_array_append_val (priv->requested_features, *f);
+    }
 
   if (callback == NULL)
     return;
diff --git a/telepathy-glib/account.c b/telepathy-glib/account.c
index 4650a8c..5dfcd02 100644
--- a/telepathy-glib/account.c
+++ b/telepathy-glib/account.c
@@ -241,28 +241,6 @@ _tp_account_feature_in_array (GQuark feature,
   return FALSE;
 }
 
-static void
-_tp_account_update_feature_arrays (TpAccount *account,
-    const GQuark *features)
-{
-  TpAccountPrivate *priv = account->priv;
-  const GQuark *f;
-
-  for (f = features; *f != 0; f++)
-    {
-      TpAccountFeature *feature;
-
-      feature = _tp_account_get_feature (account, *f);
-
-      if (feature == NULL
-          && !_tp_account_feature_in_array (*f, priv->missing_features))
-        g_array_append_val (priv->missing_features, feature);
-
-      if (!_tp_account_feature_in_array (*f, priv->requested_features))
-        g_array_append_val (priv->requested_features, *f);
-    }
-}
-
 static gboolean
 _tp_account_check_features (TpAccount *self,
     const GQuark *features)
@@ -302,9 +280,7 @@ _tp_account_become_ready (TpAccount *self,
 
   f->ready = TRUE;
 
-  /* Possibly a useless check -- should never get this far with
-   * this expression evaluating to false. */
-  if (!_tp_account_feature_in_array (feature, priv->missing_features))
+  if (!_tp_account_feature_in_array (feature, priv->actual_features))
     g_array_append_val (priv->actual_features, feature);
 
   for (l = priv->callbacks; l != NULL; l = l->next)
@@ -2558,11 +2534,19 @@ tp_account_prepare_async (TpAccount *account,
 {
   TpAccountPrivate *priv = account->priv;
   GSimpleAsyncResult *result;
+  const GQuark *f;
 
   /* In this object, there are no features which are activatable (core is
    * forced on you). They'd be activated here though. */
 
-  _tp_account_update_feature_arrays (account, features);
+  for (f = features; *f != 0; f++)
+    {
+      /* Only add features to requested which exist on this object and are not
+       * already in the list. */
+      if (_tp_account_get_feature (account, *f) != NULL
+          && _tp_account_feature_in_array (*f, priv->requested_features))
+        g_array_append_val (priv->requested_features, *f);
+    }
 
   if (callback == NULL)
     return;
-- 
1.5.6.5




More information about the telepathy-commits mailing list