using Flow.Launcher.Plugin.SharedModels; using JetBrains.Annotations; using System; using System.Collections.Generic; using System.IO; using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; namespace Flow.Launcher.Plugin { /// /// Public APIs that plugin can use /// public interface IPublicAPI { /// /// Change Flow.Launcher query /// /// query text /// /// force requery By default, Flow Launcher will not fire query if your query is same with existing one. /// Set this to true to force Flow Launcher requerying /// void ChangeQuery(string query, bool requery = false); /// /// Restart Flow Launcher /// void RestartApp(); /// /// Save all Flow Launcher settings /// void SaveAppAllSettings(); /// /// Reloads any Plugins that have the /// IReloadable implemented. It refeshes /// Plugin's in memory data with new content /// added by user. /// Task ReloadAllPluginData(); /// /// Check for new Flow Launcher update /// void CheckForNewUpdate(); /// /// Show message box /// /// Message title /// Message subtitle /// Message icon path (relative path to your plugin folder) void ShowMsg(string title, string subTitle = "", string iconPath = ""); /// /// Show message box /// /// Message title /// Message subtitle /// Message icon path (relative path to your plugin folder) /// when true will use main windows as the owner void ShowMsg(string title, string subTitle, string iconPath, bool useMainWindowAsOwner = true); /// /// Open setting dialog /// void OpenSettingDialog(); /// /// Get translation of current language /// You need to implement IPluginI18n if you want to support multiple languages for your plugin /// /// /// string GetTranslation(string key); /// /// Get all loaded plugins /// /// List GetAllPlugins(); /// /// Fired after global keyboard events /// if you want to hook something like Ctrl+R, you should use this event /// event FlowLauncherGlobalKeyboardEventHandler GlobalKeyboardEvent; /// /// Fuzzy Search the string with the given query. This is the core search mechanism Flow uses /// /// Query string /// The string that will be compared against the query /// Match results MatchResult FuzzySearch(string query, string stringToCompare); /// /// Http download the spefic url and return as string /// /// URL to call Http Get /// Cancellation Token /// Task to get string result Task HttpGetStringAsync(string url, CancellationToken token = default); /// /// Http download the spefic url and return as stream /// /// URL to call Http Get /// Cancellation Token /// Task to get stream result Task HttpGetStreamAsync(string url, CancellationToken token = default); /// /// Download the specific url to a cretain file path /// /// URL to download file /// place to store file /// Task showing the progress Task HttpDownloadAsync([NotNull] string url, [NotNull] string filePath, CancellationToken token = default); /// /// Add ActionKeyword for specific plugin /// /// ID for plugin that needs to add action keyword /// The actionkeyword that is supposed to be added void AddActionKeyword(string pluginId, string newActionKeyword); /// /// Remove ActionKeyword for specific plugin /// /// ID for plugin that needs to remove action keyword /// The actionkeyword that is supposed to be removed void RemoveActionKeyword(string pluginId, string oldActionKeyword); /// /// Log debug message /// Message will only be logged in Debug mode /// void LogDebug(string className, string message, [CallerMemberName] string methodName = ""); /// /// Log info message /// void LogInfo(string className, string message, [CallerMemberName] string methodName = ""); /// /// Log warning message /// void LogWarn(string className, string message, [CallerMemberName] string methodName = ""); /// /// Log an Exception. Will throw if in debug mode so developer will be aware, /// otherwise logs the eror message. This is the primary logging method used for Flow /// void LogException(string className, string message, Exception e, [CallerMemberName] string methodName = ""); /// /// Load JsonStorage for current plugin. This is the method used to load settings from json in Flow /// /// Type for deserialization /// T LoadJsonStorage() where T : new(); /// /// Save JsonStorage for current plugin. This is the method used to save settings to json in Flow /// /// Type for Serialization /// void SaveJsonStorage(T setting) where T : new(); } }