(imap_messages_count): Use SELECT or EXAMINE
depending on the mailbox status. (imap_expunge): Return EACCES if the mailbox is read-only
Showing
1 changed file
with
9 additions
and
2 deletions
... | @@ -119,6 +119,8 @@ static int flags_to_string __P ((char **, int)); | ... | @@ -119,6 +119,8 @@ static int flags_to_string __P ((char **, int)); |
119 | static int delete_to_string __P ((m_imap_t, char **)); | 119 | static int delete_to_string __P ((m_imap_t, char **)); |
120 | static int is_same_folder __P ((mailbox_t, message_t)); | 120 | static int is_same_folder __P ((mailbox_t, message_t)); |
121 | 121 | ||
122 | #define MBX_WRITABLE(mbx) ((mbx)->flags & (MU_STREAM_WRITE|MU_STREAM_RDWR|MU_STREAM_CREAT)) | ||
123 | |||
122 | /* Initialize the concrete object mailbox_t by overloading the function of the | 124 | /* Initialize the concrete object mailbox_t by overloading the function of the |
123 | structure. */ | 125 | structure. */ |
124 | int | 126 | int |
... | @@ -672,8 +674,10 @@ imap_messages_count (mailbox_t mailbox, size_t *pnum) | ... | @@ -672,8 +674,10 @@ imap_messages_count (mailbox_t mailbox, size_t *pnum) |
672 | switch (f_imap->state) | 674 | switch (f_imap->state) |
673 | { | 675 | { |
674 | case IMAP_NO_STATE: | 676 | case IMAP_NO_STATE: |
675 | status = imap_writeline (f_imap, "g%d SELECT %s\r\n", | 677 | status = imap_writeline (f_imap, "g%d %s %s\r\n", |
676 | f_imap->seq++, m_imap->name); | 678 | f_imap->seq++, |
679 | MBX_WRITABLE(mailbox) ? "SELECT" : "EXAMINE", | ||
680 | m_imap->name); | ||
677 | CHECK_ERROR (f_imap, status); | 681 | CHECK_ERROR (f_imap, status); |
678 | MAILBOX_DEBUG0 (mailbox, MU_DEBUG_PROT, f_imap->buffer); | 682 | MAILBOX_DEBUG0 (mailbox, MU_DEBUG_PROT, f_imap->buffer); |
679 | f_imap->state = IMAP_SELECT; | 683 | f_imap->state = IMAP_SELECT; |
... | @@ -845,6 +849,9 @@ imap_expunge (mailbox_t mailbox) | ... | @@ -845,6 +849,9 @@ imap_expunge (mailbox_t mailbox) |
845 | m_imap_t m_imap = mailbox->data; | 849 | m_imap_t m_imap = mailbox->data; |
846 | f_imap_t f_imap = m_imap->f_imap; | 850 | f_imap_t f_imap = m_imap->f_imap; |
847 | 851 | ||
852 | if (!MBX_WRITABLE(mailbox)) | ||
853 | return EACCES; | ||
854 | |||
848 | /* Select first. */ | 855 | /* Select first. */ |
849 | status = imap_messages_count (mailbox, NULL); | 856 | status = imap_messages_count (mailbox, NULL); |
850 | if (status != 0) | 857 | if (status != 0) | ... | ... |
-
Please register or sign in to post a comment