sync updates

This commit is contained in:
Luke Pulverenti 2015-01-20 00:19:13 -05:00
parent 4ea72584db
commit 1d5f1bc474
22 changed files with 146 additions and 74 deletions

View File

@ -39,8 +39,8 @@ namespace MediaBrowser.Api
[ApiMember(Name = "SendingUserId", Description = "Sending User Id", IsRequired = true, DataType = "string", ParameterType = "body", Verb = "POST")]
public string SendingUserId { get; set; }
[ApiMember(Name = "ExcludeLibraries", Description = "ExcludeLibraries", IsRequired = true, DataType = "string", ParameterType = "body", Verb = "POST")]
public string ExcludedLibraries { get; set; }
[ApiMember(Name = "EnabledLibraries", Description = "EnabledLibraries", IsRequired = true, DataType = "string", ParameterType = "body", Verb = "POST")]
public string EnabledLibraries { get; set; }
[ApiMember(Name = "EnabledChannels", Description = "EnabledChannels", IsRequired = true, DataType = "string", ParameterType = "body", Verb = "POST")]
public string EnabledChannels { get; set; }
@ -91,7 +91,7 @@ namespace MediaBrowser.Api
public object Post(CreateConnectInvite request)
{
var excludeLibraries = (request.ExcludedLibraries ?? string.Empty)
var enabledLibraries = (request.EnabledLibraries ?? string.Empty)
.Split(',')
.Where(i => !string.IsNullOrWhiteSpace(i))
.ToArray();
@ -105,7 +105,7 @@ namespace MediaBrowser.Api
{
ConnectUserName = request.ConnectUsername,
SendingUserId = request.SendingUserId,
ExcludedLibraries = excludeLibraries,
EnabledLibraries = enabledLibraries,
EnabledChannels = enabledChannels,
EnableLiveTv = request.EnableLiveTv
});

View File

@ -1,4 +1,5 @@
using MediaBrowser.Model.Extensions;
using MediaBrowser.Controller.Devices;
using MediaBrowser.Model.Extensions;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.IO;
using MediaBrowser.Controller.Channels;
@ -66,14 +67,16 @@ namespace MediaBrowser.Api.Playback
protected ILiveTvManager LiveTvManager { get; private set; }
protected IDlnaManager DlnaManager { get; private set; }
protected IDeviceManager DeviceManager { get; private set; }
protected IChannelManager ChannelManager { get; private set; }
protected ISubtitleEncoder SubtitleEncoder { get; private set; }
/// <summary>
/// Initializes a new instance of the <see cref="BaseStreamingService" /> class.
/// </summary>
protected BaseStreamingService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IFileSystem fileSystem, ILiveTvManager liveTvManager, IDlnaManager dlnaManager, IChannelManager channelManager, ISubtitleEncoder subtitleEncoder)
protected BaseStreamingService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IFileSystem fileSystem, ILiveTvManager liveTvManager, IDlnaManager dlnaManager, IChannelManager channelManager, ISubtitleEncoder subtitleEncoder, IDeviceManager deviceManager)
{
DeviceManager = deviceManager;
SubtitleEncoder = subtitleEncoder;
ChannelManager = channelManager;
DlnaManager = dlnaManager;
@ -2030,9 +2033,26 @@ namespace MediaBrowser.Api.Playback
headers[key] = Request.Headers[key];
}
state.DeviceProfile = string.IsNullOrWhiteSpace(state.Request.DeviceProfileId) ?
DlnaManager.GetProfile(headers) :
DlnaManager.GetProfile(state.Request.DeviceProfileId);
if (!string.IsNullOrWhiteSpace(state.Request.DeviceProfileId))
{
state.DeviceProfile = DlnaManager.GetProfile(state.Request.DeviceProfileId);
}
else
{
if (!string.IsNullOrWhiteSpace(state.Request.DeviceId))
{
var caps = DeviceManager.GetCapabilities(state.Request.DeviceId);
if (caps != null)
{
state.DeviceProfile = caps.DeviceProfile;
}
else
{
state.DeviceProfile = DlnaManager.GetProfile(headers);
}
}
}
var profile = state.DeviceProfile;

