瀏覽代碼

Added new api handlers to get plugin information

LukePulverenti Luke Pulverenti luke pulverenti 13 年之前
父節點
當前提交
84af205572
共有 30 個文件被更改,包括 266 次插入190 次删除
  1. 0 101
      MediaBrowser.Api/HttpHandlers/MediaHandler.cs
  2. 19 0
      MediaBrowser.Api/HttpHandlers/PluginConfigurationHandler.cs
  3. 37 0
      MediaBrowser.Api/HttpHandlers/PluginsHandler.cs
  4. 2 1
      MediaBrowser.Api/MediaBrowser.Api.csproj
  5. 16 6
      MediaBrowser.Api/Plugin.cs
  6. 1 1
      MediaBrowser.Api/Properties/AssemblyInfo.cs
  7. 0 2
      MediaBrowser.Common/MediaBrowser.Common.csproj
  8. 68 20
      MediaBrowser.Common/Plugins/BasePlugin.cs
  9. 0 13
      MediaBrowser.Common/Plugins/BasePluginConfiguration.cs
  10. 28 10
      MediaBrowser.Common/Plugins/PluginController.cs
  11. 4 0
      MediaBrowser.Configuration/MediaBrowser.Configuration.csproj
  12. 4 2
      MediaBrowser.Configuration/Plugin.cs
  13. 1 1
      MediaBrowser.Configuration/Properties/AssemblyInfo.cs
  14. 1 0
      MediaBrowser.Controller/Configuration/ServerConfiguration.cs
  15. 1 4
      MediaBrowser.Controller/Configuration/ServerConfigurationController.cs
  16. 1 1
      MediaBrowser.Controller/Kernel.cs
  17. 9 7
      MediaBrowser.HtmlBrowser/Plugin.cs
  18. 1 1
      MediaBrowser.HtmlBrowser/Properties/AssemblyInfo.cs
  19. 4 0
      MediaBrowser.InternetProviders/MediaBrowser.InternetProviders.csproj
  20. 7 2
      MediaBrowser.InternetProviders/Plugin.cs
  21. 1 1
      MediaBrowser.InternetProviders/PluginConfiguration.cs
  22. 1 1
      MediaBrowser.InternetProviders/Properties/AssemblyInfo.cs
  23. 2 7
      MediaBrowser.Model/Configuration/UserConfiguration.cs
  24. 3 0
      MediaBrowser.Model/MediaBrowser.Model.csproj
  25. 18 0
      MediaBrowser.Model/Plugins/BasePluginConfiguration.cs
  26. 17 0
      MediaBrowser.Model/Plugins/PluginInfo.cs
  27. 8 2
      MediaBrowser.Movies/Plugin.cs
  28. 1 1
      MediaBrowser.Movies/Properties/AssemblyInfo.cs
  29. 10 5
      MediaBrowser.TV/Plugin.cs
  30. 1 1
      MediaBrowser.TV/Properties/AssemblyInfo.cs

+ 0 - 101
MediaBrowser.Api/HttpHandlers/MediaHandler.cs

@@ -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
-            {
-            }
-        }
-    }
-}

+ 19 - 0
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;
+            }
+        }
+    }
+}

+ 37 - 0
MediaBrowser.Api/HttpHandlers/PluginsHandler.cs

@@ -0,0 +1,37 @@
+using System.Linq;
+using MediaBrowser.Controller;
+using MediaBrowser.Model.Plugins;
+
+namespace MediaBrowser.Api.HttpHandlers
+{
+    /// <summary>
+    /// Provides information about installed plugins
+    /// </summary>
+    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;
+            }
+        }
+    }
+}

+ 2 - 1
MediaBrowser.Api/MediaBrowser.Api.csproj

@@ -54,13 +54,14 @@
     <Compile Include="HttpHandlers\ItemListHandler.cs" />
     <Compile Include="HttpHandlers\ItemListHandler.cs" />
     <Compile Include="HttpHandlers\JsonHandler.cs" />
     <Compile Include="HttpHandlers\JsonHandler.cs" />
     <Compile Include="HttpHandlers\PersonHandler.cs" />
     <Compile Include="HttpHandlers\PersonHandler.cs" />
