From 05a7f93b38732b2ce1282980452a122efbd0834e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Vr=C3=A1til?= Date: Wed, 13 May 2020 09:44:28 +0200 Subject: [PATCH] Allow creating Followup reminders through a DBus call to the agent Summary: The idea is for the client code to use this DBus method rather than writing to a shared config file and triggering reload. This way it will be possible to get rid of the intermediate libKF5FollowUpReminder library in kdepim-apps-libs. Reviewers: mlaurent Reviewed By: mlaurent Subscribers: kde-pim Tags: #kde_pim Differential Revision: https://phabricator.kde.org/D29622 --- .../followupreminderagent.cpp | 15 +++++++++++++++ .../followupreminderagent/followupreminderagent.h | 1 + .../followupremindermanager.cpp | 9 +++++++++ .../followupremindermanager.h | 1 + .../org.freedesktop.Akonadi.FollowUpReminder.xml | 9 +++++++++ 5 files changed, 35 insertions(+) diff --git a/agents/followupreminderagent/followupreminderagent.cpp b/agents/followupreminderagent/followupreminderagent.cpp index 43c75942b..73b1d904c 100644 --- a/agents/followupreminderagent/followupreminderagent.cpp +++ b/agents/followupreminderagent/followupreminderagent.cpp @@ -22,6 +22,8 @@ #include #include "followupreminderadaptor.h" #include "followupreminderagentsettings.h" +#include + #include #include @@ -115,6 +117,19 @@ void FollowUpReminderAgent::reload() } } +void FollowUpReminderAgent::addReminder(const QString &messageId, Akonadi::Item::Id messageItemId, const QString &to, const QString &subject, const QDate &followupDate, Akonadi::Item::Id todoId) +{ + auto info = new FollowUpReminder::FollowUpReminderInfo(); + info->setMessageId(messageId); + info->setOriginalMessageItemId(messageItemId); + info->setTo(to); + info->setSubject(subject); + info->setFollowUpReminderDate(followupDate); + info->setTodoId(todoId); + + mManager->addReminder(info); +} + QString FollowUpReminderAgent::printDebugInfo() const { return mManager->printDebugInfo(); diff --git a/agents/followupreminderagent/followupreminderagent.h b/agents/followupreminderagent/followupreminderagent.h index df0704b92..b7d37865d 100644 --- a/agents/followupreminderagent/followupreminderagent.h +++ b/agents/followupreminderagent/followupreminderagent.h @@ -36,6 +36,7 @@ public: public Q_SLOTS: void reload(); + void addReminder(const QString &messageId, Akonadi::Item::Id messageItemId, const QString &to, const QString &subject, const QDate &followupDate, Akonadi::Item::Id todoId); protected: void itemAdded(const Akonadi::Item &item, const Akonadi::Collection &collection) override; diff --git a/agents/followupreminderagent/followupremindermanager.cpp b/agents/followupreminderagent/followupremindermanager.cpp index 7c7bad8e5..8974e387e 100644 --- a/agents/followupreminderagent/followupremindermanager.cpp +++ b/agents/followupreminderagent/followupremindermanager.cpp @@ -85,6 +85,15 @@ void FollowUpReminderManager::load(bool forceReloadConfig) } } +void FollowUpReminderManager::addReminder(FollowUpReminder::FollowUpReminderInfo *info) +{ + if (info->isValid()) { + FollowUpReminderUtil::writeFollowupReminderInfo(FollowUpReminderUtil::defaultConfig(), info, true); + } else { + delete info; + } +} + void FollowUpReminderManager::slotReparseConfiguration() { load(true); diff --git a/agents/followupreminderagent/followupremindermanager.h b/agents/followupreminderagent/followupremindermanager.h index 934f6505b..a847e2a3d 100644 --- a/agents/followupreminderagent/followupremindermanager.h +++ b/agents/followupreminderagent/followupremindermanager.h @@ -36,6 +36,7 @@ public: ~FollowUpReminderManager(); void load(bool forceReloadConfig = false); + void addReminder(FollowUpReminder::FollowUpReminderInfo *reminder); // takes ownership void checkFollowUp(const Akonadi::Item &item, const Akonadi::Collection &col); Q_REQUIRED_RESULT QString printDebugInfo() const; diff --git a/agents/followupreminderagent/org.freedesktop.Akonadi.FollowUpReminder.xml b/agents/followupreminderagent/org.freedesktop.Akonadi.FollowUpReminder.xml index 435279db7..0fde523c1 100644 --- a/agents/followupreminderagent/org.freedesktop.Akonadi.FollowUpReminder.xml +++ b/agents/followupreminderagent/org.freedesktop.Akonadi.FollowUpReminder.xml @@ -11,5 +11,14 @@ + + + + + + + + +