/*
- * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2006 Hiroyuki Yamamoto and the Sylpheed-Claws Team
+ * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 1999-2007 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 2 of the License, or
+ * 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,
* 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
*/
#ifdef HAVE_CONFIG_H
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
-#include "common/sylpheed.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
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)
G_CALLBACK(socket_destroy_cb), viewer);
cmd = g_strdup_printf("dillo %s%s-x %d \"%s\"",
- (dillo_prefs.local ? "-l " : ""),
+ (!load_images(viewer) ? "-l " : ""),
(dillo_prefs.full ? "-f " : ""),
(gint) GDK_WINDOW_XWINDOW(viewer->socket->window),
viewer->filename);
debug_print("dillo_destroy_viewer\n");
+ if (viewer->socket) {
+ gtk_widget_destroy(viewer->socket);
+ }
+
gtk_widget_unref(GTK_WIDGET(viewer->widget));
g_unlink(viewer->filename);
g_free(viewer->filename);
gint plugin_init(gchar **error)
{
- if ((sylpheed_get_version() > VERSION_NUMERIC)) {
- *error = g_strdup(_("Your version of Sylpheed-Claws is newer than the version the Dillo plugin was built with"));
- return -1;
- }
+ gchar *dillo_path = NULL;
+ if (!check_plugin_version(MAKE_NUMERIC_VERSION(2,9,2,72),
+ VERSION_NUMERIC, PLUGIN_NAME, error))
+ return -1;
- if ((sylpheed_get_version() < MAKE_NUMERIC_VERSION(0, 9, 3, 86))) {
- *error = g_strdup(_("Your version of Sylpheed-Claws is too old for the Dillo plugin"));
+ 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();
return 0;
}
-void plugin_done(void)
+gboolean plugin_done(void)
{
mimeview_unregister_viewer_factory(&dillo_viewer_factory);
dillo_prefs_done();
+ return TRUE;
}
const gchar *plugin_name(void)
{
- return _("Dillo HTML Viewer");
+ return PLUGIN_NAME;
}
const gchar *plugin_desc(void)
const gchar *plugin_licence(void)
{
- return "GPL";
+ return "GPL3+";
}
const gchar *plugin_version(void)