1
0
Fork 0
mirror of https://github.com/deltachat/deltachat-core.git synced 2025-10-05 10:39:27 +02:00

Improve configuration suggestions.

This commit is contained in:
B. Petersen 2016-10-06 23:48:56 +02:00
parent 83473be637
commit 2de751c0a0
3 changed files with 32 additions and 21 deletions

View file

@ -88,6 +88,24 @@ void mrloginparam_empty(mrloginparam_t* ths)
}
void mrloginparam_read(mrloginparam_t* ths, mrsqlite3_t* sql)
{
mrloginparam_empty(ths);
ths->m_addr = mrsqlite3_get_config_ (sql, "addr", NULL);
ths->m_mail_server = mrsqlite3_get_config_ (sql, "mail_server", NULL);
ths->m_mail_port = mrsqlite3_get_config_int_(sql, "mail_port", 0);
ths->m_mail_user = mrsqlite3_get_config_ (sql, "mail_user", NULL);
ths->m_mail_pw = mrsqlite3_get_config_ (sql, "mail_pw", NULL);
ths->m_send_server = mrsqlite3_get_config_ (sql, "send_server", NULL);
ths->m_send_port = mrsqlite3_get_config_int_(sql, "send_port", 0);
ths->m_send_user = mrsqlite3_get_config_ (sql, "send_user", NULL);
ths->m_send_pw = mrsqlite3_get_config_ (sql, "send_pw", NULL);
}
void mrloginparam_complete(mrloginparam_t* ths)
{
char* adr_server;
@ -102,7 +120,8 @@ void mrloginparam_complete(mrloginparam_t* ths)
}
adr_server++;
/* set servers, ports etc. for well-known and frequently used services
/* set servers, ports etc. for well-known and frequently used services.
Remember, unset values are NULL, not the empty string!
TODO: We should add values for gmx.net, web.de etc. */
if( strcmp(adr_server, "gmail.com")==0
|| strcmp(adr_server, "googlemail.com")==0 )
@ -118,14 +137,18 @@ void mrloginparam_complete(mrloginparam_t* ths)
if( ths->m_send_port == 0 ) { ths->m_send_port = 465; } /* SSMTP - difference between 465 and 587: http://stackoverflow.com/questions/15796530/what-is-the-difference-between-ports-465-and-587 */
if( ths->m_send_user == NULL ) { ths->m_send_user = safe_strdup(ths->m_addr); }
if( ths->m_send_pw == NULL && ths->m_mail_pw ) { ths->m_send_pw = safe_strdup(ths->m_mail_pw); }
return;
}
/* generic approach */
if( ths->m_mail_port == 0 ) { ths->m_mail_port = 993; }
if( ths->m_mail_user == NULL ) { ths->m_mail_user = safe_strdup(ths->m_addr); }
if( ths->m_send_port == 0 ) { ths->m_send_port = 465; }
if( ths->m_send_user == NULL ) { ths->m_send_user = safe_strdup(ths->m_addr); }
if( ths->m_send_pw == NULL && ths->m_mail_pw ) { ths->m_send_pw = safe_strdup(ths->m_mail_pw); }
/* generic approach, just duplicate the servers and use the standard ports.
works fine eg. for all-inkl */
if( ths->m_mail_port == 0 ) { ths->m_mail_port = 993; }
if( ths->m_mail_user == NULL ) { ths->m_mail_user = safe_strdup(ths->m_addr); }
if( ths->m_send_server == NULL && ths->m_mail_server ) { ths->m_send_server = safe_strdup(ths->m_mail_server); }
if( ths->m_send_port == 0 ) { ths->m_send_port = 465; }
if( ths->m_send_user == NULL && ths->m_mail_user ) { ths->m_send_user = safe_strdup(ths->m_mail_user); }
if( ths->m_send_pw == NULL && ths->m_mail_pw ) { ths->m_send_pw = safe_strdup(ths->m_mail_pw); }
}

View file

@ -52,8 +52,8 @@ typedef struct mrloginparam_t
mrloginparam_t* mrloginparam_new ();
void mrloginparam_unref (mrloginparam_t*);
void mrloginparam_empty (mrloginparam_t*); /* clears all data and frees its memory. All pointers are NULL after this function is called. */
void mrloginparam_read (mrloginparam_t*, mrsqlite3_t*);
void mrloginparam_complete (mrloginparam_t*); /* tries to set missing parameters from at least m_addr and m_mail_pw */

View file

@ -289,19 +289,7 @@ int mrmailbox_connect(mrmailbox_t* ths)
/* read parameter, unset parameters are still NULL afterwards */
mrsqlite3_lock(ths->m_sql); /* CAVE: No return until unlock! */
mrloginparam_empty(ths->m_loginParam);
ths->m_loginParam->m_addr = mrsqlite3_get_config_ (ths->m_sql, "addr", NULL);
ths->m_loginParam->m_mail_server = mrsqlite3_get_config_ (ths->m_sql, "mail_server", NULL);
ths->m_loginParam->m_mail_port = mrsqlite3_get_config_int_(ths->m_sql, "mail_port", 0);
ths->m_loginParam->m_mail_user = mrsqlite3_get_config_ (ths->m_sql, "mail_user", NULL);
ths->m_loginParam->m_mail_pw = mrsqlite3_get_config_ (ths->m_sql, "mail_pw", NULL);
ths->m_loginParam->m_send_server = mrsqlite3_get_config_ (ths->m_sql, "send_server", NULL);
ths->m_loginParam->m_send_port = mrsqlite3_get_config_int_(ths->m_sql, "send_port", 0);
ths->m_loginParam->m_send_user = mrsqlite3_get_config_ (ths->m_sql, "send_user", NULL);
ths->m_loginParam->m_send_pw = mrsqlite3_get_config_ (ths->m_sql, "send_pw", NULL);
mrloginparam_read(ths->m_loginParam, ths->m_sql);
mrsqlite3_unlock(ths->m_sql); /* /CAVE: No return until unlock! */