|
1 |
| -pragma ComponentBehavior: Bound |
2 |
| -pragma ValueTypeBehavior: Addressable |
3 |
| - |
4 | 1 | import QtQuick
|
5 |
| -import org.kde.plasma.workspace.dbus as DBus |
6 | 2 |
|
7 |
| -QtObject { |
| 3 | +Item { |
8 | 4 | id: root
|
9 |
| - property string busType: DBus.BusType.Session |
| 5 | + property string busType |
10 | 6 | property string service: ""
|
11 | 7 | property string objectPath: ""
|
12 | 8 | property string iface: ""
|
13 | 9 | property string method: ""
|
14 | 10 | property var arguments: []
|
15 | 11 | property var signature: null
|
16 | 12 | property var inSignature: null
|
| 13 | + property bool useGdbus: false |
| 14 | + |
| 15 | + onArgumentsChanged: dbusLoader.item.arguments = root.arguments |
17 | 16 |
|
18 |
| - property DBus.dbusMessage msg: { |
19 |
| - "service": root.service, |
20 |
| - "path": root.objectPath, |
21 |
| - "iface": root.iface, |
22 |
| - "member": root.method, |
23 |
| - "arguments": root.arguments, |
24 |
| - "signature": root.signature, |
25 |
| - "inSignature": root.inSignature, |
| 17 | + Loader { |
| 18 | + id: dbusLoader |
| 19 | + source: root.useGdbus ? "DBusFallback.qml" : "DBusPrimary.qml" |
| 20 | + onStatusChanged: { |
| 21 | + if (status === Loader.Error) { |
| 22 | + dbusLoader.source = "DBusFallback.qml" |
| 23 | + } |
| 24 | + } |
| 25 | + onLoaded: { |
| 26 | + dbusLoader.item.service = root.service |
| 27 | + dbusLoader.item.objectPath = root.objectPath |
| 28 | + dbusLoader.item.iface = root.iface |
| 29 | + dbusLoader.item.method = root.method |
| 30 | + dbusLoader.item.arguments = root.arguments |
| 31 | + dbusLoader.item.signature = root.signature |
| 32 | + dbusLoader.item.inSignature = root.inSignature |
| 33 | + } |
26 | 34 | }
|
27 | 35 |
|
28 | 36 | function call(callback) {
|
29 |
| - const reply = DBus.SessionBus.asyncCall(root.msg) as DBus.DBusPendingReply |
30 |
| - if (callback) { |
31 |
| - reply.finished.connect(() => callback(reply)) |
| 37 | + if (dbusLoader.item && typeof dbusLoader.item.call === "function") { |
| 38 | + dbusLoader.item.call(callback); |
| 39 | + } else { |
| 40 | + console.error("No valid DBus implementation loaded."); |
32 | 41 | }
|
33 | 42 | }
|
34 | 43 | }
|
0 commit comments