text stringlengths 0 357 |
|---|
#define MOZ_HOSTNAME 10 |
#define MOZ_PORT 11 |
#define MOZ_USERNAME 12 |
#define MOZ_SOCKETTYPE 13 |
int tag_config; |
} moz_autoconfigure_t; |
static char* read_autoconf_file(dc_context_t* context, const char* url) |
{ |
char* filecontent = NULL; |
dc_log_info(context, 0, "Testing %s ...", url); |
filecontent = (char*)context->cb(context, DC_EVENT_HTTP_GET, (uintptr_t)url, 0); |
if (filecontent==NULL || filecontent[0]==0) { |
free(filecontent); |
dc_log_info(context, 0, "Can't read file."); /* this is not a warning or an error, we're just testing */ |
return NULL; |
} |
return filecontent; |
} |
static void moz_autoconfigure_starttag_cb(void* userdata, const char* tag, char** attr) |
{ |
moz_autoconfigure_t* moz_ac = (moz_autoconfigure_t*)userdata; |
const char* p1 = NULL; |
if (strcmp(tag, "incomingserver")==0) { |
moz_ac->tag_server = (moz_ac->out_imap_set==0 && (p1=dc_attr_find(attr, "type"))!=NULL && strcasecmp(p1, "imap")==0)? MOZ_SERVER_IMAP : 0; |
moz_ac->tag_config = 0; |
} |
else if (strcmp(tag, "outgoingserver")==0) { |
moz_ac->tag_server = moz_ac->out_smtp_set==0? MOZ_SERVER_SMTP : 0; |
moz_ac->tag_config = 0; |
} |
else if (strcmp(tag, "hostname")==0) { |
moz_ac->tag_config = MOZ_HOSTNAME; |
} |
else if (strcmp(tag, "port")==0 ) { |
moz_ac->tag_config = MOZ_PORT; |
} |
else if (strcmp(tag, "sockettype")==0) { |
moz_ac->tag_config = MOZ_SOCKETTYPE; |
} |
else if (strcmp(tag, "username")==0) { |
moz_ac->tag_config = MOZ_USERNAME; |
} |
} |
static void moz_autoconfigure_text_cb(void* userdata, const char* text, int len) |
{ |
moz_autoconfigure_t* moz_ac = (moz_autoconfigure_t*)userdata; |
char* val = dc_strdup(text); |
dc_trim(val); |
dc_str_replace(&val, "%EMAILADDRESS%", moz_ac->in->addr); |
dc_str_replace(&val, "%EMAILLOCALPART%", moz_ac->in_emaillocalpart); |
dc_str_replace(&val, "%EMAILDOMAIN%", moz_ac->in_emaildomain); |
if (moz_ac->tag_server==MOZ_SERVER_IMAP) |
{ |
switch (moz_ac->tag_config) { |
case MOZ_HOSTNAME: |
free(moz_ac->out->mail_server); |
moz_ac->out->mail_server = val; |
val = NULL; |
break; |
case MOZ_PORT: |
moz_ac->out->mail_port = atoi(val); |
break; |
case MOZ_USERNAME: |
free(moz_ac->out->mail_user); |
moz_ac->out->mail_user = val; |
val = NULL; |
break; |
case MOZ_SOCKETTYPE: |
if (strcasecmp(val, "ssl")==0) { moz_ac->out->server_flags |=DC_LP_IMAP_SOCKET_SSL; } |
if (strcasecmp(val, "starttls")==0) { moz_ac->out->server_flags |=DC_LP_IMAP_SOCKET_STARTTLS; } |
if (strcasecmp(val, "plain")==0) { moz_ac->out->server_flags |=DC_LP_IMAP_SOCKET_PLAIN; } |
break; |
} |
} |
else if (moz_ac->tag_server==MOZ_SERVER_SMTP) |
{ |
switch (moz_ac->tag_config) { |
case MOZ_HOSTNAME: |
free(moz_ac->out->send_server); |
moz_ac->out->send_server = val; |
val = NULL; |
break; |
case MOZ_PORT: |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.