Adding disk cache support for soup.
This is a merge of the patch of Ben Woolley <tautolog@gmail.com>
This commit is contained in:
parent
24ec46fc24
commit
117d484833
19
config.def.h
19
config.def.h
|
@ -4,6 +4,7 @@ static char *useragent = "Mozilla/5.0 (X11; U; Unix; en-US) "
|
||||||
"Safari/537.15 Surf/"VERSION;
|
"Safari/537.15 Surf/"VERSION;
|
||||||
static char *scriptfile = "~/.surf/script.js";
|
static char *scriptfile = "~/.surf/script.js";
|
||||||
static char *styledir = "~/.surf/styles/";
|
static char *styledir = "~/.surf/styles/";
|
||||||
|
static char *cachefolder = "~/.surf/cache/";
|
||||||
|
|
||||||
static Bool kioskmode = FALSE; /* Ignore shortcuts */
|
static Bool kioskmode = FALSE; /* Ignore shortcuts */
|
||||||
static Bool showindicators = TRUE; /* Show indicators in window title */
|
static Bool showindicators = TRUE; /* Show indicators in window title */
|
||||||
|
@ -22,15 +23,17 @@ static char *strictssl = FALSE; /* Refuse untrusted SSL connections */
|
||||||
static time_t sessiontime = 3600;
|
static time_t sessiontime = 3600;
|
||||||
|
|
||||||
/* Webkit default features */
|
/* Webkit default features */
|
||||||
static Bool enablescrollbars = TRUE;
|
static Bool enablescrollbars = TRUE;
|
||||||
static Bool enablespatialbrowsing = TRUE;
|
static Bool enablespatialbrowsing = TRUE;
|
||||||
static Bool enableplugins = TRUE;
|
static Bool enablediskcache = TRUE;
|
||||||
static Bool enablescripts = TRUE;
|
static int diskcachebytes = 5 * 1024 * 1024;
|
||||||
static Bool enableinspector = TRUE;
|
static Bool enableplugins = TRUE;
|
||||||
static Bool enablestyles = TRUE;
|
static Bool enablescripts = TRUE;
|
||||||
static Bool loadimages = TRUE;
|
static Bool enableinspector = TRUE;
|
||||||
static Bool hidebackground = FALSE;
|
static Bool enablestyles = TRUE;
|
||||||
static Bool allowgeolocation = TRUE;
|
static Bool loadimages = TRUE;
|
||||||
|
static Bool hidebackground = FALSE;
|
||||||
|
static Bool allowgeolocation = TRUE;
|
||||||
|
|
||||||
#define SETPROP(p, q) { \
|
#define SETPROP(p, q) { \
|
||||||
.v = (char *[]){ "/bin/sh", "-c", \
|
.v = (char *[]){ "/bin/sh", "-c", \
|
||||||
|
|
30
surf.c
30
surf.c
|
@ -85,11 +85,12 @@ static GdkNativeWindow embed = 0;
|
||||||
static gboolean showxid = FALSE;
|
static gboolean showxid = FALSE;
|
||||||
static char winid[64];
|
static char winid[64];
|
||||||
static gboolean usingproxy = 0;
|
static gboolean usingproxy = 0;
|
||||||
static char togglestat[8];
|
static char togglestat[9];
|
||||||
static char pagestat[3];
|
static char pagestat[3];
|
||||||
static GTlsDatabase *tlsdb;
|
static GTlsDatabase *tlsdb;
|
||||||
static int policysel = 0;
|
static int policysel = 0;
|
||||||
static char *stylefile = NULL;
|
static char *stylefile = NULL;
|
||||||
|
static SoupCache *diskcache = NULL;
|
||||||
|
|
||||||
static void addaccelgroup(Client *c);
|
static void addaccelgroup(Client *c);
|
||||||
static void beforerequest(WebKitWebView *w, WebKitWebFrame *f,
|
static void beforerequest(WebKitWebView *w, WebKitWebFrame *f,
|
||||||
|
@ -270,6 +271,10 @@ buttonrelease(WebKitWebView *web, GdkEventButton *e, GList *gl) {
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cleanup(void) {
|
cleanup(void) {
|
||||||
|
if (diskcache) {
|
||||||
|
soup_cache_flush(diskcache);
|
||||||
|
soup_cache_dump(diskcache);
|
||||||
|
}
|
||||||
while(clients)
|
while(clients)
|
||||||
destroyclient(clients);
|
destroyclient(clients);
|
||||||
g_free(cookiefile);
|
g_free(cookiefile);
|
||||||
|
@ -677,6 +682,10 @@ loadstatuschange(WebKitWebView *view, GParamSpec *pspec, Client *c) {
|
||||||
case WEBKIT_LOAD_FINISHED:
|
case WEBKIT_LOAD_FINISHED:
|
||||||
c->progress = 100;
|
c->progress = 100;
|
||||||
updatetitle(c);
|
updatetitle(c);
|
||||||
|
if (diskcache) {
|
||||||
|
soup_cache_flush(diskcache);
|
||||||
|
soup_cache_dump(diskcache);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -972,6 +981,8 @@ newwindow(Client *c, const Arg *arg, gboolean noembed) {
|
||||||
cmd[i++] = "-s";
|
cmd[i++] = "-s";
|
||||||
if(showxid)
|
if(showxid)
|
||||||
cmd[i++] = "-x";
|
cmd[i++] = "-x";
|
||||||
|
if(enablediskcache)
|
||||||
|
cmd[i++] = "-D";
|
||||||
cmd[i++] = "-c";
|
cmd[i++] = "-c";
|
||||||
cmd[i++] = cookiefile;
|
cmd[i++] = cookiefile;
|
||||||
cmd[i++] = "--";
|
cmd[i++] = "--";
|
||||||
|
@ -1149,6 +1160,7 @@ setup(void) {
|
||||||
/* dirs and files */
|
/* dirs and files */
|
||||||
cookiefile = buildpath(cookiefile);
|
cookiefile = buildpath(cookiefile);
|
||||||
scriptfile = buildpath(scriptfile);
|
scriptfile = buildpath(scriptfile);
|
||||||
|
cachefolder = buildpath(cachefolder);
|
||||||
styledir = buildpath(styledir);
|
styledir = buildpath(styledir);
|
||||||
if(stylefile == NULL && enablestyles) {
|
if(stylefile == NULL && enablestyles) {
|
||||||
for(i = 0; i < LENGTH(styles); i++) {
|
for(i = 0; i < LENGTH(styles); i++) {
|
||||||
|
@ -1175,6 +1187,14 @@ setup(void) {
|
||||||
SOUP_SESSION_FEATURE(cookiejar_new(cookiefile, FALSE,
|
SOUP_SESSION_FEATURE(cookiejar_new(cookiefile, FALSE,
|
||||||
cookiepolicy_get())));
|
cookiepolicy_get())));
|
||||||
|
|
||||||
|
/* disk cache */
|
||||||
|
if(enablediskcache) {
|
||||||
|
diskcache = soup_cache_new(cachefolder, SOUP_CACHE_SINGLE_USER);
|
||||||
|
soup_cache_set_max_size(diskcache, diskcachebytes);
|
||||||
|
soup_cache_load(diskcache);
|
||||||
|
soup_session_add_feature(s, SOUP_SESSION_FEATURE(diskcache));
|
||||||
|
}
|
||||||
|
|
||||||
/* ssl */
|
/* ssl */
|
||||||
tlsdb = g_tls_file_database_new(cafile, &error);
|
tlsdb = g_tls_file_database_new(cafile, &error);
|
||||||
|
|
||||||
|
@ -1363,6 +1383,8 @@ gettogglestat(Client *c){
|
||||||
|
|
||||||
togglestat[p++] = allowgeolocation? 'G': 'g';
|
togglestat[p++] = allowgeolocation? 'G': 'g';
|
||||||
|
|
||||||
|
togglestat[p++] = enablediskcache? 'D': 'd';
|
||||||
|
|
||||||
g_object_get(G_OBJECT(settings), "auto-load-images", &value, NULL);
|
g_object_get(G_OBJECT(settings), "auto-load-images", &value, NULL);
|
||||||
togglestat[p++] = value? 'I': 'i';
|
togglestat[p++] = value? 'I': 'i';
|
||||||
|
|
||||||
|
@ -1479,6 +1501,12 @@ main(int argc, char *argv[]) {
|
||||||
case 'c':
|
case 'c':
|
||||||
cookiefile = EARGF(usage());
|
cookiefile = EARGF(usage());
|
||||||
break;
|
break;
|
||||||
|
case 'd':
|
||||||
|
enablediskcache = 0;
|
||||||
|
break;
|
||||||
|
case 'D':
|
||||||
|
enablediskcache = 1;
|
||||||
|
break;
|
||||||
case 'e':
|
case 'e':
|
||||||
embed = strtol(EARGF(usage()), NULL, 0);
|
embed = strtol(EARGF(usage()), NULL, 0);
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user