{
int rc;
- if (!mutt_bit_isset(adata->capabilities, IMAP_CAP_AUTH_ANON))
+ if (!(adata->capabilities & IMAP_CAP_AUTH_ANON))
return IMAP_AUTH_UNAVAIL;
if (mutt_account_getuser(&adata->conn->account) < 0)
int len;
int rc;
- if (!mutt_bit_isset(adata->capabilities, IMAP_CAP_ACRAM_MD5))
+ if (!(adata->capabilities & IMAP_CAP_ACRAM_MD5))
return IMAP_AUTH_UNAVAIL;
mutt_message(_("Authenticating (CRAM-MD5)..."));
unsigned long buf_size;
int rc;
- if (!mutt_bit_isset(adata->capabilities, IMAP_CAP_AGSSAPI))
+ if (!(adata->capabilities & IMAP_CAP_AGSSAPI))
return IMAP_AUTH_UNAVAIL;
if (mutt_account_getuser(&adata->conn->account) < 0)
char q_user[STRING], q_pass[STRING];
char buf[LONG_STRING];
- if (mutt_bit_isset(adata->capabilities, IMAP_CAP_LOGINDISABLED))
+ if ((adata->capabilities & IMAP_CAP_LOGINDISABLED))
{
mutt_message(_("LOGIN disabled on this server"));
return IMAP_AUTH_UNAVAIL;
int rc;
/* For now, we only support SASL_IR also and over TLS */
- if (!mutt_bit_isset(adata->capabilities, IMAP_CAP_AUTH_OAUTHBEARER) ||
- !mutt_bit_isset(adata->capabilities, IMAP_CAP_SASL_IR) || !adata->conn->ssf)
+ if (!(adata->capabilities & IMAP_CAP_AUTH_OAUTHBEARER) ||
+ !(adata->capabilities & IMAP_CAP_SASL_IR) || !adata->conn->ssf)
{
return IMAP_AUTH_UNAVAIL;
}
mutt_sasl_plain_msg(buf, sizeof(buf), auth_plain_cmd, adata->conn->account.user,
adata->conn->account.user, adata->conn->account.pass);
- if (mutt_bit_isset(adata->capabilities, IMAP_CAP_SASL_IR))
+ if (adata->capabilities & IMAP_CAP_SASL_IR)
{
imap_cmd_start(adata, buf);
}
return IMAP_AUTH_FAILURE;
}
- if (mutt_bit_isset(adata->capabilities, IMAP_CAP_AUTH_ANON) &&
+ if ((adata->capabilities & IMAP_CAP_AUTH_ANON) &&
(!adata->conn->account.user[0] ||
mutt_str_startswith(adata->conn->account.user, "anonymous", CASE_MATCH)))
{
buf = mutt_mem_malloc(bufsize);
snprintf(buf, bufsize, "AUTHENTICATE %s", mech);
- if (mutt_bit_isset(adata->capabilities, IMAP_CAP_SASL_IR) && client_start)
+ if ((adata->capabilities & IMAP_CAP_SASL_IR) && client_start)
{
len = mutt_str_strlen(buf);
buf[len++] = ' ';
* Capabilities - Server capabilities strings that we understand
*
* @note This must be kept in the same order as ImapCaps.
- *
- * @note Gmail documents one string but use another, so we support both.
*/
static const char *const Capabilities[] = {
"IMAP4", "IMAP4rev1", "STATUS",
"AUTH=GSSAPI", "AUTH=ANONYMOUS", "AUTH=OAUTHBEARER",
"STARTTLS", "LOGINDISABLED", "IDLE",
"SASL-IR", "ENABLE", "CONDSTORE",
- "QRESYNC", "X-GM-EXT-1", "X-GM-EXT1",
- NULL,
+ "QRESYNC", "X-GM-EXT-1", NULL,
};
/**
*bracket = '\0';
FREE(&adata->capstr);
adata->capstr = mutt_str_strdup(s);
-
- memset(adata->capabilities, 0, sizeof(adata->capabilities));
+ adata->capabilities = 0;
while (*s)
{
- for (int i = 0; i < IMAP_CAP_MAX; i++)
+ for (size_t i = 0; Capabilities[i]; i++)
{
if (mutt_str_word_casecmp(Capabilities[i], s) == 0)
{
- mutt_bit_set(adata->capabilities, i);
+ adata->capabilities |= (1 << i);
mutt_debug(4, " Found capability \"%s\": %d\n", Capabilities[i], i);
break;
}
return -1;
}
- if (!(mutt_bit_isset(adata->capabilities, IMAP_CAP_IMAP4) ||
- mutt_bit_isset(adata->capabilities, IMAP_CAP_IMAP4REV1)))
+ if (!((adata->capabilities & IMAP_CAP_IMAP4) ||
+ (adata->capabilities & IMAP_CAP_IMAP4REV1)))
{
mutt_error(
_("This IMAP server is ancient. NeoMutt does not work with it."));
case MUTT_SERVERSEARCH:
{
struct ImapAccountData *adata = imap_adata_get(m);
- if (!mutt_bit_isset(adata->capabilities, IMAP_CAP_X_GM_EXT1))
+ if (!(adata->capabilities & IMAP_CAP_X_GM_EXT1))
{
mutt_error(_("Server-side custom search not supported: %s"), pat->p.str);
return -1;
#ifdef USE_SSL
/* Attempt STARTTLS if available and desired. */
if (!adata->conn->ssf &&
- (SslForceTls || mutt_bit_isset(adata->capabilities, IMAP_CAP_STARTTLS)))
+ (SslForceTls || (adata->capabilities & IMAP_CAP_STARTTLS)))
{
int rc;
int result = 0;
/* try IDLE first, unless force is set */
- if (!force && ImapIdle && mutt_bit_isset(adata->capabilities, IMAP_CAP_IDLE) &&
+ if (!force && ImapIdle && (adata->capabilities & IMAP_CAP_IDLE) &&
(adata->state != IMAP_IDLE || time(NULL) >= adata->lastread + ImapKeepalive))
{
if (imap_cmd_idle(adata) < 0)
if (result < 0)
{
mutt_debug(1, "Poll failed, disabling IDLE\n");
- mutt_bit_unset(adata->capabilities, IMAP_CAP_IDLE);
+ adata->capabilities &= ~IMAP_CAP_IDLE; // Clear the flag
}
}
return mdata->messages;
}
- if (mutt_bit_isset(adata->capabilities, IMAP_CAP_IMAP4REV1))
+ if (adata->capabilities & IMAP_CAP_IMAP4REV1)
uid_validity_flag = "UIDVALIDITY";
- else if (mutt_bit_isset(adata->capabilities, IMAP_CAP_STATUS))
+ else if (adata->capabilities & IMAP_CAP_STATUS)
uid_validity_flag = "UID-VALIDITY";
else
{
imap_exec(adata, "CAPABILITY", IMAP_CMD_QUEUE);
/* enable RFC6855, if the server supports that */
- if (mutt_bit_isset(adata->capabilities, IMAP_CAP_ENABLE))
+ if (adata->capabilities & IMAP_CAP_ENABLE)
imap_exec(adata, "ENABLE UTF8=ACCEPT", IMAP_CMD_QUEUE);
/* enable QRESYNC. Advertising QRESYNC also means CONDSTORE
* is supported (even if not advertised), so flip that bit. */
- if (mutt_bit_isset(adata->capabilities, IMAP_CAP_QRESYNC))
+ if (adata->capabilities & IMAP_CAP_QRESYNC)
{
- mutt_bit_set(adata->capabilities, IMAP_CAP_CONDSTORE);
+ adata->capabilities |= IMAP_CAP_CONDSTORE;
if (ImapQResync)
imap_exec(adata, "ENABLE QRESYNC", IMAP_CMD_QUEUE);
}
mutt_message(_("Selecting %s..."), mdata->name);
/* pipeline ACL test */
- if (mutt_bit_isset(adata->capabilities, IMAP_CAP_ACL))
+ if (adata->capabilities & IMAP_CAP_ACL)
{
snprintf(buf, sizeof(buf), "MYRIGHTS %s", mdata->munge_name);
imap_exec(adata, buf, IMAP_CMD_QUEUE);
imap_exec(adata, "LSUB \"\" \"*\"", IMAP_CMD_QUEUE);
#ifdef USE_HCACHE
- if (mutt_bit_isset(adata->capabilities, IMAP_CAP_CONDSTORE) && ImapCondStore)
+ if ((adata->capabilities & IMAP_CAP_CONDSTORE) && ImapCondStore)
condstore = " (CONDSTORE)";
else
#endif
/* check for READ-ONLY notification */
if (mutt_str_startswith(imap_get_qualifier(adata->buf), "[READ-ONLY]", CASE_IGNORE) &&
- !mutt_bit_isset(adata->capabilities, IMAP_CAP_ACL))
+ !(adata->capabilities & IMAP_CAP_ACL))
{
mutt_debug(2, "Mailbox is read-only.\n");
m->readonly = true;
};
/**
- * enum ImapCaps - Capabilities we are interested in
+ * ImapCaps - Capabilities we are interested in
*
* @note This must be kept in the same order as Capabilities.
*/
-enum ImapCaps
-{
- IMAP_CAP_IMAP4 = 0, ///< Server supports IMAP4
- IMAP_CAP_IMAP4REV1, ///< Server supports IMAP4rev1
- IMAP_CAP_STATUS, ///< Server supports STATUS command
- IMAP_CAP_ACL, ///< RFC2086: IMAP4 ACL extension
- IMAP_CAP_NAMESPACE, ///< RFC2342: IMAP4 Namespace
- IMAP_CAP_ACRAM_MD5, ///< RFC2195: CRAM-MD5 authentication
- IMAP_CAP_AGSSAPI, ///< RFC1731: GSSAPI authentication
- IMAP_CAP_AUTH_ANON, ///< AUTH=ANONYMOUS
- IMAP_CAP_AUTH_OAUTHBEARER, ///< RFC7628: AUTH=OAUTHBEARER
- IMAP_CAP_STARTTLS, ///< RFC2595: STARTTLS
- IMAP_CAP_LOGINDISABLED, ///< RFC2595: LOGINDISABLED
- IMAP_CAP_IDLE, ///< RFC2177: IDLE
- IMAP_CAP_SASL_IR, ///< SASL initial response draft
- IMAP_CAP_ENABLE, ///< RFC5161
- IMAP_CAP_CONDSTORE, ///< RFC7162
- IMAP_CAP_QRESYNC, ///< RFC7162
- IMAP_CAP_X_GM_EXT1, ///< https://developers.google.com/gmail/imap/imap-extensions
- IMAP_CAP_X_GM_ALT1 = IMAP_CAP_X_GM_EXT1, ///< Alternative capability string
- IMAP_CAP_MAX,
-};
+#define IMAP_CAP_IMAP4 (1 << 0) ///< Server supports IMAP4
+#define IMAP_CAP_IMAP4REV1 (1 << 1) ///< Server supports IMAP4rev1
+#define IMAP_CAP_STATUS (1 << 2) ///< Server supports STATUS command
+#define IMAP_CAP_ACL (1 << 3) ///< RFC2086: IMAP4 ACL extension
+#define IMAP_CAP_NAMESPACE (1 << 4) ///< RFC2342: IMAP4 Namespace
+#define IMAP_CAP_ACRAM_MD5 (1 << 5) ///< RFC2195: CRAM-MD5 authentication
+#define IMAP_CAP_AGSSAPI (1 << 6) ///< RFC1731: GSSAPI authentication
+#define IMAP_CAP_AUTH_ANON (1 << 7) ///< AUTH=ANONYMOUS
+#define IMAP_CAP_AUTH_OAUTHBEARER (1 << 8) ///< RFC7628: AUTH=OAUTHBEARER
+#define IMAP_CAP_STARTTLS (1 << 9) ///< RFC2595: STARTTLS
+#define IMAP_CAP_LOGINDISABLED (1 << 10) ///< RFC2595: LOGINDISABLED
+#define IMAP_CAP_IDLE (1 << 11) ///< RFC2177: IDLE
+#define IMAP_CAP_SASL_IR (1 << 12) ///< SASL initial response draft
+#define IMAP_CAP_ENABLE (1 << 13) ///< RFC5161
+#define IMAP_CAP_CONDSTORE (1 << 14) ///< RFC7162
+#define IMAP_CAP_QRESYNC (1 << 15) ///< RFC7162
+#define IMAP_CAP_X_GM_EXT1 (1 << 16) ///< https://developers.google.com/gmail/imap/imap-extensions
+
+#define IMAP_CAP_ALL ((1 << 17) - 1)
/**
* struct ImapList - Items in an IMAP browser
* tracking all possible capabilities. bah. (1) I don't like because
* it's just no fun to get the same information twice */
char *capstr;
- unsigned char capabilities[(IMAP_CAP_MAX + 7) / 8];
+ unsigned int capabilities;
unsigned char seqid; /* tag sequence prefix */
unsigned int seqno; ///< tag sequence number, e.g. '{seqid}0001'
time_t lastread; /**< last time we read a command for the server */
if (!adata || adata->mailbox != m)
return -1;
- if (mutt_bit_isset(adata->capabilities, IMAP_CAP_IMAP4REV1))
+ if (adata->capabilities & IMAP_CAP_IMAP4REV1)
{
safe_asprintf(&hdrreq, "BODY.PEEK[HEADER.FIELDS (%s%s%s)]", want_headers,
ImapHeaders ? " " : "", NONULL(ImapHeaders));
}
- else if (mutt_bit_isset(adata->capabilities, IMAP_CAP_IMAP4))
+ else if (adata->capabilities & IMAP_CAP_IMAP4)
{
safe_asprintf(&hdrreq, "RFC822.HEADER.LINES (%s%s%s)", want_headers,
ImapHeaders ? " " : "", NONULL(ImapHeaders));
if (mdata->modseq)
{
- if (mutt_bit_isset(adata->capabilities, IMAP_CAP_CONDSTORE) && ImapCondStore)
+ if ((adata->capabilities & IMAP_CAP_CONDSTORE) && ImapCondStore)
has_condstore = true;
- /* If mutt_bit_isset(QRESYNC) and option(OPTIMAPQRESYNC) then Mutt
- * sends ENABLE QRESYNC. If we receive an ENABLED response back, then
- * adata->qresync is set.
+ /* If IMAP_CAP_QRESYNC and ImapQResync then Mutt sends ENABLE QRESYNC.
+ * If we receive an ENABLED response back, then adata->qresync is set.
*/
if (adata->qresync)
has_qresync = true;
e->active = false;
snprintf(buf, sizeof(buf), "UID FETCH %u %s", imap_edata_get(e)->uid,
- (mutt_bit_isset(adata->capabilities, IMAP_CAP_IMAP4REV1) ?
+ ((adata->capabilities & IMAP_CAP_IMAP4REV1) ?
(ImapPeek ? "BODY.PEEK[]" : "BODY[]") :
"RFC822"));