break;
case MUTT_SERVERSEARCH:
{
- struct ImapAccountData *adata = mailbox->data;
+ struct ImapAccountData *adata = imap_get_adata(mailbox);
if (!mutt_bit_isset(adata->capabilities, X_GM_EXT1))
{
mutt_error(_("Server-side custom search not supported: %s"), pat->p.str);
int imap_delete_mailbox(struct Mailbox *mailbox, struct ImapMbox *mx)
{
char buf[PATH_MAX], mbox[PATH_MAX];
- struct ImapAccountData *adata = NULL;
+ struct ImapAccountData *adata = imap_get_adata(mailbox);
- if (!mailbox || !mailbox->data)
+ if (!mailbox || !adata)
{
adata = imap_conn_find(&mx->account, ImapPassive ? MUTT_IMAP_CONN_NONEW : 0);
if (!adata)
*/
int imap_check_mailbox(struct Mailbox *mailbox, bool force)
{
- return imap_check(mailbox->data, force);
+ struct ImapAccountData *adata = imap_get_adata(mailbox);
+ return imap_check(adata, force);
}
/**
int imap_search(struct Mailbox *mailbox, const struct Pattern *pat)
{
struct Buffer buf;
- struct ImapAccountData *adata = mailbox->data;
+ struct ImapAccountData *adata = imap_get_adata(mailbox);
for (int i = 0; i < mailbox->msg_count; i++)
mailbox->hdrs[i]->matched = false;
struct Buffer *sync_cmd = NULL;
int err_continue = MUTT_NO;
- struct ImapAccountData *adata = mailbox->data;
+ struct ImapAccountData *adata = imap_get_adata(mailbox);
if (imap_parse_path(dest, &mx))
{
int oldsort;
int rc;
- struct ImapAccountData *adata = ctx->mailbox->data;
+ struct ImapAccountData *adata = imap_get_adata(ctx->mailbox);
if (adata->state < IMAP_SELECTED)
{
*/
static int imap_mbox_check(struct Context *ctx, int *index_hint)
{
- int rc;
(void) index_hint;
imap_allow_reopen(ctx);
- rc = imap_check(ctx->mailbox->data, false);
+ struct ImapAccountData *adata = imap_get_adata(ctx->mailbox);
+ int rc = imap_check(adata, false);
/* NOTE - ctx might have been changed at this point. In particular,
* ctx->mailbox could be NULL. Beware. */
imap_disallow_reopen(ctx);
*/
static int imap_mbox_close(struct Context *ctx)
{
- struct ImapAccountData *adata = ctx->mailbox->data;
+ struct ImapAccountData *adata = imap_get_adata(ctx->mailbox);
/* Check to see if the mailbox is actually open */
if (!adata)
return 0;
{
char *new = NULL;
char *checker = NULL;
- struct ImapAccountData *adata = ctx->mailbox->data;
+ struct ImapAccountData *adata = imap_get_adata(ctx->mailbox);
/* Check for \* flags capability */
if (!imap_has_flag(&adata->flags, NULL))
struct Buffer *cmd = NULL;
char uid[11];
- struct ImapAccountData *adata = ctx->mailbox->data;
+ struct ImapAccountData *adata = imap_get_adata(ctx->mailbox);
if (*buf == '\0')
buf = NULL;
int rc = -1; /* default now is that string isn't FETCH response */
int parse_rc;
- struct ImapAccountData *adata = mailbox->data;
+ struct ImapAccountData *adata = imap_get_adata(mailbox);
if (buf[0] != '*')
return rc;
struct ImapMbox mx;
int rc;
- struct ImapAccountData *adata = ctx->mailbox->data;
+ struct ImapAccountData *adata = imap_get_adata(ctx->mailbox);
if (imap_parse_path(ctx->mailbox->path, &mx))
return -1;
int err_continue = MUTT_NO;
int triedcreate = 0;
- struct ImapAccountData *adata = ctx->mailbox->data;
+ struct ImapAccountData *adata = imap_get_adata(ctx->mailbox);
if (imap_parse_path(dest, &mx))
{
bool fetched = false;
int output_progress;
- struct ImapAccountData *adata = ctx->mailbox->data;
+ struct ImapAccountData *adata = imap_get_adata(ctx->mailbox);
struct Email *e = ctx->mailbox->hdrs[msgno];
msg->fp = msg_cache_get(adata, e);
char *ImapDelimChars; ///< Config: (imap) Characters that denote separators in IMAP folders
short ImapPipelineDepth; ///< Config: (imap) Number of IMAP commands that may be queued up
+/**
+ * imap_get_adata - Get the Account data for this mailbox
+ */
+struct ImapAccountData *imap_get_adata(struct Mailbox *m)
+{
+ if (!m || (m->magic != MUTT_IMAP))
+ return NULL;
+ return m->data;
+}
+
/**
* imap_expand_path - Canonicalise an IMAP path
* @param buf Buffer containing path
*/
void imap_allow_reopen(struct Context *ctx)
{
- struct ImapAccountData *adata = NULL;
- if (!ctx || !ctx->mailbox->data || ctx->mailbox->magic != MUTT_IMAP)
+ if (!ctx)
+ return;
+ struct ImapAccountData *adata = imap_get_adata(ctx->mailbox);
+ if (!adata)
return;
- adata = ctx->mailbox->data;
if (adata->ctx == ctx)
adata->reopen |= IMAP_REOPEN_ALLOW;
}
*/
void imap_disallow_reopen(struct Context *ctx)
{
- struct ImapAccountData *adata = NULL;
- if (!ctx || !ctx->mailbox || !ctx->mailbox->data || ctx->mailbox->magic != MUTT_IMAP)
+ if (!ctx)
+ return;
+ struct ImapAccountData *adata = imap_get_adata(ctx->mailbox);
+ if (!adata)
return;
- adata = ctx->mailbox->data;
if (adata->ctx == ctx)
adata->reopen &= ~IMAP_REOPEN_ALLOW;
}