* mailbox/body.c: body_lines () nd body_size () were not
properly overriden given the wrong size and line number, fixed. * mailbox/mbx_imap.c (mailbox_imap_close): Not to send another SELECT but rather just close the mailbox if not selected. (imap_scan0): If there is no messages in the mailbox no need to send the FETCH 1:*. * mailbox/message.c (message_is_modified): Protect against null pointer. * TODO: Some stuff todo 8).
Showing
8 changed files
with
114 additions
and
55 deletions
1 | 2001-10-23 Alain Magloire | ||
2 | |||
3 | * mailbox/body.c: body_lines () nd body_size () were not | ||
4 | properly overriden given the wrong size and line number, fixed. | ||
5 | * mailbox/mbx_imap.c (mailbox_imap_close): Not to send another SELECT | ||
6 | but rather just close the mailbox if not selected. | ||
7 | (imap_scan0): If there is no messages in the mailbox no need to | ||
8 | send the FETCH 1:*. | ||
9 | * mailbox/message.c (message_is_modified): Protect against null | ||
10 | pointer. | ||
11 | |||
12 | * TODO: Some stuff todo 8). | ||
13 | |||
1 | 2001-10-23 Sergey Poznyakoff | 14 | 2001-10-23 Sergey Poznyakoff |
2 | 15 | ||
3 | * mailbox/mutil.c: New function mu_get_user_email. | 16 | * mailbox/mutil.c: New function mu_get_user_email. |
... | @@ -23,7 +36,7 @@ | ... | @@ -23,7 +36,7 @@ |
23 | of hardcoded ones. | 36 | of hardcoded ones. |
24 | * mh/inc.c: Do not call mh_init() explicitly. | 37 | * mh/inc.c: Do not call mh_init() explicitly. |
25 | * mh/scan.c: Likewise. | 38 | * mh/scan.c: Likewise. |
26 | 39 | ||
27 | 2001-10-22 Jeff Bailey <jbailey@outpost.dnsalias.org> | 40 | 2001-10-22 Jeff Bailey <jbailey@outpost.dnsalias.org> |
28 | 41 | ||
29 | * doc/texinfo/Makefile.am: Remove version.texi, it's implied. | 42 | * doc/texinfo/Makefile.am: Remove version.texi, it's implied. | ... | ... |
... | @@ -23,10 +23,14 @@ IMPORTANT: | ... | @@ -23,10 +23,14 @@ IMPORTANT: |
23 | 23 | ||
24 | + crypt is linked even if pam was detected, it should be one or the other (JB Oct 08/99) | 24 | + crypt is linked even if pam was detected, it should be one or the other (JB Oct 08/99) |
25 | 25 | ||
26 | - SSL support | ||
27 | |||
26 | [imap4d] | 28 | [imap4d] |
27 | 29 | ||
28 | - Check interaction with imap clients. | 30 | - Check interaction with imap clients. |
29 | 31 | ||
32 | - Better support of multi-access mailbox | ||
33 | |||
30 | - implement charsets in search: 1 SEARCH CHARSET ISO-8859-2 TEXT ... | 34 | - implement charsets in search: 1 SEARCH CHARSET ISO-8859-2 TEXT ... |
31 | 35 | ||
32 | - implement AUTHENTICATE command (at least kerberos?) | 36 | - implement AUTHENTICATE command (at least kerberos?) |
... | @@ -35,6 +39,22 @@ IMPORTANT: | ... | @@ -35,6 +39,22 @@ IMPORTANT: |
35 | 39 | ||
36 | - Add MIME support. | 40 | - Add MIME support. |
37 | 41 | ||
42 | [mailbox] | ||
43 | |||
44 | - finish rewrite 8-) | ||
45 | |||
46 | - Configuration API | ||
47 | |||
48 | - Mailcap API | ||
49 | |||
50 | - Mime.types API | ||
51 | |||
52 | - imap4 client login referals | ||
53 | |||
54 | - imap4 client mailbox referals | ||
55 | |||
56 | - Maildir mailbox support | ||
57 | |||
38 | [sieve] | 58 | [sieve] |
39 | 59 | ||
40 | - bug: imap_fetch() can loop forever when sieve tries fileinto (sr - seen | 60 | - bug: imap_fetch() can loop forever when sieve tries fileinto (sr - seen | ... | ... |
... | @@ -31,14 +31,17 @@ | ... | @@ -31,14 +31,17 @@ |
31 | #include <mailutils/stream.h> | 31 | #include <mailutils/stream.h> |
32 | #include <body0.h> | 32 | #include <body0.h> |
33 | 33 | ||
34 | static int lazy_create __P ((body_t)); | 34 | static int lazy_create __P ((body_t)); |
35 | static int _body_flush __P ((stream_t)); | 35 | static int _body_flush __P ((stream_t)); |
36 | static int _body_get_fd __P ((stream_t, int *)); | 36 | static int _body_get_fd __P ((stream_t, int *)); |
37 | static int _body_read __P ((stream_t, char *, size_t, off_t, size_t *)); | 37 | static int _body_read __P ((stream_t, char *, size_t, off_t, size_t *)); |
38 | static int _body_readline __P ((stream_t, char *, size_t, off_t, size_t *)); | 38 | static int _body_readline __P ((stream_t, char *, size_t, off_t, size_t *)); |
39 | static int _body_write __P ((stream_t, const char *, size_t, off_t, size_t *)); | ||
40 | static int _body_truncate __P ((stream_t, off_t)); | 39 | static int _body_truncate __P ((stream_t, off_t)); |
41 | static int _body_size __P ((stream_t, off_t *)); | 40 | static int _body_size __P ((stream_t, off_t *)); |
41 | static int _body_lines __P ((stream_t, size_t *)); | ||
42 | static int _body_write __P ((stream_t, const char *, size_t, off_t, size_t *)); | ||
43 | static int _body_get_size __P ((body_t, size_t *)); | ||
44 | static int _body_get_lines __P ((body_t, size_t *)); | ||
42 | 45 | ||
43 | int | 46 | int |
44 | body_create (body_t *pbody, void *owner) | 47 | body_create (body_t *pbody, void *owner) |
... | @@ -158,6 +161,9 @@ body_get_stream (body_t body, stream_t *pstream) | ... | @@ -158,6 +161,9 @@ body_get_stream (body_t body, stream_t *pstream) |
158 | stream_set_truncate (body->stream, _body_truncate, body); | 161 | stream_set_truncate (body->stream, _body_truncate, body); |
159 | stream_set_size (body->stream, _body_size, body); | 162 | stream_set_size (body->stream, _body_size, body); |
160 | stream_set_flush (body->stream, _body_flush, body); | 163 | stream_set_flush (body->stream, _body_flush, body); |
164 | /* Override the defaults. */ | ||
165 | body->_lines = _body_get_lines; | ||
166 | body->_size = _body_get_size; | ||
161 | } | 167 | } |
162 | *pstream = body->stream; | 168 | *pstream = body->stream; |
163 | return 0; | 169 | return 0; |
... | @@ -202,39 +208,13 @@ body_lines (body_t body, size_t *plines) | ... | @@ -202,39 +208,13 @@ body_lines (body_t body, size_t *plines) |
202 | int | 208 | int |
203 | body_size (body_t body, size_t *psize) | 209 | body_size (body_t body, size_t *psize) |
204 | { | 210 | { |
205 | int status = 0; | ||
206 | if (body == NULL) | 211 | if (body == NULL) |
207 | return EINVAL; | 212 | return EINVAL; |
208 | |||
209 | /* Check to see if they want to doit themselves, | ||
210 | * it was probably not a floating message */ | ||
211 | if (body->_size) | 213 | if (body->_size) |
212 | return body->_size (body, psize); | 214 | return body->_size (body, psize); |
213 | 215 | if (psize) | |
214 | /* ok we should handle this */ | ||
215 | if (body->stream) | ||
216 | { | ||
217 | off_t off = 0; | ||
218 | status = stream_size (body->stream, &off); | ||
219 | if (status == 0) | ||
220 | if (psize) | ||
221 | *psize = off; | ||
222 | } | ||
223 | else if (body->filename) | ||
224 | { | ||
225 | struct stat st; | ||
226 | if (stat (body->filename, &st) == 0) | ||
227 | { | ||
228 | if (psize) | ||
229 | *psize = st.st_size; | ||
230 | } | ||
231 | else | ||
232 | status = errno; | ||
233 | } | ||
234 | else if (psize) | ||
235 | *psize = 0; | 216 | *psize = 0; |
236 | 217 | return 0; | |
237 | return status; | ||
238 | } | 218 | } |
239 | 219 | ||
240 | int | 220 | int |
... | @@ -297,6 +277,39 @@ _body_flush (stream_t stream) | ... | @@ -297,6 +277,39 @@ _body_flush (stream_t stream) |
297 | return stream_flush (body->fstream); | 277 | return stream_flush (body->fstream); |
298 | } | 278 | } |
299 | 279 | ||
280 | static int | ||
281 | _body_get_size (body_t body, size_t *plines) | ||
282 | { | ||
283 | off_t off = 0; | ||
284 | int status = _body_size (body->stream, &off); | ||
285 | if (plines) | ||
286 | *plines = off; | ||
287 | return status; | ||
288 | } | ||
289 | |||
290 | static int | ||
291 | _body_get_lines (body_t body, size_t *plines) | ||
292 | { | ||
293 | int status = stream_flush (body->fstream); | ||
294 | size_t lines = 0; | ||
295 | if (status == 0) | ||
296 | { | ||
297 | char buf[128]; | ||
298 | size_t n = 0; | ||
299 | off_t off = 0; | ||
300 | while ((status = stream_readline (body->fstream, buf, sizeof buf, | ||
301 | off, &n)) == 0 && n > 0) | ||
302 | { | ||
303 | if (buf[n - 1] == '\n') | ||
304 | lines++; | ||
305 | off += n; | ||
306 | } | ||
307 | } | ||
308 | if (plines) | ||
309 | *plines = lines; | ||
310 | return status; | ||
311 | } | ||
312 | |||
300 | #ifndef P_tmpdir | 313 | #ifndef P_tmpdir |
301 | # define P_tmpdir "/tmp" | 314 | # define P_tmpdir "/tmp" |
302 | #endif | 315 | #endif | ... | ... |
... | @@ -233,6 +233,10 @@ mailbox_imap_close (mailbox_t mailbox) | ... | @@ -233,6 +233,10 @@ mailbox_imap_close (mailbox_t mailbox) |
233 | f_imap_t f_imap = m_imap->f_imap; | 233 | f_imap_t f_imap = m_imap->f_imap; |
234 | int status = 0; | 234 | int status = 0; |
235 | 235 | ||
236 | /* If we are not the selected mailbox, just close the stream. */ | ||
237 | if (m_imap != f_imap->selected) | ||
238 | return folder_close (mailbox->folder); | ||
239 | |||
236 | /* Select first. */ | 240 | /* Select first. */ |
237 | status = imap_messages_count (mailbox, NULL); | 241 | status = imap_messages_count (mailbox, NULL); |
238 | if (status != 0) | 242 | if (status != 0) |
... | @@ -582,6 +586,10 @@ imap_scan0 (mailbox_t mailbox, size_t msgno, size_t *pcount, int notif) | ... | @@ -582,6 +586,10 @@ imap_scan0 (mailbox_t mailbox, size_t msgno, size_t *pcount, int notif) |
582 | if (status != 0) | 586 | if (status != 0) |
583 | return status; | 587 | return status; |
584 | 588 | ||
589 | /* No need to scan, there is no messages. */ | ||
590 | if (count == 0) | ||
591 | return 0; | ||
592 | |||
585 | switch (f_imap->state) | 593 | switch (f_imap->state) |
586 | { | 594 | { |
587 | case IMAP_NO_STATE: | 595 | case IMAP_NO_STATE: |
... | @@ -792,18 +800,18 @@ imap_append_message (mailbox_t mailbox, message_t msg) | ... | @@ -792,18 +800,18 @@ imap_append_message (mailbox_t mailbox, message_t msg) |
792 | status = flags_to_string (&abuf, flags); | 800 | status = flags_to_string (&abuf, flags); |
793 | if (status != 0) | 801 | if (status != 0) |
794 | return status; | 802 | return status; |
795 | if (*abuf != '\0') | 803 | /* Put the surrounding parenthesis, wu-IMAP is sensible to this. */ |
796 | { | 804 | { |
797 | char *tmp = calloc (strlen (abuf) + 3, 1); | 805 | char *tmp = calloc (strlen (abuf) + 3, 1); |
798 | if (tmp == NULL) | 806 | if (tmp == NULL) |
799 | { | 807 | { |
800 | free (abuf); | 808 | free (abuf); |
801 | return ENOMEM; | 809 | return ENOMEM; |
802 | } | 810 | } |
803 | sprintf (tmp, "(%s)", abuf); | 811 | sprintf (tmp, "(%s)", abuf); |
804 | free (abuf); | 812 | free (abuf); |
805 | abuf = tmp; | 813 | abuf = tmp; |
806 | } | 814 | } |
807 | } | 815 | } |
808 | 816 | ||
809 | /* Get the mailbox filepath. */ | 817 | /* Get the mailbox filepath. */ | ... | ... |
... | @@ -163,9 +163,12 @@ int | ... | @@ -163,9 +163,12 @@ int |
163 | message_is_modified (message_t msg) | 163 | message_is_modified (message_t msg) |
164 | { | 164 | { |
165 | int mod = 0; | 165 | int mod = 0; |
166 | mod |= header_is_modified (msg->header); | 166 | if (msg) |
167 | mod |= attribute_is_modified (msg->attribute); | 167 | { |
168 | mod |= body_is_modified (msg->body); | 168 | mod |= header_is_modified (msg->header); |
169 | mod |= attribute_is_modified (msg->attribute); | ||
170 | mod |= body_is_modified (msg->body); | ||
171 | } | ||
169 | return mod; | 172 | return mod; |
170 | } | 173 | } |
171 | 174 | ... | ... |
... | @@ -30,6 +30,7 @@ | ... | @@ -30,6 +30,7 @@ |
30 | #include <unistd.h> | 30 | #include <unistd.h> |
31 | #include <string.h> | 31 | #include <string.h> |
32 | #include <netdb.h> | 32 | #include <netdb.h> |
33 | #include <errno.h> | ||
33 | 34 | ||
34 | #include <mailutils/mutil.h> | 35 | #include <mailutils/mutil.h> |
35 | #include <mailutils/iterator.h> | 36 | #include <mailutils/iterator.h> |
... | @@ -414,7 +415,7 @@ mu_get_user_email (char *name) | ... | @@ -414,7 +415,7 @@ mu_get_user_email (char *name) |
414 | struct hostent *hp; | 415 | struct hostent *hp; |
415 | char *domainpart; | 416 | char *domainpart; |
416 | char *email; | 417 | char *email; |
417 | 418 | ||
418 | if (!name) | 419 | if (!name) |
419 | { | 420 | { |
420 | struct passwd *pw = getpwuid (getuid ()); | 421 | struct passwd *pw = getpwuid (getuid ()); | ... | ... |
... | @@ -78,16 +78,18 @@ struct work_buf | ... | @@ -78,16 +78,18 @@ struct work_buf |
78 | char *ptr; | 78 | char *ptr; |
79 | char *nl; | 79 | char *nl; |
80 | size_t len; | 80 | size_t len; |
81 | off_t offset; /* To synchronise with the buffering. */ | ||
81 | }; | 82 | }; |
82 | 83 | ||
83 | /* Structure to hold things general to POP3 mailbox, like its state, etc ... */ | 84 | /* Structure to hold things general to POP3 mailbox, like its state, etc ... */ |
84 | struct _pop3 | 85 | struct _pop3 |
85 | { | 86 | { |
86 | /* Working I/O buffers. */ | 87 | /* Working I/O buffer. */ |
87 | /* io.buf: Working io buffer. */ | 88 | /* io.buf: Working io buffer. */ |
88 | /* io.ptr: Points to the end of the buffer, the non consume chars. */ | 89 | /* io.ptr: Points to the end of the buffer, the non consume chars. */ |
89 | /* io.nl: Points to the '\n' char in the string. */ | 90 | /* io.nl: Points to the '\n' char in the string. */ |
90 | /* io.len: Len of io_buf. */ | 91 | /* io.len: Len of io_buf. */ |
92 | /* io.offset; full the stream_t implementation. */ | ||
91 | struct work_buf io; | 93 | struct work_buf io; |
92 | 94 | ||
93 | /* Holds the first line response of the last command, i.e the ACK. */ | 95 | /* Holds the first line response of the last command, i.e the ACK. */ |
... | @@ -102,7 +104,6 @@ struct _pop3 | ... | @@ -102,7 +104,6 @@ struct _pop3 |
102 | 104 | ||
103 | enum pop3_state state; | 105 | enum pop3_state state; |
104 | stream_t carrier; /* TCP Connection. */ | 106 | stream_t carrier; /* TCP Connection. */ |
105 | off_t offset; /* To synchronise with the buffering. */ | ||
106 | mu_debug_t debug; /* Send the debug info. */ | 107 | mu_debug_t debug; /* Send the debug info. */ |
107 | }; | 108 | }; |
108 | 109 | ... | ... |
... | @@ -50,10 +50,10 @@ pop3_getline (pop3_t pop3) | ... | @@ -50,10 +50,10 @@ pop3_getline (pop3_t pop3) |
50 | } | 50 | } |
51 | 51 | ||
52 | status = stream_readline (pop3->carrier, pop3->io.buf + total, | 52 | status = stream_readline (pop3->carrier, pop3->io.buf + total, |
53 | pop3->io.len - total, pop3->offset, &n); | 53 | pop3->io.len - total, pop3->io.offset, &n); |
54 | if (status != 0) | 54 | if (status != 0) |
55 | return status; | 55 | return status; |
56 | pop3->offset += n; | 56 | pop3->io.offset += n; |
57 | 57 | ||
58 | /* The server went away: It maybe a timeout and some pop server | 58 | /* The server went away: It maybe a timeout and some pop server |
59 | does not send the -ERR. Consider this like an error. */ | 59 | does not send the -ERR. Consider this like an error. */ | ... | ... |
-
Please register or sign in to post a comment