root / libsylph / prefs_common.c @ 2649
History | View | Annotate | Download (23.7 kB)
| 1 | /*
|
|---|---|
| 2 | * LibSylph -- E-Mail client library |
| 3 | * Copyright (C) 1999-2010 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 | {"recipients_autoreg", "TRUE", &prefs_common.recipients_autoreg,
|
| 59 | P_BOOL}, |
| 60 | |
| 61 | {"encoding_method", "0", &prefs_common.encoding_method, P_ENUM},
|
| 62 | {"mime_filename_encoding_method", "0",
|
| 63 | &prefs_common.mime_fencoding_method, P_ENUM}, |
| 64 | {"check_attach", "FALSE", &prefs_common.check_attach, P_BOOL},
|
| 65 | {"check_attach_str", NULL, &prefs_common.check_attach_str, P_STRING},
|
| 66 | {"check_recipients", "FALSE", &prefs_common.check_recipients, P_BOOL},
|
| 67 | {"check_recp_exclude", NULL, &prefs_common.check_recp_exclude,
|
| 68 | P_STRING}, |
| 69 | |
| 70 | {"allow_jisx0201_kana", "FALSE", &prefs_common.allow_jisx0201_kana,
|
| 71 | P_BOOL}, |
| 72 | |
| 73 | /* Compose */
|
| 74 | {"auto_signature", "TRUE", &prefs_common.auto_sig, P_BOOL},
|
| 75 | {"signature_separator", "-- ", &prefs_common.sig_sep, P_STRING},
|
| 76 | |
| 77 | {"auto_ext_editor", "FALSE", &prefs_common.auto_exteditor, P_BOOL},
|
| 78 | |
| 79 | {"undo_level", "50", &prefs_common.undolevels, P_INT},
|
| 80 | |
| 81 | {"linewrap_length", "72", &prefs_common.linewrap_len, P_INT},
|
| 82 | {"linewrap_quotation", "FALSE", &prefs_common.linewrap_quote, P_BOOL},
|
| 83 | {"linewrap_auto", "FALSE", &prefs_common.autowrap, P_BOOL},
|
| 84 | |
| 85 | {"enable_autosave", "FALSE", &prefs_common.enable_autosave, P_BOOL},
|
| 86 | {"autosave_interval", "5", &prefs_common.autosave_itv, P_INT},
|
| 87 | |
| 88 | {"reply_with_quote", "TRUE", &prefs_common.reply_with_quote, P_BOOL},
|
| 89 | {"reply_account_autoselect", "TRUE",
|
| 90 | &prefs_common.reply_account_autosel, P_BOOL}, |
| 91 | {"default_reply_list", "TRUE", &prefs_common.default_reply_list,
|
| 92 | P_BOOL}, |
| 93 | {"inherit_recipient_on_self_reply", "FALSE",
|
| 94 | &prefs_common.inherit_recipient_on_self_reply, P_BOOL}, |
| 95 | {"reply_address_only", "FALSE",
|
| 96 | &prefs_common.reply_address_only, P_BOOL}, |
| 97 | |
| 98 | {"show_ruler", "TRUE", &prefs_common.show_ruler, P_BOOL},
|
| 99 | |
| 100 | /* Quote */
|
| 101 | {"reply_quote_mark", "> ", &prefs_common.quotemark, P_STRING},
|
| 102 | {"reply_quote_format", "On %d\\n%f wrote:\\n\\n%Q",
|
| 103 | &prefs_common.quotefmt, P_STRING}, |
| 104 | |
| 105 | {"forward_quote_mark", "> ", &prefs_common.fw_quotemark, P_STRING},
|
| 106 | {"forward_quote_format",
|
| 107 | "\\n\\nBegin forwarded message:\\n\\n"
|
| 108 | "?d{Date: %d\\n}?f{From: %f\\n}?t{To: %t\\n}?c{Cc: %c\\n}"
|
| 109 | "?n{Newsgroups: %n\\n}?s{Subject: %s\\n}\\n\\n%M",
|
| 110 | &prefs_common.fw_quotefmt, P_STRING}, |
| 111 | |
| 112 | /* Spelling */
|
| 113 | {"check_spell", "FALSE", &prefs_common.check_spell, P_BOOL},
|
| 114 | {"spell_lang", "en", &prefs_common.spell_lang, P_STRING},
|
| 115 | |
| 116 | /* Display */
|
| 117 | {"message_font_name", DEFAULT_MESSAGE_FONT, &prefs_common.textfont,
|
| 118 | P_STRING}, |
| 119 | |
| 120 | {"display_folder_unread_num", "TRUE",
|
| 121 | &prefs_common.display_folder_unread, P_BOOL}, |
| 122 | {"display_folder_num_columns", "FALSE",
|
| 123 | &prefs_common.display_folder_num_columns, P_BOOL}, |
| 124 | {"folder_col_show_new", "FALSE",
|
| 125 | &prefs_common.folder_col_visible[1], P_BOOL},
|
| 126 | {"folder_col_show_unread", "FALSE",
|
| 127 | &prefs_common.folder_col_visible[2], P_BOOL},
|
| 128 | {"folder_col_show_total", "FALSE",
|
| 129 | &prefs_common.folder_col_visible[3], P_BOOL},
|
| 130 | |
| 131 | {"newsgroup_abbrev_len", "16", &prefs_common.ng_abbrev_len, P_INT},
|
| 132 | |
| 133 | {"translate_header", "TRUE", &prefs_common.trans_hdr, P_BOOL},
|
| 134 | |
| 135 | /* Display: Summary View */
|
| 136 | {"enable_swap_from", "FALSE", &prefs_common.swap_from, P_BOOL},
|
| 137 | {"date_format", "%y/%m/%d(%a) %H:%M", &prefs_common.date_format,
|
| 138 | P_STRING}, |
| 139 | {"expand_thread", "TRUE", &prefs_common.expand_thread, P_BOOL},
|
| 140 | |
| 141 | {"enable_rules_hint", "TRUE", &prefs_common.enable_rules_hint, P_BOOL},
|
| 142 | {"bold_unread", "TRUE", &prefs_common.bold_unread, P_BOOL},
|
| 143 | |
| 144 | {"persist_qsearch_filter", "TRUE", &prefs_common.persist_qsearch_filter,
|
| 145 | P_BOOL}, |
| 146 | |
| 147 | {"toolbar_style", "4", &prefs_common.toolbar_style, P_ENUM},
|
| 148 | {"show_searchbar", "TRUE", &prefs_common.show_searchbar, P_BOOL},
|
| 149 | {"show_statusbar", "TRUE", &prefs_common.show_statusbar, P_BOOL},
|
| 150 | |
| 151 | {"main_toolbar_setting", NULL, &prefs_common.main_toolbar_setting,
|
| 152 | P_STRING}, |
| 153 | {"compose_toolbar_setting", NULL,
|
| 154 | &prefs_common.compose_toolbar_setting, P_STRING}, |
| 155 | |
| 156 | {"layout_type", "0", &prefs_common.layout_type, P_ENUM},
|
| 157 | |
| 158 | {"summary_col_show_mark", "TRUE",
|
| 159 | &prefs_common.summary_col_visible[S_COL_MARK], P_BOOL}, |
| 160 | {"summary_col_show_unread", "TRUE",
|
| 161 | &prefs_common.summary_col_visible[S_COL_UNREAD], P_BOOL}, |
| 162 | {"summary_col_show_mime", "TRUE",
|
| 163 | &prefs_common.summary_col_visible[S_COL_MIME], P_BOOL}, |
| 164 | {"summary_col_show_subject", "TRUE",
|
| 165 | &prefs_common.summary_col_visible[S_COL_SUBJECT], P_BOOL}, |
| 166 | {"summary_col_show_from", "TRUE",
|
| 167 | &prefs_common.summary_col_visible[S_COL_FROM], P_BOOL}, |
| 168 | {"summary_col_show_date", "TRUE",
|
| 169 | &prefs_common.summary_col_visible[S_COL_DATE], P_BOOL}, |
| 170 | {"summary_col_show_size", "TRUE",
|
| 171 | &prefs_common.summary_col_visible[S_COL_SIZE], P_BOOL}, |
| 172 | {"summary_col_show_number", "FALSE",
|
| 173 | &prefs_common.summary_col_visible[S_COL_NUMBER], P_BOOL}, |
| 174 | {"summary_col_show_to", "FALSE",
|
| 175 | &prefs_common.summary_col_visible[S_COL_TO], P_BOOL}, |
| 176 | |
| 177 | {"summary_col_pos_mark", "0",
|
| 178 | &prefs_common.summary_col_pos[S_COL_MARK], P_INT}, |
| 179 | {"summary_col_pos_unread", "1",
|
| 180 | &prefs_common.summary_col_pos[S_COL_UNREAD], P_INT}, |
| 181 | {"summary_col_pos_mime", "2",
|
| 182 | &prefs_common.summary_col_pos[S_COL_MIME], P_INT}, |
| 183 | {"summary_col_pos_subject", "3",
|
| 184 | &prefs_common.summary_col_pos[S_COL_SUBJECT], P_INT}, |
| 185 | {"summary_col_pos_from", "4",
|
| 186 | &prefs_common.summary_col_pos[S_COL_FROM], P_INT}, |
| 187 | {"summary_col_pos_date", "5",
|
| 188 | &prefs_common.summary_col_pos[S_COL_DATE], P_INT}, |
| 189 | {"summary_col_pos_size", "6",
|
| 190 | &prefs_common.summary_col_pos[S_COL_SIZE], P_INT}, |
| 191 | {"summary_col_pos_number", "7",
|
| 192 | &prefs_common.summary_col_pos[S_COL_NUMBER], P_INT}, |
| 193 | {"summary_col_pos_to", "8",
|
| 194 | &prefs_common.summary_col_pos[S_COL_TO], P_INT}, |
| 195 | |
| 196 | {"summary_sent_col_show_mark", "TRUE",
|
| 197 | &prefs_common.summary_sent_col_visible[S_COL_MARK], P_BOOL}, |
| 198 | {"summary_sent_col_show_unread", "TRUE",
|
| 199 | &prefs_common.summary_sent_col_visible[S_COL_UNREAD], P_BOOL}, |
| 200 | {"summary_sent_col_show_mime", "TRUE",
|
| 201 | &prefs_common.summary_sent_col_visible[S_COL_MIME], P_BOOL}, |
| 202 | {"summary_sent_col_show_subject", "TRUE",
|
| 203 | &prefs_common.summary_sent_col_visible[S_COL_SUBJECT], P_BOOL}, |
| 204 | {"summary_sent_col_show_from", "FALSE",
|
| 205 | &prefs_common.summary_sent_col_visible[S_COL_FROM], P_BOOL}, |
| 206 | {"summary_sent_col_show_date", "TRUE",
|
| 207 | &prefs_common.summary_sent_col_visible[S_COL_DATE], P_BOOL}, |
| 208 | {"summary_sent_col_show_size", "TRUE",
|
| 209 | &prefs_common.summary_sent_col_visible[S_COL_SIZE], P_BOOL}, |
| 210 | {"summary_sent_col_show_number", "FALSE",
|
| 211 | &prefs_common.summary_sent_col_visible[S_COL_NUMBER], P_BOOL}, |
| 212 | {"summary_sent_col_show_to", "TRUE",
|
| 213 | &prefs_common.summary_sent_col_visible[S_COL_TO], P_BOOL}, |
| 214 | |
| 215 | {"summary_sent_col_pos_mark", "0",
|
| 216 | &prefs_common.summary_sent_col_pos[S_COL_MARK], P_INT}, |
| 217 | {"summary_sent_col_pos_unread", "1",
|
| 218 | &prefs_common.summary_sent_col_pos[S_COL_UNREAD], P_INT}, |
| 219 | {"summary_sent_col_pos_mime", "2",
|
| 220 | &prefs_common.summary_sent_col_pos[S_COL_MIME], P_INT}, |
| 221 | {"summary_sent_col_pos_subject", "3",
|
| 222 | &prefs_common.summary_sent_col_pos[S_COL_SUBJECT], P_INT}, |
| 223 | {"summary_sent_col_pos_from", "8",
|
| 224 | &prefs_common.summary_sent_col_pos[S_COL_FROM], P_INT}, |
| 225 | {"summary_sent_col_pos_date", "5",
|
| 226 | &prefs_common.summary_sent_col_pos[S_COL_DATE], P_INT}, |
| 227 | {"summary_sent_col_pos_size", "6",
|
| 228 | &prefs_common.summary_sent_col_pos[S_COL_SIZE], P_INT}, |
| 229 | {"summary_sent_col_pos_number", "7",
|
| 230 | &prefs_common.summary_sent_col_pos[S_COL_NUMBER], P_INT}, |
| 231 | {"summary_sent_col_pos_to", "4",
|
| 232 | &prefs_common.summary_sent_col_pos[S_COL_TO], P_INT}, |
| 233 | |
| 234 | {"summary_col_size_mark", "10",
|
| 235 | &prefs_common.summary_col_size[S_COL_MARK], P_INT}, |
| 236 | {"summary_col_size_unread", "13",
|
| 237 | &prefs_common.summary_col_size[S_COL_UNREAD], P_INT}, |
| 238 | {"summary_col_size_mime", "10",
|
| 239 | &prefs_common.summary_col_size[S_COL_MIME], P_INT}, |
| 240 | {"summary_col_size_subject", "200",
|
| 241 | &prefs_common.summary_col_size[S_COL_SUBJECT], P_INT}, |
| 242 | {"summary_col_size_from", "120",
|
| 243 | &prefs_common.summary_col_size[S_COL_FROM], P_INT}, |
| 244 | {"summary_col_size_date", "118",
|
| 245 | &prefs_common.summary_col_size[S_COL_DATE], P_INT}, |
| 246 | {"summary_col_size_size", "45",
|
| 247 | &prefs_common.summary_col_size[S_COL_SIZE], P_INT}, |
| 248 | {"summary_col_size_number", "40",
|
| 249 | &prefs_common.summary_col_size[S_COL_NUMBER], P_INT}, |
| 250 | {"summary_col_size_to", "120",
|
| 251 | &prefs_common.summary_col_size[S_COL_TO], P_INT}, |
| 252 | |
| 253 | /* Widget size */
|
| 254 | {"folderwin_x", "16", &prefs_common.folderwin_x, P_INT},
|
| 255 | {"folderwin_y", "16", &prefs_common.folderwin_y, P_INT},
|
| 256 | {"folderview_width", "179", &prefs_common.folderview_width, P_INT},
|
| 257 | {"folderview_height", "450", &prefs_common.folderview_height, P_INT},
|
| 258 | {"folderview_visible", "TRUE", &prefs_common.folderview_visible,
|
| 259 | P_BOOL}, |
| 260 | |
| 261 | {"folder_col_folder", "150", &prefs_common.folder_col_folder, P_INT},
|
| 262 | {"folder_col_new", "32", &prefs_common.folder_col_new, P_INT},
|
| 263 | {"folder_col_unread", "32", &prefs_common.folder_col_unread, P_INT},
|
| 264 | {"folder_col_total", "32", &prefs_common.folder_col_total, P_INT},
|
| 265 | |
| 266 | {"summaryview_width", "600", &prefs_common.summaryview_width, P_INT},
|
| 267 | {"summaryview_height", "180", &prefs_common.summaryview_height, P_INT},
|
| 268 | {"summaryview_vwidth", "300", &prefs_common.summaryview_vwidth, P_INT},
|
| 269 | {"summaryview_vheight", "600", &prefs_common.summaryview_vheight,
|
| 270 | P_INT}, |
| 271 | |
| 272 | {"main_messagewin_x", "256", &prefs_common.main_msgwin_x, P_INT},
|
| 273 | {"main_messagewin_y", "210", &prefs_common.main_msgwin_y, P_INT},
|
| 274 | {"messageview_width", "600", &prefs_common.msgview_width, P_INT},
|
| 275 | {"messageview_height", "300", &prefs_common.msgview_height, P_INT},
|
| 276 | {"messageview_vwidth", "300", &prefs_common.msgview_vwidth, P_INT},
|
| 277 | {"messageview_vheight", "600", &prefs_common.msgview_vheight, P_INT},
|
| 278 | {"messageview_visible", "TRUE", &prefs_common.msgview_visible, P_BOOL},
|
| 279 | |
| 280 | {"mainview_x", "64", &prefs_common.mainview_x, P_INT},
|
| 281 | {"mainview_y", "64", &prefs_common.mainview_y, P_INT},
|
| 282 | {"mainview_width", "600", &prefs_common.mainview_width, P_INT},
|
| 283 | {"mainview_height", "600", &prefs_common.mainview_height, P_INT},
|
| 284 | {"mainwin_x", "64", &prefs_common.mainwin_x, P_INT},
|
| 285 | {"mainwin_y", "64", &prefs_common.mainwin_y, P_INT},
|
| 286 | {"mainwin_width", "800", &prefs_common.mainwin_width, P_INT},
|
| 287 | {"mainwin_height", "600", &prefs_common.mainwin_height, P_INT},
|
| 288 | {"messagewin_width", "600", &prefs_common.msgwin_width, P_INT},
|
| 289 | {"messagewin_height", "540", &prefs_common.msgwin_height, P_INT},
|
| 290 | |
| 291 | {"mainwin_maximized", "FALSE", &prefs_common.mainwin_maximized, P_BOOL},
|
| 292 | |
| 293 | {"sourcewin_width", "600", &prefs_common.sourcewin_width, P_INT},
|
| 294 | {"sourcewin_height", "500", &prefs_common.sourcewin_height, P_INT},
|
| 295 | |
| 296 | {"compose_x", "32", &prefs_common.compose_x, P_INT},
|
| 297 | {"compose_y", "32", &prefs_common.compose_y, P_INT},
|
| 298 | {"compose_width", "600", &prefs_common.compose_width, P_INT},
|
| 299 | {"compose_height", "560", &prefs_common.compose_height, P_INT},
|
| 300 | |
| 301 | {"compose_maximized", "FALSE", &prefs_common.compose_maximized, P_BOOL},
|
| 302 | |
| 303 | {"addressbook_x", "32", &prefs_common.addressbook_x, P_INT},
|
| 304 | {"addressbook_y", "32", &prefs_common.addressbook_y, P_INT},
|
| 305 | {"addressbook_width", "620", &prefs_common.addressbook_width, P_INT},
|
| 306 | {"addressbook_height", "360", &prefs_common.addressbook_height, P_INT},
|
| 307 | |
| 308 | /* Message */
|
| 309 | {"enable_color", "TRUE", &prefs_common.enable_color, P_BOOL},
|
| 310 | |
| 311 | {"quote_level1_color", "179", &prefs_common.quote_level1_col, P_INT},
|
| 312 | {"quote_level2_color", "179", &prefs_common.quote_level2_col, P_INT},
|
| 313 | {"quote_level3_color", "179", &prefs_common.quote_level3_col, P_INT},
|
| 314 | {"uri_color", "32512", &prefs_common.uri_col, P_INT},
|
| 315 | {"signature_color", "0", &prefs_common.sig_col, P_USHORT},
|
| 316 | {"recycle_quote_colors", "FALSE", &prefs_common.recycle_quote_colors,
|
| 317 | P_BOOL}, |
| 318 | |
| 319 | {"convert_mb_alnum", "FALSE", &prefs_common.conv_mb_alnum, P_BOOL},
|
| 320 | {"display_header_pane", "TRUE", &prefs_common.display_header_pane,
|
| 321 | P_BOOL}, |
| 322 | {"display_header", "TRUE", &prefs_common.display_header, P_BOOL},
|
| 323 | {"render_html", "TRUE", &prefs_common.render_html, P_BOOL},
|
| 324 | {"html_only_as_attach", "FALSE", &prefs_common.html_only_as_attach,
|
| 325 | P_BOOL}, |
| 326 | {"line_space", "2", &prefs_common.line_space, P_INT},
|
| 327 | |
| 328 | {"textview_cursor_visible", "FALSE",
|
| 329 | &prefs_common.textview_cursor_visible, P_BOOL}, |
| 330 | |
| 331 | {"enable_smooth_scroll", "FALSE", &prefs_common.enable_smooth_scroll,
|
| 332 | P_BOOL}, |
| 333 | {"scroll_step", "1", &prefs_common.scroll_step, P_INT},
|
| 334 | {"scroll_half_page", "FALSE", &prefs_common.scroll_halfpage, P_BOOL},
|
| 335 | |
| 336 | {"resize_image", "TRUE", &prefs_common.resize_image, P_BOOL},
|
| 337 | {"inline_image", "TRUE", &prefs_common.inline_image, P_BOOL},
|
| 338 | |
| 339 | /* Encoding */
|
| 340 | {"default_encoding", NULL, &prefs_common.default_encoding, P_STRING},
|
| 341 | {"outgoing_charset", NULL, &prefs_common.outgoing_charset, P_STRING},
|
| 342 | |
| 343 | {"show_other_header", "FALSE", &prefs_common.show_other_header, P_BOOL},
|
| 344 | |
| 345 | /* MIME viewer */
|
| 346 | {"mime_image_viewer", NULL, &prefs_common.mime_image_viewer, P_STRING},
|
| 347 | {"mime_audio_player", NULL, &prefs_common.mime_audio_player, P_STRING},
|
| 348 | #ifdef G_OS_WIN32
|
| 349 | {"mime_open_command", "notepad '%s'", &prefs_common.mime_open_cmd,
|
| 350 | #else
|
| 351 | {"mime_open_command", "gedit '%s'", &prefs_common.mime_open_cmd,
|
| 352 | #endif
|
| 353 | P_STRING}, |
| 354 | {"mime_command", NULL, &prefs_common.mime_cmd, P_STRING},
|
| 355 | |
| 356 | /* Junk mail */
|
| 357 | {"enable_junk", "FALSE", &prefs_common.enable_junk, P_BOOL},
|
| 358 | #ifdef G_OS_WIN32
|
| 359 | {"junk_learn_command", "bsfilterw -C -s -u",
|
| 360 | &prefs_common.junk_learncmd, P_STRING}, |
| 361 | {"nojunk_learn_command", "bsfilterw -c -S -u",
|
| 362 | &prefs_common.nojunk_learncmd, P_STRING}, |
| 363 | {"junk_classify_command", "bsfilterw",
|
| 364 | &prefs_common.junk_classify_cmd, P_STRING}, |
| 365 | #else
|
| 366 | {"junk_learn_command", "bogofilter -N -s -I",
|
| 367 | &prefs_common.junk_learncmd, P_STRING}, |
| 368 | {"nojunk_learn_command", "bogofilter -n -S -I",
|
| 369 | &prefs_common.nojunk_learncmd, P_STRING}, |
| 370 | {"junk_classify_command", "bogofilter -I",
|
| 371 | &prefs_common.junk_classify_cmd, P_STRING}, |
| 372 | #endif
|
| 373 | {"junk_folder", NULL, &prefs_common.junk_folder, P_STRING},
|
| 374 | {"filter_junk_on_receive", "FALSE", &prefs_common.filter_junk_on_recv,
|
| 375 | P_BOOL}, |
| 376 | {"filter_junk_before", "FALSE", &prefs_common.filter_junk_before,
|
| 377 | P_BOOL}, |
| 378 | {"delete_junk_on_receive", "TRUE", &prefs_common.delete_junk_on_recv,
|
| 379 | P_BOOL}, |
| 380 | {"mark_junk_as_read", "FALSE", &prefs_common.mark_junk_as_read, P_BOOL},
|
| 381 | |
| 382 | /* Privacy */
|
| 383 | {"auto_check_signatures", "TRUE", &prefs_common.auto_check_signatures,
|
| 384 | P_BOOL}, |
| 385 | {"gpg_signature_popup", "FALSE", &prefs_common.gpg_signature_popup,
|
| 386 | P_BOOL}, |
| 387 | {"store_passphrase", "FALSE", &prefs_common.store_passphrase, P_BOOL},
|
| 388 | {"store_passphrase_timeout", "0",
|
| 389 | &prefs_common.store_passphrase_timeout, P_INT}, |
| 390 | {"passphrase_grab", "FALSE", &prefs_common.passphrase_grab, P_BOOL},
|
| 391 | #ifdef G_OS_WIN32
|
| 392 | {"show_gpg_warning", "FALSE", &prefs_common.gpg_warning, P_BOOL},
|
| 393 | #else
|
| 394 | {"show_gpg_warning", "TRUE", &prefs_common.gpg_warning, P_BOOL},
|
| 395 | #endif
|
| 396 | |
| 397 | /* Interface */
|
| 398 | {"separate_folder", "FALSE", &prefs_common.sep_folder, P_BOOL},
|
| 399 | {"separate_message", "FALSE", &prefs_common.sep_msg, P_BOOL},
|
| 400 | |
| 401 | {"always_show_message_when_selected", "TRUE",
|
| 402 | &prefs_common.always_show_msg, P_BOOL}, |
| 403 | {"open_unread_on_enter", "FALSE", &prefs_common.open_unread_on_enter,
|
| 404 | P_BOOL}, |
| 405 | {"remember_last_selected", "FALSE",
|
| 406 | &prefs_common.remember_last_selected, P_BOOL}, |
| 407 | {"mark_as_read_on_new_window", "FALSE",
|
| 408 | &prefs_common.mark_as_read_on_new_window, P_BOOL}, |
| 409 | {"open_inbox_on_inc", "FALSE", &prefs_common.open_inbox_on_inc, P_BOOL},
|
| 410 | {"open_inbox_on_startup", "FALSE", &prefs_common.open_inbox_on_startup,
|
| 411 | P_BOOL}, |
| 412 | {"change_account_on_folder_selection", "TRUE",
|
| 413 | &prefs_common.change_account_on_folder_sel, P_BOOL}, |
| 414 | {"immediate_execution", "TRUE", &prefs_common.immediate_exec, P_BOOL},
|
| 415 | |
| 416 | #ifdef G_OS_WIN32
|
| 417 | {"comply_gnome_hig", "FALSE", &prefs_common.comply_gnome_hig, P_BOOL},
|
| 418 | #else
|
| 419 | {"comply_gnome_hig", "TRUE", &prefs_common.comply_gnome_hig, P_BOOL},
|
| 420 | #endif
|
| 421 | |
| 422 | {"show_trayicon", "TRUE", &prefs_common.show_trayicon, P_BOOL},
|
| 423 | {"minimize_to_tray", "FALSE", &prefs_common.minimize_to_tray, P_BOOL},
|
| 424 | #ifdef G_OS_WIN32
|
| 425 | {"toggle_window_on_trayicon_click", "FALSE",
|
| 426 | #else
|
| 427 | {"toggle_window_on_trayicon_click", "TRUE",
|
| 428 | #endif
|
| 429 | &prefs_common.toggle_window_on_trayicon_click, P_BOOL}, |
| 430 | |
| 431 | /* Other */
|
| 432 | {"receive_dialog_mode", "1", &prefs_common.recv_dialog_mode, P_ENUM},
|
| 433 | {"no_receive_error_panel", "FALSE", &prefs_common.no_recv_err_panel,
|
| 434 | P_BOOL}, |
| 435 | {"close_receive_dialog", "TRUE", &prefs_common.close_recv_dialog,
|
| 436 | P_BOOL}, |
| 437 | |
| 438 | {"add_address_by_click", "FALSE", &prefs_common.add_address_by_click,
|
| 439 | P_BOOL}, |
| 440 | {"enable_address_completion", "TRUE",
|
| 441 | &prefs_common.enable_address_completion, P_BOOL}, |
| 442 | {"fullauto_completion_mode", "TRUE",
|
| 443 | &prefs_common.fullauto_completion_mode, P_BOOL}, |
| 444 | |
| 445 | {"confirm_on_exit", "FALSE", &prefs_common.confirm_on_exit, P_BOOL},
|
| 446 | {"clean_trash_on_exit", "FALSE", &prefs_common.clean_on_exit, P_BOOL},
|
| 447 | {"ask_on_cleaning", "TRUE", &prefs_common.ask_on_clean, P_BOOL},
|
| 448 | {"warn_queued_on_exit", "TRUE", &prefs_common.warn_queued_on_exit,
|
| 449 | P_BOOL}, |
| 450 | |
| 451 | {"logwindow_line_limit", "1000", &prefs_common.logwin_line_limit,
|
| 452 | P_INT}, |
| 453 | |
| 454 | /* External commands */
|
| 455 | #ifdef G_OS_WIN32
|
| 456 | {"uri_open_command", NULL, &prefs_common.uri_cmd,
|
| 457 | #else
|
| 458 | {"uri_open_command", DEFAULT_BROWSER_CMD, &prefs_common.uri_cmd,
|
| 459 | #endif
|
| 460 | P_STRING}, |
| 461 | #ifdef G_OS_WIN32
|
| 462 | {"ext_editor_command", "notepad '%s'", &prefs_common.ext_editor_cmd,
|
| 463 | #else
|
| 464 | {"ext_editor_command", "gedit %s", &prefs_common.ext_editor_cmd,
|
| 465 | #endif
|
| 466 | P_STRING}, |
| 467 | |
| 468 | {"use_print_command", "FALSE", &prefs_common.use_print_cmd, P_BOOL},
|
| 469 | #ifdef G_OS_WIN32
|
| 470 | {"print_command", NULL, &prefs_common.print_cmd, P_STRING},
|
| 471 | #else
|
| 472 | {"print_command", "lpr %s", &prefs_common.print_cmd, P_STRING},
|
| 473 | #endif
|
| 474 | |
| 475 | {"use_ext_inc", "FALSE", &prefs_common.use_extinc, P_BOOL},
|
| 476 | {"ext_inc_path", DEFAULT_INC_PATH, &prefs_common.extinc_cmd, P_STRING},
|
| 477 | {"use_ext_sendmail", "FALSE", &prefs_common.use_extsend, P_BOOL},
|
| 478 | {"ext_sendmail_cmd", DEFAULT_SENDMAIL_CMD, &prefs_common.extsend_cmd,
|
| 479 | P_STRING}, |
| 480 | |
| 481 | /* Update check */
|
| 482 | {"auto_update_check", "TRUE", &prefs_common.auto_update_check, P_BOOL},
|
| 483 | {"use_http_proxy", "FALSE", &prefs_common.use_http_proxy, P_BOOL},
|
| 484 | {"http_proxy_host", NULL, &prefs_common.http_proxy_host, P_STRING},
|
| 485 | |
| 486 | /* Advanced */
|
| 487 | {"strict_cache_check", "FALSE", &prefs_common.strict_cache_check,
|
| 488 | P_BOOL}, |
| 489 | {"io_timeout_secs", "60", &prefs_common.io_timeout_secs, P_INT},
|
| 490 | |
| 491 | {NULL, NULL, NULL, P_OTHER}
|
| 492 | }; |
| 493 | |
| 494 | |
| 495 | PrefsCommon *prefs_common_get(void)
|
| 496 | {
|
| 497 | return &prefs_common;
|
| 498 | } |
| 499 | |
| 500 | PrefParam *prefs_common_get_params(void)
|
| 501 | {
|
| 502 | return param;
|
| 503 | } |
| 504 | |
| 505 | void prefs_common_read_config(void) |
| 506 | {
|
| 507 | FILE *fp; |
| 508 | gchar *path; |
| 509 | gchar buf[PREFSBUFSIZE]; |
| 510 | |
| 511 | path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, COMMON_RC, NULL);
|
| 512 | |
| 513 | prefs_read_config(param, "Common", path, NULL); |
| 514 | |
| 515 | g_free(path); |
| 516 | |
| 517 | prefs_common.online_mode = TRUE; |
| 518 | |
| 519 | path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, COMMAND_HISTORY, |
| 520 | NULL);
|
| 521 | if ((fp = g_fopen(path, "rb")) == NULL) { |
| 522 | if (ENOENT != errno) FILE_OP_ERROR(path, "fopen"); |
| 523 | g_free(path); |
| 524 | return;
|
| 525 | } |
| 526 | g_free(path); |
| 527 | while (fgets(buf, sizeof(buf), fp) != NULL) { |
| 528 | g_strstrip(buf); |
| 529 | if (buf[0] == '\0') continue; |
| 530 | prefs_common.mime_open_cmd_history = |
| 531 | add_history(prefs_common.mime_open_cmd_history, buf); |
| 532 | } |
| 533 | fclose(fp); |
| 534 | |
| 535 | prefs_common.mime_open_cmd_history = |
| 536 | g_list_reverse(prefs_common.mime_open_cmd_history); |
| 537 | } |
| 538 | |
| 539 | void prefs_common_write_config(void) |
| 540 | {
|
| 541 | GList *cur; |
| 542 | FILE *fp; |
| 543 | gchar *path; |
| 544 | |
| 545 | prefs_write_config(param, "Common", COMMON_RC);
|
| 546 | |
| 547 | path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, COMMAND_HISTORY, |
| 548 | NULL);
|
| 549 | if ((fp = g_fopen(path, "wb")) == NULL) { |
| 550 | FILE_OP_ERROR(path, "fopen");
|
| 551 | g_free(path); |
| 552 | return;
|
| 553 | } |
| 554 | |
| 555 | for (cur = prefs_common.mime_open_cmd_history;
|
| 556 | cur != NULL; cur = cur->next) {
|
| 557 | fputs((gchar *)cur->data, fp); |
| 558 | fputc('\n', fp);
|
| 559 | } |
| 560 | |
| 561 | fclose(fp); |
| 562 | g_free(path); |
| 563 | } |
| 564 | |
| 565 | static FilterRule *prefs_common_junk_filter_rule_create(gboolean is_manual)
|
| 566 | {
|
| 567 | FilterRule *rule; |
| 568 | FilterCond *cond; |
| 569 | FilterAction *action; |
| 570 | GSList *cond_list = NULL, *action_list = NULL; |
| 571 | gchar *junk_id; |
| 572 | |
| 573 | if (prefs_common.junk_folder)
|
| 574 | junk_id = g_strdup(prefs_common.junk_folder); |
| 575 | else {
|
| 576 | FolderItem *item; |
| 577 | item = folder_get_default_junk(); |
| 578 | if (!item)
|
| 579 | return NULL; |
| 580 | junk_id = folder_item_get_identifier(item); |
| 581 | if (!junk_id)
|
| 582 | return NULL; |
| 583 | } |
| 584 | |
| 585 | debug_print("prefs_common_junk_filter_rule_create: junk folder: %s\n",
|
| 586 | junk_id); |
| 587 | |
| 588 | cond = filter_cond_new(FLT_COND_CMD_TEST, 0, 0, NULL, |
| 589 | prefs_common.junk_classify_cmd); |
| 590 | cond_list = g_slist_append(NULL, cond);
|
| 591 | if (prefs_common.delete_junk_on_recv && !is_manual) {
|
| 592 | action = filter_action_new(FLT_ACTION_COPY, junk_id); |
| 593 | action_list = g_slist_append(NULL, action);
|
| 594 | action = filter_action_new(FLT_ACTION_DELETE, NULL);
|
| 595 | action_list = g_slist_append(action_list, action); |
| 596 | } else {
|
| 597 | action = filter_action_new(FLT_ACTION_MOVE, junk_id); |
| 598 | action_list = g_slist_append(NULL, action);
|
| 599 | } |
| 600 | |
| 601 | if (prefs_common.mark_junk_as_read) {
|
| 602 | action = filter_action_new(FLT_ACTION_MARK_READ, NULL);
|
| 603 | action_list = g_slist_append(action_list, action); |
| 604 | } |
| 605 | |
| 606 | if (is_manual)
|
| 607 | rule = filter_rule_new(_("Junk mail filter (manual)"), FLT_OR,
|
| 608 | cond_list, action_list); |
| 609 | else
|
| 610 | rule = filter_rule_new(_("Junk mail filter"), FLT_OR,
|
| 611 | cond_list, action_list); |
| 612 | |
| 613 | g_free(junk_id); |
| 614 | |
| 615 | return rule;
|
| 616 | } |
| 617 | |
| 618 | void prefs_common_junk_filter_list_set(void) |
| 619 | {
|
| 620 | FilterRule *rule; |
| 621 | |
| 622 | debug_print("prefs_common_junk_filter_list_set\n");
|
| 623 | |
| 624 | if (prefs_common.junk_fltlist) {
|
| 625 | filter_rule_list_free(prefs_common.junk_fltlist); |
| 626 | prefs_common.junk_fltlist = NULL;
|
| 627 | } |
| 628 | if (prefs_common.manual_junk_fltlist) {
|
| 629 | filter_rule_list_free(prefs_common.manual_junk_fltlist); |
| 630 | prefs_common.manual_junk_fltlist = NULL;
|
| 631 | } |
| 632 | |
| 633 | if (!prefs_common.junk_classify_cmd)
|
| 634 | return;
|
| 635 | |
| 636 | rule = prefs_common_junk_filter_rule_create(FALSE); |
| 637 | if (!rule)
|
| 638 | return;
|
| 639 | prefs_common.junk_fltlist = g_slist_append(NULL, rule);
|
| 640 | |
| 641 | rule = prefs_common_junk_filter_rule_create(TRUE); |
| 642 | if (!rule)
|
| 643 | return;
|
| 644 | prefs_common.manual_junk_fltlist = g_slist_append(NULL, rule);
|
| 645 | } |
| 646 | |
| 647 | void prefs_common_junk_folder_rename_path(const gchar *old_path, |
| 648 | const gchar *new_path)
|
| 649 | {
|
| 650 | gint len; |
| 651 | gchar *base; |
| 652 | gchar *dest_path; |
| 653 | |
| 654 | g_return_if_fail(old_path != NULL);
|
| 655 | g_return_if_fail(new_path != NULL);
|
| 656 | |
| 657 | if (!prefs_common.junk_folder)
|
| 658 | return;
|
| 659 | |
| 660 | len = strlen(old_path); |
| 661 | |
| 662 | if (!strncmp(old_path, prefs_common.junk_folder, len)) {
|
| 663 | base = prefs_common.junk_folder + len; |
| 664 | if (*base != '/' && *base != '\0') |
| 665 | return;
|
| 666 | while (*base == '/') base++; |
| 667 | if (*base == '\0') |
| 668 | dest_path = g_strdup(new_path); |
| 669 | else
|
| 670 | dest_path = g_strconcat(new_path, "/", base, NULL); |
| 671 | debug_print("prefs_common_junk_folder_rename_path(): "
|
| 672 | "renaming %s -> %s\n", prefs_common.junk_folder,
|
| 673 | dest_path); |
| 674 | g_free(prefs_common.junk_folder); |
| 675 | prefs_common.junk_folder = dest_path; |
| 676 | prefs_common_junk_filter_list_set(); |
| 677 | } |
| 678 | } |