DBUS Java MethodCall problem

Matthew Johnson dbus at matthew.ath.cx
Fri Dec 12 01:27:24 PST 2008


On Fri Dec 12 12:12, Ben Itzstein wrote:
> Hi all, I'm having some difficulty understanding the interface of the Java
> MethodCall constructor, as the javadoc doesn't explain the arguments at all.
> 
> I want to be able to replicate the call:
> dbus-send --type=method_call --dest=org.freedesktop.compiz
> /org/freedesktop/compiz/firepaint/allscreens/add_particle
> org.freedesktop.compiz.activate string:'root' int32:`xwininfo -root | grep
> id: | awk '{ print $4 }'` string:'x' double:320 string:'y' double:240
> 
> I've replicated the low-level example in the java documentation, and am just
> altering the MethodCall parameters to suit my case. My attempt is:

OK, is there any reason you are doing this using the low level API? The
normal way unless you have a really good reason would be to do:

DBusConnection conn = DBusConnection.getConnection(DBusConnection.SESSION)
compiz c = conn.getRemoteObject("org.freedesktop.compiz",
      "/org/freedesktop/compiz/firepaint/allscreens/add_particle",
      compiz.class);
c.activate("root", 0xC2, "x", 320.0, "y", 240.0);

> 
>             Message addParticle = new MethodCall(
>                     "org.freedesktop.compiz", //dest
> 
> "/org/freedesktop/compiz/firepaint/allscreens/add_particle", //path
>                     "org.freedesktop.compiz", //iface
>                     "activate", //member
>                     (byte)0, //flags
>                     null, //signature
>                     "root", (int)0xC2, //args
>                     "x", (double)320.0,
>                     "y", (double)440.0);

If you really want to do this then you need to give it a valid
signature. In this case it is "sisdsd".

> Second (off-topic) question:
> 0xC2 was the result of `xwininfo -root | grep id: | awk '{ print $4 }'` at
> the time I was testing this program. Is there a way I can get this
> information from java?

I don't know of any direct way, I suspect you can't, but I might be
wrong. There _might_ be a non-public Sun API, otherwise you are down to
writing some JNI to get it or forking that command and reading the
output.

Matt

-- 
www.matthew.ath.cx
D-Bus Java
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.freedesktop.org/archives/dbus/attachments/20081212/c6f94299/attachment.pgp 


More information about the dbus mailing list