summaryrefslogtreecommitdiffstats
path: root/src/plugins/script
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@nokia.com>2009-03-23 09:18:55 (GMT)
committerSimon Hausmann <simon.hausmann@nokia.com>2009-03-23 09:18:55 (GMT)
commite5fcad302d86d316390c6b0f62759a067313e8a9 (patch)
treec2afbf6f1066b6ce261f14341cf6d310e5595bc1 /src/plugins/script
downloadQt-e5fcad302d86d316390c6b0f62759a067313e8a9.zip
Qt-e5fcad302d86d316390c6b0f62759a067313e8a9.tar.gz
Qt-e5fcad302d86d316390c6b0f62759a067313e8a9.tar.bz2
Long live Qt 4.5!
Diffstat (limited to 'src/plugins/script')
-rw-r--r--src/plugins/script/qtdbus/main.cpp396
-rw-r--r--src/plugins/script/qtdbus/main.h176
-rw-r--r--src/plugins/script/qtdbus/qtdbus.pro11
-rw-r--r--src/plugins/script/script.pro2
4 files changed, 585 insertions, 0 deletions
diff --git a/src/plugins/script/qtdbus/main.cpp b/src/plugins/script/qtdbus/main.cpp
new file mode 100644
index 0000000..394c1f8
--- /dev/null
+++ b/src/plugins/script/qtdbus/main.cpp
@@ -0,0 +1,396 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** 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.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "main.h"
+#include <QDebug>
+#include <QMetaMethod>
+#include <QScriptExtensionPlugin>
+
+QT_USE_NAMESPACE
+
+static QScriptValue setupDBusInterface(QScriptEngine *engine, QDBusAbstractInterface *iface);
+
+static QScriptValue do_dbus_call(QScriptContext *context, QScriptEngine *engine)
+{
+ int firstArgument = 0;
+ QString functionName = context->callee().property(QLatin1String("functionName")).toString();
+ if (functionName.isEmpty()) {
+ functionName = context->argument(0).toString();
+ ++firstArgument;
+ }
+
+ QScriptValue thisObject = context->thisObject();
+ QDBusAbstractInterface *iface = qobject_cast<QDBusAbstractInterface *>(thisObject.toQObject());
+ if (!iface)
+ return QScriptValue();
+
+ QDBusMessage msg = QDBusMessage::createMethodCall(iface->service(),
+ iface->path(),
+ iface->interface(),
+ functionName);
+
+ QList<QVariant> args;
+ for (int i = firstArgument; i < context->argumentCount(); ++i) {
+ args.append(context->argument(i).toVariant());
+ }
+ msg.setArguments(args);
+
+ msg = iface->connection().call(msg);
+
+ QScriptValue returnValue = engine->nullValue();
+ args = msg.arguments();
+ if (args.count() != 1)
+ return returnValue;
+
+ QVariant variant = args.first();
+ if (variant.type() == QVariant::UserType
+ && variant.userType() == qMetaTypeId<QDBusObjectPath>()) {
+ QDBusObjectPath path = qvariant_cast<QDBusObjectPath>(variant);
+
+ QDBusInterface *returnedIface = new QDBusInterface(iface->service(),
+ path.path(),
+ /*interface*/QString(),
+ iface->connection(),
+ engine);
+ returnValue = setupDBusInterface(engine, returnedIface);
+ } else {
+ returnValue = engine->newVariant(variant);
+ }
+
+ return returnValue;
+}
+
+static QScriptValue setupDBusInterface(QScriptEngine *engine, QDBusAbstractInterface *iface)
+{
+ QScriptValue v = engine->newQObject(iface);
+
+ if (!qobject_cast<QDBusConnectionInterface *>(iface)) {
+ const QMetaObject *mo = iface->metaObject();
+ for (int i = 0; i < mo->methodCount(); ++i) {
+ const QMetaMethod method = mo->method(i);
+ const QByteArray signature = method.signature();
+ //qDebug() << "signature" << signature;
+ int parenIndex = signature.indexOf('(');
+ if (parenIndex == -1)
+ continue;
+ const QByteArray name = signature.left(parenIndex);
+ if (name.isEmpty())
+ continue;
+
+ // don't try to override properties
+ if (mo->indexOfProperty(name) != -1)
+ continue;
+
+ QScriptValue callWrapper = engine->newFunction(do_dbus_call);
+ const QString nameString = QString::fromAscii(name);
+ callWrapper.setProperty(QLatin1String("functionName"), QScriptValue(engine, nameString));
+ v.setProperty(nameString, callWrapper);
+ }
+ }
+
+ v.setProperty(QLatin1String("service"), QScriptValue(engine, iface->service()), QScriptValue::ReadOnly);
+ v.setProperty(QLatin1String("path"), QScriptValue(engine, iface->path()), QScriptValue::ReadOnly);
+ v.setProperty(QLatin1String("interface"), QScriptValue(engine, iface->interface()), QScriptValue::ReadOnly);
+ v.setProperty(QLatin1String("isValid"), QScriptValue(engine, iface->isValid()), QScriptValue::ReadOnly);
+ v.setProperty(QLatin1String("connection"), engine->newQObject(new QScriptDBusConnection(iface->connection(), engine)), QScriptValue::ReadOnly);
+
+ return v;
+}
+
+QDBusConnectionConstructor::QDBusConnectionConstructor(QScriptEngine *engine, QScriptValue extensionObject)
+ : QObject(engine)
+{
+ QScriptValue ctor = engine->newQObject(this);
+
+ QScriptValue proto = engine->newQMetaObject(&QDBusConnection::staticMetaObject);
+ proto.setPrototype(engine->globalObject().property(QLatin1String("Function")).property(QLatin1String("prototype")));
+ ctor.setProperty(QLatin1String("prototype"), proto);
+
+ extensionObject.setProperty(QLatin1String("QDBusConnection"), ctor);
+}
+
+QScriptValue QDBusConnectionConstructor::sessionBus() const
+{
+ return engine()->newQObject(new QScriptDBusConnection(QDBusConnection::sessionBus(), engine()));
+}
+
+QScriptValue QDBusConnectionConstructor::systemBus() const
+{
+ return engine()->newQObject(new QScriptDBusConnection(QDBusConnection::systemBus(), engine()));
+}
+
+QObject *QDBusConnectionConstructor::qscript_call(const QString &name)
+{
+ return new QScriptDBusConnection(QDBusConnection(name), this);
+}
+
+void QDBusConnectionConstructor::disconnectFromBus(const QString &name)
+{
+ QDBusConnection::disconnectFromBus(name);
+}
+
+QDBusConnection QDBusConnectionConstructor::connectToBus(const QString &address, const QString &name)
+{
+ return QDBusConnection::connectToBus(address, name);
+}
+
+QDBusConnection QDBusConnectionConstructor::connectToBus(QDBusConnection::BusType type, const QString &name)
+{
+ return QDBusConnection::connectToBus(type, name);
+}
+
+QScriptDBusConnection::QScriptDBusConnection(const QDBusConnection &conn, QObject *parent)
+ : QObject(parent), connection(conn)
+{
+}
+
+QScriptValue QScriptDBusConnection::dbusInterface() const
+{
+ QDBusConnectionInterface *iface = connection.interface();
+ if (!iface)
+ return engine()->nullValue();
+ return setupDBusInterface(engine(), iface);
+}
+
+QScriptDBusInterfaceConstructor::QScriptDBusInterfaceConstructor(QScriptEngine *engine, QScriptValue extensionObject)
+{
+ QScriptValue ctorValue = engine->newQObject(this);
+ QScriptValue klass = engine->newQMetaObject(metaObject(), ctorValue);
+ extensionObject.setProperty(QLatin1String("QDBusInterface"), klass);
+}
+
+QScriptValue QScriptDBusInterfaceConstructor::qscript_call(const QString &service, const QString &path, const QString &interface,
+ const QScriptValue &conn)
+{
+ QDBusConnection connection = QDBusConnection::sessionBus();
+
+ QScriptDBusConnection *connWrapper = qobject_cast<QScriptDBusConnection *>(conn.toQObject());
+ if (connWrapper)
+ connection = connWrapper->dbusConnection();
+
+ return setupDBusInterface(engine(), new QDBusInterface(service, path, interface, connection, engine()));
+}
+
+QScriptDBusMessageConstructor::QScriptDBusMessageConstructor(QScriptEngine *engine, QScriptValue extensionObject)
+ : QObject(engine)
+{
+ proto = engine->newQMetaObject(metaObject(), engine->newQObject(this));
+
+ proto.setProperty(QLatin1String("createReply"), engine->newFunction(createReply));
+ proto.setProperty(QLatin1String("createErrorReply"), engine->newFunction(createErrorReply));
+
+ extensionObject.setProperty(QLatin1String("QDBusMessage"), proto);
+ engine->setDefaultPrototype(qMetaTypeId<QDBusMessage>(), proto);
+}
+
+QDBusMessage QScriptDBusMessageConstructor::createSignal(const QString &path, const QString &interface, const QString &name)
+{
+ return QDBusMessage::createSignal(path, interface, name);
+}
+
+QDBusMessage QScriptDBusMessageConstructor::createMethodCall(const QString &destination, const QString &path, const QString &interface, const QString &method)
+{
+ return QDBusMessage::createMethodCall(destination, path, interface, method);
+}
+
+QDBusMessage QScriptDBusMessageConstructor::createError(const QString &name, const QString &msg)
+{
+ return QDBusMessage::createError(name, msg);
+}
+
+static QScriptValue messageToScriptValue(QScriptEngine *engine, const QDBusMessage &message)
+{
+ QScriptValue v = engine->newVariant(QVariant::fromValue(message));
+ v.setProperty(QLatin1String("service"), QScriptValue(engine, message.service()), QScriptValue::ReadOnly);
+ v.setProperty(QLatin1String("path"), QScriptValue(engine, message.path()), QScriptValue::ReadOnly);
+ v.setProperty(QLatin1String("interface"), QScriptValue(engine, message.interface()), QScriptValue::ReadOnly);
+ v.setProperty(QLatin1String("member"), QScriptValue(engine, message.member()), QScriptValue::ReadOnly);
+ v.setProperty(QLatin1String("type"), QScriptValue(engine, message.type()), QScriptValue::ReadOnly);
+ v.setProperty(QLatin1String("signature"), QScriptValue(engine, message.signature()), QScriptValue::ReadOnly);
+ v.setProperty(QLatin1String("isReplyRequired"), QScriptValue(engine, message.isReplyRequired()), QScriptValue::ReadOnly);
+
+ v.setProperty(QLatin1String("delayedReply"), QScriptValue(engine, message.isDelayedReply()));
+ QScriptValue argValue = engine->newArray();
+ const QList<QVariant> args = message.arguments();
+ for (int i = 0; i < args.count(); ++i)
+ argValue.setProperty(QScriptValue(engine, i).toString(),
+ engine->newVariant(args.at(i)));
+
+ v.setProperty(QLatin1String("arguments"), argValue);
+
+ return v;
+}
+
+static void scriptValueToMessage(const QScriptValue &value, QDBusMessage &message)
+{
+ QVariant v = value.toVariant();
+ message = qvariant_cast<QDBusMessage>(v);
+ message.setDelayedReply(value.property(QLatin1String("delayedReply")).toBoolean());
+
+ QList<QVariant> args;
+ quint32 len = value.property(QLatin1String("length")).toUInt32();
+ for (quint32 i = 0; i < len; ++i) {
+ QScriptValue item = value.property(i);
+ args.append(item.toVariant());
+ }
+ message.setArguments(args);
+}
+
+QScriptValue QScriptDBusMessageConstructor::createReply(QScriptContext *context, QScriptEngine *engine)
+{
+ QDBusMessage msg;
+ scriptValueToMessage(context->thisObject(), msg);
+
+ QList<QVariant> args;
+ for (int i = 0; i < context->argumentCount(); ++i) {
+ QScriptValue value = context->argument(i);
+ args.append(value.toVariant());
+ }
+
+ return messageToScriptValue(engine, msg.createReply(args));
+}
+
+QScriptValue QScriptDBusMessageConstructor::createErrorReply(QScriptContext *context, QScriptEngine *engine)
+{
+ if (context->argumentCount() != 2)
+ return engine->nullValue();
+
+ QDBusMessage msg;
+ scriptValueToMessage(context->thisObject(), msg);
+
+ QString name = context->argument(0).toString();
+ QString errMsg = context->argument(1).toString();
+ return messageToScriptValue(engine, msg.createErrorReply(name, errMsg));
+}
+
+template <typename T>
+QScriptValue qDBusReplyToScriptValue(QScriptEngine *eng, const QDBusReply<T> &reply)
+{
+ return QScriptValue(eng, reply.value());
+}
+
+template <>
+QScriptValue qDBusReplyToScriptValue(QScriptEngine *eng, const QDBusReply<QStringList> &reply)
+{
+ QScriptValue v = eng->newArray();
+ const QStringList &lst = reply.value();
+ for (int i = 0; i < lst.count(); ++i)
+ v.setProperty(i, QScriptValue(eng, lst.at(i)));
+ return v;
+}
+
+template <typename T>
+void qDBusReplyFromScriptValue(const QScriptValue &, QDBusReply<T> &)
+{
+ // never called
+}
+
+QScriptValue qDBusErrorToScriptValue(QScriptEngine *engine, const QDBusError &error)
+{
+ QScriptValue v = engine->newObject();
+ v.setProperty(QLatin1String("type"), QScriptValue(engine, error.type()), QScriptValue::ReadOnly);
+ v.setProperty(QLatin1String("name"), QScriptValue(engine, error.name()), QScriptValue::ReadOnly);
+ v.setProperty(QLatin1String("message"), QScriptValue(engine, error.message()), QScriptValue::ReadOnly);
+ v.setProperty(QLatin1String("isValid"), QScriptValue(engine, error.isValid()), QScriptValue::ReadOnly);
+ return v;
+}
+
+void scriptValueToQDBusError(const QScriptValue &value, QDBusError &error)
+{
+ Q_UNUSED(value)
+ Q_UNUSED(error)
+ // never called
+}
+
+Q_DECLARE_METATYPE(QDBusReply<QString>)
+Q_DECLARE_METATYPE(QDBusReply<QStringList>)
+Q_DECLARE_METATYPE(QDBusReply<uint>)
+Q_DECLARE_METATYPE(QDBusReply<bool>)
+Q_DECLARE_METATYPE(QDBusReply<QDBusConnectionInterface::RegisterServiceReply>)
+Q_DECLARE_METATYPE(QDBusError)
+
+class QtDBusScriptPlugin : public QScriptExtensionPlugin
+{
+public:
+ QStringList keys() const;
+ void initialize(const QString &key, QScriptEngine *engine);
+};
+
+QStringList QtDBusScriptPlugin::keys() const
+{
+ return QStringList(QLatin1String("qt.dbus"));
+}
+
+void QtDBusScriptPlugin::initialize(const QString &key, QScriptEngine *engine)
+{
+ if (key != QLatin1String("qt.dbus")) {
+ Q_ASSERT_X(false, "initialize", qPrintable(key));
+ return;
+ }
+
+ QScriptValue extensionObject = engine->globalObject();
+
+ qScriptRegisterMetaType<QDBusReply<QString> >(engine, qDBusReplyToScriptValue, qDBusReplyFromScriptValue);
+ qScriptRegisterMetaType<QDBusReply<QStringList> >(engine, qDBusReplyToScriptValue, qDBusReplyFromScriptValue);
+ qScriptRegisterMetaType<QDBusReply<uint> >(engine, qDBusReplyToScriptValue, qDBusReplyFromScriptValue);
+ qScriptRegisterMetaType<QDBusReply<bool> >(engine, qDBusReplyToScriptValue, qDBusReplyFromScriptValue);
+ qScriptRegisterMetaType<QDBusReply<QDBusConnectionInterface::RegisterServiceReply> >(engine, qDBusReplyToScriptValue, qDBusReplyFromScriptValue);
+ qScriptRegisterMetaType<QDBusMessage>(engine, messageToScriptValue, scriptValueToMessage);
+ qScriptRegisterMetaType<QDBusError>(engine, qDBusErrorToScriptValue, scriptValueToQDBusError);
+
+ QScriptValue connIfaceProto = engine->newQMetaObject(&QDBusConnectionInterface::staticMetaObject, engine->nullValue());
+ extensionObject.setProperty(QLatin1String("QDBusConnectionInterface"), connIfaceProto);
+
+ QScriptValue qdbus = engine->newObject();
+ qdbus.setProperty(QLatin1String("NoBlock"), QScriptValue(engine, QDBus::NoBlock));
+ qdbus.setProperty(QLatin1String("Block"), QScriptValue(engine, QDBus::Block));
+ qdbus.setProperty(QLatin1String("BlockWithGui"), QScriptValue(engine, QDBus::BlockWithGui));
+ qdbus.setProperty(QLatin1String("AutoDetect"), QScriptValue(engine, QDBus::AutoDetect));
+ engine->globalObject().setProperty(QLatin1String("QDBus"), qdbus);
+
+ (void)new QDBusConnectionConstructor(engine, extensionObject);
+ (void)new QScriptDBusInterfaceConstructor(engine, extensionObject);
+ (void)new QScriptDBusMessageConstructor(engine, extensionObject);
+}
+
+
+Q_EXPORT_STATIC_PLUGIN(QtDBusScriptPlugin)
+Q_EXPORT_PLUGIN2(qtscriptdbus, QtDBusScriptPlugin)
diff --git a/src/plugins/script/qtdbus/main.h b/src/plugins/script/qtdbus/main.h
new file mode 100644
index 0000000..1e14040
--- /dev/null
+++ b/src/plugins/script/qtdbus/main.h
@@ -0,0 +1,176 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** 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.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDBUSBINDING_H
+#define QDBUSBINDING_H
+
+#include <QtDBus/QtDBus>
+#include <QtScript/qscriptable.h>
+#include <QtScript/qscriptengine.h>
+
+class QDBusConnectionConstructor : public QObject,
+ public QScriptable
+{
+ Q_OBJECT
+ Q_PROPERTY(QScriptValue sessionBus READ sessionBus)
+ Q_PROPERTY(QScriptValue systemBus READ systemBus)
+
+public:
+ QDBusConnectionConstructor(QScriptEngine *engine, QScriptValue extensionObject);
+
+ QScriptValue sessionBus() const;
+ QScriptValue systemBus() const;
+
+public Q_SLOTS:
+ QObject *qscript_call(const QString &name);
+
+ void disconnectFromBus(const QString &name);
+ QDBusConnection connectToBus(const QString &address, const QString &name);
+ QDBusConnection connectToBus(QDBusConnection::BusType type, const QString &name);
+};
+
+class QScriptDBusConnection : public QObject,
+ public QScriptable
+{
+ Q_OBJECT
+ Q_PROPERTY(QString baseService READ baseService)
+ Q_PROPERTY(bool isConnected READ isConnected)
+ Q_PROPERTY(QScriptValue dbusInterface READ dbusInterface)
+public:
+ QScriptDBusConnection(const QDBusConnection &conn, QObject *parent);
+
+ inline QString baseService() const { return connection.baseService(); }
+ inline bool isConnected() const { return connection.isConnected(); }
+ QScriptValue dbusInterface() const;
+
+ inline QDBusConnection dbusConnection() const { return connection; }
+
+public Q_SLOTS:
+ inline bool send(const QDBusMessage &message) const
+ { return connection.send(message); }
+ inline QDBusMessage call(const QDBusMessage &message, int callMode = QDBus::Block, int timeout = -1) const
+ { return connection.call(message, QDBus::CallMode(callMode), timeout); }
+
+ inline bool registerService(const QString &serviceName)
+ { return connection.registerService(serviceName); }
+ inline bool unregisterService(const QString &serviceName)
+ { return connection.unregisterService(serviceName); }
+
+ inline QDBusError lastError() const
+ { return connection.lastError(); }
+
+ inline void unregisterObject(const QString &path, QDBusConnection::UnregisterMode mode = QDBusConnection::UnregisterNode)
+ { return connection.unregisterObject(path, mode); }
+ inline QObject *objectRegisteredAt(const QString &path) const
+ { return connection.objectRegisteredAt(path); }
+
+#if 0
+ bool callWithCallback(const QDBusMessage &message, QObject *receiver,
+ const char *slot, int timeout = -1) const;
+
+ bool connect(const QString &service, const QString &path, const QString &interface,
+ const QString &name, QObject *receiver, const char *slot);
+ bool disconnect(const QString &service, const QString &path, const QString &interface,
+ const QString &name, QObject *receiver, const char *slot);
+
+ bool connect(const QString &service, const QString &path, const QString &interface,
+ const QString &name, const QString& signature,
+ QObject *receiver, const char *slot);
+ bool disconnect(const QString &service, const QString &path, const QString &interface,
+ const QString &name, const QString& signature,
+ QObject *receiver, const char *slot);
+
+ bool registerObject(const QString &path, QObject *object,
+ RegisterOptions options = ExportAdaptors);
+
+#endif
+
+private:
+ QDBusConnection connection;
+};
+
+Q_DECLARE_METATYPE(QScriptDBusConnection*)
+
+class QScriptDBusInterfaceConstructor : public QObject,
+ public QScriptable
+{
+ Q_OBJECT
+public:
+ QScriptDBusInterfaceConstructor(QScriptEngine *engine, QScriptValue extensionObject);
+
+public Q_SLOTS:
+ QScriptValue qscript_call(const QString &service, const QString &path, const QString &interface = QString(),
+ const QScriptValue &conn = QScriptValue());
+};
+
+Q_DECLARE_METATYPE(QDBusMessage)
+
+class QScriptDBusMessageConstructor : public QObject, public QScriptable
+{
+ Q_OBJECT
+ Q_ENUMS(MessageType)
+public:
+ enum MessageType {
+ InvalidMessage = QDBusMessage::InvalidMessage,
+ MethodCallMessage = QDBusMessage::MethodCallMessage,
+ ReplyMessage = QDBusMessage::ReplyMessage,
+ ErrorMessage = QDBusMessage::ErrorMessage,
+ SignalMessage = QDBusMessage::SignalMessage
+ };
+
+ QScriptDBusMessageConstructor(QScriptEngine *engine, QScriptValue extensionObject);
+
+ QScriptValue protoType() const { return proto; }
+
+public Q_SLOTS:
+ QDBusMessage createSignal(const QString &path, const QString &interface, const QString &name);
+ QDBusMessage createMethodCall(const QString &destination, const QString &path, const QString &interface, const QString &method);
+ QDBusMessage createError(const QString &name, const QString &msg);
+
+public:
+ static QScriptValue createReply(QScriptContext *context, QScriptEngine *engine);
+ static QScriptValue createErrorReply(QScriptContext *context, QScriptEngine *engine);
+
+private:
+ QScriptValue proto;
+};
+
+#endif // QDBUSBINDING_H
diff --git a/src/plugins/script/qtdbus/qtdbus.pro b/src/plugins/script/qtdbus/qtdbus.pro
new file mode 100644
index 0000000..18663bb
--- /dev/null
+++ b/src/plugins/script/qtdbus/qtdbus.pro
@@ -0,0 +1,11 @@
+TARGET = qtscriptdbus
+include(../../qpluginbase.pri)
+QT = core gui script
+CONFIG += qdbus
+
+SOURCES += main.cpp
+HEADERS += main.h
+
+QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/script
+target.path += $$[QT_INSTALL_PLUGINS]/script
+INSTALLS += target
diff --git a/src/plugins/script/script.pro b/src/plugins/script/script.pro
new file mode 100644
index 0000000..dbcecea
--- /dev/null
+++ b/src/plugins/script/script.pro
@@ -0,0 +1,2 @@
+TEMPLATE = subdirs
+contains(QT_CONFIG, dbus):SUBDIRS += qtdbus