use a define for js_auto_open_windows setting
[xombrero.git] / xombrero.h
blob777b3d39447a9c294946fc4e1c5c4f724e1d1f31
1 /*
2 * Copyright (c) 2011 Conformal Systems LLC <info@conformal.com>
3 * Copyright (c) 2011 Marco Peereboom <marco@peereboom.us>
4 * Copyright (c) 2010, 2011, 2012 Edd Barrett <vext01@gmail.com>
5 * Copyright (c) 2012, 2013 Josh Rickmar <jrick@devio.us>
7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20 #include <ctype.h>
21 #include <dlfcn.h>
22 #include <err.h>
23 #include <errno.h>
24 #include <libgen.h>
25 #include <pwd.h>
26 #include <regex.h>
27 #include <stdio.h>
28 #include <stdlib.h>
29 #include <string.h>
30 #include <unistd.h>
31 #include <dirent.h>
32 #include <fcntl.h>
33 #include <inttypes.h>
35 #include <sys/types.h>
36 #if defined(__linux__)
37 #include "linux/util.h"
38 #include "linux/tree.h"
39 #include <bsd/stdlib.h>
40 #include <X11/Xlib.h>
41 #include <sys/un.h>
42 # if !defined(sane_libbsd_headers)
43 void arc4random_buf(void *, size_t);
44 u_int32_t arc4random_uniform(u_int32_t);
45 # endif
46 #elif defined(__APPLE__)
47 #include "osx/util.h"
48 #include "osx/tree.h"
49 #include <stdlib.h>
50 #include <X11/Xlib.h>
51 #include <sys/un.h>
52 #include <sys/param.h>
53 #include <sys/ucred.h>
54 #define LOGIN_NAME_MAX MAXLOGNAME
55 #elif defined(__FreeBSD__)
56 #include <libutil.h>
57 #include "freebsd/util.h"
58 #include <sys/tree.h>
59 #include <X11/Xlib.h>
60 #include <sys/un.h>
61 #include <sys/param.h>
62 #define LOGIN_NAME_MAX MAXLOGNAME
63 #elif defined(__DragonFly__)
64 #include <sys/param.h>
65 #include <sys/un.h>
66 #include <libutil.h>
67 #include "dragonfly/util.h"
68 #include <sys/tree.h>
69 #include <X11/Xlib.h>
70 #define LOGIN_NAME_MAX MAXLOGNAME
71 #elif defined(__NetBSD__)
72 #include <sys/param.h>
73 #include <sys/un.h>
74 #include "netbsd/util.h"
75 #include <sys/tree.h>
76 #include <X11/Xlib.h>
77 #define LOGIN_NAME_MAX_MAXLOGNAME
78 #elif defined(__OpenBSD__)
79 #include <util.h>
80 #include <sys/tree.h>
81 #include <X11/Xlib.h>
82 #include <sys/un.h>
83 #else
84 /* mingw */
85 void arc4random_buf(void *, size_t);
86 uint32_t arc4random_uniform(uint32_t);
87 #include "tree.h"
88 #endif
89 #include <sys/queue.h>
90 #include <sys/socket.h>
91 #include <sys/stat.h>
92 #include <sys/time.h>
94 #include <gtk/gtk.h>
95 #include <gdk/gdk.h>
96 #include <gdk/gdkkeysyms.h>
98 #if GTK_CHECK_VERSION(3,0,0)
99 /* we still use GDK_* instead of GDK_KEY_* */
100 #include <gdk/gdkkeysyms-compat.h>
101 #endif
103 #include <webkit/webkit.h>
104 #include <libsoup/soup.h>
105 #include <JavaScriptCore/JavaScript.h>
106 #include <gnutls/gnutls.h>
107 #include <gnutls/x509.h>
109 /* set if you don't want to use resource limits */
110 #ifndef XT_RESOURCE_LIMITS_DISABLE
111 #include <sys/resource.h>
112 #endif
114 #include "javascript.h"
116 javascript.h borrowed from vimprobable2 under the following license:
118 Copyright (c) 2009 Leon Winter
119 Copyright (c) 2009-2011 Hannes Schueller
120 Copyright (c) 2009-2010 Matto Fransen
121 Copyright (c) 2010-2011 Hans-Peter Deifel
122 Copyright (c) 2010-2011 Thomas Adam
123 Copyright (c) 2011 Albert Kim
124 Copyright (c) 2011 Daniel Carl
126 Permission is hereby granted, free of charge, to any person obtaining a copy
127 of this software and associated documentation files (the "Software"), to deal
128 in the Software without restriction, including without limitation the rights
129 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
130 copies of the Software, and to permit persons to whom the Software is
131 furnished to do so, subject to the following conditions:
133 The above copyright notice and this permission notice shall be included in
134 all copies or substantial portions of the Software.
136 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
137 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
138 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
139 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
140 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
141 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
142 THE SOFTWARE.
145 /*#define XT_DEBUG*/
146 #ifdef XT_DEBUG
147 #define DPRINTF(x...) do { if (swm_debug) fprintf(stderr, x); } while (0)
148 #define DNPRINTF(n,x...) do { if (swm_debug & n) fprintf(stderr, x); } while (0)
149 #define XT_D_MOVE 0x0001
150 #define XT_D_KEY 0x0002
151 #define XT_D_TAB 0x0004
152 #define XT_D_URL 0x0008
153 #define XT_D_CMD 0x0010
154 #define XT_D_NAV 0x0020
155 #define XT_D_DOWNLOAD 0x0040
156 #define XT_D_CONFIG 0x0080
157 #define XT_D_JS 0x0100
158 #define XT_D_FAVORITE 0x0200
159 #define XT_D_PRINTING 0x0400
160 #define XT_D_COOKIE 0x0800
161 #define XT_D_KEYBINDING 0x1000
162 #define XT_D_CLIP 0x2000
163 #define XT_D_BUFFERCMD 0x4000
164 #define XT_D_INSPECTOR 0x8000
165 #define XT_D_VISITED 0x10000
166 #define XT_D_HISTORY 0x20000
167 #define XT_D_MISC 0x40000
168 #define XT_D_CUSTOM_URI 0x80000
169 #define XT_D_CMD_ALIAS 0x100000
170 #define XT_D_SEARCH 0x200000
171 extern uint32_t swm_debug;
172 #else
173 #define DPRINTF(x...)
174 #define DNPRINTF(n,x...)
175 #endif
177 #define LENGTH(x) (sizeof x / sizeof x[0])
178 #define CLEAN(mask) (mask & ~(GDK_MOD2_MASK) & \
179 ~(GDK_BUTTON1_MASK) & \
180 ~(GDK_BUTTON2_MASK) & \
181 ~(GDK_BUTTON3_MASK) & \
182 ~(GDK_BUTTON4_MASK) & \
183 ~(GDK_BUTTON5_MASK))
185 #define XT_MARKS "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'"
186 #define XT_NOMARKS (sizeof(XT_MARKS) - 1)
187 #define XT_QMARKS "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
188 #define XT_NOQMARKS (sizeof(XT_QMARKS) - 1)
190 /* Path Separator */
191 #ifndef PS
192 #define PS "/"
193 #define PSC '/'
194 #endif
196 struct tab {
197 TAILQ_ENTRY(tab) entry;
198 GtkWidget *vbox;
199 GtkWidget *tab_content;
200 struct {
201 GtkWidget *label;
202 GtkWidget *favicon;
203 GtkWidget *eventbox;
204 GtkWidget *box;
205 } tab_elems;
206 GtkWidget *label;
207 GtkWidget *spinner;
208 GtkWidget *uri_entry;
209 #if !GTK_CHECK_VERSION(3, 0, 0)
210 GtkStyle *default_style;
211 #endif
212 GtkWidget *search_entry;
213 GtkWidget *toolbar;
214 GtkWidget *browser_win;
215 GtkWidget *statusbar;
216 struct {
217 GtkWidget *ebox; /* non window-less widget for colors */
218 GtkWidget *uri;
219 GtkWidget *buffercmd;
220 GtkWidget *zoom;
221 GtkWidget *position;
222 GtkWidget *tabs;
223 GtkWidget *proxy;
224 } sbe;
225 GtkWidget *cmd;
226 GtkWidget *buffers;
227 GtkWidget *oops;
228 GtkWidget *backward;
229 GtkWidget *forward;
230 GtkWidget *stop;
231 GtkWidget *gohome;
232 GtkWidget *js_toggle;
233 GtkWidget *proxy_toggle;
234 GtkEntryCompletion *completion;
235 guint tab_id;
236 WebKitWebView *wv;
238 WebKitWebBackForwardList *bfl;
239 WebKitWebHistoryItem *item;
241 /* favicon */
242 WebKitNetworkRequest *icon_request;
243 WebKitDownload *icon_download;
244 gchar *icon_dest_uri;
246 /* adjustments for browser */
247 GtkAdjustment *adjust_h;
248 GtkAdjustment *adjust_v;
250 /* flags */
251 int mode;
252 #define XT_MODE_COMMAND (0)
253 #define XT_MODE_INSERT (1)
254 #define XT_MODE_HINT (2)
255 #define XT_MODE_PASSTHROUGH (3)
256 int (*mode_cb)(struct tab *, GdkEventKey *, gpointer);
257 gpointer mode_cb_data;
258 int focus_wv;
259 int ctrl_click;
260 gchar *status;
261 int xtp_meaning; /* identifies dls/favorites */
262 int xtp_arg;
263 char *session_key;
264 gchar *tmp_uri;
265 int popup; /* 1 if cmd_entry has popup visible */
266 int download_requested;
268 /* hints */
269 int script_init;
270 int new_tab;
272 /* custom stylesheet */
273 int styled;
274 char *stylesheet;
276 /* search */
277 char *search_text;
278 int search_forward;
279 guint search_id;
281 /* settings */
282 WebKitWebSettings *settings;
283 int user_agent_id;
284 int http_accept_id;
285 gboolean load_images;
287 /* marks */
288 double mark[XT_NOMARKS];
290 /* inspector */
291 WebKitWebInspector *inspector;
292 GtkWidget *inspector_window;
293 GtkWidget *inspector_view;
295 /* focused text entry */
296 #if WEBKIT_CHECK_VERSION(1, 5, 0)
297 WebKitDOMElement *active;
298 char *active_text;
299 #endif
301 /* signal handles */
302 gulong progress_handle;
304 /* cert chain (pem) */
305 char *pem;
307 /* previous host (:cert show) */
308 char *about_cert_host;
310 TAILQ_HEAD(tab_list, tab);
312 struct karg {
313 int i;
314 char *s;
315 int precount;
316 void *ptr;
319 struct download {
320 RB_ENTRY(download) entry;
321 int id;
322 WebKitDownload *download;
323 struct tab *tab;
325 RB_HEAD(download_list, download);
326 RB_PROTOTYPE(download_list, download, entry, download_rb_cmp);
328 struct history {
329 RB_ENTRY(history) entry;
330 gchar *uri;
331 gchar *title;
332 time_t time; /* When the item was added. */
334 RB_HEAD(history_list, history);
335 RB_PROTOTYPE(history_list, history, entry, history_rb_cmp);
337 #define XT_STS_FLAGS_INCLUDE_SUBDOMAINS (1)
338 #define XT_STS_FLAGS_EXPAND (2)
339 #define XT_STS_FILE ("strict-transport")
341 struct strict_transport {
342 RB_ENTRY(strict_transport) entry;
343 gchar *host;
344 time_t timeout;
345 int flags;
347 RB_HEAD(strict_transport_tree, strict_transport);
348 RB_PROTOTYPE(strict_transport_tree, strict_transport, entry, strict_transport_rb_cmp);
350 struct secviolation {
351 RB_ENTRY(secviolation) entry;
352 int xtp_arg;
353 struct tab *t;
354 char *uri;
356 RB_HEAD(secviolation_list, secviolation);
357 RB_PROTOTYPE(secviolation_list, secviolation, entry, secviolation_rb_cmp);
359 struct user_agent {
360 RB_ENTRY(user_agent) entry;
361 int id;
362 char *value;
364 RB_HEAD(user_agent_list, user_agent);
365 RB_PROTOTYPE(user_agent_list, user_agent, entry, user_agent_rb_cmp);
367 struct http_accept {
368 RB_ENTRY(http_accept) entry;
369 int id;
370 char *value;
372 RB_HEAD(http_accept_list, http_accept);
373 RB_PROTOTYPE(http_accept_list, http_accept, entry, http_accept_rb_cmp);
375 struct domain_id {
376 RB_ENTRY(domain_id) entry;
377 int ua_id; /* user agent id key */
378 int ha_id; /* http accept header id key */
379 char *domain;
381 RB_HEAD(domain_id_list, domain_id);
382 RB_PROTOTYPE(domain_id_list, domain_id, entry, domain_id_rb_cmp);
384 /* utility */
385 #define XT_NAME ("xombrero")
386 #define XT_DIR (".xombrero")
387 #define XT_CB_HANDLED (TRUE)
388 #define XT_CB_PASSTHROUGH (FALSE)
389 #define XT_CONF_FILE ("xombrero.conf")
390 #define XT_CSS_FILE ("xombrero.css")
391 #define XT_FAVS_FILE ("favorites")
392 #define XT_SOD_FILE ("startofday")
393 #define XT_HSTS_PRELOAD_FILE ("hsts-preload")
394 #define XT_USER_AGENT_FILE ("user-agent-headers")
395 #define XT_HTTP_ACCEPT_FILE ("http-accept-headers")
396 #define XT_RESERVED_CHARS "$&+,/:;=?@ \"<>#%%{}|^~[]`"
398 int run_script(struct tab *, char *);
399 void js_autorun(struct tab *);
400 void xt_icon_from_file(struct tab *, char *);
401 GtkWidget *create_window(const gchar *);
402 void show_oops(struct tab *, const char *, ...);
403 gchar *get_html_page(gchar *, gchar *, gchar *, bool);
404 const gchar *get_uri(struct tab *);
405 const gchar *get_title(struct tab *, bool);
406 void load_uri(struct tab *t, const gchar *uri);
407 gboolean match_uri(const gchar *uri, const gchar *key);
408 int valid_url_type(const char *);
409 void expand_tilde(char *, size_t, const char *);
410 char *html_escape(const char *val);
411 void set_status(struct tab *t, gchar *fmt, ...);
413 void load_webkit_string(struct tab *, const char *, gchar *, int);
414 void button_set_stockid(GtkWidget *, char *);
415 void button_set_file(GtkWidget *, char *);
416 void webview_progress_changed_cb(WebKitWebView *, GParamSpec *, struct tab *);
418 /* cookies */
419 int remove_cookie(int);
420 int remove_cookie_domain(int);
421 int remove_cookie_all(void);
422 void print_cookie(char *msg, SoupCookie *);
423 void setup_cookies(void);
425 /* history */
426 int insert_history_item(const gchar *uri, const gchar *title, time_t time);
427 int save_global_history_to_disk(struct tab *t);
428 int restore_global_history(void);
429 char *color_visited_helper(void);
430 int color_visited(struct tab *t, char *visited);
432 /* completion */
433 void completion_add(struct tab *);
434 void completion_add_uri(const gchar *uri);
436 /* external editor */
437 #define XT_EE_BUFSZ (64 * 1024)
438 int edit_src(struct tab *t, struct karg *args);
439 int edit_element(struct tab *t, struct karg *a);
441 /* proxy */
442 #define XT_PRXY_SHOW (1<<0)
443 #define XT_PRXY_TOGGLE (1<<1)
445 /* url modify */
446 #define XT_URL (1<<0)
447 #define XT_URL_PLUS (1<<1)
448 #define XT_URL_MIN (1<<2)
450 /* inspector */
451 #define XT_INS_SHOW (1<<0)
452 #define XT_INS_HIDE (1<<1)
453 #define XT_INS_CLOSE (1<<2)
455 WebKitWebView* inspector_inspect_web_view_cb(WebKitWebInspector *,
456 WebKitWebView*, struct tab *);
457 void setup_inspector(struct tab *);
458 int inspector_cmd(struct tab *, struct karg *);
460 /* tld public suffix */
461 void tld_tree_init();
462 char *tld_get_suffix(const char *);
464 /* about */
465 #define XT_XTP_STR "xxxt://"
466 #define XT_XTP_SCHEME "xxxt"
467 #define XT_URI_ABOUT ("about:")
468 #define XT_URI_ABOUT_LEN (strlen(XT_URI_ABOUT))
469 #define XT_URI_ABOUT_ABOUT ("about")
470 #define XT_URI_ABOUT_ALLTHETHINGS ("allthethings")
471 #define XT_URI_ABOUT_BLANK ("blank")
472 #define XT_URI_ABOUT_CERTS ("certs")
473 #define XT_URI_ABOUT_COOKIEWL ("cookiewl")
474 #define XT_URI_ABOUT_COOKIEJAR ("cookiejar")
475 #define XT_URI_ABOUT_DOWNLOADS ("downloads")
476 #define XT_URI_ABOUT_FAVORITES ("favorites")
477 #define XT_URI_ABOUT_HELP ("help")
478 #define XT_URI_ABOUT_HISTORY ("history")
479 #define XT_URI_ABOUT_JSWL ("jswl")
480 #define XT_URI_ABOUT_PLUGINWL ("plwl")
481 #define XT_URI_ABOUT_HTTPS ("https")
482 #define XT_URI_ABOUT_SET ("set")
483 #define XT_URI_ABOUT_STATS ("stats")
484 #define XT_URI_ABOUT_MARCO ("marco")
485 #define XT_URI_ABOUT_STARTPAGE ("startpage")
486 #define XT_URI_ABOUT_WEBKIT ("webkit")
487 #define XT_URI_ABOUT_SEARCH ("search")
488 #define XT_URI_ABOUT_SECVIOLATION ("secviolation")
489 #define XT_URI_ABOUT_RUNTIME ("runtime")
491 struct about_type {
492 char *name;
493 int (*func)(struct tab *, struct karg *);
496 struct sp {
497 char *line;
498 TAILQ_ENTRY(sp) entry;
500 TAILQ_HEAD(sp_list, sp);
502 int blank(struct tab *, struct karg *);
503 int help(struct tab *, struct karg *);
504 int stats(struct tab *, struct karg *);
505 void show_certs(struct tab *, gnutls_x509_crt_t *,
506 size_t, char *);
507 int ca_cmd(struct tab *, struct karg *);
508 int cookie_show_wl(struct tab *, struct karg *);
509 int xtp_page_ab(struct tab *, struct karg *);
510 int xtp_page_cl(struct tab *, struct karg *);
511 int xtp_page_dl(struct tab *, struct karg *);
512 int xtp_page_fl(struct tab *, struct karg *);
513 int xtp_page_hl(struct tab *, struct karg *);
514 int xtp_page_sl(struct tab *, struct karg *);
515 int xtp_page_sv(struct tab *, struct karg *);
516 int parse_xtp_url(struct tab *, const char *);
517 int add_favorite(struct tab *, struct karg *);
518 void update_favorite_tabs(struct tab *);
519 void update_history_tabs(struct tab *);
520 void update_download_tabs(struct tab *);
521 size_t about_list_size(void);
522 int cookie_cmd(struct tab *, struct karg *);
523 int js_cmd(struct tab *, struct karg *);
524 int pl_cmd(struct tab *, struct karg *);
525 int https_cmd(struct tab *, struct karg *);
526 void startpage_add(const char *, ...);
529 * xtp tab meanings
530 * identifies which tabs have xtp pages in (corresponding to about_list indices)
532 #define XT_XTP_TAB_MEANING_NORMAL (-1) /* normal url */
533 #define XT_XTP_TAB_MEANING_AB (0) /* any other about page */
534 #define XT_XTP_TAB_MEANING_BL (2) /* about:blank in this tab */
535 #define XT_XTP_TAB_MEANING_CL (5) /* cookie manager in this tab */
536 #define XT_XTP_TAB_MEANING_DL (6) /* download manager in this tab */
537 #define XT_XTP_TAB_MEANING_FL (7) /* favorite manager in this tab */
538 #define XT_XTP_TAB_MEANING_HL (9) /* history manager in this tab */
539 #define XT_XTP_TAB_MEANING_SET (11) /* settings manager/viewer */
540 #define XT_XTP_TAB_MEANING_SL (18) /* search engine chooser */
541 #define XT_XTP_TAB_MEANING_RT (19) /* about:runtime in this tab */
542 #define XT_XTP_TAB_MEANING_SV (20) /* about:secviolation in tab */
544 /* whitelists */
545 #define XT_WL_TOGGLE (1<<0)
546 #define XT_WL_ENABLE (1<<1)
547 #define XT_WL_DISABLE (1<<2)
548 #define XT_WL_FQDN (1<<3) /* default */
549 #define XT_WL_TOPLEVEL (1<<4)
550 #define XT_WL_PERSISTENT (1<<5)
551 #define XT_WL_SESSION (1<<6)
552 #define XT_WL_RELOAD (1<<7)
553 #define XT_SHOW (1<<8)
554 #define XT_DELETE (1<<9)
555 #define XT_SAVE (1<<10)
556 #define XT_OPEN (1<<11)
557 #define XT_CACHE (1<<12)
558 #define XT_WL_REGEX (1<<13)
560 #define XT_WL_INVALID (0)
561 #define XT_WL_JAVASCRIPT (1)
562 #define XT_WL_COOKIE (2)
563 #define XT_WL_PLUGIN (3)
564 #define XT_WL_HTTPS (4)
566 struct wl_entry {
567 regex_t *re;
568 char *pat;
569 int handy; /* app use */
570 TAILQ_ENTRY(wl_entry) entry;
572 TAILQ_HEAD(wl_list, wl_entry);
574 int wl_show(struct tab *, struct karg *, char *,
575 struct wl_list *);
577 /* uri aliases */
578 struct alias {
579 char *a_name;
580 char *a_uri;
581 TAILQ_ENTRY(alias) entry;
583 TAILQ_HEAD(alias_list, alias);
585 /* mime types */
586 struct mime_type {
587 char *mt_type;
588 char *mt_action;
589 int mt_default;
590 int mt_download;
591 TAILQ_ENTRY(mime_type) entry;
593 TAILQ_HEAD(mime_type_list, mime_type);
595 struct wl_entry * wl_find(const gchar *, struct wl_list *);
596 int wl_save(struct tab *, struct karg *, int);
597 int toggle_cwl(struct tab *, struct karg *);
598 int toggle_js(struct tab *, struct karg *);
599 int toggle_pl(struct tab *, struct karg *);
600 int toggle_force_https(struct tab *, struct karg *);
602 /* input autofocus */
603 void input_autofocus(struct tab *);
604 void *input_check_mode(struct tab *);
605 int command_mode(struct tab *, struct karg *);
607 /* settings */
608 #define XT_BM_NORMAL (0)
609 #define XT_BM_WHITELIST (1)
610 #define XT_BM_KIOSK (2)
612 #define XT_GM_CLASSIC (0)
613 #define XT_GM_MINIMAL (1)
615 #define XT_TABS_NORMAL (0)
616 #define XT_TABS_COMPACT (1)
618 #define XT_STATUSBAR_URL (0)
619 #define XT_STATUSBAR_TITLE (1)
621 #define XT_EM_HYBRID (0)
622 #define XT_EM_VI (1)
624 #define XT_DM_START (0)
625 #define XT_DM_ASK (1)
626 #define XT_DM_ADD (2)
628 #define XT_REFERER_ALWAYS (0)
629 #define XT_REFERER_NEVER (1)
630 #define XT_REFERER_SAME_DOMAIN (2)
631 #define XT_REFERER_CUSTOM (3)
632 #define XT_REFERER_SAME_FQDN (4)
634 #define CTRL GDK_CONTROL_MASK
635 #define MOD1 GDK_MOD1_MASK
636 #define SHFT GDK_SHIFT_MASK
638 /* runtime default settings */
639 #define XT_DS_SHOW_TABS (1)
640 #define XT_DS_TAB_STYLE XT_TABS_NORMAL
641 #define XT_DS_STATUSBAR_STYLE XT_STATUSBAR_URL
642 #define XT_DS_SHOW_URL (1)
643 #define XT_DS_SHOW_SCROLLBARS (1)
644 #define XT_DS_SHOW_STATUSBAR (0)
645 #define XT_DS_CTRL_CLICK_FOCUS (0)
646 #define XT_DS_COOKIES_ENABLED (1)
647 #define XT_DS_READ_ONLY_COOKIES (0)
648 #define XT_DS_ENABLE_SCRIPTS (1)
649 #define XT_DS_ENABLE_PLUGINS (1)
650 #define XT_DS_DEFAULT_ZOOM_LEVEL (1.0)
651 #define XT_DS_DEFAULT_SCRIPT ("")
652 #define XT_DS_REFRESH_INTERVAL (10)
653 #define XT_DS_ENABLE_PLUGIN_WHITELIST (0)
654 #define XT_DS_ENABLE_COOKIE_WHITELIST (0)
655 #define XT_DS_ENABLE_JS_WHITELIST (0)
656 #define XT_DS_ENABLE_LOCALSTORAGE (1)
657 #define XT_DS_SESSION_TIMEOUT (3600)
658 #define XT_DS_COOKIE_POLICY SOUP_COOKIE_JAR_ACCEPT_ALWAYS
659 #define XT_DS_SSL_STRICT_CERTS FALSE
660 #define XT_DS_SSL_CA_FILE ("")
661 #define XT_DS_ENABLE_STRICT_TRANSPORT TRUE
662 #define XT_DS_APPEND_NEXT (1)
663 #define XT_DS_HOME ("https://www.cyphertite.com/")
664 #define XT_DS_SEARCH_STRING ("about:search")
665 #define XT_DS_COLOR_VISITED_URIS (1)
666 #define XT_DS_SESSION_AUTOSAVE (0)
667 #define XT_DS_GUESS_SEARCH (0)
668 #define XT_DS_ENABLE_SPELL_CHECKING (0)
669 #define XT_DS_SPELL_CHECK_LANGUAGES ("en_US")
670 #define XT_DS_URL_REGEX ("^[[:blank:]]*[^[:blank:]]*([[:alnum:]-]+\\.)+[[:alnum:]-][^[:blank:]]*[[:blank:]]*$")
671 #define XT_DS_ENCODING ("UTF-8")
672 #define XT_DS_AUTOFOCUS_ONLOAD (0)
673 #define XT_DS_ENABLE_JS_AUTORUN (1)
674 #define XT_DS_USERSTYLE_GLOBAL (0)
675 #define XT_DS_AUTO_LOAD_IMAGES (1)
676 #define XT_DS_ENABLE_AUTOSCROLL (0)
677 #define XT_DS_ENABLE_FAVICON_ENTRY (1)
678 #define XT_DS_ENABLE_FAVICON_TABS (0)
679 #define XT_DS_EXTERNAL_EDITOR (NULL)
680 #define XT_DS_REFERER_MODE XT_REFERER_ALWAYS
681 #define XT_DS_REFERER_CUSTOM ("always")
682 #define XT_DS_DOWNLOAD_NOTIFICATIONS (0)
683 #define XT_DS_CMD_FONT_NAME ("monospace normal 9")
684 #define XT_DS_OOPS_FONT_NAME ("monospace normal 9")
685 #define XT_DS_STATUSBAR_FONT_NAME ("monospace normal 9")
686 #define XT_DS_TABBAR_FONT_NAME ("monospace normal 9")
687 #define XT_DS_ALLOW_INSECURE_CONTENT (TRUE)
688 #define XT_DS_ALLOW_INSECURE_SCRIPTS (TRUE)
689 #define XT_DS_WARN_CERT_CHANGES (0)
690 #define XT_DS_RESOURCE_DIR ("/usr/local/share/xombrero")
691 #define XT_DS_DO_NOT_TRACK (0)
692 #define XT_DS_PRELOAD_STRICT_TRANSPORT (1)
693 #define XT_DS_GNUTLS_PRIORITY_STRING (NULL)
694 #define XT_DS_JS_AUTO_OPEN_WINDOWS (1)
696 /* actions */
697 #define XT_STYLE_CURRENT_TAB (0)
698 #define XT_STYLE_GLOBAL (1)
700 #define XT_TAB_LAST (-4)
701 #define XT_TAB_FIRST (-3)
702 #define XT_TAB_PREV (-2)
703 #define XT_TAB_NEXT (-1)
704 #define XT_TAB_INVALID (0)
705 #define XT_TAB_NEW (1)
706 #define XT_TAB_DELETE (2)
707 #define XT_TAB_DELQUIT (3)
708 #define XT_TAB_OPEN (4)
709 #define XT_TAB_UNDO_CLOSE (5)
710 #define XT_TAB_SHOW (6)
711 #define XT_TAB_HIDE (7)
712 #define XT_TAB_NEXTSTYLE (8)
713 #define XT_TAB_LOAD_IMAGES (9)
714 #define XT_TAB_ONLY (10)
716 #define XT_URL_SHOW (1)
717 #define XT_URL_HIDE (2)
719 /* XTP classes (xxxt://<class>) */
720 #define XT_XTP_INVALID (0) /* invalid */
721 #define XT_XTP_DL (1) /* downloads */
722 #define XT_XTP_HL (2) /* history */
723 #define XT_XTP_CL (3) /* cookies */
724 #define XT_XTP_FL (4) /* favorites */
725 #define XT_XTP_SL (5) /* search */
726 #define XT_XTP_AB (6) /* about */
727 #define XT_XTP_SV (7) /* security violation */
728 #define XT_XTP_RT (8) /* set */
730 /* XTP download actions */
731 #define XT_XTP_DL_LIST (1)
732 #define XT_XTP_DL_CANCEL (2)
733 #define XT_XTP_DL_REMOVE (3)
734 #define XT_XTP_DL_UNLINK (4)
735 #define XT_XTP_DL_START (5)
737 /* XTP history actions */
738 #define XT_XTP_HL_LIST (1)
739 #define XT_XTP_HL_REMOVE (2)
740 #define XT_XTP_HL_REMOVE_ALL (3)
742 /* XTP cookie actions */
743 #define XT_XTP_CL_LIST (1)
744 #define XT_XTP_CL_REMOVE (2)
745 #define XT_XTP_CL_REMOVE_DOMAIN (3)
746 #define XT_XTP_CL_REMOVE_ALL (4)
748 /* XTP cookie actions */
749 #define XT_XTP_FL_LIST (1)
750 #define XT_XTP_FL_REMOVE (2)
752 /* XPT search actions */
753 #define XT_XTP_SL_SET (1)
755 /* XPT about actions */
756 #define XT_XTP_AB_EDIT_CONF (1)
758 /* XTP security violation actions */
759 #define XT_XTP_SV_SHOW_NEW_CERT (1)
760 #define XT_XTP_SV_ALLOW_SESSION (2)
761 #define XT_XTP_SV_CACHE (3)
762 #define XT_XTP_SV_SHOW_CACHED_CERT (4)
764 /* XTP set actions */
765 #define XT_XTP_RT_SAVE (1)
767 /* needed for xtp_page_rt in settings.c */
768 void generate_xtp_session_key(char **);
770 struct key_binding {
771 char *cmd;
772 guint mask;
773 guint use_in_entry;
774 guint key;
775 TAILQ_ENTRY(key_binding) entry; /* in bss so no need to init */
777 TAILQ_HEAD(keybinding_list, key_binding);
779 struct custom_uri {
780 char *uri;
781 char cmd[PATH_MAX];
782 TAILQ_ENTRY(custom_uri) entry;
784 TAILQ_HEAD(custom_uri_list, custom_uri);
786 struct cmd_alias {
787 char *alias;
788 char *cmd;
789 TAILQ_ENTRY(cmd_alias) entry;
791 TAILQ_HEAD(cmd_alias_list, cmd_alias);
793 struct set_reject {
794 char *name;
795 char *value;
796 TAILQ_ENTRY(set_reject) entry;
798 TAILQ_HEAD(set_reject_list, set_reject);
800 struct settings {
801 char *name;
802 int type;
803 #define XT_S_INVALID (0)
804 #define XT_S_INT (1)
805 #define XT_S_STR (2)
806 #define XT_S_FLOAT (3)
807 #define XT_S_BOOL (4)
808 uint32_t flags;
809 #define XT_SF_RESTART (1<<0)
810 #define XT_SF_RUNTIME (1<<1)
811 #define XT_SF_INVISIBLE (1<<2)
812 int *ival;
813 char **sval;
814 struct special *s;
815 gfloat *fval;
816 int (*activate)(char *);
817 int (*ismodified)(char **);
818 char *tt;
821 struct special {
822 int (*set)(struct settings *, char *);
823 char *(*get)(struct settings *);
824 void (*walk)(struct settings *,
825 void (*cb)(struct settings *, char *, void *),
826 void *);
827 char *valid_options[];
830 int set(struct tab *, struct karg *);
831 int xtp_page_rt(struct tab *, struct karg *);
832 size_t get_settings_size(void);
833 int settings_add(char *, char *);
834 int setup_proxy(const char *);
835 int proxy_cmd(struct tab *, struct karg *);
836 int set_browser_mode(struct settings *, char *);
837 int set_encoding(struct tab *, struct karg *);
838 int set_gui_mode(struct settings *, char *);
839 int set_cookie_policy(struct settings *, char *);
840 int set_search_string(char *);
841 int set_ssl_ca_file(struct settings *, char *);
842 char *get_browser_mode(struct settings *);
843 char *get_gui_mode(struct settings *);
844 char *get_cookie_policy(struct settings *);
845 void init_keybindings(void);
846 void config_parse(char *, int);
847 char *get_setting_name(int);
848 void statusbar_set_visibility(void);
849 int tabaction(struct tab *, struct karg *);
850 int urlaction(struct tab *, struct karg *);
851 int userstyle_cmd(struct tab *, struct karg *);
852 struct tab *get_current_tab(void);
853 int resizetab(struct tab *, struct karg *);
854 int cert_cmd(struct tab *, struct karg *);
855 void focus_webview(struct tab *);
856 int is_g_object_setting(GObject *, char *);
857 int set_scrollbar_visibility(struct tab *, int);
858 int save_runtime_setting(const char *, const char *);
859 void wl_add(const char *, struct wl_list *, int);
861 #ifndef SOUP_CHECK_VERSION
862 #define SOUP_CHECK_VERSION(major, minor, micro) (0)
863 #endif
865 #if GTK_CHECK_VERSION(3,0,0)
866 #define modify_font gtk_widget_override_font
867 #else
868 #define modify_font gtk_widget_modify_font
869 #endif
871 #define XT_DL_START (0)
872 #define XT_DL_RESTART (1)
873 int download_start(struct tab *, struct download *, int flag);
875 extern int tabless;
876 extern int enable_socket;
877 extern int single_instance;
878 extern int fancy_bar;
879 extern int browser_mode;
880 extern int enable_localstorage;
881 extern char *statusbar_elems;
883 #if SOUP_CHECK_VERSION(2, 42, 2)
884 extern GProxyResolver *proxy_uri;
885 extern gchar *proxy_exclude[];
886 #else
887 extern SoupURI *proxy_uri;
888 #endif
890 extern int show_tabs;
891 extern int tab_style;
892 extern int statusbar_style;
893 extern int show_url;
894 extern int show_scrollbars;
895 extern int show_statusbar;
896 extern int ctrl_click_focus;
897 extern int cookies_enabled;
898 extern int read_only_cookies;
899 extern int enable_cache;
900 extern int enable_scripts;
901 extern int enable_plugins;
902 extern gfloat default_zoom_level;
903 extern char default_script[PATH_MAX];
904 extern int window_height;
905 extern int window_width;
906 extern int window_maximize;
907 extern int icon_size;
908 extern int refresh_interval;
909 extern int enable_plugin_whitelist;
910 extern int enable_cookie_whitelist;
911 extern int enable_js_whitelist;
912 extern int session_timeout;
913 extern int cookie_policy;
914 extern char ssl_ca_file[PATH_MAX];
915 extern char *resource_dir;
916 extern gboolean ssl_strict_certs;
917 extern gboolean enable_strict_transport;
918 extern int append_next;
919 extern char *home;
920 extern char *search_string;
921 extern char *http_proxy;
922 extern int http_proxy_starts_enabled;
923 extern char *external_editor;
924 extern char download_dir[PATH_MAX];
925 extern int download_mode;
926 extern char runtime_settings[PATH_MAX];
927 extern int allow_volatile_cookies;
928 extern int color_visited_uris;
929 extern int save_global_history;
930 extern int save_rejected_cookies;
931 extern int session_autosave;
932 extern int guess_search;
933 extern gint max_connections;
934 extern gint max_host_connections;
935 extern gint enable_spell_checking;
936 extern char *spell_check_languages;
937 extern char *url_regex;
938 extern int history_autosave;
939 extern char search_file[PATH_MAX];
940 extern char command_file[PATH_MAX];
941 extern char *encoding;
942 extern int autofocus_onload;
943 extern int enable_js_autorun;
944 extern char *cmd_font_name;
945 extern char *oops_font_name;
946 extern char *statusbar_font_name;
947 extern char *tabbar_font_name;
948 extern int edit_mode;
949 extern char *userstyle;
950 extern char *stylesheet;
951 extern int userstyle_global;
952 extern int auto_load_images;
953 extern int enable_autoscroll;
954 extern int enable_favicon_entry;
955 extern int enable_favicon_tabs;
956 extern int referer_mode;
957 extern char *referer_custom;
958 extern int download_notifications;
959 extern int warn_cert_changes;
960 extern regex_t url_re;
961 extern int allow_insecure_content;
962 extern int allow_insecure_scripts;
963 extern int do_not_track;
964 extern int preload_strict_transport;
965 extern char *gnutls_priority_string;
966 extern int anonymize_headers;
967 extern int js_auto_open_windows;
969 /* globals */
970 extern void (*os_init)(void);
971 extern char *version;
972 extern char *icons[];
973 extern char rc_fname[PATH_MAX];
974 extern char work_dir[PATH_MAX];
975 extern char temp_dir[PATH_MAX];
976 extern struct passwd *pwd;
977 extern SoupCookieJar *s_cookiejar;
978 extern SoupCookieJar *p_cookiejar;
979 extern SoupSession *session;
980 extern GtkNotebook *notebook;
981 extern GtkListStore *completion_model;
982 extern uint64_t blocked_cookies;
983 extern SoupSession *session;
985 extern void (*_soup_cookie_jar_add_cookie)(SoupCookieJar *, SoupCookie *);
987 extern struct history_list hl;
988 extern int hl_purge_count;
989 extern struct download_list downloads;
990 extern struct tab_list tabs;
991 extern struct about_type about_list[];
992 extern struct wl_list c_wl;
993 extern struct wl_list js_wl;
994 extern struct wl_list pl_wl;
995 extern struct wl_list force_https;
996 extern struct wl_list svil;
997 extern struct strict_transport_tree st_tree;
998 extern struct alias_list aliases;
999 extern struct mime_type_list mtl;
1000 extern struct keybinding_list kbl;
1001 extern struct sp_list spl;
1002 extern struct user_agent_list ua_list;
1003 extern struct http_accept_list ha_list;
1004 extern struct cmd_alias_list cal;
1005 extern struct custom_uri_list cul;
1006 extern struct secviolation_list svl;
1007 extern struct set_reject_list srl;
1008 extern struct settings rs[];
1010 extern PangoFontDescription *cmd_font;
1011 extern PangoFontDescription *oops_font;
1012 extern PangoFontDescription *statusbar_font;
1013 extern PangoFontDescription *tabbar_font;