[next] telepathy-haze: Redo fill_contact_attributes functions for GVariant-based API

Simon McVittie smcv at kemper.freedesktop.org
Wed May 7 02:18:33 PDT 2014


Module: telepathy-haze
Branch: next
Commit: 4ab5af50a901d4421fe23f0aaf14863a04a4dcb3
URL:    http://cgit.freedesktop.org/telepathy/telepathy-haze/commit/?id=4ab5af50a901d4421fe23f0aaf14863a04a4dcb3

Author: Simon McVittie <simon.mcvittie at collabora.co.uk>
Date:   Tue Apr 22 13:23:50 2014 +0100

Redo fill_contact_attributes functions for GVariant-based API

---

 src/connection-aliasing.c     |   11 +++---
 src/connection-aliasing.h     |    2 +-
 src/connection-avatars.c      |   10 +++---
 src/connection-avatars.h      |    2 +-
 src/connection-capabilities.c |   80 ++++++-----------------------------------
 src/connection-capabilities.h |    2 +-
 src/connection.c              |    2 +-
 7 files changed, 23 insertions(+), 86 deletions(-)

diff --git a/src/connection-aliasing.c b/src/connection-aliasing.c
index 9ff8ef7..90f25c2 100644
--- a/src/connection-aliasing.c
+++ b/src/connection-aliasing.c
@@ -361,16 +361,13 @@ gboolean
 haze_connection_aliasing_fill_contact_attributes (HazeConnection *self,
     const gchar *dbus_interface,
     TpHandle handle,
-    TpContactAttributeMap *attributes)
+    GVariantDict *attributes)
 {
     if (!tp_strdiff (dbus_interface, TP_IFACE_CONNECTION_INTERFACE_ALIASING1))
     {
-        GValue *value = tp_g_value_slice_new (G_TYPE_STRING);
-
-        g_value_set_string (value, get_alias (self, handle));
-
-        tp_contact_attribute_map_take_sliced_gvalue (attributes, handle,
-            TP_TOKEN_CONNECTION_INTERFACE_ALIASING1_ALIAS, value);
+        g_variant_dict_insert_value (attributes,
+            TP_TOKEN_CONNECTION_INTERFACE_ALIASING1_ALIAS,
+            g_variant_new_string (get_alias (self, handle)));
         return TRUE;
     }
 
diff --git a/src/connection-aliasing.h b/src/connection-aliasing.h
index cd2117d..d3807d6 100644
--- a/src/connection-aliasing.h
+++ b/src/connection-aliasing.h
@@ -35,6 +35,6 @@ gboolean haze_connection_aliasing_fill_contact_attributes (
     HazeConnection *self,
     const gchar *dbus_interface,
     TpHandle handle,
-    TpContactAttributeMap *attributes);
+    GVariantDict *attributes);
 
 #endif
diff --git a/src/connection-avatars.c b/src/connection-avatars.c
index 35b53bb..7f0a7d5 100644
--- a/src/connection-avatars.c
+++ b/src/connection-avatars.c
@@ -521,18 +521,16 @@ gboolean
 haze_connection_avatars_fill_contact_attributes (HazeConnection *self,
     const gchar *dbus_interface,
     TpHandle handle,
-    TpContactAttributeMap *attributes)
+    GVariantDict *attributes)
 {
     if (!tp_strdiff (dbus_interface, TP_IFACE_CONNECTION_INTERFACE_AVATARS1))
     {
         gchar *token = get_handle_token (self, handle);
-        GValue *value = tp_g_value_slice_new (G_TYPE_STRING);
 
         g_assert (token != NULL);
-        g_value_set_string (value, token);
-
-        tp_contact_attribute_map_take_sliced_gvalue (attributes, handle,
-            TP_TOKEN_CONNECTION_INTERFACE_AVATARS1_TOKEN, value);
+        g_variant_dict_insert_value (attributes,
+            TP_TOKEN_CONNECTION_INTERFACE_AVATARS1_TOKEN,
+            g_variant_new_string (token));
         g_free (token);
         return TRUE;
     }
diff --git a/src/connection-avatars.h b/src/connection-avatars.h
index a7ba02c..cf4f29b 100644
--- a/src/connection-avatars.h
+++ b/src/connection-avatars.h
@@ -46,6 +46,6 @@ gboolean haze_connection_avatars_fill_contact_attributes (
     HazeConnection *self,
     const gchar *dbus_interface,
     TpHandle handle,
-    TpContactAttributeMap *attributes);
+    GVariantDict *attributes);
 
 #endif
diff --git a/src/connection-capabilities.c b/src/connection-capabilities.c
index 35489e5..7da1c24 100644
--- a/src/connection-capabilities.c
+++ b/src/connection-capabilities.c
@@ -44,84 +44,26 @@ haze_connection_update_capabilities (TpSvcConnectionInterfaceContactCapabilities
       context);
 }
 
