allow 'on-the-fly' changing of the type of encryption and/or signing used (mime/ascii...
[claws.git] / src / compose.h
1 /*
2  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 1999-2002 Hiroyuki Yamamoto
4  *
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.
9  *
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.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  */
19
20 #ifndef __COMPOSE_H__
21 #define __COMPOSE_H__
22
23 #include <glib.h>
24 #include <gtk/gtkwidget.h>
25 #include <gtk/gtkitemfactory.h>
26
27 typedef struct _Compose         Compose;
28 typedef struct _ComposeToolbar  ComposeToolbar;
29 typedef struct _AttachInfo      AttachInfo;
30
31 #include "procmsg.h"
32 #include "procmime.h"
33 #include "addressbook.h"
34 #include "prefs_account.h"
35 #include "undo.h"
36
37 #ifdef USE_ASPELL
38 #include "gtkaspell.h"
39 #endif
40
41 typedef enum
42 {
43         COMPOSE_TO,
44         COMPOSE_CC,
45         COMPOSE_BCC,
46         COMPOSE_REPLYTO,
47         COMPOSE_NEWSGROUPS,
48         COMPOSE_FOLLOWUPTO
49 } ComposeEntryType;
50
51 typedef enum
52 {
53         COMPOSE_REPLY,
54         COMPOSE_REPLY_WITH_QUOTE,
55         COMPOSE_REPLY_WITHOUT_QUOTE,
56         COMPOSE_REPLY_TO_SENDER,
57         COMPOSE_FOLLOWUP_AND_REPLY_TO,
58         COMPOSE_REPLY_TO_SENDER_WITH_QUOTE,
59         COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE,
60         COMPOSE_REPLY_TO_ALL,
61         COMPOSE_REPLY_TO_ALL_WITH_QUOTE,
62         COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE,
63         COMPOSE_REPLY_TO_LIST,
64         COMPOSE_REPLY_TO_LIST_WITH_QUOTE,
65         COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE,
66         COMPOSE_FORWARD,
67         COMPOSE_FORWARD_AS_ATTACH,
68         COMPOSE_FORWARD_INLINE,
69         COMPOSE_NEW,
70         COMPOSE_REDIRECT,
71         COMPOSE_REEDIT
72 } ComposeMode;
73
74 typedef struct {
75         guint headernum;
76         Compose *compose;
77         GtkWidget *combo;
78         GtkWidget *entry;
79 } ComposeHeaderEntry;
80
81 struct _Compose
82 {
83         GtkWidget *window;
84         GtkWidget *vbox;
85         GtkWidget *menubar;
86         
87         /* Toolbar handlebox */
88         GtkWidget *handlebox;
89         ComposeToolbar *toolbar;
90
91         GtkWidget *vbox2;
92
93         /* Header */
94         GtkWidget *table_vbox;
95         GtkWidget *table;
96 /*
97         GtkWidget *to_hbox;
98         GtkWidget *to_entry;
99         GtkWidget *newsgroups_hbox;
100         GtkWidget *newsgroups_entry;
101 */
102         GtkWidget *subject_entry;
103 /*
104         GtkWidget *cc_hbox;
105         GtkWidget *cc_entry;
106         GtkWidget *bcc_hbox;
107         GtkWidget *bcc_entry;
108         GtkWidget *reply_hbox;
109         GtkWidget *reply_entry;
110         GtkWidget *followup_hbox;
111         GtkWidget *followup_entry;
112 */
113         GtkWidget *paned;
114
115         /* Attachments */
116         GtkWidget *attach_scrwin;
117         GtkWidget *attach_clist;
118
119         /* Others */
120         GtkWidget *savemsg_checkbtn;
121         GtkWidget *savemsg_entry;
122
123         /* Textedit */
124         GtkWidget *edit_vbox;
125         GtkWidget *ruler_hbox;
126         GtkWidget *ruler;
127         GtkWidget *scrolledwin;
128         GtkWidget *text;
129
130         GtkWidget *focused_editable;
131
132         GtkWidget *popupmenu;
133
134         GtkItemFactory *popupfactory;
135
136         GtkWidget *tmpl_menu;
137
138         ComposeMode mode;
139
140         MsgInfo *targetinfo;
141         MsgInfo *replyinfo;
142
143         GtkWidget *header_table;
144         GSList    *header_list;
145         guint      header_nextrow;
146         ComposeHeaderEntry *header_last;
147
148         gchar   *replyto;
149         gchar   *cc;
150         gchar   *bcc;
151         gchar   *newsgroups;
152         gchar   *followup_to;
153
154         gchar   *ml_post;
155
156         gchar   *inreplyto;
157         gchar   *references;
158         gchar   *msgid;
159         gchar   *boundary;
160
161         gboolean use_to;
162         gboolean use_cc;
163         gboolean use_bcc;
164         gboolean use_replyto;
165         gboolean use_newsgroups;
166         gboolean use_followupto;
167         gboolean use_attach;
168
169         /* privacy settings */
170         gboolean use_signing;
171         gboolean use_encryption;
172         
173         gint sigmode;
174         gint encmode;
175
176         gboolean modified;
177
178         gboolean sending;
179         
180         gboolean return_receipt;
181         gboolean paste_as_quotation;
182
183         GSList *to_list;
184         GSList *newsgroup_list;
185
186         PrefsAccount *account;
187
188         UndoMain *undostruct;
189
190         /* external editor */
191         gchar *exteditor_file;
192         pid_t  exteditor_pid;
193         gint   exteditor_readdes;
194         gint   exteditor_tag;
195
196 #if USE_ASPELL
197         /* GNU/aspell spell checker */
198         GtkAspell *gtkaspell;
199 #endif
200
201         /* Priority */
202         gint priority;
203
204         gchar *redirect_filename;
205 };
206
207 struct _ComposeToolbar {
208
209         GtkWidget *toolbar;
210
211         GtkWidget *send_btn;
212         GtkWidget *sendl_btn;
213         GtkWidget *draft_btn;
214         GtkWidget *insert_btn;
215         GtkWidget *attach_btn;
216         GtkWidget *sig_btn;
217         GtkWidget *exteditor_btn;
218         GtkWidget *linewrap_btn;
219         GtkWidget *addrbook_btn;
220
221         GSList    *t_action_list;
222         GSList    *t_item_list;
223 };
224
225 struct _AttachInfo
226 {
227         gchar *file;
228         gchar *content_type;
229         EncodingType encoding;
230         gchar *name;
231         off_t size;
232 };
233
234 Compose *compose_new                    (PrefsAccount   *account,
235                                          const gchar    *mailto,
236                                          GPtrArray      *attach_files);
237
238 Compose *compose_new_with_folderitem    (PrefsAccount   *account,
239                                          FolderItem     *item);
240
241 void compose_followup_and_reply_to      (MsgInfo        *msginfo,
242                                          gboolean        quote,
243                                          gboolean        to_all,
244                                          gboolean        ignore_replyto,
245                                          const gchar    *body);
246 void compose_reply                      (MsgInfo        *msginfo,
247                                          gboolean        quote,
248                                          gboolean        to_all,
249                                          gboolean        to_ml,
250                                          gboolean        ignore_replyto,
251                                          const gchar    *body);
252 Compose *compose_forward                (PrefsAccount *account,
253                                          MsgInfo        *msginfo,
254                                          gboolean        as_attach,
255                                          const gchar    *body);
256 Compose *compose_forward_multiple       (PrefsAccount   *account, 
257                                          GSList         *msginfo_list);
258 Compose *compose_redirect               (PrefsAccount   *account,
259                                          MsgInfo        *msginfo);
260 void compose_reedit                     (MsgInfo        *msginfo);
261
262 GList *compose_get_compose_list         (void);
263
264 void compose_entry_append               (Compose          *compose,
265                                          const gchar      *address,
266                                          ComposeEntryType  type);
267
268 void compose_entry_select               (Compose          *compose,
269                                          const gchar      *address);
270
271 gint compose_send                       (Compose          *compose);
272
273 void compose_reflect_prefs_all                  (void);
274 void compose_reflect_prefs_pixmap_theme (void);
275
276 void compose_destroy_all                (void);
277 void compose_draft                      (gpointer data);
278
279 #endif /* __COMPOSE_H__ */