[tracker/tracker-0.6] Fixes NB#129094, HasKeywords is wrongly set for an attached image



commit 52525d6a73d865f7d6c466fd2abcbbc8588065b1
Author: Mikael Ottela <mikael ottela ixonos com>
Date:   Tue Sep 8 14:10:30 2009 +0300

    Fixes NB#129094, HasKeywords is wrongly set for an attached image

 src/tracker-extract/tracker-extract-jpeg.c |   35 ++++++++++++++-------------
 src/tracker-extract/tracker-extract-png.c  |   33 ++++++++++++++------------
 src/tracker-extract/tracker-extract-tiff.c |   33 ++++++++++++++------------
 3 files changed, 54 insertions(+), 47 deletions(-)
---
diff --git a/src/tracker-extract/tracker-extract-jpeg.c b/src/tracker-extract/tracker-extract-jpeg.c
index ae7921c..7d0d746 100644
--- a/src/tracker-extract/tracker-extract-jpeg.c
+++ b/src/tracker-extract/tracker-extract-jpeg.c
@@ -37,6 +37,7 @@
 
 #include <libtracker-common/tracker-type-utils.h>
 #include <libtracker-common/tracker-file-utils.h>
+#include <libtracker-common/tracker-utils.h>
 
 #include "tracker-main.h"
 #include "tracker-xmp.h"
@@ -171,22 +172,24 @@ metadata_append (GHashTable  *metadata,
 		g_free (escaped);		
 	} else {
 		new_value = tracker_escape_metadata (value);
-		g_hash_table_insert (metadata, g_strdup (key), new_value);
-
-		/* FIXME Postprocessing is evil and should be elsewhere */
-		if (strcmp (key, "Image:Keywords") == 0) {
-			g_hash_table_insert (metadata,
-					     g_strdup ("Image:HasKeywords"),
-					     tracker_escape_metadata ("1"));			
-		}		
-	}
+		if (!tracker_is_empty_string (new_value)) {
+			g_hash_table_insert (metadata, g_strdup (key), new_value);
 
-	/* Adding certain fields also to HasKeywords FIXME Postprocessing is evil */
-	if ((strcmp (key, "Image:Title") == 0) ||
-	    (strcmp (key, "Image:Description") == 0) ) {
-		g_hash_table_insert (metadata,
-				     g_strdup ("Image:HasKeywords"),
-				     tracker_escape_metadata ("1"));
+			/* FIXME Postprocessing is evil and should be elsewhere */
+			if (strcmp (key, "Image:Keywords") == 0) {
+				g_hash_table_insert (metadata,
+						     g_strdup ("Image:HasKeywords"),
+						     tracker_escape_metadata ("1"));			
+			}
+			
+			/* Adding certain fields also to HasKeywords FIXME Postprocessing is evil */
+			if ((strcmp (key, "Image:Title") == 0) ||
+			    (strcmp (key, "Image:Description") == 0) ) {
+				g_hash_table_insert (metadata,
+						     g_strdup ("Image:HasKeywords"),
+						     tracker_escape_metadata ("1"));
+			}
+		}
 	}
 }
 
@@ -486,8 +489,6 @@ fail:
 				     tracker_escape_metadata (date));
 		g_free (date);
 	}
-
-	g_debug ("Date: %s", (char *)g_hash_table_lookup (metadata, "Image:Date"));
 }
 
 TrackerExtractData *
diff --git a/src/tracker-extract/tracker-extract-png.c b/src/tracker-extract/tracker-extract-png.c
index 38082e0..980c8e6 100644
--- a/src/tracker-extract/tracker-extract-png.c
+++ b/src/tracker-extract/tracker-extract-png.c
@@ -39,6 +39,7 @@
 
 #include <libtracker-common/tracker-type-utils.h>
 #include <libtracker-common/tracker-file-utils.h>
+#include <libtracker-common/tracker-utils.h>
 
 #include "tracker-main.h"
 #include "tracker-xmp.h"
