summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiovanni Campagna <gcampagna@src.gnome.org>2012-12-01 18:52:14 +0100
committerGiovanni Campagna <gcampagna@src.gnome.org>2012-12-01 18:52:14 +0100
commit572844ab2157f1837f5ca53a77234f13f54e27c4 (patch)
tree3deeb0c69f7139ae07949d9e3a2134000d21668f
parentcc75314ab4e347b75f491a95c335a5892c043bed (diff)
downloadlibgweather-572844ab2157f1837f5ca53a77234f13f54e27c4.tar.gz
Prefer Yahoo! Weather over Yr.no if available and enabled.
Yahoo! Weather has better data (it provides minimum and maximum temperature, for one), and we can know for sure if it's going to work or not, so we can easily fallback on yr.no
-rw-r--r--libgweather/weather-priv.h2
-rw-r--r--libgweather/weather-yahoo.c7
-rw-r--r--libgweather/weather.c12
3 files changed, 12 insertions, 9 deletions
diff --git a/libgweather/weather-priv.h b/libgweather/weather-priv.h
index 0ea27f2..e0cd51e 100644
--- a/libgweather/weather-priv.h
+++ b/libgweather/weather-priv.h
@@ -193,7 +193,7 @@ gboolean iwin_start_open (GWeatherInfo *info);
void metoffice_start_open (GWeatherInfo *info);
void bom_start_open (GWeatherInfo *info);
void wx_start_open (GWeatherInfo *info);
-void yahoo_start_open (GWeatherInfo *info);
+gboolean yahoo_start_open (GWeatherInfo *info);
gboolean yrno_start_open (GWeatherInfo *info);
gboolean metar_parse (gchar *metar,
diff --git a/libgweather/weather-yahoo.c b/libgweather/weather-yahoo.c
index b0500f7..0e8be62 100644
--- a/libgweather/weather-yahoo.c
+++ b/libgweather/weather-yahoo.c
@@ -264,7 +264,7 @@ yahoo_finish (SoupSession *session,
request_done (info, TRUE);
}
-void
+gboolean
yahoo_start_open (GWeatherInfo *info)
{
GWeatherInfoPrivate *priv;
@@ -276,13 +276,14 @@ yahoo_start_open (GWeatherInfo *info)
loc = priv->location;
if (!loc || !loc->yahoo_id)
- return;
+ return FALSE;
/* Yahoo! Weather only supports forecast list
(and really, the other types only make sense with national
weather offices that cannot return structured data)
*/
if (!priv->forecast_type != GWEATHER_FORECAST_LIST)
+ return FALSE;
/* u=f means that the values are in imperial system (which is what
weather.c expects). They're converted to user preferences before
@@ -296,4 +297,6 @@ yahoo_start_open (GWeatherInfo *info)
priv->requests_pending++;
g_free (url);
+
+ return TRUE;
}
diff --git a/libgweather/weather.c b/libgweather/weather.c
index 7d37977..ae8d89a 100644
--- a/libgweather/weather.c
+++ b/libgweather/weather.c
@@ -539,15 +539,15 @@ gweather_info_update (GWeatherInfo *info)
if (ok)
return;
- /* Try yr.no next */
- if (priv->providers & GWEATHER_PROVIDER_YR_NO)
- ok = yrno_start_open (info);
+ /* Try Yahoo! Weather next */
+ if (priv->providers & GWEATHER_PROVIDER_YAHOO)
+ ok = yahoo_start_open (info);
if (ok)
return;
- /* Try Yahoo! Weather next */
- if (priv->providers & GWEATHER_PROVIDER_YAHOO)
- yahoo_start_open (info);
+ /* Try yr.no next */
+ if (priv->providers & GWEATHER_PROVIDER_YR_NO)
+ yrno_start_open (info);
}
void