/SparkleShare/Mac/Growl.framework/Versions/A/Headers/GrowlApplicationBridge-Carbon.h

http://github.com/hbons/SparkleShare · C++ Header · 780 lines · 116 code · 68 blank · 596 comment · 4 complexity · 96254e37dd540ce99650becbc3f7be1d MD5 · raw file

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