Create IRequiresRegistration. First part of #31

pull/702/head
Eric Reed 12 years ago
parent 133047a495
commit d3b37a73cc

@ -226,6 +226,8 @@ namespace MediaBrowser.Common.Implementations
Task.Run(() => ConfigureAutoRunAtStartup()); Task.Run(() => ConfigureAutoRunAtStartup());
Task.Run(() => SecurityManager.LoadAllRegistrationInfo());
ConfigurationManager.ConfigurationUpdated += ConfigurationManager_ConfigurationUpdated; ConfigurationManager.ConfigurationUpdated += ConfigurationManager_ConfigurationUpdated;
}); });
} }

@ -1,4 +1,5 @@
using MediaBrowser.Common.Configuration; using System.Collections.Generic;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Security; using MediaBrowser.Common.Security;
using MediaBrowser.Model.Serialization; using MediaBrowser.Model.Serialization;
using Mediabrowser.Model.Entities; using Mediabrowser.Model.Entities;
@ -7,6 +8,7 @@ using MediaBrowser.Common.Net;
using System; using System;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Linq;
namespace MediaBrowser.Common.Implementations.Security namespace MediaBrowser.Common.Implementations.Security
{ {
@ -44,6 +46,7 @@ namespace MediaBrowser.Common.Implementations.Security
private IHttpClient _httpClient; private IHttpClient _httpClient;
private IJsonSerializer _jsonSerializer; private IJsonSerializer _jsonSerializer;
private IApplicationHost _appHost; private IApplicationHost _appHost;
private IEnumerable<IRequiresRegistration> _registeredEntities;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="PluginSecurityManager" /> class. /// Initializes a new instance of the <see cref="PluginSecurityManager" /> class.
@ -58,9 +61,23 @@ namespace MediaBrowser.Common.Implementations.Security
_appHost = appHost; _appHost = appHost;
_httpClient = httpClient; _httpClient = httpClient;
_jsonSerializer = jsonSerializer; _jsonSerializer = jsonSerializer;
_registeredEntities = _appHost.GetExports<IRequiresRegistration>();
MBRegistration.Init(appPaths); MBRegistration.Init(appPaths);
} }
/// <summary>
/// Load all registration info for all entities that require registration
/// </summary>
/// <returns></returns>
public async Task LoadAllRegistrationInfo()
{
var tasks = new List<Task>();
tasks.AddRange(_registeredEntities.Select(i => i.LoadRegistrationInfoAsync()));
await Task.WhenAll(tasks);
ResetSupporterInfo();
}
/// <summary> /// <summary>
/// Gets the registration status. /// Gets the registration status.
/// </summary> /// </summary>

@ -100,6 +100,7 @@
<Compile Include="ScheduledTasks\IntervalTrigger.cs" /> <Compile Include="ScheduledTasks\IntervalTrigger.cs" />
<Compile Include="ScheduledTasks\TaskCompletionEventArgs.cs" /> <Compile Include="ScheduledTasks\TaskCompletionEventArgs.cs" />
<Compile Include="ScheduledTasks\WeeklyTrigger.cs" /> <Compile Include="ScheduledTasks\WeeklyTrigger.cs" />
<Compile Include="Security\IRequiresRegistration.cs" />
<Compile Include="Security\ISecurityManager.cs" /> <Compile Include="Security\ISecurityManager.cs" />
<Compile Include="Updates\IPackageManager.cs" /> <Compile Include="Updates\IPackageManager.cs" />
</ItemGroup> </ItemGroup>

@ -0,0 +1,9 @@
using System.Threading.Tasks;
namespace MediaBrowser.Common.Security
{
public interface IRequiresRegistration
{
Task LoadRegistrationInfoAsync();
}
}

@ -30,5 +30,11 @@ namespace MediaBrowser.Common.Security
/// <param name="mb2Equivalent">The MB2 equivalent.</param> /// <param name="mb2Equivalent">The MB2 equivalent.</param>
/// <returns>Task{MBRegistrationRecord}.</returns> /// <returns>Task{MBRegistrationRecord}.</returns>
Task<MBRegistrationRecord> GetRegistrationStatus(string feature, string mb2Equivalent = null); Task<MBRegistrationRecord> GetRegistrationStatus(string feature, string mb2Equivalent = null);
/// <summary>
/// Load all registration info for all entities that require registration
/// </summary>
/// <returns></returns>
Task LoadAllRegistrationInfo();
} }
} }
Loading…
Cancel
Save