diff --git a/src/modules/launcher/Plugins/indexer/Images/WindowsIndexerImg.bmp b/src/modules/launcher/Plugins/indexer/Images/WindowsIndexerImg.bmp deleted file mode 100644 index 78a015715e..0000000000 Binary files a/src/modules/launcher/Plugins/indexer/Images/WindowsIndexerImg.bmp and /dev/null differ diff --git a/src/modules/launcher/Plugins/indexer/Main.cs b/src/modules/launcher/Plugins/indexer/Main.cs deleted file mode 100644 index 652af40c40..0000000000 --- a/src/modules/launcher/Plugins/indexer/Main.cs +++ /dev/null @@ -1,128 +0,0 @@ -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 _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 Query(Query query) - { - var results = new List(); - 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 = _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"; - } - - - } -} diff --git a/src/modules/launcher/Plugins/indexer/Properties/AssemblyInfo.cs b/src/modules/launcher/Plugins/indexer/Properties/AssemblyInfo.cs deleted file mode 100644 index a6f591220c..0000000000 --- a/src/modules/launcher/Plugins/indexer/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -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")] diff --git a/src/modules/launcher/Plugins/indexer/SearchHelper/DriveDetection.cs b/src/modules/launcher/Plugins/indexer/SearchHelper/DriveDetection.cs deleted file mode 100644 index 25520d7487..0000000000 --- a/src/modules/launcher/Plugins/indexer/SearchHelper/DriveDetection.cs +++ /dev/null @@ -1,88 +0,0 @@ -using System; -using System.IO; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Microsoft.Search.Interop; - -namespace Wox.Plugin.Indexer.SearchHelper -{ - class DriveDetection - { - // Variable which sets the warning status, can be turned off by user - // TODO : To be linked with the UI once it is finalized - public bool warningOn = true; - - // Function to return the names of all drives - public List GetDrives() - { - DriveInfo[] allDrives = DriveInfo.GetDrives(); - List allDriveNames = new List(); - - foreach (DriveInfo d in allDrives) - { - allDriveNames.Add(d.Name); - } - return allDriveNames; - } - - [STAThread] - // Function to get all the Search Scopes of the indexer - public List GetScopeRules() - { - List allScopeRules = new List(); - // 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 - ISearchCrawlScopeManager crawlScopeManager = catalogManager.GetCrawlScopeManager(); - - // search for the scope rules - IEnumSearchScopeRules scopeRules = crawlScopeManager.EnumerateScopeRules(); - CSearchScopeRule scopeRule; - uint numScopes = 0; - - bool nextExists = true; - while (nextExists) - { - try - { - scopeRules.Next(1, out scopeRule, ref numScopes); - allScopeRules.Add(scopeRule.PatternOrURL); - /*Console.WriteLine(numScopes);*/ - } - catch (Exception ex) - { - nextExists = false; - } - } - - return allScopeRules; - } - - // Function to check if all Drives are indexed - public bool allDrivesIndexed() - { - bool allDrivesAreIndexed = true; - List drives = GetDrives(); - List scopeRules = GetScopeRules(); - - foreach (var drive in drives) - { - string driveScope = @"file:///" + drive; - if (!scopeRules.Contains(driveScope)) - { - allDrivesAreIndexed = false; - break; - } - } - - return allDrivesAreIndexed; - } - - } -} diff --git a/src/modules/launcher/Plugins/indexer/SearchHelper/IndexerExecutableInfo.cs b/src/modules/launcher/Plugins/indexer/SearchHelper/IndexerExecutableInfo.cs deleted file mode 100644 index 9fd4cd97ed..0000000000 --- a/src/modules/launcher/Plugins/indexer/SearchHelper/IndexerExecutableInfo.cs +++ /dev/null @@ -1,66 +0,0 @@ -using System; -using System.Diagnostics; -using Microsoft.Win32; - -namespace Wox.Plugin.Indexer.SearchHelper -{ - class IndexerExecutableInfo - { - // Reference - Control Panel Plugin - private const string CONTROL = @"%SystemRoot%\System32\control.exe"; - private RegistryKey nameSpace = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ControlPanel\\NameSpace"); - RegistryKey clsid = Registry.ClassesRoot.OpenSubKey("CLSID"); - RegistryKey currentKey; - ProcessStartInfo executablePath; - - public ProcessStartInfo Create(uint iconSize) - { - foreach (string key in nameSpace.GetSubKeyNames()) - { - currentKey = clsid.OpenSubKey(key); - if (currentKey != null) - { - executablePath = getExecutablePath(currentKey); - - if (!(executablePath == null)) //Cannot have item without executable path - { - localizedString = getLocalizedString(currentKey); - } - } - } - - return executablePath; - } - - - // Ref - ControlPanelPlugin Wox - // Code to obtain the executable path for an item in the Control Panel - private ProcessStartInfo getExecutablePath(RegistryKey currentKey) - { - ProcessStartInfo executablePath = new ProcessStartInfo(); - string applicationName; - - if (currentKey.GetValue("System.ApplicationName") != null) - { - //CPL Files (usually native MS items) - applicationName = currentKey.GetValue("System.ApplicationName").ToString(); - executablePath.FileName = Environment.ExpandEnvironmentVariables(CONTROL); - executablePath.Arguments = "-name " + applicationName; - } - else if (currentKey.OpenSubKey("Shell\\Open\\Command") != null && currentKey.OpenSubKey("Shell\\Open\\Command").GetValue(null) != null) - { - //Other files (usually third party items) - string input = "\"" + Environment.ExpandEnvironmentVariables(currentKey.OpenSubKey("Shell\\Open\\Command").GetValue(null).ToString()) + "\""; - executablePath.FileName = "cmd.exe"; - executablePath.Arguments = "/C " + input; - executablePath.WindowStyle = ProcessWindowStyle.Hidden; - } - else - { - return null; - } - - return executablePath; - } - } -} diff --git a/src/modules/launcher/Plugins/indexer/SearchHelper/SearchResult.cs b/src/modules/launcher/Plugins/indexer/SearchHelper/SearchResult.cs deleted file mode 100644 index fc4c0ed770..0000000000 --- a/src/modules/launcher/Plugins/indexer/SearchHelper/SearchResult.cs +++ /dev/null @@ -1,14 +0,0 @@ -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; } - } -} diff --git a/src/modules/launcher/Plugins/indexer/SearchHelper/WindowsSearchAPI.cs b/src/modules/launcher/Plugins/indexer/SearchHelper/WindowsSearchAPI.cs deleted file mode 100644 index 64875595a1..0000000000 --- a/src/modules/launcher/Plugins/indexer/SearchHelper/WindowsSearchAPI.cs +++ /dev/null @@ -1,99 +0,0 @@ -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 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 Search(string keyword, string pattern = "*", int maxCount = 100) - { - ISearchQueryHelper queryHelper; - InitQueryHelper(out queryHelper, maxCount); - ModifyQueryHelper(ref queryHelper, pattern); - return ExecuteQuery(queryHelper, keyword); - } - } -} diff --git a/src/modules/launcher/Plugins/indexer/Settings.cs b/src/modules/launcher/Plugins/indexer/Settings.cs deleted file mode 100644 index 6fc9bbbf94..0000000000 --- a/src/modules/launcher/Plugins/indexer/Settings.cs +++ /dev/null @@ -1,23 +0,0 @@ -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 ContextMenus = new List(); - 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; } - } -} diff --git a/src/modules/launcher/Plugins/indexer/indexer.csproj b/src/modules/launcher/Plugins/indexer/indexer.csproj deleted file mode 100644 index 8613f27349..0000000000 --- a/src/modules/launcher/Plugins/indexer/indexer.csproj +++ /dev/null @@ -1,87 +0,0 @@ - - - - - Debug - AnyCPU - {63C3CEA8-51FE-472E-B97C-B58F8B17DD51} - Library - Properties - Wox.Plugin.Indexer - Wox.Plugin.Indexer - v4.5.2 - 512 - true - - - - true - ..\..\..\..\..\x64\Debug\modules\launcher\Plugins\Wox.Plugin.Indexer\ - DEBUG;TRACE - full - x64 - 7.3 - prompt - MinimumRecommendedRules.ruleset - 4 - false - - - - ..\..\..\..\..\x64\Release\modules\launcher\Plugins\Wox.Plugin.Indexer\ - TRACE - true - pdbonly - x64 - 7.3 - prompt - MinimumRecommendedRules.ruleset - 4 - - - - ..\..\..\..\..\packages\tlbimp-Microsoft.Search.Interop.1.0.0\lib\net45\Microsoft.Search.Interop.dll - True - - - - - - - - - - - - - - - - - - - - - PreserveNewest - - - - - - {4fd29318-a8ab-4d8f-aa47-60bc241b8da3} - Wox.Infrastructure - - - {8451ecdd-2ea4-4966-bb0a-7bbc40138e80} - Wox.Plugin - - - - - - PreserveNewest - - - - - \ No newline at end of file diff --git a/src/modules/launcher/Plugins/indexer/packages.config b/src/modules/launcher/Plugins/indexer/packages.config deleted file mode 100644 index 6b77ac3b21..0000000000 --- a/src/modules/launcher/Plugins/indexer/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/src/modules/launcher/Plugins/indexer/plugin.json b/src/modules/launcher/Plugins/indexer/plugin.json deleted file mode 100644 index 741c57ddcc..0000000000 --- a/src/modules/launcher/Plugins/indexer/plugin.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "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" -}