update mac project

pull/702/head
Luke 8 years ago
parent db5008644b
commit 9700a3be60

@ -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;

@ -90,16 +90,22 @@
<Reference Include="Mono.Posix">
<HintPath>..\packages\Mono.Posix.4.0.0.0\lib\net40\Mono.Posix.dll</HintPath>
</Reference>
<Reference Include="Patterns.Logging">
<HintPath>..\packages\Patterns.Logging.1.0.0.2\lib\portable-net45+sl4+wp71+win8+wpa81\Patterns.Logging.dll</HintPath>
</Reference>
<Reference Include="CommonIO">
<HintPath>..\packages\CommonIO.1.0.0.9\lib\net45\CommonIO.dll</HintPath>
</Reference>
<Reference Include="System.Data.SQLite">
<HintPath>..\ThirdParty\System.Data.SQLite.ManagedOnly\1.0.94.0\System.Data.SQLite.dll</HintPath>
</Reference>
<Reference Include="System.Data" />
<Reference Include="Emby.Common.Implementations">
<HintPath>..\ThirdParty\emby\Emby.Common.Implementations.dll</HintPath>
</Reference>
<Reference Include="Emby.Server.Core">
<HintPath>..\ThirdParty\emby\Emby.Server.Core.dll</HintPath>
</Reference>
<Reference Include="Mono.Nat">
<HintPath>..\ThirdParty\emby\Mono.Nat.dll</HintPath>
</Reference>
<Reference Include="TagLib.Portable">
<HintPath>..\ThirdParty\taglib\TagLib.Portable.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Folder Include="Resources\" />
@ -114,7 +120,6 @@
<Compile Include="AppController.designer.cs">
<DependentUpon>AppController.cs</DependentUpon>
</Compile>
<Compile Include="Native\BaseMonoApp.cs" />
<Compile Include="..\SharedVersion.cs">
<Link>SharedVersion.cs</Link>
</Compile>
@ -125,6 +130,8 @@
<Link>Native\SqliteExtensions.cs</Link>
</Compile>
<Compile Include="MacAppHost.cs" />
<Compile Include="Native\MonoFileSystem.cs" />
<Compile Include="Native\PowerManagement.cs" />
</ItemGroup>
<ItemGroup>
<InterfaceDefinition Include="MainMenu.xib" />
@ -154,18 +161,10 @@
<Project>{9142EEFA-7570-41E1-BFCC-468BB571AF2F}</Project>
<Name>MediaBrowser.Common</Name>
</ProjectReference>
<ProjectReference Include="..\MediaBrowser.Common.Implementations\MediaBrowser.Common.Implementations.csproj">
<Project>{C4D2573A-3FD3-441F-81AF-174AC4CD4E1D}</Project>
<Name>MediaBrowser.Common.Implementations</Name>
</ProjectReference>
<ProjectReference Include="..\MediaBrowser.Server.Implementations\MediaBrowser.Server.Implementations.csproj">
<Project>{2E781478-814D-4A48-9D80-BFF206441A65}</Project>
<Name>MediaBrowser.Server.Implementations</Name>
</ProjectReference>
<ProjectReference Include="..\MediaBrowser.Dlna\MediaBrowser.Dlna.csproj">
<Project>{734098EB-6DC1-4DD0-A1CA-3140DCD2737C}</Project>
<Name>MediaBrowser.Dlna</Name>
</ProjectReference>
<ProjectReference Include="..\MediaBrowser.LocalMetadata\MediaBrowser.LocalMetadata.csproj">
<Project>{7EF9F3E0-697D-42F3-A08F-19DEB5F84392}</Project>
<Name>MediaBrowser.LocalMetadata</Name>
@ -194,6 +193,50 @@
<Project>{4FD51AC5-2C16-4308-A993-C3A84F3B4582}</Project>
<Name>MediaBrowser.Api</Name>
</ProjectReference>
<ProjectReference Include="..\Emby.Server.Implementations\Emby.Server.Implementations.csproj">
<Project>{E383961B-9356-4D5D-8233-9A1079D03055}</Project>
<Name>Emby.Server.Implementations</Name>
</ProjectReference>
<ProjectReference Include="..\Emby.Photos\Emby.Photos.csproj">
<Project>{89AB4548-770D-41FD-A891-8DAFF44F452C}</Project>
<Name>Emby.Photos</Name>
</ProjectReference>
<ProjectReference Include="..\Emby.Drawing.Net\Emby.Drawing.Net.csproj">
<Project>{C97A239E-A96C-4D64-A844-CCF8CC30AECB}</Project>
<Name>Emby.Drawing.Net</Name>
</ProjectReference>
<ProjectReference Include="..\Emby.Drawing.ImageMagick\Emby.Drawing.ImageMagick.csproj">
<Project>{6CFEE013-6E7C-432B-AC37-CABF0880C69A}</Project>
<Name>Emby.Drawing.ImageMagick</Name>
</ProjectReference>
<ProjectReference Include="..\Emby.Drawing\Emby.Drawing.csproj">
<Project>{08FFF49B-F175-4807-A2B5-73B0EBD9F716}</Project>
<Name>Emby.Drawing</Name>
</ProjectReference>
<ProjectReference Include="..\Emby.Dlna\Emby.Dlna.csproj">
<Project>{805844AB-E92F-45E6-9D99-4F6D48D129A5}</Project>
<Name>Emby.Dlna</Name>
</ProjectReference>
<ProjectReference Include="..\DvdLib\DvdLib.csproj">
<Project>{713F42B5-878E-499D-A878-E4C652B1D5E8}</Project>
<Name>DvdLib</Name>
</ProjectReference>
<ProjectReference Include="..\BDInfo\BDInfo.csproj">
<Project>{88AE38DF-19D7-406F-A6A9-09527719A21E}</Project>
<Name>BDInfo</Name>
</ProjectReference>
<ProjectReference Include="..\SocketHttpListener.Portable\SocketHttpListener.Portable.csproj">
<Project>{4F26D5D8-A7B0-42B3-BA42-7CB7D245934E}</Project>
<Name>SocketHttpListener.Portable</Name>
</ProjectReference>
<ProjectReference Include="..\ServiceStack\ServiceStack.csproj">
<Project>{680A1709-25EB-4D52-A87F-EE03FFD94BAA}</Project>
<Name>ServiceStack</Name>
</ProjectReference>
<ProjectReference Include="..\RSSDP\RSSDP.csproj">
<Project>{21002819-C39A-4D3E-BE83-2A276A77FB1F}</Project>
<Name>RSSDP</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Content Include="statusicon.png" />

@ -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<string, string> certificateGenerator, Func<string> 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)
{

@ -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);
}
/// <summary>
@ -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());

@ -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
{

@ -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;
}
}
}

@ -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
{

@ -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);
}
}
}

@ -0,0 +1,15 @@
using MediaBrowser.Model.System;
namespace Emby.Server.Mac.Native
{
public class PowerManagement : IPowerManagement
{
public void PreventSystemStandby()
{
}
public void AllowSystemStandby()
{
}
}
}
Loading…
Cancel
Save