Create cookie jar on startup instead of waiting for an HTTP request
This commit is contained in:
parent
1aa158d78f
commit
15790565e8
2 changed files with 20 additions and 45 deletions
|
@ -218,7 +218,6 @@ cookie_jar_changed_cb (SoupCookieJar* jar,
|
|||
SoupCookie* new_cookie,
|
||||
gchar* filename)
|
||||
{
|
||||
GObject* app;
|
||||
GObject* settings;
|
||||
guint accept_cookies;
|
||||
|
||||
|
@ -229,10 +228,7 @@ cookie_jar_changed_cb (SoupCookieJar* jar,
|
|||
{
|
||||
FILE *out;
|
||||
|
||||
/* FIXME: This is really a hack */
|
||||
app = g_type_get_qdata (SOUP_TYPE_SESSION,
|
||||
g_quark_from_static_string ("midori-app"));
|
||||
settings = katze_object_get_object (G_OBJECT (app), "settings");
|
||||
settings = g_object_get_data (G_OBJECT (jar), "midori-settings");
|
||||
accept_cookies = katze_object_get_enum (settings, "accept-cookies");
|
||||
if (accept_cookies == 2 /* MIDORI_ACCEPT_COOKIES_NONE */)
|
||||
{
|
||||
|
@ -259,45 +255,28 @@ cookie_jar_changed_cb (SoupCookieJar* jar,
|
|||
}
|
||||
|
||||
static void
|
||||
katze_http_cookies_session_request_queued_cb (SoupSession* session,
|
||||
SoupMessage* msg,
|
||||
SoupSessionFeature* feature)
|
||||
katze_http_cookies_attach (SoupSessionFeature* feature,
|
||||
SoupSession* session)
|
||||
{
|
||||
const gchar* filename;
|
||||
SoupSessionFeature* cookie_jar;
|
||||
|
||||
filename = g_object_get_data (G_OBJECT (feature), "filename");
|
||||
if (!filename)
|
||||
return;
|
||||
gchar* filename;
|
||||
|
||||
cookie_jar = soup_session_get_feature (session, SOUP_TYPE_COOKIE_JAR);
|
||||
if (!cookie_jar)
|
||||
return;
|
||||
|
||||
g_type_set_qdata (SOUP_TYPE_COOKIE_JAR,
|
||||
g_quark_from_static_string ("midori-has-jar"), (void*)1);
|
||||
g_return_if_fail (cookie_jar != NULL);
|
||||
filename = g_object_get_data (G_OBJECT (feature), "filename");
|
||||
g_return_if_fail (filename != NULL);
|
||||
cookie_jar_load (SOUP_COOKIE_JAR (cookie_jar), filename);
|
||||
g_signal_connect_data (cookie_jar, "changed",
|
||||
G_CALLBACK (cookie_jar_changed_cb), g_strdup (filename),
|
||||
(GClosureNotify)g_free, 0);
|
||||
g_signal_handlers_disconnect_by_func (session,
|
||||
katze_http_cookies_session_request_queued_cb, feature);
|
||||
}
|
||||
|
||||
static void
|
||||
katze_http_cookies_attach (SoupSessionFeature* feature,
|
||||
SoupSession* session)
|
||||
{
|
||||
g_signal_connect (session, "request-queued",
|
||||
G_CALLBACK (katze_http_cookies_session_request_queued_cb), feature);
|
||||
}
|
||||
|
||||
static void
|
||||
katze_http_cookies_detach (SoupSessionFeature* feature,
|
||||
SoupSession* session)
|
||||
{
|
||||
g_signal_handlers_disconnect_by_func (session,
|
||||
katze_http_cookies_session_request_queued_cb, feature);
|
||||
/* Nothing to do. */
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -1320,6 +1320,7 @@ midori_soup_session_debug (SoupSession* session)
|
|||
|
||||
static void
|
||||
midori_soup_session_prepare (SoupSession* session,
|
||||
SoupCookieJar* cookie_jar,
|
||||
MidoriWebSettings* settings)
|
||||
{
|
||||
SoupSessionFeature* feature;
|
||||
|
@ -1341,6 +1342,7 @@ midori_soup_session_prepare (SoupSession* session,
|
|||
config_file = build_config_filename ("cookies.txt");
|
||||
g_object_set_data_full (G_OBJECT (feature), "filename",
|
||||
config_file, (GDestroyNotify)g_free);
|
||||
soup_session_add_feature (session, SOUP_SESSION_FEATURE (cookie_jar));
|
||||
soup_session_add_feature (session, feature);
|
||||
}
|
||||
|
||||
|
@ -1644,6 +1646,7 @@ main (int argc,
|
|||
KatzeItem* item;
|
||||
gchar* uri_ready;
|
||||
KatzeNet* net;
|
||||
SoupSession* webkit_session;
|
||||
SoupSession* s_session;
|
||||
SoupCookieJar* jar;
|
||||
#if HAVE_SQLITE
|
||||
|
@ -1869,22 +1872,15 @@ main (int argc,
|
|||
}
|
||||
g_string_free (error_messages, TRUE);
|
||||
|
||||
if (1)
|
||||
{
|
||||
SoupSession* webkit_session = webkit_get_default_session ();
|
||||
|
||||
webkit_session = webkit_get_default_session ();
|
||||
net = katze_net_new ();
|
||||
s_session = katze_net_get_session (net);
|
||||
g_type_set_qdata (SOUP_TYPE_SESSION,
|
||||
g_quark_from_static_string ("midori-app"), app);
|
||||
jar = soup_cookie_jar_new ();
|
||||
soup_session_add_feature (s_session, SOUP_SESSION_FEATURE (jar));
|
||||
soup_session_add_feature (webkit_session, SOUP_SESSION_FEATURE (jar));
|
||||
g_object_set_data (G_OBJECT (jar), "midori-settings", settings);
|
||||
midori_soup_session_prepare (s_session, jar, settings);
|
||||
midori_soup_session_prepare (webkit_session, jar, settings);
|
||||
g_object_unref (jar);
|
||||
midori_soup_session_prepare (s_session, settings);
|
||||
midori_soup_session_prepare (webkit_session, settings);
|
||||
g_object_unref (net);
|
||||
}
|
||||
|
||||
/* Open as many tabs as we have uris, seperated by pipes */
|
||||
i = 0;
|
||||
|
|
Loading…
Reference in a new issue