-- File: WalnutMsgOps.Mesa

-- Created by: Haugeland, June 21, 1983
-- Last Edited by: Willie-Sue, August 2, 1983 3:13 pm

-- Last Edited by: Donahue, July 27, 1983 2:22 pm

DIRECTORY

 Rope USING [ROPE],
 WalnutDB USING [Msg, MsgSet, Relship],
 WalnutLog USING [MsgRec],
 ViewerClasses USING [Viewer];

WalnutMsgOps: CEDAR DEFINITIONS =

BEGIN OPEN WalnutDB, WalnutLog;

Viewer
: TYPE = ViewerClasses.Viewer;
ROPE: TYPE = Rope.ROPE;

-- ***********************************************************
-- FieldHandle for msgSet displayers, needed by msg displayers

MsgSetFieldHandle
: TYPE = REF MsgSetFieldObject;

MsgSetFieldObject
: TYPE = RECORD[
relship: Relship,
msgViewer: Viewer← NIL,
msg: Msg,
msgName: ROPE,   -- needed for rebuilding after an abort
msgTOC: ROPE,
posOK: BOOL FALSE,
hasBeenRead: BOOL TRUE,
headersPos, msgLength: INT← 0,
prev, next: Viewer← NIL];

-- ***********************************************************
-- displaying Msgs, from WalnutMsgDisplayerImpl

DisplayMsgFromMsgSet:
PROC[mfh: MsgSetFieldHandle, msViewer: Viewer, shift: BOOL← FALSE] RETURNS[v: Viewer];

MsgCategories: PROC[msg: Msg];
-- lists the MsgSets for msg, in the walnut control window

FixUpMsgViewer: PROC[mName: ROPE, v: Viewer];
-- called after transaction abort

-- ***********************************************************
-- maintaining MsgSet displayers, from WalnutMsgSetDisplayerImpl

BuildMsgSetDisplayer
:
PROC[msgSet: MsgSet, name: ROPE, shift: BOOL← FALSE, initialActive: BOOLFALSE]
  RETURNS[msV: Viewer];

DisplayMsgSetInViewer: PROC[msgSet: MsgSet, msViewer: Viewer, shift: BOOL← FALSE];

AddParsedMsgToMSViewer
: PROC[msg: Msg, msgR: MsgRec, msViewer: Viewer, rel: Relship];
-- used by new mail & old mail file readers

-- the following routines figure out if the referenced MsgSet is being displayed

RemoveFromMsgSetDisplayer
: PROC[msgSet: MsgSet, msg: Msg];

AddMsgToMsgSetDisplayer: PROC[msg: Msg, msgSet: MsgSet, rel: Relship];

FixUpMsgSetViewer: PROC[msName: ROPE, v: Viewer];
-- called after transaction abort

-- ***********************************************************
-- used to implement procs called from outside of Walnut

BuildListOfMsgsViewer: PUBLIC PROC[mL: LIST OF ROPE, name: ROPE, oldV: Viewer]
RETURNS[v: Viewer];
-- builds a msgset-like displayer for a list of msgs, using oldV if given
-- Walnut will maintain it in the face of aborts

BuildMsgViewer: PROC[mName: ROPE, msg: Msg, shift, paint: BOOLFALSE]
  RETURNS[v: Viewer];
-- returns NIL if mName is not a Msg

MsgInViewer: PROC[mName: ROPE, msg: Msg, v: Viewer, shift: BOOLFALSE];
-- displays Msg name (if it exists) in Viewer v

BuildMsgSetViewer: PROC[msName: ROPE, msgSet: MsgSet, shift, paint: BOOLFALSE]
  RETURNS[v: Viewer];
-- returns NIL if msName is not a MsgSet
-- if msName is already being displayed, returns that Viewer

MsgSetInViewer:
PROC[msName: ROPE, msgSet: MsgSet, v: Viewer, shift: BOOLFALSE];
-- displays the MsgSet name (if it exists) in Viewer v

END
.