imap-thread.h (5787B)
1 /* 2 * Claws Mail -- a GTK based, lightweight, and fast e-mail client 3 * Copyright (C) 2005-2023 the Claws Mail team and DINH Viet Hoa 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 3 of the License, or 8 * (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program. If not, see <http://www.gnu.org/licenses/>. 17 * 18 */ 19 20 #ifndef IMAP_THREAD_H 21 22 #define IMAP_THREAD_H 23 24 #include <libetpan/libetpan.h> 25 #include "folder.h" 26 27 typedef enum 28 { 29 IMAP_FLAG_SEEN = 1 << 0, 30 IMAP_FLAG_ANSWERED = 1 << 1, 31 IMAP_FLAG_FLAGGED = 1 << 2, 32 IMAP_FLAG_DELETED = 1 << 3, 33 IMAP_FLAG_DRAFT = 1 << 4, 34 IMAP_FLAG_FORWARDED = 1 << 5, 35 IMAP_FLAG_SPAM = 1 << 6, 36 IMAP_FLAG_HAM = 1 << 7 37 } IMAPFlags; 38 39 void imap_main_set_timeout(int sec); 40 void imap_main_init(gboolean skip_ssl_cert_check); 41 void imap_main_done(gboolean have_connectivity); 42 43 void imap_init(Folder * folder); 44 void imap_done(Folder * folder); 45 46 int imap_threaded_connect(Folder * folder, const char * server, int port); 47 int imap_threaded_connect_ssl(Folder * folder, const char * server, int port); 48 int imap_threaded_capability(Folder *folder, struct mailimap_capability_data ** caps); 49 50 int imap_threaded_connect_cmd(Folder * folder, const char * command, 51 const char * server, int port); 52 void imap_threaded_disconnect(Folder * folder); 53 54 int imap_threaded_list(Folder * folder, const char * base, 55 const char * wildcard, 56 clist ** p_result); 57 int imap_threaded_lsub(Folder * folder, const char * base, 58 const char * wildcard, 59 clist ** p_result); 60 int imap_threaded_login(Folder * folder, 61 const char * login, const char * password, 62 const char * type); 63 int imap_threaded_status(Folder * folder, const char * mb, 64 struct mailimap_mailbox_data_status ** data_status, 65 guint mask); 66 int imap_threaded_close(Folder * folder); 67 68 int imap_threaded_noop(Folder * folder, unsigned int * p_exists, 69 unsigned int *p_recent, 70 unsigned int *p_expunge, 71 unsigned int *p_unseen, 72 unsigned int *p_uidnext, 73 unsigned int *p_uidval); 74 int imap_threaded_starttls(Folder * folder, const gchar *host, int port); 75 int imap_threaded_create(Folder * folder, const char * mb); 76 int imap_threaded_rename(Folder * folder, 77 const char * mb, const char * new_name); 78 int imap_threaded_delete(Folder * folder, const char * mb); 79 int imap_threaded_select(Folder * folder, const char * mb, 80 gint * exists, gint * recent, gint * unseen, 81 guint32 * uid_validity, gint * can_create_flags, 82 GSList **ok_flags); 83 int imap_threaded_examine(Folder * folder, const char * mb, 84 gint * exists, gint * recent, gint * unseen, 85 guint32 * uid_validity); 86 int imap_threaded_subscribe(Folder * folder, const char * mb, 87 gboolean subscribe); 88 89 enum { 90 IMAP_SEARCH_TYPE_SIMPLE, 91 IMAP_SEARCH_TYPE_SEEN, 92 IMAP_SEARCH_TYPE_UNSEEN, 93 IMAP_SEARCH_TYPE_ANSWERED, 94 IMAP_SEARCH_TYPE_FLAGGED, 95 IMAP_SEARCH_TYPE_DELETED, 96 IMAP_SEARCH_TYPE_FORWARDED, 97 IMAP_SEARCH_TYPE_SPAM, 98 99 IMAP_SEARCH_TYPE_KEYED, 100 }; 101 102 typedef struct mailimap_search_key IMAPSearchKey; 103 104 enum { 105 IMAP_SEARCH_CRITERIA_ALL, 106 IMAP_SEARCH_CRITERIA_READ, 107 IMAP_SEARCH_CRITERIA_UNREAD, 108 IMAP_SEARCH_CRITERIA_NEW, 109 IMAP_SEARCH_CRITERIA_MARKED, 110 IMAP_SEARCH_CRITERIA_DELETED, 111 IMAP_SEARCH_CRITERIA_REPLIED, 112 IMAP_SEARCH_CRITERIA_TAG, 113 IMAP_SEARCH_CRITERIA_SUBJECT, 114 IMAP_SEARCH_CRITERIA_FROM, 115 IMAP_SEARCH_CRITERIA_TO, 116 IMAP_SEARCH_CRITERIA_CC, 117 IMAP_SEARCH_CRITERIA_AGE_GREATER, 118 IMAP_SEARCH_CRITERIA_AGE_LOWER, 119 IMAP_SEARCH_CRITERIA_BODY, 120 IMAP_SEARCH_CRITERIA_MESSAGE, 121 IMAP_SEARCH_CRITERIA_HEADER, 122 IMAP_SEARCH_CRITERIA_SIZE_GREATER, 123 IMAP_SEARCH_CRITERIA_SIZE_SMALLER, 124 }; 125 126 IMAPSearchKey* imap_search_new(gint criteria, 127 const gchar *header, 128 const gchar *expr, 129 int value); 130 IMAPSearchKey* imap_search_not(IMAPSearchKey* key); 131 IMAPSearchKey* imap_search_or(IMAPSearchKey* l, IMAPSearchKey* r); 132 IMAPSearchKey* imap_search_and(IMAPSearchKey* l, IMAPSearchKey* r); 133 void imap_search_free(IMAPSearchKey* search); 134 135 int imap_threaded_search(Folder * folder, int search_type, IMAPSearchKey* key, 136 const char *charset, struct mailimap_set * set, clist ** result); 137 138 int imap_threaded_fetch_uid(Folder * folder, uint32_t first_index, 139 carray ** result); 140 141 void imap_fetch_uid_list_free(carray * uid_list); 142 143 int imap_threaded_fetch_uid_flags(Folder * folder, uint32_t first_index, 144 carray ** fetch_result); 145 146 void imap_fetch_uid_flags_list_free(carray * uid_flags_list); 147 148 int imap_threaded_fetch_content(Folder * folder, uint32_t msg_index, 149 int with_body, 150 const char * filename); 151 152 struct imap_fetch_env_info { 153 uint32_t uid; 154 char * headers; 155 uint32_t size; 156 int flags; 157 }; 158 159 int imap_threaded_fetch_env(Folder * folder, struct mailimap_set * set, 160 carray ** p_env_list); 161 162 void imap_fetch_env_free(carray * env_list); 163 164 int imap_threaded_append(Folder * folder, const char * mailbox, 165 const char * filename, 166 struct mailimap_flag_list * flag_list, 167 int *uid); 168 169 int imap_threaded_expunge(Folder * folder); 170 171 int imap_threaded_copy(Folder * folder, struct mailimap_set * set, 172 const char * mb, struct mailimap_set **source, 173 struct mailimap_set **dest); 174 175 int imap_threaded_store(Folder * folder, struct mailimap_set * set, 176 struct mailimap_store_att_flags * store_att_flags); 177 178 void imap_threaded_cancel(Folder * folder); 179 180 #endif