PATCH: IMAP server mail checking
- From: "M . Thielker" <balsa t-data com>
- To: Balsa List <balsa-list gnome org>
- Subject: PATCH: IMAP server mail checking
- Date: Fri, 13 Jul 2001 23:04:23 +0200
Hi,
after the comments to balsa-checkprefs.patch I went back into it and made
some changes.
This (final) version provides:
- selectable IMAP mailbox checking
- selectable checking of INBOX only
- suppression of progress indications when mail is received in the
background
- general behavior change: progress dialog box is _never_ displayed on
background mail checks
diff -b -B -r -u -P --exclude-from=ignore ../balsa/src/balsa-app.c ./src/balsa-app.c
--- ../balsa/src/balsa-app.c Thu Jul 12 13:53:01 2001
+++ ./src/balsa-app.c Fri Jul 13 22:23:35 2001
@@ -313,6 +313,10 @@
/* Tooltips */
balsa_app.tooltips = gtk_tooltips_new();
+
+ /* IMAP */
+ balsa_app.check_imap = 1;
+ balsa_app.check_imap_inbox = 0;
}
static gint
diff -b -B -r -u -P --exclude-from=ignore ../balsa/src/balsa-app.h ./src/balsa-app.h
--- ../balsa/src/balsa-app.h Thu Jul 12 13:53:01 2001
+++ ./src/balsa-app.h Fri Jul 13 22:22:29 2001
@@ -185,6 +185,9 @@
/* automatically close mailboxes after XX minutes */
gboolean close_mailbox_auto;
gint close_mailbox_timeout;
+ gint check_imap;
+ gint check_imap_inbox;
+ gint quiet_background_check;
/* GUI settings */
gint mw_width;
diff -b -B -r -u -P --exclude-from=ignore ../balsa/src/main-window.c ./src/main-window.c
--- ../balsa/src/main-window.c Thu Jul 12 13:53:02 2001
+++ ./src/main-window.c Fri Jul 13 22:52:23 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);
@@ -1439,14 +1441,34 @@
static void
mailbox_check_func(GtkCTree * ctree, GtkCTreeNode * node, gpointer data)
{
+ char *tmp;
+
BalsaMailboxNode *mbnode = gtk_ctree_node_get_row_data(ctree, node);
g_return_if_fail(mbnode);
if(mbnode->mailbox) {/* mailbox, not a folder */
+ if(balsa_app.check_imap || !LIBBALSA_IS_MAILBOX_IMAP(mbnode->mailbox))
+ {
+ if(LIBBALSA_IS_MAILBOX_IMAP(mbnode->mailbox))
+ {
+ tmp=LIBBALSA_MAILBOX_IMAP(mbnode->mailbox)->path;
+
+ /* Specs say there may be a {host:port} prefix */
+ /* Set the pointer to point past that to the real path */
+ if(strchr(tmp, '}'))
+ tmp=strchr(tmp, '}')+1;
+
+ /* My Cyrus IMAP server uses UPPERCASE for INBOX */
+ /* FIXME: Check if that's true for all IMAP servers */
+ if(balsa_app.check_imap_inbox &&
+ strcmp(tmp, "INBOX"))
+ return;
+ }
gdk_threads_enter();
libbalsa_mailbox_check(mbnode->mailbox);
gdk_threads_leave();
}
+ }
}
/*
@@ -1456,7 +1478,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");
@@ -1470,9 +1492,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);
@@ -1482,12 +1503,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));
@@ -1521,7 +1548,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
@@ -1539,6 +1567,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.
*/
@@ -1568,10 +1602,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,
@@ -1614,6 +1649,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 -P --exclude-from=ignore ../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 Fri Jul 13 22:15:27 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 -P --exclude-from=ignore ../balsa/src/pref-manager.c ./src/pref-manager.c
--- ../balsa/src/pref-manager.c Thu Jul 12 13:53:02 2001
+++ ./src/pref-manager.c Fri Jul 13 22:51:05 2001
@@ -53,6 +53,9 @@
GtkRadioButton *encoding_type[NUM_ENCODING_MODES];
GtkWidget *check_mail_auto;
GtkWidget *check_mail_minutes;
+ GtkWidget *quiet_background_check;
+ GtkWidget *check_imap;
+ GtkWidget *check_imap_inbox;
#ifdef BALSA_MDN_REPLY
GtkWidget *mdn_reply_clean_menu, *mdn_reply_notclean_menu;
#endif
@@ -154,6 +157,7 @@
static void wrap_modified_cb(GtkWidget * widget, GtkWidget * pbox);
static void spelling_optionmenu_cb(GtkItem * menuitem, gpointer data);
static void set_default_address_book_cb(GtkWidget * button, gpointer data);
+static void imap_toggled_cb(GtkWidget * widget, GtkWidget * pbox);
guint toolbar_type[NUM_TOOLBAR_MODES] = {
GTK_TOOLBAR_TEXT,
@@ -321,6 +325,15 @@
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(imap_toggled_cb), property_box);
+
+ gtk_signal_connect(GTK_OBJECT(pui->check_imap_inbox), "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);
@@ -508,6 +521,12 @@
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;
+ balsa_app.check_imap_inbox =
+ GTK_TOGGLE_BUTTON(pui->check_imap_inbox)->active;
#ifdef BALSA_MDN_REPLY
menu_item = gtk_menu_get_active(GTK_MENU(pui->mdn_reply_clean_menu));
balsa_app.mdn_reply_clean =
@@ -700,6 +719,19 @@
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);
+ gtk_toggle_button_set_active(
+ GTK_TOGGLE_BUTTON(pui->check_imap_inbox),
+ balsa_app.check_imap_inbox);
+ if(!balsa_app.check_imap)
+ gtk_widget_set_sensitive(
+ GTK_WIDGET(pui->check_imap_inbox),
+ FALSE);
#ifdef BALSA_MDN_REPLY
gtk_menu_set_active(GTK_MENU(pui->mdn_reply_clean_menu),
@@ -1125,6 +1157,8 @@
incoming_page(gpointer data)
{
GtkWidget *vbox1;
+ GtkWidget *vbox2;
+ GtkWidget *hbox1;
GtkWidget *frame15;
GtkWidget *table7;
GtkWidget *label33;
@@ -1146,9 +1180,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,
@@ -1167,6 +1203,24 @@
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
+ hbox1 = gtk_hbox_new(FALSE, 5);
+ gtk_box_pack_start(GTK_BOX(vbox2), hbox1,
+ TRUE, FALSE, 0);
+ pui->check_imap = gtk_check_button_new_with_label(
+ _("Check IMAP mailboxes"));
+ gtk_box_pack_start(GTK_BOX(hbox1), pui->check_imap,
+ FALSE, FALSE, 0);
+
+ pui->check_imap_inbox = gtk_check_button_new_with_label(
+ _("Check INBOX only"));
+ gtk_box_pack_start(GTK_BOX(hbox1), pui->check_imap_inbox,
+ FALSE, 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"));
gtk_container_set_border_width(GTK_CONTAINER(regex_frame), 5);
@@ -2067,3 +2121,20 @@
properties_modified_cb(widget, pbox);
}
+
+static void imap_toggled_cb(GtkWidget * widget, GtkWidget * pbox)
+{
+ properties_modified_cb(widget, pbox);
+
+ if(GTK_TOGGLE_BUTTON(pui->check_imap)->active)
+ {
+ gtk_widget_set_sensitive(GTK_WIDGET(pui->check_imap_inbox), TRUE);
+ }
+ else
+ {
+ gtk_toggle_button_set_active(
+ GTK_TOGGLE_BUTTON(pui->check_imap_inbox), FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(pui->check_imap_inbox), FALSE);
+ }
+}
+
diff -b -B -r -u -P --exclude-from=ignore ../balsa/src/save-restore.c ./src/save-restore.c
--- ../balsa/src/save-restore.c Thu Jul 12 13:53:02 2001
+++ ./src/save-restore.c Fri Jul 13 22:25:12 2001
@@ -526,7 +526,9 @@
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.check_imap_inbox=d_get_gint("CheckIMAPInbox", 0);
+ balsa_app.quiet_background_check=d_get_gint("QuietBackgroundCheck", 0);
gnome_config_pop_prefix();
#ifdef BALSA_MDN_REPLY
@@ -750,6 +752,10 @@
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("CheckIMAPInbox", balsa_app.check_imap_inbox);
+ 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]