Messagelib

messagefactoryreplyjob.cpp
1 /*
2  SPDX-FileCopyrightText: 2017-2021 Laurent Montel <[email protected]>
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 
11 using namespace MessageComposer;
12 
13 MessageFactoryReplyJob::MessageFactoryReplyJob(QObject *parent)
14  : QObject(parent)
15 {
16 }
17 
18 MessageFactoryReplyJob::~MessageFactoryReplyJob() = default;
19 
20 void 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->setCharsets(MessageComposerSettings::self()->preferredCharsets());
28  parser->setWordWrap(MessageComposerSettings::wordWrap(), MessageComposerSettings::lineWrapWidth());
29  parser->setReplyAsHtml(mReplyAsHtml);
30  if (MessageComposer::MessageComposerSettings::quoteSelectionOnly()) {
31  parser->setSelection(mSelection);
32  }
33  parser->setAllowDecryption(true);
34  if (!mTemplate.isEmpty()) {
35  parser->process(mTemplate, mOrigMsg);
36  } else {
37  parser->process(mOrigMsg, mCollection.id());
38  }
39 }
40 
41 void MessageFactoryReplyJob::slotReplyDone()
42 {
43  Q_EMIT replyDone(mMsg, mReplyAll);
44  deleteLater();
45 }
46 
47 void MessageFactoryReplyJob::setCollection(const Akonadi::Collection &collection)
48 {
49  mCollection = collection;
50 }
51 
52 void MessageFactoryReplyJob::setReplyAsHtml(bool replyAsHtml)
53 {
54  mReplyAsHtml = replyAsHtml;
55 }
56 
57 void MessageFactoryReplyJob::setReplyAll(bool replyAll)
58 {
59  mReplyAll = replyAll;
60 }
61 
62 void MessageFactoryReplyJob::setMsg(const KMime::Message::Ptr &msg)
63 {
64  mMsg = msg;
65 }
66 
67 void MessageFactoryReplyJob::setTemplate(const QString &tmpl)
68 {
69  mTemplate = tmpl;
70 }
71 
72 void MessageFactoryReplyJob::setSelection(const QString &selection)
73 {
74  mSelection = selection;
75 }
76 
77 void MessageFactoryReplyJob::setOrigMsg(const KMime::Message::Ptr &origMsg)
78 {
79  mOrigMsg = origMsg;
80 }
81 
82 void MessageFactoryReplyJob::setIdentityManager(KIdentityManagement::IdentityManager *identityManager)
83 {
84  mIdentityManager = identityManager;
85 }
bool replyAll
If true, the "reply all" template was used, otherwise the normal reply.
void deleteLater()
The TemplateParser transforms a message with a given template.
Simple interface that both EncryptJob and SignEncryptJob implement so the composer can extract some e...
KMime::Message::Ptr msg
The actual reply message.
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
Q_EMITQ_EMIT
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Fri Nov 26 2021 23:16:42 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.