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