text stringlengths 0 357 |
|---|
int success = 0; |
if (imap==NULL || lp==NULL |
|| lp->mail_server==NULL || lp->mail_user==NULL || lp->mail_pw==NULL) { |
return 0; |
} |
if (imap->connected) { |
success = 1; |
goto cleanup; |
} |
imap->addr = dc_strdup(lp->addr); |
imap->imap_server = dc_strdup(lp->mail_server); |
imap->imap_port = lp->mail_port; |
imap->imap_user = dc_strdup(lp->mail_user); |
imap->imap_pw = dc_strdup(lp->mail_pw); |
imap->server_flags = lp->server_flags; |
if (!setup_handle_if_needed(imap)) { |
goto cleanup; |
} |
/* we set the following flags here and not in setup_handle_if_needed() as they must not change during connection */ |
imap->can_idle = mailimap_has_idle(imap->etpan); |
imap->has_xlist = mailimap_has_xlist(imap->etpan); |
#ifdef __APPLE__ |
imap->can_idle = 0; // HACK to force iOS not to work IMAP-IDLE which does not work for now, see also (*) |
#endif |
if (!imap->skip_log_capabilities |
&& imap->etpan->imap_connection_info && imap->etpan->imap_connection_info->imap_capability) |
{ |
/* just log the whole capabilities list (the mailimap_has_*() function also use this list, so this is a good overview on problems) */ |
imap->skip_log_capabilities = 1; |
dc_strbuilder_t capinfostr; |
dc_strbuilder_init(&capinfostr, 0); |
clist* list = imap->etpan->imap_connection_info->imap_capability->cap_list; |
if (list) { |
clistiter* cur; |
for(cur = clist_begin(list) ; cur!=NULL ; cur = clist_next(cur)) { |
struct mailimap_capability * cap = clist_content(cur); |
if (cap && cap->cap_type==MAILIMAP_CAPABILITY_NAME) { |
dc_strbuilder_cat(&capinfostr, " "); |
dc_strbuilder_cat(&capinfostr, cap->cap_data.cap_name); |
} |
} |
} |
dc_log_info(imap->context, 0, "IMAP-capabilities:%s", capinfostr.buf); |
free(capinfostr.buf); |
} |
imap->connected = 1; |
success = 1; |
cleanup: |
if (success==0) { |
unsetup_handle(imap); |
free_connect_param(imap); |
} |
return success; |
} |
void dc_imap_disconnect(dc_imap_t* imap) |
{ |
if (imap==NULL) { |
return; |
} |
if (imap->connected) |
{ |
unsetup_handle(imap); |
free_connect_param(imap); |
imap->connected = 0; |
} |
} |
int dc_imap_is_connected(const dc_imap_t* imap) |
{ |
return (imap && imap->connected); |
} |
void dc_imap_set_watch_folder(dc_imap_t* imap, const char* watch_folder) |
{ |
if (imap==NULL || watch_folder==NULL) { |
return; |
} |
free(imap->watch_folder); |
imap->watch_folder = dc_strdup(watch_folder); |
} |
/******************************************************************************* |
* Main interface |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.