summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--qt/dbus/qdbus.h1
-rw-r--r--qt/dbus/qdbusabstractadaptor.h1
-rw-r--r--qt/dbus/qdbusabstractadaptor_p.h1
-rw-r--r--qt/dbus/qdbusabstractinterface.h1
-rw-r--r--qt/dbus/qdbusabstractinterface_p.h1
-rw-r--r--qt/dbus/qdbusbus.h1
-rw-r--r--qt/dbus/qdbusconnection.h1
-rw-r--r--qt/dbus/qdbusconnection_p.h1
-rw-r--r--qt/dbus/qdbuserror.h1
-rw-r--r--qt/dbus/qdbusinterface.h1
-rw-r--r--qt/dbus/qdbusinterface_p.h1
-rw-r--r--qt/dbus/qdbusintrospection_p.h1
-rw-r--r--qt/dbus/qdbusmacros.h1
-rw-r--r--qt/dbus/qdbusmarshall_p.h1
-rw-r--r--qt/dbus/qdbusmessage.h1
-rw-r--r--qt/dbus/qdbusmessage_p.h1
-rw-r--r--qt/dbus/qdbusmetaobject_p.h1
-rw-r--r--qt/dbus/qdbusreply.h1
-rw-r--r--qt/dbus/qdbusserver.h1
-rw-r--r--qt/dbus/qdbustype_p.h1
-rw-r--r--qt/dbus/qdbustypehelper_p.h1
-rw-r--r--qt/dbus/qdbusutil.h1
-rw-r--r--qt/dbus/qdbusxmlparser_p.h1
-rw-r--r--qt/examples/Makefile.am3
-rw-r--r--qt/examples/complexpong.cpp1
-rw-r--r--qt/examples/pong.cpp1
-rw-r--r--qt/src/qdbusabstractadaptor.cpp21
-rw-r--r--qt/src/qdbusabstractinterface.cpp9
-rw-r--r--qt/src/qdbusbus.cpp46
-rw-r--r--qt/src/qdbusbus.h34
-rw-r--r--qt/src/qdbusconnection.cpp43
-rw-r--r--qt/src/qdbusconnection.h10
-rw-r--r--qt/src/qdbuserror.cpp16
-rw-r--r--qt/src/qdbuserror.h2
-rw-r--r--qt/src/qdbusintegrator.cpp56
-rw-r--r--qt/src/qdbusinterface.cpp12
-rw-r--r--qt/src/qdbusinternalfilters.cpp2
-rw-r--r--qt/src/qdbusmessage.cpp18
-rw-r--r--qt/src/qdbusmessage.h2
-rw-r--r--qt/src/qdbusmetaobject.cpp62
-rw-r--r--qt/src/qdbusreply.h12
-rw-r--r--qt/src/qdbusserver.cpp4
-rw-r--r--qt/src/qdbusutil.cpp38
-rw-r--r--qt/src/qdbusxmlgenerator.cpp16
-rw-r--r--qt/src/qdbusxmlparser.cpp85
-rw-r--r--qt/tools/Makefile.am5
-rw-r--r--qt/tools/dbus.cpp (renamed from qt/examples/dbus.cpp)87
-rw-r--r--qt/tools/dbuscpp2xml.cpp23
-rw-r--r--qt/tools/dbusidl2cpp.cpp118
49 files changed, 464 insertions, 285 deletions
diff --git a/qt/dbus/qdbus.h b/qt/dbus/qdbus.h
new file mode 100644
index 0000000..9fbc27a
--- /dev/null
+++ b/qt/dbus/qdbus.h
@@ -0,0 +1 @@
+#include "../src/qdbus.h"
diff --git a/qt/dbus/qdbusabstractadaptor.h b/qt/dbus/qdbusabstractadaptor.h
new file mode 100644
index 0000000..94cc3a2
--- /dev/null
+++ b/qt/dbus/qdbusabstractadaptor.h
@@ -0,0 +1 @@
+#include "../src/qdbusabstractadaptor.h"
diff --git a/qt/dbus/qdbusabstractadaptor_p.h b/qt/dbus/qdbusabstractadaptor_p.h
new file mode 100644
index 0000000..d55bef3
--- /dev/null
+++ b/qt/dbus/qdbusabstractadaptor_p.h
@@ -0,0 +1 @@
+#include "../src/qdbusabstractadaptor_p.h"
diff --git a/qt/dbus/qdbusabstractinterface.h b/qt/dbus/qdbusabstractinterface.h
new file mode 100644
index 0000000..e7ab181
--- /dev/null
+++ b/qt/dbus/qdbusabstractinterface.h
@@ -0,0 +1 @@
+#include "../src/qdbusabstractinterface.h"
diff --git a/qt/dbus/qdbusabstractinterface_p.h b/qt/dbus/qdbusabstractinterface_p.h
new file mode 100644
index 0000000..5f6e7d5
--- /dev/null
+++ b/qt/dbus/qdbusabstractinterface_p.h
@@ -0,0 +1 @@
+#include "../src/qdbusabstractinterface_p.h"
diff --git a/qt/dbus/qdbusbus.h b/qt/dbus/qdbusbus.h
new file mode 100644
index 0000000..eb849ac
--- /dev/null
+++ b/qt/dbus/qdbusbus.h
@@ -0,0 +1 @@
+#include "../src/qdbusbus.h"
diff --git a/qt/dbus/qdbusconnection.h b/qt/dbus/qdbusconnection.h
new file mode 100644
index 0000000..99ac323
--- /dev/null
+++ b/qt/dbus/qdbusconnection.h
@@ -0,0 +1 @@
+#include "../src/qdbusconnection.h"
diff --git a/qt/dbus/qdbusconnection_p.h b/qt/dbus/qdbusconnection_p.h
new file mode 100644
index 0000000..aaabb23
--- /dev/null
+++ b/qt/dbus/qdbusconnection_p.h
@@ -0,0 +1 @@
+#include "../src/qdbusconnection_p.h"
diff --git a/qt/dbus/qdbuserror.h b/qt/dbus/qdbuserror.h
new file mode 100644
index 0000000..680395a
--- /dev/null
+++ b/qt/dbus/qdbuserror.h
@@ -0,0 +1 @@
+#include "../src/qdbuserror.h"
diff --git a/qt/dbus/qdbusinterface.h b/qt/dbus/qdbusinterface.h
new file mode 100644
index 0000000..c7024c8
--- /dev/null
+++ b/qt/dbus/qdbusinterface.h
@@ -0,0 +1 @@
+#include "../src/qdbusinterface.h"
diff --git a/qt/dbus/qdbusinterface_p.h b/qt/dbus/qdbusinterface_p.h
new file mode 100644
index 0000000..9538448
--- /dev/null
+++ b/qt/dbus/qdbusinterface_p.h
@@ -0,0 +1 @@
+#include "../src/qdbusinterface_p.h"
diff --git a/qt/dbus/qdbusintrospection_p.h b/qt/dbus/qdbusintrospection_p.h
new file mode 100644
index 0000000..210ed1e
--- /dev/null
+++ b/qt/dbus/qdbusintrospection_p.h
@@ -0,0 +1 @@
+#include "../src/qdbusintrospection_p.h"
diff --git a/qt/dbus/qdbusmacros.h b/qt/dbus/qdbusmacros.h
new file mode 100644
index 0000000..dcd725e
--- /dev/null
+++ b/qt/dbus/qdbusmacros.h
@@ -0,0 +1 @@
+#include "../src/qdbusmacros.h"
diff --git a/qt/dbus/qdbusmarshall_p.h b/qt/dbus/qdbusmarshall_p.h
new file mode 100644
index 0000000..1e91185
--- /dev/null
+++ b/qt/dbus/qdbusmarshall_p.h
@@ -0,0 +1 @@
+#include "../src/qdbusmarshall_p.h"
diff --git a/qt/dbus/qdbusmessage.h b/qt/dbus/qdbusmessage.h
new file mode 100644
index 0000000..e993c1f
--- /dev/null
+++ b/qt/dbus/qdbusmessage.h
@@ -0,0 +1 @@
+#include "../src/qdbusmessage.h"
diff --git a/qt/dbus/qdbusmessage_p.h b/qt/dbus/qdbusmessage_p.h
new file mode 100644
index 0000000..2b94201
--- /dev/null
+++ b/qt/dbus/qdbusmessage_p.h
@@ -0,0 +1 @@
+#include "../src/qdbusmessage_p.h"
diff --git a/qt/dbus/qdbusmetaobject_p.h b/qt/dbus/qdbusmetaobject_p.h
new file mode 100644
index 0000000..37a6e30
--- /dev/null
+++ b/qt/dbus/qdbusmetaobject_p.h
@@ -0,0 +1 @@
+#include "../src/qdbusmetaobject_p.h"
diff --git a/qt/dbus/qdbusreply.h b/qt/dbus/qdbusreply.h
new file mode 100644
index 0000000..8c87a71
--- /dev/null
+++ b/qt/dbus/qdbusreply.h
@@ -0,0 +1 @@
+#include "../src/qdbusreply.h"
diff --git a/qt/dbus/qdbusserver.h b/qt/dbus/qdbusserver.h
new file mode 100644
index 0000000..a8ca4ed
--- /dev/null
+++ b/qt/dbus/qdbusserver.h
@@ -0,0 +1 @@
+#include "../src/qdbusserver.h"
diff --git a/qt/dbus/qdbustype_p.h b/qt/dbus/qdbustype_p.h
new file mode 100644
index 0000000..1f94601
--- /dev/null
+++ b/qt/dbus/qdbustype_p.h
@@ -0,0 +1 @@
+#include "../src/qdbustype_p.h"
diff --git a/qt/dbus/qdbustypehelper_p.h b/qt/dbus/qdbustypehelper_p.h
new file mode 100644
index 0000000..1e3c342
--- /dev/null
+++ b/qt/dbus/qdbustypehelper_p.h
@@ -0,0 +1 @@
+#include "../src/qdbustypehelper_p.h"
diff --git a/qt/dbus/qdbusutil.h b/qt/dbus/qdbusutil.h
new file mode 100644
index 0000000..1b9dbd0
--- /dev/null
+++ b/qt/dbus/qdbusutil.h
@@ -0,0 +1 @@
+#include "../src/qdbusutil.h"
diff --git a/qt/dbus/qdbusxmlparser_p.h b/qt/dbus/qdbusxmlparser_p.h
new file mode 100644
index 0000000..f3e1100
--- /dev/null
+++ b/qt/dbus/qdbusxmlparser_p.h
@@ -0,0 +1 @@
+#include "../src/qdbusxmlparser_p.h"
diff --git a/qt/examples/Makefile.am b/qt/examples/Makefile.am
index 5d1e054..ab56944 100644
--- a/qt/examples/Makefile.am
+++ b/qt/examples/Makefile.am
@@ -16,9 +16,8 @@ CHAT=chat
endif
-noinst_PROGRAMS = hello listnames dbus ping pong complexping complexpong $(CHAT)
+noinst_PROGRAMS = hello listnames ping pong complexping complexpong $(CHAT)
hello_SOURCES = hello.cpp
-dbus_SOURCES = dbus.cpp
listnames_SOURCES = listnames.cpp
ping_SOURCES = ping.cpp
diff --git a/qt/examples/complexpong.cpp b/qt/examples/complexpong.cpp
index 1d9c975..ff76740 100644
--- a/qt/examples/complexpong.cpp
+++ b/qt/examples/complexpong.cpp
@@ -20,6 +20,7 @@
*/
#include <stdio.h>
+#include <stdlib.h>
#include <dbus/qdbus.h>
#include <QtCore/QCoreApplication>
diff --git a/qt/examples/pong.cpp b/qt/examples/pong.cpp
index 3917bb5..b85f1f0 100644
--- a/qt/examples/pong.cpp
+++ b/qt/examples/pong.cpp
@@ -20,6 +20,7 @@
*/
#include <stdio.h>
+#include <stdlib.h>
#include <dbus/qdbus.h>
#include <QtCore/QCoreApplication>
diff --git a/qt/src/qdbusabstractadaptor.cpp b/qt/src/qdbusabstractadaptor.cpp
index b7c4188..4592b29 100644
--- a/qt/src/qdbusabstractadaptor.cpp
+++ b/qt/src/qdbusabstractadaptor.cpp
@@ -88,8 +88,7 @@ void QDBusAbstractAdaptorPrivate::saveIntrospectionXml(QDBusAbstractAdaptor *ada
}
/*!
- \page usingannotations.html
- \title Using annotations in adaptors
+ \page usingannotations.html Using annotations in adaptors
It is currently not possible to specify arbitrary annotations in adaptors.
*/
@@ -121,12 +120,12 @@ void QDBusAbstractAdaptorPrivate::saveIntrospectionXml(QDBusAbstractAdaptor *ada
*/
/*!
- Constructs a QDBusAbstractAdaptor with \a parent as the object we refer to.
+ Constructs a QDBusAbstractAdaptor with \a obj as the parent object.
*/
-QDBusAbstractAdaptor::QDBusAbstractAdaptor(QObject* parent)
- : QObject(parent), d(new QDBusAbstractAdaptorPrivate)
+QDBusAbstractAdaptor::QDBusAbstractAdaptor(QObject* obj)
+ : QObject(obj), d(new QDBusAbstractAdaptorPrivate)
{
- QDBusAdaptorConnector *connector = qDBusCreateAdaptorConnector(parent);
+ QDBusAdaptorConnector *connector = qDBusCreateAdaptorConnector(obj);
connector->waitingForPolish = true;
QTimer::singleShot(0, connector, SLOT(polish()));
@@ -181,8 +180,8 @@ void QDBusAbstractAdaptor::setAutoRelaySignals(bool enable)
}
}
-QDBusAdaptorConnector::QDBusAdaptorConnector(QObject *parent)
- : QObject(parent), waitingForPolish(false), lastSignalIdx(0), argv(0)
+QDBusAdaptorConnector::QDBusAdaptorConnector(QObject *obj)
+ : QObject(obj), waitingForPolish(false), lastSignalIdx(0), argv(0)
{
}
@@ -258,18 +257,18 @@ void QDBusAdaptorConnector::relaySlot()
relay(sender());
}
-void QDBusAdaptorConnector::relay(QObject *sender)
+void QDBusAdaptorConnector::relay(QObject *senderObj)
{
// we're being called because there is a signal being emitted that we must relay
Q_ASSERT(lastSignalIdx);
Q_ASSERT(argv);
Q_ASSERT(senderMetaObject);
- if (senderMetaObject != sender->metaObject()) {
+ if (senderMetaObject != senderObj->metaObject()) {
qWarning("Inconsistency detected: QDBusAdaptorConnector::relay got called with unexpected sender object!");
} else {
QMetaMethod mm = senderMetaObject->method(lastSignalIdx);
- QObject *object = static_cast<QDBusAbstractAdaptor *>(sender)->parent();
+ QObject *object = static_cast<QDBusAbstractAdaptor *>(senderObj)->parent();
// break down the parameter list
QList<int> types;
diff --git a/qt/src/qdbusabstractinterface.cpp b/qt/src/qdbusabstractinterface.cpp
index 2a6bcf0..ffe5d67 100644
--- a/qt/src/qdbusabstractinterface.cpp
+++ b/qt/src/qdbusabstractinterface.cpp
@@ -31,7 +31,8 @@
QVariant QDBusAbstractInterfacePrivate::property(const QMetaProperty &mp) const
{
// try to read this property
- QDBusMessage msg = QDBusMessage::methodCall(service, path, DBUS_INTERFACE_PROPERTIES,
+ QDBusMessage msg = QDBusMessage::methodCall(service, path,
+ QLatin1String(DBUS_INTERFACE_PROPERTIES),
QLatin1String("Get"));
msg << interface << QString::fromUtf8(mp.name());
QDBusMessage reply = connp->sendWithReply(msg, QDBusConnection::NoUseEventLoop);
@@ -72,7 +73,8 @@ QVariant QDBusAbstractInterfacePrivate::property(const QMetaProperty &mp) const
void QDBusAbstractInterfacePrivate::setProperty(const QMetaProperty &mp, const QVariant &value)
{
// send the value
- QDBusMessage msg = QDBusMessage::methodCall(service, path, DBUS_INTERFACE_PROPERTIES,
+ QDBusMessage msg = QDBusMessage::methodCall(service, path,
+ QLatin1String(DBUS_INTERFACE_PROPERTIES),
QLatin1String("Set"));
msg.setSignature(QLatin1String("ssv"));
msg << interface << QString::fromUtf8(mp.name()) << value;
@@ -185,7 +187,6 @@ QDBusError QDBusAbstractInterface::lastError() const
}
/*!
- \threadsafe
Places a call to the remote method specified by \a method on this interface, using \a args as
arguments. This function returns the message that was received as a reply, which can be a normal
QDBusMessage::ReplyMessage (indicating success) or QDBusMessage::ErrorMessage (if the call
@@ -199,6 +200,8 @@ QDBusError QDBusAbstractInterface::lastError() const
\warning If you use \c UseEventLoop, your code must be prepared to deal with any reentrancy:
other method calls and signals may be delivered before this function returns, as well
as other Qt queued signals and events.
+
+ \threadsafe
*/
QDBusMessage QDBusAbstractInterface::callWithArgs(const QString& method, const QList<QVariant>& args,
CallMode mode)
diff --git a/qt/src/qdbusbus.cpp b/qt/src/qdbusbus.cpp
index 02c231e..f46966b 100644
--- a/qt/src/qdbusbus.cpp
+++ b/qt/src/qdbusbus.cpp
@@ -151,21 +151,21 @@ QDBusReply<QStringList> QDBusBusService::ListNames()
}
/*!
- \fn QDBusBusService::listQueuedOwners(const QString &service)
+ \fn QDBusBusService::listQueuedOwners(const QString &serviceName)
Returns a list of all unique connection names in queue for the service name \a service.
*/
-QDBusReply<QStringList> QDBusBusService::ListQueuedOwners(const QString &service)
+QDBusReply<QStringList> QDBusBusService::ListQueuedOwners(const QString &serviceName)
{
- return call(QLatin1String("ListQueuedOwners.s"), service);
+ return call(QLatin1String("ListQueuedOwners.s"), serviceName);
}
/*!
- \fn QDBusBusService::nameHasOwner(const QString &service)
+ \fn QDBusBusService::nameHasOwner(const QString &serviceName)
Returns true if the service name \a service has an owner.
*/
-QDBusReply<bool> QDBusBusService::NameHasOwner(const QString &service)
+QDBusReply<bool> QDBusBusService::NameHasOwner(const QString &serviceName)
{
- return call(QLatin1String("NameHasOwner.s"), service);
+ return call(QLatin1String("NameHasOwner.s"), serviceName);
}
/*!
@@ -189,31 +189,31 @@ QDBusReply<void> QDBusBusService::RemoveMatch(const QString &rule)
}
/*!
- \fn QDBusBusService::connectionSELinuxSecurityContext(const QString &service)
+ \fn QDBusBusService::connectionSELinuxSecurityContext(const QString &serviceName)
Returns the SELinux security context of the process currently holding the bus service \a
service.
*/
-QDBusReply<QByteArray> QDBusBusService::GetConnectionSELinuxSecurityContext(const QString &service)
+QDBusReply<QByteArray> QDBusBusService::GetConnectionSELinuxSecurityContext(const QString &serviceName)
{
- return call(QLatin1String("GetConnectionSELinuxSecurityContext.s"), service);
+ return call(QLatin1String("GetConnectionSELinuxSecurityContext.s"), serviceName);
}
/*!
- \fn QDBusBusService::connectionUnixProcessID(const QString &service)
+ \fn QDBusBusService::connectionUnixProcessID(const QString &serviceName)
Returns the Unix Process ID (PID) for the process currently holding the bus service \a service.
*/
-QDBusReply<uint> QDBusBusService::GetConnectionUnixProcessID(const QString &service)
+QDBusReply<uint> QDBusBusService::GetConnectionUnixProcessID(const QString &serviceName)
{
- return call(QLatin1String("GetConnectionUnixProcessID.s"), service);
+ return call(QLatin1String("GetConnectionUnixProcessID.s"), serviceName);
}
/*!
- \fn QDBusBusService::connectionUnixUser(const QString &service)
+ \fn QDBusBusService::connectionUnixUser(const QString &serviceName)
Returns the Unix User ID (UID) for the process currently holding the bus service \a service.
*/
-QDBusReply<uint> QDBusBusService::GetConnectionUnixUser(const QString &service)
+QDBusReply<uint> QDBusBusService::GetConnectionUnixUser(const QString &serviceName)
{
- return call(QLatin1String("GetConnectionUnixUser.s"), service);
+ return call(QLatin1String("GetConnectionUnixUser.s"), serviceName);
}
/*!
@@ -244,36 +244,36 @@ inline QDBUS_EXPORT int qDBusMetaTypeId(QDBusBusService::RequestNameReply *)
{ return QVariant::Int; }
/*!
- \fn QDBusBusService::requestName(const QString &service, RequestNameOptions flags)
+ \fn QDBusBusService::requestName(const QString &serviceName, RequestNameOptions flags)
Requests the bus service name \a service from the bus. The \a flags parameter specifies how the
bus server daemon should act when the same name is requested by two different applications.
\sa releaseName()
*/
QDBusReply<QDBusBusService::RequestNameReply>
-QDBusBusService::RequestName(const QString &service, RequestNameOptions flags)
+QDBusBusService::RequestName(const QString &serviceName, RequestNameOptions flags)
{
- return call(QLatin1String("RequestName.su"), service, uint(int(flags)));
+ return call(QLatin1String("RequestName.su"), serviceName, uint(int(flags)));
}
inline QDBUS_EXPORT int qDBusMetaTypeId(QDBusBusService::ReleaseNameReply *)
{ return QVariant::Int; }
/*!
- \fn QDBusBusService::releaseName(const QString &service)
+ \fn QDBusBusService::releaseName(const QString &serviceName)
Releases the claim on the bus service name \a service, that had been previously requested with
requestName(). If this application had ownership of the name, it will be released for other
applications to claim. If it only had the name queued, it gives up its position in the queue.
*/
QDBusReply<QDBusBusService::ReleaseNameReply>
-QDBusBusService::ReleaseName(const QString &service)
+QDBusBusService::ReleaseName(const QString &serviceName)
{
- return call(QLatin1String("ReleaseName.s"), service);
+ return call(QLatin1String("ReleaseName.s"), serviceName);
}
// signals
/*!
- \fn QDBusBusService::nameAcquired(const QString &service)
+ \fn QDBusBusService::nameAcquired(const QString &serviceName)
This signal is emitted by the D-Bus bus server when the bus service name (unique connection name
or well-known service name) given by \a service is acquired by this application.
@@ -282,7 +282,7 @@ QDBusBusService::ReleaseName(const QString &service)
*/
/*!
- \fn QDBusBusService::nameLost(const QString &service)
+ \fn QDBusBusService::nameLost(const QString &serviceName)
This signal is emitted by the D-Bus bus server when the application loses ownership of the bus
service name given by \a service.
diff --git a/qt/src/qdbusbus.h b/qt/src/qdbusbus.h
index 2260685..1f69579 100644
--- a/qt/src/qdbusbus.h
+++ b/qt/src/qdbusbus.h
@@ -105,14 +105,14 @@ public: // METHODS
QDBusReply<StartServiceReply> StartServiceByName(const QString &name, uint flags);
-signals: // SIGNALS
+Q_SIGNALS: // SIGNALS
void NameAcquired(const QString &service);
void NameLost(const QString &service);
void NameOwnerChanged(const QString &name, const QString &oldOwner, const QString &newOwner);
#endif
// Qt-style naming
-public slots:
+public Q_SLOTS:
QDBusReply<QString> hello()
{ return Hello(); }
QDBusReply<void> reloadConfig()
@@ -121,33 +121,33 @@ public slots:
QDBusReply<QStringList> listNames()
{ return ListNames(); }
- QDBusReply<bool> nameHasOwner(const QString &service)
- { return NameHasOwner(service); }
+ QDBusReply<bool> nameHasOwner(const QString &serviceName)
+ { return NameHasOwner(serviceName); }
QDBusReply<QString> nameOwner(const QString &name)
{ return GetNameOwner(name); }
- QDBusReply<ReleaseNameReply> releaseName(const QString &service)
- { return ReleaseName(service); }
- QDBusReply<RequestNameReply> requestName(const QString &service, RequestNameOptions flags)
- { return RequestName(service, flags); }
- QDBusReply<QStringList> listQueuedOwners(const QString &service)
- { return ListQueuedOwners(service); }
+ QDBusReply<ReleaseNameReply> releaseName(const QString &serviceName)
+ { return ReleaseName(serviceName); }
+ QDBusReply<RequestNameReply> requestName(const QString &serviceName, RequestNameOptions flags)
+ { return RequestName(serviceName, flags); }
+ QDBusReply<QStringList> listQueuedOwners(const QString &serviceName)
+ { return ListQueuedOwners(serviceName); }
QDBusReply<void> addMatch(const QString &rule)
{ return AddMatch(rule); }
QDBusReply<void> removeMatch(const QString &rule)
{ return RemoveMatch(rule); }
- QDBusReply<QByteArray> connectionSELinuxSecurityContext(const QString &service)
- { return GetConnectionSELinuxSecurityContext(service); }
- QDBusReply<uint> connectionUnixProcessID(const QString &service)
- { return GetConnectionUnixProcessID(service); }
- QDBusReply<uint> connectionUnixUser(const QString &service)
- { return GetConnectionUnixUser(service); }
+ QDBusReply<QByteArray> connectionSELinuxSecurityContext(const QString &serviceName)
+ { return GetConnectionSELinuxSecurityContext(serviceName); }
+ QDBusReply<uint> connectionUnixProcessID(const QString &serviceName)
+ { return GetConnectionUnixProcessID(serviceName); }
+ QDBusReply<uint> connectionUnixUser(const QString &serviceName)
+ { return GetConnectionUnixUser(serviceName); }
QDBusReply<StartServiceReply> startServiceByName(const QString &name, uint flags)
{ return StartServiceByName(name, flags); }
-signals:
+Q_SIGNALS:
void nameAcquired(const QString &service);
void nameLost(const QString &service);
void nameOwnerChanged(const QString &name, const QString &oldOwner, const QString &newOwner);
diff --git a/qt/src/qdbusconnection.cpp b/qt/src/qdbusconnection.cpp
index 6cd733c..7049857 100644
--- a/qt/src/qdbusconnection.cpp
+++ b/qt/src/qdbusconnection.cpp
@@ -294,7 +294,7 @@ QDBusConnection QDBusConnection::addConnection(BusType type, const QString &name
QDBusAbstractInterfacePrivate *p;
p = retval.findInterface_helper(QLatin1String(DBUS_SERVICE_DBUS),
QLatin1String(DBUS_PATH_DBUS),
- QLatin1String(DBUS_INTERFACE_DBUS));
+ DBUS_INTERFACE_DBUS);
if (p) {
d->busService = new QDBusBusService(p);
d->busService->setParent(d); // auto-deletion
@@ -330,7 +330,7 @@ QDBusConnection QDBusConnection::addConnection(const QString &address,
QDBusAbstractInterfacePrivate *p;
p = retval.findInterface_helper(QLatin1String(DBUS_SERVICE_DBUS),
QLatin1String(DBUS_PATH_DBUS),
- QLatin1String(DBUS_INTERFACE_DBUS));
+ DBUS_INTERFACE_DBUS);
if (p) {
d->busService = new QDBusBusService(p);
d->busService->setParent(d); // auto-deletion
@@ -451,7 +451,7 @@ bool QDBusConnection::connect(const QString &service, const QString &path, const
// avoid duplicating:
QWriteLocker locker(&d->lock);
QDBusConnectionPrivate::SignalHookHash::ConstIterator it = d->signalHooks.find(key);
- for ( ; it != d->signalHooks.end() && it.key() == key; ++it) {
+ for ( ; it != d->signalHooks.constEnd() && it.key() == key; ++it) {
const QDBusConnectionPrivate::SignalHook &entry = it.value();
if (entry.sender == hook.sender &&
entry.path == hook.path &&
@@ -481,6 +481,8 @@ bool QDBusConnection::connect(const QString &service, const QString &path, const
*/
bool QDBusConnection::registerObject(const QString &path, QObject *object, RegisterOptions options)
{
+ Q_ASSERT_X(QDBusUtil::isValidObjectPath(path), "QDBusConnection::registerObject",
+ "Invalid object path given");
if (!d || !d->connection || !object || !options || !QDBusUtil::isValidObjectPath(path))
return false;
@@ -601,6 +603,12 @@ void QDBusConnection::unregisterObject(const QString &path, UnregisterMode mode)
QDBusInterface *QDBusConnection::findInterface(const QString& service, const QString& path,
const QString& interface)
{
+ Q_ASSERT_X(QDBusUtil::isValidBusName(service),
+ "QDBusConnection::findInterface", "Invalid service name");
+ Q_ASSERT_X(QDBusUtil::isValidObjectPath(path),
+ "QDBusConnection::findInterface", "Invalid object path given");
+ Q_ASSERT_X(interface.isEmpty() || QDBusUtil::isValidInterfaceName(interface),
+ "QDBusConnection::findInterface", "Invalid interface name");
if (!d)
return 0;
@@ -636,24 +644,31 @@ QDBusBusService *QDBusConnection::busService() const
QDBusAbstractInterfacePrivate *
QDBusConnection::findInterface_helper(const QString &service, const QString &path,
- const QString &interface)
+ const char *iface)
{
+ QString interface = QLatin1String(iface);
+ // service and path can be empty here, but interface can't
+ Q_ASSERT_X(service.isEmpty() || QDBusUtil::isValidBusName(service),
+ "QDBusConnection::findInterface", "Invalid service name");
+ Q_ASSERT_X(path.isEmpty() || QDBusUtil::isValidObjectPath(path),
+ "QDBusConnection::findInterface", "Invalid object path given");
+ Q_ASSERT_X(QDBusUtil::isValidInterfaceName(interface),
+ "QDBusConnection::findInterface", "Invalid interface class!");
if (!d)
return 0;
- if (!interface.isEmpty() && !QDBusUtil::isValidInterfaceName(interface))
- return 0;
-
+
QString owner;
if (!service.isEmpty()) {
- if (!QDBusUtil::isValidObjectPath(path))
- return 0;
-
// check if it's there first -- FIXME: add binding mode
owner = d->getNameOwner(service);
- if (owner.isEmpty())
- return 0;
- } else if (!path.isEmpty())
- return 0;
+ if (owner.isEmpty()) {
+ QDBusAbstractInterfacePrivate *p;
+ p = new QDBusAbstractInterfacePrivate(*this, d, service, path, interface);
+ p->isValid = false;
+ p->lastError = d->lastError;
+ return p;
+ }
+ }
return new QDBusAbstractInterfacePrivate(*this, d, owner, path, interface);
}
diff --git a/qt/src/qdbusconnection.h b/qt/src/qdbusconnection.h
index c1c420a..61a3439 100644
--- a/qt/src/qdbusconnection.h
+++ b/qt/src/qdbusconnection.h
@@ -101,17 +101,17 @@ public:
private:
QDBusAbstractInterfacePrivate *findInterface_helper(const QString &, const QString &,
- const QString&);
+ const char*);
QDBusConnectionPrivate *d;
};
template<class Interface>
inline Interface *QDBusConnection::findInterface(const QString &service, const QString &path)
{
- register QDBusAbstractInterfacePrivate *d;
- d = findInterface_helper(service, path, Interface::staticInterfaceName());
- if (d)
- return new Interface(d);
+ register QDBusAbstractInterfacePrivate *d_ptr;
+ d_ptr = findInterface_helper(service, path, Interface::staticInterfaceName());
+ if (d_ptr)
+ return new Interface(d_ptr);
return 0;
}
diff --git a/qt/src/qdbuserror.cpp b/qt/src/qdbuserror.cpp
index d5cd675..ee6ce12 100644
--- a/qt/src/qdbuserror.cpp
+++ b/qt/src/qdbuserror.cpp
@@ -135,11 +135,11 @@ Q_GLOBAL_STATIC(ErrorMessageMapping, errorMessages)
pre-defined values (\c org.freedesktop.DBus.Error.LimitsExceeded)
\value AccessDenied The call/operation tried to access a resource it isn't allowed to
(\c org.freedesktop.DBus.Error.AccessDenied)
- \value NoServer \i{Documentation doesn't say what this is for}
+ \value NoServer \e {Documentation doesn't say what this is for}
(\c org.freedesktop.DBus.Error.NoServer)
- \value Timeout \i{Documentation doesn't say what this is for or how it's used}
+ \value Timeout \e {Documentation doesn't say what this is for or how it's used}
(\c org.freedesktop.DBus.Error.Timeout)
- \value NoNetwork \i{Documentation doesn't say what this is for}
+ \value NoNetwork \e {Documentation doesn't say what this is for}
(\c org.freedesktop.DBus.Error.NoNetwork)
\value AddressInUse QDBusServer tried to bind to an address that is already in use
(\c org.freedesktop.DBus.Error.AddressInUse)
@@ -149,7 +149,7 @@ Q_GLOBAL_STATIC(ErrorMessageMapping, errorMessages)
(\c org.freedesktop.DBus.Error.InvalidArgs)
\value UnknownMethod The method called was not found in this object/interface with the
given parameters (\c org.freedesktop.DBus.Error.UnknownMethod)
- \value TimedOut \i{Documentation doesn't say...}
+ \value TimedOut \e {Documentation doesn't say...}
(\c org.freedesktop.DBus.Error.TimedOut)
\value InvalidSignature The type signature is not valid or compatible
(\c org.freedesktop.DBus.Error.InvalidSignature)
@@ -194,11 +194,11 @@ QDBusError::QDBusError(const QDBusMessage &qdmsg)
\internal
Constructs a QDBusError from a well-known error code
*/
-QDBusError::QDBusError(KnownErrors error, const QString &message)
+QDBusError::QDBusError(KnownErrors error, const QString &mess)
: code(error)
{
- nm = errorMessages()->get(error);
- msg = message;
+ nm = QLatin1String(errorMessages()->get(error));
+ msg = mess;
}
/*!
@@ -233,7 +233,7 @@ QDBusError::QDBusError(KnownErrors error, const QString &message)
match.
*/
-#ifndef QT_NO_DEBUG
+#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug dbg, const QDBusError &msg)
{
dbg.nospace() << "QDBusError(" << msg.name() << ", " << msg.message() << ")";
diff --git a/qt/src/qdbuserror.h b/qt/src/qdbuserror.h
index 71c636d..e7aacdb 100644
--- a/qt/src/qdbuserror.h
+++ b/qt/src/qdbuserror.h
@@ -86,7 +86,7 @@ inline bool operator!=(QDBusError::KnownErrors p1, const QDBusError &p2)
inline bool operator!=(const QDBusError &p1, QDBusError::KnownErrors p2)
{ return !(p1 == p2); }
-#ifndef QT_NO_DEBUG
+#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug, const QDBusError &);
#endif
diff --git a/qt/src/qdbusintegrator.cpp b/qt/src/qdbusintegrator.cpp
index 07921cf..de012c1 100644
--- a/qt/src/qdbusintegrator.cpp
+++ b/qt/src/qdbusintegrator.cpp
@@ -507,13 +507,13 @@ bool QDBusConnectionPrivate::activateCall(QObject* object, int flags,
{
const QMetaObject *mo = object->metaObject();
QDBusTypeList typeList(msg.signature().toUtf8());
- QByteArray name = msg.name().toUtf8();
+ QByteArray memberName = msg.name().toUtf8();
// find a slot that matches according to the rules above
- idx = ::findSlot(mo, name, flags, typeList, metaTypes);
+ idx = ::findSlot(mo, memberName, flags, typeList, metaTypes);
if (idx == -1) {
// try with no parameters, but with a QDBusMessage
- idx = ::findSlot(mo, name, flags, QDBusTypeList(), metaTypes);
+ idx = ::findSlot(mo, memberName, flags, QDBusTypeList(), metaTypes);
if (metaTypes.count() != 2 || metaTypes.at(1) != messageMetaType)
return false;
}
@@ -594,7 +594,7 @@ void QDBusConnectionPrivate::deliverCall(const CallDeliveryEvent& data) const
const QVariant &in = msg.at(i - 1);
QVariant &out = auxParameters[auxParameters.count() - 1];
- bool error = false;
+ bool isOk = true;
if (id == QVariant::List) {
int mid = in.userType();
// the only conversion possible here is from a specialised QList<T> to QVariantList
@@ -615,7 +615,7 @@ void QDBusConnectionPrivate::deliverCall(const CallDeliveryEvent& data) const
else if (mid == QDBusTypeHelper<double>::listId())
out = qVariantFromValue(QDBusTypeHelper<double>::toVariantList(in));
else
- error = true;
+ isOk = false;
} else if (in.type() == QVariant::UInt) {
if (id == QMetaType::UChar) {
uchar uc = in.toUInt();
@@ -624,20 +624,20 @@ void QDBusConnectionPrivate::deliverCall(const CallDeliveryEvent& data) const
ushort us = in.toUInt();
out = qVariantFromValue(us);
} else {
- error = true;
+ isOk = false;
}
} else if (in.type() == QVariant::Int) {
if (id == QMetaType::Short) {
short s = in.toInt();
out = qVariantFromValue(s);
} else {
- error = true;
+ isOk = false;
}
} else {
- error = true;
+ isOk = false;
}
- if (error)
+ if (!isOk)
qFatal("Internal error: got invalid meta type %d when trying to convert to meta type %d",
in.userType(), id);
@@ -697,10 +697,10 @@ void QDBusConnectionPrivate::deliverCall(const CallDeliveryEvent& data) const
return;
}
-void QDBusConnectionPrivate::customEvent(QEvent *event)
+void QDBusConnectionPrivate::customEvent(QEvent *e)
{
// nothing else should be sending custom events at us
- CallDeliveryEvent* call = static_cast<CallDeliveryEvent *>(event);
+ CallDeliveryEvent* call = static_cast<CallDeliveryEvent *>(e);
// self check:
Q_ASSERT(call->conn == this);
@@ -708,8 +708,8 @@ void QDBusConnectionPrivate::customEvent(QEvent *event)
deliverCall(*call);
}
-QDBusConnectionPrivate::QDBusConnectionPrivate(QObject *parent)
- : QObject(parent), ref(1), mode(InvalidMode), connection(0), server(0), busService(0)
+QDBusConnectionPrivate::QDBusConnectionPrivate(QObject *p)
+ : QObject(p), ref(1), mode(InvalidMode), connection(0), server(0), busService(0)
{
extern bool qDBusInitThreads();
static const int msgType = registerMessageMetaType();
@@ -845,16 +845,16 @@ void QDBusConnectionPrivate::objectDestroyed(QObject *obj)
obj->disconnect(this);
}
-void QDBusConnectionPrivate::relaySignal(QObject *obj, const char *interface, const char *name,
+void QDBusConnectionPrivate::relaySignal(QObject *obj, const char *interface, const char *memberName,
const QVariantList &args)
{
QReadLocker locker(&lock);
QDBusMessage message = QDBusMessage::signal(QLatin1String("/"), QLatin1String(interface),
- QLatin1String(name));
+ QLatin1String(memberName));
message += args;
DBusMessage *msg = message.toDBusMessage();
if (!msg) {
- qWarning("Could not emit signal %s.%s", interface, name);
+ qWarning("Could not emit signal %s.%s", interface, memberName);
return;
}
@@ -910,7 +910,7 @@ bool QDBusConnectionPrivate::prepareHook(QDBusConnectionPrivate::SignalHook &hoo
}
key = mname;
key.reserve(interface.length() + 1 + mname.length());
- key += ':';
+ key += QLatin1Char(':');
key += interface;
if (buildSignature) {
@@ -973,7 +973,7 @@ bool QDBusConnectionPrivate::activateObject(const ObjectTreeNode *node, const QD
QDBusAdaptorConnector::AdaptorMap::ConstIterator it;
it = qLowerBound(connector->adaptors.constBegin(), connector->adaptors.constEnd(),
msg.interface());
- if (it != connector->adaptors.end() && it->interface == msg.interface())
+ if (it != connector->adaptors.constEnd() && it->interface == msg.interface())
if (activateCall(it->adaptor, newflags, msg))
return true;
}
@@ -1114,7 +1114,7 @@ bool QDBusConnectionPrivate::handleSignal(const QDBusMessage& msg)
{
QString key = msg.member();
key.reserve(key.length() + 1 + msg.interface().length());
- key += ':';
+ key += QLatin1Char(':');
key += msg.interface();
QReadLocker locker(&lock);
@@ -1257,9 +1257,9 @@ int QDBusConnectionPrivate::send(const QDBusMessage& message) const
}
QDBusMessage QDBusConnectionPrivate::sendWithReply(const QDBusMessage &message,
- int mode)
+ int sendMode)
{
- if (!QCoreApplication::instance() || mode == QDBusConnection::NoUseEventLoop) {
+ if (!QCoreApplication::instance() || sendMode == QDBusConnection::NoUseEventLoop) {
DBusMessage *msg = message.toDBusMessage();
if (!msg)
return QDBusMessage();
@@ -1368,7 +1368,7 @@ void QDBusConnectionPrivate::connectRelay(const QString &service, const QString
// add it to our list:
QWriteLocker locker(&lock);
SignalHookHash::ConstIterator it = signalHooks.find(key);
- SignalHookHash::ConstIterator end = signalHooks.end();
+ SignalHookHash::ConstIterator end = signalHooks.constEnd();
for ( ; it != end && it.key() == key; ++it) {
const SignalHook &entry = it.value();
if (entry.sender == hook.sender &&
@@ -1415,17 +1415,17 @@ void QDBusConnectionPrivate::disconnectRelay(const QString &service, const QStri
qWarning("QDBusConnectionPrivate::disconnectRelay called for a signal that was not found");
}
-QString QDBusConnectionPrivate::getNameOwner(const QString& name)
+QString QDBusConnectionPrivate::getNameOwner(const QString& serviceName)
{
- if (QDBusUtil::isValidUniqueConnectionName(name))
- return name;
- if (!connection || !QDBusUtil::isValidBusName(name))
+ if (QDBusUtil::isValidUniqueConnectionName(serviceName))
+ return serviceName;
+ if (!connection || !QDBusUtil::isValidBusName(serviceName))
return QString();
QDBusMessage msg = QDBusMessage::methodCall(QLatin1String(DBUS_SERVICE_DBUS),
QLatin1String(DBUS_PATH_DBUS), QLatin1String(DBUS_INTERFACE_DBUS),
QLatin1String("GetNameOwner"));
- msg << name;
+ msg << serviceName;
QDBusMessage reply = sendWithReply(msg, QDBusConnection::NoUseEventLoop);
if (!lastError.isValid() && reply.type() == QDBusMessage::ReplyMessage)
return reply.first().toString();
@@ -1459,12 +1459,14 @@ QDBusConnectionPrivate::findInterface(const QString &service,
else if (owner.isEmpty())
p->lastError = QDBusError(QDBusError::ServiceUnknown,
QString(QLatin1String("Service %1 is unknown")).arg(service));
+#if 0 // caught by Q_ASSERT in QDBusConnection::findInterface
else if (!QDBusUtil::isValidObjectPath(path))
p->lastError = QDBusError(QDBusError::InvalidArgs,
QString(QLatin1String("Object path %1 is invalid")).arg(path));
else if (!interface.isEmpty() && !QDBusUtil::isValidInterfaceName(interface))
p->lastError = QDBusError(QDBusError::InvalidArgs,
QString(QLatin1String("Interface %1 is invalid")).arg(interface));
+#endif
else
p->lastError = QDBusError(QDBusError::Other, QLatin1String("Unknown error"));
}
diff --git a/qt/src/qdbusinterface.cpp b/qt/src/qdbusinterface.cpp
index 6367654..7209707 100644
--- a/qt/src/qdbusinterface.cpp
+++ b/qt/src/qdbusinterface.cpp
@@ -75,7 +75,7 @@ void *QDBusInterface::qt_metacast(const char *_clname)
if (!_clname) return 0;
if (!strcmp(_clname, "QDBusInterface"))
return static_cast<void*>(const_cast<QDBusInterface*>(this));
- if (d_func()->interface == _clname)
+ if (d_func()->interface.toLatin1() == _clname)
return static_cast<void*>(const_cast<QDBusInterface*>(this));
return QDBusAbstractInterface::qt_metacast(_clname);
}
@@ -107,7 +107,7 @@ int QDBusInterfacePrivate::metacall(QMetaObject::Call c, int id, void **argv)
} else if (mm.methodType() == QMetaMethod::Slot) {
// method call relay from Qt world to D-Bus world
// get D-Bus equivalent signature
- QString methodName = metaObject->dbusNameForMethod(id);
+ QString methodName = QLatin1String(metaObject->dbusNameForMethod(id));
const int *inputTypes = metaObject->inputTypesForMethod(id);
const int *outputTypes = metaObject->outputTypesForMethod(id);
@@ -191,13 +191,13 @@ int QDBusInterfacePrivate::metacall(QMetaObject::Call c, int id, void **argv)
}
QDBusInterfacePtr::QDBusInterfacePtr(QDBusConnection &conn, const QString &service, const QString &path,
- const QString &interface)
- : d(conn.findInterface(service, path, interface))
+ const QString &iface)
+ : d(conn.findInterface(service, path, iface))
{
}
-QDBusInterfacePtr::QDBusInterfacePtr(const QString &service, const QString &path, const QString &interface)
- : d(QDBus::sessionBus().findInterface(service, path, interface))
+QDBusInterfacePtr::QDBusInterfacePtr(const QString &service, const QString &path, const QString &iface)
+ : d(QDBus::sessionBus().findInterface(service, path, iface))
{
}
diff --git a/qt/src/qdbusinternalfilters.cpp b/qt/src/qdbusinternalfilters.cpp
index 8886d3b..ed21074 100644
--- a/qt/src/qdbusinternalfilters.cpp
+++ b/qt/src/qdbusinternalfilters.cpp
@@ -165,7 +165,7 @@ void qDBusPropertyGet(const QDBusConnectionPrivate::ObjectTreeNode *node, const
QDBusAdaptorConnector::AdaptorMap::ConstIterator it;
it = qLowerBound(connector->adaptors.constBegin(), connector->adaptors.constEnd(),
interface_name);
- if (it != connector->adaptors.end() && it->interface == interface_name)
+ if (it != connector->adaptors.constEnd() && it->interface == interface_name)
value = it->adaptor->property(property_name);
}
diff --git a/qt/src/qdbusmessage.cpp b/qt/src/qdbusmessage.cpp
index d0a0f1e..ec24100 100644
--- a/qt/src/qdbusmessage.cpp
+++ b/qt/src/qdbusmessage.cpp
@@ -55,12 +55,10 @@ QDBusMessagePrivate::~QDBusMessagePrivate()
This object can represent any of four different types of messages possible on the bus
(see MessageType)
- \list
- \o Method calls
- \o Method return values
- \o Signal emissions
- \o Error codes
- \endlist
+ - Method calls
+ - Method return values
+ - Signal emissions
+ - Error codes
Objects of this type are created with the four static functions signal, methodCall,
methodReply and error.
@@ -432,7 +430,7 @@ QString QDBusMessage::signature() const
/*!
Sets the signature for the output arguments of this method call to be the value of \a
- signature. This function has no meaning in other types of messages or when dealing with received
+ sig. This function has no meaning in other types of messages or when dealing with received
method calls.
A message's signature indicate the type of the parameters to
@@ -442,10 +440,10 @@ QString QDBusMessage::signature() const
when a variant of type QVariant::Invalid is converted to the type).
*/
-void QDBusMessage::setSignature(const QString &signature)
+void QDBusMessage::setSignature(const QString &sig)
{
qAtomicDetach(d_ptr);
- d_ptr->signature = signature;
+ d_ptr->signature = sig;
}
/*!
@@ -569,7 +567,7 @@ QDBusMessage::MessageType QDBusMessage::type() const
value.
*/
-#ifndef QT_NO_DEBUG
+#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug dbg, QDBusMessage::MessageType t)
{
switch (t)
diff --git a/qt/src/qdbusmessage.h b/qt/src/qdbusmessage.h
index f8feeae..a36d398 100644
--- a/qt/src/qdbusmessage.h
+++ b/qt/src/qdbusmessage.h
@@ -91,7 +91,7 @@ private:
QDBusMessagePrivate *d_ptr;
};
-#ifndef QT_NO_DEBUG
+#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug, const QDBusMessage &);
#endif
diff --git a/qt/src/qdbusmetaobject.cpp b/qt/src/qdbusmetaobject.cpp
index a923d79..60675d5 100644
--- a/qt/src/qdbusmetaobject.cpp
+++ b/qt/src/qdbusmetaobject.cpp
@@ -154,7 +154,7 @@ void QDBusMetaObjectGenerator::parseMethods()
break;
}
- mm.inputSignature += arg.type;
+ mm.inputSignature += arg.type.toLatin1();
mm.inputTypes.append(typeId);
mm.parameters.append(arg.name.toLatin1());
@@ -175,7 +175,7 @@ void QDBusMetaObjectGenerator::parseMethods()
break;
}
- mm.outputSignature += arg.type;
+ mm.outputSignature += arg.type.toLatin1();
mm.outputTypes.append(typeId);
if (i == 0) {
@@ -230,7 +230,7 @@ void QDBusMetaObjectGenerator::parseSignals()
break;
}
- mm.inputSignature += arg.type;
+ mm.inputSignature += arg.type.toLatin1();
mm.inputTypes.append(typeId);
mm.parameters.append(arg.name.toLatin1());
@@ -297,16 +297,16 @@ void QDBusMetaObjectGenerator::write(QDBusMetaObject *obj)
if (className.isEmpty())
className = QLatin1String("QDBusInterface");
- QVarLengthArray<int> data;
- data.resize(sizeof(QDBusMetaObjectPrivate) / sizeof(int));
+ QVarLengthArray<int> idata;
+ idata.resize(sizeof(QDBusMetaObjectPrivate) / sizeof(int));
- QDBusMetaObjectPrivate *header = reinterpret_cast<QDBusMetaObjectPrivate *>(data.data());
+ QDBusMetaObjectPrivate *header = reinterpret_cast<QDBusMetaObjectPrivate *>(idata.data());
header->revision = 1;
header->className = 0;
header->classInfoCount = 0;
header->classInfoData = 0;
header->methodCount = methods.count();
- header->methodData = data.size();
+ header->methodData = idata.size();
header->propertyCount = properties.count();
header->propertyData = header->methodData + header->methodCount * 5;
header->enumeratorCount = 0;
@@ -314,12 +314,12 @@ void QDBusMetaObjectGenerator::write(QDBusMetaObject *obj)
header->propertyDBusData = header->propertyData + header->propertyCount * 3;
header->methodDBusData = header->propertyDBusData + header->propertyCount * intsPerProperty;
- int data_size = data.size() +
+ int data_size = idata.size() +
(header->methodCount * (5+intsPerMethod)) +
(header->propertyCount * (3+intsPerProperty));
foreach (const Method &mm, methods)
data_size += 2 + mm.inputTypes.count() + mm.outputTypes.count();
- data.resize(data_size + 1);
+ idata.resize(data_size + 1);
char null('\0');
QByteArray stringdata = className.toLatin1();
@@ -329,7 +329,7 @@ void QDBusMetaObjectGenerator::write(QDBusMetaObject *obj)
int offset = header->methodData;
int signatureOffset = header->methodDBusData;
int typeidOffset = header->methodDBusData + header->methodCount * intsPerMethod;
- data[typeidOffset++] = 0; // eod
+ idata[typeidOffset++] = 0; // eod
// add each method:
for (QMap<QByteArray, Method>::ConstIterator it = methods.constBegin();
@@ -337,41 +337,41 @@ void QDBusMetaObjectGenerator::write(QDBusMetaObject *obj)
// form "prototype\0parameters\0typeName\0tag\0inputSignature\0outputSignature"
const Method &mm = it.value();
- data[offset++] = stringdata.length();
+ idata[offset++] = stringdata.length();
stringdata += it.key(); // prototype
stringdata += null;
- data[offset++] = stringdata.length();
+ idata[offset++] = stringdata.length();
stringdata += mm.parameters;
stringdata += null;
- data[offset++] = stringdata.length();
+ idata[offset++] = stringdata.length();
stringdata += mm.typeName;
stringdata += null;
- data[offset++] = stringdata.length();
+ idata[offset++] = stringdata.length();
stringdata += mm.tag;
stringdata += null;
- data[offset++] = mm.flags;
+ idata[offset++] = mm.flags;
- data[signatureOffset++] = stringdata.length();
+ idata[signatureOffset++] = stringdata.length();
stringdata += mm.inputSignature;
stringdata += null;
- data[signatureOffset++] = stringdata.length();
+ idata[signatureOffset++] = stringdata.length();
stringdata += mm.outputSignature;
stringdata += null;
- data[signatureOffset++] = typeidOffset;
- data[typeidOffset++] = mm.inputTypes.count();
- memcpy(data.data() + typeidOffset, mm.inputTypes.data(), mm.inputTypes.count() * sizeof(int));
+ idata[signatureOffset++] = typeidOffset;
+ idata[typeidOffset++] = mm.inputTypes.count();
+ memcpy(idata.data() + typeidOffset, mm.inputTypes.data(), mm.inputTypes.count() * sizeof(int));
typeidOffset += mm.inputTypes.count();
- data[signatureOffset++] = typeidOffset;
- data[typeidOffset++] = mm.outputTypes.count();
- memcpy(data.data() + typeidOffset, mm.outputTypes.data(), mm.outputTypes.count() * sizeof(int));
+ 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);
Q_ASSERT(signatureOffset == header->methodDBusData + header->methodCount * intsPerMethod);
- Q_ASSERT(typeidOffset == data.size());
+ Q_ASSERT(typeidOffset == idata.size());
// add each property
signatureOffset = header->propertyDBusData;
@@ -380,18 +380,18 @@ void QDBusMetaObjectGenerator::write(QDBusMetaObject *obj)
const Property &mp = it.value();
// form is "name\0typeName\0signature\0"
- data[offset++] = stringdata.length();
+ idata[offset++] = stringdata.length();
stringdata += it.key(); // name
stringdata += null;
- data[offset++] = stringdata.length();
+ idata[offset++] = stringdata.length();
stringdata += mp.typeName;
stringdata += null;
- data[offset++] = mp.flags;
+ idata[offset++] = mp.flags;
- data[signatureOffset++] = stringdata.length();
+ idata[signatureOffset++] = stringdata.length();
stringdata += mp.signature;
stringdata += null;
- data[signatureOffset++] = mp.type;
+ idata[signatureOffset++] = mp.type;
}
Q_ASSERT(offset == header->propertyDBusData);
@@ -400,8 +400,8 @@ void QDBusMetaObjectGenerator::write(QDBusMetaObject *obj)
char *string_data = new char[stringdata.length()];
memcpy(string_data, stringdata, stringdata.length());
- uint *uint_data = new uint[data.size()];
- memcpy(uint_data, data.data(), data.size() * sizeof(int));
+ uint *uint_data = new uint[idata.size()];
+ memcpy(uint_data, idata.data(), idata.size() * sizeof(int));
// put the metaobject together
obj->d.data = uint_data;
diff --git a/qt/src/qdbusreply.h b/qt/src/qdbusreply.h
index 0b5c12d..2b69cbb 100644
--- a/qt/src/qdbusreply.h
+++ b/qt/src/qdbusreply.h
@@ -53,13 +53,13 @@ public:
return *this;
}
- inline QDBusReply(const QDBusError &error = QDBusError())
- : m_error(error), m_data(Type())
+ inline QDBusReply(const QDBusError &dbusError = QDBusError())
+ : m_error(dbusError), m_data(Type())
{
}
- inline QDBusReply& operator=(const QDBusError& error)
+ inline QDBusReply& operator=(const QDBusError& dbusError)
{
- m_error = error;
+ m_error = dbusError;
m_data = Type();
return *this;
}
@@ -114,8 +114,8 @@ public:
: m_error(reply)
{
}
- inline QDBusReply(const QDBusError &error)
- : m_error(error)
+ inline QDBusReply(const QDBusError &dbusError)
+ : m_error(dbusError)
{
}
diff --git a/qt/src/qdbusserver.cpp b/qt/src/qdbusserver.cpp
index b3b9835..4f5b510 100644
--- a/qt/src/qdbusserver.cpp
+++ b/qt/src/qdbusserver.cpp
@@ -25,8 +25,8 @@
#include "qdbusserver.h"
#include "qdbusconnection_p.h"
-QDBusServer::QDBusServer(const QString &addr, QObject *parent)
- : QObject(parent)
+QDBusServer::QDBusServer(const QString &addr, QObject *p)
+ : QObject(p)
{
d = new QDBusConnectionPrivate(this);
diff --git a/qt/src/qdbusutil.cpp b/qt/src/qdbusutil.cpp
index 872434c..22ce3a8 100644
--- a/qt/src/qdbusutil.cpp
+++ b/qt/src/qdbusutil.cpp
@@ -42,13 +42,11 @@ namespace QDBusUtil
Returns true if this is \a ifaceName is a valid interface name.
Valid interface names must:
- \list
- \o not be empty
- \o not exceed 255 characters in length
- \o be composed of dot-separated string components that contain only ASCII letters, digits
- and the underscore ("_") character
- \o contain at least two such components
- \endlist
+ - not be empty
+ - not exceed 255 characters in length
+ - be composed of dot-separated string components that contain only ASCII letters, digits
+ and the underscore ("_") character
+ - contain at least two such components
*/
bool isValidInterfaceName(const QString& ifaceName)
{
@@ -96,13 +94,11 @@ namespace QDBusUtil
Returns true if \a busName is a valid bus name.
A valid bus name is either a valid unique connection name or follows the rules:
- \list
- \o is not empty
- \o does not exceed 255 characters in length
- \o be composed of dot-separated string components that contain only ASCII letters, digits,
- hyphens or underscores ("_"), but don't start with a digit
- \o contains at least two such elements
- \endlist
+ - is not empty
+ - does not exceed 255 characters in length
+ - be composed of dot-separated string components that contain only ASCII letters, digits,
+ hyphens or underscores ("_"), but don't start with a digit
+ - contains at least two such elements
\sa isValidUniqueConnectionName()
*/
@@ -137,7 +133,7 @@ namespace QDBusUtil
if (memberName.isEmpty() || memberName.length() > DBUS_MAXIMUM_NAME_LENGTH)
return false;
- QRegExp regex(QLatin1String("[a-zA-Z_][a-zA-Z0-9_]+"));
+ QRegExp regex(QLatin1String("[a-zA-Z_][a-zA-Z0-9_]*"));
return regex.exactMatch(memberName);
}
@@ -156,13 +152,11 @@ namespace QDBusUtil
Returns true if \a path is valid object path.
Valid object paths follow the rules:
- \list
- \o start with the slash character ("/")
- \o do not end in a slash, unless the path is just the initial slash
- \o do not contain any two slashes in sequence
- \o contain slash-separated parts, each of which is composed of ASCII letters, digits and
- underscores ("_")
- \endlist
+ - start with the slash character ("/")
+ - do not end in a slash, unless the path is just the initial slash
+ - do not contain any two slashes in sequence
+ - contain slash-separated parts, each of which is composed of ASCII letters, digits and
+ underscores ("_")
*/
bool isValidObjectPath(const QString &path)
{
diff --git a/qt/src/qdbusxmlgenerator.cpp b/qt/src/qdbusxmlgenerator.cpp
index cbd5388..135b8d1 100644
--- a/qt/src/qdbusxmlgenerator.cpp
+++ b/qt/src/qdbusxmlgenerator.cpp
@@ -62,7 +62,7 @@ static QString generateInterfaceXml(const QMetaObject *mo, int flags, int method
continue;
retval += QString(QLatin1String(" <property name=\"%1\" type=\"%2\" access=\"%3\" />\n"))
- .arg(mp.name())
+ .arg(QLatin1String(mp.name()))
.arg(QLatin1String( QDBusUtil::typeToSignature( QVariant::Type(typeId) )))
.arg(QLatin1String( accessvalues[access] ));
}
@@ -165,7 +165,8 @@ QString qDBusGenerateMetaObjectXml(QString interface, const QMetaObject *mo, con
if (interface.startsWith( QLatin1String("QDBus") )) {
interface.prepend( QLatin1String("com.trolltech.QtDBus.") );
- } else if (interface.startsWith( QLatin1Char('Q') )) {
+ } else if (interface.startsWith( QLatin1Char('Q') ) &&
+ interface.length() >= 2 && interface.at(1).isUpper()) {
// assume it's Qt
interface.prepend( QLatin1String("com.trolltech.Qt.") );
} else if (!QCoreApplication::instance() ||
@@ -173,9 +174,14 @@ QString qDBusGenerateMetaObjectXml(QString interface, const QMetaObject *mo, con
interface.prepend( QLatin1String("local.") );
} else {
interface.prepend(QLatin1Char('.')).prepend( QCoreApplication::instance()->applicationName() );
- QStringList domainName = QCoreApplication::instance()->organizationDomain().split(QLatin1Char('.'));
- foreach (const QString &part, domainName)
- interface.prepend(QLatin1Char('.')).prepend(part);
+ QStringList domainName =
+ QCoreApplication::instance()->organizationDomain().split(QLatin1Char('.'),
+ QString::SkipEmptyParts);
+ if (domainName.isEmpty())
+ interface.prepend("local.");
+ else
+ foreach (const QString &part, domainName)
+ interface.prepend(QLatin1Char('.')).prepend(part);
}
}
}
diff --git a/qt/src/qdbusxmlparser.cpp b/qt/src/qdbusxmlparser.cpp
index 0370cb2..359967b 100644
--- a/qt/src/qdbusxmlparser.cpp
+++ b/qt/src/qdbusxmlparser.cpp
@@ -47,8 +47,11 @@ parseAnnotations(const QDomElement& elem)
QString name = ann.attribute(QLatin1String("name")),
value = ann.attribute(QLatin1String("value"));
- if (name.isEmpty())
+ if (!QDBusUtil::isValidInterfaceName(name)) {
+ qWarning("Invalid D-BUS annotation '%s' found while parsing introspection",
+ qPrintable(name));
continue;
+ }
retval.insert(name, value);
}
@@ -74,8 +77,11 @@ parseArgs(const QDomElement& elem, const QLatin1String& direction, bool acceptEm
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))
+ if (!QDBusUtil::isValidSingleSignature(argData.type)) {
+ qWarning("Invalid D-BUS type signature '%s' found while parsing introspection",
+ qPrintable(argData.type));
continue;
+ }
retval << argData;
}
@@ -106,13 +112,18 @@ QDBusXmlParser::interfaces() const
if (m_node.isNull())
return retval;
- QDomNodeList interfaces = m_node.elementsByTagName(QLatin1String("interface"));
- for (int i = 0; i < interfaces.count(); ++i)
+ QDomNodeList interfaceList = m_node.elementsByTagName(QLatin1String("interface"));
+ for (int i = 0; i < interfaceList.count(); ++i)
{
- QDomElement iface = interfaces.item(i).toElement();
+ QDomElement iface = interfaceList.item(i).toElement();
QString ifaceName = iface.attribute(QLatin1String("name"));
- if (iface.isNull() || ifaceName.isEmpty())
+ if (iface.isNull())
continue; // for whatever reason
+ if (!QDBusUtil::isValidInterfaceName(ifaceName)) {
+ qWarning("Invalid D-BUS interface name '%s' found while parsing introspection",
+ qPrintable(ifaceName));
+ continue;
+ }
QDBusIntrospection::Interface *ifaceData = new QDBusIntrospection::Interface;
ifaceData->name = ifaceName;
@@ -131,8 +142,13 @@ QDBusXmlParser::interfaces() const
{
QDomElement method = list.item(j).toElement();
QString methodName = method.attribute(QLatin1String("name"));
- if (method.isNull() || methodName.isEmpty())
+ if (method.isNull())
continue;
+ if (!QDBusUtil::isValidMemberName(methodName)) {
+ qWarning("Invalid D-BUS member name '%s' found in interface '%s' while parsing introspection",
+ qPrintable(methodName), qPrintable(ifaceName));
+ continue;
+ }
QDBusIntrospection::Method methodData;
methodData.name = methodName;
@@ -152,8 +168,13 @@ QDBusXmlParser::interfaces() const
{
QDomElement signal = list.item(j).toElement();
QString signalName = signal.attribute(QLatin1String("name"));
- if (signal.isNull() || signalName.isEmpty())
+ if (signal.isNull())
+ continue;
+ if (!QDBusUtil::isValidMemberName(signalName)) {
+ qWarning("Invalid D-BUS member name '%s' found in interface '%s' while parsing introspection",
+ qPrintable(signalName), qPrintable(ifaceName));
continue;
+ }
QDBusIntrospection::Signal signalData;
signalData.name = signalName;
@@ -172,8 +193,13 @@ QDBusXmlParser::interfaces() const
{
QDomElement property = list.item(j).toElement();
QString propertyName = property.attribute(QLatin1String("name"));
- if (property.isNull() || propertyName.isEmpty())
+ if (property.isNull())
continue;
+ if (!QDBusUtil::isValidMemberName(propertyName)) {
+ qWarning("Invalid D-BUS member name '%s' found in interface '%s' while parsing introspection",
+ qPrintable(propertyName), qPrintable(ifaceName));
+ continue;
+ }
QDBusIntrospection::Property propertyData;
@@ -182,22 +208,27 @@ QDBusXmlParser::interfaces() const
propertyData.type = property.attribute(QLatin1String("type"));
propertyData.annotations = parseAnnotations(property);
- if (!QDBusUtil::isValidSingleSignature(propertyData.type))
+ if (!QDBusUtil::isValidSingleSignature(propertyData.type)) {
// cannot be!
+ qWarning("Invalid D-BUS type signature '%s' found in property '%s.%s' while parsing introspection",
+ qPrintable(propertyData.type), qPrintable(ifaceName),
+ qPrintable(propertyName));
continue;
+ }
QString access = property.attribute(QLatin1String("access"));
- if (access.isEmpty())
- // can't be empty either!
- continue;
- else if (access == QLatin1String("read"))
+ 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
+ else {
+ qWarning("Invalid D-BUS property access '%s' found in property '%s.%s' while parsing introspection",
+ qPrintable(access), qPrintable(ifaceName),
+ qPrintable(propertyName));
continue; // invalid one!
+ }
// add it
ifaceData->properties.insert(propertyName, propertyData);
@@ -231,18 +262,28 @@ QDBusXmlParser::object() const
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())
+ if (obj.isNull())
continue; // for whatever reason
+ if (!QDBusUtil::isValidObjectPath(m_path + QLatin1Char('/') + objName)) {
+ qWarning("Invalid D-BUS object path '%s/%s' found while parsing introspection",
+ qPrintable(m_path), qPrintable(objName));
+ continue;
+ }
objData->childObjects.append(objName);
}
- QDomNodeList interfaces = m_node.elementsByTagName(QLatin1String("interface"));
- for (int i = 0; i < interfaces.count(); ++i) {
- QDomElement iface = interfaces.item(i).toElement();
+ 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() || ifaceName.isEmpty())
+ if (iface.isNull())
+ continue;
+ if (!QDBusUtil::isValidInterfaceName(ifaceName)) {
+ qWarning("Invalid D-BUS interface name '%s' found while parsing introspection",
+ qPrintable(ifaceName));
continue;
+ }
objData->interfaces.append(ifaceName);
}
@@ -287,8 +328,8 @@ QDBusXmlParser::objectTree() const
if (!obj.firstChild().isNull()) {
// yes, introspect this object
QString xml;
- QTextStream ts(&xml);
- obj.save(ts,0);
+ QTextStream ts2(&xml);
+ obj.save(ts2,0);
// parse it
QString objAbsName = m_path;
diff --git a/qt/tools/Makefile.am b/qt/tools/Makefile.am
index a79aafd..4da3870 100644
--- a/qt/tools/Makefile.am
+++ b/qt/tools/Makefile.am
@@ -1,5 +1,5 @@
INCLUDES=-I$(top_srcdir)/qt $(DBUS_CLIENT_CFLAGS) $(DBUS_QT_CFLAGS) -DDBUS_COMPILATION
-bin_PROGRAMS = dbusidl2cpp dbuscpp2xml
+bin_PROGRAMS = dbusidl2cpp dbuscpp2xml dbus
dbusidl2cpp_SOURCES = dbusidl2cpp.cpp
dbusidl2cpp_LDFLAGS = -no-undefined
@@ -8,3 +8,6 @@ dbusidl2cpp_LDADD = $(DBUS_QT_LIBS) ../src/libdbus-qt4-1.la
dbuscpp2xml_SOURCES = dbuscpp2xml.cpp
dbuscpp2xml_LDFLAGS = -no-undefined
dbuscpp2xml_LDADD = $(DBUS_QT_LIBS) ../src/libdbus-qt4-1.la
+
+dbus_SOURCES = dbus.cpp
+dbus_LDADD = $(DBUS_QT_LIBS) ../src/libdbus-qt4-1.la
diff --git a/qt/examples/dbus.cpp b/qt/tools/dbus.cpp
index 32fcc3f..b2556ef 100644
--- a/qt/examples/dbus.cpp
+++ b/qt/tools/dbus.cpp
@@ -20,6 +20,7 @@
*/
#include <stdio.h>
+#include <stdlib.h>
#include <dbus/qdbus.h>
#include <QtCore/QCoreApplication>
@@ -136,7 +137,13 @@ void listAllInterfaces(const QString &service, const QString &path)
QDomElement child = node.firstChildElement();
while (!child.isNull()) {
if (child.tagName() == QLatin1String("interface")) {
- listInterface(service, path, child.attribute("name"));
+ QString ifaceName = child.attribute("name");
+ if (QDBusUtil::isValidInterfaceName(ifaceName))
+ listInterface(service, path, ifaceName);
+ else {
+ qWarning("Invalid D-BUS interface name '%s' found while parsing introspection",
+ qPrintable(ifaceName));
+ }
}
child = child.nextSiblingElement();
}
@@ -209,10 +216,15 @@ void placeCall(const QString &service, const QString &path, const QString &inter
else
p = QString::fromLocal8Bit(argv[0]);
- if (id < int(QVariant::UserType))
+ if (id < int(QVariant::UserType)) {
// avoid calling it for QVariant
p.convert( QVariant::Type(id) );
- else if (types.at(i) == "QVariant") {
+ if (p.type() == QVariant::Invalid) {
+ fprintf(stderr, "Could not convert '%s' to type '%s'.\n",
+ argv[0], types.at(i).constData());
+ exit(1);
+ }
+ } else if (types.at(i) == "QVariant") {
QVariant tmp(id, p.constData());
p = tmp;
}
@@ -249,6 +261,58 @@ void placeCall(const QString &service, const QString &path, const QString &inter
exit(0);
}
+bool splitInterfaceAndName(const QString &interfaceAndName, const char *type,
+ QString &interface, QString &member)
+{
+ interface = interfaceAndName;
+ int pos = interface.lastIndexOf(QLatin1Char('.'));
+ if (pos != -1) {
+ member = interface.mid(pos + 1);
+ interface.truncate(pos);
+ }
+
+ if (!QDBusUtil::isValidInterfaceName(interface)) {
+ fprintf(stderr, "Interface '%s' is not a valid interface name.\n", qPrintable(interface));
+ return false;
+ } else if (!QDBusUtil::isValidMemberName(member)) {
+ fprintf(stderr, "%s name '%s' is not a valid member name.\n", type, qPrintable(member));
+ return false;
+ }
+ return true;
+}
+
+void getProperty(const QString &service, const QString &path, const QString &interfaceAndName)
+{
+ QString property;
+ QString interface;
+ if (!splitInterfaceAndName(interfaceAndName, "Property", interface, property))
+ exit(1);
+
+ QDBusInterfacePtr iface(*connection, service, path, interface);
+ QVariant reply = iface->property(property.toLatin1());
+ if (reply.isNull()) {
+ QDBusError error = iface->lastError();
+ fprintf(stderr, "Could not get property '%s' on interface '%s': %s (%s)\n",
+ qPrintable(property), qPrintable(interface), qPrintable(error.name()),
+ qPrintable(error.message()));
+ exit(1);
+ }
+
+ printf("%s\n", qPrintable(reply.toString()));
+}
+
+void setProperty(const QString &service, const QString &path, const QString &interfaceAndName,
+ const QString &valueStr)
+{
+ QString property;
+ QString interface;
+ if (!splitInterfaceAndName(interfaceAndName, "Property", interface, property))
+ exit(1);
+
+ QDBusInterfacePtr iface(*connection, service, path, interface);
+ iface->setProperty(property.toLatin1(), valueStr);
+}
+
int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
@@ -310,7 +374,24 @@ int main(int argc, char **argv)
member = interface.mid(pos + 1);
interface.truncate(pos);
}
+ if (!interface.isEmpty() && !QDBusUtil::isValidInterfaceName(interface)) {
+ fprintf(stderr, "Interface '%s' is not a valid interface name.\n", qPrintable(interface));
+ exit(1);
+ }
+ if (!QDBusUtil::isValidMemberName(member)) {
+ fprintf(stderr, "Method name '%s' is not a valid member name.\n", qPrintable(member));
+ exit(1);
+ }
+ if (interface.isEmpty()) {
+ if (member.toLower() == QLatin1String("get") && argc == 5) {
+ getProperty(service, path, QLatin1String(argv[4]));
+ return 0;
+ } else if (member.toLower() == QLatin1String("set") && argc == 6) {
+ setProperty(service, path, QLatin1String(argv[4]), QLatin1String(argv[5]));
+ return 0;
+ }
+ }
placeCall(service, path, interface, member, argc - 4, argv + 4);
}
diff --git a/qt/tools/dbuscpp2xml.cpp b/qt/tools/dbuscpp2xml.cpp
index dd08b5f..42d7831 100644
--- a/qt/tools/dbuscpp2xml.cpp
+++ b/qt/tools/dbuscpp2xml.cpp
@@ -29,6 +29,7 @@
#include <QRegExp>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
@@ -76,7 +77,7 @@ class MocParser
QIODevice *input;
const char *filename;
- int line;
+ int lineNumber;
public:
~MocParser();
void parse(const char *filename, QIODevice *input, int lineNumber = 0);
@@ -86,13 +87,13 @@ public:
void MocParser::parseError()
{
- fprintf(stderr, PROGRAMNAME ": error parsing input file '%s' line %d \n", filename, line);
+ fprintf(stderr, PROGRAMNAME ": error parsing input file '%s' line %d \n", filename, lineNumber);
exit(1);
}
QByteArray MocParser::readLine()
{
- ++line;
+ ++lineNumber;
return input->readLine();
}
@@ -100,15 +101,15 @@ void MocParser::loadIntData(uint *&data)
{
data = 0; // initialise
QVarLengthArray<uint> array;
- QRegExp rx("(\\d+|0x[0-9abcdef]+)", Qt::CaseInsensitive);
+ QRegExp rx(QLatin1String("(\\d+|0x[0-9abcdef]+)"), Qt::CaseInsensitive);
while (!input->atEnd()) {
QString line = QLatin1String(readLine());
- int pos = line.indexOf("//");
+ int pos = line.indexOf(QLatin1String("//"));
if (pos != -1)
line.truncate(pos); // drop comments
- if (line == "};\n") {
+ if (line == QLatin1String("};\n")) {
// end of data
data = new uint[array.count()];
memcpy(data, array.data(), array.count() * sizeof(*data));
@@ -118,7 +119,7 @@ void MocParser::loadIntData(uint *&data)
pos = 0;
while ((pos = rx.indexIn(line, pos)) != -1) {
QString num = rx.cap(1);
- if (num.startsWith("0x"))
+ if (num.startsWith(QLatin1String("0x")))
array.append(num.mid(2).toUInt(0, 16));
else
array.append(num.toUInt());
@@ -205,7 +206,7 @@ void MocParser::loadStringData(char *&stringdata)
}
} else {
// octal
- QRegExp octal("([0-7]+)");
+ QRegExp octal(QLatin1String("([0-7]+)"));
if (octal.indexIn(QLatin1String(line), start) == -1)
parseError();
array.append(char(octal.cap(1).toInt(0, 8)));
@@ -218,11 +219,11 @@ void MocParser::loadStringData(char *&stringdata)
parseError();
}
-void MocParser::parse(const char *fname, QIODevice *io, int lineNumber)
+void MocParser::parse(const char *fname, QIODevice *io, int lineNum)
{
filename = fname;
input = io;
- line = lineNumber;
+ lineNumber = lineNum;
while (!input->atEnd()) {
QByteArray line = readLine();
@@ -360,7 +361,7 @@ int main(int argc, char **argv)
else {
// run moc on this file
QProcess proc;
- proc.start("moc", QStringList() << QFile::encodeName(argv[i]));
+ proc.start(QLatin1String("moc"), QStringList() << QFile::decodeName(argv[i]));
if (!proc.waitForStarted()) {
fprintf(stderr, PROGRAMNAME ": could not execute moc! Aborting.\n");
diff --git a/qt/tools/dbusidl2cpp.cpp b/qt/tools/dbusidl2cpp.cpp
index 091685b..216c7ce 100644
--- a/qt/tools/dbusidl2cpp.cpp
+++ b/qt/tools/dbusidl2cpp.cpp
@@ -37,7 +37,7 @@
#include "../src/qdbusintrospection_p.h"
#define PROGRAMNAME "dbusidl2cpp"
-#define PROGRAMVERSION "0.4"
+#define PROGRAMVERSION "0.5"
#define PROGRAMCOPYRIGHT "Copyright (C) 2006 Trolltech AS. All rights reserved."
#define ANNOTATION_NO_WAIT "org.freedesktop.DBus.Method.NoReply"
@@ -68,7 +68,9 @@ static const char help[] =
" -V Show the program version and quit.\n"
"\n"
"If the file name given to the options -a and -p does not end in .cpp or .h, the\n"
- "program will automatically append the suffixes and produce both files.\n";
+ "program will automatically append the suffixes and produce both files.\n"
+ "You can also use a colon (:) to separate the header name from the source file\n"
+ "name, as in '-a filename_p.h:filename.cpp'.";
static const char includeList[] =
"#include <QtCore/QByteArray>\n"
@@ -154,7 +156,7 @@ static void parseCmdLine(int argc, char **argv)
static QDBusIntrospection::Interfaces readInput()
{
QFile input(QFile::decodeName(inputFile));
- if (inputFile && QLatin1String("-") != inputFile)
+ if (inputFile && qstrcmp(inputFile, "-") != 0)
input.open(QIODevice::ReadOnly);
else
input.open(stdin, QIODevice::ReadOnly);
@@ -190,9 +192,11 @@ static QString header(const char *name)
if (!name || (name[0] == '-' && name[1] == '\0'))
return QString();
- QString retval = QFile::decodeName(name);
- if (!retval.endsWith(".h") && !retval.endsWith(".cpp") && !retval.endsWith(".cc"))
- retval.append(".h");
+ QStringList parts = QFile::decodeName(name).split(QLatin1Char(':'));
+ QString retval = parts.first();
+ if (!retval.endsWith(QLatin1String(".h")) && !retval.endsWith(QLatin1String(".cpp")) &&
+ !retval.endsWith(QLatin1String(".cc")))
+ retval.append(QLatin1String(".h"));
return retval;
}
@@ -203,9 +207,11 @@ static QString cpp(const char *name)
if (!name || (name[0] == '-' && name[1] == '\0'))
return QString();
- QString retval = QFile::decodeName(name);
- if (!retval.endsWith(".h") && !retval.endsWith(".cpp") && !retval.endsWith(".cc"))
- retval.append(".cpp");
+ QStringList parts = QFile::decodeName(name).split(QLatin1Char(':'));
+ QString retval = parts.last();
+ if (!retval.endsWith(QLatin1String(".h")) && !retval.endsWith(QLatin1String(".cpp")) &&
+ !retval.endsWith(QLatin1String(".cc")))
+ retval.append(QLatin1String(".cpp"));
return retval;
}
@@ -235,7 +241,7 @@ static QString classNameForInterface(const QString &interface, ClassType classTy
if (globalClassName)
return QLatin1String(globalClassName);
- QStringList parts = interface.split('.');
+ QStringList parts = interface.split(QLatin1Char('.'));
QString retval;
if (classType == Proxy)
@@ -249,9 +255,9 @@ static QString classNameForInterface(const QString &interface, ClassType classTy
}
if (classType == Proxy)
- retval += "Interface";
+ retval += QLatin1String("Interface");
else
- retval += "Adaptor";
+ retval += QLatin1String("Adaptor");
return retval;
}
@@ -283,7 +289,7 @@ static QString constRefArg(const QByteArray &arg)
if (!arg.startsWith('Q'))
return QLatin1String(arg + ' ');
else
- return QString("const %1 &").arg( QLatin1String(arg) );
+ return QString( QLatin1String("const %1 &") ).arg( QLatin1String(arg) );
}
static QStringList makeArgNames(const QDBusIntrospection::Arguments &inputArgs,
@@ -295,18 +301,18 @@ static QStringList makeArgNames(const QDBusIntrospection::Arguments &inputArgs,
const QDBusIntrospection::Argument &arg = inputArgs.at(i);
QString name = arg.name;
if (name.isEmpty())
- name = QString("in%1").arg(i);
+ name = QString( QLatin1String("in%1") ).arg(i);
while (retval.contains(name))
- name += "_";
+ name += QLatin1String("_");
retval << name;
}
for (int i = 0; i < outputArgs.count(); ++i) {
const QDBusIntrospection::Argument &arg = outputArgs.at(i);
QString name = arg.name;
if (name.isEmpty())
- name = QString("out%1").arg(i);
+ name = QString( QLatin1String("out%1") ).arg(i);
while (retval.contains(name))
- name += "_";
+ name += QLatin1String("_");
retval << name;
}
return retval;
@@ -346,7 +352,7 @@ static void writeArgList(QTextStream &ts, const QStringList &argNames,
static QString propertyGetter(const QDBusIntrospection::Property &property)
{
- QString getter = property.annotations.value("com.trolltech.QtDBus.propertyGetter");
+ QString getter = property.annotations.value(QLatin1String("com.trolltech.QtDBus.propertyGetter"));
if (getter.isEmpty()) {
getter = property.name;
getter[0] = getter[0].toLower();
@@ -356,9 +362,9 @@ static QString propertyGetter(const QDBusIntrospection::Property &property)
static QString propertySetter(const QDBusIntrospection::Property &property)
{
- QString setter = property.annotations.value("com.trolltech.QtDBus.propertySetter");
+ QString setter = property.annotations.value(QLatin1String("com.trolltech.QtDBus.propertySetter"));
if (setter.isEmpty()) {
- setter = "set" + property.name;
+ setter = QLatin1String("set") + property.name;
setter[3] = setter[3].toUpper();
}
return setter;
@@ -369,21 +375,21 @@ static QString stringify(const QString &data)
QString retval;
int i;
for (i = 0; i < data.length(); ++i) {
- retval += '\"';
- for ( ; i < data.length() && data[i] != QChar('\n'); ++i)
- if (data[i] == '\"')
- retval += "\\\"";
+ retval += QLatin1Char('\"');
+ for ( ; i < data.length() && data[i] != QLatin1Char('\n'); ++i)
+ if (data[i] == QLatin1Char('\"'))
+ retval += QLatin1String("\\\"");
else
retval += data[i];
- retval += "\\n\"\n";
+ retval += QLatin1String("\\n\"\n");
}
return retval;
}
-static void writeProxy(const char *proxyFile, const QDBusIntrospection::Interfaces &interfaces)
+static void writeProxy(const char *filename, const QDBusIntrospection::Interfaces &interfaces)
{
// open the file
- QString headerName = header(proxyFile);
+ QString headerName = header(filename);
QFile file(headerName);
if (!headerName.isEmpty())
file.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text);
@@ -391,7 +397,7 @@ static void writeProxy(const char *proxyFile, const QDBusIntrospection::Interfac
file.open(stdout, QIODevice::WriteOnly | QIODevice::Text);
QTextStream hs(&file);
- QString cppName = cpp(proxyFile);
+ QString cppName = cpp(filename);
QByteArray cppData;
QTextStream cs(&cppData);
@@ -401,14 +407,14 @@ static void writeProxy(const char *proxyFile, const QDBusIntrospection::Interfac
// include guards:
QString includeGuard;
if (!headerName.isEmpty()) {
- includeGuard = headerName.toUpper().replace(QChar('.'), QChar('_'));
- int pos = includeGuard.lastIndexOf('/');
+ includeGuard = headerName.toUpper().replace(QLatin1Char('.'), QLatin1Char('_'));
+ int pos = includeGuard.lastIndexOf(QLatin1Char('/'));
if (pos != -1)
includeGuard = includeGuard.mid(pos + 1);
} else {
- includeGuard = QString("QDBUSIDL2CPP_PROXY");
+ includeGuard = QLatin1String("QDBUSIDL2CPP_PROXY");
}
- includeGuard = QString("%1_%2%3")
+ includeGuard = QString(QLatin1String("%1_%2%3"))
.arg(includeGuard)
.arg(getpid())
.arg(QDateTime::currentDateTime().toTime_t());
@@ -512,7 +518,8 @@ static void writeProxy(const char *proxyFile, const QDBusIntrospection::Interfac
// methods:
hs << "public Q_SLOTS: // METHODS" << endl;
foreach (const QDBusIntrospection::Method &method, interface->methods) {
- bool isAsync = method.annotations.value(ANNOTATION_NO_WAIT) == "true";
+ bool isAsync =
+ method.annotations.value(QLatin1String(ANNOTATION_NO_WAIT)) == QLatin1String("true");
if (isAsync && !method.outputArgs.isEmpty()) {
fprintf(stderr, "warning: method %s in interface %s is marked 'async' but has output arguments.\n",
qPrintable(method.name), qPrintable(interface->name));
@@ -521,7 +528,7 @@ static void writeProxy(const char *proxyFile, const QDBusIntrospection::Interfac
hs << " inline ";
- if (method.annotations.value("org.freedesktop.DBus.Deprecated") == "true")
+ if (method.annotations.value(QLatin1String("org.freedesktop.DBus.Deprecated")) == QLatin1String("true"))
hs << "Q_DECL_DEPRECATED ";
if (isAsync)
@@ -548,7 +555,7 @@ static void writeProxy(const char *proxyFile, const QDBusIntrospection::Interfac
hs << " call(NoWaitForReply, QLatin1String(\"";
// rebuild the method input signature:
- QString signature = QChar('.');
+ QString signature = QLatin1String(".");
foreach (const QDBusIntrospection::Argument &arg, method.inputArgs)
signature += arg.type;
if (signature.length() == 1)
@@ -583,7 +590,8 @@ static void writeProxy(const char *proxyFile, const QDBusIntrospection::Interfac
hs << "Q_SIGNALS: // SIGNALS" << endl;
foreach (const QDBusIntrospection::Signal &signal, interface->signals_) {
hs << " ";
- if (signal.annotations.value("org.freedesktop.DBus.Deprecated") == "true")
+ if (signal.annotations.value(QLatin1String("org.freedesktop.DBus.Deprecated")) ==
+ QLatin1String("true"))
hs << "Q_DECL_DEPRECATED ";
hs << "void " << signal.name << "(";
@@ -607,7 +615,7 @@ static void writeProxy(const char *proxyFile, const QDBusIntrospection::Interfac
QStringList current;
QString name;
if (it != interfaces.constEnd()) {
- current = it->constData()->name.split('.');
+ current = it->constData()->name.split(QLatin1Char('.'));
name = current.takeLast();
}
@@ -618,15 +626,15 @@ static void writeProxy(const char *proxyFile, const QDBusIntrospection::Interfac
// i parts matched
// close last.count() - i namespaces:
for (int j = i; j < last.count(); ++j)
- hs << QString((last.count() - j - 1 + i) * 2, ' ') << "}" << endl;
+ hs << QString((last.count() - j - 1 + i) * 2, QLatin1Char(' ')) << "}" << endl;
// open current.count() - i namespaces
for (int j = i; j < current.count(); ++j)
- hs << QString(j * 2, ' ') << "namespace " << current.at(j) << " {" << endl;
+ hs << QString(j * 2, QLatin1Char(' ')) << "namespace " << current.at(j) << " {" << endl;
// add this class:
if (!name.isEmpty()) {
- hs << QString(current.count() * 2, ' ')
+ hs << QString(current.count() * 2, QLatin1Char(' '))
<< "typedef ::" << classNameForInterface(it->constData()->name, Proxy)
<< " " << name << ";" << endl;
}
@@ -643,7 +651,7 @@ static void writeProxy(const char *proxyFile, const QDBusIntrospection::Interfac
if (includeMocs)
cs << endl
- << "#include \"" << proxyFile << ".moc\"" << endl;
+ << "#include \"" << filename << ".moc\"" << endl;
cs.flush();
hs.flush();
@@ -657,10 +665,10 @@ static void writeProxy(const char *proxyFile, const QDBusIntrospection::Interfac
}
}
-static void writeAdaptor(const char *adaptorFile, const QDBusIntrospection::Interfaces &interfaces)
+static void writeAdaptor(const char *filename, const QDBusIntrospection::Interfaces &interfaces)
{
// open the file
- QString headerName = header(adaptorFile);
+ QString headerName = header(filename);
QFile file(headerName);
if (!headerName.isEmpty())
file.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text);
@@ -668,7 +676,7 @@ static void writeAdaptor(const char *adaptorFile, const QDBusIntrospection::Inte
file.open(stdout, QIODevice::WriteOnly | QIODevice::Text);
QTextStream hs(&file);
- QString cppName = cpp(adaptorFile);
+ QString cppName = cpp(filename);
QByteArray cppData;
QTextStream cs(&cppData);
@@ -678,14 +686,14 @@ static void writeAdaptor(const char *adaptorFile, const QDBusIntrospection::Inte
// include guards:
QString includeGuard;
if (!headerName.isEmpty()) {
- includeGuard = headerName.toUpper().replace(QChar('.'), QChar('_'));
- int pos = includeGuard.lastIndexOf('/');
+ includeGuard = headerName.toUpper().replace(QLatin1Char('.'), QLatin1Char('_'));
+ int pos = includeGuard.lastIndexOf(QLatin1Char('/'));
if (pos != -1)
includeGuard = includeGuard.mid(pos + 1);
} else {
- includeGuard = QString("QDBUSIDL2CPP_ADAPTOR");
+ includeGuard = QLatin1String("QDBUSIDL2CPP_ADAPTOR");
}
- includeGuard = QString("%1_%2%3")
+ includeGuard = QString(QLatin1String("%1_%2%3"))
.arg(includeGuard)
.arg(getpid())
.arg(QDateTime::currentDateTime().toTime_t());
@@ -794,7 +802,8 @@ static void writeAdaptor(const char *adaptorFile, const QDBusIntrospection::Inte
hs << "public Q_SLOTS: // METHODS" << endl;
foreach (const QDBusIntrospection::Method &method, interface->methods) {
- bool isAsync = method.annotations.value(ANNOTATION_NO_WAIT) == "true";
+ bool isAsync =
+ method.annotations.value(QLatin1String(ANNOTATION_NO_WAIT)) == QLatin1String("true");
if (isAsync && !method.outputArgs.isEmpty()) {
fprintf(stderr, "warning: method %s in interface %s is marked 'async' but has output arguments.\n",
qPrintable(method.name), qPrintable(interface->name));
@@ -802,7 +811,8 @@ static void writeAdaptor(const char *adaptorFile, const QDBusIntrospection::Inte
}
hs << " ";
- if (method.annotations.value("org.freedesktop.DBus.Deprecated") == "true")
+ if (method.annotations.value(QLatin1String("org.freedesktop.DBus.Deprecated")) ==
+ QLatin1String("true"))
hs << "Q_DECL_DEPRECATED ";
QByteArray returnType;
@@ -888,7 +898,8 @@ static void writeAdaptor(const char *adaptorFile, const QDBusIntrospection::Inte
hs << "Q_SIGNALS: // SIGNALS" << endl;
foreach (const QDBusIntrospection::Signal &signal, interface->signals_) {
hs << " ";
- if (signal.annotations.value("org.freedesktop.DBus.Deprecated") == "true")
+ if (signal.annotations.value(QLatin1String("org.freedesktop.DBus.Deprecated")) ==
+ QLatin1String("true"))
hs << "Q_DECL_DEPRECATED ";
hs << "void " << signal.name << "(";
@@ -909,7 +920,7 @@ static void writeAdaptor(const char *adaptorFile, const QDBusIntrospection::Inte
if (includeMocs)
cs << endl
- << "#include \"" << adaptorFile << ".moc\"" << endl;
+ << "#include \"" << filename << ".moc\"" << endl;
cs.flush();
hs.flush();
@@ -930,7 +941,8 @@ int main(int argc, char **argv)
QDBusIntrospection::Interfaces interfaces = readInput();
cleanInterfaces(interfaces);
- writeProxy(proxyFile, interfaces);
+ if (proxyFile || (!proxyFile && !adaptorFile))
+ writeProxy(proxyFile, interfaces);
if (adaptorFile)
writeAdaptor(adaptorFile, interfaces);