diff --git a/MediaBrowser.Server.Mac/AppController.cs b/MediaBrowser.Server.Mac/AppController.cs index 8d690b813a..9e32b53f18 100644 --- a/MediaBrowser.Server.Mac/AppController.cs +++ b/MediaBrowser.Server.Mac/AppController.cs @@ -1,8 +1,6 @@ using MediaBrowser.Controller; using MediaBrowser.Controller.Configuration; -using MediaBrowser.Controller.Localization; using MediaBrowser.Model.Logging; -using MediaBrowser.Server.Startup.Common.Browser; using System; using MonoMac.Foundation; using MonoMac.AppKit; diff --git a/MediaBrowser.Server.Mac/Emby.Server.Mac.csproj b/MediaBrowser.Server.Mac/Emby.Server.Mac.csproj index 56c7caad4d..7f6c028553 100644 --- a/MediaBrowser.Server.Mac/Emby.Server.Mac.csproj +++ b/MediaBrowser.Server.Mac/Emby.Server.Mac.csproj @@ -90,16 +90,22 @@ ..\packages\Mono.Posix.4.0.0.0\lib\net40\Mono.Posix.dll - - ..\packages\Patterns.Logging.1.0.0.2\lib\portable-net45+sl4+wp71+win8+wpa81\Patterns.Logging.dll - - - ..\packages\CommonIO.1.0.0.9\lib\net45\CommonIO.dll - ..\ThirdParty\System.Data.SQLite.ManagedOnly\1.0.94.0\System.Data.SQLite.dll + + ..\ThirdParty\emby\Emby.Common.Implementations.dll + + + ..\ThirdParty\emby\Emby.Server.Core.dll + + + ..\ThirdParty\emby\Mono.Nat.dll + + + ..\ThirdParty\taglib\TagLib.Portable.dll + @@ -114,7 +120,6 @@ AppController.cs - SharedVersion.cs @@ -125,6 +130,8 @@ Native\SqliteExtensions.cs + + @@ -154,18 +161,10 @@ {9142EEFA-7570-41E1-BFCC-468BB571AF2F} MediaBrowser.Common - - {C4D2573A-3FD3-441F-81AF-174AC4CD4E1D} - MediaBrowser.Common.Implementations - {2E781478-814D-4A48-9D80-BFF206441A65} MediaBrowser.Server.Implementations - - {734098EB-6DC1-4DD0-A1CA-3140DCD2737C} - MediaBrowser.Dlna - {7EF9F3E0-697D-42F3-A08F-19DEB5F84392} MediaBrowser.LocalMetadata @@ -194,6 +193,50 @@ {4FD51AC5-2C16-4308-A993-C3A84F3B4582} MediaBrowser.Api + + {E383961B-9356-4D5D-8233-9A1079D03055} + Emby.Server.Implementations + + + {89AB4548-770D-41FD-A891-8DAFF44F452C} + Emby.Photos + + + {C97A239E-A96C-4D64-A844-CCF8CC30AECB} + Emby.Drawing.Net + + + {6CFEE013-6E7C-432B-AC37-CABF0880C69A} + Emby.Drawing.ImageMagick + + + {08FFF49B-F175-4807-A2B5-73B0EBD9F716} + Emby.Drawing + + + {805844AB-E92F-45E6-9D99-4F6D48D129A5} + Emby.Dlna + + + {713F42B5-878E-499D-A878-E4C652B1D5E8} + DvdLib + + + {88AE38DF-19D7-406F-A6A9-09527719A21E} + BDInfo + + + {4F26D5D8-A7B0-42B3-BA42-7CB7D245934E} + SocketHttpListener.Portable + + + {680A1709-25EB-4D52-A87F-EE03FFD94BAA} + ServiceStack + + + {21002819-C39A-4D3E-BE83-2A276A77FB1F} + RSSDP + diff --git a/MediaBrowser.Server.Mac/MacAppHost.cs b/MediaBrowser.Server.Mac/MacAppHost.cs index c909b3e0f2..660f6913db 100644 --- a/MediaBrowser.Server.Mac/MacAppHost.cs +++ b/MediaBrowser.Server.Mac/MacAppHost.cs @@ -4,7 +4,6 @@ using System.Reflection; using Emby.Server.Core; using Emby.Server.Core.Data; using Emby.Server.Core.FFMpeg; -using MediaBrowser.IsoMounter; using MediaBrowser.Model.IO; using MediaBrowser.Model.Logging; using MediaBrowser.Model.System; @@ -13,7 +12,7 @@ using System.Diagnostics; namespace MediaBrowser.Server.Mac { - public class MacAppHost + public class MacAppHost : ApplicationHost { public MacAppHost(ServerApplicationPaths applicationPaths, ILogManager logManager, StartupOptions options, IFileSystem fileSystem, IPowerManagement powerManagement, string releaseAssetFilename, IEnvironmentInfo environmentInfo, MediaBrowser.Controller.Drawing.IImageEncoder imageEncoder, ISystemEvents systemEvents, IMemoryStreamFactory memoryStreamFactory, MediaBrowser.Common.Net.INetworkManager networkManager, Action certificateGenerator, Func defaultUsernameFactory) : base(applicationPaths, logManager, options, fileSystem, powerManagement, releaseAssetFilename, environmentInfo, imageEncoder, systemEvents, memoryStreamFactory, networkManager, certificateGenerator, defaultUsernameFactory) { @@ -56,7 +55,7 @@ namespace MediaBrowser.Server.Mac return info; } - private static string[] GetDownloadUrls(NativeEnvironment environment) + private string[] GetDownloadUrls() { switch (EnvironmentInfo.SystemArchitecture) { diff --git a/MediaBrowser.Server.Mac/Main.cs b/MediaBrowser.Server.Mac/Main.cs index b48f447078..d0d4891423 100644 --- a/MediaBrowser.Server.Mac/Main.cs +++ b/MediaBrowser.Server.Mac/Main.cs @@ -10,25 +10,22 @@ using System.Runtime.InteropServices; using System.Security.Cryptography.X509Certificates; using System.Threading; using System.Threading.Tasks; -using MediaBrowser.Common.Configuration; -using MediaBrowser.Common.Implementations.IO; -using MediaBrowser.Common.Implementations.Logging; using MediaBrowser.Model.Logging; using MediaBrowser.Server.Implementations; using MediaBrowser.Server.Startup.Common; -using MediaBrowser.Server.Startup.Common.Browser; using Microsoft.Win32; using MonoMac.AppKit; using MonoMac.Foundation; using MonoMac.ObjCRuntime; -using CommonIO; -using MediaBrowser.Server.Implementations.Logging; +using Emby.Server.Core; +using Emby.Common.Implementations.Logging; +using Emby.Server.Mac.Native; namespace MediaBrowser.Server.Mac { class MainClass { - internal static ApplicationHost AppHost; + internal static MacAppHost AppHost; private static ILogger _logger; @@ -41,7 +38,9 @@ namespace MediaBrowser.Server.Mac // Allow this to be specified on the command line. var customProgramDataPath = options.GetOption("-programdata"); - var appPaths = CreateApplicationPaths(applicationPath, customProgramDataPath); + var appFolderPath = Path.GetDirectoryName(applicationPath); + + var appPaths = CreateApplicationPaths(appFolderPath, customProgramDataPath); var logManager = new NlogManager(appPaths.LogDirectoryPath, "server"); logManager.ReloadLogger(LogSeverity.Info); @@ -58,7 +57,7 @@ namespace MediaBrowser.Server.Mac NSApplication.Main (args); } - private static ServerApplicationPaths CreateApplicationPaths(string applicationPath, string programDataPath) + private static ServerApplicationPaths CreateApplicationPaths(string appFolderPath, string programDataPath) { if (string.IsNullOrEmpty(programDataPath)) { @@ -71,9 +70,9 @@ namespace MediaBrowser.Server.Mac } // Within the mac bundle, go uo two levels then down into Resources folder - var resourcesPath = Path.Combine(Path.GetDirectoryName(Path.GetDirectoryName (applicationPath)), "Resources"); + var resourcesPath = Path.Combine(Path.GetDirectoryName(appFolderPath), "Resources"); - return new ServerApplicationPaths(programDataPath, applicationPath, resourcesPath); + return new ServerApplicationPaths(programDataPath, appFolderPath, resourcesPath); } /// @@ -91,12 +90,16 @@ namespace MediaBrowser.Server.Mac // Allow all https requests ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(delegate { return true; }); - var fileSystem = new ManagedFileSystem(new PatternsLogger(logManager.GetLogger("FileSystem")), false, true); + var fileSystem = new MonoFileSystem(logManager.GetLogger("FileSystem"), false, false); fileSystem.AddShortcutHandler(new MbLinkShortcutHandler(fileSystem)); - var nativeApp = new NativeApp(logManager.GetLogger("App")); - - AppHost = new ApplicationHost(appPaths, logManager, options, fileSystem, "Emby.Server.Mac.pkg", nativeApp); + AppHost = new MacAppHost(appPaths, + logManager, + options, + fileSystem, + new PowerManagement(), + "Emby.Server.Mac.pkg", + nativeApp); if (options.ContainsOption("-v")) { Console.WriteLine (AppHost.ApplicationVersion.ToString()); diff --git a/MediaBrowser.Server.Mac/MenuBarIcon.cs b/MediaBrowser.Server.Mac/MenuBarIcon.cs index 865f45057a..646b5ff690 100644 --- a/MediaBrowser.Server.Mac/MenuBarIcon.cs +++ b/MediaBrowser.Server.Mac/MenuBarIcon.cs @@ -1,11 +1,10 @@ using MediaBrowser.Controller; using MediaBrowser.Controller.Configuration; -using MediaBrowser.Controller.Localization; using MediaBrowser.Model.Logging; -using MediaBrowser.Server.Startup.Common.Browser; using System; using MonoMac.Foundation; using MonoMac.AppKit; +using Emby.Server.Core.Browser; namespace MediaBrowser.Server.Mac { diff --git a/MediaBrowser.Server.Mac/Native/BaseMonoApp.cs b/MediaBrowser.Server.Mac/Native/BaseMonoApp.cs deleted file mode 100644 index f28ff8c0df..0000000000 --- a/MediaBrowser.Server.Mac/Native/BaseMonoApp.cs +++ /dev/null @@ -1,272 +0,0 @@ -using MediaBrowser.Common.Net; -using MediaBrowser.Model.Logging; -using MediaBrowser.Server.Startup.Common; -using Mono.Unix.Native; -using System; -using System.Collections.Generic; -using System.Reflection; -using System.Text.RegularExpressions; -using MediaBrowser.Server.Implementations.Persistence; -using MediaBrowser.Server.Startup.Common.FFMpeg; -using System.Diagnostics; -using MediaBrowser.Model.System; - -namespace MediaBrowser.Server.Mac -{ - public abstract class BaseMonoApp : INativeApp - { - protected ILogger Logger { get; private set; } - - protected BaseMonoApp(ILogger logger) - { - Logger = logger; - } - - /// - /// Shutdowns this instance. - /// - public abstract void Shutdown(); - - /// - /// Restarts this instance. - /// - public virtual void Restart(StartupOptions options) - { - throw new NotImplementedException(); - } - - /// - /// Determines whether this instance [can self restart]. - /// - /// true if this instance [can self restart]; otherwise, false. - public virtual bool CanSelfRestart - { - get - { - return false; - } - } - - public void PreventSystemStandby() - { - - } - - public void AllowSystemStandby() - { - - } - - public IDbConnector GetDbConnector() - { - return new DbConnector(Logger); - } - - public virtual bool SupportsLibraryMonitor - { - get - { - return true; - } - } - - /// - /// Gets a value indicating whether this instance can self update. - /// - /// true if this instance can self update; otherwise, false. - public bool CanSelfUpdate - { - get - { - return false; - } - } - - public bool SupportsAutoRunAtStartup - { - get { return false; } - } - - public List GetAssembliesWithParts() - { - var list = new List(); - - list.Add(GetType().Assembly); - - return list; - } - - public void AuthorizeServer(int udpPort, int httpServerPort, int httpsPort, string applicationPath, 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 void LaunchUrl(string url) - { - var process = new Process - { - StartInfo = new ProcessStartInfo - { - FileName = url - }, - - EnableRaisingEvents = true, - }; - - process.Exited += ProcessExited; - - process.Start(); - } - - /// - /// Processes the exited. - /// - /// The sender. - /// The instance containing the event data. - private static void ProcessExited(object sender, EventArgs e) - { - ((Process)sender).Dispose(); - } - - public FFMpegInstallInfo GetFfmpegInstallInfo() - { - return GetInfo(Environment); - } - - public static FFMpegInstallInfo GetInfo(NativeEnvironment environment) - { - var info = new FFMpegInstallInfo(); - - info.ArchiveType = "7z"; - - switch (environment.SystemArchitecture) - { - case Architecture.X64: - info.Version = "20160124"; - break; - case Architecture.X86: - info.Version = "20150110"; - break; - } - - info.DownloadUrls = GetDownloadUrls(environment); - - return info; - } - - private static string[] GetDownloadUrls(NativeEnvironment environment) - { - switch (environment.SystemArchitecture) - { - case Architecture.X64: - return new[] - { - "https://github.com/MediaBrowser/Emby.Resources/raw/master/ffmpeg/osx/ffmpeg-x64-2.8.5.7z" - }; - } - - // No version available - return new string[] { }; - } - - public INetworkManager CreateNetworkManager(ILogger logger) - { - return new NetworkManager(logger); - } - - public void EnableLoopback(string appName) - { - - } - - public bool PortsRequireAuthorization(string applicationPath) - { - return false; - } - - private NativeEnvironment GetEnvironmentInfo() - { - var info = new NativeEnvironment - { - OperatingSystem = Startup.Common.OperatingSystem.Linux - }; - - var uname = GetUnixName(); - - var sysName = uname.sysname ?? string.Empty; - - info.OperatingSystem = Startup.Common.OperatingSystem.Osx; - - 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.X64; - } - else if (uname.machine.StartsWith("arm", StringComparison.OrdinalIgnoreCase)) - { - info.SystemArchitecture = Architecture.Arm; - } - - info.OperatingSystemVersionString = string.IsNullOrWhiteSpace(sysName) ? - System.Environment.OSVersion.VersionString : - sysName; - - return info; - } - - private Uname _unixName; - private Uname GetUnixName() - { - if (_unixName == null) - { - var uname = new Uname(); - Utsname utsname; - var callResult = Syscall.uname(out utsname); - if (callResult == 0) - { - uname.sysname = utsname.sysname; - uname.machine = utsname.machine; - } - - _unixName = uname; - } - return _unixName; - } - - private class Uname - { - public string sysname = string.Empty; - public string machine = string.Empty; - } - } -} diff --git a/MediaBrowser.Server.Mac/Native/DbConnector.cs b/MediaBrowser.Server.Mac/Native/DbConnector.cs index 4c19210b81..1ef9d2388e 100644 --- a/MediaBrowser.Server.Mac/Native/DbConnector.cs +++ b/MediaBrowser.Server.Mac/Native/DbConnector.cs @@ -3,7 +3,7 @@ using System.Data; using System.Data.SQLite; using System.Threading.Tasks; using MediaBrowser.Model.Logging; -using MediaBrowser.Server.Implementations.Persistence; +using Emby.Server.Core.Data; namespace MediaBrowser.Server.Mac { diff --git a/MediaBrowser.Server.Mac/Native/MonoFileSystem.cs b/MediaBrowser.Server.Mac/Native/MonoFileSystem.cs new file mode 100644 index 0000000000..e713457234 --- /dev/null +++ b/MediaBrowser.Server.Mac/Native/MonoFileSystem.cs @@ -0,0 +1,21 @@ +using Emby.Common.Implementations.IO; +using MediaBrowser.Model.Logging; +using Mono.Unix.Native; + +namespace Emby.Server.Mac.Native +{ + public class MonoFileSystem : ManagedFileSystem + { + public MonoFileSystem(ILogger logger, bool supportsAsyncFileStreams, bool enableManagedInvalidFileNameChars) : base(logger, supportsAsyncFileStreams, enableManagedInvalidFileNameChars, false) + { + } + + public override void SetExecutable(string path) + { + // Linux: File permission to 666, and user's execute bit + Logger.Info("Syscall.chmod {0} FilePermissions.DEFFILEMODE | FilePermissions.S_IRWXU | FilePermissions.S_IXGRP | FilePermissions.S_IXOTH", path); + + Syscall.chmod(path, FilePermissions.DEFFILEMODE | FilePermissions.S_IRWXU | FilePermissions.S_IXGRP | FilePermissions.S_IXOTH); + } + } +} diff --git a/MediaBrowser.Server.Mac/Native/PowerManagement.cs b/MediaBrowser.Server.Mac/Native/PowerManagement.cs new file mode 100644 index 0000000000..f3c97d6582 --- /dev/null +++ b/MediaBrowser.Server.Mac/Native/PowerManagement.cs @@ -0,0 +1,15 @@ +using MediaBrowser.Model.System; + +namespace Emby.Server.Mac.Native +{ + public class PowerManagement : IPowerManagement + { + public void PreventSystemStandby() + { + } + + public void AllowSystemStandby() + { + } + } +}