author | zautrix <zautrix> | 2004-09-01 10:23:29 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-01 10:23:29 (UTC) |
commit | 6cefbdc9c8f3f3001373f10715361e2740c45395 (patch) (unidiff) | |
tree | cb2c36f57620e698913c27ca4ebe59e4a7c9d46e /kmicromail/libetpan/generic/pop3driver_message.c | |
parent | b9257cb225cd29bab5d96fcdaf557926603ee587 (diff) | |
download | kdepimpi-6cefbdc9c8f3f3001373f10715361e2740c45395.zip kdepimpi-6cefbdc9c8f3f3001373f10715361e2740c45395.tar.gz kdepimpi-6cefbdc9c8f3f3001373f10715361e2740c45395.tar.bz2 |
Mail fixes and libetpan updated
Diffstat (limited to 'kmicromail/libetpan/generic/pop3driver_message.c') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kmicromail/libetpan/generic/pop3driver_message.c | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/kmicromail/libetpan/generic/pop3driver_message.c b/kmicromail/libetpan/generic/pop3driver_message.c index 77bd94c..357bb2e 100644 --- a/kmicromail/libetpan/generic/pop3driver_message.c +++ b/kmicromail/libetpan/generic/pop3driver_message.c | |||
@@ -18,130 +18,164 @@ | |||
18 | * | 18 | * |
19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | 19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
29 | * SUCH DAMAGE. | 29 | * SUCH DAMAGE. |
30 | */ | 30 | */ |
31 | 31 | ||
32 | /* | 32 | /* |
33 | * $Id$ | 33 | * $Id$ |
34 | */ | 34 | */ |
35 | 35 | ||
36 | #include "pop3driver_message.h" | 36 | #include "pop3driver_message.h" |
37 | 37 | ||
38 | #include "mailmessage_tools.h" | 38 | #include "mailmessage_tools.h" |
39 | #include "pop3driver_tools.h" | 39 | #include "pop3driver_tools.h" |
40 | #include "pop3driver.h" | 40 | #include "pop3driver.h" |
41 | #include "mailpop3.h" | 41 | #include "mailpop3.h" |
42 | #include <stdlib.h> | ||
43 | #include <string.h> | ||
42 | 44 | ||
43 | static int pop3_prefetch(mailmessage * msg_info); | 45 | static int pop3_prefetch(mailmessage * msg_info); |
44 | 46 | ||
45 | static void pop3_prefetch_free(struct generic_message_t * msg); | 47 | static void pop3_prefetch_free(struct generic_message_t * msg); |
46 | 48 | ||
47 | static int pop3_initialize(mailmessage * msg_info); | 49 | static int pop3_initialize(mailmessage * msg_info); |
48 | 50 | ||
49 | static int pop3_fetch_header(mailmessage * msg_info, | 51 | static int pop3_fetch_header(mailmessage * msg_info, |
50 | char ** result, | 52 | char ** result, |
51 | size_t * result_len); | 53 | size_t * result_len); |
52 | 54 | ||
53 | static int pop3_fetch_size(mailmessage * msg_info, | 55 | static int pop3_fetch_size(mailmessage * msg_info, |
54 | size_t * result); | 56 | size_t * result); |
55 | 57 | ||
56 | static mailmessage_driver local_pop3_message_driver = { | 58 | static mailmessage_driver local_pop3_message_driver = { |
57 | .msg_name = "pop3", | 59 | .msg_name = "pop3", |
58 | 60 | ||
59 | .msg_initialize = pop3_initialize, | 61 | .msg_initialize = pop3_initialize, |
60 | .msg_uninitialize = mailmessage_generic_uninitialize, | 62 | .msg_uninitialize = mailmessage_generic_uninitialize, |
61 | 63 | ||
62 | .msg_flush = mailmessage_generic_flush, | 64 | .msg_flush = mailmessage_generic_flush, |
63 | .msg_check = NULL, | 65 | .msg_check = NULL, |
64 | 66 | ||
65 | .msg_fetch_result_free = mailmessage_generic_fetch_result_free, | 67 | .msg_fetch_result_free = mailmessage_generic_fetch_result_free, |
66 | 68 | ||
67 | .msg_fetch = mailmessage_generic_fetch, | 69 | .msg_fetch = mailmessage_generic_fetch, |
68 | .msg_fetch_header = pop3_fetch_header, | 70 | .msg_fetch_header = pop3_fetch_header, |
69 | .msg_fetch_body = mailmessage_generic_fetch_body, | 71 | .msg_fetch_body = mailmessage_generic_fetch_body, |
70 | .msg_fetch_size = pop3_fetch_size, | 72 | .msg_fetch_size = pop3_fetch_size, |
71 | .msg_get_bodystructure = mailmessage_generic_get_bodystructure, | 73 | .msg_get_bodystructure = mailmessage_generic_get_bodystructure, |
72 | .msg_fetch_section = mailmessage_generic_fetch_section, | 74 | .msg_fetch_section = mailmessage_generic_fetch_section, |
73 | .msg_fetch_section_header = mailmessage_generic_fetch_section_header, | 75 | .msg_fetch_section_header = mailmessage_generic_fetch_section_header, |
74 | .msg_fetch_section_mime = mailmessage_generic_fetch_section_mime, | 76 | .msg_fetch_section_mime = mailmessage_generic_fetch_section_mime, |
75 | .msg_fetch_section_body = mailmessage_generic_fetch_section_body, | 77 | .msg_fetch_section_body = mailmessage_generic_fetch_section_body, |
76 | .msg_fetch_envelope = mailmessage_generic_fetch_envelope, | 78 | .msg_fetch_envelope = mailmessage_generic_fetch_envelope, |
77 | 79 | ||
78 | .msg_get_flags = NULL, | 80 | .msg_get_flags = NULL, |
79 | }; | 81 | }; |
80 | 82 | ||
81 | mailmessage_driver * pop3_message_driver = &local_pop3_message_driver; | 83 | mailmessage_driver * pop3_message_driver = &local_pop3_message_driver; |
82 | 84 | ||
85 | static inline struct pop3_session_state_data * | ||
86 | get_data(mailsession * session) | ||
87 | { | ||
88 | return session->sess_data; | ||
89 | } | ||
90 | |||
91 | |||
92 | static mailpop3 * get_pop3_session(mailsession * session) | ||
93 | { | ||
94 | return get_data(session)->pop3_session; | ||
95 | } | ||
96 | |||
83 | 97 | ||
84 | static int pop3_prefetch(mailmessage * msg_info) | 98 | static int pop3_prefetch(mailmessage * msg_info) |
85 | { | 99 | { |
86 | char * msg_content; | 100 | char * msg_content; |
87 | size_t msg_length; | 101 | size_t msg_length; |
88 | struct generic_message_t * msg; | 102 | struct generic_message_t * msg; |
89 | int r; | 103 | int r; |
90 | 104 | ||
91 | r = pop3driver_retr(msg_info->msg_session, msg_info->msg_index, | 105 | r = pop3driver_retr(msg_info->msg_session, msg_info->msg_index, |
92 | &msg_content, &msg_length); | 106 | &msg_content, &msg_length); |
93 | if (r != MAIL_NO_ERROR) | 107 | if (r != MAIL_NO_ERROR) |
94 | return r; | 108 | return r; |
95 | 109 | ||
96 | msg = msg_info->msg_data; | 110 | msg = msg_info->msg_data; |
97 | 111 | ||
98 | msg->msg_message = msg_content; | 112 | msg->msg_message = msg_content; |
99 | msg->msg_length = msg_length; | 113 | msg->msg_length = msg_length; |
100 | 114 | ||
101 | return MAIL_NO_ERROR; | 115 | return MAIL_NO_ERROR; |
102 | } | 116 | } |
103 | 117 | ||
104 | static void pop3_prefetch_free(struct generic_message_t * msg) | 118 | static void pop3_prefetch_free(struct generic_message_t * msg) |
105 | { | 119 | { |
106 | if (msg->msg_message != NULL) { | 120 | if (msg->msg_message != NULL) { |
107 | mmap_string_unref(msg->msg_message); | 121 | mmap_string_unref(msg->msg_message); |
108 | msg->msg_message = NULL; | 122 | msg->msg_message = NULL; |
109 | } | 123 | } |
110 | } | 124 | } |
111 | 125 | ||
112 | static int pop3_initialize(mailmessage * msg_info) | 126 | static int pop3_initialize(mailmessage * msg_info) |
113 | { | 127 | { |
114 | struct generic_message_t * msg; | 128 | struct generic_message_t * msg; |
115 | int r; | 129 | int r; |
130 | char * uid; | ||
131 | struct mailpop3_msg_info * info; | ||
132 | mailpop3 * pop3; | ||
133 | |||
134 | pop3 = get_pop3_session(msg_info->msg_session); | ||
135 | |||
136 | r = mailpop3_get_msg_info(pop3, msg_info->msg_index, &info); | ||
137 | switch (r) { | ||
138 | case MAILPOP3_NO_ERROR: | ||
139 | break; | ||
140 | default: | ||
141 | return pop3driver_pop3_error_to_mail_error(r); | ||
142 | } | ||
143 | |||
144 | uid = strdup(info->msg_uidl); | ||
145 | if (uid == NULL) | ||
146 | return MAIL_ERROR_MEMORY; | ||
116 | 147 | ||
117 | r = mailmessage_generic_initialize(msg_info); | 148 | r = mailmessage_generic_initialize(msg_info); |
118 | if (r != MAIL_NO_ERROR) | 149 | if (r != MAIL_NO_ERROR) { |
150 | free(uid); | ||
119 | return r; | 151 | return r; |
152 | } | ||
120 | 153 | ||
121 | msg = msg_info->msg_data; | 154 | msg = msg_info->msg_data; |
122 | msg->msg_prefetch = pop3_prefetch; | 155 | msg->msg_prefetch = pop3_prefetch; |
123 | msg->msg_prefetch_free = pop3_prefetch_free; | 156 | msg->msg_prefetch_free = pop3_prefetch_free; |
157 | msg_info->msg_uid = uid; | ||
124 | 158 | ||
125 | return MAIL_NO_ERROR; | 159 | return MAIL_NO_ERROR; |
126 | } | 160 | } |
127 | 161 | ||
128 | 162 | ||
129 | static int pop3_fetch_header(mailmessage * msg_info, | 163 | static int pop3_fetch_header(mailmessage * msg_info, |
130 | char ** result, | 164 | char ** result, |
131 | size_t * result_len) | 165 | size_t * result_len) |
132 | { | 166 | { |
133 | struct generic_message_t * msg; | 167 | struct generic_message_t * msg; |
134 | char * headers; | 168 | char * headers; |
135 | size_t headers_length; | 169 | size_t headers_length; |
136 | int r; | 170 | int r; |
137 | 171 | ||
138 | msg = msg_info->msg_data; | 172 | msg = msg_info->msg_data; |
139 | 173 | ||
140 | if (msg->msg_message != NULL) | 174 | if (msg->msg_message != NULL) |
141 | return mailmessage_generic_fetch_header(msg_info, | 175 | return mailmessage_generic_fetch_header(msg_info, |
142 | result, result_len); | 176 | result, result_len); |
143 | 177 | ||
144 | r = pop3driver_header(msg_info->msg_session, msg_info->msg_index, | 178 | r = pop3driver_header(msg_info->msg_session, msg_info->msg_index, |
145 | &headers, &headers_length); | 179 | &headers, &headers_length); |
146 | if (r != MAIL_NO_ERROR) | 180 | if (r != MAIL_NO_ERROR) |
147 | return r; | 181 | return r; |