X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=buffy.c;h=f6b2d4bd4d964c1d88c460fc15a1648c78c5801e;hp=28f88ace63b39b0e3597dfb581b24a41aa07acf6;hb=1dc7032b59cc5b91d70076ed228bda8caf65a7f3;hpb=c8ceef3ed6424dcb5a6ec835e7d8d9cc00595372 diff --git a/buffy.c b/buffy.c index 28f88ac..f6b2d4b 100644 --- a/buffy.c +++ b/buffy.c @@ -14,6 +14,9 @@ # include "config.h" #endif +#include +#include + #include "mutt.h" #include "buffy.h" #include "buffer.h" @@ -27,8 +30,6 @@ #include "imap.h" #endif -#include "lib/mem.h" -#include "lib/intl.h" #include #include @@ -170,8 +171,8 @@ void buffy_update_mailbox (BUFFY * b) /* func to free buffy for list_del() */ static void buffy_free (BUFFY** p) { - mem_free(&(*p)->path); - mem_free(p); + p_delete(&(*p)->path); + p_delete(p); } int buffy_lookup (const char* path) { @@ -220,7 +221,7 @@ int buffy_parse_mailboxes (BUFFER * path, BUFFER * s, unsigned long data, } if (i < 0) { - tmp = mem_calloc (1, sizeof (BUFFY)); + tmp = p_new(BUFFY, 1); tmp->path = str_dup (buf); tmp->magic = 0; list_push_back (&Incoming, tmp); @@ -260,7 +261,7 @@ int buffy_parse_mailboxes (BUFFER * path, BUFFER * s, unsigned long data, /* values for force: * 0 don't force any checks + update sidebar * 1 force all checks + update sidebar - * 2 force all checks + _don't_ update sidebar + * 2 don't force any checks + _don't_ update sidebar */ int buffy_check (int force) { @@ -277,7 +278,7 @@ int buffy_check (int force) time_t last2; /* update postponed count as well, on force */ - if (force != 0) + if (force == 1) mutt_update_num_postponed (); #endif @@ -294,11 +295,11 @@ int buffy_check (int force) return BuffyCount; last1 = BuffyTime; - if (force != 0 || now - BuffyTime >= BuffyTimeout) + if (force == 1 || now - BuffyTime >= BuffyTimeout) BuffyTime = now; #ifdef USE_IMAP last2 = ImapBuffyTime; - if (force != 0 || now - ImapBuffyTime >= ImapBuffyTimeout) + if (force == 1 || now - ImapBuffyTime >= ImapBuffyTimeout) ImapBuffyTime = now; #endif BuffyCount = 0; @@ -337,7 +338,7 @@ int buffy_check (int force) case M_MBOX: case M_MMDF: /* only check on force or $mail_check reached */ - if (force != 0 || (now - last1 >= BuffyTimeout)) { + if (force == 1 || (now - last1 >= BuffyTimeout)) { if (!count) { if (STAT_CHECK) { BuffyCount++; @@ -373,7 +374,7 @@ int buffy_check (int force) case M_MAILDIR: /* only check on force or $mail_check reached */ - if (force != 0 || (now - last1 >= BuffyTimeout)) { + if (force == 1 || (now - last1 >= BuffyTimeout)) { snprintf (path, sizeof (path), "%s/new", tmp->path); if ((dirp = opendir (path)) == NULL) { tmp->magic = 0; @@ -390,10 +391,11 @@ int buffy_check (int force) /* one new and undeleted message is enough */ if (tmp->new == 0) { BuffyCount++; - tmp->new = 1; - if (!count) + if (!count) { /* if sidebar invisible -> done */ + tmp->new = 1; break; + } } tmp->msgcount++; tmp->msg_unread++; @@ -431,7 +433,7 @@ int buffy_check (int force) case M_MH: /* only check on force or $mail_check reached */ - if (force != 0 || (now - last1 >= BuffyTimeout)) { + if (force == 1 || (now - last1 >= BuffyTimeout)) { if ((tmp->new = mh_buffy (tmp->path)) > 0) BuffyCount++; if (count) { @@ -461,16 +463,16 @@ int buffy_check (int force) #ifdef USE_IMAP case M_IMAP: /* only check on force or $imap_mail_check reached */ - if (force != 0 || (now - last2 >= ImapBuffyTimeout)) { + if (force == 1 || (now - last2 >= ImapBuffyTimeout)) { tmp->msgcount = imap_mailbox_check (tmp->path, 0); - if ((tmp->new = imap_mailbox_check (tmp->path, 1)) > 0) { + tmp->new = imap_mailbox_check (tmp->path, 1); + tmp->msg_unread = imap_mailbox_check (tmp->path, 2); + if (tmp->new > 0) BuffyCount++; - tmp->msg_unread = tmp->new; /* for sidebar; wtf? */ - } - else { + else tmp->new = 0; + if (tmp->msg_unread < 0) tmp->msg_unread = 0; - } } else if (tmp->new > 0) /* keep current stats if !force and !$imap_mail_check reached */