Statistics
| Revision:

root / libsylph / prefs_common.c @ 2164

History | View | Annotate | Download (22.7 KB)

1
/*
2
 * LibSylph -- E-Mail client library
3
 * Copyright (C) 1999-2009 Hiroyuki Yamamoto
4
 *
5
 * This library is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU Lesser General Public
7
 * License as published by the Free Software Foundation; either
8
 * version 2.1 of the License, or (at your option) any later version.
9
 *
10
 * This library 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 GNU
13
 * Lesser General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU Lesser General Public
16
 * License along with this library; if not, write to the Free Software
17
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
 */
19

    
20
#ifdef HAVE_CONFIG_H
21
#  include "config.h"
22
#endif
23

    
24
#include "defs.h"
25

    
26
#include <glib.h>
27
#include <glib/gi18n.h>
28
#include <stdio.h>
29
#include <errno.h>
30

    
31
#include "prefs.h"
32
#include "prefs_common.h"
33
#include "filter.h"
34
#include "codeconv.h"
35
#include "utils.h"
36

    
37
PrefsCommon prefs_common;
38

    
39
static PrefParam param[] = {
40
        /* Receive */
41
        {"autochk_newmail", "FALSE", &prefs_common.autochk_newmail, P_BOOL},
42
        {"autochk_interval", "10", &prefs_common.autochk_itv, P_INT},
43
        {"check_on_startup", "FALSE", &prefs_common.chk_on_startup, P_BOOL},
44
        {"scan_all_after_inc", "FALSE", &prefs_common.scan_all_after_inc,
45
         P_BOOL},
46
        {"enable_newmsg_notify", "FALSE", &prefs_common.enable_newmsg_notify,
47
         P_BOOL},
48
        {"newmsg_notify_command", NULL, &prefs_common.newmsg_notify_cmd,
49
         P_STRING},
50

    
51
        {"inc_local", "FALSE", &prefs_common.inc_local, P_BOOL},
52
        {"filter_on_inc_local", "TRUE", &prefs_common.filter_on_inc, P_BOOL},
53
        {"spool_path", DEFAULT_SPOOL_PATH, &prefs_common.spool_path, P_STRING},
54

    
55
        /* Send */
56
        {"save_message", "TRUE", &prefs_common.savemsg, P_BOOL},
57
        {"filter_sent_message", "FALSE", &prefs_common.filter_sent, P_BOOL},
58

    
59
        {"encoding_method", "0", &prefs_common.encoding_method, P_ENUM},
60
        {"mime_filename_encoding_method", "0",
61
         &prefs_common.mime_fencoding_method, P_ENUM},
62
        {"check_attach", "FALSE", &prefs_common.check_attach, P_BOOL},
63
        {"check_attach_str", NULL, &prefs_common.check_attach_str, P_STRING},
64
        {"check_recipients", "FALSE", &prefs_common.check_recipients, P_BOOL},
65
        {"check_recp_exclude", NULL, &prefs_common.check_recp_exclude,
66
         P_STRING},
67

    
68
        {"allow_jisx0201_kana", "FALSE", &prefs_common.allow_jisx0201_kana,
69
         P_BOOL},
70

    
71
        /* Compose */
72
        {"auto_signature", "TRUE", &prefs_common.auto_sig, P_BOOL},
73
        {"signature_separator", "-- ", &prefs_common.sig_sep, P_STRING},
74

    
75
        {"auto_ext_editor", "FALSE", &prefs_common.auto_exteditor, P_BOOL},
76

    
77
        {"undo_level", "50", &prefs_common.undolevels, P_INT},
78

    
79
        {"linewrap_length", "72", &prefs_common.linewrap_len, P_INT},
80
        {"linewrap_quotation", "FALSE", &prefs_common.linewrap_quote, P_BOOL},
81
        {"linewrap_auto", "FALSE", &prefs_common.autowrap, P_BOOL},
82

    
83
        {"enable_autosave", "FALSE", &prefs_common.enable_autosave, P_BOOL},
84
        {"autosave_interval", "5", &prefs_common.autosave_itv, P_INT},
85

    
86
        {"reply_with_quote", "TRUE", &prefs_common.reply_with_quote, P_BOOL},
87
        {"reply_account_autoselect", "TRUE",
88
         &prefs_common.reply_account_autosel, P_BOOL},
89
        {"default_reply_list", "TRUE", &prefs_common.default_reply_list,
90
         P_BOOL},
91
        {"inherit_recipient_on_self_reply", "FALSE",
92
         &prefs_common.inherit_recipient_on_self_reply, P_BOOL},
93

    
94
        {"show_ruler", "TRUE", &prefs_common.show_ruler, P_BOOL},
95

    
96
        /* Quote */
97
        {"reply_quote_mark", "> ", &prefs_common.quotemark, P_STRING},
98
        {"reply_quote_format", "On %d\\n%f wrote:\\n\\n%Q",
99
         &prefs_common.quotefmt, P_STRING},
100

    
101
        {"forward_quote_mark", "> ", &prefs_common.fw_quotemark, P_STRING},
102
        {"forward_quote_format",
103
         "\\n\\nBegin forwarded message:\\n\\n"
104
         "?d{Date: %d\\n}?f{From: %f\\n}?t{To: %t\\n}?c{Cc: %c\\n}"
105
         "?n{Newsgroups: %n\\n}?s{Subject: %s\\n}\\n\\n%M",
106
         &prefs_common.fw_quotefmt, P_STRING},
107

    
108
        /* Spelling */
109
        {"check_spell", "FALSE", &prefs_common.check_spell, P_BOOL},
110
        {"spell_lang", "en", &prefs_common.spell_lang, P_STRING},
111

    
112
        /* Display */
113
        {"message_font_name", DEFAULT_MESSAGE_FONT, &prefs_common.textfont,
114
         P_STRING},
115

    
116
        {"display_folder_unread_num", "TRUE",
117
         &prefs_common.display_folder_unread, P_BOOL},
118
        {"display_folder_num_columns", "FALSE",
119
         &prefs_common.display_folder_num_columns, P_BOOL},
120

    
121
        {"newsgroup_abbrev_len", "16", &prefs_common.ng_abbrev_len, P_INT},
122

    
123
        {"translate_header", "TRUE", &prefs_common.trans_hdr, P_BOOL},
124

    
125
        /* Display: Summary View */
126
        {"enable_swap_from", "FALSE", &prefs_common.swap_from, P_BOOL},
127
        {"date_format", "%y/%m/%d(%a) %H:%M", &prefs_common.date_format,
128
         P_STRING},
129
        {"expand_thread", "TRUE", &prefs_common.expand_thread, P_BOOL},
130

    
131
        {"enable_rules_hint", "TRUE", &prefs_common.enable_rules_hint, P_BOOL},
132
        {"bold_unread", "TRUE", &prefs_common.bold_unread, P_BOOL},
133

    
134
        {"persist_qsearch_filter", "TRUE", &prefs_common.persist_qsearch_filter,
135
         P_BOOL},
136

    
137
        {"toolbar_style", "4", &prefs_common.toolbar_style, P_ENUM},
138
        {"show_searchbar", "TRUE", &prefs_common.show_searchbar, P_BOOL},
139
        {"show_statusbar", "TRUE", &prefs_common.show_statusbar, P_BOOL},
140

    
141
        {"main_toolbar_setting", NULL, &prefs_common.main_toolbar_setting,
142
         P_STRING},
143
        {"compose_toolbar_setting", NULL,
144
         &prefs_common.compose_toolbar_setting, P_STRING},
145

    
146
        {"layout_type", "0", &prefs_common.layout_type, P_ENUM},
147

    
148
        {"summary_col_show_mark", "TRUE",
149
         &prefs_common.summary_col_visible[S_COL_MARK], P_BOOL},
150
        {"summary_col_show_unread", "TRUE",
151
         &prefs_common.summary_col_visible[S_COL_UNREAD], P_BOOL},
152
        {"summary_col_show_mime", "TRUE",
153
         &prefs_common.summary_col_visible[S_COL_MIME], P_BOOL},
154
        {"summary_col_show_subject", "TRUE",
155
         &prefs_common.summary_col_visible[S_COL_SUBJECT], P_BOOL},
156
        {"summary_col_show_from", "TRUE",
157
         &prefs_common.summary_col_visible[S_COL_FROM], P_BOOL},
158
        {"summary_col_show_date", "TRUE",
159
         &prefs_common.summary_col_visible[S_COL_DATE], P_BOOL},
160
        {"summary_col_show_size", "TRUE",
161
         &prefs_common.summary_col_visible[S_COL_SIZE], P_BOOL},
162
        {"summary_col_show_number", "FALSE",
163
         &prefs_common.summary_col_visible[S_COL_NUMBER], P_BOOL},
164
        {"summary_col_show_to", "FALSE",
165
         &prefs_common.summary_col_visible[S_COL_TO], P_BOOL},
166

    
167
        {"summary_col_pos_mark", "0",
168
          &prefs_common.summary_col_pos[S_COL_MARK], P_INT},
169
        {"summary_col_pos_unread", "1",
170
          &prefs_common.summary_col_pos[S_COL_UNREAD], P_INT},
171
        {"summary_col_pos_mime", "2",
172
          &prefs_common.summary_col_pos[S_COL_MIME], P_INT},
173
        {"summary_col_pos_subject", "3",
174
          &prefs_common.summary_col_pos[S_COL_SUBJECT], P_INT},
175
        {"summary_col_pos_from", "4",
176
          &prefs_common.summary_col_pos[S_COL_FROM], P_INT},
177
        {"summary_col_pos_date", "5",
178
          &prefs_common.summary_col_pos[S_COL_DATE], P_INT},
179
        {"summary_col_pos_size", "6",
180
          &prefs_common.summary_col_pos[S_COL_SIZE], P_INT},
181
        {"summary_col_pos_number", "7",
182
          &prefs_common.summary_col_pos[S_COL_NUMBER], P_INT},
183
        {"summary_col_pos_to", "8",
184
          &prefs_common.summary_col_pos[S_COL_TO], P_INT},
185

    
186
        {"summary_sent_col_show_mark", "TRUE",
187
         &prefs_common.summary_sent_col_visible[S_COL_MARK], P_BOOL},
188
        {"summary_sent_col_show_unread", "TRUE",
189
         &prefs_common.summary_sent_col_visible[S_COL_UNREAD], P_BOOL},
190
        {"summary_sent_col_show_mime", "TRUE",
191
         &prefs_common.summary_sent_col_visible[S_COL_MIME], P_BOOL},
192
        {"summary_sent_col_show_subject", "TRUE",
193
         &prefs_common.summary_sent_col_visible[S_COL_SUBJECT], P_BOOL},
194
        {"summary_sent_col_show_from", "FALSE",
195
         &prefs_common.summary_sent_col_visible[S_COL_FROM], P_BOOL},
196
        {"summary_sent_col_show_date", "TRUE",
197
         &prefs_common.summary_sent_col_visible[S_COL_DATE], P_BOOL},
198
        {"summary_sent_col_show_size", "TRUE",
199
         &prefs_common.summary_sent_col_visible[S_COL_SIZE], P_BOOL},
200
        {"summary_sent_col_show_number", "FALSE",
201
         &prefs_common.summary_sent_col_visible[S_COL_NUMBER], P_BOOL},
202
        {"summary_sent_col_show_to", "TRUE",
203
         &prefs_common.summary_sent_col_visible[S_COL_TO], P_BOOL},
204

    
205
        {"summary_sent_col_pos_mark", "0",
206
          &prefs_common.summary_sent_col_pos[S_COL_MARK], P_INT},
207
        {"summary_sent_col_pos_unread", "1",
208
          &prefs_common.summary_sent_col_pos[S_COL_UNREAD], P_INT},
209
        {"summary_sent_col_pos_mime", "2",
210
          &prefs_common.summary_sent_col_pos[S_COL_MIME], P_INT},
211
        {"summary_sent_col_pos_subject", "3",
212
          &prefs_common.summary_sent_col_pos[S_COL_SUBJECT], P_INT},
213
        {"summary_sent_col_pos_from", "8",
214
          &prefs_common.summary_sent_col_pos[S_COL_FROM], P_INT},
215
        {"summary_sent_col_pos_date", "5",
216
          &prefs_common.summary_sent_col_pos[S_COL_DATE], P_INT},
217
        {"summary_sent_col_pos_size", "6",
218
          &prefs_common.summary_sent_col_pos[S_COL_SIZE], P_INT},
219
        {"summary_sent_col_pos_number", "7",
220
          &prefs_common.summary_sent_col_pos[S_COL_NUMBER], P_INT},
221
        {"summary_sent_col_pos_to", "4",
222
          &prefs_common.summary_sent_col_pos[S_COL_TO], P_INT},
223

    
224
        {"summary_col_size_mark", "10",
225
         &prefs_common.summary_col_size[S_COL_MARK], P_INT},
226
        {"summary_col_size_unread", "13",
227
         &prefs_common.summary_col_size[S_COL_UNREAD], P_INT},
228
        {"summary_col_size_mime", "10",
229
         &prefs_common.summary_col_size[S_COL_MIME], P_INT},
230
        {"summary_col_size_subject", "200",
231
         &prefs_common.summary_col_size[S_COL_SUBJECT], P_INT},
232
        {"summary_col_size_from", "120",
233
         &prefs_common.summary_col_size[S_COL_FROM], P_INT},
234
        {"summary_col_size_date", "118",
235
         &prefs_common.summary_col_size[S_COL_DATE], P_INT},
236
        {"summary_col_size_size", "45",
237
         &prefs_common.summary_col_size[S_COL_SIZE], P_INT},
238
        {"summary_col_size_number", "40",
239
         &prefs_common.summary_col_size[S_COL_NUMBER], P_INT},
240
        {"summary_col_size_to", "120",
241
         &prefs_common.summary_col_size[S_COL_TO], P_INT},
242

    
243
        /* Widget size */
244
        {"folderwin_x", "16", &prefs_common.folderwin_x, P_INT},
245
        {"folderwin_y", "16", &prefs_common.folderwin_y, P_INT},
246
        {"folderview_width", "179", &prefs_common.folderview_width, P_INT},
247
        {"folderview_height", "450", &prefs_common.folderview_height, P_INT},
248
        {"folderview_visible", "TRUE", &prefs_common.folderview_visible,
249
         P_BOOL},
250

    
251
        {"folder_col_folder", "150", &prefs_common.folder_col_folder, P_INT},
252
        {"folder_col_new", "32", &prefs_common.folder_col_new, P_INT},
253
        {"folder_col_unread", "32", &prefs_common.folder_col_unread, P_INT},
254
        {"folder_col_total", "32", &prefs_common.folder_col_total, P_INT},
255

    
256
        {"summaryview_width", "600", &prefs_common.summaryview_width, P_INT},
257
        {"summaryview_height", "180", &prefs_common.summaryview_height, P_INT},
258
        {"summaryview_vwidth", "300", &prefs_common.summaryview_vwidth, P_INT},
259
        {"summaryview_vheight", "600", &prefs_common.summaryview_vheight,
260
         P_INT},
261

    
262
        {"main_messagewin_x", "256", &prefs_common.main_msgwin_x, P_INT},
263
        {"main_messagewin_y", "210", &prefs_common.main_msgwin_y, P_INT},
264
        {"messageview_width", "600", &prefs_common.msgview_width, P_INT},
265
        {"messageview_height", "300", &prefs_common.msgview_height, P_INT},
266
        {"messageview_vwidth", "300", &prefs_common.msgview_vwidth, P_INT},
267
        {"messageview_vheight", "600", &prefs_common.msgview_vheight, P_INT},
268
        {"messageview_visible", "TRUE", &prefs_common.msgview_visible, P_BOOL},
269

    
270
        {"mainview_x", "64", &prefs_common.mainview_x, P_INT},
271
        {"mainview_y", "64", &prefs_common.mainview_y, P_INT},
272
        {"mainview_width", "600", &prefs_common.mainview_width, P_INT},
273
        {"mainview_height", "600", &prefs_common.mainview_height, P_INT},
274
        {"mainwin_x", "64", &prefs_common.mainwin_x, P_INT},
275
        {"mainwin_y", "64", &prefs_common.mainwin_y, P_INT},
276
        {"mainwin_width", "800", &prefs_common.mainwin_width, P_INT},
277
        {"mainwin_height", "600", &prefs_common.mainwin_height, P_INT},
278
        {"messagewin_width", "600", &prefs_common.msgwin_width, P_INT},
279
        {"messagewin_height", "540", &prefs_common.msgwin_height, P_INT},
280

    
281
        {"mainwin_maximized", "FALSE", &prefs_common.mainwin_maximized, P_BOOL},
282

    
283
        {"sourcewin_width", "600", &prefs_common.sourcewin_width, P_INT},
284
        {"sourcewin_height", "500", &prefs_common.sourcewin_height, P_INT},
285

    
286
        {"compose_x", "32", &prefs_common.compose_x, P_INT},
287
        {"compose_y", "32", &prefs_common.compose_y, P_INT},
288
        {"compose_width", "600", &prefs_common.compose_width, P_INT},
289
        {"compose_height", "560", &prefs_common.compose_height, P_INT},
290

    
291
        {"compose_maximized", "FALSE", &prefs_common.compose_maximized, P_BOOL},
292

    
293
        {"addressbook_x", "32", &prefs_common.addressbook_x, P_INT},
294
        {"addressbook_y", "32", &prefs_common.addressbook_y, P_INT},
295
        {"addressbook_width", "620", &prefs_common.addressbook_width, P_INT},
296
        {"addressbook_height", "360", &prefs_common.addressbook_height, P_INT},
297

    
298
        /* Message */
299
        {"enable_color", "TRUE", &prefs_common.enable_color, P_BOOL},
300

    
301
        {"quote_level1_color", "179", &prefs_common.quote_level1_col, P_INT},
302
        {"quote_level2_color", "179", &prefs_common.quote_level2_col, P_INT},
303
        {"quote_level3_color", "179", &prefs_common.quote_level3_col, P_INT},
304
        {"uri_color", "32512", &prefs_common.uri_col, P_INT},
305
        {"signature_color", "0", &prefs_common.sig_col, P_USHORT},
306
        {"recycle_quote_colors", "FALSE", &prefs_common.recycle_quote_colors,
307
         P_BOOL},
308

    
309
        {"convert_mb_alnum", "FALSE", &prefs_common.conv_mb_alnum, P_BOOL},
310
        {"display_header_pane", "TRUE", &prefs_common.display_header_pane,
311
         P_BOOL},
312
        {"display_header", "TRUE", &prefs_common.display_header, P_BOOL},
313
        {"render_html", "TRUE", &prefs_common.render_html, P_BOOL},
314
        {"html_only_as_attach", "FALSE", &prefs_common.html_only_as_attach,
315
         P_BOOL},
316
        {"line_space", "2", &prefs_common.line_space, P_INT},
317

    
318
        {"textview_cursor_visible", "FALSE",
319
         &prefs_common.textview_cursor_visible, P_BOOL},
320

    
321
        {"enable_smooth_scroll", "FALSE", &prefs_common.enable_smooth_scroll,
322
         P_BOOL},
323
        {"scroll_step", "1", &prefs_common.scroll_step, P_INT},
324
        {"scroll_half_page", "FALSE", &prefs_common.scroll_halfpage, P_BOOL},
325

    
326
        {"resize_image", "TRUE", &prefs_common.resize_image, P_BOOL},
327
        {"inline_image", "TRUE", &prefs_common.inline_image, P_BOOL},
328

    
329
        /* Encoding */
330
        {"default_encoding", NULL, &prefs_common.default_encoding, P_STRING},
331
        {"outgoing_charset", NULL, &prefs_common.outgoing_charset, P_STRING},
332

    
333
        {"show_other_header", "FALSE", &prefs_common.show_other_header, P_BOOL},
334

    
335
        /* MIME viewer */
336
        {"mime_image_viewer", NULL, &prefs_common.mime_image_viewer, P_STRING},
337
        {"mime_audio_player", NULL, &prefs_common.mime_audio_player, P_STRING},
338
#ifdef G_OS_WIN32
339
        {"mime_open_command", "notepad '%s'", &prefs_common.mime_open_cmd,
340
#else
341
        {"mime_open_command", "gedit '%s'", &prefs_common.mime_open_cmd,
342
#endif
343
         P_STRING},
344
        {"mime_command", NULL, &prefs_common.mime_cmd, P_STRING},
345

    
346
        /* Junk mail */
347
        {"enable_junk", "FALSE", &prefs_common.enable_junk, P_BOOL},
348
#ifdef G_OS_WIN32
349
        {"junk_learn_command", "bsfilterw -C -s -u",
350
         &prefs_common.junk_learncmd, P_STRING},
351
        {"nojunk_learn_command", "bsfilterw -c -S -u",
352
         &prefs_common.nojunk_learncmd, P_STRING},
353
        {"junk_classify_command", "bsfilterw",
354
         &prefs_common.junk_classify_cmd, P_STRING},
355
#else
356
        {"junk_learn_command", "bogofilter -N -s -I",
357
         &prefs_common.junk_learncmd, P_STRING},
358
        {"nojunk_learn_command", "bogofilter -n -S -I",
359
         &prefs_common.nojunk_learncmd, P_STRING},
360
        {"junk_classify_command", "bogofilter -I",
361
         &prefs_common.junk_classify_cmd, P_STRING},
362
#endif
363
        {"junk_folder", NULL, &prefs_common.junk_folder, P_STRING},
364
        {"filter_junk_on_receive", "FALSE", &prefs_common.filter_junk_on_recv,
365
         P_BOOL},
366
        {"filter_junk_before", "FALSE", &prefs_common.filter_junk_before,
367
         P_BOOL},
368
        {"delete_junk_on_receive", "TRUE", &prefs_common.delete_junk_on_recv,
369
         P_BOOL},
370
        {"mark_junk_as_read", "FALSE", &prefs_common.mark_junk_as_read, P_BOOL},
371

    
372
        /* Privacy */
373
        {"auto_check_signatures", "TRUE", &prefs_common.auto_check_signatures,
374
         P_BOOL},
375
        {"gpg_signature_popup", "FALSE", &prefs_common.gpg_signature_popup,
376
         P_BOOL},
377
        {"store_passphrase", "FALSE", &prefs_common.store_passphrase, P_BOOL},
378
        {"store_passphrase_timeout", "0",
379
         &prefs_common.store_passphrase_timeout, P_INT},
380
        {"passphrase_grab", "FALSE", &prefs_common.passphrase_grab, P_BOOL},
381
#ifdef G_OS_WIN32
382
        {"show_gpg_warning", "FALSE", &prefs_common.gpg_warning, P_BOOL},
383
#else
384
        {"show_gpg_warning", "TRUE", &prefs_common.gpg_warning, P_BOOL},
385
#endif
386

    
387
        /* Interface */
388
        {"separate_folder", "FALSE", &prefs_common.sep_folder, P_BOOL},
389
        {"separate_message", "FALSE", &prefs_common.sep_msg, P_BOOL},
390

    
391
        {"always_show_message_when_selected", "FALSE",
392
         &prefs_common.always_show_msg, P_BOOL},
393
        {"open_unread_on_enter", "FALSE", &prefs_common.open_unread_on_enter,
394
         P_BOOL},
395
        {"remember_last_selected", "FALSE",
396
         &prefs_common.remember_last_selected, P_BOOL},
397
        {"mark_as_read_on_new_window", "FALSE",
398
         &prefs_common.mark_as_read_on_new_window, P_BOOL},
399
        {"open_inbox_on_inc", "FALSE", &prefs_common.open_inbox_on_inc, P_BOOL},
400
        {"open_inbox_on_startup", "FALSE", &prefs_common.open_inbox_on_startup,
401
         P_BOOL},
402
        {"immediate_execution", "TRUE", &prefs_common.immediate_exec, P_BOOL},
403

    
404
#ifdef G_OS_WIN32
405
        {"comply_gnome_hig", "FALSE", &prefs_common.comply_gnome_hig, P_BOOL},
406
#else
407
        {"comply_gnome_hig", "TRUE", &prefs_common.comply_gnome_hig, P_BOOL},
408
#endif
409

    
410
        {"show_trayicon", "TRUE", &prefs_common.show_trayicon, P_BOOL},
411
        {"minimize_to_tray", "FALSE", &prefs_common.minimize_to_tray, P_BOOL},
412
#ifdef G_OS_WIN32
413
        {"toggle_window_on_trayicon_click", "FALSE",
414
#else
415
        {"toggle_window_on_trayicon_click", "TRUE",
416
#endif
417
         &prefs_common.toggle_window_on_trayicon_click, P_BOOL},
418

    
419
        /* Other */
420
        {"receive_dialog_mode", "1", &prefs_common.recv_dialog_mode, P_ENUM},
421
        {"no_receive_error_panel", "FALSE", &prefs_common.no_recv_err_panel,
422
         P_BOOL},
423
        {"close_receive_dialog", "TRUE", &prefs_common.close_recv_dialog,
424
         P_BOOL},
425

    
426
        {"add_address_by_click", "FALSE", &prefs_common.add_address_by_click,
427
         P_BOOL},
428

    
429
        {"confirm_on_exit", "FALSE", &prefs_common.confirm_on_exit, P_BOOL},
430
        {"clean_trash_on_exit", "FALSE", &prefs_common.clean_on_exit, P_BOOL},
431
        {"ask_on_cleaning", "TRUE", &prefs_common.ask_on_clean, P_BOOL},
432
        {"warn_queued_on_exit", "TRUE", &prefs_common.warn_queued_on_exit,
433
         P_BOOL},
434

    
435
        {"logwindow_line_limit", "1000", &prefs_common.logwin_line_limit,
436
         P_INT},
437

    
438
        /* External commands */
439
#ifdef G_OS_WIN32
440
        {"uri_open_command", NULL, &prefs_common.uri_cmd,
441
#else
442
        {"uri_open_command", DEFAULT_BROWSER_CMD, &prefs_common.uri_cmd,
443
#endif
444
         P_STRING},
445
#ifdef G_OS_WIN32
446
        {"ext_editor_command", "notepad '%s'", &prefs_common.ext_editor_cmd,
447
#else
448
        {"ext_editor_command", "gedit %s", &prefs_common.ext_editor_cmd,
449
#endif
450
         P_STRING},
451

    
452
        {"use_print_command", "FALSE", &prefs_common.use_print_cmd, P_BOOL},
453
#ifdef G_OS_WIN32
454
        {"print_command", NULL, &prefs_common.print_cmd, P_STRING},
455
#else
456
        {"print_command", "lpr %s", &prefs_common.print_cmd, P_STRING},
457
#endif
458

    
459
        {"use_ext_inc", "FALSE", &prefs_common.use_extinc, P_BOOL},
460
        {"ext_inc_path", DEFAULT_INC_PATH, &prefs_common.extinc_cmd, P_STRING},
461
        {"use_ext_sendmail", "FALSE", &prefs_common.use_extsend, P_BOOL},
462
        {"ext_sendmail_cmd", DEFAULT_SENDMAIL_CMD, &prefs_common.extsend_cmd,
463
         P_STRING},
464

    
465
        /* Update check */
466
        {"auto_update_check", "TRUE", &prefs_common.auto_update_check, P_BOOL},
467
        {"use_http_proxy", "FALSE", &prefs_common.use_http_proxy, P_BOOL},
468
        {"http_proxy_host", NULL, &prefs_common.http_proxy_host, P_STRING},
469

    
470
        /* Advanced */
471
        {"strict_cache_check", "FALSE", &prefs_common.strict_cache_check,
472
         P_BOOL},
473
        {"io_timeout_secs", "60", &prefs_common.io_timeout_secs, P_INT},
474

    
475
        {NULL, NULL, NULL, P_OTHER}
476
};
477

    
478

    
479
PrefsCommon *prefs_common_get(void)
480
{
481
        return &prefs_common;
482
}
483

    
484
PrefParam *prefs_common_get_params(void)
485
{
486
        return param;
487
}
488

    
489
void prefs_common_read_config(void)
490
{
491
        FILE *fp;
492
        gchar *path;
493
        gchar buf[PREFSBUFSIZE];
494

    
495
        path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, COMMON_RC, NULL);
496

    
497
        prefs_read_config(param, "Common", path, NULL);
498

    
499
        g_free(path);
500

    
501
        prefs_common.online_mode = TRUE;
502

    
503
        prefs_common_junk_filter_list_set();
504

    
505
        path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, COMMAND_HISTORY,
506
                           NULL);
507
        if ((fp = g_fopen(path, "rb")) == NULL) {
508
                if (ENOENT != errno) FILE_OP_ERROR(path, "fopen");
509
                g_free(path);
510
                return;
511
        }
512
        g_free(path);
513
        while (fgets(buf, sizeof(buf), fp) != NULL) {
514
                g_strstrip(buf);
515
                if (buf[0] == '\0') continue;
516
                prefs_common.mime_open_cmd_history =
517
                        add_history(prefs_common.mime_open_cmd_history, buf);
518
        }
519
        fclose(fp);
520

    
521
        prefs_common.mime_open_cmd_history =
522
                g_list_reverse(prefs_common.mime_open_cmd_history);
523
}
524

    
525
void prefs_common_write_config(void)
526
{
527
        GList *cur;
528
        FILE *fp;
529
        gchar *path;
530

    
531
        prefs_write_config(param, "Common", COMMON_RC);
532

    
533
        path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, COMMAND_HISTORY,
534
                           NULL);
535
        if ((fp = g_fopen(path, "wb")) == NULL) {
536
                FILE_OP_ERROR(path, "fopen");
537
                g_free(path);
538
                return;
539
        }
540

    
541
        for (cur = prefs_common.mime_open_cmd_history;
542
             cur != NULL; cur = cur->next) {
543
                fputs((gchar *)cur->data, fp);
544
                fputc('\n', fp);
545
        }
546

    
547
        fclose(fp);
548
        g_free(path);
549
}
550

    
551
static FilterRule *prefs_common_junk_filter_rule_create(gboolean is_manual)
552
{
553
        FilterRule *rule;
554
        FilterCond *cond;
555
        FilterAction *action;
556
        GSList *cond_list = NULL, *action_list = NULL;
557

    
558
        cond = filter_cond_new(FLT_COND_CMD_TEST, 0, 0, NULL,
559
                               prefs_common.junk_classify_cmd);
560
        cond_list = g_slist_append(NULL, cond);
561
        if (prefs_common.delete_junk_on_recv && !is_manual) {
562
                action = filter_action_new(FLT_ACTION_COPY,
563
                                           prefs_common.junk_folder);
564
                action_list = g_slist_append(NULL, action);
565
                action = filter_action_new(FLT_ACTION_DELETE, NULL);
566
                action_list = g_slist_append(action_list, action);
567
        } else {
568
                action = filter_action_new(FLT_ACTION_MOVE,
569
                                           prefs_common.junk_folder);
570
                action_list = g_slist_append(NULL, action);
571
        }
572

    
573
        if (prefs_common.mark_junk_as_read) {
574
                action = filter_action_new(FLT_ACTION_MARK_READ, NULL);
575
                action_list = g_slist_append(action_list, action);
576
        }
577

    
578
        if (is_manual)
579
                rule = filter_rule_new(_("Junk mail filter (manual)"), FLT_OR,
580
                                        cond_list, action_list);
581
        else
582
                rule = filter_rule_new(_("Junk mail filter"), FLT_OR,
583
                                       cond_list, action_list);
584

    
585
        return rule;
586
}
587

    
588
void prefs_common_junk_filter_list_set(void)
589
{
590
        FilterRule *rule;
591

    
592
        if (prefs_common.junk_fltlist) {
593
                filter_rule_list_free(prefs_common.junk_fltlist);
594
                prefs_common.junk_fltlist = NULL;
595
        }
596
        if (prefs_common.manual_junk_fltlist) {
597
                filter_rule_list_free(prefs_common.manual_junk_fltlist);
598
                prefs_common.manual_junk_fltlist = NULL;
599
        }
600

    
601
        if (!prefs_common.junk_classify_cmd || !prefs_common.junk_folder)
602
                return;
603

    
604
        rule = prefs_common_junk_filter_rule_create(FALSE);
605
        prefs_common.junk_fltlist = g_slist_append(NULL, rule);
606

    
607
        rule = prefs_common_junk_filter_rule_create(TRUE);
608
        prefs_common.manual_junk_fltlist = g_slist_append(NULL, rule);
609
}
610

    
611
void prefs_common_junk_folder_rename_path(const gchar *old_path,
612
                                          const gchar *new_path)
613
{
614
        gint len;
615
        gchar *base;
616
        gchar *dest_path;
617

    
618
        g_return_if_fail(old_path != NULL);
619
        g_return_if_fail(new_path != NULL);
620

    
621
        if (!prefs_common.junk_folder)
622
                return;
623

    
624
        len = strlen(old_path);
625

    
626
        if (!strncmp(old_path, prefs_common.junk_folder, len)) {
627
                base = prefs_common.junk_folder + len;
628
                if (*base != '/' && *base != '\0')
629
                        return;
630
                while (*base == '/') base++;
631
                if (*base == '\0')
632
                        dest_path = g_strdup(new_path);
633
                else
634
                        dest_path = g_strconcat(new_path, "/", base, NULL);
635
                debug_print("prefs_common_junk_folder_rename_path(): "
636
                            "renaming %s -> %s\n", prefs_common.junk_folder,
637
                            dest_path);
638
                g_free(prefs_common.junk_folder);
639
                prefs_common.junk_folder = dest_path;
640
                prefs_common_junk_filter_list_set();
641
        }
642
}