Messagelib

messagefactoryreplyjob.cpp
1/*
2 SPDX-FileCopyrightText: 2017-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "messagefactoryreplyjob.h"
8#include "settings/messagecomposersettings.h"
9#include <TemplateParser/TemplateParserJob>
10
11using namespace MessageComposer;
12
13MessageFactoryReplyJob::MessageFactoryReplyJob(QObject *parent)
14 : QObject(parent)
15{
16}
17
18MessageFactoryReplyJob::~MessageFactoryReplyJob() = default;
19
20void MessageFactoryReplyJob::start()
21{
22 auto parser =
23 new TemplateParser::TemplateParserJob(mMsg, (mReplyAll ? TemplateParser::TemplateParserJob::ReplyAll : TemplateParser::TemplateParserJob::Reply), this);
24 connect(parser, &TemplateParser::TemplateParserJob::parsingDone, this, &MessageFactoryReplyJob::slotReplyDone);
25 connect(parser, &TemplateParser::TemplateParserJob::parsingFailed, this, &MessageFactoryReplyJob::slotReplyDone);
26 parser->setIdentityManager(mIdentityManager);
27 parser->setWordWrap(MessageComposerSettings::wordWrap(), MessageComposerSettings::lineWrapWidth());
28 parser->setReplyAsHtml(mReplyAsHtml);
29 if (MessageComposer::MessageComposerSettings::quoteSelectionOnly()) {
30 parser->setSelection(mSelection);
31 }
32 parser->setAllowDecryption(true);
33 if (!mTemplate.isEmpty()) {
34 parser->process(mTemplate, mOrigMsg);
35 } else {
36 parser->process(mOrigMsg, mCollection.id());
37 }
38}
39
40void MessageFactoryReplyJob::slotReplyDone()
41{
42 Q_EMIT replyDone(mMsg, mReplyAll);
44}
45
46void MessageFactoryReplyJob::setCollection(const Akonadi::Collection &collection)
47{
48 mCollection = collection;
49}
50
51void MessageFactoryReplyJob::setReplyAsHtml(bool replyAsHtml)
52{
53 mReplyAsHtml = replyAsHtml;
54}
55
56void MessageFactoryReplyJob::setReplyAll(bool replyAll)
57{
58 mReplyAll = replyAll;
59}
60
61void MessageFactoryReplyJob::setMsg(const KMime::Message::Ptr &msg)
62{
63 mMsg = msg;
64}
65
66void MessageFactoryReplyJob::setTemplate(const QString &tmpl)
67{
68 mTemplate = tmpl;
69}
70
71void MessageFactoryReplyJob::setSelection(const QString &selection)
72{
73 mSelection = selection;
74}
75
76void MessageFactoryReplyJob::setOrigMsg(const KMime::Message::Ptr &origMsg)
77{
78 mOrigMsg = origMsg;
79}
80
81void MessageFactoryReplyJob::setIdentityManager(KIdentityManagementCore::IdentityManager *identityManager)
82{
83 mIdentityManager = identityManager;
84}
85
86#include "moc_messagefactoryreplyjob.cpp"
The TemplateParser transforms a message with a given template.
Simple interface that both EncryptJob and SignEncryptJob implement so the composer can extract some e...
Q_EMITQ_EMIT
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
void deleteLater()
bool isEmpty() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:59:12 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.