Re: how to read out the values of a complex dbus reply

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thank you for being so helpful and supportive with this question ;-)

Here is an example code for the future generation

        TQT_DBusConnection connection = TQT_DBusConnection::systemBus();
        if (!connection.isConnected())
                tqFatal("Failed to connect to session bus");
        
        // create a proxy object for method calls
        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" ); // which of
its interfaces we will use
        
        TQValueList<TQT_DBusData> params;
        TQT_DBusMessage reply = proxy.sendWithReply("GetManagedObjects", params);
        
        if (reply.type() != TQT_DBusMessage::ReplyMessage)
                tqFatal("Call failed");
        
        if ( reply.type() != TQT_DBusMessage::ReplyMessage || reply.count() != 1 ||
reply[0].type() != TQT_DBusData::Map)
                tqFatal("Unexpected reply");
        
        bool ok = false;
        TQT_DBusDataMap<TQT_DBusObjectPath> names =
reply[0].toObjectPathKeyMap(&ok);

        kdDebug() << "TQT_DBusMessage::ReplyMessage  : " << reply.type() << endl;
        kdDebug() << "TQT_DBusData::Map              : " << reply[0].type() <<
endl;
        kdDebug() << "Name1                          : " << reply[0].typeName() <<
endl;
        kdDebug() << "Size1                          : " << names.count() << endl;
        if (!ok) tqFatal("toTQStringList failed");

        for (TQT_DBusDataMap<TQT_DBusObjectPath>::const_iterator it =
names.begin(); it != names.end(); ++it)
        {
                kdDebug() << "Name2                          : " << (*it).typeName() <<
endl;
                ok = false;
                TQT_DBusDataMap<TQString> names1 = (*it).toStringKeyMap(&ok);
                kdDebug() << "Size2                          : " << names1.count() <<
endl;
                if (!ok) tqFatal("toTQStringList failed");
                
                for (TQT_DBusDataMap<TQString>::const_iterator it1 = names1.begin();
it1 != names1.end(); ++it1)
                {
                        ok = false;
                        kdDebug() << "Name3                          : " << (*it1).typeName() <<
endl;
                        TQT_DBusDataMap<TQString> names2 = (*it1).toStringKeyMap(&ok);
                        if (!ok) tqFatal("toTQStringList failed");
                        kdDebug() << "key                            : " << TQString(it1.key())
<< endl;
                        kdDebug() << "Size3                          : " << names2.count() <<
endl;

                }
        }


---------------------------------------------------------------------
To unsubscribe, e-mail: trinity-devel-unsubscribe@xxxxxxxxxxxxxxxxxxxxxxxxxx
For additional commands, e-mail: trinity-devel-help@xxxxxxxxxxxxxxxxxxxxxxxxxx
Read list messages on the web archive: http://trinity-devel.pearsoncomputing.net/
Please remember not to top-post: http://trinity.pearsoncomputing.net/mailing_lists/#top-posting




[Index of Archives]     [Trinity Users]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [KDE]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]     [Trinity Desktop Environment]

  Powered by Linux