From f2c3e014b7b86d2e4792ce5214be44b250813ae6 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 4 Feb 2015 14:13:00 -0500 Subject: [PATCH] sync updates --- MediaBrowser.Controller/Sync/ISyncManager.cs | 2 +- MediaBrowser.Dlna/DlnaManager.cs | 2 +- MediaBrowser.Model/ApiClient/IServerEvents.cs | 4 ++++ MediaBrowser.Model/Sync/SyncJobStatus.cs | 9 ++++--- MediaBrowser.Model/System/SystemInfo.cs | 6 +++++ .../EntryPoints/ServerEventNotifier.cs | 7 ++++++ .../Localization/JavaScript/javascript.json | 14 +++++++---- .../Sync/SyncJobProcessor.cs | 24 ++++++++++++++----- .../Sync/SyncManager.cs | 1 + .../ApplicationHost.cs | 3 ++- Nuget/MediaBrowser.Common.Internal.nuspec | 4 ++-- Nuget/MediaBrowser.Common.nuspec | 2 +- Nuget/MediaBrowser.Model.Signed.nuspec | 2 +- Nuget/MediaBrowser.Server.Core.nuspec | 4 ++-- 14 files changed, 61 insertions(+), 23 deletions(-) diff --git a/MediaBrowser.Controller/Sync/ISyncManager.cs b/MediaBrowser.Controller/Sync/ISyncManager.cs index e0ea6eb9a..362b9c3bc 100644 --- a/MediaBrowser.Controller/Sync/ISyncManager.cs +++ b/MediaBrowser.Controller/Sync/ISyncManager.cs @@ -1,5 +1,4 @@ using MediaBrowser.Controller.Entities; -using MediaBrowser.Controller.Entities.Audio; using MediaBrowser.Model.Dlna; using MediaBrowser.Model.Events; using MediaBrowser.Model.Querying; @@ -15,6 +14,7 @@ namespace MediaBrowser.Controller.Sync { event EventHandler> SyncJobCreated; event EventHandler> SyncJobCancelled; + event EventHandler> SyncJobUpdated; /// /// Creates the job. diff --git a/MediaBrowser.Dlna/DlnaManager.cs b/MediaBrowser.Dlna/DlnaManager.cs index 0bce849ce..f0f295c83 100644 --- a/MediaBrowser.Dlna/DlnaManager.cs +++ b/MediaBrowser.Dlna/DlnaManager.cs @@ -515,7 +515,7 @@ namespace MediaBrowser.Dlna public void Run() { - DumpProfiles(); + //DumpProfiles(); } private void DumpProfiles() diff --git a/MediaBrowser.Model/ApiClient/IServerEvents.cs b/MediaBrowser.Model/ApiClient/IServerEvents.cs index b74d43ee0..cc51ce4c6 100644 --- a/MediaBrowser.Model/ApiClient/IServerEvents.cs +++ b/MediaBrowser.Model/ApiClient/IServerEvents.cs @@ -135,5 +135,9 @@ namespace MediaBrowser.Model.ApiClient /// Occurs when [synchronize job created]. /// event EventHandler> SyncJobCreated; + /// + /// Occurs when [synchronize job cancelled]. + /// + event EventHandler> SyncJobCancelled; } } diff --git a/MediaBrowser.Model/Sync/SyncJobStatus.cs b/MediaBrowser.Model/Sync/SyncJobStatus.cs index 961ccf544..6c0068a8a 100644 --- a/MediaBrowser.Model/Sync/SyncJobStatus.cs +++ b/MediaBrowser.Model/Sync/SyncJobStatus.cs @@ -4,8 +4,11 @@ namespace MediaBrowser.Model.Sync public enum SyncJobStatus { Queued = 0, - InProgress = 1, - Completed = 2, - CompletedWithError = 3 + Converting = 1, + Transferring = 2, + Completed = 3, + CompletedWithError = 4, + Failed = 5, + Cancelled = 6 } } diff --git a/MediaBrowser.Model/System/SystemInfo.cs b/MediaBrowser.Model/System/SystemInfo.cs index ce081d5f2..8c1fc759f 100644 --- a/MediaBrowser.Model/System/SystemInfo.cs +++ b/MediaBrowser.Model/System/SystemInfo.cs @@ -38,6 +38,12 @@ namespace MediaBrowser.Model.System /// true if this instance has pending restart; otherwise, false. public bool HasPendingRestart { get; set; } + /// + /// Gets or sets a value indicating whether [supports synchronize]. + /// + /// true if [supports synchronize]; otherwise, false. + public bool SupportsSync { get; set; } + /// /// Gets or sets a value indicating whether this instance is network deployed. /// diff --git a/MediaBrowser.Server.Implementations/EntryPoints/ServerEventNotifier.cs b/MediaBrowser.Server.Implementations/EntryPoints/ServerEventNotifier.cs index 51e6ddc0e..b5624625f 100644 --- a/MediaBrowser.Server.Implementations/EntryPoints/ServerEventNotifier.cs +++ b/MediaBrowser.Server.Implementations/EntryPoints/ServerEventNotifier.cs @@ -75,6 +75,12 @@ namespace MediaBrowser.Server.Implementations.EntryPoints _taskManager.TaskCompleted += _taskManager_TaskCompleted; _syncManager.SyncJobCreated += _syncManager_SyncJobCreated; + _syncManager.SyncJobCancelled += _syncManager_SyncJobCancelled; + } + + void _syncManager_SyncJobCancelled(object sender, GenericEventArgs e) + { + _sessionManager.SendMessageToUserDeviceSessions(e.Argument.TargetId, "SyncJobCancelled", e.Argument, CancellationToken.None); } void _syncManager_SyncJobCreated(object sender, GenericEventArgs e) @@ -189,6 +195,7 @@ namespace MediaBrowser.Server.Implementations.EntryPoints _appHost.HasPendingRestartChanged -= kernel_HasPendingRestartChanged; _syncManager.SyncJobCreated -= _syncManager_SyncJobCreated; + _syncManager.SyncJobCancelled -= _syncManager_SyncJobCancelled; } } } diff --git a/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json b/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json index b494adfd8..1349881a4 100644 --- a/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json +++ b/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json @@ -19,7 +19,7 @@ "PinCodeResetComplete": "The pin code has been reset.", "PasswordResetConfirmation": "Are you sure you wish to reset the password?", "PinCodeResetConfirmation": "Are you sure you wish to reset the pin code?", - "HeaderPinCodeReset": "Reset Pin Code", + "HeaderPinCodeReset": "Reset Pin Code", "PasswordSaved": "Password saved.", "PasswordMatchError": "Password and password confirmation must match.", "OptionRelease": "Official Release", @@ -48,10 +48,13 @@ "LabelFailed": "(failed)", "ButtonHelp": "Help", "ButtonSave": "Save", - "SyncJobStatusQueued": "Queued", - "SyncJobStatusInProgress": "In-Progress", - "SyncJobStatusCompleted": "Synced", - "SyncJobStatusCompletedWithError": "Synced with errors", + "SyncJobStatusQueued": "Queued", + "SyncJobStatusConverting": "Converting", + "SyncJobStatusFailed": "Failed", + "SyncJobStatusCancelled": "Cancelled", + "SyncJobStatusCompleted": "Synced", + "SyncJobStatusTransferring": "Transferring", + "SyncJobStatusCompletedWithError": "Synced with errors", "LabelCollection": "Collection", "HeaderAddToCollection": "Add to Collection", "NewCollectionNameExample": "Example: Star Wars Collection", @@ -91,6 +94,7 @@ "HeaderSelectSubtitles": "Select Subtitles", "ButtonMarkForRemoval": "Remove from device", "ButtonUnmarkForRemoval": "Cancel removal from device", + "LabelSyncQualityHelp": "Use high quality for the maximum supported quality by the device. Medium and Low reduce the allowed bitrate.", "LabelDefaultStream": "(Default)", "LabelForcedStream": "(Forced)", "LabelDefaultForcedStream": "(Default/Forced)", diff --git a/MediaBrowser.Server.Implementations/Sync/SyncJobProcessor.cs b/MediaBrowser.Server.Implementations/Sync/SyncJobProcessor.cs index 328b8441a..6ef74d953 100644 --- a/MediaBrowser.Server.Implementations/Sync/SyncJobProcessor.cs +++ b/MediaBrowser.Server.Implementations/Sync/SyncJobProcessor.cs @@ -172,7 +172,23 @@ namespace MediaBrowser.Server.Implementations.Sync job.Progress = null; } - if (pct >= 100) + if (jobItems.All(i => i.Status == SyncJobItemStatus.Queued)) + { + job.Status = SyncJobStatus.Queued; + } + else if (jobItems.All(i => i.Status == SyncJobItemStatus.Failed)) + { + job.Status = SyncJobStatus.Failed; + } + else if (jobItems.All(i => i.Status == SyncJobItemStatus.Cancelled)) + { + job.Status = SyncJobStatus.Cancelled; + } + else if (jobItems.Any(i => i.Status == SyncJobItemStatus.Converting)) + { + job.Status = SyncJobStatus.Converting; + } + else if (pct >= 100) { if (jobItems.Any(i => i.Status == SyncJobItemStatus.Failed)) { @@ -183,13 +199,9 @@ namespace MediaBrowser.Server.Implementations.Sync job.Status = SyncJobStatus.Completed; } } - else if (pct.Equals(0) && jobItems.All(i => i.Status == SyncJobItemStatus.Queued)) - { - job.Status = SyncJobStatus.Queued; - } else { - job.Status = SyncJobStatus.InProgress; + job.Status = SyncJobStatus.Transferring; } return _syncRepo.Update(job); diff --git a/MediaBrowser.Server.Implementations/Sync/SyncManager.cs b/MediaBrowser.Server.Implementations/Sync/SyncManager.cs index 6034390c6..627e94eb1 100644 --- a/MediaBrowser.Server.Implementations/Sync/SyncManager.cs +++ b/MediaBrowser.Server.Implementations/Sync/SyncManager.cs @@ -51,6 +51,7 @@ namespace MediaBrowser.Server.Implementations.Sync public event EventHandler> SyncJobCreated; public event EventHandler> SyncJobCancelled; + public event EventHandler> SyncJobUpdated; public SyncManager(ILibraryManager libraryManager, ISyncRepository repo, IImageProcessor imageProcessor, ILogger logger, IUserManager userManager, Func dtoService, IApplicationHost appHost, ITVSeriesManager tvSeriesManager, Func mediaEncoder, IFileSystem fileSystem, Func subtitleEncoder, IConfigurationManager config) { diff --git a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs index e3e0d1363..b72a10801 100644 --- a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs +++ b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs @@ -1023,7 +1023,8 @@ namespace MediaBrowser.Server.Startup.Common IsRunningAsService = IsRunningAsService, SupportsRunningAsService = SupportsRunningAsService, ServerName = FriendlyName, - LocalAddress = LocalApiUrl + LocalAddress = LocalApiUrl, + SupportsSync = true }; } diff --git a/Nuget/MediaBrowser.Common.Internal.nuspec b/Nuget/MediaBrowser.Common.Internal.nuspec index a9194c05c..37c4d9ba4 100644 --- a/Nuget/MediaBrowser.Common.Internal.nuspec +++ b/Nuget/MediaBrowser.Common.Internal.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common.Internal - 3.0.554 + 3.0.556 MediaBrowser.Common.Internal Luke ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption. Copyright © Media Browser 2013 - + diff --git a/Nuget/MediaBrowser.Common.nuspec b/Nuget/MediaBrowser.Common.nuspec index 5bbb13e19..a2472fb84 100644 --- a/Nuget/MediaBrowser.Common.nuspec +++ b/Nuget/MediaBrowser.Common.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common - 3.0.554 + 3.0.556 MediaBrowser.Common Media Browser Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Model.Signed.nuspec b/Nuget/MediaBrowser.Model.Signed.nuspec index 124006492..24f94d22e 100644 --- a/Nuget/MediaBrowser.Model.Signed.nuspec +++ b/Nuget/MediaBrowser.Model.Signed.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Model.Signed - 3.0.554 + 3.0.556 MediaBrowser.Model - Signed Edition Media Browser Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Server.Core.nuspec b/Nuget/MediaBrowser.Server.Core.nuspec index da3283c32..b50c59b59 100644 --- a/Nuget/MediaBrowser.Server.Core.nuspec +++ b/Nuget/MediaBrowser.Server.Core.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Server.Core - 3.0.554 + 3.0.556 Media Browser.Server.Core Media Browser Team ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains core components required to build plugins for Media Browser Server. Copyright © Media Browser 2013 - +