about summary refs log tree commit diff
path: root/MatrixRoomUtils.Desktop
diff options
context:
space:
mode:
Diffstat (limited to 'MatrixRoomUtils.Desktop')
-rw-r--r--MatrixRoomUtils.Desktop/App.axaml10
-rw-r--r--MatrixRoomUtils.Desktop/App.axaml.cs49
-rw-r--r--MatrixRoomUtils.Desktop/Components/NavigationStack.axaml12
-rw-r--r--MatrixRoomUtils.Desktop/Components/NavigationStack.axaml.cs72
-rw-r--r--MatrixRoomUtils.Desktop/Components/Pages/RoomList.axaml21
-rw-r--r--MatrixRoomUtils.Desktop/Components/Pages/RoomList.axaml.cs15
-rw-r--r--MatrixRoomUtils.Desktop/Components/RoomListEntry.axaml16
-rw-r--r--MatrixRoomUtils.Desktop/Components/RoomListEntry.axaml.cs74
-rw-r--r--MatrixRoomUtils.Desktop/LoginWindow.axaml25
-rw-r--r--MatrixRoomUtils.Desktop/LoginWindow.axaml.cs37
-rw-r--r--MatrixRoomUtils.Desktop/MRUDesktopConfiguration.cs47
-rw-r--r--MatrixRoomUtils.Desktop/MRUStorageWrapper.cs123
-rw-r--r--MatrixRoomUtils.Desktop/MainWindow.axaml16
-rw-r--r--MatrixRoomUtils.Desktop/MainWindow.axaml.cs57
-rw-r--r--MatrixRoomUtils.Desktop/MatrixRoomUtils.Desktop.csproj50
-rw-r--r--MatrixRoomUtils.Desktop/Program.cs33
-rw-r--r--MatrixRoomUtils.Desktop/Properties/launchSettings.json27
-rw-r--r--MatrixRoomUtils.Desktop/SentryService.cs29
-rw-r--r--MatrixRoomUtils.Desktop/app.manifest18
-rw-r--r--MatrixRoomUtils.Desktop/appsettings.Development.json14
-rw-r--r--MatrixRoomUtils.Desktop/appsettings.json13
21 files changed, 0 insertions, 758 deletions
diff --git a/MatrixRoomUtils.Desktop/App.axaml b/MatrixRoomUtils.Desktop/App.axaml
deleted file mode 100644

