summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSami Nurmenniemi <sami.nurmenniemi@qt.io>2017-11-03 16:18:07 +0200
committerSami Nurmenniemi <sami.nurmenniemi@qt.io>2017-11-22 10:42:02 +0000
commit860cfc1d38b707fc06055c9e9d56751bb65cb2d1 (patch)
treeb78a07eb2c144699999653560398765729db02fe
parentd1fcfe58025603ae28e8fda31d96519a92cdb7dd (diff)
Bluetooth on/off switch now enables/disables bluetooth device
Task-number: QTBUG-64230 Change-Id: I151933f74f459f245822a5986b009d686ce6fdfd Reviewed-by: Kari Oikarinen <kari.oikarinen@qt.io> Reviewed-by: Teemu Holappa <teemu.holappa@qt.io>
-rw-r--r--src/bluetoothsettings/bluez/bluetoothdevice_p.cpp7
-rw-r--r--src/bluetoothsettings/bluez/bluetoothdevice_p.h2
-rw-r--r--src/bluetoothsettings/bluez/bluez.pri4
-rw-r--r--src/networksettings/connman/connmancommon.cpp3
-rw-r--r--src/networksettings/connman/connmancommon.h1
-rw-r--r--src/settingsui/network/NetworkSettings.qml1
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<ManagedObjectList> 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 {