| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/dbus/qdbusconnectioninterface.cpp |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||
|---|---|---|---|---|---|---|---|---|
| 1 | /**************************************************************************** | - | ||||||
| 2 | ** | - | ||||||
| 3 | ** Copyright (C) 2015 The Qt Company Ltd. | - | ||||||
| 4 | ** Contact: http://www.qt.io/licensing/ | - | ||||||
| 5 | ** | - | ||||||
| 6 | ** This file is part of the QtDBus module of the Qt Toolkit. | - | ||||||
| 7 | ** | - | ||||||
| 8 | ** $QT_BEGIN_LICENSE:LGPL21$ | - | ||||||
| 9 | ** Commercial License Usage | - | ||||||
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||
| 11 | ** accordance with the commercial license agreement provided with the | - | ||||||
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||
| 13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||
| 14 | ** and conditions see http://www.qt.io/terms-conditions. For further | - | ||||||
| 15 | ** information use the contact form at http://www.qt.io/contact-us. | - | ||||||
| 16 | ** | - | ||||||
| 17 | ** GNU Lesser General Public License Usage | - | ||||||
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||
| 19 | ** General Public License version 2.1 or version 3 as published by the Free | - | ||||||
| 20 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and | - | ||||||
| 21 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the | - | ||||||
| 22 | ** following information to ensure the GNU Lesser General Public License | - | ||||||
| 23 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and | - | ||||||
| 24 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - | ||||||
| 25 | ** | - | ||||||
| 26 | ** As a special exception, The Qt Company gives you certain additional | - | ||||||
| 27 | ** rights. These rights are described in The Qt Company LGPL Exception | - | ||||||
| 28 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - | ||||||
| 29 | ** | - | ||||||
| 30 | ** $QT_END_LICENSE$ | - | ||||||
| 31 | ** | - | ||||||
| 32 | ****************************************************************************/ | - | ||||||
| 33 | - | |||||||
| 34 | #include "qdbusconnectioninterface.h" | - | ||||||
| 35 | - | |||||||
| 36 | #include <QtCore/QByteArray> | - | ||||||
| 37 | #include <QtCore/QList> | - | ||||||
| 38 | #include <QtCore/QMap> | - | ||||||
| 39 | #include <QtCore/QMetaMethod> | - | ||||||
| 40 | #include <QtCore/QString> | - | ||||||
| 41 | #include <QtCore/QStringList> | - | ||||||
| 42 | #include <QtCore/QVariant> | - | ||||||
| 43 | #include <QtCore/QDebug> | - | ||||||
| 44 | - | |||||||
| 45 | #include "qdbusutil_p.h" // for the DBUS_* constants | - | ||||||
| 46 | - | |||||||
| 47 | #ifndef QT_NO_DBUS | - | ||||||
| 48 | - | |||||||
| 49 | QT_BEGIN_NAMESPACE | - | ||||||
| 50 | - | |||||||
| 51 | /* | - | ||||||
| 52 | * Implementation of interface class QDBusConnectionInterface | - | ||||||
| 53 | */ | - | ||||||
| 54 | - | |||||||
| 55 | /*! | - | ||||||
| 56 | \class QDBusConnectionInterface | - | ||||||
| 57 | \inmodule QtDBus | - | ||||||
| 58 | \since 4.2 | - | ||||||
| 59 | - | |||||||
| 60 | \brief The QDBusConnectionInterface class provides access to the D-Bus bus daemon service. | - | ||||||
| 61 | - | |||||||
| 62 | The D-Bus bus server daemon provides one special interface \c | - | ||||||
| 63 | org.freedesktop.DBus that allows clients to access certain | - | ||||||
| 64 | properties of the bus, such as the current list of clients | - | ||||||
| 65 | connected. The QDBusConnectionInterface class provides access to that | - | ||||||
| 66 | interface. | - | ||||||
| 67 | - | |||||||
| 68 | The most common uses of this class are to register and unregister | - | ||||||
| 69 | service names on the bus using the registerService() and | - | ||||||
| 70 | unregisterService() functions, query about existing names using | - | ||||||
| 71 | the isServiceRegistered(), registeredServiceNames() and | - | ||||||
| 72 | serviceOwner() functions, and to receive notification that a | - | ||||||
| 73 | client has registered or de-registered through the | - | ||||||
| 74 | serviceRegistered(), serviceUnregistered() and serviceOwnerChanged() | - | ||||||
| 75 | signals. | - | ||||||
| 76 | */ | - | ||||||
| 77 | - | |||||||
| 78 | /*! | - | ||||||
| 79 | \enum QDBusConnectionInterface::ServiceQueueOptions | - | ||||||
| 80 | - | |||||||
| 81 | Flags for determining how a service registration should behave, in | - | ||||||
| 82 | case the service name is already registered. | - | ||||||
| 83 | - | |||||||
| 84 | \value DontQueueService If an application requests a name that | - | ||||||
| 85 | is already owned, no queueing will be | - | ||||||
| 86 | performed. The registeredService() | - | ||||||
| 87 | call will simply fail. | - | ||||||
| 88 | This is the default. | - | ||||||
| 89 | - | |||||||
| 90 | \value QueueService Attempts to register the requested | - | ||||||
| 91 | service, but do not try to replace it | - | ||||||
| 92 | if another application already has it | - | ||||||
| 93 | registered. Instead, simply put this | - | ||||||
| 94 | application in queue, until it is | - | ||||||
| 95 | given up. The serviceRegistered() | - | ||||||
| 96 | signal will be emitted when that | - | ||||||
| 97 | happens. | - | ||||||
| 98 | - | |||||||
| 99 | \value ReplaceExistingService If another application already has | - | ||||||
| 100 | the service name registered, attempt | - | ||||||
| 101 | to replace it. | - | ||||||
| 102 | - | |||||||
| 103 | \sa ServiceReplacementOptions | - | ||||||
| 104 | */ | - | ||||||
| 105 | - | |||||||
| 106 | /*! | - | ||||||
| 107 | \enum QDBusConnectionInterface::ServiceReplacementOptions | - | ||||||
| 108 | - | |||||||
| 109 | Flags for determining if the D-Bus server should allow another | - | ||||||
| 110 | application to replace a name that this application has registered | - | ||||||
| 111 | with the ReplaceExistingService option. | - | ||||||
| 112 | - | |||||||
| 113 | The possible values are: | - | ||||||
| 114 | - | |||||||
| 115 | \value DontAllowReplacement Do not allow another application to | - | ||||||
| 116 | replace us. The service must be | - | ||||||
| 117 | explicitly unregistered with | - | ||||||
| 118 | unregisterService() for another | - | ||||||
| 119 | application to acquire it. | - | ||||||
| 120 | This is the default. | - | ||||||
| 121 | - | |||||||
| 122 | \value AllowReplacement Allow other applications to replace us | - | ||||||
| 123 | with the ReplaceExistingService option | - | ||||||
| 124 | to registerService() without | - | ||||||
| 125 | intervention. If that happens, the | - | ||||||
| 126 | serviceUnregistered() signal will be | - | ||||||
| 127 | emitted. | - | ||||||
| 128 | - | |||||||
| 129 | \sa ServiceQueueOptions | - | ||||||
| 130 | */ | - | ||||||
| 131 | - | |||||||
| 132 | /*! | - | ||||||
| 133 | \enum QDBusConnectionInterface::RegisterServiceReply | - | ||||||
| 134 | - | |||||||
| 135 | The possible return values from registerService(): | - | ||||||
| 136 | - | |||||||
| 137 | \value ServiceNotRegistered The call failed and the service name was not registered. | - | ||||||
| 138 | \value ServiceRegistered The caller is now the owner of the service name. | - | ||||||
| 139 | \value ServiceQueued The caller specified the QueueService flag and the | - | ||||||
| 140 | service was already registered, so we are in queue. | - | ||||||
| 141 | - | |||||||
| 142 | The serviceRegistered() signal will be emitted when the service is | - | ||||||
| 143 | acquired by this application. | - | ||||||
| 144 | */ | - | ||||||
| 145 | - | |||||||
| 146 | /*! | - | ||||||
| 147 | \internal | - | ||||||
| 148 | */ | - | ||||||
| 149 | const char *QDBusConnectionInterface::staticInterfaceName() | - | ||||||
| 150 | { never executed: return "org.freedesktop.DBus"; }return "org.freedesktop.DBus";never executed: return "org.freedesktop.DBus"; | 0 | ||||||
| 151 | - | |||||||
| 152 | /*! | - | ||||||
| 153 | \internal | - | ||||||
| 154 | */ | - | ||||||
| 155 | QDBusConnectionInterface::QDBusConnectionInterface(const QDBusConnection &connection, | - | ||||||
| 156 | QObject *parent) | - | ||||||
| 157 | : QDBusAbstractInterface(QDBusUtil::dbusService(), | - | ||||||
| 158 | QDBusUtil::dbusPath(), | - | ||||||
| 159 | DBUS_INTERFACE_DBUS, connection, parent) | - | ||||||
| 160 | { | - | ||||||
| 161 | connect(this, SIGNAL(NameAcquired(QString)), this, SIGNAL(serviceRegistered(QString))); | - | ||||||
| 162 | connect(this, SIGNAL(NameLost(QString)), this, SIGNAL(serviceUnregistered(QString))); | - | ||||||
| 163 | connect(this, SIGNAL(NameOwnerChanged(QString,QString,QString)), | - | ||||||
| 164 | this, SIGNAL(serviceOwnerChanged(QString,QString,QString))); | - | ||||||
| 165 | } executed 323 times by 160 tests: end of blockExecuted by:
| 323 | ||||||
| 166 | - | |||||||
| 167 | /*! | - | ||||||
| 168 | \internal | - | ||||||
| 169 | */ | - | ||||||
| 170 | QDBusConnectionInterface::~QDBusConnectionInterface() | - | ||||||
| 171 | { | - | ||||||
| 172 | } | - | ||||||
| 173 | - | |||||||
| 174 | /*! | - | ||||||
| 175 | Returns the unique connection name of the primary owner of the | - | ||||||
| 176 | name \a name. If the requested name doesn't have an owner, returns | - | ||||||
| 177 | a \c org.freedesktop.DBus.Error.NameHasNoOwner error. | - | ||||||
| 178 | */ | - | ||||||
| 179 | QDBusReply<QString> QDBusConnectionInterface::serviceOwner(const QString &name) const | - | ||||||
| 180 | { | - | ||||||
| 181 | return internalConstCall(QDBus::AutoDetect, QLatin1String("GetNameOwner"), QList<QVariant>() << name); never executed: return internalConstCall(QDBus::AutoDetect, QLatin1String("GetNameOwner"), QList<QVariant>() << name); | 0 | ||||||
| 182 | } | - | ||||||
| 183 | - | |||||||
| 184 | /*! | - | ||||||
| 185 | \property QDBusConnectionInterface::registeredServiceNames | - | ||||||
| 186 | \brief holds the registered service names | - | ||||||
| 187 | - | |||||||
| 188 | Lists all names currently registered on the bus. | - | ||||||
| 189 | */ | - | ||||||
| 190 | QDBusReply<QStringList> QDBusConnectionInterface::registeredServiceNames() const | - | ||||||
| 191 | { | - | ||||||
| 192 | return internalConstCall(QDBus::AutoDetect, QLatin1String("ListNames")); executed 3 times by 1 test: return internalConstCall(QDBus::AutoDetect, QLatin1String("ListNames"));Executed by:
| 3 | ||||||
| 193 | } | - | ||||||
| 194 | - | |||||||
| 195 | /*! | - | ||||||
| 196 | Returns \c true if the service name \a serviceName has is currently | - | ||||||
| 197 | registered. | - | ||||||
| 198 | */ | - | ||||||
| 199 | QDBusReply<bool> QDBusConnectionInterface::isServiceRegistered(const QString &serviceName) const | - | ||||||
| 200 | { | - | ||||||
| 201 | return internalConstCall(QDBus::AutoDetect, QLatin1String("NameHasOwner"), executed 230 times by 149 tests: return internalConstCall(QDBus::AutoDetect, QLatin1String("NameHasOwner"), QList<QVariant>() << serviceName);Executed by:
| 230 | ||||||
| 202 | QList<QVariant>() << serviceName); executed 230 times by 149 tests: return internalConstCall(QDBus::AutoDetect, QLatin1String("NameHasOwner"), QList<QVariant>() << serviceName);Executed by:
| 230 | ||||||
| 203 | } | - | ||||||
| 204 | - | |||||||
| 205 | /*! | - | ||||||
| 206 | Returns the Unix Process ID (PID) for the process currently | - | ||||||
| 207 | holding the bus service \a serviceName. | - | ||||||
| 208 | */ | - | ||||||
| 209 | QDBusReply<uint> QDBusConnectionInterface::servicePid(const QString &serviceName) const | - | ||||||
| 210 | { | - | ||||||
| 211 | return internalConstCall(QDBus::AutoDetect, QLatin1String("GetConnectionUnixProcessID"), never executed: return internalConstCall(QDBus::AutoDetect, QLatin1String("GetConnectionUnixProcessID"), QList<QVariant>() << serviceName); | 0 | ||||||
| 212 | QList<QVariant>() << serviceName); never executed: return internalConstCall(QDBus::AutoDetect, QLatin1String("GetConnectionUnixProcessID"), QList<QVariant>() << serviceName); | 0 | ||||||
| 213 | } | - | ||||||
| 214 | - | |||||||
| 215 | /*! | - | ||||||
| 216 | Returns the Unix User ID (UID) for the process currently holding | - | ||||||
| 217 | the bus service \a serviceName. | - | ||||||
| 218 | */ | - | ||||||
| 219 | QDBusReply<uint> QDBusConnectionInterface::serviceUid(const QString &serviceName) const | - | ||||||
| 220 | { | - | ||||||
| 221 | return internalConstCall(QDBus::AutoDetect, QLatin1String("GetConnectionUnixUser"), never executed: return internalConstCall(QDBus::AutoDetect, QLatin1String("GetConnectionUnixUser"), QList<QVariant>() << serviceName); | 0 | ||||||
| 222 | QList<QVariant>() << serviceName); never executed: return internalConstCall(QDBus::AutoDetect, QLatin1String("GetConnectionUnixUser"), QList<QVariant>() << serviceName); | 0 | ||||||
| 223 | } | - | ||||||
| 224 | - | |||||||
| 225 | /*! | - | ||||||
| 226 | Requests that the bus start the service given by the name \a name. | - | ||||||
| 227 | */ | - | ||||||
| 228 | QDBusReply<void> QDBusConnectionInterface::startService(const QString &name) | - | ||||||
| 229 | { | - | ||||||
| 230 | return call(QLatin1String("StartServiceByName"), name, uint(0)); never executed: return call(QLatin1String("StartServiceByName"), name, uint(0)); | 0 | ||||||
| 231 | } | - | ||||||
| 232 | - | |||||||
| 233 | /*! | - | ||||||
| 234 | Requests to register the service name \a serviceName on the | - | ||||||
| 235 | bus. The \a qoption flag specifies how the D-Bus server should behave | - | ||||||
| 236 | if \a serviceName is already registered. The \a roption flag | - | ||||||
| 237 | specifies if the server should allow another application to | - | ||||||
| 238 | replace our registered name. | - | ||||||
| 239 | - | |||||||
| 240 | If the service registration succeeds, the serviceRegistered() | - | ||||||
| 241 | signal will be emitted. If we are placed in queue, the signal will | - | ||||||
| 242 | be emitted when we obtain the name. If \a roption is | - | ||||||
| 243 | AllowReplacement, the serviceUnregistered() signal will be emitted | - | ||||||
| 244 | if another application replaces this one. | - | ||||||
| 245 | - | |||||||
| 246 | \sa unregisterService() | - | ||||||
| 247 | */ | - | ||||||
| 248 | QDBusReply<QDBusConnectionInterface::RegisterServiceReply> | - | ||||||
| 249 | QDBusConnectionInterface::registerService(const QString &serviceName, | - | ||||||
| 250 | ServiceQueueOptions qoption, | - | ||||||
| 251 | ServiceReplacementOptions roption) | - | ||||||
| 252 | { | - | ||||||
| 253 | // reconstruct the low-level flags | - | ||||||
| 254 | uint flags = 0; | - | ||||||
| 255 | switch (qoption) { | - | ||||||
| 256 | case DontQueueService: executed 31 times by 9 tests: case DontQueueService:Executed by:
| 31 | ||||||
| 257 | flags = DBUS_NAME_FLAG_DO_NOT_QUEUE; | - | ||||||
| 258 | break; executed 31 times by 9 tests: break;Executed by:
| 31 | ||||||
| 259 | case QueueService: never executed: case QueueService: | 0 | ||||||
| 260 | flags = 0; | - | ||||||
| 261 | break; never executed: break; | 0 | ||||||
| 262 | case ReplaceExistingService: never executed: case ReplaceExistingService: | 0 | ||||||
| 263 | flags = DBUS_NAME_FLAG_DO_NOT_QUEUE | DBUS_NAME_FLAG_REPLACE_EXISTING; | - | ||||||
| 264 | break; never executed: break; | 0 | ||||||
| 265 | } | - | ||||||
| 266 | - | |||||||
| 267 | switch (roption) { | - | ||||||
| 268 | case DontAllowReplacement: executed 31 times by 9 tests: case DontAllowReplacement:Executed by:
| 31 | ||||||
| 269 | break; executed 31 times by 9 tests: break;Executed by:
| 31 | ||||||
| 270 | case AllowReplacement: never executed: case AllowReplacement: | 0 | ||||||
| 271 | flags |= DBUS_NAME_FLAG_ALLOW_REPLACEMENT; | - | ||||||
| 272 | break; never executed: break; | 0 | ||||||
| 273 | } | - | ||||||
| 274 | - | |||||||
| 275 | QDBusMessage reply = call(QLatin1String("RequestName"), serviceName, flags); | - | ||||||
| 276 | // qDebug() << "QDBusConnectionInterface::registerService" << serviceName << "Reply:" << reply; | - | ||||||
| 277 | - | |||||||
| 278 | // convert the low-level flags to something that we can use | - | ||||||
| 279 | if (reply.type() == QDBusMessage::ReplyMessage) {
| 0-31 | ||||||
| 280 | uint code = 0; | - | ||||||
| 281 | - | |||||||
| 282 | switch (reply.arguments().at(0).toUInt()) { | - | ||||||
| 283 | case DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER: executed 25 times by 9 tests: case 1:Executed by:
| 25 | ||||||
| 284 | case DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER: executed 6 times by 1 test: case 4:Executed by:
| 6 | ||||||
| 285 | code = uint(ServiceRegistered); | - | ||||||
| 286 | break; executed 31 times by 9 tests: break;Executed by:
| 31 | ||||||
| 287 | - | |||||||
| 288 | case DBUS_REQUEST_NAME_REPLY_EXISTS: never executed: case 3: | 0 | ||||||
| 289 | code = uint(ServiceNotRegistered); | - | ||||||
| 290 | break; never executed: break; | 0 | ||||||
| 291 | - | |||||||
| 292 | case DBUS_REQUEST_NAME_REPLY_IN_QUEUE: never executed: case 2: | 0 | ||||||
| 293 | code = uint(ServiceQueued); | - | ||||||
| 294 | break; never executed: break; | 0 | ||||||
| 295 | } | - | ||||||
| 296 | - | |||||||
| 297 | reply.setArguments(QVariantList() << code); | - | ||||||
| 298 | } executed 31 times by 9 tests: end of blockExecuted by:
| 31 | ||||||
| 299 | - | |||||||
| 300 | return reply; executed 31 times by 9 tests: return reply;Executed by:
| 31 | ||||||
| 301 | } | - | ||||||
| 302 | - | |||||||
| 303 | /*! | - | ||||||
| 304 | Releases the claim on the bus service name \a serviceName, that | - | ||||||
| 305 | had been previously registered with registerService(). If this | - | ||||||
| 306 | application had ownership of the name, it will be released for | - | ||||||
| 307 | other applications to claim. If it only had the name queued, it | - | ||||||
| 308 | gives up its position in the queue. | - | ||||||
| 309 | */ | - | ||||||
| 310 | QDBusReply<bool> | - | ||||||
| 311 | QDBusConnectionInterface::unregisterService(const QString &serviceName) | - | ||||||
| 312 | { | - | ||||||
| 313 | QDBusMessage reply = call(QLatin1String("ReleaseName"), serviceName); | - | ||||||
| 314 | if (reply.type() == QDBusMessage::ReplyMessage) {
| 0-11 | ||||||
| 315 | bool success = reply.arguments().at(0).toUInt() == DBUS_RELEASE_NAME_REPLY_RELEASED; | - | ||||||
| 316 | reply.setArguments(QVariantList() << success); | - | ||||||
| 317 | } executed 11 times by 4 tests: end of blockExecuted by:
| 11 | ||||||
| 318 | return reply; executed 11 times by 4 tests: return reply;Executed by:
| 11 | ||||||
| 319 | } | - | ||||||
| 320 | - | |||||||
| 321 | /*! | - | ||||||
| 322 | \internal | - | ||||||
| 323 | */ | - | ||||||
| 324 | void QDBusConnectionInterface::connectNotify(const QMetaMethod &signal) | - | ||||||
| 325 | { | - | ||||||
| 326 | // translate the signal names to what we really want | - | ||||||
| 327 | // this avoids setting hooks for signals that don't exist on the bus | - | ||||||
| 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)
| 0-971 | ||||||
| 335 | QDBusAbstractInterface::connectNotify(NameAcquiredSignal); never executed: QDBusAbstractInterface::connectNotify(NameAcquiredSignal); | 0 | ||||||
| 336 | - | |||||||
| 337 | else if (signal == serviceUnregisteredSignal)
| 0-971 | ||||||
| 338 | QDBusAbstractInterface::connectNotify(NameLostSignal); never executed: QDBusAbstractInterface::connectNotify(NameLostSignal); | 0 | ||||||
| 339 | - | |||||||
| 340 | else if (signal == serviceOwnerChangedSignal) {
| 1-970 | ||||||
| 341 | static bool warningPrinted = false; | - | ||||||
| 342 | if (!warningPrinted) {
| 0-1 | ||||||
| 343 | qWarning("Connecting to deprecated signal QDBusConnectionInterface::serviceOwnerChanged(QString,QString,QString)"); | - | ||||||
| 344 | warningPrinted = true; | - | ||||||
| 345 | } executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||
| 346 | QDBusAbstractInterface::connectNotify(NameOwnerChangedSignal); | - | ||||||
| 347 | } executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||
| 348 | } executed 971 times by 160 tests: end of blockExecuted by:
| 971 | ||||||
| 349 | - | |||||||
| 350 | /*! | - | ||||||
| 351 | \internal | - | ||||||
| 352 | */ | - | ||||||
| 353 | void QDBusConnectionInterface::disconnectNotify(const QMetaMethod &signal) | - | ||||||
| 354 | { | - | ||||||
| 355 | // translate the signal names to what we really want | - | ||||||
| 356 | // this avoids setting hooks for signals that don't exist on the bus | - | ||||||
| 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)
| 0-2 | ||||||
| 364 | QDBusAbstractInterface::disconnectNotify(NameAcquiredSignal); never executed: QDBusAbstractInterface::disconnectNotify(NameAcquiredSignal); | 0 | ||||||
| 365 | - | |||||||
| 366 | else if (signal == serviceUnregisteredSignal)
| 0-2 | ||||||
| 367 | QDBusAbstractInterface::disconnectNotify(NameLostSignal); never executed: QDBusAbstractInterface::disconnectNotify(NameLostSignal); | 0 | ||||||
| 368 | - | |||||||
| 369 | else if (signal == serviceOwnerChangedSignal)
| 1 | ||||||
| 370 | QDBusAbstractInterface::disconnectNotify(NameOwnerChangedSignal); executed 1 time by 1 test: QDBusAbstractInterface::disconnectNotify(NameOwnerChangedSignal);Executed by:
| 1 | ||||||
| 371 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||
| 372 | - | |||||||
| 373 | // signals | - | ||||||
| 374 | /*! | - | ||||||
| 375 | \fn QDBusConnectionInterface::serviceRegistered(const QString &serviceName) | - | ||||||
| 376 | - | |||||||
| 377 | This signal is emitted by the D-Bus server when the bus service | - | ||||||
| 378 | name (unique connection name or well-known service name) given by | - | ||||||
| 379 | \a serviceName is acquired by this application. | - | ||||||
| 380 | - | |||||||
| 381 | Acquisition happens after this application has requested a name using | - | ||||||
| 382 | registerService(). | - | ||||||
| 383 | */ | - | ||||||
| 384 | - | |||||||
| 385 | /*! | - | ||||||
| 386 | \fn QDBusConnectionInterface::serviceUnregistered(const QString &serviceName) | - | ||||||
| 387 | - | |||||||
| 388 | This signal is emitted by the D-Bus server when this application | - | ||||||
| 389 | loses ownership of the bus service name given by \a serviceName. | - | ||||||
| 390 | */ | - | ||||||
| 391 | - | |||||||
| 392 | /*! | - | ||||||
| 393 | \fn QDBusConnectionInterface::serviceOwnerChanged(const QString &name, const QString &oldOwner, const QString &newOwner) | - | ||||||
| 394 | \deprecated | - | ||||||
| 395 | - | |||||||
| 396 | Use QDBusServiceWatcher instead. | - | ||||||
| 397 | - | |||||||
| 398 | This signal is emitted by the D-Bus server whenever a service | - | ||||||
| 399 | ownership change happens in the bus, including apparition and | - | ||||||
| 400 | disparition of names. | - | ||||||
| 401 | - | |||||||
| 402 | This signal means the application \a oldOwner lost ownership of | - | ||||||
| 403 | bus name \a name to application \a newOwner. If \a oldOwner is an | - | ||||||
| 404 | empty string, it means the name \a name has just been created; if | - | ||||||
| 405 | \a newOwner is empty, the name \a name has no current owner and is | - | ||||||
| 406 | no longer available. | - | ||||||
| 407 | - | |||||||
| 408 | \note connecting to this signal will make the application listen for and | - | ||||||
| 409 | receive every single service ownership change on the bus. Depending on | - | ||||||
| 410 | how many services are running, this make the application be activated to | - | ||||||
| 411 | receive more signals than it needs. To avoid this problem, use the | - | ||||||
| 412 | QDBusServiceWatcher class, which can listen for specific changes. | - | ||||||
| 413 | */ | - | ||||||
| 414 | - | |||||||
| 415 | /*! | - | ||||||
| 416 | \fn void QDBusConnectionInterface::callWithCallbackFailed(const QDBusError &error, const QDBusMessage &call) | - | ||||||
| 417 | - | |||||||
| 418 | This signal is emitted when there is an error during a | - | ||||||
| 419 | QDBusConnection::callWithCallback(). \a error specifies the error. | - | ||||||
| 420 | \a call is the message that couldn't be delivered. | - | ||||||
| 421 | - | |||||||
| 422 | \sa QDBusConnection::callWithCallback() | - | ||||||
| 423 | */ | - | ||||||
| 424 | - | |||||||
| 425 | QT_END_NAMESPACE | - | ||||||
| 426 | - | |||||||
| 427 | #endif // QT_NO_DBUS | - | ||||||
| Source code | Switch to Preprocessed file |