+++ /dev/null
-/* GrowlCommunicator.cs $\r
- This file is part of the HandBrake source code.\r
- Homepage: <http://handbrake.fr>.\r
- It may be used under the terms of the GNU General Public License. */\r
-\r
-namespace Handbrake.Functions\r
-{\r
- using System;\r
- using Growl.Connector;\r
-\r
- /// <summary>\r
- /// Provides all functionality for communicating with Growl for Windows.\r
- /// </summary>\r
- /// <remarks>\r
- /// This class is implemented as a static class because:\r
- /// 1. It allows nearly all of the Growl-related code to be in one place\r
- /// 2. It prevents the main form, queue handler, and any other part of Handbrake from having to declare\r
- /// or track any new instance variables\r
- /// </remarks>\r
- public static class GrowlCommunicator\r
- {\r
- /// <summary>\r
- /// The <see cref="GrowlConnector"/> that actually talks to Growl\r
- /// </summary>\r
- private static GrowlConnector growl;\r
-\r
- /// <summary>\r
- /// The Handbrake application instance that is registered with Growl\r
- /// </summary>\r
- private static Application application;\r
-\r
- /// <summary>\r
- /// Notification shown upon completion of encoding\r
- /// </summary>\r
- private static NotificationType encodeOrQueueCompleted = new NotificationType("EncodeOrQueue", "HandBrake Status");\r
-\r
- /// <summary>\r
- /// Checks to see if Growl is currently running on the local machine.\r
- /// </summary>\r
- /// <returns>\r
- /// <c>true</c> if Growl is running;\r
- /// <c>false</c> otherwise\r
- /// </returns>\r
- public static bool IsRunning()\r
- {\r
- Initialize();\r
-\r
- return growl.IsGrowlRunning();\r
- }\r
-\r
- /// <summary>\r
- /// Registers Handbrake with the local Growl instance\r
- /// </summary>\r
- /// <remarks>\r
- /// This should usually be called at application start-up\r
- /// </remarks>\r
- public static void Register()\r
- {\r
- Initialize();\r
- growl.Register(application, new[] {encodeOrQueueCompleted});\r
- }\r
-\r
- /// <summary>\r
- /// Sends a notification to Growl. (Since Handbrake currently only supports one type of notification with\r
- /// static text, this is a shortcut method).\r
- /// </summary>\r
- /// <param name="title">\r
- /// The title.\r
- /// </param>\r
- /// <param name="text">\r
- /// The text to display.\r
- /// </param>\r
- public static void Notify(string title, string text)\r
- {\r
- Notification notification = new Notification(application.Name, encodeOrQueueCompleted.Name, String.Empty, \r
- title, text);\r
- growl.Notify(notification);\r
- }\r
-\r
- /// <summary>\r
- /// Sends a notification to Growl. (This is the more generic version that could be used in the future if \r
- /// more notification types are implemented)\r
- /// </summary>\r
- /// <param name="notificationType">The <see cref="NotificationType">type</see> of notification to send</param>\r
- /// <param name="title">The notification title</param>\r
- /// <param name="text">The notification text</param>\r
- /// <param name="imageUrl">The notification image as a url</param>\r
- public static void Notify(NotificationType notificationType, string title, string text, string imageUrl)\r
- {\r
- Notification notification = new Notification(application.Name, notificationType.Name, String.Empty, title, \r
- text)\r
- {\r
- Icon = imageUrl\r
- };\r
-\r
- growl.Notify(notification);\r
- }\r
-\r
- /// <summary>\r
- /// Initializes the GrowlCommunicator\r
- /// </summary>\r
- private static void Initialize()\r
- {\r
- if (growl == null)\r
- {\r
- growl = new GrowlConnector\r
- {\r
- EncryptionAlgorithm = Cryptography.SymmetricAlgorithmType.PlainText\r
- };\r
-\r
- application = new Application("Handbrake")\r
- {\r
- Icon = Properties.Resources.logo64\r
- };\r
- }\r
- }\r
- }\r
-}
\ No newline at end of file