[Xfce4-commits] <midori:master> Move session loading steps into its own file
Christian Dywan
noreply at xfce.org
Mon Nov 26 19:06:03 CET 2012
Updating branch refs/heads/master
to 114214bc5c13bfe79e436664dc2c1ddc20b2c557 (commit)
from 20ed959262dd2b718aa7ec747bb4e2b180938216 (commit)
commit 114214bc5c13bfe79e436664dc2c1ddc20b2c557
Author: Christian Dywan <christian at twotoasts.de>
Date: Mon Nov 26 18:32:12 2012 +0100
Move session loading steps into its own file
midori/main.c | 599 ++---------------------------------------------
midori/midori-app.c | 2 +-
midori/midori-session.c | 550 +++++++++++++++++++++++++++++++++++++++++++
midori/midori-session.h | 30 +++
midori/sokoke.c | 4 +-
po/POTFILES.in | 1 +
6 files changed, 601 insertions(+), 585 deletions(-)
diff --git a/midori/main.c b/midori/main.c
index c68f18d..febab2a 100644
--- a/midori/main.c
+++ b/midori/main.c
@@ -14,7 +14,6 @@
#include "midori-array.h"
#include "midori-bookmarks.h"
#include "panels/midori-bookmarks.h"
-#include "midori-extension.h"
#include "midori-history.h"
#include "panels/midori-history.h"
#include "midori-transfers.h"
@@ -23,6 +22,7 @@
#include "midori-preferences.h"
#include "midori-privatedata.h"
#include "midori-searchaction.h"
+#include "midori/midori-session.h"
#include <midori/midori-core.h>
#include <config.h>
@@ -38,43 +38,6 @@
#include <webkit/webkit.h>
#include <sqlite3.h>
-#if WEBKIT_CHECK_VERSION (1, 3, 11)
- #define LIBSOUP_USE_UNSTABLE_REQUEST_API
- #include <libsoup/soup-cache.h>
-#endif
-
-static void
-settings_notify_cb (MidoriWebSettings* settings,
- GParamSpec* pspec,
- MidoriApp* app)
-{
- GError* error = NULL;
- gchar* config_file;
-
- /* Skip state related properties to avoid disk IO */
- if (pspec && midori_settings_delay_saving (MIDORI_SETTINGS (settings), pspec->name))
- return;
-
- config_file = midori_paths_get_config_filename_for_writing ("config");
- if (!midori_settings_save_to_file (settings, G_OBJECT (app), config_file, &error))
- {
- g_warning (_("The configuration couldn't be saved. %s"), error->message);
- g_error_free (error);
- }
- g_free (config_file);
-}
-
-static void
-accel_map_changed_cb (GtkAccelMap* accel_map,
- gchar* accel_path,
- guint accel_key,
- GdkModifierType accel_mods)
-{
- gchar* config_file = midori_paths_get_config_filename_for_writing ("accels");
- gtk_accel_map_save (config_file);
- g_free (config_file);
-}
-
static void
midori_trash_add_item_no_save_cb (KatzeArray* trash,
GObject* item)
@@ -154,283 +117,6 @@ midori_app_add_browser_cb (MidoriApp* app,
g_object_unref (panel);
}
-static guint save_timeout = 0;
-
-static gboolean
-midori_session_save_timeout_cb (KatzeArray* session)
-{
- gchar* config_file = midori_paths_get_config_filename_for_writing ("session.xbel");
- GError* error = NULL;
- if (!midori_array_to_file (session, config_file, "xbel", &error))
- {
- g_warning (_("The session couldn't be saved. %s"), error->message);
- g_error_free (error);
- }
- g_free (config_file);
-
- save_timeout = 0;
- g_object_unref (session);
-
- return FALSE;
-}
-
-static void
-midori_browser_session_cb (MidoriBrowser* browser,
- gpointer pspec,
- KatzeArray* session)
-{
- if (!save_timeout)
- {
- g_object_ref (session);
- save_timeout = g_timeout_add_seconds (5,
- (GSourceFunc)midori_session_save_timeout_cb, session);
- }
-}
-
-static void
-midori_app_quit_cb (MidoriBrowser* browser,
- KatzeArray* session)
-{
- midori_session_save_timeout_cb (session);
-}
-
-static void
-midori_browser_weak_notify_cb (MidoriBrowser* browser,
- KatzeArray* session)
-{
- g_object_disconnect (browser, "any-signal",
- G_CALLBACK (midori_browser_session_cb), session, NULL);
-}
-
-static void
-midori_soup_session_set_proxy_uri (SoupSession* session,
- const gchar* uri)
-{
- gchar* fixed_uri;
- SoupURI* proxy_uri;
-
- /* soup_uri_new expects a non-NULL string with a protocol */
- if (midori_uri_is_http (uri))
- proxy_uri = soup_uri_new (uri);
- else if (uri && *uri)
- {
- fixed_uri = g_strconcat ("http://", uri, NULL);
- proxy_uri = soup_uri_new (fixed_uri);
- g_free (fixed_uri);
- }
- else
- proxy_uri = NULL;
- g_object_set (session, "proxy-uri", proxy_uri, NULL);
- if (proxy_uri)
- soup_uri_free (proxy_uri);
-}
-
-static void
-soup_session_settings_notify_http_proxy_cb (MidoriWebSettings* settings,
- GParamSpec* pspec,
- SoupSession* session)
-{
- MidoriProxy proxy_type;
-
- proxy_type = katze_object_get_enum (settings, "proxy-type");
- if (proxy_type == MIDORI_PROXY_AUTOMATIC)
- {
- gboolean gnome_supported = FALSE;
- GModule* module;
- GType (*get_type_function) (void);
- if (g_module_supported ())
- if ((module = g_module_open ("libsoup-gnome-2.4.so", G_MODULE_BIND_LOCAL)))
- {
- if (g_module_symbol (module, "soup_proxy_resolver_gnome_get_type",
- (void*) &get_type_function))
- {
- soup_session_add_feature_by_type (session, get_type_function ());
- gnome_supported = TRUE;
- }
- }
- if (!gnome_supported)
- midori_soup_session_set_proxy_uri (session, g_getenv ("http_proxy"));
- }
- else if (proxy_type == MIDORI_PROXY_HTTP)
- {
- gchar* proxy = katze_object_get_string (settings, "http-proxy");
- GString *http_proxy = g_string_new (proxy);
- g_string_append_printf (http_proxy, ":%d", katze_object_get_int (settings, "http-proxy-port"));
- midori_soup_session_set_proxy_uri (session, http_proxy->str);
- g_string_free (http_proxy, TRUE);
- g_free (proxy);
- }
- else
- midori_soup_session_set_proxy_uri (session, NULL);
-}
-
-#ifdef HAVE_LIBSOUP_2_29_91
-static void
-soup_session_settings_notify_first_party_cb (MidoriWebSettings* settings,
- GParamSpec* pspec,
- SoupSession* session)
-{
- void* jar = soup_session_get_feature (session, SOUP_TYPE_COOKIE_JAR);
- gboolean yes = katze_object_get_boolean (settings, "first-party-cookies-only");
- g_object_set (jar, "accept-policy",
- yes ? SOUP_COOKIE_JAR_ACCEPT_NO_THIRD_PARTY
- : SOUP_COOKIE_JAR_ACCEPT_ALWAYS, NULL);
-}
-#endif
-
-#if defined (HAVE_LIBSOUP_2_34_0)
-/* Implemented in MidoriLocationAction */
-void
-midori_map_add_message (SoupMessage* message);
-
-static void
-midori_soup_session_request_started_cb (SoupSession* session,
- SoupMessage* message,
- SoupSocket* socket,
- gpointer user_data)
-{
- midori_map_add_message (message);
-}
-#endif
-
-static void
-midori_soup_session_settings_accept_language_cb (SoupSession* session,
- SoupMessage* msg,
- MidoriWebSettings* settings)
-{
- const gchar* accept = midori_web_settings_get_accept_language (settings);
- soup_message_headers_append (msg->request_headers, "Accept-Language", accept);
-
- if (katze_object_get_boolean (settings, "strip-referer"))
- {
- const gchar* referer
- = soup_message_headers_get_one (msg->request_headers, "Referer");
- SoupURI* destination = soup_message_get_uri (msg);
- SoupURI* stripped_uri;
- if (referer && destination && !strstr (referer, destination->host)
- && (stripped_uri = soup_uri_new (referer)))
- {
- gchar* stripped_referer;
- soup_uri_set_path (stripped_uri, "");
- soup_uri_set_query (stripped_uri, NULL);
- stripped_referer = soup_uri_to_string (stripped_uri, FALSE);
- soup_uri_free (stripped_uri);
- if (strcmp (stripped_referer, referer))
- {
- if (midori_debug ("referer"))
- g_message ("Referer '%s' stripped to '%s'", referer, stripped_referer);
- soup_message_headers_replace (msg->request_headers, "Referer",
- stripped_referer);
- }
- g_free (stripped_referer);
- }
-
- /* With HTTP, Host is optional. Strip to outsmart some filter proxies */
- if (destination && destination->scheme == SOUP_URI_SCHEME_HTTP)
- soup_message_headers_remove (msg->request_headers, "Host");
- }
-}
-
-static void
-midori_soup_session_debug (SoupSession* session)
-{
- gint soup_debug_level = 0;
- if (midori_debug ("headers"))
- soup_debug_level = SOUP_LOGGER_LOG_HEADERS;
- else if (midori_debug ("body"))
- soup_debug_level = SOUP_LOGGER_LOG_BODY;
- if (soup_debug_level > 0)
- {
- SoupLogger* logger = soup_logger_new (soup_debug_level, -1);
- soup_logger_attach (logger, session);
- g_object_unref (logger);
- }
-}
-
-static gboolean
-midori_load_soup_session (gpointer settings)
-{
- SoupSession* session = webkit_get_default_session ();
-
- #ifndef G_OS_WIN32
- #if defined (HAVE_LIBSOUP_2_37_1)
- g_object_set (session,
- "ssl-use-system-ca-file", TRUE,
- "ssl-strict", FALSE,
- NULL);
- #elif defined (HAVE_LIBSOUP_2_29_91)
- const gchar* certificate_files[] =
- {
- "/etc/pki/tls/certs/ca-bundle.crt",
- "/etc/ssl/certs/ca-certificates.crt",
- "/etc/ssl/certs/ca-bundle.crt",
- "/usr/local/share/certs/ca-root-nss.crt", /* FreeBSD */
- "/var/lib/ca-certificates/ca-bundle.pem", /* openSUSE */
- NULL
- };
- guint i;
-
- for (i = 0; i < G_N_ELEMENTS (certificate_files); i++)
- if (g_access (certificate_files[i], F_OK) == 0)
- {
- g_object_set (session,
- "ssl-ca-file", certificate_files[i],
- "ssl-strict", FALSE,
- NULL);
- break;
- }
- if (i == G_N_ELEMENTS (certificate_files))
- g_warning (_("No root certificate file is available. "
- "SSL certificates cannot be verified."));
- #endif
- #else /* G_OS_WIN32 */
- /* We cannot use "ssl-use-system-ca-file" on Windows
- * some GTLS backend pieces are missing currently.
- * Instead we specify the bundle we ship ourselves */
- gchar* certificate_file = midori_paths_get_res_filename ("ca-bundle.crt");
- g_object_set (session,
- "ssl-ca-file", certificate_file,
- "ssl-strict", FALSE,
- NULL);
- g_free (certificate_file);
- #endif
-
- #if !WEBKIT_CHECK_VERSION (1, 3, 5)
- /* See http://stevesouders.com/ua/index.php */
- g_object_set (session, "max-conns", 60,
- "max-conns-per-host", 6,
- NULL);
- #endif
-
- g_object_set_data (G_OBJECT (session), "midori-settings", settings);
- soup_session_settings_notify_http_proxy_cb (settings, NULL, session);
- g_signal_connect (settings, "notify::http-proxy",
- G_CALLBACK (soup_session_settings_notify_http_proxy_cb), session);
- g_signal_connect (settings, "notify::proxy-type",
- G_CALLBACK (soup_session_settings_notify_http_proxy_cb), session);
- #ifdef HAVE_LIBSOUP_2_29_91
- if (g_object_class_find_property (G_OBJECT_GET_CLASS (settings),
- "enable-file-access-from-file-uris")) /* WebKitGTK+ >= 1.1.21 */
- g_signal_connect (settings, "notify::first-party-cookies-only",
- G_CALLBACK (soup_session_settings_notify_first_party_cb), session);
- #endif
-
- #if defined (HAVE_LIBSOUP_2_34_0)
- g_signal_connect (session, "request-started",
- G_CALLBACK (midori_soup_session_request_started_cb), session);
- #endif
- g_signal_connect (session, "request-queued",
- G_CALLBACK (midori_soup_session_settings_accept_language_cb), settings);
-
- soup_session_add_feature (session, SOUP_SESSION_FEATURE (midori_hsts_new ()));
-
- midori_soup_session_debug (session);
-
- g_object_set_data (G_OBJECT (session), "midori-session-initialized", (void*)1);
-
- return FALSE;
-}
-
static void
button_modify_preferences_clicked_cb (GtkWidget* button,
MidoriWebSettings* settings)
@@ -452,14 +138,14 @@ button_disable_extensions_clicked_cb (GtkWidget* button,
static MidoriStartup
midori_show_diagnostic_dialog (MidoriWebSettings* settings,
- KatzeArray* _session)
+ KatzeArray* session)
{
GtkWidget* dialog;
GtkWidget* content_area;
GtkWidget* align;
GtkWidget* box;
GtkWidget* button;
- MidoriApp* app = katze_item_get_parent (KATZE_ITEM (_session));
+ MidoriApp* app = katze_item_get_parent (KATZE_ITEM (session));
MidoriStartup load_on_startup = katze_object_get_enum (settings, "load-on-startup");
gint response;
@@ -528,243 +214,10 @@ midori_show_diagnostic_dialog (MidoriWebSettings* settings,
if (response == GTK_RESPONSE_DELETE_EVENT)
response = G_MAXINT;
else if (response == MIDORI_STARTUP_BLANK_PAGE)
- katze_array_clear (_session);
+ katze_array_clear (session);
return response;
}
-static gboolean
-midori_load_soup_session_full (gpointer settings)
-{
- SoupSession* session = webkit_get_default_session ();
- SoupCookieJar* jar;
- gchar* config_file;
- SoupSessionFeature* feature;
- gboolean have_new_cookies;
- SoupSessionFeature* feature_import;
-
- midori_load_soup_session (settings);
-
- config_file = midori_paths_get_config_filename_for_writing ("logins");
- feature = g_object_new (KATZE_TYPE_HTTP_AUTH, "filename", config_file, NULL);
- soup_session_add_feature (session, feature);
- g_object_unref (feature);
-
- jar = soup_cookie_jar_new ();
- g_object_set_data (G_OBJECT (jar), "midori-settings", settings);
- soup_session_add_feature (session, SOUP_SESSION_FEATURE (jar));
- g_object_unref (jar);
-
- katze_assign (config_file, midori_paths_get_config_filename_for_writing ("cookies.db"));
- have_new_cookies = g_access (config_file, F_OK) == 0;
- feature = g_object_new (KATZE_TYPE_HTTP_COOKIES_SQLITE, NULL);
- g_object_set_data_full (G_OBJECT (feature), "filename",
- config_file, (GDestroyNotify)g_free);
- soup_session_add_feature (session, feature);
- g_object_unref (feature);
-
- if (!have_new_cookies)
- {
- katze_assign (config_file, midori_paths_get_config_filename_for_writing ("cookies.txt"));
- if (g_access (config_file, F_OK) == 0)
- {
- g_message ("Importing cookies from txt to sqlite3");
- feature_import = g_object_new (KATZE_TYPE_HTTP_COOKIES, NULL);
- g_object_set_data_full (G_OBJECT (feature_import), "filename",
- config_file, (GDestroyNotify)g_free);
- soup_session_add_feature (session, SOUP_SESSION_FEATURE (feature_import));
- soup_session_remove_feature (session, SOUP_SESSION_FEATURE (feature_import));
- }
- }
-
- #if WEBKIT_CHECK_VERSION (1, 3, 11)
- katze_assign (config_file, g_build_filename (midori_paths_get_cache_dir (), "web", NULL));
- feature = SOUP_SESSION_FEATURE (soup_cache_new (config_file, 0));
- soup_session_add_feature (session, feature);
- soup_cache_set_max_size (SOUP_CACHE (feature),
- katze_object_get_int (settings, "maximum-cache-size") * 1024 * 1024);
- soup_cache_load (SOUP_CACHE (feature));
- #endif
-
- #if WEBKIT_CHECK_VERSION (1, 8, 0)
- katze_assign (config_file, g_build_filename (midori_paths_get_user_data_dir (),
- "webkit", "icondatabase", NULL));
- webkit_favicon_database_set_path (webkit_get_favicon_database (), config_file);
- #endif
- g_free (config_file);
-
- return FALSE;
-}
-
-static void
-extensions_update_cb (KatzeArray* extensions,
- MidoriApp* app)
-{
- MidoriWebSettings* settings = katze_object_get_object (app, "settings");
- settings_notify_cb (settings, NULL, app);
- g_object_unref (settings);
-}
-
-static gboolean
-midori_load_extensions (gpointer data)
-{
- MidoriApp* app = MIDORI_APP (data);
- gchar** keys = g_object_get_data (G_OBJECT (app), "extensions");
- KatzeArray* extensions;
- #ifdef G_ENABLE_DEBUG
- gboolean startup_timer = midori_debug ("startup");
- GTimer* timer = startup_timer ? g_timer_new () : NULL;
- #endif
-
- /* Load extensions */
- extensions = katze_array_new (MIDORI_TYPE_EXTENSION);
- g_signal_connect (extensions, "update", G_CALLBACK (extensions_update_cb), app);
- g_object_set (app, "extensions", extensions, NULL);
-
- if (g_module_supported ())
- {
- gchar* extension_path;
- if (keys && (extension_path = midori_paths_get_lib_path (PACKAGE_NAME)))
- {
- gint i = 0;
- const gchar* filename;
- while ((filename = keys[i++]))
- midori_extension_activate_gracefully (app, extension_path, filename, TRUE);
- g_free (extension_path);
- }
- }
-
- #ifdef G_ENABLE_DEBUG
- if (startup_timer)
- g_debug ("Extensions:\t%f", g_timer_elapsed (timer, NULL));
- #endif
-
- return FALSE;
-}
-
-static void
-midori_browser_action_last_session_activate_cb (GtkAction* action,
- MidoriBrowser* browser)
-{
- KatzeArray* old_session = katze_array_new (KATZE_TYPE_ITEM);
- gchar* config_file = midori_paths_get_config_filename_for_reading ("session.old.xbel");
- GError* error = NULL;
- if (midori_array_from_file (old_session, config_file, "xbel", &error))
- {
- KatzeItem* item;
- KATZE_ARRAY_FOREACH_ITEM (item, old_session)
- midori_browser_add_item (browser, item);
- }
- else
- {
- g_warning (_("The session couldn't be loaded: %s\n"), error->message);
- /* FIXME: Show a graphical dialog */
- g_error_free (error);
- }
- g_free (config_file);
- gtk_action_set_sensitive (action, FALSE);
- g_signal_handlers_disconnect_by_func (action,
- midori_browser_action_last_session_activate_cb, browser);
-}
-
-static gboolean
-midori_load_session (gpointer data)
-{
- KatzeArray* _session = KATZE_ARRAY (data);
- MidoriBrowser* browser;
- MidoriApp* app = katze_item_get_parent (KATZE_ITEM (_session));
- MidoriWebSettings* settings = katze_object_get_object (app, "settings");
- MidoriStartup load_on_startup;
- gchar* config_file;
- KatzeArray* session;
- KatzeItem* item;
- gint64 current;
- gchar** command = g_object_get_data (G_OBJECT (app), "execute-command");
- #ifdef G_ENABLE_DEBUG
- gboolean startup_timer = midori_debug ("startup");
- GTimer* timer = startup_timer ? g_timer_new () : NULL;
- #endif
-
- browser = midori_app_create_browser (app);
- g_signal_connect_after (settings, "notify", G_CALLBACK (settings_notify_cb), app);
-
- config_file = midori_paths_get_config_filename_for_reading ("session.old.xbel");
- if (g_access (config_file, F_OK) == 0)
- {
- GtkActionGroup* action_group = midori_browser_get_action_group (browser);
- GtkAction* action = gtk_action_group_get_action (action_group, "LastSession");
- g_signal_connect (action, "activate",
- G_CALLBACK (midori_browser_action_last_session_activate_cb), browser);
- gtk_action_set_visible (action, TRUE);
- }
- midori_app_add_browser (app, browser);
- gtk_widget_show (GTK_WIDGET (browser));
-
- katze_assign (config_file, midori_paths_get_config_filename_for_reading ("accels"));
- g_signal_connect_after (gtk_accel_map_get (), "changed",
- G_CALLBACK (accel_map_changed_cb), NULL);
-
- load_on_startup = (MidoriStartup)g_object_get_data (G_OBJECT (settings), "load-on-startup");
- if (katze_array_is_empty (_session))
- {
- gchar* homepage;
- item = katze_item_new ();
-
- if (load_on_startup == MIDORI_STARTUP_BLANK_PAGE)
- katze_item_set_uri (item, "");
- else
- {
- g_object_get (settings, "homepage", &homepage, NULL);
- katze_item_set_uri (item, homepage);
- g_free (homepage);
- }
- katze_array_add_item (_session, item);
- g_object_unref (item);
- }
-
- session = midori_browser_get_proxy_array (browser);
- KATZE_ARRAY_FOREACH_ITEM (item, _session)
- {
- katze_item_set_meta_integer (item, "append", 1);
- katze_item_set_meta_integer (item, "dont-write-history", 1);
- if (load_on_startup == MIDORI_STARTUP_DELAYED_PAGES
- || katze_item_get_meta_integer (item, "delay") == MIDORI_DELAY_PENDING_UNDELAY)
- katze_item_set_meta_integer (item, "delay", MIDORI_DELAY_DELAYED);
- midori_browser_add_item (browser, item);
- }
- current = katze_item_get_meta_integer (KATZE_ITEM (_session), "current");
- if (!(item = katze_array_get_nth_item (_session, current)))
- {
- current = 0;
- item = katze_array_get_nth_item (_session, 0);
- }
- midori_browser_set_current_page (browser, current);
- if (midori_uri_is_blank (katze_item_get_uri (item)))
- midori_browser_activate_action (browser, "Location");
-
- g_object_unref (settings);
- g_object_unref (_session);
- g_free (config_file);
-
- g_signal_connect_after (browser, "add-tab",
- G_CALLBACK (midori_browser_session_cb), session);
- g_signal_connect_after (browser, "remove-tab",
- G_CALLBACK (midori_browser_session_cb), session);
- g_signal_connect (app, "quit",
- G_CALLBACK (midori_app_quit_cb), session);
- g_object_weak_ref (G_OBJECT (session),
- (GWeakNotify)(midori_browser_weak_notify_cb), browser);
-
- if (command)
- midori_app_send_command (app, command);
-
- #ifdef G_ENABLE_DEBUG
- if (startup_timer)
- g_debug ("Session setup:\t%f", g_timer_elapsed (timer, NULL));
- #endif
-
- return FALSE;
-}
-
#define HAVE_OFFSCREEN GTK_CHECK_VERSION (2, 20, 0)
static void
@@ -838,10 +291,8 @@ main (int argc,
{
{ "app", 'a', 0, G_OPTION_ARG_STRING, &webapp,
N_("Run ADDRESS as a web application"), N_("ADDRESS") },
- #if !HAVE_HILDON
{ "config", 'c', 0, G_OPTION_ARG_FILENAME, &config,
N_("Use FOLDER as configuration folder"), N_("FOLDER") },
- #endif
{ "private", 'p', 0, G_OPTION_ARG_NONE, &private,
N_("Private browsing, no changes are saved"), NULL },
#ifdef G_OS_WIN32
@@ -882,14 +333,13 @@ main (int argc,
KatzeArray* search_engines;
KatzeArray* bookmarks;
KatzeArray* history;
- KatzeArray* _session;
+ KatzeArray* session;
KatzeArray* trash;
guint i;
gchar* uri;
KatzeItem* item;
gchar* uri_ready;
gchar* errmsg;
- sqlite3* db;
#ifdef G_ENABLE_DEBUG
gboolean startup_timer = midori_debug ("startup");
#define midori_startup_timer(tmrmsg) if (startup_timer) \
@@ -1178,7 +628,7 @@ main (int argc,
gchar* tmp_uri = sokoke_prepare_uri (webapp);
midori_browser_set_action_visible (browser, "Menubar", FALSE);
midori_browser_set_action_visible (browser, "CompactMenu", FALSE);
- midori_browser_add_uri (browser, tmp_uri ? tmp_uri : webapp);
+ midori_browser_add_uri (browser, tmp_uri);
g_object_set (settings,
"show-menubar", FALSE,
"show-navigationbar", FALSE,
@@ -1294,14 +744,13 @@ main (int argc,
midori_startup_timer ("Bookmarks read: \t%f");
config_file = NULL;
- _session = katze_array_new (KATZE_TYPE_ITEM);
+ session = katze_array_new (KATZE_TYPE_ITEM);
load_on_startup = katze_object_get_enum (settings, "load-on-startup");
- #if HAVE_LIBXML
if (load_on_startup >= MIDORI_STARTUP_LAST_OPEN_PAGES)
{
katze_assign (config_file, midori_paths_get_config_filename_for_reading ("session.xbel"));
error = NULL;
- if (!midori_array_from_file (_session, config_file, "xbel", &error))
+ if (!midori_array_from_file (session, config_file, "xbel", &error))
{
if (error->code != G_FILE_ERROR_NOENT)
g_string_append_printf (error_messages,
@@ -1309,11 +758,9 @@ main (int argc,
g_error_free (error);
}
}
- #endif
midori_startup_timer ("Session read: \t%f");
trash = katze_array_new (KATZE_TYPE_ITEM);
- #if HAVE_LIBXML
katze_assign (config_file, g_build_filename (config, "tabtrash.xbel", NULL));
error = NULL;
if (!midori_array_from_file (trash, config_file, "xbel", &error))
@@ -1323,8 +770,6 @@ main (int argc,
_("The trash couldn't be loaded: %s\n"), error->message);
g_error_free (error);
}
- #endif
-
midori_startup_timer ("Trash read: \t%f");
if (!(history = midori_history_new (&errmsg)))
@@ -1361,26 +806,17 @@ main (int argc,
/* If -e or --execute was specified, "uris" refers to the command. */
if (!execute)
{
- /* Open as many tabs as we have uris, seperated by pipes */
- i = 0;
- while (uris && uris[i])
- {
- uri = strtok (g_strdup (uris[i]), "|");
- while (uri != NULL)
+ i = 0;
+ while (uris && uris[i])
{
item = katze_item_new ();
- uri_ready = sokoke_prepare_uri (uri);
- katze_item_set_uri (item, uri_ready ? uri_ready : uri);
- g_free (uri_ready);
+ item->uri = sokoke_prepare_uri (uris[i]);
/* Never delay command line arguments */
katze_item_set_meta_integer (item, "delay", 0);
- katze_array_add_item (_session, item);
- uri = strtok (NULL, "|");
+ katze_array_add_item (session, item);
}
- g_free (uri);
i++;
}
- }
katze_assign (config_file, g_build_filename (config, "search", NULL));
midori_search_engines_set_filename (search_engines, config_file);
@@ -1390,18 +826,17 @@ main (int argc,
g_signal_connect_after (trash, "remove-item",
G_CALLBACK (midori_trash_remove_item_cb), NULL);
- katze_item_set_parent (KATZE_ITEM (_session), app);
+ katze_item_set_parent (KATZE_ITEM (session), app);
g_object_set_data_full (G_OBJECT (app), "extensions", extensions, (GDestroyNotify)g_strfreev);
-
if (midori_app_get_crashed (app)
&& katze_object_get_boolean (settings, "show-crash-dialog")
- && !katze_array_is_empty (_session))
+ && !katze_array_is_empty (session))
diagnostic_dialog = TRUE;
if (diagnostic_dialog)
{
- load_on_startup = midori_show_diagnostic_dialog (settings, _session);
+ load_on_startup = midori_show_diagnostic_dialog (settings, session);
if (load_on_startup == G_MAXINT)
return 0;
}
@@ -1425,14 +860,14 @@ main (int argc,
g_idle_add (midori_load_soup_session_full, settings);
g_idle_add (midori_load_extensions, app);
- g_idle_add (midori_load_session, _session);
+ g_idle_add (midori_load_session, session);
if (execute)
g_object_set_data (G_OBJECT (app), "execute-command", uris);
gtk_main ();
- settings_notify_cb (settings, NULL, app);
+ g_object_notify (G_OBJECT (settings), "load-on-startup");
midori_bookmarks_on_quit (bookmarks);
midori_history_on_quit (history, settings);
midori_private_data_on_quit (settings);
diff --git a/midori/midori-app.c b/midori/midori-app.c
index b49f43c..c00ba52 100644
--- a/midori/midori-app.c
+++ b/midori/midori-app.c
@@ -1152,7 +1152,7 @@ midori_app_instance_send_uris (MidoriApp* app,
while (uris[i] != NULL)
{
gchar* new_uri = sokoke_prepare_uri (uris[i]);
- gchar* escaped_uri = g_uri_escape_string (new_uri ? new_uri : uris[i], NULL, FALSE);
+ gchar* escaped_uri = g_uri_escape_string (new_uri, NULL, FALSE);
g_free (new_uri);
katze_assign (uris[i], escaped_uri);
i++;
diff --git a/midori/midori-session.c b/midori/midori-session.c
new file mode 100644
index 0000000..dbdb425
--- /dev/null
+++ b/midori/midori-session.c
@@ -0,0 +1,550 @@
+/*
+ Copyright (C) 2008-2012 Christian Dywan <christian at twotoasts.de>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ See the file COPYING for the full license text.
+*/
+
+#include "midori/midori-session.h"
+
+#include <midori/midori-core.h>
+#include "midori-app.h"
+#include "midori-array.h"
+#include "midori-websettings.h"
+#include "midori-extension.h"
+
+#include <glib/gi18n-lib.h>
+
+#if WEBKIT_CHECK_VERSION (1, 3, 11)
+ #define LIBSOUP_USE_UNSTABLE_REQUEST_API
+ #include <libsoup/soup-cache.h>
+#endif
+
+static void
+midori_soup_session_set_proxy_uri (SoupSession* session,
+ const gchar* uri)
+{
+ SoupURI* proxy_uri;
+
+ /* soup_uri_new expects a non-NULL string with a protocol */
+ if (midori_uri_is_http (uri))
+ proxy_uri = soup_uri_new (uri);
+ else if (uri && *uri)
+ {
+ gchar* fixed_uri = g_strconcat ("http://", uri, NULL);
+ proxy_uri = soup_uri_new (fixed_uri);
+ g_free (fixed_uri);
+ }
+ else
+ proxy_uri = NULL;
+ g_object_set (session, "proxy-uri", proxy_uri, NULL);
+ if (proxy_uri)
+ soup_uri_free (proxy_uri);
+}
+
+static void
+soup_session_settings_notify_http_proxy_cb (MidoriWebSettings* settings,
+ GParamSpec* pspec,
+ SoupSession* session)
+{
+ MidoriProxy proxy_type = katze_object_get_enum (settings, "proxy-type");
+ if (proxy_type == MIDORI_PROXY_AUTOMATIC)
+ {
+ gboolean gnome_supported = FALSE;
+ GModule* module;
+ GType (*get_type_function) (void);
+ if (g_module_supported ())
+ if ((module = g_module_open ("libsoup-gnome-2.4.so", G_MODULE_BIND_LOCAL)))
+ {
+ if (g_module_symbol (module, "soup_proxy_resolver_gnome_get_type",
+ (void*) &get_type_function))
+ {
+ soup_session_add_feature_by_type (session, get_type_function ());
+ gnome_supported = TRUE;
+ }
+ }
+ if (!gnome_supported)
+ midori_soup_session_set_proxy_uri (session, g_getenv ("http_proxy"));
+ }
+ else if (proxy_type == MIDORI_PROXY_HTTP)
+ {
+ gchar* proxy = katze_object_get_string (settings, "http-proxy");
+ GString* http_proxy = g_string_new (proxy);
+ g_string_append_printf (http_proxy, ":%d", katze_object_get_int (settings, "http-proxy-port"));
+ midori_soup_session_set_proxy_uri (session, http_proxy->str);
+ g_string_free (http_proxy, TRUE);
+ g_free (proxy);
+ }
+ else
+ midori_soup_session_set_proxy_uri (session, NULL);
+}
+
+#ifdef HAVE_LIBSOUP_2_29_91
+static void
+soup_session_settings_notify_first_party_cb (MidoriWebSettings* settings,
+ GParamSpec* pspec,
+ SoupSession* session)
+{
+ gpointer jar = soup_session_get_feature (session, SOUP_TYPE_COOKIE_JAR);
+ gboolean yes = katze_object_get_boolean (settings, "first-party-cookies-only");
+ g_object_set (jar, "accept-policy",
+ yes ? SOUP_COOKIE_JAR_ACCEPT_NO_THIRD_PARTY
+ : SOUP_COOKIE_JAR_ACCEPT_ALWAYS, NULL);
+}
+#endif
+
+#if defined (HAVE_LIBSOUP_2_34_0)
+/* Implemented in MidoriLocationAction */
+void
+midori_map_add_message (SoupMessage* message);
+
+static void
+midori_soup_session_request_started_cb (SoupSession* session,
+ SoupMessage* message,
+ SoupSocket* socket,
+ gpointer user_data)
+{
+ midori_map_add_message (message);
+}
+#endif
+
+static void
+midori_soup_session_settings_accept_language_cb (SoupSession* session,
+ SoupMessage* msg,
+ MidoriWebSettings* settings)
+{
+ const gchar* accept = midori_web_settings_get_accept_language (settings);
+ soup_message_headers_append (msg->request_headers, "Accept-Language", accept);
+
+ if (katze_object_get_boolean (settings, "strip-referer"))
+ {
+ const gchar* referer
+ = soup_message_headers_get_one (msg->request_headers, "Referer");
+ SoupURI* destination = soup_message_get_uri (msg);
+ SoupURI* stripped_uri;
+ if (referer && destination && !strstr (referer, destination->host)
+ && (stripped_uri = soup_uri_new (referer)))
+ {
+ gchar* stripped_referer;
+ soup_uri_set_path (stripped_uri, "");
+ soup_uri_set_query (stripped_uri, NULL);
+ stripped_referer = soup_uri_to_string (stripped_uri, FALSE);
+ soup_uri_free (stripped_uri);
+ if (strcmp (stripped_referer, referer))
+ {
+ if (midori_debug ("referer"))
+ g_message ("Referer '%s' stripped to '%s'", referer, stripped_referer);
+ soup_message_headers_replace (msg->request_headers, "Referer",
+ stripped_referer);
+ }
+ g_free (stripped_referer);
+ }
+
+ /* With HTTP, Host is optional. Strip to outsmart some filter proxies */
+ if (destination && destination->scheme == SOUP_URI_SCHEME_HTTP)
+ soup_message_headers_remove (msg->request_headers, "Host");
+ }
+}
+
+gboolean
+midori_load_soup_session (gpointer settings)
+{
+ SoupSession* session = webkit_get_default_session ();
+
+ #ifndef G_OS_WIN32
+ #if defined (HAVE_LIBSOUP_2_37_1)
+ g_object_set (session,
+ "ssl-use-system-ca-file", TRUE,
+ "ssl-strict", FALSE,
+ NULL);
+ #elif defined (HAVE_LIBSOUP_2_29_91)
+ const gchar* certificate_files[] =
+ {
+ "/etc/pki/tls/certs/ca-bundle.crt",
+ "/etc/ssl/certs/ca-certificates.crt",
+ "/etc/ssl/certs/ca-bundle.crt",
+ "/usr/local/share/certs/ca-root-nss.crt", /* FreeBSD */
+ "/var/lib/ca-certificates/ca-bundle.pem", /* openSUSE */
+ NULL
+ };
+ guint i;
+
+ for (i = 0; i < G_N_ELEMENTS (certificate_files); i++)
+ if (g_access (certificate_files[i], F_OK) == 0)
+ {
+ g_object_set (session,
+ "ssl-ca-file", certificate_files[i],
+ "ssl-strict", FALSE,
+ NULL);
+ break;
+ }
+ if (i == G_N_ELEMENTS (certificate_files))
+ g_warning (_("No root certificate file is available. "
+ "SSL certificates cannot be verified."));
+ #endif
+ #else /* G_OS_WIN32 */
+ /* We cannot use "ssl-use-system-ca-file" on Windows
+ * some GTLS backend pieces are missing currently.
+ * Instead we specify the bundle we ship ourselves */
+ gchar* certificate_file = midori_paths_get_res_filename ("ca-bundle.crt");
+ g_object_set (session,
+ "ssl-ca-file", certificate_file,
+ "ssl-strict", FALSE,
+ NULL);
+ g_free (certificate_file);
+ #endif
+
+ #if !WEBKIT_CHECK_VERSION (1, 3, 5)
+ /* See http://stevesouders.com/ua/index.php */
+ g_object_set (session, "max-conns", 60,
+ "max-conns-per-host", 6,
+ NULL);
+ #endif
+
+ g_object_set_data (G_OBJECT (session), "midori-settings", settings);
+ soup_session_settings_notify_http_proxy_cb (settings, NULL, session);
+ g_signal_connect (settings, "notify::http-proxy",
+ G_CALLBACK (soup_session_settings_notify_http_proxy_cb), session);
+ g_signal_connect (settings, "notify::proxy-type",
+ G_CALLBACK (soup_session_settings_notify_http_proxy_cb), session);
+ #ifdef HAVE_LIBSOUP_2_29_91
+ if (g_object_class_find_property (G_OBJECT_GET_CLASS (settings),
+ "enable-file-access-from-file-uris")) /* WebKitGTK+ >= 1.1.21 */
+ g_signal_connect (settings, "notify::first-party-cookies-only",
+ G_CALLBACK (soup_session_settings_notify_first_party_cb), session);
+ #endif
+
+ #if defined (HAVE_LIBSOUP_2_34_0)
+ g_signal_connect (session, "request-started",
+ G_CALLBACK (midori_soup_session_request_started_cb), session);
+ #endif
+ g_signal_connect (session, "request-queued",
+ G_CALLBACK (midori_soup_session_settings_accept_language_cb), settings);
+
+ soup_session_add_feature (session, SOUP_SESSION_FEATURE (midori_hsts_new ()));
+
+ if (midori_debug ("headers"))
+ {
+ SoupLogger* logger = soup_logger_new (SOUP_LOGGER_LOG_HEADERS, -1);
+ soup_logger_attach (logger, session);
+ g_object_unref (logger);
+ }
+ else if (midori_debug ("body"))
+ {
+ SoupLogger* logger = soup_logger_new (SOUP_LOGGER_LOG_BODY, -1);
+ soup_logger_attach (logger, session);
+ g_object_unref (logger);
+ }
+
+ g_object_set_data (G_OBJECT (session), "midori-session-initialized", (void*)1);
+
+ return FALSE;
+}
+
+gboolean
+midori_load_soup_session_full (gpointer settings)
+{
+ SoupSession* session = webkit_get_default_session ();
+ SoupCookieJar* jar;
+ gchar* config_file;
+ SoupSessionFeature* feature;
+ gboolean have_new_cookies;
+ SoupSessionFeature* feature_import;
+
+ midori_load_soup_session (settings);
+
+ config_file = midori_paths_get_config_filename_for_writing ("logins");
+ feature = g_object_new (KATZE_TYPE_HTTP_AUTH, "filename", config_file, NULL);
+ soup_session_add_feature (session, feature);
+ g_object_unref (feature);
+
+ jar = soup_cookie_jar_new ();
+ g_object_set_data (G_OBJECT (jar), "midori-settings", settings);
+ soup_session_add_feature (session, SOUP_SESSION_FEATURE (jar));
+ g_object_unref (jar);
+
+ katze_assign (config_file, midori_paths_get_config_filename_for_writing ("cookies.db"));
+ have_new_cookies = g_access (config_file, F_OK) == 0;
+ feature = g_object_new (KATZE_TYPE_HTTP_COOKIES_SQLITE, NULL);
+ g_object_set_data_full (G_OBJECT (feature), "filename",
+ config_file, (GDestroyNotify)g_free);
+ soup_session_add_feature (session, feature);
+ g_object_unref (feature);
+
+ if (!have_new_cookies)
+ {
+ katze_assign (config_file, midori_paths_get_config_filename_for_writing ("cookies.txt"));
+ if (g_access (config_file, F_OK) == 0)
+ {
+ g_message ("Importing cookies from txt to sqlite3");
+ feature_import = g_object_new (KATZE_TYPE_HTTP_COOKIES, NULL);
+ g_object_set_data_full (G_OBJECT (feature_import), "filename",
+ config_file, (GDestroyNotify)g_free);
+ soup_session_add_feature (session, SOUP_SESSION_FEATURE (feature_import));
+ soup_session_remove_feature (session, SOUP_SESSION_FEATURE (feature_import));
+ }
+ }
+
+ #if WEBKIT_CHECK_VERSION (1, 3, 11)
+ katze_assign (config_file, g_build_filename (midori_paths_get_cache_dir (), "web", NULL));
+ feature = SOUP_SESSION_FEATURE (soup_cache_new (config_file, 0));
+ soup_session_add_feature (session, feature);
+ soup_cache_set_max_size (SOUP_CACHE (feature),
+ katze_object_get_int (settings, "maximum-cache-size") * 1024 * 1024);
+ soup_cache_load (SOUP_CACHE (feature));
+ #endif
+
+ #if WEBKIT_CHECK_VERSION (1, 8, 0)
+ katze_assign (config_file, g_build_filename (midori_paths_get_user_data_dir (),
+ "webkit", "icondatabase", NULL));
+ webkit_favicon_database_set_path (webkit_get_favicon_database (), config_file);
+ #endif
+ g_free (config_file);
+
+ return FALSE;
+}
+
+static void
+extensions_update_cb (KatzeArray* extensions,
+ MidoriApp* app)
+{
+ MidoriWebSettings* settings = katze_object_get_object (app, "settings");
+ g_object_notify (G_OBJECT (settings), "load-on-startup");
+ g_object_unref (settings);
+}
+
+gboolean
+midori_load_extensions (gpointer data)
+{
+ MidoriApp* app = MIDORI_APP (data);
+ gchar** keys = g_object_get_data (G_OBJECT (app), "extensions");
+ KatzeArray* extensions;
+ #ifdef G_ENABLE_DEBUG
+ gboolean startup_timer = midori_debug ("startup");
+ GTimer* timer = startup_timer ? g_timer_new () : NULL;
+ #endif
+
+ /* Load extensions */
+ extensions = katze_array_new (MIDORI_TYPE_EXTENSION);
+ g_signal_connect (extensions, "update", G_CALLBACK (extensions_update_cb), app);
+ g_object_set (app, "extensions", extensions, NULL);
+
+ if (g_module_supported ())
+ {
+ gchar* extension_path;
+ if (keys && (extension_path = midori_paths_get_lib_path (PACKAGE_NAME)))
+ {
+ gint i = 0;
+ const gchar* filename;
+ while ((filename = keys[i++]))
+ midori_extension_activate_gracefully (app, extension_path, filename, TRUE);
+ g_free (extension_path);
+ }
+ }
+
+ #ifdef G_ENABLE_DEBUG
+ if (startup_timer)
+ g_debug ("Extensions:\t%f", g_timer_elapsed (timer, NULL));
+ #endif
+
+ return FALSE;
+}
+
+static void
+settings_notify_cb (MidoriWebSettings* settings,
+ GParamSpec* pspec,
+ MidoriApp* app)
+{
+ GError* error = NULL;
+ gchar* config_file;
+
+ /* Skip state related properties to avoid disk I/ O */
+ if (pspec && midori_settings_delay_saving (MIDORI_SETTINGS (settings), pspec->name))
+ return;
+
+ config_file = midori_paths_get_config_filename_for_writing ("config");
+ if (!midori_settings_save_to_file (settings, G_OBJECT (app), config_file, &error))
+ {
+ g_warning (_("The configuration couldn't be saved. %s"), error->message);
+ g_error_free (error);
+ }
+ g_free (config_file);
+}
+
+static void
+midori_browser_action_last_session_activate_cb (GtkAction* action,
+ MidoriBrowser* browser)
+{
+ KatzeArray* old_session = katze_array_new (KATZE_TYPE_ITEM);
+ gchar* config_file = midori_paths_get_config_filename_for_reading ("session.old.xbel");
+ GError* error = NULL;
+ if (midori_array_from_file (old_session, config_file, "xbel", &error))
+ {
+ KatzeItem* item;
+ KATZE_ARRAY_FOREACH_ITEM (item, old_session)
+ midori_browser_add_item (browser, item);
+ }
+ else
+ {
+ g_warning (_("The session couldn't be loaded: %s\n"), error->message);
+ /* FIXME: Show a graphical dialog */
+ g_error_free (error);
+ }
+ g_free (config_file);
+ gtk_action_set_sensitive (action, FALSE);
+ g_signal_handlers_disconnect_by_func (action,
+ midori_browser_action_last_session_activate_cb, browser);
+}
+
+static void
+midori_session_accel_map_changed_cb (GtkAccelMap* accel_map,
+ gchar* accel_path,
+ guint accel_key,
+ GdkModifierType accel_mods)
+{
+ gchar* config_file = midori_paths_get_config_filename_for_writing ("accels");
+ gtk_accel_map_save (config_file);
+ g_free (config_file);
+}
+
+static guint save_timeout = 0;
+
+static gboolean
+midori_session_save_timeout_cb (KatzeArray* session)
+{
+ gchar* config_file = midori_paths_get_config_filename_for_writing ("session.xbel");
+ GError* error = NULL;
+ if (!midori_array_to_file (session, config_file, "xbel", &error))
+ {
+ g_warning (_("The session couldn't be saved. %s"), error->message);
+ g_error_free (error);
+ }
+ g_free (config_file);
+
+ save_timeout = 0;
+ g_object_unref (session);
+
+ return FALSE;
+}
+
+static void
+midori_browser_session_cb (MidoriBrowser* browser,
+ gpointer pspec,
+ KatzeArray* session)
+{
+ if (!save_timeout)
+ save_timeout = g_timeout_add_seconds (5, (GSourceFunc)midori_session_save_timeout_cb, session);
+}
+
+static void
+midori_app_quit_cb (MidoriBrowser* browser,
+ KatzeArray* session)
+{
+ midori_session_save_timeout_cb (session);
+}
+
+static void
+midori_browser_weak_notify_cb (MidoriBrowser* browser,
+ KatzeArray* session)
+{
+ g_object_disconnect (browser, "any-signal",
+ G_CALLBACK (midori_browser_session_cb), session, NULL);
+}
+
+gboolean
+midori_load_session (gpointer data)
+{
+ KatzeArray* _session = KATZE_ARRAY (data);
+ MidoriBrowser* browser;
+ MidoriApp* app = katze_item_get_parent (KATZE_ITEM (_session));
+ MidoriWebSettings* settings = katze_object_get_object (app, "settings");
+ MidoriStartup load_on_startup;
+ gchar* config_file;
+ KatzeArray* session;
+ KatzeItem* item;
+ gint64 current;
+ gchar** command = g_object_get_data (G_OBJECT (app), "execute-command");
+ #ifdef G_ENABLE_DEBUG
+ gboolean startup_timer = midori_debug ("startup");
+ GTimer* timer = startup_timer ? g_timer_new () : NULL;
+ #endif
+
+ browser = midori_app_create_browser (app);
+ g_signal_connect_after (settings, "notify", G_CALLBACK (settings_notify_cb), app);
+
+ config_file = midori_paths_get_config_filename_for_reading ("session.old.xbel");
+ if (g_access (config_file, F_OK) == 0)
+ {
+ GtkActionGroup* action_group = midori_browser_get_action_group (browser);
+ GtkAction* action = gtk_action_group_get_action (action_group, "LastSession");
+ g_signal_connect (action, "activate",
+ G_CALLBACK (midori_browser_action_last_session_activate_cb), browser);
+ gtk_action_set_visible (action, TRUE);
+ }
+ midori_app_add_browser (app, browser);
+ gtk_widget_show (GTK_WIDGET (browser));
+
+ katze_assign (config_file, midori_paths_get_config_filename_for_reading ("accels"));
+ g_signal_connect_after (gtk_accel_map_get (), "changed",
+ G_CALLBACK (midori_session_accel_map_changed_cb), NULL);
+
+ load_on_startup = (MidoriStartup)g_object_get_data (G_OBJECT (settings), "load-on-startup");
+ if (katze_array_is_empty (_session))
+ {
+ item = katze_item_new ();
+ if (load_on_startup == MIDORI_STARTUP_BLANK_PAGE)
+ katze_item_set_uri (item, "about:blank");
+ else
+ item->uri = katze_object_get_string (settings, "homepage");
+ katze_array_add_item (_session, item);
+ g_object_unref (item);
+ }
+
+ session = midori_browser_get_proxy_array (browser);
+ KATZE_ARRAY_FOREACH_ITEM (item, _session)
+ {
+ katze_item_set_meta_integer (item, "append", 1);
+ katze_item_set_meta_integer (item, "dont-write-history", 1);
+ if (load_on_startup == MIDORI_STARTUP_DELAYED_PAGES
+ || katze_item_get_meta_integer (item, "delay") == MIDORI_DELAY_PENDING_UNDELAY)
+ katze_item_set_meta_integer (item, "delay", MIDORI_DELAY_DELAYED);
+ midori_browser_add_item (browser, item);
+ }
+ current = katze_item_get_meta_integer (KATZE_ITEM (_session), "current");
+ if (!(item = katze_array_get_nth_item (_session, current)))
+ {
+ current = 0;
+ item = katze_array_get_nth_item (_session, 0);
+ }
+ midori_browser_set_current_page (browser, current);
+ if (midori_uri_is_blank (katze_item_get_uri (item)))
+ midori_browser_activate_action (browser, "Location");
+
+ g_object_unref (settings);
+ g_object_unref (_session);
+ g_free (config_file);
+
+ g_signal_connect_after (browser, "add-tab",
+ G_CALLBACK (midori_browser_session_cb), session);
+ g_signal_connect_after (browser, "remove-tab",
+ G_CALLBACK (midori_browser_session_cb), session);
+ g_signal_connect (app, "quit",
+ G_CALLBACK (midori_app_quit_cb), session);
+ g_object_weak_ref (G_OBJECT (session),
+ (GWeakNotify)(midori_browser_weak_notify_cb), browser);
+
+ if (command)
+ midori_app_send_command (app, command);
+
+ #ifdef G_ENABLE_DEBUG
+ if (startup_timer)
+ g_debug ("Session setup:\t%f", g_timer_elapsed (timer, NULL));
+ #endif
+
+ return FALSE;
+}
+
diff --git a/midori/midori-session.h b/midori/midori-session.h
new file mode 100644
index 0000000..cfe6482
--- /dev/null
+++ b/midori/midori-session.h
@@ -0,0 +1,30 @@
+/*
+ Copyright (C) 2008-2012 Christian Dywan <christian at twotoasts.de>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ See the file COPYING for the full license text.
+*/
+
+#ifndef __MIDORI_SESSION_H__
+#define __MIDORI_SESSION_H__
+
+#include <glib/gstdio.h>
+
+gboolean
+midori_load_soup_session (gpointer settings);
+
+gboolean
+midori_load_soup_session_full (gpointer settings);
+
+gboolean
+midori_load_extensions (gpointer data);
+
+gboolean
+midori_load_session (gpointer data);
+
+#endif /* __MIDORI_SESSION_H__ */
+
diff --git a/midori/sokoke.c b/midori/sokoke.c
index c1d19f4..fa936ba 100644
--- a/midori/sokoke.c
+++ b/midori/sokoke.c
@@ -486,8 +486,8 @@ sokoke_prepare_uri (const gchar *uri)
{
gchar* uri_ready;
- if (g_str_has_prefix(uri, "javascript:"))
- return NULL;
+ if (g_str_has_prefix (uri, "javascript:"))
+ return g_strdup (uri);
else if (g_file_test (uri, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)
&& !g_path_is_absolute (uri))
{
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 57a2bfa..998a52a 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -78,3 +78,4 @@ midori/midori-extensions-column.vala
midori/midori-viewcompletion.vala
midori/midori-history.c
midori/midori-bookmarks.c
+midori/midori-session.c
More information about the Xfce4-commits
mailing list