2020-03-21 02:23:57 +00:00
|
|
|
using System.ComponentModel;
|
2013-10-12 18:44:40 +00:00
|
|
|
using FluentValidation;
|
2013-06-12 06:45:25 +00:00
|
|
|
using Newtonsoft.Json;
|
2022-12-05 08:57:21 +00:00
|
|
|
using NzbDrone.Common.Extensions;
|
2013-05-19 23:17:32 +00:00
|
|
|
using NzbDrone.Core.Annotations;
|
2013-09-21 06:39:26 +00:00
|
|
|
using NzbDrone.Core.ThingiProvider;
|
2015-03-17 04:33:34 +00:00
|
|
|
using NzbDrone.Core.Validation;
|
2013-05-19 23:17:32 +00:00
|
|
|
|
|
|
|
namespace NzbDrone.Core.Notifications.Xbmc
|
|
|
|
{
|
2013-10-12 18:44:40 +00:00
|
|
|
public class XbmcSettingsValidator : AbstractValidator<XbmcSettings>
|
|
|
|
{
|
|
|
|
public XbmcSettingsValidator()
|
|
|
|
{
|
2015-03-31 21:52:27 +00:00
|
|
|
RuleFor(c => c.Host).ValidHost();
|
2015-01-16 07:12:49 +00:00
|
|
|
RuleFor(c => c.DisplayTime).GreaterThanOrEqualTo(2);
|
2013-10-12 18:44:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-21 06:39:26 +00:00
|
|
|
public class XbmcSettings : IProviderConfig
|
2013-05-19 23:17:32 +00:00
|
|
|
{
|
2013-10-12 18:44:40 +00:00
|
|
|
private static readonly XbmcSettingsValidator Validator = new XbmcSettingsValidator();
|
|
|
|
|
2013-07-18 07:08:32 +00:00
|
|
|
public XbmcSettings()
|
|
|
|
{
|
2013-08-09 06:22:26 +00:00
|
|
|
Port = 8080;
|
2016-04-07 22:45:11 +00:00
|
|
|
DisplayTime = 5;
|
2013-07-18 07:08:32 +00:00
|
|
|
}
|
|
|
|
|
2013-05-20 04:19:54 +00:00
|
|
|
[FieldDefinition(0, Label = "Host")]
|
2015-10-03 17:45:26 +00:00
|
|
|
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")]
|
2015-10-03 17:45:26 +00:00
|
|
|
public int Port { get; set; }
|
2013-05-19 23:17:32 +00:00
|
|
|
|
2024-01-03 20:41:16 +00:00
|
|
|
[FieldDefinition(2, Label = "UseSsl", Type = FieldType.Checkbox, HelpText = "NotificationsSettingsUseSslHelpText")]
|
|
|
|
[FieldToken(TokenField.HelpText, "UseSsl", "serviceName", "Kodi")]
|
2021-04-24 17:43:26 +00:00
|
|
|
public bool UseSsl { get; set; }
|
|
|
|
|
2024-02-28 05:03:35 +00:00
|
|
|
[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)]
|
2015-10-03 17:45:26 +00:00
|
|
|
public string Username { get; set; }
|
2013-05-19 23:17:32 +00:00
|
|
|
|
2024-02-28 05:03:35 +00:00
|
|
|
[FieldDefinition(5, Label = "Password", Type = FieldType.Password, Privacy = PrivacyLevel.Password)]
|
2015-10-03 17:45:26 +00:00
|
|
|
public string Password { get; set; }
|
2013-05-19 23:17:32 +00:00
|
|
|
|
2013-07-18 07:08:32 +00:00
|
|
|
[DefaultValue(5)]
|
2024-02-28 05:03:35 +00:00
|
|
|
[FieldDefinition(6, Label = "NotificationsKodiSettingsDisplayTime", HelpText = "NotificationsKodiSettingsDisplayTimeHelpText")]
|
2015-10-03 17:45:26 +00:00
|
|
|
public int DisplayTime { get; set; }
|
2013-07-18 07:08:32 +00:00
|
|
|
|
2024-02-28 05:03:35 +00:00
|
|
|
[FieldDefinition(7, Label = "NotificationsKodiSettingsGuiNotification", Type = FieldType.Checkbox)]
|
2015-10-03 17:45:26 +00:00
|
|
|
public bool Notify { get; set; }
|
2013-05-20 04:19:54 +00:00
|
|
|
|
2024-02-28 05:03:35 +00:00
|
|
|
[FieldDefinition(8, Label = "NotificationsSettingsUpdateLibrary", HelpText = "NotificationsKodiSettingsUpdateLibraryHelpText", Type = FieldType.Checkbox)]
|
2015-10-03 17:45:26 +00:00
|
|
|
public bool UpdateLibrary { get; set; }
|
2013-05-19 23:17:32 +00:00
|
|
|
|
2024-02-28 05:03:35 +00:00
|
|
|
[FieldDefinition(9, Label = "NotificationsKodiSettingsCleanLibrary", HelpText = "NotificationsKodiSettingsCleanLibraryHelpText", Type = FieldType.Checkbox)]
|
2015-10-03 17:45:26 +00:00
|
|
|
public bool CleanLibrary { get; set; }
|
2013-05-19 23:17:32 +00:00
|
|
|
|
2024-02-28 05:03:35 +00:00
|
|
|
[FieldDefinition(10, Label = "NotificationsKodiSettingAlwaysUpdate", HelpText = "NotificationsKodiSettingAlwaysUpdateHelpText", Type = FieldType.Checkbox)]
|
2015-10-03 17:45:26 +00:00
|
|
|
public bool AlwaysUpdate { get; set; }
|
2013-05-19 23:17:32 +00:00
|
|
|
|
2013-06-12 06:45:25 +00:00
|
|
|
[JsonIgnore]
|
2022-12-05 08:57:21 +00:00
|
|
|
public string Address => $"{Host.ToUrlHost()}:{Port}";
|
2014-08-01 06:51:34 +00:00
|
|
|
|
2015-03-17 04:33:34 +00:00
|
|
|
public NzbDroneValidationResult Validate()
|
2014-08-01 06:51:34 +00:00
|
|
|
{
|
2015-03-17 04:33:34 +00:00
|
|
|
return new NzbDroneValidationResult(Validator.Validate(this));
|
2014-08-01 06:51:34 +00:00
|
|
|
}
|
2013-05-19 23:17:32 +00:00
|
|
|
}
|
|
|
|
}
|