Dbus Java - addSigHandler - GNU Classpath
Ed Hemphill
ed at izuma.net
Sun Sep 13 19:41:35 PDT 2009
Hi,
I was hoping someone could assist with the below issues. It may be
something obvious to DBus as I am new to it.
I have seen some posts from Matthew Johnson in the past which were
quite useful, but 'FrzRemoteSignal' is in a package.
When trying to add a SigHandler for a DBusSignal I am getting the
following exception:
type.getName: org.freedesktop.DBus type.getSimpleName: DBus
0 [main] ERROR Broadcast - Error: Member name
'FrzRemoteSignal$Sig' is invalid--> [
org.freedesktop.dbus.exceptions.DBusException ] Member name
'FrzRemoteSignal$Sig' is invalid -->
org.freedesktop.dbus.exceptions.DBusException: Member name
'FrzRemoteSignal$Sig' is invalid
at org.freedesktop.dbus.DBusConnection.addSigHandler(Unknown Source)
at org.freedesktop.dbus.AbstractConnection.addSigHandler(Unknown Source)
at framez.io.dbus.FrzDBusDrv.startFrzSigListen(FrzDBusDrv.java:96)
at framez.io.dbus.FrzDBusDrv.connect(FrzDBusDrv.java:70)
at DBusBroadcastSigTest.initApp(DBusBroadcastSigTest.java:96)
at framez.core.controller.FrzControllerExec.main(FrzControllerExec.java:104)
What I find weird is that the Member name is being called
FrzRemoteSignal$Sig - where as DBus's own information does not have
this dollar sign:
[.()] Handling incoming signal: DBusSignal(1,3) { Signature=>s,
Sender=>org.freedesktop.DBus, Destination=>:1.201,
Member=>NameAcquired, Interface=>org.freedesktop.DBus,
Path=>/org/freedesktop/DBus } { framez.tests.dbus.broadcast }
I have ran across a bug in GNU Classpath 0.98 (which is patched now)
for Class.getName and Class.getSimpleName - where both of these were
being reported as the same. This bug is patched but wonder if this
could be another problem like that...
As above, using the dbus-java-debug libraries...
[.()] Dequeueing MethodCall(0,3) { Signature=>s,
Destination=>org.freedesktop.DBus, Member=>AddMatch,
Interface=>org.freedesktop.DBus, Path=>/org/freedesktop/DBus } {
type='signal',member='FrzRemoteSignal$Sig',interface='framez.io.dbus.FrzRemoteSignal'
}
[.()] Got message: MethodCall(0,3) { Signature=>s,
Destination=>org.freedesktop.DBus, Member=>AddMatch,
Interface=>org.freedesktop.DBus, Path=>/org/freedesktop/DBus } {
type='signal',member='FrzRemoteSignal$Sig',interface='framez.io.dbus.FrzRemoteSignal'
}
[.()] <= MethodCall(0,3) { Signature=>s,
Destination=>org.freedesktop.DBus, Member=>AddMatch,
Interface=>org.freedesktop.DBus, Path=>/org/freedesktop/DBus } {
type='signal',member='FrzRemoteSignal$Sig',interface='framez.io.dbus.FrzRemoteSignal'
}
[.()] Writing all 40 buffers simultaneously to Unix Socket
[.()] => Error(1,5) { Signature=>s, Sender=>org.freedesktop.DBus,
Destination=>:1.195, Reply Serial=>3, Error
Name=>org.freedesktop.DBus.Error.MatchRuleInvalid } { Member name
'FrzRemoteSignal$Sig' is invalid
}
[.()] Handling incoming error: Error(1,5) { Signature=>s,
Sender=>org.freedesktop.DBus, Destination=>:1.195, Reply Serial=>3,
Error Name=>org.freedesktop.DBus.Error.MatchRuleInvalid } { Member
name 'FrzRemoteSignal$Sig' is invalid
}
FrzRemoteSignal DBusInterface----------->
package framez.io.dbus;
import org.freedesktop.dbus.DBusSignal;
import org.freedesktop.dbus.DBusInterface;
import org.freedesktop.dbus.Struct;
import org.freedesktop.dbus.exceptions.DBusException;
import framez.core.signal.FrzSignal;
/** This class is used by d-bus for transmission of a FrzSignal<br>
* The FrzSignal is essentially represented by two Struct(s) <br>
* See org.freedesktop.dbus for why this must be DBusSignal inside a
DBusInterface.
* @author ed
* @see FrzSignal
*/
public interface FrzRemoteSignal extends DBusInterface {
/** We only have one signal for this class right now, Send a signal */
public static class Sig extends DBusSignal {
public final Struct signal;
public final Struct data;
public Sig(String path, Struct signal, Struct data )
throws DBusException {
super(path, signal, data);
this.signal = signal;
this.data = data;
}
}
}
in other code - adding the sigHandler---------->
public void startFrzSigListen() {
if (remoteSigHandler != null)
try {
conn.addSigHandler(FrzRemoteSignal.Sig.class, remoteSigHandler);
} catch (DBusException e) {
FrzLog.error("Error: " + e.getMessage() + "-->" + FrzLog.stringifyTrace(e));
} catch (ClassCastException e) {
FrzLog.error("Error: " + e.getMessage() + "-->" + FrzLog.stringifyTrace(e));
}
else
FrzLog.error("remoteSigHandler is uninitialized.");
}
remoteSigHandler is just an instance of...
public class FrzRemoteSigHandler implements DBusSigHandler {
public void handle(DBusSignal s) {
if(s instanceof FrzRemoteSignal.Sig) {
FrzRemoteSignal.Sig sig = (FrzRemoteSignal.Sig) s;
FrzSignal frzsig = null;
FrzLog.debug("Got incoming remote signal: " +
((FrzSignal.SigStruct) sig.signal).Code);
if(((FrzSignal.SigStruct)sig.signal).dataTypeName != "") // if the
signal had a type, then...
frzsig = new FrzSignal( (FrzSignal.SigStruct) sig.signal,
sig.data ); // try to create with data
else // otherwise just a Signal, but no FrzSigData
frzsig = new FrzSignal( (FrzSignal.SigStruct) sig.signal, null );
sigQueue.enqueSignal(frzsig); // send to event queue
}
}
}
I am happy to post more code, but this is the crux of the DBus
related... any help appreciated
-Ed
More information about the dbus
mailing list