diff options
| author | Luke <luke.pulverenti@gmail.com> | 2016-12-18 00:44:33 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-12-18 00:44:33 -0500 |
| commit | e7cebb91a73354dc3e0d0b6340c9fbd6511f4406 (patch) | |
| tree | 6f1c368c766c17b7514fe749c0e92e69cd89194a /MediaBrowser.Server.Mac/Native | |
| parent | 025905a3e4d50b9a2e07fbf4ff0a203af6604ced (diff) | |
| parent | aaa027f3229073e9a40756c3157d41af2a442922 (diff) | |
Merge pull request #2350 from MediaBrowser/beta
Beta
Diffstat (limited to 'MediaBrowser.Server.Mac/Native')
| -rw-r--r-- | MediaBrowser.Server.Mac/Native/BaseMonoApp.cs | 272 | ||||
| -rw-r--r-- | MediaBrowser.Server.Mac/Native/DbConnector.cs | 24 | ||||
| -rw-r--r-- | MediaBrowser.Server.Mac/Native/MonoFileSystem.cs | 21 | ||||
| -rw-r--r-- | MediaBrowser.Server.Mac/Native/NativeApp.cs | 46 | ||||
| -rw-r--r-- | MediaBrowser.Server.Mac/Native/NetworkManager.cs | 50 | ||||
| -rw-r--r-- | MediaBrowser.Server.Mac/Native/PowerManagement.cs | 15 |
6 files changed, 36 insertions, 392 deletions
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; - } - - /// <summary> - /// Shutdowns this instance. - /// </summary> - public abstract void Shutdown(); - - /// <summary> - /// Restarts this instance. - /// </summary> - public virtual void Restart(StartupOptions options) - { - throw new NotImplementedException(); - } - - /// <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 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; - } - } - - /// <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 false; - } - } - - public bool SupportsAutoRunAtStartup - { - get { return false; } - } - - public List<Assembly> GetAssembliesWithParts() - { - var list = new List<Assembly>(); - - 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(); - } - - /// <summary> - /// Processes the exited. - /// </summary> - /// <param name="sender">The sender.</param> - /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param> - 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 deleted file mode 100644 index 4c19210b81..0000000000 --- a/MediaBrowser.Server.Mac/Native/DbConnector.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using System.Data; -using System.Data.SQLite; -using System.Threading.Tasks; -using MediaBrowser.Model.Logging; -using MediaBrowser.Server.Implementations.Persistence; - -namespace MediaBrowser.Server.Mac -{ - public class DbConnector : IDbConnector - { - private readonly ILogger _logger; - - public DbConnector(ILogger logger) - { - _logger = logger; - } - - public Task<IDbConnection> Connect(string dbPath, bool isReadOnly, bool enablePooling = false, int? cacheSize = null) - { - return SqliteExtensions.ConnectToDb(dbPath, isReadOnly, enablePooling, cacheSize, _logger); - } - } -}
\ No newline at end of file diff --git a/MediaBrowser.Server.Mac/Native/MonoFileSystem.cs b/MediaBrowser.Server.Mac/Native/MonoFileSystem.cs new file mode 100644 index 0000000000..3fb07b8d83 --- /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, true) + { + } + + 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/NativeApp.cs b/MediaBrowser.Server.Mac/Native/NativeApp.cs deleted file mode 100644 index 59fa92dd18..0000000000 --- a/MediaBrowser.Server.Mac/Native/NativeApp.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System; -using MediaBrowser.Server.Startup.Common; -using MediaBrowser.Model.Logging; - -namespace MediaBrowser.Server.Mac -{ - /// <summary> - /// Class NativeApp - /// </summary> - public class NativeApp : BaseMonoApp - { - public NativeApp(ILogger logger) - : base(logger) - { - } - - /// <summary> - /// Shutdowns this instance. - /// </summary> - public override void Shutdown() - { - MainClass.Shutdown(); - } - - /// <summary> - /// Determines whether this instance [can self restart]. - /// </summary> - /// <value><c>true</c> if this instance can self restart; otherwise, <c>false</c>.</value> - public override bool CanSelfRestart - { - get - { - return true; - } - } - - /// <summary> - /// Restarts this instance. - /// </summary> - public override void Restart(StartupOptions options) - { - MainClass.Restart(); - } - } -} - diff --git a/MediaBrowser.Server.Mac/Native/NetworkManager.cs b/MediaBrowser.Server.Mac/Native/NetworkManager.cs deleted file mode 100644 index 959ac6774a..0000000000 --- a/MediaBrowser.Server.Mac/Native/NetworkManager.cs +++ /dev/null @@ -1,50 +0,0 @@ -using MediaBrowser.Common.Implementations.Networking; -using MediaBrowser.Common.Net; -using MediaBrowser.Model.IO; -using MediaBrowser.Model.Logging; -using MediaBrowser.Model.Net; -using System.Collections.Generic; -using MediaBrowser.Server.Mono.Networking; - -namespace MediaBrowser.Server.Mac -{ - /// <summary> - /// Class NetUtils - /// </summary> - public class NetworkManager : BaseNetworkManager, INetworkManager - { - public NetworkManager(ILogger logger) - : base(logger) - { - } - - /// <summary> - /// Gets the network shares. - /// </summary> - /// <param name="path">The path.</param> - /// <returns>IEnumerable{NetworkShare}.</returns> - public IEnumerable<NetworkShare> GetNetworkShares(string path) - { - return new List<NetworkShare> (); - } - - /// <summary> - /// Gets available devices within the domain - /// </summary> - /// <returns>PC's in the Domain</returns> - public IEnumerable<FileSystemEntryInfo> GetNetworkDevices() - { - return new List<FileSystemEntryInfo> (); - } - - /// <summary> - /// Generates a self signed certificate at the locatation specified by <paramref name="certificatePath"/>. - /// </summary> - /// <param name="certificatePath">The path to generate the certificate.</param> - /// <param name="hostname">The common name for the certificate.</param> - public void GenerateSelfSignedSslCertificate(string certificatePath, string hostname) - { - CertificateGenerator.CreateSelfSignCertificatePfx(certificatePath, hostname, Logger); - } - } -} 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() + { + } + } +} |
