PATCH: Several enhancements to mailbox checking (with patch, this time)



HI,

 this patch fixes a major annoyance and
a few minor issues in mailbox checking
and adds a few choices for the user.

When background mailbox checking is
enabled and the progress dialog is
enabled as well, the dialog will appear
every time the background check is done.
With this patch, the progress dialog is
used only when the mail check is
initiated by user action, the background
check always uses the task bar for
status display.

For those, like me, who don't want that
flickering in the status bar, that
display can now be turned off through
prefs, making the bacjground mail check
completely invisible. I run it every 2
minutes and the status display gets on
my nerves.

When IMAP servers are used for storage
of messages only, there is no need to
regularly check them for new mail. A new
option in prefs allows the user to
select if IMAP mailboxes should be
checked for new mail at all.

I have experienced UI hangs during the
background mail check, the "Quiet"
option may serve to work around those,
too. If so, the hangs may be caused by
by the UI rather than libmutt....

Still more code?? :)

Melanie
diff -b -B -r -u ../balsa/src/balsa-app.h ./src/balsa-app.h
--- ../balsa/src/balsa-app.h	Tue Jul 10 16:45:59 2001
+++ ./src/balsa-app.h	Wed Jul 11 22:40:18 2001
@@ -200,6 +200,8 @@
     /* automatically close mailboxes after XX minutes */
     gboolean close_mailbox_auto;
     gint close_mailbox_timeout;
+	gint check_imap;
+	gint quiet_background_check;
 
     /* GUI settings */
     gint mw_width;
diff -b -B -r -u ../balsa/src/main-window.c ./src/main-window.c
--- ../balsa/src/main-window.c	Sat Jul  7 00:44:32 2001
+++ ./src/main-window.c	Wed Jul 11 22:42:21 2001
@@ -143,6 +143,8 @@
 /* dialogs */
 static void show_about_box(void);
 
+static int quiet_background_check=0;
+
 /* callbacks */
 static void send_outbox_messages_cb(GtkWidget *, gpointer data);
 
@@ -1426,10 +1428,13 @@
     g_return_if_fail(mbnode);
 
     if(mbnode->mailbox) {/* mailbox, not a folder */
+		if(balsa_app.check_imap || !LIBBALSA_IS_MAILBOX_IMAP(mbnode->mailbox))
+		{
 	gdk_threads_enter();
 	libbalsa_mailbox_check(mbnode->mailbox);
 	gdk_threads_leave();
     }
+    }
 }
 
 /*
@@ -1439,7 +1444,7 @@
 gint
 check_new_messages_auto_cb(gpointer data)
 {
-    check_new_messages_cb((GtkWidget *) NULL, data);
+    check_new_messages_real((GtkWidget *) NULL, data, TYPE_BACKGROUND);
 
     if (balsa_app.debug)
 	fprintf(stderr, "Auto-checked for new messages...\n");
@@ -1453,9 +1458,8 @@
    or NULL.
 */
 void
-check_new_messages_cb(GtkWidget * widget, gpointer data)
+check_new_messages_real(GtkWidget *widget, gpointer data, int type)
 {
-
 #ifdef BALSA_USE_THREADS
     /*  Only Run once -- If already checking mail, return.  */
     pthread_mutex_lock(&mailbox_lock);
@@ -1465,12 +1469,18 @@
 	return;
     }
     checking_mail = 1;
+
+	if(type == TYPE_CALLBACK)
+		quiet_background_check=0;
+	else
+		quiet_background_check=balsa_app.quiet_background_check;
+
     pthread_mutex_unlock(&mailbox_lock);
 
     fill_mailbox_passwords(balsa_app.inbox_input);
-    if (balsa_app.pwindow_option == WHILERETR ||
+    if (type == TYPE_CALLBACK && (balsa_app.pwindow_option == WHILERETR ||
 	(balsa_app.pwindow_option == UNTILCLOSED &&
-	 !(progress_dialog && GTK_IS_WIDGET(progress_dialog)))) {
+	 !(progress_dialog && GTK_IS_WIDGET(progress_dialog))))) {
 	if (progress_dialog && GTK_IS_WIDGET(progress_dialog))
 	    gtk_widget_destroy(GTK_WIDGET(progress_dialog));
 
@@ -1504,7 +1514,8 @@
 
     /* initiate threads */
     pthread_create(&get_mail_thread,
-		   NULL, (void *) &check_messages_thread, NULL);
+		NULL, (void *) &check_messages_thread, (void *)0);
+	
     /* Detach so we don't need to pthread_join
      * This means that all resources will be
      * reclaimed as soon as the thread exits
@@ -1522,6 +1533,12 @@
 #endif
 }
 
+void
+check_new_messages_cb(GtkWidget * widget, gpointer data)
+{
+	check_new_messages_real(widget, data, TYPE_CALLBACK);
+}
+
 /* send_outbox_messages_cb:
    tries again to send the messages queued in outbox.
 */
