From 922583ea5d277b21a9684880f45370f4dc4385bb Mon Sep 17 00:00:00 2001 From: KZ Date: Thu, 30 Jul 2015 18:50:46 +0100 Subject: [PATCH] Fix compilation under mono #117. Allow explicit web client selection. Init curl at application start. --- Build.bat | 35 ++++++++++++------- Installer.iss | 4 +-- src/Jackett.Console/ConsoleOptions.cs | 4 +-- src/Jackett.Console/Program.cs | 11 +++--- src/Jackett.Test/TestWebClient.cs | 5 +++ src/Jackett.Tray/Jackett.Tray.csproj | 13 ++++++- src/Jackett.Tray/Main.Designer.cs | 13 +++---- src/Jackett.Tray/Main.cs | 10 +++++- src/Jackett.Tray/packages.config | 1 + src/Jackett/CurlHelper.cs | 6 ---- src/Jackett/Indexers/BaseIndexer.cs | 27 ++++++++++---- src/Jackett/Indexers/ImmortalSeed.cs | 2 ++ src/Jackett/Indexers/SceneTime.cs | 2 +- src/Jackett/Jackett.csproj | 2 +- src/Jackett/JackettModule.cs | 33 +++++++++++------ src/Jackett/Services/ServerService.cs | 7 ++-- src/Jackett/Startup.cs | 2 +- .../{WindowsWebClient.cs => HttpWebClient.cs} | 9 +++-- src/Jackett/Utils/Clients/IWebClient.cs | 1 + .../Utils/Clients/UnixLibCurlWebClient.cs | 7 ++++ .../Utils/Clients/UnixSafeCurlWebClient.cs | 4 +++ 21 files changed, 139 insertions(+), 59 deletions(-) rename src/Jackett/Utils/Clients/{WindowsWebClient.cs => HttpWebClient.cs} (96%) diff --git a/Build.bat b/Build.bat index 320e860a8..7f9b4c60c 100644 --- a/Build.bat +++ b/Build.bat @@ -1,21 +1,32 @@ -rmdir /s /q build +rmdir /s /q build.windows +rmdir /s /q build.mono rmdir /s /q Output cd src -Msbuild Jackett.sln /t:Clean,Build /p:Configuration=Release +Msbuild Jackett.sln /t:Clean,Build /p:Configuration=Release /verbosity:minimal cd .. -xcopy src\Jackett.Console\bin\Release Build\ /e /y -copy /Y src\Jackett.Service\bin\Release\JackettService.exe build\JackettService.exe -copy /Y src\Jackett.Service\bin\Release\JackettService.exe.config build\JackettService.exe.config -copy /Y src\Jackett.Tray\bin\Release\JackettTray.exe build\JackettTray.exe -copy /Y src\Jackett.Tray\bin\Release\JackettTray.exe.config build\JackettTray.exe.config -copy /Y LICENSE build\LICENSE -copy /Y README.md build\README.md -cd build -del *.pdb -del *.xml +xcopy src\Jackett.Console\bin\Release Build.windows\ /e /y +copy /Y src\Jackett.Service\bin\Release\JackettService.exe build.windows\JackettService.exe +copy /Y src\Jackett.Service\bin\Release\JackettService.exe.config build.windows\JackettService.exe.config +copy /Y src\Jackett.Tray\bin\Release\JackettTray.exe build.windows\JackettTray.exe +copy /Y src\Jackett.Tray\bin\Release\JackettTray.exe.config build.windows\JackettTray.exe.config +copy /Y LICENSE build.windows\LICENSE +copy /Y README.md build.windows\README.md + + +cd src +Msbuild Jackett.sln /t:Clean +call "C:\Program Files (x86)\Mono\bin\xbuild.bat" Jackett.sln /t:Build /p:Configuration=Release /verbosity:minimal cd .. +xcopy src\Jackett.Console\bin\Release Build.mono\ /e /y +copy /Y src\Jackett.Service\bin\Release\JackettService.exe build.mono\JackettService.exe +copy /Y src\Jackett.Service\bin\Release\JackettService.exe.config build.mono\JackettService.exe.config +copy /Y src\Jackett.Tray\bin\Release\JackettTray.exe build.mono\JackettTray.exe +copy /Y src\Jackett.Tray\bin\Release\JackettTray.exe.config build.mono\JackettTray.exe.config +copy /Y LICENSE build.mono\LICENSE +copy /Y README.md build.mono\README.md + iscc Installer.iss diff --git a/Installer.iss b/Installer.iss index 6733eda52..9a3dc6386 100644 --- a/Installer.iss +++ b/Installer.iss @@ -36,8 +36,8 @@ Name: "windowsService"; Description: "Install as a Windows Service" Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked [Files] -Source: "Build\JackettTray.exe"; DestDir: "{app}"; Flags: ignoreversion -Source: "Build\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs +Source: "Build.windows\JackettTray.exe"; DestDir: "{app}"; Flags: ignoreversion +Source: "Build.windows\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs ; NOTE: Don't use "Flags: ignoreversion" on any shared system files [Icons] diff --git a/src/Jackett.Console/ConsoleOptions.cs b/src/Jackett.Console/ConsoleOptions.cs index cf05c933c..4839686fa 100644 --- a/src/Jackett.Console/ConsoleOptions.cs +++ b/src/Jackett.Console/ConsoleOptions.cs @@ -24,8 +24,8 @@ namespace Jackett.Console [Option('t', "Tracing", HelpText = "Enable tracing")] public bool Tracing { get; set; } - [Option('c', "UseCurlExec", HelpText = "Execute curl rather than libcurl for all outgoing requests.")] - public bool UseCurlExec { get; set; } + [Option('c', "UseClient", HelpText = "Override web client selection. Automatic(Default)/libcurl/safecurl/httpclient ")] + public string Client { get; set; } [Option('s', "Start", HelpText = "Start the Jacket Windows service (Must be admin)")] public bool StartService { get; set; } diff --git a/src/Jackett.Console/Program.cs b/src/Jackett.Console/Program.cs index 24c0095c0..2aec6fe4a 100644 --- a/src/Jackett.Console/Program.cs +++ b/src/Jackett.Console/Program.cs @@ -9,6 +9,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; +using System.Reflection; using System.Text; using System.Text.RegularExpressions; using System.Threading; @@ -34,11 +35,14 @@ namespace JackettConsole } else { + + + /* ====== Options ===== */ // Use curl - if (options.UseCurlExec) - Startup.CurlSafe = true; + if (options.Client!=null) + Startup.ClientOverride = options.Client.ToLowerInvariant(); // Logging if (options.Logging) @@ -50,9 +54,6 @@ namespace JackettConsole // Log after the fact as using the logger will cause the options above to be used - if (options.UseCurlExec) - Engine.Logger.Info("Safe curl enabled."); - if (options.Logging) Engine.Logger.Info("Logging enabled."); diff --git a/src/Jackett.Test/TestWebClient.cs b/src/Jackett.Test/TestWebClient.cs index dd375c38c..4104972ed 100644 --- a/src/Jackett.Test/TestWebClient.cs +++ b/src/Jackett.Test/TestWebClient.cs @@ -31,5 +31,10 @@ namespace JackettTest { return Task.FromResult(stringCallbacks.Where(r => r.Key.Equals(request)).First().Value.Invoke(request)); } + + public void Init() + { + + } } } diff --git a/src/Jackett.Tray/Jackett.Tray.csproj b/src/Jackett.Tray/Jackett.Tray.csproj index 1f60966da..ce5277011 100644 --- a/src/Jackett.Tray/Jackett.Tray.csproj +++ b/src/Jackett.Tray/Jackett.Tray.csproj @@ -55,6 +55,14 @@ ..\packages\Autofac.WebApi2.Owin.3.2.0\lib\net45\Autofac.Integration.WebApi.Owin.dll True + + ..\packages\AutoMapper.3.3.1\lib\net40\AutoMapper.dll + True + + + ..\packages\AutoMapper.3.3.1\lib\net40\AutoMapper.Net4.dll + True + ..\packages\Microsoft.Owin.3.0.1\lib\net45\Microsoft.Owin.dll True @@ -146,7 +154,9 @@ Resources.resx True - + + Designer + SettingsSingleFileGenerator Settings.Designer.cs @@ -190,6 +200,7 @@ +