diff --git a/src/Libraries/Growl.Connector.dll b/src/Libraries/Growl.Connector.dll deleted file mode 100644 index ba848ae44..000000000 Binary files a/src/Libraries/Growl.Connector.dll and /dev/null differ diff --git a/src/Libraries/Growl.CoreLibrary.dll b/src/Libraries/Growl.CoreLibrary.dll deleted file mode 100644 index 5e67e08f4..000000000 Binary files a/src/Libraries/Growl.CoreLibrary.dll and /dev/null differ diff --git a/src/NzbDrone.Core/Datastore/Migration/145_remove_growl.cs b/src/NzbDrone.Core/Datastore/Migration/145_remove_growl.cs new file mode 100644 index 000000000..f04bfe163 --- /dev/null +++ b/src/NzbDrone.Core/Datastore/Migration/145_remove_growl.cs @@ -0,0 +1,14 @@ +using FluentMigrator; +using NzbDrone.Core.Datastore.Migration.Framework; + +namespace NzbDrone.Core.Datastore.Migration +{ + [Migration(145)] + public class remove_growl : NzbDroneMigrationBase + { + protected override void MainDbUpgrade() + { + Delete.FromTable("Notifications").Row(new { Implementation = "Growl" }); + } + } +} \ No newline at end of file diff --git a/src/NzbDrone.Core/Indexers/FileList/FileListSettings.cs b/src/NzbDrone.Core/Indexers/FileList/FileListSettings.cs index a61de3447..a90705796 100644 --- a/src/NzbDrone.Core/Indexers/FileList/FileListSettings.cs +++ b/src/NzbDrone.Core/Indexers/FileList/FileListSettings.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using FluentValidation; -using Growl.Connector; using NzbDrone.Core.Annotations; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Validation; diff --git a/src/NzbDrone.Core/Notifications/Growl/Growl.cs b/src/NzbDrone.Core/Notifications/Growl/Growl.cs deleted file mode 100644 index b46c1f7a9..000000000 --- a/src/NzbDrone.Core/Notifications/Growl/Growl.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System.Collections.Generic; -using FluentValidation.Results; -using NzbDrone.Common.Extensions; - -namespace NzbDrone.Core.Notifications.Growl -{ - public class Growl : NotificationBase - { - private readonly IGrowlService _growlService; - - public override string Name => "Growl"; - - - public Growl(IGrowlService growlService) - { - _growlService = growlService; - } - - public override string Link => "http://growl.info/"; - - public override void OnGrab(GrabMessage grabMessage) - { - _growlService.SendNotification(EPISODE_GRABBED_TITLE, grabMessage.Message, "GRAB", Settings.Host, Settings.Port, Settings.Password); - } - - public override void OnDownload(DownloadMessage message) - { - _growlService.SendNotification(EPISODE_DOWNLOADED_TITLE, message.Message, "DOWNLOAD", Settings.Host, Settings.Port, Settings.Password); - } - public override void OnHealthIssue(HealthCheck.HealthCheck message) - { - _growlService.SendNotification(HEALTH_ISSUE_TITLE, message.Message, "HEALTHISSUE", Settings.Host, Settings.Port, Settings.Password); - } - - public override ValidationResult Test() - { - var failures = new List(); - - failures.AddIfNotNull(_growlService.Test(Settings)); - - return new ValidationResult(failures); - } - } -} diff --git a/src/NzbDrone.Core/Notifications/Growl/GrowlService.cs b/src/NzbDrone.Core/Notifications/Growl/GrowlService.cs deleted file mode 100644 index 116800dfe..000000000 --- a/src/NzbDrone.Core/Notifications/Growl/GrowlService.cs +++ /dev/null @@ -1,161 +0,0 @@ -using FluentValidation.Results; -using Growl.Connector; -using Growl.CoreLibrary; -using NzbDrone.Common.Extensions; -using GrowlNotification = Growl.Connector.Notification; -using NLog; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; - -namespace NzbDrone.Core.Notifications.Growl -{ - public interface IGrowlService - { - void SendNotification(string title, string message, string notificationTypeName, string hostname, int port, string password); - ValidationFailure Test(GrowlSettings settings); - } - - public class GrowlService : IGrowlService - { - private readonly Logger _logger; - - private readonly Application _growlApplication = new Application("Sonarr"); - private readonly NotificationType[] _notificationTypes; - - private class GrowlRequestState - { - private AutoResetEvent _autoEvent = new AutoResetEvent(false); - private bool _isError; - private int _code; - private string _description; - - public void Wait(int timeoutMs) - { - try - { - if (!_autoEvent.WaitOne(timeoutMs)) - { - throw new GrowlException(ErrorCode.TIMED_OUT, ErrorDescription.TIMED_OUT, null); - } - if (_isError) - { - throw new GrowlException(_code, _description, null); - } - } - finally - { - _autoEvent.Reset(); - _isError = false; - _code = 0; - _description = null; - } - } - - public void Update() - { - _autoEvent.Set(); - } - - public void Update(int code, string description) - { - _code = code; - _description = description; - _isError = true; - _autoEvent.Set(); - } - } - - public GrowlService(Logger logger) - { - _logger = logger; - _notificationTypes = GetNotificationTypes(); - - var logo = typeof(GrowlService).Assembly.GetManifestResourceBytes("NzbDrone.Core.Resources.Logo.64.png"); - - _growlApplication.Icon = new BinaryData(logo); - } - - private GrowlConnector GetGrowlConnector(string hostname, int port, string password) - { - var growlConnector = new GrowlConnector(password, hostname, port); - growlConnector.OKResponse += GrowlOKResponse; - growlConnector.ErrorResponse += GrowlErrorResponse; - return growlConnector; - } - - public void SendNotification(string title, string message, string notificationTypeName, string hostname, int port, string password) - { - _logger.Debug("Sending Notification to: {0}:{1}", hostname, port); - - var notificationType = _notificationTypes.Single(n => n.Name == notificationTypeName); - var notification = new GrowlNotification(_growlApplication.Name, notificationType.Name, DateTime.Now.Ticks.ToString(), title, message); - - var growlConnector = GetGrowlConnector(hostname, port, password); - - var requestState = new GrowlRequestState(); - growlConnector.Notify(notification, requestState); - requestState.Wait(5000); - } - - private void Register(string host, int port, string password) - { - _logger.Debug("Registering Sonarr with Growl host: {0}:{1}", host, port); - - var growlConnector = GetGrowlConnector(host, port, password); - - var requestState = new GrowlRequestState(); - growlConnector.Register(_growlApplication, _notificationTypes, requestState); - requestState.Wait(5000); - } - - private void GrowlErrorResponse(Response response, object state) - { - var requestState = state as GrowlRequestState; - if (requestState != null) - { - requestState.Update(response.ErrorCode, response.ErrorDescription); - } - } - - private void GrowlOKResponse(Response response, object state) - { - var requestState = state as GrowlRequestState; - if (requestState != null) - { - requestState.Update(); - } - } - - private NotificationType[] GetNotificationTypes() - { - var notificationTypes = new List(); - notificationTypes.Add(new NotificationType("TEST", "Test")); - notificationTypes.Add(new NotificationType("GRAB", "Episode Grabbed")); - notificationTypes.Add(new NotificationType("DOWNLOAD", "Episode Complete")); - - return notificationTypes.ToArray(); - } - - public ValidationFailure Test(GrowlSettings settings) - { - try - { - Register(settings.Host, settings.Port, settings.Password); - - const string title = "Test Notification"; - const string body = "This is a test message from Sonarr"; - - SendNotification(title, body, "TEST", settings.Host, settings.Port, settings.Password); - } - catch (Exception ex) - { - _logger.Error(ex, "Unable to send test message"); - return new ValidationFailure("Host", "Unable to send test message"); - } - - return null; - } - } -} diff --git a/src/NzbDrone.Core/Notifications/Growl/GrowlSettings.cs b/src/NzbDrone.Core/Notifications/Growl/GrowlSettings.cs deleted file mode 100644 index d8942fac8..000000000 --- a/src/NzbDrone.Core/Notifications/Growl/GrowlSettings.cs +++ /dev/null @@ -1,42 +0,0 @@ -using FluentValidation; -using NzbDrone.Core.Annotations; -using NzbDrone.Core.ThingiProvider; -using NzbDrone.Core.Validation; - -namespace NzbDrone.Core.Notifications.Growl -{ - public class GrowlSettingsValidator : AbstractValidator - { - public GrowlSettingsValidator() - { - RuleFor(c => c.Host).ValidHost(); - RuleFor(c => c.Port).InclusiveBetween(1, 65535); - } - } - - public class GrowlSettings : IProviderConfig - { - private static readonly GrowlSettingsValidator Validator = new GrowlSettingsValidator(); - - public GrowlSettings() - { - Port = 23053; - } - - [FieldDefinition(0, Label = "Host")] - public string Host { get; set; } - - [FieldDefinition(1, Label = "Port")] - public int Port { get; set; } - - [FieldDefinition(2, Label = "Password", Privacy = PrivacyLevel.Password)] - public string Password { get; set; } - - public bool IsValid => !string.IsNullOrWhiteSpace(Host) && !string.IsNullOrWhiteSpace(Password) && Port > 0; - - public NzbDroneValidationResult Validate() - { - return new NzbDroneValidationResult(Validator.Validate(this)); - } - } -}