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 System.Collections.Generic;
\r
11 using Growl.Connector;
\r
12 using Growl.CoreLibrary;
\r
15 /// Provides all functionality for communicating with Growl for Windows.
\r
18 /// This class is implemented as a static class because:
\r
19 /// 1. It allows nearly all of the Growl-related code to be in one place
\r
20 /// 2. It prevents the main form, queue handler, and any other part of Handbrake from having to declare
\r
21 /// or track any new instance variables
\r
23 public static class GrowlCommunicator
\r
26 /// The <see cref="GrowlConnector"/> that actually talks to Growl
\r
28 private static GrowlConnector growl;
\r
31 /// The Handbrake application instance that is registered with Growl
\r
33 private static Application application;
\r
36 /// Notification shown upon completion of encoding
\r
38 private static NotificationType encodeOrQueueCompleted = new NotificationType("EncodeOrQueue", "HandBrake Status");
\r
41 /// Checks to see if Growl is currently running on the local machine.
\r
44 /// <c>true</c> if Growl is running;
\r
45 /// <c>false</c> otherwise
\r
47 public static bool IsRunning()
\r
51 return growl.IsGrowlRunning();
\r
55 /// Registers Handbrake with the local Growl instance
\r
58 /// This should usually be called at application start-up
\r
60 public static void Register()
\r
63 growl.Register(application, new NotificationType[] { encodeOrQueueCompleted });
\r
67 /// Sends a notification to Growl. (Since Handbrake currently only supports one type of notification with
\r
68 /// static text, this is a shortcut method).
\r
70 /// <param name="title">
\r
73 /// <param name="text">
\r
74 /// The text to display.
\r
76 public static void Notify(string title, string text)
\r
78 Notification notification = new Notification(application.Name, encodeOrQueueCompleted.Name, String.Empty, title, text);
\r
79 growl.Notify(notification);
\r
83 /// Sends a notification to Growl. (This is the more generic version that could be used in the future if
\r
84 /// more notification types are implemented)
\r
86 /// <param name="notificationType">The <see cref="NotificationType">type</see> of notification to send</param>
\r
87 /// <param name="title">The notification title</param>
\r
88 /// <param name="text">The notification text</param>
\r
89 /// <param name="imageUrl">The notification image as a url</param>
\r
90 public static void Notify(NotificationType notificationType, string title, string text, string imageUrl)
\r
92 Notification notification = new Notification(application.Name, notificationType.Name, String.Empty, title, text)
\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