diff --git a/plugins/UM3NetworkPrinting/src/Messages/LegacyDeviceNoLongerSupportedMessage.py b/plugins/UM3NetworkPrinting/src/Messages/LegacyDeviceNoLongerSupportedMessage.py index a26c65ba29..f4132dbcbc 100644 --- a/plugins/UM3NetworkPrinting/src/Messages/LegacyDeviceNoLongerSupportedMessage.py +++ b/plugins/UM3NetworkPrinting/src/Messages/LegacyDeviceNoLongerSupportedMessage.py @@ -7,14 +7,27 @@ from UM.Message import Message I18N_CATALOG = i18nCatalog("cura") -## Message shown when uploading a print job to a cluster is blocked because another upload is already in progress. +## Message shown when trying to connect to a legacy printer device. class LegacyDeviceNoLongerSupportedMessage(Message): + # Singleton used to prevent duplicate messages of this type at the same time. + __is_visible = False + def __init__(self) -> None: super().__init__( - text = I18N_CATALOG.i18nc("@info:status", "You are attempting to connect to a printer that is not " - "running Ultimaker Connect. Please update the printer to the " - "latest firmware."), - title = I18N_CATALOG.i18nc("@info:title", "Update your printer"), - lifetime = 10 + text = I18N_CATALOG.i18nc("@info:status", "You are attempting to connect to a printer that is not " + "running Ultimaker Connect. Please update the printer to the " + "latest firmware."), + title = I18N_CATALOG.i18nc("@info:title", "Update your printer"), + lifetime = 10 ) + + def show(self) -> None: + if LegacyDeviceNoLongerSupportedMessage.__is_visible: + return + super().show() + LegacyDeviceNoLongerSupportedMessage.__is_visible = True + + def hide(self, send_signal = True) -> None: + super().hide(send_signal) + LegacyDeviceNoLongerSupportedMessage.__is_visible = False diff --git a/plugins/UM3NetworkPrinting/src/Messages/NotClusterHostMessage.py b/plugins/UM3NetworkPrinting/src/Messages/NotClusterHostMessage.py new file mode 100644 index 0000000000..10c2f1c9b4 --- /dev/null +++ b/plugins/UM3NetworkPrinting/src/Messages/NotClusterHostMessage.py @@ -0,0 +1,33 @@ +# Copyright (c) 2019 Ultimaker B.V. +# Cura is released under the terms of the LGPLv3 or higher. +from UM import i18nCatalog +from UM.Message import Message + + +I18N_CATALOG = i18nCatalog("cura") + + +## Message shown when trying to connect to a printer that is not a host. +class NotClusterHostMessage(Message): + + # Singleton used to prevent duplicate messages of this type at the same time. + __is_visible = False + + def __init__(self) -> None: + super().__init__( + text = I18N_CATALOG.i18nc("@info:status", "You are attempting to connect to a printer that is not " + "the host of an Ultimaker Connect group. Please connect to " + "the host instead."), + title = I18N_CATALOG.i18nc("@info:title", "Not a cluster host"), + lifetime = 10 + ) + + def show(self) -> None: + if NotClusterHostMessage.__is_visible: + return + super().show() + NotClusterHostMessage.__is_visible = True + + def hide(self, send_signal = True) -> None: + super().hide(send_signal) + NotClusterHostMessage.__is_visible = False diff --git a/plugins/UM3NetworkPrinting/src/Network/LocalClusterOutputDeviceManager.py b/plugins/UM3NetworkPrinting/src/Network/LocalClusterOutputDeviceManager.py index 29f21847d6..b5f0c3bb4b 100644 --- a/plugins/UM3NetworkPrinting/src/Network/LocalClusterOutputDeviceManager.py +++ b/plugins/UM3NetworkPrinting/src/Network/LocalClusterOutputDeviceManager.py @@ -16,6 +16,7 @@ from .LocalClusterOutputDevice import LocalClusterOutputDevice from ..UltimakerNetworkedPrinterOutputDevice import UltimakerNetworkedPrinterOutputDevice from ..CloudFlowMessage import CloudFlowMessage from ..Messages.LegacyDeviceNoLongerSupportedMessage import LegacyDeviceNoLongerSupportedMessage +from ..Messages.NotClusterHostMessage import NotClusterHostMessage from ..Models.Http.PrinterSystemStatus import PrinterSystemStatus @@ -128,8 +129,6 @@ class LocalClusterOutputDeviceManager: ## Add a new device. def _onDeviceDiscovered(self, key: str, address: str, properties: Dict[bytes, bytes]) -> None: - cluster_size = int(properties.get(b"cluster_size", -1)) - firmware_version = Version(properties.get(b"firmware", "1.0.0")) machine_identifier = properties.get(b"machine", b"").decode("utf-8") printer_type_identifiers = self._getPrinterTypeIdentifiers() @@ -140,10 +139,6 @@ class LocalClusterOutputDeviceManager: properties[b"printer_type"] = bytes(p_type, encoding="utf8") break - # We no longer support legacy devices, prevent them from showing up in the discovered devices list. - if cluster_size == -1 or firmware_version < self.MIN_SUPPORTED_CLUSTER_VERSION: - return - device = LocalClusterOutputDevice(key, address, properties) CuraApplication.getInstance().getDiscoveredPrintersModel().addDiscoveredPrinter( ip_address=address, @@ -210,11 +205,16 @@ class LocalClusterOutputDeviceManager: ## Add a device to the current active machine. def _connectToOutputDevice(self, device: UltimakerNetworkedPrinterOutputDevice, machine: GlobalStack) -> None: - + # Make sure users know that we no longer support legacy devices. - if device.clusterSize < 1 or Version(device.firmwareVersion) < self.MIN_SUPPORTED_CLUSTER_VERSION: + if Version(device.firmwareVersion) < self.MIN_SUPPORTED_CLUSTER_VERSION: LegacyDeviceNoLongerSupportedMessage().show() return + + # Tell the user that they cannot connect to a non-host printer. + if device.clusterSize < 1: + NotClusterHostMessage().show() + return device.connect() machine.addConfiguredConnectionType(device.connectionType.value)