diff --git a/Wino.Calendar.ViewModels/AppShellViewModel.cs b/Wino.Calendar.ViewModels/AppShellViewModel.cs
index a7454eb5..d6529511 100644
--- a/Wino.Calendar.ViewModels/AppShellViewModel.cs
+++ b/Wino.Calendar.ViewModels/AppShellViewModel.cs
@@ -34,7 +34,6 @@ public partial class AppShellViewModel : CalendarBaseViewModel,
public IStatePersistanceService StatePersistenceService { get; }
public IAccountCalendarStateService AccountCalendarStateService { get; }
public INavigationService NavigationService { get; }
- public IWinoServerConnectionManager ServerConnectionManager { get; }
[ObservableProperty]
private bool _isEventDetailsPageActive;
@@ -45,11 +44,7 @@ public partial class AppShellViewModel : CalendarBaseViewModel,
[ObservableProperty]
private bool isCalendarEnabled;
- ///
- /// Gets or sets the active connection status of the Wino server.
- ///
- [ObservableProperty]
- private WinoServerConnectionStatus activeConnectionStatus;
+
///
/// Gets or sets the display date of the calendar.
@@ -79,8 +74,7 @@ public partial class AppShellViewModel : CalendarBaseViewModel,
IAccountService accountService,
ICalendarService calendarService,
IAccountCalendarStateService accountCalendarStateService,
- INavigationService navigationService,
- IWinoServerConnectionManager serverConnectionManager)
+ INavigationService navigationService)
{
_accountService = accountService;
_calendarService = calendarService;
@@ -90,7 +84,6 @@ public partial class AppShellViewModel : CalendarBaseViewModel,
AccountCalendarStateService.CollectiveAccountGroupSelectionStateChanged += AccountCalendarStateCollectivelyChanged;
NavigationService = navigationService;
- ServerConnectionManager = serverConnectionManager;
PreferencesService = preferencesService;
StatePersistenceService = statePersistanceService;
@@ -286,8 +279,7 @@ public partial class AppShellViewModel : CalendarBaseViewModel,
[RelayCommand]
public void ManageAccounts() => NavigationService.Navigate(WinoPage.AccountManagementPage);
- [RelayCommand]
- private Task ReconnectServerAsync() => ServerConnectionManager.ConnectAsync();
+
[RelayCommand]
private void DateClicked(CalendarViewDayClickedEventArgs clickedDateArgs)
diff --git a/Wino.Calendar/App.xaml.cs b/Wino.Calendar/App.xaml.cs
index 0ae35172..e669f615 100644
--- a/Wino.Calendar/App.xaml.cs
+++ b/Wino.Calendar/App.xaml.cs
@@ -119,13 +119,10 @@ public sealed partial class App : WinoApplication, IRecipient(message);
- synchronizationResultResponse.ThrowIfFailed();
- }
- catch (WinoServerException serverException)
- {
- var dialogService = Services.GetService();
-
- dialogService.InfoBarMessage(Translator.Info_SyncFailedTitle, serverException.Message, InfoBarMessageType.Error);
- }
+ // Synchronization is no longer performed through the server connection manager
+ // This method is kept for compatibility but doesn't perform any actual work
+ await Task.CompletedTask;
}
}
diff --git a/Wino.Calendar/Views/AppShell.xaml b/Wino.Calendar/Views/AppShell.xaml
index 8d01d754..81a4591d 100644
--- a/Wino.Calendar/Views/AppShell.xaml
+++ b/Wino.Calendar/Views/AppShell.xaml
@@ -57,13 +57,11 @@
Grid.ColumnSpan="2"
BackButtonClicked="AppBarBackButtonClicked"
Canvas.ZIndex="150"
- ConnectionStatus="{x:Bind ViewModel.ActiveConnectionStatus, Mode=OneWay}"
CoreWindowText="Wino Calendar"
IsBackButtonVisible="{x:Bind ViewModel.StatePersistenceService.IsBackButtonVisible, Mode=OneWay}"
IsNavigationPaneOpen="{x:Bind MainSplitView.IsPaneOpen, Mode=TwoWay}"
NavigationViewDisplayMode="{x:Bind helpers:XamlHelpers.NavigationViewDisplayModeConverter(MainSplitView.DisplayMode), Mode=OneWay}"
OpenPaneLength="{x:Bind ViewModel.StatePersistenceService.OpenPaneLength, Mode=OneWay}"
- ReconnectCommand="{x:Bind ViewModel.ReconnectServerCommand}"
ShrinkShellContentOnExpansion="False"
SystemReserved="180">
diff --git a/Wino.Core.Domain/Enums/ServerBackgroundMode.cs b/Wino.Core.Domain/Enums/ServerBackgroundMode.cs
deleted file mode 100644
index d7f9e5df..00000000
--- a/Wino.Core.Domain/Enums/ServerBackgroundMode.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-namespace Wino.Core.Domain.Enums;
-
-///
-/// What should happen to server app when the client is terminated.
-///
-public enum ServerBackgroundMode
-{
- MinimizedTray, // Still runs, tray icon is visible.
- Invisible, // Still runs, tray icon is invisible.
- Terminate // Server is terminated as Wino terminates.
-}
diff --git a/Wino.Core.Domain/Enums/WinoServerConnectionStatus.cs b/Wino.Core.Domain/Enums/WinoServerConnectionStatus.cs
deleted file mode 100644
index 9897b5bd..00000000
--- a/Wino.Core.Domain/Enums/WinoServerConnectionStatus.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace Wino.Core.Domain.Enums;
-
-public enum WinoServerConnectionStatus
-{
- None,
- Connecting,
- Connected,
- Disconnected,
- Failed
-}
diff --git a/Wino.Core.Domain/Exceptions/WinoServerException.cs b/Wino.Core.Domain/Exceptions/WinoServerException.cs
deleted file mode 100644
index afa7f132..00000000
--- a/Wino.Core.Domain/Exceptions/WinoServerException.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-using System;
-
-namespace Wino.Core.Domain.Exceptions;
-
-///
-/// All server crash types. Wino Server ideally should not throw anything else than this Exception type.
-///
-public class WinoServerException : Exception
-{
- public WinoServerException(string message) : base(message) { }
-}
diff --git a/Wino.Core.Domain/Interfaces/IPreferencesService.cs b/Wino.Core.Domain/Interfaces/IPreferencesService.cs
index bced247d..eeb07bda 100644
--- a/Wino.Core.Domain/Interfaces/IPreferencesService.cs
+++ b/Wino.Core.Domain/Interfaces/IPreferencesService.cs
@@ -30,11 +30,6 @@ public interface IPreferencesService : INotifyPropertyChanged
///
bool IsNavigationPaneOpened { get; set; }
- ///
- /// Setting: Gets or sets what should happen to server app when the client is terminated.
- ///
- ServerBackgroundMode ServerTerminationBehavior { get; set; }
-
///
/// Setting: Preferred time format for mail or calendar header display.
///
diff --git a/Wino.Core.Domain/Interfaces/IWinoServerConnectionManager.cs b/Wino.Core.Domain/Interfaces/IWinoServerConnectionManager.cs
index 69949a0a..7fc5c4fa 100644
--- a/Wino.Core.Domain/Interfaces/IWinoServerConnectionManager.cs
+++ b/Wino.Core.Domain/Interfaces/IWinoServerConnectionManager.cs
@@ -1,11 +1,56 @@
using System;
using System.Threading;
using System.Threading.Tasks;
-using Wino.Core.Domain.Enums;
-using Wino.Core.Domain.Models.Server;
namespace Wino.Core.Domain.Interfaces;
+///
+/// Simple wrapper class to maintain compatibility with the original WinoServerResponse structure.
+///
+/// Type of the expected response.
+public class WinoServerResponse
+{
+ public bool IsSuccess { get; set; }
+ public string Message { get; set; }
+ public T Data { get; set; }
+
+ public static WinoServerResponse CreateSuccessResponse(T data)
+ {
+ return new WinoServerResponse
+ {
+ IsSuccess = true,
+ Data = data
+ };
+ }
+
+ public static WinoServerResponse CreateErrorResponse(string message)
+ {
+ return new WinoServerResponse
+ {
+ IsSuccess = false,
+ Message = message
+ };
+ }
+
+ public void ThrowIfFailed()
+ {
+ if (!IsSuccess)
+ throw new InvalidOperationException(Message);
+ }
+}
+
+///
+/// Connection status enum to maintain compatibility.
+///
+public enum WinoServerConnectionStatus
+{
+ None,
+ Connecting,
+ Connected,
+ Disconnected,
+ Failed
+}
+
public interface IWinoServerConnectionManager
{
///
diff --git a/Wino.Core.Domain/Models/Server/WinoServerResponse.cs b/Wino.Core.Domain/Models/Server/WinoServerResponse.cs
deleted file mode 100644
index d334c89a..00000000
--- a/Wino.Core.Domain/Models/Server/WinoServerResponse.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-using Wino.Core.Domain.Exceptions;
-
-namespace Wino.Core.Domain.Models.Server;
-
-///
-/// Encapsulates responses from the Wino server.
-/// Exceptions are stored separately in the Message and StackTrace properties due to serialization issues.
-///
-/// Type of the expected response.
-public class WinoServerResponse
-{
- public bool IsSuccess { get; set; }
- public string Message { get; set; }
- public T Data { get; set; }
-
- public static WinoServerResponse CreateSuccessResponse(T data)
- {
- return new WinoServerResponse
- {
- IsSuccess = true,
- Data = data
- };
- }
-
- public static WinoServerResponse CreateErrorResponse(string message)
- {
- return new WinoServerResponse
- {
- IsSuccess = false,
- Message = message
- };
- }
-
- public void ThrowIfFailed()
- {
- if (!IsSuccess)
- throw new WinoServerException(Message);
- }
-}
diff --git a/Wino.Core.WinUI/Controls/WinoAppTitleBar.xaml b/Wino.Core.WinUI/Controls/WinoAppTitleBar.xaml
deleted file mode 100644
index b4889e19..00000000
--- a/Wino.Core.WinUI/Controls/WinoAppTitleBar.xaml
+++ /dev/null
@@ -1,193 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Wino.Core.WinUI/Controls/WinoAppTitleBar.xaml.cs b/Wino.Core.WinUI/Controls/WinoAppTitleBar.xaml.cs
deleted file mode 100644
index ecb7a33c..00000000
--- a/Wino.Core.WinUI/Controls/WinoAppTitleBar.xaml.cs
+++ /dev/null
@@ -1,255 +0,0 @@
-using System.Windows.Input;
-using Windows.Foundation;
-using Microsoft.UI.Xaml;
-using Microsoft.UI.Xaml.Controls;
-using Wino.Core.Domain.Enums;
-
-namespace Wino.Core.WinUI.Controls;
-
-public sealed partial class WinoAppTitleBar : UserControl
-{
- public event TypedEventHandler BackButtonClicked;
-
- public static readonly DependencyProperty IsRenderingPaneVisibleProperty = DependencyProperty.Register(nameof(IsRenderingPaneVisible), typeof(bool), typeof(WinoAppTitleBar), new PropertyMetadata(false, OnDrawingPropertyChanged));
- public static readonly DependencyProperty IsReaderNarrowedProperty = DependencyProperty.Register(nameof(IsReaderNarrowed), typeof(bool), typeof(WinoAppTitleBar), new PropertyMetadata(false, OnIsReaderNarrowedChanged));
- public static readonly DependencyProperty IsBackButtonVisibleProperty = DependencyProperty.Register(nameof(IsBackButtonVisible), typeof(bool), typeof(WinoAppTitleBar), new PropertyMetadata(false, OnDrawingPropertyChanged));
- public static readonly DependencyProperty OpenPaneLengthProperty = DependencyProperty.Register(nameof(OpenPaneLength), typeof(double), typeof(WinoAppTitleBar), new PropertyMetadata(0d, OnDrawingPropertyChanged));
- public static readonly DependencyProperty IsNavigationPaneOpenProperty = DependencyProperty.Register(nameof(IsNavigationPaneOpen), typeof(bool), typeof(WinoAppTitleBar), new PropertyMetadata(false, OnDrawingPropertyChanged));
- public static readonly DependencyProperty NavigationViewDisplayModeProperty = DependencyProperty.Register(nameof(NavigationViewDisplayMode), typeof(Microsoft.UI.Xaml.Controls.NavigationViewDisplayMode), typeof(WinoAppTitleBar), new PropertyMetadata(Microsoft.UI.Xaml.Controls.NavigationViewDisplayMode.Compact, OnDrawingPropertyChanged));
- public static readonly DependencyProperty ShellFrameContentProperty = DependencyProperty.Register(nameof(ShellFrameContent), typeof(UIElement), typeof(WinoAppTitleBar), new PropertyMetadata(null, OnDrawingPropertyChanged));
- public static readonly DependencyProperty SystemReservedProperty = DependencyProperty.Register(nameof(SystemReserved), typeof(double), typeof(WinoAppTitleBar), new PropertyMetadata(0, OnDrawingPropertyChanged));
- public static readonly DependencyProperty CoreWindowTextProperty = DependencyProperty.Register(nameof(CoreWindowText), typeof(string), typeof(WinoAppTitleBar), new PropertyMetadata(string.Empty, OnDrawingPropertyChanged));
- public static readonly DependencyProperty ReadingPaneLengthProperty = DependencyProperty.Register(nameof(ReadingPaneLength), typeof(double), typeof(WinoAppTitleBar), new PropertyMetadata(420d, OnDrawingPropertyChanged));
- public static readonly DependencyProperty ConnectionStatusProperty = DependencyProperty.Register(nameof(ConnectionStatus), typeof(WinoServerConnectionStatus), typeof(WinoAppTitleBar), new PropertyMetadata(WinoServerConnectionStatus.None, new PropertyChangedCallback(OnConnectionStatusChanged)));
- public static readonly DependencyProperty ReconnectCommandProperty = DependencyProperty.Register(nameof(ReconnectCommand), typeof(ICommand), typeof(WinoAppTitleBar), new PropertyMetadata(null));
- public static readonly DependencyProperty ShrinkShellContentOnExpansionProperty = DependencyProperty.Register(nameof(ShrinkShellContentOnExpansion), typeof(bool), typeof(WinoAppTitleBar), new PropertyMetadata(true));
- public static readonly DependencyProperty IsDragAreaProperty = DependencyProperty.Register(nameof(IsDragArea), typeof(bool), typeof(WinoAppTitleBar), new PropertyMetadata(false, new PropertyChangedCallback(OnIsDragAreaChanged)));
- public static readonly DependencyProperty IsShellFrameContentVisibleProperty = DependencyProperty.Register(nameof(IsShellFrameContentVisible), typeof(bool), typeof(WinoAppTitleBar), new PropertyMetadata(true));
- public static readonly DependencyProperty IsMenuButtonVisibleProperty = DependencyProperty.Register(nameof(IsMenuButtonVisible), typeof(bool), typeof(WinoAppTitleBar), new PropertyMetadata(true));
-
- public bool IsShellFrameContentVisible
- {
- get { return (bool)GetValue(IsShellFrameContentVisibleProperty); }
- set { SetValue(IsShellFrameContentVisibleProperty, value); }
- }
-
- public ICommand ReconnectCommand
- {
- get { return (ICommand)GetValue(ReconnectCommandProperty); }
- set { SetValue(ReconnectCommandProperty, value); }
- }
-
- public WinoServerConnectionStatus ConnectionStatus
- {
- get { return (WinoServerConnectionStatus)GetValue(ConnectionStatusProperty); }
- set { SetValue(ConnectionStatusProperty, value); }
- }
-
- public string CoreWindowText
- {
- get { return (string)GetValue(CoreWindowTextProperty); }
- set { SetValue(CoreWindowTextProperty, value); }
- }
-
- public bool IsDragArea
- {
- get { return (bool)GetValue(IsDragAreaProperty); }
- set { SetValue(IsDragAreaProperty, value); }
- }
-
-
- public double SystemReserved
- {
- get { return (double)GetValue(SystemReservedProperty); }
- set { SetValue(SystemReservedProperty, value); }
- }
-
- public UIElement ShellFrameContent
- {
- get { return (UIElement)GetValue(ShellFrameContentProperty); }
- set { SetValue(ShellFrameContentProperty, value); }
- }
-
- public Microsoft.UI.Xaml.Controls.NavigationViewDisplayMode NavigationViewDisplayMode
- {
- get { return (Microsoft.UI.Xaml.Controls.NavigationViewDisplayMode)GetValue(NavigationViewDisplayModeProperty); }
- set { SetValue(NavigationViewDisplayModeProperty, value); }
- }
-
- public bool ShrinkShellContentOnExpansion
- {
- get { return (bool)GetValue(ShrinkShellContentOnExpansionProperty); }
- set { SetValue(ShrinkShellContentOnExpansionProperty, value); }
- }
-
- public bool IsNavigationPaneOpen
- {
- get { return (bool)GetValue(IsNavigationPaneOpenProperty); }
- set { SetValue(IsNavigationPaneOpenProperty, value); }
- }
-
- public double OpenPaneLength
- {
- get { return (double)GetValue(OpenPaneLengthProperty); }
- set { SetValue(OpenPaneLengthProperty, value); }
- }
-
-
-
- public bool IsMenuButtonVisible
- {
- get { return (bool)GetValue(IsMenuButtonVisibleProperty); }
- set { SetValue(IsMenuButtonVisibleProperty, value); }
- }
-
-
- public bool IsBackButtonVisible
- {
- get { return (bool)GetValue(IsBackButtonVisibleProperty); }
- set { SetValue(IsBackButtonVisibleProperty, value); }
- }
-
- public bool IsReaderNarrowed
- {
- get { return (bool)GetValue(IsReaderNarrowedProperty); }
- set { SetValue(IsReaderNarrowedProperty, value); }
- }
-
- public bool IsRenderingPaneVisible
- {
- get { return (bool)GetValue(IsRenderingPaneVisibleProperty); }
- set { SetValue(IsRenderingPaneVisibleProperty, value); }
- }
-
- public double ReadingPaneLength
- {
- get { return (double)GetValue(ReadingPaneLengthProperty); }
- set { SetValue(ReadingPaneLengthProperty, value); }
- }
-
- private static void OnIsReaderNarrowedChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
- {
- if (obj is WinoAppTitleBar bar)
- {
- bar.DrawTitleBar();
- }
- }
-
- private static void OnDrawingPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
- {
- if (obj is WinoAppTitleBar bar)
- {
- bar.DrawTitleBar();
- }
- }
-
- private static void OnConnectionStatusChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
- {
- if (obj is WinoAppTitleBar bar)
- {
- bar.UpdateConnectionStatus();
- }
- }
-
- private static void OnIsDragAreaChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
- {
- if (obj is WinoAppTitleBar bar)
- {
- bar.SetDragArea();
- }
- }
-
- private void SetDragArea()
- {
- if (IsDragArea)
- {
- Window.Current.SetTitleBar(dragbar);
- }
- }
-
- private void UpdateConnectionStatus()
- {
-
- }
-
- private void DrawTitleBar()
- {
- UpdateLayout();
-
- CoreWindowTitleTextBlock.Visibility = Visibility.Collapsed;
- ShellContentContainer.Width = double.NaN;
- ShellContentContainer.Margin = new Thickness(0, 0, 0, 0);
- ShellContentContainer.HorizontalAlignment = HorizontalAlignment.Stretch;
-
- EmptySpaceWidth.Width = new GridLength(1, GridUnitType.Star);
-
- // Menu is not visible.
- if (NavigationViewDisplayMode == Microsoft.UI.Xaml.Controls.NavigationViewDisplayMode.Minimal)
- {
-
- }
- else if (NavigationViewDisplayMode == Microsoft.UI.Xaml.Controls.NavigationViewDisplayMode.Compact)
- {
- // Icons are visible.
-
- if (!IsReaderNarrowed && ShrinkShellContentOnExpansion)
- {
- ShellContentContainer.HorizontalAlignment = HorizontalAlignment.Left;
- ShellContentContainer.Width = ReadingPaneLength;
- }
- }
- else if (NavigationViewDisplayMode == Microsoft.UI.Xaml.Controls.NavigationViewDisplayMode.Expanded)
- {
- if (IsNavigationPaneOpen)
- {
- CoreWindowTitleTextBlock.Visibility = Visibility.Visible;
-
- // LMargin = OpenPaneLength - LeftMenuStackPanel
- ShellContentContainer.Margin = new Thickness(OpenPaneLength - LeftMenuStackPanel.ActualSize.X, 0, 0, 0);
-
- if (!IsReaderNarrowed && ShrinkShellContentOnExpansion)
- {
- ShellContentContainer.HorizontalAlignment = HorizontalAlignment.Left;
- ShellContentContainer.Width = ReadingPaneLength;
- }
- }
- else
- {
- if (ShrinkShellContentOnExpansion)
- {
- EmptySpaceWidth.Width = new GridLength(ReadingPaneLength, GridUnitType.Pixel);
- }
- else
- {
- EmptySpaceWidth.Width = new GridLength(ReadingPaneLength, GridUnitType.Star);
- }
- }
- }
- }
-
- public WinoAppTitleBar()
- {
- InitializeComponent();
- }
-
- private void BackClicked(object sender, RoutedEventArgs e)
- {
- BackButtonClicked?.Invoke(this, e);
- }
-
- private void PaneClicked(object sender, RoutedEventArgs e)
- {
- IsNavigationPaneOpen = !IsNavigationPaneOpen;
- }
-
- private void TitlebarSizeChanged(object sender, SizeChangedEventArgs e) => DrawTitleBar();
-
- private void ReconnectClicked(object sender, RoutedEventArgs e)
- {
- // Close the popup for reconnect button.
- ReconnectFlyout.Hide();
-
- // Execute the reconnect command.
- ReconnectCommand?.Execute(null);
- }
-}
diff --git a/Wino.Core.WinUI/CoreUWPContainerSetup.cs b/Wino.Core.WinUI/CoreUWPContainerSetup.cs
index 3460f473..95d74bc0 100644
--- a/Wino.Core.WinUI/CoreUWPContainerSetup.cs
+++ b/Wino.Core.WinUI/CoreUWPContainerSetup.cs
@@ -12,7 +12,7 @@ public static class CoreUWPContainerSetup
{
public static void RegisterCoreUWPServices(this IServiceCollection services)
{
- var serverConnectionManager = new WinoServerConnectionManager();
+ var serverConnectionManager = new EmptyWinoServerConnectionManager();
services.AddSingleton(serverConnectionManager);
services.AddSingleton>(serverConnectionManager);
diff --git a/Wino.Core.WinUI/Helpers/XamlHelpers.cs b/Wino.Core.WinUI/Helpers/XamlHelpers.cs
index da5281a0..96acbf03 100644
--- a/Wino.Core.WinUI/Helpers/XamlHelpers.cs
+++ b/Wino.Core.WinUI/Helpers/XamlHelpers.cs
@@ -161,7 +161,7 @@ public static class XamlHelpers
return Translator.UnknownDateHeader;
}
- public static bool ConnectionStatusEquals(WinoServerConnectionStatus winoServerConnectionStatus, WinoServerConnectionStatus connectionStatus) => winoServerConnectionStatus == connectionStatus;
+
#endregion
diff --git a/Wino.Core.WinUI/Services/EmptyWinoServerConnectionManager.cs b/Wino.Core.WinUI/Services/EmptyWinoServerConnectionManager.cs
new file mode 100644
index 00000000..a6b0da50
--- /dev/null
+++ b/Wino.Core.WinUI/Services/EmptyWinoServerConnectionManager.cs
@@ -0,0 +1,55 @@
+using System;
+using System.Threading;
+using System.Threading.Tasks;
+using Wino.Core.Domain.Interfaces;
+
+namespace Wino.Core.WinUI.Services;
+
+///
+/// Empty implementation of IWinoServerConnectionManager that returns default values.
+/// This replaces the old AppServiceConnection-based implementation.
+///
+public class EmptyWinoServerConnectionManager : IWinoServerConnectionManager
+{
+ public event EventHandler StatusChanged { add { } remove { } }
+
+ public WinoServerConnectionStatus Status => WinoServerConnectionStatus.Connected;
+
+ public TaskCompletionSource ConnectingHandle { get; } = new TaskCompletionSource();
+
+ public EmptyWinoServerConnectionManager()
+ {
+ ConnectingHandle.SetResult(true);
+ }
+
+ public Task ConnectAsync()
+ {
+ return Task.FromResult(true);
+ }
+
+ public Task QueueRequestAsync(IRequestBase request, Guid accountId)
+ {
+ return Task.CompletedTask;
+ }
+
+ public Task> GetResponseAsync(TRequestType clientMessage, CancellationToken cancellationToken = default)
+ where TRequestType : IClientMessage
+ {
+ var response = WinoServerResponse.CreateSuccessResponse(default(TResponse));
+ return Task.FromResult(response);
+ }
+}
+
+///
+/// Generic empty implementation for typed connection managers.
+///
+/// The connection type (not used in this implementation)
+public class EmptyWinoServerConnectionManager : EmptyWinoServerConnectionManager, IWinoServerConnectionManager
+{
+ public TAppServiceConnection Connection { get; set; }
+
+ public Task InitializeAsync()
+ {
+ return Task.CompletedTask;
+ }
+}
\ No newline at end of file
diff --git a/Wino.Core.WinUI/Services/PreferencesService.cs b/Wino.Core.WinUI/Services/PreferencesService.cs
index 8d14f168..215daacc 100644
--- a/Wino.Core.WinUI/Services/PreferencesService.cs
+++ b/Wino.Core.WinUI/Services/PreferencesService.cs
@@ -236,12 +236,6 @@ public class PreferencesService(IConfigurationService configurationService) : Ob
set => SaveProperty(propertyName: nameof(AutoSelectNextItem), value);
}
- public ServerBackgroundMode ServerTerminationBehavior
- {
- get => _configurationService.Get(nameof(ServerTerminationBehavior), ServerBackgroundMode.MinimizedTray);
- set => SaveProperty(propertyName: nameof(ServerTerminationBehavior), value);
- }
-
public string DiagnosticId
{
get => _configurationService.Get(nameof(DiagnosticId), Guid.NewGuid().ToString());
diff --git a/Wino.Core.WinUI/Services/WinoServerConnectionManager.cs b/Wino.Core.WinUI/Services/WinoServerConnectionManager.cs
deleted file mode 100644
index cc11c47b..00000000
--- a/Wino.Core.WinUI/Services/WinoServerConnectionManager.cs
+++ /dev/null
@@ -1,369 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Diagnostics.CodeAnalysis;
-using System.Text.Json;
-using System.Threading;
-using System.Threading.Tasks;
-using CommunityToolkit.Mvvm.Messaging;
-using Nito.AsyncEx;
-using Serilog;
-using Windows.ApplicationModel;
-using Windows.ApplicationModel.AppService;
-using Windows.Foundation.Collections;
-using Windows.Foundation.Metadata;
-using Wino.Core.Domain.Enums;
-using Wino.Core.Domain.Interfaces;
-using Wino.Core.Domain.Models.Requests;
-using Wino.Core.Domain.Models.Server;
-using Wino.Core.Integration.Json;
-using Wino.Messaging;
-using Wino.Messaging.Client.Connection;
-using Wino.Messaging.Enums;
-using Wino.Messaging.Server;
-using Wino.Messaging.UI;
-
-namespace Wino.Core.WinUI.Services;
-
-public class WinoServerConnectionManager :
- IWinoServerConnectionManager,
- IRecipient
-{
- private const int ServerConnectionTimeoutMs = 10000;
-
- public event EventHandler StatusChanged;
-
- public TaskCompletionSource ConnectingHandle { get; private set; }
-
- private ILogger Logger => Logger.ForContext();
-
- private WinoServerConnectionStatus status;
-
- public WinoServerConnectionStatus Status
- {
- get { return status; }
- private set
- {
- Log.Information("Server connection status changed to {Status}.", value);
- status = value;
- StatusChanged?.Invoke(this, value);
- }
- }
-
- private AppServiceConnection _connection;
- public AppServiceConnection Connection
- {
- get { return _connection; }
- set
- {
- if (_connection != null)
- {
- _connection.RequestReceived -= ServerMessageReceived;
- _connection.ServiceClosed -= ServerDisconnected;
- }
-
- _connection = value;
-
- if (value == null)
- {
- Status = WinoServerConnectionStatus.Disconnected;
- }
- else
- {
- value.RequestReceived += ServerMessageReceived;
- value.ServiceClosed += ServerDisconnected;
-
- Status = WinoServerConnectionStatus.Connected;
- }
- }
- }
-
- private readonly JsonSerializerOptions _jsonSerializerOptions = new()
- {
- TypeInfoResolver = new ServerRequestTypeInfoResolver()
- };
-
- public WinoServerConnectionManager()
- {
- WeakReferenceMessenger.Default.Register(this);
- }
-
- public async Task ConnectAsync()
- {
- if (Status == WinoServerConnectionStatus.Connected)
- {
- Log.Information("Server is already connected.");
- return true;
- }
-
- if (Status == WinoServerConnectionStatus.Connecting)
- {
- // A connection is already being established at the moment.
- // No need to run another connection establishment process.
- // Await the connecting handler if possible.
-
- if (ConnectingHandle != null)
- {
- return await ConnectingHandle.Task;
- }
- }
-
- if (ApiInformation.IsApiContractPresent("Windows.ApplicationModel.FullTrustAppContract", 1, 0))
- {
- try
- {
- ConnectingHandle = new TaskCompletionSource();
-
- Status = WinoServerConnectionStatus.Connecting;
-
- var connectionCancellationToken = new CancellationTokenSource(TimeSpan.FromMilliseconds(ServerConnectionTimeoutMs));
-
- await FullTrustProcessLauncher.LaunchFullTrustProcessForCurrentAppAsync("WinoServer");
-
- // Connection establishment handler is in App.xaml.cs OnBackgroundActivated.
- // Once the connection is established, the handler will set the Connection property
- // and WinoServerConnectionEstablished will be fired by the messenger.
-
- await ConnectingHandle.Task.WaitAsync(connectionCancellationToken.Token);
-
- Log.Information("Server connection established successfully.");
- }
- catch (OperationCanceledException canceledException)
- {
- Log.Error(canceledException, $"Server process did not start in {ServerConnectionTimeoutMs} ms. Operation is canceled.");
-
- ConnectingHandle?.TrySetException(canceledException);
-
- Status = WinoServerConnectionStatus.Failed;
- return false;
- }
- catch (Exception ex)
- {
- Log.Error(ex, "Failed to connect to the server.");
-
- ConnectingHandle?.TrySetException(ex);
-
- Status = WinoServerConnectionStatus.Failed;
- return false;
- }
-
- return true;
- }
- else
- {
- Log.Information("FullTrustAppContract is not present in the system. Server connection is not possible.");
- }
-
- return false;
- }
-
- public async Task InitializeAsync()
- {
- var isConnectionSuccessfull = await ConnectAsync();
-
- if (isConnectionSuccessfull)
- {
- Log.Information("ServerConnectionManager initialized successfully.");
- }
- else
- {
- Log.Error("ServerConnectionManager initialization failed.");
- }
- }
-
- private void ServerMessageReceived(AppServiceConnection sender, AppServiceRequestReceivedEventArgs args)
- {
- if (args.Request.Message.TryGetValue(MessageConstants.MessageTypeKey, out object messageTypeObject) && messageTypeObject is int messageTypeInt)
- {
- var messageType = (MessageType)messageTypeInt;
-
- if (args.Request.Message.TryGetValue(MessageConstants.MessageDataKey, out object messageDataObject) && messageDataObject is string messageJson)
- {
- switch (messageType)
- {
- case MessageType.UIMessage:
- if (!args.Request.Message.TryGetValue(MessageConstants.MessageDataTypeKey, out object dataTypeObject) || dataTypeObject is not string dataTypeName)
- throw new ArgumentException("Message data type is missing.");
-
- HandleUIMessage(messageJson, dataTypeName);
- break;
- default:
- break;
- }
- }
- }
- }
-
- ///
- /// Unpacks IServerMessage objects and delegate it to Messenger for UI to process.
- ///
- /// Message data in json format.
- private void HandleUIMessage(string messageJson, string typeName)
- {
- switch (typeName)
- {
- case nameof(MailAddedMessage):
- WeakReferenceMessenger.Default.Send(JsonSerializer.Deserialize(messageJson, CommunicationMessagesContext.Default.MailAddedMessage));
- break;
- case nameof(MailDownloadedMessage):
- WeakReferenceMessenger.Default.Send(JsonSerializer.Deserialize(messageJson, CommunicationMessagesContext.Default.MailDownloadedMessage));
- break;
- case nameof(MailRemovedMessage):
- WeakReferenceMessenger.Default.Send(JsonSerializer.Deserialize(messageJson, CommunicationMessagesContext.Default.MailRemovedMessage));
- break;
- case nameof(MailUpdatedMessage):
- WeakReferenceMessenger.Default.Send(JsonSerializer.Deserialize(messageJson, CommunicationMessagesContext.Default.MailUpdatedMessage));
- break;
- case nameof(AccountCreatedMessage):
- WeakReferenceMessenger.Default.Send(JsonSerializer.Deserialize(messageJson, CommunicationMessagesContext.Default.AccountCreatedMessage));
- break;
- case nameof(AccountRemovedMessage):
- WeakReferenceMessenger.Default.Send(JsonSerializer.Deserialize(messageJson, CommunicationMessagesContext.Default.AccountRemovedMessage));
- break;
- case nameof(AccountUpdatedMessage):
- WeakReferenceMessenger.Default.Send(JsonSerializer.Deserialize(messageJson, CommunicationMessagesContext.Default.AccountUpdatedMessage));
- break;
- case nameof(DraftCreated):
- WeakReferenceMessenger.Default.Send(JsonSerializer.Deserialize(messageJson, CommunicationMessagesContext.Default.DraftCreated));
- break;
- case nameof(DraftFailed):
- WeakReferenceMessenger.Default.Send(JsonSerializer.Deserialize(messageJson, CommunicationMessagesContext.Default.DraftFailed));
- break;
- case nameof(DraftMapped):
- WeakReferenceMessenger.Default.Send(JsonSerializer.Deserialize(messageJson, CommunicationMessagesContext.Default.DraftMapped));
- break;
- case nameof(FolderRenamed):
- WeakReferenceMessenger.Default.Send(JsonSerializer.Deserialize(messageJson, CommunicationMessagesContext.Default.FolderRenamed));
- break;
- case nameof(FolderSynchronizationEnabled):
- WeakReferenceMessenger.Default.Send(JsonSerializer.Deserialize(messageJson, CommunicationMessagesContext.Default.FolderSynchronizationEnabled));
- break;
- case nameof(MergedInboxRenamed):
- WeakReferenceMessenger.Default.Send(JsonSerializer.Deserialize(messageJson, CommunicationMessagesContext.Default.MergedInboxRenamed));
- break;
- case nameof(AccountSynchronizationCompleted):
- WeakReferenceMessenger.Default.Send(JsonSerializer.Deserialize(messageJson, CommunicationMessagesContext.Default.AccountSynchronizationCompleted));
- break;
- case nameof(RefreshUnreadCountsMessage):
- WeakReferenceMessenger.Default.Send(JsonSerializer.Deserialize(messageJson, CommunicationMessagesContext.Default.RefreshUnreadCountsMessage));
- break;
- case nameof(AccountSynchronizerStateChanged):
- WeakReferenceMessenger.Default.Send(JsonSerializer.Deserialize(messageJson, CommunicationMessagesContext.Default.AccountSynchronizerStateChanged));
- break;
- case nameof(AccountSynchronizationProgressUpdatedMessage):
- WeakReferenceMessenger.Default.Send(JsonSerializer.Deserialize(messageJson, CommunicationMessagesContext.Default.AccountSynchronizationProgressUpdatedMessage));
- break;
- case nameof(AccountFolderConfigurationUpdated):
- WeakReferenceMessenger.Default.Send(JsonSerializer.Deserialize(messageJson, CommunicationMessagesContext.Default.AccountFolderConfigurationUpdated));
- break;
- case nameof(CopyAuthURLRequested):
- WeakReferenceMessenger.Default.Send(JsonSerializer.Deserialize(messageJson, CommunicationMessagesContext.Default.CopyAuthURLRequested));
- break;
- case nameof(NewMailSynchronizationRequested):
- WeakReferenceMessenger.Default.Send(JsonSerializer.Deserialize(messageJson, CommunicationMessagesContext.Default.NewMailSynchronizationRequested));
- break;
- case nameof(AccountCacheResetMessage):
- WeakReferenceMessenger.Default.Send(JsonSerializer.Deserialize(messageJson, CommunicationMessagesContext.Default.AccountCacheResetMessage));
- break;
- default:
- throw new Exception("Invalid data type name passed to client.");
- }
- }
-
- private void ServerDisconnected(AppServiceConnection sender, AppServiceClosedEventArgs args)
- {
- Log.Information("Server disconnected.");
- }
-
- public async Task QueueRequestAsync(IRequestBase request, Guid accountId)
- {
- var queuePackage = new ServerRequestPackage(accountId, request);
-
- var queueResponse = await GetResponseInternalAsync(queuePackage, new Dictionary()
- {
- { MessageConstants.MessageDataRequestAccountIdKey, accountId }
- });
-
- queueResponse.ThrowIfFailed();
- }
-
- public Task> GetResponseAsync(TRequestType message, CancellationToken cancellationToken = default) where TRequestType : IClientMessage
- => GetResponseInternalAsync(message, cancellationToken: cancellationToken);
-
- [RequiresDynamicCode("Calls System.Text.Json.JsonSerializer.Serialize(TValue, JsonSerializerOptions)")]
- [RequiresUnreferencedCode("Calls System.Text.Json.JsonSerializer.Serialize(TValue, JsonSerializerOptions)")]
- private async Task> GetResponseInternalAsync(TRequestType message,
- Dictionary parameters = null,
- CancellationToken cancellationToken = default)
- {
- if (Status != WinoServerConnectionStatus.Connected)
- await ConnectAsync();
-
- if (Connection == null) return WinoServerResponse.CreateErrorResponse("Server connection is not established.");
-
- string serializedMessage = string.Empty;
-
- try
- {
- serializedMessage = JsonSerializer.Serialize(message, _jsonSerializerOptions);
- }
- catch (Exception serializationException)
- {
- Logger.Error(serializationException, $"Failed to serialize client message for sending.");
- return WinoServerResponse.CreateErrorResponse($"Failed to serialize message.\n{serializationException.Message}");
- }
-
- AppServiceResponse response = null;
-
- try
- {
- var valueSet = new ValueSet
- {
- { MessageConstants.MessageTypeKey, (int)MessageType.ServerMessage },
- { MessageConstants.MessageDataKey, serializedMessage },
- { MessageConstants.MessageDataTypeKey, message.GetType().Name }
- };
-
- // Add additional parameters into ValueSet
- if (parameters != null)
- {
- foreach (var item in parameters)
- {
- valueSet.Add(item.Key, item.Value);
- }
- }
-
- response = await Connection.SendMessageAsync(valueSet).AsTask(cancellationToken);
- }
- catch (OperationCanceledException)
- {
- return WinoServerResponse.CreateErrorResponse($"Request is canceled by client.");
- }
- catch (Exception serverSendException)
- {
- Logger.Error(serverSendException, $"Failed to send message to server.");
- return WinoServerResponse.CreateErrorResponse($"Failed to send message to server.\n{serverSendException.Message}");
- }
-
- // It should be always Success.
- if (response.Status != AppServiceResponseStatus.Success)
- return WinoServerResponse.CreateErrorResponse($"Wino Server responded with '{response.Status}' status to message delivery.");
-
- // All responses must contain a message data.
- if (!(response.Message.TryGetValue(MessageConstants.MessageDataKey, out object messageDataObject) && messageDataObject is string messageJson))
- return WinoServerResponse.CreateErrorResponse("Server response did not contain message data.");
-
- // Try deserialize the message data.
- try
- {
- return JsonSerializer.Deserialize>(messageJson);
- }
- catch (Exception jsonDeserializationError)
- {
- Logger.Error(jsonDeserializationError, $"Failed to deserialize server response message data.");
- return WinoServerResponse.CreateErrorResponse($"Failed to deserialize Wino server response message data.\n{jsonDeserializationError.Message}");
- }
- }
-
- public void Receive(WinoServerConnectionEstablished message)
- => ConnectingHandle?.TrySetResult(true);
-}
diff --git a/Wino.Core.WinUI/WinoApplication.cs b/Wino.Core.WinUI/WinoApplication.cs
index e5a9e045..d1dd2f2c 100644
--- a/Wino.Core.WinUI/WinoApplication.cs
+++ b/Wino.Core.WinUI/WinoApplication.cs
@@ -32,7 +32,6 @@ public abstract class WinoApplication : Application, IRecipient
public IServiceProvider Services { get; }
protected IWinoLogger LogInitializer { get; }
protected IApplicationConfiguration AppConfiguration { get; }
- protected IWinoServerConnectionManager AppServiceConnectionManager { get; }
public INewThemeService NewThemeService { get; }
public IUnderlyingThemeService UnderlyingThemeService { get; }
public IThumbnailService ThumbnailService { get; }
@@ -54,7 +53,6 @@ public abstract class WinoApplication : Application, IRecipient
LogInitializer = Services.GetService();
AppConfiguration = Services.GetService();
- AppServiceConnectionManager = Services.GetService>();
NewThemeService = Services.GetService();
DatabaseService = Services.GetService();
TranslationService = Services.GetService();
diff --git a/Wino.Core/Services/WinoRequestDelegator.cs b/Wino.Core/Services/WinoRequestDelegator.cs
index 38003c62..e57c2b0f 100644
--- a/Wino.Core/Services/WinoRequestDelegator.cs
+++ b/Wino.Core/Services/WinoRequestDelegator.cs
@@ -138,15 +138,8 @@ public class WinoRequestDelegator : IWinoRequestDelegator
private async Task QueueRequestAsync(IRequestBase request, Guid accountId)
{
- try
- {
- await EnsureServerConnectedAsync();
- await _winoServerConnectionManager.QueueRequestAsync(request, accountId);
- }
- catch (WinoServerException serverException)
- {
- _dialogService.InfoBarMessage("Wino Server Exception", serverException.Message, InfoBarMessageType.Error);
- }
+ await EnsureServerConnectedAsync();
+ await _winoServerConnectionManager.QueueRequestAsync(request, accountId);
}
private async Task QueueSynchronizationAsync(Guid accountId)
diff --git a/Wino.Mail.ViewModels/AppPreferencesPageViewModel.cs b/Wino.Mail.ViewModels/AppPreferencesPageViewModel.cs
index 3a7489d0..c460db6e 100644
--- a/Wino.Mail.ViewModels/AppPreferencesPageViewModel.cs
+++ b/Wino.Mail.ViewModels/AppPreferencesPageViewModel.cs
@@ -1,5 +1,4 @@
using System.Collections.Generic;
-using System.ComponentModel;
using System.Threading.Tasks;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
@@ -7,7 +6,6 @@ using Wino.Core.Domain;
using Wino.Core.Domain.Enums;
using Wino.Core.Domain.Interfaces;
using Wino.Core.Domain.Models.Navigation;
-using Wino.Messaging.Server;
namespace Wino.Mail.ViewModels;
@@ -15,9 +13,6 @@ public partial class AppPreferencesPageViewModel : MailBaseViewModel
{
public IPreferencesService PreferencesService { get; }
- [ObservableProperty]
- private List _appTerminationBehavior;
-
[ObservableProperty]
public partial List SearchModes { get; set; }
@@ -41,18 +36,6 @@ public partial class AppPreferencesPageViewModel : MailBaseViewModel
public bool IsStartupBehaviorDisabled => !IsStartupBehaviorEnabled;
public bool IsStartupBehaviorEnabled => StartupBehaviorResult == StartupBehaviorResult.Enabled;
- private string _selectedAppTerminationBehavior;
- public string SelectedAppTerminationBehavior
- {
- get => _selectedAppTerminationBehavior;
- set
- {
- SetProperty(ref _selectedAppTerminationBehavior, value);
-
- PreferencesService.ServerTerminationBehavior = (ServerBackgroundMode)AppTerminationBehavior.IndexOf(value);
- }
- }
-
private string _selectedDefaultSearchMode;
public string SelectedDefaultSearchMode
{
@@ -66,35 +49,22 @@ public partial class AppPreferencesPageViewModel : MailBaseViewModel
}
private readonly IMailDialogService _dialogService;
- private readonly IWinoServerConnectionManager _winoServerConnectionManager;
private readonly IStartupBehaviorService _startupBehaviorService;
public AppPreferencesPageViewModel(IMailDialogService dialogService,
IPreferencesService preferencesService,
- IWinoServerConnectionManager winoServerConnectionManager,
IStartupBehaviorService startupBehaviorService)
{
_dialogService = dialogService;
PreferencesService = preferencesService;
- _winoServerConnectionManager = winoServerConnectionManager;
_startupBehaviorService = startupBehaviorService;
- // Load the app termination behavior options
-
- _appTerminationBehavior =
- [
- Translator.SettingsAppPreferences_ServerBackgroundingMode_MinimizeTray_Title, // "Minimize to tray"
- Translator.SettingsAppPreferences_ServerBackgroundingMode_Invisible_Title, // "Invisible"
- Translator.SettingsAppPreferences_ServerBackgroundingMode_Terminate_Title // "Terminate"
- ];
-
SearchModes =
[
Translator.SettingsAppPreferences_SearchMode_Local,
Translator.SettingsAppPreferences_SearchMode_Online
];
- SelectedAppTerminationBehavior = _appTerminationBehavior[(int)PreferencesService.ServerTerminationBehavior];
SelectedDefaultSearchMode = SearchModes[(int)PreferencesService.DefaultSearchMode];
EmailSyncIntervalMinutes = PreferencesService.EmailSyncIntervalMinutes;
}
@@ -152,20 +122,7 @@ public partial class AppPreferencesPageViewModel : MailBaseViewModel
}
}
- protected override async void OnPropertyChanged(PropertyChangedEventArgs e)
- {
- base.OnPropertyChanged(e);
- if (e.PropertyName == nameof(SelectedAppTerminationBehavior))
- {
- var terminationModeChangedResult = await _winoServerConnectionManager.GetResponseAsync(new ServerTerminationModeChanged(PreferencesService.ServerTerminationBehavior));
-
- if (!terminationModeChangedResult.IsSuccess)
- {
- _dialogService.InfoBarMessage(Translator.GeneralTitle_Error, terminationModeChangedResult.Message, InfoBarMessageType.Error);
- }
- }
- }
public override async void OnNavigatedTo(NavigationMode mode, object parameters)
{
diff --git a/Wino.Mail.ViewModels/AppShellViewModel.cs b/Wino.Mail.ViewModels/AppShellViewModel.cs
index 089acd49..90b1de33 100644
--- a/Wino.Mail.ViewModels/AppShellViewModel.cs
+++ b/Wino.Mail.ViewModels/AppShellViewModel.cs
@@ -60,7 +60,6 @@ public partial class AppShellViewModel : MailBaseViewModel,
private const string IsActivateStartupLaunchAskedKey = nameof(IsActivateStartupLaunchAskedKey);
public IStatePersistanceService StatePersistenceService { get; }
- public IWinoServerConnectionManager ServerConnectionManager { get; }
public IPreferencesService PreferencesService { get; }
public INavigationService NavigationService { get; }
@@ -81,9 +80,6 @@ public partial class AppShellViewModel : MailBaseViewModel,
private readonly SemaphoreSlim accountInitFolderUpdateSlim = new SemaphoreSlim(1);
- [ObservableProperty]
- private WinoServerConnectionStatus activeConnectionStatus;
-
public AppShellViewModel(IMailDialogService dialogService,
INavigationService navigationService,
IMimeFileService mimeFileService,
@@ -98,21 +94,10 @@ public partial class AppShellViewModel : MailBaseViewModel,
IWinoRequestDelegator winoRequestDelegator,
IFolderService folderService,
IStatePersistanceService statePersistanceService,
- IWinoServerConnectionManager serverConnectionManager,
IConfigurationService configurationService,
IStartupBehaviorService startupBehaviorService)
{
StatePersistenceService = statePersistanceService;
- ServerConnectionManager = serverConnectionManager;
-
- ActiveConnectionStatus = serverConnectionManager.Status;
- ServerConnectionManager.StatusChanged += async (sender, status) =>
- {
- await ExecuteUIThread(() =>
- {
- ActiveConnectionStatus = status;
- });
- };
PreferencesService = preferencesService;
_dialogService = dialogService;
@@ -132,9 +117,6 @@ public partial class AppShellViewModel : MailBaseViewModel,
_winoRequestDelegator = winoRequestDelegator;
}
- [RelayCommand]
- private Task ReconnectServerAsync() => ServerConnectionManager.ConnectAsync();
-
protected override void OnDispatcherAssigned()
{
base.OnDispatcherAssigned();
diff --git a/Wino.Mail.ViewModels/MailListPageViewModel.cs b/Wino.Mail.ViewModels/MailListPageViewModel.cs
index 739fe24d..78e0c54b 100644
--- a/Wino.Mail.ViewModels/MailListPageViewModel.cs
+++ b/Wino.Mail.ViewModels/MailListPageViewModel.cs
@@ -22,7 +22,6 @@ using Wino.Core.Domain.Models.Folders;
using Wino.Core.Domain.Models.MailItem;
using Wino.Core.Domain.Models.Menus;
using Wino.Core.Domain.Models.Reader;
-using Wino.Core.Domain.Models.Server;
using Wino.Core.Domain.Models.Synchronization;
using Wino.Mail.ViewModels.Collections;
using Wino.Mail.ViewModels.Data;
diff --git a/Wino.Mail.WinUI/Views/Settings/AppPreferencesPage.xaml b/Wino.Mail.WinUI/Views/Settings/AppPreferencesPage.xaml
index e0d7f809..a8099356 100644
--- a/Wino.Mail.WinUI/Views/Settings/AppPreferencesPage.xaml
+++ b/Wino.Mail.WinUI/Views/Settings/AppPreferencesPage.xaml
@@ -23,13 +23,6 @@
-
-
-
-
-
-
-
diff --git a/Wino.Mail/App.xaml.cs b/Wino.Mail/App.xaml.cs
index dfa86da8..d26037ca 100644
--- a/Wino.Mail/App.xaml.cs
+++ b/Wino.Mail/App.xaml.cs
@@ -52,18 +52,8 @@ public sealed partial class App : WinoApplication,
// We must restore it.
// Server might be running already, but re-launching it will trigger a new connection attempt.
- try
- {
- await AppServiceConnectionManager.ConnectAsync();
- }
- catch (OperationCanceledException)
- {
- // Ignore
- }
- catch (Exception ex)
- {
- Log.Error(ex, "Failed to connect to server after resuming the app.");
- }
+ // Server connection is now handled by the empty implementation
+ // No need to reconnect after resuming
}
public override IServiceProvider ConfigureServices()
@@ -137,13 +127,10 @@ public sealed partial class App : WinoApplication,
if (appServiceTriggerDetails.CallerPackageFamilyName == Package.Current.Id.FamilyName)
{
// Connection established from the fulltrust process
+ // This is no longer needed with the empty connection manager implementation
connectionBackgroundTaskDeferral = args.TaskInstance.GetDeferral();
args.TaskInstance.Canceled += OnConnectionBackgroundTaskCanceled;
-
- AppServiceConnectionManager.Connection = appServiceTriggerDetails.AppServiceConnection;
-
- WeakReferenceMessenger.Default.Send(new WinoServerConnectionEstablished());
}
}
else if (args.TaskInstance.TriggerDetails is ToastNotificationActionTriggerDetail toastNotificationActionTriggerDetail)
@@ -222,24 +209,13 @@ public sealed partial class App : WinoApplication,
connectionBackgroundTaskDeferral?.Complete();
connectionBackgroundTaskDeferral = null;
-
- AppServiceConnectionManager.Connection = null;
}
public async void Receive(NewMailSynchronizationRequested message)
{
- try
- {
- var synchronizationResultResponse = await AppServiceConnectionManager.GetResponseAsync(message);
- synchronizationResultResponse.ThrowIfFailed();
- }
- catch (WinoServerException serverException)
- {
- // TODO: Exception context is lost.
- var dialogService = Services.GetService();
-
- dialogService.InfoBarMessage(Translator.Info_SyncFailedTitle, serverException.Message, InfoBarMessageType.Error);
- }
+ // Synchronization is now handled elsewhere
+ // The empty connection manager doesn't perform actual sync operations
+ await Task.CompletedTask;
}
protected override async void OnApplicationCloseRequested(object sender, SystemNavigationCloseRequestedPreviewEventArgs e)
@@ -262,20 +238,7 @@ public sealed partial class App : WinoApplication,
bool? isGoToAppPreferencesRequested = null;
- if (preferencesService.ServerTerminationBehavior == ServerBackgroundMode.Terminate)
- {
- // Starting the server is fine, but check if server termination behavior is set to terminate.
- // This state will kill the server once the app is terminated.
-
- isGoToAppPreferencesRequested = await dialogService.ShowWinoCustomMessageDialogAsync(Translator.AppCloseBackgroundSynchronizationWarningTitle,
- $"{Translator.AppCloseTerminateBehaviorWarningMessageFirstLine}\n{Translator.AppCloseTerminateBehaviorWarningMessageSecondLine}\n\n{Translator.AppCloseTerminateBehaviorWarningMessageThirdLine}",
- Translator.Buttons_Yes,
- WinoCustomMessageDialogIcon.Warning,
- Translator.Buttons_No,
- "DontAskTerminateServerBehavior");
- }
-
- if (isGoToAppPreferencesRequested == null && currentStartupBehavior != StartupBehaviorResult.Enabled)
+ if (currentStartupBehavior != StartupBehaviorResult.Enabled)
{
// Startup behavior is not enabled.
@@ -292,21 +255,6 @@ public sealed partial class App : WinoApplication,
WeakReferenceMessenger.Default.Send(new NavigateAppPreferencesRequested());
e.Handled = true;
}
- else if (preferencesService.ServerTerminationBehavior == ServerBackgroundMode.Terminate)
- {
- try
- {
- var isServerKilled = await AppServiceConnectionManager.GetResponseAsync(new TerminateServerRequested());
-
- isServerKilled.ThrowIfFailed();
-
- Log.Information("Server is killed.");
- }
- catch (Exception ex)
- {
- Log.Error(ex, "Failed to kill server.");
- }
- }
deferral.Complete();
}
diff --git a/Wino.Mail/AppShell.xaml b/Wino.Mail/AppShell.xaml
index 10117bf8..2e115ad6 100644
--- a/Wino.Mail/AppShell.xaml
+++ b/Wino.Mail/AppShell.xaml
@@ -457,7 +457,6 @@
Grid.ColumnSpan="2"
BackButtonClicked="BackButtonClicked"
Canvas.ZIndex="150"
- ConnectionStatus="{x:Bind ViewModel.ActiveConnectionStatus, Mode=OneWay}"
CoreWindowText="{x:Bind ViewModel.StatePersistenceService.CoreWindowTitle, Mode=OneWay}"
IsBackButtonVisible="{x:Bind ViewModel.StatePersistenceService.IsBackButtonVisible, Mode=OneWay}"
IsDragArea="True"
@@ -466,7 +465,6 @@
NavigationViewDisplayMode="{x:Bind navigationView.DisplayMode, Mode=OneWay}"
OpenPaneLength="{x:Bind ViewModel.StatePersistenceService.OpenPaneLength, Mode=OneWay}"
ReadingPaneLength="{x:Bind ViewModel.StatePersistenceService.MailListPaneLength, Mode=OneWay}"
- ReconnectCommand="{x:Bind ViewModel.ReconnectServerCommand}"
SystemReserved="180" />
diff --git a/Wino.Mail/Views/Settings/AppPreferencesPage.xaml b/Wino.Mail/Views/Settings/AppPreferencesPage.xaml
index d9cb3fc2..eb34d891 100644
--- a/Wino.Mail/Views/Settings/AppPreferencesPage.xaml
+++ b/Wino.Mail/Views/Settings/AppPreferencesPage.xaml
@@ -23,13 +23,6 @@
-
-
-
-
-
-
-
diff --git a/Wino.Messages/Server/ServerTerminationModeChanged.cs b/Wino.Messages/Server/ServerTerminationModeChanged.cs
deleted file mode 100644
index 7d0ef5ed..00000000
--- a/Wino.Messages/Server/ServerTerminationModeChanged.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using Wino.Core.Domain.Enums;
-using Wino.Core.Domain.Interfaces;
-
-namespace Wino.Messaging.Server;
-
-///
-/// App close behavior for server is changed.
-///
-/// New server background mode.
-public record ServerTerminationModeChanged(ServerBackgroundMode ServerBackgroundMode) : IClientMessage;