[tracker/direct-access: 5/13] libtracker-direct: Add initial implementation



commit 86b4be42ff37e06519d010e56dc43b4a64bfb116
Author: Jürg Billeter <j bitron ch>
Date:   Mon Jul 5 18:31:36 2010 +0200

    libtracker-direct: Add initial implementation

 src/Makefile.am                           |    1 +
 src/libtracker-data/libtracker-data.vapi  |   17 ++++++++++++
 src/libtracker-direct/.gitignore          |    2 +
 src/libtracker-direct/Makefile.am         |   36 ++++++++++++++++++-------
 src/libtracker-direct/tracker-direct.vala |   41 +++++++++++-----------------
 5 files changed, 62 insertions(+), 35 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 4cdc9d6..640e0ec 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -17,6 +17,7 @@ SUBDIRS = 					\
 	$(libtrackerfts_dir)			\
 	libtracker-bus				\
 	libtracker-data				\
+	libtracker-direct			\
 	libtracker-extract			\
 	libtracker-miner			\
 	miners					\
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/.gitignore b/src/libtracker-direct/.gitignore
new file mode 100644
index 0000000..a97bf1e
--- /dev/null
+++ b/src/libtracker-direct/.gitignore
@@ -0,0 +1,2 @@
+tracker-direct.[ch]
+tracker-direct-*.vapi
diff --git a/src/libtracker-direct/Makefile.am b/src/libtracker-direct/Makefile.am
index 3172ba9..c5113e0 100644
--- a/src/libtracker-direct/Makefile.am
+++ b/src/libtracker-direct/Makefile.am
@@ -1,15 +1,26 @@
 include $(top_srcdir)/Makefile.decl
 
+INCLUDES =								\
+	-DG_LOG_DOMAIN=\"Tracker\"					\
+	-DTRACKER_COMPILATION						\
+	-I$(top_srcdir)/src						\
+	-I$(top_srcdir)/src/libtracker-sparql				\
+	-I$(top_srcdir)/src/libtracker-data				\
+	-I$(top_builddir)/src						\
+	$(WARN_CFLAGS)							\
+	$(GLIB2_CFLAGS)							\
+	$(GCOV_CFLAGS)
+
 lib_LTLIBRARIES = libtracker-direct- TRACKER_API_VERSION@.la
 
 libtracker_directincludedir = $(includedir)/tracker-$(TRACKER_API_VERSION)/libtracker-direct
 
-libtracker_direct_ TRACKER_API_VERSION@_la_VALASOURCES = \
+libtracker_direct_la_VALASOURCES = \
 	tracker-direct.vala
 
 libtracker_direct_ TRACKER_API_VERSION@_la_SOURCES = 	\
 	libtracker-direct.vala.stamp			\
-	$(libtracker_direct_ TRACKER_API_VERSION@_la_VALASOURCES:.vala=.c)
+	$(libtracker_direct_la_VALASOURCES:.vala=.c)
 
 libtracker_direct_ TRACKER_API_VERSION@_la_LDFLAGS = 	\
 	-version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) 
@@ -18,18 +29,23 @@ libtracker_direct_ TRACKER_API_VERSION@_la_LDFLAGS = 	\
 
 libtracker_directinclude_HEADERS = 			\
 	$(top_srcdir)/src/libtracker-sparql/tracker-sparql-$(TRACKER_API_VERSION).vapi	\
-	tracker-connection.h
+	tracker-direct.h
 
 # Vala sources
 vapi_sources =						\
 	$(top_srcdir)/src/libtracker-sparql/tracker-sparql-$(TRACKER_API_VERSION).vapi	\
-	$(top_srcdir)/src/vapi/posix.vapi		\
-	$(top_srcdir)/src/vapi/glib-2.0-fixes.vapi
+	$(top_srcdir)/src/libtracker-common/libtracker-common.vapi	\
+	$(top_srcdir)/src/libtracker-data/libtracker-data.vapi	\
+	$(top_srcdir)/src/libtracker-data/tracker-sparql-query.vapi
 
-libtracker-direct.vala.stamp: $(libtracker_direct_ TRACKER_API_VERSION@_la_VALASOURCES) $(vapi_sources)
-	$(AM_V_GEN)$(VALAC) $(GCOV_VALAFLAGS) -C $(VALAFLAGS) --pkg gio-2.0 -H tracker-connection.h $^
+libtracker-direct.vala.stamp: $(libtracker_direct_la_VALASOURCES) $(vapi_sources)
+	$(AM_V_GEN)$(VALAC) $(GCOV_VALAFLAGS) -C $(VALAFLAGS) --pkg gio-2.0 -H tracker-direct.h $^
 	$(AM_V_GEN)touch $@
 
+libtracker_direct_ TRACKER_API_VERSION@_la_LIBADD = 						\
+	$(top_builddir)/src/libtracker-data/libtracker-data.la	\
+	$(GLIB2_LIBS)
+
 BUILT_SOURCES = 					\
 	libtracker-direct.vala.stamp
 
@@ -37,10 +53,10 @@ CLEANFILES = 						\
 	$(BUILT_SOURCES)
 
 MAINTAINERCLEANFILES =					\
-	$(libtracker_direct_ TRACKER_API_VERSION@_la_VALASOURCES:.vala=.c) \
+	$(libtracker_direct_la_VALASOURCES:.vala=.c) \
 	libtracker-direct.vala.stamp			\
-	tracker-connection.h
+	tracker-direct.h
 
 EXTRA_DIST = 						\
-	$(libtracker_direct_ TRACKER_API_VERSION@_la_VALASOURCES) \
+	$(libtracker_direct_la_VALASOURCES) \
 	libtracker-direct.vala.stamp
diff --git a/src/libtracker-direct/tracker-direct.vala b/src/libtracker-direct/tracker-direct.vala
index a5a61cb..e227f15 100644
--- a/src/libtracker-direct/tracker-direct.vala
+++ b/src/libtracker-direct/tracker-direct.vala
@@ -17,38 +17,29 @@
  * Boston, MA  02110-1301, USA.
  */
 
-public class Tracker.Direct.Connection : GLib.Object, Tracker.Sparql.Cursor {
-	private int _n_columns = 0;
-
-	Connection () {
+public class Tracker.Direct.Connection : Tracker.Sparql.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 int n_columns { 
-		get { return _n_columns; }
-	}
-
-	public bool get_value (uint column, out GLib.Value value) {
-		return false;
-	}
-
-	public bool get_string (uint column, out string value) {
-		return false;
-	}
-
-	public bool get_double (uint column, out double value) {
-		return false;
-	}
-
-	public bool iter_next () {
-		return false;
+	public override Sparql.Cursor query (string sparql, Cancellable? cancellable) throws GLib.Error {
+		var query_object = new Sparql.Query (sparql);
+		return query_object.execute_cursor ();
 	}
 
-	public bool rewind () {
-		return false;
+	public async override Sparql.Cursor query_async (string sparql, Cancellable? cancellable = null) throws GLib.Error {
+		// just creating the cursor won't block
+		return query (sparql, cancellable);
 	}
-}
\ No newline at end of file
+}



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