@@ -14,82 +14,83 @@ using Wino.Core.Domain.Models.AutoDiscovery;
|
||||
using Wino.Messaging.Client.Mails;
|
||||
|
||||
|
||||
namespace Wino.Views.ImapSetup;
|
||||
|
||||
public sealed partial class WelcomeImapSetupPage : Page
|
||||
namespace Wino.Views.ImapSetup
|
||||
{
|
||||
private readonly IAutoDiscoveryService _autoDiscoveryService = App.Current.Services.GetService<IAutoDiscoveryService>();
|
||||
|
||||
public WelcomeImapSetupPage()
|
||||
public sealed partial class WelcomeImapSetupPage : Page
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
private readonly IAutoDiscoveryService _autoDiscoveryService = App.Current.Services.GetService<IAutoDiscoveryService>();
|
||||
|
||||
protected override void OnNavigatedTo(NavigationEventArgs e)
|
||||
{
|
||||
base.OnNavigatedTo(e);
|
||||
|
||||
AutoDiscoveryPanel.Visibility = Visibility.Collapsed;
|
||||
MainSetupPanel.Visibility = Visibility.Visible;
|
||||
|
||||
if (e.Parameter is MailAccount accountProperties)
|
||||
public WelcomeImapSetupPage()
|
||||
{
|
||||
DisplayNameBox.Text = accountProperties.Name;
|
||||
InitializeComponent();
|
||||
}
|
||||
else if (e.Parameter is AccountCreationDialogResult creationDialogResult)
|
||||
|
||||
protected override void OnNavigatedTo(NavigationEventArgs e)
|
||||
{
|
||||
WeakReferenceMessenger.Default.Send(new ImapSetupNavigationRequested(typeof(TestingImapConnectionPage), creationDialogResult));
|
||||
base.OnNavigatedTo(e);
|
||||
|
||||
AutoDiscoveryPanel.Visibility = Visibility.Collapsed;
|
||||
MainSetupPanel.Visibility = Visibility.Visible;
|
||||
|
||||
if (e.Parameter is MailAccount accountProperties)
|
||||
{
|
||||
DisplayNameBox.Text = accountProperties.Name;
|
||||
}
|
||||
else if (e.Parameter is AccountCreationDialogResult creationDialogResult)
|
||||
{
|
||||
WeakReferenceMessenger.Default.Send(new ImapSetupNavigationRequested(typeof(TestingImapConnectionPage), creationDialogResult));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async void SignInClicked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
MainSetupPanel.Visibility = Visibility.Collapsed;
|
||||
AutoDiscoveryPanel.Visibility = Visibility.Visible;
|
||||
|
||||
// Let users see the discovery message for a while...
|
||||
|
||||
await Task.Delay(1000);
|
||||
|
||||
var minimalSettings = new AutoDiscoveryMinimalSettings()
|
||||
private async void SignInClicked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Password = PasswordBox.Password,
|
||||
DisplayName = DisplayNameBox.Text,
|
||||
Email = AddressBox.Text,
|
||||
};
|
||||
MainSetupPanel.Visibility = Visibility.Collapsed;
|
||||
AutoDiscoveryPanel.Visibility = Visibility.Visible;
|
||||
|
||||
var discoverySettings = await _autoDiscoveryService.GetAutoDiscoverySettings(minimalSettings);
|
||||
// Let users see the discovery message for a while...
|
||||
|
||||
if (discoverySettings == null)
|
||||
{
|
||||
// Couldn't find settings.
|
||||
await Task.Delay(1000);
|
||||
|
||||
var failurePackage = new ImapConnectionFailedPackage(Translator.Exception_ImapAutoDiscoveryFailed, string.Empty, discoverySettings);
|
||||
var minimalSettings = new AutoDiscoveryMinimalSettings()
|
||||
{
|
||||
Password = PasswordBox.Password,
|
||||
DisplayName = DisplayNameBox.Text,
|
||||
Email = AddressBox.Text,
|
||||
};
|
||||
|
||||
WeakReferenceMessenger.Default.Send(new ImapSetupBackNavigationRequested(typeof(ImapConnectionFailedPage), failurePackage));
|
||||
var discoverySettings = await _autoDiscoveryService.GetAutoDiscoverySettings(minimalSettings);
|
||||
|
||||
if (discoverySettings == null)
|
||||
{
|
||||
// Couldn't find settings.
|
||||
|
||||
var failurePackage = new ImapConnectionFailedPackage(Translator.Exception_ImapAutoDiscoveryFailed, string.Empty, discoverySettings);
|
||||
|
||||
WeakReferenceMessenger.Default.Send(new ImapSetupBackNavigationRequested(typeof(ImapConnectionFailedPage), failurePackage));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Settings are found. Test the connection with the given password.
|
||||
|
||||
discoverySettings.UserMinimalSettings = minimalSettings;
|
||||
|
||||
WeakReferenceMessenger.Default.Send(new ImapSetupNavigationRequested(typeof(TestingImapConnectionPage), discoverySettings));
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
private void CancelClicked(object sender, RoutedEventArgs e) => WeakReferenceMessenger.Default.Send(new ImapSetupDismissRequested());
|
||||
|
||||
private void AdvancedConfigurationClicked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// Settings are found. Test the connection with the given password.
|
||||
var latestMinimalSettings = new AutoDiscoveryMinimalSettings()
|
||||
{
|
||||
DisplayName = DisplayNameBox.Text,
|
||||
Password = PasswordBox.Password,
|
||||
Email = AddressBox.Text
|
||||
};
|
||||
|
||||
discoverySettings.UserMinimalSettings = minimalSettings;
|
||||
|
||||
WeakReferenceMessenger.Default.Send(new ImapSetupNavigationRequested(typeof(TestingImapConnectionPage), discoverySettings));
|
||||
WeakReferenceMessenger.Default.Send(new ImapSetupNavigationRequested(typeof(AdvancedImapSetupPage), latestMinimalSettings));
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
};
|
||||
|
||||
|
||||
WeakReferenceMessenger.Default.Send(new ImapSetupNavigationRequested(typeof(AdvancedImapSetupPage), latestMinimalSettings));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user