51d0e7e020d01d218639616eeec1f96d469ce743
[claws.git] / src / compose.h
1 /*
2  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 1999-2012 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 3 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, see <http://www.gnu.org/licenses/>.
17  * 
18  */
19
20 #ifndef __COMPOSE_H__
21 #define __COMPOSE_H__
22
23 typedef struct _Compose         Compose;
24 typedef struct _AttachInfo      AttachInfo;
25
26 #include <glib.h>
27 #include <gtk/gtk.h>
28
29 #include "procmsg.h"
30 #include "procmime.h"
31 #include "prefs_account.h"
32 #include "undo.h"
33 #include "toolbar.h"
34 #include "codeconv.h"
35 #include "template.h"
36 #include "viewtypes.h"
37 #include "folder.h"
38
39 #ifdef USE_ENCHANT
40 #include "gtkaspell.h"
41 #endif
42
43 #define COMPOSE_CHECK_BEFORE_SEND_HOOKLIST "compose_check_before_send"
44 #define COMPOSE_CREATED_HOOKLIST "compose_created"
45
46 typedef enum
47 {
48         COMPOSE_TO,
49         COMPOSE_CC,
50         COMPOSE_BCC,
51         COMPOSE_REPLYTO,
52         COMPOSE_NEWSGROUPS,
53         COMPOSE_FOLLOWUPTO,
54         COMPOSE_INREPLYTO
55 } ComposeEntryType;
56
57 typedef enum
58 {
59         COMPOSE_REPLY,
60         COMPOSE_REPLY_WITH_QUOTE,
61         COMPOSE_REPLY_WITHOUT_QUOTE,
62         COMPOSE_REPLY_TO_SENDER,
63         COMPOSE_REPLY_TO_ADDRESS,
64         COMPOSE_FOLLOWUP_AND_REPLY_TO,
65         COMPOSE_REPLY_TO_SENDER_WITH_QUOTE,
66         COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE,
67         COMPOSE_REPLY_TO_ALL,
68         COMPOSE_REPLY_TO_ALL_WITH_QUOTE,
69         COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE,
70         COMPOSE_REPLY_TO_LIST,
71         COMPOSE_REPLY_TO_LIST_WITH_QUOTE,
72         COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE,
73         COMPOSE_FORWARD,
74         COMPOSE_FORWARD_AS_ATTACH,
75         COMPOSE_FORWARD_INLINE,
76         COMPOSE_NEW,
77         COMPOSE_REDIRECT,
78         COMPOSE_REEDIT
79 } ComposeMode;
80
81 typedef enum {
82         PREF_ACCOUNT,
83         PREF_FOLDER,
84         PREF_TEMPLATE,
85         PREF_ML,
86         PREF_MAILTO,
87         PREF_NONE
88 } ComposePrefType;
89
90 typedef struct {
91         guint headernum;
92         Compose *compose;
93         GtkWidget *combo;
94         GtkWidget *entry;
95         GtkWidget *button;
96         GtkWidget *hbox;
97         ComposePrefType type;
98 } ComposeHeaderEntry;
99
100 struct _Compose
101 {
102         /* start with window widget don`t change order */
103         GtkWidget *window;
104         GtkWidget *vbox;
105         GtkWidget *menubar;
106
107         /* Toolbar handlebox */
108         GtkWidget *handlebox;
109         Toolbar *toolbar;
110         
111         GtkWidget *vbox2;
112
113         /* Header */
114         GtkWidget *table_vbox;
115         GtkWidget *table;
116         GtkWidget *account_combo;
117         GtkWidget *subject_entry;
118         GtkWidget *paned;
119
120         /* Attachments */
121         GtkWidget *attach_scrwin;
122         GtkWidget *attach_clist;
123         GtkWidget *attach_label;
124
125         /* Others */
126         GtkWidget *savemsg_checkbtn;
127         GtkWidget *savemsg_combo;
128
129         /* Headers notebook */
130         GtkWidget *notebook;
131
132         /* Textedit */
133         GtkWidget *edit_vbox;
134         GtkWidget *ruler_hbox;
135         GtkWidget *ruler;
136         GtkWidget *scrolledwin;
137         GtkWidget *text;
138         GtkWidget *from_name;
139 #if !GTK_CHECK_VERSION(2,12,0)
140         GtkTooltips *tooltips;
141 #endif
142
143         GtkWidget *focused_editable;
144
145         GtkWidget *popupmenu;
146
147         GtkWidget *tmpl_menu;
148
149         ComposeMode mode;
150
151         MsgInfo *targetinfo;
152         MsgInfo *replyinfo;
153         MsgInfo *autosaved_draft;
154         MsgInfo *fwdinfo;
155
156         GtkWidget *header_table;
157         GSList    *header_list;
158         guint      header_nextrow;
159         ComposeHeaderEntry *header_last;
160
161         GHashTable *email_hashtable;
162
163         gchar   *replyto;
164         gchar   *cc;
165         gchar   *bcc;
166         gchar   *newsgroups;
167         gchar   *followup_to;
168
169         gchar   *ml_post;
170
171         gchar   *inreplyto;
172         gchar   *references;
173         gchar   *msgid;
174         gchar   *boundary;
175
176         gboolean autowrap;
177         gboolean autoindent;
178
179         gboolean use_to;
180         gboolean use_cc;
181         gboolean use_bcc;
182         gboolean use_replyto;
183         gboolean use_newsgroups;
184         gboolean use_followupto;
185         gboolean use_attach;
186
187         CharSet out_encoding;
188
189         /* privacy settings */
190         gboolean use_signing;
191         gboolean use_encryption;
192         gchar *privacy_system;
193
194         gboolean modified;
195
196         gboolean sending;
197         
198         gboolean return_receipt;
199
200         gboolean batch;
201         
202         GSList *to_list;
203         GSList *newsgroup_list;
204
205         PrefsAccount *account;
206         FolderItem *folder;
207
208         UndoMain *undostruct;
209
210         gchar *sig_str;
211         gboolean sig_inserted;
212
213         /* external editor */
214         gchar      *exteditor_file;
215         pid_t       exteditor_pid;
216         GIOChannel *exteditor_ch;
217         gint        exteditor_tag;
218
219         /* Priority */
220         gint priority;
221
222         gchar *redirect_filename;
223         
224         gboolean remove_references;
225
226         gint64 draft_timeout_tag;
227         
228         GtkTextTag *no_wrap_tag;
229         GtkTextTag *no_join_tag;
230         GtkTextTag *signature_tag;
231         GtkTextTag *quote0_tag;
232         GtkTextTag *quote1_tag;
233         GtkTextTag *quote2_tag;
234         GtkTextTag *uri_tag;
235
236         gboolean automatic_break;
237         GMutex *mutex;
238         gint close_timeout_tag;
239         gchar *orig_charset;
240         gint set_cursor_pos;
241
242         gboolean updating;
243         gboolean deferred_destroy;
244         ComposeMode rmode;
245         GtkWidget *first_combo;
246         GtkWidget *first_entry;
247
248         GtkUIManager *ui_manager;
249
250         gint folder_update_callback_id;
251 #if USE_ENCHANT
252         /* GNU/aspell spell checker */
253         GtkAspell *gtkaspell;
254         GtkWidget *aspell_options_menu;
255 #endif
256 };
257
258 struct _AttachInfo
259 {
260         gchar *file;
261         gchar *content_type;
262         EncodingType encoding;
263         gchar *name;
264         goffset size;
265         gchar *charset;
266 };
267
268 typedef enum
269 {
270         COMPOSE_QUIT_EDITING,
271         COMPOSE_KEEP_EDITING,
272         COMPOSE_AUTO_SAVE,
273         COMPOSE_DRAFT_FOR_EXIT
274 } ComposeDraftAction;
275
276 /*#warning FIXME_GTK2 */
277 /* attache_files will be locale encode */
278 Compose *compose_new                    (PrefsAccount   *account,
279                                          const gchar    *mailto,
280                                          GList          *attach_files);
281
282 Compose *compose_new_with_folderitem    (PrefsAccount   *account,
283                                          FolderItem     *item,
284                                          const gchar    *mailto);
285
286 Compose *compose_new_with_list          (PrefsAccount   *account,
287                                          GList          *listAddress);
288
289 Compose *compose_forward                (PrefsAccount *account,
290                                          MsgInfo        *msginfo,
291                                          gboolean        as_attach,
292                                          const gchar    *body,
293                                          gboolean        no_extedit,
294                                          gboolean        batch);
295
296 Compose *compose_redirect               (PrefsAccount   *account,
297                                          MsgInfo        *msginfo,
298                                          gboolean        batch);
299 Compose *compose_reedit                 (MsgInfo        *msginfo,
300                                          gboolean        batch);
301
302 const GList *compose_get_compose_list   (void);
303
304 void compose_entry_append               (Compose          *compose,
305                                          const gchar      *address,
306                                          ComposeEntryType  type,
307                                          ComposePrefType   pref_type);
308
309
310 gint compose_send                       (Compose          *compose);
311
312 void compose_update_actions_menu        (Compose        *compose);
313 void compose_reflect_prefs_all                  (void);
314 void compose_reflect_prefs_pixmap_theme (void);
315
316 void compose_destroy_all                (void);
317 gboolean compose_draft                  (gpointer data, guint action);
318 void compose_toolbar_cb                 (gint           action, 
319                                          gpointer       data);
320 void compose_reply_to_address           (MessageView    *msgview,
321                                          MsgInfo        *msginfo,
322                                          const gchar    *address);
323 void compose_reply_from_messageview     (MessageView    *msgview, 
324                                          GSList         *msginfo_list, 
325                                          guint           action);
326 void compose_action_cb                  (void           *data);
327
328 void compose_set_position                               (Compose        *compose,
329                                                  gint            pos);
330 gboolean compose_search_string                  (Compose        *compose,
331                                                  const gchar    *str,
332                                                  gboolean        case_sens);
333 gboolean compose_search_string_backward (Compose        *compose,
334                                                  const gchar    *str,
335                                                  gboolean        case_sens);
336 gint compose_queue                      (Compose *compose, 
337                                          gint *msgnum, 
338                                          FolderItem **item, 
339                                          gchar **msgpath,
340                                          gboolean remove_reedit_target);
341 gboolean compose_close                  (Compose *compose);
342 void compose_close_toolbar              (Compose *compose);
343 void compose_clear_exit_drafts          (void);
344 void compose_reopen_exit_drafts         (void);
345 void compose_attach_from_list (Compose *compose, GList *file_list, gboolean free_data);
346 void compose_check_for_email_account(Compose *compose);
347
348 #endif /* __COMPOSE_H__ */