summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2014-04-07 18:28:20 +0100
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2014-04-08 19:53:51 +0100
commit614b2fa28ef759fce970951893697ed67931c1c7 (patch)
treee6593f21a1598ddde14b577b418f48cf02c5bb5e
parentd7a8163baa6aabbfc1d3643f9f3ae1cb71b5aa0b (diff)
TpChannel::group-members-changed: change details GHashTable to GVariant
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=77139 Reviewed-by: Xavier Claessens
-rw-r--r--telepathy-glib/channel-group.c14
-rw-r--r--telepathy-glib/channel.c9
-rw-r--r--tests/dbus/channel.c2
-rw-r--r--tests/dbus/cli-group.c9
-rw-r--r--tests/dbus/group-mixin.c55
5 files changed, 53 insertions, 36 deletions
diff --git a/telepathy-glib/channel-group.c b/telepathy-glib/channel-group.c
index 7e1272f4c..e3c143100 100644
--- a/telepathy-glib/channel-group.c
+++ b/telepathy-glib/channel-group.c
@@ -447,7 +447,7 @@ typedef struct
GPtrArray *local_pending;
GPtrArray *remote_pending;
TpContact *actor;
- GHashTable *details;
+ GVariant *details;
} MembersChangedData;
static void
@@ -458,7 +458,7 @@ members_changed_data_free (MembersChangedData *data)
tp_clear_pointer (&data->local_pending, g_ptr_array_unref);
tp_clear_pointer (&data->remote_pending, g_ptr_array_unref);
g_clear_object (&data->actor);
- tp_clear_pointer (&data->details, g_hash_table_unref);
+ g_clear_pointer (&data->details, g_variant_unref);
g_slice_free (MembersChangedData, data);
}
@@ -477,8 +477,8 @@ members_changed_prepared_cb (GObject *object,
_tp_channel_contacts_queue_prepare_finish (self, result, NULL, NULL);
- reason = tp_asv_get_uint32 (data->details, "change-reason", NULL);
- message = tp_asv_get_string (data->details, "message");
+ reason = tp_vardict_get_uint32 (data->details, "change-reason", NULL);
+ message = tp_vardict_get_string (data->details, "message");
for (i = 0; i < data->added->len; i++)
{
@@ -575,9 +575,9 @@ members_changed_prepared_cb (GObject *object,
if (contact == self->priv->group_self_contact ||
contact == tp_connection_get_self_contact (self->priv->connection))
{
- const gchar *error_detail = tp_asv_get_string (data->details,
+ const gchar *error_detail = tp_vardict_get_string (data->details,
"error");
- const gchar *debug_message = tp_asv_get_string (data->details,
+ const gchar *debug_message = tp_vardict_get_string (data->details,
"debug-message");
if (debug_message == NULL && !tp_str_empty (message))
@@ -675,7 +675,7 @@ members_changed_cb (TpChannel *self,
data->local_pending = dup_contact_array (self, local_pending, ids);
data->remote_pending = dup_contact_array (self, remote_pending, ids);
data->actor = dup_contact (self, actor, ids);
- data->details = g_hash_table_ref (details);
+ data->details = g_variant_ref_sink (tp_asv_to_vardict (details));
contacts = g_ptr_array_new ();
tp_g_ptr_array_extend (contacts, data->added);
diff --git a/telepathy-glib/channel.c b/telepathy-glib/channel.c
index f2451aa83..9faaf5d55 100644
--- a/telepathy-glib/channel.c
+++ b/telepathy-glib/channel.c
@@ -1425,10 +1425,9 @@ tp_channel_class_init (TpChannelClass *klass)
* @remote_pending: (type GLib.PtrArray) (element-type TelepathyGLib.Contact):
* a #GPtrArray of #TpContact containing the remote-pending members added
* @actor: a #TpContact for the "actor" handle in @details
- * @details: (type GLib.HashTable) (element-type utf8 GObject.Value):
- * a #GHashTable mapping (gchar *) to #GValue containing details
- * about the change, as described in the specification of the
- * MembersChanged signal.
+ * @details: a %G_VARIANT_TYPE_VARDICT (map from strings to variants)
+ * containing details about the change, as described in the specification
+ * of the MembersChanged signal.
*
* Emitted when the group members change in a Group channel.
*
@@ -1445,7 +1444,7 @@ tp_channel_class_init (TpChannelClass *klass)
NULL, NULL, NULL,
G_TYPE_NONE, 6,
G_TYPE_PTR_ARRAY, G_TYPE_PTR_ARRAY, G_TYPE_PTR_ARRAY, G_TYPE_PTR_ARRAY,
- TP_TYPE_CONTACT, TP_HASH_TYPE_STRING_VARIANT_MAP);
+ TP_TYPE_CONTACT, G_TYPE_VARIANT);
}
TpChannel *
diff --git a/tests/dbus/channel.c b/tests/dbus/channel.c
index e226bf1ad..c3da0f69a 100644
--- a/tests/dbus/channel.c
+++ b/tests/dbus/channel.c
@@ -574,7 +574,7 @@ group_contacts_changed_cb (TpChannel *self,
GPtrArray *local_pending,
GPtrArray *remote_pending,
TpContact *actor,
- GHashTable *details,
+ GVariant *details,
Test *test)
{
test->wait--;
diff --git a/tests/dbus/cli-group.c b/tests/dbus/cli-group.c
index d3e5b7ce7..4a199e26c 100644
--- a/tests/dbus/cli-group.c
+++ b/tests/dbus/cli-group.c
@@ -49,14 +49,15 @@ group_members_changed_cb (TpChannel *chan_,
GPtrArray *local_pending,
GPtrArray *remote_pending,
TpContact *actor,
- GHashTable *details,
+ GVariant *details,
gpointer user_data)
{
- guint reason = tp_asv_get_uint32 (details, "change-reason", NULL);
+ guint reason = tp_vardict_get_uint32 (details, "change-reason", NULL);
GMainLoop *loop = user_data;
- DEBUG ("%u, %u, %u, %u, %u details", added->len, removed->len,
- local_pending->len, remote_pending->len, g_hash_table_size (details));
+ DEBUG ("%u, %u, %u, %u, %" G_GSIZE_FORMAT " details", added->len,
+ removed->len, local_pending->len, remote_pending->len,
+ g_variant_n_children (details));
MYASSERT (expecting_group_members_changed, "");
g_assert_cmpuint (reason, ==, expected_reason);
diff --git a/tests/dbus/group-mixin.c b/tests/dbus/group-mixin.c
index df94f039e..9c110816d 100644
--- a/tests/dbus/group-mixin.c
+++ b/tests/dbus/group-mixin.c
@@ -51,7 +51,7 @@ TpHandle self_handle, camel, camel2;
typedef void (*diff_checker) (const GPtrArray *added, const GPtrArray *removed,
const GPtrArray *local_pending, const GPtrArray *remote_pending,
- const GHashTable *details);
+ GVariant *details);
static gboolean expecting_members_changed = FALSE;
static const gchar *expected_message;
@@ -93,7 +93,7 @@ on_members_changed (TpChannel *proxy,
GPtrArray *local_pending,
GPtrArray *remote_pending,
TpContact *actor,
- GHashTable *details,
+ GVariant *details,
gpointer user_data)
{
const gchar *message;
@@ -104,7 +104,7 @@ on_members_changed (TpChannel *proxy,
": got unexpected MembersChanged");
expecting_members_changed = FALSE;
- message = tp_asv_get_string (details, "message");
+ message = tp_vardict_get_string (details, "message");
if (message == NULL)
message = "";
@@ -120,7 +120,7 @@ on_members_changed (TpChannel *proxy,
g_assert_cmpuint (expected_actor, ==, 0);
}
- reason = tp_asv_get_uint32 (details, "change-reason", &valid);
+ reason = tp_vardict_get_uint32 (details, "change-reason", &valid);
if (valid)
{
g_assert_cmpuint (reason, ==, expected_reason);
@@ -129,8 +129,7 @@ on_members_changed (TpChannel *proxy,
{
g_assert_cmpuint (expected_reason, ==,
TP_CHANNEL_GROUP_CHANGE_REASON_NONE);
- MYASSERT (tp_asv_lookup (details, "reason") == NULL,
- ": utterly unreasonable");
+ g_assert (!tp_vardict_has_key (details, "reason"));
}
expected_diffs (added, removed, local_pending,
@@ -178,10 +177,10 @@ check_initial_properties (void)
}
static void
-details_contains_ids_for (const GHashTable *details,
+details_contains_ids_for (GVariant *details,
TpHandle *hs)
{
- GHashTable *contact_ids;
+ GVariant *contact_ids;
const gchar *id;
guint n = 0;
TpHandle *h;
@@ -189,20 +188,38 @@ details_contains_ids_for (const GHashTable *details,
if (details == NULL)
return;
- contact_ids = tp_asv_get_boxed (details, "contact-ids",
- TP_HASH_TYPE_HANDLE_IDENTIFIER_MAP);
+ if (!g_variant_lookup (details, "contact-ids", "@a{us}", &contact_ids))
+ {
+ g_error ("details did not contain contact-ids or it had the wrong type");
+ }
+
g_assert (contact_ids != NULL);
for (h = hs; *h != 0; h++)
{
+ gboolean found = FALSE;
+ gsize i;
+ guint32 handle;
n++;
- id = g_hash_table_lookup (contact_ids, GUINT_TO_POINTER (*h));
- MYASSERT (id != NULL, ": id for %u in map", *h);
- g_assert_cmpstr (id, ==, tp_handle_inspect (contact_repo, *h));
+ for (i = 0; i < g_variant_n_children (contact_ids); i++)
+ {
+ g_variant_get_child (contact_ids, i, "{u&s}", &handle, &id);
+
+ if (handle == *h)
+ {
+ g_assert_cmpstr (id, !=, NULL);
+ g_assert_cmpstr (id, ==, tp_handle_inspect (contact_repo, *h));
+ found = TRUE;
+ }
+ }
+
+ if (!found)
+ g_error ("did not find an ID for contact#%u", *h);
}
- MYASSERT (g_hash_table_size (contact_ids) == n, ": %u contact IDs", n);
+ g_assert_cmpuint (g_variant_n_children (contact_ids), ==, n);
+ g_variant_unref (contact_ids);
}
static void
@@ -210,7 +227,7 @@ self_added_to_lp (const GPtrArray *added,
const GPtrArray *removed,
const GPtrArray *local_pending,
const GPtrArray *remote_pending,
- const GHashTable *details)
+ GVariant *details)
{
TpContact *c;
TpHandle hs[] = { self_handle, 0 };
@@ -232,7 +249,7 @@ self_added_to_members (const GPtrArray *added,
const GPtrArray *removed,
const GPtrArray *local_pending,
const GPtrArray *remote_pending,
- const GHashTable *details)
+ GVariant *details)
{
TpContact *c;
TpHandle hs[] = { self_handle, 0 };
@@ -301,7 +318,7 @@ camel_added (const GPtrArray *added,
const GPtrArray *removed,
const GPtrArray *local_pending,
const GPtrArray *remote_pending,
- const GHashTable *details)
+ GVariant *details)
{
TpContact *c;
TpHandle hs[] = { camel, 0 };
@@ -323,7 +340,7 @@ camel2_added (const GPtrArray *added,
const GPtrArray *removed,
const GPtrArray *local_pending,
const GPtrArray *remote_pending,
- const GHashTable *details)
+ GVariant *details)
{
TpContact *c;
/* camel is the actor */
@@ -346,7 +363,7 @@ camel_removed (const GPtrArray *added,
const GPtrArray *removed,
const GPtrArray *local_pending,
const GPtrArray *remote_pending,
- const GHashTable *details)
+ GVariant *details)
{
TpContact *c;
/* camel2 is the actor. camel shouldn't be in the ids, because they were