rejig downloads a bit to accomodate windows
[xombrero.git] / xombrero.h
blobfeab5b6ccfdcfaeb021abd96ad6f82194fa7060f
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>
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 #include <ctype.h>
20 #include <dlfcn.h>
21 #include <err.h>
22 #include <errno.h>
23 #include <libgen.h>
24 #include <pwd.h>
25 #include <regex.h>
26 #include <signal.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(__FreeBSD__)
47 #include <libutil.h>
48 #include "freebsd/util.h"
49 #include <sys/tree.h>
50 #include <X11/Xlib.h>
51 #include <sys/un.h>
52 #elif defined(__OpenBSD__)
53 #include <util.h>
54 #include <sys/tree.h>
55 #include <X11/Xlib.h>
56 #include <sys/un.h>
57 #else
58 /* mingw */
59 void arc4random_buf(void *, size_t);
60 uint32_t arc4random_uniform(uint32_t);
61 #include "tree.h"
62 #endif
63 #include <sys/queue.h>
64 #include <sys/socket.h>
65 #include <sys/stat.h>
66 #include <sys/time.h>
68 #include <gtk/gtk.h>
69 #include <gdk/gdk.h>
70 #include <gdk/gdkkeysyms.h>
72 #if GTK_CHECK_VERSION(3,0,0)
73 /* we still use GDK_* instead of GDK_KEY_* */
74 #include <gdk/gdkkeysyms-compat.h>
75 #endif
77 #include <webkit/webkit.h>
78 #include <libsoup/soup.h>
79 #include <JavaScriptCore/JavaScript.h>
80 #include <gnutls/gnutls.h>
81 #include <gnutls/x509.h>
83 /* comment if you don't want to use threads */
84 #define USE_THREADS
86 #ifdef USE_THREADS
87 #include <gcrypt.h>
88 #include <pthread.h>
90 /* #define USE_FLUSH */
91 #ifdef USE_FLUSH
92 #define GDK_FLUSH() do { gdk_flush(); } while (0)
93 #else
94 #define GDK_FLUSH()
95 #endif /* USE_FLUSH */
97 #endif
99 /* set if you don't want to use signals */
100 #ifndef XT_SIGNALS_DISABLE
101 #include <sys/wait.h>
102 #endif
104 /* set if you don't want to use resource limits */
105 #ifndef XT_RESOURCE_LIMITS_DISABLE
106 #include <sys/resource.h>
107 #endif
109 #include "javascript.h"
111 javascript.h borrowed from vimprobable2 under the following license:
113 Copyright (c) 2009 Leon Winter
114 Copyright (c) 2009-2011 Hannes Schueller
115 Copyright (c) 2009-2010 Matto Fransen
116 Copyright (c) 2010-2011 Hans-Peter Deifel
117 Copyright (c) 2010-2011 Thomas Adam
118 Copyright (c) 2011 Albert Kim
119 Copyright (c) 2011 Daniel Carl
121 Permission is hereby granted, free of charge, to any person obtaining a copy
122 of this software and associated documentation files (the "Software"), to deal
123 in the Software without restriction, including without limitation the rights
124 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
125 copies of the Software, and to permit persons to whom the Software is
126 furnished to do so, subject to the following conditions:
128 The above copyright notice and this permission notice shall be included in
129 all copies or substantial portions of the Software.
131 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
132 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
133 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
134 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
135 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
136 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
137 THE SOFTWARE.
140 /*#define XT_DEBUG*/
141 #ifdef XT_DEBUG
142 #define DPRINTF(x...) do { if (swm_debug) fprintf(stderr, x); } while (0)
143 #define DNPRINTF(n,x...) do { if (swm_debug & n) fprintf(stderr, x); } while (0)
144 #define XT_D_MOVE 0x0001
145 #define XT_D_KEY 0x0002
146 #define XT_D_TAB 0x0004
147 #define XT_D_URL 0x0008
148 #define XT_D_CMD 0x0010
149 #define XT_D_NAV 0x0020
150 #define XT_D_DOWNLOAD 0x0040
151 #define XT_D_CONFIG 0x0080
152 #define XT_D_JS 0x0100
153 #define XT_D_FAVORITE 0x0200
154 #define XT_D_PRINTING 0x0400
155 #define XT_D_COOKIE 0x0800
156 #define XT_D_KEYBINDING 0x1000
157 #define XT_D_CLIP 0x2000
158 #define XT_D_BUFFERCMD 0x4000
159 #define XT_D_INSPECTOR 0x8000
160 #define XT_D_VISITED 0x10000
161 #define XT_D_HISTORY 0x20000
162 #define XT_D_MISC 0x40000
163 #define XT_D_CUSTOM_URI 0x80000
164 #define XT_D_CMD_ALIAS 0x100000
165 #define XT_D_SEARCH 0x200000
166 #define XT_D_MTX 0x400000
167 extern uint32_t swm_debug;
168 #else
169 #define DPRINTF(x...)
170 #define DNPRINTF(n,x...)
171 #endif
173 #define LENGTH(x) (sizeof x / sizeof x[0])
174 #define CLEAN(mask) (mask & ~(GDK_MOD2_MASK) & \
175 ~(GDK_BUTTON1_MASK) & \
176 ~(GDK_BUTTON2_MASK) & \
177 ~(GDK_BUTTON3_MASK) & \
178 ~(GDK_BUTTON4_MASK) & \
179 ~(GDK_BUTTON5_MASK))
181 #define XT_MARKS "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'"
182 #define XT_NOMARKS (sizeof(XT_MARKS) - 1)
183 #define XT_QMARKS "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
184 #define XT_NOQMARKS (sizeof(XT_QMARKS) - 1)
186 /* Path Separator */
187 #ifndef PS
188 #define PS "/"
189 #define PSC '/'
190 #endif
192 struct tab {
193 TAILQ_ENTRY(tab) entry;
194 GtkWidget *vbox;
195 GtkWidget *tab_content;
196 struct {
197 GtkWidget *label;
198 GtkWidget *favicon;
199 GtkWidget *eventbox;
200 GtkWidget *box;
201 } tab_elems;
202 GtkWidget *label;
203 GtkWidget *spinner;
204 GtkWidget *uri_entry;
205 #if !GTK_CHECK_VERSION(3, 0, 0)
206 GtkStyle *default_style;
207 #endif
208 GtkWidget *search_entry;
209 GtkWidget *toolbar;
210 GtkWidget *browser_win;
211 GtkWidget *statusbar_box;
212 struct {
213 GtkWidget *statusbar;
214 GtkWidget *buffercmd;
215 GtkWidget *zoom;
216 GtkWidget *position;
217 GtkWidget *tabs;
218 GtkWidget *proxy;
219 } sbe;
220 GtkWidget *cmd;
221 GtkWidget *buffers;
222 GtkWidget *oops;
223 GtkWidget *backward;
224 GtkWidget *forward;
225 GtkWidget *stop;
226 GtkWidget *gohome;
227 GtkWidget *js_toggle;
228 GtkEntryCompletion *completion;
229 guint tab_id;
230 WebKitWebView *wv;
232 WebKitWebHistoryItem *item;
233 WebKitWebBackForwardList *bfl;
235 /* favicon */
236 WebKitNetworkRequest *icon_request;
237 WebKitDownload *icon_download;
238 gchar *icon_dest_uri;
240 /* adjustments for browser */
241 GtkAdjustment *adjust_h;
242 GtkAdjustment *adjust_v;
244 /* flags */
245 int mode;
246 #define XT_MODE_COMMAND (0)
247 #define XT_MODE_INSERT (1)
248 #define XT_MODE_HINT (2)
249 #define XT_MODE_PASSTHROUGH (3)
250 int (*mode_cb)(struct tab *, GdkEventKey *, gpointer);
251 gpointer mode_cb_data;
252 int focus_wv;
253 int ctrl_click;
254 gchar *status;
255 int xtp_meaning; /* identifies dls/favorites */
256 int xtp_arg;
257 gchar *tmp_uri;
258 int popup; /* 1 if cmd_entry has popup visible */
259 int download_requested;
260 #ifdef USE_THREADS
261 /* https thread stuff */
262 GThread *thread;
263 #endif
264 /* hints */
265 int script_init;
266 int new_tab;
268 /* custom stylesheet */
269 int styled;
270 char *stylesheet;
272 /* search */
273 char *search_text;
274 int search_forward;
275 guint search_id;
277 /* settings */
278 WebKitWebSettings *settings;
279 gchar *user_agent;
280 int user_agent_id;
281 int http_accept_id;
282 gboolean load_images;
284 /* marks */
285 double mark[XT_NOMARKS];
287 /* inspector */
288 WebKitWebInspector *inspector;
289 GtkWidget *inspector_window;
290 GtkWidget *inspector_view;
292 /* focused text entry */
293 #if WEBKIT_CHECK_VERSION(1, 5, 0)
294 WebKitDOMElement *active;
295 char *active_text;
296 #endif
298 TAILQ_HEAD(tab_list, tab);
300 struct karg {
301 int i;
302 char *s;
303 int precount;
304 void *ptr;
307 struct download {
308 RB_ENTRY(download) entry;
309 int id;
310 WebKitDownload *download;
311 struct tab *tab;
313 RB_HEAD(download_list, download);
314 RB_PROTOTYPE(download_list, download, entry, download_rb_cmp);
316 struct history {
317 RB_ENTRY(history) entry;
318 gchar *uri;
319 gchar *title;
320 time_t time; /* When the item was added. */
322 RB_HEAD(history_list, history);
323 RB_PROTOTYPE(history_list, history, entry, history_rb_cmp);
325 #define XT_STS_FLAGS_INCLUDE_SUBDOMAINS (1)
326 #define XT_STS_FLAGS_EXPAND (2)
327 #define XT_STS_FILE ("strict-transport")
329 struct strict_transport {
330 RB_ENTRY(strict_transport) entry;
331 gchar *host;
332 time_t timeout;
333 int flags;
335 RB_HEAD(strict_transport_tree, strict_transport);
336 RB_PROTOTYPE(strict_transport_tree, strict_transport, entry, strict_transport_rb_cmp);
338 struct secviolation {
339 RB_ENTRY(secviolation) entry;
340 int xtp_arg;
341 struct tab *t;
342 char *uri;
344 RB_HEAD(secviolation_list, secviolation);
345 RB_PROTOTYPE(secviolation_list, secviolation, entry, secviolation_rb_cmp);
347 struct sv_ignore {
348 RB_ENTRY(sv_ignore) entry;
349 char *domain;
351 RB_HEAD(sv_ignore_list, sv_ignore);
352 RB_PROTOTYPE(sv_ignore_list, sv_ignore, entry, sv_ignore_rb_cmp);
354 struct user_agent {
355 RB_ENTRY(user_agent) entry;
356 int id;
357 char *value;
359 RB_HEAD(user_agent_list, user_agent);
360 RB_PROTOTYPE(user_agent_list, user_agent, entry, user_agent_rb_cmp);
362 struct http_accept {
363 RB_ENTRY(http_accept) entry;
364 int id;
365 char *value;
367 RB_HEAD(http_accept_list, http_accept);
368 RB_PROTOTYPE(http_accept_list, http_accept, entry, http_accept_rb_cmp);
370 /* utility */
371 #define XT_NAME ("xombrero")
372 #define XT_CB_HANDLED (TRUE)
373 #define XT_CB_PASSTHROUGH (FALSE)
374 #define XT_CONF_FILE ("xombrero.conf")
375 #define XT_CSS_FILE ("xombrero.css")
376 #define XT_FAVS_FILE ("favorites")
377 #define XT_SOD_FILE ("startofday")
378 #define XT_RESERVED_CHARS "$&+,/:;=?@ \"<>#%%{}|^~[]`"
380 int run_script(struct tab *, char *);
381 void xt_icon_from_file(struct tab *, char *);
382 GtkWidget *create_window(const gchar *);
383 void show_oops(struct tab *, const char *, ...);
384 gchar *get_html_page(gchar *, gchar *, gchar *, bool);
385 const gchar *get_uri(struct tab *);
386 const gchar *get_title(struct tab *, bool);
387 void load_uri(struct tab *t, gchar *uri);
388 gboolean match_uri(const gchar *uri, const gchar *key);
389 int valid_url_type(char *);
390 void expand_tilde(char *, size_t, const char *);
391 char *html_escape(const char *val);
392 void set_status(struct tab *t, gchar *fmt, ...);
394 void load_webkit_string(struct tab *, const char *, gchar *);
395 void button_set_stockid(GtkWidget *, char *);
397 /* cookies */
398 int remove_cookie(int);
399 int remove_cookie_domain(int);
400 int remove_cookie_all(void);
401 void print_cookie(char *msg, SoupCookie *);
402 void setup_cookies(void);
404 /* history */
405 int insert_history_item(const gchar *uri, const gchar *title, time_t time);
406 int save_global_history_to_disk(struct tab *t);
407 int restore_global_history(void);
408 char *color_visited_helper(void);
409 int color_visited(struct tab *t, char *visited);
411 /* completion */
412 void completion_add(struct tab *);
413 void completion_add_uri(const gchar *uri);
415 /* external editor */
416 #define XT_EE_BUFSZ (64 * 1024)
417 int edit_src(struct tab *t, struct karg *args);
418 int edit_element(struct tab *t, struct karg *a);
420 /* proxy */
421 #define XT_PRXY_SHOW (1<<0)
422 #define XT_PRXY_TOGGLE (1<<1)
424 /* inspector */
425 #define XT_INS_SHOW (1<<0)
426 #define XT_INS_HIDE (1<<1)
427 #define XT_INS_CLOSE (1<<2)
429 WebKitWebView* inspector_inspect_web_view_cb(WebKitWebInspector *,
430 WebKitWebView*, struct tab *);
431 void setup_inspector(struct tab *);
432 int inspector_cmd(struct tab *, struct karg *);
434 /* tld public suffix */
435 void tld_tree_init();
436 char *tld_get_suffix(const char *);
438 /* about */
439 #define XT_XTP_STR "xxxt://"
440 #define XT_URI_ABOUT ("about:")
441 #define XT_URI_ABOUT_LEN (strlen(XT_URI_ABOUT))
442 #define XT_URI_ABOUT_ABOUT ("about")
443 #define XT_URI_ABOUT_ALLTHETHINGS ("allthethings")
444 #define XT_URI_ABOUT_BLANK ("blank")
445 #define XT_URI_ABOUT_CERTS ("certs")
446 #define XT_URI_ABOUT_COOKIEWL ("cookiewl")
447 #define XT_URI_ABOUT_COOKIEJAR ("cookiejar")
448 #define XT_URI_ABOUT_DOWNLOADS ("downloads")
449 #define XT_URI_ABOUT_FAVORITES ("favorites")
450 #define XT_URI_ABOUT_HELP ("help")
451 #define XT_URI_ABOUT_HISTORY ("history")
452 #define XT_URI_ABOUT_JSWL ("jswl")
453 #define XT_URI_ABOUT_PLUGINWL ("plwl")
454 #define XT_URI_ABOUT_SET ("set")
455 #define XT_URI_ABOUT_STATS ("stats")
456 #define XT_URI_ABOUT_MARCO ("marco")
457 #define XT_URI_ABOUT_STARTPAGE ("startpage")
458 #define XT_URI_ABOUT_WEBKIT ("webkit")
459 #define XT_URI_ABOUT_SEARCH ("search")
460 #define XT_URI_ABOUT_SECVIOLATION ("secviolation")
462 struct about_type {
463 char *name;
464 int (*func)(struct tab *, struct karg *);
467 struct sp {
468 char *line;
469 TAILQ_ENTRY(sp) entry;
471 TAILQ_HEAD(sp_list, sp);
473 int blank(struct tab *, struct karg *);
474 int help(struct tab *, struct karg *);
475 int stats(struct tab *, struct karg *);
476 void show_certs(struct tab *, gnutls_x509_crt_t *,
477 size_t, char *);
478 int ca_cmd(struct tab *, struct karg *);
479 int cookie_show_wl(struct tab *, struct karg *);
480 int xtp_page_ab(struct tab *, struct karg *);
481 int xtp_page_cl(struct tab *, struct karg *);
482 int xtp_page_dl(struct tab *, struct karg *);
483 int xtp_page_fl(struct tab *, struct karg *);
484 int xtp_page_hl(struct tab *, struct karg *);
485 int xtp_page_sl(struct tab *, struct karg *);
486 int xtp_page_sv(struct tab *, struct karg *);
487 int parse_xtp_url(struct tab *, const char *);
488 int add_favorite(struct tab *, struct karg *);
489 void update_favorite_tabs(struct tab *);
490 void update_history_tabs(struct tab *);
491 void update_download_tabs(struct tab *);
492 void xtp_generate_keys(void);
493 size_t about_list_size(void);
494 int cookie_cmd(struct tab *, struct karg *);
495 int js_cmd(struct tab *, struct karg *);
496 int pl_cmd(struct tab *, struct karg *);
497 void startpage_add(const char *, ...);
500 * xtp tab meanings
501 * identifies which tabs have xtp pages in (corresponding to about_list indices)
503 #define XT_XTP_TAB_MEANING_NORMAL (-1) /* normal url */
504 #define XT_XTP_TAB_MEANING_BL (1) /* about:blank in this tab */
505 #define XT_XTP_TAB_MEANING_CL (4) /* cookie manager in this tab */
506 #define XT_XTP_TAB_MEANING_DL (5) /* download manager in this tab */
507 #define XT_XTP_TAB_MEANING_FL (6) /* favorite manager in this tab */
508 #define XT_XTP_TAB_MEANING_HL (8) /* history manager in this tab */
509 #define XT_XTP_TAB_MEANING_SL (9) /* search engine chooser */
510 #define XT_XTP_TAB_MEANING_AB (10) /* about:about in this tab */
511 #define XT_XTP_TAB_MEANING_SV (18) /* about:secviolation in tab */
513 /* whitelists */
514 #define XT_WL_TOGGLE (1<<0)
515 #define XT_WL_ENABLE (1<<1)
516 #define XT_WL_DISABLE (1<<2)
517 #define XT_WL_FQDN (1<<3) /* default */
518 #define XT_WL_TOPLEVEL (1<<4)
519 #define XT_WL_PERSISTENT (1<<5)
520 #define XT_WL_SESSION (1<<6)
521 #define XT_WL_RELOAD (1<<7)
522 #define XT_SHOW (1<<8)
523 #define XT_DELETE (1<<9)
524 #define XT_SAVE (1<<10)
525 #define XT_OPEN (1<<11)
526 #define XT_CACHE (1<<12)
528 #define XT_WL_INVALID (0)
529 #define XT_WL_JAVASCRIPT (1)
530 #define XT_WL_COOKIE (2)
531 #define XT_WL_PLUGIN (3)
533 struct domain {
534 RB_ENTRY(domain) entry;
535 gchar *d;
536 int handy; /* app use */
538 RB_HEAD(domain_list, domain);
539 RB_PROTOTYPE(domain_list, domain, entry, domain_rb_cmp);
541 int wl_show(struct tab *, struct karg *, char *,
542 struct domain_list *);
544 /* uri aliases */
545 struct alias {
546 char *a_name;
547 char *a_uri;
548 TAILQ_ENTRY(alias) entry;
550 TAILQ_HEAD(alias_list, alias);
552 /* mime types */
553 struct mime_type {
554 char *mt_type;
555 char *mt_action;
556 int mt_default;
557 int mt_download;
558 TAILQ_ENTRY(mime_type) entry;
560 TAILQ_HEAD(mime_type_list, mime_type);
562 struct domain * wl_find(const gchar *, struct domain_list *);
563 int wl_save(struct tab *, struct karg *, int);
564 int toggle_cwl(struct tab *, struct karg *);
565 int toggle_js(struct tab *, struct karg *);
566 int toggle_pl(struct tab *, struct karg *);
568 /* input autofocus */
569 void input_autofocus(struct tab *);
570 void *input_check_mode(struct tab *);
571 int command_mode(struct tab *, struct karg *);
573 /* settings */
574 #define XT_BM_NORMAL (0)
575 #define XT_BM_WHITELIST (1)
576 #define XT_BM_KIOSK (2)
578 #define XT_GM_CLASSIC (0)
579 #define XT_GM_MINIMAL (1)
581 #define XT_TABS_NORMAL (0)
582 #define XT_TABS_COMPACT (1)
584 #define XT_STATUSBAR_URL (0)
585 #define XT_STATUSBAR_TITLE (1)
587 #define XT_EM_HYBRID (0)
588 #define XT_EM_VI (1)
590 #define XT_DM_START (0)
591 #define XT_DM_ASK (1)
592 #define XT_DM_ADD (2)
594 #define XT_REFERER_ALWAYS (0)
595 #define XT_REFERER_NEVER (1)
596 #define XT_REFERER_SAME_DOMAIN (2)
597 #define XT_REFERER_CUSTOM (3)
598 #define XT_REFERER_SAME_FQDN (4)
600 #define CTRL GDK_CONTROL_MASK
601 #define MOD1 GDK_MOD1_MASK
602 #define SHFT GDK_SHIFT_MASK
604 /* runtime default settings */
605 #define XT_DS_SHOW_TABS (1)
606 #define XT_DS_TAB_STYLE XT_TABS_NORMAL
607 #define XT_DS_STATUSBAR_STYLE XT_STATUSBAR_URL
608 #define XT_DS_SHOW_URL (1)
609 #define XT_DS_SHOW_SCROLLBARS (1)
610 #define XT_DS_SHOW_STATUSBAR (0)
611 #define XT_DS_CTRL_CLICK_FOCUS (0)
612 #define XT_DS_COOKIES_ENABLED (1)
613 #define XT_DS_READ_ONLY_COOKIES (0)
614 #define XT_DS_ENABLE_SCRIPTS (1)
615 #define XT_DS_ENABLE_PLUGINS (1)
616 #define XT_DS_DEFAULT_ZOOM_LEVEL (1.0)
617 #define XT_DS_DEFAULT_SCRIPT ("")
618 #define XT_DS_REFRESH_INTERVAL (10)
619 #define XT_DS_ENABLE_PLUGIN_WHITELIST (0)
620 #define XT_DS_ENABLE_COOKIE_WHITELIST (0)
621 #define XT_DS_ENABLE_JS_WHITELIST (0)
622 #define XT_DS_ENABLE_LOCALSTORAGE (1)
623 #define XT_DS_SESSION_TIMEOUT (3600)
624 #define XT_DS_COOKIE_POLICY SOUP_COOKIE_JAR_ACCEPT_ALWAYS
625 #define XT_DS_SSL_STRICT_CERTS FALSE
626 #define XT_DS_SSL_CA_FILE ("")
627 #define XT_DS_ENABLE_STRICT_TRANSPORT TRUE
628 #define XT_DS_APPEND_NEXT (1)
629 #define XT_DS_HOME ("https://www.cyphertite.com/")
630 #define XT_DS_SEARCH_STRING ("about:search")
631 #define XT_DS_COLOR_VISITED_URIS (1)
632 #define XT_DS_SESSION_AUTOSAVE (0)
633 #define XT_DS_GUESS_SEARCH (0)
634 #define XT_DS_ENABLE_SPELL_CHECKING (0)
635 #define XT_DS_SPELL_CHECK_LANGUAGES ("en_US")
636 #define XT_DS_URL_REGEX ("^[[:blank:]]*[^[:blank:]]*([[:alnum:]-]+\\.)+[[:alnum:]-][^[:blank:]]*[[:blank:]]*$")
637 #define XT_DS_ENCODING ("UTF-8")
638 #define XT_DS_AUTOFOCUS_ONLOAD (0)
639 #define XT_DS_ENABLE_JS_AUTORUN (1)
640 #define XT_DS_USERSTYLE_GLOBAL (0)
641 #define XT_DS_AUTO_LOAD_IMAGES (1)
642 #define XT_DS_ENABLE_AUTOSCROLL (0)
643 #define XT_DS_ENABLE_FAVICON_ENTRY (1)
644 #define XT_DS_ENABLE_FAVICON_TABS (0)
645 #define XT_DS_EXTERNAL_EDITOR ("")
646 #define XT_DS_REFERER_MODE XT_REFERER_ALWAYS
647 #define XT_DS_REFERER_CUSTOM ("always")
648 #define XT_DS_DOWNLOAD_NOTIFICATIONS (0)
649 #define XT_DS_CMD_FONT_NAME ("monospace normal 9")
650 #define XT_DS_OOPS_FONT_NAME ("monospace normal 9")
651 #define XT_DS_STATUSBAR_FONT_NAME ("monospace normal 9")
652 #define XT_DS_TABBAR_FONT_NAME ("monospace normal 9")
653 #define XT_DS_ALLOW_INSECURE_CONTENT (TRUE)
654 #define XT_DS_ALLOW_INSECURE_SCRIPTS (TRUE)
657 /* actions */
658 #define XT_STYLE_CURRENT_TAB (0)
659 #define XT_STYLE_GLOBAL (1)
661 #define XT_TAB_LAST (-4)
662 #define XT_TAB_FIRST (-3)
663 #define XT_TAB_PREV (-2)
664 #define XT_TAB_NEXT (-1)
665 #define XT_TAB_INVALID (0)
666 #define XT_TAB_NEW (1)
667 #define XT_TAB_DELETE (2)
668 #define XT_TAB_DELQUIT (3)
669 #define XT_TAB_OPEN (4)
670 #define XT_TAB_UNDO_CLOSE (5)
671 #define XT_TAB_SHOW (6)
672 #define XT_TAB_HIDE (7)
673 #define XT_TAB_NEXTSTYLE (8)
674 #define XT_TAB_LOAD_IMAGES (9)
675 #define XT_TAB_ONLY (10)
677 #define XT_URL_SHOW (1)
678 #define XT_URL_HIDE (2)
680 struct key_binding {
681 char *cmd;
682 guint mask;
683 guint use_in_entry;
684 guint key;
685 TAILQ_ENTRY(key_binding) entry; /* in bss so no need to init */
687 TAILQ_HEAD(keybinding_list, key_binding);
689 struct custom_uri {
690 char *uri;
691 char cmd[PATH_MAX];
692 TAILQ_ENTRY(custom_uri) entry;
694 TAILQ_HEAD(custom_uri_list, custom_uri);
696 struct cmd_alias {
697 char *alias;
698 char *cmd;
699 TAILQ_ENTRY(cmd_alias) entry;
701 TAILQ_HEAD(cmd_alias_list, cmd_alias);
703 struct settings {
704 char *name;
705 int type;
706 #define XT_S_INVALID (0)
707 #define XT_S_INT (1)
708 #define XT_S_STR (2)
709 #define XT_S_FLOAT (3)
710 uint32_t flags;
711 #define XT_SF_RESTART (1<<0)
712 #define XT_SF_RUNTIME (1<<1)
713 int *ival;
714 char **sval;
715 struct special *s;
716 gfloat *fval;
717 int (*activate)(char *);
720 int set(struct tab *, struct karg *);
721 size_t get_settings_size(void);
722 int settings_add(char *, char *);
723 void setup_proxy(char *);
724 int set_browser_mode(struct settings *, char *);
725 int set_encoding(struct tab *, struct karg *);
726 int set_gui_mode(struct settings *, char *);
727 int set_cookie_policy(struct settings *, char *);
728 int set_search_string(char *);
729 int set_ssl_ca_file(struct settings *, char *);
730 char *get_browser_mode(struct settings *);
731 char *get_gui_mode(struct settings *);
732 char *get_cookie_policy(struct settings *);
733 void init_keybindings(void);
734 void config_parse(char *, int);
735 char *get_setting_name(int);
736 void statusbar_set_visibility(void);
737 int tabaction(struct tab *, struct karg *);
738 int urlaction(struct tab *, struct karg *);
739 int userstyle_cmd(struct tab *, struct karg *);
740 struct tab *get_current_tab(void);
741 int resizetab(struct tab *, struct karg *);
742 int cert_cmd(struct tab *, struct karg *);
743 void focus_webview(struct tab *);
744 int is_g_object_setting(GObject *, char *);
745 int set_scrollbar_visibility(struct tab *, int);
747 #define XT_DL_START (0)
748 #define XT_DL_RESTART (1)
749 int download_start(struct tab *, struct download *, int flag);
751 extern int tabless;
752 extern int enable_socket;
753 extern int single_instance;
754 extern int fancy_bar;
755 extern int browser_mode;
756 extern int enable_localstorage;
757 extern char *statusbar_elems;
758 extern SoupURI *proxy_uri;
760 extern int show_tabs;
761 extern int tab_style;
762 extern int statusbar_style;
763 extern int show_url;
764 extern int show_scrollbars;
765 extern int show_statusbar;
766 extern int ctrl_click_focus;
767 extern int cookies_enabled;
768 extern int read_only_cookies;
769 extern int enable_scripts;
770 extern int enable_plugins;
771 extern gfloat default_zoom_level;
772 extern char default_script[PATH_MAX];
773 extern int window_height;
774 extern int window_width;
775 extern int window_maximize;
776 extern int icon_size;
777 extern int refresh_interval;
778 extern int enable_plugin_whitelist;
779 extern int enable_cookie_whitelist;
780 extern int enable_js_whitelist;
781 extern int session_timeout;
782 extern int cookie_policy;
783 extern char ssl_ca_file[PATH_MAX];
784 extern char *resource_dir;
785 extern gboolean ssl_strict_certs;
786 extern gboolean enable_strict_transport;
787 extern int append_next;
788 extern char *home;
789 extern char *search_string;
790 extern char *http_proxy;
791 extern int http_proxy_starts_enabled;
792 extern char *external_editor;
793 extern char download_dir[PATH_MAX];
794 extern int download_mode;
795 extern char runtime_settings[PATH_MAX];
796 extern int allow_volatile_cookies;
797 extern int color_visited_uris;
798 extern int save_global_history;
799 extern struct user_agent *user_agent;
800 extern struct http_accept *http_accept;
801 extern int save_rejected_cookies;
802 extern int session_autosave;
803 extern int guess_search;
804 extern gint max_connections;
805 extern gint max_host_connections;
806 extern gint enable_spell_checking;
807 extern char *spell_check_languages;
808 extern char *url_regex;
809 extern int history_autosave;
810 extern char search_file[PATH_MAX];
811 extern char command_file[PATH_MAX];
812 extern char *encoding;
813 extern int autofocus_onload;
814 extern int enable_js_autorun;
815 extern char *cmd_font_name;
816 extern char *oops_font_name;
817 extern char *statusbar_font_name;
818 extern char *tabbar_font_name;
819 extern int edit_mode;
820 extern char *userstyle;
821 extern char *stylesheet;
822 extern int userstyle_global;
823 extern int auto_load_images;
824 extern int enable_autoscroll;
825 extern int enable_favicon_entry;
826 extern int enable_favicon_tabs;
827 extern int referer_mode;
828 extern char *referer_custom;
829 extern int download_notifications;
830 extern int warn_cert_changes;
831 extern regex_t url_re;
832 extern int allow_insecure_content;
833 extern int allow_insecure_scripts;
835 /* globals */
836 extern void (*os_init)(void);
837 extern char *version;
838 extern char *icons[];
839 extern char rc_fname[PATH_MAX];
840 extern char work_dir[PATH_MAX];
841 extern char temp_dir[PATH_MAX];
842 extern struct passwd *pwd;
843 extern SoupCookieJar *s_cookiejar;
844 extern SoupCookieJar *p_cookiejar;
845 extern SoupSession *session;
846 extern GtkNotebook *notebook;
847 extern GtkListStore *completion_model;
848 extern uint64_t blocked_cookies;
850 extern void (*_soup_cookie_jar_add_cookie)(SoupCookieJar *, SoupCookie *);
852 extern struct history_list hl;
853 extern int hl_purge_count;
854 extern struct download_list downloads;
855 extern struct tab_list tabs;
856 extern struct about_type about_list[];
857 extern struct domain_list c_wl;
858 extern struct domain_list js_wl;
859 extern struct domain_list pl_wl;
860 extern struct strict_transport_tree st_tree;
861 extern struct alias_list aliases;
862 extern struct mime_type_list mtl;
863 extern struct keybinding_list kbl;
864 extern struct sp_list spl;
865 extern struct user_agent_list ua_list;
866 extern struct http_accept_list ha_list;
867 extern struct cmd_alias_list cal;
868 extern struct custom_uri_list cul;
869 extern struct secviolation_list svl;
870 extern struct sv_ignore_list svil;
872 extern PangoFontDescription *cmd_font;
873 extern PangoFontDescription *oops_font;
874 extern PangoFontDescription *statusbar_font;
875 extern PangoFontDescription *tabbar_font;