CameraUploadsFolder.cs 2.1 KB

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