Messagelib

composer.h
1 /*
2  SPDX-FileCopyrightText: 2009 Constantin Berzan <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #pragma once
8 
9 #include "MessageComposer/JobBase"
10 #include <Libkleo/Enum>
11 
12 #include "messagecomposer_export.h"
13 #include <QStringList>
14 #include <QVector>
15 
16 #include <KMime/KMimeMessage>
17 
18 #include <MessageCore/AttachmentPart>
19 
20 #include <gpgme++/key.h>
21 #include <vector>
22 
23 namespace MessageComposer
24 {
25 class ComposerPrivate;
26 class GlobalPart;
27 class InfoPart;
28 class TextPart;
29 
30 /**
31  * @brief The Composer class
32  */
33 class MESSAGECOMPOSER_EXPORT Composer : public JobBase
34 {
35  Q_OBJECT
36 
37 public:
38  explicit Composer(QObject *parent = nullptr);
39  ~Composer() override;
40 
41  Q_REQUIRED_RESULT QVector<KMime::Message::Ptr> resultMessages() const;
42 
43  Q_REQUIRED_RESULT GlobalPart *globalPart() const;
44  Q_REQUIRED_RESULT InfoPart *infoPart() const;
45  Q_REQUIRED_RESULT TextPart *textPart() const;
46  Q_REQUIRED_RESULT MessageCore::AttachmentPart::List attachmentParts() const;
47  void addAttachmentPart(MessageCore::AttachmentPart::Ptr part, bool autoresizeImage = false);
48  void addAttachmentParts(const MessageCore::AttachmentPart::List &parts, bool autoresizeImage = false);
49  void removeAttachmentPart(MessageCore::AttachmentPart::Ptr part);
50 
51  // if the message and attachments should not be encrypted regardless of settings
52  void setNoCrypto(bool noCrypto);
53  void setSignAndEncrypt(const bool doSign, const bool doEncrypt);
54  void setMessageCryptoFormat(Kleo::CryptoMessageFormat format);
55  void setSigningKeys(const std::vector<GpgME::Key> &signers);
56  void setEncryptionKeys(const QVector<QPair<QStringList, std::vector<GpgME::Key>>> &data);
57 
58  void setAutocryptEnabled(bool autocryptEnabled);
59  void setSenderEncryptionKey(const GpgME::Key &senderKey);
60 
61  void setGnupgHome(const QString &path);
62  Q_REQUIRED_RESULT QString gnupgHome() const;
63 
64  /// Sets if this message being composed is an auto-saved message
65  /// if so, might need different handling, such as no crypto attachments.
66  void setAutoSave(bool isAutoSave);
67  Q_REQUIRED_RESULT bool autoSave() const;
68 
69  Q_REQUIRED_RESULT bool finished() const;
70 
71 public Q_SLOTS:
72  void start() override;
73 
74 protected Q_SLOTS:
75  void slotResult(KJob *job) override;
76 
77 private:
78  Q_DECLARE_PRIVATE(Composer)
79 
80  Q_PRIVATE_SLOT(d_func(), void doStart())
81  Q_PRIVATE_SLOT(d_func(), void contentJobFinished(KJob *))
82  Q_PRIVATE_SLOT(d_func(), void attachmentsFinished(KJob *))
83 };
84 }
85 
The GlobalPart class.
Definition: globalpart.h:19
The Composer class.
Definition: composer.h:33
Simple interface that both EncryptJob and SignEncryptJob implement so the composer can extract some e...
The InfoPart class contains the message header.
Definition: infopart.h:21
A dummy abstract class defining some errors pertaining to the Composer.
Definition: jobbase.h:24
The TextPart class.
Definition: textpart.h:20
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Mon Dec 6 2021 23:04:56 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.