background image
C H A P T E R 2 2
Transport Interface
Using the Transport Interface
22-15
e-mail address to the sender's internet address. Here's an example of code that sets
the appropriate e-mail address in the
fromRef
object:
owner:=ResolveEntryAlias(GetUserConfig('currentPersona));
if owner and GetRoot().cardfile then begin
addrs := GetRoot().cardfile:BcEmailAddress(owner,
['|string.email.internet|]);
if addrs then
fromRef := clone(addrs[0]);
end
You can find a description of
BcEmailAddress
and other similar functions that
extract information from Names soup entries in "Names Functions and Methods"
(page 16-5) in Newton Programmer's Reference.
If, instead of extracting the address and sending it as a string, your transport sends
addressing information as a frame, like the beam transport, you must remove any
soup entry aliases from the name reference before it is transmitted. You can do
this by using the name reference data definition method
PrepareForRouting
,
as follows:
// strip the aliases from a name ref
fromRef := datadef:PrepareForRouting(fromRef);
In general, however, you should not send all the information in a user's persona
with a message, since it can include personal or confidential information such as
credit card numbers.
For more information about name references and the methods of name reference
data definitions, see the section "Creating a Name Reference" beginning on
page 21-27, and "Name References" (page 5-1) in Newton Programmer's
Reference
.
The following is an example of how to override the
NewItem
method during a
send operation to add a
fromRef
slot:
// a sample overridden NewItem method
mytransport.NewItem := func(context) begin
// first call inherited method to get default frame
local item := inherited:NewItem(context);
// get sender info and insert fromRef slot
local persona:= GetUserConfig('currentPersona);
local dataDef := GetDataDefs(addressingClass);
© 2007-2017, o7 studio » при воспроизведении материала сайта ссылка обязательна