Radarr/src/NzbDrone.Core/Notifications/Xbmc/XbmcSettings.cs

76 lines
3.0 KiB
C#
Raw Normal View History

using System.ComponentModel;
using FluentValidation;
2013-06-12 06:45:25 +00:00
using Newtonsoft.Json;
using NzbDrone.Common.Extensions;
2013-05-19 23:17:32 +00:00
using NzbDrone.Core.Annotations;
using NzbDrone.Core.ThingiProvider;
using NzbDrone.Core.Validation;
2013-05-19 23:17:32 +00:00
namespace NzbDrone.Core.Notifications.Xbmc
{
public class XbmcSettingsValidator : AbstractValidator<XbmcSettings>
{
public XbmcSettingsValidator()
{
RuleFor(c => c.Host).ValidHost();
RuleFor(c => c.DisplayTime).GreaterThanOrEqualTo(2);
}
}
public class XbmcSettings : IProviderConfig
2013-05-19 23:17:32 +00:00
{
private static readonly XbmcSettingsValidator Validator = new XbmcSettingsValidator();
public XbmcSettings()
{
2013-08-09 06:22:26 +00:00
Port = 8080;
DisplayTime = 5;
}
2013-05-20 04:19:54 +00:00
[FieldDefinition(0, Label = "Host")]
public string Host { get; set; }
2013-05-19 23:17:32 +00:00
2013-05-20 04:19:54 +00:00
[FieldDefinition(1, Label = "Port")]
public int Port { get; set; }
2013-05-19 23:17:32 +00:00
[FieldDefinition(2, Label = "UseSsl", Type = FieldType.Checkbox, HelpText = "NotificationsSettingsUseSslHelpText")]
[FieldToken(TokenField.HelpText, "UseSsl", "serviceName", "Kodi")]
public bool UseSsl { get; set; }
[FieldDefinition(3, Label = "UrlBase", Type = FieldType.Textbox, Advanced = true, HelpText = "ConnectionSettingsUrlBaseHelpText")]
[FieldToken(TokenField.HelpText, "UrlBase", "connectionName", "Kodi")]
[FieldToken(TokenField.HelpText, "UrlBase", "url", "http://[host]:[port]/[urlBase]/kodi")]
public string UrlBase { get; set; }
[FieldDefinition(4, Label = "Username", Privacy = PrivacyLevel.UserName)]
public string Username { get; set; }
2013-05-19 23:17:32 +00:00
[FieldDefinition(5, Label = "Password", Type = FieldType.Password, Privacy = PrivacyLevel.Password)]
public string Password { get; set; }
2013-05-19 23:17:32 +00:00
[DefaultValue(5)]
[FieldDefinition(6, Label = "NotificationsKodiSettingsDisplayTime", HelpText = "NotificationsKodiSettingsDisplayTimeHelpText")]
public int DisplayTime { get; set; }
[FieldDefinition(7, Label = "NotificationsKodiSettingsGuiNotification", Type = FieldType.Checkbox)]
public bool Notify { get; set; }
2013-05-20 04:19:54 +00:00
[FieldDefinition(8, Label = "NotificationsSettingsUpdateLibrary", HelpText = "NotificationsKodiSettingsUpdateLibraryHelpText", Type = FieldType.Checkbox)]
public bool UpdateLibrary { get; set; }
2013-05-19 23:17:32 +00:00
[FieldDefinition(9, Label = "NotificationsKodiSettingsCleanLibrary", HelpText = "NotificationsKodiSettingsCleanLibraryHelpText", Type = FieldType.Checkbox)]
public bool CleanLibrary { get; set; }
2013-05-19 23:17:32 +00:00
[FieldDefinition(10, Label = "NotificationsKodiSettingAlwaysUpdate", HelpText = "NotificationsKodiSettingAlwaysUpdateHelpText", Type = FieldType.Checkbox)]
public bool AlwaysUpdate { get; set; }
2013-05-19 23:17:32 +00:00
2013-06-12 06:45:25 +00:00
[JsonIgnore]
public string Address => $"{Host.ToUrlHost()}:{Port}";
public NzbDroneValidationResult Validate()
{
return new NzbDroneValidationResult(Validator.Validate(this));
}
2013-05-19 23:17:32 +00:00
}
}