summaryrefslogtreecommitdiffstats
path: root/src/bluetoothsettings
diff options
context:
space:
mode:
Diffstat (limited to 'src/bluetoothsettings')
-rw-r--r--src/bluetoothsettings/bluetoothdevice.cpp185
-rw-r--r--src/bluetoothsettings/bluetoothdevice.h71
-rw-r--r--src/bluetoothsettings/bluetoothsettings.pro18
-rw-r--r--src/bluetoothsettings/bluez/bluetoothdevice_p.cpp278
-rw-r--r--src/bluetoothsettings/bluez/bluetoothdevice_p.h106
-rw-r--r--src/bluetoothsettings/bluez/bluez.pri22
-rw-r--r--src/bluetoothsettings/bluez/datatypes.h50
-rw-r--r--src/bluetoothsettings/bluez/device1.xml31
-rw-r--r--src/bluetoothsettings/bluez/objectmanager.xml20
-rw-r--r--src/bluetoothsettings/discoverymodel.cpp270
-rw-r--r--src/bluetoothsettings/discoverymodel.h127
11 files changed, 0 insertions, 1178 deletions
diff --git a/src/bluetoothsettings/bluetoothdevice.cpp b/src/bluetoothsettings/bluetoothdevice.cpp
deleted file mode 100644
index dda2386..0000000
--- a/src/bluetoothsettings/bluetoothdevice.cpp
+++ /dev/null
@@ -1,185 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Device Utilities module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) any later version
-** approved by the KDE Free Qt Foundation. The licenses are as published by
-** the Free Software Foundation and appearing in the file LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <discoverymodel.h>
-#include "bluetoothdevice.h"
-#include "bluetoothdevice_p.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \module QtBluetoothSettings
- \qtvariable bluetoothsettings
- \ingroup qtdevice-utilities-cpp-modules
- \ingroup modules
- \title Qt Bluetooth Settings C++ Classes
- \brief Provides functionality for controlling Bluetooth settings.
-
- To use classes from this module, add this directive into the C++ files:
-
- \code
- #include <QtBluetoothSettings>
- \endcode
-
- To link against the corresponding C++ libraries, add the following to your
- qmake project file:
-
- \code
- QT += bluetoothsettings
- \endcode
-*/
-
-/*!
- \class BluetoothDevice
- \inmodule QtBluetoothSettings
-
- \brief The BluetoothDevice class controls Bluetooth settings.
-
- The Bluetooth settings contain information about the local Bluetooth device,
- such as the device model and whether the device is powered on and available
- for connections with other Bluetooth devices.
-
- The Bluetooth device can scan for other Bluetooth devices in range and
- retrieve information about them. The Bluetooth device then uses the address
- of another device to attempt pairing to it, and connects to it if the
- pairing was successful.
-*/
-
-/*!
- \property BluetoothDevice::scanning
- \brief Whether the Bluetooth device is scanning for remote devices.
-*/
-
-/*!
- \property BluetoothDevice::powered
- \brief Whether the power in the Bluetooth device is on or off.
-*/
-
-/*!
- \property BluetoothDevice::available
- \brief Whether the Bluetooth device is available.
-*/
-
-/*!
- \property BluetoothDevice::deviceModel
- \brief The model of the Bluetooth device.
-*/
-
-/*!
- Creates a new Bluetooth device with the parent \a parent.
-*/
-BluetoothDevice::BluetoothDevice(QObject *parent) : QObject(parent)
- ,d_ptr(new BluetoothDevicePrivate(this))
-{
-}
-
-/*!
- Returns \c true if the power is switched on in the Bluetooth device.
-*/
-bool BluetoothDevice::powered() const
-{
- Q_D(const BluetoothDevice);
- return d->powered();
-}
-
-/*!
- Sets the powered state in the Bluetooth device to \a aPowered.
-*/
-void BluetoothDevice::setPowered(const bool& aPowered)
-{
- Q_D(BluetoothDevice);
- d->setPowered(aPowered);
-}
-
-/*!
- Returns the model of the Bluetooth device.
-*/
-DiscoveryModel* BluetoothDevice::deviceModel() const
-{
- Q_D(const BluetoothDevice);
- return d->deviceModel();
-}
-
-/*!
- Returns whether the Bluetooth device is scanning for remote devices.
-*/
-bool BluetoothDevice::scanning() const
-{
- Q_D(const BluetoothDevice);
- return d->scanning();
-}
-
-/*!
- Sets scanning in the Bluetooth device to \a aScan.
-*/
-void BluetoothDevice::setScanning(const bool& aScan)
-{
- Q_D(BluetoothDevice);
- d->setScanning(aScan);
-}
-
-/*!
- Starts the process of pairing to a remote device specified by \a address,
- and connects to it if the pairing was successful.
-
- \sa requestConnect
-*/
-void BluetoothDevice::requestPairing(const QString& address)
-{
- Q_D(BluetoothDevice);
- d->requestPairing(address);
-}
-
-/*!
- Connects to the remote device specified by \a address.
-*/
-void BluetoothDevice::requestConnect(const QString& address)
-{
- Q_D(BluetoothDevice);
- d->requestConnect(address);
-}
-
-/*!
- Disconnects from the remote device specified by \a address.
-*/
-void BluetoothDevice::requestDisconnect(const QString& address)
-{
- Q_D(BluetoothDevice);
- d->requestDisconnect(address);
-}
-
-/*!
- Returns the availability of the Bluetooth device.
-*/
-bool BluetoothDevice::available() const
-{
- Q_D(const BluetoothDevice);
- return d->available();
-}
-
-QT_END_NAMESPACE
diff --git a/src/bluetoothsettings/bluetoothdevice.h b/src/bluetoothsettings/bluetoothdevice.h
deleted file mode 100644
index 1c51b87..0000000
--- a/src/bluetoothsettings/bluetoothdevice.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Device Utilities module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) any later version
-** approved by the KDE Free Qt Foundation. The licenses are as published by
-** the Free Software Foundation and appearing in the file LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef BLUETOOTHDEVICE_H
-#define BLUETOOTHDEVICE_H
-
-#include <QObject>
-#include "discoverymodel.h"
-
-QT_FORWARD_DECLARE_CLASS(DiscoveryModel)
-QT_FORWARD_DECLARE_CLASS(BluetoothDevicePrivate)
-
-QT_BEGIN_NAMESPACE
-
-class Q_DECL_EXPORT BluetoothDevice : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(bool scanning READ scanning WRITE setScanning NOTIFY scanningChanged)
- Q_PROPERTY(bool powered READ powered WRITE setPowered NOTIFY poweredChanged)
- Q_PROPERTY(bool available READ available NOTIFY availabilityChanged)
- Q_PROPERTY(DiscoveryModel* deviceModel READ deviceModel CONSTANT)
-public:
- explicit BluetoothDevice(QObject *parent = Q_NULLPTR);
- bool powered() const;
- void setPowered(const bool& aPowered);
- DiscoveryModel *deviceModel() const;
- bool scanning() const;
- void setScanning(const bool& aScan);
- bool available() const;
- Q_INVOKABLE void requestPairing(const QString& address);
- Q_INVOKABLE void requestConnect(const QString& address);
- Q_INVOKABLE void requestDisconnect(const QString& address);
-Q_SIGNALS:
- void poweredChanged();
- void scanningChanged();
- void availabilityChanged();
-protected:
- BluetoothDevicePrivate *d_ptr;
-private:
-Q_DISABLE_COPY(BluetoothDevice)
-Q_DECLARE_PRIVATE(BluetoothDevice)
-};
-
-QT_END_NAMESPACE
-
-#endif // BLUETOOTHDEVICE_H
diff --git a/src/bluetoothsettings/bluetoothsettings.pro b/src/bluetoothsettings/bluetoothsettings.pro
deleted file mode 100644
index 7f46c58..0000000
--- a/src/bluetoothsettings/bluetoothsettings.pro
+++ /dev/null
@@ -1,18 +0,0 @@
-load(qt_build_config)
-
-TARGET = QtBluetoothSettings
-VERSION = 1.0
-
-QT += core bluetooth
-
-MODULE = bluetoothsettings
-load(qt_module)
-
-include(bluez/bluez.pri)
-
-HEADERS += \
- bluetoothdevice.h \
- discoverymodel.h
-
-SOURCES += bluetoothdevice.cpp \
- discoverymodel.cpp
diff --git a/src/bluetoothsettings/bluez/bluetoothdevice_p.cpp b/src/bluetoothsettings/bluez/bluetoothdevice_p.cpp
deleted file mode 100644
index 7b29ec9..0000000
--- a/src/bluetoothsettings/bluez/bluetoothdevice_p.cpp
+++ /dev/null
@@ -1,278 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Device Utilities module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) any later version
-** approved by the KDE Free Qt Foundation. The licenses are as published by
-** the Free Software Foundation and appearing in the file LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include "discoverymodel.h"
-#include "bluetoothdevice_p.h"
-#include "datatypes.h"
-#include "objectmanager_interface.cpp"
-#include "moc_objectmanager_interface.cpp"
-#include "device1_interface.h"
-
-#ifdef USE_CONNMAN_BLUETOOTH
-#include "connman_technology_interface.h"
-#include "connmancommon.h"
-#endif
-
-QT_BEGIN_NAMESPACE
-
-BluetoothDevicePrivate::BluetoothDevicePrivate(BluetoothDevice *parent) : QObject(parent)
- ,q_ptr(parent)
- ,m_localDevice(Q_NULLPTR)
- ,m_powered(false)
- ,m_scanning(false)
- ,m_adapter(QStringLiteral(""))
- ,m_deviceModel(new DiscoveryModel(this))
-{
- qDBusRegisterMetaType<InterfaceList>();
- qDBusRegisterMetaType<ManagedObjectList>();
-
- m_manager = new OrgFreedesktopDBusObjectManagerInterface(QStringLiteral("org.bluez"),
- QStringLiteral("/"),
- QDBusConnection::systemBus(), this);
-#ifdef USE_CONNMAN_BLUETOOTH
- m_technology = new NetConnmanTechnologyInterface(QStringLiteral("net.connman"),
- QStringLiteral("/net/connman/technology/bluetooth"),
- QDBusConnection::systemBus(), this);
-#endif
- QDBusPendingReply<ManagedObjectList> reply = m_manager->GetManagedObjects();
- QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this);
- connect(watcher, &QDBusPendingCallWatcher::finished,
- this, &BluetoothDevicePrivate::getManagedObjectsFinished, Qt::QueuedConnection);
-}
-
-void BluetoothDevicePrivate::deviceStateChanged(QBluetoothLocalDevice::HostMode state)
-{
- Q_Q(BluetoothDevice);
- m_powered = state != QBluetoothLocalDevice::HostPoweredOff;
- emit q->poweredChanged();
-}
-
-bool BluetoothDevicePrivate::powered() const
-{
- return m_powered;
-}
-
-void BluetoothDevicePrivate::setPowered(const bool& aPowered)
-{
- if (!m_localDevice)
- return;
-
-#ifdef USE_CONNMAN_BLUETOOTH
- m_technology->SetProperty(PropertyPowered, QDBusVariant(QVariant(aPowered)));
-#endif
-
- if (aPowered) {
- m_localDevice->powerOn();
- }
- else {
- m_localDevice->setHostMode(QBluetoothLocalDevice::HostPoweredOff);
- }
-}
-
-DiscoveryModel* BluetoothDevicePrivate::deviceModel() const
-{
- return m_deviceModel;
-}
-
-void BluetoothDevicePrivate::scanFinished()
-{
- Q_Q(BluetoothDevice);
- m_scanning = false;
- emit q->scanningChanged();
- updateConnectionStatuses();
-}
-
-bool BluetoothDevicePrivate::scanning() const
-{
- return m_scanning;
-}
-
-void BluetoothDevicePrivate::setScanning(const bool& aScan)
-{
- Q_Q(BluetoothDevice);
- if (m_scanning && !aScan) {
- m_deviceModel->stopScanning();
- }
- else if (aScan && !m_scanning) {
- m_deviceModel->scanDevices();
- }
- m_scanning = aScan;
- emit q->scanningChanged();
-}
-
-bool BluetoothDevicePrivate::available() const
-{
- return (!m_adapter.isEmpty());
-}
-
-void BluetoothDevicePrivate::updateConnectionStatuses()
-{
- QList<QBluetoothAddress> connectedDevices =
- m_localDevice->connectedDevices();
-
- foreach (QBluetoothAddress addr, connectedDevices) {
- m_deviceModel->setConnected(addr.toString(), true);
- }
-}
-
-void BluetoothDevicePrivate::requestPairing(const QString& address)
-{
- QBluetoothAddress addr(address);
- if (m_localDevice) {
- m_localDevice->requestPairing(addr, QBluetoothLocalDevice::Paired);
- connect(m_localDevice, &QBluetoothLocalDevice::pairingDisplayConfirmation, this, &BluetoothDevicePrivate::pairingDisplayConfirmation);
-
- connect(m_localDevice, &QBluetoothLocalDevice::pairingDisplayPinCode, this, &BluetoothDevicePrivate::pairingDisplayPinCode);
-
- connect(m_localDevice, &QBluetoothLocalDevice::pairingFinished, this, &BluetoothDevicePrivate::pairingFinished);
- }
-}
-
-void BluetoothDevicePrivate::requestConnect(const QString &address)
-{
- OrgBluezDevice1Interface *dev = findPeerDevice(address);
- if (dev) {
- dev->Connect();
- dev->deleteLater();
- }
-}
-
-void BluetoothDevicePrivate::requestDisconnect(const QString& address)
-{
- OrgBluezDevice1Interface *dev = findPeerDevice(address);
- if (dev) {
- dev->Disconnect();
- dev->deleteLater();
- }
-}
-
-void BluetoothDevicePrivate::pairingDisplayConfirmation(const QBluetoothAddress & address, QString pin)
-{
- Q_UNUSED(address);
- Q_UNUSED(pin);
-}
-
-void BluetoothDevicePrivate::pairingDisplayPinCode(const QBluetoothAddress & address, QString pin)
-{
- Q_UNUSED(address);
- Q_UNUSED(pin);
-}
-
-void BluetoothDevicePrivate::pairingFinished(const QBluetoothAddress & address, QBluetoothLocalDevice::Pairing pairing)
-{
- if (pairing == QBluetoothLocalDevice::Paired) {
- requestConnect(address.toString());
- }
-}
-
-void BluetoothDevicePrivate::deviceConnected(const QBluetoothAddress & address)
-{
- m_deviceModel->setConnected(address.toString(), true);
-}
-
-void BluetoothDevicePrivate::deviceDisconnected(const QBluetoothAddress & address)
-{
- m_deviceModel->setConnected(address.toString(), false);
-}
-
-void BluetoothDevicePrivate::getManagedObjectsFinished(QDBusPendingCallWatcher *watcher)
-{
- Q_Q(BluetoothDevice);
-
- QDBusPendingReply<ManagedObjectList> reply = *watcher;
- watcher->deleteLater();
- if (reply.isError()) {
- return;
- }
-
- //Find adapter
- ManagedObjectList managedObjectList = reply.value();
- for (ManagedObjectList::const_iterator it = managedObjectList.constBegin(); it != managedObjectList.constEnd(); ++it) {
- const InterfaceList &ifaceList = it.value();
- for (InterfaceList::const_iterator jt = ifaceList.constBegin(); jt != ifaceList.constEnd(); ++jt) {
- const QString &iface = jt.key();
- const QVariantMap &ifaceValues = jt.value();
-
- if (iface == QStringLiteral("org.bluez.Adapter1")) {
- m_adapter = ifaceValues[QStringLiteral("Address")].toString();
- break;
- }
- }
- }
-
- if (!m_adapter.isEmpty()) {
- m_localDevice = new QBluetoothLocalDevice(this);
- m_powered = m_localDevice->hostMode() != QBluetoothLocalDevice::HostPoweredOff;
-
- connect(m_localDevice, &QBluetoothLocalDevice::hostModeStateChanged, this, &BluetoothDevicePrivate::deviceStateChanged);
- connect(m_localDevice, &QBluetoothLocalDevice::deviceConnected, this, &BluetoothDevicePrivate::deviceConnected);
- connect(m_localDevice, &QBluetoothLocalDevice::deviceDisconnected, this, &BluetoothDevicePrivate::deviceDisconnected);
- connect(m_deviceModel, &DiscoveryModel::scanFinished, this, &BluetoothDevicePrivate::scanFinished);
-
- if (m_powered) {
- emit q->poweredChanged();
- if (!m_scanning) {
- m_deviceModel->scanDevices();
- m_scanning = true;
- emit q->scanningChanged();
- }
- }
-
- emit q->availabilityChanged();
- }
-}
-
-OrgBluezDevice1Interface* BluetoothDevicePrivate::findPeerDevice(const QString &address)
-{
- QDBusPendingReply<ManagedObjectList> reply = m_manager->GetManagedObjects();
- reply.waitForFinished();
- if (reply.isError()) {
- qWarning() << "Failed to get objects";
- return NULL;
- }
-
- ManagedObjectList managedObjectList = reply.value();
- for (ManagedObjectList::const_iterator it = managedObjectList.constBegin(); it != managedObjectList.constEnd(); ++it) {
- const QDBusObjectPath &path = it.key();
-
- const InterfaceList &ifaceList = it.value();
- for (InterfaceList::const_iterator jt = ifaceList.constBegin(); jt != ifaceList.constEnd(); ++jt) {
- const QString &iface = jt.key();
- const QVariantMap &ifaceValues = jt.value();
- if (iface == QStringLiteral("org.bluez.Device1")) {
- if (ifaceValues[QStringLiteral("Address")] == address) {
- OrgBluezDevice1Interface *devIf = new OrgBluezDevice1Interface(QStringLiteral("org.bluez"), path.path(), QDBusConnection::systemBus());
- return devIf;
- }
- }
- }
- }
- return NULL;
-}
-
-QT_END_NAMESPACE
diff --git a/src/bluetoothsettings/bluez/bluetoothdevice_p.h b/src/bluetoothsettings/bluez/bluetoothdevice_p.h
deleted file mode 100644
index 0e1777e..0000000
--- a/src/bluetoothsettings/bluez/bluetoothdevice_p.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Device Utilities module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) any later version
-** approved by the KDE Free Qt Foundation. The licenses are as published by
-** the Free Software Foundation and appearing in the file LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef BLUETOOTHDEVICE__P_H
-#define BLUETOOTHDEVICE__P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of other Qt classes. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QObject>
-#include <QBluetoothLocalDevice>
-#include <QtDBus>
-#include "bluetoothdevice.h"
-
-// Automatically generated classes in global namespace
-class OrgBluezDevice1Interface;
-class OrgFreedesktopDBusObjectManagerInterface;
-
-#ifdef USE_CONNMAN_BLUETOOTH
-class NetConnmanTechnologyInterface;
-#endif
-
-QT_BEGIN_NAMESPACE
-
-class BluetoothDevicePrivate : public QObject
-{
- Q_OBJECT
- Q_DECLARE_PUBLIC(BluetoothDevice)
-public:
- BluetoothDevice *q_ptr;
- BluetoothDevicePrivate(BluetoothDevice *parent);
- bool powered() const;
- void setPowered(const bool& aPowered);
- bool scanning() const;
- bool available() const;
- void setScanning(const bool& aScan);
- void requestPairing(const QString& address);
- void requestConnect(const QString& address);
- void requestDisconnect(const QString& address);
- DiscoveryModel* deviceModel() const;
-
-public Q_SLOTS:
- void deviceStateChanged(QBluetoothLocalDevice::HostMode state);
- void scanFinished();
- //These are not yet signaled
- //See bug https://bugreports.qt.io/browse/QTBUG-38401
- void pairingDisplayConfirmation(const QBluetoothAddress & address, QString pin);
- void pairingDisplayPinCode(const QBluetoothAddress & address, QString pin);
- void pairingFinished(const QBluetoothAddress & address, QBluetoothLocalDevice::Pairing pairing);
- void deviceConnected(const QBluetoothAddress & address);
- void deviceDisconnected(const QBluetoothAddress & address);
- void getManagedObjectsFinished(QDBusPendingCallWatcher *watcher);
-
-private:
- void updateConnectionStatuses();
- OrgBluezDevice1Interface* findPeerDevice(const QString& address);
-
-private:
- QBluetoothLocalDevice* m_localDevice;
- bool m_powered;
- bool m_scanning;
- QString m_adapter;
- DiscoveryModel *m_deviceModel;
- OrgFreedesktopDBusObjectManagerInterface *m_manager;
-
-#ifdef USE_CONNMAN_BLUETOOTH
- NetConnmanTechnologyInterface *m_technology;
-#endif
-};
-
-QT_END_NAMESPACE
-
-#endif // BLUETOOTHDEVICE__P_H
diff --git a/src/bluetoothsettings/bluez/bluez.pri b/src/bluetoothsettings/bluez/bluez.pri
deleted file mode 100644
index 60a3b17..0000000
--- a/src/bluetoothsettings/bluez/bluez.pri
+++ /dev/null
@@ -1,22 +0,0 @@
-QT += core dbus
-
-INCLUDEPATH += $${PWD}
-INCLUDEPATH += $${PWD}/bluez
-
-DBUS_INTERFACES = \
- $${PWD}/objectmanager.xml \
- $${PWD}/device1.xml
-
-HEADERS += \
- $$PWD/bluetoothdevice_p.h \
- $$PWD/datatypes.h \
-
-SOURCES += \
- $$PWD/bluetoothdevice_p.cpp
-
-qtHaveModule(networksettings) {
- DEFINES += USE_CONNMAN_BLUETOOTH
- INCLUDEPATH += $${PWD}/../../networksettings/connman
- DBUS_INTERFACES += $${PWD}/../../networksettings/connman/connman_technology.xml
-
-}
diff --git a/src/bluetoothsettings/bluez/datatypes.h b/src/bluetoothsettings/bluez/datatypes.h
deleted file mode 100644
index 9458dbe..0000000
--- a/src/bluetoothsettings/bluez/datatypes.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Device Utilities module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) any later version
-** approved by the KDE Free Qt Foundation. The licenses are as published by
-** the Free Software Foundation and appearing in the file LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef DATATYPES_H
-#define DATATYPES_H
-
-#include <QObject>
-#include <QtDBus>
-#include <QMap>
-#include <QVariantMap>
-#include <QtDBus/QDBusObjectPath>
-#include <QtCore/QMetaType>
-
-QT_BEGIN_NAMESPACE
-
-typedef QMap<QString, QVariantMap> InterfaceList;
-typedef QMap<QDBusObjectPath, InterfaceList> ManagedObjectList;
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(InterfaceList)
-Q_DECLARE_METATYPE(ManagedObjectList)
-
-
-#endif // DATATYPES_H
diff --git a/src/bluetoothsettings/bluez/device1.xml b/src/bluetoothsettings/bluez/device1.xml
deleted file mode 100644
index 5b16992..0000000
--- a/src/bluetoothsettings/bluez/device1.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
- "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
-<node>
- <interface name="org.bluez.Device1">
- <method name="Disconnect"></method>
- <method name="Connect"></method>
- <method name="ConnectProfile">
- <arg name="UUID" type="s" direction="in"/>
- </method>
- <method name="DisconnectProfile">
- <arg name="UUID" type="s" direction="in"/>
- </method>
- <method name="Pair"></method>
- <method name="CancelPairing"></method>
- <property name="Address" type="s" access="read"></property>
- <property name="Name" type="s" access="read"></property>
- <property name="Alias" type="s" access="readwrite"></property>
- <property name="Appearance" type="q" access="read"></property>
- <property name="Icon" type="s" access="read"></property>
- <property name="Paired" type="b" access="read"></property>
- <property name="Trusted" type="b" access="readwrite"></property>
- <property name="Blocked" type="b" access="readwrite"></property>
- <property name="LegacyPairing" type="b" access="read"></property>
- <property name="RSSI" type="n" access="read"></property>
- <property name="Connected" type="b" access="read"></property>
- <property name="UUIDs" type="as" access="read"></property>
- <property name="Modalias" type="s" access="read"></property>
- <property name="Adapter" type="o" access="read"></property>
- </interface>
-</node>
-
diff --git a/src/bluetoothsettings/bluez/objectmanager.xml b/src/bluetoothsettings/bluez/objectmanager.xml
deleted file mode 100644
index e52d6fe..0000000
--- a/src/bluetoothsettings/bluez/objectmanager.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
- "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
-<node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0">
- <interface name="org.freedesktop.DBus.ObjectManager">
- <method name="GetManagedObjects">
- <arg type="a{oa{sa{sv}}}" name="object_paths_interfaces_and_properties" direction="out"/>
- <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="ManagedObjectList"/>
- </method>
- <signal name="InterfacesAdded">
- <arg type="o" name="object_path"/>
- <arg type="a{sa{sv}}" name="interfaces_and_properties"/>
- <annotation name="org.qtproject.QtDBus.QtTypeName.In1" value="InterfaceList"/>
- </signal>
- <signal name="InterfacesRemoved">
- <arg type="o" name="object_path"/>
- <arg type="as" name="interfaces"/>
- </signal>
- </interface>
-</node>
-
diff --git a/src/bluetoothsettings/discoverymodel.cpp b/src/bluetoothsettings/discoverymodel.cpp
deleted file mode 100644
index 31cf972..0000000
--- a/src/bluetoothsettings/discoverymodel.cpp
+++ /dev/null
@@ -1,270 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Device Utilities module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) any later version
-** approved by the KDE Free Qt Foundation. The licenses are as published by
-** the Free Software Foundation and appearing in the file LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <QBluetoothAddress>
-#include "discoverymodel.h"
-
-QT_BEGIN_NAMESPACE
-
-BtDeviceItem::BtDeviceItem(const QBluetoothDeviceInfo& bt, QObject *parent)
- : QObject(parent)
- ,m_name(bt.name())
- ,m_address(bt.address().toString())
- ,m_connected(false)
-{
- m_type = getDeviceType(bt.majorDeviceClass(), bt.minorDeviceClass());
-}
-
-QString BtDeviceItem::name() const
-{
- return m_name;
-}
-
-QString BtDeviceItem::address() const
-{
- return m_address;
-}
-
-bool BtDeviceItem::connected() const
-{
- return m_connected;
-}
-
-void BtDeviceItem::setConnected(bool aConnected)
-{
- m_connected = aConnected;
- emit connectedChanged();
-}
-
-BtDeviceItem::DeviceType BtDeviceItem::type() const
-{
- return m_type;
-}
-
-BtDeviceItem::DeviceType BtDeviceItem::getDeviceType(const QBluetoothDeviceInfo::MajorDeviceClass major, const quint8 minor) const
-{
- switch (major) {
- case QBluetoothDeviceInfo::ComputerDevice:
- return getComputerDeviceType(minor);
- break;
- case QBluetoothDeviceInfo::PhoneDevice:
- return getPhoneDeviceType(minor);
- break;
- case QBluetoothDeviceInfo::AudioVideoDevice:
- return getAudioDeviceType(minor);
- break;
- case QBluetoothDeviceInfo::PeripheralDevice:
- return getPeripheralDeviceType(minor);
- break;
- case QBluetoothDeviceInfo::ImagingDevice:
- return getImagingDeviceType(minor);
- break;
- default:
- return GenericDevice;
- }
- return GenericDevice;
-}
-
-BtDeviceItem::DeviceType BtDeviceItem::getComputerDeviceType(const quint8 minor) const
-{
- Q_UNUSED(minor);
- return Computer;
-}
-
-BtDeviceItem::DeviceType BtDeviceItem::getAudioDeviceType(const quint8 minor) const
-{
- switch (minor) {
- case QBluetoothDeviceInfo::Microphone:
- return Microphone;
- break;
- case QBluetoothDeviceInfo::WearableHeadsetDevice:
- case QBluetoothDeviceInfo::Headphones:
- return Headphones;
- break;
- case QBluetoothDeviceInfo::Camcorder:
- case QBluetoothDeviceInfo::VideoCamera:
- return Camcorder;
- break;
- default:
- return GenericDevice;
- break;
- }
-}
-
-BtDeviceItem::DeviceType BtDeviceItem::getPeripheralDeviceType(const quint8 minor) const
-{
- switch (minor) {
- case QBluetoothDeviceInfo::KeyboardPeripheral:
- return Keyboard;
- break;
- case QBluetoothDeviceInfo::PointingDevicePeripheral:
- return Mouse;
- break;
- default:
- return GenericDevice;
- break;
- }
-}
-
-BtDeviceItem::DeviceType BtDeviceItem::getImagingDeviceType(const quint8 minor) const
-{
- switch (minor) {
- case QBluetoothDeviceInfo::ImageCamera:
- return Camera;
- break;
- default:
- return GenericDevice;
- break;
- }
-}
-
-BtDeviceItem::DeviceType BtDeviceItem::getPhoneDeviceType(const quint8 minor) const
-{
- Q_UNUSED(minor);
- return Phone;
-}
-
-
-DiscoveryModel::DiscoveryModel(QObject *parent)
- : QAbstractListModel(parent)
- ,m_discoveryAgent(Q_NULLPTR)
-{
- m_roleNames.insert(Qt::UserRole, "modelData");
- m_roleNames.insert(Address, "address");
- m_roleNames.insert(Name, "name");
- m_roleNames.insert(Type, "type");
- m_roleNames.insert(Connected, "connected");
-}
-
-void DiscoveryModel::deviceDiscovered(const QBluetoothDeviceInfo &device)
-{
- int index;
-
- // Insert the device to alphabetically sorted location
- for (index = 0; index < m_items.count(); index++)
- {
- if (device.name() < m_items.at(index)->name())
- break;
- }
-
- beginInsertRows(QModelIndex(), index, index);
- BtDeviceItem *item = new BtDeviceItem(device);
- m_items.insert(index, item);
- endInsertRows();
-}
-
-DiscoveryModel::~DiscoveryModel()
-{
-
-}
-
-void DiscoveryModel::scanDevices()
-{
- if (!m_discoveryAgent) {
- m_discoveryAgent = new QBluetoothDeviceDiscoveryAgent(this);
- connect(m_discoveryAgent, SIGNAL(deviceDiscovered(QBluetoothDeviceInfo)),
- this, SLOT(deviceDiscovered(QBluetoothDeviceInfo)));
-
- connect(m_discoveryAgent, SIGNAL(finished()),
- this, SIGNAL(scanFinished()));
- }
-
- // Reset previous list, devices are already cached by bluez
- clearDeviceList();
-
- m_discoveryAgent->start();
-}
-
-void DiscoveryModel::stopScanning()
-{
- if (m_discoveryAgent) {
- m_discoveryAgent->stop();
- }
-}
-
-QHash<int, QByteArray> DiscoveryModel::roleNames() const
-{
- return m_roleNames;
-}
-
-int DiscoveryModel::rowCount(const QModelIndex & parent) const
-{
- Q_UNUSED(parent);
- return m_items.count();
-}
-
-QVariant DiscoveryModel::data(const QModelIndex & index, int role) const
-{
- if (!index.isValid()) return QVariant();
-
- BtDeviceItem *item = m_items[index.row()];
-
- switch (role) {
- case DiscoveryModel::Name:
- return item->name();
- break;
- case DiscoveryModel::Address:
- return item->address();
- break;
- case DiscoveryModel::Type:
- return item->type();
- break;
- case DiscoveryModel::Connected:
- return item->connected();
- default:
- return QVariant();
- }
-}
-
-void DiscoveryModel::setConnected(const QString &aAddress, bool connected)
-{
- bool found = false;
- int i = 0;
- QVector<int> role;
- role.append(DiscoveryModel::Connected);
- foreach (BtDeviceItem *item, m_items) {
- if (item->address() == aAddress) {
- item->setConnected(connected);
- found = true;
- break;
- }
- i++;
- }
-
- if (found)
- emit dataChanged(index(i, 0), index(i, 0), role);
-}
-
-void DiscoveryModel::clearDeviceList()
-{
- beginResetModel();
- m_items.clear();
- endResetModel();
-}
-
-QT_END_NAMESPACE
diff --git a/src/bluetoothsettings/discoverymodel.h b/src/bluetoothsettings/discoverymodel.h
deleted file mode 100644
index 56f8299..0000000
--- a/src/bluetoothsettings/discoverymodel.h
+++ /dev/null
@@ -1,127 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Device Utilities module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) any later version
-** approved by the KDE Free Qt Foundation. The licenses are as published by
-** the Free Software Foundation and appearing in the file LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef DISCOVERYMODEL_H
-#define DISCOVERYMODEL_H
-
-
-#include <QObject>
-#include <QAbstractListModel>
-#include <QBluetoothDeviceInfo>
-#include <QBluetoothDeviceDiscoveryAgent>
-
-QT_BEGIN_NAMESPACE
-
-class Q_DECL_EXPORT BtDeviceItem : public QObject
-{
- Q_OBJECT
- Q_ENUMS(DeviceType)
- Q_PROPERTY(QString address READ address CONSTANT)
- Q_PROPERTY(QString name READ name CONSTANT)
- Q_PROPERTY(bool connected READ connected NOTIFY connectedChanged)
- Q_PROPERTY(DeviceType type READ type CONSTANT)
-public:
- explicit BtDeviceItem(const QBluetoothDeviceInfo& id, QObject *parent = Q_NULLPTR);
- //The list of device type we want to show the icon
- enum DeviceType {
- Phone,
- Computer,
- Mouse,
- Keyboard,
- Headphones,
- Microphone,
- Camera,
- Camcorder,
- Clock,
- HealthDevice,
- GenericDevice=1000
- };
- QString name() const;
- QString address() const;
- DeviceType type() const;
- bool connected() const;
- void setConnected(bool aConnected);
-
-Q_SIGNALS:
- void connectedChanged();
-
-protected:
- DeviceType getDeviceType(const QBluetoothDeviceInfo::MajorDeviceClass major,
- const quint8 minor) const;
- DeviceType getComputerDeviceType(const quint8 minor) const;
- DeviceType getAudioDeviceType(const quint8 minor) const;
- DeviceType getPeripheralDeviceType(const quint8 minor) const;
- DeviceType getImagingDeviceType(const quint8 minor) const;
- DeviceType getHealthDeviceType(const quint8 minor) const;
- DeviceType getPhoneDeviceType(const quint8 minor) const;
-
-private:
- QString m_name;
- QString m_address;
- bool m_connected;
- DeviceType m_type;
-};
-
-class Q_DECL_EXPORT DiscoveryModel : public QAbstractListModel
-{
- Q_OBJECT
- Q_ENUMS(DeviceType)
-public:
- explicit DiscoveryModel(QObject *parent = Q_NULLPTR);
- virtual ~DiscoveryModel();
- // from QAbstractItemModel
- int rowCount(const QModelIndex & parent = QModelIndex()) const;
- QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
- QHash<int, QByteArray> roleNames() const;
- void setConnected(const QString& aAddress, bool connected);
- void scanDevices();
- void stopScanning();
-
- enum Roles {
- Name = Qt::UserRole,
- Address,
- Type,
- Connected
- };
-
-Q_SIGNALS:
- void scanFinished();
-
-private Q_SLOTS:
- void deviceDiscovered(const QBluetoothDeviceInfo &device);
-private:
- void clearDeviceList();
-
- QList<BtDeviceItem*> m_items;
- QHash<int, QByteArray> m_roleNames;
- QBluetoothDeviceDiscoveryAgent *m_discoveryAgent;
-};
-
-QT_END_NAMESPACE
-
-#endif // DISCOVERYMODEL_H