Commit 556aee75 authored by Thomas Roessler's avatar Thomas Roessler

IMAP postpone changes from Byrial Jensen.

parent 9f37deb6
......@@ -240,11 +240,12 @@ int mutt_buffy_check (int force)
else
last_imap_check = now;
}
#endif
/* update postponed count on force */
if (force && Postponed)
mutt_num_postponed ();
/* update postponed count as well, on force */
if (force)
mutt_update_num_postponed ();
#endif
/* fastest return if there are no mailboxes */
if (!Incoming)
......
......@@ -126,7 +126,6 @@ WHERE short HistSize;
WHERE short PagerContext;
WHERE short PagerIndexLines;
WHERE short PopPort;
WHERE short PostCount INITVAL(0);
WHERE short ReadInc;
WHERE short SendmailWait;
WHERE short Timeout;
......
......@@ -48,35 +48,59 @@ static struct mapping_t PostponeHelp[] = {
#endif /* _PGPPATH */
static time_t LastModify = 0;
static short PostCount = 0;
static CONTEXT *PostContext = NULL;
static short UpdateNumPostponed = 0;
int mutt_num_postponed (void)
/* Return the number of postponed messages.
* if force is 0, use a cached value if it is costly to get a fresh
* count (IMAP) - else check.
*/
int mutt_num_postponed (int force)
{
struct stat st;
CONTEXT ctx;
static time_t LastModify = 0;
static char *OldPostponed = NULL;
if (UpdateNumPostponed)
{
UpdateNumPostponed = 0;
force = 1;
}
if (Postponed != OldPostponed)
{
OldPostponed = Postponed;
LastModify = 0;
force = 1;
}
if (!Postponed)
return 0;
#ifdef USE_IMAP
/* LastModify is useless for IMAP */
if (Postponed && mx_is_imap (Postponed))
if (mx_is_imap (Postponed))
{
PostCount = imap_mailbox_check (Postponed, 0);
PostCount = (PostCount < 0) ? 0 : PostCount;
dprint(2, (debugfile,
"mutt_num_postponed: %d postponed IMAP messages found.\n", PostCount));
if (force)
{
PostCount = imap_mailbox_check (Postponed, 0);
PostCount = (PostCount < 0) ? 0 : PostCount;
dprint(2, (debugfile,
"mutt_num_postponed: %d postponed IMAP messages found.\n", PostCount));
}
return PostCount;
}
#endif
if (!Postponed || stat (Postponed, &st) == -1)
if (stat (Postponed, &st) == -1)
{
PostCount = 0;
LastModify = 0;
return (0);
}
}
if (S_ISDIR (st.st_mode))
{
......@@ -109,6 +133,11 @@ int mutt_num_postponed (void)
return (PostCount);
}
void mutt_update_num_postponed (void)
{
UpdateNumPostponed = 1;
}
static void post_entry (char *s, size_t slen, MUTTMENU *menu, int entry)
{
CONTEXT *ctx = (CONTEXT *) menu->data;
......
......@@ -238,7 +238,7 @@ int mutt_is_text_type (int, char *);
int mutt_is_valid_mailbox (const char *);
int mutt_multi_choice (char *prompt, char *letters);
int mutt_needs_mailcap (BODY *);
int mutt_num_postponed (void);
int mutt_num_postponed (int);
int mutt_parse_bind (BUFFER *, BUFFER *, unsigned long, BUFFER *);
int mutt_parse_exec (BUFFER *, BUFFER *, unsigned long, BUFFER *);
int mutt_parse_color (BUFFER *, BUFFER *, unsigned long, BUFFER *);
......@@ -263,6 +263,7 @@ int mutt_search_command (int, int);
int mutt_compose_menu (HEADER *, char *, size_t, HEADER *);
int mutt_thread_set_flag (HEADER *, int, int, int);
int mutt_user_is_recipient (HEADER *);
void mutt_update_num_postponed (void);
int mutt_view_attachment (FILE*, BODY *, int);
int mutt_wait_filter (pid_t);
int mutt_which_case (const char *);
......
......@@ -903,7 +903,8 @@ ci_send_message (int flags, /* send mode */
char *signmic = NULL;
#endif
if (!flags && !msg && quadoption (OPT_RECALL) != M_NO && mutt_num_postponed ())
if (!flags && !msg && quadoption (OPT_RECALL) != M_NO &&
mutt_num_postponed (1))
{
/* If the user is composing a new message, check to see if there
* are any postponed messages first.
......@@ -1204,9 +1205,8 @@ main_loop:
msg->content = mutt_remove_multipart (msg->content);
goto main_loop;
}
mutt_update_num_postponed ();
mutt_message _("Message postponed.");
PostCount++;
mutt_num_postponed ();
goto cleanup;
}
}
......
......@@ -176,7 +176,7 @@ status_format_str (char *buf, size_t buflen, char op, const char *src,
break;
case 'p':
count = PostCount;
count = mutt_num_postponed (0);
if (!optional)
{
snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment