CameraUploadsFolder.cs 2.0 KB

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