using Flow.Launcher.Plugin.SharedModels; using JetBrains.Annotations; using System; using System.Collections.Generic; using System.ComponentModel; 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(); /// /// Run a shell command /// /// The command or program to run /// the shell type to run, e.g. powershell.exe /// Thrown when unable to find the file specified in the command /// Thrown when error occurs during the execution of the command void ShellRun(string cmd, string filename = "cmd.exe"); /// /// Copy Text to clipboard /// /// Text to save on clipboard public void CopyToClipboard(string text); /// /// Save everything, all of Flow Launcher and plugins' data and settings /// void SaveAppAllSettings(); /// /// Save all Flow's plugins settings /// void SavePluginSettings(); /// /// 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 the error message using Flow's standard error icon. /// /// Message title /// Optional message subtitle void ShowMsgError(string title, string subTitle = ""); /// /// Show the MainWindow when hiding /// void ShowMainWindow(); /// /// 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 /// [Obsolete("Unable to Retrieve correct return value")] event FlowLauncherGlobalKeyboardEventHandler GlobalKeyboardEvent; /// /// Register a callback for Global Keyboard Event /// /// public void RegisterGlobalKeyboardCallback(Func callback); /// /// Remove a callback for Global Keyboard Event /// /// public void RemoveGlobalKeyboardCallback(Func callback); /// /// 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 /// path to save downloaded 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); /// /// Check whether specific ActionKeyword is assigned to any of the plugin /// /// The actionkeyword for checking /// True if the actionkeyword is already assigned, False otherwise bool ActionKeywordAssigned(string actionKeyword); /// /// 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's setting. This is the method used to load settings from json in Flow. /// When the file is not exist, it will create a new instance for the specific type. /// /// Type for deserialization /// T LoadSettingJsonStorage() where T : new(); /// /// Save JsonStorage for current plugin's setting. This is the method used to save settings to json in Flow.Launcher /// This method will save the original instance loaded with LoadJsonStorage. /// This API call is for manually Save. Flow will automatically save all setting type that has called LoadSettingJsonStorage or SaveSettingJsonStorage previously. /// /// Type for Serialization /// void SaveSettingJsonStorage() where T : new(); /// /// Open directory in an explorer configured by user via Flow's Settings. The default is Windows Explorer /// /// Directory Path to open /// Extra FileName Info public void OpenDirectory(string DirectoryPath, string FileName = null); /// /// Opens the URL with the given Uri object. /// The browser and mode used is based on what's configured in Flow's default browser settings. /// public void OpenUrl(Uri url, bool? inPrivate = null); /// /// Opens the URL with the given string. /// The browser and mode used is based on what's configured in Flow's default browser settings. /// Non-C# plugins should use this method. /// public void OpenUrl(string url, bool? inPrivate = null); /// /// Opens the application URI with the given Uri object, e.g. obsidian://search-query-example /// public void OpenAppUri(Uri appUri); /// /// Opens the application URI with the given string, e.g. obsidian://search-query-example /// Non-C# plugins should use this method /// public void OpenAppUri(string appUri); } }