Re: [Vala] How to use a DBus Dict in Vala?



Am Friday 09 January 2009 18:04:47 schrieb Michael 'Mickey' Lauer:
Am Tuesday 11 November 2008 11:52:01 schrieb Daniele Benucci:
2008/11/10 Daniele Benucci <d benux gmail com>

I need to call a DBus method that returns a "Dict of {String,
Variant}". How can I store and handle this result in Vala?

I found it.
HashTable to store the dict and GValue to store the variant.
It works only with Vala >= 0.5.1 since these two types are supported in
DBus clients starting with that version.

Does that also work for signals? I want to catch a signal with the
signature a{sv}, but when I define something like:

public void testing_test( dynamic DBus.Object sender,
HashTable<string,Value?> dict, Value? foo )

my signal handler does not get called.

(yes it works for simple types such as 's', and yes, I'm sure the signature
is correct as mdbus shows the signal emission at run time like that:

 [SIGNAL]    org.freesmartphone.Testing.Test
from :1.275 /org/freesmartphone/Testing
(dbus.Dictionary({dbus.String(u'yo'): dbus.String(u'kurt',
variant_level=1)}, signature=dbus.Signature('sv')),)

Following up on that, apparantly the way we generate the signal registration 
is only working for simple types. The following diff to the vala generated 
code leads at least to the correct signature w/ dbus, so my signal callback 
gets finally called:

 void _dynamic_Test1_connect (gpointer obj, const char * signal_name, 
GCallback handler, gpointer data) {
        dbus_g_object_register_marshaller 
(g_cclosure_user_marshal_VOID__BOXED, G_TYPE_NONE, G_TYPE_HASH_TABLE, 
G_TYPE_INVALID);
-       dbus_g_proxy_add_signal (obj, "Test", G_TYPE_HASH_TABLE, 
G_TYPE_INVALID);
+       dbus_g_proxy_add_signal (obj, "Test", 
dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE), 
G_TYPE_INVALID);
        dbus_g_proxy_connect_signal (obj, signal_name, handler, data, NULL);

So apparantly we need to use dbus_g_type_get_map for a{sv} [and likewise, I've 
seen dbus_g_type_get_collection getting used for arrays].

How do we move from here?

Cheers,
-- 
:M:



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