Compare commits

...

1 Commits

Author SHA1 Message Date
Alexander Krotov
3e09efaf0a Add mail_security and send_security fields to LoginParam 2019-09-29 23:17:21 +03:00
2 changed files with 35 additions and 17 deletions

View File

@@ -296,26 +296,18 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &Context) {
param.server_flags &= !(DC_LP_AUTH_FLAGS as i32);
param.server_flags |= DC_LP_AUTH_NORMAL as i32
}
if !dc_exactly_one_bit_set(
param.server_flags & DC_LP_IMAP_SOCKET_FLAGS as i32,
) {
param.server_flags &= !(DC_LP_IMAP_SOCKET_FLAGS as i32);
param.server_flags |= if param.send_port == 143 {
DC_LP_IMAP_SOCKET_STARTTLS as i32
if param.mail_security == 0 {
param.mail_security = if param.send_port == 143 {
2 // StartTLS
} else {
DC_LP_IMAP_SOCKET_SSL as i32
1 // SSL/TLS
}
}
if !dc_exactly_one_bit_set(
param.server_flags & (DC_LP_SMTP_SOCKET_FLAGS as i32),
) {
param.server_flags &= !(DC_LP_SMTP_SOCKET_FLAGS as i32);
param.server_flags |= if param.send_port == 587 {
DC_LP_SMTP_SOCKET_STARTTLS as i32
} else if param.send_port == 25 {
DC_LP_SMTP_SOCKET_PLAIN as i32
} else {
DC_LP_SMTP_SOCKET_SSL as i32
if param.send_security == 0 {
param.send_security = match param.send_port {
587 => 2, // StartTLS
25 => 3, // Plain
_ => 1, // SSL/TLS
}
}
/* do we have a complete configuration? */

View File

@@ -11,10 +11,12 @@ pub struct LoginParam {
pub mail_user: String,
pub mail_pw: String,
pub mail_port: i32,
pub mail_security: i32,
pub send_server: String,
pub send_user: String,
pub send_pw: String,
pub send_port: i32,
pub send_security: i32,
pub server_flags: i32,
}
@@ -63,16 +65,40 @@ impl LoginParam {
let key = format!("{}server_flags", prefix);
let server_flags = sql.get_config_int(context, key).unwrap_or_default();
let mail_security = match (
server_flags & DC_LP_IMAP_SOCKET_STARTTLS,
server_flags & DC_LP_IMAP_SOCKET_SSL,
server_flags & DC_LP_IMAP_SOCKET_PLAIN,
) {
(1, 0, 0) => 2, // StartTLS
(0, 1, 0) => 1, // SSL/TLS
(0, 0, 1) => 3, // Plain
_ => 0, // Automatic
};
let send_security = match (
server_flags & DC_LP_SMTP_SOCKET_FLAGS,
server_flags & DC_LP_SMTP_SOCKET_SSL,
server_flags & DC_LP_SMTP_SOCKET_PLAIN,
) {
(1, 0, 0) => 2, // StartTLS
(0, 1, 0) => 1, // SSL/TLS
(0, 0, 1) => 3, // Plain
_ => 0, // Automatic
};
LoginParam {
addr: addr.to_string(),
mail_server,
mail_user,
mail_pw,
mail_port,
mail_security,
send_server,
send_user,
send_pw,
send_port,
send_security,
server_flags,
}
}