Messagelib

dkimgeneraterulejob.cpp
1 /*
2  SPDX-FileCopyrightText: 2019-2021 Laurent Montel <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #include "dkimgeneraterulejob.h"
8 #include "dkimmanagerrules.h"
9 #include "messageviewer_debug.h"
10 using namespace MessageViewer;
11 
12 DKIMGenerateRuleJob::DKIMGenerateRuleJob(QObject *parent)
13  : QObject(parent)
14 {
15 }
16 
17 DKIMGenerateRuleJob::~DKIMGenerateRuleJob() = default;
18 
19 bool DKIMGenerateRuleJob::canStart() const
20 {
21  if (!mResult.isValid()) {
22  qCWarning(MESSAGEVIEWER_LOG) << "Rule is not valid";
23  return false;
24  }
25  return true;
26 }
27 
28 bool DKIMGenerateRuleJob::start()
29 {
30  if (!canStart()) {
31  deleteLater();
32  qCWarning(MESSAGEVIEWER_LOG) << "Impossible to start DKIMGenerateRuleJob";
33  return false;
34  }
35  verifyAndGenerateRule();
36  return true;
37 }
38 
39 void DKIMGenerateRuleJob::verifyAndGenerateRule()
40 {
41  DKIMRule rule;
42  rule.setEnabled(true);
43  rule.setFrom(mResult.fromEmail);
44  // TODO add Domain when we create a rule from base domain.
45  rule.setSignedDomainIdentifier(QStringList() << mResult.sdid);
46  rule.setRuleType(DKIMRule::RuleType::MustBeSigned);
47  deleteLater();
48 }
49 
50 DKIMCheckSignatureJob::CheckSignatureResult DKIMGenerateRuleJob::result() const
51 {
52  return mResult;
53 }
54 
55 void DKIMGenerateRuleJob::setResult(const DKIMCheckSignatureJob::CheckSignatureResult &checkResult)
56 {
57  mResult = checkResult;
58 }
void deleteLater()
The DKIMRule class.
Definition: dkimrule.h:17
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sun Dec 5 2021 23:04:53 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.