D-BUS interfaces and whatnot (Re: KDE/kdebase/konqueror/settings/performance)

Richard Dale Richard_Dale at tipitina.demon.co.uk
Wed Jun 7 19:22:09 BST 2006


On Wednesday 07 June 2006 18:42, Thiago Macieira wrote:
> >Is it possible to come up
> >with a simpler equivalent to dbus-send for normal humans?
>
> It's called "dbus" and it's part of QtDBus.
>
> It works just like the "dcop" tool, which means that it looks into what
> you want to call in order to convert the arguments. If you have 47 and
> you're trying to call a method that takes a QString, it'll send as a
> string.
>
> If you have "hello world" and the method takes a QByteArray, it'll be sent
> as a byte array.
>
> If you write "abc" or 65.32 and the method takes an int, the conversion
> will probably fail and no call will be placed.
Yes, that looks good. It expects:
dbus <service> <path> <interface> <member> arg(s)

So I've tried the following:

./dbus :1.88 /MyWidget org.kde.MyWidget mySlot hello
gives:
 Interface 'org.kde' not available in object / at :1.88:

and

./dbus :1.88 / org.kde.MyWidget mySlot hello
gives:
Cannot find 'org.kde.MyWidget' in object /MyWidget at :1.88

I can invoke the slot fine from kdbus. This is my simple test app:

require 'Qt'
class MyWidget < Qt::PushButton
    q_classinfo("D-Bus Interface", "org.kde.MyWidget")
    slots 'mySlot(QString)'
                
    def initialize(parent, name)
        super
        Qt::DBus.sessionBus.registerObject("/", self, 
Qt::DBusConnection::ExportSlots)
    end
    
    def mySlot(greeting)
        puts "greeting: #{greeting}"
    end
end

a = Qt::Application.new(ARGV)
slottest = MyWidget.new('Hello dbus', nil)
slottest.show
a.exec

What naming conventions should it be using. Should the q_classinfo/Q_CLASSINFO 
specifiy 'org.kde.<appname>.MyWidget' ? Am I supposed to call 
registerObject() with a "/" or "/MyWidget" or "/<appname>/MyWidget" path? I 
can't seem to quite get a grip on it.

-- Richard




More information about the kde-core-devel mailing list