2 * Copyright (c) 2010, 2011 Marco Peereboom <marco@peereboom.us>
3 * Copyright (c) 2011 Stevan Andjelkovic <stevan@student.chalmers.se>
4 * Copyright (c) 2010, 2011 Edd Barrett <vext01@gmail.com>
5 * Copyright (c) 2011 Todd T. Fries <todd@fries.net>
6 * Copyright (c) 2011 Raphael Graf <r@undefined.ch>
7 * Copyright (c) 2011 Michal Mazurek <akfaew@jasminek.net>
8 * Copyright (c) 2012 Josh Rickmar <jrick@devio.us>
10 * Permission to use, copy, modify, and distribute this software for any
11 * purpose with or without fee is hereby granted, provided that the above
12 * copyright notice and this permission notice appear in all copies.
14 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
15 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
17 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
27 SoupURI
*proxy_uri
= NULL
;
28 PangoFontDescription
*cmd_font
;
29 PangoFontDescription
*oops_font
;
30 PangoFontDescription
*statusbar_font
;
31 PangoFontDescription
*tabbar_font
;
34 char search_file
[PATH_MAX
];
35 char command_file
[PATH_MAX
];
36 char runtime_settings
[PATH_MAX
]; /* override of settings */
38 /* settings that require restart */
39 int enable_socket
= 0;
40 int single_instance
= 0; /* only allow one xombrero to run */
41 int fancy_bar
= 1; /* fancy toolbar */
42 int browser_mode
= XT_BM_NORMAL
;
43 int gui_mode
= XT_GM_CLASSIC
;
44 char *statusbar_elems
= NULL
;
45 int window_height
= 768;
46 int window_width
= 1024;
47 int window_maximize
= 0;
48 int icon_size
= 2; /* 1 = smallest, 2+ = bigger */
49 char *resource_dir
= NULL
;
50 char download_dir
[PATH_MAX
];
51 int allow_volatile_cookies
= 0;
52 int save_global_history
= 0; /* save global history to disk */
53 int save_rejected_cookies
= 0;
54 gint max_connections
= 25;
55 gint max_host_connections
= 5;
56 int history_autosave
= 0;
57 int edit_mode
= XT_EM_HYBRID
;
58 char *include_config
= NULL
;
59 int anonymize_headers
= 0;
60 int tabless
= 0; /* allow only 1 tab */
62 /* runtime settings */
63 int show_tabs
= XT_DS_SHOW_TABS
; /* show tabs on notebook */
64 int tab_style
= XT_DS_TAB_STYLE
; /* tab bar style */
65 int statusbar_style
= XT_DS_STATUSBAR_STYLE
; /* status bar style */
66 int show_url
= XT_DS_SHOW_URL
; /* show url toolbar on notebook */
67 int show_scrollbars
= XT_DS_SHOW_SCROLLBARS
;
68 int show_statusbar
= XT_DS_SHOW_STATUSBAR
; /* vimperator style status bar */
69 int ctrl_click_focus
= XT_DS_CTRL_CLICK_FOCUS
; /* ctrl click gets focus */
70 int cookies_enabled
= XT_DS_COOKIES_ENABLED
; /* enable cookies */
71 int read_only_cookies
= XT_DS_READ_ONLY_COOKIES
; /* enable to not write cookies */
72 int enable_scripts
= XT_DS_ENABLE_SCRIPTS
;
73 int enable_plugins
= XT_DS_ENABLE_PLUGINS
;
74 gfloat default_zoom_level
= XT_DS_DEFAULT_ZOOM_LEVEL
;
75 char default_script
[PATH_MAX
]; /* special setting - is never g_free'd */
76 int refresh_interval
= XT_DS_REFRESH_INTERVAL
; /* download refresh interval */
77 int enable_plugin_whitelist
= XT_DS_ENABLE_PLUGIN_WHITELIST
;
78 int enable_cookie_whitelist
= XT_DS_ENABLE_COOKIE_WHITELIST
;
79 int enable_js_whitelist
= XT_DS_ENABLE_JS_WHITELIST
;
80 int enable_localstorage
= XT_DS_ENABLE_LOCALSTORAGE
;
81 int session_timeout
= XT_DS_SESSION_TIMEOUT
; /* cookie session timeout */
82 int cookie_policy
= XT_DS_COOKIE_POLICY
;
83 char ssl_ca_file
[PATH_MAX
]; /* special setting - is never g_free'd */
84 gboolean ssl_strict_certs
= XT_DS_SSL_STRICT_CERTS
;
85 gboolean enable_strict_transport
= XT_DS_ENABLE_STRICT_TRANSPORT
;
86 int append_next
= XT_DS_APPEND_NEXT
; /* append tab after current tab */
87 char *home
= NULL
; /* allocated/set at startup */
88 char *search_string
= NULL
; /* allocated/set at startup */
89 char *http_proxy
= NULL
;
90 int http_proxy_starts_enabled
= 1;
91 int download_mode
= XT_DM_START
;
92 int color_visited_uris
= XT_DS_COLOR_VISITED_URIS
;
93 int session_autosave
= XT_DS_SESSION_AUTOSAVE
;
94 int guess_search
= XT_DS_GUESS_SEARCH
;
95 gint enable_spell_checking
= XT_DS_ENABLE_SPELL_CHECKING
;
96 char *spell_check_languages
= NULL
; /* allocated/set at startup */
97 char *url_regex
= NULL
; /* allocated/set at startup */
98 char *encoding
= NULL
; /* allocated/set at startup */
99 int autofocus_onload
= XT_DS_AUTOFOCUS_ONLOAD
;
100 int enable_js_autorun
= XT_DS_ENABLE_JS_AUTORUN
;
101 char *userstyle
= NULL
; /* allocated/set at startup */
102 int userstyle_global
= XT_DS_USERSTYLE_GLOBAL
;
103 int auto_load_images
= XT_DS_AUTO_LOAD_IMAGES
;
104 int enable_autoscroll
= XT_DS_ENABLE_AUTOSCROLL
;
105 int enable_favicon_entry
= XT_DS_ENABLE_FAVICON_ENTRY
;
106 int enable_favicon_tabs
= XT_DS_ENABLE_FAVICON_TABS
;
107 char *external_editor
= NULL
;
108 int referer_mode
= XT_DS_REFERER_MODE
;
109 char *referer_custom
= NULL
;
110 int download_notifications
= XT_DS_DOWNLOAD_NOTIFICATIONS
;
111 int warn_cert_changes
= 0;
112 int allow_insecure_content
= XT_DS_ALLOW_INSECURE_CONTENT
;
113 int allow_insecure_scripts
= XT_DS_ALLOW_INSECURE_SCRIPTS
;
114 int do_not_track
= XT_DS_DO_NOT_TRACK
;
115 int preload_strict_transport
= XT_DS_PRELOAD_STRICT_TRANSPORT
;
116 char *gnutls_priority_string
= XT_DS_GNUTLS_PRIORITY_STRING
;
118 char *cmd_font_name
= NULL
; /* these are all set at startup */
119 char *oops_font_name
= NULL
;
120 char *statusbar_font_name
= NULL
;
121 char *tabbar_font_name
= NULL
;
123 char *get_download_dir(struct settings
*);
124 char *get_default_script(struct settings
*);
125 char *get_runtime_dir(struct settings
*);
126 char *get_tab_style(struct settings
*);
127 char *get_statusbar_style(struct settings
*);
128 char *get_edit_mode(struct settings
*);
129 char *get_download_mode(struct settings
*);
130 char *get_work_dir(struct settings
*);
131 char *get_referer(struct settings
*);
132 char *get_ssl_ca_file(struct settings
*);
133 char *get_userstyle(struct settings
*);
134 char *get_gnutls_priority_string(struct settings
*);
136 int add_cookie_wl(struct settings
*, char *);
137 int add_js_wl(struct settings
*, char *);
138 int add_pl_wl(struct settings
*, char *);
139 int add_mime_type(struct settings
*, char *);
140 int add_alias(struct settings
*, char *);
141 int add_kb(struct settings
*, char *);
142 int add_ua(struct settings
*, char *);
143 int add_http_accept(struct settings
*, char *);
144 int add_cmd_alias(struct settings
*, char *);
145 int add_custom_uri(struct settings
*, char *);
146 int add_force_https(struct settings
*, char *);
148 int set_append_next(char *);
149 int set_autofocus_onload(char *);
150 int set_cmd_font(char *);
151 int set_color_visited_uris(char *);
152 int set_cookie_policy_rt(char *);
153 int set_cookies_enabled(char *);
154 int set_ctrl_click_focus(char *);
155 int set_fancy_bar(char *);
156 int set_home(char *);
157 int set_download_dir(struct settings
*, char *);
158 int set_download_notifications(char *);
159 int set_default_script(struct settings
*, char *);
160 int set_default_script_rt(char *);
161 int set_default_zoom_level(char *);
162 int set_enable_cookie_whitelist(char *);
163 int set_enable_js_autorun(char *);
164 int set_enable_js_whitelist(char *);
165 int set_enable_localstorage(char *);
166 int set_enable_plugins(char *);
167 int set_enable_plugin_whitelist(char *);
168 int set_enable_scripts(char *);
169 int set_enable_spell_checking(char *);
170 int set_enable_strict_transport(char *);
171 int set_encoding_rt(char *);
172 int set_runtime_dir(struct settings
*, char *);
173 int set_tabbar_font(char *value
);
174 int set_tab_style(struct settings
*, char *);
175 int set_tab_style_rt(char *);
176 int set_statusbar_style(struct settings
*, char *);
177 int set_statusbar_style_rt(char *);
178 int set_edit_mode(struct settings
*, char *);
179 int set_work_dir(struct settings
*, char *);
180 int set_auto_load_images(char *);
181 int set_enable_autoscroll(char *);
182 int set_enable_favicon_entry(char *);
183 int set_enable_favicon_tabs(char *);
184 int set_guess_search(char *);
185 int set_download_mode(struct settings
*, char *);
186 int set_download_mode_rt(char *);
187 int set_oops_font(char *);
188 int set_read_only_cookies(char *);
189 int set_referer(struct settings
*, char *);
190 int set_referer_rt(char *);
191 int set_refresh_interval(char *);
192 int set_search_string(char *s
);
193 int set_session_autosave(char *);
194 int set_session_timeout(char *);
195 int set_show_scrollbars(char *);
196 int set_show_statusbar(char *);
197 int set_show_tabs(char *);
198 int set_show_url(char *);
199 int set_spell_check_languages(char *);
200 int set_ssl_ca_file_rt(char *);
201 int set_ssl_strict_certs(char *);
202 int set_statusbar_font(char *);
203 int set_url_regex(char *);
204 int set_userstyle(struct settings
*, char *);
205 int set_userstyle_rt(char *);
206 int set_userstyle_global(char *);
207 int set_external_editor(char *);
208 int set_warn_cert_changes(char *);
209 int set_allow_insecure_content(char *);
210 int set_allow_insecure_scripts(char *);
211 int set_http_proxy(char *);
212 int set_do_not_track(char *);
213 int set_gnutls_priority_string(struct settings
*, char *);
215 int check_allow_insecure_content(char **);
216 int check_allow_insecure_scripts(char **);
217 int check_allow_volatile_cookies(char **);
218 int check_anonymize_headers(char **);
219 int check_append_next(char **);
220 int check_auto_load_images(char **);
221 int check_autofocus_onload(char **);
222 int check_browser_mode(char **);
223 int check_cmd_font(char **);
224 int check_color_visited_uris(char **);
225 int check_cookie_policy(char **);
226 int check_cookies_enabled(char **);
227 int check_ctrl_click_focus(char **);
228 int check_default_script(char **);
229 int check_default_zoom_level(char **);
230 int check_download_dir(char **);
231 int check_download_mode(char **);
232 int check_download_notifications(char **);
233 int check_edit_mode(char **);
234 int check_enable_autoscroll(char **);
235 int check_enable_cookie_whitelist(char **);
236 int check_enable_favicon_entry(char **);
237 int check_enable_favicon_tabs(char **);
238 int check_enable_js_autorun(char **);
239 int check_enable_js_whitelist(char **);
240 int check_enable_localstorage(char **);
241 int check_enable_plugin_whitelist(char **);
242 int check_enable_plugins(char **);
243 int check_enable_scripts(char **);
244 int check_enable_socket(char **);
245 int check_enable_spell_checking(char **);
246 int check_enable_strict_transport(char **);
247 int check_encoding(char **);
248 int check_external_editor(char **);
249 int check_fancy_bar(char **);
250 int check_gnutls_search_string(char **);
251 int check_guess_search(char **);
252 int check_gui_mode(char **);
253 int check_history_autosave(char **);
254 int check_home(char **);
255 int check_http_proxy(char **);
256 int check_http_proxy_starts_enabled(char **);
257 int check_icon_size(char **);
258 int check_max_connections(char **);
259 int check_max_host_connections(char **);
260 int check_oops_font(char **);
261 int check_read_only_cookies(char **);
262 int check_referer(char **);
263 int check_refresh_interval(char **);
264 int check_resource_dir(char **);
265 int check_save_global_history(char **);
266 int check_save_rejected_cookies(char **);
267 int check_search_string(char **);
268 int check_session_autosave(char **);
269 int check_session_timeout(char **);
270 int check_show_scrollbars(char **);
271 int check_show_statusbar(char **);
272 int check_show_tabs(char **);
273 int check_show_url(char **);
274 int check_single_instance(char **);
275 int check_spell_check_languages(char **);
276 int check_ssl_ca_file(char **);
277 int check_ssl_strict_certs(char **);
278 int check_statusbar_elems(char **);
279 int check_statusbar_font(char **);
280 int check_statusbar_style(char **);
281 int check_tab_style(char **);
282 int check_tabless(char **);
283 int check_tabbar_font(char **);
284 int check_url_regex(char **);
285 int check_userstyle(char **);
286 int check_userstyle_global(char **);
287 int check_warn_cert_changes(char **);
288 int check_window_height(char **);
289 int check_window_maximize(char **);
290 int check_window_width(char **);
291 int check_work_dir(char **);
292 int check_do_not_track(char **);
294 void walk_mime_type(struct settings
*, void (*)(struct settings
*,
295 char *, void *), void *);
296 void walk_alias(struct settings
*, void (*)(struct settings
*,
297 char *, void *), void *);
298 void walk_cookie_wl(struct settings
*, void (*)(struct settings
*,
299 char *, void *), void *);
300 void walk_js_wl(struct settings
*, void (*)(struct settings
*,
301 char *, void *), void *);
302 void walk_pl_wl(struct settings
*, void (*)(struct settings
*,
303 char *, void *), void *);
304 void walk_kb(struct settings
*, void (*)(struct settings
*, char *,
306 void walk_ua(struct settings
*, void (*)(struct settings
*, char *,
308 void walk_http_accept(struct settings
*, void (*)(struct settings
*,
309 char *, void *), void *);
310 void walk_cmd_alias(struct settings
*, void (*)(struct settings
*,
311 char *, void *), void *);
312 void walk_custom_uri(struct settings
*, void (*)(struct settings
*,
313 char *, void *), void *);
314 void walk_force_https(struct settings
*, void (*)(struct settings
*,
315 char *, void *), void *);
317 struct special s_browser_mode
= {
321 { "kiosk", "normal", "whitelist", NULL
}
324 struct special s_gui_mode
= {
328 { "classic", "minimal", NULL
}
331 struct special s_cookie
= {
335 { "accept", "no3rdparty", "reject", NULL
}
338 struct special s_alias
= {
345 struct special s_cmd_alias
= {
352 struct special s_mime
= {
359 struct special s_js
= {
366 struct special s_pl
= {
373 struct special s_kb
= {
380 struct special s_cookie_wl
= {
387 struct special s_uri
= {
394 struct special s_default_script
= {
401 struct special s_ssl_ca_file
= {
408 struct special s_download_dir
= {
415 struct special s_work_dir
= {
422 struct special s_tab_style
= {
426 { "compact", "normal", NULL
}
429 struct special s_statusbar_style
= {
433 { "title", "url", NULL
}
436 struct special s_edit_mode
= {
440 { "hybrid", "vi", NULL
}
443 struct special s_download_mode
= {
447 { "add", "ask", "start", NULL
}
450 struct special s_ua
= {
457 struct special s_http_accept
= {
464 struct special s_referer
= {
468 { "always", "never", "same-domain", "same-fqdn", NULL
}
471 struct special s_userstyle
= {
478 struct special s_force_https
= {
485 struct special s_gnutls_priority_string
= {
486 set_gnutls_priority_string
,
487 get_gnutls_priority_string
,
492 struct settings rs
[] = {
493 { "allow_insecure_content", XT_S_BOOL
, 0, &allow_insecure_content
, NULL
, NULL
, NULL
, set_allow_insecure_content
, check_allow_insecure_content
, TT_ALLOW_INSECURE_CONTENT
},
494 { "allow_insecure_scripts", XT_S_BOOL
, 0, &allow_insecure_scripts
, NULL
, NULL
, NULL
, set_allow_insecure_scripts
, check_allow_insecure_scripts
, TT_ALLOW_INSECURE_SCRIPTS
},
495 { "allow_volatile_cookies", XT_S_BOOL
, 0, &allow_volatile_cookies
, NULL
, NULL
, NULL
, NULL
, check_allow_volatile_cookies
, TT_ALLOW_VOLATILE_COOKIES
},
496 { "anonymize_headers", XT_S_BOOL
, 0, &anonymize_headers
, NULL
, NULL
, NULL
, NULL
, check_anonymize_headers
, TT_ANONYMIZE_HEADERS
},
497 { "append_next", XT_S_BOOL
, 0, &append_next
, NULL
, NULL
, NULL
, set_append_next
, check_append_next
, TT_APPEND_NEXT
},
498 { "auto_load_images", XT_S_BOOL
, 0, &auto_load_images
, NULL
, NULL
, NULL
, set_auto_load_images
, check_auto_load_images
, TT_AUTO_LOAD_IMAGES
},
499 { "autofocus_onload", XT_S_BOOL
, 0, &autofocus_onload
, NULL
, NULL
, NULL
, set_autofocus_onload
, check_autofocus_onload
, TT_AUTOFOCUS_ONLOAD
},
500 { "browser_mode", XT_S_STR
, 0, NULL
, NULL
,&s_browser_mode
, NULL
, NULL
, check_browser_mode
, TT_BROWSER_MODE
},
501 { "cmd_font", XT_S_STR
, 0, NULL
, &cmd_font_name
, NULL
, NULL
, set_cmd_font
, check_cmd_font
, TT_CMD_FONT
},
502 { "color_visited_uris", XT_S_BOOL
, 0, &color_visited_uris
, NULL
, NULL
, NULL
, set_color_visited_uris
, check_color_visited_uris
, TT_COLOR_VISITED_URIS
},
503 { "cookie_policy", XT_S_STR
, 0, NULL
, NULL
,&s_cookie
, NULL
, set_cookie_policy_rt
, check_cookie_policy
, TT_COOKIE_POLICY
},
504 { "cookies_enabled", XT_S_BOOL
, 0, &cookies_enabled
, NULL
, NULL
, NULL
, set_cookies_enabled
, check_cookies_enabled
, TT_COOKIES_ENABLED
},
505 { "ctrl_click_focus", XT_S_BOOL
, 0, &ctrl_click_focus
, NULL
, NULL
, NULL
, set_ctrl_click_focus
, check_ctrl_click_focus
, TT_CTRL_CLICK_FOCUS
},
506 { "default_script", XT_S_STR
, 1, NULL
, NULL
,&s_default_script
, NULL
, set_default_script_rt
, check_default_script
, TT_DEFAULT_SCRIPT
},
507 { "default_zoom_level", XT_S_FLOAT
, 0, NULL
, NULL
, NULL
, &default_zoom_level
, set_default_zoom_level
, check_default_zoom_level
, TT_DEFAULT_ZOOM_LEVEL
},
508 { "do_not_track", XT_S_BOOL
, 0, &do_not_track
, NULL
, NULL
, NULL
, set_do_not_track
, check_do_not_track
, TT_DO_NOT_TRACK
},
509 { "download_dir", XT_S_STR
, 0, NULL
, NULL
,&s_download_dir
, NULL
, NULL
, check_download_dir
, TT_DOWNLOAD_DIR
},
510 { "download_mode", XT_S_STR
, 0, NULL
, NULL
,&s_download_mode
, NULL
, set_download_mode_rt
, check_download_mode
, TT_DOWNLOAD_MODE
},
511 { "download_notifications", XT_S_BOOL
, 0, &download_notifications
, NULL
, NULL
, NULL
, set_download_notifications
, check_download_notifications
, TT_DOWNLOAD_NOTIFICATIONS
},
512 { "edit_mode", XT_S_STR
, 0, NULL
, NULL
,&s_edit_mode
, NULL
, NULL
, check_edit_mode
, NULL
},
513 { "enable_autoscroll", XT_S_BOOL
, 0, &enable_autoscroll
, NULL
, NULL
, NULL
, set_enable_autoscroll
, check_enable_autoscroll
, TT_ENABLE_AUTOSCROLL
},
514 { "enable_cookie_whitelist", XT_S_BOOL
, 0, &enable_cookie_whitelist
, NULL
, NULL
, NULL
, set_enable_cookie_whitelist
, check_enable_cookie_whitelist
, TT_ENABLE_COOKIE_WHITELIST
},
515 { "enable_favicon_entry", XT_S_BOOL
, 0, &enable_favicon_entry
, NULL
, NULL
, NULL
, set_enable_favicon_entry
, check_enable_favicon_entry
, TT_ENABLE_FAVICON_ENTRY
},
516 { "enable_favicon_tabs", XT_S_BOOL
, 0, &enable_favicon_tabs
, NULL
, NULL
, NULL
, set_enable_favicon_tabs
, check_enable_favicon_tabs
, TT_ENABLE_FAVICON_TABS
},
517 { "enable_js_autorun", XT_S_BOOL
, 0, &enable_js_autorun
, NULL
, NULL
, NULL
, set_enable_js_autorun
, check_enable_js_autorun
, TT_ENABLE_JS_AUTORUN
},
518 { "enable_js_whitelist", XT_S_BOOL
, 0, &enable_js_whitelist
, NULL
, NULL
, NULL
, set_enable_js_whitelist
, check_enable_js_whitelist
, TT_ENABLE_JS_WHITELIST
},
519 { "enable_localstorage", XT_S_BOOL
, 0, &enable_localstorage
, NULL
, NULL
, NULL
, set_enable_localstorage
, check_enable_localstorage
, TT_ENABLE_LOCALSTORAGE
},
520 { "enable_plugin_whitelist", XT_S_BOOL
, 0, &enable_plugin_whitelist
, NULL
, NULL
, NULL
, set_enable_plugin_whitelist
, check_enable_plugin_whitelist
, TT_ENABLE_PLUGIN_WHITELIST
},
521 { "enable_plugins", XT_S_BOOL
, 0, &enable_plugins
, NULL
, NULL
, NULL
, set_enable_plugins
, check_enable_plugins
, TT_ENABLE_PLUGINS
},
522 { "enable_scripts", XT_S_BOOL
, 0, &enable_scripts
, NULL
, NULL
, NULL
, set_enable_scripts
, check_enable_scripts
, TT_ENABLE_SCRIPTS
},
523 { "enable_socket", XT_S_BOOL
,XT_SF_RESTART
,&enable_socket
, NULL
, NULL
, NULL
, NULL
, check_enable_socket
, TT_ENABLE_SOCKET
},
524 { "enable_spell_checking", XT_S_BOOL
, 0, &enable_spell_checking
, NULL
, NULL
, NULL
, set_enable_spell_checking
, check_enable_spell_checking
, TT_ENABLE_SPELL_CHECKING
},
525 { "enable_strict_transport", XT_S_BOOL
, 0, &enable_strict_transport
, NULL
, NULL
, NULL
, set_enable_strict_transport
, check_enable_strict_transport
, TT_ENABLE_STRICT_TRANSPORT
},
526 { "encoding", XT_S_STR
, 0, NULL
, &encoding
, NULL
, NULL
, NULL
, check_encoding
, TT_ENCODING
},
527 { "external_editor", XT_S_STR
,0, NULL
, &external_editor
, NULL
, NULL
, set_external_editor
, check_external_editor
, TT_EXTERNAL_EDITOR
},
528 { "fancy_bar", XT_S_BOOL
,XT_SF_RESTART
,&fancy_bar
, NULL
, NULL
, NULL
, set_fancy_bar
, check_fancy_bar
, TT_FANCY_BAR
},
529 { "gnutls_priority_string", XT_S_STR
, 0, NULL
, NULL
,&s_gnutls_priority_string
, NULL
, NULL
, check_gnutls_search_string
, TT_GNUTLS_PRIORITY_STRING
},
530 { "guess_search", XT_S_BOOL
, 0, &guess_search
, NULL
, NULL
, NULL
, set_guess_search
, check_guess_search
, TT_GUESS_SEARCH
},
531 { "gui_mode", XT_S_STR
, 0, NULL
, NULL
,&s_gui_mode
, NULL
, NULL
, check_gui_mode
, TT_GUI_MODE
},
532 { "history_autosave", XT_S_BOOL
, 0, &history_autosave
, NULL
, NULL
, NULL
, NULL
, check_history_autosave
, TT_HISTORY_AUTOSAVE
},
533 { "home", XT_S_STR
, 0, NULL
, &home
, NULL
, NULL
, set_home
, check_home
, TT_HOME
},
534 { "http_proxy", XT_S_STR
, 0, NULL
, &http_proxy
, NULL
, NULL
, set_http_proxy
, check_http_proxy
, TT_HTTP_PROXY
},
535 { "http_proxy_starts_enabled", XT_S_BOOL
, 0, &http_proxy_starts_enabled
, NULL
, NULL
, NULL
, NULL
, check_http_proxy_starts_enabled
, TT_HTTP_PROXY_STARTS_ENABLED
},
536 { "icon_size", XT_S_INT
, 0, &icon_size
, NULL
, NULL
, NULL
, NULL
, check_icon_size
, TT_ICON_SIZE
},
537 { "include_config", XT_S_STR
, XT_SF_INVISIBLE
, NULL
, &include_config
, NULL
, NULL
, NULL
, NULL
},
538 { "max_connections", XT_S_INT
, XT_SF_RESTART
,&max_connections
, NULL
, NULL
, NULL
, NULL
, check_max_connections
, TT_MAX_CONNECTIONS
},
539 { "max_host_connections", XT_S_INT
, XT_SF_RESTART
,&max_host_connections
, NULL
, NULL
, NULL
, NULL
, check_max_host_connections
, TT_MAX_HOST_CONNECTIONS
},
540 { "oops_font", XT_S_STR
, 0, NULL
, &oops_font_name
, NULL
, NULL
, set_oops_font
, check_oops_font
, TT_OOPS_FONT
},
541 { "preload_strict_transport", XT_S_BOOL
, 0, &preload_strict_transport
, NULL
, NULL
, NULL
, NULL
, NULL
, TT_PRELOAD_STRICT_TRANSPORT
},
542 { "read_only_cookies", XT_S_BOOL
, 0, &read_only_cookies
, NULL
, NULL
, NULL
, NULL
, check_read_only_cookies
, TT_READ_ONLY_COOKIES
},
543 { "referer", XT_S_STR
, 0, NULL
, NULL
,&s_referer
, NULL
, set_referer_rt
, check_referer
, TT_REFERER
},
544 { "refresh_interval", XT_S_INT
, 0, &refresh_interval
, NULL
, NULL
, NULL
, set_refresh_interval
, check_refresh_interval
, TT_REFRESH_INTERVAL
},
545 { "resource_dir", XT_S_STR
, 0, NULL
, &resource_dir
, NULL
, NULL
, NULL
, check_resource_dir
, TT_RESOURCE_DIR
},
546 { "save_global_history", XT_S_BOOL
,XT_SF_RESTART
,&save_global_history
, NULL
, NULL
, NULL
, NULL
, check_save_global_history
, TT_SAVE_GLOBAL_HISTORY
},
547 { "save_rejected_cookies", XT_S_BOOL
,XT_SF_RESTART
,&save_rejected_cookies
, NULL
, NULL
, NULL
, NULL
, check_save_rejected_cookies
, TT_SAVE_REJECTED_COOKIES
},
548 { "search_string", XT_S_STR
, 0, NULL
, &search_string
, NULL
, NULL
, set_search_string
, check_search_string
, TT_SEARCH_STRING
},
549 { "session_autosave", XT_S_BOOL
, 0, &session_autosave
, NULL
, NULL
, NULL
, set_session_autosave
, check_session_autosave
, TT_SESSION_AUTOSAVE
},
550 { "session_timeout", XT_S_INT
, 0, &session_timeout
, NULL
, NULL
, NULL
, set_session_timeout
, check_session_timeout
, TT_SESSION_TIMEOUT
},
551 { "show_scrollbars", XT_S_BOOL
, 0, &show_scrollbars
, NULL
, NULL
, NULL
, set_show_scrollbars
, check_show_scrollbars
, TT_SHOW_SCROLLBARS
},
552 { "show_statusbar", XT_S_BOOL
, 0, &show_statusbar
, NULL
, NULL
, NULL
, set_show_statusbar
, check_show_statusbar
, TT_SHOW_STATUSBAR
},
553 { "show_tabs", XT_S_BOOL
, 0, &show_tabs
, NULL
, NULL
, NULL
, set_show_tabs
, check_show_tabs
, TT_SHOW_TABS
},
554 { "show_url", XT_S_BOOL
, 0, &show_url
, NULL
, NULL
, NULL
, set_show_url
, check_show_url
, TT_SHOW_URL
},
555 { "single_instance", XT_S_BOOL
,XT_SF_RESTART
,&single_instance
, NULL
, NULL
, NULL
, NULL
, check_single_instance
, TT_SINGLE_INSTANCE
},
556 { "spell_check_languages", XT_S_STR
, 0, NULL
, &spell_check_languages
, NULL
, NULL
, set_spell_check_languages
, check_spell_check_languages
, TT_SPELL_CHECK_LANGUAGES
},
557 { "ssl_ca_file", XT_S_STR
, 0, NULL
, NULL
,&s_ssl_ca_file
, NULL
, set_ssl_ca_file_rt
, check_ssl_ca_file
, TT_SSL_CA_FILE
},
558 { "ssl_strict_certs", XT_S_BOOL
, 0, &ssl_strict_certs
, NULL
, NULL
, NULL
, set_ssl_strict_certs
, check_ssl_strict_certs
, TT_SSL_STRICT_CERTS
},
559 { "statusbar_elems", XT_S_STR
, 0, NULL
, &statusbar_elems
, NULL
, NULL
, NULL
, check_statusbar_elems
, TT_STATUSBAR_ELEMS
},
560 { "statusbar_font", XT_S_STR
, 0, NULL
, &statusbar_font_name
, NULL
, NULL
, set_statusbar_font
, check_statusbar_font
, TT_STATUSBAR_FONT
},
561 { "statusbar_style", XT_S_STR
, 0, NULL
, NULL
,&s_statusbar_style
, NULL
, set_statusbar_style_rt
, check_statusbar_style
, TT_STATUSBAR_STYLE
},
562 { "tab_style", XT_S_STR
, 0, NULL
, NULL
,&s_tab_style
, NULL
, set_tab_style_rt
, check_tab_style
, TT_TAB_STYLE
},
563 { "tabbar_font", XT_S_STR
, 0, NULL
, &tabbar_font_name
, NULL
, NULL
, set_tabbar_font
, check_tabbar_font
, TT_TABBAR_FONT
},
564 { "tabless", XT_S_BOOL
, 0, &tabless
, NULL
, NULL
, NULL
, NULL
, check_tabless
, TT_TABLESS
},
565 { "url_regex", XT_S_STR
, 0, NULL
, &url_regex
, NULL
, NULL
, set_url_regex
, check_url_regex
, TT_URL_REGEX
},
566 { "userstyle", XT_S_STR
, 0, NULL
, NULL
,&s_userstyle
, NULL
, set_userstyle_rt
, check_userstyle
, TT_USERSTYLE
},
567 { "userstyle_global", XT_S_BOOL
, 0, &userstyle_global
, NULL
, NULL
, NULL
, set_userstyle_global
, check_userstyle_global
, TT_USERSTYLE_GLOBAL
},
568 { "warn_cert_changes", XT_S_BOOL
, 0, &warn_cert_changes
, NULL
, NULL
, NULL
, set_warn_cert_changes
, check_warn_cert_changes
, TT_WARN_CERT_CHANGES
},
569 { "window_height", XT_S_INT
, 0, &window_height
, NULL
, NULL
, NULL
, NULL
, check_window_height
, TT_WINDOW_HEIGHT
},
570 { "window_maximize", XT_S_BOOL
, 0, &window_maximize
, NULL
, NULL
, NULL
, NULL
, check_window_maximize
, TT_WINDOW_MAXIMIZE
},
571 { "window_width", XT_S_INT
, 0, &window_width
, NULL
, NULL
, NULL
, NULL
, check_window_width
, TT_WINDOW_WIDTH
},
572 { "work_dir", XT_S_STR
, 0, NULL
, NULL
,&s_work_dir
, NULL
, NULL
, check_work_dir
, TT_WORK_DIR
},
574 /* special settings */
575 { "alias", XT_S_STR
, XT_SF_RUNTIME
, NULL
, NULL
, &s_alias
, NULL
, NULL
},
576 { "cmd_alias", XT_S_STR
, XT_SF_RUNTIME
, NULL
, NULL
, &s_cmd_alias
, NULL
, NULL
},
577 { "cookie_wl", XT_S_STR
, XT_SF_RUNTIME
, NULL
, NULL
, &s_cookie_wl
, NULL
, NULL
},
578 { "custom_uri", XT_S_STR
, XT_SF_RUNTIME
, NULL
, NULL
, &s_uri
, NULL
, NULL
},
579 { "force_https", XT_S_STR
, XT_SF_RUNTIME
, NULL
, NULL
, &s_force_https
, NULL
, NULL
},
580 { "http_accept", XT_S_STR
, XT_SF_RUNTIME
, NULL
, NULL
, &s_http_accept
, NULL
, NULL
},
581 { "js_wl", XT_S_STR
, XT_SF_RUNTIME
, NULL
, NULL
, &s_js
, NULL
, NULL
},
582 { "keybinding", XT_S_STR
, XT_SF_RUNTIME
, NULL
, NULL
, &s_kb
, NULL
, NULL
},
583 { "mime_type", XT_S_STR
, XT_SF_RUNTIME
, NULL
, NULL
, &s_mime
, NULL
, NULL
},
584 { "pl_wl", XT_S_STR
, XT_SF_RUNTIME
, NULL
, NULL
, &s_pl
, NULL
, NULL
},
585 { "user_agent", XT_S_STR
, XT_SF_RUNTIME
, NULL
, NULL
, &s_ua
, NULL
, NULL
},
589 set_http_proxy(char *proxy
)
593 /* see if we need to clear it */
594 if (proxy
== NULL
|| strlen(proxy
) == 0) {
599 uri
= soup_uri_new(proxy
);
602 if (!SOUP_URI_VALID_FOR_HTTP(uri
)) {
615 check_http_proxy(char **tt
)
617 *tt
= g_strdup("Default: (empty)");
618 return (g_strcmp0(http_proxy
, NULL
));
622 check_http_proxy_starts_enabled(char **tt
)
624 *tt
= g_strdup("Default: Enabled");
625 return (http_proxy_starts_enabled
!= 1);
629 check_icon_size(char **tt
)
631 *tt
= g_strdup_printf("Default: %d", 2);
632 return (icon_size
!= 2);
636 check_max_connections(char **tt
)
638 *tt
= g_strdup_printf("Default: %d", 25);
639 return (max_connections
!= 25);
643 check_max_host_connections(char **tt
)
645 *tt
= g_strdup_printf("Default: %d", 5);
646 return (max_host_connections
!= 5);
650 set_default_zoom_level(char *value
)
652 struct karg args
= {0};
655 if (value
== NULL
|| strlen(value
) == 0)
656 default_zoom_level
= XT_DS_DEFAULT_ZOOM_LEVEL
;
658 default_zoom_level
= g_strtod(value
, NULL
);
659 args
.i
= 100; /* adjust = 100 percent for no additional adjustment */
660 TAILQ_FOREACH(t
, &tabs
, entry
)
666 check_default_zoom_level(char **tt
)
668 *tt
= g_strdup_printf("Default: %f", XT_DS_DEFAULT_ZOOM_LEVEL
);
669 return (default_zoom_level
!= XT_DS_DEFAULT_ZOOM_LEVEL
);
673 set_cookies_enabled(char *value
)
678 if (value
== NULL
|| strlen(value
) == 0)
679 cookies_enabled
= XT_DS_COOKIES_ENABLED
;
681 tmp
= strtonum(value
, 0, 1, &errstr
);
684 cookies_enabled
= tmp
;
690 check_cookies_enabled(char **tt
)
692 *tt
= g_strdup_printf("Default: %s",
693 XT_DS_COOKIES_ENABLED
? "Enabled" : "Disabled");
694 return (cookies_enabled
!= XT_DS_COOKIES_ENABLED
);
698 set_append_next(char *value
)
703 if (value
== NULL
|| strlen(value
) == 0)
704 append_next
= XT_DS_APPEND_NEXT
;
706 tmp
= strtonum(value
, 0, 1, &errstr
);
715 check_append_next(char **tt
)
717 *tt
= g_strdup_printf("Default: %s",
718 XT_DS_APPEND_NEXT
? "Enabled" : "Disabled");
719 return (append_next
!= XT_DS_APPEND_NEXT
);
723 set_cmd_font(char *value
)
728 g_free(cmd_font_name
);
730 pango_font_description_free(cmd_font
);
731 if (value
== NULL
|| strlen(value
) == 0)
732 cmd_font_name
= g_strdup(XT_DS_CMD_FONT_NAME
);
734 cmd_font_name
= g_strdup(value
);
735 cmd_font
= pango_font_description_from_string(cmd_font_name
);
736 TAILQ_FOREACH(t
, &tabs
, entry
)
737 gtk_widget_modify_font(GTK_WIDGET(t
->cmd
), cmd_font
);
742 check_cmd_font(char **tt
)
744 *tt
= g_strdup_printf("Default: %s", XT_DS_CMD_FONT_NAME
);
745 return (g_strcmp0(cmd_font_name
, XT_DS_CMD_FONT_NAME
));
749 set_oops_font(char *value
)
754 g_free(oops_font_name
);
756 pango_font_description_free(oops_font
);
757 if (value
== NULL
|| strlen(value
) == 0)
758 cmd_font_name
= g_strdup(XT_DS_OOPS_FONT_NAME
);
760 oops_font_name
= g_strdup(value
);
761 oops_font
= pango_font_description_from_string(oops_font_name
);
762 TAILQ_FOREACH(t
, &tabs
, entry
)
763 gtk_widget_modify_font(GTK_WIDGET(t
->oops
), oops_font
);
768 check_oops_font(char **tt
)
770 *tt
= g_strdup_printf("Default: %s", XT_DS_OOPS_FONT_NAME
);
771 return (g_strcmp0(oops_font_name
, XT_DS_OOPS_FONT_NAME
));
775 check_read_only_cookies(char **tt
)
777 *tt
= g_strdup_printf("Default: %s",
778 XT_DS_READ_ONLY_COOKIES
? "Enabled" : "Disabled");
779 return (read_only_cookies
!= XT_DS_READ_ONLY_COOKIES
);
783 set_statusbar_font(char *value
)
787 if (statusbar_font_name
)
788 g_free(statusbar_font_name
);
790 pango_font_description_free(statusbar_font
);
791 if (value
== NULL
|| strlen(value
) == 0)
792 statusbar_font_name
= g_strdup(XT_DS_STATUSBAR_FONT_NAME
);
794 statusbar_font_name
= g_strdup(value
);
795 statusbar_font
= pango_font_description_from_string(
796 statusbar_font_name
);
797 TAILQ_FOREACH(t
, &tabs
, entry
) {
798 gtk_widget_modify_font(GTK_WIDGET(t
->sbe
.uri
),
800 gtk_widget_modify_font(GTK_WIDGET(t
->sbe
.buffercmd
),
802 gtk_widget_modify_font(GTK_WIDGET(t
->sbe
.zoom
),
804 gtk_widget_modify_font(GTK_WIDGET(t
->sbe
.position
),
806 gtk_widget_modify_font(GTK_WIDGET(t
->sbe
.proxy
),
813 check_statusbar_font(char **tt
)
815 *tt
= g_strdup_printf("Default: %s", XT_DS_STATUSBAR_FONT_NAME
);
816 return (g_strcmp0(statusbar_font_name
, XT_DS_STATUSBAR_FONT_NAME
));
820 set_tabbar_font(char *value
)
824 if (tabbar_font_name
)
825 g_free(tabbar_font_name
);
827 pango_font_description_free(tabbar_font
);
828 if (value
== NULL
|| strlen(value
) == 0)
829 tabbar_font_name
= g_strdup(XT_DS_TABBAR_FONT_NAME
);
831 tabbar_font_name
= g_strdup(value
);
832 tabbar_font
= pango_font_description_from_string(tabbar_font_name
);
833 TAILQ_FOREACH(t
, &tabs
, entry
)
834 gtk_widget_modify_font(GTK_WIDGET(t
->tab_elems
.label
),
840 check_tabbar_font(char **tt
)
842 *tt
= g_strdup_printf("Default: %s", XT_DS_TABBAR_FONT_NAME
);
843 return (g_strcmp0(tabbar_font_name
, XT_DS_TABBAR_FONT_NAME
));
847 check_tabless(char **tt
)
849 *tt
= g_strdup_printf("Default: Disabled\n");
850 return (tabless
!= 0);
854 set_color_visited_uris(char *value
)
859 if (value
== NULL
|| strlen(value
) == 0)
860 color_visited_uris
= XT_DS_COLOR_VISITED_URIS
;
862 tmp
= strtonum(value
, 0, 1, &errstr
);
865 color_visited_uris
= tmp
;
871 check_color_visited_uris(char **tt
)
873 *tt
= g_strdup_printf("Default: %s",
874 XT_DS_COLOR_VISITED_URIS
? "Enabled" : "Disabled");
875 return (color_visited_uris
!= XT_DS_COLOR_VISITED_URIS
);
879 set_home(char *value
)
883 if (value
== NULL
|| strlen(value
) == 0)
884 home
= g_strdup(XT_DS_HOME
);
886 home
= g_strdup(value
);
891 check_home(char **tt
)
893 *tt
= g_strdup_printf("Default: %s", XT_DS_HOME
);
894 return (g_strcmp0(home
, XT_DS_HOME
));
898 set_search_string(char *value
)
903 g_free(search_string
);
904 if (value
== NULL
|| strlen(value
) == 0) {
905 search_string
= NULL
;
906 TAILQ_FOREACH(t
, &tabs
, entry
)
907 gtk_widget_hide(t
->search_entry
);
909 search_string
= g_strdup(value
);
910 TAILQ_FOREACH(t
, &tabs
, entry
)
911 gtk_widget_show(t
->search_entry
);
917 check_search_string(char **tt
)
919 *tt
= g_strdup_printf("Default: %s", XT_DS_SEARCH_STRING
);
920 return (g_strcmp0(search_string
, XT_DS_SEARCH_STRING
));
924 get_settings_size(void)
930 get_setting_name(int i
)
938 get_as_string(struct settings
*s
)
945 if (s
->s
&& s
->s
->get
)
947 else if (s
->type
== XT_S_INT
)
948 r
= g_strdup_printf("%d", *s
->ival
);
949 else if (s
->type
== XT_S_STR
)
950 r
= g_strdup(*s
->sval
);
951 else if (s
->type
== XT_S_FLOAT
)
952 r
= g_strdup_printf("%f", *s
->fval
);
953 else if (s
->type
== XT_S_BOOL
)
954 r
= g_strdup_printf("%d", *s
->ival
);
956 r
= g_strdup_printf("INVALID TYPE");
962 settings_walk(void (*cb
)(struct settings
*, char *, void *), void *cb_args
)
967 for (i
= 0; i
< LENGTH(rs
); i
++) {
968 if (rs
[i
].s
&& rs
[i
].s
->walk
)
969 rs
[i
].s
->walk(&rs
[i
], cb
, cb_args
);
971 s
= get_as_string(&rs
[i
]);
972 cb(&rs
[i
], s
, cb_args
);
979 check_allow_volatile_cookies(char **tt
)
981 *tt
= g_strdup("Default: Disabled");
982 return (allow_volatile_cookies
!= 0);
986 check_anonymize_headers(char **tt
)
988 *tt
= g_strdup("Default: Disabled");
989 return (anonymize_headers
!= 0);
993 set_browser_mode(struct settings
*s
, char *val
)
995 if (!strcmp(val
, "whitelist")) {
996 browser_mode
= XT_BM_WHITELIST
;
997 allow_volatile_cookies
= 0;
998 cookie_policy
= SOUP_COOKIE_JAR_ACCEPT_NO_THIRD_PARTY
;
1000 enable_cookie_whitelist
= 1;
1001 enable_plugin_whitelist
= 1;
1003 read_only_cookies
= 0;
1004 save_rejected_cookies
= 0;
1005 session_timeout
= 3600;
1007 enable_js_whitelist
= 1;
1008 enable_localstorage
= 0;
1009 referer_mode
= XT_REFERER_SAME_DOMAIN
;
1010 allow_insecure_content
= 0;
1011 allow_insecure_scripts
= 0;
1013 } else if (!strcmp(val
, "normal")) {
1014 browser_mode
= XT_BM_NORMAL
;
1015 allow_volatile_cookies
= 0;
1016 cookie_policy
= SOUP_COOKIE_JAR_ACCEPT_ALWAYS
;
1017 cookies_enabled
= 1;
1018 enable_cookie_whitelist
= 0;
1019 enable_plugin_whitelist
= 0;
1021 read_only_cookies
= 0;
1022 save_rejected_cookies
= 0;
1023 session_timeout
= 3600;
1025 enable_js_whitelist
= 0;
1026 enable_localstorage
= 1;
1027 referer_mode
= XT_REFERER_ALWAYS
;
1028 allow_insecure_content
= 1;
1029 allow_insecure_scripts
= 1;
1031 } else if (!strcmp(val
, "kiosk")) {
1032 browser_mode
= XT_BM_KIOSK
;
1033 allow_volatile_cookies
= 0;
1034 cookie_policy
= SOUP_COOKIE_JAR_ACCEPT_ALWAYS
;
1035 cookies_enabled
= 1;
1036 enable_cookie_whitelist
= 0;
1037 enable_plugin_whitelist
= 0;
1039 read_only_cookies
= 0;
1040 save_rejected_cookies
= 0;
1041 session_timeout
= 3600;
1043 enable_js_whitelist
= 0;
1044 enable_localstorage
= 1;
1045 referer_mode
= XT_REFERER_ALWAYS
;
1046 allow_insecure_content
= 1;
1047 allow_insecure_scripts
= 1;
1058 get_browser_mode(struct settings
*s
)
1062 if (browser_mode
== XT_BM_WHITELIST
)
1063 r
= g_strdup("whitelist");
1064 else if (browser_mode
== XT_BM_NORMAL
)
1065 r
= g_strdup("normal");
1066 else if (browser_mode
== XT_BM_KIOSK
)
1067 r
= g_strdup("kiosk");
1075 check_browser_mode(char **tt
)
1077 *tt
= g_strdup("Default: normal");
1078 return (browser_mode
!= XT_BM_NORMAL
);
1082 set_gui_mode(struct settings
*s
, char *val
)
1084 if (!strcmp(val
, "classic")) {
1087 tab_style
= XT_TABS_NORMAL
;
1090 show_scrollbars
= 1;
1091 } else if (!strcmp(val
, "minimal")) {
1094 tab_style
= XT_TABS_COMPACT
;
1097 show_scrollbars
= 0;
1105 get_gui_mode(struct settings
*s
)
1109 if (gui_mode
== XT_GM_CLASSIC
)
1110 r
= g_strdup("classic");
1111 else if (browser_mode
== XT_GM_MINIMAL
)
1112 r
= g_strdup("minimal");
1120 check_gui_mode(char **tt
)
1122 *tt
= g_strdup("Default: classic");
1123 return (gui_mode
!= XT_GM_CLASSIC
);
1127 check_history_autosave(char **tt
)
1129 *tt
= g_strdup("Default: Disabled");
1130 return (history_autosave
!= 0);
1134 set_cookie_policy(struct settings
*s
, char *val
)
1136 if (!strcmp(val
, "no3rdparty"))
1137 cookie_policy
= SOUP_COOKIE_JAR_ACCEPT_NO_THIRD_PARTY
;
1138 else if (!strcmp(val
, "accept"))
1139 cookie_policy
= SOUP_COOKIE_JAR_ACCEPT_ALWAYS
;
1140 else if (!strcmp(val
, "reject"))
1141 cookie_policy
= SOUP_COOKIE_JAR_ACCEPT_NEVER
;
1149 set_cookie_policy_rt(char *value
)
1151 if (value
== NULL
|| strlen(value
) == 0)
1152 cookie_policy
= XT_DS_COOKIE_POLICY
;
1153 else if (set_cookie_policy(NULL
, value
))
1155 g_object_set(G_OBJECT(s_cookiejar
), SOUP_COOKIE_JAR_ACCEPT_POLICY
,
1156 cookie_policy
, (void *)NULL
);
1161 check_cookie_policy(char **tt
)
1163 *tt
= g_strdup("Default (depends on browser_mode):\n"
1164 "\tnormal:\talways\n"
1165 "\twhitelist:\tno3rdparty\n"
1166 "\tkiosk:\talways");
1167 if (browser_mode
== XT_BM_WHITELIST
&&
1168 cookie_policy
!= SOUP_COOKIE_JAR_ACCEPT_NO_THIRD_PARTY
)
1170 if (browser_mode
== XT_BM_NORMAL
&&
1171 cookie_policy
!= SOUP_COOKIE_JAR_ACCEPT_ALWAYS
)
1173 if (browser_mode
== XT_BM_KIOSK
&&
1174 cookie_policy
!= SOUP_COOKIE_JAR_ACCEPT_ALWAYS
)
1180 get_cookie_policy(struct settings
*s
)
1184 if (cookie_policy
== SOUP_COOKIE_JAR_ACCEPT_NO_THIRD_PARTY
)
1185 r
= g_strdup("no3rdparty");
1186 else if (cookie_policy
== SOUP_COOKIE_JAR_ACCEPT_ALWAYS
)
1187 r
= g_strdup("accept");
1188 else if (cookie_policy
== SOUP_COOKIE_JAR_ACCEPT_NEVER
)
1189 r
= g_strdup("reject");
1197 get_default_script(struct settings
*s
)
1199 if (default_script
[0] == '\0')
1201 return (g_strdup(default_script
));
1205 set_default_script(struct settings
*s
, char *val
)
1207 expand_tilde(default_script
, sizeof default_script
, val
);
1212 check_default_script(char **tt
)
1214 *tt
= g_strdup("Default: (empty)");
1215 return (g_strcmp0(default_script
, XT_DS_DEFAULT_SCRIPT
));
1219 set_default_script_rt(char *value
)
1221 if (value
== NULL
|| strlen(value
) == 0)
1222 return set_default_script(NULL
, "");
1223 return (set_default_script(NULL
, value
));
1227 set_do_not_track(char *value
)
1232 if (value
== NULL
|| strlen(value
) == 0)
1233 do_not_track
= XT_DS_DO_NOT_TRACK
;
1235 tmp
= strtonum(value
, 0, 1, &errstr
);
1244 check_do_not_track(char **tt
)
1246 *tt
= g_strdup("Default (depends on browser_mode):\n"
1247 "\tnormal:\tDisabled\n"
1248 "\twhitelist:\tEnabled\n"
1249 "\tkiosk:\tDisabled");
1250 if (browser_mode
== XT_BM_WHITELIST
&& do_not_track
!= 1)
1252 if (browser_mode
== XT_BM_NORMAL
&& do_not_track
!= 0)
1254 if (browser_mode
== XT_BM_KIOSK
&& do_not_track
!= 0)
1260 get_download_dir(struct settings
*s
)
1262 if (download_dir
[0] == '\0')
1264 return (g_strdup(download_dir
));
1268 set_download_dir(struct settings
*s
, char *val
)
1270 expand_tilde(download_dir
, sizeof download_dir
, val
);
1275 check_download_dir(char **tt
)
1278 char buf
[PATH_MAX
] = {0};
1280 /* XXX this might need some additonal magic on windows */
1281 if ((pwd
= getpwuid(getuid())) == NULL
)
1283 snprintf(buf
, sizeof buf
, "%s" PS
"downloads", pwd
->pw_dir
);
1284 *tt
= g_strdup_printf("Default: %s", buf
);
1285 return (g_strcmp0(download_dir
, buf
));
1289 add_alias(struct settings
*s
, char *line
)
1292 struct alias
*a
= NULL
;
1294 if (s
== NULL
|| line
== NULL
) {
1295 show_oops(NULL
, "add_alias invalid parameters");
1300 a
= g_malloc(sizeof(*a
));
1302 if ((alias
= strsep(&l
, " \t,")) == NULL
|| l
== NULL
) {
1303 show_oops(NULL
, "add_alias: incomplete alias definition");
1307 /* Remove additional leading whitespace */
1308 l
+= (long)strspn(l
, " \t");
1310 if (strlen(alias
) == 0 || strlen(l
) == 0) {
1311 show_oops(NULL
, "add_alias: invalid alias definition");
1315 a
->a_name
= g_strdup(alias
);
1316 a
->a_uri
= g_strdup(l
);
1318 DNPRINTF(XT_D_CONFIG
, "add_alias: %s for %s\n", a
->a_name
, a
->a_uri
);
1320 TAILQ_INSERT_TAIL(&aliases
, a
, entry
);
1330 walk_alias(struct settings
*s
,
1331 void (*cb
)(struct settings
*, char *, void *), void *cb_args
)
1336 if (s
== NULL
|| cb
== NULL
) {
1337 show_oops(NULL
, "walk_alias invalid parameters");
1341 TAILQ_FOREACH(a
, &aliases
, entry
) {
1342 str
= g_strdup_printf("%s --> %s", a
->a_name
, a
->a_uri
);
1343 cb(s
, str
, cb_args
);
1349 add_mime_type(struct settings
*s
, char *line
)
1353 struct mime_type
*m
= NULL
;
1354 int downloadfirst
= 0;
1356 /* XXX this could be smarter */
1358 if (line
== NULL
|| strlen(line
) == 0) {
1359 show_oops(NULL
, "add_mime_type invalid parameters");
1368 m
= g_malloc(sizeof(*m
));
1370 if ((mime_type
= strsep(&l
, " \t,")) == NULL
|| l
== NULL
) {
1371 show_oops(NULL
, "add_mime_type: invalid mime_type");
1374 if (mime_type
[strlen(mime_type
) - 1] == '*') {
1375 mime_type
[strlen(mime_type
) - 1] = '\0';
1380 if (strlen(mime_type
) == 0 || strlen(l
) == 0) {
1381 show_oops(NULL
, "add_mime_type: invalid mime_type");
1385 m
->mt_type
= g_strdup(mime_type
);
1386 m
->mt_action
= g_strdup(l
);
1387 m
->mt_download
= downloadfirst
;
1389 DNPRINTF(XT_D_CONFIG
, "add_mime_type: type %s action %s default %d\n",
1390 m
->mt_type
, m
->mt_action
, m
->mt_default
);
1392 TAILQ_INSERT_TAIL(&mtl
, m
, entry
);
1402 walk_mime_type(struct settings
*s
,
1403 void (*cb
)(struct settings
*, char *, void *), void *cb_args
)
1405 struct mime_type
*m
;
1408 if (s
== NULL
|| cb
== NULL
) {
1409 show_oops(NULL
, "walk_mime_type invalid parameters");
1413 TAILQ_FOREACH(m
, &mtl
, entry
) {
1414 str
= g_strdup_printf("%s%s --> %s",
1416 m
->mt_default
? "*" : "",
1418 cb(s
, str
, cb_args
);
1423 /* inherent to GTK not all keys will be caught at all times */
1424 /* XXX sort key bindings */
1425 struct key_binding keys
[] = {
1426 { "command_mode", 0, 1, GDK_Escape
},
1427 { "insert_mode", 0, 0, GDK_i
},
1428 { "cookiejar", MOD1
, 1, GDK_j
},
1429 { "downloadmgr", MOD1
, 1, GDK_d
},
1430 { "history", MOD1
, 1, GDK_h
},
1431 { "print", CTRL
, 1, GDK_p
},
1432 { "search", 0, 0, GDK_slash
},
1433 { "searchb", 0, 0, GDK_question
},
1434 { "statustoggle", CTRL
, 1, GDK_n
},
1435 { "command", 0, 0, GDK_colon
},
1436 { "qa", CTRL
, 1, GDK_q
},
1437 { "restart", MOD1
, 1, GDK_q
},
1438 { "js toggle", CTRL
, 1, GDK_j
},
1439 { "plugin toggle", MOD1
, 1, GDK_p
},
1440 { "cookie toggle", MOD1
, 1, GDK_c
},
1441 { "togglesrc", CTRL
, 1, GDK_s
},
1442 { "yankuri", 0, 0, GDK_y
},
1443 { "pasteuricur", 0, 0, GDK_p
},
1444 { "pasteurinew", 0, 0, GDK_P
},
1445 { "toplevel toggle", 0, 1, GDK_F4
},
1446 { "help", 0, 1, GDK_F1
},
1447 { "run_script", MOD1
, 1, GDK_r
},
1448 { "proxy toggle", 0, 1, GDK_F2
},
1449 { "editelement", CTRL
, 1, GDK_i
},
1450 { "passthrough", CTRL
, 1, GDK_z
},
1451 { "modurl", CTRL
, 1, GDK_Return
},
1452 { "urlmod plus", MOD1
, 1, GDK_a
},
1453 { "urlmod min", MOD1
, 1, GDK_A
},
1456 { "searchnext", 0, 0, GDK_n
},
1457 { "searchprevious", 0, 0, GDK_N
},
1460 { "focusaddress", 0, 1, GDK_F6
},
1461 { "focussearch", 0, 1, GDK_F7
},
1464 { "hinting", 0, 0, GDK_f
},
1465 { "hinting", 0, 0, GDK_period
},
1466 { "hinting_newtab", SHFT
, 0, GDK_F
},
1467 { "hinting_newtab", 0, 0, GDK_comma
},
1469 /* custom stylesheet */
1470 { "userstyle", 0, 0, GDK_s
},
1471 { "userstyle_global", SHFT
, 0, GDK_S
},
1474 { "goback", 0, 0, GDK_BackSpace
},
1475 { "goback", MOD1
, 1, GDK_Left
},
1476 { "goforward", SHFT
, 1, GDK_BackSpace
},
1477 { "goforward", MOD1
, 1, GDK_Right
},
1478 { "reload", 0, 1, GDK_F5
},
1479 { "reload", CTRL
, 1, GDK_r
},
1480 { "reload", CTRL
, 1, GDK_l
},
1481 { "favorites", MOD1
, 1, GDK_f
},
1483 /* vertical movement */
1484 { "scrolldown", 0, 0, GDK_j
},
1485 { "scrolldown", 0, 0, GDK_Down
},
1486 { "scrollup", 0, 0, GDK_Up
},
1487 { "scrollup", 0, 0, GDK_k
},
1488 { "scrollbottom", 0, 0, GDK_G
},
1489 { "scrollbottom", 0, 0, GDK_End
},
1490 { "scrolltop", 0, 0, GDK_Home
},
1491 { "scrollpagedown", 0, 0, GDK_space
},
1492 { "scrollpagedown", CTRL
, 1, GDK_f
},
1493 { "scrollhalfdown", CTRL
, 1, GDK_d
},
1494 { "scrollpagedown", 0, 0, GDK_Page_Down
},
1495 { "scrollpageup", 0, 0, GDK_Page_Up
},
1496 { "scrollpageup", CTRL
, 1, GDK_b
},
1497 { "scrollhalfup", CTRL
, 1, GDK_u
},
1498 /* horizontal movement */
1499 { "scrollright", 0, 0, GDK_l
},
1500 { "scrollright", 0, 0, GDK_Right
},
1501 { "scrollleft", 0, 0, GDK_Left
},
1502 { "scrollleft", 0, 0, GDK_h
},
1503 { "scrollfarright", 0, 0, GDK_dollar
},
1504 { "scrollfarleft", 0, 0, GDK_0
},
1507 { "tabnew", CTRL
, 1, GDK_t
},
1508 { "999tabnew", CTRL
, 1, GDK_T
},
1509 { "tabclose", CTRL
, 1, GDK_w
},
1510 { "tabundoclose", 0, 0, GDK_U
},
1511 { "tabnext 1", CTRL
, 1, GDK_1
},
1512 { "tabnext 2", CTRL
, 1, GDK_2
},
1513 { "tabnext 3", CTRL
, 1, GDK_3
},
1514 { "tabnext 4", CTRL
, 1, GDK_4
},
1515 { "tabnext 5", CTRL
, 1, GDK_5
},
1516 { "tabnext 6", CTRL
, 1, GDK_6
},
1517 { "tabnext 7", CTRL
, 1, GDK_7
},
1518 { "tabnext 8", CTRL
, 1, GDK_8
},
1519 { "tabnext 9", CTRL
, 1, GDK_9
},
1520 { "tabfirst", CTRL
, 1, GDK_less
},
1521 { "tablast", CTRL
, 1, GDK_greater
},
1522 { "tabprevious", CTRL
, 1, GDK_Left
},
1523 { "tabnext", CTRL
, 1, GDK_Right
},
1524 { "focusout", CTRL
, 1, GDK_minus
},
1525 { "focusin", CTRL
, 1, GDK_plus
},
1526 { "focusin", CTRL
, 1, GDK_equal
},
1527 { "focusreset", CTRL
, 1, GDK_0
},
1529 /* command aliases (handy when -S flag is used) */
1530 { ":open ", 0, 1, GDK_F9
},
1531 { ":open <uri>", 0, 1, GDK_F10
},
1532 { ":tabnew ", 0, 1, GDK_F11
},
1533 { ":tabnew <uri>", 0, 1, GDK_F12
},
1537 walk_kb(struct settings
*s
,
1538 void (*cb
)(struct settings
*, char *, void *), void *cb_args
)
1540 struct key_binding
*k
;
1543 if (s
== NULL
|| cb
== NULL
) {
1544 show_oops(NULL
, "walk_kb invalid parameters");
1548 TAILQ_FOREACH(k
, &kbl
, entry
) {
1554 if (gdk_keyval_name(k
->key
) == NULL
)
1557 strlcat(str
, k
->cmd
, sizeof str
);
1558 strlcat(str
, ",", sizeof str
);
1560 if (k
->mask
& GDK_SHIFT_MASK
)
1561 strlcat(str
, "S-", sizeof str
);
1562 if (k
->mask
& GDK_CONTROL_MASK
)
1563 strlcat(str
, "C-", sizeof str
);
1564 if (k
->mask
& GDK_MOD1_MASK
)
1565 strlcat(str
, "M1-", sizeof str
);
1566 if (k
->mask
& GDK_MOD2_MASK
)
1567 strlcat(str
, "M2-", sizeof str
);
1568 if (k
->mask
& GDK_MOD3_MASK
)
1569 strlcat(str
, "M3-", sizeof str
);
1570 if (k
->mask
& GDK_MOD4_MASK
)
1571 strlcat(str
, "M4-", sizeof str
);
1572 if (k
->mask
& GDK_MOD5_MASK
)
1573 strlcat(str
, "M5-", sizeof str
);
1575 strlcat(str
, gdk_keyval_name(k
->key
), sizeof str
);
1576 cb(s
, str
, cb_args
);
1581 init_keybindings(void)
1584 struct key_binding
*k
;
1586 for (i
= 0; i
< LENGTH(keys
); i
++) {
1587 k
= g_malloc0(sizeof *k
);
1588 k
->cmd
= keys
[i
].cmd
;
1589 k
->mask
= keys
[i
].mask
;
1590 k
->use_in_entry
= keys
[i
].use_in_entry
;
1591 k
->key
= keys
[i
].key
;
1592 TAILQ_INSERT_HEAD(&kbl
, k
, entry
);
1594 DNPRINTF(XT_D_KEYBINDING
, "init_keybindings: added: %s\n",
1595 k
->cmd
? k
->cmd
: "unnamed key");
1600 keybinding_clearall(void)
1602 struct key_binding
*k
, *next
;
1604 for (k
= TAILQ_FIRST(&kbl
); k
; k
= next
) {
1605 next
= TAILQ_NEXT(k
, entry
);
1609 DNPRINTF(XT_D_KEYBINDING
, "keybinding_clearall: %s\n",
1610 k
->cmd
? k
->cmd
: "unnamed key");
1611 TAILQ_REMOVE(&kbl
, k
, entry
);
1617 keybinding_set(char *cmd
, char *key
, int use_in_entry
)
1619 struct key_binding
*k
;
1620 guint keyval
, mask
= 0;
1623 DNPRINTF(XT_D_KEYBINDING
, "keybinding_set: %s %s\n", cmd
, key
);
1625 /* Keys which are to be used in entry have been prefixed with an
1626 * exclamation mark. */
1630 /* find modifier keys */
1631 if (strstr(key
, "S-"))
1632 mask
|= GDK_SHIFT_MASK
;
1633 if (strstr(key
, "C-"))
1634 mask
|= GDK_CONTROL_MASK
;
1635 if (strstr(key
, "M1-"))
1636 mask
|= GDK_MOD1_MASK
;
1637 if (strstr(key
, "M2-"))
1638 mask
|= GDK_MOD2_MASK
;
1639 if (strstr(key
, "M3-"))
1640 mask
|= GDK_MOD3_MASK
;
1641 if (strstr(key
, "M4-"))
1642 mask
|= GDK_MOD4_MASK
;
1643 if (strstr(key
, "M5-"))
1644 mask
|= GDK_MOD5_MASK
;
1647 for (i
= strlen(key
) - 1; i
> 0; i
--)
1651 /* validate keyname */
1652 keyval
= gdk_keyval_from_name(key
);
1653 if (keyval
== GDK_VoidSymbol
) {
1654 warnx("invalid keybinding name %s", key
);
1657 /* must run this test too, gtk+ doesn't handle 10 for example */
1658 if (gdk_keyval_name(keyval
) == NULL
) {
1659 warnx("invalid keybinding name %s", key
);
1663 /* Remove eventual dupes. */
1664 TAILQ_FOREACH(k
, &kbl
, entry
)
1665 if (k
->key
== keyval
&& k
->mask
== mask
) {
1666 TAILQ_REMOVE(&kbl
, k
, entry
);
1671 if (strcmp(cmd
, "unbind") == 0) {
1672 DNPRINTF(XT_D_KEYBINDING
, "keybinding_set: just unbinding: %s\n",
1673 gdk_keyval_name(keyval
));
1674 printf("keybinding_set: just unbinding: %s\n",
1675 gdk_keyval_name(keyval
));
1680 k
= g_malloc0(sizeof *k
);
1681 k
->cmd
= g_strdup(cmd
);
1683 k
->use_in_entry
= use_in_entry
;
1686 DNPRINTF(XT_D_KEYBINDING
, "keybinding_set: %s 0x%x %d 0x%x\n",
1691 DNPRINTF(XT_D_KEYBINDING
, "keybinding_set: adding: %s %s\n",
1692 k
->cmd
, gdk_keyval_name(keyval
));
1694 TAILQ_INSERT_HEAD(&kbl
, k
, entry
);
1700 cmd_alias_add(char *alias
, char *cmd
)
1702 struct cmd_alias
*c
;
1705 TAILQ_FOREACH(c
, &cal
, entry
)
1706 if (!strcmp((alias
), c
->alias
)) {
1707 TAILQ_REMOVE(&cal
, c
, entry
);
1711 c
= g_malloc(sizeof (struct cmd_alias
));
1712 c
->alias
= g_strchug(g_strdup(alias
));
1713 c
->cmd
= g_strchug(g_strdup(cmd
));
1715 DNPRINTF(XT_D_CUSTOM_URI
, "cmd_alias_add: %s %s\n", c
->alias
, c
->cmd
);
1717 TAILQ_INSERT_HEAD(&cal
, c
, entry
);
1722 custom_uri_add(char *uri
, char *cmd
)
1724 struct custom_uri
*u
;
1726 TAILQ_FOREACH(u
, &cul
, entry
)
1727 if (!strcmp((uri
), u
->uri
) && !strcmp(cmd
, u
->cmd
)) {
1728 TAILQ_REMOVE(&cul
, u
, entry
);
1732 u
= g_malloc(sizeof (struct custom_uri
));
1733 u
->uri
= g_strdup(uri
);
1734 expand_tilde(u
->cmd
, sizeof u
->cmd
, cmd
);
1736 DNPRINTF(XT_D_CUSTOM_URI
, "custom_uri_add: %s %s\n", u
->uri
, u
->cmd
);
1738 /* don't check here if the script is valid, wait until running it */
1739 TAILQ_INSERT_HEAD(&cul
, u
, entry
);
1744 add_kb(struct settings
*s
, char *entry
)
1748 DNPRINTF(XT_D_KEYBINDING
, "add_kb: %s\n", entry
);
1750 /* clearall is special */
1751 if (!strcmp(entry
, "clearall")) {
1752 keybinding_clearall();
1756 kb
= strstr(entry
, ",");
1762 return (keybinding_set(entry
, key
, key
[0] == '!'));
1766 add_custom_uri(struct settings
*s
, char *entry
)
1770 DNPRINTF(XT_D_CUSTOM_URI
, "add_custom_uri: %s\n", entry
);
1772 uri
= strstr(entry
, ",");
1778 return (custom_uri_add(entry
, cmd
));
1782 walk_custom_uri(struct settings
*s
,
1783 void (*cb
)(struct settings
*, char *, void *), void *cb_args
)
1785 struct custom_uri
*u
;
1788 if (s
== NULL
|| cb
== NULL
) {
1789 show_oops(NULL
, "walk_custom_uri invalid parameters");
1793 TAILQ_FOREACH(u
, &cul
, entry
) {
1794 snprintf(buf
, sizeof buf
, "%s,%s", u
->uri
, u
->cmd
);
1795 cb(s
, buf
, cb_args
);
1800 add_ua(struct settings
*s
, char *value
)
1802 struct user_agent
*ua
;
1803 static int ua_count
= 0;
1805 ua
= g_malloc(sizeof *ua
);
1806 ua
->id
= ua_count
++;
1807 ua
->value
= g_strdup(value
);
1809 RB_INSERT(user_agent_list
, &ua_list
, ua
);
1816 walk_ua(struct settings
*s
,
1817 void (*cb
)(struct settings
*, char *, void *), void *cb_args
)
1819 struct user_agent
*ua
;
1821 if (s
== NULL
|| cb
== NULL
) {
1822 show_oops(NULL
, "walk_ua invalid parameters");
1826 RB_FOREACH(ua
, user_agent_list
, &ua_list
)
1827 cb(s
, ua
->value
, cb_args
);
1831 add_force_https(struct settings
*s
, char *value
)
1833 if (g_str_has_prefix(value
, "re:")) {
1835 wl_add(value
, &force_https
, XT_WL_PERSISTENT
| XT_WL_REGEX
);
1837 wl_add(value
, &force_https
, XT_WL_PERSISTENT
);
1842 add_http_accept(struct settings
*s
, char *value
)
1844 struct http_accept
*ha
;
1845 static int ha_count
= 0;
1847 ha
= g_malloc(sizeof *ha
);
1848 ha
->id
= ha_count
++;
1849 ha
->value
= g_strdup(value
);
1851 RB_INSERT(http_accept_list
, &ha_list
, ha
);
1857 walk_http_accept(struct settings
*s
,
1858 void (*cb
)(struct settings
*, char *, void *), void *cb_args
)
1860 struct http_accept
*ha
;
1862 if (s
== NULL
|| cb
== NULL
) {
1863 show_oops(NULL
, "%s: invalid parameters", __func__
);
1867 RB_FOREACH(ha
, http_accept_list
, &ha_list
)
1868 cb(s
, ha
->value
, cb_args
);
1872 add_cmd_alias(struct settings
*s
, char *entry
)
1876 DNPRINTF(XT_D_CMD_ALIAS
, "add_cmd_alias: %s\n", entry
);
1878 alias
= strstr(entry
, ",");
1884 return (cmd_alias_add(entry
, cmd
));
1888 walk_cmd_alias(struct settings
*s
,
1889 void (*cb
)(struct settings
*, char *, void *), void *cb_args
)
1891 struct cmd_alias
*c
;
1894 if (s
== NULL
|| cb
== NULL
) {
1895 show_oops(NULL
, "walk_cmd_alias invalid parameters");
1899 TAILQ_FOREACH(c
, &cal
, entry
) {
1900 snprintf(buf
, sizeof buf
, "%s --> %s", c
->alias
, c
->cmd
);
1901 cb(s
, buf
, cb_args
);
1906 set_allow_insecure_content(char *value
)
1912 if (value
== NULL
|| strlen(value
) == 0)
1913 allow_insecure_content
= XT_DS_ALLOW_INSECURE_CONTENT
;
1915 tmp
= strtonum(value
, 0, 1, &errstr
);
1918 allow_insecure_content
= tmp
;
1920 TAILQ_FOREACH(t
, &tabs
, entry
)
1921 if (is_g_object_setting(G_OBJECT(t
->settings
),
1922 "enable-display-of-insecure-content")) {
1923 g_object_set(G_OBJECT(t
->settings
),
1924 "enable-display-of-insecure-content",
1925 allow_insecure_content
, (char *)NULL
);
1926 webkit_web_view_set_settings(t
->wv
, t
->settings
);
1932 check_allow_insecure_content(char **tt
)
1934 *tt
= g_strdup("Default (depends on browser_mode):\n"
1935 "\tnormal:\tEnabled\n"
1936 "\twhitelist:\tDisabled\n"
1937 "\tkiosk:\tEnabled");
1938 if (browser_mode
== XT_BM_NORMAL
&& allow_insecure_content
!= 1)
1940 if (browser_mode
== XT_BM_WHITELIST
&& allow_insecure_content
!= 0)
1942 if (browser_mode
== XT_BM_KIOSK
&& allow_insecure_content
!= 1)
1948 set_allow_insecure_scripts(char *value
)
1954 if (value
== NULL
|| strlen(value
) == 0)
1955 allow_insecure_scripts
= XT_DS_ALLOW_INSECURE_SCRIPTS
;
1957 tmp
= strtonum(value
, 0, 1, &errstr
);
1960 allow_insecure_scripts
= tmp
;
1962 TAILQ_FOREACH(t
, &tabs
, entry
)
1963 if (is_g_object_setting(G_OBJECT(t
->settings
),
1964 "enable-running-of-insecure-content")) {
1965 g_object_set(G_OBJECT(t
->settings
),
1966 "enable-running-of-insecure-content",
1967 allow_insecure_scripts
, (char *)NULL
);
1968 webkit_web_view_set_settings(t
->wv
, t
->settings
);
1974 check_allow_insecure_scripts(char **tt
)
1976 *tt
= g_strdup("Default (depends on browser_mode):\n"
1977 "\tnormal:\tEnabled\n"
1978 "\twhitelist:\tDisabled\n"
1979 "\tkiosk:\tEnabled");
1980 if (browser_mode
== XT_BM_NORMAL
&& allow_insecure_scripts
!= 1)
1982 if (browser_mode
== XT_BM_WHITELIST
&& allow_insecure_scripts
!= 0)
1984 if (browser_mode
== XT_BM_KIOSK
&& allow_insecure_scripts
!= 1)
1990 set_auto_load_images(char *value
)
1996 if (value
== NULL
|| strlen(value
) == 0)
1997 auto_load_images
= XT_DS_AUTO_LOAD_IMAGES
;
1999 tmp
= strtonum(value
, 0, 1, &errstr
);
2002 auto_load_images
= tmp
;
2004 TAILQ_FOREACH(t
, &tabs
, entry
) {
2005 g_object_set(G_OBJECT(t
->settings
),
2006 "auto-load-images", auto_load_images
, (char *)NULL
);
2007 webkit_web_view_set_settings(t
->wv
, t
->settings
);
2013 check_auto_load_images(char **tt
)
2015 *tt
= g_strdup_printf("Default: %s",
2016 XT_DS_AUTO_LOAD_IMAGES
? "Enabled" : "Disabled");
2017 return (auto_load_images
!= XT_DS_AUTO_LOAD_IMAGES
);
2021 set_autofocus_onload(char *value
)
2026 if (value
== NULL
|| strlen(value
) == 0)
2027 autofocus_onload
= XT_DS_AUTOFOCUS_ONLOAD
;
2029 tmp
= strtonum(value
, 0, 1, &errstr
);
2032 autofocus_onload
= tmp
;
2038 check_autofocus_onload(char **tt
)
2040 *tt
= g_strdup_printf("Default: %s",
2041 XT_DS_AUTOFOCUS_ONLOAD
? "Enabled" : "Disabled");
2042 return (autofocus_onload
!= XT_DS_AUTOFOCUS_ONLOAD
);
2046 set_ctrl_click_focus(char *value
)
2051 if (value
== NULL
|| strlen(value
) == 0)
2052 ctrl_click_focus
= XT_DS_CTRL_CLICK_FOCUS
;
2054 tmp
= strtonum(value
, 0, 1, &errstr
);
2057 ctrl_click_focus
= tmp
;
2063 check_ctrl_click_focus(char **tt
)
2065 *tt
= g_strdup_printf("Default: %s",
2066 XT_DS_CTRL_CLICK_FOCUS
? "Enabled" : "Disabled");
2067 return (ctrl_click_focus
!= XT_DS_CTRL_CLICK_FOCUS
);
2071 set_download_notifications(char *value
)
2076 if (value
== NULL
|| strlen(value
) == 0)
2077 download_notifications
= XT_DS_DOWNLOAD_NOTIFICATIONS
;
2079 tmp
= strtonum(value
, 0, 1, &errstr
);
2082 download_notifications
= tmp
;
2088 check_download_notifications(char **tt
)
2090 *tt
= g_strdup_printf("Default: %s",
2091 XT_DS_DOWNLOAD_NOTIFICATIONS
? "Enabled" : "Disabled");
2092 return (download_notifications
!= XT_DS_DOWNLOAD_NOTIFICATIONS
);
2096 set_enable_autoscroll(char *value
)
2101 if (value
== NULL
|| strlen(value
) == 0)
2102 enable_autoscroll
= XT_DS_ENABLE_AUTOSCROLL
;
2104 tmp
= strtonum(value
, 0, 1, &errstr
);
2107 enable_autoscroll
= tmp
;
2113 check_enable_autoscroll(char **tt
)
2115 *tt
= g_strdup_printf("Default: %s",
2116 XT_DS_ENABLE_AUTOSCROLL
? "Enabled" : "Disabled");
2117 return (enable_autoscroll
!= XT_DS_ENABLE_AUTOSCROLL
);
2121 set_enable_cookie_whitelist(char *value
)
2126 if (value
== NULL
|| strlen(value
) == 0)
2127 enable_cookie_whitelist
= XT_DS_ENABLE_COOKIE_WHITELIST
;
2129 tmp
= strtonum(value
, 0, 1, &errstr
);
2132 enable_cookie_whitelist
= tmp
;
2138 check_enable_cookie_whitelist(char **tt
)
2140 *tt
= g_strdup("Default (depends on browser_mode):\n"
2141 "\tnormal:\tDisabled\n"
2142 "\twhitelist:\tEnabled\n"
2143 "\tkiosk:\tDisabled");
2144 if (browser_mode
== XT_BM_WHITELIST
&& enable_cookie_whitelist
!= 1)
2146 if (browser_mode
== XT_BM_NORMAL
&& enable_cookie_whitelist
!= 0)
2148 if (browser_mode
== XT_BM_KIOSK
&& enable_cookie_whitelist
!= 0)
2154 set_enable_js_autorun(char *value
)
2159 if (value
== NULL
|| strlen(value
) == 0)
2160 enable_js_autorun
= XT_DS_ENABLE_JS_AUTORUN
;
2162 tmp
= strtonum(value
, 0, 1, &errstr
);
2165 enable_js_autorun
= tmp
;
2171 check_enable_js_autorun(char **tt
)
2173 *tt
= g_strdup_printf("Default: %s",
2174 XT_DS_ENABLE_JS_AUTORUN
? "Enabled" : "Disabled");
2175 return (enable_js_autorun
!= XT_DS_ENABLE_JS_AUTORUN
);
2179 set_enable_js_whitelist(char *value
)
2184 if (value
== NULL
|| strlen(value
) == 0)
2185 enable_js_whitelist
= XT_DS_ENABLE_JS_WHITELIST
;
2187 tmp
= strtonum(value
, 0, 1, &errstr
);
2190 enable_js_whitelist
= tmp
;
2196 check_enable_js_whitelist(char **tt
)
2198 *tt
= g_strdup("Default (depends on browser_mode):\n"
2199 "\tnormal:\tDisabled\n"
2200 "\twhitelist:\tEnabled\n"
2201 "\tkiosk:\tDisabled");
2202 if (browser_mode
== XT_BM_WHITELIST
&& enable_js_whitelist
!= 1)
2204 if (browser_mode
== XT_BM_NORMAL
&& enable_js_whitelist
!= 0)
2206 if (browser_mode
== XT_BM_KIOSK
&& enable_js_whitelist
!= 0)
2212 set_enable_favicon_entry(char *value
)
2217 if (value
== NULL
|| strlen(value
) == 0)
2218 enable_favicon_entry
= XT_DS_ENABLE_FAVICON_ENTRY
;
2220 tmp
= strtonum(value
, 0, 1, &errstr
);
2223 enable_favicon_entry
= tmp
;
2229 check_enable_favicon_entry(char **tt
)
2231 *tt
= g_strdup_printf("Default: %s",
2232 XT_DS_ENABLE_FAVICON_ENTRY
? "Enabled" : "Disabled");
2233 return (enable_favicon_entry
!= XT_DS_ENABLE_FAVICON_ENTRY
);
2237 set_enable_favicon_tabs(char *value
)
2242 if (value
== NULL
|| strlen(value
) == 0)
2243 enable_favicon_tabs
= XT_DS_ENABLE_FAVICON_TABS
;
2245 tmp
= strtonum(value
, 0, 1, &errstr
);
2248 enable_favicon_tabs
= tmp
;
2254 check_enable_favicon_tabs(char **tt
)
2256 *tt
= g_strdup_printf("Default: %s",
2257 XT_DS_ENABLE_FAVICON_TABS
? "Enabled" : "Disabled");
2258 return (enable_favicon_tabs
!= XT_DS_ENABLE_FAVICON_TABS
);
2262 set_enable_localstorage(char *value
)
2268 if (value
== NULL
|| strlen(value
) == 0)
2269 enable_localstorage
= XT_DS_ENABLE_LOCALSTORAGE
;
2271 tmp
= strtonum(value
, 0, 1, &errstr
);
2274 enable_localstorage
= tmp
;
2276 TAILQ_FOREACH(t
, &tabs
, entry
)
2277 g_object_set(G_OBJECT(t
->settings
),
2278 "enable-html5-local-storage", enable_localstorage
,
2284 check_enable_localstorage(char **tt
)
2286 *tt
= g_strdup("Default (depends on browser_mode):\n"
2287 "\tnormal:\tEnabled\n"
2288 "\twhitelist:\tDisabled\n"
2289 "\tkiosk:\tEnabled");
2290 if (browser_mode
== XT_BM_WHITELIST
&& enable_localstorage
!= 0)
2292 if (browser_mode
== XT_BM_NORMAL
&& enable_localstorage
!= 1)
2294 if (browser_mode
== XT_BM_KIOSK
&& enable_localstorage
!= 1)
2300 set_enable_plugins(char *value
)
2306 if (value
== NULL
|| strlen(value
) == 0)
2307 enable_plugins
= XT_DS_ENABLE_PLUGINS
;
2309 tmp
= strtonum(value
, 0, 1, &errstr
);
2312 enable_plugins
= tmp
;
2314 TAILQ_FOREACH(t
, &tabs
, entry
)
2315 g_object_set(G_OBJECT(t
->settings
), "enable-plugins",
2316 enable_plugins
, (char *)NULL
);
2321 check_enable_plugins(char **tt
)
2323 *tt
= g_strdup("Default (depends on browser_mode):\n"
2324 "\tnormal:\tEnabled\n"
2325 "\twhitelist:\tDisabled\n"
2326 "\tkiosk:\tEnabled");
2327 if (browser_mode
== XT_BM_WHITELIST
&& enable_plugins
!= 0)
2329 if (browser_mode
== XT_BM_NORMAL
&& enable_plugins
!= 1)
2331 if (browser_mode
== XT_BM_KIOSK
&& enable_plugins
!= 1)
2337 set_enable_plugin_whitelist(char *value
)
2342 if (value
== NULL
|| strlen(value
) == 0)
2343 enable_plugin_whitelist
= XT_DS_ENABLE_PLUGIN_WHITELIST
;
2345 tmp
= strtonum(value
, 0, 1, &errstr
);
2348 enable_plugin_whitelist
= tmp
;
2354 check_enable_plugin_whitelist(char **tt
)
2356 *tt
= g_strdup("Default (depends on browser_mode):\n"
2357 "\tnormal:\tDisabled\n"
2358 "\twhitelist:\tEnabled\n"
2359 "\tkiosk:\tDisabled");
2360 if (browser_mode
== XT_BM_WHITELIST
&& enable_plugin_whitelist
!= 1)
2362 if (browser_mode
== XT_BM_NORMAL
&& enable_plugin_whitelist
!= 0)
2364 if (browser_mode
== XT_BM_KIOSK
&& enable_plugin_whitelist
!= 0)
2370 set_enable_scripts(char *value
)
2376 if (value
== NULL
|| strlen(value
) == 0)
2377 enable_scripts
= XT_DS_ENABLE_SCRIPTS
;
2379 tmp
= strtonum(value
, 0, 1, &errstr
);
2382 enable_scripts
= tmp
;
2384 TAILQ_FOREACH(t
, &tabs
, entry
)
2385 g_object_set(G_OBJECT(t
->settings
), "enable-scripts",
2386 enable_scripts
, (char *)NULL
);
2391 check_enable_scripts(char **tt
)
2393 *tt
= g_strdup("Default (depends on browser_mode):\n"
2394 "\tnormal:\tEnabled\n"
2395 "\twhitelist:\tDisabled\n"
2396 "\tkiosk:\tEnabled");
2397 if (browser_mode
== XT_BM_WHITELIST
&& enable_scripts
!= 0)
2399 if (browser_mode
== XT_BM_NORMAL
&& enable_scripts
!= 1)
2401 if (browser_mode
== XT_BM_KIOSK
&& enable_scripts
!= 1)
2407 check_enable_socket(char **tt
)
2409 *tt
= g_strdup("Default: Disabled");
2410 return (enable_socket
!= 0);
2414 set_enable_spell_checking(char *value
)
2420 if (value
== NULL
|| strlen(value
) == 0)
2421 enable_spell_checking
= XT_DS_ENABLE_SPELL_CHECKING
;
2423 tmp
= strtonum(value
, 0, 1, &errstr
);
2426 enable_spell_checking
= tmp
;
2428 TAILQ_FOREACH(t
, &tabs
, entry
)
2429 g_object_set(G_OBJECT(t
->settings
), "enable_spell_checking",
2430 enable_spell_checking
, (char *)NULL
);
2435 check_enable_spell_checking(char **tt
)
2437 *tt
= g_strdup_printf("Default: %s",
2438 XT_DS_ENABLE_SPELL_CHECKING
? "Enabled" : "Disabled");
2439 return (enable_spell_checking
!= XT_DS_ENABLE_SPELL_CHECKING
);
2443 set_enable_strict_transport(char *value
)
2448 if (value
== NULL
|| strlen(value
) == 0)
2449 enable_strict_transport
= XT_DS_ENABLE_STRICT_TRANSPORT
;
2451 tmp
= strtonum(value
, 0, 1, &errstr
);
2454 enable_strict_transport
= tmp
;
2460 check_enable_strict_transport(char **tt
)
2462 *tt
= g_strdup_printf("Default: %s",
2463 XT_DS_ENABLE_STRICT_TRANSPORT
? "Enabled" : "Disabled");
2464 return (enable_strict_transport
!= XT_DS_ENABLE_STRICT_TRANSPORT
);
2469 * XXX: this is currently broken. Need to figure out what to do with
2470 * this. Problemm is set_encoding will refresh the tab it's run on, so
2471 * we can either put a big fat warning in the manpage and refresh every
2472 * single open tab with the new encoding or scrap it as a runtime
2476 set_encoding_rt(char *value
)
2478 struct karg args
= {0};
2480 if (value
== NULL
|| strlen(value
) == 0)
2484 encoding
= g_strdup(value
);
2486 set_encoding(get_current_tab(), &args
);
2492 check_encoding(char **tt
)
2494 *tt
= g_strdup_printf("Default: %s", XT_DS_ENCODING
);
2495 return (g_strcmp0(encoding
, XT_DS_ENCODING
));
2499 check_gnutls_search_string(char **tt
)
2501 *tt
= g_strdup("Default: (empty)");
2502 return (g_strcmp0(gnutls_priority_string
,
2503 XT_DS_GNUTLS_PRIORITY_STRING
));
2507 set_gnutls_priority_string(struct settings
*s
, char *value
)
2509 return (!g_setenv("G_TLS_GNUTLS_PRIORITY", value
, FALSE
));
2513 get_gnutls_priority_string(struct settings
*s
)
2515 return (g_strdup(g_getenv("G_TLS_GNUTLS_PRIORITY")));
2519 set_guess_search(char *value
)
2524 if (value
== NULL
|| strlen(value
) == 0)
2525 guess_search
= XT_DS_GUESS_SEARCH
;
2527 tmp
= strtonum(value
, 0, 1, &errstr
);
2536 check_guess_search(char **tt
)
2538 *tt
= g_strdup_printf("Default: %s",
2539 XT_DS_GUESS_SEARCH
? "Enabled" : "Disabled");
2540 return (guess_search
!= XT_DS_GUESS_SEARCH
);
2544 get_referer(struct settings
*s
)
2546 if (referer_mode
== XT_REFERER_ALWAYS
)
2547 return (g_strdup("always"));
2548 if (referer_mode
== XT_REFERER_NEVER
)
2549 return (g_strdup("never"));
2550 if (referer_mode
== XT_REFERER_SAME_DOMAIN
)
2551 return (g_strdup("same-domain"));
2552 if (referer_mode
== XT_REFERER_SAME_FQDN
)
2553 return (g_strdup("same-fqdn"));
2554 if (referer_mode
== XT_REFERER_CUSTOM
)
2555 return (g_strdup(referer_custom
));
2560 set_referer(struct settings
*s
, char *value
)
2562 if (referer_custom
) {
2563 g_free(referer_custom
);
2564 referer_custom
= NULL
;
2567 if (!strcmp(value
, "always"))
2568 referer_mode
= XT_REFERER_ALWAYS
;
2569 else if (!strcmp(value
, "never"))
2570 referer_mode
= XT_REFERER_NEVER
;
2571 else if (!strcmp(value
, "same-domain"))
2572 referer_mode
= XT_REFERER_SAME_DOMAIN
;
2573 else if (!strcmp(value
, "same-fqdn"))
2574 referer_mode
= XT_REFERER_SAME_FQDN
;
2575 else if (!valid_url_type(value
)) {
2576 referer_mode
= XT_REFERER_CUSTOM
;
2577 referer_custom
= g_strdup(value
);
2579 /* we've already free'd the custom referer */
2580 if (referer_mode
== XT_REFERER_CUSTOM
)
2581 referer_mode
= XT_REFERER_NEVER
;
2589 set_referer_rt(char *value
)
2591 if (value
== NULL
|| strlen(value
) == 0) {
2593 g_free(referer_custom
);
2594 referer_custom
= g_strdup(XT_DS_REFERER_CUSTOM
);
2595 referer_mode
= XT_DS_REFERER_MODE
;
2598 return (set_referer(NULL
, value
));
2602 check_referer(char **tt
)
2604 *tt
= g_strdup("Default (depends on browser_mode):\n"
2605 "\tnormal:\talways\n"
2606 "\twhitelist:\tsame-domain\n"
2607 "\tkiosk:\talways");
2608 if (browser_mode
== XT_BM_WHITELIST
&&
2609 referer_mode
!= XT_REFERER_SAME_DOMAIN
)
2611 if (browser_mode
== XT_BM_NORMAL
&& referer_mode
!= XT_REFERER_ALWAYS
)
2613 if (browser_mode
== XT_BM_KIOSK
&& referer_mode
!= XT_REFERER_ALWAYS
)
2619 get_ssl_ca_file(struct settings
*s
)
2621 if (strlen(ssl_ca_file
) == 0)
2623 return (g_strdup(ssl_ca_file
));
2627 set_refresh_interval(char *value
)
2632 if (value
== NULL
|| strlen(value
) == 0)
2633 refresh_interval
= XT_DS_REFRESH_INTERVAL
;
2635 tmp
= strtonum(value
, 0, INT_MAX
, &errstr
);
2638 refresh_interval
= tmp
;
2644 check_resource_dir(char **tt
)
2646 *tt
= g_strdup_printf("Default: %s", XT_DS_RESOURCE_DIR
);
2647 return (g_strcmp0(resource_dir
, XT_DS_RESOURCE_DIR
));
2651 check_save_global_history(char **tt
)
2653 *tt
= g_strdup("Default: Disabled");
2654 return (save_global_history
!= 0);
2658 check_save_rejected_cookies(char **tt
)
2660 *tt
= g_strdup("Default: Disabled");
2661 return (save_rejected_cookies
!= 0);
2665 check_refresh_interval(char **tt
)
2667 *tt
= g_strdup_printf("Default: %d", XT_DS_REFRESH_INTERVAL
);
2668 return (refresh_interval
!= XT_DS_REFRESH_INTERVAL
);
2672 set_session_autosave(char *value
)
2677 if (value
== NULL
|| strlen(value
) == 0)
2678 session_autosave
= XT_DS_SESSION_AUTOSAVE
;
2680 tmp
= strtonum(value
, 0, 1, &errstr
);
2683 session_autosave
= tmp
;
2689 check_session_autosave(char **tt
)
2691 *tt
= g_strdup_printf("Default: %s",
2692 XT_DS_SESSION_AUTOSAVE
? "Enabled" : "Disabled");
2693 return (session_autosave
!= XT_DS_SESSION_AUTOSAVE
);
2697 set_session_timeout(char *value
)
2702 if (value
== NULL
|| strlen(value
) == 0)
2703 session_timeout
= XT_DS_SESSION_TIMEOUT
;
2705 tmp
= strtonum(value
, 0, INT_MAX
, &errstr
);
2708 session_timeout
= tmp
;
2714 check_session_timeout(char **tt
)
2716 *tt
= g_strdup_printf("Default: %d", XT_DS_SESSION_TIMEOUT
);
2717 return (session_timeout
!= XT_DS_SESSION_TIMEOUT
);
2721 set_show_scrollbars(char *value
)
2727 if (value
== NULL
|| strlen(value
) == 0)
2728 tmp
= XT_DS_SHOW_SCROLLBARS
;
2730 tmp
= strtonum(value
, 0, 1, &errstr
);
2734 show_scrollbars
= tmp
;
2735 TAILQ_FOREACH(t
, &tabs
, entry
)
2736 if (set_scrollbar_visibility(t
, show_scrollbars
))
2742 check_show_scrollbars(char **tt
)
2744 *tt
= g_strdup("Default (depends on gui_mode):\n"
2745 "\tclassic:\tEnabled\n"
2746 "\tminimal:\tDisabled");
2747 if (gui_mode
== XT_GM_CLASSIC
&& show_scrollbars
!= 1)
2749 if (gui_mode
== XT_GM_MINIMAL
&& show_scrollbars
!= 0)
2755 set_show_statusbar(char *value
)
2760 if (value
== NULL
|| strlen(value
) == 0)
2761 tmp
= XT_DS_SHOW_STATUSBAR
;
2763 tmp
= strtonum(value
, 0, 1, &errstr
);
2767 show_statusbar
= tmp
;
2768 statusbar_set_visibility();
2773 check_show_statusbar(char **tt
)
2775 *tt
= g_strdup("Default (depends on gui_mode):\n"
2776 "\tclassic:\tDisabled\n"
2777 "\tminimal:\tEnabled");
2778 if (gui_mode
== XT_GM_CLASSIC
&& show_statusbar
!= 0)
2780 if (gui_mode
== XT_GM_MINIMAL
&& show_statusbar
!= 1)
2786 set_show_tabs(char *value
)
2788 struct karg args
= {0};
2792 if (value
== NULL
|| strlen(value
) == 0)
2793 val
= XT_DS_SHOW_TABS
;
2795 val
= strtonum(value
, 0, 1, &errstr
);
2799 args
.i
= val
? XT_TAB_SHOW
: XT_TAB_HIDE
;
2800 tabaction(get_current_tab(), &args
);
2805 check_show_tabs(char **tt
)
2807 *tt
= g_strdup("Default (depends on gui_mode):\n"
2808 "\tclassic:\tEnabled\n"
2809 "\tminimal:\tDisabled");
2810 if (gui_mode
== XT_GM_CLASSIC
&& show_tabs
!= 1)
2812 if (gui_mode
== XT_GM_MINIMAL
&& show_tabs
!= 0)
2818 set_show_url(char *value
)
2820 struct karg args
= {0};
2824 if (value
== NULL
|| strlen(value
) == 0)
2825 val
= XT_DS_SHOW_URL
;
2827 val
= strtonum(value
, 0, 1, &errstr
);
2831 args
.i
= val
? XT_URL_SHOW
: XT_URL_HIDE
;
2832 urlaction(get_current_tab(), &args
);
2837 check_show_url(char **tt
)
2839 *tt
= g_strdup("Default (depends on gui_mode):\n"
2840 "\tclassic:\tEnabled\n"
2841 "\tminimal:\tDisabled");
2842 if (gui_mode
== XT_GM_CLASSIC
&& show_url
!= 1)
2844 if (gui_mode
== XT_GM_MINIMAL
&& show_url
!= 0)
2850 check_single_instance(char **tt
)
2852 *tt
= g_strdup("Default: Disabled");
2853 return (single_instance
!= 0);
2857 set_spell_check_languages(char *value
)
2861 if (spell_check_languages
)
2862 g_free(spell_check_languages
);
2863 if (value
== NULL
|| strlen(value
) == 0)
2864 spell_check_languages
= g_strdup(XT_DS_SPELL_CHECK_LANGUAGES
);
2866 spell_check_languages
= g_strdup(value
);
2867 TAILQ_FOREACH(t
, &tabs
, entry
)
2868 g_object_set(G_OBJECT(t
->settings
), "spell_checking_languages",
2869 spell_check_languages
, (char *)NULL
);
2874 check_spell_check_languages(char **tt
)
2876 *tt
= g_strdup_printf("Default: %s", XT_DS_SPELL_CHECK_LANGUAGES
);
2877 return (g_strcmp0(spell_check_languages
, XT_DS_SPELL_CHECK_LANGUAGES
));
2881 check_valid_file(char *name
)
2885 if (name
== NULL
|| stat(name
, &sb
))
2891 set_ssl_ca_file_rt(char *value
)
2893 if (value
== NULL
|| strlen(value
) == 0) {
2894 strlcpy(ssl_ca_file
, XT_DS_SSL_CA_FILE
, sizeof ssl_ca_file
);
2895 g_object_set(session
, SOUP_SESSION_SSL_CA_FILE
, "", NULL
);
2898 return (set_ssl_ca_file(NULL
, value
));
2902 check_ssl_ca_file(char **tt
)
2904 *tt
= g_strdup("Default: (empty)");
2905 return (g_strcmp0(ssl_ca_file
, XT_DS_SSL_CA_FILE
));
2909 set_ssl_strict_certs(char *value
)
2914 if (value
== NULL
|| strlen(value
) == 0)
2915 ssl_strict_certs
= XT_DS_SSL_STRICT_CERTS
;
2917 tmp
= strtonum(value
, 0, 1, &errstr
);
2920 ssl_strict_certs
= tmp
;
2922 g_object_set(session
, SOUP_SESSION_SSL_STRICT
, ssl_strict_certs
, NULL
);
2927 check_ssl_strict_certs(char **tt
)
2929 *tt
= g_strdup_printf("Default: %s",
2930 XT_DS_SSL_STRICT_CERTS
? "Enabled" : "Disabled");
2931 return (ssl_strict_certs
!= XT_DS_SSL_STRICT_CERTS
);
2935 check_statusbar_elems(char **tt
)
2937 *tt
= g_strdup("Default: BP");
2938 return (g_strcmp0(statusbar_elems
, "BP"));
2942 set_external_editor(char *editor
)
2944 if (external_editor
)
2945 g_free(external_editor
);
2946 if (editor
== NULL
|| strlen(editor
) == 0)
2947 external_editor
= NULL
;
2949 external_editor
= g_strdup(editor
);
2954 check_external_editor(char **tt
)
2956 *tt
= g_strdup("Default: (empty)");
2957 return (g_strcmp0(external_editor
, NULL
));
2961 set_fancy_bar(char *value
)
2967 if (value
== NULL
|| strlen(value
) == 0)
2968 fancy_bar
= 1; /* XXX */
2970 tmp
= strtonum(value
, 0, 1, &errstr
);
2975 TAILQ_FOREACH(t
, &tabs
, entry
)
2977 gtk_widget_show(t
->backward
);
2978 gtk_widget_show(t
->forward
);
2979 gtk_widget_show(t
->stop
);
2980 gtk_widget_show(t
->js_toggle
);
2981 if (search_string
&& strlen(search_string
))
2982 gtk_widget_show(t
->search_entry
);
2984 gtk_widget_hide(t
->backward
);
2985 gtk_widget_hide(t
->forward
);
2986 gtk_widget_hide(t
->stop
);
2987 gtk_widget_hide(t
->js_toggle
);
2988 gtk_widget_hide(t
->search_entry
);
2994 check_fancy_bar(char **tt
)
2996 *tt
= g_strdup("Default (depends on gui_mode):\n"
2997 "\tclassic:\tEnabled\n"
2998 "\tminimal:\tDisabled");
2999 if (gui_mode
== XT_GM_CLASSIC
&& fancy_bar
!= 1)
3001 if (gui_mode
== XT_GM_MINIMAL
&& fancy_bar
!= 0)
3007 setup_proxy(char *uri
)
3012 g_object_set(session
, "proxy_uri", NULL
, (char *)NULL
);
3013 soup_uri_free(proxy_uri
);
3015 TAILQ_FOREACH(t
, &tabs
, entry
)
3016 gtk_label_set_text(GTK_LABEL(t
->sbe
.proxy
), "");
3019 if (http_proxy
!= uri
) {
3026 http_proxy
= g_strdup(uri
);
3027 DNPRINTF(XT_D_CONFIG
, "setup_proxy: %s\n", uri
);
3028 proxy_uri
= soup_uri_new(http_proxy
);
3029 if (proxy_uri
!= NULL
&& SOUP_URI_VALID_FOR_HTTP(proxy_uri
)) {
3030 g_object_set(session
, "proxy-uri", proxy_uri
,
3032 TAILQ_FOREACH(t
, &tabs
, entry
) {
3033 gtk_label_set_text(GTK_LABEL(t
->sbe
.proxy
),
3035 gtk_widget_show(t
->proxy_toggle
);
3036 button_set_file(t
->proxy_toggle
,
3041 TAILQ_FOREACH(t
, &tabs
, entry
)
3042 button_set_file(t
->proxy_toggle
, "tordisabled.ico");
3047 get_tab_style(struct settings
*s
)
3049 if (tab_style
== XT_TABS_NORMAL
)
3050 return (g_strdup("normal"));
3052 return (g_strdup("compact"));
3056 set_tab_style(struct settings
*s
, char *val
)
3058 if (!strcmp(val
, "normal"))
3059 tab_style
= XT_TABS_NORMAL
;
3060 else if (!strcmp(val
, "compact"))
3061 tab_style
= XT_TABS_COMPACT
;
3069 check_tab_style(char **tt
)
3071 *tt
= g_strdup("Default (depends on gui_mode):\n"
3072 "\tclassic:\tnormal\n"
3073 "\tminimal:\tcompact");
3074 if (gui_mode
== XT_GM_CLASSIC
&& tab_style
!= XT_TABS_NORMAL
)
3076 if (gui_mode
== XT_GM_MINIMAL
&& tab_style
!= XT_TABS_COMPACT
)
3082 set_tab_style_rt(char *value
)
3084 struct karg args
= {0};
3087 if (value
== NULL
|| strlen(value
) == 0) {
3088 if (tab_style
== XT_DS_TAB_STYLE
)
3090 tab_style
= XT_TABS_COMPACT
;
3091 args
.i
= XT_TAB_NEXTSTYLE
;
3093 old_tab_style
= tab_style
;
3094 if (set_tab_style(NULL
, value
))
3096 if (old_tab_style
!= tab_style
) {
3097 tab_style
= old_tab_style
;
3098 args
.i
= XT_TAB_NEXTSTYLE
;
3101 tabaction(get_current_tab(), &args
);
3106 get_statusbar_style(struct settings
*s
)
3108 if (statusbar_style
== XT_STATUSBAR_URL
)
3109 return (g_strdup("url"));
3111 return (g_strdup("title"));
3115 set_statusbar_style(struct settings
*s
, char *val
)
3117 if (!strcmp(val
, "url"))
3118 statusbar_style
= XT_STATUSBAR_URL
;
3119 else if (!strcmp(val
, "title"))
3120 statusbar_style
= XT_STATUSBAR_TITLE
;
3128 set_statusbar_style_rt(char *value
)
3131 const gchar
*page_uri
;
3133 if (value
== NULL
|| strlen(value
) == 0) {
3134 if (statusbar_style
== XT_DS_STATUSBAR_STYLE
)
3136 statusbar_style
= XT_DS_STATUSBAR_STYLE
;
3138 if (!strcmp(value
, "url"))
3139 statusbar_style
= XT_STATUSBAR_URL
;
3140 else if (!strcmp(value
, "title"))
3141 statusbar_style
= XT_STATUSBAR_TITLE
;
3145 TAILQ_FOREACH(t
, &tabs
, entry
) {
3146 if (statusbar_style
== XT_STATUSBAR_TITLE
)
3147 set_status(t
, "%s", get_title(t
, FALSE
));
3148 else if ((page_uri
= get_uri(t
)) != NULL
)
3149 set_status(t
, "%s", page_uri
);
3156 check_statusbar_style(char **tt
)
3158 *tt
= g_strdup("Default: url");
3159 return (statusbar_style
!= XT_DS_STATUSBAR_STYLE
);
3163 set_url_regex(char *value
)
3165 if (value
== NULL
|| strlen(value
) == 0) {
3168 url_regex
= g_strdup(XT_DS_URL_REGEX
);
3170 if (regcomp(&url_re
, value
, REG_EXTENDED
| REG_NOSUB
))
3174 url_regex
= g_strdup(value
);
3180 check_url_regex(char **tt
)
3182 *tt
= g_strdup_printf("Default: %s", XT_DS_URL_REGEX
);
3183 return (g_strcmp0(url_regex
, XT_DS_URL_REGEX
));
3187 set_userstyle(struct settings
*s
, char *value
)
3190 char script
[PATH_MAX
] = {'\0'};
3193 if (value
== NULL
|| strlen(value
) == 0) {
3194 snprintf(script
, sizeof script
, "%s" PS
"style.css", resource_dir
);
3195 tmp
= g_filename_to_uri(script
, NULL
, NULL
);
3204 expand_tilde(script
, sizeof script
, value
);
3205 tmp
= g_filename_to_uri(script
, NULL
, NULL
);
3216 stylesheet
= g_strdup(userstyle
);
3221 get_userstyle(struct settings
*s
)
3224 return (g_filename_from_uri(userstyle
, NULL
, NULL
));
3229 set_userstyle_rt(char *value
)
3231 return (set_userstyle(NULL
, value
));
3235 check_userstyle(char **tt
)
3241 snprintf(buf
, sizeof buf
, "%s" PS
"%s", resource_dir
, "style.css");
3242 *tt
= g_strdup_printf("Default: %s", buf
);
3243 file
= g_filename_from_uri(userstyle
, NULL
, NULL
);
3244 rv
= g_strcmp0(file
, buf
);
3251 set_userstyle_global(char *value
)
3253 struct karg args
= {0};
3257 if (value
== NULL
|| strlen(value
) == 0) {
3258 if (userstyle_global
== XT_DS_USERSTYLE_GLOBAL
)
3260 userstyle_global
= 1;
3261 args
.i
= XT_STYLE_GLOBAL
;
3262 userstyle_cmd(get_current_tab(), &args
);
3264 old_style
= userstyle_global
;
3265 tmp
= strtonum(value
, 0, 1, &errstr
);
3268 if (tmp
!= old_style
) {
3269 args
.i
= XT_STYLE_GLOBAL
;
3270 userstyle_cmd(get_current_tab(), &args
);
3277 check_userstyle_global(char **tt
)
3279 *tt
= g_strdup_printf("Default: %s",
3280 XT_DS_USERSTYLE_GLOBAL
? "Enabled" : "Disabled");
3281 return (userstyle_global
!= XT_DS_USERSTYLE_GLOBAL
);
3285 set_warn_cert_changes(char *value
)
3290 if (value
== NULL
|| strlen(value
) == 0)
3291 warn_cert_changes
= XT_DS_WARN_CERT_CHANGES
;
3293 tmp
= strtonum(value
, 0, 1, &errstr
);
3296 warn_cert_changes
= tmp
;
3302 check_warn_cert_changes(char **tt
)
3304 *tt
= g_strdup_printf("Default: %s",
3305 XT_DS_WARN_CERT_CHANGES
? "Enabled" : "Disabled");
3306 return (warn_cert_changes
!= XT_DS_WARN_CERT_CHANGES
);
3310 check_window_height(char **tt
)
3312 *tt
= g_strdup_printf("Default: %d", 768);
3313 return (window_height
!= 768);
3317 check_window_maximize(char **tt
)
3319 *tt
= g_strdup("Default: Disabled");
3320 return (window_maximize
!= 0);
3324 check_window_width(char **tt
)
3326 *tt
= g_strdup_printf("Default: %d", 768);
3327 return (window_width
!= 1024);
3331 check_work_dir(char **tt
)
3336 if ((pwd
= getpwuid(getuid())) == NULL
)
3338 snprintf(buf
, sizeof buf
, "%s" PS
".xombrero", pwd
->pw_dir
);
3339 *tt
= g_strdup_printf("Default: %s", buf
);
3340 return (g_strcmp0(work_dir
, buf
));
3344 get_edit_mode(struct settings
*s
)
3346 if (edit_mode
== XT_EM_HYBRID
)
3347 return (g_strdup("hybrid"));
3349 return (g_strdup("vi"));
3353 set_edit_mode(struct settings
*s
, char *val
)
3355 if (!strcmp(val
, "hybrid"))
3356 edit_mode
= XT_EM_HYBRID
;
3357 else if (!strcmp(val
, "vi"))
3358 edit_mode
= XT_EM_VI
;
3366 check_edit_mode(char **tt
)
3368 *tt
= g_strdup("Default: hybrid");
3369 return (edit_mode
!= XT_EM_HYBRID
);
3373 get_download_mode(struct settings
*s
)
3375 switch (download_mode
) {
3377 return (g_strdup("start"));
3380 return (g_strdup("ask"));
3383 return (g_strdup("add"));
3386 return (g_strdup("unknown"));
3390 set_download_mode(struct settings
*s
, char *val
)
3392 if (val
== NULL
|| strlen(val
) == 0 || !strcmp(val
, "start"))
3393 download_mode
= XT_DM_START
;
3394 else if (!strcmp(val
, "ask"))
3395 download_mode
= XT_DM_ASK
;
3396 else if (!strcmp(val
, "add"))
3397 download_mode
= XT_DM_ADD
;
3405 set_download_mode_rt(char *val
)
3407 return (set_download_mode(NULL
, val
));
3411 check_download_mode(char **tt
)
3413 *tt
= g_strdup("Default: start");
3414 return (download_mode
!= XT_DM_START
);
3418 get_work_dir(struct settings
*s
)
3420 if (work_dir
[0] == '\0')
3422 return (g_strdup(work_dir
));
3426 set_work_dir(struct settings
*s
, char *val
)
3428 expand_tilde(work_dir
, sizeof work_dir
, val
);
3433 walk_cookie_wl(struct settings
*s
,
3434 void (*cb
)(struct settings
*, char *, void *), void *cb_args
)
3438 if (s
== NULL
|| cb
== NULL
) {
3439 show_oops(NULL
, "walk_cookie_wl invalid parameters");
3443 TAILQ_FOREACH_REVERSE(w
, &c_wl
, wl_list
, entry
)
3444 cb(s
, w
->pat
, cb_args
);
3448 walk_js_wl(struct settings
*s
,
3449 void (*cb
)(struct settings
*, char *, void *), void *cb_args
)
3453 if (s
== NULL
|| cb
== NULL
) {
3454 show_oops(NULL
, "walk_js_wl invalid parameters");
3458 TAILQ_FOREACH_REVERSE(w
, &js_wl
, wl_list
, entry
)
3459 cb(s
, w
->pat
, cb_args
);
3463 walk_pl_wl(struct settings
*s
,
3464 void (*cb
)(struct settings
*, char *, void *), void *cb_args
)
3468 if (s
== NULL
|| cb
== NULL
) {
3469 show_oops(NULL
, "walk_pl_wl invalid parameters");
3473 TAILQ_FOREACH_REVERSE(w
, &pl_wl
, wl_list
, entry
)
3474 cb(s
, w
->pat
, cb_args
);
3478 walk_force_https(struct settings
*s
,
3479 void (*cb
)(struct settings
*, char *, void *), void *cb_args
)
3483 if (s
== NULL
|| cb
== NULL
) {
3484 show_oops(NULL
, "walk_force_https invalid parameters");
3488 TAILQ_FOREACH_REVERSE(w
, &force_https
, wl_list
, entry
)
3489 cb(s
, w
->pat
, cb_args
);
3493 settings_add(char *var
, char *val
)
3497 char c
[PATH_MAX
], **s
;
3500 for (i
= 0, rv
= 0; i
< LENGTH(rs
); i
++) {
3501 if (strcmp(var
, rs
[i
].name
))
3504 if (!strcmp(var
, "include_config")) {
3505 expand_tilde(c
, sizeof c
, val
);
3512 if (rs
[i
].s
->set(&rs
[i
], val
))
3513 startpage_add("invalid value for %s: %s", var
,
3518 switch (rs
[i
].type
) {
3519 case XT_S_INT
: /* FALLTHROUGH */
3528 errx(1, "invalid sval for %s",
3542 errx(1, "invalid type for %s", var
);
3551 config_parse(char *filename
, int runtime
)
3554 char *line
, *cp
, *var
, *val
;
3555 size_t len
, lineno
= 0;
3557 char file
[PATH_MAX
];
3560 DNPRINTF(XT_D_CONFIG
, "config_parse: filename %s\n", filename
);
3562 if (filename
== NULL
)
3565 if (runtime
&& runtime_settings
[0] != '\0') {
3566 snprintf(file
, sizeof file
, "%s" PS
"%s",
3567 work_dir
, runtime_settings
);
3568 if (stat(file
, &sb
)) {
3569 warnx("runtime file doesn't exist, creating it");
3570 if ((f
= fopen(file
, "w")) == NULL
)
3572 fprintf(f
, "# AUTO GENERATED, DO NOT EDIT\n");
3576 strlcpy(file
, filename
, sizeof file
);
3578 if ((config
= fopen(file
, "r")) == NULL
) {
3579 warn("config_parse: cannot open %s", filename
);
3584 if ((line
= fparseln(config
, &len
, &lineno
, NULL
, 0)) == NULL
)
3585 if (feof(config
) || ferror(config
))
3589 cp
+= (long)strspn(cp
, WS
);
3590 if (cp
[0] == '\0') {
3596 if ((var
= strsep(&cp
, WS
)) == NULL
|| cp
== NULL
)
3597 startpage_add("invalid configuration file entry: %s",
3600 cp
+= (long)strspn(cp
, WS
);
3602 if ((val
= strsep(&cp
, "\0")) == NULL
)
3605 DNPRINTF(XT_D_CONFIG
, "config_parse: %s=%s\n",
3607 handled
= settings_add(var
, val
);
3610 startpage_add("invalid configuration file entry"
3611 ": %s=%s", var
, val
);
3620 struct settings_args
{
3626 print_setting(struct settings
*s
, char *val
, void *cb_args
)
3628 char *enc_val
, *tmp
, *color
;
3629 struct settings_args
*sa
= cb_args
;
3631 if (sa
== NULL
|| s
->flags
& XT_SF_INVISIBLE
)
3634 if (s
->flags
& XT_SF_RUNTIME
)
3639 enc_val
= html_escape(val
);
3641 *sa
->body
= g_strdup_printf(
3643 "<td style='background-color: %s; width: 10%%;word-break:break-all'>%s</td>"
3644 "<td style='background-color: %s; width: 20%%;word-break:break-all'>%s</td>",
3649 enc_val
== NULL
? "" : enc_val
3658 print_runtime_setting(struct settings
*s
, char *val
, void *cb_args
)
3660 char *tmp
, *tt
= NULL
;
3661 struct settings_args
*sa
= cb_args
;
3668 if (s
== NULL
|| s
->flags
& XT_SF_INVISIBLE
|| s
->activate
== NULL
)
3673 modified
= s
->ismodified(&tt
);
3674 *sa
->body
= g_strdup_printf(
3676 "<td title=\"%s\" style='width: 240px;'><div style='width: 100%%;'>%s</div></td>"
3677 "<td title=\"%s\"><div style='width: 100%%; word-break:break-all'>",
3679 modified
? "id='modified'" : "",
3687 if (s
->type
== XT_S_STR
&& s
->s
&& s
->s
->valid_options
[0]) {
3688 *sa
->body
= g_strdup_printf("%s<select name='%s'>",
3691 for (i
= 0; s
->s
->valid_options
[i
]; ++i
) {
3694 *sa
->body
= g_strdup_printf("%s"
3695 "<option value='%s' %s>%s</option>",
3697 s
->s
->valid_options
[i
],
3698 !strcmp(s
->s
->valid_options
[i
], val
) ? "selected" : "",
3699 s
->s
->valid_options
[i
]);
3701 } else if (s
->type
== XT_S_STR
)
3702 *sa
->body
= g_strdup_printf(
3703 "%s<input style='width: 98%%' type='text' name='%s' value='%s'>"
3708 else if (s
->type
== XT_S_INT
)
3709 *sa
->body
= g_strdup_printf(
3710 "%s<input type='number' name='%s' value='%s'>"
3715 else if (s
->type
== XT_S_FLOAT
)
3716 *sa
->body
= g_strdup_printf(
3717 "%s<input type='number' step='0.000001' name='%s' value='%s'>"
3722 else if (s
->type
== XT_S_BOOL
)
3723 *sa
->body
= g_strdup_printf(
3724 "%s<input type='hidden' name='%s' value='0'>"
3725 "<input type='checkbox' name='%s' value='1''%s>"
3730 atoi(val
) ? " checked='checked'" : "");
3732 *sa
->body
= g_strdup(*sa
->body
);
3733 warnx("Did not print setting %s", s
->name
);
3740 print_set_rejects(void)
3742 struct set_reject
*sr
, *st
;
3743 char *body
= NULL
, *tmp
;
3745 if (TAILQ_EMPTY(&srl
))
3748 body
= g_strdup_printf("The following settings were invalid and could "
3749 "not be set:<br><div align='center'><table id='settings'>"
3750 "<th align='left'>Setting</th>"
3751 "<th align='left'>Value</th>");
3752 TAILQ_FOREACH_SAFE(sr
, &srl
, entry
, st
) {
3754 body
= g_strdup_printf("%s\n<tr>"
3755 "<td style='width:240px'><div>%s</div></td>"
3756 "<td><div style='word-break:break-all'>%s</div></td></tr>",
3761 TAILQ_REMOVE(&srl
, sr
, entry
);
3767 body
= g_strdup_printf("%s</table></div><br>", body
);
3773 xtp_page_set(struct tab
*t
, struct karg
*args
)
3775 char *body
, *page
, *tmp
;
3777 struct settings_args sa
;
3779 bzero(&sa
, sizeof sa
);
3783 body
= g_strdup_printf("<div align='center'><table><tr>"
3784 "<th align='left'>Setting</th>"
3785 "<th align='left'>Value</th></tr>\n");
3787 settings_walk(print_setting
, &sa
);
3790 /* small message if there are none */
3793 body
= g_strdup_printf("%s\n<tr><td style='text-align:center'"
3794 "colspan='2'>No settings</td></tr>\n", body
);
3799 body
= g_strdup_printf("%s</table></div>", body
);
3802 page
= get_html_page("Settings", body
, "", 0);
3806 load_webkit_string(t
, page
, XT_URI_ABOUT_SET
, 0);
3810 return (XT_CB_PASSTHROUGH
);
3814 xtp_page_rt(struct tab
*t
, struct karg
*args
)
3816 char *body
= NULL
, *page
, *tmp
;
3818 struct settings_args sa
;
3820 generate_xtp_session_key(&t
->session_key
);
3822 bzero(&sa
, sizeof sa
);
3826 body
= print_set_rejects();
3829 body
= g_strdup_printf("%s<div align='center'>"
3830 "<form method='GET' action='%s%d/%s/%d'>"
3831 "<input type='submit' value='Save Settings'>"
3832 "<table id='settings'>"
3833 "<th align='left'>Setting</th>"
3834 "<th align='left'>Value</th>\n",
3842 settings_walk(print_runtime_setting
, &sa
);
3845 /* small message if there are none */
3848 body
= g_strdup_printf("%s\n<tr><td style='text-align:center'"
3849 "colspan='2'>No settings</td></tr>\n", body
);
3854 body
= g_strdup_printf("%s</table>"
3855 "<input type='submit' value='Save Settings'></form></div>", body
);
3858 page
= get_html_page("Runtime Settings", body
, "", 1);
3862 load_webkit_string(t
, page
, XT_URI_ABOUT_RUNTIME
, 0);
3866 return (XT_CB_PASSTHROUGH
);
3870 set(struct tab
*t
, struct karg
*args
)
3875 if (args
== NULL
|| args
->s
== NULL
)
3876 return (xtp_page_set(t
, args
));
3879 p
= g_strstrip(args
->s
);
3882 return (xtp_page_set(t
, args
));
3884 /* we got some sort of string */
3885 val
= g_strstr_len(p
, strlen(p
), "=");
3888 val
= g_strstrip(val
);
3891 for (i
= 0; i
< get_settings_size(); i
++) {
3892 if (strcmp(rs
[i
].name
, p
))
3895 if (rs
[i
].activate
) {
3896 if (rs
[i
].activate(val
))
3897 show_oops(t
, "%s invalid value %s",
3900 show_oops(t
, ":set %s = %s", p
, val
);
3903 show_oops(t
, "not a runtime option: %s", p
);
3907 show_oops(t
, "unknown option: %s", p
);
3911 for (i
= 0; i
< get_settings_size(); i
++) {
3912 if (strcmp(rs
[i
].name
, p
))
3915 /* XXX this could use some cleanup */
3916 switch (rs
[i
].type
) {
3917 case XT_S_INT
: /* FALLTHROUGH */
3920 show_oops(t
, "%s = %d",
3921 rs
[i
].name
, *rs
[i
].ival
);
3922 else if (rs
[i
].s
&& rs
[i
].s
->get
)
3923 show_oops(t
, "%s = %s",
3925 rs
[i
].s
->get(&rs
[i
]));
3926 else if (rs
[i
].s
&& rs
[i
].s
->get
== NULL
)
3927 show_oops(t
, "%s = ...", rs
[i
].name
);
3929 show_oops(t
, "%s = ", rs
[i
].name
);
3933 show_oops(t
, "%s = %f",
3934 rs
[i
].name
, *rs
[i
].fval
);
3935 else if (rs
[i
].s
&& rs
[i
].s
->get
)
3936 show_oops(t
, "%s = %s",
3938 rs
[i
].s
->get(&rs
[i
]));
3939 else if (rs
[i
].s
&& rs
[i
].s
->get
== NULL
)
3940 show_oops(t
, "%s = ...", rs
[i
].name
);
3942 show_oops(t
, "%s = ", rs
[i
].name
);
3945 if (rs
[i
].sval
&& *rs
[i
].sval
)
3946 show_oops(t
, "%s = %s",
3947 rs
[i
].name
, *rs
[i
].sval
);
3948 else if (rs
[i
].s
&& rs
[i
].s
->get
)
3949 show_oops(t
, "%s = %s",
3951 rs
[i
].s
->get(&rs
[i
]));
3952 else if (rs
[i
].s
&& rs
[i
].s
->get
== NULL
)
3953 show_oops(t
, "%s = ...", rs
[i
].name
);
3955 show_oops(t
, "%s = ", rs
[i
].name
);
3958 show_oops(t
, "unknown type for %s", rs
[i
].name
);
3964 show_oops(t
, "unknown option: %s", p
);
3967 return (XT_CB_PASSTHROUGH
);