[Vala] Getting access to objects using an ObjectPath




-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi all:

I'm starting with DBus over Vala, and I'm having problems in getting
access to some elements.

I want to work with the UDisk system, so I started to connecto to
"org/freedesktop/Udisks" and get all the devices. This returns an
array of ObjectPaths. Now, I want to get the file associated with each
device, but it returns NULL, so I'm not sure if I'm not getting access
to the dbus object itself, or the code is fine and the problem is in
UDisk...

Here is the code (links to the DBus interfaces of UDisk is after it):

- ------- cut here --------- cut here --------- cut here ---------------

using GLib;

[DBus (name = "org.freedesktop.UDisks")]
interface DemoClient : Object {
    public abstract ObjectPath[] EnumerateDevices() throws IOError;
    public abstract string DaemonVersion { owned get; set; }
}

[DBus (name = "org.freedesktop.UDisks.Device")]
interface DemoClient2 : Object {
    public abstract string DeviceFile { owned get; set; }
}

void main () {

    DemoClient client = Bus.get_proxy_sync (BusType.SYSTEM,
"org.freedesktop.UDisks","/org/freedesktop/UDisks");
    var retval = client.EnumerateDevices();
   
    GLib.stdout.printf("Version %s\n",client.DaemonVersion);
   
    DemoClient2 client2;
   
    foreach (ObjectPath o in retval) {
        client2 = Bus.get_proxy_sync (BusType.SYSTEM,
"org.freedesktop.UDisks.Device",o,DBusProxyFlags.NONE,null);
        GLib.stdout.printf("Values: %s %s\n",o,client2.DeviceFile);
    }
}

- ------- cut here --------- cut here --------- cut here ---------------

UDisks interfaces are here:

http://hal.freedesktop.org/docs/udisks/UDisks.html

UDisks.Device interfaces are here

http://hal.freedesktop.org/docs/udisks/Device.html#Device:DeviceFile

Thanks!

- -- 
Nos leemos
                 RASTER    (Linux user #228804)
raster rastersoft com              http://www.rastersoft.com

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk5I7AgACgkQXEZvyfy1ha+o/ACgi4jiQd2dnOAd7RkUIZm8ukdI
LpUAn14letMJeL4sG7EScX9ne03yPN+R
=MKeQ
-----END PGP SIGNATURE-----




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