** Fix for bug #564652
authorMilan Crha <mcrha@redhat.com>
Tue, 23 Dec 2008 22:00:51 +0000 (22:00 +0000)
committerMilan Crha <mcrha@src.gnome.org>
Tue, 23 Dec 2008 22:00:51 +0000 (22:00 +0000)
2008-12-23  Milan Crha  <mcrha@redhat.com>

** Fix for bug #564652

* configure.in: Bump of libgweather version to 2.25.4 because
of new function 'gweather_xml_free_locations'.

* calendar/backends/weather/e-cal-backend-weather.c: (create_weather):
Convert time from UTC properly. Leak a bit less.
* calendar/backends/weather/e-weather-source-ccf.c: (find_location):
Leak a bit less.

svn path=/trunk/; revision=9848

ChangeLog
calendar/ChangeLog
calendar/backends/weather/e-cal-backend-weather.c
calendar/backends/weather/e-weather-source-ccf.c
configure.in

index 97689f2..09845bf 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2008-12-23  Milan Crha  <mcrha@redhat.com>
+
+       ** Part of fix for bug #564652
+
+       * configure.in: Bump of libgweather version to 2.25.4 because
+       of new function 'gweather_xml_free_locations'.
+
 2008-12-15  Srinivasa Ragavan  <sragavan@novell.com>
 
        * NEWS: Evolution Data Server 2.25.3 release
index 33d2df5..abd8a61 100644 (file)
@@ -1,3 +1,12 @@
+2008-12-23  Milan Crha  <mcrha@redhat.com>
+
+       ** Fix for bug #564652
+
+       * backends/weather/e-cal-backend-weather.c: (create_weather):
+       Convert time from UTC properly. Leak a bit less.
+       * backends/weather/e-weather-source-ccf.c: (find_location):
+       Leak a bit less.
+
 2008-12-10  Suman Manjunath  <msuman@novell.com>
 
        * backends/Makefile.am:
