DIRECTORY CedarSnapshot USING [CheckpointProc, Register, RollbackProc], CIFS USING [Enumerate, EProc], Commander USING [CommandProc, Register], Process USING [Detach], Menus USING [ClickProc, MenuProc], PeanutSendMail, RefText USING [Match], Rope USING [Equal, Find, FromProc, ROPE, Substr], PeanutRetrieve, PeanutWindow, UserProfile, ViewerClasses, ViewerOps, VirtualDesktops; PeanutTopImpl: CEDAR PROGRAM IMPORTS PeanutWindow, PeanutRetrieve, PeanutSendMail, CedarSnapshot, CIFS, Process, RefText, Rope, Commander, UserProfile, VirtualDesktops, ViewerOps = BEGIN NewForm: Menus.MenuProc = { PeanutSendMail.NewMsgForm[mouseButton, shift, control] }; AnswerMessage: Menus.MenuProc = { PeanutSendMail.AnswerMsg[mouseButton, shift, control] }; ForwardMessage: Menus.MenuProc = { PeanutSendMail.ForwardMsg[mouseButton, shift, control] }; SendMessage: Menus.MenuProc = { PeanutSendMail.SendMsg[mouseButton, shift, control] }; NewMail: Menus.MenuProc = { PeanutRetrieve.GetNewMsgs[] }; Abort: Menus.MenuProc = { PeanutWindow.abortFlag _ TRUE }; SaveAll: Menus.MenuProc = { files: LIST OF Rope.ROPE _ mailFiles; killThem: BOOLEAN _ UserProfile.Boolean[key: "Peanut.KillViewersOnSaveall", default: FALSE]; activeName: Rope.ROPE _ UserProfile.Token[key:"Peanut.ActiveMailFile", default:"Active.mail"]; outgoingName: Rope.ROPE _ UserProfile.Token[key:"Peanut.OutGoingMailFile", default:""]; PeanutWindow.OutputRope["\nSaving all message sets:"]; WHILE files # NIL DO viewer: ViewerClasses.Viewer _ VirtualDesktops.FindViewer[files.first].viewer; IF viewer # NIL THEN { IF viewer.newVersion THEN { PeanutWindow.OutputRope["\nSaving "]; PeanutWindow.OutputRope[files.first]; ViewerOps.SaveViewer[viewer]; }; IF killThem THEN { IF Rope.Equal[viewer.name,activeName] OR Rope.Equal[viewer.name,outgoingName] THEN ViewerOps.CloseViewer[viewer] ELSE ViewerOps.DestroyViewer[viewer]; }; }; files _ files.rest; ENDLOOP; PeanutWindow.OutputRope["\nDone saving all message sets."]; }; MailFileButton: Menus.ClickProc = { IF mouseButton=yellow THEN -- open the message file ViewerOps.OpenIcon[PeanutRetrieve.GetMailViewer[NARROW[clientData]]] ELSE PeanutRetrieve.CopyMessages[to: NARROW[clientData], delete: mouseButton=blue] }; restartAfterRollback: BOOL _ FALSE; PeanutCheckpointProc: CedarSnapshot.CheckpointProc = { CloseDown[]; restartAfterRollback _ TRUE }; PeanutRollbackProc: CedarSnapshot.RollbackProc = { IF restartAfterRollback THEN TRUSTED {Process.Detach[FORK StartPeanut[]]}}; BuildPeanut: Commander.CommandProc = {StartPeanut[]}; CloseDown: PROC = { PeanutRetrieve.CloseConnection[] }; mailFiles: LIST OF Rope.ROPE; GetMatchingFileList: PROC[pattern: REF TEXT] RETURNS[LIST OF Rope.ROPE] = { list: LIST OF Rope.ROPE _ NIL; tail: LIST OF Rope.ROPE _ NIL; proc: CIFS.EProc --[name, link, comment: REF TEXT] RETURNS[stop: BOOL]-- = { IF RefText.Match[pattern: pattern, object: name, case: FALSE] THEN { ShortFileName: PROC[name: REF READONLY TEXT] RETURNS[Rope.ROPE] = { index: NAT _ 0; p: PROC RETURNS[CHAR] = { c: CHAR = name[index]; index _ index+1; RETURN[c] }; FOR i: NAT IN[0..name.length) DO IF name[i]='> THEN index _ i+1; ENDLOOP; RETURN[Rope.FromProc[len: name.length-index, p: p]]; }; rope: Rope.ROPE = ShortFileName[name]; item: LIST OF Rope.ROPE = CONS[rope, NIL]; IF list=NIL THEN list _ item ELSE tail.rest _ item; tail _ item; }; RETURN[stop: FALSE]; }; CIFS.Enumerate[dir: NIL, pattern: "*", p: proc]; -- "*" is the only pattern that works! RETURN[list]; }; StartPeanut: PROC = { files: LIST OF Rope.ROPE; AddName: PROC [fileName: Rope.ROPE, redisplay: BOOL] = { name: Rope.ROPE _ Rope.Substr[fileName, 0, Rope.Find[fileName, "."]]; PeanutWindow.AddButton[name: name, proc: MailFileButton, data: fileName, redisplay: redisplay] }; IF PeanutSendMail.AuthenticateUser[] THEN [] _ PeanutRetrieve.NewUser[PeanutSendMail.userRName]; IF PeanutWindow.Create[] THEN { -- created a new one files _ mailFiles _ GetMatchingFileList["*.Mail"]; WHILE files # NIL DO AddName[files.first, (files.rest = NIL)]; files _ files.rest; ENDLOOP; PeanutWindow.OutputRope["MIDDLE click mail file button to open the file\n"]; PeanutWindow.OutputRope["LEFT click to copy selected message(s)\n"]; PeanutWindow.OutputRope["RIGHT click to move selected message(s)\n"] } ELSE { -- restarting, probably after Rollback; check for new Mail files IsOld: PROC [name: Rope.ROPE] RETURNS [yes: BOOL] = { fileList: LIST OF Rope.ROPE _ mailFiles; WHILE fileList # NIL DO IF Rope.Equal[name, fileList.first] THEN RETURN [TRUE]; fileList _ fileList.rest; ENDLOOP; RETURN [FALSE] }; files _ GetMatchingFileList["*.Mail"]; WHILE files # NIL DO IF ~IsOld[files.first] THEN { PeanutWindow.Destroy[]; [] _ PeanutWindow.Create[]; files _ mailFiles _ GetMatchingFileList["*.Mail"]; WHILE files # NIL DO AddName[files.first, (files.rest = NIL)]; files _ files.rest; ENDLOOP; EXIT }; files _ files.rest; ENDLOOP }; }; PeanutWindow.AddCommand[name: "NewMail", proc: NewMail]; PeanutWindow.AddCommand[name: "NewForm", proc: NewForm]; PeanutWindow.AddCommand[name: "Answer", proc: AnswerMessage]; PeanutWindow.AddCommand[name: "Forward", proc: ForwardMessage]; PeanutWindow.AddCommand[name: "Send", proc: SendMessage]; PeanutWindow.AddCommand[name: "Abort", proc: Abort]; PeanutWindow.AddCommand[name: "SaveAll", proc: SaveAll]; Commander.Register["Peanut", BuildPeanut, "For retrieving and sending mail"]; TRUSTED {CedarSnapshot.Register[c: PeanutCheckpointProc, r: PeanutRollbackProc]}; StartPeanut[]; END. ΜPeanutTopImpl.mesa; Written by Bill Paxton, February 1983 Last edited by Paxton on April 4, 1983 9:10 am Last edited by Wyatt on April 14, 1983 2:38 pm Last Edited by: Pausch, July 18, 1983 1:37 pm Κ›– "Cedar" style˜Iproc– "Cedar" stylešœ9™9Kšœ.™.Kšœ.™.J™-unitšΟk ˜ Jšœœ*˜=Jšœœ˜Jšœ œ˜(Jšœœ ˜Jšœœ˜"Jšœ˜Jšœœ ˜Jšœœœ ˜1Jšœ˜Jšœ ˜ J˜ Jšœ˜Jšœ ˜ Jšœ˜—šœœ˜Jšœ>œN˜——Lš˜I modheader˜šœ˜Mšœ9˜9—M˜šœ!˜!Mšœ8˜8—M˜šœ"˜"Mšœ9˜9—M˜šœ˜Mšœ6˜6—M˜šœ˜Mšœ˜—M˜šœ˜Mšœœ˜ —M˜šœ˜Mšœœœœ ˜%Mšœ œDœ˜\MšœœI˜^Mšœœ@˜WMšœ8˜8šœ œ˜M˜Nšœ œœ˜šœœ˜M˜%M˜%Mšœ˜M˜—šœ œ˜Mšœ$œ&œ˜pMšœ!˜%Mšœ˜—Mšœ˜—Mšœ˜Mšœ˜—Mšœ=˜=šœ˜M˜——šœ#˜#šœœΟc˜3Mšœ0œ˜D—Mšœ!œ*˜U—M˜Mšœœœ˜#šœ6˜6Mšœ$œ˜+—šœ2˜2Mšœœœœ˜KM˜—Jšœ5˜5J˜šΟn œœ˜J˜#—M˜šœ œœœ˜J˜—šŸœœ œœœœœœ˜KMš œœœœœ˜Mš œœœœœ˜šœœžœœœœœžœ˜Lšœ5œœ˜DšŸ œœœœœœœ˜CMšœœ˜Mš œœœœ œ!œ˜Nšœœœ˜ Mšœ œ ˜Mšœ˜—Mšœ.˜4M˜—Mšœ œ˜&Mš œœœœœœ˜*Mšœœœ œ˜3M˜ M˜—Mšœœ˜M˜—Mšœœž&˜WMšœ˜ M˜—M˜šŸ œœ˜Mšœœœœ˜M˜šŸœœœ œ˜8Mšœ œ6˜EMšœa˜aM˜—šœ#˜)Mšœ6˜6—šœœž˜4Mšœ2˜2šœ œœ˜Mšœ#œ˜*Mšœ˜Mš˜—MšœL˜LMšœD˜DMšœF˜F—šœž@˜Gš Ÿœœ œœœ˜5Mšœ œœœ ˜(šœ œ˜Mšœ"œœœ˜7Mšœ˜Mšœ˜—Mšœœ˜—Mšœ&˜&šœ œ˜šœœ˜Mšœ˜Mšœ˜Mšœ2˜2šœ œœ˜Mšœ#œ˜*Mšœ˜Mšœ˜—Mšœ˜—Mšœ˜Mšœ˜ ——M˜—M˜Mšœ8˜8Mšœ8˜8Mšœ=˜=Mšœ?˜?Mšœ9˜9Mšœ4˜4Mšœ8˜8J˜J˜MM˜MšœJ˜QM˜M˜M˜Mšœ˜J˜—…—|γ