Problem with org.freedesktop.DBus.Properties PropertiesChanged signal

Arnaud Tanguy arn.tanguy at gmail.com
Mon Oct 1 10:58:58 PDT 2012


Hi,
I'm currently creating an Android application aiming to be able to fully
control all multimedia application using DBus system. That way, I would be
able to control pretty much all of linux audio and video programs from a
single application and server, nice ;)

I managed to go pretty far on my own, the android application works (with a
minimal set of functionalities for now), the MPRIS1 interface works
perfectly, and MPRIS2 is well on the way, but for a single problem that
kept me stuck for a while now.

I need to connect my application to the signal
org.freedesktop.DBUS.Properties.PropertiesChanged.
Here is how the signals are organised :
Bus name: org.bansheeproject.Banshee
Object Path : /org/mpris/MediaPlayer2
Interface : org.freedesktop.DBus.Properties (containing the
PropertiesChanged signal)

So I applied the same principle I used successfully until then to try to
use this signal:
- Create an interface extending DBusInterface, and using the annotation
@DBusInterfaceName("org.freedesktop.DBus.Properties")

- Creating a handler implementing DBusSigHandler

- Connecting the the handler to dbus via the addSigHandler function

But this time, it doesn't work. I think I might be doing something wrong
about the fact that the interface is org.freedesktop.DBus.Properties.
Usually I dealt with interfaces that had the same name as the object path
(like org.mpris.MediaPlayer2.Player for instance).

Here are the relevant (adapted to be more readable) code part, and stripped
bare of anything useless to solve my problem



** File: dbus.mpris2.DBusMPRIS2.java
String serviceBusName = "org.mpris.MediaPlayer2.banshee";
String playerPath = "/org/mpris/MediaPlayer2";
String playerPropertiesInterface = "org.mpris.MediaPlayer2.Player";
        trackListObjectPath = "/TrackList";
protected static DBusConnection conn =
DBusConnection.getConnection(DBusConnection.SESSION);

// THIS ONE DOESN'T work
PropertiesHandler pHandler = new PropertiesHandler();
conn.addSigHandler(org.mpris.MediaPlayer2.PropertiesChangedSignal.PropertiesChanged.class,
pHandler);

// This one works perfectly
SeekedHandler seekedHandler = new SeekedHandler(server);
conn.addSigHandler(org.mpris.MediaPlayer2.Player.Seeked.class,
seekedHandler);


**************************************************
** File : dbus.mpris2.PropertiesChangedSignal.java
I wanted to put it into org.freedesktop.DBus.Properties.java, but obviously
I can't, because the interface already exists...
I think that it is the source of my problem, since I don't quite understand
the relationship between the annotation, and the package location...
**************************************************
@DBusInterfaceName("org.freedesktop.DBus.Properties")
public interface PropertiesChangedSignal extends DBusInterface {

    public static class PropertiesChanged extends DBusSignal {
        public final Map<String, Variant> changed_properties;
        public final List<String> invalidated_properties;

        public PropertiesChanged(String path,
                Map<String, Variant> changed_properties,
                List<String> invalidated_properties) throws DBusException {
            super(path, changed_properties, invalidated_properties);
            this.changed_properties = changed_properties;
            this.invalidated_properties = invalidated_properties;
        }
    }
}

***************************
** File: PropertiesHandler
***************************

public class PropertiesHandler implements
DBusSigHandler<dbus.mpris2.PropertiesChangedSignal.PropertiesChanged>  {

    @Override
    public void handle(PropertiesChanged arg0) {
        // TODO Auto-generated method stub
        System.out.println("SIGNAL RECIEVED!!! AT LAST");
    }

}




*****
And finally, here is the dbus log relevant to the signal

signal sender=:1.68 -> dest=(null destination) serial=828
path=/org/mpris/MediaPlayer2; interface=org.freedesktop.DBus.Properties;
member=PropertiesChanged
   string "org.mpris.MediaPlayer2.Player"
   array [
      dict entry(
         string "PlaybackStatus"
         variant             string "Paused"
      )
   ]
   array [
   ]



*****
If you need to have a look at my full code to get a better understanding of
the situation, it is here:
https://github.com/geenux/AndroidMultimediaControl

Another little side question: Why didn't CreateInterface provide me the
interface for the PropertiesChanged signal, but provided it for everything
else than this signal?

Thanks in advance for your precious help,

Arnaud TANGUY
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/dbus/attachments/20121001/a63127dc/attachment.html>


More information about the dbus mailing list