summaryrefslogtreecommitdiffstats
path: root/src/dbus/qdbusconnection.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/dbus/qdbusconnection.cpp')
-rw-r--r--src/dbus/qdbusconnection.cpp149
1 files changed, 69 insertions, 80 deletions
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);
-
}
/*!