diff --git a/Deploy/squirrel_installer.ps1 b/Deploy/squirrel_installer.ps1
index 9c1d010d1..160e062ec 100644
--- a/Deploy/squirrel_installer.ps1
+++ b/Deploy/squirrel_installer.ps1
@@ -1,9 +1,12 @@
+# msbuild based installer generation is not working in appveyor, not sure why
+
$currentPath = Convert-Path .
Write-Host "Current path: " + $currentPath
$path = $env:APPVEYOR_BUILD_FOLDER + "\Deploy\wox.nuspec"
Write-Host "nuspec path: " + $path
-& nuget.exe pack $path -Version $env:APPVEYOR_BUILD_VERSION -Properties Configuration=Release
+$releasePath = $env:APPVEYOR_BUILD_FOLDER + "\Output\Release"
+& nuget.exe pack $path -Version $env:APPVEYOR_BUILD_VERSION -Properties Configuration=Release -BasePath $releasePath
$nupkgPath = $env:APPVEYOR_BUILD_FOLDER + "\Wox." + $env:APPVEYOR_BUILD_VERSION + ".nupkg"
Write-Host "nupkg path: " + $nupkgPath
@@ -12,4 +15,4 @@ Write-Host "nupkg path: " + $nupkgPath
$squirrelPath = $env:APPVEYOR_BUILD_FOLDER + "\packages\squirrel*\tools\Squirrel.com"
Write-Host "squirrel path: " + $squirrelPath
$iconPath = $env:APPVEYOR_BUILD_FOLDER + "\Wox\Resources\app.ico"
-& $squirrelPath --releasify $nupkgPath --setupIcon $iconPath --no-msi
+& $squirrelPath --releasify $nupkgPath --setupIcon $iconPath --no-msi
\ No newline at end of file
diff --git a/Deploy/wox.nuspec b/Deploy/wox.nuspec
index 448cc8ea3..681099663 100644
--- a/Deploy/wox.nuspec
+++ b/Deploy/wox.nuspec
@@ -11,6 +11,6 @@
Wox - a launcher for windows
-
+
diff --git a/Plugins/Wox.Plugin.WebSearch/Main.cs b/Plugins/Wox.Plugin.WebSearch/Main.cs
index 5d08fa5ac..e99d61529 100644
--- a/Plugins/Wox.Plugin.WebSearch/Main.cs
+++ b/Plugins/Wox.Plugin.WebSearch/Main.cs
@@ -85,10 +85,10 @@ namespace Wox.Plugin.WebSearch
if (_settings.EnableWebSearchSuggestion)
{
const int waittime = 300;
- var task = Task.Run(() =>
+ var task = Task.Run(async () =>
{
- results.AddRange(ResultsFromSuggestions(keyword, subtitle, webSearch));
-
+ var suggestions = await Suggestions(keyword, subtitle, webSearch);
+ results.AddRange(suggestions);
}, _updateToken);
if (!task.Wait(waittime))
@@ -102,12 +102,12 @@ namespace Wox.Plugin.WebSearch
}
}
- private IEnumerable ResultsFromSuggestions(string keyword, string subtitle, WebSearch webSearch)
+ private async Task> Suggestions(string keyword, string subtitle, WebSearch webSearch)
{
var source = SuggestionSource.GetSuggestionSource(_settings.WebSearchSuggestionSource, Context);
- var suggestions = source?.GetSuggestions(keyword);
- if (suggestions != null)
+ if (source != null)
{
+ var suggestions = await source.GetSuggestions(keyword);
var resultsFromSuggestion = suggestions.Select(o => new Result
{
Title = o,
diff --git a/Plugins/Wox.Plugin.WebSearch/SuggestionSources/Baidu.cs b/Plugins/Wox.Plugin.WebSearch/SuggestionSources/Baidu.cs
index c4a472ac9..d05d7287f 100644
--- a/Plugins/Wox.Plugin.WebSearch/SuggestionSources/Baidu.cs
+++ b/Plugins/Wox.Plugin.WebSearch/SuggestionSources/Baidu.cs
@@ -2,9 +2,11 @@
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
+using System.Threading.Tasks;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Wox.Infrastructure.Http;
+using Wox.Infrastructure.Logger;
namespace Wox.Plugin.WebSearch.SuggestionSources
{
@@ -14,20 +16,24 @@ namespace Wox.Plugin.WebSearch.SuggestionSources
Regex reg = new Regex("window.baidu.sug\\((.*)\\)");
- public override List GetSuggestions(string query)
+ public override async Task> GetSuggestions(string query)
{
- var result = HttpRequest.Get("http://suggestion.baidu.com/su?json=1&wd=" + Uri.EscapeUriString(query), Proxy, "GB2312");
+ var result = await HttpRequest.Get("http://suggestion.baidu.com/su?json=1&wd=" + Uri.EscapeUriString(query), Proxy, "GB2312");
if (string.IsNullOrEmpty(result)) return new List();
Match match = reg.Match(result);
if (match.Success)
{
- JContainer json = null;
+ JContainer json;
try
{
json = JsonConvert.DeserializeObject(match.Groups[1].Value) as JContainer;
}
- catch { }
+ catch (JsonSerializationException e)
+ {
+ Log.Error(e);
+ return new List();
+ }
if (json != null)
{
diff --git a/Plugins/Wox.Plugin.WebSearch/SuggestionSources/Google.cs b/Plugins/Wox.Plugin.WebSearch/SuggestionSources/Google.cs
index fd732375f..ab569219c 100644
--- a/Plugins/Wox.Plugin.WebSearch/SuggestionSources/Google.cs
+++ b/Plugins/Wox.Plugin.WebSearch/SuggestionSources/Google.cs
@@ -1,34 +1,39 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Threading.Tasks;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Wox.Infrastructure.Http;
+using Wox.Infrastructure.Logger;
namespace Wox.Plugin.WebSearch.SuggestionSources
{
public class Google : SuggestionSource
{
public override string Domain { get; set; } = "www.google.com";
- public override List GetSuggestions(string query)
+ public override async Task> GetSuggestions(string query)
{
- var result = HttpRequest.Get("https://www.google.com/complete/search?output=chrome&q=" + Uri.EscapeUriString(query), Proxy);
+ var result = await HttpRequest.Get("https://www.google.com/complete/search?output=chrome&q=" + Uri.EscapeUriString(query), Proxy);
if (string.IsNullOrEmpty(result)) return new List();
-
+ JContainer json;
try
{
- JContainer json = JsonConvert.DeserializeObject(result) as JContainer;
- if (json != null)
+ json = JsonConvert.DeserializeObject(result) as JContainer;
+ }
+ catch (JsonSerializationException e)
+ {
+ Log.Error(e);
+ return new List();
+ }
+ if (json != null)
+ {
+ var results = json[1] as JContainer;
+ if (results != null)
{
- var results = json[1] as JContainer;
- if (results != null)
- {
- return results.OfType().Select(o => o.Value).OfType().ToList();
- }
+ return results.OfType().Select(o => o.Value).OfType().ToList();
}
}
- catch { }
-
return new List();
}
diff --git a/Plugins/Wox.Plugin.WebSearch/SuggestionSources/ISuggestionSource.cs b/Plugins/Wox.Plugin.WebSearch/SuggestionSources/ISuggestionSource.cs
index 75556602e..8c654ecd4 100644
--- a/Plugins/Wox.Plugin.WebSearch/SuggestionSources/ISuggestionSource.cs
+++ b/Plugins/Wox.Plugin.WebSearch/SuggestionSources/ISuggestionSource.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using System.Threading.Tasks;
namespace Wox.Plugin.WebSearch.SuggestionSources
{
@@ -12,7 +13,7 @@ namespace Wox.Plugin.WebSearch.SuggestionSources
Proxy = httpProxy;
}
- public abstract List GetSuggestions(string query);
+ public abstract Task> GetSuggestions(string query);
public static SuggestionSource GetSuggestionSource(string name, PluginInitContext context)
{
diff --git a/SolutionAssemblyInfo.cs b/SolutionAssemblyInfo.cs
index 980e82176..0c060df81 100644
--- a/SolutionAssemblyInfo.cs
+++ b/SolutionAssemblyInfo.cs
@@ -15,6 +15,6 @@ using System.Runtime.InteropServices;
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
-[assembly: AssemblyVersion("1.2.0")]
-[assembly: AssemblyFileVersion("1.2.0")]
-[assembly: AssemblyInformationalVersion("1.2.0")]
\ No newline at end of file
+[assembly: AssemblyVersion("1.2.0.*")]
+[assembly: AssemblyFileVersion("1.2.0.*")]
+[assembly: AssemblyInformationalVersion("1.2.0.*")]
\ No newline at end of file
diff --git a/Wox.Core/APIServer.cs b/Wox.Core/APIServer.cs
deleted file mode 100644
index 7830d091a..000000000
--- a/Wox.Core/APIServer.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-namespace Wox.Core
-{
- public static class APIServer
- {
- private static string BaseAPIURL = "http://api.getwox.com";
- public static string ErrorReportURL = BaseAPIURL + "/error/";
- public static string LastestReleaseURL = BaseAPIURL + "/release/latest/";
- }
-}
diff --git a/Wox.Core/Updater/Release.cs b/Wox.Core/Updater/Release.cs
deleted file mode 100644
index 4808ffefb..000000000
--- a/Wox.Core/Updater/Release.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-namespace Wox.Core.Updater
-{
- public class Release
- {
- public string version { get; set; }
- public string download_link { get; set; }
- public string download_link1 { get; set; }
- public string download_link2 { get; set; }
- public string description { get; set; }
-
- public override string ToString()
- {
- return version;
- }
- }
-}
\ No newline at end of file
diff --git a/Wox.Core/Updater/SemanticVersion.cs b/Wox.Core/Updater/SemanticVersion.cs
deleted file mode 100644
index 01012183d..000000000
--- a/Wox.Core/Updater/SemanticVersion.cs
+++ /dev/null
@@ -1,95 +0,0 @@
-using System;
-using Wox.Infrastructure.Exception;
-
-namespace Wox.Core.Updater
-{
- public class SemanticVersion : IComparable
- {
- public int MAJOR { get; set; }
- public int MINOR { get; set; }
- public int PATCH { get; set; }
-
- public SemanticVersion(Version version)
- {
- MAJOR = version.Major;
- MINOR = version.Minor;
- PATCH = version.Build;
- }
-
- public SemanticVersion(int major, int minor, int patch)
- {
- MAJOR = major;
- MINOR = minor;
- PATCH = patch;
- }
-
- public SemanticVersion(string version)
- {
- var strings = version.Split('.');
- if (strings.Length != 3)
- {
- throw new WoxException("Invalid semantic version");
- }
- MAJOR = int.Parse(strings[0]);
- MINOR = int.Parse(strings[1]);
- PATCH = int.Parse(strings[2]);
- }
-
- public static bool operator >(SemanticVersion v1, SemanticVersion v2)
- {
- return v1.CompareTo(v2) > 0;
- }
-
- public static bool operator <(SemanticVersion v1, SemanticVersion v2)
- {
- return v1.CompareTo(v2) < 0;
- }
-
- public static bool operator ==(SemanticVersion v1, SemanticVersion v2)
- {
- if (ReferenceEquals(v1, null))
- {
- return ReferenceEquals(v2, null);
- }
- if (ReferenceEquals(v2, null))
- {
- return false;
- }
- return v1.Equals(v2);
- }
-
- public static bool operator !=(SemanticVersion v1, SemanticVersion v2)
- {
- return !(v1 == v2);
- }
-
- public override string ToString()
- {
- return string.Format("{0}.{1}.{2}", MAJOR, MINOR, PATCH);
- }
-
- public override bool Equals(object version)
- {
- var v2 = (SemanticVersion)version;
- return MAJOR == v2.MAJOR && MINOR == v2.MINOR && PATCH == v2.PATCH;
- }
-
- public int CompareTo(object version)
- {
- var v2 = (SemanticVersion)version;
- if (MAJOR == v2.MAJOR)
- {
- if (MINOR == v2.MINOR)
- {
- if (PATCH == v2.PATCH)
- {
- return 0;
- }
- return PATCH - v2.PATCH;
- }
- return MINOR - v2.MINOR;
- }
- return MAJOR - v2.MAJOR;
- }
- }
-}
diff --git a/Wox.Core/Updater/UpdaterManager.cs b/Wox.Core/Updater/UpdaterManager.cs
deleted file mode 100644
index 62ea31291..000000000
--- a/Wox.Core/Updater/UpdaterManager.cs
+++ /dev/null
@@ -1,182 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Reflection;
-using System.Threading;
-using System.Threading.Tasks;
-using System.Windows.Forms;
-using NAppUpdate.Framework;
-using NAppUpdate.Framework.Common;
-using NAppUpdate.Framework.Sources;
-using NAppUpdate.Framework.Tasks;
-using Newtonsoft.Json;
-using Wox.Core.Resource;
-using Wox.Core.UserSettings;
-using Wox.Infrastructure.Http;
-using Wox.Infrastructure.Logger;
-
-namespace Wox.Core.Updater
-{
- public class UpdaterManager
- {
- private static UpdaterManager instance;
- private const string VersionCheckURL = "http://api.getwox.com/release/latest/";
- private const string UpdateFeedURL = "http://upgrade.getwox.com/update.xml";
- //private const string UpdateFeedURL = "http://127.0.0.1:8888/update.xml";
- private static SemanticVersion currentVersion;
- public UserSettings.Settings Settings { get; set; }
-
- public event EventHandler PrepareUpdateReady;
- public event EventHandler UpdateError;
-
- public Release NewRelease { get; set; }
-
- public static UpdaterManager Instance
- {
- get
- {
- if (instance == null)
- {
- instance = new UpdaterManager();
- }
- return instance;
- }
- }
-
- private UpdaterManager()
- {
- UpdateManager.Instance.UpdateSource = GetUpdateSource();
- }
-
- public SemanticVersion CurrentVersion
- {
- get
- {
- if (currentVersion == null)
- {
- currentVersion = new SemanticVersion(Assembly.GetExecutingAssembly().GetName().Version);
- }
- return currentVersion;
- }
- }
-
- private bool IsNewerThanCurrent(Release release)
- {
- if (release == null) return false;
-
- return new SemanticVersion(release.version) > CurrentVersion;
- }
-
- public List GetAvailableUpdateFiles()
- {
- List files = new List();
- foreach (var task in UpdateManager.Instance.Tasks)
- {
- if (task is FileUpdateTask)
- {
- files.Add(((FileUpdateTask)task).LocalPath);
- }
- }
- return files;
- }
-
- public void CheckUpdate()
- {
- Task.Run(() =>
- {
- string json = HttpRequest.Get(VersionCheckURL, HttpProxy.Instance);
- if (!string.IsNullOrEmpty(json))
- {
- try
- {
- NewRelease = JsonConvert.DeserializeObject(json);
- if (IsNewerThanCurrent(NewRelease) && !Settings.DontPromptUpdateMsg)
- {
- StartUpdate();
- }
- }
- catch (Exception e)
- {
- Log.Error(e);
- }
- }
- });
- }
-
- private void StartUpdate()
- {
- UpdateManager updManager = UpdateManager.Instance;
- updManager.BeginCheckForUpdates(asyncResult =>
- {
- if (asyncResult.IsCompleted)
- {
- // still need to check for caught exceptions if any and rethrow
- try
- {
- ((UpdateProcessAsyncResult)asyncResult).EndInvoke();
- }
- catch (Exception e)
- {
- updManager.CleanUp();
- Log.Error(e);
- return;
- }
-
- // No updates were found, or an error has occured. We might want to check that...
- if (updManager.UpdatesAvailable == 0)
- {
- return;
- }
- }
-
- updManager.BeginPrepareUpdates(result =>
- {
- ((UpdateProcessAsyncResult)result).EndInvoke();
- OnPrepareUpdateReady();
- }, null);
- }, null);
- }
-
- public void CleanUp()
- {
- UpdateManager.Instance.CleanUp();
- }
-
- public void ApplyUpdates()
- {
- // ApplyUpdates is a synchronous method by design. Make sure to save all user work before calling
- // it as it might restart your application
- // get out of the way so the console window isn't obstructed
- try
- {
- UpdateManager.Instance.ApplyUpdates(true, Settings.EnableUpdateLog, false);
- }
- catch (Exception e)
- {
- string updateError = InternationalizationManager.Instance.GetTranslation("update_wox_update_error");
- Log.Error(e);
- MessageBox.Show(updateError);
- OnUpdateError();
- }
-
- UpdateManager.Instance.CleanUp();
- }
-
- private IUpdateSource GetUpdateSource()
- {
- var source = new WoxUpdateSource(UpdateFeedURL, HttpRequest.GetWebProxy(HttpProxy.Instance));
- return source;
- }
-
- protected virtual void OnPrepareUpdateReady()
- {
- var handler = PrepareUpdateReady;
- if (handler != null) handler(this, EventArgs.Empty);
- }
-
- protected virtual void OnUpdateError()
- {
- var handler = UpdateError;
- if (handler != null) handler(this, EventArgs.Empty);
- }
- }
-}
diff --git a/Wox.Core/Updater/WoxUpdateSource.cs b/Wox.Core/Updater/WoxUpdateSource.cs
deleted file mode 100644
index a9f86807d..000000000
--- a/Wox.Core/Updater/WoxUpdateSource.cs
+++ /dev/null
@@ -1,65 +0,0 @@
-using System;
-using System.IO;
-using System.Net;
-using NAppUpdate.Framework.Common;
-using NAppUpdate.Framework.Sources;
-using NAppUpdate.Framework.Utils;
-
-namespace Wox.Core.Updater
-{
- internal class WoxUpdateSource : IUpdateSource
- {
- public IWebProxy Proxy { get; set; }
-
- public string FeedUrl { get; set; }
-
- public WoxUpdateSource(string feedUrl,IWebProxy proxy)
- {
- FeedUrl = feedUrl;
- Proxy = proxy;
- }
-
- private void TryResolvingHost()
- {
- Uri uri = new Uri(FeedUrl);
- try
- {
- Dns.GetHostEntry(uri.Host);
- }
- catch (Exception ex)
- {
- throw new WebException(string.Format("Failed to resolve {0}. Check your connectivity.", uri.Host), WebExceptionStatus.ConnectFailure);
- }
- }
-
- public string GetUpdatesFeed()
- {
- TryResolvingHost();
- string str = string.Empty;
- WebRequest webRequest = WebRequest.Create(FeedUrl);
- webRequest.Method = "GET";
- webRequest.Proxy = Proxy;
- using (WebResponse response = webRequest.GetResponse())
- {
- Stream responseStream = response.GetResponseStream();
- if (responseStream != null)
- {
- using (StreamReader streamReader = new StreamReader(responseStream, true))
- str = streamReader.ReadToEnd();
- }
- }
- return str;
- }
-
- public bool GetData(string url, string baseUrl, Action onProgress, ref string tempLocation)
- {
- if (!string.IsNullOrEmpty(baseUrl) && !baseUrl.EndsWith("/"))
- baseUrl += "/";
- FileDownloader fileDownloader = !Uri.IsWellFormedUriString(url, UriKind.Absolute) ? (!Uri.IsWellFormedUriString(baseUrl, UriKind.Absolute) ? (string.IsNullOrEmpty(baseUrl) ? new FileDownloader(url) : new FileDownloader(new Uri(new Uri(baseUrl), url))) : new FileDownloader(new Uri(new Uri(baseUrl, UriKind.Absolute), url))) : new FileDownloader(url);
- fileDownloader.Proxy = Proxy;
- if (string.IsNullOrEmpty(tempLocation) || !Directory.Exists(Path.GetDirectoryName(tempLocation)))
- tempLocation = Path.GetTempFileName();
- return fileDownloader.DownloadToFile(tempLocation, onProgress);
- }
- }
-}
diff --git a/Wox.Core/Wox.Core.csproj b/Wox.Core/Wox.Core.csproj
index 78e8244d2..92b58b27c 100644
--- a/Wox.Core/Wox.Core.csproj
+++ b/Wox.Core/Wox.Core.csproj
@@ -64,12 +64,8 @@
Properties\SolutionAssemblyInfo.cs
-
-
-
-
@@ -90,7 +86,6 @@
-
diff --git a/Wox.CrashReporter/ReportWindow.xaml.cs b/Wox.CrashReporter/ReportWindow.xaml.cs
index 584e73f3a..e16fc09bc 100644
--- a/Wox.CrashReporter/ReportWindow.xaml.cs
+++ b/Wox.CrashReporter/ReportWindow.xaml.cs
@@ -5,7 +5,7 @@ using System.Windows;
using System.Windows.Documents;
using Exceptionless;
using Wox.Core.Resource;
-using Wox.Core.Updater;
+using Wox.Infrastructure;
namespace Wox.CrashReporter
{
@@ -23,7 +23,7 @@ namespace Wox.CrashReporter
private void SetException(Exception exception)
{
tbSummary.AppendText(exception.Message);
- tbVersion.Text = UpdaterManager.Instance.CurrentVersion.ToString();
+ tbVersion.Text = Infrastructure.Wox.Version;
tbDatetime.Text = DateTime.Now.ToString();
tbStackTrace.AppendText(exception.StackTrace);
tbSource.Text = exception.Source;
diff --git a/Wox.CrashReporter/Wox.CrashReporter.csproj b/Wox.CrashReporter/Wox.CrashReporter.csproj
index 6a9d6ae48..dd4269796 100644
--- a/Wox.CrashReporter/Wox.CrashReporter.csproj
+++ b/Wox.CrashReporter/Wox.CrashReporter.csproj
@@ -78,6 +78,10 @@
{B749F0DB-8E75-47DB-9E5E-265D16D0C0D2}
Wox.Core
+
+ {4fd29318-a8ab-4d8f-aa47-60bc241b8da3}
+ Wox.Infrastructure
+
diff --git a/Wox.Infrastructure/Exception/ExceptionFormatter.cs b/Wox.Infrastructure/Exception/ExceptionFormatter.cs
index ce232d07d..5c472b5fc 100644
--- a/Wox.Infrastructure/Exception/ExceptionFormatter.cs
+++ b/Wox.Infrastructure/Exception/ExceptionFormatter.cs
@@ -14,6 +14,7 @@ namespace Wox.Infrastructure.Exception
return CreateExceptionReport(exception);
}
+ //todo log /display line by line
private static string CreateExceptionReport(System.Exception ex)
{
var sb = new StringBuilder();
@@ -84,7 +85,21 @@ namespace Wox.Infrastructure.Exception
sb.Append("* ");
sb.Append(ass.FullName);
sb.Append(" (");
- sb.Append(string.IsNullOrEmpty(ass.Location) ? "not supported" : ass.Location);
+
+ if (ass.IsDynamic)
+ {
+ sb.Append("dynamic assembly doesn't has location");
+ }
+ else if (string.IsNullOrEmpty(ass.Location))
+ {
+ sb.Append("location is null or empty");
+
+ }
+ else
+ {
+ sb.Append(ass.Location);
+
+ }
sb.AppendLine(")");
}
diff --git a/Wox.Infrastructure/Http/HttpRequest.cs b/Wox.Infrastructure/Http/HttpRequest.cs
index 1142f217f..6dd7030af 100644
--- a/Wox.Infrastructure/Http/HttpRequest.cs
+++ b/Wox.Infrastructure/Http/HttpRequest.cs
@@ -1,120 +1,79 @@
-using System.IO;
+using System;
+using System.IO;
using System.Net;
+using System.Net.Http;
+using System.Net.Http.Headers;
using System.Text;
+using System.Threading.Tasks;
+using JetBrains.Annotations;
using Wox.Infrastructure.Logger;
using Wox.Plugin;
namespace Wox.Infrastructure.Http
{
- public class HttpRequest
+ public static class HttpRequest
{
- public static string Get(string url, IHttpProxy proxy, string encoding = "UTF-8")
- {
- return Get(url, encoding, proxy);
- }
-
- public static WebProxy GetWebProxy(IHttpProxy proxy)
+ private static WebProxy GetWebProxy(IHttpProxy proxy)
{
if (proxy != null && proxy.Enabled && !string.IsNullOrEmpty(proxy.Server))
{
if (string.IsNullOrEmpty(proxy.UserName) || string.IsNullOrEmpty(proxy.Password))
{
- return new WebProxy(proxy.Server, proxy.Port);
- }
-
- return new WebProxy(proxy.Server, proxy.Port)
- {
- Credentials = new NetworkCredential(proxy.UserName, proxy.Password)
- };
- }
-
- return null;
- }
-
- private static string Get(string url, string encoding, IHttpProxy proxy)
- {
- if (string.IsNullOrEmpty(url)) return string.Empty;
-
- HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
- request.Method = "GET";
- request.Timeout = 10 * 1000;
- request.Proxy = GetWebProxy(proxy);
-
- try
- {
- HttpWebResponse response = request.GetResponse() as HttpWebResponse;
- if (response != null)
- {
- Stream stream = response.GetResponseStream();
- if (stream != null)
- {
- using (StreamReader reader = new StreamReader(stream, Encoding.GetEncoding(encoding)))
- {
- return reader.ReadToEnd();
- }
- }
- }
- }
- catch (System.Exception e)
- {
- Log.Error(e);
- return string.Empty;
- }
-
- return string.Empty;
- }
-
- public static string Post(string url, string jsonData, IHttpProxy proxy)
- {
- if (string.IsNullOrEmpty(url)) return string.Empty;
-
- HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
- request.Method = "POST";
- request.ContentType = "text/json";
- request.Timeout = 10 * 1000;
- if (proxy != null && proxy.Enabled && !string.IsNullOrEmpty(proxy.Server))
- {
- if (string.IsNullOrEmpty(proxy.UserName) || string.IsNullOrEmpty(proxy.Password))
- {
- request.Proxy = new WebProxy(proxy.Server, proxy.Port);
+ var webProxy = new WebProxy(proxy.Server, proxy.Port);
+ return webProxy;
}
else
{
- request.Proxy = new WebProxy(proxy.Server, proxy.Port)
+ var webProxy = new WebProxy(proxy.Server, proxy.Port)
{
Credentials = new NetworkCredential(proxy.UserName, proxy.Password)
};
+ return webProxy;
}
}
- using (var streamWriter = new StreamWriter(request.GetRequestStream()))
+ else
{
- streamWriter.Write(jsonData);
- streamWriter.Flush();
- streamWriter.Close();
+ return null;
}
+ }
+ public static async Task Get([NotNull] string url, IHttpProxy proxy, string encoding = "UTF-8")
+ {
+
+ HttpWebRequest request = WebRequest.CreateHttp(url);
+ request.Method = "GET";
+ request.Timeout = 10 * 1000;
+ request.Proxy = GetWebProxy(proxy);
+ request.UserAgent = @"Mozilla/5.0 (Trident/7.0; rv:11.0) like Gecko";
+ HttpWebResponse response;
try
{
- HttpWebResponse response = request.GetResponse() as HttpWebResponse;
- if (response != null)
- {
- Stream stream = response.GetResponseStream();
- if (stream != null)
- {
- using (StreamReader reader = new StreamReader(stream, Encoding.GetEncoding("UTF-8")))
- {
- return reader.ReadToEnd();
- }
- }
- }
+ response = await request.GetResponseAsync() as HttpWebResponse;
}
- catch (System.Exception e)
+ catch (WebException e)
{
Log.Error(e);
return string.Empty;
}
-
- return string.Empty;
+ if (response != null)
+ {
+ var stream = response.GetResponseStream();
+ if (stream != null)
+ {
+ using (var reader = new StreamReader(stream, Encoding.GetEncoding(encoding)))
+ {
+ return await reader.ReadToEndAsync();
+ }
+ }
+ else
+ {
+ return string.Empty;
+ }
+ }
+ else
+ {
+ return string.Empty;
+ }
}
}
}
\ No newline at end of file
diff --git a/Wox.Infrastructure/Wox.Infrastructure.csproj b/Wox.Infrastructure/Wox.Infrastructure.csproj
index dcdb0e2be..77653ce8a 100644
--- a/Wox.Infrastructure/Wox.Infrastructure.csproj
+++ b/Wox.Infrastructure/Wox.Infrastructure.csproj
@@ -57,6 +57,7 @@
+
diff --git a/Wox.Infrastructure/Wox.cs b/Wox.Infrastructure/Wox.cs
index 3e04189da..c6353acfb 100644
--- a/Wox.Infrastructure/Wox.cs
+++ b/Wox.Infrastructure/Wox.cs
@@ -1,4 +1,5 @@
using System;
+using System.Diagnostics;
using System.IO;
using System.Reflection;
@@ -10,11 +11,13 @@ namespace Wox.Infrastructure
public const string Plugins = "Plugins";
public const string Settings = "Settings";
- public static readonly string ProgramPath = Directory.GetParent(Assembly.GetExecutingAssembly().Location).ToString();
+ private static readonly Assembly Assembly = Assembly.GetExecutingAssembly();
+ public static readonly string ProgramPath = Directory.GetParent(Assembly.Location).ToString();
public static readonly string DataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), Name);
public static readonly string UserDirectory = Path.Combine(DataPath, Plugins);
public static readonly string PreinstalledDirectory = Path.Combine(ProgramPath, Plugins);
public static readonly string SettingsPath = Path.Combine(DataPath, Settings);
public const string Github = "https://github.com/Wox-launcher/Wox";
+ public static readonly string Version = FileVersionInfo.GetVersionInfo(Assembly.Location).ProductVersion;
}
}
diff --git a/Wox.Test/SemanticVersionTest.cs b/Wox.Test/SemanticVersionTest.cs
deleted file mode 100644
index 5b7097b69..000000000
--- a/Wox.Test/SemanticVersionTest.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-using NUnit.Framework;
-using Wox.Core.Updater;
-
-namespace Wox.Test
-{
- [TestFixture]
- public class SemanticVersionTest
- {
- [Test]
- public void CompareTest()
- {
- SemanticVersion v1 = new SemanticVersion(1, 1, 0);
- SemanticVersion v2 = new SemanticVersion(1, 2, 0);
- SemanticVersion v3 = new SemanticVersion(1, 1, 0);
- SemanticVersion v4 = new SemanticVersion("1.1.0");
- Assert.IsTrue(v1 < v2);
- Assert.IsTrue(v2 > v1);
- Assert.IsTrue(v1 == v3);
- Assert.IsTrue(v1.Equals(v3));
- Assert.IsTrue(v1 == v4);
- }
- }
-}
diff --git a/Wox.Test/Wox.Test.csproj b/Wox.Test/Wox.Test.csproj
index e1b65e45b..0827bde5a 100644
--- a/Wox.Test/Wox.Test.csproj
+++ b/Wox.Test/Wox.Test.csproj
@@ -52,7 +52,6 @@
-
diff --git a/Wox/App.xaml.cs b/Wox/App.xaml.cs
index 842bd91a4..2412eb3d9 100644
--- a/Wox/App.xaml.cs
+++ b/Wox/App.xaml.cs
@@ -1,5 +1,6 @@
using System;
using System.Diagnostics;
+using System.Net;
using System.Windows;
using Squirrel;
using Wox.Core.Plugin;
@@ -57,14 +58,26 @@ namespace Wox
{
try
{
- using (Updater = await UpdateManager.GitHubUpdateManager(Infrastructure.Wox.Github, prerelease: true))
+ using (Updater = await UpdateManager.GitHubUpdateManager(Infrastructure.Wox.Github))
{
await Updater.UpdateApp();
}
}
+ catch (WebException ex)
+ {
+ Log.Error(ex);
+ }
catch (Exception exception)
{
- Log.Error(exception);
+ const string info = "Update.exe not found, not a Squirrel-installed app?";
+ if (exception.Message == info)
+ {
+ Log.Warn(info);
+ }
+ else
+ {
+ throw;
+ }
}
}
diff --git a/Wox/CommandArgs/CommandArgsFactory.cs b/Wox/CommandArgs/CommandArgsFactory.cs
deleted file mode 100644
index 2b7a7b8b5..000000000
--- a/Wox/CommandArgs/CommandArgsFactory.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Reflection;
-using Wox.Helper;
-
-namespace Wox.CommandArgs
-{
- internal static class CommandArgsFactory
- {
- private static List commandArgs;
-
- static CommandArgsFactory()
- {
- var type = typeof(ICommandArg);
- commandArgs = Assembly.GetExecutingAssembly()
- .GetTypes()
- .Where(p => type.IsAssignableFrom(p) && !p.IsInterface)
- .Select(t => Activator.CreateInstance(t) as ICommandArg).ToList();
- }
-
- public static void Execute(IList args)
- {
- // todo restart command line args?
- //if (args.Count > 0 && args[0] != SingleInstance.Restart)
- if (args.Count > 0)
- {
- string command = args[0];
- ICommandArg cmd = commandArgs.FirstOrDefault(o => o.Command.ToLower() == command);
- if (cmd != null)
- {
- args.RemoveAt(0); //remove command itself
- cmd.Execute(args);
- }
- }
- else
- {
- App.API.ShowApp();
- }
- }
- }
-}
diff --git a/Wox/CommandArgs/HideStartCommandArg.cs b/Wox/CommandArgs/HideStartCommandArg.cs
deleted file mode 100644
index 1918858b1..000000000
--- a/Wox/CommandArgs/HideStartCommandArg.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using System.Collections.Generic;
-
-namespace Wox.CommandArgs
-{
- public class HideStartCommandArg : ICommandArg
- {
- public string Command
- {
- get { return "hidestart"; }
- }
-
- public void Execute(IList args)
- {
- //App.Window.ShowApp();
- //App.Window.HideApp();
- }
- }
-}
diff --git a/Wox/CommandArgs/ICommandArg.cs b/Wox/CommandArgs/ICommandArg.cs
deleted file mode 100644
index 11db54557..000000000
--- a/Wox/CommandArgs/ICommandArg.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System.Collections.Generic;
-
-namespace Wox.CommandArgs
-{
- interface ICommandArg
- {
- string Command { get; }
- void Execute(IList args);
- }
-}
diff --git a/Wox/CommandArgs/InstallPluginCommandArg.cs b/Wox/CommandArgs/InstallPluginCommandArg.cs
deleted file mode 100644
index 524115b4d..000000000
--- a/Wox/CommandArgs/InstallPluginCommandArg.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-using System.Collections.Generic;
-using System.IO;
-using System.Windows;
-using Wox.Core.Plugin;
-
-namespace Wox.CommandArgs
-{
- public class InstallPluginCommandArg : ICommandArg
- {
- public string Command
- {
- get { return "installplugin"; }
- }
-
- public void Execute(IList args)
- {
- if (args.Count > 0)
- {
- var path = args[0];
- if (!File.Exists(path))
- {
- MessageBox.Show("Plugin " + path + " didn't exist");
- return;
- }
- PluginManager.InstallPlugin(path);
- }
- }
- }
-}
\ No newline at end of file
diff --git a/Wox/CommandArgs/QueryCommandArg.cs b/Wox/CommandArgs/QueryCommandArg.cs
deleted file mode 100644
index d1df8e0a5..000000000
--- a/Wox/CommandArgs/QueryCommandArg.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-using System;
-using System.Collections.Generic;
-
-namespace Wox.CommandArgs
-{
- public class QueryCommandArg : ICommandArg
- {
- public string Command
- {
- get { return "query"; }
- }
-
- public void Execute(IList args)
- {
- Console.WriteLine("test");
- if (args.Count > 0)
- {
- string query = args[0];
- App.API.ChangeQuery(query);
- }
- App.API.ShowApp();
- }
- }
-}
diff --git a/Wox/CommandArgs/ToggleCommandArg.cs b/Wox/CommandArgs/ToggleCommandArg.cs
deleted file mode 100644
index e50931629..000000000
--- a/Wox/CommandArgs/ToggleCommandArg.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-using System.Collections.Generic;
-
-namespace Wox.CommandArgs
-{
- public class ToggleCommandArg:ICommandArg
- {
- public string Command
- {
- get { return "toggle"; }
- }
-
- public void Execute(IList args)
- {
- if (App.Window.IsVisible)
- {
- App.API.HideApp();
- }
- else
- {
- App.API.ShowApp();
- }
- }
- }
-}
diff --git a/Wox/Languages/en.xaml b/Wox/Languages/en.xaml
index 71065ba6b..35d0a80db 100644
--- a/Wox/Languages/en.xaml
+++ b/Wox/Languages/en.xaml
@@ -78,6 +78,9 @@
About
Website
Version
+ Check Updates
+ New Version {0} avaiable, please restart
+ Release Notes:
You have activated Wox {0} times
diff --git a/Wox/MainWindow.xaml.cs b/Wox/MainWindow.xaml.cs
index cf9e20e62..4d94ef8d9 100644
--- a/Wox/MainWindow.xaml.cs
+++ b/Wox/MainWindow.xaml.cs
@@ -7,7 +7,6 @@ using System.Windows.Media.Animation;
using System.Windows.Controls;
using Wox.Core.Plugin;
using Wox.Core.Resource;
-using Wox.Core.Updater;
using Wox.Core.UserSettings;
using Wox.Helper;
using Wox.Infrastructure.Hotkey;
@@ -47,8 +46,6 @@ namespace Wox
private void OnLoaded(object sender, RoutedEventArgs _)
{
- CheckUpdate();
-
InitProgressbarAnimation();
WindowIntelopHelper.DisableControlBox(this);
@@ -110,27 +107,6 @@ namespace Wox
return top;
}
- private void CheckUpdate()
- {
- UpdaterManager.Instance.PrepareUpdateReady += OnPrepareUpdateReady;
- UpdaterManager.Instance.UpdateError += OnUpdateError;
- UpdaterManager.Instance.CheckUpdate();
- }
-
- void OnUpdateError(object sender, EventArgs e)
- {
- string updateError = InternationalizationManager.Instance.GetTranslation("update_wox_update_error");
- MessageBox.Show(updateError);
- }
-
- private void OnPrepareUpdateReady(object sender, EventArgs e)
- {
- Dispatcher.Invoke(() =>
- {
- new WoxUpdate().ShowDialog();
- });
- }
-
private void InitProgressbarAnimation()
{
var da = new DoubleAnimation(ProgressBar.X2, ActualWidth + 100, new Duration(new TimeSpan(0, 0, 0, 0, 1600)));
diff --git a/Wox/PublicAPIInstance.cs b/Wox/PublicAPIInstance.cs
index 500df1217..c4626cba8 100644
--- a/Wox/PublicAPIInstance.cs
+++ b/Wox/PublicAPIInstance.cs
@@ -68,6 +68,11 @@ namespace Wox
public void RestarApp()
{
+ HideWox();
+ // we must force dispose application
+ // UpdateManager.RestartApp() will call Environment.Exit(0)
+ // which will cause ungraceful exit
+ ((IDisposable) Application.Current).Dispose();
UpdateManager.RestartApp();
}
diff --git a/Wox/SettingWindow.xaml b/Wox/SettingWindow.xaml
index 9fd385ecf..45bd9442f 100644
--- a/Wox/SettingWindow.xaml
+++ b/Wox/SettingWindow.xaml
@@ -340,27 +340,42 @@
-
-
+
+
+
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+ https://github.com/Wox-launcher/Wox
+
+
+
+
+
+
+
+
+
+
+ https://github.com/Wox-launcher/Wox/releases/latest
+
+
+
+
+
+
diff --git a/Wox/SettingWindow.xaml.cs b/Wox/SettingWindow.xaml.cs
index 5ce33428d..46d8128eb 100644
--- a/Wox/SettingWindow.xaml.cs
+++ b/Wox/SettingWindow.xaml.cs
@@ -4,6 +4,8 @@ using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
+using System.Reflection;
+using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
@@ -11,16 +13,21 @@ using System.Windows.Forms;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
using Microsoft.Win32;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
using NHotkey;
using NHotkey.Wpf;
+using Squirrel;
using Wox.Core.Plugin;
using Wox.Core.Resource;
-using Wox.Core.Updater;
using Wox.Core.UserSettings;
using Wox.Helper;
using Wox.Infrastructure.Hotkey;
+using Wox.Infrastructure.Http;
using Wox.Infrastructure.Image;
+using Wox.Infrastructure.Logger;
using Wox.Plugin;
using Wox.ViewModel;
using Application = System.Windows.Forms.Application;
@@ -56,9 +63,10 @@ namespace Wox
_settings.ProxyEnabled = ToggleProxy.IsChecked ?? false;
}
- private void Setting_Loaded(object sender, RoutedEventArgs ev)
+ private async void Setting_Loaded(object sender, RoutedEventArgs ev)
{
#region General
+
cbHideWhenDeactive.Checked += (o, e) =>
{
_settings.HideWhenDeactive = true;
@@ -137,10 +145,10 @@ namespace Wox
#region About
- tbVersion.Text = UpdaterManager.Instance.CurrentVersion.ToString();
- string activateTimes = string.Format(InternationalizationManager.Instance.GetTranslation("about_activate_times"),
- _settings.ActivateTimes);
- tbActivatedTimes.Text = activateTimes;
+ string activateTimes = string.Format(
+ InternationalizationManager.Instance.GetTranslation("about_activate_times"), _settings.ActivateTimes);
+ ActivatedTimes.Text = activateTimes;
+ tbVersion.Text = Infrastructure.Wox.Version;
#endregion
@@ -221,7 +229,9 @@ namespace Wox
private void AddApplicationToStartup()
{
- using (RegistryKey key = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true))
+ using (
+ RegistryKey key = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run",
+ true))
{
key.SetValue("Wox", "\"" + Application.ExecutablePath + "\" --hidestart");
}
@@ -229,7 +239,9 @@ namespace Wox
private void RemoveApplicationFromStartup()
{
- using (RegistryKey key = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true))
+ using (
+ RegistryKey key = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run",
+ true))
{
key.DeleteValue("Wox", false);
}
@@ -237,7 +249,9 @@ namespace Wox
private bool CheckApplicationIsStartupWithWindow()
{
- using (RegistryKey key = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true))
+ using (
+ RegistryKey key = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run",
+ true))
{
return key.GetValue("Wox") != null;
}
@@ -270,6 +284,7 @@ namespace Wox
}
}
}
+
#endregion
#region Hotkey
@@ -303,7 +318,8 @@ namespace Wox
}
catch (Exception)
{
- string errorMsg = string.Format(InternationalizationManager.Instance.GetTranslation("registerHotkeyFailed"), hotkeyStr);
+ string errorMsg =
+ string.Format(InternationalizationManager.Instance.GetTranslation("registerHotkeyFailed"), hotkeyStr);
MessageBox.Show(errorMsg);
}
}
@@ -332,8 +348,12 @@ namespace Wox
return;
}
- string deleteWarning = string.Format(InternationalizationManager.Instance.GetTranslation("deleteCustomHotkeyWarning"), item.Hotkey);
- if (MessageBox.Show(deleteWarning, InternationalizationManager.Instance.GetTranslation("delete"), MessageBoxButton.YesNo) == MessageBoxResult.Yes)
+ string deleteWarning =
+ string.Format(InternationalizationManager.Instance.GetTranslation("deleteCustomHotkeyWarning"),
+ item.Hotkey);
+ if (
+ MessageBox.Show(deleteWarning, InternationalizationManager.Instance.GetTranslation("delete"),
+ MessageBoxButton.YesNo) == MessageBoxResult.Yes)
{
_settings.CustomPluginHotkeys.Remove(item);
lvCustomHotkey.Items.Refresh();
@@ -390,22 +410,26 @@ namespace Wox
{
cbQueryBoxFont.Text = _settings.QueryBoxFont;
- cbQueryBoxFontFaces.SelectedItem = SyntaxSugars.CallOrRescueDefault(() => ((FontFamily)cbQueryBoxFont.SelectedItem).ConvertFromInvariantStringsOrNormal(
- _settings.QueryBoxFontStyle,
- _settings.QueryBoxFontWeight,
- _settings.QueryBoxFontStretch
- ));
+ cbQueryBoxFontFaces.SelectedItem =
+ SyntaxSugars.CallOrRescueDefault(
+ () => ((FontFamily)cbQueryBoxFont.SelectedItem).ConvertFromInvariantStringsOrNormal(
+ _settings.QueryBoxFontStyle,
+ _settings.QueryBoxFontWeight,
+ _settings.QueryBoxFontStretch
+ ));
}
if (!string.IsNullOrEmpty(_settings.ResultFont) &&
Fonts.SystemFontFamilies.Count(o => o.FamilyNames.Values.Contains(_settings.ResultFont)) > 0)
{
ResultFontComboBox.Text = _settings.ResultFont;
- ResultFontFacesComboBox.SelectedItem = SyntaxSugars.CallOrRescueDefault(() => ((FontFamily)ResultFontComboBox.SelectedItem).ConvertFromInvariantStringsOrNormal(
- _settings.ResultFontStyle,
- _settings.ResultFontWeight,
- _settings.ResultFontStretch
- ));
+ ResultFontFacesComboBox.SelectedItem =
+ SyntaxSugars.CallOrRescueDefault(
+ () => ((FontFamily)ResultFontComboBox.SelectedItem).ConvertFromInvariantStringsOrNormal(
+ _settings.ResultFontStyle,
+ _settings.ResultFontWeight,
+ _settings.ResultFontStretch
+ ));
}
ResultListBoxPreview.AddResults(new List
@@ -526,7 +550,8 @@ namespace Wox
if (!settingsLoaded) return;
string resultItemFont = ResultFontComboBox.SelectedItem.ToString();
_settings.ResultFont = resultItemFont;
- ResultFontFacesComboBox.SelectedItem = ((FontFamily)ResultFontComboBox.SelectedItem).ChooseRegularFamilyTypeface();
+ ResultFontFacesComboBox.SelectedItem =
+ ((FontFamily)ResultFontComboBox.SelectedItem).ChooseRegularFamilyTypeface();
ThemeManager.Instance.ChangeTheme(_settings.Theme);
}
@@ -564,7 +589,8 @@ namespace Wox
pluginInitTime.Text =
string.Format(InternationalizationManager.Instance.GetTranslation("plugin_init_time"), pair.InitTime);
pluginQueryTime.Text =
- string.Format(InternationalizationManager.Instance.GetTranslation("plugin_query_time"), pair.AvgQueryTime);
+ string.Format(InternationalizationManager.Instance.GetTranslation("plugin_query_time"),
+ pair.AvgQueryTime);
if (actionKeywords.Count > 1)
{
pluginActionKeywordsTitle.Visibility = Visibility.Collapsed;
@@ -579,7 +605,8 @@ namespace Wox
pluginTitle.Text = pair.Metadata.Name;
pluginTitle.Cursor = Cursors.Hand;
pluginActionKeywords.Text = string.Join(Query.ActionKeywordSeperater, actionKeywords.ToArray());
- pluginAuthor.Text = InternationalizationManager.Instance.GetTranslation("author") + ": " + pair.Metadata.Author;
+ pluginAuthor.Text = InternationalizationManager.Instance.GetTranslation("author") + ": " +
+ pair.Metadata.Author;
pluginSubTitle.Text = pair.Metadata.Description;
pluginId = pair.Metadata.ID;
pluginIcon.Source = ImageLoader.Load(pair.Metadata.IcoPath);
@@ -651,7 +678,9 @@ namespace Wox
ActionKeywords changeKeywordsWindow = new ActionKeywords(id, _settings);
changeKeywordsWindow.ShowDialog();
PluginPair plugin = PluginManager.GetPluginForId(id);
- if (plugin != null) pluginActionKeywords.Text = string.Join(Query.ActionKeywordSeperater, pair.Metadata.ActionKeywords.ToArray());
+ if (plugin != null)
+ pluginActionKeywords.Text = string.Join(Query.ActionKeywordSeperater,
+ pair.Metadata.ActionKeywords.ToArray());
}
}
}
@@ -671,7 +700,8 @@ namespace Wox
Process.Start(pair.Metadata.Website);
}
catch
- { }
+ {
+ }
}
}
}
@@ -692,7 +722,8 @@ namespace Wox
Process.Start(pair.Metadata.PluginDirectory);
}
catch
- { }
+ {
+ }
}
}
}
@@ -719,6 +750,7 @@ namespace Wox
#endregion
#region Proxy
+
private void btnSaveProxy_Click(object sender, RoutedEventArgs e)
{
_settings.ProxyEnabled = ToggleProxy.IsChecked ?? false;
@@ -806,7 +838,7 @@ namespace Wox
private void tbWebsite_MouseUp(object sender, MouseButtonEventArgs e)
{
- Process.Start("http://www.getwox.com");
+ Process.Start(Infrastructure.Wox.Github);
}
#endregion
@@ -820,5 +852,84 @@ namespace Wox
}
}
+ private async void OnCheckUpdates(object sender, RoutedEventArgs e)
+ {
+ var version = await NewVersion();
+ if (!string.IsNullOrEmpty(version))
+ {
+ var newVersion = NumericVersion(version);
+ var oldVersion = NumericVersion(Infrastructure.Wox.Version);
+ if (newVersion > oldVersion)
+ {
+ NewVersionTips.Text = string.Format(NewVersionTips.Text, version);
+ NewVersionTips.Visibility = Visibility.Visible;
+ UpdateApp();
+ }
+ }
+ }
+
+ private async void UpdateApp()
+ {
+ try
+ {
+ using (var updater = await UpdateManager.GitHubUpdateManager(Infrastructure.Wox.Github))
+ {
+ // todo 5/9 the return value of UpdateApp() is NULL, fucking useless!
+ await updater.UpdateApp();
+ }
+ }
+ catch (WebException ex)
+ {
+ Log.Error(ex);
+ }
+ catch (Exception ex)
+ {
+ Log.Error(ex);
+ }
+ }
+ private async Task NewVersion()
+ {
+ const string githubAPI = @"https://api.github.com/repos/wox-launcher/wox/releases/latest";
+ var response = await HttpRequest.Get(githubAPI, HttpProxy.Instance);
+
+ if (!string.IsNullOrEmpty(response))
+ {
+ JContainer json;
+ try
+ {
+ json = (JContainer)JsonConvert.DeserializeObject(response);
+ }
+ catch (JsonSerializationException e)
+ {
+ Log.Error(e);
+ return string.Empty;
+ }
+ var version = json?["tag_name"]?.ToString();
+ if (!string.IsNullOrEmpty(version))
+ {
+ return version;
+ }
+ else
+ {
+ return string.Empty;
+ }
+ }
+ else
+ {
+ return string.Empty;
+ }
+ }
+
+ private
+ int NumericVersion(string version)
+ {
+ var newVersion = version.Replace("v", ".").Replace(".", "").Replace("*", "");
+ return int.Parse(newVersion);
+ }
+ private void OnRequestNavigate(object sender, RequestNavigateEventArgs e)
+ {
+ Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri));
+ e.Handled = true;
+ }
}
}
diff --git a/Wox/ViewModel/MainViewModel.cs b/Wox/ViewModel/MainViewModel.cs
index a8a8e7f1f..4a7978c6a 100644
--- a/Wox/ViewModel/MainViewModel.cs
+++ b/Wox/ViewModel/MainViewModel.cs
@@ -7,7 +7,6 @@ using System.Windows;
using System.Windows.Input;
using Wox.Core.Plugin;
using Wox.Core.Resource;
-using Wox.Core.Updater;
using Wox.Core.UserSettings;
using Wox.Helper;
using Wox.Infrastructure;
@@ -64,7 +63,6 @@ namespace Wox.ViewModel
// happlebao todo temp fix for instance code logic
HttpProxy.Instance.Settings = _settings;
- UpdaterManager.Instance.Settings = _settings;
InternationalizationManager.Instance.Settings = _settings;
InternationalizationManager.Instance.ChangeLanguage(_settings.Language);
ThemeManager.Instance.Settings = _settings;
diff --git a/Wox/Wox.csproj b/Wox/Wox.csproj
index 857b5d521..9c7fe0001 100644
--- a/Wox/Wox.csproj
+++ b/Wox/Wox.csproj
@@ -157,7 +157,6 @@
Properties\SolutionAssemblyInfo.cs
-
@@ -172,9 +171,6 @@
-
- WoxUpdate.xaml
-
MSBuild:Compile
Designer
@@ -182,11 +178,6 @@
ActionKeywords.xaml
-
-
-
-
-
@@ -332,10 +323,6 @@
Designer
PreserveNewest
-
- Designer
- MSBuild:Compile
-
@@ -418,29 +405,31 @@
- xcopy /Y $(ProjectDir)Themes\* $(TargetDir)Themes\
-xcopy /Y /E $(ProjectDir)Images\* $(TargetDir)Images\
-xcopy /Y /D /E $(SolutionDir)Plugins\HelloWorldPython\* $(TargetDir)Plugins\HelloWorldPython\*
-
+
+ xcopy /Y $(ProjectDir)Themes\* $(TargetDir)Themes\
+ xcopy /Y /E $(ProjectDir)Images\* $(TargetDir)Images\
+ xcopy /Y /D /E $(SolutionDir)Plugins\HelloWorldPython\* $(TargetDir)Plugins\HelloWorldPython\*
-if $(ConfigurationName) == Release (
-cd "$(TargetDir)Plugins" & del /s /q NLog.dll
-cd "$(TargetDir)Plugins" & del /s /q NLog.config
-cd "$(TargetDir)Plugins" & del /s /q Wox.Plugin.pdb
-cd "$(TargetDir)Plugins" & del /s /q Wox.Plugin.dll
-cd "$(TargetDir)Plugins" & del /s /q Wox.Core.dll
-cd "$(TargetDir)Plugins" & del /s /q Wox.Core.pdb
-cd "$(TargetDir)Plugins" & del /s /q ICSharpCode.SharpZipLib.dll
-cd "$(TargetDir)Plugins" & del /s /q NAppUpdate.Framework.dll
-cd "$(TargetDir)Plugins" & del /s /q Wox.Infrastructure.dll
-cd "$(TargetDir)Plugins" & del /s /q Wox.Infrastructure.pdb
-cd "$(TargetDir)Plugins" & del /s /q Newtonsoft.Json.dll
-cd "$(TargetDir)Plugins" & del /s /q JetBrains.Annotations.dll
-cd "$(TargetDir)Plugins" & del /s /q Pinyin4Net.dll
-cd "$(TargetDir)" & del /s /q *.xml
-)
+ if $(ConfigurationName) == Release (
+ cd "$(TargetDir)Plugins" & del /s /q NLog.dll
+ cd "$(TargetDir)Plugins" & del /s /q NLog.config
+ cd "$(TargetDir)Plugins" & del /s /q Wox.Plugin.pdb
+ cd "$(TargetDir)Plugins" & del /s /q Wox.Plugin.dll
+ cd "$(TargetDir)Plugins" & del /s /q Wox.Core.dll
+ cd "$(TargetDir)Plugins" & del /s /q Wox.Core.pdb
+ cd "$(TargetDir)Plugins" & del /s /q ICSharpCode.SharpZipLib.dll
+ cd "$(TargetDir)Plugins" & del /s /q NAppUpdate.Framework.dll
+ cd "$(TargetDir)Plugins" & del /s /q Wox.Infrastructure.dll
+ cd "$(TargetDir)Plugins" & del /s /q Wox.Infrastructure.pdb
+ cd "$(TargetDir)Plugins" & del /s /q Newtonsoft.Json.dll
+ cd "$(TargetDir)Plugins" & del /s /q JetBrains.Annotations.dll
+ cd "$(TargetDir)Plugins" & del /s /q Pinyin4Net.dll
+
+ cd "$(TargetDir)" & del /s /q *.xml
+ )
+
@@ -448,9 +437,14 @@ cd "$(TargetDir)" & del /s /q *.xml
-
+
+
+
+
+
+
- -->
\ No newline at end of file
diff --git a/Wox/WoxUpdate.xaml b/Wox/WoxUpdate.xaml
deleted file mode 100644
index 23687ff5a..000000000
--- a/Wox/WoxUpdate.xaml
+++ /dev/null
@@ -1,46 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Wox/WoxUpdate.xaml.cs b/Wox/WoxUpdate.xaml.cs
deleted file mode 100644
index 83f7e57d5..000000000
--- a/Wox/WoxUpdate.xaml.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-using System.Windows;
-using MarkdownSharp;
-using Wox.Core.Resource;
-using Wox.Core.Updater;
-
-namespace Wox
-{
- public partial class WoxUpdate : Window
- {
- public WoxUpdate()
- {
- InitializeComponent();
-
- string newVersionAvailable = string.Format(
- InternationalizationManager.Instance.GetTranslation("update_wox_update_new_version_available"),
- UpdaterManager.Instance.NewRelease);
- tbNewVersionAvailable.Text = newVersionAvailable;
- Markdown markdown = new Markdown();
- wbDetails.NavigateToString(markdown.Transform(UpdaterManager.Instance.NewRelease.description));
- lbUpdatedFiles.ItemsSource = UpdaterManager.Instance.GetAvailableUpdateFiles();
- }
-
- private void btnUpdate_Click(object sender, RoutedEventArgs e)
- {
- UpdaterManager.Instance.ApplyUpdates();
- }
-
- private void btnCancel_Click(object sender, RoutedEventArgs e)
- {
- UpdaterManager.Instance.CleanUp();
- Close();
- }
- }
-}
diff --git a/Wox/packages.config b/Wox/packages.config
index e82276498..d828900ca 100644
--- a/Wox/packages.config
+++ b/Wox/packages.config
@@ -8,6 +8,7 @@
+
diff --git a/appveyor.yml b/appveyor.yml
index 437f7f60e..a8c2e4fe3 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -7,7 +7,7 @@ assembly_info:
file: AssemblyInfo.*
assembly_version: '{version}'
assembly_file_version: '{version}'
- assembly_informational_version: '{version}-$(APPVEYOR_REPO_COMMIT)'
+ assembly_informational_version: '{version}'
before_build:
- ps: nuget restore
build:
@@ -17,7 +17,7 @@ after_test:
.\Deploy\nuget.ps1
.\Deploy\binary_zip.ps1
-
+
.\Deploy\squirrel_installer.ps1
artifacts:
- path: 'Wox-*.zip'