From 42b2db19fe660f7c044103b0d64624c685e4823e Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Fri, 16 May 2014 10:09:05 +0200 Subject: [PATCH 09/10] stop using tp_handle_set_to_array() in tests --- tests/lib/contact-list-manager.c | 94 ++++++++++++++++++++++++---------------- 1 file changed, 56 insertions(+), 38 deletions(-) diff --git a/tests/lib/contact-list-manager.c b/tests/lib/contact-list-manager.c index 452bcce..f4ebf07 100644 --- a/tests/lib/contact-list-manager.c +++ b/tests/lib/contact-list-manager.c @@ -427,13 +427,17 @@ contact_list_request_subscription_async (TpBaseContactList *self, GAsyncReadyCallback callback, gpointer user_data) { - GArray *handles; + GVariant *handles; + gconstpointer arr; + gsize len; + + handles = tp_handle_set_to_variant (contacts); + arr = g_variant_get_fixed_array (handles, &len, sizeof (TpHandle)); - handles = tp_handle_set_to_array (contacts); tp_tests_contact_list_manager_request_subscription ( (TpTestsContactListManager *) self, - handles->len, (TpHandle *) handles->data, message); - g_array_unref (handles); + len, (TpHandle *) arr, message); + g_variant_unref (handles); tp_simple_async_report_success_in_idle ((GObject *) self, callback, user_data, contact_list_request_subscription_async); @@ -445,13 +449,16 @@ contact_list_authorize_publication_async (TpBaseContactList *self, GAsyncReadyCallback callback, gpointer user_data) { - GArray *handles; + GVariant *handles; + gconstpointer arr; + gsize len; + + handles = tp_handle_set_to_variant (contacts); + arr = g_variant_get_fixed_array (handles, &len, sizeof (TpHandle)); - handles = tp_handle_set_to_array (contacts); tp_tests_contact_list_manager_authorize_publication ( - (TpTestsContactListManager *) self, - handles->len, (TpHandle *) handles->data); - g_array_unref (handles); + (TpTestsContactListManager *) self, len, (TpHandle *) arr); + g_variant_unref (handles); tp_simple_async_report_success_in_idle ((GObject *) self, callback, user_data, contact_list_authorize_publication_async); @@ -463,13 +470,16 @@ contact_list_remove_contacts_async (TpBaseContactList *self, GAsyncReadyCallback callback, gpointer user_data) { - GArray *handles; + GVariant *handles; + gconstpointer arr; + gsize len; + + handles = tp_handle_set_to_variant (contacts); + arr = g_variant_get_fixed_array (handles, &len, sizeof (TpHandle)); - handles = tp_handle_set_to_array (contacts); tp_tests_contact_list_manager_remove ( - (TpTestsContactListManager *) self, - handles->len, (TpHandle *) handles->data); - g_array_unref (handles); + (TpTestsContactListManager *) self, len, (TpHandle *) arr); + g_variant_unref (handles); tp_simple_async_report_success_in_idle ((GObject *) self, callback, user_data, contact_list_remove_contacts_async); @@ -481,13 +491,15 @@ contact_list_unsubscribe_async (TpBaseContactList *self, GAsyncReadyCallback callback, gpointer user_data) { - GArray *handles; + GVariant *handles; + gconstpointer arr; + gsize len; - handles = tp_handle_set_to_array (contacts); + handles = tp_handle_set_to_variant (contacts); + arr = g_variant_get_fixed_array (handles, &len, sizeof (TpHandle)); tp_tests_contact_list_manager_unsubscribe ( - (TpTestsContactListManager *) self, - handles->len, (TpHandle *) handles->data); - g_array_unref (handles); + (TpTestsContactListManager *) self, len, (TpHandle *) arr); + g_variant_unref (handles); tp_simple_async_report_success_in_idle ((GObject *) self, callback, user_data, contact_list_unsubscribe_async); @@ -499,13 +511,15 @@ contact_list_unpublish_async (TpBaseContactList *self, GAsyncReadyCallback callback, gpointer user_data) { - GArray *handles; + GVariant *handles; + gconstpointer arr; + gsize len; - handles = tp_handle_set_to_array (contacts); + handles = tp_handle_set_to_variant (contacts); + arr = g_variant_get_fixed_array (handles, &len, sizeof (TpHandle)); tp_tests_contact_list_manager_unpublish ( - (TpTestsContactListManager *) self, - handles->len, (TpHandle *) handles->data); - g_array_unref (handles); + (TpTestsContactListManager *) self, len, (TpHandle *) arr); + g_variant_unref (handles); tp_simple_async_report_success_in_idle ((GObject *) self, callback, user_data, contact_list_unpublish_async); @@ -668,14 +682,16 @@ static gboolean receive_authorized (gpointer p) { SelfAndContact *s = p; - GArray *handles_array; - guint i; + GVariant *handles; + GVariantIter iter; + TpHandle handle; + + handles = tp_handle_set_to_variant (s->handles); - handles_array = tp_handle_set_to_array (s->handles); - for (i = 0; i < handles_array->len; i++) + g_variant_iter_init (&iter, handles); + while (g_variant_iter_loop (&iter, "u", &handle)) { - ContactDetails *d = lookup_contact (s->self, - g_array_index (handles_array, TpHandle, i)); + ContactDetails *d = lookup_contact (s->self, handle); if (d == NULL) continue; @@ -690,7 +706,7 @@ receive_authorized (gpointer p) d->publish_request = g_strdup ("automatic publish request"); } } - g_array_unref (handles_array); + g_variant_unref (handles); tp_base_contact_list_contacts_changed (TP_BASE_CONTACT_LIST (s->self), s->handles, NULL); @@ -702,21 +718,23 @@ static gboolean receive_unauthorized (gpointer p) { SelfAndContact *s = p; - GArray *handles_array; - guint i; + GVariant *handles; + GVariantIter iter; + TpHandle handle; + + handles = tp_handle_set_to_variant (s->handles); - handles_array = tp_handle_set_to_array (s->handles); - for (i = 0; i < handles_array->len; i++) + g_variant_iter_init (&iter, handles); + while (g_variant_iter_loop (&iter, "u", &handle)) { - ContactDetails *d = lookup_contact (s->self, - g_array_index (handles_array, TpHandle, i)); + ContactDetails *d = lookup_contact (s->self, handle); if (d == NULL) continue; d->subscribe = TP_SUBSCRIPTION_STATE_REMOVED_REMOTELY; } - g_array_unref (handles_array); + g_variant_unref (handles); tp_base_contact_list_contacts_changed (TP_BASE_CONTACT_LIST (s->self), s->handles, NULL); -- 1.9.0