📄 growlapplicationbridge.h
字号:
//// GrowlApplicationBridge.h// Growl//// Created by Evan Schoenberg on Wed Jun 16 2004.// Copyright 2004-2005 The Growl Project. All rights reserved.///*! * @header GrowlApplicationBridge.h * @abstract Defines the GrowlApplicationBridge class. * @discussion This header defines the GrowlApplicationBridge class as well as * the GROWL_PREFPANE_BUNDLE_IDENTIFIER constant. */#ifndef __GrowlApplicationBridge_h__#define __GrowlApplicationBridge_h__#import <Foundation/Foundation.h>#import "GrowlDefines.h"//Forward declarations@protocol GrowlApplicationBridgeDelegate;/*! * @defined GROWL_PREFPANE_BUNDLE_IDENTIFIER * @discussion The bundle identifier for the Growl prefpane. */#define GROWL_PREFPANE_BUNDLE_IDENTIFIER @"com.growl.prefpanel"/*! * @defined GROWL_PREFPANE_NAME * @discussion The file name of the Growl prefpane. */#define GROWL_PREFPANE_NAME @"Growl.prefPane"//Internal notification when the user chooses not to install (to avoid continuing to cache notifications awaiting installation)#define GROWL_USER_CHOSE_NOT_TO_INSTALL_NOTIFICATION @"User chose not to install"//------------------------------------------------------------------------------#pragma mark -/*! * @class GrowlApplicationBridge * @abstract A class used to interface with Growl. * @discussion This class provides a means to interface with Growl. * * Currently it provides a way to detect if Growl is installed and launch the * GrowlHelperApp if it's not already running. */@interface GrowlApplicationBridge : NSObject {}/*! * @method isGrowlInstalled * @abstract Detects whether Growl is installed. * @discussion Determines if the Growl prefpane and its helper app are installed. * @result Returns YES if Growl is installed, NO otherwise. */+ (BOOL) isGrowlInstalled;/*! * @method isGrowlRunning * @abstract Detects whether GrowlHelperApp is currently running. * @discussion Cycles through the process list to find whether GrowlHelperApp is running and returns its findings. * @result Returns YES if GrowlHelperApp is running, NO otherwise. */+ (BOOL) isGrowlRunning;#pragma mark -/*! * @method setGrowlDelegate: * @abstract Set the object which will be responsible for providing and receiving Growl information. * @discussion This must be called before using GrowlApplicationBridge. * * The methods in the GrowlApplicationBridgeDelegate protocol are required * and return the basic information needed to register with Growl. * * The methods in the GrowlApplicationBridgeDelegate_InformalProtocol * informal protocol are individually optional. They provide a greater * degree of interaction between the application and growl such as informing * the application when one of its Growl notifications is clicked by the user. * * The methods in the GrowlApplicationBridgeDelegate_Installation_InformalProtocol * informal protocol are individually optional and are only applicable when * using the Growl-WithInstaller.framework which allows for automated Growl * installation. * * When this method is called, data will be collected from inDelegate, Growl * will be launched if it is not already running, and the application will be * registered with Growl. * * If using the Growl-WithInstaller framework, if Growl is already installed * but this copy of the framework has an updated version of Growl, the user * will be prompted to update automatically. * * @param inDelegate The delegate for the GrowlApplicationBridge. It must conform to the GrowlApplicationBridgeDelegate protocol. */+ (void) setGrowlDelegate:(NSObject<GrowlApplicationBridgeDelegate> *)inDelegate;/*! * @method growlDelegate * @abstract Return the object responsible for providing and receiving Growl information. * @discussion See setGrowlDelegate: for details. * @result The Growl delegate. */+ (NSObject<GrowlApplicationBridgeDelegate> *) growlDelegate;#pragma mark -/*! * @method notifyWithTitle:description:notificationName:iconData:priority:isSticky:clickContext: * @abstract Send a Growl notification. * @discussion This is the preferred means for sending a Growl notification. * The notification name and at least one of the title and description are * required (all three are preferred). All other parameters may be * <code>nil</code> (or 0 or NO as appropriate) to accept default values. * * If using the Growl-WithInstaller framework, if Growl is not installed the * user will be prompted to install Growl. If the user cancels, this method * will have no effect until the next application session, at which time when * it is called the user will be prompted again. The user is also given the * option to not be prompted again. If the user does choose to install Growl, * the requested notification will be displayed once Growl is installed and * running. * * @param title The title of the notification displayed to the user. * @param description The full description of the notification displayed to the user. * @param notifName The internal name of the notification. Should be human-readable, as it will be displayed in the Growl preference pane. * @param iconData <code>NSData</code> object to show with the notification as its icon. If <code>nil</code>, the application's icon will be used instead. * @param priority The priority of the notification. The default value is 0; positive values are higher priority and negative values are lower priority. Not all Growl displays support priority. * @param isSticky If YES, the notification will remain on screen until clicked. Not all Growl displays support sticky notifications. * @param clickContext A context passed back to the Growl delegate if it implements -(void)growlNotificationWasClicked: and the notification is clicked. Not all display plugins support clicking. The clickContext must be plist-encodable (completely of <code>NSString</code>, <code>NSArray</code>, <code>NSNumber</code>, <code>NSDictionary</code>, and <code>NSData</code> types). */+ (void) notifyWithTitle:(NSString *)title description:(NSString *)description notificationName:(NSString *)notifName iconData:(NSData *)iconData priority:(signed int)priority isSticky:(BOOL)isSticky clickContext:(id)clickContext;/*! * @method notifyWithTitle:description:notificationName:iconData:priority:isSticky:clickContext:identifier: * @abstract Send a Growl notification. * @discussion This is the preferred means for sending a Growl notification. * The notification name and at least one of the title and description are * required (all three are preferred). All other parameters may be * <code>nil</code> (or 0 or NO as appropriate) to accept default values. * * If using the Growl-WithInstaller framework, if Growl is not installed the * user will be prompted to install Growl. If the user cancels, this method * will have no effect until the next application session, at which time when * it is called the user will be prompted again. The user is also given the * option to not be prompted again. If the user does choose to install Growl, * the requested notification will be displayed once Growl is installed and * running. * * @param title The title of the notification displayed to the user. * @param description The full description of the notification displayed to the user. * @param notifName The internal name of the notification. Should be human-readable, as it will be displayed in the Growl preference pane. * @param iconData <code>NSData</code> object to show with the notification as its icon. If <code>nil</code>, the application's icon will be used instead. * @param priority The priority of the notification. The default value is 0; positive values are higher priority and negative values are lower priority. Not all Growl displays support priority. * @param isSticky If YES, the notification will remain on screen until clicked. Not all Growl displays support sticky notifications. * @param clickContext A context passed back to the Growl delegate if it implements -(void)growlNotificationWasClicked: and the notification is clicked. Not all display plugins support clicking. The clickContext must be plist-encodable (completely of <code>NSString</code>, <code>NSArray</code>, <code>NSNumber</code>, <code>NSDictionary</code>, and <code>NSData</code> types). * @param identifier An identifier for this notification. Notifications with equal identifiers are coalesced. */+ (void) notifyWithTitle:(NSString *)title description:(NSString *)description notificationName:(NSString *)notifName iconData:(NSData *)iconData priority:(signed int)priority isSticky:(BOOL)isSticky clickContext:(id)clickContext identifier:(NSString *)identifier;/*! @method notifyWithDictionary: * @abstract Notifies using a userInfo dictionary suitable for passing to * <code>NSDistributedNotificationCenter</code>. * @param userInfo The dictionary to notify with. * @discussion Before Growl 0.6, your application would have posted * notifications using <code>NSDistributedNotificationCenter</code> by * creating a userInfo dictionary with the notification data. This had the * advantage of allowing you to add other data to the dictionary for programs * besides Growl that might be listening. * * This method allows you to use such dictionaries without being restricted * to using <code>NSDistributedNotificationCenter</code>. The keys for this dictionary * can be found in GrowlDefines.h. */+ (void) notifyWithDictionary:(NSDictionary *)userInfo;#pragma mark -/*! @method registerWithDictionary: * @abstract Register your application with Growl without setting a delegate. * @discussion When you call this method with a dictionary, * GrowlApplicationBridge registers your application using that dictionary. * If you pass <code>nil</code>, GrowlApplicationBridge will ask the delegate * (if there is one) for a dictionary, and if that doesn't work, it will look * in your application's bundle for an auto-discoverable plist. * (XXX refer to more information on that) * * If you pass a dictionary to this method, it must include the * <code>GROWL_APP_NAME</code> key, unless a delegate is set. * * This method is mainly an alternative to the delegate system introduced * with Growl 0.6. Without a delegate, you cannot receive callbacks such as * <code>-growlIsReady</code> (since they are sent to the delegate). You can, * however, set a delegate after registering without one. * * This method was introduced in Growl.framework 0.7. */+ (BOOL) registerWithDictionary:(NSDictionary *)regDict;/*! @method reregisterGrowlNotifications * @abstract Reregister the notifications for this application. * @discussion This method does not normally need to be called. If your * application changes what notifications it is registering with Growl, call * this method to have the Growl delegate's * <code>-registrationDictionaryForGrowl</code> method called again and the * Growl registration information updated. * * This method is now implemented using <code>-registerWithDictionary:</code>. */+ (void) reregisterGrowlNotifications;#pragma mark -/*! @method setWillRegisterWhenGrowlIsReady: * @abstract Tells GrowlApplicationBridge to register with Growl when Growl * launches (or not). * @discussion When Growl has started listening for notifications, it posts a * <code>GROWL_IS_READY</code> notification on the Distributed Notification * Center. GrowlApplicationBridge listens for this notification, using it to * perform various tasks (such as calling your delegate's * <code>-growlIsReady</code> method, if it has one). If this method is * called with <code>YES</code>, one of those tasks will be to reregister * with Growl (in the manner of <code>-reregisterGrowlNotifications</code>). * * This attribute is automatically set back to <code>NO</code> (the default) * after every <code>GROWL_IS_READY</code> notification. * @param flag <code>YES</code> if you want GrowlApplicationBridge to register with * Growl when next it is ready; <code>NO</code> if not. */+ (void) setWillRegisterWhenGrowlIsReady:(BOOL)flag;/*! @method willRegisterWhenGrowlIsReady * @abstract Reports whether GrowlApplicationBridge will register with Growl * when Growl next launches. * @result <code>YES</code> if GrowlApplicationBridge will register with Growl * when next it posts GROWL_IS_READY; <code>NO</code> if not. */+ (BOOL) willRegisterWhenGrowlIsReady;#pragma mark -/*! @method registrationDictionaryFromDelegate * @abstract Asks the delegate for a registration dictionary. * @discussion If no delegate is set, or if the delegate's * <code>-registrationDictionaryForGrowl</code> method returns * <code>nil</code>, this method returns <code>nil</code>. * * This method does not attempt to clean up the dictionary in any way - for * example, if it is missing the <code>GROWL_APP_NAME</code> key, the result * will be missing it too. Use <code>+[GrowlApplicationBridge * registrationDictionaryByFillingInDictionary:]</code> or * <code>+[GrowlApplicationBridge * registrationDictionaryByFillingInDictionary:restrictToKeys:]</code> to try * to fill in missing keys. * * This method was introduced in Growl.framework 0.7. * @result A registration dictionary. */+ (NSDictionary *) registrationDictionaryFromDelegate;/*! @method registrationDictionaryFromBundle: * @abstract Looks in a bundle for a registration dictionary.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -