[Kde-pim] Re: dbus and pim 4.6 only on second try

David Jarvie djarvie at kde.org
Mon Apr 25 09:35:53 BST 2011


On Sun, April 24, 2011 5:29 pm, Ingo Klöcker wrote:
> On Friday 22 April 2011, Gerd Fleischer wrote:
>> Hi,
>>
>> I have a little problem with dbus and kdepim 4.6:
>>
>> I try to call korganizer to open an event via dbus.
>> Works perfectly with the code below with kdepim 4.4.10 and KDE SC
>> 4.6.
>>
>> With pim 4.6 - if korganizer is not running already it is started but
>> the event is not opened, if korganizer is running already (like
>> called via dbus for second time) the event is opened as supposed?
>>
>> Also tried Akonadi::ItemId or korganizer uid.
>>
>> Any hints?
>
> Most likely, this is a timing problem.
>   KToolInvocation::kdeinitExecWait()
> does not do what you might think it does. It does not wait until the
> program is started or has registered with D-Bus, but it waits until the
> program has finished (or detached).
>
> In any case, you want to use
>   KToolInvocation::startServiceByDesktopName("korganizer")
> or
>   QDBusConnection::sessionBus().interface()-
>>startService("org.kde.korganizer")
>
> If you use startService() then you might have to connect to the
> serviceRegistered() signal of QDBusConnectionInterface to get notified
> when korganizer has registered with D-Bus.

One other thing to watch out for is that the korganizer interface which
you want to use may not be available immediately when korganizer registers
with D-Bus. There could be a short time lag before the application creates
a particular interface, so always check by calling isValid() on the
interface before trying to use it.

-- 
David Jarvie.
KDE developer.
KAlarm author - http://www.astrojar.org.uk/kalarm

_______________________________________________
KDE PIM mailing list kde-pim at kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
KDE PIM home page at http://pim.kde.org/



More information about the kde-pim mailing list