mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 03:37:59 +01:00
Change plugin config file format (from ini to json)
This commit is contained in:
|
Before Width: | Height: | Size: 924 B After Width: | Height: | Size: 924 B |
@@ -60,7 +60,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
<None Include="plugin.ini">
|
<None Include="plugin.json">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
12
Plugins/Wox.Plugin.Clipboard/plugin.json
Normal file
12
Plugins/Wox.Plugin.Clipboard/plugin.json
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"ID":"D2D2C23B084D411DB66FE0C79D6C2A6C",
|
||||||
|
"ActionKeyword":"cb",
|
||||||
|
"Name":"Wox.Plugin.Clipboard",
|
||||||
|
"Description":"clipboard history search",
|
||||||
|
"Author":"qianlifeng",
|
||||||
|
"Version":"1.0",
|
||||||
|
"Language":"csharp",
|
||||||
|
"Website":"http://www.getwox.com",
|
||||||
|
"ExecuteFileName":"Wox.Plugin.Clipboard.dll"
|
||||||
|
}
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ namespace Wox.Plugin.Doc
|
|||||||
|
|
||||||
public void Init(PluginInitContext context)
|
public void Init(PluginInitContext context)
|
||||||
{
|
{
|
||||||
docsetBasePath = context.PluginMetadata.PluginDirecotry + @"Docset";
|
docsetBasePath = context.CurrentPluginMetadata.PluginDirecotry + @"Docset";
|
||||||
if (!Directory.Exists(docsetBasePath))
|
if (!Directory.Exists(docsetBasePath))
|
||||||
Directory.CreateDirectory(docsetBasePath);
|
Directory.CreateDirectory(docsetBasePath);
|
||||||
|
|
||||||
|
|||||||
@@ -80,7 +80,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
<None Include="plugin.ini">
|
<None Include="plugin.json">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
<None Include="README.md" />
|
<None Include="README.md" />
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
[plugin]
|
|
||||||
ActionKeyword = doc
|
|
||||||
Name = Dash.Doc
|
|
||||||
Author = qianlifeng
|
|
||||||
Version = 0.1
|
|
||||||
Language = csharp
|
|
||||||
Description = Offline doc, inspired by dash
|
|
||||||
ExecuteFile = Wox.Plugin.Doc.dll
|
|
||||||
11
Plugins/Wox.Plugin.Doc/plugin.json
Normal file
11
Plugins/Wox.Plugin.Doc/plugin.json
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"ID":"D2D2C23B084D411DB66FE0C79D6C2A6B",
|
||||||
|
"ActionKeyword":"doc",
|
||||||
|
"Name":"Dash.Doc",
|
||||||
|
"Description":"Offline doc, inspired by dash",
|
||||||
|
"Author":"qianlifeng",
|
||||||
|
"Version":"1.0",
|
||||||
|
"Language":"csharp",
|
||||||
|
"Website":"http://www.getwox.com",
|
||||||
|
"ExecuteFileName":"Wox.Plugin.Doc.dll"
|
||||||
|
}
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
[plugin]
|
|
||||||
ActionKeyword = cb
|
|
||||||
Name = clipboard monitor
|
|
||||||
Author = qianlifeng
|
|
||||||
Version = 0.1
|
|
||||||
Language = csharp
|
|
||||||
Description = clipboard monitor
|
|
||||||
ExecuteFile = Wox.Plugin.Clipboard.dll
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
[plugin]
|
|
||||||
ActionKeyword = movie
|
|
||||||
Name = douban
|
|
||||||
Author = qianlifeng
|
|
||||||
Version = 0.1
|
|
||||||
Language = python
|
|
||||||
Description = test
|
|
||||||
ExecuteFile = main.py
|
|
||||||
11
Plugins/Wox.Plugin.DouBan/plugin.json
Normal file
11
Plugins/Wox.Plugin.DouBan/plugin.json
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"ID":"D2D2C23B084D411DB66FE0C79D6C2A6D",
|
||||||
|
"ActionKeyword":"movie",
|
||||||
|
"Name":"Wox.Plugin.Douban.Movie",
|
||||||
|
"Description":"search douban movies",
|
||||||
|
"Author":"qianlifeng",
|
||||||
|
"Version":"1.0",
|
||||||
|
"Language":"python",
|
||||||
|
"Website":"http://www.getwox.com",
|
||||||
|
"ExecuteFileName":"main.py"
|
||||||
|
}
|
||||||
@@ -55,7 +55,7 @@ namespace Wox.Plugin.Everything
|
|||||||
this.context = context;
|
this.context = context;
|
||||||
|
|
||||||
LoadLibrary(Path.Combine(
|
LoadLibrary(Path.Combine(
|
||||||
Path.Combine(context.PluginMetadata.PluginDirecotry, (IntPtr.Size == 4) ? "x86" : "x64"),
|
Path.Combine(context.CurrentPluginMetadata.PluginDirecotry, (IntPtr.Size == 4) ? "x86" : "x64"),
|
||||||
"Everything.dll"
|
"Everything.dll"
|
||||||
));
|
));
|
||||||
//init everything
|
//init everything
|
||||||
|
|||||||
@@ -70,15 +70,15 @@
|
|||||||
<Name>Wox.Plugin</Name>
|
<Name>Wox.Plugin</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<None Include="plugin.ini">
|
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
|
||||||
</None>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="x64\Everything.dll" />
|
<Content Include="x64\Everything.dll" />
|
||||||
<Content Include="x86\Everything.dll" />
|
<Content Include="x86\Everything.dll" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="plugin.json">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<PostBuildEvent>xcopy /Y /E $(TargetDir)*.* $(SolutionDir)Wox\bin\Debug\Plugins\$(ProjectName)\
|
<PostBuildEvent>xcopy /Y /E $(TargetDir)*.* $(SolutionDir)Wox\bin\Debug\Plugins\$(ProjectName)\
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
[plugin]
|
|
||||||
ActionKeyword = ev
|
|
||||||
Name = everything
|
|
||||||
Author = qianlifeng
|
|
||||||
Version = 0.1
|
|
||||||
Language = csharp
|
|
||||||
Description = test
|
|
||||||
ExecuteFile = Wox.Plugin.Everything.dll
|
|
||||||
11
Plugins/Wox.Plugin.Everything/plugin.json
Normal file
11
Plugins/Wox.Plugin.Everything/plugin.json
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"ID":"D2D2C23B084D411DB66FE0C79D6C2A6E",
|
||||||
|
"ActionKeyword":"ev",
|
||||||
|
"Name":"Wox.Plugin.Everything",
|
||||||
|
"Description":"Search Everything",
|
||||||
|
"Author":"orzfly",
|
||||||
|
"Version":"1.0",
|
||||||
|
"Language":"csharp",
|
||||||
|
"Website":"http://www.getwox.com",
|
||||||
|
"ExecuteFileName":"Wox.Plugin.Everything.dll"
|
||||||
|
}
|
||||||
@@ -59,7 +59,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
<None Include="plugin.ini">
|
<None Include="plugin.json">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
[plugin]
|
|
||||||
ActionKeyword = fy
|
|
||||||
Name = Translator
|
|
||||||
Author = qianlifeng
|
|
||||||
Version = 0.1
|
|
||||||
Language = csharp
|
|
||||||
Description = Chinese and English Translator
|
|
||||||
ExecuteFile = Wox.Plugin.Fanyi.dll
|
|
||||||
11
Plugins/Wox.Plugin.Fanyi/plugin.json
Normal file
11
Plugins/Wox.Plugin.Fanyi/plugin.json
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"ID":"D2D2C23B084D411DB66FE0C79D6C2A6A",
|
||||||
|
"ActionKeyword":"fy",
|
||||||
|
"Name":"Baidu Translator",
|
||||||
|
"Description":"Translate Chinese and English",
|
||||||
|
"Author":"qianlifeng",
|
||||||
|
"Version":"1.0",
|
||||||
|
"Language":"csharp",
|
||||||
|
"Website":"http://www.getwox.com",
|
||||||
|
"ExecuteFileName":"Wox.Plugin.Fanyi.dll"
|
||||||
|
}
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
[plugin]
|
|
||||||
ActionKeyword = kill
|
|
||||||
Name = Wox.Kill
|
|
||||||
Author = qianlifeng
|
|
||||||
Version = 0.1
|
|
||||||
Language = python
|
|
||||||
Description = kill process
|
|
||||||
ExecuteFile = main.py
|
|
||||||
12
Plugins/Wox.Plugin.Kill/plugin.json
Normal file
12
Plugins/Wox.Plugin.Kill/plugin.json
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"ID":"D2D2C23B084D411DB66FE0C79D6C2A6G",
|
||||||
|
"ActionKeyword":"kill",
|
||||||
|
"Name":"Wox.Plugin.kill",
|
||||||
|
"Description":"kill running program",
|
||||||
|
"Author":"qianlifeng",
|
||||||
|
"Version":"1.0",
|
||||||
|
"Language":"python",
|
||||||
|
"Website":"http://www.getwox.com",
|
||||||
|
"ExecuteFileName":"main.py"
|
||||||
|
}
|
||||||
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
[plugin]
|
|
||||||
ActionKeyword = v2ex
|
|
||||||
Name = Wox.V2ex
|
|
||||||
Author = qianlifeng
|
|
||||||
Version = 0.1
|
|
||||||
Language = python
|
|
||||||
Description = workflow for v2ex
|
|
||||||
ExecuteFile = main.py
|
|
||||||
12
Plugins/Wox.Plugin.V2ex/plugin.json
Normal file
12
Plugins/Wox.Plugin.V2ex/plugin.json
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"ID":"D2D2C23B084D411DB66FE0C79D6C2A6H",
|
||||||
|
"ActionKeyword":"v2ex",
|
||||||
|
"Name":"Wox.Plugin.v2ex",
|
||||||
|
"Description":"v2ex viewer",
|
||||||
|
"Author":"qianlifeng",
|
||||||
|
"Version":"1.0",
|
||||||
|
"Language":"python",
|
||||||
|
"Website":"http://www.getwox.com",
|
||||||
|
"ExecuteFileName":"main.py"
|
||||||
|
}
|
||||||
|
|
||||||
@@ -82,7 +82,6 @@ namespace Python.Runtime {
|
|||||||
//====================================================================
|
//====================================================================
|
||||||
|
|
||||||
public static IntPtr tp_call(IntPtr ob, IntPtr args, IntPtr kw) {
|
public static IntPtr tp_call(IntPtr ob, IntPtr args, IntPtr kw) {
|
||||||
// todo: add fast type check!
|
|
||||||
IntPtr pytype = Runtime.PyObject_TYPE(ob);
|
IntPtr pytype = Runtime.PyObject_TYPE(ob);
|
||||||
DelegateObject self = (DelegateObject)GetManagedObject(pytype);
|
DelegateObject self = (DelegateObject)GetManagedObject(pytype);
|
||||||
CLRObject o = GetManagedObject(ob) as CLRObject;
|
CLRObject o = GetManagedObject(ob) as CLRObject;
|
||||||
|
|||||||
@@ -384,7 +384,6 @@ namespace Python.Runtime {
|
|||||||
/// </remarks>
|
/// </remarks>
|
||||||
|
|
||||||
public static PythonException GetException() {
|
public static PythonException GetException() {
|
||||||
// TODO: implement this.
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -330,7 +330,6 @@ namespace Python.Runtime {
|
|||||||
public static int ValidVersionTag = (1 << 19);
|
public static int ValidVersionTag = (1 << 19);
|
||||||
public static int IsAbstract = (1 << 20);
|
public static int IsAbstract = (1 << 20);
|
||||||
public static int HaveNewBuffer = (1 << 21);
|
public static int HaveNewBuffer = (1 << 21);
|
||||||
// TODO: Implement FastSubclass functions
|
|
||||||
public static int IntSubclass = (1 << 23);
|
public static int IntSubclass = (1 << 23);
|
||||||
public static int LongSubclass = (1 << 24);
|
public static int LongSubclass = (1 << 24);
|
||||||
public static int ListSubclass = (1 << 25);
|
public static int ListSubclass = (1 << 25);
|
||||||
|
|||||||
@@ -88,7 +88,6 @@ namespace Python.Runtime {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// hack for now... fix for 1.0
|
|
||||||
//return TypeManager.CreateSubType(args);
|
//return TypeManager.CreateSubType(args);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ namespace Python.Runtime {
|
|||||||
// Implements a Python type that represents a CLR method. Method objects
|
// Implements a Python type that represents a CLR method. Method objects
|
||||||
// support a subscript syntax [] to allow explicit overload selection.
|
// support a subscript syntax [] to allow explicit overload selection.
|
||||||
//========================================================================
|
//========================================================================
|
||||||
// TODO: ForbidPythonThreadsAttribute per method info
|
|
||||||
|
|
||||||
internal class MethodObject : ExtensionType {
|
internal class MethodObject : ExtensionType {
|
||||||
|
|
||||||
|
|||||||
@@ -37,11 +37,6 @@ namespace Python.Runtime {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// TODO: add all of the PyNumber_XXX methods.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ namespace Wox.Plugin.System
|
|||||||
{
|
{
|
||||||
results.Add(new Result()
|
results.Add(new Result()
|
||||||
{
|
{
|
||||||
Title = "Wox Setting Dialog",
|
Title = "Wox Setting",
|
||||||
Score = 100,
|
Score = 100,
|
||||||
IcoPath = "Images/app.png",
|
IcoPath = "Images/app.png",
|
||||||
Action = (contenxt) =>
|
Action = (contenxt) =>
|
||||||
|
|||||||
@@ -8,7 +8,8 @@ namespace Wox.Plugin
|
|||||||
public class PluginInitContext
|
public class PluginInitContext
|
||||||
{
|
{
|
||||||
public List<PluginPair> Plugins { get; set; }
|
public List<PluginPair> Plugins { get; set; }
|
||||||
public PluginMetadata PluginMetadata { get; set; }
|
public PluginMetadata CurrentPluginMetadata { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public Action<string> ChangeQuery { get; set; }
|
public Action<string> ChangeQuery { get; set; }
|
||||||
public Action CloseApp { get; set; }
|
public Action CloseApp { get; set; }
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
@@ -7,12 +8,29 @@ namespace Wox.Plugin
|
|||||||
{
|
{
|
||||||
public class PluginMetadata
|
public class PluginMetadata
|
||||||
{
|
{
|
||||||
|
private int configVersion = 1;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// if we need to change the plugin config in the futher, use this to
|
||||||
|
/// indicate config version
|
||||||
|
/// </summary>
|
||||||
|
public int ConfigVersion
|
||||||
|
{
|
||||||
|
get { return configVersion; }
|
||||||
|
set { configVersion = value; }
|
||||||
|
}
|
||||||
|
public string ID { get; set; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public string Author { get; set; }
|
public string Author { get; set; }
|
||||||
public string Version { get; set; }
|
public string Version { get; set; }
|
||||||
public string Language { get; set; }
|
public string Language { get; set; }
|
||||||
public string Description { get; set; }
|
public string Description { get; set; }
|
||||||
public string ExecuteFilePath { get; set; }
|
|
||||||
|
public string ExecuteFilePath
|
||||||
|
{
|
||||||
|
get { return Path.Combine(PluginDirecotry, ExecuteFileName); }
|
||||||
|
}
|
||||||
|
|
||||||
public string ExecuteFileName { get; set; }
|
public string ExecuteFileName { get; set; }
|
||||||
public string PluginDirecotry { get; set; }
|
public string PluginDirecotry { get; set; }
|
||||||
public string ActionKeyword { get; set; }
|
public string ActionKeyword { get; set; }
|
||||||
|
|||||||
2
Wox.sln
2
Wox.sln
@@ -25,7 +25,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.Plugin.Everything", "Pl
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.UAC", "Wox.UAC\Wox.UAC.csproj", "{C9BC17A0-C2BC-4185-AC1F-32E3352C1233}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.UAC", "Wox.UAC\Wox.UAC.csproj", "{C9BC17A0-C2BC-4185-AC1F-32E3352C1233}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.Plugin.Clipboard", "Plugins\Wox.Plugin.DotnetPluginTest\Wox.Plugin.Clipboard.csproj", "{8C14DC11-2737-4DCB-A121-5D7BDD57FEA2}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.Plugin.Clipboard", "Plugins\Wox.Plugin.Clipboard\Wox.Plugin.Clipboard.csproj", "{8C14DC11-2737-4DCB-A121-5D7BDD57FEA2}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
|||||||
@@ -168,7 +168,6 @@ namespace Wox.Helper
|
|||||||
metadata.Version = ini.GetSetting("plugin", "Version");
|
metadata.Version = ini.GetSetting("plugin", "Version");
|
||||||
metadata.PluginType = PluginType.ThirdParty;
|
metadata.PluginType = PluginType.ThirdParty;
|
||||||
metadata.ActionKeyword = ini.GetSetting("plugin", "ActionKeyword");
|
metadata.ActionKeyword = ini.GetSetting("plugin", "ActionKeyword");
|
||||||
metadata.ExecuteFilePath = directory + "\\" + ini.GetSetting("plugin", "ExecuteFile");
|
|
||||||
metadata.PluginDirecotry = directory + "\\";
|
metadata.PluginDirecotry = directory + "\\";
|
||||||
metadata.ExecuteFileName = ini.GetSetting("plugin", "ExecuteFile");
|
metadata.ExecuteFileName = ini.GetSetting("plugin", "ExecuteFile");
|
||||||
|
|
||||||
|
|||||||
@@ -32,9 +32,9 @@ namespace Wox
|
|||||||
{
|
{
|
||||||
resolvedPath = path;
|
resolvedPath = path;
|
||||||
}
|
}
|
||||||
else if (!string.IsNullOrEmpty(path) && File.Exists(pluginDirectory + path))
|
else if (!string.IsNullOrEmpty(path) && File.Exists(Path.Combine(pluginDirectory,path)))
|
||||||
{
|
{
|
||||||
resolvedPath = pluginDirectory + path;
|
resolvedPath = Path.Combine(pluginDirectory, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resolvedPath.ToLower().EndsWith(".exe") || resolvedPath.ToLower().EndsWith(".lnk"))
|
if (resolvedPath.ToLower().EndsWith(".exe") || resolvedPath.ToLower().EndsWith(".lnk"))
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ namespace Wox
|
|||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Registe hotkey: " + CommonStorage.Instance.UserSetting.Hotkey + " failed.");
|
MessageBox.Show("Registe hotkey: " + hotkeyStr + " failed.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ using System.IO;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using Wox.Helper;
|
using Wox.Helper;
|
||||||
using Wox.Infrastructure;
|
|
||||||
using Wox.Plugin;
|
using Wox.Plugin;
|
||||||
using Wox.Plugin.System;
|
using Wox.Plugin.System;
|
||||||
|
|
||||||
@@ -14,7 +14,7 @@ namespace Wox.PluginLoader
|
|||||||
public abstract class BasePluginLoader
|
public abstract class BasePluginLoader
|
||||||
{
|
{
|
||||||
private static string PluginPath = AppDomain.CurrentDomain.BaseDirectory + "Plugins";
|
private static string PluginPath = AppDomain.CurrentDomain.BaseDirectory + "Plugins";
|
||||||
private static string PluginConfigName = "plugin.ini";
|
private static string PluginConfigName = "plugin.json";
|
||||||
protected static List<PluginMetadata> pluginMetadatas = new List<PluginMetadata>();
|
protected static List<PluginMetadata> pluginMetadatas = new List<PluginMetadata>();
|
||||||
public abstract List<PluginPair> LoadPlugin();
|
public abstract List<PluginPair> LoadPlugin();
|
||||||
|
|
||||||
@@ -36,7 +36,6 @@ namespace Wox.PluginLoader
|
|||||||
metadata.PluginType = PluginType.System;
|
metadata.PluginType = PluginType.System;
|
||||||
metadata.ActionKeyword = "*";
|
metadata.ActionKeyword = "*";
|
||||||
metadata.ExecuteFileName = "Wox.Plugin.System.dll";
|
metadata.ExecuteFileName = "Wox.Plugin.System.dll";
|
||||||
metadata.ExecuteFilePath = AppDomain.CurrentDomain.BaseDirectory + metadata.ExecuteFileName;
|
|
||||||
metadata.PluginDirecotry = AppDomain.CurrentDomain.BaseDirectory;
|
metadata.PluginDirecotry = AppDomain.CurrentDomain.BaseDirectory;
|
||||||
pluginMetadatas.Add(metadata);
|
pluginMetadatas.Add(metadata);
|
||||||
}
|
}
|
||||||
@@ -49,84 +48,67 @@ namespace Wox.PluginLoader
|
|||||||
string[] directories = Directory.GetDirectories(PluginPath);
|
string[] directories = Directory.GetDirectories(PluginPath);
|
||||||
foreach (string directory in directories)
|
foreach (string directory in directories)
|
||||||
{
|
{
|
||||||
PluginMetadata metadata = GetMetadataFromIni(directory);
|
PluginMetadata metadata = GetMetadataFromJson(directory);
|
||||||
if (metadata != null) pluginMetadatas.Add(metadata);
|
if (metadata != null) pluginMetadatas.Add(metadata);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static PluginMetadata GetMetadataFromIni(string directory)
|
private static PluginMetadata GetMetadataFromJson(string pluginDirectory)
|
||||||
{
|
{
|
||||||
string iniPath = directory + "\\" + PluginConfigName;
|
string configPath = Path.Combine(pluginDirectory, PluginConfigName);
|
||||||
|
PluginMetadata metadata;
|
||||||
|
|
||||||
if (!File.Exists(iniPath))
|
if (!File.Exists(configPath))
|
||||||
{
|
{
|
||||||
Log.Error(string.Format("parse plugin {0} failed: didn't find config file.", iniPath));
|
Log.Error(string.Format("parse plugin {0} failed: didn't find config file.", configPath));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
PluginMetadata metadata = new PluginMetadata();
|
metadata = JsonConvert.DeserializeObject<PluginMetadata>(File.ReadAllText(configPath));
|
||||||
IniParser ini = new IniParser(iniPath);
|
|
||||||
metadata.Name = ini.GetSetting("plugin", "Name");
|
|
||||||
metadata.Author = ini.GetSetting("plugin", "Author");
|
|
||||||
metadata.Description = ini.GetSetting("plugin", "Description");
|
|
||||||
metadata.Language = ini.GetSetting("plugin", "Language");
|
|
||||||
metadata.Version = ini.GetSetting("plugin", "Version");
|
|
||||||
metadata.PluginType = PluginType.ThirdParty;
|
metadata.PluginType = PluginType.ThirdParty;
|
||||||
metadata.ActionKeyword = ini.GetSetting("plugin", "ActionKeyword");
|
metadata.PluginDirecotry = pluginDirectory;
|
||||||
metadata.ExecuteFilePath = directory + "\\" + ini.GetSetting("plugin", "ExecuteFile");
|
|
||||||
metadata.PluginDirecotry = directory + "\\";
|
|
||||||
metadata.ExecuteFileName = ini.GetSetting("plugin", "ExecuteFile");
|
|
||||||
|
|
||||||
if (!AllowedLanguage.IsAllowed(metadata.Language))
|
|
||||||
{
|
|
||||||
string error = string.Format("Parse ini {0} failed: invalid language {1}", iniPath,
|
|
||||||
metadata.Language);
|
|
||||||
Log.Error(error);
|
|
||||||
#if (DEBUG)
|
|
||||||
{
|
|
||||||
throw new WoxException(error);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (!File.Exists(metadata.ExecuteFilePath))
|
|
||||||
{
|
|
||||||
string error = string.Format("Parse ini {0} failed: ExecuteFilePath didn't exist {1}", iniPath,
|
|
||||||
metadata.ExecuteFilePath);
|
|
||||||
Log.Error(error);
|
|
||||||
#if (DEBUG)
|
|
||||||
{
|
|
||||||
throw new WoxException(error);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return metadata;
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
Log.Error(string.Format("Parse ini {0} failed: {1}", iniPath, e.Message));
|
string error = string.Format("Parse plugin config {0} failed: json format is not valid", configPath);
|
||||||
|
Log.Error(error);
|
||||||
#if (DEBUG)
|
#if (DEBUG)
|
||||||
{
|
{
|
||||||
throw;
|
throw new WoxException(error);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (!AllowedLanguage.IsAllowed(metadata.Language))
|
||||||
|
{
|
||||||
|
string error = string.Format("Parse plugin config {0} failed: invalid language {1}", configPath,
|
||||||
|
metadata.Language);
|
||||||
|
Log.Error(error);
|
||||||
|
#if (DEBUG)
|
||||||
|
{
|
||||||
|
throw new WoxException(error);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (!File.Exists(metadata.ExecuteFilePath))
|
||||||
|
{
|
||||||
|
string error = string.Format("Parse plugin config {0} failed: ExecuteFile {1} didn't exist", configPath,
|
||||||
|
metadata.ExecuteFilePath);
|
||||||
|
Log.Error(error);
|
||||||
|
#if (DEBUG)
|
||||||
|
{
|
||||||
|
throw new WoxException(error);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
///// <summary>
|
|
||||||
///// Change python execute file name to unique file name using GUID
|
|
||||||
///// this is because if two pythong plugin use the same
|
|
||||||
///// </summary>
|
|
||||||
///// <param name="metadata"></param>
|
|
||||||
///// <returns></returns>
|
|
||||||
//private static PluginMetadata filterPythonMetadata(PluginMetadata metadata)
|
|
||||||
//{
|
|
||||||
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ namespace Wox.PluginLoader
|
|||||||
ThreadPool.QueueUserWorkItem(o => plugin1.Init(new PluginInitContext()
|
ThreadPool.QueueUserWorkItem(o => plugin1.Init(new PluginInitContext()
|
||||||
{
|
{
|
||||||
Plugins = plugins,
|
Plugins = plugins,
|
||||||
PluginMetadata = metadata,
|
CurrentPluginMetadata = metadata,
|
||||||
ChangeQuery = s => App.Window.ChangeQuery(s),
|
ChangeQuery = s => App.Window.ChangeQuery(s),
|
||||||
CloseApp = App.Window.CloseApp,
|
CloseApp = App.Window.CloseApp,
|
||||||
HideApp = App.Window.HideApp,
|
HideApp = App.Window.HideApp,
|
||||||
|
|||||||
Reference in New Issue
Block a user