Skip to content

Commit 28acd46

Browse files
committed
Merge branch 'dev'
2 parents cbcca9c + 3184f8d commit 28acd46

File tree

24 files changed

+413
-153
lines changed

24 files changed

+413
-153
lines changed

Plugins/Wox.Plugin.PluginIndicator/Main.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ public List<Result> Query(Query query)
1313
var results = from keyword in PluginManager.NonGlobalPlugins.Keys
1414
where keyword.StartsWith(query.Terms[0])
1515
let metadata = PluginManager.NonGlobalPlugins[keyword].Metadata
16-
let disabled = PluginManager.Settings.Plugins[metadata.ID].Disabled
17-
where !disabled
16+
where !metadata.Disabled
1817
select new Result
1918
{
2019
Title = keyword,
22.7 KB
Loading

Plugins/Wox.Plugin.Sys/Main.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,20 @@ private List<Result> Commands()
234234
context.API.GetTranslation("wox_plugin_sys_dlgtext_all_applicableplugins_reloaded"));
235235
return true;
236236
}
237+
},
238+
new Result
239+
{
240+
Title = "Check For Update",
241+
SubTitle = "Check for new Wox update",
242+
IcoPath = "Images\\checkupdate.png",
243+
Action = c =>
244+
{
245+
Application.Current.MainWindow.Hide();
246+
context.API.CheckForNewUpdate();
247+
context.API.ShowMsg("Please wait...",
248+
"Checking for new update");
249+
return true;
250+
}
237251
}
238252
});
239253
return results;

Plugins/Wox.Plugin.Sys/Wox.Plugin.Sys.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,15 @@
7171
</ProjectReference>
7272
</ItemGroup>
7373
<ItemGroup>
74+
<None Include="Images\checkupdate.png">
75+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
76+
</None>
7477
<Content Include="Images\recyclebin.png">
7578
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
7679
</Content>
80+
<None Include="Images\shutdown.png">
81+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
82+
</None>
7783
<Content Include="Images\sleep.png">
7884
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
7985
</Content>

README.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,22 @@ Features
1919
- Search for everything—applications, **uwp**, folders, files and more.
2020
- Use *pinyin* to search for programs / 支持用 **拼音** 搜索程序
2121
- wyy / wangyiyun → 网易云音乐
22-
- Keyword plugin search
23-
- search google with `g search_term`
22+
- Keyword plugin search `g search_term`
23+
- Search youtube, google, twitter and many more
2424
- Build custom themes at http://www.wox.one/theme/builder
2525
- Install plugins from http://www.wox.one/plugin
2626

27+
**New from this fork:**
28+
- Portable mode
29+
- Drastically improved search experience
30+
- Search all subfolders and files
31+
- Option to always run CMD or Powershell as administrator
32+
- Run CMD, Powershell and programs as a different user
33+
- Manage what programs should be loaded
34+
- Highlighting of how results are matched during query search
35+
- Open web search result as a tab or a new window
36+
- Automatic update
37+
- Reload/update plugin data
2738

2839
Installation
2940
------------
@@ -42,8 +53,8 @@ Versions marked as **pre-release** are unstable pre-release versions.
4253

