1 /* GrowlCommunicator.cs $
\r
3 This file is part of the HandBrake source code.
\r
4 Homepage: <http://handbrake.fr>.
\r
5 It may be used under the terms of the GNU General Public License. */
\r
8 using System.Collections.Generic;
\r
10 using Growl.Connector;
\r
11 using Growl.CoreLibrary;
\r
13 namespace Handbrake.Functions
\r
16 /// Provides all functionality for communicating with Growl for Windows.
\r
19 /// This class is implemented as a static class because:
\r
20 /// 1. It allows nearly all of the Growl-related code to be in one place
\r
21 /// 2. It prevents the main form, queue handler, and any other part of Handbrake from having to declare
\r
22 /// or track any new instance variables
\r
24 public static class GrowlCommunicator
\r
27 /// The <see cref="GrowlConnector"/> that actually talks to Growl
\r
29 private static GrowlConnector growl;
\r
32 /// The Handbrake application instance that is registered with Growl
\r
34 private static Application application;
\r
37 /// Notification shown upon completion of encoding
\r
39 public static NotificationType EncodeOrQueueCompleted = new NotificationType("EncodeOrQueue", "HandBrake Status");
\r
42 /// Checks to see if Growl is currently running on the local machine.
\r
45 /// <c>true</c> if Growl is running;
\r
46 /// <c>false</c> otherwise
\r
48 public static bool IsRunning()
\r
52 return growl.IsGrowlRunning();
\r
56 /// Registers Handbrake with the local Growl instance
\r
59 /// This should usually be called at application start-up
\r
61 public static void Register()
\r
64 growl.Register(application, new NotificationType[] { EncodeOrQueueCompleted });
\r
68 /// Sends a notification to Growl. (Since Handbrake currently only supports one type of notification with
\r
69 /// static text, this is a shortcut method).
\r
71 public static void Notify(string title, string text)
\r
73 Notification notification = new Notification(application.Name, EncodeOrQueueCompleted.Name, String.Empty, title, text);
\r
74 growl.Notify(notification);
\r
78 /// Sends a notification to Growl. (This is the more generic version that could be used in the future if
\r
79 /// more notification types are implemented)
\r
81 /// <param name="notificationType">The <see cref="NotificationType">type</see> of notification to send</param>
\r
82 /// <param name="title">The notification title</param>
\r
83 /// <param name="text">The notification text</param>
\r
84 /// <param name="imageUrl">The notification image as a url</param>
\r
85 public static void Notify(NotificationType notificationType, string title, string text, string imageUrl)
\r
87 Notification notification = new Notification(application.Name, notificationType.Name, String.Empty, title, text);
\r
88 notification.Icon = imageUrl;
\r
90 growl.Notify(notification);
\r
94 /// Initializes the GrowlCommunicator
\r
96 private static void Initialize()
\r
100 growl = new GrowlConnector();
\r
101 growl.EncryptionAlgorithm = Cryptography.SymmetricAlgorithmType.PlainText;
\r
103 application = new Application("Handbrake");
\r
104 application.Icon = global::Handbrake.Properties.Resources.logo64;
\r