[next] telepathy-glib: Observer: Requests_Satisfied is now a dict

Guillaume Desmottes gdesmott at kemper.freedesktop.org
Mon Feb 10 08:33:11 PST 2014


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

Author: Guillaume Desmottes <guillaume.desmottes at collabora.co.uk>
Date:   Mon Feb 10 12:25:02 2014 +0100

Observer: Requests_Satisfied is now a dict

---

 telepathy-glib/base-client.c             |   22 ++++++++++------------
 telepathy-glib/observe-channel-context.c |   15 ++++++++-------
 tests/dbus/base-client.c                 |   13 ++++++-------
 tests/dbus/simple-observer.c             |    7 +++----
 4 files changed, 27 insertions(+), 30 deletions(-)

diff --git a/telepathy-glib/base-client.c b/telepathy-glib/base-client.c
index 111566d..f0f920e 100644
--- a/telepathy-glib/base-client.c
+++ b/telepathy-glib/base-client.c
@@ -1651,7 +1651,7 @@ _tp_base_client_observe_channel (TpSvcClientObserver *iface,
     const gchar *channel_path,
     GHashTable *channel_props,
     const gchar *dispatch_operation_path,
-    const GPtrArray *requests_arr,
+    GHashTable *requests_hash,
     GHashTable *observer_info,
     DBusGMethodInvocation *context)
 {
@@ -1663,12 +1663,12 @@ _tp_base_client_observe_channel (TpSvcClientObserver *iface,
   TpConnection *connection = NULL;
   GPtrArray *requests = NULL;
   TpChannelDispatchOperation *dispatch_operation = NULL;
-  guint i;
   TpChannel *channel = NULL;
   GArray *account_features;
   GArray *connection_features;
   GArray *channel_features;
-  GHashTable *request_props;
+  GHashTableIter iter;
+  gpointer k, v;
 
   if (!(self->priv->flags & CLIENT_IS_OBSERVER))
     {
@@ -1709,17 +1709,15 @@ _tp_base_client_observe_channel (TpSvcClientObserver *iface,
         }
     }
 
-  requests = g_ptr_array_new_full (requests_arr->len, g_object_unref);
-  request_props = tp_asv_get_boxed (observer_info, "request-properties",
-    TP_HASH_TYPE_OBJECT_IMMUTABLE_PROPERTIES_MAP);
-  for (i = 0; i < requests_arr->len; i++)
+  requests = g_ptr_array_new_full (g_hash_table_size (requests_hash),
+      g_object_unref);
+
+  g_hash_table_iter_init (&iter, requests_hash);
+  while (g_hash_table_iter_next (&iter, &k, &v))
     {
-      const gchar *req_path = g_ptr_array_index (requests_arr, i);
+      const gchar *req_path = k;
+      GHashTable *props = v;
       TpChannelRequest *request;
-      GHashTable *props = NULL;
-
-      if (request_props != NULL)
-        props = g_hash_table_lookup (request_props, req_path);
 
       request = _tp_client_factory_ensure_channel_request (
           self->priv->factory, req_path, props, &error);
diff --git a/telepathy-glib/observe-channel-context.c b/telepathy-glib/observe-channel-context.c
index 5539563..e5efa57 100644
--- a/telepathy-glib/observe-channel-context.c
+++ b/telepathy-glib/observe-channel-context.c
@@ -694,13 +694,14 @@ _tp_observe_channel_context_prepare_finish (
 GList *
 tp_observe_channel_context_get_requests (TpObserveChannelContext *self)
 {
-  GHashTable *request_props;
+  GList *list = NULL;
+  guint i;
 
-  request_props = tp_asv_get_boxed (self->observer_info, "request-properties",
-      TP_HASH_TYPE_OBJECT_IMMUTABLE_PROPERTIES_MAP);
-  if (request_props == NULL)
-    return NULL;
+  for (i = 0; i < self->requests->len; i++)
+    {
+      list = g_list_prepend (list, g_object_ref (g_ptr_array_index (
+              self->requests, i)));
+    }
 
-  return _tp_create_channel_request_list (
-      tp_proxy_get_factory (self->account), request_props);
+  return list;
 }
diff --git a/tests/dbus/base-client.c b/tests/dbus/base-client.c
index 2efa5cc..685cd92 100644
--- a/tests/dbus/base-client.c
+++ b/tests/dbus/base-client.c
@@ -467,8 +467,7 @@ static void
 test_observer (Test *test,
     gconstpointer data G_GNUC_UNUSED)
 {
-  GHashTable *filter, *chan_props;
-  GPtrArray *requests_satisified;
+  GHashTable *requests_satisfied, *filter, *chan_props;
   GHashTable *info;
   TpChannel *chan;
 
@@ -512,7 +511,7 @@ test_observer (Test *test,
   /* Call ObserveChannels */
   chan_props = tp_tests_dup_channel_props_asv (test->text_chan);
 
-  requests_satisified = g_ptr_array_sized_new (0);
+  requests_satisfied = g_hash_table_new (NULL, NULL);
   info = tp_asv_new (
       "recovering", G_TYPE_BOOLEAN, TRUE,
       NULL);
@@ -524,7 +523,7 @@ test_observer (Test *test,
       tp_proxy_get_object_path (test->account),
       tp_proxy_get_object_path (test->connection),
       tp_proxy_get_object_path (test->text_chan), chan_props,
-      "/", requests_satisified, info,
+      "/", requests_satisfied, info,
       no_return_cb, test, NULL, NULL);
 
   test->wait++;
@@ -544,7 +543,7 @@ test_observer (Test *test,
       tp_proxy_get_object_path (test->account),
       tp_proxy_get_object_path (test->connection),
       tp_proxy_get_object_path (test->text_chan), chan_props,
-      "/", requests_satisified, info,
+      "/", requests_satisfied, info,
       no_return_cb, test, NULL, NULL);
 
   test->wait++;
@@ -559,7 +558,7 @@ test_observer (Test *test,
       tp_proxy_get_object_path (test->account),
       tp_proxy_get_object_path (test->connection),
       tp_proxy_get_object_path (test->text_chan), chan_props,
-      "/", requests_satisified, info,
+      "/", requests_satisfied, info,
       no_return_cb, test, NULL, NULL);
 
   tp_base_channel_close ((TpBaseChannel *) test->text_chan_service);
@@ -572,7 +571,7 @@ test_observer (Test *test,
   g_assert (TP_IS_CHANNEL (chan));
   g_assert (tp_proxy_get_invalidated (chan) != NULL);
 
-  g_ptr_array_unref (requests_satisified);
+  g_hash_table_unref (requests_satisfied);
   g_hash_table_unref (info);
   g_hash_table_unref (chan_props);
 }
diff --git a/tests/dbus/simple-observer.c b/tests/dbus/simple-observer.c
index 3e23411..56e2e93 100644
--- a/tests/dbus/simple-observer.c
+++ b/tests/dbus/simple-observer.c
@@ -317,12 +317,11 @@ out:
 static void
 call_observe_channel (Test *test)
 {
-  GPtrArray *requests_satisified;
-  GHashTable *info, *chan_props;
+  GHashTable *requests_satisified, *info, *chan_props;
 
   chan_props = tp_tests_dup_channel_props_asv (test->text_chan);
 
-  requests_satisified = g_ptr_array_sized_new (0);
+  requests_satisified = g_hash_table_new (NULL, NULL);
   info = tp_asv_new (
       "recovering", G_TYPE_BOOLEAN, TRUE,
       NULL);
@@ -339,7 +338,7 @@ call_observe_channel (Test *test)
 
   g_main_loop_run (test->mainloop);
 
-  g_ptr_array_unref (requests_satisified);
+  g_hash_table_unref (requests_satisified);
   g_hash_table_unref (info);
   g_hash_table_unref (chan_props);
 }



More information about the telepathy-commits mailing list