Skip to content

Commit

Permalink
Last release update
Browse files Browse the repository at this point in the history
  • Loading branch information
opengd committed Oct 8, 2015
1 parent 3e12778 commit eaafa9e
Show file tree
Hide file tree
Showing 9 changed files with 190 additions and 363 deletions.
118 changes: 95 additions & 23 deletions Chimney.MPD/Chimney.MPD.csproj
Original file line number Diff line number Diff line change
@@ -1,50 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="https://schemas.microsoft.com/developer/msbuild/2003">
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="https://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<MinimumVisualStudioVersion>12.0</MinimumVisualStudioVersion>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{13A46569-714B-4C79-BA5B-30E5BDD579A2}</ProjectGuid>
<ProjectGuid>{FC9A0095-F01A-4A14-A16C-EDF6EFECF16C}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Chimney.MPD</RootNamespace>
<AssemblyName>Chimney.MPD</AssemblyName>
<DefaultLanguage>en-US</DefaultLanguage>
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
<TargetPlatformVersion>10.0.10240.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.10240.0</TargetPlatformMinVersion>
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<TargetFrameworkProfile>Profile32</TargetFrameworkProfile>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
<ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'">
<PlatformTarget>ARM</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\ARM\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>ARM</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM'">
<PlatformTarget>ARM</PlatformTarget>
<OutputPath>bin\ARM\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<PlatformTarget>ARM</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<PlatformTarget>x64</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<PlatformTarget>x64</PlatformTarget>
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<PlatformTarget>x86</PlatformTarget>
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<!-- A reference to the entire .NET Framework is automatically included -->
</ItemGroup>
<ItemGroup>
<TargetPlatform Include="WindowsPhoneApp, Version=8.1" />
<TargetPlatform Include="Windows, Version=8.1" />
<!-- A reference to the entire .Net Framework and Windows SDK are automatically included -->
<None Include="project.json" />
</ItemGroup>
<ItemGroup>
<Compile Include="ChimneyMPDBase.cs" />
<Compile Include="ChimneyMPDClient.cs" />
<Compile Include="ChimneyMPDDirectClient.cs" />
<Compile Include="ChimneyMPDEvent.cs" />
<Compile Include="ChimneyMPDServer.cs" />
<Compile Include="Classes\Channel.cs" />
<Compile Include="Classes\Message.cs" />
<Compile Include="Classes\Output.cs" />
Expand All @@ -54,16 +127,15 @@
<Compile Include="Classes\Status.cs" />
<Compile Include="Classes\StoredPlaylist.cs" />
<Compile Include="Classes\TagType.cs" />
<Compile Include="ChimneyMPDBase.cs" />
<Compile Include="ChimneyMPDClient.cs" />
<None Include="ChimneyMPDDirectClient.cs" />
<Compile Include="ChimneyMPDEvent.cs" />
<Compile Include="ChimneyMPDServer.cs" />
<Compile Include="MPDKeyWords.cs" />
<Compile Include="Net\Connection.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Content Include="Properties\Chimney.MPD.rd.xml" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '14.0' ">
<VisualStudioVersion>14.0</VisualStudioVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
Expand Down
53 changes: 52 additions & 1 deletion Chimney.MPD/ChimneyMPDBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,58 @@ public async Task<bool> Connect(string host, string port, string password = null

return success;
}


public async Task<Tuple<bool, bool>> TestConnect(string host, string port, string password = null, bool silent = false, int timeout = 0)
{
this.host = host;
this.port = port;
this.password = password;

if (_connection != null)
{
_connection.Close();
Debug.WriteLine(this.name + " : CLOSE CONNECTION");
}

_connection = new Connection();

var permission = true;

bool success = await _connection.Connect(host, port, timeout);

Debug.WriteLine(this.name + " : NEW CONNECTION : " + success);

if (success)
{
var response = await Connection.Recive(_connection.Socket,
new List<string>() { MPDKeyWords.Response.SUCCESS_CONNECT },
new List<string>() { MPDKeyWords.Response.OK + MPDKeyWords.Response.LINEBREAK },
new List<string>() { MPDKeyWords.Response.ACK },
new List<string>() { MPDKeyWords.Response.LINEBREAK });

if (string.IsNullOrEmpty(response) || !response.StartsWith(MPDKeyWords.Response.SUCCESS_CONNECT))
success = false;

Debug.WriteLine(this.name + " : NEW CONNECTION : RESPONSE : " + success);

if (success)
{
await Password(password, false);

if (await TestPermission() == null)
permission = false;
}

Debug.WriteLine(this.name + " : NEW CONNECTION : PERMISSION : " + permission);
}

_connection.Close();

Debug.WriteLine(this.name + " : NEW CONNECTION : RETURN : " + success + " " + permission);

return new Tuple<bool, bool>(success, permission);
}

