Browse Source

Merge pull request #2288 from MediaBrowser/dev

Dev
Luke 8 years ago
parent
commit
54d3c2eed7
73 changed files with 1941 additions and 1855 deletions
  1. 2 2
      Emby.Common.Implementations/BaseApplicationHost.cs
  2. 3 7
      Emby.Common.Implementations/BaseApplicationPaths.cs
  3. 10 0
      Emby.Common.Implementations/EnvironmentInfo/EnvironmentInfo.cs
  4. 11 2
      Emby.Common.Implementations/IO/ManagedFileSystem.cs
  5. 0 13
      Emby.Common.Implementations/IO/WindowsFileSystem.cs
  6. 9 0
      Emby.Common.Implementations/Net/NetSocket.cs
  7. 19 5
      Emby.Common.Implementations/Net/SocketAcceptor.cs
  8. 6 1
      Emby.Common.Implementations/Net/SocketFactory.cs
  9. 49 75
      Emby.Server.Core/ApplicationHost.cs
  10. 2 2
      Emby.Server.Core/Data/DataExtensions.cs
  11. 16 3
      Emby.Server.Core/Data/SqliteItemRepository.cs
  12. 0 78
      Emby.Server.Core/INativeApp.cs
  13. 1 1
      Emby.Server.Core/Notifications/SqliteNotificationsRepository.cs
  14. 2 2
      Emby.Server.Core/ServerApplicationPaths.cs
  15. 29 4
      Emby.Server.Implementations/Channels/ChannelManager.cs
  16. 1 0
      Emby.Server.Implementations/Emby.Server.Implementations.csproj
  17. 47 0
      Emby.Server.Implementations/EntryPoints/SystemEvents.cs
  18. 2 0
      Emby.Server.Implementations/HttpServer/HttpListenerHost.cs
  19. 71 19
      Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs
  20. 1 2
      Emby.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs
  21. 16 4
      Emby.Server.Implementations/LiveTv/LiveTvDtoService.cs
  22. 50 17
      Emby.Server.Implementations/LiveTv/LiveTvManager.cs
  23. 13 1
      Emby.Server.Implementations/LiveTv/ProgramImageProvider.cs
  24. 9 3
      Emby.Server.Implementations/Security/MBLicenseFile.cs
  25. 5 1
      MediaBrowser.Api/ApiEntryPoint.cs
  26. 13 3
      MediaBrowser.Api/Playback/BaseStreamingService.cs
  27. 1 0
      MediaBrowser.Api/Playback/StreamRequest.cs
  28. 0 6
      MediaBrowser.Common/Configuration/IApplicationPaths.cs
  29. 1 18
      MediaBrowser.Controller/Entities/BaseItem.cs
  30. 9 7
      MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs
  31. 5 2
      MediaBrowser.MediaEncoding/Encoder/EncodingJobFactory.cs
  32. 27 51
      MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs
  33. 5 71
      MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs
  34. 19 1
      MediaBrowser.Model/Dlna/StreamBuilder.cs
  35. 2 0
      MediaBrowser.Model/Dlna/StreamInfo.cs
  36. 1 0
      MediaBrowser.Model/IO/IFileSystem.cs
  37. 2 0
      MediaBrowser.Model/System/IEnvironmentInfo.cs
  38. 2 0
      MediaBrowser.Model/System/ISystemEvents.cs
  39. 467 206
      MediaBrowser.Server.Mac.sln
  40. 0 2
      MediaBrowser.Server.Mac/AppController.cs
  41. 60 178
      MediaBrowser.Server.Mac/Emby.Server.Mac.csproj
  42. 154 0
      MediaBrowser.Server.Mac/MacAppHost.cs
  43. 141 41
      MediaBrowser.Server.Mac/Main.cs
  44. 1 2
      MediaBrowser.Server.Mac/MenuBarIcon.cs
  45. 0 272
      MediaBrowser.Server.Mac/Native/BaseMonoApp.cs
  46. 1 1
      MediaBrowser.Server.Mac/Native/DbConnector.cs
  47. 21 0
      MediaBrowser.Server.Mac/Native/MonoFileSystem.cs
  48. 0 46
      MediaBrowser.Server.Mac/Native/NativeApp.cs
  49. 0 50
      MediaBrowser.Server.Mac/Native/NetworkManager.cs
  50. 15 0
      MediaBrowser.Server.Mac/Native/PowerManagement.cs
  51. 1 1
      MediaBrowser.Server.Mono/MediaBrowser.Server.Mono.csproj
  52. 139 0
      MediaBrowser.Server.Mono/MonoAppHost.cs
  53. 0 164
      MediaBrowser.Server.Mono/Native/MonoApp.cs
  54. 1 1
      MediaBrowser.Server.Mono/Native/MonoFileSystem.cs
  55. 11 24
      MediaBrowser.Server.Mono/Program.cs
  56. 5 1
      MediaBrowser.Server.Startup.Common/Persistence/SqliteExtensions.cs
  57. 16 0
      MediaBrowser.Server.Startup.Common/SystemEvents.cs
  58. 30 46
      MediaBrowser.ServerApplication/MainStartup.cs
  59. 1 1
      MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj
  60. 1 1
      MediaBrowser.ServerApplication/Updates/ApplicationUpdater.cs
  61. 96 93
      MediaBrowser.ServerApplication/WindowsAppHost.cs
  62. 0 2
      MediaBrowser.XbmcMetadata/Savers/SeriesNfoSaver.cs
  63. 1 1
      Nuget/MediaBrowser.Common.nuspec
  64. 2 2
      Nuget/MediaBrowser.Server.Core.nuspec
  65. 6 0
      RSSDP/RSSDP.nuget.targets
  66. 40 0
      src/Emby.Server/ApplicationPathHelper.cs
  67. 107 0
      src/Emby.Server/CoreAppHost.cs
  68. 11 0
      src/Emby.Server/CoreSystemEvents.cs
  69. 52 0
      src/Emby.Server/Data/DbConnector.cs
  70. 33 0
      src/Emby.Server/IO/MemoryStreamFactory.cs
  71. 15 0
      src/Emby.Server/PowerManagement.cs
  72. 47 318
      src/Emby.Server/Program.cs
  73. 5 1
      src/Emby.Server/project.json

+ 2 - 2
Emby.Common.Implementations/BaseApplicationHost.cs

@@ -326,7 +326,7 @@ namespace Emby.Common.Implementations
 
 
             builder.AppendLine(string.Format("Processor count: {0}", Environment.ProcessorCount));
             builder.AppendLine(string.Format("Processor count: {0}", Environment.ProcessorCount));
             builder.AppendLine(string.Format("Program data path: {0}", appPaths.ProgramDataPath));
             builder.AppendLine(string.Format("Program data path: {0}", appPaths.ProgramDataPath));
-            builder.AppendLine(string.Format("Application Path: {0}", appPaths.ApplicationPath));
+            builder.AppendLine(string.Format("Application directory: {0}", appPaths.ProgramSystemPath));
 
 
             return builder;
             return builder;
         }
         }
@@ -548,7 +548,7 @@ return null;
             TimerFactory = new TimerFactory();
             TimerFactory = new TimerFactory();
             RegisterSingleInstance(TimerFactory);
             RegisterSingleInstance(TimerFactory);
 
 
-            SocketFactory = new SocketFactory(null);
+            SocketFactory = new SocketFactory(LogManager.GetLogger("SocketFactory"));
             RegisterSingleInstance(SocketFactory);
             RegisterSingleInstance(SocketFactory);
 
 
             RegisterSingleInstance(CryptographyProvider);
             RegisterSingleInstance(CryptographyProvider);

+ 3 - 7
Emby.Common.Implementations/BaseApplicationPaths.cs

@@ -12,22 +12,18 @@ namespace Emby.Common.Implementations
         /// <summary>
         /// <summary>
         /// Initializes a new instance of the <see cref="BaseApplicationPaths"/> class.
         /// Initializes a new instance of the <see cref="BaseApplicationPaths"/> class.
         /// </summary>
         /// </summary>
-        protected BaseApplicationPaths(string programDataPath, string applicationPath)
+        protected BaseApplicationPaths(string programDataPath, string appFolderPath)
         {
         {
             ProgramDataPath = programDataPath;
             ProgramDataPath = programDataPath;
-            ApplicationPath = applicationPath;
+            ProgramSystemPath = appFolderPath;
         }
         }
 
 
-        public string ApplicationPath { get; private set; }
         public string ProgramDataPath { get; private set; }
         public string ProgramDataPath { get; private set; }
 
 
         /// <summary>
         /// <summary>
         /// Gets the path to the system folder
         /// Gets the path to the system folder
         /// </summary>
         /// </summary>
-        public string ProgramSystemPath
-        {
-            get { return Path.GetDirectoryName(ApplicationPath); }
-        }
+        public string ProgramSystemPath { get; private set; }
 
 
         /// <summary>
         /// <summary>
         /// The _data directory
         /// The _data directory

+ 10 - 0
Emby.Common.Implementations/EnvironmentInfo/EnvironmentInfo.cs

@@ -95,5 +95,15 @@ namespace Emby.Common.Implementations.EnvironmentInfo
                 return MediaBrowser.Model.System.Architecture.X64;
                 return MediaBrowser.Model.System.Architecture.X64;
             }
             }
         }
         }
+
+        public string GetEnvironmentVariable(string name)
+        {
+            return Environment.GetEnvironmentVariable(name);
+        }
+
+        public virtual string GetUserId()
+        {
+            return null;
+        }
     }
     }
 }
 }

+ 11 - 2
Emby.Common.Implementations/IO/ManagedFileSystem.cs

@@ -18,12 +18,13 @@ namespace Emby.Common.Implementations.IO
         private readonly bool _supportsAsyncFileStreams;
         private readonly bool _supportsAsyncFileStreams;
         private char[] _invalidFileNameChars;
         private char[] _invalidFileNameChars;
         private readonly List<IShortcutHandler> _shortcutHandlers = new List<IShortcutHandler>();
         private readonly List<IShortcutHandler> _shortcutHandlers = new List<IShortcutHandler>();
-        protected bool EnableFileSystemRequestConcat = true;
+        private bool EnableFileSystemRequestConcat = true;
 
 
-        public ManagedFileSystem(ILogger logger, bool supportsAsyncFileStreams, bool enableManagedInvalidFileNameChars)
+        public ManagedFileSystem(ILogger logger, bool supportsAsyncFileStreams, bool enableManagedInvalidFileNameChars, bool enableFileSystemRequestConcat)
         {
         {
             Logger = logger;
             Logger = logger;
             _supportsAsyncFileStreams = supportsAsyncFileStreams;
             _supportsAsyncFileStreams = supportsAsyncFileStreams;
+            EnableFileSystemRequestConcat = enableFileSystemRequestConcat;
             SetInvalidFileNameChars(enableManagedInvalidFileNameChars);
             SetInvalidFileNameChars(enableManagedInvalidFileNameChars);
         }
         }
 
 
@@ -56,6 +57,14 @@ namespace Emby.Common.Implementations.IO
             }
             }
         }
         }
 
 
+        public char PathSeparator
+        {
+            get
+            {
+                return Path.DirectorySeparatorChar;
+            }
+        }
+
         public string GetFullPath(string path)
         public string GetFullPath(string path)
         {
         {
             return Path.GetFullPath(path);
             return Path.GetFullPath(path);

+ 0 - 13
Emby.Common.Implementations/IO/WindowsFileSystem.cs

@@ -1,13 +0,0 @@
-using MediaBrowser.Model.Logging;
-
-namespace Emby.Common.Implementations.IO
-{
-    public class WindowsFileSystem : ManagedFileSystem
-    {
-        public WindowsFileSystem(ILogger logger)
-            : base(logger, true, true)
-        {
-            EnableFileSystemRequestConcat = false;
-        }
-    }
-}

+ 9 - 0
Emby.Common.Implementations/Net/NetSocket.cs

@@ -15,6 +15,15 @@ namespace Emby.Common.Implementations.Net
 
 
         public NetSocket(Socket socket, ILogger logger)
         public NetSocket(Socket socket, ILogger logger)
         {
         {
+            if (socket == null)
+            {
+                throw new ArgumentNullException("socket");
+            }
+            if (logger == null)
+            {
+                throw new ArgumentNullException("logger");
+            }
+
             Socket = socket;
             Socket = socket;
             _logger = logger;
             _logger = logger;
         }
         }

+ 19 - 5
Emby.Common.Implementations/Net/SocketAcceptor.cs

@@ -14,6 +14,23 @@ namespace Emby.Common.Implementations.Net
 
 
         public SocketAcceptor(ILogger logger, Socket originalSocket, Action<ISocket> onAccept, Func<bool> isClosed)
         public SocketAcceptor(ILogger logger, Socket originalSocket, Action<ISocket> onAccept, Func<bool> isClosed)
         {
         {
+            if (logger == null)
+            {
+                throw new ArgumentNullException("logger");
+            }
+            if (originalSocket == null)
+            {
+                throw new ArgumentNullException("originalSocket");
+            }
+            if (onAccept == null)
+            {
+                throw new ArgumentNullException("onAccept");
+            }
+            if (isClosed == null)
+            {
+                throw new ArgumentNullException("isClosed");
+            }
+
             _logger = logger;
             _logger = logger;
             _originalSocket = originalSocket;
             _originalSocket = originalSocket;
             _isClosed = isClosed;
             _isClosed = isClosed;
@@ -101,11 +118,8 @@ namespace Emby.Common.Implementations.Net
                 _onAccept(new NetSocket(acceptSocket, _logger));
                 _onAccept(new NetSocket(acceptSocket, _logger));
             }
             }
 
 
-            if (_originalSocket != null)
-            {
-                // Accept the next connection request
-                StartAccept(e, ref acceptSocket);
-            }
+            // Accept the next connection request
+            StartAccept(e, ref acceptSocket);
         }
         }
     }
     }
 }
 }

+ 6 - 1
Emby.Common.Implementations/Net/SocketFactory.cs

@@ -23,10 +23,15 @@ namespace Emby.Common.Implementations.Net
         /// </summary>
         /// </summary>
         private IPAddress _LocalIP;
         private IPAddress _LocalIP;
 
 
-        private ILogger _logger;
+        private readonly ILogger _logger;
 
 
         public SocketFactory(ILogger logger)
         public SocketFactory(ILogger logger)
         {
         {
+            if (logger == null)
+            {
+                throw new ArgumentNullException("logger");
+            }
+
             _logger = logger;
             _logger = logger;
             _LocalIP = IPAddress.Any;
             _LocalIP = IPAddress.Any;
         }
         }

+ 49 - 75
Emby.Server.Core/ApplicationHost.cs

@@ -142,7 +142,7 @@ namespace Emby.Server.Core
     /// <summary>
     /// <summary>
     /// Class CompositionRoot
     /// Class CompositionRoot
     /// </summary>
     /// </summary>
-    public class ApplicationHost : BaseApplicationHost<ServerApplicationPaths>, IServerApplicationHost, IDependencyContainer
+    public abstract class ApplicationHost : BaseApplicationHost<ServerApplicationPaths>, IServerApplicationHost, IDependencyContainer
     {
     {
         /// <summary>
         /// <summary>
         /// Gets the server configuration manager.
         /// Gets the server configuration manager.
@@ -257,11 +257,9 @@ namespace Emby.Server.Core
 
 
         protected IAuthService AuthService { get; private set; }
         protected IAuthService AuthService { get; private set; }
 
 
-        private readonly StartupOptions _startupOptions;
+        protected readonly StartupOptions StartupOptions;
         private readonly string _releaseAssetFilename;
         private readonly string _releaseAssetFilename;
 
 
-        internal INativeApp NativeApp { get; set; }
-
         internal IPowerManagement PowerManagement { get; private set; }
         internal IPowerManagement PowerManagement { get; private set; }
         internal IImageEncoder ImageEncoder { get; private set; }
         internal IImageEncoder ImageEncoder { get; private set; }
 
 
@@ -275,7 +273,6 @@ namespace Emby.Server.Core
             ILogManager logManager,
             ILogManager logManager,
             StartupOptions options,
             StartupOptions options,
             IFileSystem fileSystem,
             IFileSystem fileSystem,
-            INativeApp nativeApp,
             IPowerManagement powerManagement,
             IPowerManagement powerManagement,
             string releaseAssetFilename,
             string releaseAssetFilename,
             IEnvironmentInfo environmentInfo,
             IEnvironmentInfo environmentInfo,
@@ -293,11 +290,10 @@ namespace Emby.Server.Core
                   memoryStreamFactory, 
                   memoryStreamFactory, 
                   networkManager)
                   networkManager)
         {
         {
-            _startupOptions = options;
+            StartupOptions = options;
             _certificateGenerator = certificateGenerator;
             _certificateGenerator = certificateGenerator;
             _releaseAssetFilename = releaseAssetFilename;
             _releaseAssetFilename = releaseAssetFilename;
             _defaultUserNameFactory = defaultUsernameFactory;
             _defaultUserNameFactory = defaultUsernameFactory;
-            NativeApp = nativeApp;
             PowerManagement = powerManagement;
             PowerManagement = powerManagement;
 
 
             ImageEncoder = imageEncoder;
             ImageEncoder = imageEncoder;
@@ -314,19 +310,11 @@ namespace Emby.Server.Core
         {
         {
             get
             get
             {
             {
-                return _version ?? (_version = GetAssembly(NativeApp.GetType()).GetName().Version);
+                return _version ?? (_version = GetAssembly(GetType()).GetName().Version);
             }
             }
         }
         }
 
 
-        public override bool IsRunningAsService
-        {
-            get { return NativeApp.IsRunningAsService; }
-        }
-
-        public bool SupportsRunningAsService
-        {
-            get { return NativeApp.SupportsRunningAsService; }
-        }
+        public abstract bool SupportsRunningAsService { get; }
 
 
         /// <summary>
         /// <summary>
         /// Gets the name.
         /// Gets the name.
@@ -345,19 +333,7 @@ namespace Emby.Server.Core
             return type.GetTypeInfo().Assembly;
             return type.GetTypeInfo().Assembly;
         }
         }
 
 
-        /// <summary>
-        /// Gets a value indicating 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 NativeApp.CanSelfRestart; }
-        }
-
-        public bool SupportsAutoRunAtStartup
-        {
-            get { return NativeApp.SupportsAutoRunAtStartup; }
-        }
+        public abstract bool SupportsAutoRunAtStartup { get; }
 
 
         private void SetBaseExceptionMessage()
         private void SetBaseExceptionMessage()
         {
         {
@@ -580,11 +556,11 @@ namespace Emby.Server.Core
 
 
             UserRepository = await GetUserRepository().ConfigureAwait(false);
             UserRepository = await GetUserRepository().ConfigureAwait(false);
 
 
-            var displayPreferencesRepo = new SqliteDisplayPreferencesRepository(LogManager, JsonSerializer, ApplicationPaths, NativeApp.GetDbConnector(), MemoryStreamFactory);
+            var displayPreferencesRepo = new SqliteDisplayPreferencesRepository(LogManager, JsonSerializer, ApplicationPaths, GetDbConnector(), MemoryStreamFactory);
             DisplayPreferencesRepository = displayPreferencesRepo;
             DisplayPreferencesRepository = displayPreferencesRepo;
             RegisterSingleInstance(DisplayPreferencesRepository);
             RegisterSingleInstance(DisplayPreferencesRepository);
 
 
-            var itemRepo = new SqliteItemRepository(ServerConfigurationManager, JsonSerializer, LogManager, NativeApp.GetDbConnector(), MemoryStreamFactory);
+            var itemRepo = new SqliteItemRepository(ServerConfigurationManager, JsonSerializer, LogManager, GetDbConnector(), MemoryStreamFactory);
             ItemRepository = itemRepo;
             ItemRepository = itemRepo;
             RegisterSingleInstance(ItemRepository);
             RegisterSingleInstance(ItemRepository);
 
 
@@ -707,7 +683,7 @@ namespace Emby.Server.Core
             EncodingManager = new EncodingManager(FileSystemManager, Logger, MediaEncoder, ChapterManager, LibraryManager);
             EncodingManager = new EncodingManager(FileSystemManager, Logger, MediaEncoder, ChapterManager, LibraryManager);
             RegisterSingleInstance(EncodingManager);
             RegisterSingleInstance(EncodingManager);
 
 
-            var sharingRepo = new SharingRepository(LogManager, ApplicationPaths, NativeApp.GetDbConnector());
+            var sharingRepo = new SharingRepository(LogManager, ApplicationPaths, GetDbConnector());
             await sharingRepo.Initialize().ConfigureAwait(false);
             await sharingRepo.Initialize().ConfigureAwait(false);
             RegisterSingleInstance<ISharingManager>(new SharingManager(sharingRepo, ServerConfigurationManager, LibraryManager, this));
             RegisterSingleInstance<ISharingManager>(new SharingManager(sharingRepo, ServerConfigurationManager, LibraryManager, this));
 
 
@@ -727,7 +703,7 @@ namespace Emby.Server.Core
 
 
             await displayPreferencesRepo.Initialize().ConfigureAwait(false);
             await displayPreferencesRepo.Initialize().ConfigureAwait(false);
 
 
-            var userDataRepo = new SqliteUserDataRepository(LogManager, ApplicationPaths, NativeApp.GetDbConnector());
+            var userDataRepo = new SqliteUserDataRepository(LogManager, ApplicationPaths, GetDbConnector());
 
 
             ((UserDataManager)UserDataManager).Repository = userDataRepo;
             ((UserDataManager)UserDataManager).Repository = userDataRepo;
             await itemRepo.Initialize(userDataRepo).ConfigureAwait(false);
             await itemRepo.Initialize(userDataRepo).ConfigureAwait(false);
@@ -749,6 +725,11 @@ namespace Emby.Server.Core
 
 
             try
             try
             {
             {
+                if (!FileSystemManager.FileExists(certificateLocation))
+                {
+                    return null;
+                }
+
                 X509Certificate2 localCert = new X509Certificate2(certificateLocation);
                 X509Certificate2 localCert = new X509Certificate2(certificateLocation);
                 //localCert.PrivateKey = PrivateKey.CreateFromFile(pvk_file).RSA;
                 //localCert.PrivateKey = PrivateKey.CreateFromFile(pvk_file).RSA;
                 if (!localCert.HasPrivateKey)
                 if (!localCert.HasPrivateKey)
@@ -770,14 +751,16 @@ namespace Emby.Server.Core
         {
         {
             var maxConcurrentImageProcesses = Math.Max(Environment.ProcessorCount, 4);
             var maxConcurrentImageProcesses = Math.Max(Environment.ProcessorCount, 4);
 
 
-            if (_startupOptions.ContainsOption("-imagethreads"))
+            if (StartupOptions.ContainsOption("-imagethreads"))
             {
             {
-                int.TryParse(_startupOptions.GetOption("-imagethreads"), NumberStyles.Any, CultureInfo.InvariantCulture, out maxConcurrentImageProcesses);
+                int.TryParse(StartupOptions.GetOption("-imagethreads"), NumberStyles.Any, CultureInfo.InvariantCulture, out maxConcurrentImageProcesses);
             }
             }
 
 
             return new ImageProcessor(LogManager.GetLogger("ImageProcessor"), ServerConfigurationManager.ApplicationPaths, FileSystemManager, JsonSerializer, ImageEncoder, maxConcurrentImageProcesses, () => LibraryManager, TimerFactory);
             return new ImageProcessor(LogManager.GetLogger("ImageProcessor"), ServerConfigurationManager.ApplicationPaths, FileSystemManager, JsonSerializer, ImageEncoder, maxConcurrentImageProcesses, () => LibraryManager, TimerFactory);
         }
         }
 
 
+        protected abstract FFMpegInstallInfo GetFfmpegInstallInfo();
+
         /// <summary>
         /// <summary>
         /// Registers the media encoder.
         /// Registers the media encoder.
         /// </summary>
         /// </summary>
@@ -787,8 +770,8 @@ namespace Emby.Server.Core
             string encoderPath = null;
             string encoderPath = null;
             string probePath = null;
             string probePath = null;
 
 
-            var info = await new FFMpegLoader(Logger, ApplicationPaths, HttpClient, ZipClient, FileSystemManager, NativeApp.GetFfmpegInstallInfo())
-                .GetFFMpegInfo(_startupOptions, progress).ConfigureAwait(false);
+            var info = await new FFMpegLoader(Logger, ApplicationPaths, HttpClient, ZipClient, FileSystemManager, GetFfmpegInstallInfo())
+                .GetFFMpegInfo(StartupOptions, progress).ConfigureAwait(false);
 
 
             encoderPath = info.EncoderPath;
             encoderPath = info.EncoderPath;
             probePath = info.ProbePath;
             probePath = info.ProbePath;
@@ -825,7 +808,7 @@ namespace Emby.Server.Core
         /// <returns>Task{IUserRepository}.</returns>
         /// <returns>Task{IUserRepository}.</returns>
         private async Task<IUserRepository> GetUserRepository()
         private async Task<IUserRepository> GetUserRepository()
         {
         {
-            var repo = new SqliteUserRepository(LogManager, ApplicationPaths, JsonSerializer, NativeApp.GetDbConnector(), MemoryStreamFactory);
+            var repo = new SqliteUserRepository(LogManager, ApplicationPaths, JsonSerializer, GetDbConnector(), MemoryStreamFactory);
 
 
             await repo.Initialize().ConfigureAwait(false);
             await repo.Initialize().ConfigureAwait(false);
 
 
@@ -838,7 +821,7 @@ namespace Emby.Server.Core
         /// <returns>Task{IUserRepository}.</returns>
         /// <returns>Task{IUserRepository}.</returns>
         private async Task<IFileOrganizationRepository> GetFileOrganizationRepository()
         private async Task<IFileOrganizationRepository> GetFileOrganizationRepository()
         {
         {
-            var repo = new SqliteFileOrganizationRepository(LogManager, ServerConfigurationManager.ApplicationPaths, NativeApp.GetDbConnector());
+            var repo = new SqliteFileOrganizationRepository(LogManager, ServerConfigurationManager.ApplicationPaths, GetDbConnector());
 
 
             await repo.Initialize().ConfigureAwait(false);
             await repo.Initialize().ConfigureAwait(false);
 
 
@@ -847,7 +830,7 @@ namespace Emby.Server.Core
 
 
         private async Task<IAuthenticationRepository> GetAuthenticationRepository()
         private async Task<IAuthenticationRepository> GetAuthenticationRepository()
         {
         {
-            var repo = new AuthenticationRepository(LogManager, ServerConfigurationManager.ApplicationPaths, NativeApp.GetDbConnector());
+            var repo = new AuthenticationRepository(LogManager, ServerConfigurationManager.ApplicationPaths, GetDbConnector());
 
 
             await repo.Initialize().ConfigureAwait(false);
             await repo.Initialize().ConfigureAwait(false);
 
 
@@ -856,7 +839,7 @@ namespace Emby.Server.Core
 
 
         private async Task<IActivityRepository> GetActivityLogRepository()
         private async Task<IActivityRepository> GetActivityLogRepository()
         {
         {
-            var repo = new ActivityRepository(LogManager, ServerConfigurationManager.ApplicationPaths, NativeApp.GetDbConnector());
+            var repo = new ActivityRepository(LogManager, ServerConfigurationManager.ApplicationPaths, GetDbConnector());
 
 
             await repo.Initialize().ConfigureAwait(false);
             await repo.Initialize().ConfigureAwait(false);
 
 
@@ -865,7 +848,7 @@ namespace Emby.Server.Core
 
 
         private async Task<ISyncRepository> GetSyncRepository()
         private async Task<ISyncRepository> GetSyncRepository()
         {
         {
-            var repo = new SyncRepository(LogManager, JsonSerializer, ServerConfigurationManager.ApplicationPaths, NativeApp.GetDbConnector());
+            var repo = new SyncRepository(LogManager, JsonSerializer, ServerConfigurationManager.ApplicationPaths, GetDbConnector());
 
 
             await repo.Initialize().ConfigureAwait(false);
             await repo.Initialize().ConfigureAwait(false);
 
 
@@ -877,7 +860,7 @@ namespace Emby.Server.Core
         /// </summary>
         /// </summary>
         private async Task ConfigureNotificationsRepository()
         private async Task ConfigureNotificationsRepository()
         {
         {
-            var repo = new SqliteNotificationsRepository(LogManager, ApplicationPaths, NativeApp.GetDbConnector());
+            var repo = new SqliteNotificationsRepository(LogManager, ApplicationPaths, GetDbConnector());
 
 
             await repo.Initialize().ConfigureAwait(false);
             await repo.Initialize().ConfigureAwait(false);
 
 
@@ -1123,24 +1106,12 @@ namespace Emby.Server.Core
                 Logger.ErrorException("Error sending server restart notification", ex);
                 Logger.ErrorException("Error sending server restart notification", ex);
             }
             }
 
 
-            Logger.Info("Calling NativeApp.Restart");
+            Logger.Info("Calling RestartInternal");
 
 
-            NativeApp.Restart(_startupOptions);
+            RestartInternal();
         }
         }
 
 
-        /// <summary>
-        /// Gets or sets 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 override bool CanSelfUpdate
-        {
-            get
-            {
-#pragma warning disable 162
-                return NativeApp.CanSelfUpdate;
-#pragma warning restore 162
-            }
-        }
+        protected abstract void RestartInternal();
 
 
         /// <summary>
         /// <summary>
         /// Gets the composable part assemblies.
         /// Gets the composable part assemblies.
@@ -1196,14 +1167,16 @@ namespace Emby.Server.Core
             // Xbmc 
             // Xbmc 
             list.Add(GetAssembly(typeof(ArtistNfoProvider)));
             list.Add(GetAssembly(typeof(ArtistNfoProvider)));
 
 
-            list.AddRange(NativeApp.GetAssembliesWithParts());
+            list.AddRange(GetAssembliesWithPartsInternal());
 
 
             // Include composable parts in the running assembly
             // Include composable parts in the running assembly
-            list.Add(GetAssembly(GetType()));
+            list.Add(GetAssembly(typeof(ApplicationHost)));
 
 
             return list;
             return list;
         }
         }
 
 
+        protected abstract List<Assembly> GetAssembliesWithPartsInternal();
+
         /// <summary>
         /// <summary>
         /// Gets the plugin assemblies.
         /// Gets the plugin assemblies.
         /// </summary>
         /// </summary>
@@ -1280,7 +1253,7 @@ namespace Emby.Server.Core
                 EncoderLocationType = MediaEncoder.EncoderLocationType,
                 EncoderLocationType = MediaEncoder.EncoderLocationType,
                 SystemArchitecture = EnvironmentInfo.SystemArchitecture,
                 SystemArchitecture = EnvironmentInfo.SystemArchitecture,
                 SystemUpdateLevel = ConfigurationManager.CommonConfiguration.SystemUpdateLevel,
                 SystemUpdateLevel = ConfigurationManager.CommonConfiguration.SystemUpdateLevel,
-                PackageName = _startupOptions.GetOption("-package")
+                PackageName = StartupOptions.GetOption("-package")
             };
             };
         }
         }
 
 
@@ -1456,9 +1429,11 @@ namespace Emby.Server.Core
                 Logger.ErrorException("Error sending server shutdown notification", ex);
                 Logger.ErrorException("Error sending server shutdown notification", ex);
             }
             }
 
 
-            NativeApp.Shutdown();
+            ShutdownInternal();
         }
         }
 
 
+        protected abstract void ShutdownInternal();
+
         /// <summary>
         /// <summary>
         /// Registers the server with administrator access.
         /// Registers the server with administrator access.
         /// </summary>
         /// </summary>
@@ -1468,12 +1443,7 @@ namespace Emby.Server.Core
 
 
             try
             try
             {
             {
-                NativeApp.AuthorizeServer(
-                    UdpServerEntryPoint.PortNumber,
-                    ServerConfigurationManager.Configuration.HttpServerPortNumber,
-                    ServerConfigurationManager.Configuration.HttpsPortNumber,
-                    ConfigurationManager.CommonApplicationPaths.ApplicationPath,
-                    ConfigurationManager.CommonApplicationPaths.TempDirectory);
+                AuthorizeServer();
             }
             }
             catch (Exception ex)
             catch (Exception ex)
             {
             {
@@ -1481,6 +1451,9 @@ namespace Emby.Server.Core
             }
             }
         }
         }
 
 
+        protected abstract void AuthorizeServer();
+        protected abstract IDbConnector GetDbConnector();
+
         public event EventHandler HasUpdateAvailableChanged;
         public event EventHandler HasUpdateAvailableChanged;
 
 
         private bool _hasUpdateAvailable;
         private bool _hasUpdateAvailable;
@@ -1551,10 +1524,12 @@ namespace Emby.Server.Core
         {
         {
             if (SupportsAutoRunAtStartup)
             if (SupportsAutoRunAtStartup)
             {
             {
-                NativeApp.ConfigureAutoRun(autorun);
+                ConfigureAutoRunInternal(autorun);
             }
             }
         }
         }
 
 
+        protected abstract void ConfigureAutoRunInternal(bool autorun);
+
         /// <summary>
         /// <summary>
         /// This returns localhost in the case of no external dns, and the hostname if the 
         /// This returns localhost in the case of no external dns, and the hostname if the 
         /// dns is prefixed with a valid Uri prefix.
         /// dns is prefixed with a valid Uri prefix.
@@ -1578,16 +1553,15 @@ namespace Emby.Server.Core
             }
             }
         }
         }
 
 
-        public void LaunchUrl(string url)
-        {
-            NativeApp.LaunchUrl(url);
-        }
+        public abstract void LaunchUrl(string url);
 
 
         public void EnableLoopback(string appName)
         public void EnableLoopback(string appName)
         {
         {
-            NativeApp.EnableLoopback(appName);
+            EnableLoopbackInternal(appName);
         }
         }
 
 
+        protected abstract void EnableLoopbackInternal(string appName);
+
         private void RegisterModules()
         private void RegisterModules()
         {
         {
             var moduleTypes = GetExportTypes<IDependencyModule>();
             var moduleTypes = GetExportTypes<IDependencyModule>();

+ 2 - 2
Emby.Server.Core/Data/DataExtensions.cs

@@ -40,7 +40,7 @@ namespace Emby.Server.Core.Data
         public static IDataParameter Add(this IDataParameterCollection paramCollection, IDbCommand cmd, string name)
         public static IDataParameter Add(this IDataParameterCollection paramCollection, IDbCommand cmd, string name)
         {
         {
             var param = cmd.CreateParameter();
             var param = cmd.CreateParameter();
-
+            
             param.ParameterName = name;
             param.ParameterName = name;
 
 
             paramCollection.Add(param);
             paramCollection.Add(param);
@@ -173,7 +173,7 @@ namespace Emby.Server.Core.Data
             var builder = new StringBuilder();
             var builder = new StringBuilder();
 
 
             builder.AppendLine("alter table " + table);
             builder.AppendLine("alter table " + table);
-            builder.AppendLine("add column " + columnName + " " + type);
+            builder.AppendLine("add column " + columnName + " " + type + " NULL");
 
 
             connection.RunQueries(new[] { builder.ToString() }, logger);
             connection.RunQueries(new[] { builder.ToString() }, logger);
         }
         }

+ 16 - 3
Emby.Server.Core/Data/SqliteItemRepository.cs

@@ -157,7 +157,7 @@ namespace Emby.Server.Core.Data
 
 
             string[] queries = {
             string[] queries = {
 
 
-                                "create table if not exists TypedBaseItems (guid GUID primary key, type TEXT, data BLOB, ParentId GUID, Path TEXT)",
+                                "create table if not exists TypedBaseItems (guid GUID primary key NOT NULL, type TEXT NOT NULL, data BLOB NULL, ParentId GUID NULL, Path TEXT NULL)",
 
 
                                 "create table if not exists AncestorIds (ItemId GUID, AncestorId GUID, AncestorIdText TEXT, PRIMARY KEY (ItemId, AncestorId))",
                                 "create table if not exists AncestorIds (ItemId GUID, AncestorId GUID, AncestorIdText TEXT, PRIMARY KEY (ItemId, AncestorId))",
                                 "create index if not exists idx_AncestorIds1 on AncestorIds(AncestorId)",
                                 "create index if not exists idx_AncestorIds1 on AncestorIds(AncestorId)",
@@ -286,6 +286,7 @@ namespace Emby.Server.Core.Data
             _connection.AddColumn(Logger, "TypedBaseItems", "ExtraType", "Text");
             _connection.AddColumn(Logger, "TypedBaseItems", "ExtraType", "Text");
             _connection.AddColumn(Logger, "TypedBaseItems", "Artists", "Text");
             _connection.AddColumn(Logger, "TypedBaseItems", "Artists", "Text");
             _connection.AddColumn(Logger, "TypedBaseItems", "AlbumArtists", "Text");
             _connection.AddColumn(Logger, "TypedBaseItems", "AlbumArtists", "Text");
+            _connection.AddColumn(Logger, "TypedBaseItems", "ExternalId", "Text");
 
 
             _connection.AddColumn(Logger, "ItemValues", "CleanValue", "Text");
             _connection.AddColumn(Logger, "ItemValues", "CleanValue", "Text");
 
 
@@ -440,7 +441,8 @@ namespace Emby.Server.Core.Data
             "TotalBitrate",
             "TotalBitrate",
             "ExtraType",
             "ExtraType",
             "Artists",
             "Artists",
-            "AlbumArtists"
+            "AlbumArtists",
+            "ExternalId"
         };
         };
 
 
         private readonly string[] _mediaStreamSaveColumns =
         private readonly string[] _mediaStreamSaveColumns =
@@ -575,7 +577,8 @@ namespace Emby.Server.Core.Data
                 "TotalBitrate",
                 "TotalBitrate",
                 "ExtraType",
                 "ExtraType",
                 "Artists",
                 "Artists",
-                "AlbumArtists"
+                "AlbumArtists",
+                "ExternalId"
             };
             };
             _saveItemCommand = _connection.CreateCommand();
             _saveItemCommand = _connection.CreateCommand();
             _saveItemCommand.CommandText = "replace into TypedBaseItems (" + string.Join(",", saveColumns.ToArray()) + ") values (";
             _saveItemCommand.CommandText = "replace into TypedBaseItems (" + string.Join(",", saveColumns.ToArray()) + ") values (";
