diff --git a/plugins/messageviewer/bodypartformatter/semantic/CMakeLists.txt b/plugins/messageviewer/bodypartformatter/semantic/CMakeLists.txt --- a/plugins/messageviewer/bodypartformatter/semantic/CMakeLists.txt +++ b/plugins/messageviewer/bodypartformatter/semantic/CMakeLists.txt @@ -11,6 +11,7 @@ add_library(messageviewer_bodypartformatter_semantic MODULE ${semantic_plugin_srcs}) target_compile_definitions(messageviewer_bodypartformatter_semantic PRIVATE -DTRANSLATION_DOMAIN=\"messageviewer_semantic_plugin\") target_link_libraries(messageviewer_bodypartformatter_semantic + KF5::KontactInterface KF5::MessageViewer KF5::CalendarSupport KF5::I18n diff --git a/plugins/messageviewer/bodypartformatter/semantic/semanticurlhandler.cpp b/plugins/messageviewer/bodypartformatter/semantic/semanticurlhandler.cpp --- a/plugins/messageviewer/bodypartformatter/semantic/semanticurlhandler.cpp +++ b/plugins/messageviewer/bodypartformatter/semantic/semanticurlhandler.cpp @@ -43,7 +43,7 @@ #include -#include +#include #include #include @@ -288,30 +288,18 @@ void SemanticUrlHandler::showCalendar(const QDate &date) const { // ensure KOrganizer or Kontact are running - QString error, dbusService; - const auto result = KDBusServiceStarter::self()->findServiceFor(QStringLiteral("DBUS/Organizer"), {}, &error, &dbusService) == 0; - if (!result) { - qCWarning(SEMANTIC_LOG) << "Failed to start KOrganizer" << error << dbusService; - } - - // switch to KOrganizer if we are using Kontact - std::unique_ptr kontactIface( - new QDBusInterface(QStringLiteral("org.kde.kontact"), QStringLiteral("/KontactInterface"), - QStringLiteral("org.kde.kontact.KontactInterface"), QDBusConnection::sessionBus())); - if (kontactIface->isValid()) { - kontactIface->call(QStringLiteral("selectPlugin"), QStringLiteral("kontact_korganizerplugin")); - } + if (KontactInterface::PimUniqueApplication::activateApplication(QLatin1String("korganizer"))) { - // select the date of the reservation - std::unique_ptr korgIface( - new QDBusInterface(QStringLiteral("org.kde.korganizer"), QStringLiteral("/Calendar"), - QStringLiteral("org.kde.Korganizer.Calendar"), QDBusConnection::sessionBus())); - if (!korgIface->isValid()) { - qCWarning(SEMANTIC_LOG) << "Calendar interface is not valid! " << korgIface->lastError().message(); - return; + // select the date of the reservation + QDBusInterface korgIface(QStringLiteral("org.kde.korganizer"), QStringLiteral("/Calendar"), + QStringLiteral("org.kde.Korganizer.Calendar"), QDBusConnection::sessionBus()); + if (!korgIface.isValid()) { + qCWarning(SEMANTIC_LOG) << "Calendar interface is not valid! " << korgIface.lastError().message(); + return; + } + korgIface.call(QStringLiteral("showEventView")); + korgIface.call(QStringLiteral("showDate"), date); } - korgIface->call(QStringLiteral("showEventView")); - korgIface->call(QStringLiteral("showDate"), date); } static void attachPass(const KCalCore::Event::Ptr &event, const QVector &reservations, SemanticMemento *memento)