From 57c876a42045996fd429715af81cd32e0844e05c Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Thu, 18 Jul 2013 00:08:32 -0700 Subject: [PATCH] Added Notification display time to XBMC --- .../Notifications/Xbmc/HttpApiProvider.cs | 2 +- .../Notifications/Xbmc/JsonApiProvider.cs | 3 ++- .../Notifications/Xbmc/TestXbmcCommand.cs | 1 + .../Notifications/Xbmc/XbmcService.cs | 3 ++- .../Notifications/Xbmc/XbmcSettings.cs | 18 ++++++++++++++---- 5 files changed, 20 insertions(+), 7 deletions(-) diff --git a/NzbDrone.Core/Notifications/Xbmc/HttpApiProvider.cs b/NzbDrone.Core/Notifications/Xbmc/HttpApiProvider.cs index 2e4a36487..9186b98da 100644 --- a/NzbDrone.Core/Notifications/Xbmc/HttpApiProvider.cs +++ b/NzbDrone.Core/Notifications/Xbmc/HttpApiProvider.cs @@ -26,7 +26,7 @@ namespace NzbDrone.Core.Notifications.Xbmc public void Notify(XbmcSettings settings, string title, string message) { - var notification = String.Format("Notification({0},{1},{2},{3})", title, message, 5000, "https://raw.github.com/NzbDrone/NzbDrone/vnext/NzbDrone.Core/NzbDrone.jpg"); + var notification = String.Format("Notification({0},{1},{2},{3})", title, message, settings.DisplayTime * 1000, "https://raw.github.com/NzbDrone/NzbDrone/vnext/NzbDrone.Core/NzbDrone.jpg"); var command = BuildExecBuiltInCommand(notification); SendCommand(settings, command); diff --git a/NzbDrone.Core/Notifications/Xbmc/JsonApiProvider.cs b/NzbDrone.Core/Notifications/Xbmc/JsonApiProvider.cs index fc5e9af47..061588bbd 100644 --- a/NzbDrone.Core/Notifications/Xbmc/JsonApiProvider.cs +++ b/NzbDrone.Core/Notifications/Xbmc/JsonApiProvider.cs @@ -27,7 +27,8 @@ namespace NzbDrone.Core.Notifications.Xbmc var parameters = new JObject( new JProperty("title", title), new JProperty("message", message), - new JProperty("image", "https://raw.github.com/NzbDrone/NzbDrone/vnext/NzbDrone.Core/NzbDrone.jpg")); + new JProperty("image", "https://raw.github.com/NzbDrone/NzbDrone/vnext/NzbDrone.Core/NzbDrone.jpg"), + new JProperty("displaytime", settings.DisplayTime * 1000)); var postJson = BuildJsonRequest("GUI.ShowNotification", parameters); diff --git a/NzbDrone.Core/Notifications/Xbmc/TestXbmcCommand.cs b/NzbDrone.Core/Notifications/Xbmc/TestXbmcCommand.cs index f49ea6ded..56eb75ee8 100644 --- a/NzbDrone.Core/Notifications/Xbmc/TestXbmcCommand.cs +++ b/NzbDrone.Core/Notifications/Xbmc/TestXbmcCommand.cs @@ -8,5 +8,6 @@ namespace NzbDrone.Core.Notifications.Xbmc public int Port { get; set; } public string Username { get; set; } public string Password { get; set; } + public int DisplayTime { get; set; } } } diff --git a/NzbDrone.Core/Notifications/Xbmc/XbmcService.cs b/NzbDrone.Core/Notifications/Xbmc/XbmcService.cs index 133d7d54a..4ac54eb06 100644 --- a/NzbDrone.Core/Notifications/Xbmc/XbmcService.cs +++ b/NzbDrone.Core/Notifications/Xbmc/XbmcService.cs @@ -105,7 +105,8 @@ namespace NzbDrone.Core.Notifications.Xbmc Host = message.Host, Port = message.Port, Username = message.Username, - Password = message.Password + Password = message.Password, + DisplayTime = message.DisplayTime }; Logger.Trace("Determining version of XBMC Host: {0}", settings.Address); diff --git a/NzbDrone.Core/Notifications/Xbmc/XbmcSettings.cs b/NzbDrone.Core/Notifications/Xbmc/XbmcSettings.cs index e42ca7598..bf69be494 100644 --- a/NzbDrone.Core/Notifications/Xbmc/XbmcSettings.cs +++ b/NzbDrone.Core/Notifications/Xbmc/XbmcSettings.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.Linq; using System.Text; using Newtonsoft.Json; @@ -9,6 +10,11 @@ namespace NzbDrone.Core.Notifications.Xbmc { public class XbmcSettings : INotifcationSettings { + public XbmcSettings() + { + DisplayTime = 5; + } + [FieldDefinition(0, Label = "Host")] public String Host { get; set; } @@ -21,16 +27,20 @@ namespace NzbDrone.Core.Notifications.Xbmc [FieldDefinition(3, Label = "Password", Type = FieldType.Password)] public String Password { get; set; } - [FieldDefinition(4, Label = "GUI Notification", HelpText = "Show GUI notifications?", Type = FieldType.Checkbox)] + [DefaultValue(5)] + [FieldDefinition(4, Label = "Display Time", HelpText = "How long the notification will be displayed for (In seconds)")] + public Int32 DisplayTime { get; set; } + + [FieldDefinition(5, Label = "GUI Notification", HelpText = "Show GUI notifications?", Type = FieldType.Checkbox)] public Boolean Notify { get; set; } - [FieldDefinition(5, Label = "Update Library", HelpText = "Update Library on Download & Rename?", Type = FieldType.Checkbox)] + [FieldDefinition(6, Label = "Update Library", HelpText = "Update Library on Download & Rename?", Type = FieldType.Checkbox)] public Boolean UpdateLibrary { get; set; } - [FieldDefinition(6, Label = "Clean Library", HelpText = "Clean Library after update?", Type = FieldType.Checkbox)] + [FieldDefinition(7, Label = "Clean Library", HelpText = "Clean Library after update?", Type = FieldType.Checkbox)] public Boolean CleanLibrary { get; set; } - [FieldDefinition(7, Label = "Always Update", HelpText = "Update Library even when a video is playing?", Type = FieldType.Checkbox)] + [FieldDefinition(8, Label = "Always Update", HelpText = "Update Library even when a video is playing?", Type = FieldType.Checkbox)] public Boolean AlwaysUpdate { get; set; } [JsonIgnore]