Flow.Launcher/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs

190 lines
7.6 KiB
C#
Raw Normal View History

2021-01-26 07:01:39 +00:00
using Flow.Launcher.Plugin.SharedModels;
2021-01-08 08:05:50 +00:00
using JetBrains.Annotations;
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
2014-07-05 15:10:34 +00:00
2020-04-21 09:12:17 +00:00
namespace Flow.Launcher.Plugin
2014-07-05 15:10:34 +00:00
{
2015-01-19 11:14:02 +00:00
/// <summary>
/// Public APIs that plugin can use
/// </summary>
2014-07-05 15:10:34 +00:00
public interface IPublicAPI
{
2015-01-19 11:14:02 +00:00
/// <summary>
2020-04-21 09:12:17 +00:00
/// Change Flow.Launcher query
2015-01-19 11:14:02 +00:00
/// </summary>
/// <param name="query">query text</param>
/// <param name="requery">
2020-04-22 10:26:09 +00:00
/// 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
2015-01-19 11:14:02 +00:00
/// </param>
2014-07-05 15:10:34 +00:00
void ChangeQuery(string query, bool requery = false);
/// <summary>
2020-04-22 10:26:09 +00:00
/// Restart Flow Launcher
2021-05-16 07:14:55 +00:00
/// </summary>
void RestartApp();
/// <summary>
2021-05-16 07:14:55 +00:00
/// Save everything, all of Flow Launcher and plugins' data and settings
/// </summary>
void SaveAppAllSettings();
/// <summary>
2021-05-16 07:14:55 +00:00
/// Save all Flow's plugins settings
/// </summary>
void SavePluginSettings();
2019-10-06 02:44:38 +00:00
/// <summary>
/// Reloads any Plugins that have the
/// IReloadable implemented. It refeshes
/// Plugin's in memory data with new content
/// added by user.
/// </summary>
Task ReloadAllPluginData();
2019-10-06 02:44:38 +00:00
/// <summary>
2020-04-22 10:26:09 +00:00
/// Check for new Flow Launcher update
/// </summary>
void CheckForNewUpdate();
/// <summary>
/// Show the error message using Flow's standard error icon.
/// </summary>
/// <param name="title">Message title</param>
/// <param name="subTitle">Optional message subtitle</param>
void ShowMsgError(string title, string subTitle = "");
2015-01-19 11:14:02 +00:00
/// <summary>
/// Show message box
/// </summary>
/// <param name="title">Message title</param>
/// <param name="subTitle">Message subtitle</param>
/// <param name="iconPath">Message icon path (relative path to your plugin folder)</param>
void ShowMsg(string title, string subTitle = "", string iconPath = "");
/// <summary>
/// Show message box
/// </summary>
/// <param name="title">Message title</param>
/// <param name="subTitle">Message subtitle</param>
/// <param name="iconPath">Message icon path (relative path to your plugin folder)</param>
/// <param name="useMainWindowAsOwner">when true will use main windows as the owner</param>
void ShowMsg(string title, string subTitle, string iconPath, bool useMainWindowAsOwner = true);
2014-07-05 15:10:34 +00:00
2015-01-19 11:14:02 +00:00
/// <summary>
/// Open setting dialog
/// </summary>
2016-05-22 18:16:39 +00:00
void OpenSettingDialog();
2015-02-04 15:16:41 +00:00
2015-01-19 11:14:02 +00:00
/// <summary>
/// Get translation of current language
/// You need to implement IPluginI18n if you want to support multiple languages for your plugin
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
2015-01-06 15:24:11 +00:00
string GetTranslation(string key);
2015-01-19 11:14:02 +00:00
/// <summary>
/// Get all loaded plugins
/// </summary>
/// <returns></returns>
2014-07-05 15:10:34 +00:00
List<PluginPair> GetAllPlugins();
2014-07-19 02:12:11 +00:00
2015-01-19 11:14:02 +00:00
/// <summary>
/// Fired after global keyboard events
/// if you want to hook something like Ctrl+R, you should use this event
/// </summary>
2020-04-21 12:16:10 +00:00
event FlowLauncherGlobalKeyboardEventHandler GlobalKeyboardEvent;
/// <summary>
2021-02-14 19:42:18 +00:00
/// Fuzzy Search the string with the given query. This is the core search mechanism Flow uses
/// </summary>
2021-02-14 19:42:18 +00:00
/// <param name="query">Query string</param>
/// <param name="stringToCompare">The string that will be compared against the query</param>
/// <returns>Match results</returns>
MatchResult FuzzySearch(string query, string stringToCompare);
/// <summary>
2021-02-14 19:42:18 +00:00
/// Http download the spefic url and return as string
/// </summary>
/// <param name="url">URL to call Http Get</param>
/// <param name="token">Cancellation Token</param>
/// <returns>Task to get string result</returns>
Task<string> HttpGetStringAsync(string url, CancellationToken token = default);
/// <summary>
2021-02-14 19:42:18 +00:00
/// Http download the spefic url and return as stream
/// </summary>
/// <param name="url">URL to call Http Get</param>
/// <param name="token">Cancellation Token</param>
/// <returns>Task to get stream result</returns>
Task<Stream> HttpGetStreamAsync(string url, CancellationToken token = default);
2021-01-08 08:05:50 +00:00
/// <summary>
/// Download the specific url to a cretain file path
/// </summary>
/// <param name="url">URL to download file</param>
/// <param name="token">place to store file</param>
/// <returns>Task showing the progress</returns>
Task HttpDownloadAsync([NotNull] string url, [NotNull] string filePath, CancellationToken token = default);
/// <summary>
/// Add ActionKeyword for specific plugin
/// </summary>
/// <param name="pluginId">ID for plugin that needs to add action keyword</param>
/// <param name="newActionKeyword">The actionkeyword that is supposed to be added</param>
void AddActionKeyword(string pluginId, string newActionKeyword);
/// <summary>
/// Remove ActionKeyword for specific plugin
/// </summary>
/// <param name="pluginId">ID for plugin that needs to remove action keyword</param>
/// <param name="newActionKeyword">The actionkeyword that is supposed to be removed</param>
void RemoveActionKeyword(string pluginId, string oldActionKeyword);
/// <summary>
2021-02-14 19:42:18 +00:00
/// Log debug message
/// Message will only be logged in Debug mode
/// </summary>
void LogDebug(string className, string message, [CallerMemberName] string methodName = "");
/// <summary>
2021-02-14 19:42:18 +00:00
/// Log info message
/// </summary>
void LogInfo(string className, string message, [CallerMemberName] string methodName = "");
/// <summary>
2021-02-14 19:42:18 +00:00
/// Log warning message
/// </summary>
void LogWarn(string className, string message, [CallerMemberName] string methodName = "");
/// <summary>
2021-02-14 19:42:18 +00:00
/// 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
/// </summary>
void LogException(string className, string message, Exception e, [CallerMemberName] string methodName = "");
/// <summary>
/// Load JsonStorage for current plugin's setting. This is the method used to load settings from json in Flow.
2021-05-13 05:37:41 +00:00
/// When the file is not exist, it will create a new instance for the specific type.
/// </summary>
/// <typeparam name="T">Type for deserialization</typeparam>
/// <returns></returns>
T LoadSettingJsonStorage<T>() where T : new();
/// <summary>
/// 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.
2021-05-16 07:11:29 +00:00
/// This API call is for manually Save. Flow will automatically save all setting type that has called LoadSettingJsonStorage or SaveSettingJsonStorage previously.
/// </summary>
/// <typeparam name="T">Type for Serialization</typeparam>
/// <returns></returns>
void SaveSettingJsonStorage<T>() where T : new();
2014-07-05 15:10:34 +00:00
}
}