@@ -1551,10 +1568,11 @@
     MailThreadMessage *threadmessage;
 
     MSGMAILTHREAD(threadmessage, MSGMAILTHREAD_SOURCE, NULL, "POP3", 0, 0);
+	
     check_mailbox_list(balsa_app.inbox_input);
 
-    MSGMAILTHREAD(threadmessage, MSGMAILTHREAD_SOURCE, NULL, "Local Mail",
-		  0, 0);
+	MSGMAILTHREAD(threadmessage, MSGMAILTHREAD_SOURCE, NULL,
+		"Local Mail", 0, 0);
     libbalsa_notify_start_check();
 
     gtk_ctree_post_recursive(GTK_CTREE(balsa_app.mblist), NULL, 
@@ -1597,6 +1615,19 @@
     }
 
     currentpos = (MailThreadMessage **) msgbuffer;
+
+	if(quiet_background_check)
+	{
+		/* Eat messages */
+		while (count) {
+			threadmessage = *currentpos;
+			g_free(threadmessage);
+			currentpos++;
+			count -= sizeof(void *);
+		}
+		g_free(msgbuffer);
+		return TRUE;
+	}
 
     gdk_threads_enter();
 
diff -b -B -r -u ../balsa/src/main-window.h ./src/main-window.h
--- ../balsa/src/main-window.h	Tue Apr 10 11:09:47 2001
+++ ./src/main-window.h	Wed Jul 11 22:20:10 2001
@@ -28,6 +28,9 @@
 #define BALSA_IS_WINDOW(obj)		       (GTK_CHECK_TYPE (obj, BALSA_TYPE_WINDOW))
 #define BALSA_IS_WINDOW_CLASS(klass)	       (GTK_CHECK_CLASS_TYPE (klass, BALSA_TYPE_WINDOW))
 
+/* Type values for mailbox checking */
+#define TYPE_BACKGROUND 1
+#define TYPE_CALLBACK 2
 
 typedef struct _BalsaWindow BalsaWindow;
 typedef struct _BalsaWindowClass BalsaWindowClass;
@@ -63,6 +66,7 @@
 gboolean send_progress_notify_cb(void);
 gint check_new_messages_auto_cb(gpointer data);
 void check_new_messages_cb(GtkWidget *, gpointer data);
+void check_new_messages_real(GtkWidget *, gpointer data, int type);
 void empty_trash(void);
 
 /* functions to manipulate the progress bars of the window */
diff -b -B -r -u ../balsa/src/pref-manager.c ./src/pref-manager.c
--- ../balsa/src/pref-manager.c	Fri Jul  6 18:38:04 2001
+++ ./src/pref-manager.c	Wed Jul 11 22:44:05 2001
@@ -53,6 +53,8 @@
     GtkRadioButton *encoding_type[NUM_ENCODING_MODES];
     GtkWidget *check_mail_auto;
     GtkWidget *check_mail_minutes;
+	GtkWidget *quiet_background_check;
+	GtkWidget *check_imap;
 #ifdef BALSA_MDN_REPLY
     GtkWidget *mdn_reply_clean_menu, *mdn_reply_notclean_menu;
 #endif
@@ -316,6 +318,12 @@
     gtk_signal_connect(GTK_OBJECT(pui->check_mail_minutes), "changed",
 		       GTK_SIGNAL_FUNC(timer_modified_cb), property_box);
 
+    gtk_signal_connect(GTK_OBJECT(pui->quiet_background_check), "toggled",
+		       GTK_SIGNAL_FUNC(properties_modified_cb), property_box);
+
+    gtk_signal_connect(GTK_OBJECT(pui->check_imap), "toggled",
+		       GTK_SIGNAL_FUNC(properties_modified_cb), property_box);
+
     gtk_signal_connect(GTK_OBJECT(pui->close_mailbox_auto), "toggled",
 		       GTK_SIGNAL_FUNC(mailbox_timer_modified_cb), property_box);
 
@@ -500,6 +508,10 @@
     balsa_app.check_mail_timer =
 	gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON
 					 (pui->check_mail_minutes));
