jellyfin/Emby.Server.Implementations/Devices/CameraUploadsFolder.cs

72 lines
2.1 KiB
C#
Raw Normal View History

2017-08-16 10:30:16 -07:00
using System;
2014-10-11 13:38:13 -07:00
using System.Linq;
2015-11-02 21:34:47 -07:00
using System.Threading;
using System.Threading.Tasks;
2017-08-16 10:30:16 -07:00
using MediaBrowser.Controller.Entities;
2015-11-02 21:34:47 -07:00
using MediaBrowser.Controller.Providers;
2016-11-10 20:29:51 -07:00
using MediaBrowser.Model.Serialization;
2014-10-11 13:38:13 -07:00
2017-08-16 10:30:16 -07:00
namespace Emby.Server.Implementations.Devices
2014-10-11 13:38:13 -07:00
{
2015-11-14 09:58:01 -07:00
public class CameraUploadsFolder : BasePluginFolder, ISupportsUserSpecificView
2014-10-11 13:38:13 -07:00
{
public CameraUploadsFolder()
{
Name = "Camera Uploads";
}
public override bool IsVisible(User user)
{
2015-03-01 22:16:29 -07:00
if (!user.Policy.EnableAllFolders && !user.Policy.EnabledFolders.Contains(Id.ToString("N"), StringComparer.OrdinalIgnoreCase))
{
return false;
}
2015-10-30 08:23:06 -07:00
return base.IsVisible(user) && HasChildren();
2014-10-11 13:38:13 -07:00
}
2016-05-24 19:06:56 -07:00
[IgnoreDataMember]
2015-10-30 08:23:06 -07:00
public override string CollectionType
2014-10-11 13:38:13 -07:00
{
2017-10-21 09:39:52 -07:00
get { return MediaBrowser.Model.Entities.CollectionType.HomeVideos; }
2014-10-11 13:38:13 -07:00
}
2017-06-29 12:10:58 -07:00
[IgnoreDataMember]
public override bool SupportsInheritedParentImages
{
get
{
return false;
}
}
2015-10-30 08:23:06 -07:00
public override string GetClientTypeName()
2014-10-11 13:38:13 -07:00
{
2015-10-30 08:23:06 -07:00
return typeof(CollectionFolder).Name;
2014-10-11 13:38:13 -07:00
}
2015-10-30 08:23:06 -07:00
private bool? _hasChildren;
private bool HasChildren()
2014-10-11 13:38:13 -07:00
{
2015-10-30 08:23:06 -07:00
if (!_hasChildren.HasValue)
{
2017-05-23 09:43:24 -07:00
_hasChildren = LibraryManager.GetItemIds(new InternalItemsQuery { Parent = this }).Count > 0;
2015-10-30 08:23:06 -07:00
}
return _hasChildren.Value;
2014-10-11 13:38:13 -07:00
}
2015-11-02 21:34:47 -07:00
protected override Task ValidateChildrenInternal(IProgress<double> progress, CancellationToken cancellationToken, bool recursive, bool refreshChildMetadata, MetadataRefreshOptions refreshOptions, IDirectoryService directoryService)
2014-10-11 13:38:13 -07:00
{
2015-10-30 08:23:06 -07:00
_hasChildren = null;
return base.ValidateChildrenInternal(progress, cancellationToken, recursive, refreshChildMetadata, refreshOptions, directoryService);
2014-10-11 13:38:13 -07:00
}
2015-11-14 09:58:01 -07:00
[IgnoreDataMember]
public bool EnableUserSpecificView
{
get { return true; }
}
2014-10-11 13:38:13 -07:00
}
}