< Previous PageNext Page > Hide TOC

Creating and Using Address Book Action Plug-ins

A unique aspect of Address Book is its ability to act on data contained within a person's card. You can install your own custom plug-ins to add additional actions to a given record. An example of an existing action is the “Large Type” action, which works on any phone number entry. When selected from its rollover menu, it displays the number in large type across the screen.

The action plug-in protocol, which must be followed for Address Book to recognize the plug-in, is specified in ABActionDelegate. The plug-in must respond to three methods (actionProperty, titleForPerson:identifier:, performActionForPerson:identifier:), and may optionally respond to shouldEnableActionForPerson:identifier:. Note that Carbon applications must also implement the ABActionRegisterCallbacks function. The following table describes the action methods and functions, and what their purpose is in an Address Book action plug-in:

Table 1  Action Methods for an Address Book action plug-in

Method

Purpose

(void)performActionForPerson:(ABPerson *)person identifier:(NSString *)identifier

Performs the appropriate action for the plug-in. Each plug-in supports only one action.

(NSString *)titleForPerson:(ABPerson *)person identifier:(NSString *)identifier

Returns the title of the menu item for the action.

(NSString *)actionProperty

Returns the ABProperty constant that the action applies to.

(BOOL)shouldEnableActionForPerson:(ABPerson *)person identifier:(NSString *)identifier

Returns YES if the action is applicable and NO otherwise.

For a description of all the appropriate constants, refer to Address Book Reference for Objective-C. In addition, see ABActionDelegate reference for a complete description of the methods above, including how to leverage the method parameters to customize the plug-in’s action.

An example plug-in project is included with Xcode. Out of the box, it will compile into an action plug-in designed to create a rollover menu item on any phone number. When the menu item is selected, Address Book will speak the number using Mac OS X’s speech synthesis framework. To view this project and review its code, create a new Address Book Action Plug-in from Xcode’s New Project window. You will edit this pre-created template whenever you want to make a new plug-in.

Once your project is complete, you may want to change the wrapper extension from .bundle to something more appropriate, such as .plugin. This can be changed in the Styles pane of the project Inspector, and is completely optional. Do that step or not, you can build your project. The completed bundle should be placed in ~/Library/Address Book Plug-Ins (to only use it on your user account) or in /Library/Address Book Plug-ins (to offer it to all users on the machine).



< Previous PageNext Page > Hide TOC


© 2002, 2006 Apple Computer, Inc. All Rights Reserved. (Last updated: 2006-04-04)


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.