Add Executable Plugin Loader

This commit is contained in:
qianlifeng
2014-07-05 23:10:34 +08:00
parent f01de3a69d
commit 659ff866e1
17 changed files with 850 additions and 542 deletions

View File

@@ -17,9 +17,16 @@ namespace Wox.Plugin
get { return "csharp"; }
}
public static string ExecutableFile
{
get { return "ExecutableFile"; }
}
public static bool IsAllowed(string language)
{
return language.ToUpper() == Python.ToUpper() || language.ToUpper() == CSharp.ToUpper();
return language.ToUpper() == Python.ToUpper()
|| language.ToUpper() == CSharp.ToUpper()
|| language.ToUpper() == ExecutableFile.ToUpper();
}
}
}

38
Wox.Plugin/IPublicAPI.cs Normal file
View File

@@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.Windows.Documents;
namespace Wox.Plugin
{
public interface IPublicAPI
{
void PushResults(Query query,PluginMetadata plugin, List<Result> results);
bool ShellRun(string cmd);
void ChangeQuery(string query, bool requery = false);
void CloseApp();
void HideApp();
void ShowApp();
void ShowMsg(string title, string subTitle, string iconPath);
void OpenSettingDialog();
void ShowCurrentResultItemTooltip(string tooltip);
void StartLoadingBar();
void StopLoadingBar();
void InstallPlugin(string path);
void ReloadPlugins();
List<PluginPair> GetAllPlugins();
}
}

View File

@@ -7,31 +7,87 @@ namespace Wox.Plugin
{
public class PluginInitContext
{
public List<PluginPair> Plugins { get; set; }
public PluginMetadata CurrentPluginMetadata { get; set; }
public Action<string> ChangeQuery { get; set; }
public Action CloseApp { get; set; }
public Action HideApp { get; set; }
public Action ShowApp { get; set; }
public Action<string, string, string> ShowMsg { get; set; }
public Action OpenSettingDialog { get; set; }
public Action<string> ShowCurrentResultItemTooltip { get; set; }
/// <summary>
/// reload all plugins
/// Public APIs for plugin invocation
/// </summary>
public Action ReloadPlugins { get; set; }
public IPublicAPI API { get; set; }
public Action<string> InstallPlugin { get; set; }
#region Legacy APIs
public Action StartLoadingBar { get; set; }
public Action StopLoadingBar { get; set; }
[Obsolete("This method has been obsoleted, use API.ShellRun instead")]
public bool ShellRun(string cmd)
{
return API.ShellRun(cmd);
}
public Func<string, bool> ShellRun { get; set; }
[Obsolete("This method has been obsoleted, use API.OpenSettingDialog instead")]
public void ChangeQuery(string query, bool requery = false)
{
API.ChangeQuery(query, requery);
}
public Action<Query, List<Result>> PushResults { get; set; }
[Obsolete("This method has been obsoleted, use API.CloseApp instead")]
public void CloseApp()
{
API.CloseApp();
}
[Obsolete("This method has been obsoleted, use API.HideApp instead")]
public void HideApp()
{
API.HideApp();
}
[Obsolete("This method has been obsoleted, use API.ShowApp instead")]
public void ShowApp()
{
API.ShowApp();
}
[Obsolete("This method has been obsoleted, use API.OpenSettingDialog instead")]
public void ShowMsg(string title, string subTitle, string iconPath)
{
API.ShowMsg(title, subTitle, iconPath);
}
[Obsolete("This method has been obsoleted, use API.OpenSettingDialog instead")]
public void OpenSettingDialog()
{
API.OpenSettingDialog();
}
[Obsolete("This method has been obsoleted, use API.ShowCurrentResultItemTooltip instead")]
public void ShowCurrentResultItemTooltip(string tooltip)
{
API.ShowCurrentResultItemTooltip(tooltip);
}
[Obsolete("This method has been obsoleted, use API.StartLoadingBar instead")]
public void StartLoadingBar()
{
API.StartLoadingBar();
}
[Obsolete("This method has been obsoleted, use API.StopLoadingBar instead")]
public void StopLoadingBar()
{
API.StopLoadingBar();
}
[Obsolete("This method has been obsoleted, use API.InstallPlugin instead")]
public void InstallPlugin(string path)
{
API.InstallPlugin(path);
}
[Obsolete("This method has been obsoleted, use API.ReloadPlugins instead")]
public void ReloadPlugins()
{
API.ReloadPlugins();
}
#endregion
}
}

View File

@@ -3,6 +3,7 @@ using System.Collections;
using System.Collections.Generic;
namespace Wox.Plugin {
public class Result {
public string Title { get; set; }
public string SubTitle { get; set; }
@@ -41,7 +42,6 @@ namespace Wox.Plugin {
return Title + SubTitle;
}
public Result() {
}
@@ -52,6 +52,5 @@ namespace Wox.Plugin {
this.SubTitle = SubTitle;
}
}
}

View File

@@ -46,6 +46,7 @@
<ItemGroup>
<Compile Include="AllowedLanguage.cs" />
<Compile Include="IPlugin.cs" />
<Compile Include="IPublicAPI.cs" />
<Compile Include="ISettingProvider.cs" />
<Compile Include="PluginPair.cs" />
<Compile Include="PluginInitContext.cs" />