dbus-java and org.freedesktop.UDisks.Device

andy andy at benow.ca
Sat Apr 2 14:11:17 PDT 2011


Hello,

I would like to use dbus-java to find information about a disc insert.
To do so, I need to listen for the DriveChanged signal, retrieve the
device and examine properties.  So far, I've managed to register for the
signal, but I am not able to create a UDisks.Device interface or
otherwise retrieve information for the device.

DBusConnection conn
=DBusConnection.getConnection(DBusConnection.SYSTEM);
conn.addSigHandler(UDisks.DeviceChanged.class, new
DBusSigHandler<UDisks.DeviceChanged>() {
  @Override
  public void handle(
    UDisks.DeviceChanged changed) {
     Object dev = changed.getParameters()[0];
     // at this point, dev is a $Proxy2 object.
     System.out.println(dev);
  }
}

What can I do with dev?  I've tried to use CreateInterface to create a
org.freedesktop.UDisks.Device for /org/freedesktop/UDisks/devices/sr1,
but that fails with a:

ERROR: Failure in DBus Communications: The name
org.freedesktop.UDisks.Device was not provided by any .service files

How can I access the information about the device?

Right now, my hacky solution to this problem is to parse the dev
toString() and create a hal query to submit to hal-get-property.  It's a
mess, and I'd rather do it all with dbus.

TIA, and if this is not the correct list for java related queries,
please point me in the right direction.

Andy




More information about the dbus mailing list