Skip to content

Commit 1bd9bc2

Browse files
committed
Implement public api interface for consistent api functions
1 parent 0b8db59 commit 1bd9bc2

File tree

1 file changed

+80
-5
lines changed

1 file changed

+80
-5
lines changed

Flow.Launcher.Core/Plugin/JsonRPCV2Models/JsonRPCPublicAPI.cs

Lines changed: 80 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
using System;
22
using System.Collections.Generic;
3-
using System.ComponentModel;
43
using System.Diagnostics.CodeAnalysis;
54
using System.IO;
65
using System.Runtime.CompilerServices;
76
using System.Threading;
87
using System.Threading.Tasks;
8+
using System.Windows;
99
using Flow.Launcher.Plugin;
1010
using Flow.Launcher.Plugin.SharedModels;
1111

1212
namespace Flow.Launcher.Core.Plugin.JsonRPCV2Models
1313
{
14-
public class JsonRPCPublicAPI
14+
public class JsonRPCPublicAPI : IPublicAPI
1515
{
16-
private IPublicAPI _api;
16+
private readonly IPublicAPI _api;
1717

1818
public JsonRPCPublicAPI(IPublicAPI api)
1919
{
@@ -55,6 +55,14 @@ public Task ReloadAllPluginDataAsync()
5555
return _api.ReloadAllPluginData();
5656
}
5757

58+
/// <summary>
59+
/// The same as <see cref="ReloadAllPluginDataAsync"/>
60+
/// </summary>
61+
public Task ReloadAllPluginData()
62+
{
63+
return _api.ReloadAllPluginData();
64+
}
65+
5866
public void CheckForNewUpdate()
5967
{
6068
_api.CheckForNewUpdate();
@@ -80,6 +88,12 @@ public bool IsMainWindowVisible()
8088
return _api.IsMainWindowVisible();
8189
}
8290

91+
public event VisibilityChangedEventHandler VisibilityChanged
92+
{
93+
add { _api.VisibilityChanged += value; }
94+
remove { _api.VisibilityChanged -= value; }
95+
}
96+
8397
public void ShowMsg(string title, string subTitle = "", string iconPath = "")
8498
{
8599
_api.ShowMsg(title, subTitle, iconPath);
@@ -105,6 +119,15 @@ public List<PluginPair> GetAllPlugins()
105119
return _api.GetAllPlugins();
106120
}
107121

122+
public void RegisterGlobalKeyboardCallback(Func<int, int, SpecialKeyState, bool> callback)
123+
{
124+
_api.RegisterGlobalKeyboardCallback(callback);
125+
}
126+
127+
public void RemoveGlobalKeyboardCallback(Func<int, int, SpecialKeyState, bool> callback)
128+
{
129+
_api.RemoveGlobalKeyboardCallback(callback);
130+
}
108131

109132
public MatchResult FuzzySearch(string query, string stringToCompare)
110133
{
@@ -121,8 +144,7 @@ public Task<Stream> HttpGetStreamAsync(string url, CancellationToken token = def
121144
return _api.HttpGetStreamAsync(url, token);
122145
}
123146

124-
public Task HttpDownloadAsync([NotNull] string url, [NotNull] string filePath,
125-
CancellationToken token = default)
147+
public Task HttpDownloadAsync([NotNull] string url, [NotNull] string filePath, CancellationToken token = default)
126148
{
127149
return _api.HttpDownloadAsync(url, filePath, token);
128150
}
@@ -157,21 +179,74 @@ public void LogWarn(string className, string message, [CallerMemberName] string
157179
_api.LogWarn(className, message, methodName);
158180
}
159181

182+
public void LogException(string className, string message, Exception e, [CallerMemberName] string methodName = "")
183+
{
184+
_api.LogException(className, message, e, methodName);
185+
}
186+
187+
public T LoadSettingJsonStorage<T>() where T : new()
188+
{
189+
return _api.LoadSettingJsonStorage<T>();
190+
}
191+
192+
public void SaveSettingJsonStorage<T>() where T : new()
193+
{
194+
_api.SaveSettingJsonStorage<T>();
195+
}
196+
160197
public void OpenDirectory(string DirectoryPath, string FileNameOrFilePath = null)
161198
{
162199
_api.OpenDirectory(DirectoryPath, FileNameOrFilePath);
163200
}
164201

202+
public void OpenUrl(Uri url, bool? inPrivate = null)
203+
{
204+
_api.OpenUrl(url);
205+
}
165206

166207
public void OpenUrl(string url, bool? inPrivate = null)
167208
{
168209
_api.OpenUrl(url, inPrivate);
169210
}
170211

212+
public void OpenAppUri(Uri appUri)
213+
{
214+
_api.OpenAppUri(appUri);
215+
}
171216

172217
public void OpenAppUri(string appUri)
173218
{
174219
_api.OpenAppUri(appUri);
175220
}
221+
222+
public void ToggleGameMode()
223+
{
224+
_api.ToggleGameMode();
225+
}
226+
227+
public void SetGameMode(bool value)
228+
{
229+
_api.SetGameMode(value);
230+
}
231+
232+
public bool IsGameModeOn()
233+
{
234+
return _api.IsGameModeOn();
235+
}
236+
237+
public void ReQuery(bool reselect = true)
238+
{
239+
_api.ReQuery(reselect);
240+
}
241+
242+
public void BackToQueryResults()
243+
{
244+
_api.BackToQueryResults();
245+
}
246+
247+
public MessageBoxResult ShowMsgBox(string messageBoxText, string caption = "", MessageBoxButton button = MessageBoxButton.OK, MessageBoxImage icon = MessageBoxImage.None, MessageBoxResult defaultResult = MessageBoxResult.OK)
248+
{
249+
return _api.ShowMsgBox(messageBoxText, caption, button, icon, defaultResult);
250+
}
176251
}
177252
}

0 commit comments

Comments
 (0)