diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-03-26 16:14:47 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-03-26 16:14:47 -0400 |
| commit | 0cfc20ac0899d83f2bed2af140bee20fc4b32a78 (patch) | |
| tree | 5e8b24c240ea0b8ded12d899e96bb49c3592f1f3 | |
| parent | 6a5b64bcb4764eb9cf68fd61960f0f5bb558ecd4 (diff) | |
stub out profile edit page
23 files changed, 93 insertions, 19 deletions
diff --git a/MediaBrowser.Api/DlnaService.cs b/MediaBrowser.Api/DlnaService.cs index d40492ee2..792a7ff43 100644 --- a/MediaBrowser.Api/DlnaService.cs +++ b/MediaBrowser.Api/DlnaService.cs @@ -30,6 +30,18 @@ namespace MediaBrowser.Api public string Id { get; set; } } + [Route("/Dlna/Profiles/{ProfileId}", "POST", Summary = "Updates a profile")] + public class UpdateProfile : DeviceProfile, IReturnVoid + { + [ApiMember(Name = "ProfileId", Description = "Profile Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")] + public string ProfileId { get; set; } + } + + [Route("/Dlna/Profiles", "POST", Summary = "Creates a profile")] + public class CreateProfile : DeviceProfile, IReturnVoid + { + } + public class DlnaService : BaseApiService { private readonly IDlnaManager _dlnaManager; @@ -64,5 +76,15 @@ namespace MediaBrowser.Api { _dlnaManager.DeleteProfile(request.Id); } + + public void Post(UpdateProfile request) + { + _dlnaManager.UpdateProfile(request); + } + + public void Post(CreateProfile request) + { + _dlnaManager.CreateProfile(request); + } } } diff --git a/MediaBrowser.Controller/Dlna/DeviceProfile.cs b/MediaBrowser.Controller/Dlna/DeviceProfile.cs index d0c2dcc1a..5950698fb 100644 --- a/MediaBrowser.Controller/Dlna/DeviceProfile.cs +++ b/MediaBrowser.Controller/Dlna/DeviceProfile.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Model.Entities; +using MediaBrowser.Model.Dlna; +using MediaBrowser.Model.Entities; using System; using System.Collections.Generic; using System.Linq; @@ -17,9 +18,11 @@ namespace MediaBrowser.Controller.Dlna public string Name { get; set; } [XmlIgnore] - [IgnoreDataMember] public string Id { get; set; } + [XmlIgnore] + public DeviceProfileType ProfileType { get; set; } + /// <summary> /// Gets or sets the identification. /// </summary> diff --git a/MediaBrowser.Controller/Dlna/IDlnaManager.cs b/MediaBrowser.Controller/Dlna/IDlnaManager.cs index eb4b65e14..521d17e01 100644 --- a/MediaBrowser.Controller/Dlna/IDlnaManager.cs +++ b/MediaBrowser.Controller/Dlna/IDlnaManager.cs @@ -25,6 +25,18 @@ namespace MediaBrowser.Controller.Dlna DeviceProfile GetDefaultProfile(); /// <summary> + /// Creates the profile. + /// </summary> + /// <param name="profile">The profile.</param> + void CreateProfile(DeviceProfile profile); + + /// <summary> + /// Updates the profile. + /// </summary> + /// <param name="profile">The profile.</param> + void UpdateProfile(DeviceProfile profile); + + /// <summary> /// Deletes the profile. /// </summary> /// <param name="id">The identifier.</param> diff --git a/MediaBrowser.Dlna/DlnaManager.cs b/MediaBrowser.Dlna/DlnaManager.cs index e40b085fd..edccc71c9 100644 --- a/MediaBrowser.Dlna/DlnaManager.cs +++ b/MediaBrowser.Dlna/DlnaManager.cs @@ -35,11 +35,11 @@ namespace MediaBrowser.Dlna { ExtractProfilesIfNeeded(); - var list = GetProfiles(UserProfilesPath) + var list = GetProfiles(UserProfilesPath, DeviceProfileType.User) .OrderBy(i => i.Name) .ToList(); - list.AddRange(GetProfiles(SystemProfilesPath) + list.AddRange(GetProfiles(SystemProfilesPath, DeviceProfileType.System) .OrderBy(i => i.Name)); return list; @@ -111,7 +111,13 @@ namespace MediaBrowser.Dlna public DeviceProfile GetProfile(DeviceIdentification deviceInfo) { - var profile = GetProfiles().FirstOrDefault(i => IsMatch(deviceInfo, i.Identification)); + if (deviceInfo == null) + { + throw new ArgumentNullException("deviceInfo"); + } + + var profile = GetProfiles() + .FirstOrDefault(i => i.Identification != null && IsMatch(deviceInfo, i.Identification)); if (profile != null) { @@ -127,12 +133,6 @@ namespace MediaBrowser.Dlna private bool IsMatch(DeviceIdentification deviceInfo, DeviceIdentification profileInfo) { - if (profileInfo == null) - { - //There are profiles without identification, ignore thoose - return false; - } - if (!string.IsNullOrWhiteSpace(profileInfo.DeviceDescription)) { if (deviceInfo.DeviceDescription == null || !Regex.IsMatch(deviceInfo.DeviceDescription, profileInfo.DeviceDescription)) @@ -192,6 +192,11 @@ namespace MediaBrowser.Dlna public DeviceProfile GetProfile(IDictionary<string, string> headers) { + if (headers == null) + { + throw new ArgumentNullException("headers"); + } + return GetProfiles().FirstOrDefault(i => IsMatch(headers, i.Identification)); } @@ -238,14 +243,14 @@ namespace MediaBrowser.Dlna } } - private IEnumerable<DeviceProfile> GetProfiles(string path) + private IEnumerable<DeviceProfile> GetProfiles(string path, DeviceProfileType type) { try { return new DirectoryInfo(path) .EnumerateFiles("*", SearchOption.TopDirectoryOnly) .Where(i => string.Equals(i.Extension, ".xml", StringComparison.OrdinalIgnoreCase)) - .Select(i => ParseProfileXmlFile(i.FullName)) + .Select(i => ParseProfileXmlFile(i.FullName, type)) .Where(i => i != null) .ToList(); } @@ -255,13 +260,14 @@ namespace MediaBrowser.Dlna } } - private DeviceProfile ParseProfileXmlFile(string path) + private DeviceProfile ParseProfileXmlFile(string path, DeviceProfileType type) { try { var profile = (DeviceProfile)_xmlSerializer.DeserializeFromFile(typeof(DeviceProfile), path); profile.Id = path.ToLower().GetMD5().ToString("N"); + profile.ProfileType = type; return profile; } @@ -275,9 +281,14 @@ namespace MediaBrowser.Dlna public DeviceProfile GetProfile(string id) { + if (string.IsNullOrWhiteSpace(id)) + { + throw new ArgumentNullException("id"); + } + var info = GetProfileInfosInternal().First(i => string.Equals(i.Info.Id, id)); - return ParseProfileXmlFile(info.Path); + return ParseProfileXmlFile(info.Path, info.Info.Type); } private IEnumerable<InternalProfileInfo> GetProfileInfosInternal() @@ -368,6 +379,14 @@ namespace MediaBrowser.Dlna File.Delete(info.Path); } + public void CreateProfile(DeviceProfile profile) + { + } + + public void UpdateProfile(DeviceProfile profile) + { + } + class InternalProfileInfo { internal DeviceProfileInfo Info { get; set; } diff --git a/MediaBrowser.Dlna/Profiles/DefaultProfile.cs b/MediaBrowser.Dlna/Profiles/DefaultProfile.cs index 254a4d944..0efe18755 100644 --- a/MediaBrowser.Dlna/Profiles/DefaultProfile.cs +++ b/MediaBrowser.Dlna/Profiles/DefaultProfile.cs @@ -8,10 +8,11 @@ namespace MediaBrowser.Dlna.Profiles { public DefaultProfile() { - Name = "Media Browser"; + Name = "Generic Device"; ProtocolInfo = "DLNA"; + FriendlyName = "Media Browser"; Manufacturer = "Media Browser"; ModelDescription = "Media Browser"; ModelName = "Media Browser"; diff --git a/MediaBrowser.Dlna/Profiles/WdtvLiveProfile.cs b/MediaBrowser.Dlna/Profiles/WdtvLiveProfile.cs index b0d65469d..af5d9b295 100644 --- a/MediaBrowser.Dlna/Profiles/WdtvLiveProfile.cs +++ b/MediaBrowser.Dlna/Profiles/WdtvLiveProfile.cs @@ -1,5 +1,5 @@ -using System.Xml.Serialization; -using MediaBrowser.Controller.Dlna; +using MediaBrowser.Controller.Dlna; +using System.Xml.Serialization; namespace MediaBrowser.Dlna.Profiles { diff --git a/MediaBrowser.Dlna/Profiles/Xml/Default.xml b/MediaBrowser.Dlna/Profiles/Xml/Default.xml index 25d553a07..52b92c6f3 100644 --- a/MediaBrowser.Dlna/Profiles/Xml/Default.xml +++ b/MediaBrowser.Dlna/Profiles/Xml/Default.xml @@ -1,6 +1,7 @@ <?xml version="1.0"?> <Profile xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> - <Name>Media Browser</Name> + <Name>Generic Device</Name> + <FriendlyName>Media Browser</FriendlyName> <Manufacturer>Media Browser</Manufacturer> <ManufacturerUrl>http://mediabrowser3.com/</ManufacturerUrl> <ModelName>Media Browser</ModelName> diff --git a/MediaBrowser.Dlna/Profiles/Xml/Denon AVR.xml b/MediaBrowser.Dlna/Profiles/Xml/Denon AVR.xml index ac0309ce4..3332e4d45 100644 --- a/MediaBrowser.Dlna/Profiles/Xml/Denon AVR.xml +++ b/MediaBrowser.Dlna/Profiles/Xml/Denon AVR.xml @@ -6,6 +6,7 @@ <Manufacturer>Denon</Manufacturer> <Headers /> </Identification> + <FriendlyName>Media Browser</FriendlyName> <Manufacturer>Media Browser</Manufacturer> <ManufacturerUrl>http://mediabrowser3.com/</ManufacturerUrl> <ModelName>Media Browser</ModelName> diff --git a/MediaBrowser.Dlna/Profiles/Xml/LG Smart TV.xml b/MediaBrowser.Dlna/Profiles/Xml/LG Smart TV.xml index 32364ced7..cc8b40430 100644 --- a/MediaBrowser.Dlna/Profiles/Xml/LG Smart TV.xml +++ b/MediaBrowser.Dlna/Profiles/Xml/LG Smart TV.xml @@ -7,6 +7,7 @@ <HttpHeaderInfo name="User-Agent" value="LG" match="Substring" /> </Headers> </Identification> + <FriendlyName>Media Browser</FriendlyName> <Manufacturer>Media Browser</Manufacturer> <ManufacturerUrl>http://mediabrowser3.com/</ManufacturerUrl> <ModelName>Media Browser</ModelName> diff --git a/MediaBrowser.Dlna/Profiles/Xml/Linksys DMA2100.xml b/MediaBrowser.Dlna/Profiles/Xml/Linksys DMA2100.xml index 3437cdb5c..b19cb0f7b 100644 --- a/MediaBrowser.Dlna/Profiles/Xml/Linksys DMA2100.xml +++ b/MediaBrowser.Dlna/Profiles/Xml/Linksys DMA2100.xml @@ -5,6 +5,7 @@ <ModelName>DMA2100us</ModelName> <Headers /> </Identification> + <FriendlyName>Media Browser</FriendlyName> <Manufacturer>Media Browser</Manufacturer> <ManufacturerUrl>http://mediabrowser3.com/</ManufacturerUrl> <ModelName>Media Browser</ModelName> diff --git a/MediaBrowser.Dlna/Profiles/Xml/Panasonic Viera.xml b/MediaBrowser.Dlna/Profiles/Xml/Panasonic Viera.xml index e8b2ff619..71e240313 100644 --- a/MediaBrowser.Dlna/Profiles/Xml/Panasonic Viera.xml +++ b/MediaBrowser.Dlna/Profiles/Xml/Panasonic Viera.xml @@ -8,6 +8,7 @@ <HttpHeaderInfo name="User-Agent" value="Panasonic MIL DLNA" match="Substring" /> </Headers> </Identification> + <FriendlyName>Media Browser</FriendlyName> <Manufacturer>Media Browser</Manufacturer> <ManufacturerUrl>http://mediabrowser3.com/</ManufacturerUrl> <ModelName>Media Browser</ModelName> diff --git a/MediaBrowser.Dlna/Profiles/Xml/Samsung Smart TV.xml b/MediaBrowser.Dlna/Profiles/Xml/Samsung Smart TV.xml index 0cc34bbca..77648147f 100644 --- a/MediaBrowser.Dlna/Profiles/Xml/Samsung Smart TV.xml +++ b/MediaBrowser.Dlna/Profiles/Xml/Samsung Smart TV.xml @@ -5,6 +5,7 @@ <ModelUrl>samsung.com</ModelUrl> <Headers /> </Identification> + <FriendlyName>Media Browser</FriendlyName> <Manufacturer>Media Browser</Manufacturer> <ManufacturerUrl>http://mediabrowser3.com/</ManufacturerUrl> <ModelName>Media Browser</ModelName> diff --git a/MediaBrowser.Dlna/Profiles/Xml/Sony Blu-ray Player 2013.xml b/MediaBrowser.Dlna/Profiles/Xml/Sony Blu-ray Player 2013.xml index a26ab8c85..942812295 100644 --- a/MediaBrowser.Dlna/Profiles/Xml/Sony Blu-ray Player 2013.xml +++ b/MediaBrowser.Dlna/Profiles/Xml/Sony Blu-ray Player 2013.xml @@ -7,6 +7,7 @@ <Manufacturer>Sony</Manufacturer> <Headers /> </Identification> + <FriendlyName>Media Browser</FriendlyName> <Manufacturer>Microsoft Corporation</Manufacturer> <ManufacturerUrl>http://mediabrowser3.com/</ManufacturerUrl> <ModelName>Windows Media Player Sharing</ModelName> diff --git a/MediaBrowser.Dlna/Profiles/Xml/Sony Blu-ray Player.xml b/MediaBrowser.Dlna/Profiles/Xml/Sony Blu-ray Player.xml index f5e4da835..519304576 100644 --- a/MediaBrowser.Dlna/Profiles/Xml/Sony Blu-ray Player.xml +++ b/MediaBrowser.Dlna/Profiles/Xml/Sony Blu-ray Player.xml @@ -9,6 +9,7 @@ <HttpHeaderInfo name="X-AV-Physical-Unit-Info" value="(Blu-ray Disc Player|Home Theater System|Home Theatre System|Media Player)" match="Regex" /> </Headers> </Identification> + <FriendlyName>Media Browser</FriendlyName> <Manufacturer>Microsoft Corporation</Manufacturer> <ManufacturerUrl>http://mediabrowser3.com/</ManufacturerUrl> <ModelName>Windows Media Player Sharing</ModelName> diff --git a/MediaBrowser.Dlna/Profiles/Xml/Sony Bravia (2010).xml b/MediaBrowser.Dlna/Profiles/Xml/Sony Bravia (2010).xml index 8387e2d0d..d240e1d34 100644 --- a/MediaBrowser.Dlna/Profiles/Xml/Sony Bravia (2010).xml +++ b/MediaBrowser.Dlna/Profiles/Xml/Sony Bravia (2010).xml @@ -8,6 +8,7 @@ <HttpHeaderInfo name="X-AV-Client-Info" value=".*KDL-\d{2}[EHLNPB]X\d[01]\d.*" match="Regex" /> </Headers> </Identification> + <FriendlyName>Media Browser</FriendlyName> <Manufacturer>Microsoft Corporation</Manufacturer> <ManufacturerUrl>http://www.microsoft.com/</ManufacturerUrl> <ModelName>Windows Media Player Sharing</ModelName> diff --git a/MediaBrowser.Dlna/Profiles/Xml/Sony Bravia (2011).xml b/MediaBrowser.Dlna/Profiles/Xml/Sony Bravia (2011).xml index febd70f50..2372aa5ad 100644 --- a/MediaBrowser.Dlna/Profiles/Xml/Sony Bravia (2011).xml +++ b/MediaBrowser.Dlna/Profiles/Xml/Sony Bravia (2011).xml @@ -8,6 +8,7 @@ <HttpHeaderInfo name="X-AV-Client-Info" value=".*KDL-\d{2}([A-Z]X\d2\d|CX400).*" match="Regex" /> </Headers> </Identification> + <FriendlyName>Media Browser</FriendlyName> <Manufacturer>Microsoft Corporation</Manufacturer> <ManufacturerUrl>http://www.microsoft.com/</ManufacturerUrl> <ModelName>Windows Media Player Sharing</ModelName> diff --git a/MediaBrowser.Dlna/Profiles/Xml/Sony Bravia (2012).xml b/MediaBrowser.Dlna/Profiles/Xml/Sony Bravia (2012).xml index 08217ce04..7edf09134 100644 --- a/MediaBrowser.Dlna/Profiles/Xml/Sony Bravia (2012).xml +++ b/MediaBrowser.Dlna/Profiles/Xml/Sony Bravia (2012).xml @@ -8,6 +8,7 @@ <HttpHeaderInfo name="X-AV-Client-Info" value=".*KDL-\d{2}[A-Z]X\d5(\d|G).*" match="Regex" /> </Headers> </Identification> + <FriendlyName>Media Browser</FriendlyName> <Manufacturer>Microsoft Corporation</Manufacturer> <ManufacturerUrl>http://www.microsoft.com/</ManufacturerUrl> <ModelName>Windows Media Player Sharing</ModelName> diff --git a/MediaBrowser.Dlna/Profiles/Xml/Sony Bravia (2013).xml b/MediaBrowser.Dlna/Profiles/Xml/Sony Bravia (2013).xml index 9f0f4204e..ec624cd8e 100644 --- a/MediaBrowser.Dlna/Profiles/Xml/Sony Bravia (2013).xml +++ b/MediaBrowser.Dlna/Profiles/Xml/Sony Bravia (2013).xml @@ -8,6 +8,7 @@ <HttpHeaderInfo name="X-AV-Client-Info" value=".*KDL-\d{2}[WR][5689]\d{2}A.*" match="Regex" /> </Headers> </Identification> + <FriendlyName>Media Browser</FriendlyName> <Manufacturer>Microsoft Corporation</Manufacturer> <ManufacturerUrl>http://www.microsoft.com/</ManufacturerUrl> <ModelName>Windows Media Player Sharing</ModelName> diff --git a/MediaBrowser.Dlna/Profiles/Xml/Sony PlayStation 3.xml b/MediaBrowser.Dlna/Profiles/Xml/Sony PlayStation 3.xml index 21e94f3e5..eeaf2d819 100644 --- a/MediaBrowser.Dlna/Profiles/Xml/Sony PlayStation 3.xml +++ b/MediaBrowser.Dlna/Profiles/Xml/Sony PlayStation 3.xml @@ -8,6 +8,7 @@ <HttpHeaderInfo name="X-AV-Client-Info" value="PLAYSTATION 3" match="Substring" /> </Headers> </Identification> + <FriendlyName>Media Browser</FriendlyName> <Manufacturer>Media Browser</Manufacturer> <ManufacturerUrl>http://mediabrowser3.com/</ManufacturerUrl> <ModelName>Media Browser</ModelName> diff --git a/MediaBrowser.Dlna/Profiles/Xml/WDTV Live.xml b/MediaBrowser.Dlna/Profiles/Xml/WDTV Live.xml index df3d78f03..ffa39c26d 100644 --- a/MediaBrowser.Dlna/Profiles/Xml/WDTV Live.xml +++ b/MediaBrowser.Dlna/Profiles/Xml/WDTV Live.xml @@ -8,6 +8,7 @@ <HttpHeaderInfo name="User-Agent" value="ALPHA Networks" match="Substring" /> </Headers> </Identification> + <FriendlyName>Media Browser</FriendlyName> <Manufacturer>Media Browser</Manufacturer> <ManufacturerUrl>http://mediabrowser3.com/</ManufacturerUrl> <ModelName>Media Browser</ModelName> diff --git a/MediaBrowser.Dlna/Profiles/Xml/Xbox 360.xml b/MediaBrowser.Dlna/Profiles/Xml/Xbox 360.xml index 99401434c..e7839ca77 100644 --- a/MediaBrowser.Dlna/Profiles/Xml/Xbox 360.xml +++ b/MediaBrowser.Dlna/Profiles/Xml/Xbox 360.xml @@ -8,6 +8,7 @@ <HttpHeaderInfo name="User-Agent" value="Xenon" match="Substring" /> </Headers> </Identification> + <FriendlyName>Media Browser</FriendlyName> <Manufacturer>Microsoft Corporation</Manufacturer> <ManufacturerUrl>http://www.microsoft.com/</ManufacturerUrl> <ModelName>Windows Media Player Sharing</ModelName> diff --git a/MediaBrowser.Dlna/Profiles/Xml/Xbox One.xml b/MediaBrowser.Dlna/Profiles/Xml/Xbox One.xml index f731903ce..5243218fb 100644 --- a/MediaBrowser.Dlna/Profiles/Xml/Xbox One.xml +++ b/MediaBrowser.Dlna/Profiles/Xml/Xbox One.xml @@ -6,6 +6,7 @@ <ModelName>Xbox One</ModelName> <Headers /> </Identification> + <FriendlyName>Media Browser</FriendlyName> <Manufacturer>Media Browser</Manufacturer> <ManufacturerUrl>http://mediabrowser3.com/</ManufacturerUrl> <ModelName>Media Browser</ModelName> diff --git a/MediaBrowser.Dlna/Profiles/Xml/foobar2000.xml b/MediaBrowser.Dlna/Profiles/Xml/foobar2000.xml index f50ea581a..126d7fe73 100644 --- a/MediaBrowser.Dlna/Profiles/Xml/foobar2000.xml +++ b/MediaBrowser.Dlna/Profiles/Xml/foobar2000.xml @@ -7,6 +7,7 @@ <HttpHeaderInfo name="User-Agent" value="foobar" match="Substring" /> </Headers> </Identification> + <FriendlyName>Media Browser</FriendlyName> <Manufacturer>Media Browser</Manufacturer> <ManufacturerUrl>http://mediabrowser3.com/</ManufacturerUrl> <ModelName>Media Browser</ModelName> |
