Index: trunk/src/dbus/qdbusconnection.cpp
===================================================================
--- trunk/src/dbus/qdbusconnection.cpp	(revision 5)
+++ trunk/src/dbus/qdbusconnection.cpp	(revision 561)
@@ -2,5 +2,6 @@
 **
 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
 **
 ** This file is part of the QtDBus module of the Qt Toolkit.
@@ -21,8 +22,7 @@
 ** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** 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.
 **
 ** GNU General Public License Usage
@@ -34,6 +34,6 @@
 ** met: http://www.gnu.org/copyleft/gpl.html.
 **
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
 ** $QT_END_LICENSE$
 **
@@ -558,19 +558,5 @@
                               const QString &name, QObject *receiver, const char *slot)
 {
-    return connect(service, path, interface, name, 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.
-
-    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, QString(), receiver, slot);
+    return connect(service, path, interface, name, QStringList(), QString(), receiver, slot);
 }
 
@@ -579,5 +565,5 @@
 
     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
@@ -585,4 +571,6 @@
     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
@@ -594,4 +582,35 @@
                               QObject *receiver, const char *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 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 QStringList &argumentMatch, const QString &signature,
+                              QObject *receiver, const char *slot)
+{
+
     if (!receiver || !slot || !d || !d->connection)
         return false;
@@ -601,35 +620,19 @@
         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:
     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
-        }
-    }
-
-    d->connectSignal(key, hook);
-    return true;
+    return d->connectSignal(service, 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.
+
+    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);
 }
 
@@ -637,13 +640,31 @@
     \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)
 {
@@ -655,36 +676,6 @@
         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);
 }
 
@@ -974,6 +965,13 @@
 
 /*!
+  \nonreentrant
+
   Returns the connection that sent the signal, if called in a slot activated
   by QDBus; otherwise it returns 0.
+
+  \note Please avoid this function. This function is not thread-safe, so if
+  there's any other thread delivering a D-Bus call, this function may return
+  the wrong connection. In new code, please use QDBusContext::connection()
+  (see that class for a description on how to use it).
 */
 QDBusConnection QDBusConnection::sender()
@@ -1006,12 +1004,8 @@
     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);
-
 }
 
