break; \
}
-#ifdef USE_IMAP
-/* the error message returned here could be better. */
-#define CHECK_IMAP_ACL(aclbit) if (Context->magic == M_IMAP) \
- if (mutt_bit_isset (((IMAP_DATA *)Context->data)->capabilities, ACL) \
- && !mutt_bit_isset(((IMAP_DATA *)Context->data)->rights,aclbit)){ \
+#define CHECK_ACL(aclbit,action) \
+ if (!mutt_bit_isset(Context->rights,aclbit)) { \
mutt_flushinp(); \
- mutt_error ("Operation not permitted by the IMAP ACL for this mailbox"); \
+ mutt_error (_("Cannot %s: Operation not permitted by ACL"), action); \
break; \
}
-#else
-#define CHECK_IMAP_ACL(aclbit) /**/
-#endif
#define CHECK_ATTACH if(option(OPTATTACHMSG)) \
{\
CHECK_MSGCOUNT;
CHECK_VISIBLE;
CHECK_READONLY;
- CHECK_IMAP_ACL(IMAP_ACL_DELETE);
+ CHECK_ACL(M_ACL_DELETE, _("delete message(s)"));
CHECK_ATTACH;
mutt_pattern_func (M_DELETE, _("Delete messages matching: "));
CHECK_MSGCOUNT;
CHECK_VISIBLE;
CHECK_READONLY;
- CHECK_IMAP_ACL(IMAP_ACL_DELETE);
+ CHECK_ACL(M_ACL_DELETE, _("undelete message(s)"));
if (mutt_pattern_func (M_UNDELETE, _("Undelete messages matching: ")) == 0)
menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
CHECK_MSGCOUNT;
CHECK_VISIBLE;
CHECK_READONLY;
- CHECK_IMAP_ACL(IMAP_ACL_DELETE);
+ CHECK_ACL(M_ACL_DELETE, _("link threads"));
if ((Sort & SORT_MASK) != SORT_THREADS)
mutt_error _("Threading is not enabled.");
CHECK_MSGCOUNT;
CHECK_VISIBLE;
CHECK_READONLY;
- CHECK_IMAP_ACL(IMAP_ACL_WRITE);
-
-#ifdef USE_POP
- if (Context->magic == M_POP)
- {
- mutt_flushinp ();
- mutt_error _("Can't change 'important' flag on POP server.");
- break;
- }
-#endif
+ CHECK_ACL(M_ACL_WRITE, _("flag message"));
if (tag)
{
CHECK_MSGCOUNT;
CHECK_VISIBLE;
CHECK_READONLY;
- CHECK_IMAP_ACL(IMAP_ACL_SEEN);
+ CHECK_ACL(M_ACL_SEEN, _("toggle new"));
if (tag)
{
CHECK_MSGCOUNT;
CHECK_VISIBLE;
CHECK_READONLY;
- /* CHECK_IMAP_ACL(IMAP_ACL_WRITE); */
+ /* CHECK_ACL(M_ACL_WRITE); */
if (mutt_change_flag (tag ? NULL : CURHDR, (op == OP_MAIN_SET_FLAG)) == 0)
{
CHECK_MSGCOUNT;
CHECK_VISIBLE;
CHECK_READONLY;
- CHECK_IMAP_ACL(IMAP_ACL_DELETE);
+ CHECK_ACL(M_ACL_DELETE, _("delete message"));
if (tag)
{
CHECK_MSGCOUNT;
CHECK_VISIBLE;
CHECK_READONLY;
- CHECK_IMAP_ACL(IMAP_ACL_DELETE);
+ CHECK_ACL(M_ACL_DELETE, _("delete message(s)"));
rc = mutt_thread_set_flag (CURHDR, M_DELETE, 1,
op == OP_DELETE_THREAD ? 0 : 1);
CHECK_VISIBLE;
CHECK_READONLY;
CHECK_ATTACH;
- CHECK_IMAP_ACL(IMAP_ACL_INSERT);
-
-#ifdef USE_POP
- if (Context->magic == M_POP)
- {
- mutt_flushinp ();
- mutt_error _("Can't edit message on POP server.");
- break;
- }
-#endif
+ CHECK_ACL(M_ACL_INSERT, _("edit message"));
if (option (OPTPGPAUTODEC) && (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED)))
mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
CHECK_MSGCOUNT;
CHECK_VISIBLE;
CHECK_READONLY;
- CHECK_IMAP_ACL(IMAP_ACL_SEEN);
+ CHECK_ACL(M_ACL_SEEN, _("mark message(s) as read"));
rc = mutt_thread_set_flag (CURHDR, M_READ, 1,
op == OP_MAIN_READ_THREAD ? 0 : 1);
CHECK_MSGCOUNT;
CHECK_VISIBLE;
CHECK_READONLY;
- CHECK_IMAP_ACL(IMAP_ACL_DELETE);
+ CHECK_ACL(M_ACL_DELETE, _("undelete message"));
if (tag)
{
CHECK_MSGCOUNT;
CHECK_VISIBLE;
CHECK_READONLY;
- CHECK_IMAP_ACL(IMAP_ACL_DELETE);
+ CHECK_ACL(M_ACL_DELETE, _("undelete message(s)"));
rc = mutt_thread_set_flag (CURHDR, M_DELETE, 0,
op == OP_UNDELETE_THREAD ? 0 : 1);
{
case M_DELETE:
-#ifdef USE_IMAP
- if (ctx && ctx->magic == M_IMAP)
- if (mutt_bit_isset (((IMAP_DATA *)ctx->data)->capabilities, ACL) \
- && !mutt_bit_isset(((IMAP_DATA *)ctx->data)->rights,IMAP_ACL_DELETE))
- return;
-#endif
+ if (!mutt_bit_isset(ctx->rights,M_ACL_DELETE))
+ return;
if (bf)
{
case M_NEW:
-#ifdef USE_IMAP
- if (ctx && ctx->magic == M_IMAP)
- if (mutt_bit_isset (((IMAP_DATA *)ctx->data)->capabilities, ACL) \
- && !mutt_bit_isset(((IMAP_DATA *)ctx->data)->rights,IMAP_ACL_SEEN))
- return;
-#endif
+ if (!mutt_bit_isset(ctx->rights,M_ACL_SEEN))
+ return;
if (bf)
{
case M_OLD:
-#ifdef USE_IMAP
- if (ctx && ctx->magic == M_IMAP)
- if (mutt_bit_isset (((IMAP_DATA *)ctx->data)->capabilities, ACL) \
- && !mutt_bit_isset(((IMAP_DATA *)ctx->data)->rights,IMAP_ACL_SEEN))
- return;
-#endif
+ if (!mutt_bit_isset(ctx->rights,M_ACL_SEEN))
+ return;
if (bf)
{
case M_READ:
-#ifdef USE_IMAP
- if (ctx && ctx->magic == M_IMAP)
- if (mutt_bit_isset (((IMAP_DATA *)ctx->data)->capabilities, ACL) \
- && !mutt_bit_isset(((IMAP_DATA *)ctx->data)->rights,IMAP_ACL_SEEN))
- return;
-#endif
+ if (!mutt_bit_isset(ctx->rights,M_ACL_SEEN))
+ return;
if (bf)
{
case M_REPLIED:
-#ifdef USE_IMAP
- if (ctx && ctx->magic == M_IMAP)
- if (mutt_bit_isset (((IMAP_DATA *)ctx->data)->capabilities, ACL) \
- && !mutt_bit_isset(((IMAP_DATA *)ctx->data)->rights,IMAP_ACL_WRITE))
- return;
-#endif
+ if (!mutt_bit_isset(ctx->rights,M_ACL_WRITE))
+ return;
if (bf)
{
case M_FLAG:
-#ifdef USE_IMAP
- if (ctx && ctx->magic == M_IMAP)
- if (mutt_bit_isset (((IMAP_DATA *)ctx->data)->capabilities, ACL) \
- && !mutt_bit_isset(((IMAP_DATA *)ctx->data)->rights,IMAP_ACL_WRITE))
- return;
-#endif
+ if (!mutt_bit_isset(ctx->rights,M_ACL_WRITE))
+ return;
if (bf)
{
s = imap_next_word ((char*)s);
/* zero out current rights set */
- memset (idata->rights, 0, sizeof (idata->rights));
+ memset (idata->ctx->rights, 0, sizeof (idata->ctx->rights));
while (*s && !isspace((unsigned char) *s))
{
switch (*s)
{
case 'l':
- mutt_bit_set (idata->rights, IMAP_ACL_LOOKUP);
+ mutt_bit_set (idata->ctx->rights, M_ACL_LOOKUP);
break;
case 'r':
- mutt_bit_set (idata->rights, IMAP_ACL_READ);
+ mutt_bit_set (idata->ctx->rights, M_ACL_READ);
break;
case 's':
- mutt_bit_set (idata->rights, IMAP_ACL_SEEN);
+ mutt_bit_set (idata->ctx->rights, M_ACL_SEEN);
break;
case 'w':
- mutt_bit_set (idata->rights, IMAP_ACL_WRITE);
+ mutt_bit_set (idata->ctx->rights, M_ACL_WRITE);
break;
case 'i':
- mutt_bit_set (idata->rights, IMAP_ACL_INSERT);
+ mutt_bit_set (idata->ctx->rights, M_ACL_INSERT);
break;
case 'p':
- mutt_bit_set (idata->rights, IMAP_ACL_POST);
+ mutt_bit_set (idata->ctx->rights, M_ACL_POST);
break;
case 'c':
- mutt_bit_set (idata->rights, IMAP_ACL_CREATE);
+ mutt_bit_set (idata->ctx->rights, M_ACL_CREATE);
break;
case 'd':
- mutt_bit_set (idata->rights, IMAP_ACL_DELETE);
+ mutt_bit_set (idata->ctx->rights, M_ACL_DELETE);
break;
case 'a':
- mutt_bit_set (idata->rights, IMAP_ACL_ADMIN);
+ mutt_bit_set (idata->ctx->rights, M_ACL_ADMIN);
break;
}
s++;
/* clear mailbox status */
idata->status = 0;
- memset (idata->rights, 0, (RIGHTSMAX+7)/8);
+ memset (idata->ctx->rights, 0, sizeof (idata->ctx->rights));
idata->newMailCount = 0;
mutt_message (_("Selecting %s..."), idata->mailbox);
/* assume we have all rights if ACL is unavailable */
else
{
- mutt_bit_set (idata->rights, IMAP_ACL_LOOKUP);
- mutt_bit_set (idata->rights, IMAP_ACL_READ);
- mutt_bit_set (idata->rights, IMAP_ACL_SEEN);
- mutt_bit_set (idata->rights, IMAP_ACL_WRITE);
- mutt_bit_set (idata->rights, IMAP_ACL_INSERT);
- mutt_bit_set (idata->rights, IMAP_ACL_POST);
- mutt_bit_set (idata->rights, IMAP_ACL_CREATE);
- mutt_bit_set (idata->rights, IMAP_ACL_DELETE);
+ mutt_bit_set (idata->ctx->rights, M_ACL_LOOKUP);
+ mutt_bit_set (idata->ctx->rights, M_ACL_READ);
+ mutt_bit_set (idata->ctx->rights, M_ACL_SEEN);
+ mutt_bit_set (idata->ctx->rights, M_ACL_WRITE);
+ mutt_bit_set (idata->ctx->rights, M_ACL_INSERT);
+ mutt_bit_set (idata->ctx->rights, M_ACL_POST);
+ mutt_bit_set (idata->ctx->rights, M_ACL_CREATE);
+ mutt_bit_set (idata->ctx->rights, M_ACL_DELETE);
}
/* pipeline the postponed count if possible */
pmx.mbox = NULL;
}
#endif
- if (!(mutt_bit_isset(idata->rights, IMAP_ACL_DELETE) ||
- mutt_bit_isset(idata->rights, IMAP_ACL_SEEN) ||
- mutt_bit_isset(idata->rights, IMAP_ACL_WRITE) ||
- mutt_bit_isset(idata->rights, IMAP_ACL_INSERT)))
+ if (!(mutt_bit_isset(idata->ctx->rights, M_ACL_DELETE) ||
+ mutt_bit_isset(idata->ctx->rights, M_ACL_SEEN) ||
+ mutt_bit_isset(idata->ctx->rights, M_ACL_WRITE) ||
+ mutt_bit_isset(idata->ctx->rights, M_ACL_INSERT)))
ctx->readonly = 1;
ctx->hdrmax = count;
static void imap_set_flag (IMAP_DATA* idata, int aclbit, int flag,
const char *str, char *flags, size_t flsize)
{
- if (mutt_bit_isset (idata->rights, aclbit))
+ if (mutt_bit_isset (idata->ctx->rights, aclbit))
if (flag && imap_has_flag (idata->flags, str))
safe_strcat (flags, flsize, str);
}
flags[0] = '\0';
- imap_set_flag (idata, IMAP_ACL_SEEN, hdr->read, "\\Seen ",
+ imap_set_flag (idata, M_ACL_SEEN, hdr->read, "\\Seen ",
flags, sizeof (flags));
- imap_set_flag (idata, IMAP_ACL_WRITE, hdr->old,
+ imap_set_flag (idata, M_ACL_WRITE, hdr->old,
"Old ", flags, sizeof (flags));
- imap_set_flag (idata, IMAP_ACL_WRITE, hdr->flagged,
+ imap_set_flag (idata, M_ACL_WRITE, hdr->flagged,
"\\Flagged ", flags, sizeof (flags));
- imap_set_flag (idata, IMAP_ACL_WRITE, hdr->replied,
+ imap_set_flag (idata, M_ACL_WRITE, hdr->replied,
"\\Answered ", flags, sizeof (flags));
- imap_set_flag (idata, IMAP_ACL_DELETE, hdr->deleted,
+ imap_set_flag (idata, M_ACL_DELETE, hdr->deleted,
"\\Deleted ", flags, sizeof (flags));
/* now make sure we don't lose custom tags */
- if (mutt_bit_isset (idata->rights, IMAP_ACL_WRITE))
+ if (mutt_bit_isset (idata->ctx->rights, M_ACL_WRITE))
imap_add_keywords (flags, hdr, idata->flags, sizeof (flags));
mutt_remove_trailing_ws (flags);
* explicitly revoke all system flags (if we have permission) */
if (!*flags)
{
- imap_set_flag (idata, IMAP_ACL_SEEN, 1, "\\Seen ", flags, sizeof (flags));
- imap_set_flag (idata, IMAP_ACL_WRITE, 1, "Old ", flags, sizeof (flags));
- imap_set_flag (idata, IMAP_ACL_WRITE, 1, "\\Flagged ", flags, sizeof (flags));
- imap_set_flag (idata, IMAP_ACL_WRITE, 1, "\\Answered ", flags, sizeof (flags));
- imap_set_flag (idata, IMAP_ACL_DELETE, 1, "\\Deleted ", flags, sizeof (flags));
+ imap_set_flag (idata, M_ACL_SEEN, 1, "\\Seen ", flags, sizeof (flags));
+ imap_set_flag (idata, M_ACL_WRITE, 1, "Old ", flags, sizeof (flags));
+ imap_set_flag (idata, M_ACL_WRITE, 1, "\\Flagged ", flags, sizeof (flags));
+ imap_set_flag (idata, M_ACL_WRITE, 1, "\\Answered ", flags, sizeof (flags));
+ imap_set_flag (idata, M_ACL_DELETE, 1, "\\Deleted ", flags, sizeof (flags));
mutt_remove_trailing_ws (flags);
{
int rc = 0;
- if (!mutt_bit_isset (idata->rights, right))
+ if (!mutt_bit_isset (idata->ctx->rights, right))
return 0;
- if (right == IMAP_ACL_WRITE && !imap_has_flag (idata->flags, name))
+ if (right == M_ACL_WRITE && !imap_has_flag (idata->flags, name))
return 0;
buf->dptr = buf->data;
memset (&cmd, 0, sizeof (cmd));
/* if we are expunging anyway, we can do deleted messages very quickly... */
- if (expunge && mutt_bit_isset (idata->rights, IMAP_ACL_DELETE))
+ if (expunge && mutt_bit_isset (idata->ctx->rights, M_ACL_DELETE))
{
mutt_buffer_addstr (&cmd, "UID STORE ");
deleted = imap_make_msg_set (idata, &cmd, M_DELETED, 1, 0);
mutt_get_sort_func (SORT_ORDER));
}
- rc += sync_helper (idata, &cmd, IMAP_ACL_DELETE, M_DELETED, "\\Deleted");
- rc += sync_helper (idata, &cmd, IMAP_ACL_WRITE, M_FLAG, "\\Flagged");
- rc += sync_helper (idata, &cmd, IMAP_ACL_WRITE, M_OLD, "Old");
- rc += sync_helper (idata, &cmd, IMAP_ACL_SEEN, M_READ, "\\Seen");
- rc += sync_helper (idata, &cmd, IMAP_ACL_WRITE, M_REPLIED, "\\Answered");
+ rc += sync_helper (idata, &cmd, M_ACL_DELETE, M_DELETED, "\\Deleted");
+ rc += sync_helper (idata, &cmd, M_ACL_WRITE, M_FLAG, "\\Flagged");
+ rc += sync_helper (idata, &cmd, M_ACL_WRITE, M_OLD, "Old");
+ rc += sync_helper (idata, &cmd, M_ACL_SEEN, M_READ, "\\Seen");
+ rc += sync_helper (idata, &cmd, M_ACL_WRITE, M_REPLIED, "\\Answered");
if (oldsort != Sort)
{
/* We must send an EXPUNGE command if we're not closing. */
if (expunge && !(ctx->closing) &&
- mutt_bit_isset(idata->rights, IMAP_ACL_DELETE))
+ mutt_bit_isset(idata->ctx->rights, M_ACL_DELETE))
{
mutt_message _("Expunging messages from server...");
/* Set expunge bit so we don't get spurious reopened messages */
IMAP_NS_SHARED
};
-/* ACL Rights */
-enum
-{
- IMAP_ACL_LOOKUP = 0,
- IMAP_ACL_READ,
- IMAP_ACL_SEEN,
- IMAP_ACL_WRITE,
- IMAP_ACL_INSERT,
- IMAP_ACL_POST,
- IMAP_ACL_CREATE,
- IMAP_ACL_DELETE,
- IMAP_ACL_ADMIN,
-
- RIGHTSMAX
-};
-
/* Capabilities we are interested in */
enum
{
char *mailbox;
unsigned short check_status;
unsigned char reopen;
- unsigned char rights[(RIGHTSMAX + 7)/8];
unsigned int newMailCount;
IMAP_CACHE cache[IMAP_CACHE_LEN];
unsigned int uid_validity;
} p;
} pattern_t;
+/* ACL Rights */
+enum
+{
+ M_ACL_LOOKUP = 0,
+ M_ACL_READ,
+ M_ACL_SEEN,
+ M_ACL_WRITE,
+ M_ACL_INSERT,
+ M_ACL_POST,
+ M_ACL_CREATE,
+ M_ACL_DELETE,
+ M_ACL_ADMIN,
+
+ RIGHTSMAX
+};
+
typedef struct
{
char *path;
short magic; /* mailbox type */
+ unsigned char rights[(RIGHTSMAX + 7)/8]; /* ACL bits */
+
unsigned int locked : 1; /* is the mailbox locked? */
unsigned int changed : 1; /* mailbox has been modified */
unsigned int readonly : 1; /* don't allow changes to the mailbox */
ctx->msgnotreadyet = -1;
ctx->collapsed = 0;
-
+
+ for (rc=0; rc < RIGHTSMAX; rc++)
+ mutt_bit_set(ctx->rights,rc);
+
if (flags & M_QUIET)
ctx->quiet = 1;
if (flags & M_READONLY)
break; \
}
-#ifdef USE_IMAP
-/* the error message returned here could be better. */
-#define CHECK_IMAP_ACL(aclbit) if (Context->magic == M_IMAP) \
- if (mutt_bit_isset (((IMAP_DATA *)Context->data)->capabilities, ACL) \
- && !mutt_bit_isset(((IMAP_DATA *)Context->data)->rights,aclbit)){ \
+#define CHECK_ACL(aclbit,action) \
+ if (!mutt_bit_isset(Context->rights,aclbit)) { \
mutt_flushinp(); \
- mutt_error ("Operation not permitted by the IMAP ACL for this mailbox"); \
+ mutt_error (_("Cannot %s: Operation not permitted by ACL"), action); \
break; \
}
-#endif
struct q_class_t
{
case OP_DELETE:
CHECK_MODE(IsHeader (extra));
CHECK_READONLY;
-
-#ifdef USE_IMAP
-CHECK_IMAP_ACL(IMAP_ACL_DELETE);
-#endif
+ CHECK_ACL(M_ACL_DELETE, _("delete message"));
mutt_set_flag (Context, extra->hdr, M_DELETE, 1);
if (option (OPTDELETEUNTAG))
case OP_DELETE_SUBTHREAD:
CHECK_MODE(IsHeader (extra));
CHECK_READONLY;
-
-#ifdef USE_IMAP
-CHECK_IMAP_ACL(IMAP_ACL_DELETE);
-#endif
+ CHECK_ACL(M_ACL_DELETE, _("delete message(s)"));
r = mutt_thread_set_flag (extra->hdr, M_DELETE, 1,
ch == OP_DELETE_THREAD ? 0 : 1);
case OP_FLAG_MESSAGE:
CHECK_MODE(IsHeader (extra));
CHECK_READONLY;
-
-#ifdef USE_POP
- if (Context->magic == M_POP)
- {
- mutt_flushinp ();
- mutt_error _("Can't change 'important' flag on POP server.");
- break;
- }
-#endif
-
-#ifdef USE_IMAP
-CHECK_IMAP_ACL(IMAP_ACL_WRITE);
-#endif
+ CHECK_ACL(M_ACL_WRITE, "flag message");
mutt_set_flag (Context, extra->hdr, M_FLAG, !extra->hdr->flagged);
redraw = REDRAW_STATUS | REDRAW_INDEX;
case OP_TOGGLE_NEW:
CHECK_MODE(IsHeader (extra));
CHECK_READONLY;
-
-#ifdef USE_IMAP
-CHECK_IMAP_ACL(IMAP_ACL_SEEN);
-#endif
+ CHECK_ACL(M_ACL_SEEN, _("toggle new"));
if (extra->hdr->read || extra->hdr->old)
mutt_set_flag (Context, extra->hdr, M_NEW, 1);
case OP_UNDELETE:
CHECK_MODE(IsHeader (extra));
CHECK_READONLY;
-
-#ifdef USE_IMAP
-CHECK_IMAP_ACL(IMAP_ACL_DELETE);
-#endif
+ CHECK_ACL(M_ACL_DELETE, _("undelete message"));
mutt_set_flag (Context, extra->hdr, M_DELETE, 0);
redraw = REDRAW_STATUS | REDRAW_INDEX;
case OP_UNDELETE_SUBTHREAD:
CHECK_MODE(IsHeader (extra));
CHECK_READONLY;
-
-#ifdef USE_IMAP
-CHECK_IMAP_ACL(IMAP_ACL_DELETE);
-#endif
+ CHECK_ACL(M_ACL_DELETE, _("undelete message(s)"));
r = mutt_thread_set_flag (extra->hdr, M_DELETE, 0,
ch == OP_UNDELETE_THREAD ? 0 : 1);
conn->data = pop_data;
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, M_ACL_SEEN);
+ mutt_bit_set (ctx->rights, M_ACL_DELETE);
+
FOREVER
{
if (pop_reconnect (ctx) < 0)