evolution-data-server r9848 - in trunk: . calendar calendar/backends/weather



Author: mcrha
Date: Tue Dec 23 22:00:51 2008
New Revision: 9848
URL: http://svn.gnome.org/viewvc/evolution-data-server?rev=9848&view=rev

Log:
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.



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

Modified: trunk/calendar/backends/weather/e-cal-backend-weather.c
==============================================================================
--- trunk/calendar/backends/weather/e-cal-backend-weather.c	(original)
+++ trunk/calendar/backends/weather/e-cal-backend-weather.c	Tue Dec 23 22:00:51 2008
@@ -278,13 +278,15 @@
 	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 @@
 	/* 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 @@
 			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 @@
 	}
 	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));

Modified: trunk/calendar/backends/weather/e-weather-source-ccf.c
==============================================================================
--- trunk/calendar/backends/weather/e-weather-source-ccf.c	(original)
+++ trunk/calendar/backends/weather/e-weather-source-ccf.c	Tue Dec 23 22:00:51 2008
@@ -106,7 +106,7 @@
 
 	gtk_tree_model_foreach (model, (GtkTreeModelForeachFunc) find_location_func, &search);
 
-	g_object_unref (model);
+	gweather_xml_free_locations (model);
 	g_strfreev (ids);
 
 done:

Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in	(original)
+++ trunk/configure.in	Tue Dec 23 22:00:51 2008
@@ -32,7 +32,7 @@
 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



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