make more classes portable

This commit is contained in:
Luke Pulverenti 2017-02-20 15:50:58 -05:00
parent de3ca87a76
commit 5d55b36487
27 changed files with 118 additions and 1606 deletions

View File

@ -147,7 +147,7 @@ namespace Emby.Common.Implementations
/// <value>The configuration manager.</value>
protected IConfigurationManager ConfigurationManager { get; private set; }
protected IFileSystem FileSystemManager { get; private set; }
public IFileSystem FileSystemManager { get; private set; }
protected IIsoManager IsoManager { get; private set; }

View File

@ -83,7 +83,6 @@ using Emby.Dlna.MediaReceiverRegistrar;
using Emby.Dlna.Ssdp;
using Emby.Server.Core;
using Emby.Server.Implementations.Activity;
using Emby.Server.Core.Configuration;
using Emby.Server.Implementations.Devices;
using Emby.Server.Implementations.FFMpeg;
using Emby.Server.Core.IO;
@ -94,7 +93,6 @@ using Emby.Server.Implementations.Social;
using Emby.Server.Implementations.Sync;
using Emby.Server.Implementations.Channels;
using Emby.Server.Implementations.Collections;
using Emby.Server.Implementations.Connect;
using Emby.Server.Implementations.Dto;
using Emby.Server.Implementations.EntryPoints;
using Emby.Server.Implementations.FileOrganization;
@ -134,6 +132,7 @@ using Emby.Drawing;
using Emby.Server.Implementations.Migrations;
using MediaBrowser.Model.Diagnostics;
using Emby.Common.Implementations.Diagnostics;
using Emby.Server.Implementations.Configuration;
namespace Emby.Server.Core
{
@ -526,6 +525,8 @@ namespace Emby.Server.Core
}
}
protected abstract IConnectManager CreateConnectManager();
/// <summary>
/// Registers resources that classes will depend on
/// </summary>
@ -635,7 +636,7 @@ namespace Emby.Server.Core
var encryptionManager = new EncryptionManager();
RegisterSingleInstance<IEncryptionManager>(encryptionManager);
ConnectManager = new ConnectManager(LogManager.GetLogger("ConnectManager"), ApplicationPaths, JsonSerializer, encryptionManager, HttpClient, this, ServerConfigurationManager, UserManager, ProviderManager, SecurityManager, FileSystemManager);
ConnectManager = CreateConnectManager();
RegisterSingleInstance(ConnectManager);
DeviceManager = new DeviceManager(new DeviceRepository(ApplicationPaths, JsonSerializer, LogManager.GetLogger("DeviceManager"), FileSystemManager), UserManager, FileSystemManager, LibraryMonitor, ServerConfigurationManager, LogManager.GetLogger("DeviceManager"), NetworkManager);

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using MediaBrowser.Model.Logging;
namespace Emby.Server.Core.Logging
{
public class ConsoleLogger : IConsoleLogger
{
public void WriteLine(string message)
{
Console.WriteLine(message);
}
}
}

View File

