using System; using System.Collections.ObjectModel; using System.Security.Cryptography.X509Certificates; using SQLite; using Wino.Core.Domain; using Wino.Core.Domain.Enums; namespace Wino.Core.Domain.Entities.Mail; public class RemoteAccountAlias { /// /// Display address of the alias. /// public string AliasAddress { get; set; } /// /// Address to be included in Reply-To header when alias is used for sending messages. /// public string ReplyToAddress { get; set; } /// /// Whether this alias is the primary alias for the account. /// public bool IsPrimary { get; set; } /// /// Whether the alias is verified by the server. /// Only Gmail aliases are verified for now. /// Non-verified alias messages might be rejected by SMTP server. /// public bool IsVerified { get; set; } /// /// Whether this alias is the root alias for the account. /// Root alias means the first alias that was created for the account. /// It can't be deleted or changed. /// public bool IsRootAlias { get; set; } /// /// Optional sender name for the alias. /// Falls back to account's sender name if not set when preparing messages. /// Used for Gmail only. /// public string AliasSenderName { get; set; } /// /// Whether the alias was entered by the user or discovered from the provider. /// public AliasSource Source { get; set; } = AliasSource.Manual; /// /// Represents Wino's confidence that the alias can be used for sending. /// public AliasSendCapability SendCapability { get; set; } = AliasSendCapability.Unknown; } public class MailAccountAlias : RemoteAccountAlias { /// /// Unique Id for the alias. /// [PrimaryKey] public Guid Id { get; set; } /// /// Account id that this alias is attached to. /// public Guid AccountId { get; set; } /// /// Root aliases can't be deleted. /// public bool CanDelete => !IsRootAlias; public string SelectedSigningCertificateThumbprint { get; set; } public bool IsSmimeEncryptionEnabled { get; set; } [Ignore] public X509Certificate2 SelectedSigningCertificate { get; set; } [Ignore] public ObservableCollection Certificates { get; set; } = []; [Ignore] public bool IsCapabilityConfirmed => SendCapability == AliasSendCapability.Confirmed; [Ignore] public bool IsCapabilityUnknown => SendCapability == AliasSendCapability.Unknown; [Ignore] public bool IsCapabilityDenied => SendCapability == AliasSendCapability.Denied; [Ignore] public string CapabilityDisplayName => SendCapability switch { AliasSendCapability.Confirmed => Translator.AccountAlias_Status_Confirmed, AliasSendCapability.Denied => Translator.AccountAlias_Status_Denied, _ => Translator.AccountAlias_Status_Unknown }; [Ignore] public string SourceDisplayName => Source switch { AliasSource.ProviderDiscovered => Translator.AccountAlias_Source_ProviderDiscovered, _ => Translator.AccountAlias_Source_Manual }; }