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 ()
 
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 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
 
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 (QObject *object)
 
qobject_cast (const 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 *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
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, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &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
Item {
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

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

Creates a new Manager object.

Parameters
parent

Definition at line 24 of file manager.cpp.

BluezQt::Manager::~Manager ( )

Destroys a Manager object.

Definition at line 31 of file manager.cpp.

Member Function Documentation

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

Indicates that adapter was added.

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

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

AdapterPtr BluezQt::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 97 of file manager.cpp.

AdapterPtr BluezQt::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 107 of file manager.cpp.

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

Indicates that adapter was removed.

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

Returns a list of all adapters.

Returns
list of adapters
void BluezQt::Manager::allAdaptersRemoved ( )
signal

Indicates that all adapters were removed.

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

Indicates that Bluetooth blocked state have changed.

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

Indicates that Bluetooth operational state have changed.

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

Indicates that a new device was added (eg.

found by discovery).

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

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

DevicePtr BluezQt::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 112 of file manager.cpp.

DevicePtr BluezQt::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 133 of file manager.cpp.

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

Indicates that a device was removed.

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

Returns a list of all devices.

Returns
list of devices
InitManagerJob * BluezQt::Manager::init ( )

Creates a new init job.

Returns
init manager job

Definition at line 36 of file manager.cpp.

bool BluezQt::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 56 of file manager.cpp.

bool BluezQt::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 51 of file manager.cpp.

bool BluezQt::Manager::isInitialized ( ) const

Returns whether the manager is initialized.

Returns
true if manager is initialized

Definition at line 41 of file manager.cpp.

bool BluezQt::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 46 of file manager.cpp.

MediaPtr BluezQt::Manager::media ( ) const

Returns the media interface.

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

Definition at line 232 of file manager.cpp.

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

Indicates that operational state have changed.

PendingCall * BluezQt::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 138 of file manager.cpp.

PendingCall * BluezQt::Manager::registerProfile ( Profile profile)

Registers profile.

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

Parameters
profileprofile to be registered
Returns
void pending call

Definition at line 199 of file manager.cpp.

PendingCall * BluezQt::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 188 of file manager.cpp.

bool BluezQt::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 61 of file manager.cpp.

PendingCall * BluezQt::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 85 of file manager.cpp.

PendingCall * BluezQt::Manager::unregisterAgent ( Agent agent)

Unregisters agent.

Possible errors: PendingCall::DoesNotExist

Parameters
agentagent to be unregistered
Returns
void pending call

Definition at line 175 of file manager.cpp.

PendingCall * BluezQt::Manager::unregisterProfile ( Profile profile)

Unregisters profile.

Possible errors: PendingCall::DoesNotExist

Parameters
profileprofile to be unregistered
Returns
void pending call

Definition at line 218 of file manager.cpp.

AdapterPtr BluezQt::Manager::usableAdapter ( ) const

Returns a usable adapter.

Usable adapter is any adapter that is currently powered on.

Returns
usable adapter
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-2021 The KDE developers.
Generated on Tue Oct 19 2021 22:50:47 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.