[tracker/libtracker-sparql-porting: 7/34] tracker-miner-fs: Use new libtracker-sparql API
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/libtracker-sparql-porting: 7/34] tracker-miner-fs: Use new libtracker-sparql API
- Date: Mon, 16 Aug 2010 10:21:21 +0000 (UTC)
commit 3e954dbb6f3610ee7e9d3577b72c8eda7bdfb7cf
Author: Martyn Russell <martyn lanedo com>
Date: Tue Jul 20 12:49:19 2010 +0100
tracker-miner-fs: Use new libtracker-sparql API
src/miners/fs/tracker-miner-applications.c | 6 +-
src/miners/fs/tracker-miner-files-reindex.c | 75 ++++++++++++++------------
2 files changed, 43 insertions(+), 38 deletions(-)
---
diff --git a/src/miners/fs/tracker-miner-applications.c b/src/miners/fs/tracker-miner-applications.c
index 24b40e4..6b756f9 100644
--- a/src/miners/fs/tracker-miner-applications.c
+++ b/src/miners/fs/tracker-miner-applications.c
@@ -224,7 +224,7 @@ process_directory (ProcessApplicationData *data,
path = g_file_get_path (data->file);
uri = g_file_get_uri (data->file);
- urn = tracker_uri_printf_escaped ("urn:applications-dir:%s", path);
+ urn = tracker_sparql_escape_uri_printf ("urn:applications-dir:%s", path);
tracker_sparql_builder_insert_silent_open (sparql, TRACKER_MINER_FS_GRAPH_URN);
@@ -299,7 +299,7 @@ process_desktop_file (ProcessApplicationData *data,
}
if (name && g_ascii_strcasecmp (type, "Directory") == 0) {
- gchar *canonical_uri = tracker_uri_printf_escaped (SOFTWARE_CATEGORY_URN_PREFIX "%s", path);
+ gchar *canonical_uri = tracker_sparql_escape_uri_printf (SOFTWARE_CATEGORY_URN_PREFIX "%s", path);
gchar *icon = g_key_file_get_string (key_file, GROUP_DESKTOP_ENTRY, "Icon", NULL);
uri = canonical_uri;
@@ -454,7 +454,7 @@ process_desktop_file (ProcessApplicationData *data,
/* Sanitize category */
g_strstrip (cat);
- cat_uri = tracker_uri_printf_escaped (SOFTWARE_CATEGORY_URN_PREFIX "%s", cat);
+ cat_uri = tracker_sparql_escape_uri_printf (SOFTWARE_CATEGORY_URN_PREFIX "%s", cat);
/* There are also .desktop
* files that describe these categories, but we can handle
diff --git a/src/miners/fs/tracker-miner-files-reindex.c b/src/miners/fs/tracker-miner-files-reindex.c
index a510843..3a7e059 100644
--- a/src/miners/fs/tracker-miner-files-reindex.c
+++ b/src/miners/fs/tracker-miner-files-reindex.c
@@ -21,7 +21,7 @@
#include <libtracker-common/tracker-dbus.h>
-#include <libtracker-client/tracker.h>
+#include <libtracker-sparql/tracker-sparql.h>
#include "tracker-miner-files-reindex.h"
#include "tracker-dbus.h"
@@ -30,7 +30,7 @@
typedef struct {
guint request_id;
DBusGMethodInvocation *context;
- TrackerClient *client;
+ TrackerSparqlConnection *connection;
TrackerMinerFiles *miner_files;
} MimeTypesData;
@@ -133,10 +133,10 @@ tracker_miner_files_reindex_init (TrackerMinerFilesReindex *object)
}
static MimeTypesData *
-mime_types_data_new (guint request_id,
- DBusGMethodInvocation *context,
- TrackerClient *client,
- TrackerMinerFiles *miner_files)
+mime_types_data_new (guint request_id,
+ DBusGMethodInvocation *context,
+ TrackerSparqlConnection *connection,
+ TrackerMinerFiles *miner_files)
{
MimeTypesData *mtd;
@@ -145,7 +145,7 @@ mime_types_data_new (guint request_id,
mtd->miner_files = g_object_ref (miner_files);
mtd->request_id = request_id;
mtd->context = context;
- mtd->client = g_object_ref (client);
+ mtd->connection = g_object_ref (connection);
return mtd;
}
@@ -158,34 +158,38 @@ mime_types_data_destroy (gpointer data)
mtd = data;
g_object_unref (mtd->miner_files);
- g_object_unref (mtd->client);
+ g_object_unref (mtd->connection);
g_slice_free (MimeTypesData, mtd);
}
static void
-mime_types_cb (TrackerResultIterator *iterator,
- GError *error,
- gpointer user_data)
+mime_types_cb (GObject *object,
+ GAsyncResult *result,
+ gpointer user_data)
{
MimeTypesData *mtd = user_data;
+ TrackerSparqlCursor *cursor;
+ GError *error = NULL;
+
+ cursor = tracker_sparql_connection_query_finish (TRACKER_SPARQL_CONNECTION (object), result, &error);
if (!error) {
tracker_dbus_request_comment (mtd->request_id, mtd->context,
"Found files that will need reindexing");
- while (tracker_result_iterator_next (iterator)) {
- if (tracker_result_iterator_value (iterator, 0)) {
- const gchar *url = (const gchar *) tracker_result_iterator_value (iterator, 0);
- GFile *file = g_file_new_for_uri (url);
- tracker_miner_fs_file_add (TRACKER_MINER_FS (mtd->miner_files), file);
- g_object_unref (file);
- }
+ while (tracker_sparql_cursor_next (cursor, NULL, NULL)) {
+ GFile *file;
+ const gchar *url;
+
+ url = tracker_sparql_cursor_get_string (cursor, 0, NULL);
+ file = g_file_new_for_uri (url);
+ tracker_miner_fs_file_add (TRACKER_MINER_FS (mtd->miner_files), file);
+ g_object_unref (file);
}
tracker_dbus_request_success (mtd->request_id, mtd->context);
dbus_g_method_return (mtd->context);
-
} else {
tracker_dbus_request_success (mtd->request_id, mtd->context);
dbus_g_method_return_error (mtd->context, error);
@@ -211,7 +215,8 @@ tracker_miner_files_reindex_mime_types (TrackerMinerFilesReindex *object,
{
TrackerMinerFilesReindexPrivate *priv;
GString *query;
- TrackerClient *client;
+ GError *inner_error = NULL;
+ TrackerSparqlConnection *connection;
guint request_id;
gint len, i;
@@ -224,16 +229,15 @@ tracker_miner_files_reindex_mime_types (TrackerMinerFilesReindex *object,
tracker_dbus_request_new (request_id, context, "%s()", __FUNCTION__);
- client = tracker_client_new (FALSE, G_MAXINT);
- if (!client) {
- GError *actual_error = NULL;
+ connection = tracker_sparql_connection_get (&inner_error);
+ if (!connection) {
tracker_dbus_request_failed (request_id,
context,
- &actual_error,
- "Could not create TrackerClient");
- dbus_g_method_return_error (context, actual_error);
- g_error_free (actual_error);
+ &inner_error,
+ NULL);
+ dbus_g_method_return_error (context, inner_error);
+ g_error_free (inner_error);
return;
}
@@ -261,14 +265,15 @@ tracker_miner_files_reindex_mime_types (TrackerMinerFilesReindex *object,
priv = TRACKER_MINER_FILES_REINDEX_GET_PRIVATE (object);
/* FIXME: save last call id */
- tracker_resources_sparql_query_iterate_async (client,
- query->str,
- mime_types_cb,
- mime_types_data_new (request_id,
- context,
- client,
- priv->files_miner));
+ tracker_sparql_connection_query_async (connection,
+ query->str,
+ NULL,
+ mime_types_cb,
+ mime_types_data_new (request_id,
+ context,
+ connection,
+ priv->files_miner));
g_string_free (query, TRUE);
- g_object_unref (client);
+ g_object_unref (connection);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]