Commit 2962a5e3 authored by Volker Krause's avatar Volker Krause
Browse files

Add D-Bus interface for the new reminder daemon

parent bd32d5fe
Pipeline #136448 passed with stage
in 1 minute and 39 seconds
......@@ -296,6 +296,10 @@ qt_add_dbus_adaptor(korganizerprivate_LIB_SRCS
data/org.kde.Korganizer.Calendar.xml actionmanager.h
ActionManager calendaradaptor KOrgCalendarAdaptor
)
qt_add_dbus_adaptor(korganizerprivate_LIB_SRCS
data/org.kde.calendar.Calendar.xml actionmanager.h
ActionManager calendarinterfaceadaptor CalendarInterfaceAdaptor
)
qt_add_dbus_interfaces(korganizerprivate_LIB_SRCS
data/org.kde.korganizer.Korganizer.xml
......
......@@ -14,6 +14,7 @@
#include "actionmanager.h"
#include "akonadicollectionview.h"
#include "calendaradaptor.h"
#include "calendarinterfaceadaptor.h"
#include "calendarview.h"
#include "kocore.h"
#include "kodialogmanager.h"
......@@ -74,6 +75,7 @@
#include <QStandardPaths>
#include <QTimer>
#include <QToolBar>
#include <QWindow>
KOWindowList *ActionManager::mWindowList = nullptr;
......@@ -87,6 +89,9 @@ ActionManager::ActionManager(KXMLGUIClient *client,
: QObject(parent)
{
new KOrgCalendarAdaptor(this);
// reminder daemon interface
new CalendarInterfaceAdaptor(this);
QDBusConnection::sessionBus().registerObject(QStringLiteral("/Calendar"), this);
mGUIClient = client;
......@@ -1103,6 +1108,20 @@ bool ActionManager::showIncidenceContext(Akonadi::Item::Id id)
return mCalendarView->showIncidenceContext(id);
}
void ActionManager::showIncidenceByUid(const QString &uid, const QDateTime &occurrence, const QString &xdgActivationToken)
{
mCalendarView->showIncidenceByUid(uid);
mCalendarView->showDate(occurrence.date());
KWindowSystem::setCurrentXdgActivationToken(xdgActivationToken);
KOrg::MainWindow *mainWindow = ActionManager::findInstance(QUrl());
if (mainWindow) {
KWindowSystem::activateWindow(mainWindow->topLevelWidget()->windowHandle());
mainWindow->topLevelWidget()->show();
mainWindow->topLevelWidget()->windowHandle()->raise();
}
}
bool ActionManager::handleCommandLine(const QStringList &args)
{
QCommandLineParser parser;
......
......@@ -131,6 +131,12 @@ public:
*/
bool showIncidenceContext(Akonadi::Item::Id id);
/**
Show an incidence in context, given its uid.
@param uid the iCal uid of the incidence to show.
*/
void showIncidenceByUid(const QString &uid, const QDateTime &occurence, const QString &xdgActivationToken);
/**
* Called by KOrganizerUniqueAppHandler in the kontact plugin
* Returns true if the command line was successfully handled
......
......@@ -2110,6 +2110,15 @@ bool CalendarView::editIncidence(const Akonadi::Item &item, bool isCounter)
return true;
}
void CalendarView::showIncidenceByUid(const QString &uid)
{
const auto item = mCalendar->item(uid);
if (item.isValid()) {
showIncidenceContext(item);
mEventViewer->setIncidence(item);
}
}
void CalendarView::deleteIncidenceFamily(const Akonadi::Item &item)
{
const auto incidence = CalendarSupport::incidence(item);
......
......@@ -303,6 +303,12 @@ public Q_SLOTS:
void showIncidenceContext(const Akonadi::Item &incidence);
bool showIncidenceContext(Akonadi::Item::Id id);
/**
Show an incidence in context, given its uid.
@param uid the iCal uid of the incidence to show.
*/
void showIncidenceByUid(const QString &uid);
/** Create an editor for the supplied incidence. It calls the correct editXXX method*/
bool editIncidence(const Akonadi::Item &item, bool isCounter = false) override;
bool editIncidence(Akonadi::Item::Id id);
......
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<!--
SPDX-FileCopyrightText: 2021 Volker Krause <vkrause@kde.org>
SPDX-License-Identifier: LGPL-2.1-or-later
-->
<node>
<interface name="org.kde.calendar.Calendar">
<method name="showIncidenceByUid">
<arg name="uid" type="s" direction="in"/>
<arg name="occurrence" type="(iii)(iiii)i" direction="in"/>
<arg name="xdgActivationToken" type="s" direction="in"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.In1" value="QDateTime"/>
</method>
</interface>
</node>
......@@ -25,6 +25,8 @@
#include "korganizerplugin_debug.h"
#include <KActionCollection>
#include <KConfig>
#include <KConfigGroup>
#include <KLocalizedString>
#include <QAction>
#include <QIcon>
......@@ -51,6 +53,12 @@ KOrganizerPlugin::KOrganizerPlugin(KontactInterface::Core *core, const QVariantL
insertNewAction(action);
mUniqueAppWatcher = new KontactInterface::UniqueAppWatcher(new KontactInterface::UniqueAppHandlerFactory<KOrganizerUniqueAppHandler>(), this);
// information for the reminder daemon
KConfig cfg(QStringLiteral("defaultcalendarrc"));
KConfigGroup grp(&cfg, QStringLiteral("General"));
grp.writeEntry(QStringLiteral("ApplicationId"), QStringLiteral("org.kde.kontact"));
grp.writeEntry(QStringLiteral("KontactPlugin"), QStringLiteral("korganizer"));
}
KOrganizerPlugin::~KOrganizerPlugin() = default;
......
......@@ -15,6 +15,8 @@
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#include "korgmigrateapplication.h"
#endif
#include <KConfig>
#include <KConfigGroup>
#include <KCrash>
#include <KLocalizedString>
......@@ -61,5 +63,10 @@ int main(int argc, char **argv)
kRestoreMainWindows<KOrganizer>();
}
// information for the reminder daemon
KConfig cfg(QStringLiteral("defaultcalendarrc"));
KConfigGroup grp(&cfg, QStringLiteral("General"));
grp.writeEntry(QStringLiteral("ApplicationId"), QStringLiteral("org.kde.korganizer"));
return app.exec();
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment