diff --git a/EveChatNotifier/App_Readme/Spring.Rest.txt b/EveChatNotifier/App_Readme/Spring.Rest.txt new file mode 100644 index 0000000..980d2f8 --- /dev/null +++ b/EveChatNotifier/App_Readme/Spring.Rest.txt @@ -0,0 +1,4 @@ +Spring.NET REST Client Framework +-------------------------------- +Download full package with sources, documentation and examples at +http://www.springframework.net/rest/ diff --git a/EveChatNotifier/EveChatNotifier.csproj b/EveChatNotifier/EveChatNotifier.csproj index d6cf2e9..bcc1a83 100644 --- a/EveChatNotifier/EveChatNotifier.csproj +++ b/EveChatNotifier/EveChatNotifier.csproj @@ -8,8 +8,9 @@ WinExe EveChatNotifier EveChatNotifier - v4.0 + v4.5.2 512 + AnyCPU @@ -20,6 +21,7 @@ DEBUG;TRACE prompt 4 + false AnyCPU @@ -29,26 +31,31 @@ TRACE prompt 4 + false preferences_desktop_notification_bell.ico - - ..\packages\Autoupdater.NET.Official.1.4.6\lib\net40\AutoUpdater.NET.dll + + ..\packages\Autoupdater.NET.Official.1.4.9\lib\net40\AutoUpdater.NET.dll - - ..\packages\TaskScheduler.2.7.2\lib\net40\Microsoft.Win32.TaskScheduler.dll + + ..\packages\TaskScheduler.2.8.1\lib\net40\Microsoft.Win32.TaskScheduler.dll ..\packages\NAudio.1.8.4\lib\net35\NAudio.dll - - ..\packages\Newtonsoft.Json.10.0.3\lib\net40\Newtonsoft.Json.dll + + ..\packages\Newtonsoft.Json.11.0.2\lib\net40\Newtonsoft.Json.dll + + + ..\packages\RestSharp.106.2.2\lib\net452\RestSharp.dll + @@ -66,6 +73,7 @@ + diff --git a/EveChatNotifier/GithubUpdater/GithubReleaseRestSharp.cs b/EveChatNotifier/GithubUpdater/GithubReleaseRestSharp.cs new file mode 100644 index 0000000..d524aa6 --- /dev/null +++ b/EveChatNotifier/GithubUpdater/GithubReleaseRestSharp.cs @@ -0,0 +1,89 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EveChatNotifier.GithubUpdater +{ + public class GithubReleaseRestSharp + { + public string url { get; set; } + public string assets_url { get; set; } + public string upload_url { get; set; } + public string html_url { get; set; } + public int id { get; set; } + public string tag_name { get; set; } + public string target_commitish { get; set; } + public string name { get; set; } + public bool draft { get; set; } + public Author author { get; set; } + public bool prerelease { get; set; } + public DateTime created_at { get; set; } + public DateTime published_at { get; set; } + public List assets { get; set; } + public string tarball_url { get; set; } + public string zipball_url { get; set; } + public string body { get; set; } + } + + public class Author + { + public string login { get; set; } + public int id { get; set; } + public string avatar_url { get; set; } + public string gravatar_id { get; set; } + public string url { get; set; } + public string html_url { get; set; } + public string followers_url { get; set; } + public string following_url { get; set; } + public string gists_url { get; set; } + public string starred_url { get; set; } + public string subscriptions_url { get; set; } + public string organizations_url { get; set; } + public string repos_url { get; set; } + public string events_url { get; set; } + public string received_events_url { get; set; } + public string type { get; set; } + public bool site_admin { get; set; } + } + + public class Uploader + { + public string login { get; set; } + public int id { get; set; } + public string avatar_url { get; set; } + public string gravatar_id { get; set; } + public string url { get; set; } + public string html_url { get; set; } + public string followers_url { get; set; } + public string following_url { get; set; } + public string gists_url { get; set; } + public string starred_url { get; set; } + public string subscriptions_url { get; set; } + public string organizations_url { get; set; } + public string repos_url { get; set; } + public string events_url { get; set; } + public string received_events_url { get; set; } + public string type { get; set; } + public bool site_admin { get; set; } + } + + public class Asset + { + public string url { get; set; } + public int id { get; set; } + public string name { get; set; } + public object label { get; set; } + public Uploader uploader { get; set; } + public string content_type { get; set; } + public string state { get; set; } + public int size { get; set; } + public int download_count { get; set; } + public DateTime created_at { get; set; } + public DateTime updated_at { get; set; } + public string browser_download_url { get; set; } + } +} diff --git a/EveChatNotifier/GithubUpdater/GithubUpdateCheck.cs b/EveChatNotifier/GithubUpdater/GithubUpdateCheck.cs index 587fd08..4d25a15 100644 --- a/EveChatNotifier/GithubUpdater/GithubUpdateCheck.cs +++ b/EveChatNotifier/GithubUpdater/GithubUpdateCheck.cs @@ -1,4 +1,5 @@ using AutoUpdaterDotNET; +using RestSharp; using System; using System.Collections.Generic; using System.IO; @@ -25,9 +26,32 @@ public static void UpdateUsingLocalXmlFile(string gitUserName, string repoName) try { - wc.DownloadStringCompleted += Wc_DownloadStringCompleted; - wc.Headers.Add("user-agent", repoName); - wc.DownloadStringAsync(new Uri(string.Format(@"https://api.github.com/repos/{0}/{1}/releases/latest", gitUserName, repoName))); + // no idea why but we need to fallback to TSL1.2 in order to retrieve github information ... + //ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true; + //ServicePointManager.Expect100Continue = true; + ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; + + Uri reqUri = new Uri(string.Format(@"http://api.github.com/repos/{0}/{1}/releases/latest", gitUserName, repoName)); + + RestClient client = new RestClient(@"https://api.github.com"); + RestRequest request = new RestRequest("repos/{username}/{reponame}/releases/latest", Method.GET); + request.AddUrlSegment("username", gitUserName); + request.AddUrlSegment("reponame", repoName); + request.AddHeader("user-agent", repoName); + request.RequestFormat = DataFormat.Json; + request.JsonSerializer = new RestSharp.Serializers.JsonSerializer(); + + client.ExecuteAsync(request, (response) => + { + if(response.IsSuccessful) + { + RestReleaseCheck(response.Data); + } + else + { + Logging.WriteLine(string.Format("Unable to start update procedure:{0}{1}", Environment.NewLine, response.ErrorMessage)); + } + }); } catch (Exception ex) { @@ -35,12 +59,63 @@ public static void UpdateUsingLocalXmlFile(string gitUserName, string repoName) } } - /// - /// start auto update after download - /// - /// - /// - private static void Wc_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) + /// + /// RestSharp update detection + /// + /// + private static void RestReleaseCheck(GithubUpdater.GithubReleaseRestSharp release) + { + try + { + // generate update information object + UpdaterXml.item update = new UpdaterXml.item(); + update.url = release.assets.Where(w => w.browser_download_url.EndsWith(".zip", StringComparison.OrdinalIgnoreCase)).First().browser_download_url; + update.version = release.tag_name; + update.changelog = releaseUrl; + update.mandatory = false; + + // generate xml file + string updateUrl = null; + do + { + updateUrl = System.IO.Path.Combine(System.IO.Path.GetTempPath(), string.Format("{0}.xml", Guid.NewGuid().ToString("N"))); + } while (System.IO.File.Exists(updateUrl)); + + // add file to cleanup job + Cleanup.GetInstance().FilesToDelete.AddIfNotExist(updateUrl); + + // serialize to file + using (TextWriter writer = new StreamWriter(updateUrl, false)) + { + XmlSerializer serializer = new XmlSerializer(typeof(UpdaterXml.item)); + serializer.Serialize(writer, update); + writer.Close(); + } + + // start update procedure + if (Properties.Settings.Default.CheckForUpdates) + { + Logging.WriteLine("AutoUpdater feature enabled - checking for update in the background."); + + AutoUpdater.ShowRemindLaterButton = true; + AutoUpdater.ReportErrors = false; + AutoUpdater.Mandatory = false; + AutoUpdater.ShowSkipButton = true; + AutoUpdater.Start(updateUrl); + } + } + catch(Exception ex) + { + Logging.WriteLine(string.Format("Unable to start update procedure:{0}{1}", Environment.NewLine, ex.ToString())); + } + } + + /// + /// start auto update after download + /// + /// + /// + private static void Wc_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { try { diff --git a/EveChatNotifier/Properties/AssemblyInfo.cs b/EveChatNotifier/Properties/AssemblyInfo.cs index 50249c7..b21ed64 100644 --- a/EveChatNotifier/Properties/AssemblyInfo.cs +++ b/EveChatNotifier/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden, // übernehmen, indem Sie "*" eingeben: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.8.8.0")] -[assembly: AssemblyFileVersion("2.8.8.0")] +[assembly: AssemblyVersion("2.9.0.0")] +[assembly: AssemblyFileVersion("2.9.0.0")] diff --git a/EveChatNotifier/app.config b/EveChatNotifier/app.config index 5df58c9..4fad9f5 100644 --- a/EveChatNotifier/app.config +++ b/EveChatNotifier/app.config @@ -1,11 +1,11 @@ - + - -
+ +
- -
+ +
@@ -112,4 +112,4 @@ - \ No newline at end of file + diff --git a/EveChatNotifier/packages.config b/EveChatNotifier/packages.config index 2dd47e8..77678b0 100644 --- a/EveChatNotifier/packages.config +++ b/EveChatNotifier/packages.config @@ -1,8 +1,9 @@  - + - - + + + \ No newline at end of file