diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b78cbf4..e7fb993 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,168 +1,172 @@ set(bluezqt_SRCS a2dp-codecs.c manager.cpp manager_p.cpp adapter.cpp adapter_p.cpp device.cpp device_p.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 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 gattcharacteristic1) -qt5_add_dbus_interface(bluezqt_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/interfaces/org.bluez.GattManager1.xml gattmanager1) +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 leadvertisement1) -qt5_add_dbus_interface(bluezqt_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/interfaces/org.bluez.LEAdvertisingManager1.xml leadvertisingmanager1) +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 STATIC ${bluezqt_SRCS}) generate_export_header(KF5BluezQt BASE_NAME BluezQt) add_library(KF5::BluezQt ALIAS KF5BluezQt) 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 Input 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 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/adapter.cpp b/src/adapter.cpp index c6b63bf..d01b6c1 100644 --- a/src/adapter.cpp +++ b/src/adapter.cpp @@ -1,187 +1,192 @@ /* * 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 "adapter.h" #include "adapter_p.h" #include "device.h" #include "device_p.h" #include "pendingcall.h" namespace BluezQt { Adapter::Adapter(const QString &path, const QVariantMap &properties) : QObject() , d(new AdapterPrivate(path, properties)) { } Adapter::~Adapter() { delete d; } AdapterPtr Adapter::toSharedPtr() const { return d->q.toStrongRef(); } QString Adapter::ubi() const { return d->m_bluezAdapter->path(); } QString Adapter::address() const { return d->m_address; } QString Adapter::name() const { return d->m_alias; } PendingCall *Adapter::setName(const QString &name) { return new PendingCall(d->setDBusProperty(QStringLiteral("Alias"), name), PendingCall::ReturnVoid, this); } QString Adapter::systemName() const { return d->m_name; } quint32 Adapter::adapterClass() const { return d->m_adapterClass; } bool Adapter::isPowered() const { return d->m_powered; } PendingCall *Adapter::setPowered(bool powered) { return new PendingCall(d->setDBusProperty(QStringLiteral("Powered"), powered), PendingCall::ReturnVoid, this); } bool Adapter::isDiscoverable() const { return d->m_discoverable; } PendingCall *Adapter::setDiscoverable(bool discoverable) { return new PendingCall(d->setDBusProperty(QStringLiteral("Discoverable"), discoverable), PendingCall::ReturnVoid, this); } quint32 Adapter::discoverableTimeout() const { return d->m_discoverableTimeout; } PendingCall *Adapter::setDiscoverableTimeout(quint32 timeout) { return new PendingCall(d->setDBusProperty(QStringLiteral("DiscoverableTimeout"), timeout), PendingCall::ReturnVoid, this); } bool Adapter::isPairable() const { return d->m_pairable; } PendingCall *Adapter::setPairable(bool pairable) { return new PendingCall(d->setDBusProperty(QStringLiteral("Pairable"), pairable), PendingCall::ReturnVoid, this); } quint32 Adapter::pairableTimeout() const { return d->m_pairableTimeout; } PendingCall *Adapter::setPairableTimeout(quint32 timeout) { return new PendingCall(d->setDBusProperty(QStringLiteral("PairableTimeout"), timeout), PendingCall::ReturnVoid, this); } bool Adapter::isDiscovering() { return d->m_discovering; } QStringList Adapter::uuids() const { return d->m_uuids; } QString Adapter::modalias() const { return d->m_modalias; } +LEAdvertisingManagerPtr Adapter::leAdvertisingManager() const +{ + return d->m_leAdvertisingManager; +} + MediaPtr Adapter::media() const { return d->m_media; } QList Adapter::devices() const { return d->m_devices; } DevicePtr Adapter::deviceForAddress(const QString &address) const { for (DevicePtr device : qAsConst(d->m_devices)) { if (device->address() == address) { return device; } } return DevicePtr(); } PendingCall *Adapter::startDiscovery() { return new PendingCall(d->m_bluezAdapter->StartDiscovery(), PendingCall::ReturnVoid, this); } PendingCall *Adapter::stopDiscovery() { return new PendingCall(d->m_bluezAdapter->StopDiscovery(), PendingCall::ReturnVoid, this); } PendingCall *Adapter::removeDevice(DevicePtr device) { return new PendingCall(d->m_bluezAdapter->RemoveDevice(QDBusObjectPath(device->ubi())), PendingCall::ReturnVoid, this); } } // namespace BluezQt diff --git a/src/adapter.h b/src/adapter.h index 90dbc55..c1ab9b2 100644 --- a/src/adapter.h +++ b/src/adapter.h @@ -1,385 +1,398 @@ /* * 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_ADAPTER_H #define BLUEZQT_ADAPTER_H #include #include #include #include "types.h" #include "bluezqt_export.h" namespace BluezQt { class Device; class PendingCall; /** * @class BluezQt::Adapter adapter.h * * Bluetooth adapter. * * This class represents a Bluetooth adapter. */ class BLUEZQT_EXPORT Adapter : public QObject { Q_OBJECT Q_PROPERTY(QString ubi READ ubi) Q_PROPERTY(QString address READ address) Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) Q_PROPERTY(QString systemName READ systemName NOTIFY systemNameChanged) Q_PROPERTY(quint32 adapterClass READ adapterClass NOTIFY adapterClassChanged) Q_PROPERTY(bool powered READ isPowered WRITE setPowered NOTIFY poweredChanged) Q_PROPERTY(bool discoverable READ isDiscoverable WRITE setDiscoverable NOTIFY discoverableChanged) Q_PROPERTY(quint32 discoverableTimeout READ discoverableTimeout WRITE setDiscoverableTimeout NOTIFY discoverableTimeoutChanged) Q_PROPERTY(bool pairable READ isPairable WRITE setPairable NOTIFY pairableChanged) Q_PROPERTY(quint32 pairableTimeout READ pairableTimeout WRITE setPairableTimeout NOTIFY pairableTimeoutChanged) Q_PROPERTY(bool discovering READ isDiscovering NOTIFY discoveringChanged) Q_PROPERTY(QStringList uuids READ uuids NOTIFY uuidsChanged) Q_PROPERTY(QString modalias READ modalias NOTIFY modaliasChanged) + Q_PROPERTY(LEAdvertisingManagerPtr leAdvertisingManager READ leAdvertisingManager NOTIFY leAdvertisingManagerChanged) Q_PROPERTY(MediaPtr media READ media NOTIFY mediaChanged) Q_PROPERTY(QList devices READ devices) public: /** * Destroys an Adapter object. */ ~Adapter(); /** * Returns a shared pointer from this. * * @return AdapterPtr */ AdapterPtr toSharedPtr() const; /** * Returns an UBI of the adapter. * * Example UBI: "/org/bluez/hci0" * * @return UBI of adapter */ QString ubi() const; /** * Returns an address of the adapter. * * Example address: "1C:E5:C3:BC:94:7E" * * @return address of adapter */ QString address() const; /** * Returns a name of the adapter. * * @return name of adapter */ QString name() const; /** * Sets the name of the adapter. * * @param name name of adapter * @return void pending call */ PendingCall *setName(const QString &name); /** * Returns a system name (hostname) of the adapter. * * @return system name of adapter */ QString systemName() const; /** * Returns a class of the adapter. * * @return class of adapter */ quint32 adapterClass() const; /** * Returns whether the adapter is powered on. * * @return true if adapter is powered on */ bool isPowered() const; /** * Sets the powered state of the adapter. * * @param powered powered state * @return void pending call */ PendingCall *setPowered(bool powered); /** * Returns whether the adapter is discoverable by other devices. * * @return true if adapter is discoverable */ bool isDiscoverable() const; /** * Sets the discoverable state of the adapter. * * @param discoverable discoverable state * @return void pending call */ PendingCall *setDiscoverable(bool discoverable); /** * Returns the discoverable timeout in seconds of the adapter. * * Discoverable timeout defines how long the adapter stays in * discoverable state after calling setDiscoverable(true). * * Timeout 0 means infinitely. * * @return discoverable timeout of adapter */ quint32 discoverableTimeout() const; /** * Sets the discoverable timeout of the adapter. * * @param timeout timeout in seconds * @return void pending call */ PendingCall *setDiscoverableTimeout(quint32 timeout); /** * Returns whether the adapter is pairable with other devices. * * @return true if adapter is pairable */ bool isPairable() const; /** * Sets the pairable state of the adapter. * * @param pairable pairable state * @return void pending call */ PendingCall *setPairable(bool pairable); /** * Returns the pairable timeout in seconds of the adapter. * * Pairable timeout defines how long the adapter stays in * pairable state after calling setPairable(true). * * Timeout 0 means infinitely. * * @return pairable timeout of adapter */ quint32 pairableTimeout() const; /** * Sets the pairable timeout of the adapter. * * @param timeout timeout in seconds * @return void pending call */ PendingCall *setPairableTimeout(quint32 timeout); /** * Returns whether the adapter is discovering for other devices * * @return true if adapter is discovering */ bool isDiscovering(); /** * Returns UUIDs of supported services by the adapter. * * UUIDs will always be returned in uppercase. * * @return UUIDs of supported services */ QStringList uuids() const; /** * Returns local device ID in modalias format. * * @return adapter modalias */ QString modalias() const; + /** + * Returns the LE advertising manager interface for the adapter. + * + * @return null if adapter have no Bluetooth LE + */ + LEAdvertisingManagerPtr leAdvertisingManager() const; + /** * Returns the media interface for the adapter. * * @return null if adapter have no media */ MediaPtr media() const; /** * Returns list of devices known by the adapter. * * @return list of devices */ QList devices() const; /** * Returns a device for specified address. * * @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; /** * Starts device discovery. * * Possible errors: PendingCall::NotReady, PendingCall::Failed * * @return void pending call * @see discoverableTimeout() const */ PendingCall *startDiscovery(); /** * Stops device discovery. * * Possible errors: PendingCall::NotReady, PendingCall::Failed, PendingCall::NotAuthorized * * @return void pending call */ PendingCall *stopDiscovery(); /** * Removes the specified device. * * It will also remove the pairing information. * * Possible errors: PendingCall::InvalidArguments, PendingCall::Failed * * @param device device to be removed * @return void pending call */ PendingCall *removeDevice(DevicePtr device); Q_SIGNALS: /** * Indicates that the 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 adapter's name have changed. */ void nameChanged(const QString &name); /** * Indicates that adapter's system name have changed. */ void systemNameChanged(const QString &systemName); /** * Indicates that adapter's class have changed. */ void adapterClassChanged(quint32 adapterClass); /** * Indicates that adapter's powered state have changed. */ void poweredChanged(bool powered); /** * Indicates that adapter's discoverable state have changed. */ void discoverableChanged(bool discoverable); /** * Indicates that adapter's discoverable timeout have changed. */ void discoverableTimeoutChanged(quint32 timeout); /** * Indicates that adapter's pairable state have changed. */ void pairableChanged(bool pairable); /** * Indicates that adapter's pairable timeout have changed. */ void pairableTimeoutChanged(quint32 timeout); /** * Indicates that adapter's discovering state have changed. */ void discoveringChanged(bool discovering); /** * Indicates that adapter's UUIDs have changed. */ void uuidsChanged(const QStringList &uuids); /** * Indicates that adapter's modalias have changed. */ void modaliasChanged(const QString &modalias); + /** + * Indicates that adapter's LE advertising manager have changed. + */ + void leAdvertisingManagerChanged(LEAdvertisingManagerPtr leAdvertisingManager); + /** * Indicates that adapter's media have changed. */ void mediaChanged(MediaPtr media); /** * 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); private: explicit Adapter(const QString &path, const QVariantMap &properties); class AdapterPrivate *const d; friend class AdapterPrivate; friend class ManagerPrivate; friend class InitAdaptersJobPrivate; }; } // namespace BluezQt #endif // BLUEZQT_ADAPTER_H diff --git a/src/adapter_p.cpp b/src/adapter_p.cpp index 73048b3..714cda4 100644 --- a/src/adapter_p.cpp +++ b/src/adapter_p.cpp @@ -1,169 +1,179 @@ /* * 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 "adapter_p.h" #include "adapter.h" #include "utils.h" #include "macros.h" +#include "leadvertisingmanager.h" +#include "leadvertisingmanager_p.h" #include "media.h" #include "media_p.h" namespace BluezQt { AdapterPrivate::AdapterPrivate(const QString &path, const QVariantMap &properties) : QObject() , m_dbusProperties(nullptr) , m_adapterClass(0) , m_powered(0) , m_discoverable(false) , m_discoverableTimeout(0) , m_pairable(false) , m_pairableTimeout(0) { m_bluezAdapter = new BluezAdapter(Strings::orgBluez(), path, DBusConnection::orgBluez(), this); init(properties); } void AdapterPrivate::init(const QVariantMap &properties) { m_dbusProperties = new DBusProperties(Strings::orgBluez(), m_bluezAdapter->path(), DBusConnection::orgBluez(), this); // Init properties m_address = properties.value(QStringLiteral("Address")).toString(); m_name = properties.value(QStringLiteral("Name")).toString(); m_alias = properties.value(QStringLiteral("Alias")).toString(); m_adapterClass = properties.value(QStringLiteral("Class")).toUInt(); m_powered = properties.value(QStringLiteral("Powered")).toBool(); m_discoverable = properties.value(QStringLiteral("Discoverable")).toBool(); m_discoverableTimeout = properties.value(QStringLiteral("DiscoverableTimeout")).toUInt(); m_pairable = properties.value(QStringLiteral("Pairable")).toBool(); m_pairableTimeout = properties.value(QStringLiteral("PairableTimeout")).toUInt(); m_discovering = properties.value(QStringLiteral("Discovering")).toBool(); m_uuids = stringListToUpper(properties.value(QStringLiteral("UUIDs")).toStringList()); m_modalias = properties.value(QStringLiteral("Modalias")).toString(); } void AdapterPrivate::interfacesAdded(const QString &path, const QVariantMapMap &interfaces) { bool changed = false; for (auto it = interfaces.cbegin(); it != interfaces.cend(); ++it) { if (it.key() == Strings::orgBluezMedia1()) { m_media = MediaPtr(new Media(path)); Q_EMIT q.data()->mediaChanged(m_media); changed = true; + } else if (it.key() == Strings::orgBluezLEAdvertisingManager1()) { + m_leAdvertisingManager = LEAdvertisingManagerPtr(new LEAdvertisingManager(path)); + Q_EMIT q.data()->leAdvertisingManagerChanged(m_leAdvertisingManager); + changed = true; } } if (changed) { Q_EMIT q.data()->adapterChanged(q.toStrongRef()); } } void AdapterPrivate::interfacesRemoved(const QString &path, const QStringList &interfaces) { bool changed = false; for (const QString &interface : interfaces) { if (interface == Strings::orgBluezMedia1() && m_media && m_media->d->m_path == path) { m_media.clear(); Q_EMIT q.data()->mediaChanged(m_media); changed = true; + } else if (interface == Strings::orgBluezLEAdvertisingManager1() && m_leAdvertisingManager && m_leAdvertisingManager->d->m_path == path) { + m_leAdvertisingManager.clear(); + Q_EMIT q.data()->leAdvertisingManagerChanged(m_leAdvertisingManager); + changed = true; } } if (changed) { Q_EMIT q.data()->adapterChanged(q.toStrongRef()); } } void AdapterPrivate::addDevice(const DevicePtr &device) { m_devices.append(device); Q_EMIT q.data()->deviceAdded(device); connect(device.data(), &Device::deviceChanged, q.data(), &Adapter::deviceChanged); } void AdapterPrivate::removeDevice(const DevicePtr &device) { m_devices.removeOne(device); Q_EMIT device->deviceRemoved(device); Q_EMIT q.data()->deviceRemoved(device); disconnect(device.data(), &Device::deviceChanged, q.data(), &Adapter::deviceChanged); } QDBusPendingReply<> AdapterPrivate::setDBusProperty(const QString &name, const QVariant &value) { return m_dbusProperties->Set(Strings::orgBluezAdapter1(), name, QDBusVariant(value)); } void AdapterPrivate::propertiesChanged(const QString &interface, const QVariantMap &changed, const QStringList &invalidated) { if (interface != Strings::orgBluezAdapter1()) { return; } QVariantMap::const_iterator i; for (i = changed.constBegin(); i != changed.constEnd(); ++i) { const QVariant &value = i.value(); const QString &property = i.key(); if (property == QLatin1String("Name")) { PROPERTY_CHANGED(m_name, toString, systemNameChanged); } else if (property == QLatin1String("Alias")) { PROPERTY_CHANGED(m_alias, toString, nameChanged); } else if (property == QLatin1String("Class")) { PROPERTY_CHANGED(m_adapterClass, toUInt, adapterClassChanged); } else if (property == QLatin1String("Powered")) { PROPERTY_CHANGED(m_powered, toBool, poweredChanged); } else if (property == QLatin1String("Discoverable")) { PROPERTY_CHANGED(m_discoverable, toBool, discoverableChanged); } else if (property == QLatin1String("DiscoverableTimeout")) { PROPERTY_CHANGED(m_discoverableTimeout, toUInt, discoverableTimeoutChanged); } else if (property == QLatin1String("Pairable")) { PROPERTY_CHANGED(m_pairable, toBool, pairableChanged); } else if (property == QLatin1String("PairableTimeout")) { PROPERTY_CHANGED(m_pairableTimeout, toUInt, pairableTimeoutChanged); } else if (property == QLatin1String("Discovering")) { PROPERTY_CHANGED(m_discovering, toBool, discoveringChanged); } else if (property == QLatin1String("Modalias")) { PROPERTY_CHANGED(m_modalias, toString, modaliasChanged); } else if (property == QLatin1String("UUIDs")) { PROPERTY_CHANGED2(m_uuids, stringListToUpper(value.toStringList()), uuidsChanged); } } for (const QString &property : invalidated) { if (property == QLatin1String("Modalias")) { PROPERTY_INVALIDATED(m_modalias, QString(), modaliasChanged); } } Q_EMIT q.data()->adapterChanged(q.toStrongRef()); } } // namespace BluezQt diff --git a/src/adapter_p.h b/src/adapter_p.h index 461932b..ad6077b 100644 --- a/src/adapter_p.h +++ b/src/adapter_p.h @@ -1,80 +1,81 @@ /* * 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 . */ #ifndef BLUEZQT_ADAPTER_P_H #define BLUEZQT_ADAPTER_P_H #include #include #include "types.h" #include "bluezadapter1.h" #include "dbusproperties.h" #include "bluezqt_dbustypes.h" namespace BluezQt { typedef org::bluez::Adapter1 BluezAdapter; typedef org::freedesktop::DBus::Properties DBusProperties; class AdapterPrivate : public QObject { Q_OBJECT public: explicit AdapterPrivate(const QString &path, const QVariantMap &properties); void init(const QVariantMap &properties); void interfacesAdded(const QString &path, const QVariantMapMap &interfaces); void interfacesRemoved(const QString &path, const QStringList &interfaces); void addDevice(const DevicePtr &device); void removeDevice(const DevicePtr &device); QDBusPendingReply<> setDBusProperty(const QString &name, const QVariant &value); void propertiesChanged(const QString &interface, const QVariantMap &changed, const QStringList &invalidated); QWeakPointer q; BluezAdapter *m_bluezAdapter; DBusProperties *m_dbusProperties; QString m_address; QString m_name; QString m_alias; quint32 m_adapterClass; bool m_powered; bool m_discoverable; quint32 m_discoverableTimeout; bool m_pairable; quint32 m_pairableTimeout; bool m_discovering; QStringList m_uuids; QList m_devices; QString m_modalias; MediaPtr m_media; + LEAdvertisingManagerPtr m_leAdvertisingManager; }; } // namespace BluezQt #endif // BLUEZQT_ADAPTER_P_H diff --git a/src/leadvertisement.cpp b/src/leadvertisement.cpp new file mode 100644 index 0000000..9ef88f8 --- /dev/null +++ b/src/leadvertisement.cpp @@ -0,0 +1,54 @@ +/* + * BluezQt - Asynchronous Bluez wrapper library + * + * Copyright (C) 2019 Manuel Weichselbaumer + * + * 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 "leadvertisement.h" +#include "leadvertisement_p.h" + +namespace BluezQt +{ + +LEAdvertisement::LEAdvertisement(const QStringList& serviceUuids, QObject *parent) + : QObject(parent), + d(new LEAdvertisementPrivate(serviceUuids)) +{ +} + +LEAdvertisement::~LEAdvertisement() +{ + delete d; +} + +QDBusObjectPath LEAdvertisement::objectPath() const +{ + return d->m_objectPath; +} + +QStringList LEAdvertisement::serviceUuids() const +{ + return d->m_serviceUuids; +} + +void LEAdvertisement::release() +{ +} + +} // namespace BluezQt diff --git a/src/leadvertisement.h b/src/leadvertisement.h new file mode 100644 index 0000000..96fe086 --- /dev/null +++ b/src/leadvertisement.h @@ -0,0 +1,93 @@ +/* + * BluezQt - Asynchronous BlueZ wrapper library + * + * Copyright (C) 2019 Manuel Weichselbaumer + * + * 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_LEADVERTISEMENT_H +#define BLUEZQT_LEADVERTISEMENT_H + +#include + +#include "bluezqt_export.h" + +class QDBusObjectPath; + +namespace BluezQt +{ + +/** + * @class BluezQt::LEAdvertisement leadvertisement.h + * + * Bluetooth LE advertisement. + * + * This class represents a Bluetooth LE advertisement. + */ +class BLUEZQT_EXPORT LEAdvertisement : public QObject +{ + Q_OBJECT + +public: + /** + * Creates a new LEAdvertisement object. + * + * @param parent + */ + explicit LEAdvertisement(const QStringList& serviceUuids, QObject *parent = nullptr); + + /** + * Destroys a LEAdvertisement object. + */ + ~LEAdvertisement(); + + /** + * D-Bus object path of the advertisement. + * + * The path where the advertisement will be registered. + * + * @note You must provide valid object path! + * + * @return object path of advertisement + */ + virtual QDBusObjectPath objectPath() const; + + /** + * List of UUIDs to include in the "Service UUID" field of the Advertising Data. + * + * @return UUIDs of the advertisement + */ + virtual QStringList serviceUuids() const; + + /** + * Indicates that the MediaEndpoint was unregistered. + * + * This method gets called when the service daemon removes the Advertisement. + * A client can use it to do cleanup tasks. There is no need to call + * UnregisterAdvertisement because when this method gets called it has + * already been unregistered. + */ + virtual void release(); + +private: + class LEAdvertisementPrivate *const d; +}; + +} // namespace BluezQt + +#endif // BLUEZQT_LEADVERTISEMENT_H diff --git a/src/leadvertisement_p.cpp b/src/leadvertisement_p.cpp new file mode 100644 index 0000000..418e1bd --- /dev/null +++ b/src/leadvertisement_p.cpp @@ -0,0 +1,38 @@ +/* + * BluezQt - Asynchronous Bluez wrapper library + * + * Copyright (C) 2019 Manuel Weichselbaumer + * + * 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 "leadvertisement_p.h" + +namespace BluezQt +{ + +LEAdvertisementPrivate::LEAdvertisementPrivate(const QStringList& serviceUuids) + : m_serviceUuids(serviceUuids) +{ + QString objectPath = QStringLiteral("/org/bluez/leadvertisements/"); + if (!serviceUuids.isEmpty()) { + objectPath += serviceUuids.front(); + } + m_objectPath.setPath(objectPath); +} + +} // namespace BluezQt diff --git a/src/leadvertisement_p.h b/src/leadvertisement_p.h new file mode 100644 index 0000000..5027b76 --- /dev/null +++ b/src/leadvertisement_p.h @@ -0,0 +1,41 @@ +/* + * BluezQt - Asynchronous Bluez wrapper library + * + * Copyright (C) 2019 Manuel Weichselbaumer + * + * 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_LEADVERTISEMENT_P_H +#define BLUEZQT_LEADVERTISEMENT_P_H + +#include + +namespace BluezQt +{ + +class LEAdvertisementPrivate +{ +public: + explicit LEAdvertisementPrivate(const QStringList& serviceUuids); + QStringList m_serviceUuids; + QDBusObjectPath m_objectPath; +}; + +} // namespace BluezQt + +#endif // BLUEZQT_LEADVERTISEMENT_P_H diff --git a/src/leadvertisementadaptor.cpp b/src/leadvertisementadaptor.cpp new file mode 100644 index 0000000..ac1559b --- /dev/null +++ b/src/leadvertisementadaptor.cpp @@ -0,0 +1,53 @@ +/* + * BluezQt - Asynchronous Bluez wrapper library + * + * Copyright (C) 2019 Manuel Weichselbaumer + * + * 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 "leadvertisementadaptor.h" +#include "leadvertisement.h" + +#include +#include + +namespace BluezQt +{ + +LEAdvertisementAdaptor::LEAdvertisementAdaptor(LEAdvertisement *parent) + : QDBusAbstractAdaptor(parent) + , m_advertisement(parent) +{ +} + +QString LEAdvertisementAdaptor::type() const +{ + return QStringLiteral("peripheral"); +} + +QStringList LEAdvertisementAdaptor::serviceUuids() const +{ + return m_advertisement->serviceUuids(); +} + +void LEAdvertisementAdaptor::Release() +{ + m_advertisement->release(); +} + +} // namespace BluezQt diff --git a/src/leadvertisementadaptor.h b/src/leadvertisementadaptor.h new file mode 100644 index 0000000..7182011 --- /dev/null +++ b/src/leadvertisementadaptor.h @@ -0,0 +1,56 @@ +/* + * BluezQt - Asynchronous Bluez wrapper library + * + * Copyright (C) 2019 Manuel Weichselbaumer + * + * 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_LEADVERTISEMENTADAPTOR_H +#define BLUEZQT_LEADVERTISEMENTADAPTOR_H + +#include + +namespace BluezQt +{ + +class LEAdvertisement; + +class LEAdvertisementAdaptor : public QDBusAbstractAdaptor +{ + Q_OBJECT + Q_CLASSINFO("D-Bus Interface", "org.bluez.LEAdvertisement1") + Q_PROPERTY(QString Type READ type) + Q_PROPERTY(QStringList ServiceUUIDs READ serviceUuids) + +public: + explicit LEAdvertisementAdaptor(LEAdvertisement *parent); + + QString type() const; + + QStringList serviceUuids() const; + +public Q_SLOTS: + Q_NOREPLY void Release(); + +private: + LEAdvertisement *m_advertisement; +}; + +} // namespace BluezQt + +#endif // BLUEZQT_LEADVERTISEMENTADAPTOR_H diff --git a/src/leadvertisingmanager.cpp b/src/leadvertisingmanager.cpp new file mode 100644 index 0000000..3bac837 --- /dev/null +++ b/src/leadvertisingmanager.cpp @@ -0,0 +1,79 @@ +/* + * BluezQt - Asynchronous Bluez wrapper library + * + * Copyright (C) 2019 Manuel Weichselbaumer + * + * 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 "leadvertisingmanager.h" +#include "leadvertisingmanager_p.h" +#include "leadvertisement.h" +#include "leadvertisementadaptor.h" +#include "pendingcall.h" +#include "utils.h" +#include "debug.h" + +namespace BluezQt +{ + +LEAdvertisingManager::LEAdvertisingManager(const QString &path, QObject *parent) + : QObject(parent) + , d(new LEAdvertisingManagerPrivate()) +{ + d->m_path = path; + d->m_bluezLEAdvertisingManager = new BluezLEAdvertisingManager(Strings::orgBluez(), path, DBusConnection::orgBluez(), this); +} + +LEAdvertisingManager::~LEAdvertisingManager() +{ + delete d; +} + +PendingCall *LEAdvertisingManager::registerAdvertisement(LEAdvertisement *advertisement) +{ + Q_ASSERT(advertisement); + + if (!d->m_bluezLEAdvertisingManager) { + return new PendingCall(PendingCall::InternalError, QStringLiteral("LEAdvertisingManager not operational!")); + } + + new LEAdvertisementAdaptor(advertisement); + + if (!DBusConnection::orgBluez().registerObject(advertisement->objectPath().path(), advertisement)) { + qCDebug(BLUEZQT) << "Cannot register object" << advertisement->objectPath().path(); + } + + return new PendingCall(d->m_bluezLEAdvertisingManager->RegisterAdvertisement(advertisement->objectPath(), QVariantMap()), + PendingCall::ReturnVoid, this); +} + +PendingCall *LEAdvertisingManager::unregisterAdvertisement(LEAdvertisement *advertisement) +{ + Q_ASSERT(advertisement); + + if (!d->m_bluezLEAdvertisingManager) { + return new PendingCall(PendingCall::InternalError, QStringLiteral("LEAdvertisingManager not operational!")); + } + + DBusConnection::orgBluez().unregisterObject(advertisement->objectPath().path()); + + return new PendingCall(d->m_bluezLEAdvertisingManager->UnregisterAdvertisement(advertisement->objectPath()), + PendingCall::ReturnVoid, this); +} + +} // namespace BluezQt diff --git a/src/leadvertisingmanager.h b/src/leadvertisingmanager.h new file mode 100644 index 0000000..5d5922e --- /dev/null +++ b/src/leadvertisingmanager.h @@ -0,0 +1,100 @@ +/* + * BluezQt - Asynchronous BlueZ wrapper library + * + * Copyright (C) 2019 Manuel Weichselbaumer + * + * 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_LEADVERTISINGMANAGER_H +#define BLUEZQT_LEADVERTISINGMANAGER_H + +#include + +#include "bluezqt_export.h" + +namespace BluezQt +{ + +class LEAdvertisement; +class PendingCall; + +/** + * @class BluezQt::LEAdvertisingManager leadvertisingmanager.h + * + * Bluetooth LE advertising manager. + * + * The Advertising Manager allows external applications to register Advertisement + * Data which should be broadcast to devices. Advertisement Data elements must + * follow the API for LE Advertisement Data. + * + * @see LEAdvertisement + */ +class BLUEZQT_EXPORT LEAdvertisingManager : public QObject +{ + Q_OBJECT + +public: + /** + * Destroys an LEAdvertisingManager object. + */ + ~LEAdvertisingManager(); + + /** + * Registers advertisement. + * + * Registers an advertisement object to be sent over the LE Advertising + * channel. The service must be exported under interface LEAdvertisement1. + * + * InvalidArguments error indicates invalid or conflicting properties. + * InvalidLength error indicates that provided data results in too long data packet. + * The properties of this object are parsed on register, any changes are ignored. + * If the same object is registered twice it will result in an AlreadyExists error. + * NotPermitted error indicates that the maximum number of advertisements is reached. + * + * Possible errors: PendingCall::InvalidArguments, PendingCall::AlreadyExists, + * PendingCall::InvalidLength, PendingCall::NotPermitted + * + * @param advertisement advertisement to be registered + * @return void pending call + */ + PendingCall *registerAdvertisement(LEAdvertisement *advertisement); + + /** + * Unregisters advertisement. + * + * This unregisters an advertisement that has been previously registered. + * The object path must match the same value that has been used on registration. + * + * Possible errors: PendingCall::InvalidArguments, PendingCall::DoesNotExist + * + * @param advertisement advertisement to be unregistered + * @return void pending call + */ + PendingCall *unregisterAdvertisement(LEAdvertisement *advertisement); + +private: + explicit LEAdvertisingManager(const QString &path, QObject *parent = nullptr); + + class LEAdvertisingManagerPrivate *const d; + + friend class AdapterPrivate; +}; + +} // namespace BluezQt + +#endif // BLUEZQT_LEADVERTISINGMANAGER_H diff --git a/src/leadvertisingmanager_p.h b/src/leadvertisingmanager_p.h new file mode 100644 index 0000000..83a8085 --- /dev/null +++ b/src/leadvertisingmanager_p.h @@ -0,0 +1,42 @@ +/* + * BluezQt - Asynchronous Bluez wrapper library + * + * Copyright (C) 2019 Manuel Weichselbaumer + * + * 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_LEADVERTISINGMANAGER_P_H +#define BLUEZQT_LEADVERTISINGMANAGER_P_H + +#include "bluezleadvertisingmanager1.h" + +namespace BluezQt +{ + +typedef org::bluez::LEAdvertisingManager1 BluezLEAdvertisingManager; + +class LEAdvertisingManagerPrivate +{ +public: + QString m_path; + BluezLEAdvertisingManager *m_bluezLEAdvertisingManager = nullptr; +}; + +} // namespace BluezQt + +#endif // BLUEZQT_LEADVERTISINGMANAGER_P_H diff --git a/src/pendingcall.cpp b/src/pendingcall.cpp index 1e2b6cb..382d271 100644 --- a/src/pendingcall.cpp +++ b/src/pendingcall.cpp @@ -1,317 +1,319 @@ /* * 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 "pendingcall.h" #include "obextransfer.h" #include "obextransfer_p.h" #include "obexfiletransferentry.h" #include "bluezqt_dbustypes.h" #include "debug.h" #include #include #include namespace BluezQt { static PendingCall::Error nameToError(const QString &name) { if (name.startsWith(QLatin1String("org.freedesktop.DBus.Error"))) { return PendingCall::DBusError; } if (!name.startsWith(QLatin1String("org.bluez.Error"))) { return PendingCall::UnknownError; } #define FROM_BLUEZ_ERROR(string, value) \ if (errorName == QLatin1String(string)) { \ return value; \ } const QString &errorName = name.mid(16); FROM_BLUEZ_ERROR("NotReady", PendingCall::NotReady); FROM_BLUEZ_ERROR("Failed", PendingCall::Failed); FROM_BLUEZ_ERROR("Rejected", PendingCall::Rejected); FROM_BLUEZ_ERROR("Canceled", PendingCall::Canceled); FROM_BLUEZ_ERROR("InvalidArguments", PendingCall::InvalidArguments); FROM_BLUEZ_ERROR("AlreadyExists", PendingCall::AlreadyExists); FROM_BLUEZ_ERROR("DoesNotExist", PendingCall::DoesNotExist); FROM_BLUEZ_ERROR("AlreadyConnected", PendingCall::AlreadyConnected); FROM_BLUEZ_ERROR("ConnectFailed", PendingCall::ConnectFailed); FROM_BLUEZ_ERROR("NotConnected", PendingCall::NotConnected); FROM_BLUEZ_ERROR("NotSupported", PendingCall::NotSupported); FROM_BLUEZ_ERROR("NotAuthorized", PendingCall::NotAuthorized); FROM_BLUEZ_ERROR("AuthenticationCanceled", PendingCall::AuthenticationCanceled); FROM_BLUEZ_ERROR("AuthenticationFailed", PendingCall::AuthenticationFailed); FROM_BLUEZ_ERROR("AuthenticationRejected", PendingCall::AuthenticationRejected); FROM_BLUEZ_ERROR("AuthenticationTimeout", PendingCall::AuthenticationTimeout); FROM_BLUEZ_ERROR("ConnectionAttemptFailed", PendingCall::ConnectionAttemptFailed); + FROM_BLUEZ_ERROR("InvalidLength", PendingCall::InvalidLength); + FROM_BLUEZ_ERROR("NotPermitted", PendingCall::NotPermitted); #undef FROM_BLUEZ_ERROR return PendingCall::UnknownError; } class PendingCallPrivate : public QObject { public: explicit PendingCallPrivate(PendingCall *parent); void processReply(QDBusPendingCallWatcher *call); void processVoidReply(const QDBusPendingReply<> &reply); void processUint32Reply(const QDBusPendingReply &reply); void processStringReply(const QDBusPendingReply &reply); void processObjectPathReply(const QDBusPendingReply &reply); void processFileTransferListReply(const QDBusPendingReply &reply); void processTransferWithPropertiesReply(const QDBusPendingReply &reply); void processError(const QDBusError &m_error); void emitFinished(); void emitDelayedFinished(); void emitInternalError(const QString &errorText); void pendingCallFinished(QDBusPendingCallWatcher *m_watcher); PendingCall *q; int m_error; QString m_errorText; QVariant m_userData; QVariantList m_value; PendingCall::ReturnType m_type; QDBusPendingCallWatcher *m_watcher; }; PendingCallPrivate::PendingCallPrivate(PendingCall *parent) : QObject(parent) , q(parent) , m_error(PendingCall::NoError) , m_type(PendingCall::ReturnVoid) , m_watcher(nullptr) { } void PendingCallPrivate::processReply(QDBusPendingCallWatcher *call) { switch (m_type) { case PendingCall::ReturnVoid: processVoidReply(*call); break; case PendingCall::ReturnUint32: processUint32Reply(*call); break; case PendingCall::ReturnString: processStringReply(*call); break; case PendingCall::ReturnObjectPath: processObjectPathReply(*call); break; case PendingCall::ReturnFileTransferList: processFileTransferListReply(*call); break; case PendingCall::ReturnTransferWithProperties: processTransferWithPropertiesReply(*call); break; default: break; } } void PendingCallPrivate::processVoidReply(const QDBusPendingReply<> &reply) { processError(reply.error()); } void PendingCallPrivate::processUint32Reply(const QDBusPendingReply &reply) { processError(reply.error()); if (!reply.isError()) { m_value.append(reply.value()); } } void PendingCallPrivate::processStringReply(const QDBusPendingReply &reply) { processError(reply.error()); if (!reply.isError()) { m_value.append(reply.value()); } } void PendingCallPrivate::processObjectPathReply(const QDBusPendingReply &reply) { processError(reply.error()); if (!reply.isError()) { m_value.append(QVariant::fromValue(reply.value())); } } void PendingCallPrivate::processFileTransferListReply(const QDBusPendingReply &reply) { processError(reply.error()); if (!reply.isError()) { QList items; items.reserve(reply.value().size()); const auto maps = reply.value(); for (const QVariantMap &map : maps) { items.append(ObexFileTransferEntry(map)); } m_value.append(QVariant::fromValue(items)); } } void PendingCallPrivate::processTransferWithPropertiesReply(const QDBusPendingReply &reply) { processError(reply.error()); if (reply.isError()) { return; } ObexTransferPtr transfer = ObexTransferPtr(new ObexTransfer(reply.argumentAt<0>().path(), reply.argumentAt<1>())); transfer->d->q = transfer.toWeakRef(); transfer->d->m_suspendable = true; m_value.append(QVariant::fromValue(transfer)); } void PendingCallPrivate::processError(const QDBusError &error) { if (error.isValid()) { qCWarning(BLUEZQT) << "PendingCall Error:" << error.message(); m_error = nameToError(error.name()); m_errorText = error.message(); } } void PendingCallPrivate::emitFinished() { m_watcher->deleteLater(); m_watcher = nullptr; Q_EMIT q->finished(q); q->deleteLater(); } void PendingCallPrivate::emitDelayedFinished() { Q_ASSERT(qobject_cast(sender())); Q_EMIT q->finished(q); static_cast(sender())->deleteLater(); } void PendingCallPrivate::emitInternalError(const QString &errorText) { qCWarning(BLUEZQT) << "PendingCall Internal error:" << errorText; m_error = PendingCall::InternalError; m_errorText = errorText; emitFinished(); } void PendingCallPrivate::pendingCallFinished(QDBusPendingCallWatcher *watcher) { processReply(watcher); emitFinished(); } PendingCall::PendingCall(const QDBusPendingCall &call, ReturnType type, QObject *parent) : QObject(parent) , d(new PendingCallPrivate(this)) { qDBusRegisterMetaType(); d->m_type = type; d->m_watcher = new QDBusPendingCallWatcher(call, this); connect(d->m_watcher, &QDBusPendingCallWatcher::finished, d, &PendingCallPrivate::pendingCallFinished); } PendingCall::PendingCall(PendingCall::Error error, const QString &errorText, QObject *parent) : QObject(parent) , d(new PendingCallPrivate(this)) { d->m_error = error; d->m_errorText = errorText; QTimer *timer = new QTimer(this); timer->setSingleShot(true); timer->start(0); connect(timer, &QTimer::timeout, d, &PendingCallPrivate::emitDelayedFinished); } PendingCall::~PendingCall() { delete d; } QVariant PendingCall::value() const { if (d->m_value.isEmpty()) { return QVariant(); } return d->m_value.first(); } QVariantList PendingCall::values() const { return d->m_value; } int PendingCall::error() const { return d->m_error; } QString PendingCall::errorText() const { return d->m_errorText; } bool PendingCall::isFinished() const { if (d->m_watcher) { return d->m_watcher->isFinished(); } return true; } void PendingCall::waitForFinished() { if (d->m_watcher) { d->m_watcher->waitForFinished(); } } QVariant PendingCall::userData() const { return d->m_userData; } void PendingCall::setUserData(const QVariant &userData) { d->m_userData = userData; } } // namespace BluezQt diff --git a/src/pendingcall.h b/src/pendingcall.h index 7accf1e..fae3c27 100644 --- a/src/pendingcall.h +++ b/src/pendingcall.h @@ -1,206 +1,211 @@ /* * 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_PENDINGCALL_H #define BLUEZQT_PENDINGCALL_H #include #include "bluezqt_export.h" class QDBusPendingCall; namespace BluezQt { /** * @class BluezQt::PendingCall pendingcall.h * * Pending method call. * * This class represents a pending method call. It is a convenient wrapper * around QDBusPendingReply and QDBusPendingCallWatcher. */ class BLUEZQT_EXPORT PendingCall : public QObject { Q_OBJECT Q_PROPERTY(QVariant value READ value) Q_PROPERTY(QVariantList values READ values) Q_PROPERTY(int error READ error) Q_PROPERTY(QString errorText READ errorText) Q_PROPERTY(bool isFinished READ isFinished) Q_PROPERTY(QVariant userData READ userData WRITE setUserData) public: /** * Known error types. */ enum Error { /** Indicates there is no error. */ NoError = 0, /** Indicates that the device is not ready. */ NotReady = 1, /** Indicates that the action have failed. */ Failed = 2, /** Indicates that the action was rejected. */ Rejected = 3, /** Indicates that the action was canceled. */ Canceled = 4, /** Indicates that invalid arguments were passed. */ InvalidArguments = 5, /** Indicates that an agent or pairing record already exists. */ AlreadyExists = 6, /** Indicates that an agent, service or pairing operation does not exists. */ DoesNotExist = 7, /** Indicates that the action is already in progress. */ InProgress = 8, /** Indicates that the action is not in progress. */ NotInProgress = 9, /** Indicates that the device is already connected. */ AlreadyConnected = 10, /** Indicates that the connection to the device have failed. */ ConnectFailed = 11, /** Indicates that the device is not connected. */ NotConnected = 12, /** Indicates that the action is not supported. */ NotSupported = 13, /** Indicates that the caller is not authorized to do the action. */ NotAuthorized = 14, /** Indicates that the authentication was canceled. */ AuthenticationCanceled = 15, /** Indicates that the authentication have failed. */ AuthenticationFailed = 16, /** Indicates that the authentication was rejected. */ AuthenticationRejected = 17, /** Indicates that the authentication timed out. */ AuthenticationTimeout = 18, /** Indicates that the connection attempt have failed. */ ConnectionAttemptFailed = 19, + /** Indicates that the data provided generates a data packet which is too long. */ + InvalidLength = 20, + /** Indicates that the action is not permitted (e.g. maximum reached or socket locked). */ + NotPermitted = 21, /** Indicates an error with D-Bus. */ DBusError = 98, /** Indicates an internal error. */ InternalError = 99, /** Indicates an unknown error. */ UnknownError = 100 }; Q_ENUM(Error) /** * Destroys a PendingCall object. */ ~PendingCall(); /** * Returns a first return value of the call. * * @return first return value */ QVariant value() const; /** * Returns all values of the call. * * @return all return values */ QVariantList values() const; /** * Returns an error code. * * @return error code * @see Error */ int error() const; /** * Returns an error text. * * @return error text */ QString errorText() const; /** * Returns whether the call is finished. * * @return true if call is finished */ bool isFinished() const; /** * Waits for the call to finish. * * @warning This method blocks until the call finishes! */ void waitForFinished(); /** * Returns the user data of the call. * * @return user data of call */ QVariant userData() const; /** * Sets the user data of the call. * * @param userData user data */ void setUserData(const QVariant &userData); Q_SIGNALS: /** * Indicates that the call have finished. */ void finished(PendingCall *call); private: enum ReturnType { ReturnVoid, ReturnUint32, ReturnString, ReturnObjectPath, ReturnFileTransferList, ReturnTransferWithProperties }; explicit PendingCall(const QDBusPendingCall &call, ReturnType type, QObject *parent = nullptr); explicit PendingCall(Error error, const QString &errorText, QObject *parent = nullptr); class PendingCallPrivate *const d; friend class PendingCallPrivate; friend class Manager; friend class Adapter; friend class Device; + friend class LEAdvertisingManager; friend class Media; friend class MediaPlayer; friend class ObexManager; friend class ObexTransfer; friend class ObexSession; friend class ObexObjectPush; friend class ObexFileTransfer; }; } // namespace BluezQt #endif // BLUEZQT_PENDINGCALL_H diff --git a/src/types.h b/src/types.h index 97a254e..cd96fc0 100644 --- a/src/types.h +++ b/src/types.h @@ -1,64 +1,66 @@ /* * BluezQt - Asynchronous BlueZ wrapper library * * Copyright (C) 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_TYPES_H #define BLUEZQT_TYPES_H #include namespace BluezQt { class Manager; class Adapter; class Device; class Input; +class LEAdvertisingManager; class Media; class MediaPlayer; class MediaPlayerTrack; class Agent; class DevicesModel; class InitManagerJob; class Profile; class PendingCall; class ObexManager; class ObexSession; class ObexTransfer; class InitObexManagerJob; class ObexAgent; class ObexFileTransfer; class ObexFileTransferEntry; class ObexObjectPush; typedef QSharedPointer ManagerPtr; typedef QSharedPointer AdapterPtr; typedef QSharedPointer DevicePtr; typedef QSharedPointer InputPtr; +typedef QSharedPointer LEAdvertisingManagerPtr; typedef QSharedPointer MediaPtr; typedef QSharedPointer MediaPlayerPtr; typedef QSharedPointer ObexManagerPtr; typedef QSharedPointer ObexSessionPtr; typedef QSharedPointer ObexTransferPtr; } // namespace BluezQt #endif // BLUEZQT_TYPES_H diff --git a/src/utils.cpp b/src/utils.cpp index 69e43cc..fc1bfe7 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -1,305 +1,312 @@ /* * 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 . */ #include "utils.h" #include "manager.h" #include "obexmanager.h" #include "bluezqt_export.h" #include #include #include namespace BluezQt { class GlobalData { public: explicit GlobalData(); bool testRun; QString orgFreedesktopDBus; QString orgFreedesktopDBusProperties; QString orgBluez; QString orgBluezAdapter1; QString orgBluezDevice1; QString orgBluezInput1; + QString orgBluezLEAdvertisingManager1; QString orgBluezMedia1; QString orgBluezMediaPlayer1; QString orgBluezAgentManager1; QString orgBluezProfileManager1; QString orgBluezObex; QString orgBluezObexClient1; QString orgBluezObexAgentManager1; QString orgBluezObexSession1; QString orgBluezObexTransfer1; QPointer manager; QPointer obexManager; }; GlobalData::GlobalData() { testRun = false; orgFreedesktopDBus = QStringLiteral("org.freedesktop.DBus"); orgFreedesktopDBusProperties = QStringLiteral("org.freedesktop.DBus.Properties"); orgBluez = QStringLiteral("org.bluez"); orgBluezAdapter1 = QStringLiteral("org.bluez.Adapter1"); orgBluezDevice1 = QStringLiteral("org.bluez.Device1"); orgBluezInput1 = QStringLiteral("org.bluez.Input1"); + orgBluezLEAdvertisingManager1 = QStringLiteral("org.bluez.LEAdvertisingManager1"); orgBluezMedia1 = QStringLiteral("org.bluez.Media1"); orgBluezMediaPlayer1 = QStringLiteral("org.bluez.MediaPlayer1"); orgBluezAgentManager1 = QStringLiteral("org.bluez.AgentManager1"); orgBluezProfileManager1 = QStringLiteral("org.bluez.ProfileManager1"); orgBluezObex = QStringLiteral("org.bluez.obex"); orgBluezObexClient1 = QStringLiteral("org.bluez.obex.Client1"); orgBluezObexAgentManager1 = QStringLiteral("org.bluez.obex.AgentManager1"); orgBluezObexSession1 = QStringLiteral("org.bluez.obex.Session1"); orgBluezObexTransfer1 = QStringLiteral("org.bluez.obex.Transfer1"); } Q_GLOBAL_STATIC(GlobalData, globalData) // For fakebluez tests BLUEZQT_EXPORT void bluezqt_initFakeBluezTestRun() { globalData->testRun = true; globalData->orgBluez = QStringLiteral("org.kde.bluezqt.fakebluez"); globalData->orgBluezObex = QStringLiteral("org.kde.bluezqt.fakebluez"); } QString Strings::orgFreedesktopDBus() { return globalData->orgFreedesktopDBus; } QString Strings::orgFreedesktopDBusProperties() { return globalData->orgFreedesktopDBusProperties; } QString Strings::orgBluez() { return globalData->orgBluez; } QString Strings::orgBluezAdapter1() { return globalData->orgBluezAdapter1; } QString Strings::orgBluezDevice1() { return globalData->orgBluezDevice1; } QString Strings::orgBluezInput1() { return globalData->orgBluezInput1; } +QString Strings::orgBluezLEAdvertisingManager1() +{ + return globalData->orgBluezLEAdvertisingManager1; +} + QString Strings::orgBluezMedia1() { return globalData->orgBluezMedia1; } QString Strings::orgBluezMediaPlayer1() { return globalData->orgBluezMediaPlayer1; } QString Strings::orgBluezAgentManager1() { return globalData->orgBluezAgentManager1; } QString Strings::orgBluezProfileManager1() { return globalData->orgBluezProfileManager1; } QString Strings::orgBluezObex() { return globalData->orgBluezObex; } QString Strings::orgBluezObexClient1() { return globalData->orgBluezObexClient1; } QString Strings::orgBluezObexAgentManager1() { return globalData->orgBluezObexAgentManager1; } QString Strings::orgBluezObexSession1() { return globalData->orgBluezObexSession1; } QString Strings::orgBluezObexTransfer1() { return globalData->orgBluezObexTransfer1; } QDBusConnection DBusConnection::orgBluez() { if (globalData->testRun) { return QDBusConnection::sessionBus(); } return QDBusConnection::systemBus(); } QDBusConnection DBusConnection::orgBluezObex() { return QDBusConnection::sessionBus(); } Manager *Instance::manager() { return globalData->manager; } void Instance::setManager(Manager *manager) { globalData->manager = manager; } ObexManager *Instance::obexManager() { return globalData->obexManager; } void Instance::setObexManager(ObexManager *obexManager) { globalData->obexManager = obexManager; } QStringList stringListToUpper(const QStringList &list) { QStringList converted; converted.reserve(list.size()); for (const QString &str : list) { converted.append(str.toUpper()); } return converted; } Device::Type classToType(quint32 classNum) { switch ((classNum & 0x1f00) >> 8) { case 0x01: return Device::Computer; case 0x02: switch ((classNum & 0xfc) >> 2) { case 0x04: return Device::Modem; default: return Device::Phone; } case 0x03: return Device::Network; case 0x04: switch ((classNum & 0xfc) >> 2) { case 0x01: case 0x02: return Device::Headset; case 0x06: return Device::Headphones; default: return Device::AudioVideo; } case 0x05: switch ((classNum & 0xc0) >> 6) { case 0x00: switch ((classNum & 0x1e) >> 2) { case 0x01: case 0x02: return Device::Joypad; } break; case 0x01: return Device::Keyboard; case 0x02: switch ((classNum & 0x1e) >> 2) { case 0x05: return Device::Tablet; default: return Device::Mouse; } } return Device::Peripheral; case 0x06: if (classNum & 0x80) { return Device::Printer; } else if (classNum & 0x20) { return Device::Camera; } return Device::Imaging; case 0x07: return Device::Wearable; case 0x08: return Device::Toy; case 0x09: return Device::Health; default: return Device::Uncategorized; } } Device::Type appearanceToType(quint16 appearance) { switch ((appearance & 0xffc0) >> 6) { case 0x00: return Device::Uncategorized; case 0x01: // Generic Phone return Device::Phone; case 0x02: // Generic Computer return Device::Computer; case 0x05: // Generic Display return Device::AudioVideo; case 0x0a: // Generic Media Player return Device::AudioVideo; case 0x0b: // Generic Barcode Scanner return Device::Peripheral; case 0x0f: // Generic HID switch (appearance & 0x3f) { case 0x01: // Keyboard return Device::Keyboard; case 0x02: // Mouse return Device::Mouse; case 0x03: // Joystick case 0x04: // Gamepad return Device::Joypad; case 0x05: // Digitizer Tablet return Device::Tablet; case 0x08: // Barcode Scanner return Device::Peripheral; } // fall-through default: return Device::Uncategorized; } } } // namespace BluezQt diff --git a/src/utils.h b/src/utils.h index 3e017b5..59b3f31 100644 --- a/src/utils.h +++ b/src/utils.h @@ -1,81 +1,82 @@ /* * 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_UTILS_H #define BLUEZQT_UTILS_H #include "device.h" class QString; class QStringList; class QDBusConnection; namespace BluezQt { namespace Strings { QString orgFreedesktopDBus(); QString orgFreedesktopDBusProperties(); QString orgBluez(); QString orgBluezAdapter1(); QString orgBluezDevice1(); QString orgBluezInput1(); +QString orgBluezLEAdvertisingManager1(); QString orgBluezMedia1(); QString orgBluezMediaPlayer1(); QString orgBluezAgentManager1(); QString orgBluezProfileManager1(); QString orgBluezObex(); QString orgBluezObexClient1(); QString orgBluezObexAgentManager1(); QString orgBluezObexSession1(); QString orgBluezObexTransfer1(); } namespace DBusConnection { QDBusConnection orgBluez(); QDBusConnection orgBluezObex(); } namespace Instance { Manager *manager(); void setManager(Manager *manager); ObexManager *obexManager(); void setObexManager(ObexManager *obexManager); } QStringList stringListToUpper(const QStringList &list); Device::Type classToType(quint32 classNum); Device::Type appearanceToType(quint16 appearance); } // namespace BluezQt #endif // BLUEZQT_UTILS_H