| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/dbus/qdbusconnection.cpp | 
| Switch to Source code | Preprocessed file | 
| Line | Source | Count | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||||||||||||||
| 2 | - | |||||||||||||||||||||||||||||||
| 3 | - | |||||||||||||||||||||||||||||||
| 4 | - | |||||||||||||||||||||||||||||||
| 5 | - | |||||||||||||||||||||||||||||||
| 6 | - | |||||||||||||||||||||||||||||||
| 7 | - | |||||||||||||||||||||||||||||||
| 8 | - | |||||||||||||||||||||||||||||||
| 9 | - | |||||||||||||||||||||||||||||||
| 10 | namespace { namespace Q_QGS__q_manager { typedef QDBusConnectionManager Type; QBasicAtomicInt guard = { QtGlobalStatic::Uninitialized }; __attribute__((visibility("hidden"))) inline Type *innerFunction() { struct HolderBase { ~HolderBase() noexcept { if (guard.load() == QtGlobalStatic::Initialized) guard.store(QtGlobalStatic::Destroyed); } }; static struct Holder : public HolderBase { Type value; Holder() noexcept(noexcept(Type ())) : value () { guard.store(QtGlobalStatic::Initialized); } } holder; return &holder.value; } } } static QGlobalStatic<QDBusConnectionManager, Q_QGS__q_manager::innerFunction, Q_QGS__q_manager::guard> _q_manager; | - | ||||||||||||||||||||||||||||||
| 11 | - | |||||||||||||||||||||||||||||||
| 12 | struct QDBusConnectionManager::ConnectionRequestData | - | ||||||||||||||||||||||||||||||
| 13 | { | - | ||||||||||||||||||||||||||||||
| 14 | enum RequestType { | - | ||||||||||||||||||||||||||||||
| 15 | ConnectToStandardBus, | - | ||||||||||||||||||||||||||||||
| 16 | ConnectToBusByAddress, | - | ||||||||||||||||||||||||||||||
| 17 | ConnectToPeerByAddress | - | ||||||||||||||||||||||||||||||
| 18 | } type; | - | ||||||||||||||||||||||||||||||
| 19 | - | |||||||||||||||||||||||||||||||
| 20 | union { | - | ||||||||||||||||||||||||||||||
| 21 | QDBusConnection::BusType busType; | - | ||||||||||||||||||||||||||||||
| 22 | const QString *busAddress; | - | ||||||||||||||||||||||||||||||
| 23 | }; | - | ||||||||||||||||||||||||||||||
| 24 | const QString *name; | - | ||||||||||||||||||||||||||||||
| 25 | - | |||||||||||||||||||||||||||||||
| 26 | QDBusConnectionPrivate *result; | - | ||||||||||||||||||||||||||||||
| 27 | - | |||||||||||||||||||||||||||||||
| 28 | bool suspendedDelivery; | - | ||||||||||||||||||||||||||||||
| 29 | }; | - | ||||||||||||||||||||||||||||||
| 30 | - | |||||||||||||||||||||||||||||||
| 31 | QDBusConnectionPrivate *QDBusConnectionManager::busConnection(QDBusConnection::BusType type) | - | ||||||||||||||||||||||||||||||
| 32 | { | - | ||||||||||||||||||||||||||||||
| 33 | static_assert(bool(int(QDBusConnection::SessionBus) + int(QDBusConnection::SystemBus) == 1), "int(QDBusConnection::SessionBus) + int(QDBusConnection::SystemBus) == 1"); | - | ||||||||||||||||||||||||||||||
| 34 | ((!(type == QDBusConnection::SessionBus || type == QDBusConnection::SystemBus)) ? qt_assert("type == QDBusConnection::SessionBus || type == QDBusConnection::SystemBus",__FILE__,93100) : qt_noop()); | - | ||||||||||||||||||||||||||||||
| 35 | - | |||||||||||||||||||||||||||||||
| 36 | if (!qdbus_loadLibDBus()) | - | ||||||||||||||||||||||||||||||
| 37 | return 0; | - | ||||||||||||||||||||||||||||||
| 38 | - | |||||||||||||||||||||||||||||||
| 39 | - | |||||||||||||||||||||||||||||||
| 40 | - | |||||||||||||||||||||||||||||||
| 41 | bool suspendedDelivery = QCoreApplication::instance() && QCoreApplication::instance()->thread() == QThread::currentThread(); | - | ||||||||||||||||||||||||||||||
| 42 | - | |||||||||||||||||||||||||||||||
| 43 | QMutexLocker lock(&defaultBusMutex); | - | ||||||||||||||||||||||||||||||
| 44 | if (defaultBuses[type]) | - | ||||||||||||||||||||||||||||||
| 45 | return defaultBuses[type]; | - | ||||||||||||||||||||||||||||||
| 46 | - | |||||||||||||||||||||||||||||||
| 47 | QString name = ([]() -> QString { enum { Size = sizeof(u"" "qt_default_session_bus")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "qt_default_session_bus" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()); | - | ||||||||||||||||||||||||||||||
| 48 | if (type == QDBusConnection::SystemBus) | - | ||||||||||||||||||||||||||||||
| 49 | name = ([]() -> QString { enum { Size = sizeof(u"" "qt_default_system_bus")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "qt_default_system_bus" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()); | - | ||||||||||||||||||||||||||||||
| 50 | return defaultBuses[type] = connectToBus(type, name, suspendedDelivery); | - | ||||||||||||||||||||||||||||||
| 51 | } | - | ||||||||||||||||||||||||||||||
| 52 | - | |||||||||||||||||||||||||||||||
| 53 | QDBusConnectionPrivate *QDBusConnectionManager::connection(const QString &name) const | - | ||||||||||||||||||||||||||||||
| 54 | { | - | ||||||||||||||||||||||||||||||
| 55 | return connectionHash.value(name, 0); | - | ||||||||||||||||||||||||||||||
| 56 | } | - | ||||||||||||||||||||||||||||||
| 57 | - | |||||||||||||||||||||||||||||||
| 58 | void QDBusConnectionManager::removeConnection(const QString &name) | - | ||||||||||||||||||||||||||||||
| 59 | { | - | ||||||||||||||||||||||||||||||
| 60 | QDBusConnectionPrivate *d = 0; | - | ||||||||||||||||||||||||||||||
| 61 | d = connectionHash.take(name); | - | ||||||||||||||||||||||||||||||
| 62 | if (d && !d->ref.deref()) | - | ||||||||||||||||||||||||||||||
| 63 | d->deleteLater(); | - | ||||||||||||||||||||||||||||||
| 64 | - | |||||||||||||||||||||||||||||||
| 65 | - | |||||||||||||||||||||||||||||||
| 66 | - | |||||||||||||||||||||||||||||||
| 67 | - | |||||||||||||||||||||||||||||||
| 68 | - | |||||||||||||||||||||||||||||||
| 69 | - | |||||||||||||||||||||||||||||||
| 70 | } | - | ||||||||||||||||||||||||||||||
| 71 | - | |||||||||||||||||||||||||||||||
| 72 | QDBusConnectionManager::QDBusConnectionManager() | - | ||||||||||||||||||||||||||||||
| 73 | { | - | ||||||||||||||||||||||||||||||
| 74 | connect(this, &QDBusConnectionManager::connectionRequested, | - | ||||||||||||||||||||||||||||||
| 75 | this, &QDBusConnectionManager::executeConnectionRequest, Qt::BlockingQueuedConnection); | - | ||||||||||||||||||||||||||||||
| 76 | connect(this, &QDBusConnectionManager::serverRequested, | - | ||||||||||||||||||||||||||||||
| 77 | this, &QDBusConnectionManager::createServer, Qt::BlockingQueuedConnection); | - | ||||||||||||||||||||||||||||||
| 78 | moveToThread(this); | - | ||||||||||||||||||||||||||||||
| 79 | - | |||||||||||||||||||||||||||||||
| 80 | - | |||||||||||||||||||||||||||||||
| 81 | - | |||||||||||||||||||||||||||||||
| 82 | - | |||||||||||||||||||||||||||||||
| 83 | - | |||||||||||||||||||||||||||||||
| 84 | defaultBuses[0] = defaultBuses[1] = nullptr; | - | ||||||||||||||||||||||||||||||
| 85 | start(); | - | ||||||||||||||||||||||||||||||
| 86 | } executed 169 times by 160 tests:  end of blockExecuted by: 
  | 169 | ||||||||||||||||||||||||||||||
| 87 | - | |||||||||||||||||||||||||||||||
| 88 | QDBusConnectionManager::~QDBusConnectionManager() | - | ||||||||||||||||||||||||||||||
| 89 | { | - | ||||||||||||||||||||||||||||||
| 90 | quit(); | - | ||||||||||||||||||||||||||||||
| 91 | wait(); | - | ||||||||||||||||||||||||||||||
| 92 | } | - | ||||||||||||||||||||||||||||||
| 93 | - | |||||||||||||||||||||||||||||||
| 94 | QDBusConnectionManager* QDBusConnectionManager::instance() | - | ||||||||||||||||||||||||||||||
| 95 | { | - | ||||||||||||||||||||||||||||||
| 96 | return _q_manager(); | - | ||||||||||||||||||||||||||||||
| 97 | } | - | ||||||||||||||||||||||||||||||
| 98 | - | |||||||||||||||||||||||||||||||
| 99 | __attribute__((visibility("default"))) void qDBusBindToApplication(); | - | ||||||||||||||||||||||||||||||
| 100 | void qDBusBindToApplication() | - | ||||||||||||||||||||||||||||||
| 101 | { | - | ||||||||||||||||||||||||||||||
| 102 | } | - | ||||||||||||||||||||||||||||||
| 103 | - | |||||||||||||||||||||||||||||||
| 104 | void QDBusConnectionManager::setConnection(const QString &name, QDBusConnectionPrivate *c) | - | ||||||||||||||||||||||||||||||
| 105 | { | - | ||||||||||||||||||||||||||||||
| 106 | connectionHash[name] = c; | - | ||||||||||||||||||||||||||||||
| 107 | c->name = name; | - | ||||||||||||||||||||||||||||||
| 108 | } | - | ||||||||||||||||||||||||||||||
| 109 | - | |||||||||||||||||||||||||||||||
| 110 | void QDBusConnectionManager::run() | - | ||||||||||||||||||||||||||||||
| 111 | { | - | ||||||||||||||||||||||||||||||
| 112 | exec(); | - | ||||||||||||||||||||||||||||||
| 113 | - | |||||||||||||||||||||||||||||||
| 114 | - | |||||||||||||||||||||||||||||||
| 115 | QMutexLocker locker(&mutex); | - | ||||||||||||||||||||||||||||||
| 116 | for (QHash<QString, QDBusConnectionPrivate *>::const_iterator it = connectionHash.constBegin(); | - | ||||||||||||||||||||||||||||||
| 117 | it != connectionHash.constEnd(); ++it) { | - | ||||||||||||||||||||||||||||||
| 118 | QDBusConnectionPrivate *d = it.value(); | - | ||||||||||||||||||||||||||||||
| 119 | if (!d->ref.deref()) { | - | ||||||||||||||||||||||||||||||
| 120 | delete d; | - | ||||||||||||||||||||||||||||||
| 121 | } else { | - | ||||||||||||||||||||||||||||||
| 122 | d->closeConnection(); | - | ||||||||||||||||||||||||||||||
| 123 | d->moveToThread(nullptr); | - | ||||||||||||||||||||||||||||||
| 124 | } | - | ||||||||||||||||||||||||||||||
| 125 | } | - | ||||||||||||||||||||||||||||||
| 126 | connectionHash.clear(); | - | ||||||||||||||||||||||||||||||
| 127 | - | |||||||||||||||||||||||||||||||
| 128 | - | |||||||||||||||||||||||||||||||
| 129 | moveToThread(nullptr); | - | ||||||||||||||||||||||||||||||
| 130 | } | - | ||||||||||||||||||||||||||||||
| 131 | - | |||||||||||||||||||||||||||||||
| 132 | QDBusConnectionPrivate *QDBusConnectionManager::connectToBus(QDBusConnection::BusType type, const QString &name, | - | ||||||||||||||||||||||||||||||
| 133 | bool suspendedDelivery) | - | ||||||||||||||||||||||||||||||
| 134 | { | - | ||||||||||||||||||||||||||||||
| 135 | ConnectionRequestData data; | - | ||||||||||||||||||||||||||||||
| 136 | data.type = ConnectionRequestData::ConnectToStandardBus; | - | ||||||||||||||||||||||||||||||
| 137 | data.busType = type; | - | ||||||||||||||||||||||||||||||
| 138 | data.name = &name; | - | ||||||||||||||||||||||||||||||
| 139 | data.suspendedDelivery = suspendedDelivery; | - | ||||||||||||||||||||||||||||||
| 140 | - | |||||||||||||||||||||||||||||||
| 141 | connectionRequested(&data); | - | ||||||||||||||||||||||||||||||
| 142 | if (suspendedDelivery && data.result->connection) { | - | ||||||||||||||||||||||||||||||
| 143 | data.result->ref.ref(); | - | ||||||||||||||||||||||||||||||
| 144 | QDBusConnectionDispatchEnabler *o = new QDBusConnectionDispatchEnabler(data.result); | - | ||||||||||||||||||||||||||||||
| 145 | QTimer::singleShot(0, o, qFlagLocation("1""execute()" "\0" __FILE__ ":" "204""211")); | - | ||||||||||||||||||||||||||||||
| 146 | o->moveToThread(QCoreApplication::instance()->thread()); | - | ||||||||||||||||||||||||||||||
| 147 | } | - | ||||||||||||||||||||||||||||||
| 148 | return data.result; | - | ||||||||||||||||||||||||||||||
| 149 | } | - | ||||||||||||||||||||||||||||||
| 150 | - | |||||||||||||||||||||||||||||||
| 151 | QDBusConnectionPrivate *QDBusConnectionManager::connectToBus(const QString &address, const QString &name) | - | ||||||||||||||||||||||||||||||
| 152 | { | - | ||||||||||||||||||||||||||||||
| 153 | ConnectionRequestData data; | - | ||||||||||||||||||||||||||||||
| 154 | data.type = ConnectionRequestData::ConnectToBusByAddress; | - | ||||||||||||||||||||||||||||||
| 155 | data.busAddress = &address; | - | ||||||||||||||||||||||||||||||
| 156 | data.name = &name; | - | ||||||||||||||||||||||||||||||
| 157 | data.suspendedDelivery = false; | - | ||||||||||||||||||||||||||||||
| 158 | - | |||||||||||||||||||||||||||||||
| 159 | connectionRequested(&data); | - | ||||||||||||||||||||||||||||||
| 160 | return data.result; | - | ||||||||||||||||||||||||||||||
| 161 | } | - | ||||||||||||||||||||||||||||||
| 162 | - | |||||||||||||||||||||||||||||||
| 163 | QDBusConnectionPrivate *QDBusConnectionManager::connectToPeer(const QString &address, const QString &name) | - | ||||||||||||||||||||||||||||||
| 164 | { | - | ||||||||||||||||||||||||||||||
| 165 | ConnectionRequestData data; | - | ||||||||||||||||||||||||||||||
| 166 | data.type = ConnectionRequestData::ConnectToPeerByAddress; | - | ||||||||||||||||||||||||||||||
| 167 | data.busAddress = &address; | - | ||||||||||||||||||||||||||||||
| 168 | data.name = &name; | - | ||||||||||||||||||||||||||||||
| 169 | data.suspendedDelivery = false; | - | ||||||||||||||||||||||||||||||
| 170 | - | |||||||||||||||||||||||||||||||
| 171 | connectionRequested(&data); | - | ||||||||||||||||||||||||||||||
| 172 | return data.result; | - | ||||||||||||||||||||||||||||||
| 173 | } | - | ||||||||||||||||||||||||||||||
| 174 | - | |||||||||||||||||||||||||||||||
| 175 | void QDBusConnectionManager::executeConnectionRequest(QDBusConnectionManager::ConnectionRequestData *data) | - | ||||||||||||||||||||||||||||||
| 176 | { | - | ||||||||||||||||||||||||||||||
| 177 | QMutexLocker locker(&mutex); | - | ||||||||||||||||||||||||||||||
| 178 | const QString &name = *data->name; | - | ||||||||||||||||||||||||||||||
| 179 | QDBusConnectionPrivate *&d = data->result; | - | ||||||||||||||||||||||||||||||
| 180 | - | |||||||||||||||||||||||||||||||
| 181 | - | |||||||||||||||||||||||||||||||
| 182 | d = connection(name); | - | ||||||||||||||||||||||||||||||
| 183 | if (d || name.isEmpty()) | - | ||||||||||||||||||||||||||||||
| 184 | return; | - | ||||||||||||||||||||||||||||||
| 185 | - | |||||||||||||||||||||||||||||||
| 186 | d = new QDBusConnectionPrivate; | - | ||||||||||||||||||||||||||||||
| 187 | DBusConnection *c = 0; | - | ||||||||||||||||||||||||||||||
| 188 | QDBusErrorInternal error; | - | ||||||||||||||||||||||||||||||
| 189 | switch (data->type) { | - | ||||||||||||||||||||||||||||||
| 190 | case ConnectionRequestData::ConnectToStandardBus: | - | ||||||||||||||||||||||||||||||
| 191 | switch (data->busType) { | - | ||||||||||||||||||||||||||||||
| 192 | case QDBusConnection::SystemBus: | - | ||||||||||||||||||||||||||||||
| 193 | c = q_dbus_bus_get_private(DBUS_BUS_SYSTEM, error); | - | ||||||||||||||||||||||||||||||
| 194 | break; | - | ||||||||||||||||||||||||||||||
| 195 | case QDBusConnection::SessionBus: | - | ||||||||||||||||||||||||||||||
| 196 | c = q_dbus_bus_get_private(DBUS_BUS_SESSION, error); | - | ||||||||||||||||||||||||||||||
| 197 | break; | - | ||||||||||||||||||||||||||||||
| 198 | case QDBusConnection::ActivationBus: | - | ||||||||||||||||||||||||||||||
| 199 | c = q_dbus_bus_get_private(DBUS_BUS_STARTER, error); | - | ||||||||||||||||||||||||||||||
| 200 | break; | - | ||||||||||||||||||||||||||||||
| 201 | } | - | ||||||||||||||||||||||||||||||
| 202 | break; | - | ||||||||||||||||||||||||||||||
| 203 | - | |||||||||||||||||||||||||||||||
| 204 | case ConnectionRequestData::ConnectToBusByAddress: | - | ||||||||||||||||||||||||||||||
| 205 | case ConnectionRequestData::ConnectToPeerByAddress: | - | ||||||||||||||||||||||||||||||
| 206 | c = q_dbus_connection_open_private(data->busAddress->toUtf8().constData(), error); | - | ||||||||||||||||||||||||||||||
| 207 | if (c && data->type == ConnectionRequestData::ConnectToBusByAddress) { | - | ||||||||||||||||||||||||||||||
| 208 | - | |||||||||||||||||||||||||||||||
| 209 | if (!q_dbus_bus_register(c, error)) { | - | ||||||||||||||||||||||||||||||
| 210 | q_dbus_connection_unref(c); | - | ||||||||||||||||||||||||||||||
| 211 | c = 0; | - | ||||||||||||||||||||||||||||||
| 212 | } | - | ||||||||||||||||||||||||||||||
| 213 | } | - | ||||||||||||||||||||||||||||||
| 214 | break; | - | ||||||||||||||||||||||||||||||
| 215 | } | - | ||||||||||||||||||||||||||||||
| 216 | - | |||||||||||||||||||||||||||||||
| 217 | setConnection(name, d); | - | ||||||||||||||||||||||||||||||
| 218 | if (data->type == ConnectionRequestData::ConnectToPeerByAddress) { | - | ||||||||||||||||||||||||||||||
| 219 | d->setPeer(c, error); | - | ||||||||||||||||||||||||||||||
| 220 | } else { | - | ||||||||||||||||||||||||||||||
| 221 | - | |||||||||||||||||||||||||||||||
| 222 | - | |||||||||||||||||||||||||||||||
| 223 | d->setConnection(c, error); | - | ||||||||||||||||||||||||||||||
| 224 | d->createBusService(); | - | ||||||||||||||||||||||||||||||
| 225 | if (c && data->suspendedDelivery) | - | ||||||||||||||||||||||||||||||
| 226 | d->setDispatchEnabled(false); | - | ||||||||||||||||||||||||||||||
| 227 | } | - | ||||||||||||||||||||||||||||||
| 228 | } | - | ||||||||||||||||||||||||||||||
| 229 | - | |||||||||||||||||||||||||||||||
| 230 | void QDBusConnectionManager::createServer(const QString &address, void *server) | - | ||||||||||||||||||||||||||||||
| 231 | { | - | ||||||||||||||||||||||||||||||
| 232 | QDBusErrorInternal error; | - | ||||||||||||||||||||||||||||||
| 233 | QDBusConnectionPrivate *d = new QDBusConnectionPrivate; | - | ||||||||||||||||||||||||||||||
| 234 | d->setServer(static_cast<QDBusServer *>(server), | - | ||||||||||||||||||||||||||||||
| 235 | q_dbus_server_listen(address.toUtf8().constData(), error), error); | - | ||||||||||||||||||||||||||||||
| 236 | } | - | ||||||||||||||||||||||||||||||
| 237 | QDBusConnection::QDBusConnection(const QString &name) | - | ||||||||||||||||||||||||||||||
| 238 | { | - | ||||||||||||||||||||||||||||||
| 239 | if (name.isEmpty()) { | - | ||||||||||||||||||||||||||||||
| 240 | d = 0; | - | ||||||||||||||||||||||||||||||
| 241 | } else { | - | ||||||||||||||||||||||||||||||
| 242 | QMutexLocker locker(&_q_manager()->mutex); | - | ||||||||||||||||||||||||||||||
| 243 | d = _q_manager()->connection(name); | - | ||||||||||||||||||||||||||||||
| 244 | if (d) | - | ||||||||||||||||||||||||||||||
| 245 | d->ref.ref(); | - | ||||||||||||||||||||||||||||||
| 246 | } | - | ||||||||||||||||||||||||||||||
| 247 | } | - | ||||||||||||||||||||||||||||||
| 248 | - | |||||||||||||||||||||||||||||||
| 249 | - | |||||||||||||||||||||||||||||||
| 250 | - | |||||||||||||||||||||||||||||||
| 251 | - | |||||||||||||||||||||||||||||||
| 252 | QDBusConnection::QDBusConnection(const QDBusConnection &other) | - | ||||||||||||||||||||||||||||||
| 253 | { | - | ||||||||||||||||||||||||||||||
| 254 | d = other.d; | - | ||||||||||||||||||||||||||||||
| 255 | if (d) | - | ||||||||||||||||||||||||||||||
| 256 | d->ref.ref(); | - | ||||||||||||||||||||||||||||||
| 257 | } | - | ||||||||||||||||||||||||||||||
| 258 | - | |||||||||||||||||||||||||||||||
| 259 | - | |||||||||||||||||||||||||||||||
| 260 | - | |||||||||||||||||||||||||||||||
| 261 | - | |||||||||||||||||||||||||||||||
| 262 | - | |||||||||||||||||||||||||||||||
| 263 | QDBusConnection::QDBusConnection(QDBusConnectionPrivate *dd) | - | ||||||||||||||||||||||||||||||
| 264 | { | - | ||||||||||||||||||||||||||||||
| 265 | d = dd; | - | ||||||||||||||||||||||||||||||
| 266 | if (d) | - | ||||||||||||||||||||||||||||||
| 267 | d->ref.ref(); | - | ||||||||||||||||||||||||||||||
| 268 | } | - | ||||||||||||||||||||||||||||||
| 269 | - | |||||||||||||||||||||||||||||||
| 270 | - | |||||||||||||||||||||||||||||||
| 271 | - | |||||||||||||||||||||||||||||||
| 272 | - | |||||||||||||||||||||||||||||||
| 273 | - | |||||||||||||||||||||||||||||||
| 274 | QDBusConnection::~QDBusConnection() | - | ||||||||||||||||||||||||||||||
| 275 | { | - | ||||||||||||||||||||||||||||||
| 276 | if (d && !d->ref.deref()) | - | ||||||||||||||||||||||||||||||
| 277 | d->deleteLater(); | - | ||||||||||||||||||||||||||||||
| 278 | } | - | ||||||||||||||||||||||||||||||
| 279 | QDBusConnection &QDBusConnection::operator=(const QDBusConnection &other) | - | ||||||||||||||||||||||||||||||
| 280 | { | - | ||||||||||||||||||||||||||||||
| 281 | if (other.d) | - | ||||||||||||||||||||||||||||||
| 282 | other.d->ref.ref(); | - | ||||||||||||||||||||||||||||||
| 283 | if (d && !d->ref.deref()) | - | ||||||||||||||||||||||||||||||
| 284 | d->deleteLater(); | - | ||||||||||||||||||||||||||||||
| 285 | d = other.d; | - | ||||||||||||||||||||||||||||||
| 286 | return *this; | - | ||||||||||||||||||||||||||||||
| 287 | } | - | ||||||||||||||||||||||||||||||
| 288 | - | |||||||||||||||||||||||||||||||
| 289 | - | |||||||||||||||||||||||||||||||
| 290 | - | |||||||||||||||||||||||||||||||
| 291 | - | |||||||||||||||||||||||||||||||
| 292 | - | |||||||||||||||||||||||||||||||
| 293 | - | |||||||||||||||||||||||||||||||
| 294 | QDBusConnection QDBusConnection::connectToBus(BusType type, const QString &name) | - | ||||||||||||||||||||||||||||||
| 295 | { | - | ||||||||||||||||||||||||||||||
| 296 | if (!qdbus_loadLibDBus()) { | - | ||||||||||||||||||||||||||||||
| 297 | QDBusConnectionPrivate *d = 0; | - | ||||||||||||||||||||||||||||||
| 298 | return QDBusConnection(d); | - | ||||||||||||||||||||||||||||||
| 299 | } | - | ||||||||||||||||||||||||||||||
| 300 | return QDBusConnection(_q_manager()->connectToBus(type, name, false)); | - | ||||||||||||||||||||||||||||||
| 301 | } | - | ||||||||||||||||||||||||||||||
| 302 | - | |||||||||||||||||||||||||||||||
| 303 | - | |||||||||||||||||||||||||||||||
| 304 | - | |||||||||||||||||||||||||||||||
| 305 | - | |||||||||||||||||||||||||||||||
| 306 | - | |||||||||||||||||||||||||||||||
| 307 | QDBusConnection QDBusConnection::connectToBus(const QString &address, | - | ||||||||||||||||||||||||||||||
| 308 | const QString &name) | - | ||||||||||||||||||||||||||||||
| 309 | { | - | ||||||||||||||||||||||||||||||
| 310 | if (!qdbus_loadLibDBus()) { | - | ||||||||||||||||||||||||||||||
| 311 | QDBusConnectionPrivate *d = 0; | - | ||||||||||||||||||||||||||||||
| 312 | return QDBusConnection(d); | - | ||||||||||||||||||||||||||||||
| 313 | } | - | ||||||||||||||||||||||||||||||
| 314 | return QDBusConnection(_q_manager()->connectToBus(address, name)); | - | ||||||||||||||||||||||||||||||
| 315 | } | - | ||||||||||||||||||||||||||||||
| 316 | - | |||||||||||||||||||||||||||||||
| 317 | - | |||||||||||||||||||||||||||||||
| 318 | - | |||||||||||||||||||||||||||||||
| 319 | - | |||||||||||||||||||||||||||||||
| 320 | - | |||||||||||||||||||||||||||||||
| 321 | - | |||||||||||||||||||||||||||||||
| 322 | QDBusConnection QDBusConnection::connectToPeer(const QString &address, | - | ||||||||||||||||||||||||||||||
| 323 | const QString &name) | - | ||||||||||||||||||||||||||||||
| 324 | { | - | ||||||||||||||||||||||||||||||
| 325 | if (!qdbus_loadLibDBus()) { | - | ||||||||||||||||||||||||||||||
| 326 | QDBusConnectionPrivate *d = 0; | - | ||||||||||||||||||||||||||||||
| 327 | return QDBusConnection(d); | - | ||||||||||||||||||||||||||||||
| 328 | } | - | ||||||||||||||||||||||||||||||
| 329 | return QDBusConnection(_q_manager()->connectToPeer(address, name)); | - | ||||||||||||||||||||||||||||||
| 330 | } | - | ||||||||||||||||||||||||||||||
| 331 | void QDBusConnection::disconnectFromBus(const QString &name) | - | ||||||||||||||||||||||||||||||
| 332 | { | - | ||||||||||||||||||||||||||||||
| 333 | if (_q_manager()) { | - | ||||||||||||||||||||||||||||||
| 334 | QMutexLocker locker(&_q_manager()->mutex); | - | ||||||||||||||||||||||||||||||
| 335 | QDBusConnectionPrivate *d = _q_manager()->connection(name); | - | ||||||||||||||||||||||||||||||
| 336 | if (d && d->mode != QDBusConnectionPrivate::ClientMode) | - | ||||||||||||||||||||||||||||||
| 337 | return; | - | ||||||||||||||||||||||||||||||
| 338 | _q_manager()->removeConnection(name); | - | ||||||||||||||||||||||||||||||
| 339 | } | - | ||||||||||||||||||||||||||||||
| 340 | } | - | ||||||||||||||||||||||||||||||
| 341 | void QDBusConnection::disconnectFromPeer(const QString &name) | - | ||||||||||||||||||||||||||||||
| 342 | { | - | ||||||||||||||||||||||||||||||
| 343 | if (_q_manager()) { | - | ||||||||||||||||||||||||||||||
| 344 | QMutexLocker locker(&_q_manager()->mutex); | - | ||||||||||||||||||||||||||||||
| 345 | QDBusConnectionPrivate *d = _q_manager()->connection(name); | - | ||||||||||||||||||||||||||||||
| 346 | if (d && d->mode != QDBusConnectionPrivate::PeerMode) | - | ||||||||||||||||||||||||||||||
| 347 | return; | - | ||||||||||||||||||||||||||||||
| 348 | _q_manager()->removeConnection(name); | - | ||||||||||||||||||||||||||||||
| 349 | } | - | ||||||||||||||||||||||||||||||
| 350 | } | - | ||||||||||||||||||||||||||||||
| 351 | bool QDBusConnection::send(const QDBusMessage &message) const | - | ||||||||||||||||||||||||||||||
| 352 | { | - | ||||||||||||||||||||||||||||||
| 353 | if (!d || !d->connection) { | - | ||||||||||||||||||||||||||||||
| 354 | QDBusError err = QDBusError(QDBusError::Disconnected, | - | ||||||||||||||||||||||||||||||
| 355 | QDBusUtil::disconnectedErrorMessage()); | - | ||||||||||||||||||||||||||||||
| 356 | if (d) | - | ||||||||||||||||||||||||||||||
| 357 | d->lastError = err; | - | ||||||||||||||||||||||||||||||
| 358 | return false; | - | ||||||||||||||||||||||||||||||
| 359 | } | - | ||||||||||||||||||||||||||||||
| 360 | return d->send(message); | - | ||||||||||||||||||||||||||||||
| 361 | } | - | ||||||||||||||||||||||||||||||
| 362 | bool QDBusConnection::callWithCallback(const QDBusMessage &message, QObject *receiver, | - | ||||||||||||||||||||||||||||||
| 363 | const char *returnMethod, const char *errorMethod, | - | ||||||||||||||||||||||||||||||
| 364 | int timeout) const | - | ||||||||||||||||||||||||||||||
| 365 | { | - | ||||||||||||||||||||||||||||||
| 366 | if (!d || !d->connection) { | - | ||||||||||||||||||||||||||||||
| 367 | QDBusError err = QDBusError(QDBusError::Disconnected, | - | ||||||||||||||||||||||||||||||
| 368 | QDBusUtil::disconnectedErrorMessage()); | - | ||||||||||||||||||||||||||||||
| 369 | if (d) | - | ||||||||||||||||||||||||||||||
| 370 | d->lastError = err; | - | ||||||||||||||||||||||||||||||
| 371 | return false; | - | ||||||||||||||||||||||||||||||
| 372 | } | - | ||||||||||||||||||||||||||||||
| 373 | return d->sendWithReplyAsync(message, receiver, returnMethod, errorMethod, timeout) != 0; | - | ||||||||||||||||||||||||||||||
| 374 | } | - | ||||||||||||||||||||||||||||||
| 375 | bool QDBusConnection::callWithCallback(const QDBusMessage &message, QObject *receiver, | - | ||||||||||||||||||||||||||||||
| 376 | const char *returnMethod, int timeout) const | - | ||||||||||||||||||||||||||||||
| 377 | { | - | ||||||||||||||||||||||||||||||
| 378 | return callWithCallback(message, receiver, returnMethod, 0, timeout); | - | ||||||||||||||||||||||||||||||
| 379 | } | - | ||||||||||||||||||||||||||||||
| 380 | QDBusMessage QDBusConnection::call(const QDBusMessage &message, QDBus::CallMode mode, int timeout) const | - | ||||||||||||||||||||||||||||||
| 381 | { | - | ||||||||||||||||||||||||||||||
| 382 | if (!d || !d->connection) { | - | ||||||||||||||||||||||||||||||
| 383 | QDBusError err = QDBusError(QDBusError::Disconnected, | - | ||||||||||||||||||||||||||||||
| 384 | QDBusUtil::disconnectedErrorMessage()); | - | ||||||||||||||||||||||||||||||
| 385 | if (d) | - | ||||||||||||||||||||||||||||||
| 386 | d->lastError = err; | - | ||||||||||||||||||||||||||||||
| 387 | - | |||||||||||||||||||||||||||||||
| 388 | return QDBusMessage::createError(err); | - | ||||||||||||||||||||||||||||||
| 389 | } | - | ||||||||||||||||||||||||||||||
| 390 | - | |||||||||||||||||||||||||||||||
| 391 | if (mode != QDBus::NoBlock) | - | ||||||||||||||||||||||||||||||
| 392 | return d->sendWithReply(message, mode, timeout); | - | ||||||||||||||||||||||||||||||
| 393 | - | |||||||||||||||||||||||||||||||
| 394 | d->send(message); | - | ||||||||||||||||||||||||||||||
| 395 | QDBusMessage retval; | - | ||||||||||||||||||||||||||||||
| 396 | retval << QVariant(); | - | ||||||||||||||||||||||||||||||
| 397 | return retval; | - | ||||||||||||||||||||||||||||||
| 398 | } | - | ||||||||||||||||||||||||||||||
| 399 | QDBusPendingCall QDBusConnection::asyncCall(const QDBusMessage &message, int timeout) const | - | ||||||||||||||||||||||||||||||
| 400 | { | - | ||||||||||||||||||||||||||||||
| 401 | if (!d || !d->connection) { | - | ||||||||||||||||||||||||||||||
| 402 | return QDBusPendingCall(0); | - | ||||||||||||||||||||||||||||||
| 403 | } | - | ||||||||||||||||||||||||||||||
| 404 | - | |||||||||||||||||||||||||||||||
| 405 | QDBusPendingCallPrivate *priv = d->sendWithReplyAsync(message, 0, 0, 0, timeout); | - | ||||||||||||||||||||||||||||||
| 406 | return QDBusPendingCall(priv); | - | ||||||||||||||||||||||||||||||
| 407 | } | - | ||||||||||||||||||||||||||||||
| 408 | bool QDBusConnection::connect(const QString &service, const QString &path, const QString& interface, | - | ||||||||||||||||||||||||||||||
| 409 | const QString &name, QObject *receiver, const char *slot) | - | ||||||||||||||||||||||||||||||
| 410 | { | - | ||||||||||||||||||||||||||||||
| 411 | return connect(service, path, interface, name, QStringList(), QString(), receiver, slot); | - | ||||||||||||||||||||||||||||||
| 412 | } | - | ||||||||||||||||||||||||||||||
| 413 | bool QDBusConnection::connect(const QString &service, const QString &path, const QString& interface, | - | ||||||||||||||||||||||||||||||
| 414 | const QString &name, const QString &signature, | - | ||||||||||||||||||||||||||||||
| 415 | QObject *receiver, const char *slot) | - | ||||||||||||||||||||||||||||||
| 416 | { | - | ||||||||||||||||||||||||||||||
| 417 | return connect(service, path, interface, name, QStringList(), signature, receiver, slot); | - | ||||||||||||||||||||||||||||||
| 418 | } | - | ||||||||||||||||||||||||||||||
| 419 | bool QDBusConnection::connect(const QString &service, const QString &path, const QString& interface, | - | ||||||||||||||||||||||||||||||
| 420 | const QString &name, const QStringList &argumentMatch, const QString &signature, | - | ||||||||||||||||||||||||||||||
| 421 | QObject *receiver, const char *slot) | - | ||||||||||||||||||||||||||||||
| 422 | { | - | ||||||||||||||||||||||||||||||
| 423 | - | |||||||||||||||||||||||||||||||
| 424 | if (!receiver || !slot || !d || !d->connection) | - | ||||||||||||||||||||||||||||||
| 425 | return false; | - | ||||||||||||||||||||||||||||||
| 426 | if (interface.isEmpty() && name.isEmpty()) | - | ||||||||||||||||||||||||||||||
| 427 | return false; | - | ||||||||||||||||||||||||||||||
| 428 | if (!interface.isEmpty() && !QDBusUtil::isValidInterfaceName(interface)) { | - | ||||||||||||||||||||||||||||||
| 429 | - | |||||||||||||||||||||||||||||||
| 430 | QMessageLogger(__FILE__, 782789, __PRETTY_FUNCTION__).warning("QDBusConnection::connect: interface name '%s' is not valid", interface.toLatin1().constData()); | - | ||||||||||||||||||||||||||||||
| 431 | - | |||||||||||||||||||||||||||||||
| 432 | return false; | - | ||||||||||||||||||||||||||||||
| 433 | } | - | ||||||||||||||||||||||||||||||
| 434 | if (!service.isEmpty() && !QDBusUtil::isValidBusName(service)) { | - | ||||||||||||||||||||||||||||||
| 435 | - | |||||||||||||||||||||||||||||||
| 436 | QMessageLogger(__FILE__, 788795, __PRETTY_FUNCTION__).warning("QDBusConnection::connect: service name '%s' is not valid", service.toLatin1().constData()); | - | ||||||||||||||||||||||||||||||
| 437 | - | |||||||||||||||||||||||||||||||
| 438 | return false; | - | ||||||||||||||||||||||||||||||
| 439 | } | - | ||||||||||||||||||||||||||||||
| 440 | if (!path.isEmpty() && !QDBusUtil::isValidObjectPath(path)) { | - | ||||||||||||||||||||||||||||||
| 441 | - | |||||||||||||||||||||||||||||||
| 442 | QMessageLogger(__FILE__, 794801, __PRETTY_FUNCTION__).warning("QDBusConnection::connect: object path '%s' is not valid", path.toLatin1().constData()); | - | ||||||||||||||||||||||||||||||
| 443 | - | |||||||||||||||||||||||||||||||
| 444 | return false; | - | ||||||||||||||||||||||||||||||
| 445 | } | - | ||||||||||||||||||||||||||||||
| 446 | - | |||||||||||||||||||||||||||||||
| 447 | return d->connectSignal(service, path, interface, name, argumentMatch, signature, receiver, slot); | - | ||||||||||||||||||||||||||||||
| 448 | } | - | ||||||||||||||||||||||||||||||
| 449 | bool QDBusConnection::disconnect(const QString &service, const QString &path, const QString &interface, | - | ||||||||||||||||||||||||||||||
| 450 | const QString &name, QObject *receiver, const char *slot) | - | ||||||||||||||||||||||||||||||
| 451 | { | - | ||||||||||||||||||||||||||||||
| 452 | return disconnect(service, path, interface, name, QStringList(), QString(), receiver, slot); | - | ||||||||||||||||||||||||||||||
| 453 | } | - | ||||||||||||||||||||||||||||||
| 454 | bool QDBusConnection::disconnect(const QString &service, const QString &path, const QString& interface, | - | ||||||||||||||||||||||||||||||
| 455 | const QString &name, const QString &signature, | - | ||||||||||||||||||||||||||||||
| 456 | QObject *receiver, const char *slot) | - | ||||||||||||||||||||||||||||||
| 457 | { | - | ||||||||||||||||||||||||||||||
| 458 | return disconnect(service, path, interface, name, QStringList(), signature, receiver, slot); | - | ||||||||||||||||||||||||||||||
| 459 | } | - | ||||||||||||||||||||||||||||||
| 460 | bool QDBusConnection::disconnect(const QString &service, const QString &path, const QString& interface, | - | ||||||||||||||||||||||||||||||
| 461 | const QString &name, const QStringList &argumentMatch, const QString &signature, | - | ||||||||||||||||||||||||||||||
| 462 | QObject *receiver, const char *slot) | - | ||||||||||||||||||||||||||||||
| 463 | { | - | ||||||||||||||||||||||||||||||
| 464 | if (!receiver || !slot || !d || !d->connection) | - | ||||||||||||||||||||||||||||||
| 465 | return false; | - | ||||||||||||||||||||||||||||||
| 466 | if (!interface.isEmpty() && !QDBusUtil::isValidInterfaceName(interface)) | - | ||||||||||||||||||||||||||||||
| 467 | return false; | - | ||||||||||||||||||||||||||||||
| 468 | if (interface.isEmpty() && name.isEmpty()) | - | ||||||||||||||||||||||||||||||
| 469 | return false; | - | ||||||||||||||||||||||||||||||
| 470 | - | |||||||||||||||||||||||||||||||
| 471 | return d->disconnectSignal(service, path, interface, name, argumentMatch, signature, receiver, slot); | - | ||||||||||||||||||||||||||||||
| 472 | } | - | ||||||||||||||||||||||||||||||
| 473 | bool QDBusConnection::registerObject(const QString &path, QObject *object, RegisterOptions options) | - | ||||||||||||||||||||||||||||||
| 474 | { | - | ||||||||||||||||||||||||||||||
| 475 | return registerObject(path, QString(), object, options); | - | ||||||||||||||||||||||||||||||
| 476 | } | - | ||||||||||||||||||||||||||||||
| 477 | bool QDBusConnection::registerObject(const QString &path, const QString &interface, QObject *object, RegisterOptions options) | - | ||||||||||||||||||||||||||||||
| 478 | { | - | ||||||||||||||||||||||||||||||
| 479 | ((!(QDBusUtil::isValidObjectPath(path))) ? qt_assert_x("QDBusConnection::registerObject", "Invalid object path given", | - | ||||||||||||||||||||||||||||||
| 480 | __FILE__ | - | ||||||||||||||||||||||||||||||
| 481 | , | - | ||||||||||||||||||||||||||||||
| 482 | 892899 | - | ||||||||||||||||||||||||||||||
| 483 | ) : qt_noop()) | - | ||||||||||||||||||||||||||||||
| 484 | ; | - | ||||||||||||||||||||||||||||||
| 485 |     if (!d
 
 
 
 
  | 0-403 | ||||||||||||||||||||||||||||||
| 486 |         return executed 4 times by 1 test:   false;return false;Executed by: 
 executed 4 times by 1 test:  return false;Executed by: 
  | 4 | ||||||||||||||||||||||||||||||
| 487 | - | |||||||||||||||||||||||||||||||
| 488 | QStringListauto pathComponents = path.splitsplitRef(QLatin1Char('/')); | - | ||||||||||||||||||||||||||||||
| 489 |     if (pathComponents.lastconstLast().isEmpty()
  | 196-203 | ||||||||||||||||||||||||||||||
| 490 |         pathComponents.removeLast(); executed 203 times by 11 tests:  pathComponents.removeLast();Executed by: 
  | 203 | ||||||||||||||||||||||||||||||
| 491 | QDBusWriteLocker locker(RegisterObjectAction, d); | - | ||||||||||||||||||||||||||||||
| 492 | - | |||||||||||||||||||||||||||||||
| 493 | - | |||||||||||||||||||||||||||||||
| 494 | QDBusConnectionPrivate::ObjectTreeNode::DataList::Iterator node = &d->rootNode; | - | ||||||||||||||||||||||||||||||
| 495 | int i = 1; | - | ||||||||||||||||||||||||||||||
| 496 |     while (node
  | 0-727 | ||||||||||||||||||||||||||||||
| 497 |         if (pathComponents.count() == i
  | 331-396 | ||||||||||||||||||||||||||||||
| 498 | - | |||||||||||||||||||||||||||||||
| 499 | - | |||||||||||||||||||||||||||||||
| 500 | - | |||||||||||||||||||||||||||||||
| 501 |             if (node->obj
  | 3-393 | ||||||||||||||||||||||||||||||
| 502 |                 return executed 3 times by 3 tests:   false;return false;Executed by: 
 executed 3 times by 3 tests:  return false;Executed by: 
  | 3 | ||||||||||||||||||||||||||||||
| 503 | - | |||||||||||||||||||||||||||||||
| 504 |             if (options & QDBusConnectionPrivate::VirtualObject
  | 24-369 | ||||||||||||||||||||||||||||||
| 505 |                 if (options & SubPath && !node->children.isEmpty()
  | 6-15 | ||||||||||||||||||||||||||||||
| 506 |                     return executed 6 times by 3 tests:   false;return false;Executed by: 
 executed 6 times by 3 tests:  return false;Executed by: 
  | 6 | ||||||||||||||||||||||||||||||
| 507 |             } executed 18 times by 4 tests:   else {end of blockExecuted by: 
  | 18 | ||||||||||||||||||||||||||||||
| 508 |                 if ((options & ExportChildObjects && !node->children.isEmpty()
  | 0-5 | ||||||||||||||||||||||||||||||
| 509 |                     return never executed:   false;return false;never executed:  return false; | 0 | ||||||||||||||||||||||||||||||
| 510 |             } executed 369 times by 14 tests:  end of blockExecuted by: 
  | 369 | ||||||||||||||||||||||||||||||
| 511 | - | |||||||||||||||||||||||||||||||
| 512 | node->obj = object; | - | ||||||||||||||||||||||||||||||
| 513 | node->flags = options; | - | ||||||||||||||||||||||||||||||
| 514 | node->interfaceName = interface; | - | ||||||||||||||||||||||||||||||
| 515 | - | |||||||||||||||||||||||||||||||
| 516 | d->registerObject(node); | - | ||||||||||||||||||||||||||||||
| 517 | - | |||||||||||||||||||||||||||||||
| 518 |             return executed 387 times by 14 tests:   true;return true;Executed by: 
 executed 387 times by 14 tests:  return true;Executed by: 
  | 387 | ||||||||||||||||||||||||||||||
| 519 | } | - | ||||||||||||||||||||||||||||||
| 520 | - | |||||||||||||||||||||||||||||||
| 521 | - | |||||||||||||||||||||||||||||||
| 522 |         if (node->obj
 
 
 
 
  | 0-326 | ||||||||||||||||||||||||||||||
| 523 | - | |||||||||||||||||||||||||||||||
| 524 | - | |||||||||||||||||||||||||||||||
| 525 |             return executed 3 times by 3 tests:   false;return false;Executed by: 
 executed 3 times by 3 tests:  return false;Executed by: 
  | 3 | ||||||||||||||||||||||||||||||
| 526 | } | - | ||||||||||||||||||||||||||||||
| 527 | - | |||||||||||||||||||||||||||||||
| 528 | - | |||||||||||||||||||||||||||||||
| 529 | QDBusConnectionPrivate::ObjectTreeNode::DataList::Iterator it = | - | ||||||||||||||||||||||||||||||
| 530 | std::lower_bound(node->children.begin(), node->children.end(), pathComponents.at(i)); | - | ||||||||||||||||||||||||||||||
| 531 |         if (it != node->children.end()
 
  | 0-304 | ||||||||||||||||||||||||||||||
| 532 | - | |||||||||||||||||||||||||||||||
| 533 | node = it; | - | ||||||||||||||||||||||||||||||
| 534 | - | |||||||||||||||||||||||||||||||
| 535 | - | |||||||||||||||||||||||||||||||
| 536 |             if (node->flags & ExportChildObjects
  | 0-24 | ||||||||||||||||||||||||||||||
| 537 | - | |||||||||||||||||||||||||||||||
| 538 | - | |||||||||||||||||||||||||||||||
| 539 | - | |||||||||||||||||||||||||||||||
| 540 |                 return never executed:   false;return false;never executed:  return false; | 0 | ||||||||||||||||||||||||||||||
| 541 | } | - | ||||||||||||||||||||||||||||||
| 542 |         } executed 24 times by 3 tests:   else {end of blockExecuted by: 
  | 24 | ||||||||||||||||||||||||||||||
| 543 | - | |||||||||||||||||||||||||||||||
| 544 | node = node->children.insert(it, pathComponents.at(i));).toString()); | - | ||||||||||||||||||||||||||||||
| 545 |         } executed 304 times by 9 tests:  end of blockExecuted by: 
  | 304 | ||||||||||||||||||||||||||||||
| 546 | - | |||||||||||||||||||||||||||||||
| 547 | - | |||||||||||||||||||||||||||||||
| 548 | ++i; | - | ||||||||||||||||||||||||||||||
| 549 |     } executed 328 times by 9 tests:  end of blockExecuted by: 
  | 328 | ||||||||||||||||||||||||||||||
| 550 | - | |||||||||||||||||||||||||||||||
| 551 | ((!(false)) ? qt_assert_x("QDBusConnection::registerObject", "The impossible happened",__FILE__,959966) : qt_noop()); | - | ||||||||||||||||||||||||||||||
| 552 |     return never executed:   false;return false;never executed:  return false; | 0 | ||||||||||||||||||||||||||||||
| 553 | } | - | ||||||||||||||||||||||||||||||
| 554 | bool QDBusConnection::registerVirtualObject(const QString &path, QDBusVirtualObject *treeNode, | - | ||||||||||||||||||||||||||||||
| 555 | VirtualObjectRegisterOption options) | - | ||||||||||||||||||||||||||||||
| 556 | { | - | ||||||||||||||||||||||||||||||
| 557 | int opts = options | QDBusConnectionPrivate::VirtualObject; | - | ||||||||||||||||||||||||||||||
| 558 | return registerObject(path, (QObject*) treeNode, (RegisterOptions) opts); | - | ||||||||||||||||||||||||||||||
| 559 | } | - | ||||||||||||||||||||||||||||||
| 560 | - | |||||||||||||||||||||||||||||||
| 561 | - | |||||||||||||||||||||||||||||||
| 562 | - | |||||||||||||||||||||||||||||||
| 563 | - | |||||||||||||||||||||||||||||||
| 564 | - | |||||||||||||||||||||||||||||||
| 565 | - | |||||||||||||||||||||||||||||||
| 566 | - | |||||||||||||||||||||||||||||||
| 567 | void QDBusConnection::unregisterObject(const QString &path, UnregisterMode mode) | - | ||||||||||||||||||||||||||||||
| 568 | { | - | ||||||||||||||||||||||||||||||
| 569 | if (!d || !d->connection || !QDBusUtil::isValidObjectPath(path)) | - | ||||||||||||||||||||||||||||||
| 570 | return; | - | ||||||||||||||||||||||||||||||
| 571 | - | |||||||||||||||||||||||||||||||
| 572 | QDBusWriteLocker locker(UnregisterObjectAction, d); | - | ||||||||||||||||||||||||||||||
| 573 | d->unregisterObject(path, mode); | - | ||||||||||||||||||||||||||||||
| 574 | } | - | ||||||||||||||||||||||||||||||
| 575 | - | |||||||||||||||||||||||||||||||
| 576 | - | |||||||||||||||||||||||||||||||
| 577 | - | |||||||||||||||||||||||||||||||
| 578 | - | |||||||||||||||||||||||||||||||
| 579 | - | |||||||||||||||||||||||||||||||
| 580 | QObject *QDBusConnection::objectRegisteredAt(const QString &path) const | - | ||||||||||||||||||||||||||||||
| 581 | { | - | ||||||||||||||||||||||||||||||
| 582 | ((!(QDBusUtil::isValidObjectPath(path))) ? qt_assert_x("QDBusConnection::registeredObject", "Invalid object path given", | - | ||||||||||||||||||||||||||||||
| 583 | __FILE__ | - | ||||||||||||||||||||||||||||||
| 584 | , | - | ||||||||||||||||||||||||||||||
| 585 | 10001007 | - | ||||||||||||||||||||||||||||||
| 586 | ) : qt_noop()) | - | ||||||||||||||||||||||||||||||
| 587 | ; | - | ||||||||||||||||||||||||||||||
| 588 |     if (!d
 
 
  | 0-156 | ||||||||||||||||||||||||||||||
| 589 |         return never executed:   0;return 0;never executed:  return 0; | 0 | ||||||||||||||||||||||||||||||
| 590 | - | |||||||||||||||||||||||||||||||
| 591 | QStringListauto pathComponents = path.splitsplitRef(QLatin1Char('/')); | - | ||||||||||||||||||||||||||||||
| 592 |     if (pathComponents.lastconstLast().isEmpty()
  | 18-138 | ||||||||||||||||||||||||||||||
| 593 |         pathComponents.removeLast(); executed 18 times by 3 tests:  pathComponents.removeLast();Executed by: 
  | 18 | ||||||||||||||||||||||||||||||
| 594 | - | |||||||||||||||||||||||||||||||
| 595 | - | |||||||||||||||||||||||||||||||
| 596 | QDBusReadLocker lock(ObjectRegisteredAtAction, d); | - | ||||||||||||||||||||||||||||||
| 597 | const QDBusConnectionPrivate::ObjectTreeNode *node = &d->rootNode; | - | ||||||||||||||||||||||||||||||
| 598 | - | |||||||||||||||||||||||||||||||
| 599 | int i = 1; | - | ||||||||||||||||||||||||||||||
| 600 |     while (node
  | 0-378 | ||||||||||||||||||||||||||||||
| 601 |         if (pathComponents.count() == i
  | 117-261 | ||||||||||||||||||||||||||||||
| 602 |             return executed 117 times by 3 tests:   node->obj;return node->obj;Executed by: 
 executed 117 times by 3 tests:  return node->obj;Executed by: 
  | 117 | ||||||||||||||||||||||||||||||
| 603 |         if ((
 
 
 
  | 3-243 | ||||||||||||||||||||||||||||||
| 604 |             return executed 15 times by 3 tests:   node->obj;return node->obj;Executed by: 
 executed 15 times by 3 tests:  return node->obj;Executed by: 
  | 15 | ||||||||||||||||||||||||||||||
| 605 | - | |||||||||||||||||||||||||||||||
| 606 | QDBusConnectionPrivate::ObjectTreeNode::DataList::ConstIterator it = | - | ||||||||||||||||||||||||||||||
| 607 | std::lower_bound(node->children.constBegin(), node->children.constEnd(), pathComponents.at(i)); | - | ||||||||||||||||||||||||||||||
| 608 |         if (it == node->children.constEnd()
 
  | 0-222 | ||||||||||||||||||||||||||||||
| 609 |             break; executed 24 times by 3 tests:  break;Executed by: 
  | 24 | ||||||||||||||||||||||||||||||
| 610 | - | |||||||||||||||||||||||||||||||
| 611 | node = it; | - | ||||||||||||||||||||||||||||||
| 612 | ++i; | - | ||||||||||||||||||||||||||||||
| 613 |     } executed 222 times by 3 tests:  end of blockExecuted by: 
  | 222 | ||||||||||||||||||||||||||||||
| 614 |     return executed 24 times by 3 tests:   0;return 0;Executed by: 
 executed 24 times by 3 tests:  return 0;Executed by: 
  | 24 | ||||||||||||||||||||||||||||||
| 615 | } | - | ||||||||||||||||||||||||||||||
| 616 | - | |||||||||||||||||||||||||||||||
| 617 | - | |||||||||||||||||||||||||||||||
| 618 | - | |||||||||||||||||||||||||||||||
| 619 | - | |||||||||||||||||||||||||||||||
| 620 | - | |||||||||||||||||||||||||||||||
| 621 | - | |||||||||||||||||||||||||||||||
| 622 | - | |||||||||||||||||||||||||||||||
| 623 | QDBusConnectionInterface *QDBusConnection::interface() const | - | ||||||||||||||||||||||||||||||
| 624 | { | - | ||||||||||||||||||||||||||||||
| 625 | if (!d || d->mode != QDBusConnectionPrivate::ClientMode) | - | ||||||||||||||||||||||||||||||
| 626 | return 0; | - | ||||||||||||||||||||||||||||||
| 627 | return d->busService; | - | ||||||||||||||||||||||||||||||
| 628 | } | - | ||||||||||||||||||||||||||||||
| 629 | void *QDBusConnection::internalPointer() const | - | ||||||||||||||||||||||||||||||
| 630 | { | - | ||||||||||||||||||||||||||||||
| 631 | return d ? d->connection : 0; | - | ||||||||||||||||||||||||||||||
| 632 | } | - | ||||||||||||||||||||||||||||||
| 633 | - | |||||||||||||||||||||||||||||||
| 634 | - | |||||||||||||||||||||||||||||||
| 635 | - | |||||||||||||||||||||||||||||||
| 636 | - | |||||||||||||||||||||||||||||||
| 637 | bool QDBusConnection::isConnected() const | - | ||||||||||||||||||||||||||||||
| 638 | { | - | ||||||||||||||||||||||||||||||
| 639 | return d && d->connection && q_dbus_connection_get_is_connected(d->connection); | - | ||||||||||||||||||||||||||||||
| 640 | } | - | ||||||||||||||||||||||||||||||
| 641 | QDBusError QDBusConnection::lastError() const | - | ||||||||||||||||||||||||||||||
| 642 | { | - | ||||||||||||||||||||||||||||||
| 643 | return d ? d->lastError : QDBusError(QDBusError::Disconnected, QDBusUtil::disconnectedErrorMessage()); | - | ||||||||||||||||||||||||||||||
| 644 | } | - | ||||||||||||||||||||||||||||||
| 645 | QString QDBusConnection::baseService() const | - | ||||||||||||||||||||||||||||||
| 646 | { | - | ||||||||||||||||||||||||||||||
| 647 | return d ? d->baseService : QString(); | - | ||||||||||||||||||||||||||||||
| 648 | } | - | ||||||||||||||||||||||||||||||
| 649 | QString QDBusConnection::name() const | - | ||||||||||||||||||||||||||||||
| 650 | { | - | ||||||||||||||||||||||||||||||
| 651 | return d ? d->name : QString(); | - | ||||||||||||||||||||||||||||||
| 652 | } | - | ||||||||||||||||||||||||||||||
| 653 | QDBusConnection::ConnectionCapabilities QDBusConnection::connectionCapabilities() const | - | ||||||||||||||||||||||||||||||
| 654 | { | - | ||||||||||||||||||||||||||||||
| 655 | return d ? d->capabilities : ConnectionCapabilities(0); | - | ||||||||||||||||||||||||||||||
| 656 | } | - | ||||||||||||||||||||||||||||||
| 657 | bool QDBusConnection::registerService(const QString &serviceName) | - | ||||||||||||||||||||||||||||||
| 658 | { | - | ||||||||||||||||||||||||||||||
| 659 | if (interface() && interface()->registerService(serviceName)) { | - | ||||||||||||||||||||||||||||||
| 660 | if (d) d->registerService(serviceName); | - | ||||||||||||||||||||||||||||||
| 661 | return true; | - | ||||||||||||||||||||||||||||||
| 662 | } | - | ||||||||||||||||||||||||||||||
| 663 | return false; | - | ||||||||||||||||||||||||||||||
| 664 | } | - | ||||||||||||||||||||||||||||||
| 665 | bool QDBusConnection::unregisterService(const QString &serviceName) | - | ||||||||||||||||||||||||||||||
| 666 | { | - | ||||||||||||||||||||||||||||||
| 667 | if (interface()->unregisterService(serviceName)) { | - | ||||||||||||||||||||||||||||||
| 668 | if (d) d->unregisterService(serviceName); | - | ||||||||||||||||||||||||||||||
| 669 | return true; | - | ||||||||||||||||||||||||||||||
| 670 | } | - | ||||||||||||||||||||||||||||||
| 671 | return false; | - | ||||||||||||||||||||||||||||||
| 672 | } | - | ||||||||||||||||||||||||||||||
| 673 | QDBusConnection QDBusConnection::sessionBus() | - | ||||||||||||||||||||||||||||||
| 674 | { | - | ||||||||||||||||||||||||||||||
| 675 | return QDBusConnection(_q_manager()->busConnection(SessionBus)); | - | ||||||||||||||||||||||||||||||
| 676 | } | - | ||||||||||||||||||||||||||||||
| 677 | QDBusConnection QDBusConnection::systemBus() | - | ||||||||||||||||||||||||||||||
| 678 | { | - | ||||||||||||||||||||||||||||||
| 679 | return QDBusConnection(_q_manager()->busConnection(SystemBus)); | - | ||||||||||||||||||||||||||||||
| 680 | } | - | ||||||||||||||||||||||||||||||
| 681 | QDBusConnection QDBusConnection::sender() | - | ||||||||||||||||||||||||||||||
| 682 | { | - | ||||||||||||||||||||||||||||||
| 683 | return QDBusConnection(QString()); | - | ||||||||||||||||||||||||||||||
| 684 | } | - | ||||||||||||||||||||||||||||||
| 685 | - | |||||||||||||||||||||||||||||||
| 686 | - | |||||||||||||||||||||||||||||||
| 687 | - | |||||||||||||||||||||||||||||||
| 688 | - | |||||||||||||||||||||||||||||||
| 689 | - | |||||||||||||||||||||||||||||||
| 690 | void QDBusConnectionPrivate::createBusService() | - | ||||||||||||||||||||||||||||||
| 691 | { | - | ||||||||||||||||||||||||||||||
| 692 | ((!(mode == ClientMode)) ? qt_assert("mode == ClientMode",__FILE__,12051212) : qt_noop()); | - | ||||||||||||||||||||||||||||||
| 693 | QDBusConnection connection(this); | - | ||||||||||||||||||||||||||||||
| 694 | busService = new QDBusConnectionInterface(connection, this); | - | ||||||||||||||||||||||||||||||
| 695 | ref.deref(); | - | ||||||||||||||||||||||||||||||
| 696 | - | |||||||||||||||||||||||||||||||
| 697 | - | |||||||||||||||||||||||||||||||
| 698 | QObject::connect(this, qFlagLocation("2""callWithCallbackFailed(QDBusError&QDBusConnectionPrivate::callWithCallbackFailed, | - | ||||||||||||||||||||||||||||||
| 699 | QDBusMessage)" "\0" __FILE__ ":" "1211"),busService, qFlagLocation("2""callWithCallbackFailed(QDBusError&QDBusConnectionInterface::callWithCallbackFailed,QDBusMessage)" "\0" __FILE__ ":" "1212"), | - | ||||||||||||||||||||||||||||||
| 700 | Qt::QueuedConnection); | - | ||||||||||||||||||||||||||||||
| 701 | } executed 326 times by 160 tests:  end of blockExecuted by: 
  | 326 | ||||||||||||||||||||||||||||||
| 702 | QByteArray QDBusConnection::localMachineId() | - | ||||||||||||||||||||||||||||||
| 703 | { | - | ||||||||||||||||||||||||||||||
| 704 | char *dbus_machine_id = q_dbus_get_local_machine_id(); | - | ||||||||||||||||||||||||||||||
| 705 | QByteArray result = dbus_machine_id; | - | ||||||||||||||||||||||||||||||
| 706 | q_dbus_free(dbus_machine_id); | - | ||||||||||||||||||||||||||||||
| 707 | return result; | - | ||||||||||||||||||||||||||||||
| 708 | } | - | ||||||||||||||||||||||||||||||
| 709 | - | |||||||||||||||||||||||||||||||
| Switch to Source code | Preprocessed file |