Skip to content

Commit ce6c375

Browse files
committed
Use MauiKit System for Bluetooth adapter power control
- Simplified Valenz’s Bluetooth toggle path in src/controllers/valenzbridge_properties.cpp to defer adapter power changes to MauiKitSystem::setControlCenterBluetoothEnabled(bool). - Removed the duplicated direct BlueZ D-Bus adapter-management code, including the custom managed-object type definitions and related Qt D-Bus includes. - Leaves Valenz consuming the shared MauiKit System Bluetooth control layer instead of maintaining its own BlueZ adapter toggle implementation.
1 parent 95e077c commit ce6c375

1 file changed

Lines changed: 1 addition & 71 deletions

File tree

src/controllers/valenzbridge_properties.cpp

Lines changed: 1 addition & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -2,82 +2,12 @@
22
#include "valenzbridge_p.h"
33
#include "mauikit_system_control.h"
44

5-
#include <QDBusConnection>
6-
#include <QDBusInterface>
7-
#include <QDBusObjectPath>
8-
#include <QDBusReply>
9-
#include <QDBusVariant>
10-
#include <QDBusMetaType>
11-
#include <QMap>
12-
#include <QVariant>
13-
14-
namespace
15-
{
16-
using BluezPropertyMap = QMap<QString, QVariant>;
17-
using BluezInterfaceMap = QMap<QString, BluezPropertyMap>;
18-
using BluezManagedObjects = QMap<QDBusObjectPath, BluezInterfaceMap>;
19-
}
20-
21-
Q_DECLARE_METATYPE(BluezPropertyMap)
22-
Q_DECLARE_METATYPE(BluezInterfaceMap)
23-
Q_DECLARE_METATYPE(BluezManagedObjects)
24-
255
namespace
266
{
277

288
bool setBluezAdapterPowered(bool enabled)
299
{
30-
qDBusRegisterMetaType<BluezPropertyMap>();
31-
qDBusRegisterMetaType<BluezInterfaceMap>();
32-
qDBusRegisterMetaType<BluezManagedObjects>();
33-
34-
QDBusInterface objectsIface(QStringLiteral("org.bluez"),
35-
QStringLiteral("/"),
36-
QStringLiteral("org.freedesktop.DBus.ObjectManager"),
37-
QDBusConnection::systemBus());
38-
if (!objectsIface.isValid())
39-
return false;
40-
41-
const QDBusReply<BluezManagedObjects> reply = objectsIface.call(QStringLiteral("GetManagedObjects"));
42-
if (!reply.isValid())
43-
return false;
44-
45-
const BluezManagedObjects objects = reply.value();
46-
bool anyAdapter = false;
47-
bool allSucceeded = true;
48-
49-
for (const QDBusObjectPath &path : objects.keys())
50-
{
51-
const BluezInterfaceMap interfaces = objects.value(path);
52-
if (!interfaces.contains(QStringLiteral("org.bluez.Adapter1")))
53-
continue;
54-
55-
anyAdapter = true;
56-
57-
QDBusInterface propertiesIface(QStringLiteral("org.bluez"),
58-
path.path(),
59-
QStringLiteral("org.freedesktop.DBus.Properties"),
60-
QDBusConnection::systemBus());
61-
if (!propertiesIface.isValid())
62-
{
63-
allSucceeded = false;
64-
continue;
65-
}
66-
67-
QDBusMessage setCall = QDBusMessage::createMethodCall(QStringLiteral("org.bluez"),
68-
path.path(),
69-
QStringLiteral("org.freedesktop.DBus.Properties"),
70-
QStringLiteral("Set"));
71-
setCall.setArguments({QStringLiteral("org.bluez.Adapter1"),
72-
QStringLiteral("Powered"),
73-
QVariant::fromValue(QDBusVariant(QVariant(enabled)))});
74-
75-
const QDBusMessage result = QDBusConnection::systemBus().call(setCall);
76-
if (result.type() == QDBusMessage::ErrorMessage)
77-
allSucceeded = false;
78-
}
79-
80-
return anyAdapter && allSucceeded;
10+
return MauiKitSystem::setControlCenterBluetoothEnabled(enabled);
8111
}
8212

8313
}

0 commit comments

Comments
 (0)