@@ -120,22 +121,24 @@ metadata_append (GHashTable *metadata, gchar *key, gchar *value, gboolean append
 		g_free (escaped);		
 	} else {
 		new_value = tracker_escape_metadata (value);
-		g_hash_table_insert (metadata, g_strdup (key), new_value);
-
-		/* FIXME Postprocessing is evil and should be elsewhere */
-		if (strcmp (key, "Image:Keywords") == 0) {
-			g_hash_table_insert (metadata,
-					     g_strdup ("Image:HasKeywords"),
-					     tracker_escape_metadata ("1"));			
-		}		
-	}
+		if (!tracker_is_empty_string (new_value)) {
+			g_hash_table_insert (metadata, g_strdup (key), new_value);
 
-	/* Adding certain fields also to keywords FIXME Postprocessing is evil */
-	if ((strcmp (key, "Image:Title") == 0) ||
-	    (strcmp (key, "Image:Description") == 0) ) {
-		g_hash_table_insert (metadata,
-				     g_strdup ("Image:HasKeywords"),
-				     tracker_escape_metadata ("1"));
+			/* FIXME Postprocessing is evil and should be elsewhere */
+			if (strcmp (key, "Image:Keywords") == 0) {
+				g_hash_table_insert (metadata,
+						     g_strdup ("Image:HasKeywords"),
+						     tracker_escape_metadata ("1"));			
+			}
+			
+			/* Adding certain fields also to HasKeywords FIXME Postprocessing is evil */
+			if ((strcmp (key, "Image:Title") == 0) ||
+			    (strcmp (key, "Image:Description") == 0) ) {
+				g_hash_table_insert (metadata,
+						     g_strdup ("Image:HasKeywords"),
+						     tracker_escape_metadata ("1"));
+			}
+		}
 	}
 }
 
diff --git a/src/tracker-extract/tracker-extract-tiff.c b/src/tracker-extract/tracker-extract-tiff.c
index 1768369..97a7ac4 100644
--- a/src/tracker-extract/tracker-extract-tiff.c
+++ b/src/tracker-extract/tracker-extract-tiff.c
@@ -30,6 +30,7 @@
 
 #include <libtracker-common/tracker-type-utils.h>
 #include <libtracker-common/tracker-file-utils.h>
+#include <libtracker-common/tracker-utils.h>
 
 #include "tracker-main.h"
 #include "tracker-xmp.h"
@@ -141,22 +142,24 @@ metadata_append (GHashTable *metadata, gchar *key, gchar *value, gboolean append
 		g_free (escaped);		
 	} else {
 		new_value = tracker_escape_metadata (value);
-		g_hash_table_insert (metadata, g_strdup (key), new_value);
-
-		/* FIXME Postprocessing is evil and should be elsewhere */
-		if (strcmp (key, "Image:Keywords") == 0) {
-			g_hash_table_insert (metadata,
-					     g_strdup ("Image:HasKeywords"),
-					     tracker_escape_metadata ("1"));			
-		}		
-	}
+		if (!tracker_is_empty_string (new_value)) {
+			g_hash_table_insert (metadata, g_strdup (key), new_value);
 
-	/* Adding certain fields also to keywords FIXME Postprocessing is evil */
-	if ((strcmp (key, "Image:Title") == 0) ||
-	    (strcmp (key, "Image:Description") == 0) ) {
-		g_hash_table_insert (metadata,
-				     g_strdup ("Image:HasKeywords"),
-				     tracker_escape_metadata ("1"));
+			/* FIXME Postprocessing is evil and should be elsewhere */
+			if (strcmp (key, "Image:Keywords") == 0) {
+				g_hash_table_insert (metadata,
+						     g_strdup ("Image:HasKeywords"),
+						     tracker_escape_metadata ("1"));			
+			}
+			
+			/* Adding certain fields also to HasKeywords FIXME Postprocessing is evil */
+			if ((strcmp (key, "Image:Title") == 0) ||
+			    (strcmp (key, "Image:Description") == 0) ) {
+				g_hash_table_insert (metadata,
+						     g_strdup ("Image:HasKeywords"),
+						     tracker_escape_metadata ("1"));
+			}
+		}
 	}
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]