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
 
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
 
MediaPtr media () const
 
PendingCallregisterAgent (Agent *agent)
 
PendingCallregisterProfile (Profile *profile)
 
PendingCallrequestDefaultAgent (Agent *agent)
 
Rfkill * rfkill () const
 
bool setBluetoothBlocked (bool blocked)
 
PendingCallunregisterAgent (Agent *agent)
 
PendingCallunregisterProfile (Profile *profile)
 
AdapterPtr usableAdapter () const
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
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 ()
 
void dumpObjectInfo () const const
 
void dumpObjectTree ()
 
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 QRegExp &regExp, 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
 
bool inherits (const char *className) const const
 
void installEventFilter (QObject *filterObj)
 
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_DISABLE_COPY (Class)
 
 Q_DISABLE_COPY_MOVE (Class)
 
 Q_DISABLE_MOVE (Class)
 
 Q_EMIT Q_EMIT
 
 Q_ENUM (...)
 
 Q_ENUM_NS (...)
 
 Q_ENUMS (...)
 
 Q_FLAG (...)
 
 Q_FLAG_NS (...)
 
 Q_FLAGS (...)
 
 Q_GADGET Q_GADGET
 
 Q_INTERFACES (...)
 
 Q_INVOKABLE Q_INVOKABLE
 
 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
 
qFindChild (const QObject *obj, const QString &name)
 
QList< T > qFindChildren (const QObject *obj, const QRegExp &regExp)
 
QList< T > qFindChildren (const QObject *obj, const QString &name)
 
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 setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool signalsBlocked () const const
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds time, 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)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 

Additional Inherited Members

- Public Attributes 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:

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 2.2
import org.kde.bluezqt 1.0 as BluezQt
property QtObject 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

Definition at line 77 of file manager.h.

Constructor & Destructor Documentation

◆ Manager()

Manager::Manager ( QObject parent = nullptr)
explicit

Creates a new Manager object.

Parameters
parent

Definition at line 23 of file manager.cpp.

◆ ~Manager()

Manager::~Manager ( )
override

Destroys a Manager object.

Definition at line 30 of file manager.cpp.

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 96 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 106 of file manager.cpp.

◆ adapterRemoved

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

Indicates that adapter was removed.

◆ adapters()

QList<AdapterPtr> BluezQt::Manager::adapters ( ) const

Returns a list of all adapters.

Returns
list of adapters

◆ 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 111 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 132 of file manager.cpp.

◆ deviceRemoved

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

Indicates that a device was removed.

◆ devices()

QList<DevicePtr> BluezQt::Manager::devices ( ) const

Returns a list of all devices.

Returns
list of devices

◆ init()

InitManagerJob * Manager::init ( )

Creates a new init job.

Returns
init manager job

Definition at line 35 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 55 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 50 of file manager.cpp.

◆ isInitialized()

bool Manager::isInitialized ( ) const

Returns whether the manager is initialized.

Returns
true if manager is initialized

Definition at line 40 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 45 of file manager.cpp.

◆ media()

MediaPtr Manager::media ( ) const

Returns the media interface.

Returns
media
Deprecated:
since 5.57, use Adapter::media() instead.

Definition at line 231 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 137 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 198 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 187 of file manager.cpp.

◆ setBluetoothBlocked()

bool 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.
Returns
true if unblocking rfkill devices succeeded

Definition at line 60 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 84 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 174 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 217 of file manager.cpp.

◆ usableAdapter()

AdapterPtr BluezQt::Manager::usableAdapter ( ) const

Returns a usable adapter.

Usable adapter is any adapter that is currently powered on.

Returns
usable adapter

◆ 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:
void result(InitManagerJob *job)
Indicates that the job have finished.
Manager(QObject *parent=nullptr)
Creates a new Manager object.
Definition: manager.cpp:23
InitManagerJob * init()
Creates a new init job.
Definition: manager.cpp:35
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
void start()
Starts the job asynchronously.
Definition: job.cpp:38
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sun Nov 27 2022 04:09:33 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.