static int pop3driver_login(mailsession * session, const char * userid, const char * password) { int r; carray * msg_tab; struct pop3_session_state_data * data; data = get_data(session); switch (data->pop3_auth_type) { case POP3DRIVER_AUTH_TYPE_TRY_APOP: r = mailpop3_login_apop(get_pop3_session(session), userid, password); if (r != MAILPOP3_NO_ERROR) r = mailpop3_login(get_pop3_session(session), userid, password); break; case POP3DRIVER_AUTH_TYPE_APOP: r = mailpop3_login_apop(get_pop3_session(session), userid, password); break; default: case POP3DRIVER_AUTH_TYPE_PLAIN: r = mailpop3_login(get_pop3_session(session), userid, password); break; } if (r != MAILPOP3_NO_ERROR) return pop3driver_pop3_error_to_mail_error(r); r = mailpop3_list(get_pop3_session(session), &msg_tab); return pop3driver_pop3_error_to_mail_error(r); }
static int pop3driver_messages_number(mailsession * session, const char * mb, uint32_t * result) { carray * msg_tab; int r; r = mailpop3_list(get_pop3_session(session), &msg_tab); if (r != MAILPOP3_NO_ERROR) { return pop3driver_pop3_error_to_mail_error(r); } * result = carray_count(msg_tab) - get_pop3_session(session)->pop3_deleted_count; return MAIL_NO_ERROR; }
int mailpop3_get_msg_info(mailpop3 * f, unsigned int indx, struct mailpop3_msg_info ** result) { carray * tab; struct mailpop3_msg_info * info; int r; r = mailpop3_list(f, &tab); if (r != MAILPOP3_NO_ERROR) return r; if (tab == NULL) return MAILPOP3_ERROR_BAD_STATE; info = mailpop3_msg_info_tab_find_msg(tab, indx); if (info == NULL) return MAILPOP3_ERROR_NO_SUCH_MESSAGE; * result = info; return MAILPOP3_NO_ERROR; }
static int pop3driver_cached_status_folder(mailsession * session, const char * mb, uint32_t * result_messages, uint32_t * result_recent, uint32_t * result_unseen) { int res; struct pop3_cached_session_state_data * cached_data; char filename_flags[PATH_MAX]; struct mail_cache_db * cache_db_flags; MMAPString * mmapstr; unsigned int i; int r; carray * msg_tab; mailpop3 * pop3; uint32_t recent; uint32_t unseen; recent = 0; unseen = 0; pop3 = get_pop3_session(session); cached_data = get_cached_data(session); pop3_flags_store_process(cached_data->pop3_flags_directory, cached_data->pop3_flags_store); snprintf(filename_flags, PATH_MAX, "%s/%s", cached_data->pop3_flags_directory, FLAGS_NAME); r = mail_cache_db_open_lock(filename_flags, &cache_db_flags); if (r < 0) { res = MAIL_ERROR_FILE; goto err; } mmapstr = mmap_string_new(""); if (mmapstr == NULL) { res = MAIL_ERROR_MEMORY; goto close_db_flags; } r = mailpop3_list(pop3, &msg_tab); if (r != MAILPOP3_NO_ERROR) { res = pop3driver_pop3_error_to_mail_error(r); goto free_mmapstr; } for(i = 0 ; i < carray_count(msg_tab) ; i++) { struct mailpop3_msg_info * pop3_info; struct mail_flags * flags; pop3_info = carray_get(msg_tab, i); if (pop3_info == NULL) continue; if (pop3_info->msg_deleted) continue; r = pop3driver_get_cached_flags(cache_db_flags, mmapstr, session, pop3_info->msg_index, &flags); if (r != MAIL_NO_ERROR) { recent ++; unseen ++; continue; } if ((flags->fl_flags & MAIL_FLAG_NEW) != 0) { recent ++; } if ((flags->fl_flags & MAIL_FLAG_SEEN) == 0) { unseen ++; } mail_flags_free(flags); } mmap_string_free(mmapstr); mail_cache_db_close_unlock(filename_flags, cache_db_flags); * result_messages = carray_count(msg_tab) - pop3->pop3_deleted_count; * result_recent = recent; * result_unseen = unseen; return MAIL_NO_ERROR; free_mmapstr: mmap_string_free(mmapstr); close_db_flags: mail_cache_db_close_unlock(filename_flags, cache_db_flags); err: return res; }