aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Controller/Plugins
diff options
context:
space:
mode:
authorLukePulverenti <luke.pulverenti@gmail.com>2013-02-20 20:33:05 -0500
committerLukePulverenti <luke.pulverenti@gmail.com>2013-02-20 20:33:05 -0500
commit767cdc1f6f6a63ce997fc9476911e2c361f9d402 (patch)
tree49add55976f895441167c66cfa95e5c7688d18ce /MediaBrowser.Controller/Plugins
parent845554722efaed872948a9e0f7202e3ef52f1b6e (diff)
Pushing missing changes
Diffstat (limited to 'MediaBrowser.Controller/Plugins')
-rw-r--r--MediaBrowser.Controller/Plugins/BaseConfigurationPage.cs81
-rw-r--r--MediaBrowser.Controller/Plugins/PluginSecurityManager.cs65
2 files changed, 146 insertions, 0 deletions
diff --git a/MediaBrowser.Controller/Plugins/BaseConfigurationPage.cs b/MediaBrowser.Controller/Plugins/BaseConfigurationPage.cs
new file mode 100644
index 000000000..dc9405840
--- /dev/null
+++ b/MediaBrowser.Controller/Plugins/BaseConfigurationPage.cs
@@ -0,0 +1,81 @@
+using MediaBrowser.Common.Plugins;
+using System.IO;
+
+namespace MediaBrowser.Controller.Plugins
+{
+ /// <summary>
+ /// Class BaseConfigurationPage
+ /// </summary>
+ public abstract class BaseConfigurationPage
+ {
+ /// <summary>
+ /// Gets the name.
+ /// </summary>
+ /// <value>The name.</value>
+ public abstract string Name { get; }
+
+ /// <summary>
+ /// Gets the description.
+ /// </summary>
+ /// <value>The description.</value>
+ public virtual string Description
+ {
+ get { return string.Empty; }
+ }
+
+ /// <summary>
+ /// Gets the type of the configuration page.
+ /// </summary>
+ /// <value>The type of the configuration page.</value>
+ public virtual ConfigurationPageType ConfigurationPageType
+ {
+ get { return ConfigurationPageType.PluginConfiguration; }
+ }
+
+ /// <summary>
+ /// Gets the HTML stream from manifest resource.
+ /// </summary>
+ /// <param name="resource">The resource.</param>
+ /// <returns>Stream.</returns>
+ protected Stream GetHtmlStreamFromManifestResource(string resource)
+ {
+ return GetType().Assembly.GetManifestResourceStream(resource);
+ }
+
+ /// <summary>
+ /// Gets the HTML stream.
+ /// </summary>
+ /// <returns>Stream.</returns>
+ public abstract Stream GetHtmlStream();
+
+ /// <summary>
+ /// Gets the name of the plugin.
+ /// </summary>
+ /// <value>The name of the plugin.</value>
+ public virtual string OwnerPluginName
+ {
+ get { return GetOwnerPlugin().Name; }
+ }
+
+ /// <summary>
+ /// Gets the owner plugin.
+ /// </summary>
+ /// <returns>BasePlugin.</returns>
+ public abstract IPlugin GetOwnerPlugin();
+ }
+
+ /// <summary>
+ /// Enum ConfigurationPageType
+ /// </summary>
+ public enum ConfigurationPageType
+ {
+ /// <summary>
+ /// The plugin configuration
+ /// </summary>
+ PluginConfiguration,
+ /// <summary>
+ /// The none
+ /// </summary>
+ None
+ }
+}
diff --git a/MediaBrowser.Controller/Plugins/PluginSecurityManager.cs b/MediaBrowser.Controller/Plugins/PluginSecurityManager.cs
new file mode 100644
index 000000000..341e3582b
--- /dev/null
+++ b/MediaBrowser.Controller/Plugins/PluginSecurityManager.cs
@@ -0,0 +1,65 @@
+using Mediabrowser.Model.Entities;
+using Mediabrowser.PluginSecurity;
+using MediaBrowser.Common.Kernel;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace MediaBrowser.Controller.Plugins
+{
+ public class PluginSecurityManager : BaseManager<Kernel>
+ {
+ private bool? _isMBSupporter;
+ private bool _isMBSupporterInitialized;
+ private object _isMBSupporterSyncLock = new object();
+
+ public bool IsMBSupporter
+ {
+ get
+ {
+ LazyInitializer.EnsureInitialized(ref _isMBSupporter, ref _isMBSupporterInitialized, ref _isMBSupporterSyncLock, () => GetRegistrationStatus("MBSupporter").Result.IsRegistered);
+ return _isMBSupporter.Value;
+ }
+ }
+
+ public PluginSecurityManager(Kernel kernel) : base(kernel)
+ {
+ }
+
+ public async Task<MBRegistrationRecord> GetRegistrationStatus(string feature, string mb2Equivalent = null)
+ {
+ return await MBRegistration.GetRegistrationStatus(feature, mb2Equivalent).ConfigureAwait(false);
+ }
+
+ public string SupporterKey
+ {
+ get { return MBRegistration.SupporterKey; }
+ set {
+ if (value != MBRegistration.SupporterKey)
+ {
+ MBRegistration.SupporterKey = value;
+ // Clear this so it will re-evaluate
+ ResetSupporterInfo();
+ // And we'll need to restart to re-evaluate the status of plug-ins
+ Kernel.NotifyPendingRestart();
+
+ }
+ }
+ }
+
+ public string LegacyKey
+ {
+ get { return MBRegistration.LegacyKey; }
+ set {
+ MBRegistration.LegacyKey = value;
+ // And we'll need to restart to re-evaluate the status of plug-ins
+ Kernel.NotifyPendingRestart();
+ }
+ }
+
+ private void ResetSupporterInfo()
+ {
+ _isMBSupporter = null;
+ _isMBSupporterInitialized = false;
+ }
+ }
+}