[Kde-bindings] Qyoto D-Bus

Richard Dale rdale at foton.es
Thu Oct 19 11:55:25 UTC 2006


On Thursday 19 October 2006 12:37, Arno Rehn wrote:
> Am Donnerstag, 19. Oktober 2006 00:32 schrieb Richard Dale:
> > I've updated the QDBus* classes, so we can experiment with getting DBus
> > to work. If Q_CLASSINFO and Q_SCRIPTABLE are working, and the details are
> > going into the QMetaObject then QDBus slots should 'just work'.
> > QDBusAbstractInterface.Call() should work ok too - just give the method
> > name as a string, and wrap each arg in a QVariant to call a D-Bus method.
>
> Uhm, first there seem to be other problems to solve. I've roughly converted
> the "listnames" example to C# and that doesn't rely on Q_CLASSINFO or
> Q_SCRIPTABLE at all. The example is attached. QDBusConnection.SessionBus()
> doesn't return a reference to an object and I think we need QDBusReply to
> get it working.
Snap! That was what I was doing last night too - here is my version:

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;
    }
}

I need to fix a bug in returning Enums for the 'result.type()' call to work, 
but it does return a 'ReplyMessage' which means the call has worked. We need 
to be able to marshall the 'QList<QVariant>' that QDbusMessage.Arguments() 
returns in order to get the QVariant that contains the QStringList with the 
reply. Then we need to be able to marshall the QStringList to an ArrayList of 
strings for the list of services. So I've added some non-working code in 
handlers.cpp to do that. We need to have callbacks to C# to create an 
ArrayList, and then another callback to add items to it.

-- Richard



More information about the Kde-bindings mailing list