summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.com>2014-04-06 22:38:03 -0400
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2014-05-07 09:43:43 +0100
commitfc320bca700961898fb54af379d3dd17ed698958 (patch)
tree19376c2818590ad416a42d8fca8ea6babdefa892
parent2c2458ed09a85efa2e9679ab086f2b340ad5013f (diff)
downloadtelepathy-glib-fc320bca700961898fb54af379d3dd17ed698958.tar.gz
TpBaseConnection: Change fill_contact_attributes() to take a GVariantDict
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=77189
-rw-r--r--docs/reference/telepathy-glib/telepathy-glib-sections.txt5
-rw-r--r--examples/cm/call/conn.c2
-rw-r--r--examples/cm/contactlist/conn.c10
-rw-r--r--telepathy-glib/base-connection-internal.h6
-rw-r--r--telepathy-glib/base-connection.c181
-rw-r--r--telepathy-glib/base-connection.h23
-rw-r--r--telepathy-glib/base-contact-list.c50
-rw-r--r--telepathy-glib/base-contact-list.h2
-rw-r--r--telepathy-glib/presence-mixin.c50
-rw-r--r--telepathy-glib/presence-mixin.h2
-rw-r--r--telepathy-glib/versions/main-1.0.abi3
-rw-r--r--tests/lib/broken-client-types-conn.c14
-rw-r--r--tests/lib/contacts-conn.c41
13 files changed, 131 insertions, 258 deletions
diff --git a/docs/reference/telepathy-glib/telepathy-glib-sections.txt b/docs/reference/telepathy-glib/telepathy-glib-sections.txt
index 4a43f601b..bdbb2fa26 100644
--- a/docs/reference/telepathy-glib/telepathy-glib-sections.txt
+++ b/docs/reference/telepathy-glib/telepathy-glib-sections.txt
@@ -60,13 +60,8 @@ tp_base_connection_finish_shutdown
TP_BASE_CONNECTION_ERROR_IF_NOT_CONNECTED
tp_base_connection_add_possible_client_interest
tp_base_connection_add_client_interest
-tp_base_connection_dup_contact_attributes_hash
tp_base_connection_get_account_path_suffix
<SUBSECTION>
-TpContactAttributeMap
-tp_contact_attribute_map_set
-tp_contact_attribute_map_take_sliced_gvalue
-<SUBSECTION>
TpChannelManagerIter
tp_base_connection_channel_manager_iter_init
tp_base_connection_channel_manager_iter_next
diff --git a/examples/cm/call/conn.c b/examples/cm/call/conn.c
index e1d74de35..b3e945cc2 100644
--- a/examples/cm/call/conn.c
+++ b/examples/cm/call/conn.c
@@ -337,7 +337,7 @@ static void
example_call_connection_fill_contact_attributes (TpBaseConnection *conn,
const gchar *dbus_interface,
TpHandle contact,
- TpContactAttributeMap *attributes)
+ GVariantDict *attributes)
{
if (tp_presence_mixin_fill_contact_attributes (G_OBJECT (conn),
dbus_interface, contact, attributes))
diff --git a/examples/cm/contactlist/conn.c b/examples/cm/contactlist/conn.c
index 266a0b2fc..e4ed215f2 100644
--- a/examples/cm/contactlist/conn.c
+++ b/examples/cm/contactlist/conn.c
@@ -233,18 +233,16 @@ static void
example_contact_list_connection_fill_contact_attributes (TpBaseConnection *conn,
const gchar *dbus_interface,
TpHandle contact,
- TpContactAttributeMap *attributes)
+ GVariantDict *attributes)
{
ExampleContactListConnection *self =
EXAMPLE_CONTACT_LIST_CONNECTION (conn);
if (!tp_strdiff (dbus_interface, TP_IFACE_CONNECTION_INTERFACE_ALIASING1))
{
- tp_contact_attribute_map_set (attributes, contact,
- TP_TOKEN_CONNECTION_INTERFACE_ALIASING1_ALIAS,
- g_variant_new_string (
- example_contact_list_get_alias (self->priv->contact_list,
- contact)));
+ g_variant_dict_insert (attributes,
+ TP_TOKEN_CONNECTION_INTERFACE_ALIASING1_ALIAS, "s",
+ example_contact_list_get_alias (self->priv->contact_list, contact));
return;
}
diff --git a/telepathy-glib/base-connection-internal.h b/telepathy-glib/base-connection-internal.h
index 30685bc89..64fba2517 100644
--- a/telepathy-glib/base-connection-internal.h
+++ b/telepathy-glib/base-connection-internal.h
@@ -33,6 +33,12 @@ void _tp_base_connection_set_handle_repo (TpBaseConnection *self,
gpointer _tp_base_connection_find_channel_manager (TpBaseConnection *self,
GType type);
+GVariant *_tp_base_connection_dup_contact_attributes_hash (
+ TpBaseConnection *self,
+ const GArray *handles,
+ const gchar * const *interfaces,
+ const gchar * const *assumed_interfaces);
+
G_END_DECLS
#endif
diff --git a/telepathy-glib/base-connection.c b/telepathy-glib/base-connection.c
index bdcfdcd81..03b98600f 100644
--- a/telepathy-glib/base-connection.c
+++ b/telepathy-glib/base-connection.c
@@ -143,11 +143,9 @@
* Connection. This must be set by subclasses to a non-%NULL
* value. Since: 0.7.15
* @fill_contact_attributes: If @dbus_interface is recognised by this
- * object, fill in any contact attribute tokens for @contact in @attributes
- * by using tp_contact_attribute_map_set()
- * or tp_contact_attribute_map_take_sliced_gvalue, and return. Otherwise,
- * chain up to the superclass' implementation.
- * Since: 0.99.6
+ * object, fill in any contact attribute tokens for @contact in @attributes,
+ * and return. Otherwise, chain up to the superclass' implementation.
+ * Since: 0.UNRELEASED
*
* The class of a #TpBaseConnection. Many members are virtual methods etc.
* to be filled in in the subclass' class_init function.
@@ -1000,22 +998,20 @@ update_rcc_property (TpBaseConnection *self)
* @self: a connection
* @dbus_interface: a D-Bus interface
* @contact: a contact
- * @attributes: used to return the attributes
+ * @attributes: used to return @contact's attributes
*
* If @dbus_interface is recognised by this object, fill in any contact
- * attribute tokens for @contact in @attributes by using
- * tp_contact_attribute_map_set() or
- * tp_contact_attribute_map_take_sliced_gvalue, and return. Otherwise,
+ * attribute tokens for @contact in @attributes, and return. Otherwise,
* chain up to the superclass' implementation.
*
- * Since: 0.99.6
+ * Since: 0.UNRELEASED
*/
static void
_tp_base_connection_fill_contact_attributes (TpBaseConnection *self,
const gchar *dbus_interface,
TpHandle contact,
- TpContactAttributeMap *attributes)
+ GVariantDict *attributes)
{
const gchar *tmp;
@@ -1030,9 +1026,7 @@ _tp_base_connection_fill_contact_attributes (TpBaseConnection *self,
g_assert (tmp != NULL);
/* this is always included */
- tp_contact_attribute_map_take_sliced_gvalue (attributes,
- contact, TP_TOKEN_CONNECTION_CONTACT_ID,
- tp_g_value_slice_new_string (tmp));
+ g_variant_dict_insert (attributes, TP_TOKEN_CONNECTION_CONTACT_ID, "s", tmp);
}
static void
@@ -2730,97 +2724,12 @@ tp_base_connection_get_object_path (TpBaseConnection *self)
return self->priv->object_path;
}
-/**
- * TpContactAttributeMap:
- *
- * Opaque structure representing a map from #TpHandle to
- * maps from contact attribute tokens to variants.
- *
- * This structure cannot currently be copied, freed or read via
- * public API.
- *
- * Since: 0.99.6
- */
-
-/* Implementation detail: there is no such thing as a TpContactAttributeMap,
- * it's just a GHashTable<TpHandle, GHashTable<gchar *, sliced GValue *>>. */
-
-/**
- * tp_contact_attribute_map_set:
- * @map: an opaque map from contacts to their attributes
- * @contact: a contact
- * @token: a contact attribute
- * @value: the value of the attribute. If it is floating, ownership
- * will be taken, as if via g_variant_ref_sink().
- *
- * Put a contact attribute in @self. It is an error to use this function
- * for a @contact that was not requested.
- *
- * Since: 0.99.6
- */
-void
-tp_contact_attribute_map_set (TpContactAttributeMap *map,
- TpHandle contact,
- const gchar *token,
- GVariant *value)
-{
- GValue *gv = g_slice_new0 (GValue);
-
- g_variant_ref_sink (value);
- dbus_g_value_parse_g_variant (value, gv);
- tp_contact_attribute_map_take_sliced_gvalue (map, contact, token, gv);
- g_variant_unref (value);
-}
-
-/**
- * tp_contact_attribute_map_take_sliced_gvalue: (skip)
- * @map: an opaque map from contacts to their attributes
- * @contact: a contact
- * @token: a contact attribute
- * @value: (transfer full): a slice-allocated #GValue, for instance
- * from tp_g_value_slice_new(). Ownership is taken by @self.
- *
- * Put a contact attribute in @self. It is an error to use this function
- * for a @contact that was not requested.
- *
- * This version of tp_contact_attribute_map_set() isn't
- * introspectable, but is close to the API that "Telepathy 0"
- * connection managers used.
- *
- * Since: 0.99.6
- */
-void
-tp_contact_attribute_map_take_sliced_gvalue (TpContactAttributeMap *map,
- TpHandle contact,
- const gchar *token,
- GValue *value)
-{
- GHashTable *auasv = (GHashTable *) map;
- GHashTable *asv;
-
- g_return_if_fail (map != NULL);
-
- asv = g_hash_table_lookup (auasv, GUINT_TO_POINTER (contact));
-
- if (G_UNLIKELY (asv == NULL))
- {
- /* This is a programmer error; I'm not using g_return_if_fail
- * to give a better diagnostic */
- CRITICAL ("contact %u not in TpContactAttributeMap", contact);
- return;
- }
-
- g_return_if_fail (G_IS_VALUE (value));
-
- g_hash_table_insert (asv, g_strdup (token), value);
-}
-
static const gchar * const contacts_always_included_interfaces[] = {
TP_IFACE_CONNECTION,
NULL
};
-/**
+/*
* tp_base_connection_dup_contact_attributes_hash: (skip)
* @self: A connection instance that uses this mixin. The connection must
* be connected.
@@ -2840,35 +2749,24 @@ static const gchar * const contacts_always_included_interfaces[] = {
* the behaviour is defined by the interface; the attribute should either
* be omitted from the result or replaced with a default value.
*
- * Returns: (element-type guint GLib.HashTable): a map from #TpHandle
- * to #GHashTable, where the values are maps from string to #GValue
+ * Returns: a floating GVariant of type "a{ua{sv}}"
* Since: 0.99.6
*/
-GHashTable *
-tp_base_connection_dup_contact_attributes_hash (TpBaseConnection *self,
+GVariant *
+_tp_base_connection_dup_contact_attributes_hash (TpBaseConnection *self,
const GArray *handles,
const gchar * const *interfaces,
const gchar * const *assumed_interfaces)
{
- GHashTable *result;
- guint i;
+ TpBaseConnectionClass *klass = TP_BASE_CONNECTION_GET_CLASS (self);
TpHandleRepoIface *contact_repo;
- GArray *valid_handles;
- TpBaseConnectionClass *klass;
+ GVariantBuilder builder;
+ guint i;
g_return_val_if_fail (TP_IS_BASE_CONNECTION (self), NULL);
g_return_val_if_fail (tp_base_connection_check_connected (self, NULL), NULL);
-
- contact_repo = tp_base_connection_get_handles (self, TP_ENTITY_TYPE_CONTACT);
- klass = TP_BASE_CONNECTION_GET_CLASS (self);
g_return_val_if_fail (klass->fill_contact_attributes != NULL, NULL);
- /* Setup handle array and hash with valid handles */
- valid_handles = g_array_sized_new (TRUE, TRUE, sizeof (TpHandle),
- handles->len);
- result = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL,
- (GDestroyNotify) g_hash_table_unref);
-
DEBUG ("%u contact(s)", handles->len);
for (i = 0; assumed_interfaces != NULL && assumed_interfaces[i] != NULL; i++)
@@ -2881,14 +2779,15 @@ tp_base_connection_dup_contact_attributes_hash (TpBaseConnection *self,
DEBUG ("\tselected interface: '%s'", interfaces[i]);
}
+ contact_repo = tp_base_connection_get_handles (self, TP_ENTITY_TYPE_CONTACT);
+ g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{ua{sv}}"));
+
for (i = 0; i < handles->len; i++)
{
- TpHandle h;
- GHashTable *attr_hash;
+ TpHandle h = g_array_index (handles, TpHandle, i);
+ GVariantDict dict;
guint j;
- h = g_array_index (handles, TpHandle, i);
-
DEBUG ("\tcontact #%u", h);
if (!tp_handle_is_valid (contact_repo, h, NULL))
@@ -2897,27 +2796,24 @@ tp_base_connection_dup_contact_attributes_hash (TpBaseConnection *self,
continue;
}
- attr_hash = g_hash_table_new_full (g_str_hash,
- g_str_equal, g_free, (GDestroyNotify) tp_g_value_slice_free);
- g_array_append_val (valid_handles, h);
- g_hash_table_insert (result, GUINT_TO_POINTER (h), attr_hash);
+ g_variant_dict_init (&dict, NULL);
for (j = 0; assumed_interfaces != NULL && assumed_interfaces[j] != NULL; j++)
{
klass->fill_contact_attributes (self, assumed_interfaces[j], h,
- (TpContactAttributeMap *) result);
+ &dict);
}
for (j = 0; interfaces != NULL && interfaces[j] != NULL; j++)
{
- klass->fill_contact_attributes (self, interfaces[j], h,
- (TpContactAttributeMap *) result);
+ klass->fill_contact_attributes (self, interfaces[j], h, &dict);
}
- }
- g_array_unref (valid_handles);
+ g_variant_builder_add (&builder, "{u@a{sv}}", h,
+ g_variant_dict_end (&dict));
+ }
- return result;
+ return g_variant_builder_end (&builder);
}
static gboolean
@@ -2930,8 +2826,6 @@ contacts_get_contact_attributes_impl (_TpGDBusConnection *skeleton,
const TpHandle *c_array;
GArray *array;
gsize n;
- GHashTable *attributes;
- GValue value = G_VALUE_INIT;
GVariant *result;
/* In principle C does not guarantee that TpHandle (which is an
* unsigned int) is exactly 32 bits. In practice, int is 32-bit on
@@ -2948,12 +2842,8 @@ contacts_get_contact_attributes_impl (_TpGDBusConnection *skeleton,
array = g_array_sized_new (FALSE, FALSE, sizeof (TpHandle), n);
g_array_append_vals (array, c_array, n);
- attributes = tp_base_connection_dup_contact_attributes_hash (conn,
+ result = _tp_base_connection_dup_contact_attributes_hash (conn,
array, interfaces, contacts_always_included_interfaces);
- g_value_init (&value, TP_HASH_TYPE_CONTACT_ATTRIBUTES_MAP);
- g_value_take_boxed (&value, attributes);
- result = dbus_g_value_build_g_variant (&value);
- g_value_unset (&value);
_tp_gdbus_connection_complete_get_contact_attributes (skeleton, context,
result);
@@ -2980,9 +2870,9 @@ ensure_handle_cb (GObject *source,
TpBaseConnection *self = data->conn;
TpHandle handle;
GArray *handles;
- GHashTable *attributes;
- GHashTable *asv;
+ GVariant *attributes;
GVariant *ret;
+ TpHandle ret_handle;
GError *error = NULL;
handle = tp_handle_ensure_finish (contact_repo, result, &error);
@@ -2996,19 +2886,18 @@ ensure_handle_cb (GObject *source,
handles = g_array_new (FALSE, FALSE, sizeof (TpHandle));
g_array_append_val (handles, handle);
- attributes = tp_base_connection_dup_contact_attributes_hash (self,
+ attributes = _tp_base_connection_dup_contact_attributes_hash (self,
handles, (const gchar * const *) data->interfaces,
contacts_always_included_interfaces);
-
- asv = g_hash_table_lookup (attributes, GUINT_TO_POINTER (handle));
- g_assert (asv != NULL);
- ret = tp_asv_to_vardict (asv);
- g_hash_table_unref (attributes);
+ g_variant_ref_sink (attributes);
+ g_variant_get_child (attributes, 0, "{u@a{sv}}", &ret_handle, &ret);
+ g_assert (ret_handle == handle);
_tp_gdbus_connection_complete_get_contact_by_id (
self->priv->connection_skeleton, data->context, handle, ret);
g_array_unref (handles);
+ g_variant_unref (attributes);
out:
g_object_unref (data->conn);
diff --git a/telepathy-glib/base-connection.h b/telepathy-glib/base-connection.h
index b3a8b9481..da9aecda6 100644
--- a/telepathy-glib/base-connection.h
+++ b/telepathy-glib/base-connection.h
@@ -40,8 +40,6 @@ G_BEGIN_DECLS
typedef struct _TpBaseConnectionClass TpBaseConnectionClass;
typedef struct _TpBaseConnectionPrivate TpBaseConnectionPrivate;
-typedef struct _TpContactAttributeMap TpContactAttributeMap;
-
typedef void (*TpBaseConnectionProc) (TpBaseConnection *self);
typedef gboolean (*TpBaseConnectionStartConnectingImpl) (
@@ -89,7 +87,7 @@ struct _TpBaseConnectionClass {
void (*fill_contact_attributes) (TpBaseConnection *self,
const gchar *dbus_interface,
TpHandle contact,
- TpContactAttributeMap *attributes);
+ GVariantDict *attributes);
/*<private>*/
GCallback _future[16];
@@ -202,25 +200,6 @@ void tp_base_connection_add_client_interest (TpBaseConnection *self,
void tp_base_connection_add_possible_client_interest (TpBaseConnection *self,
GQuark token);
-_TP_AVAILABLE_IN_1_0
-GHashTable *tp_base_connection_dup_contact_attributes_hash (
- TpBaseConnection *self,
- const GArray *handles,
- const gchar * const *interfaces,
- const gchar * const *assumed_interfaces);
-
-_TP_AVAILABLE_IN_1_0
-void tp_contact_attribute_map_set (TpContactAttributeMap *map,
- TpHandle contact,
- const gchar *token,
- GVariant *value);
-
-_TP_AVAILABLE_IN_1_0
-void tp_contact_attribute_map_take_sliced_gvalue (TpContactAttributeMap *map,
- TpHandle contact,
- const gchar *token,
- GValue *value);
-
_TP_AVAILABLE_IN_0_24
const gchar *tp_base_connection_get_account_path_suffix (
TpBaseConnection *self);
diff --git a/telepathy-glib/base-contact-list.c b/telepathy-glib/base-contact-list.c
index ae5987645..5496bbac4 100644
--- a/telepathy-glib/base-contact-list.c
+++ b/telepathy-glib/base-contact-list.c
@@ -23,6 +23,7 @@
#include <dbus/dbus-glib-lowlevel.h>
+#include <telepathy-glib/asv.h>
#include <telepathy-glib/dbus.h>
#include <telepathy-glib/dbus-properties-mixin.h>
#include <telepathy-glib/handle-repo-dynamic.h>
@@ -3648,18 +3649,22 @@ tp_base_contact_list_mixin_get_contact_list_attributes (
GArray *contacts;
const gchar *assumed[] = { TP_IFACE_CONNECTION,
TP_IFACE_CONNECTION_INTERFACE_CONTACT_LIST1, NULL };
- GHashTable *result;
+ GVariant *result;
+ GValue value = G_VALUE_INIT;
set = tp_base_contact_list_dup_contacts (self);
contacts = tp_handle_set_to_array (set);
- result = tp_base_connection_dup_contact_attributes_hash (
+ result = _tp_base_connection_dup_contact_attributes_hash (
self->priv->conn, contacts, interfaces, assumed);
+ g_variant_ref_sink (result);
+ dbus_g_value_parse_g_variant (result, &value);
tp_svc_connection_interface_contact_list1_return_from_get_contact_list_attributes (
- context, result);
+ context, g_value_get_boxed (&value));
g_array_unref (contacts);
tp_handle_set_destroy (set);
- g_hash_table_unref (result);
+ g_variant_unref (result);
+ g_value_unset (&value);
}
}
@@ -4184,7 +4189,7 @@ gboolean
tp_base_contact_list_fill_contact_attributes (TpBaseContactList *self,
const gchar *dbus_interface,
TpHandle contact,
- TpContactAttributeMap *attributes)
+ GVariantDict *attributes)
{
g_return_val_if_fail (TP_IS_BASE_CONTACT_LIST (self), FALSE);
g_return_val_if_fail (self->priv->conn != NULL, FALSE);
@@ -4202,13 +4207,12 @@ tp_base_contact_list_fill_contact_attributes (TpBaseContactList *self,
tp_base_contact_list_dup_states (self, contact,
&subscribe, &publish, &publish_request);
- tp_contact_attribute_map_take_sliced_gvalue (attributes,
- contact, TP_TOKEN_CONNECTION_INTERFACE_CONTACT_LIST1_PUBLISH,
- tp_g_value_slice_new_uint (publish));
+ g_variant_dict_insert (attributes,
+ TP_TOKEN_CONNECTION_INTERFACE_CONTACT_LIST1_PUBLISH, "u", publish);
- tp_contact_attribute_map_take_sliced_gvalue (attributes,
- contact, TP_TOKEN_CONNECTION_INTERFACE_CONTACT_LIST1_SUBSCRIBE,
- tp_g_value_slice_new_uint (subscribe));
+ g_variant_dict_insert (attributes,
+ TP_TOKEN_CONNECTION_INTERFACE_CONTACT_LIST1_SUBSCRIBE,
+ "u", subscribe);
if (tp_str_empty (publish_request) ||
publish != TP_SUBSCRIPTION_STATE_ASK)
@@ -4217,9 +4221,9 @@ tp_base_contact_list_fill_contact_attributes (TpBaseContactList *self,
}
else
{
- tp_contact_attribute_map_take_sliced_gvalue (attributes,
- contact, TP_TOKEN_CONNECTION_INTERFACE_CONTACT_LIST1_PUBLISH_REQUEST,
- tp_g_value_slice_new_take_string (publish_request));
+ g_variant_dict_insert (attributes,
+ TP_TOKEN_CONNECTION_INTERFACE_CONTACT_LIST1_PUBLISH_REQUEST,
+ "&s", publish_request);
}
return TRUE;
@@ -4231,10 +4235,13 @@ tp_base_contact_list_fill_contact_attributes (TpBaseContactList *self,
{
if (self->priv->state == TP_CONTACT_LIST_STATE_SUCCESS)
{
- tp_contact_attribute_map_take_sliced_gvalue (attributes,
- contact, TP_TOKEN_CONNECTION_INTERFACE_CONTACT_GROUPS1_GROUPS,
- tp_g_value_slice_new_take_boxed (G_TYPE_STRV,
- tp_base_contact_list_dup_contact_groups (self, contact)));
+ gchar **groups;
+
+ groups = tp_base_contact_list_dup_contact_groups (self, contact);
+ g_variant_dict_insert (attributes,
+ TP_TOKEN_CONNECTION_INTERFACE_CONTACT_GROUPS1_GROUPS,
+ "^a&s", groups);
+ g_free (groups);
}
/* else just omit the attributes */
@@ -4247,10 +4254,9 @@ tp_base_contact_list_fill_contact_attributes (TpBaseContactList *self,
{
if (self->priv->state == TP_CONTACT_LIST_STATE_SUCCESS)
{
- tp_contact_attribute_map_take_sliced_gvalue (attributes,
- contact, TP_TOKEN_CONNECTION_INTERFACE_CONTACT_BLOCKING1_BLOCKED,
- tp_g_value_slice_new_boolean (
- tp_base_contact_list_is_blocked (self, contact)));
+ g_variant_dict_insert (attributes,
+ TP_TOKEN_CONNECTION_INTERFACE_CONTACT_BLOCKING1_BLOCKED,
+ "b", tp_base_contact_list_is_blocked (self, contact));
}
/* else just omit the attributes */
diff --git a/telepathy-glib/base-contact-list.h b/telepathy-glib/base-contact-list.h
index db61fdb3d..cef0552ec 100644
--- a/telepathy-glib/base-contact-list.h
+++ b/telepathy-glib/base-contact-list.h
@@ -600,7 +600,7 @@ _TP_AVAILABLE_IN_1_0
gboolean tp_base_contact_list_fill_contact_attributes (TpBaseContactList *self,
const gchar *dbus_interface,
TpHandle contact,
- TpContactAttributeMap *attributes);
+ GVariantDict *attributes);
G_END_DECLS
diff --git a/telepathy-glib/presence-mixin.c b/telepathy-glib/presence-mixin.c
index 36509c665..56527a745 100644
--- a/telepathy-glib/presence-mixin.c
+++ b/telepathy-glib/presence-mixin.c
@@ -252,7 +252,7 @@
#include "debug-internal.h"
-static GHashTable *construct_presence_hash (
+static GVariant *construct_presence_hash (
const TpPresenceStatusSpec *supported_statuses,
GHashTable *contact_statuses);
@@ -471,16 +471,20 @@ tp_presence_mixin_emit_presence_update (GObject *obj,
{
TpPresenceMixinClass *mixin_cls =
TP_PRESENCE_MIXIN_CLASS (G_OBJECT_GET_CLASS (obj));
- GHashTable *presence_hash;
+ GVariant *presence_hash;
+ GValue value = G_VALUE_INIT;
DEBUG ("called.");
presence_hash = construct_presence_hash (mixin_cls->statuses,
contact_statuses);
+ g_variant_ref_sink (presence_hash);
+ dbus_g_value_parse_g_variant (presence_hash, &value);
tp_svc_connection_interface_presence1_emit_presences_changed (obj,
- presence_hash);
+ g_value_get_boxed (&value));
- g_hash_table_unref (presence_hash);
+ g_value_unset (&value);
+ g_variant_unref (presence_hash);
}
@@ -751,14 +755,13 @@ out:
}
}
-static GValueArray *
-construct_presence_value_array (TpPresenceStatus *status,
+static GVariant *
+construct_presence_variant (TpPresenceStatus *status,
const TpPresenceStatusSpec *supported_statuses)
{
TpConnectionPresenceType status_type;
const gchar *status_name;
const gchar *message = NULL;
- GValueArray *presence;
status_name = supported_statuses[status->index].name;
status_type = supported_statuses[status->index].presence_type;
@@ -768,36 +771,31 @@ construct_presence_value_array (TpPresenceStatus *status,
if (message == NULL)
message = "";
- presence = tp_value_array_build (3,
- G_TYPE_UINT, status_type,
- G_TYPE_STRING, status_name,
- G_TYPE_STRING, message,
- G_TYPE_INVALID);
-
- return presence;
+ return g_variant_new ("(uss)", status_type, status_name, message);
}
-static GHashTable *
+static GVariant *
construct_presence_hash (const TpPresenceStatusSpec *supported_statuses,
GHashTable *contact_statuses)
{
- GHashTable *presence_hash = g_hash_table_new_full (NULL, NULL, NULL,
- (GDestroyNotify) tp_value_array_free);
+ GVariantBuilder builder;
GHashTableIter iter;
gpointer key, value;
DEBUG ("called.");
+ g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{u(uss)}"));
g_hash_table_iter_init (&iter, contact_statuses);
while (g_hash_table_iter_next (&iter, &key, &value))
{
- GValueArray *presence;
+ TpHandle handle = GPOINTER_TO_UINT (key);
+ GVariant *presence;
- presence = construct_presence_value_array (value, supported_statuses);
- g_hash_table_insert (presence_hash, key, presence);
+ presence = construct_presence_variant (value, supported_statuses);
+ g_variant_builder_add (&builder, "{u@(uss)}", handle, presence);
}
- return presence_hash;
+ return g_variant_builder_end (&builder);
}
/**
@@ -841,12 +839,11 @@ gboolean
tp_presence_mixin_fill_contact_attributes (GObject *obj,
const gchar *dbus_interface,
TpHandle contact,
- TpContactAttributeMap *attributes)
+ GVariantDict *attributes)
{
TpPresenceMixinClass *mixin_cls =
TP_PRESENCE_MIXIN_CLASS (G_OBJECT_GET_CLASS (obj));
TpPresenceStatus *status;
- GValueArray *presence;
if (tp_strdiff (dbus_interface, TP_IFACE_CONNECTION_INTERFACE_PRESENCE1))
return FALSE;
@@ -859,11 +856,10 @@ tp_presence_mixin_fill_contact_attributes (GObject *obj,
}
else
{
- presence = construct_presence_value_array (status, mixin_cls->statuses);
- tp_presence_status_free (status);
- tp_contact_attribute_map_take_sliced_gvalue (attributes, contact,
+ g_variant_dict_insert_value (attributes,
TP_TOKEN_CONNECTION_INTERFACE_PRESENCE1_PRESENCE,
- tp_g_value_slice_new_take_boxed (TP_STRUCT_TYPE_PRESENCE, presence));
+ construct_presence_variant (status, mixin_cls->statuses));
+ tp_presence_status_free (status);
}
return TRUE;
}
diff --git a/telepathy-glib/presence-mixin.h b/telepathy-glib/presence-mixin.h
index 27a5a992a..24c9b2108 100644
--- a/telepathy-glib/presence-mixin.h
+++ b/telepathy-glib/presence-mixin.h
@@ -170,7 +170,7 @@ _TP_AVAILABLE_IN_1_0
gboolean tp_presence_mixin_fill_contact_attributes (GObject *obj,
const gchar *dbus_interface,
TpHandle contact,
- TpContactAttributeMap *attributes);
+ GVariantDict *attributes);
G_END_DECLS
diff --git a/telepathy-glib/versions/main-1.0.abi b/telepathy-glib/versions/main-1.0.abi
index a5f714758..272a54afe 100644
--- a/telepathy-glib/versions/main-1.0.abi
+++ b/telepathy-glib/versions/main-1.0.abi
@@ -224,7 +224,6 @@ tp_base_connection_channel_manager_iter_init
tp_base_connection_channel_manager_iter_next
tp_base_connection_check_connected
tp_base_connection_disconnect_with_dbus_error
-tp_base_connection_dup_contact_attributes_hash
tp_base_connection_finish_shutdown
tp_base_connection_get_account_path_suffix
tp_base_connection_get_bus_name
@@ -672,8 +671,6 @@ tp_connection_upgrade_contacts_async
tp_connection_upgrade_contacts_finish
tp_contact_add_to_group_async
tp_contact_add_to_group_finish
-tp_contact_attribute_map_set
-tp_contact_attribute_map_take_sliced_gvalue
tp_contact_authorize_publication_async
tp_contact_authorize_publication_finish
tp_contact_block_async
diff --git a/tests/lib/broken-client-types-conn.c b/tests/lib/broken-client-types-conn.c
index 7bdc76600..27246e3d5 100644
--- a/tests/lib/broken-client-types-conn.c
+++ b/tests/lib/broken-client-types-conn.c
@@ -33,22 +33,16 @@ static void
fill_contact_attributes (TpBaseConnection *base,
const gchar *dbus_interface,
TpHandle contact,
- TpContactAttributeMap *attributes)
+ GVariantDict *attributes)
{
if (!tp_strdiff (dbus_interface,
TP_IFACE_CONNECTION_INTERFACE_CLIENT_TYPES1))
{
/* Muahaha. Actually we add Presence information. */
- GValueArray *presence = tp_value_array_build (3,
- G_TYPE_UINT, TP_CONNECTION_PRESENCE_TYPE_AVAILABLE,
- G_TYPE_STRING, "available",
- G_TYPE_STRING, "hi mum!",
- G_TYPE_INVALID);
-
- tp_contact_attribute_map_take_sliced_gvalue (attributes,
- contact,
+ g_variant_dict_insert (attributes,
TP_TOKEN_CONNECTION_INTERFACE_PRESENCE1_PRESENCE,
- tp_g_value_slice_new_take_boxed (TP_STRUCT_TYPE_PRESENCE, presence));
+ "(uss)", TP_CONNECTION_PRESENCE_TYPE_AVAILABLE, "available",
+ "hi mum!");
}
}
diff --git a/tests/lib/contacts-conn.c b/tests/lib/contacts-conn.c
index 092ae975d..c59928fad 100644
--- a/tests/lib/contacts-conn.c
+++ b/tests/lib/contacts-conn.c
@@ -190,11 +190,26 @@ finalize (GObject *object)
G_OBJECT_CLASS (tp_tests_contacts_connection_parent_class)->finalize (object);
}
+static GVariant *
+_tp_g_variant_new_boxed (GType gtype,
+ gpointer boxed)
+{
+ GValue value = G_VALUE_INIT;
+ GVariant *variant;
+
+ g_value_init (&value, gtype);
+ g_value_set_boxed (&value, boxed);
+ variant = dbus_g_value_build_g_variant (&value);
+ g_value_unset (&value);
+
+ return variant;
+}
+
static void
tp_tests_contacts_connection_fill_contact_attributes (TpBaseConnection *base,
const gchar *dbus_interface,
TpHandle contact,
- TpContactAttributeMap *attributes)
+ GVariantDict *attributes)
{
TpTestsContactsConnection *self = TP_TESTS_CONTACTS_CONNECTION (base);
TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (base,
@@ -211,9 +226,8 @@ tp_tests_contacts_connection_fill_contact_attributes (TpBaseConnection *base,
alias = tp_handle_inspect (contact_repo, contact);
}
- tp_contact_attribute_map_take_sliced_gvalue (attributes, contact,
- TP_IFACE_CONNECTION_INTERFACE_ALIASING1 "/alias",
- tp_g_value_slice_new_string (alias));
+ g_variant_dict_insert (attributes,
+ TP_IFACE_CONNECTION_INTERFACE_ALIASING1 "/alias", "s", alias);
return;
}
@@ -226,9 +240,8 @@ tp_tests_contacts_connection_fill_contact_attributes (TpBaseConnection *base,
if (a != NULL && a->token != NULL)
{
- tp_contact_attribute_map_take_sliced_gvalue (attributes, contact,
- TP_IFACE_CONNECTION_INTERFACE_AVATARS1 "/token",
- tp_g_value_slice_new_string (a->token));
+ g_variant_dict_insert (attributes,
+ TP_IFACE_CONNECTION_INTERFACE_AVATARS1 "/token", "s", a->token);
}
return;
@@ -242,9 +255,9 @@ tp_tests_contacts_connection_fill_contact_attributes (TpBaseConnection *base,
if (location != NULL)
{
- tp_contact_attribute_map_take_sliced_gvalue (attributes, contact,
+ g_variant_dict_insert_value (attributes,
TP_IFACE_CONNECTION_INTERFACE_LOCATION1 "/location",
- tp_g_value_slice_new_boxed (TP_HASH_TYPE_LOCATION, location));
+ _tp_g_variant_new_boxed (TP_HASH_TYPE_LOCATION, location));
}
return;
@@ -258,10 +271,10 @@ tp_tests_contacts_connection_fill_contact_attributes (TpBaseConnection *base,
if (caps != NULL)
{
- tp_contact_attribute_map_take_sliced_gvalue (attributes, contact,
+ g_variant_dict_insert_value (attributes,
TP_IFACE_CONNECTION_INTERFACE_CONTACT_CAPABILITIES1 "/capabilities",
- tp_g_value_slice_new_boxed (
- TP_ARRAY_TYPE_REQUESTABLE_CHANNEL_CLASS_LIST, caps));
+ _tp_g_variant_new_boxed (
+ TP_ARRAY_TYPE_REQUESTABLE_CHANNEL_CLASS_LIST, caps));
}
return;
@@ -275,9 +288,9 @@ tp_tests_contacts_connection_fill_contact_attributes (TpBaseConnection *base,
if (info != NULL)
{
- tp_contact_attribute_map_take_sliced_gvalue (attributes, contact,
+ g_variant_dict_insert_value (attributes,
TP_IFACE_CONNECTION_INTERFACE_CONTACT_INFO1 "/info",
- tp_g_value_slice_new_boxed (TP_ARRAY_TYPE_CONTACT_INFO_FIELD_LIST,
+ _tp_g_variant_new_boxed (TP_ARRAY_TYPE_CONTACT_INFO_FIELD_LIST,
info));
}