return M_POP;
#endif /* USE_POP */
+#ifdef USE_NOTMUCH
+ if (mx_is_notmuch(path))
+ return M_NOTMUCH;
+#endif
+
if (stat (path, &st) == -1)
{
dprint (1, (debugfile, "mx_get_magic(): unable to stat %s: %s (errno %d).\n",
break;
#endif /* USE_POP */
+#ifdef USE_NOTMUCH
+ case M_NOTMUCH:
+ rc = nm_read_query (ctx);
+ break;
+#endif /* USE_IMAP */
+
default:
rc = -1;
break;
rc = pop_sync_mailbox (ctx, index_hint);
break;
#endif /* USE_POP */
+
+#ifdef USE_NOTMUCH
+ case M_NOTMUCH:
+ rc = nm_sync (ctx, index_hint);
+ break;
+#endif /* USE_NOTMUCH */
+
}
#if 0
case M_POP:
return (pop_check_mailbox (ctx, index_hint));
#endif /* USE_POP */
+
+#ifdef USE_NOTMUTCH
+ case M_NOTMUCH:
+ return nm_check_database(cxt, index_hint);
+#endif
}
}
MESSAGE *mx_open_message (CONTEXT *ctx, int msgno)
{
MESSAGE *msg;
-
+
msg = safe_calloc (1, sizeof (MESSAGE));
switch (msg->magic = ctx->magic)
{
case M_MH:
case M_MAILDIR:
+#ifdef USE_NOTMUCH
+ case M_NOTMUCH:
+#endif
{
HEADER *cur = ctx->hdrs[msgno];
char path[_POSIX_PATH_MAX];
-
- snprintf (path, sizeof (path), "%s/%s", ctx->path, cur->path);
-
+ char *folder = ctx->path;
+#ifdef USE_NOTMUCH
+ if (ctx->magic == M_NOTMUCH) {
+ msg->magic = nm_header_get_magic(cur);
+ folder = nm_header_get_folder(cur);
+ }
+#endif
+ snprintf (path, sizeof (path), "%s/%s", folder, cur->path);
+
if ((msg->fp = fopen (path, "r")) == NULL && errno == ENOENT &&
- ctx->magic == M_MAILDIR)
- msg->fp = maildir_open_find_message (ctx->path, cur->path);
+ (ctx->magic == M_MAILDIR || ctx->magic == M_NOTMUCH))
+ msg->fp = maildir_open_find_message (folder, cur->path);
if (msg->fp == NULL)
{
break;
}
#endif
-
+
case M_MAILDIR:
{
r = maildir_commit_message (ctx, msg, NULL);
break;
}
-
+
+ case M_NOTMUCH:
+ mutt_perror _("Can't write to virtual folder.");
+ break;
+
case M_MH:
{
r = mh_commit_message (ctx, msg, NULL);
mutt_perror _("Can't write message");
r = -1;
}
-
+
return r;
}
int r = 0;
if ((*msg)->magic == M_MH || (*msg)->magic == M_MAILDIR
- || (*msg)->magic == M_IMAP || (*msg)->magic == M_POP)
+ || (*msg)->magic == M_IMAP || (*msg)->magic == M_POP
+ || (*msg)->magic == M_NOTMUCH)
{
r = safe_fclose (&(*msg)->fp);
}
else
(*msg)->fp = NULL;
- if ((*msg)->path)
+ if ((*msg)->path && (*msg)->magic != M_NOTMUCH)
{
dprint (1, (debugfile, "mx_close_message (): unlinking %s\n",
(*msg)->path));