Blame SOURCES/evolution-data-server-3.8.5-weather-calendar.patch

22d06c
diff -up evolution-data-server-3.8.5/calendar/backends/weather/e-cal-backend-weather.c.weather-calendar evolution-data-server-3.8.5/calendar/backends/weather/e-cal-backend-weather.c
22d06c
--- evolution-data-server-3.8.5/calendar/backends/weather/e-cal-backend-weather.c.weather-calendar	2013-07-23 13:58:14.000000000 +0200
22d06c
+++ evolution-data-server-3.8.5/calendar/backends/weather/e-cal-backend-weather.c	2014-10-08 13:12:19.142604974 +0200
22d06c
@@ -69,9 +69,6 @@ struct _ECalBackendWeatherPrivate {
22d06c
 	/* Flags */
22d06c
 	gboolean opened;
22d06c
 
22d06c
-	/* City (for summary) */
22d06c
-	gchar *city;
22d06c
-
22d06c
 	/* Weather source */
22d06c
 	EWeatherSource *source;
22d06c
 
22d06c
@@ -313,7 +310,6 @@ create_weather (ECalBackendWeather *cbw,
22d06c
                 GWeatherInfo *report,
22d06c
                 gboolean is_forecast)
22d06c
 {
22d06c
-	ECalBackendWeatherPrivate *priv;
22d06c
 	ECalComponent             *cal_comp;
22d06c
 	ECalComponentText          comp_summary;
22d06c
 	icalcomponent             *ical_comp;
22d06c
@@ -322,19 +318,18 @@ create_weather (ECalBackendWeather *cbw,
22d06c
 	gchar			  *uid;
22d06c
 	GSList                    *text_list = NULL;
22d06c
 	ECalComponentText         *description;
22d06c
-	gchar                     *tmp;
22d06c
+	gchar                     *tmp, *city_name;
22d06c
 	time_t			   update_time;
22d06c
 	icaltimezone		  *update_zone = NULL;
22d06c
 	const GWeatherLocation    *location;
22d06c
 	const GWeatherTimezone    *w_timezone;
22d06c
+	gdouble tmin = 0.0, tmax = 0.0;
22d06c
 
22d06c
 	g_return_val_if_fail (E_IS_CAL_BACKEND_WEATHER (cbw), NULL);
22d06c
 
22d06c
 	if (!gweather_info_get_value_update (report, &update_time))
22d06c
 		return NULL;
22d06c
 
22d06c
-	priv = cbw->priv;
22d06c
-
22d06c
 	/* create the component and event object */
22d06c
 	ical_comp = icalcomponent_new (ICAL_VEVENT_COMPONENT);
22d06c
 	cal_comp = e_cal_component_new ();
22d06c
@@ -373,28 +368,27 @@ create_weather (ECalBackendWeather *cbw,
22d06c
 	/* We have to add 1 day to DTEND, as it is not inclusive. */
22d06c
 	e_cal_component_set_dtend (cal_comp, &dt);
22d06c
 
22d06c
-	{
22d06c
-		gdouble tmin = 0.0, tmax = 0.0;
22d06c
+	city_name = gweather_info_get_location_name (report);
22d06c
+	if (gweather_info_get_value_temp_min (report, GWEATHER_TEMP_UNIT_DEFAULT, &tmin) &&
22d06c
+	    gweather_info_get_value_temp_max (report, GWEATHER_TEMP_UNIT_DEFAULT, &tmax) &&
22d06c
+	    tmin != tmax) {
22d06c
+		gchar *min, *max;
22d06c
+
22d06c
+		min = gweather_info_get_temp_min (report);
22d06c
+		max = gweather_info_get_temp_max (report);
22d06c
+		comp_summary.value = g_strdup_printf ("%s : %s / %s", city_name, min, max);
22d06c
 
22d06c
-		if (gweather_info_get_value_temp_min (report, GWEATHER_TEMP_UNIT_DEFAULT, &tmin) &&
22d06c
-		    gweather_info_get_value_temp_max (report, GWEATHER_TEMP_UNIT_DEFAULT, &tmax) &&
22d06c
-		    tmin != tmax) {
22d06c
-			gchar *min, *max;
22d06c
-
22d06c
-			min = gweather_info_get_temp_min (report);
22d06c
-			max = gweather_info_get_temp_max (report);
22d06c
-			comp_summary.value = g_strdup_printf ("%s : %s / %s", priv->city, min, max);
22d06c
-
22d06c
-			g_free (min); g_free (max);
22d06c
-		} else {
22d06c
-			gchar *temp;
22d06c
+		g_free (min); g_free (max);
22d06c
+	} else {
22d06c
+		gchar *temp;
22d06c
 
22d06c
-			temp = gweather_info_get_temp (report);
22d06c
-			comp_summary.value = g_strdup_printf ("%s : %s", priv->city, temp);
22d06c
+		temp = gweather_info_get_temp (report);
22d06c
+		comp_summary.value = g_strdup_printf ("%s : %s", city_name, temp);
22d06c
 
22d06c
-			g_free (temp);
22d06c
-		}
22d06c
+		g_free (temp);
22d06c
 	}
22d06c
+	g_free (city_name);
22d06c
+
22d06c
 	comp_summary.altrep = NULL;
22d06c
 	e_cal_component_set_summary (cal_comp, &comp_summary);
22d06c
 	g_free ((gchar *) comp_summary.value);
22d06c
@@ -484,28 +478,14 @@ e_cal_backend_weather_open (ECalBackendS
22d06c
 {
22d06c
 	ECalBackendWeather *cbw;
22d06c
 	ECalBackendWeatherPrivate *priv;
22d06c
-	ESource *source;
22d06c
-	ESourceWeather *extension;
22d06c
-	const gchar *extension_name;
22d06c
 	const gchar *cache_dir;
22d06c
-	gchar *location;
22d06c
 	gboolean online;
22d06c
 
22d06c
 	cbw = E_CAL_BACKEND_WEATHER (backend);
22d06c
 	priv = cbw->priv;
22d06c
 
22d06c
-	source = e_backend_get_source (E_BACKEND (backend));
22d06c
 	cache_dir = e_cal_backend_get_cache_dir (E_CAL_BACKEND (backend));
22d06c
 
22d06c
-	extension_name = E_SOURCE_EXTENSION_WEATHER_BACKEND;
22d06c
-	extension = e_source_get_extension (source, extension_name);
22d06c
-
22d06c
-	g_free (priv->city);
22d06c
-
22d06c
-	location = e_source_weather_dup_location (extension);
22d06c
-	priv->city = g_strdup (strrchr (location, '/') + 1);
22d06c
-	g_free (location);
22d06c
-
22d06c
 	e_cal_backend_notify_readonly (E_CAL_BACKEND (backend), TRUE);
22d06c
 
22d06c
 	online = e_backend_get_online (E_BACKEND (backend));
22d06c
@@ -788,8 +768,6 @@ e_cal_backend_weather_finalize (GObject
22d06c
 		priv->store = NULL;
22d06c
 	}
22d06c
 
22d06c
-	g_free (priv->city);
22d06c
-
22d06c
 	/* Chain up to parent's finalize() method. */
22d06c
 	G_OBJECT_CLASS (e_cal_backend_weather_parent_class)->finalize (object);
22d06c
 }
22d06c
diff -up evolution-data-server-3.8.5/calendar/backends/weather/e-weather-source.c.weather-calendar evolution-data-server-3.8.5/calendar/backends/weather/e-weather-source.c
22d06c
--- evolution-data-server-3.8.5/calendar/backends/weather/e-weather-source.c.weather-calendar	2013-07-23 13:58:13.000000000 +0200
22d06c
+++ evolution-data-server-3.8.5/calendar/backends/weather/e-weather-source.c	2014-10-08 13:10:01.743610796 +0200
22d06c
@@ -71,6 +71,37 @@ e_weather_source_init (EWeatherSource *s
22d06c
 	source->priv = E_WEATHER_SOURCE_GET_PRIVATE (source);
22d06c
 }
22d06c
 
22d06c
+static GWeatherLocation *
22d06c
+weather_source_find_location_by_coords (GWeatherLocation *start,
22d06c
+					gdouble latitude,
22d06c
+					gdouble longitude)
22d06c
+{
22d06c
+	GWeatherLocation *location, **children;
22d06c
+	gint ii;
22d06c
+
22d06c
+	if (!start)
22d06c
+		return NULL;
22d06c
+
22d06c
+	location = start;
22d06c
+	if (gweather_location_has_coords (location)) {
22d06c
+		gdouble lat, lon;
22d06c
+
22d06c
+		gweather_location_get_coords (location, &lat, &lon);
22d06c
+
22d06c
+		if (lat == latitude && lon == longitude)
22d06c
+			return location;
22d06c
+	}
22d06c
+
22d06c
+	children = gweather_location_get_children (location);
22d06c
+	for (ii = 0; children[ii]; ii++) {
22d06c
+		location = weather_source_find_location_by_coords (children[ii], latitude, longitude);
22d06c
+		if (location)
22d06c
+			return location;
22d06c
+	}
22d06c
+
22d06c
+	return NULL;
22d06c
+}
22d06c
+
22d06c
 EWeatherSource *
22d06c
 e_weather_source_new (const gchar *location)
22d06c
 {
22d06c
@@ -99,6 +130,18 @@ e_weather_source_new (const gchar *locat
22d06c
 	tokens = g_strsplit (location, "/", 2);
22d06c
 
22d06c
 	glocation = gweather_location_find_by_station_code (world, tokens[0]);
22d06c
+
22d06c
+	if (!glocation) {
22d06c
+		gdouble latitude, longitude;
22d06c
+		gchar *endptr = NULL;
22d06c
+
22d06c
+		latitude = g_ascii_strtod (location, &endptr);
22d06c
+		if (endptr && *endptr == '/') {
22d06c
+			longitude = g_ascii_strtod (endptr + 1, NULL);
22d06c
+			glocation = weather_source_find_location_by_coords (world, latitude, longitude);
22d06c
+		}
22d06c
+	}
22d06c
+
22d06c
 	if (glocation != NULL)
22d06c
 		gweather_location_ref (glocation);
22d06c
 
22d06c
@@ -109,7 +152,7 @@ e_weather_source_new (const gchar *locat
22d06c
 		return NULL;
22d06c
 
22d06c
 	source = g_object_new (E_TYPE_WEATHER_SOURCE, NULL);
22d06c
-	source->priv->location = gweather_location_ref (glocation);
22d06c
+	source->priv->location = glocation;
22d06c
 
22d06c
 	return source;
22d06c
 }
22d06c
@@ -146,11 +189,12 @@ e_weather_source_parse (EWeatherSource *
22d06c
 		source->priv->info = gweather_info_new (
22d06c
 			source->priv->location,
22d06c
 			GWEATHER_FORECAST_LIST);
22d06c
+		gweather_info_set_enabled_providers (source->priv->info, GWEATHER_PROVIDER_ALL);
22d06c
 		g_signal_connect (
22d06c
 			source->priv->info, "updated",
22d06c
 			G_CALLBACK (weather_source_updated_cb), source);
22d06c
-	} else {
22d06c
-		gweather_info_update (source->priv->info);
22d06c
 	}
22d06c
+
22d06c
+	gweather_info_update (source->priv->info);
22d06c
 }
22d06c