talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

commit c45dc1be79e0849b06d70e8861122457bc64cd4d
parent 5d798106f43254befbf3231bd0180ceaf51c32d3
Author: Jonathan Boeing <jonathan@claws-mail.org>
Date:   Wed, 19 Oct 2022 20:26:45 -0700

Don't load Fancy if the Web Extension isn't found

Diffstat:
Msrc/plugins/fancy/Makefile.am | 13+++++++------
Msrc/plugins/fancy/fancy_viewer.c | 19+++++++++++++++++++
2 files changed, 26 insertions(+), 6 deletions(-)

diff --git a/src/plugins/fancy/Makefile.am b/src/plugins/fancy/Makefile.am @@ -16,7 +16,7 @@ webextensiondir = $(pkglibdir)/plugins/web_extensions if BUILD_FANCY_PLUGIN plugin_LTLIBRARIES = fancy.la -webextension_LTLIBRARIES = libfancywebextension.la +webextension_LTLIBRARIES = fancywebextension.la endif fancy_la_LDFLAGS = \ @@ -39,7 +39,8 @@ fancy_la_CPPFLAGS = \ $(WEBKIT_CFLAGS) \ $(LIBSOUP_GNOME_CFLAGS) \ $(CURL_CFLAGS) \ - -DFANCY_WEB_EXTENSIONS_DIR=\""$(pkglibdir)/plugins/web_extensions"\" + -DFANCY_WEB_EXTENSIONS_DIR=\""$(pkglibdir)/plugins/web_extensions"\" \ + -DFANCY_WEB_EXTENSION_FILE=\""fancywebextension"\" fancy_la_SOURCES = \ fancy_prefs.c \ @@ -47,9 +48,9 @@ fancy_la_SOURCES = \ fancy_viewer.c \ fancy_viewer.h -libfancywebextension_la_SOURCES = fancy_web_extension.c -libfancywebextension_la_CFLAGS = $(WEBKIT_CFLAGS) -libfancywebextension_la_LIBADD = $(WEBKIT_LIBS) -libfancywebextension_la_LDFLAGS = -module -avoid-version -no-undefined +fancywebextension_la_SOURCES = fancy_web_extension.c +fancywebextension_la_CFLAGS = $(WEBKIT_CFLAGS) +fancywebextension_la_LIBADD = $(WEBKIT_LIBS) +fancywebextension_la_LDFLAGS = -module -avoid-version -no-undefined .PHONY: test diff --git a/src/plugins/fancy/fancy_viewer.c b/src/plugins/fancy/fancy_viewer.c @@ -1267,6 +1267,25 @@ gint plugin_init(gchar **error) } g_free(directory); + gchar *web_ext_filename = g_strconcat(FANCY_WEB_EXTENSION_FILE, + ".", + G_MODULE_SUFFIX, + NULL); + gchar *web_ext_file = g_build_path(G_DIR_SEPARATOR_S, + FANCY_WEB_EXTENSIONS_DIR, + web_ext_filename, + NULL); + + if (!g_file_test(web_ext_file, G_FILE_TEST_EXISTS)) { + *error = g_strdup_printf(_("Failed to find the companion WebKit extension %s"), web_ext_file); + g_free(web_ext_filename); + g_free(web_ext_file); + return -1; + } + + g_free(web_ext_filename); + g_free(web_ext_file); + webkit_web_context_set_web_extensions_directory(webkit_web_context_get_default(), FANCY_WEB_EXTENSIONS_DIR);