]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
* qt/dbus: Add directory. I had forgotten to add this
authorThiago Macieira <thiago@kde.org>
Mon, 5 Jun 2006 18:13:07 +0000 (18:13 +0000)
committerThiago Macieira <thiago@kde.org>
Mon, 5 Jun 2006 18:13:07 +0000 (18:13 +0000)
yesterday after the move...

* qt/examples/Makefile.am:
* qt/examples/dbus.cpp: Moved to qt/tools/dbus.cpp.

* qt/tools/Makefile.am:
* qt/tools/dbus.cpp: Moved from qt/examples/dbus.cpp.
Added feature to get and set properties.
Added validation of service, object path and interface names.

* qt/tools/dbusidl2cpp.cpp: Two new features:
1) Allow specifying both the header and the source file names,
by separating them with a colon.
2) Don't write an interface output if the -p switch wasn't
given, but the -a was.

* qt/src/*: Fix usage of Iterators and ConstIterators.
Fix shadowing of variables by other variables (-Wshadow).
Fix keyword-cleanliness in headers.
Fix ASCII-cast (QLatin1String, QLatin1Char).
Fix validation of member names.
Add extra checking of introspection data during XML parsing.
Various bug fixes.

50 files changed:
ChangeLog
qt/dbus/qdbus.h [new file with mode: 0644]
qt/dbus/qdbusabstractadaptor.h [new file with mode: 0644]
qt/dbus/qdbusabstractadaptor_p.h [new file with mode: 0644]
qt/dbus/qdbusabstractinterface.h [new file with mode: 0644]
qt/dbus/qdbusabstractinterface_p.h [new file with mode: 0644]
qt/dbus/qdbusbus.h [new file with mode: 0644]
qt/dbus/qdbusconnection.h [new file with mode: 0644]
qt/dbus/qdbusconnection_p.h [new file with mode: 0644]
qt/dbus/qdbuserror.h [new file with mode: 0644]
qt/dbus/qdbusinterface.h [new file with mode: 0644]
qt/dbus/qdbusinterface_p.h [new file with mode: 0644]
qt/dbus/qdbusintrospection_p.h [new file with mode: 0644]
qt/dbus/qdbusmacros.h [new file with mode: 0644]
qt/dbus/qdbusmarshall_p.h [new file with mode: 0644]
qt/dbus/qdbusmessage.h [new file with mode: 0644]
qt/dbus/qdbusmessage_p.h [new file with mode: 0644]
qt/dbus/qdbusmetaobject_p.h [new file with mode: 0644]
qt/dbus/qdbusreply.h [new file with mode: 0644]
qt/dbus/qdbusserver.h [new file with mode: 0644]
qt/dbus/qdbustype_p.h [new file with mode: 0644]
qt/dbus/qdbustypehelper_p.h [new file with mode: 0644]
qt/dbus/qdbusutil.h [new file with mode: 0644]
qt/dbus/qdbusxmlparser_p.h [new file with mode: 0644]
qt/examples/Makefile.am
qt/examples/complexpong.cpp
qt/examples/pong.cpp
qt/src/qdbusabstractadaptor.cpp
qt/src/qdbusabstractinterface.cpp
qt/src/qdbusbus.cpp
qt/src/qdbusbus.h
qt/src/qdbusconnection.cpp
qt/src/qdbusconnection.h
qt/src/qdbuserror.cpp
qt/src/qdbuserror.h
qt/src/qdbusintegrator.cpp
qt/src/qdbusinterface.cpp
qt/src/qdbusinternalfilters.cpp
qt/src/qdbusmessage.cpp
qt/src/qdbusmessage.h
qt/src/qdbusmetaobject.cpp
qt/src/qdbusreply.h
qt/src/qdbusserver.cpp
qt/src/qdbusutil.cpp
qt/src/qdbusxmlgenerator.cpp
qt/src/qdbusxmlparser.cpp
qt/tools/Makefile.am
qt/tools/dbus.cpp [moved from qt/examples/dbus.cpp with 75% similarity]
qt/tools/dbuscpp2xml.cpp
qt/tools/dbusidl2cpp.cpp

index 12b6fad35b4083438538762750ff831097eb5b84..5234c7db583bc94502d8ffe202120ef4a003679d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,30 @@
+2006-06-05  Thiago Macieira <thiago.macieira@trolltech.com>
+
+       * qt/dbus: Add directory. I had forgotten to add this
+       yesterday after the move...
+
+       * qt/examples/Makefile.am:
+       * qt/examples/dbus.cpp: Moved to qt/tools/dbus.cpp.
+
+       * qt/tools/Makefile.am:
+       * qt/tools/dbus.cpp: Moved from qt/examples/dbus.cpp.
+       Added feature to get and set properties.
+       Added validation of service, object path and interface names.
+
+       * qt/tools/dbusidl2cpp.cpp: Two new features:
+       1) Allow specifying both the header and the source file names,
+       by separating them with a colon.
+       2) Don't write an interface output if the -p switch wasn't
+       given, but the -a was.
+
+       * qt/src/*: Fix usage of Iterators and ConstIterators.
+       Fix shadowing of variables by other variables (-Wshadow).
+       Fix keyword-cleanliness in headers.
+       Fix ASCII-cast (QLatin1String, QLatin1Char).
+       Fix validation of member names.
+       Add extra checking of introspection data during XML parsing.
+       Various bug fixes.
+
 2006-06-04  Thiago Macieira <thiago.macieira@trolltech.com>
 
        * dbus/Makefile.am:
diff --git a/qt/dbus/qdbus.h b/qt/dbus/qdbus.h
new file mode 100644 (file)
index 0000000..9fbc27a
--- /dev/null
@@ -0,0 +1 @@
+#include "../src/qdbus.h"
diff --git a/qt/dbus/qdbusabstractadaptor.h b/qt/dbus/qdbusabstractadaptor.h
new file mode 100644 (file)
index 0000000..94cc3a2
--- /dev/null
@@ -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 (file)
index 0000000..d55bef3
--- /dev/null
@@ -0,0 +1 @@
+#include "../src/qdbusabstractadaptor_p.h"
diff --git a/qt/dbus/qdbusabstractinterface.h b/qt/dbus/qdbusabstractinterface.h
new file mode 100644 (file)
index 0000000..e7ab181
--- /dev/null
@@ -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 (file)
index 0000000..5f6e7d5
--- /dev/null
@@ -0,0 +1 @@
+#include "../src/qdbusabstractinterface_p.h"
diff --git a/qt/dbus/qdbusbus.h b/qt/dbus/qdbusbus.h
new file mode 100644 (file)
index 0000000..eb849ac
--- /dev/null
@@ -0,0 +1 @@
+#include "../src/qdbusbus.h"
diff --git a/qt/dbus/qdbusconnection.h b/qt/dbus/qdbusconnection.h
new file mode 100644 (file)
index 0000000..99ac323
--- /dev/null
@@ -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 (file)
index 0000000..aaabb23
--- /dev/null
@@ -0,0 +1 @@
+#include "../src/qdbusconnection_p.h"
diff --git a/qt/dbus/qdbuserror.h b/qt/dbus/qdbuserror.h
new file mode 100644 (file)
index 0000000..680395a
--- /dev/null
@@ -0,0 +1 @@
+#include "../src/qdbuserror.h"
diff --git a/qt/dbus/qdbusinterface.h b/qt/dbus/qdbusinterface.h
new file mode 100644 (file)
index 0000000..c7024c8
--- /dev/null
@@ -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 (file)
index 0000000..9538448
--- /dev/null
@@ -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 (file)
index 0000000..210ed1e
--- /dev/null
@@ -0,0 +1 @@
+#include "../src/qdbusintrospection_p.h"
diff --git a/qt/dbus/qdbusmacros.h b/qt/dbus/qdbusmacros.h
new file mode 100644 (file)
index 0000000..dcd725e
--- /dev/null
@@ -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 (file)
index 0000000..1e91185
--- /dev/null
@@ -0,0 +1 @@
+#include "../src/qdbusmarshall_p.h"
diff --git a/qt/dbus/qdbusmessage.h b/qt/dbus/qdbusmessage.h
new file mode 100644 (file)
index 0000000..e993c1f
--- /dev/null
@@ -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 (file)
index 0000000..2b94201
--- /dev/null
@@ -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 (file)
index 0000000..37a6e30
--- /dev/null
@@ -0,0 +1 @@
+#include "../src/qdbusmetaobject_p.h"
diff --git a/qt/dbus/qdbusreply.h b/qt/dbus/qdbusreply.h
new file mode 100644 (file)
index 0000000..8c87a71
--- /dev/null
@@ -0,0 +1 @@
+#include "../src/qdbusreply.h"
diff --git a/qt/dbus/qdbusserver.h b/qt/dbus/qdbusserver.h
new file mode 100644 (file)
index 0000000..a8ca4ed
--- /dev/null
@@ -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 (file)
index 0000000..1f94601
--- /dev/null
@@ -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 (file)
index 0000000..1e3c342
--- /dev/null
@@ -0,0 +1 @@
+#include "../src/qdbustypehelper_p.h"
diff --git a/qt/dbus/qdbusutil.h b/qt/dbus/qdbusutil.h
new file mode 100644 (file)
index 0000000..1b9dbd0
--- /dev/null
@@ -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 (file)
index 0000000..f3e1100
--- /dev/null
@@ -0,0 +1 @@
+#include "../src/qdbusxmlparser_p.h"
index 5d1e0542f09877cc95dbc982085f7840555f5244..ab569448888169fb707281dd22fe5364f8b69ec7 100644 (file)
@@ -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
index 1d9c9756226b29a67a7c18dedfaed1c8fa27be80..ff767407d80542ef905199490c78e60b7c8c149e 100644 (file)
@@ -20,6 +20,7 @@
  */
 
 #include <stdio.h>
