def inquiry(self): def prop_changed(lst, adapter, key_value): key, value = key_value if key == "Discovering" and not value: prog.finalize() self.List.disconnect_by_func(on_progress) self.List.disconnect_by_func(prop_changed) def on_progress(lst, frac): if abs(1.0 - frac) <= 0.00001: if not prog.started(): prog.start() else: prog.fraction(frac) prog = ManagerProgressbar(self, text=_("Searching")) prog.connect("cancelled", lambda x: self.List.stop_discovery()) try: self.List.discover_devices() except Exception as e: prog.finalize() MessageArea.show_message(*e_(e)) self.List.connect("discovery-progress", on_progress) self.List.connect("adapter-property-changed", prop_changed)
def fail(obj, result, _user_data): prog.message(_("Failed")) self.unset_op(device) logging.warning("fail %s" % result) msg, tb = e_(result.message) MessageArea.show_message(_("Connection Failed: ") + msg, tb)
def _handle_error_message(self, msg: str) -> None: msg = msg.split(":", 3)[-1].strip() # https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/gnu/errlist.h # https://git.musl-libc.org/cgit/musl/tree/src/errno/__strerror.h # https://git.uclibc.org/uClibc/tree/libc/string/_string_syserrmsgs.c if msg == "Protocol not available": # ENOPROTOOPT logging.warning( "No audio endpoints registered to bluetoothd. " "Pulseaudio Bluetooth module, bluez-alsa, PipeWire or other audio support missing." ) msg = _("No audio endpoints registered") elif msg in ("Input/output error", "I/O error"): # EIO logging.warning( "bluetoothd reported input/output error. Check its logs for context." ) msg = _("Input/output error") elif msg == "Host is down": # EHOSTDOWN (Bluetooth errors 0x04 (Page Timeout) or 0x3c (Advertising Timeout)) msg = _("Device did not respond") elif msg == "Resource temporarily unavailable": # EAGAIN logging.warning( "bluetoothd reported resource temporarily unavailable. " "Retry or check its logs for context.") msg = _("Resource temporarily unavailable") if msg != "Cancelled": MessageArea.show_message(_("Connection Failed: ") + msg)
def fail(*args): prog.message(_("Failed")) self.unset_op(device) dprint("fail", args) MessageArea.show_message( _("Connection Failed: ") + e_(str(args[0])))
def inquiry(self): def prop_changed(lst, adapter, key_value): key, value = key_value if key == "Discovering" and not value: prog.finalize() self.List.disconnect(s1) self.List.disconnect(s2) def on_progress(lst, frac): if abs(1.0 - frac) <= 0.00001: if not prog.started(): prog.start() else: prog.fraction(frac) prog = ManagerProgressbar(self, text=_("Searching")) prog.connect("cancelled", lambda x: self.List.stop_discovery()) try: self.List.discover_devices() except Exception as e: prog.finalize() MessageArea.show_message(*e_(e)) s1 = self.List.connect("discovery-progress", on_progress) s2 = self.List.connect("adapter-property-changed", prop_changed)
def fail(_obj: Optional[AppletService], result: GLib.Error, _user_data: None) -> None: prog.message(_("Failed")) self.unset_op(device) logging.warning(f"fail {result}") msg, tb = e_(result.message) MessageArea.show_message(_("Connection Failed: ") + msg, tb)
def success(obj, result, _user_data): logging.info("success") prog.message(_("Success!")) if isinstance(service, SerialPort) and SERIAL_PORT_SVCLASS_ID == service.short_uuid: MessageArea.show_message(_("Serial port connected to %s") % result, None, "dialog-information") else: MessageArea.close() self.unset_op(device)
def success(obj, result, _user_data): dprint("success") prog.message(_("Success!")) if isinstance(service, SerialPort) and SERIAL_PORT_SVCLASS_ID == uuid128_to_uuid16(service.uuid): MessageArea.show_message(_("Serial port connected to %s") % result, "dialog-information") else: MessageArea.close() self.unset_op(device)
def success(*args2): dprint("success", " ".join(args2)) prog.message(_("Success!")) if isinstance(service, SerialPort) and SERIAL_PORT_SVCLASS_ID == uuid128_to_uuid16(service.uuid): MessageArea.show_message(_("Serial port connected to %s") % args2[0], "dialog-information") else: MessageArea.close() self.unset_op(device)
def success(*args2): try: uuid16 = sdp_get_serial_type(device.Address, args[0]) except: uuid16 = 0 dprint("success", args2) prog.message(_("Success!")) if service_id == "serial" and SERIAL_PORT_SVCLASS_ID in uuid16: MessageArea.show_message(_("Serial port connected to %s") % args2[0], "dialog-information") else: MessageArea.close() self.unset_op(device)
def success(*args2): try: uuid16 = sdp_get_serial_type(device.Address, args[0]) except: uuid16 = 0 dprint("success", args2) prog.message(_("Success!")) if service_id == "serial" and SERIAL_PORT_SVCLASS_ID in uuid16: MessageArea.show_message( _("Serial port connected to %s") % args2[0], gtk.STOCK_DIALOG_INFO) else: MessageArea.close() self.unset_op(device)
def _handle_error_message(self, error: GLib.Error) -> None: err = self._get_errno(error) if err == errno.ENOPROTOOPT: logging.warning("No audio endpoints registered to bluetoothd. " "Pulseaudio Bluetooth module, bluez-alsa, PipeWire or other audio support missing.") msg = _("No audio endpoints registered") elif err == errno.EIO: logging.warning("bluetoothd reported input/output error. Check its logs for context.") msg = _("Input/output error") elif err == errno.EHOSTDOWN: msg = _("Device did not respond") elif err == errno.EAGAIN: logging.warning("bluetoothd reported resource temporarily unavailable. " "Retry or check its logs for context.") msg = _("Resource temporarily unavailable") else: msg = error.message.split(":", 3)[-1].strip() if msg != "Cancelled": MessageArea.show_message(_("Connection Failed: ") + msg)
def on_error(e: Exception) -> None: prog.finalize() MessageArea.show_message(*e_(e))
def on_result(res: int) -> None: if not res: MessageArea.show_message(_("Failed to change profile to %s" % profile))
def error(*args): dprint("err", args) prog_msg(_("Fail")) MessageArea.show_message(e_(str(args[0])))
def fail(obj, result, user_date): logging.info("fail", result) prog.message(_("Failed")) self.unset_op(device) msg, tb = e_(result.message) MessageArea.show_message(_("Connection Failed: ") + msg)
def err(obj, result, user_date): logging.warning("disconnect failed %s" % result) msg, tb = e_(result.message) MessageArea.show_message(_("Disconnection Failed: ") + msg, tb) self.Generate()
def fail(obj, result, _user_data): prog.message(_("Failed")) self.unset_op(device) dprint("fail", result) MessageArea.show_message(_("Connection Failed: ") + e_(str(result.message)))
def fail(*args): prog.message(_("Failed")) self.unset_op(device) dprint("fail", args) MessageArea.show_message(_("Connection Failed: ") + e_(str(args[0])))
def err(obj, result, user_date): logging.warning("disconnect failed %s" % result) msg, tb = e_(result.message) MessageArea.show_message(_("Disconnection Failed: ") + msg, tb) self.generate()
def err(_obj: Optional[AppletService], result: GLib.Error, _user_date: None) -> None: logging.warning(f"disconnect failed {result}") msg, tb = e_(result.message) MessageArea.show_message(_("Disconnection Failed: ") + msg, tb) self.generate()
def error(*args): self.unset_op(device) prog.message(_("Fail")) MessageArea.show_message(e_(str(args[0])))
def on_result(res): if not res: MessageArea.show_message(_("Failed to change profile to %s" % profile))