mirror of
https://github.com/archlinuxarm/PKGBUILDs.git
synced 2024-12-08 23:03:46 +00:00
855 lines
26 KiB
Diff
855 lines
26 KiB
Diff
From 1e068dbfc2837809030dcbf0173d2841a411d95a Mon Sep 17 00:00:00 2001
|
|
From: wwp <wwp@free.fr>
|
|
Date: Thu, 2 Feb 2017 18:06:27 +0100
|
|
Subject: [PATCH] Re-introducing the Dillo plugin. Tested against Dillo
|
|
3.0.4.1/3.0.5.
|
|
|
|
---
|
|
configure.ac | 15 ++
|
|
src/plugins/Makefile.am | 1 +
|
|
src/plugins/dillo/Makefile.am | 33 ++++
|
|
src/plugins/dillo/README | 48 ++++++
|
|
src/plugins/dillo/dillo_prefs.c | 305 +++++++++++++++++++++++++++++++++++++
|
|
src/plugins/dillo/dillo_prefs.h | 46 ++++++
|
|
src/plugins/dillo/dillo_viewer.c | 310 ++++++++++++++++++++++++++++++++++++++
|
|
7 files changed, 758 insertions(+)
|
|
create mode 100644 src/plugins/dillo/Makefile.am
|
|
create mode 100644 src/plugins/dillo/README
|
|
create mode 100644 src/plugins/dillo/dillo_prefs.c
|
|
create mode 100644 src/plugins/dillo/dillo_prefs.h
|
|
create mode 100644 src/plugins/dillo/dillo_viewer.c
|
|
|
|
diff --git a/configure.ac b/configure.ac
|
|
index b0683cf..e8e4ae4 100644
|
|
--- a/configure.ac
|
|
+++ b/configure.ac
|
|
@@ -988,6 +988,10 @@ AC_ARG_ENABLE(clamd-plugin,
|
|
[ --disable-clamd-plugin Do not build clamd plugin],
|
|
[enable_clamd_plugin=$enableval], [enable_clamd_plugin=auto])
|
|
|
|
+AC_ARG_ENABLE(dillo-plugin,
|
|
+ [ --disable-dillo-plugin Do not build dillo plugin],
|
|
+ [enable_dillo_plugin=$enableval], [enable_dillo_plugin=auto])
|
|
+
|
|
AC_ARG_ENABLE(fancy-plugin,
|
|
[ --disable-fancy-plugin Do not build fancy plugin],
|
|
[enable_fancy_plugin=$enableval], [enable_fancy_plugin=auto])
|
|
@@ -1416,6 +1420,15 @@ else
|
|
AC_MSG_RESULT(no)
|
|
fi
|
|
|
|
+AC_MSG_CHECKING([whether to build Dillo plugin])
|
|
+if test x"$enable_dillo_plugin" != xno; then
|
|
+ PLUGINS="$PLUGINS dillo"
|
|
+ AC_MSG_RESULT(yes)
|
|
+else
|
|
+ DISABLED_PLUGINS="$DISABLED_PLUGINS dillo"
|
|
+ AC_MSG_RESULT(no)
|
|
+fi
|
|
+
|
|
AC_MSG_CHECKING([whether to build fancy plugin])
|
|
if test x"$enable_fancy_plugin" != xno; then
|
|
dependencies_missing=""
|
|
@@ -1872,6 +1885,7 @@ AM_CONDITIONAL(BUILD_BOGOFILTER_PLUGIN, test x"$enable_bogofilter_plugin" != xn
|
|
AM_CONDITIONAL(BUILD_BSFILTER_PLUGIN, test x"$enable_bsfilter_plugin" != xno)
|
|
AM_CONDITIONAL(BUILD_CLAMD_PLUGIN, test x"$enable_clamd_plugin" != xno)
|
|
AM_CONDITIONAL(BUILD_DEMO_PLUGIN, test x"$enable_demo_plugin" != xno)
|
|
+AM_CONDITIONAL(BUILD_DILLO_PLUGIN, test x"$enable_dillo_plugin" != xno)
|
|
AM_CONDITIONAL(BUILD_FANCY_PLUGIN, test x"$enable_fancy_plugin" != xno)
|
|
AM_CONDITIONAL(BUILD_FETCHINFO_PLUGIN, test x"$enable_fetchinfo_plugin" != xno)
|
|
AM_CONDITIONAL(BUILD_GDATA_PLUGIN, test x"$enable_gdata_plugin" != xno)
|
|
@@ -1920,6 +1934,7 @@ src/plugins/bsfilter/Makefile
|
|
src/plugins/clamd/Makefile
|
|
src/plugins/clamd/libclamd/Makefile
|
|
src/plugins/demo/Makefile
|
|
+src/plugins/dillo/Makefile
|
|
src/plugins/fancy/Makefile
|
|
src/plugins/fetchinfo/Makefile
|
|
src/plugins/gdata/Makefile
|
|
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
|
|
index 6acc1fb..28abfdb 100644
|
|
--- a/src/plugins/Makefile.am
|
|
+++ b/src/plugins/Makefile.am
|
|
@@ -13,6 +13,7 @@ SUBDIRS = \
|
|
bsfilter \
|
|
clamd \
|
|
demo \
|
|
+ dillo \
|
|
fancy \
|
|
fetchinfo \
|
|
gdata \
|
|
diff --git a/src/plugins/dillo/Makefile.am b/src/plugins/dillo/Makefile.am
|
|
new file mode 100644
|
|
index 0000000..2dd9349
|
|
--- /dev/null
|
|
+++ b/src/plugins/dillo/Makefile.am
|
|
@@ -0,0 +1,33 @@
|
|
+# Copyright 1999-2014 the Claws Mail team.
|
|
+# This file is part of Claws Mail package, and distributed under the
|
|
+# terms of the General Public License version 3 (or later).
|
|
+# See COPYING file for license details.
|
|
+
|
|
+plugindir = $(pkglibdir)/plugins
|
|
+
|
|
+plugin_LTLIBRARIES = dillo.la
|
|
+
|
|
+dillo_la_SOURCES = \
|
|
+ dillo_viewer.c \
|
|
+ dillo_prefs.c \
|
|
+ dillo_prefs.h
|
|
+
|
|
+dillo_la_LDFLAGS = \
|
|
+ -avoid-version -module
|
|
+
|
|
+if CYGWIN
|
|
+cygwin_export_lib = -L$(top_builddir)/src -lclaws-mail
|
|
+else
|
|
+cygwin_export_lib =
|
|
+endif
|
|
+
|
|
+dillo_la_LIBADD = $(cygwin_export_lib) \
|
|
+ $(GTK_LIBS)
|
|
+
|
|
+dillo_la_CPPFLAGS = \
|
|
+ -I$(top_srcdir)/src \
|
|
+ -I$(top_builddir)/src/common \
|
|
+ -I$(top_srcdir)/src/common \
|
|
+ -I$(top_srcdir)/src/gtk \
|
|
+ $(GLIB_CFLAGS) \
|
|
+ $(GTK_CFLAGS)
|
|
diff --git a/src/plugins/dillo/README b/src/plugins/dillo/README
|
|
new file mode 100644
|
|
index 0000000..a61f4e0
|
|
--- /dev/null
|
|
+++ b/src/plugins/dillo/README
|
|
@@ -0,0 +1,48 @@
|
|
+Dillo Viewer: HTML mail viewing in Claws Mail
|
|
+-------------------------------------------------
|
|
+
|
|
+This plugin uses the Dillo (http://www.dillo.org) browser to
|
|
+view text/html MIME parts inside Claws Mail.
|
|
+
|
|
+When the plugin is loaded, if the MIME part to be viewed is of
|
|
+text/html type, then the MIME part is saved in a temporary file and
|
|
+Dillo is started with special options to embed it inside
|
|
+Claws Mail' message view and to "safely" view the part. Dillo is
|
|
+also run in the fullwindow mode, where the toolbar, menubar and the
|
|
+statusbar are hidden so the message is viewed in a larger area. The
|
|
+fullwindow mode is toggled on and off by double clicking on an empty
|
|
+part of the page or by clicking on the icon in the lower right corner.
|
|
+
|
|
+The "safe" viewing of text/html message parts is achieved by using the
|
|
+-l (or --local) option of Dillo. This option prevents Dillo from
|
|
+retrieving remote web resources, like images. Thus, no connection
|
|
+to the Internet is done. If the user wants to view the message
|
|
+without this restriction, s/he just reloads the page by clicking on
|
|
+the "Reload" button in Dillo's toolbar.
|
|
+
|
|
+WARNING: This plugin is provided as is. The author does not guarantee
|
|
+safe viewing of text/html messages although he tried hard to achieve
|
|
+this goal.
|
|
+
|
|
+What Dillo version should be used?
|
|
+----------------------------------
|
|
+
|
|
+Dillo 0.7.0 was the first version that included the features needed by
|
|
+Claws, but it had a small bug where remote resources could be
|
|
+accessed even with the --local option (when a BASE element is present
|
|
+in the message).
|
|
+
|
|
+Since 2002-03-16, the CVS tree of Dillo fixed that bug.
|
|
+
|
|
+Dillo 0.7.2 and newer (up to 3.0.5) do not have that bug, and are the
|
|
+recommended versions to be used.
|
|
+
|
|
+Acknowledgment:
|
|
+---------------
|
|
+
|
|
+The author of this plugin thanks the author of Dillo, Jorge Arellano
|
|
+Cid, who accepted to integrate and improve the different patches
|
|
+needed for this functionality.
|
|
+
|
|
+--
|
|
+Melvin Hadasht
|
|
diff --git a/src/plugins/dillo/dillo_prefs.c b/src/plugins/dillo/dillo_prefs.c
|
|
new file mode 100644
|
|
index 0000000..8d9529b
|
|
--- /dev/null
|
|
+++ b/src/plugins/dillo/dillo_prefs.c
|
|
@@ -0,0 +1,305 @@
|
|
+/*
|
|
+ * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
|
|
+ * Copyright (C) 1999-2012 the Claws Mail Team
|
|
+ *
|
|
+ * This program is free software; you can redistribute it and/or modify
|
|
+ * it under the terms of the GNU General Public License as published by
|
|
+ * the Free Software Foundation; either version 3 of the License, or
|
|
+ * (at your option) any later version.
|
|
+ *
|
|
+ * This program is distributed in the hope that it will be useful,
|
|
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
+ * GNU General Public License for more details.
|
|
+ *
|
|
+ * You should have received a copy of the GNU General Public License
|
|
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
+ *
|
|
+ */
|
|
+
|
|
+/*
|
|
+ * The structure of this file has been borrowed from the structure of
|
|
+ * the image_viewer plugin file. I also used it as an example of how to
|
|
+ * build the preferences for the dillo plugin.
|
|
+ */
|
|
+
|
|
+#ifdef HAVE_CONFIG_H
|
|
+# include "config.h"
|
|
+#include "claws-features.h"
|
|
+#endif
|
|
+
|
|
+#include "defs.h"
|
|
+
|
|
+#include <glib.h>
|
|
+#include <glib/gi18n.h>
|
|
+#include <gtk/gtk.h>
|
|
+
|
|
+#include "gtkutils.h"
|
|
+#include "utils.h"
|
|
+#include "prefs.h"
|
|
+#include "prefs_gtk.h"
|
|
+#include "prefswindow.h"
|
|
+#include "combobox.h"
|
|
+#include "addressbook.h"
|
|
+
|
|
+#include "dillo_prefs.h"
|
|
+
|
|
+#define PREFS_BLOCK_NAME "Dillo"
|
|
+
|
|
+DilloBrowserPrefs dillo_prefs;
|
|
+
|
|
+typedef struct _DilloBrowserPage DilloBrowserPage;
|
|
+
|
|
+struct _DilloBrowserPage {
|
|
+ PrefsPage page;
|
|
+ GtkWidget *local;
|
|
+ GtkWidget *whitelist_ab;
|
|
+ GtkWidget *whitelist_ab_folder_combo;
|
|
+ GtkWidget *whitelist_ab_select_btn;
|
|
+ GtkWidget *full;
|
|
+};
|
|
+
|
|
+static PrefParam param[] = {
|
|
+ {"local_browse", "TRUE", &dillo_prefs.local, P_BOOL, NULL, NULL, NULL},
|
|
+ {"full_window", "TRUE", &dillo_prefs.full, P_BOOL, NULL, NULL, NULL},
|
|
+ {"whitelist_ab", "FALSE", &dillo_prefs.whitelist_ab, P_BOOL,
|
|
+ NULL, NULL, NULL},
|
|
+ {"whitelist_ab_folder", N_("Any"), &dillo_prefs.whitelist_ab_folder, P_STRING,
|
|
+ NULL, NULL, NULL},
|
|
+
|
|
+ {0,0,0,0,0,0,0}
|
|
+};
|
|
+
|
|
+static DilloBrowserPage prefs_page;
|
|
+
|
|
+static void create_dillo_prefs_page (PrefsPage *page,
|
|
+ GtkWindow *window,
|
|
+ gpointer data);
|
|
+static void destroy_dillo_prefs_page (PrefsPage *page);
|
|
+static void save_dillo_prefs (PrefsPage *page);
|
|
+
|
|
+#ifndef USE_NEW_ADDRBOOK
|
|
+static void dillo_whitelist_ab_select_cb(GtkWidget *widget, gpointer data)
|
|
+{
|
|
+ DilloBrowserPage *page = (DilloBrowserPage *) data;
|
|
+ const gchar *folderpath = NULL;
|
|
+ gchar *new_path = NULL;
|
|
+
|
|
+ folderpath = gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN((page->whitelist_ab_folder_combo)))));
|
|
+ new_path = addressbook_folder_selection(folderpath);
|
|
+ if (new_path) {
|
|
+ gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN((page->whitelist_ab_folder_combo)))), new_path);
|
|
+ g_free(new_path);
|
|
+ }
|
|
+}
|
|
+#endif
|
|
+
|
|
+static void local_checkbox_toggled(GtkToggleButton *button,
|
|
+ gpointer user_data)
|
|
+{
|
|
+ gboolean active = gtk_toggle_button_get_active(button);
|
|
+ DilloBrowserPage *prefs_page = (DilloBrowserPage *) user_data;
|
|
+
|
|
+ gtk_widget_set_sensitive(prefs_page->whitelist_ab, active);
|
|
+ gtk_widget_set_sensitive(prefs_page->whitelist_ab_folder_combo, active &&
|
|
+ gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(prefs_page->whitelist_ab)));
|
|
+#ifndef USE_NEW_ADDRBOOK
|
|
+ gtk_widget_set_sensitive(prefs_page->whitelist_ab_select_btn, active &&
|
|
+ gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(prefs_page->whitelist_ab)));
|
|
+#endif
|
|
+}
|
|
+
|
|
+static void whitelist_checkbox_toggled(GtkToggleButton *button,
|
|
+ gpointer user_data)
|
|
+{
|
|
+ gboolean active = gtk_toggle_button_get_active(button);
|
|
+ DilloBrowserPage *prefs_page = (DilloBrowserPage *) user_data;
|
|
+
|
|
+ active &= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(prefs_page->local));
|
|
+
|
|
+ gtk_widget_set_sensitive(prefs_page->whitelist_ab_folder_combo, active);
|
|
+ gtk_widget_set_sensitive(prefs_page->whitelist_ab_select_btn, active);
|
|
+}
|
|
+
|
|
+void dillo_prefs_init(void)
|
|
+{
|
|
+ static gchar *path[3];
|
|
+ gchar *rcpath;
|
|
+
|
|
+ path[0] = _("Plugins");
|
|
+ path[1] = _("Dillo Browser");
|
|
+ path[2] = NULL;
|
|
+
|
|
+ prefs_set_default(param);
|
|
+ rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, COMMON_RC, NULL);
|
|
+ prefs_read_config(param, PREFS_BLOCK_NAME, rcpath, NULL);
|
|
+ g_free(rcpath);
|
|
+
|
|
+ prefs_page.page.path = path;
|
|
+ prefs_page.page.create_widget = create_dillo_prefs_page;
|
|
+ prefs_page.page.destroy_widget = destroy_dillo_prefs_page;
|
|
+ prefs_page.page.save_page = save_dillo_prefs;
|
|
+ prefs_page.page.weight = 35.0;
|
|
+ prefs_gtk_register_page((PrefsPage *) &prefs_page);
|
|
+}
|
|
+
|
|
+void dillo_prefs_done(void)
|
|
+{
|
|
+ prefs_gtk_unregister_page((PrefsPage *) &prefs_page);
|
|
+}
|
|
+
|
|
+static void create_dillo_prefs_page(PrefsPage *page,
|
|
+ GtkWindow *window,
|
|
+ gpointer data)
|
|
+{
|
|
+ DilloBrowserPage *prefs_page = (DilloBrowserPage *) page;
|
|
+
|
|
+ GtkWidget *vbox;
|
|
+ GtkWidget *local_checkbox;
|
|
+ GtkWidget *full_checkbox;
|
|
+ GtkWidget *label;
|
|
+ GtkWidget *whitelist_ab_checkbtn;
|
|
+ GtkWidget *whitelist_ab_folder_combo;
|
|
+ GtkWidget *whitelist_ab_select_btn;
|
|
+ GtkWidget *hbox_whitelist, *spacer;
|
|
+
|
|
+ vbox = gtk_vbox_new(FALSE, 3);
|
|
+ gtk_container_set_border_width(GTK_CONTAINER(vbox), VBOX_BORDER);
|
|
+ gtk_widget_show(vbox);
|
|
+
|
|
+ local_checkbox = gtk_check_button_new_with_label
|
|
+ (_("Load remote links in mails"));
|
|
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(local_checkbox),
|
|
+ !dillo_prefs.local);
|
|
+ gtk_box_pack_start(GTK_BOX(vbox), local_checkbox, FALSE, FALSE, 0);
|
|
+ gtk_widget_show(local_checkbox);
|
|
+ CLAWS_SET_TIP(local_checkbox,
|
|
+ _("Equivalent to Dillo's '--local' option"));
|
|
+
|
|
+ label = gtk_label_new(_("You can still load remote links "
|
|
+ "by reloading the page"));
|
|
+ gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
|
|
+ gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
|
|
+ gtkut_widget_set_small_font_size (label);
|
|
+ gtk_widget_show(label);
|
|
+
|
|
+
|
|
+ hbox_whitelist = gtk_hbox_new(FALSE, 8);
|
|
+ gtk_widget_show(hbox_whitelist);
|
|
+ gtk_box_pack_start (GTK_BOX (vbox), hbox_whitelist, FALSE, FALSE, 0);
|
|
+
|
|
+ spacer = gtk_hbox_new(FALSE, 0);
|
|
+ gtk_widget_set_size_request(spacer, 12, -1);
|
|
+ gtk_widget_show(spacer);
|
|
+ gtk_box_pack_start(GTK_BOX(hbox_whitelist), spacer, FALSE, FALSE, 0);
|
|
+
|
|
+ whitelist_ab_checkbtn = gtk_check_button_new_with_label(_("Only for senders found in address book/folder"));
|
|
+ gtk_widget_show(whitelist_ab_checkbtn);
|
|
+ gtk_box_pack_start(GTK_BOX(hbox_whitelist), whitelist_ab_checkbtn, FALSE, FALSE, 0);
|
|
+
|
|
+ whitelist_ab_folder_combo = combobox_text_new(TRUE, _("Any"), NULL);
|
|
+ gtk_widget_set_size_request(whitelist_ab_folder_combo, 100, -1);
|
|
+ gtk_box_pack_start (GTK_BOX (hbox_whitelist), whitelist_ab_folder_combo, TRUE, TRUE, 0);
|
|
+
|
|
+ whitelist_ab_select_btn = gtk_button_new_with_label(_("Select ..."));
|
|
+ gtk_widget_show (whitelist_ab_select_btn);
|
|
+ gtk_box_pack_start (GTK_BOX (hbox_whitelist), whitelist_ab_select_btn, FALSE, FALSE, 0);
|
|
+
|
|
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(whitelist_ab_checkbtn), dillo_prefs.whitelist_ab);
|
|
+ if (dillo_prefs.whitelist_ab_folder != NULL) {
|
|
+ /* translate "Any" (stored UNtranslated) */
|
|
+ if (strcasecmp(dillo_prefs.whitelist_ab_folder, "Any") == 0)
|
|
+ gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN((whitelist_ab_folder_combo)))),
|
|
+ _("Any"));
|
|
+ else
|
|
+ /* backward compatibility (when translated "Any" was stored) */
|
|
+ if (g_utf8_collate(dillo_prefs.whitelist_ab_folder, _("Any")) == 0)
|
|
+ gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN((whitelist_ab_folder_combo)))),
|
|
+ dillo_prefs.whitelist_ab_folder);
|
|
+ else
|
|
+ gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN((whitelist_ab_folder_combo)))),
|
|
+ dillo_prefs.whitelist_ab_folder);
|
|
+ }
|
|
+
|
|
+ full_checkbox = gtk_check_button_new_with_label
|
|
+ (_("Full window mode (hide controls)"));
|
|
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(full_checkbox),
|
|
+ dillo_prefs.full);
|
|
+ gtk_box_pack_start(GTK_BOX(vbox), full_checkbox, FALSE, FALSE, 0);
|
|
+ gtk_widget_show(full_checkbox);
|
|
+ CLAWS_SET_TIP(full_checkbox,
|
|
+ _("Equivalent to Dillo's '--fullwindow' option"));
|
|
+
|
|
+ g_signal_connect(G_OBJECT(local_checkbox), "toggled",
|
|
+ G_CALLBACK(local_checkbox_toggled),
|
|
+ prefs_page);
|
|
+
|
|
+ g_signal_connect(G_OBJECT(whitelist_ab_checkbtn), "toggled",
|
|
+ G_CALLBACK(whitelist_checkbox_toggled),
|
|
+ prefs_page);
|
|
+
|
|
+#ifndef USE_NEW_ADDRBOOK
|
|
+ g_signal_connect(G_OBJECT (whitelist_ab_select_btn), "clicked",
|
|
+ G_CALLBACK(dillo_whitelist_ab_select_cb), prefs_page);
|
|
+#else
|
|
+ gtk_widget_set_sensitive(GTK_WIDGET(whitelist_ab_select_btn), FALSE);
|
|
+#endif
|
|
+ gtk_widget_set_sensitive(whitelist_ab_checkbtn, !dillo_prefs.local);
|
|
+ gtk_widget_set_sensitive(whitelist_ab_folder_combo, !dillo_prefs.local && dillo_prefs.whitelist_ab);
|
|
+ gtk_widget_set_sensitive(whitelist_ab_select_btn, !dillo_prefs.local && dillo_prefs.whitelist_ab);
|
|
+
|
|
+
|
|
+ prefs_page->local = local_checkbox;
|
|
+ prefs_page->full = full_checkbox;
|
|
+ prefs_page->whitelist_ab = whitelist_ab_checkbtn;
|
|
+ prefs_page->whitelist_ab_folder_combo = whitelist_ab_folder_combo;
|
|
+ prefs_page->whitelist_ab_select_btn = whitelist_ab_select_btn;
|
|
+ prefs_page->page.widget = vbox;
|
|
+}
|
|
+
|
|
+static void destroy_dillo_prefs_page(PrefsPage *page)
|
|
+{
|
|
+ /* Do nothing! */
|
|
+}
|
|
+
|
|
+static void save_dillo_prefs(PrefsPage *page)
|
|
+{
|
|
+ DilloBrowserPage *prefs_page = (DilloBrowserPage *) page;
|
|
+ PrefFile *pref_file;
|
|
+ gchar *rc_file_path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
|
|
+ COMMON_RC, NULL);
|
|
+
|
|
+ dillo_prefs.local = !gtk_toggle_button_get_active
|
|
+ (GTK_TOGGLE_BUTTON(prefs_page->local));
|
|
+ dillo_prefs.full = gtk_toggle_button_get_active
|
|
+ (GTK_TOGGLE_BUTTON(prefs_page->full));
|
|
+
|
|
+ dillo_prefs.whitelist_ab = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(prefs_page->whitelist_ab));
|
|
+ g_free(dillo_prefs.whitelist_ab_folder);
|
|
+ dillo_prefs.whitelist_ab_folder = gtk_editable_get_chars(
|
|
+ GTK_EDITABLE(gtk_bin_get_child(GTK_BIN((prefs_page->whitelist_ab_folder_combo)))), 0, -1);
|
|
+ /* store UNtranslated "Any" */
|
|
+ if (g_utf8_collate(dillo_prefs.whitelist_ab_folder, _("Any")) == 0) {
|
|
+ g_free(dillo_prefs.whitelist_ab_folder);
|
|
+ dillo_prefs.whitelist_ab_folder = g_strdup("Any");
|
|
+ }
|
|
+
|
|
+ pref_file = prefs_write_open(rc_file_path);
|
|
+ g_free(rc_file_path);
|
|
+
|
|
+ if (!(pref_file) ||
|
|
+ (prefs_set_block_label(pref_file, PREFS_BLOCK_NAME) < 0))
|
|
+ return;
|
|
+
|
|
+ if (prefs_write_param(param, pref_file->fp) < 0) {
|
|
+ g_warning("failed to write Dillo Plugin configuration\n");
|
|
+ prefs_file_close_revert(pref_file);
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ if (fprintf(pref_file->fp, "\n") < 0) {
|
|
+ FILE_OP_ERROR(rc_file_path, "fprintf");
|
|
+ prefs_file_close_revert(pref_file);
|
|
+ } else
|
|
+ prefs_file_close(pref_file);
|
|
+}
|
|
diff --git a/src/plugins/dillo/dillo_prefs.h b/src/plugins/dillo/dillo_prefs.h
|
|
new file mode 100644
|
|
index 0000000..d4b5b4d
|
|
--- /dev/null
|
|
+++ b/src/plugins/dillo/dillo_prefs.h
|
|
@@ -0,0 +1,46 @@
|
|
+/*
|
|
+ * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
|
|
+ * Copyright (C) 1999-2012 the Claws Mail Team
|
|
+ *
|
|
+ * This program is free software; you can redistribute it and/or modify
|
|
+ * it under the terms of the GNU General Public License as published by
|
|
+ * the Free Software Foundation; either version 3 of the License, or
|
|
+ * (at your option) any later version.
|
|
+ *
|
|
+ * This program is distributed in the hope that it will be useful,
|
|
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
+ * GNU General Public License for more details.
|
|
+ *
|
|
+ * You should have received a copy of the GNU General Public License
|
|
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
+ *
|
|
+ */
|
|
+
|
|
+/*
|
|
+ * The structure of this file has been borrowed from the structure of
|
|
+ * the image_viewer plugin file. I also used it as an example of how to
|
|
+ * build the preferences for the dillo plugin.
|
|
+ */
|
|
+
|
|
+#ifndef DILLOPREFS_H
|
|
+#define DILLOPREFS_H
|
|
+
|
|
+#include <glib.h>
|
|
+
|
|
+typedef struct _DilloBrowserPrefs DilloBrowserPrefs;
|
|
+
|
|
+struct _DilloBrowserPrefs
|
|
+{
|
|
+ gboolean local; /**< local browsing */
|
|
+ gboolean whitelist_ab;
|
|
+ gchar *whitelist_ab_folder;
|
|
+ gboolean full; /**< use full window */
|
|
+};
|
|
+
|
|
+extern DilloBrowserPrefs dillo_prefs;
|
|
+
|
|
+void dillo_prefs_init(void);
|
|
+void dillo_prefs_done(void);
|
|
+
|
|
+#endif
|
|
diff --git a/src/plugins/dillo/dillo_viewer.c b/src/plugins/dillo/dillo_viewer.c
|
|
new file mode 100644
|
|
index 0000000..1c63fa3
|
|
--- /dev/null
|
|
+++ b/src/plugins/dillo/dillo_viewer.c
|
|
@@ -0,0 +1,310 @@
|
|
+/*
|
|
+ * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
|
|
+ * Copyright (C) 1999-2012 the Claws Mail Team
|
|
+ *
|
|
+ * This program is free software; you can redistribute it and/or modify
|
|
+ * it under the terms of the GNU General Public License as published by
|
|
+ * the Free Software Foundation; either version 3 of the License, or
|
|
+ * (at your option) any later version.
|
|
+ *
|
|
+ * This program is distributed in the hope that it will be useful,
|
|
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
+ * GNU General Public License for more details.
|
|
+ *
|
|
+ * You should have received a copy of the GNU General Public License
|
|
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
+ *
|
|
+ */
|
|
+
|
|
+#ifdef HAVE_CONFIG_H
|
|
+# include "config.h"
|
|
+#include "claws-features.h"
|
|
+#endif
|
|
+
|
|
+#include <unistd.h>
|
|
+
|
|
+#include <glib.h>
|
|
+#include <glib/gi18n.h>
|
|
+#include <gtk/gtk.h>
|
|
+#if GTK_CHECK_VERSION(3, 0, 0)
|
|
+#include <gtk/gtkx.h>
|
|
+#endif
|
|
+#include <gdk/gdkx.h>
|
|
+
|
|
+#include "common/claws.h"
|
|
+#include "common/version.h"
|
|
+#include "plugin.h"
|
|
+#include "utils.h"
|
|
+#include "mimeview.h"
|
|
+#include "addr_compl.h"
|
|
+
|
|
+#include "dillo_prefs.h"
|
|
+
|
|
+#define PLUGIN_NAME (_("Dillo HTML Viewer"))
|
|
+
|
|
+typedef struct _DilloViewer DilloViewer;
|
|
+
|
|
+struct _DilloViewer
|
|
+{
|
|
+ MimeViewer mimeviewer;
|
|
+ GtkWidget *widget;
|
|
+ GtkWidget *socket;
|
|
+ gchar *filename;
|
|
+};
|
|
+
|
|
+static MimeViewerFactory dillo_viewer_factory;
|
|
+
|
|
+static GtkWidget *dillo_get_widget(MimeViewer *_viewer)
|
|
+{
|
|
+ DilloViewer *viewer = (DilloViewer *) _viewer;
|
|
+
|
|
+ debug_print("dillo_get_widget\n");
|
|
+
|
|
+ return GTK_WIDGET(viewer->widget);
|
|
+}
|
|
+
|
|
+#if !GTK_CHECK_VERSION(3, 0, 0)
|
|
+static gboolean socket_destroy_cb(GtkObject *object, gpointer data)
|
|
+#else
|
|
+static gboolean socket_destroy_cb(GtkObject *object, gpointer data)
|
|
+#endif
|
|
+{
|
|
+ DilloViewer *viewer = (DilloViewer *) data;
|
|
+ debug_print("Destroyed dillo socket %p\n", viewer->socket);
|
|
+ viewer->socket = NULL;
|
|
+ return FALSE;
|
|
+}
|
|
+
|
|
+static gboolean found_in_addressbook(const gchar *address)
|
|
+{
|
|
+ gchar *addr = NULL;
|
|
+ gboolean found = FALSE;
|
|
+ gint num_addr = 0;
|
|
+
|
|
+ if (!address)
|
|
+ return FALSE;
|
|
+
|
|
+ addr = g_strdup(address);
|
|
+ extract_address(addr);
|
|
+ num_addr = complete_address(addr);
|
|
+ if (num_addr > 1) {
|
|
+ /* skip first item (this is the search string itself) */
|
|
+ int i = 1;
|
|
+ for (; i < num_addr && !found; i++) {
|
|
+ gchar *caddr = get_complete_address(i);
|
|
+ extract_address(caddr);
|
|
+ if (strcasecmp(caddr, addr) == 0)
|
|
+ found = TRUE;
|
|
+ g_free(caddr);
|
|
+ }
|
|
+ }
|
|
+ g_free(addr);
|
|
+ return found;
|
|
+}
|
|
+
|
|
+static gboolean load_images(DilloViewer *viewer)
|
|
+{
|
|
+ MessageView *messageview = ((MimeViewer *)viewer)->mimeview
|
|
+ ? ((MimeViewer *)viewer)->mimeview->messageview
|
|
+ : NULL;
|
|
+ MsgInfo *msginfo = NULL;
|
|
+ gchar *ab_folderpath = NULL;
|
|
+
|
|
+ if (messageview == NULL)
|
|
+ return FALSE;
|
|
+
|
|
+ msginfo = messageview->msginfo;
|
|
+
|
|
+ if (msginfo == NULL)
|
|
+ return FALSE;
|
|
+
|
|
+ /* don't load remote images, period. */
|
|
+ if (dillo_prefs.local)
|
|
+ return FALSE;
|
|
+
|
|
+ /* don't do whitelisting -> load images */
|
|
+ if (!dillo_prefs.whitelist_ab)
|
|
+ return TRUE;
|
|
+
|
|
+ if (*dillo_prefs.whitelist_ab_folder != '\0' &&
|
|
+ strcasecmp(dillo_prefs.whitelist_ab_folder, _("Any")) != 0)
|
|
+ ab_folderpath = dillo_prefs.whitelist_ab_folder;
|
|
+
|
|
+ start_address_completion(ab_folderpath);
|
|
+
|
|
+ /* do whitelisting -> check sender */
|
|
+ if (found_in_addressbook(msginfo->from)) {
|
|
+ end_address_completion();
|
|
+ return TRUE;
|
|
+ }
|
|
+
|
|
+ end_address_completion();
|
|
+ return FALSE;
|
|
+}
|
|
+
|
|
+static void dillo_show_mimepart(MimeViewer *_viewer,
|
|
+ const gchar *infile,
|
|
+ MimeInfo *partinfo)
|
|
+{
|
|
+ DilloViewer *viewer = (DilloViewer *) _viewer;
|
|
+
|
|
+ debug_print("dillo_show_mimepart\n");
|
|
+
|
|
+ if (viewer->filename != NULL) {
|
|
+ claws_unlink(viewer->filename);
|
|
+ g_free(viewer->filename);
|
|
+ }
|
|
+
|
|
+ viewer->filename = procmime_get_tmp_file_name(partinfo);
|
|
+
|
|
+ if (!(procmime_get_part(viewer->filename, partinfo) < 0)) {
|
|
+ gchar *cmd;
|
|
+
|
|
+ if (viewer->socket)
|
|
+ gtk_widget_destroy(viewer->socket);
|
|
+ viewer->socket = gtk_socket_new();
|
|
+ debug_print("Adding dillo socket %p", viewer->socket);
|
|
+ gtk_container_add(GTK_CONTAINER(viewer->widget),
|
|
+ viewer->socket);
|
|
+ gtk_widget_realize(viewer->socket);
|
|
+ gtk_widget_show(viewer->socket);
|
|
+ g_signal_connect(G_OBJECT(viewer->socket), "destroy",
|
|
+ G_CALLBACK(socket_destroy_cb), viewer);
|
|
+
|
|
+ cmd = g_strdup_printf("dillo %s%s-x %d \"%s\"",
|
|
+ (!load_images(viewer) ? "-l " : ""),
|
|
+ (dillo_prefs.full ? "-f " : ""),
|
|
+ (gint) GDK_WINDOW_XWINDOW(viewer->socket->window),
|
|
+ viewer->filename);
|
|
+
|
|
+ execute_command_line(cmd, TRUE, NULL);
|
|
+ g_free(cmd);
|
|
+ }
|
|
+}
|
|
+
|
|
+static void dillo_clear_viewer(MimeViewer *_viewer)
|
|
+{
|
|
+ DilloViewer *viewer = (DilloViewer *) _viewer;
|
|
+
|
|
+ debug_print("dillo_clear_viewer\n");
|
|
+ debug_print("Removing dillo socket %p\n", viewer->socket);
|
|
+
|
|
+ if (viewer->socket) {
|
|
+ gtk_widget_destroy(viewer->socket);
|
|
+ }
|
|
+}
|
|
+
|
|
+static void dillo_destroy_viewer(MimeViewer *_viewer)
|
|
+{
|
|
+ DilloViewer *viewer = (DilloViewer *) _viewer;
|
|
+
|
|
+ debug_print("dillo_destroy_viewer\n");
|
|
+
|
|
+ if (viewer->socket) {
|
|
+ gtk_widget_destroy(viewer->socket);
|
|
+ }
|
|
+
|
|
+ g_object_unref(GTK_WIDGET(viewer->widget));
|
|
+ claws_unlink(viewer->filename);
|
|
+ g_free(viewer->filename);
|
|
+ g_free(viewer);
|
|
+}
|
|
+
|
|
+static MimeViewer *dillo_viewer_create(void)
|
|
+{
|
|
+ DilloViewer *viewer;
|
|
+
|
|
+ debug_print("dillo_viewer_create\n");
|
|
+
|
|
+ viewer = g_new0(DilloViewer, 1);
|
|
+ viewer->mimeviewer.factory = &dillo_viewer_factory;
|
|
+ viewer->mimeviewer.get_widget = dillo_get_widget;
|
|
+ viewer->mimeviewer.show_mimepart = dillo_show_mimepart;
|
|
+ viewer->mimeviewer.clear_viewer = dillo_clear_viewer;
|
|
+ viewer->mimeviewer.destroy_viewer = dillo_destroy_viewer;
|
|
+ viewer->mimeviewer.get_selection = NULL;
|
|
+ viewer->widget = gtk_event_box_new();
|
|
+
|
|
+ gtk_widget_show(viewer->widget);
|
|
+ g_object_ref(viewer->widget);
|
|
+
|
|
+ viewer->filename = NULL;
|
|
+
|
|
+ return (MimeViewer *) viewer;
|
|
+}
|
|
+
|
|
+static gchar *content_types[] =
|
|
+ {"text/html", NULL};
|
|
+
|
|
+static MimeViewerFactory dillo_viewer_factory =
|
|
+{
|
|
+ content_types,
|
|
+ 0,
|
|
+
|
|
+ dillo_viewer_create,
|
|
+};
|
|
+
|
|
+gint plugin_init(gchar **error)
|
|
+{
|
|
+ gchar *dillo_path = NULL;
|
|
+ if (!check_plugin_version(MAKE_NUMERIC_VERSION(2,9,2,72),
|
|
+ VERSION_NUMERIC, PLUGIN_NAME, error))
|
|
+ return -1;
|
|
+
|
|
+ if ((dillo_path = g_find_program_in_path("dillo")) == NULL) {
|
|
+ *error = g_strdup(_("Can't find the dillo executable in PATH. Is it installed?"));
|
|
+ return -1;
|
|
+ }
|
|
+ g_free(dillo_path);
|
|
+
|
|
+ dillo_prefs_init();
|
|
+
|
|
+ mimeview_register_viewer_factory(&dillo_viewer_factory);
|
|
+
|
|
+ return 0;
|
|
+}
|
|
+
|
|
+gboolean plugin_done(void)
|
|
+{
|
|
+ mimeview_unregister_viewer_factory(&dillo_viewer_factory);
|
|
+
|
|
+ dillo_prefs_done();
|
|
+ return TRUE;
|
|
+}
|
|
+
|
|
+const gchar *plugin_name(void)
|
|
+{
|
|
+ return PLUGIN_NAME;
|
|
+}
|
|
+
|
|
+const gchar *plugin_desc(void)
|
|
+{
|
|
+ return _("This plugin renders HTML mail using the Dillo "
|
|
+ "web browser.\n"
|
|
+ "\n"
|
|
+ "Options can be found in /Configuration/Preferences/Plugins/Dillo Browser");
|
|
+}
|
|
+
|
|
+const gchar *plugin_type(void)
|
|
+{
|
|
+ return "GTK2";
|
|
+}
|
|
+
|
|
+const gchar *plugin_licence(void)
|
|
+{
|
|
+ return "GPL3+";
|
|
+}
|
|
+
|
|
+const gchar *plugin_version(void)
|
|
+{
|
|
+ return VERSION;
|
|
+}
|
|
+
|
|
+struct PluginFeature *plugin_provides(void)
|
|
+{
|
|
+ static struct PluginFeature features[] =
|
|
+ { {PLUGIN_MIMEVIEWER, "text/html"},
|
|
+ {PLUGIN_NOTHING, NULL}};
|
|
+ return features;
|
|
+}
|
|
--
|
|
1.7.10.4
|
|
|