+#include <stdlib.h>
 
 #include <dbus/qdbus.h>
 #include <QtCore/QCoreApplication>
index 3917bb5839741f2af4ab32fce5218feb1ae7f08b..b85f1f0cdf59ab538d4860efcbb4a5e1c228dd30 100644 (file)
@@ -20,6 +20,7 @@
  */
 
 #include <stdio.h>
+#include <stdlib.h>
 
 #include <dbus/qdbus.h>
 #include <QtCore/QCoreApplication>
index b7c41888962e0e9ced999b7ed14bf754ae0060c0..4592b29a19a5f3c62724c7e36f9cd8dc5e746ec6 100644 (file)
@@ -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;
index 2a6bcf042ff7c5bf4433107e5a2a29538a1e6895..ffe5d67e80744162dde13c89a124a22670441469 100644 (file)
@@ -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)
index 02c231eb82797f2c728149d8f613b7827fe5ad0a..f46966b47aa5978a91fbfe63045448ddcd0dbec6 100644 (file)
@@ -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.
index 226068523019f6670382816987e6116052cbd734..1f69579896407f21b67530fe201a33483abfa823 100644 (file)
@@ -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);
index 6cd733cb9162afcfc61919fa0be1b6c5f1a36155..7049857d641ace0b85dd145f32a8fb3cf12663d9 100644 (file)
@@ -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);
 }
