OptNews = false;
if (op == OP_COMPOSE_ATTACH_NEWS_MESSAGE)
{
- CurrentNewsSrv = nntp_select_server(Context, NewsServer, false);
+ CurrentNewsSrv = nntp_select_server(Context->mailbox, NewsServer, false);
if (!CurrentNewsSrv)
break;
#ifdef USE_NOTMUCH
if (msg->committed_path && dest->mailbox->magic == MUTT_MAILDIR &&
src->mailbox->magic == MUTT_NOTMUCH)
- nm_update_filename(src, NULL, msg->committed_path, hdr);
+ nm_update_filename(src->mailbox, NULL, msg->committed_path, hdr);
#endif
mx_msg_close(dest, &msg);
sizeof(buf));
}
if (!Context->mailbox->id_hash)
- Context->mailbox->id_hash = mutt_make_id_hash(Context);
+ Context->mailbox->id_hash = mutt_make_id_hash(Context->mailbox);
hdr = mutt_hash_find(Context->mailbox->id_hash, buf);
if (hdr)
{
mutt_message(_("Fetching message headers..."));
if (!Context->mailbox->id_hash)
- Context->mailbox->id_hash = mutt_make_id_hash(Context);
+ Context->mailbox->id_hash = mutt_make_id_hash(Context->mailbox);
mutt_str_strfcpy(buf, CURHDR->env->message_id, sizeof(buf));
/* trying to find msgid of the root message */
if (op == OP_MAIN_CHANGE_GROUP || op == OP_MAIN_CHANGE_GROUP_READONLY)
{
OptNews = true;
- CurrentNewsSrv = nntp_select_server(Context, NewsServer, false);
+ CurrentNewsSrv = nntp_select_server(Context->mailbox, NewsServer, false);
if (!CurrentNewsSrv)
break;
if (flags)
/* once again the context is new */
ctx->mailbox->data = idata;
- /* Clean up path and replace the one in the ctx */
+ /* Clean up path and replace the one in the mailbox */
imap_fix_path(idata, mx.mbox, buf, sizeof(buf));
if (!*buf)
mutt_str_strfcpy(buf, "INBOX", sizeof(buf));
h.data->replied = ctx->mailbox->hdrs[idx]->replied;
}
- /* ctx->hdrs[msgno]->received is restored from mutt_hcache_restore */
+ /* mailbox->hdrs[msgno]->received is restored from mutt_hcache_restore */
ctx->mailbox->hdrs[idx]->data = h.data;
STAILQ_INIT(&ctx->mailbox->hdrs[idx]->tags);
driver_tags_replace(&ctx->mailbox->hdrs[idx]->tags,
idata->msn_index[msn - 1] = h;
if (ctx->mailbox->msg_count >= ctx->mailbox->hdrmax)
- mx_alloc_memory(ctx);
+ mx_alloc_memory(ctx->mailbox);
struct ImapHeaderData *ihd = mutt_mem_calloc(1, sizeof(struct ImapHeaderData));
h->data = ihd;
msn_begin = idata->max_msn + 1;
msn_end = idata->new_mail_count;
while (msn_end > ctx->mailbox->hdrmax)
- mx_alloc_memory(ctx);
+ mx_alloc_memory(ctx->mailbox);
alloc_msn_index(idata, msn_end);
idata->reopen &= ~IMAP_NEWMAIL_PENDING;
idata->new_mail_count = 0;
/* make sure context has room to hold the mailbox */
while (msn_end > ctx->mailbox->hdrmax)
- mx_alloc_memory(ctx);
+ mx_alloc_memory(ctx->mailbox);
alloc_msn_index(idata, msn_end);
imap_alloc_uid_hash(idata, msn_end);
{
/* TODO: it's not clear to me why we are calling mx_alloc_memory
* yet again. */
- mx_alloc_memory(ctx);
+ mx_alloc_memory(ctx->mailbox);
mx_update_context(ctx, ctx->mailbox->msg_count - oldmsgcount);
}
/* YAUH (yet another ugly hack): temporarily set context to
* read-write even if it's read-only, so *server* updates of
- * flags can be processed by mutt_set_flag. ctx->changed must
+ * flags can be processed by mutt_set_flag. mailbox->changed must
* be restored afterwards */
readonly = ctx->mailbox->readonly;
ctx->mailbox->readonly = false;
/**
* mh_mkstemp - Create a temporary file
- * @param[in] dest Mailbox to create the file in
- * @param[out] fp File handle
- * @param[out] tgt File name
+ * @param[in] mailbox Mailbox to create the file in
+ * @param[out] fp File handle
+ * @param[out] tgt File name
* @retval 0 Success
* @retval -1 Failure
*/
-static int mh_mkstemp(struct Context *dest, FILE **fp, char **tgt)
+static int mh_mkstemp(struct Mailbox *mailbox, FILE **fp, char **tgt)
{
int fd;
char path[PATH_MAX];
mode_t omask;
- omask = umask(mh_umask(dest->mailbox));
+ omask = umask(mh_umask(mailbox));
while (true)
{
- snprintf(path, sizeof(path), "%s/.neomutt-%s-%d-%" PRIu64, dest->mailbox->path,
+ snprintf(path, sizeof(path), "%s/.neomutt-%s-%d-%" PRIu64, mailbox->path,
NONULL(ShortHostname), (int) getpid(), mutt_rand64());
fd = open(path, O_WRONLY | O_EXCL | O_CREAT, 0666);
if (fd == -1)
/**
* mh_update_sequences - Update sequence numbers
- * @param ctx Mailbox
+ * @param mailbox Mailbox
*
* XXX we don't currently remove deleted messages from sequences we don't know.
* Should we?
*/
-static void mh_update_sequences(struct Context *ctx)
+static void mh_update_sequences(struct Mailbox *mailbox)
{
FILE *ofp = NULL, *nfp = NULL;
snprintf(seq_replied, sizeof(seq_replied), "%s:", NONULL(MhSeqReplied));
snprintf(seq_flagged, sizeof(seq_flagged), "%s:", NONULL(MhSeqFlagged));
- if (mh_mkstemp(ctx, &nfp, &tmpfname) != 0)
+ if (mh_mkstemp(mailbox, &nfp, &tmpfname) != 0)
{
/* error message? */
return;
}
- snprintf(sequences, sizeof(sequences), "%s/.mh_sequences", ctx->mailbox->path);
+ snprintf(sequences, sizeof(sequences), "%s/.mh_sequences", mailbox->path);
/* first, copy unknown sequences */
ofp = fopen(sequences, "r");
mutt_file_fclose(&ofp);
/* now, update our unseen, flagged, and replied sequences */
- for (l = 0; l < ctx->mailbox->msg_count; l++)
+ for (l = 0; l < mailbox->msg_count; l++)
{
- if (ctx->mailbox->hdrs[l]->deleted)
+ if (mailbox->hdrs[l]->deleted)
continue;
- p = strrchr(ctx->mailbox->hdrs[l]->path, '/');
+ p = strrchr(mailbox->hdrs[l]->path, '/');
if (p)
p++;
else
- p = ctx->mailbox->hdrs[l]->path;
+ p = mailbox->hdrs[l]->path;
if (mutt_str_atoi(p, &i) < 0)
continue;
- if (!ctx->mailbox->hdrs[l]->read)
+ if (!mailbox->hdrs[l]->read)
{
mhs_set(&mhs, i, MH_SEQ_UNSEEN);
unseen++;
}
- if (ctx->mailbox->hdrs[l]->flagged)
+ if (mailbox->hdrs[l]->flagged)
{
mhs_set(&mhs, i, MH_SEQ_FLAGGED);
flagged++;
}
- if (ctx->mailbox->hdrs[l]->replied)
+ if (mailbox->hdrs[l]->replied)
{
mhs_set(&mhs, i, MH_SEQ_REPLIED);
replied++;
/**
* mh_sequences_add_one - Update the flags for one sequence
- * @param ctx Mailbox
+ * @param mailbox Mailbox
* @param n Sequence number to update
* @param unseen Update the unseen sequence
* @param flagged Update the flagged sequence
* @param replied Update the replied sequence
*/
-static void mh_sequences_add_one(struct Context *ctx, int n, bool unseen,
+static void mh_sequences_add_one(struct Mailbox *mailbox, int n, bool unseen,
bool flagged, bool replied)
{
short unseen_done = 0;
int line = 0;
size_t sz;
- if (mh_mkstemp(ctx, &nfp, &tmpfname) == -1)
+ if (mh_mkstemp(mailbox, &nfp, &tmpfname) == -1)
return;
snprintf(seq_unseen, sizeof(seq_unseen), "%s:", NONULL(MhSeqUnseen));
snprintf(seq_replied, sizeof(seq_replied), "%s:", NONULL(MhSeqReplied));
snprintf(seq_flagged, sizeof(seq_flagged), "%s:", NONULL(MhSeqFlagged));
- snprintf(sequences, sizeof(sequences), "%s/.mh_sequences", ctx->mailbox->path);
+ snprintf(sequences, sizeof(sequences), "%s/.mh_sequences", mailbox->path);
ofp = fopen(sequences, "r");
if (ofp)
{
/**
* maildir_update_mtime - Update our record of the Maildir modification time
- * @param ctx Mailbox
+ * @param mailbox Mailbox
*/
-static void maildir_update_mtime(struct Context *ctx)
+static void maildir_update_mtime(struct Mailbox *mailbox)
{
char buf[PATH_MAX];
struct stat st;
- struct MhData *data = mh_data(ctx->mailbox);
+ struct MhData *data = mh_data(mailbox);
- if (ctx->mailbox->magic == MUTT_MAILDIR)
+ if (mailbox->magic == MUTT_MAILDIR)
{
- snprintf(buf, sizeof(buf), "%s/%s", ctx->mailbox->path, "cur");
+ snprintf(buf, sizeof(buf), "%s/%s", mailbox->path, "cur");
if (stat(buf, &st) == 0)
mutt_get_stat_timespec(&data->mtime_cur, &st, MUTT_STAT_MTIME);
- snprintf(buf, sizeof(buf), "%s/%s", ctx->mailbox->path, "new");
+ snprintf(buf, sizeof(buf), "%s/%s", mailbox->path, "new");
}
else
{
- snprintf(buf, sizeof(buf), "%s/.mh_sequences", ctx->mailbox->path);
+ snprintf(buf, sizeof(buf), "%s/.mh_sequences", mailbox->path);
if (stat(buf, &st) == 0)
mutt_get_stat_timespec(&data->mtime_cur, &st, MUTT_STAT_MTIME);
- mutt_str_strfcpy(buf, ctx->mailbox->path, sizeof(buf));
+ mutt_str_strfcpy(buf, mailbox->path, sizeof(buf));
}
if (stat(buf, &st) == 0)
- mutt_get_stat_timespec(&ctx->mailbox->mtime, &st, MUTT_STAT_MTIME);
+ mutt_get_stat_timespec(&mailbox->mtime, &st, MUTT_STAT_MTIME);
}
/**
md->h->flagged ? "f" : "", md->h->deleted ? "D" : "",
md->h->replied ? "r" : "", md->h->old ? "O" : "", md->h->read ? "R" : "");
if (ctx->mailbox->msg_count == ctx->mailbox->hdrmax)
- mx_alloc_memory(ctx);
+ mx_alloc_memory(ctx->mailbox);
ctx->mailbox->hdrs[ctx->mailbox->msg_count] = md->h;
ctx->mailbox->hdrs[ctx->mailbox->msg_count]->index = ctx->mailbox->msg_count;
}
data = mh_data(ctx->mailbox);
- maildir_update_mtime(ctx);
+ maildir_update_mtime(ctx->mailbox);
md = NULL;
last = &md;
*
* Open a new (temporary) message in an MH folder.
*/
-static int mh_msg_open_new(struct Context *ctx, struct Message *msg, struct Header *hdr)
+static int mh_msg_open_new(struct Context *ctx, struct Message *msg, struct Header *hdr)
{
- return mh_mkstemp(ctx, &msg->fp, &msg->path);
+ return mh_mkstemp(ctx->mailbox, &msg->fp, &msg->path);
}
/**
/**
* maildir_mh_open_message - Open a Maildir or MH message
- * @param ctx Mailbox
+ * @param mailbox Mailbox
* @param msg Message to open
* @param msgno Index number
* @param is_maildir true, if a Maildir
* @retval 0 Success
* @retval -1 Failure
*/
-static int maildir_mh_open_message(struct Context *ctx, struct Message *msg,
+static int maildir_mh_open_message(struct Mailbox *mailbox, struct Message *msg,
int msgno, int is_maildir)
{
- struct Header *cur = ctx->mailbox->hdrs[msgno];
+ struct Header *cur = mailbox->hdrs[msgno];
char path[PATH_MAX];
- snprintf(path, sizeof(path), "%s/%s", ctx->mailbox->path, cur->path);
+ snprintf(path, sizeof(path), "%s/%s", mailbox->path, cur->path);
msg->fp = fopen(path, "r");
if (!msg->fp && (errno == ENOENT) && is_maildir)
- msg->fp = maildir_open_find_message(ctx->mailbox->path, cur->path, NULL);
+ msg->fp = maildir_open_find_message(mailbox->path, cur->path, NULL);
if (!msg->fp)
{
*/
static int maildir_msg_open(struct Context *ctx, struct Message *msg, int msgno)
{
- return maildir_mh_open_message(ctx, msg, msgno, 1);
+ return maildir_mh_open_message(ctx->mailbox, msg, msgno, 1);
}
/**
*/
static int mh_msg_open(struct Context *ctx, struct Message *msg, int msgno)
{
- return maildir_mh_open_message(ctx, msg, msgno, 0);
+ return maildir_mh_open_message(ctx->mailbox, msg, msgno, 0);
}
/**
/**
* md_commit_message - Commit a message to a maildir folder
- * @param ctx Mailbox
- * @param msg Message to commit
- * @param hdr Header of the email
+ * @param mailbox Mailbox
+ * @param msg Message to commit
+ * @param hdr Header of the email
* @retval 0 Success
* @retval -1 Failure
*
* msg->path contains the file name of a file in tmp/. We take the
* flags from this file's name.
*
- * ctx is the mail folder we commit to.
+ * mailbox is the mail folder we commit to.
*
* hdr is a header structure to which we write the message's new
* file name. This is used in the mh and maildir folder synch
*
* See also maildir_msg_open_new().
*/
-static int md_commit_message(struct Context *ctx, struct Message *msg, struct Header *hdr)
+static int md_commit_message(struct Mailbox *mailbox, struct Message *msg, struct Header *hdr)
{
char subdir[4];
char suffix[16];
{
snprintf(path, sizeof(path), "%s/%lld.R%" PRIu64 ".%s%s", subdir,
(long long) time(NULL), mutt_rand64(), NONULL(ShortHostname), suffix);
- snprintf(full, sizeof(full), "%s/%s", ctx->mailbox->path, path);
+ snprintf(full, sizeof(full), "%s/%s", mailbox->path, path);
mutt_debug(2, "renaming %s to %s.\n", msg->path, full);
}
#ifdef USE_NOTMUCH
- if (ctx->mailbox->magic == MUTT_NOTMUCH)
- nm_update_filename(ctx, hdr->path, full, hdr);
+ if (mailbox->magic == MUTT_NOTMUCH)
+ nm_update_filename(mailbox, hdr->path, full, hdr);
#endif
if (hdr)
mutt_str_replace(&hdr->path, path);
}
else if (errno != EEXIST)
{
- mutt_perror(ctx->mailbox->path);
+ mutt_perror(mailbox->path);
return -1;
}
}
*/
static int maildir_msg_commit(struct Context *ctx, struct Message *msg)
{
- return md_commit_message(ctx, msg, NULL);
+ return md_commit_message(ctx->mailbox, msg, NULL);
}
/**
* mh_commit_msg - Commit a message to an MH folder
- * @param ctx Mailbox
- * @param msg Message to commit
- * @param hdr Email Header
- * @param updseq If true, update the sequence number
+ * @param mailbox Mailbox
+ * @param msg Message to commit
+ * @param hdr Email Header
+ * @param updseq If true, update the sequence number
* @retval 0 Success
* @retval -1 Failure
*/
-static int mh_commit_msg(struct Context *ctx, struct Message *msg,
+static int mh_commit_msg(struct Mailbox *mailbox, struct Message *msg,
struct Header *hdr, bool updseq)
{
DIR *dirp = NULL;
return -1;
}
- dirp = opendir(ctx->mailbox->path);
+ dirp = opendir(mailbox->path);
if (!dirp)
{
- mutt_perror(ctx->mailbox->path);
+ mutt_perror(mailbox->path);
return -1;
}
{
hi++;
snprintf(tmp, sizeof(tmp), "%u", hi);
- snprintf(path, sizeof(path), "%s/%s", ctx->mailbox->path, tmp);
+ snprintf(path, sizeof(path), "%s/%s", mailbox->path, tmp);
if (mutt_file_safe_rename(msg->path, path) == 0)
{
if (hdr)
}
else if (errno != EEXIST)
{
- mutt_perror(ctx->mailbox->path);
+ mutt_perror(mailbox->path);
return -1;
}
}
if (updseq)
{
- mh_sequences_add_one(ctx, hi, !msg->flags.read, msg->flags.flagged,
+ mh_sequences_add_one(mailbox, hi, !msg->flags.read, msg->flags.flagged,
msg->flags.replied);
}
return 0;
*/
static int mh_msg_commit(struct Context *ctx, struct Message *msg)
{
- return mh_commit_msg(ctx, msg, NULL, true);
+ return mh_commit_msg(ctx->mailbox, msg, NULL, true);
}
/**
mutt_str_strfcpy(partpath, h->path, sizeof(partpath));
if (ctx->mailbox->magic == MUTT_MAILDIR)
- rc = md_commit_message(ctx, dest, h);
+ rc = md_commit_message(ctx->mailbox, dest, h);
else
- rc = mh_commit_msg(ctx, dest, h, false);
+ rc = mh_commit_msg(ctx->mailbox, dest, h, false);
mx_msg_close(ctx, &dest);
char *tmp = NULL;
FILE *fp = NULL;
- if (mh_mkstemp(ctx, &fp, &tmp) == 0)
+ if (mh_mkstemp(ctx->mailbox, &fp, &tmp) == 0)
{
mutt_file_fclose(&fp);
if (mutt_file_safe_rename(tmp, buf) == -1)
#endif
if (ctx->mailbox->magic == MUTT_MH)
- mh_update_sequences(ctx);
+ mh_update_sequences(ctx->mailbox);
/* XXX race condition? */
- maildir_update_mtime(ctx);
+ maildir_update_mtime(ctx->mailbox);
/* adjust indices */
if (flags & MUTT_NEWS)
{
OptNews = true;
- CurrentNewsSrv = nntp_select_server(Context, NewsServer, false);
+ CurrentNewsSrv = nntp_select_server(Context->mailbox, NewsServer, false);
if (!CurrentNewsSrv)
goto main_curses; // TEST38: neomutt -G (unset news_server)
}
/**
* get_mboxdata - Get the private data associated with a Mailbox
- * @param ctx Mailbox
+ * @param mailbox Mailbox
* @retval ptr Private data
*/
-struct MboxData *get_mboxdata(struct Context *ctx)
+struct MboxData *get_mboxdata(struct Mailbox *mailbox)
{
- if (ctx && ctx->mailbox && (ctx->mailbox->magic == MUTT_MBOX))
- return ctx->mailbox->data;
+ if (mailbox && (mailbox->magic == MUTT_MBOX))
+ return mailbox->data;
return NULL;
}
/**
* mbox_lock_mailbox - Lock a mailbox
- * @param ctx Mailbox to lock
+ * @param mailbox Mailbox to lock
* @param excl Exclusive lock?
* @param retry Should retry if unable to lock?
* @retval 0 Success
* @retval -1 Failure
*/
-static int mbox_lock_mailbox(struct Context *ctx, int excl, int retry)
+static int mbox_lock_mailbox(struct Mailbox *mailbox, bool excl, bool retry)
{
- struct MboxData *mdata = get_mboxdata(ctx);
+ struct MboxData *mdata = get_mboxdata(mailbox);
if (!mdata)
return -1;
mdata->locked = true;
else if (retry && !excl)
{
- ctx->mailbox->readonly = true;
+ mailbox->readonly = true;
return 0;
}
/**
* mbox_unlock_mailbox - Unlock a mailbox
- * @param ctx Mailbox to unlock
+ * @param mailbox Mailbox to unlock
*/
-static void mbox_unlock_mailbox(struct Context *ctx)
+static void mbox_unlock_mailbox(struct Mailbox *mailbox)
{
- struct MboxData *mdata = get_mboxdata(ctx);
+ struct MboxData *mdata = get_mboxdata(mailbox);
if (!mdata)
return;
*/
static int mmdf_parse_mailbox(struct Context *ctx)
{
- struct MboxData *mdata = get_mboxdata(ctx);
+ struct MboxData *mdata = get_mboxdata(ctx->mailbox);
if (!mdata)
return -1;
(int) (loc / (ctx->mailbox->size / 100 + 1)));
if (ctx->mailbox->msg_count == ctx->mailbox->hdrmax)
- mx_alloc_memory(ctx);
+ mx_alloc_memory(ctx->mailbox);
hdr = mutt_header_new();
ctx->mailbox->hdrs[ctx->mailbox->msg_count] = hdr;
hdr->offset = loc;
*/
static int mbox_parse_mailbox(struct Context *ctx)
{
- struct MboxData *mdata = get_mboxdata(ctx);
+ struct MboxData *mdata = get_mboxdata(ctx->mailbox);
if (!mdata)
return -1;
}
if (ctx->mailbox->msg_count == ctx->mailbox->hdrmax)
- mx_alloc_memory(ctx);
+ mx_alloc_memory(ctx->mailbox);
ctx->mailbox->hdrs[ctx->mailbox->msg_count] = mutt_header_new();
curhdr = ctx->mailbox->hdrs[ctx->mailbox->msg_count];
if (init_mailbox(mailbox) != 0)
return -1;
- struct MboxData *mdata = get_mboxdata(ctx);
+ struct MboxData *mdata = get_mboxdata(mailbox);
if (!mdata)
return -1;
return -1;
}
mutt_sig_block();
- if (mbox_lock_mailbox(ctx, 0, 1) == -1)
+ if (mbox_lock_mailbox(mailbox, false, true) == -1)
{
mutt_sig_unblock();
return -1;
rc = -1;
mutt_file_touch_atime(fileno(mdata->fp));
- mbox_unlock_mailbox(ctx);
+ mbox_unlock_mailbox(mailbox);
mutt_sig_unblock();
return rc;
}
if (init_mailbox(mailbox) != 0)
return -1;
- struct MboxData *mdata = get_mboxdata(ctx);
+ struct MboxData *mdata = get_mboxdata(mailbox);
if (!mdata)
return -1;
return -1;
}
- if (mbox_lock_mailbox(ctx, 1, 1) != 0)
+ if (mbox_lock_mailbox(mailbox, true, true) != false)
{
mutt_error(_("Couldn't lock %s"), mailbox->path);
mutt_file_fclose(&mdata->fp);
*/
static int mbox_mbox_close(struct Context *ctx)
{
- struct MboxData *mdata = get_mboxdata(ctx);
+ struct MboxData *mdata = get_mboxdata(ctx->mailbox);
if (!mdata)
return -1;
*/
static int mbox_msg_open(struct Context *ctx, struct Message *msg, int msgno)
{
- struct MboxData *mdata = get_mboxdata(ctx);
+ struct MboxData *mdata = get_mboxdata(ctx->mailbox);
if (!mdata)
return -1;
*/
static int mbox_msg_open_new(struct Context *ctx, struct Message *msg, struct Header *hdr)
{
- struct MboxData *mdata = get_mboxdata(ctx);
+ struct MboxData *mdata = get_mboxdata(ctx->mailbox);
if (!mdata)
return -1;
*/
static int reopen_mailbox(struct Context *ctx, int *index_hint)
{
- struct MboxData *mdata = get_mboxdata(ctx);
+ struct MboxData *mdata = get_mboxdata(ctx->mailbox);
if (!mdata)
return -1;
ctx->mailbox->changed = false;
ctx->mailbox->id_hash = NULL;
ctx->mailbox->subj_hash = NULL;
- mutt_make_label_hash(ctx);
+ mutt_make_label_hash(ctx->mailbox);
switch (ctx->mailbox->magic)
{
*/
static int mbox_mbox_check(struct Context *ctx, int *index_hint)
{
- struct MboxData *mdata = get_mboxdata(ctx);
+ struct MboxData *mdata = get_mboxdata(ctx->mailbox);
if (!mdata)
return -1;
if (!mdata->locked)
{
mutt_sig_block();
- if (mbox_lock_mailbox(ctx, 0, 0) == -1)
+ if (mbox_lock_mailbox(ctx->mailbox, false, false) == -1)
{
mutt_sig_unblock();
/* we couldn't lock the mailbox, but nothing serious happened:
if (unlock)
{
- mbox_unlock_mailbox(ctx);
+ mbox_unlock_mailbox(ctx->mailbox);
mutt_sig_unblock();
}
{
if (unlock)
{
- mbox_unlock_mailbox(ctx);
+ mbox_unlock_mailbox(ctx->mailbox);
mutt_sig_unblock();
}
return MUTT_REOPENED;
/* fatal error */
- mbox_unlock_mailbox(ctx);
+ mbox_unlock_mailbox(ctx->mailbox);
mx_fastclose_mailbox(ctx);
mutt_sig_unblock();
mutt_error(_("Mailbox was corrupted"));
*/
static int mbox_mbox_sync(struct Context *ctx, int *index_hint)
{
- struct MboxData *mdata = get_mboxdata(ctx);
+ struct MboxData *mdata = get_mboxdata(ctx->mailbox);
if (!mdata)
return -1;
mutt_sig_block();
- if (mbox_lock_mailbox(ctx, 1, 1) == -1)
+ if (mbox_lock_mailbox(ctx->mailbox, true, true) == -1)
{
mutt_sig_unblock();
mutt_error(_("Unable to lock mailbox"));
mutt_file_fclose(&fp);
fp = NULL;
- mbox_unlock_mailbox(ctx);
+ mbox_unlock_mailbox(ctx->mailbox);
if (mutt_file_fclose(&mdata->fp) != 0 || i == -1)
{
}
/* this is ok to call even if we haven't locked anything */
- mbox_unlock_mailbox(ctx);
+ mbox_unlock_mailbox(ctx->mailbox);
mutt_sig_unblock();
FREE(&new_offset);
/**
* label_ref_dec - Decrease the refcount of a label
- * @param ctx Mailbox
+ * @param mailbox Mailbox
* @param label Label
*/
-static void label_ref_dec(struct Context *ctx, char *label)
+static void label_ref_dec(struct Mailbox *mailbox, char *label)
{
- struct HashElem *elem = mutt_hash_find_elem(ctx->mailbox->label_hash, label);
+ struct HashElem *elem = mutt_hash_find_elem(mailbox->label_hash, label);
if (!elem)
return;
uintptr_t count = (uintptr_t) elem->data;
if (count <= 1)
{
- mutt_hash_delete(ctx->mailbox->label_hash, label, NULL);
+ mutt_hash_delete(mailbox->label_hash, label, NULL);
return;
}
/**
* label_ref_inc - Increase the refcount of a label
- * @param ctx Mailbox
+ * @param mailbox Mailbox
* @param label Label
*/
-static void label_ref_inc(struct Context *ctx, char *label)
+static void label_ref_inc(struct Mailbox *mailbox, char *label)
{
uintptr_t count;
- struct HashElem *elem = mutt_hash_find_elem(ctx->mailbox->label_hash, label);
+ struct HashElem *elem = mutt_hash_find_elem(mailbox->label_hash, label);
if (!elem)
{
count = 1;
- mutt_hash_insert(ctx->mailbox->label_hash, label, (void *) count);
+ mutt_hash_insert(mailbox->label_hash, label, (void *) count);
return;
}
/**
* label_message - add an X-Label: field
- * @param[in] ctx Mailbox
+ * @param[in] mailbox Mailbox
* @param[in] hdr Header of email
* @param[out] new Set to true if this is a new label
* @retval true If the label was added
*/
-static bool label_message(struct Context *ctx, struct Header *hdr, char *new)
+static bool label_message(struct Mailbox *mailbox, struct Header *hdr, char *new)
{
if (!hdr)
return false;
return false;
if (hdr->env->x_label)
- label_ref_dec(ctx, hdr->env->x_label);
+ label_ref_dec(mailbox, hdr->env->x_label);
mutt_str_replace(&hdr->env->x_label, new);
if (hdr->env->x_label)
- label_ref_inc(ctx, hdr->env->x_label);
+ label_ref_inc(mailbox, hdr->env->x_label);
hdr->changed = true;
hdr->xlabel_changed = true;
changed = 0;
if (hdr)
{
- if (label_message(Context, hdr, new))
+ if (label_message(Context->mailbox, hdr, new))
{
changed++;
mutt_set_header_color(Context, hdr);
continue;
struct Header *h = Context->mailbox->hdrs[i];
- if (label_message(Context, h, new))
+ if (label_message(Context->mailbox, h, new))
{
changed++;
mutt_set_flag(Context, h, MUTT_TAG, 0);
/**
* mutt_make_label_hash - Create a Hash Table to store the labels
- * @param ctx Mailbox
+ * @param mailbox Mailbox
*/
-void mutt_make_label_hash(struct Context *ctx)
+void mutt_make_label_hash(struct Mailbox *mailbox)
{
/* 131 is just a rough prime estimate of how many distinct
* labels someone might have in a mailbox.
*/
- ctx->mailbox->label_hash = mutt_hash_create(131, MUTT_HASH_STRDUP_KEYS);
+ mailbox->label_hash = mutt_hash_create(131, MUTT_HASH_STRDUP_KEYS);
}
/**
* mutt_label_hash_add - Add a message's labels to the Hash Table
- * @param ctx Mailbox
+ * @param mailbox Mailbox
* @param hdr Header of message
*/
-void mutt_label_hash_add(struct Context *ctx, struct Header *hdr)
+void mutt_label_hash_add(struct Mailbox *mailbox, struct Header *hdr)
{
- if (!ctx || !ctx->mailbox->label_hash)
+ if (!mailbox || !mailbox->label_hash)
return;
if (hdr->env->x_label)
- label_ref_inc(ctx, hdr->env->x_label);
+ label_ref_inc(mailbox, hdr->env->x_label);
}
/**
* mutt_label_hash_remove - Rmove a message's labels from the Hash Table
- * @param ctx Mailbox
+ * @param mailbox Mailbox
* @param hdr Header of message
*/
-void mutt_label_hash_remove(struct Context *ctx, struct Header *hdr)
+void mutt_label_hash_remove(struct Mailbox *mailbox, struct Header *hdr)
{
- if (!ctx || !ctx->mailbox->label_hash)
+ if (!mailbox || !mailbox->label_hash)
return;
if (hdr->env->x_label)
- label_ref_dec(ctx, hdr->env->x_label);
+ label_ref_dec(mailbox, hdr->env->x_label);
}
struct Header;
void mutt_edit_headers(const char *editor, const char *body, struct Header *msg, char *fcc, size_t fcclen);
-void mutt_label_hash_add(struct Context *ctx, struct Header *hdr);
-void mutt_label_hash_remove(struct Context *ctx, struct Header *hdr);
+void mutt_label_hash_add(struct Mailbox *mailbox, struct Header *hdr);
+void mutt_label_hash_remove(struct Mailbox *mailbox, struct Header *hdr);
int mutt_label_message(struct Header *hdr);
-void mutt_make_label_hash(struct Context *ctx);
+void mutt_make_label_hash(struct Mailbox *mailbox);
#endif /* MUTT_MUTT_HEADER_H */
/**
* mutt_make_id_hash - Create a Hash Table for message-ids
- * @param ctx Mailbox
+ * @param mailbox Mailbox
* @retval ptr Newly allocated Hash Table
*/
-struct Hash *mutt_make_id_hash(struct Context *ctx)
+struct Hash *mutt_make_id_hash(struct Mailbox *mailbox)
{
- struct Hash *hash = mutt_hash_create(ctx->mailbox->msg_count * 2, 0);
+ struct Hash *hash = mutt_hash_create(mailbox->msg_count * 2, 0);
- for (int i = 0; i < ctx->mailbox->msg_count; i++)
+ for (int i = 0; i < mailbox->msg_count; i++)
{
- struct Header *hdr = ctx->mailbox->hdrs[i];
+ struct Header *hdr = mailbox->hdrs[i];
if (hdr->env->message_id)
mutt_hash_insert(hash, hdr->env->message_id, hdr);
}
void mutt_sort_threads(struct Context *ctx, bool init);
int mutt_parent_message(struct Context *ctx, struct Header *hdr, bool find_root);
void mutt_set_virtual(struct Context *ctx);
-struct Hash *mutt_make_id_hash(struct Context *ctx);
+struct Hash *mutt_make_id_hash(struct Mailbox *mailbox);
#endif /* MUTT_MUTT_THREAD_H */
return NULL;
}
- mutt_make_label_hash(ctx);
+ mutt_make_label_hash(ctx->mailbox);
/* if the user has a `push' command in their .neomuttrc, or in a folder-hook,
* it will cause the progress messages not to be displayed because
if (ctx->mailbox->id_hash && ctx->mailbox->hdrs[i]->env->message_id)
mutt_hash_delete(ctx->mailbox->id_hash, ctx->mailbox->hdrs[i]->env->message_id,
ctx->mailbox->hdrs[i]);
- mutt_label_hash_remove(ctx, ctx->mailbox->hdrs[i]);
+ mutt_label_hash_remove(ctx->mailbox, ctx->mailbox->hdrs[i]);
/* The path mx_mbox_check() -> imap_check_mailbox() ->
* imap_expunge_mailbox() -> mx_update_tables()
* can occur before a call to mx_mbox_sync(), resulting in
/**
* mx_alloc_memory - Create storage for the emails
- * @param ctx Mailbox
+ * @param mailbox Mailbox
*/
-void mx_alloc_memory(struct Context *ctx)
+void mx_alloc_memory(struct Mailbox *mailbox)
{
size_t s = MAX(sizeof(struct Header *), sizeof(int));
- if ((ctx->mailbox->hdrmax + 25) * s < ctx->mailbox->hdrmax * s)
+ if ((mailbox->hdrmax + 25) * s < mailbox->hdrmax * s)
{
mutt_error(_("Out of memory"));
mutt_exit(1);
}
- if (ctx->mailbox->hdrs)
+ if (mailbox->hdrs)
{
- mutt_mem_realloc(&ctx->mailbox->hdrs,
- sizeof(struct Header *) * (ctx->mailbox->hdrmax += 25));
- mutt_mem_realloc(&ctx->mailbox->v2r, sizeof(int) * ctx->mailbox->hdrmax);
+ mutt_mem_realloc(&mailbox->hdrs, sizeof(struct Header *) * (mailbox->hdrmax += 25));
+ mutt_mem_realloc(&mailbox->v2r, sizeof(int) * mailbox->hdrmax);
}
else
{
- ctx->mailbox->hdrs =
- mutt_mem_calloc((ctx->mailbox->hdrmax += 25), sizeof(struct Header *));
- ctx->mailbox->v2r = mutt_mem_calloc(ctx->mailbox->hdrmax, sizeof(int));
+ mailbox->hdrs = mutt_mem_calloc((mailbox->hdrmax += 25), sizeof(struct Header *));
+ mailbox->v2r = mutt_mem_calloc(mailbox->hdrmax, sizeof(int));
}
- for (int i = ctx->mailbox->msg_count; i < ctx->mailbox->hdrmax; i++)
+ for (int i = mailbox->msg_count; i < mailbox->hdrmax; i++)
{
- ctx->mailbox->hdrs[i] = NULL;
- ctx->mailbox->v2r[i] = -1;
+ mailbox->hdrs[i] = NULL;
+ mailbox->v2r[i] = -1;
}
}
struct Header *h2 = NULL;
if (!ctx->mailbox->id_hash)
- ctx->mailbox->id_hash = mutt_make_id_hash(ctx);
+ ctx->mailbox->id_hash = mutt_make_id_hash(ctx->mailbox);
h2 = mutt_hash_find(ctx->mailbox->id_hash, h->env->supersedes);
if (h2)
mutt_hash_insert(ctx->mailbox->id_hash, h->env->message_id, h);
if (ctx->mailbox->subj_hash && h->env->real_subj)
mutt_hash_insert(ctx->mailbox->subj_hash, h->env->real_subj, h);
- mutt_label_hash_add(ctx, h);
+ mutt_label_hash_add(ctx->mailbox, h);
if (Score)
mutt_score_message(ctx, h, false);
int mx_tags_edit (struct Context *ctx, const char *tags, char *buf, size_t buflen);
int mx_access(const char *path, int flags);
-void mx_alloc_memory(struct Context *ctx);
+void mx_alloc_memory(struct Mailbox *mailbox);
int mx_check_empty(const char *path);
int mx_check_mailbox(struct Context *ctx, int *index_hint);
void mx_fastclose_mailbox(struct Context *ctx);
/**
* nntp_select_server - Open a connection to an NNTP server
- * @param ctx Mailbox
+ * @param mailbox Mailbox
* @param server Server URI
* @param leave_lock Leave the server locked?
* @retval ptr NNTP server
* system has broken mtimes, this might mean the file is reloaded every time,
* which we'd have to fix.
*/
-struct NntpServer *nntp_select_server(struct Context *ctx, char *server, bool leave_lock)
+struct NntpServer *nntp_select_server(struct Mailbox *mailbox, char *server, bool leave_lock)
{
char file[PATH_MAX];
#ifdef USE_HCACHE
return NULL;
/* check for new newsgroups */
- if (!leave_lock && nntp_check_new_groups(ctx->mailbox, nserv) < 0)
+ if (!leave_lock && nntp_check_new_groups(mailbox, nserv) < 0)
rc = -1;
/* .newsrc has been externally modified */
{
/* try to load list of newsgroups from cache */
if (nserv->cacheable && active_get_cache(nserv) == 0)
- rc = nntp_check_new_groups(ctx->mailbox, nserv);
+ rc = nntp_check_new_groups(mailbox, nserv);
/* load list of newsgroups from server */
else
/* allocate memory for headers */
if (ctx->mailbox->msg_count >= ctx->mailbox->hdrmax)
- mx_alloc_memory(ctx);
+ mx_alloc_memory(ctx->mailbox);
/* parse header */
ctx->mailbox->hdrs[ctx->mailbox->msg_count] = mutt_header_new();
/* allocate memory for headers */
if (ctx->mailbox->msg_count >= ctx->mailbox->hdrmax)
- mx_alloc_memory(ctx);
+ mx_alloc_memory(ctx->mailbox);
#ifdef USE_HCACHE
/* try to fetch header from cache */
group = url.path;
url.path = strchr(url.path, '\0');
url_tostring(&url, server, sizeof(server), 0);
- nserv = nntp_select_server(ctx, server, true);
+ nserv = nntp_select_server(ctx->mailbox, server, true);
url_free(&url);
if (!nserv)
return -1;
/**
* nntp_post - Post article
- * @param ctx Mailbox
- * @param msg Message to post
+ * @param mailbox Mailbox
+ * @param msg Message to post
* @retval 0 Success
* @retval -1 Failure
*/
-int nntp_post(struct Context *ctx, const char *msg)
+int nntp_post(struct Mailbox *mailbox, const char *msg)
{
struct NntpData *nntp_data = NULL;
struct NntpData nntp_tmp = { 0 };
char buf[LONG_STRING];
- if (ctx && (ctx->mailbox->magic == MUTT_NNTP))
- nntp_data = ctx->mailbox->data;
+ if (mailbox && (mailbox->magic == MUTT_NNTP))
+ nntp_data = mailbox->data;
else
{
- CurrentNewsSrv = nntp_select_server(ctx, NewsServer, false);
+ CurrentNewsSrv = nntp_select_server(mailbox, NewsServer, false);
if (!CurrentNewsSrv)
return -1;
{
mutt_debug(2, "#2 mutt_hcache_fetch %s\n", buf);
if (ctx->mailbox->msg_count >= ctx->mailbox->hdrmax)
- mx_alloc_memory(ctx);
+ mx_alloc_memory(ctx->mailbox);
hdr = mutt_hcache_restore(hdata);
ctx->mailbox->hdrs[ctx->mailbox->msg_count] = hdr;
/* parse header */
if (ctx->mailbox->msg_count == ctx->mailbox->hdrmax)
- mx_alloc_memory(ctx);
+ mx_alloc_memory(ctx->mailbox);
ctx->mailbox->hdrs[ctx->mailbox->msg_count] = mutt_header_new();
struct Header *hdr = ctx->mailbox->hdrs[ctx->mailbox->msg_count];
hdr->data = mutt_mem_calloc(1, sizeof(struct NntpHeaderData));
struct BodyCache *bcache;
};
-struct NntpServer *nntp_select_server(struct Context *ctx, char *server, bool leave_lock);
+struct NntpServer *nntp_select_server(struct Mailbox *mailbox, char *server, bool leave_lock);
struct NntpData *mutt_newsgroup_subscribe(struct NntpServer *nserv, char *group);
struct NntpData *mutt_newsgroup_unsubscribe(struct NntpServer *nserv, char *group);
struct NntpData *mutt_newsgroup_catchup(struct Context *ctx, struct NntpServer *nserv, char *group);
struct NntpData *mutt_newsgroup_uncatchup(struct Context *ctx, struct NntpServer *nserv, char *group);
int nntp_active_fetch(struct NntpServer *nserv, bool new);
int nntp_newsrc_update(struct NntpServer *nserv);
-int nntp_post(struct Context *ctx, const char *msg);
+int nntp_post(struct Mailbox *mailbox, const char *msg);
int nntp_check_msgid(struct Context *ctx, const char *msgid);
int nntp_check_children(struct Context *ctx, const char *msgid);
int nntp_newsrc_parse(struct NntpServer *nserv);
/**
* get_mutt_header - Get the Header of a Notmuch message
- * @param ctx Mailbox
+ * @param mailbox Mailbox
* @param msg Notmuch message
* @retval ptr Email Header
* @retval NULL Error
*/
-static struct Header *get_mutt_header(struct Context *ctx, notmuch_message_t *msg)
+static struct Header *get_mutt_header(struct Mailbox *mailbox, notmuch_message_t *msg)
{
char *mid = NULL;
const char *id = NULL;
struct Header *h = NULL;
- if (!ctx || !msg)
+ if (!mailbox || !msg)
return NULL;
id = notmuch_message_get_message_id(msg);
mutt_debug(2, "nm: neomutt header, id='%s'\n", id);
- if (!ctx->mailbox->id_hash)
+ if (!mailbox->id_hash)
{
mutt_debug(2, "nm: init hash\n");
- ctx->mailbox->id_hash = mutt_make_id_hash(ctx);
- if (!ctx->mailbox->id_hash)
+ mailbox->id_hash = mutt_make_id_hash(mailbox);
+ if (!mailbox->id_hash)
return NULL;
}
mid = nm2mutt_message_id(id);
mutt_debug(2, "nm: neomutt id='%s'\n", mid);
- h = mutt_hash_find(ctx->mailbox->id_hash, mid);
+ h = mutt_hash_find(mailbox->id_hash, mid);
FREE(&mid);
return h;
}
/**
* append_message - Associate a message
- * @param ctx Mailbox
- * @param q Notmuch query
- * @param msg Notmuch message
- * @param dedup De-duplicate results
+ * @param mailbox Mailbox
+ * @param q Notmuch query
+ * @param msg Notmuch message
+ * @param dedup De-duplicate results
*/
-static void append_message(struct Context *ctx, notmuch_query_t *q,
+static void append_message(struct Mailbox *mailbox, notmuch_query_t *q,
notmuch_message_t *msg, bool dedup)
{
char *newpath = NULL;
const char *path = NULL;
struct Header *h = NULL;
- struct NmMboxData *data = get_mboxdata(ctx->mailbox);
+ struct NmMboxData *data = get_mboxdata(mailbox);
if (!data)
return;
/* deduplicate */
- if (dedup && get_mutt_header(ctx, msg))
+ if (dedup && get_mutt_header(mailbox, msg))
{
data->ignmsgcount++;
- progress_update(ctx->mailbox, q);
+ progress_update(mailbox, q);
mutt_debug(2, "nm: ignore id=%s, already in the mailbox\n",
notmuch_message_get_message_id(msg));
return;
return;
mutt_debug(2, "nm: appending message, i=%d, id=%s, path=%s\n",
- ctx->mailbox->msg_count, notmuch_message_get_message_id(msg), path);
+ mailbox->msg_count, notmuch_message_get_message_id(msg), path);
- if (ctx->mailbox->msg_count >= ctx->mailbox->hdrmax)
+ if (mailbox->msg_count >= mailbox->hdrmax)
{
mutt_debug(2, "nm: allocate mx memory\n");
- mx_alloc_memory(ctx);
+ mx_alloc_memory(mailbox);
}
if (access(path, F_OK) == 0)
h = maildir_parse_message(MUTT_MAILDIR, path, false, NULL);
}
h->active = true;
- h->index = ctx->mailbox->msg_count;
- ctx->mailbox->size += h->content->length + h->content->offset - h->content->hdr_offset;
- ctx->mailbox->hdrs[ctx->mailbox->msg_count] = h;
- ctx->mailbox->msg_count++;
+ h->index = mailbox->msg_count;
+ mailbox->size += h->content->length + h->content->offset - h->content->hdr_offset;
+ mailbox->hdrs[mailbox->msg_count] = h;
+ mailbox->msg_count++;
if (newpath)
{
hd->oldpath = mutt_str_strdup(path);
}
}
- progress_update(ctx->mailbox, q);
+ progress_update(mailbox, q);
done:
FREE(&newpath);
}
/**
* append_replies - add all the replies to a given messages into the display
- * @param ctx Mailbox
- * @param q Notmuch query
- * @param top Notmuch message
- * @param dedup De-duplicate the results
+ * @param mailbox Mailbox
+ * @param q Notmuch query
+ * @param top Notmuch message
+ * @param dedup De-duplicate the results
*
* Careful, this calls itself recursively to make sure we get everything.
*/
-static void append_replies(struct Context *ctx, notmuch_query_t *q,
+static void append_replies(struct Mailbox *mailbox, notmuch_query_t *q,
notmuch_message_t *top, bool dedup)
{
notmuch_messages_t *msgs = NULL;
notmuch_messages_move_to_next(msgs))
{
notmuch_message_t *m = notmuch_messages_get(msgs);
- append_message(ctx, q, m, dedup);
+ append_message(mailbox, q, m, dedup);
/* recurse through all the replies to this message too */
- append_replies(ctx, q, m, dedup);
+ append_replies(mailbox, q, m, dedup);
notmuch_message_destroy(m);
}
}
/**
* append_thread - add each top level reply in the thread
- * @param ctx Mailbox
- * @param q Notmuch query
- * @param thread Notmuch thread
- * @param dedup De-duplicate the results
+ * @param mailbox Mailbox
+ * @param q Notmuch query
+ * @param thread Notmuch thread
+ * @param dedup De-duplicate the results
*
* add each top level reply in the thread, and then add each reply to the top
* level replies
*/
-static void append_thread(struct Context *ctx, notmuch_query_t *q,
+static void append_thread(struct Mailbox *mailbox, notmuch_query_t *q,
notmuch_thread_t *thread, bool dedup)
{
notmuch_messages_t *msgs = NULL;
notmuch_messages_valid(msgs); notmuch_messages_move_to_next(msgs))
{
notmuch_message_t *m = notmuch_messages_get(msgs);
- append_message(ctx, q, m, dedup);
- append_replies(ctx, q, m, dedup);
+ append_message(mailbox, q, m, dedup);
+ append_replies(mailbox, q, m, dedup);
notmuch_message_destroy(m);
}
}
/**
* read_mesgs_query - Search for matching messages
- * @param ctx Mailbox
- * @param q Notmuch query
- * @param dedup De-duplicate the results
+ * @param mailbox Mailbox
+ * @param q Notmuch query
+ * @param dedup De-duplicate the results
* @retval true Success
* @retval false Failure
*/
-static bool read_mesgs_query(struct Context *ctx, notmuch_query_t *q, bool dedup)
+static bool read_mesgs_query(struct Mailbox *mailbox, notmuch_query_t *q, bool dedup)
{
- struct NmMboxData *data = get_mboxdata(ctx->mailbox);
+ struct NmMboxData *data = get_mboxdata(mailbox);
int limit;
notmuch_messages_t *msgs = NULL;
msgs = notmuch_query_search_messages(q);
#endif
- for (; notmuch_messages_valid(msgs) && ((limit == 0) || (ctx->mailbox->msg_count < limit));
+ for (; notmuch_messages_valid(msgs) && ((limit == 0) || (mailbox->msg_count < limit));
notmuch_messages_move_to_next(msgs))
{
if (SigInt == 1)
return false;
}
notmuch_message_t *m = notmuch_messages_get(msgs);
- append_message(ctx, q, m, dedup);
+ append_message(mailbox, q, m, dedup);
notmuch_message_destroy(m);
}
return true;
/**
* read_threads_query - Perform a query with threads
- * @param ctx Mailbox
- * @param q Query type
- * @param dedup Should the results be de-duped?
- * @param limit Maximum number of results
+ * @param mailbox Mailbox
+ * @param q Query type
+ * @param dedup Should the results be de-duped?
+ * @param limit Maximum number of results
* @retval true Success
* @retval false Failure
*/
-static bool read_threads_query(struct Context *ctx, notmuch_query_t *q, bool dedup, int limit)
+static bool read_threads_query(struct Mailbox *mailbox, notmuch_query_t *q, bool dedup, int limit)
{
- struct NmMboxData *data = get_mboxdata(ctx->mailbox);
+ struct NmMboxData *data = get_mboxdata(mailbox);
notmuch_threads_t *threads = NULL;
if (!data)
#endif
for (; notmuch_threads_valid(threads) &&
- ((limit == 0) || (ctx->mailbox->msg_count < limit));
+ ((limit == 0) || (mailbox->msg_count < limit));
notmuch_threads_move_to_next(threads))
{
if (SigInt == 1)
return false;
}
notmuch_thread_t *thread = notmuch_threads_get(threads);
- append_thread(ctx, q, thread, dedup);
+ append_thread(mailbox, q, thread, dedup);
notmuch_thread_destroy(thread);
}
return true;
apply_exclude_tags(q);
notmuch_query_set_sort(q, NOTMUCH_SORT_NEWEST_FIRST);
- read_threads_query(ctx, q, true, 0);
+ read_threads_query(ctx->mailbox, q, true, 0);
ctx->mailbox->mtime.tv_sec = time(NULL);
ctx->mailbox->mtime.tv_nsec = 0;
rc = 0;
/**
* nm_update_filename - Change the filename
- * @param ctx Mailbox
+ * @param mailbox Mailbox
* @param old Old filename
* @param new New filename
* @param h Email Header
* @retval 0 Success
* @retval -1 Failure
*/
-int nm_update_filename(struct Context *ctx, const char *old, const char *new,
+int nm_update_filename(struct Mailbox *mailbox, const char *old, const char *new,
struct Header *h)
{
char buf[PATH_MAX];
int rc;
- struct NmMboxData *data = get_mboxdata(ctx->mailbox);
+ struct NmMboxData *data = get_mboxdata(mailbox);
if (!data || !new)
return -1;
if (!is_longrun(data))
release_db(data);
- ctx->mailbox->mtime.tv_sec = time(NULL);
- ctx->mailbox->mtime.tv_nsec = 0;
+ mailbox->mtime.tv_sec = time(NULL);
+ mailbox->mtime.tv_nsec = 0;
return rc;
}
switch (data->query_type)
{
case NM_QUERY_TYPE_MESGS:
- if (!read_mesgs_query(ctx, q, false))
+ if (!read_mesgs_query(ctx->mailbox, q, false))
rc = -2;
break;
case NM_QUERY_TYPE_THREADS:
- if (!read_threads_query(ctx, q, false, get_limit(data)))
+ if (!read_threads_query(ctx->mailbox, q, false, get_limit(data)))
rc = -2;
break;
}
if (ctx->mailbox->mtime.tv_sec >= mtime)
{
- mutt_debug(2, "nm: check unnecessary (db=%lu ctx=%lu)\n", mtime,
+ mutt_debug(2, "nm: check unnecessary (db=%lu mailbox=%lu)\n", mtime,
ctx->mailbox->mtime);
return 0;
}
- mutt_debug(1, "nm: checking (db=%lu ctx=%lu)\n", mtime, ctx->mailbox->mtime);
+ mutt_debug(1, "nm: checking (db=%lu mailbox=%lu)\n", mtime, ctx->mailbox->mtime);
q = get_query(data, false);
if (!q)
const char *new = NULL;
notmuch_message_t *m = notmuch_messages_get(msgs);
- struct Header *h = get_mutt_header(ctx, m);
+ struct Header *h = get_mutt_header(ctx->mailbox, m);
if (!h)
{
/* new email */
- append_message(ctx, NULL, m, 0);
+ append_message(ctx->mailbox, NULL, m, 0);
notmuch_message_destroy(m);
continue;
}
int nm_read_entire_thread(struct Context *ctx, struct Header *h);
char *nm_header_get_folder(struct Header *h);
-int nm_update_filename(struct Context *ctx, const char *old, const char *new, struct Header *h);
+int nm_update_filename(struct Mailbox *mailbox, const char *old, const char *new, struct Header *h);
bool nm_normalize_uri(const char *uri, char *buf, size_t buflen);
char *nm_uri_from_query(struct Mailbox *mailbox, char *buf, size_t buflen);
bool nm_message_is_still_queried(struct Mailbox *mailbox, struct Header *hdr);
static int fetch_uidl(char *line, void *data)
{
int i, index;
- struct Context *ctx = data;
- struct PopData *pop_data = ctx->mailbox->data;
+ struct Mailbox *mailbox = data;
+ struct PopData *pop_data = mailbox->data;
char *endp = NULL;
errno = 0;
if (strlen(line) == 0)
return -1;
- for (i = 0; i < ctx->mailbox->msg_count; i++)
- if (mutt_str_strcmp(line, ctx->mailbox->hdrs[i]->data) == 0)
+ for (i = 0; i < mailbox->msg_count; i++)
+ if (mutt_str_strcmp(line, mailbox->hdrs[i]->data) == 0)
break;
- if (i == ctx->mailbox->msg_count)
+ if (i == mailbox->msg_count)
{
mutt_debug(1, "new header %d %s\n", index, line);
- if (i >= ctx->mailbox->hdrmax)
- mx_alloc_memory(ctx);
+ if (i >= mailbox->hdrmax)
+ mx_alloc_memory(mailbox);
- ctx->mailbox->msg_count++;
- ctx->mailbox->hdrs[i] = mutt_header_new();
- ctx->mailbox->hdrs[i]->data = mutt_str_strdup(line);
+ mailbox->msg_count++;
+ mailbox->hdrs[i] = mutt_header_new();
+ mailbox->hdrs[i]->data = mutt_str_strdup(line);
}
- else if (ctx->mailbox->hdrs[i]->index != index - 1)
+ else if (mailbox->hdrs[i]->index != index - 1)
pop_data->clear_cache = true;
- ctx->mailbox->hdrs[i]->refno = index;
- ctx->mailbox->hdrs[i]->index = index - 1;
+ mailbox->hdrs[i]->refno = index;
+ mailbox->hdrs[i]->index = index - 1;
return 0;
}
ctx->mailbox->hdrs[i]->refno = -1;
const int old_count = ctx->mailbox->msg_count;
- int ret = pop_fetch_data(pop_data, "UIDL\r\n", NULL, fetch_uidl, ctx);
+ int ret = pop_fetch_data(pop_data, "UIDL\r\n", NULL, fetch_uidl, ctx->mailbox);
const int new_count = ctx->mailbox->msg_count;
ctx->mailbox->msg_count = old_count;
/* we replace envelop, key in subj_hash has to be updated as well */
if (ctx->mailbox->subj_hash && h->env->real_subj)
mutt_hash_delete(ctx->mailbox->subj_hash, h->env->real_subj, h);
- mutt_label_hash_remove(ctx, h);
+ mutt_label_hash_remove(ctx->mailbox, h);
mutt_env_free(&h->env);
h->env = mutt_rfc822_read_header(msg->fp, h, false, false);
if (ctx->mailbox->subj_hash && h->env->real_subj)
mutt_hash_insert(ctx->mailbox->subj_hash, h->env->real_subj, h);
- mutt_label_hash_add(ctx, h);
+ mutt_label_hash_add(ctx->mailbox, h);
h->data = uidl;
h->lines = 0;
pop_data->check_time = 0;
+ int num_deleted = 0;
+ for (i = 0; i < ctx->mailbox->msg_count; i++)
+ {
+ if (ctx->mailbox->hdrs[i]->deleted)
+ num_deleted++;
+ }
+
while (true)
{
if (pop_reconnect(ctx->mailbox) < 0)
return -1;
mutt_progress_init(&progress, _("Marking messages deleted..."),
- MUTT_PROGRESS_MSG, WriteInc, ctx->deleted);
+ MUTT_PROGRESS_MSG, WriteInc, num_deleted);
#ifdef USE_HCACHE
hc = pop_hcache_open(pop_data, ctx->mailbox->path);
the user attempted to reply to is in this mailbox */
p = mutt_str_skip_email_wsp(np->data + 18);
if (!ctx->mailbox->id_hash)
- ctx->mailbox->id_hash = mutt_make_id_hash(ctx);
+ ctx->mailbox->id_hash = mutt_make_id_hash(ctx->mailbox);
*cur = mutt_hash_find(ctx->mailbox->id_hash, p);
}
if (*cur)
NONULL(Inews), nntp_format_str, 0, 0);
if (!*cmd)
{
- i = nntp_post(Context, msg);
+ i = nntp_post(Context->mailbox, msg);
unlink(msg);
return i;
}