[tracker/urn-in-extractor: 2/3] libtracker-extract: Add tracker_extract_get_urn().
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/urn-in-extractor: 2/3] libtracker-extract: Add tracker_extract_get_urn().
- Date: Wed, 24 Feb 2010 10:10:36 +0000 (UTC)
commit 5f79c9b7768b6f30b4b9cc03184f4fe3b80e8187
Author: Carlos Garnacho <carlos lanedo com>
Date: Wed Feb 24 11:05:00 2010 +0100
libtracker-extract: Add tracker_extract_get_urn().
This is a helper function so extractor implementations may know
the item URN if there is any at the moment of metadata extraction,
else NULL will be returned.
src/libtracker-extract/tracker-extract.h | 11 +++++++++++
src/tracker-extract/tracker-extract.c | 21 +++++++++++++++++++++
2 files changed, 32 insertions(+), 0 deletions(-)
---
diff --git a/src/libtracker-extract/tracker-extract.h b/src/libtracker-extract/tracker-extract.h
index 88eece1..fcfc062 100644
--- a/src/libtracker-extract/tracker-extract.h
+++ b/src/libtracker-extract/tracker-extract.h
@@ -175,6 +175,17 @@ typedef TrackerExtractData * (*TrackerExtractDataFunc) (void);
*/
TrackerExtractData *tracker_extract_get_data (void);
+/**
+ * tracker_extract_get_urn:
+ *
+ * Returns the URN for the element being inspected, or %NULL if none.
+ *
+ * Returns: The element URN or %NULL. This string is owned by
+ * tracker-extract and must not be freed.
+ */
+G_CONST_RETURN gchar * tracker_extract_get_urn (void);
+
G_END_DECLS
#endif /* __LIBTRACKER_EXTRACT_EXTRACT_H__ */
+
diff --git a/src/tracker-extract/tracker-extract.c b/src/tracker-extract/tracker-extract.c
index 2304794..43467db 100644
--- a/src/tracker-extract/tracker-extract.c
+++ b/src/tracker-extract/tracker-extract.c
@@ -48,6 +48,7 @@
#define TRACKER_EXTRACT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TRACKER_TYPE_EXTRACT, TrackerExtractPrivate))
extern gboolean debug;
+static gchar *current_item_urn = NULL;
typedef struct {
GArray *specific_extractors;
@@ -214,6 +215,25 @@ tracker_extract_new (gboolean disable_shutdown,
return object;
}
+static void
+_tracker_extract_set_urn (const gchar *new_urn)
+{
+ if (current_item_urn) {
+ g_free (current_item_urn);
+ current_item_urn = NULL;
+ }
+
+ if (new_urn && *new_urn) {
+ current_item_urn = g_strdup (new_urn);
+ }
+}
+
+G_CONST_RETURN gchar *
+tracker_extract_get_urn (void)
+{
+ return current_item_urn;
+}
+
static gboolean
get_file_metadata (TrackerExtract *extract,
guint request_id,
@@ -527,6 +547,7 @@ tracker_extract_get_metadata (TrackerExtract *object,
alarm (MAX_EXTRACT_TIME);
}
+ _tracker_extract_set_urn (urn);
extracted = get_file_metadata (object, request_id, context, uri, mime, &preupdate, &sparql);
if (extracted) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]