[tracker/direct-access: 7/38] libtracker-direct: Add init and shutdown code



commit aeeb4cc00ef118e3cb2301f9f5d5f435aaf8a1c3
Author: Jürg Billeter <j bitron ch>
Date:   Tue Jul 6 14:10:18 2010 +0200

    libtracker-direct: Add init and shutdown code

 src/libtracker-data/libtracker-data.vapi      |   17 +++++++++++++++++
 src/libtracker-direct/tracker-connection.vala |    9 ++++++++-
 2 files changed, 25 insertions(+), 1 deletions(-)
---
diff --git a/src/libtracker-data/libtracker-data.vapi b/src/libtracker-data/libtracker-data.vapi
index 903680c..b427e3f 100644
--- a/src/libtracker-data/libtracker-data.vapi
+++ b/src/libtracker-data/libtracker-data.vapi
@@ -40,6 +40,17 @@ namespace Tracker {
 		public abstract DBStatement create_statement (...) throws DBInterfaceError;
 	}
 
+	[CCode (cheader_filename = "libtracker-data/tracker-data-update.h")]
+	public delegate void BusyCallback (string status, double progress);
+
+	[CCode (cprefix = "TRACKER_DB_MANAGER_", cheader_filename = "libtracker-data/tracker-db-manager.h")]
+	public enum DBManagerFlags {
+		FORCE_REINDEX,
+		REMOVE_CACHE,
+		REMOVE_ALL,
+		READONLY
+	}
+
 	[CCode (cheader_filename = "libtracker-data/tracker-db-manager.h")]
 	namespace DBManager {
 		public unowned DBInterface get_db_interface ();
@@ -136,5 +147,11 @@ namespace Tracker {
 		public void update_buffer_flush () throws DBInterfaceError;
 		public void update_buffer_might_flush () throws DBInterfaceError;
 	}
+
+	[CCode (cheader_filename = "libtracker-data/tracker-data-manager.h")]
+	namespace Data.Manager {
+		public bool init (DBManagerFlags flags, [CCode (array_length = false)] string[]? test_schema, out bool first_time, bool journal_check, BusyCallback? busy_callback, string? busy_status);
+		public void shutdown ();
+	}
 }
 
diff --git a/src/libtracker-direct/tracker-connection.vala b/src/libtracker-direct/tracker-connection.vala
index b8a68eb..d68a424 100644
--- a/src/libtracker-direct/tracker-connection.vala
+++ b/src/libtracker-direct/tracker-connection.vala
@@ -18,12 +18,19 @@
  */
 
 public class Tracker.Direct.Connection : Tracker.Sparql.Connection {
-	public Connection () {
+	// only single connection is currently supported per process
+	static bool initialized;
 
+	public Connection ()
+	requires (!initialized) {
+		initialized = true;
+		Data.Manager.init (DBManagerFlags.READONLY, null, null, false, null, null);
 	}
 
 	~Connection () {
 		// Clean up connection
+		Data.Manager.shutdown ();
+		initialized = false;
 	}
 
 	public override Sparql.Cursor query (string sparql) throws GLib.Error {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]