trinity-devel@lists.pearsoncomputing.net

Message: previous - next
Month: December 2016

how to read out the values of a complex dbus reply

From: deloptes <deloptes@...>
Date: Sat, 10 Dec 2016 21:34:04 +0100
Hi,
I am trying to understand how I could read out the values of a complex dbus
reply

I want to access following

//           org.freedesktop.DBus.ObjectManager.GetManagedObjects (out
DICT<OBJPATH,DICT<STRING,DICT<STRING,VARIANT>>>
objpath_interfaces_and_properties);
https://dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces-objectmanager

In my code I do

        TQT_DBusConnection connection = TQT_DBusConnection::systemBus();
        if (!connection.isConnected())
                tqFatal("Failed to connect to system bus");
        TQT_DBusProxy proxy(connection);

        proxy.setService("org.bluez");   // who we work with
        proxy.setPath("/");     // which object inside the peer work with
        proxy.setInterface("org.freedesktop.DBus.ObjectManager"); 
      
        if ( connection.isConnected() ) {
                if ( proxy.canSend() ) {
                        TQValueList<TQT_DBusData> params;
                        TQT_DBusMessage reply = proxy.sendWithReply("GetManagedObjects",
params );
                        if ( reply.type() != 2 || reply.count() != 1 || reply[0].type() !=
TQT_DBusData::Map)
                                tqFatal("GetManagedObjects failed");

                        kdDebug() << "TQT_DBusMessage: Reply " << reply.type() << endl;
                        kdDebug() << "Type:  TQT_DBusDataMap " << reply[0].type() << endl;
                        kdDebug() << "Count : " << dict.count() << endl;
                        TQT_DBusDataMap<TQT_DBusObjectPath> dict( reply[0] );

                                for (TQT_DBusDataMap<TQT_DBusObjectPath>::const_iterator it =
dict.begin(); it != dict.end(); ++it) {
                                        kdDebug() << (*it).type() << endl;
                                }
                }
                else
                        tqFatal("proxy can not send messages");
        }
        else
                tqFatal("manager is not connected");

result is
./bttest
TQT_DBusMessage: Reply 2
Type:  TQT_DBusDataMap 16
Count : 0

but when I run

gdbus
call -y -d "org.bluez" -o "/" -m "org.freedesktop.DBus.ObjectManager.GetManagedObjects"
({objectpath '/org/bluez': {'org.freedesktop.DBus.Introspectable': @a{sv}
{}, 'org.bluez.AgentManager1': {}, 'org.bluez.ProfileManager1':
{}, 'org.bluez.Alert1': {}, 'org.bluez.HealthManager1': {}}},)