sync update

This commit is contained in:
Luke Pulverenti 2015-02-28 09:35:12 -05:00
parent 975f6899fe
commit 76584ed984
4 changed files with 30 additions and 9 deletions

View File

@ -68,11 +68,5 @@ namespace MediaBrowser.Controller.Sync
/// </summary>
/// <returns>ISyncDataProvider.</returns>
ISyncDataProvider GetDataProvider();
/// <summary>
/// Gets all synchronize targets.
/// </summary>
/// <returns>IEnumerable&lt;SyncTarget&gt;.</returns>
IEnumerable<SyncTarget> GetAllSyncTargets();
}
}

View File

@ -1,5 +1,4 @@
using MediaBrowser.Model.Dlna;
using MediaBrowser.Model.Sync;
using MediaBrowser.Model.Sync;
using System.Collections.Generic;
namespace MediaBrowser.Controller.Sync
@ -18,6 +17,12 @@ namespace MediaBrowser.Controller.Sync
/// <param name="userId">The user identifier.</param>
/// <returns>IEnumerable&lt;SyncTarget&gt;.</returns>
IEnumerable<SyncTarget> GetSyncTargets(string userId);
/// <summary>
/// Gets all synchronize targets.
/// </summary>
/// <returns>IEnumerable&lt;SyncTarget&gt;.</returns>
IEnumerable<SyncTarget> GetAllSyncTargets();
}
public interface IHasUniqueTargetIds

View File

@ -42,5 +42,18 @@ namespace MediaBrowser.Server.Implementations.Sync
{
get { return "App Sync"; }
}
public IEnumerable<SyncTarget> GetAllSyncTargets()
{
return _deviceManager.GetDevices(new DeviceQuery
{
SupportsSync = true
}).Items.Select(i => new SyncTarget
{
Id = i.Id,
Name = i.Name
});
}
}
}

View File

@ -407,6 +407,15 @@ namespace MediaBrowser.Server.Implementations.Sync
.OrderBy(i => i.Name);
}
private IEnumerable<SyncTarget> GetSyncTargets(ISyncProvider provider)
{
return provider.GetAllSyncTargets().Select(i => new SyncTarget
{
Name = i.Name,
Id = GetSyncTargetId(provider, i)
});
}
private IEnumerable<SyncTarget> GetSyncTargets(ISyncProvider provider, string userId)
{
return provider.GetSyncTargets(userId).Select(i => new SyncTarget
@ -536,7 +545,7 @@ namespace MediaBrowser.Server.Implementations.Sync
{
foreach (var provider in _providers)
{
foreach (var target in GetSyncTargets(provider, null))
foreach (var target in GetSyncTargets(provider))
{
if (string.Equals(target.Id, targetId, StringComparison.OrdinalIgnoreCase))
{