index 9c99838..0000000 --- a/MatrixRoomUtils.Desktop/App.axaml +++ /dev/null
@@ -1,10 +0,0 @@ -<Application xmlns="https://github.com/avaloniaui" - xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" - x:Class="MatrixRoomUtils.Desktop.App" - RequestedThemeVariant="Default"> - <!-- "Default" ThemeVariant follows system theme variant. "Dark" or "Light" are other available options. --> - - <Application.Styles> - <FluentTheme /> - </Application.Styles> -</Application> \ No newline at end of file diff --git a/MatrixRoomUtils.Desktop/App.axaml.cs b/MatrixRoomUtils.Desktop/App.axaml.cs deleted file mode 100644
index aeb154c..0000000 --- a/MatrixRoomUtils.Desktop/App.axaml.cs +++ /dev/null
@@ -1,49 +0,0 @@ -using Avalonia; -using Avalonia.Controls.ApplicationLifetimes; -using Avalonia.Markup.Xaml; -using Avalonia.Styling; -using LibMatrix.Services; -using MatrixRoomUtils.Abstractions; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; - -namespace MatrixRoomUtils.Desktop; - -public partial class App : Application { - public IHost host { get; set; } - - public override void OnFrameworkInitializationCompleted() { - host = Host.CreateDefaultBuilder().ConfigureServices((ctx, services) => { - services.AddSingleton<MRUDesktopConfiguration>(); - services.AddSingleton<SentryService>(); - services.AddSingleton<TieredStorageService>(x => - new TieredStorageService( - cacheStorageProvider: new FileStorageProvider(x.GetService<MRUDesktopConfiguration>()!.CacheStoragePath), - dataStorageProvider: new FileStorageProvider(x.GetService<MRUDesktopConfiguration>()!.DataStoragePath) - ) - ); - services.AddSingleton(new RoryLibMatrixConfiguration { - AppName = "MatrixRoomUtils.Desktop" - }); - services.AddRoryLibMatrixServices(); - // foreach (var commandClass in new ClassCollector<ICommand>().ResolveFromAllAccessibleAssemblies()) { - // Console.WriteLine($"Adding command {commandClass.Name}"); - // services.AddScoped(typeof(ICommand), commandClass); - // } - services.AddSingleton<MRUStorageWrapper>(); - services.AddSingleton<MainWindow>(); - services.AddSingleton(this); - }).UseConsoleLifetime().Build(); - - if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) { - var scopeFac = host.Services.GetService<IServiceScopeFactory>(); - var scope = scopeFac.CreateScope(); - desktop.MainWindow = scope.ServiceProvider.GetRequiredService<MainWindow>(); - } - - if(Environment.GetEnvironmentVariable("AVALONIA_THEME")?.Equals("dark", StringComparison.OrdinalIgnoreCase) ?? false) - RequestedThemeVariant = ThemeVariant.Dark; - - base.OnFrameworkInitializationCompleted(); - } -} \ No newline at end of file diff --git a/MatrixRoomUtils.Desktop/Components/NavigationStack.axaml b/MatrixRoomUtils.Desktop/Components/NavigationStack.axaml deleted file mode 100644
index bc6b75d..0000000 --- a/MatrixRoomUtils.Desktop/Components/NavigationStack.axaml +++ /dev/null
@@ -1,12 +0,0 @@ -<UserControl xmlns="https://github.com/avaloniaui" - xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" - xmlns:d="http://schemas.microsoft.com/expression/blend/2008" - xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" - x:Class="MatrixRoomUtils.Desktop.Components.NavigationStack"> - <StackPanel x:Name="dock"> - <Label>NagivationStack</Label> - <StackPanel x:Name="navPanel" Orientation="Horizontal"></StackPanel> - <ContentControl x:Name="content"></ContentControl> - </StackPanel> -</UserControl> \ No newline at end of file diff --git a/MatrixRoomUtils.Desktop/Components/NavigationStack.axaml.cs b/MatrixRoomUtils.Desktop/Components/NavigationStack.axaml.cs deleted file mode 100644
index 92c617b..0000000 --- a/MatrixRoomUtils.Desktop/Components/NavigationStack.axaml.cs +++ /dev/null
@@ -1,72 +0,0 @@ -using Avalonia.Controls; -using Avalonia.Interactivity; -using Avalonia.Markup.Xaml; - -namespace MatrixRoomUtils.Desktop.Components; - -public partial class NavigationStack : UserControl { - public NavigationStack() { - InitializeComponent(); - } - - // private void InitializeComponent() { - // AvaloniaXamlLoader.Load(this); - // buildView(); - // } - - protected override void OnLoaded(RoutedEventArgs e) { - base.OnLoaded(e); - buildView(); - } - - private void buildView() { - if (navPanel is null) { - Console.WriteLine("NavigationStack buildView called while navpanel is null!"); - // await Task.Delay(100); - // if (navPanel is null) - // await buildView(); - // else Console.WriteLine("navpanel is not null!"); - } - navPanel.Children.Clear(); - foreach (var item in _stack) { - Button btn = new() { - Content = item.Name - }; - btn.Click += (_, _) => { - PopTo(_stack.IndexOf(item)); - buildView(); - }; - navPanel.Children.Add(btn); - } - content.Content = Current?.View ?? new UserControl(); - } - - - public class NavigationStackItem { - public string Name { get; set; } - public string Description { get; set; } = ""; - public UserControl View { get; set; } - } - - private List<NavigationStackItem> _stack = new(); - - public NavigationStackItem? Current => _stack.LastOrDefault(); - - public void Push(string name, UserControl view) { - _stack.Add(new NavigationStackItem { - Name = name, - View = view - }); - buildView(); - } - - public void Pop() { - _stack.RemoveAt(_stack.Count - 1); - buildView(); - } - - public void PopTo(int index) { - _stack.RemoveRange(index, _stack.Count - index); - buildView(); - } -} diff --git a/MatrixRoomUtils.Desktop/Components/Pages/RoomList.axaml b/MatrixRoomUtils.Desktop/Components/Pages/RoomList.axaml deleted file mode 100644
index 0e43d99..0000000 --- a/MatrixRoomUtils.Desktop/Components/Pages/RoomList.axaml +++ /dev/null
@@ -1,21 +0,0 @@ -<UserControl xmlns="https://github.com/avaloniaui" - xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" - xmlns:d="http://schemas.microsoft.com/expression/blend/2008" - xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - xmlns:components="clr-namespace:MatrixRoomUtils.Desktop.Components.Pages" - xmlns:components1="clr-namespace:MatrixRoomUtils.Desktop.Components" - xmlns:abstractions="clr-namespace:MatrixRoomUtils.Abstractions;assembly=MatrixRoomUtils.Abstractions" - - mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" - x:Class="MatrixRoomUtils.Desktop.Components.Pages.RoomList" - x:DataType="components:RoomList" - DataContext="{Binding $self}" - > - <ListBox ItemsSource="{Binding Rooms}"> - <ListBox.ItemTemplate> - <DataTemplate DataType="abstractions:RoomInfo"> - <components1:RoomListEntry Room="{Binding Path=.}"/> - </DataTemplate> - </ListBox.ItemTemplate> - </ListBox> -</UserControl> diff --git a/MatrixRoomUtils.Desktop/Components/Pages/RoomList.axaml.cs b/MatrixRoomUtils.Desktop/Components/Pages/RoomList.axaml.cs deleted file mode 100644
index 53c3063..0000000 --- a/MatrixRoomUtils.Desktop/Components/Pages/RoomList.axaml.cs +++ /dev/null
@@ -1,15 +0,0 @@ -using System.Collections.ObjectModel; -using Avalonia; -using Avalonia.Controls; -using Avalonia.Markup.Xaml; -using MatrixRoomUtils.Abstractions; - -namespace MatrixRoomUtils.Desktop.Components.Pages; - -public partial class RoomList : UserControl { - private ObservableCollection<RoomInfo> Rooms { get; set; } = new(); - - public RoomList() { - InitializeComponent(); - } -} \ No newline at end of file diff --git a/MatrixRoomUtils.Desktop/Components/RoomListEntry.axaml b/MatrixRoomUtils.Desktop/Components/RoomListEntry.axaml deleted file mode 100644
index db22ccc..0000000 --- a/MatrixRoomUtils.Desktop/Components/RoomListEntry.axaml +++ /dev/null
@@ -1,16 +0,0 @@ -<UserControl xmlns="https://github.com/avaloniaui" - xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" - xmlns:d="http://schemas.microsoft.com/expression/blend/2008" - xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - xmlns:components="clr-namespace:MatrixRoomUtils.Desktop.Components" - mc:Ignorable="d" d:DesignWidth="250" d:DesignHeight="32" - x:Class="MatrixRoomUtils.Desktop.Components.RoomListEntry" - - x:DataType="components:RoomListEntry" - DataContext="{Binding $self}" - > - <StackPanel Orientation="Horizontal"> - <Image MaxWidth="64" x:Name="RoomIcon"></Image> - <Label x:Name="RoomName" Content="{Binding Room.RoomName}"></Label> - </StackPanel> -</UserControl> diff --git a/MatrixRoomUtils.Desktop/Components/RoomListEntry.axaml.cs b/MatrixRoomUtils.Desktop/Components/RoomListEntry.axaml.cs deleted file mode 100644
index 73115a2..0000000 --- a/MatrixRoomUtils.Desktop/Components/RoomListEntry.axaml.cs +++ /dev/null
@@ -1,74 +0,0 @@ -using Avalonia.Controls; -using Avalonia.Interactivity; -using Avalonia.Media.Imaging; -using LibMatrix; -using LibMatrix.EventTypes.Spec.State; -using LibMatrix.EventTypes.Spec.State.RoomInfo; -using LibMatrix.Helpers; -using LibMatrix.Interfaces.Services; -using LibMatrix.Services; -using MatrixRoomUtils.Abstractions; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; - -namespace MatrixRoomUtils.Desktop.Components; - -public partial class RoomListEntry : UserControl { - public RoomInfo Room { get; set; } - - public RoomListEntry() { - InitializeComponent(); - } - - protected override void OnLoaded(RoutedEventArgs e) { - base.OnLoaded(e); - RoomName.Content = Room.Room.RoomId; - Task.WhenAll(GetRoomName(), GetRoomIcon()); - } - - private async Task GetRoomName() { - try { - var nameEvent = await Room.GetStateEvent("m.room.name"); - if (nameEvent?.TypedContent is RoomNameEventContent nameData) - RoomName.Content = nameData.Name; - } - catch (MatrixException e) { - if (e.ErrorCode != "M_NOT_FOUND") - throw; - } - } - - private async Task GetRoomIcon() { - try { - using var hc = new HttpClient(); - var avatarEvent = await Room.GetStateEvent("m.room.avatar"); - if (avatarEvent?.TypedContent is RoomAvatarEventContent avatarData) { - var mxcUrl = avatarData.Url; - var resolvedUrl = await Room.Room.GetResolvedRoomAvatarUrlAsync(); - - // await using var svc = _serviceScopeFactory.CreateAsyncScope(); - // var hs = await svc.ServiceProvider.GetService<MRUStorageWrapper>()?.GetCurrentSessionOrPrompt()!; - // var hsResolver = svc.ServiceProvider.GetService<HomeserverResolverService>(); - // var storage = svc.ServiceProvider.GetService<TieredStorageService>()?.CacheStorageProvider; - // var resolvedUrl = await hsResolver.ResolveMediaUri(hs.ServerName, mxcUrl); - var storage = new FileStorageProvider("cache"); - var storageKey = $"media/{mxcUrl.Replace("mxc://", "").Replace("/", ".")}"; - try { - if (!await storage.ObjectExistsAsync(storageKey)) - await storage.SaveStreamAsync(storageKey, await hc.GetStreamAsync(resolvedUrl)); - - RoomIcon.Source = new Bitmap(await storage.LoadStreamAsync(storageKey) ?? throw new NullReferenceException()); - } - catch (IOException) { } - catch (MatrixException e) { - if (e.ErrorCode != "M_UNKNOWN") - throw; - } - } - } - catch (MatrixException e) { - if (e.ErrorCode != "M_NOT_FOUND") - throw; - } - } -} diff --git a/MatrixRoomUtils.Desktop/LoginWindow.axaml b/MatrixRoomUtils.Desktop/LoginWindow.axaml deleted file mode 100644
index fc0ee6f..0000000 --- a/MatrixRoomUtils.Desktop/LoginWindow.axaml +++ /dev/null
@@ -1,25 +0,0 @@ -<Window xmlns="https://github.com/avaloniaui" - xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" - xmlns:d="http://schemas.microsoft.com/expression/blend/2008" - xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - xmlns:desktop="clr-namespace:MatrixRoomUtils.Desktop" - mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" - Title="LoginWindow" - x:Class="MatrixRoomUtils.Desktop.LoginWindow" - x:DataType="desktop:LoginWindow" - DataContext="{Binding $self}" - SizeToContent="WidthAndHeight" CanResize="False" - MinWidth="250"> - <StackPanel> - <Label>Log in</Label> - <StackPanel Orientation="Horizontal"> - <Label Width="100">User ID</Label> - <TextBox MinWidth="250" Text="{Binding Username, Mode=TwoWay}" /> - </StackPanel> - <StackPanel Orientation="Horizontal"> - <Label Width="100">Password</Label> - <MaskedTextBox MinWidth="250" PasswordChar="*" Text="{Binding Password, Mode=TwoWay}" /> - </StackPanel> - <Button Click="Login">Login</Button> - </StackPanel> -</Window> \ No newline at end of file diff --git a/MatrixRoomUtils.Desktop/LoginWindow.axaml.cs b/MatrixRoomUtils.Desktop/LoginWindow.axaml.cs deleted file mode 100644
index 183c46b..0000000 --- a/MatrixRoomUtils.Desktop/LoginWindow.axaml.cs +++ /dev/null
@@ -1,37 +0,0 @@ -using Avalonia; -using Avalonia.Controls; -using Avalonia.Interactivity; -using Avalonia.Markup.Xaml; -using Avalonia.VisualTree; - -namespace MatrixRoomUtils.Desktop; - -public partial class LoginWindow : Window { - private readonly MRUStorageWrapper _storage; - - public LoginWindow(MRUStorageWrapper storage) { - _storage = storage; - InitializeComponent(); -#if DEBUG - this.AttachDevTools(); -#endif - } - - private void InitializeComponent() { - AvaloniaXamlLoader.Load(this); - } - - public string Username { get; set; } - public string Password { get; set; } - // ReSharper disable once AsyncVoidMethod - private async void Login(object? sender, RoutedEventArgs e) { - var res = await _storage.Login(Username.Split(':')[1], Username.Split(':')[0][1..], Password); - if (res is not null) { - await _storage.AddToken(res); - Close(); - } - else { - Password = ""; - } - } -} diff --git a/MatrixRoomUtils.Desktop/MRUDesktopConfiguration.cs b/MatrixRoomUtils.Desktop/MRUDesktopConfiguration.cs deleted file mode 100644
index c7a311d..0000000 --- a/MatrixRoomUtils.Desktop/MRUDesktopConfiguration.cs +++ /dev/null
@@ -1,47 +0,0 @@ -using System.Collections; -using System.Diagnostics.CodeAnalysis; -using ArcaneLibs.Extensions; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Logging; - -namespace MatrixRoomUtils.Desktop; - -public class MRUDesktopConfiguration { - private static ILogger<MRUDesktopConfiguration> _logger; - - [RequiresUnreferencedCode("Uses reflection binding")] - public MRUDesktopConfiguration(ILogger<MRUDesktopConfiguration> logger, IConfiguration config, HostBuilderContext host) { - _logger = logger; - logger.LogInformation("Loading configuration for environment: {}...", host.HostingEnvironment.EnvironmentName); - config.GetSection("MRUDesktop").Bind(this); - DataStoragePath = ExpandPath(DataStoragePath); - CacheStoragePath = ExpandPath(CacheStoragePath); - } - - public string DataStoragePath { get; set; } = ""; - public string CacheStoragePath { get; set; } = ""; - public string? SentryDsn { get; set; } - - private static string ExpandPath(string path, bool retry = true) { - _logger.LogInformation("Expanding path `{}`", path); - - if (path.StartsWith('~')) { - path = Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), path[1..]); - } - - Environment.GetEnvironmentVariables().Cast<DictionaryEntry>().OrderByDescending(x => x.Key.ToString()!.Length).ToList().ForEach(x => { - path = path.Replace($"${x.Key}", x.Value.ToString()); - }); - - _logger.LogInformation("Expanded path to `{}`", path); - var tries = 0; - while (retry && path.ContainsAnyOf("~$".Split())) { - if (tries++ > 100) - throw new Exception($"Path `{path}` contains unrecognised environment variables"); - path = ExpandPath(path, false); - } - - return path; - } -} diff --git a/MatrixRoomUtils.Desktop/MRUStorageWrapper.cs b/MatrixRoomUtils.Desktop/MRUStorageWrapper.cs deleted file mode 100644
index b69c50d..0000000 --- a/MatrixRoomUtils.Desktop/MRUStorageWrapper.cs +++ /dev/null
@@ -1,123 +0,0 @@ -using Avalonia; -using LibMatrix; -using LibMatrix.Homeservers; -using LibMatrix.Responses; -using LibMatrix.Services; - -namespace MatrixRoomUtils.Desktop; - -public class MRUStorageWrapper(TieredStorageService storageService, HomeserverProviderService homeserverProviderService) { - public async Task<List<LoginResponse>?> GetAllTokens() { - if (!await storageService.DataStorageProvider.ObjectExistsAsync("mru.tokens")) { - return null; - } - return await storageService.DataStorageProvider.LoadObjectAsync<List<LoginResponse>>("mru.tokens") ?? - new List<LoginResponse>(); - } - - public async Task<LoginResponse?> GetCurrentToken() { - if (!await storageService.DataStorageProvider.ObjectExistsAsync("token")) { - return null; - } - var currentToken = await storageService.DataStorageProvider.LoadObjectAsync<LoginResponse>("token"); - var allTokens = await GetAllTokens(); - if (allTokens is null or { Count: 0 }) { - await SetCurrentToken(null); - return null; - } - - if (currentToken is null) { - await SetCurrentToken(currentToken = allTokens[0]); - } - - if (!allTokens.Any(x => x.AccessToken == currentToken.AccessToken)) { - await SetCurrentToken(currentToken = allTokens[0]); - } - - return currentToken; - } - - public async Task AddToken(LoginResponse loginResponse) { - var tokens = await GetAllTokens() ?? new List<LoginResponse>(); - - tokens.Add(loginResponse); - await storageService.DataStorageProvider.SaveObjectAsync("mru.tokens", tokens); - if (await GetCurrentToken() is null) - await SetCurrentToken(loginResponse); - } - - private async Task<AuthenticatedHomeserverGeneric?> GetCurrentSession() { - var token = await GetCurrentToken(); - if (token == null) { - return null; - } - - return await homeserverProviderService.GetAuthenticatedWithToken(token.Homeserver, token.AccessToken); - } - - public async Task<AuthenticatedHomeserverGeneric?> GetCurrentSessionOrPrompt() { - AuthenticatedHomeserverGeneric? session = null; - - try { - //catch if the token is invalid - session = await GetCurrentSession(); - } - catch (MatrixException e) { - if (e.ErrorCode == "M_UNKNOWN_TOKEN") { - var token = await GetCurrentToken(); - // _navigationManager.NavigateTo("/InvalidSession?ctx=" + token.AccessToken); - return null; - } - - throw; - } - - if (session is null) { - // _navigationManager.NavigateTo("/Login"); - var wnd = new LoginWindow(this); - wnd.Position = MainWindow.Instance.Position + new PixelPoint(50, 50); - await wnd.ShowDialog(MainWindow.Instance); - while (wnd.IsVisible) { - await Task.Delay(100); - } - session = await GetCurrentSession(); - } - - return session; - } - - public class Settings { - public DeveloperSettings DeveloperSettings { get; set; } = new(); - } - - public class DeveloperSettings { - public bool EnableLogViewers { get; set; } = false; - public bool EnableConsoleLogging { get; set; } = true; - public bool EnablePortableDevtools { get; set; } = false; - } - - public async Task RemoveToken(LoginResponse auth) { - var tokens = await GetAllTokens(); - if (tokens == null) { - return; - } - - tokens.RemoveAll(x => x.AccessToken == auth.AccessToken); - await storageService.DataStorageProvider.SaveObjectAsync("mru.tokens", tokens); - } - - public async Task SetCurrentToken(LoginResponse? auth) => await storageService.DataStorageProvider.SaveObjectAsync("token", auth); - - public async Task<LoginResponse?> Login(string homeserver, string username, string password) { - try { - return await homeserverProviderService.Login(homeserver, username, password); - } - catch (MatrixException e) { - if (e.ErrorCode == "M_FORBIDDEN") { - return null; - } - - throw; - } - } -} diff --git a/MatrixRoomUtils.Desktop/MainWindow.axaml b/MatrixRoomUtils.Desktop/MainWindow.axaml deleted file mode 100644
index dd807b5..0000000 --- a/MatrixRoomUtils.Desktop/MainWindow.axaml +++ /dev/null
@@ -1,16 +0,0 @@ -<Window xmlns="https://github.com/avaloniaui" - xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" - xmlns:d="http://schemas.microsoft.com/expression/blend/2008" - xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - xmlns:desktop="clr-namespace:MatrixRoomUtils.Desktop" - xmlns:components="clr-namespace:MatrixRoomUtils.Desktop.Components" - mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" - x:Class="MatrixRoomUtils.Desktop.MainWindow" - Title="Rory&amp;::MatrixRoomUtils"> - <!-- <Interaction.Behaviors> --> - <!-- <EventTriggerBehavior EventName="Loaded"> --> - <!-- <InvokeCommandAction Command="{Binding LoadedCommand}"></InvokeCommandAction> --> - <!-- </EventTriggerBehavior> --> - <!-- </Interaction.Behaviors> --> - <components:NavigationStack x:Name="windowContent"/> -</Window> diff --git a/MatrixRoomUtils.Desktop/MainWindow.axaml.cs b/MatrixRoomUtils.Desktop/MainWindow.axaml.cs deleted file mode 100644
index 6ef573e..0000000 --- a/MatrixRoomUtils.Desktop/MainWindow.axaml.cs +++ /dev/null
@@ -1,57 +0,0 @@ -using Avalonia.Controls; -using Avalonia.Interactivity; -using MatrixRoomUtils.Abstractions; -using MatrixRoomUtils.Desktop.Components; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; - -namespace MatrixRoomUtils.Desktop; - -public partial class MainWindow : Window { - private readonly ILogger<MainWindow> _logger; - private readonly IServiceScopeFactory _scopeFactory; - private readonly MRUStorageWrapper _storageWrapper; - private readonly MRUDesktopConfiguration _configuration; - public static MainWindow Instance { get; private set; } = null!; - - public MainWindow(ILogger<MainWindow> logger, IServiceScopeFactory scopeFactory, SentryService _) { - Instance = this; - _logger = logger; - _scopeFactory = scopeFactory; - _configuration = scopeFactory.CreateScope().ServiceProvider.GetRequiredService<MRUDesktopConfiguration>(); - _storageWrapper = scopeFactory.CreateScope().ServiceProvider.GetRequiredService<MRUStorageWrapper>(); - - _logger.LogInformation("Initialising MainWindow"); - - InitializeComponent(); - - _logger.LogInformation("Cache location: {}", _configuration.CacheStoragePath); - _logger.LogInformation("Data location: {}", _configuration.DataStoragePath); - - // for (int i = 0; i < 100; i++) { - // roomList.Children.Add(new RoomListEntry()); - // } - } - - // ReSharper disable once AsyncVoidMethod - protected override async void OnLoaded(RoutedEventArgs e) { - _logger.LogInformation("async onloaded override"); - var hs = await _storageWrapper.GetCurrentSessionOrPrompt(); - var rooms = await hs.GetJoinedRooms(); - foreach (var room in rooms) { - // roomList.Children.Add(new RoomListEntry(_scopeFactory, new RoomInfo(room))); - - windowContent.Push("home", new RoomListEntry() { - Room = new RoomInfo() { - Room = room - } - }); - base.OnLoaded(e); - } - } - - // public Command - // protected void LoadedCommand() { - // _logger.LogInformation("async command"); - // } -} \ No newline at end of file diff --git a/MatrixRoomUtils.Desktop/MatrixRoomUtils.Desktop.csproj b/MatrixRoomUtils.Desktop/MatrixRoomUtils.Desktop.csproj deleted file mode 100644
index 94bf245..0000000 --- a/MatrixRoomUtils.Desktop/MatrixRoomUtils.Desktop.csproj +++ /dev/null
@@ -1,50 +0,0 @@ -<Project Sdk="Microsoft.NET.Sdk"> - <PropertyGroup> - <OutputType>WinExe</OutputType> - <TargetFramework>net8.0</TargetFramework> - <Nullable>enable</Nullable> - <BuiltInComInteropSupport>true</BuiltInComInteropSupport> - <ApplicationManifest>app.manifest</ApplicationManifest> - <AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault> - - <LangVersion>preview</LangVersion> - <ImplicitUsings>enable</ImplicitUsings> - <InvariantGlobalization>true</InvariantGlobalization> -<!-- <PublishTrimmed>true</PublishTrimmed>--> -<!-- <PublishReadyToRun>true</PublishReadyToRun>--> -<!-- <PublishSingleFile>true</PublishSingleFile>--> -<!-- <PublishReadyToRunShowWarnings>true</PublishReadyToRunShowWarnings>--> -<!-- <PublishTrimmedShowLinkerSizeComparison>true</PublishTrimmedShowLinkerSizeComparison>--> -<!-- <PublishTrimmedShowLinkerSizeComparisonWarnings>true</PublishTrimmedShowLinkerSizeComparisonWarnings>--> - </PropertyGroup> - - - <ItemGroup> - <PackageReference Include="Avalonia" Version="11.0.6" /> - <PackageReference Include="Avalonia.Desktop" Version="11.0.6" /> - <PackageReference Include="Avalonia.Fonts.Inter" Version="11.0.6" /> - <PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.6" /> - <!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.--> - <PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.6" /> - <PackageReference Include="Sentry" Version="3.36.0" /> - </ItemGroup> - - - - - <ItemGroup> - <PackageReference Include="Avalonia.Xaml.Behaviors" Version="11.0.5" /> - <PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" /> - </ItemGroup> - <ItemGroup> - <Content Include="appsettings*.json"> - <CopyToOutputDirectory>Always</CopyToOutputDirectory> - </Content> - <Content Update="appsettings.Local.json"> - <CopyToOutputDirectory>Always</CopyToOutputDirectory> - </Content> - </ItemGroup> - <ItemGroup> - <ProjectReference Include="..\MatrixRoomUtils.Abstractions\MatrixRoomUtils.Abstractions.csproj" /> - </ItemGroup> -</Project> diff --git a/MatrixRoomUtils.Desktop/Program.cs b/MatrixRoomUtils.Desktop/Program.cs deleted file mode 100644
index aa1d9d3..0000000 --- a/MatrixRoomUtils.Desktop/Program.cs +++ /dev/null
@@ -1,33 +0,0 @@ -using Avalonia; -using Microsoft.Extensions.Hosting; -using Tmds.DBus.Protocol; - -namespace MatrixRoomUtils.Desktop; - -internal class Program { - private static IHost appHost; - // Initialization code. Don't use any Avalonia, third-party APIs or any - // SynchronizationContext-reliant code before AppMain is called: things aren't initialized - // yet and stuff might break. - // [STAThread] - public static Task Main(string[] args) { - try { - BuildAvaloniaApp() - .StartWithClassicDesktopLifetime(args); - } - catch (DBusException e) { } - catch (Exception e) { - Console.WriteLine(e); - throw; - } - - return Task.CompletedTask; - } - - // Avalonia configuration, don't remove; also used by visual designer. - public static AppBuilder BuildAvaloniaApp() - => AppBuilder.Configure<App>() - .UsePlatformDetect() - .WithInterFont() - .LogToTrace(); -} diff --git a/MatrixRoomUtils.Desktop/Properties/launchSettings.json b/MatrixRoomUtils.Desktop/Properties/launchSettings.json deleted file mode 100644
index 36405e8..0000000 --- a/MatrixRoomUtils.Desktop/Properties/launchSettings.json +++ /dev/null
@@ -1,27 +0,0 @@ -{ - "$schema": "http://json.schemastore.org/launchsettings.json", - "profiles": { - "Default": { - "commandName": "Project", - "dotnetRunMessages": true, - "environmentVariables": { - - } - }, - "Development": { - "commandName": "Project", - "dotnetRunMessages": true, - "environmentVariables": { - "DOTNET_ENVIRONMENT": "Development", - "AVALONIA_THEME": "Dark" - } - }, - "Local config": { - "commandName": "Project", - "dotnetRunMessages": true, - "environmentVariables": { - "DOTNET_ENVIRONMENT": "Local" - } - } - } -} diff --git a/MatrixRoomUtils.Desktop/SentryService.cs b/MatrixRoomUtils.Desktop/SentryService.cs deleted file mode 100644
index 26212fa..0000000 --- a/MatrixRoomUtils.Desktop/SentryService.cs +++ /dev/null
@@ -1,29 +0,0 @@ -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; -using Sentry; - -namespace MatrixRoomUtils.Desktop; - -public class SentryService : IDisposable { - private IDisposable? _sentrySdkDisposable; - public SentryService(IServiceScopeFactory scopeFactory, ILogger<SentryService> logger) { - var config = scopeFactory.CreateScope().ServiceProvider.GetRequiredService<MRUDesktopConfiguration>(); - if (config.SentryDsn is null) { - logger.LogWarning("Sentry DSN is not set, skipping Sentry initialisation"); - return; - } - _sentrySdkDisposable = SentrySdk.Init(o => { - o.Dsn = config.SentryDsn; - // When configuring for the first time, to see what the SDK is doing: - o.Debug = true; - // Set traces_sample_rate to 1.0 to capture 100% of transactions for performance monitoring. - // We recommend adjusting this value in production. - o.TracesSampleRate = 1.0; - // Enable Global Mode if running in a client app - o.IsGlobalModeEnabled = true; - }); - } - - /// <summary>Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.</summary> - public void Dispose() => _sentrySdkDisposable?.Dispose(); -} diff --git a/MatrixRoomUtils.Desktop/app.manifest b/MatrixRoomUtils.Desktop/app.manifest deleted file mode 100644
index 35ffb0d..0000000 --- a/MatrixRoomUtils.Desktop/app.manifest +++ /dev/null
@@ -1,18 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1"> - <!-- This manifest is used on Windows only. - Don't remove it as it might cause problems with window transparency and embeded controls. - For more details visit https://learn.microsoft.com/en-us/windows/win32/sbscs/application-manifests --> - <assemblyIdentity version="1.0.0.0" name="MatrixRoomUtils.Desktop.Desktop"/> - - <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> - <application> - <!-- A list of the Windows versions that this application has been tested on - and is designed to work with. Uncomment the appropriate elements - and Windows will automatically select the most compatible environment. --> - - <!-- Windows 10 --> - <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" /> - </application> - </compatibility> -</assembly> diff --git a/MatrixRoomUtils.Desktop/appsettings.Development.json b/MatrixRoomUtils.Desktop/appsettings.Development.json deleted file mode 100644
index a00f349..0000000 --- a/MatrixRoomUtils.Desktop/appsettings.Development.json +++ /dev/null
@@ -1,14 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Debug", - "System": "Information", - "Microsoft": "Information" - } - }, - "MRUDesktop": { - "DataStoragePath": "mru-desktop/data", - "CacheStoragePath": "mru-desktop/cache", - "SentryDsn": "https://a41e99dd2fdd45f699c432b21ebce632@sentry.thearcanebrony.net/15" - } -} diff --git a/MatrixRoomUtils.Desktop/appsettings.json b/MatrixRoomUtils.Desktop/appsettings.json deleted file mode 100644
index 4164e87..0000000 --- a/MatrixRoomUtils.Desktop/appsettings.json +++ /dev/null
@@ -1,13 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Debug", - "System": "Information", - "Microsoft": "Information" - } - }, - "MRUDesktop": { - "DataStoragePath": "~/.local/share/mru-desktop", - "CacheStoragePath": "~/.cache/mru-desktop" - } -}