From 6a1c772cf6fb610716107c6bdfd1bd9d9e3daca1 Mon Sep 17 00:00:00 2001 From: Sergiotarxz Date: Thu, 14 Nov 2024 13:25:34 +0100 Subject: [PATCH] v1.0.14 Making non fatal if we cannot find cat-printers because of dbus limitations --- lib/Exd/Gui/PrinterConfigure.pm | 16 ++++++++++++---- me.sergiotarxz.Exd.metainfo.xml | 6 ++++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/lib/Exd/Gui/PrinterConfigure.pm b/lib/Exd/Gui/PrinterConfigure.pm index 8465695..32e41c7 100644 --- a/lib/Exd/Gui/PrinterConfigure.pm +++ b/lib/Exd/Gui/PrinterConfigure.pm @@ -28,7 +28,8 @@ has _window => ( is => 'rw' ); has _bluetooth_printers => ( is => 'rw', default => sub { [] } ); has _usb_printers => ( is => 'rw', default => sub { [] } ); has _cat_printers => ( is => 'rw', default => sub { [] } ); -has _stop_timeout => ( is => 'rw' ); +has _stop_timeout => ( is => 'rw' ); +has _show_cat_printer_experimental_error => ( is => 'rw' ); sub _build__select($self) { return IO::Select->new; @@ -143,8 +144,8 @@ sub _read_cat_printers($self) { use Data::Dumper; my $device_path = '/org/bluez/hci0'; $service->get_object( $device_path, 'org.bluez.Adapter1' )->StartDiscovery; - $service->get_object( $device_path, 'org.bluez.Adapter1' )->SetDiscoveryFilter( - { Transport => Net::DBus::dbus_string('le') } ); + $service->get_object( $device_path, 'org.bluez.Adapter1' ) + ->SetDiscoveryFilter( { Transport => Net::DBus::dbus_string('le') } ); my $items = $object->GetManagedObjects; $object->get_service->get_bus->get_connection->disconnect; @@ -205,7 +206,14 @@ sub start($self) { return 0 if $self->_stop_timeout; eval { $self->_read_usb_printers; - $self->_read_cat_printers; + eval { $self->_read_cat_printers; }; + if ($@) { + if ( !$self->_show_cat_printer_experimental_error ) { + warn "Unable to read Cat-Printers" + . " (Maybe you need bluez experimental): $@"; + } + $self->_show_cat_printer_experimental_error(1); + } $self->_read_bluetooth_printers; $self->_update_box; }; diff --git a/me.sergiotarxz.Exd.metainfo.xml b/me.sergiotarxz.Exd.metainfo.xml index b1f8478..4a24fb2 100644 --- a/me.sergiotarxz.Exd.metainfo.xml +++ b/me.sergiotarxz.Exd.metainfo.xml @@ -30,6 +30,12 @@ + + +

The required bluez API for Cat-Printers is not warranted to be there + because it is experimental in some versions, making non fatal the unability to find the API.

+
+

Make discount to show the previous price