From fb0c07aa9317997612161523f5955e249f4b6ea3 Mon Sep 17 00:00:00 2001 From: Luke Date: Wed, 26 Nov 2014 15:23:52 -0500 Subject: update mac project --- MediaBrowser.Server.Mac/Native/BaseMonoApp.cs | 165 +++++++++++++++++++++++ MediaBrowser.Server.Mac/Native/NativeApp.cs | 1 - MediaBrowser.Server.Mac/Native/NetworkManager.cs | 39 ++++++ 3 files changed, 204 insertions(+), 1 deletion(-) create mode 100644 MediaBrowser.Server.Mac/Native/BaseMonoApp.cs create mode 100644 MediaBrowser.Server.Mac/Native/NetworkManager.cs (limited to 'MediaBrowser.Server.Mac/Native') diff --git a/MediaBrowser.Server.Mac/Native/BaseMonoApp.cs b/MediaBrowser.Server.Mac/Native/BaseMonoApp.cs new file mode 100644 index 0000000000..a2c860413c --- /dev/null +++ b/MediaBrowser.Server.Mac/Native/BaseMonoApp.cs @@ -0,0 +1,165 @@ +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; + +namespace MediaBrowser.Server.Mac +{ + public abstract class BaseMonoApp : INativeApp + { + /// + /// Shutdowns this instance. + /// + public abstract void Shutdown(); + + /// + /// Restarts this instance. + /// + public void Restart() + { + + } + + /// + /// Determines whether this instance [can self restart]. + /// + /// true if this instance [can self restart]; otherwise, false. + public bool CanSelfRestart + { + get + { + return false; + } + } + + /// + /// 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 void PreventSystemStandby() + { + + } + + public List GetAssembliesWithParts() + { + var list = new List(); + + list.Add(GetType().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; + + 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.X86_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/NativeApp.cs b/MediaBrowser.Server.Mac/Native/NativeApp.cs index aedce3d667..f7c2dd4c95 100644 --- a/MediaBrowser.Server.Mac/Native/NativeApp.cs +++ b/MediaBrowser.Server.Mac/Native/NativeApp.cs @@ -1,5 +1,4 @@ using System; -using MediaBrowser.Server.Mono.Native; namespace MediaBrowser.Server.Mac { diff --git a/MediaBrowser.Server.Mac/Native/NetworkManager.cs b/MediaBrowser.Server.Mac/Native/NetworkManager.cs new file mode 100644 index 0000000000..6e4e055a22 --- /dev/null +++ b/MediaBrowser.Server.Mac/Native/NetworkManager.cs @@ -0,0 +1,39 @@ +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; + +namespace MediaBrowser.Server.Mac +{ + /// + /// Class NetUtils + /// + public class NetworkManager : BaseNetworkManager, INetworkManager + { + public NetworkManager(ILogger logger) + : base(logger) + { + } + + /// + /// Gets the network shares. + /// + /// The path. + /// IEnumerable{NetworkShare}. + public IEnumerable GetNetworkShares(string path) + { + return new List (); + } + + /// + /// Gets available devices within the domain + /// + /// PC's in the Domain + public IEnumerable GetNetworkDevices() + { + return new List (); + } + } +} -- cgit v1.2.3