Commit 9c57918e 9c57918efb596b918322bd6ba8aeeabc2cfd6a57 by Alain Magloire

A small cleanup of the IMAP code.

	* mailbox/folder_imap.c (imap_body):  Destry the cache header
	if it was previously set on a SCAN.
	* mailbox/mbx_imap.c (delete_to_string): New function, to generate
	a string of IMAP message numbers.
	(imap_expunge): use delete_to_string;
	(attribute_string): Removed.
	(flags_string): Removed.
	(flags_to_string): Replace attribute_string() and flags_string().
	(message_operation): Rename to fetch_operation.
	* mailbox/include/imap0.h(struct _f_imap): field func and id
	removed, never used.
1 parent cf69f401
1 2001-10-11 Alain Magloire 1 2001-10-11 Alain Magloire
2 2
3 A small cleanup of the IMAP code.
4
5 * mailbox/folder_imap.c (imap_body): Destry the cache header
6 if it was previously set on a SCAN.
7 * mailbox/mbx_imap.c (delete_to_string): New function, to generate
8 a string of IMAP message numbers.
9 (imap_expunge): use delete_to_string;
10 (attribute_string): Removed.
11 (flags_string): Removed.
12 (flags_to_string): Replace attribute_string() and flags_string().
13 (message_operation): Rename to fetch_operation.
14 * mailbox/include/imap0.h(struct _f_imap): field func and id
15 removed, never used.
16
17 2001-10-11 Alain Magloire
18
3 * mailbox/folder_imap.c (imap_quoted_string): Free the buffer. 19 * mailbox/folder_imap.c (imap_quoted_string): Free the buffer.
4 (imap_string): Free the buffer. 20 (imap_string): Free the buffer.
5 (imap_body): Check if we already have the fheader header. 21 (imap_body): Check if we already have the fheader header.
...@@ -7,14 +23,15 @@ ...@@ -7,14 +23,15 @@
7 23
8 2001-10-11 Alain Magloire 24 2001-10-11 Alain Magloire
9 25
10 In order to boost performance, when doing the scan we use 26 In order to boost performance, when doing the scan, we use
11 the approach of downloading part of the header of the total 27 the approach of downloading a subset of the header from all
12 set of messages. The it was done before is that the headers 28 of messages. The way it was done before was that the headers
13 were ask one by one per message. This was causing performance 29 were requested one by one per message. This was causing performance
14 delay because we were doing a lot of small transaction on 30 issues because we were doing a lot of small transactions on
15 the TCP/IP stack. By bundling the entire thing in one request 31 the TCP/IP stack. By bundling the entire thing in one request
16 there was much less transcation and the speed was increase 32 "a0000 FETCH 1:* (FLAGS RFC822.SIZE BODY.PEEK[HEADER.FIELDS(..)])\r\n"
17 by a factor of 10++. 33 there were less transcations and the speed was increase
34 by a factor of 100+.
18 The Imap code folder_imap.c and mbx_imap.c is now messy. 35 The Imap code folder_imap.c and mbx_imap.c is now messy.
19 The rewrite in mailbox2 should clean this up though. 36 The rewrite in mailbox2 should clean this up though.
20 37
......
...@@ -61,6 +61,7 @@ record_t imap_record = &_imap_record; ...@@ -61,6 +61,7 @@ record_t imap_record = &_imap_record;
61 #ifndef HAVE_STRTOK_R 61 #ifndef HAVE_STRTOK_R
62 char *strtok_r __P ((char *, const char *, char **)); 62 char *strtok_r __P ((char *, const char *, char **));
63 #endif 63 #endif
64
64 /* Concrete IMAP implementation. */ 65 /* Concrete IMAP implementation. */
65 static int folder_imap_open __P ((folder_t, int)); 66 static int folder_imap_open __P ((folder_t, int));
66 static int folder_imap_create __P ((folder_t)); 67 static int folder_imap_create __P ((folder_t));
...@@ -122,7 +123,7 @@ _folder_imap_init (folder_t folder) ...@@ -122,7 +123,7 @@ _folder_imap_init (folder_t folder)
122 return 0; 123 return 0;
123 } 124 }
124 125
125 /* Destroy the resources. */ 126 /* Destroy the folder resources. */
126 static void 127 static void
127 folder_imap_destroy (folder_t folder) 128 folder_imap_destroy (folder_t folder)
128 { 129 {
...@@ -1374,9 +1375,12 @@ imap_body (f_imap_t f_imap, char **ptr) ...@@ -1374,9 +1375,12 @@ imap_body (f_imap_t f_imap, char **ptr)
1374 } 1375 }
1375 } 1376 }
1376 status = imap_string (f_imap, ptr); 1377 status = imap_string (f_imap, ptr);
1377 if (f_imap->callback.msg_imap->fheader == NULL 1378
1378 && f_imap->state == IMAP_SCAN_ACK && f_imap->callback.total) 1379 /* If the state scan. Catch it here. */
1380 if (f_imap->state == IMAP_SCAN_ACK)
1379 { 1381 {
1382 if (f_imap->callback.msg_imap->fheader)
1383 header_destroy (&f_imap->callback.msg_imap->fheader, NULL);
1380 status = header_create (&f_imap->callback.msg_imap->fheader, 1384 status = header_create (&f_imap->callback.msg_imap->fheader,
1381 f_imap->callback.buffer, f_imap->callback.total, 1385 f_imap->callback.buffer, f_imap->callback.total,
1382 NULL); 1386 NULL);
......
...@@ -39,7 +39,7 @@ extern "C" { ...@@ -39,7 +39,7 @@ extern "C" {
39 #endif /*__P */ 39 #endif /*__P */
40 40
41 #define CLEAR_STATE(f_imap) \ 41 #define CLEAR_STATE(f_imap) \
42 f_imap->selected = NULL, f_imap->id = 0, f_imap->func = NULL, f_imap->state = IMAP_NO_STATE 42 f_imap->selected = NULL, f_imap->state = IMAP_NO_STATE
43 43
44 /* Clear the state and close the stream. */ 44 /* Clear the state and close the stream. */
45 #define CHECK_ERROR_CLOSE(folder, f_imap, status) \ 45 #define CHECK_ERROR_CLOSE(folder, f_imap, status) \
...@@ -136,8 +136,6 @@ struct _f_imap ...@@ -136,8 +136,6 @@ struct _f_imap
136 m_imap_t selected; 136 m_imap_t selected;
137 137
138 enum imap_state state; 138 enum imap_state state;
139 void *func;
140 size_t id;
141 139
142 size_t seq; /* Sequence number to build a tag. */ 140 size_t seq; /* Sequence number to build a tag. */
143 char *capa; /* Cabilities of the server. */ 141 char *capa; /* Cabilities of the server. */
......