beautypg.com

Supporting the intelligent assistant 21 – Apple Newton Programmer’s Newton 2.0 (for Newton 2.0) User Manual

Page 778

background image

C H A P T E R 2 1

Routing Interface

21-30

Using Routing

// get an entry from the Names soup to use for the recipient

curs:=GetUnionSoupAlways(ROM_CardfileSoupName):Query(nil);

if curs:Entry() then

begin

// set the toRef slot in the item frame

class := '|nameRef.phone|; // transport addressing class

nameRef := GetDataDefs(class):MakeNameRef(anEntry, class);

item.toRef := [nameRef];

targetInfo := {

targetView: getroot(),

target: {}, // for non-Call transports, add your data here

appsymbol: '|my:SIG|

};

// open the routing slip

OpenRoutingSlip(item, targetInfo);

// returns view (succeeded), or fails with

// nil or 'skipErrorMessage

end;

For the built-in fax and call transports, and for e-mail transports, addressing
information for an item is stored in the

toRef

slot of the item frame. E-mail

transports may also store addresses in additional slots such as

cc

and

bcc

. These

slots contain arrays of one or more name reference objects. The example code
above illustrates a name reference created from the data definition registered for the
addressing class of the transport (in this case the Call transport). For more
information about creating name references, see “Creating a Name Reference”
beginning on page 21-27.

For transports that handle data (unlike the Call transport example here), you must
also pass a target information frame to the

OpenRoutingSlip

function. The

target

slot in this frame contains the data to send. Note that the target slot can

contain a multiple-item target object, which you can create using the function

CreateTargetCursor

.

Supporting the Intelligent Assistant

21

Besides using the standard interface for routing (the Action button), the user can
also invoke routing actions by using the Intelligent Assistant and writing the name
of the action. In order to determine what item to route, the Intelligent Assistant
sends the

GetActiveView

message to your application. This method returns the

view to which the

GetTargetInfo

message should be sent.

The

GetActiveView

method is implemented by default in the root view and

simply returns

self

, the current receiver. If this return value is not appropriate for

your application, you must override this method in your application base view.