Verified Commit 05a7f93b authored by Daniel Vrátil's avatar Daniel Vrátil 🤖
Browse files

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
parent 64e2f082
...@@ -22,6 +22,8 @@ ...@@ -22,6 +22,8 @@
#include <FollowupReminder/FollowUpReminderUtil> #include <FollowupReminder/FollowUpReminderUtil>
#include "followupreminderadaptor.h" #include "followupreminderadaptor.h"
#include "followupreminderagentsettings.h" #include "followupreminderagentsettings.h"
#include <FollowupReminder/FollowUpReminderInfo>
#include <KMime/Message> #include <KMime/Message>
#include <AkonadiCore/ChangeRecorder> #include <AkonadiCore/ChangeRecorder>
...@@ -115,6 +117,19 @@ void FollowUpReminderAgent::reload() ...@@ -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 QString FollowUpReminderAgent::printDebugInfo() const
{ {
return mManager->printDebugInfo(); return mManager->printDebugInfo();
......
...@@ -36,6 +36,7 @@ public: ...@@ -36,6 +36,7 @@ public:
public Q_SLOTS: public Q_SLOTS:
void reload(); 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: protected:
void itemAdded(const Akonadi::Item &item, const Akonadi::Collection &collection) override; void itemAdded(const Akonadi::Item &item, const Akonadi::Collection &collection) override;
......
...@@ -85,6 +85,15 @@ void FollowUpReminderManager::load(bool forceReloadConfig) ...@@ -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() void FollowUpReminderManager::slotReparseConfiguration()
{ {
load(true); load(true);
......
...@@ -36,6 +36,7 @@ public: ...@@ -36,6 +36,7 @@ public:
~FollowUpReminderManager(); ~FollowUpReminderManager();
void load(bool forceReloadConfig = false); void load(bool forceReloadConfig = false);
void addReminder(FollowUpReminder::FollowUpReminderInfo *reminder); // takes ownership
void checkFollowUp(const Akonadi::Item &item, const Akonadi::Collection &col); void checkFollowUp(const Akonadi::Item &item, const Akonadi::Collection &col);
Q_REQUIRED_RESULT QString printDebugInfo() const; Q_REQUIRED_RESULT QString printDebugInfo() const;
......
...@@ -11,5 +11,14 @@ ...@@ -11,5 +11,14 @@
<arg type="s" direction="out"/> <arg type="s" direction="out"/>
</method> </method>
<method name="reload" /> <method name="reload" />
<method name="addReminder">
<arg name="messageId" type="s" direction="in" />
<arg name="originalMessageItemId" type="x" direction="in" />
<arg name="to" type="s" direction="in" />
<arg name="subject" type="s" direction="in" />
<arg name="followupDate" type="(iii)" direction="in" />
<annotation name="org.qtproject.QtDBus.QtTypeName.In4" value="QDate" />
<arg name="todoId" type="x" direction="in" />
</method>
</interface> </interface>
</node> </node>
Markdown is supported
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