Imap flow.
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
namespace Wino.Core.Domain.Models.Navigation;
|
||||
|
||||
public enum ProviderSelectionHostMode
|
||||
{
|
||||
Wizard,
|
||||
SettingsAddAccount
|
||||
}
|
||||
|
||||
public sealed class ProviderSelectionNavigationContext
|
||||
{
|
||||
public ProviderSelectionHostMode HostMode { get; init; } = ProviderSelectionHostMode.Wizard;
|
||||
|
||||
public static ProviderSelectionNavigationContext CreateForWizard()
|
||||
=> new()
|
||||
{
|
||||
HostMode = ProviderSelectionHostMode.Wizard
|
||||
};
|
||||
|
||||
public static ProviderSelectionNavigationContext CreateForSettingsAddAccount()
|
||||
=> new()
|
||||
{
|
||||
HostMode = ProviderSelectionHostMode.SettingsAddAccount
|
||||
};
|
||||
|
||||
public bool IsWizardHost => HostMode == ProviderSelectionHostMode.Wizard;
|
||||
}
|
||||
@@ -141,7 +141,9 @@ public static class SettingsNavigationInfoProvider
|
||||
public static SettingsNavigationItemInfo GetInfo(WinoPage pageType, string manageAccountsDescription = "")
|
||||
{
|
||||
var rootPage = GetRootPage(pageType);
|
||||
return GetNavigationItems(manageAccountsDescription).First(item => item.PageType == rootPage);
|
||||
return GetNavigationItems(manageAccountsDescription)
|
||||
.FirstOrDefault(item => item.PageType == rootPage)
|
||||
?? GetNavigationItems(manageAccountsDescription).First(item => item.PageType == WinoPage.SettingOptionsPage);
|
||||
}
|
||||
|
||||
public static string GetPageTitle(WinoPage pageType)
|
||||
@@ -180,6 +182,9 @@ public static class SettingsNavigationInfoProvider
|
||||
WinoPage.MailCategoryManagementPage => WinoPage.ManageAccountsPage,
|
||||
WinoPage.SignatureManagementPage => WinoPage.ManageAccountsPage,
|
||||
WinoPage.ImapCalDavSettingsPage => WinoPage.ManageAccountsPage,
|
||||
WinoPage.ProviderSelectionPage => WinoPage.ManageAccountsPage,
|
||||
WinoPage.SpecialImapCredentialsPage => WinoPage.ManageAccountsPage,
|
||||
WinoPage.AccountSetupProgressPage => WinoPage.ManageAccountsPage,
|
||||
WinoPage.CreateEmailTemplatePage => WinoPage.EmailTemplatesPage,
|
||||
WinoPage.CalendarSettingsPage => WinoPage.CalendarPreferenceSettingsPage,
|
||||
WinoPage.CalendarAccountSettingsPage => WinoPage.CalendarPreferenceSettingsPage,
|
||||
|
||||
@@ -438,7 +438,7 @@
|
||||
"IMAPAdvancedSetupDialog_ValidationAuthMethodRequired": "Authentication method is required",
|
||||
"IMAPAdvancedSetupDialog_ValidationConnectionSecurityRequired": "Connection security type is required",
|
||||
"IMAPAdvancedSetupDialog_ValidationDisplayNameRequired": "Display name is required",
|
||||
"IMAPAdvancedSetupDialog_ValidationEmailInvalid": "Please enter a valid email address",
|
||||
"IMAPAdvancedSetupDialog_ValidationEmailInvalid": "Please enter a valid mailbox address, such as user@example.com or user@localhost",
|
||||
"IMAPAdvancedSetupDialog_ValidationEmailRequired": "Email address is required",
|
||||
"IMAPAdvancedSetupDialog_ValidationErrorTitle": "Please check the following:",
|
||||
"IMAPAdvancedSetupDialog_ValidationIncomingPortInvalid": "Incoming port must be between 1-65535",
|
||||
@@ -485,7 +485,7 @@
|
||||
"IMAPSetupDialog_IMAPSettings": "IMAP Server Settings",
|
||||
"IMAPSetupDialog_SMTPSettings": "SMTP Server Settings",
|
||||
"IMAPSetupDialog_MailAddress": "Email address",
|
||||
"IMAPSetupDialog_MailAddressPlaceholder": "someone@example.com",
|
||||
"IMAPSetupDialog_MailAddressPlaceholder": "someone@example.com or user@localhost",
|
||||
"IMAPSetupDialog_OutgoingMailServer": "Outgoing (SMTP) mail server",
|
||||
"IMAPSetupDialog_OutgoingMailServerPassword": "Outgoing server password",
|
||||
"IMAPSetupDialog_OutgoingMailServerPort": "Port",
|
||||
@@ -502,7 +502,7 @@
|
||||
"ImapCalDavSettingsPage_TitleEdit": "Edit IMAP and Calendar Settings",
|
||||
"ImapCalDavSettingsPage_Subtitle": "Configure IMAP/SMTP and optional calendar synchronization for this account.",
|
||||
"ImapCalDavSettingsPage_BasicSectionTitle": "Basic setup",
|
||||
"ImapCalDavSettingsPage_BasicSectionDescription": "Enter your identity and credentials. Wino can try to detect server settings automatically.",
|
||||
"ImapCalDavSettingsPage_BasicSectionDescription": "Enter your identity and credentials. Wino supports manual addresses such as user@localhost and can try to detect server settings automatically.",
|
||||
"ImapCalDavSettingsPage_BasicTab": "Basic",
|
||||
"ImapCalDavSettingsPage_EnableCalendarSupport": "Enable calendar support",
|
||||
"ImapCalDavSettingsPage_AutoDiscoverButton": "Autodiscover mail settings",
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
using System;
|
||||
using System.Net.Mail;
|
||||
|
||||
namespace Wino.Core.Domain.Validation;
|
||||
|
||||
public static class MailAccountAddressValidator
|
||||
{
|
||||
public static bool IsValid(string address)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(address))
|
||||
return false;
|
||||
|
||||
var trimmedAddress = address.Trim();
|
||||
|
||||
if (trimmedAddress.Contains('\r') || trimmedAddress.Contains('\n'))
|
||||
return false;
|
||||
|
||||
try
|
||||
{
|
||||
var parsedAddress = new MailAddress(trimmedAddress);
|
||||
return parsedAddress.Address.Equals(trimmedAddress, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool TryGetDomain(string address, out string domain)
|
||||
{
|
||||
domain = string.Empty;
|
||||
|
||||
if (!IsValid(address))
|
||||
return false;
|
||||
|
||||
var trimmedAddress = address.Trim();
|
||||
var separatorIndex = trimmedAddress.LastIndexOf('@');
|
||||
|
||||
if (separatorIndex <= 0 || separatorIndex >= trimmedAddress.Length - 1)
|
||||
return false;
|
||||
|
||||
domain = trimmedAddress[(separatorIndex + 1)..];
|
||||
return !string.IsNullOrWhiteSpace(domain);
|
||||
}
|
||||
|
||||
public static bool IsImplicitlyResolvableHost(string host)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(host))
|
||||
return false;
|
||||
|
||||
var normalizedHost = host.Trim().TrimEnd('.');
|
||||
if (string.IsNullOrWhiteSpace(normalizedHost))
|
||||
return false;
|
||||
|
||||
if (normalizedHost.Equals("localhost", StringComparison.OrdinalIgnoreCase))
|
||||
return true;
|
||||
|
||||
var hostType = Uri.CheckHostName(normalizedHost);
|
||||
if (hostType is UriHostNameType.IPv4 or UriHostNameType.IPv6)
|
||||
return true;
|
||||
|
||||
return normalizedHost.IndexOf('.') < 0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user