diff options
Diffstat (limited to 'src/dbus')
66 files changed, 484 insertions, 582 deletions
diff --git a/src/dbus/dbus.pro b/src/dbus/dbus.pro index 8669bb003a..6fd48de48d 100644 --- a/src/dbus/dbus.pro +++ b/src/dbus/dbus.pro @@ -2,8 +2,7 @@ load(qt_module) TARGET = QtDBus QPRO_PWD = $$PWD -QT = core-private \ - xml +QT = core-private CONFIG += link_pkgconfig module MODULE_PRI = ../modules/qt_dbus.pri @@ -21,8 +20,7 @@ unix|win32-g++* { QMAKE_PKGCONFIG_DESCRIPTION = Qt \ DBus \ module - QMAKE_PKGCONFIG_REQUIRES = QtCore \ - QtXml + QMAKE_PKGCONFIG_REQUIRES = QtCore } win32 { wince*:LIBS_PRIVATE += -lws2 diff --git a/src/dbus/qdbus_symbols.cpp b/src/dbus/qdbus_symbols.cpp index 8f02bedf15..7f4d8e7f33 100644 --- a/src/dbus/qdbus_symbols.cpp +++ b/src/dbus/qdbus_symbols.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** 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$ ** ****************************************************************************/ diff --git a/src/dbus/qdbus_symbols_p.h b/src/dbus/qdbus_symbols_p.h index bb17231c34..080fe68e6e 100644 --- a/src/dbus/qdbus_symbols_p.h +++ b/src/dbus/qdbus_symbols_p.h @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** 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$ ** ****************************************************************************/ diff --git a/src/dbus/qdbusabstractadaptor.cpp b/src/dbus/qdbusabstractadaptor.cpp index 6acbd98fbf..9eae45b34b 100644 --- a/src/dbus/qdbusabstractadaptor.cpp +++ b/src/dbus/qdbusabstractadaptor.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** 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$ ** ****************************************************************************/ diff --git a/src/dbus/qdbusabstractadaptor.h b/src/dbus/qdbusabstractadaptor.h index 2f5896a9cb..75a3876b1b 100644 --- a/src/dbus/qdbusabstractadaptor.h +++ b/src/dbus/qdbusabstractadaptor.h @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** 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$ ** ****************************************************************************/ @@ -51,7 +51,6 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE -QT_MODULE(DBus) class QDBusAbstractAdaptorPrivate; class Q_DBUS_EXPORT QDBusAbstractAdaptor: public QObject diff --git a/src/dbus/qdbusabstractadaptor_p.h b/src/dbus/qdbusabstractadaptor_p.h index a9e184a186..a0b61e1887 100644 --- a/src/dbus/qdbusabstractadaptor_p.h +++ b/src/dbus/qdbusabstractadaptor_p.h @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** 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$ ** ****************************************************************************/ diff --git a/src/dbus/qdbusabstractinterface.cpp b/src/dbus/qdbusabstractinterface.cpp index a63864a0b3..eeaf0b13eb 100644 --- a/src/dbus/qdbusabstractinterface.cpp +++ b/src/dbus/qdbusabstractinterface.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** 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$ ** ****************************************************************************/ @@ -125,7 +125,7 @@ void QDBusAbstractInterfacePrivate::property(const QMetaProperty &mp, QVariant & // is this metatype registered? const char *expectedSignature = ""; - if (mp.type() != 0xff) { + if (int(mp.type()) != QMetaType::QVariant) { expectedSignature = QDBusMetaType::typeToSignature(where.userType()); if (expectedSignature == 0) { qWarning("QDBusAbstractInterface: type %s must be registered with QtDBus before it can be " @@ -164,7 +164,7 @@ void QDBusAbstractInterfacePrivate::property(const QMetaProperty &mp, QVariant & const char *foundType = 0; QVariant value = qvariant_cast<QDBusVariant>(reply.arguments().at(0)).variant(); - if (value.userType() == where.userType() || mp.type() == 0xff + if (value.userType() == where.userType() || mp.userType() == QMetaType::QVariant || (expectedSignature[0] == 'v' && expectedSignature[1] == '\0')) { // simple match where = value; diff --git a/src/dbus/qdbusabstractinterface.h b/src/dbus/qdbusabstractinterface.h index 9cc68594e6..648229c061 100644 --- a/src/dbus/qdbusabstractinterface.h +++ b/src/dbus/qdbusabstractinterface.h @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** 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,7 +57,6 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE -QT_MODULE(DBus) class QDBusError; class QDBusPendingCall; diff --git a/src/dbus/qdbusabstractinterface_p.h b/src/dbus/qdbusabstractinterface_p.h index b0fb04e831..4324302cf3 100644 --- a/src/dbus/qdbusabstractinterface_p.h +++ b/src/dbus/qdbusabstractinterface_p.h @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** 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$ ** ****************************************************************************/ diff --git a/src/dbus/qdbusargument.cpp b/src/dbus/qdbusargument.cpp index 4bb5d55724..1c2cb6f0f0 100644 --- a/src/dbus/qdbusargument.cpp +++ b/src/dbus/qdbusargument.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** 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$ ** ****************************************************************************/ @@ -1134,7 +1134,7 @@ const QDBusArgument &operator>>(const QDBusArgument &a, QDate &date) a.endStructure(); if (y != 0 && m != 0 && d != 0) - date.setYMD(y, m, d); + date.setDate(y, m, d); else date = QDate(); return a; diff --git a/src/dbus/qdbusargument.h b/src/dbus/qdbusargument.h index 74a5b37078..b4731fdb1f 100644 --- a/src/dbus/qdbusargument.h +++ b/src/dbus/qdbusargument.h @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** 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$ ** ****************************************************************************/ @@ -59,7 +59,6 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE -QT_MODULE(DBus) class QDBusUnixFileDescriptor; diff --git a/src/dbus/qdbusargument_p.h b/src/dbus/qdbusargument_p.h index c04e458449..02f86c1413 100644 --- a/src/dbus/qdbusargument_p.h +++ b/src/dbus/qdbusargument_p.h @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** 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$ ** ****************************************************************************/ diff --git a/src/dbus/qdbusconnection.cpp b/src/dbus/qdbusconnection.cpp index 50a55040c8..08a840c5c9 100644 --- a/src/dbus/qdbusconnection.cpp +++ b/src/dbus/qdbusconnection.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** 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$ ** ****************************************************************************/ diff --git a/src/dbus/qdbusconnection.h b/src/dbus/qdbusconnection.h index 3b88ad3f9a..ad620fd7a6 100644 --- a/src/dbus/qdbusconnection.h +++ b/src/dbus/qdbusconnection.h @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** 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$ ** ****************************************************************************/ @@ -51,7 +51,6 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE -QT_MODULE(DBus) namespace QDBus { diff --git a/src/dbus/qdbusconnection_p.h b/src/dbus/qdbusconnection_p.h index 46fed80865..41a1341e40 100644 --- a/src/dbus/qdbusconnection_p.h +++ b/src/dbus/qdbusconnection_p.h @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** 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$ ** ****************************************************************************/ @@ -336,7 +336,6 @@ public: // in qdbusmisc.cpp extern int qDBusParametersForMethod(const QMetaMethod &mm, QList<int>& metaTypes); -extern int qDBusNameToTypeId(const char *name); extern bool qDBusCheckAsyncTag(const char *tag); extern bool qDBusInterfaceInObject(QObject *obj, const QString &interface_name); extern QString qDBusInterfaceFromMetaObject(const QMetaObject *mo); diff --git a/src/dbus/qdbusconnectioninterface.cpp b/src/dbus/qdbusconnectioninterface.cpp index 46080027a6..0f85f9090e 100644 --- a/src/dbus/qdbusconnectioninterface.cpp +++ b/src/dbus/qdbusconnectioninterface.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** 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$ ** ****************************************************************************/ diff --git a/src/dbus/qdbusconnectioninterface.h b/src/dbus/qdbusconnectioninterface.h index 93ee6709eb..b3651c87a7 100644 --- a/src/dbus/qdbusconnectioninterface.h +++ b/src/dbus/qdbusconnectioninterface.h @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** 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$ ** ****************************************************************************/ @@ -53,7 +53,6 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE -QT_MODULE(DBus) class QDBusConnection; class QString; diff --git a/src/dbus/qdbusconnectionmanager_p.h b/src/dbus/qdbusconnectionmanager_p.h index 9d929b019b..f82314aa36 100644 --- a/src/dbus/qdbusconnectionmanager_p.h +++ b/src/dbus/qdbusconnectionmanager_p.h @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** 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$ ** ****************************************************************************/ diff --git a/src/dbus/qdbuscontext.cpp b/src/dbus/qdbuscontext.cpp index e4a5d879d7..cc987d1410 100644 --- a/src/dbus/qdbuscontext.cpp +++ b/src/dbus/qdbuscontext.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** 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$ ** ****************************************************************************/ diff --git a/src/dbus/qdbuscontext.h b/src/dbus/qdbuscontext.h index 9ceef6ecc1..dd3a8fca3b 100644 --- a/src/dbus/qdbuscontext.h +++ b/src/dbus/qdbuscontext.h @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** 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$ ** ****************************************************************************/ @@ -51,7 +51,6 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE -QT_MODULE(DBus) class QDBusConnection; class QDBusMessage; diff --git a/src/dbus/qdbuscontext_p.h b/src/dbus/qdbuscontext_p.h index 5aa5da0378..f7f28a114e 100644 --- a/src/dbus/qdbuscontext_p.h +++ b/src/dbus/qdbuscontext_p.h @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** 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$ ** ****************************************************************************/ diff --git a/src/dbus/qdbusdemarshaller.cpp b/src/dbus/qdbusdemarshaller.cpp index 215e6a1eb1..692606b539 100644 --- a/src/dbus/qdbusdemarshaller.cpp +++ b/src/dbus/qdbusdemarshaller.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** 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$ ** ****************************************************************************/ diff --git a/src/dbus/qdbuserror.cpp b/src/dbus/qdbuserror.cpp index 911e104736..9db279e005 100644 --- a/src/dbus/qdbuserror.cpp +++ b/src/dbus/qdbuserror.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** 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$ ** ****************************************************************************/ diff --git a/src/dbus/qdbuserror.h b/src/dbus/qdbuserror.h index 3f6a66c2f4..0cea8e2cde 100644 --- a/src/dbus/qdbuserror.h +++ b/src/dbus/qdbuserror.h @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** 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$ ** ****************************************************************************/ @@ -53,7 +53,6 @@ struct DBusError; QT_BEGIN_NAMESPACE -QT_MODULE(DBus) class QDBusMessage; diff --git a/src/dbus/qdbusextratypes.cpp b/src/dbus/qdbusextratypes.cpp index 8d9d2e06fd..fca3a8db6e 100644 --- a/src/dbus/qdbusextratypes.cpp +++ b/src/dbus/qdbusextratypes.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** 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$ ** ****************************************************************************/ diff --git a/src/dbus/qdbusextratypes.h b/src/dbus/qdbusextratypes.h index 36060ab0a4..c4e843422d 100644 --- a/src/dbus/qdbusextratypes.h +++ b/src/dbus/qdbusextratypes.h @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** 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$ ** ****************************************************************************/ @@ -54,7 +54,6 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE -QT_MODULE(DBus) // defined in qhash.cpp Q_CORE_EXPORT uint qHash(const QString &key); diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index 59b191bd10..f0c8224be2 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** 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$ ** ****************************************************************************/ @@ -645,7 +645,7 @@ static int findSlot(const QMetaObject *mo, const QByteArray &name, int flags, 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; diff --git a/src/dbus/qdbusintegrator_p.h b/src/dbus/qdbusintegrator_p.h index 1e39bd734a..c9a2efc57d 100644 --- a/src/dbus/qdbusintegrator_p.h +++ b/src/dbus/qdbusintegrator_p.h @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** 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$ ** ****************************************************************************/ diff --git a/src/dbus/qdbusinterface.cpp b/src/dbus/qdbusinterface.cpp index 1bf468acad..d390f395ee 100644 --- a/src/dbus/qdbusinterface.cpp +++ b/src/dbus/qdbusinterface.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** 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$ ** ****************************************************************************/ diff --git a/src/dbus/qdbusinterface.h b/src/dbus/qdbusinterface.h index 75e876a389..5e123927fa 100644 --- a/src/dbus/qdbusinterface.h +++ b/src/dbus/qdbusinterface.h @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** 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$ ** ****************************************************************************/ @@ -51,7 +51,6 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE -QT_MODULE(DBus) class QDBusInterfacePrivate; class Q_DBUS_EXPORT QDBusInterface: public QDBusAbstractInterface diff --git a/src/dbus/qdbusinterface_p.h b/src/dbus/qdbusinterface_p.h index b85d3cea77..e9254d03dd 100644 --- a/src/dbus/qdbusinterface_p.h +++ b/src/dbus/qdbusinterface_p.h @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** 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$ ** ****************************************************************************/ diff --git a/src/dbus/qdbusinternalfilters.cpp b/src/dbus/qdbusinternalfilters.cpp index 7d07c92663..de1191afea 100644 --- a/src/dbus/qdbusinternalfilters.cpp +++ b/src/dbus/qdbusinternalfilters.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** 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$ ** ****************************************************************************/ @@ -324,19 +324,15 @@ static int writeProperty(QObject *obj, const QByteArray &property_name, QVariant // we found our property // do we have the right type? - int id = mp.type(); - if (id == QVariant::UserType) { - // dynamic type - id = qDBusNameToTypeId(mp.typeName()); - if (id == -1) { - // type not registered? - qWarning("QDBusConnection: Unable to handle unregistered datatype '%s' for property '%s::%s'", - mp.typeName(), mo->className(), property_name.constData()); - return PropertyWriteFailed; - } + int id = mp.userType(); + if (!id){ + // type not registered or invalid / void? + qWarning("QDBusConnection: Unable to handle unregistered datatype '%s' for property '%s::%s'", + mp.typeName(), mo->className(), property_name.constData()); + return PropertyWriteFailed; } - if (id != 0xff && value.userType() == QDBusMetaTypeId::argument) { + if (id != QMetaType::QVariant && value.userType() == QDBusMetaTypeId::argument) { // we have to demarshall before writing void *null = 0; QVariant other(id, null); @@ -434,7 +430,7 @@ static QVariantMap readAllProperties(QObject *object, int flags) continue; // is it a registered property? - int typeId = qDBusNameToTypeId(mp.typeName()); + int typeId = mp.userType(); if (!typeId) continue; const char *signature = QDBusMetaType::typeToSignature(typeId); diff --git a/src/dbus/qdbusintrospection.cpp b/src/dbus/qdbusintrospection.cpp index 23eda78e5a..88e44a5af3 100644 --- a/src/dbus/qdbusintrospection.cpp +++ b/src/dbus/qdbusintrospection.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** 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$ ** ****************************************************************************/ @@ -407,23 +407,6 @@ QDBusIntrospection::parseObject(const QString &xml, const QString &service, cons return *retval; } -/*! - Parses the XML document fragment (given by \a xml) containing one object node and returns all - the information about the interfaces and sub-objects, found at the service \a service and path - \a path. - - The Objects map returned will contain the absolute path names in the key. -*/ -QDBusIntrospection::ObjectTree -QDBusIntrospection::parseObjectTree(const QString &xml, const QString &service, const QString &path) -{ - QDBusXmlParser parser(service, path, xml); - QSharedDataPointer<QDBusIntrospection::ObjectTree> retval = parser.objectTree(); - if (!retval) - return QDBusIntrospection::ObjectTree(); - return *retval; -} - QT_END_NAMESPACE #endif // QT_NO_DBUS diff --git a/src/dbus/qdbusintrospection_p.h b/src/dbus/qdbusintrospection_p.h index 025cf63fe3..62a2d14f42 100644 --- a/src/dbus/qdbusintrospection_p.h +++ b/src/dbus/qdbusintrospection_p.h @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** 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$ ** ****************************************************************************/ @@ -59,7 +59,7 @@ #include <QtCore/qmap.h> #include <QtCore/qpair.h> #include <QtCore/qshareddata.h> -#include <qdbusmacros.h> +#include "qdbusmacros.h" QT_BEGIN_NAMESPACE @@ -150,26 +150,16 @@ public: { QString service; QString path; - QString introspection; QStringList interfaces; QStringList childObjects; }; - struct ObjectTree: public Object - { - Interfaces interfaceData; - Objects childObjectData; - }; - public: static Interface parseInterface(const QString &xml); static Interfaces parseInterfaces(const QString &xml); static Object parseObject(const QString &xml, const QString &service = QString(), const QString &path = QString()); - static ObjectTree parseObjectTree(const QString &xml, - const QString &service, - const QString &path); private: QDBusIntrospection(); diff --git a/src/dbus/qdbusmacros.h b/src/dbus/qdbusmacros.h index e508362db0..a595e631a2 100644 --- a/src/dbus/qdbusmacros.h +++ b/src/dbus/qdbusmacros.h @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** 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$ ** ****************************************************************************/ @@ -62,7 +62,6 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE -QT_MODULE(DBus) QT_END_NAMESPACE QT_END_HEADER diff --git a/src/dbus/qdbusmarshaller.cpp b/src/dbus/qdbusmarshaller.cpp index 843388c51e..1f6ef99153 100644 --- a/src/dbus/qdbusmarshaller.cpp +++ b/src/dbus/qdbusmarshaller.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** 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$ ** ****************************************************************************/ diff --git a/src/dbus/qdbusmessage.cpp b/src/dbus/qdbusmessage.cpp index 8cd2cc5d67..d6bdc19d51 100644 --- a/src/dbus/qdbusmessage.cpp +++ b/src/dbus/qdbusmessage.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** 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$ ** ****************************************************************************/ diff --git a/src/dbus/qdbusmessage.h b/src/dbus/qdbusmessage.h index 9cb1a476ca..20859ebb70 100644 --- a/src/dbus/qdbusmessage.h +++ b/src/dbus/qdbusmessage.h @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** 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$ ** ****************************************************************************/ @@ -53,7 +53,6 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE -QT_MODULE(DBus) class QDBusMessagePrivate; class Q_DBUS_EXPORT QDBusMessage diff --git a/src/dbus/qdbusmessage_p.h b/src/dbus/qdbusmessage_p.h index da716a6def..d1f1aef371 100644 --- a/src/dbus/qdbusmessage_p.h +++ b/src/dbus/qdbusmessage_p.h @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** 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$ ** ****************************************************************************/ diff --git a/src/dbus/qdbusmetaobject.cpp b/src/dbus/qdbusmetaobject.cpp index e25de261ed..c83865978c 100644 --- a/src/dbus/qdbusmetaobject.cpp +++ b/src/dbus/qdbusmetaobject.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** 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$ ** ****************************************************************************/ @@ -53,6 +53,8 @@ #include "qdbusintrospection_p.h" #include "qdbusabstractinterface_p.h" +#include <private/qmetaobject_p.h> + #ifndef QT_NO_DBUS QT_BEGIN_NAMESPACE @@ -89,47 +91,7 @@ private: QByteArray name; }; - enum PropertyFlags { - Invalid = 0x00000000, - Readable = 0x00000001, - Writable = 0x00000002, - Resettable = 0x00000004, - EnumOrFlag = 0x00000008, - StdCppSet = 0x00000100, - // Override = 0x00000200, - Designable = 0x00001000, - ResolveDesignable = 0x00002000, - Scriptable = 0x00004000, - ResolveScriptable = 0x00008000, - Stored = 0x00010000, - ResolveStored = 0x00020000, - Editable = 0x00040000, - ResolveEditable = 0x00080000, - User = 0x00100000, - ResolveUser = 0x00200000 - }; - - enum MethodFlags { - AccessPrivate = 0x00, - AccessProtected = 0x01, - AccessPublic = 0x02, - AccessMask = 0x03, //mask - - MethodMethod = 0x00, - MethodSignal = 0x04, - MethodSlot = 0x08, - MethodTypeMask = 0x0c, - - MethodCompatibility = 0x10, - MethodCloned = 0x20, - MethodScriptable = 0x40 - }; - - enum MetaObjectFlags { - DynamicMetaObject = 0x01, - RequiresVariantMetaObject = 0x02 - }; - + QMap<QByteArray, Method> signals_; QMap<QByteArray, Method> methods; QMap<QByteArray, Property> properties; @@ -148,19 +110,8 @@ private: static const int intsPerProperty = 2; static const int intsPerMethod = 5; -// ### from kernel/qmetaobject.cpp (Qt 4.1.2): -struct QDBusMetaObjectPrivate +struct QDBusMetaObjectPrivate : public QMetaObjectPrivate { - int revision; - int className; - int classInfoCount, classInfoData; - int methodCount, methodData; - int propertyCount, propertyData; - int enumeratorCount, enumeratorData; - int constructorCount, constructorData; // since revision 2 - int flags; // since revision 3 - - // this is specific for QDBusMetaObject: int propertyDBusData; int methodDBusData; }; @@ -202,9 +153,7 @@ QDBusMetaObjectGenerator::findType(const QByteArray &signature, // verify that it's a valid one if (!typeName.isEmpty()) { // type name found - type = QVariant::nameToType(typeName); - if (type == QVariant::UserType) - type = QMetaType::type(typeName); + type = QMetaType::type(typeName); } if (type == QVariant::Invalid || signature != QDBusMetaType::typeToSignature(type)) { @@ -371,7 +320,7 @@ void QDBusMetaObjectGenerator::parseSignals() mm.flags = AccessProtected | MethodSignal | MethodScriptable; // add - methods.insert(QMetaObject::normalizedSignature(prototype), mm); + signals_.insert(QMetaObject::normalizedSignature(prototype), mm); } } @@ -399,7 +348,7 @@ void QDBusMetaObjectGenerator::parseProperties() mp.flags |= Writable; if (mp.typeName == "QDBusVariant") - mp.flags |= 0xff << 24; + mp.flags |= QMetaType::QVariant << 24; else if (mp.type < 0xff) // encode the type in the flags mp.flags |= mp.type << 24; @@ -423,11 +372,12 @@ void QDBusMetaObjectGenerator::write(QDBusMetaObject *obj) idata.resize(sizeof(QDBusMetaObjectPrivate) / sizeof(int)); QDBusMetaObjectPrivate *header = reinterpret_cast<QDBusMetaObjectPrivate *>(idata.data()); - header->revision = 3; + Q_STATIC_ASSERT_X(QMetaObjectPrivate::OutputRevision == 6, "QtDBus meta-object generator should generate the same version as moc"); + header->revision = QMetaObjectPrivate::OutputRevision; header->className = 0; header->classInfoCount = 0; header->classInfoData = 0; - header->methodCount = methods.count(); + header->methodCount = signals_.count() + methods.count(); header->methodData = idata.size(); header->propertyCount = properties.count(); header->propertyData = header->methodData + header->methodCount * 5; @@ -436,12 +386,16 @@ void QDBusMetaObjectGenerator::write(QDBusMetaObject *obj) header->constructorCount = 0; header->constructorData = 0; header->flags = RequiresVariantMetaObject; + header->signalCount = signals_.count(); + // These are specific to QDBusMetaObject: header->propertyDBusData = header->propertyData + header->propertyCount * 3; header->methodDBusData = header->propertyDBusData + header->propertyCount * intsPerProperty; int data_size = idata.size() + (header->methodCount * (5+intsPerMethod)) + (header->propertyCount * (3+intsPerProperty)); + foreach (const Method &mm, signals_) + data_size += 2 + mm.inputTypes.count() + mm.outputTypes.count(); foreach (const Method &mm, methods) data_size += 2 + mm.inputTypes.count() + mm.outputTypes.count(); idata.resize(data_size + 1); @@ -457,44 +411,48 @@ void QDBusMetaObjectGenerator::write(QDBusMetaObject *obj) idata[typeidOffset++] = 0; // eod // add each method: - for (QMap<QByteArray, Method>::ConstIterator it = methods.constBegin(); - it != methods.constEnd(); ++it) { - // form "prototype\0parameters\0typeName\0tag\0methodname\0inputSignature\0outputSignature" - const Method &mm = it.value(); - - idata[offset++] = stringdata.length(); - stringdata += it.key(); // prototype - stringdata += null; - idata[offset++] = stringdata.length(); - stringdata += mm.parameters; - stringdata += null; - idata[offset++] = stringdata.length(); - stringdata += mm.typeName; - stringdata += null; - idata[offset++] = stringdata.length(); - stringdata += mm.tag; - stringdata += null; - idata[offset++] = mm.flags; - - idata[signatureOffset++] = stringdata.length(); - stringdata += mm.name; - stringdata += null; - idata[signatureOffset++] = stringdata.length(); - stringdata += mm.inputSignature; - stringdata += null; - idata[signatureOffset++] = stringdata.length(); - stringdata += mm.outputSignature; - stringdata += null; - - idata[signatureOffset++] = typeidOffset; - idata[typeidOffset++] = mm.inputTypes.count(); - memcpy(idata.data() + typeidOffset, mm.inputTypes.data(), mm.inputTypes.count() * sizeof(int)); - typeidOffset += mm.inputTypes.count(); - - idata[signatureOffset++] = typeidOffset; - idata[typeidOffset++] = mm.outputTypes.count(); - memcpy(idata.data() + typeidOffset, mm.outputTypes.data(), mm.outputTypes.count() * sizeof(int)); - typeidOffset += mm.outputTypes.count(); + for (int x = 0; x < 2; ++x) { + // Signals must be added before other methods, to match moc. + QMap<QByteArray, Method> &map = (x == 0) ? signals_ : methods; + for (QMap<QByteArray, Method>::ConstIterator it = map.constBegin(); + it != map.constEnd(); ++it) { + // form "prototype\0parameters\0typeName\0tag\0methodname\0inputSignature\0outputSignature" + const Method &mm = it.value(); + + idata[offset++] = stringdata.length(); + stringdata += it.key(); // prototype + stringdata += null; + idata[offset++] = stringdata.length(); + stringdata += mm.parameters; + stringdata += null; + idata[offset++] = stringdata.length(); + stringdata += mm.typeName; + stringdata += null; + idata[offset++] = stringdata.length(); + stringdata += mm.tag; + stringdata += null; + idata[offset++] = mm.flags; + + idata[signatureOffset++] = stringdata.length(); + stringdata += mm.name; + stringdata += null; + idata[signatureOffset++] = stringdata.length(); + stringdata += mm.inputSignature; + stringdata += null; + idata[signatureOffset++] = stringdata.length(); + stringdata += mm.outputSignature; + stringdata += null; + + idata[signatureOffset++] = typeidOffset; + idata[typeidOffset++] = mm.inputTypes.count(); + memcpy(idata.data() + typeidOffset, mm.inputTypes.data(), mm.inputTypes.count() * sizeof(int)); + typeidOffset += mm.inputTypes.count(); + + idata[signatureOffset++] = typeidOffset; + idata[typeidOffset++] = mm.outputTypes.count(); + memcpy(idata.data() + typeidOffset, mm.outputTypes.data(), mm.outputTypes.count() * sizeof(int)); + typeidOffset += mm.outputTypes.count(); + } } Q_ASSERT(offset == header->propertyData); diff --git a/src/dbus/qdbusmetaobject_p.h b/src/dbus/qdbusmetaobject_p.h index 063234a49e..d8385fbcc7 100644 --- a/src/dbus/qdbusmetaobject_p.h +++ b/src/dbus/qdbusmetaobject_p.h @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** 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$ ** ****************************************************************************/ diff --git a/src/dbus/qdbusmetatype.cpp b/src/dbus/qdbusmetatype.cpp index e3ed5b5146..b0d640608a 100644 --- a/src/dbus/qdbusmetatype.cpp +++ b/src/dbus/qdbusmetatype.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** 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$ ** ****************************************************************************/ diff --git a/src/dbus/qdbusmetatype.h b/src/dbus/qdbusmetatype.h index 53b4c29591..bb791c9636 100644 --- a/src/dbus/qdbusmetatype.h +++ b/src/dbus/qdbusmetatype.h @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** 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$ ** ****************************************************************************/ @@ -51,7 +51,6 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE -QT_MODULE(DBus) class Q_DBUS_EXPORT QDBusMetaType { diff --git a/src/dbus/qdbusmetatype_p.h b/src/dbus/qdbusmetatype_p.h index 68deffbe08..8239657232 100644 --- a/src/dbus/qdbusmetatype_p.h +++ b/src/dbus/qdbusmetatype_p.h @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** 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$ ** ****************************************************************************/ diff --git a/src/dbus/qdbusmisc.cpp b/src/dbus/qdbusmisc.cpp index e7c7715eaa..7d68bf1185 100644 --- a/src/dbus/qdbusmisc.cpp +++ b/src/dbus/qdbusmisc.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** 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$ ** ****************************************************************************/ @@ -69,14 +69,6 @@ bool qDBusCheckAsyncTag(const char *tag) return false; } -int qDBusNameToTypeId(const char *name) -{ - int id = static_cast<int>( QVariant::nameToType(name) ); - if (id == QVariant::UserType) - id = QMetaType::type(name); - return id; -} - QString qDBusInterfaceFromMetaObject(const QMetaObject *mo) { QString interface; @@ -158,7 +150,7 @@ int qDBusParametersForMethod(const QMetaMethod &mm, QList<int>& metaTypes) QByteArray basictype = type; basictype.truncate(type.length() - 1); - int id = qDBusNameToTypeId(basictype); + int id = QMetaType::type(basictype); if (id == 0) { //qWarning("Could not parse the method '%s'", mm.signature()); // invalid type in method parameter list @@ -177,7 +169,7 @@ int qDBusParametersForMethod(const QMetaMethod &mm, QList<int>& metaTypes) return -1; // not allowed } - int id = qDBusNameToTypeId(type); + int id = QMetaType::type(type); if (id == 0) { //qWarning("Could not parse the method '%s'", mm.signature()); // invalid type in method parameter list diff --git a/src/dbus/qdbuspendingcall.cpp b/src/dbus/qdbuspendingcall.cpp index 1004146f1d..65d4b5533b 100644 --- a/src/dbus/qdbuspendingcall.cpp +++ b/src/dbus/qdbuspendingcall.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** 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$ ** ****************************************************************************/ diff --git a/src/dbus/qdbuspendingcall.h b/src/dbus/qdbuspendingcall.h index dfdaf4e76a..6dfdef59d0 100644 --- a/src/dbus/qdbuspendingcall.h +++ b/src/dbus/qdbuspendingcall.h @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** 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$ ** ****************************************************************************/ @@ -55,7 +55,6 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE -QT_MODULE(DBus) class QDBusConnection; class QDBusError; diff --git a/src/dbus/qdbuspendingcall_p.h b/src/dbus/qdbuspendingcall_p.h index 02057a74b2..2aaae7b494 100644 --- a/src/dbus/qdbuspendingcall_p.h +++ b/src/dbus/qdbuspendingcall_p.h @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** 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$ ** ****************************************************************************/ diff --git a/src/dbus/qdbuspendingreply.cpp b/src/dbus/qdbuspendingreply.cpp index 5f930c71a1..78b64c4772 100644 --- a/src/dbus/qdbuspendingreply.cpp +++ b/src/dbus/qdbuspendingreply.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** 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$ ** ****************************************************************************/ diff --git a/src/dbus/qdbuspendingreply.h b/src/dbus/qdbuspendingreply.h index 596a459009..ce8354deb3 100644 --- a/src/dbus/qdbuspendingreply.h +++ b/src/dbus/qdbuspendingreply.h @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** 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$ ** ****************************************************************************/ @@ -53,7 +53,6 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE -QT_MODULE(DBus) class Q_DBUS_EXPORT QDBusPendingReplyData: public QDBusPendingCall { diff --git a/src/dbus/qdbusreply.cpp b/src/dbus/qdbusreply.cpp index 6c5b598ea2..098fe7f4bb 100644 --- a/src/dbus/qdbusreply.cpp +++ b/src/dbus/qdbusreply.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** 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$ ** ****************************************************************************/ diff --git a/src/dbus/qdbusreply.h b/src/dbus/qdbusreply.h index b9013185b4..a3170f7d54 100644 --- a/src/dbus/qdbusreply.h +++ b/src/dbus/qdbusreply.h @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** 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,7 +57,6 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE -QT_MODULE(DBus) Q_DBUS_EXPORT void qDBusReplyFill(const QDBusMessage &reply, QDBusError &error, QVariant &data); diff --git a/src/dbus/qdbusserver.cpp b/src/dbus/qdbusserver.cpp index 078f56aa61..32471dfe5d 100644 --- a/src/dbus/qdbusserver.cpp +++ b/src/dbus/qdbusserver.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** 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$ ** ****************************************************************************/ @@ -82,6 +82,31 @@ QDBusServer::QDBusServer(const QString &address, QObject *parent) } /*! + Constructs a QDBusServer with the given \a parent. The server will listen + for connections in \c {/tmp}. +*/ +QDBusServer::QDBusServer(QObject *parent) + : QObject(parent) +{ + const QString address = QLatin1String("unix:tmpdir=/tmp"); + + if (!qdbus_loadLibDBus()) { + d = 0; + return; + } + d = new QDBusConnectionPrivate(this); + + QMutexLocker locker(&QDBusConnectionManager::instance()->mutex); + QDBusConnectionManager::instance()->setConnection(QLatin1String("QDBusServer-") + QString::number(reinterpret_cast<qulonglong>(d)), d); + + QObject::connect(d, SIGNAL(newServerConnection(QDBusConnection)), + this, SIGNAL(newConnection(QDBusConnection))); + + QDBusErrorInternal error; + d->setServer(q_dbus_server_listen(address.toUtf8().constData(), error), error); +} + +/*! Destructs a QDBusServer */ QDBusServer::~QDBusServer() diff --git a/src/dbus/qdbusserver.h b/src/dbus/qdbusserver.h index 900c652d37..dff20a2f2a 100644 --- a/src/dbus/qdbusserver.h +++ b/src/dbus/qdbusserver.h @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** 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$ ** ****************************************************************************/ @@ -51,7 +51,6 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE -QT_MODULE(DBus) class QDBusConnectionPrivate; class QDBusError; @@ -61,7 +60,8 @@ class Q_DBUS_EXPORT QDBusServer: public QObject { Q_OBJECT public: - QDBusServer(const QString &address = "unix:tmpdir=/tmp", QObject *parent = 0); + explicit QDBusServer(const QString &address, QObject *parent = 0); + explicit QDBusServer(QObject *parent = 0); virtual ~QDBusServer(); bool isConnected() const; diff --git a/src/dbus/qdbusservicewatcher.cpp b/src/dbus/qdbusservicewatcher.cpp index 6db9a28712..749d68fad5 100644 --- a/src/dbus/qdbusservicewatcher.cpp +++ b/src/dbus/qdbusservicewatcher.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** 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$ ** ****************************************************************************/ diff --git a/src/dbus/qdbusservicewatcher.h b/src/dbus/qdbusservicewatcher.h index 853064032b..8acf72d900 100644 --- a/src/dbus/qdbusservicewatcher.h +++ b/src/dbus/qdbusservicewatcher.h @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** 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$ ** ****************************************************************************/ @@ -51,7 +51,6 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE -QT_MODULE(DBus) class QDBusConnection; diff --git a/src/dbus/qdbusthreaddebug_p.h b/src/dbus/qdbusthreaddebug_p.h index 131437d370..879f5fdcc1 100644 --- a/src/dbus/qdbusthreaddebug_p.h +++ b/src/dbus/qdbusthreaddebug_p.h @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** 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$ ** ****************************************************************************/ diff --git a/src/dbus/qdbusunixfiledescriptor.cpp b/src/dbus/qdbusunixfiledescriptor.cpp index 5a8835735e..bcf5f64a90 100644 --- a/src/dbus/qdbusunixfiledescriptor.cpp +++ b/src/dbus/qdbusunixfiledescriptor.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the FOO module of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/dbus/qdbusunixfiledescriptor.h b/src/dbus/qdbusunixfiledescriptor.h index 46d933ea24..ad5d00ba0b 100644 --- a/src/dbus/qdbusunixfiledescriptor.h +++ b/src/dbus/qdbusunixfiledescriptor.h @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the FOO module of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -56,7 +56,6 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE -QT_MODULE(DBus) class QDBusUnixFileDescriptorPrivate; template<> QExplicitlySharedDataPointer<QDBusUnixFileDescriptorPrivate>::~QExplicitlySharedDataPointer(); diff --git a/src/dbus/qdbusutil.cpp b/src/dbus/qdbusutil.cpp index 70ef22f428..9ca80864aa 100644 --- a/src/dbus/qdbusutil.cpp +++ b/src/dbus/qdbusutil.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** 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$ ** ****************************************************************************/ diff --git a/src/dbus/qdbusutil_p.h b/src/dbus/qdbusutil_p.h index 50ef4fc9c2..3374d5fa86 100644 --- a/src/dbus/qdbusutil_p.h +++ b/src/dbus/qdbusutil_p.h @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** 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$ ** ****************************************************************************/ diff --git a/src/dbus/qdbusvirtualobject.cpp b/src/dbus/qdbusvirtualobject.cpp index c421e7dfd6..7325bc1f58 100644 --- a/src/dbus/qdbusvirtualobject.cpp +++ b/src/dbus/qdbusvirtualobject.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** 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$ ** ****************************************************************************/ diff --git a/src/dbus/qdbusvirtualobject.h b/src/dbus/qdbusvirtualobject.h index 6f0807f16d..90d4e75d16 100644 --- a/src/dbus/qdbusvirtualobject.h +++ b/src/dbus/qdbusvirtualobject.h @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** 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$ ** ****************************************************************************/ @@ -52,7 +52,6 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE -QT_MODULE(DBus) class QDBusMessage; class QDBusConnection; diff --git a/src/dbus/qdbusxmlgenerator.cpp b/src/dbus/qdbusxmlgenerator.cpp index b49756ebfe..a6572b2c86 100644 --- a/src/dbus/qdbusxmlgenerator.cpp +++ b/src/dbus/qdbusxmlgenerator.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** 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$ ** ****************************************************************************/ @@ -101,7 +101,7 @@ static QString generateInterfaceXml(const QMetaObject *mo, int flags, int method if (mp.isWritable()) access |= 2; - int typeId = qDBusNameToTypeId(mp.typeName()); + int typeId = mp.userType(); if (!typeId) continue; const char *signature = QDBusMetaType::typeToSignature(typeId); @@ -150,7 +150,7 @@ static QString generateInterfaceXml(const QMetaObject *mo, int flags, int method .arg(QLatin1String(signature.left(paren))); // check the return type first - int typeId = qDBusNameToTypeId(mm.typeName()); + int typeId = QMetaType::type(mm.typeName()); if (typeId) { const char *typeName = QDBusMetaType::typeToSignature(typeId); if (typeName) { diff --git a/src/dbus/qdbusxmlparser.cpp b/src/dbus/qdbusxmlparser.cpp index b1d0b78c96..68fc5f0ce4 100644 --- a/src/dbus/qdbusxmlparser.cpp +++ b/src/dbus/qdbusxmlparser.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the QtDBus module of the Qt Toolkit. ** @@ -35,342 +34,325 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ #include "qdbusxmlparser_p.h" -#include "qdbusinterface.h" -#include "qdbusinterface_p.h" -#include "qdbusconnection_p.h" #include "qdbusutil_p.h" -#include <QtXml/qdom.h> #include <QtCore/qmap.h> #include <QtCore/qvariant.h> #include <QtCore/qtextstream.h> +#include <QtCore/qxmlstream.h> +#include <QtCore/qdebug.h> #ifndef QT_NO_DBUS //#define QDBUS_PARSER_DEBUG #ifdef QDBUS_PARSER_DEBUG -# define qDBusParserError qWarning +# define qDBusParserError qDebug #else # define qDBusParserError if (true) {} else qDebug #endif QT_BEGIN_NAMESPACE -static QDBusIntrospection::Annotations -parseAnnotations(const QDomElement& elem) +static bool parseArg(const QXmlStreamAttributes &attributes, QDBusIntrospection::Argument &argData) { - QDBusIntrospection::Annotations retval; - QDomNodeList list = elem.elementsByTagName(QLatin1String("annotation")); - for (int i = 0; i < list.count(); ++i) - { - QDomElement ann = list.item(i).toElement(); - if (ann.isNull()) - continue; - - QString name = ann.attribute(QLatin1String("name")), - value = ann.attribute(QLatin1String("value")); - - if (!QDBusUtil::isValidInterfaceName(name)) { - qDBusParserError("Invalid D-BUS annotation '%s' found while parsing introspection", - qPrintable(name)); - continue; - } + const QString argType = attributes.value(QLatin1String("type")).toString(); - retval.insert(name, value); + bool ok = QDBusUtil::isValidSingleSignature(argType); + if (!ok) { + qDBusParserError("Invalid D-BUS type signature '%s' found while parsing introspection", + qPrintable(argType)); } - return retval; + argData.name = attributes.value(QLatin1String("name")).toString(); + argData.type = argType; + + return ok; } -static QDBusIntrospection::Arguments -parseArgs(const QDomElement& elem, const QLatin1String& direction, bool acceptEmpty) +static bool parseAnnotation(const QXmlStreamReader &xml, QDBusIntrospection::Annotations &annotations) { - QDBusIntrospection::Arguments retval; - QDomNodeList list = elem.elementsByTagName(QLatin1String("arg")); - for (int i = 0; i < list.count(); ++i) - { - QDomElement arg = list.item(i).toElement(); - if (arg.isNull()) - continue; - - if ((acceptEmpty && !arg.hasAttribute(QLatin1String("direction"))) || - arg.attribute(QLatin1String("direction")) == direction) { - - QDBusIntrospection::Argument argData; - if (arg.hasAttribute(QLatin1String("name"))) - argData.name = arg.attribute(QLatin1String("name")); // can be empty - argData.type = arg.attribute(QLatin1String("type")); - if (!QDBusUtil::isValidSingleSignature(argData.type)) { - qDBusParserError("Invalid D-BUS type signature '%s' found while parsing introspection", - qPrintable(argData.type)); - } + Q_ASSERT(xml.isStartElement() && xml.name() == QLatin1String("annotation")); - retval << argData; - } + const QXmlStreamAttributes attributes = xml.attributes(); + const QString name = attributes.value(QLatin1String("name")).toString(); + + if (!QDBusUtil::isValidInterfaceName(name)) { + qDBusParserError("Invalid D-BUS annotation '%s' found while parsing introspection", + qPrintable(name)); + return false; } - return retval; + annotations.insert(name, attributes.value(QLatin1String("value")).toString()); + return true; } -QDBusXmlParser::QDBusXmlParser(const QString& service, const QString& path, - const QString& xmlData) - : m_service(service), m_path(path) +static bool parseProperty(QXmlStreamReader &xml, QDBusIntrospection::Property &propertyData, + const QString &ifaceName) { - QDomDocument doc; - doc.setContent(xmlData); - m_node = doc.firstChildElement(QLatin1String("node")); -} + Q_ASSERT(xml.isStartElement() && xml.name() == QLatin1String("property")); + + QXmlStreamAttributes attributes = xml.attributes(); + const QString propertyName = attributes.value(QLatin1String("name")).toString(); + if (!QDBusUtil::isValidMemberName(propertyName)) { + qDBusParserError("Invalid D-BUS member name '%s' found in interface '%s' while parsing introspection", + qPrintable(propertyName), qPrintable(ifaceName)); + xml.skipCurrentElement(); + return false; + } -QDBusXmlParser::QDBusXmlParser(const QString& service, const QString& path, - const QDomElement& node) - : m_service(service), m_path(path), m_node(node) -{ -} + // parse data + propertyData.name = propertyName; + propertyData.type = attributes.value(QLatin1String("type")).toString(); -QDBusIntrospection::Interfaces -QDBusXmlParser::interfaces() const -{ - QDBusIntrospection::Interfaces retval; - - if (m_node.isNull()) - return retval; - - QDomNodeList interfaceList = m_node.elementsByTagName(QLatin1String("interface")); - for (int i = 0; i < interfaceList.count(); ++i) - { - QDomElement iface = interfaceList.item(i).toElement(); - QString ifaceName = iface.attribute(QLatin1String("name")); - if (iface.isNull()) - continue; // for whatever reason - if (!QDBusUtil::isValidInterfaceName(ifaceName)) { - qDBusParserError("Invalid D-BUS interface name '%s' found while parsing introspection", - qPrintable(ifaceName)); - continue; - } + if (!QDBusUtil::isValidSingleSignature(propertyData.type)) { + // cannot be! + qDBusParserError("Invalid D-BUS type signature '%s' found in property '%s.%s' while parsing introspection", + qPrintable(propertyData.type), qPrintable(ifaceName), + qPrintable(propertyName)); + } - QDBusIntrospection::Interface *ifaceData = new QDBusIntrospection::Interface; - ifaceData->name = ifaceName; - { - // save the data - QTextStream ts(&ifaceData->introspection); - iface.save(ts,2); + const QString access = attributes.value(QLatin1String("access")).toString(); + if (access == QLatin1String("read")) + propertyData.access = QDBusIntrospection::Property::Read; + else if (access == QLatin1String("write")) + propertyData.access = QDBusIntrospection::Property::Write; + else if (access == QLatin1String("readwrite")) + propertyData.access = QDBusIntrospection::Property::ReadWrite; + else { + qDBusParserError("Invalid D-BUS property access '%s' found in property '%s.%s' while parsing introspection", + qPrintable(access), qPrintable(ifaceName), + qPrintable(propertyName)); + return false; // invalid one! + } + + while (xml.readNextStartElement()) { + if (xml.name() == QLatin1String("annotation")) { + parseAnnotation(xml, propertyData.annotations); + } else if (xml.prefix().isEmpty()) { + qDBusParserError() << "Unknown element" << xml.name() << "while checking for annotations"; } + xml.skipCurrentElement(); + } - // parse annotations - ifaceData->annotations = parseAnnotations(iface); - - // parse methods - QDomNodeList list = iface.elementsByTagName(QLatin1String("method")); - for (int j = 0; j < list.count(); ++j) - { - QDomElement method = list.item(j).toElement(); - QString methodName = method.attribute(QLatin1String("name")); - if (method.isNull()) - continue; - if (!QDBusUtil::isValidMemberName(methodName)) { - qDBusParserError("Invalid D-BUS member name '%s' found in interface '%s' while parsing introspection", - qPrintable(methodName), qPrintable(ifaceName)); - continue; - } + if (!xml.isEndElement() || xml.name() != QLatin1String("property")) { + qDBusParserError() << "Invalid property specification" << xml.tokenString() << xml.name(); + return false; + } - QDBusIntrospection::Method methodData; - methodData.name = methodName; + return true; +} - // parse arguments - methodData.inputArgs = parseArgs(method, QLatin1String("in"), true); - methodData.outputArgs = parseArgs(method, QLatin1String("out"), false); - methodData.annotations = parseAnnotations(method); +static bool parseMethod(QXmlStreamReader &xml, QDBusIntrospection::Method &methodData, + const QString &ifaceName) +{ + Q_ASSERT(xml.isStartElement() && xml.name() == QLatin1String("method")); + + const QXmlStreamAttributes attributes = xml.attributes(); + const QString methodName = attributes.value(QLatin1String("name")).toString(); + if (!QDBusUtil::isValidMemberName(methodName)) { + qDBusParserError("Invalid D-BUS member name '%s' found in interface '%s' while parsing introspection", + qPrintable(methodName), qPrintable(ifaceName)); + return false; + } - // add it - ifaceData->methods.insert(methodName, methodData); + methodData.name = methodName; + + QDBusIntrospection::Arguments outArguments; + QDBusIntrospection::Arguments inArguments; + QDBusIntrospection::Annotations annotations; + + while (xml.readNextStartElement()) { + if (xml.name() == QLatin1String("annotation")) { + parseAnnotation(xml, annotations); + } else if (xml.name() == QLatin1String("arg")) { + const QXmlStreamAttributes attributes = xml.attributes(); + const QString direction = attributes.value(QLatin1String("direction")).toString(); + QDBusIntrospection::Argument argument; + if (!attributes.hasAttribute(QLatin1String("direction")) + || direction == QLatin1String("in")) { + parseArg(attributes, argument); + inArguments << argument; + } else if (direction == QLatin1String("out")) { + parseArg(attributes, argument); + outArguments << argument; + } + } else if (xml.prefix().isEmpty()) { + qDBusParserError() << "Unknown element" << xml.name() << "while checking for method arguments"; } + xml.skipCurrentElement(); + } - // parse signals - list = iface.elementsByTagName(QLatin1String("signal")); - for (int j = 0; j < list.count(); ++j) - { - QDomElement signal = list.item(j).toElement(); - QString signalName = signal.attribute(QLatin1String("name")); - if (signal.isNull()) - continue; - if (!QDBusUtil::isValidMemberName(signalName)) { - qDBusParserError("Invalid D-BUS member name '%s' found in interface '%s' while parsing introspection", - qPrintable(signalName), qPrintable(ifaceName)); - continue; - } + methodData.inputArgs = inArguments; + methodData.outputArgs = outArguments; + methodData.annotations = annotations; - QDBusIntrospection::Signal signalData; - signalData.name = signalName; + return true; +} - // parse data - signalData.outputArgs = parseArgs(signal, QLatin1String("out"), true); - signalData.annotations = parseAnnotations(signal); - // add it - ifaceData->signals_.insert(signalName, signalData); - } +static bool parseSignal(QXmlStreamReader &xml, QDBusIntrospection::Signal &signalData, + const QString &ifaceName) +{ + Q_ASSERT(xml.isStartElement() && xml.name() == QLatin1String("signal")); - // parse properties - list = iface.elementsByTagName(QLatin1String("property")); - for (int j = 0; j < list.count(); ++j) - { - QDomElement property = list.item(j).toElement(); - QString propertyName = property.attribute(QLatin1String("name")); - if (property.isNull()) - continue; - if (!QDBusUtil::isValidMemberName(propertyName)) { - qDBusParserError("Invalid D-BUS member name '%s' found in interface '%s' while parsing introspection", - qPrintable(propertyName), qPrintable(ifaceName)); - continue; - } + const QXmlStreamAttributes attributes = xml.attributes(); + const QString signalName = attributes.value(QLatin1String("name")).toString(); - QDBusIntrospection::Property propertyData; + if (!QDBusUtil::isValidMemberName(signalName)) { + qDBusParserError("Invalid D-BUS member name '%s' found in interface '%s' while parsing introspection", + qPrintable(signalName), qPrintable(ifaceName)); + return false; + } - // parse data - propertyData.name = propertyName; - propertyData.type = property.attribute(QLatin1String("type")); - propertyData.annotations = parseAnnotations(property); + signalData.name = signalName; - if (!QDBusUtil::isValidSingleSignature(propertyData.type)) { - // cannot be! - qDBusParserError("Invalid D-BUS type signature '%s' found in property '%s.%s' while parsing introspection", - qPrintable(propertyData.type), qPrintable(ifaceName), - qPrintable(propertyName)); - } - QString access = property.attribute(QLatin1String("access")); - if (access == QLatin1String("read")) - propertyData.access = QDBusIntrospection::Property::Read; - else if (access == QLatin1String("write")) - propertyData.access = QDBusIntrospection::Property::Write; - else if (access == QLatin1String("readwrite")) - propertyData.access = QDBusIntrospection::Property::ReadWrite; - else { - qDBusParserError("Invalid D-BUS property access '%s' found in property '%s.%s' while parsing introspection", - qPrintable(access), qPrintable(ifaceName), - qPrintable(propertyName)); - continue; // invalid one! - } + QDBusIntrospection::Arguments arguments; + QDBusIntrospection::Annotations annotations; - // add it - ifaceData->properties.insert(propertyName, propertyData); + while (xml.readNextStartElement()) { + if (xml.name() == QLatin1String("annotation")) { + parseAnnotation(xml, annotations); + } else if (xml.name() == QLatin1String("arg")) { + const QXmlStreamAttributes attributes = xml.attributes(); + QDBusIntrospection::Argument argument; + if (!attributes.hasAttribute(QLatin1String("direction")) || + attributes.value(QLatin1String("direction")) == QLatin1String("out")) { + parseArg(attributes, argument); + arguments << argument; + } + } else { + qDBusParserError() << "Unknown element" << xml.name() << "while checking for signal arguments"; } - - // add it - retval.insert(ifaceName, QSharedDataPointer<QDBusIntrospection::Interface>(ifaceData)); + xml.skipCurrentElement(); } - return retval; + signalData.outputArgs = arguments; + signalData.annotations = annotations; + + return true; } -QSharedDataPointer<QDBusIntrospection::Object> -QDBusXmlParser::object() const +static void readInterface(QXmlStreamReader &xml, QDBusIntrospection::Object *objData, + QDBusIntrospection::Interfaces *interfaces) { - if (m_node.isNull()) - return QSharedDataPointer<QDBusIntrospection::Object>(); - - QDBusIntrospection::Object* objData; - objData = new QDBusIntrospection::Object; - objData->service = m_service; - objData->path = m_path; - - // check if we have anything to process - if (objData->introspection.isNull() && !m_node.firstChild().isNull()) { - // yes, introspect this object - QTextStream ts(&objData->introspection); - m_node.save(ts,2); - - QDomNodeList objects = m_node.elementsByTagName(QLatin1String("node")); - for (int i = 0; i < objects.count(); ++i) { - QDomElement obj = objects.item(i).toElement(); - QString objName = obj.attribute(QLatin1String("name")); - if (obj.isNull()) - continue; // for whatever reason - if (!QDBusUtil::isValidObjectPath(m_path + QLatin1Char('/') + objName)) { - qDBusParserError("Invalid D-BUS object path '%s/%s' found while parsing introspection", - qPrintable(m_path), qPrintable(objName)); - continue; - } + const QString ifaceName = xml.attributes().value(QLatin1String("name")).toString(); + if (!QDBusUtil::isValidInterfaceName(ifaceName)) { + qDBusParserError("Invalid D-BUS interface name '%s' found while parsing introspection", + qPrintable(ifaceName)); + return; + } - objData->childObjects.append(objName); - } + objData->interfaces.append(ifaceName); - QDomNodeList interfaceList = m_node.elementsByTagName(QLatin1String("interface")); - for (int i = 0; i < interfaceList.count(); ++i) { - QDomElement iface = interfaceList.item(i).toElement(); - QString ifaceName = iface.attribute(QLatin1String("name")); - if (iface.isNull()) - continue; - if (!QDBusUtil::isValidInterfaceName(ifaceName)) { - qDBusParserError("Invalid D-BUS interface name '%s' found while parsing introspection", - qPrintable(ifaceName)); - continue; - } + QDBusIntrospection::Interface *ifaceData = new QDBusIntrospection::Interface; + ifaceData->name = ifaceName; - objData->interfaces.append(ifaceName); + while (xml.readNextStartElement()) { + if (xml.name() == QLatin1String("method")) { + QDBusIntrospection::Method methodData; + if (parseMethod(xml, methodData, ifaceName)) + ifaceData->methods.insert(methodData.name, methodData); + } else if (xml.name() == QLatin1String("signal")) { + QDBusIntrospection::Signal signalData; + if (parseSignal(xml, signalData, ifaceName)) + ifaceData->signals_.insert(signalData.name, signalData); + } else if (xml.name() == QLatin1String("property")) { + QDBusIntrospection::Property propertyData; + if (parseProperty(xml, propertyData, ifaceName)) + ifaceData->properties.insert(propertyData.name, propertyData); + } else if (xml.name() == QLatin1String("annotation")) { + parseAnnotation(xml, ifaceData->annotations); + xml.skipCurrentElement(); // skip over annotation object + } else { + if (xml.prefix().isEmpty()) { + qDBusParserError() << "Unknown element while parsing interface" << xml.name(); + } + xml.skipCurrentElement(); } - } else { - objData->introspection = QLatin1String("<node/>\n"); } - QSharedDataPointer<QDBusIntrospection::Object> retval; - retval = objData; - return retval; + interfaces->insert(ifaceName, QSharedDataPointer<QDBusIntrospection::Interface>(ifaceData)); + + if (!xml.isEndElement() || xml.name() != QLatin1String("interface")) { + qDBusParserError() << "Invalid Interface specification"; + } } -QSharedDataPointer<QDBusIntrospection::ObjectTree> -QDBusXmlParser::objectTree() const +static void readNode(const QXmlStreamReader &xml, QDBusIntrospection::Object *objData, int nodeLevel) { - QSharedDataPointer<QDBusIntrospection::ObjectTree> retval; - - if (m_node.isNull()) - return retval; - - retval = new QDBusIntrospection::ObjectTree; - - retval->service = m_service; - retval->path = m_path; - - QTextStream ts(&retval->introspection); - m_node.save(ts,2); - - // interfaces are easy: - retval->interfaceData = interfaces(); - retval->interfaces = retval->interfaceData.keys(); - - // sub-objects are slightly more difficult: - QDomNodeList objects = m_node.elementsByTagName(QLatin1String("node")); - for (int i = 0; i < objects.count(); ++i) { - QDomElement obj = objects.item(i).toElement(); - QString objName = obj.attribute(QLatin1String("name")); - if (obj.isNull() || objName.isEmpty()) - continue; // for whatever reason - - // check if we have anything to process - if (!obj.firstChild().isNull()) { - // yes, introspect this object - QString xml; - QTextStream ts2(&xml); - obj.save(ts2,0); - - // parse it - QString objAbsName = m_path; - if (!objAbsName.endsWith(QLatin1Char('/'))) - objAbsName.append(QLatin1Char('/')); - objAbsName += objName; - - QDBusXmlParser parser(m_service, objAbsName, obj); - retval->childObjectData.insert(objName, parser.objectTree()); - } + const QString objName = xml.attributes().value(QLatin1String("name")).toString(); + const QString fullName = objData->path.endsWith(QLatin1Char('/')) + ? (objData->path + objName) + : QString(objData->path + QLatin1Char('/') + objName); + if (!QDBusUtil::isValidObjectPath(fullName)) { + qDBusParserError("Invalid D-BUS object path '%s' found while parsing introspection", + qPrintable(fullName)); + return; + } + + if (nodeLevel > 0) + objData->childObjects.append(objName); +} + +QDBusXmlParser::QDBusXmlParser(const QString& service, const QString& path, + const QString& xmlData) + : m_service(service), m_path(path), m_object(new QDBusIntrospection::Object) +{ +// qDBusParserError() << "parsing" << xmlData; - retval->childObjects << objName; + m_object->service = m_service; + m_object->path = m_path; + + QXmlStreamReader xml(xmlData); + + int nodeLevel = -1; + + while (!xml.atEnd()) { + xml.readNext(); + + switch (xml.tokenType()) { + case QXmlStreamReader::StartElement: + if (xml.name() == QLatin1String("node")) { + readNode(xml, m_object, ++nodeLevel); + } else if (xml.name() == QLatin1String("interface")) { + readInterface(xml, m_object, &m_interfaces); + } else { + if (xml.prefix().isEmpty()) { + qDBusParserError() << "skipping unknown element" << xml.name(); + } + xml.skipCurrentElement(); + } + break; + case QXmlStreamReader::EndElement: + if (xml.name() == QLatin1String("node")) { + --nodeLevel; + } else { + qDBusParserError() << "Invalid Node declaration" << xml.name(); + } + break; + case QXmlStreamReader::StartDocument: + case QXmlStreamReader::EndDocument: + case QXmlStreamReader::DTD: + // not interested + break; + case QXmlStreamReader::Comment: + // ignore comments and processing instructions + break; + default: + qDBusParserError() << "unknown token" << xml.name() << xml.tokenString(); + break; + } } - return QSharedDataPointer<QDBusIntrospection::ObjectTree>( retval ); + if (xml.hasError()) { + qDBusParserError() << "xml error" << xml.errorString() << "doc" << xmlData; + } } QT_END_NAMESPACE diff --git a/src/dbus/qdbusxmlparser_p.h b/src/dbus/qdbusxmlparser_p.h index f7677e0ae4..fe82eaf2cf 100644 --- a/src/dbus/qdbusxmlparser_p.h +++ b/src/dbus/qdbusxmlparser_p.h @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** 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$ ** ****************************************************************************/ @@ -54,7 +54,6 @@ // #include <QtCore/qmap.h> -#include <QtXml/qdom.h> #include <qdbusmacros.h> #include "qdbusintrospection_p.h" @@ -69,17 +68,15 @@ class QDBusXmlParser { QString m_service; QString m_path; - QDomElement m_node; + QSharedDataPointer<QDBusIntrospection::Object> m_object; + QDBusIntrospection::Interfaces m_interfaces; public: QDBusXmlParser(const QString& service, const QString& path, const QString& xmlData); - QDBusXmlParser(const QString& service, const QString& path, - const QDomElement& node); - QDBusIntrospection::Interfaces interfaces() const; - QSharedDataPointer<QDBusIntrospection::Object> object() const; - QSharedDataPointer<QDBusIntrospection::ObjectTree> objectTree() const; + inline QDBusIntrospection::Interfaces interfaces() const { return m_interfaces; } + inline QSharedDataPointer<QDBusIntrospection::Object> object() const { return m_object; } }; QT_END_NAMESPACE |