backport 1145339: no error box spam
[kdepim.git] / kmail / composer.h
blob9e22922be068936f4eb6766929566b0634989d8f
1 /* -*- mode: C++; c-file-style: "gnu" -*-
2 This file is part of KMail, the KDE mail client.
3 Copyright (c) 1997 Markus Wuebben <markus.wuebben@kde.org>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 #ifndef __KMAIL_COMPOSER_H__
21 #define __KMAIL_COMPOSER_H__
23 #include "secondarywindow.h"
25 #include <kurl.h>
26 #include <kglobalsettings.h>
27 #include <kmime/kmime_message.h>
28 #include <akonadi/collection.h>
29 #include <QString>
31 #include <boost/shared_ptr.hpp>
33 class MailComposerIface;
35 namespace KMime {
36 class Content;
39 namespace KMail {
41 class Composer : public KMail::SecondaryWindow
43 Q_OBJECT
44 protected:
45 Composer( const char *name=0 ) : KMail::SecondaryWindow( name ) {}
47 public:
48 enum TemplateContext { New, Reply, ReplyToAll, Forward, NoTemplate };
49 enum VisibleHeaderFlag {
50 HDR_FROM = 0x01,
51 HDR_REPLY_TO = 0x02,
52 HDR_SUBJECT = 0x20,
53 HDR_NEWSGROUPS = 0x40,
54 HDR_FOLLOWUP_TO = 0x80,
55 HDR_IDENTITY = 0x100,
56 HDR_TRANSPORT = 0x200,
57 HDR_FCC = 0x400,
58 HDR_DICTIONARY = 0x800,
59 HDR_ALL = 0xfff
61 typedef QFlags<VisibleHeaderFlag> VisibleHeaderFlags;
63 public: // mailserviceimpl
64 /**
65 * From MailComposerIface
67 virtual void send( int how ) = 0;
68 virtual void addAttachmentsAndSend( const KUrl::List &urls,
69 const QString &comment, int how) = 0;
70 virtual void addAttachment( const KUrl &url, const QString &comment ) = 0;
71 virtual void addAttachment( const QString & name,
72 KMime::Headers::contentEncoding cte,
73 const QString& charset,
74 const QByteArray & data,
75 const QByteArray & mimeType ) = 0;
76 public: // kmcommand
77 virtual QString dbusObjectPath() const = 0;
78 public: // kmkernel, kmcommands, callback
79 /**
80 * Set the message the composer shall work with. This discards
81 * previous messages without calling applyChanges() on them before.
83 virtual void setMsg( const KMime::Message::Ptr &newMsg, bool mayAutoSign=true,
84 bool allowDecryption=false, bool isModified=false ) = 0;
86 /**
87 * Returns @c true while the message composing is in progress.
89 virtual bool isComposing() const = 0;
91 /**
92 * Set the text selection the message is a response to.
94 virtual void setTextSelection( const QString& selection ) = 0;
96 /**
97 * Set custom template to be used for the message.
99 virtual void setCustomTemplate( const QString& customTemplate ) = 0;
101 virtual void setAutoSaveFileName( const QString &fileName ) = 0;
103 public: // kmcommand
105 * If this folder is set, the original message is inserted back after
106 * canceling
108 virtual void setFolder( const Akonadi::Collection& ) = 0;
110 public: // kmcommand
112 * Sets the focus to the edit-widget and the cursor below the
113 * "On ... you wrote" line when hasMessage is true.
114 * Make sure you call this _after_ setMsg().
116 virtual void setReplyFocus( bool hasMessage=true ) = 0;
119 * Sets the focus to the subject line edit. For use when creating a
120 * message to a known recipient.
122 virtual void setFocusToSubject() = 0;
124 public: // callback
125 /** Disabled signing and encryption completely for this composer window. */
126 virtual void setSigningAndEncryptionDisabled( bool v ) = 0;
128 public slots: // kmkernel, callback
129 virtual void slotSendNow() = 0;
131 public slots: // kmkernel
133 Tell the composer to always send the message, even if the user
134 hasn't changed the text. This is useful if a message is
135 autogenerated (e.g., via a D-Bus call), and the user should
136 simply be able to confirm the message and send it.
138 virtual void slotSetAlwaysSend( bool bAlwaysSend ) = 0;
140 public slots: // kmkernel, callback
142 * Switch wordWrap on/off
144 virtual void slotWordWrapToggled( bool ) = 0;
146 public slots: // kmkernel
147 virtual void autoSaveMessage() = 0;
149 public: // kmkernel, attachmentlistview
150 virtual void disableWordWrap() = 0;
152 virtual void forceDisableHtml() = 0;
154 virtual void disableRecipientNumberCheck() = 0;
156 virtual void disableForgottenAttachmentsCheck() = 0;
158 virtual void ignoreStickyFields() = 0;
160 public: // kmcommand
162 * Add an attachment to the list.
164 virtual void addAttach( KMime::Content *msgPart ) = 0;
167 Composer *makeComposer( const KMime::Message::Ptr &msg = KMime::Message::Ptr(),
168 Composer::TemplateContext context = Composer::NoTemplate,
169 uint identity = 0, const QString & textSelection = QString(),
170 const QString & customTemplate = QString() );
174 #endif // __KMAIL_COMPOSER_H__