[libgweather/wip/forecasts] Prefer Yahoo! Weather over Yr.no if available and enabled.



commit 572844ab2157f1837f5ca53a77234f13f54e27c4
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Sat Dec 1 18:52:14 2012 +0100

    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

 libgweather/weather-priv.h  |    2 +-
 libgweather/weather-yahoo.c |    7 +++++--
 libgweather/weather.c       |   12 ++++++------
 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



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