telepathy-mission-control: _mcd_client_match_property: take channel properties as GVariant

Simon McVittie smcv at kemper.freedesktop.org
Mon Oct 8 08:20:50 PDT 2012


Module: telepathy-mission-control
Branch: master
Commit: a5a5d85001669af4411d01daa98da0e6d3c3094c
URL:    http://cgit.freedesktop.org/telepathy/telepathy-mission-control/commit/?id=a5a5d85001669af4411d01daa98da0e6d3c3094c

Author: Simon McVittie <simon.mcvittie at collabora.co.uk>
Date:   Mon Oct  8 15:46:44 2012 +0100

_mcd_client_match_property: take channel properties as GVariant

Signed-off-by: Simon McVittie <simon.mcvittie at collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=55391
Reviewed-by: Xavier Claessens <xavier.claessens at collabora.co.uk>

---

 src/mcd-client-priv.h |    4 ----
 src/mcd-client.c      |   29 +++++++++++++----------------
 2 files changed, 13 insertions(+), 20 deletions(-)

diff --git a/src/mcd-client-priv.h b/src/mcd-client-priv.h
index 8b300a6..c00ce13 100644
--- a/src/mcd-client-priv.h
+++ b/src/mcd-client-priv.h
@@ -110,10 +110,6 @@ G_GNUC_INTERNAL void _mcd_client_proxy_dec_ready_lock (McdClientProxy *self);
 
 #define MC_CLIENT_BUS_NAME_BASE_LEN (sizeof (TP_CLIENT_BUS_NAME_BASE) - 1)
 
-G_GNUC_INTERNAL gboolean _mcd_client_match_property (
-    GHashTable *channel_properties, gchar *property_name,
-    GValue *filter_value);
-
 G_GNUC_INTERNAL guint _mcd_client_match_filters (
     GVariant *channel_properties, const GList *filters,
     gboolean assume_requested);
diff --git a/src/mcd-client.c b/src/mcd-client.c
index efdcf56..455cfd7 100644
--- a/src/mcd-client.c
+++ b/src/mcd-client.c
@@ -1471,20 +1471,23 @@ _mcd_client_proxy_dup_handler_capabilities (McdClientProxy *self)
 
 /* returns TRUE if the channel matches one property criteria
  */
-gboolean
-_mcd_client_match_property (GHashTable *channel_properties,
+static gboolean
+_mcd_client_match_property (GVariant *channel_properties,
                             gchar *property_name,
                             GValue *filter_value)
 {
     GType filter_type = G_VALUE_TYPE (filter_value);
 
+    g_return_val_if_fail (g_variant_is_of_type (channel_properties,
+            G_VARIANT_TYPE_VARDICT), FALSE);
+
     g_assert (G_IS_VALUE (filter_value));
 
     if (filter_type == G_TYPE_STRING)
     {
         const gchar *string;
 
-        string = tp_asv_get_string (channel_properties, property_name);
+        string = tp_vardict_get_string (channel_properties, property_name);
         if (!string)
             return FALSE;
 
@@ -1495,7 +1498,7 @@ _mcd_client_match_property (GHashTable *channel_properties,
     {
         const gchar *path;
 
-        path = tp_asv_get_object_path (channel_properties, property_name);
+        path = tp_vardict_get_object_path (channel_properties, property_name);
         if (!path)
             return FALSE;
 
@@ -1507,7 +1510,7 @@ _mcd_client_match_property (GHashTable *channel_properties,
         gboolean valid;
         gboolean b;
 
-        b = tp_asv_get_boolean (channel_properties, property_name, &valid);
+        b = tp_vardict_get_boolean (channel_properties, property_name, &valid);
         if (!valid)
             return FALSE;
 
@@ -1520,7 +1523,7 @@ _mcd_client_match_property (GHashTable *channel_properties,
         gboolean valid;
         guint64 i;
 
-        i = tp_asv_get_uint64 (channel_properties, property_name, &valid);
+        i = tp_vardict_get_uint64 (channel_properties, property_name, &valid);
         if (!valid)
             return FALSE;
 
@@ -1537,7 +1540,7 @@ _mcd_client_match_property (GHashTable *channel_properties,
         gboolean valid;
         gint64 i;
 
-        i = tp_asv_get_int64 (channel_properties, property_name, &valid);
+        i = tp_vardict_get_int64 (channel_properties, property_name, &valid);
         if (!valid)
             return FALSE;
 
@@ -1565,13 +1568,9 @@ _mcd_client_match_filters (GVariant *channel_properties,
 {
     const GList *list;
     guint best_quality = 0;
-    GValue value = G_VALUE_INIT;
 
-    /* FIXME: when Xavier's tp_vardict_get_*() functions have landed,
-     * make _mcd_client_match_property use those on variant_properties
-     * rather than doing this. But for now... */
-    dbus_g_value_parse_g_variant (channel_properties, &value);
-    g_assert (G_VALUE_HOLDS (&value, TP_HASH_TYPE_STRING_VARIANT_MAP));
+    g_return_val_if_fail (g_variant_is_of_type (channel_properties,
+            G_VARIANT_TYPE_VARDICT), 0);
 
     for (list = filters; list != NULL; list = list->next)
     {
@@ -1607,7 +1606,7 @@ _mcd_client_match_filters (GVariant *channel_properties,
                     break;
                 }
             }
-            else if (! _mcd_client_match_property (g_value_get_boxed (&value),
+            else if (! _mcd_client_match_property (channel_properties,
                                                    property_name,
                                                    filter_value))
             {
@@ -1622,8 +1621,6 @@ _mcd_client_match_filters (GVariant *channel_properties,
         }
     }
 
-    g_value_unset (&value);
-
     return best_quality;
 }
 



More information about the telepathy-commits mailing list