Honor autosave_encrypted preference when using external editor.
[claws.git] / src / prefs_common.h
1 /*
2  * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 1999-2016 Hiroyuki Yamamoto and the Claws Mail team
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 #ifndef __PREFS_COMMON_H__
20 #define __PREFS_COMMON_H__
21
22 #ifdef HAVE_CONFIG_H
23 #include "config.h"
24 #include "claws-features.h"
25 #endif
26
27 #include <glib.h>
28
29 #include "mainwindow.h"
30 #include "summaryview.h"
31 #include "folderview.h"
32 #include "codeconv.h"
33 #include "textview.h"
34 #include "procmime.h"
35 #include "prefs_msg_colors.h"
36 #include "prefs_summary_open.h"
37
38 #define CLAWS_CONFIG_VERSION 2
39
40 typedef struct _PrefsCommon     PrefsCommon;
41
42 typedef enum {
43         RECV_DIALOG_ALWAYS,
44         RECV_DIALOG_MANUAL,
45         RECV_DIALOG_NEVER
46 } RecvDialogMode;
47
48 typedef enum {
49         COMPOSE_DND_ASK,
50         COMPOSE_DND_INSERT,
51         COMPOSE_DND_ATTACH
52 } ComposeDndInsertOrAttach;
53
54 typedef enum {
55         CTE_AUTO,
56         CTE_BASE64,
57         CTE_QUOTED_PRINTABLE,
58         CTE_8BIT
59 } TransferEncodingMethod;
60
61 typedef enum
62 {
63 /* U = unread, N = new, M = marked */
64         SELECTONENTRY_NOTHING,
65         SELECTONENTRY_UNM,
66         SELECTONENTRY_UMN,
67         SELECTONENTRY_NUM,
68         SELECTONENTRY_NMU,
69         SELECTONENTRY_MNU,
70         SELECTONENTRY_MUN,
71         SELECTONENTRY_LAST
72 } SelectOnEntry;
73
74 typedef enum
75 {
76         ACTION_UNSET = 0, /* for backward compatibility */
77         ACTION_MARKED,
78         ACTION_NEW,
79         ACTION_UNREAD,
80         ACTION_LAST_OPENED,
81         ACTION_LAST_LIST,
82         ACTION_NOTHING,
83         ACTION_FIRST_LIST
84 } EntryAction;
85
86 typedef enum
87 {
88         NEXTUNREADMSGDIALOG_ALWAYS,
89         NEXTUNREADMSGDIALOG_ASSUME_YES,
90         NEXTUNREADMSGDIALOG_ASSUME_NO
91 } NextUnreadMsgDialogShow;
92
93 typedef enum
94 {
95         OPENMSG_NO = 0,
96         OPENMSG_YES = 1,
97         OPENMSG_WHEN_VIEW_VISIBLE
98 } ShowMsgPolicy;
99
100 typedef enum
101 {
102         SHOW_NAME,
103         SHOW_ADDR,
104         SHOW_BOTH
105 } SummaryFromShow;
106
107 typedef enum
108 {
109         AVATARS_DISABLE = 0,
110         AVATARS_ENABLE_CAPTURE = 1,
111         AVATARS_ENABLE_RENDER = 2,
112         AVATARS_ENABLE_BOTH = 3
113 } EnableAvatars;
114
115 struct _PrefsCommon
116 {
117         gint config_version;
118
119         /* Receive */
120         gboolean use_extinc;
121         gchar *extinc_cmd;
122         gboolean scan_all_after_inc;
123         gboolean autochk_newmail;
124         gint autochk_itv;
125         gboolean chk_on_startup;
126         gboolean open_inbox_on_inc;
127         gboolean newmail_notify_auto;
128         gboolean newmail_notify_manu;
129         gchar   *newmail_notify_cmd;
130         RecvDialogMode recv_dialog_mode;
131         gint receivewin_width;
132         gint receivewin_height;
133         gboolean close_recv_dialog;
134         gboolean no_recv_err_panel;
135
136         /* Send */
137         gboolean savemsg;
138         gboolean confirm_send_queued_messages;
139         gboolean send_dialog_invisible;
140         gint sendwin_width;
141         gint sendwin_height;
142         gchar *outgoing_charset;
143         TransferEncodingMethod encoding_method;
144         gboolean outgoing_fallback_to_ascii;
145         gboolean rewrite_first_from;
146         gboolean warn_empty_subj;
147         gboolean hide_timezone;
148         gboolean allow_jisx0201_kana;
149
150         /* Compose */
151         gint undolevels;
152         gint linewrap_len;
153         gboolean linewrap_quote;
154         gboolean linewrap_pastes;
155         gboolean primary_paste_unselects;
156         gboolean autowrap;
157         gboolean auto_indent;
158         gboolean auto_exteditor;
159         gboolean reply_account_autosel;
160         gboolean default_reply_list;
161         gboolean forward_account_autosel;
162         gboolean reedit_account_autosel;
163         gboolean show_ruler;
164         gboolean autosave;
165         gint autosave_length;
166         gboolean autosave_encrypted;
167         gboolean warn_large_insert;
168         gint warn_large_insert_size;
169         gboolean compose_no_markup;
170         ComposeDndInsertOrAttach compose_dnd_mode;
171         gboolean compose_with_format;
172         gchar *compose_subject_format;
173         gchar *compose_body_format;
174         gboolean show_compose_margin;
175         gboolean type_any_header;
176
177         /* Quote */
178         gboolean reply_with_quote;
179         gchar *quotemark;
180         gchar *quotefmt;
181         gchar *fw_quotemark;
182         gchar *fw_quotefmt;
183         gboolean forward_as_attachment;
184         gboolean redirect_keep_from;
185         gchar *quote_chars;
186         
187         gboolean enable_aspell;
188         gchar *dictionary;
189         gchar *alt_dictionary;
190         gulong misspelled_col;
191         gboolean check_while_typing;
192         gboolean recheck_when_changing_dict;
193         gboolean use_alternate;
194         gboolean use_both_dicts;
195         
196         /* Display */
197         /* obsolete fonts */
198         gchar *widgetfont_gtk1;
199         gchar *textfont_gtk1;
200         gchar *normalfont_gtk1;
201         gchar *boldfont_gtk1;
202         gchar *smallfont_gtk1;
203
204         /* new fonts */
205         gchar *widgetfont;
206         gchar *textfont;
207         gchar *printfont;
208         gchar *boldfont;
209         gchar *normalfont;
210         gchar *smallfont;
211         gchar *titlefont;
212         gboolean use_different_print_font;
213         gboolean derive_from_normal_font;
214
215         /* custom colors */
216         ColorlabelPrefs custom_colorlabel[COLORLABELS];
217
218         /* image viewer */
219         gboolean display_img;
220         gboolean resize_img;
221         gboolean inline_img;
222
223         gboolean trans_hdr;
224         gint display_folder_unread;
225         gint ng_abbrev_len;
226
227         gboolean show_searchbar;
228         gboolean expand_thread;
229         gboolean swap_from;
230         gboolean use_addr_book;
231         gchar *date_format;
232         gboolean *msgview_date_format;
233
234         gboolean use_stripes_everywhere;
235         gboolean use_stripes_in_summaries; /* overrides if use_stripes_everywhere is set to TRUE */
236         gint stripes_color_offset;
237         gboolean enable_hscrollbar;
238         gboolean bold_unread;
239         gboolean next_on_delete;
240         gboolean enable_thread;
241         gboolean thread_by_subject;
242         gint thread_by_subject_max_age; /*!< Max. age of a thread which was threaded
243                                          *   by subject (days) */
244         FolderSortKey default_sort_key;
245         FolderSortType default_sort_type;
246
247         gchar *last_opened_folder;
248         gboolean goto_last_folder_on_startup;
249
250         ToolbarStyle toolbar_style;
251         gboolean toolbar_detachable;
252         gboolean show_statusbar;
253         gboolean show_col_headers;
254
255         gint folderview_vscrollbar_policy;
256
257         /* Filtering */
258         GSList *fltlist;
259
260         gint kill_score;
261         gint important_score;
262
263         /* Actions */
264         GSList *actions_list;
265
266         /* Summary columns visibility, position and size */
267         gboolean summary_col_visible[N_SUMMARY_COLS];
268         gint summary_col_pos[N_SUMMARY_COLS];
269         gint summary_col_size[N_SUMMARY_COLS];
270
271         gboolean folder_col_visible[N_FOLDER_COLS];
272         gint folder_col_pos[N_FOLDER_COLS];
273         gint folder_col_size[N_FOLDER_COLS];
274
275         /* Widget visibility, position and size */
276         gint folderwin_x;
277         gint folderwin_y;
278         gint folderview_width;
279         gint folderview_height;
280         gboolean folderview_visible;
281
282         gint summaryview_width;
283         gint summaryview_height;
284
285         gint main_msgwin_x;
286         gint main_msgwin_y;
287         gint msgview_width;
288         gint msgview_height;
289         gboolean msgview_visible;
290
291         gint mainview_x;
292         gint mainview_y;
293         gint mainview_width;
294         gint mainview_height;
295         gint mainwin_x;
296         gint mainwin_y;
297         gint mainwin_width;
298         gint mainwin_height;
299         gint mainwin_maximised;
300         gint mainwin_fullscreen;
301         gint mainwin_menubar;
302
303         gint msgwin_width;
304         gint msgwin_height;
305
306         gint mimeview_tree_height;
307         
308         gint sourcewin_width;
309         gint sourcewin_height;
310
311         gint compose_width;
312         gint compose_height;
313         gint compose_notebook_height;
314         gint compose_x;
315         gint compose_y;
316
317         /* Message */
318         gboolean enable_color;
319         gboolean enable_bgcolor;
320         gulong quote_level1_col;
321         gulong quote_level2_col;
322         gulong quote_level3_col;
323         gulong quote_level1_bgcol;
324         gulong quote_level2_bgcol;
325         gulong quote_level3_bgcol;
326         gulong uri_col;
327         gulong tgt_folder_col;
328         gulong signature_col;
329         gulong emphasis_col;
330         gboolean recycle_quote_colors;
331         gulong default_header_bgcolor;
332         gulong default_header_color;
333         gulong tags_bgcolor;
334         gulong tags_color;
335         gulong qs_active_bgcolor;
336         gulong qs_active_color;
337         gulong qs_error_bgcolor;
338         gulong qs_error_color;
339         gboolean display_header_pane;
340         gboolean display_header;
341         gboolean display_xface;
342         gint line_space;
343         gboolean render_html;
344         gboolean invoke_plugin_on_html;
345         gboolean promote_html_part;
346         gboolean textview_cursor_visible;
347         gboolean enable_smooth_scroll;
348         gint scroll_step;
349         gboolean scroll_halfpage;
350         gboolean hide_quoted;
351         gboolean respect_flowed_format;
352         gboolean show_all_headers;
353
354         gboolean show_other_header;
355         GSList *disphdr_list;
356
357         gboolean attach_desc;
358
359         /* MIME viewer */
360         gchar *mime_textviewer;
361         gchar *mime_open_cmd;
362         gchar *attach_save_dir;
363         gchar *attach_load_dir;
364
365         GList *mime_open_cmd_history;
366         gboolean show_inline_attachments;
367
368         /* Addressbook */
369         gboolean addressbook_use_editaddress_dialog;
370         gint addressbook_hpaned_pos;
371         gint addressbook_vpaned_pos;
372         GList *addressbook_custom_attributes;
373
374         /* Interface */
375         gboolean layout_mode;
376
377         gint statusbar_update_step;
378         gboolean emulate_emacs;
379         gboolean open_selected_on_folder_open;
380         ShowMsgPolicy always_show_msg;
381         gboolean mark_as_read_on_new_window;
382         gboolean mark_as_read_delay;
383         gboolean immediate_exec;
384         SelectOnEntry select_on_entry;
385         gboolean show_tooltips;
386
387         EntryAction summary_select_prio[SUMMARY_OPEN_ACTIONS-1];
388
389         NextUnreadMsgDialogShow next_unread_msg_dialog;
390         SummaryFromShow summary_from_show;
391         gboolean add_address_by_click;
392         gchar *pixmap_theme_path;
393         int hover_timeout; /* msecs mouse hover timeout */
394         gboolean ask_mark_all_read;
395         gboolean ask_apply_per_account_filtering_rules;
396         gint apply_per_account_filtering_rules;
397
398         /* Other */
399 #ifndef G_OS_WIN32
400         gchar *uri_cmd;
401 #else
402         gchar *gtk_theme;
403 #endif
404         gchar *ext_editor_cmd;
405         gboolean cmds_use_system_default;
406
407         gboolean cliplog;
408         guint loglength;
409         gboolean enable_log_standard;
410         gboolean enable_log_warning;
411         gboolean enable_log_error;
412         gboolean enable_log_status;
413
414         gulong log_msg_color;
415         gulong log_warn_color;
416         gulong log_error_color;
417         gulong log_in_color;
418         gulong log_out_color;
419         gulong log_status_ok_color;
420         gulong log_status_nok_color;
421         gulong log_status_skip_color;
422
423         gboolean enable_filtering_debug;
424         gint filtering_debug_level;
425         gboolean enable_filtering_debug_inc;
426         gboolean enable_filtering_debug_manual;
427         gboolean enable_filtering_debug_folder_proc;
428         gboolean enable_filtering_debug_pre_proc;
429         gboolean enable_filtering_debug_post_proc;
430         gboolean filtering_debug_cliplog;
431         guint filtering_debug_loglength;
432
433         gboolean confirm_on_exit;
434         gboolean session_passwords;
435         gboolean clean_on_exit;
436         gboolean ask_on_clean;
437         gboolean warn_queued_on_exit;
438
439         gint io_timeout_secs;
440
441         gboolean gtk_can_change_accels;
442         
443         /* Memory cache*/
444         gint cache_max_mem_usage;
445         gint cache_min_keep_time;
446         
447         /* boolean for work offline 
448            stored here for use in inc.c */
449         gboolean work_offline;
450         
451         gint summary_quicksearch_type;
452         gint summary_quicksearch_sticky;
453         gint summary_quicksearch_recurse;
454         gint summary_quicksearch_dynamic;
455         gint summary_quicksearch_autorun;
456         gulong color_new;
457         
458         GList *summary_quicksearch_history;
459         GList *summary_search_from_history;
460         GList *summary_search_to_history;
461         GList *summary_search_subject_history;
462         GList *summary_search_body_history;
463         GList *summary_search_adv_condition_history;
464         GList *message_search_history;
465         GList *compose_save_to_history;
466
467         gint filteringwin_width;
468         gint filteringwin_height;
469         gint filteringactionwin_width;
470         gint filteringactionwin_height;
471         gint matcherwin_width;
472         gint matcherwin_height;
473         gint templateswin_width;
474         gint templateswin_height;
475         gint actionswin_width;
476         gint actionswin_height;
477         gint tagswin_width;
478         gint tagswin_height;
479         gint addressbookwin_width;
480         gint addressbookwin_height;
481         gint addressbookeditpersonwin_width;
482         gint addressbookeditpersonwin_height;
483         gint addressbookeditgroupwin_width;
484         gint addressbookeditgroupwin_height;
485         gint pluginswin_width;
486         gint pluginswin_height;
487         gint prefswin_width;
488         gint prefswin_height;
489         gint folderitemwin_width;
490         gint folderitemwin_height;
491         gchar *zero_replacement;
492         gint editaccountwin_width;
493         gint editaccountwin_height;
494         gint accountswin_width;
495         gint accountswin_height;
496         gint logwin_width;
497         gint logwin_height;
498         gint filtering_debugwin_width;
499         gint filtering_debugwin_height;
500         gint folderselwin_width;
501         gint folderselwin_height;
502         gint addressaddwin_width;
503         gint addressaddwin_height;
504         gint addressbook_folderselwin_width;
505         gint addressbook_folderselwin_height;
506         gint aboutwin_width;
507         gint aboutwin_height;
508         gint addrgather_width;
509         gint addrgather_height;
510         gint news_subscribe_width;
511         gint news_subscribe_height;
512
513         gint warn_dnd;
514         gint broken_are_utf8;
515         gint skip_ssl_cert_check;
516         gint live_dangerously;
517         gint save_parts_readwrite;
518         gint never_send_retrcpt;
519         gint hide_quotes;
520         gboolean unsafe_ssl_certs;
521         gboolean real_time_sync;
522         
523         gchar *print_paper_type;
524         gint print_paper_orientation;
525         gint print_margin_top;
526         gint print_margin_bottom;
527         gint print_margin_left;
528         gint print_margin_right;
529   
530         gint print_use_color;
531         gint print_use_collate;
532         gint print_use_reverse;
533         gint print_use_duplex;
534         gint print_imgs;
535         gint print_previewwin_width;
536         gint print_previewwin_height;
537         
538         gboolean use_networkmanager;
539         gboolean use_shred;
540         gboolean two_line_vert;
541         gboolean inherit_folder_props;
542         gboolean flush_metadata;
543
544         gint nav_history_length;
545
546         gulong diff_added_color;
547         gulong diff_deleted_color;
548         gulong diff_hunk_color;
549         
550         gboolean folder_search_wildcard;
551         gboolean address_search_wildcard;
552
553         guint enable_avatars;
554
555 #ifndef PASSWORD_CRYPTO_OLD
556         gboolean use_master_passphrase;
557         gchar *master_passphrase;
558         gchar *master_passphrase_salt;
559         guint master_passphrase_pbkdf2_rounds;
560 #endif
561 };
562
563 extern PrefsCommon prefs_common;
564
565 PrefsCommon *prefs_common_get_prefs(void);
566
567 GList *prefs_common_read_history_from_dir_with_defaults(const gchar *dirname, const gchar *history,
568                                                                                                                           GList *default_list);
569 void prefs_common_read_config   (void);
570 void prefs_common_write_config  (void);
571 void prefs_common_open          (void);
572 void pref_get_unescaped_pref(gchar *out, const gchar *in);
573 void pref_get_escaped_pref(gchar *out, const gchar *in);
574 void pref_set_textview_from_pref(GtkTextView *textview, const gchar *txt);
575 void pref_set_entry_from_pref(GtkEntry *entry, const gchar *txt);
576 gchar *pref_get_pref_from_textview(GtkTextView *textview);
577 gchar *pref_get_pref_from_entry(GtkEntry *entry);
578 const gchar *prefs_common_translated_header_name(const gchar *header_name);
579 const gchar *prefs_common_get_uri_cmd(void);
580 const gchar *prefs_common_get_ext_editor_cmd(void);
581 #endif /* __PREFS_COMMON_H__ */