aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Api/HttpHandlers/PluginsHandler.cs
blob: a1b37ecaba5a3d2dccdf197a6fbf9eb017b1fff2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using MediaBrowser.Common.Net.Handlers;
using MediaBrowser.Controller;
using MediaBrowser.Model.DTO;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Net;
using System.Threading.Tasks;

namespace MediaBrowser.Api.HttpHandlers
{
    /// <summary>
    /// Provides information about installed plugins
    /// </summary>
    [Export(typeof(BaseHandler))]
    public class PluginsHandler : BaseSerializationHandler<IEnumerable<PluginInfo>>
    {
        public override bool HandlesRequest(HttpListenerRequest request)
        {
            return ApiService.IsApiUrlMatch("plugins", request);
        }

        protected override Task<IEnumerable<PluginInfo>> GetObjectToSerialize()
        {
            var plugins = Kernel.Instance.Plugins.Select(p => new PluginInfo
            {
                Name = p.Name,
                Enabled = p.Enabled,
                DownloadToUI = p.DownloadToUi,
                Version = p.Version.ToString(),
                AssemblyFileName = p.AssemblyFileName,
                ConfigurationDateLastModified = p.ConfigurationDateLastModified
            });

            return Task.FromResult(plugins);
        }
    }
}