From 7bce2e04b618671faafc32a39978d0d8c87cba21 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 27 Dec 2014 17:52:41 -0500 Subject: [PATCH] sync updates --- MediaBrowser.Api/Sync/SyncService.cs | 12 +++++++ MediaBrowser.Controller/Entities/BaseItem.cs | 2 +- .../Net/IWebSocketConnection.cs | 3 +- MediaBrowser.Controller/Sync/ISyncManager.cs | 14 ++++---- MediaBrowser.Dlna/Main/DlnaEntryPoint.cs | 1 - .../Configuration/ServerConfiguration.cs | 2 ++ MediaBrowser.Model/Sync/DeviceFileInfo.cs | 2 +- MediaBrowser.Model/Sync/ItemFIleInfo.cs | 2 +- .../Connect/ConnectEntryPoint.cs | 1 - .../EntryPoints/UdpServerEntryPoint.cs | 1 - .../EntryPoints/UsageEntryPoint.cs | 2 -- .../EntryPoints/UsageReporter.cs | 1 - .../HttpServer/HttpListenerHost.cs | 16 ++++++--- .../HttpServer/IHttpListener.cs | 5 ++- .../HttpServer/NativeWebSocket.cs | 5 ++- .../NetListener/HttpListenerServer.cs | 3 +- .../HttpServer/SocketSharp/SharpWebSocket.cs | 5 +-- .../SocketSharp/WebSocketSharpListener.cs | 3 +- .../ServerManager/WebSocketConnection.cs | 1 - .../Session/WebSocketController.cs | 3 +- .../Sync/SyncManager.cs | 20 ++++++++--- .../Sync/SyncRepository.cs | 16 ++++++--- .../Udp/UdpServer.cs | 1 - MediaBrowser.Server.Mac/Native/BaseMonoApp.cs | 2 +- .../Native/BaseMonoApp.cs | 3 +- .../Networking/NetworkManager.cs | 1 - .../ApplicationHost.cs | 35 ++++++++++--------- .../INativeApp.cs | 6 ++-- .../Native/RegisterServer.bat | 18 ++++------ .../Native/ServerAuthorization.cs | 9 ++--- .../Native/WindowsApp.cs | 5 ++- .../Networking/NetworkManager.cs | 1 - Nuget/MediaBrowser.Common.Internal.nuspec | 4 +-- Nuget/MediaBrowser.Common.nuspec | 2 +- Nuget/MediaBrowser.Model.Signed.nuspec | 2 +- Nuget/MediaBrowser.Server.Core.nuspec | 4 +-- 36 files changed, 109 insertions(+), 104 deletions(-) diff --git a/MediaBrowser.Api/Sync/SyncService.cs b/MediaBrowser.Api/Sync/SyncService.cs index ab4e759230..0036b316ff 100644 --- a/MediaBrowser.Api/Sync/SyncService.cs +++ b/MediaBrowser.Api/Sync/SyncService.cs @@ -85,6 +85,13 @@ namespace MediaBrowser.Api.Sync { } + [Route("/Sync/Items/Ready", "GET", Summary = "Gets ready to download sync items.")] + public class GetReadySyncItems : IReturn> + { + [ApiMember(Name = "TargetId", Description = "TargetId", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "GET")] + public string TargetId { get; set; } + } + [Authenticated] public class SyncService : BaseApiService { @@ -207,5 +214,10 @@ namespace MediaBrowser.Api.Sync await _syncManager.ReportOfflineAction(action).ConfigureAwait(false); } } + + public object Get(GetReadySyncItems request) + { + return ToOptimizedResult(_syncManager.GetReadySyncItems(request.TargetId)); + } } } diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index aea04187d9..90427de75d 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -14,6 +14,7 @@ using MediaBrowser.Model.Dto; using MediaBrowser.Model.Entities; using MediaBrowser.Model.Library; using MediaBrowser.Model.Logging; +using MediaBrowser.Model.Users; using System; using System.Collections.Generic; using System.IO; @@ -21,7 +22,6 @@ using System.Linq; using System.Runtime.Serialization; using System.Threading; using System.Threading.Tasks; -using MediaBrowser.Model.Users; namespace MediaBrowser.Controller.Entities { diff --git a/MediaBrowser.Controller/Net/IWebSocketConnection.cs b/MediaBrowser.Controller/Net/IWebSocketConnection.cs index 83ead5a12f..37fd6708d9 100644 --- a/MediaBrowser.Controller/Net/IWebSocketConnection.cs +++ b/MediaBrowser.Controller/Net/IWebSocketConnection.cs @@ -1,5 +1,4 @@ -using MediaBrowser.Common.Net; -using MediaBrowser.Model.Net; +using MediaBrowser.Model.Net; using System; using System.Threading; using System.Threading.Tasks; diff --git a/MediaBrowser.Controller/Sync/ISyncManager.cs b/MediaBrowser.Controller/Sync/ISyncManager.cs index e16a978c39..39cec4f00f 100644 --- a/MediaBrowser.Controller/Sync/ISyncManager.cs +++ b/MediaBrowser.Controller/Sync/ISyncManager.cs @@ -82,18 +82,18 @@ namespace MediaBrowser.Controller.Sync /// SyncJobItem. SyncJobItem GetJobItem(string id); - /// - /// Gets the job item information. - /// - /// The identifier. - /// SyncedItem. - SyncedItem GetJobItemInfo(string id); - /// /// Reports the offline action. /// /// The action. /// Task. Task ReportOfflineAction(UserAction action); + + /// + /// Gets the ready synchronize items. + /// + /// The target identifier. + /// List<SyncedItem>. + List GetReadySyncItems(string targetId); } } diff --git a/MediaBrowser.Dlna/Main/DlnaEntryPoint.cs b/MediaBrowser.Dlna/Main/DlnaEntryPoint.cs index dc4aff1901..810b1e5684 100644 --- a/MediaBrowser.Dlna/Main/DlnaEntryPoint.cs +++ b/MediaBrowser.Dlna/Main/DlnaEntryPoint.cs @@ -7,7 +7,6 @@ using MediaBrowser.Controller.Dlna; using MediaBrowser.Controller.Drawing; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Localization; -using MediaBrowser.Controller.Net; using MediaBrowser.Controller.Persistence; using MediaBrowser.Controller.Plugins; using MediaBrowser.Controller.Session; diff --git a/MediaBrowser.Model/Configuration/ServerConfiguration.cs b/MediaBrowser.Model/Configuration/ServerConfiguration.cs index 7307354994..ba5b6a122f 100644 --- a/MediaBrowser.Model/Configuration/ServerConfiguration.cs +++ b/MediaBrowser.Model/Configuration/ServerConfiguration.cs @@ -165,6 +165,7 @@ namespace MediaBrowser.Model.Configuration public string[] InsecureApps7 { get; set; } public bool SaveMetadataHidden { get; set; } + public bool EnableWin8HttpListener { get; set; } public NameValuePair[] ContentTypes { get; set; } @@ -180,6 +181,7 @@ namespace MediaBrowser.Model.Configuration EnableDashboardResponseCaching = true; EnableAutomaticRestart = true; + EnableWin8HttpListener = true; EnableUPnP = true; diff --git a/MediaBrowser.Model/Sync/DeviceFileInfo.cs b/MediaBrowser.Model/Sync/DeviceFileInfo.cs index bc93b69bcf..bb9a0c6ef2 100644 --- a/MediaBrowser.Model/Sync/DeviceFileInfo.cs +++ b/MediaBrowser.Model/Sync/DeviceFileInfo.cs @@ -3,7 +3,7 @@ namespace MediaBrowser.Model.Sync { public class DeviceFileInfo { - public string Path { get; set; } + public string[] Path { get; set; } public string Name { get; set; } } } diff --git a/MediaBrowser.Model/Sync/ItemFIleInfo.cs b/MediaBrowser.Model/Sync/ItemFIleInfo.cs index 8095b0cff2..ef19973a23 100644 --- a/MediaBrowser.Model/Sync/ItemFIleInfo.cs +++ b/MediaBrowser.Model/Sync/ItemFIleInfo.cs @@ -18,7 +18,7 @@ namespace MediaBrowser.Model.Sync /// Gets or sets the path. /// /// The path. - public string Path { get; set; } + public string[] Path { get; set; } /// /// Gets or sets the type of the image. /// diff --git a/MediaBrowser.Server.Implementations/Connect/ConnectEntryPoint.cs b/MediaBrowser.Server.Implementations/Connect/ConnectEntryPoint.cs index 5acec2d6b9..52ec5c9b12 100644 --- a/MediaBrowser.Server.Implementations/Connect/ConnectEntryPoint.cs +++ b/MediaBrowser.Server.Implementations/Connect/ConnectEntryPoint.cs @@ -1,7 +1,6 @@ using MediaBrowser.Common.Configuration; using MediaBrowser.Common.Net; using MediaBrowser.Controller.Connect; -using MediaBrowser.Controller.Net; using MediaBrowser.Controller.Plugins; using MediaBrowser.Model.Logging; using System; diff --git a/MediaBrowser.Server.Implementations/EntryPoints/UdpServerEntryPoint.cs b/MediaBrowser.Server.Implementations/EntryPoints/UdpServerEntryPoint.cs index d97ccb9bd2..386c16513b 100644 --- a/MediaBrowser.Server.Implementations/EntryPoints/UdpServerEntryPoint.cs +++ b/MediaBrowser.Server.Implementations/EntryPoints/UdpServerEntryPoint.cs @@ -1,6 +1,5 @@ using MediaBrowser.Common.Net; using MediaBrowser.Controller; -using MediaBrowser.Controller.Net; using MediaBrowser.Controller.Plugins; using MediaBrowser.Model.Logging; using MediaBrowser.Model.Serialization; diff --git a/MediaBrowser.Server.Implementations/EntryPoints/UsageEntryPoint.cs b/MediaBrowser.Server.Implementations/EntryPoints/UsageEntryPoint.cs index 098a1d2bda..fcc6640119 100644 --- a/MediaBrowser.Server.Implementations/EntryPoints/UsageEntryPoint.cs +++ b/MediaBrowser.Server.Implementations/EntryPoints/UsageEntryPoint.cs @@ -1,8 +1,6 @@ using MediaBrowser.Common; using MediaBrowser.Common.Extensions; -using MediaBrowser.Common.Implementations.Security; using MediaBrowser.Common.Net; -using MediaBrowser.Controller.Net; using MediaBrowser.Controller.Plugins; using MediaBrowser.Controller.Session; using MediaBrowser.Model.Logging; diff --git a/MediaBrowser.Server.Implementations/EntryPoints/UsageReporter.cs b/MediaBrowser.Server.Implementations/EntryPoints/UsageReporter.cs index 940be6d02b..36ba55828a 100644 --- a/MediaBrowser.Server.Implementations/EntryPoints/UsageReporter.cs +++ b/MediaBrowser.Server.Implementations/EntryPoints/UsageReporter.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; -using MediaBrowser.Controller.Net; namespace MediaBrowser.Server.Implementations.EntryPoints { diff --git a/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs b/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs index b754a943a8..c3228db920 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs @@ -1,7 +1,6 @@ using Funq; using MediaBrowser.Common; using MediaBrowser.Common.Extensions; -using MediaBrowser.Common.Net; using MediaBrowser.Controller.Net; using MediaBrowser.Model.Logging; using MediaBrowser.Server.Implementations.HttpServer.NetListener; @@ -205,10 +204,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer { HostContext.Config.HandlerFactoryPath = ListenerRequest.GetHandlerPathIfAny(UrlPrefixes.First()); - _listener = _supportsNativeWebSocket && NativeWebSocket.IsSupported - //? _listener = new HttpListenerServer(_logger, OnRequestReceived) - ? _listener = new WebSocketSharpListener(_logger, OnRequestReceived) - : _listener = new WebSocketSharpListener(_logger, OnRequestReceived); + _listener = GetListener(); _listener.WebSocketHandler = WebSocketHandler; _listener.ErrorHandler = ErrorHandler; @@ -217,6 +213,16 @@ namespace MediaBrowser.Server.Implementations.HttpServer _listener.Start(UrlPrefixes); } + private IHttpListener GetListener() + { + if (_supportsNativeWebSocket && NativeWebSocket.IsSupported) + { + return new HttpListenerServer(_logger, OnRequestReceived); + } + + return new WebSocketSharpListener(_logger, OnRequestReceived); + } + private void WebSocketHandler(WebSocketConnectEventArgs args) { if (WebSocketConnected != null) diff --git a/MediaBrowser.Server.Implementations/HttpServer/IHttpListener.cs b/MediaBrowser.Server.Implementations/HttpServer/IHttpListener.cs index dfde34e25b..e77600e938 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/IHttpListener.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/IHttpListener.cs @@ -1,9 +1,8 @@ -using System.Threading.Tasks; -using MediaBrowser.Common.Net; -using MediaBrowser.Controller.Net; +using MediaBrowser.Controller.Net; using ServiceStack.Web; using System; using System.Collections.Generic; +using System.Threading.Tasks; namespace MediaBrowser.Server.Implementations.HttpServer { diff --git a/MediaBrowser.Server.Implementations/HttpServer/NativeWebSocket.cs b/MediaBrowser.Server.Implementations/HttpServer/NativeWebSocket.cs index f8e8bb9dd5..cac2f8e094 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/NativeWebSocket.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/NativeWebSocket.cs @@ -1,10 +1,9 @@ -using System.Text; -using MediaBrowser.Common.Events; -using MediaBrowser.Common.Net; +using MediaBrowser.Common.Events; using MediaBrowser.Controller.Net; using MediaBrowser.Model.Logging; using System; using System.Net.WebSockets; +using System.Text; using System.Threading; using System.Threading.Tasks; using WebSocketMessageType = MediaBrowser.Model.Net.WebSocketMessageType; diff --git a/MediaBrowser.Server.Implementations/HttpServer/NetListener/HttpListenerServer.cs b/MediaBrowser.Server.Implementations/HttpServer/NetListener/HttpListenerServer.cs index 9635854d46..31c0e87b33 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/NetListener/HttpListenerServer.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/NetListener/HttpListenerServer.cs @@ -1,5 +1,4 @@ -using MediaBrowser.Common.Net; -using MediaBrowser.Controller.Net; +using MediaBrowser.Controller.Net; using MediaBrowser.Model.Logging; using ServiceStack; using ServiceStack.Host.HttpListener; diff --git a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/SharpWebSocket.cs b/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/SharpWebSocket.cs index 354b1e20fd..401d49325a 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/SharpWebSocket.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/SharpWebSocket.cs @@ -1,12 +1,9 @@ -using System.Text; -using MediaBrowser.Common.Events; -using MediaBrowser.Common.Net; +using MediaBrowser.Common.Events; using MediaBrowser.Controller.Net; using MediaBrowser.Model.Logging; using System; using System.Threading; using System.Threading.Tasks; -using WebSocketMessageType = MediaBrowser.Model.Net.WebSocketMessageType; using WebSocketState = MediaBrowser.Model.Net.WebSocketState; namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp diff --git a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpListener.cs b/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpListener.cs index ffaecc0d54..4d2d57b6ea 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpListener.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpListener.cs @@ -1,5 +1,4 @@ -using MediaBrowser.Common.Net; -using MediaBrowser.Controller.Net; +using MediaBrowser.Controller.Net; using MediaBrowser.Model.Logging; using ServiceStack; using ServiceStack.Web; diff --git a/MediaBrowser.Server.Implementations/ServerManager/WebSocketConnection.cs b/MediaBrowser.Server.Implementations/ServerManager/WebSocketConnection.cs index a8950da899..9f75d522c9 100644 --- a/MediaBrowser.Server.Implementations/ServerManager/WebSocketConnection.cs +++ b/MediaBrowser.Server.Implementations/ServerManager/WebSocketConnection.cs @@ -1,5 +1,4 @@ using MediaBrowser.Common.Events; -using MediaBrowser.Common.Net; using MediaBrowser.Controller.Net; using MediaBrowser.Model.Logging; using MediaBrowser.Model.Net; diff --git a/MediaBrowser.Server.Implementations/Session/WebSocketController.cs b/MediaBrowser.Server.Implementations/Session/WebSocketController.cs index 0788ed2cee..8eb1298768 100644 --- a/MediaBrowser.Server.Implementations/Session/WebSocketController.cs +++ b/MediaBrowser.Server.Implementations/Session/WebSocketController.cs @@ -1,5 +1,4 @@ -using MediaBrowser.Common.Net; -using MediaBrowser.Controller.Net; +using MediaBrowser.Controller.Net; using MediaBrowser.Controller.Session; using MediaBrowser.Model.Entities; using MediaBrowser.Model.Logging; diff --git a/MediaBrowser.Server.Implementations/Sync/SyncManager.cs b/MediaBrowser.Server.Implementations/Sync/SyncManager.cs index a9e257a8c9..22d0ee5e7e 100644 --- a/MediaBrowser.Server.Implementations/Sync/SyncManager.cs +++ b/MediaBrowser.Server.Implementations/Sync/SyncManager.cs @@ -32,12 +32,12 @@ namespace MediaBrowser.Server.Implementations.Sync private readonly IImageProcessor _imageProcessor; private readonly ILogger _logger; private readonly IUserManager _userManager; - private readonly IDtoService _dtoService; + private readonly Func _dtoService; private readonly IApplicationHost _appHost; private ISyncProvider[] _providers = { }; - public SyncManager(ILibraryManager libraryManager, ISyncRepository repo, IImageProcessor imageProcessor, ILogger logger, IUserManager userManager, IDtoService dtoService, IApplicationHost appHost) + public SyncManager(ILibraryManager libraryManager, ISyncRepository repo, IImageProcessor imageProcessor, ILogger logger, IUserManager userManager, Func dtoService, IApplicationHost appHost) { _libraryManager = libraryManager; _repo = repo; @@ -323,9 +323,8 @@ namespace MediaBrowser.Server.Implementations.Sync return _repo.GetJobItems(query); } - public SyncedItem GetJobItemInfo(string id) + private SyncedItem GetJobItemInfo(SyncJobItem jobItem) { - var jobItem = GetJobItem(id); var job = _repo.GetJob(jobItem.JobId); var libraryItem = _libraryManager.GetItemById(jobItem.ItemId); @@ -338,7 +337,7 @@ namespace MediaBrowser.Server.Implementations.Sync UserId = job.UserId }; - syncedItem.Item = _dtoService.GetBaseItemDto(libraryItem, new DtoOptions()); + syncedItem.Item = _dtoService().GetBaseItemDto(libraryItem, new DtoOptions()); // TODO: this should be the media source of the transcoded output syncedItem.Item.MediaSources = syncedItem.Item.MediaSources @@ -365,5 +364,16 @@ namespace MediaBrowser.Server.Implementations.Sync { return Task.FromResult(true); } + + public List GetReadySyncItems(string targetId) + { + var jobItemResult = GetJobItems(new SyncJobItemQuery + { + TargetId = targetId, + //Status = SyncJobItemStatus.Transferring + }); + + return jobItemResult.Items.Select(GetJobItemInfo).ToList(); + } } } diff --git a/MediaBrowser.Server.Implementations/Sync/SyncRepository.cs b/MediaBrowser.Server.Implementations/Sync/SyncRepository.cs index 2ff6d7ae6b..a981ffc572 100644 --- a/MediaBrowser.Server.Implementations/Sync/SyncRepository.cs +++ b/MediaBrowser.Server.Implementations/Sync/SyncRepository.cs @@ -36,7 +36,7 @@ namespace MediaBrowser.Server.Implementations.Sync public async Task Initialize() { - var dbFile = Path.Combine(_appPaths.DataPath, "sync7.db"); + var dbFile = Path.Combine(_appPaths.DataPath, "sync8.db"); _connection = await SqliteExtensions.ConnectToDb(dbFile, _logger).ConfigureAwait(false); @@ -298,7 +298,8 @@ namespace MediaBrowser.Server.Implementations.Sync _deleteJobCommand.Transaction = transaction; _deleteJobCommand.ExecuteNonQuery(); - _deleteJobItemsCommand.GetParameter(index++).Value = new Guid(id); + index = 0; + _deleteJobItemsCommand.GetParameter(index++).Value = id; _deleteJobItemsCommand.Transaction = transaction; _deleteJobItemsCommand.ExecuteNonQuery(); @@ -607,11 +608,16 @@ namespace MediaBrowser.Server.Implementations.Sync var info = new SyncJobItem { Id = reader.GetGuid(0).ToString("N"), - ItemId = reader.GetString(1), - MediaSourceId = reader.GetString(2), - JobId = reader.GetString(3) + ItemId = reader.GetString(1) }; + if (!reader.IsDBNull(2)) + { + info.MediaSourceId = reader.GetString(2); + } + + info.JobId = reader.GetString(3); + if (!reader.IsDBNull(4)) { info.OutputPath = reader.GetString(4); diff --git a/MediaBrowser.Server.Implementations/Udp/UdpServer.cs b/MediaBrowser.Server.Implementations/Udp/UdpServer.cs index d80e0b66ef..91a4940ae3 100644 --- a/MediaBrowser.Server.Implementations/Udp/UdpServer.cs +++ b/MediaBrowser.Server.Implementations/Udp/UdpServer.cs @@ -1,6 +1,5 @@ using MediaBrowser.Common.Net; using MediaBrowser.Controller; -using MediaBrowser.Controller.Net; using MediaBrowser.Model.ApiClient; using MediaBrowser.Model.Logging; using MediaBrowser.Model.Serialization; diff --git a/MediaBrowser.Server.Mac/Native/BaseMonoApp.cs b/MediaBrowser.Server.Mac/Native/BaseMonoApp.cs index a2c860413c..576b5b75f1 100644 --- a/MediaBrowser.Server.Mac/Native/BaseMonoApp.cs +++ b/MediaBrowser.Server.Mac/Native/BaseMonoApp.cs @@ -67,7 +67,7 @@ namespace MediaBrowser.Server.Mac return list; } - public void AuthorizeServer(int httpServerPort, string httpServerUrlPrefix, int udpPort, string tempDirectory) + public void AuthorizeServer(int udpPort, int httpServerPort, string tempDirectory) { } diff --git a/MediaBrowser.Server.Mono/Native/BaseMonoApp.cs b/MediaBrowser.Server.Mono/Native/BaseMonoApp.cs index 227c32242e..7f61570a4d 100644 --- a/MediaBrowser.Server.Mono/Native/BaseMonoApp.cs +++ b/MediaBrowser.Server.Mono/Native/BaseMonoApp.cs @@ -1,5 +1,4 @@ using MediaBrowser.Common.Net; -using MediaBrowser.Controller.Net; using MediaBrowser.IsoMounter; using MediaBrowser.Model.Logging; using MediaBrowser.Server.Mono.Networking; @@ -84,7 +83,7 @@ namespace MediaBrowser.Server.Mono.Native return list; } - public void AuthorizeServer(int httpServerPort, string httpServerUrlPrefix, int udpPort, string tempDirectory) + public void AuthorizeServer(int udpPort, int httpServerPort, string tempDirectory) { } diff --git a/MediaBrowser.Server.Mono/Networking/NetworkManager.cs b/MediaBrowser.Server.Mono/Networking/NetworkManager.cs index d76a7c7eea..60c2501157 100644 --- a/MediaBrowser.Server.Mono/Networking/NetworkManager.cs +++ b/MediaBrowser.Server.Mono/Networking/NetworkManager.cs @@ -1,6 +1,5 @@ using MediaBrowser.Common.Implementations.Networking; using MediaBrowser.Common.Net; -using MediaBrowser.Controller.Net; using MediaBrowser.Model.IO; using MediaBrowser.Model.Logging; using MediaBrowser.Model.Net; diff --git a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs index 06d63b355e..8398c63cbd 100644 --- a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs +++ b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs @@ -224,7 +224,7 @@ namespace MediaBrowser.Server.Startup.Common private readonly StartupOptions _startupOptions; private readonly string _remotePackageName; - private readonly bool _supportsNativeWebSocket; + private bool _supportsNativeWebSocket; internal INativeApp NativeApp { get; set; } @@ -454,6 +454,18 @@ namespace MediaBrowser.Server.Startup.Common RegisterSingleInstance(() => new SearchEngine(LogManager, LibraryManager, UserManager)); + if (IsFirstRun) + { + ServerConfigurationManager.Configuration.EnableWin8HttpListener = false; + ServerConfigurationManager.SaveConfiguration(); + _supportsNativeWebSocket = false; + } + + if (!ServerConfigurationManager.Configuration.EnableWin8HttpListener) + { + _supportsNativeWebSocket = false; + } + HttpServer = ServerFactory.CreateServer(this, LogManager, "Media Browser", WebApplicationName, "dashboard/index.html", _supportsNativeWebSocket); RegisterSingleInstance(HttpServer, false); progress.Report(10); @@ -470,7 +482,7 @@ namespace MediaBrowser.Server.Startup.Common ImageProcessor = new ImageProcessor(LogManager.GetLogger("ImageProcessor"), ServerConfigurationManager.ApplicationPaths, FileSystemManager, JsonSerializer, MediaEncoder); RegisterSingleInstance(ImageProcessor); - SyncManager = new SyncManager(LibraryManager, SyncRepository, ImageProcessor, LogManager.GetLogger("SyncManager"), UserManager, DtoService, this); + SyncManager = new SyncManager(LibraryManager, SyncRepository, ImageProcessor, LogManager.GetLogger("SyncManager"), UserManager, () => DtoService, this); RegisterSingleInstance(SyncManager); DtoService = new DtoService(Logger, LibraryManager, UserDataManager, ItemRepository, ImageProcessor, ServerConfigurationManager, FileSystemManager, ProviderManager, () => ChannelManager, SyncManager, this); @@ -735,7 +747,7 @@ namespace MediaBrowser.Server.Startup.Common ServerManager.AddWebSocketListeners(GetExports(false)); - StartServer(true); + StartServer(); LibraryManager.AddParts(GetExports(), GetExports(), @@ -773,8 +785,7 @@ namespace MediaBrowser.Server.Startup.Common /// /// Starts the server. /// - /// if set to true [retry on failure]. - private void StartServer(bool retryOnFailure) + private void StartServer() { try { @@ -784,16 +795,7 @@ namespace MediaBrowser.Server.Startup.Common { Logger.ErrorException("Error starting http server", ex); - if (retryOnFailure) - { - RegisterServerWithAdministratorAccess(); - - StartServer(false); - } - else - { - throw; - } + throw; } } @@ -1070,9 +1072,8 @@ namespace MediaBrowser.Server.Startup.Common try { NativeApp.AuthorizeServer( - ServerConfigurationManager.Configuration.HttpServerPortNumber, - HttpServerUrlPrefixes.First(), UdpServerEntryPoint.PortNumber, + ServerConfigurationManager.Configuration.HttpServerPortNumber, ConfigurationManager.CommonApplicationPaths.TempDirectory); } catch (Exception ex) diff --git a/MediaBrowser.Server.Startup.Common/INativeApp.cs b/MediaBrowser.Server.Startup.Common/INativeApp.cs index cf0135fa82..4abea57fb1 100644 --- a/MediaBrowser.Server.Startup.Common/INativeApp.cs +++ b/MediaBrowser.Server.Startup.Common/INativeApp.cs @@ -1,5 +1,4 @@ using MediaBrowser.Common.Net; -using MediaBrowser.Controller.Net; using MediaBrowser.Model.Logging; using System.Collections.Generic; using System.Reflection; @@ -17,11 +16,10 @@ namespace MediaBrowser.Server.Startup.Common /// /// Authorizes the server. /// - /// The HTTP server port. - /// The HTTP server URL prefix. /// The UDP port. + /// The HTTP server port. /// The temporary directory. - void AuthorizeServer(int httpServerPort, string httpServerUrlPrefix, int udpPort, string tempDirectory); + void AuthorizeServer(int udpPort, int httpServerPort, string tempDirectory); /// /// Gets the environment. diff --git a/MediaBrowser.ServerApplication/Native/RegisterServer.bat b/MediaBrowser.ServerApplication/Native/RegisterServer.bat index 3504123444..3346ecb317 100644 --- a/MediaBrowser.ServerApplication/Native/RegisterServer.bat +++ b/MediaBrowser.ServerApplication/Native/RegisterServer.bat @@ -1,21 +1,15 @@ -rem %1 = http server port -rem %2 = http server url -rem %3 = udp server port +rem %1 = udp server port +rem %2 = http server port if [%1]==[] GOTO DONE -netsh advfirewall firewall delete rule name="Port %1" protocol=TCP localport=%1 -netsh advfirewall firewall add rule name="Port %1" dir=in action=allow protocol=TCP localport=%1 +netsh advfirewall firewall delete rule name="Port %1" protocol=UDP localport=%1 +netsh advfirewall firewall add rule name="Port %1" dir=in action=allow protocol=UDP localport=%1 if [%2]==[] GOTO DONE -netsh http del urlacl url="%2" user="NT AUTHORITY\Authenticated Users" -netsh http add urlacl url="%2" user="NT AUTHORITY\Authenticated Users" - -if [%3]==[] GOTO DONE - -netsh advfirewall firewall delete rule name="Port %3" protocol=UDP localport=%3 -netsh advfirewall firewall add rule name="Port %3" dir=in action=allow protocol=UDP localport=%3 +netsh advfirewall firewall delete rule name="Port %2" protocol=TCP localport=%2 +netsh advfirewall firewall add rule name="Port %2" dir=in action=allow protocol=TCP localport=%2 :DONE diff --git a/MediaBrowser.ServerApplication/Native/ServerAuthorization.cs b/MediaBrowser.ServerApplication/Native/ServerAuthorization.cs index e5989db3bf..d9063aa580 100644 --- a/MediaBrowser.ServerApplication/Native/ServerAuthorization.cs +++ b/MediaBrowser.ServerApplication/Native/ServerAuthorization.cs @@ -13,11 +13,10 @@ namespace MediaBrowser.ServerApplication.Native /// /// Authorizes the server. /// - /// The HTTP server port. - /// The HTTP server URL prefix. /// The UDP port. + /// The HTTP server port. /// The temp directory. - public static void AuthorizeServer(int httpServerPort, string httpServerUrlPrefix, int udpPort, string tempDirectory) + public static void AuthorizeServer(int udpPort, int httpServerPort, string tempDirectory) { Directory.CreateDirectory(tempDirectory); @@ -37,9 +36,7 @@ namespace MediaBrowser.ServerApplication.Native { FileName = tmpFile, - Arguments = string.Format("{0} {1} {2}", httpServerPort, - httpServerUrlPrefix, - udpPort), + Arguments = string.Format("{0} {1}", udpPort, httpServerPort), CreateNoWindow = true, WindowStyle = ProcessWindowStyle.Hidden, diff --git a/MediaBrowser.ServerApplication/Native/WindowsApp.cs b/MediaBrowser.ServerApplication/Native/WindowsApp.cs index 0712164187..0970d6537a 100644 --- a/MediaBrowser.ServerApplication/Native/WindowsApp.cs +++ b/MediaBrowser.ServerApplication/Native/WindowsApp.cs @@ -1,5 +1,4 @@ using MediaBrowser.Common.Net; -using MediaBrowser.Controller.Net; using MediaBrowser.IsoMounter; using MediaBrowser.Model.Logging; using MediaBrowser.Server.Startup.Common; @@ -22,9 +21,9 @@ namespace MediaBrowser.ServerApplication.Native return list; } - public void AuthorizeServer(int httpServerPort, string httpServerUrlPrefix, int udpPort, string tempDirectory) + public void AuthorizeServer(int httpServerPort, int udpPort, string tempDirectory) { - ServerAuthorization.AuthorizeServer(httpServerPort, httpServerUrlPrefix, udpPort, tempDirectory); + ServerAuthorization.AuthorizeServer(udpPort, httpServerPort, tempDirectory); } public NativeEnvironment Environment diff --git a/MediaBrowser.ServerApplication/Networking/NetworkManager.cs b/MediaBrowser.ServerApplication/Networking/NetworkManager.cs index 4dbe0f3470..fc4d263636 100644 --- a/MediaBrowser.ServerApplication/Networking/NetworkManager.cs +++ b/MediaBrowser.ServerApplication/Networking/NetworkManager.cs @@ -1,6 +1,5 @@ using MediaBrowser.Common.Implementations.Networking; using MediaBrowser.Common.Net; -using MediaBrowser.Controller.Net; using MediaBrowser.Model.IO; using MediaBrowser.Model.Logging; using MediaBrowser.Model.Net; diff --git a/Nuget/MediaBrowser.Common.Internal.nuspec b/Nuget/MediaBrowser.Common.Internal.nuspec index 3fd559a4d3..80e2f32f7b 100644 --- a/Nuget/MediaBrowser.Common.Internal.nuspec +++ b/Nuget/MediaBrowser.Common.Internal.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common.Internal - 3.0.532 + 3.0.533 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 84eec30d67..8c22ebb5df 100644 --- a/Nuget/MediaBrowser.Common.nuspec +++ b/Nuget/MediaBrowser.Common.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common - 3.0.532 + 3.0.533 MediaBrowser.Common Media Browser Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Model.Signed.nuspec b/Nuget/MediaBrowser.Model.Signed.nuspec index ad3bd826d3..f313bd7a59 100644 --- a/Nuget/MediaBrowser.Model.Signed.nuspec +++ b/Nuget/MediaBrowser.Model.Signed.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Model.Signed - 3.0.532 + 3.0.533 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 191ab9e88e..a31f8023bf 100644 --- a/Nuget/MediaBrowser.Server.Core.nuspec +++ b/Nuget/MediaBrowser.Server.Core.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Server.Core - 3.0.532 + 3.0.533 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 - +