46 #include <QStringList> 48 #include <private/qobject_p.h> 62 QDBusServiceWatcherPrivate(
const QDBusConnection &
c, QDBusServiceWatcher::WatchMode wm)
63 : connection(c), watchMode(wm)
69 QDBusServiceWatcher::WatchMode watchMode;
71 void _q_serviceOwnerChanged(
const QString &,
const QString &,
const QString &);
74 QStringList matchArgsForService(
const QString &service);
75 void addService(
const QString &service);
76 void removeService(
const QString &service);
79 void QDBusServiceWatcherPrivate::_q_serviceOwnerChanged(
const QString &service,
const QString &oldOwner,
const QString &newOwner)
82 emit q->serviceOwnerChanged(service, oldOwner, newOwner);
84 emit q->serviceRegistered(service);
86 emit q->serviceUnregistered(service);
91 if (connection.isConnected()) {
93 foreach (
const QString &s, servicesWatched)
101 if (connection.isConnected()) {
103 foreach (
const QString &s, servicesWatched)
111 matchArgs << service;
128 void QDBusServiceWatcherPrivate::addService(
const QString &service)
130 QStringList matchArgs = matchArgsForService(service);
132 matchArgs,
QString(), q_func(),
136 void QDBusServiceWatcherPrivate::removeService(
const QString &service)
138 QStringList matchArgs = matchArgsForService(service);
140 matchArgs,
QString(), q_func(),
287 :
QObject(*new QDBusServiceWatcherPrivate(connection, watchMode), parent)
289 d_func()->setConnection(
QStringList() << service, connection, watchMode);
307 return d_func()->servicesWatched;
321 if (services ==
d->servicesWatched)
323 d->setConnection(services,
d->connection,
d->watchMode);
334 if (
d->servicesWatched.contains(newService))
336 d->addService(newService);
337 d->servicesWatched << newService;
351 d->removeService(service);
352 return d->servicesWatched.removeOne(service);
357 return d_func()->watchMode;
363 if (mode ==
d->watchMode)
365 d->setConnection(
d->servicesWatched,
d->connection, mode);
375 return d_func()->connection;
393 if (connection.
name() ==
d->connection.name())
395 d->setConnection(
d->servicesWatched, connection,
d->watchMode);
402 #include "moc_qdbusservicewatcher.cpp"
void setWatchedServices(const QStringList &services)
Sets the list of D-Bus services being watched to be services.
#define QT_END_NAMESPACE
This macro expands to.
void setWatchMode(WatchMode mode)
QStringList watchedServices() const
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
bool removeWatchedService(const QString &service)
Removes the service from the list of services being watched by this object.
The QString class provides a Unicode character string.
The QObject class is the base class of all Qt objects.
QString name() const
Returns the connection name for this connection, as given as the name parameter to connectToBus()...
#define QT_BEGIN_NAMESPACE
This macro expands to.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
The QStringList class provides a list of strings.
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
WatchMode watchMode() const
Q_GLOBAL_STATIC_WITH_ARGS(QString, busService,(QLatin1String(DBUS_SERVICE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
void addWatchedService(const QString &newService)
Adds newService to the list of services to be watched by this object.
~QDBusServiceWatcher()
Destroys the QDBusServiceWatcher object and releases any resources associated with it...
#define Q_DECLARE_PUBLIC(Class)
The QDBusConnection class represents a connection to the D-Bus bus daemon.
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
QObject * parent() const
Returns a pointer to the parent object.
QDBusServiceWatcher(QObject *parent=0)
Creates a QDBusServiceWatcher object.
The QDBusServiceWatcher class allows the user to watch for a bus service change.
void setConnection(const QDBusConnection &connection)
Sets the D-Bus connection that this object is attached to be connection.
QDBusConnection connection() const
Returns the QDBusConnection that this object is attached to.