Skip to content

Commit f325674

Browse files
committed
Merge branch 'dev'
2 parents 4ba4324 + 7e26689 commit f325674

38 files changed

+365
-80
lines changed

Plugins/Wox.Plugin.Folder/ContextMenuLoader.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ private bool CanRunAsDifferentUser(string path)
194194
{
195195
case ".exe":
196196
case ".bat":
197+
case ".msi":
197198
return true;
198199

199200
default:

Plugins/Wox.Plugin.Program/Logger/ProgramLogger.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using NLog;
1+
using NLog;
22
using NLog.Config;
33
using NLog.Targets;
44
using System;
@@ -7,6 +7,7 @@
77
using System.Runtime.CompilerServices;
88
using System.Security;
99
using Wox.Infrastructure;
10+
using Wox.Infrastructure.UserSettings;
1011

1112
namespace Wox.Plugin.Program.Logger
1213
{
@@ -21,7 +22,7 @@ internal static class ProgramLogger
2122

2223
static ProgramLogger()
2324
{
24-
var path = Path.Combine(Constant.DataDirectory, DirectoryName, Constant.Version);
25+
var path = Path.Combine(DataLocation.DataDirectory(), DirectoryName, Constant.Version);
2526
if (!Directory.Exists(path))
2627
{
2728
Directory.CreateDirectory(path);

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,6 @@ Install Visual Studio 2017/2019
8383

8484
Documentation
8585
-------------
86-
- [Wiki](https://github.com/Wox-launcher/Wox/wiki)
86+
- [Wiki](https://github.com/jjw24/Wox/wiki)
8787
- Outdated doc: [WoX doc](http://doc.wox.one).
88-
- Just ask questions in [issues](https://github.com/Wox-launcher/Wox/issues) for now.
88+
- Just ask questions in [issues](https://github.com/jjw24/Wox/issues) for now.

Scripts/post_build.ps1

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
param(
22
[string]$config = "Release",
3-
[string]$solution
3+
[string]$solution,
4+
[string]$targetpath
45
)
56
Write-Host "Config: $config"
67

78
function Build-Version {
8-
if ([string]::IsNullOrEmpty($env:APPVEYOR_BUILD_VERSION)) {
9-
$v = "1.2.0"
10-
} else {
9+
if ([string]::IsNullOrEmpty($env:APPVEYOR_BUILD_VERSION)) {
10+
$v = (Get-Command ${TargetPath}).FileVersionInfo.FileVersion
11+
} else {
1112
$v = $env:APPVEYOR_BUILD_VERSION
1213
}
1314

@@ -73,7 +74,7 @@ function Zip-Release ($path, $version, $output) {
7374

7475
$input = "$path\Output\Release"
7576
Write-Host "Input path: $input"
76-
$file = "$output\Wox-$version.zip"
77+
$file = "$output\Wox-JJW24-$version.zip"
7778
Write-Host "Filename: $file"
7879

7980
[Reflection.Assembly]::LoadWithPartialName("System.IO.Compression.FileSystem")
@@ -92,7 +93,7 @@ function Pack-Squirrel-Installer ($path, $version, $output) {
9293
Write-Host "Input path: $input"
9394
Nuget pack $spec -Version $version -Properties Configuration=Release -BasePath $input -OutputDirectory $output
9495

95-
$nupkg = "$output\Wox.$version.nupkg"
96+
$nupkg = "$output\Wox-JJW24.$version.nupkg"
9697
Write-Host "nupkg path: $nupkg"
9798
$icon = "$path\Wox\Resources\app.ico"
9899
Write-Host "icon: $icon"
@@ -106,7 +107,7 @@ function Pack-Squirrel-Installer ($path, $version, $output) {
106107
Move-Item $temp\* $output -Force
107108
Remove-Item $temp
108109

109-
$file = "$output\Wox-$version.exe"
110+
$file = "$output\Wox-JJW24-$version.exe"
110111
Write-Host "Filename: $file"
111112

112113
Move-Item "$output\Setup.exe" $file -Force

Scripts/wox.nuspec

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<?xml version="1.0"?>
22
<package>
33
<metadata>
4-
<id>Wox</id>
4+
<id>Wox-JJW24</id>
55
<title>Wox</title>
66
<version>$version$</version>
7-
<authors>happlebao</authors>
8-
<projectUrl>https://github.com/Wox-launcher/Wox</projectUrl>
9-
<iconUrl>https://raw.githubusercontent.com/Wox-launcher/Wox/master/Wox/Images/app.png</iconUrl>
7+
<authors>happlebao, Jeremy Wu</authors>
8+
<projectUrl>https://github.com/jjw24/Wox</projectUrl>
9+
<iconUrl>https://raw.githubusercontent.com/jjw24/Wox/master/Wox/Images/app.png</iconUrl>
1010
<requireLicenseAcceptance>false</requireLicenseAcceptance>
1111
<description>Wox - a launcher for windows</description>
1212
</metadata>

Scripts/wox.plugin.nuspec

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
<metadata>
44
<id>Wox.Plugin</id>
55
<version>$version$</version>
6-
<authors>qianlifeng</authors>
7-
<licenseUrl>https://github.com/Wox-launcher/Wox/blob/master/LICENSE</licenseUrl>
8-
<projectUrl>https://github.com/Wox-launcher/Wox</projectUrl>
6+
<authors>qianlifeng, Jeremy Wu</authors>
7+
<licenseUrl>https://github.com/jjw24/Wox/blob/master/LICENSE</licenseUrl>
8+
<projectUrl>https://github.com/jjw24/Wox</projectUrl>
99
<requireLicenseAcceptance>false</requireLicenseAcceptance>
1010
<description>Reference this library if you want to develop a wox plugin</description>
1111
<tags>wox</tags>

SolutionAssemblyInfo.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
#if DEBUG
55

66
[assembly: AssemblyConfiguration("Debug")]
7-
[assembly: AssemblyDescription("Debug build, https://github.com/Wox-launcher/Wox")]
7+
[assembly: AssemblyDescription("Debug build, https://github.com/jjw24/Wox")]
88
#else
99
[assembly: AssemblyConfiguration("Release")]
10-
[assembly: AssemblyDescription("Release build, https://github.com/Wox-launcher/Wox")]
10+
[assembly: AssemblyDescription("Release build, https://github.com/jjw24/Wox")]
1111
#endif
1212

1313
[assembly: AssemblyCompany("Wox")]
@@ -17,5 +17,5 @@
1717
[assembly: AssemblyCulture("")]
1818
[assembly: ComVisible(false)]
1919
[assembly: AssemblyVersion("1.2.0")]
20-
[assembly: AssemblyFileVersion("1.2.0.0")]
20+
[assembly: AssemblyFileVersion("1.2.0")]
2121
[assembly: AssemblyInformationalVersion("1.2.0")]

Wox.Core/Configuration/IPortable.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+

2+
namespace Wox.Core.Configuration
3+
{
4+
public interface IPortable
5+
{
6+
void EnablePortableMode();
7+
void DisablePortableMode();
8+
void RemoveShortcuts();
9+
void RemoveUninstallerEntry();
10+
void CreateShortcuts();
11+
void CreateUninstallerEntry();
12+
void MoveUserDataFolder(string fromLocation, string toLocation);
13+
void VerifyUserDataAfterMove(string fromLocation, string toLocation);
14+
bool CanUpdatePortability();
15+
}
16+
}

Wox.Core/Configuration/Portable.cs

Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
using Microsoft.Win32;
2+
using Squirrel;
3+
using System;
4+
using System.IO;
5+
using System.Reflection;
6+
using System.Windows;
7+
using Wox.Infrastructure;
8+
using Wox.Infrastructure.Logger;
9+
using Wox.Infrastructure.UserSettings;
10+
using Wox.Plugin.SharedCommands;
11+
12+
namespace Wox.Core.Configuration
13+
{
14+
public class Portable : IPortable
15+
{
16+
/// <summary>
17+
/// As at Squirrel.Windows version 1.5.2, UpdateManager needs to be disposed after finish
18+
/// </summary>
19+
/// <returns></returns>
20+
private UpdateManager NewUpdateManager()
21+
{
22+
return new UpdateManager(string.Empty, Constant.Wox, Constant.RootDirectory);
23+
}
24+
25+
public void DisablePortableMode()
26+
{
27+
try
28+
{
29+
MoveUserDataFolder(DataLocation.PortableDataPath, DataLocation.RoamingDataPath);
30+
#if DEBUG
31+
// Create shortcuts and uninstaller are not required in debug mode,
32+
// otherwise will repoint the path of the actual installed production version to the debug version
33+
#else
34+
CreateShortcuts();
35+
CreateUninstallerEntry();
36+
#endif
37+
IndicateDeletion(DataLocation.PortableDataPath);
38+
39+
MessageBox.Show("Wox needs to restart to finish disabling portable mode, " +
40+
"after the restart your portable data profile will be deleted and roaming data profile kept");
41+
42+
UpdateManager.RestartApp();
43+
}
44+
catch (Exception e)
45+
{
46+
#if !DEBUG
47+
Log.Exception("Portable", "Error occured while disabling portable mode", e);
48+
#endif
49+
throw;
50+
}
51+
}
52+
53+
public void EnablePortableMode()
54+
{
55+
try
56+
{
57+
MoveUserDataFolder(DataLocation.RoamingDataPath, DataLocation.PortableDataPath);
58+
#if DEBUG
59+
// Remove shortcuts and uninstaller are not required in debug mode,
60+
// otherwise will delete the actual installed production version
61+
#else
62+
RemoveShortcuts();
63+
RemoveUninstallerEntry();
64+
#endif
65+
IndicateDeletion(DataLocation.RoamingDataPath);
66+
67+
MessageBox.Show("Wox needs to restart to finish enabling portable mode, " +
68+
"after the restart your roaming data profile will be deleted and portable data profile kept");
69+
70+
UpdateManager.RestartApp();
71+
}
72+
catch (Exception e)
73+
{
74+
#if !DEBUG
75+
Log.Exception("Portable", "Error occured while enabling portable mode", e);
76+
#endif
77+
throw;
78+
}
79+
}
80+
81+
public void RemoveShortcuts()
82+
{
83+
using (var portabilityUpdater = NewUpdateManager())
84+
{
85+
var exeName = Constant.Wox + ".exe";
86+
portabilityUpdater.RemoveShortcutsForExecutable(exeName, ShortcutLocation.StartMenu);
87+
portabilityUpdater.RemoveShortcutsForExecutable(exeName, ShortcutLocation.Desktop);
88+
portabilityUpdater.RemoveShortcutsForExecutable(exeName, ShortcutLocation.Startup);
89+
}
90+
}
91+
92+
public void RemoveUninstallerEntry()
93+
{
94+
using (var portabilityUpdater = NewUpdateManager())
95+
{
96+
portabilityUpdater.RemoveUninstallerRegistryEntry();
97+
}
98+
}
99+
100+
public void MoveUserDataFolder(string fromLocation, string toLocation)
101+
{
102+
FilesFolders.Copy(fromLocation, toLocation);
103+
VerifyUserDataAfterMove(fromLocation, toLocation);
104+
}
105+
106+
public void VerifyUserDataAfterMove(string fromLocation, string toLocation)
107+
{
108+
FilesFolders.VerifyBothFolderFilesEqual(fromLocation, toLocation);
109+
}
110+
111+
public void CreateShortcuts()
112+
{
113+
using (var portabilityUpdater = NewUpdateManager())
114+
{
115+
var exeName = Constant.Wox + ".exe";
116+
portabilityUpdater.CreateShortcutsForExecutable(exeName, ShortcutLocation.StartMenu, false);
117+
portabilityUpdater.CreateShortcutsForExecutable(exeName, ShortcutLocation.Desktop, false);
118+
portabilityUpdater.CreateShortcutsForExecutable(exeName, ShortcutLocation.Startup, false);
119+
}
120+
}
121+
122+
public void CreateUninstallerEntry()
123+
{
124+
var uninstallRegSubKey = @"Software\Microsoft\Windows\CurrentVersion\Uninstall";
125+
// NB: Sometimes the Uninstall key doesn't exist
126+
using (var parentKey =
127+
RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Default)
128+
.CreateSubKey("Uninstall", RegistryKeyPermissionCheck.ReadWriteSubTree)) {; }
129+
130+
var key = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Default)
131+
.CreateSubKey(uninstallRegSubKey + "\\" + Constant.Wox, RegistryKeyPermissionCheck.ReadWriteSubTree);
132+
key.SetValue("DisplayIcon", Constant.ApplicationDirectory + "\\app.ico", RegistryValueKind.String);
133+
134+
using (var portabilityUpdater = NewUpdateManager())
135+
{
136+
portabilityUpdater.CreateUninstallerRegistryEntry();
137+
}
138+
}
139+
140+
internal void IndicateDeletion(string filePathTodelete)
141+
{
142+
using (StreamWriter sw = File.CreateText(filePathTodelete + "\\" + DataLocation.DeletionIndicatorFile)){}
143+
}
144+
145+
///<summary>
146+
///This method should be run at first before all methods during start up and should be run before determining which data location
147+
///will be used for Wox.
148+
///</summary>
149+
public void PreStartCleanUpAfterPortabilityUpdate()
150+
{
151+
// Specify here so this method does not rely on other environment variables to initialise
152+
var portableDataPath = Path.Combine(Directory.GetParent(Assembly.GetExecutingAssembly().Location.NonNull()).ToString(), "UserData");
153+
var roamingDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Wox");
154+
155+
bool DataLocationPortableDeleteRequired = false;
156+
bool DataLocationRoamingDeleteRequired = false;
157+
158+
if ((roamingDataPath + "\\" + DataLocation.DeletionIndicatorFile).FileExits())
159+
DataLocationRoamingDeleteRequired = true;
160+
161+
if ((portableDataPath + "\\" + DataLocation.DeletionIndicatorFile).FileExits())
162+
DataLocationPortableDeleteRequired = true;
163+
164+
if (DataLocationRoamingDeleteRequired)
165+
{
166+
if(roamingDataPath.LocationExists())
167+
MessageBox.Show("Wox detected you restarted after enabling portable mode, " +
168+
"your roaming data profile will now be deleted");
169+
170+
FilesFolders.RemoveFolderIfExists(roamingDataPath);
171+
172+
return;
173+
}
174+
175+
if(DataLocationPortableDeleteRequired)
176+
{
177+
MessageBox.Show("Wox detected you restarted after disabling portable mode, " +
178+
"your portable data profile will now be deleted");
179+
180+
FilesFolders.RemoveFolderIfExists(portableDataPath);
181+
182+
return;
183+
}
184+
}
185+
186+
public bool CanUpdatePortability()
187+
{
188+
var roamingLocationExists = DataLocation.RoamingDataPath.LocationExists();
189+
var portableLocationExists = DataLocation.PortableDataPath.LocationExists();
190+
191+
if(roamingLocationExists && portableLocationExists)
192+
{
193+
MessageBox.Show(string.Format("Wox detected your user data exists both in {0} and " +
194+
"{1}. {2}{2}Please delete {1} in order to proceed. No changes have occured.",
195+
DataLocation.PortableDataPath, DataLocation.RoamingDataPath, Environment.NewLine));
196+
197+
return false;
198+
}
199+
200+
return true;
201+
}
202+
}
203+
}

Wox.Core/Plugin/PluginInstaller.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ internal static void Install(string path)
3434
return;
3535
}
3636

37-
string pluginFolerPath = Infrastructure.Constant.PluginsDirectory;
37+
string pluginFolerPath = Infrastructure.UserSettings.DataLocation.PluginsDirectory;
3838

3939
string newPluginName = plugin.Name
4040
.Replace("/", "_")

0 commit comments

Comments
 (0)