diff options
Diffstat (limited to 'MediaBrowser.Server.Implementations/Devices/DeviceManager.cs')
| -rw-r--r-- | MediaBrowser.Server.Implementations/Devices/DeviceManager.cs | 38 |
1 files changed, 31 insertions, 7 deletions
diff --git a/MediaBrowser.Server.Implementations/Devices/DeviceManager.cs b/MediaBrowser.Server.Implementations/Devices/DeviceManager.cs index ddd5ef58d..3211f88d5 100644 --- a/MediaBrowser.Server.Implementations/Devices/DeviceManager.cs +++ b/MediaBrowser.Server.Implementations/Devices/DeviceManager.cs @@ -27,6 +27,8 @@ namespace MediaBrowser.Server.Implementations.Devices private readonly IConfigurationManager _config; private readonly ILogger _logger; + public event EventHandler<GenericEventArgs<CameraImageUploadInfo>> CameraImageUploaded; + /// <summary> /// Occurs when [device options updated]. /// </summary> @@ -100,18 +102,23 @@ 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)) { devices = devices.Where(i => CanAccessDevice(query.UserId, i.Id)); } - + var array = devices.ToArray(); return new QueryResult<DeviceInfo> { @@ -132,7 +139,8 @@ namespace MediaBrowser.Server.Implementations.Devices public async Task AcceptCameraUpload(string deviceId, Stream stream, LocalFileInfo file) { - var path = GetUploadPath(deviceId); + var device = GetDevice(deviceId); + var path = GetUploadPath(device); if (!string.IsNullOrWhiteSpace(file.Album)) { @@ -158,11 +166,27 @@ namespace MediaBrowser.Server.Implementations.Devices { _libraryMonitor.ReportFileSystemChangeComplete(path, true); } + + if (CameraImageUploaded != null) + { + EventHelper.FireEventIfNotNull(CameraImageUploaded, this, new GenericEventArgs<CameraImageUploadInfo> + { + Argument = new CameraImageUploadInfo + { + Device = device, + FileInfo = file + } + }, _logger); + } } private string GetUploadPath(string deviceId) { - var device = GetDevice(deviceId); + return GetUploadPath(GetDevice(deviceId)); + } + + private string GetUploadPath(DeviceInfo device) + { if (!string.IsNullOrWhiteSpace(device.CameraUploadPath)) { return device.CameraUploadPath; @@ -212,7 +236,7 @@ namespace MediaBrowser.Server.Implementations.Devices { var capabilities = GetCapabilities(deviceId); - if (capabilities.SupportsUniqueIdentifier) + if (capabilities != null && capabilities.SupportsPersistentIdentifier) { return false; } |
