-- File: WalnutWindow.Mesa
-- Created by: Willie-Sue, March 23, 1982

-- Last Edited by:

-- Willie-Sue on July 22, 1983 12:26 pm

DIRECTORY

 DB USING [Transaction],
 Buttons USING [ButtonProc],
 Commander USING [CommandProc],
 GVRetrieve USING [MBXState],
 Icons USING [IconFlavor],
 Menus USING [Menu, MenuProc],
 WalnutViewer USING [Queue],
 WalnutDB USING [Msg, MsgSet],
 Rope USING [ROPE],
 ViewerClasses USING [Viewer];

WalnutWindow: CEDAR DEFINITIONS =

BEGIN OPEN WalnutDB;

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

initialActiveIconic: BOOL;
initialActiveOpen: BOOL;
initialActiveRight: BOOL;
msgSetBorders: BOOL;
enableTailRewrite: BOOL;
excessBytesInLogFile: INT;

walnut: Viewer;
walnutQueue: Queue;

walnutSegmentFile: ROPE;
walnutLogName: ROPE;
readOnlyAccess: BOOL;
logIsAlpineFile: PUBLIC BOOL;
personalMailDB: PUBLIC BOOL;

walnutNullTrans: DB.Transaction;
iconFilePathName: ROPE;

walnutIcon: Icons.IconFlavor;
newMailIcon: Icons.IconFlavor;
msgSetIcon: Icons.IconFlavor;
msgIcon: Icons.IconFlavor;

msgSetText: Viewer; -- the text argument for Create/Delete MsgSet
fileNameText: Viewer; -- fileName for Archiving
mailNotifyLabel: Viewer;

walnutMenu: Menus.Menu;
workingMenu: Menus.Menu;

-- ***********************************************************
-- types & variables shared with walnutmsgsetbuttonsimpl

MsgSetButton
: TYPE = REF MsgSetButtonObject;
MsgSetButtonObject: TYPE = RECORD[
  msgSet: MsgSet,
  selector, msViewer: Viewer← NIL,
  next: MsgSetButton← NIL,  -- list of all MsgSets
  selected: MsgSetButton← NIL]; -- list of Selected MsgSets
----------------------------

selectedMsgSetButtons: MsgSetButton;  -- List of selected MsgSets (may be empty)
lastMsgSetButton: MsgSetButton;    -- tail of List of MsgSets (never empty)
firstMsgSetButton: MsgSetButton;
walnutRulerBefore, walnutRulerAfter, walnutTS: Viewer;

-- ***********************************************************
-- Operation on Walnut Window [WalnutWindowImpl]

RestartWalnut: PROC;

SetWalnutUpdatesPending: PROC[isDirty: BOOL];
-- sets newversion bit on in walnut window

UncomittedUpdates: PROC RETURNS[updatesPending: BOOL];
-- returns TRUE if uncomitted updates to database exist

UserConfirmed
: PROC RETURNS[BOOL];
-- returns TRUE if user responds Confirm

WatchMailBox: PROC[newState: GVRetrieve.MBXState];

RetrieveNewMail: PROC;
-- checks if user has changes, then calls DoNewMail

WalnutReadMailFile
: Commander.CommandProc;

WalnutExpunge: Commander.CommandProc;

WalnutScavenge: Commander.CommandProc;

WalnutNewMail: Commander.CommandProc;

WalnutDump: Commander.CommandProc;

Report: PROC[msg1, msg2, msg3, msg4: ROPENIL];
-- Prints non-omitted arguments in the Walnut window followed by CR.

ReportRope: PROC[msg1: ROPE];
-- Similar to above, but prints one rope and doesn't print CR at end.

-- ***********************************************************
-- in WalnutExtrasImpl

-- for use by programs, goes thru walnutQueue

GetNewMail
: PUBLIC PROC;
ReadMailFile: PROC[fName, msgSet: ROPE];

-- *****************

DoNewMail
: PROC;
-- retrieves new mail from Grapevine & adds it to the database

SizeOfMsgSetsProc: Menus.MenuProc;

DeleteMsgSetsProc: Menus.MenuProc;

PrintMsgSetsProc: Menus.MenuProc;

CreateMsgSetButtonProc: Buttons.ButtonProc;

ArchiveButtonProc: Buttons.ButtonProc;

AppendButtonProc: Buttons.ButtonProc;

DestroyAllMsgSetButtons: PROC;

-- ***********************************************************
-- these are implemented in WalnutMsgSetButtonsImpl

DisplayMsgSet: PROC[msgSet: MsgSet] RETURNS[Viewer];
-- Walnut wants to check if a MsgSet msgSet is already being displayed

FindMSViewer: PROC[msgSet: MsgSet] RETURNS[Viewer];
-- returns NIL if msgSet is not being displayed

ShowMsgSetButtons: PROC;
-- constructs or re-constructs the msgSetButtons in the control window;
-- "knows"
where in the window the buttons belong

GetSelectedMsgSets: PROC RETURNS[msL: LIST OF MsgSetButton];
-- the list of MsgSets the user has selected (for Add/Remove Msg operations)

DeleteMsgSetButton: PROC[msgSet: MsgSet];

CreateMsgSetProc: PROC[msName: ROPE, select: BOOL] RETURNS[nameOK: BOOL];
-- creates button for MsgSet & selects it, if select is TRUE
-- RETURNS FALSE is if name is illegal for a MsgSet

AddMsgSetButton: PROC[msgSet: MsgSet, msName: ROPE, select: BOOL];
-- adds a button for msgSet

FindMSBForMsgSet: PROC[msgSet: MsgSet] RETURNS[MsgSetButton];
-- used after rollback, to hookup any displayed message set with its MsgSetButton

END.