Merge lp:~kalikiana/midori/cookieswk2 into lp:midori
- cookieswk2
- Merge into trunk
Proposed by
Cris Dywan
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | André Stösel | ||||
Approved revision: | 6268 | ||||
Merged at revision: | 6295 | ||||
Proposed branch: | lp:~kalikiana/midori/cookieswk2 | ||||
Merge into: | lp:midori | ||||
Diff against target: |
1069 lines (+82/-766) 11 files modified
extensions/cookie-manager/cookie-manager.c (+10/-2) extensions/wscript_build (+1/-1) katze/katze-http-cookies-sqlite.c (+0/-292) katze/katze-http-cookies-sqlite.h (+0/-42) katze/katze-http-cookies.c (+0/-331) katze/katze-http-cookies.h (+0/-42) katze/katze.h (+0/-2) midori/midori-frontend.c (+0/-5) midori/midori-privatedata.c (+11/-10) midori/midori-session.c (+59/-38) wscript (+1/-1) |
||||
To merge this branch: | bzr merge lp:~kalikiana/midori/cookieswk2 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
André Stösel | Approve | ||
Review via email:
|
Commit message
WebKit2 cookie support
Description of the change
To post a comment you must log in.
lp:~kalikiana/midori/cookieswk2
updated
- 6267. By Cris Dywan
-
Move gchar* cache and disable cookie/ session callbacks
- 6268. By Cris Dywan
-
Unblock cookie manager from WebKit2 build
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Cris Dywan (kalikiana) wrote : | # |
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'extensions/cookie-manager/cookie-manager.c' |
2 | --- extensions/cookie-manager/cookie-manager.c 2013-02-21 21:36:30 +0000 |
3 | +++ extensions/cookie-manager/cookie-manager.c 2013-07-29 21:07:25 +0000 |
4 | @@ -12,6 +12,7 @@ |
5 | #include "config.h" |
6 | #include <midori/midori.h> |
7 | #include "katze/katze.h" |
8 | +#include <libsoup/soup-cookie-jar-sqlite.h> |
9 | |
10 | #include "cookie-manager.h" |
11 | #include "cookie-manager-page.h" |
12 | @@ -259,6 +260,7 @@ |
13 | |
14 | g_object_unref(priv->store); |
15 | g_free(priv->filter_text); |
16 | + g_object_unref(priv->jar); |
17 | |
18 | G_OBJECT_CLASS(cookie_manager_parent_class)->finalize(object); |
19 | } |
20 | @@ -267,7 +269,6 @@ |
21 | static void cookie_manager_init(CookieManager *self) |
22 | { |
23 | CookieManagerPrivate *priv; |
24 | - SoupSession *session; |
25 | |
26 | self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, |
27 | COOKIE_MANAGER_TYPE, CookieManagerPrivate); |
28 | @@ -279,8 +280,15 @@ |
29 | COOKIE_MANAGER_COL_NAME, GTK_SORT_ASCENDING); |
30 | |
31 | /* setup soup */ |
32 | - session = webkit_get_default_session(); |
33 | +#ifdef HAVE_WEBKIT2 |
34 | + gchar *filename = midori_paths_get_config_filename_for_writing ("cookies.db"); |
35 | + priv->jar = soup_cookie_jar_sqlite_new (filename, FALSE); |
36 | + g_free(filename); |
37 | +#else |
38 | + SoupSession *session = webkit_get_default_session(); |
39 | priv->jar = SOUP_COOKIE_JAR(soup_session_get_feature(session, soup_cookie_jar_get_type())); |
40 | + g_object_ref(priv->jar); |
41 | +#endif |
42 | g_signal_connect(priv->jar, "changed", G_CALLBACK(cookie_manager_jar_changed_cb), self); |
43 | |
44 | cookie_manager_refresh_store(self); |
45 | |
46 | === modified file 'extensions/wscript_build' |
47 | --- extensions/wscript_build 2013-06-03 19:37:36 +0000 |
48 | +++ extensions/wscript_build 2013-07-29 21:07:25 +0000 |
49 | @@ -32,7 +32,7 @@ |
50 | source = extension |
51 | |
52 | # FIXME |
53 | - if bld.env['HAVE_WEBKIT2'] and target in ['external-download-manager', 'nsplugin-manager', 'formhistory', 'adblock', 'cookie-permissions', 'addons', 'cookie-manager']: |
54 | + if bld.env['HAVE_WEBKIT2'] and target in ['external-download-manager', 'nsplugin-manager', 'formhistory', 'adblock', 'cookie-permissions', 'addons']: |
55 | continue |
56 | |
57 | obj = bld.new_task_gen ('cc', 'shlib') |
58 | |
59 | === removed file 'katze/katze-http-cookies-sqlite.c' |
60 | --- katze/katze-http-cookies-sqlite.c 2012-07-19 19:14:09 +0000 |
61 | +++ katze/katze-http-cookies-sqlite.c 1970-01-01 00:00:00 +0000 |
62 | @@ -1,292 +0,0 @@ |
63 | -/* |
64 | - Copyright (C) 2008-2010 Christian Dywan <christian@twotoasts.de> |
65 | - Copyright (C) 2011 Alexander Butenko <a.butenka@gmail.com> |
66 | - |
67 | - This library is free software; you can redistribute it and/or |
68 | - modify it under the terms of the GNU Lesser General Public |
69 | - License as published by the Free Software Foundation; either |
70 | - version 2.1 of the License, or (at your option) any later version. |
71 | - |
72 | - See the file COPYING for the full license text. |
73 | -*/ |
74 | - |
75 | -#if HAVE_CONFIG_H |
76 | - #include <config.h> |
77 | -#endif |
78 | - |
79 | -#include "katze-http-cookies-sqlite.h" |
80 | - |
81 | -#include <stdlib.h> |
82 | -#ifdef HAVE_UNISTD_H |
83 | - #include <unistd.h> |
84 | -#endif |
85 | -#include <glib/gi18n.h> |
86 | -#include <libsoup/soup.h> |
87 | -#include <gtk/gtk.h> |
88 | -#include <glib/gstdio.h> |
89 | -#include <sqlite3.h> |
90 | - |
91 | -#define QUERY_ALL "SELECT id, name, value, host, path, expiry, lastAccessed, isSecure, isHttpOnly FROM moz_cookies;" |
92 | -#define CREATE_TABLE "CREATE TABLE IF NOT EXISTS moz_cookies (id INTEGER PRIMARY KEY, name TEXT, value TEXT, host TEXT, path TEXT,expiry INTEGER, lastAccessed INTEGER, isSecure INTEGER, isHttpOnly INTEGER)" |
93 | -#define QUERY_INSERT "INSERT INTO moz_cookies VALUES(NULL, %Q, %Q, %Q, %Q, %d, NULL, %d, %d);" |
94 | -#define QUERY_DELETE "DELETE FROM moz_cookies WHERE name=%Q AND host=%Q;" |
95 | - |
96 | -enum { |
97 | - COL_ID, |
98 | - COL_NAME, |
99 | - COL_VALUE, |
100 | - COL_HOST, |
101 | - COL_PATH, |
102 | - COL_EXPIRY, |
103 | - COL_LAST_ACCESS, |
104 | - COL_SECURE, |
105 | - COL_HTTP_ONLY, |
106 | - N_COL, |
107 | -}; |
108 | - |
109 | -struct _KatzeHttpCookiesSqlite |
110 | -{ |
111 | - GObject parent_instance; |
112 | - gchar* filename; |
113 | - SoupCookieJar* jar; |
114 | - sqlite3 *db; |
115 | - guint counter; |
116 | -}; |
117 | - |
118 | -struct _KatzeHttpCookiesSqliteClass |
119 | -{ |
120 | - GObjectClass parent_class; |
121 | -}; |
122 | - |
123 | -static void |
124 | -katze_http_cookies_sqlite_session_feature_iface_init (SoupSessionFeatureInterface *iface, |
125 | - gpointer data); |
126 | - |
127 | -G_DEFINE_TYPE_WITH_CODE (KatzeHttpCookiesSqlite, katze_http_cookies_sqlite, G_TYPE_OBJECT, |
128 | - G_IMPLEMENT_INTERFACE (SOUP_TYPE_SESSION_FEATURE, |
129 | - katze_http_cookies_sqlite_session_feature_iface_init)); |
130 | - |
131 | -/* Cookie jar saving into sqlite database |
132 | - Copyright (C) 2008 Diego Escalante Urrelo |
133 | - Copyright (C) 2009 Collabora Ltd. |
134 | - Mostly copied from libSoup 2.30, coding style retained */ |
135 | - |
136 | -/* Follows sqlite3 convention; returns TRUE on error */ |
137 | -static gboolean |
138 | -katze_http_cookies_sqlite_open_db (KatzeHttpCookiesSqlite* http_cookies) |
139 | -{ |
140 | - char *error = NULL; |
141 | - |
142 | - if (sqlite3_open (http_cookies->filename, &http_cookies->db)) { |
143 | - sqlite3_close (http_cookies->db); |
144 | - g_warning ("Can't open %s", http_cookies->filename); |
145 | - return TRUE; |
146 | - } |
147 | - |
148 | - if (sqlite3_exec (http_cookies->db, CREATE_TABLE, NULL, NULL, &error)) { |
149 | - g_warning ("Failed to execute query: %s", error); |
150 | - sqlite3_free (error); |
151 | - } |
152 | - |
153 | - if (sqlite3_exec (http_cookies->db, "PRAGMA secure_delete = 1;", |
154 | - NULL, NULL, &error)) { |
155 | - g_warning ("Failed to execute query: %s", error); |
156 | - sqlite3_free (error); |
157 | - } |
158 | - |
159 | - sqlite3_exec (http_cookies->db, |
160 | - /* Arguably cookies are like a cache, so performance over integrity */ |
161 | - "PRAGMA synchronous = OFF; PRAGMA temp_store = MEMORY;" |
162 | - "PRAGMA count_changes = OFF; PRAGMA journal_mode = TRUNCATE;", |
163 | - NULL, NULL, &error); |
164 | - |
165 | - return FALSE; |
166 | -} |
167 | - |
168 | -static void |
169 | -katze_http_cookies_sqlite_load (KatzeHttpCookiesSqlite* http_cookies) |
170 | -{ |
171 | - const char *name, *value, *host, *path; |
172 | - sqlite3_stmt* stmt; |
173 | - SoupCookie *cookie = NULL; |
174 | - gint64 expire_time; |
175 | - time_t now; |
176 | - int max_age; |
177 | - gboolean http_only = FALSE, secure = FALSE; |
178 | - char *query; |
179 | - int result; |
180 | - |
181 | - if (http_cookies->db == NULL) { |
182 | - if (katze_http_cookies_sqlite_open_db (http_cookies)) |
183 | - return; |
184 | - } |
185 | - |
186 | - sqlite3_prepare_v2 (http_cookies->db, QUERY_ALL, strlen (QUERY_ALL) + 1, &stmt, NULL); |
187 | - result = sqlite3_step (stmt); |
188 | - if (result != SQLITE_ROW) |
189 | - { |
190 | - if (result == SQLITE_ERROR) |
191 | - g_print (_("Failed to load cookies\n")); |
192 | - sqlite3_reset (stmt); |
193 | - return; |
194 | - } |
195 | - |
196 | - while (result == SQLITE_ROW) |
197 | - { |
198 | - now = time (NULL); |
199 | - name = (const char*)sqlite3_column_text (stmt, COL_NAME); |
200 | - value = (const char*)sqlite3_column_text (stmt, COL_VALUE); |
201 | - host = (const char*)sqlite3_column_text (stmt, COL_HOST); |
202 | - path = (const char*)sqlite3_column_text (stmt, COL_PATH); |
203 | - expire_time = sqlite3_column_int64 (stmt,COL_EXPIRY); |
204 | - secure = sqlite3_column_int (stmt, COL_SECURE); |
205 | - http_only = sqlite3_column_int (stmt, COL_HTTP_ONLY); |
206 | - |
207 | - if (now >= expire_time) |
208 | - { |
209 | - /* Cookie expired, remove it from database */ |
210 | - query = sqlite3_mprintf (QUERY_DELETE, name, host); |
211 | - sqlite3_exec (http_cookies->db, QUERY_DELETE, NULL, NULL, NULL); |
212 | - sqlite3_free (query); |
213 | - result = sqlite3_step (stmt); |
214 | - continue; |
215 | - } |
216 | - max_age = (expire_time - now <= G_MAXINT ? expire_time - now : G_MAXINT); |
217 | - cookie = soup_cookie_new (name, value, host, path, max_age); |
218 | - |
219 | - if (secure) |
220 | - soup_cookie_set_secure (cookie, TRUE); |
221 | - if (http_only) |
222 | - soup_cookie_set_http_only (cookie, TRUE); |
223 | - |
224 | - soup_cookie_jar_add_cookie (http_cookies->jar, cookie); |
225 | - result = sqlite3_step (stmt); |
226 | - } |
227 | - |
228 | - if (stmt) |
229 | - { |
230 | - sqlite3_reset (stmt); |
231 | - sqlite3_clear_bindings (stmt); |
232 | - } |
233 | -} |
234 | -static void |
235 | -katze_http_cookies_sqlite_jar_changed_cb (SoupCookieJar* jar, |
236 | - SoupCookie* old_cookie, |
237 | - SoupCookie* new_cookie, |
238 | - KatzeHttpCookiesSqlite* http_cookies) |
239 | -{ |
240 | - GObject* settings; |
241 | - char *query; |
242 | - time_t expires = 0; /* Avoid warning */ |
243 | - |
244 | - if (http_cookies->db == NULL) { |
245 | - if (katze_http_cookies_sqlite_open_db (http_cookies)) |
246 | - return; |
247 | - } |
248 | - |
249 | - if (new_cookie && new_cookie->expires) |
250 | - { |
251 | - gint age; |
252 | - |
253 | - expires = soup_date_to_time_t (new_cookie->expires); |
254 | - settings = g_object_get_data (G_OBJECT (jar), "midori-settings"); |
255 | - age = katze_object_get_int (settings, "maximum-cookie-age"); |
256 | - if (age > 0) |
257 | - { |
258 | - SoupDate* max_date = soup_date_new_from_now ( |
259 | - age * SOUP_COOKIE_MAX_AGE_ONE_DAY); |
260 | - if (soup_date_to_time_t (new_cookie->expires) |
261 | - > soup_date_to_time_t (max_date)) |
262 | - soup_cookie_set_expires (new_cookie, max_date); |
263 | - } |
264 | - else |
265 | - { |
266 | - /* An age of 0 to SoupCookie means already-expired |
267 | - A user choosing 0 days probably expects 1 hour. */ |
268 | - soup_cookie_set_max_age (new_cookie, SOUP_COOKIE_MAX_AGE_ONE_HOUR); |
269 | - } |
270 | - } |
271 | - |
272 | - if (!g_strcmp0 (g_getenv ("MIDORI_DEBUG"), "cookies")) |
273 | - http_cookies->counter++; |
274 | - |
275 | - if (old_cookie) { |
276 | - query = sqlite3_mprintf (QUERY_DELETE, |
277 | - old_cookie->name, |
278 | - old_cookie->domain); |
279 | - sqlite3_exec (http_cookies->db, query, NULL, NULL, NULL); |
280 | - sqlite3_free (query); |
281 | - } |
282 | - |
283 | - if (new_cookie && new_cookie->expires) { |
284 | - |
285 | - query = sqlite3_mprintf (QUERY_INSERT, |
286 | - new_cookie->name, |
287 | - new_cookie->value, |
288 | - new_cookie->domain, |
289 | - new_cookie->path, |
290 | - expires, |
291 | - new_cookie->secure, |
292 | - new_cookie->http_only); |
293 | - sqlite3_exec (http_cookies->db, query, NULL, NULL, NULL); |
294 | - sqlite3_free (query); |
295 | - } |
296 | -} |
297 | - |
298 | -static void |
299 | -katze_http_cookies_sqlite_attach (SoupSessionFeature* feature, |
300 | - SoupSession* session) |
301 | -{ |
302 | - KatzeHttpCookiesSqlite* http_cookies = (KatzeHttpCookiesSqlite*)feature; |
303 | - const gchar* filename = g_object_get_data (G_OBJECT (feature), "filename"); |
304 | - SoupSessionFeature* jar = soup_session_get_feature (session, SOUP_TYPE_COOKIE_JAR); |
305 | - g_return_if_fail (jar != NULL); |
306 | - g_return_if_fail (filename != NULL); |
307 | - katze_assign (http_cookies->filename, g_strdup (filename)); |
308 | - http_cookies->jar = g_object_ref (jar); |
309 | - katze_http_cookies_sqlite_open_db (http_cookies); |
310 | - katze_http_cookies_sqlite_load (http_cookies); |
311 | - g_signal_connect (jar, "changed", |
312 | - G_CALLBACK (katze_http_cookies_sqlite_jar_changed_cb), feature); |
313 | - |
314 | -} |
315 | - |
316 | -static void |
317 | -katze_http_cookies_sqlite_detach (SoupSessionFeature* feature, |
318 | - SoupSession* session) |
319 | -{ |
320 | - KatzeHttpCookiesSqlite* http_cookies = (KatzeHttpCookiesSqlite*)feature; |
321 | - katze_assign (http_cookies->filename, NULL); |
322 | - katze_object_assign (http_cookies->jar, NULL); |
323 | - sqlite3_close (http_cookies->db); |
324 | -} |
325 | - |
326 | -static void |
327 | -katze_http_cookies_sqlite_session_feature_iface_init (SoupSessionFeatureInterface *iface, |
328 | - gpointer data) |
329 | -{ |
330 | - iface->attach = katze_http_cookies_sqlite_attach; |
331 | - iface->detach = katze_http_cookies_sqlite_detach; |
332 | -} |
333 | - |
334 | -static void |
335 | -katze_http_cookies_sqlite_finalize (GObject* object) |
336 | -{ |
337 | - katze_http_cookies_sqlite_detach ((SoupSessionFeature*)object, NULL); |
338 | -} |
339 | - |
340 | -static void |
341 | -katze_http_cookies_sqlite_class_init (KatzeHttpCookiesSqliteClass* class) |
342 | -{ |
343 | - GObjectClass* gobject_class = (GObjectClass*)class; |
344 | - gobject_class->finalize = katze_http_cookies_sqlite_finalize; |
345 | -} |
346 | - |
347 | -static void |
348 | -katze_http_cookies_sqlite_init (KatzeHttpCookiesSqlite* http_cookies) |
349 | -{ |
350 | - http_cookies->filename = NULL; |
351 | - http_cookies->jar = NULL; |
352 | - http_cookies->db = NULL; |
353 | - http_cookies->counter = 0; |
354 | -} |
355 | |
356 | === removed file 'katze/katze-http-cookies-sqlite.h' |
357 | --- katze/katze-http-cookies-sqlite.h 2011-10-10 21:22:27 +0000 |
358 | +++ katze/katze-http-cookies-sqlite.h 1970-01-01 00:00:00 +0000 |
359 | @@ -1,42 +0,0 @@ |
360 | -/* |
361 | - Copyright (C) 2009 Christian Dywan <christian@twotoasts.de> |
362 | - |
363 | - This library is free software; you can redistribute it and/or |
364 | - modify it under the terms of the GNU Lesser General Public |
365 | - License as published by the Free Software Foundation; either |
366 | - version 2.1 of the License, or (at your option) any later version. |
367 | - |
368 | - See the file COPYING for the full license text. |
369 | -*/ |
370 | - |
371 | -#ifndef __KATZE_HTTP_COOKIES_SQLITE_H__ |
372 | -#define __KATZE_HTTP_COOKIES_SQLITE_H__ |
373 | - |
374 | -#include "katze-utils.h" |
375 | - |
376 | -#include <glib-object.h> |
377 | - |
378 | -G_BEGIN_DECLS |
379 | - |
380 | -#define KATZE_TYPE_HTTP_COOKIES_SQLITE \ |
381 | - (katze_http_cookies_sqlite_get_type ()) |
382 | -#define KATZE_HTTP_COOKIES_SQLITE(obj) \ |
383 | - (G_TYPE_CHECK_INSTANCE_CAST ((obj), KATZE_TYPE_HTTP_COOKIES_SQLITE, KatzeHttpCookiesSqlite)) |
384 | -#define KATZE_HTTP_COOKIES_SQLITE_CLASS(klass) \ |
385 | - (G_TYPE_CHECK_CLASS_CAST ((klass), KATZE_TYPE_HTTP_COOKIES_SQLITE, KatzeHttpCookiesSqliteClass)) |
386 | -#define KATZE_IS_HTTP_COOKIES_SQLITE(obj) \ |
387 | - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), KATZE_TYPE_HTTP_COOKIES_SQLITE)) |
388 | -#define KATZE_IS_HTTP_COOKIES_SQLITE_CLASS(klass) \ |
389 | - (G_TYPE_CHECK_CLASS_TYPE ((klass), KATZE_TYPE_HTTP_COOKIES_SQLITE)) |
390 | -#define KATZE_HTTP_COOKIES_SQLITE_GET_CLASS(obj) \ |
391 | - (G_TYPE_INSTANCE_GET_CLASS ((obj), KATZE_TYPE_HTTP_COOKIES_SQLITE, KatzeHttpCookiesSqliteClass)) |
392 | - |
393 | -typedef struct _KatzeHttpCookiesSqlite KatzeHttpCookiesSqlite; |
394 | -typedef struct _KatzeHttpCookiesSqliteClass KatzeHttpCookiesSqliteClass; |
395 | - |
396 | -GType |
397 | -katze_http_cookies_sqlite_get_type (void) G_GNUC_CONST; |
398 | - |
399 | -G_END_DECLS |
400 | - |
401 | -#endif /* __KATZE_HTTP_COOKIES_SQLITE_H__ */ |
402 | |
403 | === removed file 'katze/katze-http-cookies.c' |
404 | --- katze/katze-http-cookies.c 2013-04-16 23:16:24 +0000 |
405 | +++ katze/katze-http-cookies.c 1970-01-01 00:00:00 +0000 |
406 | @@ -1,331 +0,0 @@ |
407 | -/* |
408 | - Copyright (C) 2008-2010 Christian Dywan <christian@twotoasts.de> |
409 | - |
410 | - This library is free software; you can redistribute it and/or |
411 | - modify it under the terms of the GNU Lesser General Public |
412 | - License as published by the Free Software Foundation; either |
413 | - version 2.1 of the License, or (at your option) any later version. |
414 | - |
415 | - See the file COPYING for the full license text. |
416 | -*/ |
417 | - |
418 | -#if HAVE_CONFIG_H |
419 | - #include <config.h> |
420 | -#endif |
421 | - |
422 | -#include "katze-http-cookies.h" |
423 | -#include "midori/midori-core.h" |
424 | - |
425 | -#include <stdlib.h> |
426 | -#ifdef HAVE_UNISTD_H |
427 | - #include <unistd.h> |
428 | -#endif |
429 | -#include <glib/gi18n.h> |
430 | -#include <libsoup/soup.h> |
431 | -#include <gtk/gtk.h> |
432 | -#include <glib/gstdio.h> |
433 | - |
434 | -struct _KatzeHttpCookies |
435 | -{ |
436 | - GObject parent_instance; |
437 | - gchar* filename; |
438 | - SoupCookieJar* jar; |
439 | - guint timeout; |
440 | - guint counter; |
441 | -}; |
442 | - |
443 | -struct _KatzeHttpCookiesClass |
444 | -{ |
445 | - GObjectClass parent_class; |
446 | -}; |
447 | - |
448 | -static void |
449 | -katze_http_cookies_session_feature_iface_init (SoupSessionFeatureInterface *iface, |
450 | - gpointer data); |
451 | - |
452 | -G_DEFINE_TYPE_WITH_CODE (KatzeHttpCookies, katze_http_cookies, G_TYPE_OBJECT, |
453 | - G_IMPLEMENT_INTERFACE (SOUP_TYPE_SESSION_FEATURE, |
454 | - katze_http_cookies_session_feature_iface_init)); |
455 | - |
456 | -/* Cookie jar saving to Mozilla format |
457 | - Copyright (C) 2008 Xan Lopez <xan@gnome.org> |
458 | - Copyright (C) 2008 Dan Winship <danw@gnome.org> |
459 | - Mostly copied from libSoup 2.24, coding style adjusted */ |
460 | -static SoupCookie* |
461 | -parse_cookie (gchar* line, |
462 | - time_t now) |
463 | -{ |
464 | - gchar** result; |
465 | - SoupCookie *cookie = NULL; |
466 | - gboolean http_only; |
467 | - time_t max_age; |
468 | - gchar* host/*, *is_domain*/, *path, *secure, *expires, *name, *value; |
469 | - |
470 | - if (g_str_has_prefix (line, "#HttpOnly_")) |
471 | - { |
472 | - http_only = TRUE; |
473 | - line += strlen ("#HttpOnly_"); |
474 | - } |
475 | - else if (*line == '#' || g_ascii_isspace (*line)) |
476 | - return cookie; |
477 | - else |
478 | - http_only = FALSE; |
479 | - |
480 | - result = g_strsplit (line, "\t", -1); |
481 | - if (g_strv_length (result) != 7) |
482 | - goto out; |
483 | - |
484 | - /* Check this first */ |
485 | - expires = result[4]; |
486 | - max_age = strtoul (expires, NULL, 10) - now; |
487 | - if (max_age <= 0) |
488 | - goto out; |
489 | - |
490 | - host = result[0]; |
491 | - /* is_domain = result[1]; */ |
492 | - path = result[2]; |
493 | - secure = result[3]; |
494 | - |
495 | - name = result[5]; |
496 | - value = result[6]; |
497 | - |
498 | - cookie = soup_cookie_new (name, value, host, path, max_age); |
499 | - |
500 | - if (strcmp (secure, "FALSE")) |
501 | - soup_cookie_set_secure (cookie, TRUE); |
502 | - if (http_only) |
503 | - soup_cookie_set_http_only (cookie, TRUE); |
504 | - |
505 | - out: |
506 | - g_strfreev (result); |
507 | - |
508 | - return cookie; |
509 | -} |
510 | - |
511 | -/* Cookie jar saving to Mozilla format |
512 | - Copyright (C) 2008 Xan Lopez <xan@gnome.org> |
513 | - Copyright (C) 2008 Dan Winship <danw@gnome.org> |
514 | - Mostly copied from libSoup 2.24, coding style adjusted */ |
515 | -static void |
516 | -parse_line (SoupCookieJar* jar, |
517 | - gchar* line, |
518 | - time_t now) |
519 | -{ |
520 | - SoupCookie* cookie; |
521 | - |
522 | - if ((cookie = parse_cookie (line, now))) |
523 | - soup_cookie_jar_add_cookie (jar, cookie); |
524 | -} |
525 | - |
526 | -/* Cookie jar saving to Mozilla format |
527 | - Copyright (C) 2008 Xan Lopez <xan@gnome.org> |
528 | - Copyright (C) 2008 Dan Winship <danw@gnome.org> |
529 | - Mostly copied from libSoup 2.24, coding style adjusted */ |
530 | -static void |
531 | -cookie_jar_load (SoupCookieJar* jar, |
532 | - const gchar* filename) |
533 | -{ |
534 | - char* contents = NULL; |
535 | - gchar* line; |
536 | - gchar* p; |
537 | - gsize length = 0; |
538 | - time_t now; |
539 | - |
540 | - if (!g_file_get_contents (filename, &contents, &length, NULL)) |
541 | - return; |
542 | - |
543 | - now = time (NULL); |
544 | - line = contents; |
545 | - for (p = contents; *p; p++) |
546 | - { |
547 | - /* \r\n comes out as an extra empty line and gets ignored */ |
548 | - if (*p == '\r' || *p == '\n') |
549 | - { |
550 | - *p = '\0'; |
551 | - parse_line (jar, line, now); |
552 | - line = p + 1; |
553 | - } |
554 | - } |
555 | - parse_line (jar, line, now); |
556 | - |
557 | - g_free (contents); |
558 | -} |
559 | - |
560 | -/* Cookie jar saving to Mozilla format |
561 | - Copyright (C) 2008 Xan Lopez <xan@gnome.org> |
562 | - Copyright (C) 2008 Dan Winship <danw@gnome.org> |
563 | - Copied from libSoup 2.24, coding style preserved */ |
564 | -static gboolean |
565 | -write_cookie (FILE *out, SoupCookie *cookie) |
566 | -{ |
567 | - if (fprintf (out, "%s%s\t%s\t%s\t%s\t%lu\t%s\t%s\n", |
568 | - cookie->http_only ? "#HttpOnly_" : "", |
569 | - cookie->domain, |
570 | - *cookie->domain == '.' ? "TRUE" : "FALSE", |
571 | - cookie->path, |
572 | - cookie->secure ? "TRUE" : "FALSE", |
573 | - (gulong)soup_date_to_time_t (cookie->expires), |
574 | - cookie->name, |
575 | - cookie->value) < 0) |
576 | - return FALSE; |
577 | - return TRUE; |
578 | -} |
579 | - |
580 | -static gboolean |
581 | -katze_http_cookies_update_jar (KatzeHttpCookies* http_cookies) |
582 | -{ |
583 | - gint fn = 0; |
584 | - FILE* f = NULL; |
585 | - gchar* temporary_filename = NULL; |
586 | - GSList* cookies; |
587 | - |
588 | - if (http_cookies->timeout > 0) |
589 | - { |
590 | - g_source_remove (http_cookies->timeout); |
591 | - http_cookies->timeout = 0; |
592 | - } |
593 | - |
594 | - temporary_filename = g_strconcat (http_cookies->filename, ".XXXXXX", NULL); |
595 | - if ((fn = g_mkstemp (temporary_filename)) == -1) |
596 | - goto failed; |
597 | - if (!((f = fdopen (fn, "wb")))) |
598 | - goto failed; |
599 | - |
600 | - cookies = soup_cookie_jar_all_cookies (http_cookies->jar); |
601 | - for (; cookies != NULL; cookies = g_slist_next (cookies)) |
602 | - { |
603 | - SoupCookie* cookie = cookies->data; |
604 | - if (cookie->expires && !soup_date_is_past (cookie->expires)) |
605 | - write_cookie (f, cookie); |
606 | - soup_cookie_free (cookie); |
607 | - } |
608 | - g_slist_free (cookies); |
609 | - |
610 | - if (fclose (f) != 0) |
611 | - { |
612 | - f = NULL; |
613 | - goto failed; |
614 | - } |
615 | - f = NULL; |
616 | - |
617 | - if (g_rename (temporary_filename, http_cookies->filename) == -1) |
618 | - goto failed; |
619 | - g_free (temporary_filename); |
620 | - |
621 | - if (!g_strcmp0 (g_getenv ("MIDORI_DEBUG"), "cookies")) |
622 | - { |
623 | - g_print ("KatzeHttpCookies: %d cookies changed\n", http_cookies->counter); |
624 | - http_cookies->counter = 0; |
625 | - } |
626 | - return FALSE; |
627 | - |
628 | -failed: |
629 | - if (f) |
630 | - fclose (f); |
631 | - g_unlink (temporary_filename); |
632 | - g_free (temporary_filename); |
633 | - if (!g_strcmp0 (g_getenv ("MIDORI_DEBUG"), "cookies")) |
634 | - g_print ("KatzeHttpCookies: Failed to write '%s'\n", |
635 | - http_cookies->filename); |
636 | - return FALSE; |
637 | -} |
638 | - |
639 | -static void |
640 | -katze_http_cookies_jar_changed_cb (SoupCookieJar* jar, |
641 | - SoupCookie* old_cookie, |
642 | - SoupCookie* new_cookie, |
643 | - KatzeHttpCookies* http_cookies) |
644 | -{ |
645 | - GObject* settings; |
646 | - |
647 | - if (old_cookie) |
648 | - soup_cookie_set_max_age (old_cookie, 0); |
649 | - |
650 | - if (new_cookie) |
651 | - { |
652 | - settings = g_object_get_data (G_OBJECT (jar), "midori-settings"); |
653 | - if (new_cookie->expires) |
654 | - { |
655 | - gint age = katze_object_get_int (settings, "maximum-cookie-age"); |
656 | - if (age > 0) |
657 | - { |
658 | - SoupDate* max_date = soup_date_new_from_now ( |
659 | - age * SOUP_COOKIE_MAX_AGE_ONE_DAY); |
660 | - if (soup_date_to_time_t (new_cookie->expires) |
661 | - > soup_date_to_time_t (max_date)) |
662 | - soup_cookie_set_expires (new_cookie, max_date); |
663 | - } |
664 | - else |
665 | - { |
666 | - /* An age of 0 to SoupCookie means already-expired |
667 | - A user choosing 0 days probably expects 1 hour. */ |
668 | - soup_cookie_set_max_age (new_cookie, SOUP_COOKIE_MAX_AGE_ONE_HOUR); |
669 | - } |
670 | - } |
671 | - } |
672 | - |
673 | - if (!g_strcmp0 (g_getenv ("MIDORI_DEBUG"), "cookies")) |
674 | - http_cookies->counter++; |
675 | - |
676 | - if (!http_cookies->timeout && (old_cookie || (new_cookie && new_cookie->expires))) |
677 | - http_cookies->timeout = midori_timeout_add_seconds ( |
678 | - 5, (GSourceFunc)katze_http_cookies_update_jar, http_cookies, NULL); |
679 | -} |
680 | - |
681 | -static void |
682 | -katze_http_cookies_attach (SoupSessionFeature* feature, |
683 | - SoupSession* session) |
684 | -{ |
685 | - KatzeHttpCookies* http_cookies = (KatzeHttpCookies*)feature; |
686 | - const gchar* filename = g_object_get_data (G_OBJECT (feature), "filename"); |
687 | - SoupSessionFeature* jar = soup_session_get_feature (session, SOUP_TYPE_COOKIE_JAR); |
688 | - g_return_if_fail (jar != NULL); |
689 | - g_return_if_fail (filename != NULL); |
690 | - katze_assign (http_cookies->filename, g_strdup (filename)); |
691 | - http_cookies->jar = g_object_ref (jar); |
692 | - cookie_jar_load (http_cookies->jar, http_cookies->filename); |
693 | - g_signal_connect (jar, "changed", |
694 | - G_CALLBACK (katze_http_cookies_jar_changed_cb), feature); |
695 | - |
696 | -} |
697 | - |
698 | -static void |
699 | -katze_http_cookies_detach (SoupSessionFeature* feature, |
700 | - SoupSession* session) |
701 | -{ |
702 | - KatzeHttpCookies* http_cookies = (KatzeHttpCookies*)feature; |
703 | - if (http_cookies->timeout > 0) |
704 | - katze_http_cookies_update_jar (http_cookies); |
705 | - katze_assign (http_cookies->filename, NULL); |
706 | - katze_object_assign (http_cookies->jar, NULL); |
707 | -} |
708 | - |
709 | -static void |
710 | -katze_http_cookies_session_feature_iface_init (SoupSessionFeatureInterface *iface, |
711 | - gpointer data) |
712 | -{ |
713 | - iface->attach = katze_http_cookies_attach; |
714 | - iface->detach = katze_http_cookies_detach; |
715 | -} |
716 | - |
717 | -static void |
718 | -katze_http_cookies_finalize (GObject* object) |
719 | -{ |
720 | - katze_http_cookies_detach ((SoupSessionFeature*)object, NULL); |
721 | -} |
722 | - |
723 | -static void |
724 | -katze_http_cookies_class_init (KatzeHttpCookiesClass* class) |
725 | -{ |
726 | - GObjectClass* gobject_class = (GObjectClass*)class; |
727 | - gobject_class->finalize = katze_http_cookies_finalize; |
728 | -} |
729 | - |
730 | -static void |
731 | -katze_http_cookies_init (KatzeHttpCookies* http_cookies) |
732 | -{ |
733 | - http_cookies->filename = NULL; |
734 | - http_cookies->jar = NULL; |
735 | - http_cookies->timeout = 0; |
736 | - http_cookies->counter = 0; |
737 | -} |
738 | |
739 | === removed file 'katze/katze-http-cookies.h' |
740 | --- katze/katze-http-cookies.h 2010-01-17 17:14:48 +0000 |
741 | +++ katze/katze-http-cookies.h 1970-01-01 00:00:00 +0000 |
742 | @@ -1,42 +0,0 @@ |
743 | -/* |
744 | - Copyright (C) 2009 Christian Dywan <christian@twotoasts.de> |
745 | - |
746 | - This library is free software; you can redistribute it and/or |
747 | - modify it under the terms of the GNU Lesser General Public |
748 | - License as published by the Free Software Foundation; either |
749 | - version 2.1 of the License, or (at your option) any later version. |
750 | - |
751 | - See the file COPYING for the full license text. |
752 | -*/ |
753 | - |
754 | -#ifndef __KATZE_HTTP_COOKIES_H__ |
755 | -#define __KATZE_HTTP_COOKIES_H__ |
756 | - |
757 | -#include "katze-utils.h" |
758 | - |
759 | -#include <glib-object.h> |
760 | - |
761 | -G_BEGIN_DECLS |
762 | - |
763 | -#define KATZE_TYPE_HTTP_COOKIES \ |
764 | - (katze_http_cookies_get_type ()) |
765 | -#define KATZE_HTTP_COOKIES(obj) \ |
766 | - (G_TYPE_CHECK_INSTANCE_CAST ((obj), KATZE_TYPE_HTTP_COOKIES, KatzeHttpCookies)) |
767 | -#define KATZE_HTTP_COOKIES_CLASS(klass) \ |
768 | - (G_TYPE_CHECK_CLASS_CAST ((klass), KATZE_TYPE_HTTP_COOKIES, KatzeHttpCookiesClass)) |
769 | -#define KATZE_IS_HTTP_COOKIES(obj) \ |
770 | - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), KATZE_TYPE_HTTP_COOKIES)) |
771 | -#define KATZE_IS_HTTP_COOKIES_CLASS(klass) \ |
772 | - (G_TYPE_CHECK_CLASS_TYPE ((klass), KATZE_TYPE_HTTP_COOKIES)) |
773 | -#define KATZE_HTTP_COOKIES_GET_CLASS(obj) \ |
774 | - (G_TYPE_INSTANCE_GET_CLASS ((obj), KATZE_TYPE_HTTP_COOKIES, KatzeHttpCookiesClass)) |
775 | - |
776 | -typedef struct _KatzeHttpCookies KatzeHttpCookies; |
777 | -typedef struct _KatzeHttpCookiesClass KatzeHttpCookiesClass; |
778 | - |
779 | -GType |
780 | -katze_http_cookies_get_type (void) G_GNUC_CONST; |
781 | - |
782 | -G_END_DECLS |
783 | - |
784 | -#endif /* __KATZE_HTTP_COOKIES_H__ */ |
785 | |
786 | === modified file 'katze/katze.h' |
787 | --- katze/katze.h 2013-07-27 12:35:55 +0000 |
788 | +++ katze/katze.h 2013-07-29 21:07:25 +0000 |
789 | @@ -13,8 +13,6 @@ |
790 | #define __KATZE_H__ |
791 | |
792 | #include "katze-http-auth.h" |
793 | -#include "katze-http-cookies.h" |
794 | -#include "katze-http-cookies-sqlite.h" |
795 | #include "katze-throbber.h" |
796 | #include "katze-utils.h" |
797 | #include "katze-item.h" |
798 | |
799 | === modified file 'midori/midori-frontend.c' |
800 | --- midori/midori-frontend.c 2013-06-30 14:58:59 +0000 |
801 | +++ midori/midori-frontend.c 2013-07-29 21:07:25 +0000 |
802 | @@ -600,11 +600,6 @@ |
803 | midori_bookmarks_on_quit (bookmarks); |
804 | midori_history_on_quit (history, settings); |
805 | midori_private_data_on_quit (settings); |
806 | - /* Removing KatzeHttpCookies makes it save outstanding changes */ |
807 | -#ifndef HAVE_WEBKIT2 |
808 | - soup_session_remove_feature_by_type (webkit_get_default_session (), |
809 | - KATZE_TYPE_HTTP_COOKIES); |
810 | -#endif |
811 | |
812 | MidoriStartup load_on_startup = katze_object_get_int (settings, "load-on-startup"); |
813 | if (load_on_startup < MIDORI_STARTUP_LAST_OPEN_PAGES) |
814 | |
815 | === modified file 'midori/midori-privatedata.c' |
816 | --- midori/midori-privatedata.c 2013-06-19 20:23:55 +0000 |
817 | +++ midori/midori-privatedata.c 2013-07-29 21:07:25 +0000 |
818 | @@ -221,13 +221,17 @@ |
819 | static void |
820 | midori_clear_web_cookies_cb (void) |
821 | { |
822 | -#ifndef HAVE_WEBKIT2 |
823 | +#ifdef HAVE_WEBKIT2 |
824 | + WebKitWebContext* context = webkit_web_context_get_default (); |
825 | + WebKitCookieManager* cookie_manager = webkit_web_context_get_cookie_manager (context); |
826 | + webkit_cookie_manager_delete_all_cookies (cookie_manager); |
827 | + /* FIXME: site data policy */ |
828 | +#else |
829 | SoupSession* session = webkit_get_default_session (); |
830 | MidoriWebSettings* settings = g_object_get_data (G_OBJECT (session), "midori-settings"); |
831 | SoupSessionFeature* jar = soup_session_get_feature (session, SOUP_TYPE_COOKIE_JAR); |
832 | GSList* cookies = soup_cookie_jar_all_cookies (SOUP_COOKIE_JAR (jar)); |
833 | SoupSessionFeature* feature; |
834 | - gchar* cache; |
835 | |
836 | /* HTTP Cookies/ Web Cookies */ |
837 | for (; cookies != NULL; cookies = g_slist_next (cookies)) |
838 | @@ -239,18 +243,12 @@ |
839 | soup_cookie_jar_delete_cookie ((SoupCookieJar*)jar, cookies->data); |
840 | } |
841 | soup_cookies_free (cookies); |
842 | - /* Removing KatzeHttpCookies makes it save outstanding changes */ |
843 | - if ((feature = soup_session_get_feature (session, KATZE_TYPE_HTTP_COOKIES))) |
844 | - { |
845 | - g_object_ref (feature); |
846 | - soup_session_remove_feature (session, feature); |
847 | - soup_session_add_feature (session, feature); |
848 | - g_object_unref (feature); |
849 | - } |
850 | +#endif |
851 | |
852 | /* Local shared objects/ Flash cookies */ |
853 | if (midori_web_settings_has_plugin_support ()) |
854 | { |
855 | + gchar* cache; |
856 | #ifdef GDK_WINDOWING_X11 |
857 | cache = g_build_filename (g_get_home_dir (), ".macromedia", "Flash_Player", NULL); |
858 | midori_paths_remove_path (cache); |
859 | @@ -267,6 +265,9 @@ |
860 | #endif |
861 | } |
862 | |
863 | +#ifdef HAVE_WEBKIT2 |
864 | + /* TODO: clear databases and offline app caches */ |
865 | +#else |
866 | /* HTML5 databases */ |
867 | webkit_remove_all_web_databases (); |
868 | |
869 | |
870 | === modified file 'midori/midori-session.c' |
871 | --- midori/midori-session.c 2013-07-11 08:40:04 +0000 |
872 | +++ midori/midori-session.c 2013-07-29 21:07:25 +0000 |
873 | @@ -17,10 +17,12 @@ |
874 | #include "sokoke.h" |
875 | |
876 | #include <glib/gi18n-lib.h> |
877 | +#include <libsoup/soup-cookie-jar-sqlite.h> |
878 | |
879 | #define LIBSOUP_USE_UNSTABLE_REQUEST_API |
880 | #include <libsoup/soup-cache.h> |
881 | |
882 | +#ifndef HAVE_WEBKIT2 |
883 | static void |
884 | midori_soup_session_set_proxy_uri (SoupSession* session, |
885 | const gchar* uri) |
886 | @@ -83,18 +85,28 @@ |
887 | else |
888 | midori_soup_session_set_proxy_uri (session, NULL); |
889 | } |
890 | +#endif |
891 | |
892 | -#ifdef HAVE_LIBSOUP_2_29_91 |
893 | +#if defined(HAVE_LIBSOUP_2_29_91) && WEBKIT_CHECK_VERSION (1, 1, 21) |
894 | static void |
895 | soup_session_settings_notify_first_party_cb (MidoriWebSettings* settings, |
896 | GParamSpec* pspec, |
897 | - SoupSession* session) |
898 | + gpointer user_data) |
899 | { |
900 | + gboolean yes = katze_object_get_boolean (settings, "first-party-cookies-only"); |
901 | +#ifdef HAVE_WEBKIT2 |
902 | + WebKitWebContext* context = webkit_web_context_get_default (); |
903 | + WebKitCookieManager* cookie_manager = webkit_web_context_get_cookie_manager (context); |
904 | + webkit_cookie_manager_set_accept_policy (cookie_manager, |
905 | + yes ? WEBKIT_COOKIE_POLICY_ACCEPT_NO_THIRD_PARTY |
906 | + : WEBKIT_COOKIE_POLICY_ACCEPT_ALWAYS); |
907 | +#else |
908 | + SoupSession* session = webkit_get_default_session (); |
909 | gpointer jar = soup_session_get_feature (session, SOUP_TYPE_COOKIE_JAR); |
910 | - gboolean yes = katze_object_get_boolean (settings, "first-party-cookies-only"); |
911 | g_object_set (jar, "accept-policy", |
912 | yes ? SOUP_COOKIE_JAR_ACCEPT_NO_THIRD_PARTY |
913 | : SOUP_COOKIE_JAR_ACCEPT_ALWAYS, NULL); |
914 | +#endif |
915 | } |
916 | #endif |
917 | |
918 | @@ -116,17 +128,14 @@ |
919 | #ifndef HAVE_WEBKIT2 |
920 | const gchar* |
921 | midori_web_settings_get_accept_language (MidoriWebSettings* settings); |
922 | -#endif |
923 | |
924 | static void |
925 | midori_soup_session_settings_accept_language_cb (SoupSession* session, |
926 | SoupMessage* msg, |
927 | MidoriWebSettings* settings) |
928 | { |
929 | - #ifndef HAVE_WEBKIT2 |
930 | const gchar* accept = midori_web_settings_get_accept_language (settings); |
931 | soup_message_headers_append (msg->request_headers, "Accept-Language", accept); |
932 | - #endif |
933 | |
934 | if (katze_object_get_boolean (settings, "strip-referer")) |
935 | { |
936 | @@ -157,10 +166,16 @@ |
937 | soup_message_headers_remove (msg->request_headers, "Host"); |
938 | } |
939 | } |
940 | +#endif |
941 | |
942 | gboolean |
943 | midori_load_soup_session (gpointer settings) |
944 | { |
945 | + #if defined(HAVE_LIBSOUP_2_29_91) && WEBKIT_CHECK_VERSION (1, 1, 21) |
946 | + g_signal_connect (settings, "notify::first-party-cookies-only", |
947 | + G_CALLBACK (soup_session_settings_notify_first_party_cb), NULL); |
948 | + #endif |
949 | + |
950 | #ifndef HAVE_WEBKIT2 |
951 | SoupSession* session = webkit_get_default_session (); |
952 | |
953 | @@ -213,12 +228,6 @@ |
954 | G_CALLBACK (soup_session_settings_notify_http_proxy_cb), session); |
955 | g_signal_connect (settings, "notify::proxy-type", |
956 | G_CALLBACK (soup_session_settings_notify_http_proxy_cb), session); |
957 | - #ifdef HAVE_LIBSOUP_2_29_91 |
958 | - if (g_object_class_find_property (G_OBJECT_GET_CLASS (settings), |
959 | - "enable-file-access-from-file-uris")) /* WebKitGTK+ >= 1.1.21 */ |
960 | - g_signal_connect (settings, "notify::first-party-cookies-only", |
961 | - G_CALLBACK (soup_session_settings_notify_first_party_cb), session); |
962 | - #endif |
963 | |
964 | #if defined (HAVE_LIBSOUP_2_34_0) |
965 | g_signal_connect (session, "request-started", |
966 | @@ -247,10 +256,42 @@ |
967 | return FALSE; |
968 | } |
969 | |
970 | +#ifndef HAVE_WEBKIT2 |
971 | +static void |
972 | +midori_session_cookie_jar_changed_cb (SoupCookieJar* jar, |
973 | + SoupCookie* old_cookie, |
974 | + SoupCookie* new_cookie, |
975 | + MidoriWebSettings* settings) |
976 | +{ |
977 | + if (new_cookie && new_cookie->expires) |
978 | + { |
979 | + time_t expires = soup_date_to_time_t (new_cookie->expires); |
980 | + gint age = katze_object_get_int (settings, "maximum-cookie-age"); |
981 | + if (age > 0) |
982 | + { |
983 | + SoupDate* max_date = soup_date_new_from_now ( |
984 | + age * SOUP_COOKIE_MAX_AGE_ONE_DAY); |
985 | + if (soup_date_to_time_t (new_cookie->expires) |
986 | + > soup_date_to_time_t (max_date)) |
987 | + soup_cookie_set_expires (new_cookie, max_date); |
988 | + } |
989 | + else |
990 | + { |
991 | + /* An age of 0 to SoupCookie means already-expired |
992 | + A user choosing 0 days probably expects 1 hour. */ |
993 | + soup_cookie_set_max_age (new_cookie, SOUP_COOKIE_MAX_AGE_ONE_HOUR); |
994 | + } |
995 | + } |
996 | + |
997 | + if (midori_debug ("cookies")) |
998 | + g_print ("cookie changed: old %p new %p\n", old_cookie, new_cookie); |
999 | +} |
1000 | +#endif |
1001 | + |
1002 | gboolean |
1003 | midori_load_soup_session_full (gpointer settings) |
1004 | { |
1005 | -#ifndef HAVE_WEBKIT2 |
1006 | + #ifndef HAVE_WEBKIT2 |
1007 | SoupSession* session = webkit_get_default_session (); |
1008 | SoupCookieJar* jar; |
1009 | gchar* config_file; |
1010 | @@ -265,33 +306,13 @@ |
1011 | soup_session_add_feature (session, feature); |
1012 | g_object_unref (feature); |
1013 | |
1014 | - jar = soup_cookie_jar_new (); |
1015 | - g_object_set_data (G_OBJECT (jar), "midori-settings", settings); |
1016 | + katze_assign (config_file, midori_paths_get_config_filename_for_writing ("cookies.db")); |
1017 | + jar = soup_cookie_jar_sqlite_new (config_file, FALSE); |
1018 | soup_session_add_feature (session, SOUP_SESSION_FEATURE (jar)); |
1019 | + g_signal_connect (jar, "changed", |
1020 | + G_CALLBACK (midori_session_cookie_jar_changed_cb), settings); |
1021 | g_object_unref (jar); |
1022 | |
1023 | - katze_assign (config_file, midori_paths_get_config_filename_for_writing ("cookies.db")); |
1024 | - have_new_cookies = g_access (config_file, F_OK) == 0; |
1025 | - feature = g_object_new (KATZE_TYPE_HTTP_COOKIES_SQLITE, NULL); |
1026 | - g_object_set_data_full (G_OBJECT (feature), "filename", |
1027 | - config_file, (GDestroyNotify)g_free); |
1028 | - soup_session_add_feature (session, feature); |
1029 | - g_object_unref (feature); |
1030 | - |
1031 | - if (!have_new_cookies) |
1032 | - { |
1033 | - katze_assign (config_file, midori_paths_get_config_filename_for_writing ("cookies.txt")); |
1034 | - if (g_access (config_file, F_OK) == 0) |
1035 | - { |
1036 | - g_message ("Importing cookies from txt to sqlite3"); |
1037 | - feature_import = g_object_new (KATZE_TYPE_HTTP_COOKIES, NULL); |
1038 | - g_object_set_data_full (G_OBJECT (feature_import), "filename", |
1039 | - config_file, (GDestroyNotify)g_free); |
1040 | - soup_session_add_feature (session, SOUP_SESSION_FEATURE (feature_import)); |
1041 | - soup_session_remove_feature (session, SOUP_SESSION_FEATURE (feature_import)); |
1042 | - } |
1043 | - } |
1044 | - |
1045 | katze_assign (config_file, g_build_filename (midori_paths_get_cache_dir (), "web", NULL)); |
1046 | feature = SOUP_SESSION_FEATURE (soup_cache_new (config_file, 0)); |
1047 | soup_session_add_feature (session, feature); |
1048 | @@ -299,7 +320,7 @@ |
1049 | katze_object_get_int (settings, "maximum-cache-size") * 1024 * 1024); |
1050 | soup_cache_load (SOUP_CACHE (feature)); |
1051 | g_free (config_file); |
1052 | -#endif |
1053 | + #endif |
1054 | return FALSE; |
1055 | } |
1056 | |
1057 | |
1058 | === modified file 'wscript' |
1059 | --- wscript 2013-07-16 14:20:37 +0000 |
1060 | +++ wscript 2013-07-29 21:07:25 +0000 |
1061 | @@ -278,7 +278,7 @@ |
1062 | conf.check_message_custom ('unique', '', 'disabled') |
1063 | conf.define ('HAVE_UNIQUE', [0,1][conf.env['UNIQUE_VERSION'] != 'No']) |
1064 | |
1065 | - check_pkg ('libsoup-2.4', '2.27.90', var='LIBSOUP') |
1066 | + check_pkg ('libsoup-gnome-2.4', '2.27.90', var='LIBSOUP') |
1067 | if check_version (conf.env['LIBSOUP_VERSION'], 2, 29, 91): |
1068 | conf.define ('HAVE_LIBSOUP_2_29_91', 1) |
1069 | if check_version (conf.env['LIBSOUP_VERSION'], 2, 34, 0): |
As the question come up in IRC: the cookie manager does show cookies. It won't yet update in real-time. I haven't made up my mind what the best approach is since the WebKit2 API has a "changed" signal but doesn't say what happens…