[Kde-bindings] Qyoto DBUS

Arno Rehn arno at arnorehn.de
Wed Jan 10 16:25:13 UTC 2007


Am Mittwoch, 10. Januar 2007 16:24 schrieb Richard Dale:
> 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.
Same goes for me. ;-)

> 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.
These are only used when marshalling from an ArrayList to a QList<whatever>. I 
store the pointers to the C#-objects which are in the ArrayList in a 
QList<void*>. In C++ I iterate through the list and first get the 
smokeqyoto_objects with value_object_info and then the underlying real 
Qt-object. Couldn't think of a better solution.

> > 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?

DBus is running and the C++ example works perfectly. I have no clue why it 
doesn't work in C#. It doesn't even come as far as method2(). It gets stuck 
when trying to call QDBusConnection.SessionBus().IsConnected().
QDBusConnection.SessionBus() returns 'null'

-- 
Arno Rehn
arno at arnorehn.de



More information about the Kde-bindings mailing list