From 84af205572e6ab9ca3e10f6de33cbce278e01335 Mon Sep 17 00:00:00 2001 From: LukePulverenti Luke Pulverenti luke pulverenti Date: Tue, 24 Jul 2012 10:54:34 -0400 Subject: Added new api handlers to get plugin information --- MediaBrowser.Common/Plugins/PluginController.cs | 38 ++++++++++++++++++------- 1 file changed, 28 insertions(+), 10 deletions(-) (limited to 'MediaBrowser.Common/Plugins/PluginController.cs') diff --git a/MediaBrowser.Common/Plugins/PluginController.cs b/MediaBrowser.Common/Plugins/PluginController.cs index 1f83d485b..c26275436 100644 --- a/MediaBrowser.Common/Plugins/PluginController.cs +++ b/MediaBrowser.Common/Plugins/PluginController.cs @@ -18,7 +18,7 @@ namespace MediaBrowser.Common.Plugins /// /// Gets the list of currently loaded plugins /// - public IEnumerable Plugins { get; private set; } + public IEnumerable Plugins { get; private set; } /// /// Initializes the controller @@ -32,7 +32,21 @@ namespace MediaBrowser.Common.Plugins Parallel.For(0, Plugins.Count(), i => { - Plugins.ElementAt(i).Init(); + var plugin = Plugins.ElementAt(i); + + plugin.ReloadConfiguration(); + + if (plugin.Enabled) + { + if (context == KernelContext.Server) + { + plugin.InitInServer(); + } + else + { + plugin.InitInUI(); + } + } }); } @@ -40,18 +54,18 @@ namespace MediaBrowser.Common.Plugins /// Gets all plugins within PluginsPath /// /// - private IEnumerable GetAllPlugins() + private IEnumerable GetAllPlugins() { if (!Directory.Exists(PluginsPath)) { Directory.CreateDirectory(PluginsPath); } - List plugins = new List(); + List plugins = new List(); foreach (string folder in Directory.GetDirectories(PluginsPath, "*", SearchOption.TopDirectoryOnly)) { - IPlugin plugin = GetPluginFromDirectory(folder); + BasePlugin plugin = GetPluginFromDirectory(folder); plugin.Path = folder; @@ -64,7 +78,7 @@ namespace MediaBrowser.Common.Plugins return plugins; } - private IPlugin GetPluginFromDirectory(string path) + private BasePlugin GetPluginFromDirectory(string path) { string dll = Directory.GetFiles(path, "*.dll", SearchOption.TopDirectoryOnly).FirstOrDefault(); @@ -76,18 +90,22 @@ namespace MediaBrowser.Common.Plugins return null; } - private IPlugin GetPluginFromDll(string path) + private BasePlugin GetPluginFromDll(string path) { return GetPluginFromDll(Assembly.Load(File.ReadAllBytes(path))); } - private IPlugin GetPluginFromDll(Assembly assembly) + private BasePlugin GetPluginFromDll(Assembly assembly) { - var plugin = assembly.GetTypes().Where(type => typeof(IPlugin).IsAssignableFrom(type)).FirstOrDefault(); + var plugin = assembly.GetTypes().Where(type => typeof(BasePlugin).IsAssignableFrom(type)).FirstOrDefault(); if (plugin != null) { - return plugin.GetConstructor(Type.EmptyTypes).Invoke(null) as IPlugin; + BasePlugin instance = plugin.GetConstructor(Type.EmptyTypes).Invoke(null) as BasePlugin; + + instance.Version = assembly.GetName().Version; + + return instance; } return null; -- cgit v1.2.3