[tracker/extract-where] tracker-extract: Support extra string for WHERE patterns in GetMetadata
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/extract-where] tracker-extract: Support extra string for WHERE patterns in GetMetadata
- Date: Fri, 25 Mar 2011 14:51:08 +0000 (UTC)
commit bc356738246a922ea41a4767618c6db9235a63c2
Author: Jürg Billeter <j bitron ch>
Date: Fri Mar 25 12:07:00 2011 +0100
tracker-extract: Support extra string for WHERE patterns in GetMetadata
data/dbus/tracker-extract.xml | 1 +
.../libtracker-extract/tracker-extract-mockup.c | 3 +-
src/libtracker-extract/tracker-data.h | 7 ++-
src/libtracker-extract/tracker-module-manager.h | 3 +-
src/libtracker-extract/tracker-xmp.c | 11 +----
src/libtracker-extract/tracker-xmp.h | 1 +
src/miners/fs/tracker-miner-files.c | 35 ++++++++++---
src/tracker-extract/tracker-extract-abw.c | 3 +-
src/tracker-extract/tracker-extract-flac.c | 3 +-
src/tracker-extract/tracker-extract-gif.c | 16 ++-----
.../tracker-extract-gstreamer-helix.c | 3 +-
src/tracker-extract/tracker-extract-gstreamer.c | 3 +-
src/tracker-extract/tracker-extract-gupnp-dlna.c | 3 +-
src/tracker-extract/tracker-extract-html.c | 3 +-
src/tracker-extract/tracker-extract-icon.c | 3 +-
src/tracker-extract/tracker-extract-jpeg.c | 13 +----
src/tracker-extract/tracker-extract-libxine.c | 3 +-
src/tracker-extract/tracker-extract-mp3.c | 3 +-
src/tracker-extract/tracker-extract-mplayer.c | 3 +-
src/tracker-extract/tracker-extract-msoffice-xml.c | 3 +-
src/tracker-extract/tracker-extract-msoffice.c | 3 +-
src/tracker-extract/tracker-extract-oasis.c | 3 +-
src/tracker-extract/tracker-extract-pdf.c | 13 +----
src/tracker-extract/tracker-extract-playlist.c | 3 +-
src/tracker-extract/tracker-extract-png.c | 16 ++-----
src/tracker-extract/tracker-extract-ps.c | 3 +-
src/tracker-extract/tracker-extract-text.c | 3 +-
src/tracker-extract/tracker-extract-tiff.c | 13 +----
src/tracker-extract/tracker-extract-totem.c | 3 +-
src/tracker-extract/tracker-extract-vorbis.c | 3 +-
src/tracker-extract/tracker-extract-xmp.c | 5 +-
src/tracker-extract/tracker-extract.c | 53 +++++++++++++++++---
tests/functional-tests/common/utils/helpers.py | 2 +-
tests/libtracker-extract/tracker-test-xmp.c | 8 ++-
34 files changed, 145 insertions(+), 109 deletions(-)
---
diff --git a/data/dbus/tracker-extract.xml b/data/dbus/tracker-extract.xml
index 308f211..fff17ed 100644
--- a/data/dbus/tracker-extract.xml
+++ b/data/dbus/tracker-extract.xml
@@ -21,6 +21,7 @@
<arg type="s" name="mime" direction="in" />
<arg type="s" name="preupdate" direction="out" />
<arg type="s" name="embedded" direction="out" />
+ <arg type="s" name="where" direction="out" />
</method>
</interface>
</node>
diff --git a/examples/libtracker-extract/tracker-extract-mockup.c b/examples/libtracker-extract/tracker-extract-mockup.c
index 3ddb94b..50ec69d 100644
--- a/examples/libtracker-extract/tracker-extract-mockup.c
+++ b/examples/libtracker-extract/tracker-extract-mockup.c
@@ -30,7 +30,8 @@ G_MODULE_EXPORT gboolean
tracker_extract_get_metadata (const gchar *uri,
const gchar *mimetype,
TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata)
+ TrackerSparqlBuilder *metadata,
+ GString *where)
{
/* NOTE: This function has to exist, tracker-extract checks
* the symbole table for this function and if it doesn't
diff --git a/src/libtracker-extract/tracker-data.h b/src/libtracker-extract/tracker-data.h
index 1ab773c..bf6c58d 100644
--- a/src/libtracker-extract/tracker-data.h
+++ b/src/libtracker-extract/tracker-data.h
@@ -60,7 +60,8 @@ G_BEGIN_DECLS
* tracker_extract_get_metadata (const gchar *uri,
* const gchar *mimetype,
* TrackerSparqlBuilder *preupdate,
- * TrackerSparqlBuilder *metadata)
+ * TrackerSparqlBuilder *metadata,
+ * GString *where)
* {
* gint height, width;
*
@@ -101,6 +102,7 @@ G_BEGIN_DECLS
* are a prerequisite for the actual file
* metadata insertion.
* @metadata: used to populate with file metadata predicate/object(s).
+ * @where: used for optional WHERE patterns
*
* This function must be provided by ALL extractors. This is merely
* the declaration of the function which must be written by each
@@ -135,7 +137,8 @@ G_BEGIN_DECLS
gboolean tracker_extract_get_metadata (const gchar *uri,
const gchar *mimetype,
TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata);
+ TrackerSparqlBuilder *metadata,
+ GString *where);
G_END_DECLS
diff --git a/src/libtracker-extract/tracker-module-manager.h b/src/libtracker-extract/tracker-module-manager.h
index fb0f243..596e233 100644
--- a/src/libtracker-extract/tracker-module-manager.h
+++ b/src/libtracker-extract/tracker-module-manager.h
@@ -34,7 +34,8 @@ G_BEGIN_DECLS
typedef gboolean (* TrackerExtractMetadataFunc) (const gchar *uri,
const gchar *mime_type,
TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata);
+ TrackerSparqlBuilder *metadata,
+ GString *where);
gboolean tracker_extract_module_manager_init (void) G_GNUC_CONST;
diff --git a/src/libtracker-extract/tracker-xmp.c b/src/libtracker-extract/tracker-xmp.c
index ce364ca..21ec190 100644
--- a/src/libtracker-extract/tracker-xmp.c
+++ b/src/libtracker-extract/tracker-xmp.c
@@ -657,12 +657,12 @@ tracker_xmp_free (TrackerXmpData *data)
gboolean
tracker_xmp_apply (TrackerSparqlBuilder *preupdate,
TrackerSparqlBuilder *metadata,
+ GString *where,
const gchar *uri,
TrackerXmpData *data)
{
GPtrArray *keywords;
guint i;
- GString *where = NULL;
g_return_val_if_fail (TRACKER_SPARQL_IS_BUILDER (metadata), FALSE);
g_return_val_if_fail (uri != NULL, FALSE);
@@ -704,10 +704,6 @@ tracker_xmp_apply (TrackerSparqlBuilder *preupdate,
tracker_sparql_builder_predicate (metadata, "nao:hasTag");
tracker_sparql_builder_object_variable (metadata, var);
- if (where == NULL) {
- where = g_string_new ("} } WHERE { {\n");
- }
-
g_string_append_printf (where, "?%s a nao:Tag ; nao:prefLabel \"%s\" .\n", var, escaped);
g_free (var);
@@ -937,10 +933,5 @@ tracker_xmp_apply (TrackerSparqlBuilder *preupdate,
}
- if (where != NULL) {
- tracker_sparql_builder_append (metadata, where->str);
- g_string_free (where, TRUE);
- }
-
return TRUE;
}
diff --git a/src/libtracker-extract/tracker-xmp.h b/src/libtracker-extract/tracker-xmp.h
index c51debc..e0d0085 100644
--- a/src/libtracker-extract/tracker-xmp.h
+++ b/src/libtracker-extract/tracker-xmp.h
@@ -90,6 +90,7 @@ TrackerXmpData * tracker_xmp_new (const gchar *buffer,
void tracker_xmp_free (TrackerXmpData *data);
gboolean tracker_xmp_apply (TrackerSparqlBuilder *preupdate,
TrackerSparqlBuilder *metadata,
+ GString *where,
const gchar *uri,
TrackerXmpData *data);
diff --git a/src/miners/fs/tracker-miner-files.c b/src/miners/fs/tracker-miner-files.c
index e08b456..a479f54 100644
--- a/src/miners/fs/tracker-miner-files.c
+++ b/src/miners/fs/tracker-miner-files.c
@@ -77,6 +77,7 @@ struct ProcessFileData {
typedef void (*fast_async_cb) (const gchar *preupdate,
const gchar *sparql,
+ const gchar *where,
GError *error,
gpointer user_data);
@@ -1950,6 +1951,7 @@ process_file_data_free (ProcessFileData *data)
static void
extractor_get_embedded_metadata_cb (const gchar *preupdate,
const gchar *sparql,
+ const gchar *where,
GError *error,
gpointer user_data)
{
@@ -1985,6 +1987,12 @@ extractor_get_embedded_metadata_cb (const gchar *preupdate,
tracker_sparql_builder_graph_close (data->sparql);
tracker_sparql_builder_insert_close (data->sparql);
+ if (where && *where) {
+ tracker_sparql_builder_where_open (data->sparql);
+ tracker_sparql_builder_append (data->sparql, where);
+ tracker_sparql_builder_where_close (data->sparql);
+ }
+
/* Prepend preupdate queries */
if (preupdate && *preupdate) {
tracker_sparql_builder_prepend (data->sparql, preupdate);
@@ -2055,7 +2063,7 @@ extractor_get_embedded_metadata_cancel (GCancellable *cancellable,
static gboolean
extractor_skip_embedded_metadata_idle (gpointer user_data)
{
- extractor_get_embedded_metadata_cb (NULL, NULL, NULL, user_data);
+ extractor_get_embedded_metadata_cb (NULL, NULL, NULL, NULL, user_data);
return FALSE;
}
@@ -2251,22 +2259,35 @@ get_metadata_fast_cb (void *buffer,
{
FastAsyncData *data;
ProcessFileData *process_data;
+ gboolean valid_input = FALSE;
gboolean free_error = FALSE;
const gchar *preupdate = NULL;
const gchar *sparql = NULL;
+ const gchar *where = NULL;
data = user_data;
process_data = data->user_data;
if (!error && buffer_size) {
- gsize preupdate_length;
+ gsize preupdate_length, sparql_length, where_length;
preupdate = buffer;
- preupdate_length = strnlen (preupdate, buffer_size);
- if (preupdate_length < buffer_size && preupdate[buffer_size - 1] == '\0') {
+ preupdate_length = strnlen (preupdate, buffer_size - 1);
+ if (preupdate[preupdate_length] == '\0') {
/* sparql is stored just after preupdate in the original buffer */
sparql = preupdate + preupdate_length + 1;
- } else {
+ sparql_length = strnlen (sparql, preupdate + buffer_size - 1 - sparql);
+ if (sparql[sparql_length] == '\0') {
+ /* where is stored just after sparql in the original buffer */
+ where = sparql + sparql_length + 1;
+ where_length = strnlen (where, preupdate + buffer_size - 1 - where);
+ if (where[where_length] == '\0') {
+ valid_input = TRUE;
+ }
+ }
+ }
+
+ if (!valid_input) {
error = g_error_new_literal (miner_files_error_quark,
0,
"Invalid data received from GetMetadataFast");
@@ -2276,13 +2297,13 @@ get_metadata_fast_cb (void *buffer,
if (G_UNLIKELY (error)) {
if (error->code != G_IO_ERROR_CANCELLED) {
- (* data->callback) (NULL, NULL, error, process_data);
+ (* data->callback) (NULL, NULL, NULL, error, process_data);
}
if (free_error) {
g_error_free (error);
}
} else {
- (* data->callback) (preupdate, sparql, NULL, data->user_data);
+ (* data->callback) (preupdate, sparql, where, NULL, data->user_data);
}
fast_async_data_free (data);
diff --git a/src/tracker-extract/tracker-extract-abw.c b/src/tracker-extract/tracker-extract-abw.c
index 6d42aa7..da2cb70 100644
--- a/src/tracker-extract/tracker-extract-abw.c
+++ b/src/tracker-extract/tracker-extract-abw.c
@@ -41,7 +41,8 @@ G_MODULE_EXPORT gboolean
tracker_extract_get_metadata (const gchar *uri,
const gchar *mimetype,
TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata)
+ TrackerSparqlBuilder *metadata,
+ GString *where)
{
FILE *f;
gchar *filename;
diff --git a/src/tracker-extract/tracker-extract-flac.c b/src/tracker-extract/tracker-extract-flac.c
index 5062d79..8afbaf7 100644
--- a/src/tracker-extract/tracker-extract-flac.c
+++ b/src/tracker-extract/tracker-extract-flac.c
@@ -154,7 +154,8 @@ G_MODULE_EXPORT gboolean
tracker_extract_get_metadata (const gchar *uri,
const gchar *mimetype,
TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata)
+ TrackerSparqlBuilder *metadata,
+ GString *where)
{
FLAC__Metadata_SimpleIterator *iter;
FLAC__StreamMetadata *stream = NULL, *vorbis, *picture;
diff --git a/src/tracker-extract/tracker-extract-gif.c b/src/tracker-extract/tracker-extract-gif.c
index 6671cfe..fb113d3 100644
--- a/src/tracker-extract/tracker-extract-gif.c
+++ b/src/tracker-extract/tracker-extract-gif.c
@@ -71,6 +71,7 @@ ext_block_append(ExtBlock *extBlock,
static void
read_metadata (TrackerSparqlBuilder *preupdate,
TrackerSparqlBuilder *metadata,
+ GString *where,
GifFileType *gifFile,
const gchar *uri)
{
@@ -84,7 +85,6 @@ read_metadata (TrackerSparqlBuilder *preupdate,
MergeData md = { 0 };
GifData gd = { 0 };
TrackerXmpData *xd = NULL;
- GString *where = NULL;
do {
GifByteType *ExtData;
@@ -363,10 +363,6 @@ read_metadata (TrackerSparqlBuilder *preupdate,
tracker_sparql_builder_predicate (metadata, "nao:hasTag");
tracker_sparql_builder_object_variable (metadata, var);
- if (where == NULL) {
- where = g_string_new ("} } WHERE { {\n");
- }
-
g_string_append_printf (where, "?%s a nao:Tag ; nao:prefLabel \"%s\" .\n", var, escaped);
g_free (var);
@@ -492,11 +488,6 @@ read_metadata (TrackerSparqlBuilder *preupdate,
g_free (gd.comment);
}
- if (where != NULL) {
- tracker_sparql_builder_append (metadata, where->str);
- g_string_free (where, TRUE);
- }
-
tracker_xmp_free (xd);
}
@@ -505,7 +496,8 @@ G_MODULE_EXPORT gboolean
tracker_extract_get_metadata (const gchar *uri,
const gchar *mimetype,
TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata)
+ TrackerSparqlBuilder *metadata,
+ GString *where)
{
goffset size;
GifFileType *gifFile = NULL;
@@ -530,7 +522,7 @@ tracker_extract_get_metadata (const gchar *uri,
tracker_sparql_builder_object (metadata, "nfo:Image");
tracker_sparql_builder_object (metadata, "nmm:Photo");
- read_metadata (preupdate, metadata, gifFile, uri);
+ read_metadata (preupdate, metadata, where, gifFile, uri);
if (DGifCloseFile (gifFile) != GIF_OK) {
PrintGifError ();
diff --git a/src/tracker-extract/tracker-extract-gstreamer-helix.c b/src/tracker-extract/tracker-extract-gstreamer-helix.c
index b18bd6d..460619a 100644
--- a/src/tracker-extract/tracker-extract-gstreamer-helix.c
+++ b/src/tracker-extract/tracker-extract-gstreamer-helix.c
@@ -845,7 +845,8 @@ G_MODULE_EXPORT gboolean
tracker_extract_get_metadata (const gchar *uri,
const gchar *mimetype,
TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata)
+ TrackerSparqlBuilder *metadata,
+ GString *where)
{
if (g_str_has_prefix (mimetype, "audio/")) {
tracker_extract_gstreamer_helix (uri, preupdate, metadata, EXTRACT_MIME_AUDIO);
diff --git a/src/tracker-extract/tracker-extract-gstreamer.c b/src/tracker-extract/tracker-extract-gstreamer.c
index ce613a2..e86a7db 100644
--- a/src/tracker-extract/tracker-extract-gstreamer.c
+++ b/src/tracker-extract/tracker-extract-gstreamer.c
@@ -1322,7 +1322,8 @@ G_MODULE_EXPORT gboolean
tracker_extract_get_metadata (const gchar *uri,
const gchar *mimetype,
TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata)
+ TrackerSparqlBuilder *metadata,
+ GString *where)
{
if (strcmp (mimetype, "image/svg+xml") == 0) {
tracker_extract_gstreamer (uri, preupdate, metadata, EXTRACT_MIME_SVG);
diff --git a/src/tracker-extract/tracker-extract-gupnp-dlna.c b/src/tracker-extract/tracker-extract-gupnp-dlna.c
index 6f8c1ca..0f07550 100644
--- a/src/tracker-extract/tracker-extract-gupnp-dlna.c
+++ b/src/tracker-extract/tracker-extract-gupnp-dlna.c
@@ -819,7 +819,8 @@ G_MODULE_EXPORT gboolean
tracker_extract_get_metadata (const gchar *uri,
const gchar *mimetype,
TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata)
+ TrackerSparqlBuilder *metadata,
+ GString *where)
{
if (strcmp (mimetype, "video/3gpp") == 0 ||
strcmp (mimetype, "video/mp4") == 0 ||
diff --git a/src/tracker-extract/tracker-extract-html.c b/src/tracker-extract/tracker-extract-html.c
index b15407c..6b761d6 100644
--- a/src/tracker-extract/tracker-extract-html.c
+++ b/src/tracker-extract/tracker-extract-html.c
@@ -234,7 +234,8 @@ G_MODULE_EXPORT gboolean
tracker_extract_get_metadata (const gchar *uri,
const gchar *mimetype,
TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata)
+ TrackerSparqlBuilder *metadata,
+ GString *where)
{
TrackerConfig *config;
htmlDocPtr doc;
diff --git a/src/tracker-extract/tracker-extract-icon.c b/src/tracker-extract/tracker-extract-icon.c
index add946e..c2b3670 100644
--- a/src/tracker-extract/tracker-extract-icon.c
+++ b/src/tracker-extract/tracker-extract-icon.c
@@ -128,7 +128,8 @@ G_MODULE_EXPORT gboolean
tracker_extract_get_metadata (const gchar *uri,
const gchar *mimetype,
TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata)
+ TrackerSparqlBuilder *metadata,
+ GString *where)
{
guint max_width;
guint max_height;
diff --git a/src/tracker-extract/tracker-extract-jpeg.c b/src/tracker-extract/tracker-extract-jpeg.c
index 589c438..b54f511 100644
--- a/src/tracker-extract/tracker-extract-jpeg.c
+++ b/src/tracker-extract/tracker-extract-jpeg.c
@@ -94,7 +94,8 @@ G_MODULE_EXPORT gboolean
tracker_extract_get_metadata (const gchar *uri,
const gchar *mimetype,
TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata)
+ TrackerSparqlBuilder *metadata,
+ GString *where)
{
struct jpeg_decompress_struct cinfo;
struct tej_error_mgr tejerr;
@@ -110,7 +111,6 @@ tracker_extract_get_metadata (const gchar *uri,
GPtrArray *keywords;
gboolean success = TRUE;
guint i;
- GString *where = NULL;
filename = g_filename_from_uri (uri, NULL, NULL);
@@ -377,10 +377,6 @@ tracker_extract_get_metadata (const gchar *uri,
tracker_sparql_builder_predicate (metadata, "nao:hasTag");
tracker_sparql_builder_object_variable (metadata, var);
- if (where == NULL) {
- where = g_string_new ("} } WHERE { {\n");
- }
-
g_string_append_printf (where, "?%s a nao:Tag ; nao:prefLabel \"%s\" .\n", var, escaped);
g_free (var);
@@ -633,11 +629,6 @@ tracker_extract_get_metadata (const gchar *uri,
tracker_sparql_builder_object_double (metadata, value);
}
- if (where != NULL) {
- tracker_sparql_builder_append (metadata, where->str);
- g_string_free (where, TRUE);
- }
-
jpeg_destroy_decompress (&cinfo);
tracker_exif_free (ed);
diff --git a/src/tracker-extract/tracker-extract-libxine.c b/src/tracker-extract/tracker-extract-libxine.c
index 743bfbf..7bd8654 100644
--- a/src/tracker-extract/tracker-extract-libxine.c
+++ b/src/tracker-extract/tracker-extract-libxine.c
@@ -32,7 +32,8 @@ G_MODULE_EXPORT gboolean
tracker_extract_get_metadata (const gchar *uri,
const gchar *mimetype,
TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata)
+ TrackerSparqlBuilder *metadata,
+ GString *where)
{
xine_t *xine_base;
xine_audio_port_t *audio_port;
diff --git a/src/tracker-extract/tracker-extract-mp3.c b/src/tracker-extract/tracker-extract-mp3.c
index 770007e..dda4ab9 100644
--- a/src/tracker-extract/tracker-extract-mp3.c
+++ b/src/tracker-extract/tracker-extract-mp3.c
@@ -2006,7 +2006,8 @@ G_MODULE_EXPORT gboolean
tracker_extract_get_metadata (const gchar *uri,
const gchar *mimetype,
TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata)
+ TrackerSparqlBuilder *metadata,
+ GString *where)
{
gchar *filename;
int fd;
diff --git a/src/tracker-extract/tracker-extract-mplayer.c b/src/tracker-extract/tracker-extract-mplayer.c
index 3e1c373..611e2d7 100644
--- a/src/tracker-extract/tracker-extract-mplayer.c
+++ b/src/tracker-extract/tracker-extract-mplayer.c
@@ -104,7 +104,8 @@ G_MODULE_EXPORT gboolean
tracker_extract_get_metadata (const gchar *uri,
const gchar *mimetype,
TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata)
+ TrackerSparqlBuilder *metadata,
+ GString *where)
{
gchar *argv[10];
gchar *mplayer;
diff --git a/src/tracker-extract/tracker-extract-msoffice-xml.c b/src/tracker-extract/tracker-extract-msoffice-xml.c
index cdcc9d1..c574090 100644
--- a/src/tracker-extract/tracker-extract-msoffice-xml.c
+++ b/src/tracker-extract/tracker-extract-msoffice-xml.c
@@ -710,7 +710,8 @@ G_MODULE_EXPORT gboolean
tracker_extract_get_metadata (const gchar *uri,
const gchar *mimetype,
TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata)
+ TrackerSparqlBuilder *metadata,
+ GString *where)
{
MsOfficeXMLParserInfo info;
MsOfficeXMLFileType file_type;
diff --git a/src/tracker-extract/tracker-extract-msoffice.c b/src/tracker-extract/tracker-extract-msoffice.c
index 572ddd6..1e2bbdf 100644
--- a/src/tracker-extract/tracker-extract-msoffice.c
+++ b/src/tracker-extract/tracker-extract-msoffice.c
@@ -1635,7 +1635,8 @@ G_MODULE_EXPORT gboolean
tracker_extract_get_metadata (const gchar *uri,
const gchar *mime_used,
TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata)
+ TrackerSparqlBuilder *metadata,
+ GString *where)
{
TrackerConfig *config;
GsfInfile *infile = NULL;
diff --git a/src/tracker-extract/tracker-extract-oasis.c b/src/tracker-extract/tracker-extract-oasis.c
index 7ef8688..d826a85 100644
--- a/src/tracker-extract/tracker-extract-oasis.c
+++ b/src/tracker-extract/tracker-extract-oasis.c
@@ -160,7 +160,8 @@ G_MODULE_EXPORT gboolean
tracker_extract_get_metadata (const gchar *uri,
const gchar *mime_used,
TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata)
+ TrackerSparqlBuilder *metadata,
+ GString *where)
{
TrackerConfig *config;
ODTMetadataParseInfo info;
diff --git a/src/tracker-extract/tracker-extract-pdf.c b/src/tracker-extract/tracker-extract-pdf.c
index 57a216f..d0cf089 100644
--- a/src/tracker-extract/tracker-extract-pdf.c
+++ b/src/tracker-extract/tracker-extract-pdf.c
@@ -269,7 +269,8 @@ G_MODULE_EXPORT gboolean
tracker_extract_get_metadata (const gchar *uri,
const gchar *mimetype,
TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata)
+ TrackerSparqlBuilder *metadata,
+ GString *where)
{
TrackerConfig *config;
GTime creation_date;
@@ -283,7 +284,6 @@ tracker_extract_get_metadata (const gchar *uri,
guint n_bytes;
GPtrArray *keywords;
guint i;
- GString *where = NULL;
g_type_init ();
@@ -583,10 +583,6 @@ tracker_extract_get_metadata (const gchar *uri,
tracker_sparql_builder_predicate (metadata, "nao:hasTag");
tracker_sparql_builder_object_variable (metadata, var);
- if (where == NULL) {
- where = g_string_new ("} } WHERE { {\n");
- }
-
g_string_append_printf (where, "?%s a nao:Tag ; nao:prefLabel \"%s\" .\n", var, escaped);
g_free (var);
@@ -610,11 +606,6 @@ tracker_extract_get_metadata (const gchar *uri,
read_outline (document, metadata);
- if (where != NULL) {
- tracker_sparql_builder_append (metadata, where->str);
- g_string_free (where, TRUE);
- }
-
g_free (xml);
g_free (pd.keywords);
g_free (pd.title);
diff --git a/src/tracker-extract/tracker-extract-playlist.c b/src/tracker-extract/tracker-extract-playlist.c
index ebbefc0..8e4340c 100644
--- a/src/tracker-extract/tracker-extract-playlist.c
+++ b/src/tracker-extract/tracker-extract-playlist.c
@@ -96,7 +96,8 @@ G_MODULE_EXPORT gboolean
tracker_extract_get_metadata (const gchar *uri,
const gchar *mimetype,
TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata)
+ TrackerSparqlBuilder *metadata,
+ GString *where)
{
TotemPlParser *pl;
TotemPlParserResult result;
diff --git a/src/tracker-extract/tracker-extract-png.c b/src/tracker-extract/tracker-extract-png.c
index 801afc8..7bd5073 100644
--- a/src/tracker-extract/tracker-extract-png.c
+++ b/src/tracker-extract/tracker-extract-png.c
@@ -81,6 +81,7 @@ rfc1123_to_iso8601_date (const gchar *date)
static void
read_metadata (TrackerSparqlBuilder *preupdate,
TrackerSparqlBuilder *metadata,
+ GString *where,
png_structp png_ptr,
png_infop info_ptr,
png_infop end_ptr,
@@ -97,7 +98,6 @@ read_metadata (TrackerSparqlBuilder *preupdate,
gint i;
gint found;
GPtrArray *keywords;
- GString *where = NULL;
info_ptrs[0] = info_ptr;
info_ptrs[1] = end_ptr;
@@ -496,10 +496,6 @@ read_metadata (TrackerSparqlBuilder *preupdate,
tracker_sparql_builder_predicate (metadata, "nao:hasTag");
tracker_sparql_builder_object_variable (metadata, var);
- if (where == NULL) {
- where = g_string_new ("} } WHERE { {\n");
- }
-
g_string_append_printf (where, "?%s a nao:Tag ; nao:prefLabel \"%s\" .\n", var, escaped);
g_free (var);
@@ -508,11 +504,6 @@ read_metadata (TrackerSparqlBuilder *preupdate,
}
g_ptr_array_free (keywords, TRUE);
- if (where != NULL) {
- tracker_sparql_builder_append (metadata, where->str);
- g_string_free (where, TRUE);
- }
-
tracker_exif_free (ed);
tracker_xmp_free (xd);
g_free (pd.creation_time);
@@ -522,7 +513,8 @@ G_MODULE_EXPORT gboolean
tracker_extract_get_metadata (const gchar *uri,
const gchar *mimetype,
TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata)
+ TrackerSparqlBuilder *metadata,
+ GString *where)
{
goffset size;
FILE *f;
@@ -620,7 +612,7 @@ tracker_extract_get_metadata (const gchar *uri,
tracker_sparql_builder_object (metadata, "nfo:Image");
tracker_sparql_builder_object (metadata, "nmm:Photo");
- read_metadata (preupdate, metadata, png_ptr, info_ptr, end_ptr, uri);
+ read_metadata (preupdate, metadata, where, png_ptr, info_ptr, end_ptr, uri);
tracker_sparql_builder_predicate (metadata, "nfo:width");
tracker_sparql_builder_object_int64 (metadata, width);
diff --git a/src/tracker-extract/tracker-extract-ps.c b/src/tracker-extract/tracker-extract-ps.c
index 7cd7613..edfacb6 100644
--- a/src/tracker-extract/tracker-extract-ps.c
+++ b/src/tracker-extract/tracker-extract-ps.c
@@ -282,7 +282,8 @@ G_MODULE_EXPORT gboolean
tracker_extract_get_metadata (const gchar *uri,
const gchar *mimetype,
TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata)
+ TrackerSparqlBuilder *metadata,
+ GString *where)
{
#ifdef USING_UNZIPPSFILES
if (strcmp (mimetype, "application/x-gzpostscript") == 0) {
diff --git a/src/tracker-extract/tracker-extract-text.c b/src/tracker-extract/tracker-extract-text.c
index 2141c87..a93fe0b 100644
--- a/src/tracker-extract/tracker-extract-text.c
+++ b/src/tracker-extract/tracker-extract-text.c
@@ -76,7 +76,8 @@ G_MODULE_EXPORT gboolean
tracker_extract_get_metadata (const gchar *uri,
const gchar *mimetype,
TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata)
+ TrackerSparqlBuilder *metadata,
+ GString *where)
{
TrackerConfig *config;
gchar *content;
diff --git a/src/tracker-extract/tracker-extract-tiff.c b/src/tracker-extract/tracker-extract-tiff.c
index e6aeb6c..53f9644 100644
--- a/src/tracker-extract/tracker-extract-tiff.c
+++ b/src/tracker-extract/tracker-extract-tiff.c
@@ -243,7 +243,8 @@ G_MODULE_EXPORT gboolean
tracker_extract_get_metadata (const gchar *uri,
const gchar *mimetype,
TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata)
+ TrackerSparqlBuilder *metadata,
+ GString *where)
{
TIFF *image;
TrackerXmpData *xd = NULL;
@@ -256,7 +257,6 @@ tracker_extract_get_metadata (const gchar *uri,
glong exif_offset;
GPtrArray *keywords;
guint i;
- GString *where = NULL;
#ifdef HAVE_LIBIPTCDATA
gchar *iptc_offset;
@@ -550,10 +550,6 @@ tracker_extract_get_metadata (const gchar *uri,
tracker_sparql_builder_predicate (metadata, "nao:hasTag");
tracker_sparql_builder_object_variable (metadata, var);
- if (where == NULL) {
- where = g_string_new ("} } WHERE { {\n");
- }
-
g_string_append_printf (where, "?%s a nao:Tag ; nao:prefLabel \"%s\" .\n", var, escaped);
g_free (var);
@@ -719,11 +715,6 @@ tracker_extract_get_metadata (const gchar *uri,
tracker_sparql_builder_object_double (metadata, value);
}
- if (where != NULL) {
- tracker_sparql_builder_append (metadata, where->str);
- g_string_free (where, TRUE);
- }
-
tiff_data_free (&td);
tracker_exif_free (ed);
tracker_xmp_free (xd);
diff --git a/src/tracker-extract/tracker-extract-totem.c b/src/tracker-extract/tracker-extract-totem.c
index 1c7cec2..1bfc3d9 100644
--- a/src/tracker-extract/tracker-extract-totem.c
+++ b/src/tracker-extract/tracker-extract-totem.c
@@ -59,7 +59,8 @@ G_MODULE_EXPORT gboolean
tracker_extract_get_metadata (const gchar *uri,
const gchar *mimetype,
TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata)
+ TrackerSparqlBuilder *metadata,
+ GString *where)
{
gchar *argv[3];
gchar *totem;
diff --git a/src/tracker-extract/tracker-extract-vorbis.c b/src/tracker-extract/tracker-extract-vorbis.c
index a328d37..04f58df 100644
--- a/src/tracker-extract/tracker-extract-vorbis.c
+++ b/src/tracker-extract/tracker-extract-vorbis.c
@@ -89,7 +89,8 @@ G_MODULE_EXPORT gboolean
tracker_extract_get_metadata (const char *uri,
const gchar *mimetype,
TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata)
+ TrackerSparqlBuilder *metadata,
+ GString *where)
{
VorbisData vd = { 0 };
MergeData md = { 0 };
diff --git a/src/tracker-extract/tracker-extract-xmp.c b/src/tracker-extract/tracker-extract-xmp.c
index b0faf37..3d749ee 100644
--- a/src/tracker-extract/tracker-extract-xmp.c
+++ b/src/tracker-extract/tracker-extract-xmp.c
@@ -123,7 +123,8 @@ G_MODULE_EXPORT gboolean
tracker_extract_get_metadata (const gchar *uri,
const gchar *mimetype,
TrackerSparqlBuilder *preupdate,
- TrackerSparqlBuilder *metadata)
+ TrackerSparqlBuilder *metadata,
+ GString *where)
{
TrackerXmpData *xd = NULL;
GError *error = NULL;
@@ -146,7 +147,7 @@ tracker_extract_get_metadata (const gchar *uri,
original_uri ? original_uri : uri);
if (xd) {
- tracker_xmp_apply (preupdate, metadata, uri, xd);
+ tracker_xmp_apply (preupdate, metadata, where, uri, xd);
}
g_free (original_uri);
diff --git a/src/tracker-extract/tracker-extract.c b/src/tracker-extract/tracker-extract.c
index 0d7d2b5..d4b7de6 100644
--- a/src/tracker-extract/tracker-extract.c
+++ b/src/tracker-extract/tracker-extract.c
@@ -57,6 +57,7 @@ static const gchar introspection_xml[] =
" <arg type='s' name='mime' direction='in' />"
" <arg type='s' name='preupdate' direction='out' />"
" <arg type='s' name='embedded' direction='out' />"
+ " <arg type='s' name='where' direction='out' />"
" </method>"
" <method name='GetMetadataFast'>"
" <arg type='s' name='uri' direction='in' />"
@@ -209,10 +210,12 @@ get_file_metadata (TrackerExtract *extract,
const gchar *uri,
const gchar *mime,
TrackerSparqlBuilder **preupdate_out,
- TrackerSparqlBuilder **statements_out)
+ TrackerSparqlBuilder **statements_out,
+ gchar **where_out)
{
TrackerExtractPrivate *priv;
TrackerSparqlBuilder *statements, *preupdate;
+ GString *where;
gchar *mime_used = NULL;
#ifdef HAVE_LIBSTREAMANALYZER
gchar *content_type = NULL;
@@ -222,10 +225,12 @@ get_file_metadata (TrackerExtract *extract,
*preupdate_out = NULL;
*statements_out = NULL;
+ *where_out = NULL;
/* Create sparql builders to send back */
preupdate = tracker_sparql_builder_new_update ();
statements = tracker_sparql_builder_new_embedded_insert ();
+ where = g_string_new ("");
#ifdef HAVE_LIBSTREAMANALYZER
if (!priv->force_internal_extractors) {
@@ -240,6 +245,8 @@ get_file_metadata (TrackerExtract *extract,
*preupdate_out = preupdate;
*statements_out = statements;
+ *where_out = where->str;
+ g_string_free (where, FALSE);
return TRUE;
}
} else {
@@ -271,6 +278,7 @@ get_file_metadata (TrackerExtract *extract,
uri);
g_object_unref (statements);
g_object_unref (preupdate);
+ g_string_free (where, TRUE);
return FALSE;
}
@@ -293,6 +301,7 @@ get_file_metadata (TrackerExtract *extract,
g_object_unref (file);
g_object_unref (statements);
g_object_unref (preupdate);
+ g_string_free (where, TRUE);
return FALSE;
}
@@ -321,7 +330,7 @@ get_file_metadata (TrackerExtract *extract,
StatisticsData *data;
gint items;
- (func) (uri, mime_used, preupdate, statements);
+ (func) (uri, mime_used, preupdate, statements, where);
items = tracker_sparql_builder_get_length (statements);
@@ -343,6 +352,8 @@ get_file_metadata (TrackerExtract *extract,
*preupdate_out = preupdate;
*statements_out = statements;
+ *where_out = where->str;
+ g_string_free (where, FALSE);
return TRUE;
} else {
@@ -367,6 +378,8 @@ get_file_metadata (TrackerExtract *extract,
*preupdate_out = preupdate;
*statements_out = statements;
+ *where_out = where->str;
+ g_string_free (where, FALSE);
return TRUE;
}
@@ -378,6 +391,7 @@ tracker_extract_get_metadata_by_cmdline (TrackerExtract *object,
{
TrackerDBusRequest *request;
TrackerSparqlBuilder *statements, *preupdate;
+ gchar *where;
TrackerExtractPrivate *priv;
priv = TRACKER_EXTRACT_GET_PRIVATE (object);
@@ -395,7 +409,7 @@ tracker_extract_get_metadata_by_cmdline (TrackerExtract *object,
if (get_file_metadata (object, request,
NULL, uri, mime,
- &preupdate, &statements)) {
+ &preupdate, &statements, &where)) {
const gchar *preupdate_str, *statements_str;
preupdate_str = statements_str = NULL;
@@ -412,9 +426,12 @@ tracker_extract_get_metadata_by_cmdline (TrackerExtract *object,
preupdate_str ? preupdate_str : "");
tracker_dbus_request_info (request, "%s",
statements_str ? statements_str : "");
+ tracker_dbus_request_info (request, "%s",
+ where ? where : "");
g_object_unref (statements);
g_object_unref (preupdate);
+ g_free (where);
}
tracker_dbus_request_end (request, NULL);
@@ -451,6 +468,7 @@ handle_method_call_get_metadata (TrackerExtract *object,
TrackerDBusRequest *request;
TrackerExtractPrivate *priv;
TrackerSparqlBuilder *sparql, *preupdate;
+ gchar *where;
gboolean extracted = FALSE;
const gchar *uri = NULL, *mime = NULL;
@@ -480,7 +498,8 @@ handle_method_call_get_metadata (TrackerExtract *object,
uri,
mime,
&preupdate,
- &sparql);
+ &sparql,
+ &where);
if (extracted) {
tracker_dbus_request_end (request, NULL);
@@ -493,16 +512,18 @@ handle_method_call_get_metadata (TrackerExtract *object,
}
g_dbus_method_invocation_return_value (invocation,
- g_variant_new ("(ss)",
+ g_variant_new ("(sss)",
preupdate_str ? preupdate_str : "",
- tracker_sparql_builder_get_result (sparql)));
+ tracker_sparql_builder_get_result (sparql),
+ where ? where : ""));
} else {
g_dbus_method_invocation_return_value (invocation,
- g_variant_new ("(ss)", "", ""));
+ g_variant_new ("(sss)", "", "", ""));
}
g_object_unref (sparql);
g_object_unref (preupdate);
+ g_free (where);
} else {
GError *actual_error;
@@ -536,6 +557,7 @@ handle_method_call_get_metadata_fast (TrackerExtract *object,
GDataOutputStream *data_output_stream;
GError *error = NULL;
TrackerSparqlBuilder *sparql, *preupdate;
+ gchar *where;
gboolean extracted = FALSE;
GDBusMessage *method_message;
GDBusConnection *connection;
@@ -573,7 +595,7 @@ handle_method_call_get_metadata_fast (TrackerExtract *object,
alarm (MAX_EXTRACT_TIME);
}
- extracted = get_file_metadata (object, request, NULL, uri, mime, &preupdate, &sparql);
+ extracted = get_file_metadata (object, request, NULL, uri, mime, &preupdate, &sparql, &where);
if (extracted) {
unix_output_stream = g_unix_output_stream_new (fd, TRUE);
@@ -615,10 +637,25 @@ handle_method_call_get_metadata_fast (TrackerExtract *object,
NULL,
&error);
}
+
+ if (!error && where) {
+ g_data_output_stream_put_string (data_output_stream,
+ where,
+ NULL,
+ &error);
+ }
+
+ if (!error) {
+ g_data_output_stream_put_byte (data_output_stream,
+ 0,
+ NULL,
+ &error);
+ }
}
g_object_unref (sparql);
g_object_unref (preupdate);
+ g_free (where);
g_object_unref (data_output_stream);
g_object_unref (buffered_output_stream);
g_object_unref (unix_output_stream);
diff --git a/tests/functional-tests/common/utils/helpers.py b/tests/functional-tests/common/utils/helpers.py
index 5c82dfd..2e8d381 100644
--- a/tests/functional-tests/common/utils/helpers.py
+++ b/tests/functional-tests/common/utils/helpers.py
@@ -178,7 +178,7 @@ class ExtractorHelper ():
}
"""
metadata = {}
- preupdate, embedded = self.extractor.GetMetadata (filename, mime)
+ preupdate, embedded, where = self.extractor.GetMetadata (filename, mime)
for attribute_value in self.__process_lines (embedded):
att, value = attribute_value.split (" ", 1)
if metadata.has_key (att):
diff --git a/tests/libtracker-extract/tracker-test-xmp.c b/tests/libtracker-extract/tracker-test-xmp.c
index e46d1fd..8ceb453 100644
--- a/tests/libtracker-extract/tracker-test-xmp.c
+++ b/tests/libtracker-extract/tracker-test-xmp.c
@@ -273,10 +273,12 @@ static void
test_xmp_apply (void)
{
TrackerSparqlBuilder *metadata, *preupdate;
+ GString *where;
TrackerXmpData *data;
metadata = tracker_sparql_builder_new_update ();
preupdate = tracker_sparql_builder_new_update ();
+ where = g_string_new ("");
data = tracker_xmp_new (EXAMPLE_XMP, strlen (EXAMPLE_XMP), "urn:uuid:test");
g_assert (data != NULL);
@@ -284,7 +286,7 @@ test_xmp_apply (void)
tracker_sparql_builder_insert_open (metadata, NULL);
tracker_sparql_builder_subject_iri (metadata, "urn:uuid:test");
- g_assert (tracker_xmp_apply (preupdate, metadata, "urn:uuid:test", data));
+ g_assert (tracker_xmp_apply (preupdate, metadata, where, "urn:uuid:test", data));
tracker_sparql_builder_insert_close (metadata);
@@ -305,6 +307,7 @@ test_xmp_apply_location (void)
{
TrackerXmpData data = { 0, };
TrackerSparqlBuilder *metadata, *preupdate;
+ GString *where;
data.address = g_strdup ("Itamerenkatu 11-13");
data.city = g_strdup ("Helsinki");
@@ -313,11 +316,12 @@ test_xmp_apply_location (void)
metadata = tracker_sparql_builder_new_update ();
preupdate = tracker_sparql_builder_new_update ();
+ where = g_string_new ("");
tracker_sparql_builder_insert_open (metadata, NULL);
tracker_sparql_builder_subject_iri (metadata, "urn:uuid:test");
- g_assert (tracker_xmp_apply (preupdate, metadata, "urn:uuid:test", &data));
+ g_assert (tracker_xmp_apply (preupdate, metadata, where, "urn:uuid:test", &data));
tracker_sparql_builder_insert_close (metadata);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]