7#include <QtCore/QByteArray>
10#include <QtCore/QMetaMethod>
11#include <QtCore/QString>
12#include <QtCore/QStringList>
13#include <QtCore/QVariant>
14#include <QtCore/QDebug>
22using namespace Qt::StringLiterals;
25
26
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
106
107
108
109
110
111
112
113
114
115
116
117
120
121
122const char *QDBusConnectionInterface::staticInterfaceName()
123{
return "org.freedesktop.DBus"; }
126
127
128QDBusConnectionInterface::QDBusConnectionInterface(
const QDBusConnection &connection,
130 : QDBusAbstractInterface(QDBusUtil::dbusService(),
131 QDBusUtil::dbusPath(),
134 connect(
this, &QDBusConnectionInterface::NameAcquired,
this, emit &QDBusConnectionInterface::serviceRegistered);
135 connect(
this, &QDBusConnectionInterface::NameLost,
this, emit &QDBusConnectionInterface::serviceUnregistered);
136 connect(
this, &QDBusConnectionInterface::NameOwnerChanged,
137 this, emit &QDBusConnectionInterface::serviceOwnerChanged);
141
142
143QDBusConnectionInterface::~QDBusConnectionInterface()
148
149
150
151
152QDBusReply<QString> QDBusConnectionInterface::serviceOwner(
const QString &name)
const
154 return internalConstCall(QDBus::AutoDetect,
"GetNameOwner"_L1, QList<QVariant>() << name);
158
159
160
161
162
163QDBusReply<QStringList> QDBusConnectionInterface::registeredServiceNames()
const
165 return internalConstCall(QDBus::AutoDetect,
"ListNames"_L1);
169
170
171
172
173
174
175QDBusReply<QStringList> QDBusConnectionInterface::activatableServiceNames()
const
177 return internalConstCall(QDBus::AutoDetect,
"ListActivatableNames"_L1);
181
182
183
184QDBusReply<
bool> QDBusConnectionInterface::isServiceRegistered(
const QString &serviceName)
const
186 return internalConstCall(QDBus::AutoDetect,
"NameHasOwner"_L1,
187 QList<QVariant>() << serviceName);
191
192
193
194QDBusReply<uint> QDBusConnectionInterface::servicePid(
const QString &serviceName)
const
196 return internalConstCall(QDBus::AutoDetect,
"GetConnectionUnixProcessID"_L1,
197 QList<QVariant>() << serviceName);
201
202
203
204QDBusReply<uint> QDBusConnectionInterface::serviceUid(
const QString &serviceName)
const
206 return internalConstCall(QDBus::AutoDetect,
"GetConnectionUnixUser"_L1,
207 QList<QVariant>() << serviceName);
211
212
213
214
215
216
217
218
219QDBusReply<QVariantMap> QDBusConnectionInterface::serviceCredentials(
const QString &serviceName)
const
221 return internalConstCall(QDBus::AutoDetect,
"GetConnectionCredentials"_L1,
222 QList<QVariant>() << serviceName);
226
227
228QDBusReply<
void> QDBusConnectionInterface::startService(
const QString &name)
230 return call(
"StartServiceByName"_L1, name, uint(0));
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248QDBusReply<QDBusConnectionInterface::RegisterServiceReply>
249QDBusConnectionInterface::registerService(
const QString &serviceName,
250 ServiceQueueOptions qoption,
251 ServiceReplacementOptions roption)
256 case DontQueueService:
262 case ReplaceExistingService:
268 case DontAllowReplacement:
270 case AllowReplacement:
275 QDBusMessage reply = call(
"RequestName"_L1, serviceName, flags);
279 if (reply.type() == QDBusMessage::ReplyMessage) {
282 switch (reply.arguments().at(0).toUInt()) {
285 code = uint(ServiceRegistered);
289 code = uint(ServiceNotRegistered);
293 code = uint(ServiceQueued);
297 reply.setArguments(QVariantList() << code);
304
305
306
307
308
309
311QDBusConnectionInterface::unregisterService(
const QString &serviceName)
313 QDBusMessage reply = call(
"ReleaseName"_L1, serviceName);
314 if (reply.type() == QDBusMessage::ReplyMessage) {
316 reply.setArguments(QVariantList() << success);
322
323
324void QDBusConnectionInterface::connectNotify(
const QMetaMethod &signal)
328 static const QMetaMethod serviceRegisteredSignal = QMetaMethod::fromSignal(&QDBusConnectionInterface::serviceRegistered);
329 static const QMetaMethod serviceUnregisteredSignal = QMetaMethod::fromSignal(&QDBusConnectionInterface::serviceUnregistered);
330 static const QMetaMethod serviceOwnerChangedSignal = QMetaMethod::fromSignal(&QDBusConnectionInterface::serviceOwnerChanged);
331 static const QMetaMethod NameAcquiredSignal = QMetaMethod::fromSignal(&QDBusConnectionInterface::NameAcquired);
332 static const QMetaMethod NameLostSignal = QMetaMethod::fromSignal(&QDBusConnectionInterface::NameLost);
333 static const QMetaMethod NameOwnerChangedSignal = QMetaMethod::fromSignal(&QDBusConnectionInterface::NameOwnerChanged);
334 if (signal == serviceRegisteredSignal)
335 QDBusAbstractInterface::connectNotify(NameAcquiredSignal);
337 else if (signal == serviceUnregisteredSignal)
338 QDBusAbstractInterface::connectNotify(NameLostSignal);
340 else if (signal == serviceOwnerChangedSignal) {
341 static bool warningPrinted =
false;
342 if (!warningPrinted) {
343 qWarning(
"Connecting to deprecated signal QDBusConnectionInterface::serviceOwnerChanged(QString,QString,QString)");
344 warningPrinted =
true;
346 QDBusAbstractInterface::connectNotify(NameOwnerChangedSignal);
351
352
353void QDBusConnectionInterface::disconnectNotify(
const QMetaMethod &signal)
357 static const QMetaMethod serviceRegisteredSignal = QMetaMethod::fromSignal(&QDBusConnectionInterface::serviceRegistered);
358 static const QMetaMethod serviceUnregisteredSignal = QMetaMethod::fromSignal(&QDBusConnectionInterface::serviceUnregistered);
359 static const QMetaMethod serviceOwnerChangedSignal = QMetaMethod::fromSignal(&QDBusConnectionInterface::serviceOwnerChanged);
360 static const QMetaMethod NameAcquiredSignal = QMetaMethod::fromSignal(&QDBusConnectionInterface::NameAcquired);
361 static const QMetaMethod NameLostSignal = QMetaMethod::fromSignal(&QDBusConnectionInterface::NameLost);
362 static const QMetaMethod NameOwnerChangedSignal = QMetaMethod::fromSignal(&QDBusConnectionInterface::NameOwnerChanged);
363 if (signal == serviceRegisteredSignal)
364 QDBusAbstractInterface::disconnectNotify(NameAcquiredSignal);
366 else if (signal == serviceUnregisteredSignal)
367 QDBusAbstractInterface::disconnectNotify(NameLostSignal);
369 else if (signal == serviceOwnerChangedSignal)
370 QDBusAbstractInterface::disconnectNotify(NameOwnerChangedSignal);
375
376
377
378
379
380
381
382
383
386
387
388
389
390
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
416
417
418
419
420
421
422
423
427#include "moc_qdbusconnectioninterface.cpp"
#define DBUS_NAME_FLAG_REPLACE_EXISTING
#define DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER
#define DBUS_NAME_FLAG_DO_NOT_QUEUE
#define DBUS_NAME_FLAG_ALLOW_REPLACEMENT
#define DBUS_INTERFACE_DBUS
#define DBUS_REQUEST_NAME_REPLY_EXISTS
#define DBUS_REQUEST_NAME_REPLY_IN_QUEUE
#define DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER
#define DBUS_RELEASE_NAME_REPLY_RELEASED