Messagelib

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

KDE's Doxygen guidelines are available online.