From a63c8b036bd4c29dd0355b39ccadeda5381f7880 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Mon, 7 Jul 2025 21:35:12 +1000 Subject: [PATCH] updates to method summary and correct spell check errors --- .github/actions/spelling/expect.txt | 2 + .github/actions/spelling/patterns.txt | 1 + Flow.Launcher.Core/Plugin/PluginInstaller.cs | 42 +++++++++++++++++-- Flow.Launcher.Core/Plugin/PluginManager.cs | 2 +- Flow.Launcher/ProgressBoxEx.xaml.cs | 20 ++++----- .../PluginsManager.cs | 4 +- 6 files changed, 55 insertions(+), 16 deletions(-) diff --git a/.github/actions/spelling/expect.txt b/.github/actions/spelling/expect.txt index 177c00fa2..6bbd57ac6 100644 --- a/.github/actions/spelling/expect.txt +++ b/.github/actions/spelling/expect.txt @@ -99,3 +99,5 @@ pluginsmanager alreadyexists Softpedia img +Reloadable +metadatas diff --git a/.github/actions/spelling/patterns.txt b/.github/actions/spelling/patterns.txt index 5ef8859fc..f308ec599 100644 --- a/.github/actions/spelling/patterns.txt +++ b/.github/actions/spelling/patterns.txt @@ -133,3 +133,4 @@ \bPortuguês (Brasil)\b \bčeština\b \bPortuguês\b +\bIoc\b diff --git a/Flow.Launcher.Core/Plugin/PluginInstaller.cs b/Flow.Launcher.Core/Plugin/PluginInstaller.cs index 6e2ff99ff..33963c01a 100644 --- a/Flow.Launcher.Core/Plugin/PluginInstaller.cs +++ b/Flow.Launcher.Core/Plugin/PluginInstaller.cs @@ -13,7 +13,7 @@ using Flow.Launcher.Plugin; namespace Flow.Launcher.Core.Plugin; /// -/// Helper class for installing, updating, and uninstalling plugins. +/// Class for installing, updating, and uninstalling plugins. /// public static class PluginInstaller { @@ -25,6 +25,11 @@ public static class PluginInstaller private static IPublicAPI api = null; private static IPublicAPI API => api ??= Ioc.Default.GetRequiredService(); + /// + /// Installs a plugin and restarts the application if required by settings. Prompts user for confirmation and handles download if needed. + /// + /// The plugin to install. + /// A Task representing the asynchronous install operation. public static async Task InstallPluginAndCheckRestartAsync(UserPlugin newPlugin) { if (API.PluginModified(newPlugin.ID)) @@ -106,6 +111,11 @@ public static class PluginInstaller } } + /// + /// Installs a plugin from a local zip file and restarts the application if required by settings. Validates the zip and prompts user for confirmation. + /// + /// The path to the plugin zip file. + /// A Task representing the asynchronous install operation. public static async Task InstallPluginAndCheckRestartAsync(string filePath) { UserPlugin plugin; @@ -147,6 +157,11 @@ public static class PluginInstaller await InstallPluginAndCheckRestartAsync(plugin); } + /// + /// Uninstalls a plugin and restarts the application if required by settings. Prompts user for confirmation and whether to keep plugin settings. + /// + /// The plugin metadata to uninstall. + /// A Task representing the asynchronous uninstall operation. public static async Task UninstallPluginAndCheckRestartAsync(PluginMetadata oldPlugin) { if (API.PluginModified(oldPlugin.ID)) @@ -197,6 +212,12 @@ public static class PluginInstaller } } + /// + /// Updates a plugin to a new version and restarts the application if required by settings. Prompts user for confirmation and handles download if needed. + /// + /// The new plugin version to install. + /// The existing plugin metadata to update. + /// A Task representing the asynchronous update operation. public static async Task UpdatePluginAndCheckRestartAsync(UserPlugin newPlugin, PluginMetadata oldPlugin) { if (API.ShowMsgBox( @@ -256,7 +277,17 @@ public static class PluginInstaller } } - private static async Task DownloadFileAsync(string prgBoxTitle, string downloadUrl, string filePath, CancellationTokenSource cts, bool deleteFile = true, bool showProgress = true) + /// + /// Downloads a file from a URL to a local path, optionally showing a progress box and handling cancellation. + /// + /// The title for the progress box. + /// The URL to download from. + /// The local file path to save to. + /// Cancellation token source for cancelling the download. + /// Whether to delete the file if it already exists. + /// Whether to show a progress box during download. + /// A Task representing the asynchronous download operation. + private static async Task DownloadFileAsync(string progressBoxTitle, string downloadUrl, string filePath, CancellationTokenSource cts, bool deleteFile = true, bool showProgress = true) { if (deleteFile && File.Exists(filePath)) File.Delete(filePath); @@ -264,7 +295,7 @@ public static class PluginInstaller if (showProgress) { var exceptionHappened = false; - await API.ShowProgressBoxAsync(prgBoxTitle, + await API.ShowProgressBoxAsync(progressBoxTitle, async (reportProgress) => { if (reportProgress == null) @@ -291,6 +322,11 @@ public static class PluginInstaller } } + /// + /// Determines if the plugin install source is a known/approved source (e.g., GitHub and matches an existing plugin author). + /// + /// The URL to check. + /// True if the source is known, otherwise false. private static bool InstallSourceKnown(string url) { if (string.IsNullOrEmpty(url)) diff --git a/Flow.Launcher.Core/Plugin/PluginManager.cs b/Flow.Launcher.Core/Plugin/PluginManager.cs index 3860787f9..60790abed 100644 --- a/Flow.Launcher.Core/Plugin/PluginManager.cs +++ b/Flow.Launcher.Core/Plugin/PluginManager.cs @@ -18,7 +18,7 @@ using ISavable = Flow.Launcher.Plugin.ISavable; namespace Flow.Launcher.Core.Plugin { /// - /// The entry for managing Flow Launcher plugins + /// Class for co-ordinating and managing all plugin lifecycle. /// public static class PluginManager { diff --git a/Flow.Launcher/ProgressBoxEx.xaml.cs b/Flow.Launcher/ProgressBoxEx.xaml.cs index 840c8bade..119463348 100644 --- a/Flow.Launcher/ProgressBoxEx.xaml.cs +++ b/Flow.Launcher/ProgressBoxEx.xaml.cs @@ -19,32 +19,32 @@ namespace Flow.Launcher public static async Task ShowAsync(string caption, Func, Task> reportProgressAsync, Action cancelProgress = null) { - ProgressBoxEx prgBox = null; + ProgressBoxEx progressBox = null; try { if (!Application.Current.Dispatcher.CheckAccess()) { await Application.Current.Dispatcher.InvokeAsync(() => { - prgBox = new ProgressBoxEx(cancelProgress) + progressBox = new ProgressBoxEx(cancelProgress) { Title = caption }; - prgBox.TitleTextBlock.Text = caption; - prgBox.Show(); + progressBox.TitleTextBlock.Text = caption; + progressBox.Show(); }); } else { - prgBox = new ProgressBoxEx(cancelProgress) + progressBox = new ProgressBoxEx(cancelProgress) { Title = caption }; - prgBox.TitleTextBlock.Text = caption; - prgBox.Show(); + progressBox.TitleTextBlock.Text = caption; + progressBox.Show(); } - await reportProgressAsync(prgBox.ReportProgress).ConfigureAwait(false); + await reportProgressAsync(progressBox.ReportProgress).ConfigureAwait(false); } catch (Exception e) { @@ -58,12 +58,12 @@ namespace Flow.Launcher { await Application.Current.Dispatcher.InvokeAsync(() => { - prgBox?.Close(); + progressBox?.Close(); }); } else { - prgBox?.Close(); + progressBox?.Close(); } } } diff --git a/Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs b/Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs index 76d5eeafd..efbe8d7ba 100644 --- a/Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs +++ b/Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs @@ -205,7 +205,7 @@ namespace Flow.Launcher.Plugin.PluginsManager } } - private async Task DownloadFileAsync(string prgBoxTitle, string downloadUrl, string filePath, CancellationTokenSource cts, bool deleteFile = true, bool showProgress = true) + private async Task DownloadFileAsync(string progressBoxTitle, string downloadUrl, string filePath, CancellationTokenSource cts, bool deleteFile = true, bool showProgress = true) { if (deleteFile && File.Exists(filePath)) File.Delete(filePath); @@ -213,7 +213,7 @@ namespace Flow.Launcher.Plugin.PluginsManager if (showProgress) { var exceptionHappened = false; - await Context.API.ShowProgressBoxAsync(prgBoxTitle, + await Context.API.ShowProgressBoxAsync(progressBoxTitle, async (reportProgress) => { if (reportProgress == null)