diff --git a/MediaBrowser.Api/Plugin.cs b/MediaBrowser.Api/Plugin.cs index 7005b8f8a..e83f366df 100644 --- a/MediaBrowser.Api/Plugin.cs +++ b/MediaBrowser.Api/Plugin.cs @@ -18,7 +18,7 @@ namespace MediaBrowser.Api get { return "Media Browser API"; } } - protected override void InitializeInternal() + protected override void InitializeOnServer() { var httpServer = Kernel.Instance.HttpServer; diff --git a/MediaBrowser.Common/Plugins/BasePlugin.cs b/MediaBrowser.Common/Plugins/BasePlugin.cs index 55f092666..705e15f17 100644 --- a/MediaBrowser.Common/Plugins/BasePlugin.cs +++ b/MediaBrowser.Common/Plugins/BasePlugin.cs @@ -184,22 +184,58 @@ namespace MediaBrowser.Common.Plugins if (Enabled) { - InitializeInternal(); + if (kernel.KernelContext == KernelContext.Server) + { + InitializeOnServer(); + } + else if (kernel.KernelContext == KernelContext.UI) + { + InitializeInUI(); + } } } } /// - /// Starts the plugin. + /// Starts the plugin on the server /// - protected virtual void InitializeInternal() + protected virtual void InitializeOnServer() + { + } + + /// + /// Starts the plugin in the UI + /// + protected virtual void InitializeInUI() { } /// /// Disposes the plugins. Undos all actions performed during Init. /// - public virtual void Dispose() + public void Dispose() + { + if (Context == KernelContext.Server) + { + DisposeOnServer(); + } + else if (Context == KernelContext.UI) + { + InitializeInUI(); + } + } + + /// + /// Disposes the plugin on the server + /// + protected virtual void DisposeOnServer() + { + } + + /// + /// Disposes the plugin in the UI + /// + protected virtual void DisposeInUI() { } diff --git a/MediaBrowser.TV/Plugin.cs b/MediaBrowser.TV/Plugin.cs index 75a108b2d..c4ae87cae 100644 --- a/MediaBrowser.TV/Plugin.cs +++ b/MediaBrowser.TV/Plugin.cs @@ -16,12 +16,12 @@ namespace MediaBrowser.TV get { return "TV"; } } - protected override void InitializeInternal() + protected override void InitializeOnServer() { Kernel.Instance.ItemController.PreBeginResolvePath += ItemController_PreBeginResolvePath; } - public override void Dispose() + protected override void DisposeOnServer() { Kernel.Instance.ItemController.PreBeginResolvePath -= ItemController_PreBeginResolvePath; }