From 17c1fd576057bdd2d6aea517d733fe8af6e6b2ba Mon Sep 17 00:00:00 2001 From: LukePulverenti Date: Sat, 23 Feb 2013 10:58:08 -0500 Subject: moved ui to it's own repo --- MediaBrowser.UI/Controller/UIKernel.cs | 181 --------------------------------- 1 file changed, 181 deletions(-) delete mode 100644 MediaBrowser.UI/Controller/UIKernel.cs (limited to 'MediaBrowser.UI/Controller/UIKernel.cs') diff --git a/MediaBrowser.UI/Controller/UIKernel.cs b/MediaBrowser.UI/Controller/UIKernel.cs deleted file mode 100644 index 118067140..000000000 --- a/MediaBrowser.UI/Controller/UIKernel.cs +++ /dev/null @@ -1,181 +0,0 @@ -using MediaBrowser.ApiInteraction; -using MediaBrowser.Common.Kernel; -using MediaBrowser.Model.Connectivity; -using MediaBrowser.Model.Logging; -using MediaBrowser.Model.Net; -using MediaBrowser.UI.Configuration; -using MediaBrowser.UI.Playback; -using System; -using System.Collections.Generic; -using System.Net; -using System.Net.Cache; -using System.Net.Http; -using System.Threading.Tasks; - -namespace MediaBrowser.UI.Controller -{ - /// - /// This controls application logic as well as server interaction within the UI. - /// - public class UIKernel : BaseKernel - { - /// - /// Gets the instance. - /// - /// The instance. - public static UIKernel Instance { get; private set; } - - /// - /// Gets the API client. - /// - /// The API client. - public ApiClient ApiClient { get; private set; } - - /// - /// Gets the playback manager. - /// - /// The playback manager. - public PlaybackManager PlaybackManager { get; private set; } - - /// - /// Initializes a new instance of the class. - /// - public UIKernel(IApplicationHost appHost, ILogger logger) - : base(appHost, logger) - { - Instance = this; - } - - /// - /// Gets the media players. - /// - /// The media players. - public IEnumerable MediaPlayers { get; private set; } - - /// - /// Gets the list of currently loaded themes - /// - /// The themes. - public IEnumerable Themes { get; private set; } - - /// - /// Gets the kernel context. - /// - /// The kernel context. - public override KernelContext KernelContext - { - get { return KernelContext.Ui; } - } - - /// - /// Gets the UDP server port number. - /// - /// The UDP server port number. - public override int UdpServerPortNumber - { - get { return 7360; } - } - - /// - /// Give the UI a different url prefix so that they can share the same port, in case they are installed on the same machine. - /// - /// The HTTP server URL prefix. - public override string HttpServerUrlPrefix - { - get - { - return "http://+:" + Configuration.HttpServerPortNumber + "/mediabrowserui/"; - } - } - - /// - /// Reload api client and update plugins after loading configuration - /// - /// Task. - protected override async Task OnConfigurationLoaded() - { - ReloadApiClient(); - - try - { - await new PluginUpdater(Logger).UpdatePlugins().ConfigureAwait(false); - } - catch (HttpException ex) - { - Logger.ErrorException("Error updating plugins from the server", ex); - } - } - - /// - /// Disposes the current ApiClient and creates a new one - /// - private void ReloadApiClient() - { - DisposeApiClient(); - - ApiClient = new ApiClient(Logger, new AsyncHttpClient(new WebRequestHandler - { - AutomaticDecompression = DecompressionMethods.Deflate, - CachePolicy = new RequestCachePolicy(RequestCacheLevel.Revalidate) - })) - { - ServerHostName = Configuration.ServerHostName, - ServerApiPort = Configuration.ServerApiPort, - ClientType = ClientType.Pc, - DeviceName = Environment.MachineName, - SerializationFormat = SerializationFormats.Json - }; - } - - /// - /// Finds the parts. - /// - /// All types. - protected override void FindParts(Type[] allTypes) - { - PlaybackManager = (PlaybackManager)ApplicationHost.CreateInstance(typeof(PlaybackManager)); - - base.FindParts(allTypes); - - Themes = GetExports(allTypes); - MediaPlayers = GetExports(allTypes); - } - - /// - /// Called when [composable parts loaded]. - /// - /// Task. - protected override async Task OnComposablePartsLoaded() - { - await base.OnComposablePartsLoaded().ConfigureAwait(false); - - // Once plugins have loaded give the api a reference to our protobuf serializer - DataSerializer.DynamicSerializer = ProtobufSerializer.TypeModel; - } - - /// - /// Disposes the current ApiClient - /// - private void DisposeApiClient() - { - if (ApiClient != null) - { - ApiClient.Dispose(); - } - } - - /// - /// Releases unmanaged and - optionally - managed resources. - /// - /// true to release both managed and unmanaged resources; false to release only unmanaged resources. - protected override void Dispose(bool dispose) - { - if (dispose) - { - DisposeApiClient(); - } - - base.Dispose(dispose); - } - } -} -- cgit v1.2.3