summaryrefslogtreecommitdiffstats
path: root/src/dbus/qdbusservicewatcher.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2015-03-30 17:53:06 -0700
committerThiago Macieira <thiago.macieira@intel.com>2015-09-15 02:08:50 +0000
commitf744aece9df792fdc63593b5bd749ad69dfbd9c1 (patch)
tree451bdaea8b456f27246ece378164b60c4929c9e6 /src/dbus/qdbusservicewatcher.cpp
parent186d8814407ccb3e221537d9797172c37127bc51 (diff)
QDBusServiceWatcher: Move the logic to QDBusConnectionPrivate
With kdbus, we won't have a regular signal, but instead a special message. So keep the logic of what to do in QDBusConnectionPrivate. The #ifdef is to make sure the bootstrapped qdbuscpp2xml continues to build in cross-compilation environments. Change-Id: Iee8cbc07c4434ce9b560ffff13d06f0d9904cb6d Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Diffstat (limited to 'src/dbus/qdbusservicewatcher.cpp')
-rw-r--r--src/dbus/qdbusservicewatcher.cpp36
1 files changed, 7 insertions, 29 deletions
diff --git a/src/dbus/qdbusservicewatcher.cpp b/src/dbus/qdbusservicewatcher.cpp
index 4adf049d17..72c1a12f2c 100644
--- a/src/dbus/qdbusservicewatcher.cpp
+++ b/src/dbus/qdbusservicewatcher.cpp
@@ -38,6 +38,7 @@
#include <QStringList>
#include <private/qobject_p.h>
+#include <private/qdbusconnection_p.h>
#ifndef QT_NO_DBUS
@@ -59,7 +60,6 @@ public:
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);
};
@@ -93,40 +93,18 @@ void QDBusServiceWatcherPrivate::setConnection(const QStringList &s, const QDBus
}
}
-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(QDBusUtil::dbusService(), QString(), QDBusUtil::dbusInterface(), QDBusUtil::nameOwnerChanged(),
- matchArgs, QString(), q_func(),
- SLOT(_q_serviceOwnerChanged(QString,QString,QString)));
+ QDBusConnectionPrivate *d = QDBusConnectionPrivate::d(connection);
+ if (d && d->shouldWatchService(service))
+ d->watchService(service, watchMode, q_func(), SLOT(_q_serviceOwnerChanged(QString,QString,QString)));
}
void QDBusServiceWatcherPrivate::removeService(const QString &service)
{
- QStringList matchArgs = matchArgsForService(service);
- connection.disconnect(QDBusUtil::dbusService(), QString(), QDBusUtil::dbusInterface(), QDBusUtil::nameOwnerChanged(),
- matchArgs, QString(), q_func(),
- SLOT(_q_serviceOwnerChanged(QString,QString,QString)));
+ QDBusConnectionPrivate *d = QDBusConnectionPrivate::d(connection);
+ if (d && d->shouldWatchService(service))
+ d->unwatchService(service, watchMode, q_func(), SLOT(_q_serviceOwnerChanged(QString,QString,QString)));
}
/*!