tracker r2532 - in trunk: . src/libtracker-common src/tracker-extract



Author: mr
Date: Thu Nov 20 12:27:58 2008
New Revision: 2532
URL: http://svn.gnome.org/viewvc/tracker?rev=2532&view=rev

Log:
	* src/libtracker-common/tracker-type-utils.[ch]: 
	* src/tracker-extract/tracker-extract.[ch]: 
	* src/tracker-extract/tracker-extract-mp3.c: 
	* src/tracker-extract/tracker-extract-gstreamer.c: Revert changes
	that removed "tracker:unknown" when we didn't know the metadata
	value for some fields. Now we have METADATA_UNKNOWN defined in
	tracker-extract.h so we can be consistent everywhere with this.
	Moved tracker_generic_date_to_iso8601() here from
	tracker-extract.c since it is so common.

	* src/tracker-extract/tracker-extract-exif.c: Code clean up and
	remark that this module is not used.

	* src/tracker-extract/tracker-extract-imagemagick.c:
	* src/tracker-extract/tracker-extract-jpeg.c:
	* src/tracker-extract/tracker-extract-ps.c: 
	* src/tracker-extract/tracker-extract-tiff.c: Code clean up and
	used the new date function in tracker-type-utils.

	* src/tracker-extract/tracker-extract-png.c: Fixed a warning and
	used the new date function in tracker-type-utils.


Modified:
   trunk/ChangeLog
   trunk/src/libtracker-common/tracker-type-utils.c
   trunk/src/libtracker-common/tracker-type-utils.h
   trunk/src/tracker-extract/tracker-extract-exif.c
   trunk/src/tracker-extract/tracker-extract-gstreamer.c
   trunk/src/tracker-extract/tracker-extract-imagemagick.c
   trunk/src/tracker-extract/tracker-extract-jpeg.c
   trunk/src/tracker-extract/tracker-extract-mp3.c
   trunk/src/tracker-extract/tracker-extract-png.c
   trunk/src/tracker-extract/tracker-extract-ps.c
   trunk/src/tracker-extract/tracker-extract-tiff.c
   trunk/src/tracker-extract/tracker-extract.c
   trunk/src/tracker-extract/tracker-extract.h

Modified: trunk/src/libtracker-common/tracker-type-utils.c
==============================================================================
--- trunk/src/libtracker-common/tracker-type-utils.c	(original)
+++ trunk/src/libtracker-common/tracker-type-utils.c	Thu Nov 20 12:27:58 2008
@@ -28,6 +28,8 @@
 #include "tracker-utils.h"
 #include "tracker-type-utils.h"
 
+#define DATE_FORMAT_ISO8601 "%Y-%m-%dT%H:%M:%S%z"
+
 static const char *months[] = {
 	"Jan", "Feb", "Mar", "Apr", "May", "Jun",
 	"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
@@ -74,16 +76,16 @@
 
 /* Determine date format and convert to ISO 8601 format */
 gchar *
-tracker_date_format (const gchar *timestamp)
+tracker_date_format (const gchar *date_string)
 {
 	gchar buf[30];
 	gint  len;
 
-	if (!timestamp) {
+	if (!date_string) {
 		return NULL;
 	}
 
-	len = strlen (timestamp);
+	len = strlen (date_string);
 
 	/* We cannot format a date without at least a four digit
 	 * year.
@@ -96,11 +98,11 @@
 	 * Audio.ReleaseDate as 4 digit year)
 	 */
 	if (len == 4) {
-		if (is_int (timestamp)) {
-			buf[0] = timestamp[0];
-			buf[1] = timestamp[1];
-			buf[2] = timestamp[2];
-			buf[3] = timestamp[3];
+		if (is_int (date_string)) {
+			buf[0] = date_string[0];
+			buf[1] = date_string[1];
+			buf[2] = date_string[2];
+			buf[3] = date_string[3];
 			buf[4] = '-';
 			buf[5] = '0';
 			buf[6] = '1';
@@ -124,16 +126,16 @@
 		}
 	} else if (len == 10)  {
 		/* Check for date part only YYYY-MM-DD*/
-		buf[0] = timestamp[0];
-		buf[1] = timestamp[1];
-		buf[2] = timestamp[2];
-		buf[3] = timestamp[3];
+		buf[0] = date_string[0];
+		buf[1] = date_string[1];
+		buf[2] = date_string[2];
+		buf[3] = date_string[3];
 		buf[4] = '-';
-		buf[5] = timestamp[5];
-		buf[6] = timestamp[6];
+		buf[5] = date_string[5];
+		buf[6] = date_string[6];
 		buf[7] = '-';
-		buf[8] = timestamp[8];
-		buf[9] = timestamp[9];
+		buf[8] = date_string[8];
+		buf[9] = date_string[9];
 		buf[10] = 'T';
 		buf[11] = '0';
 		buf[12] = '0';
@@ -150,101 +152,101 @@
 		/* Check for pdf format EG 20050315113224-08'00' or
 		 * 20050216111533Z
 		 */
-		buf[0] = timestamp[0];
-		buf[1] = timestamp[1];
-		buf[2] = timestamp[2];
-		buf[3] = timestamp[3];
+		buf[0] = date_string[0];
+		buf[1] = date_string[1];
+		buf[2] = date_string[2];
+		buf[3] = date_string[3];
 		buf[4] = '-';
-		buf[5] = timestamp[4];
-		buf[6] = timestamp[5];
+		buf[5] = date_string[4];
+		buf[6] = date_string[5];
 		buf[7] = '-';
-		buf[8] = timestamp[6];
-		buf[9] = timestamp[7];
+		buf[8] = date_string[6];
+		buf[9] = date_string[7];
 		buf[10] = 'T';
-		buf[11] = timestamp[8];
-		buf[12] = timestamp[9];
+		buf[11] = date_string[8];
+		buf[12] = date_string[9];
 		buf[13] = ':';
-		buf[14] = timestamp[10];
-		buf[15] = timestamp[11];
+		buf[14] = date_string[10];
+		buf[15] = date_string[11];
 		buf[16] = ':';
-		buf[17] = timestamp[12];
-		buf[18] = timestamp[13];
+		buf[17] = date_string[12];
+		buf[18] = date_string[13];
 		buf[19] = '\0';
 
 		return g_strdup (buf);
-	} else if (len == 15 && timestamp[14] == 'Z') {
-		buf[0] = timestamp[0];
-		buf[1] = timestamp[1];
-		buf[2] = timestamp[2];
-		buf[3] = timestamp[3];
+	} else if (len == 15 && date_string[14] == 'Z') {
+		buf[0] = date_string[0];
+		buf[1] = date_string[1];
+		buf[2] = date_string[2];
+		buf[3] = date_string[3];
 		buf[4] = '-';
-		buf[5] = timestamp[4];
-		buf[6] = timestamp[5];
+		buf[5] = date_string[4];
+		buf[6] = date_string[5];
 		buf[7] = '-';
-		buf[8] = timestamp[6];
-		buf[9] = timestamp[7];
+		buf[8] = date_string[6];
+		buf[9] = date_string[7];
 		buf[10] = 'T';
-		buf[11] = timestamp[8];
-		buf[12] = timestamp[9];
+		buf[11] = date_string[8];
+		buf[12] = date_string[9];
 		buf[13] = ':';
-		buf[14] = timestamp[10];
-		buf[15] = timestamp[11];
+		buf[14] = date_string[10];
+		buf[15] = date_string[11];
 		buf[16] = ':';
-		buf[17] = timestamp[12];
-		buf[18] = timestamp[13];
+		buf[17] = date_string[12];
+		buf[18] = date_string[13];
 		buf[19] = 'Z';
 		buf[20] = '\0';
 
 		return g_strdup (buf);
-	} else if (len == 21 && (timestamp[14] == '-' || timestamp[14] == '+' )) {
-		buf[0] = timestamp[0];
-		buf[1] = timestamp[1];
-		buf[2] = timestamp[2];
-		buf[3] = timestamp[3];
+	} else if (len == 21 && (date_string[14] == '-' || date_string[14] == '+' )) {
+		buf[0] = date_string[0];
+		buf[1] = date_string[1];
+		buf[2] = date_string[2];
+		buf[3] = date_string[3];
 		buf[4] = '-';
-		buf[5] = timestamp[4];
-		buf[6] = timestamp[5];
+		buf[5] = date_string[4];
+		buf[6] = date_string[5];
 		buf[7] = '-';
-		buf[8] = timestamp[6];
-		buf[9] = timestamp[7];
+		buf[8] = date_string[6];
+		buf[9] = date_string[7];
 		buf[10] = 'T';
-		buf[11] = timestamp[8];
-		buf[12] = timestamp[9];
+		buf[11] = date_string[8];
+		buf[12] = date_string[9];
 		buf[13] = ':';
-		buf[14] = timestamp[10];
-		buf[15] = timestamp[11];
+		buf[14] = date_string[10];
+		buf[15] = date_string[11];
 		buf[16] = ':';
-		buf[17] = timestamp[12];
-		buf[18] = timestamp[13];
-		buf[19] = timestamp[14];
-		buf[20] = timestamp[15];
-		buf[21] =  timestamp[16];
+		buf[17] = date_string[12];
+		buf[18] = date_string[13];
+		buf[19] = date_string[14];
+		buf[20] = date_string[15];
+		buf[21] = date_string[16];
 		buf[22] =  ':';
-		buf[23] =  timestamp[18];
-		buf[24] = timestamp[19];
+		buf[23] = date_string[18];
+		buf[24] = date_string[19];
 		buf[25] = '\0';
 
 		return g_strdup (buf);
-	} else if ((len == 24) && (timestamp[3] == ' ')) {
+	} else if ((len == 24) && (date_string[3] == ' ')) {
 		/* Check for msoffice date format "Mon Feb  9 10:10:00 2004" */
 		gint  num_month;
 		gchar mon1;
 		gchar day1;
 
-		num_month = parse_month (timestamp + 4);
+		num_month = parse_month (date_string + 4);
 
 		mon1 = imonths[num_month];
 
-		if (timestamp[8] == ' ') {
+		if (date_string[8] == ' ') {
 			day1 = '0';
 		} else {
-			day1 = timestamp[8];
+			day1 = date_string[8];
 		}
 
-		buf[0] = timestamp[20];
-		buf[1] = timestamp[21];
-		buf[2] = timestamp[22];
-		buf[3] = timestamp[23];
+		buf[0] = date_string[20];
+		buf[1] = date_string[21];
+		buf[2] = date_string[22];
+		buf[3] = date_string[23];
 		buf[4] = '-';
 
 		if (num_month < 10) {
@@ -257,63 +259,86 @@
 
 		buf[7] = '-';
 		buf[8] = day1;
-		buf[9] = timestamp[9];
+		buf[9] = date_string[9];
 		buf[10] = 'T';
-		buf[11] = timestamp[11];
-		buf[12] = timestamp[12];
+		buf[11] = date_string[11];
+		buf[12] = date_string[12];
 		buf[13] = ':';
-		buf[14] = timestamp[14];
-		buf[15] = timestamp[15];
+		buf[14] = date_string[14];
+		buf[15] = date_string[15];
 		buf[16] = ':';
-		buf[17] = timestamp[17];
-		buf[18] = timestamp[18];
+		buf[17] = date_string[17];
+		buf[18] = date_string[18];
 		buf[19] = '\0';
 
 		return g_strdup (buf);
-	} else if ((len == 19) && (timestamp[4] == ':') && (timestamp[7] == ':')) {
+	} else if ((len == 19) && (date_string[4] == ':') && (date_string[7] == ':')) {
 		/* Check for Exif date format "2005:04:29 14:56:54" */
-		buf[0] = timestamp[0];
-		buf[1] = timestamp[1];
-		buf[2] = timestamp[2];
-		buf[3] = timestamp[3];
+		buf[0] = date_string[0];
+		buf[1] = date_string[1];
+		buf[2] = date_string[2];
+		buf[3] = date_string[3];
 		buf[4] = '-';
-		buf[5] = timestamp[5];
-		buf[6] = timestamp[6];
+		buf[5] = date_string[5];
+		buf[6] = date_string[6];
 		buf[7] = '-';
-		buf[8] = timestamp[8];
-		buf[9] = timestamp[9];
+		buf[8] = date_string[8];
+		buf[9] = date_string[9];
 		buf[10] = 'T';
-		buf[11] = timestamp[11];
-		buf[12] = timestamp[12];
+		buf[11] = date_string[11];
+		buf[12] = date_string[12];
 		buf[13] = ':';
-		buf[14] = timestamp[14];
-		buf[15] = timestamp[15];
+		buf[14] = date_string[14];
+		buf[15] = date_string[15];
 		buf[16] = ':';
-		buf[17] = timestamp[17];
-		buf[18] = timestamp[18];
+		buf[17] = date_string[17];
+		buf[18] = date_string[18];
 		buf[19] = '\0';
 
 		return g_strdup (buf);
 	}
 
-	return g_strdup (timestamp);
+	return g_strdup (date_string);
+}
+
+gchar *
+tracker_date_format_to_iso8601 (const gchar *date_string,
+				const gchar *format)
+{
+	gchar *result;
+	struct tm date_tm;
+
+	g_return_val_if_fail (date_string != NULL, NULL);
+	g_return_val_if_fail (format != NULL, NULL);
+
+	memset (&date_tm, 0, sizeof (struct tm));
+
+	if (strptime (date_string, format, &date_tm) == 0) {
+		return NULL;
+	}
+
+	result = g_malloc (sizeof (char)*25);
+
+	strftime (result, 25, DATE_FORMAT_ISO8601 , &date_tm);
+
+	return result;
 }
 
 gchar *
-tracker_date_to_time_string (const gchar  *time_string)
+tracker_date_to_time_string (const gchar *date_string)
 {
-	gchar *dvalue;
+	gchar *str;
 
-	dvalue = tracker_date_format (time_string);
+	str = tracker_date_format (date_string);
 
-	if (dvalue) {
-		time_t time;
+	if (str) {
+		time_t t;
 
-		time = tracker_string_to_date (dvalue);
-		g_free (dvalue);
+		t = tracker_string_to_date (str);
+		g_free (str);
 
-		if (time != -1) {
-			return tracker_gint_to_string (time);
+		if (t != -1) {
+			return tracker_gint_to_string (t);
 		}
 	}
 
@@ -321,70 +346,70 @@
 }
 
 static gboolean
-is_valid_8601_datetime (const gchar *timestamp)
+is_valid_8601_datetime (const gchar *date_string)
 {
 	gint len;
 
-	len = strlen (timestamp);
+	len = strlen (date_string);
 
 	if (len < 19) {
 		return FALSE;
 	}
 
-	if (!g_ascii_isdigit (timestamp[0]) ||
-	    !g_ascii_isdigit (timestamp[1]) ||
-	    !g_ascii_isdigit (timestamp[2]) ||
-	    !g_ascii_isdigit (timestamp[3])) {
+	if (!g_ascii_isdigit (date_string[0]) ||
+	    !g_ascii_isdigit (date_string[1]) ||
+	    !g_ascii_isdigit (date_string[2]) ||
+	    !g_ascii_isdigit (date_string[3])) {
 		return FALSE;
 	}
 
-	if (timestamp[4] != '-') {
+	if (date_string[4] != '-') {
 		return FALSE;
 	}
 
-	if (!g_ascii_isdigit (timestamp[5]) ||
-	    !g_ascii_isdigit (timestamp[6])) {
+	if (!g_ascii_isdigit (date_string[5]) ||
+	    !g_ascii_isdigit (date_string[6])) {
 		return FALSE;
 	}
 
-	if (timestamp[7] != '-') {
+	if (date_string[7] != '-') {
 		return FALSE;
 	}
 
-	if (!g_ascii_isdigit (timestamp[8]) ||
-	    !g_ascii_isdigit (timestamp[9])) {
+	if (!g_ascii_isdigit (date_string[8]) ||
+	    !g_ascii_isdigit (date_string[9])) {
 		return FALSE;
 	}
 
-	if ((timestamp[10] != 'T')) {
+	if ((date_string[10] != 'T')) {
 		return FALSE;
 	}
 
-	if (!g_ascii_isdigit (timestamp[11]) ||
-	    !g_ascii_isdigit (timestamp[12])) {
+	if (!g_ascii_isdigit (date_string[11]) ||
+	    !g_ascii_isdigit (date_string[12])) {
 		return FALSE;
 	}
 
-	if (timestamp[13] != ':') {
+	if (date_string[13] != ':') {
 		return FALSE;
 	}
 
-	if (!g_ascii_isdigit (timestamp[14]) ||
-	    !g_ascii_isdigit (timestamp[15])) {
+	if (!g_ascii_isdigit (date_string[14]) ||
+	    !g_ascii_isdigit (date_string[15])) {
 		return FALSE;
 	}
 
-	if (timestamp[16] != ':'){
+	if (date_string[16] != ':'){
 		return FALSE;
 	}
 
-	if (!g_ascii_isdigit (timestamp[17]) ||
-	    !g_ascii_isdigit (timestamp[18])) {
+	if (!g_ascii_isdigit (date_string[17]) ||
+	    !g_ascii_isdigit (date_string[18])) {
 		return FALSE;
 	}
 
 	if (len == 20) {
-		if (timestamp[19] != 'Z') {
+		if (date_string[19] != 'Z') {
 			return FALSE;
 		}
 	} else {
@@ -396,13 +421,13 @@
 				return FALSE;
 			}
 
-			if (timestamp[19] != '+' &&
-			    timestamp[19] != '-') {
+			if (date_string[19] != '+' &&
+			    date_string[19] != '-') {
 				return FALSE;
 			}
 
-			if (!g_ascii_isdigit (timestamp[20]) ||
-			    !g_ascii_isdigit (timestamp[21])) {
+			if (!g_ascii_isdigit (date_string[20]) ||
+			    !g_ascii_isdigit (date_string[21])) {
 				return FALSE;
 			}
 		}
@@ -412,57 +437,57 @@
 }
 
 time_t
-tracker_string_to_date (const gchar *timestamp)
+tracker_string_to_date (const gchar *date_string)
 {
 	struct tm tm;
 	long	  val;
 	time_t	  t;
 
-	g_return_val_if_fail (timestamp, -1);
+	g_return_val_if_fail (date_string, -1);
 
 	/* We should have a valid iso 8601 date in format
 	 * YYYY-MM-DDThh:mm:ss with optional TZ
 	 */
-	if (!is_valid_8601_datetime (timestamp)) {
+	if (!is_valid_8601_datetime (date_string)) {
 		return -1;
 	}
 
 	memset (&tm, 0, sizeof (struct tm));
-	val = strtoul (timestamp, (gchar**) &timestamp, 10);
+	val = strtoul (date_string, (gchar**) &date_string, 10);
 
-	if (*timestamp == '-') {
+	if (*date_string == '-') {
 		/* YYYY-MM-DD */
 		tm.tm_year = val - 1900;
-		timestamp++;
-		tm.tm_mon = strtoul (timestamp, (gchar **) &timestamp, 10) - 1;
+		date_string++;
+		tm.tm_mon = strtoul (date_string, (gchar **) &date_string, 10) - 1;
 
-		if (*timestamp++ != '-') {
+		if (*date_string++ != '-') {
 			return -1;
 		}
 
-		tm.tm_mday = strtoul (timestamp, (gchar **) &timestamp, 10);
+		tm.tm_mday = strtoul (date_string, (gchar **) &date_string, 10);
 	}
 
-	if (*timestamp++ != 'T') {
+	if (*date_string++ != 'T') {
 		g_critical ("Date validation failed for '%s' st '%c'",
-			    timestamp,
-			    *timestamp);
+			    date_string,
+			    *date_string);
 		return -1;
 	}
 
-	val = strtoul (timestamp, (gchar**) &timestamp, 10);
+	val = strtoul (date_string, (gchar**) &date_string, 10);
 
-	if (*timestamp == ':') {
+	if (*date_string == ':') {
 		/* hh:mm:ss */
 		tm.tm_hour = val;
-		timestamp++;
-		tm.tm_min = strtoul (timestamp, (gchar**) &timestamp, 10);
+		date_string++;
+		tm.tm_min = strtoul (date_string, (gchar**) &date_string, 10);
 
-		if (*timestamp++ != ':') {
+		if (*date_string++ != ':') {
 			return -1;
 		}
 
-		tm.tm_sec = strtoul (timestamp, (gchar**) &timestamp, 10);
+		tm.tm_sec = strtoul (date_string, (gchar**) &date_string, 10);
 	}
 
 	/* mktime() always assumes that "tm" is in locale time but we
@@ -471,48 +496,48 @@
 	t  = mktime (&tm);
 	t -= timezone;
 
-	if (*timestamp == '+' ||
-	    *timestamp == '-') {
+	if (*date_string == '+' ||
+	    *date_string == '-') {
 		gint sign;
 
-		sign = *timestamp++ == '+' ? -1 : 1;
+		sign = *date_string++ == '+' ? -1 : 1;
 
 		/* We have format hh:mm or hhmm */
 		/* Now, we are reading hours */
-		if (timestamp[0] &&
-		    timestamp[1]) {
-			if (g_ascii_isdigit (timestamp[0]) &&
-			    g_ascii_isdigit (timestamp[1])) {
+		if (date_string[0] &&
+		    date_string[1]) {
+			if (g_ascii_isdigit (date_string[0]) &&
+			    g_ascii_isdigit (date_string[1])) {
 				gchar buff[3];
 
-				buff[0] = timestamp[0];
-				buff[1] = timestamp[1];
+				buff[0] = date_string[0];
+				buff[1] = date_string[1];
 				buff[2] = '\0';
 
 				val = strtoul (buff, NULL, 10);
 				t += sign * (3600 * val);
-				timestamp += 2;
+				date_string += 2;
 			}
 
-			if (*timestamp == ':' || *timestamp == '\'') {
-				timestamp++;
+			if (*date_string == ':' || *date_string == '\'') {
+				date_string++;
 			}
 		}
 
 		/* Now, we are reading minutes */
-		if (timestamp[0] &&
-		    timestamp[1]) {
-			if (g_ascii_isdigit (timestamp[0]) &&
-			    g_ascii_isdigit (timestamp[1])) {
+		if (date_string[0] &&
+		    date_string[1]) {
+			if (g_ascii_isdigit (date_string[0]) &&
+			    g_ascii_isdigit (date_string[1])) {
 				gchar buff[3];
 
-				buff[0] = timestamp[0];
-				buff[1] = timestamp[1];
+				buff[0] = date_string[0];
+				buff[1] = date_string[1];
 				buff[2] = '\0';
 
 				val = strtoul (buff, NULL, 10);
 				t += sign * (60 * val);
-				timestamp += 2;
+				date_string += 2;
 			}
 		}
 	}

Modified: trunk/src/libtracker-common/tracker-type-utils.h
==============================================================================
--- trunk/src/libtracker-common/tracker-type-utils.h	(original)
+++ trunk/src/libtracker-common/tracker-type-utils.h	Thu Nov 20 12:27:58 2008
@@ -30,9 +30,11 @@
 #error "only <libtracker-common/tracker-common.h> must be included directly."
 #endif
 
-gchar *  tracker_date_format		       (const gchar  *time_string);
+gchar *  tracker_date_format		       (const gchar  *date_string);
+gchar *  tracker_date_format_to_iso8601        (const gchar  *date_string,
+						const gchar  *format);
 gchar *  tracker_date_to_time_string	       (const gchar  *date_string);
-time_t	 tracker_string_to_date		       (const gchar  *time_string);
+time_t	 tracker_string_to_date		       (const gchar  *date_string);
 gchar *  tracker_date_to_string		       (time_t	      date_time);
 gchar *  tracker_glong_to_string	       (glong	      i);
 gchar *  tracker_gint_to_string		       (gint	      i);

Modified: trunk/src/tracker-extract/tracker-extract-exif.c
==============================================================================
--- trunk/src/tracker-extract/tracker-extract-exif.c	(original)
+++ trunk/src/tracker-extract/tracker-extract-exif.c	Thu Nov 20 12:27:58 2008
@@ -19,14 +19,67 @@
 
 #include "config.h"
 
-#include "tracker-extract.h"
 #include <stdio.h>
 #include <string.h>
+
 #include <glib.h>
+
 #include <libexif/exif-data.h>
 
+#include <libtracker-common/tracker-type-utils.h>
+
+#include "tracker-extract.h"
+
 #define EXIF_DATE_FORMAT "%Y:%m:%d %H:%M:%S"
 
+typedef gchar * (*PostProcessor) (gchar *);
+
+typedef struct {
+	ExifTag       tag;
+	gchar	      *name;
+	PostProcessor post;
+} TagType;
+
+static gchar *date_to_iso8601   (gchar       *exif_date);
+static gchar *fix_focal_length  (gchar       *fl);
+static gchar *fix_flash         (gchar       *flash);
+static gchar *fix_fnumber       (gchar       *fn);
+static gchar *fix_exposure_time (gchar       *et);
+static void   extract_exif      (const gchar *filename,
+                                 GHashTable  *metadata);
+
+static TagType tags[] = {
+	{ EXIF_TAG_PIXEL_Y_DIMENSION, "Image:Height", NULL },
+	{ EXIF_TAG_PIXEL_X_DIMENSION, "Image:Width", NULL },
+	{ EXIF_TAG_RELATED_IMAGE_WIDTH, "Image:Width", NULL },
+	{ EXIF_TAG_DOCUMENT_NAME, "Image:Title", NULL },
+	/* { -1, "Image:Album", NULL }, */
+	{ EXIF_TAG_DATE_TIME, "Image:Date", date_to_iso8601 },
+	/* { -1, "Image:Keywords", NULL }, */
+	{ EXIF_TAG_ARTIST, "Image:Creator", NULL },
+	{ EXIF_TAG_USER_COMMENT, "Image:Comments", NULL },
+	{ EXIF_TAG_IMAGE_DESCRIPTION, "Image:Description", NULL },
+	{ EXIF_TAG_SOFTWARE, "Image:Software", NULL },
+	{ EXIF_TAG_MAKE, "Image:CameraMake", NULL },
+	{ EXIF_TAG_MODEL, "Image:CameraModel", NULL },
+	{ EXIF_TAG_ORIENTATION, "Image:Orientation", NULL },
+	{ EXIF_TAG_EXPOSURE_PROGRAM, "Image:ExposureProgram", NULL },
+	{ EXIF_TAG_EXPOSURE_TIME, "Image:ExposureTime", fix_exposure_time },
+	{ EXIF_TAG_FNUMBER, "Image:FNumber", fix_fnumber },
+	{ EXIF_TAG_FLASH, "Image:Flash", fix_flash },
+	{ EXIF_TAG_FOCAL_LENGTH, "Image:FocalLength", fix_focal_length },
+	{ EXIF_TAG_ISO_SPEED_RATINGS, "Image:ISOSpeed", NULL },
+	{ EXIF_TAG_METERING_MODE, "Image:MeteringMode", NULL },
+	{ EXIF_TAG_WHITE_BALANCE, "Image:WhiteBalance", NULL },
+	{ EXIF_TAG_COPYRIGHT, "File:Copyright", NULL },
+	{ -1, NULL, NULL }
+};
+
+static TrackerExtractorData data[] = {
+	{ "image/jpeg", extract_exif },
+	{ NULL, NULL }
+};
+
 static gchar *
 date_to_iso8601 (gchar *exif_date)
 {
@@ -34,10 +87,9 @@
 	   To
 	   ex. "2007-04-15T17:35:58+0200 where +0200 is localtime
 	*/
-	return tracker_generic_date_to_iso8601 (exif_date, EXIF_DATE_FORMAT);
+	return tracker_date_format_to_iso8601 (exif_date, EXIF_DATE_FORMAT);
 }
 
-
 static gchar *
 fix_focal_length (gchar *fl)
 {
@@ -55,7 +107,6 @@
 	}
 }
 
-
 static gchar *
 fix_fnumber (gchar *fn)
 {
@@ -69,7 +120,6 @@
 	return fn;
 }
 
-
 static gchar *
 fix_exposure_time (gchar *et)
 {
@@ -90,47 +140,9 @@
 	return et;
 }
 
-
-typedef gchar * (*PostProcessor) (gchar *);
-
-
-typedef struct {
-	ExifTag       tag;
-	gchar	      *name;
-	PostProcessor post;
-} TagType;
-
-
-TagType tags[] = {
-	{ EXIF_TAG_PIXEL_Y_DIMENSION, "Image:Height", NULL },
-	{ EXIF_TAG_PIXEL_X_DIMENSION, "Image:Width", NULL },
-	{ EXIF_TAG_RELATED_IMAGE_WIDTH, "Image:Width", NULL },
-	{ EXIF_TAG_DOCUMENT_NAME, "Image:Title", NULL },
-	/* { -1, "Image:Album", NULL }, */
-	{ EXIF_TAG_DATE_TIME, "Image:Date", date_to_iso8601 },
-	/* { -1, "Image:Keywords", NULL }, */
-	{ EXIF_TAG_ARTIST, "Image:Creator", NULL },
-	{ EXIF_TAG_USER_COMMENT, "Image:Comments", NULL },
-	{ EXIF_TAG_IMAGE_DESCRIPTION, "Image:Description", NULL },
-	{ EXIF_TAG_SOFTWARE, "Image:Software", NULL },
-	{ EXIF_TAG_MAKE, "Image:CameraMake", NULL },
-	{ EXIF_TAG_MODEL, "Image:CameraModel", NULL },
-	{ EXIF_TAG_ORIENTATION, "Image:Orientation", NULL },
-	{ EXIF_TAG_EXPOSURE_PROGRAM, "Image:ExposureProgram", NULL },
-	{ EXIF_TAG_EXPOSURE_TIME, "Image:ExposureTime", fix_exposure_time },
-	{ EXIF_TAG_FNUMBER, "Image:FNumber", fix_fnumber },
-	{ EXIF_TAG_FLASH, "Image:Flash", fix_flash },
-	{ EXIF_TAG_FOCAL_LENGTH, "Image:FocalLength", fix_focal_length },
-	{ EXIF_TAG_ISO_SPEED_RATINGS, "Image:ISOSpeed", NULL },
-	{ EXIF_TAG_METERING_MODE, "Image:MeteringMode", NULL },
-	{ EXIF_TAG_WHITE_BALANCE, "Image:WhiteBalance", NULL },
-	{ EXIF_TAG_COPYRIGHT, "File:Copyright", NULL },
-	{ -1, NULL, NULL }
-};
-
-
 static void
-tracker_extract_exif (const gchar *filename, GHashTable *metadata)
+extract_exif (const gchar *filename, 
+              GHashTable  *metadata)
 {
 	ExifData *exif;
 	TagType  *p;
@@ -156,13 +168,9 @@
 	}
 }
 
-
-TrackerExtractorData data[] = {
-	{ "image/jpeg", tracker_extract_exif },
-	{ NULL, NULL }
-};
-
-
+/* FIXME: Note, tracker-extract-exif is completely unused right now so
+ * any changes to this code are uncompiled, -mr.
+ */
 TrackerExtractorData *
 tracker_get_extractor_data (void)
 {

Modified: trunk/src/tracker-extract/tracker-extract-gstreamer.c
==============================================================================
--- trunk/src/tracker-extract/tracker-extract-gstreamer.c	(original)
+++ trunk/src/tracker-extract/tracker-extract-gstreamer.c	Thu Nov 20 12:27:58 2008
@@ -73,7 +73,7 @@
 #define INCLUDE_FLUENDO_TAGS 
 
 typedef enum {
-	EXTRACT_MIME_UNDEFINED=0,
+	EXTRACT_MIME_UNDEFINED,
 	EXTRACT_MIME_AUDIO,
 	EXTRACT_MIME_VIDEO,
 	EXTRACT_MIME_IMAGE
@@ -912,19 +912,19 @@
 		if (!g_hash_table_lookup (metadata, "Audio:Album")) {
 			g_hash_table_insert (metadata, 
 					     g_strdup ("Audio:Album"), 
-					     g_strdup (""));
+					     g_strdup (METADATA_UNKNONN));
 		}
 		
 		if (!g_hash_table_lookup (metadata, "Audio:Artist")) {
 			g_hash_table_insert (metadata, 
 					     g_strdup ("Audio:Artist"), 
-					     g_strdup (""));
+					     g_strdup (METADATA_UNKNONN));
 		}
 		
 		if (!g_hash_table_lookup (metadata, "Audio:Genre")) {
 			g_hash_table_insert (metadata, 
 					     g_strdup ("Audio:Genre"), 
-					     g_strdup (""));
+					     g_strdup (METADATA_UNKNONN));
 		}
 
 		if (!g_hash_table_lookup (metadata, "Audio:PlayCount")) {
@@ -958,7 +958,7 @@
 		if (!g_hash_table_lookup (metadata, "Video:Author")) {
 			g_hash_table_insert (metadata, 
 					     g_strdup ("Video:Author"),
-					     g_strdup (""));
+					     g_strdup (METADATA_UNKNONN));
 		}
 
 		if (!g_hash_table_lookup (metadata, "Video:PlayCount")) {

Modified: trunk/src/tracker-extract/tracker-extract-imagemagick.c
==============================================================================
--- trunk/src/tracker-extract/tracker-extract-imagemagick.c	(original)
+++ trunk/src/tracker-extract/tracker-extract-imagemagick.c	Thu Nov 20 12:27:58 2008
@@ -32,8 +32,17 @@
 #include "tracker-extract.h"
 #include "tracker-xmp.h"
 
+static void extract_imagemagick (const gchar *filename, 
+				 GHashTable  *metadata);
+
+static TrackerExtractorData data[] = {
+	{ "image/*", extract_imagemagick },
+	{ NULL, NULL }
+};
+
 static void
-tracker_extract_imagemagick (const gchar *filename, GHashTable *metadata)
+extract_imagemagick (const gchar *filename, 
+		     GHashTable  *metadata)
 {
 	gchar *argv[6];
 	gchar *identify;
@@ -42,7 +51,7 @@
 
 	g_return_if_fail (filename != NULL);
 
-	/* imagemagick crashes trying to extract from xcf files */
+	/* Imagemagick crashes trying to extract from xcf files */
 	if (g_str_has_suffix (filename, ".xcf")) {
 		return;
 	}
@@ -50,29 +59,39 @@
 	argv[0] = g_strdup ("identify");
 	argv[1] = g_strdup ("-format");
 	argv[2] = g_strdup ("%w;\\n%h;\\n%c;\\n");
+
 	if (g_str_has_suffix (filename, ".xcf")) {
 		argv[3] = g_strdup (filename);
 		argv[4] = NULL;
-	}
-	else {
+	} else {
 		argv[3] = g_strdup ("-ping");
 		argv[4] = g_strdup (filename);
 	}
+
 	argv[5] = NULL;
 
 	if (tracker_spawn (argv, 10, &identify, &exit_status)) {
 		if (exit_status == EXIT_SUCCESS) {
 			lines = g_strsplit (identify, ";\n", 4);
-			g_hash_table_insert (metadata, g_strdup ("Image:Width"), g_strdup (lines[0]));
-			g_hash_table_insert (metadata, g_strdup ("Image:Height"), g_strdup (lines[1]));
-			g_hash_table_insert (metadata, g_strdup ("Image:Comments"), g_strdup (g_strescape (lines[2], "")));
+
+			g_hash_table_insert (metadata, 
+					     g_strdup ("Image:Width"), 
+					     g_strdup (lines[0]));
+			g_hash_table_insert (metadata, 
+					     g_strdup ("Image:Height"), 
+					     g_strdup (lines[1]));
+
+			/* FIXME: Should we use METADATA_UNKNOWN
+			 * (tracker:unknown) here? -mr
+			 */
+			g_hash_table_insert (metadata, 
+					     g_strdup ("Image:Comments"), 
+					     g_strdup (g_strescape (lines[2], "")));
 		}
 	}
 
 #ifdef HAVE_EXEMPI
-
-	/* convert is buggy atm so disable temporarily */
-
+	/* FIXME: Convert is buggy atm so disable temporarily */
 	return;
 
 	gchar *xmp;
@@ -87,16 +106,9 @@
 			tracker_read_xmp (xmp, strlen (xmp), metadata);
 		}
 	}
-#endif
+#endif /* HAVE_EXEMPI */
 }
 
-
-TrackerExtractorData data[] = {
-	{ "image/*", tracker_extract_imagemagick },
-	{ NULL, NULL }
-};
-
-
 TrackerExtractorData *
 tracker_get_extractor_data (void)
 {

Modified: trunk/src/tracker-extract/tracker-extract-jpeg.c
==============================================================================
--- trunk/src/tracker-extract/tracker-extract-jpeg.c	(original)
+++ trunk/src/tracker-extract/tracker-extract-jpeg.c	Thu Nov 20 12:27:58 2008
@@ -34,9 +34,21 @@
 
 #include <jpeglib.h>
 
+#include <libtracker-common/tracker-type-utils.h>
+
 #include "tracker-extract.h"
 #include "tracker-xmp.h"
 
+#ifdef HAVE_EXEMPI
+#define XMP_NAMESPACE	     "http://ns.adobe.com/xap/1.0/\x00";
+#define XMP_NAMESPACE_LENGTH 29
+#endif /* HAVE_EXEMPI */
+
+#ifdef HAVE_LIBEXIF
+#include <libexif/exif-data.h>
+#define EXIF_DATE_FORMAT "%Y:%m:%d %H:%M:%S"
+#endif /* HAVE_LIBEXIF */
+
 static void extract_jpeg (const gchar *filename,
 			  GHashTable  *metadata);
 
@@ -45,18 +57,9 @@
 	{ NULL, NULL }
 };
 
-#ifdef HAVE_EXEMPI
-#define XMP_NAMESPACE	     "http://ns.adobe.com/xap/1.0/\x00";
-#define XMP_NAMESPACE_LENGTH 29
-#endif /* HAVE_EXEMPI */
-
 #ifdef HAVE_LIBEXIF
 
-#include <libexif/exif-data.h>
-
-#define EXIF_DATE_FORMAT "%Y:%m:%d %H:%M:%S"
-
-typedef gchar * (*PostProcessor) (const gchar *);
+typedef gchar * (*PostProcessor) (const gchar*);
 
 typedef struct {
 	ExifTag       tag;
@@ -99,12 +102,12 @@
 };
 
 static gchar *
-date_to_iso8601 (const gchar *exif_date)
+date_to_iso8601 (const gchar *date)
 {
 	/* From: ex; date "2007:04:15 15:35:58"
 	 * To  : ex. "2007-04-15T17:35:58+0200 where +0200 is localtime
 	 */
-	return tracker_generic_date_to_iso8601 (exif_date, EXIF_DATE_FORMAT);
+	return tracker_date_format_to_iso8601 (date, EXIF_DATE_FORMAT);
 }
 
 static gchar *
@@ -169,14 +172,11 @@
 	return g_strdup (et);
 }
 
-#endif /* HAVE_LIBEXIF */
-
 static void
 read_exif (const unsigned char *buffer,
 	   size_t		len,
 	   GHashTable	       *metadata)
 {
-#ifdef HAVE_LIBEXIF
 	ExifData *exif;
 	TagType  *p;
 
@@ -203,9 +203,10 @@
 			}
 		}
 	}
-#endif /* HAVE_LIBEXIF */
 }
 
+#endif /* HAVE_LIBEXIF */
+
 static void
 extract_jpeg (const gchar *filename,
 	      GHashTable  *metadata)
@@ -257,7 +258,7 @@
 				break;
 
 			case JPEG_APP0+1:
-#if defined(HAVE_LIBEXIF)
+#ifdef HAVE_LIBEXIF
 				if (strncmp ("Exif", (gchar*) (marker->data), 5) == 0) {
 					read_exif ((unsigned char*) marker->data,
 						   marker->data_length,
@@ -265,7 +266,7 @@
 				}
 #endif /* HAVE_LIBEXIF */
 
-#if defined(HAVE_EXEMPI)
+#ifdef HAVE_EXEMPI
 				str = (gchar*) marker->data;
 				len = marker->data_length;
 

Modified: trunk/src/tracker-extract/tracker-extract-mp3.c
==============================================================================
--- trunk/src/tracker-extract/tracker-extract-mp3.c	(original)
+++ trunk/src/tracker-extract/tracker-extract-mp3.c	Thu Nov 20 12:27:58 2008
@@ -1321,19 +1321,19 @@
 	if (!g_hash_table_lookup (metadata, "Audio:Album")) {
 		g_hash_table_insert (metadata,
 				     g_strdup ("Audio:Album"),
-				     g_strdup (""));
+				     g_strdup (METADATA_UNKNONN));
 	}
 
 	if (!g_hash_table_lookup (metadata, "Audio:Artist")) {
 		g_hash_table_insert (metadata,
 				     g_strdup ("Audio:Artist"),
-				     g_strdup (""));
+				     g_strdup (METADATA_UNKNONN));
 	}
 
 	if (!g_hash_table_lookup (metadata, "Audio:Genre")) {
 		g_hash_table_insert (metadata,
 				     g_strdup ("Audio:Genre"),
-				     g_strdup (""));
+				     g_strdup (METADATA_UNKNONN));
 	}
 
 	if (!g_hash_table_lookup (metadata, "Audio:PlayCount")) {

Modified: trunk/src/tracker-extract/tracker-extract-png.c
==============================================================================
--- trunk/src/tracker-extract/tracker-extract-png.c	(original)
+++ trunk/src/tracker-extract/tracker-extract-png.c	Thu Nov 20 12:27:58 2008
@@ -27,6 +27,7 @@
 
 #include <fcntl.h>
 #include <string.h>
+#include <stdlib.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
@@ -36,6 +37,8 @@
 #include <glib.h>
 #include <glib/gstdio.h>
 
+#include <libtracker-common/tracker-type-utils.h>
+
 #include "tracker-extract.h"
 #include "tracker-xmp.h"
 
@@ -72,12 +75,12 @@
 };
 
 static gchar *
-rfc1123_to_iso8601_date (gchar *rfc_date)
+rfc1123_to_iso8601_date (gchar *date)
 {
 	/* From: ex. RFC1123 date: "22 May 1997 18:07:10 -0600"
 	 * To  : ex. ISO8601 date: "2007-05-22T18:07:10-0600"
 	 */
-	return tracker_generic_date_to_iso8601 (rfc_date, RFC1123_DATE_FORMAT);
+	return tracker_date_format_to_iso8601 (date, RFC1123_DATE_FORMAT);
 }
 
 static void
@@ -211,12 +214,14 @@
 		/* Read the image. FIXME We should be able to skip this step and
 		 * just get the info from the end. This causes some errors atm.
 		 */
-		row_pointers = (png_bytepp)malloc(height * sizeof(png_bytep));		
+		row_pointers = (png_bytepp) malloc (height * sizeof (png_bytep));		
 		for (row = 0; row < height; row++) {
-			row_pointers[row] = png_malloc(png_ptr,
-						       png_get_rowbytes(png_ptr,info_ptr));
+			row_pointers[row] = png_malloc (png_ptr,
+							png_get_rowbytes(png_ptr,info_ptr));
 		}
+
 		png_read_image (png_ptr, row_pointers);
+
 		for (row = 0; row < height; row++) {
 			png_free (png_ptr, row_pointers[row]);
 		}
@@ -229,7 +234,6 @@
 		
 		/* We want native have higher priority than XMP etc.
 		 */
-
 		g_hash_table_insert (metadata,
 				     g_strdup ("Image:Width"),
 				     g_strdup_printf ("%ld", width));

Modified: trunk/src/tracker-extract/tracker-extract-ps.c
==============================================================================
--- trunk/src/tracker-extract/tracker-extract-ps.c	(original)
+++ trunk/src/tracker-extract/tracker-extract-ps.c	Thu Nov 20 12:27:58 2008
@@ -34,10 +34,25 @@
 #include <glib.h>
 #include <glib/gstdio.h>
 
+#include <libtracker-common/tracker-type-utils.h>
 #include <libtracker-common/tracker-os-dependant.h>
 
 #include "tracker-extract.h"
 
+#ifndef HAVE_GETLINE
+
+#include <stddef.h>
+#include <stdlib.h>
+#include <limits.h>
+#include <errno.h>
+
+#undef getdelim
+#undef getline
+
+#define GROWBY 80
+
+#endif /* HAVE_GETLINE */
+
 static void extract_ps_gz (const gchar *filename,
 			   GHashTable  *metadata);
 static void extract_ps	  (const gchar *filename,
@@ -51,16 +66,6 @@
 
 #ifndef HAVE_GETLINE
 
-#include <stddef.h>
-#include <stdlib.h>
-#include <limits.h>
-#include <errno.h>
-
-#undef getdelim
-#undef getline
-
-#define GROWBY 80
-
 static ssize_t
 igetdelim (gchar  **linebuf,
 	   size_t  *linebufsz,
@@ -131,7 +136,7 @@
 	/* From: ex. date: "(18:07 Tuesday 22 May 2007)"
 	 * To  : ex. ISO8601 date: "2007-05-22T18:07:10-0600"
 	 */
-	return tracker_generic_date_to_iso8601 (date, "(%H:%M %A %d %B %Y)");
+	return tracker_date_format_to_iso8601 (date, "(%H:%M %A %d %B %Y)");
 }
 
 static gchar *
@@ -140,7 +145,7 @@
 	/* From: ex. date: "Tue May 22 18:07:10 2007"
 	 * To  : ex. ISO8601 date: "2007-05-22T18:07:10-0600"
 	 */
-	return tracker_generic_date_to_iso8601 (date, "%A %B %d %H:%M:%S %Y");
+	return tracker_date_format_to_iso8601 (date, "%A %B %d %H:%M:%S %Y");
 }
 
 static gchar *
@@ -149,7 +154,7 @@
 	/* From: ex. date: "22 May 1997 18:07:10 -0600"
 	 * To  : ex. ISO8601 date: "2007-05-22T18:07:10-0600"
 	 */
-	return tracker_generic_date_to_iso8601 (date, "%d %B %Y %H:%M:%S %z");
+	return tracker_date_format_to_iso8601 (date, "%d %B %Y %H:%M:%S %z");
 }
 
 static gchar *
@@ -158,7 +163,7 @@
 	/* From: ex. date: "6:07 PM May 22, 2007"
 	 * To  : ex. ISO8601 date: "2007-05-22T18:07:10-0600"
 	 */
-	return tracker_generic_date_to_iso8601 (date, "%I:%M %p %B %d, %Y");
+	return tracker_date_format_to_iso8601 (date, "%I:%M %p %B %d, %Y");
 }
 
 static gchar *

Modified: trunk/src/tracker-extract/tracker-extract-tiff.c
==============================================================================
--- trunk/src/tracker-extract/tracker-extract-tiff.c	(original)
+++ trunk/src/tracker-extract/tracker-extract-tiff.c	Thu Nov 20 12:27:58 2008
@@ -21,16 +21,18 @@
 
 #include "config.h"
 
-#include "tracker-extract.h"
-
 #include <glib.h>
 
 #include <tiff.h>
 #include <tiffio.h>
 
+#include <libtracker-common/tracker-type-utils.h>
+
+#include "tracker-extract.h"
 #include "tracker-xmp.h"
 
 #define XMP_NAMESPACE_LENGTH 29
+#define EXIF_DATE_FORMAT     "%Y:%m:%d %H:%M:%S"
 
 typedef gchar * (*PostProcessor) (gchar *);
 
@@ -49,22 +51,18 @@
 	TagType        type;
 	PostProcessor  post;
 } TiffTag;
+ 
+static void   extract_tiff    (const gchar *filename,
+			       GHashTable  *metadata);
+static gchar *date_to_iso8601 (gchar       *date);
 
-#define EXIF_DATE_FORMAT "%Y:%m:%d %H:%M:%S"
-
-static gchar *
-date_to_iso8601 (gchar *exif_date)
-{
-	/* ex; date "2007:04:15 15:35:58"
-	   To
-	   ex. "2007-04-15T17:35:58+0200 where +0200 is localtime
-	*/
-	return tracker_generic_date_to_iso8601 (exif_date, EXIF_DATE_FORMAT);
-}
-
+static TrackerExtractorData data[] = {
+	{ "image/tiff", extract_tiff },
+	{ NULL, NULL }
+};
 
-/* FIXME We are missing some */
-TiffTag tags[] = {
+/* FIXME: We are missing some */
+static TiffTag tags[] = {
 	{ TIFFTAG_ARTIST, "Image:Creator", TIFF_TAGTYPE_STRING, NULL },
 	{ TIFFTAG_COPYRIGHT, "File:Copyright", TIFF_TAGTYPE_STRING, NULL },
 	{ TIFFTAG_DATETIME, "Image:Date", TIFF_TAGTYPE_STRING, NULL },
@@ -79,29 +77,39 @@
 	{ -1, NULL, TIFF_TAGTYPE_UNDEFINED, NULL }
 };
 
-TiffTag exiftags[] = {
-	{EXIFTAG_EXPOSURETIME, "Image:ExposureTime", TIFF_TAGTYPE_DOUBLE, NULL},
-	{EXIFTAG_FNUMBER, "Image:FNumber", TIFF_TAGTYPE_DOUBLE, NULL},
-	{EXIFTAG_EXPOSUREPROGRAM, "Image:ExposureProgram", TIFF_TAGTYPE_UINT16 ,NULL },
-	{EXIFTAG_ISOSPEEDRATINGS, "Image:ISOSpeed",TIFF_TAGTYPE_C16_UINT16, NULL},
-	{EXIFTAG_DATETIMEORIGINAL, "Image:Date", TIFF_TAGTYPE_STRING,date_to_iso8601},
-	{EXIFTAG_METERINGMODE, "Image:MeteringMode", TIFF_TAGTYPE_UINT16, NULL},
-	{EXIFTAG_FLASH, "Image:Flash", TIFF_TAGTYPE_UINT16, NULL},
-	{EXIFTAG_FOCALLENGTH, "Image:FocalLength", TIFF_TAGTYPE_DOUBLE, NULL},
-	{EXIFTAG_PIXELXDIMENSION, "Image:Width",TIFF_TAGTYPE_UINT32, NULL},
-	{EXIFTAG_PIXELYDIMENSION, "Image:Height", TIFF_TAGTYPE_UINT32,NULL},
-	{EXIFTAG_WHITEBALANCE, "Image:WhiteBalance", TIFF_TAGTYPE_UINT16,NULL},
+static TiffTag exiftags[] = {
+	{ EXIFTAG_EXPOSURETIME, "Image:ExposureTime", TIFF_TAGTYPE_DOUBLE, NULL},
+	{ EXIFTAG_FNUMBER, "Image:FNumber", TIFF_TAGTYPE_DOUBLE, NULL},
+	{ EXIFTAG_EXPOSUREPROGRAM, "Image:ExposureProgram", TIFF_TAGTYPE_UINT16, NULL },
+	{ EXIFTAG_ISOSPEEDRATINGS, "Image:ISOSpeed", TIFF_TAGTYPE_C16_UINT16, NULL},
+	{ EXIFTAG_DATETIMEORIGINAL, "Image:Date", TIFF_TAGTYPE_STRING, date_to_iso8601 },
+	{ EXIFTAG_METERINGMODE, "Image:MeteringMode", TIFF_TAGTYPE_UINT16, NULL},
+	{ EXIFTAG_FLASH, "Image:Flash", TIFF_TAGTYPE_UINT16, NULL},
+	{ EXIFTAG_FOCALLENGTH, "Image:FocalLength", TIFF_TAGTYPE_DOUBLE, NULL},
+	{ EXIFTAG_PIXELXDIMENSION, "Image:Width", TIFF_TAGTYPE_UINT32, NULL},
+	{ EXIFTAG_PIXELYDIMENSION, "Image:Height", TIFF_TAGTYPE_UINT32, NULL},
+	{ EXIFTAG_WHITEBALANCE, "Image:WhiteBalance", TIFF_TAGTYPE_UINT16, NULL},
 	{ -1, NULL, TIFF_TAGTYPE_UNDEFINED, NULL }
 };
 
+static gchar *
+date_to_iso8601 (gchar *date)
+{
+	/* ex; date "2007:04:15 15:35:58"
+	 * To
+	 * ex. "2007-04-15T17:35:58+0200 where +0200 is localtime
+	 */
+	return tracker_date_format_to_iso8601 (date, EXIF_DATE_FORMAT);
+}
 
 static void
-tracker_extract_tiff (const gchar *filename, GHashTable *metadata)
+extract_tiff (const gchar *filename, 
+	      GHashTable  *metadata)
 {
-	TIFF	 *image;
-	long	  exifOffset;
+	TIFF *image;
+	glong exifOffset;
 
-	TiffTag  *tag;
+	TiffTag *tag;
 
 	gchar buffer[1024];
 	guint16 varui16 = 0;
@@ -110,16 +118,15 @@
 	void *data;
 	guint16 count16;
 
-	float vardouble;
+	gfloat vardouble;
 
 #ifdef HAVE_EXEMPI
-	gchar	 *xmpOffset;
-	uint32	  size;
+	gchar *xmpOffset;
+	guint32 size;
 #endif /* HAVE_EXEMPI */
 
-
-	if((image = TIFFOpen(filename, "r")) == NULL){
-		g_error("Could not open image\n");
+	if ((image = TIFFOpen (filename, "r")) == NULL){
+		g_critical ("Could not open image:'%s'\n", filename);
 		return;
 	}
 
@@ -127,55 +134,50 @@
 	   due to bugs in the original spec (type) */
 
 #ifdef HAVE_EXEMPI
-
-	if (TIFFGetField(image, TIFFTAG_XMLPACKET, &size, &xmpOffset)) {
+	if (TIFFGetField (image, TIFFTAG_XMLPACKET, &size, &xmpOffset)) {
 		tracker_read_xmp (xmpOffset,
 				  size,
 				  metadata);
 	}
-
 #endif /* HAVE_EXEMPI */
 
-	if (TIFFGetField(image, TIFFTAG_EXIFIFD, &exifOffset)) {
-
-		if (TIFFReadEXIFDirectory(image, exifOffset)) {
-
+	if (TIFFGetField (image, TIFFTAG_EXIFIFD, &exifOffset)) {
+		if (TIFFReadEXIFDirectory (image, exifOffset)) {
 			for (tag = exiftags; tag->name; ++tag) {
-
 				switch (tag->type) {
 				case TIFF_TAGTYPE_STRING:
-					if (!TIFFGetField(image, tag->tag, &buffer)) {
+					if (!TIFFGetField (image, tag->tag, &buffer)) {
 						continue;
 					}
 					break;
 				case TIFF_TAGTYPE_UINT16:						
-					if (!TIFFGetField(image, tag->tag, &varui16)) {
+					if (!TIFFGetField (image, tag->tag, &varui16)) {
 						continue;
 					}
 
-					sprintf(buffer,"%i",varui16);
+					sprintf (buffer,"%i",varui16);
 					break;
 				case TIFF_TAGTYPE_UINT32:
-					if (!TIFFGetField(image, tag->tag, &varui32)) {
+					if (!TIFFGetField (image, tag->tag, &varui32)) {
 						continue;
 					}
 
 					sprintf(buffer,"%i",varui32);
 					break;
 				case TIFF_TAGTYPE_DOUBLE:
-					if (!TIFFGetField(image, tag->tag, &vardouble)) {
+					if (!TIFFGetField (image, tag->tag, &vardouble)) {
 						continue;
 					}
 
-					sprintf(buffer,"%f",vardouble);
+					sprintf (buffer,"%f",vardouble);
 					break;
 				case TIFF_TAGTYPE_C16_UINT16:						
-					if (!TIFFGetField(image, tag->tag, &count16, &data)) {
+					if (!TIFFGetField (image, tag->tag, &count16, &data)) {
 						continue;
 					}
 
 					/* We only take only the first for now */
-					sprintf(buffer,"%i",*(guint16 *)data);
+					sprintf (buffer,"%i",*(guint16 *)data);
 					break;	
 
 				default:
@@ -184,14 +186,15 @@
 				}
 
 				if (tag->post) {
-					g_hash_table_insert (metadata, g_strdup (tag->name),
+					g_hash_table_insert (metadata,
+							     g_strdup (tag->name),
 							     g_strdup ((*tag->post) (buffer)));
 				} else {
-					g_hash_table_insert (metadata, g_strdup (tag->name),
+					g_hash_table_insert (metadata, 
+							     g_strdup (tag->name),
 							     g_strdup (buffer));
 				}
 			}
-
 		}
 	}
 
@@ -199,30 +202,30 @@
 	for (tag = tags; tag->name; ++tag) {
 		switch (tag->type) {
 			case TIFF_TAGTYPE_STRING:
-				if (!TIFFGetField(image, tag->tag, &buffer)) {
+				if (!TIFFGetField (image, tag->tag, &buffer)) {
 					continue;
 				}
 				break;
 			case TIFF_TAGTYPE_UINT16:
-				if (!TIFFGetField(image, tag->tag, &varui16)) {
+				if (!TIFFGetField (image, tag->tag, &varui16)) {
 					continue;
 				}
 
-				sprintf(buffer,"%i",varui16);
+				sprintf (buffer,"%i",varui16);
 				break;
 			case TIFF_TAGTYPE_UINT32:
-				if (!TIFFGetField(image, tag->tag, &varui32)) {
+				if (!TIFFGetField (image, tag->tag, &varui32)) {
 					continue;
 				}
 
 				sprintf(buffer,"%i",varui32);
 				break;
 			case TIFF_TAGTYPE_DOUBLE:
-				if (!TIFFGetField(image, tag->tag, &vardouble)) {
+				if (!TIFFGetField (image, tag->tag, &vardouble)) {
 					continue;
 				}
 
-				sprintf(buffer,"%f",vardouble);
+				sprintf (buffer,"%f",vardouble);
 				break;
 			default:
 				continue;
@@ -230,27 +233,19 @@
 			}
 
 		if (tag->post) {
-			g_hash_table_insert (metadata, g_strdup (tag->name),
+			g_hash_table_insert (metadata, 
+					     g_strdup (tag->name),
 					     g_strdup ((*tag->post) (buffer)));
 		} else {
-			g_hash_table_insert (metadata, g_strdup (tag->name),
+			g_hash_table_insert (metadata, 
+					     g_strdup (tag->name),
 					     g_strdup (buffer));
 		}
 	}
 
-	TIFFClose(image);
-
+	TIFFClose (image);
 }
 
-
-
-
-TrackerExtractorData data[] = {
-	{ "image/tiff", tracker_extract_tiff },
-	{ NULL, NULL }
-};
-
-
 TrackerExtractorData *
 tracker_get_extractor_data (void)
 {

Modified: trunk/src/tracker-extract/tracker-extract.c
==============================================================================
--- trunk/src/tracker-extract/tracker-extract.c	(original)
+++ trunk/src/tracker-extract/tracker-extract.c	Thu Nov 20 12:27:58 2008
@@ -51,7 +51,6 @@
 #define MAX_MEM       128
 #define MAX_MEM_AMD64 512
 
-#define ISO8601_FORMAT "%Y-%m-%dT%H:%M:%S%z"
 
 #define DISABLE_DEBUG
 
@@ -78,26 +77,6 @@
 static GArray *extractors = NULL;
 static guint   shutdown_timeout_id = 0;
 
-gchar *
-tracker_generic_date_to_iso8601 (const gchar *date,
-				 const gchar *format)
-{
-	gchar *result;
-	struct tm date_tm;
-
-	memset (&date_tm, 0, sizeof (struct tm));
-
-	if (strptime (date, format, &date_tm) == NULL) {
-		return NULL;
-	}
-
-	result = g_malloc (sizeof (char)*25);
-
-	strftime (result, 25, ISO8601_FORMAT , &date_tm);
-
-	return result;
-}
-
 #ifndef DISABLE_DEBUG
 
 static void

Modified: trunk/src/tracker-extract/tracker-extract.h
==============================================================================
--- trunk/src/tracker-extract/tracker-extract.h	(original)
+++ trunk/src/tracker-extract/tracker-extract.h	Thu Nov 20 12:27:58 2008
@@ -26,9 +26,16 @@
 
 G_BEGIN_DECLS
 
+/* FIXME: We use this to say that we don't actually have any metadata
+ * for this keyword. This is bad because it means we have to string
+ * check every value returned in clients that use the Tracker API.
+ * This will be fixed in due course after January some time, -mr.
+ */
+#define METADATA_UNKNONN "tracker:unknown"
+
 typedef struct TrackerExtractorData TrackerExtractorData;
 
-typedef TrackerExtractorData * (* TrackerExtractorDataFunc) (void);
+typedef TrackerExtractorData * (*TrackerExtractorDataFunc)(void);
 
 struct TrackerExtractorData {
 	const gchar *mime;
@@ -37,9 +44,7 @@
 			    GHashTable	*metadata);
 };
 
-gchar *		      tracker_generic_date_to_iso8601 (const gchar  *date,
-						       const gchar  *format);
-TrackerExtractorData *tracker_get_extractor_data      (void);
+TrackerExtractorData *tracker_get_extractor_data (void);
 
 G_END_DECLS
 



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