aboutsummaryrefslogtreecommitdiff
path: root/libdino/src/plugin
diff options
context:
space:
mode:
authorMarvin W <git@larma.de>2017-03-12 13:19:04 +0100
committerMarvin W <git@larma.de>2017-03-12 14:09:32 +0100
commite8f11178ecc1a333976ba713f532fcae11931b16 (patch)
tree71ef4de63e27203780f3d5bfaa1662d97faaca16 /libdino/src/plugin
parenta9ea0e9f87e71c60bc570066525d3e3634fbdcc0 (diff)
downloaddino-e8f11178ecc1a333976ba713f532fcae11931b16.tar.gz
dino-e8f11178ecc1a333976ba713f532fcae11931b16.zip
Move storage into user directory and fix plugin search path
Diffstat (limited to 'libdino/src/plugin')
-rw-r--r--libdino/src/plugin/loader.vala27
1 files changed, 25 insertions, 2 deletions
diff --git a/libdino/src/plugin/loader.vala b/libdino/src/plugin/loader.vala
index acb26ff4..42d7fa9b 100644
--- a/libdino/src/plugin/loader.vala
+++ b/libdino/src/plugin/loader.vala
@@ -14,17 +14,40 @@ public class Loader : Object {
[CCode (has_target = false)]
private delegate Type RegisterPluginFunction (Module module);
+ private string[] search_paths = new string[0];
private RootInterface[] plugins = new RootInterface[0];
private Info[] infos = new Info[0];
+ public Loader(string? exec_str = null) {
+ search_paths += Application.get_storage_dir();
+ if (exec_str != null) {
+ string exec_path = exec_str;
+ if (!exec_path.contains(Path.DIR_SEPARATOR_S)) {
+ exec_path = Environment.find_program_in_path(exec_str);
+ }
+ if (exec_path[0:5] != "/usr") {
+ search_paths += Path.get_dirname(exec_path);
+ }
+ }
+ foreach (string dir in Environment.get_system_data_dirs()) {
+ search_paths += Path.build_filename(dir, "dino");
+ }
+ }
+
public RootInterface load(string name, Dino.Application app) throws Error {
if (Module.supported () == false) {
throw new Error (-1, 0, "Plugins are not supported");
}
- Module module = Module.open ("plugins/" + name, ModuleFlags.BIND_LAZY);
+ Module module = null;
+ string path = "";
+ foreach (string prefix in search_paths) {
+ path = Path.build_filename(prefix, "plugins", name);
+ module = Module.open (path, ModuleFlags.BIND_LAZY);
+ if (module != null) break;
+ }
if (module == null) {
- throw new Error (-1, 1, Module.error ());
+ throw new Error (-1, 1, Module.error ().replace(path, name));
}
void* function;