BluezQt::Manager Class
class BluezQt::ManagerBluetooth manager. More...
Header: | #include <BluezQt/Manager> |
CMake: | find_package(KF6 REQUIRED COMPONENTS BluezQt) target_link_libraries(mytarget PRIVATE KF6::BluezQt) |
Inherits: | QObject |
Properties
|
|
Public Functions
Manager(QObject *parent = nullptr) | |
BluezQt::AdapterPtr | adapterForAddress(const QString &address) const |
BluezQt::AdapterPtr | adapterForUbi(const QString &ubi) const |
QList<BluezQt::AdapterPtr> | adapters() const |
BluezQt::DevicePtr | deviceForAddress(const QString &address) const |
BluezQt::DevicePtr | deviceForUbi(const QString &ubi) const |
QList<BluezQt::DevicePtr> | devices() const |
BluezQt::InitManagerJob * | init() |
bool | isBluetoothBlocked() const |
bool | isBluetoothOperational() const |
bool | isInitialized() const |
bool | isOperational() const |
BluezQt::PendingCall * | registerAgent(BluezQt::Agent *agent) |
BluezQt::PendingCall * | registerProfile(BluezQt::Profile *profile) |
BluezQt::PendingCall * | requestDefaultAgent(BluezQt::Agent *agent) |
BluezQt::Rfkill * | rfkill() const |
void | setBluetoothBlocked(bool blocked) |
BluezQt::PendingCall * | unregisterAgent(BluezQt::Agent *agent) |
BluezQt::PendingCall * | unregisterProfile(BluezQt::Profile *profile) |
BluezQt::AdapterPtr | usableAdapter() const |
Signals
void | adapterAdded(BluezQt::AdapterPtr adapter) |
void | adapterChanged(BluezQt::AdapterPtr adapter) |
void | adapterRemoved(BluezQt::AdapterPtr adapter) |
void | allAdaptersRemoved() |
void | bluetoothBlockedChanged(bool blocked) |
void | bluetoothOperationalChanged(bool operational) |
void | deviceAdded(BluezQt::DevicePtr device) |
void | deviceChanged(BluezQt::DevicePtr device) |
void | deviceRemoved(BluezQt::DevicePtr device) |
void | operationalChanged(bool operational) |
void | usableAdapterChanged(BluezQt::AdapterPtr adapter) |
Static Public Members
BluezQt::PendingCall * | startService() |
Detailed Description
The entry point to communicate with system BlueZ daemon.
The typical usecase is to work with usableAdapter() (any powered adapter), but it is also possible to use specific adapter.
You must call init() before other functions can be used.
The only functions that can be used before initialization are two rfkill-related functions: isBluetoothBlocked() and setBluetoothBlocked().
Example use in C++ code:
BluezQt::Manager *manager = new BluezQt::Manager(); BluezQt::InitManagerJob *job = manager->init(); job->start(); connect(job, &BluezQt::InitManagerJob::result, ...);
In QML, manager is a singleton and initialization is started when first using the manager. You don't need to track initialized state, just use property binding.
Example use in QML code:
import QtQuick import org.kde.bluezqt as BluezQt Item { readonly property BluezQt.Manager manager: BluezQt.Manager property devicesCount: manager.devices.length property adaptersCount: manager.adapters.length Component.onCompleted: { console.log("Manager operational:", manager.operational) } }
Note: All communication with BlueZ daemon happens asynchronously. Almost all methods returns PendingCall to help track the call progress and to check for any errors.
Note: If manager is not operational, all methods that returns a PendingCall will fail with PendingCall::InternalError.
See also InitManagerJob.
Property Documentation
[read-only]
adapters : const QList<AdapterPtr>
Access functions:
QList<BluezQt::AdapterPtr> | adapters() const |
bluetoothBlocked : bool
Access functions:
bool | isBluetoothBlocked() const |
void | setBluetoothBlocked(bool blocked) |
Notifier signal:
void | bluetoothBlockedChanged(bool blocked) |
[read-only]
bluetoothOperational : const bool
Access functions:
bool | isBluetoothOperational() const |
Notifier signal:
void | bluetoothOperationalChanged(bool operational) |
[read-only]
devices : const QList<DevicePtr>
Access functions:
QList<BluezQt::DevicePtr> | devices() const |
[read-only]
initialized : const bool
Access functions:
bool | isInitialized() const |
[read-only]
operational : const bool
Access functions:
bool | isOperational() const |
Notifier signal:
void | operationalChanged(bool operational) |
[read-only]
rfkill : BluezQt::Rfkill* const
Access functions:
BluezQt::Rfkill * | rfkill() const |
[read-only]
usableAdapter : const AdapterPtr
Access functions:
BluezQt::AdapterPtr | usableAdapter() const |
Notifier signal:
void | usableAdapterChanged(BluezQt::AdapterPtr adapter) |
Member Function Documentation
[explicit]
Manager::Manager(QObject *parent = nullptr)
Creates a new Manager object as a child of parent.
[signal]
void Manager::adapterAdded(BluezQt::AdapterPtr adapter)
Indicates that an adapter was added.
[signal]
void Manager::adapterChanged(BluezQt::AdapterPtr adapter)
Indicates that at least one of the adapter's properties has changed.
BluezQt::AdapterPtr Manager::adapterForAddress(const QString &address) const
Returns an adapter for the specified address.
address The address of adapter (eg. "1C:E5:C3:BC:94:7E").
BluezQt::AdapterPtr Manager::adapterForUbi(const QString &ubi) const
Returns an adapter for specified UBI.
ubi The UBI of adapter (eg. "/org/bluez/hci0")
[signal]
void Manager::adapterRemoved(BluezQt::AdapterPtr adapter)
Indicates that an adapter was removed.
QList<BluezQt::AdapterPtr> Manager::adapters() const
Returns a list of all adapters.
Note: Getter function for property adapters.
[signal]
void Manager::allAdaptersRemoved()
Indicates that all adapters were removed.
[signal]
void Manager::bluetoothBlockedChanged(bool blocked)
Indicates that Bluetooth blocked state has changed.
Note: Notifier signal for property bluetoothBlocked.
[signal]
void Manager::bluetoothOperationalChanged(bool operational)
Indicates that the Bluetooth operational state has changed.
Note: Notifier signal for property bluetoothOperational.
[signal]
void Manager::deviceAdded(BluezQt::DevicePtr device)
Indicates that a new device was added (found by discovery).
[signal]
void Manager::deviceChanged(BluezQt::DevicePtr device)
Indicates that at least one of the device's properties has changed.
BluezQt::DevicePtr Manager::deviceForAddress(const QString &address) const
Returns a device for the specified address.
Note: There may be more devices with the same address (same device in multiple adapters). In this case, the first found device will be returned while preferring powered adapters in search.
address The address of device (eg. "40:79:6A:0C:39:75")
BluezQt::DevicePtr Manager::deviceForUbi(const QString &ubi) const
Returns a device for specified UBI.
ubi The UBI of device (eg. "/org/bluez/hci0/dev_40_79_6A_0C_39_75")
[signal]
void Manager::deviceRemoved(BluezQt::DevicePtr device)
Indicates that a device was removed.
QList<BluezQt::DevicePtr> Manager::devices() const
Returns a list of all devices.
Note: Getter function for property devices.
BluezQt::InitManagerJob *Manager::init()
Creates a new init job.
bool Manager::isBluetoothBlocked() const
Returns whether Bluetooth is blocked.
Bluetooth is blocked if rfkill state for Bluetooth is either SOFT_BLOCKED or HARD_BLOCKED.
Note: This requires read access to /dev/rfkill.
Note: Getter function for property bluetoothBlocked.
bool Manager::isBluetoothOperational() const
Returns whether Bluetooth is operational.
Bluetooth is operational when manager is operational and there is a valid usable adapter.
Note: Getter function for property bluetoothOperational.
bool Manager::isInitialized() const
Returns whether the manager is initialized.
Note: Getter function for property initialized.
bool Manager::isOperational() const
Returns whether the manager is operational.
The manager is operational when initialization was successful and BlueZ system daemon is running.
Note: Getter function for property operational.
[signal]
void Manager::operationalChanged(bool operational)
Indicates that the operational state has changed.
Note: Notifier signal for property operational.
BluezQt::PendingCall *Manager::registerAgent(BluezQt::Agent *agent)
Registers an agent.
This agent will be used for for all actions triggered by the application. Eg. show a PIN code in pairing process.
Possible errors:
Returns void pending call.
BluezQt::PendingCall *Manager::registerProfile(BluezQt::Profile *profile)
Registers a profile.
Possible errors:
Returns void pending call.
BluezQt::PendingCall *Manager::requestDefaultAgent(BluezQt::Agent *agent)
Requests the default agent.
This requests to make the application agent the default agent.
Possible errors:
Returns void pending call.
BluezQt::Rfkill *Manager::rfkill() const
Note: Getter function for property rfkill.
void Manager::setBluetoothBlocked(bool blocked)
Sets a Bluetooth blocked state.
This may fail either due to insufficient permissions or because rfkill state is HARD_BLOCKED. In that case, this function returns false.
Note: This requires write access to /dev/rfkill.
Note: Setter function for property bluetoothBlocked.
See also isBluetoothBlocked().
[static]
BluezQt::PendingCall *Manager::startService()
Attempts to start org.bluez service by D-Bus activation.
Possible return values are 1 if the service was started, 2 if the service is already running or error if the service could not be started.
Returns quint32 pending call.
BluezQt::PendingCall *Manager::unregisterAgent(BluezQt::Agent *agent)
Unregisters an agent.
Possible errors:
Returns void pending call.
BluezQt::PendingCall *Manager::unregisterProfile(BluezQt::Profile *profile)
Unregisters a profile.
Possible errors:
Returns void pending call.
BluezQt::AdapterPtr Manager::usableAdapter() const
Returns a usable adapter.
A usable adapter is any adapter that is currently powered on.
Note: Getter function for property usableAdapter.
[signal]
void Manager::usableAdapterChanged(BluezQt::AdapterPtr adapter)
Indicates that a usable adapter has changed.
Note: Notifier signal for property usableAdapter.