summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/libetpan/generic/pop3driver.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/kmicromail/libetpan/generic/pop3driver.c b/kmicromail/libetpan/generic/pop3driver.c
index 475dfcc..a4a4893 100644
--- a/kmicromail/libetpan/generic/pop3driver.c
+++ b/kmicromail/libetpan/generic/pop3driver.c
@@ -155,216 +155,216 @@ static int pop3driver_initialize(mailsession * session)
155 155
156 session->sess_data = data; 156 session->sess_data = data;
157 157
158 return MAIL_NO_ERROR; 158 return MAIL_NO_ERROR;
159 159
160 free: 160 free:
161 mailpop3_free(pop3); 161 mailpop3_free(pop3);
162 err: 162 err:
163 return MAIL_ERROR_MEMORY; 163 return MAIL_ERROR_MEMORY;
164} 164}
165 165
166static void pop3driver_uninitialize(mailsession * session) 166static void pop3driver_uninitialize(mailsession * session)
167{ 167{
168 struct pop3_session_state_data * data; 168 struct pop3_session_state_data * data;
169 169
170 data = get_data(session); 170 data = get_data(session);
171 171
172 mailpop3_free(data->pop3_session); 172 mailpop3_free(data->pop3_session);
173 free(data); 173 free(data);
174 174
175 session->sess_data = data; 175 session->sess_data = data;
176} 176}
177 177
178static int pop3driver_connect_stream(mailsession * session, mailstream * s) 178static int pop3driver_connect_stream(mailsession * session, mailstream * s)
179{ 179{
180 int r; 180 int r;
181 181
182 r = mailpop3_connect(get_pop3_session(session), s); 182 r = mailpop3_connect(get_pop3_session(session), s);
183 183
184 switch (r) { 184 switch (r) {
185 case MAILPOP3_NO_ERROR: 185 case MAILPOP3_NO_ERROR:
186 return MAIL_NO_ERROR_NON_AUTHENTICATED; 186 return MAIL_NO_ERROR_NON_AUTHENTICATED;
187 187
188 default: 188 default:
189 return pop3driver_pop3_error_to_mail_error(r); 189 return pop3driver_pop3_error_to_mail_error(r);
190 } 190 }
191} 191}
192 192
193static int pop3driver_starttls(mailsession * session) 193static int pop3driver_starttls(mailsession * session)
194{ 194{
195 int r; 195 int r;
196 int fd; 196 int fd;
197 mailstream_low * low; 197 mailstream_low * low;
198 mailstream_low * new_low; 198 mailstream_low * new_low;
199 mailpop3 * pop3; 199 mailpop3 * pop3;
200 200
201 pop3 = get_pop3_session(session); 201 pop3 = get_pop3_session(session);
202 202
203 r = mailpop3_stls(pop3); 203 r = mailpop3_stls(pop3);
204 204
205 switch (r) { 205 switch (r) {
206 case MAILPOP3_NO_ERROR: 206 case MAILPOP3_NO_ERROR:
207 break; 207 break;
208 default: 208 default:
209 return pop3driver_pop3_error_to_mail_error(r); 209 return pop3driver_pop3_error_to_mail_error(r);
210 } 210 }
211 211
212 low = mailstream_get_low(pop3->pop3_stream); 212 low = mailstream_get_low(pop3->pop3_stream);
213 fd = mailstream_low_get_fd(low); 213 fd = mailstream_low_get_fd(low);
214 if (fd == -1) 214 if (fd == -1)
215 return MAIL_ERROR_STREAM; 215 return MAIL_ERROR_STREAM;
216 216
217 new_low = mailstream_low_ssl_open(fd); 217 new_low = mailstream_low_ssl_open(fd);
218 if (new_low == NULL) 218 if (new_low == NULL)
219 return MAIL_ERROR_STREAM; 219 return MAIL_ERROR_STREAM;
220 mailstream_low_free(low); 220 mailstream_low_free(low);
221 mailstream_set_low(pop3->pop3_stream, new_low); 221 mailstream_set_low(pop3->pop3_stream, new_low);
222 222
223 return MAIL_NO_ERROR; 223 return MAIL_NO_ERROR;
224} 224}
225 225
226static int pop3driver_parameters(mailsession * session, 226static int pop3driver_parameters(mailsession * session,
227 int id, void * value) 227 int id, void * value)
228{ 228{
229 struct pop3_session_state_data * data; 229 struct pop3_session_state_data * data;
230 230
231 data = get_data(session); 231 data = get_data(session);
232 232
233 switch (id) { 233 switch (id) {
234 case POP3DRIVER_SET_AUTH_TYPE: 234 case POP3DRIVER_SET_AUTH_TYPE:
235 { 235 {
236 int * param; 236 int * param;
237 237
238 param = value; 238 param = value;
239 239
240 data->pop3_auth_type = * param; 240 data->pop3_auth_type = * param;
241 return MAIL_NO_ERROR; 241 return MAIL_NO_ERROR;
242 } 242 }
243 } 243 }
244 244
245 return MAIL_ERROR_INVAL; 245 return MAIL_ERROR_INVAL;
246} 246}
247 247
248static int pop3driver_login(mailsession * session, 248static int pop3driver_login(mailsession * session,
249 char * userid, char * password) 249 char * userid, char * password)
250{ 250{
251 int r; 251 int r;int ret ;
252 carray * msg_tab; 252 carray * msg_tab;
253 struct pop3_session_state_data * data; 253 struct pop3_session_state_data * data;
254 254
255 data = get_data(session); 255 data = get_data(session);
256 256
257 switch (data->pop3_auth_type) { 257 switch (data->pop3_auth_type) {
258 case POP3DRIVER_AUTH_TYPE_TRY_APOP: 258 case POP3DRIVER_AUTH_TYPE_TRY_APOP:
259 r = mailpop3_login_apop(get_pop3_session(session), userid, password); 259 r = mailpop3_login_apop(get_pop3_session(session), userid, password);
260 if (r != MAILPOP3_NO_ERROR) 260 if (r != MAILPOP3_NO_ERROR)
261 r = mailpop3_login(get_pop3_session(session), userid, password); 261 r = mailpop3_login(get_pop3_session(session), userid, password);
262 break; 262 break;
263 263
264 case POP3DRIVER_AUTH_TYPE_APOP: 264 case POP3DRIVER_AUTH_TYPE_APOP:
265 r = mailpop3_login_apop(get_pop3_session(session), userid, password); 265 r = mailpop3_login_apop(get_pop3_session(session), userid, password);
266 break; 266 break;
267 267
268 default: 268 default:
269 case POP3DRIVER_AUTH_TYPE_PLAIN: 269 case POP3DRIVER_AUTH_TYPE_PLAIN:
270 r = mailpop3_login(get_pop3_session(session), userid, password); 270 r = mailpop3_login(get_pop3_session(session), userid, password);
271 break; 271 break;
272 } 272 }
273 // LR 2 lines 273 // LR 2 lines
274 int ret = pop3driver_pop3_error_to_mail_error(r); 274 ret = pop3driver_pop3_error_to_mail_error(r);
275 if ( ret == MAIL_NO_ERROR ) 275 if ( ret == MAIL_NO_ERROR )
276 mailpop3_list(get_pop3_session(session), &msg_tab); 276 mailpop3_list(get_pop3_session(session), &msg_tab);
277 277
278 // LR 278 // LR
279 return ret; 279 return ret;
280} 280}
281 281
282static int pop3driver_logout(mailsession * session) 282static int pop3driver_logout(mailsession * session)
283{ 283{
284 int r; 284 int r;
285 285
286 r = mailpop3_quit(get_pop3_session(session)); 286 r = mailpop3_quit(get_pop3_session(session));
287 287
288 return pop3driver_pop3_error_to_mail_error(r); 288 return pop3driver_pop3_error_to_mail_error(r);
289} 289}
290 290
291static int pop3driver_noop(mailsession * session) 291static int pop3driver_noop(mailsession * session)
292{ 292{
293 int r; 293 int r;
294 294
295 r = mailpop3_noop(get_pop3_session(session)); 295 r = mailpop3_noop(get_pop3_session(session));
296 296
297 return pop3driver_pop3_error_to_mail_error(r); 297 return pop3driver_pop3_error_to_mail_error(r);
298} 298}
299 299
300static int pop3driver_status_folder(mailsession * session, char * mb, 300static int pop3driver_status_folder(mailsession * session, char * mb,
301 uint32_t * result_messages, 301 uint32_t * result_messages,
302 uint32_t * result_recent, 302 uint32_t * result_recent,
303 uint32_t * result_unseen) 303 uint32_t * result_unseen)
304{ 304{
305 uint32_t count; 305 uint32_t count;
306 int r; 306 int r;
307 307
308 r = pop3driver_messages_number(session, mb, &count); 308 r = pop3driver_messages_number(session, mb, &count);
309 if (r != MAIL_NO_ERROR) 309 if (r != MAIL_NO_ERROR)
310 return r; 310 return r;
311 311
312 * result_messages = count; 312 * result_messages = count;
313 * result_recent = count; 313 * result_recent = count;
314 * result_unseen = count; 314 * result_unseen = count;
315 315
316 return MAIL_NO_ERROR; 316 return MAIL_NO_ERROR;
317} 317}
318 318
319static int pop3driver_messages_number(mailsession * session, char * mb, 319static int pop3driver_messages_number(mailsession * session, char * mb,
320 uint32_t * result) 320 uint32_t * result)
321{ 321{
322 carray * msg_tab; 322 carray * msg_tab;
323 323
324 mailpop3_list(get_pop3_session(session), &msg_tab); 324 mailpop3_list(get_pop3_session(session), &msg_tab);
325 325
326 * result = carray_count(msg_tab) - 326 * result = carray_count(msg_tab) -
327 get_pop3_session(session)->pop3_deleted_count; 327 get_pop3_session(session)->pop3_deleted_count;
328 328
329 return MAIL_NO_ERROR; 329 return MAIL_NO_ERROR;
330} 330}
331 331
332 332
333/* messages operations */ 333/* messages operations */
334 334
335static int pop3driver_remove_message(mailsession * session, uint32_t num) 335static int pop3driver_remove_message(mailsession * session, uint32_t num)
336{ 336{
337 mailpop3 * pop3; 337 mailpop3 * pop3;
338 int r; 338 int r;
339 339
340 pop3 = get_pop3_session(session); 340 pop3 = get_pop3_session(session);
341 341
342 r = mailpop3_dele(pop3, num); 342 r = mailpop3_dele(pop3, num);
343 switch (r) { 343 switch (r) {
344 case MAILPOP3_ERROR_BAD_STATE: 344 case MAILPOP3_ERROR_BAD_STATE:
345 return MAIL_ERROR_BAD_STATE; 345 return MAIL_ERROR_BAD_STATE;
346 346
347 case MAILPOP3_ERROR_NO_SUCH_MESSAGE: 347 case MAILPOP3_ERROR_NO_SUCH_MESSAGE:
348 return MAIL_ERROR_MSG_NOT_FOUND; 348 return MAIL_ERROR_MSG_NOT_FOUND;
349 349
350 case MAILPOP3_ERROR_STREAM: 350 case MAILPOP3_ERROR_STREAM:
351 return MAIL_ERROR_STREAM; 351 return MAIL_ERROR_STREAM;
352 352
353 case MAILPOP3_NO_ERROR: 353 case MAILPOP3_NO_ERROR:
354 return MAIL_NO_ERROR; 354 return MAIL_NO_ERROR;
355 355
356 default: 356 default:
357 return MAIL_ERROR_REMOVE; 357 return MAIL_ERROR_REMOVE;
358 } 358 }
359} 359}
360 360
361static int pop3driver_get_messages_list(mailsession * session, 361static int pop3driver_get_messages_list(mailsession * session,
362 struct mailmessage_list ** result) 362 struct mailmessage_list ** result)
363{ 363{
364 mailpop3 * pop3; 364 mailpop3 * pop3;
365 365
366 pop3 = get_pop3_session(session); 366 pop3 = get_pop3_session(session);
367 367
368 return pop3_get_messages_list(pop3, session, 368 return pop3_get_messages_list(pop3, session,
369 pop3_message_driver, result); 369 pop3_message_driver, result);
370} 370}