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 /* hack so that it's linked together */
52 #define MX_IDX(idx) (idx >= 0 && idx < countof(mxfmts))
53 #define mutt_is_spool(s) (m_strcmp(Spoolfile, s) == 0)
55 static int dotlock_file(const char *path, int retry)
57 char lockfile[_POSIX_PATH_MAX];
58 snprintf(lockfile, sizeof(lockfile), "%s.lock", path);
60 if (lockfile_create(lockfile, retry ? 1 : 0, 0)) {
62 mutt_error (_("Can't dotlock %s.\n"), lockfile);
67 static int undotlock_file (const char *path)
69 char lockfile[_POSIX_PATH_MAX];
70 snprintf(lockfile, sizeof(lockfile), "%s.lock", path);
71 return lockfile_remove(lockfile);
74 /* looks up index of type for path in mxfmts */
75 static int mx_get_idx (const char* path) {
79 /* first, test all non-local folders to avoid stat() call */
80 for (i = 0; i < countof(mxfmts); i++) {
81 if (!mxfmts[i]->local)
82 t = mxfmts[i]->mx_is_magic(path, NULL);
86 if (stat (path, &st) == 0) {
87 /* if stat() succeeded, keep testing until success and
88 * pass stat() info so that we only need to do it once */
89 for (i = 0; i < countof(mxfmts); i++) {
91 t = mxfmts[i]->mx_is_magic(path, &st);
100 * excl if excl != 0, request an exclusive lock
101 * time_out should retry locking?
103 int mx_lock_file(const char *path, int fd, int excl, int time_out)
105 int count = 0, attempt = 0;
107 .l_type = excl ? F_WRLCK : F_RDLCK,
108 .l_whence = SEEK_SET,
111 if (dotlock_file(path, time_out) < 0)
114 while (fcntl(fd, F_SETLK, &lck) == -1) {
115 if (errno != EAGAIN && errno != EACCES) {
116 mutt_perror("fcntl");
120 if (++count >= (time_out ? MAXLOCKATTEMPT : 0)) {
122 mutt_error _("Timeout exceeded while attempting fcntl lock!");
125 mutt_message(_("Waiting for fcntl lock... %d"), ++attempt);
131 undotlock_file(path);
135 int mx_unlock_file(const char *path, int fd)
137 struct flock unlockit;
139 p_clear(&unlockit, 1);
140 unlockit.l_type = F_UNLCK;
141 unlockit.l_whence = SEEK_SET;
142 fcntl(fd, F_SETLK, &unlockit);
143 undotlock_file(path);
147 /* try to figure out what type of mailbox ``path'' is */
148 int mx_get_magic (const char *path) {
151 if (m_strlen(path) == 0)
153 if ((i = mx_get_idx (path)) >= 0)
154 return mxfmts[i]->type;
158 int mx_is_local (int m) {
161 return mxfmts[m]->local;
164 /* mx_access: Wrapper for access, checks permissions on a given mailbox.
165 * We may be interested in using ACL-style flags at some point, currently
166 * we use the normal access() flags. */
167 int mx_access (const char *path, int flags)
171 if ((i = mx_get_idx (path)) >= 0 && mxfmts[i]->mx_access)
172 return mxfmts[i]->mx_access(path,flags);
176 static int mx_open_mailbox_append (CONTEXT * ctx, int flags)
180 /* special case for appending to compressed folders -
181 * even if we can not open them for reading */
182 if (mutt_can_append_compressed (ctx->path))
183 mutt_open_append_compressed (ctx);
187 if (mx_get_magic (ctx->path) == M_IMAP)
188 return imap_open_mailbox_append (ctx);
190 if (stat (ctx->path, &sb) == 0) {
191 ctx->magic = mx_get_magic (ctx->path);
193 switch (ctx->magic) {
195 mutt_error (_("%s is not a mailbox."), ctx->path);
200 } else if (errno == ENOENT) {
201 int len = m_strlen(ctx->path);
202 if (len > 0 && ctx->path[len - 1] == '/') {
203 char tmp[_POSIX_PATH_MAX];
205 if (mkdir (ctx->path, S_IRWXU)) {
206 mutt_perror (ctx->path);
210 snprintf (tmp, sizeof (tmp), "%s/cur", ctx->path);
211 if (mkdir (tmp, S_IRWXU)) {
217 snprintf (tmp, sizeof (tmp), "%s/new", ctx->path);
218 if (mkdir (tmp, S_IRWXU)) {
220 snprintf (tmp, sizeof (tmp), "%s/cur", ctx->path);
225 snprintf (tmp, sizeof (tmp), "%s/tmp", ctx->path);
226 if (mkdir (tmp, S_IRWXU)) {
228 snprintf (tmp, sizeof (tmp), "%s/cur", ctx->path);
230 snprintf (tmp, sizeof (tmp), "%s/new", ctx->path);
235 ctx->magic = M_MAILDIR;
240 mutt_perror (ctx->path);
244 if (ctx->magic == M_MBOX) {
245 if (!(ctx->fp = safe_fopen(ctx->path, flags & M_NEWFOLDER ? "w" : "a"))) {
246 mutt_perror(ctx->path);
249 if (mbox_lock_mailbox(ctx, 1, 1) != 0) {
250 mutt_error(_("Couldn't lock %s\n"), ctx->path);
254 fseeko(ctx->fp, 0, 2);
260 * open a mailbox and parse it
263 * flags M_NOSORT do not sort mailbox
264 * M_APPEND open mailbox for appending
265 * M_READONLY open mailbox in read-only mode
266 * M_QUIET only print error messages
267 * ctx if non-null, context struct to use
269 CONTEXT *mx_open_mailbox (const char *path, int flags, CONTEXT * pctx)
275 ctx = p_new(CONTEXT, 1);
277 ctx->path = m_strdup(path);
279 ctx->msgnotreadyet = -1;
284 if (flags & M_READONLY)
289 if (flags & (M_APPEND | M_NEWFOLDER)) {
290 if (mx_open_mailbox_append (ctx, flags) != 0) {
291 mx_fastclose_mailbox (ctx);
299 if (!MX_IDX(ctx->magic-1))
300 ctx->magic = mx_get_magic (path);
302 if (ctx->magic == M_COMPRESSED)
303 mutt_open_read_compressed (ctx);
306 mutt_error (_("%s is not a mailbox."), path);
308 if (ctx->magic == -1)
311 if (ctx->magic <= 0) {
312 mx_fastclose_mailbox (ctx);
318 /* if the user has a `push' command in their .muttrc, or in a folder-hook,
319 * it will cause the progress messages not to be displayed because
320 * mutt_refresh() will think we are in the middle of a macro. so set a
321 * flag to indicate that we should really refresh the screen.
323 set_option (OPTFORCEREFRESH);
326 mutt_message (_("Reading %s..."), ctx->path);
328 rc = mxfmts[ctx->magic-1]->mx_open_mailbox(ctx);
331 if ((flags & M_NOSORT) == 0) {
332 /* avoid unnecessary work since the mailbox is completely unthreaded
334 unset_option (OPTSORTSUBTHREADS);
335 unset_option (OPTNEEDRESCORE);
336 mutt_sort_headers (ctx, 1);
342 mx_fastclose_mailbox (ctx);
347 unset_option (OPTFORCEREFRESH);
351 /* free up memory associated with the mailbox context */
352 void mx_fastclose_mailbox (CONTEXT * ctx)
359 if (MX_IDX(ctx->magic-1) && mxfmts[ctx->magic-1]->mx_fastclose_mailbox)
360 mxfmts[ctx->magic-1]->mx_fastclose_mailbox(ctx);
362 hash_delete (&ctx->subj_hash, NULL);
364 hash_delete (&ctx->id_hash, NULL);
365 mutt_clear_threads (ctx);
366 for (i = 0; i < ctx->msgcount; i++)
367 header_delete(&ctx->hdrs[i]);
368 p_delete(&ctx->hdrs);
372 mutt_fast_close_compressed (ctx);
374 p_delete(&ctx->path);
375 p_delete(&ctx->pattern);
376 pattern_list_wipe(&ctx->limit_pattern);
381 /* save changes to disk */
382 static int sync_mailbox (CONTEXT * ctx, int *index_hint)
387 mutt_message (_("Writing %s..."), ctx->path);
389 if (MX_IDX(ctx->magic-1))
390 /* the 1 is only of interest for IMAP and means EXPUNGE */
391 rc = mxfmts[ctx->magic-1]->mx_sync_mailbox(ctx,1,index_hint);
393 if (rc == 0 && ctx->cinfo)
394 return mutt_sync_compressed (ctx);
399 /* move deleted mails to the trash folder */
400 static int trash_append (CONTEXT * ctx)
406 if (!TrashPath || !ctx->deleted ||
407 (ctx->magic == M_MAILDIR && option (OPTMAILDIRTRASH)))
410 for (; i < ctx->msgcount && (!ctx->hdrs[i]->deleted ||
411 ctx->hdrs[i]->appended); i++);
412 if (i == ctx->msgcount)
413 return 0; /* nothing to be done */
415 if (mutt_save_confirm (TrashPath, &st) != 0) {
416 mutt_error _("message(s) not deleted");
421 if (lstat (ctx->path, &stc) == 0 && stc.st_ino == st.st_ino
422 && stc.st_dev == st.st_dev && stc.st_rdev == st.st_rdev)
423 return 0; /* we are in the trash folder: simple sync */
425 if ((ctx_trash = mx_open_mailbox (TrashPath, M_APPEND, NULL)) != NULL) {
426 for (i = 0; i < ctx->msgcount; i++)
427 if (ctx->hdrs[i]->deleted && !ctx->hdrs[i]->appended
428 && !ctx->hdrs[i]->purged
429 && mutt_append_message (ctx_trash, ctx, ctx->hdrs[i], 0, 0) == -1) {
430 mx_close_mailbox (ctx_trash, NULL);
434 mx_close_mailbox (ctx_trash, NULL);
437 mutt_error _("Can't open trash folder");
445 /* save changes and close mailbox */
446 static int _mx_close_mailbox (CONTEXT * ctx, int *index_hint)
448 int i, move_messages = 0, purge = 1, read_msgs = 0;
452 char mbox[_POSIX_PATH_MAX];
460 if (ctx->readonly || ctx->dontwrite) {
461 /* mailbox is readonly or we don't want to write */
462 mx_fastclose_mailbox (ctx);
467 /* mailbox was opened in write-mode */
468 if (ctx->magic == M_MBOX)
469 mbox_close_mailbox (ctx);
471 mx_fastclose_mailbox (ctx);
475 for (i = 0; i < ctx->msgcount; i++) {
476 if (!ctx->hdrs[i]->deleted && ctx->hdrs[i]->read
477 && !(ctx->hdrs[i]->flagged && option (OPTKEEPFLAGGED)))
481 if (read_msgs && quadoption (OPT_MOVE) != M_NO) {
482 m_strcpy(mbox, sizeof(mbox), NONULL(Inbox));
483 isSpool = mutt_is_spool (ctx->path) && !mutt_is_spool (mbox);
484 mutt_expand_path (mbox, sizeof (mbox));
487 snprintf (buf, sizeof (buf), _("Move read messages to %s?"), mbox);
488 if ((move_messages = query_quadoption (OPT_MOVE, buf)) == -1) {
496 * There is no point in asking whether or not to purge if we are
497 * just marking messages as "trash".
499 if (ctx->deleted && !(ctx->magic == M_MAILDIR && option (OPTMAILDIRTRASH))) {
500 snprintf (buf, sizeof (buf), ctx->deleted == 1
501 ? _("Purge %d deleted message?") :
502 _("Purge %d deleted messages?"), ctx->deleted);
503 if ((purge = query_quadoption (OPT_DELETE, buf)) < 0) {
509 /* IMAP servers manage the OLD flag themselves */
510 if (ctx->magic != M_IMAP)
511 if (option (OPTMARKOLD)) {
512 for (i = 0; i < ctx->msgcount; i++) {
513 if (!ctx->hdrs[i]->deleted && !ctx->hdrs[i]->old)
514 mutt_set_flag (ctx, ctx->hdrs[i], M_OLD, 1);
519 mutt_message (_("Moving read messages to %s..."), mbox);
521 /* try to use server-side copy first */
524 if (ctx->magic == M_IMAP && imap_mx.mx_is_magic (mbox, NULL) == M_IMAP) {
525 /* tag messages for moving, and clear old tags, if any */
526 for (i = 0; i < ctx->msgcount; i++)
527 if (ctx->hdrs[i]->read && !ctx->hdrs[i]->deleted
528 && !(ctx->hdrs[i]->flagged && option (OPTKEEPFLAGGED)))
529 ctx->hdrs[i]->tagged = 1;
531 ctx->hdrs[i]->tagged = 0;
533 i = imap_copy_messages (ctx, NULL, mbox, 1);
536 if (i == 0) /* success */
538 else if (i == -1) { /* horrible error, bail */
542 else /* use regular append-copy mode */
544 if (mx_open_mailbox (mbox, M_APPEND, &f) == NULL) {
549 for (i = 0; i < ctx->msgcount; i++) {
550 if (ctx->hdrs[i]->read && !ctx->hdrs[i]->deleted
551 && !(ctx->hdrs[i]->flagged && option (OPTKEEPFLAGGED))) {
552 if (mutt_append_message (&f, ctx, ctx->hdrs[i], 0, CH_UPDATE_LEN) ==
554 mutt_set_flag (ctx, ctx->hdrs[i], M_DELETE, 1);
555 mutt_set_flag (ctx, ctx->hdrs[i], M_APPENDED, 1);
558 mx_close_mailbox (&f, NULL);
565 mx_close_mailbox (&f, NULL);
569 else if (!ctx->changed && ctx->deleted == 0) {
570 mutt_message _("Mailbox is unchanged.");
572 mx_fastclose_mailbox (ctx);
576 /* copy mails to the trash before expunging */
577 if (purge && ctx->deleted)
578 if (trash_append (ctx) != 0) {
583 /* allow IMAP to preserve the deleted flag across sessions */
584 if (ctx->magic == M_IMAP) {
585 if ((check = imap_sync_mailbox (ctx, purge, index_hint)) != 0) {
593 for (i = 0; i < ctx->msgcount; i++)
594 ctx->hdrs[i]->deleted = 0;
598 if (ctx->changed || ctx->deleted) {
599 if ((check = sync_mailbox (ctx, index_hint)) != 0) {
607 mutt_message (_("%d kept, %d moved, %d deleted."),
608 ctx->msgcount - ctx->deleted, read_msgs, ctx->deleted);
610 mutt_message (_("%d kept, %d deleted."),
611 ctx->msgcount - ctx->deleted, ctx->deleted);
613 if (ctx->cinfo && mutt_slow_close_compressed (ctx))
616 mx_fastclose_mailbox (ctx);
621 int mx_close_mailbox (CONTEXT * ctx, int *index_hint) {
625 ret = _mx_close_mailbox (ctx, index_hint);
626 sidebar_set_buffystats (ctx);
630 /* update a Context structure's internal tables. */
632 void mx_update_tables (CONTEXT * ctx, int committing)
636 /* update memory to reflect the new state of the mailbox */
645 #define this_body ctx->hdrs[j]->content
646 for (i = 0, j = 0; i < ctx->msgcount; i++) {
647 if ((committing && (!ctx->hdrs[i]->deleted ||
648 (ctx->magic == M_MAILDIR
649 && option (OPTMAILDIRTRASH)))) || (!committing
653 ctx->hdrs[j] = ctx->hdrs[i];
656 ctx->hdrs[j]->msgno = j;
657 if (ctx->hdrs[j]->virtual != -1) {
658 ctx->v2r[ctx->vcount] = j;
659 ctx->hdrs[j]->virtual = ctx->vcount++;
660 ctx->vsize += this_body->length + this_body->offset -
661 this_body->hdr_offset;
665 ctx->hdrs[j]->changed = 0;
666 else if (ctx->hdrs[j]->changed)
670 || (ctx->magic == M_MAILDIR && option (OPTMAILDIRTRASH))) {
671 if (ctx->hdrs[j]->deleted)
675 if (ctx->hdrs[j]->tagged)
677 if (ctx->hdrs[j]->flagged)
679 if (!ctx->hdrs[j]->read) {
681 if (!ctx->hdrs[j]->old)
688 if (ctx->magic == M_MH || ctx->magic == M_MAILDIR)
689 ctx->size -= (ctx->hdrs[i]->content->length +
690 ctx->hdrs[i]->content->offset -
691 ctx->hdrs[i]->content->hdr_offset);
692 /* remove message from the hash tables */
693 if (ctx->subj_hash && ctx->hdrs[i]->env->real_subj)
694 hash_remove (ctx->subj_hash, ctx->hdrs[i]->env->real_subj,
696 if (ctx->id_hash && ctx->hdrs[i]->env->message_id)
697 hash_remove (ctx->id_hash, ctx->hdrs[i]->env->message_id,
699 header_delete(&ctx->hdrs[i]);
705 /* update sidebar count */
706 sidebar_set_buffystats (ctx);
710 /* save changes to mailbox
716 static int _mx_sync_mailbox (CONTEXT * ctx, int *index_hint)
720 int msgcount, deleted;
722 if (ctx->dontwrite) {
723 char buf[STRING], tmp[STRING];
725 if (km_expand_key (buf, sizeof (buf),
726 km_find_func (MENU_MAIN, OP_TOGGLE_WRITE)))
727 snprintf (tmp, sizeof (tmp), _(" Press '%s' to toggle write"), buf);
729 m_strcpy(tmp, sizeof(tmp), _("Use 'toggle-write' to re-enable write!"));
731 mutt_error (_("Mailbox is marked unwritable. %s"), tmp);
734 else if (ctx->readonly) {
735 mutt_error _("Mailbox is read-only.");
740 if (!ctx->changed && !ctx->deleted) {
741 mutt_message _("Mailbox is unchanged.");
749 snprintf (buf, sizeof (buf), ctx->deleted == 1
750 ? _("Purge %d deleted message?") :
751 _("Purge %d deleted messages?"), ctx->deleted);
752 if ((purge = query_quadoption (OPT_DELETE, buf)) < 0)
754 else if (purge == M_NO) {
756 return 0; /* nothing to do! */
757 /* let IMAP servers hold on to D flags */
758 if (ctx->magic != M_IMAP)
760 for (i = 0; i < ctx->msgcount; i++)
761 ctx->hdrs[i]->deleted = 0;
765 else if (ctx->last_tag && ctx->last_tag->deleted)
766 ctx->last_tag = NULL; /* reset last tagged msg now useless */
769 /* really only for IMAP - imap_sync_mailbox results in a call to
770 * mx_update_tables, so ctx->deleted is 0 when it comes back */
771 msgcount = ctx->msgcount;
772 deleted = ctx->deleted;
774 if (purge && ctx->deleted) {
775 if (trash_append (ctx) == -1)
779 if (ctx->magic == M_IMAP)
780 rc = imap_sync_mailbox (ctx, purge, index_hint);
782 rc = sync_mailbox (ctx, index_hint);
784 if (ctx->magic == M_IMAP && !purge)
785 mutt_message (_("Mailbox checkpointed."));
787 mutt_message (_("%d kept, %d deleted."), msgcount - deleted, deleted);
791 /* if we haven't deleted any messages, we don't need to resort */
792 /* ... except for certain folder formats which need "unsorted"
793 * sort order in order to synchronize folders.
795 * MH and maildir are safe. mbox-style seems to need re-sorting,
796 * at least with the new threading code.
798 if (purge || (ctx->magic != M_MAILDIR && ctx->magic != M_MH)) {
799 /* IMAP does this automatically after handling EXPUNGE */
800 if (ctx->magic != M_IMAP)
802 mx_update_tables (ctx, 1);
803 mutt_sort_headers (ctx, 1); /* rethread from scratch */
811 int mx_sync_mailbox (CONTEXT* ctx, int* index_hint) {
812 int ret = _mx_sync_mailbox (ctx, index_hint);
813 sidebar_set_buffystats (ctx);
818 * dest destintation mailbox
819 * hdr message being copied (required for maildir support, because
820 * the filename depends on the message flags)
822 MESSAGE *mx_open_new_message (CONTEXT * dest, HEADER * hdr, int flags)
828 if (!MX_IDX(dest->magic-1)) {
832 msg = p_new(MESSAGE, 1);
833 msg->magic = dest->magic;
837 msg->flags.flagged = hdr->flagged;
838 msg->flags.replied = hdr->replied;
839 msg->flags.read = hdr->read;
840 msg->received = hdr->received;
843 if (msg->received == 0)
844 time (&msg->received);
846 if (mxfmts[dest->magic-1]->mx_open_new_message(msg, dest, hdr) == 0) {
847 if (msg->magic == M_MBOX && flags & M_ADD_FROM) {
849 if (hdr->env->return_path)
850 p = hdr->env->return_path;
851 else if (hdr->env->sender)
852 p = hdr->env->sender;
857 fprintf (msg->fp, "From %s %s", p ? p->mailbox : NONULL(mod_core.username),
858 ctime (&msg->received));
867 /* check for new mail */
868 int mx_check_mailbox (CONTEXT * ctx, int *index_hint, int lock) {
870 return mutt_check_mailbox_compressed (ctx);
875 if (MX_IDX(ctx->magic-1) && mxfmts[ctx->magic-1]->mx_check_mailbox)
876 return mxfmts[ctx->magic-1]->mx_check_mailbox(ctx, index_hint, lock);
882 /* return a stream pointer for a message */
883 MESSAGE *mx_open_message (CONTEXT * ctx, int msgno)
887 if (!MX_IDX(ctx->magic) || !mxfmts[ctx->magic - 1]->mx_open_message)
890 msg = p_new(MESSAGE, 1);
891 msg->magic = ctx->magic;
892 if (mxfmts[ctx->magic - 1]->mx_open_message(msg, ctx, msgno))
897 /* commit a message to a folder */
899 int mx_commit_message (MESSAGE * msg, CONTEXT * ctx) {
900 if (!(msg->write && ctx->append)) {
903 if (!ctx || !MX_IDX(ctx->magic-1) || !mxfmts[ctx->magic-1]->mx_commit_message)
905 return mxfmts[ctx->magic-1]->mx_commit_message (msg, ctx);
908 /* close a pointer to a message */
909 int mx_close_message (MESSAGE ** msg)
913 if ((*msg)->magic == M_MH || (*msg)->magic == M_MAILDIR
914 || (*msg)->magic == M_IMAP || (*msg)->magic == M_POP)
916 r = m_fclose(&(*msg)->fp);
922 unlink ((*msg)->path);
923 p_delete(&(*msg)->path);
930 void mx_alloc_memory (CONTEXT * ctx)
934 p_realloc(&ctx->hdrs, ctx->hdrmax);
935 p_realloc(&ctx->v2r, ctx->hdrmax);
936 p_clear(ctx->hdrs + ctx->msgcount, ctx->hdrmax - ctx->msgcount);
937 p_clear(ctx->v2r + ctx->msgcount, ctx->hdrmax - ctx->msgcount);
940 /* this routine is called to update the counts in the context structure for
941 * the last message header parsed.
943 void mx_update_context (CONTEXT * ctx, int new_messages)
948 for (msgno = ctx->msgcount - new_messages; msgno < ctx->msgcount; msgno++) {
949 h = ctx->hdrs[msgno];
951 /* NOTE: this _must_ be done before the check for mailcap! */
952 h->security = crypt_query (h->content);
955 ctx->v2r[ctx->vcount] = msgno;
956 h->virtual = ctx->vcount++;
962 if (h->env->supersedes) {
966 ctx->id_hash = mutt_make_id_hash (ctx);
968 h2 = hash_find (ctx->id_hash, h->env->supersedes);
970 /* p_delete(&h->env->supersedes); should I ? */
973 if (!ctx->counting && mod_score.enable)
974 mutt_score_message (ctx, h2, 1);
978 /* add this message to the hash tables */
979 if (ctx->id_hash && h->env->message_id)
980 hash_insert (ctx->id_hash, h->env->message_id, h);
981 if (!ctx->counting) {
982 if (ctx->subj_hash && h->env->real_subj)
983 hash_insert (ctx->subj_hash, h->env->real_subj, h);
985 if (mod_score.enable)
986 mutt_score_message (ctx, h, 0);
1001 /* update sidebar count */
1002 sidebar_set_buffystats (ctx);
1007 * 1 if the specified mailbox contains 0 messages.
1008 * 0 if the mailbox contains messages
1011 int mx_check_empty (const char *path)
1014 if ((i = mx_get_idx (path)) >= 0 && mxfmts[i]->mx_check_empty)
1015 return mxfmts[i]->mx_check_empty(path);
1020 int mx_acl_check(CONTEXT *ctx, int flag)
1022 if (!mxfmts[ctx->magic-1]->mx_acl_check)
1024 return mxfmts[ctx->magic-1]->mx_acl_check(ctx,flag);
1027 void mutt_parse_mime_message (CONTEXT * ctx, HEADER * cur)
1033 if (cur->content->type != TYPEMESSAGE
1034 && cur->content->type != TYPEMULTIPART)
1035 break; /* nothing to do */
1037 if (cur->content->parts)
1038 break; /* The message was parsed earlier. */
1040 if ((msg = mx_open_message (ctx, cur->msgno))) {
1041 mutt_parse_part (msg->fp, cur->content);
1043 cur->security = crypt_query (cur->content);
1045 mx_close_message (&msg);
1048 mutt_count_body_parts (cur, flags | M_PARTS_RECOUNT);