Don't load Fancy if the Web Extension isn't found
authorJonathan Boeing <jonathan@claws-mail.org>
Thu, 20 Oct 2022 03:26:45 +0000 (20:26 -0700)
committerJonathan Boeing <jonathan@claws-mail.org>
Thu, 20 Oct 2022 04:16:17 +0000 (21:16 -0700)
src/plugins/fancy/Makefile.am
src/plugins/fancy/fancy_viewer.c

index 9998a6b770d18b2c0454344ef3fdbc671f331117..81341c21863eaf8a656f43a0d631170a604b86c4 100644 (file)
@@ -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
index b69fed53302d45dc18ed614951f79c3e8454f6a4..48f312ec78f1945d7aa4de281df59a89945d0761 100644 (file)
@@ -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);