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: [PATCH] Added new api handlers to get plugin information --- MediaBrowser.Api/HttpHandlers/MediaHandler.cs | 101 ------------------ .../PluginConfigurationHandler.cs | 19 ++++ .../HttpHandlers/PluginsHandler.cs | 37 +++++++ MediaBrowser.Api/MediaBrowser.Api.csproj | 3 +- MediaBrowser.Api/Plugin.cs | 22 ++-- MediaBrowser.Api/Properties/AssemblyInfo.cs | 2 +- .../MediaBrowser.Common.csproj | 2 - MediaBrowser.Common/Plugins/BasePlugin.cs | 88 +++++++++++---- .../Plugins/BasePluginConfiguration.cs | 13 --- .../Plugins/PluginController.cs | 38 +++++-- .../MediaBrowser.Configuration.csproj | 4 + MediaBrowser.Configuration/Plugin.cs | 6 +- .../Properties/AssemblyInfo.cs | 2 +- .../Configuration/ServerConfiguration.cs | 1 + .../ServerConfigurationController.cs | 5 +- MediaBrowser.Controller/Kernel.cs | 2 +- MediaBrowser.HtmlBrowser/Plugin.cs | 16 +-- .../Properties/AssemblyInfo.cs | 2 +- .../MediaBrowser.InternetProviders.csproj | 4 + MediaBrowser.InternetProviders/Plugin.cs | 9 +- .../PluginConfiguration.cs | 2 +- .../Properties/AssemblyInfo.cs | 2 +- .../Configuration/UserConfiguration.cs | 9 +- MediaBrowser.Model/MediaBrowser.Model.csproj | 3 + .../Plugins/BasePluginConfiguration.cs | 18 ++++ MediaBrowser.Model/Plugins/PluginInfo.cs | 17 +++ MediaBrowser.Movies/Plugin.cs | 10 +- .../Properties/AssemblyInfo.cs | 2 +- MediaBrowser.TV/Plugin.cs | 15 ++- MediaBrowser.TV/Properties/AssemblyInfo.cs | 2 +- 30 files changed, 266 insertions(+), 190 deletions(-) delete mode 100644 MediaBrowser.Api/HttpHandlers/MediaHandler.cs create mode 100644 MediaBrowser.Api/HttpHandlers/PluginConfigurationHandler.cs create mode 100644 MediaBrowser.Api/HttpHandlers/PluginsHandler.cs delete mode 100644 MediaBrowser.Common/Plugins/BasePluginConfiguration.cs rename {MediaBrowser.Common => MediaBrowser.Model}/Configuration/UserConfiguration.cs (62%) create mode 100644 MediaBrowser.Model/Plugins/BasePluginConfiguration.cs create mode 100644 MediaBrowser.Model/Plugins/PluginInfo.cs diff --git a/MediaBrowser.Api/HttpHandlers/MediaHandler.cs b/MediaBrowser.Api/HttpHandlers/MediaHandler.cs deleted file mode 100644 index 73f8de7d82..0000000000 --- a/MediaBrowser.Api/HttpHandlers/MediaHandler.cs +++ /dev/null @@ -1,101 +0,0 @@ -using System; -using System.IO; -using MediaBrowser.Common.Net.Handlers; -using MediaBrowser.Model.Entities; - -namespace MediaBrowser.Api.HttpHandlers -{ - class MediaHandler : BaseHandler - { - private string _MediaPath = string.Empty; - private string MediaPath - { - get - { - if (string.IsNullOrEmpty(_MediaPath)) - { - _MediaPath = GetMediaPath(); - } - - return _MediaPath; - } - } - - private string GetMediaPath() - { - string path = QueryString["path"] ?? string.Empty; - - if (!string.IsNullOrEmpty(path)) - { - return path; - } - - BaseItem item = ApiService.GetItemById(QueryString["id"]); - - return item.Path; - } - - public override bool GzipResponse - { - get - { - return false; - } - } - - public override string ContentType - { - get - { - // http://www.codingcereal.com/2011/10/an-array-of-45-video-mime-types/ - - string extension = Path.GetExtension(MediaPath); - - if (extension.EndsWith("mkv", StringComparison.OrdinalIgnoreCase)) - { - return "video/x-matroska"; - } - else if (extension.EndsWith("avi", StringComparison.OrdinalIgnoreCase)) - { - return "video/avi"; - } - else if (extension.EndsWith("wmv", StringComparison.OrdinalIgnoreCase)) - { - return "video/wmv"; - } - else if (extension.EndsWith("m4v", StringComparison.OrdinalIgnoreCase)) - { - return "video/m4v"; - } - else if (extension.EndsWith("flv", StringComparison.OrdinalIgnoreCase)) - { - return "video/flv"; - } - else if (extension.EndsWith("mov", StringComparison.OrdinalIgnoreCase)) - { - return "video/quicktime"; - } - else if (extension.EndsWith("mp4", StringComparison.OrdinalIgnoreCase)) - { - return "video/mp4"; - } - - return "video/x-matroska"; - } - } - - protected override void WriteResponseToOutputStream(Stream stream) - { - try - { - using (Stream input = File.OpenRead(MediaPath)) - { - input.CopyTo(stream); - } - } - catch - { - } - } - } -} diff --git a/MediaBrowser.Api/HttpHandlers/PluginConfigurationHandler.cs b/MediaBrowser.Api/HttpHandlers/PluginConfigurationHandler.cs new file mode 100644 index 0000000000..9e5657e3c2 --- /dev/null +++ b/MediaBrowser.Api/HttpHandlers/PluginConfigurationHandler.cs @@ -0,0 +1,19 @@ +using System; +using System.Linq; +using MediaBrowser.Controller; + +namespace MediaBrowser.Api.HttpHandlers +{ + public class PluginConfigurationHandler : JsonHandler + { + protected override object ObjectToSerialize + { + get + { + string pluginName = QueryString["name"]; + + return Kernel.Instance.PluginController.Plugins.First(p => p.Name.Equals(pluginName, StringComparison.OrdinalIgnoreCase)).Configuration; + } + } + } +} diff --git a/MediaBrowser.Api/HttpHandlers/PluginsHandler.cs b/MediaBrowser.Api/HttpHandlers/PluginsHandler.cs new file mode 100644 index 0000000000..a558da163d --- /dev/null +++ b/MediaBrowser.Api/HttpHandlers/PluginsHandler.cs @@ -0,0 +1,37 @@ +using System.Linq; +using MediaBrowser.Controller; +using MediaBrowser.Model.Plugins; + +namespace MediaBrowser.Api.HttpHandlers +{ + /// + /// Provides information about installed plugins + /// + public class PluginsHandler : JsonHandler + { + protected override object ObjectToSerialize + { + get + { + var plugins = Kernel.Instance.PluginController.Plugins.Select(p => + { + return new PluginInfo() + { + Path = p.Path, + Name = p.Name, + Enabled = p.Enabled, + DownloadToUI = p.DownloadToUI, + Version = p.Version + }; + }); + + if (QueryString["uionly"] == "1") + { + plugins = plugins.Where(p => p.DownloadToUI); + } + + return plugins; + } + } + } +} diff --git a/MediaBrowser.Api/MediaBrowser.Api.csproj b/MediaBrowser.Api/MediaBrowser.Api.csproj index a803cb73a4..25889f9837 100644 --- a/MediaBrowser.Api/MediaBrowser.Api.csproj +++ b/MediaBrowser.Api/MediaBrowser.Api.csproj @@ -54,13 +54,14 @@ + + - diff --git a/MediaBrowser.Api/Plugin.cs b/MediaBrowser.Api/Plugin.cs index 6c2e9df7ec..6ced7a704a 100644 --- a/MediaBrowser.Api/Plugin.cs +++ b/MediaBrowser.Api/Plugin.cs @@ -5,12 +5,18 @@ using MediaBrowser.Common.Net; using MediaBrowser.Common.Net.Handlers; using MediaBrowser.Common.Plugins; using MediaBrowser.Controller; +using MediaBrowser.Model.Plugins; namespace MediaBrowser.Api { - public class Plugin : BasePlugin + public class Plugin : BaseGenericPlugin { - protected override void InitInternal() + public override string Name + { + get { return "WebAPI"; } + } + + public override void InitInServer() { var httpServer = Kernel.Instance.HttpServer; @@ -43,10 +49,6 @@ namespace MediaBrowser.Api { handler = new UsersHandler(); } - else if (localPath.EndsWith("/api/media", StringComparison.OrdinalIgnoreCase)) - { - handler = new MediaHandler(); - } else if (localPath.EndsWith("/api/genre", StringComparison.OrdinalIgnoreCase)) { handler = new GenreHandler(); @@ -75,6 +77,14 @@ namespace MediaBrowser.Api { handler = new UserConfigurationHandler(); } + else if (localPath.EndsWith("/api/plugins", StringComparison.OrdinalIgnoreCase)) + { + handler = new PluginsHandler(); + } + else if (localPath.EndsWith("/api/pluginconfiguration", StringComparison.OrdinalIgnoreCase)) + { + handler = new PluginConfigurationHandler(); + } if (handler != null) { diff --git a/MediaBrowser.Api/Properties/AssemblyInfo.cs b/MediaBrowser.Api/Properties/AssemblyInfo.cs index 0a7a85dc66..bd747ea7da 100644 --- a/MediaBrowser.Api/Properties/AssemblyInfo.cs +++ b/MediaBrowser.Api/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/MediaBrowser.Common/MediaBrowser.Common.csproj b/MediaBrowser.Common/MediaBrowser.Common.csproj index 01d89d0f55..f7a223f1f5 100644 --- a/MediaBrowser.Common/MediaBrowser.Common.csproj +++ b/MediaBrowser.Common/MediaBrowser.Common.csproj @@ -49,7 +49,6 @@ - @@ -63,7 +62,6 @@ - diff --git a/MediaBrowser.Common/Plugins/BasePlugin.cs b/MediaBrowser.Common/Plugins/BasePlugin.cs index be72dabca3..7fdb2583ee 100644 --- a/MediaBrowser.Common/Plugins/BasePlugin.cs +++ b/MediaBrowser.Common/Plugins/BasePlugin.cs @@ -1,49 +1,97 @@ -using System.IO; +using System; +using System.IO; using MediaBrowser.Common.Json; +using MediaBrowser.Model.Plugins; namespace MediaBrowser.Common.Plugins { - public abstract class BasePlugin : IPlugin + /// + /// Provides a BasePlugin with generics, allowing for strongly typed configuration access. + /// + public abstract class BaseGenericPlugin : BasePlugin where TConfigurationType : BasePluginConfiguration, new() { + public new TConfigurationType Configuration + { + get + { + return base.Configuration as TConfigurationType; + } + set + { + base.Configuration = value; + } + } + + public override void ReloadConfiguration() + { + if (!File.Exists(ConfigurationPath)) + { + Configuration = new TConfigurationType(); + } + else + { + Configuration = JsonSerializer.DeserializeFromFile(ConfigurationPath); + Configuration.DateLastModified = File.GetLastWriteTime(ConfigurationPath); + } + } + } + + /// + /// Provides a common base class for all plugins + /// + public abstract class BasePlugin + { + public abstract string Name { get; } public string Path { get; set; } - public TConfigurationType Configuration { get; private set; } + public Version Version { get; set; } - private string ConfigurationPath + public BasePluginConfiguration Configuration { get; protected set; } + + protected string ConfigurationPath { get { return System.IO.Path.Combine(Path, "config.js"); } } - - public void Init() - { - Configuration = GetConfiguration(); - if (Configuration.Enabled) + public bool Enabled + { + get { - InitInternal(); + return Configuration.Enabled; } } - protected abstract void InitInternal(); + public DateTime ConfigurationDateLastModified + { + get + { + return Configuration.DateLastModified; + } + } - private TConfigurationType GetConfiguration() + /// + /// Returns true or false indicating if the plugin should be downloaded and run within the UI. + /// + public virtual bool DownloadToUI { - if (!File.Exists(ConfigurationPath)) + get { - return new TConfigurationType(); + return false; } + } - return JsonSerializer.DeserializeFromFile(ConfigurationPath); + public abstract void ReloadConfiguration(); + + public virtual void InitInServer() + { } - } - public interface IPlugin - { - string Path { get; set; } + public virtual void InitInUI() + { + } - void Init(); } } diff --git a/MediaBrowser.Common/Plugins/BasePluginConfiguration.cs b/MediaBrowser.Common/Plugins/BasePluginConfiguration.cs deleted file mode 100644 index d3e47c84a4..0000000000 --- a/MediaBrowser.Common/Plugins/BasePluginConfiguration.cs +++ /dev/null @@ -1,13 +0,0 @@ - -namespace MediaBrowser.Common.Plugins -{ - public class BasePluginConfiguration - { - public bool Enabled { get; set; } - - public BasePluginConfiguration() - { - Enabled = true; - } - } -} diff --git a/MediaBrowser.Common/Plugins/PluginController.cs b/MediaBrowser.Common/Plugins/PluginController.cs index 1f83d485b0..c26275436b 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; diff --git a/MediaBrowser.Configuration/MediaBrowser.Configuration.csproj b/MediaBrowser.Configuration/MediaBrowser.Configuration.csproj index b94672537b..98b179f355 100644 --- a/MediaBrowser.Configuration/MediaBrowser.Configuration.csproj +++ b/MediaBrowser.Configuration/MediaBrowser.Configuration.csproj @@ -55,6 +55,10 @@ {17e1f4e6-8abd-4fe5-9ecf-43d4b6087ba2} MediaBrowser.Controller + + {7eeeb4bb-f3e8-48fc-b4c5-70f0fff8329b} + MediaBrowser.Model + diff --git a/MediaBrowser.Configuration/Plugin.cs b/MediaBrowser.Configuration/Plugin.cs index a16ad064b4..f88dc7a4ca 100644 --- a/MediaBrowser.Configuration/Plugin.cs +++ b/MediaBrowser.Configuration/Plugin.cs @@ -1,11 +1,13 @@ using MediaBrowser.Common.Plugins; +using MediaBrowser.Model.Plugins; namespace MediaBrowser.Configuration { - public class Plugin : BasePlugin + public class Plugin : BaseGenericPlugin { - protected override void InitInternal() + public override string Name { + get { return "Web-based Configuration"; } } } } diff --git a/MediaBrowser.Configuration/Properties/AssemblyInfo.cs b/MediaBrowser.Configuration/Properties/AssemblyInfo.cs index 5212f26db7..919388d51d 100644 --- a/MediaBrowser.Configuration/Properties/AssemblyInfo.cs +++ b/MediaBrowser.Configuration/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/MediaBrowser.Controller/Configuration/ServerConfiguration.cs b/MediaBrowser.Controller/Configuration/ServerConfiguration.cs index 73727b393f..818c69eed2 100644 --- a/MediaBrowser.Controller/Configuration/ServerConfiguration.cs +++ b/MediaBrowser.Controller/Configuration/ServerConfiguration.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using MediaBrowser.Common.Configuration; +using MediaBrowser.Model.Configuration; namespace MediaBrowser.Controller.Configuration { diff --git a/MediaBrowser.Controller/Configuration/ServerConfigurationController.cs b/MediaBrowser.Controller/Configuration/ServerConfigurationController.cs index 6f262a32e8..76c3cc43ce 100644 --- a/MediaBrowser.Controller/Configuration/ServerConfigurationController.cs +++ b/MediaBrowser.Controller/Configuration/ServerConfigurationController.cs @@ -1,9 +1,6 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using MediaBrowser.Common.Configuration; +using MediaBrowser.Model.Configuration; namespace MediaBrowser.Controller.Configuration { diff --git a/MediaBrowser.Controller/Kernel.cs b/MediaBrowser.Controller/Kernel.cs index 468e7ab2f4..8b2688da74 100644 --- a/MediaBrowser.Controller/Kernel.cs +++ b/MediaBrowser.Controller/Kernel.cs @@ -5,13 +5,13 @@ using System.Linq; using System.Security.Cryptography; using System.Text; using System.Threading.Tasks; -using MediaBrowser.Common.Configuration; using MediaBrowser.Common.Kernel; using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Events; using MediaBrowser.Controller.IO; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Resolvers; +using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Entities; using MediaBrowser.Model.Users; diff --git a/MediaBrowser.HtmlBrowser/Plugin.cs b/MediaBrowser.HtmlBrowser/Plugin.cs index b8296492fb..57e2886f93 100644 --- a/MediaBrowser.HtmlBrowser/Plugin.cs +++ b/MediaBrowser.HtmlBrowser/Plugin.cs @@ -1,15 +1,17 @@ -using System; -using System.Reactive.Linq; -using MediaBrowser.Common.Net.Handlers; -using MediaBrowser.Common.Plugins; +using MediaBrowser.Common.Plugins; using MediaBrowser.Controller; -using MediaBrowser.HtmlBrowser.Handlers; +using MediaBrowser.Model.Plugins; namespace MediaBrowser.HtmlBrowser { - public class Plugin : BasePlugin + public class Plugin : BaseGenericPlugin { - protected override void InitInternal() + public override string Name + { + get { return "Html Library Browser"; } + } + + public override void InitInServer() { var httpServer = Kernel.Instance.HttpServer; diff --git a/MediaBrowser.HtmlBrowser/Properties/AssemblyInfo.cs b/MediaBrowser.HtmlBrowser/Properties/AssemblyInfo.cs index b65ea6f779..538756b974 100644 --- a/MediaBrowser.HtmlBrowser/Properties/AssemblyInfo.cs +++ b/MediaBrowser.HtmlBrowser/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/MediaBrowser.InternetProviders/MediaBrowser.InternetProviders.csproj b/MediaBrowser.InternetProviders/MediaBrowser.InternetProviders.csproj index 3b88a5b56b..c37218f851 100644 --- a/MediaBrowser.InternetProviders/MediaBrowser.InternetProviders.csproj +++ b/MediaBrowser.InternetProviders/MediaBrowser.InternetProviders.csproj @@ -52,6 +52,10 @@ {17e1f4e6-8abd-4fe5-9ecf-43d4b6087ba2} MediaBrowser.Controller + + {7eeeb4bb-f3e8-48fc-b4c5-70f0fff8329b} + MediaBrowser.Model + {92b9f802-4415-438f-90e1-44602135ea41} MediaBrowser.Movies diff --git a/MediaBrowser.InternetProviders/Plugin.cs b/MediaBrowser.InternetProviders/Plugin.cs index c7b981aed0..837b698311 100644 --- a/MediaBrowser.InternetProviders/Plugin.cs +++ b/MediaBrowser.InternetProviders/Plugin.cs @@ -2,9 +2,14 @@ namespace MediaBrowser.InternetProviders { - public class Plugin : BasePlugin + public class Plugin : BaseGenericPlugin { - protected override void InitInternal() + public override string Name + { + get { return "Internet Providers"; } + } + + public override void InitInServer() { } } diff --git a/MediaBrowser.InternetProviders/PluginConfiguration.cs b/MediaBrowser.InternetProviders/PluginConfiguration.cs index abd189f2a2..bf9c04b724 100644 --- a/MediaBrowser.InternetProviders/PluginConfiguration.cs +++ b/MediaBrowser.InternetProviders/PluginConfiguration.cs @@ -1,4 +1,4 @@ -using MediaBrowser.Common.Plugins; +using MediaBrowser.Model.Plugins; namespace MediaBrowser.InternetProviders { diff --git a/MediaBrowser.InternetProviders/Properties/AssemblyInfo.cs b/MediaBrowser.InternetProviders/Properties/AssemblyInfo.cs index 859fc6ef9a..ff041feccd 100644 --- a/MediaBrowser.InternetProviders/Properties/AssemblyInfo.cs +++ b/MediaBrowser.InternetProviders/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/MediaBrowser.Common/Configuration/UserConfiguration.cs b/MediaBrowser.Model/Configuration/UserConfiguration.cs similarity index 62% rename from MediaBrowser.Common/Configuration/UserConfiguration.cs rename to MediaBrowser.Model/Configuration/UserConfiguration.cs index 0cdc810a6a..5616f6dd60 100644 --- a/MediaBrowser.Common/Configuration/UserConfiguration.cs +++ b/MediaBrowser.Model/Configuration/UserConfiguration.cs @@ -1,10 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace MediaBrowser.Common.Configuration + +namespace MediaBrowser.Model.Configuration { /// /// This holds settings that can be personalized on a per-user, per-device basis. diff --git a/MediaBrowser.Model/MediaBrowser.Model.csproj b/MediaBrowser.Model/MediaBrowser.Model.csproj index b41b54c0bf..ceb58163ab 100644 --- a/MediaBrowser.Model/MediaBrowser.Model.csproj +++ b/MediaBrowser.Model/MediaBrowser.Model.csproj @@ -35,6 +35,7 @@ + @@ -45,6 +46,8 @@ + + diff --git a/MediaBrowser.Model/Plugins/BasePluginConfiguration.cs b/MediaBrowser.Model/Plugins/BasePluginConfiguration.cs new file mode 100644 index 0000000000..7881de598b --- /dev/null +++ b/MediaBrowser.Model/Plugins/BasePluginConfiguration.cs @@ -0,0 +1,18 @@ +using System; +using System.Runtime.Serialization; + +namespace MediaBrowser.Model.Plugins +{ + public class BasePluginConfiguration + { + public bool Enabled { get; set; } + + [IgnoreDataMember] + public DateTime DateLastModified { get; set; } + + public BasePluginConfiguration() + { + Enabled = true; + } + } +} diff --git a/MediaBrowser.Model/Plugins/PluginInfo.cs b/MediaBrowser.Model/Plugins/PluginInfo.cs new file mode 100644 index 0000000000..e08128fd7b --- /dev/null +++ b/MediaBrowser.Model/Plugins/PluginInfo.cs @@ -0,0 +1,17 @@ +using System; + +namespace MediaBrowser.Model.Plugins +{ + /// + /// This is a serializable stub class that is used by the api to provide information about installed plugins. + /// + public class PluginInfo + { + public string Name { get; set; } + public string Path { get; set; } + public bool Enabled { get; set; } + public bool DownloadToUI { get; set; } + public DateTime ConfigurationDateLastModified { get; set; } + public Version Version { get; set; } + } +} diff --git a/MediaBrowser.Movies/Plugin.cs b/MediaBrowser.Movies/Plugin.cs index df80dfaa8d..54e8279b21 100644 --- a/MediaBrowser.Movies/Plugin.cs +++ b/MediaBrowser.Movies/Plugin.cs @@ -1,13 +1,19 @@ using MediaBrowser.Common.Plugins; using MediaBrowser.Controller; +using MediaBrowser.Model.Plugins; using MediaBrowser.Movies.Entities; using MediaBrowser.Movies.Resolvers; namespace MediaBrowser.Movies { - public class Plugin : BasePlugin + public class Plugin : BaseGenericPlugin { - protected override void InitInternal() + public override string Name + { + get { return "Movies"; } + } + + public override void InitInServer() { Kernel.Instance.AddBaseItemType(); Kernel.Instance.AddBaseItemType(); diff --git a/MediaBrowser.Movies/Properties/AssemblyInfo.cs b/MediaBrowser.Movies/Properties/AssemblyInfo.cs index bc9c6b006a..351928efc2 100644 --- a/MediaBrowser.Movies/Properties/AssemblyInfo.cs +++ b/MediaBrowser.Movies/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/MediaBrowser.TV/Plugin.cs b/MediaBrowser.TV/Plugin.cs index d003b04f6c..e68e737401 100644 --- a/MediaBrowser.TV/Plugin.cs +++ b/MediaBrowser.TV/Plugin.cs @@ -1,16 +1,21 @@ -using MediaBrowser.Common.Plugins; +using System; +using MediaBrowser.Common.Plugins; using MediaBrowser.Controller; using MediaBrowser.Controller.Events; -using MediaBrowser.Model.Entities; +using MediaBrowser.Model.Plugins; using MediaBrowser.TV.Entities; using MediaBrowser.TV.Resolvers; -using System; namespace MediaBrowser.TV { - public class Plugin : BasePlugin + public class Plugin : BaseGenericPlugin { - protected override void InitInternal() + public override string Name + { + get { return "TV"; } + } + + public override void InitInServer() { Kernel.Instance.AddBaseItemType(); Kernel.Instance.AddBaseItemType(); diff --git a/MediaBrowser.TV/Properties/AssemblyInfo.cs b/MediaBrowser.TV/Properties/AssemblyInfo.cs index d92a7f5762..ebc70e3a2e 100644 --- a/MediaBrowser.TV/Properties/AssemblyInfo.cs +++ b/MediaBrowser.TV/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyFileVersion("1.0.0.0")]