mirror of
https://github.com/ZuneDev/ZuneShell.dll.git
synced 2026-07-27 13:11:51 -07:00
Merge pull request #5 from ZuneDev/dev/net6
This commit is contained in:
+14
-50
@@ -3,63 +3,27 @@
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">x64</Platform>
|
||||
<ApplicationVersion>4.9.0.0</ApplicationVersion>
|
||||
<AssemblyVersion>$(ApplicationVersion)</AssemblyVersion>
|
||||
<FileVersion>$(ApplicationVersion)</FileVersion>
|
||||
<ApplicationVersion>5.0.0.0</ApplicationVersion>
|
||||
<AssemblyVersion>$(ApplicationVersion)</AssemblyVersion>
|
||||
<FileVersion>$(ApplicationVersion)</FileVersion>
|
||||
<LangVersion>latest</LangVersion>
|
||||
|
||||
<TargetFrameworks>netstandard2.0;net35;net40;net6.0;net6.0-windows</TargetFrameworks>
|
||||
<DefineConstants>$(DefineConstants);OPENZUNE</DefineConstants>
|
||||
|
||||
<TargetFrameworks>netstandard2.0;net461;net6.0;net6.0-windows</TargetFrameworks>
|
||||
<Platforms>x64;x86</Platforms>
|
||||
|
||||
<SignAssembly>False</SignAssembly>
|
||||
<AssemblyOriginatorKeyFile>$(SolutionDir)\libs\MicrosoftIris\36MSApp1024.snk</AssemblyOriginatorKeyFile>
|
||||
<DelaySign>True</DelaySign>
|
||||
|
||||
<UseOpenZune>False</UseOpenZune>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="**\*.lg.cs" Exclude="bin\**\*.lg.cs;obj\**\*.lg.cs" />
|
||||
<Compile Remove="**\*.lg.cs" Condition="$(UseOpenZune)" />
|
||||
<Compile Include="**\*.lg.cs"
|
||||
Exclude="bin\**\*.lg.cs;obj\**\*.lg.cs"
|
||||
Condition="!$(UseOpenZune)" />
|
||||
|
||||
<None Include="**\*.oz.cs" Exclude="bin\**\*.oz.cs;obj\**\*.oz.cs" />
|
||||
<Compile Remove="**\*.oz.cs" Condition="!$(UseOpenZune)" />
|
||||
<Compile Include="**\*.oz.cs"
|
||||
Exclude="bin\**\*.oz.cs;obj\**\*.oz.cs"
|
||||
Condition="$(UseOpenZune)" />
|
||||
</ItemGroup>
|
||||
|
||||
<Choose>
|
||||
<When Condition=" $(TargetFramework.StartsWith('net6.0-windows')) ">
|
||||
<PropertyGroup>
|
||||
<UseOpenZune>True</UseOpenZune>
|
||||
|
||||
<DefineConstants Condition="$(TargetFramework.StartsWith('net6.0-windows10'))">$(DefineConstants);WINDOWS10</DefineConstants>
|
||||
<DefineConstants Condition="$(TargetFramework.StartsWith('net6.0-windows8'))">$(DefineConstants);WINDOWS8</DefineConstants>
|
||||
</PropertyGroup>
|
||||
</When>
|
||||
|
||||
<When Condition=" $(TargetFramework.StartsWith('net6.0')) ">
|
||||
<PropertyGroup>
|
||||
<UseOpenZune>True</UseOpenZune>
|
||||
</PropertyGroup>
|
||||
</When>
|
||||
|
||||
<!--
|
||||
.NET Core 3.1 is only used to target Windows 8/8.1
|
||||
-->
|
||||
<When Condition=" $(TargetFramework.StartsWith('netcoreapp')) ">
|
||||
<PropertyGroup>
|
||||
<UseOpenZune>True</UseOpenZune>
|
||||
</PropertyGroup>
|
||||
</When>
|
||||
</Choose>
|
||||
|
||||
<PropertyGroup Condition="$(UseOpenZune)">
|
||||
<ApplicationVersion>5.0.0.0</ApplicationVersion>
|
||||
<DefineConstants>$(DefineConstants);OPENZUNE</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<Choose>
|
||||
<When Condition=" $(TargetFramework.StartsWith('net6.0-windows')) ">
|
||||
<PropertyGroup>
|
||||
<DefineConstants Condition="$(TargetFramework.StartsWith('net6.0-windows10'))">$(DefineConstants);WINDOWS10</DefineConstants>
|
||||
<DefineConstants Condition="$(TargetFramework.StartsWith('net6.0-windows8'))">$(DefineConstants);WINDOWS8</DefineConstants>
|
||||
</PropertyGroup>
|
||||
</When>
|
||||
</Choose>
|
||||
</Project>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<startup useLegacyV2RuntimeActivationPolicy="true">
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
|
||||
</startup>
|
||||
</configuration>
|
||||
@@ -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;
|
||||
|
||||
@@ -2,10 +2,11 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFrameworks>net6.0-windows10.0.22000;net40</TargetFrameworks>
|
||||
<TargetFrameworks>net6.0-windows10.0.22000;net461</TargetFrameworks>
|
||||
<LangVersion>11.0</LangVersion>
|
||||
<UseWPF>true</UseWPF>
|
||||
<ApplicationIcon>Assets\ZuneFluentGem.ico</ApplicationIcon>
|
||||
<AppConfig>App.config</AppConfig>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
|
||||
namespace ZuneHost
|
||||
{
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFrameworks>net40;net6.0-windows10.0.22000;net6.0;</TargetFrameworks>
|
||||
<TargetFrameworks>net461;net6.0-windows10.0.22000;net6.0;</TargetFrameworks>
|
||||
<Platforms>AnyCPU;x64;x86;ARM32</Platforms>
|
||||
<LangVersion>11.0</LangVersion>
|
||||
<AppConfig>App.config</AppConfig>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
#if OPENZUNE
|
||||
|
||||
using CommunityToolkit.Diagnostics;
|
||||
using MicrosoftZunePlayback;
|
||||
using OwlCore.Storage;
|
||||
using OwlCore.Storage.SystemIO;
|
||||
using StrixMusic.Sdk.MediaPlayback;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@@ -11,8 +15,33 @@ namespace Microsoft.Zune.Playback
|
||||
public class PlayerInteropAudioService : IAudioPlayerService
|
||||
{
|
||||
private readonly PlayerInterop _playbackWrapper = PlayerInterop.Instance;
|
||||
private readonly IModifiableFolder _tempFolder;
|
||||
private PlaybackItem m_currentSource;
|
||||
private int _playbackId = 0;
|
||||
|
||||
public PlaybackItem CurrentSource { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
public PlayerInteropAudioService(IModifiableFolder tempFolder)
|
||||
{
|
||||
_tempFolder = tempFolder;
|
||||
}
|
||||
|
||||
public PlayerInteropAudioService()
|
||||
{
|
||||
DirectoryInfo cacheFolderPath = new(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"Microsoft\Zune\OpenZune\PlayerInteropTemp"));
|
||||
cacheFolderPath.Create();
|
||||
_tempFolder = new SystemFolder(cacheFolderPath);
|
||||
}
|
||||
|
||||
public static PlayerInteropAudioService Instance => new();
|
||||
|
||||
public PlaybackItem CurrentSource
|
||||
{
|
||||
get => m_currentSource;
|
||||
set
|
||||
{
|
||||
m_currentSource = value;
|
||||
CurrentSourceChanged?.Invoke(this, value);
|
||||
}
|
||||
}
|
||||
|
||||
public TimeSpan Position => new(_playbackWrapper.Position);
|
||||
|
||||
@@ -20,7 +49,7 @@ namespace Microsoft.Zune.Playback
|
||||
|
||||
public double Volume => _playbackWrapper.Volume / 100d;
|
||||
|
||||
public double PlaybackSpeed => 1.0d;
|
||||
public double PlaybackSpeed => _playbackWrapper.Rate;
|
||||
|
||||
public event EventHandler<PlaybackItem> CurrentSourceChanged;
|
||||
public event EventHandler<float[]> QuantumProcessed;
|
||||
@@ -31,7 +60,8 @@ namespace Microsoft.Zune.Playback
|
||||
|
||||
public Task ChangePlaybackSpeedAsync(double speed, CancellationToken cancellationToken = default)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
_playbackWrapper.Rate = (float)speed;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task ChangeVolumeAsync(double volume, CancellationToken cancellationToken = default)
|
||||
@@ -46,15 +76,29 @@ namespace Microsoft.Zune.Playback
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task Play(PlaybackItem sourceConfig, CancellationToken cancellationToken = default)
|
||||
public async Task Play(PlaybackItem sourceConfig, CancellationToken cancellationToken = default)
|
||||
{
|
||||
_playbackWrapper.Play();
|
||||
return Task.CompletedTask;
|
||||
var media = await LoadAsync(sourceConfig.MediaConfig);
|
||||
|
||||
Iris.Application.DeferredInvoke(new Iris.DeferredInvokeHandler(delegate
|
||||
{
|
||||
// Play cannot be called immediately after SetUri,
|
||||
// so we have to listen for when the change is done.
|
||||
_playbackWrapper.UriSet += PlaybackWrapper_UriSet;
|
||||
_playbackWrapper.SetUri(media.Uri, 0, media.Id);
|
||||
}), Iris.DeferredInvokePriority.Normal);
|
||||
}
|
||||
|
||||
public Task Preload(PlaybackItem sourceConfig, CancellationToken cancellationToken = default)
|
||||
private void PlaybackWrapper_UriSet(object sender, EventArgs e)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
_playbackWrapper.UriSet -= PlaybackWrapper_UriSet;
|
||||
_playbackWrapper.Play();
|
||||
}
|
||||
|
||||
public async Task Preload(PlaybackItem sourceConfig, CancellationToken cancellationToken = default)
|
||||
{
|
||||
var media = await LoadAsync(sourceConfig.MediaConfig);
|
||||
_playbackWrapper.SetNextUri(media.Uri, 0, media.Id);
|
||||
}
|
||||
|
||||
public Task ResumeAsync(CancellationToken cancellationToken = default)
|
||||
@@ -69,6 +113,53 @@ namespace Microsoft.Zune.Playback
|
||||
_playbackWrapper.SeekToAbsolutePosition(position.Ticks);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private async Task<PlayerInteropMedia> LoadAsync(IMediaSourceConfig mediaConfig, bool saveStream = true)
|
||||
{
|
||||
Guard.IsNotNull(mediaConfig);
|
||||
|
||||
mediaConfig.FileStreamSource?.Dispose();
|
||||
|
||||
var url = mediaConfig.MediaSourceUri?.ToString();
|
||||
if (url is null)
|
||||
{
|
||||
if (IsValidUri(mediaConfig.Id))
|
||||
{
|
||||
url = mediaConfig.Id;
|
||||
}
|
||||
else if (saveStream && mediaConfig.FileStreamSource is not null)
|
||||
{
|
||||
var dstFile = await _tempFolder.CreateFileAsync(mediaConfig.Id, true);
|
||||
using (var stream = await dstFile.OpenStreamAsync(FileAccess.ReadWrite))
|
||||
{
|
||||
await mediaConfig.FileStreamSource.CopyToAsync(stream);
|
||||
}
|
||||
|
||||
Guard.IsTrue(IsValidUri(url));
|
||||
url = dstFile.Id;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ArgumentException("PlayerInterop can only load media from a URI.");
|
||||
}
|
||||
}
|
||||
|
||||
return new(url, ++_playbackId);
|
||||
}
|
||||
|
||||
private static bool IsValidUri(string? url) => Uri.TryCreate(url, UriKind.Absolute, out _);
|
||||
|
||||
private readonly struct PlayerInteropMedia
|
||||
{
|
||||
public PlayerInteropMedia(string uri, int id)
|
||||
{
|
||||
Uri = uri;
|
||||
Id = id;
|
||||
}
|
||||
|
||||
public string Uri { get; }
|
||||
public int Id { get; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -470,9 +470,7 @@ namespace Microsoft.Zune.Service
|
||||
|
||||
if (hr.IsSuccess)
|
||||
{
|
||||
#if OPENZUNE
|
||||
hr = CommunityCommerce.TrySignIn();
|
||||
#endif
|
||||
|
||||
if (hr.IsSuccess)
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,38 +14,14 @@
|
||||
<!-- This is the last version of NAudio to support net35 and net6.0 -->
|
||||
<PackageReference Include="NAudio" Version="1.10.0" />
|
||||
<PackageReference Include="Zune.Xml" Version="0.1.0" />
|
||||
<PackageReference Include="StrixMusic.Sdk" Version="0.1.0-alpha" />
|
||||
<PackageReference Include="LibVLCSharp" Version="3.6.6" />
|
||||
<PackageReference Include="Meziantou.Framework.Win32.CredentialManager" Version="1.4.2" />
|
||||
|
||||
<ProjectReference Include="..\libs\MicrosoftIris\UIX\UIX.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="**\*.lg.cs" Exclude="bin\**\*.lg.cs;obj\**\*.lg.cs" />
|
||||
<Compile Remove="**\*.lg.cs" />
|
||||
<Compile Include="**\*.lg.cs"
|
||||
Exclude="bin\**\*.lg.cs;obj\**\*.lg.cs"
|
||||
Condition="!$(UseOpenZune)" />
|
||||
|
||||
<None Include="**\*.oz.cs" Exclude="bin\**\*.oz.cs;obj\**\*.oz.cs" />
|
||||
<Compile Remove="**\*.oz.cs" />
|
||||
<Compile Include="**\*.oz.cs"
|
||||
Exclude="bin\**\*.oz.cs;obj\**\*.oz.cs"
|
||||
Condition="$(UseOpenZune)" />
|
||||
<ProjectReference Include="..\libs\MicrosoftIris\UIX\UIX.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="$(UseOpenZune)">
|
||||
<PackageReference Include="StrixMusic.Sdk" Version="0.0.12-alpha" />
|
||||
<PackageReference Include="StrixMusic.Cores.LocalFiles" Version="0.0.12-alpha" />
|
||||
|
||||
<PackageReference Include="LibVLCSharp" Version="3.6.6" />
|
||||
|
||||
<PackageReference Include="Meziantou.Framework.Win32.CredentialManager" Version="1.4.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="!$(UseOpenZune)">
|
||||
<ProjectReference Include="..\libs\Meziantou.Framework.Win32.CredentialManager\Meziantou.Framework.Win32.CredentialManager.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition=" $(TargetFramework.StartsWith('net6.0-windows')) ">
|
||||
<ItemGroup Condition=" $(TargetFramework.StartsWith('net6.0-windows')) Or $(TargetFramework.StartsWith('net4')) ">
|
||||
<PackageReference Include="VideoLAN.LibVLC.Windows" Version="3.0.17.4" PrivateAssets="analyzers;build" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -8,10 +8,18 @@ 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 OwlCore.ComponentModel;
|
||||
using StrixMusic.Sdk.AdapterModels;
|
||||
using StrixMusic.Sdk.AppModels;
|
||||
using StrixMusic.Sdk.CoreModels;
|
||||
using StrixMusic.Sdk.MediaPlayback;
|
||||
using StrixMusic.Sdk.PluginModels;
|
||||
using StrixMusic.Sdk.Plugins.PlaybackHandler;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
@@ -19,23 +27,12 @@ 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;
|
||||
using System.Linq;
|
||||
|
||||
#if OPENZUNE
|
||||
using Microsoft.Zune.Playback;
|
||||
using OwlCore.Events;
|
||||
using StrixMusic.Sdk.AdapterModels;
|
||||
using StrixMusic.Sdk.AppModels;
|
||||
using StrixMusic.Sdk.CoreModels;
|
||||
using StrixMusic.Sdk.MediaPlayback;
|
||||
using StrixMusic.Sdk.PluginModels;
|
||||
using StrixMusic.Sdk.Plugins.PlaybackHandler;
|
||||
#endif
|
||||
|
||||
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,23 +140,14 @@ namespace Microsoft.Zune.Shell
|
||||
FeaturesChanged.Instance.StartUp();
|
||||
CultureHelper.CheckValidRegionAndLanguage();
|
||||
|
||||
#if OPENZUNE
|
||||
string id = Guid.NewGuid().ToString();
|
||||
DirectoryInfo cacheFolderPath = new(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"Microsoft\Zune\OpenZune\LocalCoreCache"));
|
||||
cacheFolderPath.Create();
|
||||
OwlCore.Storage.SystemIO.SystemFolder cacheFolder = new(cacheFolderPath);
|
||||
|
||||
var fileService = new OwlCore.AbstractStorage.Win32FileSystemService(@"D:\Music\Zune\Test");
|
||||
OwlCore.AbstractStorage.SystemIOFolderData settingsFolder =
|
||||
new(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"Microsoft\Zune\OpenZune"));
|
||||
settingsFolder.EnsureExists().Wait();
|
||||
StrixMusic.Cores.LocalFiles.Settings.LocalFilesCoreSettings settings = new(settingsFolder)
|
||||
OwlCore.Storage.SystemIO.SystemFolder musicFolder = new(@"D:\Music\Zune\Test");
|
||||
var localCore = new StrixMusic.Cores.Storage.StorageCore(musicFolder, cacheFolder, "Local Test")
|
||||
{
|
||||
InitWithEmptyMetadataRepos = true,
|
||||
ScanWithTagLib = true,
|
||||
};
|
||||
|
||||
var localCore = new StrixMusic.Cores.LocalFiles.LocalFilesCore(
|
||||
id, settings, fileService, null, null)
|
||||
{
|
||||
ScannerWaitBehavior = StrixMusic.Cores.Files.ScannerWaitBehavior.AlwaysWait
|
||||
ScannerWaitBehavior = StrixMusic.Cores.Storage.ScannerWaitBehavior.AlwaysWait,
|
||||
};
|
||||
|
||||
var prefs = new MergedCollectionConfig
|
||||
@@ -190,9 +161,9 @@ namespace Microsoft.Zune.Shell
|
||||
|
||||
// Perform any async initialization needed. Authenticating, connecting to database, etc.
|
||||
// Add plugins
|
||||
string mfAudioServiceId = Guid.NewGuid().ToString();
|
||||
PlaybackHandler = new PlaybackHandlerService();
|
||||
PlaybackHandler.RegisterAudioPlayer(VlcAudioService.Instance, localCore.InstanceId);
|
||||
//PlaybackHandler.RegisterAudioPlayer(PlayerInteropAudioService.Instance, localCore.InstanceId);
|
||||
|
||||
DataRoot = new StrixDataRootPluginWrapper(mergedLayer,
|
||||
new PlaybackHandlerPlugin(PlaybackHandler)
|
||||
@@ -210,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<CollectionChangedItem<ITrack>> addedItems,
|
||||
IReadOnlyList<CollectionChangedItem<ITrack>> removedItems)
|
||||
@@ -227,7 +196,7 @@ namespace Microsoft.Zune.Shell
|
||||
|
||||
ITrack firstTrack = addedItems[1].Data;
|
||||
|
||||
await firstTrack.PlayArtistCollectionAsync();
|
||||
//await firstTrack.PlayArtistCollectionAsync();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -243,7 +212,6 @@ namespace Microsoft.Zune.Shell
|
||||
await firstTrack.PlayArtistCollectionAsync();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
private static void Phase2InitializationUIStage(object arg)
|
||||
{
|
||||
@@ -469,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();
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
#if OPENZUNE
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OwlCore.AbstractStorage
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public class FileDataProperties : IFileDataProperties
|
||||
{
|
||||
private readonly FileInfo _file;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="FileDataProperties"/> class.
|
||||
/// </summary>
|
||||
/// <param name="file">The file to get properties from.</param>
|
||||
public FileDataProperties(FileInfo file)
|
||||
{
|
||||
_file = file;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<MusicFileProperties?> GetMusicPropertiesAsync()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,71 +0,0 @@
|
||||
#if OPENZUNE
|
||||
|
||||
// Copyright (c) Arlo Godfrey. All Rights Reserved.
|
||||
// Licensed under the GNU Lesser General Public License, Version 3.0 with additional terms.
|
||||
// See the LICENSE, LICENSE.LESSER and LICENSE.ADDITIONAL files in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using OwlCore.Extensions;
|
||||
|
||||
namespace OwlCore.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// An <see cref="IAsyncSerializer{TSerialized}"/> and implementation for serializing and deserializing streams using System.Text.Json.
|
||||
/// </summary>
|
||||
public class NewtonsoftStreamSerializer : IAsyncSerializer<Stream>, ISerializer<Stream>
|
||||
{
|
||||
/// <summary>
|
||||
/// A singleton instance for <see cref="NewtonsoftStreamSerializer"/>.
|
||||
/// </summary>
|
||||
public static NewtonsoftStreamSerializer Singleton { get; } = new();
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task<Stream> SerializeAsync<T>(T data, CancellationToken? cancellationToken = null) => Task.Run(() => Serialize(data), cancellationToken ?? CancellationToken.None);
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task<Stream> SerializeAsync(Type inputType, object data, CancellationToken? cancellationToken = null) => Task.Run(() => Serialize(inputType, data), cancellationToken ?? CancellationToken.None);
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task<TResult> DeserializeAsync<TResult>(Stream serialized, CancellationToken? cancellationToken = null) => Task.Run(() => Deserialize<TResult>(serialized), cancellationToken ?? CancellationToken.None);
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task<object> DeserializeAsync(Type returnType, Stream serialized, CancellationToken? cancellationToken = null) => Task.Run(() => Deserialize(returnType, serialized), cancellationToken ?? CancellationToken.None);
|
||||
|
||||
/// <inheritdoc />
|
||||
public Stream Serialize<T>(T data)
|
||||
{
|
||||
var res = JsonConvert.SerializeObject(data, typeof(T), null);
|
||||
return new MemoryStream(Encoding.UTF8.GetBytes(res));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Stream Serialize(Type type, object data)
|
||||
{
|
||||
var res = JsonConvert.SerializeObject(data, type, null);
|
||||
return new MemoryStream(Encoding.UTF8.GetBytes(res));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public TResult Deserialize<TResult>(Stream serialized)
|
||||
{
|
||||
serialized.Position = 0;
|
||||
var str = Encoding.UTF8.GetString(serialized.ToBytes());
|
||||
return (TResult)JsonConvert.DeserializeObject(str, typeof(TResult))!;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public object Deserialize(Type type, Stream serialized)
|
||||
{
|
||||
serialized.Position = 0;
|
||||
var str = Encoding.UTF8.GetString(serialized.ToBytes());
|
||||
return JsonConvert.DeserializeObject(str, type)!;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,89 +0,0 @@
|
||||
#if OPENZUNE
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OwlCore.AbstractStorage
|
||||
{
|
||||
/// <inheritdoc cref="IFileData"/>
|
||||
public class SystemIOFileData : IFileData
|
||||
{
|
||||
/// <summary>
|
||||
/// The underlying <see cref="File"/> instance in use.
|
||||
/// </summary>
|
||||
internal FileInfo File { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of <see cref="SystemIOFileData" />.
|
||||
/// </summary>
|
||||
/// <param name="file">The <see cref="FileInfo"/> to wrap.</param>
|
||||
public SystemIOFileData(FileInfo file)
|
||||
{
|
||||
File = file;
|
||||
Properties = new FileDataProperties(file);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of <see cref="SystemIOFileData" />.
|
||||
/// </summary>
|
||||
/// <param name="file">The path of the file to wrap.</param>
|
||||
public SystemIOFileData(string filePath) : this(new FileInfo(filePath))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public string Path => File.FullName;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public string Name => File.Name;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public string DisplayName => File.Name;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public string FileExtension => File.Extension;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public string Id => Extensions.StringExtensions.HashMD5Fast(Path);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public IFileDataProperties Properties { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Task<IFolderData> GetParentAsync()
|
||||
{
|
||||
return Task.FromResult<IFolderData>(new SystemIOFolderData(File.Directory));
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Task Delete()
|
||||
{
|
||||
return Task.Run(File.Delete);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task<Stream> GetStreamAsync(FileAccessMode accessMode = FileAccessMode.Read)
|
||||
{
|
||||
return Task.Run<Stream>(() => File.Open(
|
||||
FileMode.Open,
|
||||
accessMode == FileAccessMode.ReadWrite ? FileAccess.ReadWrite : FileAccess.Read));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task WriteAllBytesAsync(byte[] bytes)
|
||||
{
|
||||
return System.IO.File.WriteAllBytesAsync(File.FullName, bytes);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<Stream> GetThumbnailAsync(ThumbnailMode thumbnailMode, uint requiredSize)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user