summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEvan Nguyen <evan.nguyen@nokia.com>2010-07-26 04:18:37 (GMT)
committerEvan Nguyen <evan.nguyen@nokia.com>2010-07-26 04:32:05 (GMT)
commit3e8597ff6029d33d629191370d9fed7d37d3962a (patch)
treed386b22037d6b1e4e42c89cb34164c39e4af904a /src
parenta847edefd9e2efd70e63935965624354406f932d (diff)
downloadQt-3e8597ff6029d33d629191370d9fed7d37d3962a.zip
Qt-3e8597ff6029d33d629191370d9fed7d37d3962a.tar.gz
Qt-3e8597ff6029d33d629191370d9fed7d37d3962a.tar.bz2
Q_INVOKABLES added to Qt-DBus
Task-number: QTBUG-12397
Diffstat (limited to 'src')
-rw-r--r--src/dbus/qdbusconnection.h3
-rw-r--r--src/dbus/qdbusintegrator.cpp22
-rw-r--r--src/dbus/qdbusinterface.cpp2
-rw-r--r--src/dbus/qdbusxmlgenerator.cpp8
4 files changed, 23 insertions, 12 deletions
diff --git a/src/dbus/qdbusconnection.h b/src/dbus/qdbusconnection.h
index 0f365ec..eedda16 100644
--- a/src/dbus/qdbusconnection.h
+++ b/src/dbus/qdbusconnection.h
@@ -85,16 +85,19 @@ public:
ExportScriptableSlots = 0x10,
ExportScriptableSignals = 0x20,
ExportScriptableProperties = 0x40,
+ ExportScriptableInvokables = 0x80,
ExportScriptableContents = 0xf0,
ExportNonScriptableSlots = 0x100,
ExportNonScriptableSignals = 0x200,
ExportNonScriptableProperties = 0x400,
+ ExportNonScriptableInvokables = 0x800,
ExportNonScriptableContents = 0xf00,
ExportAllSlots = ExportScriptableSlots|ExportNonScriptableSlots,
ExportAllSignals = ExportScriptableSignals|ExportNonScriptableSignals,
ExportAllProperties = ExportScriptableProperties|ExportNonScriptableProperties,
+ ExportAllInvokables = ExportScriptableInvokables|ExportNonScriptableInvokables,
ExportAllContents = ExportScriptableContents|ExportNonScriptableContents,
#ifndef Q_QDOC
diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp
index 1f44bd2..e1b90b8 100644
--- a/src/dbus/qdbusintegrator.cpp
+++ b/src/dbus/qdbusintegrator.cpp
@@ -508,7 +508,7 @@ static bool shouldWatchService(const QString &service)
return !service.isEmpty() && !service.startsWith(QLatin1Char(':'));
}
-extern Q_DBUS_EXPORT void qDBusAddSpyHook(QDBusSpyHook);
+extern QDBUS_EXPORT void qDBusAddSpyHook(QDBusSpyHook);
void qDBusAddSpyHook(QDBusSpyHook hook)
{
qDBusSpyHookList()->append(hook);
@@ -618,7 +618,7 @@ static int findSlot(const QMetaObject *mo, const QByteArray &name, int flags,
continue;
// check type:
- if (mm.methodType() != QMetaMethod::Slot)
+ if (mm.methodType() != QMetaMethod::Slot && mm.methodType() != QMetaMethod::Method)
continue;
// check name:
@@ -682,10 +682,17 @@ static int findSlot(const QMetaObject *mo, const QByteArray &name, int flags,
if (isAsync && metaTypes.count() > i + 1)
continue;
- if (isScriptable && (flags & QDBusConnection::ExportScriptableSlots) == 0)
- continue; // not exported
- if (!isScriptable && (flags & QDBusConnection::ExportNonScriptableSlots) == 0)
- continue; // not exported
+ if (mm.methodType() == QMetaMethod::Slot) {
+ if (isScriptable && (flags & QDBusConnection::ExportScriptableSlots) == 0)
+ continue; // scriptable slots not exported
+ if (!isScriptable && (flags & QDBusConnection::ExportNonScriptableSlots) == 0)
+ continue; // non-scriptable slots not exported
+ } else {
+ if (isScriptable && (flags & QDBusConnection::ExportScriptableInvokables) == 0)
+ continue; // scriptable invokables not exported
+ if (!isScriptable && (flags & QDBusConnection::ExportNonScriptableInvokables) == 0)
+ continue; // non-scriptable invokables not exported
+ }
// if we got here, this slot matched
return idx;
@@ -1379,7 +1386,8 @@ void QDBusConnectionPrivate::activateObject(ObjectTreeNode &node, const QDBusMes
return; // internal filters have already run or an error has been sent
// try the object itself:
- if (node.flags & (QDBusConnection::ExportScriptableSlots|QDBusConnection::ExportNonScriptableSlots)) {
+ if (node.flags & (QDBusConnection::ExportScriptableSlots|QDBusConnection::ExportNonScriptableSlots) ||
+ node.flags & (QDBusConnection::ExportScriptableInvokables|QDBusConnection::ExportNonScriptableInvokables)) {
bool interfaceFound = true;
if (!msg.interface().isEmpty())
interfaceFound = qDBusInterfaceInObject(node.obj, msg.interface());
diff --git a/src/dbus/qdbusinterface.cpp b/src/dbus/qdbusinterface.cpp
index b989cab..248bf65 100644
--- a/src/dbus/qdbusinterface.cpp
+++ b/src/dbus/qdbusinterface.cpp
@@ -277,7 +277,7 @@ int QDBusInterfacePrivate::metacall(QMetaObject::Call c, int id, void **argv)
// signal relay from D-Bus world to Qt world
QMetaObject::activate(q, metaObject, id, argv);
- } else if (mm.methodType() == QMetaMethod::Slot) {
+ } else if (mm.methodType() == QMetaMethod::Slot || mm.methodType() == QMetaMethod::Method) {
// method call relay from Qt world to D-Bus world
// get D-Bus equivalent signature
QString methodName = QLatin1String(metaObject->dbusNameForMethod(id));
diff --git a/src/dbus/qdbusxmlgenerator.cpp b/src/dbus/qdbusxmlgenerator.cpp
index 7cc5acb..1222ac7 100644
--- a/src/dbus/qdbusxmlgenerator.cpp
+++ b/src/dbus/qdbusxmlgenerator.cpp
@@ -133,7 +133,7 @@ static QString generateInterfaceXml(const QMetaObject *mo, int flags, int method
if (mm.methodType() == QMetaMethod::Signal)
// adding a signal
isSignal = true;
- else if (mm.methodType() == QMetaMethod::Slot && mm.access() == QMetaMethod::Public)
+ else if (mm.access() == QMetaMethod::Public && (mm.methodType() == QMetaMethod::Slot || mm.methodType() == QMetaMethod::Method))
isSignal = false;
else
continue; // neither signal nor public slot
@@ -141,9 +141,9 @@ static QString generateInterfaceXml(const QMetaObject *mo, int flags, int method
if (isSignal && !(flags & (QDBusConnection::ExportScriptableSignals |
QDBusConnection::ExportNonScriptableSignals)))
continue; // we're not exporting any signals
- if (!isSignal && !(flags & (QDBusConnection::ExportScriptableSlots |
- QDBusConnection::ExportNonScriptableSlots)))
- continue; // we're not exporting any slots
+ if (!isSignal && (!(flags & (QDBusConnection::ExportScriptableSlots | QDBusConnection::ExportNonScriptableSlots)) &&
+ !(flags & (QDBusConnection::ExportScriptableInvokables | QDBusConnection::ExportNonScriptableInvokables))))
+ continue; // we're not exporting any slots or invokables
QString xml = QString::fromLatin1(" <%1 name=\"%2\">\n")
.arg(isSignal ? QLatin1String("signal") : QLatin1String("method"))