[Kde-pim] Re: dbus and pim 4.6 only on second try
Ingo Klöcker
kloecker at kde.org
Sun Apr 24 17:29:59 BST 2011
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.
Regards,
Ingo
>
> Thanks, Gerd
>
> void KOrganizerAppletUtil::showEvent(const QString &uid)
> {
> checkAndLaunchKontact();
>
> OrgKdeKorganizerKorganizerInterface
> interface("org.kde.korganizer", "/Korganizer",
> QDBusConnection::sessionBus()); interface.showIncidence(uid);
> KOrganizerAppletUtil::showMainWindow();
> }
>
> void KOrganizerAppletUtil::showMainWindow()
> {
> QDBusInterface kontactInterface("org.kde.korganizer",
> "/kontact/MainWindow_1",
> "org.kde.KMainWindow",
> QDBusConnection::sessionBus());
> QDBusReply<long> kontactWinId = kontactInterface.call("winId");
>
> KWindowSystem::forceActiveWindow (kontactWinId, 1);
> }
>
> void KOrganizerAppletUtil::checkAndLaunchKontact()
> {
>
> if(!QDBusConnection::sessionBus().interface()->isServiceRegistered("
> org.kde.korganizer")) {
> KToolInvocation::kdeinitExecWait("korganizer");
> }
> }
> _______________________________________________
> 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/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-pim/attachments/20110424/40eb0304/attachment.sig>
-------------- next part --------------
_______________________________________________
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