277 */ |
277 */ |
278 QDBusAbstractInterface::QDBusAbstractInterface(QDBusAbstractInterfacePrivate &d, QObject *parent) |
278 QDBusAbstractInterface::QDBusAbstractInterface(QDBusAbstractInterfacePrivate &d, QObject *parent) |
279 : QDBusAbstractInterfaceBase(d, parent) |
279 : QDBusAbstractInterfaceBase(d, parent) |
280 { |
280 { |
281 // keep track of the service owner |
281 // keep track of the service owner |
282 if (!d_func()->currentOwner.isEmpty()) |
282 if (d.isValid && |
283 QObject::connect(d_func()->connectionPrivate(), SIGNAL(serviceOwnerChanged(QString,QString,QString)), |
283 d.connection.isConnected() |
284 this, SLOT(_q_serviceOwnerChanged(QString,QString,QString))); |
284 && !d.service.isEmpty() |
|
285 && !d.service.startsWith(QLatin1Char(':'))) |
|
286 d_func()->connection.connect(QLatin1String(DBUS_SERVICE_DBUS), // service |
|
287 QString(), // path |
|
288 QLatin1String(DBUS_INTERFACE_DBUS), // interface |
|
289 QLatin1String("NameOwnerChanged"), |
|
290 QStringList() << d.service, |
|
291 QString(), // signature |
|
292 this, SLOT(_q_serviceOwnerChanged(QString,QString,QString))); |
285 } |
293 } |
286 |
294 |
287 /*! |
295 /*! |
288 \internal |
296 \internal |
289 This is the constructor called from static classes derived from |
297 This is the constructor called from static classes derived from |
294 QObject *parent) |
302 QObject *parent) |
295 : QDBusAbstractInterfaceBase(*new QDBusAbstractInterfacePrivate(service, path, QString::fromLatin1(interface), |
303 : QDBusAbstractInterfaceBase(*new QDBusAbstractInterfacePrivate(service, path, QString::fromLatin1(interface), |
296 con, false), parent) |
304 con, false), parent) |
297 { |
305 { |
298 // keep track of the service owner |
306 // keep track of the service owner |
299 if (d_func()->connection.isConnected()) |
307 if (d_func()->isValid && |
300 QObject::connect(d_func()->connectionPrivate(), SIGNAL(serviceOwnerChanged(QString,QString,QString)), |
308 d_func()->connection.isConnected() |
301 this, SLOT(_q_serviceOwnerChanged(QString,QString,QString))); |
309 && !service.isEmpty() |
|
310 && !service.startsWith(QLatin1Char(':'))) |
|
311 d_func()->connection.connect(QLatin1String(DBUS_SERVICE_DBUS), // service |
|
312 QString(), // path |
|
313 QLatin1String(DBUS_INTERFACE_DBUS), // interface |
|
314 QLatin1String("NameOwnerChanged"), |
|
315 QStringList() << service, |
|
316 QString(), //signature |
|
317 this, SLOT(_q_serviceOwnerChanged(QString,QString,QString))); |
302 } |
318 } |
303 |
319 |
304 /*! |
320 /*! |
305 Releases this object's resources. |
321 Releases this object's resources. |
306 */ |
322 */ |
542 // we end up recursing here, so optimise away |
558 // we end up recursing here, so optimise away |
543 if (qstrcmp(signal + 1, "destroyed(QObject*)") == 0) |
559 if (qstrcmp(signal + 1, "destroyed(QObject*)") == 0) |
544 return; |
560 return; |
545 |
561 |
546 QDBusConnectionPrivate *conn = d->connectionPrivate(); |
562 QDBusConnectionPrivate *conn = d->connectionPrivate(); |
547 if (conn) |
563 if (conn) { |
548 conn->connectRelay(d->service, d->currentOwner, d->path, d->interface, |
564 // do we know what our owner is? |
|
565 QString owner; |
|
566 if (!d->service.isEmpty() && d->currentOwner.isNull()) |
|
567 owner = QLatin1String(""); |
|
568 else |
|
569 owner = d->currentOwner; |
|
570 conn->connectRelay(d->service, owner, d->path, d->interface, |
549 this, signal); |
571 this, signal); |
|
572 } |
550 } |
573 } |
551 |
574 |
552 /*! |
575 /*! |
553 \internal |
576 \internal |
554 Catch signal disconnections. |
577 Catch signal disconnections. |