-- File: WalnutSendMail.mesa
-- Created by: Haugeland, August 26, 1982
-- Edited by
-- Cattell on XXX
-- Willie-Sue on June 3, 1983 4:46 pm

DIRECTORY
 GVBasics USING [ItemType, RName],
 GVSend USING [Handle],
IO USING [STREAM],
 Menus USING [Menu],
 Rope USING [ROPE],
 ViewerClasses USING [Viewer],
 ViewerEvents USING [EventRegistration],
 ViewerTools USING [TiogaContents];

WalnutSendMail: CEDAR DEFINITIONS =

BEGIN
ROPE: TYPE = Rope.ROPE;
Viewer: TYPE = ViewerClasses.Viewer;
RName: TYPE = GVBasics.RName;
TiogaContents: TYPE = ViewerTools.TiogaContents;

SendMsgRecObject: TYPE = RECORD[
 fullText: ROPE,   -- text to be sent
 from: ROPE,    -- The From: field
 to: LIST OF GVBasics.RName,
 cc: LIST OF ROPE,
 replyTo: BOOLFALSE,  -- is this field present
 numRecipients: INT← 0,
 numDLs: INT← 0,
 endHeadersPos: INT← 0  -- for adding Reply-To: field
 ];

SendingRec: TYPE = REF SendMsgRecObject;

SenderInfo
: TYPE = REF SenderInfoObject;
SenderInfoObject: TYPE = RECORD
[senderV: Viewer,
replyToResponse: HowToReplyTo← self,
prevMsg: TiogaContents← NIL,
numCharsToDelete: INT← 0,
closeEvent, destroyEvent, editEvent: ViewerEvents.EventRegistration← NIL,
successfullySent, userResponded, confirmed: BOOLFALSE,
aborted: BOOLFALSE,
validateFlag: BOOLTRUE,
sendHandle: GVSend.Handle← NIL];

maxWithNoReplyTo: INT = 20;
HowToReplyTo: TYPE = {self, all, cancel};

SendParseStatus: PUBLIC TYPE =
 {ok, includesPublicDL, includesPrivateDL, fieldNotAllowed, syntaxError};

-- globals that used to be in WalnutWindow
userRName: ROPE;
simpleUserName: ROPE;
needToAuthenticate: BOOL;
replyToSelf: BOOL;

sendMenu, sendingMenu, blankMenu, confirmMenu, replyToMenu: Menus.Menu;

defaultRegistry: ROPE;
arpaGatewayHosts: LIST OF ROPE;
TiogaCTRL: GVBasics.ItemType;

-- ***********************************************************
-- Sending messages & dealing with sender viewers [WalnutSendCommonImpl]

SendMsg:
PROC[senderV: ViewerClasses.Viewer, doClose: BOOLFALSE] RETURNS[sendOk: BOOL];
-- is given a container set up for sending; does the sending

BuildSendViewer: PROC [paint, iconic: BOOL, who: Viewer← NIL] RETURNS[senderV: Viewer];
-- builds sending viewer

AnswerMsg: PROC[msgHeaders: ROPE, who: Viewer← NIL] RETURNS [v: Viewer];

ForwardMsg: PROC[oldMsg: ViewerTools.TiogaContents, who: Viewer← NIL]
  RETURNS [v: Viewer];

NewMsgFormInViewer: PROC[senderV: Viewer, form: ROPE];
-- fills in senderV with a new Form

WalnutSendProc: PROC[fromExec: BOOL];
-- create a viewer for sending msgs

RegisterReporter: PROC[strm: IO.STREAM];
-- allows Walnut to have WalnutSend use its reporting procedure

UnregisterReporter: PROC[strm: IO.STREAM];

-- ********************************************************
TiogaTextFromStrm: PROC[strm: IO.STREAM, startPos: INT← 0, len: INTLAST[INT]]
RETURNS[contents: TiogaContents];
-- returns NIL IF EndOfStream encountered during read

InsertIntoViewer: PROC[v: Viewer, what: ROPE, where: INT];

DeleteChars: PROC[v: Viewer, num: INT];

SenderReport: PROC[msg: ROPE];

CheckForAbortSend
: PROC[senderInfo: SenderInfo] RETURNS[BOOL];

Confirmation: PROC[senderInfo: SenderInfo] RETURNS [BOOL];

ReplyToResponse: PROC[senderInfo: SenderInfo] RETURNS [HowToReplyTo];

END
.