forked from conformal/xombrero
-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings.c
4095 lines (3620 loc) · 99.7 KB
/
settings.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright (c) 2010, 2011 Marco Peereboom <[email protected]>
* Copyright (c) 2011 Stevan Andjelkovic <[email protected]>
* Copyright (c) 2010, 2011 Edd Barrett <[email protected]>
* Copyright (c) 2011 Todd T. Fries <[email protected]>
* Copyright (c) 2011 Raphael Graf <[email protected]>
* Copyright (c) 2011 Michal Mazurek <[email protected]>
* Copyright (c) 2012 Josh Rickmar <[email protected]>
* Copyright (c) 2013 David Hill <[email protected]>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <xombrero.h>
#include "tooltip.h"
/* globals */
#if SOUP_CHECK_VERSION(2, 42, 2)
GProxyResolver *proxy_uri = NULL;
gchar *proxy_exclude[] = { "fc00::/7", "::1", "127.0.0.1", NULL };
#else
SoupURI *proxy_uri = NULL;
#endif
PangoFontDescription *cmd_font;
PangoFontDescription *oops_font;
PangoFontDescription *statusbar_font;
PangoFontDescription *tabbar_font;
/* non-settings */
char search_file[PATH_MAX];
char command_file[PATH_MAX];
char runtime_settings[PATH_MAX]; /* override of settings */
/* settings that require restart */
int enable_socket = 0;
int single_instance = 0; /* only allow one xombrero to run */
int fancy_bar = 1; /* fancy toolbar */
int browser_mode = XT_BM_NORMAL;
int gui_mode = XT_GM_CLASSIC;
char *statusbar_elems = NULL;
int window_height = 768;
int window_width = 1024;
int window_maximize = 0;
int icon_size = 2; /* 1 = smallest, 2+ = bigger */
char *resource_dir = NULL;
char download_dir[PATH_MAX];
int allow_volatile_cookies = 0;
int save_global_history = 0; /* save global history to disk */
int save_rejected_cookies = 0;
gint max_connections = 25;
gint max_host_connections = 5;
int history_autosave = 0;
int edit_mode = XT_EM_HYBRID;
char *include_config = NULL;
int anonymize_headers = 0;
int tabless = 0; /* allow only 1 tab */
/* runtime settings */
int show_tabs = XT_DS_SHOW_TABS; /* show tabs on notebook */
int tab_style = XT_DS_TAB_STYLE; /* tab bar style */
int statusbar_style = XT_DS_STATUSBAR_STYLE; /* status bar style */
int show_url = XT_DS_SHOW_URL; /* show url toolbar on notebook */
int show_scrollbars = XT_DS_SHOW_SCROLLBARS;
int show_statusbar = XT_DS_SHOW_STATUSBAR; /* vimperator style status bar */
int ctrl_click_focus = XT_DS_CTRL_CLICK_FOCUS; /* ctrl click gets focus */
int cookies_enabled = XT_DS_COOKIES_ENABLED; /* enable cookies */
int read_only_cookies = XT_DS_READ_ONLY_COOKIES; /* enable to not write cookies */
int enable_scripts = XT_DS_ENABLE_SCRIPTS;
int enable_plugins = XT_DS_ENABLE_PLUGINS;
double default_zoom_level = XT_DS_DEFAULT_ZOOM_LEVEL;
char default_script[PATH_MAX]; /* special setting - is never g_free'd */
int refresh_interval = XT_DS_REFRESH_INTERVAL; /* download refresh interval */
int enable_plugin_whitelist = XT_DS_ENABLE_PLUGIN_WHITELIST;
int enable_cookie_whitelist = XT_DS_ENABLE_COOKIE_WHITELIST;
int enable_js_whitelist = XT_DS_ENABLE_JS_WHITELIST;
int enable_localstorage = XT_DS_ENABLE_LOCALSTORAGE;
int session_timeout = XT_DS_SESSION_TIMEOUT; /* cookie session timeout */
int cookie_policy = XT_DS_COOKIE_POLICY;
char ssl_ca_file[PATH_MAX]; /* special setting - is never g_free'd */
gboolean ssl_strict_certs = XT_DS_SSL_STRICT_CERTS;
gboolean enable_strict_transport = XT_DS_ENABLE_STRICT_TRANSPORT;
int append_next = XT_DS_APPEND_NEXT; /* append tab after current tab */
char *home = NULL; /* allocated/set at startup */
char *search_string = NULL; /* allocated/set at startup */
char *http_proxy = NULL;
int http_proxy_starts_enabled = 1;
int download_mode = XT_DM_START;
int color_visited_uris = XT_DS_COLOR_VISITED_URIS;
int session_autosave = XT_DS_SESSION_AUTOSAVE;
int guess_search = XT_DS_GUESS_SEARCH;
gint enable_spell_checking = XT_DS_ENABLE_SPELL_CHECKING;
char *spell_check_languages = NULL; /* allocated/set at startup */
char *url_regex = NULL; /* allocated/set at startup */
char *encoding = NULL; /* allocated/set at startup */
int autofocus_onload = XT_DS_AUTOFOCUS_ONLOAD;
int enable_js_autorun = XT_DS_ENABLE_JS_AUTORUN;
char *userstyle = NULL; /* allocated/set at startup */
int userstyle_global = XT_DS_USERSTYLE_GLOBAL;
int auto_load_images = XT_DS_AUTO_LOAD_IMAGES;
int enable_autoscroll = XT_DS_ENABLE_AUTOSCROLL;
int enable_cache = 0;
int enable_favicon_entry = XT_DS_ENABLE_FAVICON_ENTRY;
int enable_favicon_tabs = XT_DS_ENABLE_FAVICON_TABS;
char *external_editor = NULL;
int referer_mode = XT_DS_REFERER_MODE;
char *referer_custom = NULL;
int download_notifications = XT_DS_DOWNLOAD_NOTIFICATIONS;
int warn_cert_changes = 0;
int allow_insecure_content = XT_DS_ALLOW_INSECURE_CONTENT;
int allow_insecure_scripts = XT_DS_ALLOW_INSECURE_SCRIPTS;
int do_not_track = XT_DS_DO_NOT_TRACK;
int preload_strict_transport = XT_DS_PRELOAD_STRICT_TRANSPORT;
char *gnutls_priority_string = XT_DS_GNUTLS_PRIORITY_STRING;
int js_auto_open_windows = XT_DS_JS_AUTO_OPEN_WINDOWS;
char *cmd_font_name = NULL; /* these are all set at startup */
char *oops_font_name = NULL;
char *statusbar_font_name = NULL;
char *tabbar_font_name = NULL;
char *get_download_dir(struct settings *);
char *get_default_script(struct settings *);
char *get_runtime_dir(struct settings *);
char *get_tab_style(struct settings *);
char *get_statusbar_style(struct settings *);
char *get_edit_mode(struct settings *);
char *get_download_mode(struct settings *);
char *get_work_dir(struct settings *);
char *get_referer(struct settings *);
char *get_ssl_ca_file(struct settings *);
char *get_userstyle(struct settings *);
char *get_gnutls_priority_string(struct settings *);
int add_cookie_wl(struct settings *, char *);
int add_js_wl(struct settings *, char *);
int add_pl_wl(struct settings *, char *);
int add_mime_type(struct settings *, char *);
int add_alias(struct settings *, char *);
int add_kb(struct settings *, char *);
int add_ua(struct settings *, char *);
int add_http_accept(struct settings *, char *);
int add_cmd_alias(struct settings *, char *);
int add_custom_uri(struct settings *, char *);
int add_force_https(struct settings *, char *);
int set_append_next(char *);
int set_autofocus_onload(char *);
int set_cmd_font(char *);
int set_color_visited_uris(char *);
int set_cookie_policy_rt(char *);
int set_cookies_enabled(char *);
int set_ctrl_click_focus(char *);
int set_fancy_bar(char *);
int set_home(char *);
int set_download_dir(struct settings *, char *);
int set_download_notifications(char *);
int set_default_script(struct settings *, char *);
int set_default_script_rt(char *);
int set_default_zoom_level(char *);
int set_enable_cookie_whitelist(char *);
int set_enable_js_autorun(char *);
int set_enable_js_whitelist(char *);
int set_enable_localstorage(char *);
int set_enable_plugins(char *);
int set_enable_plugin_whitelist(char *);
int set_enable_scripts(char *);
int set_enable_spell_checking(char *);
int set_enable_strict_transport(char *);
int set_encoding_rt(char *);
int set_runtime_dir(struct settings *, char *);
int set_tabbar_font(char *value);
int set_tab_style(struct settings *, char *);
int set_tab_style_rt(char *);
int set_statusbar_style(struct settings *, char *);
int set_statusbar_style_rt(char *);
int set_edit_mode(struct settings *, char *);
int set_work_dir(struct settings *, char *);
int set_auto_load_images(char *);
int set_enable_autoscroll(char *);
int set_enable_cache(char *);
int set_enable_favicon_entry(char *);
int set_enable_favicon_tabs(char *);
int set_guess_search(char *);
int set_download_mode(struct settings *, char *);
int set_download_mode_rt(char *);
int set_js_auto_open_windows(char *);
int set_oops_font(char *);
int set_read_only_cookies(char *);
int set_referer(struct settings *, char *);
int set_referer_rt(char *);
int set_refresh_interval(char *);
int set_search_string(char *s);
int set_session_autosave(char *);
int set_session_timeout(char *);
int set_show_scrollbars(char *);
int set_show_statusbar(char *);
int set_show_tabs(char *);
int set_show_url(char *);
int set_spell_check_languages(char *);
int set_ssl_ca_file_rt(char *);
int set_ssl_strict_certs(char *);
int set_statusbar_font(char *);
int set_url_regex(char *);
int set_userstyle(struct settings *, char *);
int set_userstyle_rt(char *);
int set_userstyle_global(char *);
int set_external_editor(char *);
int set_warn_cert_changes(char *);
int set_allow_insecure_content(char *);
int set_allow_insecure_scripts(char *);
int set_http_proxy(char *);
int set_do_not_track(char *);
int set_gnutls_priority_string(struct settings *, char *);
int check_allow_insecure_content(char **);
int check_allow_insecure_scripts(char **);
int check_allow_volatile_cookies(char **);
int check_anonymize_headers(char **);
int check_append_next(char **);
int check_auto_load_images(char **);
int check_autofocus_onload(char **);
int check_browser_mode(char **);
int check_cmd_font(char **);
int check_color_visited_uris(char **);
int check_cookie_policy(char **);
int check_cookies_enabled(char **);
int check_ctrl_click_focus(char **);
int check_default_script(char **);
int check_default_zoom_level(char **);
int check_download_dir(char **);
int check_download_mode(char **);
int check_download_notifications(char **);
int check_edit_mode(char **);
int check_enable_autoscroll(char **);
int check_enable_cache(char **);
int check_enable_cookie_whitelist(char **);
int check_enable_favicon_entry(char **);
int check_enable_favicon_tabs(char **);
int check_enable_js_autorun(char **);
int check_enable_js_whitelist(char **);
int check_enable_localstorage(char **);
int check_enable_plugin_whitelist(char **);
int check_enable_plugins(char **);
int check_enable_scripts(char **);
int check_enable_socket(char **);
int check_enable_spell_checking(char **);
int check_enable_strict_transport(char **);
int check_encoding(char **);
int check_external_editor(char **);
int check_fancy_bar(char **);
int check_gnutls_search_string(char **);
int check_guess_search(char **);
int check_gui_mode(char **);
int check_history_autosave(char **);
int check_home(char **);
int check_http_proxy(char **);
int check_http_proxy_scheme(const char *);
int check_http_proxy_starts_enabled(char **);
int check_icon_size(char **);
int check_js_auto_open_windows(char **);
int check_max_connections(char **);
int check_max_host_connections(char **);
int check_oops_font(char **);
int check_read_only_cookies(char **);
int check_referer(char **);
int check_refresh_interval(char **);
int check_resource_dir(char **);
int check_save_global_history(char **);
int check_save_rejected_cookies(char **);
int check_search_string(char **);
int check_session_autosave(char **);
int check_session_timeout(char **);
int check_show_scrollbars(char **);
int check_show_statusbar(char **);
int check_show_tabs(char **);
int check_show_url(char **);
int check_single_instance(char **);
int check_spell_check_languages(char **);
int check_ssl_ca_file(char **);
int check_ssl_strict_certs(char **);
int check_statusbar_elems(char **);
int check_statusbar_font(char **);
int check_statusbar_style(char **);
int check_tab_style(char **);
int check_tabless(char **);
int check_tabbar_font(char **);
int check_url_regex(char **);
int check_userstyle(char **);
int check_userstyle_global(char **);
int check_warn_cert_changes(char **);
int check_window_height(char **);
int check_window_maximize(char **);
int check_window_width(char **);
int check_work_dir(char **);
int check_do_not_track(char **);
void walk_mime_type(struct settings *, void (*)(struct settings *,
char *, void *), void *);
void walk_alias(struct settings *, void (*)(struct settings *,
char *, void *), void *);
void walk_cookie_wl(struct settings *, void (*)(struct settings *,
char *, void *), void *);
void walk_js_wl(struct settings *, void (*)(struct settings *,
char *, void *), void *);
void walk_pl_wl(struct settings *, void (*)(struct settings *,
char *, void *), void *);
void walk_kb(struct settings *, void (*)(struct settings *, char *,
void *), void *);
void walk_ua(struct settings *, void (*)(struct settings *, char *,
void *), void *);
void walk_http_accept(struct settings *, void (*)(struct settings *,
char *, void *), void *);
void walk_cmd_alias(struct settings *, void (*)(struct settings *,
char *, void *), void *);
void walk_custom_uri(struct settings *, void (*)(struct settings *,
char *, void *), void *);
void walk_force_https(struct settings *, void (*)(struct settings *,
char *, void *), void *);
struct special s_browser_mode = {
set_browser_mode,
get_browser_mode,
NULL,
{ "kiosk", "normal", "whitelist", NULL }
};
struct special s_gui_mode = {
set_gui_mode,
get_gui_mode,
NULL,
{ "classic", "minimal", NULL }
};
struct special s_cookie = {
set_cookie_policy,
get_cookie_policy,
NULL,
{ "accept", "no3rdparty", "reject", NULL }
};
struct special s_alias = {
add_alias,
NULL,
walk_alias,
{ NULL }
};
struct special s_cmd_alias = {
add_cmd_alias,
NULL,
walk_cmd_alias,
{ NULL }
};
struct special s_mime = {
add_mime_type,
NULL,
walk_mime_type,
{ NULL }
};
struct special s_js = {
add_js_wl,
NULL,
walk_js_wl,
{ NULL }
};
struct special s_pl = {
add_pl_wl,
NULL,
walk_pl_wl,
{ NULL }
};
struct special s_kb = {
add_kb,
NULL,
walk_kb,
{ NULL }
};
struct special s_cookie_wl = {
add_cookie_wl,
NULL,
walk_cookie_wl,
{ NULL }
};
struct special s_uri = {
add_custom_uri,
NULL,
walk_custom_uri,
{ NULL }
};
struct special s_default_script = {
set_default_script,
get_default_script,
NULL,
{ NULL }
};
struct special s_ssl_ca_file = {
set_ssl_ca_file,
get_ssl_ca_file,
NULL,
{ NULL }
};
struct special s_download_dir = {
set_download_dir,
get_download_dir,
NULL,
{ NULL }
};
struct special s_work_dir = {
set_work_dir,
get_work_dir,
NULL,
{ NULL }
};
struct special s_tab_style = {
set_tab_style,
get_tab_style,
NULL,
{ "compact", "normal", NULL }
};
struct special s_statusbar_style = {
set_statusbar_style,
get_statusbar_style,
NULL,
{ "title", "url", NULL }
};
struct special s_edit_mode = {
set_edit_mode,
get_edit_mode,
NULL,
{ "hybrid", "vi", NULL }
};
struct special s_download_mode = {
set_download_mode,
get_download_mode,
NULL,
{ "add", "ask", "start", NULL }
};
struct special s_ua = {
add_ua,
NULL,
walk_ua,
{ NULL }
};
struct special s_http_accept = {
add_http_accept,
NULL,
walk_http_accept,
{ NULL }
};
struct special s_referer = {
set_referer,
get_referer,
NULL,
{ "always", "never", "same-domain", "same-fqdn", NULL }
};
struct special s_userstyle = {
set_userstyle,
get_userstyle,
NULL,
{ NULL }
};
struct special s_force_https = {
add_force_https,
NULL,
walk_force_https,
{ NULL }
};
struct special s_gnutls_priority_string = {
set_gnutls_priority_string,
get_gnutls_priority_string,
NULL,
{ NULL }
};
struct settings rs[] = {
{ "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 },
{ "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},
{ "allow_volatile_cookies", XT_S_BOOL, 0, &allow_volatile_cookies, NULL, NULL, NULL, NULL, check_allow_volatile_cookies, TT_ALLOW_VOLATILE_COOKIES },
{ "anonymize_headers", XT_S_BOOL, 0, &anonymize_headers, NULL, NULL, NULL, NULL, check_anonymize_headers, TT_ANONYMIZE_HEADERS },
{ "append_next", XT_S_BOOL, 0, &append_next, NULL, NULL, NULL, set_append_next, check_append_next, TT_APPEND_NEXT },
{ "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 },
{ "autofocus_onload", XT_S_BOOL, 0, &autofocus_onload, NULL, NULL, NULL, set_autofocus_onload, check_autofocus_onload, TT_AUTOFOCUS_ONLOAD },
{ "browser_mode", XT_S_STR, 0, NULL, NULL,&s_browser_mode, NULL, NULL, check_browser_mode, TT_BROWSER_MODE },
{ "cmd_font", XT_S_STR, 0, NULL, &cmd_font_name, NULL, NULL, set_cmd_font, check_cmd_font, TT_CMD_FONT },
{ "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 },
{ "cookie_policy", XT_S_STR, 0, NULL, NULL,&s_cookie, NULL, set_cookie_policy_rt, check_cookie_policy, TT_COOKIE_POLICY },
{ "cookies_enabled", XT_S_BOOL, 0, &cookies_enabled, NULL, NULL, NULL, set_cookies_enabled, check_cookies_enabled, TT_COOKIES_ENABLED },
{ "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 },
{ "default_script", XT_S_STR, 1, NULL, NULL,&s_default_script, NULL, set_default_script_rt, check_default_script, TT_DEFAULT_SCRIPT },
{ "default_zoom_level", XT_S_DOUBLE, 0, NULL, NULL, NULL, &default_zoom_level, set_default_zoom_level, check_default_zoom_level, TT_DEFAULT_ZOOM_LEVEL },
{ "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 },
{ "download_dir", XT_S_STR, 0, NULL, NULL,&s_download_dir, NULL, NULL, check_download_dir, TT_DOWNLOAD_DIR },
{ "download_mode", XT_S_STR, 0, NULL, NULL,&s_download_mode, NULL, set_download_mode_rt, check_download_mode, TT_DOWNLOAD_MODE },
{ "download_notifications", XT_S_BOOL, 0, &download_notifications, NULL, NULL, NULL, set_download_notifications, check_download_notifications, TT_DOWNLOAD_NOTIFICATIONS },
{ "edit_mode", XT_S_STR, 0, NULL, NULL,&s_edit_mode, NULL, NULL, check_edit_mode, NULL },
{ "enable_autoscroll", XT_S_BOOL, 0, &enable_autoscroll, NULL, NULL, NULL, set_enable_autoscroll, check_enable_autoscroll, TT_ENABLE_AUTOSCROLL },
{ "enable_cache", XT_S_BOOL, 0, &enable_cache, NULL, NULL, NULL, set_enable_cache, check_enable_cache, TT_ENABLE_CACHE },
{ "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 },
{ "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 },
{ "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 },
{ "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 },
{ "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 },
{ "enable_localstorage", XT_S_BOOL, 0, &enable_localstorage, NULL, NULL, NULL, set_enable_localstorage, check_enable_localstorage, TT_ENABLE_LOCALSTORAGE },
{ "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 },
{ "enable_plugins", XT_S_BOOL, 0, &enable_plugins, NULL, NULL, NULL, set_enable_plugins, check_enable_plugins, TT_ENABLE_PLUGINS },
{ "enable_scripts", XT_S_BOOL, 0, &enable_scripts, NULL, NULL, NULL, set_enable_scripts, check_enable_scripts, TT_ENABLE_SCRIPTS },
{ "enable_socket", XT_S_BOOL,XT_SF_RESTART,&enable_socket, NULL, NULL, NULL, NULL, check_enable_socket, TT_ENABLE_SOCKET },
{ "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 },
{ "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 },
{ "encoding", XT_S_STR, 0, NULL, &encoding, NULL, NULL, NULL, check_encoding, TT_ENCODING },
{ "external_editor", XT_S_STR,0, NULL, &external_editor, NULL, NULL, set_external_editor, check_external_editor, TT_EXTERNAL_EDITOR },
{ "fancy_bar", XT_S_BOOL,XT_SF_RESTART,&fancy_bar, NULL, NULL, NULL, set_fancy_bar, check_fancy_bar, TT_FANCY_BAR },
{ "gnutls_priority_string", XT_S_STR, 0, NULL, NULL,&s_gnutls_priority_string, NULL, NULL, check_gnutls_search_string, TT_GNUTLS_PRIORITY_STRING },
{ "guess_search", XT_S_BOOL, 0, &guess_search, NULL, NULL, NULL, set_guess_search, check_guess_search, TT_GUESS_SEARCH },
{ "gui_mode", XT_S_STR, 0, NULL, NULL,&s_gui_mode, NULL, NULL, check_gui_mode, TT_GUI_MODE },
{ "history_autosave", XT_S_BOOL, 0, &history_autosave, NULL, NULL, NULL, NULL, check_history_autosave, TT_HISTORY_AUTOSAVE },
{ "home", XT_S_STR, 0, NULL, &home, NULL, NULL, set_home, check_home, TT_HOME },
{ "http_proxy", XT_S_STR, 0, NULL, &http_proxy, NULL, NULL, set_http_proxy, check_http_proxy, TT_HTTP_PROXY },
{ "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 },
{ "icon_size", XT_S_INT, 0, &icon_size, NULL, NULL, NULL, NULL, check_icon_size, TT_ICON_SIZE },
{ "include_config", XT_S_STR, XT_SF_INVISIBLE, NULL, &include_config, NULL, NULL, NULL, NULL },
{ "js_auto_open_windows", XT_S_BOOL, 1, &js_auto_open_windows, NULL, NULL, NULL, set_js_auto_open_windows, check_js_auto_open_windows, TT_JS_AUTO_OPEN_WINDOWS },
{ "max_connections", XT_S_INT, XT_SF_RESTART,&max_connections, NULL, NULL, NULL, NULL, check_max_connections, TT_MAX_CONNECTIONS },
{ "max_host_connections", XT_S_INT, XT_SF_RESTART,&max_host_connections, NULL, NULL, NULL, NULL, check_max_host_connections, TT_MAX_HOST_CONNECTIONS },
{ "oops_font", XT_S_STR, 0, NULL, &oops_font_name, NULL, NULL, set_oops_font, check_oops_font, TT_OOPS_FONT },
{ "preload_strict_transport", XT_S_BOOL, 0, &preload_strict_transport, NULL, NULL, NULL, NULL, NULL, TT_PRELOAD_STRICT_TRANSPORT },
{ "read_only_cookies", XT_S_BOOL, 0, &read_only_cookies, NULL, NULL, NULL, NULL, check_read_only_cookies, TT_READ_ONLY_COOKIES },
{ "referer", XT_S_STR, 0, NULL, NULL,&s_referer, NULL, set_referer_rt, check_referer, TT_REFERER },
{ "refresh_interval", XT_S_INT, 0, &refresh_interval, NULL, NULL, NULL, set_refresh_interval, check_refresh_interval, TT_REFRESH_INTERVAL },
{ "resource_dir", XT_S_STR, 0, NULL, &resource_dir, NULL, NULL, NULL, check_resource_dir, TT_RESOURCE_DIR },
{ "save_global_history", XT_S_BOOL,XT_SF_RESTART,&save_global_history, NULL, NULL, NULL, NULL, check_save_global_history, TT_SAVE_GLOBAL_HISTORY },
{ "save_rejected_cookies", XT_S_BOOL,XT_SF_RESTART,&save_rejected_cookies, NULL, NULL, NULL, NULL, check_save_rejected_cookies, TT_SAVE_REJECTED_COOKIES },
{ "search_string", XT_S_STR, 0, NULL, &search_string, NULL, NULL, set_search_string, check_search_string, TT_SEARCH_STRING },
{ "session_autosave", XT_S_BOOL, 0, &session_autosave, NULL, NULL, NULL, set_session_autosave, check_session_autosave, TT_SESSION_AUTOSAVE },
{ "session_timeout", XT_S_INT, 0, &session_timeout, NULL, NULL, NULL, set_session_timeout, check_session_timeout, TT_SESSION_TIMEOUT },
{ "show_scrollbars", XT_S_BOOL, 0, &show_scrollbars, NULL, NULL, NULL, set_show_scrollbars, check_show_scrollbars, TT_SHOW_SCROLLBARS },
{ "show_statusbar", XT_S_BOOL, 0, &show_statusbar, NULL, NULL, NULL, set_show_statusbar, check_show_statusbar, TT_SHOW_STATUSBAR },
{ "show_tabs", XT_S_BOOL, 0, &show_tabs, NULL, NULL, NULL, set_show_tabs, check_show_tabs, TT_SHOW_TABS },
{ "show_url", XT_S_BOOL, 0, &show_url, NULL, NULL, NULL, set_show_url, check_show_url, TT_SHOW_URL },
{ "single_instance", XT_S_BOOL,XT_SF_RESTART,&single_instance, NULL, NULL, NULL, NULL, check_single_instance, TT_SINGLE_INSTANCE },
{ "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 },
{ "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 },
{ "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 },
{ "statusbar_elems", XT_S_STR, 0, NULL, &statusbar_elems, NULL, NULL, NULL, check_statusbar_elems, TT_STATUSBAR_ELEMS },
{ "statusbar_font", XT_S_STR, 0, NULL, &statusbar_font_name, NULL, NULL, set_statusbar_font, check_statusbar_font, TT_STATUSBAR_FONT },
{ "statusbar_style", XT_S_STR, 0, NULL, NULL,&s_statusbar_style, NULL, set_statusbar_style_rt, check_statusbar_style, TT_STATUSBAR_STYLE },
{ "tab_style", XT_S_STR, 0, NULL, NULL,&s_tab_style, NULL, set_tab_style_rt, check_tab_style, TT_TAB_STYLE },
{ "tabbar_font", XT_S_STR, 0, NULL, &tabbar_font_name, NULL, NULL, set_tabbar_font, check_tabbar_font, TT_TABBAR_FONT },
{ "tabless", XT_S_BOOL, 0, &tabless, NULL, NULL, NULL, NULL, check_tabless, TT_TABLESS },
{ "url_regex", XT_S_STR, 0, NULL, &url_regex, NULL, NULL, set_url_regex, check_url_regex, TT_URL_REGEX },
{ "userstyle", XT_S_STR, 0, NULL, NULL,&s_userstyle, NULL, set_userstyle_rt, check_userstyle, TT_USERSTYLE },
{ "userstyle_global", XT_S_BOOL, 0, &userstyle_global, NULL, NULL, NULL, set_userstyle_global, check_userstyle_global, TT_USERSTYLE_GLOBAL },
{ "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 },
{ "window_height", XT_S_INT, 0, &window_height, NULL, NULL, NULL, NULL, check_window_height, TT_WINDOW_HEIGHT },
{ "window_maximize", XT_S_BOOL, 0, &window_maximize, NULL, NULL, NULL, NULL, check_window_maximize, TT_WINDOW_MAXIMIZE },
{ "window_width", XT_S_INT, 0, &window_width, NULL, NULL, NULL, NULL, check_window_width, TT_WINDOW_WIDTH },
{ "work_dir", XT_S_STR, 0, NULL, NULL,&s_work_dir, NULL, NULL, check_work_dir, TT_WORK_DIR },
/* special settings */
{ "alias", XT_S_STR, XT_SF_RUNTIME, NULL, NULL, &s_alias, NULL, NULL },
{ "cmd_alias", XT_S_STR, XT_SF_RUNTIME, NULL, NULL, &s_cmd_alias, NULL, NULL },
{ "cookie_wl", XT_S_STR, XT_SF_RUNTIME, NULL, NULL, &s_cookie_wl, NULL, NULL },
{ "custom_uri", XT_S_STR, XT_SF_RUNTIME, NULL, NULL, &s_uri, NULL, NULL },
{ "force_https", XT_S_STR, XT_SF_RUNTIME, NULL, NULL, &s_force_https, NULL, NULL },
{ "http_accept", XT_S_STR, XT_SF_RUNTIME, NULL, NULL, &s_http_accept, NULL, NULL },
{ "js_wl", XT_S_STR, XT_SF_RUNTIME, NULL, NULL, &s_js, NULL, NULL },
{ "keybinding", XT_S_STR, XT_SF_RUNTIME, NULL, NULL, &s_kb, NULL, NULL },
{ "mime_type", XT_S_STR, XT_SF_RUNTIME, NULL, NULL, &s_mime, NULL, NULL },
{ "pl_wl", XT_S_STR, XT_SF_RUNTIME, NULL, NULL, &s_pl, NULL, NULL },
{ "user_agent", XT_S_STR, XT_SF_RUNTIME, NULL, NULL, &s_ua, NULL, NULL },
};
int
set_http_proxy(char *proxy)
{
char *tmpproxy = proxy;
/* see if we need to clear it */
if (proxy == NULL || strlen(proxy) == 0)
tmpproxy = NULL;
if (check_http_proxy_scheme(proxy) == 0)
tmpproxy = NULL;
return (setup_proxy(tmpproxy));
}
int
check_http_proxy(char **tt)
{
*tt = g_strdup("Default: (empty)");
return (g_strcmp0(http_proxy, NULL));
}
int
check_http_proxy_scheme(const char *uri)
{
int rv = 0;
char *scheme;
if (!uri)
return (0);
scheme = g_uri_parse_scheme(uri);
if (!scheme)
return (0);
#if SOUP_CHECK_VERSION(2, 42, 2)
if (strcmp(scheme, "socks5") == 0 || strcmp(scheme, "socks4a") == 0 ||
strcmp(scheme, "socks4") == 0 || strcmp(scheme, "socks") == 0 ||
strcmp(scheme, "http") == 0) {
rv = 1;
}
#else
if (strcmp(scheme, "http") == 0) {
rv = 1;
}
#endif
free(scheme);
return (rv);
}
int
check_http_proxy_starts_enabled(char **tt)
{
*tt = g_strdup("Default: Enabled");
return (http_proxy_starts_enabled != 1);
}
int
check_icon_size(char **tt)
{
*tt = g_strdup_printf("Default: %d", 2);
return (icon_size != 2);
}
int
check_max_connections(char **tt)
{
*tt = g_strdup_printf("Default: %d", 25);
return (max_connections != 25);
}
int
check_max_host_connections(char **tt)
{
*tt = g_strdup_printf("Default: %d", 5);
return (max_host_connections != 5);
}
int
set_default_zoom_level(char *value)
{
struct karg args = {0};
struct tab *t;
if (value == NULL || strlen(value) == 0)
default_zoom_level = XT_DS_DEFAULT_ZOOM_LEVEL;
else
default_zoom_level = g_strtod(value, NULL);
args.i = 100; /* adjust = 100 percent for no additional adjustment */
TAILQ_FOREACH(t, &tabs, entry)
resizetab(t, &args);
return (0);
}
int
check_default_zoom_level(char **tt)
{
*tt = g_strdup_printf("Default: %f", XT_DS_DEFAULT_ZOOM_LEVEL);
return (default_zoom_level < (XT_DS_DEFAULT_ZOOM_LEVEL - 0.0001) ||
default_zoom_level > (XT_DS_DEFAULT_ZOOM_LEVEL + 0.0001));
}
int
set_cookies_enabled(char *value)
{
int tmp;
const char *errstr;
if (value == NULL || strlen(value) == 0)
cookies_enabled = XT_DS_COOKIES_ENABLED;
else {
tmp = strtonum(value, 0, 1, &errstr);
if (errstr)
return (-1);
cookies_enabled = tmp;
}
return (0);
}
int
check_cookies_enabled(char **tt)
{
*tt = g_strdup_printf("Default: %s",
XT_DS_COOKIES_ENABLED ? "Enabled" : "Disabled");
return (cookies_enabled != XT_DS_COOKIES_ENABLED);
}
int
set_append_next(char *value)
{
int tmp;
const char *errstr;
if (value == NULL || strlen(value) == 0)
append_next = XT_DS_APPEND_NEXT;
else {
tmp = strtonum(value, 0, 1, &errstr);
if (errstr)
return (-1);
append_next = tmp;
}
return (0);
}
int
check_append_next(char **tt)
{
*tt = g_strdup_printf("Default: %s",
XT_DS_APPEND_NEXT ? "Enabled" : "Disabled");
return (append_next != XT_DS_APPEND_NEXT);
}
int
set_cmd_font(char *value)
{
struct tab *t;
if (cmd_font_name)
g_free(cmd_font_name);
if (cmd_font)
pango_font_description_free(cmd_font);
if (value == NULL || strlen(value) == 0)
cmd_font_name = g_strdup(XT_DS_CMD_FONT_NAME);
else
cmd_font_name = g_strdup(value);
cmd_font = pango_font_description_from_string(cmd_font_name);
TAILQ_FOREACH(t, &tabs, entry)
modify_font(GTK_WIDGET(t->cmd), cmd_font);
return (0);
}
int
check_cmd_font(char **tt)
{
*tt = g_strdup_printf("Default: %s", XT_DS_CMD_FONT_NAME);
return (g_strcmp0(cmd_font_name, XT_DS_CMD_FONT_NAME));
}
int
set_oops_font(char *value)
{
struct tab *t;
if (oops_font_name)
g_free(oops_font_name);
if (oops_font)
pango_font_description_free(oops_font);
if (value == NULL || strlen(value) == 0)
cmd_font_name = g_strdup(XT_DS_OOPS_FONT_NAME);
else
oops_font_name = g_strdup(value);
oops_font = pango_font_description_from_string(oops_font_name);
TAILQ_FOREACH(t, &tabs, entry)
modify_font(GTK_WIDGET(t->oops), oops_font);
return (0);
}
int
check_oops_font(char **tt)
{
*tt = g_strdup_printf("Default: %s", XT_DS_OOPS_FONT_NAME);
return (g_strcmp0(oops_font_name, XT_DS_OOPS_FONT_NAME));
}
int
check_read_only_cookies(char **tt)
{
*tt = g_strdup_printf("Default: %s",
XT_DS_READ_ONLY_COOKIES ? "Enabled" : "Disabled");
return (read_only_cookies != XT_DS_READ_ONLY_COOKIES);
}
int
set_statusbar_font(char *value)
{
struct tab *t;
if (statusbar_font_name)
g_free(statusbar_font_name);
if (statusbar_font)
pango_font_description_free(statusbar_font);
if (value == NULL || strlen(value) == 0)
statusbar_font_name = g_strdup(XT_DS_STATUSBAR_FONT_NAME);
else
statusbar_font_name = g_strdup(value);
statusbar_font = pango_font_description_from_string(
statusbar_font_name);
TAILQ_FOREACH(t, &tabs, entry) {
modify_font(GTK_WIDGET(t->sbe.uri),
statusbar_font);
if (t->sbe.buffercmd != NULL)
modify_font(GTK_WIDGET(t->sbe.buffercmd),
statusbar_font);
if (t->sbe.zoom != NULL)
modify_font(GTK_WIDGET(t->sbe.zoom),
statusbar_font);
if (t->sbe.position != NULL)
modify_font(GTK_WIDGET(t->sbe.position),
statusbar_font);
if (t->sbe.proxy != NULL)
modify_font(GTK_WIDGET(t->sbe.proxy),
statusbar_font);
}
return (0);
}
int
check_statusbar_font(char **tt)
{
*tt = g_strdup_printf("Default: %s", XT_DS_STATUSBAR_FONT_NAME);
return (g_strcmp0(statusbar_font_name, XT_DS_STATUSBAR_FONT_NAME));
}
int
set_tabbar_font(char *value)
{
struct tab *t;
if (tabbar_font_name)
g_free(tabbar_font_name);
if (tabbar_font)
pango_font_description_free(tabbar_font);
if (value == NULL || strlen(value) == 0)
tabbar_font_name = g_strdup(XT_DS_TABBAR_FONT_NAME);
else
tabbar_font_name = g_strdup(value);
tabbar_font = pango_font_description_from_string(tabbar_font_name);
TAILQ_FOREACH(t, &tabs, entry)
modify_font(GTK_WIDGET(t->tab_elems.label),
tabbar_font);
return (0);
}
int
check_tabbar_font(char **tt)
{
*tt = g_strdup_printf("Default: %s", XT_DS_TABBAR_FONT_NAME);
return (g_strcmp0(tabbar_font_name, XT_DS_TABBAR_FONT_NAME));
}
int
check_tabless(char **tt)
{
*tt = g_strdup_printf("Default: Disabled\n");
return (tabless != 0);
}
int
set_color_visited_uris(char *value)
{
int tmp;
const char *errstr;
if (value == NULL || strlen(value) == 0)
color_visited_uris = XT_DS_COLOR_VISITED_URIS;
else {
tmp = strtonum(value, 0, 1, &errstr);
if (errstr)
return (-1);
color_visited_uris = tmp;
}
return (0);
}
int
check_color_visited_uris(char **tt)
{
*tt = g_strdup_printf("Default: %s",
XT_DS_COLOR_VISITED_URIS ? "Enabled" : "Disabled");
return (color_visited_uris != XT_DS_COLOR_VISITED_URIS);
}
int
set_home(char *value)
{
if (home)
g_free(home);
if (value == NULL || strlen(value) == 0)
home = g_strdup(XT_DS_HOME);
else
home = g_strdup(value);
return (0);
}
int
check_home(char **tt)
{
*tt = g_strdup_printf("Default: %s", XT_DS_HOME);
return (g_strcmp0(home, XT_DS_HOME));
}
int
set_search_string(char *value)
{
struct tab *t;
if (search_string)
g_free(search_string);
if (value == NULL || strlen(value) == 0) {
search_string = NULL;
TAILQ_FOREACH(t, &tabs, entry)
gtk_widget_hide(t->search_entry);
} else {
search_string = g_strdup(value);
TAILQ_FOREACH(t, &tabs, entry)
gtk_widget_show(t->search_entry);
}
return (0);
}
int
check_search_string(char **tt)
{
*tt = g_strdup_printf("Default: %s", XT_DS_SEARCH_STRING);
return (g_strcmp0(search_string, XT_DS_SEARCH_STRING));
}
size_t
get_settings_size(void)
{
return (LENGTH(rs));
}
char *
get_setting_name(int i)
{
if (i > LENGTH(rs))
return (NULL);
return (rs[i].name);
}
char *
get_as_string(struct settings *s)
{
char *r = NULL;
if (s == NULL)
return (NULL);
if (s->s && s->s->get)
r = s->s->get(s);
else if (s->type == XT_S_INT)
r = g_strdup_printf("%d", *s->ival);
else if (s->type == XT_S_STR)
r = g_strdup(*s->sval);
else if (s->type == XT_S_DOUBLE)
r = g_strdup_printf("%lf", *s->dval);
else if (s->type == XT_S_BOOL)
r = g_strdup_printf("%d", *s->ival);
else
r = g_strdup_printf("INVALID TYPE");
return (r);
}
void
settings_walk(void (*cb)(struct settings *, char *, void *), void *cb_args)
{