created common startup project for mono & windows

This commit is contained in:
Luke Pulverenti 2014-11-09 13:24:57 -05:00
parent 40897bac14
commit 1a80362a0f
52 changed files with 1028 additions and 3425 deletions

View File

@ -0,0 +1,112 @@
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Net;
using MediaBrowser.Model.Querying;
using ServiceStack;
using System;
using System.Linq;
using System.Threading.Tasks;
namespace MediaBrowser.Api
{
[Route("/Items/Filters", "GET", Summary = "Gets branding configuration")]
public class GetQueryFilters : IReturn<QueryFilters>
{
/// <summary>
/// Gets or sets the user id.
/// </summary>
/// <value>The user id.</value>
[ApiMember(Name = "UserId", Description = "User Id", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
public string UserId { get; set; }
[ApiMember(Name = "ParentId", Description = "Specify this to localize the search to a specific item or folder. Omit to use the root", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
public string ParentId { get; set; }
[ApiMember(Name = "IncludeItemTypes", Description = "Optional. If specified, results will be filtered based on item type. This allows multiple, comma delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
public string IncludeItemTypes { get; set; }
[ApiMember(Name = "MediaTypes", Description = "Optional filter by MediaType. Allows multiple, comma delimited.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
public string MediaTypes { get; set; }
public string[] GetMediaTypes()
{
return (MediaTypes ?? string.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
}
public string[] GetIncludeItemTypes()
{
return (IncludeItemTypes ?? string.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
}
}
[Authenticated]
public class FilterService : BaseApiService
{
private readonly ILibraryManager _libraryManager;
private readonly IUserManager _userManager;
public FilterService(ILibraryManager libraryManager, IUserManager userManager)
{
_libraryManager = libraryManager;
_userManager = userManager;
}
public async Task<object> Get(GetQueryFilters request)
{
var parentItem = string.IsNullOrEmpty(request.ParentId) ? null : _libraryManager.GetItemById(request.ParentId);
var user = !string.IsNullOrWhiteSpace(request.UserId) ? _userManager.GetUserById(request.UserId) : null;
var item = string.IsNullOrEmpty(request.ParentId) ?
user == null ? _libraryManager.RootFolder : user.RootFolder :
parentItem;
var result = await ((Folder)item).GetItems(GetItemsQuery(request, user));
return ToOptimizedResult(GetFilters(result.Items));
}
private QueryFilters GetFilters(BaseItem[] items)
{
var result = new QueryFilters();
result.Years = items.Select(i => i.ProductionYear ?? -1)
.Where(i => i > 0)
.Distinct()
.OrderBy(i => i)
.ToArray();
result.Genres = items.SelectMany(i => i.Genres)
.Distinct(StringComparer.OrdinalIgnoreCase)
.OrderBy(i => i)
.ToArray();
result.Tags = items.OfType<IHasTags>()
.SelectMany(i => i.Tags)
.Distinct(StringComparer.OrdinalIgnoreCase)
.OrderBy(i => i)
.ToArray();
result.OfficialRatings = items
.Select(i => i.OfficialRating)
.Where(i => !string.IsNullOrWhiteSpace(i))
.Distinct(StringComparer.OrdinalIgnoreCase)
.OrderBy(i => i)
.ToArray();
return result;
}
private InternalItemsQuery GetItemsQuery(GetQueryFilters request, User user)
{
var query = new InternalItemsQuery
{
User = user,
MediaTypes = request.GetMediaTypes(),
IncludeItemTypes = request.GetIncludeItemTypes(),
Recursive = true
};
return query;
}
}
}

View File

@ -658,7 +658,7 @@ namespace MediaBrowser.Api.Images
private ImageOutputFormat[] GetClientSupportedFormats() private ImageOutputFormat[] GetClientSupportedFormats()
{ {
if (Request.AcceptTypes.Contains("image/webp", StringComparer.OrdinalIgnoreCase)) if ((Request.AcceptTypes ?? new string[] { }).Contains("image/webp", StringComparer.OrdinalIgnoreCase))
{ {
return new[] { ImageOutputFormat.Webp, ImageOutputFormat.Jpg, ImageOutputFormat.Png }; return new[] { ImageOutputFormat.Webp, ImageOutputFormat.Jpg, ImageOutputFormat.Png };
} }

View File

@ -49,8 +49,9 @@
<RunPostBuildEvent>Always</RunPostBuildEvent> <RunPostBuildEvent>Always</RunPostBuildEvent>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="MoreLinq"> <Reference Include="MoreLinq, Version=1.1.17511.0, Culture=neutral, PublicKeyToken=384d532d7e88985d, processorArchitecture=MSIL">
<HintPath>..\packages\morelinq.1.0.16006\lib\net35\MoreLinq.dll</HintPath> <SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\morelinq.1.1.0\lib\net35\MoreLinq.dll</HintPath>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
@ -74,6 +75,7 @@
<Compile Include="Devices\DeviceService.cs" /> <Compile Include="Devices\DeviceService.cs" />
<Compile Include="Dlna\DlnaServerService.cs" /> <Compile Include="Dlna\DlnaServerService.cs" />
<Compile Include="Dlna\DlnaService.cs" /> <Compile Include="Dlna\DlnaService.cs" />
<Compile Include="FilterService.cs" />
<Compile Include="Library\ChapterService.cs" /> <Compile Include="Library\ChapterService.cs" />
<Compile Include="Playback\Hls\MpegDashService.cs" /> <Compile Include="Playback\Hls\MpegDashService.cs" />
<Compile Include="PlaylistService.cs" /> <Compile Include="PlaylistService.cs" />

View File

@ -1,5 +1,4 @@
using System.Threading; using MediaBrowser.Controller.Collections;
using MediaBrowser.Controller.Collections;
using MediaBrowser.Controller.Dto; using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio; using MediaBrowser.Controller.Entities.Audio;
@ -8,15 +7,12 @@ using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Localization; using MediaBrowser.Controller.Localization;
using MediaBrowser.Controller.Net; using MediaBrowser.Controller.Net;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Channels;
using MediaBrowser.Model.Entities; using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Querying; using MediaBrowser.Model.Querying;
using ServiceStack; using ServiceStack;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.IO;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="morelinq" version="1.0.16006" targetFramework="net45" /> <package id="morelinq" version="1.1.0" targetFramework="net45" />
</packages> </packages>

View File

@ -48,8 +48,9 @@
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="MoreLinq"> <Reference Include="MoreLinq, Version=1.1.17511.0, Culture=neutral, PublicKeyToken=384d532d7e88985d, processorArchitecture=MSIL">
<HintPath>..\packages\morelinq.1.0.16006\lib\net35\MoreLinq.dll</HintPath> <SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\morelinq.1.1.0\lib\net35\MoreLinq.dll</HintPath>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="morelinq" version="1.0.16006" targetFramework="net45" /> <package id="morelinq" version="1.1.0" targetFramework="net45" />
</packages> </packages>

View File

@ -923,6 +923,9 @@
<Compile Include="..\MediaBrowser.Model\Querying\PersonsQuery.cs"> <Compile Include="..\MediaBrowser.Model\Querying\PersonsQuery.cs">
<Link>Querying\PersonsQuery.cs</Link> <Link>Querying\PersonsQuery.cs</Link>
</Compile> </Compile>
<Compile Include="..\MediaBrowser.Model\Querying\QueryFilters.cs">
<Link>Querying\QueryFilters.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Querying\QueryResult.cs"> <Compile Include="..\MediaBrowser.Model\Querying\QueryResult.cs">
<Link>Querying\QueryResult.cs</Link> <Link>Querying\QueryResult.cs</Link>
</Compile> </Compile>

View File

@ -882,6 +882,9 @@
<Compile Include="..\MediaBrowser.Model\Querying\PersonsQuery.cs"> <Compile Include="..\MediaBrowser.Model\Querying\PersonsQuery.cs">
<Link>Querying\PersonsQuery.cs</Link> <Link>Querying\PersonsQuery.cs</Link>
</Compile> </Compile>
<Compile Include="..\MediaBrowser.Model\Querying\QueryFilters.cs">
<Link>Querying\QueryFilters.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Querying\QueryResult.cs"> <Compile Include="..\MediaBrowser.Model\Querying\QueryResult.cs">
<Link>Querying\QueryResult.cs</Link> <Link>Querying\QueryResult.cs</Link>
</Compile> </Compile>

View File

@ -85,12 +85,6 @@ namespace MediaBrowser.Model.Configuration
/// <value>The sort remove words.</value> /// <value>The sort remove words.</value>
public string[] SortRemoveWords { get; set; } public string[] SortRemoveWords { get; set; }
/// <summary>
/// Show an output log window for debugging
/// </summary>
/// <value><c>true</c> if [show log window]; otherwise, <c>false</c>.</value>
public bool ShowLogWindow { get; set; }
/// <summary> /// <summary>
/// Gets or sets the minimum percentage of an item that must be played in order for playstate to be updated. /// Gets or sets the minimum percentage of an item that must be played in order for playstate to be updated.
/// </summary> /// </summary>

View File

@ -302,6 +302,7 @@
<Compile Include="Entities\BaseItemInfo.cs" /> <Compile Include="Entities\BaseItemInfo.cs" />
<Compile Include="Querying\LatestItemsQuery.cs" /> <Compile Include="Querying\LatestItemsQuery.cs" />
<Compile Include="Querying\NextUpQuery.cs" /> <Compile Include="Querying\NextUpQuery.cs" />
<Compile Include="Querying\QueryFilters.cs" />
<Compile Include="Querying\QueryResult.cs" /> <Compile Include="Querying\QueryResult.cs" />
<Compile Include="Querying\SeasonQuery.cs" /> <Compile Include="Querying\SeasonQuery.cs" />
<Compile Include="Querying\SessionQuery.cs" /> <Compile Include="Querying\SessionQuery.cs" />

View File

@ -0,0 +1,19 @@

namespace MediaBrowser.Model.Querying
{
public class QueryFilters
{
public string[] Genres { get; set; }
public string[] Tags { get; set; }
public string[] OfficialRatings { get; set; }
public int[] Years { get; set; }
public QueryFilters()
{
Genres = new string[] { };
Tags = new string[] { };
OfficialRatings = new string[] { };
Years = new int[] { };
}
}
}

View File

@ -53,8 +53,9 @@
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\MediaBrowser.BdInfo.1.0.0.10\lib\net35\DvdLib.dll</HintPath> <HintPath>..\packages\MediaBrowser.BdInfo.1.0.0.10\lib\net35\DvdLib.dll</HintPath>
</Reference> </Reference>
<Reference Include="MoreLinq"> <Reference Include="MoreLinq, Version=1.1.17511.0, Culture=neutral, PublicKeyToken=384d532d7e88985d, processorArchitecture=MSIL">
<HintPath>..\packages\morelinq.1.0.16006\lib\net35\MoreLinq.dll</HintPath> <SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\morelinq.1.1.0\lib\net35\MoreLinq.dll</HintPath>
</Reference> </Reference>
<Reference Include="policy.2.0.taglib-sharp"> <Reference Include="policy.2.0.taglib-sharp">
<HintPath>..\packages\taglib.2.1.0.0\lib\policy.2.0.taglib-sharp.dll</HintPath> <HintPath>..\packages\taglib.2.1.0.0\lib\policy.2.0.taglib-sharp.dll</HintPath>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="MediaBrowser.BdInfo" version="1.0.0.10" targetFramework="net45" /> <package id="MediaBrowser.BdInfo" version="1.0.0.10" targetFramework="net45" />
<package id="morelinq" version="1.0.16006" targetFramework="net45" /> <package id="morelinq" version="1.1.0" targetFramework="net45" />
<package id="taglib" version="2.1.0.0" targetFramework="net45" /> <package id="taglib" version="2.1.0.0" targetFramework="net45" />
</packages> </packages>

View File

@ -1274,7 +1274,10 @@
"LabelForgotPasswordUsernameHelp": "Enter your username, if you remember it.", "LabelForgotPasswordUsernameHelp": "Enter your username, if you remember it.",
"HeaderForgotPassword": "Forgot Password", "HeaderForgotPassword": "Forgot Password",
"TitleForgotPassword": "Forgot Password", "TitleForgotPassword": "Forgot Password",
"TitlePasswordReset": "Password Reset", "TitlePasswordReset": "Password Reset",
"LabelPasswordRecoveryPinCode": "Pin code:", "LabelPasswordRecoveryPinCode": "Pin code:",
"HeaderPasswordReset": "Password Reset" "HeaderPasswordReset": "Password Reset",
"HeaderParentalRatings": "Parental Ratings",
"HeaderVideoTypes": "Video Types",
"HeaderYears": "Years"
} }

View File

@ -53,8 +53,9 @@
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Mono.Nat.1.2.21.0\lib\net40\Mono.Nat.dll</HintPath> <HintPath>..\packages\Mono.Nat.1.2.21.0\lib\net40\Mono.Nat.dll</HintPath>
</Reference> </Reference>
<Reference Include="MoreLinq"> <Reference Include="MoreLinq, Version=1.1.17511.0, Culture=neutral, PublicKeyToken=384d532d7e88985d, processorArchitecture=MSIL">
<HintPath>..\packages\morelinq.1.0.16006\lib\net35\MoreLinq.dll</HintPath> <SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\morelinq.1.1.0\lib\net35\MoreLinq.dll</HintPath>
</Reference> </Reference>
<Reference Include="ServiceStack.Api.Swagger"> <Reference Include="ServiceStack.Api.Swagger">
<HintPath>..\ThirdParty\ServiceStack\ServiceStack.Api.Swagger.dll</HintPath> <HintPath>..\ThirdParty\ServiceStack\ServiceStack.Api.Swagger.dll</HintPath>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="Mono.Nat" version="1.2.21.0" targetFramework="net45" /> <package id="Mono.Nat" version="1.2.21.0" targetFramework="net45" />
<package id="morelinq" version="1.0.16006" targetFramework="net45" /> <package id="morelinq" version="1.1.0" targetFramework="net45" />
</packages> </packages>

View File

@ -66,40 +66,20 @@
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="..\MediaBrowser.ServerApplication\IO\StartupOptions.cs">
<Link>IO\StartupOptions.cs</Link>
</Compile>
<Compile Include="..\SharedVersion.cs"> <Compile Include="..\SharedVersion.cs">
<Link>Properties\SharedVersion.cs</Link> <Link>Properties\SharedVersion.cs</Link>
</Compile> </Compile>
<Compile Include="Program.cs" /> <Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="..\MediaBrowser.ServerApplication\EntryPoints\StartupWizard.cs">
<Link>EntryPoints\StartupWizard.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.ServerApplication\Native\BrowserLauncher.cs">
<Link>Native\BrowserLauncher.cs</Link>
</Compile>
<Compile Include="Native\Autorun.cs" />
<Compile Include="Native\ServerAuthorization.cs" />
<Compile Include="..\MediaBrowser.ServerApplication\FFMpeg\FFMpegInfo.cs">
<Link>FFMpeg\FFMpegInfo.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.ServerApplication\ApplicationHost.cs">
<Link>ApplicationHost.cs</Link>
</Compile>
<Compile Include="Native\Assemblies.cs" />
<Compile Include="Native\NativeApp.cs" /> <Compile Include="Native\NativeApp.cs" />
<Compile Include="Networking\NetworkManager.cs" /> <Compile Include="Networking\NetworkManager.cs" />
<Compile Include="..\MediaBrowser.ServerApplication\FFMpeg\FFMpegDownloader.cs">
<Link>FFMpeg\FFMpegDownloader.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.ServerApplication\FFMpeg\FFMpegDownloadInfo.cs">
<Link>FFMpeg\FFMpegDownloadInfo.cs</Link>
</Compile>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\MediaBrowser.Server.Startup.Common\MediaBrowser.Server.Startup.Common.csproj">
<Project>{b90ab8f2-1bff-4568-a3fd-2a338a435a75}</Project>
<Name>MediaBrowser.Server.Startup.Common</Name>
</ProjectReference>
<ProjectReference Include="..\MediaBrowser.WebDashboard\MediaBrowser.WebDashboard.csproj"> <ProjectReference Include="..\MediaBrowser.WebDashboard\MediaBrowser.WebDashboard.csproj">
<Project>{5624B7B5-B5A7-41D8-9F10-CC5611109619}</Project> <Project>{5624B7B5-B5A7-41D8-9F10-CC5611109619}</Project>
<Name>MediaBrowser.WebDashboard</Name> <Name>MediaBrowser.WebDashboard</Name>

View File

@ -1,25 +0,0 @@
using MediaBrowser.IsoMounter;
using System.Collections.Generic;
using System.Reflection;
namespace MediaBrowser.ServerApplication.Native
{
/// <summary>
/// Class Assemblies
/// </summary>
public static class Assemblies
{
/// <summary>
/// Gets the assemblies with parts.
/// </summary>
/// <returns>List{Assembly}.</returns>
public static List<Assembly> GetAssembliesWithParts()
{
var list = new List<Assembly>();
list.Add(typeof(LinuxIsoManager).Assembly);
return list;
}
}
}

View File

@ -1,20 +0,0 @@
using System;
using System.IO;
namespace MediaBrowser.ServerApplication.Native
{
/// <summary>
/// Class Autorun
/// </summary>
public static class Autorun
{
/// <summary>
/// Configures the specified autorun.
/// </summary>
/// <param name="autorun">if set to <c>true</c> [autorun].</param>
public static void Configure(bool autorun)
{
}
}
}

View File

@ -1,67 +1,189 @@
using MediaBrowser.Server.Mono; using MediaBrowser.Common.Net;
using System; using MediaBrowser.IsoMounter;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Common.Updates;
using MediaBrowser.Model.Logging; using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Updates; using MediaBrowser.Server.Mono.Networking;
using MediaBrowser.Server.Startup.Common;
using Mono.Unix.Native;
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Text.RegularExpressions;
namespace MediaBrowser.ServerApplication.Native namespace MediaBrowser.Server.Mono.Native
{ {
/// <summary> /// <summary>
/// Class NativeApp /// Class NativeApp
/// </summary> /// </summary>
public static class NativeApp public class NativeApp : INativeApp
{ {
/// <summary> /// <summary>
/// Shutdowns this instance. /// Shutdowns this instance.
/// </summary> /// </summary>
public static void Shutdown() public void Shutdown()
{ {
MainClass.Shutdown (); MainClass.Shutdown();
} }
/// <summary> /// <summary>
/// Restarts this instance. /// Restarts this instance.
/// </summary> /// </summary>
public static void Restart() public void Restart()
{ {
MainClass.Restart (); MainClass.Restart();
} }
/// <summary> /// <summary>
/// Determines whether this instance [can self restart]. /// Determines whether this instance [can self restart].
/// </summary> /// </summary>
/// <returns><c>true</c> if this instance [can self restart]; otherwise, <c>false</c>.</returns> /// <returns><c>true</c> if this instance [can self restart]; otherwise, <c>false</c>.</returns>
public static bool CanSelfRestart public bool CanSelfRestart
{
get
{
return MainClass.CanSelfRestart;
}
}
/// <summary>
/// Gets a value indicating whether this instance can self update.
/// </summary>
/// <value><c>true</c> if this instance can self update; otherwise, <c>false</c>.</value>
public static bool CanSelfUpdate
{
get
{
return MainClass.CanSelfUpdate;
}
}
public static bool SupportsAutoRunAtStartup
{
get { return false; }
}
public static void PreventSystemStandby()
{ {
get
{
return MainClass.CanSelfRestart;
}
}
/// <summary>
/// Gets a value indicating whether this instance can self update.
/// </summary>
/// <value><c>true</c> if this instance can self update; otherwise, <c>false</c>.</value>
public bool CanSelfUpdate
{
get
{
return MainClass.CanSelfUpdate;
}
}
public bool SupportsAutoRunAtStartup
{
get { return false; }
}
public void PreventSystemStandby()
{
}
public List<Assembly> GetAssembliesWithParts()
{
var list = new List<Assembly>();
if (Environment.OperatingSystem == Startup.Common.OperatingSystem.Linux)
{
list.AddRange(GetLinuxAssemblies());
}
list.Add(GetType().Assembly);
return list;
}
private List<Assembly> GetLinuxAssemblies()
{
var list = new List<Assembly>();
list.Add(typeof(LinuxIsoManager).Assembly);
return list;
}
public void AuthorizeServer(int httpServerPort, string httpServerUrlPrefix, int udpPort, string tempDirectory)
{
}
private NativeEnvironment _nativeEnvironment;
public NativeEnvironment Environment
{
get { return _nativeEnvironment ?? (_nativeEnvironment = GetEnvironmentInfo()); }
}
public bool SupportsRunningAsService
{
get
{
return false;
}
}
public bool IsRunningAsService
{
get
{
return false;
}
}
public void ConfigureAutoRun(bool autorun)
{
}
public INetworkManager CreateNetworkManager(ILogger logger)
{
return new NetworkManager(logger);
}
private NativeEnvironment GetEnvironmentInfo()
{
var info = new NativeEnvironment
{
OperatingSystem = Startup.Common.OperatingSystem.Linux
};
var uname = GetUnixName();
var sysName = uname.sysname ?? string.Empty;
if (string.Equals(sysName, "Darwin", StringComparison.OrdinalIgnoreCase))
{
info.OperatingSystem = Startup.Common.OperatingSystem.Osx;
}
else if (string.Equals(sysName, "Linux", StringComparison.OrdinalIgnoreCase))
{
info.OperatingSystem = Startup.Common.OperatingSystem.Linux;
}
else if (string.Equals(sysName, "BSD", StringComparison.OrdinalIgnoreCase))
{
// TODO: How to detect BSD?
info.OperatingSystem = Startup.Common.OperatingSystem.Bsd;
}
var archX86 = new Regex("(i|I)[3-6]86");
if (archX86.IsMatch(uname.machine))
{
info.SystemArchitecture = Architecture.X86;
}
else if (string.Equals(uname.machine, "x86_64", StringComparison.OrdinalIgnoreCase))
{
info.SystemArchitecture = Architecture.X86_X64;
}
else if (uname.machine.StartsWith("arm", StringComparison.OrdinalIgnoreCase))
{
info.SystemArchitecture = Architecture.Arm;
}
return info;
}
private static Uname GetUnixName()
{
var uname = new Uname();
Utsname utsname;
var callResult = Syscall.uname(out utsname);
if (callResult == 0)
{
uname.sysname = utsname.sysname;
uname.machine = utsname.machine;
}
return uname;
}
public class Uname
{
public string sysname = string.Empty;
public string machine = string.Empty;
} }
} }
} }

View File

@ -1,26 +0,0 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
namespace MediaBrowser.ServerApplication.Native
{
/// <summary>
/// Class Authorization
/// </summary>
public static class ServerAuthorization
{
/// <summary>
/// Authorizes the server.
/// </summary>
/// <param name="httpServerPort">The HTTP server port.</param>
/// <param name="httpServerUrlPrefix">The HTTP server URL prefix.</param>
/// <param name="webSocketPort">The web socket port.</param>
/// <param name="udpPort">The UDP port.</param>
/// <param name="tempDirectory">The temp directory.</param>
public static void AuthorizeServer(int httpServerPort, string httpServerUrlPrefix, int udpPort, string tempDirectory)
{
}
}
}

View File

@ -3,11 +3,9 @@ using MediaBrowser.Common.Net;
using MediaBrowser.Model.IO; using MediaBrowser.Model.IO;
using MediaBrowser.Model.Logging; using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Net; using MediaBrowser.Model.Net;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Runtime.InteropServices;
namespace MediaBrowser.ServerApplication.Networking namespace MediaBrowser.Server.Mono.Networking
{ {
/// <summary> /// <summary>
/// Class NetUtils /// Class NetUtils

View File

@ -3,8 +3,8 @@ using MediaBrowser.Common.Implementations.IO;
using MediaBrowser.Common.Implementations.Logging; using MediaBrowser.Common.Implementations.Logging;
using MediaBrowser.Model.Logging; using MediaBrowser.Model.Logging;
using MediaBrowser.Server.Implementations; using MediaBrowser.Server.Implementations;
using MediaBrowser.ServerApplication; using MediaBrowser.Server.Mono.Native;
using MediaBrowser.ServerApplication.IO; using MediaBrowser.Server.Startup.Common;
using Microsoft.Win32; using Microsoft.Win32;
using System; using System;
using System.Diagnostics; using System.Diagnostics;
@ -114,7 +114,9 @@ namespace MediaBrowser.Server.Mono
var fileSystem = new CommonFileSystem(logManager.GetLogger("FileSystem"), false, true); var fileSystem = new CommonFileSystem(logManager.GetLogger("FileSystem"), false, true);
_appHost = new ApplicationHost(appPaths, logManager, false, false, options, fileSystem, "MBServer.Mono", false); var nativeApp = new NativeApp();
_appHost = new ApplicationHost(appPaths, logManager, options, fileSystem, "MBServer.Mono", false, nativeApp);
if (options.ContainsOption("-v")) { if (options.ContainsOption("-v")) {
Console.WriteLine (_appHost.ApplicationVersion.ToString()); Console.WriteLine (_appHost.ApplicationVersion.ToString());

View File

@ -81,10 +81,7 @@ using MediaBrowser.Server.Implementations.Session;
using MediaBrowser.Server.Implementations.Sync; using MediaBrowser.Server.Implementations.Sync;
using MediaBrowser.Server.Implementations.Themes; using MediaBrowser.Server.Implementations.Themes;
using MediaBrowser.Server.Implementations.TV; using MediaBrowser.Server.Implementations.TV;
using MediaBrowser.ServerApplication.FFMpeg; using MediaBrowser.Server.Startup.Common.FFMpeg;
using MediaBrowser.ServerApplication.IO;
using MediaBrowser.ServerApplication.Native;
using MediaBrowser.ServerApplication.Networking;
using MediaBrowser.WebDashboard.Api; using MediaBrowser.WebDashboard.Api;
using MediaBrowser.XbmcMetadata.Providers; using MediaBrowser.XbmcMetadata.Providers;
using System; using System;
@ -96,7 +93,7 @@ using System.Reflection;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace MediaBrowser.ServerApplication namespace MediaBrowser.Server.Startup.Common
{ {
/// <summary> /// <summary>
/// Class CompositionRoot /// Class CompositionRoot
@ -193,7 +190,7 @@ namespace MediaBrowser.ServerApplication
private ILiveTvManager LiveTvManager { get; set; } private ILiveTvManager LiveTvManager { get; set; }
internal ILocalizationManager LocalizationManager { get; set; } public ILocalizationManager LocalizationManager { get; set; }
private IEncodingManager EncodingManager { get; set; } private IEncodingManager EncodingManager { get; set; }
private IChannelManager ChannelManager { get; set; } private IChannelManager ChannelManager { get; set; }
@ -228,40 +225,42 @@ namespace MediaBrowser.ServerApplication
private readonly bool _supportsNativeWebSocket; private readonly bool _supportsNativeWebSocket;
internal INativeApp NativeApp { get; set; }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="ApplicationHost" /> class. /// Initializes a new instance of the <see cref="ApplicationHost" /> class.
/// </summary> /// </summary>
/// <param name="applicationPaths">The application paths.</param> /// <param name="applicationPaths">The application paths.</param>
/// <param name="logManager">The log manager.</param> /// <param name="logManager">The log manager.</param>
/// <param name="supportsRunningAsService">if set to <c>true</c> [supports running as service].</param>
/// <param name="isRunningAsService">if set to <c>true</c> [is running as service].</param>
/// <param name="options">The options.</param> /// <param name="options">The options.</param>
/// <param name="fileSystem">The file system.</param> /// <param name="fileSystem">The file system.</param>
/// <param name="remotePackageName">Name of the remote package.</param> /// <param name="remotePackageName">Name of the remote package.</param>
/// <param name="supportsNativeWebSocket">if set to <c>true</c> [supports native web socket].</param>
/// <param name="nativeApp">The native application.</param>
public ApplicationHost(ServerApplicationPaths applicationPaths, public ApplicationHost(ServerApplicationPaths applicationPaths,
ILogManager logManager, ILogManager logManager,
bool supportsRunningAsService,
bool isRunningAsService,
StartupOptions options, StartupOptions options,
IFileSystem fileSystem, IFileSystem fileSystem,
string remotePackageName, string remotePackageName,
bool supportsNativeWebSocket) bool supportsNativeWebSocket,
INativeApp nativeApp)
: base(applicationPaths, logManager, fileSystem) : base(applicationPaths, logManager, fileSystem)
{ {
_startupOptions = options; _startupOptions = options;
_remotePackageName = remotePackageName; _remotePackageName = remotePackageName;
_supportsNativeWebSocket = supportsNativeWebSocket; _supportsNativeWebSocket = supportsNativeWebSocket;
_isRunningAsService = isRunningAsService; NativeApp = nativeApp;
SupportsRunningAsService = supportsRunningAsService;
} }
private readonly bool _isRunningAsService;
public override bool IsRunningAsService public override bool IsRunningAsService
{ {
get { return _isRunningAsService; } get { return NativeApp.IsRunningAsService; }
} }
public bool SupportsRunningAsService { get; private set; } public bool SupportsRunningAsService
{
get { return NativeApp.SupportsRunningAsService; }
}
/// <summary> /// <summary>
/// Gets the name. /// Gets the name.
@ -582,7 +581,7 @@ namespace MediaBrowser.ServerApplication
protected override INetworkManager CreateNetworkManager(ILogger logger) protected override INetworkManager CreateNetworkManager(ILogger logger)
{ {
return new NetworkManager(logger); return NativeApp.CreateNetworkManager(logger);
} }
/// <summary> /// <summary>
@ -591,7 +590,8 @@ namespace MediaBrowser.ServerApplication
/// <returns>Task.</returns> /// <returns>Task.</returns>
private async Task RegisterMediaEncoder(IProgress<double> progress) private async Task RegisterMediaEncoder(IProgress<double> progress)
{ {
var info = await new FFMpegDownloader(Logger, ApplicationPaths, HttpClient, ZipClient, FileSystemManager).GetFFMpegInfo(_startupOptions, progress).ConfigureAwait(false); var info = await new FFMpegDownloader(Logger, ApplicationPaths, HttpClient, ZipClient, FileSystemManager)
.GetFFMpegInfo(NativeApp.Environment, _startupOptions, progress).ConfigureAwait(false);
MediaEncoder = new MediaEncoder(LogManager.GetLogger("MediaEncoder"), JsonSerializer, info.EncoderPath, info.ProbePath, info.Version); MediaEncoder = new MediaEncoder(LogManager.GetLogger("MediaEncoder"), JsonSerializer, info.EncoderPath, info.ProbePath, info.Version);
RegisterSingleInstance(MediaEncoder); RegisterSingleInstance(MediaEncoder);
@ -915,7 +915,7 @@ namespace MediaBrowser.ServerApplication
// Xbmc // Xbmc
list.Add(typeof(ArtistNfoProvider).Assembly); list.Add(typeof(ArtistNfoProvider).Assembly);
list.AddRange(Assemblies.GetAssembliesWithParts()); list.AddRange(NativeApp.GetAssembliesWithParts());
// Include composable parts in the running assembly // Include composable parts in the running assembly
list.Add(GetType().Assembly); list.Add(GetType().Assembly);
@ -1088,7 +1088,7 @@ namespace MediaBrowser.ServerApplication
try try
{ {
ServerAuthorization.AuthorizeServer( NativeApp.AuthorizeServer(
ServerConfigurationManager.Configuration.HttpServerPortNumber, ServerConfigurationManager.Configuration.HttpServerPortNumber,
HttpServerUrlPrefixes.First(), HttpServerUrlPrefixes.First(),
UdpServerEntryPoint.PortNumber, UdpServerEntryPoint.PortNumber,
@ -1173,7 +1173,7 @@ namespace MediaBrowser.ServerApplication
{ {
if (SupportsAutoRunAtStartup) if (SupportsAutoRunAtStartup)
{ {
Autorun.Configure(autorun); NativeApp.ConfigureAutoRun(autorun);
} }
} }
} }

View File

@ -3,7 +3,7 @@ using MediaBrowser.Model.Logging;
using System; using System;
using System.Diagnostics; using System.Diagnostics;
namespace MediaBrowser.ServerApplication.Native namespace MediaBrowser.Server.Startup.Common.Browser
{ {
/// <summary> /// <summary>
/// Class BrowserLauncher /// Class BrowserLauncher
@ -100,7 +100,7 @@ namespace MediaBrowser.ServerApplication.Native
{ {
logger.ErrorException("Error launching url: {0}", ex, url); logger.ErrorException("Error launching url: {0}", ex, url);
Console.WriteLine("Error launching browser"); Console.WriteLine(string.Format("Error launching url: {0}", ex));
Console.WriteLine(ex.Message); Console.WriteLine(ex.Message);
//#if !__MonoCS__ //#if !__MonoCS__

View File

@ -1,23 +1,25 @@
using MediaBrowser.Controller.Plugins; using MediaBrowser.Controller;
using MediaBrowser.Controller.Plugins;
using MediaBrowser.Controller.Session; using MediaBrowser.Controller.Session;
using MediaBrowser.Model.Logging; using MediaBrowser.Model.Logging;
using MediaBrowser.ServerApplication.Native;
using System; using System;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
namespace MediaBrowser.ServerApplication.EntryPoints namespace MediaBrowser.Server.Startup.Common.EntryPoints
{ {
public class KeepServerAwake : IServerEntryPoint public class KeepServerAwake : IServerEntryPoint
{ {
private readonly ISessionManager _sessionManager; private readonly ISessionManager _sessionManager;
private readonly ILogger _logger; private readonly ILogger _logger;
private Timer _timer; private Timer _timer;
private readonly IServerApplicationHost _appHost;
public KeepServerAwake(ISessionManager sessionManager, ILogger logger) public KeepServerAwake(ISessionManager sessionManager, ILogger logger, IServerApplicationHost appHost)
{ {
_sessionManager = sessionManager; _sessionManager = sessionManager;
_logger = logger; _logger = logger;
_appHost = appHost;
} }
public void Run() public void Run()
@ -35,9 +37,11 @@ namespace MediaBrowser.ServerApplication.EntryPoints
private void KeepAlive() private void KeepAlive()
{ {
var nativeApp = ((ApplicationHost)_appHost).NativeApp;
try try
{ {
NativeApp.PreventSystemStandby(); nativeApp.PreventSystemStandby();
} }
catch (Exception ex) catch (Exception ex)
{ {

View File

@ -1,9 +1,9 @@
using MediaBrowser.Controller; using MediaBrowser.Controller;
using MediaBrowser.Controller.Plugins; using MediaBrowser.Controller.Plugins;
using MediaBrowser.Model.Logging; using MediaBrowser.Model.Logging;
using MediaBrowser.ServerApplication.Native; using MediaBrowser.Server.Startup.Common.Browser;
namespace MediaBrowser.ServerApplication.EntryPoints namespace MediaBrowser.Server.Startup.Common.EntryPoints
{ {
/// <summary> /// <summary>
/// Class StartupWizard /// Class StartupWizard

View File

@ -0,0 +1,148 @@

namespace MediaBrowser.Server.Startup.Common.FFMpeg
{
public class FFMpegDownloadInfo
{
public string Version { get; set; }
public string FFMpegFilename { get; set; }
public string FFProbeFilename { get; set; }
public string ArchiveType { get; set; }
public string[] DownloadUrls { get; set; }
public FFMpegDownloadInfo()
{
DownloadUrls = new string[] { };
Version = "Path";
FFMpegFilename = "ffmpeg";
FFProbeFilename = "ffprobe";
}
public static FFMpegDownloadInfo GetInfo(NativeEnvironment environment)
{
var info = new FFMpegDownloadInfo();
// Windows builds: http://ffmpeg.zeranoe.com/builds/
// Linux builds: http://ffmpeg.gusari.org/static/
// OS X builds: http://ffmpegmac.net/
// OS X x64: http://www.evermeet.cx/ffmpeg/
switch (environment.OperatingSystem)
{
case OperatingSystem.Bsd:
break;
case OperatingSystem.Linux:
info.ArchiveType = "gz";
switch (environment.SystemArchitecture)
{
case Architecture.X86_X64:
info.Version = "20140716";
break;
case Architecture.X86:
info.Version = "20140923";
break;
}
break;
case OperatingSystem.Osx:
info.ArchiveType = "7z";
switch (environment.SystemArchitecture)
{
case Architecture.X86_X64:
info.Version = "20140923";
break;
case Architecture.X86:
info.Version = "20140716";
break;
}
break;
case OperatingSystem.Windows:
info.FFMpegFilename = "ffmpeg.exe";
info.FFProbeFilename = "ffprobe.exe";
info.Version = "20141005";
info.ArchiveType = "7z";
switch (environment.SystemArchitecture)
{
case Architecture.X86_X64:
break;
case Architecture.X86:
break;
}
break;
}
info.DownloadUrls = GetDownloadUrls(environment);
return info;
}
private static string[] GetDownloadUrls(NativeEnvironment environment)
{
switch (environment.OperatingSystem)
{
case OperatingSystem.Windows:
switch (environment.SystemArchitecture)
{
case Architecture.X86_X64:
return new[]
{
"http://ffmpeg.zeranoe.com/builds/win64/static/ffmpeg-20141005-git-e079d43-win64-static.7z",
"https://github.com/MediaBrowser/MediaBrowser.Resources/raw/master/ffmpeg/windows/ffmpeg-20141005-git-e079d43-win64-static.7z"
};
case Architecture.X86:
return new[]
{
"http://ffmpeg.zeranoe.com/builds/win32/static/ffmpeg-20141005-git-e079d43-win32-static.7z",
"https://github.com/MediaBrowser/MediaBrowser.Resources/raw/master/ffmpeg/windows/ffmpeg-20141005-git-e079d43-win32-static.7z"
};
}
break;
case OperatingSystem.Osx:
switch (environment.SystemArchitecture)
{
case Architecture.X86_X64:
return new[]
{
"https://github.com/MediaBrowser/MediaBrowser.Resources/raw/master/ffmpeg/osx/ffmpeg-x64-2.4.1.7z"
};
case Architecture.X86:
return new[]
{
"https://github.com/MediaBrowser/MediaBrowser.Resources/raw/master/ffmpeg/osx/ffmpeg-x86-2.4.2.7z"
};
}
break;
case OperatingSystem.Linux:
switch (environment.SystemArchitecture)
{
case Architecture.X86_X64:
return new[]
{
"http://ffmpeg.gusari.org/static/64bit/ffmpeg.static.64bit.latest.tar.gz",
"https://github.com/MediaBrowser/MediaBrowser.Resources/raw/master/ffmpeg/linux/ffmpeg.static.64bit.2014-07-16.tar.gz"
};
case Architecture.X86:
return new[]
{
"http://ffmpeg.gusari.org/static/32bit/ffmpeg.static.32bit.latest.tar.gz",
"https://github.com/MediaBrowser/MediaBrowser.Resources/raw/master/ffmpeg/linux/ffmpeg.static.32bit.2014-07-16.tar.gz"
};
}
break;
}
// No version available
return new string[] { };
}
}
}

View File

@ -4,7 +4,6 @@ using MediaBrowser.Common.Net;
using MediaBrowser.Model.IO; using MediaBrowser.Model.IO;
using MediaBrowser.Model.Logging; using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Net; using MediaBrowser.Model.Net;
using MediaBrowser.ServerApplication.IO;
using Mono.Unix.Native; using Mono.Unix.Native;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -14,7 +13,7 @@ using System.Text;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace MediaBrowser.ServerApplication.FFMpeg namespace MediaBrowser.Server.Startup.Common.FFMpeg
{ {
public class FFMpegDownloader public class FFMpegDownloader
{ {
@ -38,7 +37,7 @@ namespace MediaBrowser.ServerApplication.FFMpeg
_fileSystem = fileSystem; _fileSystem = fileSystem;
} }
public async Task<FFMpegInfo> GetFFMpegInfo(StartupOptions options, IProgress<double> progress) public async Task<FFMpegInfo> GetFFMpegInfo(NativeEnvironment environment, StartupOptions options, IProgress<double> progress)
{ {
var customffMpegPath = options.GetOption("-ffmpeg"); var customffMpegPath = options.GetOption("-ffmpeg");
var customffProbePath = options.GetOption("-ffprobe"); var customffProbePath = options.GetOption("-ffprobe");
@ -53,14 +52,16 @@ namespace MediaBrowser.ServerApplication.FFMpeg
}; };
} }
var version = FFMpegDownloadInfo.Version; var downloadInfo = FFMpegDownloadInfo.GetInfo(environment);
var version = downloadInfo.Version;
if (string.Equals(version, "path", StringComparison.OrdinalIgnoreCase)) if (string.Equals(version, "path", StringComparison.OrdinalIgnoreCase))
{ {
return new FFMpegInfo return new FFMpegInfo
{ {
ProbePath = FFMpegDownloadInfo.FFProbeFilename, ProbePath = downloadInfo.FFProbeFilename,
EncoderPath = FFMpegDownloadInfo.FFMpegFilename, EncoderPath = downloadInfo.FFMpegFilename,
Version = version Version = version
}; };
} }
@ -70,8 +71,8 @@ namespace MediaBrowser.ServerApplication.FFMpeg
var info = new FFMpegInfo var info = new FFMpegInfo
{ {
ProbePath = Path.Combine(versionedDirectoryPath, FFMpegDownloadInfo.FFProbeFilename), ProbePath = Path.Combine(versionedDirectoryPath, downloadInfo.FFProbeFilename),
EncoderPath = Path.Combine(versionedDirectoryPath, FFMpegDownloadInfo.FFMpegFilename), EncoderPath = Path.Combine(versionedDirectoryPath, downloadInfo.FFMpegFilename),
Version = version Version = version
}; };
@ -87,14 +88,14 @@ namespace MediaBrowser.ServerApplication.FFMpeg
// No older version. Need to download and block until complete // No older version. Need to download and block until complete
if (existingVersion == null) if (existingVersion == null)
{ {
await DownloadFFMpeg(versionedDirectoryPath, progress).ConfigureAwait(false); await DownloadFFMpeg(downloadInfo, versionedDirectoryPath, progress).ConfigureAwait(false);
} }
else else
{ {
// Older version found. // Older version found.
// Start with that. Download new version in the background. // Start with that. Download new version in the background.
var newPath = versionedDirectoryPath; var newPath = versionedDirectoryPath;
Task.Run(() => DownloadFFMpegInBackground(newPath)); Task.Run(() => DownloadFFMpegInBackground(downloadInfo, newPath));
info = existingVersion; info = existingVersion;
versionedDirectoryPath = Path.GetDirectoryName(info.EncoderPath); versionedDirectoryPath = Path.GetDirectoryName(info.EncoderPath);
@ -162,11 +163,11 @@ namespace MediaBrowser.ServerApplication.FFMpeg
return null; return null;
} }
private async void DownloadFFMpegInBackground(string directory) private async void DownloadFFMpegInBackground(FFMpegDownloadInfo downloadinfo, string directory)
{ {
try try
{ {
await DownloadFFMpeg(directory, new Progress<double>()).ConfigureAwait(false); await DownloadFFMpeg(downloadinfo, directory, new Progress<double>()).ConfigureAwait(false);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -174,9 +175,9 @@ namespace MediaBrowser.ServerApplication.FFMpeg
} }
} }
private async Task DownloadFFMpeg(string directory, IProgress<double> progress) private async Task DownloadFFMpeg(FFMpegDownloadInfo downloadinfo, string directory, IProgress<double> progress)
{ {
foreach (var url in FFMpegDownloadInfo.GetDownloadUrls()) foreach (var url in downloadinfo.DownloadUrls)
{ {
progress.Report(0); progress.Report(0);
@ -190,7 +191,7 @@ namespace MediaBrowser.ServerApplication.FFMpeg
}).ConfigureAwait(false); }).ConfigureAwait(false);
ExtractFFMpeg(tempFile, directory); ExtractFFMpeg(downloadinfo, tempFile, directory);
return; return;
} }
catch (Exception ex) catch (Exception ex)
@ -202,7 +203,7 @@ namespace MediaBrowser.ServerApplication.FFMpeg
throw new ApplicationException("Unable to download required components. Please try again later."); throw new ApplicationException("Unable to download required components. Please try again later.");
} }
private void ExtractFFMpeg(string tempFile, string targetFolder) private void ExtractFFMpeg(FFMpegDownloadInfo downloadinfo, string tempFile, string targetFolder)
{ {
_logger.Info("Extracting ffmpeg from {0}", tempFile); _logger.Info("Extracting ffmpeg from {0}", tempFile);
@ -212,7 +213,7 @@ namespace MediaBrowser.ServerApplication.FFMpeg
try try
{ {
ExtractArchive(tempFile, tempFolder); ExtractArchive(downloadinfo, tempFile, tempFolder);
var files = Directory.EnumerateFiles(tempFolder, "*", SearchOption.AllDirectories).ToList(); var files = Directory.EnumerateFiles(tempFolder, "*", SearchOption.AllDirectories).ToList();
@ -221,8 +222,8 @@ namespace MediaBrowser.ServerApplication.FFMpeg
var filename = Path.GetFileName(i); var filename = Path.GetFileName(i);
return return
string.Equals(filename, FFMpegDownloadInfo.FFProbeFilename, StringComparison.OrdinalIgnoreCase) || string.Equals(filename, downloadinfo.FFProbeFilename, StringComparison.OrdinalIgnoreCase) ||
string.Equals(filename, FFMpegDownloadInfo.FFMpegFilename, StringComparison.OrdinalIgnoreCase); string.Equals(filename, downloadinfo.FFMpegFilename, StringComparison.OrdinalIgnoreCase);
})) }))
{ {
File.Copy(file, Path.Combine(targetFolder, Path.GetFileName(file)), true); File.Copy(file, Path.Combine(targetFolder, Path.GetFileName(file)), true);
@ -245,15 +246,15 @@ namespace MediaBrowser.ServerApplication.FFMpeg
} }
} }
private void ExtractArchive(string archivePath, string targetPath) private void ExtractArchive(FFMpegDownloadInfo downloadinfo, string archivePath, string targetPath)
{ {
_logger.Info("Extracting {0} to {1}", archivePath, targetPath); _logger.Info("Extracting {0} to {1}", archivePath, targetPath);
if (string.Equals(FFMpegDownloadInfo.ArchiveType, "7z", StringComparison.OrdinalIgnoreCase)) if (string.Equals(downloadinfo.ArchiveType, "7z", StringComparison.OrdinalIgnoreCase))
{ {
_zipClient.ExtractAllFrom7z(archivePath, targetPath, true); _zipClient.ExtractAllFrom7z(archivePath, targetPath, true);
} }
else if (string.Equals(FFMpegDownloadInfo.ArchiveType, "gz", StringComparison.OrdinalIgnoreCase)) else if (string.Equals(downloadinfo.ArchiveType, "gz", StringComparison.OrdinalIgnoreCase))
{ {
_zipClient.ExtractAllFromTar(archivePath, targetPath, true); _zipClient.ExtractAllFromTar(archivePath, targetPath, true);
} }

View File

@ -1,4 +1,4 @@
namespace MediaBrowser.ServerApplication.FFMpeg namespace MediaBrowser.Server.Startup.Common.FFMpeg
{ {
/// <summary> /// <summary>
/// Class FFMpegInfo /// Class FFMpegInfo

View File

@ -0,0 +1,88 @@
using MediaBrowser.Common.Net;
using MediaBrowser.Model.Logging;
using System.Collections.Generic;
using System.Reflection;
namespace MediaBrowser.Server.Startup.Common
{
public interface INativeApp
{
/// <summary>
/// Gets the assemblies with parts.
/// </summary>
/// <returns>List&lt;Assembly&gt;.</returns>
List<Assembly> GetAssembliesWithParts();
/// <summary>
/// Authorizes the server.
/// </summary>
/// <param name="httpServerPort">The HTTP server port.</param>
/// <param name="httpServerUrlPrefix">The HTTP server URL prefix.</param>
/// <param name="udpPort">The UDP port.</param>
/// <param name="tempDirectory">The temporary directory.</param>
void AuthorizeServer(int httpServerPort, string httpServerUrlPrefix, int udpPort, string tempDirectory);
/// <summary>
/// Gets the environment.
/// </summary>
/// <value>The environment.</value>
NativeEnvironment Environment { get; }
/// <summary>
/// Gets a value indicating whether [supports running as service].
/// </summary>
/// <value><c>true</c> if [supports running as service]; otherwise, <c>false</c>.</value>
bool SupportsRunningAsService { get; }
/// <summary>
/// Gets a value indicating whether this instance is running as service.
/// </summary>
/// <value><c>true</c> if this instance is running as service; otherwise, <c>false</c>.</value>
bool IsRunningAsService { get; }
/// <summary>
/// Gets a value indicating whether this instance can self restart.
/// </summary>
/// <value><c>true</c> if this instance can self restart; otherwise, <c>false</c>.</value>
bool CanSelfRestart { get; }
/// <summary>
/// Gets a value indicating whether [supports autorun at startup].
/// </summary>
/// <value><c>true</c> if [supports autorun at startup]; otherwise, <c>false</c>.</value>
bool SupportsAutoRunAtStartup { get; }
/// <summary>
/// Gets a value indicating whether this instance can self update.
/// </summary>
/// <value><c>true</c> if this instance can self update; otherwise, <c>false</c>.</value>
bool CanSelfUpdate { get; }
/// <summary>
/// Shutdowns this instance.
/// </summary>
void Shutdown();
/// <summary>
/// Restarts this instance.
/// </summary>
void Restart();
/// <summary>
/// Configures the automatic run.
/// </summary>
/// <param name="autorun">if set to <c>true</c> [autorun].</param>
void ConfigureAutoRun(bool autorun);
/// <summary>
/// Gets the network manager.
/// </summary>
/// <returns>INetworkManager.</returns>
INetworkManager CreateNetworkManager(ILogger logger);
/// <summary>
/// Prevents the system stand by.
/// </summary>
void PreventSystemStandby();
}
}

View File

@ -0,0 +1,128 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{B90AB8F2-1BFF-4568-A3FD-2A338A435A75}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>MediaBrowser.Server.Startup.Common</RootNamespace>
<AssemblyName>MediaBrowser.Server.Startup.Common</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<RestorePackages>true</RestorePackages>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Mono.Posix, Version=4.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Mono.Posix.4.0.0.0\lib\net40\Mono.Posix.dll</HintPath>
</Reference>
<Reference Include="ServiceStack.Interfaces, Version=4.0.0.0, Culture=neutral, PublicKeyToken=e06fbc6124f57c43, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\ThirdParty\ServiceStack\ServiceStack.Interfaces.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\SharedVersion.cs">
<Link>Properties\SharedVersion.cs</Link>
</Compile>
<Compile Include="ApplicationHost.cs" />
<Compile Include="Browser\BrowserLauncher.cs" />
<Compile Include="EntryPoints\KeepServerAwake.cs" />
<Compile Include="EntryPoints\StartupWizard.cs" />
<Compile Include="FFMpeg\FFMpegDownloader.cs" />
<Compile Include="FFMpeg\FFMpegDownloadInfo.cs" />
<Compile Include="FFMpeg\FFMpegInfo.cs" />
<Compile Include="INativeApp.cs" />
<Compile Include="NativeEnvironment.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="StartupOptions.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MediaBrowser.Api\MediaBrowser.Api.csproj">
<Project>{4fd51ac5-2c16-4308-a993-c3a84f3b4582}</Project>
<Name>MediaBrowser.Api</Name>
</ProjectReference>
<ProjectReference Include="..\MediaBrowser.Common.Implementations\MediaBrowser.Common.Implementations.csproj">
<Project>{c4d2573a-3fd3-441f-81af-174ac4cd4e1d}</Project>
<Name>MediaBrowser.Common.Implementations</Name>
</ProjectReference>
<ProjectReference Include="..\MediaBrowser.Common\MediaBrowser.Common.csproj">
<Project>{9142eefa-7570-41e1-bfcc-468bb571af2f}</Project>
<Name>MediaBrowser.Common</Name>
</ProjectReference>
<ProjectReference Include="..\MediaBrowser.Controller\MediaBrowser.Controller.csproj">
<Project>{17e1f4e6-8abd-4fe5-9ecf-43d4b6087ba2}</Project>
<Name>MediaBrowser.Controller</Name>
</ProjectReference>
<ProjectReference Include="..\MediaBrowser.Dlna\MediaBrowser.Dlna.csproj">
<Project>{734098eb-6dc1-4dd0-a1ca-3140dcd2737c}</Project>
<Name>MediaBrowser.Dlna</Name>
</ProjectReference>
<ProjectReference Include="..\MediaBrowser.LocalMetadata\MediaBrowser.LocalMetadata.csproj">
<Project>{7ef9f3e0-697d-42f3-a08f-19deb5f84392}</Project>
<Name>MediaBrowser.LocalMetadata</Name>
</ProjectReference>
<ProjectReference Include="..\MediaBrowser.MediaEncoding\MediaBrowser.MediaEncoding.csproj">
<Project>{0bd82fa6-eb8a-4452-8af5-74f9c3849451}</Project>
<Name>MediaBrowser.MediaEncoding</Name>
</ProjectReference>
<ProjectReference Include="..\MediaBrowser.Model\MediaBrowser.Model.csproj">
<Project>{7eeeb4bb-f3e8-48fc-b4c5-70f0fff8329b}</Project>
<Name>MediaBrowser.Model</Name>
</ProjectReference>
<ProjectReference Include="..\MediaBrowser.Providers\MediaBrowser.Providers.csproj">
<Project>{442b5058-dcaf-4263-bb6a-f21e31120a1b}</Project>
<Name>MediaBrowser.Providers</Name>
</ProjectReference>
<ProjectReference Include="..\MediaBrowser.Server.Implementations\MediaBrowser.Server.Implementations.csproj">
<Project>{2e781478-814d-4a48-9d80-bff206441a65}</Project>
<Name>MediaBrowser.Server.Implementations</Name>
</ProjectReference>
<ProjectReference Include="..\MediaBrowser.WebDashboard\MediaBrowser.WebDashboard.csproj">
<Project>{5624b7b5-b5a7-41d8-9f10-cc5611109619}</Project>
<Name>MediaBrowser.WebDashboard</Name>
</ProjectReference>
<ProjectReference Include="..\MediaBrowser.XbmcMetadata\MediaBrowser.XbmcMetadata.csproj">
<Project>{23499896-b135-4527-8574-c26e926ea99e}</Project>
<Name>MediaBrowser.XbmcMetadata</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -0,0 +1,24 @@

namespace MediaBrowser.Server.Startup.Common
{
public class NativeEnvironment
{
public OperatingSystem OperatingSystem { get; set; }
public Architecture SystemArchitecture { get; set; }
}
public enum OperatingSystem
{
Windows = 0,
Osx = 1,
Bsd = 2,
Linux = 3
}
public enum Architecture
{
X86 = 0,
X86_X64 = 1,
Arm = 2
}
}

View File

@ -0,0 +1,31 @@
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.Server.Startup.Common")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MediaBrowser.Server.Startup.Common")]
[assembly: AssemblyCopyright("Copyright © 2014")]
[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("fcc1d690-3a86-4c4b-baef-439c53e1547a")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//

View File

@ -2,7 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
namespace MediaBrowser.ServerApplication.IO namespace MediaBrowser.Server.Startup.Common
{ {
public class StartupOptions public class StartupOptions
{ {

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Mono.Posix" version="4.0.0.0" targetFramework="net45" />
</packages>

View File

@ -1,252 +0,0 @@
using Mono.Unix.Native;
using System;
using System.IO;
using System.Text.RegularExpressions;
namespace MediaBrowser.ServerApplication.FFMpeg
{
public static class FFMpegDownloadInfo
{
// Windows builds: http://ffmpeg.zeranoe.com/builds/
// Linux builds: http://ffmpeg.gusari.org/static/
// OS X builds: http://ffmpegmac.net/
// OS X x64: http://www.evermeet.cx/ffmpeg/
public static string Version = getFfmpegValue("Version");
public static string FFMpegFilename = getFfmpegValue("FFMpegFilename");
public static string FFProbeFilename = getFfmpegValue("FFProbeFilename");
public static string ArchiveType = getFfmpegValue("ArchiveType");
private static string getFfmpegValue(string arg)
{
OperatingSystem os = Environment.OSVersion;
PlatformID pid = os.Platform;
switch (pid)
{
case PlatformID.Win32NT:
switch (arg)
{
case "Version":
return "20141005";
case "FFMpegFilename":
return "ffmpeg.exe";
case "FFProbeFilename":
return "ffprobe.exe";
case "ArchiveType":
return "7z";
}
break;
case PlatformID.Unix:
if (PlatformDetection.IsMac)
{
if (PlatformDetection.IsX86_64)
{
switch (arg)
{
case "Version":
return "20140923";
case "FFMpegFilename":
return "ffmpeg";
case "FFProbeFilename":
return "ffprobe";
case "ArchiveType":
return "7z";
}
}
if (PlatformDetection.IsX86)
{
switch (arg)
{
case "Version":
return "20140910";
case "FFMpegFilename":
return "ffmpeg";
case "FFProbeFilename":
return "ffprobe";
case "ArchiveType":
return "7z";
}
}
}
else if (PlatformDetection.IsLinux)
{
if (PlatformDetection.IsX86)
{
switch (arg)
{
case "Version":
return "20140716";
case "FFMpegFilename":
return "ffmpeg";
case "FFProbeFilename":
return "ffprobe";
case "ArchiveType":
return "gz";
}
}
else if (PlatformDetection.IsX86_64)
{
// Linux on x86 or x86_64
switch (arg)
{
case "Version":
return "20140716";
case "FFMpegFilename":
return "ffmpeg";
case "FFProbeFilename":
return "ffprobe";
case "ArchiveType":
return "gz";
}
}
}
break;
}
switch (arg)
{
case "Version":
return "path";
case "FFMpegFilename":
return "ffmpeg";
case "FFProbeFilename":
return "ffprobe";
case "ArchiveType":
return "";
default:
return string.Empty;
}
}
public static string[] GetDownloadUrls()
{
var pid = Environment.OSVersion.Platform;
switch (pid)
{
case PlatformID.Win32NT:
if (PlatformDetection.IsX86_64)
{
return new[]
{
"http://ffmpeg.zeranoe.com/builds/win64/static/ffmpeg-20141005-git-e079d43-win64-static.7z",
"https://github.com/MediaBrowser/MediaBrowser.Resources/raw/master/ffmpeg/windows/ffmpeg-20141005-git-e079d43-win64-static.7z"
};
}
return new[]
{
"http://ffmpeg.zeranoe.com/builds/win32/static/ffmpeg-20141005-git-e079d43-win32-static.7z",
"https://github.com/MediaBrowser/MediaBrowser.Resources/raw/master/ffmpeg/windows/ffmpeg-20141005-git-e079d43-win32-static.7z"
};
case PlatformID.Unix:
if (PlatformDetection.IsMac && PlatformDetection.IsX86)
{
return new[]
{
"https://github.com/MediaBrowser/MediaBrowser.Resources/raw/master/ffmpeg/osx/ffmpeg-x86-2.4.2.7z"
};
}
if (PlatformDetection.IsMac && PlatformDetection.IsX86_64)
{
return new[]
{
"https://github.com/MediaBrowser/MediaBrowser.Resources/raw/master/ffmpeg/osx/ffmpeg-x64-2.4.1.7z"
};
}
if (PlatformDetection.IsLinux)
{
if (PlatformDetection.IsX86)
{
return new[]
{
"http://ffmpeg.gusari.org/static/32bit/ffmpeg.static.32bit.latest.tar.gz",
"https://github.com/MediaBrowser/MediaBrowser.Resources/raw/master/ffmpeg/linux/ffmpeg.static.32bit.2014-07-16.tar.gz"
};
}
if (PlatformDetection.IsX86_64)
{
return new[]
{
"http://ffmpeg.gusari.org/static/64bit/ffmpeg.static.64bit.latest.tar.gz",
"https://github.com/MediaBrowser/MediaBrowser.Resources/raw/master/ffmpeg/linux/ffmpeg.static.64bit.2014-07-16.tar.gz"
};
}
}
// No Unix version available
return new string[] { };
default:
throw new ApplicationException("No ffmpeg download available for " + pid);
}
}
}
public static class PlatformDetection
{
public readonly static bool IsWindows;
public readonly static bool IsMac;
public readonly static bool IsLinux;
public readonly static bool IsX86;
public readonly static bool IsX86_64;
public readonly static bool IsArm;
static PlatformDetection()
{
IsWindows = Path.DirectorySeparatorChar == '\\';
// Don't call uname on windows
if (!IsWindows)
{
var uname = GetUnixName();
var sysName = uname.sysname ?? string.Empty;
IsMac = string.Equals(sysName, "Darwin", StringComparison.OrdinalIgnoreCase);
IsLinux = string.Equals(sysName, "Linux", StringComparison.OrdinalIgnoreCase);
var archX86 = new Regex("(i|I)[3-6]86");
IsX86 = archX86.IsMatch(uname.machine);
IsX86_64 = !IsX86 && uname.machine == "x86_64";
IsArm = !IsX86 && !IsX86_64 && uname.machine.StartsWith("arm");
}
else
{
if (Environment.Is64BitOperatingSystem)
IsX86_64 = true;
else
IsX86 = true;
}
}
private static Uname GetUnixName()
{
var uname = new Uname();
Utsname utsname;
var callResult = Syscall.uname(out utsname);
if (callResult == 0)
{
uname.sysname = utsname.sysname;
uname.machine = utsname.machine;
}
return uname;
}
}
public class Uname
{
public string sysname = string.Empty;
public string machine = string.Empty;
}
}

View File

@ -1,65 +0,0 @@
namespace MediaBrowser.ServerApplication.Logging
{
partial class LogForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(LogForm));
this.listBox1 = new System.Windows.Forms.ListBox();
this.SuspendLayout();
//
// listBox1
//
this.listBox1.Dock = System.Windows.Forms.DockStyle.Fill;
this.listBox1.Font = new System.Drawing.Font("Consolas", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.listBox1.FormattingEnabled = true;
this.listBox1.ItemHeight = 18;
this.listBox1.Location = new System.Drawing.Point(0, 0);
this.listBox1.Margin = new System.Windows.Forms.Padding(0);
this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(984, 561);
this.listBox1.TabIndex = 0;
//
// LogForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(984, 561);
this.Controls.Add(this.listBox1);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "LogForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Media Browser Log";
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.ListBox listBox1;
}
}

View File

@ -1,88 +0,0 @@
using MediaBrowser.Common.Implementations.Logging;
using MediaBrowser.Model.Logging;
using NLog.Targets;
using System;
using System.ComponentModel;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace MediaBrowser.ServerApplication.Logging
{
public partial class LogForm : Form
{
private readonly TaskScheduler _uiThread;
private readonly ILogManager _logManager;
public LogForm(ILogManager logManager)
{
InitializeComponent();
_logManager = logManager;
_uiThread = TaskScheduler.FromCurrentSynchronizationContext();
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
((NlogManager)_logManager).RemoveTarget("LogWindowTraceTarget");
((NlogManager)_logManager).AddLogTarget(new TraceTarget
{
Layout = "${longdate}, ${level}, ${logger}, ${message}",
Name = "LogWindowTraceTarget"
}, LogSeverity.Debug);
}
/// <summary>
/// Logs the message.
/// </summary>
/// <param name="msg">The MSG.</param>
public async void LogMessage(string msg)
{
await Task.Factory.StartNew(() =>
{
if (listBox1.Items.Count > 10000)
{
//I think the quickest and safest thing to do here is just clear it out
listBox1.Items.Clear();
}
foreach (var line in msg.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries))
{
if (!string.IsNullOrWhiteSpace(line))
{
listBox1.Items.Insert(0, line);
}
}
}, CancellationToken.None, TaskCreationOptions.None, _uiThread);
}
/// <summary>
/// The log layout
/// </summary>
/// <value>The log layout.</value>
public string LogLayout
{
get { return "${longdate}, ${level}, ${logger}, ${message}"; }
}
/// <summary>
/// Shuts down.
/// </summary>
public async void ShutDown()
{
await Task.Factory.StartNew(Close, CancellationToken.None, TaskCreationOptions.None, _uiThread);
}
protected override void OnClosing(CancelEventArgs e)
{
base.OnClosing(e);
((NlogManager)_logManager).RemoveTarget("LogWindowTraceTarget");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,75 +0,0 @@
using System.Diagnostics;
namespace MediaBrowser.ServerApplication.Logging
{
/// <summary>
/// Class WindowTraceListener
/// </summary>
public class WindowTraceListener : DefaultTraceListener
{
/// <summary>
/// The _window
/// </summary>
private readonly LogForm _window;
/// <summary>
/// Initializes a new instance of the <see cref="WindowTraceListener" /> class.
/// </summary>
/// <param name="window">The window.</param>
public WindowTraceListener(LogForm window)
{
_window = window;
_window.Show();
Name = "MBLogWindow";
}
/// <summary>
/// Writes the value of the object's <see cref="M:System.Object.ToString" /> method to the listener you create when you implement the <see cref="T:System.Diagnostics.TraceListener" /> class.
/// </summary>
/// <param name="o">An <see cref="T:System.Object" /> whose fully qualified class name you want to write.</param>
public override void Write(object o)
{
var str = o as string;
if (str != null)
Write(str);
else
base.Write(o);
}
/// <summary>
/// Writes the output to the OutputDebugString function and to the <see cref="M:System.Diagnostics.Debugger.Log(System.Int32,System.String,System.String)" /> method.
/// </summary>
/// <param name="message">The message to write to OutputDebugString and <see cref="M:System.Diagnostics.Debugger.Log(System.Int32,System.String,System.String)" />.</param>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="ControlEvidence" />
/// </PermissionSet>
public override void Write(string message)
{
_window.LogMessage(message);
}
/// <summary>
/// Writes the output to the OutputDebugString function and to the <see cref="M:System.Diagnostics.Debugger.Log(System.Int32,System.String,System.String)" /> method, followed by a carriage return and line feed (\r\n).
/// </summary>
/// <param name="message">The message to write to OutputDebugString and <see cref="M:System.Diagnostics.Debugger.Log(System.Int32,System.String,System.String)" />.</param>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="ControlEvidence" />
/// </PermissionSet>
public override void WriteLine(string message)
{
Write(message+"\n");
}
/// <summary>
/// Releases the unmanaged resources used by the <see cref="T:System.Diagnostics.TraceListener" /> and optionally releases the managed resources.
/// </summary>
/// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources.</param>
protected override void Dispose(bool disposing)
{
if (_window != null)
_window.ShutDown();
base.Dispose(disposing);
}
}
}

View File

@ -2,7 +2,8 @@
using MediaBrowser.Common.Implementations.Logging; using MediaBrowser.Common.Implementations.Logging;
using MediaBrowser.Model.Logging; using MediaBrowser.Model.Logging;
using MediaBrowser.Server.Implementations; using MediaBrowser.Server.Implementations;
using MediaBrowser.ServerApplication.IO; using MediaBrowser.Server.Startup.Common;
using MediaBrowser.Server.Startup.Common.Browser;
using MediaBrowser.ServerApplication.Native; using MediaBrowser.ServerApplication.Native;
using MediaBrowser.ServerApplication.Splash; using MediaBrowser.ServerApplication.Splash;
using MediaBrowser.ServerApplication.Updates; using MediaBrowser.ServerApplication.Updates;
@ -211,21 +212,25 @@ namespace MediaBrowser.ServerApplication
{ {
var fileSystem = new NativeFileSystem(logManager.GetLogger("FileSystem"), false); var fileSystem = new NativeFileSystem(logManager.GetLogger("FileSystem"), false);
_appHost = new ApplicationHost(appPaths, var nativeApp = new WindowsApp
logManager, {
true, IsRunningAsService = runService
runService, };
options,
fileSystem, _appHost = new ApplicationHost(appPaths,
logManager,
options,
fileSystem,
"MBServer", "MBServer",
true); true,
nativeApp);
var initProgress = new Progress<double>(); var initProgress = new Progress<double>();
if (!runService) if (!runService)
{ {
if (!options.ContainsOption("-nosplash")) ShowSplashScreen(_appHost.ApplicationVersion, initProgress, logManager.GetLogger("Splash")); if (!options.ContainsOption("-nosplash")) ShowSplashScreen(_appHost.ApplicationVersion, initProgress, logManager.GetLogger("Splash"));
// Not crazy about this but it's the only way to suppress ffmpeg crash dialog boxes // Not crazy about this but it's the only way to suppress ffmpeg crash dialog boxes
SetErrorMode(ErrorModes.SEM_FAILCRITICALERRORS | ErrorModes.SEM_NOALIGNMENTFAULTEXCEPT | SetErrorMode(ErrorModes.SEM_FAILCRITICALERRORS | ErrorModes.SEM_NOALIGNMENTFAULTEXCEPT |
ErrorModes.SEM_NOGPFAULTERRORBOX | ErrorModes.SEM_NOOPENFILEERRORBOX); ErrorModes.SEM_NOGPFAULTERRORBOX | ErrorModes.SEM_NOOPENFILEERRORBOX);
@ -245,11 +250,11 @@ namespace MediaBrowser.ServerApplication
SystemEvents.SessionEnding += SystemEvents_SessionEnding; SystemEvents.SessionEnding += SystemEvents_SessionEnding;
SystemEvents.SessionSwitch += SystemEvents_SessionSwitch; SystemEvents.SessionSwitch += SystemEvents_SessionSwitch;
HideSplashScreen(); HideSplashScreen();
ShowTrayIcon(); ShowTrayIcon();
task = ApplicationTaskCompletionSource.Task; task = ApplicationTaskCompletionSource.Task;
Task.WaitAll(task); Task.WaitAll(task);
} }
@ -260,7 +265,7 @@ namespace MediaBrowser.ServerApplication
{ {
//Application.EnableVisualStyles(); //Application.EnableVisualStyles();
//Application.SetCompatibleTextRenderingDefault(false); //Application.SetCompatibleTextRenderingDefault(false);
_serverNotifyIcon = new ServerNotifyIcon(_appHost.LogManager, _appHost, _appHost.ServerConfigurationManager, _appHost.UserManager, _appHost.LibraryManager, _appHost.JsonSerializer, _appHost.LocalizationManager, _appHost.UserViewManager); _serverNotifyIcon = new ServerNotifyIcon(_appHost.LogManager, _appHost, _appHost.ServerConfigurationManager, _appHost.LocalizationManager);
Application.Run(); Application.Run();
} }
@ -274,7 +279,7 @@ namespace MediaBrowser.ServerApplication
_splash.ShowDialog(); _splash.ShowDialog();
}); });
thread.SetApartmentState(ApartmentState.STA); thread.SetApartmentState(ApartmentState.STA);
thread.IsBackground = true; thread.IsBackground = true;
thread.Start(); thread.Start();

View File

@ -63,10 +63,6 @@
<Reference Include="MediaBrowser.IsoMounter"> <Reference Include="MediaBrowser.IsoMounter">
<HintPath>..\packages\MediaBrowser.IsoMounting.3.0.69\lib\net45\MediaBrowser.IsoMounter.dll</HintPath> <HintPath>..\packages\MediaBrowser.IsoMounting.3.0.69\lib\net45\MediaBrowser.IsoMounter.dll</HintPath>
</Reference> </Reference>
<Reference Include="Mono.Posix, Version=4.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Mono.Posix.4.0.0.0\lib\net40\Mono.Posix.dll</HintPath>
</Reference>
<Reference Include="NLog, Version=3.1.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL"> <Reference Include="NLog, Version=3.1.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\NLog.3.1.0.0\lib\net45\NLog.dll</HintPath> <HintPath>..\packages\NLog.3.1.0.0\lib\net45\NLog.dll</HintPath>
@ -98,28 +94,14 @@
<Compile Include="..\SharedVersion.cs"> <Compile Include="..\SharedVersion.cs">
<Link>Properties\SharedVersion.cs</Link> <Link>Properties\SharedVersion.cs</Link>
</Compile> </Compile>
<Compile Include="ApplicationHost.cs" />
<Compile Include="BackgroundService.cs"> <Compile Include="BackgroundService.cs">
<SubType>Component</SubType> <SubType>Component</SubType>
</Compile> </Compile>
<Compile Include="BackgroundServiceInstaller.cs"> <Compile Include="BackgroundServiceInstaller.cs">
<SubType>Component</SubType> <SubType>Component</SubType>
</Compile> </Compile>
<Compile Include="EntryPoints\KeepServerAwake.cs" />
<Compile Include="EntryPoints\ResourceEntryPoint.cs" /> <Compile Include="EntryPoints\ResourceEntryPoint.cs" />
<Compile Include="EntryPoints\StartupWizard.cs" /> <Compile Include="Native\NativeFileSystem.cs" />
<Compile Include="FFMpeg\FFMpegDownloader.cs" />
<Compile Include="FFMpeg\FFMpegDownloadInfo.cs" />
<Compile Include="FFMpeg\FFMpegInfo.cs" />
<Compile Include="IO\NativeFileSystem.cs" />
<Compile Include="IO\StartupOptions.cs" />
<Compile Include="Logging\LogForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Logging\LogForm.Designer.cs">
<DependentUpon>LogForm.cs</DependentUpon>
</Compile>
<Compile Include="Logging\WindowTraceListener.cs" />
<Compile Include="MainForm.cs"> <Compile Include="MainForm.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
@ -127,11 +109,10 @@
<DependentUpon>MainForm.cs</DependentUpon> <DependentUpon>MainForm.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="MainStartup.cs" /> <Compile Include="MainStartup.cs" />
<Compile Include="Native\Assemblies.cs" />
<Compile Include="Native\Autorun.cs" /> <Compile Include="Native\Autorun.cs" />
<Compile Include="Native\BrowserLauncher.cs" /> <Compile Include="Native\Standby.cs" />
<Compile Include="Native\NativeApp.cs" />
<Compile Include="Native\ServerAuthorization.cs" /> <Compile Include="Native\ServerAuthorization.cs" />
<Compile Include="Native\WindowsApp.cs" />
<Compile Include="Networking\NativeMethods.cs" /> <Compile Include="Networking\NativeMethods.cs" />
<Compile Include="Networking\NetworkManager.cs" /> <Compile Include="Networking\NetworkManager.cs" />
<Compile Include="Networking\NetworkShares.cs" /> <Compile Include="Networking\NetworkShares.cs" />
@ -157,9 +138,6 @@
<None Include="packages.config" /> <None Include="packages.config" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="Logging\LogForm.resx">
<DependentUpon>LogForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="MainForm.resx"> <EmbeddedResource Include="MainForm.resx">
<DependentUpon>MainForm.cs</DependentUpon> <DependentUpon>MainForm.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
@ -232,6 +210,10 @@
<Project>{2e781478-814d-4a48-9d80-bff206441a65}</Project> <Project>{2e781478-814d-4a48-9d80-bff206441a65}</Project>
<Name>MediaBrowser.Server.Implementations</Name> <Name>MediaBrowser.Server.Implementations</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\MediaBrowser.Server.Startup.Common\MediaBrowser.Server.Startup.Common.csproj">
<Project>{b90ab8f2-1bff-4568-a3fd-2a338a435a75}</Project>
<Name>MediaBrowser.Server.Startup.Common</Name>
</ProjectReference>
<ProjectReference Include="..\MediaBrowser.WebDashboard\MediaBrowser.WebDashboard.csproj"> <ProjectReference Include="..\MediaBrowser.WebDashboard\MediaBrowser.WebDashboard.csproj">
<Project>{5624b7b5-b5a7-41d8-9f10-cc5611109619}</Project> <Project>{5624b7b5-b5a7-41d8-9f10-cc5611109619}</Project>
<Name>MediaBrowser.WebDashboard</Name> <Name>MediaBrowser.WebDashboard</Name>

View File

@ -1,25 +0,0 @@
using MediaBrowser.IsoMounter;
using System.Collections.Generic;
using System.Reflection;
namespace MediaBrowser.ServerApplication.Native
{
/// <summary>
/// Class Assemblies
/// </summary>
public static class Assemblies
{
/// <summary>
/// Gets the assemblies with parts.
/// </summary>
/// <returns>List{Assembly}.</returns>
public static List<Assembly> GetAssembliesWithParts()
{
var list = new List<Assembly>();
list.Add(typeof(PismoIsoManager).Assembly);
return list;
}
}
}

View File

@ -1,88 +0,0 @@
using System.Runtime.InteropServices;
namespace MediaBrowser.ServerApplication.Native
{
/// <summary>
/// Class NativeApp
/// </summary>
public static class NativeApp
{
/// <summary>
/// Shutdowns this instance.
/// </summary>
public static void Shutdown()
{
MainStartup.Shutdown();
}
/// <summary>
/// Restarts this instance.
/// </summary>
public static void Restart()
{
MainStartup.Restart();
}
/// <summary>
/// Determines whether this instance [can self restart].
/// </summary>
/// <returns><c>true</c> if this instance [can self restart]; otherwise, <c>false</c>.</returns>
public static bool CanSelfRestart
{
get
{
return MainStartup.CanSelfRestart;
}
}
/// <summary>
/// Gets a value indicating whether [supports automatic run at startup].
/// </summary>
/// <value><c>true</c> if [supports automatic run at startup]; otherwise, <c>false</c>.</value>
public static bool SupportsAutoRunAtStartup
{
get
{
return true;
}
}
/// <summary>
/// Gets a value indicating whether this instance can self update.
/// </summary>
/// <value><c>true</c> if this instance can self update; otherwise, <c>false</c>.</value>
public static bool CanSelfUpdate
{
get
{
return MainStartup.CanSelfUpdate;
}
}
public static void PreventSystemStandby()
{
SystemHelper.ResetStandbyTimer();
}
internal enum EXECUTION_STATE : uint
{
ES_NONE = 0,
ES_SYSTEM_REQUIRED = 0x00000001,
ES_DISPLAY_REQUIRED = 0x00000002,
ES_USER_PRESENT = 0x00000004,
ES_AWAYMODE_REQUIRED = 0x00000040,
ES_CONTINUOUS = 0x80000000
}
public class SystemHelper
{
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
static extern EXECUTION_STATE SetThreadExecutionState(EXECUTION_STATE esFlags);
public static void ResetStandbyTimer()
{
EXECUTION_STATE es = SetThreadExecutionState(EXECUTION_STATE.ES_SYSTEM_REQUIRED);
}
}
}
}

View File

@ -6,7 +6,7 @@ using System.Runtime.InteropServices;
using System.Security; using System.Security;
using System.Text; using System.Text;
namespace MediaBrowser.ServerApplication.IO namespace MediaBrowser.ServerApplication.Native
{ {
public class NativeFileSystem : CommonFileSystem public class NativeFileSystem : CommonFileSystem
{ {

View File

@ -0,0 +1,36 @@
using System.Runtime.InteropServices;
namespace MediaBrowser.ServerApplication.Native
{
/// <summary>
/// Class NativeApp
/// </summary>
public static class Standby
{
public static void PreventSystemStandby()
{
SystemHelper.ResetStandbyTimer();
}
internal enum EXECUTION_STATE : uint
{
ES_NONE = 0,
ES_SYSTEM_REQUIRED = 0x00000001,
ES_DISPLAY_REQUIRED = 0x00000002,
ES_USER_PRESENT = 0x00000004,
ES_AWAYMODE_REQUIRED = 0x00000040,
ES_CONTINUOUS = 0x80000000
}
public class SystemHelper
{
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
static extern EXECUTION_STATE SetThreadExecutionState(EXECUTION_STATE esFlags);
public static void ResetStandbyTimer()
{
EXECUTION_STATE es = SetThreadExecutionState(EXECUTION_STATE.ES_SYSTEM_REQUIRED);
}
}
}
}

View File

@ -0,0 +1,104 @@
using MediaBrowser.Common.Net;
using MediaBrowser.IsoMounter;
using MediaBrowser.Model.Logging;
using MediaBrowser.Server.Startup.Common;
using MediaBrowser.ServerApplication.Networking;
using System.Collections.Generic;
using System.Reflection;
namespace MediaBrowser.ServerApplication.Native
{
public class WindowsApp : INativeApp
{
public List<Assembly> GetAssembliesWithParts()
{
var list = new List<Assembly>();
list.Add(typeof(PismoIsoManager).Assembly);
list.Add(GetType().Assembly);
return list;
}
public void AuthorizeServer(int httpServerPort, string httpServerUrlPrefix, int udpPort, string tempDirectory)
{
ServerAuthorization.AuthorizeServer(httpServerPort, httpServerUrlPrefix, udpPort, tempDirectory);
}
public NativeEnvironment Environment
{
get
{
return new NativeEnvironment
{
OperatingSystem = OperatingSystem.Windows,
SystemArchitecture = System.Environment.Is64BitOperatingSystem ? Architecture.X86_X64 : Architecture.X86
};
}
}
public bool SupportsRunningAsService
{
get
{
return true;
}
}
public bool IsRunningAsService
{
get;
set;
}
public bool CanSelfRestart
{
get
{
return MainStartup.CanSelfRestart;
}
}
public bool SupportsAutoRunAtStartup
{
get
{
return true;
}
}
public bool CanSelfUpdate
{
get
{
return MainStartup.CanSelfUpdate;
}
}
public void Shutdown()
{
MainStartup.Shutdown();
}
public void Restart()
{
MainStartup.Restart();
}
public void ConfigureAutoRun(bool autorun)
{
Autorun.Configure(autorun);
}
public INetworkManager CreateNetworkManager(ILogger logger)
{
return new NetworkManager(logger);
}
public void PreventSystemStandby()
{
Standby.PreventSystemStandby();
}
}
}

View File

@ -5,7 +5,7 @@ using MediaBrowser.Controller.Localization;
using MediaBrowser.Controller.Persistence; using MediaBrowser.Controller.Persistence;
using MediaBrowser.Model.Logging; using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Serialization; using MediaBrowser.Model.Serialization;
using MediaBrowser.ServerApplication.Logging; using MediaBrowser.Server.Startup.Common.Browser;
using MediaBrowser.ServerApplication.Native; using MediaBrowser.ServerApplication.Native;
using System; using System;
using System.Diagnostics; using System.Diagnostics;
@ -25,7 +25,6 @@ namespace MediaBrowser.ServerApplication
private System.Windows.Forms.ToolStripSeparator toolStripSeparator2; private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
private System.Windows.Forms.ToolStripMenuItem cmdRestart; private System.Windows.Forms.ToolStripMenuItem cmdRestart;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
private System.Windows.Forms.ToolStripMenuItem cmdLogWindow;
private System.Windows.Forms.ToolStripMenuItem cmdCommunity; private System.Windows.Forms.ToolStripMenuItem cmdCommunity;
private System.Windows.Forms.ToolStripMenuItem cmdApiDocs; private System.Windows.Forms.ToolStripMenuItem cmdApiDocs;
private System.Windows.Forms.ToolStripMenuItem cmdSwagger; private System.Windows.Forms.ToolStripMenuItem cmdSwagger;
@ -33,14 +32,8 @@ namespace MediaBrowser.ServerApplication
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly IServerApplicationHost _appHost; private readonly IServerApplicationHost _appHost;
private readonly ILogManager _logManager;
private readonly IServerConfigurationManager _configurationManager; private readonly IServerConfigurationManager _configurationManager;
private readonly IUserManager _userManager;
private readonly ILibraryManager _libraryManager;
private readonly IJsonSerializer _jsonSerializer;
private readonly IUserViewManager _userViewManager;
private readonly ILocalizationManager _localization; private readonly ILocalizationManager _localization;
private LogForm _logForm;
public bool Visible public bool Visible
{ {
@ -57,20 +50,13 @@ namespace MediaBrowser.ServerApplication
public ServerNotifyIcon(ILogManager logManager, public ServerNotifyIcon(ILogManager logManager,
IServerApplicationHost appHost, IServerApplicationHost appHost,
IServerConfigurationManager configurationManager, IServerConfigurationManager configurationManager,
IUserManager userManager, ILibraryManager libraryManager, ILocalizationManager localization)
IJsonSerializer jsonSerializer,
ILocalizationManager localization, IUserViewManager userViewManager)
{ {
_logger = logManager.GetLogger("MainWindow"); _logger = logManager.GetLogger("MainWindow");
_localization = localization; _localization = localization;
_userViewManager = userViewManager;
_appHost = appHost; _appHost = appHost;
_logManager = logManager;
_configurationManager = configurationManager; _configurationManager = configurationManager;
_userManager = userManager;
_libraryManager = libraryManager;
_jsonSerializer = jsonSerializer;
var components = new System.ComponentModel.Container(); var components = new System.ComponentModel.Container();
@ -80,7 +66,6 @@ namespace MediaBrowser.ServerApplication
cmdExit = new System.Windows.Forms.ToolStripMenuItem(); cmdExit = new System.Windows.Forms.ToolStripMenuItem();
cmdCommunity = new System.Windows.Forms.ToolStripMenuItem(); cmdCommunity = new System.Windows.Forms.ToolStripMenuItem();
cmdLogWindow = new System.Windows.Forms.ToolStripMenuItem();
toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
cmdRestart = new System.Windows.Forms.ToolStripMenuItem(); cmdRestart = new System.Windows.Forms.ToolStripMenuItem();
toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
@ -107,7 +92,6 @@ namespace MediaBrowser.ServerApplication
cmdRestart, cmdRestart,
toolStripSeparator1, toolStripSeparator1,
cmdApiDocs, cmdApiDocs,
//cmdLogWindow,
cmdCommunity, cmdCommunity,
cmdExit}); cmdExit});
contextMenuStrip1.Name = "contextMenuStrip1"; contextMenuStrip1.Name = "contextMenuStrip1";
@ -125,12 +109,6 @@ namespace MediaBrowser.ServerApplication
cmdCommunity.Name = "cmdCommunity"; cmdCommunity.Name = "cmdCommunity";
cmdCommunity.Size = new System.Drawing.Size(208, 22); cmdCommunity.Size = new System.Drawing.Size(208, 22);
// //
// cmdLogWindow
//
cmdLogWindow.CheckOnClick = true;
cmdLogWindow.Name = "cmdLogWindow";
cmdLogWindow.Size = new System.Drawing.Size(208, 22);
//
// toolStripSeparator1 // toolStripSeparator1
// //
toolStripSeparator1.Name = "toolStripSeparator1"; toolStripSeparator1.Name = "toolStripSeparator1";
@ -176,7 +154,6 @@ namespace MediaBrowser.ServerApplication
cmdExit.Click += cmdExit_Click; cmdExit.Click += cmdExit_Click;
cmdRestart.Click += cmdRestart_Click; cmdRestart.Click += cmdRestart_Click;
cmdLogWindow.Click += cmdLogWindow_Click;
cmdConfigure.Click += cmdConfigure_Click; cmdConfigure.Click += cmdConfigure_Click;
cmdCommunity.Click += cmdCommunity_Click; cmdCommunity.Click += cmdCommunity_Click;
cmdBrowse.Click += cmdBrowse_Click; cmdBrowse.Click += cmdBrowse_Click;
@ -184,8 +161,6 @@ namespace MediaBrowser.ServerApplication
cmdSwagger.Click += cmdSwagger_Click; cmdSwagger.Click += cmdSwagger_Click;
cmdGtihub.Click += cmdGtihub_Click; cmdGtihub.Click += cmdGtihub_Click;
LoadLogWindow(null, EventArgs.Empty);
_logManager.LoggerLoaded += LoadLogWindow;
_configurationManager.ConfigurationUpdated += Instance_ConfigurationUpdated; _configurationManager.ConfigurationUpdated += Instance_ConfigurationUpdated;
LocalizeText(); LocalizeText();
@ -210,7 +185,6 @@ namespace MediaBrowser.ServerApplication
cmdBrowse.Text = _localization.GetLocalizedString("LabelBrowseLibrary"); cmdBrowse.Text = _localization.GetLocalizedString("LabelBrowseLibrary");
cmdConfigure.Text = _localization.GetLocalizedString("LabelConfigureMediaBrowser"); cmdConfigure.Text = _localization.GetLocalizedString("LabelConfigureMediaBrowser");
cmdRestart.Text = _localization.GetLocalizedString("LabelRestartServer"); cmdRestart.Text = _localization.GetLocalizedString("LabelRestartServer");
cmdLogWindow.Text = _localization.GetLocalizedString("LabelShowLogWindow");
} }
private string _uiCulture; private string _uiCulture;
@ -226,62 +200,6 @@ namespace MediaBrowser.ServerApplication
{ {
LocalizeText(); LocalizeText();
} }
Action action = () =>
{
var isLogWindowOpen = _logForm != null;
if ((!isLogWindowOpen && _configurationManager.Configuration.ShowLogWindow) ||
(isLogWindowOpen && !_configurationManager.Configuration.ShowLogWindow))
{
_logManager.ReloadLogger(_configurationManager.Configuration.EnableDebugLevelLogging
? LogSeverity.Debug
: LogSeverity.Info);
}
};
contextMenuStrip1.Invoke(action);
}
/// <summary>
/// Loads the log window.
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="args">The <see cref="EventArgs" /> instance containing the event data.</param>
void LoadLogWindow(object sender, EventArgs args)
{
CloseLogWindow();
Action action = () =>
{
// Add our log window if specified
if (_configurationManager.Configuration.ShowLogWindow)
{
_logForm = new LogForm(_logManager);
Trace.Listeners.Add(new WindowTraceListener(_logForm));
}
else
{
Trace.Listeners.Remove("MBLogWindow");
}
// Set menu option indicator
cmdLogWindow.Checked = _configurationManager.Configuration.ShowLogWindow;
};
contextMenuStrip1.Invoke(action);
}
/// <summary>
/// Closes the log window.
/// </summary>
void CloseLogWindow()
{
if (_logForm != null)
{
_logForm.ShutDown();
}
} }
void cmdBrowse_Click(object sender, EventArgs e) void cmdBrowse_Click(object sender, EventArgs e)
@ -299,13 +217,6 @@ namespace MediaBrowser.ServerApplication
BrowserLauncher.OpenDashboard(_appHost, _logger); BrowserLauncher.OpenDashboard(_appHost, _logger);
} }
void cmdLogWindow_Click(object sender, EventArgs e)
{
_configurationManager.Configuration.ShowLogWindow = !_configurationManager.Configuration.ShowLogWindow;
_configurationManager.SaveConfiguration();
LoadLogWindow(sender, e);
}
void cmdRestart_Click(object sender, EventArgs e) void cmdRestart_Click(object sender, EventArgs e)
{ {
_appHost.Restart(); _appHost.Restart();

View File

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="MediaBrowser.IsoMounting" version="3.0.69" targetFramework="net45" /> <package id="MediaBrowser.IsoMounting" version="3.0.69" targetFramework="net45" />
<package id="Mono.Posix" version="4.0.0.0" targetFramework="net45" />
<package id="NLog" version="3.1.0.0" targetFramework="net45" /> <package id="NLog" version="3.1.0.0" targetFramework="net45" />
<package id="System.Data.SQLite.Core" version="1.0.94.0" targetFramework="net45" /> <package id="System.Data.SQLite.Core" version="1.0.94.0" targetFramework="net45" />
</packages> </packages>

View File

@ -55,6 +55,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediaBrowser.MediaInfo", "M
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediaBrowser.Server.Mono", "MediaBrowser.Server.Mono\MediaBrowser.Server.Mono.csproj", "{175A9388-F352-4586-A6B4-070DED62B644}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediaBrowser.Server.Mono", "MediaBrowser.Server.Mono\MediaBrowser.Server.Mono.csproj", "{175A9388-F352-4586-A6B4-070DED62B644}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediaBrowser.Server.Startup.Common", "MediaBrowser.Server.Startup.Common\MediaBrowser.Server.Startup.Common.csproj", "{B90AB8F2-1BFF-4568-A3FD-2A338A435A75}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug_Ubuntu|Any CPU = Debug_Ubuntu|Any CPU Debug_Ubuntu|Any CPU = Debug_Ubuntu|Any CPU
@ -773,6 +775,41 @@ Global
{175A9388-F352-4586-A6B4-070DED62B644}.Release|x64.ActiveCfg = Release|Any CPU {175A9388-F352-4586-A6B4-070DED62B644}.Release|x64.ActiveCfg = Release|Any CPU
{175A9388-F352-4586-A6B4-070DED62B644}.Release|x86.ActiveCfg = Release|x86 {175A9388-F352-4586-A6B4-070DED62B644}.Release|x86.ActiveCfg = Release|x86
{175A9388-F352-4586-A6B4-070DED62B644}.Release|x86.Build.0 = Release|x86 {175A9388-F352-4586-A6B4-070DED62B644}.Release|x86.Build.0 = Release|x86
{B90AB8F2-1BFF-4568-A3FD-2A338A435A75}.Debug_Ubuntu|Any CPU.ActiveCfg = Debug|Any CPU
{B90AB8F2-1BFF-4568-A3FD-2A338A435A75}.Debug_Ubuntu|Any CPU.Build.0 = Debug|Any CPU
{B90AB8F2-1BFF-4568-A3FD-2A338A435A75}.Debug_Ubuntu|Mixed Platforms.ActiveCfg = Debug|Any CPU
{B90AB8F2-1BFF-4568-A3FD-2A338A435A75}.Debug_Ubuntu|Mixed Platforms.Build.0 = Debug|Any CPU
{B90AB8F2-1BFF-4568-A3FD-2A338A435A75}.Debug_Ubuntu|Win32.ActiveCfg = Debug|Any CPU
{B90AB8F2-1BFF-4568-A3FD-2A338A435A75}.Debug_Ubuntu|x64.ActiveCfg = Debug|Any CPU
{B90AB8F2-1BFF-4568-A3FD-2A338A435A75}.Debug_Ubuntu|x86.ActiveCfg = Debug|Any CPU
{B90AB8F2-1BFF-4568-A3FD-2A338A435A75}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B90AB8F2-1BFF-4568-A3FD-2A338A435A75}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B90AB8F2-1BFF-4568-A3FD-2A338A435A75}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{B90AB8F2-1BFF-4568-A3FD-2A338A435A75}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{B90AB8F2-1BFF-4568-A3FD-2A338A435A75}.Debug|Win32.ActiveCfg = Debug|Any CPU
{B90AB8F2-1BFF-4568-A3FD-2A338A435A75}.Debug|x64.ActiveCfg = Debug|Any CPU
{B90AB8F2-1BFF-4568-A3FD-2A338A435A75}.Debug|x86.ActiveCfg = Debug|Any CPU
{B90AB8F2-1BFF-4568-A3FD-2A338A435A75}.Release Mono|Any CPU.ActiveCfg = Release|Any CPU
{B90AB8F2-1BFF-4568-A3FD-2A338A435A75}.Release Mono|Any CPU.Build.0 = Release|Any CPU
{B90AB8F2-1BFF-4568-A3FD-2A338A435A75}.Release Mono|Mixed Platforms.ActiveCfg = Release|Any CPU
{B90AB8F2-1BFF-4568-A3FD-2A338A435A75}.Release Mono|Mixed Platforms.Build.0 = Release|Any CPU
{B90AB8F2-1BFF-4568-A3FD-2A338A435A75}.Release Mono|Win32.ActiveCfg = Release|Any CPU
{B90AB8F2-1BFF-4568-A3FD-2A338A435A75}.Release Mono|x64.ActiveCfg = Release|Any CPU
{B90AB8F2-1BFF-4568-A3FD-2A338A435A75}.Release Mono|x86.ActiveCfg = Release|Any CPU
{B90AB8F2-1BFF-4568-A3FD-2A338A435A75}.Release_Ubuntu|Any CPU.ActiveCfg = Release|Any CPU
{B90AB8F2-1BFF-4568-A3FD-2A338A435A75}.Release_Ubuntu|Any CPU.Build.0 = Release|Any CPU
{B90AB8F2-1BFF-4568-A3FD-2A338A435A75}.Release_Ubuntu|Mixed Platforms.ActiveCfg = Release|Any CPU
{B90AB8F2-1BFF-4568-A3FD-2A338A435A75}.Release_Ubuntu|Mixed Platforms.Build.0 = Release|Any CPU
{B90AB8F2-1BFF-4568-A3FD-2A338A435A75}.Release_Ubuntu|Win32.ActiveCfg = Release|Any CPU
{B90AB8F2-1BFF-4568-A3FD-2A338A435A75}.Release_Ubuntu|x64.ActiveCfg = Release|Any CPU
{B90AB8F2-1BFF-4568-A3FD-2A338A435A75}.Release_Ubuntu|x86.ActiveCfg = Release|Any CPU
{B90AB8F2-1BFF-4568-A3FD-2A338A435A75}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B90AB8F2-1BFF-4568-A3FD-2A338A435A75}.Release|Any CPU.Build.0 = Release|Any CPU
{B90AB8F2-1BFF-4568-A3FD-2A338A435A75}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{B90AB8F2-1BFF-4568-A3FD-2A338A435A75}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{B90AB8F2-1BFF-4568-A3FD-2A338A435A75}.Release|Win32.ActiveCfg = Release|Any CPU
{B90AB8F2-1BFF-4568-A3FD-2A338A435A75}.Release|x64.ActiveCfg = Release|Any CPU
{B90AB8F2-1BFF-4568-A3FD-2A338A435A75}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE