CloudSyncProvider.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using MediaBrowser.Common;
  2. using MediaBrowser.Controller.Sync;
  3. using MediaBrowser.Model.Dlna;
  4. using MediaBrowser.Model.Sync;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.IO;
  8. using System.Linq;
  9. using System.Threading;
  10. using System.Threading.Tasks;
  11. namespace MediaBrowser.Server.Implementations.Sync
  12. {
  13. public class CloudSyncProvider : IServerSyncProvider
  14. {
  15. private readonly ICloudSyncProvider[] _providers = {};
  16. public CloudSyncProvider(IApplicationHost appHost)
  17. {
  18. _providers = appHost.GetExports<ICloudSyncProvider>().ToArray();
  19. }
  20. public IEnumerable<SyncTarget> GetSyncTargets(string userId)
  21. {
  22. return _providers.SelectMany(i => i.GetSyncTargets(userId));
  23. }
  24. public DeviceProfile GetDeviceProfile(SyncTarget target)
  25. {
  26. return new DeviceProfile();
  27. }
  28. public string Name
  29. {
  30. get { return "Cloud Sync"; }
  31. }
  32. private ICloudSyncProvider GetProvider(SyncTarget target)
  33. {
  34. return null;
  35. }
  36. public Task SendFile(string inputFile, string[] pathParts, SyncTarget target, IProgress<double> progress, CancellationToken cancellationToken)
  37. {
  38. var provider = GetProvider(target);
  39. return provider.SendFile(inputFile, pathParts, target, progress, cancellationToken);
  40. }
  41. public Task<Stream> GetFile(string[] pathParts, SyncTarget target, IProgress<double> progress, CancellationToken cancellationToken)
  42. {
  43. var provider = GetProvider(target);
  44. return provider.GetFile(pathParts, target, progress, cancellationToken);
  45. }
  46. }
  47. }