BluezQt::Manager

Search for usage in LXR

#include <BluezQt/Manager>

Inheritance diagram for BluezQt::Manager:

Properties

QList< AdapterPtradapters
 
bool bluetoothBlocked
 
bool bluetoothOperational
 
QList< DevicePtrdevices
 
bool initialized
 
bool operational
 
BluezQt::Rfkill * rfkill
 
AdapterPtr usableAdapter
 
- Properties inherited from QObject
 objectName
 

Signals

void adapterAdded (AdapterPtr adapter)
 
void adapterChanged (AdapterPtr adapter)
 
void adapterRemoved (AdapterPtr adapter)
 
void allAdaptersRemoved ()
 
void bluetoothBlockedChanged (bool blocked)
 
void bluetoothOperationalChanged (bool operational)
 
void deviceAdded (DevicePtr device)
 
void deviceChanged (DevicePtr device)
 
void deviceRemoved (DevicePtr device)
 
void operationalChanged (bool operational)
 
void usableAdapterChanged (AdapterPtr adapter)
 

Public Member Functions

 Manager (QObject *parent=nullptr)
 
 ~Manager () override
 
AdapterPtr adapterForAddress (const QString &address) const
 
AdapterPtr adapterForUbi (const QString &ubi) const
 
QList< AdapterPtradapters () const
 
DevicePtr deviceForAddress (const QString &address) const
 
DevicePtr deviceForUbi (const QString &ubi) const
 
QList< DevicePtrdevices () const
 
InitManagerJobinit ()
 
bool isBluetoothBlocked () const
 
bool isBluetoothOperational () const
 
bool isInitialized () const
 
bool isOperational () const
 
PendingCallregisterAgent (Agent *agent)
 
PendingCallregisterProfile (Profile *profile)
 
PendingCallrequestDefaultAgent (Agent *agent)
 
Rfkill * rfkill () const
 
void setBluetoothBlocked (bool blocked)
 
PendingCallunregisterAgent (Agent *agent)
 
PendingCallunregisterProfile (Profile *profile)
 
AdapterPtr usableAdapter () const
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
QBindable< QStringbindableObjectName ()
 
bool blockSignals (bool block)
 
const QObjectListchildren () const const
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectInfo () const const
 
void dumpObjectTree () const const
 
QList< QByteArraydynamicPropertyNames () const const
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (Qt::FindChildOptions options) const const
 
bool inherits (const char *className) const const
 
void installEventFilter (QObject *filterObj)
 
bool isQuickItemType () const const
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
void killTimer (int id)
 
virtual const QMetaObjectmetaObject () const const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const const
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
QVariant property (const char *name) const const
 
 Q_CLASSINFO (Name, Value)
 
 Q_EMIT Q_EMIT
 
 Q_ENUM (...)
 
 Q_ENUM_NS (...)
 
 Q_ENUMS (...)
 
 Q_FLAG (...)
 
 Q_FLAG_NS (...)
 
 Q_FLAGS (...)
 
 Q_GADGET Q_GADGET
 
 Q_GADGET_EXPORT (EXPORT_MACRO)
 
 Q_INTERFACES (...)
 
 Q_INVOKABLE Q_INVOKABLE
 
 Q_MOC_INCLUDE Q_MOC_INCLUDE
 
 Q_NAMESPACE Q_NAMESPACE
 
 Q_NAMESPACE_EXPORT (EXPORT_MACRO)
 
 Q_OBJECT Q_OBJECT
 
 Q_PROPERTY (...)
 
 Q_REVISION Q_REVISION
 
 Q_SET_OBJECT_NAME (Object)
 
 Q_SIGNAL Q_SIGNAL
 
 Q_SIGNALS Q_SIGNALS
 
 Q_SLOT Q_SLOT
 
 Q_SLOTS Q_SLOTS
 
qobject_cast (const QObject *object)
 
qobject_cast (QObject *object)
 
 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setObjectName (QAnyStringView name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool setProperty (const char *name, QVariant &&value)
 
bool signalsBlocked () const const
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds interval, Qt::TimerType timerType)
 
QThreadthread () const const
 

Static Public Member Functions

static PendingCallstartService ()
 
- Static Public Member Functions inherited from QObject
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 

Additional Inherited Members

