mirror of
https://github.com/Radarr/Radarr.git
synced 2026-04-19 21:46:50 -04:00
removed NzbDrone.Console dependency to UI components
This commit is contained in:
@@ -1,60 +0,0 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Instrumentation;
|
||||
using NzbDrone.Common.Security;
|
||||
using NzbDrone.Core.Datastore;
|
||||
|
||||
namespace NzbDrone
|
||||
{
|
||||
public static class AppMain
|
||||
{
|
||||
private static readonly Logger Logger = LogManager.GetLogger("AppMain");
|
||||
|
||||
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
try
|
||||
{
|
||||
GlobalExceptionHandlers.Register();
|
||||
IgnoreCertErrorPolicy.Register();
|
||||
|
||||
Logger.Info("Starting NzbDrone Console. Version {0}", Assembly.GetExecutingAssembly().GetName().Version);
|
||||
|
||||
//Check if full version .NET is installed.
|
||||
try
|
||||
{
|
||||
Assembly.Load("System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
Logger.Error("It looks like you don't have full version of .NET Framework installed. Press any key and you will be directed to the download page.");
|
||||
Console.Read();
|
||||
|
||||
try
|
||||
{
|
||||
Process.Start("http://www.microsoft.com/download/en/details.aspx?id=17851");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Warn("Oops. can't start default browser. Please visit http://www.microsoft.com/download/en/details.aspx?id=17851 to download .NET Framework 4.");
|
||||
Console.ReadLine();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
var container = MainAppContainerBuilder.BuildContainer(args);
|
||||
|
||||
DbFactory.RegisterDatabase(container);
|
||||
container.Resolve<Router>().Route();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.FatalException("Epic Fail " + e.Message, e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
namespace NzbDrone
|
||||
{
|
||||
public enum ApplicationModes
|
||||
{
|
||||
Console,
|
||||
Help,
|
||||
InstallService,
|
||||
UninstallService,
|
||||
Service,
|
||||
}
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
using System;
|
||||
using System.ServiceProcess;
|
||||
using NLog;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Host;
|
||||
using NzbDrone.Owin;
|
||||
|
||||
namespace NzbDrone
|
||||
{
|
||||
public interface INzbDroneServiceFactory
|
||||
{
|
||||
ServiceBase Build();
|
||||
void Start();
|
||||
}
|
||||
|
||||
public class NzbDroneServiceFactory : ServiceBase, INzbDroneServiceFactory
|
||||
{
|
||||
private readonly IConfigFileProvider _configFileProvider;
|
||||
private readonly IRuntimeInfo _runtimeInfo;
|
||||
private readonly IHostController _hostController;
|
||||
private readonly IProcessProvider _processProvider;
|
||||
private readonly PriorityMonitor _priorityMonitor;
|
||||
private readonly StartupArguments _startupArguments;
|
||||
private readonly IFirewallAdapter _firewallAdapter;
|
||||
private readonly IUrlAclAdapter _urlAclAdapter;
|
||||
private readonly Logger _logger;
|
||||
|
||||
public NzbDroneServiceFactory(IConfigFileProvider configFileProvider, IHostController hostController, IRuntimeInfo runtimeInfo,
|
||||
IProcessProvider processProvider, PriorityMonitor priorityMonitor, StartupArguments startupArguments,
|
||||
IFirewallAdapter firewallAdapter, IUrlAclAdapter urlAclAdapter, Logger logger)
|
||||
{
|
||||
_configFileProvider = configFileProvider;
|
||||
_hostController = hostController;
|
||||
_runtimeInfo = runtimeInfo;
|
||||
_processProvider = processProvider;
|
||||
_priorityMonitor = priorityMonitor;
|
||||
_startupArguments = startupArguments;
|
||||
_firewallAdapter = firewallAdapter;
|
||||
_urlAclAdapter = urlAclAdapter;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
protected override void OnStart(string[] args)
|
||||
{
|
||||
Start();
|
||||
}
|
||||
|
||||
public void Start()
|
||||
{
|
||||
if (_runtimeInfo.IsAdmin)
|
||||
{
|
||||
_urlAclAdapter.RefreshRegistration();
|
||||
_firewallAdapter.MakeAccessible();
|
||||
|
||||
}
|
||||
_hostController.StartServer();
|
||||
|
||||
if (!_startupArguments.Flags.Contains(StartupArguments.NO_BROWSER) &&
|
||||
_runtimeInfo.IsUserInteractive &&
|
||||
_configFileProvider.LaunchBrowser)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger.Info("Starting default browser. {0}", _hostController.AppUrl);
|
||||
_processProvider.Start(_hostController.AppUrl);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.ErrorException("Failed to open URL in default browser.", e);
|
||||
}
|
||||
}
|
||||
|
||||
_priorityMonitor.Start();
|
||||
}
|
||||
|
||||
protected override void OnStop()
|
||||
{
|
||||
_logger.Info("Attempting to stop application.");
|
||||
_hostController.StopServer();
|
||||
_logger.Info("Application has finished stop routine.");
|
||||
}
|
||||
|
||||
public ServiceBase Build()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,146 +0,0 @@
|
||||
using System;
|
||||
using NLog;
|
||||
using NetFwTypeLib;
|
||||
using NzbDrone.Core.Configuration;
|
||||
|
||||
namespace NzbDrone.Host
|
||||
{
|
||||
public interface IFirewallAdapter
|
||||
{
|
||||
void MakeAccessible();
|
||||
bool IsNzbDronePortOpen();
|
||||
}
|
||||
|
||||
public class FirewallAdapter : IFirewallAdapter
|
||||
{
|
||||
private readonly IConfigFileProvider _configFileProvider;
|
||||
private readonly Logger _logger;
|
||||
|
||||
public FirewallAdapter(IConfigFileProvider configFileProvider, Logger logger)
|
||||
{
|
||||
_configFileProvider = configFileProvider;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public void MakeAccessible()
|
||||
{
|
||||
int port = 0;
|
||||
|
||||
if (IsFirewallEnabled())
|
||||
{
|
||||
if (IsNzbDronePortOpen())
|
||||
{
|
||||
_logger.Trace("NzbDrone port is already open, skipping.");
|
||||
return;
|
||||
}
|
||||
|
||||
CloseFirewallPort();
|
||||
|
||||
//Open the new port
|
||||
OpenFirewallPort(_configFileProvider.Port);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public bool IsNzbDronePortOpen()
|
||||
{
|
||||
try
|
||||
{
|
||||
var netFwMgrType = Type.GetTypeFromProgID("HNetCfg.FwMgr", false);
|
||||
|
||||
var mgr = (INetFwMgr)Activator.CreateInstance(netFwMgrType);
|
||||
|
||||
if (!mgr.LocalPolicy.CurrentProfile.FirewallEnabled)
|
||||
return false;
|
||||
|
||||
var ports = mgr.LocalPolicy.CurrentProfile.GloballyOpenPorts;
|
||||
|
||||
foreach (INetFwOpenPort p in ports)
|
||||
{
|
||||
if (p.Port == _configFileProvider.Port)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.WarnException("Failed to check for open port in firewall", ex);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void OpenFirewallPort(int portNumber)
|
||||
{
|
||||
try
|
||||
{
|
||||
var type = Type.GetTypeFromProgID("HNetCfg.FWOpenPort", false);
|
||||
var port = Activator.CreateInstance(type) as INetFwOpenPort;
|
||||
|
||||
port.Port = portNumber;
|
||||
port.Name = "NzbDrone";
|
||||
port.Protocol = NET_FW_IP_PROTOCOL_.NET_FW_IP_PROTOCOL_TCP;
|
||||
port.Enabled = true;
|
||||
|
||||
var netFwMgrType = Type.GetTypeFromProgID("HNetCfg.FwMgr", false);
|
||||
var mgr = (INetFwMgr)Activator.CreateInstance(netFwMgrType);
|
||||
var ports = mgr.LocalPolicy.CurrentProfile.GloballyOpenPorts;
|
||||
|
||||
ports.Add(port);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.WarnException("Failed to open port in firewall for NzbDrone " + portNumber, ex);
|
||||
}
|
||||
}
|
||||
|
||||
private int CloseFirewallPort()
|
||||
{
|
||||
try
|
||||
{
|
||||
var netFwMgrType = Type.GetTypeFromProgID("HNetCfg.FwMgr", false);
|
||||
var mgr = (INetFwMgr)Activator.CreateInstance(netFwMgrType);
|
||||
var ports = mgr.LocalPolicy.CurrentProfile.GloballyOpenPorts;
|
||||
|
||||
var portNumber = 8989;
|
||||
|
||||
foreach (INetFwOpenPort p in ports)
|
||||
{
|
||||
if (p.Name == "NzbDrone")
|
||||
{
|
||||
portNumber = p.Port;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (portNumber != _configFileProvider.Port)
|
||||
{
|
||||
ports.Remove(portNumber, NET_FW_IP_PROTOCOL_.NET_FW_IP_PROTOCOL_TCP);
|
||||
return portNumber;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.WarnException("Failed to close port in firewall for NzbDrone", ex);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private bool IsFirewallEnabled()
|
||||
{
|
||||
try
|
||||
{
|
||||
var netFwMgrType = Type.GetTypeFromProgID("HNetCfg.FwMgr", false);
|
||||
var mgr = (INetFwMgr)Activator.CreateInstance(netFwMgrType);
|
||||
return mgr.LocalPolicy.CurrentProfile.FirewallEnabled;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.WarnException("Failed to check if the firewall is enabled", ex);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using NLog;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
using NzbDrone.Core.Configuration;
|
||||
|
||||
namespace NzbDrone.Host
|
||||
{
|
||||
public interface IUrlAclAdapter
|
||||
{
|
||||
void RefreshRegistration();
|
||||
}
|
||||
|
||||
public class UrlAclAdapter : IUrlAclAdapter
|
||||
{
|
||||
private readonly IProcessProvider _processProvider;
|
||||
private readonly IConfigFileProvider _configFileProvider;
|
||||
private readonly Logger _logger;
|
||||
|
||||
public UrlAclAdapter(IProcessProvider processProvider, IConfigFileProvider configFileProvider, Logger logger)
|
||||
{
|
||||
_processProvider = processProvider;
|
||||
_configFileProvider = configFileProvider;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public void RefreshRegistration()
|
||||
{
|
||||
if (OsInfo.Version.Major < 6)
|
||||
return;
|
||||
|
||||
RegisterUrl(_configFileProvider.Port);
|
||||
}
|
||||
|
||||
|
||||
private void RegisterUrl(int portNumber)
|
||||
{
|
||||
var arguments = String.Format("http add urlacl http://*:{0}/ user=EVERYONE", portNumber);
|
||||
RunNetsh(arguments);
|
||||
}
|
||||
|
||||
private string RunNetsh(string arguments)
|
||||
{
|
||||
try
|
||||
{
|
||||
var startInfo = new ProcessStartInfo()
|
||||
{
|
||||
RedirectStandardOutput = true,
|
||||
UseShellExecute = false,
|
||||
FileName = "netsh.exe",
|
||||
Arguments = arguments
|
||||
};
|
||||
|
||||
var process = _processProvider.Start(startInfo);
|
||||
process.WaitForExit(5000);
|
||||
return process.StandardOutput.ReadToEnd();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.WarnException("Error executing netsh with arguments: " + arguments, ex);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
using Nancy.Bootstrapper;
|
||||
using NzbDrone.Api;
|
||||
using NzbDrone.Api.SignalR;
|
||||
using NzbDrone.Common.Composition;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.Organizer;
|
||||
using NzbDrone.Core.RootFolders;
|
||||
|
||||
namespace NzbDrone
|
||||
{
|
||||
public class MainAppContainerBuilder : ContainerBuilderBase
|
||||
{
|
||||
public static IContainer BuildContainer(string[] args)
|
||||
{
|
||||
return new MainAppContainerBuilder(args).Container;
|
||||
}
|
||||
|
||||
private MainAppContainerBuilder(string[] args)
|
||||
: base("NzbDrone", "NzbDrone.Common", "NzbDrone.Core", "NzbDrone.Api")
|
||||
{
|
||||
AutoRegisterImplementations<NzbDronePersistentConnection>();
|
||||
|
||||
Container.Register(typeof(IBasicRepository<RootFolder>), typeof(BasicRepository<RootFolder>));
|
||||
Container.Register(typeof(IBasicRepository<NamingConfig>), typeof(BasicRepository<NamingConfig>));
|
||||
|
||||
Container.Register<INancyBootstrapper, NancyBootstrapper>();
|
||||
|
||||
Container.Register(new StartupArguments(args));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
autoReload="true"
|
||||
internalLogLevel="Info"
|
||||
throwExceptions="true"
|
||||
internalLogToConsole="true"
|
||||
internalLogToConsoleError="true">
|
||||
<extensions>
|
||||
<add assembly="NzbDrone.Core"/>
|
||||
<add assembly="NzbDrone.Common"/>
|
||||
</extensions>
|
||||
<targets>
|
||||
<target xsi:type="ColoredConsole" name="consoleLogger" layout="[${level}] ${logger}: ${message} ${onexception:inner=${newline}${newline}${exception:format=ToString}${newline}}"/>
|
||||
<target xsi:type="NLogViewer" name="udpTarget" address="udp://127.0.0.1:20480" includeCallSite="true" includeSourceInfo="true" includeNLogData="true" includeNdc="true">
|
||||
<parameter>
|
||||
<name>Exception</name>
|
||||
<layout>${exception:format=ToString}</layout>
|
||||
</parameter>
|
||||
</target>
|
||||
<target xsi:type="File" name="rollingFileLogger" fileName="${appLog}" autoFlush="true" keepFileOpen="false"
|
||||
concurrentWrites="false" concurrentWriteAttemptDelay="50" concurrentWriteAttempts ="10"
|
||||
archiveAboveSize="1024000" maxArchiveFiles="5" enableFileDelete="true" archiveNumbering ="Rolling"
|
||||
layout="${date:format=yy-M-d HH\:mm\:ss.f}|${level}|${logger}|${message}${onexception:inner=${newline}${newline}${exception:format=ToString}${newline}}"/>
|
||||
</targets>
|
||||
<rules>
|
||||
<logger name="*" minlevel="Trace" writeTo="consoleLogger"/>
|
||||
<logger name="*" minlevel="Off" writeTo="udpTarget"/>
|
||||
<logger name="*" minlevel="Info" writeTo="rollingFileLogger"/>
|
||||
</rules>
|
||||
</nlog>
|
||||
-2585
File diff suppressed because it is too large
Load Diff
+19
-93
@@ -54,114 +54,35 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationIcon>NzbDrone.ico</ApplicationIcon>
|
||||
<ApplicationIcon>..\NzbDrone.Host\NzbDrone.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<StartupObject>NzbDrone.AppMain</StartupObject>
|
||||
<StartupObject>NzbDrone.WindowsApp</StartupObject>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<RunPostBuildEvent>OnOutputUpdated</RunPostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="FluentMigrator, Version=1.1.1.0, Culture=neutral, PublicKeyToken=aacfc7de5acabf05, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\FluentMigrator.1.1.1.0\lib\40\FluentMigrator.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="FluentMigrator.Runner, Version=1.1.0.0, Culture=neutral, PublicKeyToken=aacfc7de5acabf05, processorArchitecture=x86">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\FluentMigrator.1.1.1.0\tools\FluentMigrator.Runner.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="ICSharpCode.SharpZipLib, Version=0.86.0.518, Culture=neutral, PublicKeyToken=1b03e6acf1164f73, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\SharpZipLib.0.86.0\lib\20\ICSharpCode.SharpZipLib.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Interop.NetFwTypeLib">
|
||||
<HintPath>..\Libraries\Interop.NetFwTypeLib.dll</HintPath>
|
||||
<EmbedInteropTypes>True</EmbedInteropTypes>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.AspNet.SignalR.Core, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Microsoft.AspNet.SignalR.Core.1.1.2\lib\net40\Microsoft.AspNet.SignalR.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.AspNet.SignalR.Owin, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Microsoft.AspNet.SignalR.Owin.1.1.2\lib\net40\Microsoft.AspNet.SignalR.Owin.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="Microsoft.Owin">
|
||||
<HintPath>..\packages\Microsoft.Owin.1.1.0-beta2\lib\net40\Microsoft.Owin.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Owin.Host.HttpListener, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Microsoft.Owin.Host.HttpListener.1.1.0-beta2\lib\net40\Microsoft.Owin.Host.HttpListener.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Owin.Hosting, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Microsoft.Owin.Hosting.1.1.0-beta2\lib\net40\Microsoft.Owin.Hosting.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Nancy">
|
||||
<HintPath>..\packages\Nancy.0.16.1\lib\net40\Nancy.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Nancy.Owin, Version=0.16.1.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Nancy.Owin.0.16.1\lib\net40\Nancy.Owin.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Newtonsoft.Json.5.0.6\lib\net40\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NLog, Version=2.0.1.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\NLog.2.0.1.2\lib\net40\NLog.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Owin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f0ebd12fd5e55cc5, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Owin.1.0\lib\net40\Owin.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.ServiceProcess" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\NzbDrone.Common\Properties\SharedAssemblyInfo.cs">
|
||||
<Link>Properties\SharedAssemblyInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="ApplicationServer.cs">
|
||||
<SubType>Component</SubType>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Host\FirewallAdapter.cs" />
|
||||
<Compile Include="Host\UrlAclAdapter.cs" />
|
||||
<Compile Include="MainAppContainerBuilder.cs" />
|
||||
<Compile Include="ApplicationModes.cs" />
|
||||
<Compile Include="AppMain.cs" />
|
||||
<Compile Include="Owin\MiddleWare\NancyMiddleWare.cs" />
|
||||
<Compile Include="Owin\IHostController.cs" />
|
||||
<Compile Include="Owin\MiddleWare\IOwinMiddleWare.cs" />
|
||||
<Compile Include="Owin\MiddleWare\SignalRMiddleWare.cs" />
|
||||
<Compile Include="Owin\OwinHostController.cs" />
|
||||
<Compile Include="WindowsApp.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="PriorityMonitor.cs" />
|
||||
<Compile Include="Router.cs" />
|
||||
<Compile Include="SysTray\SysTrayApp.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
<Content Include="NLog.config">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
<SubType>Designer</SubType>
|
||||
</Content>
|
||||
<None Include="NLog.xsd">
|
||||
<SubType>Designer</SubType>
|
||||
</None>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="NzbDrone.ico" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include=".NETFramework,Version=v4.0">
|
||||
<Visible>False</Visible>
|
||||
@@ -185,19 +106,24 @@
|
||||
</BootstrapperPackage>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\NzbDrone.Api\NzbDrone.Api.csproj">
|
||||
<Project>{FD286DF8-2D3A-4394-8AD5-443FADE55FB2}</Project>
|
||||
<Name>NzbDrone.Api</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\NzbDrone.Common\NzbDrone.Common.csproj">
|
||||
<Project>{F2BE0FDF-6E47-4827-A420-DD4EF82407F8}</Project>
|
||||
<Name>NzbDrone.Common</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\NzbDrone.Core\NzbDrone.Core.csproj">
|
||||
<Project>{FF5EE3B6-913B-47CE-9CEB-11C51B4E1205}</Project>
|
||||
<Name>NzbDrone.Core</Name>
|
||||
<ProjectReference Include="..\NzbDrone.Host\NzbDrone.Host.csproj">
|
||||
<Project>{95C11A9E-56ED-456A-8447-2C89C1139266}</Project>
|
||||
<Name>NzbDrone.Host</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\NzbDroneIcon.bmp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PreBuildEvent>
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 17 KiB |
@@ -1,10 +0,0 @@
|
||||
namespace NzbDrone.Owin
|
||||
{
|
||||
public interface IHostController
|
||||
{
|
||||
string AppUrl { get; }
|
||||
void StartServer();
|
||||
void RestartServer();
|
||||
void StopServer();
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
using Owin;
|
||||
|
||||
namespace NzbDrone.Owin.MiddleWare
|
||||
{
|
||||
public interface IOwinMiddleWare
|
||||
{
|
||||
int Order { get; }
|
||||
void Attach(IAppBuilder appBuilder);
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Nancy.Bootstrapper;
|
||||
using Nancy.Owin;
|
||||
using Owin;
|
||||
|
||||
namespace NzbDrone.Owin.MiddleWare
|
||||
{
|
||||
public class NancyMiddleWare : IOwinMiddleWare
|
||||
{
|
||||
private readonly INancyBootstrapper _nancyBootstrapper;
|
||||
|
||||
public NancyMiddleWare(INancyBootstrapper nancyBootstrapper)
|
||||
{
|
||||
_nancyBootstrapper = nancyBootstrapper;
|
||||
}
|
||||
|
||||
public int Order { get { return 1; } }
|
||||
|
||||
public void Attach(IAppBuilder appBuilder)
|
||||
{
|
||||
var nancyOwinHost = new NancyOwinHost(null, _nancyBootstrapper);
|
||||
appBuilder.Use((Func<Func<IDictionary<string, object>, Task>, Func<IDictionary<string, object>, Task>>)(next => (Func<IDictionary<string, object>, Task>)nancyOwinHost.Invoke), new object[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNet.SignalR;
|
||||
using NzbDrone.Api.SignalR;
|
||||
using NzbDrone.Common.Composition;
|
||||
using Owin;
|
||||
|
||||
namespace NzbDrone.Owin.MiddleWare
|
||||
{
|
||||
public class SignalRMiddleWare : IOwinMiddleWare
|
||||
{
|
||||
private readonly IEnumerable<NzbDronePersistentConnection> _persistentConnections;
|
||||
|
||||
public int Order { get { return 0; } }
|
||||
|
||||
public SignalRMiddleWare(IEnumerable<NzbDronePersistentConnection> persistentConnections, IContainer container)
|
||||
{
|
||||
_persistentConnections = persistentConnections;
|
||||
|
||||
SignalrDependencyResolver.Register(container);
|
||||
}
|
||||
|
||||
public void Attach(IAppBuilder appBuilder)
|
||||
{
|
||||
foreach (var nzbDronePersistentConnection in _persistentConnections)
|
||||
{
|
||||
var url = string.Format("signalr/{0}", nzbDronePersistentConnection.Resource.Trim('/'));
|
||||
appBuilder.MapConnection(url, nzbDronePersistentConnection.GetType(), new ConnectionConfiguration { EnableCrossDomain = true });
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.Owin.Hosting;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Security;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Owin.MiddleWare;
|
||||
using Owin;
|
||||
using System.Linq;
|
||||
|
||||
namespace NzbDrone.Owin
|
||||
{
|
||||
public class OwinHostController : IHostController
|
||||
{
|
||||
private readonly IConfigFileProvider _configFileProvider;
|
||||
private readonly IEnumerable<IOwinMiddleWare> _owinMiddleWares;
|
||||
private readonly Logger _logger;
|
||||
private IDisposable _host;
|
||||
|
||||
public OwinHostController(IConfigFileProvider configFileProvider, IEnumerable<IOwinMiddleWare> owinMiddleWares, Logger logger)
|
||||
{
|
||||
_configFileProvider = configFileProvider;
|
||||
_owinMiddleWares = owinMiddleWares;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public void StartServer()
|
||||
{
|
||||
IgnoreCertErrorPolicy.Register();
|
||||
|
||||
var url = "http://*:" + _configFileProvider.Port;
|
||||
|
||||
var options = new StartOptions(url)
|
||||
{
|
||||
ServerFactory = "Microsoft.Owin.Host.HttpListener"
|
||||
};
|
||||
|
||||
_logger.Info("starting server on {0}", url);
|
||||
|
||||
_host = WebApp.Start(options, BuildApp);
|
||||
}
|
||||
|
||||
private void BuildApp(IAppBuilder appBuilder)
|
||||
{
|
||||
appBuilder.Properties["host.AppName"] = "NzbDrone";
|
||||
|
||||
foreach (var middleWare in _owinMiddleWares.OrderBy(c => c.Order))
|
||||
{
|
||||
_logger.Debug("Attaching {0} to host", middleWare.GetType().Name);
|
||||
middleWare.Attach(appBuilder);
|
||||
}
|
||||
}
|
||||
|
||||
public string AppUrl
|
||||
{
|
||||
get { return string.Format("http://localhost:{0}", _configFileProvider.Port); }
|
||||
}
|
||||
|
||||
public void RestartServer()
|
||||
{
|
||||
_logger.Warn("Attempting to restart server.");
|
||||
|
||||
StopServer();
|
||||
StartServer();
|
||||
}
|
||||
|
||||
public void StopServer()
|
||||
{
|
||||
if (_host == null) return;
|
||||
|
||||
_logger.Info("Attempting to stop Nancy host");
|
||||
_host.Dispose();
|
||||
_host = null;
|
||||
_logger.Info("Host has stopped");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Threading;
|
||||
using NLog;
|
||||
using NzbDrone.Common;
|
||||
|
||||
namespace NzbDrone
|
||||
{
|
||||
public class PriorityMonitor
|
||||
{
|
||||
private readonly IProcessProvider _processProvider;
|
||||
private readonly Logger _logger;
|
||||
|
||||
private Timer _processPriorityCheckTimer;
|
||||
|
||||
public PriorityMonitor(IProcessProvider processProvider, Logger logger)
|
||||
{
|
||||
_processProvider = processProvider;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public void Start()
|
||||
{
|
||||
_processPriorityCheckTimer = new Timer(EnsurePriority);
|
||||
_processPriorityCheckTimer.Change(TimeSpan.FromSeconds(15), TimeSpan.FromMinutes(30));
|
||||
|
||||
}
|
||||
|
||||
public virtual void EnsurePriority(object sender)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_processProvider.GetCurrentProcessPriority() != ProcessPriorityClass.Normal)
|
||||
{
|
||||
_processProvider.SetPriority(_processProvider.GetCurrentProcess().Id, ProcessPriorityClass.Normal);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.WarnException("Unable to verify priority", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.32559
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace NzbDrone.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("NzbDrone.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
|
||||
/// </summary>
|
||||
internal static System.Drawing.Icon NzbDroneIcon {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("NzbDroneIcon", resourceCulture);
|
||||
return ((System.Drawing.Icon)(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="NzbDroneIcon" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\..\nzbdrone.host\nzbdrone.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 3.3 KiB |
@@ -1,126 +0,0 @@
|
||||
using NLog;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
using NzbDrone.SysTray;
|
||||
using IServiceProvider = NzbDrone.Common.IServiceProvider;
|
||||
|
||||
namespace NzbDrone
|
||||
{
|
||||
public class Router
|
||||
{
|
||||
private readonly INzbDroneServiceFactory _nzbDroneServiceFactory;
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
private readonly StartupArguments _startupArguments;
|
||||
private readonly IConsoleService _consoleService;
|
||||
private readonly IRuntimeInfo _runtimeInfo;
|
||||
private readonly ISystemTrayApp _systemTrayProvider;
|
||||
private readonly Logger _logger;
|
||||
|
||||
public Router(INzbDroneServiceFactory nzbDroneServiceFactory, IServiceProvider serviceProvider, StartupArguments startupArguments,
|
||||
IConsoleService consoleService, IRuntimeInfo runtimeInfo, ISystemTrayApp systemTrayProvider, Logger logger)
|
||||
{
|
||||
_nzbDroneServiceFactory = nzbDroneServiceFactory;
|
||||
_serviceProvider = serviceProvider;
|
||||
_startupArguments = startupArguments;
|
||||
_consoleService = consoleService;
|
||||
_runtimeInfo = runtimeInfo;
|
||||
_systemTrayProvider = systemTrayProvider;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public void Route()
|
||||
{
|
||||
var appMode = GetApplicationMode();
|
||||
Route(appMode);
|
||||
}
|
||||
|
||||
public void Route(ApplicationModes applicationModes)
|
||||
{
|
||||
if (!_runtimeInfo.IsUserInteractive && !OsInfo.IsLinux)
|
||||
{
|
||||
applicationModes = ApplicationModes.Service;
|
||||
}
|
||||
|
||||
_logger.Info("Application mode: {0}", applicationModes);
|
||||
|
||||
switch (applicationModes)
|
||||
{
|
||||
case ApplicationModes.Service:
|
||||
{
|
||||
_logger.Trace("Service selected");
|
||||
_serviceProvider.Run(_nzbDroneServiceFactory.Build());
|
||||
break;
|
||||
}
|
||||
|
||||
case ApplicationModes.Console:
|
||||
{
|
||||
_logger.Trace("Console selected");
|
||||
_nzbDroneServiceFactory.Start();
|
||||
if (_consoleService.IsConsoleApplication)
|
||||
{
|
||||
_consoleService.WaitForClose();
|
||||
}
|
||||
else
|
||||
{
|
||||
_systemTrayProvider.Start();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case ApplicationModes.InstallService:
|
||||
{
|
||||
_logger.Trace("Install Service selected");
|
||||
if (_serviceProvider.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME))
|
||||
{
|
||||
_consoleService.PrintServiceAlreadyExist();
|
||||
}
|
||||
else
|
||||
{
|
||||
_serviceProvider.Install(ServiceProvider.NZBDRONE_SERVICE_NAME);
|
||||
_serviceProvider.Start(ServiceProvider.NZBDRONE_SERVICE_NAME);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ApplicationModes.UninstallService:
|
||||
{
|
||||
_logger.Trace("Uninstall Service selected");
|
||||
if (!_serviceProvider.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME))
|
||||
{
|
||||
_consoleService.PrintServiceDoesNotExist();
|
||||
}
|
||||
else
|
||||
{
|
||||
_serviceProvider.UnInstall(ServiceProvider.NZBDRONE_SERVICE_NAME);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
_consoleService.PrintHelp();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ApplicationModes GetApplicationMode()
|
||||
{
|
||||
if (_startupArguments.Flags.Contains(StartupArguments.HELP))
|
||||
{
|
||||
return ApplicationModes.Help;
|
||||
}
|
||||
|
||||
if (!OsInfo.IsLinux && _startupArguments.Flags.Contains(StartupArguments.INSTALL_SERVICE))
|
||||
{
|
||||
return ApplicationModes.InstallService;
|
||||
}
|
||||
|
||||
if (!OsInfo.IsLinux && _startupArguments.Flags.Contains(StartupArguments.UNINSTALL_SERVICE))
|
||||
{
|
||||
return ApplicationModes.UninstallService;
|
||||
}
|
||||
|
||||
return ApplicationModes.Console;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,9 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
using NzbDrone.Owin;
|
||||
using NzbDrone.Host.Owin;
|
||||
|
||||
namespace NzbDrone.SysTray
|
||||
{
|
||||
@@ -32,15 +29,15 @@ namespace NzbDrone.SysTray
|
||||
|
||||
public void Start()
|
||||
{
|
||||
Application.ThreadException += new ThreadExceptionEventHandler(OnThreadException);
|
||||
Application.ApplicationExit += new EventHandler(OnApplicationExit);
|
||||
Application.ThreadException += OnThreadException;
|
||||
Application.ApplicationExit += OnApplicationExit;
|
||||
|
||||
_trayMenu.MenuItems.Add("Launch Browser", LaunchBrowser);
|
||||
_trayMenu.MenuItems.Add("-");
|
||||
_trayMenu.MenuItems.Add("Exit", OnExit);
|
||||
|
||||
_trayIcon.Text = String.Format("NzbDrone - {0}", BuildInfo.Version);
|
||||
_trayIcon.Icon = new Icon(Assembly.GetEntryAssembly().GetManifestResourceStream("NzbDrone.NzbDrone.ico"));
|
||||
_trayIcon.Icon = Properties.Resources.NzbDroneIcon;
|
||||
|
||||
_trayIcon.ContextMenu = _trayMenu;
|
||||
_trayIcon.Visible = true;
|
||||
@@ -85,7 +82,14 @@ namespace NzbDrone.SysTray
|
||||
|
||||
private void LaunchBrowser(object sender, EventArgs e)
|
||||
{
|
||||
_processProvider.Start(_hostController.AppUrl);
|
||||
try
|
||||
{
|
||||
_processProvider.Start(_hostController.AppUrl);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void OnApplicationExit(object sender, EventArgs e)
|
||||
@@ -100,10 +104,17 @@ namespace NzbDrone.SysTray
|
||||
|
||||
private void DisposeTrayIcon()
|
||||
{
|
||||
_trayIcon.Visible = false;
|
||||
_trayIcon.Icon = null;
|
||||
_trayIcon.Visible = false;
|
||||
_trayIcon.Dispose();
|
||||
try
|
||||
{
|
||||
_trayIcon.Visible = false;
|
||||
_trayIcon.Icon = null;
|
||||
_trayIcon.Visible = false;
|
||||
_trayIcon.Dispose();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using NzbDrone.SysTray;
|
||||
|
||||
namespace NzbDrone
|
||||
{
|
||||
public static class WindowsApp
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
try
|
||||
{
|
||||
var container = Host.Bootstrap.Start(args);
|
||||
container.Register<ISystemTrayApp, SystemTrayApp>();
|
||||
container.Resolve<ISystemTrayApp>().Start();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
var message = string.Format("{0}: {1}", e.GetType().Name, e.Message);
|
||||
MessageBox.Show(text: message, buttons: MessageBoxButtons.OK, icon: MessageBoxIcon.Error, caption: "Epic Fail!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<system.net>
|
||||
<connectionManagement>
|
||||
<add address="*" maxconnection="100" />
|
||||
</connectionManagement>
|
||||
</system.net>
|
||||
<startup useLegacyV2RuntimeActivationPolicy="true">
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
|
||||
</startup>
|
||||
<runtime>
|
||||
<loadFromRemoteSources enabled="true" />
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<probing privatePath="libs" />
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="4.5.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="NLog" publicKeyToken="5120e14c03d0593c" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.0.1.0" newVersion="2.0.1.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Microsoft.AspNet.SignalR.Core" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-1.1.0.0" newVersion="1.1.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="FluentMigrator" publicKeyToken="aacfc7de5acabf05" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-1.1.1.0" newVersion="1.1.1.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
||||
@@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="FluentMigrator" version="1.1.1.0" targetFramework="net40" />
|
||||
<package id="Microsoft.AspNet.SignalR.Core" version="1.1.2" targetFramework="net40" />
|
||||
<package id="Microsoft.AspNet.SignalR.Owin" version="1.1.2" targetFramework="net40" />
|
||||
<package id="Microsoft.Owin" version="1.1.0-beta2" targetFramework="net40" />
|
||||
<package id="Microsoft.Owin.Host.HttpListener" version="1.1.0-beta2" targetFramework="net40" />
|
||||
<package id="Microsoft.Owin.Hosting" version="1.1.0-beta2" targetFramework="net40" />
|
||||
<package id="Nancy" version="0.16.1" targetFramework="net40" />
|
||||
<package id="Nancy.Owin" version="0.16.1" targetFramework="net40" />
|
||||
<package id="Newtonsoft.Json" version="5.0.6" targetFramework="net40" />
|
||||
<package id="NLog" version="2.0.1.2" targetFramework="net40" />
|
||||
<package id="NLog.Config" version="2.0.1.2" targetFramework="net40" />
|
||||
<package id="NLog.Schema" version="2.0.1.2" targetFramework="net40" />
|
||||
<package id="Owin" version="1.0" targetFramework="net40" />
|
||||
<package id="SharpZipLib" version="0.86.0" targetFramework="net40" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user