DIRECTORY
Booting USING [ RegisterProcs, CheckpointProc ],
Intervoice USING [ Handle, Open, Play ],
Process USING [ Detach, MsecToTicks, Pause ],
Rope USING [ ROPE ],
UserProfile USING [ Token ],
VoiceUtils USING [ MakeAtom ]
;
PlayNoiseImpl:
CEDAR
PROGRAM
IMPORTS Booting, Intervoice, Process, UserProfile, VoiceUtils = {
reallyBoot: BOOL←TRUE;
didOurBest: BOOL;
maxTime: CARDINAL ← 4000;
PlayTheRollbackButton: Booting.CheckpointProc =
TRUSTED {
IF VoiceUtils.MakeAtom[UserProfile.Token["Finch.NoisyBoot", "false"]] # $true
THEN RETURN;
PlayAButton["Rollback"];
IF ~reallyBoot THEN rejection ← "Just pretending";
};
PlayAButton:
PROC[name: Rope.
ROPE] =
TRUSTED {
didOurBest ← FALSE;
Process.Detach[FORK ReallyPlayAButton[name]];
FOR i:
NAT
IN [0..100)
DO
Process.Pause[Process.MsecToTicks[maxTime/100]];
IF didOurBest THEN EXIT;
ENDLOOP;
};
ReallyPlayAButton:
PROC[name: Rope.
ROPE] = {
C: PROC[complaint: Rope.ROPE] = {NULL}; -- Don't bother complaining.
handle: Intervoice.Handle = Intervoice.Open[Complain: C];
Intervoice.Play[handle: handle, refID: name, refIDType: "SysNoises", wait: TRUE];
didOurBest ← TRUE;
};
Booting.RegisterProcs[c: PlayTheRollbackButton, r: NIL, b: PlayTheRollbackButton];
}.