fix bug 2954, 'Crash in "Save Image As" for HTML message'
[claws.git] / src / plugins / fancy / fancy_viewer.c
index b04d526df044522bdeb6844db6e89547f9e7d363..d3e81b9f1e421d0eaab9cb13aa5c5fd9ef5feffb 100644 (file)
@@ -85,15 +85,21 @@ static GtkWidget *fancy_get_widget(MimeViewer *_viewer)
 
 static void fancy_apply_prefs(FancyViewer *viewer)
 {
 
 static void fancy_apply_prefs(FancyViewer *viewer)
 {
-       g_object_set(viewer->settings, "auto-load-images",
-               viewer->override_prefs_images, NULL);
-       g_object_set(viewer->settings, "enable-scripts",
-               viewer->override_prefs_scripts, NULL);
-       g_object_set(viewer->settings, "enable-plugins",
-               viewer->override_prefs_plugins, NULL);
-       g_object_set(viewer->settings, "enable-java-applet",
-               viewer->override_prefs_java, NULL);
-
+       g_object_set(viewer->settings,
+               "auto-load-images", viewer->override_prefs_images,
+               "enable-scripts", viewer->override_prefs_scripts,
+               "enable-plugins", viewer->override_prefs_plugins,
+               "enable-java-applet", viewer->override_prefs_java,
+               "enable-dns-prefetching", viewer->override_prefs_remote_content,
+#ifdef G_OS_WIN32
+               "default-font-family", "Arial",
+               "cursive-font-family", "Comic Sans MS",
+               "fantasy-font-family", "Comic Sans MS",
+               "monospace-font-family", "Courier New",
+               "sans-serif-font-family", "Arial",
+               "serif-font-family", "Times New Roman",
+#endif
+               NULL); 
        webkit_web_view_set_settings(viewer->view, viewer->settings);
 }
 
        webkit_web_view_set_settings(viewer->view, viewer->settings);
 }
 
@@ -372,9 +378,9 @@ navigation_requested_cb(WebKitWebView *view, WebKitWebFrame *frame,
                                                WebKitNetworkRequest *netreq, FancyViewer *viewer)
 {
        const gchar *uri = webkit_network_request_get_uri(netreq);
                                                WebKitNetworkRequest *netreq, FancyViewer *viewer)
 {
        const gchar *uri = webkit_network_request_get_uri(netreq);
-#ifndef G_OS_WIN32
+
        debug_print("navigation requested to %s\n", uri);
        debug_print("navigation requested to %s\n", uri);
-#endif
+
        if (!strncmp(uri, "mailto:", 7)) {
                compose_new(NULL, uri + 7, NULL);
                return WEBKIT_NAVIGATION_RESPONSE_IGNORE;
        if (!strncmp(uri, "mailto:", 7)) {
                compose_new(NULL, uri + 7, NULL);
                return WEBKIT_NAVIGATION_RESPONSE_IGNORE;
@@ -414,7 +420,7 @@ static void resource_request_starting_cb(WebKitWebView              *view,
                                if ((err = procmime_get_part(filename, partinfo)) < 0)
                                        alertpanel_error(_("Couldn't save the part of multipart message: %s"),
                                                                                strerror(-err));
                                if ((err = procmime_get_part(filename, partinfo)) < 0)
                                        alertpanel_error(_("Couldn't save the part of multipart message: %s"),
                                                                                strerror(-err));
-                               gchar *file_uri = g_strconcat("file://", filename, NULL);
+                               gchar *file_uri = g_filename_to_uri(filename, NULL, NULL);
                                webkit_network_request_set_uri(request, file_uri);
                                g_free(file_uri);
                                g_free(filename);
                                webkit_network_request_set_uri(request, file_uri);
                                g_free(file_uri);
                                g_free(filename);
@@ -427,16 +433,12 @@ static void resource_request_starting_cb(WebKitWebView            *view,
        /* refresh URI that may have changed */
        uri = webkit_network_request_get_uri(request);
        if (!viewer->override_prefs_remote_content
        /* refresh URI that may have changed */
        uri = webkit_network_request_get_uri(request);
        if (!viewer->override_prefs_remote_content
-           && strncmp(uri, "file://", 7)) {
-#ifndef G_OS_WIN32
+           && strncmp(uri, "file://", 7) && strncmp(uri, "data:", 5)) {
                debug_print("Preventing load of %s\n", uri);
                debug_print("Preventing load of %s\n", uri);
-#endif
                webkit_network_request_set_uri(request, "about:blank");
        }
                webkit_network_request_set_uri(request, "about:blank");
        }
-#ifndef G_OS_WIN32
        else
        else
-               debug_print("Starting request of %s\n", uri);
-#endif
+               debug_print("Starting request of %d %s\n", strlen(uri), uri);
 }
 
 static gboolean fancy_text_search(MimeViewer *_viewer, gboolean backward,
 }
 
 static gboolean fancy_text_search(MimeViewer *_viewer, gboolean backward,
@@ -682,6 +684,11 @@ static void download_file_cb(GtkWidget *widget, FancyViewer *viewer)
 #endif
 }
 
 #endif
 }
 
+static void save_image_cb(GtkWidget *widget, FancyViewer *viewer)
+{
+       debug_print("Not Yet Implemented\n");
+}
+
 static void open_image_cb(GtkWidget *widget, FancyViewer *viewer)
 {
        debug_print("Not Yet Implemented\n");
 static void open_image_cb(GtkWidget *widget, FancyViewer *viewer)
 {
        debug_print("Not Yet Implemented\n");
@@ -766,7 +773,7 @@ static void viewer_menu_handler(GtkWidget *menuitem, FancyViewer *viewer)
 
                        GtkImageMenuItem *m_simage = GTK_IMAGE_MENU_ITEM(menuitem);
                        g_signal_connect(G_OBJECT(m_simage), "activate",
 
                        GtkImageMenuItem *m_simage = GTK_IMAGE_MENU_ITEM(menuitem);
                        g_signal_connect(G_OBJECT(m_simage), "activate",
-                                        G_CALLBACK(download_file_cb),
+                                        G_CALLBACK(save_image_cb),
                                         (gpointer *) viewer);
                }
 
                                         (gpointer *) viewer);
                }
 
@@ -1035,7 +1042,7 @@ const gchar *plugin_desc(void)
 {
        return g_strdup_printf(_("This plugin renders HTML mail using the WebKit "
                               "%d.%d.%d library.\nBy default all remote content is "
 {
        return g_strdup_printf(_("This plugin renders HTML mail using the WebKit "
                               "%d.%d.%d library.\nBy default all remote content is "
-                              "blocked and images are not automatically loaded. Options "
+                              "blocked. Options "
                               "can be found in /Configuration/Preferences/Plugins/Fancy"),
                               WEBKIT_MAJOR_VERSION, WEBKIT_MINOR_VERSION,
                               WEBKIT_MICRO_VERSION);
                               "can be found in /Configuration/Preferences/Plugins/Fancy"),
                               WEBKIT_MAJOR_VERSION, WEBKIT_MINOR_VERSION,
                               WEBKIT_MICRO_VERSION);