#include "copy.h"
#include "keymap.h"
#include "url.h"
+#include "sidebar.h"
#ifdef USE_COMPRESSED
#include "compress.h"
#include "lib/intl.h"
#include "lib/str.h"
#include "lib/list.h"
+#include "lib/debug.h"
#include <dirent.h>
#include <fcntl.h>
#define MX_COMMAND(idx,cmd) ((mx_t*) MailboxFormats->data[idx])->cmd
#define MX_IDX(idx) (idx >= 0 && idx < MailboxFormats->length)
-#define mutt_is_spool(s) (safe_strcmp (Spoolfile, s) == 0)
+#define mutt_is_spool(s) (mutt_strcmp (Spoolfile, s) == 0)
#ifdef USE_DOTLOCK
/* parameters:
while (fcntl (fd, F_SETLK, &lck) == -1) {
struct stat sb;
- dprint (1, (debugfile, "mx_lock_file(): fcntl errno %d.\n", errno));
+ debug_print (1, ("fcntl errno %d.\n", errno));
if (errno != EAGAIN && errno != EACCES) {
mutt_perror ("fcntl");
return (-1);
int mx_get_magic (const char *path) {
int i = 0;
- if (safe_strlen (path) == 0)
+ if (mutt_strlen (path) == 0)
return (-1);
if ((i = mx_get_idx (path)) >= 0)
return (MX_COMMAND(i,type));
}
#undef this_body
ctx->msgcount = j;
+
+ /* update sidebar count */
+ sidebar_set_buffystats (ctx);
}
return 0;
}
+ /* update sidebar counts */
+ sidebar_set_buffystats (ctx);
+
/* if we haven't deleted any messages, we don't need to resort */
/* ... except for certain folder formats which need "unsorted"
* sort order in order to synchronize folders.
return (rc);
}
-#ifdef USE_IMAP
-int imap_open_new_message (MESSAGE * msg, CONTEXT * dest, HEADER * hdr)
-{
- char tmp[_POSIX_PATH_MAX];
-
- mutt_mktemp (tmp);
- if ((msg->fp = safe_fopen (tmp, "w")) == NULL)
- return (-1);
- msg->path = safe_strdup (tmp);
- return 0;
-}
-#endif
-
/* args:
* dest destintation mailbox
* hdr message being copied (required for maildir support, because
MESSAGE *mx_open_new_message (CONTEXT * dest, HEADER * hdr, int flags)
{
MESSAGE *msg;
- int (*func) (MESSAGE *, CONTEXT *, HEADER *);
ADDRESS *p = NULL;
- switch (dest->magic) {
- case M_MMDF:
- case M_MBOX:
- func = mbox_open_new_message;
- break;
- case M_MAILDIR:
- func = maildir_open_new_message;
- break;
- case M_MH:
- func = mh_open_new_message;
- break;
-#ifdef USE_IMAP
- case M_IMAP:
- func = imap_open_new_message;
- break;
-#endif
- default:
- dprint (1,
- (debugfile,
- "mx_open_new_message(): function unimplemented for mailbox type %d.\n",
- dest->magic));
+ if (!MX_IDX(dest->magic-1)) {
+ debug_print (1, ("function unimplemented for mailbox type %d.\n", dest->magic));
return (NULL);
}
if (msg->received == 0)
time (&msg->received);
- if (func (msg, dest, hdr) == 0) {
+ if (MX_COMMAND(dest->magic-1,mx_open_new_message)(msg, dest, hdr) == 0) {
if (dest->magic == M_MMDF)
fputs (MMDF_SEP, msg->fp);
}
/* check for new mail */
-int mx_check_mailbox (CONTEXT * ctx, int *index_hint, int lock)
-{
- int rc;
-
+int mx_check_mailbox (CONTEXT * ctx, int *index_hint, int lock) {
#ifdef USE_COMPRESSED
if (ctx->compressinfo)
return mutt_check_mailbox_compressed (ctx);
if (ctx) {
if (ctx->locked)
lock = 0;
-
- switch (ctx->magic) {
- case M_MBOX:
- case M_MMDF:
-
- if (lock) {
- mutt_block_signals ();
- if (mbox_lock_mailbox (ctx, 0, 0) == -1) {
- mutt_unblock_signals ();
- return M_LOCKED;
- }
- }
-
- rc = mbox_check_mailbox (ctx, index_hint);
-
- if (lock) {
- mutt_unblock_signals ();
- mbox_unlock_mailbox (ctx);
- }
-
- return rc;
-
-
- case M_MH:
- return (mh_check_mailbox (ctx, index_hint));
- case M_MAILDIR:
- return (maildir_check_mailbox (ctx, index_hint));
-
-#ifdef USE_IMAP
- case M_IMAP:
- return (imap_check_mailbox (ctx, index_hint, 0));
-#endif /* USE_IMAP */
-
-#ifdef USE_POP
- case M_POP:
- return (pop_check_mailbox (ctx, index_hint));
-#endif /* USE_POP */
-
-#ifdef USE_NNTP
- case M_NNTP:
- return (nntp_check_mailbox (ctx));
-#endif /* USE_NNTP */
- }
+ if (MX_IDX(ctx->magic-1) && MX_COMMAND(ctx->magic-1,mx_check_mailbox))
+ return (MX_COMMAND(ctx->magic-1,mx_check_mailbox)(ctx, index_hint, lock));
}
- dprint (1, (debugfile, "mx_check_mailbox: null or invalid context.\n"));
+ debug_print (1, ("null or invalid context.\n"));
return (-1);
+
}
/* return a stream pointer for a message */
if (msg->fp == NULL) {
mutt_perror (path);
- dprint (1, (debugfile, "mx_open_message: fopen: %s: %s (errno %d).\n",
- path, strerror (errno), errno));
+ debug_print (1, ("fopen: %s: %s (errno %d).\n", path, strerror (errno), errno));
FREE (&msg);
}
}
#endif /* USE_NNTP */
default:
- dprint (1,
- (debugfile,
- "mx_open_message(): function not implemented for mailbox type %d.\n",
- ctx->magic));
+ debug_print (1, ("function not implemented for mailbox type %d.\n", ctx->magic));
FREE (&msg);
break;
}
int r = 0;
if (!(msg->write && ctx->append)) {
- dprint (1,
- (debugfile,
- "mx_commit_message(): msg->write = %d, ctx->append = %d\n",
- msg->write, ctx->append));
+ debug_print (1, ("msg->write = %d, ctx->append = %d\n", msg->write, ctx->append));
return -1;
}
(*msg)->fp = NULL;
if ((*msg)->path) {
- dprint (1, (debugfile, "mx_close_message (): unlinking %s\n",
- (*msg)->path));
+ debug_print (1, ("unlinking %s\n", (*msg)->path));
unlink ((*msg)->path);
FREE (&(*msg)->path);
}
ctx->new++;
}
}
+ /* update sidebar count */
+ sidebar_set_buffystats (ctx);
}
/*