2012-09-08 14:52:13 +00:00
|
|
|
|
using MediaBrowser.Common.Net.Handlers;
|
2012-09-04 19:23:15 +00:00
|
|
|
|
using MediaBrowser.Common.Plugins;
|
2012-07-24 14:54:34 +00:00
|
|
|
|
using MediaBrowser.Controller;
|
2012-08-17 13:16:50 +00:00
|
|
|
|
using MediaBrowser.Model.Plugins;
|
2012-09-08 14:52:13 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.ComponentModel.Composition;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Net;
|
|
|
|
|
using System.Threading.Tasks;
|
2012-07-24 14:54:34 +00:00
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Api.HttpHandlers
|
|
|
|
|
{
|
2012-09-08 14:52:13 +00:00
|
|
|
|
[Export(typeof(BaseHandler))]
|
2012-09-02 05:30:25 +00:00
|
|
|
|
public class PluginConfigurationHandler : BaseSerializationHandler<BasePluginConfiguration>
|
2012-07-24 14:54:34 +00:00
|
|
|
|
{
|
2012-09-08 14:52:13 +00:00
|
|
|
|
public override bool HandlesRequest(HttpListenerRequest request)
|
|
|
|
|
{
|
|
|
|
|
return ApiService.IsApiUrlMatch("pluginconfiguration", request);
|
|
|
|
|
}
|
2012-09-19 16:51:37 +00:00
|
|
|
|
|
2012-09-11 18:20:12 +00:00
|
|
|
|
private BasePlugin _plugin;
|
2012-09-04 19:23:15 +00:00
|
|
|
|
private BasePlugin Plugin
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2012-09-11 18:20:12 +00:00
|
|
|
|
if (_plugin == null)
|
2012-09-04 19:23:15 +00:00
|
|
|
|
{
|
|
|
|
|
string name = QueryString["assemblyfilename"];
|
|
|
|
|
|
2012-09-11 18:20:12 +00:00
|
|
|
|
_plugin = Kernel.Instance.Plugins.First(p => p.AssemblyFileName.Equals(name, StringComparison.OrdinalIgnoreCase));
|
2012-09-04 19:23:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-09-11 18:20:12 +00:00
|
|
|
|
return _plugin;
|
2012-09-04 19:23:15 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-19 20:38:31 +00:00
|
|
|
|
protected override Task<BasePluginConfiguration> GetObjectToSerialize()
|
2012-07-24 14:54:34 +00:00
|
|
|
|
{
|
2012-09-11 18:20:12 +00:00
|
|
|
|
return Task.FromResult(Plugin.Configuration);
|
2012-09-04 19:23:15 +00:00
|
|
|
|
}
|
2012-07-24 14:54:34 +00:00
|
|
|
|
|
2012-09-19 16:51:37 +00:00
|
|
|
|
protected override async Task<ResponseInfo> GetResponseInfo()
|
2012-09-04 19:23:15 +00:00
|
|
|
|
{
|
2012-09-19 16:51:37 +00:00
|
|
|
|
var info = await base.GetResponseInfo().ConfigureAwait(false);
|
2012-08-22 02:50:59 +00:00
|
|
|
|
|
2012-09-19 16:51:37 +00:00
|
|
|
|
info.DateLastModified = Plugin.ConfigurationDateLastModified;
|
2012-09-04 19:23:15 +00:00
|
|
|
|
|
2012-09-19 16:51:37 +00:00
|
|
|
|
info.CacheDuration = TimeSpan.FromDays(7);
|
|
|
|
|
|
|
|
|
|
return info;
|
|
|
|
|
}
|
2012-07-24 14:54:34 +00:00
|
|
|
|
}
|
|
|
|
|
}
|