diff --git a/MediaBrowser.Api/HttpHandlers/ImageHandler.cs b/MediaBrowser.Api/HttpHandlers/ImageHandler.cs
index ae6228ae8..33beb2901 100644
--- a/MediaBrowser.Api/HttpHandlers/ImageHandler.cs
+++ b/MediaBrowser.Api/HttpHandlers/ImageHandler.cs
@@ -1,9 +1,9 @@
using System;
using System.IO;
using System.Linq;
+using MediaBrowser.Common.Net.Handlers;
using MediaBrowser.Controller;
using MediaBrowser.Model.Entities;
-using MediaBrowser.Net.Handlers;
namespace MediaBrowser.Api.HttpHandlers
{
diff --git a/MediaBrowser.Api/HttpHandlers/ItemHandler.cs b/MediaBrowser.Api/HttpHandlers/ItemHandler.cs
index 2ff235493..a54d65524 100644
--- a/MediaBrowser.Api/HttpHandlers/ItemHandler.cs
+++ b/MediaBrowser.Api/HttpHandlers/ItemHandler.cs
@@ -1,5 +1,4 @@
using System;
-using MediaBrowser.Net.Handlers;
using MediaBrowser.Model.Entities;
namespace MediaBrowser.Api.HttpHandlers
diff --git a/MediaBrowser.Api/HttpHandlers/ItemListHandler.cs b/MediaBrowser.Api/HttpHandlers/ItemListHandler.cs
index 54af1b7e9..a94c2061e 100644
--- a/MediaBrowser.Api/HttpHandlers/ItemListHandler.cs
+++ b/MediaBrowser.Api/HttpHandlers/ItemListHandler.cs
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using MediaBrowser.Net.Handlers;
using MediaBrowser.Model.Entities;
namespace MediaBrowser.Api.HttpHandlers
diff --git a/MediaBrowser.Api/HttpHandlers/JsonHandler.cs b/MediaBrowser.Api/HttpHandlers/JsonHandler.cs
index e663085ec..a891d7d68 100644
--- a/MediaBrowser.Api/HttpHandlers/JsonHandler.cs
+++ b/MediaBrowser.Api/HttpHandlers/JsonHandler.cs
@@ -1,6 +1,6 @@
using System.IO;
using MediaBrowser.Common.Json;
-using MediaBrowser.Net.Handlers;
+using MediaBrowser.Common.Net.Handlers;
namespace MediaBrowser.Api.HttpHandlers
{
diff --git a/MediaBrowser.Api/HttpHandlers/MediaHandler.cs b/MediaBrowser.Api/HttpHandlers/MediaHandler.cs
index 47aab3c41..73f8de7d8 100644
--- a/MediaBrowser.Api/HttpHandlers/MediaHandler.cs
+++ b/MediaBrowser.Api/HttpHandlers/MediaHandler.cs
@@ -1,7 +1,7 @@
using System;
using System.IO;
+using MediaBrowser.Common.Net.Handlers;
using MediaBrowser.Model.Entities;
-using MediaBrowser.Net.Handlers;
namespace MediaBrowser.Api.HttpHandlers
{
diff --git a/MediaBrowser.Api/HttpHandlers/StudiosHandler.cs b/MediaBrowser.Api/HttpHandlers/StudiosHandler.cs
index 66daca777..d2898104f 100644
--- a/MediaBrowser.Api/HttpHandlers/StudiosHandler.cs
+++ b/MediaBrowser.Api/HttpHandlers/StudiosHandler.cs
@@ -1,5 +1,4 @@
using System;
-using MediaBrowser.Net.Handlers;
using MediaBrowser.Controller;
using MediaBrowser.Model.Entities;
diff --git a/MediaBrowser.Api/HttpHandlers/UsersHandler.cs b/MediaBrowser.Api/HttpHandlers/UsersHandler.cs
index 816d4e83a..d10561e43 100644
--- a/MediaBrowser.Api/HttpHandlers/UsersHandler.cs
+++ b/MediaBrowser.Api/HttpHandlers/UsersHandler.cs
@@ -1,5 +1,4 @@
-using MediaBrowser.Net.Handlers;
-using MediaBrowser.Controller;
+using MediaBrowser.Controller;
namespace MediaBrowser.Api.HttpHandlers
{
diff --git a/MediaBrowser.Api/MediaBrowser.Api.csproj b/MediaBrowser.Api/MediaBrowser.Api.csproj
index dd5c07232..c0942cbb9 100644
--- a/MediaBrowser.Api/MediaBrowser.Api.csproj
+++ b/MediaBrowser.Api/MediaBrowser.Api.csproj
@@ -76,10 +76,6 @@
{7eeeb4bb-f3e8-48fc-b4c5-70f0fff8329b}
MediaBrowser.Model
-
- {5da08d1c-0d52-4b1b-aa66-e4a171d938f6}
- MediaBrowser.Net
-
diff --git a/MediaBrowser.Api/Plugin.cs b/MediaBrowser.Api/Plugin.cs
index af885ef82..9a4db1518 100644
--- a/MediaBrowser.Api/Plugin.cs
+++ b/MediaBrowser.Api/Plugin.cs
@@ -1,10 +1,10 @@
using System;
using System.Reactive.Linq;
using MediaBrowser.Api.HttpHandlers;
+using MediaBrowser.Common.Net;
+using MediaBrowser.Common.Net.Handlers;
using MediaBrowser.Common.Plugins;
using MediaBrowser.Controller;
-using MediaBrowser.Net;
-using MediaBrowser.Net.Handlers;
namespace MediaBrowser.Api
{
diff --git a/MediaBrowser.Common/ApiInteraction/ApiController.cs b/MediaBrowser.Common/ApiInteraction/ApiController.cs
deleted file mode 100644
index b3a51c512..000000000
--- a/MediaBrowser.Common/ApiInteraction/ApiController.cs
+++ /dev/null
@@ -1,128 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.IO.Compression;
-using System.Linq;
-using System.Net;
-using System.Threading.Tasks;
-using MediaBrowser.Common.Json;
-using MediaBrowser.Model.Entities;
-using MediaBrowser.Model.Users;
-
-namespace MediaBrowser.Common.ApiInteraction
-{
- public class ApiController
- {
- public string ApiUrl { get; set; }
-
- private WebClient WebClient { get; set; }
-
- public ApiController()
- {
- WebClient = new WebClient();
- }
-
- public async Task> GetRootItem(Guid userId)
- {
- string url = ApiUrl + "/item?userId=" + userId.ToString();
-
- using (Stream stream = await WebClient.OpenReadTaskAsync(url))
- {
- using (GZipStream gzipStream = new GZipStream(stream, CompressionMode.Decompress, false))
- {
- return DeserializeBaseItemWrapper(gzipStream);
- }
- }
- }
-
- public async Task> GetItem(Guid id, Guid userId)
- {
- string url = ApiUrl + "/item?userId=" + userId.ToString();
-
- if (id != Guid.Empty)
- {
- url += "&id=" + id.ToString();
- }
-
- using (Stream stream = await WebClient.OpenReadTaskAsync(url))
- {
- using (GZipStream gzipStream = new GZipStream(stream, CompressionMode.Decompress, false))
- {
- return DeserializeBaseItemWrapper(gzipStream);
- }
- }
- }
-
- public async Task> GetAllUsers()
- {
- string url = ApiUrl + "/users";
-
- using (Stream stream = await WebClient.OpenReadTaskAsync(url))
- {
- using (GZipStream gzipStream = new GZipStream(stream, CompressionMode.Decompress, false))
- {
- return JsonSerializer.DeserializeFromStream>(gzipStream);
- }
- }
- }
-
- public async Task> GetAllGenres(Guid userId)
- {
- string url = ApiUrl + "/genres?userId=" + userId.ToString();
-
- using (Stream stream = await WebClient.OpenReadTaskAsync(url))
- {
- using (GZipStream gzipStream = new GZipStream(stream, CompressionMode.Decompress, false))
- {
- return JsonSerializer.DeserializeFromStream>(gzipStream);
- }
- }
- }
-
- public async Task GetGenre(string name, Guid userId)
- {
- string url = ApiUrl + "/genre?userId=" + userId.ToString() + "&name=" + name;
-
- using (Stream stream = await WebClient.OpenReadTaskAsync(url))
- {
- using (GZipStream gzipStream = new GZipStream(stream, CompressionMode.Decompress, false))
- {
- return JsonSerializer.DeserializeFromStream(gzipStream);
- }
- }
- }
-
- public async Task> GetAllStudios(Guid userId)
- {
- string url = ApiUrl + "/studios?userId=" + userId.ToString();
-
- using (Stream stream = await WebClient.OpenReadTaskAsync(url))
- {
- using (GZipStream gzipStream = new GZipStream(stream, CompressionMode.Decompress, false))
- {
- return JsonSerializer.DeserializeFromStream>(gzipStream);
- }
- }
- }
-
- public async Task GetStudio(string name, Guid userId)
- {
- string url = ApiUrl + "/studio?userId=" + userId.ToString() + "&name=" + name;
-
- using (Stream stream = await WebClient.OpenReadTaskAsync(url))
- {
- using (GZipStream gzipStream = new GZipStream(stream, CompressionMode.Decompress, false))
- {
- return JsonSerializer.DeserializeFromStream(gzipStream);
- }
- }
- }
-
- private static ApiBaseItemWrapper DeserializeBaseItemWrapper(Stream stream)
- {
- ApiBaseItemWrapper data = JsonSerializer.DeserializeFromStream>(stream);
-
- return data;
- }
- }
-}
diff --git a/MediaBrowser.Common/Configuration/BaseConfiguration.cs b/MediaBrowser.Common/Configuration/BaseConfiguration.cs
new file mode 100644
index 000000000..bf53686ab
--- /dev/null
+++ b/MediaBrowser.Common/Configuration/BaseConfiguration.cs
@@ -0,0 +1,19 @@
+using MediaBrowser.Common.Logging;
+
+namespace MediaBrowser.Common.Configuration
+{
+ ///
+ /// Serves as a common base class for the Server and UI Configurations
+ ///
+ public class BaseConfiguration
+ {
+ public LogSeverity LogSeverity { get; set; }
+ public int HttpServerPortNumber { get; set; }
+
+ public BaseConfiguration()
+ {
+ LogSeverity = LogSeverity.Info;
+ HttpServerPortNumber = 8096;
+ }
+ }
+}
diff --git a/MediaBrowser.Common/Kernel/BaseKernel.cs b/MediaBrowser.Common/Kernel/BaseKernel.cs
new file mode 100644
index 000000000..d6c13ce38
--- /dev/null
+++ b/MediaBrowser.Common/Kernel/BaseKernel.cs
@@ -0,0 +1,130 @@
+using System.Configuration;
+using System.IO;
+using System.Reflection;
+using MediaBrowser.Common.Configuration;
+using MediaBrowser.Common.Json;
+using MediaBrowser.Common.Logging;
+using MediaBrowser.Common.Net;
+using MediaBrowser.Common.Plugins;
+
+namespace MediaBrowser.Common.Kernel
+{
+ ///
+ /// Represents a shared base kernel for both the UI and server apps
+ ///
+ public abstract class BaseKernel
+ where TConfigurationType : BaseConfiguration, new()
+ {
+ ///
+ /// Gets the path to the program data folder
+ ///
+ public string ProgramDataPath { get; private set; }
+
+ ///
+ /// Gets the current configuration
+ ///
+ public TConfigurationType Configuration { get; private set; }
+
+ ///
+ /// Both the UI and server will have a built-in HttpServer.
+ /// People will inevitably want remote control apps so it's needed in the UI too.
+ ///
+ public HttpServer HttpServer { get; private set; }
+
+ public PluginController PluginController { get; private set; }
+
+ ///
+ /// Gets the kernel context. The UI kernel will have to override this.
+ ///
+ protected KernelContext KernelContext { get { return KernelContext.Server; } }
+
+ protected virtual string HttpServerUrlPrefix
+ {
+ get
+ {
+ return "http://+:" + Configuration.HttpServerPortNumber + "/mediabrowser/";
+ }
+ }
+
+ public BaseKernel()
+ {
+ ProgramDataPath = GetProgramDataPath();
+
+ PluginController = new PluginController() { PluginsPath = Path.Combine(ProgramDataPath, "Plugins") };
+
+ Logger.LoggerInstance = new FileLogger(Path.Combine(ProgramDataPath, "Logs"));
+ }
+
+ public virtual void Init()
+ {
+ ReloadConfiguration();
+
+ ReloadHttpServer();
+
+ ReloadPlugins();
+ }
+
+ ///
+ /// Gets the path to the application's ProgramDataFolder
+ ///
+ ///
+ private string GetProgramDataPath()
+ {
+ string programDataPath = ConfigurationManager.AppSettings["ProgramDataPath"];
+
+ // If it's a relative path, e.g. "..\"
+ if (!Path.IsPathRooted(programDataPath))
+ {
+ string path = Assembly.GetExecutingAssembly().Location;
+ path = Path.GetDirectoryName(path);
+
+ programDataPath = Path.Combine(path, programDataPath);
+
+ programDataPath = Path.GetFullPath(programDataPath);
+ }
+
+ if (!Directory.Exists(programDataPath))
+ {
+ Directory.CreateDirectory(programDataPath);
+ }
+
+ return programDataPath;
+ }
+
+ private void ReloadConfiguration()
+ {
+ // Deserialize config
+ Configuration = GetConfiguration(ProgramDataPath);
+
+ Logger.LoggerInstance.LogSeverity = Configuration.LogSeverity;
+ }
+
+ private void ReloadHttpServer()
+ {
+ if (HttpServer != null)
+ {
+ HttpServer.Dispose();
+ }
+
+ HttpServer = new HttpServer("http://+:" + Configuration.HttpServerPortNumber + "/mediabrowser/");
+ }
+
+ protected virtual void ReloadPlugins()
+ {
+ // Find plugins
+ PluginController.Init(KernelContext);
+ }
+
+ private static TConfigurationType GetConfiguration(string directory)
+ {
+ string file = Path.Combine(directory, "config.js");
+
+ if (!File.Exists(file))
+ {
+ return new TConfigurationType();
+ }
+
+ return JsonSerializer.DeserializeFromFile(file);
+ }
+ }
+}
diff --git a/MediaBrowser.Common/Kernel/KernelContext.cs b/MediaBrowser.Common/Kernel/KernelContext.cs
new file mode 100644
index 000000000..6aa1e83bd
--- /dev/null
+++ b/MediaBrowser.Common/Kernel/KernelContext.cs
@@ -0,0 +1,9 @@
+
+namespace MediaBrowser.Common.Kernel
+{
+ public enum KernelContext
+ {
+ Server,
+ UI
+ }
+}
diff --git a/MediaBrowser.Common/Logging/BaseLogger.cs b/MediaBrowser.Common/Logging/BaseLogger.cs
index 407c8baa7..51c6632d5 100644
--- a/MediaBrowser.Common/Logging/BaseLogger.cs
+++ b/MediaBrowser.Common/Logging/BaseLogger.cs
@@ -2,7 +2,6 @@
using System.Diagnostics;
using System.Text;
using System.Threading;
-using MediaBrowser.Model.Logging;
namespace MediaBrowser.Common.Logging
{
diff --git a/MediaBrowser.Common/Logging/LogRow.cs b/MediaBrowser.Common/Logging/LogRow.cs
index d1e234250..39c69eb45 100644
--- a/MediaBrowser.Common/Logging/LogRow.cs
+++ b/MediaBrowser.Common/Logging/LogRow.cs
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Text;
-using MediaBrowser.Model.Logging;
namespace MediaBrowser.Common.Logging
{
diff --git a/MediaBrowser.Model/Logging/LogSeverity.cs b/MediaBrowser.Common/Logging/LogSeverity.cs
similarity index 76%
rename from MediaBrowser.Model/Logging/LogSeverity.cs
rename to MediaBrowser.Common/Logging/LogSeverity.cs
index bac03acdd..2abab1a44 100644
--- a/MediaBrowser.Model/Logging/LogSeverity.cs
+++ b/MediaBrowser.Common/Logging/LogSeverity.cs
@@ -1,6 +1,6 @@
using System;
-namespace MediaBrowser.Model.Logging
+namespace MediaBrowser.Common.Logging
{
[Flags]
public enum LogSeverity
diff --git a/MediaBrowser.Common/MediaBrowser.Common.csproj b/MediaBrowser.Common/MediaBrowser.Common.csproj
index 252c9c8cc..1f68a3da7 100644
--- a/MediaBrowser.Common/MediaBrowser.Common.csproj
+++ b/MediaBrowser.Common/MediaBrowser.Common.csproj
@@ -34,7 +34,12 @@
..\packages\ServiceStack.Text.3.8.5\lib\net35\ServiceStack.Text.dll
+
+
+ False
+ ..\packages\Rx-Main.1.0.11226\lib\Net4\System.Reactive.dll
+
@@ -42,9 +47,20 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
@@ -63,6 +79,7 @@
MediaBrowser.Model
+
-
@@ -46,7 +45,6 @@
-
diff --git a/MediaBrowser.Net/MediaBrowser.Net.csproj b/MediaBrowser.Net/MediaBrowser.Net.csproj
deleted file mode 100644
index 6f1b7cccf..000000000
--- a/MediaBrowser.Net/MediaBrowser.Net.csproj
+++ /dev/null
@@ -1,66 +0,0 @@
-
-
-
-
- Debug
- AnyCPU
- {5DA08D1C-0D52-4B1B-AA66-E4A171D938F6}
- Library
- Properties
- MediaBrowser.Net
- MediaBrowser.Net
- v4.5
- 512
-
-
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
-
-
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
-
-
-
-
-
- ..\packages\Rx-Main.1.0.11226\lib\Net4\System.Reactive.dll
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/MediaBrowser.Net/Properties/AssemblyInfo.cs b/MediaBrowser.Net/Properties/AssemblyInfo.cs
deleted file mode 100644
index 00964b6a2..000000000
--- a/MediaBrowser.Net/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("MediaBrowser.Net")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("MediaBrowser.Net")]
-[assembly: AssemblyCopyright("Copyright © 2012")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
-
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("eacc40b5-e24e-4467-8000-f40874048d45")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// 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: AssemblyFileVersion("1.0.0.0")]
diff --git a/MediaBrowser.Net/packages.config b/MediaBrowser.Net/packages.config
deleted file mode 100644
index 47102a263..000000000
--- a/MediaBrowser.Net/packages.config
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/MediaBrowser.Program/App.config b/MediaBrowser.Program/App.config
index 04df0f820..5aff9b350 100644
--- a/MediaBrowser.Program/App.config
+++ b/MediaBrowser.Program/App.config
@@ -1,7 +1,7 @@
-
+
diff --git a/MediaBrowser.Program/Program.cs b/MediaBrowser.Program/Program.cs
index 1933ad126..ff7ad002f 100644
--- a/MediaBrowser.Program/Program.cs
+++ b/MediaBrowser.Program/Program.cs
@@ -1,6 +1,4 @@
using System;
-using System.Configuration;
-using System.IO;
using MediaBrowser.Controller;
namespace MediaBrowser.Program
@@ -18,24 +16,7 @@ namespace MediaBrowser.Program
Console.WriteLine("Loading");
- string installDir = ConfigurationManager.AppSettings["DataPath"];
-
- if (!Path.IsPathRooted(installDir))
- {
- string path = System.Reflection.Assembly.GetExecutingAssembly().Location;
- path = Path.GetDirectoryName(path);
-
- installDir = Path.Combine(path, installDir);
-
- installDir = Path.GetFullPath(installDir);
- }
-
- if (!Directory.Exists(installDir))
- {
- Directory.CreateDirectory(installDir);
- }
-
- Kernel kernel = new Kernel(installDir);
+ Kernel kernel = new Kernel();
kernel.Init();
diff --git a/MediaBrowser.sln b/MediaBrowser.sln
index 23e78b42f..6f94baf31 100644
--- a/MediaBrowser.sln
+++ b/MediaBrowser.sln
@@ -21,8 +21,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediaBrowser.Common", "Medi
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediaBrowser.Model", "MediaBrowser.Model\MediaBrowser.Model.csproj", "{7EEEB4BB-F3E8-48FC-B4C5-70F0FFF8329B}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediaBrowser.Net", "MediaBrowser.Net\MediaBrowser.Net.csproj", "{5DA08D1C-0D52-4B1B-AA66-E4A171D938F6}"
-EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -45,10 +43,6 @@ Global
{5758B2C7-949A-421D-B268-70A950CF8741}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5758B2C7-949A-421D-B268-70A950CF8741}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5758B2C7-949A-421D-B268-70A950CF8741}.Release|Any CPU.Build.0 = Release|Any CPU
- {5DA08D1C-0D52-4B1B-AA66-E4A171D938F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {5DA08D1C-0D52-4B1B-AA66-E4A171D938F6}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {5DA08D1C-0D52-4B1B-AA66-E4A171D938F6}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {5DA08D1C-0D52-4B1B-AA66-E4A171D938F6}.Release|Any CPU.Build.0 = Release|Any CPU
{78AEA637-AF42-4F43-8E2B-0F2F0E2931F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{78AEA637-AF42-4F43-8E2B-0F2F0E2931F3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{78AEA637-AF42-4F43-8E2B-0F2F0E2931F3}.Release|Any CPU.ActiveCfg = Release|Any CPU