From 860cfc1d38b707fc06055c9e9d56751bb65cb2d1 Mon Sep 17 00:00:00 2001 From: Sami Nurmenniemi Date: Fri, 3 Nov 2017 16:18:07 +0200 Subject: Bluetooth on/off switch now enables/disables bluetooth device Task-number: QTBUG-64230 Change-Id: I151933f74f459f245822a5986b009d686ce6fdfd Reviewed-by: Kari Oikarinen Reviewed-by: Teemu Holappa --- src/bluetoothsettings/bluez/bluetoothdevice_p.cpp | 7 +++++++ src/bluetoothsettings/bluez/bluetoothdevice_p.h | 2 ++ src/bluetoothsettings/bluez/bluez.pri | 4 +++- src/networksettings/connman/connmancommon.cpp | 3 +++ src/networksettings/connman/connmancommon.h | 1 + src/settingsui/network/NetworkSettings.qml | 1 - 6 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/bluetoothsettings/bluez/bluetoothdevice_p.cpp b/src/bluetoothsettings/bluez/bluetoothdevice_p.cpp index 4705ac4..4440277 100644 --- a/src/bluetoothsettings/bluez/bluetoothdevice_p.cpp +++ b/src/bluetoothsettings/bluez/bluetoothdevice_p.cpp @@ -32,6 +32,8 @@ #include "objectmanager_interface.cpp" #include "moc_objectmanager_interface.cpp" #include "device1_interface.h" +#include "connman_technology_interface.h" +#include "connmancommon.h" BluetoothDevicePrivate::BluetoothDevicePrivate(BluetoothDevice *parent) : QObject(parent) ,q_ptr(parent) @@ -47,6 +49,9 @@ BluetoothDevicePrivate::BluetoothDevicePrivate(BluetoothDevice *parent) : QObjec m_manager = new OrgFreedesktopDBusObjectManagerInterface(QStringLiteral("org.bluez"), QStringLiteral("/"), QDBusConnection::systemBus(), this); + m_technology = new NetConnmanTechnologyInterface(QStringLiteral("net.connman"), + QStringLiteral("/net/connman/technology/bluetooth"), + QDBusConnection::systemBus(), this); QDBusPendingReply reply = m_manager->GetManagedObjects(); QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this); connect(watcher, &QDBusPendingCallWatcher::finished, @@ -70,6 +75,8 @@ void BluetoothDevicePrivate::setPowered(const bool& aPowered) if (!m_localDevice) return; + m_technology->SetProperty(PropertyPowered, QDBusVariant(QVariant(aPowered))); + if (aPowered) { m_localDevice->powerOn(); } diff --git a/src/bluetoothsettings/bluez/bluetoothdevice_p.h b/src/bluetoothsettings/bluez/bluetoothdevice_p.h index 432a7e7..c3cc3f3 100644 --- a/src/bluetoothsettings/bluez/bluetoothdevice_p.h +++ b/src/bluetoothsettings/bluez/bluetoothdevice_p.h @@ -47,6 +47,7 @@ class OrgBluezDevice1Interface; class OrgFreedesktopDBusObjectManagerInterface; +class NetConnmanTechnologyInterface; class BluetoothDevicePrivate : public QObject { @@ -88,6 +89,7 @@ private: QString m_adapter; DiscoveryModel *m_deviceModel; OrgFreedesktopDBusObjectManagerInterface *m_manager; + NetConnmanTechnologyInterface *m_technology; }; diff --git a/src/bluetoothsettings/bluez/bluez.pri b/src/bluetoothsettings/bluez/bluez.pri index b8d39fd..2aad8b8 100644 --- a/src/bluetoothsettings/bluez/bluez.pri +++ b/src/bluetoothsettings/bluez/bluez.pri @@ -2,10 +2,12 @@ QT += core dbus INCLUDEPATH += $${PWD} INCLUDEPATH += $${PWD}/bluez +INCLUDEPATH += $${PWD}/../../networksettings/connman DBUS_INTERFACES = \ $${PWD}/objectmanager.xml \ - $${PWD}/device1.xml + $${PWD}/device1.xml \ + $${PWD}/../../networksettings/connman/connman_technology.xml HEADERS += \ $$PWD/bluetoothdevice_p.h \ diff --git a/src/networksettings/connman/connmancommon.cpp b/src/networksettings/connman/connmancommon.cpp index f609f22..572c564 100644 --- a/src/networksettings/connman/connmancommon.cpp +++ b/src/networksettings/connman/connmancommon.cpp @@ -53,6 +53,9 @@ const QString &operator>>(const QString &argument, QNetworkSettingsType &obj) else if (argument == AttributeWifi) { obj.setType(QNetworkSettingsType::Wifi); } + else if (argument == AttributeBluetooth) { + obj.setType(QNetworkSettingsType::Bluetooth); + } else { obj.setType(QNetworkSettingsType::Unknown); } diff --git a/src/networksettings/connman/connmancommon.h b/src/networksettings/connman/connmancommon.h index 212e12d..8153507 100644 --- a/src/networksettings/connman/connmancommon.h +++ b/src/networksettings/connman/connmancommon.h @@ -42,6 +42,7 @@ #define AttributeWifi QStringLiteral("wifi") #define AttributeEthernet QStringLiteral("ethernet") +#define AttributeBluetooth QStringLiteral("bluetooth") #define AttributeIdle QStringLiteral("idle") #define AttributeFailure QStringLiteral("failure") #define AttributeAssociation QStringLiteral("association") diff --git a/src/settingsui/network/NetworkSettings.qml b/src/settingsui/network/NetworkSettings.qml index 719ce77..c357671 100644 --- a/src/settingsui/network/NetworkSettings.qml +++ b/src/settingsui/network/NetworkSettings.qml @@ -30,7 +30,6 @@ import QtQuick 2.6 import QtQuick.Layouts 1.3 import QtQuick.Controls 2.2 import QtDeviceUtilities.NetworkSettings 1.0 -import QtDeviceUtilities.BluetoothSettings 1.0 import "../common" Item { -- cgit v1.2.3