Address Book Actions Reference

Framework
AddressBook/ABActionsC.h
Companion guide
Declared in
ABActionsC.h

Overview

The Address Book action callbacks allow you to populate the rollover menus of the Address Book application with custom items. You do this by writing an Address Book action plug-in that implements a function named ABActionRegisterCallbacks. This function registers a set of callback functions that are invoked by Address Book. The plug-in’s CFBundle must also implement the callback functions.

This is an example implementation of the ABActionRegisterCallbacks function:

ABActionCallbacks* ABActionRegisterCallbacks(void)
{
    ABActionCallbacks *callbacks;
    callbacks = malloc(sizeof(ABActionCallbacks));
    if (callbacks == NULL)
        return NULL;
    callbacks->version = 0;
    callbacks->property = actionProperty;
    callbacks->title = actionTitle;
    callbacks->enabled = actionEnabled;
    callbacks->selected = actionSelected;
    return callbacks;
}

Each action plug-in can implement only one action. Actions can only apply to items with labels.

Use Xcode to create Address Book action plug-ins. Place action plug-ins in ~/Library/Address Book Plug-Ins or /Library/Address Book Plug-Ins, depending on the scope you want for the action.

Callbacks

ABActionCopyTitleCallback

Return the title of the menu item for the action. If the property returned by ABActionGetPropertyCallback is a multi-value property, identifier contains the unique identifier of the value selected.

typedef CFStringRef (*ABActionCopyTitleCallback) (
   ABPersonRef person,
   CFString CFStringRef identifier
);

You may implement the function like this:

CFStringRef actionTitle(ABPersonRef person,
CFStringRef identifier)

Availability
  • Available in OS X v10.3 and later.
Declared In
ABActionsC.h

ABActionEnabledCallback

Return true if the action menu item should be enabled, false otherwise. If the property returned by ABActionGetPropertyCallback is a multi-value property, identifier contains the unique identifier of the value selected.

typedef Boolean (*ABActionEnabledCallback) (
   ABPersonRef person,
   CFStringRef identifier
);

You may implement the function like this:

Boolean actionEnabled(ABPersonRef person,
CFStringRef identifier)

Availability
  • Available in OS X v10.3 and later.
Declared In
ABActionsC.h

ABActionGetPropertyCallback

Return the property the action applies to.

typedef CFStringRef (*ABActionGetPropertyCallback)
(void);

You may implement the function like this:

CFStringRef actionProperty(void)

Availability
  • Available in OS X v10.3 and later.
Declared In
ABActionsC.h

ABActionSelectedCallback

Execute the action. If the property returned by ABActionGetPropertyCallback is a multi-value property, identifier contains the unique identifier of the value selected; otherwise, identifier is NULL.

typedef void (*ABActionSelectedCallback) (
   ABPersonRef person,
   CFStringRef identifier
);

You may implement the function like this:

void actionSelected(ABPersonRef person,
CFStringRef identifier)

Availability
  • Available in OS X v10.3 and later.
Declared In
ABActionsC.h

Data Types

ABActionCallbacks

This is the structure that the ABActionRegisterCallbacks returns to tell Address Book about the action the plug-in implements.

typedef struct {
   CFIndex version;
   ABActionGetpropertyCallback property;
   ABActionCopyTitleCallback title;
   ABActionEnabledCallback enabled;
   ABActionSelectedCallback selected;
} ABActionCallbacks;
Availability
  • Available in OS X v10.3 and later.
Declared In
ABActionsC.h