zeitgeist team mailing list archive
-
zeitgeist team
-
Mailing list archive
-
Message #03968
[Branch ~zeitgeist/zeitgeist/bluebird] Rev 227: Pass Engine instance to extensions
------------------------------------------------------------
revno: 227
committer: Michal Hruby <michal.mhr@xxxxxxxxx>
branch nick: bluebird
timestamp: Mon 2011-09-05 18:16:36 +0200
message:
Pass Engine instance to extensions
modified:
src/engine.vala
src/extension-collection.vala
src/extension.vala
--
lp:~zeitgeist/zeitgeist/bluebird
https://code.launchpad.net/~zeitgeist/zeitgeist/bluebird
Your team Zeitgeist Framework Team is subscribed to branch lp:~zeitgeist/zeitgeist/bluebird.
To unsubscribe from this branch go to https://code.launchpad.net/~zeitgeist/zeitgeist/bluebird/+edit-subscription
=== modified file 'src/engine.vala'
--- src/engine.vala 2011-09-02 17:46:22 +0000
+++ src/engine.vala 2011-09-05 16:16:36 +0000
@@ -34,7 +34,7 @@
public class Engine : Object
{
- private Zeitgeist.SQLite.ZeitgeistDatabase database;
+ public Zeitgeist.SQLite.ZeitgeistDatabase database { get; private set; }
private ExtensionCollection extension_collection;
private unowned Sqlite.Database db;
@@ -47,16 +47,16 @@
public Engine () throws EngineError
{
- database = new Zeitgeist.SQLite.ZeitgeistDatabase();
+ database = new Zeitgeist.SQLite.ZeitgeistDatabase ();
db = database.database;
- last_id = database.get_last_id();
-
- interpretations_table = new TableLookup(database, "interpretation");
- manifestations_table = new TableLookup(database, "manifestation");
- mimetypes_table = new TableLookup(database, "mimetype");
- actors_table = new TableLookup(database, "actor");
-
- extension_collection = new ExtensionCollection ();
+ last_id = database.get_last_id ();
+
+ interpretations_table = new TableLookup (database, "interpretation");
+ manifestations_table = new TableLookup (database, "manifestation");
+ mimetypes_table = new TableLookup (database, "mimetype");
+ actors_table = new TableLookup (database, "actor");
+
+ extension_collection = new ExtensionCollection (this);
}
public string[] get_extension_names ()
=== modified file 'src/extension-collection.vala'
--- src/extension-collection.vala 2011-09-02 17:46:22 +0000
+++ src/extension-collection.vala 2011-09-05 16:16:36 +0000
@@ -23,9 +23,11 @@
{
private GenericArray<Extension> extensions;
- public ExtensionCollection ()
+ public unowned Engine engine { get; construct; }
+
+ public ExtensionCollection (Engine engine)
{
- Object ();
+ Object (engine: engine);
}
~ExtensionCollection ()
@@ -49,7 +51,7 @@
foreach (var func in builtins)
{
ExtensionLoader builtin = new BuiltinExtension (func);
- extension = builtin.create_instance ();
+ extension = builtin.create_instance (engine);
if (extension != null) extensions.add (extension);
}
#endif
@@ -78,7 +80,7 @@
debug ("Loading extension: \"%s\"", path);
var loader = new ModuleLoader (path);
// FIXME: check if enabled
- extension = loader.create_instance ();
+ extension = loader.create_instance (engine);
if (extension != null) extensions.add (extension);
}
else
=== modified file 'src/extension.vala'
--- src/extension.vala 2011-09-02 17:46:22 +0000
+++ src/extension.vala 2011-09-05 16:16:36 +0000
@@ -37,6 +37,8 @@
*/
public abstract class Extension : Object
{
+ public unowned Engine engine { get; construct set; }
+
/**
* This method gets called before Zeitgeist stops.
*
@@ -132,12 +134,13 @@
{
public Type extension_type { get; protected set; }
- public virtual Extension? create_instance ()
+ public virtual Extension? create_instance (Engine engine)
{
if (this.use ())
{
if (extension_type == Type.INVALID) return null;
- Extension? instance = Object.@new (extension_type) as Extension;
+ Extension? instance = Object.@new (extension_type,
+ "engine", engine) as Extension;
debug ("Loaded extension: %s", extension_type.name ());
this.unuse ();
return instance;