Skip to content

[After UIs introduced a multi-tranpsort screen] api!: Remove unused config smtp_certificate_checks, deprecate old transport configs #6803

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions deltachat-ffi/deltachat.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In deltachat.h there is mail_pw etc still around. mail_pw is even marked as "always needed".

Copy link
Collaborator Author

@Hocuri Hocuri Jun 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In deltachat.h there is mail_pw etc still around.

mail_pw etc. is still used in order for the UIs to query the entered login params. The UIs will switch to list_transports() when they implement a screen for listing and editing the transports. The reasoning for this is that UIs would have to do work twice, if they have to switch to `list_transports() now, and then later completely rework the account-login options, anyway.

mail_pw is even marked as "always needed".

We could change this, but I don't see what it has to do with the PR here? Though we will likely mark mail_pw etc. as deprecated or remove it in a few months from now, anyways, so, I don't think it's important right now.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mail_pw etc. is still used in order for the UIs to query the entered login params.

Oops, wait, it's long since I opened the PR here, and when opening the PR here, I didn't know that we still want to use mail_pw etc. in the UI. I will mark the PR here as a draft, and revive it when we actually don't need these anymore.

* - `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
Expand Down Expand Up @@ -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
* @{
Expand Down
2 changes: 1 addition & 1 deletion deltachat-jsonrpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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?;
Expand Down
2 changes: 0 additions & 2 deletions python/src/deltachat/testplugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
93 changes: 83 additions & 10 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,50 +43,84 @@ use crate::tools::get_abs_path;
)]
#[strum(serialize_all = "snake_case")]
pub enum Config {
/// Deprecated(2025-04).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably needs to be updated before merging

/// 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.
Expand Down Expand Up @@ -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.
Expand All @@ -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,

Expand All @@ -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,

Expand All @@ -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,

Expand Down
4 changes: 2 additions & 2 deletions src/configure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(&param).await
}
Expand Down Expand Up @@ -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);
}

Expand Down
17 changes: 12 additions & 5 deletions src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -774,8 +774,8 @@ impl Context {
/// Returns information about the context as key-value pairs.
pub async fn get_info(&self) -> Result<BTreeMap<&'static str, String>> {
let unset = "0";
let l = EnteredLoginParam::load(self).await?;
let l2 = ConfiguredLoginParam::load(self)
let entered_account_settings = self.list_transports().await?;
let used_account_settings = ConfiguredLoginParam::load(self)
.await?
.map_or_else(|| "Not configured".to_string(), |param| param.to_string());
let secondary_addrs = self.get_secondary_self_addrs().await?.join(", ");
Expand Down Expand Up @@ -867,8 +867,15 @@ 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("used_account_settings", l2);
res.insert(
"entered_account_settings",
entered_account_settings
.iter()
.map(|l| l.to_string())
.collect::<Vec<_>>()
.join("; "),
);
res.insert("used_account_settings", used_account_settings);

if let Some(server_id) = &*self.server_id.read().await {
res.insert("imap_server_id", format!("{server_id:?}"));
Expand Down
17 changes: 16 additions & 1 deletion src/context/context_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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;
Expand Down
Loading