@@ -1084,6 +1087,10 @@ namespace Emby.Server.Core.Data
                         }
                         }
                     }
                     }
 
 
+                    _saveItemCommand.GetParameter(index++).Value = item.ExternalId;
+
+                    //Logger.Debug(_saveItemCommand.CommandText);
+
                     _saveItemCommand.Transaction = transaction;
                     _saveItemCommand.Transaction = transaction;
 
 
                     _saveItemCommand.ExecuteNonQuery();
                     _saveItemCommand.ExecuteNonQuery();
@@ -1967,6 +1974,12 @@ namespace Emby.Server.Core.Data
             }
             }
             index++;
             index++;
 
 
+            if (!reader.IsDBNull(index))
+            {
+                item.ExternalId = reader.GetString(index);
+            }
+            index++;
+
             if (string.IsNullOrWhiteSpace(item.Tagline))
             if (string.IsNullOrWhiteSpace(item.Tagline))
             {
             {
                 var movie = item as Movie;
                 var movie = item as Movie;

+ 0 - 78
Emby.Server.Core/INativeApp.cs

@@ -1,78 +0,0 @@
-using MediaBrowser.Common.Net;
-using MediaBrowser.Model.Logging;
-using System.Collections.Generic;
-using System.Reflection;
-using Emby.Server.Core;
-using Emby.Server.Core.Data;
-using Emby.Server.Core.FFMpeg;
-
-namespace Emby.Server.Core
-{
-    public interface INativeApp
-    {
-        /// <summary>
-        /// Gets the assemblies with parts.
-        /// </summary>
-        /// <returns>List&lt;Assembly&gt;.</returns>
-        List<Assembly> GetAssembliesWithParts();
-
-        /// <summary>
-        /// Authorizes the server.
-        /// </summary>
-        void AuthorizeServer(int udpPort, int httpServerPort, int httpsServerPort, string applicationPath, string tempDirectory);
-
-        /// <summary>
-        /// Gets a value indicating whether [supports running as service].
-        /// </summary>
-        /// <value><c>true</c> if [supports running as service]; otherwise, <c>false</c>.</value>
-        bool SupportsRunningAsService { get; }
-
-        /// <summary>
-        /// Gets a value indicating whether this instance is running as service.
-        /// </summary>
-        /// <value><c>true</c> if this instance is running as service; otherwise, <c>false</c>.</value>
-        bool IsRunningAsService { get; }
-
-        /// <summary>
-        /// Gets a value indicating whether this instance can self restart.
-        /// </summary>
-        /// <value><c>true</c> if this instance can self restart; otherwise, <c>false</c>.</value>
-        bool CanSelfRestart { get; }
-
-        /// <summary>
-        /// Gets a value indicating whether [supports autorun at startup].
-        /// </summary>
-        /// <value><c>true</c> if [supports autorun at startup]; otherwise, <c>false</c>.</value>
-        bool SupportsAutoRunAtStartup { get; }
-        
-        /// <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>
-        bool CanSelfUpdate { get; }
-
-        /// <summary>
-        /// Shutdowns this instance.
-        /// </summary>
-        void Shutdown();
-
-        /// <summary>
-        /// Restarts this instance.
-        /// </summary>
-        void Restart(StartupOptions startupOptions);
-
-        /// <summary>
-        /// Configures the automatic run.
-        /// </summary>
-        /// <param name="autorun">if set to <c>true</c> [autorun].</param>
-        void ConfigureAutoRun(bool autorun);
-
-        FFMpegInstallInfo GetFfmpegInstallInfo();
-
-        void LaunchUrl(string url);
-
-        IDbConnector GetDbConnector();
-
-        void EnableLoopback(string appName);
-    }
-}

+ 1 - 1
Emby.Server.Core/Notifications/SqliteNotificationsRepository.cs

@@ -30,7 +30,7 @@ namespace Emby.Server.Core.Notifications
             {
             {
                 string[] queries = {
                 string[] queries = {
 
 
-                                "create table if not exists Notifications (Id GUID NOT NULL, UserId GUID NOT NULL, Date DATETIME NOT NULL, Name TEXT NOT NULL, Description TEXT, Url TEXT, Level TEXT NOT NULL, IsRead BOOLEAN NOT NULL, Category TEXT NOT NULL, RelatedId TEXT, PRIMARY KEY (Id, UserId))",
+                                "create table if not exists Notifications (Id GUID NOT NULL, UserId GUID NOT NULL, Date DATETIME NOT NULL, Name TEXT NOT NULL, Description TEXT NULL, Url TEXT NULL, Level TEXT NOT NULL, IsRead BOOLEAN NOT NULL, Category TEXT NOT NULL, RelatedId TEXT NULL, PRIMARY KEY (Id, UserId))",
                                 "create index if not exists idx_Notifications1 on Notifications(Id)",
                                 "create index if not exists idx_Notifications1 on Notifications(Id)",
                                 "create index if not exists idx_Notifications2 on Notifications(UserId)"
                                 "create index if not exists idx_Notifications2 on Notifications(UserId)"
                                };
                                };

+ 2 - 2
Emby.Server.Core/ServerApplicationPaths.cs

@@ -12,8 +12,8 @@ namespace Emby.Server.Core
         /// <summary>
         /// <summary>
         /// Initializes a new instance of the <see cref="BaseApplicationPaths" /> class.
         /// Initializes a new instance of the <see cref="BaseApplicationPaths" /> class.
         /// </summary>
         /// </summary>
-        public ServerApplicationPaths(string programDataPath, string applicationPath, string applicationResourcesPath)
-            : base(programDataPath, applicationPath)
+        public ServerApplicationPaths(string programDataPath, string appFolderPath, string applicationResourcesPath)
+            : base(programDataPath, appFolderPath)
         {
         {
             ApplicationResourcesPath = applicationResourcesPath;
             ApplicationResourcesPath = applicationResourcesPath;
         }
         }

+ 29 - 4
Emby.Server.Implementations/Channels/ChannelManager.cs

@@ -326,7 +326,7 @@ namespace Emby.Server.Implementations.Channels
 
 
             if (requiresCallback != null)
             if (requiresCallback != null)
             {
             {
-                results = await GetChannelItemMediaSourcesInternal(requiresCallback, item.ExternalId, cancellationToken)
+                results = await GetChannelItemMediaSourcesInternal(requiresCallback, GetItemExternalId(item), cancellationToken)
                     .ConfigureAwait(false);
                     .ConfigureAwait(false);
             }
             }
             else
             else
@@ -1075,6 +1075,18 @@ namespace Emby.Server.Implementations.Channels
             return result;
             return result;
         }
         }
 
 
+        private string GetItemExternalId(BaseItem item)
+        {
+            var externalId = item.ExternalId;
+
+            if (string.IsNullOrWhiteSpace(externalId))
+            {
+                externalId = item.GetProviderId("ProviderExternalId");
+            }
+
+            return externalId;
+        }
+
         private readonly SemaphoreSlim _resourcePool = new SemaphoreSlim(1, 1);
         private readonly SemaphoreSlim _resourcePool = new SemaphoreSlim(1, 1);
         private async Task<ChannelItemResult> GetChannelItems(IChannel channel,
         private async Task<ChannelItemResult> GetChannelItems(IChannel channel,
             User user,
             User user,
@@ -1096,7 +1108,11 @@ namespace Emby.Server.Implementations.Channels
                 {
                 {
                     if (_fileSystem.GetLastWriteTimeUtc(cachePath).Add(cacheLength) > DateTime.UtcNow)
                     if (_fileSystem.GetLastWriteTimeUtc(cachePath).Add(cacheLength) > DateTime.UtcNow)
                     {
                     {
-                        return _jsonSerializer.DeserializeFromFile<ChannelItemResult>(cachePath);
+                        var cachedResult = _jsonSerializer.DeserializeFromFile<ChannelItemResult>(cachePath);
+                        if (cachedResult != null)
+                        {
+                            return cachedResult;
+                        }
                     }
                     }
                 }
                 }
             }
             }
@@ -1119,7 +1135,11 @@ namespace Emby.Server.Implementations.Channels
                     {
                     {
                         if (_fileSystem.GetLastWriteTimeUtc(cachePath).Add(cacheLength) > DateTime.UtcNow)
                         if (_fileSystem.GetLastWriteTimeUtc(cachePath).Add(cacheLength) > DateTime.UtcNow)
                         {
                         {
-                            return _jsonSerializer.DeserializeFromFile<ChannelItemResult>(cachePath);
+                            var cachedResult = _jsonSerializer.DeserializeFromFile<ChannelItemResult>(cachePath);
+                            if (cachedResult != null)
+                            {
+                                return cachedResult;
+                            }
                         }
                         }
                     }
                     }
                 }
                 }
@@ -1145,11 +1165,16 @@ namespace Emby.Server.Implementations.Channels
                 {
                 {
                     var categoryItem = _libraryManager.GetItemById(new Guid(folderId));
                     var categoryItem = _libraryManager.GetItemById(new Guid(folderId));
 
 
-                    query.FolderId = categoryItem.ExternalId;
+                    query.FolderId = GetItemExternalId(categoryItem);
                 }
                 }
 
 
                 var result = await channel.GetChannelItems(query, cancellationToken).ConfigureAwait(false);
                 var result = await channel.GetChannelItems(query, cancellationToken).ConfigureAwait(false);
 
 
+                if (result == null)
+                {
+                    throw new InvalidOperationException("Channel returned a null result from GetChannelItems");
+                }
+
                 if (!startIndex.HasValue && !limit.HasValue)
                 if (!startIndex.HasValue && !limit.HasValue)
                 {
                 {
                     CacheResponse(result, cachePath);
                     CacheResponse(result, cachePath);

+ 1 - 0
Emby.Server.Implementations/Emby.Server.Implementations.csproj

@@ -59,6 +59,7 @@
     <Compile Include="EntryPoints\RecordingNotifier.cs" />
     <Compile Include="EntryPoints\RecordingNotifier.cs" />
     <Compile Include="EntryPoints\RefreshUsersMetadata.cs" />
     <Compile Include="EntryPoints\RefreshUsersMetadata.cs" />
     <Compile Include="EntryPoints\ServerEventNotifier.cs" />
     <Compile Include="EntryPoints\ServerEventNotifier.cs" />
+    <Compile Include="EntryPoints\SystemEvents.cs" />
     <Compile Include="EntryPoints\UdpServerEntryPoint.cs" />
     <Compile Include="EntryPoints\UdpServerEntryPoint.cs" />
     <Compile Include="EntryPoints\UsageEntryPoint.cs" />
     <Compile Include="EntryPoints\UsageEntryPoint.cs" />
     <Compile Include="EntryPoints\UsageReporter.cs" />
     <Compile Include="EntryPoints\UsageReporter.cs" />

+ 47 - 0
Emby.Server.Implementations/EntryPoints/SystemEvents.cs

@@ -0,0 +1,47 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using MediaBrowser.Model.System;
+using MediaBrowser.Controller.Plugins;
+using MediaBrowser.Common;
+
+namespace Emby.Server.Implementations.EntryPoints
+{
+    public class SystemEvents : IServerEntryPoint
+    {
+        private readonly ISystemEvents _systemEvents;
+        private readonly IApplicationHost _appHost;
+
+        public SystemEvents(ISystemEvents systemEvents, IApplicationHost appHost)
+        {
+            _systemEvents = systemEvents;
+            _appHost = appHost;
+        }
+
+        public void Run()
+        {
+            _systemEvents.SessionLogoff += _systemEvents_SessionLogoff;
+            _systemEvents.SystemShutdown += _systemEvents_SystemShutdown;
+        }
+
+        private void _systemEvents_SessionLogoff(object sender, EventArgs e)
+        {
+            if (!_appHost.IsRunningAsService)
+            {
+                _appHost.Shutdown();
+            }
+        }
+
+        private void _systemEvents_SystemShutdown(object sender, EventArgs e)
+        {
+            _appHost.Shutdown();
+        }
+
+        public void Dispose()
+        {
+            _systemEvents.SystemShutdown -= _systemEvents_SystemShutdown;
+        }
+    }
+}

+ 2 - 0
Emby.Server.Implementations/HttpServer/HttpListenerHost.cs

@@ -396,6 +396,8 @@ namespace Emby.Server.Implementations.HttpServer
                 if (_disposed)
                 if (_disposed)
                 {
                 {
                     httpRes.StatusCode = 503;
                     httpRes.StatusCode = 503;
+                    httpRes.ContentType = "text/plain";
+                    Write(httpRes, "Server shutting down");
                     return;
                     return;
                 }
                 }
 
 

+ 71 - 19
Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs

@@ -1551,13 +1551,28 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
         {
         {
             try
             try
             {
             {
+                if (timer.IsSports)
+                {
+                    AddGenre(timer.Genres, "Sports");
+                }
+                if (timer.IsKids)
+                {
+                    AddGenre(timer.Genres, "Kids");
+                    AddGenre(timer.Genres, "Children");
+                }
+                if (timer.IsNews)
+                {
+                    AddGenre(timer.Genres, "News");
+                }
+
                 if (timer.IsProgramSeries)
                 if (timer.IsProgramSeries)
                 {
                 {
                     SaveSeriesNfo(timer, recordingPath, seriesPath);
                     SaveSeriesNfo(timer, recordingPath, seriesPath);
+                    SaveVideoNfo(timer, recordingPath, false);
                 }
                 }
                 else if (!timer.IsMovie || timer.IsSports || timer.IsNews)
                 else if (!timer.IsMovie || timer.IsSports || timer.IsNews)
                 {
                 {
-                    SaveVideoNfo(timer, recordingPath);
+                    SaveVideoNfo(timer, recordingPath, true);
                 }
                 }
             }
             }
             catch (Exception ex)
             catch (Exception ex)
@@ -1594,6 +1609,16 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
                         writer.WriteElementString("title", timer.Name);
                         writer.WriteElementString("title", timer.Name);
                     }
                     }
 
 
+                    if (!string.IsNullOrEmpty(timer.OfficialRating))
+                    {
+                        writer.WriteElementString("mpaa", timer.OfficialRating);
+                    }
+
+                    foreach (var genre in timer.Genres)
+                    {
+                        writer.WriteElementString("genre", genre);
+                    }
+
                     writer.WriteEndElement();
                     writer.WriteEndElement();
                     writer.WriteEndDocument();
                     writer.WriteEndDocument();
                 }
                 }
@@ -1601,7 +1626,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
         }
         }
 
 
         public const string DateAddedFormat = "yyyy-MM-dd HH:mm:ss";
         public const string DateAddedFormat = "yyyy-MM-dd HH:mm:ss";
-        private void SaveVideoNfo(TimerInfo timer, string recordingPath)
+        private void SaveVideoNfo(TimerInfo timer, string recordingPath, bool lockData)
         {
         {
             var nfoPath = Path.ChangeExtension(recordingPath, ".nfo");
             var nfoPath = Path.ChangeExtension(recordingPath, ".nfo");
 
 
@@ -1622,11 +1647,41 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
                 using (XmlWriter writer = XmlWriter.Create(stream, settings))
                 using (XmlWriter writer = XmlWriter.Create(stream, settings))
                 {
                 {
                     writer.WriteStartDocument(true);
                     writer.WriteStartDocument(true);
-                    writer.WriteStartElement("movie");
 
 
-                    if (!string.IsNullOrWhiteSpace(timer.Name))
+                    if (timer.IsProgramSeries)
                     {
                     {
-                        writer.WriteElementString("title", timer.Name);
+                        writer.WriteStartElement("episodedetails");
+
+                        if (!string.IsNullOrWhiteSpace(timer.EpisodeTitle))
+                        {
+                            writer.WriteElementString("title", timer.EpisodeTitle);
+                        }
+
+                        if (timer.OriginalAirDate.HasValue)
+                        {
+                            var formatString = _config.GetNfoConfiguration().ReleaseDateFormat;
+
+                            writer.WriteElementString("aired", timer.OriginalAirDate.Value.ToLocalTime().ToString(formatString));
+                        }
+
+                        if (timer.EpisodeNumber.HasValue)
+                        {
+                            writer.WriteElementString("episode", timer.EpisodeNumber.Value.ToString(CultureInfo.InvariantCulture));
+                        }
+
+                        if (timer.SeasonNumber.HasValue)
+                        {
+                            writer.WriteElementString("season", timer.SeasonNumber.Value.ToString(CultureInfo.InvariantCulture));
+                        }
+                    }
+                    else
+                    {
+                        writer.WriteStartElement("movie");
+
+                        if (!string.IsNullOrWhiteSpace(timer.Name))
+                        {
+                            writer.WriteElementString("title", timer.Name);
+                        }
                     }
                     }
 
 
                     writer.WriteElementString("dateadded", DateTime.UtcNow.ToLocalTime().ToString(DateAddedFormat));
                     writer.WriteElementString("dateadded", DateTime.UtcNow.ToLocalTime().ToString(DateAddedFormat));
@@ -1645,25 +1700,15 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
                         .Replace("&quot;", "'");
                         .Replace("&quot;", "'");
 
 
                     writer.WriteElementString("plot", overview);
                     writer.WriteElementString("plot", overview);
-                    writer.WriteElementString("lockdata", true.ToString().ToLower());
 
 
-                    if (timer.CommunityRating.HasValue)
+                    if (lockData)
                     {
                     {
-                        writer.WriteElementString("rating", timer.CommunityRating.Value.ToString(CultureInfo.InvariantCulture));
+                        writer.WriteElementString("lockdata", true.ToString().ToLower());
                     }
                     }
 
 
-                    if (timer.IsSports)
-                    {
-                        AddGenre(timer.Genres, "Sports");
-                    }
-                    if (timer.IsKids)
-                    {
-                        AddGenre(timer.Genres, "Kids");
-                        AddGenre(timer.Genres, "Children");
-                    }
-                    if (timer.IsNews)
+                    if (timer.CommunityRating.HasValue)
                     {
                     {
-                        AddGenre(timer.Genres, "News");
+                        writer.WriteElementString("rating", timer.CommunityRating.Value.ToString(CultureInfo.InvariantCulture));
                     }
                     }
 
 
                     foreach (var genre in timer.Genres)
                     foreach (var genre in timer.Genres)
@@ -1968,4 +2013,11 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
             public CancellationTokenSource CancellationTokenSource { get; set; }
             public CancellationTokenSource CancellationTokenSource { get; set; }
         }
         }
     }
     }
+    public static class ConfigurationExtension
+    {
+        public static XbmcMetadataOptions GetNfoConfiguration(this IConfigurationManager manager)
+        {
+            return manager.GetConfiguration<XbmcMetadataOptions>("xbmcmetadata");
+        }
+    }
 }
 }

+ 1 - 2
Emby.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs

@@ -54,9 +54,8 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
             catch (FileNotFoundException)
             catch (FileNotFoundException)
             {
             {
             }
             }
-            catch (IOException ex)
+            catch (IOException)
             {
             {
-                Logger.ErrorException("Error deserializing {0}", ex, jsonFile);
             }
             }
             catch (Exception ex)
             catch (Exception ex)
             {
             {

+ 16 - 4
Emby.Server.Implementations/LiveTv/LiveTvDtoService.cs

@@ -269,6 +269,18 @@ namespace Emby.Server.Implementations.LiveTv
             return _libraryManager.GetNewItemId(name.ToLower(), typeof(ILiveTvRecording));
             return _libraryManager.GetNewItemId(name.ToLower(), typeof(ILiveTvRecording));
         }
         }
 
 
+        private string GetItemExternalId(BaseItem item)
+        {
+            var externalId = item.ExternalId;
+
+            if (string.IsNullOrWhiteSpace(externalId))
+            {
+                externalId = item.GetProviderId("ProviderExternalId");
+            }
+
+            return externalId;
+        }
+
         public async Task<TimerInfo> GetTimerInfo(TimerInfoDto dto, bool isNew, LiveTvManager liveTv, CancellationToken cancellationToken)
         public async Task<TimerInfo> GetTimerInfo(TimerInfoDto dto, bool isNew, LiveTvManager liveTv, CancellationToken cancellationToken)
         {
         {
             var info = new TimerInfo
             var info = new TimerInfo
@@ -304,7 +316,7 @@ namespace Emby.Server.Implementations.LiveTv
 
 
                 if (channel != null)
                 if (channel != null)
                 {
                 {
-                    info.ChannelId = channel.ExternalId;
+                    info.ChannelId = GetItemExternalId(channel);
                 }
                 }
             }
             }
 
 
@@ -314,7 +326,7 @@ namespace Emby.Server.Implementations.LiveTv
 
 
                 if (program != null)
                 if (program != null)
                 {
                 {
-                    info.ProgramId = program.ExternalId;
+                    info.ProgramId = GetItemExternalId(program);
                 }
                 }
             }
             }
 
 
@@ -370,7 +382,7 @@ namespace Emby.Server.Implementations.LiveTv
 
 
                 if (channel != null)
                 if (channel != null)
                 {
                 {
-                    info.ChannelId = channel.ExternalId;
+                    info.ChannelId = GetItemExternalId(channel);
                 }
                 }
             }
             }
 
 
@@ -380,7 +392,7 @@ namespace Emby.Server.Implementations.LiveTv
 
 
                 if (program != null)
                 if (program != null)
                 {
                 {
-                    info.ProgramId = program.ExternalId;
+                    info.ProgramId = GetItemExternalId(program);
                 }
                 }
             }
             }
 
 

+ 50 - 17
Emby.Server.Implementations/LiveTv/LiveTvManager.cs

@@ -251,12 +251,24 @@ namespace Emby.Server.Implementations.LiveTv
             return await GetLiveStream(id, mediaSourceId, true, cancellationToken).ConfigureAwait(false);
             return await GetLiveStream(id, mediaSourceId, true, cancellationToken).ConfigureAwait(false);
         }
         }
 
 
+        private string GetItemExternalId(BaseItem item)
+        {
+            var externalId = item.ExternalId;
+
+            if (string.IsNullOrWhiteSpace(externalId))
+            {
+                externalId = item.GetProviderId("ProviderExternalId");
+            }
+
+            return externalId;
+        }
+
         public async Task<IEnumerable<MediaSourceInfo>> GetRecordingMediaSources(IHasMediaSources item, CancellationToken cancellationToken)
         public async Task<IEnumerable<MediaSourceInfo>> GetRecordingMediaSources(IHasMediaSources item, CancellationToken cancellationToken)
         {
         {
             var baseItem = (BaseItem)item;
             var baseItem = (BaseItem)item;
             var service = GetService(baseItem);
             var service = GetService(baseItem);
 
 
-            return await service.GetRecordingStreamMediaSources(baseItem.ExternalId, cancellationToken).ConfigureAwait(false);
+            return await service.GetRecordingStreamMediaSources(GetItemExternalId(baseItem), cancellationToken).ConfigureAwait(false);
         }
         }
 
 
         public async Task<IEnumerable<MediaSourceInfo>> GetChannelMediaSources(IHasMediaSources item, CancellationToken cancellationToken)
         public async Task<IEnumerable<MediaSourceInfo>> GetChannelMediaSources(IHasMediaSources item, CancellationToken cancellationToken)
@@ -313,18 +325,18 @@ namespace Emby.Server.Implementations.LiveTv
                 var channel = GetInternalChannel(id);
                 var channel = GetInternalChannel(id);
                 isVideo = channel.ChannelType == ChannelType.TV;
                 isVideo = channel.ChannelType == ChannelType.TV;
                 service = GetService(channel);
                 service = GetService(channel);
-                _logger.Info("Opening channel stream from {0}, external channel Id: {1}", service.Name, channel.ExternalId);
+                _logger.Info("Opening channel stream from {0}, external channel Id: {1}", service.Name, GetItemExternalId(channel));
 
 
                 var supportsManagedStream = service as ISupportsDirectStreamProvider;
                 var supportsManagedStream = service as ISupportsDirectStreamProvider;
                 if (supportsManagedStream != null)
                 if (supportsManagedStream != null)
                 {
                 {
-                    var streamInfo = await supportsManagedStream.GetChannelStreamWithDirectStreamProvider(channel.ExternalId, mediaSourceId, cancellationToken).ConfigureAwait(false);
+                    var streamInfo = await supportsManagedStream.GetChannelStreamWithDirectStreamProvider(GetItemExternalId(channel), mediaSourceId, cancellationToken).ConfigureAwait(false);
                     info = streamInfo.Item1;
                     info = streamInfo.Item1;
                     directStreamProvider = streamInfo.Item2;
                     directStreamProvider = streamInfo.Item2;
                 }
                 }
                 else
                 else
                 {
                 {
-                    info = await service.GetChannelStream(channel.ExternalId, mediaSourceId, cancellationToken).ConfigureAwait(false);
+                    info = await service.GetChannelStream(GetItemExternalId(channel), mediaSourceId, cancellationToken).ConfigureAwait(false);
                 }
                 }
                 info.RequiresClosing = true;
                 info.RequiresClosing = true;
 
 
@@ -341,8 +353,8 @@ namespace Emby.Server.Implementations.LiveTv
                 isVideo = !string.Equals(recording.MediaType, MediaType.Audio, StringComparison.OrdinalIgnoreCase);
                 isVideo = !string.Equals(recording.MediaType, MediaType.Audio, StringComparison.OrdinalIgnoreCase);
                 service = GetService(recording);
                 service = GetService(recording);
 
 
-                _logger.Info("Opening recording stream from {0}, external recording Id: {1}", service.Name, recording.ExternalId);
-                info = await service.GetRecordingStream(recording.ExternalId, null, cancellationToken).ConfigureAwait(false);
+                _logger.Info("Opening recording stream from {0}, external recording Id: {1}", service.Name, GetItemExternalId(recording));
+                info = await service.GetRecordingStream(GetItemExternalId(recording), null, cancellationToken).ConfigureAwait(false);
                 info.RequiresClosing = true;
                 info.RequiresClosing = true;
 
 
                 if (info.RequiresClosing)
                 if (info.RequiresClosing)
@@ -493,7 +505,7 @@ namespace Emby.Server.Implementations.LiveTv
                 isNew = true;
                 isNew = true;
             }
             }
 
 
-            if (!string.Equals(channelInfo.Id, item.ExternalId))
+            if (!string.Equals(channelInfo.Id, item.ExternalId, StringComparison.Ordinal))
             {
             {
                 isNew = true;
                 isNew = true;
             }
             }
@@ -601,7 +613,6 @@ namespace Emby.Server.Implementations.LiveTv
 
 
             item.EpisodeTitle = info.EpisodeTitle;
             item.EpisodeTitle = info.EpisodeTitle;
             item.ExternalId = info.Id;
             item.ExternalId = info.Id;
-            item.ExternalSeriesIdLegacy = seriesId;
 
 
             if (!string.IsNullOrWhiteSpace(seriesId) && !string.Equals(item.ExternalSeriesId, seriesId, StringComparison.Ordinal))
             if (!string.IsNullOrWhiteSpace(seriesId) && !string.Equals(item.ExternalSeriesId, seriesId, StringComparison.Ordinal))
             {
             {
@@ -841,6 +852,13 @@ namespace Emby.Server.Implementations.LiveTv
             return item.Id;
             return item.Id;
         }
         }
 
 
