dbus-java-2.6 No signal notification

pgodin pgodin at rheinmetall.ca
Tue Nov 3 12:50:54 PST 2009


Thanks to everyone (in fact only Kees offered some kind of support but
hey, I'm forgiving) my problem is now solved. 

The public static class defined in the object implementing the
DbusInterface must define the signal using an undocumented, additional
parameter.

Example if the API defines a signal like this one:
PropertyChanged(String propertyName, Variant newValue)

The class definition in java should be done as this:
PropertyChanged(String path, String propertyName, Variant newValue)

That's it. Now looking at examples my error seems so obvious. Maybe the
binding documentation should emphasize the use of the automatic
interface creation supplied with the bindings in order to minimize the
risk of such stupid errors.

Phil

On Tue, 2009-11-03 at 14:27 -0500, pgodin wrote:
> Hi Kees,
> 
> Thanks for your answer. I think you were mislead by the remote object
> invocations. In my proof of concept, getting a hold of these remote
> objects only allows me to call bluez/dbus methods and change some
> properties. This works fine. I am able to change the adapter visibility
> without any glitch.
> 
> Removing these statements only leaves the dbus connection and signal
> handler. This does not work. I am never notified when a property is
> changed in the adapter interface (at least in java since dbus-monitor
> does output the signal that a property have been changed). So here's my
> issue, it's only in java in these ~10 lines of code.
> 
> Any other hints or ideas would be greatly appreciated.
> Phil
> 
> On Mon, 2009-11-02 at 18:03 -0500, Kees Jongenburger wrote:
> > Hi,
> > 
> > On Mon, Nov 2, 2009 at 7:34 PM, pgodin <pgodin at rheinmetall.ca> wrote:
> > > Using dbus-1.2.14, dbus-java-2.6, jdk-1.6.0_16 and bluez-4.56,:
> > >
> > > Java application isn't notified when a signal is sent on dbus. Using
> > > dbus-monitor I can see signals being passed on the system bus. My proof
> > > of concept application uses dbus to setup a bluetooth adapter
> > > visibility. I would also like it to be notified of signals such as
> > > device removal and addition although this example listens for
> > > PopertyChanged signals. My gut feeling is that I am not using dbus as it
> > > should be although I went through the documentation and several online
> > > discussions. I you believe my problem better be posted on the bluez
> > > list, please tell me so.
> > 
> > I am pretty new to all this but I think you are indeed doing it the wrong way.
> > 
> > > public class DBusConn
> > > {
> > >    public DBusConn()
> > >    {
> > >        DBusConnection connection = null;
> > >        try
> > >        {
> > >            connection =
> > > DBusConnection.getConnection(DBusConnection.SYSTEM);
> > >
> > >            final Manager manager =
> > > connection.getRemoteObject("org.bluez", "/", Manager.class);
> > 
> > Getting a reference to a remote object
> > 
> > >
> > >            final Path defaultAdapterPath = manager.DefaultAdapter();
> > >
> > >            final Adapter adapter =
> > > connection.getRemoteObject("org.bluez", defaultAdapterPath.getPath(),
> > > Adapter.class);
> > 
> > Idem
> > 
> > 
> > > connection.addSigHandler(org.bluez.Adapter.PropertyChanged.class,
> > 
> > Registering to receive Signal but this is totally unrelated to the
> > previous code (getting hold of
> > remote objects). I aksed the same kind of question yesterday signals
> > are sent "to" object and not from so I threory
> > you need to implement the Object before you can listen to changed.
> > 
> > However apparently the Java implementation makes it possible to listen
> > to those signals but in that case you don't need to
> > get hold of the remote objects a all.
> > 
> > Here is an example that works for me
> > 
> > /**
> > http://github.com/keesj/dbus_glib_pthread/blob/master/java/src/com/test/RunNotification.java
> > **/
> > package com.test;
> > 
> > import org.freedesktop.dbus.DBusConnection;
> > import org.freedesktop.dbus.DBusSigHandler;
> > import org.freedesktop.dbus.exceptions.DBusException;
> > 
> > /**
> >  * dbus-send \
> >         --system \
> >         /com/test/Notification \
> >         com.test.Notification.Notify
> > 
> >  *
> >  */
> > public class RunNotification implements DBusSigHandler<Notification.Notify> {
> > 
> >         public static void main(String[] args) throws DBusException {
> >                 RunNotification instance = new RunNotification();
> >                 DBusConnection conn  =
> > DBusConnection.getConnection(DBusConnection.SYSTEM);
> >                 conn.addSigHandler(Notification.Notify.class, instance);
> >         }
> > 
> >         public void handle(Notification.Notify arg0) {
> >                 System.err.println("Notified");
> >         }
> > }
> 
> _______________________________________________
> dbus mailing list
> dbus at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dbus



More information about the dbus mailing list