File indexing completed on 2024-10-27 04:51:00

0001 /*
0002   This file is part of KMail, the KDE mail client.
0003   SPDX-FileCopyrightText: 1997 Markus Wuebben <markus.wuebben@kde.org>
0004 
0005   SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 #pragma once
0009 
0010 #include "kmail_export.h"
0011 #include "secondarywindow.h"
0012 
0013 #include <Akonadi/Collection>
0014 #include <KMime/KMimeMessage>
0015 #include <QUrl>
0016 
0017 namespace KMime
0018 {
0019 class Content;
0020 }
0021 
0022 namespace KMail
0023 {
0024 class KMAIL_EXPORT Composer : public KMail::SecondaryWindow
0025 {
0026     Q_OBJECT
0027 protected:
0028     Composer(const QString &name = QString())
0029         : KMail::SecondaryWindow(name)
0030     {
0031     }
0032 
0033 public:
0034     enum TemplateContext {
0035         New,
0036         Reply,
0037         ReplyToAll,
0038         Forward,
0039         NoTemplate,
0040     };
0041     enum VisibleHeaderFlag {
0042         HDR_FROM = 0x01,
0043         HDR_REPLY_TO = 0x02,
0044         HDR_SUBJECT = 0x20,
0045         HDR_IDENTITY = 0x100,
0046         HDR_TRANSPORT = 0x200,
0047         HDR_FCC = 0x400,
0048         HDR_DICTIONARY = 0x800,
0049         HDR_ALL = 0xfff,
0050     };
0051     using VisibleHeaderFlags = QFlags<VisibleHeaderFlag>;
0052 
0053     struct AttachmentInfo {
0054         QString comment;
0055         QUrl url;
0056     };
0057 
0058 public: // mailserviceimpl
0059     /**
0060      * From MailComposerIface
0061      */
0062     virtual void send(int how) = 0;
0063     virtual void addAttachmentsAndSend(const QList<QUrl> &urls, const QString &comment, int how) = 0;
0064     virtual void addAttachment(const QList<AttachmentInfo> &url, bool showWarning) = 0;
0065     virtual void
0066     addAttachment(const QString &name, KMime::Headers::contentEncoding cte, const QString &charset, const QByteArray &data, const QByteArray &mimeType) = 0;
0067 
0068 public: // kmcommand
0069     [[nodiscard]] virtual QString dbusObjectPath() const = 0;
0070 
0071 public: // kmkernel, kmcommands, callback
0072     /**
0073      * Set the message the composer shall work with. This discards
0074      * previous messages without calling applyChanges() on them before.
0075      */
0076     virtual void setMessage(const KMime::Message::Ptr &newMsg,
0077                             bool lastSignState = false,
0078                             bool lastEncryptState = false,
0079                             bool mayAutoSign = true,
0080                             bool allowDecryption = false,
0081                             bool isModified = false) = 0;
0082     virtual void setCurrentTransport(int transportId) = 0;
0083 
0084     virtual void setFcc(const QString &idString) = 0;
0085     /**
0086      * Returns @c true while the message composing is in progress.
0087      */
0088     virtual bool isComposing() const = 0;
0089 
0090     virtual void setAutoSaveFileName(const QString &fileName) = 0;
0091     virtual void setCollectionForNewMessage(const Akonadi::Collection &folder) = 0;
0092 
0093     virtual void addExtraCustomHeaders(const QMap<QByteArray, QString> &header) = 0;
0094 
0095     virtual void showAndActivateComposer() = 0;
0096 
0097 public: // kmcommand
0098     /**
0099      * If this folder is set, the original message is inserted back after
0100      * canceling
0101      */
0102     virtual void setFolder(const Akonadi::Collection &) = 0;
0103 
0104     /**
0105      * Sets the focus to the edit-widget and the cursor below the
0106      * "On ... you wrote" line when hasMessage is true.
0107      * Make sure you call this _after_ setMsg().
0108      */
0109     virtual void setFocusToEditor() = 0;
0110 
0111     /**
0112      * Sets the focus to the subject line edit. For use when creating a
0113      * message to a known recipient.
0114      */
0115     virtual void setFocusToSubject() = 0;
0116 
0117 public: // callback
0118     /** Disabled signing and encryption completely for this composer window. */
0119     virtual void setSigningAndEncryptionDisabled(bool v) = 0;
0120 
0121 public Q_SLOTS: // kmkernel, callback
0122     virtual void slotSendNow() = 0;
0123     virtual void setModified(bool modified) = 0;
0124 public Q_SLOTS: // kmkernel
0125     virtual void autoSaveMessage(bool force = false) = 0;
0126 
0127 public: // kmkernel
0128     virtual void disableWordWrap() = 0;
0129 
0130     virtual void forceDisableHtml() = 0;
0131 
0132     virtual void disableForgottenAttachmentsCheck() = 0;
0133 
0134 public: // kmcommand
0135     /**
0136      * Add an attachment to the list.
0137      */
0138     virtual void addAttach(KMime::Content *msgPart) = 0;
0139 };
0140 
0141 KMAIL_EXPORT Composer *makeComposer(const KMime::Message::Ptr &msg = KMime::Message::Ptr(),
0142                                     bool lastSignState = false,
0143                                     bool lastEncryptState = false,
0144                                     Composer::TemplateContext context = Composer::NoTemplate,
0145                                     uint identity = 0,
0146                                     const QString &textSelection = QString(),
0147                                     const QString &customTemplate = QString());
0148 }
0149 Q_DECLARE_TYPEINFO(KMail::Composer::AttachmentInfo, Q_RELOCATABLE_TYPE);