From 8d6f505336b0703b8b271e8e6a7249ed08569532 Mon Sep 17 00:00:00 2001 From: Yoshi Askharoun Date: Thu, 4 May 2023 00:18:30 -0500 Subject: [PATCH] Drop net35 and net40 targets in favor of net461 --- Directory.Build.props | 64 +++------- ZuneHost.Wpf/App.config | 6 + ZuneHost.Wpf/MainWindow.xaml.cs | 2 - ZuneHost.Wpf/ZuneHost.Wpf.csproj | 3 +- ZuneHost/Program.cs | 1 - ZuneHost/ZuneHost.csproj | 3 +- .../Playback/MediaFoundationAudioService.cs | 14 ++- ZuneImpl/Service/CommunityCommerce.cs | 57 ++++++++- ZuneImpl/Service/CommunityCommerce.oz.cs | 46 -------- ZuneImpl/Service/CommunityService.cs | 2 - ZuneImpl/Service/Escargot.cs | 36 ++++++ ZuneImpl/Service/Escargot.lg.cs | 27 ----- ZuneImpl/Service/Escargot.oz.cs | 36 ------ ZuneImpl/ZuneImpl.csproj | 33 +----- ZuneShell/AssemblyInfo.cs | 5 - .../Microsoft/Zune/Shell/ZuneApplication.cs | 61 +++------- ZuneShell/ZuneShell.csproj | 48 ++------ .../TransportControls/TransportControls.lg.cs | 110 ------------------ 18 files changed, 157 insertions(+), 397 deletions(-) create mode 100644 ZuneHost.Wpf/App.config delete mode 100644 ZuneImpl/Service/CommunityCommerce.oz.cs delete mode 100644 ZuneImpl/Service/Escargot.lg.cs delete mode 100644 ZuneImpl/Service/Escargot.oz.cs delete mode 100644 ZuneShell/ZuneUI/TransportControls/TransportControls.lg.cs diff --git a/Directory.Build.props b/Directory.Build.props index 1a012f6..7b28283 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -3,63 +3,27 @@ Debug x64 - 4.9.0.0 - $(ApplicationVersion) - $(ApplicationVersion) + 5.0.0.0 + $(ApplicationVersion) + $(ApplicationVersion) latest - netstandard2.0;net35;net40;net6.0;net6.0-windows + $(DefineConstants);OPENZUNE + + netstandard2.0;net461;net6.0;net6.0-windows x64;x86 False $(SolutionDir)\libs\MicrosoftIris\36MSApp1024.snk True - - False - - - - - - - - - - - - - - True - - $(DefineConstants);WINDOWS10 - $(DefineConstants);WINDOWS8 - - - - - - True - - - - - - - True - - - - - - 5.0.0.0 - $(DefineConstants);OPENZUNE - + + + + $(DefineConstants);WINDOWS10 + $(DefineConstants);WINDOWS8 + + + \ No newline at end of file diff --git a/ZuneHost.Wpf/App.config b/ZuneHost.Wpf/App.config new file mode 100644 index 0000000..38f9885 --- /dev/null +++ b/ZuneHost.Wpf/App.config @@ -0,0 +1,6 @@ + + + + + + diff --git a/ZuneHost.Wpf/MainWindow.xaml.cs b/ZuneHost.Wpf/MainWindow.xaml.cs index 9198169..dd486ba 100644 --- a/ZuneHost.Wpf/MainWindow.xaml.cs +++ b/ZuneHost.Wpf/MainWindow.xaml.cs @@ -64,9 +64,7 @@ namespace ZuneHost.Wpf Directory.Delete(decompResultDir, true); Directory.CreateDirectory(decompResultDir); IrisApp.DebugSettings.DecompileResults.CollectionChanged += DecompileResults_CollectionChanged; -#if NET6_0_OR_GREATER || NETCOREAPP3_1_OR_GREATER IrisApp.DebugSettings.Bridge.InterpreterStep += Bridge_InterpreterStep; -#endif } IrisApp.DebugSettings.GenerateDataMappingModels = false; diff --git a/ZuneHost.Wpf/ZuneHost.Wpf.csproj b/ZuneHost.Wpf/ZuneHost.Wpf.csproj index f06fa0c..e1615fb 100644 --- a/ZuneHost.Wpf/ZuneHost.Wpf.csproj +++ b/ZuneHost.Wpf/ZuneHost.Wpf.csproj @@ -2,10 +2,11 @@ WinExe - net6.0-windows10.0.22000;net40 + net461;net6.0-windows10.0.22000 11.0 true Assets\ZuneFluentGem.ico + App.config diff --git a/ZuneHost/Program.cs b/ZuneHost/Program.cs index ee40848..b666bd0 100644 --- a/ZuneHost/Program.cs +++ b/ZuneHost/Program.cs @@ -2,7 +2,6 @@ using System.Diagnostics; using System.IO; using System.Linq; -using System.Threading; namespace ZuneHost { diff --git a/ZuneHost/ZuneHost.csproj b/ZuneHost/ZuneHost.csproj index 9054fce..efc0241 100644 --- a/ZuneHost/ZuneHost.csproj +++ b/ZuneHost/ZuneHost.csproj @@ -2,9 +2,10 @@ Exe - net40;net6.0-windows10.0.22000;net6.0; + net461;net6.0-windows10.0.22000;net6.0; AnyCPU;x64;x86;ARM32 11.0 + App.config diff --git a/ZuneImpl/Playback/MediaFoundationAudioService.cs b/ZuneImpl/Playback/MediaFoundationAudioService.cs index 3cc8628..4213d23 100644 --- a/ZuneImpl/Playback/MediaFoundationAudioService.cs +++ b/ZuneImpl/Playback/MediaFoundationAudioService.cs @@ -99,14 +99,24 @@ namespace Microsoft.Zune.Playback System.Net.Http.HttpClient client = new(); - var httpStream = await client.GetStreamAsync(uri, cancellationToken); + var httpStream = await client.GetStreamAsync(uri +#if NET5_0_OR_GREATER + , cancellationToken); +#else + ); +#endif cancellationToken.ThrowIfCancellationRequested(); // NAudio requires some fancy stuff to stream from the web. This is // a relatively simple workaround that downloads the entire file // into memory before playing. stream = new System.IO.MemoryStream(); - await httpStream.CopyToAsync(stream, cancellationToken); + await httpStream.CopyToAsync(stream +#if NET5_0_OR_GREATER + , cancellationToken); +#else + ); +#endif cancellationToken.ThrowIfCancellationRequested(); reader = new StreamMediaFoundationReader(stream); diff --git a/ZuneImpl/Service/CommunityCommerce.cs b/ZuneImpl/Service/CommunityCommerce.cs index 65fad94..df742bb 100644 --- a/ZuneImpl/Service/CommunityCommerce.cs +++ b/ZuneImpl/Service/CommunityCommerce.cs @@ -1,15 +1,19 @@ using System.Globalization; using System.IO; +using System.Net.Http; using System.Reflection; +using System.Threading.Tasks; using System.Xml.Serialization; using Zune.Xml.Commerce; +using ZuneUI; namespace Microsoft.Zune.Service { internal static partial class CommunityCommerce { - static readonly XmlSerializer _signInRequestSerializer = new XmlSerializer(typeof(SignInRequest)); - static readonly XmlSerializer _signInResponseSerializer = new XmlSerializer(typeof(SignInResponse)); + static readonly XmlSerializer _signInRequestSerializer = new(typeof(SignInRequest)); + static readonly XmlSerializer _signInResponseSerializer = new(typeof(SignInResponse)); + static readonly HttpClient _client = Escargot._client; static SignInResponse _memberInfo; public static SignInResponse MemberInfo @@ -29,6 +33,55 @@ namespace Microsoft.Zune.Service public static void SignOut() => MemberInfo = null; + public static HRESULT TrySignIn() + { + if (!Escargot.HasToken) + return HRESULT._NS_E_SUBSCRIPTIONSERVICE_LOGIN_FAILED; + + try + { + string url = Service2.Instance.GetEndPointUri(EServiceEndpointId.SEID_Commerce) + $"/account/signin"; + HttpRequestMessage request = new(HttpMethod.Post, url); + request.Headers.UserAgent.ParseAdd(CommunityService.AppUserAgent); + + var contentStream = GetSignInRequestBody(); + request.Content = new StreamContent(contentStream); + request.Content.Headers.ContentType = new(Atom.Constants.ATOM_MIMETYPE); + request.Content.Headers.ContentLength = contentStream.Length; + + Escargot.AuthenticateRequest(request); + + var response = +#if NET5_0_OR_GREATER + _client.Send(request); +#else + Task.Run(() => _client.SendAsync(request)).Result; +#endif + + response.EnsureSuccessStatusCode(); + + System.IO.Stream responseStream = +#if NET5_0_OR_GREATER + response.Content.ReadAsStream(); +#else + Task.Run(response.Content.ReadAsStreamAsync).Result; +#endif + + var responseObj = ReadSignInResponse(responseStream); + + uint? errorCode = responseObj?.AccountState?.SignInErrorCode; + if (errorCode != 0) + return new HRESULT(unchecked((int)errorCode)); + + MemberInfo = responseObj; + return HRESULT._S_OK; + } + catch + { + return HRESULT._NS_E_SUBSCRIPTIONSERVICE_LOGIN_FAILED; + } + } + private static Stream GetSignInRequestBody() { var requestObj = new SignInRequest diff --git a/ZuneImpl/Service/CommunityCommerce.oz.cs b/ZuneImpl/Service/CommunityCommerce.oz.cs deleted file mode 100644 index 1ff2825..0000000 --- a/ZuneImpl/Service/CommunityCommerce.oz.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System.Net.Http; -using ZuneUI; - -namespace Microsoft.Zune.Service -{ - partial class CommunityCommerce - { - private static readonly HttpClient _client = Escargot._client; - - public static HRESULT TrySignIn() - { - if (!Escargot.HasToken) - return HRESULT._NS_E_SUBSCRIPTIONSERVICE_LOGIN_FAILED; - - try - { - string url = Service2.Instance.GetEndPointUri(EServiceEndpointId.SEID_Commerce) + $"/account/signin"; - HttpRequestMessage request = new(HttpMethod.Post, url); - request.Headers.UserAgent.ParseAdd(CommunityService.AppUserAgent); - - var contentStream = GetSignInRequestBody(); - request.Content = new StreamContent(contentStream); - request.Content.Headers.ContentType = new(Atom.Constants.ATOM_MIMETYPE); - request.Content.Headers.ContentLength = contentStream.Length; - - Escargot.AuthenticateRequest(request); - - var response = _client.Send(request); - response.EnsureSuccessStatusCode(); - - var responseObj = ReadSignInResponse(response.Content.ReadAsStream()); - - uint? errorCode = responseObj?.AccountState?.SignInErrorCode; - if (errorCode != 0) - return new HRESULT(unchecked((int)errorCode)); - - MemberInfo = responseObj; - return HRESULT._S_OK; - } - catch - { - return HRESULT._NS_E_SUBSCRIPTIONSERVICE_LOGIN_FAILED; - } - } - } -} diff --git a/ZuneImpl/Service/CommunityService.cs b/ZuneImpl/Service/CommunityService.cs index 9e027c9..929d25d 100644 --- a/ZuneImpl/Service/CommunityService.cs +++ b/ZuneImpl/Service/CommunityService.cs @@ -470,9 +470,7 @@ namespace Microsoft.Zune.Service if (hr.IsSuccess) { -#if OPENZUNE hr = CommunityCommerce.TrySignIn(); -#endif if (hr.IsSuccess) { diff --git a/ZuneImpl/Service/Escargot.cs b/ZuneImpl/Service/Escargot.cs index 75f9a1a..a83b101 100644 --- a/ZuneImpl/Service/Escargot.cs +++ b/ZuneImpl/Service/Escargot.cs @@ -1,5 +1,8 @@ using Meziantou.Framework.Win32; +using System.Linq; +using System.Net.Http; using System.Reflection; +using System.Threading.Tasks; namespace Microsoft.Zune.Service { @@ -10,6 +13,7 @@ namespace Microsoft.Zune.Service const string HEADER_X_PASS = "X-Password"; const string HEADER_X_TOKEN = "X-Token"; + internal static readonly HttpClient _client = new(); private static string _token; /// @@ -51,6 +55,38 @@ namespace Microsoft.Zune.Service Username = null; } + public static bool TrySignIn(string username, string password) + { + HttpRequestMessage request = new(HttpMethod.Post, ESCARGOT_NOTRST_URL); + request.Headers.TryAddWithoutValidation(HEADER_X_USER, username); + request.Headers.TryAddWithoutValidation(HEADER_X_PASS, password); + + try + { + var response = +#if NET5_0_OR_GREATER + _client.Send(request); +#else + Task.Run(() => _client.SendAsync(request)).Result; +#endif + + response.EnsureSuccessStatusCode(); + + string token = response.Headers.GetValues(HEADER_X_TOKEN).FirstOrDefault(); + + return TrySetCredentials(token, username); + } + catch + { + return false; + } + } + + public static void AuthenticateRequest(HttpRequestMessage request) + { + request.Headers.Authorization = new("Bearer", _token); + } + private static bool TrySetCredentials(string token, string username) { if (token == null) diff --git a/ZuneImpl/Service/Escargot.lg.cs b/ZuneImpl/Service/Escargot.lg.cs deleted file mode 100644 index 40029dd..0000000 --- a/ZuneImpl/Service/Escargot.lg.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System.Net; - -namespace Microsoft.Zune.Service -{ - partial class Escargot - { - public static bool TrySignIn(string username, string password) - { - var request = WebRequest.Create(ESCARGOT_NOTRST_URL); - request.Headers.Add(HEADER_X_USER, username); - request.Headers.Add(HEADER_X_PASS, password); - request.Method = "POST"; - - try - { - var response = request.GetResponse(); - string token = response.Headers[HEADER_X_TOKEN]; - - return TrySetCredentials(token, username); - } - catch - { - return false; - } - } - } -} diff --git a/ZuneImpl/Service/Escargot.oz.cs b/ZuneImpl/Service/Escargot.oz.cs deleted file mode 100644 index 626c346..0000000 --- a/ZuneImpl/Service/Escargot.oz.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Linq; -using System.Net.Http; - -namespace Microsoft.Zune.Service -{ - partial class Escargot - { - internal static readonly HttpClient _client = new(); - - public static bool TrySignIn(string username, string password) - { - HttpRequestMessage request = new(HttpMethod.Post, ESCARGOT_NOTRST_URL); - request.Headers.TryAddWithoutValidation(HEADER_X_USER, username); - request.Headers.TryAddWithoutValidation(HEADER_X_PASS, password); - - try - { - var response = _client.Send(request); - response.EnsureSuccessStatusCode(); - - string token = response.Headers.GetValues(HEADER_X_TOKEN).FirstOrDefault(); - - return TrySetCredentials(token, username); - } - catch - { - return false; - } - } - - public static void AuthenticateRequest(HttpRequestMessage request) - { - request.Headers.Authorization = new("Bearer", _token); - } - } -} diff --git a/ZuneImpl/ZuneImpl.csproj b/ZuneImpl/ZuneImpl.csproj index 4fdebbc..d4858a1 100644 --- a/ZuneImpl/ZuneImpl.csproj +++ b/ZuneImpl/ZuneImpl.csproj @@ -14,37 +14,14 @@ + + + - - - - - - - - - - - + - - - - - - - - - - - - - + diff --git a/ZuneShell/AssemblyInfo.cs b/ZuneShell/AssemblyInfo.cs index 2a7b424..032465d 100644 --- a/ZuneShell/AssemblyInfo.cs +++ b/ZuneShell/AssemblyInfo.cs @@ -11,13 +11,8 @@ using System.Security.Permissions; //[assembly: AssemblyDelaySign(true)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] -#if OPENZUNE [assembly: AssemblyFileVersion("5.0.0.0")] [assembly: AssemblyVersion("5.0.0.0")] -#else -[assembly: AssemblyFileVersion("4.8.2345.0")] -[assembly: AssemblyVersion("4.7.0.0")] -#endif // Workaround for CA1416 #if WINDOWS10 diff --git a/ZuneShell/Microsoft/Zune/Shell/ZuneApplication.cs b/ZuneShell/Microsoft/Zune/Shell/ZuneApplication.cs index 78ef883..3c19c92 100644 --- a/ZuneShell/Microsoft/Zune/Shell/ZuneApplication.cs +++ b/ZuneShell/Microsoft/Zune/Shell/ZuneApplication.cs @@ -8,26 +8,11 @@ using Microsoft.Iris; using Microsoft.Win32; using Microsoft.Zune.Configuration; using Microsoft.Zune.Messaging; +using Microsoft.Zune.Playback; using Microsoft.Zune.Service; using Microsoft.Zune.Subscription; using Microsoft.Zune.Util; using MicrosoftZuneLibrary; -using System; -using System.Collections; -using System.Collections.Generic; -using System.ComponentModel; -using System.Diagnostics; -using System.Globalization; -using System.IO; -using System.Text.RegularExpressions; -using System.Threading; -using UIXControls; -using ZuneUI; -using ZuneXml; -using System.Linq; - -#if OPENZUNE -using Microsoft.Zune.Playback; using OwlCore.ComponentModel; using StrixMusic.Sdk.AdapterModels; using StrixMusic.Sdk.AppModels; @@ -35,7 +20,19 @@ using StrixMusic.Sdk.CoreModels; using StrixMusic.Sdk.MediaPlayback; using StrixMusic.Sdk.PluginModels; using StrixMusic.Sdk.Plugins.PlaybackHandler; -#endif +using System; +using System.Collections; +using System.Collections.Generic; +using System.ComponentModel; +using System.Diagnostics; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Text.RegularExpressions; +using System.Threading; +using UIXControls; +using ZuneUI; +using ZuneXml; namespace Microsoft.Zune.Shell { @@ -71,29 +68,12 @@ namespace Microsoft.Zune.Shell public static Service.Service Service => Zune.Service.Service.Instance; public static IService Service2 => Zune.Service.Service2.Instance; - public static bool IsStrixCompatible - { - get - { -#if OPENZUNE - return true; -#else - return false; -#endif - } - } + public static bool IsStrixCompatible => true; - public static Version StrixSdkVersion => -#if OPENZUNE - typeof(ICore).Assembly.GetName().Version; -#else - null; -#endif + public static Version StrixSdkVersion => typeof(ICore).Assembly.GetName().Version; -#if OPENZUNE public static IStrixDataRoot DataRoot { get; private set; } public static IPlaybackHandlerService PlaybackHandler { get; private set; } -#endif public static event EventHandler Closing; @@ -160,7 +140,6 @@ namespace Microsoft.Zune.Shell FeaturesChanged.Instance.StartUp(); CultureHelper.CheckValidRegionAndLanguage(); -#if OPENZUNE DirectoryInfo cacheFolderPath = new(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"Microsoft\Zune\OpenZune\LocalCoreCache")); cacheFolderPath.Create(); OwlCore.Storage.SystemIO.SystemFolder cacheFolder = new(cacheFolderPath); @@ -202,13 +181,11 @@ namespace Microsoft.Zune.Shell await DataRoot.Library.PlayTrackCollectionAsync(); }); -#endif ((ZuneUI.Shell)ZuneShell.DefaultInstance).ApplicationInitializationIsComplete = true; } } -#if OPENZUNE private static async void LibraryTracksChanged(object sender, IReadOnlyList> addedItems, IReadOnlyList> removedItems) @@ -235,7 +212,6 @@ namespace Microsoft.Zune.Shell await firstTrack.PlayArtistCollectionAsync(); } } -#endif private static void Phase2InitializationUIStage(object arg) { @@ -461,11 +437,8 @@ namespace Microsoft.Zune.Shell DialogHelper.DialogNo = ZuneUI.Shell.LoadString(StringId.IDS_DIALOG_NO); DialogHelper.DialogOk = ZuneUI.Shell.LoadString(StringId.IDS_DIALOG_OK); XmlDataProviders.Register(); -#if false//OPENZUNE - Library.StrixLibraryDataProvider.Register(); -#else + //Library.StrixLibraryDataProvider.Register(); LibraryDataProvider.Register(); -#endif SubscriptionDataProvider.Register(); StaticLibraryDataProvider.Register(); AggregateDataProviderQuery.Register(); diff --git a/ZuneShell/ZuneShell.csproj b/ZuneShell/ZuneShell.csproj index 0994f6d..9eeafe6 100644 --- a/ZuneShell/ZuneShell.csproj +++ b/ZuneShell/ZuneShell.csproj @@ -6,7 +6,7 @@ Library ZuneShell - net6.0;net6.0-windows10.0.22000;net35;net40 + net6.0;net6.0-windows10.0.22000;net461 x64;x86 512 @@ -30,43 +30,8 @@ C:\Program Files\Zune\ZuneDBApi.dll - - - - - - - - - - - - - v3.5 - 3.5 - - - - - - - - - - - - - - - - - - + ..\libs\nuget\StrixMusic.Cores.Storage\StrixMusic.Cores.Storage.dll @@ -75,8 +40,11 @@ - - - + + + + + + \ No newline at end of file diff --git a/ZuneShell/ZuneUI/TransportControls/TransportControls.lg.cs b/ZuneShell/ZuneUI/TransportControls/TransportControls.lg.cs deleted file mode 100644 index 8dc13f1..0000000 --- a/ZuneShell/ZuneUI/TransportControls/TransportControls.lg.cs +++ /dev/null @@ -1,110 +0,0 @@ -using Microsoft.Zune.Util; -using MicrosoftZunePlayback; -using System; - -namespace ZuneUI -{ - partial class TransportControls - { - private void OnInit() { } - private void OnUninit() { } - - private void OnPlayClicked(object sender, EventArgs e) - { - if (!this._play.Available) - return; - SQMLog.Log(SQMDataId.PlayClicks, 1); - - if (this.Playing || this._playlistCurrent == null) - return; - if (this._lastKnownPlayerState != MCPlayerState.Closed) - { - this.SetPlayerState(PlayerState.Playing); - this._playbackWrapper.Play(); - - if (!this.PlayingVideo || this._playlistCurrent.PlayNavigationOptions != PlayNavigationOptions.NavigateVideosToNowPlaying) - return; - NowPlayingLand.NavigateToLand(); - } - else - { - if (this._playlistPending != null) - this._playlistPending.Dispose(); - this._playlistPending = this._playlistCurrent; - this.PlayPendingList(); - } - } - - private void OnPauseClicked(object sender, EventArgs e) - { - if (!this._pause.Available) - return; - SQMLog.Log(SQMDataId.PauseClicks, 1); - - if (!this.Playing) - return; - - this.SetPlayerState(PlayerState.Paused); - this._playbackWrapper.Pause(); - } - - private void OnStopClicked(object sender, EventArgs e) - { - if (!this._stop.Available) - return; - SQMLog.Log(SQMDataId.StopClicks, 1); - if (this._playlistPending != null) - this._playlistPending.Dispose(); - this._playlistPending = null; - if (this._playlistCurrent != null) - this._playlistCurrent.Dispose(); - this._playlistCurrent = null; - if (this._playerState != PlayerState.Stopped) - { - this.SetPlayerState(PlayerState.Stopped); - this._playbackWrapper.Stop(); - } - else - this.UpdatePropertiesAndCommands(); - } - - private void OnBackClicked(object sender, EventArgs e) - { - if (!this._back.Available || this._playlistCurrent == null) - return; - SQMLog.Log(SQMDataId.SkipBackwardClicks, 1); - - if (this._lastKnownPosition > 50000000L || !this._playlistCurrent.CanRetreat) - { - this._playbackWrapper.SeekToAbsolutePosition(0L); - } - else - { - this._playlistCurrent.Retreat(); - this.SetUriOnPlayer(); - } - } - - private void OnForwardClicked(object sender, EventArgs e) - { - if (!this._forward.Available || this._playlistCurrent == null) - return; - SQMLog.Log(SQMDataId.SkipForwardClicks, 1); - - if (this._currentTrack != null && this._currentTrack.IsVideo) - return; - if (this._lastKnownPlaybackTrack != null) - this._lastKnownPlaybackTrack.OnSkip(); - if (this._playlistCurrent.CanAdvance) - { - this._playlistCurrent.Advance(); - this.SetUriOnPlayer(); - } - else - { - this.SetPlayerState(PlayerState.Stopped); - this._playbackWrapper.Stop(); - } - } - } -}