19350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley# Copyright 2015 The Chromium OS Authors. All rights reserved. 29350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley# Use of this source code is governed by a BSD-style license that can be 39350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley# found in the LICENSE file. 49350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley 59350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wileyimport collections 69350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wileyimport dbus 79350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wileyimport dbus.bus 89350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wileyimport dbus.service 99350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wileyimport logging 109350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wileyimport uuid 119350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley 129350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley 139350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wileyfrom autotest_lib.client.cros import dbus_util 149350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wileyfrom autotest_lib.client.cros.tendo import peerd_dbus_helper 159350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wileyfrom autotest_lib.client.cros.tendo.n_faced_peerd import dbus_property_exposer 169350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wileyfrom autotest_lib.client.cros.tendo.n_faced_peerd import peer 179350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wileyfrom autotest_lib.client.cros.tendo.n_faced_peerd import service 189350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley 199350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley# A tuple of a bus name that sent us an ExposeService message, and an 209350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley# object responsible for watching for the death of that bus name's 219350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley# DBus connection. 229350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher WileySenderWatch = collections.namedtuple('SenderWatch', ['sender', 'watch']) 239350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley 249350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley 259350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher WileyIGNORED_MONITORING_TOKEN_VALUE = 'This is a monitoring token.' 269350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wileyclass InvalidMonitoringTokenException(Exception): 279350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley """Self explanatory.""" 289350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley 299350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley 309350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wileyclass Manager(dbus_property_exposer.DBusPropertyExposer): 319350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley """Represents an instance of org.chromium.peerd.Manager.""" 329350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley 339350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley def __init__(self, bus, ip_address, on_service_modified, unique_name, 349350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley object_manager): 359350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley """Construct an instance of Manager. 369350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley 379350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley @param bus: dbus.Bus object to export this object on. 389350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley @param ip_address: string IP address (e.g. '127.0.01'). 39a54b420e231e36b64b6ac1f3947e90024445c9cbChristopher Wiley @param on_service_modified: callback that takes a Manager instance and 40a54b420e231e36b64b6ac1f3947e90024445c9cbChristopher Wiley a service ID. We'll call this whenever we Expose/Remove a 41a54b420e231e36b64b6ac1f3947e90024445c9cbChristopher Wiley service via the DBus API. 429350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley @param unique_name: string DBus well known name to claim on DBus. 439350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley @param object_manager: an instance of ObjectManager. 449350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley 459350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley """ 469350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley super(Manager, self).__init__(bus, 479350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley peerd_dbus_helper.DBUS_PATH_MANAGER, 489350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley peerd_dbus_helper.DBUS_INTERFACE_MANAGER) 499350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley self._bus = bus 509350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley self._object_manager = object_manager 519350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley self._peer_counter = 0 529350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley self._peers = dict() 539350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley self._ip_address = ip_address 549350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley self._on_service_modified = on_service_modified 559350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley # A map from service_ids to dbus.bus.NameOwnerWatch objects. 569350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley self._watches = dict() 579350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley self.self_peer = peer.Peer(self._bus, 589350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley peerd_dbus_helper.DBUS_PATH_SELF, 59a54b420e231e36b64b6ac1f3947e90024445c9cbChristopher Wiley uuid.uuid4(), 609350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley self._object_manager, 619350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley is_self=True) 629350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley # TODO(wiley) Expose monitored technologies property 639350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley self._object_manager.claim_interface( 649350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley peerd_dbus_helper.DBUS_PATH_MANAGER, 659350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley peerd_dbus_helper.DBUS_INTERFACE_MANAGER, 669350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley self.property_getter) 679350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley if (self._bus.request_name(unique_name) != 689350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley dbus.bus.REQUEST_NAME_REPLY_PRIMARY_OWNER): 699350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley raise Exception('Failed to claim name %s' % unique_name) 709350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley 719350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley 729350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley def _on_name_owner_changed(self, service_id, owner): 739350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley """Callback that removes a service when the owner disconnects from DBus. 749350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley 759350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley @param service_id: string service_id of service to remove. 769350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley @param owner: dbus.String identifier of service owner. 779350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley 789350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley """ 799350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley owner = dbus_util.dbus2primitive(owner) 809350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley logging.debug('Name owner for service=%s changed to "%s".', 819350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley service_id, owner) 829350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley if not owner: 839350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley self.RemoveExposedService(service_id) 849350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley 859350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley 869350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley def close(self): 879350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley """Release resources held by this object and child objects.""" 889350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley # TODO(wiley) call close on self and remote peers. 899350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley raise NotImplementedError('Manager.close() does not work properly') 909350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley 919350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley 929350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley def add_remote_peer(self, remote_peer): 939350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley """Add a remote peer to this object. 949350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley 959350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley For any given face of NFacedPeerd, the other N - 1 faces are treated 969350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley as "remote peers" that we instantly discover changes on. 979350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley 989350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley @param remote_peer: Peer object. Should be the |self_peer| of another 999350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley instance of Manager. 1009350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley 1019350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley """ 102a54b420e231e36b64b6ac1f3947e90024445c9cbChristopher Wiley logging.info('Adding remote peer %s', remote_peer.uuid) 1039350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley self._peer_counter += 1 1049350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley peer_path = '%s%d' % (peerd_dbus_helper.PEER_PATH_PREFIX, 1059350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley self._peer_counter) 1069350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley self._peers[remote_peer.uuid] = peer.Peer( 107a54b420e231e36b64b6ac1f3947e90024445c9cbChristopher Wiley self._bus, peer_path, remote_peer.uuid, self._object_manager) 1089350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley 1099350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley 1109350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley def on_remote_service_modified(self, remote_peer, service_id): 1119350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley """Cause this face to update its view of a remote peer. 1129350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley 1139350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley @param remote_peer: Peer object. Should be the |self_peer| of another 1149350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley instance of Manager. 1159350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley @param service_id: string service ID of remote service that has changed. 1169350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley Note that this service may have been removed. 1179350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley 1189350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley """ 1199350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley local_peer = self._peers[remote_peer.uuid] 1209350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley remote_service = remote_peer.services.get(service_id) 1219350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley if remote_service is not None: 122a54b420e231e36b64b6ac1f3947e90024445c9cbChristopher Wiley logging.info('Exposing remote service: %s', service_id) 1239350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley local_peer.update_service(remote_service.service_id, 1249350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley remote_service.service_info, 125a54b420e231e36b64b6ac1f3947e90024445c9cbChristopher Wiley remote_service.ip_info) 1269350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley else: 127a54b420e231e36b64b6ac1f3947e90024445c9cbChristopher Wiley logging.info('Removing remote service: %s', service_id) 1289350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley local_peer.remove_service(service_id) 1299350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley 1309350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley 1319350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley @dbus.service.method( 1329350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley dbus_interface=peerd_dbus_helper.DBUS_INTERFACE_MANAGER, 1339350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley in_signature='sa{ss}a{sv}', out_signature='', 1349350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley sender_keyword='sender') 1359350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley def ExposeService(self, service_id, service_info, options, sender=None): 1369350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley """Implementation of org.chromium.peerd.Manager.ExposeService(). 1379350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley 1389350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley @param service_id: see DBus API documentation. 1399350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley @param service_info: see DBus API documentation. 1409350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley @param options: see DBus API documentation. 1419350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley @param sender: string DBus connection ID of caller. Must match 1429350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley |sender_keyword| value in decorator. 1439350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley 1449350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley """ 1459350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley if (service_id in self._watches and 1469350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley sender != self._watches[service_id].sender): 147a54b420e231e36b64b6ac1f3947e90024445c9cbChristopher Wiley logging.error('Asked to advertise a duplicate service by %s. ' 148a54b420e231e36b64b6ac1f3947e90024445c9cbChristopher Wiley 'Expected %s.', 149a54b420e231e36b64b6ac1f3947e90024445c9cbChristopher Wiley sender, self._watches[service_id].sender) 1509350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley raise Exception('Will not advertise duplicate services.') 1519350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley logging.info('Exposing service %s', service_id) 1529350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley port = options.get('mdns', dict()).get('port', 0) 1539350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley self.self_peer.update_service( 1549350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley service_id, service_info, 1559350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley service.IpInfo(addr=self._ip_address, port=port)) 1569350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley if service_id not in self._watches: 1579350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley cb = lambda owner: self._on_name_owner_changed(service_id, owner) 1589350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley watch = dbus.bus.NameOwnerWatch(self._bus, sender, cb) 1599350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley self._watches[service_id] = SenderWatch(sender, watch) 160a54b420e231e36b64b6ac1f3947e90024445c9cbChristopher Wiley self._on_service_modified(self, service_id) 1619350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley 1629350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley 1639350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley @dbus.service.method( 1649350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley dbus_interface=peerd_dbus_helper.DBUS_INTERFACE_MANAGER, 1659350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley in_signature='s', out_signature='') 1669350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley def RemoveExposedService(self, service_id): 1679350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley """Implementation of org.chromium.peerd.Manager.RemoveExposedService(). 1689350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley 1699350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley @param service_id: see DBus API documentation. 1709350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley 1719350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley """ 1729350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley logging.info('Removing service %s', service_id) 1739350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley self._watches.pop(service_id, None) 1749350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley self.self_peer.remove_service(service_id) 175a54b420e231e36b64b6ac1f3947e90024445c9cbChristopher Wiley self._on_service_modified(self, service_id) 1769350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley 1779350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley 1789350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley @dbus.service.method( 1799350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley dbus_interface=peerd_dbus_helper.DBUS_INTERFACE_MANAGER, 1809350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley in_signature='asa{sv}', out_signature='s') 1819350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley def StartMonitoring(self, technologies, options): 1829350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley """Fake implementation of org.chromium.peerd.Manager.StartMonitoring(). 1839350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley 1849350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley We do not monitor anything in NFacedPeerd. 1859350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley 1869350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley @param technologies: See DBus API documentation. 1879350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley @param options: See DBus API documentation. 1889350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley 1899350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley """ 1909350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley return IGNORED_MONITORING_TOKEN_VALUE 1919350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley 1929350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley 1939350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley @dbus.service.method( 1949350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley dbus_interface=peerd_dbus_helper.DBUS_INTERFACE_MANAGER, 1959350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley in_signature='s', out_signature='') 1969350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley def StopMonitoring(self, monitoring_token): 1979350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley """Fake implementation of org.chromium.peerd.Manager.StopMonitoring(). 1989350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley 1999350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley We do not monitor anything in NFacedPeerd 2009350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley 2019350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley @param monitoring_token: See DBus API documentation. 2029350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley 2039350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley """ 2049350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley if monitoring_token != IGNORED_MONITORING_TOKEN_VALUE: 2059350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley raise InvalidMonitoringTokenException() 2069350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley 2079350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley 2089350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley @dbus.service.method( 2099350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley dbus_interface=peerd_dbus_helper.DBUS_INTERFACE_MANAGER, 2109350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley in_signature='', out_signature='s') 2119350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley def Ping(self): 2129350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley """Implementation of org.chromium.peerd.Manager.Ping().""" 2139350c4efd2c6a97c92b064d4d5cc4a73f8919bd0Christopher Wiley return 'Hello world!' 214