[Vala] DBus.ObjectPath as DBus output parameter




Hi List

I have a pesky problem, with which I hope you can help. I'm new to both vala, GLib and DBus, so please excuse my ignorance.

I have a DBus server, which implements a method that return a DBus object path - in introspection XML:

<node name="/MediaPlayerManager">
 <interface name="Media.MediaPlayerManager">
   <method name="getDefaultMediaPlayer">
     <arg type="o" name="MediaPlayerPath" direction="out"/>
         </method>


The generated c/GLib client stub using glib-bindings-tool becomes:

Media_MediaPlayerManager_get_default_media_player (DBusGProxy *proxy, char** OUT_MediaPlayerPath, GError 
**error)
{
 return dbus_g_proxy_call (proxy, "getDefaultMediaPlayer", error, G_TYPE_INVALID, DBUS_TYPE_G_OBJECT_PATH, 
OUT_MediaPlayerPath, G_TYPE_INVALID);


But the following vala code

   private DBus.ObjectPath MediaPlayerProxy;
   private dynamic DBus.Object MediaPlayerManager;

       MediaPlayerManager = conn.get_object ("org.futarque.canvas.MediaPlayerManager",
                                      "/org/futarque/Canvas/MediaPlayerManager",
                                      "Media.MediaPlayerManager");
       MediaPlayerManager.getDefaultMediaPlayer(MediaPlayerProxy);


Becomes the following when compiled to c:

char* MediaPlayerProxy;

void _dynamic_getDefaultMediaPlayer1 (DBusGProxy* self, const char* param1, GError** error) {
   dbus_g_proxy_call (self, "getDefaultMediaPlayer", error, DBUS_TYPE_G_OBJECT_PATH, param1, G_TYPE_INVALID, 
G_TYPE_INVALID);

Here vala uses the DBus.ObjectPath as an input parameter (as I would suspect as I give it no hint otherwise) and gets the parameter type correct: DBUS_TYPE_G_OBJECT_PATH How to I change the DBus.ObjectPath to become an output parameter? I have tried changing the vala code to

MediaPlayerManager.getDefaultMediaPlayer(&MediaPlayerProxy);

Then I get the following c code:

void _dynamic_getDefaultMediaPlayer1 (DBusGProxy* self, const char** param1, GError** error) {
   dbus_g_proxy_call (self, "getDefaultMediaPlayer", error, G_TYPE_NONE, param1, G_TYPE_INVALID, 
G_TYPE_INVALID);

And this output from valac:

** (valac:22331): CRITICAL **: valadbusclientmodule.vala:477: Internal error during DBus type generation 
with: DBus.ObjectPath**
Compilation succeeded - 1 warning(s)
test.c (dep: 1)     ->    test.o
test.c: In function 'canvas_test_run':
test.c:101: warning: passing argument 2 of '_dynamic_getDefaultMediaPlayer1' from incompatible pointer type

It seems vala cannot figure out how to bind the "DBus.ObjectPath *" type? It becomes a G_TYPE_NONE as input parameter.

If I change the vala code to:

   private DBus.ObjectPath *MediaPlayerProxy;
....
       MediaPlayerManager.getDefaultMediaPlayer(MediaPlayerProxy);


I get:

const char* MediaPlayerProxy;

void _dynamic_getDefaultMediaPlayer1 (DBusGProxy* self, const char* param1, GError** error) {
   dbus_g_proxy_call (self, "getDefaultMediaPlayer", error, G_TYPE_NONE, param1, G_TYPE_INVALID, 
G_TYPE_INVALID);


And again the same warning from valac.
No matter what I do, I cannot seem to get vala to understand about output parameters - what is the convention here? Do I really need to use the XML to generate vala bindings (I've never tried that) or is this "transparent proxy" thing I am trying the way to go?

Any help appreciated.

BR Jens Kristian Jensen




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