From d1a8cd2a84b369e75c9e073660af2ac193db863e Mon Sep 17 00:00:00 2001 From: Taloth Saldono Date: Sat, 9 Aug 2014 14:58:04 +0200 Subject: [PATCH] Readded Growl logo via embedded binary blob. --- src/NzbDrone.Common/NzbDrone.Common.csproj | 1 + src/NzbDrone.Common/ResourceExtensions.cs | 28 +++++++++++++++++++ .../Notifications/Growl/GrowlService.cs | 21 +++++++------- src/NzbDrone.Core/NzbDrone.Core.csproj | 7 ++--- 4 files changed, 43 insertions(+), 14 deletions(-) create mode 100644 src/NzbDrone.Common/ResourceExtensions.cs diff --git a/src/NzbDrone.Common/NzbDrone.Common.csproj b/src/NzbDrone.Common/NzbDrone.Common.csproj index 8d4a98d3d..346c4dc04 100644 --- a/src/NzbDrone.Common/NzbDrone.Common.csproj +++ b/src/NzbDrone.Common/NzbDrone.Common.csproj @@ -138,6 +138,7 @@ + diff --git a/src/NzbDrone.Common/ResourceExtensions.cs b/src/NzbDrone.Common/ResourceExtensions.cs new file mode 100644 index 000000000..2a168a151 --- /dev/null +++ b/src/NzbDrone.Common/ResourceExtensions.cs @@ -0,0 +1,28 @@ +using NzbDrone.Common.EnsureThat; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Text; + +namespace NzbDrone.Common +{ + public static class ResourceExtensions + { + public static Byte[] GetManifestResourceBytes(this Assembly assembly, String name) + { + var stream = assembly.GetManifestResourceStream(name); + + var result = new Byte[stream.Length]; + var read = stream.Read(result, 0, result.Length); + + if (read != result.Length) + { + throw new EndOfStreamException("Reached end of stream before reading enough bytes."); + } + + return result; + } + } +} diff --git a/src/NzbDrone.Core/Notifications/Growl/GrowlService.cs b/src/NzbDrone.Core/Notifications/Growl/GrowlService.cs index b572747c2..d08fbc66d 100644 --- a/src/NzbDrone.Core/Notifications/Growl/GrowlService.cs +++ b/src/NzbDrone.Core/Notifications/Growl/GrowlService.cs @@ -1,13 +1,14 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using FluentValidation.Results; -using Growl.CoreLibrary; +using FluentValidation.Results; using Growl.Connector; -using NLog; +using Growl.CoreLibrary; using GrowlNotification = Growl.Connector.Notification; +using NLog; +using NzbDrone.Common; +using System; +using System.Collections.Generic; using System.IO; +using System.Linq; +using System.Threading; namespace NzbDrone.Core.Notifications.Growl { @@ -72,9 +73,9 @@ namespace NzbDrone.Core.Notifications.Growl _logger = logger; _notificationTypes = GetNotificationTypes(); -// var bytes = File.ReadAllBytes("64.png"); -// -// _growlApplication.Icon = new BinaryData(bytes); + 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) diff --git a/src/NzbDrone.Core/NzbDrone.Core.csproj b/src/NzbDrone.Core/NzbDrone.Core.csproj index eeda53753..a93414f85 100644 --- a/src/NzbDrone.Core/NzbDrone.Core.csproj +++ b/src/NzbDrone.Core/NzbDrone.Core.csproj @@ -794,10 +794,9 @@ - - 64.png - Always - + + Resources\Logo\64.png + Always