From e64771f70747bf324f31ac25e31c8c6b1ab0dbc1 Mon Sep 17 00:00:00 2001 From: Kevin Zhang Date: Tue, 6 Jul 2021 11:06:00 +0800 Subject: [PATCH 1/8] Move IAsyncReloadable.cs, IReloadable.cs, ISavable.cs to IFeatures --- Flow.Launcher.Plugin/{ => Interfaces}/Feature.cs | 2 ++ Flow.Launcher.Plugin/Interfaces/IAsyncReloadable.cs | 2 +- Flow.Launcher.Plugin/Interfaces/IReloadable.cs | 2 +- Flow.Launcher.Plugin/Interfaces/ISavable.cs | 4 ++-- 4 files changed, 6 insertions(+), 4 deletions(-) rename Flow.Launcher.Plugin/{ => Interfaces}/Feature.cs (91%) diff --git a/Flow.Launcher.Plugin/Feature.cs b/Flow.Launcher.Plugin/Interfaces/Feature.cs similarity index 91% rename from Flow.Launcher.Plugin/Feature.cs rename to Flow.Launcher.Plugin/Interfaces/Feature.cs index 81839d81613..d3b07f38b5e 100644 --- a/Flow.Launcher.Plugin/Feature.cs +++ b/Flow.Launcher.Plugin/Interfaces/Feature.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Collections.Specialized; +using System.Threading; namespace Flow.Launcher.Plugin { @@ -32,5 +33,6 @@ public class ResultUpdatedEventArgs : EventArgs { public List Results; public Query Query; + public CancellationToken Token { get; init; } } } diff --git a/Flow.Launcher.Plugin/Interfaces/IAsyncReloadable.cs b/Flow.Launcher.Plugin/Interfaces/IAsyncReloadable.cs index fc4ac471550..043de9ac008 100644 --- a/Flow.Launcher.Plugin/Interfaces/IAsyncReloadable.cs +++ b/Flow.Launcher.Plugin/Interfaces/IAsyncReloadable.cs @@ -13,7 +13,7 @@ namespace Flow.Launcher.Plugin /// The command that allows user to manual reload is exposed via Plugin.Sys, and /// it will call the plugins that have implemented this interface. /// - public interface IAsyncReloadable + public interface IAsyncReloadable : IFeatures { Task ReloadDataAsync(); } diff --git a/Flow.Launcher.Plugin/Interfaces/IReloadable.cs b/Flow.Launcher.Plugin/Interfaces/IReloadable.cs index 31611519cd1..ef421f5b2a2 100644 --- a/Flow.Launcher.Plugin/Interfaces/IReloadable.cs +++ b/Flow.Launcher.Plugin/Interfaces/IReloadable.cs @@ -15,7 +15,7 @@ /// If requiring reloading data asynchronously, please use the IAsyncReloadable interface /// /// - public interface IReloadable + public interface IReloadable : IFeatures { void ReloadData(); } diff --git a/Flow.Launcher.Plugin/Interfaces/ISavable.cs b/Flow.Launcher.Plugin/Interfaces/ISavable.cs index 6f408dc2ee9..2d13eaa6e1c 100644 --- a/Flow.Launcher.Plugin/Interfaces/ISavable.cs +++ b/Flow.Launcher.Plugin/Interfaces/ISavable.cs @@ -5,8 +5,8 @@ /// Otherwise if LoadSettingJsonStorage or SaveSettingJsonStorage has been callded, /// plugin settings will be automatically saved (see Flow.Launcher/PublicAPIInstance.SavePluginSettings) by Flow /// - public interface ISavable + public interface ISavable : IFeatures { void Save(); } -} +} \ No newline at end of file From 6f65e10a106584f860f083c7f65b3660224393e2 Mon Sep 17 00:00:00 2001 From: Kevin Zhang Date: Tue, 6 Jul 2021 11:15:39 +0800 Subject: [PATCH 2/8] add default token field and check token --- Flow.Launcher.Plugin/Interfaces/Feature.cs | 8 +++++--- Flow.Launcher/ViewModel/MainViewModel.cs | 5 ++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Flow.Launcher.Plugin/Interfaces/Feature.cs b/Flow.Launcher.Plugin/Interfaces/Feature.cs index d3b07f38b5e..eaffea28e62 100644 --- a/Flow.Launcher.Plugin/Interfaces/Feature.cs +++ b/Flow.Launcher.Plugin/Interfaces/Feature.cs @@ -5,7 +5,9 @@ namespace Flow.Launcher.Plugin { - public interface IFeatures { } + public interface IFeatures + { + } public interface IContextMenu : IFeatures { @@ -33,6 +35,6 @@ public class ResultUpdatedEventArgs : EventArgs { public List Results; public Query Query; - public CancellationToken Token { get; init; } + public CancellationToken Token { get; init; } = default; } -} +} \ No newline at end of file diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 1bdf6af1e10..b0bd496575f 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -135,14 +135,13 @@ private void RegisterResultsUpdatedEvent() var plugin = (IResultUpdated)pair.Plugin; plugin.ResultsUpdated += (s, e) => { - if (e.Query.RawQuery == QueryText) // TODO: allow cancellation + if (e.Query.RawQuery == QueryText && !e.Token.IsCancellationRequested) { PluginManager.UpdatePluginMetadata(e.Results, pair.Metadata, e.Query); - if (!_resultsUpdateChannelWriter.TryWrite(new ResultsForUpdate(e.Results, pair.Metadata, e.Query, _updateToken))) + if (!_resultsUpdateChannelWriter.TryWrite(new ResultsForUpdate(e.Results, pair.Metadata, e.Query, e.Token))) { Log.Error("MainViewModel", "Unable to add item to Result Update Queue"); } - ; } }; } From 3d47d2409d14ccc25e4dacfef7ac35cb85715667 Mon Sep 17 00:00:00 2001 From: Kevin Zhang Date: Wed, 7 Jul 2021 16:09:14 +0800 Subject: [PATCH 3/8] Move all interface to Features.cs --- Flow.Launcher.Plugin/Features.cs | 87 +++++++++++++++++++ Flow.Launcher.Plugin/Interfaces/Feature.cs | 40 --------- .../Interfaces/IAsyncReloadable.cs | 20 ----- .../Interfaces/IReloadable.cs | 22 ----- Flow.Launcher.Plugin/Interfaces/ISavable.cs | 12 --- 5 files changed, 87 insertions(+), 94 deletions(-) create mode 100644 Flow.Launcher.Plugin/Features.cs delete mode 100644 Flow.Launcher.Plugin/Interfaces/Feature.cs delete mode 100644 Flow.Launcher.Plugin/Interfaces/IAsyncReloadable.cs delete mode 100644 Flow.Launcher.Plugin/Interfaces/IReloadable.cs delete mode 100644 Flow.Launcher.Plugin/Interfaces/ISavable.cs diff --git a/Flow.Launcher.Plugin/Features.cs b/Flow.Launcher.Plugin/Features.cs new file mode 100644 index 00000000000..4b7e03718ce --- /dev/null +++ b/Flow.Launcher.Plugin/Features.cs @@ -0,0 +1,87 @@ +using System; +using System.Collections.Generic; +using System.Collections.Specialized; +using System.Threading; +using System.Threading.Tasks; + +namespace Flow.Launcher.Plugin +{ + public interface IFeatures + { + } + + public interface IContextMenu : IFeatures + { + List LoadContextMenus(Result selectedResult); + } + + /// + /// Represent plugins that support internationalization + /// + public interface IPluginI18n : IFeatures + { + string GetTranslatedPluginTitle(); + + string GetTranslatedPluginDescription(); + } + + public interface IResultUpdated : IFeatures + { + event ResultUpdatedEventHandler ResultsUpdated; + } + + public delegate void ResultUpdatedEventHandler(IResultUpdated sender, ResultUpdatedEventArgs e); + + public class ResultUpdatedEventArgs : EventArgs + { + public List Results; + public Query Query; + public CancellationToken Token { get; init; } = default; + } + + /// + /// This interface is to indicate and allow plugins to asyncronously reload their + /// in memory data cache or other mediums when user makes a new change + /// that is not immediately captured. For example, for BrowserBookmark and Program + /// plugin does not automatically detect when a user added a new bookmark or program, + /// so this interface's function is exposed to allow user manually do the reloading after + /// those new additions. + /// + /// The command that allows user to manual reload is exposed via Plugin.Sys, and + /// it will call the plugins that have implemented this interface. + /// + public interface IAsyncReloadable : IFeatures + { + Task ReloadDataAsync(); + } + + /// + /// This interface is to indicate and allow plugins to synchronously reload their + /// in memory data cache or other mediums when user makes a new change + /// that is not immediately captured. For example, for BrowserBookmark and Program + /// plugin does not automatically detect when a user added a new bookmark or program, + /// so this interface's function is exposed to allow user manually do the reloading after + /// those new additions. + /// + /// The command that allows user to manual reload is exposed via Plugin.Sys, and + /// it will call the plugins that have implemented this interface. + /// + /// + /// If requiring reloading data asynchronously, please use the IAsyncReloadable interface + /// + /// + public interface IReloadable : IFeatures + { + void ReloadData(); + } + + /// + /// Save addtional plugin data. Inherit this interface if additional data e.g. cache needs to be saved, + /// Otherwise if LoadSettingJsonStorage or SaveSettingJsonStorage has been callded, + /// plugin settings will be automatically saved (see Flow.Launcher/PublicAPIInstance.SavePluginSettings) by Flow + /// + public interface ISavable : IFeatures + { + void Save(); + } +} \ No newline at end of file diff --git a/Flow.Launcher.Plugin/Interfaces/Feature.cs b/Flow.Launcher.Plugin/Interfaces/Feature.cs deleted file mode 100644 index eaffea28e62..00000000000 --- a/Flow.Launcher.Plugin/Interfaces/Feature.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Collections.Specialized; -using System.Threading; - -namespace Flow.Launcher.Plugin -{ - public interface IFeatures - { - } - - public interface IContextMenu : IFeatures - { - List LoadContextMenus(Result selectedResult); - } - - /// - /// Represent plugins that support internationalization - /// - public interface IPluginI18n : IFeatures - { - string GetTranslatedPluginTitle(); - - string GetTranslatedPluginDescription(); - } - - public interface IResultUpdated : IFeatures - { - event ResultUpdatedEventHandler ResultsUpdated; - } - - public delegate void ResultUpdatedEventHandler(IResultUpdated sender, ResultUpdatedEventArgs e); - - public class ResultUpdatedEventArgs : EventArgs - { - public List Results; - public Query Query; - public CancellationToken Token { get; init; } = default; - } -} \ No newline at end of file diff --git a/Flow.Launcher.Plugin/Interfaces/IAsyncReloadable.cs b/Flow.Launcher.Plugin/Interfaces/IAsyncReloadable.cs deleted file mode 100644 index 043de9ac008..00000000000 --- a/Flow.Launcher.Plugin/Interfaces/IAsyncReloadable.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System.Threading.Tasks; - -namespace Flow.Launcher.Plugin -{ - /// - /// This interface is to indicate and allow plugins to asyncronously reload their - /// in memory data cache or other mediums when user makes a new change - /// that is not immediately captured. For example, for BrowserBookmark and Program - /// plugin does not automatically detect when a user added a new bookmark or program, - /// so this interface's function is exposed to allow user manually do the reloading after - /// those new additions. - /// - /// The command that allows user to manual reload is exposed via Plugin.Sys, and - /// it will call the plugins that have implemented this interface. - /// - public interface IAsyncReloadable : IFeatures - { - Task ReloadDataAsync(); - } -} diff --git a/Flow.Launcher.Plugin/Interfaces/IReloadable.cs b/Flow.Launcher.Plugin/Interfaces/IReloadable.cs deleted file mode 100644 index ef421f5b2a2..00000000000 --- a/Flow.Launcher.Plugin/Interfaces/IReloadable.cs +++ /dev/null @@ -1,22 +0,0 @@ -namespace Flow.Launcher.Plugin -{ - /// - /// This interface is to indicate and allow plugins to synchronously reload their - /// in memory data cache or other mediums when user makes a new change - /// that is not immediately captured. For example, for BrowserBookmark and Program - /// plugin does not automatically detect when a user added a new bookmark or program, - /// so this interface's function is exposed to allow user manually do the reloading after - /// those new additions. - /// - /// The command that allows user to manual reload is exposed via Plugin.Sys, and - /// it will call the plugins that have implemented this interface. - /// - /// - /// If requiring reloading data asynchronously, please use the IAsyncReloadable interface - /// - /// - public interface IReloadable : IFeatures - { - void ReloadData(); - } -} diff --git a/Flow.Launcher.Plugin/Interfaces/ISavable.cs b/Flow.Launcher.Plugin/Interfaces/ISavable.cs deleted file mode 100644 index 2d13eaa6e1c..00000000000 --- a/Flow.Launcher.Plugin/Interfaces/ISavable.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace Flow.Launcher.Plugin -{ - /// - /// Save addtional plugin data. Inherit this interface if additional data e.g. cache needs to be saved, - /// Otherwise if LoadSettingJsonStorage or SaveSettingJsonStorage has been callded, - /// plugin settings will be automatically saved (see Flow.Launcher/PublicAPIInstance.SavePluginSettings) by Flow - /// - public interface ISavable : IFeatures - { - void Save(); - } -} \ No newline at end of file From e24a5db8d6a01c3f5136a349d20acdc101dd5849 Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Wed, 7 Jul 2021 20:02:16 +1000 Subject: [PATCH 4/8] rename Feature.cs to Features.cs --- Flow.Launcher.Plugin/Interfaces/{Feature.cs => Features.cs} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Flow.Launcher.Plugin/Interfaces/{Feature.cs => Features.cs} (100%) diff --git a/Flow.Launcher.Plugin/Interfaces/Feature.cs b/Flow.Launcher.Plugin/Interfaces/Features.cs similarity index 100% rename from Flow.Launcher.Plugin/Interfaces/Feature.cs rename to Flow.Launcher.Plugin/Interfaces/Features.cs From 199aa75c5881af1c7dca68889da01c152cded208 Mon Sep 17 00:00:00 2001 From: Kevin Zhang Date: Wed, 7 Jul 2021 18:41:53 +0800 Subject: [PATCH 5/8] revert unexpected change --- Flow.Launcher.Plugin/Flow.Launcher.Plugin.csproj | 1 - 1 file changed, 1 deletion(-) diff --git a/Flow.Launcher.Plugin/Flow.Launcher.Plugin.csproj b/Flow.Launcher.Plugin/Flow.Launcher.Plugin.csproj index 15e35affd8d..e3d26f5d314 100644 --- a/Flow.Launcher.Plugin/Flow.Launcher.Plugin.csproj +++ b/Flow.Launcher.Plugin/Flow.Launcher.Plugin.csproj @@ -11,7 +11,6 @@ false false false - true From dea168924db87d76c9bb7351ccab4e1766977c81 Mon Sep 17 00:00:00 2001 From: Kevin Zhang Date: Thu, 8 Jul 2021 01:38:57 +0800 Subject: [PATCH 6/8] fix unexpected different token due to default --- Flow.Launcher/ViewModel/MainViewModel.cs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index b0bd496575f..2fd00224c0f 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -135,13 +135,17 @@ private void RegisterResultsUpdatedEvent() var plugin = (IResultUpdated)pair.Plugin; plugin.ResultsUpdated += (s, e) => { - if (e.Query.RawQuery == QueryText && !e.Token.IsCancellationRequested) + if (e.Query.RawQuery != QueryText || e.Token.IsCancellationRequested) { - PluginManager.UpdatePluginMetadata(e.Results, pair.Metadata, e.Query); - if (!_resultsUpdateChannelWriter.TryWrite(new ResultsForUpdate(e.Results, pair.Metadata, e.Query, e.Token))) - { - Log.Error("MainViewModel", "Unable to add item to Result Update Queue"); - } + return; + } + + var token = e.Token == default ? _updateToken : e.Token; + + PluginManager.UpdatePluginMetadata(e.Results, pair.Metadata, e.Query); + if (!_resultsUpdateChannelWriter.TryWrite(new ResultsForUpdate(e.Results, pair.Metadata, e.Query, token))) + { + Log.Error("MainViewModel", "Unable to add item to Result Update Queue"); } }; } @@ -459,7 +463,7 @@ private void QueryHistory() } private readonly IReadOnlyList _emptyResult = new List(); - + private async void QueryResults() { _updateSource?.Cancel(); @@ -553,7 +557,7 @@ async Task QueryTask(PluginPair plugin) await Task.Yield(); IReadOnlyList results = await PluginManager.QueryForPluginAsync(plugin, query, currentCancellationToken); - + currentCancellationToken.ThrowIfCancellationRequested(); results ??= _emptyResult; From c1778a54ed4de32b6139b2604860e0c042ed980b Mon Sep 17 00:00:00 2001 From: Kevin Zhang Date: Thu, 8 Jul 2021 01:47:20 +0800 Subject: [PATCH 7/8] Rearrange Interfaces --- Flow.Launcher.Plugin/Features.cs | 77 +----------------------- Flow.Launcher.Plugin/IAsyncReloadable.cs | 20 ++++++ Flow.Launcher.Plugin/IContextMenu.cs | 9 +++ Flow.Launcher.Plugin/IPluginI18n.cs | 12 ++++ Flow.Launcher.Plugin/IReloadable.cs | 22 +++++++ Flow.Launcher.Plugin/IResultUpdated.cs | 20 ++++++ Flow.Launcher.Plugin/ISavable.cs | 12 ++++ 7 files changed, 97 insertions(+), 75 deletions(-) create mode 100644 Flow.Launcher.Plugin/IAsyncReloadable.cs create mode 100644 Flow.Launcher.Plugin/IContextMenu.cs create mode 100644 Flow.Launcher.Plugin/IPluginI18n.cs create mode 100644 Flow.Launcher.Plugin/IReloadable.cs create mode 100644 Flow.Launcher.Plugin/IResultUpdated.cs create mode 100644 Flow.Launcher.Plugin/ISavable.cs diff --git a/Flow.Launcher.Plugin/Features.cs b/Flow.Launcher.Plugin/Features.cs index 4b7e03718ce..5b9c6a7b910 100644 --- a/Flow.Launcher.Plugin/Features.cs +++ b/Flow.Launcher.Plugin/Features.cs @@ -2,86 +2,13 @@ using System.Collections.Generic; using System.Collections.Specialized; using System.Threading; -using System.Threading.Tasks; namespace Flow.Launcher.Plugin { - public interface IFeatures - { - } - - public interface IContextMenu : IFeatures - { - List LoadContextMenus(Result selectedResult); - } - /// - /// Represent plugins that support internationalization + /// Base Interface for Flow's special plugin feature interface /// - public interface IPluginI18n : IFeatures - { - string GetTranslatedPluginTitle(); - - string GetTranslatedPluginDescription(); - } - - public interface IResultUpdated : IFeatures - { - event ResultUpdatedEventHandler ResultsUpdated; - } - - public delegate void ResultUpdatedEventHandler(IResultUpdated sender, ResultUpdatedEventArgs e); - - public class ResultUpdatedEventArgs : EventArgs - { - public List Results; - public Query Query; - public CancellationToken Token { get; init; } = default; - } - - /// - /// This interface is to indicate and allow plugins to asyncronously reload their - /// in memory data cache or other mediums when user makes a new change - /// that is not immediately captured. For example, for BrowserBookmark and Program - /// plugin does not automatically detect when a user added a new bookmark or program, - /// so this interface's function is exposed to allow user manually do the reloading after - /// those new additions. - /// - /// The command that allows user to manual reload is exposed via Plugin.Sys, and - /// it will call the plugins that have implemented this interface. - /// - public interface IAsyncReloadable : IFeatures - { - Task ReloadDataAsync(); - } - - /// - /// This interface is to indicate and allow plugins to synchronously reload their - /// in memory data cache or other mediums when user makes a new change - /// that is not immediately captured. For example, for BrowserBookmark and Program - /// plugin does not automatically detect when a user added a new bookmark or program, - /// so this interface's function is exposed to allow user manually do the reloading after - /// those new additions. - /// - /// The command that allows user to manual reload is exposed via Plugin.Sys, and - /// it will call the plugins that have implemented this interface. - /// - /// - /// If requiring reloading data asynchronously, please use the IAsyncReloadable interface - /// - /// - public interface IReloadable : IFeatures - { - void ReloadData(); - } - - /// - /// Save addtional plugin data. Inherit this interface if additional data e.g. cache needs to be saved, - /// Otherwise if LoadSettingJsonStorage or SaveSettingJsonStorage has been callded, - /// plugin settings will be automatically saved (see Flow.Launcher/PublicAPIInstance.SavePluginSettings) by Flow - /// - public interface ISavable : IFeatures + public interface IFeatures { - void Save(); } } \ No newline at end of file diff --git a/Flow.Launcher.Plugin/IAsyncReloadable.cs b/Flow.Launcher.Plugin/IAsyncReloadable.cs new file mode 100644 index 00000000000..bd4500a7ef6 --- /dev/null +++ b/Flow.Launcher.Plugin/IAsyncReloadable.cs @@ -0,0 +1,20 @@ +using System.Threading.Tasks; + +namespace Flow.Launcher.Plugin +{ + /// + /// This interface is to indicate and allow plugins to asyncronously reload their + /// in memory data cache or other mediums when user makes a new change + /// that is not immediately captured. For example, for BrowserBookmark and Program + /// plugin does not automatically detect when a user added a new bookmark or program, + /// so this interface's function is exposed to allow user manually do the reloading after + /// those new additions. + /// + /// The command that allows user to manual reload is exposed via Plugin.Sys, and + /// it will call the plugins that have implemented this interface. + /// + public interface IAsyncReloadable : IFeatures + { + Task ReloadDataAsync(); + } +} \ No newline at end of file diff --git a/Flow.Launcher.Plugin/IContextMenu.cs b/Flow.Launcher.Plugin/IContextMenu.cs new file mode 100644 index 00000000000..5befbf5c986 --- /dev/null +++ b/Flow.Launcher.Plugin/IContextMenu.cs @@ -0,0 +1,9 @@ +using System.Collections.Generic; + +namespace Flow.Launcher.Plugin +{ + public interface IContextMenu : IFeatures + { + List LoadContextMenus(Result selectedResult); + } +} \ No newline at end of file diff --git a/Flow.Launcher.Plugin/IPluginI18n.cs b/Flow.Launcher.Plugin/IPluginI18n.cs new file mode 100644 index 00000000000..e332d450eae --- /dev/null +++ b/Flow.Launcher.Plugin/IPluginI18n.cs @@ -0,0 +1,12 @@ +namespace Flow.Launcher.Plugin +{ + /// + /// Represent plugins that support internationalization + /// + public interface IPluginI18n : IFeatures + { + string GetTranslatedPluginTitle(); + + string GetTranslatedPluginDescription(); + } +} \ No newline at end of file diff --git a/Flow.Launcher.Plugin/IReloadable.cs b/Flow.Launcher.Plugin/IReloadable.cs new file mode 100644 index 00000000000..bd1ad406efd --- /dev/null +++ b/Flow.Launcher.Plugin/IReloadable.cs @@ -0,0 +1,22 @@ +namespace Flow.Launcher.Plugin +{ + /// + /// This interface is to indicate and allow plugins to synchronously reload their + /// in memory data cache or other mediums when user makes a new change + /// that is not immediately captured. For example, for BrowserBookmark and Program + /// plugin does not automatically detect when a user added a new bookmark or program, + /// so this interface's function is exposed to allow user manually do the reloading after + /// those new additions. + /// + /// The command that allows user to manual reload is exposed via Plugin.Sys, and + /// it will call the plugins that have implemented this interface. + /// + /// + /// If requiring reloading data asynchronously, please use the IAsyncReloadable interface + /// + /// + public interface IReloadable : IFeatures + { + void ReloadData(); + } +} \ No newline at end of file diff --git a/Flow.Launcher.Plugin/IResultUpdated.cs b/Flow.Launcher.Plugin/IResultUpdated.cs new file mode 100644 index 00000000000..fd21460ac55 --- /dev/null +++ b/Flow.Launcher.Plugin/IResultUpdated.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Threading; + +namespace Flow.Launcher.Plugin +{ + public interface IResultUpdated : IFeatures + { + event ResultUpdatedEventHandler ResultsUpdated; + } + + public delegate void ResultUpdatedEventHandler(IResultUpdated sender, ResultUpdatedEventArgs e); + + public class ResultUpdatedEventArgs : EventArgs + { + public List Results; + public Query Query; + public CancellationToken Token { get; init; } + } +} \ No newline at end of file diff --git a/Flow.Launcher.Plugin/ISavable.cs b/Flow.Launcher.Plugin/ISavable.cs new file mode 100644 index 00000000000..2d13eaa6e1c --- /dev/null +++ b/Flow.Launcher.Plugin/ISavable.cs @@ -0,0 +1,12 @@ +namespace Flow.Launcher.Plugin +{ + /// + /// Save addtional plugin data. Inherit this interface if additional data e.g. cache needs to be saved, + /// Otherwise if LoadSettingJsonStorage or SaveSettingJsonStorage has been callded, + /// plugin settings will be automatically saved (see Flow.Launcher/PublicAPIInstance.SavePluginSettings) by Flow + /// + public interface ISavable : IFeatures + { + void Save(); + } +} \ No newline at end of file From 7a318fed47adeffa2e40f04bef1d98019fdf1d95 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Thu, 8 Jul 2021 07:45:15 +1000 Subject: [PATCH 8/8] move plugins into Interfaces folder --- Flow.Launcher.Plugin/{ => Interfaces}/IAsyncPlugin.cs | 0 Flow.Launcher.Plugin/{ => Interfaces}/IAsyncReloadable.cs | 0 Flow.Launcher.Plugin/{ => Interfaces}/IContextMenu.cs | 0 Flow.Launcher.Plugin/{ => Interfaces}/IPlugin.cs | 0 Flow.Launcher.Plugin/{ => Interfaces}/IPluginI18n.cs | 0 Flow.Launcher.Plugin/{ => Interfaces}/IPublicAPI.cs | 0 Flow.Launcher.Plugin/{ => Interfaces}/IReloadable.cs | 0 Flow.Launcher.Plugin/{ => Interfaces}/IResultUpdated.cs | 0 Flow.Launcher.Plugin/{ => Interfaces}/ISavable.cs | 0 Flow.Launcher.Plugin/{ => Interfaces}/ISettingProvider.cs | 0 Flow.Launcher.Plugin/README.md | 2 +- 11 files changed, 1 insertion(+), 1 deletion(-) rename Flow.Launcher.Plugin/{ => Interfaces}/IAsyncPlugin.cs (100%) rename Flow.Launcher.Plugin/{ => Interfaces}/IAsyncReloadable.cs (100%) rename Flow.Launcher.Plugin/{ => Interfaces}/IContextMenu.cs (100%) rename Flow.Launcher.Plugin/{ => Interfaces}/IPlugin.cs (100%) rename Flow.Launcher.Plugin/{ => Interfaces}/IPluginI18n.cs (100%) rename Flow.Launcher.Plugin/{ => Interfaces}/IPublicAPI.cs (100%) rename Flow.Launcher.Plugin/{ => Interfaces}/IReloadable.cs (100%) rename Flow.Launcher.Plugin/{ => Interfaces}/IResultUpdated.cs (100%) rename Flow.Launcher.Plugin/{ => Interfaces}/ISavable.cs (100%) rename Flow.Launcher.Plugin/{ => Interfaces}/ISettingProvider.cs (100%) diff --git a/Flow.Launcher.Plugin/IAsyncPlugin.cs b/Flow.Launcher.Plugin/Interfaces/IAsyncPlugin.cs similarity index 100% rename from Flow.Launcher.Plugin/IAsyncPlugin.cs rename to Flow.Launcher.Plugin/Interfaces/IAsyncPlugin.cs diff --git a/Flow.Launcher.Plugin/IAsyncReloadable.cs b/Flow.Launcher.Plugin/Interfaces/IAsyncReloadable.cs similarity index 100% rename from Flow.Launcher.Plugin/IAsyncReloadable.cs rename to Flow.Launcher.Plugin/Interfaces/IAsyncReloadable.cs diff --git a/Flow.Launcher.Plugin/IContextMenu.cs b/Flow.Launcher.Plugin/Interfaces/IContextMenu.cs similarity index 100% rename from Flow.Launcher.Plugin/IContextMenu.cs rename to Flow.Launcher.Plugin/Interfaces/IContextMenu.cs diff --git a/Flow.Launcher.Plugin/IPlugin.cs b/Flow.Launcher.Plugin/Interfaces/IPlugin.cs similarity index 100% rename from Flow.Launcher.Plugin/IPlugin.cs rename to Flow.Launcher.Plugin/Interfaces/IPlugin.cs diff --git a/Flow.Launcher.Plugin/IPluginI18n.cs b/Flow.Launcher.Plugin/Interfaces/IPluginI18n.cs similarity index 100% rename from Flow.Launcher.Plugin/IPluginI18n.cs rename to Flow.Launcher.Plugin/Interfaces/IPluginI18n.cs diff --git a/Flow.Launcher.Plugin/IPublicAPI.cs b/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs similarity index 100% rename from Flow.Launcher.Plugin/IPublicAPI.cs rename to Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs diff --git a/Flow.Launcher.Plugin/IReloadable.cs b/Flow.Launcher.Plugin/Interfaces/IReloadable.cs similarity index 100% rename from Flow.Launcher.Plugin/IReloadable.cs rename to Flow.Launcher.Plugin/Interfaces/IReloadable.cs diff --git a/Flow.Launcher.Plugin/IResultUpdated.cs b/Flow.Launcher.Plugin/Interfaces/IResultUpdated.cs similarity index 100% rename from Flow.Launcher.Plugin/IResultUpdated.cs rename to Flow.Launcher.Plugin/Interfaces/IResultUpdated.cs diff --git a/Flow.Launcher.Plugin/ISavable.cs b/Flow.Launcher.Plugin/Interfaces/ISavable.cs similarity index 100% rename from Flow.Launcher.Plugin/ISavable.cs rename to Flow.Launcher.Plugin/Interfaces/ISavable.cs diff --git a/Flow.Launcher.Plugin/ISettingProvider.cs b/Flow.Launcher.Plugin/Interfaces/ISettingProvider.cs similarity index 100% rename from Flow.Launcher.Plugin/ISettingProvider.cs rename to Flow.Launcher.Plugin/Interfaces/ISettingProvider.cs diff --git a/Flow.Launcher.Plugin/README.md b/Flow.Launcher.Plugin/README.md index 3b4d1598a20..5c5b7c3edc1 100644 --- a/Flow.Launcher.Plugin/README.md +++ b/Flow.Launcher.Plugin/README.md @@ -3,4 +3,4 @@ * Defines base objects and interfaces for plugins * Plugin authors making C# plugins should reference this DLL via nuget -* Contains base commands used by all plugins +* Contains commands and models that can be used by plugins