re-implement GnuPG 'on-the-fly' mode selection
[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 gnupg_mode;
174
175         gboolean modified;
176
177         gboolean sending;
178         
179         gboolean return_receipt;
180         gboolean paste_as_quotation;
181
182         GSList *to_list;
183         GSList *newsgroup_list;
184
185         PrefsAccount *account;
186
187         UndoMain *undostruct;
188
189         /* external editor */
190         gchar *exteditor_file;
191         pid_t  exteditor_pid;
192         gint   exteditor_readdes;
193         gint   exteditor_tag;
194
195 #if USE_ASPELL
196         /* GNU/aspell spell checker */
197         GtkAspell *gtkaspell;
198 #endif
199
200         /* Priority */
201         gint priority;
202
203         gchar *redirect_filename;
204 };
205
206 struct _ComposeToolbar {
207
208         GtkWidget *toolbar;
209
210         GtkWidget *send_btn;
211         GtkWidget *sendl_btn;
212         GtkWidget *draft_btn;
213         GtkWidget *insert_btn;
214         GtkWidget *attach_btn;
215         GtkWidget *sig_btn;
216         GtkWidget *exteditor_btn;
217         GtkWidget *linewrap_btn;
218         GtkWidget *addrbook_btn;
219
220         GSList    *t_action_list;
221         GSList    *t_item_list;
222 };
223
224 struct _AttachInfo
225 {
226         gchar *file;
227         gchar *content_type;
228         EncodingType encoding;
229         gchar *name;
230         off_t size;
231 };
232
233 Compose *compose_new                    (PrefsAccount   *account,
234                                          const gchar    *mailto,
235                                          GPtrArray      *attach_files);
236
237 Compose *compose_new_with_folderitem    (PrefsAccount   *account,
238                                          FolderItem     *item);
239
240 void compose_followup_and_reply_to      (MsgInfo        *msginfo,
241                                          gboolean        quote,
242                                          gboolean        to_all,
243                                          gboolean        ignore_replyto,
244                                          const gchar    *body);
245 void compose_reply                      (MsgInfo        *msginfo,
246                                          gboolean        quote,
247                                          gboolean        to_all,
248                                          gboolean        to_ml,
249                                          gboolean        ignore_replyto,
250                                          const gchar    *body);
251 Compose *compose_forward                (PrefsAccount *account,
252                                          MsgInfo        *msginfo,
253                                          gboolean        as_attach,
254                                          const gchar    *body);
255 Compose *compose_forward_multiple       (PrefsAccount   *account, 
256                                          GSList         *msginfo_list);
257 Compose *compose_redirect               (PrefsAccount   *account,
258                                          MsgInfo        *msginfo);
259 void compose_reedit                     (MsgInfo        *msginfo);
260
261 GList *compose_get_compose_list         (void);
262
263 void compose_entry_append               (Compose          *compose,
264                                          const gchar      *address,
265                                          ComposeEntryType  type);
266
267 void compose_entry_select               (Compose          *compose,
268                                          const gchar      *address);
269
270 gint compose_send                       (Compose          *compose);
271
272 void compose_reflect_prefs_all                  (void);
273 void compose_reflect_prefs_pixmap_theme (void);
274
275 void compose_destroy_all                (void);
276 void compose_draft                      (gpointer data);
277
278 #endif /* __COMPOSE_H__ */