View File

@ -1,20 +1,20 @@
using MediaBrowser.Model.Extensions;
using MediaBrowser.Common.IO;
using MediaBrowser.Common.Net;
using MediaBrowser.Common.IO;
using MediaBrowser.Controller.Channels;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Devices;
using MediaBrowser.Controller.Dlna;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.LiveTv;
using MediaBrowser.Controller.MediaEncoding;
using MediaBrowser.Model.Extensions;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.Net;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Model.Net;
namespace MediaBrowser.Api.Playback.Hls
{
@ -23,8 +23,7 @@ namespace MediaBrowser.Api.Playback.Hls
/// </summary>
public abstract class BaseHlsService : BaseStreamingService
{
protected BaseHlsService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IFileSystem fileSystem, ILiveTvManager liveTvManager, IDlnaManager dlnaManager, IChannelManager channelManager, ISubtitleEncoder subtitleEncoder)
: base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, fileSystem, liveTvManager, dlnaManager, channelManager, subtitleEncoder)
protected BaseHlsService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IFileSystem fileSystem, ILiveTvManager liveTvManager, IDlnaManager dlnaManager, IChannelManager channelManager, ISubtitleEncoder subtitleEncoder, IDeviceManager deviceManager) : base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, fileSystem, liveTvManager, dlnaManager, channelManager, subtitleEncoder, deviceManager)
{
}

View File

@ -1,4 +1,5 @@
using MediaBrowser.Model.Extensions;
using MediaBrowser.Controller.Devices;
using MediaBrowser.Model.Extensions;
using MediaBrowser.Common.IO;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Channels;
@ -62,38 +63,31 @@ namespace MediaBrowser.Api.Playback.Hls
public class DynamicHlsService : BaseHlsService
{
protected INetworkManager NetworkManager { get; private set; }
public DynamicHlsService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IFileSystem fileSystem, ILiveTvManager liveTvManager, IDlnaManager dlnaManager, IChannelManager channelManager, ISubtitleEncoder subtitleEncoder, INetworkManager networkManager)
: base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, fileSystem, liveTvManager, dlnaManager, channelManager, subtitleEncoder)
public DynamicHlsService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IFileSystem fileSystem, ILiveTvManager liveTvManager, IDlnaManager dlnaManager, IChannelManager channelManager, ISubtitleEncoder subtitleEncoder, IDeviceManager deviceManager, INetworkManager networkManager) : base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, fileSystem, liveTvManager, dlnaManager, channelManager, subtitleEncoder, deviceManager)
{
NetworkManager = networkManager;
}
public object Get(GetMasterHlsVideoStream request)
{
var result = GetAsync(request, "GET").Result;
protected INetworkManager NetworkManager { get; private set; }
return result;
public Task<object> Get(GetMasterHlsVideoStream request)
{
return GetAsync(request, "GET");
}
public object Head(GetMasterHlsVideoStream request)
public Task<object> Head(GetMasterHlsVideoStream request)
{
var result = GetAsync(request, "HEAD").Result;
return result;
return GetAsync(request, "HEAD");
}
public object Get(GetMainHlsVideoStream request)
public Task<object> Get(GetMainHlsVideoStream request)
{
var result = GetPlaylistAsync(request, "main").Result;
return result;
return GetPlaylistAsync(request, "main");
}
public object Get(GetDynamicHlsVideoSegment request)
public Task<object> Get(GetDynamicHlsVideoSegment request)
{
return GetDynamicSegment(request, request.SegmentId).Result;
return GetDynamicSegment(request, request.SegmentId);
}
private async Task<object> GetDynamicSegment(VideoStreamRequest request, string segmentId)

View File

@ -2,6 +2,7 @@
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Channels;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Devices;
using MediaBrowser.Controller.Dlna;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.LiveTv;
@ -50,14 +51,13 @@ namespace MediaBrowser.Api.Playback.Hls
public class MpegDashService : BaseHlsService
{
protected INetworkManager NetworkManager { get; private set; }
public MpegDashService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IFileSystem fileSystem, ILiveTvManager liveTvManager, IDlnaManager dlnaManager, IChannelManager channelManager, ISubtitleEncoder subtitleEncoder, INetworkManager networkManager)
: base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, fileSystem, liveTvManager, dlnaManager, channelManager, subtitleEncoder)
public MpegDashService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IFileSystem fileSystem, ILiveTvManager liveTvManager, IDlnaManager dlnaManager, IChannelManager channelManager, ISubtitleEncoder subtitleEncoder, IDeviceManager deviceManager, INetworkManager networkManager) : base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, fileSystem, liveTvManager, dlnaManager, channelManager, subtitleEncoder, deviceManager)
{
NetworkManager = networkManager;
}
protected INetworkManager NetworkManager { get; private set; }
public object Get(GetMasterManifest request)
{
var result = GetAsync(request, "GET").Result;

View File

@ -1,6 +1,7 @@
using MediaBrowser.Common.IO;
using MediaBrowser.Controller.Channels;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Devices;
using MediaBrowser.Controller.Dlna;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.LiveTv;
@ -56,8 +57,7 @@ namespace MediaBrowser.Api.Playback.Hls
/// </summary>
public class VideoHlsService : BaseHlsService
{
public VideoHlsService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IFileSystem fileSystem, ILiveTvManager liveTvManager, IDlnaManager dlnaManager, IChannelManager channelManager, ISubtitleEncoder subtitleEncoder)
: base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, fileSystem, liveTvManager, dlnaManager, channelManager, subtitleEncoder)
public VideoHlsService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IFileSystem fileSystem, ILiveTvManager liveTvManager, IDlnaManager dlnaManager, IChannelManager channelManager, ISubtitleEncoder subtitleEncoder, IDeviceManager deviceManager) : base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, fileSystem, liveTvManager, dlnaManager, channelManager, subtitleEncoder, deviceManager)
{
}

View File

@ -2,6 +2,7 @@
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Channels;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Devices;
using MediaBrowser.Controller.Dlna;
using MediaBrowser.Controller.Drawing;
using MediaBrowser.Controller.Library;
@ -31,7 +32,7 @@ namespace MediaBrowser.Api.Playback.Progressive
/// </summary>
public class AudioService : BaseProgressiveStreamingService
{
public AudioService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IFileSystem fileSystem, ILiveTvManager liveTvManager, IDlnaManager dlnaManager, IChannelManager channelManager, ISubtitleEncoder subtitleEncoder, IImageProcessor imageProcessor, IHttpClient httpClient) : base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, fileSystem, liveTvManager, dlnaManager, channelManager, subtitleEncoder, imageProcessor, httpClient)
public AudioService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IFileSystem fileSystem, ILiveTvManager liveTvManager, IDlnaManager dlnaManager, IChannelManager channelManager, ISubtitleEncoder subtitleEncoder, IDeviceManager deviceManager, IImageProcessor imageProcessor, IHttpClient httpClient) : base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, fileSystem, liveTvManager, dlnaManager, channelManager, subtitleEncoder, deviceManager, imageProcessor, httpClient)
{
}

View File

@ -1,8 +1,8 @@
using System.Linq;
using MediaBrowser.Common.IO;
using MediaBrowser.Common.IO;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Channels;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Devices;
using MediaBrowser.Controller.Dlna;
using MediaBrowser.Controller.Drawing;
using MediaBrowser.Controller.Library;
@ -15,6 +15,7 @@ using ServiceStack.Web;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
@ -28,8 +29,7 @@ namespace MediaBrowser.Api.Playback.Progressive
protected readonly IImageProcessor ImageProcessor;
protected readonly IHttpClient HttpClient;
protected BaseProgressiveStreamingService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IFileSystem fileSystem, ILiveTvManager liveTvManager, IDlnaManager dlnaManager, IChannelManager channelManager, ISubtitleEncoder subtitleEncoder, IImageProcessor imageProcessor, IHttpClient httpClient)
: base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, fileSystem, liveTvManager, dlnaManager, channelManager, subtitleEncoder)
protected BaseProgressiveStreamingService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IFileSystem fileSystem, ILiveTvManager liveTvManager, IDlnaManager dlnaManager, IChannelManager channelManager, ISubtitleEncoder subtitleEncoder, IDeviceManager deviceManager, IImageProcessor imageProcessor, IHttpClient httpClient) : base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, fileSystem, liveTvManager, dlnaManager, channelManager, subtitleEncoder, deviceManager)
{
ImageProcessor = imageProcessor;
HttpClient = httpClient;

View File

@ -2,6 +2,7 @@ using MediaBrowser.Common.IO;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Channels;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Devices;
using MediaBrowser.Controller.Dlna;
using MediaBrowser.Controller.Drawing;
using MediaBrowser.Controller.Library;
@ -62,7 +63,7 @@ namespace MediaBrowser.Api.Playback.Progressive
/// </summary>
public class VideoService : BaseProgressiveStreamingService
{
public VideoService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IFileSystem fileSystem, ILiveTvManager liveTvManager, IDlnaManager dlnaManager, IChannelManager channelManager, ISubtitleEncoder subtitleEncoder, IImageProcessor imageProcessor, IHttpClient httpClient) : base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, fileSystem, liveTvManager, dlnaManager, channelManager, subtitleEncoder, imageProcessor, httpClient)
public VideoService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IFileSystem fileSystem, ILiveTvManager liveTvManager, IDlnaManager dlnaManager, IChannelManager channelManager, ISubtitleEncoder subtitleEncoder, IDeviceManager deviceManager, IImageProcessor imageProcessor, IHttpClient httpClient) : base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, fileSystem, liveTvManager, dlnaManager, channelManager, subtitleEncoder, deviceManager, imageProcessor, httpClient)
{
}