4354
- Requirements:
4455
- .net >= 4.5.2
45-
- [everything](https://www.voidtools.com/): `.exe` installer + use x64 if your windows is x64 + everything service is running
46-
- [python3](https://www.python.org/downloads/): `.exe` installer + add it to `%PATH%` or set it in WoX settings
56+
- If you want to integrate with [everything](https://www.voidtools.com/): `.exe` installer + use x64 if your windows is x64 + everything service is running. Supported version is 1.3.4.686
57+
- If you use python plugins, install [python3](https://www.python.org/downloads/): `.exe` installer + add it to `%PATH%` or set it in WoX settings
4758

4859
Usage
4960
-----

Wox.Core/Plugin/PluginManager.cs

Lines changed: 28 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Collections.Concurrent;
23
using System.Collections.Generic;
34
using System.IO;
45
using System.Linq;
@@ -92,21 +93,36 @@ public static void LoadPlugins(PluginsSettings settings)
9293
Settings.UpdatePluginSettings(_metadatas);
9394
AllPlugins = PluginsLoader.Plugins(_metadatas, Settings);
9495
}
96+
97+
/// <summary>
98+
/// Call initialize for all plugins
99+
/// </summary>
100+
/// <returns>return the list of failed to init plugins or null for none</returns>
95101
public static void InitializePlugins(IPublicAPI api)
96102
{
97103
API = api;
104+
var failedPlugins = new ConcurrentQueue<PluginPair>();
98105
Parallel.ForEach(AllPlugins, pair =>
99106
{
100-
var milliseconds = Stopwatch.Debug($"|PluginManager.InitializePlugins|Init method time cost for <{pair.Metadata.Name}>", () =>
107+
try
101108
{
102-
pair.Plugin.Init(new PluginInitContext
109+
var milliseconds = Stopwatch.Debug($"|PluginManager.InitializePlugins|Init method time cost for <{pair.Metadata.Name}>", () =>
103110
{
104-
CurrentPluginMetadata = pair.Metadata,
105-
API = API
111+
pair.Plugin.Init(new PluginInitContext
112+
{
113+
CurrentPluginMetadata = pair.Metadata,
114+
API = API
115+
});
106116
});
107-
});
108-
pair.Metadata.InitTime += milliseconds;
109-
Log.Info($"|PluginManager.InitializePlugins|Total init cost for <{pair.Metadata.Name}> is <{pair.Metadata.InitTime}ms>");
117+
pair.Metadata.InitTime += milliseconds;
118+
Log.Info($"|PluginManager.InitializePlugins|Total init cost for <{pair.Metadata.Name}> is <{pair.Metadata.InitTime}ms>");
119+
}
120+
catch (Exception e)
121+
{
122+
Log.Exception(nameof(PluginManager), $"Fail to Init plugin: {pair.Metadata.Name}", e);
123+
pair.Metadata.Disabled = true;
124+
failedPlugins.Enqueue(pair);
125+
}
110126
});
111127

112128
_contextMenuPlugins = GetPluginsForInterface<IContextMenu>();
@@ -121,42 +137,18 @@ public static void InitializePlugins(IPublicAPI api)
121137
.ForEach(x => NonGlobalPlugins[x] = plugin);
122138
}
123139

140+
if (failedPlugins.Any())
141+
{
142+
var failed = string.Join(",", failedPlugins.Select(x => x.Metadata.Name));
143+
API.ShowMsg($"Fail to Init Plugins", $"Plugins: {failed} - fail to load and would be disabled, please contact plugin creator for help", "", false);
144+
}
124145
}
125146

126147
public static void InstallPlugin(string path)
127148
{
128149
PluginInstaller.Install(path);
129150
}
130151

131-
public static Query QueryInit(string text) //todo is that possible to move it into type Query?
132-
{
133-
// replace multiple white spaces with one white space
134-
var terms = text.Split(new[] { Query.TermSeperater }, StringSplitOptions.RemoveEmptyEntries);
135-
var rawQuery = string.Join(Query.TermSeperater, terms);
136-
var actionKeyword = string.Empty;
137-
var search = rawQuery;
138-
var actionParameters = terms.ToList();
139-
if (terms.Length == 0) return null;
140-
if (NonGlobalPlugins.ContainsKey(terms[0]) &&
141-
!Settings.Plugins[NonGlobalPlugins[terms[0]].Metadata.ID].Disabled)
142-
{
143-
actionKeyword = terms[0];
144-
actionParameters = terms.Skip(1).ToList();
145-
search = string.Join(Query.TermSeperater, actionParameters.ToArray());
146-
}
147-
var query = new Query
148-
{
149-
Terms = terms,
150-
RawQuery = rawQuery,
151-
ActionKeyword = actionKeyword,
152-
Search = search,
153-
// Obsolete value initialisation
154-
ActionName = actionKeyword,
155-
ActionParameters = actionParameters
156-
};
157-
return query;
158-
}
159-
160152
public static List<PluginPair> ValidPluginsForQuery(Query query)
161153
{
162154
if (NonGlobalPlugins.ContainsKey(query.ActionKeyword))

Wox.Core/Plugin/QueryBuilder.cs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using Wox.Plugin;
5+
6+
namespace Wox.Core.Plugin
7+
{
8+
public static class QueryBuilder
9+
{
10+
public static Query Build(string text, Dictionary<string, PluginPair> nonGlobalPlugins)
11+
{
12+
// replace multiple white spaces with one white space
13+
var terms = text.Split(new[] { Query.TermSeperater }, StringSplitOptions.RemoveEmptyEntries);
14+
if (terms.Length == 0)
15+
{ // nothing was typed
16+
return null;
17+
}
18+
19+
var rawQuery = string.Join(Query.TermSeperater, terms);
20+
string actionKeyword, search;
21+
string possibleActionKeyword = terms[0];
22+
List<string> actionParameters;
23+
if (nonGlobalPlugins.TryGetValue(possibleActionKeyword, out var pluginPair) && !pluginPair.Metadata.Disabled)
24+
{ // use non global plugin for query
25+
actionKeyword = possibleActionKeyword;
26+
actionParameters = terms.Skip(1).ToList();
27+
search = actionParameters.Count > 0 ? rawQuery.Substring(actionKeyword.Length + 1) : string.Empty;
28+
}
29+
else
30+
{ // non action keyword
31+
actionKeyword = string.Empty;
32+
actionParameters = terms.ToList();
33+
search = rawQuery;
34+
}
35+
36+
var query = new Query
37+
{
38+
Terms = terms,
39+
RawQuery = rawQuery,
40+
ActionKeyword = actionKeyword,
41+
Search = search,
42+
// Obsolete value initialisation
43+
ActionName = actionKeyword,
44+
ActionParameters = actionParameters
45+
};
46+
47+
return query;
48+
}
49+
}
50+
}

Wox.Core/Updater.cs

Lines changed: 51 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.Net;
44
using System.Net.Http;
@@ -10,9 +10,11 @@
1010
using Squirrel;
1111
using Newtonsoft.Json;
1212
using Wox.Core.Resource;
13+
using Wox.Plugin.SharedCommands;
1314
using Wox.Infrastructure;
1415
using Wox.Infrastructure.Http;
1516
using Wox.Infrastructure.Logger;
17+
using System.IO;
1618

1719
namespace Wox.Core
1820
{
@@ -25,14 +27,14 @@ public Updater(string gitHubRepository)
2527
GitHubRepository = gitHubRepository;
2628
}
2729

28-
public async Task UpdateApp()
30+
public async Task UpdateApp(bool silentIfLatestVersion = true)
2931
{
30-
UpdateManager m;
31-
UpdateInfo u;
32+
UpdateManager updateManager;
33+
UpdateInfo newUpdateInfo;
3234

3335
try
3436
{
35-
m = await GitHubUpdateManager(GitHubRepository);
37+
updateManager = await GitHubUpdateManager(GitHubRepository);
3638
}
3739
catch (Exception e) when (e is HttpRequestException || e is WebException || e is SocketException)
3840
{
@@ -43,42 +45,61 @@ public async Task UpdateApp()
4345
try
4446
{
4547
// UpdateApp CheckForUpdate will return value only if the app is squirrel installed
46-
u = await m.CheckForUpdate().NonNull();
48+
newUpdateInfo = await updateManager.CheckForUpdate().NonNull();
4749
}
4850
catch (Exception e) when (e is HttpRequestException || e is WebException || e is SocketException)
4951
{
5052
Log.Exception($"|Updater.UpdateApp|Check your connection and proxy settings to api.github.com.", e);
51-
m.Dispose();
53+
updateManager.Dispose();
5254
return;
5355
}
5456

55-
var fr = u.FutureReleaseEntry;
56-
var cr = u.CurrentlyInstalledVersion;
57-
Log.Info($"|Updater.UpdateApp|Future Release <{fr.Formatted()}>");
58-
if (fr.Version > cr.Version)
57+
var newReleaseVersion = Version.Parse(newUpdateInfo.FutureReleaseEntry.Version.ToString());
58+
var currentVersion = Version.Parse(Constant.Version);
59+
60+
Log.Info($"|Updater.UpdateApp|Future Release <{newUpdateInfo.FutureReleaseEntry.Formatted()}>");
61+
62+
if (newReleaseVersion <= currentVersion)
5963
{
60-
try
61-
{
62-
await m.DownloadReleases(u.ReleasesToApply);
63-
}
64-
catch (Exception e) when (e is HttpRequestException || e is WebException || e is SocketException)
65-
{
66-
Log.Exception($"|Updater.UpdateApp|Check your connection and proxy settings to github-cloud.s3.amazonaws.com.", e);
67-
m.Dispose();
68-
return;
69-
}
70-
71-
await m.ApplyReleases(u);
72-
await m.CreateUninstallerRegistryEntry();
73-
74-
var newVersionTips = this.NewVersinoTips(fr.Version.ToString());
75-
76-
MessageBox.Show(newVersionTips);
77-
Log.Info($"|Updater.UpdateApp|Update success:{newVersionTips}");
64+
if (!silentIfLatestVersion)
65+
MessageBox.Show("You already have the latest Wox version");
66+
updateManager.Dispose();
67+
return;
7868
}
7969

70+
try
71+
{
72+
await updateManager.DownloadReleases(newUpdateInfo.ReleasesToApply);
73+
}
74+
catch (Exception e) when (e is HttpRequestException || e is WebException || e is SocketException)
75+
{
76+
Log.Exception($"|Updater.UpdateApp|Check your connection and proxy settings to github-cloud.s3.amazonaws.com.", e);
77+
updateManager.Dispose();
78+
return;
79+
}
80+
81+
await updateManager.ApplyReleases(newUpdateInfo);
82+
83+
if (Constant.IsPortableMode)
84+
{
85+
var targetDestination = updateManager.RootAppDirectory + $"\\app-{newReleaseVersion.ToString()}\\{Constant.PortableFolderName}";
86+
FilesFolders.Copy(Constant.PortableDataPath, targetDestination);
87+
if (!FilesFolders.VerifyBothFolderFilesEqual(Constant.PortableDataPath, targetDestination))
88+
MessageBox.Show(string.Format("Wox was not able to move your user profile data to the new update version. Please manually" +
89+
"move your profile data folder from {0} to {1}", Constant.PortableDataPath, targetDestination));
90+
}
91+
else
92+
{
93+
await updateManager.CreateUninstallerRegistryEntry();
94+
}
95+
96+
var newVersionTips = NewVersinoTips(newReleaseVersion.ToString());
97+
98+
MessageBox.Show(newVersionTips);
99+
Log.Info($"|Updater.UpdateApp|Update success:{newVersionTips}");
100+
80101
// always dispose UpdateManager
81-
m.Dispose();
102+
updateManager.Dispose();
82103
}
83104

84105
[UsedImplicitly]

Wox.Core/Wox.Core.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
</Compile>
5454
<Compile Include="Plugin\ExecutablePlugin.cs" />
5555
<Compile Include="Plugin\PluginsLoader.cs" />
56+
<Compile Include="Plugin\QueryBuilder.cs" />
5657
<Compile Include="Updater.cs" />
5758
<Compile Include="Resource\AvailableLanguages.cs" />
5859
<Compile Include="Resource\Internationalization.cs" />

0 commit comments

Comments
 (0)