#include <sys/types.h>
#include <time.h>
-/**
- * enum AclRights - ACL Rights
- *
- * These permissions come from the 'MYRIGHTS' command from RFC4314.
- * The quoted letter is the code returned by the server.
- *
- * These show permission to...
- */
-enum AclRights
-{
- MUTT_ACL_ADMIN = 0, ///< 'a' administer the account (get/set permissions)
- MUTT_ACL_CREATE, ///< 'k' create a mailbox
- MUTT_ACL_DELETE, ///< 't' delete a message
- MUTT_ACL_DELMX, ///< 'x' delete a mailbox
- MUTT_ACL_EXPUNGE, ///< 'e' expunge messages
- MUTT_ACL_INSERT, ///< 'i' add/copy into the mailbox (used when editing a message)
- MUTT_ACL_LOOKUP, ///< 'l' lookup mailbox (visible to 'list')
- MUTT_ACL_POST, ///< 'p' post (submit messages to the server)
- MUTT_ACL_READ, ///< 'r' read the mailbox
- MUTT_ACL_SEEN, ///< 's' change the 'seen' status of a message
- MUTT_ACL_WRITE, ///< 'w' write to a message (for flagging, or linking threads)
-
- RIGHTSMAX
-};
-
/**
* struct Context - The "current" mailbox
*/
struct Menu *menu; /**< needed for pattern compilation */
- unsigned char rights[(RIGHTSMAX + 7) / 8]; /**< ACL bits */
-
bool dontwrite : 1; /**< don't write the mailbox on close */
bool append : 1; /**< mailbox is opened in append mode */
bool collapsed : 1; /**< are all threads collapsed? */
}
#define CHECK_ACL(aclbit, action) \
- if (!mutt_bit_isset(Context->rights, aclbit)) \
+ if (!mutt_bit_isset(Context->mailbox->rights, aclbit)) \
{ \
mutt_flushinp(); \
/* L10N: %s is one of the CHECK_ACL entries below. */ \
}
else if (op == OP_EDIT_OR_VIEW_RAW_MESSAGE)
edit = !Context->mailbox->readonly &&
- mutt_bit_isset(Context->rights, MUTT_ACL_INSERT);
+ mutt_bit_isset(Context->mailbox->rights, MUTT_ACL_INSERT);
else
edit = false;
{
case MUTT_DELETE:
- if (!mutt_bit_isset(ctx->rights, MUTT_ACL_DELETE))
+ if (!mutt_bit_isset(ctx->mailbox->rights, MUTT_ACL_DELETE))
return;
if (bf)
case MUTT_PURGE:
- if (!mutt_bit_isset(ctx->rights, MUTT_ACL_DELETE))
+ if (!mutt_bit_isset(ctx->mailbox->rights, MUTT_ACL_DELETE))
return;
if (bf)
case MUTT_NEW:
- if (!mutt_bit_isset(ctx->rights, MUTT_ACL_SEEN))
+ if (!mutt_bit_isset(ctx->mailbox->rights, MUTT_ACL_SEEN))
return;
if (bf)
case MUTT_OLD:
- if (!mutt_bit_isset(ctx->rights, MUTT_ACL_SEEN))
+ if (!mutt_bit_isset(ctx->mailbox->rights, MUTT_ACL_SEEN))
return;
if (bf)
case MUTT_READ:
- if (!mutt_bit_isset(ctx->rights, MUTT_ACL_SEEN))
+ if (!mutt_bit_isset(ctx->mailbox->rights, MUTT_ACL_SEEN))
return;
if (bf)
case MUTT_REPLIED:
- if (!mutt_bit_isset(ctx->rights, MUTT_ACL_WRITE))
+ if (!mutt_bit_isset(ctx->mailbox->rights, MUTT_ACL_WRITE))
return;
if (bf)
case MUTT_FLAG:
- if (!mutt_bit_isset(ctx->rights, MUTT_ACL_WRITE))
+ if (!mutt_bit_isset(ctx->mailbox->rights, MUTT_ACL_WRITE))
return;
if (bf)
s = imap_next_word((char *) s);
/* zero out current rights set */
- memset(idata->ctx->rights, 0, sizeof(idata->ctx->rights));
+ memset(idata->ctx->mailbox->rights, 0, sizeof(idata->ctx->mailbox->rights));
while (*s && !isspace((unsigned char) *s))
{
switch (*s)
{
case 'a':
- mutt_bit_set(idata->ctx->rights, MUTT_ACL_ADMIN);
+ mutt_bit_set(idata->ctx->mailbox->rights, MUTT_ACL_ADMIN);
break;
case 'e':
- mutt_bit_set(idata->ctx->rights, MUTT_ACL_EXPUNGE);
+ mutt_bit_set(idata->ctx->mailbox->rights, MUTT_ACL_EXPUNGE);
break;
case 'i':
- mutt_bit_set(idata->ctx->rights, MUTT_ACL_INSERT);
+ mutt_bit_set(idata->ctx->mailbox->rights, MUTT_ACL_INSERT);
break;
case 'k':
- mutt_bit_set(idata->ctx->rights, MUTT_ACL_CREATE);
+ mutt_bit_set(idata->ctx->mailbox->rights, MUTT_ACL_CREATE);
break;
case 'l':
- mutt_bit_set(idata->ctx->rights, MUTT_ACL_LOOKUP);
+ mutt_bit_set(idata->ctx->mailbox->rights, MUTT_ACL_LOOKUP);
break;
case 'p':
- mutt_bit_set(idata->ctx->rights, MUTT_ACL_POST);
+ mutt_bit_set(idata->ctx->mailbox->rights, MUTT_ACL_POST);
break;
case 'r':
- mutt_bit_set(idata->ctx->rights, MUTT_ACL_READ);
+ mutt_bit_set(idata->ctx->mailbox->rights, MUTT_ACL_READ);
break;
case 's':
- mutt_bit_set(idata->ctx->rights, MUTT_ACL_SEEN);
+ mutt_bit_set(idata->ctx->mailbox->rights, MUTT_ACL_SEEN);
break;
case 't':
- mutt_bit_set(idata->ctx->rights, MUTT_ACL_DELETE);
+ mutt_bit_set(idata->ctx->mailbox->rights, MUTT_ACL_DELETE);
break;
case 'w':
- mutt_bit_set(idata->ctx->rights, MUTT_ACL_WRITE);
+ mutt_bit_set(idata->ctx->mailbox->rights, MUTT_ACL_WRITE);
break;
case 'x':
- mutt_bit_set(idata->ctx->rights, MUTT_ACL_DELMX);
+ mutt_bit_set(idata->ctx->mailbox->rights, MUTT_ACL_DELMX);
break;
/* obsolete rights */
case 'c':
- mutt_bit_set(idata->ctx->rights, MUTT_ACL_CREATE);
- mutt_bit_set(idata->ctx->rights, MUTT_ACL_DELMX);
+ mutt_bit_set(idata->ctx->mailbox->rights, MUTT_ACL_CREATE);
+ mutt_bit_set(idata->ctx->mailbox->rights, MUTT_ACL_DELMX);
break;
case 'd':
- mutt_bit_set(idata->ctx->rights, MUTT_ACL_DELETE);
- mutt_bit_set(idata->ctx->rights, MUTT_ACL_EXPUNGE);
+ mutt_bit_set(idata->ctx->mailbox->rights, MUTT_ACL_DELETE);
+ mutt_bit_set(idata->ctx->mailbox->rights, MUTT_ACL_EXPUNGE);
break;
default:
mutt_debug(1, "Unknown right: %c\n", *s);
static void set_flag(struct ImapData *idata, int aclbit, int flag,
const char *str, char *flags, size_t flsize)
{
- if (mutt_bit_isset(idata->ctx->rights, aclbit))
+ if (mutt_bit_isset(idata->ctx->mailbox->rights, aclbit))
if (flag && imap_has_flag(&idata->flags, str))
mutt_str_strcat(flags, flsize, str);
}
if (!idata->ctx)
return -1;
- if (!mutt_bit_isset(idata->ctx->rights, right))
+ if (!mutt_bit_isset(idata->ctx->mailbox->rights, right))
return 0;
if (right == MUTT_ACL_WRITE && !imap_has_flag(&idata->flags, name))
set_flag(idata, MUTT_ACL_DELETE, HEADER_DATA(hdr)->deleted, "\\Deleted ",
flags, sizeof(flags));
- if (mutt_bit_isset(idata->ctx->rights, MUTT_ACL_WRITE))
+ if (mutt_bit_isset(idata->ctx->mailbox->rights, MUTT_ACL_WRITE))
{
/* restore system flags */
if (HEADER_DATA(hdr)->flags_system)
flags, sizeof(flags));
/* erase custom flags */
- if (mutt_bit_isset(idata->ctx->rights, MUTT_ACL_WRITE) && HEADER_DATA(hdr)->flags_remote)
+ if (mutt_bit_isset(idata->ctx->mailbox->rights, MUTT_ACL_WRITE) &&
+ HEADER_DATA(hdr)->flags_remote)
mutt_str_strcat(flags, sizeof(flags), HEADER_DATA(hdr)->flags_remote);
mutt_str_remove_trailing_ws(flags);
/* clear mailbox status */
idata->status = false;
- memset(idata->ctx->rights, 0, sizeof(idata->ctx->rights));
+ memset(idata->ctx->mailbox->rights, 0, sizeof(idata->ctx->mailbox->rights));
idata->new_mail_count = 0;
idata->max_msn = 0;
/* assume we have all rights if ACL is unavailable */
else
{
- mutt_bit_set(idata->ctx->rights, MUTT_ACL_LOOKUP);
- mutt_bit_set(idata->ctx->rights, MUTT_ACL_READ);
- mutt_bit_set(idata->ctx->rights, MUTT_ACL_SEEN);
- mutt_bit_set(idata->ctx->rights, MUTT_ACL_WRITE);
- mutt_bit_set(idata->ctx->rights, MUTT_ACL_INSERT);
- mutt_bit_set(idata->ctx->rights, MUTT_ACL_POST);
- mutt_bit_set(idata->ctx->rights, MUTT_ACL_CREATE);
- mutt_bit_set(idata->ctx->rights, MUTT_ACL_DELETE);
+ mutt_bit_set(idata->ctx->mailbox->rights, MUTT_ACL_LOOKUP);
+ mutt_bit_set(idata->ctx->mailbox->rights, MUTT_ACL_READ);
+ mutt_bit_set(idata->ctx->mailbox->rights, MUTT_ACL_SEEN);
+ mutt_bit_set(idata->ctx->mailbox->rights, MUTT_ACL_WRITE);
+ mutt_bit_set(idata->ctx->mailbox->rights, MUTT_ACL_INSERT);
+ mutt_bit_set(idata->ctx->mailbox->rights, MUTT_ACL_POST);
+ mutt_bit_set(idata->ctx->mailbox->rights, MUTT_ACL_CREATE);
+ mutt_bit_set(idata->ctx->mailbox->rights, MUTT_ACL_DELETE);
}
/* pipeline the postponed count if possible */
pmx.mbox = NULL;
}
}
- if (!(mutt_bit_isset(idata->ctx->rights, MUTT_ACL_DELETE) ||
- mutt_bit_isset(idata->ctx->rights, MUTT_ACL_SEEN) ||
- mutt_bit_isset(idata->ctx->rights, MUTT_ACL_WRITE) ||
- mutt_bit_isset(idata->ctx->rights, MUTT_ACL_INSERT)))
+ if (!(mutt_bit_isset(idata->ctx->mailbox->rights, MUTT_ACL_DELETE) ||
+ mutt_bit_isset(idata->ctx->mailbox->rights, MUTT_ACL_SEEN) ||
+ mutt_bit_isset(idata->ctx->mailbox->rights, MUTT_ACL_WRITE) ||
+ mutt_bit_isset(idata->ctx->mailbox->rights, MUTT_ACL_INSERT)))
{
ctx->mailbox->readonly = true;
}
return rc;
/* if we are expunging anyway, we can do deleted messages very quickly... */
- if (expunge && mutt_bit_isset(ctx->rights, MUTT_ACL_DELETE))
+ if (expunge && mutt_bit_isset(ctx->mailbox->rights, MUTT_ACL_DELETE))
{
rc = imap_exec_msgset(idata, "UID STORE", "+FLAGS.SILENT (\\Deleted)",
MUTT_DELETED, true, false);
ctx->mailbox->changed = false;
/* We must send an EXPUNGE command if we're not closing. */
- if (expunge && !(ctx->mailbox->closing) && mutt_bit_isset(ctx->rights, MUTT_ACL_DELETE))
+ if (expunge && !(ctx->mailbox->closing) && mutt_bit_isset(ctx->mailbox->rights, MUTT_ACL_DELETE))
{
mutt_message(_("Expunging messages from server..."));
/* Set expunge bit so we don't get spurious reopened messages */
if (*buf == '\0')
buf = NULL;
- if (!mutt_bit_isset(idata->ctx->rights, MUTT_ACL_WRITE))
+ if (!mutt_bit_isset(idata->ctx->mailbox->rights, MUTT_ACL_WRITE))
return 0;
snprintf(uid, sizeof(uid), "%u", HEADER_DATA(hdr)->uid);
#define MB_NORMAL 0
#define MB_HIDDEN 1
+/**
+ * enum AclRights - ACL Rights
+ *
+ * These show permission to...
+ */
+enum AclRights
+{
+ MUTT_ACL_ADMIN = 0, ///< administer the account (get/set permissions)
+ MUTT_ACL_CREATE, ///< create a mailbox
+ MUTT_ACL_DELETE, ///< delete a message
+ MUTT_ACL_DELMX, ///< delete a mailbox
+ MUTT_ACL_EXPUNGE, ///< expunge messages
+ MUTT_ACL_INSERT, ///< add/copy into the mailbox (used when editing a message)
+ MUTT_ACL_LOOKUP, ///< lookup mailbox (visible to 'list')
+ MUTT_ACL_POST, ///< post (submit messages to the server)
+ MUTT_ACL_READ, ///< read the mailbox
+ MUTT_ACL_SEEN, ///< change the 'seen' status of a message
+ MUTT_ACL_WRITE, ///< write to a message (for flagging, or linking threads)
+
+ RIGHTSMAX
+};
+
/**
* struct Mailbox - A mailbox
*/
bool quiet : 1; /**< inhibit status messages? */
bool closing : 1; /**< mailbox is being closed */
+ unsigned char rights[(RIGHTSMAX + 7) / 8]; /**< ACL bits */
+
int flags; /**< e.g. #MB_NORMAL */
};
ctx->collapsed = false;
for (rc = 0; rc < RIGHTSMAX; rc++)
- mutt_bit_set(ctx->rights, rc);
+ mutt_bit_set(ctx->mailbox->rights, rc);
if (flags & MUTT_QUIET)
ctx->mailbox->quiet = true;
return -1;
}
- mutt_bit_unset(ctx->rights, MUTT_ACL_INSERT);
+ mutt_bit_unset(ctx->mailbox->rights, MUTT_ACL_INSERT);
if (!nntp_data->newsrc_ent && !nntp_data->subscribed && !SaveUnsubscribed)
ctx->mailbox->readonly = true;
#endif
if (!hc)
{
- mutt_bit_unset(ctx->rights, MUTT_ACL_WRITE);
- mutt_bit_unset(ctx->rights, MUTT_ACL_DELETE);
+ mutt_bit_unset(ctx->mailbox->rights, MUTT_ACL_WRITE);
+ mutt_bit_unset(ctx->mailbox->rights, MUTT_ACL_DELETE);
}
nntp_newsrc_close(nserv);
rc = nntp_fetch_headers(ctx, hc, first, nntp_data->last_message, 0);
}
#define CHECK_ACL(aclbit, action) \
- if (!Context || !mutt_bit_isset(Context->rights, aclbit)) \
+ if (!Context || !mutt_bit_isset(Context->mailbox->rights, aclbit)) \
{ \
mutt_flushinp(); \
/* L10N: %s is one of the CHECK_ACL entries below. */ \
pop_data->bcache = mutt_bcache_open(&acct, NULL);
/* init (hard-coded) ACL rights */
- memset(ctx->rights, 0, sizeof(ctx->rights));
- mutt_bit_set(ctx->rights, MUTT_ACL_SEEN);
- mutt_bit_set(ctx->rights, MUTT_ACL_DELETE);
+ memset(ctx->mailbox->rights, 0, sizeof(ctx->mailbox->rights));
+ mutt_bit_set(ctx->mailbox->rights, MUTT_ACL_SEEN);
+ mutt_bit_set(ctx->mailbox->rights, MUTT_ACL_DELETE);
#ifdef USE_HCACHE
/* flags are managed using header cache, so it only makes sense to
* enable them in that case */
- mutt_bit_set(ctx->rights, MUTT_ACL_WRITE);
+ mutt_bit_set(ctx->mailbox->rights, MUTT_ACL_WRITE);
#endif
while (true)