summaryrefslogtreecommitdiffstats
path: root/src/dbus
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-11-04 08:45:54 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2009-11-04 08:45:54 (GMT)
commite22581675866cbf88e948eae2e83eb13a43a2d44 (patch)
tree782b173b702a48fca5f68d9622cad67d65d01d88 /src/dbus
parent950cd9b3c1ae6a1b462d596a62aea92f9c231afb (diff)
parentdb997a02c1d306260d8bbfe4f13e8312efb6fa7c (diff)
downloadQt-e22581675866cbf88e948eae2e83eb13a43a2d44.zip
Qt-e22581675866cbf88e948eae2e83eb13a43a2d44.tar.gz
Qt-e22581675866cbf88e948eae2e83eb13a43a2d44.tar.bz2
Merge commit 'origin/4.6' into 4.6
Diffstat (limited to 'src/dbus')
-rw-r--r--src/dbus/dbus.pro148
-rw-r--r--src/dbus/qdbusabstractinterface.cpp39
-rw-r--r--src/dbus/qdbusconnection.cpp149
-rw-r--r--src/dbus/qdbusconnection.h12
-rw-r--r--src/dbus/qdbusconnection_p.h9
-rw-r--r--src/dbus/qdbusconnectioninterface.cpp8
-rw-r--r--src/dbus/qdbusintegrator.cpp127
-rw-r--r--src/dbus/qdbusservicewatcher.cpp374
-rw-r--r--src/dbus/qdbusservicewatcher.h103
9 files changed, 803 insertions, 166 deletions
diff --git a/src/dbus/dbus.pro b/src/dbus/dbus.pro
index 57c6a58..9ab3920 100644
--- a/src/dbus/dbus.pro
+++ b/src/dbus/dbus.pro
@@ -1,77 +1,87 @@
-TARGET = QtDBus
-QPRO_PWD = $$PWD
-QT = core xml
-CONFIG += link_pkgconfig
-DEFINES += QDBUS_MAKEDLL DBUS_API_SUBJECT_TO_CHANGE
+TARGET = QtDBus
+QPRO_PWD = $$PWD
+QT = core \
+ xml
+CONFIG += link_pkgconfig
+DEFINES += QDBUS_MAKEDLL \
+ DBUS_API_SUBJECT_TO_CHANGE
QMAKE_CXXFLAGS += $$QT_CFLAGS_DBUS
-
-contains(QT_CONFIG, dbus-linked) {
+contains(QT_CONFIG, dbus-linked) {
LIBS_PRIVATE += $$QT_LIBS_DBUS
- DEFINES += QT_LINKED_LIBDBUS
+ DEFINES += QT_LINKED_LIBDBUS
}
-#INCLUDEPATH += .
-
-unix {
- QMAKE_PKGCONFIG_DESCRIPTION = Qt DBus module
- QMAKE_PKGCONFIG_REQUIRES = QtCore QtXml
+# INCLUDEPATH += .
+unix {
+ QMAKE_PKGCONFIG_DESCRIPTION = Qt \
+ DBus \
+ module
+ QMAKE_PKGCONFIG_REQUIRES = QtCore \
+ QtXml
}
-
-win32 {
- LIBS_PRIVATE += -lws2_32 -ladvapi32 -lnetapi32 -luser32
- CONFIG(debug, debug|release):LIBS_PRIVATE += -ldbus-1d
- else:LIBS_PRIVATE += -ldbus-1
+win32 {
+ LIBS_PRIVATE += -lws2_32 \
+ -ladvapi32 \
+ -lnetapi32 \
+ -luser32
+ CONFIG(debug, debug|release):LIBS_PRIVATE += -ldbus-1d
+ else:LIBS_PRIVATE += -ldbus-1
}
-
include(../qbase.pri)
-
-PUB_HEADERS = qdbusargument.h \
- qdbusconnectioninterface.h \
- qdbusmacros.h \
- qdbuserror.h \
- qdbusextratypes.h \
- qdbusmessage.h \
- qdbusserver.h \
- qdbusconnection.h \
- qdbusabstractinterface.h \
- qdbusinterface.h \
- qdbusabstractadaptor.h \
- qdbusreply.h \
- qdbusmetatype.h \
- qdbuspendingcall.h \
- qdbuspendingreply.h \
- qdbuscontext.h
-
+PUB_HEADERS = qdbusargument.h \
+ qdbusconnectioninterface.h \
+ qdbusmacros.h \
+ qdbuserror.h \
+ qdbusextratypes.h \
+ qdbusmessage.h \
+ qdbusserver.h \
+ qdbusconnection.h \
+ qdbusabstractinterface.h \
+ qdbusinterface.h \
+ qdbusabstractadaptor.h \
+ qdbusreply.h \
+ qdbusmetatype.h \
+ qdbuspendingcall.h \
+ qdbuspendingreply.h \
+ qdbuscontext.h
HEADERS += $$PUB_HEADERS \
- qdbusconnection_p.h qdbusmessage_p.h \
- qdbusinterface_p.h qdbusxmlparser_p.h qdbusabstractadaptor_p.h \
- qdbusargument_p.h qdbusutil_p.h qdbusabstractinterface_p.h \
- qdbuscontext_p.h qdbusthreaddebug_p.h qdbusintegrator_p.h \
- qdbuspendingcall_p.h qdbus_symbols_p.h
-
-SOURCES += qdbusconnection.cpp \
- qdbusconnectioninterface.cpp \
- qdbuserror.cpp \
- qdbusintegrator.cpp \
- qdbusmessage.cpp \
- qdbusserver.cpp \
- qdbusabstractinterface.cpp \
- qdbusinterface.cpp \
- qdbusxmlparser.cpp \
- qdbusutil.cpp \
- qdbusintrospection.cpp \
- qdbusabstractadaptor.cpp \
- qdbusinternalfilters.cpp \
- qdbusmetaobject.cpp \
- qdbusxmlgenerator.cpp \
- qdbusmisc.cpp \
- qdbusargument.cpp \
- qdbusreply.cpp \
- qdbusmetatype.cpp \
- qdbusextratypes.cpp \
- qdbusmarshaller.cpp \
- qdbuscontext.cpp \
- qdbuspendingcall.cpp \
- qdbuspendingreply.cpp \
- qdbus_symbols.cpp
-
+ qdbusconnection_p.h \
+ qdbusmessage_p.h \
+ qdbusinterface_p.h \
+ qdbusxmlparser_p.h \
+ qdbusabstractadaptor_p.h \
+ qdbusargument_p.h \
+ qdbusutil_p.h \
+ qdbusabstractinterface_p.h \
+ qdbuscontext_p.h \
+ qdbusthreaddebug_p.h \
+ qdbusintegrator_p.h \
+ qdbuspendingcall_p.h \
+ qdbus_symbols_p.h \
+ qdbusservicewatcher.h
+SOURCES += qdbusconnection.cpp \
+ qdbusconnectioninterface.cpp \
+ qdbuserror.cpp \
+ qdbusintegrator.cpp \
+ qdbusmessage.cpp \
+ qdbusserver.cpp \
+ qdbusabstractinterface.cpp \
+ qdbusinterface.cpp \
+ qdbusxmlparser.cpp \
+ qdbusutil.cpp \
+ qdbusintrospection.cpp \
+ qdbusabstractadaptor.cpp \
+ qdbusinternalfilters.cpp \
+ qdbusmetaobject.cpp \
+ qdbusxmlgenerator.cpp \
+ qdbusmisc.cpp \
+ qdbusargument.cpp \
+ qdbusreply.cpp \
+ qdbusmetatype.cpp \
+ qdbusextratypes.cpp \
+ qdbusmarshaller.cpp \
+ qdbuscontext.cpp \
+ qdbuspendingcall.cpp \
+ qdbuspendingreply.cpp \
+ qdbus_symbols.cpp \
+ qdbusservicewatcher.cpp
diff --git a/src/dbus/qdbusabstractinterface.cpp b/src/dbus/qdbusabstractinterface.cpp
index 61a9d95..994da10 100644
--- a/src/dbus/qdbusabstractinterface.cpp
+++ b/src/dbus/qdbusabstractinterface.cpp
@@ -279,9 +279,17 @@ QDBusAbstractInterface::QDBusAbstractInterface(QDBusAbstractInterfacePrivate &d,
: QDBusAbstractInterfaceBase(d, parent)
{
// keep track of the service owner
- if (!d_func()->currentOwner.isEmpty())
- QObject::connect(d_func()->connectionPrivate(), SIGNAL(serviceOwnerChanged(QString,QString,QString)),
- this, SLOT(_q_serviceOwnerChanged(QString,QString,QString)));
+ if (d.isValid &&
+ d.connection.isConnected()
+ && !d.service.isEmpty()
+ && !d.service.startsWith(QLatin1Char(':')))
+ d_func()->connection.connect(QLatin1String(DBUS_SERVICE_DBUS), // service
+ QString(), // path
+ QLatin1String(DBUS_INTERFACE_DBUS), // interface
+ QLatin1String("NameOwnerChanged"),
+ QStringList() << d.service,
+ QString(), // signature
+ this, SLOT(_q_serviceOwnerChanged(QString,QString,QString)));
}
/*!
@@ -296,9 +304,17 @@ QDBusAbstractInterface::QDBusAbstractInterface(const QString &service, const QSt
con, false), parent)
{
// keep track of the service owner
- if (d_func()->connection.isConnected())
- QObject::connect(d_func()->connectionPrivate(), SIGNAL(serviceOwnerChanged(QString,QString,QString)),
- this, SLOT(_q_serviceOwnerChanged(QString,QString,QString)));
+ if (d_func()->isValid &&
+ d_func()->connection.isConnected()
+ && !service.isEmpty()
+ && !service.startsWith(QLatin1Char(':')))
+ d_func()->connection.connect(QLatin1String(DBUS_SERVICE_DBUS), // service
+ QString(), // path
+ QLatin1String(DBUS_INTERFACE_DBUS), // interface
+ QLatin1String("NameOwnerChanged"),
+ QStringList() << service,
+ QString(), //signature
+ this, SLOT(_q_serviceOwnerChanged(QString,QString,QString)));
}
/*!
@@ -544,9 +560,16 @@ void QDBusAbstractInterface::connectNotify(const char *signal)
return;
QDBusConnectionPrivate *conn = d->connectionPrivate();
- if (conn)
- conn->connectRelay(d->service, d->currentOwner, d->path, d->interface,
+ if (conn) {
+ // do we know what our owner is?
+ QString owner;
+ if (!d->service.isEmpty() && d->currentOwner.isNull())
+ owner = QLatin1String("");
+ else
+ owner = d->currentOwner;
+ conn->connectRelay(d->service, owner, d->path, d->interface,
this, signal);
+ }
}
/*!
diff --git a/src/dbus/qdbusconnection.cpp b/src/dbus/qdbusconnection.cpp
index bb0d06f..d7088ff 100644
--- a/src/dbus/qdbusconnection.cpp
+++ b/src/dbus/qdbusconnection.cpp
@@ -557,42 +557,61 @@ QDBusPendingCall QDBusConnection::asyncCall(const QDBusMessage &message, int tim
bool QDBusConnection::connect(const QString &service, const QString &path, const QString& interface,
const QString &name, QObject *receiver, const char *slot)
{
- return connect(service, path, interface, name, QString(), receiver, slot);
+ return connect(service, path, interface, name, QStringList(), QString(), receiver, slot);
}
/*!
- Disconnects the signal specified by the \a service, \a path, \a interface and \a name parameters from
- the slot \a slot in object \a receiver. The arguments \a service and \a path can be empty,
- denoting a disconnection from all signals of the (\a interface, \a name) pair, from all remote
- applications.
+ \overload
- Returns true if the disconnection was successful.
+ Connects the signal to the slot \a slot in object \a
+ receiver. Unlike the previous connect() overload, this function
+ allows one to specify the parameter signature to be connected
+ using the \a signature variable. The function will then verify
+ that this signature can be delivered to the slot specified by \a
+ slot and return false otherwise.
+
+ Returns true if the connection was successful.
+
+ \note This function verifies that the signal signature matches the
+ slot's parameters, but it does not verify that the actual
+ signal exists with the given signature in the remote
+ service.
*/
-bool QDBusConnection::disconnect(const QString &service, const QString &path, const QString &interface,
- const QString &name, QObject *receiver, const char *slot)
+bool QDBusConnection::connect(const QString &service, const QString &path, const QString& interface,
+ const QString &name, const QString &signature,
+ QObject *receiver, const char *slot)
{
- return disconnect(service, path, interface, name, QString(), receiver, slot);
+ return connect(service, path, interface, name, QStringList(), signature, receiver, slot);
}
/*!
\overload
+ \since 4.6
Connects the signal to the slot \a slot in object \a
- receiver. Unlike the other connect() overload, this function
+ receiver. Unlike the previous connect() overload, this function
allows one to specify the parameter signature to be connected
using the \a signature variable. The function will then verify
that this signature can be delivered to the slot specified by \a
slot and return false otherwise.
+ The \a argumentMatch parameter lists the string parameters to be matched,
+ in sequential order. Note that, to match an empty string, you need to
+ pass a QString that is empty but not null (i.e., QString("")). A null
+ QString skips matching at that position.
+
+ Returns true if the connection was successful.
+
\note This function verifies that the signal signature matches the
slot's parameters, but it does not verify that the actual
signal exists with the given signature in the remote
service.
*/
bool QDBusConnection::connect(const QString &service, const QString &path, const QString& interface,
- const QString &name, const QString &signature,
+ const QString &name, const QStringList &argumentMatch, const QString &signature,
QObject *receiver, const char *slot)
{
+
if (!receiver || !slot || !d || !d->connection)
return false;
if (!interface.isEmpty() && !QDBusUtil::isValidInterfaceName(interface))
@@ -600,53 +619,57 @@ bool QDBusConnection::connect(const QString &service, const QString &path, const
if (interface.isEmpty() && name.isEmpty())
return false;
- // check the slot
- QDBusConnectionPrivate::SignalHook hook;
- QString key;
- QString name2 = name;
- if (name2.isNull())
- name2.detach();
-
QString owner = d->getNameOwner(service); // we don't care if the owner is empty
- hook.signature = signature; // it might get started later
- if (!d->prepareHook(hook, key, service, owner, path, interface, name, receiver, slot, 0, false))
- return false; // don't connect
-
- // avoid duplicating:
+ // it might get started later
QDBusWriteLocker locker(ConnectAction, d);
- QDBusConnectionPrivate::SignalHookHash::ConstIterator it = d->signalHooks.find(key);
- QDBusConnectionPrivate::SignalHookHash::ConstIterator end = d->signalHooks.constEnd();
- for ( ; it != end && it.key() == key; ++it) {
- const QDBusConnectionPrivate::SignalHook &entry = it.value();
- if (entry.service == hook.service &&
- entry.owner == hook.owner &&
- entry.path == hook.path &&
- entry.signature == hook.signature &&
- entry.obj == hook.obj &&
- entry.midx == hook.midx) {
- // no need to compare the parameters if it's the same slot
- return true; // already there
- }
- }
+ return d->connectSignal(service, owner, path, interface, name, argumentMatch, signature, receiver, slot);
+}
+
+/*!
+ Disconnects the signal specified by the \a service, \a path, \a interface
+ and \a name parameters from the slot \a slot in object \a receiver. The
+ arguments must be the same as passed to the connect() function.
- d->connectSignal(key, hook);
- return true;
+ Returns true if the disconnection was successful.
+*/
+bool QDBusConnection::disconnect(const QString &service, const QString &path, const QString &interface,
+ const QString &name, QObject *receiver, const char *slot)
+{
+ return disconnect(service, path, interface, name, QStringList(), QString(), receiver, slot);
}
/*!
\overload
- Disconnects the signal from the slot \a slot in object \a
- receiver. Unlike the other disconnect() overload, this function
- allows one to specify the parameter signature to be disconnected
- using the \a signature variable. The function will then verify
- that this signature is connected to the slot specified by \a slot
- and return false otherwise.
+ Disconnects the signal specified by the \a service, \a path, \a
+ interface, \a name, and \a signature parameters from the slot \a slot in
+ object \a receiver. The arguments must be the same as passed to the
+ connect() function.
+
+ Returns true if the disconnection was successful.
*/
bool QDBusConnection::disconnect(const QString &service, const QString &path, const QString& interface,
const QString &name, const QString &signature,
QObject *receiver, const char *slot)
{
+ return disconnect(service, path, interface, name, QStringList(), signature, receiver, slot);
+}
+
+/*!
+ \overload
+ \since 4.6
+
+ Disconnects the signal specified by the \a service, \a path, \a
+ interface, \a name, \a argumentMatch, and \a signature parameters from
+ the slot \a slot in object \a receiver. The arguments must be the same as
+ passed to the connect() function.
+
+ Returns true if the disconnection was successful.
+*/
+bool QDBusConnection::disconnect(const QString &service, const QString &path, const QString& interface,
+ const QString &name, const QStringList &argumentMatch, const QString &signature,
+ QObject *receiver, const char *slot)
+{
if (!receiver || !slot || !d || !d->connection)
return false;
if (!interface.isEmpty() && !QDBusUtil::isValidInterfaceName(interface))
@@ -654,38 +677,8 @@ bool QDBusConnection::disconnect(const QString &service, const QString &path, co
if (interface.isEmpty() && name.isEmpty())
return false;
- // check the slot
- QDBusConnectionPrivate::SignalHook hook;
- QString key;
- QString name2 = name;
- if (name2.isNull())
- name2.detach();
-
- QString owner = d->getNameOwner(service); // we don't care of owner is empty
- hook.signature = signature;
- if (!d->prepareHook(hook, key, service, owner, path, interface, name, receiver, slot, 0, false))
- return false; // don't disconnect
-
- // avoid duplicating:
QDBusWriteLocker locker(DisconnectAction, d);
- QDBusConnectionPrivate::SignalHookHash::Iterator it = d->signalHooks.find(key);
- QDBusConnectionPrivate::SignalHookHash::Iterator end = d->signalHooks.end();
- for ( ; it != end && it.key() == key; ++it) {
- const QDBusConnectionPrivate::SignalHook &entry = it.value();
- if (entry.service == hook.service &&
- entry.owner == hook.owner &&
- entry.path == hook.path &&
- entry.signature == hook.signature &&
- entry.obj == hook.obj &&
- entry.midx == hook.midx) {
- // no need to compare the parameters if it's the same slot
- d->disconnectSignal(it);
- return true; // it was there
- }
- }
-
- // the slot was not found
- return false;
+ return d->disconnectSignal(service, path, interface, name, argumentMatch, signature, receiver, slot);
}
/*!
@@ -1012,14 +1005,10 @@ void QDBusConnectionPrivate::setBusService(const QDBusConnection &connection)
busService = new QDBusConnectionInterface(connection, this);
ref.deref(); // busService has increased the refcounting to us
// avoid cyclic refcounting
-// if (mode != PeerMode)
- QObject::connect(busService, SIGNAL(serviceOwnerChanged(QString,QString,QString)),
- this, SIGNAL(serviceOwnerChanged(QString,QString,QString)));
QObject::connect(this, SIGNAL(callWithCallbackFailed(QDBusError,QDBusMessage)),
busService, SIGNAL(callWithCallbackFailed(QDBusError,QDBusMessage)),
Qt::QueuedConnection);
-
}
/*!
diff --git a/src/dbus/qdbusconnection.h b/src/dbus/qdbusconnection.h
index 85fc7c2..82ae726 100644
--- a/src/dbus/qdbusconnection.h
+++ b/src/dbus/qdbusconnection.h
@@ -132,15 +132,21 @@ public:
bool connect(const QString &service, const QString &path, const QString &interface,
const QString &name, QObject *receiver, const char *slot);
- bool disconnect(const QString &service, const QString &path, const QString &interface,
- const QString &name, QObject *receiver, const char *slot);
-
bool connect(const QString &service, const QString &path, const QString &interface,
const QString &name, const QString& signature,
QObject *receiver, const char *slot);
+ bool connect(const QString &service, const QString &path, const QString &interface,
+ const QString &name, const QStringList &argumentMatch, const QString& signature,
+ QObject *receiver, const char *slot);
+
+ bool disconnect(const QString &service, const QString &path, const QString &interface,
+ const QString &name, QObject *receiver, const char *slot);
bool disconnect(const QString &service, const QString &path, const QString &interface,
const QString &name, const QString& signature,
QObject *receiver, const char *slot);
+ bool disconnect(const QString &service, const QString &path, const QString &interface,
+ const QString &name, const QStringList &argumentMatch, const QString& signature,
+ QObject *receiver, const char *slot);
bool registerObject(const QString &path, QObject *object,
RegisterOptions options = ExportAdaptors);
diff --git a/src/dbus/qdbusconnection_p.h b/src/dbus/qdbusconnection_p.h
index ab96457..ed29e4e 100644
--- a/src/dbus/qdbusconnection_p.h
+++ b/src/dbus/qdbusconnection_p.h
@@ -154,6 +154,7 @@ public:
typedef QMultiHash<QString, SignalHook> SignalHookHash;
typedef QHash<QString, QDBusMetaObject* > MetaObjectHash;
typedef QHash<QByteArray, int> MatchRefCountHash;
+ typedef QHash<QString, int> WatchedServicesHash;
public:
// public methods are entry points from other objects
@@ -175,8 +176,14 @@ public:
QDBusPendingCallPrivate *sendWithReplyAsync(const QDBusMessage &message, int timeout = -1);
int sendWithReplyAsync(const QDBusMessage &message, QObject *receiver,
const char *returnMethod, const char *errorMethod, int timeout = -1);
+ bool connectSignal(const QString &service, const QString &owner, const QString &path, const QString& interface,
+ const QString &name, const QStringList &argumentMatch, const QString &signature,
+ QObject *receiver, const char *slot);
void connectSignal(const QString &key, const SignalHook &hook);
SignalHookHash::Iterator disconnectSignal(SignalHookHash::Iterator &it);
+ bool disconnectSignal(const QString &service, const QString &path, const QString& interface,
+ const QString &name, const QStringList &argumentMatch, const QString &signature,
+ QObject *receiver, const char *slot);
void registerObject(const ObjectTreeNode *node);
void connectRelay(const QString &service, const QString &currentOwner,
const QString &path, const QString &interface,
@@ -264,6 +271,7 @@ public:
QDBusError lastError;
QStringList serviceNames;
+ WatchedServicesHash watchedServiceNames;
SignalHookHash signalHooks;
MatchRefCountHash matchRefCounts;
ObjectTreeNode rootNode;
@@ -278,6 +286,7 @@ public:
static bool prepareHook(QDBusConnectionPrivate::SignalHook &hook, QString &key,
const QString &service, const QString &owner,
const QString &path, const QString &interface, const QString &name,
+ const QStringList &argMatch,
QObject *receiver, const char *signal, int minMIdx,
bool buildSignature);
static DBusHandlerResult messageFilter(DBusConnection *, DBusMessage *, void *);
diff --git a/src/dbus/qdbusconnectioninterface.cpp b/src/dbus/qdbusconnectioninterface.cpp
index 8670ed5..414d318 100644
--- a/src/dbus/qdbusconnectioninterface.cpp
+++ b/src/dbus/qdbusconnectioninterface.cpp
@@ -336,8 +336,14 @@ void QDBusConnectionInterface::connectNotify(const char *signalName)
else if (qstrcmp(signalName, SIGNAL(serviceUnregistered(QString))) == 0)
QDBusAbstractInterface::connectNotify(SIGNAL(NameLost(QString)));
- else if (qstrcmp(signalName, SIGNAL(serviceOwnerChanged(QString,QString,QString))) == 0)
+ else if (qstrcmp(signalName, SIGNAL(serviceOwnerChanged(QString,QString,QString))) == 0) {
+ static bool warningPrinted = false;
+ if (!warningPrinted) {
+ qWarning("Connecting to deprecated signal QDBusConnectionInterface::serviceOwnerChanged(QString,QString,QString)");
+ warningPrinted = true;
+ }
QDBusAbstractInterface::connectNotify(SIGNAL(NameOwnerChanged(QString,QString,QString)));
+ }
}
/*!
diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp
index 686b56f..748658d 100644
--- a/src/dbus/qdbusintegrator.cpp
+++ b/src/dbus/qdbusintegrator.cpp
@@ -392,7 +392,7 @@ static void qDBusNewConnection(DBusServer *server, DBusConnection *connection, v
static QByteArray buildMatchRule(const QString &service, const QString & /*owner*/,
const QString &objectPath, const QString &interface,
- const QString &member, const QString & /*signature*/)
+ const QString &member, const QStringList &argMatch, const QString & /*signature*/)
{
QString result = QLatin1String("type='signal',");
QString keyValue = QLatin1String("%1='%2',");
@@ -406,6 +406,14 @@ static QByteArray buildMatchRule(const QString &service, const QString & /*owner
if (!member.isEmpty())
result += keyValue.arg(QLatin1String("member"), member);
+ // add the argument string-matching now
+ if (!argMatch.isEmpty()) {
+ keyValue = QLatin1String("arg%1='%2',");
+ for (int i = 0; i < argMatch.count(); ++i)
+ if (!argMatch.at(i).isNull())
+ result += keyValue.arg(i).arg(argMatch.at(i));
+ }
+
result.chop(1); // remove ending comma
return result.toLatin1();
}
@@ -493,6 +501,11 @@ static QObject *findChildObject(const QDBusConnectionPrivate::ObjectTreeNode *ro
return 0;
}
+static bool shouldWatchService(const QString &service)
+{
+ return !service.isEmpty() && !service.startsWith(QLatin1Char(':'));
+}
+
extern QDBUS_EXPORT void qDBusAddSpyHook(QDBusSpyHook);
void qDBusAddSpyHook(QDBusSpyHook hook)
{
@@ -933,6 +946,7 @@ QDBusConnectionPrivate::QDBusConnectionPrivate(QObject *p)
QDBusMetaTypeId::init();
rootNode.flags = 0;
+ watchedServiceNames[QLatin1String(DBUS_SERVICE_DBUS)] = 1;
connect(this, SIGNAL(serviceOwnerChanged(QString,QString,QString)),
this, SLOT(_q_serviceOwnerChanged(QString,QString,QString)));
@@ -1195,6 +1209,7 @@ int QDBusConnectionPrivate::findSlot(QObject* obj, const QByteArray &normalizedN
bool QDBusConnectionPrivate::prepareHook(QDBusConnectionPrivate::SignalHook &hook, QString &key,
const QString &service, const QString &owner,
const QString &path, const QString &interface, const QString &name,
+ const QStringList &argMatch,
QObject *receiver, const char *signal, int minMIdx,
bool buildSignature)
{
@@ -1235,7 +1250,7 @@ bool QDBusConnectionPrivate::prepareHook(QDBusConnectionPrivate::SignalHook &hoo
hook.signature += QLatin1String( QDBusMetaType::typeToSignature( hook.params.at(i) ) );
}
- hook.matchRule = buildMatchRule(service, owner, path, interface, mname, hook.signature);
+ hook.matchRule = buildMatchRule(service, owner, path, interface, mname, argMatch, hook.signature);
return true; // connect to this signal
}
@@ -1478,7 +1493,7 @@ void QDBusConnectionPrivate::handleSignal(const QString &key, const QDBusMessage
//qDBusDebug() << signalHooks.keys();
for ( ; it != end && it.key() == key; ++it) {
const SignalHook &hook = it.value();
- if (!hook.owner.isEmpty() && hook.owner != msg.service())
+ if (!hook.owner.isNull() && hook.owner != msg.service())
continue;
if (!hook.path.isEmpty() && hook.path != msg.path())
continue;
@@ -1933,6 +1948,42 @@ int QDBusConnectionPrivate::sendWithReplyAsync(const QDBusMessage &message, QObj
return 1;
}
+bool QDBusConnectionPrivate::connectSignal(const QString &service, const QString &owner,
+ const QString &path, const QString &interface, const QString &name,
+ const QStringList &argumentMatch, const QString &signature,
+ QObject *receiver, const char *slot)
+{
+ // check the slot
+ QDBusConnectionPrivate::SignalHook hook;
+ QString key;
+ QString name2 = name;
+ if (name2.isNull())
+ name2.detach();
+
+ hook.signature = signature;
+ if (!prepareHook(hook, key, service, owner, path, interface, name, argumentMatch, receiver, slot, 0, false))
+ return false; // don't connect
+
+ // avoid duplicating:
+ QDBusConnectionPrivate::SignalHookHash::ConstIterator it = signalHooks.find(key);
+ QDBusConnectionPrivate::SignalHookHash::ConstIterator end = signalHooks.constEnd();
+ for ( ; it != end && it.key() == key; ++it) {
+ const QDBusConnectionPrivate::SignalHook &entry = it.value();
+ if (entry.service == hook.service &&
+ entry.owner == hook.owner &&
+ entry.path == hook.path &&
+ entry.signature == hook.signature &&
+ entry.obj == hook.obj &&
+ entry.midx == hook.midx) {
+ // no need to compare the parameters if it's the same slot
+ return true; // already there
+ }
+ }
+
+ connectSignal(key, hook);
+ return true;
+}
+
void QDBusConnectionPrivate::connectSignal(const QString &key, const SignalHook &hook)
{
signalHooks.insertMulti(key, hook);
@@ -1960,15 +2011,81 @@ void QDBusConnectionPrivate::connectSignal(const QString &key, const SignalHook
hook.obj->metaObject()->method(hook.midx).signature(),
qPrintable(qerror.name()), qPrintable(qerror.message()));
Q_ASSERT(false);
+ } else {
+ // Successfully connected the signal
+ // Do we need to watch for this name?
+ if (shouldWatchService(hook.service)) {
+ WatchedServicesHash::Iterator it = watchedServiceNames.find(hook.service);
+ if (it != watchedServiceNames.end()) {
+ // already watching
+ ++it.value();
+ } else {
+ // we need to watch for this service changing
+ QString dbusServerService = QLatin1String(DBUS_SERVICE_DBUS);
+ connectSignal(dbusServerService, dbusServerService, QString(), QLatin1String(DBUS_INTERFACE_DBUS),
+ QLatin1String("NameOwnerChanged"), QStringList() << hook.service, QString(),
+ this, SLOT(_q_serviceOwnerChanged(QString,QString,QString)));
+ }
+ }
}
}
}
+bool QDBusConnectionPrivate::disconnectSignal(const QString &service,
+ const QString &path, const QString &interface, const QString &name,
+ const QStringList &argumentMatch, const QString &signature,
+ QObject *receiver, const char *slot)
+{
+ // check the slot
+ QDBusConnectionPrivate::SignalHook hook;
+ QString key;
+ QString name2 = name;
+ if (name2.isNull())
+ name2.detach();
+
+ hook.signature = signature;
+ if (!prepareHook(hook, key, service, QString(), path, interface, name, argumentMatch, receiver, slot, 0, false))
+ return false; // don't disconnect
+
+ // avoid duplicating:
+ QDBusConnectionPrivate::SignalHookHash::Iterator it = signalHooks.find(key);
+ QDBusConnectionPrivate::SignalHookHash::Iterator end = signalHooks.end();
+ for ( ; it != end && it.key() == key; ++it) {
+ const QDBusConnectionPrivate::SignalHook &entry = it.value();
+ if (entry.service == hook.service &&
+ //entry.owner == hook.owner &&
+ entry.path == hook.path &&
+ entry.signature == hook.signature &&
+ entry.obj == hook.obj &&
+ entry.midx == hook.midx) {
+ // no need to compare the parameters if it's the same slot
+ disconnectSignal(it);
+ return true; // it was there
+ }
+ }
+
+ // the slot was not found
+ return false;
+}
+
QDBusConnectionPrivate::SignalHookHash::Iterator
QDBusConnectionPrivate::disconnectSignal(SignalHookHash::Iterator &it)
{
const SignalHook &hook = it.value();
+ WatchedServicesHash::Iterator sit = watchedServiceNames.find(hook.service);
+ if (sit != watchedServiceNames.end()) {
+ if (sit.value() == 1) {
+ watchedServiceNames.erase(sit);
+ QString dbusServerService = QLatin1String(DBUS_SERVICE_DBUS);
+ disconnectSignal(dbusServerService, QString(), QLatin1String(DBUS_INTERFACE_DBUS),
+ QLatin1String("NameOwnerChanged"), QStringList() << hook.service, QString(),
+ this, SLOT(_q_serviceOwnerChanged(QString,QString,QString)));
+ } else {
+ --sit.value();
+ }
+ }
+
bool erase = false;
MatchRefCountHash::iterator i = matchRefCounts.find(hook.matchRule);
if (i == matchRefCounts.end()) {
@@ -2027,7 +2144,7 @@ void QDBusConnectionPrivate::connectRelay(const QString &service, const QString
SignalHook hook;
QString key;
- if (!prepareHook(hook, key, service, owner, path, interface, QString(), receiver, signal,
+ if (!prepareHook(hook, key, service, owner, path, interface, QString(), QStringList(), receiver, signal,
QDBusAbstractInterface::staticMetaObject.methodCount(), true))
return; // don't connect
@@ -2059,7 +2176,7 @@ void QDBusConnectionPrivate::disconnectRelay(const QString &service, const QStri
SignalHook hook;
QString key;
- if (!prepareHook(hook, key, service, owner, path, interface, QString(), receiver, signal,
+ if (!prepareHook(hook, key, service, owner, path, interface, QString(), QStringList(), receiver, signal,
QDBusAbstractInterface::staticMetaObject.methodCount(), true))
return; // don't connect
diff --git a/src/dbus/qdbusservicewatcher.cpp b/src/dbus/qdbusservicewatcher.cpp
new file mode 100644
index 0000000..4872732
--- /dev/null
+++ b/src/dbus/qdbusservicewatcher.cpp
@@ -0,0 +1,374 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDBus module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdbusservicewatcher.h"
+#include "qdbusconnection.h"
+#include "qdbus_symbols_p.h"
+
+#include <QStringList>
+
+#include <private/qobject_p.h>
+
+Q_GLOBAL_STATIC_WITH_ARGS(QString, busService, (QLatin1String(DBUS_SERVICE_DBUS)))
+Q_GLOBAL_STATIC_WITH_ARGS(QString, busPath, (QLatin1String(DBUS_PATH_DBUS)))
+Q_GLOBAL_STATIC_WITH_ARGS(QString, busInterface, (QLatin1String(DBUS_INTERFACE_DBUS)))
+Q_GLOBAL_STATIC_WITH_ARGS(QString, signalName, (QLatin1String("NameOwnerChanged")))
+
+class QDBusServiceWatcherPrivate: public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QDBusServiceWatcher)
+public:
+ QDBusServiceWatcherPrivate(const QDBusConnection &c, QDBusServiceWatcher::WatchMode wm)
+ : connection(c), watchMode(wm)
+ {
+ }
+
+ QStringList servicesWatched;
+ QDBusConnection connection;
+ QDBusServiceWatcher::WatchMode watchMode;
+
+ void _q_serviceOwnerChanged(const QString &, const QString &, const QString &);
+ void setConnection(const QStringList &services, const QDBusConnection &c, QDBusServiceWatcher::WatchMode watchMode);
+
+ QStringList matchArgsForService(const QString &service);
+ void addService(const QString &service);
+ void removeService(const QString &service);
+};
+
+void QDBusServiceWatcherPrivate::_q_serviceOwnerChanged(const QString &service, const QString &oldOwner, const QString &newOwner)
+{
+ Q_Q(QDBusServiceWatcher);
+ emit q->serviceOwnerChanged(service, oldOwner, newOwner);
+ if (oldOwner.isEmpty())
+ emit q->serviceRegistered(service);
+ else if (newOwner.isEmpty())
+ emit q->serviceUnregistered(service);
+}
+
+void QDBusServiceWatcherPrivate::setConnection(const QStringList &s, const QDBusConnection &c, QDBusServiceWatcher::WatchMode wm)
+{
+ if (connection.isConnected()) {
+ // remove older rules
+ foreach (const QString &s, servicesWatched)
+ removeService(s);
+ }
+
+ connection = c;
+ watchMode = wm;
+ servicesWatched = s;
+
+ if (connection.isConnected()) {
+ // add new rules
+ foreach (const QString &s, servicesWatched)
+ addService(s);
+ }
+}
+
+QStringList QDBusServiceWatcherPrivate::matchArgsForService(const QString &service)
+{
+ QStringList matchArgs;
+ matchArgs << service;
+
+ switch (watchMode) {
+ case QDBusServiceWatcher::WatchForOwnerChange:
+ break;
+
+ case QDBusServiceWatcher::WatchForRegistration:
+ matchArgs << QString::fromLatin1("", 0);
+ break;
+
+ case QDBusServiceWatcher::WatchForUnregistration:
+ matchArgs << QString() << QString::fromLatin1("", 0);
+ break;
+ }
+ return matchArgs;
+}
+
+void QDBusServiceWatcherPrivate::addService(const QString &service)
+{
+ QStringList matchArgs = matchArgsForService(service);
+ connection.connect(*busService(), *busPath(), *busInterface(), *signalName(),
+ matchArgs, QString(), q_func(),
+ SLOT(_q_serviceOwnerChanged(QString,QString,QString)));
+}
+
+void QDBusServiceWatcherPrivate::removeService(const QString &service)
+{
+ QStringList matchArgs = matchArgsForService(service);
+ connection.disconnect(*busService(), *busPath(), *busInterface(), *signalName(),
+ matchArgs, QString(), q_func(),
+ SLOT(_q_serviceOwnerChanged(QString,QString,QString)));
+}
+
+/*!
+ \class QDBusServiceWatcher
+ \since 4.6
+ \inmodule QtDBus
+
+ \brief The QDBusServiceWatcher class allows the user to watch for a bus service change.
+
+ A QDBusServiceWatcher object can be used to notify the application about
+ an ownership change of a service name on the bus. It has three watch
+ modes:
+
+ \list
+ \o watching for service registration only
+ \o watching for service unregistration only
+ \o watching for any kind of service ownership change (the default mode)
+ \endlist
+
+ Besides being created or deleted, services may change owners without a
+ unregister/register operation happening. So the \ref serviceRegistered()
+ and \ref serviceUnregistered() signals may not be emitted if that
+ happens.
+
+ This class is more efficient than using the
+ QDBusConnectionInterface::serviceOwnerChanged() signal because it allows
+ one to receive only the signals for which the class is interested in.
+
+ \sa QDBusConnection
+*/
+
+/*!
+ \enum QDBusServiceWatcher::WatchModeFlag
+
+ QDBusServiceWatcher supports three different watch modes, which are configured by this flag:
+
+ \value WatchForRegistration watch for service registration only, ignoring
+ any signals related to other service ownership change.
+
+ \value WatchForUnregistration watch for service unregistration only,
+ ignoring any signals related to other service ownership change.
+
+ \value WatchForOwnerChange watch for any kind of service ownership
+ change.
+*/
+
+/*!
+ \property QDBusServiceWatcher::watchMode
+
+ The \c watchMode property holds the current watch mode for this
+ QDBusServiceWatcher object. The default value for this property is
+ QDBusServiceWatcher::WatchForOwnershipChange.
+*/
+
+/*!
+ \property QDBusServiceWatcher::watchedServices
+
+ The \c servicesWatched property holds the list of services watched.
+
+ Note that modifying this list with setServicesWatched() is an expensive
+ operation. If you can, prefer to change it by way of addWatchedService()
+ and removeWatchedService().
+*/
+
+/*!
+ \fn void QDBusServiceWatcher::serviceRegistered(const QString &serviceName)
+
+ This signal is emitted whenever this object detects that the service \a
+ serviceName became available on the bus.
+
+ \sa serviceUnregistered(), serviceOwnerChanged()
+*/
+
+/*!
+ \fn void QDBusServiceWatcher::serviceUnregistered(const QString &serviceName)
+
+ This signal is emitted whenever this object detects that the service \a
+ serviceName was unregistered from the bus and is no longer available.
+
+ \sa serviceRegistered(), serviceOwnerChanged()
+*/
+
+/*!
+ \fn void QDBusServiceWatcher::serviceOwnerChanged(const QString &serviceName, const QString &oldOwner, const QString &newOwner)
+
+ This signal is emitted whenever this object detects that there was a
+ service ownership change relating to the \a serviceName service. The \a
+ oldOwner parameter contains the old owner name and \a newOwner is the new
+ owner. Both \a oldOwner and \a newOwner are unique connection names.
+
+ Note that this signal is also emitted whenever the \a serviceName service
+ was registered or unregistered. If it was registered, \a oldOwner will
+ contain an empty string, whereas if it was unregistered, \a newOwner will
+ contain an empty string.
+
+ If you need only to find out if the service is registered or unregistered
+ only, without being notified that the ownership changed, consider using
+ the specific modes for those operations. This class is more efficient if
+ you use the more specific modes.
+
+ \sa serviceRegistered(), serviceUnregistered()
+*/
+
+/*!
+ Creates a QDBusServiceWatcher object. Note that until you set a
+ connection with setConnection(), this object will not emit any signals.
+
+ The \a parent parameter is passed to QObject to set the parent of this
+ object.
+*/
+QDBusServiceWatcher::QDBusServiceWatcher(QObject *parent)
+ : QObject(*new QDBusServiceWatcherPrivate(QDBusConnection(QString()), WatchForOwnerChange), parent)
+{
+}
+
+/*!
+ Creates a QDBusServiceWatcher object and attaches it to the \a connection
+ connection. Also, this function immediately starts watching for \a
+ watchMode changes to service \a service.
+
+ The \a parent parameter is passed to QObject to set the parent of this
+ object.
+*/
+QDBusServiceWatcher::QDBusServiceWatcher(const QString &service, const QDBusConnection &connection, WatchMode watchMode, QObject *parent)
+ : QObject(*new QDBusServiceWatcherPrivate(connection, watchMode), parent)
+{
+ d_func()->setConnection(QStringList() << service, connection, watchMode);
+}
+
+/*!
+ Destroys the QDBusServiceWatcher object and releases any resources
+ associated with it.
+*/
+QDBusServiceWatcher::~QDBusServiceWatcher()
+{
+}
+
+/*!
+ Returns the list of D-Bus services that are being watched.
+
+ \sa setWatchedServices()
+*/
+QStringList QDBusServiceWatcher::watchedServices() const
+{
+ return d_func()->servicesWatched;
+}
+
+/*!
+ Sets the list of D-Bus services being watched to be \a services.
+
+ Note that setting the entire list means removing all previous rules for
+ watching services and adding new ones. This is an expensive operation and
+ should be avoided, if possible. Instead, use addWatchedService() and
+ removeWatchedService() if you can to manipulate entries in the list.
+*/
+void QDBusServiceWatcher::setWatchedServices(const QStringList &services)
+{
+ Q_D(QDBusServiceWatcher);
+ if (services == d->servicesWatched)
+ return;
+ d->setConnection(services, d->connection, d->watchMode);
+}
+
+/*!
+ Adds \a newService to the list of services to be watched by this object.
+ This function is more efficient than setWatchedServices() and should be
+ used whenever possible to add services.
+*/
+void QDBusServiceWatcher::addWatchedService(const QString &newService)
+{
+ Q_D(QDBusServiceWatcher);
+ if (d->servicesWatched.contains(newService))
+ return;
+ d->addService(newService);
+ d->servicesWatched << newService;
+}
+
+/*!
+ Removes the \a service from the list of services being watched by this
+ object. Note that D-Bus notifications are asynchronous, so there may
+ still be signals pending delivery about \a service. Those signals will
+ still be emitted whenever the D-Bus messages are processed.
+
+ This function returns true if any services were removed.
+*/
+bool QDBusServiceWatcher::removeWatchedService(const QString &service)
+{
+ Q_D(QDBusServiceWatcher);
+ d->removeService(service);
+ return d->servicesWatched.removeOne(service);
+}
+
+QDBusServiceWatcher::WatchMode QDBusServiceWatcher::watchMode() const
+{
+ return d_func()->watchMode;
+}
+
+void QDBusServiceWatcher::setWatchMode(WatchMode mode)
+{
+ Q_D(QDBusServiceWatcher);
+ if (mode == d->watchMode)
+ return;
+ d->setConnection(d->servicesWatched, d->connection, mode);
+}
+
+/*!
+ Returns the QDBusConnection that this object is attached to.
+
+ \sa setConnection()
+*/
+QDBusConnection QDBusServiceWatcher::connection() const
+{
+ return d_func()->connection;
+}
+
+/*!
+ Sets the D-Bus connection that this object is attached to be \a
+ connection. All services watched will be transferred to this connection.
+
+ Note that QDBusConnection objects are reference counted:
+ QDBusServiceWatcher will keep a reference for this connection while it
+ exists. The connection is not closed until the reference count drops to
+ zero, so this will ensure that any notifications are received while this
+ QDBusServiceWatcher object exists.
+
+ \sa connection()
+*/
+void QDBusServiceWatcher::setConnection(const QDBusConnection &connection)
+{
+ Q_D(QDBusServiceWatcher);
+ if (connection.name() == d->connection.name())
+ return;
+ d->setConnection(d->servicesWatched, connection, d->watchMode);
+}
+
+#include "moc_qdbusservicewatcher.cpp"
diff --git a/src/dbus/qdbusservicewatcher.h b/src/dbus/qdbusservicewatcher.h
new file mode 100644
index 0000000..a968a9c
--- /dev/null
+++ b/src/dbus/qdbusservicewatcher.h
@@ -0,0 +1,103 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDBus module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDBUSSERVICEWATCHER_H
+#define QDBUSSERVICEWATCHER_H
+
+#include <QtCore/qobject.h>
+#include <QtDBus/qdbusmacros.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(DBus)
+
+class QDBusConnection;
+
+class QDBusServiceWatcherPrivate;
+class QDBUS_EXPORT QDBusServiceWatcher: public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QStringList watchedServices READ watchedServices WRITE setWatchedServices)
+ Q_PROPERTY(WatchMode watchMode READ watchMode WRITE setWatchMode)
+public:
+ enum WatchModeFlag {
+ WatchForRegistration = 0x01,
+ WatchForUnregistration = 0x02,
+ WatchForOwnerChange = 0x03
+ };
+ Q_DECLARE_FLAGS(WatchMode, WatchModeFlag)
+
+ explicit QDBusServiceWatcher(QObject *parent = 0);
+ QDBusServiceWatcher(const QString &service, const QDBusConnection &connection,
+ WatchMode watchMode = WatchForOwnerChange, QObject *parent = 0);
+ ~QDBusServiceWatcher();
+
+ QStringList watchedServices() const;
+ void setWatchedServices(const QStringList &services);
+ void addWatchedService(const QString &newService);
+ bool removeWatchedService(const QString &service);
+
+ WatchMode watchMode() const;
+ void setWatchMode(WatchMode mode);
+
+ QDBusConnection connection() const;
+ void setConnection(const QDBusConnection &connection);
+
+Q_SIGNALS:
+ void serviceRegistered(const QString &service);
+ void serviceUnregistered(const QString &service);
+ void serviceOwnerChanged(const QString &service, const QString &oldOwner, const QString &newOwner);
+
+private:
+ Q_PRIVATE_SLOT(d_func(), void _q_serviceOwnerChanged(QString,QString,QString))
+ Q_DISABLE_COPY(QDBusServiceWatcher)
+ Q_DECLARE_PRIVATE(QDBusServiceWatcher)
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(QDBusServiceWatcher::WatchMode)
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QDBUSSERVICEWATCHER_H