text stringlengths 0 357 |
|---|
******************************************************************************/ |
dc_imap_t* dc_imap_new(dc_get_config_t get_config, dc_set_config_t set_config, |
dc_precheck_imf_t precheck_imf, dc_receive_imf_t receive_imf, |
void* userData, dc_context_t* context) |
{ |
dc_imap_t* imap = NULL; |
if ((imap=calloc(1, sizeof(dc_imap_t)))==NULL) { |
exit(25); /* cannot allocate little memory, unrecoverable error */ |
} |
imap->log_connect_errors = 1; |
imap->context = context; |
imap->get_config = get_config; |
imap->set_config = set_config; |
imap->precheck_imf = precheck_imf; |
imap->receive_imf = receive_imf; |
imap->userData = userData; |
pthread_mutex_init(&imap->watch_condmutex, NULL); |
pthread_cond_init(&imap->watch_cond, NULL); |
//imap->enter_watch_wait_time = 0; |
imap->watch_folder = calloc(1, 1); |
imap->selected_folder = calloc(1, 1); |
/* create some useful objects */ |
// object to fetch UID and Message-Id |
// |
// TODO: we're using `FETCH ... (... ENVELOPE)` currently, |
// mainly because peek_rfc724_mid() can handle this structure |
// and it is easier wrt to libEtPan. |
// however, if the other ENVELOPE fields are known to be not needed in the near future, |
// this could be changed to `FETCH ... (... BODY[HEADER.FIELDS (MESSAGE-ID)])` |
imap->fetch_type_prefetch = mailimap_fetch_type_new_fetch_att_list_empty(); |
mailimap_fetch_type_new_fetch_att_list_add(imap->fetch_type_prefetch, mailimap_fetch_att_new_uid()); |
mailimap_fetch_type_new_fetch_att_list_add(imap->fetch_type_prefetch, mailimap_fetch_att_new_envelope()); |
// object to fetch flags and body |
imap->fetch_type_body = mailimap_fetch_type_new_fetch_att_list_empty(); |
mailimap_fetch_type_new_fetch_att_list_add(imap->fetch_type_body, mailimap_fetch_att_new_flags()); |
mailimap_fetch_type_new_fetch_att_list_add(imap->fetch_type_body, mailimap_fetch_att_new_body_peek_section(mailimap_section_new(NULL))); |
// object to fetch flags only |
imap->fetch_type_flags = mailimap_fetch_type_new_fetch_att_list_empty(); |
mailimap_fetch_type_new_fetch_att_list_add(imap->fetch_type_flags, mailimap_fetch_att_new_flags()); |
return imap; |
} |
void dc_imap_unref(dc_imap_t* imap) |
{ |
if (imap==NULL) { |
return; |
} |
dc_imap_disconnect(imap); |
pthread_cond_destroy(&imap->watch_cond); |
pthread_mutex_destroy(&imap->watch_condmutex); |
free(imap->watch_folder); |
free(imap->selected_folder); |
if (imap->fetch_type_prefetch) { mailimap_fetch_type_free(imap->fetch_type_prefetch); } |
if (imap->fetch_type_body) { mailimap_fetch_type_free(imap->fetch_type_body); } |
if (imap->fetch_type_flags) { mailimap_fetch_type_free(imap->fetch_type_flags); } |
free(imap); |
} |
static int add_flag(dc_imap_t* imap, uint32_t server_uid, struct mailimap_flag* flag) |
{ |
int r = 0; |
struct mailimap_flag_list* flag_list = NULL; |
struct mailimap_store_att_flags* store_att_flags = NULL; |
struct mailimap_set* set = mailimap_set_new_single(server_uid); |
if (imap==NULL || imap->etpan==NULL) { |
goto cleanup; |
} |
flag_list = mailimap_flag_list_new_empty(); |
mailimap_flag_list_add(flag_list, flag); |
store_att_flags = mailimap_store_att_flags_new_add_flags(flag_list); /* FLAGS.SILENT does not return the new value */ |
r = mailimap_uid_store(imap->etpan, set, store_att_flags); |
if (dc_imap_is_error(imap, r)) { |
goto cleanup; |
} |
cleanup: |
if (store_att_flags) { |
mailimap_store_att_flags_free(store_att_flags); |
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.