aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Implementations/Sync/AppSyncProvider.cs
blob: 6cc5be9555f7913c759e32d9dcf83ba4823c5392 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using MediaBrowser.Controller.Devices;
using MediaBrowser.Controller.Sync;
using MediaBrowser.Model.Devices;
using MediaBrowser.Model.Dlna;
using MediaBrowser.Model.Sync;
using System.Collections.Generic;
using System.Linq;

namespace MediaBrowser.Server.Implementations.Sync
{
    public class AppSyncProvider : ISyncProvider, IHasUniqueTargetIds
    {
        private readonly IDeviceManager _deviceManager;

        public AppSyncProvider(IDeviceManager deviceManager)
        {
            _deviceManager = deviceManager;
        }

        public IEnumerable<SyncTarget> GetSyncTargets()
        {
            return _deviceManager.GetDevices(new DeviceQuery
            {
                SupportsSync = true

            }).Items.Select(i => new SyncTarget
            {
                Id = i.Id,
                Name = i.Name
            });
        }

        public IEnumerable<SyncTarget> GetSyncTargets(string userId)
        {
            return _deviceManager.GetDevices(new DeviceQuery
            {
                SupportsSync = true,
                UserId = userId

            }).Items.Select(i => new SyncTarget
            {
                Id = i.Id,
                Name = i.Name
            });
        }

        public DeviceProfile GetDeviceProfile(SyncTarget target)
        {
            var caps = _deviceManager.GetCapabilities(target.Id);

            return caps == null || caps.DeviceProfile == null ? new DeviceProfile() : caps.DeviceProfile;
        }

        public string Name
        {
            get { return "App Sync"; }
        }
    }
}