diff options
author | Marco Peereboom <marco@conformal.com> | 2010-02-21 17:25:36 +0000 |
---|---|---|
committer | Marco Peereboom <marco@conformal.com> | 2010-02-21 17:25:36 +0000 |
commit | 23bcfabcf93f5f7cdcabc9cb26eb0964f6bc4700 (patch) | |
tree | b7c6aff1faaca61c00944bee1afabfbb557ddeb9 | |
parent | 78fb9823aa4206d32e06a17dbc0bd34e08a808c6 (diff) | |
download | xombrero-23bcfabcf93f5f7cdcabc9cb26eb0964f6bc4700.tar.gz |
Add cookie support. Can't be disabled for now.
-rw-r--r-- | xxxterm.c | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/xxxterm.c b/xxxterm.c index bc57adf..c59d172 100644 --- a/xxxterm.c +++ b/xxxterm.c @@ -43,6 +43,7 @@ #include <gdk/gdkkeysyms.h> #include <webkit/webkit.h> #include <libsoup/soup.h> +#include <JavaScriptCore/JavaScript.h> static char *version = "$xxxterm$"; @@ -113,6 +114,7 @@ struct karg { }; /* defines */ +#define XT_DIR (".xxxterm") #define XT_CONF_FILE ("xxxterm.conf") #define XT_CB_HANDLED (TRUE) #define XT_CB_PASSTHROUGH (FALSE) @@ -155,7 +157,11 @@ int showurl = 1; /* show url toolbar on notebook */ int tabless = 0; /* allow only 1 tab */ int ctrl_click_focus = 0; /* ctrl click gets focus */ char *home = "http://www.peereboom.us"; +char work_dir[PATH_MAX]; +char cookie_file[PATH_MAX]; char download_dir[PATH_MAX]; +SoupSession *session; +SoupCookieJar *cookiejar; /* protos */ void create_new_tab(char *, int); @@ -1159,15 +1165,34 @@ main(int argc, char *argv[]) /* read config file */ if (strlen(conf) == 0) - snprintf(conf, sizeof conf, "%s/.%s", pwd->pw_dir, - XT_CONF_FILE); + snprintf(conf, sizeof conf, "%s/.%s", + pwd->pw_dir, XT_CONF_FILE); config_parse(conf); if (stat(download_dir, &sb)) errx(1, "must specify a valid download_dir"); + /* working directory */ + snprintf(work_dir, sizeof work_dir, "%s/%s", pwd->pw_dir, XT_DIR); + if (stat(work_dir, &sb)) { + if (mkdir(work_dir, S_IRWXU) == -1) + err(1, "mkdir"); + } else if (((sb.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO))) != S_IRWXU) { + warnx("fixing invalid permissions on %s", work_dir); + if (chmod(work_dir, S_IRWXU) == -1) + err(1, "chmod"); + } + create_canvas(); + /* cookies */ + session = webkit_get_default_session(); + snprintf(cookie_file, sizeof cookie_file, "%s/cookies.txt", work_dir); + fprintf(stderr, "cookies: %s\n", cookie_file); + cookiejar = soup_cookie_jar_text_new(cookie_file, FALSE); + soup_session_add_feature(session, (SoupSessionFeature*)cookiejar); + + while (argc) { create_new_tab(argv[0], focus); focus = 0; |