[empathy] dispatcher: use TpCapabilities to get the RCC (#626636)



commit 02cc95c188b9b29e91b0e6ffae5325c20b10377a
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date:   Wed Aug 11 17:15:26 2010 +0200

    dispatcher: use TpCapabilities to get the RCC (#626636)

 libempathy/empathy-dispatcher.c |   75 +++++++++++++++-----------------------
 1 files changed, 30 insertions(+), 45 deletions(-)
---
diff --git a/libempathy/empathy-dispatcher.c b/libempathy/empathy-dispatcher.c
index 557d435..55dfcf0 100644
--- a/libempathy/empathy-dispatcher.c
+++ b/libempathy/empathy-dispatcher.c
@@ -210,59 +210,45 @@ dispatcher_channel_invalidated_cb (TpProxy *proxy,
 }
 
 static void
-dispatcher_connection_got_all (TpProxy *proxy,
-                               GHashTable *properties,
-                               const GError *error,
-                               gpointer user_data,
-                               GObject *object)
+got_connection_rcc (EmpathyDispatcher *self,
+    TpConnection *connection)
 {
-  EmpathyDispatcher *self = EMPATHY_DISPATCHER (object);
   EmpathyDispatcherPriv *priv = GET_PRIV (self);
-  GPtrArray *requestable_channels;
-
-  if (error) {
-    DEBUG ("Error: %s", error->message);
-    return;
-  }
-
-  requestable_channels = tp_asv_get_boxed (properties,
-    "RequestableChannelClasses", TP_ARRAY_TYPE_REQUESTABLE_CHANNEL_CLASS_LIST);
+  TpCapabilities *caps;
+  ConnectionData *cd;
+  GList *requests, *l;
+  FindChannelRequest *request;
+  GList *retval;
 
-  if (requestable_channels == NULL)
-    DEBUG ("No RequestableChannelClasses property !?! on connection");
-  else
-    {
-      ConnectionData *cd;
-      GList *requests, *l;
-      FindChannelRequest *request;
-      GList *retval;
+  caps = tp_connection_get_capabilities (connection);
+  g_assert (caps != NULL);
 
-      cd = g_hash_table_lookup (priv->connections, proxy);
-      g_assert (cd != NULL);
+  cd = g_hash_table_lookup (priv->connections, connection);
+  g_assert (cd != NULL);
 
-      cd->requestable_channels = g_boxed_copy (
-        TP_ARRAY_TYPE_REQUESTABLE_CHANNEL_CLASS_LIST, requestable_channels);
+  cd->requestable_channels = g_boxed_copy (
+    TP_ARRAY_TYPE_REQUESTABLE_CHANNEL_CLASS_LIST,
+    tp_capabilities_get_channel_classes (caps));
 
-      requests = g_hash_table_lookup (priv->outstanding_classes_requests,
-          proxy);
+  requests = g_hash_table_lookup (priv->outstanding_classes_requests,
+      connection);
 
-      for (l = requests; l != NULL; l = l->next)
-        {
-          request = l->data;
+  for (l = requests; l != NULL; l = l->next)
+    {
+      request = l->data;
 
-          retval = empathy_dispatcher_find_channel_classes (self,
-              TP_CONNECTION (proxy), request->channel_type,
-              request->handle_type, request->properties);
-          request->callback (retval, request->user_data);
+      retval = empathy_dispatcher_find_channel_classes (self,
+          connection, request->channel_type,
+          request->handle_type, request->properties);
+      request->callback (retval, request->user_data);
 
-          free_find_channel_request (request);
-          g_list_free (retval);
-        }
+      free_find_channel_request (request);
+      g_list_free (retval);
+    }
 
-      g_list_free (requests);
+  g_list_free (requests);
 
-      g_hash_table_remove (priv->outstanding_classes_requests, proxy);
-    }
+  g_hash_table_remove (priv->outstanding_classes_requests, connection);
 }
 
 static void
@@ -282,9 +268,7 @@ connection_prepare_cb (GObject *source,
       goto out;
     }
 
-  tp_cli_dbus_properties_call_get_all (connection, -1,
-      TP_IFACE_CONNECTION_INTERFACE_REQUESTS, dispatcher_connection_got_all,
-      NULL, NULL, G_OBJECT (self));
+  got_connection_rcc (self, connection);
 
 out:
   g_object_unref (self);
@@ -296,6 +280,7 @@ dispatcher_init_connection_if_needed (EmpathyDispatcher *self,
 {
   EmpathyDispatcherPriv *priv = GET_PRIV (self);
   GQuark features[] = { TP_CONNECTION_FEATURE_CORE,
+         TP_CONNECTION_FEATURE_CAPABILITIES,
          0 };
 
   if (g_hash_table_lookup (priv->connections, connection) != NULL)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]