From 499c5663a50a4e038f45041206f67b863447bc88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=AD=20Climent?= Date: Fri, 28 Jun 2024 13:23:55 +0200 Subject: [PATCH 1/7] Modify PackageEngine so it uses interfaces to define objects --- .../UniGetUI.Core.LanguageEngine.csproj | 2 +- .../BackgroundApi.cs | 3 +- .../UniGetUI.Interface.BackgroundApi.csproj | 2 +- src/UniGetUI.Interface.Enums/Enums.cs | 3 +- .../IInstallationOptions.cs | 75 +++ .../IManagerSource.cs | 34 ++ .../IPackage.cs | 156 +++++++ .../IPackageDetails.cs | 106 +++++ .../IPackageManager.cs | 144 ++++++ .../ISourceFactory.cs | 38 ++ .../ManagerLogger.cs | 13 +- .../ManagerProperties.cs | 5 +- .../IPackageDetailsProvider.cs | 13 +- .../ManagerProviders}/ISourceProvider.cs | 21 +- .../UniGetUI.PackageEngine.Interfaces.csproj | 37 ++ .../ManagerCapabilities.cs | 15 +- .../ManagerStatus.cs | 0 ... => UniGetUI.PackageEngine.Structs.csproj} | 0 .../Chocolatey.cs | 20 +- .../ChocolateyDetailsProvider.cs | 3 +- .../ChocolateySourceProvider.cs | 13 +- ...I.PackageEngine.Managers.Chocolatey.csproj | 3 +- .../DotNet.cs | 18 +- ...GetUI.PackageEngine.Managers.Dotnet.csproj | 3 +- .../BaseNuGet.cs | 9 +- .../BaseNuGetDetailsProvider.cs | 9 +- .../Internal/PackageManifestLoader.cs | 7 +- .../Npm.cs | 20 +- .../NpmPackageDetailsProvider.cs | 9 +- ...UniGetUI.PackageEngine.Managers.Npm.csproj | 3 +- .../Pip.cs | 20 +- .../PipPackageDetailsProvider.cs | 9 +- ...UniGetUI.PackageEngine.Managers.Pip.csproj | 3 +- .../PowerShell.cs | 24 +- .../PowerShellSourceProvider.cs | 13 +- ...I.PackageEngine.Managers.PowerShell.csproj | 3 +- .../Scoop.cs | 46 +- .../ScoopPackageDetailsProvider.cs | 9 +- .../ScoopSourceProvider.cs | 13 +- ...iGetUI.PackageEngine.Managers.Scoop.csproj | 4 +- ...GetUI.PackageEngine.Managers.WinGet.csproj | 4 +- .../WinGet.cs | 32 +- .../WinGetHelpers.cs | 33 +- .../WinGetPackageDetailsProvider.cs | 15 +- .../WinGetSourceProvider.cs | 13 +- .../PEInterface.cs | 1 + .../UniGetUI.PackageEngine.PEInterface.csproj | 2 +- .../AbstractPackageLoader.cs | 66 +-- .../DiscoverablePackagesLoader.cs | 9 +- .../InstalledPackagesLoader.cs | 7 +- .../PackageBundlesLoader.cs | 66 +++ ...iGetUI.PackageEngine.PackageLoaders.csproj | 2 +- .../UpgradablePackagesLoader.cs | 7 +- .../BasePackageDetailsProvider.cs | 21 +- .../BaseProviders/BaseSourceProvider.cs | 26 +- .../Manager/{Classes => }/ManagerSource.cs | 21 +- .../Manager/PackageManager.cs | 144 ++++-- ...nagerSourceFactory.cs => SourceFactory.cs} | 27 +- .../Packages/ImportedPackage.cs | 48 ++ .../Packages/InstallationOptions.cs | 15 +- .../Packages/InvalidImportedPackage.cs | 19 + .../Packages/ObservablePackageCollection.cs | 11 +- .../Packages/Package.cs | 182 +++----- .../Packages/PackageCacher.cs | 39 +- .../Packages/PackageDetails.cs | 82 +--- .../Packages/PackageWrapper.cs | 9 +- .../UniGetUI.PackageEngine.Classes.csproj | 4 +- .../SerializableBundle_v1.cs | 17 + .../SerializableIncompatiblePackage_v1.cs | 16 + .../SerializablePackage_v1.cs | 63 +++ .../SerializableUpdatesOptions_v1.cs | 14 + src/UniGetUI.sln | 173 ++++++- .../Interface/Dialogs/InstallOptions.xaml.cs | 13 +- src/UniGetUI/Interface/MainView.xaml.cs | 19 +- src/UniGetUI/Interface/MainWindow.xaml.cs | 3 +- .../Pages/PackageDetailsPage.xaml.cs | 7 +- .../AbstractPackagesPage.xaml.cs | 39 +- .../SoftwarePages/DiscoverSoftwarePage.cs | 15 +- .../SoftwarePages/InstalledPackagesPage.cs | 32 +- .../SoftwarePages/NewPackageBundlesPage.cs | 426 ++++++++++++++++++ .../SoftwarePages/PackageBundle.xaml | 1 - .../SoftwarePages/PackageBundle.xaml.cs | 20 +- .../SoftwarePages/SoftwareUpdatesPage.cs | 19 +- .../Interface/Widgets/MenuForPackage.cs | 17 +- .../Interface/Widgets/PackageItemContainer.cs | 3 +- .../Interface/Widgets/SourceManager.xaml.cs | 19 +- .../PackageEngine/Classes/ImportExport.cs | 79 +--- .../Operations/PackageOperations.cs | 22 +- .../Operations/SourceOperations.cs | 11 +- src/UniGetUI/UniGetUI.csproj | 6 +- 90 files changed, 2127 insertions(+), 740 deletions(-) create mode 100644 src/UniGetUI.PAckageEngine.Interfaces/IInstallationOptions.cs create mode 100644 src/UniGetUI.PAckageEngine.Interfaces/IManagerSource.cs create mode 100644 src/UniGetUI.PAckageEngine.Interfaces/IPackage.cs create mode 100644 src/UniGetUI.PAckageEngine.Interfaces/IPackageDetails.cs create mode 100644 src/UniGetUI.PAckageEngine.Interfaces/IPackageManager.cs create mode 100644 src/UniGetUI.PAckageEngine.Interfaces/ISourceFactory.cs rename src/{UniGetUI.PackageEngine.PackageManagerClasses/Manager/Classes => UniGetUI.PAckageEngine.Interfaces}/ManagerLogger.cs (95%) rename src/{UniGetUI.PackageEngine.PackageManagerClasses/Manager/Classes => UniGetUI.PAckageEngine.Interfaces}/ManagerProperties.cs (84%) rename src/{UniGetUI.PackageEngine.PackageManagerClasses/Manager/Interfaces => UniGetUI.PAckageEngine.Interfaces/ManagerProviders}/IPackageDetailsProvider.cs (77%) rename src/{UniGetUI.PackageEngine.PackageManagerClasses/Manager/Interfaces => UniGetUI.PAckageEngine.Interfaces/ManagerProviders}/ISourceProvider.cs (75%) create mode 100644 src/UniGetUI.PAckageEngine.Interfaces/UniGetUI.PackageEngine.Interfaces.csproj rename src/{UniGetUI.PackageEngine.PackageManagerClasses/Manager/Classes => UniGetUI.PackageEngine.Enums}/ManagerCapabilities.cs (72%) rename src/{UniGetUI.PackageEngine.PackageManagerClasses/Manager/Classes => UniGetUI.PackageEngine.Enums}/ManagerStatus.cs (100%) rename src/UniGetUI.PackageEngine.Enums/{UniGetUI.PackageEngine.Enums.csproj => UniGetUI.PackageEngine.Structs.csproj} (100%) create mode 100644 src/UniGetUI.PackageEngine.PackageLoader/PackageBundlesLoader.cs rename src/UniGetUI.PackageEngine.PackageManagerClasses/Manager/{Classes => }/ManagerSource.cs (60%) rename src/UniGetUI.PackageEngine.PackageManagerClasses/Manager/{Classes/ManagerSourceFactory.cs => SourceFactory.cs} (66%) create mode 100644 src/UniGetUI.PackageEngine.PackageManagerClasses/Packages/ImportedPackage.cs create mode 100644 src/UniGetUI.PackageEngine.PackageManagerClasses/Packages/InvalidImportedPackage.cs create mode 100644 src/UniGetUI.PackageEngine.Serializable/SerializableBundle_v1.cs create mode 100644 src/UniGetUI.PackageEngine.Serializable/SerializableIncompatiblePackage_v1.cs create mode 100644 src/UniGetUI.PackageEngine.Serializable/SerializablePackage_v1.cs create mode 100644 src/UniGetUI.PackageEngine.Serializable/SerializableUpdatesOptions_v1.cs create mode 100644 src/UniGetUI/Interface/SoftwarePages/NewPackageBundlesPage.cs diff --git a/src/UniGetUI.Core.LanguageEngine/UniGetUI.Core.LanguageEngine.csproj b/src/UniGetUI.Core.LanguageEngine/UniGetUI.Core.LanguageEngine.csproj index 02c0089ce..20fb1b212 100644 --- a/src/UniGetUI.Core.LanguageEngine/UniGetUI.Core.LanguageEngine.csproj +++ b/src/UniGetUI.Core.LanguageEngine/UniGetUI.Core.LanguageEngine.csproj @@ -98,7 +98,7 @@ - + diff --git a/src/UniGetUI.Interface.BackgroundApi/BackgroundApi.cs b/src/UniGetUI.Interface.BackgroundApi/BackgroundApi.cs index 221b83fe7..febf95907 100644 --- a/src/UniGetUI.Interface.BackgroundApi/BackgroundApi.cs +++ b/src/UniGetUI.Interface.BackgroundApi/BackgroundApi.cs @@ -7,6 +7,7 @@ using UniGetUI.Core.Tools; using UniGetUI.Interface.Enums; using UniGetUI.PackageEngine; +using UniGetUI.PackageEngine.Interfaces; using UniGetUI.PackageEngine.PackageClasses; namespace UniGetUI.Interface @@ -272,7 +273,7 @@ public void BuildV1WidgetsApi() return 400; string iconPath = Path.Join(CoreData.UniGetUIExecutableDirectory, "Assets", "Images", "package_color.png"); - Package? package = PEInterface.UpgradablePackagesLoader.GetPackageForId(Request.Query.@packageId, Request.Query.@packageSource); + IPackage? package = PEInterface.UpgradablePackagesLoader.GetPackageForId(Request.Query.@packageId, Request.Query.@packageSource); if (package != null) { Uri iconUrl = await package.GetIconUrl(); diff --git a/src/UniGetUI.Interface.BackgroundApi/UniGetUI.Interface.BackgroundApi.csproj b/src/UniGetUI.Interface.BackgroundApi/UniGetUI.Interface.BackgroundApi.csproj index 563bff5fb..54601b858 100644 --- a/src/UniGetUI.Interface.BackgroundApi/UniGetUI.Interface.BackgroundApi.csproj +++ b/src/UniGetUI.Interface.BackgroundApi/UniGetUI.Interface.BackgroundApi.csproj @@ -36,7 +36,7 @@ - + diff --git a/src/UniGetUI.Interface.Enums/Enums.cs b/src/UniGetUI.Interface.Enums/Enums.cs index b1dfc85c7..86ff340be 100644 --- a/src/UniGetUI.Interface.Enums/Enums.cs +++ b/src/UniGetUI.Interface.Enums/Enums.cs @@ -11,6 +11,7 @@ public enum PackageTag Pinned, OnQueue, BeingProcessed, - Failed + Failed, + Unavailable } } diff --git a/src/UniGetUI.PAckageEngine.Interfaces/IInstallationOptions.cs b/src/UniGetUI.PAckageEngine.Interfaces/IInstallationOptions.cs new file mode 100644 index 000000000..b82481f2f --- /dev/null +++ b/src/UniGetUI.PAckageEngine.Interfaces/IInstallationOptions.cs @@ -0,0 +1,75 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; +using System.Text.Json; +using System.Threading.Tasks; +using UniGetUI.Core.Data; +using UniGetUI.Core.Language; +using UniGetUI.Core.Logging; +using UniGetUI.PackageEngine.Enums; +using UniGetUI.PackageEngine.Serializable; +using Windows.ApplicationModel; + +namespace UniGetUI.PackageEngine.Interfaces +{ + public interface IInstallationOptions + { + public bool SkipHashCheck { get; set; } + public bool InteractiveInstallation { get; set; } + public bool RunAsAdministrator { get; set; } + public string Version { get; set; } + public Architecture? Architecture { get; set; } + public PackageScope? InstallationScope { get; set; } + public List CustomParameters { get; set; } + public bool RemoveDataOnUninstall { get; set; } + public bool PreRelease { get; set; } + public string CustomInstallLocation { get; set; } + public IPackage Package { get; } + + /// + /// Loads and applies the options from the given SerializableInstallationOptions_v1 object to the current object. + /// + /// + public void FromSerializable(SerializableInstallationOptions_v1 options); + + /// + /// Returns a SerializableInstallationOptions_v1 object containing the options of the current instance. + /// + /// + public SerializableInstallationOptions_v1 AsSerializable(); + + /// + /// Saves the current options to disk, asynchronously. + /// + public async Task SaveToDiskAsync() + { + await Task.Run(() => SaveToDisk()); + } + + /// + /// Loads the options from disk, asynchronously. + /// + public async Task LoadFromDiskAsync() + { + await Task.Run(() => LoadFromDisk()); + } + + /// + /// Saves the current options to disk. + /// + public void SaveToDisk(); + + /// + /// Loads the options from disk. + /// + protected void LoadFromDisk(); + + /// + /// Returns a string representation of the current options. + /// + /// + public string ToString(); + } +} diff --git a/src/UniGetUI.PAckageEngine.Interfaces/IManagerSource.cs b/src/UniGetUI.PAckageEngine.Interfaces/IManagerSource.cs new file mode 100644 index 000000000..8bd892ca3 --- /dev/null +++ b/src/UniGetUI.PAckageEngine.Interfaces/IManagerSource.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace UniGetUI.PackageEngine.Interfaces +{ + public interface IManagerSource + { + public string IconId { get; } + public bool IsVirtualManager { get; } + public IPackageManager Manager { get; } + public string Name { get; } + public Uri Url { get; protected set; } + public int? PackageCount { get; } + public string? UpdateDate { get; } + + /// + /// Returns a human-readable string representing the source name + /// + /// + public string ToString(); + + /// + /// Replaces the current URL with the new one. Must be used only when a placeholder URL is used. + /// + /// + void ReplaceUrl(Uri newUrl) + { + Url = newUrl; + } + } +} diff --git a/src/UniGetUI.PAckageEngine.Interfaces/IPackage.cs b/src/UniGetUI.PAckageEngine.Interfaces/IPackage.cs new file mode 100644 index 000000000..55e0be182 --- /dev/null +++ b/src/UniGetUI.PAckageEngine.Interfaces/IPackage.cs @@ -0,0 +1,156 @@ +using System.ComponentModel; +using System.Runtime.CompilerServices; +using UniGetUI.Interface.Enums; +using UniGetUI.PackageEngine.Enums; +using UniGetUI.PackageEngine.Interfaces; + +namespace UniGetUI.PackageEngine.Interfaces +{ + public interface IPackage : INotifyPropertyChanged + { + public IPackageDetails Details { get; } + public PackageTag Tag { get; set; } + public bool IsChecked { get; set; } + public string Name { get; } + public string Id { get; } + public string Version { get; } + public double VersionAsFloat { get; } + public double NewVersionAsFloat { get; } + public IManagerSource Source { get; } + public IPackageManager Manager { get; } + public string NewVersion { get; } + public bool IsUpgradable { get; } + public PackageScope Scope { get; set; } + public string SourceAsString { get; } + public string AutomationName { get; } + + + /// + /// Returns an identifier that can be used to compare different packahe instances that refer to the same package. + /// What is taken into account: + /// - Manager and Source + /// - Package Identifier + /// For more specific comparsion use GetVersionedHash() + /// + /// + public long GetHash(); + + /// + /// Returns an identifier that can be used to compare different packahe instances that refer to the same package. + /// What is taken into account: + /// - Manager and Source + /// - Package Identifier + /// - Package version + /// - Package new version (if any) + /// + /// + public long GetVersionedHash(); + + /// + /// Check wether two packages are **REALLY** the same package. + /// What is taken into account: + /// - Manager and Source + /// - Package Identifier + /// - Package version + /// - Package new version (if any) + /// + /// + /// + public bool Equals(object? other); + + /// + /// Check wether two package instances represent the same package. + /// What is taken into account: + /// - Manager and Source + /// - Package Identifier + /// For more specific comparsion use package.Equals(object? other) + /// + /// A package + /// Wether the two instances refer to the same instance + public bool IsEquivalentTo(IPackage? other); + + /// + /// Load the package's normalized icon id, + /// + /// a string with the package's normalized icon id + public string GetIconId(); + + /// + /// Get the package's icon url. If the package has no icon, a fallback image is returned. + /// After calling this method, the returned URL points to a location on the local machine + /// + /// An always-valid URI object, pointing to a file:// or to a ms-appx:// URL + public Task GetIconUrl(); + + /// + /// Retrieves a list og URIs representing the available screenshots for this package. + /// + /// + public Task GetPackageScreenshots(); + + + /// + /// Adds the package to the ignored updates list. If no version is provided, all updates are ignored. + /// Calling this method will override older ignored updates. + /// + /// + /// + public Task AddToIgnoredUpdatesAsync(string version = "*"); + + /// + /// Removes the package from the ignored updates list, either if it is ignored for all updates or for a specific version only. + /// + /// + public Task RemoveFromIgnoredUpdatesAsync(); + + /// + /// Returns true if the package's updates are ignored. If the version parameter + /// is passed it will be checked if that version is ignored. Please note that if + /// all updates are ignored, calling this method with a specific version will + /// still return true, although the passed version is not explicitly ignored. + /// + /// + /// + public Task HasUpdatesIgnoredAsync(string Version = "*"); + + /// + /// Returns (as a string) the version for which a package has been ignored. When no versions + /// are ignored, an empty string will be returned; and when all versions are ignored an asterisk + /// will be returned. + /// + /// + public Task GetIgnoredUpdatesVersionAsync(); + + /// + /// Returns the corresponding installed Package object. Will return null if not applicable + /// + /// a Package object if found, null if not + public IPackage? GetInstalledPackage(); + + /// + /// Returns the corresponding available Package object. Will return null if not applicable + /// + /// a Package object if found, null if not + public IPackage? GetAvailablePackage(); + + /// + /// Returns the corresponding upgradable Package object. Will return null if not applicable + /// + /// a Package object if found, null if not + public IPackage? GetUpgradablePackage(); + + /// + /// Sets the package tag. You may as well use the Tag property. + /// This function is used for compatibility with the ? operator + /// + /// + public void SetTag(PackageTag tag); + + /// + /// Checks wether a new version of this package is installed + /// + /// + public bool NewerVersionIsInstalled(); + + } +} diff --git a/src/UniGetUI.PAckageEngine.Interfaces/IPackageDetails.cs b/src/UniGetUI.PAckageEngine.Interfaces/IPackageDetails.cs new file mode 100644 index 000000000..e720f6e5f --- /dev/null +++ b/src/UniGetUI.PAckageEngine.Interfaces/IPackageDetails.cs @@ -0,0 +1,106 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using UniGetUI.Core.Logging; +using UniGetUI.PackageEngine.Interfaces; + +namespace UniGetUI.PackageEngine.Interfaces +{ + public interface IPackageDetails + { + /// + /// The package to which this details instance corresponds + /// + public IPackage Package { get; } + + /// + /// Wether this PackageDetails instance has valid data or not. + /// To load valid data, make use of the `Load()` method + /// + public bool IsPopulated { get; protected set; } + + /// + /// The description of the package + /// + public string? Description { get; set; } + + /// + /// The publisher of the package. The one(s) in charge of maintaining the package published on the package manager. + /// + public string? Publisher { get; set; } + + /// + /// The author of the package. Who has created the package. Usually the developer of the package. + /// + public string? Author { get; set; } + + /// + /// A link to the homepage of the package + /// + public Uri? HomepageUrl { get; set; } + + /// + /// The license name (not the URL) of the package + /// + public string? License { get; set; } + + /// + /// A URL pointing to the license of the package. + /// + public Uri? LicenseUrl { get; set; } + + /// + /// A URL pointing to the installer of the package + /// + public Uri? InstallerUrl { get; set; } + + /// + /// A string representing the hash of the installer. + /// + public string? InstallerHash { get; set; } + + /// + /// A string representing the type of the installer (.zip, .exe, .msi, .appx, tarball, etc.) + /// + public string? InstallerType { get; set; } + + /// + /// The size, in **MEGABYTES**, of the installer + /// + public double InstallerSize { get; set; } + + /// + /// A URL pointing to the Manifest File of the package + /// + public Uri? ManifestUrl { get; set; } + + /// + /// The update date (aka the publication date for the latest version) of the package + /// + public string? UpdateDate { get; set; } + + /// + /// The release notes (not the URL) for the package. + /// + public string? ReleaseNotes { get; set; } + + /// + /// A URL to the package release notes. + /// + public Uri? ReleaseNotesUrl { get; set; } + + /// + /// A list of tags that (in theory) represent the package + /// + public string[] Tags { get; set; } + + /// + /// Loads the available package details. May override existing data. + /// If the load succeeds, `IsPopulated` will be set to True. + /// + /// An asynchronous task that can be awaited + public Task Load(); + } +} diff --git a/src/UniGetUI.PAckageEngine.Interfaces/IPackageManager.cs b/src/UniGetUI.PAckageEngine.Interfaces/IPackageManager.cs new file mode 100644 index 000000000..aadf5310b --- /dev/null +++ b/src/UniGetUI.PAckageEngine.Interfaces/IPackageManager.cs @@ -0,0 +1,144 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using UniGetUI.Core.IconEngine; +using UniGetUI.PackageEngine.Classes.Manager.ManagerHelpers; +using UniGetUI.PackageEngine.Enums; +using UniGetUI.PackageEngine.Interfaces.ManagerProviders; +using UniGetUI.PackageEngine.ManagerClasses.Classes; +using UniGetUI.PackageEngine.ManagerClasses.Manager; + +namespace UniGetUI.PackageEngine.Interfaces +{ + public interface IPackageManager : ISourceProvider, IPackageDetailsProvider + { + public ManagerProperties Properties { get; set; } + public ManagerCapabilities Capabilities { get; set; } + public ManagerStatus Status { get; set; } + public string Name { get; set; } + public IManagerSource DefaultSource { get; set; } + public bool ManagerReady { get; set; } + public ManagerLogger TaskLogger { get; } + + public ISourceProvider? SourceProvider { get; } + public IPackageDetailsProvider? PackageDetailsProvider { get; } + + + /// + /// Initializes the Package Manager (asynchronously). Must be run before using any other method of the manager. + /// + /// + public Task InitializeAsync(); + + /// + /// Returns true if the manager is enabled, false otherwise + /// + /// + public bool IsEnabled(); + + /// + /// Returns true if the manager is enabled and available (the required executable files were found). Returns false otherwise + /// + /// + public bool IsReady(); + + /// + /// Returns an array of Package objects that the manager lists for the given query. Depending on the manager, the list may + /// also include similar results. This method is fail-safe and will return an empty array if an error occurs. + /// + /// + /// + public Task FindPackages(string query); + + /// + /// Returns an array of UpgradablePackage objects that represent the available updates reported by the manager. + /// This method is fail-safe and will return an empty array if an error occurs. + /// + /// + /// + public Task GetAvailableUpdates(); + + /// + /// Returns an array of Package objects that represent the installed reported by the manager. + /// This method is fail-safe and will return an empty array if an error occurs. + /// + /// + public Task GetInstalledPackages(); + + /// + /// Returns the command-line parameters to install the given package. + /// Each manager MUST implement this method. + /// + /// The Package going to be installed + /// The options in which it is going to be installed + /// An array of strings containing the parameters without the manager executable file + public abstract string[] GetInstallParameters(IPackage package, IInstallationOptions options); + + + /// + /// Returns the command-line parameters to update the given package. + /// Each manager MUST implement this method. + /// + /// The Package going to be updated + /// The options in which it is going to be updated + /// An array of strings containing the parameters without the manager executable file + public abstract string[] GetUpdateParameters(IPackage package, IInstallationOptions options); + + /// + /// Returns the command-line parameters to uninstall the given package. + /// Each manager MUST implement this method. + /// + /// The Package going to be uninstalled + /// The options in which it is going to be uninstalled + /// An array of strings containing the parameters without the manager executable file + public abstract string[] GetUninstallParameters(IPackage package, IInstallationOptions options); + + /// + /// Decides and returns the verdict of the install operation. + /// Each manager MUST implement this method. + /// + /// The package that was installed + /// The options with which the package was installed. They may be modified if the returned value is OperationVeredict.AutoRetry + /// The exit code of the process + /// the output of the process + /// An OperationVeredict value representing the result of the installation + public abstract OperationVeredict GetInstallOperationVeredict(IPackage package, IInstallationOptions options, int ReturnCode, string[] Output); + + + /// + /// Decides and returns the verdict of the update operation. + /// Each manager MUST implement this method. + /// + /// The package that was updated + /// The options with which the package was updated. They may be modified if the returned value is OperationVeredict.AutoRetry + /// The exit code of the process + /// the output of the process + /// An OperationVeredict value representing the result of the update + public abstract OperationVeredict GetUpdateOperationVeredict(IPackage package, IInstallationOptions options, int ReturnCode, string[] Output); + + /// + /// Decides and returns the verdict of the uninstall operation. + /// Each manager MUST implement this method. + /// + /// The package that was uninstalled + /// The options with which the package was uninstalled. They may be modified if the returned value is OperationVeredict.AutoRetry + /// The exit code of the process + /// the output of the process + /// An OperationVeredict value representing the result of the uninstall + public abstract OperationVeredict GetUninstallOperationVeredict(IPackage package, IInstallationOptions options, int ReturnCode, string[] Output); + + /// + /// Refreshes the Package Manager sources/indexes + /// Each manager MUST implement this method. + /// + /// + public Task RefreshPackageIndexes(); + public IManagerSource GetSourceOrDefault(string SourceName); + public IManagerSource? GetSourceIfExists(string SourceName); + + public void LogOperation(Process process, string output); + } +} diff --git a/src/UniGetUI.PAckageEngine.Interfaces/ISourceFactory.cs b/src/UniGetUI.PAckageEngine.Interfaces/ISourceFactory.cs new file mode 100644 index 000000000..8aaf42599 --- /dev/null +++ b/src/UniGetUI.PAckageEngine.Interfaces/ISourceFactory.cs @@ -0,0 +1,38 @@ +using UniGetUI.PackageEngine.ManagerClasses.Manager; + +namespace UniGetUI.PackageEngine.Interfaces +{ + public interface ISourceFactory + { + /// + /// Returns the existing source for the given name, or creates a new one if it does not exist. + /// + /// The name of the source + /// A valid ManagerSource + public IManagerSource GetSourceOrDefault(string name); + + /// + /// Returns the existing source for the given name, or null if it does not exist. + /// + /// + /// + public IManagerSource? GetSourceIfExists(string name); + + /// + /// Adds a source to the factory, if the given source does not exist + /// + /// + public void AddSource(IManagerSource source); + + /// + /// Returns the available sources on the factory + /// + /// + public IManagerSource[] GetAvailableSources(); + + /// + /// Resets the current state of the SourceFactory. All sources are lost + /// + public void Reset(); + } +} diff --git a/src/UniGetUI.PackageEngine.PackageManagerClasses/Manager/Classes/ManagerLogger.cs b/src/UniGetUI.PAckageEngine.Interfaces/ManagerLogger.cs similarity index 95% rename from src/UniGetUI.PackageEngine.PackageManagerClasses/Manager/Classes/ManagerLogger.cs rename to src/UniGetUI.PAckageEngine.Interfaces/ManagerLogger.cs index af49ef8a4..32a4fb0d6 100644 --- a/src/UniGetUI.PackageEngine.PackageManagerClasses/Manager/Classes/ManagerLogger.cs +++ b/src/UniGetUI.PAckageEngine.Interfaces/ManagerLogger.cs @@ -1,15 +1,16 @@ using System.Diagnostics; using UniGetUI.PackageEngine.Enums; +using UniGetUI.PackageEngine.Interfaces; using UniGetUI.PackageEngine.ManagerClasses.Manager; namespace UniGetUI.PackageEngine.ManagerClasses.Classes { public class ManagerLogger { - readonly PackageManager Manager; + readonly IPackageManager Manager; public List Operations = new(); - public ManagerLogger(PackageManager manager) + public ManagerLogger(IPackageManager manager) { Manager = manager; } @@ -82,7 +83,7 @@ public void Close(int returnCode) public class ProcessTaskLogger : TaskLogger { - readonly PackageManager Manager; + readonly IPackageManager Manager; readonly LoggableTaskType Type; readonly string Executable; @@ -91,7 +92,7 @@ public class ProcessTaskLogger : TaskLogger readonly List StdOut = new(); readonly List StdErr = new(); - public ProcessTaskLogger(PackageManager manager, LoggableTaskType type, string executable, string arguments) : base() + public ProcessTaskLogger(IPackageManager manager, LoggableTaskType type, string executable, string arguments) : base() { Type = type; Manager = manager; @@ -196,13 +197,13 @@ public override IEnumerable AsColoredString(bool verbose = false) public class NativeTaskLogger : TaskLogger { - readonly PackageManager Manager; + readonly IPackageManager Manager; readonly LoggableTaskType Type; readonly List Info = new(); readonly List Errors = new(); - public NativeTaskLogger(PackageManager manager, LoggableTaskType type) : base() + public NativeTaskLogger(IPackageManager manager, LoggableTaskType type) : base() { Type = type; Manager = manager; diff --git a/src/UniGetUI.PackageEngine.PackageManagerClasses/Manager/Classes/ManagerProperties.cs b/src/UniGetUI.PAckageEngine.Interfaces/ManagerProperties.cs similarity index 84% rename from src/UniGetUI.PackageEngine.PackageManagerClasses/Manager/Classes/ManagerProperties.cs rename to src/UniGetUI.PAckageEngine.Interfaces/ManagerProperties.cs index 84acb5ff7..d5d45be19 100644 --- a/src/UniGetUI.PackageEngine.PackageManagerClasses/Manager/Classes/ManagerProperties.cs +++ b/src/UniGetUI.PAckageEngine.Interfaces/ManagerProperties.cs @@ -1,4 +1,5 @@ using UniGetUI.PackageEngine.Classes.Manager.ManagerHelpers; +using UniGetUI.PackageEngine.Interfaces; namespace UniGetUI.PackageEngine.ManagerClasses.Manager { @@ -14,8 +15,8 @@ public class ManagerProperties public string InstallVerb { get; set; } = "Unset"; public string UpdateVerb { get; set; } = "Unset"; public string UninstallVerb { get; set; } = "Unset"; - public ManagerSource[] KnownSources { get; set; } = []; - public ManagerSource DefaultSource { get; set; } + public IManagerSource[] KnownSources { get; set; } = []; + public IManagerSource DefaultSource { get; set; } #pragma warning disable CS8618 public ManagerProperties() { } public ManagerProperties(bool IsDummy) { this.IsDummy = IsDummy; } diff --git a/src/UniGetUI.PackageEngine.PackageManagerClasses/Manager/Interfaces/IPackageDetailsProvider.cs b/src/UniGetUI.PAckageEngine.Interfaces/ManagerProviders/IPackageDetailsProvider.cs similarity index 77% rename from src/UniGetUI.PackageEngine.PackageManagerClasses/Manager/Interfaces/IPackageDetailsProvider.cs rename to src/UniGetUI.PAckageEngine.Interfaces/ManagerProviders/IPackageDetailsProvider.cs index 5f079d14d..81f3307c3 100644 --- a/src/UniGetUI.PackageEngine.PackageManagerClasses/Manager/Interfaces/IPackageDetailsProvider.cs +++ b/src/UniGetUI.PAckageEngine.Interfaces/ManagerProviders/IPackageDetailsProvider.cs @@ -1,9 +1,8 @@ using UniGetUI.Core.IconEngine; -using UniGetUI.PackageEngine.PackageClasses; -namespace UniGetUI.PackageEngine.Classes.Manager.Interfaces +namespace UniGetUI.PackageEngine.Interfaces.ManagerProviders { - internal interface IPackageDetailsProvider + public interface IPackageDetailsProvider { /// /// Returns a PackageDetails object that represents the details for the given Package object. @@ -12,7 +11,7 @@ internal interface IPackageDetailsProvider /// /// The PackageDetails instance to load /// A PackageDetails object - public abstract Task GetPackageDetails(PackageDetails details); + public abstract Task GetPackageDetails(IPackageDetails details); /// @@ -22,7 +21,7 @@ internal interface IPackageDetailsProvider /// /// The package from which to load its versions /// An array of stings containing the found versions, an empty array if none. - public abstract Task GetPackageVersions(Package package); + public abstract Task GetPackageVersions(IPackage package); /// /// Returns an Uri pointing to the icon of this package. @@ -30,7 +29,7 @@ internal interface IPackageDetailsProvider /// /// The package from which to load the icon /// A full path to a valid icon file - public abstract Task GetPackageIconUrl(Package package); + public abstract Task GetPackageIconUrl(IPackage package); /// @@ -38,6 +37,6 @@ internal interface IPackageDetailsProvider /// /// The package from which to load the screenshots /// An array with valid URIs to the screenshots - public abstract Task GetPackageScreenshotsUrl(Package package); + public abstract Task GetPackageScreenshotsUrl(IPackage package); } } diff --git a/src/UniGetUI.PackageEngine.PackageManagerClasses/Manager/Interfaces/ISourceProvider.cs b/src/UniGetUI.PAckageEngine.Interfaces/ManagerProviders/ISourceProvider.cs similarity index 75% rename from src/UniGetUI.PackageEngine.PackageManagerClasses/Manager/Interfaces/ISourceProvider.cs rename to src/UniGetUI.PAckageEngine.Interfaces/ManagerProviders/ISourceProvider.cs index b4d3bb123..d4eb165f1 100644 --- a/src/UniGetUI.PackageEngine.PackageManagerClasses/Manager/Interfaces/ISourceProvider.cs +++ b/src/UniGetUI.PAckageEngine.Interfaces/ManagerProviders/ISourceProvider.cs @@ -1,23 +1,24 @@ -using UniGetUI.PackageEngine.Classes.Manager.ManagerHelpers; -using UniGetUI.PackageEngine.Enums; +using UniGetUI.PackageEngine.Enums; -namespace UniGetUI.PackageEngine.Classes.Manager.Interfaces +namespace UniGetUI.PackageEngine.Interfaces.ManagerProviders { - internal interface ISourceProvider + public interface ISourceProvider { + public ISourceFactory SourceFactory { get; } + /// /// Returns the command-line parameters required to add the given source to the manager. /// /// The source to add /// An array containing the parameters to pass to the manager executable - public abstract string[] GetAddSourceParameters(ManagerSource source); - + public abstract string[] GetAddSourceParameters(IManagerSource source); + /// /// Returns the command-line parameters required to remove the given source from the manager. /// /// The source to remove /// An array containing the parameters to pass to the manager executable - public abstract string[] GetRemoveSourceParameters(ManagerSource source); + public abstract string[] GetRemoveSourceParameters(IManagerSource source); /// /// Checks the result of attempting to add a source @@ -26,7 +27,7 @@ internal interface ISourceProvider /// The returncode of the operation /// the command-line output of the operation /// An OperationVeredict value - public abstract OperationVeredict GetAddSourceOperationVeredict(ManagerSource source, int ReturnCode, string[] Output); + public abstract OperationVeredict GetAddSourceOperationVeredict(IManagerSource source, int ReturnCode, string[] Output); /// /// Checks the result of attempting to remove a source @@ -35,12 +36,12 @@ internal interface ISourceProvider /// The returncode of the operation /// the command-line output of the operation /// An OperationVeredict value - public abstract OperationVeredict GetRemoveSourceOperationVeredict(ManagerSource source, int ReturnCode, string[] Output); + public abstract OperationVeredict GetRemoveSourceOperationVeredict(IManagerSource source, int ReturnCode, string[] Output); /// /// Returns the available sources /// /// An array of ManagerSource objects - public abstract Task GetSources(); + public abstract Task GetSources(); } } diff --git a/src/UniGetUI.PAckageEngine.Interfaces/UniGetUI.PackageEngine.Interfaces.csproj b/src/UniGetUI.PAckageEngine.Interfaces/UniGetUI.PackageEngine.Interfaces.csproj new file mode 100644 index 000000000..518091583 --- /dev/null +++ b/src/UniGetUI.PAckageEngine.Interfaces/UniGetUI.PackageEngine.Interfaces.csproj @@ -0,0 +1,37 @@ + + + + net8.0-windows10.0.19041.0 + enable + win-x64;win-arm64 + win-$(Platform) + ARM64;x64 + 10.0.19041.0 + 10.0.19041.0 + 8.0.204 + true + true + 3.1.0.0 + 3.1.0-beta0 + UniGetUI + Martí Climent and the contributors + Martí Climent + 3.1.0-beta0 + 2024, Martí Climent + enable + + + + + + + + + + + + + + + + diff --git a/src/UniGetUI.PackageEngine.PackageManagerClasses/Manager/Classes/ManagerCapabilities.cs b/src/UniGetUI.PackageEngine.Enums/ManagerCapabilities.cs similarity index 72% rename from src/UniGetUI.PackageEngine.PackageManagerClasses/Manager/Classes/ManagerCapabilities.cs rename to src/UniGetUI.PackageEngine.Enums/ManagerCapabilities.cs index 8b6675474..2dbdccffb 100644 --- a/src/UniGetUI.PackageEngine.PackageManagerClasses/Manager/Classes/ManagerCapabilities.cs +++ b/src/UniGetUI.PackageEngine.Enums/ManagerCapabilities.cs @@ -3,6 +3,15 @@ namespace UniGetUI.PackageEngine.ManagerClasses.Manager { + public struct SourceCapabilities + { + public bool KnowsUpdateDate { get; set; } = false; + public bool KnowsPackageCount { get; set; } = false; + public bool MustBeInstalledAsAdmin { get; set; } = false; + public SourceCapabilities() + { } + } + public struct ManagerCapabilities { public bool IsDummy = false; @@ -19,15 +28,15 @@ public struct ManagerCapabilities public bool SupportsCustomSources = false; public bool SupportsCustomPackageIcons = false; public bool SupportsCustomPackageScreenshots = false; - public ManagerSource.Capabilities Sources { get; set; } + public SourceCapabilities Sources { get; set; } public ManagerCapabilities() { - Sources = new ManagerSource.Capabilities(); + Sources = new SourceCapabilities(); } public ManagerCapabilities(bool IsDummy) { - Sources = new ManagerSource.Capabilities(); + Sources = new SourceCapabilities(); this.IsDummy = IsDummy; } } diff --git a/src/UniGetUI.PackageEngine.PackageManagerClasses/Manager/Classes/ManagerStatus.cs b/src/UniGetUI.PackageEngine.Enums/ManagerStatus.cs similarity index 100% rename from src/UniGetUI.PackageEngine.PackageManagerClasses/Manager/Classes/ManagerStatus.cs rename to src/UniGetUI.PackageEngine.Enums/ManagerStatus.cs diff --git a/src/UniGetUI.PackageEngine.Enums/UniGetUI.PackageEngine.Enums.csproj b/src/UniGetUI.PackageEngine.Enums/UniGetUI.PackageEngine.Structs.csproj similarity index 100% rename from src/UniGetUI.PackageEngine.Enums/UniGetUI.PackageEngine.Enums.csproj rename to src/UniGetUI.PackageEngine.Enums/UniGetUI.PackageEngine.Structs.csproj diff --git a/src/UniGetUI.PackageEngine.Managers.Chocolatey/Chocolatey.cs b/src/UniGetUI.PackageEngine.Managers.Chocolatey/Chocolatey.cs index 7d008b980..feca57c1d 100644 --- a/src/UniGetUI.PackageEngine.Managers.Chocolatey/Chocolatey.cs +++ b/src/UniGetUI.PackageEngine.Managers.Chocolatey/Chocolatey.cs @@ -4,8 +4,10 @@ using UniGetUI.Core.Logging; using UniGetUI.Core.SettingsEngine; using UniGetUI.Core.Tools; +using UniGetUI.PackageEngine.Classes.Manager; using UniGetUI.PackageEngine.Classes.Manager.ManagerHelpers; using UniGetUI.PackageEngine.Enums; +using UniGetUI.PackageEngine.Interfaces; using UniGetUI.PackageEngine.ManagerClasses.Manager; using UniGetUI.PackageEngine.Managers.Chocolatey; using UniGetUI.PackageEngine.Managers.PowerShellManager; @@ -32,7 +34,7 @@ public Chocolatey() : base() SupportsPreRelease = true, SupportsCustomSources = true, SupportsCustomPackageIcons = true, - Sources = new ManagerSource.Capabilities() + Sources = new SourceCapabilities() { KnowsPackageCount = false, KnowsUpdateDate = false, @@ -59,7 +61,7 @@ public Chocolatey() : base() PackageDetailsProvider = new ChocolateyDetailsProvider(this); } - protected override async Task GetAvailableUpdates_UnSafe() + protected override async Task GetAvailableUpdates_UnSafe() { Process p = new(); p.StartInfo = new ProcessStartInfo() @@ -104,7 +106,7 @@ protected override async Task GetAvailableUpdates_UnSafe() return Packages.ToArray(); } - protected override async Task GetInstalledPackages_UnSafe() + protected override async Task GetInstalledPackages_UnSafe() { Process p = new(); p.StartInfo = new ProcessStartInfo() @@ -148,7 +150,7 @@ protected override async Task GetInstalledPackages_UnSafe() return Packages.ToArray(); } - public override OperationVeredict GetInstallOperationVeredict(Package package, InstallationOptions options, int ReturnCode, string[] Output) + public override OperationVeredict GetInstallOperationVeredict(IPackage package, IInstallationOptions options, int ReturnCode, string[] Output) { string output_string = string.Join("\n", Output); @@ -164,12 +166,12 @@ public override OperationVeredict GetInstallOperationVeredict(Package package, I return OperationVeredict.Failed; } - public override OperationVeredict GetUpdateOperationVeredict(Package package, InstallationOptions options, int ReturnCode, string[] Output) + public override OperationVeredict GetUpdateOperationVeredict(IPackage package, IInstallationOptions options, int ReturnCode, string[] Output) { return GetInstallOperationVeredict(package, options, ReturnCode, Output); } - public override OperationVeredict GetUninstallOperationVeredict(Package package, InstallationOptions options, int ReturnCode, string[] Output) + public override OperationVeredict GetUninstallOperationVeredict(IPackage package, IInstallationOptions options, int ReturnCode, string[] Output) { string output_string = string.Join("\n", Output); @@ -184,7 +186,7 @@ public override OperationVeredict GetUninstallOperationVeredict(Package package, } return OperationVeredict.Failed; } - public override string[] GetInstallParameters(Package package, InstallationOptions options) + public override string[] GetInstallParameters(IPackage package, IInstallationOptions options) { List parameters = GetUninstallParameters(package, options).ToList(); parameters[0] = Properties.InstallVerb; @@ -204,14 +206,14 @@ public override string[] GetInstallParameters(Package package, InstallationOptio return parameters.ToArray(); } - public override string[] GetUpdateParameters(Package package, InstallationOptions options) + public override string[] GetUpdateParameters(IPackage package, IInstallationOptions options) { string[] parameters = GetInstallParameters(package, options); parameters[0] = Properties.UpdateVerb; return parameters; } - public override string[] GetUninstallParameters(Package package, InstallationOptions options) + public override string[] GetUninstallParameters(IPackage package, IInstallationOptions options) { List parameters = new() { Properties.UninstallVerb, package.Id, "-y" }; diff --git a/src/UniGetUI.PackageEngine.Managers.Chocolatey/ChocolateyDetailsProvider.cs b/src/UniGetUI.PackageEngine.Managers.Chocolatey/ChocolateyDetailsProvider.cs index 4013b7ded..ec01e6cea 100644 --- a/src/UniGetUI.PackageEngine.Managers.Chocolatey/ChocolateyDetailsProvider.cs +++ b/src/UniGetUI.PackageEngine.Managers.Chocolatey/ChocolateyDetailsProvider.cs @@ -1,5 +1,6 @@ using System.Diagnostics; using UniGetUI.PackageEngine.Enums; +using UniGetUI.PackageEngine.Interfaces; using UniGetUI.PackageEngine.Managers.PowerShellManager; using UniGetUI.PackageEngine.PackageClasses; @@ -10,7 +11,7 @@ public class ChocolateyDetailsProvider : BaseNuGetDetailsProvider public ChocolateyDetailsProvider(BaseNuGet manager) : base(manager) { } - protected override async Task GetPackageVersions_Unsafe(Package package) + protected override async Task GetPackageVersions_Unsafe(IPackage package) { Process p = new() { diff --git a/src/UniGetUI.PackageEngine.Managers.Chocolatey/ChocolateySourceProvider.cs b/src/UniGetUI.PackageEngine.Managers.Chocolatey/ChocolateySourceProvider.cs index 2f26ebf66..38250955c 100644 --- a/src/UniGetUI.PackageEngine.Managers.Chocolatey/ChocolateySourceProvider.cs +++ b/src/UniGetUI.PackageEngine.Managers.Chocolatey/ChocolateySourceProvider.cs @@ -1,7 +1,8 @@ using System.Diagnostics; -using UniGetUI.PackageEngine.Classes.Manager.ManagerHelpers; +using UniGetUI.PackageEngine.Classes.Manager; using UniGetUI.PackageEngine.Classes.Manager.Providers; using UniGetUI.PackageEngine.Enums; +using UniGetUI.PackageEngine.Interfaces; using UniGetUI.PackageEngine.ManagerClasses.Manager; namespace UniGetUI.PackageEngine.Managers.ChocolateyManager @@ -10,27 +11,27 @@ internal class ChocolateySourceProvider : BaseSourceProvider { public ChocolateySourceProvider(Chocolatey manager) : base(manager) { } - public override string[] GetAddSourceParameters(ManagerSource source) + public override string[] GetAddSourceParameters(IManagerSource source) { return new string[] { "source", "add", "--name", source.Name, "--source", source.Url.ToString(), "-y" }; } - public override string[] GetRemoveSourceParameters(ManagerSource source) + public override string[] GetRemoveSourceParameters(IManagerSource source) { return new string[] { "source", "remove", "--name", source.Name, "-y" }; } - public override OperationVeredict GetAddSourceOperationVeredict(ManagerSource source, int ReturnCode, string[] Output) + public override OperationVeredict GetAddSourceOperationVeredict(IManagerSource source, int ReturnCode, string[] Output) { return ReturnCode == 0 ? OperationVeredict.Succeeded : OperationVeredict.Failed; } - public override OperationVeredict GetRemoveSourceOperationVeredict(ManagerSource source, int ReturnCode, string[] Output) + public override OperationVeredict GetRemoveSourceOperationVeredict(IManagerSource source, int ReturnCode, string[] Output) { return ReturnCode == 0 ? OperationVeredict.Succeeded : OperationVeredict.Failed; } - protected override async Task GetSources_UnSafe() + protected override async Task GetSources_UnSafe() { List sources = new(); diff --git a/src/UniGetUI.PackageEngine.Managers.Chocolatey/UniGetUI.PackageEngine.Managers.Chocolatey.csproj b/src/UniGetUI.PackageEngine.Managers.Chocolatey/UniGetUI.PackageEngine.Managers.Chocolatey.csproj index 9fc5341b4..9cc041d9f 100644 --- a/src/UniGetUI.PackageEngine.Managers.Chocolatey/UniGetUI.PackageEngine.Managers.Chocolatey.csproj +++ b/src/UniGetUI.PackageEngine.Managers.Chocolatey/UniGetUI.PackageEngine.Managers.Chocolatey.csproj @@ -34,7 +34,8 @@ - + + diff --git a/src/UniGetUI.PackageEngine.Managers.Dotnet/DotNet.cs b/src/UniGetUI.PackageEngine.Managers.Dotnet/DotNet.cs index 9be9f434a..6b6591bb1 100644 --- a/src/UniGetUI.PackageEngine.Managers.Dotnet/DotNet.cs +++ b/src/UniGetUI.PackageEngine.Managers.Dotnet/DotNet.cs @@ -2,8 +2,10 @@ using System.Runtime.InteropServices; using System.Text.RegularExpressions; using UniGetUI.Core.Tools; +using UniGetUI.PackageEngine.Classes.Manager; using UniGetUI.PackageEngine.Classes.Manager.ManagerHelpers; using UniGetUI.PackageEngine.Enums; +using UniGetUI.PackageEngine.Interfaces; using UniGetUI.PackageEngine.ManagerClasses.Manager; using UniGetUI.PackageEngine.Managers.PowerShellManager; using UniGetUI.PackageEngine.PackageClasses; @@ -46,7 +48,7 @@ public DotNet() : base() }; } - protected override async Task GetAvailableUpdates_UnSafe() + protected override async Task GetAvailableUpdates_UnSafe() { Tuple which_res = await CoreTools.Which("dotnet-tools-outdated.exe"); string path = which_res.Item2; @@ -120,7 +122,7 @@ protected override async Task GetAvailableUpdates_UnSafe() return Packages.ToArray(); } - protected override async Task GetInstalledPackages_UnSafe() + protected override async Task GetInstalledPackages_UnSafe() { List Packages = new(); foreach (PackageScope scope in new PackageScope[] { PackageScope.Local, PackageScope.Global}) @@ -171,27 +173,27 @@ protected override async Task GetInstalledPackages_UnSafe() } - public override OperationVeredict GetInstallOperationVeredict(Package package, InstallationOptions options, int ReturnCode, string[] Output) + public override OperationVeredict GetInstallOperationVeredict(IPackage package, IInstallationOptions options, int ReturnCode, string[] Output) { return ReturnCode == 0 ? OperationVeredict.Succeeded : OperationVeredict.Failed; } - public override OperationVeredict GetUpdateOperationVeredict(Package package, InstallationOptions options, int ReturnCode, string[] Output) + public override OperationVeredict GetUpdateOperationVeredict(IPackage package, IInstallationOptions options, int ReturnCode, string[] Output) { return ReturnCode == 0 ? OperationVeredict.Succeeded : OperationVeredict.Failed; } - public override OperationVeredict GetUninstallOperationVeredict(Package package, InstallationOptions options, int ReturnCode, string[] Output) + public override OperationVeredict GetUninstallOperationVeredict(IPackage package, IInstallationOptions options, int ReturnCode, string[] Output) { return ReturnCode == 0 ? OperationVeredict.Succeeded : OperationVeredict.Failed; } - public override string[] GetInstallParameters(Package package, InstallationOptions options) + public override string[] GetInstallParameters(IPackage package, IInstallationOptions options) { string[] parameters = GetUpdateParameters(package, options); parameters[0] = Properties.InstallVerb; return parameters; } - public override string[] GetUpdateParameters(Package package, InstallationOptions options) + public override string[] GetUpdateParameters(IPackage package, IInstallationOptions options) { List parameters = GetUninstallParameters(package, options).ToList(); parameters[0] = Properties.UpdateVerb; @@ -208,7 +210,7 @@ public override string[] GetUpdateParameters(Package package, InstallationOption return parameters.ToArray(); } - public override string[] GetUninstallParameters(Package package, InstallationOptions options) + public override string[] GetUninstallParameters(IPackage package, IInstallationOptions options) { List parameters = new() { Properties.UninstallVerb, package.Id }; diff --git a/src/UniGetUI.PackageEngine.Managers.Dotnet/UniGetUI.PackageEngine.Managers.Dotnet.csproj b/src/UniGetUI.PackageEngine.Managers.Dotnet/UniGetUI.PackageEngine.Managers.Dotnet.csproj index e1c5bd2da..1cc862ee9 100644 --- a/src/UniGetUI.PackageEngine.Managers.Dotnet/UniGetUI.PackageEngine.Managers.Dotnet.csproj +++ b/src/UniGetUI.PackageEngine.Managers.Dotnet/UniGetUI.PackageEngine.Managers.Dotnet.csproj @@ -35,7 +35,8 @@ - + + diff --git a/src/UniGetUI.PackageEngine.Managers.Generic.NuGet/BaseNuGet.cs b/src/UniGetUI.PackageEngine.Managers.Generic.NuGet/BaseNuGet.cs index 6f82c634c..bb76eb424 100644 --- a/src/UniGetUI.PackageEngine.Managers.Generic.NuGet/BaseNuGet.cs +++ b/src/UniGetUI.PackageEngine.Managers.Generic.NuGet/BaseNuGet.cs @@ -2,7 +2,8 @@ using System.Web; using UniGetUI.Core.Data; using UniGetUI.Core.Tools; -using UniGetUI.PackageEngine.Classes.Manager.ManagerHelpers; +using UniGetUI.PackageEngine.Classes.Manager; +using UniGetUI.PackageEngine.Interfaces; using UniGetUI.PackageEngine.ManagerClasses.Manager; using UniGetUI.PackageEngine.PackageClasses; @@ -39,19 +40,19 @@ private struct SearchResult public string id; } - protected sealed override async Task FindPackages_UnSafe(string query) + protected sealed override async Task FindPackages_UnSafe(string query) { List Packages = new(); ManagerClasses.Classes.NativeTaskLogger logger = TaskLogger.CreateNew(Enums.LoggableTaskType.FindPackages); - ManagerSource[] sources; + IManagerSource[] sources; if (Capabilities.SupportsCustomSources) sources = await GetSources(); else sources = [ Properties.DefaultSource ]; - foreach(ManagerSource source in sources) + foreach(IManagerSource source in sources) { Uri SearchUrl = new($"{source.Url}/Search()?searchTerm=%27{HttpUtility.UrlEncode(query)}%27&targetFramework=%27%27&includePrerelease=false"); logger.Log($"Begin package search with url={SearchUrl} on manager {Name}"); ; diff --git a/src/UniGetUI.PackageEngine.Managers.Generic.NuGet/BaseNuGetDetailsProvider.cs b/src/UniGetUI.PackageEngine.Managers.Generic.NuGet/BaseNuGetDetailsProvider.cs index 62735fdc9..1cab8ce39 100644 --- a/src/UniGetUI.PackageEngine.Managers.Generic.NuGet/BaseNuGetDetailsProvider.cs +++ b/src/UniGetUI.PackageEngine.Managers.Generic.NuGet/BaseNuGetDetailsProvider.cs @@ -5,6 +5,7 @@ using UniGetUI.Core.Tools; using UniGetUI.PackageEngine.Classes.Manager.BaseProviders; using UniGetUI.PackageEngine.Enums; +using UniGetUI.PackageEngine.Interfaces; using UniGetUI.PackageEngine.ManagerClasses.Manager; using UniGetUI.PackageEngine.Managers.Generic.NuGet.Internal; using UniGetUI.PackageEngine.PackageClasses; @@ -15,7 +16,7 @@ public class BaseNuGetDetailsProvider : BasePackageDetailsProvider GetPackageIcon_Unsafe(Package package) + protected override async Task GetPackageIcon_Unsafe(IPackage package) { string? PackageManifestContent = await PackageManifestLoader.GetPackageManifestContent(package); if (PackageManifestContent == null) @@ -116,12 +117,12 @@ protected override async Task GetPackageDetails_Unsafe(PackageDetails details) return new CacheableIcon(new Uri(possibleIconUrl.Groups[1].Value), package.Version); } - protected override Task GetPackageScreenshots_Unsafe(Package package) + protected override Task GetPackageScreenshots_Unsafe(IPackage package) { throw new NotImplementedException(); } - protected override async Task GetPackageVersions_Unsafe(Package package) + protected override async Task GetPackageVersions_Unsafe(IPackage package) { Uri SearchUrl = new($"{package.Source.Url}/FindPackagesById()?id='{package.Id}'"); Logger.Debug($"Begin package version search with url={SearchUrl} on manager {Manager.Name}"); diff --git a/src/UniGetUI.PackageEngine.Managers.Generic.NuGet/Internal/PackageManifestLoader.cs b/src/UniGetUI.PackageEngine.Managers.Generic.NuGet/Internal/PackageManifestLoader.cs index 4e3a5dae1..305176049 100644 --- a/src/UniGetUI.PackageEngine.Managers.Generic.NuGet/Internal/PackageManifestLoader.cs +++ b/src/UniGetUI.PackageEngine.Managers.Generic.NuGet/Internal/PackageManifestLoader.cs @@ -1,5 +1,6 @@ using UniGetUI.Core.Data; using UniGetUI.Core.Logging; +using UniGetUI.PackageEngine.Interfaces; using UniGetUI.PackageEngine.PackageClasses; namespace UniGetUI.PackageEngine.Managers.Generic.NuGet.Internal @@ -13,7 +14,7 @@ internal static class PackageManifestLoader /// /// A valid Package object /// A Uri object - public static Uri GetPackageManifestUrl(Package package) + public static Uri GetPackageManifestUrl(IPackage package) { return new Uri($"{package.Source.Url}/Packages(Id='{package.Id}',Version='{package.Version}')"); } @@ -23,7 +24,7 @@ public static Uri GetPackageManifestUrl(Package package) /// /// A valid Package object /// A Uri object - public static Uri GetPackageNuGetPackageUrl(Package package) + public static Uri GetPackageNuGetPackageUrl(IPackage package) { return new Uri($"{package.Source.Url}/Packages/{package.Id}.{package.Version}.nupkg"); } @@ -33,7 +34,7 @@ public static Uri GetPackageNuGetPackageUrl(Package package) /// /// The package for which to obtain the manifest /// A string containing the contents of the manifest - public static async Task GetPackageManifestContent(Package package) + public static async Task GetPackageManifestContent(IPackage package) { string? PackageManifestContent = ""; string PackageManifestUrl = GetPackageManifestUrl(package).ToString(); diff --git a/src/UniGetUI.PackageEngine.Managers.Npm/Npm.cs b/src/UniGetUI.PackageEngine.Managers.Npm/Npm.cs index 38592f94a..0d1401892 100644 --- a/src/UniGetUI.PackageEngine.Managers.Npm/Npm.cs +++ b/src/UniGetUI.PackageEngine.Managers.Npm/Npm.cs @@ -1,7 +1,9 @@ using System.Diagnostics; using UniGetUI.Core.Tools; +using UniGetUI.PackageEngine.Classes.Manager; using UniGetUI.PackageEngine.Classes.Manager.ManagerHelpers; using UniGetUI.PackageEngine.Enums; +using UniGetUI.PackageEngine.Interfaces; using UniGetUI.PackageEngine.ManagerClasses.Manager; using UniGetUI.PackageEngine.PackageClasses; @@ -42,7 +44,7 @@ public Npm() : base() PackageDetailsProvider = new NpmPackageDetailsProvider(this); } - protected override async Task FindPackages_UnSafe(string query) + protected override async Task FindPackages_UnSafe(string query) { Process p = new(); p.StartInfo = new ProcessStartInfo() @@ -87,7 +89,7 @@ protected override async Task FindPackages_UnSafe(string query) return Packages.ToArray(); } - protected override async Task GetAvailableUpdates_UnSafe() + protected override async Task GetAvailableUpdates_UnSafe() { List Packages = new(); foreach (PackageScope scope in new PackageScope[] { PackageScope.Local, PackageScope.Global }) @@ -133,7 +135,7 @@ protected override async Task GetAvailableUpdates_UnSafe() return Packages.ToArray(); } - protected override async Task GetInstalledPackages_UnSafe() + protected override async Task GetInstalledPackages_UnSafe() { List Packages = new(); foreach (PackageScope scope in new PackageScope[] { PackageScope.Local, PackageScope.Global }) @@ -181,21 +183,21 @@ protected override async Task GetInstalledPackages_UnSafe() return Packages.ToArray(); } - public override OperationVeredict GetInstallOperationVeredict(Package package, InstallationOptions options, int ReturnCode, string[] Output) + public override OperationVeredict GetInstallOperationVeredict(IPackage package, IInstallationOptions options, int ReturnCode, string[] Output) { return ReturnCode == 0 ? OperationVeredict.Succeeded : OperationVeredict.Failed; } - public override OperationVeredict GetUpdateOperationVeredict(Package package, InstallationOptions options, int ReturnCode, string[] Output) + public override OperationVeredict GetUpdateOperationVeredict(IPackage package, IInstallationOptions options, int ReturnCode, string[] Output) { return ReturnCode == 0 ? OperationVeredict.Succeeded : OperationVeredict.Failed; } - public override OperationVeredict GetUninstallOperationVeredict(Package package, InstallationOptions options, int ReturnCode, string[] Output) + public override OperationVeredict GetUninstallOperationVeredict(IPackage package, IInstallationOptions options, int ReturnCode, string[] Output) { return ReturnCode == 0 ? OperationVeredict.Succeeded : OperationVeredict.Failed; } - public override string[] GetInstallParameters(Package package, InstallationOptions options) + public override string[] GetInstallParameters(IPackage package, IInstallationOptions options) { List parameters = GetUninstallParameters(package, options).ToList(); parameters[0] = Properties.InstallVerb; @@ -213,14 +215,14 @@ public override string[] GetInstallParameters(Package package, InstallationOptio return parameters.ToArray(); } - public override string[] GetUpdateParameters(Package package, InstallationOptions options) + public override string[] GetUpdateParameters(IPackage package, IInstallationOptions options) { string[] parameters = GetInstallParameters(package, options); parameters[0] = Properties.UpdateVerb; parameters[1] = package.Id + "@" + package.NewVersion; return parameters; } - public override string[] GetUninstallParameters(Package package, InstallationOptions options) + public override string[] GetUninstallParameters(IPackage package, IInstallationOptions options) { List parameters = new() { Properties.UninstallVerb, package.Id }; diff --git a/src/UniGetUI.PackageEngine.Managers.Npm/NpmPackageDetailsProvider.cs b/src/UniGetUI.PackageEngine.Managers.Npm/NpmPackageDetailsProvider.cs index db6da5839..da0bd0c08 100644 --- a/src/UniGetUI.PackageEngine.Managers.Npm/NpmPackageDetailsProvider.cs +++ b/src/UniGetUI.PackageEngine.Managers.Npm/NpmPackageDetailsProvider.cs @@ -3,6 +3,7 @@ using UniGetUI.Core.Logging; using UniGetUI.Core.Tools; using UniGetUI.PackageEngine.Classes.Manager.BaseProviders; +using UniGetUI.PackageEngine.Interfaces; using UniGetUI.PackageEngine.ManagerClasses.Classes; using UniGetUI.PackageEngine.ManagerClasses.Manager; using UniGetUI.PackageEngine.PackageClasses; @@ -13,7 +14,7 @@ internal class NpmPackageDetailsProvider : BasePackageDetailsProvider GetPackageIcon_Unsafe(Package package) + protected override Task GetPackageIcon_Unsafe(IPackage package) { throw new NotImplementedException(); } - protected override Task GetPackageScreenshots_Unsafe(Package package) + protected override Task GetPackageScreenshots_Unsafe(IPackage package) { throw new NotImplementedException(); } - protected override async Task GetPackageVersions_Unsafe(Package package) + protected override async Task GetPackageVersions_Unsafe(IPackage package) { Process p = new(); p.StartInfo = new ProcessStartInfo() diff --git a/src/UniGetUI.PackageEngine.Managers.Npm/UniGetUI.PackageEngine.Managers.Npm.csproj b/src/UniGetUI.PackageEngine.Managers.Npm/UniGetUI.PackageEngine.Managers.Npm.csproj index 8dd11e9ac..2cac1c47e 100644 --- a/src/UniGetUI.PackageEngine.Managers.Npm/UniGetUI.PackageEngine.Managers.Npm.csproj +++ b/src/UniGetUI.PackageEngine.Managers.Npm/UniGetUI.PackageEngine.Managers.Npm.csproj @@ -34,7 +34,8 @@ - + + diff --git a/src/UniGetUI.PackageEngine.Managers.Pip/Pip.cs b/src/UniGetUI.PackageEngine.Managers.Pip/Pip.cs index e3795f05c..6e5106572 100644 --- a/src/UniGetUI.PackageEngine.Managers.Pip/Pip.cs +++ b/src/UniGetUI.PackageEngine.Managers.Pip/Pip.cs @@ -1,8 +1,10 @@ using System.Diagnostics; using System.Text.RegularExpressions; using UniGetUI.Core.Tools; +using UniGetUI.PackageEngine.Classes.Manager; using UniGetUI.PackageEngine.Classes.Manager.ManagerHelpers; using UniGetUI.PackageEngine.Enums; +using UniGetUI.PackageEngine.Interfaces; using UniGetUI.PackageEngine.ManagerClasses.Classes; using UniGetUI.PackageEngine.ManagerClasses.Manager; using UniGetUI.PackageEngine.PackageClasses; @@ -44,7 +46,7 @@ public Pip() : base() PackageDetailsProvider = new PipPackageDetailsProvider(this); } - protected override async Task FindPackages_UnSafe(string query) + protected override async Task FindPackages_UnSafe(string query) { List Packages = new(); @@ -123,7 +125,7 @@ protected override async Task FindPackages_UnSafe(string query) return Packages.ToArray(); } - protected override async Task GetAvailableUpdates_UnSafe() + protected override async Task GetAvailableUpdates_UnSafe() { Process p = new(); p.StartInfo = new ProcessStartInfo() @@ -172,7 +174,7 @@ protected override async Task GetAvailableUpdates_UnSafe() return Packages.ToArray(); } - protected override async Task GetInstalledPackages_UnSafe() + protected override async Task GetInstalledPackages_UnSafe() { Process p = new(); @@ -222,7 +224,7 @@ protected override async Task GetInstalledPackages_UnSafe() return Packages.ToArray(); } - public override OperationVeredict GetInstallOperationVeredict(Package package, InstallationOptions options, int ReturnCode, string[] Output) + public override OperationVeredict GetInstallOperationVeredict(IPackage package, IInstallationOptions options, int ReturnCode, string[] Output) { string output_string = string.Join("\n", Output); @@ -237,22 +239,22 @@ public override OperationVeredict GetInstallOperationVeredict(Package package, I return OperationVeredict.Failed; } - public override OperationVeredict GetUpdateOperationVeredict(Package package, InstallationOptions options, int ReturnCode, string[] Output) + public override OperationVeredict GetUpdateOperationVeredict(IPackage package, IInstallationOptions options, int ReturnCode, string[] Output) { return GetInstallOperationVeredict(package, options, ReturnCode, Output); } - public override OperationVeredict GetUninstallOperationVeredict(Package package, InstallationOptions options, int ReturnCode, string[] Output) + public override OperationVeredict GetUninstallOperationVeredict(IPackage package, IInstallationOptions options, int ReturnCode, string[] Output) { return GetInstallOperationVeredict(package, options, ReturnCode, Output); } - public override string[] GetInstallParameters(Package package, InstallationOptions options) + public override string[] GetInstallParameters(IPackage package, IInstallationOptions options) { string[] parameters = GetUpdateParameters(package, options); parameters[0] = Properties.InstallVerb; return parameters; } - public override string[] GetUpdateParameters(Package package, InstallationOptions options) + public override string[] GetUpdateParameters(IPackage package, IInstallationOptions options) { List parameters = GetUninstallParameters(package, options).ToList(); parameters[0] = Properties.UpdateVerb; @@ -271,7 +273,7 @@ public override string[] GetUpdateParameters(Package package, InstallationOption return parameters.ToArray(); } - public override string[] GetUninstallParameters(Package package, InstallationOptions options) + public override string[] GetUninstallParameters(IPackage package, IInstallationOptions options) { List parameters = new() { Properties.UninstallVerb, package.Id, "--yes", "--no-input", "--no-color", "--no-python-version-warning", "--no-cache" }; diff --git a/src/UniGetUI.PackageEngine.Managers.Pip/PipPackageDetailsProvider.cs b/src/UniGetUI.PackageEngine.Managers.Pip/PipPackageDetailsProvider.cs index ae2a16f1f..03830b0cd 100644 --- a/src/UniGetUI.PackageEngine.Managers.Pip/PipPackageDetailsProvider.cs +++ b/src/UniGetUI.PackageEngine.Managers.Pip/PipPackageDetailsProvider.cs @@ -4,6 +4,7 @@ using UniGetUI.Core.IconEngine; using UniGetUI.Core.Tools; using UniGetUI.PackageEngine.Classes.Manager.BaseProviders; +using UniGetUI.PackageEngine.Interfaces; using UniGetUI.PackageEngine.ManagerClasses.Manager; using UniGetUI.PackageEngine.PackageClasses; @@ -13,7 +14,7 @@ internal class PipPackageDetailsProvider : BasePackageDetailsProvider GetPackageIcon_Unsafe(Package package) + protected override Task GetPackageIcon_Unsafe(IPackage package) { throw new NotImplementedException(); } - protected override Task GetPackageScreenshots_Unsafe(Package package) + protected override Task GetPackageScreenshots_Unsafe(IPackage package) { throw new NotImplementedException(); } - protected override async Task GetPackageVersions_Unsafe(Package package) + protected override async Task GetPackageVersions_Unsafe(IPackage package) { Process p = new(); p.StartInfo = new ProcessStartInfo() diff --git a/src/UniGetUI.PackageEngine.Managers.Pip/UniGetUI.PackageEngine.Managers.Pip.csproj b/src/UniGetUI.PackageEngine.Managers.Pip/UniGetUI.PackageEngine.Managers.Pip.csproj index eb628f15b..2d52295bf 100644 --- a/src/UniGetUI.PackageEngine.Managers.Pip/UniGetUI.PackageEngine.Managers.Pip.csproj +++ b/src/UniGetUI.PackageEngine.Managers.Pip/UniGetUI.PackageEngine.Managers.Pip.csproj @@ -34,7 +34,8 @@ - + + diff --git a/src/UniGetUI.PackageEngine.Managers.PowerShell/PowerShell.cs b/src/UniGetUI.PackageEngine.Managers.PowerShell/PowerShell.cs index 509a4db09..ece2e15c3 100644 --- a/src/UniGetUI.PackageEngine.Managers.PowerShell/PowerShell.cs +++ b/src/UniGetUI.PackageEngine.Managers.PowerShell/PowerShell.cs @@ -1,8 +1,10 @@ using System.Diagnostics; using System.Text.RegularExpressions; using UniGetUI.Core.Tools; +using UniGetUI.PackageEngine.Classes.Manager; using UniGetUI.PackageEngine.Classes.Manager.ManagerHelpers; using UniGetUI.PackageEngine.Enums; +using UniGetUI.PackageEngine.Interfaces; using UniGetUI.PackageEngine.ManagerClasses.Classes; using UniGetUI.PackageEngine.ManagerClasses.Manager; using UniGetUI.PackageEngine.PackageClasses; @@ -26,7 +28,7 @@ public PowerShell() : base() SupportsCustomSources = true, SupportsPreRelease = true, SupportsCustomPackageIcons = true, - Sources = new ManagerSource.Capabilities() + Sources = new SourceCapabilities() { KnowsPackageCount = false, KnowsUpdateDate = false, @@ -44,14 +46,14 @@ public PowerShell() : base() UninstallVerb = "Uninstall-Module", UpdateVerb = "Update-Module", ExecutableCallArgs = " -NoProfile -Command", - KnownSources = [new(this, "PSGallery", new Uri("https://www.powershellgallery.com/api/v2")), - new(this, "PoshTestGallery", new Uri("https://www.poshtestgallery.com/api/v2"))], + KnownSources = [new ManagerSource(this, "PSGallery", new Uri("https://www.powershellgallery.com/api/v2")), + new ManagerSource(this, "PoshTestGallery", new Uri("https://www.poshtestgallery.com/api/v2"))], DefaultSource = new ManagerSource(this, "PSGallery", new Uri("https://www.powershellgallery.com/api/v2")), }; SourceProvider = new PowerShellSourceProvider(this); } - protected override async Task GetAvailableUpdates_UnSafe() + protected override async Task GetAvailableUpdates_UnSafe() { Process p = new(); p.StartInfo = new ProcessStartInfo() @@ -125,7 +127,7 @@ function Test-GalleryModuleUpdate { return Packages.ToArray(); } - protected override async Task GetInstalledPackages_UnSafe() + protected override async Task GetInstalledPackages_UnSafe() { Process p = new(); p.StartInfo = new ProcessStartInfo() @@ -173,17 +175,17 @@ protected override async Task GetInstalledPackages_UnSafe() return Packages.ToArray(); } - public override OperationVeredict GetInstallOperationVeredict(Package package, InstallationOptions options, int ReturnCode, string[] Output) + public override OperationVeredict GetInstallOperationVeredict(IPackage package, IInstallationOptions options, int ReturnCode, string[] Output) { return GetUninstallOperationVeredict(package, options, ReturnCode, Output); } - public override OperationVeredict GetUpdateOperationVeredict(Package package, InstallationOptions options, int ReturnCode, string[] Output) + public override OperationVeredict GetUpdateOperationVeredict(IPackage package, IInstallationOptions options, int ReturnCode, string[] Output) { return GetUninstallOperationVeredict(package, options, ReturnCode, Output); } - public override OperationVeredict GetUninstallOperationVeredict(Package package, InstallationOptions options, int ReturnCode, string[] Output) + public override OperationVeredict GetUninstallOperationVeredict(IPackage package, IInstallationOptions options, int ReturnCode, string[] Output) { string output_string = string.Join("\n", Output); @@ -195,7 +197,7 @@ public override OperationVeredict GetUninstallOperationVeredict(Package package, return ReturnCode == 0 ? OperationVeredict.Succeeded : OperationVeredict.Failed; } - public override string[] GetInstallParameters(Package package, InstallationOptions options) + public override string[] GetInstallParameters(IPackage package, IInstallationOptions options) { List parameters = GetUpdateParameters(package, options).ToList(); parameters[0] = Properties.InstallVerb; @@ -212,7 +214,7 @@ public override string[] GetInstallParameters(Package package, InstallationOptio return parameters.ToArray(); } - public override string[] GetUpdateParameters(Package package, InstallationOptions options) + public override string[] GetUpdateParameters(IPackage package, IInstallationOptions options) { List parameters = GetUninstallParameters(package, options).ToList(); parameters[0] = Properties.UpdateVerb; @@ -226,7 +228,7 @@ public override string[] GetUpdateParameters(Package package, InstallationOption return parameters.ToArray(); } - public override string[] GetUninstallParameters(Package package, InstallationOptions options) + public override string[] GetUninstallParameters(IPackage package, IInstallationOptions options) { List parameters = new() { Properties.UninstallVerb, "-Name", package.Id, "-Confirm:$false", "-Force" }; diff --git a/src/UniGetUI.PackageEngine.Managers.PowerShell/PowerShellSourceProvider.cs b/src/UniGetUI.PackageEngine.Managers.PowerShell/PowerShellSourceProvider.cs index b01e2dca9..99e75651b 100644 --- a/src/UniGetUI.PackageEngine.Managers.PowerShell/PowerShellSourceProvider.cs +++ b/src/UniGetUI.PackageEngine.Managers.PowerShell/PowerShellSourceProvider.cs @@ -1,9 +1,10 @@ using System.Diagnostics; using System.Text.RegularExpressions; using UniGetUI.Core.Logging; -using UniGetUI.PackageEngine.Classes.Manager.ManagerHelpers; +using UniGetUI.PackageEngine.Classes.Manager; using UniGetUI.PackageEngine.Classes.Manager.Providers; using UniGetUI.PackageEngine.Enums; +using UniGetUI.PackageEngine.Interfaces; using UniGetUI.PackageEngine.ManagerClasses.Manager; namespace UniGetUI.PackageEngine.Managers.PowerShellManager @@ -12,29 +13,29 @@ internal class PowerShellSourceProvider : BaseSourceProvider { public PowerShellSourceProvider(PowerShell manager) : base(manager) { } - public override string[] GetAddSourceParameters(ManagerSource source) + public override string[] GetAddSourceParameters(IManagerSource source) { if (source.Url.ToString() == "https://www.powershellgallery.com/api/v2") return [ "Register-PSRepository", "-Default" ]; return [ "Register-PSRepository", "-Name", source.Name, "-SourceLocation", source.Url.ToString() ]; } - public override string[] GetRemoveSourceParameters(ManagerSource source) + public override string[] GetRemoveSourceParameters(IManagerSource source) { return [ "Unregister-PSRepository", "-Name", source.Name ]; } - public override OperationVeredict GetAddSourceOperationVeredict(ManagerSource source, int ReturnCode, string[] Output) + public override OperationVeredict GetAddSourceOperationVeredict(IManagerSource source, int ReturnCode, string[] Output) { return ReturnCode == 0 ? OperationVeredict.Succeeded : OperationVeredict.Failed; } - public override OperationVeredict GetRemoveSourceOperationVeredict(ManagerSource source, int ReturnCode, string[] Output) + public override OperationVeredict GetRemoveSourceOperationVeredict(IManagerSource source, int ReturnCode, string[] Output) { return ReturnCode == 0 ? OperationVeredict.Succeeded : OperationVeredict.Failed; } - protected override async Task GetSources_UnSafe() + protected override async Task GetSources_UnSafe() { List sources = new(); diff --git a/src/UniGetUI.PackageEngine.Managers.PowerShell/UniGetUI.PackageEngine.Managers.PowerShell.csproj b/src/UniGetUI.PackageEngine.Managers.PowerShell/UniGetUI.PackageEngine.Managers.PowerShell.csproj index e1c5bd2da..1cc862ee9 100644 --- a/src/UniGetUI.PackageEngine.Managers.PowerShell/UniGetUI.PackageEngine.Managers.PowerShell.csproj +++ b/src/UniGetUI.PackageEngine.Managers.PowerShell/UniGetUI.PackageEngine.Managers.PowerShell.csproj @@ -35,7 +35,8 @@ - + + diff --git a/src/UniGetUI.PackageEngine.Managers.Scoop/Scoop.cs b/src/UniGetUI.PackageEngine.Managers.Scoop/Scoop.cs index 91d106291..1714d1aad 100644 --- a/src/UniGetUI.PackageEngine.Managers.Scoop/Scoop.cs +++ b/src/UniGetUI.PackageEngine.Managers.Scoop/Scoop.cs @@ -4,8 +4,10 @@ using UniGetUI.Core.Logging; using UniGetUI.Core.SettingsEngine; using UniGetUI.Core.Tools; +using UniGetUI.PackageEngine.Classes.Manager; using UniGetUI.PackageEngine.Classes.Manager.ManagerHelpers; using UniGetUI.PackageEngine.Enums; +using UniGetUI.PackageEngine.Interfaces; using UniGetUI.PackageEngine.ManagerClasses.Manager; using UniGetUI.PackageEngine.PackageClasses; @@ -31,7 +33,7 @@ public Scoop(): base() SupportedCustomArchitectures = new Architecture[] { Architecture.X86, Architecture.X64, Architecture.Arm64 }, SupportsCustomScopes = true, SupportsCustomSources = true, - Sources = new ManagerSource.Capabilities() + Sources = new SourceCapabilities() { KnowsPackageCount = true, KnowsUpdateDate = true @@ -49,24 +51,24 @@ public Scoop(): base() InstallVerb = "install", UpdateVerb = "update", UninstallVerb = "uninstall", - KnownSources = [new(this, "main", new Uri("https://github.com/ScoopInstaller/Main")), - new(this, "extras", new Uri("https://github.com/ScoopInstaller/Extras")), - new(this, "versions", new Uri("https://github.com/ScoopInstaller/Versions")), - new(this, "nirsoft", new Uri("https://github.com/kodybrown/scoop-nirsoft")), - new(this, "sysinternals", new Uri("https://github.com/niheaven/scoop-sysinternals")), - new(this, "php", new Uri("https://github.com/ScoopInstaller/PHP")), - new(this, "nerd-fonts", new Uri("https://github.com/matthewjberger/scoop-nerd-fonts")), - new(this, "nonportable", new Uri("https://github.com/ScoopInstaller/Nonportable")), - new(this, "java", new Uri("https://github.com/ScoopInstaller/Java")), - new(this, "games", new Uri("https://github.com/Calinou/scoop-games"))], - DefaultSource = new(this, "main", new Uri("https://github.com/ScoopInstaller/Main")), + KnownSources = [new ManagerSource(this, "main", new Uri("https://github.com/ScoopInstaller/Main")), + new ManagerSource(this, "extras", new Uri("https://github.com/ScoopInstaller/Extras")), + new ManagerSource(this, "versions", new Uri("https://github.com/ScoopInstaller/Versions")), + new ManagerSource(this, "nirsoft", new Uri("https://github.com/kodybrown/scoop-nirsoft")), + new ManagerSource(this, "sysinternals", new Uri("https://github.com/niheaven/scoop-sysinternals")), + new ManagerSource(this, "php", new Uri("https://github.com/ScoopInstaller/PHP")), + new ManagerSource(this, "nerd-fonts", new Uri("https://github.com/matthewjberger/scoop-nerd-fonts")), + new ManagerSource(this, "nonportable", new Uri("https://github.com/ScoopInstaller/Nonportable")), + new ManagerSource(this, "java", new Uri("https://github.com/ScoopInstaller/Java")), + new ManagerSource(this, "games", new Uri("https://github.com/Calinou/scoop-games"))], + DefaultSource = new ManagerSource(this, "main", new Uri("https://github.com/ScoopInstaller/Main")), }; SourceProvider = new ScoopSourceProvider(this); PackageDetailsProvider = new ScoopPackageDetailsProvider(this); } - protected override async Task FindPackages_UnSafe(string query) + protected override async Task FindPackages_UnSafe(string query) { List Packages = new(); @@ -113,7 +115,7 @@ protected override async Task FindPackages_UnSafe(string query) p.Start(); string? line; - ManagerSource source = Properties.DefaultSource; + IManagerSource source = Properties.DefaultSource; while ((line = await p.StandardOutput.ReadLineAsync()) != null) { logger.AddToStdOut(line); @@ -142,7 +144,7 @@ protected override async Task FindPackages_UnSafe(string query) return Packages.ToArray(); } - protected override async Task GetAvailableUpdates_UnSafe() + protected override async Task GetAvailableUpdates_UnSafe() { Dictionary InstalledPackages = new(); foreach (Package InstalledPackage in await GetInstalledPackages()) @@ -207,7 +209,7 @@ protected override async Task GetAvailableUpdates_UnSafe() return Packages.ToArray(); } - protected override async Task GetInstalledPackages_UnSafe() + protected override async Task GetInstalledPackages_UnSafe() { List Packages = new(); @@ -262,7 +264,7 @@ protected override async Task GetInstalledPackages_UnSafe() } - public override OperationVeredict GetUninstallOperationVeredict(Package package, InstallationOptions options, int ReturnCode, string[] Output) + public override OperationVeredict GetUninstallOperationVeredict(IPackage package, IInstallationOptions options, int ReturnCode, string[] Output) { string output_string = string.Join("\n", Output); if ((output_string.Contains("Try again with the --global (or -g) flag instead") && package.Scope == PackageScope.Local)) @@ -279,7 +281,7 @@ public override OperationVeredict GetUninstallOperationVeredict(Package package, return OperationVeredict.Succeeded; return OperationVeredict.Failed; } - public override OperationVeredict GetInstallOperationVeredict(Package package, InstallationOptions options, int ReturnCode, string[] Output) + public override OperationVeredict GetInstallOperationVeredict(IPackage package, IInstallationOptions options, int ReturnCode, string[] Output) { string output_string = string.Join("\n", Output); if ((output_string.Contains("Try again with the --global (or -g) flag instead") && package.Scope == PackageScope.Local)) @@ -296,12 +298,12 @@ public override OperationVeredict GetInstallOperationVeredict(Package package, I return OperationVeredict.Failed; return OperationVeredict.Succeeded; } - public override OperationVeredict GetUpdateOperationVeredict(Package package, InstallationOptions options, int ReturnCode, string[] Output) + public override OperationVeredict GetUpdateOperationVeredict(IPackage package, IInstallationOptions options, int ReturnCode, string[] Output) { return GetInstallOperationVeredict(package, options, ReturnCode, Output); } - public override string[] GetUninstallParameters(Package package, InstallationOptions options) + public override string[] GetUninstallParameters(IPackage package, IInstallationOptions options) { List parameters = new(); @@ -319,13 +321,13 @@ public override string[] GetUninstallParameters(Package package, InstallationOpt return parameters.ToArray(); } - public override string[] GetInstallParameters(Package package, InstallationOptions options) + public override string[] GetInstallParameters(IPackage package, IInstallationOptions options) { string[] parameters = GetUpdateParameters(package, options); parameters[0] = Properties.InstallVerb; return parameters; } - public override string[] GetUpdateParameters(Package package, InstallationOptions options) + public override string[] GetUpdateParameters(IPackage package, IInstallationOptions options) { List parameters = GetUninstallParameters(package, options).ToList(); parameters[0] = Properties.UpdateVerb; diff --git a/src/UniGetUI.PackageEngine.Managers.Scoop/ScoopPackageDetailsProvider.cs b/src/UniGetUI.PackageEngine.Managers.Scoop/ScoopPackageDetailsProvider.cs index b06dbac7a..6955257ca 100644 --- a/src/UniGetUI.PackageEngine.Managers.Scoop/ScoopPackageDetailsProvider.cs +++ b/src/UniGetUI.PackageEngine.Managers.Scoop/ScoopPackageDetailsProvider.cs @@ -4,6 +4,7 @@ using UniGetUI.Core.Logging; using UniGetUI.Core.Tools; using UniGetUI.PackageEngine.Classes.Manager.BaseProviders; +using UniGetUI.PackageEngine.Interfaces; using UniGetUI.PackageEngine.ManagerClasses.Classes; using UniGetUI.PackageEngine.ManagerClasses.Manager; using UniGetUI.PackageEngine.PackageClasses; @@ -14,7 +15,7 @@ internal class ScoopPackageDetailsProvider : BasePackageDetailsProvider GetPackageIcon_Unsafe(Package package) + protected override Task GetPackageIcon_Unsafe(IPackage package) { throw new NotImplementedException(); } - protected override Task GetPackageScreenshots_Unsafe(Package package) + protected override Task GetPackageScreenshots_Unsafe(IPackage package) { throw new NotImplementedException(); } #pragma warning disable - protected override async Task GetPackageVersions_Unsafe(Package package) + protected override async Task GetPackageVersions_Unsafe(IPackage package) { throw new Exception("Scoop does not support custom package versions"); } diff --git a/src/UniGetUI.PackageEngine.Managers.Scoop/ScoopSourceProvider.cs b/src/UniGetUI.PackageEngine.Managers.Scoop/ScoopSourceProvider.cs index 9c12db10a..9b8c0c889 100644 --- a/src/UniGetUI.PackageEngine.Managers.Scoop/ScoopSourceProvider.cs +++ b/src/UniGetUI.PackageEngine.Managers.Scoop/ScoopSourceProvider.cs @@ -1,9 +1,10 @@ using System.Diagnostics; using System.Text.RegularExpressions; using UniGetUI.Core.Logging; -using UniGetUI.PackageEngine.Classes.Manager.ManagerHelpers; +using UniGetUI.PackageEngine.Classes.Manager; using UniGetUI.PackageEngine.Classes.Manager.Providers; using UniGetUI.PackageEngine.Enums; +using UniGetUI.PackageEngine.Interfaces; using UniGetUI.PackageEngine.ManagerClasses.Manager; namespace UniGetUI.PackageEngine.Managers.ScoopManager @@ -12,27 +13,27 @@ internal class ScoopSourceProvider : BaseSourceProvider { public ScoopSourceProvider(Scoop manager) : base(manager) { } - public override OperationVeredict GetAddSourceOperationVeredict(ManagerSource source, int ReturnCode, string[] Output) + public override OperationVeredict GetAddSourceOperationVeredict(IManagerSource source, int ReturnCode, string[] Output) { return ReturnCode == 0 ? OperationVeredict.Succeeded : OperationVeredict.Failed; } - public override string[] GetAddSourceParameters(ManagerSource source) + public override string[] GetAddSourceParameters(IManagerSource source) { return new string[] { "bucket", "add", source.Name, source.Url.ToString() }; } - public override OperationVeredict GetRemoveSourceOperationVeredict(ManagerSource source, int ReturnCode, string[] Output) + public override OperationVeredict GetRemoveSourceOperationVeredict(IManagerSource source, int ReturnCode, string[] Output) { return ReturnCode == 0 ? OperationVeredict.Succeeded : OperationVeredict.Failed; } - public override string[] GetRemoveSourceParameters(ManagerSource source) + public override string[] GetRemoveSourceParameters(IManagerSource source) { return new string[] { "bucket", "rm", source.Name }; } - protected override async Task GetSources_UnSafe() + protected override async Task GetSources_UnSafe() { using (Process p = new()) { diff --git a/src/UniGetUI.PackageEngine.Managers.Scoop/UniGetUI.PackageEngine.Managers.Scoop.csproj b/src/UniGetUI.PackageEngine.Managers.Scoop/UniGetUI.PackageEngine.Managers.Scoop.csproj index 41dc87982..2d52295bf 100644 --- a/src/UniGetUI.PackageEngine.Managers.Scoop/UniGetUI.PackageEngine.Managers.Scoop.csproj +++ b/src/UniGetUI.PackageEngine.Managers.Scoop/UniGetUI.PackageEngine.Managers.Scoop.csproj @@ -34,9 +34,9 @@ - + + - diff --git a/src/UniGetUI.PackageEngine.Managers.WinGet/UniGetUI.PackageEngine.Managers.WinGet.csproj b/src/UniGetUI.PackageEngine.Managers.WinGet/UniGetUI.PackageEngine.Managers.WinGet.csproj index c5d377248..47da715b6 100644 --- a/src/UniGetUI.PackageEngine.Managers.WinGet/UniGetUI.PackageEngine.Managers.WinGet.csproj +++ b/src/UniGetUI.PackageEngine.Managers.WinGet/UniGetUI.PackageEngine.Managers.WinGet.csproj @@ -35,9 +35,9 @@ - + + - diff --git a/src/UniGetUI.PackageEngine.Managers.WinGet/WinGet.cs b/src/UniGetUI.PackageEngine.Managers.WinGet/WinGet.cs index 7f1e28b0e..7b6b229ae 100644 --- a/src/UniGetUI.PackageEngine.Managers.WinGet/WinGet.cs +++ b/src/UniGetUI.PackageEngine.Managers.WinGet/WinGet.cs @@ -2,8 +2,10 @@ using System.Runtime.InteropServices; using UniGetUI.Core.Logging; using UniGetUI.Core.Tools; +using UniGetUI.PackageEngine.Classes.Manager; using UniGetUI.PackageEngine.Classes.Manager.ManagerHelpers; using UniGetUI.PackageEngine.Enums; +using UniGetUI.PackageEngine.Interfaces; using UniGetUI.PackageEngine.ManagerClasses.Manager; using UniGetUI.PackageEngine.PackageClasses; @@ -37,7 +39,7 @@ public WinGet(): base() SupportsCustomSources = true, SupportsCustomPackageIcons = true, SupportsCustomPackageScreenshots = true, - Sources = new ManagerSource.Capabilities() + Sources = new SourceCapabilities() { KnowsPackageCount = false, KnowsUpdateDate = true, @@ -56,9 +58,9 @@ public WinGet(): base() UninstallVerb = "uninstall", UpdateVerb = "update", ExecutableCallArgs = "", - KnownSources = [ new(this, "winget", new Uri("https://cdn.winget.microsoft.com/cache")), - new(this, "msstore", new Uri("https://storeedgefd.dsx.mp.microsoft.com/v9.0")) ], - DefaultSource = new(this, "winget", new Uri("https://cdn.winget.microsoft.com/cache")) + KnownSources = [ new ManagerSource(this, "winget", new Uri("https://cdn.winget.microsoft.com/cache")), + new ManagerSource(this, "msstore", new Uri("https://storeedgefd.dsx.mp.microsoft.com/v9.0")) ], + DefaultSource = new ManagerSource(this, "winget", new Uri("https://cdn.winget.microsoft.com/cache")) }; SourceProvider = new WinGetSourceProvider(this); @@ -72,12 +74,12 @@ public WinGet(): base() MicrosoftStoreSource = new(this, "Microsoft Store", "msstore"); } - protected override async Task FindPackages_UnSafe(string query) + protected override async Task FindPackages_UnSafe(string query) { return await WinGetHelper.Instance.FindPackages_UnSafe(this, query); } - protected override async Task GetAvailableUpdates_UnSafe() + protected override async Task GetAvailableUpdates_UnSafe() { List Packages = new(); @@ -139,7 +141,7 @@ function Print-WinGetPackage { if (elements.Length < 5) continue; - ManagerSource source = GetSourceOrDefault(elements[4]); + IManagerSource source = GetSourceOrDefault(elements[4]); Packages.Add(new Package(elements[0][1..], elements[1], elements[2], elements[3], source, this)); } @@ -151,7 +153,7 @@ function Print-WinGetPackage { return Packages.ToArray(); } - protected override async Task GetInstalledPackages_UnSafe() + protected override async Task GetInstalledPackages_UnSafe() { List Packages = new(); @@ -211,7 +213,7 @@ function Print-WinGetPackage { if (elements.Length < 4) continue; - ManagerSource source; + IManagerSource source; if (elements[3] != "") source = GetSourceOrDefault(elements[3]); else @@ -269,7 +271,7 @@ private ManagerSource GetLocalSource(string id) } } - public override string[] GetInstallParameters(Package package, InstallationOptions options) + public override string[] GetInstallParameters(IPackage package, IInstallationOptions options) { List parameters = GetUninstallParameters(package, options).ToList(); parameters[0] = Properties.InstallVerb; @@ -300,7 +302,7 @@ public override string[] GetInstallParameters(Package package, InstallationOptio } return parameters.ToArray(); } - public override string[] GetUpdateParameters(Package package, InstallationOptions options) + public override string[] GetUpdateParameters(IPackage package, IInstallationOptions options) { if (package.Name.Contains("64-bit") || package.Id.ToLower().Contains("x64")) options.Architecture = Architecture.X64; @@ -316,7 +318,7 @@ public override string[] GetUpdateParameters(Package package, InstallationOption return parameters; } - public override string[] GetUninstallParameters(Package package, InstallationOptions options) + public override string[] GetUninstallParameters(IPackage package, IInstallationOptions options) { List parameters = [ Properties.UninstallVerb, "--id", package.Id, "--exact"]; if(!package.Source.IsVirtualManager) @@ -351,7 +353,7 @@ public override string[] GetUninstallParameters(Package package, InstallationOpt return parameters.ToArray(); } - public override OperationVeredict GetInstallOperationVeredict(Package package, InstallationOptions options, int ReturnCode, string[] Output) + public override OperationVeredict GetInstallOperationVeredict(IPackage package, IInstallationOptions options, int ReturnCode, string[] Output) { string output_string = string.Join("\n", Output); @@ -388,12 +390,12 @@ public override OperationVeredict GetInstallOperationVeredict(Package package, I return ReturnCode == 0 ? OperationVeredict.Succeeded : OperationVeredict.Failed; } - public override OperationVeredict GetUpdateOperationVeredict(Package package, InstallationOptions options, int ReturnCode, string[] Output) + public override OperationVeredict GetUpdateOperationVeredict(IPackage package, IInstallationOptions options, int ReturnCode, string[] Output) { return GetInstallOperationVeredict(package, options, ReturnCode, Output); } - public override OperationVeredict GetUninstallOperationVeredict(Package package, InstallationOptions options, int ReturnCode, string[] Output) + public override OperationVeredict GetUninstallOperationVeredict(IPackage package, IInstallationOptions options, int ReturnCode, string[] Output) { string output_string = string.Join("\n", Output); diff --git a/src/UniGetUI.PackageEngine.Managers.WinGet/WinGetHelpers.cs b/src/UniGetUI.PackageEngine.Managers.WinGet/WinGetHelpers.cs index eba636102..bba9cbe56 100644 --- a/src/UniGetUI.PackageEngine.Managers.WinGet/WinGetHelpers.cs +++ b/src/UniGetUI.PackageEngine.Managers.WinGet/WinGetHelpers.cs @@ -4,8 +4,9 @@ using UniGetUI.Core.Data; using UniGetUI.Core.Logging; using UniGetUI.Core.Tools; -using UniGetUI.PackageEngine.Classes.Manager.ManagerHelpers; +using UniGetUI.PackageEngine.Classes.Manager; using UniGetUI.PackageEngine.Enums; +using UniGetUI.PackageEngine.Interfaces; using UniGetUI.PackageEngine.PackageClasses; using WindowsPackageManager.Interop; using Deployment = Microsoft.Management.Deployment; @@ -36,10 +37,10 @@ public static IWinGetPackageHelper Instance internal interface IWinGetPackageHelper { - public Task FindPackages_UnSafe(WinGet ManagerInstance, string query); - public Task GetSources_UnSafe(WinGet ManagerInstance); - public Task GetPackageVersions_Unsafe(WinGet ManagerInstance, Package package); - public Task GetPackageDetails_UnSafe(WinGet ManagerInstance, PackageDetails details); + public Task FindPackages_UnSafe(WinGet ManagerInstance, string query); + public Task GetSources_UnSafe(WinGet ManagerInstance); + public Task GetPackageVersions_Unsafe(WinGet ManagerInstance, IPackage package); + public Task GetPackageDetails_UnSafe(WinGet ManagerInstance, IPackageDetails details); } @@ -57,7 +58,7 @@ public NativeWinGetHelper() } - public async Task FindPackages_UnSafe(WinGet ManagerInstance, string query) + public async Task FindPackages_UnSafe(WinGet ManagerInstance, string query) { ManagerClasses.Classes.NativeTaskLogger logger = ManagerInstance.TaskLogger.CreateNew(LoggableTaskType.FindPackages); @@ -126,7 +127,7 @@ public async Task FindPackages_UnSafe(WinGet ManagerInstance, string try { // Get the source for the catalog - ManagerSource source = ManagerInstance.GetSourceOrDefault(CatalogTaskPair.Key.Info.Name); + IManagerSource source = ManagerInstance.GetSourceOrDefault(CatalogTaskPair.Key.Info.Name); FindPackagesResult FoundPackages = CatalogTaskPair.Value.Result; foreach (MatchResult package in FoundPackages.Matches.ToArray()) @@ -153,9 +154,9 @@ public async Task FindPackages_UnSafe(WinGet ManagerInstance, string return Packages.ToArray(); } - public async Task GetSources_UnSafe(WinGet ManagerInstance) + public async Task GetSources_UnSafe(WinGet ManagerInstance) { - List sources = new(); + List sources = new(); ManagerClasses.Classes.NativeTaskLogger logger = ManagerInstance.TaskLogger.CreateNew(LoggableTaskType.ListSources); foreach (PackageCatalogReference catalog in await Task.Run(() => WinGetManager.GetPackageCatalogs().ToArray())) @@ -172,7 +173,7 @@ public async Task GetSources_UnSafe(WinGet ManagerInstance) return sources.ToArray(); } - public async Task GetPackageVersions_Unsafe(WinGet ManagerInstance, Package package) + public async Task GetPackageVersions_Unsafe(WinGet ManagerInstance, IPackage package) { ManagerClasses.Classes.NativeTaskLogger logger = ManagerInstance.TaskLogger.CreateNew(LoggableTaskType.LoadPackageVersions); @@ -220,7 +221,7 @@ public async Task GetPackageVersions_Unsafe(WinGet ManagerInstance, Pa return versions ?? []; } - public async Task GetPackageDetails_UnSafe(WinGet ManagerInstance, PackageDetails details) + public async Task GetPackageDetails_UnSafe(WinGet ManagerInstance, IPackageDetails details) { ManagerClasses.Classes.NativeTaskLogger logger = ManagerInstance.TaskLogger.CreateNew(LoggableTaskType.LoadPackageDetails); @@ -377,7 +378,7 @@ public BundledWinGetHelper() WinGetBundledPath = Path.Join(CoreData.UniGetUIExecutableDirectory, "PackageEngine", "Managers", "winget-cli_x64", "winget.exe"); } - public async Task FindPackages_UnSafe(WinGet ManagerInstance, string query) + public async Task FindPackages_UnSafe(WinGet ManagerInstance, string query) { List Packages = new(); @@ -433,7 +434,7 @@ function Print-WinGetPackage { if (elements.Length < 4) continue; - ManagerSource source = ManagerInstance.GetSourceOrDefault(elements[3]); + IManagerSource source = ManagerInstance.GetSourceOrDefault(elements[3]); Packages.Add(new Package(elements[0][1..], elements[1], elements[2], source, ManagerInstance)); } @@ -446,7 +447,7 @@ function Print-WinGetPackage { } - public async Task GetPackageDetails_UnSafe(WinGet ManagerInstance, PackageDetails details) + public async Task GetPackageDetails_UnSafe(WinGet ManagerInstance, IPackageDetails details) { if (details.Package.Source.Name == "winget") details.ManifestUrl = new Uri("https://github.com/microsoft/winget-pkgs/tree/master/manifests/" @@ -637,7 +638,7 @@ public async Task GetPackageDetails_UnSafe(WinGet ManagerInstance, PackageDetail return; } - public async Task GetPackageVersions_Unsafe(WinGet ManagerInstance, Package package) + public async Task GetPackageVersions_Unsafe(WinGet ManagerInstance, IPackage package) { Process p = new() { @@ -678,7 +679,7 @@ public async Task GetPackageVersions_Unsafe(WinGet ManagerInstance, Pa return versions.ToArray(); } - public async Task GetSources_UnSafe(WinGet ManagerInstance) + public async Task GetSources_UnSafe(WinGet ManagerInstance) { List sources = new(); diff --git a/src/UniGetUI.PackageEngine.Managers.WinGet/WinGetPackageDetailsProvider.cs b/src/UniGetUI.PackageEngine.Managers.WinGet/WinGetPackageDetailsProvider.cs index 2a7d6b6d2..58cc0587c 100644 --- a/src/UniGetUI.PackageEngine.Managers.WinGet/WinGetPackageDetailsProvider.cs +++ b/src/UniGetUI.PackageEngine.Managers.WinGet/WinGetPackageDetailsProvider.cs @@ -5,6 +5,7 @@ using UniGetUI.Core.IconEngine; using UniGetUI.Core.Logging; using UniGetUI.PackageEngine.Classes.Manager.BaseProviders; +using UniGetUI.PackageEngine.Interfaces; using UniGetUI.PackageEngine.PackageClasses; using UniGetUIManagers = UniGetUI.PackageEngine.ManagerClasses.Manager; @@ -21,17 +22,17 @@ struct MicrosoftStoreProductType public WinGetPackageDetailsProvider(WinGet manager) : base(manager) { } - protected override async Task GetPackageVersions_Unsafe(Package package) + protected override async Task GetPackageVersions_Unsafe(IPackage package) { return await WinGetHelper.Instance.GetPackageVersions_Unsafe((WinGet)Manager, package); } - protected override async Task GetPackageDetails_Unsafe(PackageDetails details) + protected override async Task GetPackageDetails_Unsafe(IPackageDetails details) { await WinGetHelper.Instance.GetPackageDetails_UnSafe((WinGet)Manager, details); } - protected override async Task GetPackageIcon_Unsafe(Package package) + protected override async Task GetPackageIcon_Unsafe(IPackage package) { if(package.Source.Name == "msstore") @@ -42,7 +43,7 @@ protected override async Task GetPackageDetails_Unsafe(PackageDetails details) return await GetWinGetPackageIcon(package); } - protected override async Task GetPackageScreenshots_Unsafe(Package package) + protected override async Task GetPackageScreenshots_Unsafe(IPackage package) { if (package.Source.Name != "msstore") return []; @@ -81,7 +82,7 @@ protected override async Task GetPackageScreenshots_Unsafe(Package packag } - private async Task GetMicrosoftStorePackageManifest(Package package) + private async Task GetMicrosoftStorePackageManifest(IPackage package) { if(__msstore_package_manifests.ContainsKey(package.Id)) return __msstore_package_manifests[package.Id]; @@ -117,7 +118,7 @@ protected override async Task GetPackageScreenshots_Unsafe(Package packag return result; } - private async Task GetMicrosoftStorePackageIcon(Package package) + private async Task GetMicrosoftStorePackageIcon(IPackage package) { string? ResponseContent = await GetMicrosoftStorePackageManifest(package); if (ResponseContent == null) @@ -166,7 +167,7 @@ protected override async Task GetPackageScreenshots_Unsafe(Package packag } - private async Task GetWinGetPackageIcon(Package package) + private async Task GetWinGetPackageIcon(IPackage package) { // TODO: Need to work on retrieving WinGet icons if (WinGetHelper.Instance is not NativeWinGetHelper) diff --git a/src/UniGetUI.PackageEngine.Managers.WinGet/WinGetSourceProvider.cs b/src/UniGetUI.PackageEngine.Managers.WinGet/WinGetSourceProvider.cs index a5672fc07..8005596fc 100644 --- a/src/UniGetUI.PackageEngine.Managers.WinGet/WinGetSourceProvider.cs +++ b/src/UniGetUI.PackageEngine.Managers.WinGet/WinGetSourceProvider.cs @@ -1,6 +1,7 @@ -using UniGetUI.PackageEngine.Classes.Manager.ManagerHelpers; +using UniGetUI.PackageEngine.Classes.Manager; using UniGetUI.PackageEngine.Classes.Manager.Providers; using UniGetUI.PackageEngine.Enums; +using UniGetUI.PackageEngine.Interfaces; using UniGetUI.PackageEngine.ManagerClasses.Manager; namespace UniGetUI.PackageEngine.Managers.WingetManager @@ -9,7 +10,7 @@ internal class WinGetSourceProvider : BaseSourceProvider { public WinGetSourceProvider(WinGet manager) : base(manager) { } - public override string[] GetAddSourceParameters(ManagerSource source) + public override string[] GetAddSourceParameters(IManagerSource source) { List args = new() { "source", "add", "--name", source.Name, "--arg", source.Url.ToString(), "--accept-source-agreements", "--disable-interactivity" }; if (source.Name != "winget") @@ -17,22 +18,22 @@ public override string[] GetAddSourceParameters(ManagerSource source) return args.ToArray(); } - public override string[] GetRemoveSourceParameters(ManagerSource source) + public override string[] GetRemoveSourceParameters(IManagerSource source) { return new string[] { "source", "remove", "--name", source.Name, "--disable-interactivity" }; } - public override OperationVeredict GetAddSourceOperationVeredict(ManagerSource source, int ReturnCode, string[] Output) + public override OperationVeredict GetAddSourceOperationVeredict(IManagerSource source, int ReturnCode, string[] Output) { return ReturnCode == 0 ? OperationVeredict.Succeeded : OperationVeredict.Failed; } - public override OperationVeredict GetRemoveSourceOperationVeredict(ManagerSource source, int ReturnCode, string[] Output) + public override OperationVeredict GetRemoveSourceOperationVeredict(IManagerSource source, int ReturnCode, string[] Output) { return ReturnCode == 0 ? OperationVeredict.Succeeded : OperationVeredict.Failed; } - protected override async Task GetSources_UnSafe() + protected override async Task GetSources_UnSafe() { if (Manager is WinGet manager) return await WinGetHelper.Instance.GetSources_UnSafe(manager); diff --git a/src/UniGetUI.PackageEngine.PackageEngine/PEInterface.cs b/src/UniGetUI.PackageEngine.PackageEngine/PEInterface.cs index 362ad9359..ae1b626ad 100644 --- a/src/UniGetUI.PackageEngine.PackageEngine/PEInterface.cs +++ b/src/UniGetUI.PackageEngine.PackageEngine/PEInterface.cs @@ -28,6 +28,7 @@ public static class PEInterface public static readonly DiscoverablePackagesLoader DiscoveredPackagesLoader = new(Managers); public static readonly UpgradablePackagesLoader UpgradablePackagesLoader = new(Managers); public static readonly InstalledPackagesLoader InstalledPackagesLoader = new(Managers); + public static readonly PackageBundlesLoader PackageBundlesLoader = new(Managers); public static async Task Initialize() { diff --git a/src/UniGetUI.PackageEngine.PackageEngine/UniGetUI.PackageEngine.PEInterface.csproj b/src/UniGetUI.PackageEngine.PackageEngine/UniGetUI.PackageEngine.PEInterface.csproj index 8ff3aff91..d2e7283d6 100644 --- a/src/UniGetUI.PackageEngine.PackageEngine/UniGetUI.PackageEngine.PEInterface.csproj +++ b/src/UniGetUI.PackageEngine.PackageEngine/UniGetUI.PackageEngine.PEInterface.csproj @@ -29,7 +29,7 @@ - + diff --git a/src/UniGetUI.PackageEngine.PackageLoader/AbstractPackageLoader.cs b/src/UniGetUI.PackageEngine.PackageLoader/AbstractPackageLoader.cs index e30409da9..426a4e08d 100644 --- a/src/UniGetUI.PackageEngine.PackageLoader/AbstractPackageLoader.cs +++ b/src/UniGetUI.PackageEngine.PackageLoader/AbstractPackageLoader.cs @@ -1,5 +1,6 @@ using System.Collections.ObjectModel; using UniGetUI.Core.Logging; +using UniGetUI.PackageEngine.Interfaces; using UniGetUI.PackageEngine.ManagerClasses.Manager; using UniGetUI.PackageEngine.PackageClasses; @@ -20,8 +21,8 @@ public abstract class AbstractPackageLoader /// /// The collection of currently available packages /// - public ObservableCollection Packages { get; private set; } - private readonly Dictionary PackageReference; + public ObservableCollection Packages { get; private set; } + private readonly Dictionary PackageReference; /// /// Fires when a block of packages (one package or more) is added or removed to the loader @@ -46,8 +47,8 @@ public abstract class AbstractPackageLoader public AbstractPackageLoader(IEnumerable managers, string identifier, bool AllowMultiplePackageVersions = false) { Managers = managers; - Packages = new ObservableCollection(); - PackageReference = new Dictionary(); + Packages = new ObservableCollection(); + PackageReference = new Dictionary(); IsLoaded = false; IsLoading = false; LOADER_IDENTIFIER = identifier; @@ -61,6 +62,16 @@ public void StopLoading() LoadOperationIdentifier = -1; IsLoaded = false; IsLoading = false; + RaiseFinishedLoadingEvent(); + } + + protected void RaisePackagesChangedEvent() + { + PackagesChanged?.Invoke(this, EventArgs.Empty); + } + + protected void RaiseFinishedLoadingEvent() + { FinishedLoading?.Invoke(this, EventArgs.Empty); } @@ -76,20 +87,20 @@ public virtual async Task ReloadPackages() IsLoading = true; StartedLoading?.Invoke(this, new EventArgs()); - List> tasks = new(); + List> tasks = new(); foreach (PackageManager manager in Managers) { if (manager.IsEnabled() && manager.Status.Found) { - Task task = LoadPackagesFromManager(manager); + Task task = LoadPackagesFromManager(manager); tasks.Add(task); } } while (tasks.Count > 0) { - foreach (Task task in tasks.ToArray()) + foreach (Task task in tasks.ToArray()) { if (!task.IsCompleted) await Task.Delay(100); @@ -99,16 +110,15 @@ public virtual async Task ReloadPackages() if (LoadOperationIdentifier == current_identifier && task.IsCompletedSuccessfully) { int InitialCount = Packages.Count; - foreach (Package package in task.Result) + foreach (IPackage package in task.Result) { if (Contains(package) || !await IsPackageValid(package)) continue; AddPackage(package); await WhenAddingPackage(package); - // TODO: AddPackageToSourcesList(package); } - PackagesChanged?.Invoke(this, EventArgs.Empty); + RaisePackagesChangedEvent(); } tasks.Remove(task); } @@ -117,7 +127,7 @@ public virtual async Task ReloadPackages() if (LoadOperationIdentifier == current_identifier) { - FinishedLoading?.Invoke(this, new EventArgs()); + RaiseFinishedLoadingEvent(); IsLoaded = true; } IsLoading = false; @@ -133,7 +143,7 @@ public void ClearPackages() PackageReference.Clear(); IsLoaded = false; IsLoading = false; - PackagesChanged?.Invoke(this, new EventArgs()); + RaisePackagesChangedEvent(); } /// @@ -141,28 +151,28 @@ public void ClearPackages() /// /// The manager from which to load packages /// A task that will load the packages - protected abstract Task LoadPackagesFromManager(PackageManager manager); + protected abstract Task LoadPackagesFromManager(IPackageManager manager); /// /// Checks whether the package is valid or must be skipped /// /// The package to check /// True if the package can be added, false otherwhise - protected abstract Task IsPackageValid(Package package); + protected abstract Task IsPackageValid(IPackage package); /// /// A method to post-process packages after they have been added. /// /// The package to process /// - protected abstract Task WhenAddingPackage(Package package); + protected abstract Task WhenAddingPackage(IPackage package); /// /// Checks wether a package is contained on the current Loader /// /// The package to check against /// - public bool Contains(Package package) + public bool Contains(IPackage package) { return PackageReference.ContainsKey(HashPackage(package)); } @@ -172,12 +182,12 @@ public bool Contains(Package package) /// /// The pakage to hash /// A long int containing the hash - protected long HashPackage(Package package) + protected long HashPackage(IPackage package) { return ALLOW_MULTIPLE_PACKAGE_VERSIONS ? package.GetVersionedHash() : package.GetHash(); } - protected void AddPackage(Package package) + protected void AddPackage(IPackage package) { if(Contains(package)) { @@ -193,25 +203,25 @@ protected void AddPackage(Package package) /// Adds a foreign package to the current loader. Perhaps a package has been recently installed and it needs to be added to the installed packages loader /// /// The package to add - public void AddForeign(Package? package) + public void AddForeign(IPackage? package) { if(package == null) return; if(Contains(package)) return; AddPackage(package); - PackagesChanged?.Invoke(this, new EventArgs()); + RaisePackagesChangedEvent(); } /// /// Removes the given package from the list. /// /// - public void Remove(Package? package) + public void Remove(IPackage? package) { if (package == null) return; if (!Contains(package)) return; Packages.Remove(package); PackageReference.Remove(HashPackage(package)); - PackagesChanged?.Invoke(this, new EventArgs()); + RaisePackagesChangedEvent(); } /// @@ -220,7 +230,7 @@ public void Remove(Package? package) /// /// /// A Package? object - public Package? GetEquivalentPackage(Package? package) + public IPackage? GetEquivalentPackage(IPackage? package) { if(package == null) return null; if(!Contains(package)) return null; @@ -233,12 +243,12 @@ public void Remove(Package? package) /// /// The package for which to find the equivalent packages /// A IEnumerable object - public IEnumerable GetEquivalentPackages(Package? package) + public IEnumerable GetEquivalentPackages(IPackage? package) { if (package == null) return []; - List result = new(); + List result = new(); long hash_to_match = package.GetHash(); - foreach (Package local_package in Packages) + foreach (IPackage local_package in Packages) { if (local_package.GetHash() == hash_to_match) { @@ -248,9 +258,9 @@ public IEnumerable GetEquivalentPackages(Package? package) return result; } - public Package? GetPackageForId(string id, string? sourceName = null) + public IPackage? GetPackageForId(string id, string? sourceName = null) { - foreach (Package package in Packages) + foreach (IPackage package in Packages) if (package.Id == id && (sourceName == null || package.Source.Name == sourceName)) return package; diff --git a/src/UniGetUI.PackageEngine.PackageLoader/DiscoverablePackagesLoader.cs b/src/UniGetUI.PackageEngine.PackageLoader/DiscoverablePackagesLoader.cs index ffcb390f2..267ae946a 100644 --- a/src/UniGetUI.PackageEngine.PackageLoader/DiscoverablePackagesLoader.cs +++ b/src/UniGetUI.PackageEngine.PackageLoader/DiscoverablePackagesLoader.cs @@ -1,5 +1,6 @@ using UniGetUI.Core.Tools; using UniGetUI.Interface.Enums; +using UniGetUI.PackageEngine.Interfaces; using UniGetUI.PackageEngine.ManagerClasses.Manager; using UniGetUI.PackageEngine.PackageClasses; @@ -26,24 +27,24 @@ public override async Task ReloadPackages() } #pragma warning disable - protected override async Task IsPackageValid(Package package) + protected override async Task IsPackageValid(IPackage package) { return true; } #pragma warning restore - protected override Task LoadPackagesFromManager(PackageManager manager) + protected override Task LoadPackagesFromManager(IPackageManager manager) { string text = QUERY_TEXT; text = CoreTools.EnsureSafeQueryString(text); if (text == string.Empty) - return new Task(() => { return []; }); + return new Task(() => { return []; }); else return manager.FindPackages(text); } #pragma warning disable - protected override async Task WhenAddingPackage(Package package) + protected override async Task WhenAddingPackage(IPackage package) { if (package.GetUpgradablePackage() != null) package.SetTag(PackageTag.IsUpgradable); diff --git a/src/UniGetUI.PackageEngine.PackageLoader/InstalledPackagesLoader.cs b/src/UniGetUI.PackageEngine.PackageLoader/InstalledPackagesLoader.cs index af87a8a3e..00e694be8 100644 --- a/src/UniGetUI.PackageEngine.PackageLoader/InstalledPackagesLoader.cs +++ b/src/UniGetUI.PackageEngine.PackageLoader/InstalledPackagesLoader.cs @@ -1,4 +1,5 @@ using UniGetUI.Interface.Enums; +using UniGetUI.PackageEngine.Interfaces; using UniGetUI.PackageEngine.ManagerClasses.Manager; using UniGetUI.PackageEngine.PackageClasses; @@ -12,18 +13,18 @@ public InstalledPackagesLoader(IEnumerable managers) } #pragma warning disable - protected override async Task IsPackageValid(Package package) + protected override async Task IsPackageValid(IPackage package) { return true; } #pragma warning restore - protected override Task LoadPackagesFromManager(PackageManager manager) + protected override Task LoadPackagesFromManager(IPackageManager manager) { return manager.GetInstalledPackages(); } - protected override async Task WhenAddingPackage(Package package) + protected override async Task WhenAddingPackage(IPackage package) { if (await package.HasUpdatesIgnoredAsync(Version: "*")) package.Tag = PackageTag.Pinned; diff --git a/src/UniGetUI.PackageEngine.PackageLoader/PackageBundlesLoader.cs b/src/UniGetUI.PackageEngine.PackageLoader/PackageBundlesLoader.cs new file mode 100644 index 000000000..0a8fac8b8 --- /dev/null +++ b/src/UniGetUI.PackageEngine.PackageLoader/PackageBundlesLoader.cs @@ -0,0 +1,66 @@ +using UniGetUI.Interface.Enums; +using UniGetUI.PackageEngine.Classes.Serializable; +using UniGetUI.PackageEngine.Interfaces; +using UniGetUI.PackageEngine.ManagerClasses.Manager; +using UniGetUI.PackageEngine.PackageClasses; + +namespace UniGetUI.PackageEngine.PackageLoader +{ + public class PackageBundlesLoader : AbstractPackageLoader + { + public PackageBundlesLoader(IEnumerable managers) + : base(managers, "PACKAGE_BUNDLES", AllowMultiplePackageVersions: true) + { + } + +#pragma warning disable + protected override async Task IsPackageValid(IPackage package) + { + return true; + } +#pragma warning restore + + protected override Task LoadPackagesFromManager(IPackageManager manager) + { + return Task.Run(() => new IPackage[0]); + } + +#pragma warning disable CS1998 + protected override async Task WhenAddingPackage(IPackage package) + { + if(package.GetInstalledPackage() != null) + package.SetTag(PackageTag.AlreadyInstalled); + } +#pragma warning restore CS1998 + + public void AddPackages(IEnumerable packages) + { + foreach (var package in packages) + { + if(!Contains(package)) AddPackage(package); + } + RaisePackagesChangedEvent(); + } + + /*public void AddPackages(IEnumerable packages_data) + { + foreach (var package_data in packages_data) + { + IPackage? package = Package.FromSerializable(package_data); + if (!Contains(package)) AddPackage(package); + } + RaisePackagesChangedEvent(); + } + + public void AddPackages(IEnumerable packages_data) + { + foreach (var package_data in packages_data) + { + InvalidImportedPackage package = Package.FromSerializable(package_data); + if (!Contains(package)) AddPackage(package); + } + RaisePackagesChangedEvent(); + } + */ + } +} diff --git a/src/UniGetUI.PackageEngine.PackageLoader/UniGetUI.PackageEngine.PackageLoaders.csproj b/src/UniGetUI.PackageEngine.PackageLoader/UniGetUI.PackageEngine.PackageLoaders.csproj index 568f69de4..8a816f970 100644 --- a/src/UniGetUI.PackageEngine.PackageLoader/UniGetUI.PackageEngine.PackageLoaders.csproj +++ b/src/UniGetUI.PackageEngine.PackageLoader/UniGetUI.PackageEngine.PackageLoaders.csproj @@ -26,7 +26,7 @@ - + diff --git a/src/UniGetUI.PackageEngine.PackageLoader/UpgradablePackagesLoader.cs b/src/UniGetUI.PackageEngine.PackageLoader/UpgradablePackagesLoader.cs index da69cc6bb..7149d15a9 100644 --- a/src/UniGetUI.PackageEngine.PackageLoader/UpgradablePackagesLoader.cs +++ b/src/UniGetUI.PackageEngine.PackageLoader/UpgradablePackagesLoader.cs @@ -1,6 +1,7 @@ using UniGetUI.Core.Logging; using UniGetUI.Core.SettingsEngine; using UniGetUI.Interface.Enums; +using UniGetUI.PackageEngine.Interfaces; using UniGetUI.PackageEngine.ManagerClasses.Manager; using UniGetUI.PackageEngine.PackageClasses; @@ -17,7 +18,7 @@ public UpgradablePackagesLoader(IEnumerable managers) FinishedLoading += (s, e) => StartAutoCheckTimeout(); } - protected override async Task IsPackageValid(Package package) + protected override async Task IsPackageValid(IPackage package) { if (await package.HasUpdatesIgnoredAsync(package.NewVersion)) return false; @@ -28,12 +29,12 @@ protected override async Task IsPackageValid(Package package) return true; } - protected override Task LoadPackagesFromManager(PackageManager manager) + protected override Task LoadPackagesFromManager(IPackageManager manager) { return manager.GetAvailableUpdates(); } #pragma warning disable - protected override async Task WhenAddingPackage(Package package) + protected override async Task WhenAddingPackage(IPackage package) { package.GetAvailablePackage()?.SetTag(PackageTag.IsUpgradable); package.GetInstalledPackage()?.SetTag(PackageTag.IsUpgradable); diff --git a/src/UniGetUI.PackageEngine.PackageManagerClasses/Manager/BaseProviders/BasePackageDetailsProvider.cs b/src/UniGetUI.PackageEngine.PackageManagerClasses/Manager/BaseProviders/BasePackageDetailsProvider.cs index 98c0f9a91..bfde7d547 100644 --- a/src/UniGetUI.PackageEngine.PackageManagerClasses/Manager/BaseProviders/BasePackageDetailsProvider.cs +++ b/src/UniGetUI.PackageEngine.PackageManagerClasses/Manager/BaseProviders/BasePackageDetailsProvider.cs @@ -1,12 +1,13 @@ using UniGetUI.Core.IconEngine; using UniGetUI.Core.Logging; -using UniGetUI.PackageEngine.Classes.Manager.Interfaces; +using UniGetUI.PackageEngine.Interfaces; +using UniGetUI.PackageEngine.Interfaces.ManagerProviders; using UniGetUI.PackageEngine.ManagerClasses.Manager; using UniGetUI.PackageEngine.PackageClasses; namespace UniGetUI.PackageEngine.Classes.Manager.BaseProviders { - public abstract class BasePackageDetailsProvider : IPackageDetailsProvider where T : PackageManager + public abstract class BasePackageDetailsProvider : IPackageDetailsProvider where T : IPackageManager { protected T Manager; @@ -15,12 +16,12 @@ public BasePackageDetailsProvider(T manager) Manager = manager; } - public async Task GetPackageDetails(PackageDetails details) + public async Task GetPackageDetails(IPackageDetails details) { await GetPackageDetails_Unsafe(details); } - public async Task GetPackageVersions(Package package) + public async Task GetPackageVersions(IPackage package) { if (Manager.Capabilities.SupportsCustomVersions) { @@ -35,7 +36,7 @@ public async Task GetPackageVersions(Package package) } } - public async Task GetPackageIconUrl(Package package) + public async Task GetPackageIconUrl(IPackage package) { CacheableIcon? Icon = null; if (Manager.Capabilities.SupportsCustomPackageIcons) @@ -64,7 +65,7 @@ public async Task GetPackageVersions(Package package) return Icon; } - public async Task GetPackageScreenshotsUrl(Package package) + public async Task GetPackageScreenshotsUrl(IPackage package) { Uri[] URIs = []; @@ -83,9 +84,9 @@ public async Task GetPackageScreenshotsUrl(Package package) return URIs; } - protected abstract Task GetPackageDetails_Unsafe(PackageDetails details); - protected abstract Task GetPackageVersions_Unsafe(Package package); - protected abstract Task GetPackageIcon_Unsafe(Package package); - protected abstract Task GetPackageScreenshots_Unsafe(Package package); + protected abstract Task GetPackageDetails_Unsafe(IPackageDetails details); + protected abstract Task GetPackageVersions_Unsafe(IPackage package); + protected abstract Task GetPackageIcon_Unsafe(IPackage package); + protected abstract Task GetPackageScreenshots_Unsafe(IPackage package); } } diff --git a/src/UniGetUI.PackageEngine.PackageManagerClasses/Manager/BaseProviders/BaseSourceProvider.cs b/src/UniGetUI.PackageEngine.PackageManagerClasses/Manager/BaseProviders/BaseSourceProvider.cs index fb74411f2..d396e75d3 100644 --- a/src/UniGetUI.PackageEngine.PackageManagerClasses/Manager/BaseProviders/BaseSourceProvider.cs +++ b/src/UniGetUI.PackageEngine.PackageManagerClasses/Manager/BaseProviders/BaseSourceProvider.cs @@ -1,37 +1,37 @@ -using UniGetUI.PackageEngine.Classes.Manager.Interfaces; -using UniGetUI.PackageEngine.Classes.Manager.ManagerHelpers; -using UniGetUI.PackageEngine.Enums; +using UniGetUI.PackageEngine.Enums; +using UniGetUI.PackageEngine.Interfaces; +using UniGetUI.PackageEngine.Interfaces.ManagerProviders; using UniGetUI.PackageEngine.ManagerClasses.Manager; namespace UniGetUI.PackageEngine.Classes.Manager.Providers { public abstract class BaseSourceProvider : ISourceProvider where T : PackageManager { - public readonly ManagerSourceFactory SourceFactory; + public ISourceFactory SourceFactory { get; } protected T Manager; public BaseSourceProvider(T manager) { Manager = manager; - SourceFactory = new(manager); + SourceFactory = new SourceFactory(manager); } - public abstract string[] GetAddSourceParameters(ManagerSource source); - public abstract string[] GetRemoveSourceParameters(ManagerSource source); - public abstract OperationVeredict GetAddSourceOperationVeredict(ManagerSource source, int ReturnCode, string[] Output); - public abstract OperationVeredict GetRemoveSourceOperationVeredict(ManagerSource source, int ReturnCode, string[] Output); + public abstract string[] GetAddSourceParameters(IManagerSource source); + public abstract string[] GetRemoveSourceParameters(IManagerSource source); + public abstract OperationVeredict GetAddSourceOperationVeredict(IManagerSource source, int ReturnCode, string[] Output); + public abstract OperationVeredict GetRemoveSourceOperationVeredict(IManagerSource source, int ReturnCode, string[] Output); /// /// Loads the sources for the manager. This method SHOULD NOT handle exceptions /// /// - protected abstract Task GetSources_UnSafe(); - public virtual async Task GetSources() + protected abstract Task GetSources_UnSafe(); + public virtual async Task GetSources() { - ManagerSource[] sources = await GetSources_UnSafe(); + IManagerSource[] sources = await GetSources_UnSafe(); SourceFactory.Reset(); - foreach (ManagerSource source in sources) + foreach (IManagerSource source in sources) SourceFactory.AddSource(source); return sources; diff --git a/src/UniGetUI.PackageEngine.PackageManagerClasses/Manager/Classes/ManagerSource.cs b/src/UniGetUI.PackageEngine.PackageManagerClasses/Manager/ManagerSource.cs similarity index 60% rename from src/UniGetUI.PackageEngine.PackageManagerClasses/Manager/Classes/ManagerSource.cs rename to src/UniGetUI.PackageEngine.PackageManagerClasses/Manager/ManagerSource.cs index 8ea0a9a31..1e24f9e46 100644 --- a/src/UniGetUI.PackageEngine.PackageManagerClasses/Manager/Classes/ManagerSource.cs +++ b/src/UniGetUI.PackageEngine.PackageManagerClasses/Manager/ManagerSource.cs @@ -1,27 +1,20 @@ using UniGetUI.PackageEngine.ManagerClasses.Manager; +using UniGetUI.PackageEngine.Interfaces; -namespace UniGetUI.PackageEngine.Classes.Manager.ManagerHelpers +namespace UniGetUI.PackageEngine.Classes.Manager { - public class ManagerSource + public class ManagerSource : IManagerSource { public virtual string IconId { get { return Manager.Properties.IconId; } } - public readonly bool IsVirtualManager = false; - public struct Capabilities - { - public bool KnowsUpdateDate { get; set; } = false; - public bool KnowsPackageCount { get; set; } = false; - public bool MustBeInstalledAsAdmin { get; set; } = false; - public Capabilities() - { } - } + public bool IsVirtualManager { get; } - public PackageManager Manager { get; } + public IPackageManager Manager { get; } public string Name { get; } - public Uri Url { get; private set; } + public Uri Url { get; set; } public int? PackageCount { get; } public string UpdateDate { get; } - public ManagerSource(PackageManager manager, string name, Uri url, int? packageCount = 0, string updateDate = "", bool isVirtualManager = false) + public ManagerSource(IPackageManager manager, string name, Uri url, int? packageCount = 0, string updateDate = "", bool isVirtualManager = false) { IsVirtualManager = isVirtualManager; Manager = manager; diff --git a/src/UniGetUI.PackageEngine.PackageManagerClasses/Manager/PackageManager.cs b/src/UniGetUI.PackageEngine.PackageManagerClasses/Manager/PackageManager.cs index 19006006c..e192d0c0d 100644 --- a/src/UniGetUI.PackageEngine.PackageManagerClasses/Manager/PackageManager.cs +++ b/src/UniGetUI.PackageEngine.PackageManagerClasses/Manager/PackageManager.cs @@ -6,31 +6,36 @@ using UniGetUI.Core.Logging; using UniGetUI.Core.SettingsEngine; using UniGetUI.PackageEngine.Classes.Manager.BaseProviders; -using UniGetUI.PackageEngine.Classes.Manager.Interfaces; +using UniGetUI.PackageEngine.Interfaces.ManagerProviders; using UniGetUI.PackageEngine.Classes.Manager.ManagerHelpers; using UniGetUI.PackageEngine.Classes.Manager.Providers; using UniGetUI.PackageEngine.Classes.Packages; using UniGetUI.PackageEngine.Enums; +using UniGetUI.PackageEngine.Interfaces; using UniGetUI.PackageEngine.ManagerClasses.Classes; using UniGetUI.PackageEngine.PackageClasses; +using UniGetUI.PackageEngine.Classes.Manager; +using UniGetUI.Core.Tools; namespace UniGetUI.PackageEngine.ManagerClasses.Manager { - public abstract class PackageManager : SingletonBase, ISourceProvider, IPackageDetailsProvider + public abstract class PackageManager : SingletonBase, ISourceProvider, IPackageDetailsProvider, IPackageManager { public ManagerProperties Properties { get; set; } = new(IsDummy: true); public ManagerCapabilities Capabilities { get; set; } = new(IsDummy: true); public ManagerStatus Status { get; set; } = new() { Found = false }; public string Name { get; set; } = "Unset"; - public ManagerSource DefaultSource { get; set; } - public static string[] FALSE_PACKAGE_NAMES = new string[] { "" }; - public static string[] FALSE_PACKAGE_IDS = new string[] { "" }; - public static string[] FALSE_PACKAGE_VERSIONS = new string[] { "" }; + public IManagerSource DefaultSource { get; set; } + public static string[] FALSE_PACKAGE_NAMES = [""]; + public static string[] FALSE_PACKAGE_IDS = [""]; + public static string[] FALSE_PACKAGE_VERSIONS = [""]; public bool ManagerReady { get; set; } = false; - public ManagerLogger TaskLogger; + public ManagerLogger TaskLogger { get; } - public BaseSourceProvider? SourceProvider; - public BasePackageDetailsProvider? PackageDetailsProvider; + public ISourceProvider SourceProvider { get; set; } + public ISourceFactory SourceFactory { get => SourceProvider.SourceFactory; } + + public IPackageDetailsProvider? PackageDetailsProvider { get; set; } private readonly bool __base_constructor_called = false; public PackageManager() @@ -39,6 +44,8 @@ public PackageManager() Name = Properties.Name; __base_constructor_called = true; TaskLogger = new ManagerLogger(this); + SourceProvider = new NullSourceProvider(this); + PackageDetailsProvider = new NullPackageDetailsProvider(this); } @@ -67,7 +74,7 @@ public virtual async Task InitializeAsync() if (IsReady() && SourceProvider != null) { - Task SourcesTask = GetSources(); + Task SourcesTask = GetSources(); Task winner = await Task.WhenAny( SourcesTask, Task.Delay(10000)); @@ -144,12 +151,12 @@ public bool IsReady() /// /// /// - public async Task FindPackages(string query) + public async Task FindPackages(string query) { if (!IsReady()) { Logger.Warn($"Manager {Name} is disabled but yet FindPackages was called"); return []; }; try { - Package[] packages = await FindPackages_UnSafe(query).WaitAsync(TimeSpan.FromSeconds(60)); + IPackage[] packages = await FindPackages_UnSafe(query).WaitAsync(TimeSpan.FromSeconds(60)); for (int i = 0; i < packages.Length; i++) { packages[i] = PackageCacher.GetAvailablePackage(packages[i]); @@ -171,13 +178,13 @@ public async Task FindPackages(string query) /// /// /// - public async Task GetAvailableUpdates() + public async Task GetAvailableUpdates() { if (!IsReady()) { Logger.Warn($"Manager {Name} is disabled but yet GetAvailableUpdates was called"); return []; }; try { await RefreshPackageIndexes().WaitAsync(TimeSpan.FromSeconds(60)); - Package[] packages = await GetAvailableUpdates_UnSafe().WaitAsync(TimeSpan.FromSeconds(60)); + IPackage[] packages = await GetAvailableUpdates_UnSafe().WaitAsync(TimeSpan.FromSeconds(60)); for (int i = 0; i < packages.Length; i++) packages[i] = PackageCacher.GetUpgradablePackage(packages[i]); Logger.Info($"Found {packages.Length} available updates from {Name}"); @@ -196,12 +203,12 @@ public async Task GetAvailableUpdates() /// This method is fail-safe and will return an empty array if an error occurs. /// /// - public async Task GetInstalledPackages() + public async Task GetInstalledPackages() { if (!IsReady()) { Logger.Warn($"Manager {Name} is disabled but yet GetInstalledPackages was called"); return []; }; try { - Package[] packages = await GetInstalledPackages_UnSafe().WaitAsync(TimeSpan.FromSeconds(60)); + IPackage[] packages = await GetInstalledPackages_UnSafe().WaitAsync(TimeSpan.FromSeconds(60)); for (int i = 0; i < packages.Length; i++) packages[i] = PackageCacher.GetInstalledPackage(packages[i]); Logger.Info($"Found {packages.Length} installed packages from {Name}"); @@ -222,21 +229,21 @@ public async Task GetInstalledPackages() /// /// The query string to search for /// An array of Package objects - protected abstract Task FindPackages_UnSafe(string query); + protected abstract Task FindPackages_UnSafe(string query); /// /// Returns the available updates reported by the manager. /// Each manager MUST implement this method. /// /// An array of UpgradablePackage objects - protected abstract Task GetAvailableUpdates_UnSafe(); + protected abstract Task GetAvailableUpdates_UnSafe(); /// /// Returns an array of Package objects containing the installed packages reported by the manager. /// Each manager MUST implement this method. /// /// An array of Package objects - protected abstract Task GetInstalledPackages_UnSafe(); + protected abstract Task GetInstalledPackages_UnSafe(); /// @@ -246,7 +253,7 @@ public async Task GetInstalledPackages() /// The Package going to be installed /// The options in which it is going to be installed /// An array of strings containing the parameters without the manager executable file - public abstract string[] GetInstallParameters(Package package, InstallationOptions options); + public abstract string[] GetInstallParameters(IPackage package, IInstallationOptions options); /// @@ -256,7 +263,7 @@ public async Task GetInstalledPackages() /// The Package going to be updated /// The options in which it is going to be updated /// An array of strings containing the parameters without the manager executable file - public abstract string[] GetUpdateParameters(Package package, InstallationOptions options); + public abstract string[] GetUpdateParameters(IPackage package, IInstallationOptions options); /// /// Returns the command-line parameters to uninstall the given package. @@ -265,7 +272,7 @@ public async Task GetInstalledPackages() /// The Package going to be uninstalled /// The options in which it is going to be uninstalled /// An array of strings containing the parameters without the manager executable file - public abstract string[] GetUninstallParameters(Package package, InstallationOptions options); + public abstract string[] GetUninstallParameters(IPackage package, IInstallationOptions options); /// /// Decides and returns the verdict of the install operation. @@ -276,7 +283,7 @@ public async Task GetInstalledPackages() /// The exit code of the process /// the output of the process /// An OperationVeredict value representing the result of the installation - public abstract OperationVeredict GetInstallOperationVeredict(Package package, InstallationOptions options, int ReturnCode, string[] Output); + public abstract OperationVeredict GetInstallOperationVeredict(IPackage package, IInstallationOptions options, int ReturnCode, string[] Output); /// @@ -288,7 +295,7 @@ public async Task GetInstalledPackages() /// The exit code of the process /// the output of the process /// An OperationVeredict value representing the result of the update - public abstract OperationVeredict GetUpdateOperationVeredict(Package package, InstallationOptions options, int ReturnCode, string[] Output); + public abstract OperationVeredict GetUpdateOperationVeredict(IPackage package, IInstallationOptions options, int ReturnCode, string[] Output); /// /// Decides and returns the verdict of the uninstall operation. @@ -299,7 +306,7 @@ public async Task GetInstalledPackages() /// The exit code of the process /// the output of the process /// An OperationVeredict value representing the result of the uninstall - public abstract OperationVeredict GetUninstallOperationVeredict(Package package, InstallationOptions options, int ReturnCode, string[] Output); + public abstract OperationVeredict GetUninstallOperationVeredict(IPackage package, IInstallationOptions options, int ReturnCode, string[] Output); /// /// Refreshes the Package Manager sources/indexes @@ -328,43 +335,44 @@ private void AssertSourceCompatibility(string MethodName) throw new Exception($"Manager {Name} does support custom sources but yet the source helper is null"); } #pragma warning disable CS8602 - public ManagerSource GetSourceOrDefault(string SourceName) + public IManagerSource GetSourceOrDefault(string SourceName) { AssertSourceCompatibility("GetSourceFromName"); return SourceProvider.SourceFactory.GetSourceOrDefault(SourceName); } - public ManagerSource? GetSourceIfExists(string SourceName) + public IManagerSource? GetSourceIfExists(string SourceName) { AssertSourceCompatibility("GetSourceIfExists"); return SourceProvider.SourceFactory.GetSourceIfExists(SourceName); } - public string[] GetAddSourceParameters(ManagerSource source) + public string[] GetAddSourceParameters(IManagerSource source) { AssertSourceCompatibility("GetAddSourceParameters"); return SourceProvider.GetAddSourceParameters(source); } - public string[] GetRemoveSourceParameters(ManagerSource source) + public string[] GetRemoveSourceParameters(IManagerSource source) { AssertSourceCompatibility("GetRemoveSourceParameters"); return SourceProvider.GetRemoveSourceParameters(source); } - public OperationVeredict GetAddSourceOperationVeredict(ManagerSource source, int ReturnCode, string[] Output) + public OperationVeredict GetAddSourceOperationVeredict(IManagerSource source, int ReturnCode, string[] Output) { AssertSourceCompatibility("GetAddSourceOperationVeredict"); return SourceProvider.GetAddSourceOperationVeredict(source, ReturnCode, Output); } - public OperationVeredict GetRemoveSourceOperationVeredict(ManagerSource source, int ReturnCode, string[] Output) + public OperationVeredict GetRemoveSourceOperationVeredict(IManagerSource source, int ReturnCode, string[] Output) { AssertSourceCompatibility("GetRemoveSourceOperationVeredict"); return SourceProvider.GetRemoveSourceOperationVeredict(source, ReturnCode, Output); } - public virtual async Task GetSources() + + public virtual async Task GetSources() { if (!IsReady()) { Logger.Warn($"Manager {Name} is disabled but yet GetSources was called"); return []; }; try { AssertSourceCompatibility("GetSources"); - ManagerSource[] result = await SourceProvider.GetSources().WaitAsync(TimeSpan.FromSeconds(60)); + IManagerSource[] result = await SourceProvider.GetSources().WaitAsync(TimeSpan.FromSeconds(60)); Logger.Debug($"Loaded {result.Length} sources for manager {Name}"); return result; } @@ -392,14 +400,14 @@ private void AssertPackageDetailsCompatibility(string MethodName) throw new Exception($"Manager {Name} does not have a valid PackageDetailsProvider helper"); } #pragma warning disable CS8602 - /*public async Task GetPackageDetails(Package package) + /*public async Task GetPackageDetails(IPackage package) { var details = new PackageDetails(package); await GetPackageDetails(details); return details; }*/ - public async Task GetPackageDetails(PackageDetails details) + public async Task GetPackageDetails(IPackageDetails details) { if (!IsReady()) { Logger.Warn($"Manager {Name} is disabled but yet GetPackageDetails was called"); return; }; try @@ -415,7 +423,7 @@ public async Task GetPackageDetails(PackageDetails details) } } - public async Task GetPackageVersions(Package package) + public async Task GetPackageVersions(IPackage package) { if (!IsReady()) { Logger.Warn($"Manager {Name} is disabled but yet GetPackageVersions was called"); return []; }; try @@ -434,7 +442,7 @@ public async Task GetPackageVersions(Package package) } } - public async Task GetPackageIconUrl(Package package) + public async Task GetPackageIconUrl(IPackage package) { try { @@ -449,7 +457,7 @@ public async Task GetPackageVersions(Package package) } } - public async Task GetPackageScreenshotsUrl(Package package) + public async Task GetPackageScreenshotsUrl(IPackage package) { try { @@ -484,4 +492,64 @@ public void LogOperation(Process process, string output) } } + + internal class NullSourceProvider : BaseSourceProvider + { + public NullSourceProvider(PackageManager manager) : base(manager) + { + } + + public override string[] GetAddSourceParameters(IManagerSource source) + { + throw new Exception("Package manager does not support adding sources"); + } + public override string[] GetRemoveSourceParameters(IManagerSource source) + { + throw new Exception("Package manager does not support removing sources"); + } + + public override OperationVeredict GetAddSourceOperationVeredict(IManagerSource source, int ReturnCode, string[] Output) + { + return OperationVeredict.Failed; + } + + public override OperationVeredict GetRemoveSourceOperationVeredict(IManagerSource source, int ReturnCode, string[] Output) + { + return OperationVeredict.Failed; + } + + protected override async Task GetSources_UnSafe() + { + return await Task.Run(() => new IManagerSource[] { Manager.DefaultSource }); + } + } + + internal class NullPackageDetailsProvider : BasePackageDetailsProvider + { +#pragma warning disable CS1998 + public NullPackageDetailsProvider(PackageManager manager) : base(manager) + { + } + + protected override async Task GetPackageDetails_Unsafe(IPackageDetails details) + { + return; + } + + protected override async Task GetPackageIcon_Unsafe(IPackage package) + { + return null; + } + + protected override async Task GetPackageScreenshots_Unsafe(IPackage package) + { + return []; + } + + protected override async Task GetPackageVersions_Unsafe(IPackage package) + { + return []; + } +#pragma warning restore CS1998 + } } diff --git a/src/UniGetUI.PackageEngine.PackageManagerClasses/Manager/Classes/ManagerSourceFactory.cs b/src/UniGetUI.PackageEngine.PackageManagerClasses/Manager/SourceFactory.cs similarity index 66% rename from src/UniGetUI.PackageEngine.PackageManagerClasses/Manager/Classes/ManagerSourceFactory.cs rename to src/UniGetUI.PackageEngine.PackageManagerClasses/Manager/SourceFactory.cs index 193b7df66..cfb2728f1 100644 --- a/src/UniGetUI.PackageEngine.PackageManagerClasses/Manager/Classes/ManagerSourceFactory.cs +++ b/src/UniGetUI.PackageEngine.PackageManagerClasses/Manager/SourceFactory.cs @@ -1,14 +1,15 @@ -using UniGetUI.PackageEngine.ManagerClasses.Manager; +using UniGetUI.PackageEngine.Interfaces; +using UniGetUI.PackageEngine.ManagerClasses.Manager; -namespace UniGetUI.PackageEngine.Classes.Manager.ManagerHelpers +namespace UniGetUI.PackageEngine.Classes.Manager { - public class ManagerSourceFactory + public class SourceFactory: ISourceFactory { - private readonly PackageManager __manager; - private readonly Dictionary __reference; + private readonly IPackageManager __manager; + private readonly Dictionary __reference; private readonly Uri __default_uri = new("https://marticliment.com/unigetui/"); - public ManagerSourceFactory(PackageManager manager) + public SourceFactory(PackageManager manager) { __reference = new(); __manager = manager; @@ -24,9 +25,9 @@ public void Reset() /// /// The name of the source /// A valid ManagerSource - public ManagerSource GetSourceOrDefault(string name) + public IManagerSource GetSourceOrDefault(string name) { - ManagerSource? source; + IManagerSource? source; if (__reference.TryGetValue(name, out source) && source != null) { return source; @@ -42,9 +43,9 @@ public ManagerSource GetSourceOrDefault(string name) /// /// /// - public ManagerSource? GetSourceIfExists(string name) + public IManagerSource? GetSourceIfExists(string name) { - ManagerSource? source; + IManagerSource? source; if (__reference.TryGetValue(name, out source)) { return source; @@ -52,17 +53,17 @@ public ManagerSource GetSourceOrDefault(string name) return null; } - public void AddSource(ManagerSource source) + public void AddSource(IManagerSource source) { if (!__reference.TryAdd(source.Name, source)) { - ManagerSource existing_source = __reference[source.Name]; + IManagerSource existing_source = __reference[source.Name]; if (existing_source.Url == __default_uri) existing_source.ReplaceUrl(source.Url); } } - public ManagerSource[] GetAvailableSources() + public IManagerSource[] GetAvailableSources() { return __reference.Values.ToArray(); } diff --git a/src/UniGetUI.PackageEngine.PackageManagerClasses/Packages/ImportedPackage.cs b/src/UniGetUI.PackageEngine.PackageManagerClasses/Packages/ImportedPackage.cs new file mode 100644 index 000000000..76ad99b81 --- /dev/null +++ b/src/UniGetUI.PackageEngine.PackageManagerClasses/Packages/ImportedPackage.cs @@ -0,0 +1,48 @@ +using System.ComponentModel; +using System.Runtime.CompilerServices; +using System.Text.Json.Nodes; +using UniGetUI.Core.Data; +using UniGetUI.Core.IconEngine; +using UniGetUI.Core.Logging; +using UniGetUI.Core.Tools; +using UniGetUI.Interface.Enums; +using UniGetUI.PackageEngine.Classes.Manager; +using UniGetUI.PackageEngine.Classes.Packages; +using UniGetUI.PackageEngine.Classes.Serializable; +using UniGetUI.PackageEngine.Enums; +using UniGetUI.PackageEngine.ManagerClasses.Manager; +using UniGetUI.PackageEngine.Serializable; + +namespace UniGetUI.PackageEngine.PackageClasses +{ + public class ImportedPackage : Package + { + /// + /// Constuct an invalid package with a given name, id, version, source and manager, and an optional scope. + /// + /// + /// + /// + /// + SerializableUpdatesOptions_v1 updates_options; + SerializableInstallationOptions_v1 installation_options; + + public ImportedPackage(SerializablePackage_v1 raw_data, PackageManager manager, ManagerSource source) + : base(raw_data.Name, raw_data.Id, raw_data.Version, source, manager) + { + installation_options = raw_data.InstallationOptions; + updates_options = raw_data.Updates; + } + + public async Task RegisterPackage() + { + var options = InstallationOptions.FromSerialized(installation_options, this); + await options.SaveToDiskAsync(); + + if (updates_options.UpdatesIgnored) + { + await AddToIgnoredUpdatesAsync(updates_options.IgnoredVersion); + } + } + } +} diff --git a/src/UniGetUI.PackageEngine.PackageManagerClasses/Packages/InstallationOptions.cs b/src/UniGetUI.PackageEngine.PackageManagerClasses/Packages/InstallationOptions.cs index 9f3cd89ca..f8fbae5ea 100644 --- a/src/UniGetUI.PackageEngine.PackageManagerClasses/Packages/InstallationOptions.cs +++ b/src/UniGetUI.PackageEngine.PackageManagerClasses/Packages/InstallationOptions.cs @@ -4,6 +4,7 @@ using UniGetUI.Core.Language; using UniGetUI.Core.Logging; using UniGetUI.PackageEngine.Enums; +using UniGetUI.PackageEngine.Interfaces; using UniGetUI.PackageEngine.Serializable; namespace UniGetUI.PackageEngine.PackageClasses @@ -12,7 +13,7 @@ namespace UniGetUI.PackageEngine.PackageClasses /// /// This class represents the options in which a package must be installed, updated or uninstalled. /// - public class InstallationOptions + public class InstallationOptions: IInstallationOptions { private static readonly Dictionary OptionsCache = new(); @@ -27,11 +28,11 @@ public class InstallationOptions public bool PreRelease { get; set; } = false; public string CustomInstallLocation { get; set; } = ""; - public Package Package { get; } + public IPackage Package { get; } private readonly string __save_filename; - private InstallationOptions(Package package) + private InstallationOptions(IPackage package) { Package = package; __save_filename = package.Manager.Name.Replace(" ", "").Replace(".", "") + "." + package.Id; @@ -42,7 +43,7 @@ private InstallationOptions(Package package) /// /// The package from which to load the InstallationOptions /// The package's InstallationOptions instance - public static InstallationOptions FromPackage(Package package, bool? elevated = null, bool? + public static InstallationOptions FromPackage(IPackage package, bool? elevated = null, bool? interactive = null, bool? no_integrity = null, bool? remove_data = null) { InstallationOptions instance; @@ -71,7 +72,7 @@ public static InstallationOptions FromPackage(Package package, bool? elevated = /// /// The package from which to load the InstallationOptions /// The package's InstallationOptions instance - public static async Task FromPackageAsync(Package package, bool? elevated = null, + public static async Task FromPackageAsync(IPackage package, bool? elevated = null, bool? interactive = null, bool? no_integrity = null, bool? remove_data = null) { return await Task.Run(() => FromPackage(package, elevated, interactive, no_integrity, remove_data)); @@ -83,7 +84,7 @@ public static async Task FromPackageAsync(Package package, /// /// /// - public static InstallationOptions FromSerialized(SerializableInstallationOptions_v1 options, Package package) + public static InstallationOptions FromSerialized(SerializableInstallationOptions_v1 options, IPackage package) { InstallationOptions instance = new(package); instance.FromSerializable(options); @@ -181,7 +182,7 @@ public void SaveToDisk() /// /// Loads the options from disk. /// - private void LoadFromDisk() + public void LoadFromDisk() { FileInfo optionsFile = GetPackageOptionsFile(); try diff --git a/src/UniGetUI.PackageEngine.PackageManagerClasses/Packages/InvalidImportedPackage.cs b/src/UniGetUI.PackageEngine.PackageManagerClasses/Packages/InvalidImportedPackage.cs new file mode 100644 index 000000000..cedf34c65 --- /dev/null +++ b/src/UniGetUI.PackageEngine.PackageManagerClasses/Packages/InvalidImportedPackage.cs @@ -0,0 +1,19 @@ +using System.ComponentModel; +using System.Runtime.CompilerServices; +using System.Text.Json.Nodes; +using UniGetUI.Core.Data; +using UniGetUI.Core.IconEngine; +using UniGetUI.Core.Logging; +using UniGetUI.Core.Tools; +using UniGetUI.Interface.Enums; +using UniGetUI.PackageEngine.Classes.Manager.ManagerHelpers; +using UniGetUI.PackageEngine.Classes.Packages; +using UniGetUI.PackageEngine.Enums; +using UniGetUI.PackageEngine.ManagerClasses.Manager; + +namespace UniGetUI.PackageEngine.PackageClasses +{ + public class InvalidImportedPackage // : IPackage + { + } +} diff --git a/src/UniGetUI.PackageEngine.PackageManagerClasses/Packages/ObservablePackageCollection.cs b/src/UniGetUI.PackageEngine.PackageManagerClasses/Packages/ObservablePackageCollection.cs index 491178fa1..fe9d3491e 100644 --- a/src/UniGetUI.PackageEngine.PackageManagerClasses/Packages/ObservablePackageCollection.cs +++ b/src/UniGetUI.PackageEngine.PackageManagerClasses/Packages/ObservablePackageCollection.cs @@ -2,6 +2,7 @@ using UniGetUI.Core.Classes; using UniGetUI.Core.Tools; using UniGetUI.Interface.Enums; +using UniGetUI.PackageEngine.Interfaces; namespace UniGetUI.PackageEngine.PackageClasses { @@ -87,9 +88,9 @@ public void SetSorter(Sorter field) /// Returns a list containing the packwges in this collection /// /// - public List GetPackages() + public List GetPackages() { - List packages = new(); + List packages = new(); foreach (PackageWrapper wrapper in this) packages.Add(wrapper.Package); return packages; @@ -99,9 +100,9 @@ public List GetPackages() /// Returns a list containing the checked packages on this collection /// /// - public List GetCheckedPackages() - { - List packages = new(); + public List GetCheckedPackages() + { + List packages = new(); foreach (PackageWrapper wrapper in this) { if (wrapper.Package.IsChecked) diff --git a/src/UniGetUI.PackageEngine.PackageManagerClasses/Packages/Package.cs b/src/UniGetUI.PackageEngine.PackageManagerClasses/Packages/Package.cs index eca1cf9ce..1bfa6e31b 100644 --- a/src/UniGetUI.PackageEngine.PackageManagerClasses/Packages/Package.cs +++ b/src/UniGetUI.PackageEngine.PackageManagerClasses/Packages/Package.cs @@ -1,19 +1,28 @@ -using System.ComponentModel; +using System; +using System.ComponentModel; +using System.ComponentModel.Design; using System.Runtime.CompilerServices; using System.Text.Json.Nodes; +using System.Xml.Linq; +using UniGetUI.Core.Classes; using UniGetUI.Core.Data; using UniGetUI.Core.IconEngine; using UniGetUI.Core.Logging; using UniGetUI.Core.Tools; using UniGetUI.Interface.Enums; -using UniGetUI.PackageEngine.Classes.Manager.ManagerHelpers; +using UniGetUI.PackageEngine.Classes.Manager; using UniGetUI.PackageEngine.Classes.Packages; +using UniGetUI.PackageEngine.Classes.Serializable; using UniGetUI.PackageEngine.Enums; +using UniGetUI.PackageEngine.Interfaces; using UniGetUI.PackageEngine.ManagerClasses.Manager; +using Windows.Devices.Bluetooth.Advertisement; +using Windows.Devices.PointOfService; +using static System.Formats.Asn1.AsnWriter; namespace UniGetUI.PackageEngine.PackageClasses { - public class Package : INotifyPropertyChanged + public class Package : IPackage { // Internal properties private bool __is_checked = false; @@ -24,7 +33,7 @@ public class Package : INotifyPropertyChanged private readonly long __versioned_hash; private PackageDetails? __details = null; - public PackageDetails Details + public IPackageDetails Details { get => __details ??= new PackageDetails(this); } @@ -48,13 +57,13 @@ public bool IsChecked public string Version { get; } public double VersionAsFloat { get; } public double NewVersionAsFloat { get; } - public ManagerSource Source { get; } - public PackageManager Manager { get; } + public IManagerSource Source { get; } + public IPackageManager Manager { get; } public string NewVersion { get; } public virtual bool IsUpgradable { get; } public PackageScope Scope { get; set; } - public readonly string SourceAsString; - public readonly string AutomationName; + public string SourceAsString { get; } + public string AutomationName { get; } /// /// Constuct a package with a given name, id, version, source and manager, and an optional scope. @@ -65,7 +74,7 @@ public bool IsChecked /// /// /// - public Package(string name, string id, string version, ManagerSource source, PackageManager manager, PackageScope scope = PackageScope.Local) + public Package(string name, string id, string version, IManagerSource source, IPackageManager manager, PackageScope scope = PackageScope.Local) { Name = name; Id = id; @@ -93,7 +102,7 @@ public Package(string name, string id, string version, ManagerSource source, Pac /// /// /// - public Package(string name, string id, string installed_version, string new_version, ManagerSource source, PackageManager manager, PackageScope scope = PackageScope.Local) + public Package(string name, string id, string installed_version, string new_version, IManagerSource source, IPackageManager manager, PackageScope scope = PackageScope.Local) : this(name, id, installed_version, source, manager, scope) { IsUpgradable = true; @@ -104,66 +113,26 @@ public Package(string name, string id, string installed_version, string new_vers IsChecked = true; } - /// - /// Returns an identifier that can be used to compare different packahe instances that refer to the same package. - /// What is taken into account: - /// - Manager and Source - /// - Package Identifier - /// For more specific comparsion use GetVersionedHash() - /// - /// public long GetHash() { return __hash; } - /// - /// Returns an identifier that can be used to compare different packahe instances that refer to the same package. - /// What is taken into account: - /// - Manager and Source - /// - Package Identifier - /// - Package version - /// - Package new version (if any) - /// - /// public long GetVersionedHash() { return __versioned_hash; } - /// - /// Check wether two packages are **REALLY** the same package. - /// What is taken into account: - /// - Manager and Source - /// - Package Identifier - /// - Package version - /// - Package new version (if any) - /// - /// - /// public override bool Equals(object? other) { return __versioned_hash == (other as Package)?.__versioned_hash; } - /// - /// Check wether two package instances represent the same package. - /// What is taken into account: - /// - Manager and Source - /// - Package Identifier - /// For more specific comparsion use package.Equals(object? other) - /// - /// A package - /// Wether the two instances refer to the same instance - public bool IsEquivalentTo(Package? other) + public bool IsEquivalentTo(IPackage? other) { - return __hash == other?.__hash; + return __hash == (other as Package)?.__hash; } - /// - /// Load the package's normalized icon id, - /// - /// a string with the package's normalized icon id public string GetIconId() { string iconId = Id.ToLower(); @@ -176,12 +145,7 @@ public string GetIconId() return iconId; } - /// - /// Get the package's icon url. If the package has no icon, a fallback image is returned. - /// After calling this method, the returned URL points to a location on the local machine - /// - /// An always-valid URI object, pointing to a file:// or to a ms-appx:// URL - public async Task GetIconUrl() + public virtual async Task GetIconUrl() { try { @@ -207,23 +171,12 @@ public async Task GetIconUrl() } } - /// - /// Retrieves a list og URIs representing the available screenshots for this package. - /// - /// - public async Task GetPackageScreenshots() + public virtual async Task GetPackageScreenshots() { return await Manager.GetPackageScreenshotsUrl(this); } - - /// - /// Adds the package to the ignored updates list. If no version is provided, all updates are ignored. - /// Calling this method will override older ignored updates. - /// - /// - /// - public async Task AddToIgnoredUpdatesAsync(string version = "*") + public virtual async Task AddToIgnoredUpdatesAsync(string version = "*") { try { @@ -246,11 +199,7 @@ public async Task AddToIgnoredUpdatesAsync(string version = "*") } } - /// - /// Removes the package from the ignored updates list, either if it is ignored for all updates or for a specific version only. - /// - /// - public async Task RemoveFromIgnoredUpdatesAsync() + public virtual async Task RemoveFromIgnoredUpdatesAsync() { try { @@ -276,15 +225,7 @@ public async Task RemoveFromIgnoredUpdatesAsync() } } - /// - /// Returns true if the package's updates are ignored. If the version parameter - /// is passed it will be checked if that version is ignored. Please note that if - /// all updates are ignored, calling this method with a specific version will - /// still return true, although the passed version is not explicitly ignored. - /// - /// - /// - public async Task HasUpdatesIgnoredAsync(string Version = "*") + public virtual async Task HasUpdatesIgnoredAsync(string Version = "*") { try { @@ -308,13 +249,7 @@ public async Task HasUpdatesIgnoredAsync(string Version = "*") } - /// - /// Returns (as a string) the version for which a package has been ignored. When no versions - /// are ignored, an empty string will be returned; and when all versions are ignored an asterisk - /// will be returned. - /// - /// - public async Task GetIgnoredUpdatesVersionAsync() + public virtual async Task GetIgnoredUpdatesVersionAsync() { try { @@ -337,57 +272,68 @@ public async Task GetIgnoredUpdatesVersionAsync() } } - /// - /// Internal method to raise the PropertyChanged event. - /// - /// protected void OnPropertyChanged([CallerMemberName] string? name = null) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name)); } - /// - /// Returns the corresponding installed Package object. Will return null if not applicable - /// - /// a Package object if found, null if not - public Package? GetInstalledPackage() + public IPackage? GetInstalledPackage() { return PackageCacher.GetInstalledPackageOrNull(this); } - /// - /// Returns the corresponding available Package object. Will return null if not applicable - /// - /// a Package object if found, null if not - public Package? GetAvailablePackage() + public IPackage? GetAvailablePackage() { return PackageCacher.GetAvailablePackageOrNull(this); } - /// - /// Returns the corresponding upgradable Package object. Will return null if not applicable - /// - /// a Package object if found, null if not - public Package? GetUpgradablePackage() + public IPackage? GetUpgradablePackage() { return PackageCacher.GetUpgradablePackageOrNull(this); } - /// - /// Sets the package tag. You may as well use the Tag property. - /// This function is used for compatibility with the ? operator - /// - /// - public void SetTag(PackageTag tag) + public virtual void SetTag(PackageTag tag) { Tag = tag; } - public bool NewerVersionIsInstalled() + public virtual bool NewerVersionIsInstalled() { if(!IsUpgradable) return false; return PackageCacher.NewerVersionIsInstalled(this); } + /* + public static Package FromSerializable(SerializablePackage_v1 raw_package) + { + PackageManager? manager = null; + ManagerSource? source = null; + + foreach (var possible_manager in ManagersList) + { + if (possible_manager.Name == raw_package.ManagerName) + { + manager = possible_manager; + break; + } + } + + if (manager?.Capabilities.SupportsCustomSources == true) + source = manager?.SourceProvider?.SourceFactory.GetSourceIfExists(raw_package.Source); + else + source = manager?.DefaultSource; + + if (manager is null || source is null) + { + return FromSerializable(raw_package.GetInvalidEquivalent()); + } + + return new ImportedPackage(raw_package, manager, source); + } + + public static InvalidImportedPackage FromSerializable(SerializableIncompatiblePackage_v1 raw_package) + { + return new InvalidImportedPackage(raw_package.Name, raw_package.Id, raw_package.Version, raw_package.Source); + }*/ } } diff --git a/src/UniGetUI.PackageEngine.PackageManagerClasses/Packages/PackageCacher.cs b/src/UniGetUI.PackageEngine.PackageManagerClasses/Packages/PackageCacher.cs index 3ac86299c..05eca9106 100644 --- a/src/UniGetUI.PackageEngine.PackageManagerClasses/Packages/PackageCacher.cs +++ b/src/UniGetUI.PackageEngine.PackageManagerClasses/Packages/PackageCacher.cs @@ -1,12 +1,13 @@ -using UniGetUI.PackageEngine.PackageClasses; +using UniGetUI.PackageEngine.Interfaces; +using UniGetUI.PackageEngine.PackageClasses; namespace UniGetUI.PackageEngine.Classes.Packages { internal static class PackageCacher { - private static readonly Dictionary __available_pkgs = new(); - private static readonly Dictionary __upgradable_pkgs = new(); - private static readonly Dictionary __installed_pkgs = new(); + private static readonly Dictionary __available_pkgs = new(); + private static readonly Dictionary __upgradable_pkgs = new(); + private static readonly Dictionary __installed_pkgs = new(); /// /// Will check if a given Package is already in the cache. If not, it will be added to it @@ -14,9 +15,9 @@ internal static class PackageCacher /// /// The package to check /// The already existing package if any, otherwhise p - public static Package GetAvailablePackage(Package p) + public static IPackage GetAvailablePackage(IPackage p) { - Package? new_package = GetAvailablePackageOrNull(p); + IPackage? new_package = GetAvailablePackageOrNull(p); if (new_package == null) AddPackageToCache(p, __available_pkgs); return new_package ?? p; } @@ -27,9 +28,9 @@ public static Package GetAvailablePackage(Package p) /// /// The package to check /// The already existing package if any, otherwhise p - public static Package GetUpgradablePackage(Package p) + public static IPackage GetUpgradablePackage(IPackage p) { - Package? new_package = GetUpgradablePackageOrNull(p); + IPackage? new_package = GetUpgradablePackageOrNull(p); if (new_package == null) AddPackageToCache(p, __upgradable_pkgs); return new_package ?? p; } @@ -40,9 +41,9 @@ public static Package GetUpgradablePackage(Package p) /// /// The package to check /// The already existing package if any, otherwhise p - public static Package GetInstalledPackage(Package p) + public static IPackage GetInstalledPackage(IPackage p) { - Package? new_package = GetInstalledPackageOrNull(p); + IPackage? new_package = GetInstalledPackageOrNull(p); if (new_package == null) AddPackageToCache(p, __installed_pkgs); return new_package ?? p; } @@ -53,9 +54,9 @@ public static Package GetInstalledPackage(Package p) /// /// The package to check /// The already existing package if any, otherwhise null - public static Package? GetAvailablePackageOrNull(Package other) + public static IPackage? GetAvailablePackageOrNull(IPackage other) { - if(__available_pkgs.TryGetValue(other.GetHash(), out Package? equivalent_package)) + if(__available_pkgs.TryGetValue(other.GetHash(), out IPackage? equivalent_package)) { return equivalent_package; } @@ -68,9 +69,9 @@ public static Package GetInstalledPackage(Package p) /// /// The package to check /// The already existing package if any, otherwhise null - public static Package? GetUpgradablePackageOrNull(Package other) + public static IPackage? GetUpgradablePackageOrNull(IPackage other) { - if (__upgradable_pkgs.TryGetValue(other.GetHash(), out Package? equivalent_package)) + if (__upgradable_pkgs.TryGetValue(other.GetHash(), out IPackage? equivalent_package)) { return equivalent_package; } @@ -83,9 +84,9 @@ public static Package GetInstalledPackage(Package p) /// /// The package to check /// The already existing package if any, otherwhise null - public static Package? GetInstalledPackageOrNull(Package other) + public static IPackage? GetInstalledPackageOrNull(IPackage other) { - if (__installed_pkgs.TryGetValue(other.GetVersionedHash(), out Package? equivalent_package)) + if (__installed_pkgs.TryGetValue(other.GetVersionedHash(), out IPackage? equivalent_package)) { return equivalent_package; } @@ -97,9 +98,9 @@ public static Package GetInstalledPackage(Package p) /// /// The package to check agains /// True if a newer version was found, false otherwhise - public static bool NewerVersionIsInstalled(Package other) + public static bool NewerVersionIsInstalled(IPackage other) { - foreach (Package found in __installed_pkgs.Values) + foreach (IPackage found in __installed_pkgs.Values) { if (found.IsEquivalentTo(other) && found.VersionAsFloat == other.NewVersionAsFloat) { @@ -110,7 +111,7 @@ public static bool NewerVersionIsInstalled(Package other) return false; } - private static void AddPackageToCache(Package package, Dictionary map) + private static void AddPackageToCache(IPackage package, Dictionary map) { long hash = map == __installed_pkgs ? package.GetVersionedHash() : package.GetHash(); map.Add(hash, package); diff --git a/src/UniGetUI.PackageEngine.PackageManagerClasses/Packages/PackageDetails.cs b/src/UniGetUI.PackageEngine.PackageManagerClasses/Packages/PackageDetails.cs index c26f901d7..f4b7495da 100644 --- a/src/UniGetUI.PackageEngine.PackageManagerClasses/Packages/PackageDetails.cs +++ b/src/UniGetUI.PackageEngine.PackageManagerClasses/Packages/PackageDetails.cs @@ -1,108 +1,36 @@ using UniGetUI.Core.Logging; +using UniGetUI.PackageEngine.Interfaces; namespace UniGetUI.PackageEngine.PackageClasses { /// /// Holds the details of a Package. /// - public class PackageDetails + public class PackageDetails: IPackageDetails { - /// - /// The package to which this details instance corresponds - /// - public Package Package { get; } - - /// - /// Wether this PackageDetails instance has valid data or not. - /// To load valid data, make use of the `Load()` method - /// - public bool IsPopulated { get; private set; } = false; - - /// - /// The description of the package - /// + public IPackage Package { get; } + public bool IsPopulated { get; set; } = false; public string? Description { get; set; } = null; - - /// - /// The publisher of the package. The one(s) in charge of maintaining the package published on the package manager. - /// public string? Publisher { get; set; } = null; - - /// - /// The author of the package. Who has created the package. Usually the developer of the package. - /// public string? Author { get; set; } = null; - - /// - /// A link to the homepage of the package - /// public Uri? HomepageUrl { get; set; } = null; - - /// - /// The license name (not the URL) of the package - /// public string? License { get; set; } = null; - - /// - /// A URL pointing to the license of the package. - /// public Uri? LicenseUrl { get; set; } = null; - - /// - /// A URL pointing to the installer of the package - /// public Uri? InstallerUrl { get; set; } = null; - - /// - /// A string representing the hash of the installer. - /// public string? InstallerHash { get; set; } = null; - - /// - /// A string representing the type of the installer (.zip, .exe, .msi, .appx, tarball, etc.) - /// public string? InstallerType { get; set; } = null; - - /// - /// The size, in **MEGABYTES**, of the installer - /// public double InstallerSize { get; set; } = 0; - - /// - /// A URL pointing to the Manifest File of the package - /// public Uri? ManifestUrl { get; set; } = null; - - /// - /// The update date (aka the publication date for the latest version) of the package - /// public string? UpdateDate { get; set; } = null; - - /// - /// The release notes (not the URL) for the package. - /// public string? ReleaseNotes { get; set; } = null; - - /// - /// A URL to the package release notes. - /// public Uri? ReleaseNotesUrl { get; set; } = null; - - /// - /// A list of tags that (in theory) represent the package - /// public string[] Tags { get; set; } = []; - public PackageDetails(Package package) + public PackageDetails(IPackage package) { Package = package; } - /// - /// Loads the available package details. May override existing data. - /// If the load succeeds, `IsPopulated` will be set to True. - /// - /// An asynchronous task that can be awaited public async Task Load() { try { diff --git a/src/UniGetUI.PackageEngine.PackageManagerClasses/Packages/PackageWrapper.cs b/src/UniGetUI.PackageEngine.PackageManagerClasses/Packages/PackageWrapper.cs index 7d42a541f..387e55c6c 100644 --- a/src/UniGetUI.PackageEngine.PackageManagerClasses/Packages/PackageWrapper.cs +++ b/src/UniGetUI.PackageEngine.PackageManagerClasses/Packages/PackageWrapper.cs @@ -2,6 +2,7 @@ using UniGetUI.Core.Classes; using UniGetUI.Core.Tools; using UniGetUI.Interface.Enums; +using UniGetUI.PackageEngine.Interfaces; namespace UniGetUI.PackageEngine.PackageClasses { @@ -27,9 +28,9 @@ public bool IsChecked public int Index { get; set; } public event PropertyChangedEventHandler? PropertyChanged; - public Package Package { get; private set; } + public IPackage Package { get; private set; } public PackageWrapper Self { get; private set; } - public PackageWrapper(Package package) + public PackageWrapper(IPackage package) { Package = package; Self = this; @@ -78,6 +79,7 @@ public void WhenTagHasChanged() PackageTag.OnQueue => false, PackageTag.BeingProcessed => false, PackageTag.Failed => true, + PackageTag.Unavailable => false, }; ListedIconId = Package.Tag switch @@ -89,6 +91,7 @@ public void WhenTagHasChanged() PackageTag.OnQueue => "sandclock", PackageTag.BeingProcessed => "gears", PackageTag.Failed => "stop", + PackageTag.Unavailable => "help", }; ListedNameTooltip = Package.Tag switch @@ -100,6 +103,7 @@ public void WhenTagHasChanged() PackageTag.OnQueue => CoreTools.Translate("This package is on the queue"), PackageTag.BeingProcessed => CoreTools.Translate("This package is being processed"), PackageTag.Failed => CoreTools.Translate("An error occurred while processing this package"), + PackageTag.Unavailable => CoreTools.Translate("This package is not available"), } + " - " + Package.Name; ListedOpacity = Package.Tag switch @@ -111,6 +115,7 @@ public void WhenTagHasChanged() PackageTag.OnQueue => .5F, PackageTag.BeingProcessed => .5F, PackageTag.Failed => 1, + PackageTag.Unavailable => .5F, }; #pragma warning restore CS8524 } diff --git a/src/UniGetUI.PackageEngine.PackageManagerClasses/UniGetUI.PackageEngine.Classes.csproj b/src/UniGetUI.PackageEngine.PackageManagerClasses/UniGetUI.PackageEngine.Classes.csproj index 133b4c647..32430d379 100644 --- a/src/UniGetUI.PackageEngine.PackageManagerClasses/UniGetUI.PackageEngine.Classes.csproj +++ b/src/UniGetUI.PackageEngine.PackageManagerClasses/UniGetUI.PackageEngine.Classes.csproj @@ -32,9 +32,9 @@ - + + - diff --git a/src/UniGetUI.PackageEngine.Serializable/SerializableBundle_v1.cs b/src/UniGetUI.PackageEngine.Serializable/SerializableBundle_v1.cs new file mode 100644 index 000000000..01889c7c5 --- /dev/null +++ b/src/UniGetUI.PackageEngine.Serializable/SerializableBundle_v1.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace UniGetUI.PackageEngine.Classes.Serializable +{ + public class SerializableBundle_v1 + { + public double export_version { get; set; } = 2.0; + public List packages { get; set; } = new(); + public string incompatible_packages_info { get; set; } = "Incompatible packages cannot be installed from WingetUI, but they have been listed here for logging purposes."; + public List incompatible_packages { get; set; } = new(); + + } +} diff --git a/src/UniGetUI.PackageEngine.Serializable/SerializableIncompatiblePackage_v1.cs b/src/UniGetUI.PackageEngine.Serializable/SerializableIncompatiblePackage_v1.cs new file mode 100644 index 000000000..11505ea00 --- /dev/null +++ b/src/UniGetUI.PackageEngine.Serializable/SerializableIncompatiblePackage_v1.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace UniGetUI.PackageEngine.Classes.Serializable +{ + public class SerializableIncompatiblePackage_v1 + { + public string Id { get; set; } = ""; + public string Name { get; set; } = ""; + public string Version { get; set; } = ""; + public string Source { get; set; } = ""; + } +} diff --git a/src/UniGetUI.PackageEngine.Serializable/SerializablePackage_v1.cs b/src/UniGetUI.PackageEngine.Serializable/SerializablePackage_v1.cs new file mode 100644 index 000000000..04a8c17ab --- /dev/null +++ b/src/UniGetUI.PackageEngine.Serializable/SerializablePackage_v1.cs @@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using UniGetUI.PackageEngine.Serializable; + +namespace UniGetUI.PackageEngine.Classes.Serializable +{ + public class SerializablePackage_v1 + { + /// + /// The package full, valid identifier + /// + public string Id { get; set; } = ""; + + /// + /// The package display name + /// + public string Name { get; set; } = ""; + + /// + /// The installed version of the package + /// + public string Version { get; set; } = ""; + + /// + /// The name of the source, WITHOUT the Package Manager name + /// + public string Source { get; set; } = ""; + + /// + /// The name of the package manager + /// + public string ManagerName { get; set; } = ""; + + /// + /// The InstallationOptions associated to this package + /// + public SerializableInstallationOptions_v1 InstallationOptions { get; set; } = new(); + + /// + /// The Updates preferences associated to this package + /// + public SerializableUpdatesOptions_v1 Updates { get; set; } = new(); + + /// + /// Returns an equivalent copy of the current package as an Invalid Serializable Package. + /// The reverse operation is not possible, since data is lost. + /// + /// + public SerializableIncompatiblePackage_v1 GetInvalidEquivalent() + { + return new SerializableIncompatiblePackage_v1() + { + Id = Id, + Name = Name, + Version = Version, + Source = Source, + }; + } + } +} diff --git a/src/UniGetUI.PackageEngine.Serializable/SerializableUpdatesOptions_v1.cs b/src/UniGetUI.PackageEngine.Serializable/SerializableUpdatesOptions_v1.cs new file mode 100644 index 000000000..9e4f41580 --- /dev/null +++ b/src/UniGetUI.PackageEngine.Serializable/SerializableUpdatesOptions_v1.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace UniGetUI.PackageEngine.Classes.Serializable +{ + public class SerializableUpdatesOptions_v1 + { + public bool UpdatesIgnored { get; set; } = false; + public string IgnoredVersion { get; set; } = ""; + } +} diff --git a/src/UniGetUI.sln b/src/UniGetUI.sln index 34e1ef7f6..cffd86865 100644 --- a/src/UniGetUI.sln +++ b/src/UniGetUI.sln @@ -23,7 +23,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UniGetUI.Core.Classes", "Un EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UniGetUI.Core.IconEngine", "UniGetUI.Core.IconStore\UniGetUI.Core.IconEngine.csproj", "{990F5AFF-ABF6-4019-865D-604D2B23DE2C}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UniGetUI.PackageEngine.Enums", "UniGetUI.PackageEngine.Enums\UniGetUI.PackageEngine.Enums.csproj", "{380E9F5A-23DE-4F5A-9644-EFA51AD1D8E8}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UniGetUI.PackageEngine.Structs", "UniGetUI.PackageEngine.Enums\UniGetUI.PackageEngine.Structs.csproj", "{380E9F5A-23DE-4F5A-9644-EFA51AD1D8E8}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UniGetUI.Interface.Enums", "UniGetUI.Interface.Enums\UniGetUI.Interface.Enums.csproj", "{5A48C2FD-16E4-4B44-BC2C-D793C50E66F2}" EndProject @@ -51,8 +51,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UniGetUI.Core.Logging.Tests EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UniGetUI.PackageEngine.Classes", "UniGetUI.PackageEngine.PackageManagerClasses\UniGetUI.PackageEngine.Classes.csproj", "{7E098666-DE8C-4ABF-B709-4CE7B1A491B0}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UniGetUI.PackageEngine.Serializable", "UniGetUI.PackageEngine.Serializable\UniGetUI.PackageEngine.Serializable.csproj", "{B5E11AAA-B800-455E-9C64-051FFEFD6C0B}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Managers", "Managers", "{95168D0B-1B2C-4295-B6D4-D5BAF781B9FA}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UniGetUI.PackageEngine.Managers.WinGet", "UniGetUI.PackageEngine.Managers.WinGet\UniGetUI.PackageEngine.Managers.WinGet.csproj", "{D47CC16E-466B-4D58-A8FC-ECAE5C9606FC}" @@ -83,278 +81,428 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UniGetUI.PackageEngine.PEIn EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UniGetUI.Interface.BackgroundApi", "UniGetUI.Interface.BackgroundApi\UniGetUI.Interface.BackgroundApi.csproj", "{CC400751-216E-4BB2-8103-495B4E273477}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UniGetUI.PackageEngine.Interfaces", "UniGetUI.PAckageEngine.Interfaces\UniGetUI.PackageEngine.Interfaces.csproj", "{B4311159-9B5B-4051-94E5-AD63BB27E509}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UniGetUI.PackageEngine.Serializable", "UniGetUI.PackageEngine.Serializable\UniGetUI.PackageEngine.Serializable.csproj", "{A1A53AA4-0F4B-41A0-B1F8-B3C41841A56F}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU + Debug|ARM64 = Debug|ARM64 Debug|x64 = Debug|x64 Release|Any CPU = Release|Any CPU + Release|ARM64 = Release|ARM64 Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {80305A17-2534-48DC-8F75-41F70FCCEAAF}.Debug|Any CPU.ActiveCfg = Debug|x64 {80305A17-2534-48DC-8F75-41F70FCCEAAF}.Debug|Any CPU.Build.0 = Debug|x64 + {80305A17-2534-48DC-8F75-41F70FCCEAAF}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {80305A17-2534-48DC-8F75-41F70FCCEAAF}.Debug|ARM64.Build.0 = Debug|ARM64 {80305A17-2534-48DC-8F75-41F70FCCEAAF}.Debug|x64.ActiveCfg = Debug|x64 {80305A17-2534-48DC-8F75-41F70FCCEAAF}.Debug|x64.Build.0 = Debug|x64 {80305A17-2534-48DC-8F75-41F70FCCEAAF}.Release|Any CPU.ActiveCfg = Release|x64 {80305A17-2534-48DC-8F75-41F70FCCEAAF}.Release|Any CPU.Build.0 = Release|x64 + {80305A17-2534-48DC-8F75-41F70FCCEAAF}.Release|ARM64.ActiveCfg = Release|ARM64 + {80305A17-2534-48DC-8F75-41F70FCCEAAF}.Release|ARM64.Build.0 = Release|ARM64 {80305A17-2534-48DC-8F75-41F70FCCEAAF}.Release|x64.ActiveCfg = Release|x64 {80305A17-2534-48DC-8F75-41F70FCCEAAF}.Release|x64.Build.0 = Release|x64 {52AC982E-7382-4746-BB66-4003698FCC02}.Debug|Any CPU.ActiveCfg = Debug|x64 {52AC982E-7382-4746-BB66-4003698FCC02}.Debug|Any CPU.Build.0 = Debug|x64 + {52AC982E-7382-4746-BB66-4003698FCC02}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {52AC982E-7382-4746-BB66-4003698FCC02}.Debug|ARM64.Build.0 = Debug|ARM64 {52AC982E-7382-4746-BB66-4003698FCC02}.Debug|x64.ActiveCfg = Debug|x64 {52AC982E-7382-4746-BB66-4003698FCC02}.Debug|x64.Build.0 = Debug|x64 {52AC982E-7382-4746-BB66-4003698FCC02}.Release|Any CPU.ActiveCfg = Release|x64 {52AC982E-7382-4746-BB66-4003698FCC02}.Release|Any CPU.Build.0 = Release|x64 + {52AC982E-7382-4746-BB66-4003698FCC02}.Release|ARM64.ActiveCfg = Release|ARM64 + {52AC982E-7382-4746-BB66-4003698FCC02}.Release|ARM64.Build.0 = Release|ARM64 {52AC982E-7382-4746-BB66-4003698FCC02}.Release|x64.ActiveCfg = Release|x64 {52AC982E-7382-4746-BB66-4003698FCC02}.Release|x64.Build.0 = Release|x64 {5F5EF76B-D755-4C12-ADAE-11F08CE3D936}.Debug|Any CPU.ActiveCfg = Debug|x64 {5F5EF76B-D755-4C12-ADAE-11F08CE3D936}.Debug|Any CPU.Build.0 = Debug|x64 + {5F5EF76B-D755-4C12-ADAE-11F08CE3D936}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {5F5EF76B-D755-4C12-ADAE-11F08CE3D936}.Debug|ARM64.Build.0 = Debug|ARM64 {5F5EF76B-D755-4C12-ADAE-11F08CE3D936}.Debug|x64.ActiveCfg = Debug|x64 {5F5EF76B-D755-4C12-ADAE-11F08CE3D936}.Debug|x64.Build.0 = Debug|x64 {5F5EF76B-D755-4C12-ADAE-11F08CE3D936}.Release|Any CPU.ActiveCfg = Release|x64 {5F5EF76B-D755-4C12-ADAE-11F08CE3D936}.Release|Any CPU.Build.0 = Release|x64 + {5F5EF76B-D755-4C12-ADAE-11F08CE3D936}.Release|ARM64.ActiveCfg = Release|ARM64 + {5F5EF76B-D755-4C12-ADAE-11F08CE3D936}.Release|ARM64.Build.0 = Release|ARM64 {5F5EF76B-D755-4C12-ADAE-11F08CE3D936}.Release|x64.ActiveCfg = Release|x64 {5F5EF76B-D755-4C12-ADAE-11F08CE3D936}.Release|x64.Build.0 = Release|x64 {B70A6F17-08C8-4194-BBE8-668CA920CFF3}.Debug|Any CPU.ActiveCfg = Debug|x64 {B70A6F17-08C8-4194-BBE8-668CA920CFF3}.Debug|Any CPU.Build.0 = Debug|x64 + {B70A6F17-08C8-4194-BBE8-668CA920CFF3}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {B70A6F17-08C8-4194-BBE8-668CA920CFF3}.Debug|ARM64.Build.0 = Debug|ARM64 {B70A6F17-08C8-4194-BBE8-668CA920CFF3}.Debug|x64.ActiveCfg = Debug|x64 {B70A6F17-08C8-4194-BBE8-668CA920CFF3}.Debug|x64.Build.0 = Debug|x64 {B70A6F17-08C8-4194-BBE8-668CA920CFF3}.Release|Any CPU.ActiveCfg = Release|x64 {B70A6F17-08C8-4194-BBE8-668CA920CFF3}.Release|Any CPU.Build.0 = Release|x64 + {B70A6F17-08C8-4194-BBE8-668CA920CFF3}.Release|ARM64.ActiveCfg = Release|ARM64 + {B70A6F17-08C8-4194-BBE8-668CA920CFF3}.Release|ARM64.Build.0 = Release|ARM64 {B70A6F17-08C8-4194-BBE8-668CA920CFF3}.Release|x64.ActiveCfg = Release|x64 {B70A6F17-08C8-4194-BBE8-668CA920CFF3}.Release|x64.Build.0 = Release|x64 {72180B0C-3D20-4AAD-B015-A9337B91406E}.Debug|Any CPU.ActiveCfg = Debug|x64 {72180B0C-3D20-4AAD-B015-A9337B91406E}.Debug|Any CPU.Build.0 = Debug|x64 + {72180B0C-3D20-4AAD-B015-A9337B91406E}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {72180B0C-3D20-4AAD-B015-A9337B91406E}.Debug|ARM64.Build.0 = Debug|ARM64 {72180B0C-3D20-4AAD-B015-A9337B91406E}.Debug|x64.ActiveCfg = Debug|x64 {72180B0C-3D20-4AAD-B015-A9337B91406E}.Debug|x64.Build.0 = Debug|x64 {72180B0C-3D20-4AAD-B015-A9337B91406E}.Release|Any CPU.ActiveCfg = Release|x64 {72180B0C-3D20-4AAD-B015-A9337B91406E}.Release|Any CPU.Build.0 = Release|x64 + {72180B0C-3D20-4AAD-B015-A9337B91406E}.Release|ARM64.ActiveCfg = Release|ARM64 + {72180B0C-3D20-4AAD-B015-A9337B91406E}.Release|ARM64.Build.0 = Release|ARM64 {72180B0C-3D20-4AAD-B015-A9337B91406E}.Release|x64.ActiveCfg = Release|x64 {72180B0C-3D20-4AAD-B015-A9337B91406E}.Release|x64.Build.0 = Release|x64 {1977360F-2E42-45E6-9369-AB1EE59CC5C5}.Debug|Any CPU.ActiveCfg = Debug|x64 {1977360F-2E42-45E6-9369-AB1EE59CC5C5}.Debug|Any CPU.Build.0 = Debug|x64 + {1977360F-2E42-45E6-9369-AB1EE59CC5C5}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {1977360F-2E42-45E6-9369-AB1EE59CC5C5}.Debug|ARM64.Build.0 = Debug|ARM64 {1977360F-2E42-45E6-9369-AB1EE59CC5C5}.Debug|x64.ActiveCfg = Debug|x64 {1977360F-2E42-45E6-9369-AB1EE59CC5C5}.Debug|x64.Build.0 = Debug|x64 {1977360F-2E42-45E6-9369-AB1EE59CC5C5}.Release|Any CPU.ActiveCfg = Release|x64 {1977360F-2E42-45E6-9369-AB1EE59CC5C5}.Release|Any CPU.Build.0 = Release|x64 + {1977360F-2E42-45E6-9369-AB1EE59CC5C5}.Release|ARM64.ActiveCfg = Release|ARM64 + {1977360F-2E42-45E6-9369-AB1EE59CC5C5}.Release|ARM64.Build.0 = Release|ARM64 {1977360F-2E42-45E6-9369-AB1EE59CC5C5}.Release|x64.ActiveCfg = Release|x64 {1977360F-2E42-45E6-9369-AB1EE59CC5C5}.Release|x64.Build.0 = Release|x64 {25C6CE64-2D61-4832-B6D2-45AFC52E2447}.Debug|Any CPU.ActiveCfg = Debug|x64 {25C6CE64-2D61-4832-B6D2-45AFC52E2447}.Debug|Any CPU.Build.0 = Debug|x64 + {25C6CE64-2D61-4832-B6D2-45AFC52E2447}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {25C6CE64-2D61-4832-B6D2-45AFC52E2447}.Debug|ARM64.Build.0 = Debug|ARM64 {25C6CE64-2D61-4832-B6D2-45AFC52E2447}.Debug|x64.ActiveCfg = Debug|x64 {25C6CE64-2D61-4832-B6D2-45AFC52E2447}.Debug|x64.Build.0 = Debug|x64 {25C6CE64-2D61-4832-B6D2-45AFC52E2447}.Release|Any CPU.ActiveCfg = Release|x64 {25C6CE64-2D61-4832-B6D2-45AFC52E2447}.Release|Any CPU.Build.0 = Release|x64 + {25C6CE64-2D61-4832-B6D2-45AFC52E2447}.Release|ARM64.ActiveCfg = Release|ARM64 + {25C6CE64-2D61-4832-B6D2-45AFC52E2447}.Release|ARM64.Build.0 = Release|ARM64 {25C6CE64-2D61-4832-B6D2-45AFC52E2447}.Release|x64.ActiveCfg = Release|x64 {25C6CE64-2D61-4832-B6D2-45AFC52E2447}.Release|x64.Build.0 = Release|x64 {8156B6D8-BD7E-4201-BD8B-8C9B00177F88}.Debug|Any CPU.ActiveCfg = Debug|x64 {8156B6D8-BD7E-4201-BD8B-8C9B00177F88}.Debug|Any CPU.Build.0 = Debug|x64 + {8156B6D8-BD7E-4201-BD8B-8C9B00177F88}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {8156B6D8-BD7E-4201-BD8B-8C9B00177F88}.Debug|ARM64.Build.0 = Debug|ARM64 {8156B6D8-BD7E-4201-BD8B-8C9B00177F88}.Debug|x64.ActiveCfg = Debug|x64 {8156B6D8-BD7E-4201-BD8B-8C9B00177F88}.Debug|x64.Build.0 = Debug|x64 {8156B6D8-BD7E-4201-BD8B-8C9B00177F88}.Release|Any CPU.ActiveCfg = Release|x64 {8156B6D8-BD7E-4201-BD8B-8C9B00177F88}.Release|Any CPU.Build.0 = Release|x64 + {8156B6D8-BD7E-4201-BD8B-8C9B00177F88}.Release|ARM64.ActiveCfg = Release|ARM64 + {8156B6D8-BD7E-4201-BD8B-8C9B00177F88}.Release|ARM64.Build.0 = Release|ARM64 {8156B6D8-BD7E-4201-BD8B-8C9B00177F88}.Release|x64.ActiveCfg = Release|x64 {8156B6D8-BD7E-4201-BD8B-8C9B00177F88}.Release|x64.Build.0 = Release|x64 {990F5AFF-ABF6-4019-865D-604D2B23DE2C}.Debug|Any CPU.ActiveCfg = Debug|x64 {990F5AFF-ABF6-4019-865D-604D2B23DE2C}.Debug|Any CPU.Build.0 = Debug|x64 + {990F5AFF-ABF6-4019-865D-604D2B23DE2C}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {990F5AFF-ABF6-4019-865D-604D2B23DE2C}.Debug|ARM64.Build.0 = Debug|ARM64 {990F5AFF-ABF6-4019-865D-604D2B23DE2C}.Debug|x64.ActiveCfg = Debug|x64 {990F5AFF-ABF6-4019-865D-604D2B23DE2C}.Debug|x64.Build.0 = Debug|x64 {990F5AFF-ABF6-4019-865D-604D2B23DE2C}.Release|Any CPU.ActiveCfg = Release|x64 {990F5AFF-ABF6-4019-865D-604D2B23DE2C}.Release|Any CPU.Build.0 = Release|x64 + {990F5AFF-ABF6-4019-865D-604D2B23DE2C}.Release|ARM64.ActiveCfg = Release|ARM64 + {990F5AFF-ABF6-4019-865D-604D2B23DE2C}.Release|ARM64.Build.0 = Release|ARM64 {990F5AFF-ABF6-4019-865D-604D2B23DE2C}.Release|x64.ActiveCfg = Release|x64 {990F5AFF-ABF6-4019-865D-604D2B23DE2C}.Release|x64.Build.0 = Release|x64 {380E9F5A-23DE-4F5A-9644-EFA51AD1D8E8}.Debug|Any CPU.ActiveCfg = Debug|x64 {380E9F5A-23DE-4F5A-9644-EFA51AD1D8E8}.Debug|Any CPU.Build.0 = Debug|x64 + {380E9F5A-23DE-4F5A-9644-EFA51AD1D8E8}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {380E9F5A-23DE-4F5A-9644-EFA51AD1D8E8}.Debug|ARM64.Build.0 = Debug|ARM64 {380E9F5A-23DE-4F5A-9644-EFA51AD1D8E8}.Debug|x64.ActiveCfg = Debug|x64 {380E9F5A-23DE-4F5A-9644-EFA51AD1D8E8}.Debug|x64.Build.0 = Debug|x64 {380E9F5A-23DE-4F5A-9644-EFA51AD1D8E8}.Release|Any CPU.ActiveCfg = Release|x64 {380E9F5A-23DE-4F5A-9644-EFA51AD1D8E8}.Release|Any CPU.Build.0 = Release|x64 + {380E9F5A-23DE-4F5A-9644-EFA51AD1D8E8}.Release|ARM64.ActiveCfg = Release|ARM64 + {380E9F5A-23DE-4F5A-9644-EFA51AD1D8E8}.Release|ARM64.Build.0 = Release|ARM64 {380E9F5A-23DE-4F5A-9644-EFA51AD1D8E8}.Release|x64.ActiveCfg = Release|x64 {380E9F5A-23DE-4F5A-9644-EFA51AD1D8E8}.Release|x64.Build.0 = Release|x64 {5A48C2FD-16E4-4B44-BC2C-D793C50E66F2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {5A48C2FD-16E4-4B44-BC2C-D793C50E66F2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5A48C2FD-16E4-4B44-BC2C-D793C50E66F2}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {5A48C2FD-16E4-4B44-BC2C-D793C50E66F2}.Debug|ARM64.Build.0 = Debug|ARM64 {5A48C2FD-16E4-4B44-BC2C-D793C50E66F2}.Debug|x64.ActiveCfg = Debug|x64 {5A48C2FD-16E4-4B44-BC2C-D793C50E66F2}.Debug|x64.Build.0 = Debug|x64 {5A48C2FD-16E4-4B44-BC2C-D793C50E66F2}.Release|Any CPU.ActiveCfg = Release|Any CPU {5A48C2FD-16E4-4B44-BC2C-D793C50E66F2}.Release|Any CPU.Build.0 = Release|Any CPU + {5A48C2FD-16E4-4B44-BC2C-D793C50E66F2}.Release|ARM64.ActiveCfg = Release|ARM64 + {5A48C2FD-16E4-4B44-BC2C-D793C50E66F2}.Release|ARM64.Build.0 = Release|ARM64 {5A48C2FD-16E4-4B44-BC2C-D793C50E66F2}.Release|x64.ActiveCfg = Release|x64 {5A48C2FD-16E4-4B44-BC2C-D793C50E66F2}.Release|x64.Build.0 = Release|x64 {9AD1DEC9-1561-4753-AB4B-E81FBDBA5C9E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {9AD1DEC9-1561-4753-AB4B-E81FBDBA5C9E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9AD1DEC9-1561-4753-AB4B-E81FBDBA5C9E}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {9AD1DEC9-1561-4753-AB4B-E81FBDBA5C9E}.Debug|ARM64.Build.0 = Debug|ARM64 {9AD1DEC9-1561-4753-AB4B-E81FBDBA5C9E}.Debug|x64.ActiveCfg = Debug|x64 {9AD1DEC9-1561-4753-AB4B-E81FBDBA5C9E}.Debug|x64.Build.0 = Debug|x64 {9AD1DEC9-1561-4753-AB4B-E81FBDBA5C9E}.Release|Any CPU.ActiveCfg = Release|Any CPU {9AD1DEC9-1561-4753-AB4B-E81FBDBA5C9E}.Release|Any CPU.Build.0 = Release|Any CPU + {9AD1DEC9-1561-4753-AB4B-E81FBDBA5C9E}.Release|ARM64.ActiveCfg = Release|ARM64 + {9AD1DEC9-1561-4753-AB4B-E81FBDBA5C9E}.Release|ARM64.Build.0 = Release|ARM64 {9AD1DEC9-1561-4753-AB4B-E81FBDBA5C9E}.Release|x64.ActiveCfg = Release|x64 {9AD1DEC9-1561-4753-AB4B-E81FBDBA5C9E}.Release|x64.Build.0 = Release|x64 {E40BFCBB-7A02-4E2C-AFDB-A717359EF4FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {E40BFCBB-7A02-4E2C-AFDB-A717359EF4FC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E40BFCBB-7A02-4E2C-AFDB-A717359EF4FC}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {E40BFCBB-7A02-4E2C-AFDB-A717359EF4FC}.Debug|ARM64.Build.0 = Debug|ARM64 {E40BFCBB-7A02-4E2C-AFDB-A717359EF4FC}.Debug|x64.ActiveCfg = Debug|x64 {E40BFCBB-7A02-4E2C-AFDB-A717359EF4FC}.Debug|x64.Build.0 = Debug|x64 {E40BFCBB-7A02-4E2C-AFDB-A717359EF4FC}.Release|Any CPU.ActiveCfg = Release|Any CPU {E40BFCBB-7A02-4E2C-AFDB-A717359EF4FC}.Release|Any CPU.Build.0 = Release|Any CPU + {E40BFCBB-7A02-4E2C-AFDB-A717359EF4FC}.Release|ARM64.ActiveCfg = Release|ARM64 + {E40BFCBB-7A02-4E2C-AFDB-A717359EF4FC}.Release|ARM64.Build.0 = Release|ARM64 {E40BFCBB-7A02-4E2C-AFDB-A717359EF4FC}.Release|x64.ActiveCfg = Release|x64 {E40BFCBB-7A02-4E2C-AFDB-A717359EF4FC}.Release|x64.Build.0 = Release|x64 {562B4814-2A78-4692-90BE-A727AABCEC85}.Debug|Any CPU.ActiveCfg = Debug|x64 {562B4814-2A78-4692-90BE-A727AABCEC85}.Debug|Any CPU.Build.0 = Debug|x64 + {562B4814-2A78-4692-90BE-A727AABCEC85}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {562B4814-2A78-4692-90BE-A727AABCEC85}.Debug|ARM64.Build.0 = Debug|ARM64 {562B4814-2A78-4692-90BE-A727AABCEC85}.Debug|x64.ActiveCfg = Debug|x64 {562B4814-2A78-4692-90BE-A727AABCEC85}.Debug|x64.Build.0 = Debug|x64 {562B4814-2A78-4692-90BE-A727AABCEC85}.Release|Any CPU.ActiveCfg = Release|x64 {562B4814-2A78-4692-90BE-A727AABCEC85}.Release|Any CPU.Build.0 = Release|x64 + {562B4814-2A78-4692-90BE-A727AABCEC85}.Release|ARM64.ActiveCfg = Release|ARM64 + {562B4814-2A78-4692-90BE-A727AABCEC85}.Release|ARM64.Build.0 = Release|ARM64 {562B4814-2A78-4692-90BE-A727AABCEC85}.Release|x64.ActiveCfg = Release|x64 {562B4814-2A78-4692-90BE-A727AABCEC85}.Release|x64.Build.0 = Release|x64 {1A51EA31-6D78-4E98-B767-41A02C6E34D8}.Debug|Any CPU.ActiveCfg = Debug|x64 {1A51EA31-6D78-4E98-B767-41A02C6E34D8}.Debug|Any CPU.Build.0 = Debug|x64 + {1A51EA31-6D78-4E98-B767-41A02C6E34D8}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {1A51EA31-6D78-4E98-B767-41A02C6E34D8}.Debug|ARM64.Build.0 = Debug|ARM64 {1A51EA31-6D78-4E98-B767-41A02C6E34D8}.Debug|x64.ActiveCfg = Debug|x64 {1A51EA31-6D78-4E98-B767-41A02C6E34D8}.Debug|x64.Build.0 = Debug|x64 {1A51EA31-6D78-4E98-B767-41A02C6E34D8}.Release|Any CPU.ActiveCfg = Release|x64 {1A51EA31-6D78-4E98-B767-41A02C6E34D8}.Release|Any CPU.Build.0 = Release|x64 + {1A51EA31-6D78-4E98-B767-41A02C6E34D8}.Release|ARM64.ActiveCfg = Release|ARM64 + {1A51EA31-6D78-4E98-B767-41A02C6E34D8}.Release|ARM64.Build.0 = Release|ARM64 {1A51EA31-6D78-4E98-B767-41A02C6E34D8}.Release|x64.ActiveCfg = Release|x64 {1A51EA31-6D78-4E98-B767-41A02C6E34D8}.Release|x64.Build.0 = Release|x64 {230BF08C-C039-473B-933F-3BF647440E0E}.Debug|Any CPU.ActiveCfg = Debug|x64 {230BF08C-C039-473B-933F-3BF647440E0E}.Debug|Any CPU.Build.0 = Debug|x64 + {230BF08C-C039-473B-933F-3BF647440E0E}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {230BF08C-C039-473B-933F-3BF647440E0E}.Debug|ARM64.Build.0 = Debug|ARM64 {230BF08C-C039-473B-933F-3BF647440E0E}.Debug|x64.ActiveCfg = Debug|x64 {230BF08C-C039-473B-933F-3BF647440E0E}.Debug|x64.Build.0 = Debug|x64 {230BF08C-C039-473B-933F-3BF647440E0E}.Release|Any CPU.ActiveCfg = Release|x64 {230BF08C-C039-473B-933F-3BF647440E0E}.Release|Any CPU.Build.0 = Release|x64 + {230BF08C-C039-473B-933F-3BF647440E0E}.Release|ARM64.ActiveCfg = Release|ARM64 + {230BF08C-C039-473B-933F-3BF647440E0E}.Release|ARM64.Build.0 = Release|ARM64 {230BF08C-C039-473B-933F-3BF647440E0E}.Release|x64.ActiveCfg = Release|x64 {230BF08C-C039-473B-933F-3BF647440E0E}.Release|x64.Build.0 = Release|x64 {C55F4BA7-BBDD-42A4-88C1-FD3C411EB234}.Debug|Any CPU.ActiveCfg = Debug|x64 {C55F4BA7-BBDD-42A4-88C1-FD3C411EB234}.Debug|Any CPU.Build.0 = Debug|x64 + {C55F4BA7-BBDD-42A4-88C1-FD3C411EB234}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {C55F4BA7-BBDD-42A4-88C1-FD3C411EB234}.Debug|ARM64.Build.0 = Debug|ARM64 {C55F4BA7-BBDD-42A4-88C1-FD3C411EB234}.Debug|x64.ActiveCfg = Debug|x64 {C55F4BA7-BBDD-42A4-88C1-FD3C411EB234}.Debug|x64.Build.0 = Debug|x64 {C55F4BA7-BBDD-42A4-88C1-FD3C411EB234}.Release|Any CPU.ActiveCfg = Release|x64 {C55F4BA7-BBDD-42A4-88C1-FD3C411EB234}.Release|Any CPU.Build.0 = Release|x64 + {C55F4BA7-BBDD-42A4-88C1-FD3C411EB234}.Release|ARM64.ActiveCfg = Release|ARM64 + {C55F4BA7-BBDD-42A4-88C1-FD3C411EB234}.Release|ARM64.Build.0 = Release|ARM64 {C55F4BA7-BBDD-42A4-88C1-FD3C411EB234}.Release|x64.ActiveCfg = Release|x64 {C55F4BA7-BBDD-42A4-88C1-FD3C411EB234}.Release|x64.Build.0 = Release|x64 {2979E556-5859-4E88-A1D4-EAB72F82294E}.Debug|Any CPU.ActiveCfg = Debug|x64 {2979E556-5859-4E88-A1D4-EAB72F82294E}.Debug|Any CPU.Build.0 = Debug|x64 + {2979E556-5859-4E88-A1D4-EAB72F82294E}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {2979E556-5859-4E88-A1D4-EAB72F82294E}.Debug|ARM64.Build.0 = Debug|ARM64 {2979E556-5859-4E88-A1D4-EAB72F82294E}.Debug|x64.ActiveCfg = Debug|x64 {2979E556-5859-4E88-A1D4-EAB72F82294E}.Debug|x64.Build.0 = Debug|x64 {2979E556-5859-4E88-A1D4-EAB72F82294E}.Release|Any CPU.ActiveCfg = Release|x64 {2979E556-5859-4E88-A1D4-EAB72F82294E}.Release|Any CPU.Build.0 = Release|x64 + {2979E556-5859-4E88-A1D4-EAB72F82294E}.Release|ARM64.ActiveCfg = Release|ARM64 + {2979E556-5859-4E88-A1D4-EAB72F82294E}.Release|ARM64.Build.0 = Release|ARM64 {2979E556-5859-4E88-A1D4-EAB72F82294E}.Release|x64.ActiveCfg = Release|x64 {2979E556-5859-4E88-A1D4-EAB72F82294E}.Release|x64.Build.0 = Release|x64 {7E098666-DE8C-4ABF-B709-4CE7B1A491B0}.Debug|Any CPU.ActiveCfg = Debug|x64 {7E098666-DE8C-4ABF-B709-4CE7B1A491B0}.Debug|Any CPU.Build.0 = Debug|x64 + {7E098666-DE8C-4ABF-B709-4CE7B1A491B0}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {7E098666-DE8C-4ABF-B709-4CE7B1A491B0}.Debug|ARM64.Build.0 = Debug|ARM64 {7E098666-DE8C-4ABF-B709-4CE7B1A491B0}.Debug|x64.ActiveCfg = Debug|x64 {7E098666-DE8C-4ABF-B709-4CE7B1A491B0}.Debug|x64.Build.0 = Debug|x64 {7E098666-DE8C-4ABF-B709-4CE7B1A491B0}.Release|Any CPU.ActiveCfg = Release|x64 {7E098666-DE8C-4ABF-B709-4CE7B1A491B0}.Release|Any CPU.Build.0 = Release|x64 + {7E098666-DE8C-4ABF-B709-4CE7B1A491B0}.Release|ARM64.ActiveCfg = Release|ARM64 + {7E098666-DE8C-4ABF-B709-4CE7B1A491B0}.Release|ARM64.Build.0 = Release|ARM64 {7E098666-DE8C-4ABF-B709-4CE7B1A491B0}.Release|x64.ActiveCfg = Release|x64 {7E098666-DE8C-4ABF-B709-4CE7B1A491B0}.Release|x64.Build.0 = Release|x64 - {B5E11AAA-B800-455E-9C64-051FFEFD6C0B}.Debug|Any CPU.ActiveCfg = Debug|x64 - {B5E11AAA-B800-455E-9C64-051FFEFD6C0B}.Debug|Any CPU.Build.0 = Debug|x64 - {B5E11AAA-B800-455E-9C64-051FFEFD6C0B}.Debug|x64.ActiveCfg = Debug|x64 - {B5E11AAA-B800-455E-9C64-051FFEFD6C0B}.Debug|x64.Build.0 = Debug|x64 - {B5E11AAA-B800-455E-9C64-051FFEFD6C0B}.Release|Any CPU.ActiveCfg = Release|x64 - {B5E11AAA-B800-455E-9C64-051FFEFD6C0B}.Release|Any CPU.Build.0 = Release|x64 - {B5E11AAA-B800-455E-9C64-051FFEFD6C0B}.Release|x64.ActiveCfg = Release|x64 - {B5E11AAA-B800-455E-9C64-051FFEFD6C0B}.Release|x64.Build.0 = Release|x64 {D47CC16E-466B-4D58-A8FC-ECAE5C9606FC}.Debug|Any CPU.ActiveCfg = Debug|x64 {D47CC16E-466B-4D58-A8FC-ECAE5C9606FC}.Debug|Any CPU.Build.0 = Debug|x64 + {D47CC16E-466B-4D58-A8FC-ECAE5C9606FC}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {D47CC16E-466B-4D58-A8FC-ECAE5C9606FC}.Debug|ARM64.Build.0 = Debug|ARM64 {D47CC16E-466B-4D58-A8FC-ECAE5C9606FC}.Debug|x64.ActiveCfg = Debug|x64 {D47CC16E-466B-4D58-A8FC-ECAE5C9606FC}.Debug|x64.Build.0 = Debug|x64 {D47CC16E-466B-4D58-A8FC-ECAE5C9606FC}.Release|Any CPU.ActiveCfg = Release|x64 {D47CC16E-466B-4D58-A8FC-ECAE5C9606FC}.Release|Any CPU.Build.0 = Release|x64 + {D47CC16E-466B-4D58-A8FC-ECAE5C9606FC}.Release|ARM64.ActiveCfg = Release|ARM64 + {D47CC16E-466B-4D58-A8FC-ECAE5C9606FC}.Release|ARM64.Build.0 = Release|ARM64 {D47CC16E-466B-4D58-A8FC-ECAE5C9606FC}.Release|x64.ActiveCfg = Release|x64 {D47CC16E-466B-4D58-A8FC-ECAE5C9606FC}.Release|x64.Build.0 = Release|x64 {1143176D-B7F0-477C-90BB-72289068D927}.Debug|Any CPU.ActiveCfg = Debug|x64 {1143176D-B7F0-477C-90BB-72289068D927}.Debug|Any CPU.Build.0 = Debug|x64 + {1143176D-B7F0-477C-90BB-72289068D927}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {1143176D-B7F0-477C-90BB-72289068D927}.Debug|ARM64.Build.0 = Debug|ARM64 {1143176D-B7F0-477C-90BB-72289068D927}.Debug|x64.ActiveCfg = Debug|x64 {1143176D-B7F0-477C-90BB-72289068D927}.Debug|x64.Build.0 = Debug|x64 {1143176D-B7F0-477C-90BB-72289068D927}.Release|Any CPU.ActiveCfg = Release|x64 {1143176D-B7F0-477C-90BB-72289068D927}.Release|Any CPU.Build.0 = Release|x64 + {1143176D-B7F0-477C-90BB-72289068D927}.Release|ARM64.ActiveCfg = Release|ARM64 + {1143176D-B7F0-477C-90BB-72289068D927}.Release|ARM64.Build.0 = Release|ARM64 {1143176D-B7F0-477C-90BB-72289068D927}.Release|x64.ActiveCfg = Release|x64 {1143176D-B7F0-477C-90BB-72289068D927}.Release|x64.Build.0 = Release|x64 {E454D3A5-C5C6-4291-BE96-220CF0D5CFFD}.Debug|Any CPU.ActiveCfg = Debug|x64 {E454D3A5-C5C6-4291-BE96-220CF0D5CFFD}.Debug|Any CPU.Build.0 = Debug|x64 + {E454D3A5-C5C6-4291-BE96-220CF0D5CFFD}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {E454D3A5-C5C6-4291-BE96-220CF0D5CFFD}.Debug|ARM64.Build.0 = Debug|ARM64 {E454D3A5-C5C6-4291-BE96-220CF0D5CFFD}.Debug|x64.ActiveCfg = Debug|x64 {E454D3A5-C5C6-4291-BE96-220CF0D5CFFD}.Debug|x64.Build.0 = Debug|x64 {E454D3A5-C5C6-4291-BE96-220CF0D5CFFD}.Release|Any CPU.ActiveCfg = Release|x64 {E454D3A5-C5C6-4291-BE96-220CF0D5CFFD}.Release|Any CPU.Build.0 = Release|x64 + {E454D3A5-C5C6-4291-BE96-220CF0D5CFFD}.Release|ARM64.ActiveCfg = Release|ARM64 + {E454D3A5-C5C6-4291-BE96-220CF0D5CFFD}.Release|ARM64.Build.0 = Release|ARM64 {E454D3A5-C5C6-4291-BE96-220CF0D5CFFD}.Release|x64.ActiveCfg = Release|x64 {E454D3A5-C5C6-4291-BE96-220CF0D5CFFD}.Release|x64.Build.0 = Release|x64 {57D094C1-6913-46BF-A657-84A5F46D4EE7}.Debug|Any CPU.ActiveCfg = Debug|x64 {57D094C1-6913-46BF-A657-84A5F46D4EE7}.Debug|Any CPU.Build.0 = Debug|x64 + {57D094C1-6913-46BF-A657-84A5F46D4EE7}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {57D094C1-6913-46BF-A657-84A5F46D4EE7}.Debug|ARM64.Build.0 = Debug|ARM64 {57D094C1-6913-46BF-A657-84A5F46D4EE7}.Debug|x64.ActiveCfg = Debug|x64 {57D094C1-6913-46BF-A657-84A5F46D4EE7}.Debug|x64.Build.0 = Debug|x64 {57D094C1-6913-46BF-A657-84A5F46D4EE7}.Release|Any CPU.ActiveCfg = Release|x64 {57D094C1-6913-46BF-A657-84A5F46D4EE7}.Release|Any CPU.Build.0 = Release|x64 + {57D094C1-6913-46BF-A657-84A5F46D4EE7}.Release|ARM64.ActiveCfg = Release|ARM64 + {57D094C1-6913-46BF-A657-84A5F46D4EE7}.Release|ARM64.Build.0 = Release|ARM64 {57D094C1-6913-46BF-A657-84A5F46D4EE7}.Release|x64.ActiveCfg = Release|x64 {57D094C1-6913-46BF-A657-84A5F46D4EE7}.Release|x64.Build.0 = Release|x64 {740E2894-903D-4B94-9C32-B630593BEB16}.Debug|Any CPU.ActiveCfg = Debug|x64 {740E2894-903D-4B94-9C32-B630593BEB16}.Debug|Any CPU.Build.0 = Debug|x64 + {740E2894-903D-4B94-9C32-B630593BEB16}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {740E2894-903D-4B94-9C32-B630593BEB16}.Debug|ARM64.Build.0 = Debug|ARM64 {740E2894-903D-4B94-9C32-B630593BEB16}.Debug|x64.ActiveCfg = Debug|x64 {740E2894-903D-4B94-9C32-B630593BEB16}.Debug|x64.Build.0 = Debug|x64 {740E2894-903D-4B94-9C32-B630593BEB16}.Release|Any CPU.ActiveCfg = Release|x64 {740E2894-903D-4B94-9C32-B630593BEB16}.Release|Any CPU.Build.0 = Release|x64 + {740E2894-903D-4B94-9C32-B630593BEB16}.Release|ARM64.ActiveCfg = Release|ARM64 + {740E2894-903D-4B94-9C32-B630593BEB16}.Release|ARM64.Build.0 = Release|ARM64 {740E2894-903D-4B94-9C32-B630593BEB16}.Release|x64.ActiveCfg = Release|x64 {740E2894-903D-4B94-9C32-B630593BEB16}.Release|x64.Build.0 = Release|x64 {D401F706-A182-46E3-A25C-B0BF5AA0D07E}.Debug|Any CPU.ActiveCfg = Debug|x64 {D401F706-A182-46E3-A25C-B0BF5AA0D07E}.Debug|Any CPU.Build.0 = Debug|x64 + {D401F706-A182-46E3-A25C-B0BF5AA0D07E}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {D401F706-A182-46E3-A25C-B0BF5AA0D07E}.Debug|ARM64.Build.0 = Debug|ARM64 {D401F706-A182-46E3-A25C-B0BF5AA0D07E}.Debug|x64.ActiveCfg = Debug|x64 {D401F706-A182-46E3-A25C-B0BF5AA0D07E}.Debug|x64.Build.0 = Debug|x64 {D401F706-A182-46E3-A25C-B0BF5AA0D07E}.Release|Any CPU.ActiveCfg = Release|x64 {D401F706-A182-46E3-A25C-B0BF5AA0D07E}.Release|Any CPU.Build.0 = Release|x64 + {D401F706-A182-46E3-A25C-B0BF5AA0D07E}.Release|ARM64.ActiveCfg = Release|ARM64 + {D401F706-A182-46E3-A25C-B0BF5AA0D07E}.Release|ARM64.Build.0 = Release|ARM64 {D401F706-A182-46E3-A25C-B0BF5AA0D07E}.Release|x64.ActiveCfg = Release|x64 {D401F706-A182-46E3-A25C-B0BF5AA0D07E}.Release|x64.Build.0 = Release|x64 {0FFA3F96-A68A-453F-A5FE-0C281EC371C7}.Debug|Any CPU.ActiveCfg = Debug|x64 {0FFA3F96-A68A-453F-A5FE-0C281EC371C7}.Debug|Any CPU.Build.0 = Debug|x64 + {0FFA3F96-A68A-453F-A5FE-0C281EC371C7}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {0FFA3F96-A68A-453F-A5FE-0C281EC371C7}.Debug|ARM64.Build.0 = Debug|ARM64 {0FFA3F96-A68A-453F-A5FE-0C281EC371C7}.Debug|x64.ActiveCfg = Debug|x64 {0FFA3F96-A68A-453F-A5FE-0C281EC371C7}.Debug|x64.Build.0 = Debug|x64 {0FFA3F96-A68A-453F-A5FE-0C281EC371C7}.Release|Any CPU.ActiveCfg = Release|x64 {0FFA3F96-A68A-453F-A5FE-0C281EC371C7}.Release|Any CPU.Build.0 = Release|x64 + {0FFA3F96-A68A-453F-A5FE-0C281EC371C7}.Release|ARM64.ActiveCfg = Release|ARM64 + {0FFA3F96-A68A-453F-A5FE-0C281EC371C7}.Release|ARM64.Build.0 = Release|ARM64 {0FFA3F96-A68A-453F-A5FE-0C281EC371C7}.Release|x64.ActiveCfg = Release|x64 {0FFA3F96-A68A-453F-A5FE-0C281EC371C7}.Release|x64.Build.0 = Release|x64 {5FA79592-DE5B-46FF-9E05-34A2E72A7AF7}.Debug|Any CPU.ActiveCfg = Debug|x64 {5FA79592-DE5B-46FF-9E05-34A2E72A7AF7}.Debug|Any CPU.Build.0 = Debug|x64 + {5FA79592-DE5B-46FF-9E05-34A2E72A7AF7}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {5FA79592-DE5B-46FF-9E05-34A2E72A7AF7}.Debug|ARM64.Build.0 = Debug|ARM64 {5FA79592-DE5B-46FF-9E05-34A2E72A7AF7}.Debug|x64.ActiveCfg = Debug|x64 {5FA79592-DE5B-46FF-9E05-34A2E72A7AF7}.Debug|x64.Build.0 = Debug|x64 {5FA79592-DE5B-46FF-9E05-34A2E72A7AF7}.Release|Any CPU.ActiveCfg = Release|x64 {5FA79592-DE5B-46FF-9E05-34A2E72A7AF7}.Release|Any CPU.Build.0 = Release|x64 + {5FA79592-DE5B-46FF-9E05-34A2E72A7AF7}.Release|ARM64.ActiveCfg = Release|ARM64 + {5FA79592-DE5B-46FF-9E05-34A2E72A7AF7}.Release|ARM64.Build.0 = Release|ARM64 {5FA79592-DE5B-46FF-9E05-34A2E72A7AF7}.Release|x64.ActiveCfg = Release|x64 {5FA79592-DE5B-46FF-9E05-34A2E72A7AF7}.Release|x64.Build.0 = Release|x64 {09FD3D3A-1EFC-4AEE-B3D7-096D238E0D1A}.Debug|Any CPU.ActiveCfg = Debug|x64 {09FD3D3A-1EFC-4AEE-B3D7-096D238E0D1A}.Debug|Any CPU.Build.0 = Debug|x64 + {09FD3D3A-1EFC-4AEE-B3D7-096D238E0D1A}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {09FD3D3A-1EFC-4AEE-B3D7-096D238E0D1A}.Debug|ARM64.Build.0 = Debug|ARM64 {09FD3D3A-1EFC-4AEE-B3D7-096D238E0D1A}.Debug|x64.ActiveCfg = Debug|x64 {09FD3D3A-1EFC-4AEE-B3D7-096D238E0D1A}.Debug|x64.Build.0 = Debug|x64 {09FD3D3A-1EFC-4AEE-B3D7-096D238E0D1A}.Release|Any CPU.ActiveCfg = Release|x64 {09FD3D3A-1EFC-4AEE-B3D7-096D238E0D1A}.Release|Any CPU.Build.0 = Release|x64 + {09FD3D3A-1EFC-4AEE-B3D7-096D238E0D1A}.Release|ARM64.ActiveCfg = Release|ARM64 + {09FD3D3A-1EFC-4AEE-B3D7-096D238E0D1A}.Release|ARM64.Build.0 = Release|ARM64 {09FD3D3A-1EFC-4AEE-B3D7-096D238E0D1A}.Release|x64.ActiveCfg = Release|x64 {09FD3D3A-1EFC-4AEE-B3D7-096D238E0D1A}.Release|x64.Build.0 = Release|x64 {BDB7A8F3-87A6-4B77-9E0F-6BC785CBCF2B}.Debug|Any CPU.ActiveCfg = Debug|x64 {BDB7A8F3-87A6-4B77-9E0F-6BC785CBCF2B}.Debug|Any CPU.Build.0 = Debug|x64 + {BDB7A8F3-87A6-4B77-9E0F-6BC785CBCF2B}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {BDB7A8F3-87A6-4B77-9E0F-6BC785CBCF2B}.Debug|ARM64.Build.0 = Debug|ARM64 {BDB7A8F3-87A6-4B77-9E0F-6BC785CBCF2B}.Debug|x64.ActiveCfg = Debug|x64 {BDB7A8F3-87A6-4B77-9E0F-6BC785CBCF2B}.Debug|x64.Build.0 = Debug|x64 {BDB7A8F3-87A6-4B77-9E0F-6BC785CBCF2B}.Release|Any CPU.ActiveCfg = Release|x64 {BDB7A8F3-87A6-4B77-9E0F-6BC785CBCF2B}.Release|Any CPU.Build.0 = Release|x64 + {BDB7A8F3-87A6-4B77-9E0F-6BC785CBCF2B}.Release|ARM64.ActiveCfg = Release|ARM64 + {BDB7A8F3-87A6-4B77-9E0F-6BC785CBCF2B}.Release|ARM64.Build.0 = Release|ARM64 {BDB7A8F3-87A6-4B77-9E0F-6BC785CBCF2B}.Release|x64.ActiveCfg = Release|x64 {BDB7A8F3-87A6-4B77-9E0F-6BC785CBCF2B}.Release|x64.Build.0 = Release|x64 {27E0B288-7DFF-468D-9360-035E8CE123CB}.Debug|Any CPU.ActiveCfg = Debug|x64 {27E0B288-7DFF-468D-9360-035E8CE123CB}.Debug|Any CPU.Build.0 = Debug|x64 + {27E0B288-7DFF-468D-9360-035E8CE123CB}.Debug|ARM64.ActiveCfg = Debug|x64 + {27E0B288-7DFF-468D-9360-035E8CE123CB}.Debug|ARM64.Build.0 = Debug|x64 {27E0B288-7DFF-468D-9360-035E8CE123CB}.Debug|x64.ActiveCfg = Debug|x64 {27E0B288-7DFF-468D-9360-035E8CE123CB}.Debug|x64.Build.0 = Debug|x64 {27E0B288-7DFF-468D-9360-035E8CE123CB}.Release|Any CPU.ActiveCfg = Release|x64 {27E0B288-7DFF-468D-9360-035E8CE123CB}.Release|Any CPU.Build.0 = Release|x64 + {27E0B288-7DFF-468D-9360-035E8CE123CB}.Release|ARM64.ActiveCfg = Release|x64 + {27E0B288-7DFF-468D-9360-035E8CE123CB}.Release|ARM64.Build.0 = Release|x64 {27E0B288-7DFF-468D-9360-035E8CE123CB}.Release|x64.ActiveCfg = Release|x64 {27E0B288-7DFF-468D-9360-035E8CE123CB}.Release|x64.Build.0 = Release|x64 {20F43119-EA00-440D-B3B5-44F96592F4C8}.Debug|Any CPU.ActiveCfg = Debug|x64 {20F43119-EA00-440D-B3B5-44F96592F4C8}.Debug|Any CPU.Build.0 = Debug|x64 + {20F43119-EA00-440D-B3B5-44F96592F4C8}.Debug|ARM64.ActiveCfg = Debug|x64 + {20F43119-EA00-440D-B3B5-44F96592F4C8}.Debug|ARM64.Build.0 = Debug|x64 {20F43119-EA00-440D-B3B5-44F96592F4C8}.Debug|x64.ActiveCfg = Debug|x64 {20F43119-EA00-440D-B3B5-44F96592F4C8}.Debug|x64.Build.0 = Debug|x64 {20F43119-EA00-440D-B3B5-44F96592F4C8}.Release|Any CPU.ActiveCfg = Release|x64 {20F43119-EA00-440D-B3B5-44F96592F4C8}.Release|Any CPU.Build.0 = Release|x64 + {20F43119-EA00-440D-B3B5-44F96592F4C8}.Release|ARM64.ActiveCfg = Release|x64 + {20F43119-EA00-440D-B3B5-44F96592F4C8}.Release|ARM64.Build.0 = Release|x64 {20F43119-EA00-440D-B3B5-44F96592F4C8}.Release|x64.ActiveCfg = Release|x64 {20F43119-EA00-440D-B3B5-44F96592F4C8}.Release|x64.Build.0 = Release|x64 {CC400751-216E-4BB2-8103-495B4E273477}.Debug|Any CPU.ActiveCfg = Debug|x64 {CC400751-216E-4BB2-8103-495B4E273477}.Debug|Any CPU.Build.0 = Debug|x64 + {CC400751-216E-4BB2-8103-495B4E273477}.Debug|ARM64.ActiveCfg = Debug|x64 + {CC400751-216E-4BB2-8103-495B4E273477}.Debug|ARM64.Build.0 = Debug|x64 {CC400751-216E-4BB2-8103-495B4E273477}.Debug|x64.ActiveCfg = Debug|x64 {CC400751-216E-4BB2-8103-495B4E273477}.Debug|x64.Build.0 = Debug|x64 {CC400751-216E-4BB2-8103-495B4E273477}.Release|Any CPU.ActiveCfg = Release|x64 {CC400751-216E-4BB2-8103-495B4E273477}.Release|Any CPU.Build.0 = Release|x64 + {CC400751-216E-4BB2-8103-495B4E273477}.Release|ARM64.ActiveCfg = Release|x64 + {CC400751-216E-4BB2-8103-495B4E273477}.Release|ARM64.Build.0 = Release|x64 {CC400751-216E-4BB2-8103-495B4E273477}.Release|x64.ActiveCfg = Release|x64 {CC400751-216E-4BB2-8103-495B4E273477}.Release|x64.Build.0 = Release|x64 + {B4311159-9B5B-4051-94E5-AD63BB27E509}.Debug|Any CPU.ActiveCfg = Debug|x64 + {B4311159-9B5B-4051-94E5-AD63BB27E509}.Debug|Any CPU.Build.0 = Debug|x64 + {B4311159-9B5B-4051-94E5-AD63BB27E509}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {B4311159-9B5B-4051-94E5-AD63BB27E509}.Debug|ARM64.Build.0 = Debug|ARM64 + {B4311159-9B5B-4051-94E5-AD63BB27E509}.Debug|x64.ActiveCfg = Debug|x64 + {B4311159-9B5B-4051-94E5-AD63BB27E509}.Debug|x64.Build.0 = Debug|x64 + {B4311159-9B5B-4051-94E5-AD63BB27E509}.Release|Any CPU.ActiveCfg = Release|x64 + {B4311159-9B5B-4051-94E5-AD63BB27E509}.Release|Any CPU.Build.0 = Release|x64 + {B4311159-9B5B-4051-94E5-AD63BB27E509}.Release|ARM64.ActiveCfg = Release|ARM64 + {B4311159-9B5B-4051-94E5-AD63BB27E509}.Release|ARM64.Build.0 = Release|ARM64 + {B4311159-9B5B-4051-94E5-AD63BB27E509}.Release|x64.ActiveCfg = Release|x64 + {B4311159-9B5B-4051-94E5-AD63BB27E509}.Release|x64.Build.0 = Release|x64 + {A1A53AA4-0F4B-41A0-B1F8-B3C41841A56F}.Debug|Any CPU.ActiveCfg = Debug|x64 + {A1A53AA4-0F4B-41A0-B1F8-B3C41841A56F}.Debug|Any CPU.Build.0 = Debug|x64 + {A1A53AA4-0F4B-41A0-B1F8-B3C41841A56F}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {A1A53AA4-0F4B-41A0-B1F8-B3C41841A56F}.Debug|ARM64.Build.0 = Debug|ARM64 + {A1A53AA4-0F4B-41A0-B1F8-B3C41841A56F}.Debug|x64.ActiveCfg = Debug|x64 + {A1A53AA4-0F4B-41A0-B1F8-B3C41841A56F}.Debug|x64.Build.0 = Debug|x64 + {A1A53AA4-0F4B-41A0-B1F8-B3C41841A56F}.Release|Any CPU.ActiveCfg = Release|x64 + {A1A53AA4-0F4B-41A0-B1F8-B3C41841A56F}.Release|Any CPU.Build.0 = Release|x64 + {A1A53AA4-0F4B-41A0-B1F8-B3C41841A56F}.Release|ARM64.ActiveCfg = Release|ARM64 + {A1A53AA4-0F4B-41A0-B1F8-B3C41841A56F}.Release|ARM64.Build.0 = Release|ARM64 + {A1A53AA4-0F4B-41A0-B1F8-B3C41841A56F}.Release|x64.ActiveCfg = Release|x64 + {A1A53AA4-0F4B-41A0-B1F8-B3C41841A56F}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -379,7 +527,6 @@ Global {C55F4BA7-BBDD-42A4-88C1-FD3C411EB234} = {5B9575EA-B4F9-46E4-A75E-59D430779EC7} {2979E556-5859-4E88-A1D4-EAB72F82294E} = {5B9575EA-B4F9-46E4-A75E-59D430779EC7} {7E098666-DE8C-4ABF-B709-4CE7B1A491B0} = {7940E867-EEBA-4AFD-9904-1536F003239C} - {B5E11AAA-B800-455E-9C64-051FFEFD6C0B} = {7940E867-EEBA-4AFD-9904-1536F003239C} {95168D0B-1B2C-4295-B6D4-D5BAF781B9FA} = {7940E867-EEBA-4AFD-9904-1536F003239C} {D47CC16E-466B-4D58-A8FC-ECAE5C9606FC} = {95168D0B-1B2C-4295-B6D4-D5BAF781B9FA} {1143176D-B7F0-477C-90BB-72289068D927} = {95168D0B-1B2C-4295-B6D4-D5BAF781B9FA} @@ -395,6 +542,8 @@ Global {27E0B288-7DFF-468D-9360-035E8CE123CB} = {7940E867-EEBA-4AFD-9904-1536F003239C} {20F43119-EA00-440D-B3B5-44F96592F4C8} = {7940E867-EEBA-4AFD-9904-1536F003239C} {CC400751-216E-4BB2-8103-495B4E273477} = {8CF74C87-534F-4017-A4ED-F2918025E31A} + {B4311159-9B5B-4051-94E5-AD63BB27E509} = {7940E867-EEBA-4AFD-9904-1536F003239C} + {A1A53AA4-0F4B-41A0-B1F8-B3C41841A56F} = {7940E867-EEBA-4AFD-9904-1536F003239C} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {D044BB14-0B37-47E5-A579-8B30FCBA1F9F} diff --git a/src/UniGetUI/Interface/Dialogs/InstallOptions.xaml.cs b/src/UniGetUI/Interface/Dialogs/InstallOptions.xaml.cs index 96e857941..c940f7101 100644 --- a/src/UniGetUI/Interface/Dialogs/InstallOptions.xaml.cs +++ b/src/UniGetUI/Interface/Dialogs/InstallOptions.xaml.cs @@ -4,6 +4,7 @@ using UniGetUI.Core.Language; using UniGetUI.Core.Tools; using UniGetUI.PackageEngine.Enums; +using UniGetUI.PackageEngine.Interfaces; using UniGetUI.PackageEngine.PackageClasses; // To learn more about WinUI, the WinUI project structure, @@ -16,13 +17,13 @@ namespace UniGetUI.Interface.Dialogs /// public sealed partial class InstallOptionsPage : Page { - public InstallationOptions Options; - public Package Package; + public IInstallationOptions Options; + public IPackage Package; public event EventHandler? Close; - public InstallOptionsPage(Package package, OperationType Operation) : this(package, Operation, InstallationOptions.FromPackage(package)) { } - public InstallOptionsPage(Package package, InstallationOptions options) : this(package, OperationType.None, options) { } - public InstallOptionsPage(Package package, OperationType Operation, InstallationOptions options) + public InstallOptionsPage(IPackage package, OperationType Operation) : this(package, Operation, InstallationOptions.FromPackage(package)) { } + public InstallOptionsPage(IPackage package, IInstallationOptions options) : this(package, OperationType.None, options) { } + public InstallOptionsPage(IPackage package, OperationType Operation, IInstallationOptions options) { Package = package; InitializeComponent(); @@ -113,7 +114,7 @@ private async Task LoadVersions() VersionProgress.Visibility = Visibility.Collapsed; } - public async Task GetUpdatedOptions() + public async Task GetUpdatedOptions() { Options.RunAsAdministrator = AdminCheckBox?.IsChecked ?? false; Options.InteractiveInstallation = InteractiveCheckBox?.IsChecked ?? false; diff --git a/src/UniGetUI/Interface/MainView.xaml.cs b/src/UniGetUI/Interface/MainView.xaml.cs index 096d6e05c..5ddaadaa4 100644 --- a/src/UniGetUI/Interface/MainView.xaml.cs +++ b/src/UniGetUI/Interface/MainView.xaml.cs @@ -10,8 +10,10 @@ using UniGetUI.Interface.Dialogs; using UniGetUI.Interface.Pages; using UniGetUI.Interface.SoftwarePages; +using UniGetUI.Interface.SoftwarePages.UniGetUI.Interface.SoftwarePages; using UniGetUI.Interface.Widgets; using UniGetUI.PackageEngine.Enums; +using UniGetUI.PackageEngine.Interfaces; using UniGetUI.PackageEngine.PackageClasses; using Windows.UI.Core; @@ -27,7 +29,7 @@ public sealed partial class MainView : UserControl public SoftwareUpdatesPage UpdatesPage; public InstalledPackagesPage InstalledPage; public HelpDialog? HelpPage; - public PackageBundlePage BundlesPage; + public NewPackageBundlesPage BundlesPage; public Page? OldPage; public Page? CurrentPage; public InfoBadge UpdatesBadge; @@ -45,7 +47,7 @@ public MainView() UpdatesPage = new SoftwareUpdatesPage(); UpdatesPage.ExternalCountBadge = UpdatesBadge; InstalledPage = new InstalledPackagesPage(); - BundlesPage = new PackageBundlePage(); + BundlesPage = new NewPackageBundlesPage(); SettingsPage = new SettingsInterface(); int i = 0; @@ -335,7 +337,7 @@ public async void WarnAboutAdminRights() await MainApp.Instance.MainWindow.ShowDialogAsync(AdminDialog); } - public async Task ShowInstallationSettingsForPackageAndContinue(Package package, OperationType Operation) + public async Task ShowInstallationSettingsForPackageAndContinue(IPackage package, OperationType Operation) { InstallOptionsPage OptionsPage = new(package, Operation); @@ -368,7 +370,7 @@ public async Task ShowInstallationSettingsForPackageAndContinue(Package pa } - public async Task UpdateInstallationSettings(Package package, InstallationOptions options) + public async Task UpdateInstallationSettings(IPackage package, IInstallationOptions options) { InstallOptionsPage OptionsPage = new(package, options); @@ -413,9 +415,6 @@ private void NavigateToPage(Page TargetPage) OldPage = CurrentPage; CurrentPage = TargetPage; - - (CurrentPage as AbstractPackagesPage)?.FocusPackageList(); - if (CurrentPage == BundlesPage) BundlesPage.PackageList.Focus(FocusState.Programmatic); } private async void ReleaseNotesMenu_Click(object sender, RoutedEventArgs e) @@ -443,7 +442,7 @@ private async void ReleaseNotesMenu_Click(object sender, RoutedEventArgs e) NotesDialog = null; } - public async Task ShowPackageDetails(Package package, OperationType ActionOperation) + public async Task ShowPackageDetails(IPackage package, OperationType ActionOperation) { PackageDetailsPage? DetailsPage = new(package, ActionOperation); @@ -471,7 +470,7 @@ public async Task ShowPackageDetails(Package package, OperationType ActionOperat } - public async Task ConfirmUninstallation(Package package) + public async Task ConfirmUninstallation(IPackage package) { ContentDialog dialog = new(); @@ -486,7 +485,7 @@ public async Task ConfirmUninstallation(Package package) return await MainApp.Instance.MainWindow.ShowDialogAsync(dialog) == ContentDialogResult.Secondary; } - public async Task ConfirmUninstallation(IEnumerable packages) + public async Task ConfirmUninstallation(IEnumerable packages) { if (packages.Count() == 0) return false; if (packages.Count() == 1) diff --git a/src/UniGetUI/Interface/MainWindow.xaml.cs b/src/UniGetUI/Interface/MainWindow.xaml.cs index b659f7acb..4cedf1e6c 100644 --- a/src/UniGetUI/Interface/MainWindow.xaml.cs +++ b/src/UniGetUI/Interface/MainWindow.xaml.cs @@ -14,6 +14,7 @@ using UniGetUI.Core.Tools; using UniGetUI.Interface.Widgets; using UniGetUI.PackageEngine; +using UniGetUI.PackageEngine.Interfaces; using UniGetUI.PackageEngine.PackageClasses; using Windows.ApplicationModel.DataTransfer; using Windows.Foundation.Collections; @@ -396,7 +397,7 @@ public void HideLoadingDialog() LoadingDialogCount = 0; } - public void SharePackage(Package? package) + public void SharePackage(IPackage? package) { if (package == null) return; diff --git a/src/UniGetUI/Interface/Pages/PackageDetailsPage.xaml.cs b/src/UniGetUI/Interface/Pages/PackageDetailsPage.xaml.cs index 36e964b4a..f69667d45 100644 --- a/src/UniGetUI/Interface/Pages/PackageDetailsPage.xaml.cs +++ b/src/UniGetUI/Interface/Pages/PackageDetailsPage.xaml.cs @@ -9,6 +9,7 @@ using UniGetUI.Core.Tools; using UniGetUI.PackageEngine; using UniGetUI.PackageEngine.Enums; +using UniGetUI.PackageEngine.Interfaces; using UniGetUI.PackageEngine.Operations; using UniGetUI.PackageEngine.PackageClasses; using Windows.Storage; @@ -26,7 +27,7 @@ namespace UniGetUI.Interface.Dialogs /// public sealed partial class PackageDetailsPage : Page { - public Package Package; + public IPackage Package; private readonly InstallOptionsPage InstallOptionsPage; public event EventHandler? Close; readonly OperationType OperationRole; @@ -43,7 +44,7 @@ private enum LayoutMode private LayoutMode __layout_mode = LayoutMode.Unloaded; - public PackageDetailsPage(Package package, OperationType operationRole) + public PackageDetailsPage(IPackage package, OperationType operationRole) { OperationRole = operationRole; Package = package; @@ -132,7 +133,7 @@ public async Task LoadInformation() string NotFound = CoreTools.Translate("Not available"); - PackageDetails details = Package.Details; + IPackageDetails details = Package.Details; if (!details.IsPopulated) await details.Load(); string command = ""; diff --git a/src/UniGetUI/Interface/SoftwarePages/AbstractPackagesPage.xaml.cs b/src/UniGetUI/Interface/SoftwarePages/AbstractPackagesPage.xaml.cs index 1abf75bb3..ef0a63f90 100644 --- a/src/UniGetUI/Interface/SoftwarePages/AbstractPackagesPage.xaml.cs +++ b/src/UniGetUI/Interface/SoftwarePages/AbstractPackagesPage.xaml.cs @@ -9,8 +9,9 @@ using UniGetUI.Core.Tools; using UniGetUI.Interface.Pages; using UniGetUI.Interface.Widgets; -using UniGetUI.PackageEngine.Classes.Manager.ManagerHelpers; +using UniGetUI.PackageEngine.Classes.Manager; using UniGetUI.PackageEngine.Enums; +using UniGetUI.PackageEngine.Interfaces; using UniGetUI.PackageEngine.ManagerClasses.Manager; using UniGetUI.PackageEngine.Operations; using UniGetUI.PackageEngine.PackageClasses; @@ -66,17 +67,17 @@ protected enum ReloadReason protected DateTime LastPackageLoadTime { get; private set; } protected readonly OperationType PAGE_ROLE; - protected Package? SelectedItem + protected IPackage? SelectedItem { get => (PackageList.SelectedItem as PackageWrapper)?.Package; } protected AbstractPackageLoader Loader; public ObservablePackageCollection FilteredPackages = new(); - protected List UsedManagers = new(); - protected Dictionary> UsedSourcesForManager = new(); - protected Dictionary RootNodeForManager = new(); - protected Dictionary NodesForSources = new(); + protected List UsedManagers = new(); + protected Dictionary> UsedSourcesForManager = new(); + protected Dictionary RootNodeForManager = new(); + protected Dictionary NodesForSources = new(); private readonly TreeViewNode LocalPackagesNode; public InfoBadge? ExternalCountBadge; @@ -86,7 +87,7 @@ protected Package? SelectedItem protected abstract void WhenPackagesLoaded(ReloadReason reason); protected abstract void WhenPackageCountUpdated(); - protected abstract void WhenShowingContextMenu(Package package); + protected abstract void WhenShowingContextMenu(IPackage package); public abstract void GenerateToolBar(); public abstract BetterMenu GenerateContextMenu(); @@ -348,9 +349,9 @@ public void SelectAllTriggered() else FilteredPackages.ClearSelection(); } - protected void AddPackageToSourcesList(Package package) + protected void AddPackageToSourcesList(IPackage package) { - ManagerSource source = package.Source; + IManagerSource source = package.Source; if (!UsedManagers.Contains(source.Manager)) { UsedManagers.Add(source.Manager); @@ -368,7 +369,7 @@ protected void AddPackageToSourcesList(Package package) RootNodeForManager.Add(source.Manager, Node); - UsedSourcesForManager.Add(source.Manager, new List()); + UsedSourcesForManager.Add(source.Manager, new List()); SourcesPlaceholderText.Visibility = Visibility.Collapsed; SourcesTreeViewGrid.Visibility = Visibility.Visible; } @@ -441,8 +442,8 @@ public void FilterPackages() { FilteredPackages.Clear(); - List VisibleSources = new(); - List VisibleManagers = new(); + List VisibleSources = new(); + List VisibleManagers = new(); if (SourcesTreeView.SelectedNodes.Count > 0) { @@ -455,7 +456,7 @@ public void FilterPackages() } } - IEnumerable MatchingList; + IEnumerable MatchingList; Func CaseFunc; if (UpperLowerCaseCheckbox.IsChecked == true) @@ -589,7 +590,7 @@ protected void ClearSourceSelectionButton_Click(object sender, RoutedEventArgs e FilterPackages(); } - protected async void ShowDetailsForPackage(Package? package) + protected async void ShowDetailsForPackage(IPackage? package) { if (package == null) return; @@ -597,14 +598,14 @@ protected async void ShowDetailsForPackage(Package? package) await MainApp.Instance.MainWindow.NavigationPage.ShowPackageDetails(package, PAGE_ROLE); } - protected void SharePackage(Package? package) + protected void SharePackage(IPackage? package) { if (package == null) return; MainApp.Instance.MainWindow.SharePackage(package); } - protected async void ShowInstallationOptionsForPackage(Package? package) + protected async void ShowInstallationOptionsForPackage(IPackage? package) { if(package == null)return; @@ -624,7 +625,7 @@ private void SidepanelWidth_SizeChanged(object sender, SizeChangedEventArgs e) } } - protected void PerformMainPackageAction(Package? package) + protected void PerformMainPackageAction(IPackage? package) { if(package == null) return; @@ -643,7 +644,7 @@ private void PackageItemContainer_RightTapped(object sender, RightTappedRoutedEv { PackageItemContainer? container = (sender as PackageItemContainer); if (container is null) return; - if (container is null) return; + if (container.Package is null) return; PackageList.Select(container.Wrapper.Index); WhenShowingContextMenu(container.Package); } @@ -658,7 +659,7 @@ private void PackageItemContainer_DoubleTapped(object sender, DoubleTappedRouted private void PackageItemContainer_KeyUp(object sender, KeyRoutedEventArgs e) { - Package? package = (sender as PackageItemContainer)?.Package; + IPackage? package = (sender as PackageItemContainer)?.Package; bool IS_CONTROL_PRESSED = InputKeyboardSource.GetKeyStateForCurrentThread(VirtualKey.Control).HasFlag(CoreVirtualKeyStates.Down); bool IS_SHIFT_PRESSED = InputKeyboardSource.GetKeyStateForCurrentThread(VirtualKey.Shift).HasFlag(CoreVirtualKeyStates.Down); diff --git a/src/UniGetUI/Interface/SoftwarePages/DiscoverSoftwarePage.cs b/src/UniGetUI/Interface/SoftwarePages/DiscoverSoftwarePage.cs index 98b528c1e..32071c857 100644 --- a/src/UniGetUI/Interface/SoftwarePages/DiscoverSoftwarePage.cs +++ b/src/UniGetUI/Interface/SoftwarePages/DiscoverSoftwarePage.cs @@ -5,6 +5,7 @@ using UniGetUI.Interface.Widgets; using UniGetUI.PackageEngine; using UniGetUI.PackageEngine.Enums; +using UniGetUI.PackageEngine.Interfaces; using UniGetUI.PackageEngine.Operations; using UniGetUI.PackageEngine.PackageClasses; using UniGetUI.PackageEngine.PackageLoader; @@ -258,7 +259,7 @@ protected override void WhenPackagesLoaded(ReloadReason reason) } #pragma warning restore - protected override void WhenShowingContextMenu(Package package) + protected override void WhenShowingContextMenu(IPackage package) { if (MenuAsAdmin == null || MenuInteractive == null || MenuSkipHash == null) { @@ -271,10 +272,10 @@ protected override void WhenShowingContextMenu(Package package) MenuSkipHash.IsEnabled = package.Manager.Capabilities.CanSkipIntegrityChecks; } - private async void ExportSelection_Click(object sender, RoutedEventArgs e) + private void ExportSelection_Click(object sender, RoutedEventArgs e) { MainApp.Instance.MainWindow.NavigationPage.BundlesNavButton.ForceClick(); - await MainApp.Instance.MainWindow.NavigationPage.BundlesPage.AddPackages(FilteredPackages.GetCheckedPackages()); + PEInterface.PackageBundlesLoader.AddPackages(FilteredPackages.GetCheckedPackages()); } private void MenuDetails_Invoked(object sender, RoutedEventArgs e) @@ -290,7 +291,7 @@ private void MenuShare_Invoked(object sender, RoutedEventArgs e) private void MenuInstall_Invoked(object sender, RoutedEventArgs e) { - Package? package = SelectedItem; + IPackage? package = SelectedItem; if (package == null) return; MainApp.Instance.AddOperationToList(new InstallPackageOperation(package)); @@ -298,7 +299,7 @@ private void MenuInstall_Invoked(object sender, RoutedEventArgs e) private async void MenuSkipHash_Invoked(object sender, RoutedEventArgs e) { - Package? package = SelectedItem; + IPackage? package = SelectedItem; if (package == null) return; MainApp.Instance.AddOperationToList(new InstallPackageOperation(package, @@ -307,7 +308,7 @@ private async void MenuSkipHash_Invoked(object sender, RoutedEventArgs e) private async void MenuInteractive_Invoked(object sender, RoutedEventArgs e) { - Package? package = SelectedItem; + IPackage? package = SelectedItem; if (package == null) return; MainApp.Instance.AddOperationToList(new InstallPackageOperation(package, @@ -316,7 +317,7 @@ private async void MenuInteractive_Invoked(object sender, RoutedEventArgs e) private async void MenuAsAdmin_Invoked(object sender, RoutedEventArgs e) { - Package? package = SelectedItem; + IPackage? package = SelectedItem; if (package == null) return; MainApp.Instance.AddOperationToList(new InstallPackageOperation(package, diff --git a/src/UniGetUI/Interface/SoftwarePages/InstalledPackagesPage.cs b/src/UniGetUI/Interface/SoftwarePages/InstalledPackagesPage.cs index 74200d5a3..7cc4dc236 100644 --- a/src/UniGetUI/Interface/SoftwarePages/InstalledPackagesPage.cs +++ b/src/UniGetUI/Interface/SoftwarePages/InstalledPackagesPage.cs @@ -8,6 +8,7 @@ using UniGetUI.PackageEngine; using UniGetUI.PackageEngine.Classes; using UniGetUI.PackageEngine.Enums; +using UniGetUI.PackageEngine.Interfaces; using UniGetUI.PackageEngine.Operations; using UniGetUI.PackageEngine.PackageClasses; @@ -254,7 +255,7 @@ protected override void WhenPackagesLoaded(ReloadReason reason) } #pragma warning restore - protected override void WhenShowingContextMenu(Package package) + protected override void WhenShowingContextMenu(IPackage package) { if(MenuAsAdmin == null || MenuInteractive == null || MenuRemoveData == null) { @@ -267,13 +268,13 @@ protected override void WhenShowingContextMenu(Package package) MenuRemoveData.IsEnabled = package.Manager.Capabilities.CanRemoveDataOnUninstall; } - private async void ExportSelection_Click(object sender, RoutedEventArgs e) + private void ExportSelection_Click(object sender, RoutedEventArgs e) { MainApp.Instance.MainWindow.NavigationPage.BundlesNavButton.ForceClick(); - await MainApp.Instance.MainWindow.NavigationPage.BundlesPage.AddPackages(FilteredPackages.GetCheckedPackages()); + PEInterface.PackageBundlesLoader.AddPackages(FilteredPackages.GetCheckedPackages()); } - public async void ConfirmAndUninstall(Package package, InstallationOptions options) + public async void ConfirmAndUninstall(IPackage package, IInstallationOptions options) { if (await MainApp.Instance.MainWindow.NavigationPage.ConfirmUninstallation(package)) { @@ -281,7 +282,7 @@ public async void ConfirmAndUninstall(Package package, InstallationOptions optio } } - public async void ConfirmAndUninstall(IEnumerable packages, bool? elevated = null, bool? interactive = null, bool? remove_data = null) + public async void ConfirmAndUninstall(IEnumerable packages, bool? elevated = null, bool? interactive = null, bool? remove_data = null) { if (await MainApp.Instance.MainWindow.NavigationPage.ConfirmUninstallation(packages)) { @@ -298,8 +299,9 @@ public async Task BackupPackages() try { + // TODO: FIXME Logger.Debug("Starting package backup"); - List packagestoExport = new(); + /*List packagestoExport = new(); foreach (Package package in Loader.Packages) packagestoExport.Add(await BundledPackage.FromPackageAsync(package)); @@ -325,7 +327,7 @@ public async Task BackupPackages() await File.WriteAllTextAsync(filePath, BackupContents); HasDoneBackup = true; Logger.ImportantInfo("Backup saved to " + filePath); - } + */} catch (Exception ex) { Logger.Error("An error occurred while performing a backup"); @@ -335,7 +337,7 @@ public async Task BackupPackages() private async void MenuUninstall_Invoked(object sender, RoutedEventArgs args) { - Package? package = SelectedItem; + IPackage? package = SelectedItem; if (package == null) return; ConfirmAndUninstall(package, await InstallationOptions.FromPackageAsync(package)); @@ -343,14 +345,14 @@ private async void MenuUninstall_Invoked(object sender, RoutedEventArgs args) private async void MenuAsAdmin_Invoked(object sender, RoutedEventArgs args) { - Package? package = SelectedItem; + IPackage? package = SelectedItem; if (package == null) return; ConfirmAndUninstall(package, await InstallationOptions.FromPackageAsync(package, elevated: true)); } private async void MenuInteractive_Invoked(object sender, RoutedEventArgs args) { - Package? package = SelectedItem; + IPackage? package = SelectedItem; if (package == null) return; ConfirmAndUninstall(package, await InstallationOptions.FromPackageAsync(package, interactive: true)); @@ -358,7 +360,7 @@ private async void MenuInteractive_Invoked(object sender, RoutedEventArgs args) private async void MenuRemoveData_Invoked(object sender, RoutedEventArgs args) { - Package? package = SelectedItem; + IPackage? package = SelectedItem; if (package == null) return; ConfirmAndUninstall(package, await InstallationOptions.FromPackageAsync(package, remove_data: true)); @@ -366,7 +368,7 @@ private async void MenuRemoveData_Invoked(object sender, RoutedEventArgs args) private void MenuReinstall_Invoked(object sender, RoutedEventArgs args) { - Package? package = SelectedItem; + IPackage? package = SelectedItem; if (package == null) return; MainApp.Instance.AddOperationToList(new InstallPackageOperation(package)); @@ -374,7 +376,7 @@ private void MenuReinstall_Invoked(object sender, RoutedEventArgs args) private void MenuUninstallThenReinstall_Invoked(object sender, RoutedEventArgs args) { - Package? package = SelectedItem; + IPackage? package = SelectedItem; if (package == null) return; MainApp.Instance.AddOperationToList(new UninstallPackageOperation(package, IgnoreParallelInstalls: true)); @@ -383,7 +385,7 @@ private void MenuUninstallThenReinstall_Invoked(object sender, RoutedEventArgs a } private void MenuIgnorePackage_Invoked(object sender, RoutedEventArgs args) { - Package? package = SelectedItem; + IPackage? package = SelectedItem; if (package == null) return; _ = package.AddToIgnoredUpdatesAsync(); @@ -403,7 +405,7 @@ private void MenuDetails_Invoked(object sender, RoutedEventArgs args) private async void MenuInstallSettings_Invoked(object sender, RoutedEventArgs e) { - Package? package = SelectedItem; + IPackage? package = SelectedItem; if (package != null && await MainApp.Instance.MainWindow.NavigationPage.ShowInstallationSettingsForPackageAndContinue(package, OperationType.Uninstall)) { diff --git a/src/UniGetUI/Interface/SoftwarePages/NewPackageBundlesPage.cs b/src/UniGetUI/Interface/SoftwarePages/NewPackageBundlesPage.cs new file mode 100644 index 000000000..44fcb0eaf --- /dev/null +++ b/src/UniGetUI/Interface/SoftwarePages/NewPackageBundlesPage.cs @@ -0,0 +1,426 @@ +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection.Emit; +using System.Text; +using System.Threading.Tasks; +using UniGetUI.Core.Data; +using UniGetUI.Core.Logging; +using UniGetUI.Core.SettingsEngine; +using UniGetUI.Core.Tools; +using UniGetUI.Interface.Widgets; +using UniGetUI.PackageEngine; +using UniGetUI.PackageEngine.Enums; +using UniGetUI.PackageEngine.Interfaces; +using UniGetUI.PackageEngine.Operations; +using UniGetUI.PackageEngine.PackageClasses; + +namespace UniGetUI.Interface.SoftwarePages +{ + namespace UniGetUI.Interface.SoftwarePages + { + public class NewPackageBundlesPage : AbstractPackagesPage + { + bool HasDoneBackup = false; + + BetterMenuItem? MenuAsAdmin; + BetterMenuItem? MenuInteractive; + BetterMenuItem? MenuRemoveData; + + public NewPackageBundlesPage() + : base(new PackagesPageData() + { + DisableAutomaticPackageLoadOnStart = false, + MegaQueryBlockEnabled = false, + ShowLastLoadTime = false, + PackagesAreCheckedByDefault = false, + DisableSuggestedResultsRadio = true, + PageName = "Installed", + + Loader = PEInterface.InstalledPackagesLoader, + PageRole = OperationType.Uninstall, + + NoPackages_BackgroundText = CoreTools.Translate("No results were found matching the input criteria"), + NoPackages_SourcesText = CoreTools.Translate("No packages were found"), + NoPackages_SubtitleText_Base = CoreTools.Translate("No packages were found"), + MainSubtitle_StillLoading = CoreTools.Translate("Loading packages"), + NoMatches_BackgroundText = CoreTools.Translate("No results were found matching the input criteria"), + + PageTitle = CoreTools.Translate("Installed Packages"), + Glyph = "\uE977" + }) + { + } + + public override BetterMenu GenerateContextMenu() + { + BetterMenu menu = new(); + BetterMenuItem menuUninstall = new() + { + Text = "Uninstall", + IconName = "trash", + KeyboardAcceleratorTextOverride = "Ctrl+Enter" + }; + menuUninstall.Click += MenuUninstall_Invoked; + menu.Items.Add(menuUninstall); + + menu.Items.Add(new MenuFlyoutSeparator { Height = 5 }); + + BetterMenuItem menuInstallSettings = new() + { + Text = "Installation options", + IconName = "options", + KeyboardAcceleratorTextOverride = "Alt+Enter" + }; + menuInstallSettings.Click += MenuInstallSettings_Invoked; + menu.Items.Add(menuInstallSettings); + + menu.Items.Add(new MenuFlyoutSeparator()); + + MenuAsAdmin = new BetterMenuItem + { + Text = "Uninstall as administrator", + IconName = "runasadmin" + }; + MenuAsAdmin.Click += MenuAsAdmin_Invoked; + menu.Items.Add(MenuAsAdmin); + + MenuInteractive = new BetterMenuItem + { + Text = "Interactive uninstall", + IconName = "interactive" + }; + MenuInteractive.Click += MenuInteractive_Invoked; + menu.Items.Add(MenuInteractive); + + MenuRemoveData = new BetterMenuItem + { + Text = "Uninstall and remove data", + IconName = "menu_close" + }; + MenuRemoveData.Click += MenuRemoveData_Invoked; + menu.Items.Add(MenuRemoveData); + + menu.Items.Add(new MenuFlyoutSeparator()); + + BetterMenuItem menuReinstall = new() + { + Text = "Reinstall package", + IconName = "newversion" + }; + menuReinstall.Click += MenuReinstall_Invoked; + menu.Items.Add(menuReinstall); + + BetterMenuItem menuUninstallThenReinstall = new() + { + Text = "Uninstall package, then reinstall it", + IconName = "undelete" + }; + menuUninstallThenReinstall.Click += MenuUninstallThenReinstall_Invoked; + menu.Items.Add(menuUninstallThenReinstall); + + menu.Items.Add(new MenuFlyoutSeparator()); + + BetterMenuItem menuIgnorePackage = new() + { + Text = "Ignore updates for this package", + IconName = "pin" + }; + menuIgnorePackage.Click += MenuIgnorePackage_Invoked; + menu.Items.Add(menuIgnorePackage); + + menu.Items.Add(new MenuFlyoutSeparator()); + + BetterMenuItem menuShare = new() + { + Text = "Share this package", + IconName = "share" + }; + menuShare.Click += MenuShare_Invoked; + menu.Items.Add(menuShare); + + BetterMenuItem menuDetails = new() + { + Text = "Package details", + IconName = "info", + KeyboardAcceleratorTextOverride = "Enter" + }; + menuDetails.Click += MenuDetails_Invoked; + menu.Items.Add(menuDetails); + + return menu; + } + + public override void GenerateToolBar() + { + AppBarButton UninstallSelected = new(); + AppBarButton UninstallAsAdmin = new(); + AppBarButton UninstallInteractive = new(); + AppBarButton InstallationSettings = new(); + + AppBarButton PackageDetails = new(); + AppBarButton SharePackage = new(); + + AppBarButton IgnoreSelected = new(); + AppBarButton ManageIgnored = new(); + AppBarButton ExportSelection = new(); + + AppBarButton HelpButton = new(); + + ToolBar.PrimaryCommands.Add(UninstallSelected); + ToolBar.PrimaryCommands.Add(UninstallAsAdmin); + ToolBar.PrimaryCommands.Add(UninstallInteractive); + ToolBar.PrimaryCommands.Add(new AppBarSeparator()); + ToolBar.PrimaryCommands.Add(InstallationSettings); + ToolBar.PrimaryCommands.Add(new AppBarSeparator()); + ToolBar.PrimaryCommands.Add(PackageDetails); + ToolBar.PrimaryCommands.Add(SharePackage); + ToolBar.PrimaryCommands.Add(new AppBarSeparator()); + ToolBar.PrimaryCommands.Add(IgnoreSelected); + ToolBar.PrimaryCommands.Add(ManageIgnored); + ToolBar.PrimaryCommands.Add(new AppBarSeparator()); + ToolBar.PrimaryCommands.Add(ExportSelection); + ToolBar.PrimaryCommands.Add(new AppBarSeparator()); + ToolBar.PrimaryCommands.Add(HelpButton); + + Dictionary Labels = new() + { // Entries with a trailing space are collapsed + // Their texts will be used as the tooltip + { UninstallSelected, CoreTools.Translate("Uninstall selected packages") }, + { UninstallAsAdmin, " " + CoreTools.Translate("Uninstall as administrator") }, + { UninstallInteractive, " " + CoreTools.Translate("Interactive uninstall") }, + { InstallationSettings, " " + CoreTools.Translate("Installation options") }, + { PackageDetails, " " + CoreTools.Translate("Package details") }, + { SharePackage, " " + CoreTools.Translate("Share") }, + { IgnoreSelected, CoreTools.Translate("Ignore selected packages") }, + { ManageIgnored, CoreTools.Translate("Manage ignored updates") }, + { ExportSelection, CoreTools.Translate("Add selection to bundle") }, + { HelpButton, CoreTools.Translate("Help") } + }; + + foreach (AppBarButton toolButton in Labels.Keys) + { + toolButton.IsCompact = Labels[toolButton][0] == ' '; + if (toolButton.IsCompact) + toolButton.LabelPosition = CommandBarLabelPosition.Collapsed; + toolButton.Label = Labels[toolButton].Trim(); + } + + Dictionary Icons = new() + { + { UninstallSelected, "trash" }, + { UninstallAsAdmin, "runasadmin" }, + { UninstallInteractive, "interactive" }, + { InstallationSettings, "options" }, + { PackageDetails, "info" }, + { SharePackage, "share" }, + { IgnoreSelected, "pin" }, + { ManageIgnored, "clipboard_list" }, + { ExportSelection, "add_to" }, + { HelpButton, "help" } + }; + + foreach (AppBarButton toolButton in Icons.Keys) + toolButton.Icon = new LocalIcon(Icons[toolButton]); + + PackageDetails.Click += (s, e) => ShowDetailsForPackage(SelectedItem); + + ExportSelection.Click += ExportSelection_Click; + HelpButton.Click += (s, e) => MainApp.Instance.MainWindow.NavigationPage.ShowHelp(); + InstallationSettings.Click += (s, e) => ShowInstallationOptionsForPackage(SelectedItem); + ManageIgnored.Click += async (s, e) => await MainApp.Instance.MainWindow.NavigationPage.ManageIgnoredUpdatesDialog(); + IgnoreSelected.Click += async (s, e) => + { + foreach (Package package in FilteredPackages.GetCheckedPackages()) + { + PEInterface.UpgradablePackagesLoader.Remove(package); + await package.AddToIgnoredUpdatesAsync(); + } + }; + + UninstallSelected.Click += (s, e) => ConfirmAndUninstall(FilteredPackages.GetCheckedPackages()); + UninstallAsAdmin.Click += (s, e) => ConfirmAndUninstall(FilteredPackages.GetCheckedPackages(), elevated: true); + UninstallInteractive.Click += (s, e) => ConfirmAndUninstall(FilteredPackages.GetCheckedPackages(), interactive: true); + SharePackage.Click += (s, e) => MainApp.Instance.MainWindow.SharePackage(SelectedItem); + } + + protected override void WhenPackageCountUpdated() + { + return; + } + +#pragma warning disable + protected override void WhenPackagesLoaded(ReloadReason reason) + { + if (!HasDoneBackup) + { + if (Settings.Get("EnablePackageBackup")) + _ = BackupPackages(); + } + } +#pragma warning restore + + protected override void WhenShowingContextMenu(IPackage package) + { + if (MenuAsAdmin == null || MenuInteractive == null || MenuRemoveData == null) + { + Logger.Error("Menu items are null on InstalledPackagesTab"); + return; + } + + MenuAsAdmin.IsEnabled = package.Manager.Capabilities.CanRunAsAdmin; + MenuInteractive.IsEnabled = package.Manager.Capabilities.CanRunInteractively; + MenuRemoveData.IsEnabled = package.Manager.Capabilities.CanRemoveDataOnUninstall; + } + + private void ExportSelection_Click(object sender, RoutedEventArgs e) + { + MainApp.Instance.MainWindow.NavigationPage.BundlesNavButton.ForceClick(); + PEInterface.PackageBundlesLoader.AddPackages(FilteredPackages.GetCheckedPackages()); + } + + public async void ConfirmAndUninstall(IPackage package, IInstallationOptions options) + { + if (await MainApp.Instance.MainWindow.NavigationPage.ConfirmUninstallation(package)) + { + MainApp.Instance.AddOperationToList(new UninstallPackageOperation(package, options)); + } + } + + public async void ConfirmAndUninstall(IEnumerable packages, bool? elevated = null, bool? interactive = null, bool? remove_data = null) + { + if (await MainApp.Instance.MainWindow.NavigationPage.ConfirmUninstallation(packages)) + { + foreach (Package package in packages) + { + MainApp.Instance.AddOperationToList(new UninstallPackageOperation(package, + await InstallationOptions.FromPackageAsync(package, elevated, interactive, remove_data: remove_data))); + } + } + } + + public async Task BackupPackages() + { + + try + { + // TODO: FIXME + + Logger.Debug("Starting package backup"); + /*List packagestoExport = new(); + foreach (Package package in Loader.Packages) + packagestoExport.Add(await BundledPackage.FromPackageAsync(package)); + + string BackupContents = await PackageBundlePage.GetBundleStringFromPackages(packagestoExport.ToArray(), BundleFormatType.JSON); + + string dirName = Settings.GetValue("ChangeBackupOutputDirectory"); + if (dirName == "") + dirName = CoreData.UniGetUI_DefaultBackupDirectory; + + if (!Directory.Exists(dirName)) + Directory.CreateDirectory(dirName); + + string fileName = Settings.GetValue("ChangeBackupFileName"); + if (fileName == "") + fileName = CoreTools.Translate("{pcName} installed packages", new Dictionary { { "pcName", Environment.MachineName } }); + + if (Settings.Get("EnableBackupTimestamping")) + fileName += " " + DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss"); + + fileName += ".json"; + + string filePath = Path.Combine(dirName, fileName); + await File.WriteAllTextAsync(filePath, BackupContents); + HasDoneBackup = true; + Logger.ImportantInfo("Backup saved to " + filePath); + */ + } + catch (Exception ex) + { + Logger.Error("An error occurred while performing a backup"); + Logger.Error(ex); + } + } + + private async void MenuUninstall_Invoked(object sender, RoutedEventArgs args) + { + IPackage? package = SelectedItem; + if (package == null) return; + + ConfirmAndUninstall(package, await InstallationOptions.FromPackageAsync(package)); + } + + private async void MenuAsAdmin_Invoked(object sender, RoutedEventArgs args) + { + IPackage? package = SelectedItem; + if (package == null) return; + ConfirmAndUninstall(package, await InstallationOptions.FromPackageAsync(package, elevated: true)); + } + + private async void MenuInteractive_Invoked(object sender, RoutedEventArgs args) + { + IPackage? package = SelectedItem; + if (package == null) return; + + ConfirmAndUninstall(package, await InstallationOptions.FromPackageAsync(package, interactive: true)); + } + + private async void MenuRemoveData_Invoked(object sender, RoutedEventArgs args) + { + IPackage? package = SelectedItem; + if (package == null) return; + + ConfirmAndUninstall(package, await InstallationOptions.FromPackageAsync(package, remove_data: true)); + } + + private void MenuReinstall_Invoked(object sender, RoutedEventArgs args) + { + IPackage? package = SelectedItem; + if (package == null) return; + + MainApp.Instance.AddOperationToList(new InstallPackageOperation(package)); + } + + private void MenuUninstallThenReinstall_Invoked(object sender, RoutedEventArgs args) + { + IPackage? package = SelectedItem; + if (package == null) return; + + MainApp.Instance.AddOperationToList(new UninstallPackageOperation(package, IgnoreParallelInstalls: true)); + MainApp.Instance.AddOperationToList(new InstallPackageOperation(package, IgnoreParallelInstalls: true)); + + } + private void MenuIgnorePackage_Invoked(object sender, RoutedEventArgs args) + { + IPackage? package = SelectedItem; + if (package == null) return; + + _ = package.AddToIgnoredUpdatesAsync(); + PEInterface.UpgradablePackagesLoader.Remove(package); + } + + private void MenuShare_Invoked(object sender, RoutedEventArgs args) + { + if (PackageList.SelectedItem == null) return; + MainApp.Instance.MainWindow.SharePackage(SelectedItem); + } + + private void MenuDetails_Invoked(object sender, RoutedEventArgs args) + { + ShowDetailsForPackage(SelectedItem); + } + + private async void MenuInstallSettings_Invoked(object sender, RoutedEventArgs e) + { + IPackage? package = SelectedItem; + if (package != null && + await MainApp.Instance.MainWindow.NavigationPage.ShowInstallationSettingsForPackageAndContinue(package, OperationType.Uninstall)) + { + ConfirmAndUninstall(package, await InstallationOptions.FromPackageAsync(package)); + } + } + } + } +} diff --git a/src/UniGetUI/Interface/SoftwarePages/PackageBundle.xaml b/src/UniGetUI/Interface/SoftwarePages/PackageBundle.xaml index b4fc80215..6a3b2b95a 100644 --- a/src/UniGetUI/Interface/SoftwarePages/PackageBundle.xaml +++ b/src/UniGetUI/Interface/SoftwarePages/PackageBundle.xaml @@ -819,7 +819,6 @@ diff --git a/src/UniGetUI/Interface/SoftwarePages/PackageBundle.xaml.cs b/src/UniGetUI/Interface/SoftwarePages/PackageBundle.xaml.cs index 511620fc5..7ecc03ad9 100644 --- a/src/UniGetUI/Interface/SoftwarePages/PackageBundle.xaml.cs +++ b/src/UniGetUI/Interface/SoftwarePages/PackageBundle.xaml.cs @@ -16,8 +16,10 @@ using UniGetUI.Interface.Widgets; using UniGetUI.PackageEngine; using UniGetUI.PackageEngine.Classes; -using UniGetUI.PackageEngine.Classes.Manager.ManagerHelpers; +using UniGetUI.PackageEngine.Classes.Manager; +using UniGetUI.PackageEngine.Classes.Serializable; using UniGetUI.PackageEngine.Enums; +using UniGetUI.PackageEngine.Interfaces; using UniGetUI.PackageEngine.ManagerClasses.Manager; using UniGetUI.PackageEngine.Operations; using UniGetUI.PackageEngine.PackageClasses; @@ -28,7 +30,7 @@ namespace UniGetUI.Interface { - public partial class PackageBundlePage : Page, IPageWithKeyboardShortcuts + /*public partial class PackageBundlePage : Page, IPageWithKeyboardShortcuts { public ObservableCollection Packages = new(); public SortableObservableCollection FilteredPackages = new() { SortingSelector = (a) => (a.Package.Name) }; @@ -179,11 +181,11 @@ public void SelectAllTriggered() } - protected void AddPackageToSourcesList(Package package) + protected void AddPackageToSourcesList(IPackage package) { if (!Initialized) return; - ManagerSource source = package.Source; + /*ManagerSource source = package.Source; if (!UsedManagers.Contains(source.Manager)) { UsedManagers.Add(source.Manager); @@ -241,7 +243,7 @@ private void SourcesTreeView_SelectionChanged(TreeView sender, TreeViewSelection * DO NOT MODIFY THE UPPER PART OF THIS FILE * * - */ + public void ClearList() { @@ -720,7 +722,7 @@ public async Task AddPackagesFromBundleString(string content, BundleFormatType f ManagerSourceReference.Add(manager.Name, manager); } - foreach (SerializableValidPackage_v1 DeserializedPackage in DeserializedData.packages) + foreach (SerializablePackage_v1 DeserializedPackage in DeserializedData.packages) { // Check if the manager exists if (!ManagerSourceReference.ContainsKey(DeserializedPackage.ManagerName)) @@ -743,7 +745,7 @@ public async Task AddPackagesFromBundleString(string content, BundleFormatType f continue; } - ManagerSource? Source = PackageManager.Properties.DefaultSource; + IManagerSource? Source = PackageManager.Properties.DefaultSource; if (PackageManager.Capabilities.SupportsCustomSources) { @@ -758,7 +760,7 @@ public async Task AddPackagesFromBundleString(string content, BundleFormatType f } } - Package package = new(DeserializedPackage.Name, DeserializedPackage.Id, DeserializedPackage.Version, Source, PackageManager); + IPackage? package = new(DeserializedPackage.Name, DeserializedPackage.Id, DeserializedPackage.Version, Source, PackageManager); InstallationOptions InstallOptions = InstallationOptions.FromSerialized(DeserializedPackage.InstallationOptions, package); SerializableUpdatesOptions_v1 UpdateOptions = DeserializedPackage.Updates; @@ -864,5 +866,5 @@ private void SidepanelWidth_SizeChanged(object sender, SizeChangedEventArgs e) } - } + }*/ } diff --git a/src/UniGetUI/Interface/SoftwarePages/SoftwareUpdatesPage.cs b/src/UniGetUI/Interface/SoftwarePages/SoftwareUpdatesPage.cs index 2948739f3..177621973 100644 --- a/src/UniGetUI/Interface/SoftwarePages/SoftwareUpdatesPage.cs +++ b/src/UniGetUI/Interface/SoftwarePages/SoftwareUpdatesPage.cs @@ -9,6 +9,7 @@ using UniGetUI.Interface.Widgets; using UniGetUI.PackageEngine; using UniGetUI.PackageEngine.Enums; +using UniGetUI.PackageEngine.Interfaces; using UniGetUI.PackageEngine.Operations; using UniGetUI.PackageEngine.PackageClasses; @@ -152,7 +153,7 @@ public override BetterMenu GenerateContextMenu() return ContextMenu; } - protected override void WhenShowingContextMenu(Package package) + protected override void WhenShowingContextMenu(IPackage package) { if(MenuAsAdmin == null || MenuInteractive == null || MenuskipHash == null) { @@ -399,7 +400,7 @@ protected override void WhenPackagesLoaded(ReloadReason reason) private void MenuInstall_Invoked(object sender, RoutedEventArgs e) { - Package? package = SelectedItem; + IPackage? package = SelectedItem; if (package == null) return; MainApp.Instance.AddOperationToList(new UpdatePackageOperation(package)); @@ -407,7 +408,7 @@ private void MenuInstall_Invoked(object sender, RoutedEventArgs e) private async void MenuSkipHash_Invoked(object sender, RoutedEventArgs e) { - Package? package = SelectedItem; + IPackage? package = SelectedItem; if (package == null) return; MainApp.Instance.AddOperationToList(new UpdatePackageOperation(package, @@ -416,7 +417,7 @@ private async void MenuSkipHash_Invoked(object sender, RoutedEventArgs e) private async void MenuInteractive_Invoked(object sender, RoutedEventArgs e) { - Package? package = SelectedItem; + IPackage? package = SelectedItem; if (package == null) return; MainApp.Instance.AddOperationToList(new UpdatePackageOperation(package, @@ -425,7 +426,7 @@ private async void MenuInteractive_Invoked(object sender, RoutedEventArgs e) private async void MenuAsAdmin_Invoked(object sender, RoutedEventArgs e) { - Package? package = SelectedItem; + IPackage? package = SelectedItem; if (package == null) return; MainApp.Instance.AddOperationToList(new UpdatePackageOperation(package, @@ -434,7 +435,7 @@ private async void MenuAsAdmin_Invoked(object sender, RoutedEventArgs e) private void MenuUpdateAfterUninstall_Invoked(object sender, RoutedEventArgs e) { - Package? package = SelectedItem; + IPackage? package = SelectedItem; if (package == null) return; MainApp.Instance.AddOperationToList(new UninstallPackageOperation(package, IgnoreParallelInstalls: true)); @@ -443,7 +444,7 @@ private void MenuUpdateAfterUninstall_Invoked(object sender, RoutedEventArgs e) private void MenuUninstall_Invoked(object sender, RoutedEventArgs e) { - Package? package = SelectedItem; + IPackage? package = SelectedItem; if (package == null) return; MainApp.Instance.AddOperationToList(new UninstallPackageOperation(package)); @@ -451,7 +452,7 @@ private void MenuUninstall_Invoked(object sender, RoutedEventArgs e) private void MenuIgnorePackage_Invoked(object sender, RoutedEventArgs e) { - Package? package = SelectedItem; + IPackage? package = SelectedItem; if (package == null) return; _ = package.AddToIgnoredUpdatesAsync(); @@ -460,7 +461,7 @@ private void MenuIgnorePackage_Invoked(object sender, RoutedEventArgs e) private void MenuSkipVersion_Invoked(object sender, RoutedEventArgs e) { - Package? package = SelectedItem; + IPackage? package = SelectedItem; if (package == null) return; _ = package.AddToIgnoredUpdatesAsync((package).NewVersion); diff --git a/src/UniGetUI/Interface/Widgets/MenuForPackage.cs b/src/UniGetUI/Interface/Widgets/MenuForPackage.cs index d62963b01..8eb9aae6d 100644 --- a/src/UniGetUI/Interface/Widgets/MenuForPackage.cs +++ b/src/UniGetUI/Interface/Widgets/MenuForPackage.cs @@ -1,6 +1,7 @@ using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; using UniGetUI.Core.Tools; +using UniGetUI.PackageEngine.Interfaces; using UniGetUI.PackageEngine.PackageClasses; namespace UniGetUI.Interface.Widgets @@ -60,8 +61,13 @@ public BetterMenuItem() : base() public class MenuForPackage : MenuFlyout { - public event EventHandler? AboutToShow; + public event EventHandler? AboutToShow; readonly DependencyProperty PackageProperty; + public IPackage? Package + { + get => (Package)GetValue(PackageProperty); + set => SetValue(PackageProperty, value); + } public MenuForPackage() : base() { @@ -75,19 +81,14 @@ public MenuForPackage() : base() Opening += (s, e) => { AboutToShow?.Invoke(this, Package); }; } - public Package Package - { - get => (Package)GetValue(PackageProperty); - set => SetValue(PackageProperty, value); - } } public class MenuItemForPackage : MenuFlyoutItem { - public event EventHandler? Invoked; + public event EventHandler? Invoked; readonly DependencyProperty PackageProperty; - public Package Package + public IPackage? Package { get => (Package)GetValue(PackageProperty); set => SetValue(PackageProperty, value); diff --git a/src/UniGetUI/Interface/Widgets/PackageItemContainer.cs b/src/UniGetUI/Interface/Widgets/PackageItemContainer.cs index e6bd28e75..75bddf1ee 100644 --- a/src/UniGetUI/Interface/Widgets/PackageItemContainer.cs +++ b/src/UniGetUI/Interface/Widgets/PackageItemContainer.cs @@ -1,4 +1,5 @@ using Microsoft.UI.Xaml.Controls; +using UniGetUI.PackageEngine.Interfaces; using UniGetUI.PackageEngine.PackageClasses; namespace UniGetUI.Interface.Widgets @@ -6,7 +7,7 @@ namespace UniGetUI.Interface.Widgets public class PackageItemContainer : ItemContainer { #pragma warning disable CS8618 - public Package Package { get; set; } + public IPackage? Package { get; set; } public PackageWrapper Wrapper { get; set; } } #pragma warning restore CS8618 diff --git a/src/UniGetUI/Interface/Widgets/SourceManager.xaml.cs b/src/UniGetUI/Interface/Widgets/SourceManager.xaml.cs index af242538c..d0283f4eb 100644 --- a/src/UniGetUI/Interface/Widgets/SourceManager.xaml.cs +++ b/src/UniGetUI/Interface/Widgets/SourceManager.xaml.cs @@ -3,7 +3,8 @@ using System.Collections.ObjectModel; using UniGetUI.Core.Logging; using UniGetUI.Core.Tools; -using UniGetUI.PackageEngine.Classes.Manager.ManagerHelpers; +using UniGetUI.PackageEngine.Classes.Manager; +using UniGetUI.PackageEngine.Interfaces; using UniGetUI.PackageEngine.ManagerClasses.Manager; using UniGetUI.PackageEngine.Operations; @@ -15,9 +16,9 @@ namespace UniGetUI.Interface.Widgets public class SourceItem { public SourceManager Parent; - public ManagerSource Source; + public IManagerSource Source; - public SourceItem(SourceManager Parent, ManagerSource Source) + public SourceItem(SourceManager Parent, IManagerSource Source) { this.Parent = Parent; this.Source = Source; @@ -31,11 +32,11 @@ public void Remove(object sender, RoutedEventArgs e) } public sealed partial class SourceManager : UserControl { - private PackageManager Manager { get; set; } + private IPackageManager Manager { get; set; } private ObservableCollection Sources = new(); private ListView _datagrid { get; set; } - public SourceManager(PackageManager Manager) + public SourceManager(IPackageManager Manager) { this.Manager = Manager; InitializeComponent(); @@ -54,8 +55,8 @@ public SourceManager(PackageManager Manager) d.Title = CoreTools.Translate("Add source"); ComboBox SourcesCombo = new(); - Dictionary NameSourceRef = new(); - foreach (ManagerSource source in Manager.Properties.KnownSources) + Dictionary NameSourceRef = new(); + foreach (IManagerSource source in Manager.Properties.KnownSources) { SourcesCombo.Items.Add(source.Name); NameSourceRef.Add(source.Name, source); @@ -152,9 +153,9 @@ public async void LoadSources() LoadingBar.Visibility = Visibility.Visible; Sources.Clear(); - foreach (ManagerSource Source in await Manager.GetSources()) + foreach (IManagerSource source in await Manager.GetSources()) { - Sources.Add(new SourceItem(this, Source)); + Sources.Add(new SourceItem(this, source)); } if (Sources.Count > 0) _datagrid.SelectedIndex = 0; diff --git a/src/UniGetUI/PackageEngine/Classes/ImportExport.cs b/src/UniGetUI/PackageEngine/Classes/ImportExport.cs index d6847c49e..d685f47b5 100644 --- a/src/UniGetUI/PackageEngine/Classes/ImportExport.cs +++ b/src/UniGetUI/PackageEngine/Classes/ImportExport.cs @@ -3,67 +3,21 @@ using System.Runtime.CompilerServices; using UniGetUI.Core.Classes; using UniGetUI.Core.Tools; -using UniGetUI.PackageEngine.Classes.Manager.ManagerHelpers; +using UniGetUI.PackageEngine.Classes.Manager; +using UniGetUI.PackageEngine.Classes.Serializable; +using UniGetUI.PackageEngine.Interfaces; using UniGetUI.PackageEngine.ManagerClasses.Manager; using UniGetUI.PackageEngine.PackageClasses; using UniGetUI.PackageEngine.Serializable; namespace UniGetUI.PackageEngine.Classes { - - public class SerializableBundle_v1 - { - public double export_version { get; set; } = 2.0; - public List packages { get; set; } = new(); - public string incompatible_packages_info { get; set; } = "Incompatible packages cannot be installed from WingetUI, but they have been listed here for logging purposes."; - public List incompatible_packages { get; set; } = new(); - - } - - public class SerializableUpdatesOptions_v1 - { - public bool UpdatesIgnored { get; set; } = false; - public string IgnoredVersion { get; set; } = ""; - public static async Task FromPackageAsync(Package package) - { - SerializableUpdatesOptions_v1 Serializable = new(); - Serializable.UpdatesIgnored = await package.HasUpdatesIgnoredAsync(); - Serializable.IgnoredVersion = await package.GetIgnoredUpdatesVersionAsync(); - return Serializable; - } - } - - public class SerializableValidPackage_v1 - { - public string Id { get; set; } = ""; - public string Name { get; set; } = ""; - public string Version { get; set; } = ""; - public string Source { get; set; } = ""; - public string ManagerName { get; set; } = ""; - public SerializableInstallationOptions_v1 InstallationOptions { get; set; } = new(); - public SerializableUpdatesOptions_v1 Updates { get; set; } = new(); - } - - - - public class SerializableIncompatiblePackage_v1 - { - public string Id { get; set; } = ""; - public string Name { get; set; } = ""; - public string Version { get; set; } = ""; - public string Source { get; set; } = ""; - } - - - - - public class BundledPackage : INotifyPropertyChanged, IIndexableListItem { - public Package Package { get; } + public IPackage Package { get; } public int Index { get; set; } public bool IsValid { get; set; } = true; - public InstallationOptions InstallOptions { get; set; } + public IInstallationOptions InstallOptions { get; set; } public SerializableUpdatesOptions_v1 UpdateOptions; public double DrawOpacity = 1; @@ -116,15 +70,18 @@ public virtual string IconId return Package.Source.IconId; } } - public static async Task FromPackageAsync(Package package) + public static async Task FromPackageAsync(IPackage package) { InstallationOptions iOptions = await InstallationOptions.FromPackageAsync(package); - SerializableUpdatesOptions_v1 uOptions = await SerializableUpdatesOptions_v1.FromPackageAsync(package); + SerializableUpdatesOptions_v1 uOptions = new(); + + uOptions.UpdatesIgnored = await package.HasUpdatesIgnoredAsync(); + uOptions.IgnoredVersion = await package.GetIgnoredUpdatesVersionAsync(); return new BundledPackage(package, iOptions, uOptions); } - public BundledPackage(Package package, InstallationOptions options, SerializableUpdatesOptions_v1 updateOptions) + public BundledPackage(IPackage package, IInstallationOptions options, SerializableUpdatesOptions_v1 updateOptions) { Package = package; InstallOptions = options; @@ -139,9 +96,11 @@ public async virtual void ShowOptions(object sender, RoutedEventArgs e) public void RemoveFromList(object sender, RoutedEventArgs e) { - MainApp.Instance.MainWindow.NavigationPage.BundlesPage.Packages.Remove(this); + //TODO: FIXME + /*MainApp.Instance.MainWindow.NavigationPage.BundlesPage.Packages.Remove(this); MainApp.Instance.MainWindow.NavigationPage.BundlesPage.FilteredPackages.Remove(this); MainApp.Instance.MainWindow.NavigationPage.BundlesPage.UpdateCount(); + */ } protected void OnPropertyChanged([CallerMemberName] string? name = null) @@ -151,9 +110,9 @@ protected void OnPropertyChanged([CallerMemberName] string? name = null) - public virtual SerializableValidPackage_v1 AsSerializable() + public virtual SerializablePackage_v1 AsSerializable() { - SerializableValidPackage_v1 Serializable = new(); + SerializablePackage_v1 Serializable = new(); Serializable.Id = Id; Serializable.Name = Name; Serializable.Version = Package.Version; @@ -174,7 +133,7 @@ public virtual SerializableIncompatiblePackage_v1 AsSerializable_Incompatible() return Serializable; } - public static Package FromSerialized(SerializableValidPackage_v1 DeserializedPackage, PackageManager manager, ManagerSource source) + public static Package FromSerialized(SerializablePackage_v1 DeserializedPackage, PackageManager manager, ManagerSource source) { return new Package(DeserializedPackage.Name, DeserializedPackage.Id, DeserializedPackage.Version, source, manager); } @@ -244,7 +203,7 @@ public InvalidBundledPackage(string name, string id, string version, string sour __manager = manager; } - public InvalidBundledPackage(Package package) : base(package, InstallationOptions.FromPackage(package), new SerializableUpdatesOptions_v1()) + public InvalidBundledPackage(IPackage package) : base(package, InstallationOptions.FromPackage(package), new SerializableUpdatesOptions_v1()) { IsValid = false; DrawOpacity = 0.5; @@ -272,7 +231,7 @@ public async override void ShowOptions(object sender, RoutedEventArgs e) await Task.Delay(0); } - public override SerializableValidPackage_v1 AsSerializable() + public override SerializablePackage_v1 AsSerializable() { throw new System.Exception("Cannot serialize an invalid package as a bundled package. Call Serialized_Incompatible() instead "); } diff --git a/src/UniGetUI/PackageEngine/Operations/PackageOperations.cs b/src/UniGetUI/PackageEngine/Operations/PackageOperations.cs index d74872fe6..73bfa6d80 100644 --- a/src/UniGetUI/PackageEngine/Operations/PackageOperations.cs +++ b/src/UniGetUI/PackageEngine/Operations/PackageOperations.cs @@ -7,6 +7,7 @@ using UniGetUI.Core.Tools; using UniGetUI.Interface.Enums; using UniGetUI.PackageEngine.Enums; +using UniGetUI.PackageEngine.Interfaces; using UniGetUI.PackageEngine.PackageClasses; namespace UniGetUI.PackageEngine.Operations @@ -24,14 +25,16 @@ public OperationCancelledEventArgs(OperationStatus OldStatus) public abstract class PackageOperation : AbstractOperation { - public Package Package; - protected InstallationOptions Options; - public PackageOperation(Package package, InstallationOptions options, bool IgnoreParallelInstalls = false) : base(IgnoreParallelInstalls) + public IPackage Package; + protected IInstallationOptions Options; + public PackageOperation(IPackage package, IInstallationOptions options, bool IgnoreParallelInstalls = false) : base(IgnoreParallelInstalls) { Package = package; Options = options; MainProcedure(); } + public PackageOperation(IPackage package, bool IgnoreParallelInstalls = false) : this(package, InstallationOptions.FromPackage(package), IgnoreParallelInstalls) { } + protected override async Task WaitForAvailability() { @@ -66,14 +69,13 @@ protected override async Task WaitForAvailability() } - public PackageOperation(Package package, bool IgnoreParallelInstalls = false) : this(package, InstallationOptions.FromPackage(package), IgnoreParallelInstalls) { } } public class InstallPackageOperation : PackageOperation { - public InstallPackageOperation(Package package, InstallationOptions options, bool IgnoreParallelInstalls = false) : base(package, options, IgnoreParallelInstalls) { } - public InstallPackageOperation(Package package, bool IgnoreParallelInstalls = false) : base(package, IgnoreParallelInstalls) { } + public InstallPackageOperation(IPackage package, IInstallationOptions options, bool IgnoreParallelInstalls = false) : base(package, options, IgnoreParallelInstalls) { } + public InstallPackageOperation(IPackage package, bool IgnoreParallelInstalls = false) : base(package, IgnoreParallelInstalls) { } protected override async Task BuildProcessInstance(ProcessStartInfo startInfo) { if (Options.RunAsAdministrator || Settings.Get("AlwaysElevate" + Package.Manager.Name)) @@ -184,8 +186,8 @@ protected override async void Initialize() public class UpdatePackageOperation : PackageOperation { - public UpdatePackageOperation(Package package, InstallationOptions options, bool IgnoreParallelInstalls = false) : base(package, options, IgnoreParallelInstalls) { } - public UpdatePackageOperation(Package package, bool IgnoreParallelInstalls = false) : base(package, IgnoreParallelInstalls) { } + public UpdatePackageOperation(IPackage package, IInstallationOptions options, bool IgnoreParallelInstalls = false) : base(package, options, IgnoreParallelInstalls) { } + public UpdatePackageOperation(IPackage package, bool IgnoreParallelInstalls = false) : base(package, IgnoreParallelInstalls) { } protected override async Task BuildProcessInstance(ProcessStartInfo startInfo) { if (Options.RunAsAdministrator || Settings.Get("AlwaysElevate" + Package.Manager.Name)) @@ -302,8 +304,8 @@ protected override async void Initialize() public class UninstallPackageOperation : PackageOperation { - public UninstallPackageOperation(Package package, InstallationOptions options, bool IgnoreParallelInstalls = false) : base(package, options, IgnoreParallelInstalls) { } - public UninstallPackageOperation(Package package, bool IgnoreParallelInstalls = false) : base(package, IgnoreParallelInstalls) { } + public UninstallPackageOperation(IPackage package, IInstallationOptions options, bool IgnoreParallelInstalls = false) : base(package, options, IgnoreParallelInstalls) { } + public UninstallPackageOperation(IPackage package, bool IgnoreParallelInstalls = false) : base(package, IgnoreParallelInstalls) { } protected override async Task BuildProcessInstance(ProcessStartInfo startInfo) { if (Options.RunAsAdministrator || Settings.Get("AlwaysElevate" + Package.Manager.Name)) diff --git a/src/UniGetUI/PackageEngine/Operations/SourceOperations.cs b/src/UniGetUI/PackageEngine/Operations/SourceOperations.cs index fb81dd29c..93c47c39e 100644 --- a/src/UniGetUI/PackageEngine/Operations/SourceOperations.cs +++ b/src/UniGetUI/PackageEngine/Operations/SourceOperations.cs @@ -5,16 +5,17 @@ using UniGetUI.Core.Logging; using UniGetUI.Core.SettingsEngine; using UniGetUI.Core.Tools; -using UniGetUI.PackageEngine.Classes.Manager.ManagerHelpers; +using UniGetUI.PackageEngine.Classes.Manager; using UniGetUI.PackageEngine.Enums; +using UniGetUI.PackageEngine.Interfaces; namespace UniGetUI.PackageEngine.Operations { public abstract class SourceOperation : AbstractOperation { - protected ManagerSource Source; - public SourceOperation(ManagerSource source) + protected IManagerSource Source; + public SourceOperation(IManagerSource source) { Source = source; MainProcedure(); @@ -25,7 +26,7 @@ public class AddSourceOperation : SourceOperation { public event EventHandler? OperationSucceeded; - public AddSourceOperation(ManagerSource source) : base(source) { } + public AddSourceOperation(IManagerSource source) : base(source) { } protected override async Task BuildProcessInstance(ProcessStartInfo startInfo) { if (Source.Manager.Capabilities.Sources.MustBeInstalledAsAdmin) @@ -128,7 +129,7 @@ public class RemoveSourceOperation : SourceOperation { public event EventHandler? OperationSucceeded; - public RemoveSourceOperation(ManagerSource source) : base(source) { } + public RemoveSourceOperation(IManagerSource source) : base(source) { } protected override async Task BuildProcessInstance(ProcessStartInfo startInfo) { if (Source.Manager.Capabilities.Sources.MustBeInstalledAsAdmin) diff --git a/src/UniGetUI/UniGetUI.csproj b/src/UniGetUI/UniGetUI.csproj index 7897125fa..4e6671c48 100644 --- a/src/UniGetUI/UniGetUI.csproj +++ b/src/UniGetUI/UniGetUI.csproj @@ -168,6 +168,9 @@ + + + PreserveNewest @@ -274,7 +277,7 @@ - + @@ -285,7 +288,6 @@ - From 1071464708b91d62887ec5a04e9925421d0b15e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=AD=20Climent?= Date: Fri, 28 Jun 2024 14:30:58 +0200 Subject: [PATCH 2/7] Create base PAckageBundlesPage new page --- .../IPackage.cs | 4 + .../Packages/ImportedPackage.cs | 3 +- .../Packages/InvalidImportedPackage.cs | 19 - .../Packages/InvalidPackage.cs | 166 ++++ .../Packages/Package.cs | 68 +- .../SoftwarePages/InstalledPackagesPage.cs | 9 +- .../SoftwarePages/NewPackageBundlesPage.cs | 493 +++++++--- .../SoftwarePages/PackageBundle.xaml | 869 ----------------- .../SoftwarePages/PackageBundle.xaml.cs | 870 ------------------ .../PackageEngine/Classes/ImportExport.cs | 251 ----- src/UniGetUI/UniGetUI.csproj | 3 - 11 files changed, 551 insertions(+), 2204 deletions(-) delete mode 100644 src/UniGetUI.PackageEngine.PackageManagerClasses/Packages/InvalidImportedPackage.cs create mode 100644 src/UniGetUI.PackageEngine.PackageManagerClasses/Packages/InvalidPackage.cs delete mode 100644 src/UniGetUI/Interface/SoftwarePages/PackageBundle.xaml delete mode 100644 src/UniGetUI/Interface/SoftwarePages/PackageBundle.xaml.cs delete mode 100644 src/UniGetUI/PackageEngine/Classes/ImportExport.cs diff --git a/src/UniGetUI.PAckageEngine.Interfaces/IPackage.cs b/src/UniGetUI.PAckageEngine.Interfaces/IPackage.cs index 55e0be182..92be4b3b1 100644 --- a/src/UniGetUI.PAckageEngine.Interfaces/IPackage.cs +++ b/src/UniGetUI.PAckageEngine.Interfaces/IPackage.cs @@ -1,6 +1,7 @@ using System.ComponentModel; using System.Runtime.CompilerServices; using UniGetUI.Interface.Enums; +using UniGetUI.PackageEngine.Classes.Serializable; using UniGetUI.PackageEngine.Enums; using UniGetUI.PackageEngine.Interfaces; @@ -152,5 +153,8 @@ public interface IPackage : INotifyPropertyChanged /// public bool NewerVersionIsInstalled(); + public Task AsSerializable(); + + public SerializableIncompatiblePackage_v1 AsSerializable_Incompatible(); } } diff --git a/src/UniGetUI.PackageEngine.PackageManagerClasses/Packages/ImportedPackage.cs b/src/UniGetUI.PackageEngine.PackageManagerClasses/Packages/ImportedPackage.cs index 76ad99b81..17c8bda17 100644 --- a/src/UniGetUI.PackageEngine.PackageManagerClasses/Packages/ImportedPackage.cs +++ b/src/UniGetUI.PackageEngine.PackageManagerClasses/Packages/ImportedPackage.cs @@ -10,6 +10,7 @@ using UniGetUI.PackageEngine.Classes.Packages; using UniGetUI.PackageEngine.Classes.Serializable; using UniGetUI.PackageEngine.Enums; +using UniGetUI.PackageEngine.Interfaces; using UniGetUI.PackageEngine.ManagerClasses.Manager; using UniGetUI.PackageEngine.Serializable; @@ -27,7 +28,7 @@ public class ImportedPackage : Package SerializableUpdatesOptions_v1 updates_options; SerializableInstallationOptions_v1 installation_options; - public ImportedPackage(SerializablePackage_v1 raw_data, PackageManager manager, ManagerSource source) + public ImportedPackage(SerializablePackage_v1 raw_data, IPackageManager manager, IManagerSource source) : base(raw_data.Name, raw_data.Id, raw_data.Version, source, manager) { installation_options = raw_data.InstallationOptions; diff --git a/src/UniGetUI.PackageEngine.PackageManagerClasses/Packages/InvalidImportedPackage.cs b/src/UniGetUI.PackageEngine.PackageManagerClasses/Packages/InvalidImportedPackage.cs deleted file mode 100644 index cedf34c65..000000000 --- a/src/UniGetUI.PackageEngine.PackageManagerClasses/Packages/InvalidImportedPackage.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.ComponentModel; -using System.Runtime.CompilerServices; -using System.Text.Json.Nodes; -using UniGetUI.Core.Data; -using UniGetUI.Core.IconEngine; -using UniGetUI.Core.Logging; -using UniGetUI.Core.Tools; -using UniGetUI.Interface.Enums; -using UniGetUI.PackageEngine.Classes.Manager.ManagerHelpers; -using UniGetUI.PackageEngine.Classes.Packages; -using UniGetUI.PackageEngine.Enums; -using UniGetUI.PackageEngine.ManagerClasses.Manager; - -namespace UniGetUI.PackageEngine.PackageClasses -{ - public class InvalidImportedPackage // : IPackage - { - } -} diff --git a/src/UniGetUI.PackageEngine.PackageManagerClasses/Packages/InvalidPackage.cs b/src/UniGetUI.PackageEngine.PackageManagerClasses/Packages/InvalidPackage.cs new file mode 100644 index 000000000..5012a480b --- /dev/null +++ b/src/UniGetUI.PackageEngine.PackageManagerClasses/Packages/InvalidPackage.cs @@ -0,0 +1,166 @@ +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.CompilerServices; +using System.Text.Json.Nodes; +using UniGetUI.Core.Data; +using UniGetUI.Core.IconEngine; +using UniGetUI.Core.Logging; +using UniGetUI.Core.Tools; +using UniGetUI.Interface.Enums; +using UniGetUI.PackageEngine.Classes.Manager.ManagerHelpers; +using UniGetUI.PackageEngine.Classes.Packages; +using UniGetUI.PackageEngine.Classes.Serializable; +using UniGetUI.PackageEngine.Enums; +using UniGetUI.PackageEngine.Interfaces; +using UniGetUI.PackageEngine.ManagerClasses.Manager; + +namespace UniGetUI.PackageEngine.PackageClasses +{ + public class InvalidPackage : IPackage, INotifyPropertyChanged + { + + public InvalidPackage(string name, string id, string version, string source) { } + public IPackageDetails Details => throw new NotImplementedException(); + + public PackageTag Tag { get => PackageTag.Unavailable; set { } } + + private bool is_checked = false; + public bool IsChecked { + get => is_checked; + set { is_checked = value; } + } + + private long __hash; + private long __extended_hash; + + public string Name { get; } + + public string Id { get; } + + public string Version { get; } + + public double VersionAsFloat { get; } + + public double NewVersionAsFloat { get => .0F; } + + public IManagerSource Source => throw new NotImplementedException(); + + public IPackageManager Manager => throw new NotImplementedException(); + + public string NewVersion { get => ""; } + + public bool IsUpgradable { get => false; } + + public PackageScope Scope { get => PackageScope.Local; set { } } + + public string SourceAsString { get; } + + public string AutomationName { get; } + + public event PropertyChangedEventHandler? PropertyChanged; + + public InvalidPackage(SerializableIncompatiblePackage_v1 data) + { + Name = data.Name; + Id = data.Id; + Version = data.Version; + VersionAsFloat = CoreTools.GetVersionStringAsFloat(data.Version); + SourceAsString = data.Source; + AutomationName = data.Name; + + __hash = CoreTools.HashStringAsLong(data.Name + data.Id); + __extended_hash = CoreTools.HashStringAsLong(data.Name + data.Id + data.Version); + } + + public async Task AddToIgnoredUpdatesAsync(string version = "*") + { + return; + } + + public Task AsSerializable() + { + throw new NotImplementedException(); + } + + public SerializableIncompatiblePackage_v1 AsSerializable_Incompatible() + { + return new SerializableIncompatiblePackage_v1() + { + Name = Name, + Id = Id, + Version = Version, + Source = SourceAsString, + }; + } + + public IPackage? GetAvailablePackage() + { + return null; + } + + public long GetHash() + { + return __hash; + } + + public string GetIconId() + { + throw new NotImplementedException(); + } + + public async Task GetIconUrl() + { + return new Uri("ms-appx:///Assets/Images/package_color.png"); + } + + public async Task GetIgnoredUpdatesVersionAsync() + { + return ""; + } + + public IPackage? GetInstalledPackage() + { + return null; + } + + public async Task GetPackageScreenshots() + { + return []; + } + + public IPackage? GetUpgradablePackage() + { + return null; + } + + public long GetVersionedHash() + { + return __extended_hash; + } + + public async Task HasUpdatesIgnoredAsync(string Version = "*") + { + return false; + } + + public bool IsEquivalentTo(IPackage? other) + { + return __hash == (other as IPackage)?.GetHash(); + } + + public bool NewerVersionIsInstalled() + { + return false; + } + + public async Task RemoveFromIgnoredUpdatesAsync() + { + return; + } + + public void SetTag(PackageTag tag) + { + return; + } + } +} diff --git a/src/UniGetUI.PackageEngine.PackageManagerClasses/Packages/Package.cs b/src/UniGetUI.PackageEngine.PackageManagerClasses/Packages/Package.cs index 1bfa6e31b..8ace37d10 100644 --- a/src/UniGetUI.PackageEngine.PackageManagerClasses/Packages/Package.cs +++ b/src/UniGetUI.PackageEngine.PackageManagerClasses/Packages/Package.cs @@ -34,14 +34,15 @@ public class Package : IPackage private PackageDetails? __details = null; public IPackageDetails Details - { + { get => __details ??= new PackageDetails(this); } public PackageTag Tag { - get => __tag; - set { + get => __tag; + set + { __tag = value; OnPropertyChanged(nameof(Tag)); } @@ -86,7 +87,7 @@ public Package(string name, string id, string version, IManagerSource source, IP NewVersion = ""; Tag = PackageTag.Default; SourceAsString = source.ToString(); - AutomationName = CoreTools.Translate("Package {name} from {manager}", new Dictionary { {"name", Name },{ "manager", SourceAsString } }); + AutomationName = CoreTools.Translate("Package {name} from {manager}", new Dictionary { { "name", Name }, { "manager", SourceAsString } }); __hash = CoreTools.HashStringAsLong(Manager.Name + "\\" + Source.Name + "\\" + Id); __versioned_hash = CoreTools.HashStringAsLong(Manager.Name + "\\" + Source.Name + "\\" + Id + "\\" + Version); IsUpgradable = false; @@ -125,17 +126,17 @@ public long GetVersionedHash() public override bool Equals(object? other) { - return __versioned_hash == (other as Package)?.__versioned_hash; + return __versioned_hash == (other as IPackage)?.GetHash(); } public bool IsEquivalentTo(IPackage? other) - { - return __hash == (other as Package)?.__hash; + { + return __hash == (other as IPackage)?.GetHash(); } public string GetIconId() { - string iconId = Id.ToLower(); + string iconId = Id.ToLower(); if (Manager.Name == "Winget") iconId = string.Join('.', iconId.Split(".")[1..]); else if (Manager.Name == "Chocolatey") @@ -258,7 +259,7 @@ public virtual async Task GetIgnoredUpdatesVersionAsync() if (IgnoredUpdatesJson == null) throw new Exception("The IgnoredUpdates database seems to be invalid!"); - + if (IgnoredUpdatesJson.ContainsKey(IgnoredId)) return IgnoredUpdatesJson[IgnoredId]?.ToString() ?? ""; else @@ -299,41 +300,38 @@ public virtual void SetTag(PackageTag tag) public virtual bool NewerVersionIsInstalled() { - if(!IsUpgradable) return false; + if (!IsUpgradable) return false; return PackageCacher.NewerVersionIsInstalled(this); } - /* - public static Package FromSerializable(SerializablePackage_v1 raw_package) + public async Task AsSerializable() { - PackageManager? manager = null; - ManagerSource? source = null; - - foreach (var possible_manager in ManagersList) + return new SerializablePackage_v1() { - if (possible_manager.Name == raw_package.ManagerName) + Id = Id, + Name = Name, + Version = Version, + Source = Source.Name, + ManagerName = Manager.Name, + InstallationOptions = (await InstallationOptions.FromPackageAsync(this)).AsSerializable(), + Updates = new SerializableUpdatesOptions_v1() { - manager = possible_manager; - break; + IgnoredVersion = await GetIgnoredUpdatesVersionAsync(), + UpdatesIgnored = await HasUpdatesIgnoredAsync(), } - } - - if (manager?.Capabilities.SupportsCustomSources == true) - source = manager?.SourceProvider?.SourceFactory.GetSourceIfExists(raw_package.Source); - else - source = manager?.DefaultSource; - - if (manager is null || source is null) - { - return FromSerializable(raw_package.GetInvalidEquivalent()); - } - - return new ImportedPackage(raw_package, manager, source); + }; } - public static InvalidImportedPackage FromSerializable(SerializableIncompatiblePackage_v1 raw_package) + public SerializableIncompatiblePackage_v1 AsSerializable_Incompatible() { - return new InvalidImportedPackage(raw_package.Name, raw_package.Id, raw_package.Version, raw_package.Source); - }*/ + return new SerializableIncompatiblePackage_v1() + { + Id = Id, + Name = Name, + Version = Version, + Source = Source.Name, + }; + } } } + diff --git a/src/UniGetUI/Interface/SoftwarePages/InstalledPackagesPage.cs b/src/UniGetUI/Interface/SoftwarePages/InstalledPackagesPage.cs index 7cc4dc236..2a8a4a3b4 100644 --- a/src/UniGetUI/Interface/SoftwarePages/InstalledPackagesPage.cs +++ b/src/UniGetUI/Interface/SoftwarePages/InstalledPackagesPage.cs @@ -4,6 +4,7 @@ using UniGetUI.Core.Logging; using UniGetUI.Core.SettingsEngine; using UniGetUI.Core.Tools; +using UniGetUI.Interface.SoftwarePages.UniGetUI.Interface.SoftwarePages; using UniGetUI.Interface.Widgets; using UniGetUI.PackageEngine; using UniGetUI.PackageEngine.Classes; @@ -301,11 +302,7 @@ public async Task BackupPackages() { // TODO: FIXME Logger.Debug("Starting package backup"); - /*List packagestoExport = new(); - foreach (Package package in Loader.Packages) - packagestoExport.Add(await BundledPackage.FromPackageAsync(package)); - - string BackupContents = await PackageBundlePage.GetBundleStringFromPackages(packagestoExport.ToArray(), BundleFormatType.JSON); + string BackupContents = await NewPackageBundlesPage.CreateBundle(Loader.Packages, BundleFormatType.JSON); string dirName = Settings.GetValue("ChangeBackupOutputDirectory"); if (dirName == "") @@ -327,7 +324,7 @@ public async Task BackupPackages() await File.WriteAllTextAsync(filePath, BackupContents); HasDoneBackup = true; Logger.ImportantInfo("Backup saved to " + filePath); - */} + } catch (Exception ex) { Logger.Error("An error occurred while performing a backup"); diff --git a/src/UniGetUI/Interface/SoftwarePages/NewPackageBundlesPage.cs b/src/UniGetUI/Interface/SoftwarePages/NewPackageBundlesPage.cs index 44fcb0eaf..47b8ee347 100644 --- a/src/UniGetUI/Interface/SoftwarePages/NewPackageBundlesPage.cs +++ b/src/UniGetUI/Interface/SoftwarePages/NewPackageBundlesPage.cs @@ -1,21 +1,30 @@ -using Microsoft.UI.Xaml; +using ExternalLibraries.Pickers; +using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using System.Reflection.Emit; using System.Text; +using System.Text.Json; using System.Threading.Tasks; +using System.Xml.Serialization; using UniGetUI.Core.Data; using UniGetUI.Core.Logging; using UniGetUI.Core.SettingsEngine; using UniGetUI.Core.Tools; using UniGetUI.Interface.Widgets; using UniGetUI.PackageEngine; +using UniGetUI.PackageEngine.Classes; +using UniGetUI.PackageEngine.Classes.Manager; +using UniGetUI.PackageEngine.Classes.Serializable; using UniGetUI.PackageEngine.Enums; using UniGetUI.PackageEngine.Interfaces; using UniGetUI.PackageEngine.Operations; using UniGetUI.PackageEngine.PackageClasses; +using UniGetUI.PackageEngine.PackageLoader; +using Windows.Media.Devices; namespace UniGetUI.Interface.SoftwarePages { @@ -27,29 +36,29 @@ public class NewPackageBundlesPage : AbstractPackagesPage BetterMenuItem? MenuAsAdmin; BetterMenuItem? MenuInteractive; - BetterMenuItem? MenuRemoveData; + BetterMenuItem? MenuSkipHash; public NewPackageBundlesPage() : base(new PackagesPageData() { - DisableAutomaticPackageLoadOnStart = false, + DisableAutomaticPackageLoadOnStart = true, MegaQueryBlockEnabled = false, ShowLastLoadTime = false, PackagesAreCheckedByDefault = false, DisableSuggestedResultsRadio = true, - PageName = "Installed", + PageName = "Bundles", - Loader = PEInterface.InstalledPackagesLoader, + Loader = PEInterface.PackageBundlesLoader, PageRole = OperationType.Uninstall, - NoPackages_BackgroundText = CoreTools.Translate("No results were found matching the input criteria"), - NoPackages_SourcesText = CoreTools.Translate("No packages were found"), - NoPackages_SubtitleText_Base = CoreTools.Translate("No packages were found"), + NoPackages_BackgroundText = CoreTools.Translate("Add packages or open an existing package bundle"), + NoPackages_SourcesText = CoreTools.Translate("Add packages to start"), + NoPackages_SubtitleText_Base = CoreTools.Translate("The current bundle has no packages. Add some packages to get started"), MainSubtitle_StillLoading = CoreTools.Translate("Loading packages"), NoMatches_BackgroundText = CoreTools.Translate("No results were found matching the input criteria"), - PageTitle = CoreTools.Translate("Installed Packages"), - Glyph = "\uE977" + PageTitle = CoreTools.Translate("Package Bundles"), + Glyph = "\uF133" }) { } @@ -59,8 +68,8 @@ public override BetterMenu GenerateContextMenu() BetterMenu menu = new(); BetterMenuItem menuUninstall = new() { - Text = "Uninstall", - IconName = "trash", + Text = "Install", + IconName = "newversion", KeyboardAcceleratorTextOverride = "Ctrl+Enter" }; menuUninstall.Click += MenuUninstall_Invoked; @@ -81,7 +90,7 @@ public override BetterMenu GenerateContextMenu() MenuAsAdmin = new BetterMenuItem { - Text = "Uninstall as administrator", + Text = "Install as administrator", IconName = "runasadmin" }; MenuAsAdmin.Click += MenuAsAdmin_Invoked; @@ -89,48 +98,31 @@ public override BetterMenu GenerateContextMenu() MenuInteractive = new BetterMenuItem { - Text = "Interactive uninstall", + Text = "Interactive installation", IconName = "interactive" }; MenuInteractive.Click += MenuInteractive_Invoked; menu.Items.Add(MenuInteractive); - MenuRemoveData = new BetterMenuItem + MenuSkipHash = new BetterMenuItem { - Text = "Uninstall and remove data", - IconName = "menu_close" + Text = "Skip hash checks", + IconName = "checksum" }; - MenuRemoveData.Click += MenuRemoveData_Invoked; - menu.Items.Add(MenuRemoveData); + MenuSkipHash.Click += MenuRemoveData_Invoked; + menu.Items.Add(MenuSkipHash); menu.Items.Add(new MenuFlyoutSeparator()); - BetterMenuItem menuReinstall = new() + BetterMenuItem menuRemoveFromList = new() { - Text = "Reinstall package", - IconName = "newversion" + Text = "Remove from list", + IconName = "trash" }; - menuReinstall.Click += MenuReinstall_Invoked; - menu.Items.Add(menuReinstall); - - BetterMenuItem menuUninstallThenReinstall = new() - { - Text = "Uninstall package, then reinstall it", - IconName = "undelete" - }; - menuUninstallThenReinstall.Click += MenuUninstallThenReinstall_Invoked; - menu.Items.Add(menuUninstallThenReinstall); - + menuRemoveFromList.Click += MenuRemoveFromList_Invoked; + menu.Items.Add(menuRemoveFromList); menu.Items.Add(new MenuFlyoutSeparator()); - - BetterMenuItem menuIgnorePackage = new() - { - Text = "Ignore updates for this package", - IconName = "pin" - }; - menuIgnorePackage.Click += MenuIgnorePackage_Invoked; - menu.Items.Add(menuIgnorePackage); - + menu.Items.Add(new MenuFlyoutSeparator()); BetterMenuItem menuShare = new() @@ -155,50 +147,50 @@ public override BetterMenu GenerateContextMenu() public override void GenerateToolBar() { - AppBarButton UninstallSelected = new(); - AppBarButton UninstallAsAdmin = new(); - AppBarButton UninstallInteractive = new(); - AppBarButton InstallationSettings = new(); - + AppBarButton OpenBundle = new(); + AppBarButton NewBundle = new(); + AppBarButton InstallPackages = new(); + AppBarButton InstallAsAdmin = new(); + AppBarButton InstallInteractive = new(); + AppBarButton InstallSkipHash = new(); + AppBarButton RemoveSelected = new(); + AppBarButton ExportBundle = new(); AppBarButton PackageDetails = new(); AppBarButton SharePackage = new(); - - AppBarButton IgnoreSelected = new(); - AppBarButton ManageIgnored = new(); - AppBarButton ExportSelection = new(); - AppBarButton HelpButton = new(); - ToolBar.PrimaryCommands.Add(UninstallSelected); - ToolBar.PrimaryCommands.Add(UninstallAsAdmin); - ToolBar.PrimaryCommands.Add(UninstallInteractive); + ToolBar.PrimaryCommands.Add(NewBundle); + ToolBar.PrimaryCommands.Add(OpenBundle); + ToolBar.PrimaryCommands.Add(ExportBundle); ToolBar.PrimaryCommands.Add(new AppBarSeparator()); - ToolBar.PrimaryCommands.Add(InstallationSettings); + ToolBar.PrimaryCommands.Add(InstallPackages); + ToolBar.PrimaryCommands.Add(InstallAsAdmin); + ToolBar.PrimaryCommands.Add(InstallInteractive); + ToolBar.PrimaryCommands.Add(InstallSkipHash); ToolBar.PrimaryCommands.Add(new AppBarSeparator()); - ToolBar.PrimaryCommands.Add(PackageDetails); - ToolBar.PrimaryCommands.Add(SharePackage); ToolBar.PrimaryCommands.Add(new AppBarSeparator()); - ToolBar.PrimaryCommands.Add(IgnoreSelected); - ToolBar.PrimaryCommands.Add(ManageIgnored); + ToolBar.PrimaryCommands.Add(RemoveSelected); ToolBar.PrimaryCommands.Add(new AppBarSeparator()); - ToolBar.PrimaryCommands.Add(ExportSelection); + ToolBar.PrimaryCommands.Add(PackageDetails); + ToolBar.PrimaryCommands.Add(SharePackage); ToolBar.PrimaryCommands.Add(new AppBarSeparator()); ToolBar.PrimaryCommands.Add(HelpButton); Dictionary Labels = new() - { // Entries with a trailing space are collapsed - // Their texts will be used as the tooltip - { UninstallSelected, CoreTools.Translate("Uninstall selected packages") }, - { UninstallAsAdmin, " " + CoreTools.Translate("Uninstall as administrator") }, - { UninstallInteractive, " " + CoreTools.Translate("Interactive uninstall") }, - { InstallationSettings, " " + CoreTools.Translate("Installation options") }, - { PackageDetails, " " + CoreTools.Translate("Package details") }, - { SharePackage, " " + CoreTools.Translate("Share") }, - { IgnoreSelected, CoreTools.Translate("Ignore selected packages") }, - { ManageIgnored, CoreTools.Translate("Manage ignored updates") }, - { ExportSelection, CoreTools.Translate("Add selection to bundle") }, - { HelpButton, CoreTools.Translate("Help") } - }; + { // Entries with a trailing space are collapsed + // Their texts will be used as the tooltip + { NewBundle, CoreTools.Translate("New bundle") }, + { InstallPackages, CoreTools.Translate("Install selection") }, + { InstallAsAdmin, " " + CoreTools.Translate("Uninstall as administrator") }, + { InstallInteractive, " " + CoreTools.Translate("Interactive uninstall") }, + { InstallSkipHash, " " + CoreTools.Translate("Skip integrity checks") }, + { OpenBundle, CoreTools.Translate("Open existing bundle") }, + { RemoveSelected, CoreTools.Translate("Remove selection from bundle") }, + { ExportBundle, CoreTools.Translate("Save bundle as") }, + { PackageDetails, " " + CoreTools.Translate("Package details") }, + { SharePackage, " " + CoreTools.Translate("Share") }, + { HelpButton, CoreTools.Translate("Help") } + }; foreach (AppBarButton toolButton in Labels.Keys) { @@ -209,41 +201,87 @@ public override void GenerateToolBar() } Dictionary Icons = new() - { - { UninstallSelected, "trash" }, - { UninstallAsAdmin, "runasadmin" }, - { UninstallInteractive, "interactive" }, - { InstallationSettings, "options" }, - { PackageDetails, "info" }, - { SharePackage, "share" }, - { IgnoreSelected, "pin" }, - { ManageIgnored, "clipboard_list" }, - { ExportSelection, "add_to" }, - { HelpButton, "help" } - }; + { + { NewBundle, "add_to" }, + { InstallPackages, "newversion" }, + { InstallAsAdmin, "runasadmin" }, + { InstallInteractive, "interactive" }, + { InstallSkipHash, "checksum" }, + { OpenBundle, "openfolder" }, + { RemoveSelected, "trash" }, + { ExportBundle, "save" }, + { PackageDetails, "info" }, + { SharePackage, "share" }, + { HelpButton, "help" } + }; foreach (AppBarButton toolButton in Icons.Keys) toolButton.Icon = new LocalIcon(Icons[toolButton]); - PackageDetails.Click += (s, e) => ShowDetailsForPackage(SelectedItem); + PackageDetails.Click += (s, e) => + { + Package? package = SelectedItem as Package; + if (package != null) + _ = MainApp.Instance.MainWindow.NavigationPage.ShowPackageDetails(package, OperationType.None); + }; + + HelpButton.Click += (s, e) => { MainApp.Instance.MainWindow.NavigationPage.ShowHelp(); }; + + NewBundle.Click += (s, e) => + { + FilteredPackages.Clear(); + }; - ExportSelection.Click += ExportSelection_Click; - HelpButton.Click += (s, e) => MainApp.Instance.MainWindow.NavigationPage.ShowHelp(); - InstallationSettings.Click += (s, e) => ShowInstallationOptionsForPackage(SelectedItem); - ManageIgnored.Click += async (s, e) => await MainApp.Instance.MainWindow.NavigationPage.ManageIgnoredUpdatesDialog(); - IgnoreSelected.Click += async (s, e) => + RemoveSelected.Click += (s, e) => { foreach (Package package in FilteredPackages.GetCheckedPackages()) - { - PEInterface.UpgradablePackagesLoader.Remove(package); - await package.AddToIgnoredUpdatesAsync(); - } + PEInterface.PackageBundlesLoader.Remove(package); + }; + + InstallPackages.Click += async (s, e) => await ImportAndInstallPackage(FilteredPackages.GetCheckedPackages()); + InstallSkipHash.Click += async (s, e) => await ImportAndInstallPackage(FilteredPackages.GetCheckedPackages(), skiphash: true); + InstallInteractive.Click += async (s, e) => await ImportAndInstallPackage(FilteredPackages.GetCheckedPackages(), interactive: true); + InstallAsAdmin.Click += async (s, e) => await ImportAndInstallPackage(FilteredPackages.GetCheckedPackages(), elevated: true); + + + OpenBundle.Click += (s, e) => + { + FilteredPackages.Clear(); + OpenFile(); + }; + + ExportBundle.Click += (s, e) => + { + SaveFile(); + }; + + SharePackage.Click += (s, e) => + { + Package? package = SelectedItem as Package; + if (package != null) MainApp.Instance.MainWindow.SharePackage(package); }; - UninstallSelected.Click += (s, e) => ConfirmAndUninstall(FilteredPackages.GetCheckedPackages()); - UninstallAsAdmin.Click += (s, e) => ConfirmAndUninstall(FilteredPackages.GetCheckedPackages(), elevated: true); - UninstallInteractive.Click += (s, e) => ConfirmAndUninstall(FilteredPackages.GetCheckedPackages(), interactive: true); - SharePackage.Click += (s, e) => MainApp.Instance.MainWindow.SharePackage(SelectedItem); + } + + public async Task ImportAndInstallPackage(IEnumerable packages, bool? elevated = null, bool? interactive = null, bool? skiphash = null) + { + MainApp.Instance.MainWindow.ShowLoadingDialog(CoreTools.Translate("Preparing packages, please wait...")); + foreach (IPackage package in FilteredPackages.GetCheckedPackages()) + { + ImportedPackage? imported = package as ImportedPackage; + if (imported != null) await imported.RegisterPackage(); + } + + MainApp.Instance.MainWindow.HideLoadingDialog(); + + foreach (IPackage package in FilteredPackages.GetCheckedPackages()) + { + if (package is Package) + { + MainApp.Instance.AddOperationToList(new InstallPackageOperation(package, + await InstallationOptions.FromPackageAsync(package, elevated, interactive, skiphash))); + } + } } protected override void WhenPackageCountUpdated() @@ -254,17 +292,13 @@ protected override void WhenPackageCountUpdated() #pragma warning disable protected override void WhenPackagesLoaded(ReloadReason reason) { - if (!HasDoneBackup) - { - if (Settings.Get("EnablePackageBackup")) - _ = BackupPackages(); - } + return; } #pragma warning restore protected override void WhenShowingContextMenu(IPackage package) { - if (MenuAsAdmin == null || MenuInteractive == null || MenuRemoveData == null) + if (MenuAsAdmin == null || MenuInteractive == null || MenuSkipHash == null) { Logger.Error("Menu items are null on InstalledPackagesTab"); return; @@ -272,7 +306,7 @@ protected override void WhenShowingContextMenu(IPackage package) MenuAsAdmin.IsEnabled = package.Manager.Capabilities.CanRunAsAdmin; MenuInteractive.IsEnabled = package.Manager.Capabilities.CanRunInteractively; - MenuRemoveData.IsEnabled = package.Manager.Capabilities.CanRemoveDataOnUninstall; + MenuSkipHash.IsEnabled = package.Manager.Capabilities.CanSkipIntegrityChecks; } private void ExportSelection_Click(object sender, RoutedEventArgs e) @@ -301,49 +335,6 @@ public async void ConfirmAndUninstall(IEnumerable packages, bool? elev } } - public async Task BackupPackages() - { - - try - { - // TODO: FIXME - - Logger.Debug("Starting package backup"); - /*List packagestoExport = new(); - foreach (Package package in Loader.Packages) - packagestoExport.Add(await BundledPackage.FromPackageAsync(package)); - - string BackupContents = await PackageBundlePage.GetBundleStringFromPackages(packagestoExport.ToArray(), BundleFormatType.JSON); - - string dirName = Settings.GetValue("ChangeBackupOutputDirectory"); - if (dirName == "") - dirName = CoreData.UniGetUI_DefaultBackupDirectory; - - if (!Directory.Exists(dirName)) - Directory.CreateDirectory(dirName); - - string fileName = Settings.GetValue("ChangeBackupFileName"); - if (fileName == "") - fileName = CoreTools.Translate("{pcName} installed packages", new Dictionary { { "pcName", Environment.MachineName } }); - - if (Settings.Get("EnableBackupTimestamping")) - fileName += " " + DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss"); - - fileName += ".json"; - - string filePath = Path.Combine(dirName, fileName); - await File.WriteAllTextAsync(filePath, BackupContents); - HasDoneBackup = true; - Logger.ImportantInfo("Backup saved to " + filePath); - */ - } - catch (Exception ex) - { - Logger.Error("An error occurred while performing a backup"); - Logger.Error(ex); - } - } - private async void MenuUninstall_Invoked(object sender, RoutedEventArgs args) { IPackage? package = SelectedItem; @@ -421,6 +412,208 @@ await MainApp.Instance.MainWindow.NavigationPage.ShowInstallationSettingsForPack ConfirmAndUninstall(package, await InstallationOptions.FromPackageAsync(package)); } } + private void MenuRemoveFromList_Invoked(object sender, RoutedEventArgs args) + { + IPackage? package = SelectedItem; + if (package == null) return; + PEInterface.PackageBundlesLoader.Remove(package); + } + + + public async Task OpenFile() + { + try + { + // Select file + FileOpenPicker picker = new(MainApp.Instance.MainWindow.GetWindowHandle()); + string file = picker.Show(new List() { "*.json", "*.yaml", "*.xml" }); + if (file == String.Empty) + return; + + MainApp.Instance.MainWindow.ShowLoadingDialog(CoreTools.Translate("Loading packages, please wait...")); + + // Read file + BundleFormatType formatType; + if (file.Split('.')[^1].ToLower() == "yaml") + formatType = BundleFormatType.YAML; + else if (file.Split('.')[^1].ToLower() == "xml") + formatType = BundleFormatType.XML; + else + formatType = BundleFormatType.JSON; + + string fileContent = await File.ReadAllTextAsync(file); + + // Import packages to list + await AddFromBundle(fileContent, formatType); + + MainApp.Instance.MainWindow.HideLoadingDialog(); + + } + catch (Exception ex) + { + Logger.Error("Could not load packages from a file"); + Logger.Error(ex); + MainApp.Instance.MainWindow.HideLoadingDialog(); + } + } + + public async Task SaveFile() + { + try + { + // Get file + // Save file + string file = (new FileSavePicker(MainApp.Instance.MainWindow.GetWindowHandle())).Show(new List() { "*.json", "*.yaml", "*.xml" }, CoreTools.Translate("Package bundle") + ".json"); + if (file != String.Empty) + { + // Loading dialog + MainApp.Instance.MainWindow.ShowLoadingDialog(CoreTools.Translate("Saving packages, please wait...")); + + // Select appropriate format + BundleFormatType formatType; + if (file.Split('.')[^1].ToLower() == "yaml") + formatType = BundleFormatType.YAML; + else if (file.Split('.')[^1].ToLower() == "xml") + formatType = BundleFormatType.XML; + else + formatType = BundleFormatType.JSON; + + // Save serialized data + await File.WriteAllTextAsync(file, await CreateBundle(PEInterface.PackageBundlesLoader.Packages, formatType)); + + MainApp.Instance.MainWindow.HideLoadingDialog(); + + // Launch file + Process.Start(new ProcessStartInfo() + { + FileName = "explorer.exe", + Arguments = @$"/select, ""{file}""" + }); + + } + } + catch (Exception ex) + { + MainApp.Instance.MainWindow.HideLoadingDialog(); + Logger.Error("An error occurred when saving packages to a file"); + Logger.Error(ex); + } + } + + public static async Task CreateBundle(IEnumerable packages, BundleFormatType formatType = BundleFormatType.JSON) + { + SerializableBundle_v1 exportable = new(); + foreach (IPackage package in packages) + if (package is Package && !package.Source.IsVirtualManager) + exportable.packages.Add(await package.AsSerializable()); + else + exportable.incompatible_packages.Add(package.AsSerializable_Incompatible()); + + Logger.Debug("Finished loading serializable objects. Serializing with format " + formatType.ToString()); + string ExportableData; + + if (formatType == BundleFormatType.JSON) + ExportableData = JsonSerializer.Serialize(exportable, new JsonSerializerOptions { WriteIndented = true }); + else if (formatType == BundleFormatType.YAML) + { + YamlDotNet.Serialization.ISerializer serializer = new YamlDotNet.Serialization.SerializerBuilder() + .Build(); + ExportableData = serializer.Serialize(exportable); + } + else + { + string tempfile = Path.GetTempFileName(); + StreamWriter writer = new(tempfile); + XmlSerializer serializer = new(typeof(SerializableBundle_v1)); + serializer.Serialize(writer, exportable); + writer.Close(); + ExportableData = await File.ReadAllTextAsync(tempfile); + File.Delete(tempfile); + + } + + Logger.Debug("Serialization finished successfully"); + + return ExportableData; + } + + public async Task AddFromBundle(string content, BundleFormatType format) + { + // Deserialize data + SerializableBundle_v1? DeserializedData; + if (format == BundleFormatType.JSON) + { + DeserializedData = JsonSerializer.Deserialize(content); + } + else if (format == BundleFormatType.YAML) + { + YamlDotNet.Serialization.IDeserializer deserializer = new YamlDotNet.Serialization.DeserializerBuilder() + .Build(); + DeserializedData = deserializer.Deserialize(content); + } + else + { + string tempfile = Path.GetTempFileName(); + await File.WriteAllTextAsync(tempfile, content); + StreamReader reader = new(tempfile); + XmlSerializer serializer = new(typeof(SerializableBundle_v1)); + DeserializedData = serializer.Deserialize(reader) as SerializableBundle_v1; + reader.Close(); + File.Delete(tempfile); + } + + if (DeserializedData == null) + throw new Exception($"Deserialized data was null for content {content} and format {format}"); + + List packages = new List(); + + foreach (SerializablePackage_v1 DeserializedPackage in DeserializedData.packages) + { + packages.Add(PackageFromSerializable(DeserializedPackage)); + } + + foreach (SerializableIncompatiblePackage_v1 DeserializedPackage in DeserializedData.incompatible_packages) + { + packages.Add(PackageFromSerializable(DeserializedPackage)); + } + + PEInterface.PackageBundlesLoader.AddPackages(packages); + } + + public static IPackage PackageFromSerializable(SerializablePackage_v1 raw_package) + { + IPackageManager? manager = null; + IManagerSource? source = null; + + foreach (var possible_manager in PEInterface.Managers) + { + if (possible_manager.Name == raw_package.ManagerName) + { + manager = possible_manager; + break; + } + } + + if (manager?.Capabilities.SupportsCustomSources == true) + source = manager?.SourceProvider?.SourceFactory.GetSourceIfExists(raw_package.Source); + else + source = manager?.DefaultSource; + + if (manager is null || source is null) + { + return PackageFromSerializable(raw_package.GetInvalidEquivalent()); + } + + return new ImportedPackage(raw_package, manager, source); + } + + public static IPackage PackageFromSerializable(SerializableIncompatiblePackage_v1 raw_package) + { + return new InvalidPackage(raw_package.Name, raw_package.Id, raw_package.Version, raw_package.Source); + } } + + } + } diff --git a/src/UniGetUI/Interface/SoftwarePages/PackageBundle.xaml b/src/UniGetUI/Interface/SoftwarePages/PackageBundle.xaml deleted file mode 100644 index 6a3b2b95a..000000000 --- a/src/UniGetUI/Interface/SoftwarePages/PackageBundle.xaml +++ /dev/null @@ -1,869 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -