[tracker/wip/sam/resource: 34/41] tracker-extract: Use TrackerResource for normal extraction
- From: Sam Thursfield <sthursfield src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/sam/resource: 34/41] tracker-extract: Use TrackerResource for normal extraction
- Date: Sat, 7 May 2016 14:01:18 +0000 (UTC)
commit 65d443d05d44a4e140461e257fe820ff88ea255d
Author: Sam Thursfield <sam afuera me uk>
Date: Fri May 6 22:54:38 2016 +0200
tracker-extract: Use TrackerResource for normal extraction
FIXME: API break; and probably broken code. We should either squash this
with the "Remove deprecated libtracker-extract API commit", or fix this
one to support being called in the old way and the new way.
src/tracker-extract/tracker-extract-decorator.c | 70 ++++++-----------------
src/tracker-extract/tracker-extract.c | 33 ++---------
src/tracker-extract/tracker-extract.h | 2 -
3 files changed, 23 insertions(+), 82 deletions(-)
---
diff --git a/src/tracker-extract/tracker-extract-decorator.c b/src/tracker-extract/tracker-extract-decorator.c
index e011a92..8a1c891 100644
--- a/src/tracker-extract/tracker-extract-decorator.c
+++ b/src/tracker-extract/tracker-extract-decorator.c
@@ -146,60 +146,28 @@ decorator_save_info (TrackerSparqlBuilder *sparql,
TrackerDecoratorInfo *decorator_info,
TrackerExtractInfo *info)
{
- const gchar *urn, *result, *where;
- TrackerSparqlBuilder *builder;
- gchar *str;
+ const gchar *urn;
+ TrackerResource *resource;
+ TrackerNamespaceManager *namespaces = tracker_namespace_manager_get_default ();
+
+ /* FIXME: need to delete anything that nie:isStoredAs the resource we
+ * are updating .... right ?? no, that sounds wrong, but you do need to
+ * delete anything this extractor might create ....
+ * hmm, a sticky problem.
+ * i.e. if the cuesheet of a flac file is changed completely, then all the
+ * existing tracks need to be removed. that's specific to the gstreamer
+ * extractor though. ugh I guess u need a tracker-extract-info hack to
+ * say 'remove resource of this type that are stored as this file.' .. :(
+ */
urn = tracker_decorator_info_get_urn (decorator_info);
- tracker_sparql_builder_insert_open (sparql, NULL);
- tracker_sparql_builder_graph_open (sparql, TRACKER_OWN_GRAPH_URN);
+ tracker_resource_set_identifier (resource, urn);
+ tracker_resource_set_uri (resource, "nie:dataSource",
+ tracker_decorator_get_data_source (TRACKER_DECORATOR (decorator)));
- /* Set tracker-extract data source */
- tracker_sparql_builder_subject_iri (sparql, urn);
- tracker_sparql_builder_predicate (sparql, "nie:dataSource");
- tracker_sparql_builder_object_iri (sparql,
- tracker_decorator_get_data_source (TRACKER_DECORATOR (decorator)));
-
- builder = tracker_extract_info_get_metadata_builder (info);
-
- if (tracker_sparql_builder_get_length (builder) > 0) {
- /* Add extracted metadata */
- str = g_strdup_printf ("<%s>", urn);
- tracker_sparql_builder_append (sparql, str);
- g_free (str);
-
- result = tracker_sparql_builder_get_result (builder);
- tracker_sparql_builder_append (sparql, result);
-
- /* Close graph and insert statement, insert where clause */
- tracker_sparql_builder_graph_close (sparql);
- tracker_sparql_builder_insert_close (sparql);
-
- where = tracker_extract_info_get_where_clause (info);
-
- if (where && *where) {
- tracker_sparql_builder_where_open (sparql);
- tracker_sparql_builder_append (sparql, where);
- tracker_sparql_builder_where_close (sparql);
- }
- } else {
- tracker_sparql_builder_graph_close (sparql);
- tracker_sparql_builder_insert_close (sparql);
- }
-
- /* Prepend/append pre/postupdate chunks */
- builder = tracker_extract_info_get_preupdate_builder (info);
- result = tracker_sparql_builder_get_result (builder);
-
- if (result && *result)
- tracker_sparql_builder_prepend (sparql, result);
-
- builder = tracker_extract_info_get_postupdate_builder (info);
- result = tracker_sparql_builder_get_result (builder);
-
- if (result && *result)
- tracker_sparql_builder_append (sparql, result);
+ tracker_resource_generate_sparql_update (resource,
+ sparql, namespaces, TRACKER_OWN_GRAPH_URN, NULL);
}
static void
@@ -310,8 +278,6 @@ decorator_next_item_cb (TrackerDecorator *decorator,
tracker_extract_file (priv->extractor,
tracker_decorator_info_get_url (info),
tracker_decorator_info_get_mimetype (info),
- TRACKER_OWN_GRAPH_URN,
- tracker_decorator_info_get_urn (info),
g_task_get_cancellable (task),
(GAsyncReadyCallback) get_metadata_cb, data);
}
diff --git a/src/tracker-extract/tracker-extract.c b/src/tracker-extract/tracker-extract.c
index 7cb20b5..b4fe6e5 100644
--- a/src/tracker-extract/tracker-extract.c
+++ b/src/tracker-extract/tracker-extract.c
@@ -87,8 +87,6 @@ typedef struct {
GAsyncResult *res;
gchar *file;
gchar *mimetype;
- gchar *graph;
- gchar *urn;
TrackerMimetypeInfo *mimetype_handlers;
@@ -296,13 +294,12 @@ get_file_metadata (TrackerExtractTask *task,
TrackerExtractInfo *info;
GFile *file;
gchar *mime_used = NULL;
- gint items = 0;
gboolean success = FALSE;
*info_out = NULL;
file = g_file_new_for_uri (task->file);
- info = tracker_extract_info_new (file, task->mimetype, task->graph, task->urn);
+ info = tracker_extract_info_new (file, task->mimetype);
g_object_unref (file);
#ifdef HAVE_LIBMEDIAART
@@ -322,29 +319,17 @@ get_file_metadata (TrackerExtractTask *task,
*/
if (mime_used) {
if (task->cur_func) {
- TrackerSparqlBuilder *statements;
-
g_debug ("Using %s...",
task->cur_module ?
g_module_name (task->cur_module) :
"Dummy extraction");
- success = (task->cur_func) (info);
-
- statements = tracker_extract_info_get_metadata_builder (info);
- items = tracker_sparql_builder_get_length (statements);
-
- if (items > 0)
- tracker_sparql_builder_insert_close (statements);
-
- task->success = success;
+ task->success = (task->cur_func) (info);
}
g_free (mime_used);
}
- g_debug ("Done (%d objects added)\n", items);
-
if (!success) {
tracker_extract_info_unref (info);
info = NULL;
@@ -382,8 +367,6 @@ static TrackerExtractTask *
extract_task_new (TrackerExtract *extract,
const gchar *uri,
const gchar *mimetype,
- const gchar *graph,
- const gchar *urn,
GCancellable *cancellable,
GAsyncResult *res,
GError **error)
@@ -423,8 +406,6 @@ extract_task_new (TrackerExtract *extract,
task->res = (res) ? g_object_ref (res) : NULL;
task->file = g_strdup (uri);
task->mimetype = mimetype_used;
- task->graph = g_strdup (graph);
- task->urn = g_strdup (urn);
task->extract = extract;
if (task->cancellable) {
@@ -457,8 +438,6 @@ extract_task_free (TrackerExtractTask *task)
tracker_mimetype_info_free (task->mimetype_handlers);
}
- g_free (task->urn);
- g_free (task->graph);
g_free (task->mimetype);
g_free (task->file);
@@ -701,8 +680,6 @@ void
tracker_extract_file (TrackerExtract *extract,
const gchar *file,
const gchar *mimetype,
- const gchar *graph,
- const gchar *urn,
GCancellable *cancellable,
GAsyncReadyCallback cb,
gpointer user_data)
@@ -723,8 +700,8 @@ tracker_extract_file (TrackerExtract *extract,
async_task = g_task_new (extract, cancellable, cb, user_data);
- task = extract_task_new (extract, file, mimetype, graph, urn,
- cancellable, G_ASYNC_RESULT (async_task), &error);
+ task = extract_task_new (extract, file, mimetype, cancellable,
+ G_ASYNC_RESULT (async_task), &error);
if (error) {
g_warning ("Could not get mimetype, %s", error->message);
@@ -777,7 +754,7 @@ tracker_extract_get_metadata_by_cmdline (TrackerExtract *object,
g_return_if_fail (uri != NULL);
- task = extract_task_new (object, uri, mime, NULL, "_:file", NULL, NULL, &error);
+ task = extract_task_new (object, uri, mime, NULL, NULL, &error);
if (error) {
g_printerr ("%s, %s\n",
diff --git a/src/tracker-extract/tracker-extract.h b/src/tracker-extract/tracker-extract.h
index 704ece4..50fa8c3 100644
--- a/src/tracker-extract/tracker-extract.h
+++ b/src/tracker-extract/tracker-extract.h
@@ -62,8 +62,6 @@ TrackerExtract *tracker_extract_new (gboolean
void tracker_extract_file (TrackerExtract *extract,
const gchar *file,
const gchar *mimetype,
- const gchar *graph,
- const gchar *urn,
GCancellable *cancellable,
GAsyncReadyCallback cb,
gpointer user_data);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]