From 1185caeeeb9fc9e20a1641ecd41fa0411f5c3346 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 30 Sep 2013 13:04:36 +0100 Subject: [PATCH 07/11] McdConnection: replace GetInterfaces with Get(..., "Interfaces") In Telepathy 1.0, GetInterfaces will no longer exist. --- src/mcd-connection.c | 20 +++++++++++++++----- tests/twisted/account-manager/presence.py | 12 ++++++------ tests/twisted/dispatcher/already-has-channel.py | 17 ++++++++++------- tests/twisted/dispatcher/already-has-obsolete.py | 17 +++++++++++------ tests/twisted/mctest.py | 8 ++++++++ 5 files changed, 50 insertions(+), 24 deletions(-) diff --git a/src/mcd-connection.c b/src/mcd-connection.c index 2472292..0e1a377 100644 --- a/src/mcd-connection.c +++ b/src/mcd-connection.c @@ -1220,12 +1220,13 @@ mcd_connection_early_get_statuses_cb (TpProxy *proxy, } static void -mcd_connection_early_get_interfaces_cb (TpConnection *tp_conn, - const gchar **interfaces, +mcd_connection_early_get_interfaces_cb (TpProxy *proxy, + const GValue *value, const GError *error, gpointer user_data, GObject *weak_object) { + TpConnection *tp_conn = TP_CONNECTION (proxy); McdConnection *self = MCD_CONNECTION (weak_object); const gchar **iter; @@ -1243,9 +1244,11 @@ mcd_connection_early_get_interfaces_cb (TpConnection *tp_conn, tp_proxy_get_object_path (tp_conn), g_quark_to_string (error->domain), error->code, error->message); } - else + else if (G_VALUE_HOLDS (value, G_TYPE_STRV)) { - for (iter = interfaces; *iter != NULL; iter++) + for (iter = g_value_get_boxed (value); + iter != NULL && *iter != NULL; + iter++) { GQuark q = g_quark_try_string (*iter); @@ -1299,6 +1302,12 @@ mcd_connection_early_get_interfaces_cb (TpConnection *tp_conn, } } } + else + { + DEBUG ("%s: Early GetInterfaces returned unexpected type %s", + tp_proxy_get_object_path (tp_conn), + G_VALUE_TYPE_NAME (value)); + } mcd_connection_done_task_before_connect (self); } @@ -1427,7 +1436,8 @@ request_connection_cb (TpConnectionManager *proxy, const gchar *bus_name, /* TpConnection doesn't yet know how to get this information before * the Connection goes to CONNECTED, so we'll have to do it ourselves */ - tp_cli_connection_call_get_interfaces (priv->tp_conn, -1, + tp_cli_dbus_properties_call_get (priv->tp_conn, -1, + TP_IFACE_CONNECTION, "Interfaces", mcd_connection_early_get_interfaces_cb, NULL, NULL, (GObject *) connection); diff --git a/tests/twisted/account-manager/presence.py b/tests/twisted/account-manager/presence.py index d7e30e0..4034593 100755 --- a/tests/twisted/account-manager/presence.py +++ b/tests/twisted/account-manager/presence.py @@ -78,10 +78,10 @@ def test(q, bus, mc): requested_presence=presence, expect_before_connect=[ EventPattern('dbus-method-call', - interface=cs.CONN, method='GetInterfaces', - args=[], + interface=cs.PROPERTIES_IFACE, method='Get', + args=[cs.CONN, 'Interfaces'], handled=True, - predicate=(lambda e: log.append('GetInterfaces') or True)), + predicate=(lambda e: log.append('Get(Interfaces)') or True)), EventPattern('dbus-method-call', interface=cs.PROPERTIES_IFACE, method='Get', args=[cs.CONN_IFACE_SIMPLE_PRESENCE, 'Statuses'], @@ -112,13 +112,13 @@ def test(q, bus, mc): e.args[0].get('CurrentPresence') == presence), ]) - # The events before Connect must happen in this order. GetInterfaces() may + # The events before Connect must happen in this order. Get(Interfaces) may # be called once or 2 times if len(log) == 5: - assert log == ['GetInterfaces', 'Get(Statuses)[1]', 'SetPresence[1]', + assert log == ['Get(Interfaces)', 'Get(Statuses)[1]', 'SetPresence[1]', 'Get(Statuses)[2]', 'SetPresence[2]'], log else: - assert log == ['GetInterfaces', 'GetInterfaces', 'Get(Statuses)[1]', 'SetPresence[1]', + assert log == ['Get(Interfaces)', 'Get(Interfaces)', 'Get(Statuses)[1]', 'SetPresence[1]', 'Get(Statuses)[2]', 'SetPresence[2]'], log # Change requested presence after going online diff --git a/tests/twisted/dispatcher/already-has-channel.py b/tests/twisted/dispatcher/already-has-channel.py index b5b0b0c..7c55d41 100644 --- a/tests/twisted/dispatcher/already-has-channel.py +++ b/tests/twisted/dispatcher/already-has-channel.py @@ -69,15 +69,15 @@ def test(q, bus, mc): handled=False) # Don't allow the Connection to become ready until we want it to, by - # avoiding a return from GetInterfaces + # avoiding a return from Get(Interfaces) or GetInterfaces. conn = SimulatedConnection(q, bus, 'fakecm', 'fakeprotocol', '_', 'myself', implement_get_interfaces=False) - q.dbus_return(e.message, conn.bus_name, conn.object_path, signature='so') - # this is the pre-Connect one - e = q.expect('dbus-method-call', method='GetInterfaces', + # This is the pre-Connect one, from Mission Control. + e = q.expect('dbus-method-call', method='Get', + args=[cs.CONN, 'Interfaces'], path=conn.object_path, handled=False) q.dbus_raise(e.message, cs.DISCONNECTED, 'Not connected yet') @@ -85,7 +85,10 @@ def test(q, bus, mc): path=conn.object_path, handled=True) conn.StatusChanged(cs.CONN_STATUS_CONNECTED, cs.CSR_NONE_SPECIFIED) + # This is from TpConnection. It's an implementation detail that it calls + # GetInterfaces at this point; in 'next' it will call GetAll. get_interfaces_call = q.expect('dbus-method-call', method='GetInterfaces', + args=[], path=conn.object_path, handled=False) # subscribe to the OperationList interface (MC assumes that until this @@ -95,7 +98,7 @@ def test(q, bus, mc): cd_props = dbus.Interface(cd, cs.PROPERTIES_IFACE) assert cd_props.Get(cs.CD_IFACE_OP_LIST, 'DispatchOperations') == [] - # Before returning from GetInterfaces, make a Channel spring into + # Before returning from Get(Interfaces), make a Channel spring into # existence channel_properties = dbus.Dictionary(text_fixed_properties, @@ -112,8 +115,8 @@ def test(q, bus, mc): chan = SimulatedChannel(conn, channel_properties) chan.announce() - # Now reply to GetInterfaces and say we have Requests - conn.GetInterfaces(get_interfaces_call) + # Now reply to Get(Interfaces) and say we have Requests + conn.Get_Interfaces(get_interfaces_call) # A channel dispatch operation is created for the channel we already had diff --git a/tests/twisted/dispatcher/already-has-obsolete.py b/tests/twisted/dispatcher/already-has-obsolete.py index abc3a3c..9eafa7c 100644 --- a/tests/twisted/dispatcher/already-has-obsolete.py +++ b/tests/twisted/dispatcher/already-has-obsolete.py @@ -69,14 +69,15 @@ def test(q, bus, mc): handled=False) # Don't allow the Connection to become ready until we want it to, by - # avoiding a return from GetInterfaces + # avoiding a return from Get(Interfaces) or GetInterfaces. conn = SimulatedConnection(q, bus, 'fakecm', 'fakeprotocol', '_', 'myself', implement_get_interfaces=False, has_requests=False) q.dbus_return(e.message, conn.bus_name, conn.object_path, signature='so') - # this is the pre-Connect one - e = q.expect('dbus-method-call', method='GetInterfaces', + # This is the pre-Connect one, from Mission Control. + e = q.expect('dbus-method-call', method='Get', + args=[cs.CONN, 'Interfaces'], path=conn.object_path, handled=False) q.dbus_raise(e.message, cs.DISCONNECTED, 'Not connected yet') @@ -84,7 +85,11 @@ def test(q, bus, mc): path=conn.object_path, handled=True) conn.StatusChanged(cs.CONN_STATUS_CONNECTED, cs.CSR_NONE_SPECIFIED) + # This is from TpConnection. It's an implementation detail that it calls + # GetInterfaces at this point; in 'next' it will call GetAll (but + # this test will be obsolete anyway, so it doesn't really matter). get_interfaces_call = q.expect('dbus-method-call', method='GetInterfaces', + args=[], path=conn.object_path, handled=False) # subscribe to the OperationList interface (MC assumes that until this @@ -94,7 +99,7 @@ def test(q, bus, mc): cd_props = dbus.Interface(cd, cs.PROPERTIES_IFACE) assert cd_props.Get(cs.CD_IFACE_OP_LIST, 'DispatchOperations') == [] - # Before returning from GetInterfaces, make a Channel spring into + # Before returning from Get(Interfaces), make a Channel spring into # existence channel_properties = dbus.Dictionary(text_fixed_properties, @@ -111,8 +116,8 @@ def test(q, bus, mc): chan = SimulatedChannel(conn, channel_properties) chan.announce() - # Now reply to GetInterfaces and say we don't have Requests - conn.GetInterfaces(get_interfaces_call) + # Now reply to Get(Interfaces) and say we don't have Requests + conn.Get_Interfaces(get_interfaces_call) # MC shoots down the connection. Goodbye! q.expect_many( diff --git a/tests/twisted/mctest.py b/tests/twisted/mctest.py index 0d1bd03..7f6fef3 100644 --- a/tests/twisted/mctest.py +++ b/tests/twisted/mctest.py @@ -291,6 +291,9 @@ class SimulatedConnection(object): q.add_dbus_method_impl(self.GetInterfaces, path=self.object_path, interface=cs.CONN, method='GetInterfaces') + q.add_dbus_method_impl(self.Get_Interfaces, + path=self.object_path, interface=cs.PROPERTIES_IFACE, + method='Get', args=[cs.CONN, 'Interfaces']) q.add_dbus_method_impl(self.RequestHandles, path=self.object_path, interface=cs.CONN, @@ -495,6 +498,11 @@ class SimulatedConnection(object): def GetInterfaces(self, e): self.q.dbus_return(e.message, self.interfaces, signature='as') + def Get_Interfaces(self, e): + self.q.dbus_return(e.message, + dbus.Array(self.interfaces, signature='s'), + signature='v') + def Connect(self, e): self.StatusChanged(cs.CONN_STATUS_CONNECTING, cs.CSR_REQUESTED) -- 1.8.4.rc3