+
+
+        private string GetExternalSeriesIdLegacy(BaseItem item)
+        {
+            return item.GetProviderId("ProviderExternalSeriesId");
+        }
+
         public async Task<BaseItemDto> GetProgram(string id, CancellationToken cancellationToken, User user = null)
         public async Task<BaseItemDto> GetProgram(string id, CancellationToken cancellationToken, User user = null)
         {
         {
             var program = GetInternalProgram(id);
             var program = GetInternalProgram(id);
@@ -848,7 +866,15 @@ namespace Emby.Server.Implementations.LiveTv
             var dto = _dtoService.GetBaseItemDto(program, new DtoOptions(), user);
             var dto = _dtoService.GetBaseItemDto(program, new DtoOptions(), user);
 
 
             var list = new List<Tuple<BaseItemDto, string, string, string>>();
             var list = new List<Tuple<BaseItemDto, string, string, string>>();
-            list.Add(new Tuple<BaseItemDto, string, string, string>(dto, program.ServiceName, program.ExternalId, program.ExternalSeriesIdLegacy));
+
+            var externalSeriesId = program.ExternalSeriesId;
+
+            if (string.IsNullOrWhiteSpace(externalSeriesId))
+            {
+                externalSeriesId = GetExternalSeriesIdLegacy(program);
+            }
+
+            list.Add(new Tuple<BaseItemDto, string, string, string>(dto, program.ServiceName, GetItemExternalId(program), externalSeriesId));
 
 
             await AddRecordingInfo(list, cancellationToken).ConfigureAwait(false);
             await AddRecordingInfo(list, cancellationToken).ConfigureAwait(false);
 
 
@@ -1283,7 +1309,7 @@ namespace Emby.Server.Implementations.LiveTv
                     var isKids = false;
                     var isKids = false;
                     var iSSeries = false;
                     var iSSeries = false;
 
 
-                    var channelPrograms = await service.GetProgramsAsync(currentChannel.ExternalId, start, end, cancellationToken).ConfigureAwait(false);
+                    var channelPrograms = await service.GetProgramsAsync(GetItemExternalId(currentChannel), start, end, cancellationToken).ConfigureAwait(false);
 
 
                     var existingPrograms = _libraryManager.GetItemList(new InternalItemsQuery
                     var existingPrograms = _libraryManager.GetItemList(new InternalItemsQuery
                     {
                     {
@@ -1830,7 +1856,14 @@ namespace Emby.Server.Implementations.LiveTv
                     dto.ServiceName = serviceName;
                     dto.ServiceName = serviceName;
                 }
                 }
 
 
-                programTuples.Add(new Tuple<BaseItemDto, string, string, string>(dto, serviceName, program.ExternalId, program.ExternalSeriesIdLegacy));
+                var externalSeriesId = program.ExternalSeriesId;
+
+                if (string.IsNullOrWhiteSpace(externalSeriesId))
+                {
+                    externalSeriesId = GetExternalSeriesIdLegacy(program);
+                }
+
+                programTuples.Add(new Tuple<BaseItemDto, string, string, string>(dto, serviceName, GetItemExternalId(program), externalSeriesId));
             }
             }
 
 
             await AddRecordingInfo(programTuples, CancellationToken.None).ConfigureAwait(false);
             await AddRecordingInfo(programTuples, CancellationToken.None).ConfigureAwait(false);
@@ -2006,7 +2039,7 @@ namespace Emby.Server.Implementations.LiveTv
             if (service is EmbyTV.EmbyTV)
             if (service is EmbyTV.EmbyTV)
             {
             {
                 // We can't trust that we'll be able to direct stream it through emby server,  no matter what the provider says
                 // We can't trust that we'll be able to direct stream it through emby server,  no matter what the provider says
-                return service.DeleteRecordingAsync(recording.ExternalId, CancellationToken.None);
+                return service.DeleteRecordingAsync(GetItemExternalId(recording), CancellationToken.None);
             }
             }
 
 
             return Task.FromResult(true);
             return Task.FromResult(true);
@@ -2030,7 +2063,7 @@ namespace Emby.Server.Implementations.LiveTv
 
 
             try
             try
             {
             {
-                await service.DeleteRecordingAsync(recording.ExternalId, CancellationToken.None).ConfigureAwait(false);
+                await service.DeleteRecordingAsync(GetItemExternalId(recording), CancellationToken.None).ConfigureAwait(false);
             }
             }
             catch (ResourceNotFoundException)
             catch (ResourceNotFoundException)
             {
             {
@@ -2289,12 +2322,12 @@ namespace Emby.Server.Implementations.LiveTv
                 programInfo = new ProgramInfo
                 programInfo = new ProgramInfo
                 {
                 {
                     Audio = program.Audio,
                     Audio = program.Audio,
-                    ChannelId = channel.ExternalId,
+                    ChannelId = GetItemExternalId(channel),
                     CommunityRating = program.CommunityRating,
                     CommunityRating = program.CommunityRating,
                     EndDate = program.EndDate ?? DateTime.MinValue,
                     EndDate = program.EndDate ?? DateTime.MinValue,
                     EpisodeTitle = program.EpisodeTitle,
                     EpisodeTitle = program.EpisodeTitle,
                     Genres = program.Genres,
                     Genres = program.Genres,
-                    Id = program.ExternalId,
+                    Id = GetItemExternalId(program),
                     IsHD = program.IsHD,
                     IsHD = program.IsHD,
                     IsKids = program.IsKids,
                     IsKids = program.IsKids,
                     IsLive = program.IsLive,
                     IsLive = program.IsLive,
@@ -2360,7 +2393,7 @@ namespace Emby.Server.Implementations.LiveTv
             info.Name = program.Name;
             info.Name = program.Name;
             info.Overview = program.Overview;
             info.Overview = program.Overview;
             info.ProgramId = programDto.Id;
             info.ProgramId = programDto.Id;
-            info.ExternalProgramId = program.ExternalId;
+            info.ExternalProgramId = GetItemExternalId(program);
 
 
             if (program.EndDate.HasValue)
             if (program.EndDate.HasValue)
             {
             {
@@ -2804,7 +2837,7 @@ namespace Emby.Server.Implementations.LiveTv
 
 
         public async Task<ListingsProviderInfo> SaveListingProvider(ListingsProviderInfo info, bool validateLogin, bool validateListings)
         public async Task<ListingsProviderInfo> SaveListingProvider(ListingsProviderInfo info, bool validateLogin, bool validateListings)
         {
         {
-            info = _jsonSerializer.DeserializeFromString< ListingsProviderInfo>(_jsonSerializer.SerializeToString(info));
+            info = _jsonSerializer.DeserializeFromString<ListingsProviderInfo>(_jsonSerializer.SerializeToString(info));
 
 
             var provider = _listingProviders.FirstOrDefault(i => string.Equals(info.Type, i.Type, StringComparison.OrdinalIgnoreCase));
             var provider = _listingProviders.FirstOrDefault(i => string.Equals(info.Type, i.Type, StringComparison.OrdinalIgnoreCase));
 
 

+ 13 - 1
Emby.Server.Implementations/LiveTv/ProgramImageProvider.cs

@@ -24,6 +24,18 @@ namespace Emby.Server.Implementations.LiveTv
             return new[] { ImageType.Primary };
             return new[] { ImageType.Primary };
         }
         }
 
 
+        private string GetItemExternalId(BaseItem item)
+        {
+            var externalId = item.ExternalId;
+
+            if (string.IsNullOrWhiteSpace(externalId))
+            {
+                externalId = item.GetProviderId("ProviderExternalId");
+            }
+
+            return externalId;
+        }
+
         public async Task<DynamicImageResponse> GetImage(IHasImages item, ImageType type, CancellationToken cancellationToken)
         public async Task<DynamicImageResponse> GetImage(IHasImages item, ImageType type, CancellationToken cancellationToken)
         {
         {
             var liveTvItem = (LiveTvProgram)item;
             var liveTvItem = (LiveTvProgram)item;
@@ -38,7 +50,7 @@ namespace Emby.Server.Implementations.LiveTv
                 {
                 {
                     var channel = _liveTvManager.GetInternalChannel(liveTvItem.ChannelId);
                     var channel = _liveTvManager.GetInternalChannel(liveTvItem.ChannelId);
 
 
-                    var response = await service.GetProgramImageAsync(liveTvItem.ExternalId, channel.ExternalId, cancellationToken).ConfigureAwait(false);
+                    var response = await service.GetProgramImageAsync(GetItemExternalId(liveTvItem), GetItemExternalId(channel), cancellationToken).ConfigureAwait(false);
 
 
                     if (response != null)
                     if (response != null)
                     {
                     {

+ 9 - 3
Emby.Server.Implementations/Security/MBLicenseFile.cs

@@ -57,9 +57,14 @@ namespace Emby.Server.Implementations.Security
             _updateRecords.AddOrUpdate(key, value, (k, v) => value);
             _updateRecords.AddOrUpdate(key, value, (k, v) => value);
         }
         }
 
 
+        private Guid GetKey(string featureId)
+        {
+            return new Guid(_cryptographyProvider.ComputeMD5(Encoding.Unicode.GetBytes(featureId)));
+        }
+
         public void AddRegCheck(string featureId)
         public void AddRegCheck(string featureId)
         {
         {
-            var key = new Guid(_cryptographyProvider.ComputeMD5(Encoding.Unicode.GetBytes(featureId)));
+            var key = GetKey(featureId);
             var value = DateTime.UtcNow;
             var value = DateTime.UtcNow;
 
 
             SetUpdateRecord(key, value);
             SetUpdateRecord(key, value);
@@ -68,7 +73,7 @@ namespace Emby.Server.Implementations.Security
 
 
         public void RemoveRegCheck(string featureId)
         public void RemoveRegCheck(string featureId)
         {
         {
-            var key = new Guid(_cryptographyProvider.ComputeMD5(Encoding.Unicode.GetBytes(featureId)));
+            var key = GetKey(featureId);
             DateTime val;
             DateTime val;
 
 
             _updateRecords.TryRemove(key, out val);
             _updateRecords.TryRemove(key, out val);
@@ -78,8 +83,9 @@ namespace Emby.Server.Implementations.Security
 
 
         public DateTime LastChecked(string featureId)
         public DateTime LastChecked(string featureId)
         {
         {
+            var key = GetKey(featureId);
             DateTime last;
             DateTime last;
-            _updateRecords.TryGetValue(new Guid(_cryptographyProvider.ComputeMD5(Encoding.Unicode.GetBytes(featureId))), out last);
+            _updateRecords.TryGetValue(key, out last);
 
 
             // guard agains people just putting a large number in the file
             // guard agains people just putting a large number in the file
             return last < DateTime.UtcNow ? last : DateTime.MinValue;
             return last < DateTime.UtcNow ? last : DateTime.MinValue;

+ 5 - 1
MediaBrowser.Api/ApiEntryPoint.cs

@@ -128,7 +128,11 @@ namespace MediaBrowser.Api
             {
             {
                 // Don't clutter the log
                 // Don't clutter the log
             }
             }
-            catch (IOException ex)
+            catch (IOException)
+            {
+                // Don't clutter the log
+            }
+            catch (Exception ex)
             {
             {
                 Logger.ErrorException("Error deleting encoded media cache", ex);
                 Logger.ErrorException("Error deleting encoded media cache", ex);
             }
             }

+ 13 - 3
MediaBrowser.Api/Playback/BaseStreamingService.cs

@@ -336,9 +336,12 @@ namespace MediaBrowser.Api.Playback
             {
             {
                 // vaapi will throw an error with this input
                 // vaapi will throw an error with this input
                 // [vaapi @ 0x7faed8000960] No VAAPI support for codec mpeg4 profile -99.
                 // [vaapi @ 0x7faed8000960] No VAAPI support for codec mpeg4 profile -99.
-                if (string.Equals(videoStream.Codec, "mpeg4", StringComparison.OrdinalIgnoreCase) && videoStream.Level == -99)
+                if (string.Equals(videoStream.Codec, "mpeg4", StringComparison.OrdinalIgnoreCase))
                 {
                 {
-                    return false;
+                    if (videoStream.Level == -99 || videoStream.Level == 15)
+                    {
+                        return false;
+                    }
                 }
                 }
             }
             }
             return true;
             return true;
@@ -1756,6 +1759,13 @@ namespace MediaBrowser.Api.Playback
                         videoRequest.EnableSplittingOnNonKeyFrames = string.Equals("true", val, StringComparison.OrdinalIgnoreCase);
                         videoRequest.EnableSplittingOnNonKeyFrames = string.Equals("true", val, StringComparison.OrdinalIgnoreCase);
                     }
                     }
                 }
                 }
+                else if (i == 30)
+                {
+                    if (videoRequest != null)
+                    {
+                        videoRequest.RequireAvc = string.Equals("true", val, StringComparison.OrdinalIgnoreCase);
+                    }
+                }
             }
             }
         }
         }
 
 
@@ -2112,7 +2122,7 @@ namespace MediaBrowser.Api.Playback
 
 
             if (string.Equals("h264", videoStream.Codec, StringComparison.OrdinalIgnoreCase))
             if (string.Equals("h264", videoStream.Codec, StringComparison.OrdinalIgnoreCase))
             {
             {
-                if (videoStream.IsAVC.HasValue && !videoStream.IsAVC.Value)
+                if (videoStream.IsAVC.HasValue && !videoStream.IsAVC.Value && request.RequireAvc)
                 {
                 {
                     Logger.Debug("Cannot stream copy video. Stream is marked as not AVC");
                     Logger.Debug("Cannot stream copy video. Stream is marked as not AVC");
                     return false;
                     return false;

+ 1 - 0
MediaBrowser.Api/Playback/StreamRequest.cs

@@ -195,6 +195,7 @@ namespace MediaBrowser.Api.Playback
 
 
         public bool EnableSubtitlesInManifest { get; set; }
         public bool EnableSubtitlesInManifest { get; set; }
         public bool EnableSplittingOnNonKeyFrames { get; set; }
         public bool EnableSplittingOnNonKeyFrames { get; set; }
+        public bool RequireAvc { get; set; }
 
 
         public VideoStreamRequest()
         public VideoStreamRequest()
         {
         {

+ 0 - 6
MediaBrowser.Common/Configuration/IApplicationPaths.cs

@@ -6,12 +6,6 @@ namespace MediaBrowser.Common.Configuration
     /// </summary>
     /// </summary>
     public interface IApplicationPaths
     public interface IApplicationPaths
     {
     {
-        /// <summary>
-        /// Gets the application path.
-        /// </summary>
-        /// <value>The application path.</value>
-        string ApplicationPath { get; }
-
         /// <summary>
         /// <summary>
         /// Gets the path to the program data folder
         /// Gets the path to the program data folder
         /// </summary>
         /// </summary>

+ 1 - 18
MediaBrowser.Controller/Entities/BaseItem.cs

@@ -296,28 +296,11 @@ namespace MediaBrowser.Controller.Entities
         /// If this content came from an external service, the id of the content on that service
         /// If this content came from an external service, the id of the content on that service
         /// </summary>
         /// </summary>
         [IgnoreDataMember]
         [IgnoreDataMember]
-        public string ExternalId
-        {
-            get { return this.GetProviderId("ProviderExternalId"); }
-            set
-            {
-                this.SetProviderId("ProviderExternalId", value);
-            }
-        }
+        public string ExternalId { get; set; }
 
 
         [IgnoreDataMember]
         [IgnoreDataMember]
         public string ExternalSeriesId { get; set; }
         public string ExternalSeriesId { get; set; }
 
 
-        [IgnoreDataMember]
-        public string ExternalSeriesIdLegacy
-        {
-            get { return this.GetProviderId("ProviderExternalSeriesId"); }
-            set
-            {
-                this.SetProviderId("ProviderExternalSeriesId", value);
-            }
-        }
-
         /// <summary>
         /// <summary>
         /// Gets or sets the etag.
         /// Gets or sets the etag.
         /// </summary>
         /// </summary>

+ 9 - 7
MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs

@@ -37,20 +37,22 @@ namespace MediaBrowser.MediaEncoding.Encoder
             {
             {
                 output = GetProcessOutput(encoderAppPath, "-version");
                 output = GetProcessOutput(encoderAppPath, "-version");
             }
             }
-            catch
+            catch (Exception ex)
             {
             {
+                if (logOutput)
+                {
+                    _logger.ErrorException("Error validating encoder", ex);
+                }
             }
             }
 
 
-            output = output ?? string.Empty;
-
-            if (logOutput)
+            if (string.IsNullOrWhiteSpace(output))
             {
             {
-                _logger.Info("ffmpeg info: {0}", output);
+                return false;
             }
             }
 
 
-            if (string.IsNullOrWhiteSpace(output))
+            if (logOutput)
             {
             {
-                return false;
+                _logger.Info("ffmpeg info: {0}", output);
             }
             }
 
 
             if (output.IndexOf("Libav developers", StringComparison.OrdinalIgnoreCase) != -1)
             if (output.IndexOf("Libav developers", StringComparison.OrdinalIgnoreCase) != -1)

+ 5 - 2
MediaBrowser.MediaEncoding/Encoder/EncodingJobFactory.cs

@@ -606,9 +606,12 @@ namespace MediaBrowser.MediaEncoding.Encoder
             {
             {
                 // vaapi will throw an error with this input
                 // vaapi will throw an error with this input
                 // [vaapi @ 0x7faed8000960] No VAAPI support for codec mpeg4 profile -99.
                 // [vaapi @ 0x7faed8000960] No VAAPI support for codec mpeg4 profile -99.
-                if (string.Equals(videoStream.Codec, "mpeg4", StringComparison.OrdinalIgnoreCase) && videoStream.Level == -99)
+                if (string.Equals(videoStream.Codec, "mpeg4", StringComparison.OrdinalIgnoreCase))
                 {
                 {
-                    return false;
+                    if (videoStream.Level == -99 || videoStream.Level == 15)
+                    {
+                        return false;
+                    }
                 }
                 }
             }
             }
             return true;
             return true;

+ 27 - 51
MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs

@@ -88,8 +88,8 @@ namespace MediaBrowser.MediaEncoding.Encoder
         private readonly int DefaultImageExtractionTimeoutMs;
         private readonly int DefaultImageExtractionTimeoutMs;
         private readonly bool EnableEncoderFontFile;
         private readonly bool EnableEncoderFontFile;
 
 
-        public MediaEncoder(ILogger logger, IJsonSerializer jsonSerializer, string ffMpegPath, string ffProbePath, bool hasExternalEncoder, IServerConfigurationManager configurationManager, IFileSystem fileSystem, ILiveTvManager liveTvManager, IIsoManager isoManager, ILibraryManager libraryManager, IChannelManager channelManager, ISessionManager sessionManager, Func<ISubtitleEncoder> subtitleEncoder, Func<IMediaSourceManager> mediaSourceManager, IHttpClient httpClient, IZipClient zipClient, IMemoryStreamFactory memoryStreamProvider, IProcessFactory processFactory, 
-            int defaultImageExtractionTimeoutMs, 
+        public MediaEncoder(ILogger logger, IJsonSerializer jsonSerializer, string ffMpegPath, string ffProbePath, bool hasExternalEncoder, IServerConfigurationManager configurationManager, IFileSystem fileSystem, ILiveTvManager liveTvManager, IIsoManager isoManager, ILibraryManager libraryManager, IChannelManager channelManager, ISessionManager sessionManager, Func<ISubtitleEncoder> subtitleEncoder, Func<IMediaSourceManager> mediaSourceManager, IHttpClient httpClient, IZipClient zipClient, IMemoryStreamFactory memoryStreamProvider, IProcessFactory processFactory,
+            int defaultImageExtractionTimeoutMs,
             bool enableEncoderFontFile)
             bool enableEncoderFontFile)
         {
         {
             _logger = logger;
             _logger = logger;
@@ -459,7 +459,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
             if (request.AnalyzeDurationSections > 0)
             if (request.AnalyzeDurationSections > 0)
             {
             {
                 analyzeDuration = "-analyzeduration " +
                 analyzeDuration = "-analyzeduration " +
-                                  (request.AnalyzeDurationSections*1000000).ToString(CultureInfo.InvariantCulture);
+                                  (request.AnalyzeDurationSections * 1000000).ToString(CultureInfo.InvariantCulture);
             }
             }
             else
             else
             {
             {
@@ -542,8 +542,6 @@ namespace MediaBrowser.MediaEncoding.Encoder
 
 
                 // Must consume both or ffmpeg may hang due to deadlocks. See comments below.   
                 // Must consume both or ffmpeg may hang due to deadlocks. See comments below.   
                 RedirectStandardOutput = true,
                 RedirectStandardOutput = true,
-                //RedirectStandardError = true,
-                RedirectStandardInput = false,
                 FileName = FFProbePath,
                 FileName = FFProbePath,
                 Arguments = string.Format(args, probeSizeArgument, inputPath).Trim(),
                 Arguments = string.Format(args, probeSizeArgument, inputPath).Trim(),
 
 
@@ -554,7 +552,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
 
 
             _logger.Debug("{0} {1}", process.StartInfo.FileName, process.StartInfo.Arguments);
             _logger.Debug("{0} {1}", process.StartInfo.FileName, process.StartInfo.Arguments);
 
 
-            using (var processWrapper = new ProcessWrapper(process, this, _logger, false))
+            using (var processWrapper = new ProcessWrapper(process, this, _logger))
             {
             {
                 await _ffProbeResourcePool.WaitAsync(cancellationToken).ConfigureAwait(false);
                 await _ffProbeResourcePool.WaitAsync(cancellationToken).ConfigureAwait(false);
 
 
@@ -616,7 +614,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
                 }
                 }
                 catch
                 catch
                 {
                 {
-                    StopProcess(processWrapper, 100, true);
+                    StopProcess(processWrapper, 100);
 
 
                     throw;
                     throw;
                 }
                 }
@@ -671,9 +669,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
                 UseShellExecute = false,
                 UseShellExecute = false,
 
 
                 // Must consume both or ffmpeg may hang due to deadlocks. See comments below.   
                 // Must consume both or ffmpeg may hang due to deadlocks. See comments below.   
-                //RedirectStandardOutput = true,
                 RedirectStandardError = true,
                 RedirectStandardError = true,
-                RedirectStandardInput = false,
                 FileName = FFMpegPath,
                 FileName = FFMpegPath,
                 Arguments = string.Format(args, probeSizeArgument, inputPath, videoStream.Index.ToString(CultureInfo.InvariantCulture)).Trim(),
                 Arguments = string.Format(args, probeSizeArgument, inputPath, videoStream.Index.ToString(CultureInfo.InvariantCulture)).Trim(),
 
 
@@ -685,7 +681,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
             _logger.Debug("{0} {1}", process.StartInfo.FileName, process.StartInfo.Arguments);
             _logger.Debug("{0} {1}", process.StartInfo.FileName, process.StartInfo.Arguments);
             var idetFoundInterlaced = false;
             var idetFoundInterlaced = false;
 
 
-            using (var processWrapper = new ProcessWrapper(process, this, _logger, false))
+            using (var processWrapper = new ProcessWrapper(process, this, _logger))
             {
             {
                 try
                 try
                 {
                 {
@@ -728,7 +724,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
                 }
                 }
                 catch
                 catch
                 {
                 {
-                    StopProcess(processWrapper, 100, true);
+                    StopProcess(processWrapper, 100);
 
 
                     throw;
                     throw;
                 }
                 }
@@ -945,7 +941,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
 
 
             _logger.Debug("{0} {1}", process.StartInfo.FileName, process.StartInfo.Arguments);
             _logger.Debug("{0} {1}", process.StartInfo.FileName, process.StartInfo.Arguments);
 
 
-            using (var processWrapper = new ProcessWrapper(process, this, _logger, false))
+            using (var processWrapper = new ProcessWrapper(process, this, _logger))
             {
             {
                 await resourcePool.WaitAsync(cancellationToken).ConfigureAwait(false);
                 await resourcePool.WaitAsync(cancellationToken).ConfigureAwait(false);
 
 
@@ -965,7 +961,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
 
 
                     if (!ranToCompletion)
                     if (!ranToCompletion)
                     {
                     {
-                        StopProcess(processWrapper, 1000, false);
+                        StopProcess(processWrapper, 1000);
                     }
                     }
 
 
                 }
                 }
@@ -1043,8 +1039,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
                 FileName = FFMpegPath,
                 FileName = FFMpegPath,
                 Arguments = args,
                 Arguments = args,
                 IsHidden = true,
                 IsHidden = true,
-                ErrorDialog = false,
-                RedirectStandardInput = true
+                ErrorDialog = false
             });
             });
 
 
             _logger.Info(process.StartInfo.FileName + " " + process.StartInfo.Arguments);
             _logger.Info(process.StartInfo.FileName + " " + process.StartInfo.Arguments);
@@ -1053,7 +1048,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
 
 
             bool ranToCompletion = false;
             bool ranToCompletion = false;
 
 
-            using (var processWrapper = new ProcessWrapper(process, this, _logger, true))
+            using (var processWrapper = new ProcessWrapper(process, this, _logger))
             {
             {
                 try
                 try
                 {
                 {
@@ -1085,7 +1080,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
 
 
                     if (!ranToCompletion)
                     if (!ranToCompletion)
                     {
                     {
-                        StopProcess(processWrapper, 1000, false);
+                        StopProcess(processWrapper, 1000);
                     }
                     }
                 }
                 }
                 finally
                 finally
@@ -1157,40 +1152,25 @@ namespace MediaBrowser.MediaEncoding.Encoder
                 _runningProcesses.Add(process);
                 _runningProcesses.Add(process);
             }
             }
         }
         }
-        private void StopProcess(ProcessWrapper process, int waitTimeMs, bool enableForceKill)
+        private void StopProcess(ProcessWrapper process, int waitTimeMs)
         {
         {
             try
             try
             {
             {
-                _logger.Info("Killing ffmpeg process");
-
-                if (process.IsRedirectingStdin)
+                if (process.Process.WaitForExit(waitTimeMs))
                 {
                 {
-                    try
-                    {
-                        process.Process.StandardInput.WriteLine("q");
-                    }
-                    catch (Exception)
-                    {
-                        _logger.Error("Error sending q command to process");
-                    }
+                    return;
                 }
                 }
+            }
+            catch (Exception ex)
+            {
+                _logger.Error("Error in WaitForExit", ex);
+            }
 
 
-                try
-                {
-                    if (process.Process.WaitForExit(waitTimeMs))
-                    {
-                        return;
-                    }
-                }
-                catch (Exception ex)
-                {
-                    _logger.Error("Error in WaitForExit", ex);
-                }
+            try
+            {
+                _logger.Info("Killing ffmpeg process");
 
 
-                if (enableForceKill)
-                {
-                    process.Process.Kill();
-                }
+                process.Process.Kill();
             }
             }
             catch (Exception ex)
             catch (Exception ex)
             {
             {
@@ -1211,7 +1191,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
             {
             {
                 if (!process.HasExited)
                 if (!process.HasExited)
                 {
                 {
-                    StopProcess(process, 500, true);
+                    StopProcess(process, 500);
                 }
                 }
             }
             }
         }
         }
@@ -1221,9 +1201,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
             // https://ffmpeg.org/ffmpeg-filters.html#Notes-on-filtergraph-escaping
             // https://ffmpeg.org/ffmpeg-filters.html#Notes-on-filtergraph-escaping
             // We need to double escape
             // We need to double escape
 
 
-            var escapeChars = new[] {':', '\'', ','};
-
-            return path.Replace('\\', '/').Replace(":/", "\\:/").Replace("'", "'\\\\\\''");
+            return path.Replace('\\', '/').Replace(":", "\\:").Replace("'", "'\\\\\\''");
         }
         }
 
 
         /// <summary>
         /// <summary>
@@ -1254,15 +1232,13 @@ namespace MediaBrowser.MediaEncoding.Encoder
             public int? ExitCode;
             public int? ExitCode;
             private readonly MediaEncoder _mediaEncoder;
             private readonly MediaEncoder _mediaEncoder;
             private readonly ILogger _logger;
             private readonly ILogger _logger;
-            public bool IsRedirectingStdin { get; private set; }
 
 
-            public ProcessWrapper(IProcess process, MediaEncoder mediaEncoder, ILogger logger, bool isRedirectingStdin)
+            public ProcessWrapper(IProcess process, MediaEncoder mediaEncoder, ILogger logger)
             {
             {
                 Process = process;
                 Process = process;
                 _mediaEncoder = mediaEncoder;
                 _mediaEncoder = mediaEncoder;
                 _logger = logger;
                 _logger = logger;
                 Process.Exited += Process_Exited;
                 Process.Exited += Process_Exited;
-                IsRedirectingStdin = isRedirectingStdin;
             }
             }
 
 
             void Process_Exited(object sender, EventArgs e)
             void Process_Exited(object sender, EventArgs e)

+ 5 - 71
MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs

@@ -444,10 +444,6 @@ namespace MediaBrowser.MediaEncoding.Subtitles
 
 
             var process = _processFactory.Create(new ProcessOptions
             var process = _processFactory.Create(new ProcessOptions
             {
             {
-                RedirectStandardOutput = false,
-                RedirectStandardError = true,
-                RedirectStandardInput = true,
-
                 CreateNoWindow = true,
                 CreateNoWindow = true,
                 UseShellExecute = false,
                 UseShellExecute = false,
                 FileName = _mediaEncoder.EncoderPath,
                 FileName = _mediaEncoder.EncoderPath,
@@ -459,26 +455,16 @@ namespace MediaBrowser.MediaEncoding.Subtitles
 
 
             _logger.Info("{0} {1}", process.StartInfo.FileName, process.StartInfo.Arguments);
             _logger.Info("{0} {1}", process.StartInfo.FileName, process.StartInfo.Arguments);
 
 
-            var logFilePath = Path.Combine(_appPaths.LogDirectoryPath, "ffmpeg-sub-convert-" + Guid.NewGuid() + ".txt");
-            _fileSystem.CreateDirectory(Path.GetDirectoryName(logFilePath));
-
-            var logFileStream = _fileSystem.GetFileStream(logFilePath, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read,
-                true);
-
             try
             try
             {
             {
                 process.Start();
                 process.Start();
             }
             }
             catch (Exception ex)
             catch (Exception ex)
             {
             {
-                logFileStream.Dispose();
-
                 _logger.ErrorException("Error starting ffmpeg", ex);
                 _logger.ErrorException("Error starting ffmpeg", ex);
 
 
                 throw;
                 throw;
             }
             }
-            
-            var logTask = process.StandardError.BaseStream.CopyToAsync(logFileStream);
 
 
             var ranToCompletion = process.WaitForExit(60000);
             var ranToCompletion = process.WaitForExit(60000);
 
 
@@ -488,19 +474,12 @@ namespace MediaBrowser.MediaEncoding.Subtitles
                 {
                 {
                     _logger.Info("Killing ffmpeg subtitle conversion process");
                     _logger.Info("Killing ffmpeg subtitle conversion process");
 
 
-                    process.StandardInput.WriteLine("q");
-                    process.WaitForExit(1000);
-
-                    await logTask.ConfigureAwait(false);
+                    process.Kill();
                 }
                 }
                 catch (Exception ex)
                 catch (Exception ex)
                 {
                 {
                     _logger.ErrorException("Error killing subtitle conversion process", ex);
                     _logger.ErrorException("Error killing subtitle conversion process", ex);
                 }
                 }
-                finally
-                {
-                    logFileStream.Dispose();
-                }
             }
             }
 
 
             var exitCode = ranToCompletion ? process.ExitCode : -1;
             var exitCode = ranToCompletion ? process.ExitCode : -1;
@@ -533,13 +512,15 @@ namespace MediaBrowser.MediaEncoding.Subtitles
 
 
             if (failed)
             if (failed)
             {
             {
-                var msg = string.Format("ffmpeg subtitle converted failed for {0}", inputPath);
+                var msg = string.Format("ffmpeg subtitle conversion failed for {0}", inputPath);
 
 
                 _logger.Error(msg);
                 _logger.Error(msg);
 
 
                 throw new Exception(msg);
                 throw new Exception(msg);
             }
             }
             await SetAssFont(outputPath).ConfigureAwait(false);
             await SetAssFont(outputPath).ConfigureAwait(false);
+
+            _logger.Info("ffmpeg subtitle conversion succeeded for {0}", inputPath);
         }
         }
 
 
         /// <summary>
         /// <summary>
@@ -597,10 +578,6 @@ namespace MediaBrowser.MediaEncoding.Subtitles
                 CreateNoWindow = true,
                 CreateNoWindow = true,
                 UseShellExecute = false,
                 UseShellExecute = false,
 
 
-                RedirectStandardOutput = false,
-                RedirectStandardError = true,
-                RedirectStandardInput = true,
-
                 FileName = _mediaEncoder.EncoderPath,
                 FileName = _mediaEncoder.EncoderPath,
                 Arguments = processArgs,
                 Arguments = processArgs,
                 IsHidden = true,
                 IsHidden = true,
@@ -609,28 +586,17 @@ namespace MediaBrowser.MediaEncoding.Subtitles
 
 
             _logger.Info("{0} {1}", process.StartInfo.FileName, process.StartInfo.Arguments);
             _logger.Info("{0} {1}", process.StartInfo.FileName, process.StartInfo.Arguments);
 
 
-            var logFilePath = Path.Combine(_appPaths.LogDirectoryPath, "ffmpeg-sub-extract-" + Guid.NewGuid() + ".txt");
-            _fileSystem.CreateDirectory(Path.GetDirectoryName(logFilePath));
-
-            var logFileStream = _fileSystem.GetFileStream(logFilePath, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read,
-                true);
-
             try
             try
             {
             {
                 process.Start();
                 process.Start();
             }
             }
             catch (Exception ex)
             catch (Exception ex)
             {
             {
-                logFileStream.Dispose();
-
                 _logger.ErrorException("Error starting ffmpeg", ex);
                 _logger.ErrorException("Error starting ffmpeg", ex);
 
 
                 throw;
                 throw;
             }
             }
 
 
-            // Important - don't await the log task or we won't be able to kill ffmpeg when the user stops playback
-            Task.Run(() => StartStreamingLog(process.StandardError.BaseStream, logFileStream));
-
             var ranToCompletion = process.WaitForExit(300000);
             var ranToCompletion = process.WaitForExit(300000);
 
 
             if (!ranToCompletion)
             if (!ranToCompletion)
@@ -639,17 +605,12 @@ namespace MediaBrowser.MediaEncoding.Subtitles
                 {
                 {
                     _logger.Info("Killing ffmpeg subtitle extraction process");
                     _logger.Info("Killing ffmpeg subtitle extraction process");
 
 
-                    process.StandardInput.WriteLine("q");
-                    process.WaitForExit(1000);
+                    process.Kill();
                 }
                 }
                 catch (Exception ex)
                 catch (Exception ex)
                 {
                 {
                     _logger.ErrorException("Error killing subtitle extraction process", ex);
                     _logger.ErrorException("Error killing subtitle extraction process", ex);
                 }
                 }
-                finally
-                {
-                    logFileStream.Dispose();
-                }
             }
             }
 
 
             var exitCode = ranToCompletion ? process.ExitCode : -1;
             var exitCode = ranToCompletion ? process.ExitCode : -1;
@@ -702,33 +663,6 @@ namespace MediaBrowser.MediaEncoding.Subtitles
             }
             }
         }
         }
 
 
-        private async Task StartStreamingLog(Stream source, Stream target)
-        {
-            try
-            {
-                using (var reader = new StreamReader(source))
-                {
-                    while (!reader.EndOfStream)
-                    {
-                        var line = await reader.ReadLineAsync().ConfigureAwait(false);
-
-                        var bytes = Encoding.UTF8.GetBytes(Environment.NewLine + line);
-
-                        await target.WriteAsync(bytes, 0, bytes.Length).ConfigureAwait(false);
-                        await target.FlushAsync().ConfigureAwait(false);
-                    }
-                }
-            }
-            catch (ObjectDisposedException)
-            {
-                // Don't spam the log. This doesn't seem to throw in windows, but sometimes under linux
-            }
-            catch (Exception ex)
-            {
-                _logger.ErrorException("Error reading ffmpeg log", ex);
-            }
-        }
-
         /// <summary>
         /// <summary>
         /// Sets the ass font.
         /// Sets the ass font.
         /// </summary>
         /// </summary>

+ 19 - 1
MediaBrowser.Model/Dlna/StreamBuilder.cs

@@ -976,7 +976,7 @@ namespace MediaBrowser.Model.Dlna
 
 
             if (item.Bitrate.Value > maxBitrate.Value)
             if (item.Bitrate.Value > maxBitrate.Value)
             {
             {
-                _logger.Info("Bitrate exceeds DirectPlay limit");
+                _logger.Info("Bitrate exceeds DirectPlay limit: media bitrate: {0}, max bitrate: {1}", item.Bitrate.Value.ToString(CultureInfo.InvariantCulture), maxBitrate.Value.ToString(CultureInfo.InvariantCulture));
                 return false;
                 return false;
             }
             }
 
 
@@ -1055,6 +1055,22 @@ namespace MediaBrowser.Model.Dlna
                             }
                             }
                             break;
                             break;
                         }
                         }
+                    case ProfileConditionValue.IsAvc:
+                        {
+                            bool isAvc;
+                            if (bool.TryParse(value, out isAvc))
+                            {
+                                if (isAvc && condition.Condition == ProfileConditionType.Equals)
+                                {
+                                    item.RequireAvc = true;
+                                }
+                                else if (!isAvc && condition.Condition == ProfileConditionType.NotEquals)
+                                {
+                                    item.RequireAvc = true;
+                                }
+                            }
+                            break;
+                        }
                     case ProfileConditionValue.IsAnamorphic:
                     case ProfileConditionValue.IsAnamorphic:
                     case ProfileConditionValue.AudioProfile:
                     case ProfileConditionValue.AudioProfile:
                     case ProfileConditionValue.Has64BitOffsets:
                     case ProfileConditionValue.Has64BitOffsets:
@@ -1135,6 +1151,8 @@ namespace MediaBrowser.Model.Dlna
                             }
                             }
                             break;
                             break;
                         }
                         }
+                    default:
+                        break;
                 }
                 }
             }
             }
         }
         }

+ 2 - 0
MediaBrowser.Model/Dlna/StreamInfo.cs

@@ -35,6 +35,7 @@ namespace MediaBrowser.Model.Dlna
         public string VideoCodec { get; set; }
         public string VideoCodec { get; set; }
         public string VideoProfile { get; set; }
         public string VideoProfile { get; set; }
 
 
+        public bool RequireAvc { get; set; }
         public bool CopyTimestamps { get; set; }
         public bool CopyTimestamps { get; set; }
         public bool EnableSubtitlesInManifest { get; set; }
         public bool EnableSubtitlesInManifest { get; set; }
         public bool EnableSplittingOnNonKeyFrames { get; set; }
         public bool EnableSplittingOnNonKeyFrames { get; set; }
@@ -266,6 +267,7 @@ namespace MediaBrowser.Model.Dlna
 
 
             list.Add(new NameValuePair("Tag", item.MediaSource.ETag ?? string.Empty));
             list.Add(new NameValuePair("Tag", item.MediaSource.ETag ?? string.Empty));
             list.Add(new NameValuePair("EnableSplittingOnNonKeyFrames", item.EnableSplittingOnNonKeyFrames.ToString().ToLower()));
             list.Add(new NameValuePair("EnableSplittingOnNonKeyFrames", item.EnableSplittingOnNonKeyFrames.ToString().ToLower()));
+            list.Add(new NameValuePair("RequireAvc", item.RequireAvc.ToString().ToLower()));
 
 
             return list;
             return list;
         }
         }

+ 1 - 0
MediaBrowser.Model/IO/IFileSystem.cs

@@ -308,6 +308,7 @@ namespace MediaBrowser.Model.IO
         void SetReadOnly(string path, bool isHidden);
         void SetReadOnly(string path, bool isHidden);
 
 
         char DirectorySeparatorChar { get; }
         char DirectorySeparatorChar { get; }
+        char PathSeparator { get; }
 
 
         string GetFullPath(string path);
         string GetFullPath(string path);
 
 

+ 2 - 0
MediaBrowser.Model/System/IEnvironmentInfo.cs

@@ -12,6 +12,8 @@ namespace MediaBrowser.Model.System
         string OperatingSystemName { get; }
         string OperatingSystemName { get; }
         string OperatingSystemVersion { get; }
         string OperatingSystemVersion { get; }
         Architecture SystemArchitecture { get; }
         Architecture SystemArchitecture { get; }
+        string GetEnvironmentVariable(string name);
+        string GetUserId();
     }
     }
 
 
     public enum OperatingSystem
     public enum OperatingSystem

+ 2 - 0
MediaBrowser.Model/System/ISystemEvents.cs

@@ -6,5 +6,7 @@ namespace MediaBrowser.Model.System
     {
     {
         event EventHandler Resume;
         event EventHandler Resume;
         event EventHandler Suspend;
         event EventHandler Suspend;
+        event EventHandler SessionLogoff;
+        event EventHandler SystemShutdown;
     }
     }
 }
 }

+ 467 - 206
MediaBrowser.Server.Mac.sln

@@ -1,18 +1,16 @@
 
 
 Microsoft Visual Studio Solution File, Format Version 12.00
 Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 2012
+# Visual Studio 14
+VisualStudioVersion = 14.0.25420.1
+MinimumVisualStudioVersion = 10.0.40219.1
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Emby.Server.Mac", "MediaBrowser.Server.Mac\Emby.Server.Mac.csproj", "{C97B98FA-00D4-4880-88B8-C76017A418AB}"
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Emby.Server.Mac", "MediaBrowser.Server.Mac\Emby.Server.Mac.csproj", "{C97B98FA-00D4-4880-88B8-C76017A418AB}"
 EndProject
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediaBrowser.Api", "MediaBrowser.Api\MediaBrowser.Api.csproj", "{4FD51AC5-2C16-4308-A993-C3A84F3B4582}"
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediaBrowser.Api", "MediaBrowser.Api\MediaBrowser.Api.csproj", "{4FD51AC5-2C16-4308-A993-C3A84F3B4582}"
 EndProject
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediaBrowser.Common", "MediaBrowser.Common\MediaBrowser.Common.csproj", "{9142EEFA-7570-41E1-BFCC-468BB571AF2F}"
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediaBrowser.Common", "MediaBrowser.Common\MediaBrowser.Common.csproj", "{9142EEFA-7570-41E1-BFCC-468BB571AF2F}"
 EndProject
 EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediaBrowser.Common.Implementations", "MediaBrowser.Common.Implementations\MediaBrowser.Common.Implementations.csproj", "{C4D2573A-3FD3-441F-81AF-174AC4CD4E1D}"
-EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediaBrowser.Controller", "MediaBrowser.Controller\MediaBrowser.Controller.csproj", "{17E1F4E6-8ABD-4FE5-9ECF-43D4B6087BA2}"
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediaBrowser.Controller", "MediaBrowser.Controller\MediaBrowser.Controller.csproj", "{17E1F4E6-8ABD-4FE5-9ECF-43D4B6087BA2}"
 EndProject
 EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediaBrowser.Dlna", "MediaBrowser.Dlna\MediaBrowser.Dlna.csproj", "{734098EB-6DC1-4DD0-A1CA-3140DCD2737C}"
-EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediaBrowser.LocalMetadata", "MediaBrowser.LocalMetadata\MediaBrowser.LocalMetadata.csproj", "{7EF9F3E0-697D-42F3-A08F-19DEB5F84392}"
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediaBrowser.LocalMetadata", "MediaBrowser.LocalMetadata\MediaBrowser.LocalMetadata.csproj", "{7EF9F3E0-697D-42F3-A08F-19DEB5F84392}"
 EndProject
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediaBrowser.MediaEncoding", "MediaBrowser.MediaEncoding\MediaBrowser.MediaEncoding.csproj", "{0BD82FA6-EB8A-4452-8AF5-74F9C3849451}"
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediaBrowser.MediaEncoding", "MediaBrowser.MediaEncoding\MediaBrowser.MediaEncoding.csproj", "{0BD82FA6-EB8A-4452-8AF5-74F9C3849451}"
@@ -33,119 +31,61 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenSubtitlesHandler", "Ope
 EndProject
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Emby.Drawing", "Emby.Drawing\Emby.Drawing.csproj", "{08FFF49B-F175-4807-A2B5-73B0EBD9F716}"
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Emby.Drawing", "Emby.Drawing\Emby.Drawing.csproj", "{08FFF49B-F175-4807-A2B5-73B0EBD9F716}"
 EndProject
 EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.Nat", "Mono.Nat\Mono.Nat.csproj", "{D7453B88-2266-4805-B39B-2B5A2A33E1BA}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BDInfo", "BDInfo\BDInfo.csproj", "{88AE38DF-19D7-406F-A6A9-09527719A21E}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DvdLib", "DvdLib\DvdLib.csproj", "{713F42B5-878E-499D-A878-E4C652B1D5E8}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Emby.Dlna", "Emby.Dlna\Emby.Dlna.csproj", "{805844AB-E92F-45E6-9D99-4F6D48D129A5}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Emby.Drawing.ImageMagick", "Emby.Drawing.ImageMagick\Emby.Drawing.ImageMagick.csproj", "{6CFEE013-6E7C-432B-AC37-CABF0880C69A}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Emby.Drawing.Net", "Emby.Drawing.Net\Emby.Drawing.Net.csproj", "{C97A239E-A96C-4D64-A844-CCF8CC30AECB}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Emby.Photos", "Emby.Photos\Emby.Photos.csproj", "{89AB4548-770D-41FD-A891-8DAFF44F452C}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Emby.Server.Implementations", "Emby.Server.Implementations\Emby.Server.Implementations.csproj", "{E383961B-9356-4D5D-8233-9A1079D03055}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RSSDP", "RSSDP\RSSDP.csproj", "{21002819-C39A-4D3E-BE83-2A276A77FB1F}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SocketHttpListener.Portable", "SocketHttpListener.Portable\SocketHttpListener.Portable.csproj", "{4F26D5D8-A7B0-42B3-BA42-7CB7D245934E}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServiceStack", "ServiceStack\ServiceStack.csproj", "{680A1709-25EB-4D52-A87F-EE03FFD94BAA}"
 EndProject
 EndProject
 Global
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
-		Debug|Any CPU = Debug|Any CPU
-		Release|Any CPU = Release|Any CPU
 		AppStore|Any CPU = AppStore|Any CPU
 		AppStore|Any CPU = AppStore|Any CPU
-		Release Mono|Any CPU = Release Mono|Any CPU
+		AppStore|x86 = AppStore|x86
+		Debug|Any CPU = Debug|Any CPU
 		Debug|x86 = Debug|x86
 		Debug|x86 = Debug|x86
-		Release|x86 = Release|x86
+		Release Mono|Any CPU = Release Mono|Any CPU
 		Release Mono|x86 = Release Mono|x86
 		Release Mono|x86 = Release Mono|x86
+		Release|Any CPU = Release|Any CPU
+		Release|x86 = Release|x86
+		Signed|Any CPU = Signed|Any CPU
+		Signed|x86 = Signed|x86
 	EndGlobalSection
 	EndGlobalSection
 	GlobalSection(ProjectConfigurationPlatforms) = postSolution
 	GlobalSection(ProjectConfigurationPlatforms) = postSolution
-		{08FFF49B-F175-4807-A2B5-73B0EBD9F716}.AppStore|Any CPU.ActiveCfg = Release|Any CPU
-		{08FFF49B-F175-4807-A2B5-73B0EBD9F716}.AppStore|Any CPU.Build.0 = Release|Any CPU
-		{08FFF49B-F175-4807-A2B5-73B0EBD9F716}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{08FFF49B-F175-4807-A2B5-73B0EBD9F716}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{08FFF49B-F175-4807-A2B5-73B0EBD9F716}.Debug|x86.ActiveCfg = Debug|Any CPU
-		{08FFF49B-F175-4807-A2B5-73B0EBD9F716}.Debug|x86.Build.0 = Debug|Any CPU
-		{08FFF49B-F175-4807-A2B5-73B0EBD9F716}.Release Mono|Any CPU.ActiveCfg = Debug|Any CPU
-		{08FFF49B-F175-4807-A2B5-73B0EBD9F716}.Release Mono|Any CPU.Build.0 = Debug|Any CPU
-		{08FFF49B-F175-4807-A2B5-73B0EBD9F716}.Release Mono|x86.ActiveCfg = Debug|Any CPU
-		{08FFF49B-F175-4807-A2B5-73B0EBD9F716}.Release Mono|x86.Build.0 = Debug|Any CPU
-		{08FFF49B-F175-4807-A2B5-73B0EBD9F716}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{08FFF49B-F175-4807-A2B5-73B0EBD9F716}.Release|Any CPU.Build.0 = Release|Any CPU
-		{08FFF49B-F175-4807-A2B5-73B0EBD9F716}.Release|x86.ActiveCfg = Release|Any CPU
-		{08FFF49B-F175-4807-A2B5-73B0EBD9F716}.Release|x86.Build.0 = Release|Any CPU
-		{0BD82FA6-EB8A-4452-8AF5-74F9C3849451}.AppStore|Any CPU.ActiveCfg = Release|Any CPU
-		{0BD82FA6-EB8A-4452-8AF5-74F9C3849451}.AppStore|Any CPU.Build.0 = Release|Any CPU
-		{0BD82FA6-EB8A-4452-8AF5-74F9C3849451}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{0BD82FA6-EB8A-4452-8AF5-74F9C3849451}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{0BD82FA6-EB8A-4452-8AF5-74F9C3849451}.Debug|x86.ActiveCfg = Debug|Any CPU
-		{0BD82FA6-EB8A-4452-8AF5-74F9C3849451}.Debug|x86.Build.0 = Debug|Any CPU
-		{0BD82FA6-EB8A-4452-8AF5-74F9C3849451}.Release Mono|Any CPU.ActiveCfg = Release Mono|Any CPU
-		{0BD82FA6-EB8A-4452-8AF5-74F9C3849451}.Release Mono|Any CPU.Build.0 = Release Mono|Any CPU
-		{0BD82FA6-EB8A-4452-8AF5-74F9C3849451}.Release Mono|x86.ActiveCfg = Release Mono|Any CPU
-		{0BD82FA6-EB8A-4452-8AF5-74F9C3849451}.Release Mono|x86.Build.0 = Release Mono|Any CPU
-		{0BD82FA6-EB8A-4452-8AF5-74F9C3849451}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{0BD82FA6-EB8A-4452-8AF5-74F9C3849451}.Release|Any CPU.Build.0 = Release|Any CPU
-		{0BD82FA6-EB8A-4452-8AF5-74F9C3849451}.Release|x86.ActiveCfg = Release|Any CPU
-		{0BD82FA6-EB8A-4452-8AF5-74F9C3849451}.Release|x86.Build.0 = Release|Any CPU
-		{17E1F4E6-8ABD-4FE5-9ECF-43D4B6087BA2}.AppStore|Any CPU.ActiveCfg = Release|Any CPU
-		{17E1F4E6-8ABD-4FE5-9ECF-43D4B6087BA2}.AppStore|Any CPU.Build.0 = Release|Any CPU
-		{17E1F4E6-8ABD-4FE5-9ECF-43D4B6087BA2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{17E1F4E6-8ABD-4FE5-9ECF-43D4B6087BA2}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{17E1F4E6-8ABD-4FE5-9ECF-43D4B6087BA2}.Debug|x86.ActiveCfg = Debug|Any CPU
-		{17E1F4E6-8ABD-4FE5-9ECF-43D4B6087BA2}.Debug|x86.Build.0 = Debug|Any CPU
-		{17E1F4E6-8ABD-4FE5-9ECF-43D4B6087BA2}.Release Mono|Any CPU.ActiveCfg = Release Mono|Any CPU
-		{17E1F4E6-8ABD-4FE5-9ECF-43D4B6087BA2}.Release Mono|Any CPU.Build.0 = Release Mono|Any CPU
-		{17E1F4E6-8ABD-4FE5-9ECF-43D4B6087BA2}.Release Mono|x86.ActiveCfg = Release Mono|Any CPU
-		{17E1F4E6-8ABD-4FE5-9ECF-43D4B6087BA2}.Release Mono|x86.Build.0 = Release Mono|Any CPU
-		{17E1F4E6-8ABD-4FE5-9ECF-43D4B6087BA2}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{17E1F4E6-8ABD-4FE5-9ECF-43D4B6087BA2}.Release|Any CPU.Build.0 = Release|Any CPU
-		{17E1F4E6-8ABD-4FE5-9ECF-43D4B6087BA2}.Release|x86.ActiveCfg = Release|Any CPU
-		{17E1F4E6-8ABD-4FE5-9ECF-43D4B6087BA2}.Release|x86.Build.0 = Release|Any CPU
-		{23499896-B135-4527-8574-C26E926EA99E}.AppStore|Any CPU.ActiveCfg = Release|Any CPU
-		{23499896-B135-4527-8574-C26E926EA99E}.AppStore|Any CPU.Build.0 = Release|Any CPU
-		{23499896-B135-4527-8574-C26E926EA99E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{23499896-B135-4527-8574-C26E926EA99E}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{23499896-B135-4527-8574-C26E926EA99E}.Debug|x86.ActiveCfg = Debug|Any CPU
-		{23499896-B135-4527-8574-C26E926EA99E}.Debug|x86.Build.0 = Debug|Any CPU
-		{23499896-B135-4527-8574-C26E926EA99E}.Release Mono|Any CPU.ActiveCfg = Debug|Any CPU
-		{23499896-B135-4527-8574-C26E926EA99E}.Release Mono|Any CPU.Build.0 = Debug|Any CPU
-		{23499896-B135-4527-8574-C26E926EA99E}.Release Mono|x86.ActiveCfg = Debug|Any CPU
-		{23499896-B135-4527-8574-C26E926EA99E}.Release Mono|x86.Build.0 = Debug|Any CPU
-		{23499896-B135-4527-8574-C26E926EA99E}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{23499896-B135-4527-8574-C26E926EA99E}.Release|Any CPU.Build.0 = Release|Any CPU
-		{23499896-B135-4527-8574-C26E926EA99E}.Release|x86.ActiveCfg = Release|Any CPU
-		{23499896-B135-4527-8574-C26E926EA99E}.Release|x86.Build.0 = Release|Any CPU
-		{2E781478-814D-4A48-9D80-BFF206441A65}.AppStore|Any CPU.ActiveCfg = Release|Any CPU
-		{2E781478-814D-4A48-9D80-BFF206441A65}.AppStore|Any CPU.Build.0 = Release|Any CPU
-		{2E781478-814D-4A48-9D80-BFF206441A65}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{2E781478-814D-4A48-9D80-BFF206441A65}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{2E781478-814D-4A48-9D80-BFF206441A65}.Debug|x86.ActiveCfg = Debug|Any CPU
-		{2E781478-814D-4A48-9D80-BFF206441A65}.Debug|x86.Build.0 = Debug|Any CPU
-		{2E781478-814D-4A48-9D80-BFF206441A65}.Release Mono|Any CPU.ActiveCfg = Release Mono|Any CPU
-		{2E781478-814D-4A48-9D80-BFF206441A65}.Release Mono|Any CPU.Build.0 = Release Mono|Any CPU
-		{2E781478-814D-4A48-9D80-BFF206441A65}.Release Mono|x86.ActiveCfg = Release Mono|Any CPU
-		{2E781478-814D-4A48-9D80-BFF206441A65}.Release Mono|x86.Build.0 = Release Mono|Any CPU
-		{2E781478-814D-4A48-9D80-BFF206441A65}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{2E781478-814D-4A48-9D80-BFF206441A65}.Release|Any CPU.Build.0 = Release|Any CPU
-		{2E781478-814D-4A48-9D80-BFF206441A65}.Release|x86.ActiveCfg = Release|Any CPU
-		{2E781478-814D-4A48-9D80-BFF206441A65}.Release|x86.Build.0 = Release|Any CPU
-		{442B5058-DCAF-4263-BB6A-F21E31120A1B}.AppStore|Any CPU.ActiveCfg = Release|Any CPU
-		{442B5058-DCAF-4263-BB6A-F21E31120A1B}.AppStore|Any CPU.Build.0 = Release|Any CPU
-		{442B5058-DCAF-4263-BB6A-F21E31120A1B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{442B5058-DCAF-4263-BB6A-F21E31120A1B}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{442B5058-DCAF-4263-BB6A-F21E31120A1B}.Debug|x86.ActiveCfg = Debug|Any CPU
-		{442B5058-DCAF-4263-BB6A-F21E31120A1B}.Debug|x86.Build.0 = Debug|Any CPU
-		{442B5058-DCAF-4263-BB6A-F21E31120A1B}.Release Mono|Any CPU.ActiveCfg = Release Mono|Any CPU
-		{442B5058-DCAF-4263-BB6A-F21E31120A1B}.Release Mono|Any CPU.Build.0 = Release Mono|Any CPU
-		{442B5058-DCAF-4263-BB6A-F21E31120A1B}.Release Mono|x86.ActiveCfg = Release Mono|Any CPU
-		{442B5058-DCAF-4263-BB6A-F21E31120A1B}.Release Mono|x86.Build.0 = Release Mono|Any CPU
-		{442B5058-DCAF-4263-BB6A-F21E31120A1B}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{442B5058-DCAF-4263-BB6A-F21E31120A1B}.Release|Any CPU.Build.0 = Release|Any CPU
-		{442B5058-DCAF-4263-BB6A-F21E31120A1B}.Release|x86.ActiveCfg = Release|Any CPU
-		{442B5058-DCAF-4263-BB6A-F21E31120A1B}.Release|x86.Build.0 = Release|Any CPU
-		{4A4402D4-E910-443B-B8FC-2C18286A2CA0}.AppStore|Any CPU.ActiveCfg = Release|Any CPU
-		{4A4402D4-E910-443B-B8FC-2C18286A2CA0}.AppStore|Any CPU.Build.0 = Release|Any CPU
-		{4A4402D4-E910-443B-B8FC-2C18286A2CA0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{4A4402D4-E910-443B-B8FC-2C18286A2CA0}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{4A4402D4-E910-443B-B8FC-2C18286A2CA0}.Debug|x86.ActiveCfg = Debug|Any CPU
-		{4A4402D4-E910-443B-B8FC-2C18286A2CA0}.Debug|x86.Build.0 = Debug|Any CPU
-		{4A4402D4-E910-443B-B8FC-2C18286A2CA0}.Release Mono|Any CPU.ActiveCfg = Release Mono|Any CPU
-		{4A4402D4-E910-443B-B8FC-2C18286A2CA0}.Release Mono|Any CPU.Build.0 = Release Mono|Any CPU
-		{4A4402D4-E910-443B-B8FC-2C18286A2CA0}.Release Mono|x86.ActiveCfg = Release Mono|Any CPU
-		{4A4402D4-E910-443B-B8FC-2C18286A2CA0}.Release Mono|x86.Build.0 = Release Mono|Any CPU
-		{4A4402D4-E910-443B-B8FC-2C18286A2CA0}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{4A4402D4-E910-443B-B8FC-2C18286A2CA0}.Release|Any CPU.Build.0 = Release|Any CPU
-		{4A4402D4-E910-443B-B8FC-2C18286A2CA0}.Release|x86.ActiveCfg = Release|Any CPU
-		{4A4402D4-E910-443B-B8FC-2C18286A2CA0}.Release|x86.Build.0 = Release|Any CPU
+		{C97B98FA-00D4-4880-88B8-C76017A418AB}.AppStore|Any CPU.ActiveCfg = AppStore|Any CPU
+		{C97B98FA-00D4-4880-88B8-C76017A418AB}.AppStore|Any CPU.Build.0 = AppStore|Any CPU
+		{C97B98FA-00D4-4880-88B8-C76017A418AB}.AppStore|x86.ActiveCfg = AppStore|Any CPU
+		{C97B98FA-00D4-4880-88B8-C76017A418AB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{C97B98FA-00D4-4880-88B8-C76017A418AB}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{C97B98FA-00D4-4880-88B8-C76017A418AB}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{C97B98FA-00D4-4880-88B8-C76017A418AB}.Debug|x86.Build.0 = Debug|Any CPU
+		{C97B98FA-00D4-4880-88B8-C76017A418AB}.Release Mono|Any CPU.ActiveCfg = Debug|Any CPU
+		{C97B98FA-00D4-4880-88B8-C76017A418AB}.Release Mono|Any CPU.Build.0 = Debug|Any CPU
+		{C97B98FA-00D4-4880-88B8-C76017A418AB}.Release Mono|x86.ActiveCfg = Debug|Any CPU
+		{C97B98FA-00D4-4880-88B8-C76017A418AB}.Release Mono|x86.Build.0 = Debug|Any CPU
+		{C97B98FA-00D4-4880-88B8-C76017A418AB}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{C97B98FA-00D4-4880-88B8-C76017A418AB}.Release|Any CPU.Build.0 = Release|Any CPU
+		{C97B98FA-00D4-4880-88B8-C76017A418AB}.Release|x86.ActiveCfg = Release|Any CPU
+		{C97B98FA-00D4-4880-88B8-C76017A418AB}.Release|x86.Build.0 = Release|Any CPU
+		{C97B98FA-00D4-4880-88B8-C76017A418AB}.Signed|Any CPU.ActiveCfg = Release|Any CPU
+		{C97B98FA-00D4-4880-88B8-C76017A418AB}.Signed|x86.ActiveCfg = Release|Any CPU
 		{4FD51AC5-2C16-4308-A993-C3A84F3B4582}.AppStore|Any CPU.ActiveCfg = Release|Any CPU
 		{4FD51AC5-2C16-4308-A993-C3A84F3B4582}.AppStore|Any CPU.ActiveCfg = Release|Any CPU
 		{4FD51AC5-2C16-4308-A993-C3A84F3B4582}.AppStore|Any CPU.Build.0 = Release|Any CPU
 		{4FD51AC5-2C16-4308-A993-C3A84F3B4582}.AppStore|Any CPU.Build.0 = Release|Any CPU
+		{4FD51AC5-2C16-4308-A993-C3A84F3B4582}.AppStore|x86.ActiveCfg = Release Mono|Any CPU
+		{4FD51AC5-2C16-4308-A993-C3A84F3B4582}.AppStore|x86.Build.0 = Release Mono|Any CPU
 		{4FD51AC5-2C16-4308-A993-C3A84F3B4582}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 		{4FD51AC5-2C16-4308-A993-C3A84F3B4582}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 		{4FD51AC5-2C16-4308-A993-C3A84F3B4582}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{4FD51AC5-2C16-4308-A993-C3A84F3B4582}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{4FD51AC5-2C16-4308-A993-C3A84F3B4582}.Debug|x86.ActiveCfg = Debug|Any CPU
 		{4FD51AC5-2C16-4308-A993-C3A84F3B4582}.Debug|x86.ActiveCfg = Debug|Any CPU
@@ -158,64 +98,14 @@ Global
 		{4FD51AC5-2C16-4308-A993-C3A84F3B4582}.Release|Any CPU.Build.0 = Release|Any CPU
 		{4FD51AC5-2C16-4308-A993-C3A84F3B4582}.Release|Any CPU.Build.0 = Release|Any CPU
 		{4FD51AC5-2C16-4308-A993-C3A84F3B4582}.Release|x86.ActiveCfg = Release|Any CPU
 		{4FD51AC5-2C16-4308-A993-C3A84F3B4582}.Release|x86.ActiveCfg = Release|Any CPU
 		{4FD51AC5-2C16-4308-A993-C3A84F3B4582}.Release|x86.Build.0 = Release|Any CPU
 		{4FD51AC5-2C16-4308-A993-C3A84F3B4582}.Release|x86.Build.0 = Release|Any CPU
-		{5624B7B5-B5A7-41D8-9F10-CC5611109619}.AppStore|Any CPU.ActiveCfg = Release|Any CPU
-		{5624B7B5-B5A7-41D8-9F10-CC5611109619}.AppStore|Any CPU.Build.0 = Release|Any CPU
-		{5624B7B5-B5A7-41D8-9F10-CC5611109619}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{5624B7B5-B5A7-41D8-9F10-CC5611109619}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{5624B7B5-B5A7-41D8-9F10-CC5611109619}.Debug|x86.ActiveCfg = Debug|Any CPU
-		{5624B7B5-B5A7-41D8-9F10-CC5611109619}.Debug|x86.Build.0 = Debug|Any CPU
-		{5624B7B5-B5A7-41D8-9F10-CC5611109619}.Release Mono|Any CPU.ActiveCfg = Release Mono|Any CPU
-		{5624B7B5-B5A7-41D8-9F10-CC5611109619}.Release Mono|Any CPU.Build.0 = Release Mono|Any CPU
-		{5624B7B5-B5A7-41D8-9F10-CC5611109619}.Release Mono|x86.ActiveCfg = Release Mono|Any CPU
-		{5624B7B5-B5A7-41D8-9F10-CC5611109619}.Release Mono|x86.Build.0 = Release Mono|Any CPU
-		{5624B7B5-B5A7-41D8-9F10-CC5611109619}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{5624B7B5-B5A7-41D8-9F10-CC5611109619}.Release|Any CPU.Build.0 = Release|Any CPU
-		{5624B7B5-B5A7-41D8-9F10-CC5611109619}.Release|x86.ActiveCfg = Release|Any CPU
-		{5624B7B5-B5A7-41D8-9F10-CC5611109619}.Release|x86.Build.0 = Release|Any CPU
-		{734098EB-6DC1-4DD0-A1CA-3140DCD2737C}.AppStore|Any CPU.ActiveCfg = Release|Any CPU
-		{734098EB-6DC1-4DD0-A1CA-3140DCD2737C}.AppStore|Any CPU.Build.0 = Release|Any CPU
-		{734098EB-6DC1-4DD0-A1CA-3140DCD2737C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{734098EB-6DC1-4DD0-A1CA-3140DCD2737C}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{734098EB-6DC1-4DD0-A1CA-3140DCD2737C}.Debug|x86.ActiveCfg = Debug|Any CPU
-		{734098EB-6DC1-4DD0-A1CA-3140DCD2737C}.Debug|x86.Build.0 = Debug|Any CPU
-		{734098EB-6DC1-4DD0-A1CA-3140DCD2737C}.Release Mono|Any CPU.ActiveCfg = Release Mono|Any CPU
-		{734098EB-6DC1-4DD0-A1CA-3140DCD2737C}.Release Mono|Any CPU.Build.0 = Release Mono|Any CPU
-		{734098EB-6DC1-4DD0-A1CA-3140DCD2737C}.Release Mono|x86.ActiveCfg = Release Mono|Any CPU
-		{734098EB-6DC1-4DD0-A1CA-3140DCD2737C}.Release Mono|x86.Build.0 = Release Mono|Any CPU
-		{734098EB-6DC1-4DD0-A1CA-3140DCD2737C}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{734098EB-6DC1-4DD0-A1CA-3140DCD2737C}.Release|Any CPU.Build.0 = Release|Any CPU
-		{734098EB-6DC1-4DD0-A1CA-3140DCD2737C}.Release|x86.ActiveCfg = Release|Any CPU
-		{734098EB-6DC1-4DD0-A1CA-3140DCD2737C}.Release|x86.Build.0 = Release|Any CPU
-		{7EEEB4BB-F3E8-48FC-B4C5-70F0FFF8329B}.AppStore|Any CPU.ActiveCfg = Release|Any CPU
-		{7EEEB4BB-F3E8-48FC-B4C5-70F0FFF8329B}.AppStore|Any CPU.Build.0 = Release|Any CPU
-		{7EEEB4BB-F3E8-48FC-B4C5-70F0FFF8329B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{7EEEB4BB-F3E8-48FC-B4C5-70F0FFF8329B}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{7EEEB4BB-F3E8-48FC-B4C5-70F0FFF8329B}.Debug|x86.ActiveCfg = Debug|Any CPU
-		{7EEEB4BB-F3E8-48FC-B4C5-70F0FFF8329B}.Debug|x86.Build.0 = Debug|Any CPU
-		{7EEEB4BB-F3E8-48FC-B4C5-70F0FFF8329B}.Release Mono|Any CPU.ActiveCfg = Release Mono|Any CPU
-		{7EEEB4BB-F3E8-48FC-B4C5-70F0FFF8329B}.Release Mono|Any CPU.Build.0 = Release Mono|Any CPU
-		{7EEEB4BB-F3E8-48FC-B4C5-70F0FFF8329B}.Release Mono|x86.ActiveCfg = Release Mono|Any CPU
-		{7EEEB4BB-F3E8-48FC-B4C5-70F0FFF8329B}.Release Mono|x86.Build.0 = Release Mono|Any CPU
-		{7EEEB4BB-F3E8-48FC-B4C5-70F0FFF8329B}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{7EEEB4BB-F3E8-48FC-B4C5-70F0FFF8329B}.Release|Any CPU.Build.0 = Release|Any CPU
-		{7EEEB4BB-F3E8-48FC-B4C5-70F0FFF8329B}.Release|x86.ActiveCfg = Release|Any CPU
-		{7EEEB4BB-F3E8-48FC-B4C5-70F0FFF8329B}.Release|x86.Build.0 = Release|Any CPU
-		{7EF9F3E0-697D-42F3-A08F-19DEB5F84392}.AppStore|Any CPU.ActiveCfg = Release|Any CPU
-		{7EF9F3E0-697D-42F3-A08F-19DEB5F84392}.AppStore|Any CPU.Build.0 = Release|Any CPU
-		{7EF9F3E0-697D-42F3-A08F-19DEB5F84392}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{7EF9F3E0-697D-42F3-A08F-19DEB5F84392}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{7EF9F3E0-697D-42F3-A08F-19DEB5F84392}.Debug|x86.ActiveCfg = Debug|Any CPU
-		{7EF9F3E0-697D-42F3-A08F-19DEB5F84392}.Debug|x86.Build.0 = Debug|Any CPU
-		{7EF9F3E0-697D-42F3-A08F-19DEB5F84392}.Release Mono|Any CPU.ActiveCfg = Debug|Any CPU
-		{7EF9F3E0-697D-42F3-A08F-19DEB5F84392}.Release Mono|Any CPU.Build.0 = Debug|Any CPU
-		{7EF9F3E0-697D-42F3-A08F-19DEB5F84392}.Release Mono|x86.ActiveCfg = Debug|Any CPU
-		{7EF9F3E0-697D-42F3-A08F-19DEB5F84392}.Release Mono|x86.Build.0 = Debug|Any CPU
-		{7EF9F3E0-697D-42F3-A08F-19DEB5F84392}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{7EF9F3E0-697D-42F3-A08F-19DEB5F84392}.Release|Any CPU.Build.0 = Release|Any CPU
-		{7EF9F3E0-697D-42F3-A08F-19DEB5F84392}.Release|x86.ActiveCfg = Release|Any CPU
-		{7EF9F3E0-697D-42F3-A08F-19DEB5F84392}.Release|x86.Build.0 = Release|Any CPU
+		{4FD51AC5-2C16-4308-A993-C3A84F3B4582}.Signed|Any CPU.ActiveCfg = Release Mono|Any CPU
+		{4FD51AC5-2C16-4308-A993-C3A84F3B4582}.Signed|Any CPU.Build.0 = Release Mono|Any CPU
+		{4FD51AC5-2C16-4308-A993-C3A84F3B4582}.Signed|x86.ActiveCfg = Release Mono|Any CPU
+		{4FD51AC5-2C16-4308-A993-C3A84F3B4582}.Signed|x86.Build.0 = Release Mono|Any CPU
 		{9142EEFA-7570-41E1-BFCC-468BB571AF2F}.AppStore|Any CPU.ActiveCfg = Release|Any CPU
 		{9142EEFA-7570-41E1-BFCC-468BB571AF2F}.AppStore|Any CPU.ActiveCfg = Release|Any CPU
 		{9142EEFA-7570-41E1-BFCC-468BB571AF2F}.AppStore|Any CPU.Build.0 = Release|Any CPU
 		{9142EEFA-7570-41E1-BFCC-468BB571AF2F}.AppStore|Any CPU.Build.0 = Release|Any CPU
+		{9142EEFA-7570-41E1-BFCC-468BB571AF2F}.AppStore|x86.ActiveCfg = Release Mono|Any CPU
+		{9142EEFA-7570-41E1-BFCC-468BB571AF2F}.AppStore|x86.Build.0 = Release Mono|Any CPU
 		{9142EEFA-7570-41E1-BFCC-468BB571AF2F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 		{9142EEFA-7570-41E1-BFCC-468BB571AF2F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 		{9142EEFA-7570-41E1-BFCC-468BB571AF2F}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{9142EEFA-7570-41E1-BFCC-468BB571AF2F}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{9142EEFA-7570-41E1-BFCC-468BB571AF2F}.Debug|x86.ActiveCfg = Debug|Any CPU
 		{9142EEFA-7570-41E1-BFCC-468BB571AF2F}.Debug|x86.ActiveCfg = Debug|Any CPU
@@ -228,8 +118,134 @@ Global
 		{9142EEFA-7570-41E1-BFCC-468BB571AF2F}.Release|Any CPU.Build.0 = Release|Any CPU
 		{9142EEFA-7570-41E1-BFCC-468BB571AF2F}.Release|Any CPU.Build.0 = Release|Any CPU
 		{9142EEFA-7570-41E1-BFCC-468BB571AF2F}.Release|x86.ActiveCfg = Release|Any CPU
 		{9142EEFA-7570-41E1-BFCC-468BB571AF2F}.Release|x86.ActiveCfg = Release|Any CPU
 		{9142EEFA-7570-41E1-BFCC-468BB571AF2F}.Release|x86.Build.0 = Release|Any CPU
 		{9142EEFA-7570-41E1-BFCC-468BB571AF2F}.Release|x86.Build.0 = Release|Any CPU
+		{9142EEFA-7570-41E1-BFCC-468BB571AF2F}.Signed|Any CPU.ActiveCfg = Release Mono|Any CPU
+		{9142EEFA-7570-41E1-BFCC-468BB571AF2F}.Signed|Any CPU.Build.0 = Release Mono|Any CPU
+		{9142EEFA-7570-41E1-BFCC-468BB571AF2F}.Signed|x86.ActiveCfg = Release Mono|Any CPU
+		{9142EEFA-7570-41E1-BFCC-468BB571AF2F}.Signed|x86.Build.0 = Release Mono|Any CPU
+		{17E1F4E6-8ABD-4FE5-9ECF-43D4B6087BA2}.AppStore|Any CPU.ActiveCfg = Release|Any CPU
+		{17E1F4E6-8ABD-4FE5-9ECF-43D4B6087BA2}.AppStore|Any CPU.Build.0 = Release|Any CPU
+		{17E1F4E6-8ABD-4FE5-9ECF-43D4B6087BA2}.AppStore|x86.ActiveCfg = Release Mono|Any CPU
+		{17E1F4E6-8ABD-4FE5-9ECF-43D4B6087BA2}.AppStore|x86.Build.0 = Release Mono|Any CPU
+		{17E1F4E6-8ABD-4FE5-9ECF-43D4B6087BA2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{17E1F4E6-8ABD-4FE5-9ECF-43D4B6087BA2}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{17E1F4E6-8ABD-4FE5-9ECF-43D4B6087BA2}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{17E1F4E6-8ABD-4FE5-9ECF-43D4B6087BA2}.Debug|x86.Build.0 = Debug|Any CPU
+		{17E1F4E6-8ABD-4FE5-9ECF-43D4B6087BA2}.Release Mono|Any CPU.ActiveCfg = Release Mono|Any CPU
+		{17E1F4E6-8ABD-4FE5-9ECF-43D4B6087BA2}.Release Mono|Any CPU.Build.0 = Release Mono|Any CPU
+		{17E1F4E6-8ABD-4FE5-9ECF-43D4B6087BA2}.Release Mono|x86.ActiveCfg = Release Mono|Any CPU
+		{17E1F4E6-8ABD-4FE5-9ECF-43D4B6087BA2}.Release Mono|x86.Build.0 = Release Mono|Any CPU
+		{17E1F4E6-8ABD-4FE5-9ECF-43D4B6087BA2}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{17E1F4E6-8ABD-4FE5-9ECF-43D4B6087BA2}.Release|Any CPU.Build.0 = Release|Any CPU
+		{17E1F4E6-8ABD-4FE5-9ECF-43D4B6087BA2}.Release|x86.ActiveCfg = Release|Any CPU
+		{17E1F4E6-8ABD-4FE5-9ECF-43D4B6087BA2}.Release|x86.Build.0 = Release|Any CPU
+		{17E1F4E6-8ABD-4FE5-9ECF-43D4B6087BA2}.Signed|Any CPU.ActiveCfg = Release Mono|Any CPU
+		{17E1F4E6-8ABD-4FE5-9ECF-43D4B6087BA2}.Signed|Any CPU.Build.0 = Release Mono|Any CPU
+		{17E1F4E6-8ABD-4FE5-9ECF-43D4B6087BA2}.Signed|x86.ActiveCfg = Release Mono|Any CPU
+		{17E1F4E6-8ABD-4FE5-9ECF-43D4B6087BA2}.Signed|x86.Build.0 = Release Mono|Any CPU
+		{7EF9F3E0-697D-42F3-A08F-19DEB5F84392}.AppStore|Any CPU.ActiveCfg = Release|Any CPU
+		{7EF9F3E0-697D-42F3-A08F-19DEB5F84392}.AppStore|Any CPU.Build.0 = Release|Any CPU
+		{7EF9F3E0-697D-42F3-A08F-19DEB5F84392}.AppStore|x86.ActiveCfg = Debug|Any CPU
+		{7EF9F3E0-697D-42F3-A08F-19DEB5F84392}.AppStore|x86.Build.0 = Debug|Any CPU
+		{7EF9F3E0-697D-42F3-A08F-19DEB5F84392}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{7EF9F3E0-697D-42F3-A08F-19DEB5F84392}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{7EF9F3E0-697D-42F3-A08F-19DEB5F84392}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{7EF9F3E0-697D-42F3-A08F-19DEB5F84392}.Debug|x86.Build.0 = Debug|Any CPU
+		{7EF9F3E0-697D-42F3-A08F-19DEB5F84392}.Release Mono|Any CPU.ActiveCfg = Debug|Any CPU
+		{7EF9F3E0-697D-42F3-A08F-19DEB5F84392}.Release Mono|Any CPU.Build.0 = Debug|Any CPU
+		{7EF9F3E0-697D-42F3-A08F-19DEB5F84392}.Release Mono|x86.ActiveCfg = Debug|Any CPU
+		{7EF9F3E0-697D-42F3-A08F-19DEB5F84392}.Release Mono|x86.Build.0 = Debug|Any CPU
+		{7EF9F3E0-697D-42F3-A08F-19DEB5F84392}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{7EF9F3E0-697D-42F3-A08F-19DEB5F84392}.Release|Any CPU.Build.0 = Release|Any CPU
+		{7EF9F3E0-697D-42F3-A08F-19DEB5F84392}.Release|x86.ActiveCfg = Release|Any CPU
+		{7EF9F3E0-697D-42F3-A08F-19DEB5F84392}.Release|x86.Build.0 = Release|Any CPU
+		{7EF9F3E0-697D-42F3-A08F-19DEB5F84392}.Signed|Any CPU.ActiveCfg = Debug|Any CPU
+		{7EF9F3E0-697D-42F3-A08F-19DEB5F84392}.Signed|Any CPU.Build.0 = Debug|Any CPU
+		{7EF9F3E0-697D-42F3-A08F-19DEB5F84392}.Signed|x86.ActiveCfg = Debug|Any CPU
+		{7EF9F3E0-697D-42F3-A08F-19DEB5F84392}.Signed|x86.Build.0 = Debug|Any CPU
+		{0BD82FA6-EB8A-4452-8AF5-74F9C3849451}.AppStore|Any CPU.ActiveCfg = Release|Any CPU
+		{0BD82FA6-EB8A-4452-8AF5-74F9C3849451}.AppStore|Any CPU.Build.0 = Release|Any CPU
+		{0BD82FA6-EB8A-4452-8AF5-74F9C3849451}.AppStore|x86.ActiveCfg = Release Mono|Any CPU
+		{0BD82FA6-EB8A-4452-8AF5-74F9C3849451}.AppStore|x86.Build.0 = Release Mono|Any CPU
+		{0BD82FA6-EB8A-4452-8AF5-74F9C3849451}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{0BD82FA6-EB8A-4452-8AF5-74F9C3849451}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{0BD82FA6-EB8A-4452-8AF5-74F9C3849451}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{0BD82FA6-EB8A-4452-8AF5-74F9C3849451}.Debug|x86.Build.0 = Debug|Any CPU
+		{0BD82FA6-EB8A-4452-8AF5-74F9C3849451}.Release Mono|Any CPU.ActiveCfg = Release Mono|Any CPU
+		{0BD82FA6-EB8A-4452-8AF5-74F9C3849451}.Release Mono|Any CPU.Build.0 = Release Mono|Any CPU
+		{0BD82FA6-EB8A-4452-8AF5-74F9C3849451}.Release Mono|x86.ActiveCfg = Release Mono|Any CPU
+		{0BD82FA6-EB8A-4452-8AF5-74F9C3849451}.Release Mono|x86.Build.0 = Release Mono|Any CPU
+		{0BD82FA6-EB8A-4452-8AF5-74F9C3849451}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{0BD82FA6-EB8A-4452-8AF5-74F9C3849451}.Release|Any CPU.Build.0 = Release|Any CPU
+		{0BD82FA6-EB8A-4452-8AF5-74F9C3849451}.Release|x86.ActiveCfg = Release|Any CPU
+		{0BD82FA6-EB8A-4452-8AF5-74F9C3849451}.Release|x86.Build.0 = Release|Any CPU
+		{0BD82FA6-EB8A-4452-8AF5-74F9C3849451}.Signed|Any CPU.ActiveCfg = Release Mono|Any CPU
+		{0BD82FA6-EB8A-4452-8AF5-74F9C3849451}.Signed|Any CPU.Build.0 = Release Mono|Any CPU
+		{0BD82FA6-EB8A-4452-8AF5-74F9C3849451}.Signed|x86.ActiveCfg = Release Mono|Any CPU
+		{0BD82FA6-EB8A-4452-8AF5-74F9C3849451}.Signed|x86.Build.0 = Release Mono|Any CPU
+		{7EEEB4BB-F3E8-48FC-B4C5-70F0FFF8329B}.AppStore|Any CPU.ActiveCfg = Release|Any CPU
+		{7EEEB4BB-F3E8-48FC-B4C5-70F0FFF8329B}.AppStore|Any CPU.Build.0 = Release|Any CPU
+		{7EEEB4BB-F3E8-48FC-B4C5-70F0FFF8329B}.AppStore|x86.ActiveCfg = Debug|Any CPU
+		{7EEEB4BB-F3E8-48FC-B4C5-70F0FFF8329B}.AppStore|x86.Build.0 = Debug|Any CPU
+		{7EEEB4BB-F3E8-48FC-B4C5-70F0FFF8329B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{7EEEB4BB-F3E8-48FC-B4C5-70F0FFF8329B}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{7EEEB4BB-F3E8-48FC-B4C5-70F0FFF8329B}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{7EEEB4BB-F3E8-48FC-B4C5-70F0FFF8329B}.Debug|x86.Build.0 = Debug|Any CPU
+		{7EEEB4BB-F3E8-48FC-B4C5-70F0FFF8329B}.Release Mono|Any CPU.ActiveCfg = Release|Any CPU
+		{7EEEB4BB-F3E8-48FC-B4C5-70F0FFF8329B}.Release Mono|Any CPU.Build.0 = Release|Any CPU
+		{7EEEB4BB-F3E8-48FC-B4C5-70F0FFF8329B}.Release Mono|x86.ActiveCfg = Release|Any CPU
+		{7EEEB4BB-F3E8-48FC-B4C5-70F0FFF8329B}.Release Mono|x86.Build.0 = Release|Any CPU
+		{7EEEB4BB-F3E8-48FC-B4C5-70F0FFF8329B}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{7EEEB4BB-F3E8-48FC-B4C5-70F0FFF8329B}.Release|Any CPU.Build.0 = Release|Any CPU
+		{7EEEB4BB-F3E8-48FC-B4C5-70F0FFF8329B}.Release|x86.ActiveCfg = Release|Any CPU
+		{7EEEB4BB-F3E8-48FC-B4C5-70F0FFF8329B}.Release|x86.Build.0 = Release|Any CPU
+		{7EEEB4BB-F3E8-48FC-B4C5-70F0FFF8329B}.Signed|Any CPU.ActiveCfg = Debug|Any CPU
+		{7EEEB4BB-F3E8-48FC-B4C5-70F0FFF8329B}.Signed|Any CPU.Build.0 = Debug|Any CPU
+		{7EEEB4BB-F3E8-48FC-B4C5-70F0FFF8329B}.Signed|x86.ActiveCfg = Debug|Any CPU
+		{7EEEB4BB-F3E8-48FC-B4C5-70F0FFF8329B}.Signed|x86.Build.0 = Debug|Any CPU
+		{442B5058-DCAF-4263-BB6A-F21E31120A1B}.AppStore|Any CPU.ActiveCfg = Release|Any CPU
+		{442B5058-DCAF-4263-BB6A-F21E31120A1B}.AppStore|Any CPU.Build.0 = Release|Any CPU
+		{442B5058-DCAF-4263-BB6A-F21E31120A1B}.AppStore|x86.ActiveCfg = Release Mono|Any CPU
+		{442B5058-DCAF-4263-BB6A-F21E31120A1B}.AppStore|x86.Build.0 = Release Mono|Any CPU
+		{442B5058-DCAF-4263-BB6A-F21E31120A1B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{442B5058-DCAF-4263-BB6A-F21E31120A1B}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{442B5058-DCAF-4263-BB6A-F21E31120A1B}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{442B5058-DCAF-4263-BB6A-F21E31120A1B}.Debug|x86.Build.0 = Debug|Any CPU
+		{442B5058-DCAF-4263-BB6A-F21E31120A1B}.Release Mono|Any CPU.ActiveCfg = Release Mono|Any CPU
+		{442B5058-DCAF-4263-BB6A-F21E31120A1B}.Release Mono|Any CPU.Build.0 = Release Mono|Any CPU
+		{442B5058-DCAF-4263-BB6A-F21E31120A1B}.Release Mono|x86.ActiveCfg = Release Mono|Any CPU
+		{442B5058-DCAF-4263-BB6A-F21E31120A1B}.Release Mono|x86.Build.0 = Release Mono|Any CPU
+		{442B5058-DCAF-4263-BB6A-F21E31120A1B}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{442B5058-DCAF-4263-BB6A-F21E31120A1B}.Release|Any CPU.Build.0 = Release|Any CPU
+		{442B5058-DCAF-4263-BB6A-F21E31120A1B}.Release|x86.ActiveCfg = Release|Any CPU
+		{442B5058-DCAF-4263-BB6A-F21E31120A1B}.Release|x86.Build.0 = Release|Any CPU
+		{442B5058-DCAF-4263-BB6A-F21E31120A1B}.Signed|Any CPU.ActiveCfg = Release Mono|Any CPU
+		{442B5058-DCAF-4263-BB6A-F21E31120A1B}.Signed|Any CPU.Build.0 = Release Mono|Any CPU
+		{442B5058-DCAF-4263-BB6A-F21E31120A1B}.Signed|x86.ActiveCfg = Release Mono|Any CPU
+		{442B5058-DCAF-4263-BB6A-F21E31120A1B}.Signed|x86.Build.0 = Release Mono|Any CPU
+		{2E781478-814D-4A48-9D80-BFF206441A65}.AppStore|Any CPU.ActiveCfg = Release|Any CPU
+		{2E781478-814D-4A48-9D80-BFF206441A65}.AppStore|Any CPU.Build.0 = Release|Any CPU
+		{2E781478-814D-4A48-9D80-BFF206441A65}.AppStore|x86.ActiveCfg = Release Mono|Any CPU
+		{2E781478-814D-4A48-9D80-BFF206441A65}.AppStore|x86.Build.0 = Release Mono|Any CPU
+		{2E781478-814D-4A48-9D80-BFF206441A65}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{2E781478-814D-4A48-9D80-BFF206441A65}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{2E781478-814D-4A48-9D80-BFF206441A65}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{2E781478-814D-4A48-9D80-BFF206441A65}.Debug|x86.Build.0 = Debug|Any CPU
+		{2E781478-814D-4A48-9D80-BFF206441A65}.Release Mono|Any CPU.ActiveCfg = Release Mono|Any CPU
+		{2E781478-814D-4A48-9D80-BFF206441A65}.Release Mono|Any CPU.Build.0 = Release Mono|Any CPU
+		{2E781478-814D-4A48-9D80-BFF206441A65}.Release Mono|x86.ActiveCfg = Release Mono|Any CPU
+		{2E781478-814D-4A48-9D80-BFF206441A65}.Release Mono|x86.Build.0 = Release Mono|Any CPU
+		{2E781478-814D-4A48-9D80-BFF206441A65}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{2E781478-814D-4A48-9D80-BFF206441A65}.Release|Any CPU.Build.0 = Release|Any CPU
+		{2E781478-814D-4A48-9D80-BFF206441A65}.Release|x86.ActiveCfg = Release|Any CPU
+		{2E781478-814D-4A48-9D80-BFF206441A65}.Release|x86.Build.0 = Release|Any CPU
+		{2E781478-814D-4A48-9D80-BFF206441A65}.Signed|Any CPU.ActiveCfg = Release Mono|Any CPU
+		{2E781478-814D-4A48-9D80-BFF206441A65}.Signed|Any CPU.Build.0 = Release Mono|Any CPU
+		{2E781478-814D-4A48-9D80-BFF206441A65}.Signed|x86.ActiveCfg = Release Mono|Any CPU
+		{2E781478-814D-4A48-9D80-BFF206441A65}.Signed|x86.Build.0 = Release Mono|Any CPU
 		{B90AB8F2-1BFF-4568-A3FD-2A338A435A75}.AppStore|Any CPU.ActiveCfg = Release|Any CPU
 		{B90AB8F2-1BFF-4568-A3FD-2A338A435A75}.AppStore|Any CPU.ActiveCfg = Release|Any CPU
 		{B90AB8F2-1BFF-4568-A3FD-2A338A435A75}.AppStore|Any CPU.Build.0 = Release|Any CPU
 		{B90AB8F2-1BFF-4568-A3FD-2A338A435A75}.AppStore|Any CPU.Build.0 = Release|Any CPU
+		{B90AB8F2-1BFF-4568-A3FD-2A338A435A75}.AppStore|x86.ActiveCfg = Debug|Any CPU
+		{B90AB8F2-1BFF-4568-A3FD-2A338A435A75}.AppStore|x86.Build.0 = Debug|Any CPU
 		{B90AB8F2-1BFF-4568-A3FD-2A338A435A75}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 		{B90AB8F2-1BFF-4568-A3FD-2A338A435A75}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 		{B90AB8F2-1BFF-4568-A3FD-2A338A435A75}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{B90AB8F2-1BFF-4568-A3FD-2A338A435A75}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{B90AB8F2-1BFF-4568-A3FD-2A338A435A75}.Debug|x86.ActiveCfg = Debug|Any CPU
 		{B90AB8F2-1BFF-4568-A3FD-2A338A435A75}.Debug|x86.ActiveCfg = Debug|Any CPU
@@ -242,48 +258,293 @@ Global
 		{B90AB8F2-1BFF-4568-A3FD-2A338A435A75}.Release|Any CPU.Build.0 = Release|Any CPU
 		{B90AB8F2-1BFF-4568-A3FD-2A338A435A75}.Release|Any CPU.Build.0 = Release|Any CPU
 		{B90AB8F2-1BFF-4568-A3FD-2A338A435A75}.Release|x86.ActiveCfg = Release|Any CPU
 		{B90AB8F2-1BFF-4568-A3FD-2A338A435A75}.Release|x86.ActiveCfg = Release|Any CPU
 		{B90AB8F2-1BFF-4568-A3FD-2A338A435A75}.Release|x86.Build.0 = Release|Any CPU
 		{B90AB8F2-1BFF-4568-A3FD-2A338A435A75}.Release|x86.Build.0 = Release|Any CPU
-		{C4D2573A-3FD3-441F-81AF-174AC4CD4E1D}.AppStore|Any CPU.ActiveCfg = Release|Any CPU
-		{C4D2573A-3FD3-441F-81AF-174AC4CD4E1D}.AppStore|Any CPU.Build.0 = Release|Any CPU
-		{C4D2573A-3FD3-441F-81AF-174AC4CD4E1D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{C4D2573A-3FD3-441F-81AF-174AC4CD4E1D}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{C4D2573A-3FD3-441F-81AF-174AC4CD4E1D}.Debug|x86.ActiveCfg = Debug|Any CPU
-		{C4D2573A-3FD3-441F-81AF-174AC4CD4E1D}.Debug|x86.Build.0 = Debug|Any CPU
-		{C4D2573A-3FD3-441F-81AF-174AC4CD4E1D}.Release Mono|Any CPU.ActiveCfg = Release Mono|Any CPU
-		{C4D2573A-3FD3-441F-81AF-174AC4CD4E1D}.Release Mono|Any CPU.Build.0 = Release Mono|Any CPU
-		{C4D2573A-3FD3-441F-81AF-174AC4CD4E1D}.Release Mono|x86.ActiveCfg = Release Mono|Any CPU
-		{C4D2573A-3FD3-441F-81AF-174AC4CD4E1D}.Release Mono|x86.Build.0 = Release Mono|Any CPU
-		{C4D2573A-3FD3-441F-81AF-174AC4CD4E1D}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{C4D2573A-3FD3-441F-81AF-174AC4CD4E1D}.Release|Any CPU.Build.0 = Release|Any CPU
-		{C4D2573A-3FD3-441F-81AF-174AC4CD4E1D}.Release|x86.ActiveCfg = Release|Any CPU
-		{C4D2573A-3FD3-441F-81AF-174AC4CD4E1D}.Release|x86.Build.0 = Release|Any CPU
-		{C97B98FA-00D4-4880-88B8-C76017A418AB}.AppStore|Any CPU.ActiveCfg = AppStore|Any CPU
-		{C97B98FA-00D4-4880-88B8-C76017A418AB}.AppStore|Any CPU.Build.0 = AppStore|Any CPU
-		{C97B98FA-00D4-4880-88B8-C76017A418AB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{C97B98FA-00D4-4880-88B8-C76017A418AB}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{C97B98FA-00D4-4880-88B8-C76017A418AB}.Debug|x86.ActiveCfg = Debug|Any CPU
-		{C97B98FA-00D4-4880-88B8-C76017A418AB}.Debug|x86.Build.0 = Debug|Any CPU
-		{C97B98FA-00D4-4880-88B8-C76017A418AB}.Release Mono|Any CPU.ActiveCfg = Debug|Any CPU
-		{C97B98FA-00D4-4880-88B8-C76017A418AB}.Release Mono|Any CPU.Build.0 = Debug|Any CPU
-		{C97B98FA-00D4-4880-88B8-C76017A418AB}.Release Mono|x86.ActiveCfg = Debug|Any CPU
-		{C97B98FA-00D4-4880-88B8-C76017A418AB}.Release Mono|x86.Build.0 = Debug|Any CPU
-		{C97B98FA-00D4-4880-88B8-C76017A418AB}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{C97B98FA-00D4-4880-88B8-C76017A418AB}.Release|Any CPU.Build.0 = Release|Any CPU
-		{C97B98FA-00D4-4880-88B8-C76017A418AB}.Release|x86.ActiveCfg = Release|Any CPU
-		{C97B98FA-00D4-4880-88B8-C76017A418AB}.Release|x86.Build.0 = Release|Any CPU
-		{D7453B88-2266-4805-B39B-2B5A2A33E1BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{D7453B88-2266-4805-B39B-2B5A2A33E1BA}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{D7453B88-2266-4805-B39B-2B5A2A33E1BA}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{D7453B88-2266-4805-B39B-2B5A2A33E1BA}.Release|Any CPU.Build.0 = Release|Any CPU
-		{D7453B88-2266-4805-B39B-2B5A2A33E1BA}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU
-		{D7453B88-2266-4805-B39B-2B5A2A33E1BA}.AppStore|Any CPU.Build.0 = Debug|Any CPU
-		{D7453B88-2266-4805-B39B-2B5A2A33E1BA}.Release Mono|Any CPU.ActiveCfg = Debug|Any CPU
-		{D7453B88-2266-4805-B39B-2B5A2A33E1BA}.Release Mono|Any CPU.Build.0 = Debug|Any CPU
-		{D7453B88-2266-4805-B39B-2B5A2A33E1BA}.Debug|x86.ActiveCfg = Debug|Any CPU
-		{D7453B88-2266-4805-B39B-2B5A2A33E1BA}.Debug|x86.Build.0 = Debug|Any CPU
-		{D7453B88-2266-4805-B39B-2B5A2A33E1BA}.Release|x86.ActiveCfg = Release|Any CPU
-		{D7453B88-2266-4805-B39B-2B5A2A33E1BA}.Release|x86.Build.0 = Release|Any CPU
-		{D7453B88-2266-4805-B39B-2B5A2A33E1BA}.Release Mono|x86.ActiveCfg = Debug|Any CPU
-		{D7453B88-2266-4805-B39B-2B5A2A33E1BA}.Release Mono|x86.Build.0 = Debug|Any CPU
+		{B90AB8F2-1BFF-4568-A3FD-2A338A435A75}.Signed|Any CPU.ActiveCfg = Debug|Any CPU
+		{B90AB8F2-1BFF-4568-A3FD-2A338A435A75}.Signed|Any CPU.Build.0 = Debug|Any CPU
+		{B90AB8F2-1BFF-4568-A3FD-2A338A435A75}.Signed|x86.ActiveCfg = Debug|Any CPU
+		{B90AB8F2-1BFF-4568-A3FD-2A338A435A75}.Signed|x86.Build.0 = Debug|Any CPU
+		{5624B7B5-B5A7-41D8-9F10-CC5611109619}.AppStore|Any CPU.ActiveCfg = Release|Any CPU
+		{5624B7B5-B5A7-41D8-9F10-CC5611109619}.AppStore|Any CPU.Build.0 = Release|Any CPU
+		{5624B7B5-B5A7-41D8-9F10-CC5611109619}.AppStore|x86.ActiveCfg = Release Mono|Any CPU
+		{5624B7B5-B5A7-41D8-9F10-CC5611109619}.AppStore|x86.Build.0 = Release Mono|Any CPU
+		{5624B7B5-B5A7-41D8-9F10-CC5611109619}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{5624B7B5-B5A7-41D8-9F10-CC5611109619}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{5624B7B5-B5A7-41D8-9F10-CC5611109619}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{5624B7B5-B5A7-41D8-9F10-CC5611109619}.Debug|x86.Build.0 = Debug|Any CPU
+		{5624B7B5-B5A7-41D8-9F10-CC5611109619}.Release Mono|Any CPU.ActiveCfg = Release Mono|Any CPU
+		{5624B7B5-B5A7-41D8-9F10-CC5611109619}.Release Mono|Any CPU.Build.0 = Release Mono|Any CPU
+		{5624B7B5-B5A7-41D8-9F10-CC5611109619}.Release Mono|x86.ActiveCfg = Release Mono|Any CPU
+		{5624B7B5-B5A7-41D8-9F10-CC5611109619}.Release Mono|x86.Build.0 = Release Mono|Any CPU
+		{5624B7B5-B5A7-41D8-9F10-CC5611109619}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{5624B7B5-B5A7-41D8-9F10-CC5611109619}.Release|Any CPU.Build.0 = Release|Any CPU
+		{5624B7B5-B5A7-41D8-9F10-CC5611109619}.Release|x86.ActiveCfg = Release|Any CPU
+		{5624B7B5-B5A7-41D8-9F10-CC5611109619}.Release|x86.Build.0 = Release|Any CPU
+		{5624B7B5-B5A7-41D8-9F10-CC5611109619}.Signed|Any CPU.ActiveCfg = Release Mono|Any CPU
+		{5624B7B5-B5A7-41D8-9F10-CC5611109619}.Signed|Any CPU.Build.0 = Release Mono|Any CPU
+		{5624B7B5-B5A7-41D8-9F10-CC5611109619}.Signed|x86.ActiveCfg = Release Mono|Any CPU
+		{5624B7B5-B5A7-41D8-9F10-CC5611109619}.Signed|x86.Build.0 = Release Mono|Any CPU
+		{23499896-B135-4527-8574-C26E926EA99E}.AppStore|Any CPU.ActiveCfg = Release|Any CPU
+		{23499896-B135-4527-8574-C26E926EA99E}.AppStore|Any CPU.Build.0 = Release|Any CPU
+		{23499896-B135-4527-8574-C26E926EA99E}.AppStore|x86.ActiveCfg = Debug|Any CPU
+		{23499896-B135-4527-8574-C26E926EA99E}.AppStore|x86.Build.0 = Debug|Any CPU
+		{23499896-B135-4527-8574-C26E926EA99E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{23499896-B135-4527-8574-C26E926EA99E}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{23499896-B135-4527-8574-C26E926EA99E}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{23499896-B135-4527-8574-C26E926EA99E}.Debug|x86.Build.0 = Debug|Any CPU
+		{23499896-B135-4527-8574-C26E926EA99E}.Release Mono|Any CPU.ActiveCfg = Debug|Any CPU
+		{23499896-B135-4527-8574-C26E926EA99E}.Release Mono|Any CPU.Build.0 = Debug|Any CPU
+		{23499896-B135-4527-8574-C26E926EA99E}.Release Mono|x86.ActiveCfg = Debug|Any CPU
+		{23499896-B135-4527-8574-C26E926EA99E}.Release Mono|x86.Build.0 = Debug|Any CPU
+		{23499896-B135-4527-8574-C26E926EA99E}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{23499896-B135-4527-8574-C26E926EA99E}.Release|Any CPU.Build.0 = Release|Any CPU
+		{23499896-B135-4527-8574-C26E926EA99E}.Release|x86.ActiveCfg = Release|Any CPU
+		{23499896-B135-4527-8574-C26E926EA99E}.Release|x86.Build.0 = Release|Any CPU
+		{23499896-B135-4527-8574-C26E926EA99E}.Signed|Any CPU.ActiveCfg = Debug|Any CPU
+		{23499896-B135-4527-8574-C26E926EA99E}.Signed|Any CPU.Build.0 = Debug|Any CPU
+		{23499896-B135-4527-8574-C26E926EA99E}.Signed|x86.ActiveCfg = Debug|Any CPU
+		{23499896-B135-4527-8574-C26E926EA99E}.Signed|x86.Build.0 = Debug|Any CPU
+		{4A4402D4-E910-443B-B8FC-2C18286A2CA0}.AppStore|Any CPU.ActiveCfg = Release|Any CPU
+		{4A4402D4-E910-443B-B8FC-2C18286A2CA0}.AppStore|Any CPU.Build.0 = Release|Any CPU
+		{4A4402D4-E910-443B-B8FC-2C18286A2CA0}.AppStore|x86.ActiveCfg = Release Mono|Any CPU
+		{4A4402D4-E910-443B-B8FC-2C18286A2CA0}.AppStore|x86.Build.0 = Release Mono|Any CPU
+		{4A4402D4-E910-443B-B8FC-2C18286A2CA0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{4A4402D4-E910-443B-B8FC-2C18286A2CA0}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{4A4402D4-E910-443B-B8FC-2C18286A2CA0}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{4A4402D4-E910-443B-B8FC-2C18286A2CA0}.Debug|x86.Build.0 = Debug|Any CPU
+		{4A4402D4-E910-443B-B8FC-2C18286A2CA0}.Release Mono|Any CPU.ActiveCfg = Release Mono|Any CPU
+		{4A4402D4-E910-443B-B8FC-2C18286A2CA0}.Release Mono|Any CPU.Build.0 = Release Mono|Any CPU
+		{4A4402D4-E910-443B-B8FC-2C18286A2CA0}.Release Mono|x86.ActiveCfg = Release Mono|Any CPU
+		{4A4402D4-E910-443B-B8FC-2C18286A2CA0}.Release Mono|x86.Build.0 = Release Mono|Any CPU
+		{4A4402D4-E910-443B-B8FC-2C18286A2CA0}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{4A4402D4-E910-443B-B8FC-2C18286A2CA0}.Release|Any CPU.Build.0 = Release|Any CPU
+		{4A4402D4-E910-443B-B8FC-2C18286A2CA0}.Release|x86.ActiveCfg = Release|Any CPU
+		{4A4402D4-E910-443B-B8FC-2C18286A2CA0}.Release|x86.Build.0 = Release|Any CPU
+		{4A4402D4-E910-443B-B8FC-2C18286A2CA0}.Signed|Any CPU.ActiveCfg = Release Mono|Any CPU
+		{4A4402D4-E910-443B-B8FC-2C18286A2CA0}.Signed|Any CPU.Build.0 = Release Mono|Any CPU
+		{4A4402D4-E910-443B-B8FC-2C18286A2CA0}.Signed|x86.ActiveCfg = Release Mono|Any CPU
+		{4A4402D4-E910-443B-B8FC-2C18286A2CA0}.Signed|x86.Build.0 = Release Mono|Any CPU
+		{08FFF49B-F175-4807-A2B5-73B0EBD9F716}.AppStore|Any CPU.ActiveCfg = Release|Any CPU
+		{08FFF49B-F175-4807-A2B5-73B0EBD9F716}.AppStore|Any CPU.Build.0 = Release|Any CPU
+		{08FFF49B-F175-4807-A2B5-73B0EBD9F716}.AppStore|x86.ActiveCfg = Debug|Any CPU
+		{08FFF49B-F175-4807-A2B5-73B0EBD9F716}.AppStore|x86.Build.0 = Debug|Any CPU
+		{08FFF49B-F175-4807-A2B5-73B0EBD9F716}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{08FFF49B-F175-4807-A2B5-73B0EBD9F716}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{08FFF49B-F175-4807-A2B5-73B0EBD9F716}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{08FFF49B-F175-4807-A2B5-73B0EBD9F716}.Debug|x86.Build.0 = Debug|Any CPU
+		{08FFF49B-F175-4807-A2B5-73B0EBD9F716}.Release Mono|Any CPU.ActiveCfg = Debug|Any CPU
+		{08FFF49B-F175-4807-A2B5-73B0EBD9F716}.Release Mono|Any CPU.Build.0 = Debug|Any CPU
+		{08FFF49B-F175-4807-A2B5-73B0EBD9F716}.Release Mono|x86.ActiveCfg = Debug|Any CPU
+		{08FFF49B-F175-4807-A2B5-73B0EBD9F716}.Release Mono|x86.Build.0 = Debug|Any CPU
+		{08FFF49B-F175-4807-A2B5-73B0EBD9F716}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{08FFF49B-F175-4807-A2B5-73B0EBD9F716}.Release|Any CPU.Build.0 = Release|Any CPU
+		{08FFF49B-F175-4807-A2B5-73B0EBD9F716}.Release|x86.ActiveCfg = Release|Any CPU
+		{08FFF49B-F175-4807-A2B5-73B0EBD9F716}.Release|x86.Build.0 = Release|Any CPU
+		{08FFF49B-F175-4807-A2B5-73B0EBD9F716}.Signed|Any CPU.ActiveCfg = Debug|Any CPU
+		{08FFF49B-F175-4807-A2B5-73B0EBD9F716}.Signed|Any CPU.Build.0 = Debug|Any CPU
+		{08FFF49B-F175-4807-A2B5-73B0EBD9F716}.Signed|x86.ActiveCfg = Debug|Any CPU
+		{08FFF49B-F175-4807-A2B5-73B0EBD9F716}.Signed|x86.Build.0 = Debug|Any CPU
+		{88AE38DF-19D7-406F-A6A9-09527719A21E}.AppStore|Any CPU.ActiveCfg = Release|Any CPU
+		{88AE38DF-19D7-406F-A6A9-09527719A21E}.AppStore|Any CPU.Build.0 = Release|Any CPU
+		{88AE38DF-19D7-406F-A6A9-09527719A21E}.AppStore|x86.ActiveCfg = Release|Any CPU
+		{88AE38DF-19D7-406F-A6A9-09527719A21E}.AppStore|x86.Build.0 = Release|Any CPU
+		{88AE38DF-19D7-406F-A6A9-09527719A21E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{88AE38DF-19D7-406F-A6A9-09527719A21E}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{88AE38DF-19D7-406F-A6A9-09527719A21E}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{88AE38DF-19D7-406F-A6A9-09527719A21E}.Debug|x86.Build.0 = Debug|Any CPU
+		{88AE38DF-19D7-406F-A6A9-09527719A21E}.Release Mono|Any CPU.ActiveCfg = Release|Any CPU
+		{88AE38DF-19D7-406F-A6A9-09527719A21E}.Release Mono|Any CPU.Build.0 = Release|Any CPU
+		{88AE38DF-19D7-406F-A6A9-09527719A21E}.Release Mono|x86.ActiveCfg = Release|Any CPU
+		{88AE38DF-19D7-406F-A6A9-09527719A21E}.Release Mono|x86.Build.0 = Release|Any CPU
+		{88AE38DF-19D7-406F-A6A9-09527719A21E}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{88AE38DF-19D7-406F-A6A9-09527719A21E}.Release|Any CPU.Build.0 = Release|Any CPU
+		{88AE38DF-19D7-406F-A6A9-09527719A21E}.Release|x86.ActiveCfg = Release|Any CPU
+		{88AE38DF-19D7-406F-A6A9-09527719A21E}.Release|x86.Build.0 = Release|Any CPU
+		{88AE38DF-19D7-406F-A6A9-09527719A21E}.Signed|Any CPU.ActiveCfg = Release|Any CPU
+		{88AE38DF-19D7-406F-A6A9-09527719A21E}.Signed|Any CPU.Build.0 = Release|Any CPU
+		{88AE38DF-19D7-406F-A6A9-09527719A21E}.Signed|x86.ActiveCfg = Release|Any CPU
+		{88AE38DF-19D7-406F-A6A9-09527719A21E}.Signed|x86.Build.0 = Release|Any CPU
+		{713F42B5-878E-499D-A878-E4C652B1D5E8}.AppStore|Any CPU.ActiveCfg = Release|Any CPU
+		{713F42B5-878E-499D-A878-E4C652B1D5E8}.AppStore|Any CPU.Build.0 = Release|Any CPU
+		{713F42B5-878E-499D-A878-E4C652B1D5E8}.AppStore|x86.ActiveCfg = Release|Any CPU
+		{713F42B5-878E-499D-A878-E4C652B1D5E8}.AppStore|x86.Build.0 = Release|Any CPU
+		{713F42B5-878E-499D-A878-E4C652B1D5E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{713F42B5-878E-499D-A878-E4C652B1D5E8}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{713F42B5-878E-499D-A878-E4C652B1D5E8}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{713F42B5-878E-499D-A878-E4C652B1D5E8}.Debug|x86.Build.0 = Debug|Any CPU
+		{713F42B5-878E-499D-A878-E4C652B1D5E8}.Release Mono|Any CPU.ActiveCfg = Release|Any CPU
+		{713F42B5-878E-499D-A878-E4C652B1D5E8}.Release Mono|Any CPU.Build.0 = Release|Any CPU
+		{713F42B5-878E-499D-A878-E4C652B1D5E8}.Release Mono|x86.ActiveCfg = Release|Any CPU
+		{713F42B5-878E-499D-A878-E4C652B1D5E8}.Release Mono|x86.Build.0 = Release|Any CPU
+		{713F42B5-878E-499D-A878-E4C652B1D5E8}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{713F42B5-878E-499D-A878-E4C652B1D5E8}.Release|Any CPU.Build.0 = Release|Any CPU
+		{713F42B5-878E-499D-A878-E4C652B1D5E8}.Release|x86.ActiveCfg = Release|Any CPU
+		{713F42B5-878E-499D-A878-E4C652B1D5E8}.Release|x86.Build.0 = Release|Any CPU
+		{713F42B5-878E-499D-A878-E4C652B1D5E8}.Signed|Any CPU.ActiveCfg = Release|Any CPU
+		{713F42B5-878E-499D-A878-E4C652B1D5E8}.Signed|Any CPU.Build.0 = Release|Any CPU
+		{713F42B5-878E-499D-A878-E4C652B1D5E8}.Signed|x86.ActiveCfg = Release|Any CPU
+		{713F42B5-878E-499D-A878-E4C652B1D5E8}.Signed|x86.Build.0 = Release|Any CPU
+		{805844AB-E92F-45E6-9D99-4F6D48D129A5}.AppStore|Any CPU.ActiveCfg = Release|Any CPU
+		{805844AB-E92F-45E6-9D99-4F6D48D129A5}.AppStore|Any CPU.Build.0 = Release|Any CPU
+		{805844AB-E92F-45E6-9D99-4F6D48D129A5}.AppStore|x86.ActiveCfg = Release|Any CPU
+		{805844AB-E92F-45E6-9D99-4F6D48D129A5}.AppStore|x86.Build.0 = Release|Any CPU
+		{805844AB-E92F-45E6-9D99-4F6D48D129A5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{805844AB-E92F-45E6-9D99-4F6D48D129A5}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{805844AB-E92F-45E6-9D99-4F6D48D129A5}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{805844AB-E92F-45E6-9D99-4F6D48D129A5}.Debug|x86.Build.0 = Debug|Any CPU
+		{805844AB-E92F-45E6-9D99-4F6D48D129A5}.Release Mono|Any CPU.ActiveCfg = Release|Any CPU
+		{805844AB-E92F-45E6-9D99-4F6D48D129A5}.Release Mono|Any CPU.Build.0 = Release|Any CPU
+		{805844AB-E92F-45E6-9D99-4F6D48D129A5}.Release Mono|x86.ActiveCfg = Release|Any CPU
+		{805844AB-E92F-45E6-9D99-4F6D48D129A5}.Release Mono|x86.Build.0 = Release|Any CPU
+		{805844AB-E92F-45E6-9D99-4F6D48D129A5}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{805844AB-E92F-45E6-9D99-4F6D48D129A5}.Release|Any CPU.Build.0 = Release|Any CPU
+		{805844AB-E92F-45E6-9D99-4F6D48D129A5}.Release|x86.ActiveCfg = Release|Any CPU
+		{805844AB-E92F-45E6-9D99-4F6D48D129A5}.Release|x86.Build.0 = Release|Any CPU
+		{805844AB-E92F-45E6-9D99-4F6D48D129A5}.Signed|Any CPU.ActiveCfg = Release|Any CPU
+		{805844AB-E92F-45E6-9D99-4F6D48D129A5}.Signed|Any CPU.Build.0 = Release|Any CPU
+		{805844AB-E92F-45E6-9D99-4F6D48D129A5}.Signed|x86.ActiveCfg = Release|Any CPU
+		{805844AB-E92F-45E6-9D99-4F6D48D129A5}.Signed|x86.Build.0 = Release|Any CPU
+		{6CFEE013-6E7C-432B-AC37-CABF0880C69A}.AppStore|Any CPU.ActiveCfg = Release|Any CPU
+		{6CFEE013-6E7C-432B-AC37-CABF0880C69A}.AppStore|Any CPU.Build.0 = Release|Any CPU
+		{6CFEE013-6E7C-432B-AC37-CABF0880C69A}.AppStore|x86.ActiveCfg = Release|Any CPU
+		{6CFEE013-6E7C-432B-AC37-CABF0880C69A}.AppStore|x86.Build.0 = Release|Any CPU
+		{6CFEE013-6E7C-432B-AC37-CABF0880C69A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{6CFEE013-6E7C-432B-AC37-CABF0880C69A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{6CFEE013-6E7C-432B-AC37-CABF0880C69A}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{6CFEE013-6E7C-432B-AC37-CABF0880C69A}.Debug|x86.Build.0 = Debug|Any CPU
+		{6CFEE013-6E7C-432B-AC37-CABF0880C69A}.Release Mono|Any CPU.ActiveCfg = Release|Any CPU
+		{6CFEE013-6E7C-432B-AC37-CABF0880C69A}.Release Mono|Any CPU.Build.0 = Release|Any CPU
+		{6CFEE013-6E7C-432B-AC37-CABF0880C69A}.Release Mono|x86.ActiveCfg = Release|Any CPU
+		{6CFEE013-6E7C-432B-AC37-CABF0880C69A}.Release Mono|x86.Build.0 = Release|Any CPU
+		{6CFEE013-6E7C-432B-AC37-CABF0880C69A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{6CFEE013-6E7C-432B-AC37-CABF0880C69A}.Release|Any CPU.Build.0 = Release|Any CPU
+		{6CFEE013-6E7C-432B-AC37-CABF0880C69A}.Release|x86.ActiveCfg = Release|Any CPU
+		{6CFEE013-6E7C-432B-AC37-CABF0880C69A}.Release|x86.Build.0 = Release|Any CPU
+		{6CFEE013-6E7C-432B-AC37-CABF0880C69A}.Signed|Any CPU.ActiveCfg = Release|Any CPU
+		{6CFEE013-6E7C-432B-AC37-CABF0880C69A}.Signed|Any CPU.Build.0 = Release|Any CPU
+		{6CFEE013-6E7C-432B-AC37-CABF0880C69A}.Signed|x86.ActiveCfg = Release|Any CPU
+		{6CFEE013-6E7C-432B-AC37-CABF0880C69A}.Signed|x86.Build.0 = Release|Any CPU
+		{C97A239E-A96C-4D64-A844-CCF8CC30AECB}.AppStore|Any CPU.ActiveCfg = Release|Any CPU
+		{C97A239E-A96C-4D64-A844-CCF8CC30AECB}.AppStore|Any CPU.Build.0 = Release|Any CPU
+		{C97A239E-A96C-4D64-A844-CCF8CC30AECB}.AppStore|x86.ActiveCfg = Release|Any CPU
+		{C97A239E-A96C-4D64-A844-CCF8CC30AECB}.AppStore|x86.Build.0 = Release|Any CPU
+		{C97A239E-A96C-4D64-A844-CCF8CC30AECB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{C97A239E-A96C-4D64-A844-CCF8CC30AECB}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{C97A239E-A96C-4D64-A844-CCF8CC30AECB}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{C97A239E-A96C-4D64-A844-CCF8CC30AECB}.Debug|x86.Build.0 = Debug|Any CPU
+		{C97A239E-A96C-4D64-A844-CCF8CC30AECB}.Release Mono|Any CPU.ActiveCfg = Release|Any CPU
+		{C97A239E-A96C-4D64-A844-CCF8CC30AECB}.Release Mono|Any CPU.Build.0 = Release|Any CPU
+		{C97A239E-A96C-4D64-A844-CCF8CC30AECB}.Release Mono|x86.ActiveCfg = Release|Any CPU
+		{C97A239E-A96C-4D64-A844-CCF8CC30AECB}.Release Mono|x86.Build.0 = Release|Any CPU
+		{C97A239E-A96C-4D64-A844-CCF8CC30AECB}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{C97A239E-A96C-4D64-A844-CCF8CC30AECB}.Release|Any CPU.Build.0 = Release|Any CPU
+		{C97A239E-A96C-4D64-A844-CCF8CC30AECB}.Release|x86.ActiveCfg = Release|Any CPU
+		{C97A239E-A96C-4D64-A844-CCF8CC30AECB}.Release|x86.Build.0 = Release|Any CPU
+		{C97A239E-A96C-4D64-A844-CCF8CC30AECB}.Signed|Any CPU.ActiveCfg = Release|Any CPU
+		{C97A239E-A96C-4D64-A844-CCF8CC30AECB}.Signed|Any CPU.Build.0 = Release|Any CPU
+		{C97A239E-A96C-4D64-A844-CCF8CC30AECB}.Signed|x86.ActiveCfg = Release|Any CPU
+		{C97A239E-A96C-4D64-A844-CCF8CC30AECB}.Signed|x86.Build.0 = Release|Any CPU
+		{89AB4548-770D-41FD-A891-8DAFF44F452C}.AppStore|Any CPU.ActiveCfg = Release|Any CPU
+		{89AB4548-770D-41FD-A891-8DAFF44F452C}.AppStore|Any CPU.Build.0 = Release|Any CPU
+		{89AB4548-770D-41FD-A891-8DAFF44F452C}.AppStore|x86.ActiveCfg = Release|Any CPU
+		{89AB4548-770D-41FD-A891-8DAFF44F452C}.AppStore|x86.Build.0 = Release|Any CPU
+		{89AB4548-770D-41FD-A891-8DAFF44F452C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{89AB4548-770D-41FD-A891-8DAFF44F452C}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{89AB4548-770D-41FD-A891-8DAFF44F452C}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{89AB4548-770D-41FD-A891-8DAFF44F452C}.Debug|x86.Build.0 = Debug|Any CPU
+		{89AB4548-770D-41FD-A891-8DAFF44F452C}.Release Mono|Any CPU.ActiveCfg = Release|Any CPU
+		{89AB4548-770D-41FD-A891-8DAFF44F452C}.Release Mono|Any CPU.Build.0 = Release|Any CPU
+		{89AB4548-770D-41FD-A891-8DAFF44F452C}.Release Mono|x86.ActiveCfg = Release|Any CPU
+		{89AB4548-770D-41FD-A891-8DAFF44F452C}.Release Mono|x86.Build.0 = Release|Any CPU
+		{89AB4548-770D-41FD-A891-8DAFF44F452C}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{89AB4548-770D-41FD-A891-8DAFF44F452C}.Release|Any CPU.Build.0 = Release|Any CPU
+		{89AB4548-770D-41FD-A891-8DAFF44F452C}.Release|x86.ActiveCfg = Release|Any CPU
+		{89AB4548-770D-41FD-A891-8DAFF44F452C}.Release|x86.Build.0 = Release|Any CPU
+		{89AB4548-770D-41FD-A891-8DAFF44F452C}.Signed|Any CPU.ActiveCfg = Release|Any CPU
+		{89AB4548-770D-41FD-A891-8DAFF44F452C}.Signed|Any CPU.Build.0 = Release|Any CPU
+		{89AB4548-770D-41FD-A891-8DAFF44F452C}.Signed|x86.ActiveCfg = Release|Any CPU
+		{89AB4548-770D-41FD-A891-8DAFF44F452C}.Signed|x86.Build.0 = Release|Any CPU
+		{E383961B-9356-4D5D-8233-9A1079D03055}.AppStore|Any CPU.ActiveCfg = Release|Any CPU
+		{E383961B-9356-4D5D-8233-9A1079D03055}.AppStore|Any CPU.Build.0 = Release|Any CPU
+		{E383961B-9356-4D5D-8233-9A1079D03055}.AppStore|x86.ActiveCfg = Release|Any CPU
+		{E383961B-9356-4D5D-8233-9A1079D03055}.AppStore|x86.Build.0 = Release|Any CPU
+		{E383961B-9356-4D5D-8233-9A1079D03055}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{E383961B-9356-4D5D-8233-9A1079D03055}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{E383961B-9356-4D5D-8233-9A1079D03055}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{E383961B-9356-4D5D-8233-9A1079D03055}.Debug|x86.Build.0 = Debug|Any CPU
+		{E383961B-9356-4D5D-8233-9A1079D03055}.Release Mono|Any CPU.ActiveCfg = Release|Any CPU
+		{E383961B-9356-4D5D-8233-9A1079D03055}.Release Mono|Any CPU.Build.0 = Release|Any CPU
+		{E383961B-9356-4D5D-8233-9A1079D03055}.Release Mono|x86.ActiveCfg = Release|Any CPU
+		{E383961B-9356-4D5D-8233-9A1079D03055}.Release Mono|x86.Build.0 = Release|Any CPU
+		{E383961B-9356-4D5D-8233-9A1079D03055}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{E383961B-9356-4D5D-8233-9A1079D03055}.Release|Any CPU.Build.0 = Release|Any CPU
+		{E383961B-9356-4D5D-8233-9A1079D03055}.Release|x86.ActiveCfg = Release|Any CPU
+		{E383961B-9356-4D5D-8233-9A1079D03055}.Release|x86.Build.0 = Release|Any CPU
+		{E383961B-9356-4D5D-8233-9A1079D03055}.Signed|Any CPU.ActiveCfg = Release|Any CPU
+		{E383961B-9356-4D5D-8233-9A1079D03055}.Signed|Any CPU.Build.0 = Release|Any CPU
+		{E383961B-9356-4D5D-8233-9A1079D03055}.Signed|x86.ActiveCfg = Release|Any CPU
+		{E383961B-9356-4D5D-8233-9A1079D03055}.Signed|x86.Build.0 = Release|Any CPU
+		{21002819-C39A-4D3E-BE83-2A276A77FB1F}.AppStore|Any CPU.ActiveCfg = Release|Any CPU
+		{21002819-C39A-4D3E-BE83-2A276A77FB1F}.AppStore|Any CPU.Build.0 = Release|Any CPU
+		{21002819-C39A-4D3E-BE83-2A276A77FB1F}.AppStore|x86.ActiveCfg = Release|Any CPU
+		{21002819-C39A-4D3E-BE83-2A276A77FB1F}.AppStore|x86.Build.0 = Release|Any CPU
+		{21002819-C39A-4D3E-BE83-2A276A77FB1F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{21002819-C39A-4D3E-BE83-2A276A77FB1F}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{21002819-C39A-4D3E-BE83-2A276A77FB1F}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{21002819-C39A-4D3E-BE83-2A276A77FB1F}.Debug|x86.Build.0 = Debug|Any CPU
+		{21002819-C39A-4D3E-BE83-2A276A77FB1F}.Release Mono|Any CPU.ActiveCfg = Release|Any CPU
+		{21002819-C39A-4D3E-BE83-2A276A77FB1F}.Release Mono|Any CPU.Build.0 = Release|Any CPU
+		{21002819-C39A-4D3E-BE83-2A276A77FB1F}.Release Mono|x86.ActiveCfg = Release|Any CPU
+		{21002819-C39A-4D3E-BE83-2A276A77FB1F}.Release Mono|x86.Build.0 = Release|Any CPU
+		{21002819-C39A-4D3E-BE83-2A276A77FB1F}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{21002819-C39A-4D3E-BE83-2A276A77FB1F}.Release|Any CPU.Build.0 = Release|Any CPU
+		{21002819-C39A-4D3E-BE83-2A276A77FB1F}.Release|x86.ActiveCfg = Release|Any CPU
+		{21002819-C39A-4D3E-BE83-2A276A77FB1F}.Release|x86.Build.0 = Release|Any CPU
+		{21002819-C39A-4D3E-BE83-2A276A77FB1F}.Signed|Any CPU.ActiveCfg = Release|Any CPU
+		{21002819-C39A-4D3E-BE83-2A276A77FB1F}.Signed|Any CPU.Build.0 = Release|Any CPU
+		{21002819-C39A-4D3E-BE83-2A276A77FB1F}.Signed|x86.ActiveCfg = Release|Any CPU
+		{21002819-C39A-4D3E-BE83-2A276A77FB1F}.Signed|x86.Build.0 = Release|Any CPU
+		{4F26D5D8-A7B0-42B3-BA42-7CB7D245934E}.AppStore|Any CPU.ActiveCfg = Release|Any CPU
+		{4F26D5D8-A7B0-42B3-BA42-7CB7D245934E}.AppStore|Any CPU.Build.0 = Release|Any CPU
+		{4F26D5D8-A7B0-42B3-BA42-7CB7D245934E}.AppStore|x86.ActiveCfg = Release|Any CPU
+		{4F26D5D8-A7B0-42B3-BA42-7CB7D245934E}.AppStore|x86.Build.0 = Release|Any CPU
+		{4F26D5D8-A7B0-42B3-BA42-7CB7D245934E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{4F26D5D8-A7B0-42B3-BA42-7CB7D245934E}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{4F26D5D8-A7B0-42B3-BA42-7CB7D245934E}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{4F26D5D8-A7B0-42B3-BA42-7CB7D245934E}.Debug|x86.Build.0 = Debug|Any CPU
+		{4F26D5D8-A7B0-42B3-BA42-7CB7D245934E}.Release Mono|Any CPU.ActiveCfg = Release|Any CPU
+		{4F26D5D8-A7B0-42B3-BA42-7CB7D245934E}.Release Mono|Any CPU.Build.0 = Release|Any CPU
+		{4F26D5D8-A7B0-42B3-BA42-7CB7D245934E}.Release Mono|x86.ActiveCfg = Release|Any CPU
+		{4F26D5D8-A7B0-42B3-BA42-7CB7D245934E}.Release Mono|x86.Build.0 = Release|Any CPU
+		{4F26D5D8-A7B0-42B3-BA42-7CB7D245934E}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{4F26D5D8-A7B0-42B3-BA42-7CB7D245934E}.Release|Any CPU.Build.0 = Release|Any CPU
+		{4F26D5D8-A7B0-42B3-BA42-7CB7D245934E}.Release|x86.ActiveCfg = Release|Any CPU
+		{4F26D5D8-A7B0-42B3-BA42-7CB7D245934E}.Release|x86.Build.0 = Release|Any CPU
+		{4F26D5D8-A7B0-42B3-BA42-7CB7D245934E}.Signed|Any CPU.ActiveCfg = Release|Any CPU
+		{4F26D5D8-A7B0-42B3-BA42-7CB7D245934E}.Signed|Any CPU.Build.0 = Release|Any CPU
+		{4F26D5D8-A7B0-42B3-BA42-7CB7D245934E}.Signed|x86.ActiveCfg = Release|Any CPU
+		{4F26D5D8-A7B0-42B3-BA42-7CB7D245934E}.Signed|x86.Build.0 = Release|Any CPU
+		{680A1709-25EB-4D52-A87F-EE03FFD94BAA}.AppStore|Any CPU.ActiveCfg = Signed|Any CPU
+		{680A1709-25EB-4D52-A87F-EE03FFD94BAA}.AppStore|Any CPU.Build.0 = Signed|Any CPU
+		{680A1709-25EB-4D52-A87F-EE03FFD94BAA}.AppStore|x86.ActiveCfg = Signed|Any CPU
+		{680A1709-25EB-4D52-A87F-EE03FFD94BAA}.AppStore|x86.Build.0 = Signed|Any CPU
+		{680A1709-25EB-4D52-A87F-EE03FFD94BAA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{680A1709-25EB-4D52-A87F-EE03FFD94BAA}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{680A1709-25EB-4D52-A87F-EE03FFD94BAA}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{680A1709-25EB-4D52-A87F-EE03FFD94BAA}.Debug|x86.Build.0 = Debug|Any CPU
+		{680A1709-25EB-4D52-A87F-EE03FFD94BAA}.Release Mono|Any CPU.ActiveCfg = Release|Any CPU
+		{680A1709-25EB-4D52-A87F-EE03FFD94BAA}.Release Mono|Any CPU.Build.0 = Release|Any CPU
+		{680A1709-25EB-4D52-A87F-EE03FFD94BAA}.Release Mono|x86.ActiveCfg = Release|Any CPU
+		{680A1709-25EB-4D52-A87F-EE03FFD94BAA}.Release Mono|x86.Build.0 = Release|Any CPU
+		{680A1709-25EB-4D52-A87F-EE03FFD94BAA}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{680A1709-25EB-4D52-A87F-EE03FFD94BAA}.Release|Any CPU.Build.0 = Release|Any CPU
+		{680A1709-25EB-4D52-A87F-EE03FFD94BAA}.Release|x86.ActiveCfg = Release|Any CPU
+		{680A1709-25EB-4D52-A87F-EE03FFD94BAA}.Release|x86.Build.0 = Release|Any CPU
+		{680A1709-25EB-4D52-A87F-EE03FFD94BAA}.Signed|Any CPU.ActiveCfg = Signed|Any CPU
+		{680A1709-25EB-4D52-A87F-EE03FFD94BAA}.Signed|Any CPU.Build.0 = Signed|Any CPU
+		{680A1709-25EB-4D52-A87F-EE03FFD94BAA}.Signed|x86.ActiveCfg = Signed|Any CPU
+		{680A1709-25EB-4D52-A87F-EE03FFD94BAA}.Signed|x86.Build.0 = Signed|Any CPU
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
 	EndGlobalSection
 	EndGlobalSection
 	GlobalSection(MonoDevelopProperties) = preSolution
 	GlobalSection(MonoDevelopProperties) = preSolution
 		Policies = $0
 		Policies = $0

+ 0 - 2
MediaBrowser.Server.Mac/AppController.cs

@@ -1,8 +1,6 @@
 using MediaBrowser.Controller;
 using MediaBrowser.Controller;
 using MediaBrowser.Controller.Configuration;
 using MediaBrowser.Controller.Configuration;
-using MediaBrowser.Controller.Localization;
 using MediaBrowser.Model.Logging;
 using MediaBrowser.Model.Logging;
-using MediaBrowser.Server.Startup.Common.Browser;
 using System;
 using System;
 using MonoMac.Foundation;
 using MonoMac.Foundation;
 using MonoMac.AppKit;
 using MonoMac.AppKit;

+ 60 - 178
MediaBrowser.Server.Mac/Emby.Server.Mac.csproj

@@ -90,21 +90,26 @@
     <Reference Include="Mono.Posix">
     <Reference Include="Mono.Posix">
       <HintPath>..\packages\Mono.Posix.4.0.0.0\lib\net40\Mono.Posix.dll</HintPath>
       <HintPath>..\packages\Mono.Posix.4.0.0.0\lib\net40\Mono.Posix.dll</HintPath>
     </Reference>
     </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">
     <Reference Include="System.Data.SQLite">
       <HintPath>..\ThirdParty\System.Data.SQLite.ManagedOnly\1.0.94.0\System.Data.SQLite.dll</HintPath>
       <HintPath>..\ThirdParty\System.Data.SQLite.ManagedOnly\1.0.94.0\System.Data.SQLite.dll</HintPath>
     </Reference>
     </Reference>
     <Reference Include="System.Data" />
     <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>
   <ItemGroup>
   <ItemGroup>
     <Folder Include="Resources\" />
     <Folder Include="Resources\" />
     <Folder Include="Native\" />
     <Folder Include="Native\" />
-    <Folder Include="Security\" />
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
     <Compile Include="AppDelegate.cs" />
     <Compile Include="AppDelegate.cs" />
@@ -115,69 +120,18 @@
     <Compile Include="AppController.designer.cs">
     <Compile Include="AppController.designer.cs">
       <DependentUpon>AppController.cs</DependentUpon>
       <DependentUpon>AppController.cs</DependentUpon>
     </Compile>
     </Compile>
-    <Compile Include="Native\NativeApp.cs" />
-    <Compile Include="Native\BaseMonoApp.cs" />
-    <Compile Include="Native\NetworkManager.cs" />
     <Compile Include="..\SharedVersion.cs">
     <Compile Include="..\SharedVersion.cs">
       <Link>SharedVersion.cs</Link>
       <Link>SharedVersion.cs</Link>
     </Compile>
     </Compile>
     <Compile Include="Main.cs" />
     <Compile Include="Main.cs" />
     <Compile Include="MenuBarIcon.cs" />
     <Compile Include="MenuBarIcon.cs" />
-    <Compile Include="..\MediaBrowser.Server.Mono\Networking\CertificateGenerator.cs">
-      <Link>Native\CertificateGenerator.cs</Link>
-    </Compile>
     <Compile Include="Native\DbConnector.cs" />
     <Compile Include="Native\DbConnector.cs" />
-    <Compile Include="..\MediaBrowser.Server.Implementations\Persistence\SqliteExtensions.cs">
+    <Compile Include="..\MediaBrowser.Server.Startup.Common\Persistence\SqliteExtensions.cs">
       <Link>Native\SqliteExtensions.cs</Link>
       <Link>Native\SqliteExtensions.cs</Link>
     </Compile>
     </Compile>
-    <Compile Include="..\MediaBrowser.Server.Mono\Security\ASN1.cs">
-      <Link>Security\ASN1.cs</Link>
-    </Compile>
-    <Compile Include="..\MediaBrowser.Server.Mono\Security\ASN1Convert.cs">
-      <Link>Security\ASN1Convert.cs</Link>
-    </Compile>
-    <Compile Include="..\MediaBrowser.Server.Mono\Security\BitConverterLE.cs">
-      <Link>Security\BitConverterLE.cs</Link>
-    </Compile>
-    <Compile Include="..\MediaBrowser.Server.Mono\Security\CryptoConvert.cs">
-      <Link>Security\CryptoConvert.cs</Link>
-    </Compile>
-    <Compile Include="..\MediaBrowser.Server.Mono\Security\PKCS1.cs">
-      <Link>Security\PKCS1.cs</Link>
-    </Compile>
-    <Compile Include="..\MediaBrowser.Server.Mono\Security\PKCS12.cs">
-      <Link>Security\PKCS12.cs</Link>
-    </Compile>
-    <Compile Include="..\MediaBrowser.Server.Mono\Security\PKCS7.cs">
-      <Link>Security\PKCS7.cs</Link>
-    </Compile>
-    <Compile Include="..\MediaBrowser.Server.Mono\Security\PKCS8.cs">
-      <Link>Security\PKCS8.cs</Link>
-    </Compile>
-    <Compile Include="..\MediaBrowser.Server.Mono\Security\X501Name.cs">
-      <Link>Security\X501Name.cs</Link>
-    </Compile>
-    <Compile Include="..\MediaBrowser.Server.Mono\Security\X509Builder.cs">
-      <Link>Security\X509Builder.cs</Link>
-    </Compile>
-    <Compile Include="..\MediaBrowser.Server.Mono\Security\X509Certificate.cs">
-      <Link>Security\X509Certificate.cs</Link>
-    </Compile>
-    <Compile Include="..\MediaBrowser.Server.Mono\Security\X509CertificateBuilder.cs">
-      <Link>Security\X509CertificateBuilder.cs</Link>
-    </Compile>
-    <Compile Include="..\MediaBrowser.Server.Mono\Security\X509CertificateCollection.cs">
-      <Link>Security\X509CertificateCollection.cs</Link>
-    </Compile>
-    <Compile Include="..\MediaBrowser.Server.Mono\Security\X509Extension.cs">
-      <Link>Security\X509Extension.cs</Link>
-    </Compile>
-    <Compile Include="..\MediaBrowser.Server.Mono\Security\X509Extensions.cs">
-      <Link>Security\X509Extensions.cs</Link>
-    </Compile>
-    <Compile Include="..\MediaBrowser.Server.Mono\Security\X520Attributes.cs">
-      <Link>Security\X520Attributes.cs</Link>
-    </Compile>
+    <Compile Include="MacAppHost.cs" />
+    <Compile Include="Native\MonoFileSystem.cs" />
+    <Compile Include="Native\PowerManagement.cs" />
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
     <InterfaceDefinition Include="MainMenu.xib" />
     <InterfaceDefinition Include="MainMenu.xib" />
@@ -207,18 +161,10 @@
       <Project>{9142EEFA-7570-41E1-BFCC-468BB571AF2F}</Project>
       <Project>{9142EEFA-7570-41E1-BFCC-468BB571AF2F}</Project>
       <Name>MediaBrowser.Common</Name>
       <Name>MediaBrowser.Common</Name>
     </ProjectReference>
     </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">
     <ProjectReference Include="..\MediaBrowser.Server.Implementations\MediaBrowser.Server.Implementations.csproj">
       <Project>{2E781478-814D-4A48-9D80-BFF206441A65}</Project>
       <Project>{2E781478-814D-4A48-9D80-BFF206441A65}</Project>
       <Name>MediaBrowser.Server.Implementations</Name>
       <Name>MediaBrowser.Server.Implementations</Name>
     </ProjectReference>
     </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">
     <ProjectReference Include="..\MediaBrowser.LocalMetadata\MediaBrowser.LocalMetadata.csproj">
       <Project>{7EF9F3E0-697D-42F3-A08F-19DEB5F84392}</Project>
       <Project>{7EF9F3E0-697D-42F3-A08F-19DEB5F84392}</Project>
       <Name>MediaBrowser.LocalMetadata</Name>
       <Name>MediaBrowser.LocalMetadata</Name>
@@ -247,6 +193,50 @@
       <Project>{4FD51AC5-2C16-4308-A993-C3A84F3B4582}</Project>
       <Project>{4FD51AC5-2C16-4308-A993-C3A84F3B4582}</Project>
       <Name>MediaBrowser.Api</Name>
       <Name>MediaBrowser.Api</Name>
     </ProjectReference>
     </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>
   <ItemGroup>
   <ItemGroup>
     <Content Include="statusicon.png" />
     <Content Include="statusicon.png" />
@@ -264,114 +254,6 @@
   <ItemGroup>
   <ItemGroup>
     <BundleResource Include="Resources\appicon.icns" />
     <BundleResource Include="Resources\appicon.icns" />
     <BundleResource Include="Resources\MediaBrowser.Server.Mac\Images.xcassets\AppIcon.appiconset\Contents.json" />
     <BundleResource Include="Resources\MediaBrowser.Server.Mac\Images.xcassets\AppIcon.appiconset\Contents.json" />
-    <BundleResource Include="..\ThirdParty\ServiceStack\swagger-ui\index.html">
-      <Link>Resources\swagger-ui\index.html</Link>
-    </BundleResource>
-    <BundleResource Include="..\ThirdParty\ServiceStack\swagger-ui\o2c.html">
-      <Link>Resources\swagger-ui\o2c.html</Link>
-    </BundleResource>
-    <BundleResource Include="..\ThirdParty\ServiceStack\swagger-ui\patch.js">
-      <Link>Resources\swagger-ui\patch.js</Link>
-    </BundleResource>
-    <BundleResource Include="..\ThirdParty\ServiceStack\swagger-ui\swagger-ui.js">
-      <Link>Resources\swagger-ui\swagger-ui.js</Link>
-    </BundleResource>
-    <BundleResource Include="..\ThirdParty\ServiceStack\swagger-ui\swagger-ui.min.js">
-      <Link>Resources\swagger-ui\swagger-ui.min.js</Link>
-    </BundleResource>
-    <BundleResource Include="..\ThirdParty\ServiceStack\swagger-ui\css\reset.css">
-      <Link>Resources\swagger-ui\css\reset.css</Link>
-    </BundleResource>
-    <BundleResource Include="..\ThirdParty\ServiceStack\swagger-ui\css\screen.css">
-      <Link>Resources\swagger-ui\css\screen.css</Link>
-    </BundleResource>
-    <BundleResource Include="..\ThirdParty\ServiceStack\swagger-ui\css\typography.css">
-      <Link>Resources\swagger-ui\css\typography.css</Link>
-    </BundleResource>
-    <BundleResource Include="..\ThirdParty\ServiceStack\swagger-ui\fonts\droid-sans-v6-latin-700.eot">
-      <Link>Resources\swagger-ui\fonts\droid-sans-v6-latin-700.eot</Link>
-    </BundleResource>
-    <BundleResource Include="..\ThirdParty\ServiceStack\swagger-ui\fonts\droid-sans-v6-latin-700.svg">
-      <Link>Resources\swagger-ui\fonts\droid-sans-v6-latin-700.svg</Link>
-    </BundleResource>
-    <BundleResource Include="..\ThirdParty\ServiceStack\swagger-ui\fonts\droid-sans-v6-latin-700.ttf">
-      <Link>Resources\swagger-ui\fonts\droid-sans-v6-latin-700.ttf</Link>
-    </BundleResource>
-    <BundleResource Include="..\ThirdParty\ServiceStack\swagger-ui\fonts\droid-sans-v6-latin-700.woff">
-      <Link>Resources\swagger-ui\fonts\droid-sans-v6-latin-700.woff</Link>
-    </BundleResource>
-    <BundleResource Include="..\ThirdParty\ServiceStack\swagger-ui\fonts\droid-sans-v6-latin-700.woff2">
-      <Link>Resources\swagger-ui\fonts\droid-sans-v6-latin-700.woff2</Link>
-    </BundleResource>
-    <BundleResource Include="..\ThirdParty\ServiceStack\swagger-ui\fonts\droid-sans-v6-latin-regular.eot">
-      <Link>Resources\swagger-ui\fonts\droid-sans-v6-latin-regular.eot</Link>
-    </BundleResource>
-    <BundleResource Include="..\ThirdParty\ServiceStack\swagger-ui\fonts\droid-sans-v6-latin-regular.svg">
-      <Link>Resources\swagger-ui\fonts\droid-sans-v6-latin-regular.svg</Link>
-    </BundleResource>
-    <BundleResource Include="..\ThirdParty\ServiceStack\swagger-ui\fonts\droid-sans-v6-latin-regular.ttf">
-      <Link>Resources\swagger-ui\fonts\droid-sans-v6-latin-regular.ttf</Link>
-    </BundleResource>
-    <BundleResource Include="..\ThirdParty\ServiceStack\swagger-ui\fonts\droid-sans-v6-latin-regular.woff">
-      <Link>Resources\swagger-ui\fonts\droid-sans-v6-latin-regular.woff</Link>
-    </BundleResource>
-    <BundleResource Include="..\ThirdParty\ServiceStack\swagger-ui\fonts\droid-sans-v6-latin-regular.woff2">
-      <Link>Resources\swagger-ui\fonts\droid-sans-v6-latin-regular.woff2</Link>
-    </BundleResource>
-    <BundleResource Include="..\ThirdParty\ServiceStack\swagger-ui\images\explorer_icons.png">
-      <Link>Resources\swagger-ui\images\explorer_icons.png</Link>
-    </BundleResource>
-    <BundleResource Include="..\ThirdParty\ServiceStack\swagger-ui\images\logo_small.png">
-      <Link>Resources\swagger-ui\images\logo_small.png</Link>
-    </BundleResource>
-    <BundleResource Include="..\ThirdParty\ServiceStack\swagger-ui\images\pet_store_api.png">
-      <Link>Resources\swagger-ui\images\pet_store_api.png</Link>
-    </BundleResource>
-    <BundleResource Include="..\ThirdParty\ServiceStack\swagger-ui\images\throbber.gif">
-      <Link>Resources\swagger-ui\images\throbber.gif</Link>
-    </BundleResource>
-    <BundleResource Include="..\ThirdParty\ServiceStack\swagger-ui\images\wordnik_api.png">
-      <Link>Resources\swagger-ui\images\wordnik_api.png</Link>
-    </BundleResource>
-    <BundleResource Include="..\ThirdParty\ServiceStack\swagger-ui\lib\backbone-min.js">
-      <Link>Resources\swagger-ui\lib\backbone-min.js</Link>
-    </BundleResource>
-    <BundleResource Include="..\ThirdParty\ServiceStack\swagger-ui\lib\handlebars-2.0.0.js">
-      <Link>Resources\swagger-ui\lib\handlebars-2.0.0.js</Link>
-    </BundleResource>
-    <BundleResource Include="..\ThirdParty\ServiceStack\swagger-ui\lib\highlight.7.3.pack.js">
-      <Link>Resources\swagger-ui\lib\highlight.7.3.pack.js</Link>
-    </BundleResource>
-    <BundleResource Include="..\ThirdParty\ServiceStack\swagger-ui\lib\jquery-1.8.0.min.js">
-      <Link>Resources\swagger-ui\lib\jquery-1.8.0.min.js</Link>
-    </BundleResource>
-    <BundleResource Include="..\ThirdParty\ServiceStack\swagger-ui\lib\jquery.ba-bbq.min.js">
-      <Link>Resources\swagger-ui\lib\jquery.ba-bbq.min.js</Link>
-    </BundleResource>
-    <BundleResource Include="..\ThirdParty\ServiceStack\swagger-ui\lib\jquery.slideto.min.js">
-      <Link>Resources\swagger-ui\lib\jquery.slideto.min.js</Link>
-    </BundleResource>
-    <BundleResource Include="..\ThirdParty\ServiceStack\swagger-ui\lib\jquery.wiggle.min.js">
-      <Link>Resources\swagger-ui\lib\jquery.wiggle.min.js</Link>
-    </BundleResource>
-    <BundleResource Include="..\ThirdParty\ServiceStack\swagger-ui\lib\marked.js">
-      <Link>Resources\swagger-ui\lib\marked.js</Link>
-    </BundleResource>
-    <BundleResource Include="..\ThirdParty\ServiceStack\swagger-ui\lib\shred.bundle.js">
-      <Link>Resources\swagger-ui\lib\shred.bundle.js</Link>
-    </BundleResource>
-    <BundleResource Include="..\ThirdParty\ServiceStack\swagger-ui\lib\swagger-client.js">
-      <Link>Resources\swagger-ui\lib\swagger-client.js</Link>
-    </BundleResource>
-    <BundleResource Include="..\ThirdParty\ServiceStack\swagger-ui\lib\swagger-oauth.js">
-      <Link>Resources\swagger-ui\lib\swagger-oauth.js</Link>
-    </BundleResource>
-    <BundleResource Include="..\ThirdParty\ServiceStack\swagger-ui\lib\underscore-min.js">
-      <Link>Resources\swagger-ui\lib\underscore-min.js</Link>
-    </BundleResource>
-    <BundleResource Include="..\ThirdParty\ServiceStack\swagger-ui\lib\shred\content.js">
-      <Link>Resources\swagger-ui\lib\shred\content.js</Link>
-    </BundleResource>
     <BundleResource Include="..\MediaBrowser.WebDashboard\dashboard-ui\about.html">
     <BundleResource Include="..\MediaBrowser.WebDashboard\dashboard-ui\about.html">
       <Link>Resources\dashboard-ui\about.html</Link>
       <Link>Resources\dashboard-ui\about.html</Link>
     </BundleResource>
     </BundleResource>

+ 154 - 0
MediaBrowser.Server.Mac/MacAppHost.cs

@@ -0,0 +1,154 @@
+using System;
+using System.Collections.Generic;
+using System.Reflection;
+using Emby.Server.Core;
+using Emby.Server.Core.Data;
+using Emby.Server.Core.FFMpeg;
+using MediaBrowser.Model.IO;
+using MediaBrowser.Model.Logging;
+using MediaBrowser.Model.System;
+using Emby.Server.Mac.Native;
+using System.Diagnostics;
+
+namespace MediaBrowser.Server.Mac
+{
+	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)
+        {
+        }
+
+        public override bool CanSelfRestart
+        {
+            get
+            {
+                return false;
+            }
+        }
+
+        public override bool CanSelfUpdate
+        {
+            get
+            {
+                return false;
+            }
+        }
+
+        protected override FFMpegInstallInfo GetFfmpegInstallInfo()
+        {
+            var info = new FFMpegInstallInfo();
+
+            info.ArchiveType = "7z";
+
+            switch (EnvironmentInfo.SystemArchitecture)
+            {
+                case Architecture.X64:
+                    info.Version = "20160124";
+                    break;
+                case Architecture.X86:
+                    info.Version = "20150110";
+                    break;
+            }
+
+            info.DownloadUrls = GetDownloadUrls();
+
+            return info;
+        }
+
+        private string[] GetDownloadUrls()
+        {
+            switch (EnvironmentInfo.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[] { };
+        }
+
+        protected override void RestartInternal()
+        {
+            MainClass.Restart();
+        }
+
+        protected override List<Assembly> GetAssembliesWithPartsInternal()
+        {
+            var list = new List<Assembly>();
+
+            list.Add(GetType().Assembly);
+
+            return list;
+        }
+
+        protected override void ShutdownInternal()
+        {
+            MainClass.Shutdown();
+        }
+
+        protected override void AuthorizeServer()
+        {
+            throw new NotImplementedException();
+        }
+
+        protected override IDbConnector GetDbConnector()
+        {
+            return new DbConnector(Logger);
+        }
+
+        protected override void ConfigureAutoRunInternal(bool autorun)
+        {
+            throw new NotImplementedException();
+        }
+
+        public override void LaunchUrl(string url)
+        {
+            var process = new Process
+            {
+                StartInfo = new ProcessStartInfo
+                {
+                    FileName = url
+                },
+
+                EnableRaisingEvents = true,
+            };
+
+            process.Exited += ProcessExited;
+
+            process.Start();
+        }
+
+        private static void ProcessExited(object sender, EventArgs e)
+        {
+            ((Process)sender).Dispose();
+        }
+
+        protected override void EnableLoopbackInternal(string appName)
+        {
+        }
+
+        public override bool SupportsRunningAsService
+        {
+            get
+            {
+                return false;
+            }
+        }
+
+        public override bool SupportsAutoRunAtStartup
+        {
+            get { return false; }
+        }
+
+        public override bool IsRunningAsService
+        {
+            get
+            {
+                return false;
+            }
+        }
+    }
+}

+ 141 - 41
MediaBrowser.Server.Mac/Main.cs

@@ -1,34 +1,39 @@
-using System;
+using MediaBrowser.Model.Logging;
+using MediaBrowser.Server.Startup.Common;
+using MediaBrowser.Server.Startup.Common.IO;
+using MediaBrowser.Server.Implementations;
+using System;
 using System.Diagnostics;
 using System.Diagnostics;
-using System.Drawing;
+using System.Globalization;
 using System.IO;
 using System.IO;
 using System.Linq;
 using System.Linq;
 using System.Net;
 using System.Net;
 using System.Net.Security;
 using System.Net.Security;
 using System.Reflection;
 using System.Reflection;
+using System.Text.RegularExpressions;
+using System.Threading.Tasks;
+using System.Drawing;
 using System.Runtime.InteropServices;
 using System.Runtime.InteropServices;
 using System.Security.Cryptography.X509Certificates;
 using System.Security.Cryptography.X509Certificates;
 using System.Threading;
 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.AppKit;
 using MonoMac.Foundation;
 using MonoMac.Foundation;
 using MonoMac.ObjCRuntime;
 using MonoMac.ObjCRuntime;
-using CommonIO;
-using MediaBrowser.Server.Implementations.Logging;
+using Emby.Server.Core;
+using Emby.Common.Implementations.Logging;
+using Emby.Common.Implementations.EnvironmentInfo;
+using Emby.Server.Mac.Native;
+using Emby.Server.Implementations.IO;
+using Emby.Common.Implementations.Networking;
+using Emby.Common.Implementations.Security;
+using Mono.Unix.Native;
+using MediaBrowser.Model.System;
 
 
 namespace MediaBrowser.Server.Mac
 namespace MediaBrowser.Server.Mac
 {
 {
 	class MainClass
 	class MainClass
 	{
 	{
-		internal static ApplicationHost AppHost;
+		internal static MacAppHost AppHost;
 
 
 		private static ILogger _logger;
 		private static ILogger _logger;
 
 
@@ -41,7 +46,9 @@ namespace MediaBrowser.Server.Mac
 			// Allow this to be specified on the command line.
 			// Allow this to be specified on the command line.
 			var customProgramDataPath = options.GetOption("-programdata");
 			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");
 			var logManager = new NlogManager(appPaths.LogDirectoryPath, "server");
 			logManager.ReloadLogger(LogSeverity.Info);
 			logManager.ReloadLogger(LogSeverity.Info);
@@ -58,7 +65,7 @@ namespace MediaBrowser.Server.Mac
 			NSApplication.Main (args);
 			NSApplication.Main (args);
 		}
 		}
 
 
-		private static ServerApplicationPaths CreateApplicationPaths(string applicationPath, string programDataPath)
+		private static ServerApplicationPaths CreateApplicationPaths(string appFolderPath, string programDataPath)
 		{
 		{
 			if (string.IsNullOrEmpty(programDataPath))
 			if (string.IsNullOrEmpty(programDataPath))
 			{
 			{
@@ -71,9 +78,9 @@ namespace MediaBrowser.Server.Mac
 			}
 			}
 
 
 			// Within the mac bundle, go uo two levels then down into Resources folder
 			// 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>
 		/// <summary>
@@ -86,17 +93,34 @@ namespace MediaBrowser.Server.Mac
 			ILogManager logManager, 
 			ILogManager logManager, 
 			StartupOptions options)
 			StartupOptions options)
 		{
 		{
-			SystemEvents.SessionEnding += SystemEvents_SessionEnding;
-
 			// Allow all https requests
 			// Allow all https requests
 			ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(delegate { return true; });
 			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));
             fileSystem.AddShortcutHandler(new MbLinkShortcutHandler(fileSystem));
 
 
-			var nativeApp = new NativeApp(logManager.GetLogger("App"));
-
-			AppHost = new ApplicationHost(appPaths, logManager, options, fileSystem, "Emby.Server.Mac.pkg", nativeApp);
+			var environmentInfo = GetEnvironmentInfo();
+
+			var imageEncoder = ImageEncoderHelper.GetImageEncoder(_logger, 
+			                                                      logManager, 
+			                                                      fileSystem, 
+			                                                      options, 
+			                                                      () => AppHost.HttpClient, 
+			                                                      appPaths);
+
+			AppHost = new MacAppHost(appPaths,
+									 logManager,
+									 options,
+									 fileSystem,
+									 new PowerManagement(),
+									 "Emby.Server.Mac.pkg",
+									 environmentInfo,
+									 imageEncoder,
+									 new Startup.Common.SystemEvents(logManager.GetLogger("SystemEvents")),
+									 new MemoryStreamProvider(),
+			                         new NetworkManager(logManager.GetLogger("NetworkManager")),
+									 GenerateCertificate,
+									 () => Environment.UserName);
 
 
 			if (options.ContainsOption("-v")) {
 			if (options.ContainsOption("-v")) {
 				Console.WriteLine (AppHost.ApplicationVersion.ToString());
 				Console.WriteLine (AppHost.ApplicationVersion.ToString());
@@ -106,9 +130,95 @@ namespace MediaBrowser.Server.Mac
 			Console.WriteLine ("appHost.Init");
 			Console.WriteLine ("appHost.Init");
 
 
 			Task.Run (() => StartServer(CancellationToken.None));
 			Task.Run (() => StartServer(CancellationToken.None));
-		}
+        }
+
+        private static void GenerateCertificate(string certPath, string certHost)
+        {
+            CertificateGenerator.CreateSelfSignCertificatePfx(certPath, certHost, _logger);
+        }
+
+        private static EnvironmentInfo GetEnvironmentInfo()
+        {
+            var info = new EnvironmentInfo();
+
+            var uname = GetUnixName();
 
 
-		private static async void StartServer(CancellationToken cancellationToken) 
+            var sysName = uname.sysname ?? string.Empty;
+
+            if (string.Equals(sysName, "Darwin", StringComparison.OrdinalIgnoreCase))
+            {
+                //info.OperatingSystem = Startup.Common.OperatingSystem.Osx;
+            }
+            else if (string.Equals(sysName, "Linux", StringComparison.OrdinalIgnoreCase))
+            {
+                //info.OperatingSystem = Startup.Common.OperatingSystem.Linux;
+            }
+            else if (string.Equals(sysName, "BSD", StringComparison.OrdinalIgnoreCase))
+            {
+                //info.OperatingSystem = Startup.Common.OperatingSystem.Bsd;
+                //info.IsBsd = true;
+            }
+
+            var archX86 = new Regex("(i|I)[3-6]86");
+
+            if (archX86.IsMatch(uname.machine))
+            {
+                info.CustomArchitecture = Architecture.X86;
+            }
+            else if (string.Equals(uname.machine, "x86_64", StringComparison.OrdinalIgnoreCase))
+            {
+                info.CustomArchitecture = Architecture.X64;
+            }
+            else if (uname.machine.StartsWith("arm", StringComparison.OrdinalIgnoreCase))
+            {
+                info.CustomArchitecture = Architecture.Arm;
+            }
+            else if (System.Environment.Is64BitOperatingSystem)
+            {
+                info.CustomArchitecture = Architecture.X64;
+            }
+            else
+            {
+                info.CustomArchitecture = Architecture.X86;
+            }
+
+            return info;
+        }
+
+        private static Uname _unixName;
+
+        private static Uname GetUnixName()
+        {
+            if (_unixName == null)
+            {
+                var uname = new Uname();
+                try
+                {
+                    Utsname utsname;
+                    var callResult = Syscall.uname(out utsname);
+                    if (callResult == 0)
+                    {
+                        uname.sysname = utsname.sysname ?? string.Empty;
+                        uname.machine = utsname.machine ?? string.Empty;
+                    }
+
+                }
+                catch (Exception ex)
+                {
+                    _logger.ErrorException("Error getting unix name", ex);
+                }
+                _unixName = uname;
+            }
+            return _unixName;
+        }
+
+        public class Uname
+        {
+            public string sysname = string.Empty;
+            public string machine = string.Empty;
+        }
+
+        private static async void StartServer(CancellationToken cancellationToken) 
 		{
 		{
 			var initProgress = new Progress<double>();
 			var initProgress = new Progress<double>();
 
 
@@ -122,19 +232,6 @@ namespace MediaBrowser.Server.Mac
 			}
 			}
 		}
 		}
 
 
-		/// <summary>
-		/// Handles the SessionEnding event of the SystemEvents control.
-		/// </summary>
-		/// <param name="sender">The source of the event.</param>
-		/// <param name="e">The <see cref="SessionEndingEventArgs"/> instance containing the event data.</param>
-		static void SystemEvents_SessionEnding(object sender, SessionEndingEventArgs e)
-		{
-			if (e.Reason == SessionEndReasons.SystemShutdown)
-			{
-				Shutdown();
-			}
-		}
-
 		public static void Shutdown()
 		public static void Shutdown()
 		{
 		{
 			ShutdownApp();
 			ShutdownApp();
@@ -202,10 +299,13 @@ namespace MediaBrowser.Server.Mac
 
 
 	class NoCheckCertificatePolicy : ICertificatePolicy
 	class NoCheckCertificatePolicy : ICertificatePolicy
 	{
 	{
-		public bool CheckValidationResult (ServicePoint srvPoint, X509Certificate certificate, WebRequest request, int certificateProblem)
+		public bool CheckValidationResult (ServicePoint srvPoint, 
+		                                   System.Security.Cryptography.X509Certificates.X509Certificate certificate, 
+		                                   WebRequest request, 
+		                                   int certificateProblem)
 		{
 		{
 			return true;
 			return true;
 		}
 		}
-	}
+    }
 }
 }
 
 

+ 1 - 2
MediaBrowser.Server.Mac/MenuBarIcon.cs

@@ -1,11 +1,10 @@
 using MediaBrowser.Controller;
 using MediaBrowser.Controller;
 using MediaBrowser.Controller.Configuration;
 using MediaBrowser.Controller.Configuration;
-using MediaBrowser.Controller.Localization;
 using MediaBrowser.Model.Logging;
 using MediaBrowser.Model.Logging;
-using MediaBrowser.Server.Startup.Common.Browser;
 using System;
 using System;
 using MonoMac.Foundation;
 using MonoMac.Foundation;
 using MonoMac.AppKit;
 using MonoMac.AppKit;
+using Emby.Server.Core.Browser;
 
 
 namespace MediaBrowser.Server.Mac
 namespace MediaBrowser.Server.Mac
 {
 {

+ 0 - 272
MediaBrowser.Server.Mac/Native/BaseMonoApp.cs

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

+ 1 - 1
MediaBrowser.Server.Mac/Native/DbConnector.cs

@@ -3,7 +3,7 @@ using System.Data;
 using System.Data.SQLite;
 using System.Data.SQLite;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 using MediaBrowser.Model.Logging;
 using MediaBrowser.Model.Logging;
-using MediaBrowser.Server.Implementations.Persistence;
+using Emby.Server.Core.Data;
 
 
 namespace MediaBrowser.Server.Mac
 namespace MediaBrowser.Server.Mac
 {
 {

+ 21 - 0
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);
+        }
+    }
+}

+ 0 - 46
MediaBrowser.Server.Mac/Native/NativeApp.cs

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

+ 0 - 50
MediaBrowser.Server.Mac/Native/NetworkManager.cs

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

+ 15 - 0
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()
+        {
+        }
+    }
+}

+ 1 - 1
MediaBrowser.Server.Mono/MediaBrowser.Server.Mono.csproj

@@ -106,7 +106,7 @@
     <Compile Include="..\SharedVersion.cs">
     <Compile Include="..\SharedVersion.cs">
       <Link>Properties\SharedVersion.cs</Link>
       <Link>Properties\SharedVersion.cs</Link>
     </Compile>
     </Compile>
-    <Compile Include="Native\MonoApp.cs" />
+    <Compile Include="MonoAppHost.cs" />
     <Compile Include="Native\DbConnector.cs" />
     <Compile Include="Native\DbConnector.cs" />
     <Compile Include="Native\MonoFileSystem.cs" />
     <Compile Include="Native\MonoFileSystem.cs" />
     <Compile Include="Native\PowerManagement.cs" />
     <Compile Include="Native\PowerManagement.cs" />

+ 139 - 0
MediaBrowser.Server.Mono/MonoAppHost.cs

@@ -0,0 +1,139 @@
+using System;
+using System.Collections.Generic;
+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;
+using MediaBrowser.Server.Mono.Native;
+
+namespace MediaBrowser.Server.Mono
+{
+    public class MonoAppHost : ApplicationHost
+    {
+        public MonoAppHost(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)
+        {
+        }
+
+        public override bool CanSelfRestart
+        {
+            get
+            {
+                // A restart script must be provided
+                return StartupOptions.ContainsOption("-restartpath");
+            }
+        }
+
+        public override bool CanSelfUpdate
+        {
+            get
+            {
+                return false;
+            }
+        }
+
+        protected override FFMpegInstallInfo GetFfmpegInstallInfo()
+        {
+            var info = new FFMpegInstallInfo();
+
+            // Windows builds: http://ffmpeg.zeranoe.com/builds/
+            // Linux builds: http://johnvansickle.com/ffmpeg/
+            // OS X builds: http://ffmpegmac.net/
+            // OS X x64: http://www.evermeet.cx/ffmpeg/
+
+            var environment = (MonoEnvironmentInfo) EnvironmentInfo;
+
+            if (environment.IsBsd)
+            {
+
+            }
+            else if (environment.OperatingSystem == Model.System.OperatingSystem.Linux)
+            {
+                info.ArchiveType = "7z";
+                info.Version = "20160215";
+            }
+
+            // No version available - user requirement
+            info.DownloadUrls = new string[] { };
+
+            return info;
+        }
+
+        protected override void RestartInternal()
+        {
+            MainClass.Restart(StartupOptions);
+        }
+
+        protected override List<Assembly> GetAssembliesWithPartsInternal()
+        {
+            var list = new List<Assembly>();
+
+            list.Add(GetType().Assembly);
+            list.AddRange(GetLinuxAssemblies());
+
+            return list;
+        }
+
+        private IEnumerable<Assembly> GetLinuxAssemblies()
+        {
+            var list = new List<Assembly>();
+
+            list.Add(typeof(LinuxIsoManager).Assembly);
+
+            return list;
+        }
+
+        protected override void ShutdownInternal()
+        {
+            MainClass.Shutdown();
+        }
+
+        protected override void AuthorizeServer()
+        {
+            throw new NotImplementedException();
+        }
+
+        protected override IDbConnector GetDbConnector()
+        {
+            return new DbConnector(Logger);
+        }
+
+        protected override void ConfigureAutoRunInternal(bool autorun)
+        {
+            throw new NotImplementedException();
+        }
+
+        public override void LaunchUrl(string url)
+        {
+            throw new NotImplementedException();
+        }
+
+        protected override void EnableLoopbackInternal(string appName)
+        {
+        }
+
+        public override bool SupportsRunningAsService
+        {
+            get
+            {
+                return false;
+            }
+        }
+
+        public override bool SupportsAutoRunAtStartup
+        {
+            get { return false; }
+        }
+
+        public override bool IsRunningAsService
+        {
+            get
+            {
+                return false;
+            }
+        }
+    }
+}

+ 0 - 164
MediaBrowser.Server.Mono/Native/MonoApp.cs

@@ -1,164 +0,0 @@
-using MediaBrowser.Common.Net;
-using MediaBrowser.IsoMounter;
-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 Emby.Common.Implementations.Networking;
-using Emby.Server.Core;
-using Emby.Server.Core.Data;
-using Emby.Server.Core.FFMpeg;
-using MediaBrowser.Model.System;
-
-namespace MediaBrowser.Server.Mono.Native
-{
-    public class MonoApp : INativeApp
-    {
-        protected StartupOptions StartupOptions { get; private set; }
-        protected ILogger Logger { get; private set; }
-        private readonly MonoEnvironmentInfo _environment;
-
-        public MonoApp(StartupOptions startupOptions, ILogger logger, MonoEnvironmentInfo environment)
-        {
-            StartupOptions = startupOptions;
-            Logger = logger;
-            _environment = environment;
-        }
-
-        /// <summary>
-        /// Shutdowns this instance.
-        /// </summary>
-        public 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 bool CanSelfRestart
-        {
-            get
-            {
-                // A restart script must be provided
-                return StartupOptions.ContainsOption("-restartpath");
-            }
-        }
-
-        /// <summary>
-        /// Restarts this instance.
-        /// </summary>
-        public void Restart(StartupOptions startupOptions)
-        {
-            MainClass.Restart(startupOptions);
-        }
-
-        /// <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;
-        }
-
-        private IEnumerable<Assembly> GetLinuxAssemblies()
-        {
-            var list = new List<Assembly>();
-
-            //list.Add(typeof(LinuxIsoManager).Assembly);
-
-            return list;
-        }
-
-        public void AuthorizeServer(int udpPort, int httpServerPort, int httpsPort, string applicationPath, string tempDirectory)
-        {
-        }
-
-        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);
-        }
-
-        public FFMpegInstallInfo GetFfmpegInstallInfo()
-        {
-            var info = new FFMpegInstallInfo();
-
-            // Windows builds: http://ffmpeg.zeranoe.com/builds/
-            // Linux builds: http://johnvansickle.com/ffmpeg/
-            // OS X builds: http://ffmpegmac.net/
-            // OS X x64: http://www.evermeet.cx/ffmpeg/
-
-            if (_environment.IsBsd)
-            {
-                
-            }
-            else if (_environment.OperatingSystem == Model.System.OperatingSystem.Linux)
-            {
-                info.ArchiveType = "7z";
-                info.Version = "20160215";
-            }
-
-            // No version available - user requirement
-            info.DownloadUrls = new string[] { };
-
-            return info;
-        }
-
-        public void LaunchUrl(string url)
-        {
-            throw new NotImplementedException();
-        }
-
-        public IDbConnector GetDbConnector()
-        {
-            return new DbConnector(Logger);
-        }
-
-        public void EnableLoopback(string appName)
-        {
-
-        }
-    }
-}

+ 1 - 1
MediaBrowser.Server.Mono/Native/MonoFileSystem.cs

@@ -6,7 +6,7 @@ namespace MediaBrowser.Server.Mono.Native
 {
 {
     public class MonoFileSystem : ManagedFileSystem
     public class MonoFileSystem : ManagedFileSystem
     {
     {
-        public MonoFileSystem(ILogger logger, bool supportsAsyncFileStreams, bool enableManagedInvalidFileNameChars) : base(logger, supportsAsyncFileStreams, enableManagedInvalidFileNameChars)
+        public MonoFileSystem(ILogger logger, bool supportsAsyncFileStreams, bool enableManagedInvalidFileNameChars) : base(logger, supportsAsyncFileStreams, enableManagedInvalidFileNameChars, false)
         {
         {
         }
         }
 
 

+ 11 - 24
MediaBrowser.Server.Mono/Program.cs

@@ -1,10 +1,9 @@
 using MediaBrowser.Model.Logging;
 using MediaBrowser.Model.Logging;
-using MediaBrowser.Server.Implementations;
 using MediaBrowser.Server.Mono.Native;
 using MediaBrowser.Server.Mono.Native;
 using MediaBrowser.Server.Startup.Common;
 using MediaBrowser.Server.Startup.Common;
-using Microsoft.Win32;
 using System;
 using System;
 using System.Diagnostics;
 using System.Diagnostics;
+using System.Globalization;
 using System.IO;
 using System.IO;
 using System.Linq;
 using System.Linq;
 using System.Net;
 using System.Net;
@@ -13,7 +12,6 @@ using System.Reflection;
 using System.Text.RegularExpressions;
 using System.Text.RegularExpressions;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 using Emby.Common.Implementations.EnvironmentInfo;
 using Emby.Common.Implementations.EnvironmentInfo;
-using Emby.Common.Implementations.IO;
 using Emby.Common.Implementations.Logging;
 using Emby.Common.Implementations.Logging;
 using Emby.Common.Implementations.Networking;
 using Emby.Common.Implementations.Networking;
 using Emby.Common.Implementations.Security;
 using Emby.Common.Implementations.Security;
@@ -74,15 +72,15 @@ namespace MediaBrowser.Server.Mono
                 programDataPath = ApplicationPathHelper.GetProgramDataPath(applicationPath);
                 programDataPath = ApplicationPathHelper.GetProgramDataPath(applicationPath);
             }
             }
 
 
-            return new ServerApplicationPaths(programDataPath, applicationPath, Path.GetDirectoryName(applicationPath));
+            var appFolderPath = Path.GetDirectoryName(applicationPath);
+
+            return new ServerApplicationPaths(programDataPath, appFolderPath, Path.GetDirectoryName(applicationPath));
         }
         }
 
 
         private static readonly TaskCompletionSource<bool> ApplicationTaskCompletionSource = new TaskCompletionSource<bool>();
         private static readonly TaskCompletionSource<bool> ApplicationTaskCompletionSource = new TaskCompletionSource<bool>();
 
 
         private static void RunApplication(ServerApplicationPaths appPaths, ILogManager logManager, StartupOptions options)
         private static void RunApplication(ServerApplicationPaths appPaths, ILogManager logManager, StartupOptions options)
         {
         {
-            Microsoft.Win32.SystemEvents.SessionEnding += SystemEvents_SessionEnding;
-
             // Allow all https requests
             // Allow all https requests
             ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(delegate { return true; });
             ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(delegate { return true; });
 
 
@@ -91,15 +89,12 @@ namespace MediaBrowser.Server.Mono
 
 
             var environmentInfo = GetEnvironmentInfo();
             var environmentInfo = GetEnvironmentInfo();
 
 
-            var nativeApp = new MonoApp(options, logManager.GetLogger("App"), environmentInfo);
-
             var imageEncoder = ImageEncoderHelper.GetImageEncoder(_logger, logManager, fileSystem, options, () => _appHost.HttpClient, appPaths);
             var imageEncoder = ImageEncoderHelper.GetImageEncoder(_logger, logManager, fileSystem, options, () => _appHost.HttpClient, appPaths);
 
 
-            _appHost = new ApplicationHost(appPaths,
+            _appHost = new MonoAppHost(appPaths,
                 logManager,
                 logManager,
                 options,
                 options,
                 fileSystem,
                 fileSystem,
-                nativeApp,
                 new PowerManagement(),
                 new PowerManagement(),
                 "emby.mono.zip",
                 "emby.mono.zip",
                 environmentInfo,
                 environmentInfo,
@@ -108,7 +103,7 @@ namespace MediaBrowser.Server.Mono
                 new MemoryStreamProvider(),
                 new MemoryStreamProvider(),
                 new NetworkManager(logManager.GetLogger("NetworkManager")),
                 new NetworkManager(logManager.GetLogger("NetworkManager")),
                 GenerateCertificate,
                 GenerateCertificate,
-                () => Environment.UserDomainName);
+                () => Environment.UserName);
 
 
             if (options.ContainsOption("-v"))
             if (options.ContainsOption("-v"))
             {
             {
@@ -219,19 +214,6 @@ namespace MediaBrowser.Server.Mono
             public string machine = string.Empty;
             public string machine = string.Empty;
         }
         }
 
 
-        /// <summary>
-        /// Handles the SessionEnding event of the SystemEvents control.
-        /// </summary>
-        /// <param name="sender">The source of the event.</param>
-        /// <param name="e">The <see cref="SessionEndingEventArgs"/> instance containing the event data.</param>
-        static void SystemEvents_SessionEnding(object sender, SessionEndingEventArgs e)
-        {
-            if (e.Reason == SessionEndReasons.SystemShutdown)
-            {
-                Shutdown();
-            }
-        }
-
         /// <summary>
         /// <summary>
         /// Handles the UnhandledException event of the CurrentDomain control.
         /// Handles the UnhandledException event of the CurrentDomain control.
         /// </summary>
         /// </summary>
@@ -308,5 +290,10 @@ namespace MediaBrowser.Server.Mono
     public class MonoEnvironmentInfo : EnvironmentInfo
     public class MonoEnvironmentInfo : EnvironmentInfo
     {
     {
         public bool IsBsd { get; set; }
         public bool IsBsd { get; set; }
+
+        public virtual string GetUserId()
+        {
+            return Syscall.getuid().ToString(CultureInfo.InvariantCulture);
+        }
     }
     }
 }
 }

+ 5 - 1
MediaBrowser.Server.Startup.Common/Persistence/SqliteExtensions.cs

@@ -14,7 +14,11 @@ namespace Emby.Server.Core.Data
         /// <summary>
         /// <summary>
         /// Connects to db.
         /// Connects to db.
         /// </summary>
         /// </summary>
-        public static async Task<IDbConnection> ConnectToDb(string dbPath, bool isReadOnly, bool enablePooling, int? cacheSize, ILogger logger)
+        public static async Task<IDbConnection> ConnectToDb(string dbPath, 
+            bool isReadOnly, 
+            bool enablePooling, 
+            int? cacheSize, 
+            ILogger logger)
         {
         {
             if (string.IsNullOrEmpty(dbPath))
             if (string.IsNullOrEmpty(dbPath))
             {
             {

+ 16 - 0
MediaBrowser.Server.Startup.Common/SystemEvents.cs

@@ -9,6 +9,8 @@ namespace MediaBrowser.Server.Startup.Common
     {
     {
         public event EventHandler Resume;
         public event EventHandler Resume;
         public event EventHandler Suspend;
         public event EventHandler Suspend;
+        public event EventHandler SessionLogoff;
+        public event EventHandler SystemShutdown;
 
 
         private readonly ILogger _logger;
         private readonly ILogger _logger;
 
 
@@ -16,6 +18,20 @@ namespace MediaBrowser.Server.Startup.Common
         {
         {
             _logger = logger;
             _logger = logger;
             Microsoft.Win32.SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged;
             Microsoft.Win32.SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged;
+            Microsoft.Win32.SystemEvents.SessionEnding += SystemEvents_SessionEnding;
+        }
+
+        private void SystemEvents_SessionEnding(object sender, Microsoft.Win32.SessionEndingEventArgs e)
+        {
+            switch (e.Reason)
+            {
+                case Microsoft.Win32.SessionEndReasons.Logoff:
+                    EventHelper.FireEventIfNotNull(SessionLogoff, this, EventArgs.Empty, _logger);
+                    break;
+                case Microsoft.Win32.SessionEndReasons.SystemShutdown:
+                    EventHelper.FireEventIfNotNull(SystemShutdown, this, EventArgs.Empty, _logger);
+                    break;
+            }
         }
         }
 
 
         private void SystemEvents_PowerModeChanged(object sender, Microsoft.Win32.PowerModeChangedEventArgs e)
         private void SystemEvents_PowerModeChanged(object sender, Microsoft.Win32.PowerModeChangedEventArgs e)

+ 30 - 46
MediaBrowser.ServerApplication/MainStartup.cs

@@ -37,13 +37,15 @@ namespace MediaBrowser.ServerApplication
 
 
         private static ILogger _logger;
         private static ILogger _logger;
 
 
-        private static bool _isRunningAsService = false;
+        public static bool IsRunningAsService = false;
         private static bool _canRestartService = false;
         private static bool _canRestartService = false;
         private static bool _appHostDisposed;
         private static bool _appHostDisposed;
 
 
         [DllImport("kernel32.dll", SetLastError = true)]
         [DllImport("kernel32.dll", SetLastError = true)]
         static extern bool SetDllDirectory(string lpPathName);
         static extern bool SetDllDirectory(string lpPathName);
 
 
+        public static string ApplicationPath;
+
         public static bool TryGetLocalFromUncDirectory(string local, out string unc)
         public static bool TryGetLocalFromUncDirectory(string local, out string unc)
         {
         {
             if ((local == null) || (local == ""))
             if ((local == null) || (local == ""))
@@ -72,23 +74,23 @@ namespace MediaBrowser.ServerApplication
         public static void Main()
         public static void Main()
         {
         {
             var options = new StartupOptions();
             var options = new StartupOptions();
-            _isRunningAsService = options.ContainsOption("-service");
+            IsRunningAsService = options.ContainsOption("-service");
 
 
-            if (_isRunningAsService)
+            if (IsRunningAsService)
             {
             {
                 //_canRestartService = CanRestartWindowsService();
                 //_canRestartService = CanRestartWindowsService();
             }
             }
 
 
             var currentProcess = Process.GetCurrentProcess();
             var currentProcess = Process.GetCurrentProcess();
 
 
-            var applicationPath = currentProcess.MainModule.FileName;
-            var architecturePath = Path.Combine(Path.GetDirectoryName(applicationPath), Environment.Is64BitProcess ? "x64" : "x86");
+            ApplicationPath = currentProcess.MainModule.FileName;
+            var architecturePath = Path.Combine(Path.GetDirectoryName(ApplicationPath), Environment.Is64BitProcess ? "x64" : "x86");
 
 
             Wand.SetMagickCoderModulePath(architecturePath);
             Wand.SetMagickCoderModulePath(architecturePath);
 
 
             var success = SetDllDirectory(architecturePath);
             var success = SetDllDirectory(architecturePath);
 
 
-            var appPaths = CreateApplicationPaths(applicationPath, _isRunningAsService);
+            var appPaths = CreateApplicationPaths(ApplicationPath, IsRunningAsService);
 
 
             var logManager = new NlogManager(appPaths.LogDirectoryPath, "server");
             var logManager = new NlogManager(appPaths.LogDirectoryPath, "server");
             logManager.ReloadLogger(LogSeverity.Debug);
             logManager.ReloadLogger(LogSeverity.Debug);
@@ -102,7 +104,7 @@ namespace MediaBrowser.ServerApplication
             if (options.ContainsOption("-installservice"))
             if (options.ContainsOption("-installservice"))
             {
             {
                 logger.Info("Performing service installation");
                 logger.Info("Performing service installation");
-                InstallService(applicationPath, logger);
+                InstallService(ApplicationPath, logger);
                 return;
                 return;
             }
             }
 
 
@@ -110,7 +112,7 @@ namespace MediaBrowser.ServerApplication
             if (options.ContainsOption("-installserviceasadmin"))
             if (options.ContainsOption("-installserviceasadmin"))
             {
             {
                 logger.Info("Performing service installation");
                 logger.Info("Performing service installation");
-                RunServiceInstallation(applicationPath);
+                RunServiceInstallation(ApplicationPath);
                 return;
                 return;
             }
             }
 
 
@@ -118,7 +120,7 @@ namespace MediaBrowser.ServerApplication
             if (options.ContainsOption("-uninstallservice"))
             if (options.ContainsOption("-uninstallservice"))
             {
             {
                 logger.Info("Performing service uninstallation");
                 logger.Info("Performing service uninstallation");
-                UninstallService(applicationPath, logger);
+                UninstallService(ApplicationPath, logger);
                 return;
                 return;
             }
             }
 
 
@@ -126,15 +128,15 @@ namespace MediaBrowser.ServerApplication
             if (options.ContainsOption("-uninstallserviceasadmin"))
             if (options.ContainsOption("-uninstallserviceasadmin"))
             {
             {
                 logger.Info("Performing service uninstallation");
                 logger.Info("Performing service uninstallation");
-                RunServiceUninstallation(applicationPath);
+                RunServiceUninstallation(ApplicationPath);
                 return;
                 return;
             }
             }
 
 
             AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
             AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
 
 
-            RunServiceInstallationIfNeeded(applicationPath);
+            RunServiceInstallationIfNeeded(ApplicationPath);
 
 
-            if (IsAlreadyRunning(applicationPath, currentProcess))
+            if (IsAlreadyRunning(ApplicationPath, currentProcess))
             {
             {
                 logger.Info("Shutting down because another instance of Emby Server is already running.");
                 logger.Info("Shutting down because another instance of Emby Server is already running.");
                 return;
                 return;
@@ -148,7 +150,7 @@ namespace MediaBrowser.ServerApplication
 
 
             try
             try
             {
             {
-                RunApplication(appPaths, logManager, _isRunningAsService, options);
+                RunApplication(appPaths, logManager, IsRunningAsService, options);
             }
             }
             finally
             finally
             {
             {
@@ -204,7 +206,7 @@ namespace MediaBrowser.ServerApplication
                 }
                 }
             }
             }
 
 
-            if (!_isRunningAsService)
+            if (!IsRunningAsService)
             {
             {
                 return IsAlreadyRunningAsService(applicationPath);
                 return IsAlreadyRunningAsService(applicationPath);
             }
             }
@@ -250,6 +252,8 @@ namespace MediaBrowser.ServerApplication
         /// <returns>ServerApplicationPaths.</returns>
         /// <returns>ServerApplicationPaths.</returns>
         private static ServerApplicationPaths CreateApplicationPaths(string applicationPath, bool runAsService)
         private static ServerApplicationPaths CreateApplicationPaths(string applicationPath, bool runAsService)
         {
         {
+            var appFolderPath = Path.GetDirectoryName(applicationPath);
+
             var resourcesPath = Path.GetDirectoryName(applicationPath);
             var resourcesPath = Path.GetDirectoryName(applicationPath);
 
 
             if (runAsService)
             if (runAsService)
@@ -258,10 +262,10 @@ namespace MediaBrowser.ServerApplication
 
 
                 var programDataPath = Path.GetDirectoryName(systemPath);
                 var programDataPath = Path.GetDirectoryName(systemPath);
 
 
-                return new ServerApplicationPaths(programDataPath, applicationPath, resourcesPath);
+                return new ServerApplicationPaths(programDataPath, appFolderPath, resourcesPath);
             }
             }
 
 
-            return new ServerApplicationPaths(ApplicationPathHelper.GetProgramDataPath(applicationPath), applicationPath, resourcesPath);
+            return new ServerApplicationPaths(ApplicationPathHelper.GetProgramDataPath(applicationPath), appFolderPath, resourcesPath);
         }
         }
 
 
         /// <summary>
         /// <summary>
@@ -272,7 +276,7 @@ namespace MediaBrowser.ServerApplication
         {
         {
             get
             get
             {
             {
-                if (_isRunningAsService)
+                if (IsRunningAsService)
                 {
                 {
                     return _canRestartService;
                     return _canRestartService;
                 }
                 }
@@ -295,7 +299,7 @@ namespace MediaBrowser.ServerApplication
                 return false;
                 return false;
 #endif
 #endif
 
 
-                if (_isRunningAsService)
+                if (IsRunningAsService)
                 {
                 {
                     return _canRestartService;
                     return _canRestartService;
                 }
                 }
@@ -317,22 +321,16 @@ namespace MediaBrowser.ServerApplication
         /// <param name="options">The options.</param>
         /// <param name="options">The options.</param>
         private static void RunApplication(ServerApplicationPaths appPaths, ILogManager logManager, bool runService, StartupOptions options)
         private static void RunApplication(ServerApplicationPaths appPaths, ILogManager logManager, bool runService, StartupOptions options)
         {
         {
-            var fileSystem = new WindowsFileSystem(logManager.GetLogger("FileSystem"));
+            var fileSystem = new ManagedFileSystem(logManager.GetLogger("FileSystem"), true, true, true);
             fileSystem.AddShortcutHandler(new LnkShortcutHandler());
             fileSystem.AddShortcutHandler(new LnkShortcutHandler());
             fileSystem.AddShortcutHandler(new MbLinkShortcutHandler(fileSystem));
             fileSystem.AddShortcutHandler(new MbLinkShortcutHandler(fileSystem));
 
 
-            var nativeApp = new WindowsApp(fileSystem, _logger)
-            {
-                IsRunningAsService = runService
-            };
-
             var imageEncoder = ImageEncoderHelper.GetImageEncoder(_logger, logManager, fileSystem, options, () => _appHost.HttpClient, appPaths);
             var imageEncoder = ImageEncoderHelper.GetImageEncoder(_logger, logManager, fileSystem, options, () => _appHost.HttpClient, appPaths);
 
 
-            _appHost = new ApplicationHost(appPaths,
+            _appHost = new WindowsAppHost(appPaths,
                 logManager,
                 logManager,
                 options,
                 options,
                 fileSystem,
                 fileSystem,
-                nativeApp,
                 new PowerManagement(),
                 new PowerManagement(),
                 "emby.windows.zip",
                 "emby.windows.zip",
                 new EnvironmentInfo(),
                 new EnvironmentInfo(),
@@ -370,7 +368,6 @@ namespace MediaBrowser.ServerApplication
                 task = InstallVcredist2013IfNeeded(_appHost, _logger);
                 task = InstallVcredist2013IfNeeded(_appHost, _logger);
                 Task.WaitAll(task);
                 Task.WaitAll(task);
 
 
-                Microsoft.Win32.SystemEvents.SessionEnding += SystemEvents_SessionEnding;
                 Microsoft.Win32.SystemEvents.SessionSwitch += SystemEvents_SessionSwitch;
                 Microsoft.Win32.SystemEvents.SessionSwitch += SystemEvents_SessionSwitch;
 
 
                 HideSplashScreen();
                 HideSplashScreen();
@@ -440,7 +437,7 @@ namespace MediaBrowser.ServerApplication
 
 
         public static void Invoke(Action action)
         public static void Invoke(Action action)
         {
         {
-            if (_isRunningAsService)
+            if (IsRunningAsService)
             {
             {
                 action();
                 action();
             }
             }
@@ -571,19 +568,6 @@ namespace MediaBrowser.ServerApplication
             }
             }
         }
         }
 
 
-        /// <summary>
-        /// Handles the SessionEnding event of the SystemEvents control.
-        /// </summary>
-        /// <param name="sender">The source of the event.</param>
-        /// <param name="e">The <see cref="SessionEndingEventArgs"/> instance containing the event data.</param>
-        static void SystemEvents_SessionEnding(object sender, SessionEndingEventArgs e)
-        {
-            if (e.Reason == SessionEndReasons.SystemShutdown || !_isRunningAsService)
-            {
-                Shutdown();
-            }
-        }
-
         /// <summary>
         /// <summary>
         /// Handles the UnhandledException event of the CurrentDomain control.
         /// Handles the UnhandledException event of the CurrentDomain control.
         /// </summary>
         /// </summary>
@@ -595,7 +579,7 @@ namespace MediaBrowser.ServerApplication
 
 
             new UnhandledExceptionWriter(_appHost.ServerConfigurationManager.ApplicationPaths, _logger, _appHost.LogManager).Log(exception);
             new UnhandledExceptionWriter(_appHost.ServerConfigurationManager.ApplicationPaths, _logger, _appHost.LogManager).Log(exception);
 
 
-            if (!_isRunningAsService)
+            if (!IsRunningAsService)
             {
             {
                 MessageBox.Show("Unhandled exception: " + exception.Message);
                 MessageBox.Show("Unhandled exception: " + exception.Message);
             }
             }
@@ -623,7 +607,7 @@ namespace MediaBrowser.ServerApplication
                 // Update is there - execute update
                 // Update is there - execute update
                 try
                 try
                 {
                 {
-                    var serviceName = _isRunningAsService ? BackgroundService.GetExistingServiceName() : string.Empty;
+                    var serviceName = IsRunningAsService ? BackgroundService.GetExistingServiceName() : string.Empty;
                     new ApplicationUpdater().UpdateApplication(appPaths, updateArchive, logger, serviceName);
                     new ApplicationUpdater().UpdateApplication(appPaths, updateArchive, logger, serviceName);
 
 
                     // And just let the app exit so it can update
                     // And just let the app exit so it can update
@@ -642,7 +626,7 @@ namespace MediaBrowser.ServerApplication
 
 
         public static void Shutdown()
         public static void Shutdown()
         {
         {
-            if (_isRunningAsService)
+            if (IsRunningAsService)
             {
             {
                 ShutdownWindowsService();
                 ShutdownWindowsService();
             }
             }
@@ -658,7 +642,7 @@ namespace MediaBrowser.ServerApplication
         {
         {
             DisposeAppHost();
             DisposeAppHost();
 
 
-            if (_isRunningAsService)
+            if (IsRunningAsService)
             {
             {
                 RestartWindowsService();
                 RestartWindowsService();
             }
             }
@@ -669,7 +653,7 @@ namespace MediaBrowser.ServerApplication
 
 
                 _logger.Info("Starting new instance");
                 _logger.Info("Starting new instance");
                 //Application.Restart();
                 //Application.Restart();
-                Process.Start(_appHost.ServerConfigurationManager.ApplicationPaths.ApplicationPath);
+                Process.Start(ApplicationPath);
 
 
                 ShutdownWindowsApplication();
                 ShutdownWindowsApplication();
             }
             }

+ 1 - 1
MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj

@@ -138,7 +138,6 @@
     <Compile Include="Native\PowerManagement.cs" />
     <Compile Include="Native\PowerManagement.cs" />
     <Compile Include="Native\Standby.cs" />
     <Compile Include="Native\Standby.cs" />
     <Compile Include="Native\ServerAuthorization.cs" />
     <Compile Include="Native\ServerAuthorization.cs" />
-    <Compile Include="Native\WindowsApp.cs" />
     <Compile Include="Networking\NativeMethods.cs" />
     <Compile Include="Networking\NativeMethods.cs" />
     <Compile Include="Networking\NetworkManager.cs" />
     <Compile Include="Networking\NetworkManager.cs" />
     <Compile Include="Networking\NetworkShares.cs" />
     <Compile Include="Networking\NetworkShares.cs" />
@@ -156,6 +155,7 @@
       <DependentUpon>SplashForm.cs</DependentUpon>
       <DependentUpon>SplashForm.cs</DependentUpon>
     </Compile>
     </Compile>
     <Compile Include="Updates\ApplicationUpdater.cs" />
     <Compile Include="Updates\ApplicationUpdater.cs" />
+    <Compile Include="WindowsAppHost.cs" />
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
     <None Include="App.config" />
     <None Include="App.config" />

+ 1 - 1
MediaBrowser.ServerApplication/Updates/ApplicationUpdater.cs

@@ -44,7 +44,7 @@ namespace MediaBrowser.ServerApplication.Updates
             // startpath = executable to launch
             // startpath = executable to launch
             // systempath = folder containing installation
             // systempath = folder containing installation
             var args = string.Format("product={0} archive=\"{1}\" caller={2} pismo=false version={3} service={4} installpath=\"{5}\" startpath=\"{6}\" systempath=\"{7}\"",
             var args = string.Format("product={0} archive=\"{1}\" caller={2} pismo=false version={3} service={4} installpath=\"{5}\" startpath=\"{6}\" systempath=\"{7}\"",
-                    product, archive, Process.GetCurrentProcess().Id, version, restartServiceName ?? string.Empty, appPaths.ProgramDataPath, appPaths.ApplicationPath, systemPath);
+                    product, archive, Process.GetCurrentProcess().Id, version, restartServiceName ?? string.Empty, appPaths.ProgramDataPath, MainStartup.ApplicationPath, systemPath);
 
 
             logger.Info("Args: {0}", args);
             logger.Info("Args: {0}", args);
             Process.Start(tempUpdater, args);
             Process.Start(tempUpdater, args);

+ 96 - 93
MediaBrowser.ServerApplication/Native/WindowsApp.cs → MediaBrowser.ServerApplication/WindowsAppHost.cs

@@ -1,106 +1,102 @@
 using System;
 using System;
-using MediaBrowser.Common.Net;
-using MediaBrowser.Model.Logging;
-using MediaBrowser.Server.Startup.Common;
-using MediaBrowser.ServerApplication.Networking;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Diagnostics;
 using System.Diagnostics;
 using System.IO;
 using System.IO;
 using System.Reflection;
 using System.Reflection;
-using System.Windows.Forms;
 using Emby.Server.Core;
 using Emby.Server.Core;
 using Emby.Server.Core.Data;
 using Emby.Server.Core.Data;
 using Emby.Server.Core.FFMpeg;
 using Emby.Server.Core.FFMpeg;
-using MediaBrowser.Common.IO;
-using MediaBrowser.Controller.IO;
+using Emby.Server.Implementations.EntryPoints;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.IO;
+using MediaBrowser.Model.Logging;
+using MediaBrowser.Model.System;
+using MediaBrowser.ServerApplication.Native;
 
 
-namespace MediaBrowser.ServerApplication.Native
+namespace MediaBrowser.ServerApplication
 {
 {
-    public class WindowsApp : INativeApp
+    public class WindowsAppHost : ApplicationHost
     {
     {
-        private readonly IFileSystem _fileSystem;
-        private readonly ILogger _logger;
-
-        public WindowsApp(IFileSystem fileSystem, ILogger logger)
+        public WindowsAppHost(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)
         {
         {
-            _fileSystem = fileSystem;
-            _logger = logger;
         }
         }
 
 
-        public List<Assembly> GetAssembliesWithParts()
+        public override bool IsRunningAsService
         {
         {
-            var list = new List<Assembly>();
-
-            if (!System.Environment.Is64BitProcess)
-            {
-                //list.Add(typeof(PismoIsoManager).Assembly);
-            }
-
-            list.Add(GetType().Assembly);
-
-            return list;
+            get { return MainStartup.IsRunningAsService; }
         }
         }
 
 
-        public void AuthorizeServer(int udpPort, int httpServerPort, int httpsPort, string applicationPath, string tempDirectory)
+        protected override FFMpegInstallInfo GetFfmpegInstallInfo()
         {
         {
-            ServerAuthorization.AuthorizeServer(udpPort, httpServerPort, httpsPort, applicationPath, tempDirectory);
-        }
+            var info = new FFMpegInstallInfo();
 
 
-        public bool SupportsLibraryMonitor
-        {
-            get { return true; }
+            info.FFMpegFilename = "ffmpeg.exe";
+            info.FFProbeFilename = "ffprobe.exe";
+            info.Version = "20160410";
+            info.ArchiveType = "7z";
+            info.DownloadUrls = GetDownloadUrls();
+
+            return info;
         }
         }
 
 
-        public bool SupportsRunningAsService
+        private string[] GetDownloadUrls()
         {
         {
-            get
+            switch (EnvironmentInfo.SystemArchitecture)
             {
             {
-                return true;
+                case Architecture.X64:
+                    return new[]
+                    {
+                                "https://github.com/MediaBrowser/Emby.Resources/raw/master/ffmpeg/windows/ffmpeg-20160410-win64.7z"
+                    };
+                case Architecture.X86:
+                    return new[]
+                    {
+                                "https://github.com/MediaBrowser/Emby.Resources/raw/master/ffmpeg/windows/ffmpeg-20160410-win32.7z"
+                    };
             }
             }
-        }
 
 
-        public bool IsRunningAsService
-        {
-            get;
-            set;
+            return new string[] { };
         }
         }
 
 
-        public bool CanSelfRestart
+        protected override void RestartInternal()
         {
         {
-            get
-            {
-                return MainStartup.CanSelfRestart;
-            }
+            MainStartup.Restart();
         }
         }
 
 
-        public bool SupportsAutoRunAtStartup
+        protected override List<Assembly> GetAssembliesWithPartsInternal()
         {
         {
-            get
+            var list = new List<Assembly>();
+
+            if (!Environment.Is64BitProcess)
             {
             {
-                return true;
+                //list.Add(typeof(PismoIsoManager).Assembly);
             }
             }
+
+            list.Add(GetType().Assembly);
+
+            return list;
         }
         }
 
 
-        public bool CanSelfUpdate
+        protected override void ShutdownInternal()
         {
         {
-            get
-            {
-                return MainStartup.CanSelfUpdate;
-            }
+            MainStartup.Shutdown();
         }
         }
 
 
-        public void Shutdown()
+        protected override void AuthorizeServer()
         {
         {
-            MainStartup.Shutdown();
+            ServerAuthorization.AuthorizeServer(UdpServerEntryPoint.PortNumber,
+                    ServerConfigurationManager.Configuration.HttpServerPortNumber,
+                    ServerConfigurationManager.Configuration.HttpsPortNumber,
+                    MainStartup.ApplicationPath,
+                    ConfigurationManager.CommonApplicationPaths.TempDirectory);
         }
         }
 
 
-        public void Restart(StartupOptions startupOptions)
+        protected override IDbConnector GetDbConnector()
         {
         {
-            MainStartup.Restart();
+            return new DbConnector(Logger);
         }
         }
 
 
-        public void ConfigureAutoRun(bool autorun)
+        protected override void ConfigureAutoRunInternal(bool autorun)
         {
         {
             var shortcutPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.StartMenu), "Emby", "Emby Server.lnk");
             var shortcutPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.StartMenu), "Emby", "Emby Server.lnk");
 
 
@@ -110,33 +106,17 @@ namespace MediaBrowser.ServerApplication.Native
             {
             {
                 //Copy our shortut into the startup folder for this user
                 //Copy our shortut into the startup folder for this user
                 var targetPath = Path.Combine(startupPath, Path.GetFileName(shortcutPath) ?? "Emby Server.lnk");
                 var targetPath = Path.Combine(startupPath, Path.GetFileName(shortcutPath) ?? "Emby Server.lnk");
-                _fileSystem.CreateDirectory(Path.GetDirectoryName(targetPath));
+                FileSystemManager.CreateDirectory(Path.GetDirectoryName(targetPath));
                 File.Copy(shortcutPath, targetPath, true);
                 File.Copy(shortcutPath, targetPath, true);
             }
             }
             else
             else
             {
             {
                 //Remove our shortcut from the startup folder for this user
                 //Remove our shortcut from the startup folder for this user
-                _fileSystem.DeleteFile(Path.Combine(startupPath, Path.GetFileName(shortcutPath) ?? "Emby Server.lnk"));
+                FileSystemManager.DeleteFile(Path.Combine(startupPath, Path.GetFileName(shortcutPath) ?? "Emby Server.lnk"));
             }
             }
         }
         }
 
 
-        public INetworkManager CreateNetworkManager(ILogger logger)
-        {
-            return new NetworkManager(logger);
-        }
-
-        public FFMpegInstallInfo GetFfmpegInstallInfo()
-        {
-            var info = new FFMpegInstallInfo();
-
-            info.FFMpegFilename = "ffmpeg.exe";
-            info.FFProbeFilename = "ffprobe.exe";
-            info.Version = "0";
-
-            return info;
-        }
-
-        public void LaunchUrl(string url)
+        public override void LaunchUrl(string url)
         {
         {
             var process = new Process
             var process = new Process
             {
             {
@@ -156,32 +136,54 @@ namespace MediaBrowser.ServerApplication.Native
             }
             }
             catch (Exception ex)
             catch (Exception ex)
             {
             {
-                _logger.ErrorException("Error launching url: {0}", ex, url);
+                Logger.ErrorException("Error launching url: {0}", ex, url);
 
 
                 throw;
                 throw;
             }
             }
         }
         }
 
 
-        public IDbConnector GetDbConnector()
-        {
-            return new DbConnector(_logger);
-        }
-
-        /// <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)
         private static void ProcessExited(object sender, EventArgs e)
         {
         {
             ((Process)sender).Dispose();
             ((Process)sender).Dispose();
         }
         }
 
 
-        public void EnableLoopback(string appName)
+        protected override void EnableLoopbackInternal(string appName)
         {
         {
             LoopUtil.Run(appName);
             LoopUtil.Run(appName);
         }
         }
 
 
+        public override bool SupportsRunningAsService
+        {
+            get
+            {
+                return true;
+            }
+        }
+
+        public override bool CanSelfRestart
+        {
+            get
+            {
+                return MainStartup.CanSelfRestart;
+            }
+        }
+
+        public override bool SupportsAutoRunAtStartup
+        {
+            get
+            {
+                return true;
+            }
+        }
+
+        public override bool CanSelfUpdate
+        {
+            get
+            {
+                return MainStartup.CanSelfUpdate;
+            }
+        }
+
         public bool PortsRequireAuthorization(string applicationPath)
         public bool PortsRequireAuthorization(string applicationPath)
         {
         {
             var appNameSrch = Path.GetFileName(applicationPath);
             var appNameSrch = Path.GetFileName(applicationPath);
@@ -209,7 +211,7 @@ namespace MediaBrowser.ServerApplication.Native
 
 
                     if (data.IndexOf("Block", StringComparison.OrdinalIgnoreCase) != -1)
                     if (data.IndexOf("Block", StringComparison.OrdinalIgnoreCase) != -1)
                     {
                     {
-                        _logger.Info("Found potential windows firewall rule blocking Emby Server: " + data);
+                        Logger.Info("Found potential windows firewall rule blocking Emby Server: " + data);
                     }
                     }
 
 
                     //var parts = data.Split('\n');
                     //var parts = data.Split('\n');
@@ -220,7 +222,7 @@ namespace MediaBrowser.ServerApplication.Native
                 }
                 }
                 catch (Exception ex)
                 catch (Exception ex)
                 {
                 {
-                    _logger.ErrorException("Error querying windows firewall", ex);
+                    Logger.ErrorException("Error querying windows firewall", ex);
 
 
                     // Hate having to do this
                     // Hate having to do this
                     try
                     try
@@ -229,12 +231,13 @@ namespace MediaBrowser.ServerApplication.Native
                     }
                     }
                     catch (Exception ex1)
                     catch (Exception ex1)
                     {
                     {
-                        _logger.ErrorException("Error killing process", ex1);
+                        Logger.ErrorException("Error killing process", ex1);
                     }
                     }
 
 
                     throw;
                     throw;
                 }
                 }
             }
             }
         }
         }
+
     }
     }
-}
+}

+ 0 - 2
MediaBrowser.XbmcMetadata/Savers/SeriesNfoSaver.cs

@@ -90,8 +90,6 @@ namespace MediaBrowser.XbmcMetadata.Savers
             }
             }
         }
         }
 
 
-        private static readonly CultureInfo UsCulture = new CultureInfo("en-US");
-
         protected override List<string> GetTagsUsed()
         protected override List<string> GetTagsUsed()
         {
         {
             var list = new List<string>
             var list = new List<string>

+ 1 - 1
Nuget/MediaBrowser.Common.nuspec

@@ -2,7 +2,7 @@
 <package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
 <package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
     <metadata>
     <metadata>
         <id>MediaBrowser.Common</id>
         <id>MediaBrowser.Common</id>
-        <version>3.0.689</version>
+        <version>3.0.691</version>
         <title>Emby.Common</title>
         <title>Emby.Common</title>
         <authors>Emby Team</authors>
         <authors>Emby Team</authors>
         <owners>ebr,Luke,scottisafool</owners>
         <owners>ebr,Luke,scottisafool</owners>

+ 2 - 2
Nuget/MediaBrowser.Server.Core.nuspec

@@ -2,7 +2,7 @@
 <package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
 <package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
     <metadata>
     <metadata>
         <id>MediaBrowser.Server.Core</id>
         <id>MediaBrowser.Server.Core</id>
-        <version>3.0.689</version>
+        <version>3.0.691</version>
         <title>Emby.Server.Core</title>
         <title>Emby.Server.Core</title>
         <authors>Emby Team</authors>
         <authors>Emby Team</authors>
         <owners>ebr,Luke,scottisafool</owners>
         <owners>ebr,Luke,scottisafool</owners>
@@ -12,7 +12,7 @@
         <description>Contains core components required to build plugins for Emby Server.</description>
         <description>Contains core components required to build plugins for Emby Server.</description>
         <copyright>Copyright © Emby 2013</copyright>
         <copyright>Copyright © Emby 2013</copyright>
         <dependencies>
         <dependencies>
-            <dependency id="MediaBrowser.Common" version="3.0.689" />
+            <dependency id="MediaBrowser.Common" version="3.0.691" />
         </dependencies>
         </dependencies>
     </metadata>
     </metadata>
     <files>
     <files>

+ 6 - 0
RSSDP/RSSDP.nuget.targets

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8" standalone="no"?>
+<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Target Name="EmitMSBuildWarning" BeforeTargets="Build">
+    <Warning Text="Packages containing MSBuild targets and props files cannot be fully installed in projects targeting multiple frameworks. The MSBuild targets and props files have been ignored." />
+  </Target>
+</Project>

+ 40 - 0
src/Emby.Server/ApplicationPathHelper.cs

@@ -0,0 +1,40 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace Emby.Server
+{
+    public class ApplicationPathHelper
+    {
+        public static string GetProgramDataPath(string appDirectory)
+        {
+            var useDebugPath = false;
+
+#if DEBUG
+            useDebugPath = true;
+#endif
+
+            var programDataPath = useDebugPath ?
+                "programdata" :
+                "programdata";
+
+            programDataPath = programDataPath
+                .Replace('/', Path.DirectorySeparatorChar)
+                .Replace('\\', Path.DirectorySeparatorChar);
+
+            // If it's a relative path, e.g. "..\"
+            if (!Path.IsPathRooted(programDataPath))
+            {
+                programDataPath = Path.Combine(appDirectory, programDataPath);
+
+                programDataPath = Path.GetFullPath(programDataPath);
+            }
+
+            Directory.CreateDirectory(programDataPath);
+
+            return programDataPath;
+        }
+    }
+}

+ 107 - 0
src/Emby.Server/CoreAppHost.cs

@@ -0,0 +1,107 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using System.Threading.Tasks;
+using Emby.Server.Core;
+using Emby.Server.Core.Data;
+using Emby.Server.Core.FFMpeg;
+using Emby.Server.Data;
+using MediaBrowser.Model.IO;
+using MediaBrowser.Model.Logging;
+using MediaBrowser.Model.System;
+
+namespace Emby.Server
+{
+    public class CoreAppHost : ApplicationHost
+    {
+        public CoreAppHost(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)
+        {
+        }
+
+        public override bool IsRunningAsService
+        {
+            get { return false; }
+        }
+
+        protected override void RestartInternal()
+        {
+            Program.Restart();
+        }
+
+        protected override void ShutdownInternal()
+        {
+            Program.Shutdown();
+        }
+
+        protected override FFMpegInstallInfo GetFfmpegInstallInfo()
+        {
+            var info = new FFMpegInstallInfo();
+
+            return info;
+        }
+
+        protected override List<Assembly> GetAssembliesWithPartsInternal()
+        {
+            var list = new List<Assembly>();
+
+            list.Add(GetType().GetTypeInfo().Assembly);
+
+            return list;
+        }
+
+        protected override void AuthorizeServer()
+        {
+        }
+
+        protected override IDbConnector GetDbConnector()
+        {
+            return new DbConnector(Logger);
+        }
+
+        protected override void ConfigureAutoRunInternal(bool autorun)
+        {
+        }
+
+        public override void LaunchUrl(string url)
+        {
+        }
+
+        protected override void EnableLoopbackInternal(string appName)
+        {
+        }
+
+        public override bool SupportsRunningAsService
+        {
+            get
+            {
+                return true;
+            }
+        }
+
+        public override bool CanSelfRestart
+        {
+            get
+            {
+                return Program.CanSelfRestart;
+            }
+        }
+
+        public override bool SupportsAutoRunAtStartup
+        {
+            get
+            {
+                return true;
+            }
+        }
+
+        public override bool CanSelfUpdate
+        {
+            get
+            {
+                return Program.CanSelfUpdate;
+            }
+        }
+    }
+}

+ 11 - 0
src/Emby.Server/CoreSystemEvents.cs

@@ -0,0 +1,11 @@
+using System;
+using MediaBrowser.Model.System;
+
+namespace Emby.Server
+{
+    public class CoreSystemEvents : ISystemEvents
+    {
+        public event EventHandler Resume;
+        public event EventHandler Suspend;
+    }
+}

+ 52 - 0
src/Emby.Server/Data/DbConnector.cs

@@ -0,0 +1,52 @@
+using System;
+using System.Data;
+using System.Threading.Tasks;
+using MediaBrowser.Model.Logging;
+using Emby.Server.Core.Data;
+using Microsoft.Data.Sqlite;
+
+namespace Emby.Server.Data
+{
+    public class DbConnector : IDbConnector
+    {
+        private readonly ILogger _logger;
+
+        public DbConnector(ILogger logger)
+        {
+            _logger = logger;
+        }
+
+        public async Task<IDbConnection> Connect(string dbPath, bool isReadOnly, bool enablePooling = false, int? cacheSize = null)
+        {
+            if (string.IsNullOrEmpty(dbPath))
+            {
+                throw new ArgumentNullException("dbPath");
+            }
+
+            //SQLiteConnection.SetMemoryStatus(false);
+            
+            var connectionstr = new SqliteConnectionStringBuilder
+            {
+                //PageSize = 4096,
+                //CacheSize = cacheSize ?? 2000,
+                //SyncMode = SynchronizationModes.Normal,
+                DataSource = dbPath,
+                //JournalMode = SQLiteJournalModeEnum.Wal,
+
+                // This is causing crashing under linux
+                //Pooling = enablePooling && Environment.OSVersion.Platform == PlatformID.Win32NT,
+                //ReadOnly = isReadOnly,
+                Cache = enablePooling ? SqliteCacheMode.Default : SqliteCacheMode.Private,
+                Mode = isReadOnly ? SqliteOpenMode.ReadOnly : SqliteOpenMode.ReadWriteCreate
+            };
+
+            var connectionString = connectionstr.ConnectionString;
+
+            var connection = new SqliteConnection(connectionString);
+
+            await connection.OpenAsync().ConfigureAwait(false);
+
+            return connection;
+        }
+    }
+}

+ 33 - 0
src/Emby.Server/IO/MemoryStreamFactory.cs

@@ -0,0 +1,33 @@
+using System;
+using System.IO;
+using MediaBrowser.Model.IO;
+
+namespace Emby.Server.IO
+{
+    public class MemoryStreamFactory : IMemoryStreamFactory
+    {
+        public MemoryStream CreateNew()
+        {
+            return new MemoryStream();
+        }
+
+        public MemoryStream CreateNew(int capacity)
+        {
+            return new MemoryStream(capacity);
+        }
+
+        public MemoryStream CreateNew(byte[] buffer)
+        {
+            return new MemoryStream(buffer);
+        }
+
+        public bool TryGetBuffer(MemoryStream stream, out byte[] buffer)
+        {
+            ArraySegment<byte> arrayBuffer;
+            stream.TryGetBuffer(out arrayBuffer);
+
+            buffer = arrayBuffer.Array;
+            return true;
+        }
+    }
+}

+ 15 - 0
src/Emby.Server/PowerManagement.cs

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

+ 47 - 318
src/Emby.Server/Program.cs

@@ -1,33 +1,24 @@
 using MediaBrowser.Model.Logging;
 using MediaBrowser.Model.Logging;
 using MediaBrowser.Server.Implementations;
 using MediaBrowser.Server.Implementations;
-using MediaBrowser.Server.Startup.Common;
-using MediaBrowser.ServerApplication.Native;
-using MediaBrowser.ServerApplication.Splash;
-using MediaBrowser.ServerApplication.Updates;
 using Microsoft.Win32;
 using Microsoft.Win32;
 using System;
 using System;
-using System.Configuration.Install;
 using System.Diagnostics;
 using System.Diagnostics;
 using System.IO;
 using System.IO;
 using System.Linq;
 using System.Linq;
-using System.Management;
 using System.Runtime.InteropServices;
 using System.Runtime.InteropServices;
-using System.ServiceProcess;
 using System.Text;
 using System.Text;
 using System.Threading;
 using System.Threading;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
-using System.Windows.Forms;
 using Emby.Common.Implementations.EnvironmentInfo;
 using Emby.Common.Implementations.EnvironmentInfo;
 using Emby.Common.Implementations.IO;
 using Emby.Common.Implementations.IO;
 using Emby.Common.Implementations.Logging;
 using Emby.Common.Implementations.Logging;
 using Emby.Common.Implementations.Networking;
 using Emby.Common.Implementations.Networking;
-using Emby.Common.Implementations.Security;
+using Emby.Drawing;
 using Emby.Server.Core;
 using Emby.Server.Core;
 using Emby.Server.Core.Browser;
 using Emby.Server.Core.Browser;
 using Emby.Server.Implementations.IO;
 using Emby.Server.Implementations.IO;
-using ImageMagickSharp;
 using MediaBrowser.Common.Net;
 using MediaBrowser.Common.Net;
-using MediaBrowser.Server.Startup.Common.IO;
+using Emby.Server.IO;
 
 
 namespace Emby.Server
 namespace Emby.Server
 {
 {
@@ -37,8 +28,6 @@ namespace Emby.Server
 
 
         private static ILogger _logger;
         private static ILogger _logger;
 
 
-        private static bool _isRunningAsService = false;
-        private static bool _canRestartService = false;
         private static bool _appHostDisposed;
         private static bool _appHostDisposed;
 
 
         [DllImport("kernel32.dll", SetLastError = true)]
         [DllImport("kernel32.dll", SetLastError = true)]
@@ -50,39 +39,33 @@ namespace Emby.Server
         public static void Main(string[] args)
         public static void Main(string[] args)
         {
         {
             var options = new StartupOptions();
             var options = new StartupOptions();
-            _isRunningAsService = options.ContainsOption("-service");
-
-            if (_isRunningAsService)
-            {
-                //_canRestartService = CanRestartWindowsService();
-            }
 
 
             var currentProcess = Process.GetCurrentProcess();
             var currentProcess = Process.GetCurrentProcess();
+            
+            var baseDirectory = System.AppContext.BaseDirectory;
+            //var architecturePath = Path.Combine(Path.GetDirectoryName(applicationPath), Environment.Is64BitProcess ? "x64" : "x86");
 
 
-            var applicationPath = currentProcess.MainModule.FileName;
-            var architecturePath = Path.Combine(Path.GetDirectoryName(applicationPath), Environment.Is64BitProcess ? "x64" : "x86");
+            //Wand.SetMagickCoderModulePath(architecturePath);
 
 
-            Wand.SetMagickCoderModulePath(architecturePath);
+            //var success = SetDllDirectory(architecturePath);
 
 
-            var success = SetDllDirectory(architecturePath);
-
-            var appPaths = CreateApplicationPaths(applicationPath, _isRunningAsService);
+            var appPaths = CreateApplicationPaths(baseDirectory);
 
 
             var logManager = new NlogManager(appPaths.LogDirectoryPath, "server");
             var logManager = new NlogManager(appPaths.LogDirectoryPath, "server");
             logManager.ReloadLogger(LogSeverity.Debug);
             logManager.ReloadLogger(LogSeverity.Debug);
             logManager.AddConsoleOutput();
             logManager.AddConsoleOutput();
 
 
             var logger = _logger = logManager.GetLogger("Main");
             var logger = _logger = logManager.GetLogger("Main");
-
+            
             ApplicationHost.LogEnvironmentInfo(logger, appPaths, true);
             ApplicationHost.LogEnvironmentInfo(logger, appPaths, true);
 
 
             AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
             AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
 
 
-            if (IsAlreadyRunning(applicationPath, currentProcess))
-            {
-                logger.Info("Shutting down because another instance of Emby Server is already running.");
-                return;
-            }
+            //if (IsAlreadyRunning(applicationPath, currentProcess))
+            //{
+            //    logger.Info("Shutting down because another instance of Emby Server is already running.");
+            //    return;
+            //}
 
 
             if (PerformUpdateIfNeeded(appPaths, logger))
             if (PerformUpdateIfNeeded(appPaths, logger))
             {
             {
@@ -90,14 +73,7 @@ namespace Emby.Server
                 return;
                 return;
             }
             }
 
 
-            try
-            {
-                RunApplication(appPaths, logManager, _isRunningAsService, options);
-            }
-            finally
-            {
-                OnServiceShutdown();
-            }
+            RunApplication(appPaths, logManager, options);
         }
         }
 
 
         /// <summary>
         /// <summary>
@@ -148,34 +124,17 @@ namespace Emby.Server
                 }
                 }
             }
             }
 
 
-            if (!_isRunningAsService)
-            {
-                return false;
-            }
-
             return false;
             return false;
         }
         }
 
 
         /// <summary>
         /// <summary>
         /// Creates the application paths.
         /// Creates the application paths.
         /// </summary>
         /// </summary>
-        /// <param name="applicationPath">The application path.</param>
-        /// <param name="runAsService">if set to <c>true</c> [run as service].</param>
-        /// <returns>ServerApplicationPaths.</returns>
-        private static ServerApplicationPaths CreateApplicationPaths(string applicationPath, bool runAsService)
+        private static ServerApplicationPaths CreateApplicationPaths(string appDirectory)
         {
         {
-            var resourcesPath = Path.GetDirectoryName(applicationPath);
-
-            if (runAsService)
-            {
-                var systemPath = Path.GetDirectoryName(applicationPath);
-
-                var programDataPath = Path.GetDirectoryName(systemPath);
-
-                return new ServerApplicationPaths(programDataPath, applicationPath, resourcesPath);
-            }
+            var resourcesPath = appDirectory;
 
 
-            return new ServerApplicationPaths(ApplicationPathHelper.GetProgramDataPath(applicationPath), applicationPath, resourcesPath);
+            return new ServerApplicationPaths(ApplicationPathHelper.GetProgramDataPath(appDirectory), appDirectory, resourcesPath);
         }
         }
 
 
         /// <summary>
         /// <summary>
@@ -186,14 +145,7 @@ namespace Emby.Server
         {
         {
             get
             get
             {
             {
-                if (_isRunningAsService)
-                {
-                    return _canRestartService;
-                }
-                else
-                {
-                    return true;
-                }
+                return true;
             }
             }
         }
         }
 
 
@@ -205,14 +157,7 @@ namespace Emby.Server
         {
         {
             get
             get
             {
             {
-                if (_isRunningAsService)
-                {
-                    return _canRestartService;
-                }
-                else
-                {
-                    return true;
-                }
+                return false;
             }
             }
         }
         }
 
 
@@ -223,123 +168,49 @@ namespace Emby.Server
         /// </summary>
         /// </summary>
         /// <param name="appPaths">The app paths.</param>
         /// <param name="appPaths">The app paths.</param>
         /// <param name="logManager">The log manager.</param>
         /// <param name="logManager">The log manager.</param>
-        /// <param name="runService">if set to <c>true</c> [run service].</param>
         /// <param name="options">The options.</param>
         /// <param name="options">The options.</param>
-        private static void RunApplication(ServerApplicationPaths appPaths, ILogManager logManager, bool runService, StartupOptions options)
+        private static void RunApplication(ServerApplicationPaths appPaths, ILogManager logManager, StartupOptions options)
         {
         {
-            var fileSystem = new WindowsFileSystem(logManager.GetLogger("FileSystem"));
-            fileSystem.AddShortcutHandler(new LnkShortcutHandler());
-            fileSystem.AddShortcutHandler(new MbLinkShortcutHandler(fileSystem));
+            var fileSystem = new ManagedFileSystem(logManager.GetLogger("FileSystem"), true, true, true);
 
 
-            var nativeApp = new WindowsApp(fileSystem, _logger)
-            {
-                IsRunningAsService = runService
-            };
+            fileSystem.AddShortcutHandler(new MbLinkShortcutHandler(fileSystem));
 
 
-            var imageEncoder = ImageEncoderHelper.GetImageEncoder(_logger, logManager, fileSystem, options, () => _appHost.HttpClient, appPaths);
+            var imageEncoder = new NullImageEncoder();
 
 
-            _appHost = new ApplicationHost(appPaths,
+            _appHost = new CoreAppHost(appPaths,
                 logManager,
                 logManager,
                 options,
                 options,
                 fileSystem,
                 fileSystem,
-                nativeApp,
                 new PowerManagement(),
                 new PowerManagement(),
                 "emby.windows.zip",
                 "emby.windows.zip",
                 new EnvironmentInfo(),
                 new EnvironmentInfo(),
                 imageEncoder,
                 imageEncoder,
-                new Server.Startup.Common.SystemEvents(logManager.GetLogger("SystemEvents")),
-                new RecyclableMemoryStreamProvider(),
+                new CoreSystemEvents(),
+                new MemoryStreamFactory(),
                 new NetworkManager(logManager.GetLogger("NetworkManager")),
                 new NetworkManager(logManager.GetLogger("NetworkManager")),
                 GenerateCertificate,
                 GenerateCertificate,
-                () => Environment.UserDomainName);
+                () => "EmbyUser");
 
 
             var initProgress = new Progress<double>();
             var initProgress = new Progress<double>();
 
 
-            if (!runService)
-            {
-                // Not crazy about this but it's the only way to suppress ffmpeg crash dialog boxes
-                SetErrorMode(ErrorModes.SEM_FAILCRITICALERRORS | ErrorModes.SEM_NOALIGNMENTFAULTEXCEPT |
-                             ErrorModes.SEM_NOGPFAULTERRORBOX | ErrorModes.SEM_NOOPENFILEERRORBOX);
-            }
+            // Not crazy about this but it's the only way to suppress ffmpeg crash dialog boxes
+            SetErrorMode(ErrorModes.SEM_FAILCRITICALERRORS | ErrorModes.SEM_NOALIGNMENTFAULTEXCEPT |
+                         ErrorModes.SEM_NOGPFAULTERRORBOX | ErrorModes.SEM_NOOPENFILEERRORBOX);
 
 
             var task = _appHost.Init(initProgress);
             var task = _appHost.Init(initProgress);
             Task.WaitAll(task);
             Task.WaitAll(task);
 
 
             task = task.ContinueWith(new Action<Task>(a => _appHost.RunStartupTasks()), TaskContinuationOptions.OnlyOnRanToCompletion | TaskContinuationOptions.AttachedToParent);
             task = task.ContinueWith(new Action<Task>(a => _appHost.RunStartupTasks()), TaskContinuationOptions.OnlyOnRanToCompletion | TaskContinuationOptions.AttachedToParent);
 
 
-            if (runService)
-            {
-                StartService(logManager);
-            }
-            else
-            {
-                Task.WaitAll(task);
-
-                task = InstallVcredist2013IfNeeded(_appHost, _logger);
-                Task.WaitAll(task);
-
-                Microsoft.Win32.SystemEvents.SessionEnding += SystemEvents_SessionEnding;
-                Microsoft.Win32.SystemEvents.SessionSwitch += SystemEvents_SessionSwitch;
+            Task.WaitAll(task);
 
 
-                task = ApplicationTaskCompletionSource.Task;
-                Task.WaitAll(task);
-            }
+            task = ApplicationTaskCompletionSource.Task;
+            Task.WaitAll(task);
         }
         }
 
 
         private static void GenerateCertificate(string certPath, string certHost)
         private static void GenerateCertificate(string certPath, string certHost)
         {
         {
-            CertificateGenerator.CreateSelfSignCertificatePfx(certPath, certHost, _logger);
-        }
-
-        static void SystemEvents_SessionSwitch(object sender, SessionSwitchEventArgs e)
-        {
-            if (e.Reason == SessionSwitchReason.SessionLogon)
-            {
-                BrowserLauncher.OpenDashboard(_appHost);
-            }
-        }
-
-        /// <summary>
-        /// Starts the service.
-        /// </summary>
-        private static void StartService(ILogManager logManager)
-        {
-            var service = new BackgroundService(logManager.GetLogger("Service"));
-
-            service.Disposed += service_Disposed;
-
-            ServiceBase.Run(service);
-        }
-
-        /// <summary>
-        /// Handles the Disposed event of the service control.
-        /// </summary>
-        /// <param name="sender">The source of the event.</param>
-        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
-        static void service_Disposed(object sender, EventArgs e)
-        {
-            ApplicationTaskCompletionSource.SetResult(true);
-            OnServiceShutdown();
-        }
-
-        private static void OnServiceShutdown()
-        {
-            _logger.Info("Shutting down");
-
-            DisposeAppHost();
-        }
-
-        /// <summary>
-        /// Handles the SessionEnding event of the SystemEvents control.
-        /// </summary>
-        /// <param name="sender">The source of the event.</param>
-        /// <param name="e">The <see cref="SessionEndingEventArgs"/> instance containing the event data.</param>
-        static void SystemEvents_SessionEnding(object sender, SessionEndingEventArgs e)
-        {
-            if (e.Reason == SessionEndReasons.SystemShutdown || !_isRunningAsService)
-            {
-                Shutdown();
-            }
+            //CertificateGenerator.CreateSelfSignCertificatePfx(certPath, certHost, _logger);
         }
         }
 
 
         /// <summary>
         /// <summary>
@@ -353,10 +224,7 @@ namespace Emby.Server
 
 
             new UnhandledExceptionWriter(_appHost.ServerConfigurationManager.ApplicationPaths, _logger, _appHost.LogManager).Log(exception);
             new UnhandledExceptionWriter(_appHost.ServerConfigurationManager.ApplicationPaths, _logger, _appHost.LogManager).Log(exception);
 
 
-            if (!_isRunningAsService)
-            {
-                MessageBox.Show("Unhandled exception: " + exception.Message);
-            }
+            ShowMessageBox("Unhandled exception: " + exception.Message);
 
 
             if (!Debugger.IsAttached)
             if (!Debugger.IsAttached)
             {
             {
@@ -372,80 +240,18 @@ namespace Emby.Server
         /// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
         /// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
         private static bool PerformUpdateIfNeeded(ServerApplicationPaths appPaths, ILogger logger)
         private static bool PerformUpdateIfNeeded(ServerApplicationPaths appPaths, ILogger logger)
         {
         {
-            // Look for the existence of an update archive
-            var updateArchive = Path.Combine(appPaths.TempUpdatePath, "MBServer" + ".zip");
-            if (File.Exists(updateArchive))
-            {
-                logger.Info("An update is available from {0}", updateArchive);
-
-                // Update is there - execute update
-                try
-                {
-                    var serviceName = _isRunningAsService ? BackgroundService.GetExistingServiceName() : string.Empty;
-                    new ApplicationUpdater().UpdateApplication(appPaths, updateArchive, logger, serviceName);
-
-                    // And just let the app exit so it can update
-                    return true;
-                }
-                catch (Exception e)
-                {
-                    logger.ErrorException("Error starting updater.", e);
-
-                    MessageBox.Show(string.Format("Error attempting to update application.\n\n{0}\n\n{1}", e.GetType().Name, e.Message));
-                }
-            }
-
             return false;
             return false;
         }
         }
 
 
-        public static void Shutdown()
+        private static void ShowMessageBox(string msg)
         {
         {
-            if (_isRunningAsService)
-            {
-                ShutdownWindowsService();
-            }
-            else
-            {
-                DisposeAppHost();
 
 
-                ShutdownWindowsApplication();
-            }
         }
         }
 
 
-        public static void Restart()
+        public static void Shutdown()
         {
         {
             DisposeAppHost();
             DisposeAppHost();
 
 
-            if (_isRunningAsService)
-            {
-                RestartWindowsService();
-            }
-            else
-            {
-                //_logger.Info("Hiding server notify icon");
-                //_serverNotifyIcon.Visible = false;
-
-                _logger.Info("Starting new instance");
-                //Application.Restart();
-                Process.Start(_appHost.ServerConfigurationManager.ApplicationPaths.ApplicationPath);
-
-                ShutdownWindowsApplication();
-            }
-        }
-
-        private static void DisposeAppHost()
-        {
-            if (!_appHostDisposed)
-            {
-                _logger.Info("Disposing app host");
-
-                _appHostDisposed = true;
-                _appHost.Dispose();
-            }
-        }
-
-        private static void ShutdownWindowsApplication()
-        {
             //_logger.Info("Calling Application.Exit");
             //_logger.Info("Calling Application.Exit");
             //Application.Exit();
             //Application.Exit();
 
 
@@ -456,101 +262,24 @@ namespace Emby.Server
             ApplicationTaskCompletionSource.SetResult(true);
             ApplicationTaskCompletionSource.SetResult(true);
         }
         }
 
 
-        private static void ShutdownWindowsService()
-        {
-        }
-
-        private static void RestartWindowsService()
-        {
-        }
-
-        private static bool CanRestartWindowsService()
-        {
-            return false;
-        }
-
-        private static async Task InstallVcredist2013IfNeeded(ApplicationHost appHost, ILogger logger)
+        public static void Restart()
         {
         {
-            // Reference 
-            // http://stackoverflow.com/questions/12206314/detect-if-visual-c-redistributable-for-visual-studio-2012-is-installed
+            DisposeAppHost();
 
 
-            try
-            {
-                var subkey = Environment.Is64BitProcess
-                    ? "SOFTWARE\\WOW6432Node\\Microsoft\\VisualStudio\\12.0\\VC\\Runtimes\\x64"
-                    : "SOFTWARE\\Microsoft\\VisualStudio\\12.0\\VC\\Runtimes\\x86";
+            // todo: start new instance
 
 
-                using (RegistryKey ndpKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Default)
-                    .OpenSubKey(subkey))
-                {
-                    if (ndpKey != null && ndpKey.GetValue("Version") != null)
-                    {
-                        var installedVersion = ((string)ndpKey.GetValue("Version")).TrimStart('v');
-                        if (installedVersion.StartsWith("12", StringComparison.OrdinalIgnoreCase))
-                        {
-                            return;
-                        }
-                    }
-                }
-            }
-            catch (Exception ex)
-            {
-                logger.ErrorException("Error getting .NET Framework version", ex);
-                return;
-            }
-
-            try
-            {
-                await InstallVcredist2013().ConfigureAwait(false);
-            }
-            catch (Exception ex)
-            {
-                logger.ErrorException("Error installing Visual Studio C++ runtime", ex);
-            }
+            Shutdown();
         }
         }
 
 
-        private async static Task InstallVcredist2013()
+        private static void DisposeAppHost()
         {
         {
-            var httpClient = _appHost.HttpClient;
-
-            var tmp = await httpClient.GetTempFile(new HttpRequestOptions
-            {
-                Url = GetVcredist2013Url(),
-                Progress = new Progress<double>()
-
-            }).ConfigureAwait(false);
-
-            var exePath = Path.ChangeExtension(tmp, ".exe");
-            File.Copy(tmp, exePath);
-
-            var startInfo = new ProcessStartInfo
-            {
-                FileName = exePath,
-
-                CreateNoWindow = true,
-                WindowStyle = ProcessWindowStyle.Hidden,
-                Verb = "runas",
-                ErrorDialog = false
-            };
-
-            _logger.Info("Running {0}", startInfo.FileName);
-
-            using (var process = Process.Start(startInfo))
+            if (!_appHostDisposed)
             {
             {
-                process.WaitForExit();
-            }
-        }
+                _logger.Info("Disposing app host");
 
 
-        private static string GetVcredist2013Url()
-        {
-            if (Environment.Is64BitProcess)
-            {
-                return "https://github.com/MediaBrowser/Emby.Resources/raw/master/vcredist2013/vcredist_x64.exe";
+                _appHostDisposed = true;
+                _appHost.Dispose();
             }
             }
-
-            // TODO: ARM url - https://github.com/MediaBrowser/Emby.Resources/raw/master/vcredist2013/vcredist_arm.exe
-
-            return "https://github.com/MediaBrowser/Emby.Resources/raw/master/vcredist2013/vcredist_x86.exe";
         }
         }
 
 
         /// <summary>
         /// <summary>

+ 5 - 1
src/Emby.Server/project.json

@@ -11,7 +11,11 @@
       "type": "platform",
       "type": "platform",
       "version": "1.0.1"
       "version": "1.0.1"
     },
     },
-    "Mono.Nat": "1.0.0-*"
+    "Mono.Nat": "1.0.0-*",
+    "Microsoft.Win32.Registry": "4.0.0",
+    "System.Runtime.Extensions": "4.1.0",
+    "System.Diagnostics.Process": "4.1.0",
+    "Microsoft.Data.SQLite": "1.1.0-preview1-final"
   },
   },
 
 
   "frameworks": {
   "frameworks": {