2 using System.Collections.Generic;
\r
4 using Growl.Connector;
\r
5 using Growl.CoreLibrary;
\r
7 namespace Handbrake.Functions
\r
10 /// Provides all functionality for communicating with Growl for Windows.
\r
13 /// This class is implemented as a static class because:
\r
14 /// 1. It allows nearly all of the Growl-related code to be in one place
\r
15 /// 2. It prevents the main form, queue handler, and any other part of Handbrake from having to declare
\r
16 /// or track any new instance variables
\r
18 public static class GrowlCommunicator
\r
21 /// The <see cref="GrowlConnector"/> that actually talks to Growl
\r
23 private static GrowlConnector growl;
\r
26 /// The Handbrake application instance that is registered with Growl
\r
28 private static Application application;
\r
31 /// Notification shown upon completion of encoding
\r
33 public static NotificationType EncodingComplete;
\r
37 /// Checks to see if Growl is currently running on the local machine.
\r
40 /// <c>true</c> if Growl is running;
\r
41 /// <c>false</c> otherwise
\r
43 public static bool IsRunning()
\r
47 return growl.IsGrowlRunning();
\r
51 /// Registers Handbrake with the local Growl instance
\r
54 /// This should usually be called at application start-up
\r
56 public static void Register()
\r
60 growl.Register(application, new NotificationType[] { EncodingComplete });
\r
64 /// Sends a notification to Growl. (Since Handbrake currently only supports one type of notification with
\r
65 /// static text, this is a shortcut method).
\r
67 public static void Notify()
\r
69 string title = "Encoding Complete";
\r
70 string text = "Put down that cocktail...\nyour Handbrake encode is done.";
\r
71 Notification notification = new Notification(application.Name, EncodingComplete.Name, String.Empty, title, text);
\r
73 growl.Notify(notification);
\r
77 /// Sends a notification to Growl. (This is the more generic version that could be used in the future if
\r
78 /// more notification types are implemented)
\r
80 /// <param name="notificationType">The <see cref="NotificationType">type</see> of notification to send</param>
\r
81 /// <param name="title">The notification title</param>
\r
82 /// <param name="text">The notification text</param>
\r
83 /// <param name="imageUrl">The notification image as a url</param>
\r
84 public static void Notify(NotificationType notificationType, string title, string text, string imageUrl)
\r
86 Notification notification = new Notification(application.Name, notificationType.Name, String.Empty, title, text);
\r
87 notification.Icon = imageUrl;
\r
89 growl.Notify(notification);
\r
93 /// Initializes the GrowlCommunicator
\r
95 private static void Initialize()
\r
99 growl = new GrowlConnector();
\r
100 growl.EncryptionAlgorithm = Cryptography.SymmetricAlgorithmType.PlainText;
\r
102 application = new Application("Handbrake");
\r
103 application.Icon = global::Handbrake.Properties.Resources.logo64;
\r
105 EncodingComplete = new NotificationType("Encoding Complete");
\r