Commit d0e16c52 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Add support for reply email

parent 02ded2bb
Pipeline #67944 passed with stage
in 23 minutes and 9 seconds
......@@ -2011,6 +2011,37 @@ void KMKernel::reloadFolderArchiveConfig()
mFolderArchiveManager->reloadConfig();
}
bool KMKernel::replyMail(qint64 serialNumber, bool replyToAll)
{
KMMainWidget *mainWidget = nullptr;
// First look for a KMainWindow.
const auto lst = KMainWindow::memberList();
for (KMainWindow *window : lst) {
// Then look for a KMMainWidget.
QList<KMMainWidget *> l = window->findChildren<KMMainWidget *>();
if (!l.isEmpty() && l.first()) {
mainWidget = l.first();
if (window->isActiveWindow()) {
break;
}
}
}
if (mainWidget) {
auto job = new Akonadi::ItemFetchJob(Akonadi::Item(serialNumber), this);
job->fetchScope().fetchFullPayload();
job->fetchScope().setAncestorRetrieval(Akonadi::ItemFetchScope::Parent);
if (job->exec()) {
if (job->items().count() >= 1) {
const auto item = job->items().at(0);
mainWidget->replyMessageTo(item, replyToAll);
return true;
}
}
}
return false;
}
void KMKernel::slotCollectionChanged(const Akonadi::Collection &, const QSet<QByteArray> &set)
{
if (set.contains("newmailnotifierattribute")) {
......
......@@ -333,6 +333,8 @@ public Q_SLOTS:
Q_SCRIPTABLE void reloadFolderArchiveConfig();
Q_SCRIPTABLE bool replyMail(qint64 serialNumber, bool replyToAll);
/**
* End of D-Bus callable stuff
*/
......
......@@ -4682,18 +4682,11 @@ void KMMainWidget::slotRedirectCurrentMessage()
}
}
void KMMainWidget::replyCurrentMessageCommand(MessageComposer::ReplyStrategy strategy)
void KMMainWidget::replyMessageTo(const Akonadi::Item &item, bool replyToAll)
{
if (messageView() && messageView()->viewer()) {
Akonadi::Item currentItem = messageView()->viewer()->messageItem();
if (!currentItem.hasPayload<KMime::Message::Ptr>()) {
return;
}
const QString text = messageView()->copyText();
auto command = new KMReplyCommand(this, currentItem, strategy, text);
command->setReplyAsHtml(messageView()->htmlMail());
command->start();
}
auto command = new KMReplyCommand(this, item, replyToAll ? MessageComposer::ReplyAll : MessageComposer::ReplyAuthor);
command->setReplyAsHtml(messageView()->htmlMail());
command->start();
}
void KMMainWidget::slotReplyMessageTo(const KMime::Message::Ptr &message, bool replyToAll)
......@@ -4702,9 +4695,7 @@ void KMMainWidget::slotReplyMessageTo(const KMime::Message::Ptr &message, bool r
item.setPayload<KMime::Message::Ptr>(message);
item.setMimeType(KMime::Message::mimeType());
auto command = new KMReplyCommand(this, item, replyToAll ? MessageComposer::ReplyAll : MessageComposer::ReplyAuthor);
command->setReplyAsHtml(messageView()->htmlMail());
command->start();
replyMessageTo(item, replyToAll);
}
void KMMainWidget::showMessageActivities(const QString &str)
......
......@@ -185,6 +185,7 @@ public:
void clearPluginActions();
void replyMessageTo(const Akonadi::Item &item, bool replyToAll);
public Q_SLOTS:
/**
......@@ -526,7 +527,6 @@ private:
void showMessageActivities(const QString &str);
void slotPageIsScrolledToBottom(bool isAtBottom);
void printCurrentMessage(bool preview);
void replyCurrentMessageCommand(MessageComposer::ReplyStrategy strategy);
void setupUnifiedMailboxChecker();
QAction *filterToAction(MailCommon::MailFilter *filter);
Q_REQUIRED_RESULT Akonadi::Collection::List applyFilterOnCollection(bool recursive);
......
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