+    <Compile Include="HttpHandlers\PluginConfigurationHandler.cs" />
+    <Compile Include="HttpHandlers\PluginsHandler.cs" />
     <Compile Include="HttpHandlers\RecentlyAddedItemsHandler.cs" />
     <Compile Include="HttpHandlers\RecentlyAddedItemsHandler.cs" />
     <Compile Include="HttpHandlers\StudioHandler.cs" />
     <Compile Include="HttpHandlers\StudioHandler.cs" />
     <Compile Include="HttpHandlers\StudiosHandler.cs" />
     <Compile Include="HttpHandlers\StudiosHandler.cs" />
     <Compile Include="HttpHandlers\UserConfigurationHandler.cs" />
     <Compile Include="HttpHandlers\UserConfigurationHandler.cs" />
     <Compile Include="HttpHandlers\UsersHandler.cs" />
     <Compile Include="HttpHandlers\UsersHandler.cs" />
     <Compile Include="ImageProcessor.cs" />
     <Compile Include="ImageProcessor.cs" />
-    <Compile Include="HttpHandlers\MediaHandler.cs" />
     <Compile Include="Plugin.cs" />
     <Compile Include="Plugin.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
   </ItemGroup>
   </ItemGroup>

+ 16 - 6
MediaBrowser.Api/Plugin.cs

@@ -5,12 +5,18 @@ using MediaBrowser.Common.Net;
 using MediaBrowser.Common.Net.Handlers;
 using MediaBrowser.Common.Net.Handlers;
 using MediaBrowser.Common.Plugins;
 using MediaBrowser.Common.Plugins;
 using MediaBrowser.Controller;
 using MediaBrowser.Controller;
