zeitgeist team mailing list archive
-
zeitgeist team
-
Mailing list archive
-
Message #04513
[Branch ~zeitgeist/zeitgeist/bluebird] Rev 363: Add a way to disable extensions
------------------------------------------------------------
revno: 363
committer: Michal Hruby <michal.mhr@xxxxxxxxx>
branch nick: bluebird
timestamp: Mon 2012-01-02 20:31:15 +0100
message:
Add a way to disable extensions
modified:
doc/zeitgeist-daemon.1
src/extension-collection.vala
src/extension.vala
--
lp:zeitgeist
https://code.launchpad.net/~zeitgeist/zeitgeist/bluebird
Your team Zeitgeist Framework Team is subscribed to branch lp:zeitgeist.
To unsubscribe from this branch go to https://code.launchpad.net/~zeitgeist/zeitgeist/bluebird/+edit-subscription
=== modified file 'doc/zeitgeist-daemon.1'
--- doc/zeitgeist-daemon.1 2011-11-01 19:38:11 +0000
+++ doc/zeitgeist-daemon.1 2012-01-02 19:31:15 +0000
@@ -63,6 +63,12 @@
.B ZEITGEIST_DATABASE_BACKUP_PATH
This variable lets you specify an override for the filename of a possible
database backup. The default value is $ZEITGEIST_DATA_PATH/activity.sqlite.bck.
+.TP
+.B ZEITGEIST_DISABLED_EXTENSIONS
+This variable lets you specify comma separated list of extension names which
+shouldn't be loaded. The names are extracted from type names of the extensions,
+so to disable extension with type name ZeitgeistDataSourceRegistry, value
+of the variable should be DataSourceRegistry.
.SH SIGNALS
\fISIGHUP\f1: zeitgeist\-daemon will shut itself down in a clean way.
=== modified file 'src/extension-collection.vala'
--- src/extension-collection.vala 2011-12-25 16:24:04 +0000
+++ src/extension-collection.vala 2012-01-02 19:31:15 +0000
@@ -22,6 +22,7 @@
public class ExtensionCollection : Object
{
private GenericArray<Extension> extensions;
+ private string[] disabled_extensions = {};
public unowned Engine engine { get; construct; }
@@ -40,6 +41,13 @@
Extension? extension;
extensions = new GenericArray<Extension> ();
+ unowned string? disabled =
+ Environment.get_variable ("ZEITGEIST_DISABLED_EXTENSIONS");
+ if (disabled != null)
+ {
+ disabled_extensions = disabled.split_set (",:;");
+ }
+
// load the builtin extensions first
#if BUILTIN_EXTENSIONS
RegisterExtensionFunc[] builtins =
@@ -55,7 +63,7 @@
foreach (var func in builtins)
{
ExtensionLoader builtin = new BuiltinExtension (func);
- extension = builtin.create_instance (engine);
+ extension = instantiate_extension (builtin);
if (extension != null) extensions.add (extension);
}
#endif
@@ -85,8 +93,7 @@
string path = Path.build_filename (ext_dir1, file_name);
debug ("Loading extension: \"%s\"", path);
var loader = new ModuleLoader (path);
- // FIXME: check if disabled
- extension = loader.create_instance (engine);
+ extension = instantiate_extension (loader);
if (extension != null) extensions.add (extension);
}
else
@@ -98,6 +105,29 @@
}
}
+ private Extension? instantiate_extension (ExtensionLoader loader)
+ {
+ if (loader.use ())
+ {
+ unowned string type_name = loader.extension_type.name ();
+ if (type_name == null) return null;
+
+ if (type_name.has_prefix ("Zeitgeist"))
+ {
+ type_name = (string) ((char*) type_name + 9);
+ }
+
+ bool enabled = !(type_name in disabled_extensions);
+ if (!enabled) message ("Skipping %s (disabled)", type_name);
+
+ Extension? e = enabled ? loader.create_instance (engine) : null;
+ loader.unuse ();
+
+ return e;
+ }
+ return null;
+ }
+
public string[] get_extension_names ()
{
string[] result = {};
=== modified file 'src/extension.vala'
--- src/extension.vala 2011-10-20 11:20:36 +0000
+++ src/extension.vala 2012-01-02 19:31:15 +0000
@@ -163,6 +163,11 @@
Object (module_path: module_path);
}
+ construct
+ {
+ set_name (module_path);
+ }
+
protected override bool load ()
{
module = Module.open (module_path, ModuleFlags.BIND_LOCAL);
@@ -215,6 +220,11 @@
reg_func = func;
}
+ construct
+ {
+ set_name ("builtin");
+ }
+
protected override bool load ()
{
if (extension_type == Type.INVALID)
@@ -234,6 +244,11 @@
// to be unreferenced, so we do this
this.ref ();
}
+ else
+ {
+ // this is still needed
+ extension_type = reg_func (this);
+ }
return true;
}