index c1c420a6d85ed74fd7e9c270f8a77bef1d072c24..61a3439eb729e07115b9a2c743d745f43a8f33fe 100644 (file)
@@ -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;
 }
 
index d5cd6758cd485fc892e20bddb85806c9c5f56d4f..ee6ce12c38fab193e3babfaddc588941dec890a6 100644 (file)
@@ -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             \{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              \{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            \{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             \{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() << ")";
index 71c636df90b03c38095745bb5af661c9cc46246a..e7aacdb010e51286ada828a1ee5d0940c474ee75 100644 (file)
@@ -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
 
index 07921cf97da386ea0d13684eeb093acc0ff96a29..de012c199fc1c3842a531b21c063dc70fa87795e 100644 (file)
@@ -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"));
         }
index 6367654d71bb470fe26f75029523a337289bacd6..720970773bdd4218cb8ea5d92a39f1965d0808a0 100644 (file)
@@ -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))
 {
 }
 
index 8886d3bfefac1979e4513020f719699d7a1bd17b..ed2107443adf74adcecc473891760ebe6ae28a7b 100644 (file)
@@ -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);
     }
 
index d0a0f1e59c48302a366a10946df7f718551ea9db..ec24100e18d4b6043cf4a14ede1137031c61c785 100644 (file)
@@ -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)
index f8feeae4f9a9470ca5d95bb866c6424f72e930bf..a36d3983dbd2a273136776036cb9aec3873d882a 100644 (file)
@@ -91,7 +91,7 @@ private:
     QDBusMessagePrivate *d_ptr;
 };
 
-#ifndef QT_NO_DEBUG
+#ifndef QT_NO_DEBUG_STREAM
 QDebug operator<<(QDebug, const QDBusMessage &);
 #endif
 
index a923d79ab168a3c7f834863cf3a6435d70084ef7..60675d5da1ea11fa1cd7f18e246df6d674c268dd 100644 (file)
@@ -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;
index 0b5c12d93d56e3c3e42d376aa7bc78ee5ca0d92d..2b69cbb5b6ff86aeb84771a09eba9b838fc1da3a 100644 (file)
@@ -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)
     {
     }    
 
index b3b9835e2a7053d887f43b44488c741aa7eb29be..4f5b510549f4b27b125785451234abd07a8220c1 100644 (file)
@@ -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);
 
index 872434c59139bec9a01a5a6e257265308cd5bd36..22ce3a81c687febf7f372f1783dde875f7c2e390 100644 (file)
@@ -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)
     {
index cbd5388bb78e2a6bc0abcbd56f8df5fa1ec5dc66..135b8d1ccd2cc37da1b8fa718e9cf2607b1ae694 100644 (file)
@@ -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);
             }
         }
     }
index 0370cb2368fa121967433bfd48deb31c057c6864..359967bf1318b0a7c0e7fb49a6e3b2e50b3ac88e 100644 (file)
@@ -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;
index a79aafd63b4c90a30f99d49669edd792e358bd30..4da3870f1c5e8b72fdde11b2995f637a28263e35 100644 (file)
@@ -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
similarity index 75%
rename from qt/examples/dbus.cpp
rename to qt/tools/dbus.cpp
index 32fcc3faa724354a3f4d1da860eae90e2508ad17..b2556ef8ff84b966b69a2efc2db9419faa6ebb3d 100644 (file)
@@ -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);
 }
 
index dd08b5fd6860448b7d2a450a5285810cfcf8b1c7..42d78312a02cdc3dd0975a77510cb5f3fa9a7684 100644 (file)
@@ -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");
index 091685b490b95a257c2607f32cd537056f7c5157..216c7ced6b2ed559a3c75d6dea914dd4f6c56015 100644 (file)
@@ -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);