diff --git a/CMakeLists.txt b/CMakeLists.txt index 10a59aa..189b91a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,111 +1,113 @@ cmake_minimum_required(VERSION 3.5) set(KF5_VERSION "5.64.0") # handled by release scripts project(BluezQt VERSION ${KF5_VERSION}) include(FeatureSummary) find_package(ECM 5.63.0 NO_MODULE) set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://projects.kde.org/projects/kdesupport/extra-cmake-modules") feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH}) include(KDEInstallDirs) include(KDECMakeSettings) include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE) include(FeatureSummary) -include(GenerateExportHeader) +include(ECMGenerateExportHeader) include(ECMSetupVersion) include(ECMGenerateHeaders) include(ECMAddQch) include(CMakePackageConfigHelpers) include(ECMQtDeclareLoggingCategory) +set(EXCLUDE_DEPRECATED_BEFORE_AND_AT 0 CACHE STRING "Control the range of deprecated API excluded from the build [default=0].") + option(BUILD_QCH "Build API documentation in QCH format (for e.g. Qt Assistant, Qt Creator & KDevelop)" OFF) add_feature_info(QCH ${BUILD_QCH} "API documentation in QCH format (for e.g. Qt Assistant, Qt Creator & KDevelop)") ecm_setup_version(PROJECT VARIABLE_PREFIX BLUEZQT VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/bluezqt_version.h" PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/KF5BluezQtConfigVersion.cmake" SOVERSION 6 ) # Dependencies set(REQUIRED_QT_VERSION 5.11.0) # Required Qt5 components to build this framework find_package(Qt5 ${REQUIRED_QT_VERSION} CONFIG REQUIRED Core DBus Network) # Optional Qt5 components to build this framework find_package(Qt5Test ${REQUIRED_QT_VERSION} CONFIG) set_package_properties(Qt5Test PROPERTIES DESCRIPTION "Autotests for BluezQt" TYPE OPTIONAL) find_package(Qt5Qml ${REQUIRED_QT_VERSION} CONFIG) set_package_properties(Qt5Qml PROPERTIES DESCRIPTION "QML support for BluezQt" TYPE OPTIONAL) find_package(Qt5QuickTest ${REQUIRED_QT_VERSION} CONFIG) set_package_properties(Qt5QuickTest PROPERTIES DESCRIPTION "QML autotests for BluezQt" TYPE OPTIONAL) add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x050d00) add_definitions(-DQT_NO_FOREACH) # Subdirectories add_subdirectory(src) add_subdirectory(tools/bluezapi2qt) if (BUILD_TESTING) add_subdirectory(tests) if(Qt5Test_FOUND) add_subdirectory(autotests) endif() endif() if(Qt5Qml_FOUND) add_subdirectory(src/imports) endif() # Create a Config.cmake and a ConfigVersion.cmake file and install them set(CMAKECONFIG_INSTALL_DIR "${CMAKECONFIG_INSTALL_PREFIX}/KF5BluezQt") if (BUILD_QCH) ecm_install_qch_export( TARGETS KF5BluezQt_QCH FILE KF5BluezQtQchTargets.cmake DESTINATION "${CMAKECONFIG_INSTALL_DIR}" COMPONENT Devel ) set(PACKAGE_INCLUDE_QCHTARGETS "include(\"\${CMAKE_CURRENT_LIST_DIR}/KF5BluezQtQchTargets.cmake\")") endif() configure_package_config_file( "${CMAKE_CURRENT_SOURCE_DIR}/KF5BluezQtConfig.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/KF5BluezQtConfig.cmake" INSTALL_DESTINATION "${CMAKECONFIG_INSTALL_DIR}" ) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/KF5BluezQtConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/KF5BluezQtConfigVersion.cmake" DESTINATION "${CMAKECONFIG_INSTALL_DIR}" COMPONENT Devel) install(EXPORT KF5BluezQtTargets DESTINATION "${CMAKECONFIG_INSTALL_DIR}" FILE KF5BluezQtTargets.cmake NAMESPACE KF5::) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/bluezqt_version.h DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5} COMPONENT Devel) if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") set(INSTALL_UDEV_RULE ON CACHE BOOL "Whether to install udev rule") set(UDEV_RULES_INSTALL_DIR /lib/udev/rules.d CACHE PATH "The location of udev rules") if(${INSTALL_UDEV_RULE}) install(FILES 61-kde-bluetooth-rfkill.rules DESTINATION ${UDEV_RULES_INSTALL_DIR}) endif() endif() install(FILES bluez.categories DESTINATION ${KDE_INSTALL_LOGGINGCATEGORIESDIR}) feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3391728..61a4332 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,193 +1,200 @@ set(bluezqt_SRCS a2dp-codecs.c manager.cpp manager_p.cpp adapter.cpp adapter_p.cpp device.cpp device_p.cpp gattapplication.cpp gattapplication_p.cpp gattcharacteristic.cpp gattcharacteristic_p.cpp gattcharacteristicadaptor.cpp gattmanager.cpp gattmanager_p.cpp gattservice.cpp gattservice_p.cpp gattserviceadaptor.cpp input.cpp leadvertisement.cpp leadvertisement_p.cpp leadvertisementadaptor.cpp leadvertisingmanager.cpp media.cpp mediaendpoint.cpp mediaendpoint_p.cpp mediaendpointadaptor.cpp mediaplayer.cpp mediaplayer_p.cpp mediaplayertrack.cpp mediatransport.cpp mediatransport_p.cpp objectmanageradaptor.cpp devicesmodel.cpp job.cpp initmanagerjob.cpp initobexmanagerjob.cpp utils.cpp agent.cpp agentadaptor.cpp profile.cpp profileadaptor.cpp pendingcall.cpp request.cpp rfkill.cpp obexmanager.cpp obexmanager_p.cpp obexagent.cpp obexagentadaptor.cpp obextransfer.cpp obexsession.cpp obexobjectpush.cpp obexfiletransfer.cpp obexfiletransferentry.cpp ) ecm_qt_declare_logging_category(bluezqt_SRCS HEADER debug.h IDENTIFIER BLUEZQT CATEGORY_NAME org.kde.bluez) set(dbusobjectmanager_xml ${CMAKE_CURRENT_SOURCE_DIR}/interfaces/org.freedesktop.DBus.ObjectManager.xml) set_source_files_properties(${dbusobjectmanager_xml} PROPERTIES INCLUDE "bluezqt_dbustypes.h") qt5_add_dbus_interface(bluezqt_SRCS ${dbusobjectmanager_xml} dbusobjectmanager) set(obexfiletransfer1_xml ${CMAKE_CURRENT_SOURCE_DIR}/interfaces/org.bluez.obex.FileTransfer1.xml) set_source_files_properties(${obexfiletransfer1_xml} PROPERTIES INCLUDE "bluezqt_dbustypes.h") qt5_add_dbus_interface(bluezqt_SRCS ${obexfiletransfer1_xml} obexfiletransfer1) qt5_add_dbus_interface(bluezqt_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/interfaces/org.freedesktop.DBus.Properties.xml dbusproperties) qt5_add_dbus_interface(bluezqt_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/interfaces/org.bluez.Adapter1.xml bluezadapter1) qt5_add_dbus_interface(bluezqt_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/interfaces/org.bluez.AgentManager1.xml bluezagentmanager1) qt5_add_dbus_interface(bluezqt_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/interfaces/org.bluez.GattCharacteristic1.xml bluezgattcharacteristic1) qt5_add_dbus_interface(bluezqt_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/interfaces/org.bluez.GattManager1.xml bluezgattmanager1) qt5_add_dbus_interface(bluezqt_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/interfaces/org.bluez.ProfileManager1.xml bluezprofilemanager1) qt5_add_dbus_interface(bluezqt_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/interfaces/org.bluez.Device1.xml bluezdevice1) qt5_add_dbus_interface(bluezqt_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/interfaces/org.bluez.LEAdvertisement1.xml bluezleadvertisement1) qt5_add_dbus_interface(bluezqt_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/interfaces/org.bluez.LEAdvertisingManager1.xml bluezleadvertisingmanager1) qt5_add_dbus_interface(bluezqt_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/interfaces/org.bluez.Media1.xml bluezmedia1) qt5_add_dbus_interface(bluezqt_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/interfaces/org.bluez.MediaEndpoint1.xml bluezmediaendpoint1) qt5_add_dbus_interface(bluezqt_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/interfaces/org.bluez.MediaPlayer1.xml bluezmediaplayer1) qt5_add_dbus_interface(bluezqt_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/interfaces/org.bluez.obex.AgentManager1.xml obexagentmanager1) qt5_add_dbus_interface(bluezqt_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/interfaces/org.bluez.obex.Client1.xml obexclient1) qt5_add_dbus_interface(bluezqt_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/interfaces/org.bluez.obex.Transfer1.xml obextransfer1) qt5_add_dbus_interface(bluezqt_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/interfaces/org.bluez.obex.Session1.xml obexsession1) qt5_add_dbus_interface(bluezqt_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/interfaces/org.bluez.obex.ObjectPush1.xml obexobjectpush1) add_library(KF5BluezQt ${bluezqt_SRCS}) -generate_export_header(KF5BluezQt BASE_NAME BluezQt) add_library(KF5::BluezQt ALIAS KF5BluezQt) +ecm_generate_export_header(KF5BluezQt + BASE_NAME BluezQt + # GROUP_BASE_NAME KF <- enable once all of KF modules use ecm_generate_export_header + VERSION ${KF5_VERSION} + DEPRECATED_BASE_VERSION 0 + DEPRECATION_VERSIONS 5.57 + EXCLUDE_DEPRECATED_BEFORE_AND_AT ${EXCLUDE_DEPRECATED_BEFORE_AND_AT} +) target_include_directories(KF5BluezQt INTERFACE "$") target_link_libraries(KF5BluezQt PUBLIC Qt5::Core PRIVATE Qt5::DBus Qt5::Network ) set_target_properties(KF5BluezQt PROPERTIES VERSION ${BLUEZQT_VERSION_STRING} SOVERSION ${BLUEZQT_SOVERSION} EXPORT_NAME "BluezQt" ) ecm_generate_headers(BluezQt_CamelCase_HEADERS HEADER_NAMES Types Manager Adapter Device GattApplication GattCharacteristic GattManager GattService Input LEAdvertisement LEAdvertisingManager Media MediaEndpoint MediaPlayer MediaPlayerTrack DevicesModel Job InitManagerJob InitObexManagerJob Services Agent Profile PendingCall Request ObexManager ObexAgent ObexTransfer ObexSession ObexObjectPush ObexFileTransfer ObexFileTransferEntry REQUIRED_HEADERS BluezQt_HEADERS PREFIX BluezQt ) # Install files install(TARGETS KF5BluezQt EXPORT KF5BluezQtTargets ${KF5_INSTALL_TARGETS_DEFAULT_ARGS}) install(FILES ${BluezQt_CamelCase_HEADERS} DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5}/BluezQt/BluezQt COMPONENT Devel) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/bluezqt_export.h ${BluezQt_HEADERS} DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5}/BluezQt/bluezqt COMPONENT Devel) if(BUILD_QCH) ecm_add_qch( KF5BluezQt_QCH NAME BluezQt BASE_NAME KF5BluezQt VERSION ${KF5_VERSION} ORG_DOMAIN org.kde SOURCES # using only public headers, to cover only public API ${BluezQt_HEADERS} MD_MAINPAGE "${CMAKE_SOURCE_DIR}/README.md" LINK_QCHS Qt5Core_QCH INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR} BLANK_MACROS BLUEZQT_EXPORT BLUEZQT_DEPRECATED BLUEZQT_DEPRECATED_EXPORT TAGFILE_INSTALL_DESTINATION ${KDE_INSTALL_QTQCHDIR} QCH_INSTALL_DESTINATION ${KDE_INSTALL_QTQCHDIR} COMPONENT Devel ) endif() include(ECMGeneratePriFile) ecm_generate_pri_file( BASE_NAME BluezQt LIB_NAME KF5BluezQt DEPS "core" FILENAME_VAR PRI_FILENAME INCLUDE_INSTALL_DIR ${KDE_INSTALL_INCLUDEDIR_KF5}/BluezQt ) install(FILES ${PRI_FILENAME} DESTINATION ${ECM_MKSPECS_INSTALL_DIR}) diff --git a/src/manager.cpp b/src/manager.cpp index e0849c9..3d91ef4 100644 --- a/src/manager.cpp +++ b/src/manager.cpp @@ -1,254 +1,256 @@ /* * BluezQt - Asynchronous Bluez wrapper library * * Copyright (C) 2014 David Rosca * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) version 3, or any * later version accepted by the membership of KDE e.V. (or its * successor approved by the membership of KDE e.V.), which shall * act as a proxy defined in Section 6 of version 3 of the license. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . */ #include "manager.h" #include "manager_p.h" #include "adapter.h" #include "agent.h" #include "agentadaptor.h" #include "profile.h" #include "profile_p.h" #include "profileadaptor.h" #include "pendingcall.h" #include "initmanagerjob.h" #include "utils.h" #include "debug.h" namespace BluezQt { Manager::Manager(QObject *parent) : QObject(parent) , d(new ManagerPrivate(this)) { Instance::setManager(this); } Manager::~Manager() { delete d; } InitManagerJob *Manager::init() { return new InitManagerJob(this); } bool Manager::isInitialized() const { return d->m_initialized; } bool Manager::isOperational() const { return d->m_initialized && d->m_bluezRunning && d->m_loaded; } bool Manager::isBluetoothOperational() const { return !d->m_bluetoothBlocked && d->m_bluezRunning && d->m_loaded && d->m_usableAdapter; } bool Manager::isBluetoothBlocked() const { return d->m_bluetoothBlocked; } bool Manager::setBluetoothBlocked(bool blocked) { if (blocked) { return d->m_rfkill->block(); } else { return d->m_rfkill->unblock(); } } AdapterPtr Manager::usableAdapter() const { return d->m_usableAdapter; } QList Manager::adapters() const { return d->m_adapters.values(); } QList Manager::devices() const { return d->m_devices.values(); } PendingCall *Manager::startService() { QDBusMessage msg = QDBusMessage::createMethodCall(Strings::orgFreedesktopDBus(), QStringLiteral("/org/freedesktop/DBus"), Strings::orgFreedesktopDBus(), QStringLiteral("StartServiceByName")); msg << Strings::orgBluez(); msg << quint32(0); return new PendingCall(DBusConnection::orgBluez().asyncCall(msg), PendingCall::ReturnUint32); } AdapterPtr Manager::adapterForAddress(const QString &address) const { for (AdapterPtr adapter : qAsConst(d->m_adapters)) { if (adapter->address() == address) { return adapter; } } return AdapterPtr(); } AdapterPtr Manager::adapterForUbi(const QString &ubi) const { return d->m_adapters.value(ubi); } DevicePtr Manager::deviceForAddress(const QString &address) const { DevicePtr device; for (AdapterPtr adapter : qAsConst(d->m_adapters)) { DevicePtr d = adapter->deviceForAddress(address); if (!d) { continue; } // Prefer powered adapter if (!device) { device = d; } else if (adapter->isPowered()) { device = d; } } return device; } DevicePtr Manager::deviceForUbi(const QString &ubi) const { return d->m_devices.value(ubi); } PendingCall *Manager::registerAgent(Agent *agent) { Q_ASSERT(agent); if (!d->m_bluezAgentManager) { return new PendingCall(PendingCall::InternalError, QStringLiteral("Manager not operational!")); } QString capability; switch (agent->capability()) { case Agent::DisplayOnly: capability = QStringLiteral("DisplayOnly"); break; case Agent::DisplayYesNo: capability = QStringLiteral("DisplayYesNo"); break; case Agent::KeyboardOnly: capability = QStringLiteral("KeyboardOnly"); break; case Agent::NoInputNoOutput: capability = QStringLiteral("NoInputNoOutput"); break; default: capability = QStringLiteral("DisplayYesNo"); break; } new AgentAdaptor(agent, this); if (!DBusConnection::orgBluez().registerObject(agent->objectPath().path(), agent)) { qCDebug(BLUEZQT) << "Cannot register object" << agent->objectPath().path(); } return new PendingCall(d->m_bluezAgentManager->RegisterAgent(agent->objectPath(), capability), PendingCall::ReturnVoid, this); } PendingCall *Manager::unregisterAgent(Agent *agent) { Q_ASSERT(agent); if (!d->m_bluezAgentManager) { return new PendingCall(PendingCall::InternalError, QStringLiteral("Manager not operational!")); } DBusConnection::orgBluez().unregisterObject(agent->objectPath().path()); return new PendingCall(d->m_bluezAgentManager->UnregisterAgent(agent->objectPath()), PendingCall::ReturnVoid, this); } PendingCall *Manager::requestDefaultAgent(Agent *agent) { Q_ASSERT(agent); if (!d->m_bluezAgentManager) { return new PendingCall(PendingCall::InternalError, QStringLiteral("Manager not operational!")); } return new PendingCall(d->m_bluezAgentManager->RequestDefaultAgent(agent->objectPath()), PendingCall::ReturnVoid, this); } PendingCall *Manager::registerProfile(Profile *profile) { Q_ASSERT(profile); if (!d->m_bluezProfileManager) { return new PendingCall(PendingCall::InternalError, QStringLiteral("Manager not operational!")); } new ProfileAdaptor(profile, this); if (!DBusConnection::orgBluez().registerObject(profile->objectPath().path(), profile)) { qCDebug(BLUEZQT) << "Cannot register object" << profile->objectPath().path(); } return new PendingCall(d->m_bluezProfileManager->RegisterProfile(profile->objectPath(), profile->uuid(), profile->d->options), PendingCall::ReturnVoid, this); } PendingCall *Manager::unregisterProfile(Profile *profile) { Q_ASSERT(profile); if (!d->m_bluezProfileManager) { return new PendingCall(PendingCall::InternalError, QStringLiteral("Manager not operational!")); } DBusConnection::orgBluez().unregisterObject(profile->objectPath().path()); return new PendingCall(d->m_bluezProfileManager->UnregisterProfile(profile->objectPath()), PendingCall::ReturnVoid, this); } +#if BLUEZQT_BUILD_DEPRECATED_SINCE(5, 57) MediaPtr Manager::media() const { return usableAdapter() ? usableAdapter()->media() : nullptr; } +#endif } // namespace BluezQt diff --git a/src/manager.h b/src/manager.h index 090b5ba..716abb1 100644 --- a/src/manager.h +++ b/src/manager.h @@ -1,373 +1,376 @@ /* * BluezQt - Asynchronous BlueZ wrapper library * * Copyright (C) 2014-2015 David Rosca * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) version 3, or any * later version accepted by the membership of KDE e.V. (or its * successor approved by the membership of KDE e.V.), which shall * act as a proxy defined in Section 6 of version 3 of the license. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . */ #ifndef BLUEZQT_MANAGER_H #define BLUEZQT_MANAGER_H #include #include "types.h" #include "bluezqt_export.h" namespace BluezQt { class Device; class Adapter; class Agent; class Profile; class PendingCall; class InitManagerJob; /** * @class BluezQt::Manager manager.h * * 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: * @code * BluezQt::Manager *manager = new BluezQt::Manager(); * BluezQt::InitManagerJob *job = manager->init(); * job->start(); * connect(job, &BluezQt::InitManagerJob::result, ...); * @endcode * * 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: * @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) * } * } * @endcode * * @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 InitManagerJob */ class BLUEZQT_EXPORT Manager : public QObject { Q_OBJECT Q_PROPERTY(bool initialized READ isInitialized) Q_PROPERTY(bool operational READ isOperational NOTIFY operationalChanged) Q_PROPERTY(bool bluetoothOperational READ isBluetoothOperational NOTIFY bluetoothOperationalChanged) Q_PROPERTY(bool bluetoothBlocked READ isBluetoothBlocked WRITE setBluetoothBlocked NOTIFY bluetoothBlockedChanged) Q_PROPERTY(AdapterPtr usableAdapter READ usableAdapter NOTIFY usableAdapterChanged) Q_PROPERTY(QList adapters READ adapters) Q_PROPERTY(QList devices READ devices) public: /** * Creates a new Manager object. * * @param parent */ explicit Manager(QObject *parent = nullptr); /** * Destroys a Manager object. */ ~Manager(); /** * Creates a new init job. * * @return init manager job */ InitManagerJob *init(); /** * Returns whether the manager is initialized. * * @return true if manager is initialized */ bool isInitialized() const; /** * Returns whether the manager is operational. * * The manager is operational when initialization was successful and * BlueZ system daemon is running. * * @return true if manager is operational */ bool isOperational() const; /** * Returns whether Bluetooth is operational. * * Bluetooth is operational when manager is operational and there is * a valid usable adapter. * * @return true if Bluetooth is operational */ bool isBluetoothOperational() 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. * * @return true if Bluetooth is blocked */ bool isBluetoothBlocked() const; /** * Sets a Bluetooth blocked state. * * This may fail either due to insufficent permissions or * because rfkill state is HARD_BLOCKED. In that case, * this function returns false. * * @note This requires write access to /dev/rfkill. * * @return true if unblocking rfkill devices succeeded */ bool setBluetoothBlocked(bool blocked); /** * Returns a usable adapter. * * Usable adapter is any adapter that is currently powered on. * * @return usable adapter */ AdapterPtr usableAdapter() const; /** * Returns a list of all adapters. * * @return list of adapters */ QList adapters() const; /** * Returns a list of all devices. * * @return list of devices */ QList devices() const; /** * 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. * * @return quint32 pending call */ static PendingCall *startService(); /** * Returns an adapter for specified address. * * @param address address of adapter (eg. "1C:E5:C3:BC:94:7E") * @return null if there is no adapter with specified address */ AdapterPtr adapterForAddress(const QString &address) const; /** * Returns an adapter for specified UBI. * * @param ubi UBI of adapter (eg. "/org/bluez/hci0") * @return null if there is no adapter with specified UBI */ AdapterPtr adapterForUbi(const QString &ubi) 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. * * @param address address of device (eg. "40:79:6A:0C:39:75") * @return null if there is no device with specified address */ DevicePtr deviceForAddress(const QString &address) const; /** * Returns a device for specified UBI. * * @param ubi UBI of device (eg. "/org/bluez/hci0/dev_40_79_6A_0C_39_75") * @return null if there is no device with specified UBI */ DevicePtr deviceForUbi(const QString &ubi) const; /** * 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 * * @param agent agent to be registered * @return void pending call */ PendingCall *registerAgent(Agent *agent); /** * Unregisters agent. * * Possible errors: PendingCall::DoesNotExist * * @param agent agent to be unregistered * @return void pending call */ PendingCall *unregisterAgent(Agent *agent); /** * Requests default agent. * * This requests to make the application agent the default agent. * * Possible errors: PendingCall::DoesNotExist * * @param agent registered agent * @return void pending call */ PendingCall *requestDefaultAgent(Agent *agent); /** * Registers profile. * * Possible errors: PendingCall::InvalidArguments, PendingCall::AlreadyExists * * @param profile profile to be registered * @return void pending call */ PendingCall *registerProfile(Profile *profile); /** * Unregisters profile. * * Possible errors: PendingCall::DoesNotExist * * @param profile profile to be unregistered * @return void pending call */ PendingCall *unregisterProfile(Profile *profile); +#if BLUEZQT_ENABLE_DEPRECATED_SINCE(5, 57) /** * Returns the media interface. * - * @deprecated since 5.57, use Adapter::media() instead. * @return media + * @deprecated since 5.57, use Adapter::media() instead. */ - BLUEZQT_DEPRECATED MediaPtr media() const; // KF6 TODO: Remove + BLUEZQT_DEPRECATED_VERSION(5, 57, "Use Adapter::media()") + MediaPtr media() const; +#endif Q_SIGNALS: /** * Indicates that operational state have changed. */ void operationalChanged(bool operational); /** * Indicates that Bluetooth operational state have changed. */ void bluetoothOperationalChanged(bool operational); /** * Indicates that Bluetooth blocked state have changed. */ void bluetoothBlockedChanged(bool blocked); /** * Indicates that adapter was added. */ void adapterAdded(AdapterPtr adapter); /** * Indicates that adapter was removed. */ void adapterRemoved(AdapterPtr adapter); /** * Indicates that at least one of the adapter's properties have changed. */ void adapterChanged(AdapterPtr adapter); /** * Indicates that a new device was added (eg. found by discovery). */ void deviceAdded(DevicePtr device); /** * Indicates that a device was removed. */ void deviceRemoved(DevicePtr device); /** * Indicates that at least one of the device's properties have changed. */ void deviceChanged(DevicePtr device); /** * Indicates that usable adapter have changed. */ void usableAdapterChanged(AdapterPtr adapter); /** * Indicates that all adapters were removed. */ void allAdaptersRemoved(); private: class ManagerPrivate *const d; friend class ManagerPrivate; friend class InitManagerJobPrivate; }; } // namespace BluezQt #endif // BLUEZQT_MANAGER_H