2013-02-18 [wwp] 3.9.0cvs77
[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         guint 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         gchar *orig_charset;
239         gint set_cursor_pos;
240         
241         gboolean updating;
242         gboolean deferred_destroy;
243         ComposeMode rmode;
244         GtkWidget *first_combo;
245         GtkWidget *first_entry;
246         
247         GtkUIManager *ui_manager;
248 #if USE_ENCHANT
249         /* GNU/aspell spell checker */
250         GtkAspell *gtkaspell;
251         GtkWidget *aspell_options_menu;
252 #endif
253 };
254
255 struct _AttachInfo
256 {
257         gchar *file;
258         gchar *content_type;
259         EncodingType encoding;
260         gchar *name;
261         goffset size;
262         gchar *charset;
263 };
264
265 typedef enum
266 {
267         COMPOSE_QUIT_EDITING,
268         COMPOSE_KEEP_EDITING,
269         COMPOSE_AUTO_SAVE,
270         COMPOSE_DRAFT_FOR_EXIT
271 } ComposeDraftAction;
272
273 /*#warning FIXME_GTK2 */
274 /* attache_files will be locale encode */
275 Compose *compose_new                    (PrefsAccount   *account,
276                                          const gchar    *mailto,
277                                          GList          *attach_files);
278
279 Compose *compose_new_with_folderitem    (PrefsAccount   *account,
280                                          FolderItem     *item,
281                                          const gchar    *mailto);
282
283 Compose *compose_new_with_list          (PrefsAccount   *account,
284                                          GList          *listAddress);
285
286 Compose *compose_forward                (PrefsAccount *account,
287                                          MsgInfo        *msginfo,
288                                          gboolean        as_attach,
289                                          const gchar    *body,
290                                          gboolean        no_extedit,
291                                          gboolean        batch);
292
293 Compose *compose_redirect               (PrefsAccount   *account,
294                                          MsgInfo        *msginfo,
295                                          gboolean        batch);
296 Compose *compose_reedit                 (MsgInfo        *msginfo,
297                                          gboolean        batch);
298
299 GList *compose_get_compose_list         (void);
300
301 void compose_entry_append               (Compose          *compose,
302                                          const gchar      *address,
303                                          ComposeEntryType  type,
304                                          ComposePrefType   pref_type);
305
306
307 gint compose_send                       (Compose          *compose);
308
309 void compose_update_actions_menu        (Compose        *compose);
310 void compose_reflect_prefs_all                  (void);
311 void compose_reflect_prefs_pixmap_theme (void);
312
313 void compose_destroy_all                (void);
314 gboolean compose_draft                  (gpointer data, guint action);
315 void compose_toolbar_cb                 (gint           action, 
316                                          gpointer       data);
317 void compose_reply_to_address           (MessageView    *msgview,
318                                          MsgInfo        *msginfo,
319                                          const gchar    *address);
320 void compose_reply_from_messageview     (MessageView    *msgview, 
321                                          GSList         *msginfo_list, 
322                                          guint           action);
323 void compose_action_cb                  (void           *data);
324
325 void compose_set_position                               (Compose        *compose,
326                                                  gint            pos);
327 gboolean compose_search_string                  (Compose        *compose,
328                                                  const gchar    *str,
329                                                  gboolean        case_sens);
330 gboolean compose_search_string_backward (Compose        *compose,
331                                                  const gchar    *str,
332                                                  gboolean        case_sens);
333 gint compose_queue                      (Compose *compose, 
334                                          gint *msgnum, 
335                                          FolderItem **item, 
336                                          gchar **msgpath,
337                                          gboolean remove_reedit_target);
338 gboolean compose_close                  (Compose *compose);
339 void compose_close_toolbar              (Compose *compose);
340 void compose_clear_exit_drafts          (void);
341 void compose_reopen_exit_drafts         (void);
342 void compose_attach_from_list (Compose *compose, GList *file_list, gboolean free_data);
343 void compose_check_for_email_account(Compose *compose);
344 #endif /* __COMPOSE_H__ */