mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Added solution for executable plugins
This commit is contained in:
parent
11ecf20f89
commit
ae121895e9
4 changed files with 61 additions and 1 deletions
45
Wox.Core/Plugin/ExecutablePlugin.cs
Normal file
45
Wox.Core/Plugin/ExecutablePlugin.cs
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using Wox.Core.UserSettings;
|
||||
using Wox.Plugin;
|
||||
|
||||
namespace Wox.Core.Plugin
|
||||
{
|
||||
internal class ExecutablePlugin : JsonRPCPlugin
|
||||
{
|
||||
private readonly ProcessStartInfo _startInfo;
|
||||
public override string SupportedLanguage { get; set; } = AllowedLanguage.Executable;
|
||||
|
||||
public ExecutablePlugin(string filename)
|
||||
{
|
||||
_startInfo = new ProcessStartInfo
|
||||
{
|
||||
FileName = filename,
|
||||
UseShellExecute = false,
|
||||
CreateNoWindow = true,
|
||||
RedirectStandardOutput = true,
|
||||
RedirectStandardError = true
|
||||
};
|
||||
}
|
||||
|
||||
protected override string ExecuteQuery(Query query)
|
||||
{
|
||||
JsonRPCServerRequestModel request = new JsonRPCServerRequestModel
|
||||
{
|
||||
Method = "query",
|
||||
Parameters = new object[] { query.Search },
|
||||
HttpProxy = HttpProxy.Instance
|
||||
};
|
||||
|
||||
_startInfo.Arguments = $"\"{request}\"";
|
||||
|
||||
return Execute(_startInfo);
|
||||
}
|
||||
|
||||
protected override string ExecuteCallback(JsonRPCRequestModel rpcRequest)
|
||||
{
|
||||
_startInfo.Arguments = $"\"{rpcRequest}\"";
|
||||
return Execute(_startInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -63,7 +63,8 @@ namespace Wox.Core.Plugin
|
|||
{
|
||||
_settings = settings;
|
||||
var plugins = PluginsLoader.PythonPlugins(_metadatas, _settings.PythonDirectory);
|
||||
AllPlugins = AllPlugins.Concat(plugins).ToList();
|
||||
var executable_plugins = PluginsLoader.ExecutablePlugins(_metadatas);
|
||||
AllPlugins = AllPlugins.Concat(plugins).Concat(executable_plugins).ToList();
|
||||
_settings.UpdatePluginSettings(AllPlugins);
|
||||
|
||||
//load plugin i18n languages
|
||||
|
|
|
|||
|
|
@ -110,5 +110,18 @@ namespace Wox.Core.Plugin
|
|||
});
|
||||
return plugins;
|
||||
}
|
||||
|
||||
public static IEnumerable<PluginPair> ExecutablePlugins(IEnumerable<PluginMetadata> source)
|
||||
{
|
||||
var metadatas = source.Where(o => o.Language.ToUpper() == AllowedLanguage.Executable);
|
||||
|
||||
var plugins = metadatas.Select(metadata => new PluginPair
|
||||
{
|
||||
Plugin = new ExecutablePlugin(metadata.ExecuteFilePath),
|
||||
Metadata = metadata
|
||||
});
|
||||
return plugins;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -65,6 +65,7 @@
|
|||
<Link>Properties\SolutionAssemblyInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="APIServer.cs" />
|
||||
<Compile Include="Plugin\ExecutablePlugin.cs" />
|
||||
<Compile Include="Plugin\PluginsLoader.cs" />
|
||||
<Compile Include="Updater\Release.cs" />
|
||||
<Compile Include="Updater\UpdaterManager.cs" />
|
||||
|
|
|
|||
Loading…
Reference in a new issue