kete: make Searcher and Listener symmetrical regarding logs

The 'searching' notification was only emitted when it goes to stop, which
means we do not get notifications when it starts.
This makes SearchStopped signal redundant for the generic case, but allows
to get notifications if the search failed to start.

Rest is just making sure we have the same handling of events in Listener
and Searcher.
This commit is contained in:
Benjamin Tissoires 2018-02-13 14:01:49 +01:00
parent d8808e144f
commit 590de68269
1 changed files with 8 additions and 3 deletions

View File

@ -346,6 +346,8 @@ class TuhiKeteManager(_DBusObject):
# in unregistered devices # in unregistered devices
pass pass
self.notify('devices') self.notify('devices')
if 'Searching' in changed_props:
self.notify('searching')
def _handle_unregistered_device(self, objpath): def _handle_unregistered_device(self, objpath):
for addr, dev in self._devices.items(): for addr, dev in self._devices.items():
@ -418,8 +420,8 @@ class Searcher(Worker):
logger.error('Another client is already searching') logger.error('Another client is already searching')
return return
logger.debug(f'Starting searching')
self.manager.start_search() self.manager.start_search()
logger.debug('Started searching')
def stop(self): def stop(self):
if self.manager.searching: if self.manager.searching:
@ -432,6 +434,8 @@ class Searcher(Worker):
if not manager.searching: if not manager.searching:
logger.info('Search cancelled') logger.info('Search cancelled')
self.stop() self.stop()
else:
logger.info('Search started')
def _on_unregistered_device(self, manager, device): def _on_unregistered_device(self, manager, device):
logger.info(f'Unregistered device: {device}') logger.info(f'Unregistered device: {device}')
@ -471,8 +475,9 @@ class Listener(Worker):
self.device.start_listening() self.device.start_listening()
def stop(self): def stop(self):
logger.debug(f'{self.device}: stopping listening') if self.device.listening:
self.device.stop_listening() logger.debug(f'{self.device}: stopping listening')
self.device.stop_listening()
self.cleanup() self.cleanup()