diff --git a/deltachat-ffi/deltachat.h b/deltachat-ffi/deltachat.h index 0666149cd4..1ab070ce53 100644 --- a/deltachat-ffi/deltachat.h +++ b/deltachat-ffi/deltachat.h @@ -406,7 +406,6 @@ char* dc_get_blobdir (const dc_context_t* context); * - `proxy_enabled` = Proxy enabled. Disabled by default. * - `proxy_url` = Proxy URL. May contain multiple URLs separated by newline, but only the first one is used. * - `imap_certificate_checks` = how to check IMAP certificates, one of the @ref DC_CERTCK flags, defaults to #DC_CERTCK_AUTO (0) - * - `smtp_certificate_checks` = deprecated option, should be set to the same value as `imap_certificate_checks` but ignored by the new core * - `displayname` = Own name to use when sending messages. MUAs are allowed to spread this way e.g. using CC, defaults to empty * - `selfstatus` = Own status to display, e.g. in e-mail footers, defaults to empty * - `selfavatar` = File containing avatar. Will immediately be copied to the @@ -5802,7 +5801,7 @@ int64_t dc_lot_get_timestamp (const dc_lot_t* lot); * These constants configure TLS certificate checks for IMAP and SMTP connections. * * These constants are set via dc_set_config() - * using keys "imap_certificate_checks" and "smtp_certificate_checks". + * using the key "imap_certificate_checks". * * @addtogroup DC_CERTCK * @{ diff --git a/deltachat-jsonrpc/src/lib.rs b/deltachat-jsonrpc/src/lib.rs index 389206f467..3034c0f8b4 100644 --- a/deltachat-jsonrpc/src/lib.rs +++ b/deltachat-jsonrpc/src/lib.rs @@ -85,7 +85,7 @@ mod tests { assert_eq!(result, response.to_owned()); } { - let request = r#"{"jsonrpc":"2.0","method":"batch_set_config","id":2,"params":[1,{"addr":"","mail_user":"","mail_pw":"","mail_server":"","mail_port":"","mail_security":"","imap_certificate_checks":"","send_user":"","send_pw":"","send_server":"","send_port":"","send_security":"","smtp_certificate_checks":""}]}"#; + let request = r#"{"jsonrpc":"2.0","method":"batch_set_config","id":2,"params":[1,{"addr":"","mail_user":"","mail_pw":"","mail_server":"","mail_port":"","mail_security":"","imap_certificate_checks":"","send_user":"","send_pw":"","send_server":"","send_port":"","send_security":""}]}"#; let response = r#"{"jsonrpc":"2.0","id":2,"result":null}"#; session.handle_incoming(request).await; let result = receiver.recv().await?; diff --git a/python/src/deltachat/testplugin.py b/python/src/deltachat/testplugin.py index aecd333ff6..e2010d44af 100644 --- a/python/src/deltachat/testplugin.py +++ b/python/src/deltachat/testplugin.py @@ -427,7 +427,6 @@ def get_next_liveconfig(self): if self.pytestconfig.getoption("--strict-tls"): # Enable strict certificate checks for online accounts configdict["imap_certificate_checks"] = str(const.DC_CERTCK_STRICT) - configdict["smtp_certificate_checks"] = str(const.DC_CERTCK_STRICT) assert "addr" in configdict and "mail_pw" in configdict return configdict @@ -499,7 +498,6 @@ def new_online_configuring_account(self, cloned_from=None, cache=False, **kwargs "addr": cloned_from.get_config("addr"), "mail_pw": cloned_from.get_config("mail_pw"), "imap_certificate_checks": cloned_from.get_config("imap_certificate_checks"), - "smtp_certificate_checks": cloned_from.get_config("smtp_certificate_checks"), } configdict.update(kwargs) ac = self._get_cached_account(addr=configdict["addr"]) if cache else None diff --git a/src/config.rs b/src/config.rs index 1fa11d49ec..d79d96d918 100644 --- a/src/config.rs +++ b/src/config.rs @@ -43,50 +43,84 @@ use crate::tools::get_abs_path; )] #[strum(serialize_all = "snake_case")] pub enum Config { + /// Deprecated(2025-04). + /// Use ConfiguredAddr, EnteredLoginParam, or add_transport{from_qr}()/list_transports() instead. + /// /// Email address, used in the `From:` field. Addr, + /// Deprecated(2025-04). + /// Use EnteredLoginParam, and add_transport{from_qr}()/list_transports() instead. + /// /// IMAP server hostname. MailServer, + /// Deprecated(2025-04). + /// Use EnteredLoginParam, and add_transport{from_qr}()/list_transports() instead. + /// /// IMAP server username. MailUser, + /// Deprecated(2025-04). + /// Use EnteredLoginParam, and add_transport{from_qr}()/list_transports() instead. + /// /// IMAP server password. MailPw, + /// Deprecated(2025-04). + /// Use EnteredLoginParam, and add_transport{from_qr}()/list_transports() instead. + /// /// IMAP server port. MailPort, + /// Deprecated(2025-04). + /// Use EnteredLoginParam, and add_transport{from_qr}()/list_transports() instead. + /// /// IMAP server security (e.g. TLS, STARTTLS). MailSecurity, + /// Deprecated(2025-04). + /// Use EnteredLoginParam, and add_transport{from_qr}()/list_transports() instead. + /// /// How to check TLS certificates. /// /// "IMAP" in the name is for compatibility, /// this actually applies to both IMAP and SMTP connections. ImapCertificateChecks, + /// Deprecated(2025-04). + /// Use EnteredLoginParam, and add_transport{from_qr}()/list_transports() instead. + /// /// SMTP server hostname. SendServer, + /// Deprecated(2025-04). + /// Use EnteredLoginParam, and add_transport{from_qr}()/list_transports() instead. + /// /// SMTP server username. SendUser, + /// Deprecated(2025-04). + /// Use EnteredLoginParam, and add_transport{from_qr}()/list_transports() instead. + /// /// SMTP server password. SendPw, + /// Deprecated(2025-04). + /// Use EnteredLoginParam, and add_transport{from_qr}()/list_transports() instead. + /// /// SMTP server port. SendPort, + /// Deprecated(2025-04). + /// Use EnteredLoginParam, and add_transport{from_qr}()/list_transports() instead. + /// /// SMTP server security (e.g. TLS, STARTTLS). SendSecurity, - /// Deprecated option for backwards compatibility. + /// Deprecated(2025-04). + /// Use EnteredLoginParam, and add_transport{from_qr}()/list_transports() instead. /// - /// Certificate checks for SMTP are actually controlled by `imap_certificate_checks` config. - SmtpCertificateChecks, - /// Whether to use OAuth 2. /// /// Historically contained other bitflags, which are now deprecated. @@ -215,32 +249,47 @@ pub enum Config { /// The primary email address. Also see `SecondaryAddrs`. ConfiguredAddr, + /// Deprecated(2025-04). + /// Use ConfiguredLoginParam and add_transport{from_qr}()/list_transports() instead. + /// /// List of configured IMAP servers as a JSON array. ConfiguredImapServers, + /// Deprecated(2025-04). + /// Use ConfiguredLoginParam and add_transport{from_qr}()/list_transports() instead. + /// /// Configured IMAP server hostname. /// /// This is replaced by `configured_imap_servers` for new configurations. ConfiguredMailServer, - /// Configured IMAP server port. + /// Deprecated(2025-04). + /// Use ConfiguredLoginParam and add_transport{from_qr}()/list_transports() instead. /// - /// This is replaced by `configured_imap_servers` for new configurations. + /// Configured IMAP server port. ConfiguredMailPort, - /// Configured IMAP server security (e.g. TLS, STARTTLS). + /// Deprecated(2025-04). + /// Use ConfiguredLoginParam and add_transport{from_qr}()/list_transports() instead. /// - /// This is replaced by `configured_imap_servers` for new configurations. + /// Configured IMAP server security (e.g. TLS, STARTTLS). ConfiguredMailSecurity, - /// Configured IMAP server username. + /// Deprecated(2025-04). + /// Use ConfiguredLoginParam and add_transport{from_qr}()/list_transports() instead. /// - /// This is set if user has configured username manually. + /// Configured IMAP server username. ConfiguredMailUser, + /// Deprecated(2025-04). + /// Use ConfiguredLoginParam and add_transport{from_qr}()/list_transports() instead. + /// /// Configured IMAP server password. ConfiguredMailPw, + /// Deprecated(2025-04). + /// Use ConfiguredLoginParam and add_transport{from_qr}()/list_transports() instead. + /// /// Configured TLS certificate checks. /// This option is saved on successful configuration /// and should not be modified manually. @@ -249,29 +298,47 @@ pub enum Config { /// but has "IMAP" in the name for backwards compatibility. ConfiguredImapCertificateChecks, + /// Deprecated(2025-04). + /// Use ConfiguredLoginParam and add_transport{from_qr}()/list_transports() instead. + /// /// List of configured SMTP servers as a JSON array. ConfiguredSmtpServers, + /// Deprecated(2025-04). + /// Use ConfiguredLoginParam and add_transport{from_qr}()/list_transports() instead. + /// /// Configured SMTP server hostname. /// /// This is replaced by `configured_smtp_servers` for new configurations. ConfiguredSendServer, + /// Deprecated(2025-04). + /// Use ConfiguredLoginParam and add_transport{from_qr}()/list_transports() instead. + /// /// Configured SMTP server port. /// /// This is replaced by `configured_smtp_servers` for new configurations. ConfiguredSendPort, + /// Deprecated(2025-04). + /// Use ConfiguredLoginParam and add_transport{from_qr}()/list_transports() instead. + /// /// Configured SMTP server security (e.g. TLS, STARTTLS). /// /// This is replaced by `configured_smtp_servers` for new configurations. ConfiguredSendSecurity, + /// Deprecated(2025-04). + /// Use ConfiguredLoginParam and add_transport{from_qr}()/list_transports() instead. + /// /// Configured SMTP server username. /// /// This is set if user has configured username manually. ConfiguredSendUser, + /// Deprecated(2025-04). + /// Use ConfiguredLoginParam and add_transport{from_qr}()/list_transports() instead. + /// /// Configured SMTP server password. ConfiguredSendPw, @@ -280,6 +347,9 @@ pub enum Config { /// ConfiguredImapCertificateChecks is actually used. ConfiguredSmtpCertificateChecks, + /// Deprecated(2025-04). + /// Use ConfiguredLoginParam and add_transport{from_qr}()/list_transports() instead. + /// /// Whether OAuth 2 is used with configured provider. ConfiguredServerFlags, @@ -301,6 +371,9 @@ pub enum Config { /// ID of the configured provider from the provider database. ConfiguredProvider, + /// Deprecated(2025-04). + /// Use [`Context::is_configured()`] instead. + /// /// True if account is configured. Configured, diff --git a/src/configure.rs b/src/configure.rs index 195fdff035..850d0c094a 100644 --- a/src/configure.rs +++ b/src/configure.rs @@ -71,7 +71,7 @@ impl Context { /// Deprecated since 2025-02; use `add_transport_from_qr()` /// or `add_transport()` instead. pub async fn configure(&self) -> Result<()> { - let param = EnteredLoginParam::load(self).await?; + let param = EnteredLoginParam::load_legacy(self).await?; self.add_transport_inner(¶m).await } @@ -147,7 +147,7 @@ impl Context { progress!(self, 0, Some(error_msg.clone())); bail!(error_msg); } else { - param.save(self).await?; + param.save_legacy(self).await?; progress!(self, 1000); } diff --git a/src/context.rs b/src/context.rs index 35d7c0a42c..140680da7d 100644 --- a/src/context.rs +++ b/src/context.rs @@ -28,7 +28,7 @@ use crate::download::DownloadState; use crate::events::{Event, EventEmitter, EventType, Events}; use crate::imap::{FolderMeaning, Imap, ServerMetadata}; use crate::key::{load_self_public_key, load_self_secret_key, DcKey as _}; -use crate::login_param::{ConfiguredLoginParam, EnteredLoginParam}; +use crate::login_param::ConfiguredLoginParam; use crate::message::{self, Message, MessageState, MsgId}; use crate::param::{Param, Params}; use crate::peer_channels::Iroh; @@ -774,7 +774,7 @@ impl Context { /// Returns information about the context as key-value pairs. pub async fn get_info(&self) -> Result> { let unset = "0"; - let l = EnteredLoginParam::load(self).await?; + let l = self.list_transports().await?; let l2 = ConfiguredLoginParam::load(self) .await? .map_or_else(|| "Not configured".to_string(), |param| param.to_string()); @@ -867,7 +867,13 @@ impl Context { ); res.insert("is_configured", is_configured.to_string()); res.insert("proxy_enabled", proxy_enabled.to_string()); - res.insert("entered_account_settings", l.to_string()); + res.insert( + "entered_account_settings", + l.iter() + .map(|l| l.to_string()) + .collect::>() + .join("; "), + ); res.insert("used_account_settings", l2); if let Some(server_id) = &*self.server_id.read().await { diff --git a/src/context/context_tests.rs b/src/context/context_tests.rs index 111311aca2..92edd2f55c 100644 --- a/src/context/context_tests.rs +++ b/src/context/context_tests.rs @@ -285,7 +285,6 @@ async fn test_get_info_completeness() { "send_security", "server_flags", "skip_start_messages", - "smtp_certificate_checks", "proxy_url", // May contain passwords, don't leak it to the logs. "socks5_enabled", // SOCKS5 options are deprecated. "socks5_host", @@ -313,6 +312,22 @@ async fn test_get_info_completeness() { } } +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +async fn test_get_info_configured() -> Result<()> { + let alice = TestContext::new_alice().await; + let info = alice.get_info().await?; + let entered_account_settings = &info["entered_account_settings"]; + assert_eq!(entered_account_settings, "unset imap:unset:0:unset:0:Automatic:AUTH_NORMAL smtp:unset:0:unset:0:Automatic:AUTH_NORMAL cert_automatic"); + + let used_account_settings = &info["used_account_settings"]; + assert_eq!( + used_account_settings, + "alice@example.org imap:[] smtp:[] provider:none cert_automatic" + ); + + Ok(()) +} + #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_search_msgs() -> Result<()> { let alice = TestContext::new_alice().await; diff --git a/src/login_param.rs b/src/login_param.rs index f91ffa59e4..4ef016decd 100644 --- a/src/login_param.rs +++ b/src/login_param.rs @@ -139,7 +139,7 @@ pub struct EnteredLoginParam { impl EnteredLoginParam { /// Loads entered account settings. - pub(crate) async fn load(context: &Context) -> Result { + pub(crate) async fn load_legacy(context: &Context) -> Result { let addr = context .get_config(Config::Addr) .await? @@ -171,8 +171,7 @@ impl EnteredLoginParam { // The setting is named `imap_certificate_checks` // for backwards compatibility, - // but now it is a global setting applied to all protocols, - // while `smtp_certificate_checks` is ignored. + // but now it is a global setting applied to all protocols. let certificate_checks = if let Some(certificate_checks) = context .get_config_parsed::(Config::ImapCertificateChecks) .await? @@ -234,7 +233,7 @@ impl EnteredLoginParam { /// Saves entered account settings, /// so that they can be prefilled if the user wants to configure the server again. - pub(crate) async fn save(&self, context: &Context) -> Result<()> { + pub(crate) async fn save_legacy(&self, context: &Context) -> Result<()> { context.set_config(Config::Addr, Some(&self.addr)).await?; context @@ -924,7 +923,7 @@ mod tests { .await?; t.set_config(Config::MailPw, Some("foobarbaz")).await?; - let param = EnteredLoginParam::load(t).await?; + let param = EnteredLoginParam::load_legacy(t).await?; assert_eq!(param.addr, "alice@example.org"); assert_eq!( param.certificate_checks, @@ -933,13 +932,13 @@ mod tests { t.set_config(Config::ImapCertificateChecks, Some("1")) .await?; - let param = EnteredLoginParam::load(t).await?; + let param = EnteredLoginParam::load_legacy(t).await?; assert_eq!(param.certificate_checks, EnteredCertificateChecks::Strict); // Fail to load invalid settings, but do not panic. t.set_config(Config::ImapCertificateChecks, Some("999")) .await?; - assert!(EnteredLoginParam::load(t).await.is_err()); + assert!(EnteredLoginParam::load_legacy(t).await.is_err()); Ok(()) } @@ -966,7 +965,7 @@ mod tests { certificate_checks: Default::default(), oauth2: false, }; - param.save(&t).await?; + param.save_legacy(&t).await?; assert_eq!( t.get_config(Config::Addr).await?.unwrap(), "alice@example.org" @@ -975,7 +974,7 @@ mod tests { assert_eq!(t.get_config(Config::SendPw).await?, None); assert_eq!(t.get_config_int(Config::SendPort).await?, 2947); - assert_eq!(EnteredLoginParam::load(&t).await?, param); + assert_eq!(EnteredLoginParam::load_legacy(&t).await?, param); Ok(()) } diff --git a/src/qr/dclogin_scheme.rs b/src/qr/dclogin_scheme.rs index c8cece55d7..7d8789fd87 100644 --- a/src/qr/dclogin_scheme.rs +++ b/src/qr/dclogin_scheme.rs @@ -247,9 +247,6 @@ pub(crate) async fn configure_from_login_qr( context .set_config_internal(Config::ImapCertificateChecks, Some(&code.to_string())) .await?; - context - .set_config_internal(Config::SmtpCertificateChecks, Some(&code.to_string())) - .await?; } Ok(()) } diff --git a/src/qr/qr_tests.rs b/src/qr/qr_tests.rs index fa507b1bdc..ff57583f9f 100644 --- a/src/qr/qr_tests.rs +++ b/src/qr/qr_tests.rs @@ -608,13 +608,6 @@ async fn test_decode_and_apply_dclogin_advanced_options() -> Result<()> { ctx.ctx.get_config(Config::SendUser).await?, Some("SendUser".to_owned()) ); - - // `sc` option is actually ignored and `ic` is used instead - // because `smtp_certificate_checks` is deprecated. - assert_eq!( - ctx.ctx.get_config(Config::SmtpCertificateChecks).await?, - Some("1".to_owned()) - ); assert_eq!( ctx.ctx.get_config(Config::SendSecurity).await?, Some("3".to_owned()) // plain diff --git a/src/sql/migrations.rs b/src/sql/migrations.rs index be093db42f..5115b7da6f 100644 --- a/src/sql/migrations.rs +++ b/src/sql/migrations.rs @@ -1190,7 +1190,7 @@ CREATE INDEX gossip_timestamp_index ON gossip_timestamp (chat_id, fingerprint); inc_and_check(&mut migration_version, 131)?; if dbversion < migration_version { - let entered_param = EnteredLoginParam::load(context).await?; + let entered_param = EnteredLoginParam::load_legacy(context).await?; let configured_param = ConfiguredLoginParam::load_legacy(context).await?; sql.execute_migration_transaction(