Messagelib

messagefactoryforwardjob.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 "messagefactoryforwardjob.h"
8 #include "settings/messagecomposersettings.h"
9 #include <KIdentityManagement/IdentityManager>
10 #include <TemplateParser/TemplateParserJob>
11 
12 using namespace MessageComposer;
13 
14 MessageFactoryForwardJob::MessageFactoryForwardJob(QObject *parent)
15  : QObject(parent)
16 {
17 }
18 
19 MessageFactoryForwardJob::~MessageFactoryForwardJob() = default;
20 
21 void MessageFactoryForwardJob::start()
22 {
23  auto parser = new TemplateParser::TemplateParserJob(mMsg, TemplateParser::TemplateParserJob::Forward, this);
24  connect(parser, &TemplateParser::TemplateParserJob::parsingDone, this, &MessageFactoryForwardJob::slotParsingDone);
25  connect(parser, &TemplateParser::TemplateParserJob::parsingFailed, this, &MessageFactoryForwardJob::slotParsingDone);
26  parser->setIdentityManager(mIdentityManager);
27  parser->setCharsets(MessageComposerSettings::self()->preferredCharsets());
28  parser->setSelection(mSelection);
29  if (!mTemplate.isEmpty()) {
30  parser->process(mTemplate, mOrigMsg);
31  } else {
32  parser->process(mOrigMsg, mCollection.id());
33  }
34 }
35 
36 void MessageFactoryForwardJob::slotParsingDone()
37 {
38  Q_EMIT forwardDone(mMsg);
39  deleteLater();
40 }
41 
42 void MessageFactoryForwardJob::setCollection(const Akonadi::Collection &collection)
43 {
44  mCollection = collection;
45 }
46 
47 void MessageFactoryForwardJob::setMsg(const KMime::Message::Ptr &msg)
48 {
49  mMsg = msg;
50 }
51 
52 void MessageFactoryForwardJob::setTemplate(const QString &tmpl)
53 {
54  mTemplate = tmpl;
55 }
56 
57 void MessageFactoryForwardJob::setSelection(const QString &selection)
58 {
59  mSelection = selection;
60 }
61 
62 void MessageFactoryForwardJob::setOrigMsg(const KMime::Message::Ptr &origMsg)
63 {
64  mOrigMsg = origMsg;
65 }
66 
67 void MessageFactoryForwardJob::setIdentityManager(KIdentityManagement::IdentityManager *identityManager)
68 {
69  mIdentityManager = identityManager;
70 }
The TemplateParser transforms a message with a given template.
Simple interface that both EncryptJob and SignEncryptJob implement so the composer can extract some e...
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sat Dec 4 2021 23:12:53 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.