View File

@ -243,12 +243,12 @@ namespace MediaBrowser.Api.Session
[ApiMember(Name = "SupportsSync", Description = "Determines whether sync is supported.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "POST")]
public bool SupportsSync { get; set; }
[ApiMember(Name = "SupportsUniqueIdentifier", Description = "Determines whether the device supports a unique identifier.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "POST")]
public bool SupportsUniqueIdentifier { get; set; }
[ApiMember(Name = "SupportsPersistentIdentifier", Description = "Determines whether the device supports a unique identifier.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "POST")]
public bool SupportsPersistentIdentifier { get; set; }
public PostCapabilities()
{
SupportsUniqueIdentifier = true;
SupportsPersistentIdentifier = true;
}
}
@ -561,7 +561,7 @@ namespace MediaBrowser.Api.Session
SupportsSync = request.SupportsSync,
SupportsUniqueIdentifier = request.SupportsUniqueIdentifier
SupportsPersistentIdentifier = request.SupportsPersistentIdentifier
});
}

View File

@ -303,10 +303,7 @@ namespace MediaBrowser.Controller.Entities
{
if (this is ICollectionFolder)
{
if (user.Policy.BlockedMediaFolders.Contains(Id.ToString("N"), StringComparer.OrdinalIgnoreCase) ||
// Backwards compatibility
user.Policy.BlockedMediaFolders.Contains(Name, StringComparer.OrdinalIgnoreCase))
if (!user.Policy.EnableAllFolders && !user.Policy.EnabledFolders.Contains(Id.ToString("N"), StringComparer.OrdinalIgnoreCase))
{
return false;
}

View File

@ -7,13 +7,13 @@ namespace MediaBrowser.Model.Connect
public string UserName { get; set; }
public string ImageUrl { get; set; }
public string Id { get; set; }
public string[] ExcludedLibraries { get; set; }
public string[] EnabledLibraries { get; set; }
public bool EnableLiveTv { get; set; }
public string[] EnabledChannels { get; set; }
public ConnectAuthorization()
{
ExcludedLibraries = new string[] { };
EnabledLibraries = new string[] { };
EnabledChannels = new string[] { };
}
}

View File

@ -5,13 +5,13 @@ namespace MediaBrowser.Model.Connect
{
public string SendingUserId { get; set; }
public string ConnectUserName { get; set; }
public string[] ExcludedLibraries { get; set; }
public string[] EnabledLibraries { get; set; }
public bool EnableLiveTv { get; set; }
public string[] EnabledChannels { get; set; }
public ConnectAuthorizationRequest()
{
ExcludedLibraries = new string[] { };
EnabledLibraries = new string[] { };
EnabledChannels = new string[] { };
}
}

View File

@ -12,7 +12,7 @@ namespace MediaBrowser.Model.Devices
/// Gets or sets a value indicating whether [supports unique identifier].
/// </summary>
/// <value><c>null</c> if [supports unique identifier] contains no value, <c>true</c> if [supports unique identifier]; otherwise, <c>false</c>.</value>
public bool? SupportsUniqueIdentifier { get; set; }
public bool? SupportsPersistentIdentifier { get; set; }
/// <summary>
/// Gets or sets a value indicating whether [supports synchronize].
/// </summary>

View File

@ -14,16 +14,21 @@ namespace MediaBrowser.Model.Session
public string MessageCallbackUrl { get; set; }
public bool SupportsContentUploading { get; set; }
public bool SupportsUniqueIdentifier { get; set; }
public bool SupportsPersistentIdentifier { get; set; }
public bool SupportsSync { get; set; }
public DeviceProfile DeviceProfile { get; set; }
/// <summary>
/// Usage should be migrated to SupportsPersistentIdentifier. Keeping this to preserve data.
/// </summary>
public bool? SupportsUniqueIdentifier { get; set; }
public ClientCapabilities()
{
PlayableMediaTypes = new List<string>();
SupportedCommands = new List<string>();
SupportsUniqueIdentifier = true;
SupportsPersistentIdentifier = true;
}
}
}

View File

@ -54,6 +54,9 @@ namespace MediaBrowser.Model.Users
public string[] EnabledChannels { get; set; }
public bool EnableAllChannels { get; set; }
public string[] EnabledFolders { get; set; }
public bool EnableAllFolders { get; set; }
public UserPolicy()
{
@ -62,9 +65,6 @@ namespace MediaBrowser.Model.Users
EnableLiveTvAccess = true;
EnableSharedDeviceControl = true;
EnabledChannels = new string[] { };
BlockedMediaFolders = new string[] { };
BlockedTags = new string[] { };
BlockUnratedItems = new UnratedItem[] { };
@ -72,6 +72,12 @@ namespace MediaBrowser.Model.Users
AccessSchedules = new AccessSchedule[] { };
EnableAllChannels = true;
EnabledChannels = new string[] { };
EnableAllFolders = true;
EnabledFolders = new string[] { };
EnabledDevices = new string[] { };
EnableAllDevices = true;
}

View File

@ -572,7 +572,7 @@ namespace MediaBrowser.Server.Implementations.Connect
Id = response.Id,
ImageUrl = response.UserImageUrl,
UserName = response.UserName,
ExcludedLibraries = request.ExcludedLibraries,
EnabledLibraries = request.EnabledLibraries,
EnabledChannels = request.EnabledChannels,
EnableLiveTv = request.EnableLiveTv,
AccessToken = accessToken
@ -833,10 +833,13 @@ namespace MediaBrowser.Server.Implementations.Connect
if (currentPendingEntry != null)
{
user.Policy.EnableLiveTvAccess = currentPendingEntry.EnableLiveTv;
user.Policy.BlockedMediaFolders = currentPendingEntry.ExcludedLibraries;
user.Policy.EnabledFolders = currentPendingEntry.EnabledLibraries;
user.Policy.EnableAllFolders = false;
user.Policy.EnabledChannels = currentPendingEntry.EnabledChannels;
user.Policy.EnableAllChannels = false;
user.Policy.EnableLiveTvAccess = currentPendingEntry.EnableLiveTv;
}
await _userManager.UpdateConfiguration(user.Id.ToString("N"), user.Configuration);
@ -964,7 +967,7 @@ namespace MediaBrowser.Server.Implementations.Connect
ConnectUserId = i.ConnectUserId,
EnableLiveTv = i.EnableLiveTv,
EnabledChannels = i.EnabledChannels,
ExcludedLibraries = i.ExcludedLibraries,
EnabledLibraries = i.EnabledLibraries,
Id = i.Id,
ImageUrl = i.ImageUrl,
UserName = i.UserName

View File

@ -100,11 +100,16 @@ namespace MediaBrowser.Server.Implementations.Devices
devices = devices.Where(i => GetCapabilities(i.Id).SupportsSync == val);
}
if (query.SupportsUniqueIdentifier.HasValue)
if (query.SupportsPersistentIdentifier.HasValue)
{
var val = query.SupportsUniqueIdentifier.Value;
var val = query.SupportsPersistentIdentifier.Value;
devices = devices.Where(i => GetCapabilities(i.Id).SupportsUniqueIdentifier == val);
devices = devices.Where(i =>
{
var caps = GetCapabilities(i.Id);
var deviceVal = caps.SupportsUniqueIdentifier ?? caps.SupportsPersistentIdentifier;
return deviceVal == val;
});
}
if (!string.IsNullOrWhiteSpace(query.UserId))
@ -212,7 +217,7 @@ namespace MediaBrowser.Server.Implementations.Devices
{
var capabilities = GetCapabilities(deviceId);
if (capabilities.SupportsUniqueIdentifier)
if (capabilities != null && capabilities.SupportsPersistentIdentifier)
{
return false;
}

View File

@ -73,10 +73,11 @@ namespace MediaBrowser.Server.Implementations.Library
private readonly Func<IDtoService> _dtoServiceFactory;
private readonly Func<IConnectManager> _connectFactory;
private readonly Func<IChannelManager> _channelManager;
private readonly Func<ILibraryManager> _libraryManager;
private readonly IServerApplicationHost _appHost;
private readonly IFileSystem _fileSystem;
public UserManager(ILogger logger, IServerConfigurationManager configurationManager, IUserRepository userRepository, IXmlSerializer xmlSerializer, INetworkManager networkManager, Func<IImageProcessor> imageProcessorFactory, Func<IDtoService> dtoServiceFactory, Func<IConnectManager> connectFactory, IServerApplicationHost appHost, IJsonSerializer jsonSerializer, IFileSystem fileSystem, Func<IChannelManager> channelManager)
public UserManager(ILogger logger, IServerConfigurationManager configurationManager, IUserRepository userRepository, IXmlSerializer xmlSerializer, INetworkManager networkManager, Func<IImageProcessor> imageProcessorFactory, Func<IDtoService> dtoServiceFactory, Func<IConnectManager> connectFactory, IServerApplicationHost appHost, IJsonSerializer jsonSerializer, IFileSystem fileSystem, Func<IChannelManager> channelManager, Func<ILibraryManager> libraryManager)
{
_logger = logger;
UserRepository = userRepository;
@ -89,6 +90,7 @@ namespace MediaBrowser.Server.Implementations.Library
_jsonSerializer = jsonSerializer;
_fileSystem = fileSystem;
_channelManager = channelManager;
_libraryManager = libraryManager;
ConfigurationManager = configurationManager;
Users = new List<User>();
@ -173,6 +175,7 @@ namespace MediaBrowser.Server.Implementations.Library
{
await DoPolicyMigration(user).ConfigureAwait(false);
await DoChannelMigration(user).ConfigureAwait(false);
await DoLibraryMigration(user).ConfigureAwait(false);
}
// If there are no local users with admin rights, make them all admins
@ -389,6 +392,39 @@ namespace MediaBrowser.Server.Implementations.Library
}
}
private async Task DoLibraryMigration(User user)
{
if (user.Policy.BlockedMediaFolders != null)
{
if (user.Policy.BlockedMediaFolders.Length > 0)
{
user.Policy.EnableAllFolders = false;
try
{
user.Policy.EnabledFolders = _libraryManager().RootFolder
.Children
.Where(i => !user.Policy.BlockedMediaFolders.Contains(i.Name, StringComparer.OrdinalIgnoreCase) && !user.Policy.BlockedMediaFolders.Contains(i.Id.ToString("N"), StringComparer.OrdinalIgnoreCase))
.Select(i => i.Id.ToString("N"))
.ToArray();
}
catch
{
user.Policy.EnabledFolders = new string[] { };
}
}
else
{
user.Policy.EnableAllFolders = true;
user.Policy.EnabledFolders = new string[] { };
}
user.Policy.BlockedMediaFolders = null;
await UpdateUserPolicy(user, user.Policy, false);
}
}
public UserDto GetUserDto(User user, string remoteEndPoint = null)
{
if (user == null)

View File

@ -6,6 +6,8 @@
"Administrator": "Administrator",
"Password": "Password",
"DeleteImage": "Delete Image",
"MessageThankYouForSupporting": "Thank you for supporting Media Browser.",
"MessagePleaseSupportMediaBrowser": "Please support Media Browser.",
"DeleteImageConfirmation": "Are you sure you wish to delete this image?",
"FileReadCancelled": "The file read has been canceled.",
"FileNotFound": "File not found.",
@ -219,6 +221,7 @@
"ButtonResume": "Resume",
"HeaderScenes": "Scenes",
"HeaderAudioTracks": "Audio Tracks",
"HeaderLibraries": "Libraries",
"LabelUnknownLanguage": "Unknown language",
"HeaderSubtitles": "Subtitles",
"HeaderVideoQuality": "Video Quality",

View File

@ -79,6 +79,7 @@
"ReferToMediaLibraryWiki": "Refer to the media library wiki.",
"LabelCountry": "Country:",
"LabelLanguage": "Language:",
"ButtonJoinTheDevelopmentTeam": "Join the Development Team",
"HeaderPreferredMetadataLanguage": "Preferred metadata language:",
"LabelSaveLocalMetadata": "Save artwork and metadata into media folders",
"LabelSaveLocalMetadataHelp": "Saving artwork and metadata directly into media folders will put them in a place where they can be easily edited.",
@ -97,6 +98,7 @@
"HeaderDeviceAccess": "Device Access",
"OptionEnableAccessFromAllDevices": "Enable access from all devices",
"OptionEnableAccessToAllChannels": "Enable access to all channels",
"OptionEnableAccessToAllLibraries": "Enable access to all libraries",
"DeviceAccessHelp": "This only applies to devices that can be uniquely identified and will not prevent browser access. Filtering user device access will prevent them from using new devices until they've been approved here.",
"LabelDisplayMissingEpisodesWithinSeasons": "Display missing episodes within seasons",
"LabelUnairedMissingEpisodesWithinSeasons": "Display unaired episodes within seasons",

View File

@ -407,7 +407,7 @@ namespace MediaBrowser.Server.Startup.Common
SyncRepository = await GetSyncRepository().ConfigureAwait(false);
RegisterSingleInstance(SyncRepository);
UserManager = new UserManager(LogManager.GetLogger("UserManager"), ServerConfigurationManager, UserRepository, XmlSerializer, NetworkManager, () => ImageProcessor, () => DtoService, () => ConnectManager, this, JsonSerializer, FileSystemManager, () => ChannelManager);
UserManager = new UserManager(LogManager.GetLogger("UserManager"), ServerConfigurationManager, UserRepository, XmlSerializer, NetworkManager, () => ImageProcessor, () => DtoService, () => ConnectManager, this, JsonSerializer, FileSystemManager, () => ChannelManager, () => LibraryManager);
RegisterSingleInstance(UserManager);
LibraryManager = new LibraryManager(Logger, TaskManager, UserManager, ServerConfigurationManager, UserDataManager, () => LibraryMonitor, FileSystemManager, () => ProviderManager);