// Send and recive data to MPD server
//
private async Task RunQueue()
Expand Down
28 changes: 23 additions & 5 deletions Chimney.MPD/ChimneyMPDClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,15 @@ public async Task<bool> Prio(int id, int prio)
: false;
}

public async Task<bool> PrioRange(int from, int to, int prio)
{
int qId = await Send(MPDKeyWords.Client.Playlist.PRIO,
new List<string>() { prio.ToString(), from.ToString() + ":" + to.ToString() });
return ((await Response(qId)).Equals(MPDKeyWords.Response.OK_LINEBREAK))
? true
: false;
}

public async Task<bool> UpdateDb(string URI = "")
{
int qId = await Send(MPDKeyWords.Client.Database.UPDATE,
Expand Down Expand Up @@ -467,7 +476,7 @@ public async Task<bool> PlaybackSettingsCrossfade(int seconds)
: false;
}

public async Task<bool> RemoveFromPlaylist(int id)
public async Task<bool> RemoveIdFromPlaylist(int id)
{
int qId = await Send(MPDKeyWords.Client.Playlist.DELETEID,
new List<string>() { id.ToString() });
Expand All @@ -476,10 +485,19 @@ public async Task<bool> RemoveFromPlaylist(int id)
: false;
}

public async Task<bool> RemoveFromPlaylist(int id, string playlistname)
public async Task<bool> RemoveFromPlaylist(int position)
{
int qId = await Send(MPDKeyWords.Client.Playlist.DELETE,
new List<string>() { position.ToString() });
return ((await Response(qId)).Equals(MPDKeyWords.Response.OK_LINEBREAK))
? true
: false;
}

public async Task<bool> RemoveFromPlaylist(int position, string playlistname)
{
int qId = await Send(MPDKeyWords.Client.StoredPlaylist.PLAYLISTDELETE,
new List<string>() { id.ToString() },
new List<string>() { position.ToString() },
new List<string>() { playlistname },
true);
return ((await Response(qId)).Equals(MPDKeyWords.Response.OK_LINEBREAK))
Expand All @@ -498,7 +516,7 @@ public async Task<bool> SeekCurrent(int time)

public async Task<bool> SeekId(int time, int id)
{
int qId = await Send(MPDKeyWords.Client.Playback.SEEKCUR,
int qId = await Send(MPDKeyWords.Client.Playback.SEEKID,
new List<string>() { id.ToString(), time.ToString() });
return ((await Response(qId)).Equals(MPDKeyWords.Response.OK_LINEBREAK))
? true
Expand Down Expand Up @@ -544,7 +562,7 @@ public async Task<bool> SearchAddToPlaylist(string playlist, string type, string
new List<string>() { playlist, type, searchstring })
: await Send(MPDKeyWords.Client.Database.SEARCHADD,
new List<string>(),
new List<string>() { playlist, type, searchstring });
new List<string>() { type, searchstring });

return ((await Response(qId)).Equals(MPDKeyWords.Response.OK_LINEBREAK))
? true
Expand Down
7 changes: 5 additions & 2 deletions Chimney.MPD/ChimneyMPDDirectClient.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
using System;
using Chimney.MPD.Classes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Xaml;

namespace Chimney.MPD
{

/*
public class ChimneyMPDDirectClient : ChimneyMPDBase
{
Expand Down Expand Up @@ -838,4 +840,5 @@ public async Task<SongTag> PlaylistId(int Id)
}
*/
}
7 changes: 5 additions & 2 deletions Chimney.MPD/ChimneyMPDEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,12 @@ public PlayerEventArgs(SongTag currentsong, Status status)
public class OutputEventArgs : EventArgs
{
public List<Output> outputs;
public Status status;

public OutputEventArgs(List<Output> outputs)
public OutputEventArgs(List<Output> outputs, Status status)
{
this.outputs = outputs;
this.status = status;
}
}

Expand Down Expand Up @@ -214,7 +216,8 @@ private async Task ActionOnEventLoop()
if (OnMixer != null) OnMixer(this, new StatusEventArgs(status));
break;
case ("output"):
if (OnOutput != null) OnOutput(this, new OutputEventArgs(await this.Outputs()));
if (status == null) status = await this.GetStatus();
if (OnOutput != null) OnOutput(this, new OutputEventArgs(await this.Outputs(), status));
break;
case ("options"):
if (status == null) status = await this.GetStatus();
Expand Down
2 changes: 1 addition & 1 deletion Chimney.MPD/ChimneyMPDServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ public class ChimneyMPDServer : ChimneyMPDBase

public Dictionary<int, ResponseConfig> ResponsConfigDictionary = new Dictionary<int, ResponseConfig>();

private string password = string.Empty;
private new string password = string.Empty;

private bool password_confirmed = false;

Expand Down
Loading

0 comments on commit eaafa9e

Please sign in to comment.