Reverted [20954]: Growl-WithInstaller 0.76. The 1.1.1 framework has some remaining...
[adiumx.git] / Frameworks / Growl-WithInstaller.framework / Versions / A / Headers / GrowlApplicationBridge.h
blob7ac315af31a2fa7b7317ea560c21a8842b263e57
1 //
2 // GrowlApplicationBridge.h
3 // Growl
4 //
5 // Created by Evan Schoenberg on Wed Jun 16 2004.
6 // Copyright 2004-2005 The Growl Project. All rights reserved.
7 //
9 /*!
10 * @header GrowlApplicationBridge.h
11 * @abstract Defines the GrowlApplicationBridge class.
12 * @discussion This header defines the GrowlApplicationBridge class as well as
13 * the GROWL_PREFPANE_BUNDLE_IDENTIFIER constant.
16 #ifndef __GrowlApplicationBridge_h__
17 #define __GrowlApplicationBridge_h__
19 #import <Foundation/Foundation.h>
20 #import "GrowlDefines.h"
22 //Forward declarations
23 @protocol GrowlApplicationBridgeDelegate;
25 /*!
26 * @defined GROWL_PREFPANE_BUNDLE_IDENTIFIER
27 * @discussion The bundle identifier for the Growl prefpane.
29 #define GROWL_PREFPANE_BUNDLE_IDENTIFIER @"com.growl.prefpanel"
31 /*!
32 * @defined GROWL_PREFPANE_NAME
33 * @discussion The file name of the Growl prefpane.
35 #define GROWL_PREFPANE_NAME @"Growl.prefPane"
37 //Internal notification when the user chooses not to install (to avoid continuing to cache notifications awaiting installation)
38 #define GROWL_USER_CHOSE_NOT_TO_INSTALL_NOTIFICATION @"User chose not to install"
40 //------------------------------------------------------------------------------
41 #pragma mark -
43 /*!
44 * @class GrowlApplicationBridge
45 * @abstract A class used to interface with Growl.
46 * @discussion This class provides a means to interface with Growl.
48 * Currently it provides a way to detect if Growl is installed and launch the
49 * GrowlHelperApp if it's not already running.
51 @interface GrowlApplicationBridge : NSObject {
55 /*!
56 * @method isGrowlInstalled
57 * @abstract Detects whether Growl is installed.
58 * @discussion Determines if the Growl prefpane and its helper app are installed.
59 * @result Returns YES if Growl is installed, NO otherwise.
61 + (BOOL) isGrowlInstalled;
63 /*!
64 * @method isGrowlRunning
65 * @abstract Detects whether GrowlHelperApp is currently running.
66 * @discussion Cycles through the process list to find whether GrowlHelperApp is running and returns its findings.
67 * @result Returns YES if GrowlHelperApp is running, NO otherwise.
69 + (BOOL) isGrowlRunning;
71 #pragma mark -
73 /*!
74 * @method setGrowlDelegate:
75 * @abstract Set the object which will be responsible for providing and receiving Growl information.
76 * @discussion This must be called before using GrowlApplicationBridge.
78 * The methods in the GrowlApplicationBridgeDelegate protocol are required
79 * and return the basic information needed to register with Growl.
81 * The methods in the GrowlApplicationBridgeDelegate_InformalProtocol
82 * informal protocol are individually optional. They provide a greater
83 * degree of interaction between the application and growl such as informing
84 * the application when one of its Growl notifications is clicked by the user.
86 * The methods in the GrowlApplicationBridgeDelegate_Installation_InformalProtocol
87 * informal protocol are individually optional and are only applicable when
88 * using the Growl-WithInstaller.framework which allows for automated Growl
89 * installation.
91 * When this method is called, data will be collected from inDelegate, Growl
92 * will be launched if it is not already running, and the application will be
93 * registered with Growl.
95 * If using the Growl-WithInstaller framework, if Growl is already installed
96 * but this copy of the framework has an updated version of Growl, the user
97 * will be prompted to update automatically.
99 * @param inDelegate The delegate for the GrowlApplicationBridge. It must conform to the GrowlApplicationBridgeDelegate protocol.
101 + (void) setGrowlDelegate:(NSObject<GrowlApplicationBridgeDelegate> *)inDelegate;
104 * @method growlDelegate
105 * @abstract Return the object responsible for providing and receiving Growl information.
106 * @discussion See setGrowlDelegate: for details.
107 * @result The Growl delegate.
109 + (NSObject<GrowlApplicationBridgeDelegate> *) growlDelegate;
111 #pragma mark -
114 * @method notifyWithTitle:description:notificationName:iconData:priority:isSticky:clickContext:
115 * @abstract Send a Growl notification.
116 * @discussion This is the preferred means for sending a Growl notification.
117 * The notification name and at least one of the title and description are
118 * required (all three are preferred). All other parameters may be
119 * <code>nil</code> (or 0 or NO as appropriate) to accept default values.
121 * If using the Growl-WithInstaller framework, if Growl is not installed the
122 * user will be prompted to install Growl. If the user cancels, this method
123 * will have no effect until the next application session, at which time when
124 * it is called the user will be prompted again. The user is also given the
125 * option to not be prompted again. If the user does choose to install Growl,
126 * the requested notification will be displayed once Growl is installed and
127 * running.
129 * @param title The title of the notification displayed to the user.
130 * @param description The full description of the notification displayed to the user.
131 * @param notifName The internal name of the notification. Should be human-readable, as it will be displayed in the Growl preference pane.
132 * @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.
133 * @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.
134 * @param isSticky If YES, the notification will remain on screen until clicked. Not all Growl displays support sticky notifications.
135 * @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).
137 + (void) notifyWithTitle:(NSString *)title
138 description:(NSString *)description
139 notificationName:(NSString *)notifName
140 iconData:(NSData *)iconData
141 priority:(signed int)priority
142 isSticky:(BOOL)isSticky
143 clickContext:(id)clickContext;
146 * @method notifyWithTitle:description:notificationName:iconData:priority:isSticky:clickContext:identifier:
147 * @abstract Send a Growl notification.
148 * @discussion This is the preferred means for sending a Growl notification.
149 * The notification name and at least one of the title and description are
150 * required (all three are preferred). All other parameters may be
151 * <code>nil</code> (or 0 or NO as appropriate) to accept default values.
153 * If using the Growl-WithInstaller framework, if Growl is not installed the
154 * user will be prompted to install Growl. If the user cancels, this method
155 * will have no effect until the next application session, at which time when
156 * it is called the user will be prompted again. The user is also given the
157 * option to not be prompted again. If the user does choose to install Growl,
158 * the requested notification will be displayed once Growl is installed and
159 * running.
161 * @param title The title of the notification displayed to the user.
162 * @param description The full description of the notification displayed to the user.
163 * @param notifName The internal name of the notification. Should be human-readable, as it will be displayed in the Growl preference pane.
164 * @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.
165 * @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.
166 * @param isSticky If YES, the notification will remain on screen until clicked. Not all Growl displays support sticky notifications.
167 * @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).
168 * @param identifier An identifier for this notification. Notifications with equal identifiers are coalesced.
170 + (void) notifyWithTitle:(NSString *)title
171 description:(NSString *)description
172 notificationName:(NSString *)notifName
173 iconData:(NSData *)iconData
174 priority:(signed int)priority
175 isSticky:(BOOL)isSticky
176 clickContext:(id)clickContext
177 identifier:(NSString *)identifier;
179 /*! @method notifyWithDictionary:
180 * @abstract Notifies using a userInfo dictionary suitable for passing to
181 * <code>NSDistributedNotificationCenter</code>.
182 * @param userInfo The dictionary to notify with.
183 * @discussion Before Growl 0.6, your application would have posted
184 * notifications using <code>NSDistributedNotificationCenter</code> by
185 * creating a userInfo dictionary with the notification data. This had the
186 * advantage of allowing you to add other data to the dictionary for programs
187 * besides Growl that might be listening.
189 * This method allows you to use such dictionaries without being restricted
190 * to using <code>NSDistributedNotificationCenter</code>. The keys for this dictionary
191 * can be found in GrowlDefines.h.
193 + (void) notifyWithDictionary:(NSDictionary *)userInfo;
195 #pragma mark -
197 /*! @method registerWithDictionary:
198 * @abstract Register your application with Growl without setting a delegate.
199 * @discussion When you call this method with a dictionary,
200 * GrowlApplicationBridge registers your application using that dictionary.
201 * If you pass <code>nil</code>, GrowlApplicationBridge will ask the delegate
202 * (if there is one) for a dictionary, and if that doesn't work, it will look
203 * in your application's bundle for an auto-discoverable plist.
204 * (XXX refer to more information on that)
206 * If you pass a dictionary to this method, it must include the
207 * <code>GROWL_APP_NAME</code> key, unless a delegate is set.
209 * This method is mainly an alternative to the delegate system introduced
210 * with Growl 0.6. Without a delegate, you cannot receive callbacks such as
211 * <code>-growlIsReady</code> (since they are sent to the delegate). You can,
212 * however, set a delegate after registering without one.
214 * This method was introduced in Growl.framework 0.7.
216 + (BOOL) registerWithDictionary:(NSDictionary *)regDict;
218 /*! @method reregisterGrowlNotifications
219 * @abstract Reregister the notifications for this application.
220 * @discussion This method does not normally need to be called. If your
221 * application changes what notifications it is registering with Growl, call
222 * this method to have the Growl delegate's
223 * <code>-registrationDictionaryForGrowl</code> method called again and the
224 * Growl registration information updated.
226 * This method is now implemented using <code>-registerWithDictionary:</code>.
228 + (void) reregisterGrowlNotifications;
230 #pragma mark -
232 /*! @method setWillRegisterWhenGrowlIsReady:
233 * @abstract Tells GrowlApplicationBridge to register with Growl when Growl
234 * launches (or not).
235 * @discussion When Growl has started listening for notifications, it posts a
236 * <code>GROWL_IS_READY</code> notification on the Distributed Notification
237 * Center. GrowlApplicationBridge listens for this notification, using it to
238 * perform various tasks (such as calling your delegate's
239 * <code>-growlIsReady</code> method, if it has one). If this method is
240 * called with <code>YES</code>, one of those tasks will be to reregister
241 * with Growl (in the manner of <code>-reregisterGrowlNotifications</code>).
243 * This attribute is automatically set back to <code>NO</code> (the default)
244 * after every <code>GROWL_IS_READY</code> notification.
245 * @param flag <code>YES</code> if you want GrowlApplicationBridge to register with
246 * Growl when next it is ready; <code>NO</code> if not.
248 + (void) setWillRegisterWhenGrowlIsReady:(BOOL)flag;
249 /*! @method willRegisterWhenGrowlIsReady
250 * @abstract Reports whether GrowlApplicationBridge will register with Growl
251 * when Growl next launches.
252 * @result <code>YES</code> if GrowlApplicationBridge will register with Growl
253 * when next it posts GROWL_IS_READY; <code>NO</code> if not.
255 + (BOOL) willRegisterWhenGrowlIsReady;
257 #pragma mark -
259 /*! @method registrationDictionaryFromDelegate
260 * @abstract Asks the delegate for a registration dictionary.
261 * @discussion If no delegate is set, or if the delegate's
262 * <code>-registrationDictionaryForGrowl</code> method returns
263 * <code>nil</code>, this method returns <code>nil</code>.
265 * This method does not attempt to clean up the dictionary in any way - for
266 * example, if it is missing the <code>GROWL_APP_NAME</code> key, the result
267 * will be missing it too. Use <code>+[GrowlApplicationBridge
268 * registrationDictionaryByFillingInDictionary:]</code> or
269 * <code>+[GrowlApplicationBridge
270 * registrationDictionaryByFillingInDictionary:restrictToKeys:]</code> to try
271 * to fill in missing keys.
273 * This method was introduced in Growl.framework 0.7.
274 * @result A registration dictionary.
276 + (NSDictionary *) registrationDictionaryFromDelegate;
278 /*! @method registrationDictionaryFromBundle:
279 * @abstract Looks in a bundle for a registration dictionary.
280 * @discussion This method looks in a bundle for an auto-discoverable
281 * registration dictionary file using <code>-[NSBundle
282 * pathForResource:ofType:]</code>. If it finds one, it loads the file using
283 * <code>+[NSDictionary dictionaryWithContentsOfFile:]</code> and returns the
284 * result.
286 * If you pass <code>nil</code> as the bundle, the main bundle is examined.
288 * This method does not attempt to clean up the dictionary in any way - for
289 * example, if it is missing the <code>GROWL_APP_NAME</code> key, the result
290 * will be missing it too. Use <code>+[GrowlApplicationBridge
291 * registrationDictionaryByFillingInDictionary:]</code> or
292 * <code>+[GrowlApplicationBridge
293 * registrationDictionaryByFillingInDictionary:restrictToKeys:]</code> to try
294 * to fill in missing keys.
296 * This method was introduced in Growl.framework 0.7.
297 * @result A registration dictionary.
299 + (NSDictionary *) registrationDictionaryFromBundle:(NSBundle *)bundle;
301 /*! @method bestRegistrationDictionary
302 * @abstract Obtains a registration dictionary, filled out to the best of
303 * GrowlApplicationBridge's knowledge.
304 * @discussion This method creates a registration dictionary as best
305 * GrowlApplicationBridge knows how.
307 * First, GrowlApplicationBridge contacts the Growl delegate (if there is
308 * one) and gets the registration dictionary from that. If no such dictionary
309 * was obtained, GrowlApplicationBridge looks in your application's main
310 * bundle for an auto-discoverable registration dictionary file. If that
311 * doesn't exist either, this method returns <code>nil</code>.
313 * Second, GrowlApplicationBridge calls
314 * <code>+registrationDictionaryByFillingInDictionary:</code> with whatever
315 * dictionary was obtained. The result of that method is the result of this
316 * method.
318 * GrowlApplicationBridge uses this method when you call
319 * <code>+setGrowlDelegate:</code>, or when you call
320 * <code>+registerWithDictionary:</code> with <code>nil</code>.
322 * This method was introduced in Growl.framework 0.7.
323 * @result A registration dictionary.
325 + (NSDictionary *) bestRegistrationDictionary;
327 #pragma mark -
329 /*! @method registrationDictionaryByFillingInDictionary:
330 * @abstract Tries to fill in missing keys in a registration dictionary.
331 * @discussion This method examines the passed-in dictionary for missing keys,
332 * and tries to work out correct values for them. As of 0.7, it uses:
334 * Key Value
335 * --- -----
336 * <code>GROWL_APP_NAME</code> <code>CFBundleExecutableName</code>
337 * <code>GROWL_APP_ICON</code> The icon of the application.
338 * <code>GROWL_APP_LOCATION</code> The location of the application.
339 * <code>GROWL_NOTIFICATIONS_DEFAULT</code> <code>GROWL_NOTIFICATIONS_ALL</code>
341 * Keys are only filled in if missing; if a key is present in the dictionary,
342 * its value will not be changed.
344 * This method was introduced in Growl.framework 0.7.
345 * @param regDict The dictionary to fill in.
346 * @result The dictionary with the keys filled in. This is an autoreleased
347 * copy of <code>regDict</code>.
349 + (NSDictionary *) registrationDictionaryByFillingInDictionary:(NSDictionary *)regDict;
350 /*! @method registrationDictionaryByFillingInDictionary:restrictToKeys:
351 * @abstract Tries to fill in missing keys in a registration dictionary.
352 * @discussion This method examines the passed-in dictionary for missing keys,
353 * and tries to work out correct values for them. As of 0.7, it uses:
355 * Key Value
356 * --- -----
357 * <code>GROWL_APP_NAME</code> <code>CFBundleExecutableName</code>
358 * <code>GROWL_APP_ICON</code> The icon of the application.
359 * <code>GROWL_APP_LOCATION</code> The location of the application.
360 * <code>GROWL_NOTIFICATIONS_DEFAULT</code> <code>GROWL_NOTIFICATIONS_ALL</code>
362 * Only those keys that are listed in <code>keys</code> will be filled in.
363 * Other missing keys are ignored. Also, keys are only filled in if missing;
364 * if a key is present in the dictionary, its value will not be changed.
366 * This method was introduced in Growl.framework 0.7.
367 * @param regDict The dictionary to fill in.
368 * @param keys The keys to fill in. If <code>nil</code>, any missing keys are filled in.
369 * @result The dictionary with the keys filled in. This is an autoreleased
370 * copy of <code>regDict</code>.
372 + (NSDictionary *) registrationDictionaryByFillingInDictionary:(NSDictionary *)regDict restrictToKeys:(NSSet *)keys;
374 @end
376 //------------------------------------------------------------------------------
377 #pragma mark -
380 * @protocol GrowlApplicationBridgeDelegate
381 * @abstract Required protocol for the Growl delegate.
382 * @discussion The methods in this protocol are required and are called
383 * automatically as needed by GrowlApplicationBridge. See
384 * <code>+[GrowlApplicationBridge setGrowlDelegate:]</code>.
385 * See also <code>GrowlApplicationBridgeDelegate_InformalProtocol</code>.
388 @protocol GrowlApplicationBridgeDelegate
390 // -registrationDictionaryForGrowl has moved to the informal protocol as of 0.7.
392 @end
394 //------------------------------------------------------------------------------
395 #pragma mark -
398 * @category NSObject(GrowlApplicationBridgeDelegate_InformalProtocol)
399 * @abstract Methods which may be optionally implemented by the GrowlDelegate.
400 * @discussion The methods in this informal protocol will only be called if implemented by the delegate.
402 @interface NSObject (GrowlApplicationBridgeDelegate_InformalProtocol)
405 * @method registrationDictionaryForGrowl
406 * @abstract Return the dictionary used to register this application with Growl.
407 * @discussion The returned dictionary gives Growl the complete list of
408 * notifications this application will ever send, and it also specifies which
409 * notifications should be enabled by default. Each is specified by an array
410 * of <code>NSString</code> objects.
412 * For most applications, these two arrays can be the same (if all sent
413 * notifications should be displayed by default).
415 * The <code>NSString</code> objects of these arrays will correspond to the
416 * <code>notificationName:</code> parameter passed in
417 * <code>+[GrowlApplicationBridge
418 * notifyWithTitle:description:notificationName:iconData:priority:isSticky:clickContext:]</code> calls.
420 * The dictionary should have 2 key object pairs:
421 * key: GROWL_NOTIFICATIONS_ALL object: <code>NSArray</code> of <code>NSString</code> objects
422 * key: GROWL_NOTIFICATIONS_DEFAULT object: <code>NSArray</code> of <code>NSString</code> objects
424 * You do not need to implement this method if you have an auto-discoverable
425 * plist file in your app bundle. (XXX refer to more information on that)
427 * @result The <code>NSDictionary</code> to use for registration.
429 - (NSDictionary *) registrationDictionaryForGrowl;
432 * @method applicationNameForGrowl
433 * @abstract Return the name of this application which will be used for Growl bookkeeping.
434 * @discussion This name is used both internally and in the Growl preferences.
436 * This should remain stable between different versions and incarnations of
437 * your application.
438 * For example, "SurfWriter" is a good app name, whereas "SurfWriter 2.0" and
439 * "SurfWriter Lite" are not.
441 * You do not need to implement this method if you are providing the
442 * application name elsewhere, meaning in an auto-discoverable plist file in
443 * your app bundle (XXX refer to more information on that) or in the result
444 * of -registrationDictionaryForGrowl.
446 * @result The name of the application using Growl.
448 - (NSString *) applicationNameForGrowl;
451 * @method applicationIconDataForGrowl
452 * @abstract Return the <code>NSData</code> to treat as the application icon.
453 * @discussion The delegate may optionally return an <code>NSData</code>
454 * object to use as the application icon; if this is not implemented, the
455 * application's own icon is used. This is not generally needed.
456 * @result The <code>NSData</code> to treat as the application icon.
458 - (NSData *) applicationIconDataForGrowl;
461 * @method growlIsReady
462 * @abstract Informs the delegate that Growl has launched.
463 * @discussion Informs the delegate that Growl (specifically, the
464 * GrowlHelperApp) was launched successfully or was already running. The
465 * application can take actions with the knowledge that Growl is installed and
466 * functional.
468 - (void) growlIsReady;
471 * @method growlNotificationWasClicked:
472 * @abstract Informs the delegate that a Growl notification was clicked.
473 * @discussion Informs the delegate that a Growl notification was clicked. It
474 * is only sent for notifications sent with a non-<code>nil</code>
475 * clickContext, so if you want to receive a message when a notification is
476 * clicked, clickContext must not be <code>nil</code> when calling
477 * <code>+[GrowlApplicationBridge notifyWithTitle: description:notificationName:iconData:priority:isSticky:clickContext:]</code>.
478 * @param clickContext The clickContext passed when displaying the notification originally via +[GrowlApplicationBridge notifyWithTitle:description:notificationName:iconData:priority:isSticky:clickContext:].
480 - (void) growlNotificationWasClicked:(id)clickContext;
483 * @method growlNotificationTimedOut:
484 * @abstract Informs the delegate that a Growl notification timed out.
485 * @discussion Informs the delegate that a Growl notification timed out. It
486 * is only sent for notifications sent with a non-<code>nil</code>
487 * clickContext, so if you want to receive a message when a notification is
488 * clicked, clickContext must not be <code>nil</code> when calling
489 * <code>+[GrowlApplicationBridge notifyWithTitle: description:notificationName:iconData:priority:isSticky:clickContext:]</code>.
490 * @param clickContext The clickContext passed when displaying the notification originally via +[GrowlApplicationBridge notifyWithTitle:description:notificationName:iconData:priority:isSticky:clickContext:].
492 - (void) growlNotificationTimedOut:(id)clickContext;
494 @end
496 #pragma mark -
498 * @category NSObject(GrowlApplicationBridgeDelegate_Installation_InformalProtocol)
499 * @abstract Methods which may be optionally implemented by the Growl delegate when used with Growl-WithInstaller.framework.
500 * @discussion The methods in this informal protocol will only be called if
501 * implemented by the delegate. They allow greater control of the information
502 * presented to the user when installing or upgrading Growl from within your
503 * application when using Growl-WithInstaller.framework.
505 @interface NSObject (GrowlApplicationBridgeDelegate_Installation_InformalProtocol)
508 * @method growlInstallationWindowTitle
509 * @abstract Return the title of the installation window.
510 * @discussion If not implemented, Growl will use a default, localized title.
511 * @result An NSString object to use as the title.
513 - (NSString *)growlInstallationWindowTitle;
516 * @method growlUpdateWindowTitle
517 * @abstract Return the title of the upgrade window.
518 * @discussion If not implemented, Growl will use a default, localized title.
519 * @result An NSString object to use as the title.
521 - (NSString *)growlUpdateWindowTitle;
524 * @method growlInstallationInformation
525 * @abstract Return the information to display when installing.
526 * @discussion This information may be as long or short as desired (the window
527 * will be sized to fit it). It will be displayed to the user as an
528 * explanation of what Growl is and what it can do in your application. It
529 * should probably note that no download is required to install.
531 * If this is not implemented, Growl will use a default, localized explanation.
532 * @result An NSAttributedString object to display.
534 - (NSAttributedString *)growlInstallationInformation;
537 * @method growlUpdateInformation
538 * @abstract Return the information to display when upgrading.
539 * @discussion This information may be as long or short as desired (the window
540 * will be sized to fit it). It will be displayed to the user as an
541 * explanation that an updated version of Growl is included in your
542 * application and no download is required.
544 * If this is not implemented, Growl will use a default, localized explanation.
545 * @result An NSAttributedString object to display.
547 - (NSAttributedString *)growlUpdateInformation;
549 @end
551 //private
552 @interface GrowlApplicationBridge (GrowlInstallationPrompt_private)
553 + (void) _userChoseNotToInstallGrowl;
554 @end
556 #endif /* __GrowlApplicationBridge_h__ */