2020-04-17 21:45:50 +01:00
|
|
|
|
// /***************************************************************************
|
|
|
|
|
|
// Aaru Data Preservation Suite
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// Filename : PluginsViewModel.cs
|
|
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
|
|
|
|
|
//
|
|
|
|
|
|
// Component : GUI view models.
|
|
|
|
|
|
//
|
|
|
|
|
|
// --[ Description ] ----------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// View model and code for the plugins list dialog.
|
|
|
|
|
|
//
|
|
|
|
|
|
// --[ License ] --------------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
|
|
// it under the terms of the GNU General public License as
|
|
|
|
|
|
// published by the Free Software Foundation, either version 3 of the
|
|
|
|
|
|
// License, or (at your option) any later version.
|
|
|
|
|
|
//
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
|
// GNU General public License for more details.
|
|
|
|
|
|
//
|
|
|
|
|
|
// You should have received a copy of the GNU General public License
|
|
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
//
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2024-05-01 04:17:32 +01:00
|
|
|
|
// Copyright © 2011-2024 Natalia Portillo
|
2020-04-17 21:45:50 +01:00
|
|
|
|
// ****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
using System.Collections.ObjectModel;
|
2020-04-10 04:16:48 +01:00
|
|
|
|
using System.Reactive;
|
|
|
|
|
|
using System.Reflection;
|
2023-10-05 13:47:59 +01:00
|
|
|
|
using Aaru.CommonTypes;
|
2020-04-10 04:16:48 +01:00
|
|
|
|
using Aaru.CommonTypes.Interfaces;
|
|
|
|
|
|
using Aaru.Gui.Models;
|
2020-04-16 20:40:25 +01:00
|
|
|
|
using Aaru.Gui.Views.Dialogs;
|
2022-11-19 21:10:41 +00:00
|
|
|
|
using Aaru.Localization;
|
2020-07-22 13:20:25 +01:00
|
|
|
|
using JetBrains.Annotations;
|
2020-04-10 04:16:48 +01:00
|
|
|
|
using ReactiveUI;
|
|
|
|
|
|
|
2022-11-15 15:58:43 +00:00
|
|
|
|
namespace Aaru.Gui.ViewModels.Dialogs;
|
|
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
public sealed class PluginsViewModel : ViewModelBase
|
2020-04-10 04:16:48 +01:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
readonly PluginsDialog _view;
|
2020-04-10 04:16:48 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
public PluginsViewModel(PluginsDialog view)
|
|
|
|
|
|
{
|
|
|
|
|
|
_view = view;
|
2024-05-01 04:39:38 +01:00
|
|
|
|
Filters = [];
|
|
|
|
|
|
PartitionSchemes = [];
|
|
|
|
|
|
Filesystems = [];
|
|
|
|
|
|
ReadOnlyFilesystems = [];
|
|
|
|
|
|
Images = [];
|
|
|
|
|
|
WritableImages = [];
|
|
|
|
|
|
FloppyImages = [];
|
|
|
|
|
|
WritableFloppyImages = [];
|
2022-03-06 13:29:38 +00:00
|
|
|
|
CloseCommand = ReactiveCommand.Create(ExecuteCloseCommand);
|
2020-04-10 04:16:48 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
// TODO: Takes too much time
|
2023-10-05 23:57:19 +01:00
|
|
|
|
foreach(IFilter filter in PluginRegister.Singleton.Filters.Values)
|
2022-12-17 19:56:04 +00:00
|
|
|
|
{
|
2024-05-01 04:05:22 +01:00
|
|
|
|
if(filter is null) continue;
|
2022-12-17 19:56:04 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
Filters.Add(new PluginModel
|
|
|
|
|
|
{
|
|
|
|
|
|
Name = filter.Name,
|
|
|
|
|
|
Uuid = filter.Id,
|
2023-10-05 23:57:19 +01:00
|
|
|
|
Version = Assembly.GetAssembly(filter.GetType())?.GetName().Version?.ToString(),
|
2022-03-06 13:29:38 +00:00
|
|
|
|
Author = filter.Author
|
|
|
|
|
|
});
|
2022-12-17 19:56:04 +00:00
|
|
|
|
}
|
2020-04-10 04:16:48 +01:00
|
|
|
|
|
2023-10-06 00:14:37 +01:00
|
|
|
|
foreach(IFloppyImage floppyImage in PluginRegister.Singleton.FloppyImages.Values)
|
2022-12-17 19:58:03 +00:00
|
|
|
|
{
|
2024-05-01 04:05:22 +01:00
|
|
|
|
if(floppyImage is null) continue;
|
2022-12-17 19:58:03 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
FloppyImages.Add(new PluginModel
|
|
|
|
|
|
{
|
|
|
|
|
|
Name = floppyImage.Name,
|
|
|
|
|
|
Uuid = floppyImage.Id,
|
2023-10-06 00:14:37 +01:00
|
|
|
|
Version = Assembly.GetAssembly(floppyImage.GetType())?.GetName().Version?.ToString(),
|
2022-03-06 13:29:38 +00:00
|
|
|
|
Author = floppyImage.Author
|
|
|
|
|
|
});
|
2022-12-17 19:58:03 +00:00
|
|
|
|
}
|
2020-04-10 04:16:48 +01:00
|
|
|
|
|
2023-10-05 23:57:19 +01:00
|
|
|
|
foreach(IMediaImage mediaImage in PluginRegister.Singleton.MediaImages.Values)
|
2022-12-17 19:27:27 +00:00
|
|
|
|
{
|
2024-05-01 04:05:22 +01:00
|
|
|
|
if(mediaImage is null) continue;
|
2022-12-17 19:27:27 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
Images.Add(new PluginModel
|
|
|
|
|
|
{
|
|
|
|
|
|
Name = mediaImage.Name,
|
|
|
|
|
|
Uuid = mediaImage.Id,
|
2023-10-05 23:57:19 +01:00
|
|
|
|
Version = Assembly.GetAssembly(mediaImage.GetType())?.GetName().Version?.ToString(),
|
2022-03-06 13:29:38 +00:00
|
|
|
|
Author = mediaImage.Author
|
|
|
|
|
|
});
|
2022-12-17 19:27:27 +00:00
|
|
|
|
}
|
2020-04-10 04:16:48 +01:00
|
|
|
|
|
2023-10-05 23:57:19 +01:00
|
|
|
|
foreach(IPartition partition in PluginRegister.Singleton.Partitions.Values)
|
2022-12-17 19:16:42 +00:00
|
|
|
|
{
|
2024-05-01 04:05:22 +01:00
|
|
|
|
if(partition is null) continue;
|
2022-12-17 19:16:42 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
PartitionSchemes.Add(new PluginModel
|
|
|
|
|
|
{
|
|
|
|
|
|
Name = partition.Name,
|
|
|
|
|
|
Uuid = partition.Id,
|
2023-10-05 23:57:19 +01:00
|
|
|
|
Version = Assembly.GetAssembly(partition.GetType())?.GetName().Version?.ToString(),
|
2022-03-06 13:29:38 +00:00
|
|
|
|
Author = partition.Author
|
|
|
|
|
|
});
|
2022-12-17 19:16:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-10-05 16:39:06 +01:00
|
|
|
|
foreach(IFilesystem filesystem in PluginRegister.Singleton.Filesystems.Values)
|
2022-12-17 19:16:42 +00:00
|
|
|
|
{
|
2024-05-01 04:05:22 +01:00
|
|
|
|
if(filesystem is null) continue;
|
2020-04-10 04:16:48 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
Filesystems.Add(new PluginModel
|
|
|
|
|
|
{
|
2023-10-05 16:39:06 +01:00
|
|
|
|
Name = filesystem.Name,
|
|
|
|
|
|
Uuid = filesystem.Id,
|
|
|
|
|
|
Version = Assembly.GetAssembly(filesystem.GetType())?.GetName().Version?.ToString(),
|
|
|
|
|
|
Author = filesystem.Author
|
2022-03-06 13:29:38 +00:00
|
|
|
|
});
|
2022-12-17 19:16:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-10-05 16:55:03 +01:00
|
|
|
|
foreach(IReadOnlyFilesystem fs in PluginRegister.Singleton.ReadOnlyFilesystems.Values)
|
2022-12-17 19:16:42 +00:00
|
|
|
|
{
|
2024-05-01 04:05:22 +01:00
|
|
|
|
if(fs is null) continue;
|
2020-04-10 04:16:48 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
ReadOnlyFilesystems.Add(new PluginModel
|
|
|
|
|
|
{
|
2022-12-17 19:16:42 +00:00
|
|
|
|
Name = fs.Name,
|
|
|
|
|
|
Uuid = fs.Id,
|
2023-10-05 16:55:03 +01:00
|
|
|
|
Version = Assembly.GetAssembly(fs.GetType())?.GetName().Version?.ToString(),
|
2022-12-17 19:16:42 +00:00
|
|
|
|
Author = fs.Author
|
2022-03-06 13:29:38 +00:00
|
|
|
|
});
|
2022-12-17 19:16:42 +00:00
|
|
|
|
}
|
2020-04-10 04:16:48 +01:00
|
|
|
|
|
2023-10-06 00:19:45 +01:00
|
|
|
|
foreach(IWritableFloppyImage writableFloppyImage in PluginRegister.Singleton.WritableFloppyImages.Values)
|
2022-12-17 19:59:48 +00:00
|
|
|
|
{
|
2024-05-01 04:05:22 +01:00
|
|
|
|
if(writableFloppyImage is null) continue;
|
2022-12-17 19:59:48 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
WritableFloppyImages.Add(new PluginModel
|
|
|
|
|
|
{
|
|
|
|
|
|
Name = writableFloppyImage.Name,
|
|
|
|
|
|
Uuid = writableFloppyImage.Id,
|
2023-10-06 00:19:45 +01:00
|
|
|
|
Version = Assembly.GetAssembly(writableFloppyImage.GetType())?.GetName().Version?.ToString(),
|
2022-03-06 13:29:38 +00:00
|
|
|
|
Author = writableFloppyImage.Author
|
|
|
|
|
|
});
|
2022-12-17 19:59:48 +00:00
|
|
|
|
}
|
2020-04-10 04:16:48 +01:00
|
|
|
|
|
2023-10-06 00:55:58 +01:00
|
|
|
|
foreach(IBaseWritableImage writableImage in PluginRegister.Singleton.WritableImages.Values)
|
2022-11-15 01:35:06 +00:00
|
|
|
|
{
|
2024-05-01 04:05:22 +01:00
|
|
|
|
if(writableImage is null) continue;
|
2022-11-15 15:58:43 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
WritableImages.Add(new PluginModel
|
|
|
|
|
|
{
|
|
|
|
|
|
Name = writableImage.Name,
|
|
|
|
|
|
Uuid = writableImage.Id,
|
2023-10-06 00:40:44 +01:00
|
|
|
|
Version = Assembly.GetAssembly(writableImage.GetType())?.GetName().Version?.ToString(),
|
2022-03-06 13:29:38 +00:00
|
|
|
|
Author = writableImage.Author
|
|
|
|
|
|
});
|
2022-11-15 01:35:06 +00:00
|
|
|
|
}
|
2022-03-06 13:29:38 +00:00
|
|
|
|
}
|
2020-04-10 04:16:48 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
[NotNull]
|
2022-11-19 21:10:41 +00:00
|
|
|
|
public string Title => UI.Title_Plugins;
|
2023-10-03 23:27:57 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
[NotNull]
|
2022-11-19 21:10:41 +00:00
|
|
|
|
public string FiltersLabel => UI.Title_Filters;
|
2023-10-03 23:27:57 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
[NotNull]
|
2022-11-19 21:10:41 +00:00
|
|
|
|
public string PartitionsLabel => UI.Title_Partitions;
|
2023-10-03 23:27:57 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
[NotNull]
|
2022-11-19 21:10:41 +00:00
|
|
|
|
public string FilesystemsLabel => UI.Title_Filesystems;
|
2023-10-03 23:27:57 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
[NotNull]
|
2022-11-19 21:10:41 +00:00
|
|
|
|
public string IdentifyLabel => UI.Title_Identify_only;
|
2023-10-03 23:27:57 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
[NotNull]
|
2022-11-19 21:10:41 +00:00
|
|
|
|
public string ImagesLabel => UI.Title_Media_images;
|
2023-10-03 23:27:57 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
[NotNull]
|
2022-11-19 21:10:41 +00:00
|
|
|
|
public string FloppyImagesLabel => UI.Title_Floppy_images;
|
2023-10-03 23:27:57 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
[NotNull]
|
2022-11-19 21:10:41 +00:00
|
|
|
|
public string ReadableLabel => UI.Title_Readable;
|
2023-10-03 23:27:57 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
[NotNull]
|
2022-11-19 21:10:41 +00:00
|
|
|
|
public string WritableLabel => UI.Title_Writable;
|
2023-10-03 23:27:57 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
[NotNull]
|
2022-11-19 21:10:41 +00:00
|
|
|
|
public string CloseLabel => UI.ButtonLabel_Close;
|
2023-10-03 23:27:57 +01:00
|
|
|
|
|
2022-11-19 21:10:41 +00:00
|
|
|
|
public string NameLabel => UI.Title_Name;
|
2023-10-05 01:52:48 +01:00
|
|
|
|
public string UuidLabel => UI.Title_UUID;
|
2022-11-19 21:10:41 +00:00
|
|
|
|
public string VersionLabel => UI.Title_Version;
|
|
|
|
|
|
public string AuthorLabel => UI.Title_Author;
|
2022-11-16 21:40:54 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
public ReactiveCommand<Unit, Unit> CloseCommand { get; }
|
|
|
|
|
|
public ObservableCollection<PluginModel> Filters { get; }
|
|
|
|
|
|
public ObservableCollection<PluginModel> PartitionSchemes { get; }
|
|
|
|
|
|
public ObservableCollection<PluginModel> Filesystems { get; }
|
|
|
|
|
|
public ObservableCollection<PluginModel> ReadOnlyFilesystems { get; }
|
|
|
|
|
|
public ObservableCollection<PluginModel> Images { get; }
|
|
|
|
|
|
public ObservableCollection<PluginModel> WritableImages { get; }
|
|
|
|
|
|
public ObservableCollection<PluginModel> FloppyImages { get; }
|
|
|
|
|
|
public ObservableCollection<PluginModel> WritableFloppyImages { get; }
|
2020-04-10 04:16:48 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
void ExecuteCloseCommand() => _view.Close();
|
2020-04-10 04:16:48 +01:00
|
|
|
|
}
|