[balsa/gtk3] Restore mail check on resume
- From: Peter Bloomfield <PeterB src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa/gtk3] Restore mail check on resume
- Date: Mon, 29 Aug 2011 03:08:50 +0000 (UTC)
commit 37b7c67d4513f2990be9512b838fa4d5c44d68e9
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date: Sun Aug 28 23:00:14 2011 -0400
Restore mail check on resume
* src/main-window.c: when network connection is reestablished,
check mail if elapsed time since last check exceeds mail check
interval.
* src/main-window.h: new member last_check_time.
ChangeLog | 7 +++++++
src/main-window.c | 33 ++++++++++++++++++++++-----------
src/main-window.h | 2 +-
3 files changed, 30 insertions(+), 12 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 67c7d8c..80dcb5e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2011-08-28 Peter Bloomfield
+ * src/main-window.c: when network connection is reestablished,
+ check mail if elapsed time since last check exceeds mail check
+ interval.
+ * src/main-window.h: new member last_check_time.
+
+2011-08-28 Peter Bloomfield
+
* libbalsa/body.c (libbalsa_message_body_get_pixbuf): check for
error before closing loader.
* src/balsa-print-object-image.c (balsa_print_object_image): use
diff --git a/src/main-window.c b/src/main-window.c
index 82fa49e..06f8215 100644
--- a/src/main-window.c
+++ b/src/main-window.c
@@ -1031,7 +1031,7 @@ balsa_window_init(BalsaWindow * window)
g_signal_connect(client, "notify::state",
G_CALLBACK(bw_nm_client_state_changed_cb),
window);
- window->check_mail_skipped = FALSE;
+ window->last_check_time = 0;
} else
fprintf (stderr, "Could not get NetworkManager client.\n");
#endif /* LIBNM_GLIB */
@@ -2798,13 +2798,6 @@ bw_show_about_box(GtkAction * action, gpointer user_data)
static void
bw_check_mailbox_list(BalsaWindow * window, GList * mailbox_list)
{
-#if defined(HAVE_LIBNM_GLIB)
- if (window && window->nm_state != NM_STATE_CONNECTED) {
- window->check_mail_skipped = TRUE;
- return;
- }
-#endif /* LIBNM_GLIB */
-
for ( ; mailbox_list; mailbox_list = mailbox_list->next) {
LibBalsaMailbox *mailbox =
BALSA_MAILBOX_NODE(mailbox_list->data)->mailbox;
@@ -2923,9 +2916,19 @@ ensure_check_mail_dialog(BalsaWindow * window)
void
check_new_messages_real(BalsaWindow * window, int type)
{
- GSList *list = NULL;
+ GSList *list;
#ifdef BALSA_USE_THREADS
struct check_messages_thread_info *info;
+#endif
+
+#if defined(HAVE_LIBNM_GLIB)
+ if (window && window->nm_state != NM_STATE_CONNECTED) {
+ return;
+ }
+#endif /* LIBNM_GLIB */
+
+ list = NULL;
+#ifdef BALSA_USE_THREADS
/* Only Run once -- If already checking mail, return. */
if (pthread_mutex_trylock(&checking_mail_lock)) {
fprintf(stderr, "Already Checking Mail!\n");
@@ -2970,6 +2973,8 @@ check_new_messages_real(BalsaWindow * window, int type)
g_slist_foreach(list, (GFunc) libbalsa_mailbox_check, NULL);
g_slist_foreach(list, (GFunc) g_object_unref, NULL);
g_slist_free(list);
+
+ time(&window->last_check_time);
#endif
}
@@ -3132,6 +3137,7 @@ bw_check_messages_thread(struct check_messages_thread_info *info)
if (info->window) {
gdk_threads_enter();
bw_set_sensitive(info->window, "GetNewMail", TRUE);
+ time(&info->window->last_check_time);
g_object_unref(info->window);
gdk_threads_leave();
}
@@ -3629,10 +3635,15 @@ bw_nm_client_state_changed_cb(GObject * gobject, GParamSpec * pspec,
mw_mbox_change_connection_status,
GINT_TO_POINTER(is_connected));
#endif /* BALSA_USE_THREADS */
- if (is_connected && window->check_mail_skipped) {
+ /* GLib timeouts are now triggered by g_get_monotonic_time(),
+ * which doesn't increment while we're suspended, so we must
+ * check for ourselves whether a scheduled mail check was
+ * missed. */
+ if (is_connected &&
+ difftime(time(NULL), window->last_check_time) >
+ balsa_app.check_mail_timer * 60) {
/* Check the mail now, and reset the timer */
check_new_messages_cb(NULL, balsa_app.main_window);
- window->check_mail_skipped = FALSE;
}
}
}
diff --git a/src/main-window.h b/src/main-window.h
index aafe34c..405e9a6 100644
--- a/src/main-window.h
+++ b/src/main-window.h
@@ -100,7 +100,7 @@ struct _BalsaWindow {
#if defined(HAVE_LIBNM_GLIB)
/* NetworkManager state */
NMState nm_state;
- gboolean check_mail_skipped;
+ time_t last_check_time;
#endif /* defined(HAVE_LIBNM_GLIB) */
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]