-static GPtrArray *
-haze_connection_get_handle_contact_capabilities (HazeConnection *self,
-                                                 TpHandle handle)
-{
-  GPtrArray *arr = g_ptr_array_new ();
-  GValue monster = {0, };
-  GHashTable *fixed_properties;
-  GValue *channel_type_value;
-  GValue *target_entity_type_value;
-  const gchar * const text_allowed_properties[] = {
-    TP_PROP_CHANNEL_TARGET_HANDLE, NULL };
-
-  if (0 == handle)
-    {
-      /* obsolete request for the connection's capabilities, do nothing */
-      return arr;
-    }
-
-  /* TODO: Check for presence */
-
-  g_value_init (&monster, TP_STRUCT_TYPE_REQUESTABLE_CHANNEL_CLASS);
-  g_value_take_boxed (&monster,
-      dbus_g_type_specialized_construct (
-        TP_STRUCT_TYPE_REQUESTABLE_CHANNEL_CLASS));
-
-  fixed_properties = g_hash_table_new_full (g_str_hash, g_str_equal, NULL,
-      (GDestroyNotify) tp_g_value_slice_free);
-
-  channel_type_value = tp_g_value_slice_new (G_TYPE_STRING);
-  g_value_set_static_string (channel_type_value, TP_IFACE_CHANNEL_TYPE_TEXT);
-  g_hash_table_insert (fixed_properties, TP_IFACE_CHANNEL ".ChannelType",
-      channel_type_value);
-
-  target_entity_type_value = tp_g_value_slice_new (G_TYPE_UINT);
-  g_value_set_uint (target_entity_type_value, TP_ENTITY_TYPE_CONTACT);
-  g_hash_table_insert (fixed_properties, TP_IFACE_CHANNEL ".TargetEntityType",
-      target_entity_type_value);
-
-  dbus_g_type_struct_set (&monster,
-      0, fixed_properties,
-      1, text_allowed_properties,
-      G_MAXUINT);
-
-  g_hash_table_unref (fixed_properties);
-
-  g_ptr_array_add (arr, g_value_get_boxed (&monster));
-
-  return arr;
-}
-
 gboolean
 haze_connection_contact_capabilities_fill_contact_attributes (
     HazeConnection *self,
     const gchar *dbus_interface,
     TpHandle handle,
-    TpContactAttributeMap *attributes)
+    GVariantDict *attributes)
 {
   if (!tp_strdiff (dbus_interface,
         TP_IFACE_CONNECTION_INTERFACE_CONTACT_CAPABILITIES1))
     {
-      GPtrArray *array;
-
-      array = haze_connection_get_handle_contact_capabilities (self, handle);
-
-      if (array->len > 0)
-        {
-          GValue *val = tp_g_value_slice_new (
-              TP_ARRAY_TYPE_REQUESTABLE_CHANNEL_CLASS_LIST);
-
-          g_value_take_boxed (val, array);
-          tp_contact_attribute_map_take_sliced_gvalue (attributes,
-              handle,
-              TP_TOKEN_CONNECTION_INTERFACE_CONTACT_CAPABILITIES1_CAPABILITIES,
-              val);
-        }
-      else
-        g_ptr_array_free (array, TRUE);
-
+      /* TODO: Check for presence */
+      g_variant_dict_insert_value (attributes,
+          TP_TOKEN_CONNECTION_INTERFACE_CONTACT_CAPABILITIES1_CAPABILITIES,
+          g_variant_new_parsed ("[({%s: <%s>, %s: <%u>}, [%s])]",
+            /* Fixed properties */
+            TP_PROP_CHANNEL_CHANNEL_TYPE, TP_IFACE_CHANNEL_TYPE_TEXT,
+            TP_PROP_CHANNEL_TARGET_ENTITY_TYPE,
+              (guint32) TP_ENTITY_TYPE_CONTACT,
+            /* Allowed properties */
+            TP_PROP_CHANNEL_TARGET_HANDLE));
       return TRUE;
     }
 
diff --git a/src/connection-capabilities.h b/src/connection-capabilities.h
index f795e74..a817c02 100644
--- a/src/connection-capabilities.h
+++ b/src/connection-capabilities.h
@@ -34,6 +34,6 @@ gboolean haze_connection_contact_capabilities_fill_contact_attributes (
     HazeConnection *self,
     const gchar *dbus_interface,
     TpHandle handle,
-    TpContactAttributeMap *attributes);
+    GVariantDict *attributes);
 
 #endif
diff --git a/src/connection.c b/src/connection.c
index 7f4a91c..af95f52 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -806,7 +806,7 @@ static void
 haze_connection_fill_contact_attributes (TpBaseConnection *base,
     const gchar *dbus_interface,
     TpHandle handle,
-    TpContactAttributeMap *attributes)
+    GVariantDict *attributes)
 {
   HazeConnection *self = HAZE_CONNECTION (base);
 



More information about the telepathy-commits mailing list