summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMoritz Eberl <moritz@semiodesk.com>2016-04-12 15:23:50 +0000
committerMoritz Eberl <moritz@semiodesk.com>2016-04-12 15:23:50 +0000
commitfd70a7878e170d18f91e06a28b48e1a63daf216b (patch)
tree5b1d716052a836dc901e1a03cf5e36a21516cb3c
parentfixed naming of methods. External extensions can now be other module types. (diff)
downloadinkscape-fd70a7878e170d18f91e06a28b48e1a63daf216b.tar.gz
inkscape-fd70a7878e170d18f91e06a28b48e1a63daf216b.zip
Modified the windows build to integrate gmodule-2.0 and loader.cpp/.h
Added method to check inscape version used to build plugins. (bzr r14761.1.3)
-rw-r--r--build-x64.xml4
-rw-r--r--build.xml4
-rw-r--r--src/extension/loader.cpp38
3 files changed, 44 insertions, 2 deletions
diff --git a/build-x64.xml b/build-x64.xml
index 1be9d9449..ca3adcf58 100644
--- a/build-x64.xml
+++ b/build-x64.xml
@@ -405,6 +405,7 @@
${pcc.gdkmm-2.4}
${pcc.pangomm-1.4}
${pcc.cairomm-1.0}
+ ${pcc.gmodule-2.0}
<!-- OTHER -->
${pcc.Magick++}
${pcc.libxml-2.0}
@@ -490,6 +491,7 @@
${devlibs}/bin/libexslt-0.dll
${pcl.cairo} ${pcl.cairomm-1.0}
${pcl.librevenge-stream-0.0} ${pcl.libwpg-0.3} ${pcl.libvisio-0.1} ${pcl.libcdr-0.1}
+ ${pcl.gmodule-2.0}
${pcl.glibmm-2.4}
${pcl.gtk+-2.0}
${pcl.gdkmm-2.4}
@@ -578,6 +580,7 @@
${devlibs}/bin/libexslt-0.dll
${pcl.cairo} ${pcl.cairomm-1.0}
${pcl.librevenge-stream-0.0} ${pcl.libwpg-0.3} ${pcl.libvisio-0.1} ${pcl.libcdr-0.1}
+ ${pcl.gmodule-2.0}
${pcl.glibmm-2.4}
${pcl.gtk+-2.0}
${pcl.gdkmm-2.4}
@@ -629,6 +632,7 @@
-L${devlibs}/lib
${pcl.poppler-cairo} ${pcl.poppler-glib} ${pcl.poppler}
${pcl.gtkmm-2.4} ${pcl.pangoft2} ${pcl.gthread-2.0}
+ ${pcl.gmodule-2.0}
${devlibs}/bin/libxml2-2.dll
${devlibs}/bin/libxslt-1.dll
${devlibs}/bin/libexslt-0.dll
diff --git a/build.xml b/build.xml
index 82cb64231..0705f4f82 100644
--- a/build.xml
+++ b/build.xml
@@ -400,6 +400,7 @@
-I${devlibs}/include
<!-- GTK / GTKMM -->
${pcc.gtkmm-2.4}
+ ${pcc.gmodule-2.0}
<!-- OTHER -->
${pcc.Magick++}
${pcc.libxml-2.0}
@@ -480,6 +481,7 @@
<libs>
-L${devlibs}/lib
${pcl.poppler-cairo} ${pcl.poppler-glib} ${pcl.poppler}
+ ${pcl.gmodule-2.0}
${pcl.gtkmm-2.4} ${pcl.pangoft2} ${pcl.gthread-2.0}
${devlibs}/bin/libxml2.dll
${devlibs}/bin/libxslt.dll
@@ -564,6 +566,7 @@
-L${devlibs}/lib
${pcl.poppler-cairo} ${pcl.poppler-glib} ${pcl.poppler}
${pcl.gtkmm-2.4} ${pcl.pangoft2} ${pcl.gthread-2.0}
+ ${pcl.gmodule-2.0}
${devlibs}/bin/libxml2.dll
${devlibs}/bin/libxslt.dll
${devlibs}/bin/libexslt.dll
@@ -615,6 +618,7 @@
-L${devlibs}/lib
${pcl.poppler-cairo} ${pcl.poppler-glib} ${pcl.poppler}
${pcl.gtkmm-2.4} ${pcl.pangoft2} ${pcl.gthread-2.0}
+ ${pcl.gmodule-2.0}
${devlibs}/bin/libxml2.dll
${devlibs}/bin/libxslt.dll
${devlibs}/bin/libexslt.dll
diff --git a/src/extension/loader.cpp b/src/extension/loader.cpp
index 8893f3f1d..32ac4b3b4 100644
--- a/src/extension/loader.cpp
+++ b/src/extension/loader.cpp
@@ -14,11 +14,13 @@
#include <exception>
#include <string.h>
#include "dependency.h"
+#include "inkscape-version.h"
namespace Inkscape {
namespace Extension {
typedef Implementation::Implementation *(*_getImplementation)(void);
+typedef const gchar *(*_getInkscapeVersion)(void);
bool Loader::load_dependency(Dependency *dep)
{
@@ -38,43 +40,75 @@ bool Loader::load_dependency(Dependency *dep)
Implementation::Implementation *Loader::load_implementation(Inkscape::XML::Document *doc)
{
try {
+
Inkscape::XML::Node *repr = doc->root();
Inkscape::XML::Node *child_repr = repr->firstChild();
+
+ // Iterate over the xml content
while (child_repr != NULL) {
char const *chname = child_repr->name();
if (!strncmp(chname, INKSCAPE_EXTENSION_NS_NC, strlen(INKSCAPE_EXTENSION_NS_NC))) {
chname += strlen(INKSCAPE_EXTENSION_NS);
}
-
+
+ // Deal with dependencies if we have them
if (!strcmp(chname, "dependency")) {
Dependency dep = Dependency(child_repr);
+ // try to load it
bool success = load_dependency(&dep);
if( !success ){
+ // Could not load dependency, we abort
const char *res = g_module_error();
g_warning("Unable to load dependency %s of plugin %s.\nDetails: %s\n", dep.get_name(), res);
return NULL;
}
}
+ // Found a plugin to load
if (!strcmp(chname, "plugin")) {
+
+ // The name of the plugin is actually the library file we want to load
if (const gchar *name = child_repr->attribute("name")) {
GModule *module = NULL;
_getImplementation GetImplementation = NULL;
+ _getInkscapeVersion GetInkscapeVersion = NULL;
+
+ // build the path where to look for the plugin
gchar *path = g_build_filename(_baseDirectory, name, (char *) NULL);
module = g_module_open(path, G_MODULE_BIND_LOCAL);
g_free(path);
+
if (module == NULL) {
+ // we were not able to load the plugin, write warning and abort
const char *res = g_module_error();
g_warning("Unable to load extension %s.\nDetails: %s\n", name, res);
return NULL;
}
+ // Get a handle to the version function of the module
+ if (g_module_symbol(module, "GetInkscapeVersion", (gpointer *) &GetInkscapeVersion) == FALSE) {
+ // This didn't work, write warning and abort
+ const char *res = g_module_error();
+ g_warning("Unable to load extension %s.\nDetails: %s\n", name, res);
+ return NULL;
+ }
+
+ // Get a handle to the function that delivers the implementation
if (g_module_symbol(module, "GetImplementation", (gpointer *) &GetImplementation) == FALSE) {
+ // This didn't work, write warning and abort
const char *res = g_module_error();
g_warning("Unable to load extension %s.\nDetails: %s\n", name, res);
return NULL;
}
-
+
+ // Get version and test against this version
+ const gchar* version = GetInkscapeVersion();
+ if( strcmp(version, version_string) != 0) {
+ // The versions are different, display warning.
+ g_warning("Plugin was built against Inkscape version %s, this is %s. The plugin might not be compatible.", version, version_string);
+ }
+
+
Implementation::Implementation *i = GetImplementation();
return i;
}