From 7fdddfaa3230596267cc65648ce59dbec0c7e84c Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 26 Sep 2013 20:19:33 +0100 Subject: [PATCH 12/22] turn CreateChannelWithHints into CreateChannel Correspondingly, stop implementing SupportsRequestHints: there has been no version of Telepathy 1 that lacked this functionality. --- src/mcd-dispatcher.c | 53 +++------------------- tests/twisted/account-manager/make-valid.py | 1 + tests/twisted/account-requests/cancel.py | 5 +- tests/twisted/account-requests/create-text.py | 20 +++++--- .../delete-account-during-request.py | 14 ++++-- tests/twisted/dispatcher/cancel.py | 1 + tests/twisted/dispatcher/connect-for-request.py | 1 + tests/twisted/dispatcher/create-at-startup.py | 1 + .../dispatcher/create-delayed-by-mini-plugin.py | 1 + tests/twisted/dispatcher/create-handler-fails.py | 1 + tests/twisted/dispatcher/create-hints.py | 10 ++-- .../dispatcher/create-no-preferred-handler.py | 1 + .../dispatcher/create-rejected-by-mini-plugin.py | 1 + tests/twisted/dispatcher/create-text.py | 1 + .../dispatcher/dispatch-delayed-by-mini-plugin.py | 4 +- tests/twisted/dispatcher/ensure-and-redispatch.py | 2 + tests/twisted/dispatcher/ensure-is-approval.py | 1 + tests/twisted/dispatcher/ensure-rapidly.py | 2 + tests/twisted/dispatcher/fdo-21034.py | 2 + tests/twisted/dispatcher/redispatch-channels.py | 7 +-- .../twisted/dispatcher/request-disabled-account.py | 1 + 21 files changed, 61 insertions(+), 69 deletions(-) diff --git a/src/mcd-dispatcher.c b/src/mcd-dispatcher.c index 36fbe26..6d57f78 100644 --- a/src/mcd-dispatcher.c +++ b/src/mcd-dispatcher.c @@ -829,7 +829,6 @@ mcd_dispatcher_class_init (McdDispatcherClass * klass) { static TpDBusPropertiesMixinPropImpl cd_props[] = { { "Interfaces", "interfaces", NULL }, - { "SupportsRequestHints", "supports-request-hints", NULL }, { NULL } }; static TpDBusPropertiesMixinPropImpl op_list_props[] = { @@ -876,12 +875,6 @@ mcd_dispatcher_class_init (McdDispatcherClass * klass) G_TYPE_STRV, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); - g_object_class_install_property ( - object_class, PROP_SUPPORTS_REQUEST_HINTS, - g_param_spec_boolean ("supports-request-hints", "SupportsRequestHints", - "Yes, we support CreateChannelWithHints etc.", - TRUE, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); - g_object_class_install_property (object_class, PROP_DISPATCH_OPERATIONS, g_param_spec_boxed ("dispatch-operations", @@ -1253,6 +1246,7 @@ dispatcher_request_channel (McdDispatcher *self, McdRequest *request = NULL; GError *error = NULL; const gchar *path; + GHashTable *immutables; g_return_if_fail (account_path != NULL); g_return_if_fail (requested_properties != NULL); @@ -1297,7 +1291,10 @@ dispatcher_request_channel (McdDispatcher *self, /* This is OK because the signatures of CreateChannel and EnsureChannel * are the same */ - tp_svc_channel_dispatcher_return_from_create_channel (context, path); + immutables = _mcd_request_dup_immutable_properties (request); + tp_svc_channel_dispatcher_return_from_create_channel (context, path, + immutables); + g_hash_table_unref (immutables); _mcd_request_predict_handler (request); @@ -1318,42 +1315,6 @@ finally: static void dispatcher_create_channel (TpSvcChannelDispatcher *iface, - const gchar *account_path, - GHashTable *requested_properties, - gint64 user_action_time, - const gchar *preferred_handler, - DBusGMethodInvocation *context) -{ - dispatcher_request_channel (MCD_DISPATCHER (iface), - account_path, - requested_properties, - user_action_time, - preferred_handler, - NULL, - context, - FALSE); -} - -static void -dispatcher_ensure_channel (TpSvcChannelDispatcher *iface, - const gchar *account_path, - GHashTable *requested_properties, - gint64 user_action_time, - const gchar *preferred_handler, - DBusGMethodInvocation *context) -{ - dispatcher_request_channel (MCD_DISPATCHER (iface), - account_path, - requested_properties, - user_action_time, - preferred_handler, - NULL, - context, - TRUE); -} - -static void -dispatcher_create_channel_with_hints (TpSvcChannelDispatcher *iface, const gchar *account_path, GHashTable *requested_properties, gint64 user_action_time, @@ -1372,7 +1333,7 @@ dispatcher_create_channel_with_hints (TpSvcChannelDispatcher *iface, } static void -dispatcher_ensure_channel_with_hints (TpSvcChannelDispatcher *iface, +dispatcher_ensure_channel (TpSvcChannelDispatcher *iface, const gchar *account_path, GHashTable *requested_properties, gint64 user_action_time, @@ -2182,8 +2143,6 @@ dispatcher_iface_init (gpointer g_iface, g_iface, dispatcher_##x) IMPLEMENT (create_channel); IMPLEMENT (ensure_channel); - IMPLEMENT (create_channel_with_hints); - IMPLEMENT (ensure_channel_with_hints); IMPLEMENT (delegate_channels); IMPLEMENT (present_channel); #undef IMPLEMENT diff --git a/tests/twisted/account-manager/make-valid.py b/tests/twisted/account-manager/make-valid.py index 2f7c1f8..39980d2 100644 --- a/tests/twisted/account-manager/make-valid.py +++ b/tests/twisted/account-manager/make-valid.py @@ -121,6 +121,7 @@ def test(q, bus, unused, **kwargs): }, signature='sv') call_async(q, cd, 'CreateChannel', account_path, request, user_action_time, "", + dbus.Dictionary({}, signature='sv'), dbus_interface=cs.CD) ret = q.expect('dbus-return', method='CreateChannel') request_path = ret.value[0] diff --git a/tests/twisted/account-requests/cancel.py b/tests/twisted/account-requests/cancel.py index f236e5b..095580b 100644 --- a/tests/twisted/account-requests/cancel.py +++ b/tests/twisted/account-requests/cancel.py @@ -65,8 +65,9 @@ def test(q, bus, mc): cs.CHANNEL + '.TargetHandleType': cs.HT_CONTACT, cs.CHANNEL + '.TargetID': 'juliet', }, signature='sv') - request_path = cd.CreateChannel(account.object_path, request, - user_action_time, client.bus_name) + (request_path, immutable_props) = cd.CreateChannel(account.object_path, + request, user_action_time, client.bus_name, + dbus.Dictionary({}, signature='sv')) add_request = q.expect('dbus-method-call', handled=False, interface=cs.CLIENT_IFACE_REQUESTS, method='AddRequest', diff --git a/tests/twisted/account-requests/create-text.py b/tests/twisted/account-requests/create-text.py index e71aca9..179ac1f 100644 --- a/tests/twisted/account-requests/create-text.py +++ b/tests/twisted/account-requests/create-text.py @@ -24,8 +24,8 @@ a channel can be created successfully. import dbus import dbus.service -from servicetest import EventPattern, tp_name_prefix, tp_path_prefix, \ - call_async +from servicetest import (EventPattern, tp_name_prefix, tp_path_prefix, + call_async, assertEquals) from mctest import exec_test, SimulatedConnection, SimulatedClient, \ create_fakecm_account, enable_fakecm_account, SimulatedChannel, \ expect_client_setup, ChannelDispatcher @@ -71,12 +71,18 @@ def test_channel_creation(q, bus, account, client, conn, ensure): }, signature='sv') if ensure: - method = cd.EnsureChannel + method = 'EnsureChannel' else: - method = cd.CreateChannel - - request_path = method(account.object_path, request, - user_action_time, client.bus_name) + method = 'CreateChannel' + + call_async(q, cd, method, account.object_path, request, + user_action_time, client.bus_name, + dbus.Dictionary({}, signature='sv')) + e = q.expect('dbus-return', method=method) + (request_path, immutable_props) = e.value + assertEquals(account.object_path, immutable_props.get(cs.CR + '.Account')) + assertEquals([request], immutable_props.get(cs.CR + '.Requests')) + assertEquals(user_action_time, immutable_props.get(cs.CR + '.UserActionTime')) cr = bus.get_object(cs.CD, request_path) request_props = cr.GetAll(cs.CR, dbus_interface=cs.PROPERTIES_IFACE) diff --git a/tests/twisted/account-requests/delete-account-during-request.py b/tests/twisted/account-requests/delete-account-during-request.py index 348c45a..66a5f1b 100644 --- a/tests/twisted/account-requests/delete-account-during-request.py +++ b/tests/twisted/account-requests/delete-account-during-request.py @@ -24,8 +24,8 @@ an account is deleted while requesting a channel from that account. import dbus import dbus.service -from servicetest import EventPattern, tp_name_prefix, tp_path_prefix, \ - call_async +from servicetest import (EventPattern, tp_name_prefix, tp_path_prefix, + call_async, assertEquals) from mctest import exec_test, SimulatedConnection, SimulatedClient, \ create_fakecm_account, enable_fakecm_account, SimulatedChannel, \ expect_client_setup, ChannelDispatcher @@ -58,8 +58,14 @@ def test(q, bus, mc): cs.CHANNEL + '.TargetHandleType': cs.HT_CONTACT, cs.CHANNEL + '.TargetID': 'juliet', }, signature='sv') - request_path = cd.CreateChannel(account.object_path, request, - user_action_time, client.bus_name) + call_async(q, cd, 'CreateChannel', account.object_path, + request, user_action_time, client.bus_name, + dbus.Dictionary({}, signature='sv')) + e = q.expect('dbus-return', method='CreateChannel') + (request_path, immutable_props) = e.value + assertEquals(account.object_path, immutable_props.get(cs.CR + '.Account')) + assertEquals([request], immutable_props.get(cs.CR + '.Requests')) + assertEquals(user_action_time, immutable_props.get(cs.CR + '.UserActionTime')) add_request = q.expect('dbus-method-call', handled=False, interface=cs.CLIENT_IFACE_REQUESTS, method='AddRequest', diff --git a/tests/twisted/dispatcher/cancel.py b/tests/twisted/dispatcher/cancel.py index 5b8d90a..4866def 100644 --- a/tests/twisted/dispatcher/cancel.py +++ b/tests/twisted/dispatcher/cancel.py @@ -75,6 +75,7 @@ def test_channel_creation(q, bus, account, client, conn, }, signature='sv') call_async(q, cd, 'CreateChannel', account.object_path, request, user_action_time, client.bus_name, + dbus.Dictionary({}, signature='sv'), dbus_interface=cs.CD) ret = q.expect('dbus-return', method='CreateChannel') request_path = ret.value[0] diff --git a/tests/twisted/dispatcher/connect-for-request.py b/tests/twisted/dispatcher/connect-for-request.py index 6bb8e96..3c120bc 100644 --- a/tests/twisted/dispatcher/connect-for-request.py +++ b/tests/twisted/dispatcher/connect-for-request.py @@ -72,6 +72,7 @@ def test(q, bus, mc): }, signature='sv') call_async(q, cd, 'CreateChannel', account.object_path, request, user_action_time, "", + dbus.Dictionary({}, signature='sv'), dbus_interface=cs.CD) ret = q.expect('dbus-return', method='CreateChannel') request_path = ret.value[0] diff --git a/tests/twisted/dispatcher/create-at-startup.py b/tests/twisted/dispatcher/create-at-startup.py index 7537faa..58ef7b5 100644 --- a/tests/twisted/dispatcher/create-at-startup.py +++ b/tests/twisted/dispatcher/create-at-startup.py @@ -102,6 +102,7 @@ def test(q, bus, unused, **kwargs): }, signature='sv') call_async(q, cd, 'CreateChannel', account.object_path, request, user_action_time, client.bus_name, + dbus.Dictionary({}, signature='sv'), dbus_interface=cs.CD) ret = q.expect('dbus-return', method='CreateChannel') diff --git a/tests/twisted/dispatcher/create-delayed-by-mini-plugin.py b/tests/twisted/dispatcher/create-delayed-by-mini-plugin.py index 1c7c926..8ddd0be 100644 --- a/tests/twisted/dispatcher/create-delayed-by-mini-plugin.py +++ b/tests/twisted/dispatcher/create-delayed-by-mini-plugin.py @@ -120,6 +120,7 @@ def test(q, bus, mc): }, signature='sv') call_async(q, cd, 'CreateChannel', account.object_path, request, user_action_time, client.bus_name, + dbus.Dictionary({}, signature='sv'), dbus_interface=cs.CD) ret = q.expect('dbus-return', diff --git a/tests/twisted/dispatcher/create-handler-fails.py b/tests/twisted/dispatcher/create-handler-fails.py index ccdae2f..dea9cc8 100644 --- a/tests/twisted/dispatcher/create-handler-fails.py +++ b/tests/twisted/dispatcher/create-handler-fails.py @@ -73,6 +73,7 @@ def test_channel_creation(q, bus, account, client, conn, ensure): call_async(q, cd, (ensure and 'EnsureChannel' or 'CreateChannel'), account.object_path, request, user_action_time, client.bus_name, + dbus.Dictionary({}, signature='sv'), dbus_interface=cs.CD) ret = q.expect('dbus-return', method=(ensure and 'EnsureChannel' or 'CreateChannel')) diff --git a/tests/twisted/dispatcher/create-hints.py b/tests/twisted/dispatcher/create-hints.py index daf8cdc..ca1ae69 100644 --- a/tests/twisted/dispatcher/create-hints.py +++ b/tests/twisted/dispatcher/create-hints.py @@ -61,21 +61,21 @@ def test_channel_creation(q, bus, account, client, conn, prefer = client cd = ChannelDispatcher(bus) - assert cd.Properties.Get(cs.CD, "SupportsRequestHints") - # chat UI calls ChannelDispatcher.EnsureChannelWithHints or - # CreateChannelWithHints + # chat UI calls ChannelDispatcher.EnsureChannel or + # CreateChannel, with non-trivial "hints". This used + # to be a separate method in Telepathy 0.x. request = dbus.Dictionary({ cs.CHANNEL + '.ChannelType': channel_type, cs.CHANNEL + '.TargetHandleType': cs.HT_CONTACT, cs.CHANNEL + '.TargetID': 'juliet', }, signature='sv') call_async(q, cd, - (ensure and 'EnsureChannelWithHints' or 'CreateChannelWithHints'), + (ensure and 'EnsureChannel' or 'CreateChannel'), account.object_path, request, user_action_time, prefer.bus_name, hints, dbus_interface=cs.CD) ret = q.expect('dbus-return', - method=(ensure and 'EnsureChannelWithHints' or 'CreateChannelWithHints')) + method=(ensure and 'EnsureChannel' or 'CreateChannel')) request_path = ret.value[0] # chat UI connects to signals and calls ChannelRequest.Proceed() diff --git a/tests/twisted/dispatcher/create-no-preferred-handler.py b/tests/twisted/dispatcher/create-no-preferred-handler.py index 3e07841..0bf3703 100644 --- a/tests/twisted/dispatcher/create-no-preferred-handler.py +++ b/tests/twisted/dispatcher/create-no-preferred-handler.py @@ -79,6 +79,7 @@ def test_channel_creation(q, bus, account, client, conn, ensure): call_async(q, cd, (ensure and 'EnsureChannel' or 'CreateChannel'), account.object_path, request, user_action_time, "", + dbus.Dictionary({}, signature='sv'), dbus_interface=cs.CD) ret = q.expect('dbus-return', method=(ensure and 'EnsureChannel' or 'CreateChannel')) diff --git a/tests/twisted/dispatcher/create-rejected-by-mini-plugin.py b/tests/twisted/dispatcher/create-rejected-by-mini-plugin.py index 2f51758..4b05e87 100644 --- a/tests/twisted/dispatcher/create-rejected-by-mini-plugin.py +++ b/tests/twisted/dispatcher/create-rejected-by-mini-plugin.py @@ -75,6 +75,7 @@ def test(q, bus, mc): }, signature='sv') call_async(q, cd, 'CreateChannel', account.object_path, request, user_action_time, client.bus_name, + dbus.Dictionary({}, signature='sv'), dbus_interface=cs.CD) ret = q.expect('dbus-return', diff --git a/tests/twisted/dispatcher/create-text.py b/tests/twisted/dispatcher/create-text.py index a09ae98..6976e2a 100644 --- a/tests/twisted/dispatcher/create-text.py +++ b/tests/twisted/dispatcher/create-text.py @@ -92,6 +92,7 @@ def test_channel_creation(q, bus, account, client, conn, call_async(q, cd, (ensure and 'EnsureChannel' or 'CreateChannel'), account.object_path, request, user_action_time, prefer.bus_name, + dbus.Dictionary({}, signature='sv'), dbus_interface=cs.CD) ret = q.expect('dbus-return', method=(ensure and 'EnsureChannel' or 'CreateChannel')) diff --git a/tests/twisted/dispatcher/dispatch-delayed-by-mini-plugin.py b/tests/twisted/dispatcher/dispatch-delayed-by-mini-plugin.py index 48da4c1..b685078 100644 --- a/tests/twisted/dispatcher/dispatch-delayed-by-mini-plugin.py +++ b/tests/twisted/dispatcher/dispatch-delayed-by-mini-plugin.py @@ -277,7 +277,9 @@ def test(q, bus, mc): user_action_time = dbus.Int64(1238582606) call_async(q, cd, 'EnsureChannel', account.object_path, chan.immutable, user_action_time, - kopete.bus_name, dbus_interface=cs.CD) + kopete.bus_name, + dbus.Dictionary({}, signature='sv'), + dbus_interface=cs.CD) ret, add_request_call = q.expect_many( EventPattern('dbus-return', method='EnsureChannel'), EventPattern('dbus-method-call', handled=False, diff --git a/tests/twisted/dispatcher/ensure-and-redispatch.py b/tests/twisted/dispatcher/ensure-and-redispatch.py index 4d526c2..5b937d5 100644 --- a/tests/twisted/dispatcher/ensure-and-redispatch.py +++ b/tests/twisted/dispatcher/ensure-and-redispatch.py @@ -106,6 +106,7 @@ def test_channel_creation(q, bus, account, client, conn): }, signature='sv') call_async(q, cd, 'EnsureChannel', account.object_path, request, user_action_time, client.bus_name, + dbus.Dictionary({}, signature='sv'), dbus_interface=cs.CD) ret = q.expect('dbus-return', method='EnsureChannel') request_path = ret.value[0] @@ -238,6 +239,7 @@ def test_channel_redispatch(q, bus, account, client, conn, channel, }, signature='sv') call_async(q, cd, 'EnsureChannel', account.object_path, request, user_action_time, client.bus_name, + dbus.Dictionary({}, signature='sv'), dbus_interface=cs.CD) ret = q.expect('dbus-return', method='EnsureChannel') request_path = ret.value[0] diff --git a/tests/twisted/dispatcher/ensure-is-approval.py b/tests/twisted/dispatcher/ensure-is-approval.py index a2fb085..ed85f42 100644 --- a/tests/twisted/dispatcher/ensure-is-approval.py +++ b/tests/twisted/dispatcher/ensure-is-approval.py @@ -184,6 +184,7 @@ def test(q, bus, mc): }, signature='sv') call_async(q, cd, 'EnsureChannel', account.object_path, request, user_action_time, kopete.bus_name, + dbus.Dictionary({}, signature='sv'), dbus_interface=cs.CD) ret, add_request_call = q.expect_many( EventPattern('dbus-return', method='EnsureChannel'), diff --git a/tests/twisted/dispatcher/ensure-rapidly.py b/tests/twisted/dispatcher/ensure-rapidly.py index a338799..36f3477 100644 --- a/tests/twisted/dispatcher/ensure-rapidly.py +++ b/tests/twisted/dispatcher/ensure-rapidly.py @@ -80,6 +80,7 @@ def test_channel_creation(q, bus, account, client, conn, }, signature='sv') call_async(q, cd, 'EnsureChannel', account.object_path, request, user_action_time1, client.bus_name, + dbus.Dictionary({}, signature='sv'), dbus_interface=cs.CD) ret = q.expect('dbus-return', method='EnsureChannel') request_path = ret.value[0] @@ -110,6 +111,7 @@ def test_channel_creation(q, bus, account, client, conn, # the UI re-requests. call_async(q, cd, 'EnsureChannel', account.object_path, request, user_action_time2, client.bus_name, + dbus.Dictionary({}, signature='sv'), dbus_interface=cs.CD) ret = q.expect('dbus-return', method='EnsureChannel') request_path = ret.value[0] diff --git a/tests/twisted/dispatcher/fdo-21034.py b/tests/twisted/dispatcher/fdo-21034.py index 5a1ca3c..f26dcf9 100644 --- a/tests/twisted/dispatcher/fdo-21034.py +++ b/tests/twisted/dispatcher/fdo-21034.py @@ -61,6 +61,7 @@ def test(q, bus, mc): call_async(q, cd, 'CreateChannel', account.object_path, request, dbus.Int64(1234), 'grr.arg', # a valid bus name, but the wrong prefix + dbus.Dictionary({}, signature='sv'), dbus_interface=cs.CD) ret = q.expect('dbus-error', method='CreateChannel') assert ret.error.get_dbus_name() == cs.INVALID_ARGUMENT @@ -68,6 +69,7 @@ def test(q, bus, mc): call_async(q, cd, 'CreateChannel', account.object_path, request, dbus.Int64(1234), 'can has cheeseburger?', # a totally invalid bus name + dbus.Dictionary({}, signature='sv'), dbus_interface=cs.CD) ret = q.expect('dbus-error', method='CreateChannel') assert ret.error.get_dbus_name() == cs.INVALID_ARGUMENT diff --git a/tests/twisted/dispatcher/redispatch-channels.py b/tests/twisted/dispatcher/redispatch-channels.py index 6178a37..025f770 100644 --- a/tests/twisted/dispatcher/redispatch-channels.py +++ b/tests/twisted/dispatcher/redispatch-channels.py @@ -40,7 +40,8 @@ def test_ensure(q, bus, account, conn, chan, expected_handler_path): called on the current handler. (Previously, DelegateChannels() and PresentChannel() both broke this.)""" cd = ChannelDispatcher(bus) - call_async(q, cd, 'EnsureChannel', account.object_path, REQUEST, 0, '') + call_async(q, cd, 'EnsureChannel', account.object_path, REQUEST, 0, '', + dbus.Dictionary({}, signature='sv')) e = q.expect('dbus-return', method='EnsureChannel') cr = ChannelRequest(bus, e.value[0]) @@ -256,11 +257,11 @@ def test(q, bus, mc): expect_client_setup(q, [empathy]) # gnome-shell requests a channel for itself - call_async(q, cd, 'CreateChannelWithHints', + call_async(q, cd, 'CreateChannel', account.object_path, REQUEST, 0, cs.tp_name_prefix + '.Client.GnomeShell', {}) - e = q.expect('dbus-return', method='CreateChannelWithHints') + e = q.expect('dbus-return', method='CreateChannel') cr = ChannelRequest(bus, e.value[0]) cr.Proceed() diff --git a/tests/twisted/dispatcher/request-disabled-account.py b/tests/twisted/dispatcher/request-disabled-account.py index adb3ca2..52ae247 100644 --- a/tests/twisted/dispatcher/request-disabled-account.py +++ b/tests/twisted/dispatcher/request-disabled-account.py @@ -71,6 +71,7 @@ def test(q, bus, mc): }, signature='sv') call_async(q, cd, 'CreateChannel', account.object_path, request, user_action_time, "", + dbus.Dictionary({}, signature='sv'), dbus_interface=cs.CD) ret = q.expect('dbus-return', method='CreateChannel') request_path = ret.value[0] -- 1.8.4.rc3