From 139132afbdb2a1c69625e97eb3b5ca9584a03d0a Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Thu, 7 Jan 2010 21:12:36 +0100 Subject: [PATCH] Implement about:version page with important build configuration aspects --- midori/midori-view.c | 120 ++++++++++++++++++++++++++++++++++++------- midori/sokoke.c | 3 +- 2 files changed, 103 insertions(+), 20 deletions(-) diff --git a/midori/midori-view.c b/midori/midori-view.c index 9c8ff8cd..0f670995 100644 --- a/midori/midori-view.c +++ b/midori/midori-view.c @@ -33,6 +33,10 @@ #include #endif +#ifndef G_OS_WIN32 + #include +#endif + /* This is unstable API, so we need to declare it */ gchar* webkit_web_view_get_selected_text (WebKitWebView* web_view); @@ -861,10 +865,8 @@ midori_view_web_view_resource_request_cb (WebKitWebView* web_view, const gchar* uri = webkit_network_request_get_uri (request); /* Only apply custom URIs to special pages for security purposes */ - if (!webkit_web_data_source_get_unreachable_uri ( - webkit_web_frame_get_data_source (web_frame))) + if (view->uri && *view->uri && strncmp (view->uri, "about:", 6)) return; - if (g_str_has_prefix (uri, "res://")) { gchar* filename = g_build_filename ("midori/res", &uri[5], NULL); @@ -3104,15 +3106,14 @@ midori_view_set_uri (MidoriView* view, g_return_if_fail (MIDORI_IS_VIEW (view)); /* Treat "about:blank" and "" equally, see midori_view_is_blank(). */ - if (!g_strcmp0 (uri, "about:blank")) uri = ""; - if (!uri) uri = ""; + if (!uri || !strcmp (uri, "about:blank")) uri = ""; if (1) { if (!view->web_view) midori_view_construct_web_view (view); - if (view->speed_dial_in_new_tabs && !g_strcmp0 (uri, "")) + if (view->speed_dial_in_new_tabs && !strcmp (uri, "")) { #if !WEBKIT_CHECK_VERSION (1, 1, 14) SoupServer* res_server; @@ -3181,9 +3182,9 @@ midori_view_set_uri (MidoriView* view, g_free (speed_dial_body); g_free (body_fname); } - /* This is not prefectly elegant, but creating an - error page inline is the simplest solution. */ - else if (g_str_has_prefix (uri, "error:")) + /* This is not prefectly elegant, but creating + special pages inline is the simplest solution. */ + else if (g_str_has_prefix (uri, "error:") || g_str_has_prefix (uri, "about:")) { data = NULL; #if !WEBKIT_CHECK_VERSION (1, 1, 3) @@ -3223,16 +3224,93 @@ midori_view_set_uri (MidoriView* view, title, title, view->uri); g_free (title); } - if (data) + else if (!strcmp (uri, "about:version")) { - webkit_web_view_load_html_string ( - WEBKIT_WEB_VIEW (view->web_view), data, view->uri); - g_free (data); - g_object_notify (G_OBJECT (view), "uri"); - if (view->item) - katze_item_set_uri (view->item, uri); - return; + gchar* ident = katze_object_get_string (view->settings, "ident-string"); + #if defined (G_OS_WIN32) + gchar* sys_name = g_strdup ("Windows"); + #else + gchar* sys_name; + struct utsname name; + if (uname (&name) != -1) + sys_name = g_strdup_printf ("%s %s", name.sysname, name.machine); + else + sys_name = g_strdup ("Unix"); + #endif + + katze_assign (view->uri, g_strdup (uri)); + #ifndef WEBKIT_USER_AGENT_MAJOR_VERSION + #define WEBKIT_USER_AGENT_MAJOR_VERSION 532 + #define WEBKIT_USER_AGENT_MINOR_VERSION 1 + #endif + #if defined (HAVE_LIBSOUP_2_29_3) + #define LIBSOUP_VERSION "2.29.3" + #elif defined (HAVE_LIBSOUP_2_27_90) + #define LIBSOUP_VERSION "2.27.90" + #else + #define LIBSOUP_VERSION "2.25.2" + #endif + #ifdef G_ENABLE_DEBUG + #define DEBUGGING " (Debug)" + #else + #define DEBUGGING "" + #endif + data = g_strdup_printf ( + "about:version" + "

about:version

" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "
Midori" PACKAGE_VERSION "%s
WebKitGTK+%d.%d.%d (%d.%d.%d)
GTK+%d.%d.%d (%d.%d.%d)
Glib%d.%d.%d (%d.%d.%d)
libsoup%s
sqlite3%s
libnotify%s
libidn%s
libunique%s
libhildon%s
Platform%s
Identification%s
" + "", + DEBUGGING, + WEBKIT_MAJOR_VERSION, + WEBKIT_MINOR_VERSION, + WEBKIT_MICRO_VERSION, + webkit_major_version (), + webkit_minor_version (), + webkit_micro_version (), + GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION, + gtk_major_version, gtk_minor_version, gtk_micro_version, + GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION, GLIB_MICRO_VERSION, + glib_major_version, glib_minor_version, glib_micro_version, + LIBSOUP_VERSION, + HAVE_SQLITE ? "Yes" : "No", + HAVE_LIBNOTIFY ? "Yes" : "No", + HAVE_LIBIDN ? "Yes" : "No", + HAVE_UNIQUE ? "Yes" : "No", + HAVE_HILDON ? "Yes" : "No", + sys_name, ident); + } + else + { + katze_assign (view->uri, g_strdup (uri)); + data = g_strdup_printf ( + "%s

%s

" + "" + "", view->uri, view->uri); } + + webkit_web_view_load_html_string ( + WEBKIT_WEB_VIEW (view->web_view), data, view->uri); + g_free (data); + g_object_notify (G_OBJECT (view), "uri"); + if (view->item) + katze_item_set_uri (view->item, uri); + return; } else if (g_str_has_prefix (uri, "javascript:")) { @@ -4056,8 +4134,12 @@ midori_view_reload (MidoriView* view, #endif if (view->title && strstr (title, view->title)) webkit_web_view_open (WEBKIT_WEB_VIEW (view->web_view), view->uri); - else if (midori_view_is_blank (view)) - midori_view_set_uri (view, view->uri); + else if (!(view->uri && *view->uri && strncmp (view->uri, "about:", 6))) + { + gchar* uri = g_strdup (view->uri); + midori_view_set_uri (view, uri); + g_free (uri); + } else if (from_cache) webkit_web_view_reload (WEBKIT_WEB_VIEW (view->web_view)); else diff --git a/midori/sokoke.c b/midori/sokoke.c index c917d7e2..66ae0f30 100644 --- a/midori/sokoke.c +++ b/midori/sokoke.c @@ -596,7 +596,8 @@ sokoke_magic_uri (const gchar* uri, || g_str_has_prefix (uri, "mailto:") || g_str_has_prefix (uri, "tel:") || g_str_has_prefix (uri, "callto:") - || g_str_has_prefix (uri, "data:")) + || g_str_has_prefix (uri, "data:") + || g_str_has_prefix (uri, "about:")) return g_strdup (uri); /* Add file:// if we have a local path */ if (g_path_is_absolute (uri)) -- 2.39.5