Initial commit.
This commit is contained in:
268
Wino.Mail/Views/ImapSetup/AdvancedImapSetupPage.xaml
Normal file
268
Wino.Mail/Views/ImapSetup/AdvancedImapSetupPage.xaml
Normal file
@@ -0,0 +1,268 @@
|
||||
<Page
|
||||
x:Class="Wino.Views.ImapSetup.AdvancedImapSetupPage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:domain="using:Wino.Core.Domain"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
d:RequestedTheme="Dark"
|
||||
xmlns:helpers="using:Wino.Helpers"
|
||||
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
|
||||
d:Background="Black"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Grid RowSpacing="4">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<ScrollViewer x:Name="MainScrollviewer" Padding="{StaticResource ImapSetupDialogSubPagePadding}">
|
||||
<StackPanel Spacing="12" Padding="0,0,16,0">
|
||||
<TextBlock
|
||||
d:Text="Advanced IMAP / SMTP Configuration"
|
||||
Text="{x:Bind domain:Translator.IMAPSetupDialog_Title}"
|
||||
Margin="1,0,0,0"
|
||||
Style="{StaticResource TitleTextBlockStyle}" />
|
||||
|
||||
<TextBox
|
||||
d:Header="Mail"
|
||||
Header="{x:Bind domain:Translator.IMAPSetupDialog_MailAddress}"
|
||||
PlaceholderText="{x:Bind domain:Translator.IMAPSetupDialog_MailAddressPlaceholder}"
|
||||
x:Name="AddressBox" />
|
||||
|
||||
<TextBox
|
||||
d:Header="Display Name"
|
||||
Header="{x:Bind domain:Translator.IMAPSetupDialog_DisplayName}"
|
||||
PlaceholderText="{x:Bind domain:Translator.IMAPSetupDialog_DisplayNamePlaceholder}"
|
||||
x:Name="DisplayNameBox" />
|
||||
|
||||
<CheckBox Content="{x:Bind domain:Translator.IMAPSetupDialog_UseSameConfig}" IsChecked="{x:Bind UseSameCredentialsForSending, Mode=TwoWay}" />
|
||||
|
||||
<muxc:TabView
|
||||
d:SelectedIndex="0"
|
||||
IsAddTabButtonVisible="False"
|
||||
CanReorderTabs="False"
|
||||
TabWidthMode="Equal">
|
||||
<muxc:TabView.TabStripFooter>
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
|
||||
<Button>
|
||||
<Button.Content>
|
||||
<StackPanel Orientation="Horizontal" Spacing="4">
|
||||
<FontIcon
|
||||
FontFamily="Segoe Fluent Icons"
|
||||
Glyph=""
|
||||
FontSize="13" />
|
||||
<!--<TextBlock
|
||||
Text="Help "
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="12" />-->
|
||||
</StackPanel>
|
||||
</Button.Content>
|
||||
<Button.Flyout>
|
||||
<Flyout />
|
||||
</Button.Flyout>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</muxc:TabView.TabStripFooter>
|
||||
<muxc:TabViewItem Header="IMAP Settings" IsClosable="False">
|
||||
<!-- IMAP -->
|
||||
<StackPanel Padding="12" Spacing="10">
|
||||
<!-- Server + Port -->
|
||||
<Grid ColumnSpacing="6">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBox
|
||||
d:Header="Incoming Server"
|
||||
TextChanged="IncomingServerChanged"
|
||||
PlaceholderText="eg. imap.gmail.com"
|
||||
Header="{x:Bind domain:Translator.IMAPSetupDialog_IncomingMailServer}"
|
||||
x:Name="IncomingServerBox" />
|
||||
|
||||
<TextBox
|
||||
d:Header="Port"
|
||||
PlaceholderText="993"
|
||||
Header="{x:Bind domain:Translator.IMAPSetupDialog_IncomingMailServerPort}"
|
||||
x:Name="IncomingServerPortBox"
|
||||
Grid.Column="1" />
|
||||
</Grid>
|
||||
|
||||
<!-- Username + Password -->
|
||||
<StackPanel Spacing="6">
|
||||
<TextBox
|
||||
d:Header="Username"
|
||||
TextChanged="IncomingUsernameChanged"
|
||||
Header="{x:Bind domain:Translator.IMAPSetupDialog_Username}"
|
||||
PlaceholderText="{x:Bind domain:Translator.IMAPSetupDialog_UsernamePlaceholder}"
|
||||
x:Name="UsernameBox" />
|
||||
|
||||
<PasswordBox
|
||||
PasswordChanged="IncomingPasswordChanged"
|
||||
d:Header="Password"
|
||||
Header="{x:Bind domain:Translator.IMAPSetupDialog_Password}"
|
||||
x:Name="PasswordBox" />
|
||||
</StackPanel>
|
||||
|
||||
<!-- Security and Authentication -->
|
||||
<Grid ColumnSpacing="12">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<!-- Security -->
|
||||
<StackPanel Spacing="6">
|
||||
<TextBlock
|
||||
d:Text="Connection security"
|
||||
Text="{x:Bind domain:Translator.ImapAdvancedSetupDialog_ConnectionSecurity}"
|
||||
HorizontalAlignment="Center" />
|
||||
<ComboBox
|
||||
x:Name="IncomingConnectionSecurity"
|
||||
SelectedIndex="0"
|
||||
HorizontalAlignment="Stretch"
|
||||
ItemsSource="{x:Bind AvailableConnectionSecurities}"
|
||||
DisplayMemberPath="DisplayName" />
|
||||
</StackPanel>
|
||||
|
||||
<!-- Authentication -->
|
||||
<StackPanel Grid.Column="1" Spacing="6">
|
||||
<TextBlock
|
||||
d:Text="Authentication method"
|
||||
Text="{x:Bind domain:Translator.ImapAdvancedSetupDialog_AuthenticationMethod}"
|
||||
HorizontalAlignment="Center" />
|
||||
<ComboBox
|
||||
x:Name="IncomingAuthenticationMethod"
|
||||
SelectedIndex="0"
|
||||
HorizontalAlignment="Stretch"
|
||||
ItemsSource="{x:Bind AvailableAuthenticationMethods}"
|
||||
DisplayMemberPath="DisplayName" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
</StackPanel>
|
||||
</muxc:TabViewItem>
|
||||
<muxc:TabViewItem IsClosable="False" Header="SMTP Settings">
|
||||
<!-- SMTP -->
|
||||
<StackPanel Padding="12" Spacing="10">
|
||||
<!-- Server + Port -->
|
||||
<Grid ColumnSpacing="6">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBox
|
||||
d:Header="Outgoing Server"
|
||||
TextChanged="OutgoingServerChanged"
|
||||
PlaceholderText="eg. smtp.gmail.com"
|
||||
Header="{x:Bind domain:Translator.IMAPSetupDialog_OutgoingMailServer}"
|
||||
x:Name="OutgoingServerBox" />
|
||||
|
||||
<TextBox
|
||||
d:Header="Port"
|
||||
Header="{x:Bind domain:Translator.IMAPSetupDialog_OutgoingMailServerPort}"
|
||||
x:Name="OutgoingServerPort"
|
||||
Grid.Column="1" />
|
||||
</Grid>
|
||||
|
||||
<!-- Username + Password -->
|
||||
<StackPanel x:Name="OutgoingAuthenticationPanel" Spacing="6">
|
||||
<TextBox
|
||||
x:Name="OutgoingUsernameBox"
|
||||
d:Header="UserName"
|
||||
IsEnabled="{x:Bind helpers:XamlHelpers.ReverseBoolConverter(UseSameCredentialsForSending), Mode=OneWay}"
|
||||
Header="{x:Bind domain:Translator.IMAPSetupDialog_OutgoingMailServerUsername}" />
|
||||
<PasswordBox
|
||||
x:Name="OutgoingPasswordBox"
|
||||
IsEnabled="{x:Bind helpers:XamlHelpers.ReverseBoolConverter(UseSameCredentialsForSending), Mode=OneWay}"
|
||||
d:Header="Password"
|
||||
Header="{x:Bind domain:Translator.IMAPSetupDialog_OutgoingMailServerPassword}" />
|
||||
</StackPanel>
|
||||
|
||||
<!-- Security and Authentication -->
|
||||
<Grid ColumnSpacing="12">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<!-- Security -->
|
||||
<StackPanel Spacing="6">
|
||||
<TextBlock Text="{x:Bind domain:Translator.ImapAdvancedSetupDialog_ConnectionSecurity}" HorizontalAlignment="Center" />
|
||||
<ComboBox
|
||||
x:Name="OutgoingConnectionSecurity"
|
||||
SelectedIndex="0"
|
||||
HorizontalAlignment="Stretch"
|
||||
ItemsSource="{x:Bind AvailableConnectionSecurities}"
|
||||
DisplayMemberPath="DisplayName" />
|
||||
</StackPanel>
|
||||
|
||||
<!-- Authentication -->
|
||||
<StackPanel Grid.Column="1" Spacing="6">
|
||||
<TextBlock Text="{x:Bind domain:Translator.ImapAdvancedSetupDialog_AuthenticationMethod}" HorizontalAlignment="Center" />
|
||||
<ComboBox
|
||||
x:Name="OutgoingAuthenticationMethod"
|
||||
SelectedIndex="0"
|
||||
HorizontalAlignment="Stretch"
|
||||
ItemsSource="{x:Bind AvailableAuthenticationMethods}"
|
||||
DisplayMemberPath="DisplayName" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</muxc:TabViewItem>
|
||||
<muxc:TabViewItem IsClosable="False" Header="Proxy">
|
||||
<!-- Proxy -->
|
||||
<StackPanel Spacing="10" Padding="12">
|
||||
<TextBlock Text="Define your optional proxy server for the connection if your mail server requires it. This is optional." />
|
||||
<Grid ColumnSpacing="12">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBox Header="Proxy server" x:Name="ProxyServerBox" />
|
||||
<muxc:NumberBox
|
||||
Header="Port"
|
||||
Grid.Column="1"
|
||||
x:Name="ProxyServerPortBox" />
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</muxc:TabViewItem>
|
||||
</muxc:TabView>
|
||||
|
||||
<TextBlock
|
||||
x:Name="ErrorMessage"
|
||||
TextWrapping="Wrap"
|
||||
Foreground="{ThemeResource InfoBarWarningSeverityIconBackground}" />
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
|
||||
<!-- Buttons -->
|
||||
<Grid
|
||||
Padding="{StaticResource ImapSetupDialogSubPagePadding}"
|
||||
Background="{ThemeResource ContentDialogBackground}"
|
||||
Grid.Row="1"
|
||||
VerticalAlignment="Bottom"
|
||||
ColumnSpacing="6">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Button
|
||||
d:Content="Cancel"
|
||||
Content="{x:Bind domain:Translator.Buttons_Cancel}"
|
||||
HorizontalAlignment="Stretch"
|
||||
Click="CancelClicked" />
|
||||
|
||||
<Button
|
||||
d:Content="Sign In"
|
||||
Content="{x:Bind domain:Translator.Buttons_SignIn}"
|
||||
Click="SignInClicked"
|
||||
Style="{ThemeResource AccentButtonStyle}"
|
||||
Grid.Column="1"
|
||||
HorizontalAlignment="Stretch" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Page>
|
||||
220
Wino.Mail/Views/ImapSetup/AdvancedImapSetupPage.xaml.cs
Normal file
220
Wino.Mail/Views/ImapSetup/AdvancedImapSetupPage.xaml.cs
Normal file
@@ -0,0 +1,220 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
using Wino.Core.Domain;
|
||||
using Wino.Core.Domain.Entities;
|
||||
using Wino.Core.Domain.Models.Accounts;
|
||||
using Wino.Core.Domain.Models.AutoDiscovery;
|
||||
using Wino.Core.Messages.Mails;
|
||||
using Wino.Extensions;
|
||||
|
||||
|
||||
namespace Wino.Views.ImapSetup
|
||||
{
|
||||
public sealed partial class AdvancedImapSetupPage : Page
|
||||
{
|
||||
public List<ImapAuthenticationMethodModel> AvailableAuthenticationMethods { get; } = new List<ImapAuthenticationMethodModel>()
|
||||
{
|
||||
new ImapAuthenticationMethodModel(Core.Domain.Enums.ImapAuthenticationMethod.Auto, Translator.ImapAuthenticationMethod_Auto),
|
||||
new ImapAuthenticationMethodModel(Core.Domain.Enums.ImapAuthenticationMethod.None, Translator.ImapAuthenticationMethod_None),
|
||||
new ImapAuthenticationMethodModel(Core.Domain.Enums.ImapAuthenticationMethod.NormalPassword, Translator.ImapAuthenticationMethod_Plain),
|
||||
new ImapAuthenticationMethodModel(Core.Domain.Enums.ImapAuthenticationMethod.EncryptedPassword, Translator.ImapAuthenticationMethod_EncryptedPassword),
|
||||
new ImapAuthenticationMethodModel(Core.Domain.Enums.ImapAuthenticationMethod.Ntlm, Translator.ImapAuthenticationMethod_Ntlm),
|
||||
new ImapAuthenticationMethodModel(Core.Domain.Enums.ImapAuthenticationMethod.CramMd5, Translator.ImapAuthenticationMethod_CramMD5),
|
||||
new ImapAuthenticationMethodModel(Core.Domain.Enums.ImapAuthenticationMethod.DigestMd5, Translator.ImapAuthenticationMethod_DigestMD5)
|
||||
};
|
||||
|
||||
public List<ImapConnectionSecurityModel> AvailableConnectionSecurities { get; set; } = new List<ImapConnectionSecurityModel>()
|
||||
{
|
||||
new ImapConnectionSecurityModel(Core.Domain.Enums.ImapConnectionSecurity.Auto, Translator.ImapConnectionSecurity_Auto),
|
||||
new ImapConnectionSecurityModel(Core.Domain.Enums.ImapConnectionSecurity.SslTls, Translator.ImapConnectionSecurity_SslTls),
|
||||
new ImapConnectionSecurityModel(Core.Domain.Enums.ImapConnectionSecurity.StartTls, Translator.ImapConnectionSecurity_StartTls),
|
||||
new ImapConnectionSecurityModel(Core.Domain.Enums.ImapConnectionSecurity.None, Translator.ImapConnectionSecurity_None)
|
||||
};
|
||||
|
||||
public bool UseSameCredentialsForSending
|
||||
{
|
||||
get { return (bool)GetValue(UseSameCredentialsForSendingProperty); }
|
||||
set { SetValue(UseSameCredentialsForSendingProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty UseSameCredentialsForSendingProperty = DependencyProperty.Register(nameof(UseSameCredentialsForSending), typeof(bool), typeof(AdvancedImapSetupPage), new PropertyMetadata(true, OnUseSameCredentialsForSendingChanged));
|
||||
|
||||
public AdvancedImapSetupPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
NavigationCacheMode = NavigationCacheMode.Enabled;
|
||||
}
|
||||
|
||||
private static void OnUseSameCredentialsForSendingChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
|
||||
{
|
||||
if (obj is AdvancedImapSetupPage page)
|
||||
{
|
||||
page.UpdateOutgoingAuthenticationPanel();
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateOutgoingAuthenticationPanel()
|
||||
{
|
||||
if (UseSameCredentialsForSending)
|
||||
{
|
||||
OutgoingUsernameBox.Text = UsernameBox.Text;
|
||||
OutgoingPasswordBox.Password = PasswordBox.Password;
|
||||
}
|
||||
else
|
||||
{
|
||||
OutgoingUsernameBox.Text = string.Empty;
|
||||
OutgoingPasswordBox.Password = string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnNavigatedTo(NavigationEventArgs e)
|
||||
{
|
||||
base.OnNavigatedTo(e);
|
||||
|
||||
// Connection is succesfull but error occurred.
|
||||
// Imap and Smptp settings exists here at this point.
|
||||
|
||||
if (e.Parameter is AutoDiscoverySettings preDefinedSettings && preDefinedSettings.UserMinimalSettings != null)
|
||||
{
|
||||
// TODO: Auto discovery settings adjustments.
|
||||
|
||||
UsernameBox.Text = preDefinedSettings.UserMinimalSettings.Email;
|
||||
DisplayNameBox.Text = preDefinedSettings.UserMinimalSettings.DisplayName;
|
||||
PasswordBox.Password = preDefinedSettings.UserMinimalSettings.Password;
|
||||
|
||||
var serverInfo = preDefinedSettings.ToServerInformation();
|
||||
|
||||
IncomingServerBox.Text = serverInfo.IncomingServer;
|
||||
IncomingServerPortBox.Text = serverInfo.IncomingServerPort;
|
||||
|
||||
|
||||
OutgoingPasswordBox.Password = serverInfo.OutgoingServerPassword;
|
||||
|
||||
OutgoingServerBox.Text = serverInfo.OutgoingServer;
|
||||
OutgoingServerPort.Text = serverInfo.OutgoingServerPort;
|
||||
|
||||
OutgoingUsernameBox.Text = serverInfo.OutgoingServerUsername;
|
||||
|
||||
UseSameCredentialsForSending = OutgoingUsernameBox.Text == UsernameBox.Text;
|
||||
}
|
||||
else if (e.Parameter is AutoDiscoveryMinimalSettings autoDiscoveryMinimalSettings)
|
||||
{
|
||||
// Auto discovery failed. Only minimal settings are passed.
|
||||
|
||||
UsernameBox.Text = autoDiscoveryMinimalSettings.Email;
|
||||
DisplayNameBox.Text = autoDiscoveryMinimalSettings.DisplayName;
|
||||
PasswordBox.Password = autoDiscoveryMinimalSettings.Password;
|
||||
}
|
||||
else if (e.Parameter is AutoDiscoveryConnectionTestFailedPackage failedPackage)
|
||||
{
|
||||
ErrorMessage.Text = failedPackage.Error.Message;
|
||||
|
||||
MainScrollviewer.ScrollToElement(ErrorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
private void CancelClicked(object sender, RoutedEventArgs e) => WeakReferenceMessenger.Default.Send(new ImapSetupDismissRequested(null));
|
||||
|
||||
private string GetServerWithoutPort(string server)
|
||||
{
|
||||
var splitted = server.Split(':');
|
||||
|
||||
if (splitted.Length > 1)
|
||||
{
|
||||
return splitted[0];
|
||||
}
|
||||
|
||||
return server;
|
||||
}
|
||||
|
||||
private void SignInClicked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ErrorMessage.Text = string.Empty;
|
||||
|
||||
var info = new CustomServerInformation()
|
||||
{
|
||||
IncomingServer = GetServerWithoutPort(IncomingServerBox.Text),
|
||||
Id = Guid.NewGuid(),
|
||||
|
||||
IncomingServerPassword = PasswordBox.Password,
|
||||
IncomingServerType = Core.Domain.Enums.CustomIncomingServerType.IMAP4,
|
||||
IncomingServerUsername = UsernameBox.Text,
|
||||
IncomingAuthenticationMethod = (IncomingAuthenticationMethod.SelectedItem as ImapAuthenticationMethodModel).ImapAuthenticationMethod,
|
||||
IncomingServerSocketOption = (IncomingConnectionSecurity.SelectedItem as ImapConnectionSecurityModel).ImapConnectionSecurity,
|
||||
IncomingServerPort = IncomingServerPortBox.Text,
|
||||
|
||||
OutgoingServer = GetServerWithoutPort(OutgoingServerBox.Text),
|
||||
OutgoingServerPort = OutgoingServerPort.Text,
|
||||
OutgoingServerPassword = OutgoingPasswordBox.Password,
|
||||
OutgoingAuthenticationMethod = (OutgoingAuthenticationMethod.SelectedItem as ImapAuthenticationMethodModel).ImapAuthenticationMethod,
|
||||
OutgoingServerSocketOption = (OutgoingConnectionSecurity.SelectedItem as ImapConnectionSecurityModel).ImapConnectionSecurity,
|
||||
OutgoingServerUsername = OutgoingUsernameBox.Text,
|
||||
|
||||
ProxyServer = ProxyServerBox.Text,
|
||||
ProxyServerPort = ProxyServerPortBox.Text,
|
||||
Address = AddressBox.Text,
|
||||
DisplayName = DisplayNameBox.Text
|
||||
};
|
||||
|
||||
if (UseSameCredentialsForSending)
|
||||
{
|
||||
info.OutgoingServerUsername = info.IncomingServerUsername;
|
||||
info.OutgoingServerPassword = info.IncomingServerPassword;
|
||||
}
|
||||
else
|
||||
{
|
||||
info.OutgoingServerUsername = OutgoingUsernameBox.Text;
|
||||
info.OutgoingServerPassword = OutgoingPasswordBox.Password;
|
||||
}
|
||||
|
||||
WeakReferenceMessenger.Default.Send(new ImapSetupNavigationRequested(typeof(TestingImapConnectionPage), info));
|
||||
}
|
||||
|
||||
private void IncomingServerChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
if (sender is TextBox senderTextBox)
|
||||
{
|
||||
var splitted = senderTextBox.Text.Split(':');
|
||||
|
||||
if (splitted.Length > 1)
|
||||
{
|
||||
IncomingServerPortBox.Text = splitted[splitted.Length - 1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OutgoingServerChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
if (sender is TextBox senderTextBox)
|
||||
{
|
||||
var splitted = senderTextBox.Text.Split(':');
|
||||
|
||||
if (splitted.Length > 1)
|
||||
{
|
||||
OutgoingServerPort.Text = splitted[splitted.Length - 1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void IncomingUsernameChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
if (UseSameCredentialsForSending)
|
||||
{
|
||||
OutgoingUsernameBox.Text = UsernameBox.Text;
|
||||
}
|
||||
}
|
||||
|
||||
private void IncomingPasswordChanged(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (UseSameCredentialsForSending)
|
||||
{
|
||||
OutgoingPasswordBox.Password = PasswordBox.Password;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
30
Wino.Mail/Views/ImapSetup/AutoDiscoveryPage.xaml
Normal file
30
Wino.Mail/Views/ImapSetup/AutoDiscoveryPage.xaml
Normal file
File diff suppressed because one or more lines are too long
50
Wino.Mail/Views/ImapSetup/AutoDiscoveryPage.xaml.cs
Normal file
50
Wino.Mail/Views/ImapSetup/AutoDiscoveryPage.xaml.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using System.Threading.Tasks;
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
using Wino.Core.Domain.Interfaces;
|
||||
using Wino.Core.Domain.Models.AutoDiscovery;
|
||||
using Wino.Core.Messages.Mails;
|
||||
|
||||
namespace Wino.Views.ImapSetup
|
||||
{
|
||||
public sealed partial class AutoDiscoveryPage : Page
|
||||
{
|
||||
private readonly IAutoDiscoveryService _autoDiscoveryService;
|
||||
public AutoDiscoveryPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
_autoDiscoveryService = App.Current.Services.GetService<IAutoDiscoveryService>();
|
||||
}
|
||||
|
||||
protected override async void OnNavigatedTo(NavigationEventArgs e)
|
||||
{
|
||||
base.OnNavigatedTo(e);
|
||||
|
||||
AutoDiscoverySettings discoverySettings = null;
|
||||
|
||||
if (e.Parameter is AutoDiscoveryMinimalSettings userMinimalSettings)
|
||||
{
|
||||
discoverySettings = await _autoDiscoveryService.GetAutoDiscoverySettings(userMinimalSettings);
|
||||
|
||||
await Task.Delay(1000);
|
||||
|
||||
if (discoverySettings == null)
|
||||
{
|
||||
// Couldn't find settings.
|
||||
|
||||
WeakReferenceMessenger.Default.Send(new ImapSetupBackNavigationRequested(typeof(WelcomeImapSetupPage), "Couldn't find mailbox settings for {userMinimalSettings.Email}. Please configure it manually."));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Settings are found. Test the connection with the given password.
|
||||
|
||||
discoverySettings.UserMinimalSettings = userMinimalSettings;
|
||||
|
||||
WeakReferenceMessenger.Default.Send(new ImapSetupNavigationRequested(typeof(TestingImapConnectionPage), discoverySettings));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
31
Wino.Mail/Views/ImapSetup/PreparingImapFoldersPage.xaml
Normal file
31
Wino.Mail/Views/ImapSetup/PreparingImapFoldersPage.xaml
Normal file
@@ -0,0 +1,31 @@
|
||||
<Page
|
||||
x:Class="Wino.Views.ImapSetup.PreparingImapFoldersPage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:Wino.Views.ImapSetup"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
|
||||
xmlns:domain="using:Wino.Core.Domain"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Grid>
|
||||
<!-- Preparing Folders Panel -->
|
||||
<StackPanel
|
||||
x:Name="PreparingFoldersPanel"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Center">
|
||||
|
||||
<Viewbox
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Center"
|
||||
Width="26"
|
||||
Height="26">
|
||||
<PathIcon Data="M1024,317.5L1024,507C1014.67,495.333 1004.67,484.167 994,473.5C983.333,462.833 972,453 960,444L960,320C960,311.333 958.333,303.083 955,295.25C951.667,287.417 947.083,280.583 941.25,274.75C935.417,268.917 928.583,264.333 920.75,261C912.917,257.667 904.667,256 896,256L522,256L458,298.5C436,312.833 412.333,320 387,320L64,320L64,832C64,841 65.6667,849.417 69,857.25C72.3333,865.083 76.8333,871.833 82.5,877.5C88.1667,883.167 94.9167,887.667 102.75,891C110.583,894.333 119,896 128,896L404.5,896C410.167,907.333 416.25,918.333 422.75,929C429.25,939.667 436.333,950 444,960L125.5,960C108.833,960 92.9167,956.583 77.75,949.75C62.5833,942.917 49.25,933.75 37.75,922.25C26.25,910.75 17.0833,897.417 10.25,882.25C3.41667,867.083 0,851.167 0,834.5L0,189.5C0,172.833 3.41667,156.917 10.25,141.75C17.0833,126.583 26.25,113.25 37.75,101.75C49.25,90.25 62.5833,81.0834 77.75,74.25C92.9167,67.4167 108.833,64.0001 125.5,64L368,64C388,64.0001 407.167,68.5001 425.5,77.5C443.833,86.5001 458.833,99.0001 470.5,115L528,192L898.5,192C915.167,192 931.083,195.417 946.25,202.25C961.417,209.083 974.75,218.25 986.25,229.75C997.75,241.25 1006.92,254.583 1013.75,269.75C1020.58,284.917 1024,300.833 1024,317.5ZM466,216L419,153.5C413,145.5 405.5,139.25 396.5,134.75C387.5,130.25 378,128 368,128L128,128C119,128 110.667,129.667 103,133C95.3333,136.333 88.5833,140.917 82.75,146.75C76.9167,152.583 72.3333,159.333 69,167C65.6667,174.667 64,183 64,192L64,256L387,256C394.333,256 401.5,254.667 408.5,252C415.5,249.333 422.25,246 428.75,242C435.25,238 441.583,233.667 447.75,229C453.917,224.333 460,220 466,216ZM1024,736C1024,775.667 1016.42,813 1001.25,848C986.083,883 965.5,913.5 939.5,939.5C913.5,965.5 883,986.083 848,1001.25C813,1016.42 775.667,1024 736,1024C696,1024 658.5,1016.5 623.5,1001.5C588.5,986.5 558,966 532,940C506,914 485.5,883.5 470.5,848.5C455.5,813.5 448,776 448,736C448,696.333 455.583,659 470.75,624C485.917,589 506.5,558.5 532.5,532.5C558.5,506.5 589,485.917 624,470.75C659,455.583 696.333,448 736,448C762.333,448 787.75,451.417 812.25,458.25C836.75,465.083 859.667,474.75 881,487.25C902.333,499.75 921.833,514.833 939.5,532.5C957.167,550.167 972.25,569.667 984.75,591C997.25,612.333 1006.92,635.25 1013.75,659.75C1020.58,684.25 1024,709.667 1024,736ZM896,576C896,567.333 892.833,559.833 886.5,553.5C880.167,547.167 872.667,544 864,544C857.667,544 852.5,545.167 848.5,547.5C844.5,549.833 841.25,552.917 838.75,556.75C836.25,560.583 834.5,565 833.5,570C832.5,575 832,580.167 832,585.5C816.333,577.167 800.917,570.833 785.75,566.5C770.583,562.167 754,560 736,560C724,560 711.75,561.25 699.25,563.75C686.75,566.25 674.5,569.917 662.5,574.75C650.5,579.583 639.083,585.417 628.25,592.25C617.417,599.083 608,607 600,616C597,619.333 594.667,622.75 593,626.25C591.333,629.75 590.5,633.833 590.5,638.5C590.5,647.5 593.667,655.167 600,661.5C606.333,667.833 614,671 623,671C628.667,671 634.75,668.583 641.25,663.75C647.75,658.917 655.333,653.5 664,647.5C672.667,641.5 682.75,636.083 694.25,631.25C705.75,626.417 719.333,624 735,624C746.667,624 757.5,625.25 767.5,627.75C777.5,630.25 787.667,634.333 798,640L785,640C779,640 773.083,640.25 767.25,640.75C761.417,641.25 756.167,642.583 751.5,644.75C746.833,646.917 743.083,650.167 740.25,654.5C737.417,658.833 736,664.667 736,672C736,680.667 739.167,688.167 745.5,694.5C751.833,700.833 759.333,704 768,704L864,704C872.667,704 880.167,700.833 886.5,694.5C892.833,688.167 896,680.667 896,672ZM881.5,833C881.5,824.333 878.333,816.833 872,810.5C865.667,804.167 858.167,801 849.5,801C842.833,801 836.333,803.417 830,808.25C823.667,813.083 816.333,818.5 808,824.5C799.667,830.5 789.833,835.917 778.5,840.75C767.167,845.583 753.333,848 737,848C725.333,848 714.5,846.75 704.5,844.25C694.5,841.75 684.333,837.667 674,832L687,832C692.667,832 698.417,831.75 704.25,831.25C710.083,830.75 715.333,829.417 720,827.25C724.667,825.083 728.5,821.833 731.5,817.5C734.5,813.167 736,807.333 736,800C736,791.333 732.833,783.833 726.5,777.5C720.167,771.167 712.667,768 704,768L608,768C599.333,768 591.833,771.167 585.5,777.5C579.167,783.833 576,791.333 576,800L576,896C576,904.667 579.167,912.167 585.5,918.5C591.833,924.833 599.333,928 608,928C614.333,928 619.5,926.833 623.5,924.5C627.5,922.167 630.75,919.083 633.25,915.25C635.75,911.417 637.5,907 638.5,902C639.5,897 640,891.833 640,886.5C655.667,894.833 671.083,901.167 686.25,905.5C701.417,909.833 718,912 736,912C748,912 760.333,910.75 773,908.25C785.667,905.75 797.917,902.083 809.75,897.25C821.583,892.417 832.833,886.583 843.5,879.75C854.167,872.917 863.667,865 872,856C878.333,849.333 881.5,841.667 881.5,833Z" />
|
||||
</Viewbox>
|
||||
|
||||
<TextBlock Text="{x:Bind domain:Translator.PreparingFoldersMessage}" />
|
||||
<muxc:ProgressBar IsIndeterminate="True" Margin="0,4,0,0" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Page>
|
||||
30
Wino.Mail/Views/ImapSetup/PreparingImapFoldersPage.xaml.cs
Normal file
30
Wino.Mail/Views/ImapSetup/PreparingImapFoldersPage.xaml.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices.WindowsRuntime;
|
||||
using Windows.Foundation;
|
||||
using Windows.Foundation.Collections;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Controls.Primitives;
|
||||
using Windows.UI.Xaml.Data;
|
||||
using Windows.UI.Xaml.Input;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
|
||||
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
|
||||
|
||||
namespace Wino.Views.ImapSetup
|
||||
{
|
||||
/// <summary>
|
||||
/// An empty page that can be used on its own or navigated to within a Frame.
|
||||
/// </summary>
|
||||
public sealed partial class PreparingImapFoldersPage : Page
|
||||
{
|
||||
public PreparingImapFoldersPage()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
32
Wino.Mail/Views/ImapSetup/TestingImapConnectionPage.xaml
Normal file
32
Wino.Mail/Views/ImapSetup/TestingImapConnectionPage.xaml
Normal file
@@ -0,0 +1,32 @@
|
||||
<Page
|
||||
x:Class="Wino.Views.ImapSetup.TestingImapConnectionPage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:Wino.Views.ImapSetup"
|
||||
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:domain="using:Wino.Core.Domain"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Grid>
|
||||
<!-- Testing Connection Panel -->
|
||||
<StackPanel
|
||||
x:Name="TestingConnectionPanel"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Center">
|
||||
|
||||
<Viewbox
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Center"
|
||||
Width="26"
|
||||
Height="26">
|
||||
<PathIcon Data="F1 M 18.75 18.125 C 18.75 18.294271 18.68815 18.440756 18.564453 18.564453 C 18.440754 18.68815 18.29427 18.75 18.125 18.75 L 13.75 18.75 C 13.75 18.925781 13.717447 19.088541 13.652344 19.238281 C 13.587239 19.388021 13.497721 19.519857 13.383789 19.633789 C 13.269855 19.747721 13.13802 19.83724 12.988281 19.902344 C 12.838541 19.967447 12.675781 20 12.5 20 L 6.25 20 C 6.074219 20 5.909831 19.967447 5.756836 19.902344 C 5.603841 19.83724 5.472005 19.74935 5.361328 19.638672 C 5.250651 19.527994 5.16276 19.396158 5.097656 19.243164 C 5.032552 19.09017 5 18.925781 5 18.75 L 0.625 18.75 C 0.455729 18.75 0.309245 18.68815 0.185547 18.564453 C 0.061849 18.440756 0 18.294271 0 18.125 C 0 17.955729 0.061849 17.809244 0.185547 17.685547 C 0.309245 17.56185 0.455729 17.5 0.625 17.5 L 5 17.5 C 5 17.154949 5.120442 16.86198 5.361328 16.621094 C 5.608724 16.373699 5.904948 16.25 6.25 16.25 L 7.5 16.25 C 7.5 16.074219 7.532552 15.911459 7.597656 15.761719 C 7.66276 15.611979 7.752278 15.480144 7.866211 15.366211 C 7.980143 15.252279 8.111979 15.162761 8.261719 15.097656 C 8.411458 15.032553 8.574219 15 8.75 15 L 8.75 13.75 L 6.875 13.75 C 6.621094 13.75 6.380208 13.701172 6.152344 13.603516 C 5.924479 13.505859 5.724284 13.370769 5.551758 13.198242 C 5.379231 13.025717 5.244141 12.825521 5.146484 12.597656 C 5.048828 12.369792 5 12.128906 5 11.875 L 5 1.875 C 5 1.621094 5.048828 1.380209 5.146484 1.152344 C 5.244141 0.92448 5.379231 0.724285 5.551758 0.551758 C 5.724284 0.379232 5.924479 0.244141 6.152344 0.146484 C 6.380208 0.048828 6.621094 0 6.875 0 L 11.875 0 C 12.128906 0 12.369791 0.048828 12.597656 0.146484 C 12.825521 0.244141 13.025716 0.379232 13.198242 0.551758 C 13.370768 0.724285 13.505859 0.92448 13.603516 1.152344 C 13.701172 1.380209 13.75 1.621094 13.75 1.875 L 13.75 11.875 C 13.75 12.128906 13.701172 12.369792 13.603516 12.597656 C 13.505859 12.825521 13.370768 13.025717 13.198242 13.198242 C 13.025716 13.370769 12.825521 13.505859 12.597656 13.603516 C 12.369791 13.701172 12.128906 13.75 11.875 13.75 L 10 13.75 L 10 15 C 10.169271 15 10.330403 15.032553 10.483398 15.097656 C 10.636393 15.162761 10.769856 15.252279 10.883789 15.366211 C 10.997721 15.480144 11.087239 15.613607 11.152344 15.766602 C 11.217447 15.919597 11.25 16.080729 11.25 16.25 L 12.5 16.25 C 12.669271 16.25 12.828775 16.282553 12.978516 16.347656 C 13.128255 16.41276 13.261719 16.503906 13.378906 16.621094 C 13.626302 16.86849 13.75 17.161459 13.75 17.5 L 18.125 17.5 C 18.29427 17.5 18.440754 17.56185 18.564453 17.685547 C 18.68815 17.809244 18.75 17.955729 18.75 18.125 Z M 11.875 12.5 C 12.04427 12.5 12.190754 12.438151 12.314453 12.314453 C 12.43815 12.190756 12.5 12.044271 12.5 11.875 L 12.5 1.875 C 12.5 1.70573 12.43815 1.559246 12.314453 1.435547 C 12.190754 1.31185 12.04427 1.25 11.875 1.25 L 6.875 1.25 C 6.705729 1.25 6.559244 1.31185 6.435547 1.435547 C 6.311849 1.559246 6.25 1.70573 6.25 1.875 L 6.25 11.875 C 6.25 12.044271 6.311849 12.190756 6.435547 12.314453 C 6.559244 12.438151 6.705729 12.5 6.875 12.5 Z M 10.625 2.5 C 10.794271 2.5 10.940755 2.56185 11.064453 2.685547 C 11.18815 2.809246 11.25 2.95573 11.25 3.125 C 11.25 3.294271 11.18815 3.440756 11.064453 3.564453 C 10.940755 3.688152 10.794271 3.75 10.625 3.75 L 8.125 3.75 C 7.955729 3.75 7.809245 3.688152 7.685547 3.564453 C 7.561849 3.440756 7.5 3.294271 7.5 3.125 C 7.5 2.95573 7.561849 2.809246 7.685547 2.685547 C 7.809245 2.56185 7.955729 2.5 8.125 2.5 Z M 10.625 5 C 10.794271 5.000001 10.940755 5.06185 11.064453 5.185547 C 11.18815 5.309245 11.25 5.455729 11.25 5.625 C 11.25 5.794271 11.18815 5.940756 11.064453 6.064453 C 10.940755 6.188151 10.794271 6.25 10.625 6.25 L 8.125 6.25 C 7.955729 6.25 7.809245 6.188151 7.685547 6.064453 C 7.561849 5.940756 7.5 5.794271 7.5 5.625 C 7.5 5.455729 7.561849 5.309245 7.685547 5.185547 C 7.809245 5.06185 7.955729 5.000001 8.125 5 Z M 12.5 18.75 L 12.5 17.5 L 10.625 17.5 C 10.481771 17.5 10.367838 17.47233 10.283203 17.416992 C 10.198567 17.361654 10.135091 17.290039 10.092773 17.202148 C 10.050455 17.114258 10.022786 17.016602 10.009766 16.90918 C 9.996744 16.801758 9.990234 16.692709 9.990234 16.582031 C 9.990234 16.523438 9.991861 16.466471 9.995117 16.411133 C 9.998372 16.355795 10 16.302084 10 16.25 L 8.75 16.25 L 8.75 16.582031 C 8.75 16.692709 8.743489 16.801758 8.730469 16.90918 C 8.717447 17.016602 8.689778 17.114258 8.647461 17.202148 C 8.605143 17.290039 8.543294 17.361654 8.461914 17.416992 C 8.380533 17.47233 8.268229 17.5 8.125 17.5 L 6.25 17.5 L 6.25 18.75 Z " />
|
||||
</Viewbox>
|
||||
|
||||
<TextBlock Text="{x:Bind domain:Translator.TestingImapConnectionMessage}" />
|
||||
|
||||
<muxc:ProgressBar IsIndeterminate="True" Margin="0,4,0,0" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Page>
|
||||
80
Wino.Mail/Views/ImapSetup/TestingImapConnectionPage.xaml.cs
Normal file
80
Wino.Mail/Views/ImapSetup/TestingImapConnectionPage.xaml.cs
Normal file
@@ -0,0 +1,80 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
using Microsoft.AppCenter.Analytics;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
using Wino.Core.Domain.Interfaces;
|
||||
using Wino.Core.Domain.Entities;
|
||||
using Wino.Core.Domain.Models.AutoDiscovery;
|
||||
using Wino.Core.Messages.Mails;
|
||||
|
||||
|
||||
namespace Wino.Views.ImapSetup
|
||||
{
|
||||
public sealed partial class TestingImapConnectionPage : Page
|
||||
{
|
||||
private IImapTestService _imapTestService;
|
||||
|
||||
public TestingImapConnectionPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_imapTestService = App.Current.Services.GetService<IImapTestService>();
|
||||
}
|
||||
|
||||
private async Task TryTestConnectionAsync(CustomServerInformation serverInformation)
|
||||
{
|
||||
await Task.Delay(1000);
|
||||
|
||||
await _imapTestService.TestImapConnectionAsync(serverInformation);
|
||||
|
||||
// All success. Finish setup with validated server information.
|
||||
|
||||
WeakReferenceMessenger.Default.Send(new ImapSetupDismissRequested(serverInformation));
|
||||
}
|
||||
|
||||
protected override async void OnNavigatedTo(NavigationEventArgs e)
|
||||
{
|
||||
base.OnNavigatedTo(e);
|
||||
|
||||
// We either go back to welcome setup page or advanced config page.
|
||||
// Based on if we come from auto discovery or not.
|
||||
|
||||
if (e.Parameter is AutoDiscoverySettings autoDiscoverySettings)
|
||||
{
|
||||
var serverInformation = autoDiscoverySettings.ToServerInformation();
|
||||
|
||||
try
|
||||
{
|
||||
await TryTestConnectionAsync(serverInformation);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
WeakReferenceMessenger.Default.Send(new ImapSetupBackNavigationRequested(typeof(WelcomeImapSetupPage),
|
||||
new AutoDiscoveryConnectionTestFailedPackage(autoDiscoverySettings, ex)));
|
||||
}
|
||||
}
|
||||
else if (e.Parameter is CustomServerInformation customServerInformation)
|
||||
{
|
||||
try
|
||||
{
|
||||
await TryTestConnectionAsync(customServerInformation);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Analytics.TrackEvent("IMAP Test Failed", new Dictionary<string, string>()
|
||||
{
|
||||
{ "Server", customServerInformation.IncomingServer },
|
||||
{ "Port", customServerInformation.IncomingServerPort },
|
||||
});
|
||||
|
||||
WeakReferenceMessenger.Default.Send(new ImapSetupBackNavigationRequested(typeof(AdvancedImapSetupPage),
|
||||
new AutoDiscoveryConnectionTestFailedPackage(ex)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
101
Wino.Mail/Views/ImapSetup/WelcomeImapSetupPage.xaml
Normal file
101
Wino.Mail/Views/ImapSetup/WelcomeImapSetupPage.xaml
Normal file
File diff suppressed because one or more lines are too long
90
Wino.Mail/Views/ImapSetup/WelcomeImapSetupPage.xaml.cs
Normal file
90
Wino.Mail/Views/ImapSetup/WelcomeImapSetupPage.xaml.cs
Normal file
@@ -0,0 +1,90 @@
|
||||
using System;
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
using Wino.Core.Domain.Models.AutoDiscovery;
|
||||
using Wino.Core.Messages.Mails;
|
||||
using Wino.Extensions;
|
||||
|
||||
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
|
||||
|
||||
namespace Wino.Views.ImapSetup
|
||||
{
|
||||
/// <summary>
|
||||
/// An empty page that can be used on its own or navigated to within a Frame.
|
||||
/// </summary>
|
||||
public sealed partial class WelcomeImapSetupPage : Page
|
||||
{
|
||||
private AutoDiscoveryConnectionTestFailedPackage failedPackage;
|
||||
|
||||
public WelcomeImapSetupPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
NavigationCacheMode = Windows.UI.Xaml.Navigation.NavigationCacheMode.Enabled;
|
||||
}
|
||||
|
||||
private void SignInClicked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
failedPackage = null;
|
||||
|
||||
var minimalSettings = new AutoDiscoveryMinimalSettings()
|
||||
{
|
||||
Password = PasswordBox.Password,
|
||||
DisplayName = DisplayNameBox.Text,
|
||||
Email = AddressBox.Text,
|
||||
};
|
||||
|
||||
WeakReferenceMessenger.Default.Send(new ImapSetupNavigationRequested(typeof(AutoDiscoveryPage), minimalSettings));
|
||||
}
|
||||
|
||||
protected override void OnNavigatedTo(NavigationEventArgs e)
|
||||
{
|
||||
base.OnNavigatedTo(e);
|
||||
|
||||
if (e.Parameter is string errorMessage)
|
||||
{
|
||||
ErrorMessageText.Text = errorMessage;
|
||||
|
||||
MainScrollviewer.ScrollToElement(ErrorMessageText);
|
||||
}
|
||||
else if (e.Parameter is AutoDiscoveryConnectionTestFailedPackage autoDiscoveryConnectionTestFailedPackage)
|
||||
{
|
||||
failedPackage = autoDiscoveryConnectionTestFailedPackage;
|
||||
ErrorMessageText.Text = $"Discovery was successful but connection to the server failed.{Environment.NewLine}{Environment.NewLine}{autoDiscoveryConnectionTestFailedPackage.Error.Message}";
|
||||
|
||||
MainScrollviewer.ScrollToElement(ErrorMessageText);
|
||||
}
|
||||
}
|
||||
|
||||
private void CancelClicked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
WeakReferenceMessenger.Default.Send(new ImapSetupDismissRequested());
|
||||
}
|
||||
|
||||
private void AdvancedConfigurationClicked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var latestMinimalSettings = new AutoDiscoveryMinimalSettings()
|
||||
{
|
||||
DisplayName = DisplayNameBox.Text,
|
||||
Password = PasswordBox.Password,
|
||||
Email = AddressBox.Text
|
||||
};
|
||||
|
||||
if (failedPackage != null)
|
||||
{
|
||||
// Go to advanced settings with updated minimal settings.
|
||||
|
||||
failedPackage.Settings.UserMinimalSettings = latestMinimalSettings;
|
||||
|
||||
WeakReferenceMessenger.Default.Send(new ImapSetupNavigationRequested(typeof(AdvancedImapSetupPage), failedPackage.Settings));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Go to advanced page.
|
||||
|
||||
WeakReferenceMessenger.Default.Send(new ImapSetupNavigationRequested(typeof(AdvancedImapSetupPage), latestMinimalSettings));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user