| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/dbus/qdbusabstractadaptor.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 "qdbusabstractadaptor.h" | - | ||||||||||||
| 35 | #include "qdbusabstractadaptor_p.h" | - | ||||||||||||
| 36 | - | |||||||||||||
| 37 | #include <QtCore/qcoreapplication.h> | - | ||||||||||||
| 38 | #include <QtCore/qmetaobject.h> | - | ||||||||||||
| 39 | #include <QtCore/qset.h> | - | ||||||||||||
| 40 | #include <QtCore/qtimer.h> | - | ||||||||||||
| 41 | #include <QtCore/qthread.h> | - | ||||||||||||
| 42 | - | |||||||||||||
| 43 | #include "qdbusconnection.h" | - | ||||||||||||
| 44 | - | |||||||||||||
| 45 | #include "qdbusconnection_p.h" // for qDBusParametersForMethod | - | ||||||||||||
| 46 | #include "qdbusmetatype_p.h" | - | ||||||||||||
| 47 | - | |||||||||||||
| 48 | #include <algorithm> | - | ||||||||||||
| 49 | - | |||||||||||||
| 50 | #ifndef QT_NO_DBUS | - | ||||||||||||
| 51 | - | |||||||||||||
| 52 | QT_BEGIN_NAMESPACE | - | ||||||||||||
| 53 | - | |||||||||||||
| 54 | static int cachedRelaySlotMethodIndex = -1; | - | ||||||||||||
| 55 | - | |||||||||||||
| 56 | int QDBusAdaptorConnector::relaySlotMethodIndex() | - | ||||||||||||
| 57 | { | - | ||||||||||||
| 58 | if (cachedRelaySlotMethodIndex == -1) {
| 12-508 | ||||||||||||
| 59 | cachedRelaySlotMethodIndex = staticMetaObject.indexOfMethod("relaySlot()"); | - | ||||||||||||
| 60 | Q_ASSERT(cachedRelaySlotMethodIndex != -1); | - | ||||||||||||
| 61 | } executed 12 times by 10 tests: end of blockExecuted by:
| 12 | ||||||||||||
| 62 | return cachedRelaySlotMethodIndex; executed 520 times by 10 tests: return cachedRelaySlotMethodIndex;Executed by:
| 520 | ||||||||||||
| 63 | } | - | ||||||||||||
| 64 | - | |||||||||||||
| 65 | QDBusAdaptorConnector *qDBusFindAdaptorConnector(QObject *obj) | - | ||||||||||||
| 66 | { | - | ||||||||||||
| 67 | if (!obj)
| 0-884 | ||||||||||||
| 68 | return 0; never executed: return 0; | 0 | ||||||||||||
| 69 | const QObjectList &children = obj->children(); | - | ||||||||||||
| 70 | QObjectList::ConstIterator it = children.constBegin(); | - | ||||||||||||
| 71 | QObjectList::ConstIterator end = children.constEnd(); | - | ||||||||||||
| 72 | for ( ; it != end; ++it) {
| 122-1455 | ||||||||||||
| 73 | QDBusAdaptorConnector *connector = qobject_cast<QDBusAdaptorConnector *>(*it); | - | ||||||||||||
| 74 | if (connector) {
| 693-762 | ||||||||||||
| 75 | connector->polish(); | - | ||||||||||||
| 76 | return connector; executed 762 times by 7 tests: return connector;Executed by:
| 762 | ||||||||||||
| 77 | } | - | ||||||||||||
| 78 | } executed 693 times by 5 tests: end of blockExecuted by:
| 693 | ||||||||||||
| 79 | return 0; executed 122 times by 10 tests: return 0;Executed by:
| 122 | ||||||||||||
| 80 | } | - | ||||||||||||
| 81 | - | |||||||||||||
| 82 | QDBusAdaptorConnector *qDBusFindAdaptorConnector(QDBusAbstractAdaptor *adaptor) | - | ||||||||||||
| 83 | { | - | ||||||||||||
| 84 | return qDBusFindAdaptorConnector(adaptor->parent()); never executed: return qDBusFindAdaptorConnector(adaptor->parent()); | 0 | ||||||||||||
| 85 | } | - | ||||||||||||
| 86 | - | |||||||||||||
| 87 | QDBusAdaptorConnector *qDBusCreateAdaptorConnector(QObject *obj) | - | ||||||||||||
| 88 | { | - | ||||||||||||
| 89 | QDBusAdaptorConnector *connector = qDBusFindAdaptorConnector(obj); | - | ||||||||||||
| 90 | if (connector)
| 122-324 | ||||||||||||
| 91 | return connector; executed 324 times by 6 tests: return connector;Executed by:
| 324 | ||||||||||||
| 92 | return new QDBusAdaptorConnector(obj); executed 122 times by 10 tests: return new QDBusAdaptorConnector(obj);Executed by:
| 122 | ||||||||||||
| 93 | } | - | ||||||||||||
| 94 | - | |||||||||||||
| 95 | QString QDBusAbstractAdaptorPrivate::retrieveIntrospectionXml(QDBusAbstractAdaptor *adaptor) | - | ||||||||||||
| 96 | { | - | ||||||||||||
| 97 | return adaptor->d_func()->xml; executed 129 times by 5 tests: return adaptor->d_func()->xml;Executed by:
| 129 | ||||||||||||
| 98 | } | - | ||||||||||||
| 99 | - | |||||||||||||
| 100 | void QDBusAbstractAdaptorPrivate::saveIntrospectionXml(QDBusAbstractAdaptor *adaptor, | - | ||||||||||||
| 101 | const QString &xml) | - | ||||||||||||
| 102 | { | - | ||||||||||||
| 103 | adaptor->d_func()->xml = xml; | - | ||||||||||||
| 104 | } executed 89 times by 5 tests: end of blockExecuted by:
| 89 | ||||||||||||
| 105 | - | |||||||||||||
| 106 | /*! | - | ||||||||||||
| 107 | \class QDBusAbstractAdaptor | - | ||||||||||||
| 108 | \inmodule QtDBus | - | ||||||||||||
| 109 | \since 4.2 | - | ||||||||||||
| 110 | - | |||||||||||||
| 111 | \brief The QDBusAbstractAdaptor class is the base class of D-Bus adaptor classes. | - | ||||||||||||
| 112 | - | |||||||||||||
| 113 | The QDBusAbstractAdaptor class is the starting point for all objects intending to provide | - | ||||||||||||
| 114 | interfaces to the external world using D-Bus. This is accomplished by attaching a one or more | - | ||||||||||||
| 115 | classes derived from QDBusAbstractAdaptor to a normal QObject and then registering that QObject | - | ||||||||||||
| 116 | with QDBusConnection::registerObject. QDBusAbstractAdaptor objects are intended to be | - | ||||||||||||
| 117 | light-weight wrappers, mostly just relaying calls into the real object (its parent) and the | - | ||||||||||||
| 118 | signals from it. | - | ||||||||||||
| 119 | - | |||||||||||||
| 120 | Each QDBusAbstractAdaptor-derived class should define the D-Bus interface it is implementing | - | ||||||||||||
| 121 | using the Q_CLASSINFO macro in the class definition. Note that only one interface can be | - | ||||||||||||
| 122 | exposed in this way. | - | ||||||||||||
| 123 | - | |||||||||||||
| 124 | QDBusAbstractAdaptor uses the standard QObject mechanism of signals, slots and properties to | - | ||||||||||||
| 125 | determine what signals, methods and properties to export to the bus. Any signal emitted by | - | ||||||||||||
| 126 | QDBusAbstractAdaptor-derived classes will be automatically be relayed through any D-Bus | - | ||||||||||||
| 127 | connections the object is registered on. | - | ||||||||||||
| 128 | - | |||||||||||||
| 129 | Classes derived from QDBusAbstractAdaptor must be created on the heap using the \a new operator | - | ||||||||||||
| 130 | and must not be deleted by the user (they will be deleted automatically when the object they are | - | ||||||||||||
| 131 | connected to is also deleted). | - | ||||||||||||
| 132 | - | |||||||||||||
| 133 | \sa {usingadaptors.html}{Using adaptors}, QDBusConnection | - | ||||||||||||
| 134 | */ | - | ||||||||||||
| 135 | - | |||||||||||||
| 136 | /*! | - | ||||||||||||
| 137 | Constructs a QDBusAbstractAdaptor with \a obj as the parent object. | - | ||||||||||||
| 138 | */ | - | ||||||||||||
| 139 | QDBusAbstractAdaptor::QDBusAbstractAdaptor(QObject* obj) | - | ||||||||||||
| 140 | : QObject(*new QDBusAbstractAdaptorPrivate, obj) | - | ||||||||||||
| 141 | { | - | ||||||||||||
| 142 | QDBusAdaptorConnector *connector = qDBusCreateAdaptorConnector(obj); | - | ||||||||||||
| 143 | - | |||||||||||||
| 144 | connector->waitingForPolish = true; | - | ||||||||||||
| 145 | QMetaObject::invokeMethod(connector, "polish", Qt::QueuedConnection); | - | ||||||||||||
| 146 | } executed 200 times by 5 tests: end of blockExecuted by:
| 200 | ||||||||||||
| 147 | - | |||||||||||||
| 148 | /*! | - | ||||||||||||
| 149 | Destroys the adaptor. | - | ||||||||||||
| 150 | - | |||||||||||||
| 151 | \warning Adaptors are destroyed automatically when the real object they refer to is | - | ||||||||||||
| 152 | destroyed. Do not delete the adaptors yourself. | - | ||||||||||||
| 153 | */ | - | ||||||||||||
| 154 | QDBusAbstractAdaptor::~QDBusAbstractAdaptor() | - | ||||||||||||
| 155 | { | - | ||||||||||||
| 156 | } | - | ||||||||||||
| 157 | - | |||||||||||||
| 158 | /*! | - | ||||||||||||
| 159 | Toggles automatic signal relaying from the real object (see object()). | - | ||||||||||||
| 160 | - | |||||||||||||
| 161 | Automatic signal relaying consists of signal-to-signal connection of the signals on the parent | - | ||||||||||||
| 162 | that have the exact same method signatue in both classes. | - | ||||||||||||
| 163 | - | |||||||||||||
| 164 | If \a enable is set to true, connect the signals; if set to false, disconnect all signals. | - | ||||||||||||
| 165 | */ | - | ||||||||||||
| 166 | void QDBusAbstractAdaptor::setAutoRelaySignals(bool enable) | - | ||||||||||||
| 167 | { | - | ||||||||||||
| 168 | const QMetaObject *us = metaObject(); | - | ||||||||||||
| 169 | const QMetaObject *them = parent()->metaObject(); | - | ||||||||||||
| 170 | bool connected = false; | - | ||||||||||||
| 171 | for (int idx = staticMetaObject.methodCount(); idx < us->methodCount(); ++idx) {
| 124-632 | ||||||||||||
| 172 | QMetaMethod mm = us->method(idx); | - | ||||||||||||
| 173 | - | |||||||||||||
| 174 | if (mm.methodType() != QMetaMethod::Signal)
| 268-364 | ||||||||||||
| 175 | continue; executed 364 times by 1 test: continue;Executed by:
| 364 | ||||||||||||
| 176 | - | |||||||||||||
| 177 | // try to connect/disconnect to a signal on the parent that has the same method signature | - | ||||||||||||
| 178 | QByteArray sig = QMetaObject::normalizedSignature(mm.methodSignature().constData()); | - | ||||||||||||
| 179 | if (them->indexOfSignal(sig) == -1)
| 0-268 | ||||||||||||
| 180 | continue; executed 268 times by 1 test: continue;Executed by:
| 268 | ||||||||||||
| 181 | sig.prepend(QSIGNAL_CODE + '0'); | - | ||||||||||||
| 182 | parent()->disconnect(sig, this, sig); | - | ||||||||||||
| 183 | if (enable)
| 0 | ||||||||||||
| 184 | connected = connect(parent(), sig, sig) || connected; never executed: connected = connect(parent(), sig, sig) || connected;
| 0 | ||||||||||||
| 185 | } never executed: end of block | 0 | ||||||||||||
| 186 | d_func()->autoRelaySignals = connected; | - | ||||||||||||
| 187 | } executed 124 times by 1 test: end of blockExecuted by:
| 124 | ||||||||||||
| 188 | - | |||||||||||||
| 189 | /*! | - | ||||||||||||
| 190 | Returns \c true if automatic signal relaying from the real object (see object()) is enabled, | - | ||||||||||||
| 191 | otherwiser returns \c false. | - | ||||||||||||
| 192 | - | |||||||||||||
| 193 | \sa setAutoRelaySignals() | - | ||||||||||||
| 194 | */ | - | ||||||||||||
| 195 | bool QDBusAbstractAdaptor::autoRelaySignals() const | - | ||||||||||||
| 196 | { | - | ||||||||||||
| 197 | return d_func()->autoRelaySignals; never executed: return d_func()->autoRelaySignals; | 0 | ||||||||||||
| 198 | } | - | ||||||||||||
| 199 | - | |||||||||||||
| 200 | QDBusAdaptorConnector::QDBusAdaptorConnector(QObject *obj) | - | ||||||||||||
| 201 | : QObject(obj), waitingForPolish(false) | - | ||||||||||||
| 202 | { | - | ||||||||||||
| 203 | } executed 122 times by 10 tests: end of blockExecuted by:
| 122 | ||||||||||||
| 204 | - | |||||||||||||
| 205 | QDBusAdaptorConnector::~QDBusAdaptorConnector() | - | ||||||||||||
| 206 | { | - | ||||||||||||
| 207 | } | - | ||||||||||||
| 208 | - | |||||||||||||
| 209 | void QDBusAdaptorConnector::addAdaptor(QDBusAbstractAdaptor *adaptor) | - | ||||||||||||
| 210 | { | - | ||||||||||||
| 211 | // find the interface name | - | ||||||||||||
| 212 | const QMetaObject *mo = adaptor->metaObject(); | - | ||||||||||||
| 213 | int ciid = mo->indexOfClassInfo(QCLASSINFO_DBUS_INTERFACE); | - | ||||||||||||
| 214 | if (ciid != -1) {
| 124-424 | ||||||||||||
| 215 | QMetaClassInfo mci = mo->classInfo(ciid); | - | ||||||||||||
| 216 | if (*mci.value()) {
| 0-424 | ||||||||||||
| 217 | // find out if this interface exists first | - | ||||||||||||
| 218 | const char *interface = mci.value(); | - | ||||||||||||
| 219 | AdaptorMap::Iterator it = std::lower_bound(adaptors.begin(), adaptors.end(), | - | ||||||||||||
| 220 | QByteArray(interface)); | - | ||||||||||||
| 221 | if (it != adaptors.end() && qstrcmp(interface, it->interface) == 0) {
| 76-348 | ||||||||||||
| 222 | // exists. Replace it (though it's probably the same) | - | ||||||||||||
| 223 | if (it->adaptor != adaptor) {
| 0-224 | ||||||||||||
| 224 | // reconnect the signals | - | ||||||||||||
| 225 | disconnectAllSignals(it->adaptor); | - | ||||||||||||
| 226 | connectAllSignals(adaptor); | - | ||||||||||||
| 227 | } never executed: end of block | 0 | ||||||||||||
| 228 | it->adaptor = adaptor; | - | ||||||||||||
| 229 | } else { executed 224 times by 1 test: end of blockExecuted by:
| 224 | ||||||||||||
| 230 | // create a new one | - | ||||||||||||
| 231 | AdaptorData entry; | - | ||||||||||||
| 232 | entry.interface = interface; | - | ||||||||||||
| 233 | entry.adaptor = adaptor; | - | ||||||||||||
| 234 | adaptors << entry; | - | ||||||||||||
| 235 | - | |||||||||||||
| 236 | // connect the adaptor's signals to our relaySlot slot | - | ||||||||||||
| 237 | connectAllSignals(adaptor); | - | ||||||||||||
| 238 | } executed 200 times by 5 tests: end of blockExecuted by:
| 200 | ||||||||||||
| 239 | } | - | ||||||||||||
| 240 | } executed 424 times by 5 tests: end of blockExecuted by:
| 424 | ||||||||||||
| 241 | } executed 548 times by 5 tests: end of blockExecuted by:
| 548 | ||||||||||||
| 242 | - | |||||||||||||
| 243 | void QDBusAdaptorConnector::disconnectAllSignals(QObject *obj) | - | ||||||||||||
| 244 | { | - | ||||||||||||
| 245 | QMetaObject::disconnect(obj, -1, this, relaySlotMethodIndex()); | - | ||||||||||||
| 246 | } executed 160 times by 7 tests: end of blockExecuted by:
| 160 | ||||||||||||
| 247 | - | |||||||||||||
| 248 | void QDBusAdaptorConnector::connectAllSignals(QObject *obj) | - | ||||||||||||
| 249 | { | - | ||||||||||||
| 250 | QMetaObject::connect(obj, -1, this, relaySlotMethodIndex(), Qt::DirectConnection); | - | ||||||||||||
| 251 | } executed 360 times by 10 tests: end of blockExecuted by:
| 360 | ||||||||||||
| 252 | - | |||||||||||||
| 253 | void QDBusAdaptorConnector::polish() | - | ||||||||||||
| 254 | { | - | ||||||||||||
| 255 | if (!waitingForPolish)
| 200-690 | ||||||||||||
| 256 | return; // avoid working multiple times if multiple adaptors were added executed 690 times by 7 tests: return;Executed by:
| 690 | ||||||||||||
| 257 | - | |||||||||||||
| 258 | waitingForPolish = false; | - | ||||||||||||
| 259 | const QObjectList &objs = parent()->children(); | - | ||||||||||||
| 260 | QObjectList::ConstIterator it = objs.constBegin(); | - | ||||||||||||
| 261 | QObjectList::ConstIterator end = objs.constEnd(); | - | ||||||||||||
| 262 | for ( ; it != end; ++it) {
| 200-748 | ||||||||||||
| 263 | QDBusAbstractAdaptor *adaptor = qobject_cast<QDBusAbstractAdaptor *>(*it); | - | ||||||||||||
| 264 | if (adaptor)
| 200-548 | ||||||||||||
| 265 | addAdaptor(adaptor); executed 548 times by 5 tests: addAdaptor(adaptor);Executed by:
| 548 | ||||||||||||
| 266 | } executed 748 times by 5 tests: end of blockExecuted by:
| 748 | ||||||||||||
| 267 | - | |||||||||||||
| 268 | // sort the adaptor list | - | ||||||||||||
| 269 | std::sort(adaptors.begin(), adaptors.end()); | - | ||||||||||||
| 270 | } executed 200 times by 5 tests: end of blockExecuted by:
| 200 | ||||||||||||
| 271 | - | |||||||||||||
| 272 | void QDBusAdaptorConnector::relaySlot(void **argv) | - | ||||||||||||
| 273 | { | - | ||||||||||||
| 274 | QObject *sndr = sender(); | - | ||||||||||||
| 275 | if (Q_LIKELY(sndr)) {
| 0-321 | ||||||||||||
| 276 | relay(sndr, senderSignalIndex(), argv); | - | ||||||||||||
| 277 | } else { executed 321 times by 10 tests: end of blockExecuted by:
| 321 | ||||||||||||
| 278 | qWarning("QtDBus: cannot relay signals from parent %s(%p \"%s\") unless they are emitted in the object's thread %s(%p \"%s\"). " | - | ||||||||||||
| 279 | "Current thread is %s(%p \"%s\").", | - | ||||||||||||
| 280 | parent()->metaObject()->className(), parent(), qPrintable(parent()->objectName()), | - | ||||||||||||
| 281 | parent()->thread()->metaObject()->className(), parent()->thread(), qPrintable(parent()->thread()->objectName()), | - | ||||||||||||
| 282 | QThread::currentThread()->metaObject()->className(), QThread::currentThread(), qPrintable(QThread::currentThread()->objectName())); | - | ||||||||||||
| 283 | } never executed: end of block | 0 | ||||||||||||
| 284 | } | - | ||||||||||||
| 285 | - | |||||||||||||
| 286 | void QDBusAdaptorConnector::relay(QObject *senderObj, int lastSignalIdx, void **argv) | - | ||||||||||||
| 287 | { | - | ||||||||||||
| 288 | if (lastSignalIdx < QObject::staticMetaObject.methodCount())
| 113-208 | ||||||||||||
| 289 | // QObject signal (destroyed(QObject *)) -- ignore | - | ||||||||||||
| 290 | return; executed 113 times by 10 tests: return;Executed by:
| 113 | ||||||||||||
| 291 | - | |||||||||||||
| 292 | const QMetaObject *senderMetaObject = senderObj->metaObject(); | - | ||||||||||||
| 293 | QMetaMethod mm = senderMetaObject->method(lastSignalIdx); | - | ||||||||||||
| 294 | - | |||||||||||||
| 295 | QObject *realObject = senderObj; | - | ||||||||||||
| 296 | if (qobject_cast<QDBusAbstractAdaptor *>(senderObj))
| 95-113 | ||||||||||||
| 297 | // it's an adaptor, so the real object is in fact its parent | - | ||||||||||||
| 298 | realObject = realObject->parent(); executed 95 times by 2 tests: realObject = realObject->parent();Executed by:
| 95 | ||||||||||||
| 299 | - | |||||||||||||
| 300 | // break down the parameter list | - | ||||||||||||
| 301 | QVector<int> types; | - | ||||||||||||
| 302 | QString errorMsg; | - | ||||||||||||
| 303 | int inputCount = qDBusParametersForMethod(mm, types, errorMsg); | - | ||||||||||||
| 304 | if (inputCount == -1) {
| 1-207 | ||||||||||||
| 305 | // invalid signal signature | - | ||||||||||||
| 306 | qWarning("QDBusAbstractAdaptor: Cannot relay signal %s::%s: %s", | - | ||||||||||||
| 307 | senderMetaObject->className(), mm.methodSignature().constData(), | - | ||||||||||||
| 308 | qPrintable(errorMsg)); | - | ||||||||||||
| 309 | return; executed 1 time by 1 test: return;Executed by:
| 1 | ||||||||||||
| 310 | } | - | ||||||||||||
| 311 | if (inputCount + 1 != types.count() ||
| 0-207 | ||||||||||||
| 312 | types.at(inputCount) == QDBusMetaTypeId::message()) {
| 0-207 | ||||||||||||
| 313 | // invalid signal signature | - | ||||||||||||
| 314 | qWarning("QDBusAbstractAdaptor: Cannot relay signal %s::%s", | - | ||||||||||||
| 315 | senderMetaObject->className(), mm.methodSignature().constData()); | - | ||||||||||||
| 316 | return; never executed: return; | 0 | ||||||||||||
| 317 | } | - | ||||||||||||
| 318 | - | |||||||||||||
| 319 | QVariantList args; | - | ||||||||||||
| 320 | const int numTypes = types.count(); | - | ||||||||||||
| 321 | args.reserve(numTypes - 1); | - | ||||||||||||
| 322 | for (int i = 1; i < numTypes; ++i)
| 116-207 | ||||||||||||
| 323 | args << QVariant(types.at(i), argv[i]); executed 116 times by 2 tests: args << QVariant(types.at(i), argv[i]);Executed by:
| 116 | ||||||||||||
| 324 | - | |||||||||||||
| 325 | // now emit the signal with all the information | - | ||||||||||||
| 326 | emit relaySignal(realObject, senderMetaObject, lastSignalIdx, args); | - | ||||||||||||
| 327 | } executed 207 times by 3 tests: end of blockExecuted by:
| 207 | ||||||||||||
| 328 | - | |||||||||||||
| 329 | // our Meta Object | - | ||||||||||||
| 330 | // modify carefully: this has been hand-edited! | - | ||||||||||||
| 331 | // the relaySlot slot gets called with the void** array | - | ||||||||||||
| 332 | - | |||||||||||||
| 333 | struct qt_meta_stringdata_QDBusAdaptorConnector_t { | - | ||||||||||||
| 334 | QByteArrayData data[10]; | - | ||||||||||||
| 335 | char stringdata[96]; | - | ||||||||||||
| 336 | }; | - | ||||||||||||
| 337 | #define QT_MOC_LITERAL(idx, ofs, len) \ | - | ||||||||||||
| 338 | Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \ | - | ||||||||||||
| 339 | offsetof(qt_meta_stringdata_QDBusAdaptorConnector_t, stringdata) + ofs \ | - | ||||||||||||
| 340 | - idx * sizeof(QByteArrayData) \ | - | ||||||||||||
| 341 | ) | - | ||||||||||||
| 342 | static const qt_meta_stringdata_QDBusAdaptorConnector_t qt_meta_stringdata_QDBusAdaptorConnector = { | - | ||||||||||||
| 343 | { | - | ||||||||||||
| 344 | QT_MOC_LITERAL(0, 0, 21), | - | ||||||||||||
| 345 | QT_MOC_LITERAL(1, 22, 11), | - | ||||||||||||
| 346 | QT_MOC_LITERAL(2, 34, 0), | - | ||||||||||||
| 347 | QT_MOC_LITERAL(3, 35, 3), | - | ||||||||||||
| 348 | QT_MOC_LITERAL(4, 39, 18), | - | ||||||||||||
| 349 | QT_MOC_LITERAL(5, 58, 10), | - | ||||||||||||
| 350 | QT_MOC_LITERAL(6, 69, 3), | - | ||||||||||||
| 351 | QT_MOC_LITERAL(7, 73, 4), | - | ||||||||||||
| 352 | QT_MOC_LITERAL(8, 78, 9), | - | ||||||||||||
| 353 | QT_MOC_LITERAL(9, 88, 6) | - | ||||||||||||
| 354 | }, | - | ||||||||||||
| 355 | "QDBusAdaptorConnector\0relaySignal\0\0" | - | ||||||||||||
| 356 | "obj\0const QMetaObject*\0metaObject\0sid\0" | - | ||||||||||||
| 357 | "args\0relaySlot\0polish\0" | - | ||||||||||||
| 358 | }; | - | ||||||||||||
| 359 | #undef QT_MOC_LITERAL | - | ||||||||||||
| 360 | - | |||||||||||||
| 361 | static const uint qt_meta_data_QDBusAdaptorConnector[] = { | - | ||||||||||||
| 362 | - | |||||||||||||
| 363 | // content: | - | ||||||||||||
| 364 | 7, // revision | - | ||||||||||||
| 365 | 0, // classname | - | ||||||||||||
| 366 | 0, 0, // classinfo | - | ||||||||||||
| 367 | 3, 14, // methods | - | ||||||||||||
| 368 | 0, 0, // properties | - | ||||||||||||
| 369 | 0, 0, // enums/sets | - | ||||||||||||
| 370 | 0, 0, // constructors | - | ||||||||||||
| 371 | 0, // flags | - | ||||||||||||
| 372 | 1, // signalCount | - | ||||||||||||
| 373 | - | |||||||||||||
| 374 | // signals: name, argc, parameters, tag, flags | - | ||||||||||||
| 375 | 1, 4, 29, 2, 0x05, | - | ||||||||||||
| 376 | - | |||||||||||||
| 377 | // slots: name, argc, parameters, tag, flags | - | ||||||||||||
| 378 | 8, 0, 38, 2, 0x0a, | - | ||||||||||||
| 379 | 9, 0, 39, 2, 0x0a, | - | ||||||||||||
| 380 | - | |||||||||||||
| 381 | // signals: parameters | - | ||||||||||||
| 382 | QMetaType::Void, QMetaType::QObjectStar, 0x80000000 | 4, QMetaType::Int, QMetaType::QVariantList, 3, 5, 6, 7, | - | ||||||||||||
| 383 | - | |||||||||||||
| 384 | // slots: parameters | - | ||||||||||||
| 385 | QMetaType::Void, | - | ||||||||||||
| 386 | QMetaType::Void, | - | ||||||||||||
| 387 | - | |||||||||||||
| 388 | 0 // eod | - | ||||||||||||
| 389 | }; | - | ||||||||||||
| 390 | - | |||||||||||||
| 391 | void QDBusAdaptorConnector::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) | - | ||||||||||||
| 392 | { | - | ||||||||||||
| 393 | if (_c == QMetaObject::InvokeMetaMethod) { | - | ||||||||||||
| 394 | Q_ASSERT(staticMetaObject.cast(_o)); | - | ||||||||||||
| 395 | QDBusAdaptorConnector *_t = static_cast<QDBusAdaptorConnector *>(_o); | - | ||||||||||||
| 396 | switch (_id) { | - | ||||||||||||
| 397 | case 0: _t->relaySignal((*reinterpret_cast< QObject*(*)>(_a[1])),(*reinterpret_cast< const QMetaObject*(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3])),(*reinterpret_cast< const QVariantList(*)>(_a[4]))); break; | - | ||||||||||||
| 398 | case 1: _t->relaySlot(_a); break; // HAND EDIT: add the _a parameter | - | ||||||||||||
| 399 | case 2: _t->polish(); break; | - | ||||||||||||
| 400 | default: ; | - | ||||||||||||
| 401 | } | - | ||||||||||||
| 402 | } | - | ||||||||||||
| 403 | } | - | ||||||||||||
| 404 | - | |||||||||||||
| 405 | const QMetaObject QDBusAdaptorConnector::staticMetaObject = { | - | ||||||||||||
| 406 | { &QObject::staticMetaObject, qt_meta_stringdata_QDBusAdaptorConnector.data, | - | ||||||||||||
| 407 | qt_meta_data_QDBusAdaptorConnector, qt_static_metacall, 0, 0 } | - | ||||||||||||
| 408 | }; | - | ||||||||||||
| 409 | - | |||||||||||||
| 410 | const QMetaObject *QDBusAdaptorConnector::metaObject() const | - | ||||||||||||
| 411 | { | - | ||||||||||||
| 412 | return &staticMetaObject; | - | ||||||||||||
| 413 | } | - | ||||||||||||
| 414 | - | |||||||||||||
| 415 | void *QDBusAdaptorConnector::qt_metacast(const char *_clname) | - | ||||||||||||
| 416 | { | - | ||||||||||||
| 417 | if (!_clname) return 0; | - | ||||||||||||
| 418 | if (!strcmp(_clname, qt_meta_stringdata_QDBusAdaptorConnector.stringdata)) | - | ||||||||||||
| 419 | return static_cast<void*>(const_cast< QDBusAdaptorConnector*>(this)); | - | ||||||||||||
| 420 | return QObject::qt_metacast(_clname); | - | ||||||||||||
| 421 | } | - | ||||||||||||
| 422 | - | |||||||||||||
| 423 | int QDBusAdaptorConnector::qt_metacall(QMetaObject::Call _c, int _id, void **_a) | - | ||||||||||||
| 424 | { | - | ||||||||||||
| 425 | _id = QObject::qt_metacall(_c, _id, _a); | - | ||||||||||||
| 426 | if (_id < 0) | - | ||||||||||||
| 427 | return _id; | - | ||||||||||||
| 428 | if (_c == QMetaObject::InvokeMetaMethod) { | - | ||||||||||||
| 429 | if (_id < 3) | - | ||||||||||||
| 430 | qt_static_metacall(this, _c, _id, _a); | - | ||||||||||||
| 431 | _id -= 3; | - | ||||||||||||
| 432 | } | - | ||||||||||||
| 433 | return _id; | - | ||||||||||||
| 434 | } | - | ||||||||||||
| 435 | - | |||||||||||||
| 436 | // SIGNAL 0 | - | ||||||||||||
| 437 | void QDBusAdaptorConnector::relaySignal(QObject * _t1, const QMetaObject * _t2, int _t3, const QVariantList & _t4) | - | ||||||||||||
| 438 | { | - | ||||||||||||
| 439 | void *_a[] = { 0, const_cast<void*>(reinterpret_cast<const void*>(&_t1)), const_cast<void*>(reinterpret_cast<const void*>(&_t2)), const_cast<void*>(reinterpret_cast<const void*>(&_t3)), const_cast<void*>(reinterpret_cast<const void*>(&_t4)) }; | - | ||||||||||||
| 440 | QMetaObject::activate(this, &staticMetaObject, 0, _a); | - | ||||||||||||
| 441 | } executed 207 times by 3 tests: end of blockExecuted by:
| 207 | ||||||||||||
| 442 | - | |||||||||||||
| 443 | QT_END_NAMESPACE | - | ||||||||||||
| 444 | - | |||||||||||||
| 445 | #endif // QT_NO_DBUS | - | ||||||||||||
| Source code | Switch to Preprocessed file |