2014-12-15 05:49:04 +00:00
|
|
|
|
using MediaBrowser.Controller.Devices;
|
|
|
|
|
using MediaBrowser.Controller.Sync;
|
|
|
|
|
using MediaBrowser.Model.Devices;
|
2014-07-22 01:29:06 +00:00
|
|
|
|
using MediaBrowser.Model.Dlna;
|
|
|
|
|
using MediaBrowser.Model.Sync;
|
|
|
|
|
using System.Collections.Generic;
|
2014-12-15 05:49:04 +00:00
|
|
|
|
using System.Linq;
|
2014-07-22 01:29:06 +00:00
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Server.Implementations.Sync
|
|
|
|
|
{
|
2014-12-24 06:28:40 +00:00
|
|
|
|
public class AppSyncProvider : ISyncProvider, IHasUniqueTargetIds
|
2014-07-22 01:29:06 +00:00
|
|
|
|
{
|
2014-12-15 05:49:04 +00:00
|
|
|
|
private readonly IDeviceManager _deviceManager;
|
|
|
|
|
|
|
|
|
|
public AppSyncProvider(IDeviceManager deviceManager)
|
|
|
|
|
{
|
|
|
|
|
_deviceManager = deviceManager;
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-22 01:29:06 +00:00
|
|
|
|
public IEnumerable<SyncTarget> GetSyncTargets()
|
|
|
|
|
{
|
2014-12-15 05:49:04 +00:00
|
|
|
|
return _deviceManager.GetDevices(new DeviceQuery
|
|
|
|
|
{
|
|
|
|
|
SupportsSync = true
|
|
|
|
|
|
|
|
|
|
}).Items.Select(i => new SyncTarget
|
|
|
|
|
{
|
|
|
|
|
Id = i.Id,
|
|
|
|
|
Name = i.Name
|
|
|
|
|
});
|
2014-07-22 01:29:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-31 06:24:49 +00:00
|
|
|
|
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
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-22 01:29:06 +00:00
|
|
|
|
public DeviceProfile GetDeviceProfile(SyncTarget target)
|
|
|
|
|
{
|
2015-01-02 05:36:27 +00:00
|
|
|
|
var caps = _deviceManager.GetCapabilities(target.Id);
|
|
|
|
|
|
|
|
|
|
return caps == null || caps.DeviceProfile == null ? new DeviceProfile() : caps.DeviceProfile;
|
2014-07-22 01:29:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string Name
|
|
|
|
|
{
|
|
|
|
|
get { return "App Sync"; }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|