diff --git a/MediaBrowser.Api/ApiService.cs b/MediaBrowser.Api/ApiService.cs index 34f7e69e7..bb2427574 100644 --- a/MediaBrowser.Api/ApiService.cs +++ b/MediaBrowser.Api/ApiService.cs @@ -31,9 +31,14 @@ namespace MediaBrowser.Api UserItemData = Kernel.Instance.GetUserItemData(userId, item.Id), Type = item.GetType().Name, IsFolder = (item is Folder), - ParentId = item.Parent == null ? Guid.Empty : item.Parent.Id + ParentLogoItemId = GetParentLogoItemId(item) }; + if (item.Parent != null) + { + wrapper.ParentId = item.Parent.Id; + } + if (includeChildren) { var folder = item as Folder; @@ -46,5 +51,25 @@ namespace MediaBrowser.Api return wrapper; } + + private static Guid? GetParentLogoItemId(BaseItem item) + { + if (string.IsNullOrEmpty(item.LogoImagePath)) + { + var parent = item.Parent; + + while (parent != null) + { + if (!string.IsNullOrEmpty(parent.LogoImagePath)) + { + return parent.Id; + } + + parent = parent.Parent; + } + } + + return null; + } } } diff --git a/MediaBrowser.ApiInteraction/BaseClient.cs b/MediaBrowser.ApiInteraction/BaseClient.cs index bd25b1653..887c1779f 100644 --- a/MediaBrowser.ApiInteraction/BaseClient.cs +++ b/MediaBrowser.ApiInteraction/BaseClient.cs @@ -8,7 +8,23 @@ namespace MediaBrowser.ApiInteraction /// public abstract class BaseClient : IDisposable { - public string ApiUrl { get; set; } + /// + /// Gets or sets the server host name (myserver or 192.168.x.x) + /// + public string ServerHostName { get; set; } + + /// + /// Gets or sets the port number used by the API + /// + public int ApiPort { get; set; } + + protected string ApiUrl + { + get + { + return string.Format("http://{0}:{1}/mediabrowser/api", ServerHostName, ApiPort); + } + } protected HttpClient HttpClient { get; private set; } diff --git a/MediaBrowser.Common/Kernel/BaseKernel.cs b/MediaBrowser.Common/Kernel/BaseKernel.cs index 514c05097..2420a5091 100644 --- a/MediaBrowser.Common/Kernel/BaseKernel.cs +++ b/MediaBrowser.Common/Kernel/BaseKernel.cs @@ -141,7 +141,7 @@ namespace MediaBrowser.Common.Kernel /// /// Reloads application configuration from the config file /// - private void ReloadConfiguration() + protected virtual void ReloadConfiguration() { //Configuration information for anything other than server-specific configuration will have to come via the API... -ebr @@ -199,7 +199,7 @@ namespace MediaBrowser.Common.Kernel /// /// Disposes all resources currently in use. /// - public void Dispose() + public virtual void Dispose() { DisposeHttpServer(); DisposeLogger(); diff --git a/MediaBrowser.Common/MediaBrowser.Common.csproj b/MediaBrowser.Common/MediaBrowser.Common.csproj index 21430001c..326bbe424 100644 --- a/MediaBrowser.Common/MediaBrowser.Common.csproj +++ b/MediaBrowser.Common/MediaBrowser.Common.csproj @@ -30,8 +30,9 @@ 4 - - ..\packages\ServiceStack.Text.3.8.5\lib\net35\ServiceStack.Text.dll + + False + ..\packages\ServiceStack.Text.3.9.3\lib\net35\ServiceStack.Text.dll diff --git a/MediaBrowser.Common/packages.config b/MediaBrowser.Common/packages.config index 15a978d36..a2d64772c 100644 --- a/MediaBrowser.Common/packages.config +++ b/MediaBrowser.Common/packages.config @@ -1,5 +1,5 @@  - + \ No newline at end of file diff --git a/MediaBrowser.Model/Entities/ApiBaseItem.cs b/MediaBrowser.Model/Entities/ApiBaseItem.cs index 341b1c77f..0ec9ed7c6 100644 --- a/MediaBrowser.Model/Entities/ApiBaseItem.cs +++ b/MediaBrowser.Model/Entities/ApiBaseItem.cs @@ -26,7 +26,7 @@ namespace MediaBrowser.Model.Entities public bool IsFolder { get; set; } - public Guid ParentId { get; set; } + public Guid? ParentId { get; set; } public string Type { get; set; } @@ -39,5 +39,10 @@ namespace MediaBrowser.Model.Entities { return Type.Equals(type, StringComparison.OrdinalIgnoreCase); } + + /// + /// If the item does not have a logo, this will hold the Id of the Parent that has one. + /// + public Guid? ParentLogoItemId { get; set; } } }