DIRECTORY Atom USING [ GetPName ], BasicTime USING [ GMT, FromNSTime, Period, Now, nullGMT, ToNSTime ], Commander USING [CommandProc, Register], Convert USING [ CardFromRope ], IO, NameDB USING [ AttributeSeq, GetAttributes, SetAttribute ], Rope USING [Cat, Equal, ROPE], UserCredentials USING [Get], ViewRec USING [ RecordViewer, SampleRV, ViewRef ], VoiceUtils USING [ MakeAtom ] ; FinchValuesImpl: CEDAR PROGRAM IMPORTS Atom, BasicTime, Commander, Convert, IO, NameDB, Rope, UserCredentials, ViewRec, VoiceUtils = { ROPE: TYPE = Rope.ROPE; Values: TYPE = REF ValuesRec; ValuesRec: TYPE = RECORD [ name: ROPE _ "Telephone Parameters", Accept: PROC_NIL, Cancel: PROC_NIL, ringTune: ROPE_NIL, ringMode: ATOM_NIL, doTune: ATOM_NIL, audioSource: ATOM_NIL, multiring: ROPE_NIL, autoAnswer: BOOL_FALSE, dialToneTune: BOOL_FALSE, transmitOnly: BOOL_FALSE ]; values: Values _ NEW[ValuesRec_[]]; attributes: NameDB.AttributeSeq; rv: ViewRec.RecordViewer_NIL; rName: ROPE; Accept: PROC = { attributes _ PutRope[attributes, $ringtune, values.ringTune, NIL]; attributes _ PutAtom[attributes, $ringmode, values.ringMode, $R]; attributes _ PutAtom[attributes, $dotune, values.doTune, $false]; attributes _ PutAtom[attributes, $audioSource, values.audioSource, $telset]; attributes _ PutRope[attributes, $multiring, values.multiring, "false"]; attributes _ PutBool[attributes, $autoanswer, values.autoAnswer]; attributes _ PutBool[attributes, $dialtonetune, values.dialToneTune]; attributes _ PutBool[attributes, $transmitonly, values.transmitOnly]; }; Cancel: PROC = { attributes _ NameDB.GetAttributes[rName: rName, dbType: $blue]; values.ringTune _ GetRope[attributes, $ringtune, NIL]; values.ringMode _ GetAtom[attributes, $ringmode, $R]; values.doTune _ GetAtom[attributes, $dotune, $false]; values.audioSource _ GetAtom[attributes, $audioSource, $telset]; values.multiring _ GetRope[attributes, $multiring, "false"]; values.autoAnswer _ GetBool[attributes, $autoanswer]; values.dialToneTune _ GetBool[attributes, $dialtonetune]; values.transmitOnly _ GetBool[attributes, $transmitonly]; IF rv#NIL THEN ViewRec.SampleRV[rv]; }; GetRope: PROC[attributes: NameDB.AttributeSeq, attribute: ATOM, default: ROPE] RETURNS[rope: ROPE] = { rope _ GetAttribute[attributes, attribute]; IF rope=NIL THEN rope_default; }; GetAtom: PROC[attributes: NameDB.AttributeSeq, attribute: ATOM, default: ATOM] RETURNS[atom: ATOM] = { value: ROPE _ GetAttribute[attributes, attribute]; RETURN[IF value=NIL THEN default ELSE VoiceUtils.MakeAtom[value, FALSE]]; }; GetBool: PROC[attributes: NameDB.AttributeSeq, attribute: ATOM] RETURNS[bool: BOOL] = { value: ROPE _ GetAttribute[attributes, attribute]; RETURN[value.Equal["true", FALSE]]; }; PutRope: PROC[attributes: NameDB.AttributeSeq, attribute: ATOM, value: ROPE, default: ROPE] RETURNS[newAttributes: NameDB.AttributeSeq] = { currentValue: ROPE _ GetRope[attributes, attribute, default]; newAttributes _ attributes; IF currentValue.Equal[value, FALSE] THEN RETURN; NameDB.SetAttribute[rName, attribute, value]; newAttributes _ NameDB.GetAttributes[rName: rName, dbType: $blue]; }; PutAtom: PROC[attributes: NameDB.AttributeSeq, attribute: ATOM, atom: ATOM, default: ATOM] RETURNS[newAttributes: NameDB.AttributeSeq] = { currentAtom: ATOM _ GetAtom[attributes, attribute, default]; newAttributes _ attributes; IF currentAtom=atom THEN RETURN; NameDB.SetAttribute[rName, attribute, IF atom=NIL THEN NIL ELSE Atom.GetPName[atom]]; newAttributes _ NameDB.GetAttributes[rName: rName, dbType: $blue]; }; PutBool: PROC[attributes: NameDB.AttributeSeq, attribute:ATOM, bool: BOOL] RETURNS[newAttributes: NameDB.AttributeSeq] = { currentBool: BOOL _ GetBool[attributes, attribute]; newAttributes _ attributes; IF bool=currentBool THEN RETURN; NameDB.SetAttribute[rName, attribute, IF bool THEN "true" ELSE "false"]; newAttributes _ NameDB.GetAttributes[rName: rName, dbType: $blue]; }; GetAttribute: PROC[attributes: NameDB.AttributeSeq, attribute:ATOM, timed: BOOL_FALSE] RETURNS[value: ROPE_NIL] = { IF timed THEN { expired: BOOL; value _ GetAttribute[attributes, QualifiedAttribute["time", attribute]]; IF value = NIL THEN RETURN[NIL]; expired _ RelTime[value]<0; value _ GetAttribute[ attributes, QualifiedAttribute[IF expired THEN "untimed" ELSE "timed", attribute]]; }; FOR a: NameDB.AttributeSeq _ attributes, a.rest WHILE a#NIL DO IF a.first.type # attribute THEN LOOP; value _ a.first.value; IF Rope.Equal["#", value] THEN RETURN[GetAttribute[attributes, attribute, TRUE]]; ENDLOOP; }; QualifiedAttribute: PROC[qualifier: ROPE, attribute: ATOM] RETURNS[qualified: ATOM] = { RETURN[VoiceUtils.MakeAtom[Rope.Cat[qualifier, ".", Atom.GetPName[attribute]], FALSE]]; }; TimeFromRope: PROC[ropeTime: ROPE] RETURNS [time: BasicTime.GMT] = { RETURN[BasicTime.FromNSTime[Convert.CardFromRope[ropeTime]]]; }; RelTime: PROC[ropeTime: ROPE] RETURNS [relativeToNow: INT] = { RETURN[BasicTime.Period[from: BasicTime.Now[], to: BasicTime.FromNSTime[Convert.CardFromRope[ropeTime]]]]; }; TimeRope: PROC [time: BasicTime.GMT _ BasicTime.nullGMT] RETURNS[nowRope: ROPE] = { IF time = BasicTime.nullGMT THEN time _ BasicTime.Now[]; RETURN[IO.PutFR["%bB", [cardinal[BasicTime.ToNSTime[time]]]]]; }; Initialize: Commander.CommandProc = { rName _ UserCredentials.Get[].name; values.Accept _ Accept; values.Cancel _ Cancel; Cancel[]; rv _ ViewRec.ViewRef[ agg: values, createOptions: [highlightSelectedProc: FALSE], viewerInit: [iconic: FALSE] ]; }; Commander.Register["FinchValues", Initialize, "Produce user interface to change telephone parameters."]; }. ’FinchValuesImpl.mesa Copyright Σ 1987 by Xerox Corporation. All rights reserved. Last Edited by: Swinehart, July 24, 1987 3:31:51 pm PDT Κ– "Cedar" style˜šœ™Jšœ<™Kšœœœ˜&Kšœ˜Kšœœœ%œ˜QKšœ˜—K˜—š žœœ œ œœ œ˜WKšœIœ˜WK˜K˜—š ž œœ œœœ˜DJšœ7˜=˜J˜——š žœœ œœœ˜>šœ(˜.Jšœ;˜;J˜J˜——š žœœœœ œ˜SJšœœ˜8Jšœœ5˜>J˜J˜—šž œ˜%Kšœ#˜#K˜K˜K˜ šœ˜Kšœ ˜ Kšœ'œ˜/Kšœœ˜Kšœ˜—K˜K˜—K˜h—L™L˜—…—ΐj