Introduce QMetaType::UnknownType.
[profile/ivi/qtbase.git] / src / dbus / qdbusintegrator.cpp
index f3f3d0b..8d46ee4 100644 (file)
@@ -1,8 +1,7 @@
 /****************************************************************************
 **
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
 **
 ** This file is part of the QtDBus module of the Qt Toolkit.
 **
@@ -35,6 +34,7 @@
 **
 **
 **
+**
 ** $QT_END_LICENSE$
 **
 ****************************************************************************/
@@ -57,6 +57,7 @@
 #include "qdbusabstractadaptor.h"
 #include "qdbusabstractadaptor_p.h"
 #include "qdbusutil_p.h"
+#include "qdbusvirtualobject.h"
 #include "qdbusmessage_p.h"
 #include "qdbuscontext_p.h"
 #include "qdbuspendingcall_p.h"
@@ -442,7 +443,11 @@ static bool findObject(const QDBusConnectionPrivate::ObjectTreeNode *root,
 
     // walk the object tree
     const QDBusConnectionPrivate::ObjectTreeNode *node = root;
-    while (start < length && node && !(node->flags & QDBusConnection::ExportChildObjects)) {
+    while (start < length && node) {
+        if (node->flags & QDBusConnection::ExportChildObjects)
+            break;
+        if ((node->flags & QDBusConnectionPrivate::VirtualObject) && (node->flags & QDBusConnection::SubPath))
+            break;
         int end = fullpath.indexOf(QLatin1Char('/'), start);
         end = (end == -1 ? length : end);
         QStringRef pathComponent(&fullpath, start, end - start);
@@ -552,7 +557,7 @@ bool QDBusConnectionPrivate::handleMessage(const QDBusMessage &amsg)
         (*(*list)[i])(amsg);
     }
 
-    if (!ref)
+    if (!ref.load())
         return false;
 
     switch (amsg.type()) {
@@ -635,12 +640,12 @@ static int findSlot(const QMetaObject *mo, const QByteArray &name, int flags,
             continue;
 
         // check name:
-        QByteArray slotname = mm.signature();
+        QByteArray slotname = mm.methodSignature();
         int paren = slotname.indexOf('(');
         if (paren != name.length() || !slotname.startsWith(name))
             continue;
 
-        int returnType = qDBusNameToTypeId(mm.typeName());
+        int returnType = QMetaType::type(mm.typeName());
         bool isAsync = qDBusCheckAsyncTag(mm.tag());
         bool isScriptable = mm.attributes() & QMetaMethod::Scriptable;
 
@@ -681,7 +686,7 @@ static int findSlot(const QMetaObject *mo, const QByteArray &name, int flags,
             ++i;
 
         // make sure that the output parameters have signatures too
-        if (returnType != 0 && QDBusMetaType::typeToSignature(returnType) == 0)
+        if (returnType != QMetaType::UnknownType && returnType != QMetaType::Void && QDBusMetaType::typeToSignature(returnType) == 0)
             continue;
 
         bool ok = true;
@@ -906,17 +911,15 @@ void QDBusConnectionPrivate::deliverCall(QObject *object, int /*flags*/, const Q
         }
     }
 
-    bool takesMessage = false;
     if (metaTypes.count() > i && metaTypes[i] == QDBusMetaTypeId::message) {
         params.append(const_cast<void*>(static_cast<const void*>(&msg)));
-        takesMessage = true;
         ++i;
     }
 
     // output arguments
     QVariantList outputArgs;
     void *null = 0;
-    if (metaTypes[0] != QMetaType::Void) {
+    if (metaTypes[0] != QMetaType::Void && metaTypes[0] != QMetaType::UnknownType) {
         QVariant arg(metaTypes[0], null);
         outputArgs.append( arg );
         params[0] = const_cast<void*>(outputArgs.at( outputArgs.count() - 1 ).constData());
@@ -1185,7 +1188,7 @@ void QDBusConnectionPrivate::relaySignal(QObject *obj, const QMetaObject *mo, in
     QString interface = qDBusInterfaceFromMetaObject(mo);
 
     QMetaMethod mm = mo->method(signalId);
-    QByteArray memberName = mm.signature();
+    QByteArray memberName = mm.methodSignature();
     memberName.truncate(memberName.indexOf('('));
 
     // check if it's scriptable
@@ -1328,7 +1331,7 @@ bool QDBusConnectionPrivate::activateInternalFilters(const ObjectTreeNode &node,
     if (interface.isEmpty() || interface == QLatin1String(DBUS_INTERFACE_INTROSPECTABLE)) {
         if (msg.member() == QLatin1String("Introspect") && msg.signature().isEmpty()) {
             //qDebug() << "QDBusConnectionPrivate::activateInternalFilters introspect" << msg.d_ptr->msg;
-            QDBusMessage reply = msg.createReply(qDBusIntrospectObject(node));
+            QDBusMessage reply = msg.createReply(qDBusIntrospectObject(node, msg.path()));
             send(reply);
             return true;
         }
@@ -1375,6 +1378,15 @@ void QDBusConnectionPrivate::activateObject(ObjectTreeNode &node, const QDBusMes
 
     // object may be null
 
+    if (node.flags & QDBusConnectionPrivate::VirtualObject) {
+        if (node.treeNode->handleMessage(msg, q(this))) {
+            return;
+        } else {
+            if (activateInternalFilters(node, msg))
+                return;
+        }
+    }
+
     if (pathStartPos != msg.path().length()) {
         node.flags &= ~QDBusConnection::ExportAllSignals;
         node.obj = findChildObject(&node, msg.path(), pathStartPos);
@@ -1969,7 +1981,7 @@ QDBusPendingCallPrivate *QDBusConnectionPrivate::sendWithReplyAsync(const QDBusM
 
     checkThread();
     QDBusPendingCallPrivate *pcall = new QDBusPendingCallPrivate(message, this);
-    pcall->ref = 0;
+    pcall->ref.store(0);
 
     QDBusError error;
     DBusMessage *msg = QDBusMessagePrivate::toDBusMessage(message, capabilities, &error);