+using MediaBrowser.Model.Plugins;
 
 
 namespace MediaBrowser.Api
 namespace MediaBrowser.Api
 {
 {
-    public class Plugin : BasePlugin<BasePluginConfiguration>
+    public class Plugin : BaseGenericPlugin<BasePluginConfiguration>
     {
     {
-        protected override void InitInternal()
+        public override string Name
+        {
+            get { return "WebAPI"; }
+        }
+
+        public override void InitInServer()
         {
         {
             var httpServer = Kernel.Instance.HttpServer;
             var httpServer = Kernel.Instance.HttpServer;
 
 
@@ -43,10 +49,6 @@ namespace MediaBrowser.Api
             {
             {
                 handler = new UsersHandler();
                 handler = new UsersHandler();
             }
             }
-            else if (localPath.EndsWith("/api/media", StringComparison.OrdinalIgnoreCase))
-            {
-                handler = new MediaHandler();
-            }
             else if (localPath.EndsWith("/api/genre", StringComparison.OrdinalIgnoreCase))
             else if (localPath.EndsWith("/api/genre", StringComparison.OrdinalIgnoreCase))
             {
             {
                 handler = new GenreHandler();
                 handler = new GenreHandler();
@@ -75,6 +77,14 @@ namespace MediaBrowser.Api
             {
             {
                 handler = new UserConfigurationHandler();
                 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)
             if (handler != null)
             {
             {

+ 1 - 1
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 
 // You can specify all the values or you can default the Build and Revision Numbers 
 // by using the '*' as shown below:
 // by using the '*' as shown below:
 // [assembly: AssemblyVersion("1.0.*")]
 // [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyVersion("1.0.*")]
 [assembly: AssemblyFileVersion("1.0.0.0")]
 [assembly: AssemblyFileVersion("1.0.0.0")]

+ 0 - 2
MediaBrowser.Common/MediaBrowser.Common.csproj

@@ -49,7 +49,6 @@
   <ItemGroup>
   <ItemGroup>
     <Compile Include="Configuration\BaseConfiguration.cs" />
     <Compile Include="Configuration\BaseConfiguration.cs" />
     <Compile Include="Configuration\ConfigurationController.cs" />
     <Compile Include="Configuration\ConfigurationController.cs" />
-    <Compile Include="Configuration\UserConfiguration.cs" />
     <Compile Include="Events\GenericItemEventArgs.cs" />
     <Compile Include="Events\GenericItemEventArgs.cs" />
     <Compile Include="Json\JsonSerializer.cs" />
     <Compile Include="Json\JsonSerializer.cs" />
     <Compile Include="Kernel\BaseKernel.cs" />
     <Compile Include="Kernel\BaseKernel.cs" />
@@ -63,7 +62,6 @@
     <Compile Include="Net\Request.cs" />
     <Compile Include="Net\Request.cs" />
     <Compile Include="Net\RequestContext.cs" />
     <Compile Include="Net\RequestContext.cs" />
     <Compile Include="Net\StreamExtensions.cs" />
     <Compile Include="Net\StreamExtensions.cs" />
-    <Compile Include="Plugins\BasePluginConfiguration.cs" />
     <Compile Include="Logging\BaseLogger.cs" />
     <Compile Include="Logging\BaseLogger.cs" />
     <Compile Include="Logging\FileLogger.cs" />
     <Compile Include="Logging\FileLogger.cs" />
     <Compile Include="Logging\Logger.cs" />
     <Compile Include="Logging\Logger.cs" />

+ 68 - 20
MediaBrowser.Common/Plugins/BasePlugin.cs

@@ -1,49 +1,97 @@
-using System.IO;
+using System;
+using System.IO;
 using MediaBrowser.Common.Json;
 using MediaBrowser.Common.Json;
+using MediaBrowser.Model.Plugins;
 
 
 namespace MediaBrowser.Common.Plugins
 namespace MediaBrowser.Common.Plugins
 {
 {
-    public abstract class BasePlugin<TConfigurationType> : IPlugin
+    /// <summary>
+    /// Provides a BasePlugin with generics, allowing for strongly typed configuration access.
+    /// </summary>
+    public abstract class BaseGenericPlugin<TConfigurationType> : BasePlugin
         where TConfigurationType : BasePluginConfiguration, new()
         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<TConfigurationType>(ConfigurationPath);
+                Configuration.DateLastModified = File.GetLastWriteTime(ConfigurationPath);
+            }
+        }
+    }
+
+    /// <summary>
+    /// Provides a common base class for all plugins
+    /// </summary>
+    public abstract class BasePlugin
+    {
+        public abstract string Name { get; }
         public string Path { get; set; }
         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
             get
             {
             {
                 return System.IO.Path.Combine(Path, "config.js");
                 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()
+        /// <summary>
+        /// Returns true or false indicating if the plugin should be downloaded and run within the UI.
+        /// </summary>
+        public virtual bool DownloadToUI
         {
         {
-            if (!File.Exists(ConfigurationPath))
+            get
             {
             {
-                return new TConfigurationType();
+                return false;
             }
             }
+        }
 
 
-            return JsonSerializer.DeserializeFromFile<TConfigurationType>(ConfigurationPath);
+        public abstract void ReloadConfiguration();
+
+        public virtual void InitInServer()
+        {
         }
         }
-    }
 
 
-    public interface IPlugin
-    {
-        string Path { get; set; }
+        public virtual void InitInUI()
+        {
+        }
 
 
-        void Init();
     }
     }
 }
 }

+ 0 - 13
MediaBrowser.Common/Plugins/BasePluginConfiguration.cs

@@ -1,13 +0,0 @@
-
-namespace MediaBrowser.Common.Plugins
-{
-    public class BasePluginConfiguration
-    {
-        public bool Enabled { get; set; }
-
-        public BasePluginConfiguration()
-        {
-            Enabled = true;
-        }
-    }
-}

+ 28 - 10
MediaBrowser.Common/Plugins/PluginController.cs

@@ -18,7 +18,7 @@ namespace MediaBrowser.Common.Plugins
         /// <summary>
         /// <summary>
         /// Gets the list of currently loaded plugins
         /// Gets the list of currently loaded plugins
         /// </summary>
         /// </summary>
-        public IEnumerable<IPlugin> Plugins { get; private set; }
+        public IEnumerable<BasePlugin> Plugins { get; private set; }
         
         
         /// <summary>
         /// <summary>
         /// Initializes the controller
         /// Initializes the controller
@@ -32,7 +32,21 @@ namespace MediaBrowser.Common.Plugins
 
 
             Parallel.For(0, Plugins.Count(), i =>
             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
         /// Gets all plugins within PluginsPath
         /// </summary>
         /// </summary>
         /// <returns></returns>
         /// <returns></returns>
-        private IEnumerable<IPlugin> GetAllPlugins()
+        private IEnumerable<BasePlugin> GetAllPlugins()
         {
         {
             if (!Directory.Exists(PluginsPath))
             if (!Directory.Exists(PluginsPath))
             {
             {
                 Directory.CreateDirectory(PluginsPath);
                 Directory.CreateDirectory(PluginsPath);
             }
             }
 
 
-            List<IPlugin> plugins = new List<IPlugin>();
+            List<BasePlugin> plugins = new List<BasePlugin>();
 
 
             foreach (string folder in Directory.GetDirectories(PluginsPath, "*", SearchOption.TopDirectoryOnly))
             foreach (string folder in Directory.GetDirectories(PluginsPath, "*", SearchOption.TopDirectoryOnly))
             {
             {
-                IPlugin plugin = GetPluginFromDirectory(folder);
+                BasePlugin plugin = GetPluginFromDirectory(folder);
 
 
                 plugin.Path = folder;
                 plugin.Path = folder;
 
 
@@ -64,7 +78,7 @@ namespace MediaBrowser.Common.Plugins
             return plugins;
             return plugins;
         }
         }
 
 
-        private IPlugin GetPluginFromDirectory(string path)
+        private BasePlugin GetPluginFromDirectory(string path)
         {
         {
             string dll = Directory.GetFiles(path, "*.dll", SearchOption.TopDirectoryOnly).FirstOrDefault();
             string dll = Directory.GetFiles(path, "*.dll", SearchOption.TopDirectoryOnly).FirstOrDefault();
 
 
@@ -76,18 +90,22 @@ namespace MediaBrowser.Common.Plugins
             return null;
             return null;
         }
         }
 
 
-        private IPlugin GetPluginFromDll(string path)
+        private BasePlugin GetPluginFromDll(string path)
         {
         {
             return GetPluginFromDll(Assembly.Load(File.ReadAllBytes(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)
             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;
             return null;

+ 4 - 0
MediaBrowser.Configuration/MediaBrowser.Configuration.csproj

@@ -55,6 +55,10 @@
       <Project>{17e1f4e6-8abd-4fe5-9ecf-43d4b6087ba2}</Project>
       <Project>{17e1f4e6-8abd-4fe5-9ecf-43d4b6087ba2}</Project>
       <Name>MediaBrowser.Controller</Name>
       <Name>MediaBrowser.Controller</Name>
     </ProjectReference>
     </ProjectReference>
+    <ProjectReference Include="..\MediaBrowser.Model\MediaBrowser.Model.csproj">
+      <Project>{7eeeb4bb-f3e8-48fc-b4c5-70f0fff8329b}</Project>
+      <Name>MediaBrowser.Model</Name>
+    </ProjectReference>
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
     <None Include="packages.config" />
     <None Include="packages.config" />

+ 4 - 2
MediaBrowser.Configuration/Plugin.cs

@@ -1,11 +1,13 @@
 using MediaBrowser.Common.Plugins;
 using MediaBrowser.Common.Plugins;
+using MediaBrowser.Model.Plugins;
 
 
 namespace MediaBrowser.Configuration
 namespace MediaBrowser.Configuration
 {
 {
-    public class Plugin : BasePlugin<BasePluginConfiguration>
+    public class Plugin : BaseGenericPlugin<BasePluginConfiguration>
     {
     {
-        protected override void InitInternal()
+        public override string Name
         {
         {
+            get { return "Web-based Configuration"; }
         }
         }
     }
     }
 }
 }

+ 1 - 1
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 
 // You can specify all the values or you can default the Build and Revision Numbers 
 // by using the '*' as shown below:
 // by using the '*' as shown below:
 // [assembly: AssemblyVersion("1.0.*")]
 // [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyVersion("1.0.*")]
 [assembly: AssemblyFileVersion("1.0.0.0")]
 [assembly: AssemblyFileVersion("1.0.0.0")]

+ 1 - 0
MediaBrowser.Controller/Configuration/ServerConfiguration.cs

@@ -1,5 +1,6 @@
 using System.Collections.Generic;
 using System.Collections.Generic;
 using MediaBrowser.Common.Configuration;
 using MediaBrowser.Common.Configuration;
+using MediaBrowser.Model.Configuration;
 
 
 namespace MediaBrowser.Controller.Configuration
 namespace MediaBrowser.Controller.Configuration
 {
 {

+ 1 - 4
MediaBrowser.Controller/Configuration/ServerConfigurationController.cs

@@ -1,9 +1,6 @@
 using System;
 using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
 using MediaBrowser.Common.Configuration;
 using MediaBrowser.Common.Configuration;
+using MediaBrowser.Model.Configuration;
 
 
 namespace MediaBrowser.Controller.Configuration
 namespace MediaBrowser.Controller.Configuration
 {
 {

+ 1 - 1
MediaBrowser.Controller/Kernel.cs

@@ -5,13 +5,13 @@ using System.Linq;
 using System.Security.Cryptography;
 using System.Security.Cryptography;
 using System.Text;
 using System.Text;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
-using MediaBrowser.Common.Configuration;
 using MediaBrowser.Common.Kernel;
 using MediaBrowser.Common.Kernel;
 using MediaBrowser.Controller.Configuration;
 using MediaBrowser.Controller.Configuration;
 using MediaBrowser.Controller.Events;
 using MediaBrowser.Controller.Events;
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Controller.Library;
 using MediaBrowser.Controller.Library;
 using MediaBrowser.Controller.Resolvers;
 using MediaBrowser.Controller.Resolvers;
+using MediaBrowser.Model.Configuration;
 using MediaBrowser.Model.Entities;
 using MediaBrowser.Model.Entities;
 using MediaBrowser.Model.Users;
 using MediaBrowser.Model.Users;
 
 

+ 9 - 7
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.Controller;
-using MediaBrowser.HtmlBrowser.Handlers;
+using MediaBrowser.Model.Plugins;
 
 
 namespace MediaBrowser.HtmlBrowser
 namespace MediaBrowser.HtmlBrowser
 {
 {
-    public class Plugin : BasePlugin<BasePluginConfiguration>
+    public class Plugin : BaseGenericPlugin<BasePluginConfiguration>
     {
     {
-        protected override void InitInternal()
+        public override string Name
+        {
+            get { return "Html Library Browser"; }
+        }
+
+        public override void InitInServer()
         {
         {
             var httpServer = Kernel.Instance.HttpServer;
             var httpServer = Kernel.Instance.HttpServer;
 
 

+ 1 - 1
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 
 // You can specify all the values or you can default the Build and Revision Numbers 
 // by using the '*' as shown below:
 // by using the '*' as shown below:
 // [assembly: AssemblyVersion("1.0.*")]
 // [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyVersion("1.0.*")]
 [assembly: AssemblyFileVersion("1.0.0.0")]
 [assembly: AssemblyFileVersion("1.0.0.0")]

+ 4 - 0
MediaBrowser.InternetProviders/MediaBrowser.InternetProviders.csproj

@@ -52,6 +52,10 @@
       <Project>{17e1f4e6-8abd-4fe5-9ecf-43d4b6087ba2}</Project>
       <Project>{17e1f4e6-8abd-4fe5-9ecf-43d4b6087ba2}</Project>
       <Name>MediaBrowser.Controller</Name>
       <Name>MediaBrowser.Controller</Name>
     </ProjectReference>
     </ProjectReference>
+    <ProjectReference Include="..\MediaBrowser.Model\MediaBrowser.Model.csproj">
+      <Project>{7eeeb4bb-f3e8-48fc-b4c5-70f0fff8329b}</Project>
+      <Name>MediaBrowser.Model</Name>
+    </ProjectReference>
     <ProjectReference Include="..\MediaBrowser.Movies\MediaBrowser.Movies.csproj">
     <ProjectReference Include="..\MediaBrowser.Movies\MediaBrowser.Movies.csproj">
       <Project>{92b9f802-4415-438f-90e1-44602135ea41}</Project>
       <Project>{92b9f802-4415-438f-90e1-44602135ea41}</Project>
       <Name>MediaBrowser.Movies</Name>
       <Name>MediaBrowser.Movies</Name>

+ 7 - 2
MediaBrowser.InternetProviders/Plugin.cs

@@ -2,9 +2,14 @@
 
 
 namespace MediaBrowser.InternetProviders
 namespace MediaBrowser.InternetProviders
 {
 {
-    public class Plugin : BasePlugin<PluginConfiguration>
+    public class Plugin : BaseGenericPlugin<PluginConfiguration>
     {
     {
-        protected override void InitInternal()
+        public override string Name
+        {
+            get { return "Internet Providers"; }
+        }
+
+        public override void InitInServer()
         {
         {
         }
         }
     }
     }

+ 1 - 1
MediaBrowser.InternetProviders/PluginConfiguration.cs

@@ -1,4 +1,4 @@
-using MediaBrowser.Common.Plugins;
+using MediaBrowser.Model.Plugins;
 
 
 namespace MediaBrowser.InternetProviders
 namespace MediaBrowser.InternetProviders
 {
 {

+ 1 - 1
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 
 // You can specify all the values or you can default the Build and Revision Numbers 
 // by using the '*' as shown below:
 // by using the '*' as shown below:
 // [assembly: AssemblyVersion("1.0.*")]
 // [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyVersion("1.0.*")]
 [assembly: AssemblyFileVersion("1.0.0.0")]
 [assembly: AssemblyFileVersion("1.0.0.0")]

+ 2 - 7
MediaBrowser.Common/Configuration/UserConfiguration.cs → 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
 {
 {
     /// <summary>
     /// <summary>
     /// This holds settings that can be personalized on a per-user, per-device basis.
     /// This holds settings that can be personalized on a per-user, per-device basis.

+ 3 - 0
MediaBrowser.Model/MediaBrowser.Model.csproj

@@ -35,6 +35,7 @@
     <!-- A reference to the entire .NET Framework is automatically included -->
     <!-- A reference to the entire .NET Framework is automatically included -->
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
+    <Compile Include="Configuration\UserConfiguration.cs" />
     <Compile Include="Entities\ApiBaseItem.cs" />
     <Compile Include="Entities\ApiBaseItem.cs" />
     <Compile Include="Entities\Audio.cs" />
     <Compile Include="Entities\Audio.cs" />
     <Compile Include="Entities\BaseItem.cs" />
     <Compile Include="Entities\BaseItem.cs" />
@@ -45,6 +46,8 @@
     <Compile Include="Entities\Studio.cs" />
     <Compile Include="Entities\Studio.cs" />
     <Compile Include="Entities\Video.cs" />
     <Compile Include="Entities\Video.cs" />
     <Compile Include="Entities\Year.cs" />
     <Compile Include="Entities\Year.cs" />
+    <Compile Include="Plugins\BasePluginConfiguration.cs" />
+    <Compile Include="Plugins\PluginInfo.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="Users\User.cs" />
     <Compile Include="Users\User.cs" />
     <Compile Include="Users\UserItemData.cs" />
     <Compile Include="Users\UserItemData.cs" />

+ 18 - 0
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;
+        }
+    }
+}

+ 17 - 0
MediaBrowser.Model/Plugins/PluginInfo.cs

@@ -0,0 +1,17 @@
+using System;
+
+namespace MediaBrowser.Model.Plugins
+{
+    /// <summary>
+    /// This is a serializable stub class that is used by the api to provide information about installed plugins.
+    /// </summary>
+    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; }
+    }
+}

+ 8 - 2
MediaBrowser.Movies/Plugin.cs

@@ -1,13 +1,19 @@
 using MediaBrowser.Common.Plugins;
 using MediaBrowser.Common.Plugins;
 using MediaBrowser.Controller;
 using MediaBrowser.Controller;
+using MediaBrowser.Model.Plugins;
 using MediaBrowser.Movies.Entities;
 using MediaBrowser.Movies.Entities;
 using MediaBrowser.Movies.Resolvers;
 using MediaBrowser.Movies.Resolvers;
 
 
 namespace MediaBrowser.Movies
 namespace MediaBrowser.Movies
 {
 {
-    public class Plugin : BasePlugin<BasePluginConfiguration>
+    public class Plugin : BaseGenericPlugin<BasePluginConfiguration>
     {
     {
-        protected override void InitInternal()
+        public override string Name
+        {
+            get { return "Movies"; }
+        }
+
+        public override void InitInServer()
         {
         {
             Kernel.Instance.AddBaseItemType<BoxSet, BoxSetResolver>();
             Kernel.Instance.AddBaseItemType<BoxSet, BoxSetResolver>();
             Kernel.Instance.AddBaseItemType<Movie, MovieResolver>();
             Kernel.Instance.AddBaseItemType<Movie, MovieResolver>();

+ 1 - 1
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 
 // You can specify all the values or you can default the Build and Revision Numbers 
 // by using the '*' as shown below:
 // by using the '*' as shown below:
 // [assembly: AssemblyVersion("1.0.*")]
 // [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyVersion("1.0.*")]
 [assembly: AssemblyFileVersion("1.0.0.0")]
 [assembly: AssemblyFileVersion("1.0.0.0")]

+ 10 - 5
MediaBrowser.TV/Plugin.cs

@@ -1,16 +1,21 @@
-using MediaBrowser.Common.Plugins;
+using System;
+using MediaBrowser.Common.Plugins;
 using MediaBrowser.Controller;
 using MediaBrowser.Controller;
 using MediaBrowser.Controller.Events;
 using MediaBrowser.Controller.Events;
-using MediaBrowser.Model.Entities;
+using MediaBrowser.Model.Plugins;
 using MediaBrowser.TV.Entities;
 using MediaBrowser.TV.Entities;
 using MediaBrowser.TV.Resolvers;
 using MediaBrowser.TV.Resolvers;
-using System;
 
 
 namespace MediaBrowser.TV
 namespace MediaBrowser.TV
 {
 {
-    public class Plugin : BasePlugin<BasePluginConfiguration>
+    public class Plugin : BaseGenericPlugin<BasePluginConfiguration>
     {
     {
-        protected override void InitInternal()
+        public override string Name
+        {
+            get { return "TV"; }
+        }
+
+        public override void InitInServer()
         {
         {
             Kernel.Instance.AddBaseItemType<Series, SeriesResolver>();
             Kernel.Instance.AddBaseItemType<Series, SeriesResolver>();
             Kernel.Instance.AddBaseItemType<Season, SeasonResolver>();
             Kernel.Instance.AddBaseItemType<Season, SeasonResolver>();

+ 1 - 1
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 
 // You can specify all the values or you can default the Build and Revision Numbers 
 // by using the '*' as shown below:
 // by using the '*' as shown below:
 // [assembly: AssemblyVersion("1.0.*")]
 // [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyVersion("1.0.*")]
 [assembly: AssemblyFileVersion("1.0.0.0")]
 [assembly: AssemblyFileVersion("1.0.0.0")]