[nautilus] tracker: use libtracker-sparql directly



commit f1dd42ec1c86e78fa894c07ee6b0c8df60d45acb
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Wed Sep 7 17:53:09 2011 -0400

    tracker: use libtracker-sparql directly
    
    It's not a problem for nautilus to depend on libtracker-sparql here
    instead of using g_module_open()

 configure.in                                       |    1 +
 .../nautilus-search-engine-tracker.c               |  105 +-------------------
 2 files changed, 3 insertions(+), 103 deletions(-)
---
diff --git a/configure.in b/configure.in
index e44e01a..43baf71 100644
--- a/configure.in
+++ b/configure.in
@@ -297,6 +297,7 @@ PKG_CHECK_MODULES(NAUTILUS, [
 	gio-unix-2.0 >= glib_minver
 	gsettings-desktop-schemas
 	libnotify >= notify_minver
+	tracker-sparql-0.12
 ])
 
 AC_SUBST(NAUTILUS_CFLAGS)
diff --git a/libnautilus-private/nautilus-search-engine-tracker.c b/libnautilus-private/nautilus-search-engine-tracker.c
index 62730ee..60f8b2b 100644
--- a/libnautilus-private/nautilus-search-engine-tracker.c
+++ b/libnautilus-private/nautilus-search-engine-tracker.c
@@ -27,6 +27,8 @@
 #include <string.h>
 #include <gio/gio.h>
 
+#include <libtracker-sparql/tracker-sparql.h>
+
 /* If defined, we use fts:match, this has to be enabled in Tracker to
  * work which it usually is. The alternative is to undefine it and
  * use filename matching instead. This doesn't use the content of the
@@ -34,105 +36,6 @@
  */
 #undef FTS_MATCHING
 
-#define MODULE_FILENAME "libtracker-sparql-0.10.so.0"
-
-#define MODULE_MAP(a)   { #a, (gpointer *)&a }
-
-/* Connection object */
-typedef struct _TrackerSparqlConnection TrackerSparqlConnection;
-
-#define TRACKER_SPARQL_TYPE_CONNECTION (tracker_sparql_connection_get_type ())
-#define TRACKER_SPARQL_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TRACKER_SPARQL_TYPE_CONNECTION, TrackerSparqlConnection))
-
-/* Cursor object */
-typedef struct _TrackerSparqlCursor TrackerSparqlCursor;
-
-#define TRACKER_SPARQL_TYPE_CURSOR (tracker_sparql_cursor_get_type ())
-#define TRACKER_SPARQL_CURSOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TRACKER_SPARQL_TYPE_CURSOR, TrackerSparqlCursor))
-
-/* API */
-static GType                     (*tracker_sparql_connection_get_type)     (void) = NULL;
-static TrackerSparqlConnection * (*tracker_sparql_connection_get)          (GCancellable             *cancellable,
-                                                                            GError                  **error) = NULL;
-static void                      (*tracker_sparql_connection_query_async)  (TrackerSparqlConnection  *self,
-                                                                            const gchar              *sparql,
-                                                                            GCancellable             *cancellable,
-                                                                            GAsyncReadyCallback       callback,
-                                                                            gpointer                  user_data) = NULL;
-static TrackerSparqlCursor *     (*tracker_sparql_connection_query_finish) (TrackerSparqlConnection  *self,
-                                                                            GAsyncResult             *_res_,
-                                                                            GError                  **error) = NULL;
-static GType                     (*tracker_sparql_cursor_get_type)         (void) = NULL;
-static void                      (*tracker_sparql_cursor_next_async)       (TrackerSparqlCursor      *self,
-                                                                            GCancellable             *cancellable,
-                                                                            GAsyncReadyCallback       callback,
-                                                                            gpointer                  user_data) = NULL;
-static gboolean                  (*tracker_sparql_cursor_next_finish)      (TrackerSparqlCursor      *self,
-                                                                            GAsyncResult             *_res_,
-                                                                            GError                  **error) = NULL;
-static const gchar *             (*tracker_sparql_cursor_get_string)       (TrackerSparqlCursor      *self,
-                                                                            gint                     *column,
-                                                                            glong                    *length) = NULL;
-static gchar *                   (*tracker_sparql_escape_string)           (const gchar              *literal) = NULL;
-
-static struct TrackerFunctions
-{
-	const char *name;
-	gpointer *pointer;
-} funcs[] = {
-	MODULE_MAP (tracker_sparql_connection_get_type),
-	MODULE_MAP (tracker_sparql_connection_get),
-	MODULE_MAP (tracker_sparql_connection_query_async),
-	MODULE_MAP (tracker_sparql_connection_query_finish),
-	MODULE_MAP (tracker_sparql_cursor_get_type),
-	MODULE_MAP (tracker_sparql_cursor_next_async),
-	MODULE_MAP (tracker_sparql_cursor_next_finish),
-	MODULE_MAP (tracker_sparql_cursor_get_string),
-	MODULE_MAP (tracker_sparql_escape_string)
-};
-
-static gboolean
-init (void)
-{
-	static gboolean inited = FALSE;
-	gint i;
-	GModule *m;
-	GModuleFlags flags;
-
-	if (inited) {
-		return TRUE;
-	}
-
-	flags = G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL;
-
-	/* Only support 0.10 onwards */
-	if ((m = g_module_open (MODULE_FILENAME, flags)) == NULL)  {
-		g_debug ("No tracker backend available or it is not new enough");
-		g_debug ("Only available using '%s'", MODULE_FILENAME);
-		return FALSE;
-	}
-
-	inited = TRUE;
-
-	/* Check for the symbols we need */
-	for (i = 0; i < G_N_ELEMENTS (funcs); i++) {
-		if (!g_module_symbol (m, funcs[i].name, funcs[i].pointer)) {
-			g_warning ("Missing symbol '%s' in libtracker-sparql\n",
-				   funcs[i].name);
-			g_module_close (m);
-
-			for (i = 0; i < G_N_ELEMENTS (funcs); i++)
-				funcs[i].pointer = NULL;
-
-			return FALSE;
-		}
-	}
-
-	g_debug ("Loaded Tracker library and all required symbols");
-
-	return TRUE;
-}
-
 struct NautilusSearchEngineTrackerDetails {
 	TrackerSparqlConnection *connection;
 	GCancellable *cancellable;
@@ -465,10 +368,6 @@ nautilus_search_engine_tracker_new (void)
 	TrackerSparqlConnection *connection;
 	GError *error = NULL;
 
-	if (!init()) {
-		return NULL;
-	}
-
 	cancellable = g_cancellable_new ();
 	connection = tracker_sparql_connection_get (cancellable, &error);
 



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