sync update

pull/702/head
Luke Pulverenti 10 years ago
parent 975f6899fe
commit 76584ed984

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

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

@ -42,5 +42,18 @@ namespace MediaBrowser.Server.Implementations.Sync
{ {
get { return "App 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
});
}
} }
} }

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

Loading…
Cancel
Save