[gtk+/tracker-updates-0.8: 2/3] tracker-search-engine: Fixed 0.7/0.8 issues and add 0.9 cases
- From: Martyn James Russell <mr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/tracker-updates-0.8: 2/3] tracker-search-engine: Fixed 0.7/0.8 issues and add 0.9 cases
- Date: Fri, 9 Apr 2010 12:01:51 +0000 (UTC)
commit 8df7c722cffce26cd02ee7333922101fc84f1e43
Author: Martyn Russell <martyn lanedo com>
Date: Fri Apr 9 12:33:49 2010 +0100
tracker-search-engine: Fixed 0.7/0.8 issues and add 0.9 cases
gtk/gtksearchenginetracker.c | 76 ++++++++++++++++++++++-------------------
1 files changed, 41 insertions(+), 35 deletions(-)
---
diff --git a/gtk/gtksearchenginetracker.c b/gtk/gtksearchenginetracker.c
index 496a0fa..81eb8f3 100644
--- a/gtk/gtksearchenginetracker.c
+++ b/gtk/gtksearchenginetracker.c
@@ -33,9 +33,11 @@ typedef struct _TrackerClient TrackerClient;
typedef enum
{
- TRACKER_0_6 = 1 << 0,
- TRACKER_0_7 = 1 << 1,
- TRACKER_0_8 = 1 << 2
+ TRACKER_UNAVAILABLE = 0,
+ TRACKER_0_6 = 1 << 0,
+ TRACKER_0_7 = 1 << 1,
+ TRACKER_0_8 = 1 << 2,
+ TRACKER_0_9 = 1 << 3
} TrackerVersion;
@@ -63,7 +65,7 @@ static void (*tracker_search_metadata_by_text_and_location_async) (TrackerClient
gpointer user_data) = NULL;
-/* Tracker 0.8 API */
+/* Tracker 0.7->0.9 API */
typedef enum
{
TRACKER_CLIENT_ENABLE_WARNINGS = 1 << 0
@@ -94,12 +96,12 @@ static struct TrackerDlMapping
MAP (tracker_connect, TRACKER_0_6 | TRACKER_0_7),
MAP (tracker_disconnect, TRACKER_0_6 | TRACKER_0_7),
MAP (tracker_get_version, TRACKER_0_6),
- MAP (tracker_cancel_last_call, TRACKER_0_6 | TRACKER_0_7 | TRACKER_0_8),
+ MAP (tracker_cancel_last_call, TRACKER_0_6 | TRACKER_0_7 | TRACKER_0_8 | TRACKER_0_9),
MAP (tracker_search_metadata_by_text_async, TRACKER_0_6 | TRACKER_0_7),
MAP (tracker_search_metadata_by_text_and_location_async, TRACKER_0_6 | TRACKER_0_7),
- MAP (tracker_client_new, TRACKER_0_8),
- MAP (tracker_sparql_escape, TRACKER_0_8),
- MAP (tracker_resources_sparql_query_async, TRACKER_0_8)
+ MAP (tracker_client_new, TRACKER_0_8 | TRACKER_0_9),
+ MAP (tracker_sparql_escape, TRACKER_0_8 | TRACKER_0_9),
+ MAP (tracker_resources_sparql_query_async, TRACKER_0_8 | TRACKER_0_9)
#undef MAP
};
@@ -107,55 +109,55 @@ static TrackerVersion
open_libtracker (void)
{
static gboolean done = FALSE;
- static TrackerVersion version = 0;
- gpointer x;
+ static TrackerVersion version = TRACKER_UNAVAILABLE;
if (!done)
{
- int i;
+ gint i;
GModule *tracker;
GModuleFlags flags;
done = TRUE;
flags = G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL;
- tracker = g_module_open ("libtracker-client-0.7.so.0", flags);
- version = TRACKER_0_7;
-
- if (tracker && g_module_symbol (tracker, "tracker_resources_sparql_query_async", &x))
+ /* We should use stable versions first. So this is the order:
+ *
+ * - 0.8 (stable)
+ * - 0.9 (latest unstable)
+ * - 0.7 (note we do this before 0.6 because 0.6 sucks so badly)
+ * - 0.6 (stable)
+ */
+ if ((tracker = g_module_open ("libtracker-client-0.8.so.0", flags)) != NULL)
version = TRACKER_0_8;
-
- if (!tracker)
- {
- tracker = g_module_open ("libtrackerclient.so.0", flags);
- version = TRACKER_0_6;
- }
-
- if (!tracker)
+ else if ((tracker = g_module_open ("libtracker-client-0.9.so.0", flags)) != NULL)
+ version = TRACKER_0_9;
+ else if ((tracker = g_module_open ("libtracker-client-0.7.so.0", flags)) != NULL)
+ version = TRACKER_0_7;
+ else if ((tracker = g_module_open ("libtrackerclient.so.0", flags)) != NULL)
+ version = TRACKER_0_7;
+ else
{
- tracker = g_module_open ("libtracker.so.0", flags);
- version = TRACKER_0_6;
+ g_debug ("No tracker backend available");
+ return TRACKER_UNAVAILABLE;
}
- if (!tracker)
- return 0;
-
for (i = 0; i < G_N_ELEMENTS (tracker_dl_mapping); i++)
{
if ((tracker_dl_mapping[i].versions & version) == 0)
continue;
- if (!g_module_symbol (tracker, tracker_dl_mapping[i].fn_name,
+ if (!g_module_symbol (tracker,
+ tracker_dl_mapping[i].fn_name,
tracker_dl_mapping[i].fn_ptr_ref))
{
- g_warning ("Missing symbol '%s' in libtracker\n",
+ g_warning ("Missing symbol '%s' in libtracker-client\n",
tracker_dl_mapping[i].fn_name);
g_module_close (tracker);
for (i = 0; i < G_N_ELEMENTS (tracker_dl_mapping); i++)
tracker_dl_mapping[i].fn_ptr_ref = NULL;
- return 0;
+ return TRACKER_UNAVAILABLE;
}
}
}
@@ -187,7 +189,8 @@ finalize (GObject *object)
tracker->priv->query = NULL;
}
- if (tracker->priv->version == TRACKER_0_8)
+ if (tracker->priv->version == TRACKER_0_8 ||
+ tracker->priv->version == TRACKER_0_9)
g_object_unref (tracker->priv->client);
else
tracker_disconnect (tracker->priv->client);
@@ -240,7 +243,8 @@ search_callback (gpointer results,
if (!results)
return;
- if (tracker->priv->version == TRACKER_0_8)
+ if (tracker->priv->version == TRACKER_0_8 ||
+ tracker->priv->version == TRACKER_0_9)
{
OUT_result = (GPtrArray*) results;
@@ -307,7 +311,8 @@ gtk_search_engine_tracker_start (GtkSearchEngine *engine)
location = location_uri;
}
- if (tracker->priv->version == TRACKER_0_8)
+ if (tracker->priv->version == TRACKER_0_8 ||
+ tracker->priv->version == TRACKER_0_9)
{
sparql = g_string_new ("SELECT ?url WHERE { ?file a nfo:FileDataObject; nie:url ?url; fts:match ");
sparql_append_string_literal (sparql, search_text);
@@ -421,7 +426,8 @@ _gtk_search_engine_tracker_new (void)
version = open_libtracker ();
- if (version == TRACKER_0_8)
+ if (version == TRACKER_0_8 ||
+ version == TRACKER_0_9)
{
tracker_client = tracker_client_new (TRACKER_CLIENT_ENABLE_WARNINGS, G_MAXINT);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]