mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-08 12:18:50 +02:00
Merge branch 'master' of https://github.com/microsoft/Launcher into terminateLauncher
This commit is contained in:
@@ -154,6 +154,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.Plugin.Folder", "src\mo
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Wox.Launcher", "src\modules\launcher\Wox.Launcher\Wox.Launcher.vcxproj", "{E364F67B-BB12-4E91-B639-355866EBCD8B}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Wox.Launcher", "src\modules\launcher\Wox.Launcher\Wox.Launcher.vcxproj", "{E364F67B-BB12-4E91-B639-355866EBCD8B}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.Plugin.Indexer", "src\modules\launcher\Plugins\Wox.Plugin.Indexer\Wox.Plugin.Indexer.csproj", "{63C3CEA8-51FE-472E-B97C-B58F8B17DD51}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@@ -378,6 +380,14 @@ Global
|
|||||||
{E364F67B-BB12-4E91-B639-355866EBCD8B}.Release|Any CPU.ActiveCfg = Release|x64
|
{E364F67B-BB12-4E91-B639-355866EBCD8B}.Release|Any CPU.ActiveCfg = Release|x64
|
||||||
{E364F67B-BB12-4E91-B639-355866EBCD8B}.Release|x64.ActiveCfg = Release|x64
|
{E364F67B-BB12-4E91-B639-355866EBCD8B}.Release|x64.ActiveCfg = Release|x64
|
||||||
{E364F67B-BB12-4E91-B639-355866EBCD8B}.Release|x64.Build.0 = Release|x64
|
{E364F67B-BB12-4E91-B639-355866EBCD8B}.Release|x64.Build.0 = Release|x64
|
||||||
|
{63C3CEA8-51FE-472E-B97C-B58F8B17DD51}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{63C3CEA8-51FE-472E-B97C-B58F8B17DD51}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{63C3CEA8-51FE-472E-B97C-B58F8B17DD51}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||||
|
{63C3CEA8-51FE-472E-B97C-B58F8B17DD51}.Debug|x64.Build.0 = Debug|Any CPU
|
||||||
|
{63C3CEA8-51FE-472E-B97C-B58F8B17DD51}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{63C3CEA8-51FE-472E-B97C-B58F8B17DD51}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{63C3CEA8-51FE-472E-B97C-B58F8B17DD51}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
|
{63C3CEA8-51FE-472E-B97C-B58F8B17DD51}.Release|x64.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
@@ -419,6 +429,7 @@ Global
|
|||||||
{C21BFF9C-2C99-4B5F-B7C9-A5E6DDDB37B0} = {4AFC9975-2456-4C70-94A4-84073C1CED93}
|
{C21BFF9C-2C99-4B5F-B7C9-A5E6DDDB37B0} = {4AFC9975-2456-4C70-94A4-84073C1CED93}
|
||||||
{787B8AA6-CA93-4C84-96FE-DF31110AD1C4} = {4AFC9975-2456-4C70-94A4-84073C1CED93}
|
{787B8AA6-CA93-4C84-96FE-DF31110AD1C4} = {4AFC9975-2456-4C70-94A4-84073C1CED93}
|
||||||
{E364F67B-BB12-4E91-B639-355866EBCD8B} = {C140A3EF-6DBF-4084-9D4C-4EB5A99FEE68}
|
{E364F67B-BB12-4E91-B639-355866EBCD8B} = {C140A3EF-6DBF-4084-9D4C-4EB5A99FEE68}
|
||||||
|
{63C3CEA8-51FE-472E-B97C-B58F8B17DD51} = {4AFC9975-2456-4C70-94A4-84073C1CED93}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
SolutionGuid = {C3A2F9D1-7930-4EF4-A6FC-7EE0A99821D0}
|
SolutionGuid = {C3A2F9D1-7930-4EF4-A6FC-7EE0A99821D0}
|
||||||
|
|||||||
@@ -87,7 +87,7 @@
|
|||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||||
<WarningLevel>Level4</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
@@ -129,7 +129,7 @@
|
|||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||||
<WarningLevel>Level4</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<PreprocessorDefinitions>_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 3.7 KiB |
128
src/modules/launcher/Plugins/Wox.Plugin.Indexer/Main.cs
Normal file
128
src/modules/launcher/Plugins/Wox.Plugin.Indexer/Main.cs
Normal file
@@ -0,0 +1,128 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Wox.Plugin;
|
||||||
|
using System.IO;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using Wox.Infrastructure.Storage;
|
||||||
|
using Wox.Plugin.Indexer.SearchHelper;
|
||||||
|
using Microsoft.Search.Interop;
|
||||||
|
|
||||||
|
namespace Wox.Plugin.Indexer
|
||||||
|
{
|
||||||
|
class Main : IPlugin, ISavable, IPluginI18n
|
||||||
|
{
|
||||||
|
|
||||||
|
// This variable contains metadata about the Plugin
|
||||||
|
private PluginInitContext _context;
|
||||||
|
|
||||||
|
// This variable contains information about the context menus
|
||||||
|
private Settings _settings;
|
||||||
|
|
||||||
|
// Contains information about the plugin stored in json format
|
||||||
|
private PluginJsonStorage<Settings> _storage;
|
||||||
|
|
||||||
|
// To access Windows Search functionalities
|
||||||
|
private readonly WindowsSearchAPI _api = new WindowsSearchAPI();
|
||||||
|
|
||||||
|
// To save the configurations of plugins
|
||||||
|
public void Save()
|
||||||
|
{
|
||||||
|
_storage.Save();
|
||||||
|
}
|
||||||
|
|
||||||
|
// This function uses the Windows indexer and returns the list of results obtained
|
||||||
|
public List<Result> Query(Query query)
|
||||||
|
{
|
||||||
|
var results = new List<Result>();
|
||||||
|
if (!string.IsNullOrEmpty(query.Search))
|
||||||
|
{
|
||||||
|
var searchQuery = query.Search;
|
||||||
|
if (_settings.MaxSearchCount <= 0)
|
||||||
|
{
|
||||||
|
_settings.MaxSearchCount = 50;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var searchResultsList = _api.Search(searchQuery, maxCount: _settings.MaxSearchCount).ToList();
|
||||||
|
foreach (var searchResult in searchResultsList)
|
||||||
|
{
|
||||||
|
var path = searchResult.Path;
|
||||||
|
|
||||||
|
string workingDir = null;
|
||||||
|
if (_settings.UseLocationAsWorkingDir)
|
||||||
|
workingDir = Path.GetDirectoryName(path);
|
||||||
|
|
||||||
|
Result r = new Result();
|
||||||
|
r.Title = Path.GetFileName(path);
|
||||||
|
r.SubTitle = path;
|
||||||
|
r.IcoPath = path;
|
||||||
|
r.Action = c =>
|
||||||
|
{
|
||||||
|
bool hide;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Process.Start(new ProcessStartInfo
|
||||||
|
{
|
||||||
|
FileName = path,
|
||||||
|
UseShellExecute = true,
|
||||||
|
WorkingDirectory = workingDir
|
||||||
|
});
|
||||||
|
hide = true;
|
||||||
|
}
|
||||||
|
catch (Win32Exception)
|
||||||
|
{
|
||||||
|
var name = $"Plugin: {_context.CurrentPluginMetadata.Name}";
|
||||||
|
var msg = "Can't Open this file";
|
||||||
|
_context.API.ShowMsg(name, msg, string.Empty);
|
||||||
|
hide = false;
|
||||||
|
}
|
||||||
|
return hide;
|
||||||
|
};
|
||||||
|
r.ContextData = searchResult;
|
||||||
|
results.Add(r);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
results.Add(new Result
|
||||||
|
{
|
||||||
|
// TODO: Localize the string
|
||||||
|
Title = "Windows indexer plugin is not running",
|
||||||
|
IcoPath = "Images\\WindowsIndexerImg.bmp"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Init(PluginInitContext context)
|
||||||
|
{
|
||||||
|
// initialize the context of the plugin
|
||||||
|
_context = context;
|
||||||
|
_storage = new PluginJsonStorage<Settings>();
|
||||||
|
_settings = _storage.Load();
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Localize the strings
|
||||||
|
// Set the Plugin Title
|
||||||
|
public string GetTranslatedPluginTitle()
|
||||||
|
{
|
||||||
|
return "Windows Indexer Plugin";
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Localize the string
|
||||||
|
// Set the plugin Description
|
||||||
|
public string GetTranslatedPluginDescription()
|
||||||
|
{
|
||||||
|
return "Returns files and folders";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle("Wox.Plugin.Indexer")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("Wox.Plugin.Indexer")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2020")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[assembly: Guid("63c3cea8-51fe-472e-b97c-b58f8b17dd51")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Wox.Plugin.Indexer.SearchHelper
|
||||||
|
{
|
||||||
|
public class SearchResult
|
||||||
|
{
|
||||||
|
// Contains the Path of the file or folder
|
||||||
|
public string Path { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,99 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Data.OleDb;
|
||||||
|
using Microsoft.Search.Interop;
|
||||||
|
|
||||||
|
namespace Wox.Plugin.Indexer.SearchHelper
|
||||||
|
{
|
||||||
|
public class WindowsSearchAPI
|
||||||
|
{
|
||||||
|
public OleDbConnection conn;
|
||||||
|
public OleDbCommand command;
|
||||||
|
public OleDbDataReader WDSResults;
|
||||||
|
|
||||||
|
public IEnumerable<SearchResult> ExecuteQuery(ISearchQueryHelper queryHelper, string keyword)
|
||||||
|
{
|
||||||
|
// Generate SQL from our parameters, converting the userQuery from AQS->WHERE clause
|
||||||
|
string sqlQuery = queryHelper.GenerateSQLFromUserQuery(keyword);
|
||||||
|
|
||||||
|
// --- Perform the query ---
|
||||||
|
// create an OleDbConnection object which connects to the indexer provider with the windows application
|
||||||
|
using (conn = new OleDbConnection(queryHelper.ConnectionString))
|
||||||
|
{
|
||||||
|
// open the connection
|
||||||
|
conn.Open();
|
||||||
|
|
||||||
|
// now create an OleDB command object with the query we built above and the connection we just opened.
|
||||||
|
using (command = new OleDbCommand(sqlQuery, conn))
|
||||||
|
{
|
||||||
|
// execute the command, which returns the results as an OleDbDataReader.
|
||||||
|
using (WDSResults = command.ExecuteReader())
|
||||||
|
{
|
||||||
|
while (WDSResults.Read())
|
||||||
|
{
|
||||||
|
// col 0 is our path in display format
|
||||||
|
Console.WriteLine("{0}", WDSResults.GetString(0));
|
||||||
|
var result = new SearchResult { Path = WDSResults.GetString(0) };
|
||||||
|
|
||||||
|
yield return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void ModifyQueryHelper(ref ISearchQueryHelper queryHelper, string pattern)
|
||||||
|
{
|
||||||
|
// convert file pattern if it is not '*'. Don't create restriction for '*' as it includes all files.
|
||||||
|
if (pattern != "*")
|
||||||
|
{
|
||||||
|
pattern = pattern.Replace("*", "%");
|
||||||
|
pattern = pattern.Replace("?", "_");
|
||||||
|
|
||||||
|
if (pattern.Contains("%") || pattern.Contains("_"))
|
||||||
|
{
|
||||||
|
queryHelper.QueryWhereRestrictions += " AND System.FileName LIKE '" + pattern + "' ";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// if there are no wildcards we can use a contains which is much faster as it uses the index
|
||||||
|
queryHelper.QueryWhereRestrictions += " AND Contains(System.FileName, '" + pattern + "') ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void InitQueryHelper(out ISearchQueryHelper queryHelper, int maxCount)
|
||||||
|
{
|
||||||
|
// This uses the Microsoft.Search.Interop assembly
|
||||||
|
CSearchManager manager = new CSearchManager();
|
||||||
|
|
||||||
|
// SystemIndex catalog is the default catalog in Windows
|
||||||
|
ISearchCatalogManager catalogManager = manager.GetCatalog("SystemIndex");
|
||||||
|
|
||||||
|
// Get the ISearchQueryHelper which will help us to translate AQS --> SQL necessary to query the indexer
|
||||||
|
queryHelper = catalogManager.GetQueryHelper();
|
||||||
|
|
||||||
|
// Set the number of results we want. Don't set this property if all results are needed.
|
||||||
|
queryHelper.QueryMaxResults = maxCount;
|
||||||
|
|
||||||
|
// Set list of columns we want to display, getting the path presently
|
||||||
|
queryHelper.QuerySelectColumns = "System.ItemPathDisplay";
|
||||||
|
|
||||||
|
// Set additional query restriction
|
||||||
|
queryHelper.QueryWhereRestrictions = "AND scope='file:'";
|
||||||
|
|
||||||
|
// Set sorting order
|
||||||
|
queryHelper.QuerySorting = "System.DateModified DESC";
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<SearchResult> Search(string keyword, string pattern = "*", int maxCount = 100)
|
||||||
|
{
|
||||||
|
ISearchQueryHelper queryHelper;
|
||||||
|
InitQueryHelper(out queryHelper, maxCount);
|
||||||
|
ModifyQueryHelper(ref queryHelper, pattern);
|
||||||
|
return ExecuteQuery(queryHelper, keyword);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
23
src/modules/launcher/Plugins/Wox.Plugin.Indexer/Settings.cs
Normal file
23
src/modules/launcher/Plugins/Wox.Plugin.Indexer/Settings.cs
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Wox.Plugin.Indexer
|
||||||
|
{
|
||||||
|
public class Settings
|
||||||
|
{
|
||||||
|
public List<ContextMenu> ContextMenus = new List<ContextMenu>();
|
||||||
|
public int MaxSearchCount { get; set; } = 100;
|
||||||
|
public bool UseLocationAsWorkingDir { get; set; } = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ContextMenu
|
||||||
|
{
|
||||||
|
public string Name { get; set; }
|
||||||
|
public string Command { get; set; }
|
||||||
|
public string Argument { get; set; }
|
||||||
|
public string ImagePath { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{63C3CEA8-51FE-472E-B97C-B58F8B17DD51}</ProjectGuid>
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>Wox.Plugin.Indexer</RootNamespace>
|
||||||
|
<AssemblyName>Wox.Plugin.Indexer</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
<Deterministic>true</Deterministic>
|
||||||
|
<TargetFrameworkProfile />
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>..\..\..\..\..\x64\Debug\modules\launcher\Plugins\Wox.Plugin.Indexer\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>..\..\..\..\..\x64\Release\modules\launcher\Plugins\Wox.Plugin.Indexer\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="Microsoft.Search.Interop, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9f748985a6e9a7cb, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\..\..\..\packages\tlbimp-Microsoft.Search.Interop.1.0.0\lib\net45\Microsoft.Search.Interop.dll</HintPath>
|
||||||
|
<EmbedInteropTypes>True</EmbedInteropTypes>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Net.Http" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="Main.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="SearchHelper\SearchResult.cs" />
|
||||||
|
<Compile Include="SearchHelper\WindowsSearchAPI.cs" />
|
||||||
|
<Compile Include="Settings.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="packages.config" />
|
||||||
|
<None Include="plugin.json">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\Wox.Infrastructure\Wox.Infrastructure.csproj">
|
||||||
|
<Project>{4fd29318-a8ab-4d8f-aa47-60bc241b8da3}</Project>
|
||||||
|
<Name>Wox.Infrastructure</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\..\Wox.Plugin\Wox.Plugin.csproj">
|
||||||
|
<Project>{8451ecdd-2ea4-4966-bb0a-7bbc40138e80}</Project>
|
||||||
|
<Name>Wox.Plugin</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup />
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="Images\WindowsIndexerImg.bmp">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
</Project>
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<packages>
|
||||||
|
<package id="tlbimp-Microsoft.Search.Interop" version="1.0.0" targetFramework="net472" />
|
||||||
|
</packages>
|
||||||
12
src/modules/launcher/Plugins/Wox.Plugin.Indexer/plugin.json
Normal file
12
src/modules/launcher/Plugins/Wox.Plugin.Indexer/plugin.json
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"ID": "2140FC9819AD43A3A616E2735815C27C",
|
||||||
|
"ActionKeyword": "*",
|
||||||
|
"Name": "Windows Indexer",
|
||||||
|
"Description": "Search for files and folders",
|
||||||
|
"Author": "??",
|
||||||
|
"Version": "1.0.0",
|
||||||
|
"Language": "csharp",
|
||||||
|
"Website": "http://www.wox.one/plugin",
|
||||||
|
"ExecuteFileName": "Wox.Plugin.Indexer.dll",
|
||||||
|
"IcoPath": "Images\\WindowsIndexerImg.bmp"
|
||||||
|
}
|
||||||
@@ -107,8 +107,8 @@
|
|||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<PreBuildEvent>
|
<PreBuildEvent>
|
||||||
xcopy /Y $(PkgPinyin4DotNet)\pinyindb\unicode_to_hanyu_pinyin.txt $(TargetDir)pinyindb\
|
xcopy /Y "$(PkgPinyin4DotNet)\pinyindb\unicode_to_hanyu_pinyin.txt" "$(TargetDir)pinyindb\"
|
||||||
xcopy /Y $(PkgNLog_Schema)\content\NLog.xsd $(TargetDir)
|
xcopy /Y "$(PkgNLog_Schema)\content\NLog.xsd" "$(TargetDir)"
|
||||||
</PreBuildEvent>
|
</PreBuildEvent>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
|||||||
145
src/modules/launcher/Wox.Test/Plugins/WindowsIndexerTest.cs
Normal file
145
src/modules/launcher/Wox.Test/Plugins/WindowsIndexerTest.cs
Normal file
@@ -0,0 +1,145 @@
|
|||||||
|
using NUnit.Framework;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Data.OleDb;
|
||||||
|
using Microsoft.Search.Interop;
|
||||||
|
using Wox.Plugin.Indexer.SearchHelper;
|
||||||
|
|
||||||
|
namespace Wox.Test.Plugins
|
||||||
|
{
|
||||||
|
|
||||||
|
[TestFixture]
|
||||||
|
public class WindowsIndexerTest
|
||||||
|
{
|
||||||
|
private WindowsSearchAPI _api = new WindowsSearchAPI();
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void InitQueryHelper_ShouldInitialize_WhenFunctionIsCalled()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
int maxCount = 10;
|
||||||
|
ISearchQueryHelper queryHelper = null;
|
||||||
|
|
||||||
|
// Act
|
||||||
|
_api.InitQueryHelper(out queryHelper, maxCount);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.IsNotNull(queryHelper);
|
||||||
|
Assert.AreEqual(queryHelper.QueryMaxResults, maxCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ModifyQueryHelper_ShouldSetQueryHelper_WhenPatternIsAsterisk()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
ISearchQueryHelper queryHelper;
|
||||||
|
String pattern = "*";
|
||||||
|
_api.InitQueryHelper(out queryHelper, 10);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
_api.ModifyQueryHelper(ref queryHelper, pattern);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.IsFalse(queryHelper.QueryWhereRestrictions.Contains("LIKE"));
|
||||||
|
Assert.IsFalse(queryHelper.QueryWhereRestrictions.Contains("Contains"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ModifyQueryHelper_ShouldSetQueryHelper_WhenPatternContainsAsterisk()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
ISearchQueryHelper queryHelper;
|
||||||
|
String pattern = "tt*^&)";
|
||||||
|
_api.InitQueryHelper(out queryHelper, 10);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
_api.ModifyQueryHelper(ref queryHelper, pattern);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.IsTrue(queryHelper.QueryWhereRestrictions.Contains("LIKE"));
|
||||||
|
Assert.IsFalse(queryHelper.QueryWhereRestrictions.Contains("Contains"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ModifyQueryHelper_ShouldSetQueryHelper_WhenPatternContainsPercent()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
ISearchQueryHelper queryHelper;
|
||||||
|
String pattern = "tt%^&)";
|
||||||
|
_api.InitQueryHelper(out queryHelper, 10);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
_api.ModifyQueryHelper(ref queryHelper, pattern);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.IsTrue(queryHelper.QueryWhereRestrictions.Contains("LIKE"));
|
||||||
|
Assert.IsFalse(queryHelper.QueryWhereRestrictions.Contains("Contains"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ModifyQueryHelper_ShouldSetQueryHelper_WhenPatternContainsUnderScore()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
ISearchQueryHelper queryHelper;
|
||||||
|
String pattern = "tt_^&)";
|
||||||
|
_api.InitQueryHelper(out queryHelper, 10);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
_api.ModifyQueryHelper(ref queryHelper, pattern);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.IsTrue(queryHelper.QueryWhereRestrictions.Contains("LIKE"));
|
||||||
|
Assert.IsFalse(queryHelper.QueryWhereRestrictions.Contains("Contains"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ModifyQueryHelper_ShouldSetQueryHelper_WhenPatternContainsQuestionMark()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
ISearchQueryHelper queryHelper;
|
||||||
|
String pattern = "tt?^&)";
|
||||||
|
_api.InitQueryHelper(out queryHelper, 10);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
_api.ModifyQueryHelper(ref queryHelper, pattern);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.IsTrue(queryHelper.QueryWhereRestrictions.Contains("LIKE"));
|
||||||
|
Assert.IsFalse(queryHelper.QueryWhereRestrictions.Contains("Contains"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ModifyQueryHelper_ShouldSetQueryHelper_WhenPatternDoesNotContainSplSymbols()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
ISearchQueryHelper queryHelper;
|
||||||
|
String pattern = "tt^&)bc";
|
||||||
|
_api.InitQueryHelper(out queryHelper, 10);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
_api.ModifyQueryHelper(ref queryHelper, pattern);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.IsFalse(queryHelper.QueryWhereRestrictions.Contains("LIKE"));
|
||||||
|
Assert.IsTrue(queryHelper.QueryWhereRestrictions.Contains("Contains"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ExecuteQuery_ShouldDisposeAllConnections_AfterFunctionCall()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
ISearchQueryHelper queryHelper;
|
||||||
|
_api.InitQueryHelper(out queryHelper, 10);
|
||||||
|
_api.ModifyQueryHelper(ref queryHelper, "*");
|
||||||
|
string keyword = "test";
|
||||||
|
|
||||||
|
// Act
|
||||||
|
_api.ExecuteQuery(queryHelper, keyword);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.IsNull(_api.conn);
|
||||||
|
Assert.IsNull(_api.command);
|
||||||
|
Assert.IsNull(_api.WDSResults);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -38,6 +38,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="..\SolutionAssemblyInfo.cs">
|
<Compile Include="..\SolutionAssemblyInfo.cs">
|
||||||
@@ -45,10 +46,15 @@
|
|||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="FuzzyMatcherTest.cs" />
|
<Compile Include="FuzzyMatcherTest.cs" />
|
||||||
<Compile Include="Plugins\PluginInitTest.cs" />
|
<Compile Include="Plugins\PluginInitTest.cs" />
|
||||||
|
<Compile Include="Plugins\WindowsIndexerTest.cs" />
|
||||||
<Compile Include="QueryBuilderTest.cs" />
|
<Compile Include="QueryBuilderTest.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Plugins\Wox.Plugin.Indexer\Wox.Plugin.Indexer.csproj">
|
||||||
|
<Project>{63c3cea8-51fe-472e-b97c-b58f8b17dd51}</Project>
|
||||||
|
<Name>Wox.Plugin.Indexer</Name>
|
||||||
|
</ProjectReference>
|
||||||
<ProjectReference Include="..\Wox.Core\Wox.Core.csproj">
|
<ProjectReference Include="..\Wox.Core\Wox.Core.csproj">
|
||||||
<Project>{B749F0DB-8E75-47DB-9E5E-265D16D0C0D2}</Project>
|
<Project>{B749F0DB-8E75-47DB-9E5E-265D16D0C0D2}</Project>
|
||||||
<Name>Wox.Core</Name>
|
<Name>Wox.Core</Name>
|
||||||
@@ -72,6 +78,9 @@
|
|||||||
<PackageReference Include="NUnit3TestAdapter">
|
<PackageReference Include="NUnit3TestAdapter">
|
||||||
<Version>3.15.1</Version>
|
<Version>3.15.1</Version>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
<PackageReference Include="tlbimp-Microsoft.Search.Interop">
|
||||||
|
<Version>1.0.0</Version>
|
||||||
|
</PackageReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
|||||||
Reference in New Issue
Block a user