[Pkg-telepathy-commits] [telepathy-mission-control-6] 45/280: Make ServicePoint setup more sensible

Simon McVittie smcv at debian.org
Thu Mar 27 20:07:03 UTC 2014


This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to branch debian
in repository telepathy-mission-control-6.

commit 010677b4f5bdd6426b5f7d1a5fc946f4c5d37f2c
Author: Simon McVittie <simon.mcvittie at collabora.co.uk>
Date:   Wed Oct 2 19:46:41 2013 +0100

    Make ServicePoint setup more sensible
    
    mcd_connection_service_point_setup shouldn't call GetInterfaces -
    TpConnection already knows how to do that.
    
    As currently implemented, mcd_connection_service_point_setup() is only
    called from the status-changed callback for CONNECTED, which
    telepathy-glib guarantees not to call until core features are ready.
    However, it's a lot more clearly correct if we do this in
    on_connection_ready().
    
    Bug: https://bugs.freedesktop.org/show_bug.cgi?id=54879
    Reviewed-by: Guillaume Desmottes <guillaume.desmottes at collabora.co.uk>
---
 src/mcd-connection-service-points.c | 50 ++++++++-----------------------------
 src/mcd-connection.c                | 12 ++++++---
 2 files changed, 19 insertions(+), 43 deletions(-)

diff --git a/src/mcd-connection-service-points.c b/src/mcd-connection-service-points.c
index 896f4bc..b52abe3 100644
--- a/src/mcd-connection-service-points.c
+++ b/src/mcd-connection-service-points.c
@@ -90,31 +90,16 @@ service_points_fetched_cb (TpProxy *proxy,
     parse_services_list (connection, g_value_get_boxed (value));
 }
 
-static void
-service_point_interface_check (TpConnection *tp_conn,
-    const gchar **interfaces,
-    const GError *error,
-    gpointer data,
-    GObject *connection)
+void
+mcd_connection_service_point_setup (McdConnection *connection,
+    gboolean watch)
 {
-  const gchar *interface;
-  gboolean found = FALSE;
-  gboolean watch = GPOINTER_TO_UINT (data);
-  guint i = 0;
-
-  if (interfaces == NULL)
-    return;
-
-  for (interface = interfaces[0];
-       !found && !tp_str_empty (interface);
-       interface = interfaces[++i])
-    {
-      if (!tp_strdiff (interface, TP_IFACE_CONNECTION_INTERFACE_SERVICE_POINT))
-        found = TRUE;
-    }
+  TpConnection *tp_conn = mcd_connection_get_tp_connection (connection);
 
-  if (!found)
-    return;
+  g_return_if_fail (MCD_IS_CONNECTION (connection));
+  g_return_if_fail (TP_IS_PROXY (tp_conn));
+  g_return_if_fail (tp_proxy_is_prepared (tp_conn,
+        TP_CONNECTION_FEATURE_CONNECTED));
 
   /* so we know if/when the service points change (eg the SIM might not be
    * accessible yet, in which case the call below won't return any entries)
@@ -122,25 +107,12 @@ service_point_interface_check (TpConnection *tp_conn,
    */
   if (watch)
     tp_cli_connection_interface_service_point_connect_to_service_points_changed
-      (tp_conn, service_points_changed_cb, NULL, NULL, connection, NULL);
+      (tp_conn, service_points_changed_cb, NULL, NULL,
+       (GObject *) connection, NULL);
 
   /* fetch the current list to initialise our state */
   tp_cli_dbus_properties_call_get (tp_conn, -1,
       TP_IFACE_CONNECTION_INTERFACE_SERVICE_POINT,
       "KnownServicePoints", service_points_fetched_cb,
-      NULL, NULL, connection);
-}
-
-void
-mcd_connection_service_point_setup (McdConnection *connection, gboolean watch)
-{
-  TpConnection *tp_conn = mcd_connection_get_tp_connection (connection);
-
-  if (G_UNLIKELY (!tp_conn))
-    return;
-
-  /* see if the connection supports the service point interface */
-  tp_cli_connection_call_get_interfaces (tp_conn, -1,
-      service_point_interface_check,
-      GUINT_TO_POINTER (watch), NULL, G_OBJECT (connection));
+      NULL, NULL, (GObject *) connection);
 }
diff --git a/src/mcd-connection.c b/src/mcd-connection.c
index 0e1a377..cf8044e 100644
--- a/src/mcd-connection.c
+++ b/src/mcd-connection.c
@@ -591,10 +591,6 @@ on_connection_status_changed (TpConnection *tp_conn, GParamSpec *pspec,
                 priv->probation_drop_count = 0;
             }
 
-            mcd_connection_service_point_setup (connection,
-                                                !priv->service_points_watched);
-            priv->service_points_watched = TRUE;
-
             priv->connected = TRUE;
         }
         break;
@@ -1094,6 +1090,14 @@ on_connection_ready (GObject *source_object, GAsyncResult *result,
     DEBUG ("connection is ready");
     priv = MCD_CONNECTION_PRIV (connection);
 
+    if (tp_proxy_has_interface_by_id (tp_conn,
+        TP_IFACE_QUARK_CONNECTION_INTERFACE_SERVICE_POINT))
+    {
+        mcd_connection_service_point_setup (connection,
+                                            !priv->service_points_watched);
+        priv->service_points_watched = TRUE;
+    }
+
     priv->has_presence_if = tp_proxy_has_interface_by_id
         (tp_conn, TP_IFACE_QUARK_CONNECTION_INTERFACE_SIMPLE_PRESENCE);
     priv->has_contact_capabilities_if = tp_proxy_has_interface_by_id (tp_conn,

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-telepathy/telepathy-mission-control-6.git



More information about the Pkg-telepathy-commits mailing list