1 /* 2 This file is part of KMail, the KDE mail client. 3 SPDX-FileCopyrightText: 1997 Markus Wuebben <markus.wuebben@kde.org> 4 5 SPDX-License-Identifier: GPL-2.0-or-later 6 */ 7 8 #pragma once 9 10 #include "kmail_export.h" 11 #include "secondarywindow.h" 12 13 #include <Akonadi/Collection> 14 #include <KMime/KMimeMessage> 15 #include <QUrl> 16 17 namespace KMime 18 { 19 class Content; 20 } 21 22 namespace KMail 23 { 24 class KMAIL_EXPORT Composer : public KMail::SecondaryWindow 25 { 26 Q_OBJECT 27 protected: 28 Composer(const QString &name = QString()) SecondaryWindow(name)29 : KMail::SecondaryWindow(name) 30 { 31 } 32 33 public: 34 enum TemplateContext { 35 New, 36 Reply, 37 ReplyToAll, 38 Forward, 39 NoTemplate, 40 }; 41 enum VisibleHeaderFlag { 42 HDR_FROM = 0x01, 43 HDR_REPLY_TO = 0x02, 44 HDR_SUBJECT = 0x20, 45 HDR_IDENTITY = 0x100, 46 HDR_TRANSPORT = 0x200, 47 HDR_FCC = 0x400, 48 HDR_DICTIONARY = 0x800, 49 HDR_ALL = 0xfff, 50 }; 51 using VisibleHeaderFlags = QFlags<VisibleHeaderFlag>; 52 53 struct AttachmentInfo { 54 QString comment; 55 QUrl url; 56 }; 57 58 public: // mailserviceimpl 59 /** 60 * From MailComposerIface 61 */ 62 virtual void send(int how) = 0; 63 virtual void addAttachmentsAndSend(const QList<QUrl> &urls, const QString &comment, int how) = 0; 64 virtual void addAttachment(const QVector<AttachmentInfo> &url, bool showWarning) = 0; 65 virtual void 66 addAttachment(const QString &name, KMime::Headers::contentEncoding cte, const QString &charset, const QByteArray &data, const QByteArray &mimeType) = 0; 67 68 public: // kmcommand 69 Q_REQUIRED_RESULT virtual QString dbusObjectPath() const = 0; 70 71 public: // kmkernel, kmcommands, callback 72 /** 73 * Set the message the composer shall work with. This discards 74 * previous messages without calling applyChanges() on them before. 75 */ 76 virtual void setMessage(const KMime::Message::Ptr &newMsg, 77 bool lastSignState = false, 78 bool lastEncryptState = false, 79 bool mayAutoSign = true, 80 bool allowDecryption = false, 81 bool isModified = false) = 0; 82 virtual void setCurrentTransport(int transportId) = 0; 83 84 virtual void setFcc(const QString &idString) = 0; 85 /** 86 * Returns @c true while the message composing is in progress. 87 */ 88 virtual bool isComposing() const = 0; 89 90 virtual void setAutoSaveFileName(const QString &fileName) = 0; 91 virtual void setCollectionForNewMessage(const Akonadi::Collection &folder) = 0; 92 93 virtual void addExtraCustomHeaders(const QMap<QByteArray, QString> &header) = 0; 94 95 virtual void showAndActivateComposer() = 0; 96 97 public: // kmcommand 98 /** 99 * If this folder is set, the original message is inserted back after 100 * canceling 101 */ 102 virtual void setFolder(const Akonadi::Collection &) = 0; 103 104 /** 105 * Sets the focus to the edit-widget and the cursor below the 106 * "On ... you wrote" line when hasMessage is true. 107 * Make sure you call this _after_ setMsg(). 108 */ 109 virtual void setFocusToEditor() = 0; 110 111 /** 112 * Sets the focus to the subject line edit. For use when creating a 113 * message to a known recipient. 114 */ 115 virtual void setFocusToSubject() = 0; 116 117 public: // callback 118 /** Disabled signing and encryption completely for this composer window. */ 119 virtual void setSigningAndEncryptionDisabled(bool v) = 0; 120 121 public Q_SLOTS: // kmkernel, callback 122 virtual void slotSendNow() = 0; 123 virtual void setModified(bool modified) = 0; 124 public Q_SLOTS: // kmkernel 125 virtual void autoSaveMessage(bool force = false) = 0; 126 127 public: // kmkernel 128 virtual void disableWordWrap() = 0; 129 130 virtual void forceDisableHtml() = 0; 131 132 virtual void disableForgottenAttachmentsCheck() = 0; 133 134 public: // kmcommand 135 /** 136 * Add an attachment to the list. 137 */ 138 virtual void addAttach(KMime::Content *msgPart) = 0; 139 }; 140 141 KMAIL_EXPORT Composer *makeComposer(const KMime::Message::Ptr &msg = KMime::Message::Ptr(), 142 bool lastSignState = false, 143 bool lastEncryptState = false, 144 Composer::TemplateContext context = Composer::NoTemplate, 145 uint identity = 0, 146 const QString &textSelection = QString(), 147 const QString &customTemplate = QString()); 148 } 149 150