- Public Types inherited from QObject
typedef  QObjectList
 
- Protected Member Functions inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
bool isSignalConnected (const QMetaMethod &signal) const const
 
int receivers (const char *signal) const const
 
QObjectsender () const const
 
int senderSignalIndex () const const
 
virtual void timerEvent (QTimerEvent *event)
 

Detailed Description

Bluetooth manager.

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::InitManagerJob *job = manager->init();
job->start();
Init manager job.
void result(InitManagerJob *job)
Indicates that the job have finished.
void start()
Starts the job asynchronously.
Definition job.cpp:35
Bluetooth manager.
InitManagerJob * init()
Creates a new init job.
Definition manager.cpp:34
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)

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.
If manager is not operational, all methods that returns a PendingCall will fail with PendingCall::InternalError.
See also
InitManagerJob

Property Documentation

◆ adapters

QList<AdapterPtr> BluezQt::Manager::adapters
read

Definition at line 88 of file manager.h.

◆ bluetoothBlocked

bool BluezQt::Manager::bluetoothBlocked
readwrite

Definition at line 86 of file manager.h.

◆ bluetoothOperational

bool BluezQt::Manager::bluetoothOperational
read

Definition at line 85 of file manager.h.

◆ devices

QList<DevicePtr> BluezQt::Manager::devices
read

Definition at line 89 of file manager.h.

◆ initialized

bool BluezQt::Manager::initialized
read

Definition at line 83 of file manager.h.

◆ operational

bool BluezQt::Manager::operational
read

Definition at line 84 of file manager.h.

◆ rfkill

BluezQt::Rfkill * BluezQt::Manager::rfkill
read

Definition at line 90 of file manager.h.

◆ usableAdapter

AdapterPtr BluezQt::Manager::usableAdapter
read

Definition at line 87 of file manager.h.

Constructor & Destructor Documentation

◆ Manager()

Manager::Manager ( QObject * parent = nullptr)
explicit

Creates a new Manager object.

Parameters
parent

Definition at line 25 of file manager.cpp.

◆ ~Manager()

Manager::~Manager ( )
overridedefault

Destroys a Manager object.

Member Function Documentation

◆ adapterAdded

void BluezQt::Manager::adapterAdded ( AdapterPtr adapter)
signal

Indicates that adapter was added.

◆ adapterChanged

void BluezQt::Manager::adapterChanged ( AdapterPtr adapter)
signal

Indicates that at least one of the adapter's properties have changed.

◆ adapterForAddress()

AdapterPtr Manager::adapterForAddress ( const QString & address) const

Returns an adapter for specified address.

Parameters
addressaddress of adapter (eg. "1C:E5:C3:BC:94:7E")
Returns
null if there is no adapter with specified address

Definition at line 95 of file manager.cpp.

◆ adapterForUbi()

AdapterPtr Manager::adapterForUbi ( const QString & ubi) const

Returns an adapter for specified UBI.

Parameters
ubiUBI of adapter (eg. "/org/bluez/hci0")
Returns
null if there is no adapter with specified UBI

Definition at line 105 of file manager.cpp.

◆ adapterRemoved

void BluezQt::Manager::adapterRemoved ( AdapterPtr adapter)
signal

Indicates that adapter was removed.

◆ adapters()

QList< AdapterPtr > Manager::adapters ( ) const

Returns a list of all adapters.

Returns
list of adapters

Definition at line 73 of file manager.cpp.

◆ allAdaptersRemoved

void BluezQt::Manager::allAdaptersRemoved ( )
signal

Indicates that all adapters were removed.

◆ bluetoothBlockedChanged

void BluezQt::Manager::bluetoothBlockedChanged ( bool blocked)
signal

Indicates that Bluetooth blocked state have changed.

◆ bluetoothOperationalChanged

void BluezQt::Manager::bluetoothOperationalChanged ( bool operational)
signal

Indicates that Bluetooth operational state have changed.

◆ deviceAdded

void BluezQt::Manager::deviceAdded ( DevicePtr device)
signal

Indicates that a new device was added (eg.

found by discovery).

◆ deviceChanged

void BluezQt::Manager::deviceChanged ( DevicePtr device)
signal

Indicates that at least one of the device's properties have changed.

◆ deviceForAddress()

DevicePtr Manager::deviceForAddress ( const QString & address) const

