[tracker/writeback-miner-interaction] tracker-writeback: Use get_value_type instead of is_blank



commit 49bd60144ee84994c5dc4f296ee61eba0ff893cc
Author: Philip Van Hoof <philip codeminded be>
Date:   Fri Jun 10 15:35:12 2011 +0200

    tracker-writeback: Use get_value_type instead of is_blank

 src/tracker-writeback/tracker-writeback-xmp.c |   53 +++++++++++++++++-------
 1 files changed, 37 insertions(+), 16 deletions(-)
---
diff --git a/src/tracker-writeback/tracker-writeback-xmp.c b/src/tracker-writeback/tracker-writeback-xmp.c
index a8dfd98..e7aaacc 100644
--- a/src/tracker-writeback/tracker-writeback-xmp.c
+++ b/src/tracker-writeback/tracker-writeback-xmp.c
@@ -414,16 +414,37 @@ writeback_xmp_update_file_metadata (TrackerWritebackFile    *wbf,
 		g_free (query);
 		if (!error) {
 			if (tracker_sparql_cursor_next (cursor, NULL, NULL)) {
-				const gchar *city, *subl, *country, *state;
-				const gchar *altitude, *longitude, *latitude;
+				const gchar *city = NULL, *subl = NULL, *country = NULL,
+				            *state = NULL, *altitude = NULL, *longitude = NULL,
+				            *latitude = NULL;
 
-				city = tracker_sparql_cursor_get_string (cursor, 0, NULL);
-				state = tracker_sparql_cursor_get_string (cursor, 1, NULL);
-				subl = tracker_sparql_cursor_get_string (cursor, 2, NULL);
-				country = tracker_sparql_cursor_get_string (cursor, 3, NULL);
-				altitude = tracker_sparql_cursor_get_string (cursor, 4, NULL);
-				longitude = tracker_sparql_cursor_get_string (cursor, 5, NULL);
-				latitude = tracker_sparql_cursor_get_string (cursor, 6, NULL);
+				if (tracker_sparql_cursor_get_value_type (cursor, 0) != TRACKER_SPARQL_VALUE_TYPE_UNBOUND) {
+					city = tracker_sparql_cursor_get_string (cursor, 0, NULL);
+				}
+
+				if (tracker_sparql_cursor_get_value_type (cursor, 1) != TRACKER_SPARQL_VALUE_TYPE_UNBOUND) {
+					state = tracker_sparql_cursor_get_string (cursor, 1, NULL);
+				}
+
+				if (tracker_sparql_cursor_get_value_type (cursor, 2) != TRACKER_SPARQL_VALUE_TYPE_UNBOUND) {
+					subl = tracker_sparql_cursor_get_string (cursor, 2, NULL);
+				}
+
+				if (tracker_sparql_cursor_get_value_type (cursor, 3) != TRACKER_SPARQL_VALUE_TYPE_UNBOUND) {
+					country = tracker_sparql_cursor_get_string (cursor, 3, NULL);
+				}
+
+				if (tracker_sparql_cursor_get_value_type (cursor, 4) != TRACKER_SPARQL_VALUE_TYPE_UNBOUND) {
+					altitude = tracker_sparql_cursor_get_string (cursor, 4, NULL);
+				}
+
+				if (tracker_sparql_cursor_get_value_type (cursor, 5) != TRACKER_SPARQL_VALUE_TYPE_UNBOUND) {
+					longitude = tracker_sparql_cursor_get_string (cursor, 5, NULL);
+				}
+				
+				if (tracker_sparql_cursor_get_value_type (cursor, 6) != TRACKER_SPARQL_VALUE_TYPE_UNBOUND) {
+					latitude = tracker_sparql_cursor_get_string (cursor, 6, NULL);
+				}
 
 				/* TODO: A lot of these location fields are pretty vague and ambigious.
 				 * We should go through them one by one and ensure that all of them are
@@ -431,7 +452,7 @@ writeback_xmp_update_file_metadata (TrackerWritebackFile    *wbf,
 
 				xmp_delete_property (xmp, NS_IPTC4XMP, "City");
 				xmp_delete_property (xmp, NS_PHOTOSHOP, "City");
-				if (!tracker_is_blank_string (city)) {
+				if (city != NULL) {
 					xmp_set_property (xmp, NS_IPTC4XMP, "City", city, 0);
 					xmp_set_property (xmp, NS_PHOTOSHOP, "City", city, 0);
 				}
@@ -439,7 +460,7 @@ writeback_xmp_update_file_metadata (TrackerWritebackFile    *wbf,
 				xmp_delete_property (xmp, NS_IPTC4XMP, "State");
 				xmp_delete_property (xmp, NS_IPTC4XMP, "Province");
 				xmp_delete_property (xmp, NS_PHOTOSHOP, "State");
-				if (!tracker_is_blank_string (state)) {
+				if (state != NULL) {
 					xmp_set_property (xmp, NS_IPTC4XMP, "State", state, 0);
 					xmp_set_property (xmp, NS_IPTC4XMP, "Province", state, 0);
 					xmp_set_property (xmp, NS_PHOTOSHOP, "State", state, 0);
@@ -447,7 +468,7 @@ writeback_xmp_update_file_metadata (TrackerWritebackFile    *wbf,
 
 				xmp_delete_property (xmp, NS_IPTC4XMP, "SubLocation");
 				xmp_delete_property (xmp, NS_PHOTOSHOP, "Location");
-				if (!tracker_is_blank_string (subl)) {
+				if (subl != NULL) {
 					xmp_set_property (xmp, NS_IPTC4XMP, "SubLocation", subl, 0);
 					xmp_set_property (xmp, NS_PHOTOSHOP, "Location", subl, 0);
 				}
@@ -456,7 +477,7 @@ writeback_xmp_update_file_metadata (TrackerWritebackFile    *wbf,
 				xmp_delete_property (xmp, NS_IPTC4XMP, "Country");
 				xmp_delete_property (xmp, NS_IPTC4XMP, "PrimaryLocationName");
 				xmp_delete_property (xmp, NS_IPTC4XMP, "CountryName");
-				if (!tracker_is_blank_string (country)) {
+				if (country != NULL) {
 					xmp_set_property (xmp, NS_PHOTOSHOP, "Country", country, 0);
 					xmp_set_property (xmp, NS_IPTC4XMP, "Country", country, 0);
 					xmp_set_property (xmp, NS_IPTC4XMP, "PrimaryLocationName", country, 0);
@@ -464,17 +485,17 @@ writeback_xmp_update_file_metadata (TrackerWritebackFile    *wbf,
 				}
 
 				xmp_delete_property (xmp, NS_EXIF, "GPSAltitude");
-				if (!tracker_is_blank_string (altitude)) {
+				if (altitude != NULL) {
 					xmp_set_property (xmp, NS_EXIF, "GPSAltitude", altitude, 0);
 				}
 
 				xmp_delete_property (xmp, NS_EXIF, "GPSLongitude");
-				if (!tracker_is_blank_string (longitude)) {
+				if (longitude != NULL) {
 					xmp_set_property (xmp, NS_EXIF, "GPSLongitude", longitude, 0);
 				}
 
 				xmp_delete_property (xmp, NS_EXIF, "GPSLatitude");
-				if (!tracker_is_blank_string (latitude)) {
+				if (latitude != NULL) {
 					xmp_set_property (xmp, NS_EXIF, "GPSLatitude", latitude, 0);
 				}
 			}



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