On Tue, Jul 14, 2009 at 10:20:48PM +0100, Enrico Zini wrote: > However, I cannot connect to signals with more complex signatures, like > org.freesmartphone.Usage.ResourceChanged or > org.freesmartphone.GPS.UBX.DebugPacket. I cannot seem to be able to > concoct a method signature that will properly match the signal, and my > callbacks never get called. > > People on #vala on GimpNet will probably have seen my numerous > unanswered questions in the channel this afternoon. > > Can I have some guidance on this? Is it implemented at all?
I've eventually found out through painful trial and error and study of the generated C code: This is how to provide a callback to org.freesmartphone.Usage.ResourceChanged, with signature sba{sv}: void on_resourcechanged(dynamic DBus.Object pos, string name, bool state, HashTable<string, Value?> attributes) { stderr.printf("Resource %s changed\n", name); } And this is how to provide a callback to org.freesmartphone.GPS.UBX.DebugPacket, with signature siaa{sv}: void on_ubxdebug_packet(dynamic DBus.Object ubx, string clid, int length, HashTable<string, Value?>[] wrongdata) { stderr.printf("Received UBX debug packet"); // Ugly ugly work-around PtrArray< HashTable<string, Value?> >* data = (PtrArray< HashTable<string, Value?> >)wrongdata; stderr.printf("%u elements received", data->len); } What is happening here is that the only method signature that I found matching the dbus signature is this one. However, the unmarshaller for some reason gets it wrong, and passes a PtrArray instead of a HashTable array. So you need to cast it back to what you've actually been passed. I blogged this at http://www.enricozini.org/2009/debian/vala-dbus-signatures/ Ciao, Enrico -- GPG key: 4096R/E7AD5568 2009-05-08 Enrico Zini <enr...@enricozini.org>
signature.asc
Description: Digital signature
_______________________________________________ Smartphones-userland mailing list Smartphones-userland@linuxtogo.org http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/smartphones-userland