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 <QList>
14 #include <QStringList>
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 class ItipPart;
30 
31 /**
32  * @brief The Composer class
33  */
34 class MESSAGECOMPOSER_EXPORT Composer : public JobBase
35 {
36  Q_OBJECT
37 
38 public:
39  explicit Composer(QObject *parent = nullptr);
40  ~Composer() override;
41 
42  [[nodiscard]] QList<KMime::Message::Ptr> resultMessages() const;
43 
44  [[nodiscard]] GlobalPart *globalPart() const;
45  [[nodiscard]] InfoPart *infoPart() const;
46  [[nodiscard]] TextPart *textPart() const;
47  [[nodiscard]] ItipPart *itipPart() const;
48  void clearTextPart();
49  void clearItipPart();
50  [[nodiscard]] MessageCore::AttachmentPart::List attachmentParts() const;
51  void addAttachmentPart(MessageCore::AttachmentPart::Ptr part, bool autoresizeImage = false);
52  void addAttachmentParts(const MessageCore::AttachmentPart::List &parts, bool autoresizeImage = false);
53  void removeAttachmentPart(MessageCore::AttachmentPart::Ptr part);
54 
55  // if the message and attachments should not be encrypted regardless of settings
56  void setNoCrypto(bool noCrypto);
57  void setSignAndEncrypt(const bool doSign, const bool doEncrypt);
58  void setMessageCryptoFormat(Kleo::CryptoMessageFormat format);
59  void setSigningKeys(const std::vector<GpgME::Key> &signers);
60  void setEncryptionKeys(const QList<QPair<QStringList, std::vector<GpgME::Key>>> &data);
61 
62  void setAutocryptEnabled(bool autocryptEnabled);
63  void setSenderEncryptionKey(const GpgME::Key &senderKey);
64 
65  void setGnupgHome(const QString &path);
66  [[nodiscard]] QString gnupgHome() const;
67 
68  /// Sets if this message being composed is an auto-saved message
69  /// if so, might need different handling, such as no crypto attachments.
70  void setAutoSave(bool isAutoSave);
71  [[nodiscard]] bool autoSave() const;
72 
73  [[nodiscard]] bool finished() const;
74 
75 public Q_SLOTS:
76  void start() override;
77 
78 protected Q_SLOTS:
79  void slotResult(KJob *job) override;
80 
81 private:
82  Q_DECLARE_PRIVATE(Composer)
83 
84  Q_PRIVATE_SLOT(d_func(), void doStart())
85  Q_PRIVATE_SLOT(d_func(), void contentJobFinished(KJob *))
86  Q_PRIVATE_SLOT(d_func(), void attachmentsFinished(KJob *))
87 };
88 }
Simple interface that both EncryptJob and SignEncryptJob implement so the composer can extract some e...
Q_SCRIPTABLE Q_NOREPLY void start()
The Composer class.
Definition: composer.h:34
A dummy abstract class defining some errors pertaining to the Composer.
Definition: jobbase.h:24
The GlobalPart class.
Definition: globalpart.h:19
The ItipPart class.
Definition: itippart.h:20
The InfoPart class contains the message header.
Definition: infopart.h:21
The TextPart class.
Definition: textpart.h:20
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sat Dec 9 2023 03:55:27 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.