static GList *inc_dialog_list = NULL;
+static time_t inc_offline_overridden_yes = 0;
+static time_t inc_offline_overridden_no = 0;
+
guint inc_lock_count = 0;
static GdkPixbuf *currentpix;
cm_return_if_fail(account != NULL);
if (account->autocheck_timer != 0) {
+ g_source_remove(account->autocheck_timer);
debug_print("INC: account %d: removed inc timer %d\n", account->account_id,
account->autocheck_timer);
account->autocheck_timer = 0;
gboolean inc_offline_should_override(gboolean force_ask, const gchar *msg)
{
- static time_t overridden_yes = 0;
- static time_t overridden_no = 0;
- int length = 10; /* minutes */
+ gint length = 10; /* seconds */
gint answer = G_ALERTDEFAULT;
#ifdef HAVE_NETWORKMANAGER_SUPPORT
#endif
if (prefs_common.autochk_newmail)
- length = prefs_common.autochk_itv; /* minutes */
+ length = prefs_common.autochk_itv; /* seconds */
if (force_ask) {
- overridden_no = (time_t)0;
+ inc_offline_overridden_no = (time_t)0;
}
if (prefs_common.work_offline) {
gchar *tmp = NULL;
- if (time(NULL) - overridden_yes < length * 60) /* seconds */
+ if (time(NULL) - inc_offline_overridden_yes < length * 60) /* seconds */
return TRUE;
- else if (time(NULL) - overridden_no < length * 60) /* seconds */
+ else if (time(NULL) - inc_offline_overridden_no < length * 60) /* seconds */
return FALSE;
- if (!force_ask)
+ if (!force_ask) {
+ gchar *unit = _("seconds");
+
+ /* show the offline override time (length) using the must appropriate unit:
+ the biggest unit possible (hours, minutes, seconds), provided that there
+ is not inferior unit involved: 1 hour, 150 minutes, 25 minutes, 90 minutes,
+ 30 seconds, 90 seconds. */
+ if ((length / 3600) > 0) { /* hours? */
+ if (((length % 3600) % 60) == 0) { /* no seconds left? */
+ if ((length % 3600) > 0) { /* minutes left? */
+ length = length / 60;
+ unit = ngettext("minute", "minutes", length);
+ } else {
+ length = length / 3600;
+ unit = ngettext("hour", "hours", length);
+ }
+ } /* else: seconds */
+ } else {
+ if ((length / 60) > 0) { /* minutes left? */
+ if ((length % 60) == 0) {
+ length = length / 60;
+ unit = ngettext("minute", "minutes", length);
+ }
+ } /* else: seconds */
+ }
tmp = g_strdup_printf(
- _("%s%sYou're working offline. Override for %d minutes?"),
+ _("%s%sYou're working offline. Override for %d %s?"),
msg?msg:"",
msg?"\n\n":"",
- length);
- else
+ length, unit);
+ } else
tmp = g_strdup_printf(
_("%s%sYou're working offline. Override?"),
msg?msg:"",
!force_ask? _("On_ly once"):NULL, ALERTFOCUS_SECOND);
g_free(tmp);
if (answer == G_ALERTALTERNATE) {
- overridden_yes = time(NULL);
+ inc_offline_overridden_yes = time(NULL);
return TRUE;
} else if (answer == G_ALERTDEFAULT) {
if (!force_ask)
- overridden_no = time(NULL);
+ inc_offline_overridden_no = time(NULL);
return FALSE;
} else {
- overridden_yes = (time_t)0;
- overridden_no = (time_t)0;
+ inc_reset_offline_override_timers();
return TRUE;
}
}
return TRUE;
}
+
+void inc_reset_offline_override_timers()
+{
+ debug_print("resetting offline override timers\n");
+ inc_offline_overridden_yes = (time_t)0;
+ inc_offline_overridden_no = (time_t)0;
+}