source: trunk/Growl.framework/Versions/A/Headers/GrowlApplicationBridge-Carbon.h @ 594

Last change on this file since 594 was 594, checked in by livings124, 16 years ago

Use Growl framework rather than applescript.

File size: 32.6 KB
Line 
1//
2//  GrowlApplicationBridge-Carbon.h
3//  Growl
4//
5//  Created by Mac-arena the Bored Zo on Wed Jun 18 2004.
6//  Based on GrowlApplicationBridge.h by Evan Schoenberg.
7//  This source code is in the public domain. You may freely link it into any
8//    program.
9//
10
11#ifndef _GROWLAPPLICATIONBRIDGE_CARBON_H_
12#define _GROWLAPPLICATIONBRIDGE_CARBON_H_
13
14#include <sys/cdefs.h>
15#include <Carbon/Carbon.h>
16
17/*!     @header GrowlApplicationBridge-Carbon.h
18 *      @abstract       Declares an API that Carbon applications can use to interact with Growl.
19 *      @discussion     GrowlApplicationBridge uses a delegate to provide information //XXX
20 *       to Growl (such as your application's name and what notifications it may
21 *       post) and to provide information to your application (such as that Growl
22 *       is listening for notifications or that a notification has been clicked).
23 *
24 *       You can set the Growldelegate with Growl_SetDelegate and find out the
25 *       current delegate with Growl_GetDelegate. See struct Growl_Delegate for more
26 *       information about the delegate.
27 */
28
29__BEGIN_DECLS
30
31/*!     @struct Growl_Delegate
32 *      @abstract Delegate to supply GrowlApplicationBridge with information and respond to events.
33 *      @discussion The Growl delegate provides your interface to
34 *       GrowlApplicationBridge. When GrowlApplicationBridge needs information about
35 *       your application, it looks for it in the delegate; when Growl or the user
36 *       does something that you might be interested in, GrowlApplicationBridge
37 *       looks for a callback in the delegate and calls it if present
38 *       (meaning, if it is not <code>NULL</code>).
39 *      XXX on all of that
40 *  @field size The size of the delegate structure.
41 *      @field applicationName The name of your application.
42 *      @field registrationDictionary A dictionary describing your application and the notifications it can send out.
43 *      @field applicationIconData Your application's icon.
44 *      @field growlInstallationWindowTitle The title of the installation window.
45 *      @field growlInstallationInformation Text to display in the installation window.
46 *      @field growlUpdateWindowTitle The title of the update window.
47 *      @field growlUpdateInformation Text to display in the update window.
48 *      @field referenceCount A count of owners of the delegate.
49 *      @field retain Called when GrowlApplicationBridge receives this delegate.
50 *      @field release Called when GrowlApplicationBridge no longer needs this delegate.
51 *      @field growlIsReady Called when GrowlHelperApp is listening for notifications.
52 *      @field growlNotificationWasClicked Called when a Growl notification is clicked.
53 *  @field growlNotificationTimedOut Called when a Growl notification timed out.
54 */
55struct Growl_Delegate {
56        /*      @discussion This should be sizeof(struct Growl_Delegate).
57         */
58        size_t size;
59
60        /*All of these attributes are optional.
61         *Optional attributes can be NULL; required attributes that
62         *       are NULL cause setting the Growl delegate to fail.
63         *XXX - move optional/required status into the discussion for each field
64         */
65
66        /* This name is used both internally and in the Growl preferences.
67         *
68         *       This should remain stable between different versions and incarnations of
69         *       your application.
70         *       For example, "SurfWriter" is a good app name, whereas "SurfWriter 2.0" and
71         *       "SurfWriter Lite" are not.
72         *
73         * This can be <code>NULL</code> if it is provided elsewhere, namely in an
74         *       auto-discoverable plist file in your app bundle
75         *       (XXX refer to more information on that) or in registrationDictionary.
76         */
77        CFStringRef applicationName;
78
79        /*
80         * Must contain at least these keys:
81         *      GROWL_NOTIFICATIONS_ALL (CFArray):
82         *              Contains the names of all notifications your application may post.
83         *
84         * Can also contain these keys:
85         *      GROWL_NOTIFICATIONS_DEFAULT (CFArray):
86         *              Names of notifications that should be enabled by default.
87         *              If omitted, GROWL_NOTIFICATIONS_ALL will be used.
88         *      GROWL_APP_NAME (CFString):
89         *              Same as the applicationName member of this structure.
90         *              If both are present, the applicationName member shall prevail.
91         *              If this key is present, you may omit applicationName (set it to <code>NULL</code>).
92         *      GROWL_APP_ICON (CFData):
93         *              Same as the iconData member of this structure.
94         *              If both are present, the iconData member shall prevail.
95         *              If this key is present, you may omit iconData (set it to <code>NULL</code>).
96         *
97         * If you change the contents of this dictionary after setting the delegate,
98         *      be sure to call Growl_Reregister.
99         *
100         * This can be <code>NULL</code> if you have an auto-discoverable plist file in your app
101         *       bundle. (XXX refer to more information on that)
102         */
103        CFDictionaryRef registrationDictionary;
104
105        /* The data can be in any format supported by NSImage. As of
106         *       Mac OS X 10.3, this includes the .icns, TIFF, JPEG, GIF, PNG, PDF, and
107         *       PICT formats.
108         *
109         *       If this is not supplied, Growl will look up your application's icon by
110         *       its application name.
111         */
112        CFDataRef applicationIconData;
113
114        /* Installer display attributes
115         *
116         * These four attributes are used by the Growl installer, if this framework
117         *      supports it.
118         * For any of these being <code>NULL</code>, a localised default will be
119         *      supplied.
120         */
121
122        /*      If this is <code>NULL</code>, Growl will use a default,
123         *       localized title.
124         *
125         *       Only used if you're using Growl-WithInstaller.framework. Otherwise,
126         *       this member is ignored.
127         */
128        CFStringRef growlInstallationWindowTitle;
129        /*      This information may be as long or short as desired (the
130         *       window will be sized to fit it).  If Growl is not installed, it will
131         *       be displayed to the user as an explanation of what Growl is and what
132         *       it can do in your application.
133         *       It should probably note that no download is required to install.
134         *
135         *       If this is <code>NULL</code>, Growl will use a default, localized
136         *       explanation.
137         *
138         *       Only used if you're using Growl-WithInstaller.framework. Otherwise,
139         *       this member is ignored.
140         */
141        CFStringRef growlInstallationInformation;
142        /*      If this is <code>NULL</code>, Growl will use a default,
143         *       localized title.
144         *
145         *       Only used if you're using Growl-WithInstaller.framework. Otherwise,
146         *       this member is ignored.
147         */
148        CFStringRef growlUpdateWindowTitle;
149        /*      This information may be as long or short as desired (the
150         *       window will be sized to fit it).  If an older version of Growl is
151         *       installed, it will be displayed to the user as an explanation that an
152         *       updated version of Growl is included in your application and
153         *       no download is required.
154         *
155         *       If this is <code>NULL</code>, Growl will use a default, localized
156         *       explanation.
157         *
158         *       Only used if you're using Growl-WithInstaller.framework. Otherwise,
159         *       this member is ignored.
160         */
161        CFStringRef growlUpdateInformation;
162
163        /*      This member is provided for use by your retain and release
164         *       callbacks (see below).
165         *
166         *       GrowlApplicationBridge never directly uses this member. Instead, it
167         *       calls your retain callback (if non-<code>NULL</code>) and your release
168         *       callback (if non-<code>NULL</code>).
169         */
170        unsigned referenceCount;
171
172        //Functions. Currently all of these are optional (any of them can be NULL).
173
174        /*      When you call Growl_SetDelegate(newDelegate), it will call
175         *       oldDelegate->release(oldDelegate), and then it will call
176         *       newDelegate->retain(newDelegate), and the return value from retain
177         *       is what will be set as the delegate.
178         *       (This means that this member works like CFRetain and -[NSObject retain].)
179         *       This member is optional (it can be <code>NULL</code>).
180         *       For a delegate allocated with malloc, this member would be
181         *       <code>NULL</code>.
182         *      @result A delegate to which GrowlApplicationBridge holds a reference.
183         */
184        void *(*retain)(void *);
185        /*      When you call Growl_SetDelegate(newDelegate), it will call
186         *       oldDelegate->release(oldDelegate), and then it will call
187         *       newDelegate->retain(newDelegate), and the return value from retain
188         *       is what will be set as the delegate.
189         *       (This means that this member works like CFRelease and
190         *        -[NSObject release].)
191         *       This member is optional (it can be NULL).
192         *       For a delegate allocated with malloc, this member might be
193         *       <code>free</code>(3).
194         */
195        void (*release)(void *);
196
197        /*      Informs the delegate that Growl (specifically, the GrowlHelperApp) was
198         *       launched successfully (or was already running). The application can
199         *       take actions with the knowledge that Growl is installed and functional.
200         */
201        void (*growlIsReady)(void);
202
203        /*      Informs the delegate that a Growl notification was clicked. It is only
204         *       sent for notifications sent with a non-<code>NULL</code> clickContext,
205         *       so if you want to receive a message when a notification is clicked,
206         *       clickContext must not be <code>NULL</code> when calling
207         *       Growl_PostNotification or
208         *       Growl_NotifyWithTitleDescriptionNameIconPriorityStickyClickContext.
209         */
210        void (*growlNotificationWasClicked)(CFPropertyListRef clickContext);
211
212        /*      Informs the delegate that a Growl notification timed out. It is only
213         *       sent for notifications sent with a non-<code>NULL</code> clickContext,
214         *       so if you want to receive a message when a notification is clicked,
215         *       clickContext must not be <code>NULL</code> when calling
216         *       Growl_PostNotification or
217         *       Growl_NotifyWithTitleDescriptionNameIconPriorityStickyClickContext.
218         */
219        void (*growlNotificationTimedOut)(CFPropertyListRef clickContext);
220};
221
222/*!     @struct Growl_Notification
223 *      @abstract Structure describing a Growl notification.
224 *      @discussion XXX
225 *      @field size The size of the notification structure.
226 *      @field name Identifies the notification.
227 *      @field title Short synopsis of the notification.
228 *  @field description Additional text.
229 *      @field iconData An icon for the notification.
230 *      @field priority An indicator of the notification's importance.
231 *      @field reserved Bits reserved for future usage.
232 *      @field isSticky Requests that a notification stay on-screen until dismissed explicitly.
233 *      @field clickContext An identifier to be passed to your click callback when a notification is clicked.
234 *      @field clickCallback A callback to call when the notification is clicked.
235 */
236struct Growl_Notification {
237        /*      This should be sizeof(struct Growl_Notification).
238         */
239        size_t size;
240
241        /*      The notification name distinguishes one type of
242         *       notification from another. The name should be human-readable, as it
243         *       will be displayed in the Growl preference pane.
244         *
245         *       The name is used in the GROWL_NOTIFICATIONS_ALL and
246         *       GROWL_NOTIFICATIONS_DEFAULT arrays in the registration dictionary, and
247         *       in this member of the Growl_Notification structure.
248         */
249        CFStringRef name;
250
251        /*      A notification's title describes the notification briefly.
252         *       It should be easy to read quickly by the user.
253         */
254        CFStringRef title;
255
256        /*      The description supplements the title with more
257         *       information. It is usually longer and sometimes involves a list of
258         *       subjects. For example, for a 'Download complete' notification, the
259         *       description might have one filename per line. GrowlMail in Growl 0.6
260         *       uses a description of '%d new mail(s)' (formatted with the number of
261         *       messages).
262         */
263        CFStringRef description;
264
265        /*      The notification icon usually indicates either what
266         *       happened (it may have the same icon as e.g. a toolbar item that
267         *       started the process that led to the notification), or what it happened
268         *       to (e.g. a document icon).
269         *
270         *       The icon data is optional, so it can be <code>NULL</code>. In that
271         *       case, the application icon is used alone. Not all displays support
272         *       icons.
273         *
274         *       The data can be in any format supported by NSImage. As of Mac OS X
275         *       10.3, this includes the .icns, TIFF, JPEG, GIF, PNG, PDF, and PICT form
276         *       ats.
277         */
278        CFDataRef iconData;
279
280        /*      Priority is new in Growl 0.6, and is represented as a
281         *       signed integer from -2 to +2. 0 is Normal priority, -2 is Very Low
282         *       priority, and +2 is Very High priority.
283         *
284         *       Not all displays support priority. If you do not wish to assign a
285         *       priority to your notification, assign 0.
286         */
287        signed int priority;
288
289        /*      These bits are not used in Growl 0.6. Set them to 0.
290         */
291        unsigned reserved: 31;
292
293        /*      When the sticky bit is clear, in most displays,
294         *       notifications disappear after a certain amount of time. Sticky
295         *       notifications, however, remain on-screen until the user dismisses them
296         *       explicitly, usually by clicking them.
297         *
298         *       Sticky notifications were introduced in Growl 0.6. Most notifications
299         *       should not be sticky. Not all displays support sticky notifications,
300         *       and the user may choose in Growl's preference pane to force the
301         *       notification to be sticky or non-sticky, in which case the sticky bit
302         *       in the notification will be ignored.
303         */
304        unsigned isSticky: 1;
305
306        /*      If this is not <code>NULL</code>, and your click callback
307         *       is not <code>NULL</code> either, this will be passed to the callback
308         *       when your notification is clicked by the user.
309         *
310         *       Click feedback was introduced in Growl 0.6, and it is optional. Not
311         *       all displays support click feedback.
312         */
313        CFPropertyListRef clickContext;
314
315        /*      If this is not <code>NULL</code>, it will be called instead
316         *       of the Growl delegate's click callback when clickContext is
317         *       non-<code>NULL</code> and the notification is clicked on by the user.
318         *
319         *       Click feedback was introduced in Growl 0.6, and it is optional. Not
320         *       all displays support click feedback.
321         *
322         *       The per-notification click callback is not yet supported as of Growl
323         *       0.7.
324         */
325        void (*clickCallback)(CFPropertyListRef clickContext);
326};
327
328#pragma mark -
329#pragma mark Easy initialisers
330
331/*!     @defined        InitGrowlDelegate
332 *      @abstract       Callable macro. Initializes a Growl delegate structure to defaults.
333 *      @discussion     Call with a pointer to a struct Growl_Delegate. All of the
334 *       members of the structure will be set to 0 or <code>NULL</code>, except for
335 *       size (which will be set to <code>sizeof(struct Growl_Delegate)</code>) and
336 *       referenceCount (which will be set to 1).
337 */
338#define InitGrowlDelegate(delegate) \
339        do { \
340                if (delegate) { \
341                        (delegate)->size = sizeof(struct Growl_Delegate); \
342                        (delegate)->applicationName = NULL; \
343                        (delegate)->registrationDictionary = NULL; \
344                        (delegate)->applicationIconData = NULL; \
345                        (delegate)->growlInstallationWindowTitle = NULL; \
346                        (delegate)->growlInstallationInformation = NULL; \
347                        (delegate)->growlUpdateWindowTitle = NULL; \
348                        (delegate)->growlUpdateInformation = NULL; \
349                        (delegate)->referenceCount = 1U; \
350                        (delegate)->retain = NULL; \
351                        (delegate)->release = NULL; \
352                        (delegate)->growlIsReady = NULL; \
353                        (delegate)->growlNotificationWasClicked = NULL; \
354                        (delegate)->growlNotificationTimedOut = NULL; \
355                } \
356        } while(0)
357
358/*!     @defined        InitGrowlNotification
359 *      @abstract       Callable macro. Initializes a Growl notification structure to defaults.
360 *      @discussion     Call with a pointer to a struct Growl_Notification. All of
361 *       the members of the structure will be set to 0 or <code>NULL</code>, except
362 *       for size (which will be set to
363 *      <code>sizeof(struct Growl_Notification)</code>).
364 */
365#define InitGrowlNotification(notification) \
366        do { \
367                if (notification) { \
368                        (notification)->size = sizeof(struct Growl_Notification); \
369                        (notification)->name = NULL; \
370                        (notification)->title = NULL; \
371                        (notification)->description = NULL; \
372                        (notification)->iconData = NULL; \
373                        (notification)->priority = 0; \
374                        (notification)->reserved = 0U; \
375                        (notification)->isSticky = false; \
376                        (notification)->clickContext = NULL; \
377                } \
378        } while(0)
379
380#pragma mark -
381#pragma mark Public API
382
383//      @functiongroup  Managing the Growl delegate
384
385/*!     @function       Growl_SetDelegate
386 *      @abstract       Replaces the current Growl delegate with a new one, or removes
387 *       the Growl delegate.
388 *      @param  newDelegate
389 *      @result Returns false and does nothing else if a pointer that was passed in
390 *       is unsatisfactory (because it is non-<code>NULL</code>, but at least one
391 *       required member of it is <code>NULL</code>). Otherwise, sets or unsets the
392 *       delegate and returns true.
393 *      @discussion     When <code>newDelegate</code> is non-<code>NULL</code>, sets
394 *       the delegate to <code>newDelegate</code>. When it is <code>NULL</code>,
395 *       the current delegate will be unset, and no delegate will be in place.
396 *
397 *       It is legal for <code>newDelegate</code> to be the current delegate;
398 *       nothing will happen, and Growl_SetDelegate will return true. It is also
399 *       legal for it to be <code>NULL</code>, as described above; again, it will
400 *       return true.
401 *
402 *       If there was a delegate in place before the call, Growl_SetDelegate will
403 *       call the old delegate's release member if it was non-<code>NULL</code>. If
404 *       <code>newDelegate</code> is non-<code>NULL</code>, Growl_SetDelegate will
405 *       call <code>newDelegate->retain</code>, and set the delegate to its return
406 *       value.
407 *
408 *       If you are using Growl-WithInstaller.framework, and an older version of
409 *       Growl is installed on the user's system, the user will automatically be
410 *       prompted to update.
411 *
412 *       GrowlApplicationBridge currently does not copy this structure, nor does it
413 *       retain any of the CF objects in the structure (it regards the structure as
414 *       a container that retains the objects when they are added and releases them
415 *       when they are removed or the structure is destroyed). Also,
416 *       GrowlApplicationBridge currently does not modify any member of the
417 *       structure, except possibly the referenceCount by calling the retain and
418 *       release members.
419 */
420Boolean Growl_SetDelegate(struct Growl_Delegate *newDelegate);
421
422/*!     @function       Growl_GetDelegate
423 *      @abstract       Returns the current Growl delegate, if any.
424 *      @result The current Growl delegate.
425 *      @discussion     Returns the last pointer passed into Growl_SetDelegate, or
426 *       <code>NULL</code> if no such call has been made.
427 *
428 *       This function follows standard Core Foundation reference-counting rules.
429 *       Because it is a Get function, not a Copy function, it will not retain the
430 *       delegate on your behalf. You are responsible for retaining and releasing
431 *       the delegate as needed.
432 */
433struct Growl_Delegate *Growl_GetDelegate(void);
434
435#pragma mark -
436
437//      @functiongroup  Posting Growl notifications
438
439/*!     @function       Growl_PostNotification
440 *      @abstract       Posts a Growl notification.
441 *      @param  notification    The notification to post.
442 *      @discussion     This is the preferred means for sending a Growl notification.
443 *       The notification name and at least one of the title and description are
444 *       required (all three are preferred). All other parameters may be
445 *       <code>NULL</code> (or 0 or false as appropriate) to accept default values.
446 *
447 *       If using the Growl-WithInstaller framework, if Growl is not installed the
448 *       user will be prompted to install Growl.
449 *       If the user cancels, this function will have no effect until the next
450 *       application session, at which time when it is called the user will be
451 *       prompted again. The user is also given the option to not be prompted again.
452 *       If the user does choose to install Growl, the requested notification will
453 *       be displayed once Growl is installed and running.
454 */
455void Growl_PostNotification(const struct Growl_Notification *notification);
456
457/*!     @function Growl_PostNotificationWithDictionary
458*       @abstract       Notifies using a userInfo dictionary suitable for passing to
459*        CFDistributedNotificationCenter.
460*       @param  userInfo        The dictionary to notify with.
461*       @discussion     Before Growl 0.6, your application would have posted
462*        notifications using CFDistributedNotificationCenter by creating a userInfo
463*        dictionary with the notification data. This had the advantage of allowing
464*        you to add other data to the dictionary for programs besides Growl that
465*        might be listening.
466*
467*        This function allows you to use such dictionaries without being restricted
468*        to using CFDistributedNotificationCenter. The keys for this dictionary
469 *       can be found in GrowlDefines.h.
470*/
471void Growl_PostNotificationWithDictionary(CFDictionaryRef userInfo);
472
473/*!     @function       Growl_NotifyWithTitleDescriptionNameIconPriorityStickyClickContext
474 *      @abstract       Posts a Growl notification using parameter values.
475 *      @param  title   The title of the notification.
476 *      @param  description     The description of the notification.
477 *      @param  notificationName        The name of the notification as listed in the
478 *       registration dictionary.
479 *      @param  iconData        Data representing a notification icon. Can be <code>NULL</code>.
480 *      @param  priority        The priority of the notification (-2 to +2, with -2
481 *       being Very Low and +2 being Very High).
482 *      @param  isSticky        If true, requests that this notification wait for a
483 *       response from the user.
484 *      @param  clickContext    An object to pass to the clickCallback, if any. Can
485 *       be <code>NULL</code>, in which case the clickCallback is not called.
486 *      @discussion     Creates a temporary Growl_Notification, fills it out with the
487 *       supplied information, and calls Growl_PostNotification on it.
488 *       See struct Growl_Notification and Growl_PostNotification for more
489 *       information.
490 *
491 *       The icon data can be in any format supported by NSImage. As of Mac OS X
492 *       10.3, this includes the .icns, TIFF, JPEG, GIF, PNG, PDF, and PICT formats.
493 */
494void Growl_NotifyWithTitleDescriptionNameIconPriorityStickyClickContext(
495 /*inhale*/
496        CFStringRef title,
497        CFStringRef description,
498        CFStringRef notificationName,
499        CFDataRef iconData,
500        signed int priority,
501        Boolean isSticky,
502        CFPropertyListRef clickContext);
503
504#pragma mark -
505
506//      @functiongroup  Registering
507
508/*!     @function Growl_RegisterWithDictionary
509 *      @abstract       Register your application with Growl without setting a delegate.
510 *      @discussion     When you call this function with a dictionary,
511 *       GrowlApplicationBridge registers your application using that dictionary.
512 *       If you pass <code>NULL</code>, GrowlApplicationBridge will ask the delegate
513 *       (if there is one) for a dictionary, and if that doesn't work, it will look
514 *       in your application's bundle for an auto-discoverable plist.
515 *       (XXX refer to more information on that)
516 *
517 *       If you pass a dictionary to this function, it must include the
518 *       <code>GROWL_APP_NAME</code> key, unless a delegate is set.
519 *
520 *       This function is mainly an alternative to the delegate system introduced
521 *       with Growl 0.6. Without a delegate, you cannot receive callbacks such as
522 *       <code>growlIsReady</code> (since they are sent to the delegate). You can,
523 *       however, set a delegate after registering without one.
524 *
525 *       This function was introduced in Growl.framework 0.7.
526 *      @result <code>false</code> if registration failed (e.g. if Growl isn't installed).
527 */
528Boolean Growl_RegisterWithDictionary(CFDictionaryRef regDict);
529
530/*!     @function       Growl_Reregister
531 *      @abstract       Updates your registration with Growl.
532 *      @discussion     If your application changes the contents of the
533 *       GROWL_NOTIFICATIONS_ALL key in the registrationDictionary member of the
534 *       Growl delegate, or if it changes the value of that member, or if it
535 *       changes the contents of its auto-discoverable plist, call this function
536 *       to have Growl update its registration information for your application.
537 *
538 *       Otherwise, this function does not normally need to be called. If you're
539 *       using a delegate, your application will be registered when you set the
540 *       delegate if both the delegate and its registrationDictionary member are
541 *       non-<code>NULL</code>.
542 *
543 *       This function is now implemented using
544 *       <code>Growl_RegisterWithDictionary</code>.
545 */
546void Growl_Reregister(void);
547
548#pragma mark -
549
550/*!     @function       Growl_SetWillRegisterWhenGrowlIsReady
551 *      @abstract       Tells GrowlApplicationBridge to register with Growl when Growl
552 *       launches (or not).
553 *      @discussion     When Growl has started listening for notifications, it posts a
554 *       <code>GROWL_IS_READY</code> notification on the Distributed Notification
555 *       Center. GrowlApplicationBridge listens for this notification, using it to
556 *       perform various tasks (such as calling your delegate's
557 *       <code>growlIsReady</code> callback, if it has one). If this function is
558 *       called with <code>true</code>, one of those tasks will be to reregister
559 *       with Growl (in the manner of <code>Growl_Reregister</code>).
560 *
561 *       This attribute is automatically set back to <code>false</code>
562 *       (the default) after every <code>GROWL_IS_READY</code> notification.
563 *      @param  flag    <code>true</code> if you want GrowlApplicationBridge to register with
564 *       Growl when next it is ready; <code>false</code> if not.
565 */
566void Growl_SetWillRegisterWhenGrowlIsReady(Boolean flag);
567/*!     @function       Growl_WillRegisterWhenGrowlIsReady
568 *      @abstract       Reports whether GrowlApplicationBridge will register with Growl
569 *       when Growl next launches.
570 *      @result <code>true</code> if GrowlApplicationBridge will register with
571 *       Growl when next it posts GROWL_IS_READY; <code>false</code> if not.
572 */
573Boolean Growl_WillRegisterWhenGrowlIsReady(void);
574
575#pragma mark -
576
577//      @functiongroup  Obtaining registration dictionaries
578
579/*!     @function       Growl_CopyRegistrationDictionaryFromDelegate
580 *      @abstract       Asks the delegate for a registration dictionary.
581 *      @discussion     If no delegate is set, or if the delegate's
582 *       <code>registrationDictionary</code> member is <code>NULL</code>, this
583 *       function returns <code>NULL</code>.
584 *
585 *       This function does not attempt to clean up the dictionary in any way - for
586 *       example, if it is missing the <code>GROWL_APP_NAME</code> key, the result
587 *       will be missing it too. Use
588 *       <code>Growl_CreateRegistrationDictionaryByFillingInDictionary:</code> or
589 *       <code>Growl_CreateRegistrationDictionaryByFillingInDictionaryRestrictedToKeys</code>
590 *       to try to fill in missing keys.
591 *
592 *       This function was introduced in Growl.framework 0.7.
593 *      @result A registration dictionary.
594 */
595CFDictionaryRef Growl_CopyRegistrationDictionaryFromDelegate(void);
596
597/*!     @function       Growl_CopyRegistrationDictionaryFromBundle
598 *      @abstract       Looks in a bundle for a registration dictionary.
599 *      @discussion     This function looks in a bundle for an auto-discoverable
600 *       registration dictionary file using <code>CFBundleCopyResourceURL</code>.
601 *       If it finds one, it loads the file using <code>CFPropertyList</code> and
602 *       returns the result.
603 *
604 *       If you pass <code>NULL</code> as the bundle, the main bundle is examined.
605 *
606 *       This function does not attempt to clean up the dictionary in any way - for
607 *       example, if it is missing the <code>GROWL_APP_NAME</code> key, the result
608 *       will be missing it too. Use
609 *       <code>Growl_CreateRegistrationDictionaryByFillingInDictionary:</code> or
610 *       <code>Growl_CreateRegistrationDictionaryByFillingInDictionaryRestrictedToKeys</code>
611 *       to try to fill in missing keys.
612 *
613 *       This function was introduced in Growl.framework 0.7.
614 *      @result A registration dictionary.
615 */
616CFDictionaryRef Growl_CopyRegistrationDictionaryFromBundle(CFBundleRef bundle);
617
618/*!     @function       Growl_CreateBestRegistrationDictionary
619 *      @abstract       Obtains a registration dictionary, filled out to the best of
620 *       GrowlApplicationBridge's knowledge.
621 *      @discussion     This function creates a registration dictionary as best
622 *       GrowlApplicationBridge knows how.
623 *
624 *       First, GrowlApplicationBridge examines the Growl delegate (if there is
625 *       one) and gets the registration dictionary from that. If no such dictionary
626 *       was obtained, GrowlApplicationBridge looks in your application's main
627 *       bundle for an auto-discoverable registration dictionary file. If that
628 *       doesn't exist either, this function returns <code>NULL</code>.
629 *
630 *       Second, GrowlApplicationBridge calls
631 *       <code>Growl_CreateRegistrationDictionaryByFillingInDictionary</code> with
632 *       whatever dictionary was obtained. The result of that function is the
633 *       result of this function.
634 *
635 *       GrowlApplicationBridge uses this function when you call
636 *       <code>Growl_SetDelegate</code>, or when you call
637 *       <code>Growl_RegisterWithDictionary</code> with <code>NULL</code>.
638 *
639 *       This function was introduced in Growl.framework 0.7.
640 *      @result A registration dictionary.
641 */
642CFDictionaryRef Growl_CreateBestRegistrationDictionary(void);
643
644#pragma mark -
645
646//      @functiongroup  Filling in registration dictionaries
647
648/*!     @function       Growl_CreateRegistrationDictionaryByFillingInDictionary
649 *      @abstract       Tries to fill in missing keys in a registration dictionary.
650 *      @param  regDict The dictionary to fill in.
651 *      @result The dictionary with the keys filled in.
652 *      @discussion     This function examines the passed-in dictionary for missing keys,
653 *       and tries to work out correct values for them. As of 0.7, it uses:
654 *
655 *       Key                                                                 Value
656 *       ---                                                                 -----
657 *       <code>GROWL_APP_NAME</code>                 <code>CFBundleExecutableName</code>
658 *       <code>GROWL_APP_ICON</code>                 The icon of the application.
659 *       <code>GROWL_APP_LOCATION</code>             The location of the application.
660 *       <code>GROWL_NOTIFICATIONS_DEFAULT</code>    <code>GROWL_NOTIFICATIONS_ALL</code>
661 *
662 *       Keys are only filled in if missing; if a key is present in the dictionary,
663 *       its value will not be changed.
664 *
665 *       This function was introduced in Growl.framework 0.7.
666 */
667CFDictionaryRef Growl_CreateRegistrationDictionaryByFillingInDictionary(CFDictionaryRef regDict);
668/*!     @function       Growl_CreateRegistrationDictionaryByFillingInDictionaryRestrictedToKeys
669 *      @abstract       Tries to fill in missing keys in a registration dictionary.
670 *      @param  regDict The dictionary to fill in.
671 *      @param  keys    The keys to fill in. If <code>NULL</code>, any missing keys are filled in.
672 *      @result The dictionary with the keys filled in.
673 *      @discussion     This function examines the passed-in dictionary for missing keys,
674 *       and tries to work out correct values for them. As of 0.7, it uses:
675 *
676 *       Key                                                                 Value
677 *       ---                                                                 -----
678 *       <code>GROWL_APP_NAME</code>                 <code>CFBundleExecutableName</code>
679 *       <code>GROWL_APP_ICON</code>                 The icon of the application.
680 *       <code>GROWL_APP_LOCATION</code>             The location of the application.
681 *       <code>GROWL_NOTIFICATIONS_DEFAULT</code>    <code>GROWL_NOTIFICATIONS_ALL</code>
682 *
683 *       Only those keys that are listed in <code>keys</code> will be filled in.
684 *       Other missing keys are ignored. Also, keys are only filled in if missing;
685 *       if a key is present in the dictionary, its value will not be changed.
686 *
687 *       This function was introduced in Growl.framework 0.7.
688 */
689CFDictionaryRef Growl_CreateRegistrationDictionaryByFillingInDictionaryRestrictedToKeys(CFDictionaryRef regDict, CFSetRef keys);
690
691#pragma mark -
692
693//      @functiongroup  Querying Growl's status
694
695/*!     @function       Growl_IsInstalled
696 *      @abstract       Determines whether the Growl prefpane and its helper app are
697 *       installed.
698 *      @result Returns true if Growl is installed, false otherwise.
699 */
700Boolean Growl_IsInstalled(void);
701
702/*!     @function       Growl_IsRunning
703 *      @abstract       Cycles through the process list to find whether GrowlHelperApp
704 *       is running.
705 *      @result Returns true if Growl is running, false otherwise.
706 */
707Boolean Growl_IsRunning(void);
708
709#pragma mark -
710
711//      @functiongroup  Launching Growl
712
713/*!     @typedef        GrowlLaunchCallback
714 *      @abstract       Callback to notify you that Growl is running.
715 *      @param  context The context pointer passed to Growl_LaunchIfInstalled.
716 *      @discussion     Growl_LaunchIfInstalled calls this callback function if Growl
717 *       was already running or if it launched Growl successfully.
718 */
719typedef void (*GrowlLaunchCallback)(void *context);
720
721/*!     @function       Growl_LaunchIfInstalled
722 *      @abstract       Launches GrowlHelperApp if it is not already running.
723 *      @param  callback        A callback function which will be called if Growl was successfully
724 *       launched or was already running. Can be <code>NULL</code>.
725 *      @param  context The context pointer to pass to the callback. Can be <code>NULL</code>.
726 *      @result Returns true if Growl was successfully launched or was already
727 *       running; returns false and does not call the callback otherwise.
728 *      @discussion     Returns true and calls the callback (if the callback is not
729 *       <code>NULL</code>) if the Growl helper app began launching or was already
730 *       running. Returns false and performs no other action if Growl could not be
731 *       launched (e.g. because the Growl preference pane is not properly installed).
732 *
733 *       If <code>Growl_CreateBestRegistrationDictionary</code> returns
734 *       non-<code>NULL</code>, this function will register with Growl atomically.
735 *
736 *       The callback should take a single argument; this is to allow applications
737 *       to have context-relevant information passed back. It is perfectly
738 *       acceptable for context to be <code>NULL</code>. The callback itself can be
739 *       <code>NULL</code> if you don't want one.
740 */
741Boolean Growl_LaunchIfInstalled(GrowlLaunchCallback callback, void *context);
742
743#pragma mark -
744#pragma mark Constants
745
746/*!     @defined        GROWL_PREFPANE_BUNDLE_IDENTIFIER
747 *      @abstract       The CFBundleIdentifier of the Growl preference pane bundle.
748 *      @discussion     GrowlApplicationBridge uses this to determine whether Growl is
749 *       currently installed, by searching for the Growl preference pane. Your
750 *       application probably does not need to use this macro itself.
751 */
752#ifndef GROWL_PREFPANE_BUNDLE_IDENTIFIER
753#define GROWL_PREFPANE_BUNDLE_IDENTIFIER        CFSTR("com.growl.prefpanel")
754#endif
755
756__END_DECLS
757
758#endif /* _GROWLAPPLICATIONBRIDGE_CARBON_H_ */
Note: See TracBrowser for help on using the repository browser.