+	balsa_app.quiet_background_check =
+	GTK_TOGGLE_BUTTON(pui->quiet_background_check)->active;
+	balsa_app.check_imap =
+	GTK_TOGGLE_BUTTON(pui->check_imap)->active;
 #ifdef BALSA_MDN_REPLY
     menu_item = gtk_menu_get_active(GTK_MENU(pui->mdn_reply_clean_menu));
     balsa_app.mdn_reply_clean =
@@ -688,7 +700,12 @@
 				 balsa_app.check_mail_auto);
     gtk_spin_button_set_value(GTK_SPIN_BUTTON(pui->check_mail_minutes),
 			      (float) balsa_app.check_mail_timer);
-
+	gtk_toggle_button_set_active(
+				GTK_TOGGLE_BUTTON(pui->quiet_background_check),
+				balsa_app.quiet_background_check);
+	gtk_toggle_button_set_active(
+				GTK_TOGGLE_BUTTON(pui->check_imap),
+				balsa_app.check_imap);
 #ifdef BALSA_MDN_REPLY
     gtk_menu_set_active(GTK_MENU(pui->mdn_reply_clean_menu),
 			balsa_app.mdn_reply_clean);
@@ -1111,6 +1128,7 @@
 incoming_page(gpointer data)
 {
     GtkWidget *vbox1;
+    GtkWidget *vbox2;
     GtkWidget *frame15;
     GtkWidget *table7;
     GtkWidget *label33;
@@ -1132,9 +1150,11 @@
     gtk_container_set_border_width(GTK_CONTAINER(frame15), 5);
     gtk_box_pack_start(GTK_BOX(vbox1), frame15, FALSE, FALSE, 0);
 
+	vbox2 = vbox_in_container(frame15);
+
     table7 = gtk_table_new(2, 3, FALSE);
-    gtk_container_add(GTK_CONTAINER(frame15), table7);
-    gtk_container_set_border_width(GTK_CONTAINER(table7), 5);
+    gtk_container_add(GTK_CONTAINER(vbox2), table7);
+    gtk_container_set_border_width(GTK_CONTAINER(table7), 0);
 
     label33 = gtk_label_new(_("minutes"));
     gtk_table_attach(GTK_TABLE(table7), label33, 2, 3, 0, 1,
@@ -1152,6 +1172,16 @@
     gtk_table_attach(GTK_TABLE(table7), pui->check_mail_auto, 0, 1, 0, 1,
 		     (GtkAttachOptions) (GTK_FILL),
 		     (GtkAttachOptions) (0), 0, 0);
+
+	pui->check_imap = gtk_check_button_new_with_label(
+	_("Check IMAP mailboxes"));
+	gtk_box_pack_start(GTK_BOX(vbox2), pui->check_imap,
+			TRUE, FALSE, 0);
+
+	pui->quiet_background_check = gtk_check_button_new_with_label(
+	_("Do background check quietly (no messages in status bar)"));
+	gtk_box_pack_start(GTK_BOX(vbox2), pui->quiet_background_check,
+			TRUE, FALSE, 0);
 
     /* Quoted text regular expression */
     regex_frame = gtk_frame_new(_("Quoted Text"));
diff -b -B -r -u ../balsa/src/save-restore.c ./src/save-restore.c
--- ../balsa/src/save-restore.c	Tue Jul 10 16:45:59 2001
+++ ./src/save-restore.c	Wed Jul 11 22:41:28 2001
@@ -525,7 +525,8 @@
 	balsa_app.check_mail_timer = 10;
     if (balsa_app.check_mail_auto)
 	update_timer(TRUE, balsa_app.check_mail_timer);
-
+	balsa_app.check_imap=d_get_gint("CheckIMAP", 1);
+	balsa_app.quiet_background_check=d_get_gint("QuietBackgroundCheck", 0);
     gnome_config_pop_prefix();
 
 #ifdef BALSA_MDN_REPLY
@@ -746,6 +747,9 @@
     gnome_config_set_bool("OnStartup", balsa_app.check_mail_upon_startup);
     gnome_config_set_bool("Auto", balsa_app.check_mail_auto);
     gnome_config_set_int("AutoDelay", balsa_app.check_mail_timer);
+	gnome_config_set_int("CheckIMAP", balsa_app.check_imap);
+	gnome_config_set_int("QuietBackgroundCheck",
+				balsa_app.quiet_background_check);
 
     gnome_config_pop_prefix();
 


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