text stringlengths 0 357 |
|---|
moz_ac->out->send_port = atoi(val); |
break; |
case MOZ_USERNAME: |
free(moz_ac->out->send_user); |
moz_ac->out->send_user = val; |
val = NULL; |
break; |
case MOZ_SOCKETTYPE: |
if (strcasecmp(val, "ssl")==0) { moz_ac->out->server_flags |=DC_LP_SMTP_SOCKET_SSL; } |
if (strcasecmp(val, "starttls")==0) { moz_ac->out->server_flags |=DC_LP_SMTP_SOCKET_STARTTLS; } |
if (strcasecmp(val, "plain")==0) { moz_ac->out->server_flags |=DC_LP_SMTP_SOCKET_PLAIN; } |
break; |
} |
} |
free(val); |
} |
static void moz_autoconfigure_endtag_cb(void* userdata, const char* tag) |
{ |
moz_autoconfigure_t* moz_ac = (moz_autoconfigure_t*)userdata; |
if (strcmp(tag, "incomingserver")==0) { |
moz_ac->tag_server = 0; |
moz_ac->tag_config = 0; |
moz_ac->out_imap_set = 1; |
} |
else if (strcmp(tag, "outgoingserver")==0) { |
moz_ac->tag_server = 0; |
moz_ac->tag_config = 0; |
moz_ac->out_smtp_set = 1; |
} |
else { |
moz_ac->tag_config = 0; |
} |
} |
static dc_loginparam_t* moz_autoconfigure(dc_context_t* context, const char* url, const dc_loginparam_t* param_in) |
{ |
char* xml_raw = NULL; |
moz_autoconfigure_t moz_ac; |
memset(&moz_ac, 0, sizeof(moz_autoconfigure_t)); |
if ((xml_raw=read_autoconf_file(context, url))==NULL) { |
goto cleanup; |
} |
moz_ac.in = param_in; |
moz_ac.in_emaillocalpart = dc_strdup(param_in->addr); char* p = strchr(moz_ac.in_emaillocalpart, '@'); if (p==NULL) { goto cleanup; } *p = 0; |
moz_ac.in_emaildomain = dc_strdup(p+1); |
moz_ac.out = dc_loginparam_new(); |
dc_saxparser_t saxparser; |
dc_saxparser_init (&saxparser, &moz_ac); |
dc_saxparser_set_tag_handler (&saxparser, moz_autoconfigure_starttag_cb, moz_autoconfigure_endtag_cb); |
dc_saxparser_set_text_handler(&saxparser, moz_autoconfigure_text_cb); |
dc_saxparser_parse (&saxparser, xml_raw); |
if (moz_ac.out->mail_server==NULL |
|| moz_ac.out->mail_port ==0 |
|| moz_ac.out->send_server==NULL |
|| moz_ac.out->send_port ==0) |
{ |
{ char* r = dc_loginparam_get_readable(moz_ac.out); dc_log_warning(context, 0, "Bad or incomplete autoconfig: %s", r); free(r); } |
dc_loginparam_unref(moz_ac.out); /* autoconfig failed for the given URL */ |
moz_ac.out = NULL; |
goto cleanup; |
} |
cleanup: |
free(xml_raw); |
free(moz_ac.in_emaildomain); |
free(moz_ac.in_emaillocalpart); |
return moz_ac.out; /* may be NULL */ |
} |
/******************************************************************************* |
* Outlook's Autodiscover |
******************************************************************************/ |
typedef struct outlk_autodiscover_t |
{ |
const dc_loginparam_t* in; |
dc_loginparam_t* out; |
int out_imap_set; |
int out_smtp_set; |
/* file format: https://msdn.microsoft.com/en-us/library/bb204278(v=exchg.80).aspx */ |
#define OUTLK_TYPE 1 |
#define OUTLK_SERVER 2 |
#define OUTLK_PORT 3 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.