Re: Re: help with tqt dbus

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

 



Hi
 
> 
> I will try to take a look at this during the weekend and give some
> feedback. Cheers
>   Michele

Please, have a look at this - why it fails here

        TQValueList<TQT_DBusData> list = data.toTQValueList(&ok);

is it only on my system or you see the same?
is it me making a mistake or it is a bug?

when I remove the condition it works though I wouldn't expected if it fails
to has any data in the list.
        TQValueList<TQT_DBusData> list = data.toTQValueList(&ok);
        if (!ok) kdDebug() << "toTQValueList failed" << endl;
        else kdDebug() << "toTQValueList worked" << endl;
//      if (!ok) return -1;ok = false;

thanks in advance
regards
// TQt includes
//#include <tqmap.h>
//#include <tqstring.h>
//#include <tqstringlist.h>
#include <kdebug.h>

// TQt D-Bus includes
//#include <tqdbusconnection.h>
#include <tqdbusdata.h>
#include <tqdbusvariant.h>
#include <tqdbusdatalist.h>
#include <tqdbusdatamap.h>
//#include <tqdbuserror.h>
//#include <tqdbusmessage.h>
#include <tqdbusobjectpath.h>
//#include <tqdbusproxy.h>

//#include <tdecmdlineargs.h>
//#include <tdeaboutdata.h>
//#include <tdelocale.h>
//#include <tdeapplication.h>
//#include <iostream>

#define DBUS_CONN_NAME "BTTest"

int main() {



	kdDebug() << k_funcinfo << endl;



	TQValueList<TQT_DBusData> parameters;

	//a{oa{sa{sv}}}

	//sv
	TQT_DBusVariant variant;

	variant.value     = TQT_DBusData::fromString("First String");
	variant.signature = variant.value.buildDBusSignature();

	TQT_DBusData str1 = TQT_DBusData::fromVariant(variant);

	variant.value     = TQT_DBusData::fromString("Second String");
	variant.signature = variant.value.buildDBusSignature();

	TQT_DBusData str2 = TQT_DBusData::fromVariant(variant);

	//sa{sv}
	TQT_DBusDataMap<TQString> stringMap1;
	stringMap1.insert("string1", str1);
	stringMap1.insert("string2", str2);

	TQT_DBusDataMap<TQString> stringMap2;
	stringMap2.insert("string1", str1);
	stringMap2.insert("string2", str2);

	TQT_DBusDataMap<TQString> stringMap;
	stringMap.insert("stringMap1", TQT_DBusData::fromStringKeyMap(stringMap1));
	stringMap.insert("stringMap2", TQT_DBusData::fromStringKeyMap(stringMap2));


	//oa{sa{sv}}
	TQT_DBusDataMap<TQT_DBusObjectPath> opMap1;
	opMap1.insert(TQT_DBusObjectPath( TQCString("/path1") ), TQT_DBusData::fromStringKeyMap(stringMap));
	opMap1.insert(TQT_DBusObjectPath( TQCString("/path2") ), TQT_DBusData::fromStringKeyMap(stringMap));
	opMap1.insert(TQT_DBusObjectPath( TQCString("/path3") ), TQT_DBusData::fromStringKeyMap(stringMap));
	TQT_DBusDataMap<TQT_DBusObjectPath> opMap2;
	opMap2.insert(TQT_DBusObjectPath( TQCString("/path1") ), TQT_DBusData::fromStringKeyMap(stringMap));
	opMap2.insert(TQT_DBusObjectPath( TQCString("/path2") ), TQT_DBusData::fromStringKeyMap(stringMap));
	opMap2.insert(TQT_DBusObjectPath( TQCString("/path3") ), TQT_DBusData::fromStringKeyMap(stringMap));
	TQT_DBusDataMap<TQT_DBusObjectPath> opMap3;
	opMap3.insert(TQT_DBusObjectPath( TQCString("/path1") ), TQT_DBusData::fromStringKeyMap(stringMap));
	opMap3.insert(TQT_DBusObjectPath( TQCString("/path2") ), TQT_DBusData::fromStringKeyMap(stringMap));
	opMap3.insert(TQT_DBusObjectPath( TQCString("/path3") ), TQT_DBusData::fromStringKeyMap(stringMap));

	//a{oa{sa{sv}}}
	TQValueList<TQT_DBusData> vl;
	vl.append(TQT_DBusData::fromObjectPathKeyMap(opMap1));
	vl.append(TQT_DBusData::fromObjectPathKeyMap(opMap2));
	vl.append(TQT_DBusData::fromObjectPathKeyMap(opMap3));

	TQT_DBusData data = TQT_DBusData::fromTQValueList(vl);

	kdDebug() << "data typeName: " << data.typeName() << endl;

	// Deconstruct
	bool ok = false;
	TQValueList<TQT_DBusData> list = data.toTQValueList(&ok);
	if (!ok) kdDebug() << "toTQValueList failed" << endl;
	else kdDebug() << "toTQValueList worked" << endl;
	kdDebug() << "list.count() " << list.count() << endl;
//	if (!ok) return -1;ok = false;

	TQValueList<TQT_DBusData>::const_iterator lit = list.begin();
	for(lit; lit != list.end(); ++lit) {
		kdDebug() << "   -------------------------------------------" << endl;

		TQT_DBusDataMap<TQT_DBusObjectPath> objects = (*lit).toObjectPathKeyMap(&ok);
		if (!ok) kdDebug() << "   toObjectPathKeyMap failed" << endl;
		else kdDebug() << "   toObjectPathKeyMap worked" << endl;
		if (!ok) return -1;

		kdDebug() << "   objects.count(): " << objects.count() << endl;
		TQT_DBusDataMap<TQT_DBusObjectPath>::const_iterator it = objects.begin();
		for (it; it != objects.end(); ++it) {
			kdDebug() << "      -------------------------------------------" << endl;

			kdDebug() << "      it.data() typeName: " << it.data().typeName() << endl;
			kdDebug() << "      it.data()  keyType: " << it.data().keyType() << endl;
			kdDebug() << "      it.key()          : " << TQCString(it.key()) << endl;
			bool ok = false;
			TQT_DBusDataMap<TQString> map1 = it.data().toStringKeyMap(&ok);
			if (!ok) continue;
			kdDebug() << "      map1.size()   " << map1.count() << endl;
			TQT_DBusDataMap<TQString>::const_iterator it1 = map1.begin();
			for (it1; it1 != map1.end(); ++it1) {
				kdDebug() << "         -------------------------------------------" << endl;
				kdDebug() << "         it1.key()          : " << it1.key() << endl;
				kdDebug() << "         it1.data() typeName: " << it1.data().typeName() << endl;
				kdDebug() << "         it1.data()  keyType: " << it1.data().keyType() << endl;

				TQT_DBusDataMap<TQString>  map2 = it1.data().toStringKeyMap();
				kdDebug() << "         map2.size()   " << map2.count() << endl;
				TQT_DBusDataMap<TQString>::const_iterator it2 = map2.begin();
				for (it2; it2 != map2.end(); ++it2) {
					kdDebug() << "            -------------------------------------------" << endl;
					kdDebug() << "            it2.key()           : " << it2.key() << endl;
					kdDebug() << "            it2.data() typeName : " << it2.data().typeName() << endl;
					kdDebug() << "            it2.data()  keyType : " << it2.data().keyType() << endl;
					kdDebug() << "            it2.data() : 	      " << it2.data().toVariant().value.toString() << endl;
				}
			}
		}
	}

	kdDebug() << "DONE" << endl;
	return 0;
}


---------------------------------------------------------------------
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