[next] telepathy-glib: TpClientFactory: Simplify contact feature handling now that they are quarks

Simon McVittie smcv at kemper.freedesktop.org
Thu May 3 05:47:02 PDT 2012


Module: telepathy-glib
Branch: next
Commit: bc2e6dca525a0bfafa2ed67e7009a69e5b805218
URL:    http://cgit.freedesktop.org/telepathy/telepathy-glib/commit/?id=bc2e6dca525a0bfafa2ed67e7009a69e5b805218

Author: Xavier Claessens <xavier.claessens at collabora.co.uk>
Date:   Thu May  3 14:18:53 2012 +0200

TpClientFactory: Simplify contact feature handling now that they are quarks

---

 next-NEWS                       |    3 +++
 telepathy-glib/client-factory.c |   37 +++----------------------------------
 2 files changed, 6 insertions(+), 34 deletions(-)

diff --git a/next-NEWS b/next-NEWS
index 380da55..46e4dea 100644
--- a/next-NEWS
+++ b/next-NEWS
@@ -24,3 +24,6 @@ API/Behaviour changes
    interested by channels does not have to create a full TpAccountManager,
    TpAccount objects will be created only when a channel comes up for that
    account.
+
+ - TpContact now uses GQuark instead of TpContactFeature. This make them
+   consistent with TpProxy features.
diff --git a/telepathy-glib/client-factory.c b/telepathy-glib/client-factory.c
index cdea7f2..5bf1eb8 100644
--- a/telepathy-glib/client-factory.c
+++ b/telepathy-glib/client-factory.c
@@ -899,30 +899,9 @@ void
 tp_client_factory_add_contact_features (TpClientFactory *self,
     const GQuark *features)
 {
-  guint i;
-
   g_return_if_fail (TP_IS_CLIENT_FACTORY (self));
-  g_return_if_fail (features != NULL);
 
-  /* Add features into desired_contact_features avoiding dups */
-  for (i = 0; features[i] != 0; i++)
-    {
-      guint j;
-      gboolean found = FALSE;
-
-      for (j = 0; j < self->priv->desired_contact_features->len; j++)
-        {
-          if (features[i] == g_array_index (
-              self->priv->desired_contact_features, GQuark, j))
-            {
-              found = TRUE;
-              break;
-            }
-        }
-
-      if (!found)
-        g_array_append_val (self->priv->desired_contact_features, features[i]);
-    }
+  _tp_quark_array_merge (self->priv->desired_contact_features, features, -1);
 }
 
 /**
@@ -943,22 +922,12 @@ tp_client_factory_add_contact_features_varargs (
     ...)
 {
   va_list var_args;
-  GArray *features;
-  GQuark f;
 
   g_return_if_fail (TP_IS_CLIENT_FACTORY (self));
 
   va_start (var_args, feature);
-  features = g_array_new (TRUE, FALSE, sizeof (GQuark));
-
-  for (f = feature; f != 0;
-      f = va_arg (var_args, GQuark))
-    g_array_append_val (features, f);
-
-  tp_client_factory_add_contact_features (self,
-      (const GQuark *) features->data);
-
-  g_array_unref (features);
+  _tp_quark_array_merge_valist (self->priv->desired_contact_features,
+      feature, var_args);
   va_end (var_args);
 }
 



More information about the telepathy-commits mailing list