(imap_expunge): Use EXPUNGE instead
of closing and reopening the mailbox. This way the user is not prompted twice for his credentials. Besides, it appears to be faster, in spite of what the comment before the function said.
Showing
1 changed file
with
25 additions
and
11 deletions
... | @@ -75,7 +75,7 @@ static int imap_copy_message __P ((mailbox_t, message_t)); | ... | @@ -75,7 +75,7 @@ static int imap_copy_message __P ((mailbox_t, message_t)); |
75 | static int imap_submessage_size __P ((msg_imap_t, size_t *)); | 75 | static int imap_submessage_size __P ((msg_imap_t, size_t *)); |
76 | static int imap_message_size __P ((message_t, size_t *)); | 76 | static int imap_message_size __P ((message_t, size_t *)); |
77 | static int imap_message_lines __P ((message_t, size_t *)); | 77 | static int imap_message_lines __P ((message_t, size_t *)); |
78 | static int imap_message_fd __P ((stream_t, int *)); | 78 | static int imap_message_fd __P ((stream_t, int *, int *)); |
79 | static int imap_message_read __P ((stream_t , char *, size_t, off_t, size_t *)); | 79 | static int imap_message_read __P ((stream_t , char *, size_t, off_t, size_t *)); |
80 | static int imap_message_uid __P ((message_t, size_t *)); | 80 | static int imap_message_uid __P ((message_t, size_t *)); |
81 | 81 | ||
... | @@ -830,9 +830,6 @@ imap_is_updated (mailbox_t mailbox) | ... | @@ -830,9 +830,6 @@ imap_is_updated (mailbox_t mailbox) |
830 | } | 830 | } |
831 | 831 | ||
832 | 832 | ||
833 | /* It is only here that the Deleted flags are sent. Expunge is not | ||
834 | call rather the mailbox is close explicitely, letting the server | ||
835 | do the expunge without sending the notifications. It's faster. */ | ||
836 | static int | 833 | static int |
837 | imap_expunge (mailbox_t mailbox) | 834 | imap_expunge (mailbox_t mailbox) |
838 | { | 835 | { |
... | @@ -879,11 +876,11 @@ imap_expunge (mailbox_t mailbox) | ... | @@ -879,11 +876,11 @@ imap_expunge (mailbox_t mailbox) |
879 | MAILBOX_DEBUG0 (m_imap->mailbox, MU_DEBUG_PROT, f_imap->buffer); | 876 | MAILBOX_DEBUG0 (m_imap->mailbox, MU_DEBUG_PROT, f_imap->buffer); |
880 | f_imap->state = IMAP_NO_STATE; | 877 | f_imap->state = IMAP_NO_STATE; |
881 | 878 | ||
882 | /* We are not sending EXPUNGE, rather we close the mailbox | 879 | case IMAP_EXPUNGE: |
883 | which will purge. */ | 880 | case IMAP_EXPUNGE_ACK: |
884 | case IMAP_CLOSE: | 881 | status = imap_writeline (f_imap, "g%d EXPUNGE\r\n", f_imap->seq++); |
885 | case IMAP_CLOSE_ACK: | 882 | CHECK_ERROR (f_imap, status); |
886 | status = mailbox_imap_close (mailbox); | 883 | status = imap_send (f_imap); |
887 | CHECK_EAGAIN (f_imap, status); | 884 | CHECK_EAGAIN (f_imap, status); |
888 | 885 | ||
889 | /* Rescan after expunging but do not trigger the observers. */ | 886 | /* Rescan after expunging but do not trigger the observers. */ |
... | @@ -893,7 +890,7 @@ imap_expunge (mailbox_t mailbox) | ... | @@ -893,7 +890,7 @@ imap_expunge (mailbox_t mailbox) |
893 | CHECK_EAGAIN (f_imap, status); | 890 | CHECK_EAGAIN (f_imap, status); |
894 | 891 | ||
895 | default: | 892 | default: |
896 | /* mu_error ("imap_expunge: unknow state\n"); */ | 893 | /* mu_error ("imap_expunge: unknown state\n"); */ |
897 | break; | 894 | break; |
898 | } | 895 | } |
899 | 896 | ||
... | @@ -1331,11 +1328,16 @@ imap_message_uid (message_t msg, size_t *puid) | ... | @@ -1331,11 +1328,16 @@ imap_message_uid (message_t msg, size_t *puid) |
1331 | } | 1328 | } |
1332 | 1329 | ||
1333 | static int | 1330 | static int |
1334 | imap_message_fd (stream_t stream, int * pfd) | 1331 | imap_message_fd (stream_t stream, int *pfd, int *pfd2) |
1335 | { | 1332 | { |
1333 | if (pfd2) | ||
1334 | return ENOSYS; | ||
1335 | else | ||
1336 | { | ||
1336 | message_t msg = stream_get_owner (stream); | 1337 | message_t msg = stream_get_owner (stream); |
1337 | msg_imap_t msg_imap = message_get_owner (msg); | 1338 | msg_imap_t msg_imap = message_get_owner (msg); |
1338 | return imap_get_fd (msg_imap, pfd); | 1339 | return imap_get_fd (msg_imap, pfd); |
1340 | } | ||
1339 | } | 1341 | } |
1340 | 1342 | ||
1341 | /* Mime. */ | 1343 | /* Mime. */ |
... | @@ -2023,6 +2025,18 @@ imap_get_fd (msg_imap_t msg_imap, int *pfd) | ... | @@ -2023,6 +2025,18 @@ imap_get_fd (msg_imap_t msg_imap, int *pfd) |
2023 | return EINVAL; | 2025 | return EINVAL; |
2024 | } | 2026 | } |
2025 | 2027 | ||
2028 | static int | ||
2029 | imap_get_fd2 (msg_imap_t msg_imap, int *pfd1, int *pfd2) | ||
2030 | { | ||
2031 | if ( msg_imap | ||
2032 | && msg_imap->m_imap | ||
2033 | && msg_imap->m_imap->f_imap | ||
2034 | && msg_imap->m_imap->f_imap->folder) | ||
2035 | return stream_get_fd2 (msg_imap->m_imap->f_imap->folder->stream, | ||
2036 | pfd1, pfd2); | ||
2037 | return EINVAL; | ||
2038 | } | ||
2039 | |||
2026 | /* Since so many operations are fetch, we regoup this into one function. */ | 2040 | /* Since so many operations are fetch, we regoup this into one function. */ |
2027 | static int | 2041 | static int |
2028 | fetch_operation (f_imap_t f_imap, msg_imap_t msg_imap, char *buffer, | 2042 | fetch_operation (f_imap_t f_imap, msg_imap_t msg_imap, char *buffer, | ... | ... |
-
Please register or sign in to post a comment