2026-10-04 12:26:26 +02:00
|
|
|
using AIStudio.Tools.PluginSystem;
|
|
|
|
|
|
|
|
|
|
namespace AIStudio.Settings.DataModel;
|
|
|
|
|
|
|
|
|
|
public static class MailboxTransportSecurityExtensions
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The port IMAP with TLS from the start usually listens on.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public const int SSL_ON_CONNECT_PORT = 993;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The port IMAP with STARTTLS usually listens on.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public const int STARTTLS_PORT = 143;
|
|
|
|
|
|
|
|
|
|
private static string TB(string fallbackEN) => I18N.I.T(fallbackEN, typeof(MailboxTransportSecurityExtensions).Namespace, nameof(MailboxTransportSecurityExtensions));
|
|
|
|
|
|
2026-11-04 10:46:18 +01:00
|
|
|
extension(MailboxTransportSecurity transportSecurity)
|
2026-10-04 12:26:26 +02:00
|
|
|
{
|
2026-11-04 13:00:56 +01:00
|
|
|
public string Name => transportSecurity switch
|
2026-11-04 10:46:18 +01:00
|
|
|
{
|
|
|
|
|
MailboxTransportSecurity.SSL_ON_CONNECT => TB("TLS from the start (usually port 993)"),
|
|
|
|
|
MailboxTransportSecurity.STARTTLS => TB("STARTTLS (usually port 143)"),
|
|
|
|
|
|
|
|
|
|
_ => TB("Unknown encryption"),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The port the encryption usually comes with.
|
|
|
|
|
/// </summary>
|
2026-11-04 13:00:56 +01:00
|
|
|
/// <value>The port, or null when there is no usual one.</value>
|
|
|
|
|
public int? UsualPort => transportSecurity switch
|
2026-11-04 10:46:18 +01:00
|
|
|
{
|
|
|
|
|
MailboxTransportSecurity.SSL_ON_CONNECT => SSL_ON_CONNECT_PORT,
|
|
|
|
|
MailboxTransportSecurity.STARTTLS => STARTTLS_PORT,
|
|
|
|
|
|
|
|
|
|
_ => null,
|
|
|
|
|
};
|
|
|
|
|
}
|
2026-10-04 12:26:26 +02:00
|
|
|
}
|