Fix refresh button functionality for network printing

This commit is contained in:
ChrisTerBeke 2019-08-09 09:24:32 +02:00
parent 5bdef34121
commit 11ef53905b
2 changed files with 11 additions and 3 deletions

View file

@ -57,10 +57,14 @@ class LocalClusterOutputDeviceManager:
## Stop network discovery and clean up discovered devices. ## Stop network discovery and clean up discovered devices.
def stop(self) -> None: def stop(self) -> None:
self._zero_conf_client.stop() self._zero_conf_client.stop()
# Cleanup all manual devices.
for instance_name in list(self._discovered_devices): for instance_name in list(self._discovered_devices):
self._onDiscoveredDeviceRemoved(instance_name) self._onDiscoveredDeviceRemoved(instance_name)
## Restart discovery on the local network.
def startDiscovery(self):
self.stop()
self.start()
## Add a networked printer manually by address. ## Add a networked printer manually by address.
def addManualDevice(self, address: str, callback: Optional[Callable[[bool, str], None]] = None) -> None: def addManualDevice(self, address: str, callback: Optional[Callable[[bool, str], None]] = None) -> None:
api_client = ClusterApiClient(address, lambda error: print(error)) api_client = ClusterApiClient(address, lambda error: print(error))

View file

@ -37,6 +37,10 @@ class UM3OutputDevicePlugin(OutputDevicePlugin):
self._network_output_device_manager.stop() self._network_output_device_manager.stop()
self._cloud_output_device_manager.stop() self._cloud_output_device_manager.stop()
## Restart network discovery.
def startDiscovery(self) -> None:
self._network_output_device_manager.startDiscovery()
## Force refreshing the network connections. ## Force refreshing the network connections.
def refreshConnections(self) -> None: def refreshConnections(self) -> None:
self._network_output_device_manager.refreshConnections() self._network_output_device_manager.refreshConnections()