CameraUploadsFolder.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. using System;
  2. using System.Linq;
  3. using System.Threading;
  4. using System.Threading.Tasks;
  5. using MediaBrowser.Controller.Entities;
  6. using MediaBrowser.Controller.Providers;
  7. using MediaBrowser.Model.Serialization;
  8. namespace Emby.Server.Implementations.Devices
  9. {
  10. public class CameraUploadsFolder : BasePluginFolder, ISupportsUserSpecificView
  11. {
  12. public CameraUploadsFolder()
  13. {
  14. Name = "Camera Uploads";
  15. }
  16. public override bool IsVisible(User user)
  17. {
  18. if (!user.Policy.EnableAllFolders && !user.Policy.EnabledFolders.Contains(Id.ToString("N"), StringComparer.OrdinalIgnoreCase))
  19. {
  20. return false;
  21. }
  22. return base.IsVisible(user) && HasChildren();
  23. }
  24. [IgnoreDataMember]
  25. public override string CollectionType
  26. {
  27. get { return MediaBrowser.Model.Entities.CollectionType.Photos; }
  28. }
  29. [IgnoreDataMember]
  30. public override bool SupportsInheritedParentImages
  31. {
  32. get
  33. {
  34. return false;
  35. }
  36. }
  37. public override string GetClientTypeName()
  38. {
  39. return typeof(CollectionFolder).Name;
  40. }
  41. private bool? _hasChildren;
  42. private bool HasChildren()
  43. {
  44. if (!_hasChildren.HasValue)
  45. {
  46. _hasChildren = LibraryManager.GetItemIds(new InternalItemsQuery { Parent = this }).Count > 0;
  47. }
  48. return _hasChildren.Value;
  49. }
  50. protected override Task ValidateChildrenInternal(IProgress<double> progress, CancellationToken cancellationToken, bool recursive, bool refreshChildMetadata, MetadataRefreshOptions refreshOptions, IDirectoryService directoryService)
  51. {
  52. _hasChildren = null;
  53. return base.ValidateChildrenInternal(progress, cancellationToken, recursive, refreshChildMetadata, refreshOptions, directoryService);
  54. }
  55. [IgnoreDataMember]
  56. public bool EnableUserSpecificView
  57. {
  58. get { return true; }
  59. }
  60. }
  61. }