<<< Date Index >>>     <<< Thread Index >>>

join-threads & RO folder; IMAP ACL checks



Please find attached a patch for curs_main.c which does two things:

 (1) OP_MAIN_LINK_THREADS needs to check for IMAP_ACL_DELETE permission,
     since the thread linking involves deleting the old email

 (2) makes CHECK_IMAP_ACL() a no-op if USE_IMAP is not defined; then
     cleans up a bunch of the #ifdef litter.

I realise that point 2 might be contentious, but put it in one patch
since manually patching for point 1 is so trivial that there's no real
harm done if that's rejected.

Is it generally preferred that every reference to IMAP functionality
always be explicitly wrapped in '#ifdef's?  Personally, a name like
CHECK_IMAP_ACL() seems clear enough and a text-editor search for "IMAP"
will find it just as easily as USE_IMAP.  By leaving the #ifdef in just
one place and providing an '#else', the rest of the code becomes
cleaner, IMO.

Regards,
-Phil
diff -ur mutt/curs_main.c mutt-jointhread-ro/curs_main.c
--- mutt/curs_main.c    2006-04-04 15:38:25.000000000 +0200
+++ mutt-jointhread-ro/curs_main.c      2006-04-04 15:49:45.000000000 +0200
@@ -99,6 +99,8 @@
                        mutt_error ("Operation not permitted by the IMAP ACL 
for this mailbox"); \
                        break; \
                }
+#else
+#define CHECK_IMAP_ACL(aclbit) /**/
 #endif
 
 #define CHECK_ATTACH if(option(OPTATTACHMSG)) \
@@ -804,10 +806,7 @@
        CHECK_MSGCOUNT;
         CHECK_VISIBLE;
        CHECK_READONLY;
-
-#ifdef USE_IMAP
-CHECK_IMAP_ACL(IMAP_ACL_DELETE);
-#endif
+       CHECK_IMAP_ACL(IMAP_ACL_DELETE);
 
        CHECK_ATTACH;
        mutt_pattern_func (M_DELETE, _("Delete messages matching: "));
@@ -974,10 +973,7 @@
        CHECK_MSGCOUNT;
         CHECK_VISIBLE;
        CHECK_READONLY;
-
-#ifdef USE_IMAP
-CHECK_IMAP_ACL(IMAP_ACL_DELETE);
-#endif
+       CHECK_IMAP_ACL(IMAP_ACL_DELETE);
 
        if (mutt_pattern_func (M_UNDELETE, _("Undelete messages matching: ")) 
== 0)
          menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
@@ -1235,6 +1231,7 @@
        CHECK_MSGCOUNT;
         CHECK_VISIBLE;
        CHECK_READONLY;
+       CHECK_IMAP_ACL(IMAP_ACL_DELETE);
 
         if ((Sort & SORT_MASK) != SORT_THREADS)
          mutt_error _("Threading is not enabled.");
@@ -1502,6 +1499,7 @@
        CHECK_MSGCOUNT;
         CHECK_VISIBLE;
        CHECK_READONLY;
+       CHECK_IMAP_ACL(IMAP_ACL_WRITE);
 
 #ifdef USE_POP
        if (Context->magic == M_POP)
@@ -1512,10 +1510,6 @@
        }
 #endif
 
-#ifdef USE_IMAP
-CHECK_IMAP_ACL(IMAP_ACL_WRITE);
-#endif
-
         if (tag)
         {
          for (j = 0; j < Context->vcount; j++)
@@ -1551,10 +1545,7 @@
        CHECK_MSGCOUNT;
         CHECK_VISIBLE;
        CHECK_READONLY;
-
-#ifdef USE_IMAP
-CHECK_IMAP_ACL(IMAP_ACL_SEEN);
-#endif
+       CHECK_IMAP_ACL(IMAP_ACL_SEEN);
 
        if (tag)
        {
@@ -1668,10 +1659,7 @@
        CHECK_MSGCOUNT;
         CHECK_VISIBLE;
        CHECK_READONLY;
-       
-/* #ifdef USE_IMAP
-CHECK_IMAP_ACL(IMAP_ACL_WRITE);
-#endif */
+       /* CHECK_IMAP_ACL(IMAP_ACL_WRITE); */
 
        if (mutt_change_flag (tag ? NULL : CURHDR, (op == OP_MAIN_SET_FLAG)) == 
0)
        {
@@ -1811,10 +1799,7 @@
        CHECK_MSGCOUNT;
         CHECK_VISIBLE;
        CHECK_READONLY;
-       
-#ifdef USE_IMAP
-CHECK_IMAP_ACL(IMAP_ACL_DELETE);
-#endif
+       CHECK_IMAP_ACL(IMAP_ACL_DELETE);
 
        if (tag)
        {
@@ -1855,10 +1840,7 @@
        CHECK_MSGCOUNT;
         CHECK_VISIBLE;
        CHECK_READONLY;
-
-#ifdef USE_IMAP
-CHECK_IMAP_ACL(IMAP_ACL_DELETE);
-#endif
+       CHECK_IMAP_ACL(IMAP_ACL_DELETE);
 
        rc = mutt_thread_set_flag (CURHDR, M_DELETE, 1,
                                   op == OP_DELETE_THREAD ? 0 : 1);
@@ -1899,6 +1881,7 @@
         CHECK_VISIBLE;
        CHECK_READONLY;
        CHECK_ATTACH;
+       CHECK_IMAP_ACL(IMAP_ACL_INSERT);
 
 #ifdef USE_POP
        if (Context->magic == M_POP)
@@ -1909,10 +1892,6 @@
        }
 #endif
 
-#ifdef USE_IMAP
-CHECK_IMAP_ACL(IMAP_ACL_INSERT);
-#endif
-
        if (option (OPTPGPAUTODEC) && (tag || !(CURHDR->security & 
PGP_TRADITIONAL_CHECKED))) 
          mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
         mutt_edit_message (Context, tag ? NULL : CURHDR);
@@ -2042,10 +2021,7 @@
        CHECK_MSGCOUNT;
        CHECK_VISIBLE;
        CHECK_READONLY;
-
-#ifdef USE_IMAP
-CHECK_IMAP_ACL(IMAP_ACL_SEEN);
-#endif
+       CHECK_IMAP_ACL(IMAP_ACL_SEEN);
 
        rc = mutt_thread_set_flag (CURHDR, M_READ, 1,
                                   op == OP_MAIN_READ_THREAD ? 0 : 1);
@@ -2132,10 +2108,7 @@
        CHECK_MSGCOUNT;
         CHECK_VISIBLE;
        CHECK_READONLY;
-
-#ifdef USE_IMAP
-CHECK_IMAP_ACL(IMAP_ACL_DELETE);
-#endif
+       CHECK_IMAP_ACL(IMAP_ACL_DELETE);
        
        if (tag)
        {
@@ -2162,10 +2135,7 @@
        CHECK_MSGCOUNT;
         CHECK_VISIBLE;
        CHECK_READONLY;
-
-#ifdef USE_IMAP
-CHECK_IMAP_ACL(IMAP_ACL_DELETE);
-#endif
+       CHECK_IMAP_ACL(IMAP_ACL_DELETE);
 
        rc = mutt_thread_set_flag (CURHDR, M_DELETE, 0,
                                   op == OP_UNDELETE_THREAD ? 0 : 1);