1 /* GrowlCommunicator.cs $
\r
2 This file is part of the HandBrake source code.
\r
3 Homepage: <http://handbrake.fr>.
\r
4 It may be used under the terms of the GNU General Public License. */
\r
6 namespace Handbrake.Functions
\r
9 using Growl.Connector;
\r
12 /// Provides all functionality for communicating with Growl for Windows.
\r
15 /// This class is implemented as a static class because:
\r
16 /// 1. It allows nearly all of the Growl-related code to be in one place
\r
17 /// 2. It prevents the main form, queue handler, and any other part of Handbrake from having to declare
\r
18 /// or track any new instance variables
\r
20 public static class GrowlCommunicator
\r
23 /// The <see cref="GrowlConnector"/> that actually talks to Growl
\r
25 private static GrowlConnector growl;
\r
28 /// The Handbrake application instance that is registered with Growl
\r
30 private static Application application;
\r
33 /// Notification shown upon completion of encoding
\r
35 private static NotificationType encodeOrQueueCompleted = new NotificationType("EncodeOrQueue",
\r
36 "HandBrake Status");
\r
39 /// Checks to see if Growl is currently running on the local machine.
\r
42 /// <c>true</c> if Growl is running;
\r
43 /// <c>false</c> otherwise
\r
45 public static bool IsRunning()
\r
49 return growl.IsGrowlRunning();
\r
53 /// Registers Handbrake with the local Growl instance
\r
56 /// This should usually be called at application start-up
\r
58 public static void Register()
\r
61 growl.Register(application, new[] {encodeOrQueueCompleted});
\r
65 /// Sends a notification to Growl. (Since Handbrake currently only supports one type of notification with
\r
66 /// static text, this is a shortcut method).
\r
68 /// <param name="title">
\r
71 /// <param name="text">
\r
72 /// The text to display.
\r
74 public static void Notify(string title, string text)
\r
76 Notification notification = new Notification(application.Name, encodeOrQueueCompleted.Name, String.Empty,
\r
78 growl.Notify(notification);
\r
82 /// Sends a notification to Growl. (This is the more generic version that could be used in the future if
\r
83 /// more notification types are implemented)
\r
85 /// <param name="notificationType">The <see cref="NotificationType">type</see> of notification to send</param>
\r
86 /// <param name="title">The notification title</param>
\r
87 /// <param name="text">The notification text</param>
\r
88 /// <param name="imageUrl">The notification image as a url</param>
\r
89 public static void Notify(NotificationType notificationType, string title, string text, string imageUrl)
\r
91 Notification notification = new Notification(application.Name, notificationType.Name, String.Empty, title,
\r
97 growl.Notify(notification);
\r
101 /// Initializes the GrowlCommunicator
\r
103 private static void Initialize()
\r
107 growl = new GrowlConnector
\r
109 EncryptionAlgorithm = Cryptography.SymmetricAlgorithmType.PlainText
\r
112 application = new Application("Handbrake")
\r
114 Icon = Properties.Resources.logo64
\r