[tracker/tracker-0.16: 1/2] Don't throw log warnings if GstDateTime has missing information



commit 4155f9f8dce8d7545ef412a3f472362f43752adb
Author: Martyn Russell <martyn lanedo com>
Date:   Wed Jul 10 15:41:40 2013 +0100

    Don't throw log warnings if GstDateTime has missing information
    
    Part Fixes GB#700199

 src/tracker-extract/tracker-extract-gstreamer.c |   81 ++++++++++++++++++++---
 1 files changed, 72 insertions(+), 9 deletions(-)
---
diff --git a/src/tracker-extract/tracker-extract-gstreamer.c b/src/tracker-extract/tracker-extract-gstreamer.c
index a106809..e8cf903 100644
--- a/src/tracker-extract/tracker-extract-gstreamer.c
+++ b/src/tracker-extract/tracker-extract-gstreamer.c
@@ -259,6 +259,72 @@ add_double_gst_tag (TrackerSparqlBuilder  *metadata,
        }
 }
 
+static inline gboolean
+get_gst_date_time_to_buf (GstDateTime *date_time,
+                          gchar       *buf,
+                          size_t       size)
+{
+       const gchar *offset_str;
+       gint year, month, day, hour, minute, second;
+       gfloat offset;
+       gboolean complete;
+
+       offset_str = "+";
+       year = month = day = hour = minute = second = 0;
+       offset = 0.0;
+       complete = TRUE;
+
+       if (gst_date_time_has_year (date_time)) {
+               year = gst_date_time_get_year (date_time);
+       } else {
+               complete = FALSE;
+       }
+
+       if (gst_date_time_has_month (date_time)) {
+               month = gst_date_time_get_month (date_time);
+       } else {
+               complete = FALSE;
+       }
+
+       if (gst_date_time_has_day (date_time)) {
+               day = gst_date_time_get_day (date_time);
+       } else {
+               complete = FALSE;
+       }
+
+       /* Hour and Minute data is retrieved by first checking the
+        * _has_time() API.
+        */
+
+       if (gst_date_time_has_second (date_time)) {
+               second = gst_date_time_get_second (date_time);
+       } else {
+               complete = FALSE;
+       }
+
+       if (gst_date_time_has_time (date_time)) {
+               hour = gst_date_time_get_hour (date_time);
+               minute = gst_date_time_get_minute (date_time);
+               offset_str = gst_date_time_get_time_zone_offset (date_time) >= 0 ? "+" : "";
+               offset = gst_date_time_get_time_zone_offset (date_time);
+       } else {
+               offset_str = "+";
+               complete = FALSE;
+       }
+
+       snprintf (buf, size, "%04d-%02d-%02dT%02d:%02d:%02d%s%02d00",
+                 year,
+                 month,
+                 day,
+                 hour,
+                 minute,
+                 second,
+                 offset_str,
+                 (gint) offset);
+
+       return complete;
+}
+
 static void
 add_date_time_gst_tag_with_mtime_fallback (TrackerSparqlBuilder  *metadata,
                                            const gchar           *uri,
@@ -276,17 +342,14 @@ add_date_time_gst_tag_with_mtime_fallback (TrackerSparqlBuilder  *metadata,
        buf[0] = '\0';
 
        if (gst_tag_list_get_date_time (tag_list, tag_date_time, &date_time)) {
-               snprintf (buf, sizeof (buf), "%04d-%02d-%02dT%02d:%02d:%02d%s%02d00",
-                         gst_date_time_get_year (date_time),
-                         gst_date_time_get_month (date_time),
-                         gst_date_time_get_day (date_time),
-                         gst_date_time_get_hour (date_time),
-                         gst_date_time_get_minute (date_time),
-                         gst_date_time_get_second (date_time),
-                         gst_date_time_get_time_zone_offset (date_time) >= 0 ? "+" : "",
-                         (int) gst_date_time_get_time_zone_offset (date_time));
+               gboolean complete;
 
+               complete = get_gst_date_time_to_buf (date_time, buf, sizeof (buf));
                gst_date_time_unref (date_time);
+
+               if (!complete) {
+                       g_message ("GstDateTime was not complete, parts of the date/time were missing (e.g. 
hours, minutes, seconds)");
+               }
        } else if (gst_tag_list_get_date (tag_list, tag_date, &date)) {
                gboolean ret = FALSE;
 


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