Files
jellyfin-jellyfin-1/MediaBrowser.Controller/Entities/UserView.cs

195 lines
5.6 KiB
C#
Raw Normal View History

2015-08-14 13:24:07 -04:00
using MediaBrowser.Controller.Playlists;
2015-03-14 00:50:23 -04:00
using MediaBrowser.Controller.TV;
2014-06-04 22:32:40 -04:00
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Querying;
2014-06-04 22:32:40 -04:00
using System;
using System.Collections.Generic;
2015-08-14 13:24:07 -04:00
using System.Runtime.Serialization;
2014-08-14 09:24:30 -04:00
using System.Threading.Tasks;
2015-11-02 12:25:01 -05:00
using System.Linq;
2014-06-04 22:32:40 -04:00
namespace MediaBrowser.Controller.Entities
{
public class UserView : Folder
{
public string ViewType { get; set; }
public Guid ParentId { get; set; }
2015-10-16 00:46:41 -04:00
public Guid DisplayParentId { get; set; }
2014-06-04 22:32:40 -04:00
2015-08-14 14:30:08 -04:00
public Guid? UserId { get; set; }
2015-11-08 00:04:38 -05:00
public static ITVSeriesManager TVSeriesManager;
2015-03-14 00:50:23 -04:00
public static IPlaylistManager PlaylistManager;
public bool ContainsDynamicCategories(User user)
{
return true;
}
2015-10-29 09:28:05 -04:00
public override IEnumerable<Guid> GetIdsForAncestorQuery()
{
var list = new List<Guid>();
if (DisplayParentId != Guid.Empty)
{
list.Add(DisplayParentId);
}
else if (ParentId != Guid.Empty)
{
list.Add(ParentId);
}
2015-11-11 09:56:31 -05:00
else
{
list.Add(Id);
}
2015-10-29 09:28:05 -04:00
return list;
}
2015-11-08 00:04:38 -05:00
2014-10-06 19:58:46 -04:00
public override Task<QueryResult<BaseItem>> GetItems(InternalItemsQuery query)
2014-06-04 22:32:40 -04:00
{
2014-10-29 18:01:02 -04:00
var parent = this as Folder;
2015-10-16 00:46:41 -04:00
if (DisplayParentId != Guid.Empty)
{
parent = LibraryManager.GetItemById(DisplayParentId) as Folder ?? parent;
}
else if (ParentId != Guid.Empty)
2014-10-29 18:01:02 -04:00
{
parent = LibraryManager.GetItemById(ParentId) as Folder ?? parent;
}
2015-03-14 00:50:23 -04:00
return new UserViewBuilder(UserViewManager, LiveTvManager, ChannelManager, LibraryManager, Logger, UserDataManager, TVSeriesManager, CollectionManager, PlaylistManager)
2014-11-10 22:41:55 -05:00
.GetUserItems(parent, this, ViewType, query);
}
2014-06-04 22:32:40 -04:00
public override IEnumerable<BaseItem> GetChildren(User user, bool includeLinkedChildren)
{
2014-10-06 19:58:46 -04:00
var result = GetItems(new InternalItemsQuery
2014-06-04 22:32:40 -04:00
{
User = user
2014-08-14 09:24:30 -04:00
}).Result;
2014-08-14 09:24:30 -04:00
return result.Items;
2014-06-04 22:32:40 -04:00
}
2014-08-14 09:24:30 -04:00
2015-02-06 00:39:07 -05:00
public override bool CanDelete()
{
return false;
}
2015-02-21 08:37:27 -05:00
public override bool IsSaveLocalMetadataEnabled()
{
return true;
}
2015-01-25 01:34:50 -05:00
public override IEnumerable<BaseItem> GetRecursiveChildren(User user, Func<BaseItem, bool> filter)
2014-08-14 09:24:30 -04:00
{
2014-10-06 19:58:46 -04:00
var result = GetItems(new InternalItemsQuery
{
User = user,
2015-01-25 01:34:50 -05:00
Recursive = true,
Filter = filter
2014-08-14 09:24:30 -04:00
}).Result;
2014-08-14 09:24:30 -04:00
return result.Items;
2014-08-14 09:24:30 -04:00
}
2014-06-04 22:32:40 -04:00
protected override IEnumerable<BaseItem> GetEligibleChildrenForRecursiveChildren(User user)
{
return GetChildren(user, false);
}
public static bool IsExcludedFromGrouping(Folder folder)
{
var standaloneTypes = new List<string>
{
CollectionType.Books,
CollectionType.HomeVideos,
2015-09-15 14:09:44 -04:00
CollectionType.Photos,
CollectionType.Playlists,
2015-10-12 15:09:56 -04:00
CollectionType.BoxSets,
2015-11-02 12:25:01 -05:00
CollectionType.MusicVideos,
CollectionType.Games,
CollectionType.Music
2015-09-15 14:09:44 -04:00
};
var collectionFolder = folder as ICollectionFolder;
if (collectionFolder == null)
{
return false;
}
return standaloneTypes.Contains(collectionFolder.CollectionType ?? string.Empty);
}
public static bool IsUserSpecific(Folder folder)
{
var standaloneTypes = new List<string>
{
2015-11-11 09:56:31 -05:00
CollectionType.Playlists
2014-06-04 22:32:40 -04:00
};
2015-11-11 09:56:31 -05:00
if (!ConfigurationManager.Configuration.EnableSharedCollectionViewImage)
{
standaloneTypes.Add(CollectionType.BoxSets);
}
2014-10-11 21:46:02 -04:00
var collectionFolder = folder as ICollectionFolder;
2014-06-04 22:32:40 -04:00
if (collectionFolder == null)
{
return false;
}
2015-11-14 11:58:01 -05:00
var supportsUserSpecific = folder as ISupportsUserSpecificView;
if (supportsUserSpecific != null && supportsUserSpecific.EnableUserSpecificView)
{
return true;
}
2014-06-04 22:32:40 -04:00
return standaloneTypes.Contains(collectionFolder.CollectionType ?? string.Empty);
}
2015-06-28 21:10:45 -04:00
2015-11-02 12:25:01 -05:00
public static bool IsEligibleForEnhancedView(string viewType)
{
2015-11-14 11:58:01 -05:00
var types = new[]
{
CollectionType.Movies,
CollectionType.TvShows
};
2015-11-02 12:25:01 -05:00
return types.Contains(viewType ?? string.Empty, StringComparer.OrdinalIgnoreCase);
}
2015-11-14 12:05:08 -05:00
public static bool EnableOriginalFolder(string viewType)
{
var types = new[]
{
CollectionType.Games,
CollectionType.Books,
2015-11-14 13:57:26 -05:00
CollectionType.MusicVideos ,
CollectionType.HomeVideos
2015-11-14 12:05:08 -05:00
};
return types.Contains(viewType ?? string.Empty, StringComparer.OrdinalIgnoreCase);
}
2015-11-08 00:04:38 -05:00
protected override Task ValidateChildrenInternal(IProgress<double> progress, System.Threading.CancellationToken cancellationToken, bool recursive, bool refreshChildMetadata, Providers.MetadataRefreshOptions refreshOptions, Providers.IDirectoryService directoryService)
{
return Task.FromResult(true);
}
2015-06-28 21:10:45 -04:00
[IgnoreDataMember]
public override bool SupportsPeople
{
get
{
return false;
}
}
2014-06-04 22:32:40 -04:00
}
}