text
stringlengths
0
357
char* at = strchr(param->mail_user, '@');
if (at) { *at = 0; }
at = strchr(param->send_user, '@');
if (at) { *at = 0; }
}
imap_connected_here = 1;
PROGRESS(800)
/* try to connect to SMTP - if we did not got an autoconfig, the first try was SSL-465 and we do a second try with STARTTLS-587 */
if (!dc_smtp_connect(context->smtp, param)) {
if (param_autoconfig) {
goto cleanup;
}
PROGRESS(850)
param->server_flags &= ~DC_LP_SMTP_SOCKET_FLAGS;
param->server_flags |= DC_LP_SMTP_SOCKET_STARTTLS;
param->send_port = TYPICAL_SMTP_STARTTLS_PORT;
{ char* r = dc_loginparam_get_readable(param); dc_log_info(context, 0, "Trying: %s", r); free(r); }
if (!dc_smtp_connect(context->smtp, param)) {
PROGRESS(860)
param->server_flags &= ~DC_LP_SMTP_SOCKET_FLAGS;
param->server_flags |= DC_LP_SMTP_SOCKET_STARTTLS;
param->send_port = TYPICAL_SMTP_PLAIN_PORT;
{ char* r = dc_loginparam_get_readable(param); dc_log_info(context, 0, "Trying: %s", r); free(r); }
if (!dc_smtp_connect(context->smtp, param)) {
goto cleanup;
}
}
}
smtp_connected_here = 1;
PROGRESS(900)
int flags =
( dc_sqlite3_get_config_int(context->sql, "mvbox_watch", DC_MVBOX_WATCH_DEFAULT)
|| dc_sqlite3_get_config_int(context->sql, "mvbox_move", DC_MVBOX_MOVE_DEFAULT) ) ? DC_CREATE_MVBOX : 0;
dc_configure_folders(context, context->inbox, flags);
PROGRESS(910);
/* configuration success - write back the configured parameters with the "configured_" prefix; also write the "configured"-flag */
dc_loginparam_write(param, context->sql, "configured_" /*the trailing underscore is correct*/);
dc_sqlite3_set_config_int(context->sql, "configured", 1);
PROGRESS(920)
// we generate the keypair just now - we could also postpone this until the first message is sent, however,
// this may result in a unexpected and annoying delay when the user sends his very first message
// (~30 seconds on a Moto G4 play) and might looks as if message sending is always that slow.
dc_ensure_secret_key_exists(context);
success = 1;
dc_log_info(context, 0, "Configure completed.");
PROGRESS(940)
cleanup:
if (imap_connected_here) {
dc_imap_disconnect(context->inbox);
}
if (smtp_connected_here) {
dc_smtp_disconnect(context->smtp);
}
dc_loginparam_unref(param);
dc_loginparam_unref(param_autoconfig);
free(param_addr_urlencoded);
if (ongoing_allocated_here) {
dc_free_ongoing(context);
}
free(mvbox_folder);
context->cb(context, DC_EVENT_CONFIGURE_PROGRESS, success? 1000 : 0, 0);
}
/**
* Configure a context.
* For this purpose, the function creates a job
* that is executed in the IMAP-thread then;
* this requires to call dc_perform_imap_jobs() regularly.
* If the context is already configured,
* this function will try to change the configuration.
*
* - Before you call this function,
* you must set at least `addr` and `mail_pw` using dc_set_config().
*
* - Use `mail_user` to use a different user name than `addr`
* and `send_pw` to use a different password for the SMTP server.
*
* - If _no_ more options are specified,