Returns a device for 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.
Parameters
addressaddress of device (eg. "40:79:6A:0C:39:75")
Returns
null if there is no device with specified address

Definition at line 110 of file manager.cpp.

◆ deviceForUbi()

DevicePtr Manager::deviceForUbi ( const QString & ubi) const

Returns a device for specified UBI.

Parameters
ubiUBI of device (eg. "/org/bluez/hci0/dev_40_79_6A_0C_39_75")
Returns
null if there is no device with specified UBI

Definition at line 131 of file manager.cpp.

◆ deviceRemoved

void BluezQt::Manager::deviceRemoved ( DevicePtr device)
signal

Indicates that a device was removed.

◆ devices()

QList< DevicePtr > Manager::devices ( ) const

Returns a list of all devices.

Returns
list of devices

Definition at line 78 of file manager.cpp.

◆ init()

InitManagerJob * Manager::init ( )

Creates a new init job.

Returns
init manager job

Definition at line 34 of file manager.cpp.

◆ isBluetoothBlocked()

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.
Returns
true if Bluetooth is blocked

Definition at line 54 of file manager.cpp.

◆ isBluetoothOperational()

bool Manager::isBluetoothOperational ( ) const

Returns whether Bluetooth is operational.

Bluetooth is operational when manager is operational and there is a valid usable adapter.

Returns
true if Bluetooth is operational

Definition at line 49 of file manager.cpp.

◆ isInitialized()

bool Manager::isInitialized ( ) const

Returns whether the manager is initialized.

Returns
true if manager is initialized

Definition at line 39 of file manager.cpp.

◆ isOperational()

bool Manager::isOperational ( ) const

Returns whether the manager is operational.

The manager is operational when initialization was successful and BlueZ system daemon is running.

Returns
true if manager is operational

Definition at line 44 of file manager.cpp.

◆ operationalChanged

void BluezQt::Manager::operationalChanged ( bool operational)
signal

Indicates that operational state have changed.

◆ registerAgent()

PendingCall * Manager::registerAgent ( Agent * agent)

Registers agent.

This agent will be used for for all actions triggered by the application. Eg. show a PIN code in pairing process.

Possible errors: PendingCall::InvalidArguments, PendingCall::AlreadyExists

Parameters
agentagent to be registered
Returns
void pending call

Definition at line 136 of file manager.cpp.

◆ registerProfile()

PendingCall * Manager::registerProfile ( Profile * profile)

Registers profile.

Possible errors: PendingCall::InvalidArguments, PendingCall::AlreadyExists

Parameters
profileprofile to be registered
Returns
void pending call

Definition at line 197 of file manager.cpp.

◆ requestDefaultAgent()

PendingCall * Manager::requestDefaultAgent ( Agent * agent)

Requests default agent.

This requests to make the application agent the default agent.

Possible errors: PendingCall::DoesNotExist

Parameters
agentregistered agent
Returns
void pending call

Definition at line 186 of file manager.cpp.

◆ rfkill()

Rfkill * Manager::rfkill ( ) const

Definition at line 229 of file manager.cpp.

◆ setBluetoothBlocked()

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.

Definition at line 59 of file manager.cpp.

◆ startService()

PendingCall * Manager::startService ( )
static

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

Definition at line 83 of file manager.cpp.

◆ unregisterAgent()

PendingCall * Manager::unregisterAgent ( Agent * agent)

Unregisters agent.

Possible errors: PendingCall::DoesNotExist

Parameters
agentagent to be unregistered
Returns
void pending call

Definition at line 173 of file manager.cpp.

◆ unregisterProfile()

PendingCall * Manager::unregisterProfile ( Profile * profile)

Unregisters profile.

Possible errors: PendingCall::DoesNotExist

Parameters
profileprofile to be unregistered
Returns
void pending call

Definition at line 216 of file manager.cpp.

◆ usableAdapter()

AdapterPtr Manager::usableAdapter ( ) const

Returns a usable adapter.

Usable adapter is any adapter that is currently powered on.

Returns
usable adapter

Definition at line 68 of file manager.cpp.

◆ usableAdapterChanged

void BluezQt::Manager::usableAdapterChanged ( AdapterPtr adapter)
signal

Indicates that usable adapter have changed.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:08:46 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.