diff options
Diffstat (limited to 'MediaBrowser.Common')
27 files changed, 0 insertions, 2065 deletions
diff --git a/MediaBrowser.Common/Configuration/ConfigurationUpdateEventArgs.cs b/MediaBrowser.Common/Configuration/ConfigurationUpdateEventArgs.cs deleted file mode 100644 index 310e2aa63..000000000 --- a/MediaBrowser.Common/Configuration/ConfigurationUpdateEventArgs.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; - -namespace MediaBrowser.Common.Configuration -{ - public class ConfigurationUpdateEventArgs : EventArgs - { - /// <summary> - /// Gets or sets the key. - /// </summary> - /// <value>The key.</value> - public string Key { get; set; } - /// <summary> - /// Gets or sets the new configuration. - /// </summary> - /// <value>The new configuration.</value> - public object NewConfiguration { get; set; } - } -} diff --git a/MediaBrowser.Common/Configuration/IApplicationPaths.cs b/MediaBrowser.Common/Configuration/IApplicationPaths.cs deleted file mode 100644 index d2446ce46..000000000 --- a/MediaBrowser.Common/Configuration/IApplicationPaths.cs +++ /dev/null @@ -1,82 +0,0 @@ - -namespace MediaBrowser.Common.Configuration -{ - /// <summary> - /// Interface IApplicationPaths - /// </summary> - public interface IApplicationPaths - { - /// <summary> - /// Gets the path to the program data folder - /// </summary> - /// <value>The program data path.</value> - string ProgramDataPath { get; } - - /// <summary> - /// Gets the path to the program system folder - /// </summary> - /// <value>The program data path.</value> - string ProgramSystemPath { get; } - - /// <summary> - /// Gets the folder path to the data directory - /// </summary> - /// <value>The data directory.</value> - string DataPath { get; } - - /// <summary> - /// Gets the image cache path. - /// </summary> - /// <value>The image cache path.</value> - string ImageCachePath { get; } - - /// <summary> - /// Gets the path to the plugin directory - /// </summary> - /// <value>The plugins path.</value> - string PluginsPath { get; } - - /// <summary> - /// Gets the path to the plugin configurations directory - /// </summary> - /// <value>The plugin configurations path.</value> - string PluginConfigurationsPath { get; } - - /// <summary> - /// Gets the path to where temporary update files will be stored - /// </summary> - /// <value>The plugin configurations path.</value> - string TempUpdatePath { get; } - - /// <summary> - /// Gets the path to the log directory - /// </summary> - /// <value>The log directory path.</value> - string LogDirectoryPath { get; } - - /// <summary> - /// Gets the path to the application configuration root directory - /// </summary> - /// <value>The configuration directory path.</value> - string ConfigurationDirectoryPath { get; } - - /// <summary> - /// Gets the path to the system configuration file - /// </summary> - /// <value>The system configuration file path.</value> - string SystemConfigurationFilePath { get; } - - /// <summary> - /// Gets the folder path to the cache directory - /// </summary> - /// <value>The cache directory.</value> - string CachePath { get; } - - /// <summary> - /// Gets the folder path to the temp directory within the cache folder - /// </summary> - /// <value>The temp directory.</value> - string TempDirectory { get; } - } - -} diff --git a/MediaBrowser.Common/Configuration/IConfigurationFactory.cs b/MediaBrowser.Common/Configuration/IConfigurationFactory.cs deleted file mode 100644 index 6ed638536..000000000 --- a/MediaBrowser.Common/Configuration/IConfigurationFactory.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace MediaBrowser.Common.Configuration -{ - public interface IConfigurationFactory - { - IEnumerable<ConfigurationStore> GetConfigurations(); - } - - public class ConfigurationStore - { - public string Key { get; set; } - - public Type ConfigurationType { get; set; } - } - - public interface IValidatingConfiguration - { - void Validate(object oldConfig, object newConfig); - } -} diff --git a/MediaBrowser.Common/Configuration/IConfigurationManager.cs b/MediaBrowser.Common/Configuration/IConfigurationManager.cs deleted file mode 100644 index d826a3ee7..000000000 --- a/MediaBrowser.Common/Configuration/IConfigurationManager.cs +++ /dev/null @@ -1,82 +0,0 @@ -using MediaBrowser.Model.Configuration; -using System; -using System.Collections.Generic; - -namespace MediaBrowser.Common.Configuration -{ - public interface IConfigurationManager - { - /// <summary> - /// Occurs when [configuration updating]. - /// </summary> - event EventHandler<ConfigurationUpdateEventArgs> NamedConfigurationUpdating; - - /// <summary> - /// Occurs when [configuration updated]. - /// </summary> - event EventHandler<EventArgs> ConfigurationUpdated; - - /// <summary> - /// Occurs when [named configuration updated]. - /// </summary> - event EventHandler<ConfigurationUpdateEventArgs> NamedConfigurationUpdated; - - /// <summary> - /// Gets or sets the application paths. - /// </summary> - /// <value>The application paths.</value> - IApplicationPaths CommonApplicationPaths { get; } - - /// <summary> - /// Gets the configuration. - /// </summary> - /// <value>The configuration.</value> - BaseApplicationConfiguration CommonConfiguration { get; } - - /// <summary> - /// Saves the configuration. - /// </summary> - void SaveConfiguration(); - - /// <summary> - /// Replaces the configuration. - /// </summary> - /// <param name="newConfiguration">The new configuration.</param> - void ReplaceConfiguration(BaseApplicationConfiguration newConfiguration); - - /// <summary> - /// Gets the configuration. - /// </summary> - /// <param name="key">The key.</param> - /// <returns>System.Object.</returns> - object GetConfiguration(string key); - - /// <summary> - /// Gets the type of the configuration. - /// </summary> - /// <param name="key">The key.</param> - /// <returns>Type.</returns> - Type GetConfigurationType(string key); - - /// <summary> - /// Saves the configuration. - /// </summary> - /// <param name="key">The key.</param> - /// <param name="configuration">The configuration.</param> - void SaveConfiguration(string key, object configuration); - - /// <summary> - /// Adds the parts. - /// </summary> - /// <param name="factories">The factories.</param> - void AddParts(IEnumerable<IConfigurationFactory> factories); - } - - public static class ConfigurationManagerExtensions - { - public static T GetConfiguration<T>(this IConfigurationManager manager, string key) - { - return (T)manager.GetConfiguration(key); - } - } -} diff --git a/MediaBrowser.Common/Events/EventHelper.cs b/MediaBrowser.Common/Events/EventHelper.cs deleted file mode 100644 index 2bb52f0ae..000000000 --- a/MediaBrowser.Common/Events/EventHelper.cs +++ /dev/null @@ -1,108 +0,0 @@ -using MediaBrowser.Model.Logging; -using System; -using System.Threading.Tasks; - -namespace MediaBrowser.Common.Events -{ - /// <summary> - /// Class EventHelper - /// </summary> - public static class EventHelper - { - /// <summary> - /// Fires the event. - /// </summary> - /// <param name="handler">The handler.</param> - /// <param name="sender">The sender.</param> - /// <param name="args">The <see cref="EventArgs" /> instance containing the event data.</param> - /// <param name="logger">The logger.</param> - public static void QueueEventIfNotNull(EventHandler handler, object sender, EventArgs args, ILogger logger) - { - if (handler != null) - { - Task.Run(() => - { - try - { - handler(sender, args); - } - catch (Exception ex) - { - logger.ErrorException("Error in event handler", ex); - } - }); - } - } - - /// <summary> - /// Queues the event. - /// </summary> - /// <typeparam name="T"></typeparam> - /// <param name="handler">The handler.</param> - /// <param name="sender">The sender.</param> - /// <param name="args">The args.</param> - /// <param name="logger">The logger.</param> - public static void QueueEventIfNotNull<T>(EventHandler<T> handler, object sender, T args, ILogger logger) - { - if (handler != null) - { - Task.Run(() => - { - try - { - handler(sender, args); - } - catch (Exception ex) - { - logger.ErrorException("Error in event handler", ex); - } - }); - } - } - - /// <summary> - /// Fires the event. - /// </summary> - /// <param name="handler">The handler.</param> - /// <param name="sender">The sender.</param> - /// <param name="args">The <see cref="EventArgs" /> instance containing the event data.</param> - /// <param name="logger">The logger.</param> - public static void FireEventIfNotNull(EventHandler handler, object sender, EventArgs args, ILogger logger) - { - if (handler != null) - { - try - { - handler(sender, args); - } - catch (Exception ex) - { - logger.ErrorException("Error in event handler", ex); - } - } - } - - /// <summary> - /// Fires the event. - /// </summary> - /// <typeparam name="T"></typeparam> - /// <param name="handler">The handler.</param> - /// <param name="sender">The sender.</param> - /// <param name="args">The args.</param> - /// <param name="logger">The logger.</param> - public static void FireEventIfNotNull<T>(EventHandler<T> handler, object sender, T args, ILogger logger) - { - if (handler != null) - { - try - { - handler(sender, args); - } - catch (Exception ex) - { - logger.ErrorException("Error in event handler", ex); - } - } - } - } -} diff --git a/MediaBrowser.Common/Extensions/BaseExtensions.cs b/MediaBrowser.Common/Extensions/BaseExtensions.cs deleted file mode 100644 index d7f4424fa..000000000 --- a/MediaBrowser.Common/Extensions/BaseExtensions.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System; -using System.Globalization; -using System.Text.RegularExpressions; -using MediaBrowser.Model.Cryptography; - -namespace MediaBrowser.Common.Extensions -{ - /// <summary> - /// Class BaseExtensions - /// </summary> - public static class BaseExtensions - { - public static ICryptoProvider CryptographyProvider { get; set; } - - /// <summary> - /// Strips the HTML. - /// </summary> - /// <param name="htmlString">The HTML string.</param> - /// <returns>System.String.</returns> - public static string StripHtml(this string htmlString) - { - // http://stackoverflow.com/questions/1349023/how-can-i-strip-html-from-text-in-net - const string pattern = @"<(.|\n)*?>"; - - return Regex.Replace(htmlString, pattern, string.Empty).Trim(); - } - - /// <summary> - /// Gets the M d5. - /// </summary> - /// <param name="str">The STR.</param> - /// <returns>Guid.</returns> - public static Guid GetMD5(this string str) - { - return CryptographyProvider.GetMD5(str); - } - - /// <summary> - /// Gets the MB id. - /// </summary> - /// <param name="str">The STR.</param> - /// <param name="type">The type.</param> - /// <returns>Guid.</returns> - /// <exception cref="System.ArgumentNullException">type</exception> - [Obsolete("Use LibraryManager.GetNewItemId")] - public static Guid GetMBId(this string str, Type type) - { - if (type == null) - { - throw new ArgumentNullException("type"); - } - - var key = type.FullName + str.ToLower(); - - return key.GetMD5(); - } - } -} diff --git a/MediaBrowser.Common/Extensions/ResourceNotFoundException.cs b/MediaBrowser.Common/Extensions/ResourceNotFoundException.cs deleted file mode 100644 index 89e20b1b4..000000000 --- a/MediaBrowser.Common/Extensions/ResourceNotFoundException.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System; - -namespace MediaBrowser.Common.Extensions -{ - /// <summary> - /// Class ResourceNotFoundException - /// </summary> - public class ResourceNotFoundException : Exception - { - /// <summary> - /// Initializes a new instance of the <see cref="ResourceNotFoundException" /> class. - /// </summary> - public ResourceNotFoundException() - { - - } - - /// <summary> - /// Initializes a new instance of the <see cref="ResourceNotFoundException" /> class. - /// </summary> - /// <param name="message">The message.</param> - public ResourceNotFoundException(string message) - : base(message) - { - - } - } - - public class RemoteServiceUnavailableException : Exception - { - public RemoteServiceUnavailableException() - { - - } - - public RemoteServiceUnavailableException(string message) - : base(message) - { - - } - } - - public class RateLimitExceededException : Exception - { - /// <summary> - /// Initializes a new instance of the <see cref="RateLimitExceededException" /> class. - /// </summary> - public RateLimitExceededException() - { - - } - - /// <summary> - /// Initializes a new instance of the <see cref="RateLimitExceededException" /> class. - /// </summary> - /// <param name="message">The message.</param> - public RateLimitExceededException(string message) - : base(message) - { - - } - } -} diff --git a/MediaBrowser.Common/IApplicationHost.cs b/MediaBrowser.Common/IApplicationHost.cs deleted file mode 100644 index dc0c9ac9b..000000000 --- a/MediaBrowser.Common/IApplicationHost.cs +++ /dev/null @@ -1,165 +0,0 @@ -using MediaBrowser.Common.Plugins; -using MediaBrowser.Model.Events; -using MediaBrowser.Model.Updates; -using System; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; - -namespace MediaBrowser.Common -{ - /// <summary> - /// An interface to be implemented by the applications hosting a kernel - /// </summary> - public interface IApplicationHost - { - /// <summary> - /// Gets the display name of the operating system. - /// </summary> - /// <value>The display name of the operating system.</value> - string OperatingSystemDisplayName { get; } - - /// <summary> - /// Gets the name. - /// </summary> - /// <value>The name.</value> - string Name { get; } - - /// <summary> - /// Gets the device identifier. - /// </summary> - /// <value>The device identifier.</value> - string SystemId { get; } - - /// <summary> - /// Occurs when [application updated]. - /// </summary> - event EventHandler<GenericEventArgs<PackageVersionInfo>> ApplicationUpdated; - - /// <summary> - /// Gets or sets a value indicating whether this instance has pending kernel reload. - /// </summary> - /// <value><c>true</c> if this instance has pending kernel reload; otherwise, <c>false</c>.</value> - bool HasPendingRestart { get; } - - bool IsShuttingDown { 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> - /// Occurs when [has pending restart changed]. - /// </summary> - event EventHandler HasPendingRestartChanged; - - /// <summary> - /// Notifies the pending restart. - /// </summary> - void NotifyPendingRestart(); - - /// <summary> - /// Restarts this instance. - /// </summary> - void Restart(); - - /// <summary> - /// Gets the application version. - /// </summary> - /// <value>The application version.</value> - Version ApplicationVersion { get; } - - /// <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> - bool CanSelfUpdate { get; } - - /// <summary> - /// Gets a value indicating whether this instance is first run. - /// </summary> - /// <value><c>true</c> if this instance is first run; otherwise, <c>false</c>.</value> - bool IsFirstRun { get; } - - /// <summary> - /// Gets the failed assemblies. - /// </summary> - /// <value>The failed assemblies.</value> - List<string> FailedAssemblies { get; } - - /// <summary> - /// Gets all concrete types. - /// </summary> - /// <value>All concrete types.</value> - Type[] AllConcreteTypes { get; } - - /// <summary> - /// Gets the exports. - /// </summary> - /// <typeparam name="T"></typeparam> - /// <param name="manageLiftime">if set to <c>true</c> [manage liftime].</param> - /// <returns>IEnumerable{``0}.</returns> - IEnumerable<T> GetExports<T>(bool manageLiftime = true); - - /// <summary> - /// Checks for update. - /// </summary> - /// <returns>Task{CheckForUpdateResult}.</returns> - Task<CheckForUpdateResult> CheckForApplicationUpdate(CancellationToken cancellationToken, IProgress<double> progress); - - /// <summary> - /// Updates the application. - /// </summary> - /// <returns>Task.</returns> - Task UpdateApplication(PackageVersionInfo package, CancellationToken cancellationToken, IProgress<double> progress); - - /// <summary> - /// Resolves this instance. - /// </summary> - /// <typeparam name="T"></typeparam> - /// <returns>``0.</returns> - T Resolve<T>(); - - /// <summary> - /// Resolves this instance. - /// </summary> - /// <typeparam name="T"></typeparam> - /// <returns>``0.</returns> - T TryResolve<T>(); - - /// <summary> - /// Shuts down. - /// </summary> - Task Shutdown(); - - /// <summary> - /// Gets the plugins. - /// </summary> - /// <value>The plugins.</value> - IPlugin[] Plugins { get; } - - /// <summary> - /// Removes the plugin. - /// </summary> - /// <param name="plugin">The plugin.</param> - void RemovePlugin(IPlugin plugin); - - /// <summary> - /// Inits this instance. - /// </summary> - /// <param name="progress">The progress.</param> - /// <returns>Task.</returns> - Task Init(IProgress<double> progress); - - /// <summary> - /// Creates the instance. - /// </summary> - /// <param name="type">The type.</param> - /// <returns>System.Object.</returns> - object CreateInstance(Type type); - - PackageVersionClass SystemUpdateLevel { get; } - } -} diff --git a/MediaBrowser.Common/IDependencyContainer.cs b/MediaBrowser.Common/IDependencyContainer.cs deleted file mode 100644 index 423c1740a..000000000 --- a/MediaBrowser.Common/IDependencyContainer.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; - -namespace MediaBrowser.Common -{ - public interface IDependencyContainer - { - void RegisterSingleInstance<T>(T obj, bool manageLifetime = true) - where T : class; - - void RegisterSingleInstance<T>(Func<T> func) - where T : class; - - void Register(Type typeInterface, Type typeImplementation); - } -}
\ No newline at end of file diff --git a/MediaBrowser.Common/MediaBrowser.Common.csproj b/MediaBrowser.Common/MediaBrowser.Common.csproj deleted file mode 100644 index d561b634e..000000000 --- a/MediaBrowser.Common/MediaBrowser.Common.csproj +++ /dev/null @@ -1,90 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> - <PropertyGroup> - <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> - <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <ProjectGuid>{9142EEFA-7570-41E1-BFCC-468BB571AF2F}</ProjectGuid> - <OutputType>Library</OutputType> - <AppDesignerFolder>Properties</AppDesignerFolder> - <RootNamespace>MediaBrowser.Common</RootNamespace> - <AssemblyName>MediaBrowser.Common</AssemblyName> - <FileAlignment>512</FileAlignment> - <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir> - <ProductVersion>10.0.0</ProductVersion> - <SchemaVersion>2.0</SchemaVersion> - <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> - <TargetFrameworkProfile>Profile7</TargetFrameworkProfile> - <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> - <MinimumVisualStudioVersion>11.0</MinimumVisualStudioVersion> - </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> - <DebugSymbols>true</DebugSymbols> - <DebugType>full</DebugType> - <Optimize>false</Optimize> - <OutputPath>bin\Debug\</OutputPath> - <DefineConstants>DEBUG;TRACE</DefineConstants> - <ErrorReport>prompt</ErrorReport> - <WarningLevel>4</WarningLevel> - <PlatformTarget>AnyCPU</PlatformTarget> - </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> - <DebugType>none</DebugType> - <Optimize>true</Optimize> - <OutputPath>bin\Release\</OutputPath> - <DefineConstants>TRACE</DefineConstants> - <ErrorReport>prompt</ErrorReport> - <WarningLevel>4</WarningLevel> - </PropertyGroup> - <ItemGroup> - <Compile Include="..\SharedVersion.cs"> - <Link>Properties\SharedVersion.cs</Link> - </Compile> - <Compile Include="Configuration\ConfigurationUpdateEventArgs.cs" /> - <Compile Include="Configuration\IConfigurationManager.cs" /> - <Compile Include="Configuration\IConfigurationFactory.cs" /> - <Compile Include="Events\EventHelper.cs" /> - <Compile Include="Extensions\BaseExtensions.cs" /> - <Compile Include="Extensions\ResourceNotFoundException.cs" /> - <Compile Include="IDependencyContainer.cs" /> - <Compile Include="Configuration\IApplicationPaths.cs" /> - <Compile Include="Net\HttpRequestOptions.cs" /> - <Compile Include="Net\HttpResponseInfo.cs" /> - <Compile Include="IApplicationHost.cs" /> - <Compile Include="Net\IHttpClient.cs" /> - <Compile Include="Net\INetworkManager.cs" /> - <Compile Include="Plugins\IDependencyModule.cs" /> - <Compile Include="Plugins\IPlugin.cs" /> - <Compile Include="Progress\ActionableProgress.cs" /> - <Compile Include="Plugins\BasePlugin.cs" /> - <Compile Include="Properties\AssemblyInfo.cs" /> - <Compile Include="Security\IRequiresRegistration.cs" /> - <Compile Include="Security\ISecurityManager.cs" /> - <Compile Include="Security\PaymentRequiredException.cs" /> - <Compile Include="Updates\GithubUpdater.cs" /> - <Compile Include="Updates\IInstallationManager.cs" /> - <Compile Include="Updates\InstallationEventArgs.cs" /> - <Compile Include="Updates\InstallationFailedEventArgs.cs" /> - </ItemGroup> - <ItemGroup> - <ProjectReference Include="..\MediaBrowser.Model\MediaBrowser.Model.csproj"> - <Project>{7EEEB4BB-F3E8-48FC-B4C5-70F0FFF8329B}</Project> - <Name>MediaBrowser.Model</Name> - </ProjectReference> - </ItemGroup> - <ItemGroup /> - <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" /> - <PropertyGroup> - <PostBuildEvent /> - </PropertyGroup> - <PropertyGroup> - <PostBuildEvent /> - </PropertyGroup> - <!-- To modify your build process, add your task inside one of the targets below and uncomment it. - Other similar extension points exist, see Microsoft.Common.targets. - <Target Name="BeforeBuild"> - </Target> - <Target Name="AfterBuild"> - </Target> - --> -</Project>
\ No newline at end of file diff --git a/MediaBrowser.Common/MediaBrowser.Common.nuget.targets b/MediaBrowser.Common/MediaBrowser.Common.nuget.targets deleted file mode 100644 index e69ce0e64..000000000 --- a/MediaBrowser.Common/MediaBrowser.Common.nuget.targets +++ /dev/null @@ -1,6 +0,0 @@ -<?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>
\ No newline at end of file diff --git a/MediaBrowser.Common/Net/HttpRequestOptions.cs b/MediaBrowser.Common/Net/HttpRequestOptions.cs deleted file mode 100644 index 8f0b155f3..000000000 --- a/MediaBrowser.Common/Net/HttpRequestOptions.cs +++ /dev/null @@ -1,156 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net; -using System.Threading; -using System.Text; - -namespace MediaBrowser.Common.Net -{ - /// <summary> - /// Class HttpRequestOptions - /// </summary> - public class HttpRequestOptions - { - /// <summary> - /// Gets or sets the URL. - /// </summary> - /// <value>The URL.</value> - public string Url { get; set; } - - public CompressionMethod? DecompressionMethod { get; set; } - - /// <summary> - /// Gets or sets the accept header. - /// </summary> - /// <value>The accept header.</value> - public string AcceptHeader - { - get { return GetHeaderValue("Accept"); } - set - { - RequestHeaders["Accept"] = value; - } - } - /// <summary> - /// Gets or sets the cancellation token. - /// </summary> - /// <value>The cancellation token.</value> - public CancellationToken CancellationToken { get; set; } - - /// <summary> - /// Gets or sets the resource pool. - /// </summary> - /// <value>The resource pool.</value> - public SemaphoreSlim ResourcePool { get; set; } - - /// <summary> - /// Gets or sets the user agent. - /// </summary> - /// <value>The user agent.</value> - public string UserAgent - { - get { return GetHeaderValue("User-Agent"); } - set - { - RequestHeaders["User-Agent"] = value; - } - } - - /// <summary> - /// Gets or sets the referrer. - /// </summary> - /// <value>The referrer.</value> - public string Referer { get; set; } - - /// <summary> - /// Gets or sets the host. - /// </summary> - /// <value>The host.</value> - public string Host { get; set; } - - /// <summary> - /// Gets or sets the progress. - /// </summary> - /// <value>The progress.</value> - public IProgress<double> Progress { get; set; } - - /// <summary> - /// Gets or sets a value indicating whether [enable HTTP compression]. - /// </summary> - /// <value><c>true</c> if [enable HTTP compression]; otherwise, <c>false</c>.</value> - public bool EnableHttpCompression { get; set; } - - public Dictionary<string, string> RequestHeaders { get; private set; } - - public string RequestContentType { get; set; } - - public string RequestContent { get; set; } - public byte[] RequestContentBytes { get; set; } - - public bool BufferContent { get; set; } - - public bool LogRequest { get; set; } - public bool LogRequestAsDebug { get; set; } - public bool LogErrors { get; set; } - public bool LogResponse { get; set; } - public bool LogResponseHeaders { get; set; } - - public bool LogErrorResponseBody { get; set; } - public bool EnableKeepAlive { get; set; } - - public CacheMode CacheMode { get; set; } - public TimeSpan CacheLength { get; set; } - - public int TimeoutMs { get; set; } - public bool EnableDefaultUserAgent { get; set; } - - public bool AppendCharsetToMimeType { get; set; } - - private string GetHeaderValue(string name) - { - string value; - - RequestHeaders.TryGetValue(name, out value); - - return value; - } - - /// <summary> - /// Initializes a new instance of the <see cref="HttpRequestOptions"/> class. - /// </summary> - public HttpRequestOptions() - { - EnableHttpCompression = true; - - RequestHeaders = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); - - LogRequest = true; - LogErrors = true; - CacheMode = CacheMode.None; - - TimeoutMs = 20000; - } - - public void SetPostData(IDictionary<string,string> values) - { - var strings = values.Keys.Select(key => string.Format("{0}={1}", key, values[key])); - var postContent = string.Join("&", strings.ToArray()); - - RequestContent = postContent; - RequestContentType = "application/x-www-form-urlencoded"; - } - } - - public enum CacheMode - { - None = 0, - Unconditional = 1 - } - - public enum CompressionMethod - { - Deflate, - Gzip - } -} diff --git a/MediaBrowser.Common/Net/HttpResponseInfo.cs b/MediaBrowser.Common/Net/HttpResponseInfo.cs deleted file mode 100644 index 0d7fb69cb..000000000 --- a/MediaBrowser.Common/Net/HttpResponseInfo.cs +++ /dev/null @@ -1,76 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Net; - -namespace MediaBrowser.Common.Net -{ - /// <summary> - /// Class HttpResponseInfo - /// </summary> - public class HttpResponseInfo : IDisposable - { - /// <summary> - /// Gets or sets the type of the content. - /// </summary> - /// <value>The type of the content.</value> - public string ContentType { get; set; } - - /// <summary> - /// Gets or sets the response URL. - /// </summary> - /// <value>The response URL.</value> - public string ResponseUrl { get; set; } - - /// <summary> - /// Gets or sets the content. - /// </summary> - /// <value>The content.</value> - public Stream Content { get; set; } - - /// <summary> - /// Gets or sets the status code. - /// </summary> - /// <value>The status code.</value> - public HttpStatusCode StatusCode { get; set; } - - /// <summary> - /// Gets or sets the temp file path. - /// </summary> - /// <value>The temp file path.</value> - public string TempFilePath { get; set; } - - /// <summary> - /// Gets or sets the length of the content. - /// </summary> - /// <value>The length of the content.</value> - public long? ContentLength { get; set; } - - /// <summary> - /// Gets or sets the headers. - /// </summary> - /// <value>The headers.</value> - public Dictionary<string,string> Headers { get; set; } - - private readonly IDisposable _disposable; - - public HttpResponseInfo(IDisposable disposable) - { - _disposable = disposable; - Headers = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); - } - public HttpResponseInfo() - { - Headers = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); - } - - public void Dispose() - { - if (_disposable != null) - { - _disposable.Dispose(); - } - GC.SuppressFinalize(this); - } - } -} diff --git a/MediaBrowser.Common/Net/IHttpClient.cs b/MediaBrowser.Common/Net/IHttpClient.cs deleted file mode 100644 index cf5511965..000000000 --- a/MediaBrowser.Common/Net/IHttpClient.cs +++ /dev/null @@ -1,59 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Threading; -using System.Threading.Tasks; - -namespace MediaBrowser.Common.Net -{ - /// <summary> - /// Interface IHttpClient - /// </summary> - public interface IHttpClient - { - /// <summary> - /// Gets the response. - /// </summary> - /// <param name="options">The options.</param> - /// <returns>Task{HttpResponseInfo}.</returns> - Task<HttpResponseInfo> GetResponse(HttpRequestOptions options); - - /// <summary> - /// Gets the specified options. - /// </summary> - /// <param name="options">The options.</param> - /// <returns>Task{Stream}.</returns> - Task<Stream> Get(HttpRequestOptions options); - - /// <summary> - /// Sends the asynchronous. - /// </summary> - /// <param name="options">The options.</param> - /// <param name="httpMethod">The HTTP method.</param> - /// <returns>Task{HttpResponseInfo}.</returns> - Task<HttpResponseInfo> SendAsync(HttpRequestOptions options, string httpMethod); - - /// <summary> - /// Posts the specified options. - /// </summary> - /// <param name="options">The options.</param> - /// <returns>Task{HttpResponseInfo}.</returns> - Task<HttpResponseInfo> Post(HttpRequestOptions options); - - /// <summary> - /// Downloads the contents of a given url into a temporary location - /// </summary> - /// <param name="options">The options.</param> - /// <returns>Task{System.String}.</returns> - /// <exception cref="System.ArgumentNullException">progress</exception> - /// <exception cref="MediaBrowser.Model.Net.HttpException"></exception> - Task<string> GetTempFile(HttpRequestOptions options); - - /// <summary> - /// Gets the temporary file response. - /// </summary> - /// <param name="options">The options.</param> - /// <returns>Task{HttpResponseInfo}.</returns> - Task<HttpResponseInfo> GetTempFileResponse(HttpRequestOptions options); - } -}
\ No newline at end of file diff --git a/MediaBrowser.Common/Net/INetworkManager.cs b/MediaBrowser.Common/Net/INetworkManager.cs deleted file mode 100644 index 6ddc2e799..000000000 --- a/MediaBrowser.Common/Net/INetworkManager.cs +++ /dev/null @@ -1,62 +0,0 @@ -using MediaBrowser.Model.IO; -using MediaBrowser.Model.Net; -using System.Collections.Generic; -using System; -using System.Threading.Tasks; - -namespace MediaBrowser.Common.Net -{ - public interface INetworkManager - { - event EventHandler NetworkChanged; - - /// <summary> - /// Gets a random port number that is currently available - /// </summary> - /// <returns>System.Int32.</returns> - int GetRandomUnusedTcpPort(); - - int GetRandomUnusedUdpPort(); - - /// <summary> - /// Returns MAC Address from first Network Card in Computer - /// </summary> - /// <returns>[string] MAC Address</returns> - string GetMacAddress(); - - /// <summary> - /// Determines whether [is in private address space] [the specified endpoint]. - /// </summary> - /// <param name="endpoint">The endpoint.</param> - /// <returns><c>true</c> if [is in private address space] [the specified endpoint]; otherwise, <c>false</c>.</returns> - bool IsInPrivateAddressSpace(string endpoint); - - /// <summary> - /// Gets the network shares. - /// </summary> - /// <param name="path">The path.</param> - /// <returns>IEnumerable{NetworkShare}.</returns> - IEnumerable<NetworkShare> GetNetworkShares(string path); - - /// <summary> - /// Gets available devices within the domain - /// </summary> - /// <returns>PC's in the Domain</returns> - IEnumerable<FileSystemEntryInfo> GetNetworkDevices(); - - /// <summary> - /// Determines whether [is in local network] [the specified endpoint]. - /// </summary> - /// <param name="endpoint">The endpoint.</param> - /// <returns><c>true</c> if [is in local network] [the specified endpoint]; otherwise, <c>false</c>.</returns> - bool IsInLocalNetwork(string endpoint); - - List<IpAddressInfo> GetLocalIpAddresses(); - - IpAddressInfo ParseIpAddress(string ipAddress); - - bool TryParseIpAddress(string ipAddress, out IpAddressInfo ipAddressInfo); - - Task<IpAddressInfo[]> GetHostAddressesAsync(string host); - } -}
\ No newline at end of file diff --git a/MediaBrowser.Common/Plugins/BasePlugin.cs b/MediaBrowser.Common/Plugins/BasePlugin.cs deleted file mode 100644 index 73be04ac8..000000000 --- a/MediaBrowser.Common/Plugins/BasePlugin.cs +++ /dev/null @@ -1,294 +0,0 @@ -using MediaBrowser.Common.Configuration; -using MediaBrowser.Model.Plugins; -using MediaBrowser.Model.Serialization; -using System; -using System.IO; - -namespace MediaBrowser.Common.Plugins -{ - /// <summary> - /// Provides a common base class for all plugins - /// </summary> - /// <typeparam name="TConfigurationType">The type of the T configuration type.</typeparam> - public abstract class BasePlugin<TConfigurationType> : IPlugin, IPluginAssembly - where TConfigurationType : BasePluginConfiguration - { - /// <summary> - /// Gets the application paths. - /// </summary> - /// <value>The application paths.</value> - protected IApplicationPaths ApplicationPaths { get; private set; } - - /// <summary> - /// Gets the XML serializer. - /// </summary> - /// <value>The XML serializer.</value> - protected IXmlSerializer XmlSerializer { get; private set; } - - /// <summary> - /// Gets the name of the plugin - /// </summary> - /// <value>The name.</value> - public abstract string Name { get; } - - /// <summary> - /// Gets a value indicating whether this instance is first run. - /// </summary> - /// <value><c>true</c> if this instance is first run; otherwise, <c>false</c>.</value> - public bool IsFirstRun { get; private set; } - - /// <summary> - /// Gets the description. - /// </summary> - /// <value>The description.</value> - public virtual string Description - { - get { return string.Empty; } - } - - /// <summary> - /// Gets the type of configuration this plugin uses - /// </summary> - /// <value>The type of the configuration.</value> - public Type ConfigurationType - { - get { return typeof(TConfigurationType); } - } - - public void SetAttributes(string assemblyFilePath, string assemblyFileName, Version assemblyVersion) - { - AssemblyFilePath = assemblyFilePath; - AssemblyFileName = assemblyFileName; - Version = assemblyVersion; - } - - public void SetId(Guid assemblyId) - { - Id = assemblyId; - } - - private Func<string, DateTime> _dateModifiedFn; - private Action<string> _directoryCreateFn; - public void SetStartupInfo(bool isFirstRun, Func<string, DateTime> dateModifiedFn, Action<string> directoryCreateFn) - { - IsFirstRun = isFirstRun; - - // hack alert, until the .net core transition is complete - _dateModifiedFn = dateModifiedFn; - _directoryCreateFn = directoryCreateFn; - } - - /// <summary> - /// Gets the unique id. - /// </summary> - /// <value>The unique id.</value> - public virtual Guid Id { get; private set; } - - /// <summary> - /// Gets the plugin version - /// </summary> - /// <value>The version.</value> - public Version Version { get; private set; } - - /// <summary> - /// Gets the name the assembly file - /// </summary> - /// <value>The name of the assembly file.</value> - protected string AssemblyFileName { get; private set; } - - /// <summary> - /// Gets the last date modified of the configuration - /// </summary> - /// <value>The configuration date last modified.</value> - public DateTime ConfigurationDateLastModified - { - get - { - // Ensure it's been lazy loaded - var config = Configuration; - - return _dateModifiedFn(ConfigurationFilePath); - } - } - - /// <summary> - /// Gets the path to the assembly file - /// </summary> - /// <value>The assembly file path.</value> - public string AssemblyFilePath { get; private set; } - - /// <summary> - /// The _configuration sync lock - /// </summary> - private readonly object _configurationSyncLock = new object(); - /// <summary> - /// The _configuration - /// </summary> - private TConfigurationType _configuration; - /// <summary> - /// Gets the plugin's configuration - /// </summary> - /// <value>The configuration.</value> - public TConfigurationType Configuration - { - get - { - // Lazy load - if (_configuration == null) - { - lock (_configurationSyncLock) - { - if (_configuration == null) - { - _configuration = LoadConfiguration(); - } - } - } - return _configuration; - } - protected set - { - _configuration = value; - } - } - - private TConfigurationType LoadConfiguration() - { - var path = ConfigurationFilePath; - - try - { - return (TConfigurationType)XmlSerializer.DeserializeFromFile(typeof(TConfigurationType), path); - } - catch - { - return (TConfigurationType)Activator.CreateInstance(typeof(TConfigurationType)); - } - } - - /// <summary> - /// Gets the name of the configuration file. Subclasses should override - /// </summary> - /// <value>The name of the configuration file.</value> - public virtual string ConfigurationFileName - { - get { return Path.ChangeExtension(AssemblyFileName, ".xml"); } - } - - /// <summary> - /// Gets the full path to the configuration file - /// </summary> - /// <value>The configuration file path.</value> - public string ConfigurationFilePath - { - get - { - return Path.Combine(ApplicationPaths.PluginConfigurationsPath, ConfigurationFileName); - } - } - - /// <summary> - /// Gets the full path to the data folder, where the plugin can store any miscellaneous files needed - /// </summary> - /// <value>The data folder path.</value> - public string DataFolderPath - { - get - { - // Give the folder name the same name as the config file name - // We can always make this configurable if/when needed - return Path.Combine(ApplicationPaths.PluginsPath, Path.GetFileNameWithoutExtension(ConfigurationFileName)); - } - } - - /// <summary> - /// Initializes a new instance of the <see cref="BasePlugin{TConfigurationType}" /> class. - /// </summary> - /// <param name="applicationPaths">The application paths.</param> - /// <param name="xmlSerializer">The XML serializer.</param> - protected BasePlugin(IApplicationPaths applicationPaths, IXmlSerializer xmlSerializer) - { - ApplicationPaths = applicationPaths; - XmlSerializer = xmlSerializer; - } - - /// <summary> - /// The _save lock - /// </summary> - private readonly object _configurationSaveLock = new object(); - - /// <summary> - /// Saves the current configuration to the file system - /// </summary> - public virtual void SaveConfiguration() - { - lock (_configurationSaveLock) - { - _directoryCreateFn(Path.GetDirectoryName(ConfigurationFilePath)); - - XmlSerializer.SerializeToFile(Configuration, ConfigurationFilePath); - } - } - - /// <summary> - /// Completely overwrites the current configuration with a new copy - /// Returns true or false indicating success or failure - /// </summary> - /// <param name="configuration">The configuration.</param> - /// <exception cref="System.ArgumentNullException">configuration</exception> - public virtual void UpdateConfiguration(BasePluginConfiguration configuration) - { - if (configuration == null) - { - throw new ArgumentNullException("configuration"); - } - - Configuration = (TConfigurationType)configuration; - - SaveConfiguration(); - } - - /// <summary> - /// Gets the plugin info. - /// </summary> - /// <returns>PluginInfo.</returns> - public PluginInfo GetPluginInfo() - { - var info = new PluginInfo - { - Name = Name, - Version = Version.ToString(), - AssemblyFileName = AssemblyFileName, - ConfigurationDateLastModified = ConfigurationDateLastModified, - Description = Description, - Id = Id.ToString(), - ConfigurationFileName = ConfigurationFileName - }; - - return info; - } - - /// <summary> - /// Called when just before the plugin is uninstalled from the server. - /// </summary> - public virtual void OnUninstalling() - { - - } - - /// <summary> - /// Gets the plugin's configuration - /// </summary> - /// <value>The configuration.</value> - BasePluginConfiguration IPlugin.Configuration - { - get { return Configuration; } - } - } - - public interface IPluginAssembly - { - void SetAttributes(string assemblyFilePath, string assemblyFileName, Version assemblyVersion); - void SetId(Guid assemblyId); - } -} diff --git a/MediaBrowser.Common/Plugins/IDependencyModule.cs b/MediaBrowser.Common/Plugins/IDependencyModule.cs deleted file mode 100644 index 37ebe0d5b..000000000 --- a/MediaBrowser.Common/Plugins/IDependencyModule.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace MediaBrowser.Common.Plugins -{ - public interface IDependencyModule - { - void BindDependencies(IDependencyContainer container); - } -}
\ No newline at end of file diff --git a/MediaBrowser.Common/Plugins/IPlugin.cs b/MediaBrowser.Common/Plugins/IPlugin.cs deleted file mode 100644 index 999a783fd..000000000 --- a/MediaBrowser.Common/Plugins/IPlugin.cs +++ /dev/null @@ -1,110 +0,0 @@ -using MediaBrowser.Model.Plugins; -using System; - -namespace MediaBrowser.Common.Plugins -{ - /// <summary> - /// Interface IPlugin - /// </summary> - public interface IPlugin - { - /// <summary> - /// Gets the name of the plugin - /// </summary> - /// <value>The name.</value> - string Name { get; } - - /// <summary> - /// Gets the description. - /// </summary> - /// <value>The description.</value> - string Description { get; } - - /// <summary> - /// Gets the type of configuration this plugin uses - /// </summary> - /// <value>The type of the configuration.</value> - Type ConfigurationType { get; } - - /// <summary> - /// Gets the unique id. - /// </summary> - /// <value>The unique id.</value> - Guid Id { get; } - - /// <summary> - /// Gets the plugin version - /// </summary> - /// <value>The version.</value> - Version Version { get; } - - /// <summary> - /// Gets a value indicating whether this instance is first run. - /// </summary> - /// <value><c>true</c> if this instance is first run; otherwise, <c>false</c>.</value> - bool IsFirstRun { get; } - - /// <summary> - /// Gets the last date modified of the configuration - /// </summary> - /// <value>The configuration date last modified.</value> - DateTime ConfigurationDateLastModified { get; } - - /// <summary> - /// Gets the path to the assembly file - /// </summary> - /// <value>The assembly file path.</value> - string AssemblyFilePath { get; } - - /// <summary> - /// Gets the plugin's configuration - /// </summary> - /// <value>The configuration.</value> - BasePluginConfiguration Configuration { get; } - - /// <summary> - /// Gets the name of the configuration file. Subclasses should override - /// </summary> - /// <value>The name of the configuration file.</value> - string ConfigurationFileName { get; } - - /// <summary> - /// Gets the full path to the configuration file - /// </summary> - /// <value>The configuration file path.</value> - string ConfigurationFilePath { get; } - - /// <summary> - /// Gets the full path to the data folder, where the plugin can store any miscellaneous files needed - /// </summary> - /// <value>The data folder path.</value> - string DataFolderPath { get; } - - /// <summary> - /// Saves the current configuration to the file system - /// </summary> - /// <exception cref="System.InvalidOperationException">Cannot call Plugin.SaveConfiguration from the UI.</exception> - void SaveConfiguration(); - - /// <summary> - /// Completely overwrites the current configuration with a new copy - /// Returns true or false indicating success or failure - /// </summary> - /// <param name="configuration">The configuration.</param> - /// <exception cref="System.ArgumentNullException">configuration</exception> - void UpdateConfiguration(BasePluginConfiguration configuration); - - /// <summary> - /// Gets the plugin info. - /// </summary> - /// <returns>PluginInfo.</returns> - PluginInfo GetPluginInfo(); - - /// <summary> - /// Called when just before the plugin is uninstalled from the server. - /// </summary> - void OnUninstalling(); - - void SetStartupInfo(bool isFirstRun, Func<string, DateTime> dateModifiedFn, Action<string> directoryCreateFn); - } -}
\ No newline at end of file diff --git a/MediaBrowser.Common/Progress/ActionableProgress.cs b/MediaBrowser.Common/Progress/ActionableProgress.cs deleted file mode 100644 index 5b318c6a7..000000000 --- a/MediaBrowser.Common/Progress/ActionableProgress.cs +++ /dev/null @@ -1,74 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace MediaBrowser.Common.Progress -{ - /// <summary> - /// Class ActionableProgress - /// </summary> - /// <typeparam name="T"></typeparam> - public class ActionableProgress<T> : IProgress<T>, IDisposable - { - /// <summary> - /// The _actions - /// </summary> - private readonly List<Action<T>> _actions = new List<Action<T>>(); - public event EventHandler<T> ProgressChanged; - - /// <summary> - /// Registers the action. - /// </summary> - /// <param name="action">The action.</param> - public void RegisterAction(Action<T> action) - { - _actions.Add(action); - } - - /// <summary> - /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. - /// </summary> - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - - /// <summary> - /// Releases unmanaged and - optionally - managed resources. - /// </summary> - /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param> - protected virtual void Dispose(bool disposing) - { - if (disposing) - { - _actions.Clear(); - } - } - - public void Report(T value) - { - if (ProgressChanged != null) - { - ProgressChanged(this, value); - } - - foreach (var action in _actions) - { - action(value); - } - } - } - - public class SimpleProgress<T> : IProgress<T> - { - public event EventHandler<T> ProgressChanged; - - public void Report(T value) - { - if (ProgressChanged != null) - { - ProgressChanged(this, value); - } - } - } -} diff --git a/MediaBrowser.Common/Properties/AssemblyInfo.cs b/MediaBrowser.Common/Properties/AssemblyInfo.cs deleted file mode 100644 index 09fd68f93..000000000 --- a/MediaBrowser.Common/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("MediaBrowser.Common")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("MediaBrowser.Common")] -[assembly: AssemblyCopyright("Copyright © 2012")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -//
\ No newline at end of file diff --git a/MediaBrowser.Common/Security/IRequiresRegistration.cs b/MediaBrowser.Common/Security/IRequiresRegistration.cs deleted file mode 100644 index 7b1667c2e..000000000 --- a/MediaBrowser.Common/Security/IRequiresRegistration.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System.Threading.Tasks; - -namespace MediaBrowser.Common.Security -{ - public interface IRequiresRegistration - { - /// <summary> - /// Load all registration information required for this entity. - /// Your class should re-load all MBRegistrationRecords when this is called even if they were - /// previously loaded. - /// </summary> - /// <returns></returns> - Task LoadRegistrationInfoAsync(); - } -} diff --git a/MediaBrowser.Common/Security/ISecurityManager.cs b/MediaBrowser.Common/Security/ISecurityManager.cs deleted file mode 100644 index b47511c33..000000000 --- a/MediaBrowser.Common/Security/ISecurityManager.cs +++ /dev/null @@ -1,49 +0,0 @@ -using MediaBrowser.Model.Entities; -using System.Threading.Tasks; - -namespace MediaBrowser.Common.Security -{ - public interface ISecurityManager - { - /// <summary> - /// Gets a value indicating whether this instance is MB supporter. - /// </summary> - /// <value><c>true</c> if this instance is MB supporter; otherwise, <c>false</c>.</value> - bool IsMBSupporter { get; } - - /// <summary> - /// Gets or sets the supporter key. - /// </summary> - /// <value>The supporter key.</value> - string SupporterKey { get; set; } - - /// <summary> - /// Gets the registration status. Overload to support existing plug-ins. - /// </summary> - /// <param name="feature">The feature.</param> - /// <param name="mb2Equivalent">The MB2 equivalent.</param> - /// <returns>Task{MBRegistrationRecord}.</returns> - Task<MBRegistrationRecord> GetRegistrationStatus(string feature, string mb2Equivalent = null); - - /// <summary> - /// Gets the registration status. - /// </summary> - /// <param name="feature">The feature.</param> - /// <param name="mb2Equivalent">The MB2 equivalent.</param> - /// <param name="version">The version of the feature</param> - /// <returns>Task{MBRegistrationRecord}.</returns> - Task<MBRegistrationRecord> GetRegistrationStatus(string feature, string mb2Equivalent, string version); - - /// <summary> - /// Load all registration info for all entities that require registration - /// </summary> - /// <returns></returns> - Task LoadAllRegistrationInfo(); - - /// <summary> - /// Register and app store sale with our back-end - /// </summary> - /// <param name="parameters">Json parameters to pass to admin server</param> - Task RegisterAppStoreSale(string parameters); - } -}
\ No newline at end of file diff --git a/MediaBrowser.Common/Security/PaymentRequiredException.cs b/MediaBrowser.Common/Security/PaymentRequiredException.cs deleted file mode 100644 index 27b3e6961..000000000 --- a/MediaBrowser.Common/Security/PaymentRequiredException.cs +++ /dev/null @@ -1,8 +0,0 @@ -using System; - -namespace MediaBrowser.Common.Security -{ - public class PaymentRequiredException : Exception - { - } -} diff --git a/MediaBrowser.Common/Updates/GithubUpdater.cs b/MediaBrowser.Common/Updates/GithubUpdater.cs deleted file mode 100644 index 4275799a9..000000000 --- a/MediaBrowser.Common/Updates/GithubUpdater.cs +++ /dev/null @@ -1,278 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using MediaBrowser.Common.Net; -using MediaBrowser.Model.Serialization; -using MediaBrowser.Model.Updates; - -namespace MediaBrowser.Common.Updates -{ - public class GithubUpdater - { - private readonly IHttpClient _httpClient; - private readonly IJsonSerializer _jsonSerializer; - - public GithubUpdater(IHttpClient httpClient, IJsonSerializer jsonSerializer) - { - _httpClient = httpClient; - _jsonSerializer = jsonSerializer; - } - - public async Task<CheckForUpdateResult> CheckForUpdateResult(string organzation, string repository, Version minVersion, PackageVersionClass updateLevel, string assetFilename, string packageName, string targetFilename, TimeSpan cacheLength, CancellationToken cancellationToken) - { - var url = string.Format("https://api.github.com/repos/{0}/{1}/releases", organzation, repository); - - var options = new HttpRequestOptions - { - Url = url, - EnableKeepAlive = false, - CancellationToken = cancellationToken, - UserAgent = "Emby/3.0", - BufferContent = false - }; - - if (cacheLength.Ticks > 0) - { - options.CacheMode = CacheMode.Unconditional; - options.CacheLength = cacheLength; - } - - using (var response = await _httpClient.SendAsync(options, "GET").ConfigureAwait(false)) - { - using (var stream = response.Content) - { - var obj = _jsonSerializer.DeserializeFromStream<RootObject[]>(stream); - - return CheckForUpdateResult(obj, minVersion, updateLevel, assetFilename, packageName, targetFilename); - } - } - } - - private CheckForUpdateResult CheckForUpdateResult(RootObject[] obj, Version minVersion, PackageVersionClass updateLevel, string assetFilename, string packageName, string targetFilename) - { - if (updateLevel == PackageVersionClass.Release) - { - // Technically all we need to do is check that it's not pre-release - // But let's addititional checks for -beta and -dev to handle builds that might be temporarily tagged incorrectly. - obj = obj.Where(i => !i.prerelease && !i.name.EndsWith("-beta", StringComparison.OrdinalIgnoreCase) && !i.name.EndsWith("-dev", StringComparison.OrdinalIgnoreCase)).ToArray(); - } - else if (updateLevel == PackageVersionClass.Beta) - { - obj = obj.Where(i => i.prerelease && i.name.EndsWith("-beta", StringComparison.OrdinalIgnoreCase)).ToArray(); - } - else if (updateLevel == PackageVersionClass.Dev) - { - obj = obj.Where(i => !i.prerelease || i.name.EndsWith("-beta", StringComparison.OrdinalIgnoreCase) || i.name.EndsWith("-dev", StringComparison.OrdinalIgnoreCase)).ToArray(); - } - - var availableUpdate = obj - .Select(i => CheckForUpdateResult(i, minVersion, assetFilename, packageName, targetFilename)) - .Where(i => i != null) - .OrderByDescending(i => Version.Parse(i.AvailableVersion)) - .FirstOrDefault(); - - return availableUpdate ?? new CheckForUpdateResult - { - IsUpdateAvailable = false - }; - } - - private bool MatchesUpdateLevel(RootObject i, PackageVersionClass updateLevel) - { - if (updateLevel == PackageVersionClass.Beta) - { - return i.prerelease && i.name.EndsWith("-beta", StringComparison.OrdinalIgnoreCase); - } - if (updateLevel == PackageVersionClass.Dev) - { - return !i.prerelease || i.name.EndsWith("-beta", StringComparison.OrdinalIgnoreCase) || - i.name.EndsWith("-dev", StringComparison.OrdinalIgnoreCase); - } - - // Technically all we need to do is check that it's not pre-release - // But let's addititional checks for -beta and -dev to handle builds that might be temporarily tagged incorrectly. - return !i.prerelease && !i.name.EndsWith("-beta", StringComparison.OrdinalIgnoreCase) && - !i.name.EndsWith("-dev", StringComparison.OrdinalIgnoreCase); - } - - public async Task<List<RootObject>> GetLatestReleases(string organzation, string repository, string assetFilename, CancellationToken cancellationToken) - { - var list = new List<RootObject>(); - - var url = string.Format("https://api.github.com/repos/{0}/{1}/releases", organzation, repository); - - var options = new HttpRequestOptions - { - Url = url, - EnableKeepAlive = false, - CancellationToken = cancellationToken, - UserAgent = "Emby/3.0", - BufferContent = false - }; - - using (var response = await _httpClient.SendAsync(options, "GET").ConfigureAwait(false)) - { - using (var stream = response.Content) - { - var obj = _jsonSerializer.DeserializeFromStream<RootObject[]>(stream); - - obj = obj.Where(i => (i.assets ?? new List<Asset>()).Any(a => IsAsset(a, assetFilename, i.tag_name))).ToArray(); - - list.AddRange(obj.Where(i => MatchesUpdateLevel(i, PackageVersionClass.Release)).OrderByDescending(GetVersion).Take(1)); - list.AddRange(obj.Where(i => MatchesUpdateLevel(i, PackageVersionClass.Beta)).OrderByDescending(GetVersion).Take(1)); - list.AddRange(obj.Where(i => MatchesUpdateLevel(i, PackageVersionClass.Dev)).OrderByDescending(GetVersion).Take(1)); - - return list; - } - } - } - - public Version GetVersion(RootObject obj) - { - Version version; - if (!Version.TryParse(obj.tag_name, out version)) - { - return new Version(1, 0); - } - - return version; - } - - private CheckForUpdateResult CheckForUpdateResult(RootObject obj, Version minVersion, string assetFilename, string packageName, string targetFilename) - { - Version version; - var versionString = obj.tag_name; - if (!Version.TryParse(versionString, out version)) - { - return null; - } - - if (version < minVersion) - { - return null; - } - - var asset = (obj.assets ?? new List<Asset>()).FirstOrDefault(i => IsAsset(i, assetFilename, versionString)); - - if (asset == null) - { - return null; - } - - return new CheckForUpdateResult - { - AvailableVersion = version.ToString(), - IsUpdateAvailable = version > minVersion, - Package = new PackageVersionInfo - { - classification = obj.prerelease ? - (obj.name.EndsWith("-dev", StringComparison.OrdinalIgnoreCase) ? PackageVersionClass.Dev : PackageVersionClass.Beta) : - PackageVersionClass.Release, - name = packageName, - sourceUrl = asset.browser_download_url, - targetFilename = targetFilename, - versionStr = version.ToString(), - requiredVersionStr = "1.0.0", - description = obj.body, - infoUrl = obj.html_url - } - }; - } - - private bool IsAsset(Asset asset, string assetFilename, string version) - { - var downloadFilename = Path.GetFileName(asset.browser_download_url) ?? string.Empty; - - assetFilename = assetFilename.Replace("{version}", version); - - if (downloadFilename.IndexOf(assetFilename, StringComparison.OrdinalIgnoreCase) != -1) - { - return true; - } - - return string.Equals(assetFilename, downloadFilename, StringComparison.OrdinalIgnoreCase); - } - - public class Uploader - { - public string login { get; set; } - public int id { get; set; } - public string avatar_url { get; set; } - public string gravatar_id { get; set; } - public string url { get; set; } - public string html_url { get; set; } - public string followers_url { get; set; } - public string following_url { get; set; } - public string gists_url { get; set; } - public string starred_url { get; set; } - public string subscriptions_url { get; set; } - public string organizations_url { get; set; } - public string repos_url { get; set; } - public string events_url { get; set; } - public string received_events_url { get; set; } - public string type { get; set; } - public bool site_admin { get; set; } - } - - public class Asset - { - public string url { get; set; } - public int id { get; set; } - public string name { get; set; } - public object label { get; set; } - public Uploader uploader { get; set; } - public string content_type { get; set; } - public string state { get; set; } - public int size { get; set; } - public int download_count { get; set; } - public string created_at { get; set; } - public string updated_at { get; set; } - public string browser_download_url { get; set; } - } - - public class Author - { - public string login { get; set; } - public int id { get; set; } - public string avatar_url { get; set; } - public string gravatar_id { get; set; } - public string url { get; set; } - public string html_url { get; set; } - public string followers_url { get; set; } - public string following_url { get; set; } - public string gists_url { get; set; } - public string starred_url { get; set; } - public string subscriptions_url { get; set; } - public string organizations_url { get; set; } - public string repos_url { get; set; } - public string events_url { get; set; } - public string received_events_url { get; set; } - public string type { get; set; } - public bool site_admin { get; set; } - } - - public class RootObject - { - public string url { get; set; } - public string assets_url { get; set; } - public string upload_url { get; set; } - public string html_url { get; set; } - public int id { get; set; } - public string tag_name { get; set; } - public string target_commitish { get; set; } - public string name { get; set; } - public bool draft { get; set; } - public Author author { get; set; } - public bool prerelease { get; set; } - public string created_at { get; set; } - public string published_at { get; set; } - public List<Asset> assets { get; set; } - public string tarball_url { get; set; } - public string zipball_url { get; set; } - public string body { get; set; } - } - } -} diff --git a/MediaBrowser.Common/Updates/IInstallationManager.cs b/MediaBrowser.Common/Updates/IInstallationManager.cs deleted file mode 100644 index dab38b27c..000000000 --- a/MediaBrowser.Common/Updates/IInstallationManager.cs +++ /dev/null @@ -1,121 +0,0 @@ -using MediaBrowser.Common.Plugins; -using MediaBrowser.Model.Events; -using MediaBrowser.Model.Updates; -using System; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; - -namespace MediaBrowser.Common.Updates -{ - public interface IInstallationManager : IDisposable - { - event EventHandler<InstallationEventArgs> PackageInstalling; - event EventHandler<InstallationEventArgs> PackageInstallationCompleted; - event EventHandler<InstallationFailedEventArgs> PackageInstallationFailed; - event EventHandler<InstallationEventArgs> PackageInstallationCancelled; - - /// <summary> - /// The current installations - /// </summary> - List<Tuple<InstallationInfo, CancellationTokenSource>> CurrentInstallations { get; set; } - - /// <summary> - /// The completed installations - /// </summary> - IEnumerable<InstallationInfo> CompletedInstallations { get; } - - /// <summary> - /// Occurs when [plugin uninstalled]. - /// </summary> - event EventHandler<GenericEventArgs<IPlugin>> PluginUninstalled; - - /// <summary> - /// Occurs when [plugin updated]. - /// </summary> - event EventHandler<GenericEventArgs<Tuple<IPlugin, PackageVersionInfo>>> PluginUpdated; - - /// <summary> - /// Occurs when [plugin updated]. - /// </summary> - event EventHandler<GenericEventArgs<PackageVersionInfo>> PluginInstalled; - - /// <summary> - /// Gets all available packages. - /// </summary> - /// <param name="cancellationToken">The cancellation token.</param> - /// <param name="withRegistration">if set to <c>true</c> [with registration].</param> - /// <param name="packageType">Type of the package.</param> - /// <param name="applicationVersion">The application version.</param> - /// <returns>Task{List{PackageInfo}}.</returns> - Task<List<PackageInfo>> GetAvailablePackages(CancellationToken cancellationToken, - bool withRegistration = true, - string packageType = null, - Version applicationVersion = null); - - /// <summary> - /// Gets all available packages from a static resource. - /// </summary> - /// <param name="cancellationToken">The cancellation token.</param> - /// <returns>Task{List{PackageInfo}}.</returns> - Task<List<PackageInfo>> GetAvailablePackagesWithoutRegistrationInfo(CancellationToken cancellationToken); - - /// <summary> - /// Gets the package. - /// </summary> - /// <param name="name">The name.</param> - /// <param name="guid">The assembly guid</param> - /// <param name="classification">The classification.</param> - /// <param name="version">The version.</param> - /// <returns>Task{PackageVersionInfo}.</returns> - Task<PackageVersionInfo> GetPackage(string name, string guid, PackageVersionClass classification, Version version); - - /// <summary> - /// Gets the latest compatible version. - /// </summary> - /// <param name="name">The name.</param> - /// <param name="guid">The assembly guid</param> - /// <param name="currentServerVersion">The current server version.</param> - /// <param name="classification">The classification.</param> - /// <returns>Task{PackageVersionInfo}.</returns> - Task<PackageVersionInfo> GetLatestCompatibleVersion(string name, string guid, Version currentServerVersion, PackageVersionClass classification = PackageVersionClass.Release); - - /// <summary> - /// Gets the latest compatible version. - /// </summary> - /// <param name="availablePackages">The available packages.</param> - /// <param name="name">The name.</param> - /// <param name="guid">The assembly guid</param> - /// <param name="currentServerVersion">The current server version.</param> - /// <param name="classification">The classification.</param> - /// <returns>PackageVersionInfo.</returns> - PackageVersionInfo GetLatestCompatibleVersion(IEnumerable<PackageInfo> availablePackages, string name, string guid, Version currentServerVersion, PackageVersionClass classification = PackageVersionClass.Release); - - /// <summary> - /// Gets the available plugin updates. - /// </summary> - /// <param name="applicationVersion">The current server version.</param> - /// <param name="withAutoUpdateEnabled">if set to <c>true</c> [with auto update enabled].</param> - /// <param name="cancellationToken">The cancellation token.</param> - /// <returns>Task{IEnumerable{PackageVersionInfo}}.</returns> - Task<IEnumerable<PackageVersionInfo>> GetAvailablePluginUpdates(Version applicationVersion, bool withAutoUpdateEnabled, CancellationToken cancellationToken); - - /// <summary> - /// Installs the package. - /// </summary> - /// <param name="package">The package.</param> - /// <param name="isPlugin">if set to <c>true</c> [is plugin].</param> - /// <param name="progress">The progress.</param> - /// <param name="cancellationToken">The cancellation token.</param> - /// <returns>Task.</returns> - /// <exception cref="System.ArgumentNullException">package</exception> - Task InstallPackage(PackageVersionInfo package, bool isPlugin, IProgress<double> progress, CancellationToken cancellationToken); - - /// <summary> - /// Uninstalls a plugin - /// </summary> - /// <param name="plugin">The plugin.</param> - /// <exception cref="System.ArgumentException"></exception> - void UninstallPlugin(IPlugin plugin); - } -}
\ No newline at end of file diff --git a/MediaBrowser.Common/Updates/InstallationEventArgs.cs b/MediaBrowser.Common/Updates/InstallationEventArgs.cs deleted file mode 100644 index 9dc8ead83..000000000 --- a/MediaBrowser.Common/Updates/InstallationEventArgs.cs +++ /dev/null @@ -1,11 +0,0 @@ -using MediaBrowser.Model.Updates; - -namespace MediaBrowser.Common.Updates -{ - public class InstallationEventArgs - { - public InstallationInfo InstallationInfo { get; set; } - - public PackageVersionInfo PackageVersionInfo { get; set; } - } -} diff --git a/MediaBrowser.Common/Updates/InstallationFailedEventArgs.cs b/MediaBrowser.Common/Updates/InstallationFailedEventArgs.cs deleted file mode 100644 index 69dc1ee98..000000000 --- a/MediaBrowser.Common/Updates/InstallationFailedEventArgs.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System; - -namespace MediaBrowser.Common.Updates -{ - public class InstallationFailedEventArgs : InstallationEventArgs - { - public Exception Exception { get; set; } - } -}
\ No newline at end of file |
