Example #1
0
 def _on_interface_removed(self, _object_manager: Gio.DBusObjectManager,
                           dbus_object: Gio.DBusObject,
                           _dbus_interface: Gio.DBusInterface) -> None:
     object_path = dbus_object.get_object_path()
     battery = dbus_object.get_interface("org.bluez.Battery1")
     if battery is not None:
         logging.debug(f"Battery1 removed from {object_path}")
         self.emit('battery-removed', object_path)
Example #2
0
    def _on_object_removed(self, _object_manager: Gio.DBusObjectManager, dbus_object: Gio.DBusObject) -> None:
        device_proxy = dbus_object.get_interface('org.bluez.Device1')
        adapter_proxy = dbus_object.get_interface('org.bluez.Adapter1')

        if adapter_proxy:
            object_path = adapter_proxy.get_object_path()
            logging.debug(object_path)
            self.emit('adapter-removed', object_path)
        elif device_proxy:
            object_path = device_proxy.get_object_path()
            logging.debug(object_path)
            self.emit('device-removed', object_path)
Example #3
0
    def _on_object_added(self, _object_manager: Gio.DBusObjectManager, dbus_object: Gio.DBusObject) -> None:
        device_proxy = dbus_object.get_interface('org.bluez.Device1')
        adapter_proxy = dbus_object.get_interface('org.bluez.Adapter1')

        if adapter_proxy:
            assert isinstance(adapter_proxy, Gio.DBusProxy)
            object_path = adapter_proxy.get_object_path()
            logging.debug(object_path)
            self.emit('adapter-added', object_path)
        elif device_proxy:
            assert isinstance(device_proxy, Gio.DBusProxy)
            object_path = device_proxy.get_object_path()
            logging.debug(object_path)
            self.emit('device-created', object_path)
Example #4
0
    def _on_object_removed(self, _object_manager: Gio.DBusObjectManager,
                           dbus_object: Gio.DBusObject) -> None:
        session_proxy = dbus_object.get_interface('org.bluez.obex.Session1')
        transfer_proxy = dbus_object.get_interface('org.bluez.obex.Transfer1')
        object_path = dbus_object.get_object_path()

        if transfer_proxy and object_path in self.__transfers:
            logging.info(object_path)
            transfer, handlerids = self.__transfers.pop(object_path)

            for handlerid in handlerids:
                transfer.disconnect_signal(handlerid)

        if session_proxy:
            logging.info(object_path)
            self.emit('session-removed', object_path)
Example #5
0
    def _on_object_removed(self, _object_manager: Gio.DBusObjectManager,
                           dbus_object: Gio.DBusObject) -> None:
        session_proxy = dbus_object.get_interface('org.bluez.obex.Session1')
        transfer_proxy = dbus_object.get_interface('org.bluez.obex.Transfer1')
        object_path = dbus_object.get_object_path()

        if transfer_proxy and object_path in self.__transfers:
            logging.info(object_path)
            transfer = self.__transfers.pop(object_path)

            transfer.disconnect_by_func(self._on_transfer_completed, True)
            transfer.disconnect_by_func(self._on_transfer_completed, False)

        if session_proxy:
            logging.info(object_path)
            self.emit('session-removed', object_path)
Example #6
0
    def _on_object_added(self, _object_manager: Gio.DBusObjectManager,
                         dbus_object: Gio.DBusObject) -> None:
        session_proxy = dbus_object.get_interface('org.bluez.obex.Session1')
        transfer_proxy = dbus_object.get_interface('org.bluez.obex.Transfer1')
        object_path = dbus_object.get_object_path()

        if transfer_proxy:
            logging.info(object_path)
            transfer = Transfer(object_path)
            transfer.connect_signal('completed', self._on_transfer_completed,
                                    True)
            transfer.connect_signal('error', self._on_transfer_completed,
                                    False)
            self.__transfers[object_path] = transfer
            self.emit('transfer-started', object_path)

        if session_proxy:
            logging.info(object_path)
            self.emit('session-added', object_path)