[Kde-bindings] Qyoto DBUS
Richard Dale
rdale at foton.es
Wed Jan 10 15:24:55 UTC 2007
On Wednesday 10 January 2007 14:15, Arno Rehn wrote:
> Hi,
>
> I have added most of the marshallers by now, I think, and the ones we need
> for getting dbus to work are also complete.
Great! I've been meaning to do some work on Qyoto for a while, but haven't got
round to it. It would be really nice to get QDBus working. I've been meaning
to review your marshaller code - it had lists of 'void*'s which didn't look
quite right. I think there should be callbacks for each element of a list,
rather than for a complete list.
> I've again tried to get the
> listnames example to work, but as before it fails when we try to call get
> the session bus via SessionBus() - it doesn't return a real object.
>
> I tried it with the code from Richard:
> using Qyoto;
> using System;
>
> class ListNames {
>
> public static void method2()
> {
> QDBusConnection bus = QDBusConnection.SessionBus();
> QDBusInterface dbus_iface = new
> QDBusInterface("org.freedesktop.DBus", "/org/freedesktop/DBus",
> "org.freedesktop.DBus", bus);
> QDBusMessage result = dbus_iface.Call("ListNames");
> QDBusMessage.MessageType mess = result.type();
> }
>
> public static int Main(string[] args) {
> new QCoreApplication(args);
>
> if (!QDBusConnection.SessionBus().IsConnected()) {
> Console.WriteLine("Cannot connect to the D-BUS session bus.\n" +
> "To start it, run:\n" +
> "\teval `dbus-launch --auto-syntax`\n");
> return 1;
> }
>
> method2();
> Qyoto.Qyoto.DeleteQApp();
> return 0;
> }
> }
>
> The line
> if (!QDBusConnection.SessionBus().IsConnected()) {
> gives the error
> Unhandled Exception: System.NullReferenceException: Object reference not
> set to an instance of an object
> at ListNames.Main (System.String[] args) [0x00000]
>
> I don't really know what goes wrong here, other static methods do work
> well. Any ideas?
Hmm, I've just tried it with some debugging messages and it works fine for me:
public static void method2()
{
Console.WriteLine("In method2");
QDBusConnection bus = QDBusConnection.SessionBus();
Console.WriteLine("In method2 bus: {0}", bus);
QDBusInterface dbus_iface = new
QDBusInterface("org.freedesktop.DBus", "/org/freedesktop/DBus",
"org.freedesktop.DBus", bus);
Console.WriteLine("In method2 dbus_iface: {0}", dbus_iface);
QDBusMessage result = dbus_iface.Call("ListNames");
Console.WriteLine("In method2 result: {0}", result);
QDBusMessage.MessageType mess = result.type();
Console.WriteLine("In method2 mess: {0}", mess);
}
mardigras rdale 553% mono listnames.exe
In method2
In method2 bus: Qyoto.QDBusConnection
In method2 dbus_iface: Qyoto.QDBusInterface
In method2 result: Qyoto.QDBusMessage
In method2 mess: ReplyMessage
Are you sure you have dbus running - does the c++ example work ok?
-- Richard
More information about the Kde-bindings
mailing list