Re: Wish list of features
- From: "M. Thielker" <balsa t-data com>
- To: Balsa List <balsa-list gnome org>
- Subject: Re: Wish list of features
- Date: Sat, 24 May 2003 09:08:03 +0200
Hello,
On 2003.05.23 23:30 Ed Murphy wrote:
> On 2003.05.23 14:03 Carlos Morgado wrote:
>
>>> * Option to display 'unread' and 'total' counts for all mailboxes, as
>>> soon
>> that's kind of hard, some mailboxes are very expensive and some are
>> downright impossible in some cases (think imap)
> People with expensive/impossible mailboxes should leave this option
> disabled. My mailboxes are fairly inexpensive, I think: about 20
> local mbox mailboxes, containing a total of several dozen messages.
I am still maintaining a private patch that does this for IMAP mailboxes.
If the IMAP server is local, as in my setup, this is very much possible and
feasible.
Since almost all my mailboxes are on IMAP, I never checked into doing this
for local mailboxes.
Also, an attempt to rework the patch for Balsa 2 resulted in something that
will apply cleanly, but will not work. I haven't had the time to figure out
why and there was no need because Balsa 2 is unusable for me.
Unless and until it's use of screen real estate gets much more efficient, I
can't use it.
We've had this before, the main issue is the vertical spacing in the
mailbox tree. I need to have all my mailboxes displayed, without a
scrollbar. With Balsa 2, that is impossible because 6 pixels per line are
wasted.
Since the patch adds to a function used to walk the tree at startup, it
could quite easily be disabled by a pref. The pref should, IMHO, be in the
mailbox properties, so it can be set on a per server basis for local
servers and be cleared for remote servers. The sensible default would be
clear.
One issue with my patch: when a mailbox is added or deleted, the counts for
all mailboxes will vanish. This seems to be a general problem not related
to the patch, only since the patch makes the counts display, it becomes
more obvious with it applied.
I never bothered to fix it because adding a mailbox is an infrequent action.
I am attaching the patch for whoever may find it useful, it should apply to
current 1.4.x CVS.
Melanie
diff -b -B -r -u -P --exclude-from=ignore ../balsa/libbalsa/mailbox_imap.c ./libbalsa/mailbox_imap.c
--- ../balsa/libbalsa/mailbox_imap.c Thu Jan 9 20:04:29 2003
+++ ./libbalsa/mailbox_imap.c Thu Jan 9 20:06:16 2003
@@ -757,9 +757,48 @@
static void
libbalsa_mailbox_imap_check(LibBalsaMailbox * mailbox)
{
+ LibBalsaServer *server;
+ char *tmppath;
+
if(mailbox->open_ref == 0) {
+ /* Formerly there was no functionality on closed mailboxes */
+ /* now we issue a status request to determine the number */
+ /* of messages in the mailbox for display */
+
+ server=LIBBALSA_MAILBOX_REMOTE(mailbox)->server;
+ if(!CLIENT_CONTEXT_OPEN(mailbox))
+ {
+ /* It has in fact not been opened yet */
+ if(server != NULL)
+ {
+ if (!(server->passwd && *server->passwd) &&
+ !(server->passwd =
+ libbalsa_server_get_password(server, mailbox)))
+ {
+ if (libbalsa_notify_check_mailbox(mailbox) )
+ libbalsa_mailbox_set_unread_messages_flag(
+ mailbox, TRUE);
+ return;
+ }
+
+ reset_mutt_passwords(server);
+
+ /* Now we have a connection, even though the mailbox */
+ /* itself is NOT open. That's enough for a STATUS */
+ tmppath=g_malloc(strlen(server->host)+10+
+ strlen(LIBBALSA_MAILBOX_IMAP(mailbox)->path));
+ sprintf(tmppath, "{%s}%s", server->host,
+ LIBBALSA_MAILBOX_IMAP(mailbox)->path);
+ imap_check_mailbox_counts(tmppath,
+ &mailbox->messages, &mailbox->unread_messages);
+ g_free(tmppath);
+ }
+ }
+ mailbox->total_messages=mailbox->messages;
if (libbalsa_notify_check_mailbox(mailbox) )
libbalsa_mailbox_set_unread_messages_flag(mailbox, TRUE);
+ else
+ libbalsa_mailbox_set_unread_messages_flag(mailbox, FALSE);
} else {
gint i = 0;
long newmsg, timeout;
@@ -796,6 +835,8 @@
UNLOCK_MAILBOX(mailbox);
}
}
+ if(mailbox->unread_messages)
+ mailbox->has_unread_messages=1;
}
typedef void(*ImapSearchFunc)(unsigned, void*);
diff -b -B -r -u -P --exclude-from=ignore ../balsa/libmutt/imap/imap.c ./libmutt/imap/imap.c
--- ../balsa/libmutt/imap/imap.c Sun Dec 8 10:56:47 2002
+++ ./libmutt/imap/imap.c Thu Jan 9 20:06:16 2003
@@ -1234,7 +1234,7 @@
mutt_bit_isset(idata->capabilities,STATUS))
{
snprintf (buf, sizeof (buf), "STATUS %s (%s)", mbox,
- new ? "RECENT" : "MESSAGES");
+ new ? "UNSEEN" : "MESSAGES");
}
else
/* Server does not support STATUS, and this is not the current mailbox.
@@ -1276,6 +1276,98 @@
while (rc == IMAP_CMD_CONTINUE);
return msgcount;
+}
+
+int imap_check_mailbox_counts(char *path, long *messages, long *unread)
+{
+ CONNECTION *conn;
+ IMAP_DATA *idata;
+ char buf[LONG_STRING];
+ char mbox[LONG_STRING];
+ char mbox_unquoted[LONG_STRING];
+ char *s;
+ int msgcount = 0, newcount = 0;
+ int connflags = 0;
+ IMAP_MBOX mx;
+ int rc;
+
+ if (imap_parse_path (path, &mx))
+ {
+ printf("Bad path\n");
+ return -1;
+ }
+
+ if (!(idata = imap_conn_find (&(mx.account), connflags)))
+ {
+ printf("No connection\n");
+ FREE (&mx.mbox);
+ return -1;
+ }
+ conn = idata->conn;
+
+ imap_fix_path (idata, mx.mbox, buf, sizeof (buf));
+ FREE (&mx.mbox);
+
+ imap_munge_mbox_name (mbox, sizeof(mbox), buf);
+ strfcpy (mbox_unquoted, buf, sizeof (mbox_unquoted));
+
+ /* The draft IMAP implementor's guide warns againts using the STATUS
+ * command on a mailbox that you have selected
+ */
+
+ if (mutt_strcmp (mbox_unquoted, idata->mailbox) == 0
+ || (mutt_strcasecmp (mbox_unquoted, "INBOX") == 0
+ && mutt_strcasecmp (mbox_unquoted, idata->mailbox) == 0))
+ {
+ strfcpy (buf, "NOOP", sizeof (buf));
+ }
+ else if (mutt_bit_isset(idata->capabilities,IMAP4REV1) ||
+ mutt_bit_isset(idata->capabilities,STATUS))
+ {
+ snprintf (buf, sizeof (buf), "STATUS %s (MESSAGES UNSEEN)", mbox);
+ }
+ else
+ /* Server does not support STATUS, and this is not the current mailbox.
+ * There is no lightweight way to check recent arrivals */
+ return -1;
+
+ imap_cmd_start (idata, buf);
+
+ do
+ {
+ if ((rc = imap_cmd_step (idata)) != IMAP_CMD_CONTINUE)
+ break;
+
+ s = imap_next_word (idata->cmd.buf);
+ if (ascii_strncasecmp ("STATUS", s, 6) == 0)
+ {
+ s = imap_next_word (s);
+ /* The mailbox name may or may not be quoted here. We could try to
+ * munge the server response and compare with quoted (or vise versa)
+ * but it is probably more efficient to just strncmp against both. */
+ if(mutt_strncmp(mbox_unquoted, s, mutt_strlen(mbox_unquoted)) == 0
+ || mutt_strncmp(mbox, s, mutt_strlen(mbox)) == 0)
+ {
+ s = imap_next_word (s);
+ s = imap_next_word (s);
+ if (isdigit (*s))
+ {
+ msgcount = atoi(s);
+ }
+ s = imap_next_word (s);
+ s = imap_next_word (s);
+ if (isdigit (*s))
+ {
+ newcount = atoi(s);
+ }
+ }
+ }
+ }
+ while (rc == IMAP_CMD_CONTINUE);
+
+ *messages=msgcount;
+ *unread=newcount;
+ return msgcount;
}
/* all this listing/browsing is a mess. I don't like that name is a pointer
diff -b -B -r -u -P --exclude-from=ignore ../balsa/libmutt/imap/imap.h ./libmutt/imap/imap.h
--- ../balsa/libmutt/imap/imap.h Thu Jan 9 20:04:31 2003
+++ ./libmutt/imap/imap.h Thu Jan 9 20:06:16 2003
@@ -49,6 +49,7 @@
#endif
int imap_subscribe (const char *path, int subscribe);
int imap_complete (char* dest, size_t dlen, char* path);
+int imap_check_mailbox_counts(char *path, long *, long *);
void imap_allow_reopen (CONTEXT *ctx);
void imap_disallow_reopen (CONTEXT *ctx);
diff -b -B -r -u -P --exclude-from=ignore ../balsa/src/balsa-mblist.c ./src/balsa-mblist.c
--- ../balsa/src/balsa-mblist.c Sun Dec 8 10:56:49 2002
+++ ./src/balsa-mblist.c Thu Jan 9 20:06:16 2003
@@ -1008,7 +1008,9 @@
}
/* We only want to do this if the mailbox is open, otherwise leave
* the message numbers untouched in the display */
- if (mblist->display_info && mailbox->open_ref &&
+ if (mblist->display_info &&
+ (mailbox->open_ref ||
+ LIBBALSA_IS_MAILBOX_IMAP(mailbox)) &&
(mailbox->total_messages >= 0) ) {
if (mailbox->total_messages > 0) {
text = g_strdup_printf("%ld", mailbox->total_messages);
diff -b -B -r -u -P --exclude-from=ignore ../balsa/src/main-window.c ./src/main-window.c
--- ../balsa/src/main-window.c Thu Jan 9 20:04:34 2003
+++ ./src/main-window.c Thu Jan 9 20:06:16 2003
@@ -97,6 +97,7 @@
GtkWidget *progress_dialog_bar = NULL;
GSList *list = NULL;
static gint new_mail_dialog_visible = FALSE;
+static gint enable_new_mail_notify = FALSE;
static int quiet_check=0;
static void check_messages_thread(gpointer data);
@@ -135,7 +136,10 @@
static void check_mailbox_list(GList * list);
static void mailbox_check_func(GtkCTree * ctree, GtkCTreeNode * node,
gpointer data);
+static void imap_check_func(GtkCTree * ctree, GtkCTreeNode * node,
+ gpointer data);
static gboolean imap_check_test(const gchar * path);
+static gboolean imap_check_always(const gchar * path);
static void enable_mailbox_menus(BalsaMailboxNode * mbnode);
static void enable_message_menus(LibBalsaMessage * message);
@@ -1639,6 +1643,12 @@
}
}
+static gboolean
+imap_check_always(const gchar * path)
+{
+ return 1;
+}
+
/*
* Callback for testing whether to check an IMAP mailbox
* Called from mutt_buffy_check
@@ -2102,6 +2112,12 @@
GtkDialog *dlg;
GtkWidget *label, *ok_button, *vbox;
+ if(!enable_new_mail_notify)
+ {
+ enable_new_mail_notify = TRUE;
+ return;
+ }
+
if(num_new == 0)
return;
@@ -3350,3 +3366,61 @@
balsa_message_set_wrap(BALSA_MESSAGE(balsa_app.main_window->preview),
balsa_app.browse_wrap);
}
+
+void
+check_imap_counts(void)
+{
+ int save_background_check;
+
+ /* Only Run once -- If already checking mail, return. */
+ pthread_mutex_lock(&mailbox_lock);
+ if (checking_mail) {
+ pthread_mutex_unlock(&mailbox_lock);
+ fprintf(stderr, "Already Checking Mail!\n");
+ return;
+ }
+ checking_mail = 1;
+
+ save_background_check=balsa_app.quiet_background_check;
+ balsa_app.quiet_background_check=1;
+
+ pthread_mutex_unlock(&mailbox_lock);
+
+ libbalsa_notify_start_check(imap_check_always);
+
+ gtk_ctree_post_recursive(GTK_CTREE(balsa_app.mblist), NULL,
+ imap_check_func, NULL);
+
+ balsa_mblist_have_new(balsa_app.mblist);
+ balsa_app.quiet_background_check=save_background_check;
+
+ checking_mail = 0;
+}
+
+static void
+imap_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)
+ {
+ if(LIBBALSA_IS_MAILBOX_IMAP(mbnode->mailbox))
+ {
+ tmp=LIBBALSA_MAILBOX_IMAP(mbnode->mailbox)->path;
+
+ if(strchr(tmp, '}'))
+ tmp=strchr(tmp, '}')+1;
+ }
+ gdk_threads_enter();
+ libbalsa_mailbox_check(mbnode->mailbox);
+ gdk_threads_leave();
+ }
+ }
+ enable_new_mail_notify=TRUE;
+}
+
+
diff -b -B -r -u -P --exclude-from=ignore ../balsa/src/main-window.h ./src/main-window.h
--- ../balsa/src/main-window.h Thu Jun 6 08:29:00 2002
+++ ./src/main-window.h Thu Jan 9 20:06:16 2003
@@ -78,6 +78,7 @@
gboolean mail_progress_notify_cb(void);
gboolean send_progress_notify_cb(void);
gint check_new_messages_auto_cb(gpointer data);
+void check_imap_counts(void);
void check_new_messages_cb(GtkWidget *, gpointer data);
void check_new_messages_real(GtkWidget *, gpointer data, int type);
void empty_trash(void);
diff -b -B -r -u -P --exclude-from=ignore ../balsa/src/main.c ./src/main.c
--- ../balsa/src/main.c Sun Dec 8 10:56:50 2002
+++ ./src/main.c Thu Jan 9 20:06:16 2003
@@ -409,6 +409,8 @@
if (cmd_check_mail_on_startup || balsa_app.check_mail_upon_startup)
check_new_messages_cb(NULL, NULL);
+ else
+ check_imap_counts();
if (cmd_open_unread_mailbox || balsa_app.open_unread_mailbox)
gtk_idle_add((GtkFunction) initial_open_unread_mailboxes, NULL);
@@ -559,6 +561,8 @@
argv[argc] = g_strdup("--open-unread-mailbox");
argc++;
}
+
+ mblist_open_mailbox(balsa_app.inbox);
if (balsa_app.check_mail_upon_startup) {
argv[argc] = g_strdup("--checkmail");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]