[tracker] libtracker-data: Let TrackerDBCursor subclass TrackerSparqlCursor



commit fd4a3efe0c92f951abd316d47146c87b80d4313b
Author: Jürg Billeter <j bitron ch>
Date:   Tue Jul 6 11:53:32 2010 +0200

    libtracker-data: Let TrackerDBCursor subclass TrackerSparqlCursor

 src/libtracker-data/Makefile.am                   |    1 +
 src/libtracker-data/tracker-db-interface-sqlite.c |   17 +++++++++++++----
 src/libtracker-data/tracker-db-interface.h        |    2 +-
 src/miners/fs/Makefile.am                         |    1 +
 4 files changed, 16 insertions(+), 5 deletions(-)
---
diff --git a/src/libtracker-data/Makefile.am b/src/libtracker-data/Makefile.am
index 7a37b87..55111af 100644
--- a/src/libtracker-data/Makefile.am
+++ b/src/libtracker-data/Makefile.am
@@ -79,6 +79,7 @@ libtracker_data_la_LDFLAGS =						\
 
 libtracker_data_la_LIBADD = 						\
 	$(top_builddir)/src/libtracker-common/libtracker-common.la	\
+	$(top_builddir)/src/libtracker-sparql/libtracker-sparql- TRACKER_API_VERSION@.la \
 	$(SQLITE3_LIBS)							\
 	$(DBUS_LIBS)							\
 	$(GLIB2_LIBS)							\
diff --git a/src/libtracker-data/tracker-db-interface-sqlite.c b/src/libtracker-data/tracker-db-interface-sqlite.c
index 82bbb22..09f9166 100644
--- a/src/libtracker-data/tracker-db-interface-sqlite.c
+++ b/src/libtracker-data/tracker-db-interface-sqlite.c
@@ -28,6 +28,8 @@
 
 #include <libtracker-common/tracker-common.h>
 
+#include <libtracker-sparql/tracker-sparql.h>
+
 #if HAVE_TRACKER_FTS
 #include <libtracker-fts/tracker-fts.h>
 #endif
@@ -56,14 +58,14 @@ struct TrackerDBInterfaceClass {
 };
 
 struct TrackerDBCursor {
-	GObject parent_instance;
+	TrackerSparqlCursor parent_instance;
 	sqlite3_stmt *stmt;
 	TrackerDBStatement *ref_stmt;
 	gboolean finished;
 };
 
 struct TrackerDBCursorClass {
-	GObjectClass parent_class;
+	TrackerSparqlCursorClass parent_class;
 };
 
 struct TrackerDBStatement {
@@ -93,7 +95,7 @@ G_DEFINE_TYPE (TrackerDBInterface, tracker_db_interface, G_TYPE_OBJECT)
 
 G_DEFINE_TYPE (TrackerDBStatement, tracker_db_statement, G_TYPE_OBJECT)
 
-G_DEFINE_TYPE (TrackerDBCursor, tracker_db_cursor, G_TYPE_OBJECT)
+G_DEFINE_TYPE (TrackerDBCursor, tracker_db_cursor, TRACKER_SPARQL_TYPE_CURSOR)
 
 void
 tracker_db_interface_sqlite_enable_shared_cache (void)
@@ -1072,8 +1074,14 @@ static void
 tracker_db_cursor_class_init (TrackerDBCursorClass *class)
 {
 	GObjectClass *object_class = G_OBJECT_CLASS (class);
+	TrackerSparqlCursorClass *sparql_cursor_class = TRACKER_SPARQL_CURSOR_CLASS (class);
 
 	object_class->finalize = tracker_db_cursor_finalize;
+
+	sparql_cursor_class->get_n_columns = (gint (*) (TrackerSparqlCursor *)) tracker_db_cursor_get_n_columns;
+	sparql_cursor_class->get_string = (const gchar * (*) (TrackerSparqlCursor *, gint, glong*)) tracker_db_cursor_get_string;
+	sparql_cursor_class->next = (gboolean (*) (TrackerSparqlCursor *, GCancellable *, GError **)) tracker_db_cursor_iter_next;
+	sparql_cursor_class->rewind = (void (*) (TrackerSparqlCursor *)) tracker_db_cursor_rewind;
 }
 
 static TrackerDBCursor *
@@ -1150,6 +1158,7 @@ tracker_db_cursor_rewind (TrackerDBCursor *cursor)
 	g_return_if_fail (TRACKER_IS_DB_CURSOR (cursor));
 
 	sqlite3_reset (cursor->stmt);
+	cursor->finished = FALSE;
 }
 
 gboolean
@@ -1241,7 +1250,7 @@ tracker_db_cursor_get_double (TrackerDBCursor *cursor,  guint column)
 
 
 const gchar*
-tracker_db_cursor_get_string (TrackerDBCursor *cursor,  guint column, gint *length)
+tracker_db_cursor_get_string (TrackerDBCursor *cursor,  guint column, glong *length)
 {
 	if (length) {
 		sqlite3_value *val = sqlite3_column_value (cursor->stmt, column);
diff --git a/src/libtracker-data/tracker-db-interface.h b/src/libtracker-data/tracker-db-interface.h
index 743efc3..72b8560 100644
--- a/src/libtracker-data/tracker-db-interface.h
+++ b/src/libtracker-data/tracker-db-interface.h
@@ -143,7 +143,7 @@ void                tracker_db_cursor_get_value            (TrackerDBCursor
                                                             GValue              *value);
 const gchar*        tracker_db_cursor_get_string           (TrackerDBCursor     *cursor,
                                                             guint                column,
-                                                            gint                *length);
+                                                            glong               *length);
 gint64              tracker_db_cursor_get_int              (TrackerDBCursor     *cursor,
                                                             guint                column);
 gdouble             tracker_db_cursor_get_double           (TrackerDBCursor     *cursor,
diff --git a/src/miners/fs/Makefile.am b/src/miners/fs/Makefile.am
index 509edb5..d5749a7 100644
--- a/src/miners/fs/Makefile.am
+++ b/src/miners/fs/Makefile.am
@@ -39,6 +39,7 @@ tracker_miner_fs_SOURCES =						\
 
 tracker_miner_fs_LDADD =						\
 	$(top_builddir)/src/libtracker-miner/libtracker-miner- TRACKER_API_VERSION@.la	\
+	$(top_builddir)/src/libtracker-sparql/libtracker-sparql- TRACKER_API_VERSION@.la \
 	$(top_builddir)/src/libtracker-data/libtracker-data.la 		\
 	$(top_builddir)/src/libtracker-common/libtracker-common.la 	\
 	$(DBUS_LIBS)							\



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