[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/work/dbus-qt4-qt3backport
From:       Kevin Krammer <kevin.krammer () gmx ! at>
Date:       2007-01-30 21:28:29
Message-ID: 1170192509.809421.18277.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 628670 by krake:

Adding a code generator tool which takes a D-Bus xml introspection data file
and generates Proxy implementations and service object implementations
(pure virtuals for the D-Bus methods) for all contained interfaces


 M  +45 -7     examples/example-client.cpp  
 M  +2 -2      examples/example-client.pro  
 A             tools (directory)  
 A             tools/dbusxml2qt3 (directory)  
 A             tools/dbusxml2qt3/LICENSE  
 A             tools/dbusxml2qt3/Makefile  
 A             tools/dbusxml2qt3/classgen.cpp   [License: X11 (BSD like)]
 A             tools/dbusxml2qt3/classgen.h   [License: X11 (BSD like)]
 A             tools/dbusxml2qt3/dbusxml2qt3.pro  
 A             tools/dbusxml2qt3/main.cpp   [License: X11 (BSD like)]
 A             tools/dbusxml2qt3/methodgen.cpp   [License: X11 (BSD like)]
 A             tools/dbusxml2qt3/methodgen.h   [License: X11 (BSD like)]


--- branches/work/dbus-qt4-qt3backport/examples/example-client.cpp #628669:628670
@@ -24,6 +24,7 @@
 // Qt includes
 #include <qapplication.h>
 #include <qtimer.h>
+#include <qmap.h>
 
 // Qt DBUS includes
 #include <dbus/qdbusdatalist.h>
@@ -32,8 +33,12 @@
 #include <dbus/qdbusmessage.h>
 #include <dbus/qdbusproxy.h>
 
+#include <dbus/qdbusdatamap.h>
+#include <dbus/qdbusvariant.h>
+
 // local includes
 #include "example-client.h"
+#include "deviceproxy.h"
 
 ExampleClient::ExampleClient() : QObject(0, "ExampleClient"), m_proxy(0)
 {
@@ -48,7 +53,7 @@
 void ExampleClient::slotConnect()
 {
     // get a connection to the session bus
-    QDBusConnection connection = \
QDBusConnection::addConnection(QDBusConnection::SessionBus); +    QDBusConnection \
connection = QDBusConnection::addConnection(QDBusConnection::SystemBus);  
     if (!connection.isConnected())
     {
@@ -57,9 +62,9 @@
 
     // create a proxy for the main bus object
     m_proxy = new QDBusProxy(this);
-    m_proxy->setService("org.freedesktop.DBus");
-    m_proxy->setPath("/org/freedesktop/DBus");
-    m_proxy->setInterface("org.freedesktop.DBus");
+    m_proxy->setService("org.freedesktop.Hal");
+    m_proxy->setPath("/org/freedesktop/Hal/devices/computer");
+    m_proxy->setInterface("org.freedesktop.Hal.Device");
 
     // let it use our connection
     m_proxy->setConnection(connection);
@@ -72,13 +77,12 @@
     qDebug("Calling method 'ListNames' synchronously. Our name: '%s'",
            connection.uniqueName().local8Bit().data());
 
-    QDBusMessage reply = m_proxy->sendWithReply("ListNames", \
QValueList<QDBusData>()); +    QDBusMessage reply = \
m_proxy->sendWithReply("GetAllProperties", QValueList<QDBusData>());  
     // we expect a method reply with a list of strings as its only value
     if (reply.type() == QDBusMessage::ReplyMessage && reply.count() == 1)
     {
-        //if (reply[0].type() == QDBusData::StringList)
-        if (reply[0].type() == QDBusData::List)
+/*        if (reply[0].type() == QDBusData::List)
         {
             QDBusDataList list = reply[0].toList();
             if (list.type() != QDBusData::String)
@@ -95,6 +99,30 @@
             {
                 qDebug("%s", (*it).local8Bit().data());
             }
+        }*/
+        if (reply[0].type() == QDBusData::Map && reply[0].keyType() == \
QDBusData::String) +        {
+            QDBusDataMap<QString> map = reply[0].toStringKeyMap();
+            if (map.keyType() != QDBusData::String)
+            {
+                qWarning("Reply for 'ListNames' carried unexpected value of"
+                         " type %s-List", QDBusData::typeName(map.keyType()));
+            }
+
+            if (map.valueType() != QDBusData::Variant)
+            {
+                qWarning("map type not variant, but %s",
+                         QDBusData::typeName(map.valueType()));
+            }
+
+            QMap<QString, QDBusVariant> varMap = map.toVariantMap();
+            QMap<QString, QDBusVariant>::const_iterator it = varMap.begin();
+            for (int count = 0; it != varMap.end(); ++it, ++count)
+            {
+                qDebug("n=%d, key='%s', signature='%s', var.type='%s",
+                       count, it.key().latin1(),
+                       (*it).signature.latin1(), (*it).value.typeName());
+            }
         }
         else
             qWarning("Reply for 'ListNames' carried unexpected value of type %s",
@@ -128,6 +156,16 @@
     }
     else
         qWarning("Method call 'GetConnectionUnixUser' failed");
+
+    org::freedesktop::Hal::Device* device = new \
org::freedesktop::Hal::Device("org.freedesktop.Hal", \
"/org/freedesktop/Hal/devices/computer", this); +    \
device->setConnection(connection); +
+    QMap<QString, QDBusVariant> map;
+    QDBusError error;
+    if (device->GetAllProperties(map, error))
+    {
+        qDebug("got map with %d entries", map.count());
+    }
 }
 
 void ExampleClient::slotDBusSignal(const QDBusMessage& message)
--- branches/work/dbus-qt4-qt3backport/examples/example-client.pro #628669:628670
@@ -2,8 +2,8 @@
 
 CONFIG += qt thread
 
-SOURCES += example-client.cpp
-HEADERS += example-client.h
+SOURCES += example-client.cpp deviceproxy.cpp
+HEADERS += example-client.h deviceproxy.h
 
 TARGET = example-client
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic