PDA

View Full Version : DBus service name



charlesf
29th April 2009, 16:14
Hello everyone !

I'm writing a little DBus driven standalone progress bar, something like KDialog's progress bar.

The point would be to run a new bar from an application, getting its DBus reference through stdin and driving it from the mother application.

Each time I'm running a new bar, a new DBus service name is created. The names are :1.10, :1.11, :1.12, etc.

How to get this service name at registration time (so I could write it to stdout) ? The way the adaptor object is registered


QDBusConnection::sessionBus().registerObject( "/", &bar )

doesn't return the service name. Should I use QDBusConnection::registerService ? But what if I need to run several bar at the same time ?

Thank you very much !

wysota
29th April 2009, 16:32
Should I use QDBusConnection::registerService ?
Yes.


But what if I need to run several bar at the same time ?
That's what the object names are for. You'll have different objects for different instances of the progress bar.

charlesf
29th April 2009, 16:40
That's what the object names are for. You'll have different objects for different instances of the progress bar.

It makes totally sense. My problem being that I don't know how to get the name of my newly created object.

charlesf
29th April 2009, 16:52
I might have found the answer : QDBusConnection::sessionBus().interface() emits the signal serviceRegistered( const QString& ) when a new service is registered.

wysota
29th April 2009, 22:48
My problem being that I don't know how to get the name of my newly created object.

QDBusConnection::registerObject() takes a path to the object. The last part of the path is the object name.

charlesf
30th April 2009, 09:48
I know my object name, of course. But I don't know the service name at registration time. QDBusConnection::sessionBus().interface()->serviceRegistered( const QString& ) works for me anyway.

wysota
4th May 2009, 07:53
QDBusConnection::registerService() takes a string argument where you can pass the service name.