[tracker] tracker-extract-png: Fix guaranteed metadata
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker] tracker-extract-png: Fix guaranteed metadata
- Date: Mon, 31 Jan 2011 10:30:49 +0000 (UTC)
commit 6fa6ad3f64bab81808a62229c66e8c7cdd593b88
Author: Jürg Billeter <j bitron ch>
Date: Mon Jan 31 11:20:09 2011 +0100
tracker-extract-png: Fix guaranteed metadata
Fixes NB#223282.
src/tracker-extract/tracker-extract-png.c | 151 ++++++++++++-----------
tests/functional-tests/501-writeback-details.py | 2 -
tests/functional-tests/Makefile.am | 1 +
3 files changed, 80 insertions(+), 74 deletions(-)
---
diff --git a/src/tracker-extract/tracker-extract-png.c b/src/tracker-extract/tracker-extract-png.c
index 5684cbc..f183e89 100644
--- a/src/tracker-extract/tracker-extract-png.c
+++ b/src/tracker-extract/tracker-extract-png.c
@@ -93,93 +93,101 @@ read_metadata (TrackerSparqlBuilder *preupdate,
TrackerSparqlBuilder *metadata,
png_structp png_ptr,
png_infop info_ptr,
+ png_infop end_ptr,
const gchar *uri)
{
MergeData md = { 0 };
PngData pd = { 0 };
TrackerExifData *ed = NULL;
TrackerXmpData *xd = NULL;
+ png_infop info_ptrs[2];
png_textp text_ptr;
+ gint info_index;
gint num_text;
gint i;
gint found;
GPtrArray *keywords;
- if ((found = png_get_text (png_ptr, info_ptr, &text_ptr, &num_text)) < 1) {
- g_debug ("Calling png_get_text() returned %d (< 1)", found);
- return;
- }
+ info_ptrs[0] = info_ptr;
+ info_ptrs[1] = end_ptr;
- for (i = 0; i < num_text; i++) {
- if (!text_ptr[i].key || !text_ptr[i].text || text_ptr[i].text[0] == '\0') {
+ for (info_index = 0; info_index < 2; info_index++) {
+ if ((found = png_get_text (png_ptr, info_ptrs[info_index], &text_ptr, &num_text)) < 1) {
+ g_debug ("Calling png_get_text() returned %d (< 1)", found);
continue;
}
+
+ for (i = 0; i < num_text; i++) {
+ if (!text_ptr[i].key || !text_ptr[i].text || text_ptr[i].text[0] == '\0') {
+ continue;
+ }
-#if defined(HAVE_EXEMPI) && defined(PNG_iTXt_SUPPORTED)
- if (g_strcmp0 ("XML:com.adobe.xmp", text_ptr[i].key) == 0) {
- /* ATM tracker_extract_xmp_read supports setting xd
- * multiple times, keep it that way as here it's
- * theoretically possible that the function gets
- * called multiple times
+ #if defined(HAVE_EXEMPI) && defined(PNG_iTXt_SUPPORTED)
+ if (g_strcmp0 ("XML:com.adobe.xmp", text_ptr[i].key) == 0) {
+ /* ATM tracker_extract_xmp_read supports setting xd
+ * multiple times, keep it that way as here it's
+ * theoretically possible that the function gets
+ * called multiple times
+ */
+ xd = tracker_xmp_new (text_ptr[i].text,
+ text_ptr[i].itxt_length,
+ uri);
+ continue;
+ }
+ #endif
+
+ #if defined(HAVE_LIBEXIF) && defined(PNG_iTXt_SUPPORTED)
+ /* I'm not certain this is the key for EXIF. Using key according to
+ * this document about exiftool:
+ * http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/PNG.html#TextualData
*/
- xd = tracker_xmp_new (text_ptr[i].text,
- text_ptr[i].itxt_length,
- uri);
- continue;
- }
-#endif
-
-#if defined(HAVE_LIBEXIF) && defined(PNG_iTXt_SUPPORTED)
- /* I'm not certain this is the key for EXIF. Using key according to
- * this document about exiftool:
- * http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/PNG.html#TextualData
- */
- if (g_strcmp0 ("Raw profile type exif", text_ptr[i].key) == 0) {
- ed = tracker_exif_new (text_ptr[i].text,
- text_ptr[i].itxt_length,
- uri);
- continue;
- }
-#endif /* HAVE_LIBEXIF */
-
- if (g_strcmp0 (text_ptr[i].key, "Author") == 0) {
- pd.author = text_ptr[i].text;
- continue;
- }
-
- if (g_strcmp0 (text_ptr[i].key, "Creator") == 0) {
- pd.creator = text_ptr[i].text;
- continue;
- }
-
- if (g_strcmp0 (text_ptr[i].key, "Description") == 0) {
- pd.description = text_ptr[i].text;
- continue;
- }
-
- if (g_strcmp0 (text_ptr[i].key, "Comment") == 0) {
- pd.comment = text_ptr[i].text;
- continue;
- }
-
- if (g_strcmp0 (text_ptr[i].key, "Copyright") == 0) {
- pd.copyright = text_ptr[i].text;
- continue;
- }
-
- if (g_strcmp0 (text_ptr[i].key, "Creation Time") == 0) {
- pd.creation_time = rfc1123_to_iso8601_date (text_ptr[i].text);
- continue;
- }
-
- if (g_strcmp0 (text_ptr[i].key, "Title") == 0) {
- pd.title = text_ptr[i].text;
- continue;
- }
-
- if (g_strcmp0 (text_ptr[i].key, "Disclaimer") == 0) {
- pd.disclaimer = text_ptr[i].text;
- continue;
+ if (g_strcmp0 ("Raw profile type exif", text_ptr[i].key) == 0) {
+ ed = tracker_exif_new (text_ptr[i].text,
+ text_ptr[i].itxt_length,
+ uri);
+ continue;
+ }
+ #endif /* HAVE_LIBEXIF */
+
+ if (g_strcmp0 (text_ptr[i].key, "Author") == 0) {
+ pd.author = text_ptr[i].text;
+ continue;
+ }
+
+ if (g_strcmp0 (text_ptr[i].key, "Creator") == 0) {
+ pd.creator = text_ptr[i].text;
+ continue;
+ }
+
+ if (g_strcmp0 (text_ptr[i].key, "Description") == 0) {
+ pd.description = text_ptr[i].text;
+ continue;
+ }
+
+ if (g_strcmp0 (text_ptr[i].key, "Comment") == 0) {
+ pd.comment = text_ptr[i].text;
+ continue;
+ }
+
+ if (g_strcmp0 (text_ptr[i].key, "Copyright") == 0) {
+ pd.copyright = text_ptr[i].text;
+ continue;
+ }
+
+ if (g_strcmp0 (text_ptr[i].key, "Creation Time") == 0) {
+ pd.creation_time = rfc1123_to_iso8601_date (text_ptr[i].text);
+ continue;
+ }
+
+ if (g_strcmp0 (text_ptr[i].key, "Title") == 0) {
+ pd.title = text_ptr[i].text;
+ continue;
+ }
+
+ if (g_strcmp0 (text_ptr[i].key, "Disclaimer") == 0) {
+ pd.disclaimer = text_ptr[i].text;
+ continue;
+ }
}
}
@@ -598,8 +606,7 @@ extract_png (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, uri);
- read_metadata (preupdate, metadata, png_ptr, end_ptr, uri);
+ read_metadata (preupdate, metadata, png_ptr, info_ptr, end_ptr, uri);
tracker_sparql_builder_predicate (metadata, "nfo:width");
tracker_sparql_builder_object_int64 (metadata, width);
diff --git a/tests/functional-tests/501-writeback-details.py b/tests/functional-tests/501-writeback-details.py
index 329234a..0393e0b 100755
--- a/tests/functional-tests/501-writeback-details.py
+++ b/tests/functional-tests/501-writeback-details.py
@@ -34,7 +34,6 @@ class WritebackKeepDateTest (CommonTrackerWritebackTest):
pass
- @expectedFailureBug ("NB#2232382")
def test_01_NB217627_content_created_date (self):
"""
NB#217627 - Order if results is different when an image is marked as favorite.
@@ -48,7 +47,6 @@ class WritebackKeepDateTest (CommonTrackerWritebackTest):
results = self.tracker.query (query_images)
results_unpacked = [ r[1] for r in results ]
print results_unpacked
- # This assertion fail due bug#223282
self.assertEquals ( len (results), 3, results_unpacked)
# This triggers the writeback
diff --git a/tests/functional-tests/Makefile.am b/tests/functional-tests/Makefile.am
index 5a6a562..f9b0924 100644
--- a/tests/functional-tests/Makefile.am
+++ b/tests/functional-tests/Makefile.am
@@ -49,6 +49,7 @@ endif
standard_tests += \
400-extractor.py \
500-writeback.py \
+ 501-writeback-details.py \
600-applications-camera.py \
601-applications-sync.py \
mass-storage-mode.py \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]