index 952d331..bdd4f28 100644 (file)
@@ -278,13 +278,15 @@ create_weather (ECalBackendWeather *cbw, WeatherInfo *report, gboolean is_foreca
        icalcomponent             *ical_comp;
        struct icaltimetype        itt;
        ECalComponentDateTime      dt;
-       const char                *uid;
+       char                      *uid;
        GSList                    *text_list = NULL;
        ECalComponentText         *description;
        ESource                   *source;
        gboolean                   metric;
        const char                *tmp;
        time_t                     update_time;
+       icaltimezone              *update_zone = NULL;
+       const WeatherLocation     *location;
 
        g_return_val_if_fail (E_IS_CAL_BACKEND_WEATHER (cbw), NULL);
 
@@ -318,25 +320,42 @@ create_weather (ECalBackendWeather *cbw, WeatherInfo *report, gboolean is_foreca
        /* set uid */
        uid = e_cal_component_gen_uid ();
        e_cal_component_set_uid (cal_comp, uid);
+       g_free (uid);
+
+       /* use timezone of the location to determine date for which this is set */
+       location = weather_info_get_location (report);
+       if (location && location->tz_hint && *location->tz_hint)
+               update_zone = icaltimezone_get_builtin_timezone (location->tz_hint);
+
+       if (!update_zone)
+               update_zone = priv->default_zone;
+
+       /* Set all-day event's date from forecast data - cannot set is_date,
+          because in that case no timezone conversion is done */
+       itt = icaltime_from_timet_with_zone (update_time, 0, update_zone);
+       itt.hour = 0;
+       itt.minute = 0;
+       itt.second = 0;
+       itt.is_date = 1;
 
-       /* Set all-day event's date from forecast data */
-       itt = icaltime_from_timet (update_time, 1);
        dt.value = &itt;
-       dt.tzid = NULL;
+       if (update_zone)
+               dt.tzid = icaltimezone_get_tzid (update_zone);
+       else
+               dt.tzid = NULL;
+
        e_cal_component_set_dtstart (cal_comp, &dt);
 
-       itt = icaltime_from_timet (update_time, 1);
        icaltime_adjust (&itt, 1, 0, 0, 0);
-       dt.value = &itt;
-       dt.tzid = NULL;
        /* We have to add 1 day to DTEND, as it is not inclusive. */
        e_cal_component_set_dtend (cal_comp, &dt);
 
        if (is_forecast) {
-               gdouble tmin, tmax;
+               gdouble tmin = 0.0, tmax = 0.0;
 
                if (weather_info_get_value_temp_min (report, TEMP_UNIT_DEFAULT, &tmin) && 
-                   weather_info_get_value_temp_max (report, TEMP_UNIT_DEFAULT, &tmax)) {
+                   weather_info_get_value_temp_max (report, TEMP_UNIT_DEFAULT, &tmax) &&
+                   tmin != tmax) {
                        /* because weather_info_get_temp* uses one internal buffer, thus finally
                           the last value is shown for both, which is obviously wrong */
                        GString *str = g_string_new (priv->city);
@@ -351,14 +370,15 @@ create_weather (ECalBackendWeather *cbw, WeatherInfo *report, gboolean is_foreca
                        comp_summary.value = g_strdup_printf ("%s : %s", priv->city, weather_info_get_temp (report));
                }
        } else {
-               gdouble tmin, tmax;
+               gdouble tmin = 0.0, tmax = 0.0;
                /* because weather_info_get_temp* uses one internal buffer, thus finally
                   the last value is shown for both, which is obviously wrong */
                GString *str = g_string_new (priv->city);
 
                g_string_append (str, " : ");
                if (weather_info_get_value_temp_min (report, TEMP_UNIT_DEFAULT, &tmin) && 
-                   weather_info_get_value_temp_max (report, TEMP_UNIT_DEFAULT, &tmax)) {
+                   weather_info_get_value_temp_max (report, TEMP_UNIT_DEFAULT, &tmax) &&
+                   tmin != tmax) {
                        g_string_append (str, weather_info_get_temp_min (report));
                        g_string_append (str, "/");
                        g_string_append (str, weather_info_get_temp_max (report));
@@ -370,14 +390,17 @@ create_weather (ECalBackendWeather *cbw, WeatherInfo *report, gboolean is_foreca
        }
        comp_summary.altrep = NULL;
        e_cal_component_set_summary (cal_comp, &comp_summary);
+       g_free ((char *)comp_summary.value);
 
        tmp = weather_info_get_forecast (report);
+       comp_summary.value = weather_info_get_weather_summary (report);
 
        description = g_new0 (ECalComponentText, 1);
-       description->value = g_strconcat (is_forecast ? "" : weather_info_get_weather_summary (report), is_forecast ? "" : "\n", tmp ? _("Forecast") : "", tmp ? ":" : "", tmp && !is_forecast ? "\n" : "", tmp ? tmp : "", NULL);
+       description->value = g_strconcat (is_forecast ? "" : comp_summary.value, is_forecast ? "" : "\n", tmp ? _("Forecast") : "", tmp ? ":" : "", tmp && !is_forecast ? "\n" : "", tmp ? tmp : "", NULL);
        description->altrep = "";
        text_list = g_slist_append (text_list, description);
        e_cal_component_set_description_list (cal_comp, text_list);
+       g_free ((char *)comp_summary.value);
 
        /* Set category and visibility */
        e_cal_component_set_categories (cal_comp, getCategory (report));
index c3a2785..14800d8 100644 (file)
@@ -106,7 +106,7 @@ find_location (const gchar *code_name, gboolean is_old)
 
        gtk_tree_model_foreach (model, (GtkTreeModelForeachFunc) find_location_func, &search);
 
-       g_object_unref (model);
+       gweather_xml_free_locations (model);
        g_strfreev (ids);
 
 done:
index d9b1199..add2c01 100644 (file)
@@ -32,7 +32,7 @@ m4_define([libxml_minimum_version], [2.0.0])            # XXX Just a Guess
 m4_define([libsoup_minimum_version], [2.3.0])
 m4_define([gnome_keyring_minimum_version], [2.20.1])
 m4_define([sqlite_minimum_version], [3.5])
-m4_define([gweather_minimum_version], [2.25.2])
+m4_define([gweather_minimum_version], [2.25.4])
 
 dnl *************************************************************************************************
 dnl Base Version