mirror of
https://github.com/chatmail/core.git
synced 2026-05-17 05:46:30 +03:00
Add mail_security and send_security fields to LoginParam
This commit is contained in:
@@ -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_FLAGS as i32);
|
||||||
param.server_flags |= DC_LP_AUTH_NORMAL as i32
|
param.server_flags |= DC_LP_AUTH_NORMAL as i32
|
||||||
}
|
}
|
||||||
if !dc_exactly_one_bit_set(
|
if param.mail_security == 0 {
|
||||||
param.server_flags & DC_LP_IMAP_SOCKET_FLAGS as i32,
|
param.mail_security = if param.send_port == 143 {
|
||||||
) {
|
2 // StartTLS
|
||||||
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
|
|
||||||
} else {
|
} else {
|
||||||
DC_LP_IMAP_SOCKET_SSL as i32
|
1 // SSL/TLS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !dc_exactly_one_bit_set(
|
if param.send_security == 0 {
|
||||||
param.server_flags & (DC_LP_SMTP_SOCKET_FLAGS as i32),
|
param.send_security = match param.send_port {
|
||||||
) {
|
587 => 2, // StartTLS
|
||||||
param.server_flags &= !(DC_LP_SMTP_SOCKET_FLAGS as i32);
|
25 => 3, // Plain
|
||||||
param.server_flags |= if param.send_port == 587 {
|
_ => 1, // SSL/TLS
|
||||||
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
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* do we have a complete configuration? */
|
/* do we have a complete configuration? */
|
||||||
|
|||||||
@@ -11,10 +11,12 @@ pub struct LoginParam {
|
|||||||
pub mail_user: String,
|
pub mail_user: String,
|
||||||
pub mail_pw: String,
|
pub mail_pw: String,
|
||||||
pub mail_port: i32,
|
pub mail_port: i32,
|
||||||
|
pub mail_security: i32,
|
||||||
pub send_server: String,
|
pub send_server: String,
|
||||||
pub send_user: String,
|
pub send_user: String,
|
||||||
pub send_pw: String,
|
pub send_pw: String,
|
||||||
pub send_port: i32,
|
pub send_port: i32,
|
||||||
|
pub send_security: i32,
|
||||||
pub server_flags: i32,
|
pub server_flags: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,16 +65,40 @@ impl LoginParam {
|
|||||||
let key = format!("{}server_flags", prefix);
|
let key = format!("{}server_flags", prefix);
|
||||||
let server_flags = sql.get_config_int(context, key).unwrap_or_default();
|
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 {
|
LoginParam {
|
||||||
addr: addr.to_string(),
|
addr: addr.to_string(),
|
||||||
mail_server,
|
mail_server,
|
||||||
mail_user,
|
mail_user,
|
||||||
mail_pw,
|
mail_pw,
|
||||||
mail_port,
|
mail_port,
|
||||||
|
mail_security,
|
||||||
send_server,
|
send_server,
|
||||||
send_user,
|
send_user,
|
||||||
send_pw,
|
send_pw,
|
||||||
send_port,
|
send_port,
|
||||||
|
send_security,
|
||||||
server_flags,
|
server_flags,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user