2 * Copyright notice from original mutt:
3 * Copyright (C) 1996-2002 Michael R. Elkins <me@mutt.org>
4 * Copyright (C) 1999-2000 Thomas Roessler <roessler@does-not-exist.org>
6 * This file is part of mutt-ng, see http://www.muttng.org/.
7 * It's licensed under the GNU General Public License,
8 * please see the file GPL in the top level source directory.
11 #include <lib-lib/lib-lib.h>
15 #include <lib-lua/lib-lua.h>
16 #include <lib-sys/unix.h>
17 #include <lib-mime/mime.h>
18 #include <lib-ui/lib-ui.h>
33 #include <imap/imap.h>
36 #define MAXLOCKATTEMPT 5
38 static mx_t const *mxfmts[] = {
47 #define MX_IDX(idx) (idx >= 0 && idx < countof(mxfmts))
48 #define mutt_is_spool(s) (m_strcmp(Spoolfile, s) == 0)
50 static int dotlock_file(const char *path, int retry)
52 char lockfile[_POSIX_PATH_MAX];
53 snprintf(lockfile, sizeof(lockfile), "%s.lock", path);
55 if (lockfile_create(lockfile, retry ? 1 : 0, 0)) {
57 mutt_error (_("Can't dotlock %s.\n"), lockfile);
62 static int undotlock_file (const char *path)
64 char lockfile[_POSIX_PATH_MAX];
65 snprintf(lockfile, sizeof(lockfile), "%s.lock", path);
66 return lockfile_remove(lockfile);
69 /* looks up index of type for path in mxfmts */
70 static int mx_get_idx (const char* path) {
74 /* first, test all non-local folders to avoid stat() call */
75 for (i = 0; i < countof(mxfmts); i++) {
76 if (!mxfmts[i]->local)
77 t = mxfmts[i]->mx_is_magic(path, NULL);
81 if (stat (path, &st) == 0) {
82 /* if stat() succeeded, keep testing until success and
83 * pass stat() info so that we only need to do it once */
84 for (i = 0; i < countof(mxfmts); i++) {
86 t = mxfmts[i]->mx_is_magic(path, &st);
95 * excl if excl != 0, request an exclusive lock
96 * time_out should retry locking?
98 int mx_lock_file(const char *path, int fd, int excl, int time_out)
100 int count = 0, attempt = 0;
102 .l_type = excl ? F_WRLCK : F_RDLCK,
103 .l_whence = SEEK_SET,
106 if (dotlock_file(path, time_out) < 0)
109 while (fcntl(fd, F_SETLK, &lck) == -1) {
110 if (errno != EAGAIN && errno != EACCES) {
111 mutt_perror("fcntl");
115 if (++count >= (time_out ? MAXLOCKATTEMPT : 0)) {
117 mutt_error _("Timeout exceeded while attempting fcntl lock!");
120 mutt_message(_("Waiting for fcntl lock... %d"), ++attempt);
126 undotlock_file(path);
130 int mx_unlock_file(const char *path, int fd)
132 struct flock unlockit;
134 p_clear(&unlockit, 1);
135 unlockit.l_type = F_UNLCK;
136 unlockit.l_whence = SEEK_SET;
137 fcntl(fd, F_SETLK, &unlockit);
138 undotlock_file(path);
142 /* try to figure out what type of mailbox ``path'' is */
143 int mx_get_magic (const char *path) {
146 if (m_strlen(path) == 0)
148 if ((i = mx_get_idx (path)) >= 0)
149 return mxfmts[i]->type;
153 int mx_is_local (int m) {
156 return mxfmts[m]->local;
159 /* mx_access: Wrapper for access, checks permissions on a given mailbox.
160 * We may be interested in using ACL-style flags at some point, currently
161 * we use the normal access() flags. */
162 int mx_access (const char *path, int flags)
166 if ((i = mx_get_idx (path)) >= 0 && mxfmts[i]->mx_access)
167 return mxfmts[i]->mx_access(path,flags);
171 static int mx_open_mailbox_append (CONTEXT * ctx, int flags)
175 /* special case for appending to compressed folders -
176 * even if we can not open them for reading */
177 if (mutt_can_append_compressed (ctx->path))
178 mutt_open_append_compressed (ctx);
182 if (mx_get_magic (ctx->path) == M_IMAP)
183 return imap_open_mailbox_append (ctx);
185 if (stat (ctx->path, &sb) == 0) {
186 ctx->magic = mx_get_magic (ctx->path);
188 switch (ctx->magic) {
190 mutt_error (_("%s is not a mailbox."), ctx->path);
195 } else if (errno == ENOENT) {
196 int len = m_strlen(ctx->path);
197 if (len > 0 && ctx->path[len - 1] == '/') {
198 char tmp[_POSIX_PATH_MAX];
200 if (mkdir (ctx->path, S_IRWXU)) {
201 mutt_perror (ctx->path);
205 snprintf (tmp, sizeof (tmp), "%s/cur", ctx->path);
206 if (mkdir (tmp, S_IRWXU)) {
212 snprintf (tmp, sizeof (tmp), "%s/new", ctx->path);
213 if (mkdir (tmp, S_IRWXU)) {
215 snprintf (tmp, sizeof (tmp), "%s/cur", ctx->path);
220 snprintf (tmp, sizeof (tmp), "%s/tmp", ctx->path);
221 if (mkdir (tmp, S_IRWXU)) {
223 snprintf (tmp, sizeof (tmp), "%s/cur", ctx->path);
225 snprintf (tmp, sizeof (tmp), "%s/new", ctx->path);
230 ctx->magic = M_MAILDIR;
235 mutt_perror (ctx->path);
239 if (ctx->magic == M_MBOX) {
240 if (!(ctx->fp = safe_fopen(ctx->path, flags & M_NEWFOLDER ? "w" : "a"))) {
241 mutt_perror(ctx->path);
244 if (mbox_lock_mailbox(ctx, 1, 1) != 0) {
245 mutt_error(_("Couldn't lock %s\n"), ctx->path);
249 fseeko(ctx->fp, 0, 2);
255 * open a mailbox and parse it
258 * flags M_NOSORT do not sort mailbox
259 * M_APPEND open mailbox for appending
260 * M_READONLY open mailbox in read-only mode
261 * M_QUIET only print error messages
262 * ctx if non-null, context struct to use
264 CONTEXT *mx_open_mailbox (const char *path, int flags, CONTEXT * pctx)
270 ctx = p_new(CONTEXT, 1);
272 ctx->path = m_strdup(path);
274 ctx->msgnotreadyet = -1;
279 if (flags & M_READONLY)
284 if (flags & (M_APPEND | M_NEWFOLDER)) {
285 if (mx_open_mailbox_append (ctx, flags) != 0) {
286 mx_fastclose_mailbox (ctx);
294 if (!MX_IDX(ctx->magic-1))
295 ctx->magic = mx_get_magic (path);
297 if (ctx->magic == M_COMPRESSED)
298 mutt_open_read_compressed (ctx);
301 mutt_error (_("%s is not a mailbox."), path);
303 if (ctx->magic == -1)
306 if (ctx->magic <= 0) {
307 mx_fastclose_mailbox (ctx);
313 /* if the user has a `push' command in their .muttrc, or in a folder-hook,
314 * it will cause the progress messages not to be displayed because
315 * mutt_refresh() will think we are in the middle of a macro. so set a
316 * flag to indicate that we should really refresh the screen.
318 set_option (OPTFORCEREFRESH);
321 mutt_message (_("Reading %s..."), ctx->path);
323 rc = mxfmts[ctx->magic-1]->mx_open_mailbox(ctx);
326 if ((flags & M_NOSORT) == 0) {
327 /* avoid unnecessary work since the mailbox is completely unthreaded
329 unset_option (OPTSORTSUBTHREADS);
330 unset_option (OPTNEEDRESCORE);
331 mutt_sort_headers (ctx, 1);
337 mx_fastclose_mailbox (ctx);
342 unset_option (OPTFORCEREFRESH);
346 /* free up memory associated with the mailbox context */
347 void mx_fastclose_mailbox (CONTEXT * ctx)
354 if (MX_IDX(ctx->magic-1) && mxfmts[ctx->magic-1]->mx_fastclose_mailbox)
355 mxfmts[ctx->magic-1]->mx_fastclose_mailbox(ctx);
357 hash_delete (&ctx->subj_hash, NULL);
359 hash_delete (&ctx->id_hash, NULL);
360 mutt_clear_threads (ctx);
361 for (i = 0; i < ctx->msgcount; i++)
362 header_delete(&ctx->hdrs[i]);
363 p_delete(&ctx->hdrs);
367 mutt_fast_close_compressed (ctx);
369 p_delete(&ctx->path);
370 p_delete(&ctx->pattern);
371 pattern_list_wipe(&ctx->limit_pattern);
376 /* save changes to disk */
377 static int sync_mailbox (CONTEXT * ctx, int *index_hint)
382 mutt_message (_("Writing %s..."), ctx->path);
384 if (MX_IDX(ctx->magic-1))
385 /* the 1 is only of interest for IMAP and means EXPUNGE */
386 rc = mxfmts[ctx->magic-1]->mx_sync_mailbox(ctx,1,index_hint);
388 if (rc == 0 && ctx->cinfo)
389 return mutt_sync_compressed (ctx);
394 /* move deleted mails to the trash folder */
395 static int trash_append (CONTEXT * ctx)
401 if (!TrashPath || !ctx->deleted ||
402 (ctx->magic == M_MAILDIR && option (OPTMAILDIRTRASH)))
405 for (; i < ctx->msgcount && (!ctx->hdrs[i]->deleted ||
406 ctx->hdrs[i]->appended); i++);
407 if (i == ctx->msgcount)
408 return 0; /* nothing to be done */
410 if (mutt_save_confirm (TrashPath, &st) != 0) {
411 mutt_error _("message(s) not deleted");
416 if (lstat (ctx->path, &stc) == 0 && stc.st_ino == st.st_ino
417 && stc.st_dev == st.st_dev && stc.st_rdev == st.st_rdev)
418 return 0; /* we are in the trash folder: simple sync */
420 if ((ctx_trash = mx_open_mailbox (TrashPath, M_APPEND, NULL)) != NULL) {
421 for (i = 0; i < ctx->msgcount; i++)
422 if (ctx->hdrs[i]->deleted && !ctx->hdrs[i]->appended
423 && !ctx->hdrs[i]->purged
424 && mutt_append_message (ctx_trash, ctx, ctx->hdrs[i], 0, 0) == -1) {
425 mx_close_mailbox (ctx_trash, NULL);
429 mx_close_mailbox (ctx_trash, NULL);
432 mutt_error _("Can't open trash folder");
440 /* save changes and close mailbox */
441 static int _mx_close_mailbox (CONTEXT * ctx, int *index_hint)
443 int i, move_messages = 0, purge = 1, read_msgs = 0;
447 char mbox[_POSIX_PATH_MAX];
455 if (ctx->readonly || ctx->dontwrite) {
456 /* mailbox is readonly or we don't want to write */
457 mx_fastclose_mailbox (ctx);
462 /* mailbox was opened in write-mode */
463 if (ctx->magic == M_MBOX)
464 mbox_close_mailbox (ctx);
466 mx_fastclose_mailbox (ctx);
470 for (i = 0; i < ctx->msgcount; i++) {
471 if (!ctx->hdrs[i]->deleted && ctx->hdrs[i]->read
472 && !(ctx->hdrs[i]->flagged && option (OPTKEEPFLAGGED)))
476 if (read_msgs && quadoption (OPT_MOVE) != M_NO) {
477 m_strcpy(mbox, sizeof(mbox), NONULL(Inbox));
478 isSpool = mutt_is_spool (ctx->path) && !mutt_is_spool (mbox);
479 mutt_expand_path (mbox, sizeof (mbox));
482 snprintf (buf, sizeof (buf), _("Move read messages to %s?"), mbox);
483 if ((move_messages = query_quadoption (OPT_MOVE, buf)) == -1) {
491 * There is no point in asking whether or not to purge if we are
492 * just marking messages as "trash".
494 if (ctx->deleted && !(ctx->magic == M_MAILDIR && option (OPTMAILDIRTRASH))) {
495 snprintf (buf, sizeof (buf), ctx->deleted == 1
496 ? _("Purge %d deleted message?") :
497 _("Purge %d deleted messages?"), ctx->deleted);
498 if ((purge = query_quadoption (OPT_DELETE, buf)) < 0) {
504 /* IMAP servers manage the OLD flag themselves */
505 if (ctx->magic != M_IMAP)
506 if (option (OPTMARKOLD)) {
507 for (i = 0; i < ctx->msgcount; i++) {
508 if (!ctx->hdrs[i]->deleted && !ctx->hdrs[i]->old)
509 mutt_set_flag (ctx, ctx->hdrs[i], M_OLD, 1);
514 mutt_message (_("Moving read messages to %s..."), mbox);
516 /* try to use server-side copy first */
519 if (ctx->magic == M_IMAP && imap_is_magic (mbox, NULL) == M_IMAP) {
520 /* tag messages for moving, and clear old tags, if any */
521 for (i = 0; i < ctx->msgcount; i++)
522 if (ctx->hdrs[i]->read && !ctx->hdrs[i]->deleted
523 && !(ctx->hdrs[i]->flagged && option (OPTKEEPFLAGGED)))
524 ctx->hdrs[i]->tagged = 1;
526 ctx->hdrs[i]->tagged = 0;
528 i = imap_copy_messages (ctx, NULL, mbox, 1);
531 if (i == 0) /* success */
533 else if (i == -1) { /* horrible error, bail */
537 else /* use regular append-copy mode */
539 if (mx_open_mailbox (mbox, M_APPEND, &f) == NULL) {
544 for (i = 0; i < ctx->msgcount; i++) {
545 if (ctx->hdrs[i]->read && !ctx->hdrs[i]->deleted
546 && !(ctx->hdrs[i]->flagged && option (OPTKEEPFLAGGED))) {
547 if (mutt_append_message (&f, ctx, ctx->hdrs[i], 0, CH_UPDATE_LEN) ==
549 mutt_set_flag (ctx, ctx->hdrs[i], M_DELETE, 1);
550 mutt_set_flag (ctx, ctx->hdrs[i], M_APPENDED, 1);
553 mx_close_mailbox (&f, NULL);
560 mx_close_mailbox (&f, NULL);
564 else if (!ctx->changed && ctx->deleted == 0) {
565 mutt_message _("Mailbox is unchanged.");
567 mx_fastclose_mailbox (ctx);
571 /* copy mails to the trash before expunging */
572 if (purge && ctx->deleted)
573 if (trash_append (ctx) != 0) {
578 /* allow IMAP to preserve the deleted flag across sessions */
579 if (ctx->magic == M_IMAP) {
580 if ((check = imap_sync_mailbox (ctx, purge, index_hint)) != 0) {
588 for (i = 0; i < ctx->msgcount; i++)
589 ctx->hdrs[i]->deleted = 0;
593 if (ctx->changed || ctx->deleted) {
594 if ((check = sync_mailbox (ctx, index_hint)) != 0) {
602 mutt_message (_("%d kept, %d moved, %d deleted."),
603 ctx->msgcount - ctx->deleted, read_msgs, ctx->deleted);
605 mutt_message (_("%d kept, %d deleted."),
606 ctx->msgcount - ctx->deleted, ctx->deleted);
608 if (ctx->cinfo && mutt_slow_close_compressed (ctx))
611 mx_fastclose_mailbox (ctx);
616 int mx_close_mailbox (CONTEXT * ctx, int *index_hint) {
620 ret = _mx_close_mailbox (ctx, index_hint);
621 sidebar_set_buffystats (ctx);
625 /* update a Context structure's internal tables. */
627 void mx_update_tables (CONTEXT * ctx, int committing)
631 /* update memory to reflect the new state of the mailbox */
640 #define this_body ctx->hdrs[j]->content
641 for (i = 0, j = 0; i < ctx->msgcount; i++) {
642 if ((committing && (!ctx->hdrs[i]->deleted ||
643 (ctx->magic == M_MAILDIR
644 && option (OPTMAILDIRTRASH)))) || (!committing
648 ctx->hdrs[j] = ctx->hdrs[i];
651 ctx->hdrs[j]->msgno = j;
652 if (ctx->hdrs[j]->virtual != -1) {
653 ctx->v2r[ctx->vcount] = j;
654 ctx->hdrs[j]->virtual = ctx->vcount++;
655 ctx->vsize += this_body->length + this_body->offset -
656 this_body->hdr_offset;
660 ctx->hdrs[j]->changed = 0;
661 else if (ctx->hdrs[j]->changed)
665 || (ctx->magic == M_MAILDIR && option (OPTMAILDIRTRASH))) {
666 if (ctx->hdrs[j]->deleted)
670 if (ctx->hdrs[j]->tagged)
672 if (ctx->hdrs[j]->flagged)
674 if (!ctx->hdrs[j]->read) {
676 if (!ctx->hdrs[j]->old)
683 if (ctx->magic == M_MH || ctx->magic == M_MAILDIR)
684 ctx->size -= (ctx->hdrs[i]->content->length +
685 ctx->hdrs[i]->content->offset -
686 ctx->hdrs[i]->content->hdr_offset);
687 /* remove message from the hash tables */
688 if (ctx->subj_hash && ctx->hdrs[i]->env->real_subj)
689 hash_remove (ctx->subj_hash, ctx->hdrs[i]->env->real_subj,
691 if (ctx->id_hash && ctx->hdrs[i]->env->message_id)
692 hash_remove (ctx->id_hash, ctx->hdrs[i]->env->message_id,
694 header_delete(&ctx->hdrs[i]);
700 /* update sidebar count */
701 sidebar_set_buffystats (ctx);
705 /* save changes to mailbox
711 static int _mx_sync_mailbox (CONTEXT * ctx, int *index_hint)
715 int msgcount, deleted;
717 if (ctx->dontwrite) {
718 char buf[STRING], tmp[STRING];
720 if (km_expand_key (buf, sizeof (buf),
721 km_find_func (MENU_MAIN, OP_TOGGLE_WRITE)))
722 snprintf (tmp, sizeof (tmp), _(" Press '%s' to toggle write"), buf);
724 m_strcpy(tmp, sizeof(tmp), _("Use 'toggle-write' to re-enable write!"));
726 mutt_error (_("Mailbox is marked unwritable. %s"), tmp);
729 else if (ctx->readonly) {
730 mutt_error _("Mailbox is read-only.");
735 if (!ctx->changed && !ctx->deleted) {
736 mutt_message _("Mailbox is unchanged.");
744 snprintf (buf, sizeof (buf), ctx->deleted == 1
745 ? _("Purge %d deleted message?") :
746 _("Purge %d deleted messages?"), ctx->deleted);
747 if ((purge = query_quadoption (OPT_DELETE, buf)) < 0)
749 else if (purge == M_NO) {
751 return 0; /* nothing to do! */
752 /* let IMAP servers hold on to D flags */
753 if (ctx->magic != M_IMAP)
755 for (i = 0; i < ctx->msgcount; i++)
756 ctx->hdrs[i]->deleted = 0;
760 else if (ctx->last_tag && ctx->last_tag->deleted)
761 ctx->last_tag = NULL; /* reset last tagged msg now useless */
764 /* really only for IMAP - imap_sync_mailbox results in a call to
765 * mx_update_tables, so ctx->deleted is 0 when it comes back */
766 msgcount = ctx->msgcount;
767 deleted = ctx->deleted;
769 if (purge && ctx->deleted) {
770 if (trash_append (ctx) == -1)
774 if (ctx->magic == M_IMAP)
775 rc = imap_sync_mailbox (ctx, purge, index_hint);
777 rc = sync_mailbox (ctx, index_hint);
779 if (ctx->magic == M_IMAP && !purge)
780 mutt_message (_("Mailbox checkpointed."));
782 mutt_message (_("%d kept, %d deleted."), msgcount - deleted, deleted);
786 /* if we haven't deleted any messages, we don't need to resort */
787 /* ... except for certain folder formats which need "unsorted"
788 * sort order in order to synchronize folders.
790 * MH and maildir are safe. mbox-style seems to need re-sorting,
791 * at least with the new threading code.
793 if (purge || (ctx->magic != M_MAILDIR && ctx->magic != M_MH)) {
794 /* IMAP does this automatically after handling EXPUNGE */
795 if (ctx->magic != M_IMAP)
797 mx_update_tables (ctx, 1);
798 mutt_sort_headers (ctx, 1); /* rethread from scratch */
806 int mx_sync_mailbox (CONTEXT* ctx, int* index_hint) {
807 int ret = _mx_sync_mailbox (ctx, index_hint);
808 sidebar_set_buffystats (ctx);
813 * dest destintation mailbox
814 * hdr message being copied (required for maildir support, because
815 * the filename depends on the message flags)
817 MESSAGE *mx_open_new_message (CONTEXT * dest, HEADER * hdr, int flags)
823 if (!MX_IDX(dest->magic-1)) {
827 msg = p_new(MESSAGE, 1);
828 msg->magic = dest->magic;
832 msg->flags.flagged = hdr->flagged;
833 msg->flags.replied = hdr->replied;
834 msg->flags.read = hdr->read;
835 msg->received = hdr->received;
838 if (msg->received == 0)
839 time (&msg->received);
841 if (mxfmts[dest->magic-1]->mx_open_new_message(msg, dest, hdr) == 0) {
842 if (msg->magic == M_MBOX && flags & M_ADD_FROM) {
844 if (hdr->env->return_path)
845 p = hdr->env->return_path;
846 else if (hdr->env->sender)
847 p = hdr->env->sender;
852 fprintf (msg->fp, "From %s %s", p ? p->mailbox : NONULL(mod_core.username),
853 ctime (&msg->received));
862 /* check for new mail */
863 int mx_check_mailbox (CONTEXT * ctx, int *index_hint, int lock) {
865 return mutt_check_mailbox_compressed (ctx);
870 if (MX_IDX(ctx->magic-1) && mxfmts[ctx->magic-1]->mx_check_mailbox)
871 return mxfmts[ctx->magic-1]->mx_check_mailbox(ctx, index_hint, lock);
877 /* return a stream pointer for a message */
878 MESSAGE *mx_open_message (CONTEXT * ctx, int msgno)
882 if (!MX_IDX(ctx->magic) || !mxfmts[ctx->magic - 1]->mx_open_message)
885 msg = p_new(MESSAGE, 1);
886 msg->magic = ctx->magic;
887 if (mxfmts[ctx->magic - 1]->mx_open_message(msg, ctx, msgno))
892 /* commit a message to a folder */
894 int mx_commit_message (MESSAGE * msg, CONTEXT * ctx) {
895 if (!(msg->write && ctx->append)) {
898 if (!ctx || !MX_IDX(ctx->magic-1) || !mxfmts[ctx->magic-1]->mx_commit_message)
900 return mxfmts[ctx->magic-1]->mx_commit_message (msg, ctx);
903 /* close a pointer to a message */
904 int mx_close_message (MESSAGE ** msg)
908 if ((*msg)->magic == M_MH || (*msg)->magic == M_MAILDIR
909 || (*msg)->magic == M_IMAP || (*msg)->magic == M_POP)
911 r = m_fclose(&(*msg)->fp);
917 unlink ((*msg)->path);
918 p_delete(&(*msg)->path);
925 void mx_alloc_memory (CONTEXT * ctx)
929 p_realloc(&ctx->hdrs, ctx->hdrmax);
930 p_realloc(&ctx->v2r, ctx->hdrmax);
931 p_clear(ctx->hdrs + ctx->msgcount, ctx->hdrmax - ctx->msgcount);
932 p_clear(ctx->v2r + ctx->msgcount, ctx->hdrmax - ctx->msgcount);
935 /* this routine is called to update the counts in the context structure for
936 * the last message header parsed.
938 void mx_update_context (CONTEXT * ctx, int new_messages)
943 for (msgno = ctx->msgcount - new_messages; msgno < ctx->msgcount; msgno++) {
944 h = ctx->hdrs[msgno];
946 /* NOTE: this _must_ be done before the check for mailcap! */
947 h->security = crypt_query (h->content);
950 ctx->v2r[ctx->vcount] = msgno;
951 h->virtual = ctx->vcount++;
957 if (h->env->supersedes) {
961 ctx->id_hash = mutt_make_id_hash (ctx);
963 h2 = hash_find (ctx->id_hash, h->env->supersedes);
965 /* p_delete(&h->env->supersedes); should I ? */
968 if (!ctx->counting && mod_score.enable)
969 mutt_score_message (ctx, h2, 1);
973 /* add this message to the hash tables */
974 if (ctx->id_hash && h->env->message_id)
975 hash_insert (ctx->id_hash, h->env->message_id, h);
976 if (!ctx->counting) {
977 if (ctx->subj_hash && h->env->real_subj)
978 hash_insert (ctx->subj_hash, h->env->real_subj, h);
980 if (mod_score.enable)
981 mutt_score_message (ctx, h, 0);
996 /* update sidebar count */
997 sidebar_set_buffystats (ctx);
1002 * 1 if the specified mailbox contains 0 messages.
1003 * 0 if the mailbox contains messages
1006 int mx_check_empty (const char *path)
1009 if ((i = mx_get_idx (path)) >= 0 && mxfmts[i]->mx_check_empty)
1010 return mxfmts[i]->mx_check_empty(path);
1015 int mx_acl_check(CONTEXT *ctx, int flag)
1017 if (!mxfmts[ctx->magic-1]->mx_acl_check)
1019 return mxfmts[ctx->magic-1]->mx_acl_check(ctx,flag);
1022 void mutt_parse_mime_message (CONTEXT * ctx, HEADER * cur)
1028 if (cur->content->type != TYPEMESSAGE
1029 && cur->content->type != TYPEMULTIPART)
1030 break; /* nothing to do */
1032 if (cur->content->parts)
1033 break; /* The message was parsed earlier. */
1035 if ((msg = mx_open_message (ctx, cur->msgno))) {
1036 mutt_parse_part (msg->fp, cur->content);
1038 cur->security = crypt_query (cur->content);
1040 mx_close_message (&msg);
1043 mutt_count_body_parts (cur, flags | M_PARTS_RECOUNT);