@ -1,7 +1,8 @@
using System.IO;
using System;
using System.IO;
using MediaBrowser.Common.Configuration;
namespace Emby.Common.Implementations
namespace Emby.Server.Implementations.AppBase
{
/// <summary>
/// Provides a base class to hold common application paths used by both the Ui and Server.
@ -12,12 +13,15 @@ namespace Emby.Common.Implementations
/// <summary>
/// Initializes a new instance of the <see cref="BaseApplicationPaths"/> class.
/// </summary>
protected BaseApplicationPaths(string programDataPath, string appFolderPath)
protected BaseApplicationPaths(string programDataPath, string appFolderPath, Action<string> createDirectoryFn)
{
ProgramDataPath = programDataPath;
ProgramSystemPath = appFolderPath;
CreateDirectoryFn = createDirectoryFn;
}
protected Action<string> CreateDirectoryFn;
public string ProgramDataPath { get; private set; }
/// <summary>
@ -41,7 +45,7 @@ namespace Emby.Common.Implementations
{
_dataDirectory = Path.Combine(ProgramDataPath, "data");
Directory.CreateDirectory(_dataDirectory);
CreateDirectoryFn(_dataDirectory);
}
return _dataDirectory;
@ -148,7 +152,7 @@ namespace Emby.Common.Implementations
{
_cachePath = Path.Combine(ProgramDataPath, "cache");
Directory.CreateDirectory(_cachePath);
CreateDirectoryFn(_cachePath);
}
return _cachePath;

View File

@ -7,13 +7,12 @@ using System.Threading;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Events;
using MediaBrowser.Common.Extensions;
using Emby.Common.Implementations;
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Serialization;
namespace Emby.Common.Implementations.Configuration
namespace Emby.Server.Implementations.AppBase
{
/// <summary>
/// Class BaseConfigurationManager

View File

@ -4,7 +4,7 @@ using System.Linq;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.Serialization;
namespace Emby.Common.Implementations.Configuration
namespace Emby.Server.Implementations.AppBase
{
/// <summary>
/// Class ConfigurationHelper

View File

@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Emby.Common.Implementations.Configuration;
using Emby.Server.Implementations.AppBase;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Events;
using MediaBrowser.Controller;
@ -17,7 +17,7 @@ using MediaBrowser.Model.IO;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Serialization;
namespace Emby.Server.Core.Configuration
namespace Emby.Server.Implementations.Configuration
{
/// <summary>
/// Class ServerConfigurationManager
@ -187,7 +187,7 @@ namespace Emby.Server.Core.Configuration
// Validate
if (!FileSystem.DirectoryExists(newPath))
{
throw new DirectoryNotFoundException(string.Format("{0} does not exist.", newPath));
throw new FileNotFoundException(string.Format("{0} does not exist.", newPath));
}
EnsureWriteAccess(newPath);

View File

@ -1,36 +0,0 @@
using System;
using System.Collections.Generic;
namespace Emby.Server.Implementations.Connect
{
public class ConnectData
{
/// <summary>
/// Gets or sets the server identifier.
/// </summary>
/// <value>The server identifier.</value>
public string ServerId { get; set; }
/// <summary>
/// Gets or sets the access key.
/// </summary>
/// <value>The access key.</value>
public string AccessKey { get; set; }
/// <summary>
/// Gets or sets the authorizations.
/// </summary>
/// <value>The authorizations.</value>
public List<ConnectAuthorizationInternal> PendingAuthorizations { get; set; }
/// <summary>
/// Gets or sets the last authorizations refresh.
/// </summary>
/// <value>The last authorizations refresh.</value>
public DateTime LastAuthorizationsRefresh { get; set; }
public ConnectData()
{
PendingAuthorizations = new List<ConnectAuthorizationInternal>();
}
}
}

View File

@ -1,218 +0,0 @@
using MediaBrowser.Common;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Connect;
using MediaBrowser.Controller.Plugins;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Net;
using System;
using System.IO;
using System.Text;
using System.Threading.Tasks;
using MediaBrowser.Controller.Security;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.Threading;
namespace Emby.Server.Implementations.Connect
{
public class ConnectEntryPoint : IServerEntryPoint
{
private ITimer _timer;
private IpAddressInfo _cachedIpAddress;
private readonly IHttpClient _httpClient;
private readonly IApplicationPaths _appPaths;
private readonly ILogger _logger;
private readonly IConnectManager _connectManager;
private readonly INetworkManager _networkManager;
private readonly IApplicationHost _appHost;
private readonly IFileSystem _fileSystem;
private readonly ITimerFactory _timerFactory;
private readonly IEncryptionManager _encryption;
public ConnectEntryPoint(IHttpClient httpClient, IApplicationPaths appPaths, ILogger logger, INetworkManager networkManager, IConnectManager connectManager, IApplicationHost appHost, IFileSystem fileSystem, ITimerFactory timerFactory, IEncryptionManager encryption)
{
_httpClient = httpClient;
_appPaths = appPaths;
_logger = logger;
_networkManager = networkManager;
_connectManager = connectManager;
_appHost = appHost;
_fileSystem = fileSystem;
_timerFactory = timerFactory;
_encryption = encryption;
}
public void Run()
{
LoadCachedAddress();
_timer = _timerFactory.Create(TimerCallback, null, TimeSpan.FromSeconds(5), TimeSpan.FromHours(1));
((ConnectManager)_connectManager).Start();
}
private readonly string[] _ipLookups =
{
"http://bot.whatismyipaddress.com",
"https://connect.emby.media/service/ip"
};
private async void TimerCallback(object state)
{
IpAddressInfo validIpAddress = null;
foreach (var ipLookupUrl in _ipLookups)
{
try
{
validIpAddress = await GetIpAddress(ipLookupUrl).ConfigureAwait(false);
// Try to find the ipv4 address, if present
if (validIpAddress.AddressFamily != IpAddressFamily.InterNetworkV6)
{
break;
}
}
catch (HttpException)
{
}
catch (Exception ex)
{
_logger.ErrorException("Error getting connection info", ex);
}
}
// If this produced an ipv6 address, try again
if (validIpAddress != null && validIpAddress.AddressFamily == IpAddressFamily.InterNetworkV6)
{
foreach (var ipLookupUrl in _ipLookups)
{
try
{
var newAddress = await GetIpAddress(ipLookupUrl, true).ConfigureAwait(false);
// Try to find the ipv4 address, if present
if (newAddress.AddressFamily != IpAddressFamily.InterNetworkV6)
{
validIpAddress = newAddress;
break;
}
}
catch (HttpException)
{
}
catch (Exception ex)
{
_logger.ErrorException("Error getting connection info", ex);
}
}
}
if (validIpAddress != null)
{
((ConnectManager)_connectManager).OnWanAddressResolved(validIpAddress);
CacheAddress(validIpAddress);
}
}
private async Task<IpAddressInfo> GetIpAddress(string lookupUrl, bool preferIpv4 = false)
{
// Sometimes whatismyipaddress might fail, but it won't do us any good having users raise alarms over it.
var logErrors = false;
#if DEBUG
logErrors = true;
#endif
using (var stream = await _httpClient.Get(new HttpRequestOptions
{
Url = lookupUrl,
UserAgent = "Emby/" + _appHost.ApplicationVersion,
LogErrors = logErrors,
// Seeing block length errors with our server
EnableHttpCompression = false,
PreferIpv4 = preferIpv4,
BufferContent = false
}).ConfigureAwait(false))
{
using (var reader = new StreamReader(stream))
{
var addressString = await reader.ReadToEndAsync().ConfigureAwait(false);
return _networkManager.ParseIpAddress(addressString);
}
}
}
private string CacheFilePath
{
get { return Path.Combine(_appPaths.DataPath, "wan.dat"); }
}
private void CacheAddress(IpAddressInfo address)
{
if (_cachedIpAddress != null && _cachedIpAddress.Equals(address))
{
// no need to update the file if the address has not changed
return;
}
var path = CacheFilePath;
try
{
_fileSystem.CreateDirectory(Path.GetDirectoryName(path));
}
catch (Exception ex)
{
}
try
{
_fileSystem.WriteAllText(path, _encryption.EncryptString(address.ToString()), Encoding.UTF8);
_cachedIpAddress = address;
}
catch (Exception ex)
{
_logger.ErrorException("Error saving data", ex);
}
}
private void LoadCachedAddress()
{
var path = CacheFilePath;
_logger.Info("Loading data from {0}", path);
try
{
var endpoint = _encryption.DecryptString(_fileSystem.ReadAllText(path, Encoding.UTF8));
IpAddressInfo ipAddress;
if (_networkManager.TryParseIpAddress(endpoint, out ipAddress))
{
_cachedIpAddress = ipAddress;
((ConnectManager)_connectManager).OnWanAddressResolved(ipAddress);
}
}
catch (IOException)
{
// File isn't there. no biggie
}
catch (Exception ex)
{
_logger.ErrorException("Error loading data", ex);
}
}
public void Dispose()
{
if (_timer != null)
{
_timer.Dispose();
_timer = null;
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,85 +0,0 @@
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Connect;
namespace Emby.Server.Implementations.Connect
{
public class ServerRegistrationResponse
{
public string Id { get; set; }
public string Url { get; set; }
public string Name { get; set; }
public string AccessKey { get; set; }
}
public class UpdateServerRegistrationResponse
{
public string Id { get; set; }
public string Url { get; set; }
public string Name { get; set; }
}
public class GetConnectUserResponse
{
public string Id { get; set; }
public string Name { get; set; }
public string DisplayName { get; set; }
public string Email { get; set; }
public bool IsActive { get; set; }
public string ImageUrl { get; set; }
}
public class ServerUserAuthorizationResponse
{
public string Id { get; set; }
public string ServerId { get; set; }
public string UserId { get; set; }
public string AccessToken { get; set; }
public string DateCreated { get; set; }
public bool IsActive { get; set; }
public string AcceptStatus { get; set; }
public string UserType { get; set; }
public string UserImageUrl { get; set; }
public string UserName { get; set; }
}
public class ConnectUserPreferences
{
public string[] PreferredAudioLanguages { get; set; }
public bool PlayDefaultAudioTrack { get; set; }
public string[] PreferredSubtitleLanguages { get; set; }
public SubtitlePlaybackMode SubtitleMode { get; set; }
public bool GroupMoviesIntoBoxSets { get; set; }
public ConnectUserPreferences()
{
PreferredAudioLanguages = new string[] { };
PreferredSubtitleLanguages = new string[] { };
}
public static ConnectUserPreferences FromUserConfiguration(UserConfiguration config)
{
return new ConnectUserPreferences
{
PlayDefaultAudioTrack = config.PlayDefaultAudioTrack,
SubtitleMode = config.SubtitleMode,
PreferredAudioLanguages = string.IsNullOrWhiteSpace(config.AudioLanguagePreference) ? new string[] { } : new[] { config.AudioLanguagePreference },
PreferredSubtitleLanguages = string.IsNullOrWhiteSpace(config.SubtitleLanguagePreference) ? new string[] { } : new[] { config.SubtitleLanguagePreference }
};
}
public void MergeInto(UserConfiguration config)
{
}
}
public class UserPreferencesDto<T>
{
public T data { get; set; }
}
public class ConnectAuthorizationInternal : ConnectAuthorization
{
public string AccessToken { get; set; }
}
}

View File

@ -1,29 +0,0 @@
using System.Text.RegularExpressions;
namespace Emby.Server.Implementations.Connect
{
public static class Validator
{
static readonly Regex ValidEmailRegex = CreateValidEmailRegex();
/// <summary>
/// Taken from http://haacked.com/archive/2007/08/21/i-knew-how-to-validate-an-email-address-until-i.aspx
/// </summary>
/// <returns></returns>
private static Regex CreateValidEmailRegex()
{
const string validEmailPattern = @"^(?!\.)(""([^""\r\\]|\\[""\r\\])*""|"
+ @"([-a-z0-9!#$%&'*+/=?^_`{|}~]|(?<!\.)\.)*)(?<!\.)"
+ @"@[a-z0-9][\w\.-]*[a-z0-9]\.[a-z][a-z\.]*[a-z]$";
return new Regex(validEmailPattern, RegexOptions.IgnoreCase);
}
internal static bool EmailIsValid(string emailAddress)
{
bool isValid = ValidEmailRegex.IsMatch(emailAddress);
return isValid;
}
}
}

View File

@ -1031,7 +1031,7 @@ namespace Emby.Server.Implementations.Dto
if (fields.Contains(ItemFields.Path))
{
dto.Path = GetMappedPath(item);
dto.Path = GetMappedPath(item, owner);
}
dto.PremiereDate = item.PremiereDate;
@ -1566,7 +1566,7 @@ namespace Emby.Server.Implementations.Dto
}
}
private string GetMappedPath(BaseItem item)
private string GetMappedPath(BaseItem item, BaseItem ownerItem)
{
var path = item.Path;
@ -1574,7 +1574,7 @@ namespace Emby.Server.Implementations.Dto
if (locationType == LocationType.FileSystem || locationType == LocationType.Offline)
{
path = _libraryManager.GetPathAfterNetworkSubstitution(path, item);
path = _libraryManager.GetPathAfterNetworkSubstitution(path, ownerItem ?? item);
}
return path;

View File

@ -35,6 +35,9 @@
<Compile Include="Activity\ActivityLogEntryPoint.cs" />
<Compile Include="Activity\ActivityManager.cs" />
<Compile Include="Activity\ActivityRepository.cs" />
<Compile Include="AppBase\BaseApplicationPaths.cs" />
<Compile Include="AppBase\BaseConfigurationManager.cs" />
<Compile Include="AppBase\ConfigurationHelper.cs" />
<Compile Include="Branding\BrandingConfigurationFactory.cs" />
<Compile Include="Browser\BrowserLauncher.cs" />
<Compile Include="Channels\ChannelConfigurations.cs" />
@ -46,11 +49,7 @@
<Compile Include="Collections\CollectionImageProvider.cs" />
<Compile Include="Collections\CollectionManager.cs" />
<Compile Include="Collections\CollectionsDynamicFolder.cs" />
<Compile Include="Connect\ConnectData.cs" />
<Compile Include="Connect\ConnectEntryPoint.cs" />
<Compile Include="Connect\ConnectManager.cs" />
<Compile Include="Connect\Responses.cs" />
<Compile Include="Connect\Validator.cs" />
<Compile Include="Configuration\ServerConfigurationManager.cs" />
<Compile Include="Data\ManagedConnection.cs" />
<Compile Include="Data\SqliteDisplayPreferencesRepository.cs" />
<Compile Include="Data\SqliteFileOrganizationRepository.cs" />
@ -179,6 +178,7 @@
<Compile Include="LiveTv\TunerHosts\MulticastStream.cs" />
<Compile Include="LiveTv\TunerHosts\QueueStream.cs" />
<Compile Include="Localization\LocalizationManager.cs" />
<Compile Include="Logging\UnhandledExceptionWriter.cs" />
<Compile Include="MediaEncoder\EncodingManager.cs" />
<Compile Include="Migrations\IVersionMigration.cs" />
<Compile Include="Migrations\LibraryScanMigration.cs" />
@ -213,6 +213,7 @@
<Compile Include="Security\MBLicenseFile.cs" />
<Compile Include="Security\PluginSecurityManager.cs" />
<Compile Include="Security\RegRecord.cs" />
<Compile Include="ServerApplicationPaths.cs" />
<Compile Include="ServerManager\ServerManager.cs" />
<Compile Include="ServerManager\WebSocketConnection.cs" />
<Compile Include="Services\ServicePath.cs" />

View File

@ -2,20 +2,25 @@
using MediaBrowser.Model.Logging;
using System;
using System.IO;
using MediaBrowser.Model.IO;
namespace Emby.Server.Core
namespace Emby.Server.Implementations.Logging
{
public class UnhandledExceptionWriter
{
private readonly IApplicationPaths _appPaths;
private readonly ILogger _logger;
private readonly ILogManager _logManager;
private readonly IFileSystem _fileSystem;
private readonly IConsoleLogger _console;
public UnhandledExceptionWriter(IApplicationPaths appPaths, ILogger logger, ILogManager logManager)
public UnhandledExceptionWriter(IApplicationPaths appPaths, ILogger logger, ILogManager logManager, IFileSystem fileSystem, IConsoleLogger console)
{
_appPaths = appPaths;
_logger = logger;
_logManager = logManager;
_fileSystem = fileSystem;
_console = console;
}
public void Log(Exception ex)
@ -24,15 +29,15 @@ namespace Emby.Server.Core
_logManager.Flush();
var path = Path.Combine(_appPaths.LogDirectoryPath, "unhandled_" + Guid.NewGuid() + ".txt");
Directory.CreateDirectory(Path.GetDirectoryName(path));
_fileSystem.CreateDirectory(Path.GetDirectoryName(path));
var builder = LogHelper.GetLogMessage(ex);
// Write to console just in case file logging fails
Console.WriteLine("UnhandledException");
Console.WriteLine(builder.ToString());
File.WriteAllText(path, builder.ToString());
_console.WriteLine("UnhandledException");
_console.WriteLine(builder.ToString());
_fileSystem.WriteAllText(path, builder.ToString());
}
}
}

View File

@ -1,8 +1,9 @@
using System.IO;
using Emby.Common.Implementations;
using System;
using System.IO;
using Emby.Server.Implementations.AppBase;
using MediaBrowser.Controller;
namespace Emby.Server.Core
namespace Emby.Server.Implementations
{
/// <summary>
/// Extends BaseApplicationPaths to add paths that are only applicable on the server
@ -12,8 +13,8 @@ namespace Emby.Server.Core
/// <summary>
/// Initializes a new instance of the <see cref="BaseApplicationPaths" /> class.
/// </summary>
public ServerApplicationPaths(string programDataPath, string appFolderPath, string applicationResourcesPath)
: base(programDataPath, appFolderPath)
public ServerApplicationPaths(string programDataPath, string appFolderPath, string applicationResourcesPath, Action<string> createDirectoryFn)
: base(programDataPath, appFolderPath, createDirectoryFn)
{
ApplicationResourcesPath = applicationResourcesPath;
}

View File

@ -0,0 +1,7 @@
namespace MediaBrowser.Model.Logging
{
public interface IConsoleLogger
{
void WriteLine(string message);
}
}

View File

@ -135,6 +135,7 @@
<Compile Include="Dto\MetadataEditorInfo.cs" />
<Compile Include="Dto\NameIdPair.cs" />
<Compile Include="Dto\NameValuePair.cs" />
<Compile Include="Logging\IConsoleLogger.cs" />
<Compile Include="Net\IpEndPointInfo.cs" />
<Compile Include="Net\ISocket.cs" />
<Compile Include="Net\ISocketFactory.cs" />

View File

@ -61,6 +61,9 @@
<Reference Include="Emby.Common.Implementations">
<HintPath>..\ThirdParty\emby\Emby.Common.Implementations.dll</HintPath>
</Reference>
<Reference Include="Emby.Server.Connect">
<HintPath>..\ThirdParty\emby\Emby.Server.Connect.dll</HintPath>
</Reference>
<Reference Include="Emby.Server.Core">
<HintPath>..\ThirdParty\emby\Emby.Server.Core.dll</HintPath>
</Reference>

View File

@ -1,9 +1,10 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using Emby.Server.Connect;
using Emby.Server.Core;
using Emby.Server.Implementations;
using Emby.Server.Implementations.FFMpeg;
using MediaBrowser.Controller.Connect;
using MediaBrowser.IsoMounter;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.Logging;
@ -26,6 +27,11 @@ namespace MediaBrowser.Server.Mono
}
}
protected override IConnectManager CreateConnectManager()
{
return new ConnectManager();
}
protected override void RestartInternal()
{
MainClass.Restart(StartupOptions);
@ -46,6 +52,7 @@ namespace MediaBrowser.Server.Mono
var list = new List<Assembly>();
list.Add(typeof(LinuxIsoManager).Assembly);
list.Add(typeof(ConnectManager).Assembly);
return list;
}

View File

@ -16,8 +16,11 @@ using Emby.Common.Implementations.Logging;
using Emby.Common.Implementations.Networking;
using Emby.Common.Implementations.Security;
using Emby.Server.Core;
using Emby.Server.Core.Logging;
using Emby.Server.Implementations;
using Emby.Server.Implementations.IO;
using Emby.Server.Implementations.Logging;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.System;
using MediaBrowser.Server.Startup.Common.IO;
using Mono.Unix.Native;
@ -32,6 +35,7 @@ namespace MediaBrowser.Server.Mono
private static ApplicationHost _appHost;
private static ILogger _logger;
private static IFileSystem FileSystem;
public static void Main(string[] args)
{
@ -98,7 +102,9 @@ namespace MediaBrowser.Server.Mono
var appFolderPath = Path.GetDirectoryName(applicationPath);
return new ServerApplicationPaths(programDataPath, appFolderPath, Path.GetDirectoryName(applicationPath));
Action<string> createDirectoryFn = s => Directory.CreateDirectory(s);
return new ServerApplicationPaths(programDataPath, appFolderPath, Path.GetDirectoryName(applicationPath), createDirectoryFn);
}
private static readonly TaskCompletionSource<bool> ApplicationTaskCompletionSource = new TaskCompletionSource<bool>();
@ -111,6 +117,8 @@ namespace MediaBrowser.Server.Mono
var fileSystem = new MonoFileSystem(logManager.GetLogger("FileSystem"), false, false, appPaths.TempDirectory);
fileSystem.AddShortcutHandler(new MbLinkShortcutHandler(fileSystem));
FileSystem = fileSystem;
var environmentInfo = GetEnvironmentInfo();
var imageEncoder = ImageEncoderHelper.GetImageEncoder(_logger, logManager, fileSystem, options, () => _appHost.HttpClient, appPaths);
@ -247,7 +255,7 @@ namespace MediaBrowser.Server.Mono
{
var exception = (Exception)e.ExceptionObject;
new UnhandledExceptionWriter(_appHost.ServerConfigurationManager.ApplicationPaths, _logger, _appHost.LogManager).Log(exception);
new UnhandledExceptionWriter(_appHost.ServerConfigurationManager.ApplicationPaths, _logger, _appHost.LogManager, FileSystem, new ConsoleLogger()).Log(exception);
if (!Debugger.IsAttached)
{

View File

@ -23,11 +23,14 @@ using Emby.Common.Implementations.Logging;
using Emby.Common.Implementations.Networking;
using Emby.Common.Implementations.Security;
using Emby.Server.Core;
using Emby.Server.Core.Logging;
using Emby.Server.Implementations;
using Emby.Server.Implementations.Browser;
using Emby.Server.Implementations.IO;
using Emby.Server.Implementations.Logging;
using ImageMagickSharp;
using MediaBrowser.Common.Net;
using MediaBrowser.Model.IO;
using MediaBrowser.Server.Startup.Common.IO;
namespace MediaBrowser.ServerApplication
@ -47,6 +50,8 @@ namespace MediaBrowser.ServerApplication
public static string ApplicationPath;
private static IFileSystem FileSystem;
public static bool TryGetLocalFromUncDirectory(string local, out string unc)
{
if ((local == null) || (local == ""))
@ -259,16 +264,18 @@ namespace MediaBrowser.ServerApplication
var resourcesPath = Path.GetDirectoryName(applicationPath);
Action<string> createDirectoryFn = s => Directory.CreateDirectory(s);
if (runAsService)
{
var systemPath = Path.GetDirectoryName(applicationPath);
var programDataPath = Path.GetDirectoryName(systemPath);
return new ServerApplicationPaths(programDataPath, appFolderPath, resourcesPath);
return new ServerApplicationPaths(programDataPath, appFolderPath, resourcesPath, createDirectoryFn);
}
return new ServerApplicationPaths(ApplicationPathHelper.GetProgramDataPath(applicationPath), appFolderPath, resourcesPath);
return new ServerApplicationPaths(ApplicationPathHelper.GetProgramDataPath(applicationPath), appFolderPath, resourcesPath, createDirectoryFn);
}
/// <summary>
@ -330,6 +337,8 @@ namespace MediaBrowser.ServerApplication
var imageEncoder = ImageEncoderHelper.GetImageEncoder(_logger, logManager, fileSystem, options, () => _appHost.HttpClient, appPaths);
FileSystem = fileSystem;
_appHost = new WindowsAppHost(appPaths,
logManager,
options,
@ -580,7 +589,7 @@ namespace MediaBrowser.ServerApplication
{
var exception = (Exception)e.ExceptionObject;
new UnhandledExceptionWriter(_appHost.ServerConfigurationManager.ApplicationPaths, _logger, _appHost.LogManager).Log(exception);
new UnhandledExceptionWriter(_appHost.ServerConfigurationManager.ApplicationPaths, _logger, _appHost.LogManager, FileSystem, new ConsoleLogger()).Log(exception);
if (!IsRunningAsService)
{

View File

@ -67,6 +67,9 @@
<Reference Include="Emby.Common.Implementations">
<HintPath>..\ThirdParty\emby\Emby.Common.Implementations.dll</HintPath>
</Reference>
<Reference Include="Emby.Server.Connect">
<HintPath>..\ThirdParty\emby\Emby.Server.Connect.dll</HintPath>
</Reference>
<Reference Include="Emby.Server.Core">
<HintPath>..\ThirdParty\emby\Emby.Server.Core.dll</HintPath>
</Reference>

View File

@ -4,10 +4,12 @@ using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices.ComTypes;
using Emby.Server.Connect;
using Emby.Server.Core;
using Emby.Server.Implementations;
using Emby.Server.Implementations.EntryPoints;
using Emby.Server.Implementations.FFMpeg;
using MediaBrowser.Controller.Connect;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.System;
@ -27,6 +29,11 @@ namespace MediaBrowser.ServerApplication
get { return MainStartup.IsRunningAsService; }
}
protected override IConnectManager CreateConnectManager()
{
return new ConnectManager();
}
protected override void RestartInternal()
{
MainStartup.Restart();
@ -41,6 +48,7 @@ namespace MediaBrowser.ServerApplication
//list.Add(typeof(PismoIsoManager).Assembly);
}
list.Add(typeof(ConnectManager).Assembly);
list.Add(GetType().Assembly);
return list;

View File

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

View File

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

View File

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