[Xfce4-commits] <xfce4-weather-plugin:master> Do check for updates regularly, to handle suspend/resume.

Harald Judt noreply at xfce.org
Sat Jan 5 12:04:08 CET 2013


Updating branch refs/heads/master
         to db31d45ebe7dc9defb8c198219c9c677965751f4 (commit)
       from f8e497f8e68ca538fd03615f290ca58e275fd4fe (commit)

commit db31d45ebe7dc9defb8c198219c9c677965751f4
Author: Harald Judt <h.judt at gmx.at>
Date:   Fri Jan 4 15:09:27 2013 +0100

    Do check for updates regularly, to handle suspend/resume.

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

diff --git a/panel-plugin/weather.c b/panel-plugin/weather.c
index 3a57a08..446630d 100644
--- a/panel-plugin/weather.c
+++ b/panel-plugin/weather.c
@@ -44,6 +44,10 @@
 #define CONN_MAX_ATTEMPTS (3)    /* max retry attempts using small interval */
 #define CONN_RETRY_INTERVAL_SMALL (10)
 #define CONN_RETRY_INTERVAL_LARGE (10 * 60)
+/* standard update interval in seconds used as a precaution to deal
+   with suspend/resume events etc., when nothing needs to be updated
+   earlier: */
+#define UPDATE_INTERVAL (10)
 
 #define DATA_AND_UNIT(var, item)                                    \
     value = get_data(conditions, data->units, item, data->round);   \
@@ -626,9 +630,14 @@ schedule_next_wakeup(plugin_data *data)
                                     "sunset icon change");
     }
 
-    /* next wakeup time could not be calculated, so force it to not
-       miss any updates*/
-    if (diff < 0) {
+    if (diff > UPDATE_INTERVAL) {
+        /* next wakeup time is greater than the standard check
+           interval, so call the update handler earlier to deal with
+           cases like system resume events etc. */
+        diff = UPDATE_INTERVAL;
+        data->next_wakeup_reason = "regular check";
+    } else if (diff < 0) {
+        /* last wakeup time expired, force update immediately */
         diff = 0;
         data->next_wakeup_reason = "forced";
     }
@@ -636,7 +645,11 @@ schedule_next_wakeup(plugin_data *data)
     data->update_timer =
         g_timeout_add_seconds((guint) diff,
                               (GSourceFunc) update_handler, data);
-    weather_dump(weather_dump_plugindata, data);
+    if (!strcmp(data->next_wakeup_reason, "regular check"))
+        weather_debug("Running regular check for updates, interval %d secs.",
+                      UPDATE_INTERVAL);
+    else
+        weather_dump(weather_dump_plugindata, data);
 }
 
 


More information about the Xfce4-commits mailing list