[Xfce4-commits] <xfce4-weather-plugin:master> Schedule next weather data download when reading cache file.

Harald Judt noreply at xfce.org
Thu Jan 10 16:34:01 CET 2013


Updating branch refs/heads/master
         to 9fcaf690bac68bd22850c55163542f00be65ec02 (commit)
       from 891512a385a0088ad75cc5064a1b3bb660700fed (commit)

commit 9fcaf690bac68bd22850c55163542f00be65ec02
Author: Harald Judt <h.judt at gmx.at>
Date:   Wed Jan 9 10:42:19 2013 +0100

    Schedule next weather data download when reading cache file.
    
    Do not download weather data if cached data is present and not too old.

 panel-plugin/weather.c |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/panel-plugin/weather.c b/panel-plugin/weather.c
index 2dc33b9..ed52c28 100644
--- a/panel-plugin/weather.c
+++ b/panel-plugin/weather.c
@@ -380,8 +380,8 @@ update_current_conditions(plugin_data *data)
 
 
 static time_t
-calc_next_download_time(const update_info *upi) {
-    time_t retry_t = time(NULL);
+calc_next_download_time(const update_info *upi,
+                        time_t retry_t) {
     struct tm retry_tm;
     guint interval;
 
@@ -453,7 +453,8 @@ cb_astro_update(SoupSession *session,
     if (G_UNLIKELY(astro == NULL)) {
         /* download or parsing failed, schedule retry */
         data->astro_update->attempt++;
-        data->astro_update->next = calc_next_download_time(data->astro_update);
+        data->astro_update->next = calc_next_download_time(data->astro_update,
+                                                           now_t);
     }
     schedule_next_wakeup(data);
     weather_dump(weather_dump_astrodata, data->astrodata);
@@ -503,7 +504,8 @@ cb_weather_update(SoupSession *session,
         g_warning
             (_("Download of weather data failed with HTTP Status Code %d, "
                "Reason phrase: %s"), msg->status_code, msg->reason_phrase);
-    data->weather_update->next = calc_next_download_time(data->weather_update);
+    data->weather_update->next = calc_next_download_time(data->weather_update,
+                                                         now_t);
 
     xml_weather_clean(data->weatherdata);
     g_array_sort(data->weatherdata->timeslices,
@@ -1112,6 +1114,9 @@ read_cache_file(plugin_data *data)
     if (G_LIKELY(data->weather_update)) {
         CACHE_READ_STRING(timestring, "last_weather_download");
         data->weather_update->last = parse_timestring(timestring, NULL);
+        data->weather_update->next =
+            calc_next_download_time(data->weather_update,
+                                    data->weather_update->last);
         g_free(timestring);
     }
 


More information about the Xfce4-commits mailing list