<> <> <> <> <<>> DIRECTORY Atom USING [ DottedPairNode ], BasicTime USING [ GMT, Now, Pack, Period, ToNSTime, Unpack, Unpacked, Update ], Convert USING [ RopeFromCard ], IO, Lark, LarkSmartsMonitorImpl, MBQueue USING [ QueueClientAction ], NamesGV USING [ GVSetAttribute ], RefID USING [ ID, Reseal ], Rope USING [ Concat, Equal, Fetch, FromChar, Length ], ThParty USING [ Alert, CreateConversation, GetPartyFromNumber, GetPartyFromFeepNum ], Thrush USING [ ConversationID, ConvEvent, IntervalSpec, PartyID, NB, nullConvID, nullID, ROPE, StateInConv ], ThSmartsPrivate USING [ AssessDamage, ChangeState, ConvDesc, DBInfo, Deregister, EnableSmarts, EnterLarkState, ForgetConv, GetConv, InterpretHookState, LarkFailed, LarkInfo, NoteNewState, OpenConversations, ParseState, SmartsInfo ], TU USING [ RefAddr ], VoiceUtils USING [ MakeAtom, Problem, ProblemFR ] ; LarkSmartsImpl: CEDAR MONITOR LOCKS root IMPORTS BasicTime, Convert, IO, MBQueue, root: LarkSmartsMonitorImpl, NamesGV, RefID, Rope, ThParty, ThSmartsPrivate, TU, VoiceUtils EXPORTS ThSmartsPrivate SHARES LarkSmartsMonitorImpl = { OPEN IO; <> CommandEvents: TYPE = Lark.CommandEvents; ConversationID: TYPE = Thrush.ConversationID; nullConvID: ConversationID=Thrush.nullConvID; ConvDesc: TYPE = ThSmartsPrivate.ConvDesc; disabled: Lark.Event = Lark.disabled; enabled: Lark.Event = Lark.enabled; endNum: Lark.Event = Lark.endNum; Reseal: PROC[r: REF] RETURNS[RefID.ID] = INLINE {RETURN[RefID.Reseal[r]]; }; IntervalSpec: TYPE = Thrush.IntervalSpec; LarkInfo: TYPE = ThSmartsPrivate.LarkInfo; NB: TYPE = Thrush.NB; nullID: RefID.ID = Thrush.nullID; OpenConversations: TYPE = ThSmartsPrivate.OpenConversations; PartyID: TYPE = Thrush.PartyID; ROPE: TYPE = Thrush.ROPE; SHHH: TYPE = Lark.SHHH; -- Encrypts conv. if first arg to RPC PROC SmartsInfo: TYPE = ThSmartsPrivate.SmartsInfo; StateInConv: TYPE = Thrush.StateInConv; StatusEvents: TYPE = Lark.StatusEvents; <<>> <<>> <> <<>> <> <<>> EventSpec: TYPE = REF EventSpecBody; EventSpecBody: TYPE = RECORD [ smartsInfo: SmartsInfo, sEvent: Lark.StatusEvent ]; LarkParseEvent: PUBLIC PROC[ smartsInfo: SmartsInfo, sEvent: Lark.StatusEvent] = { smartsInfo.requests.QueueClientAction[ QdLarkParseEvent, NEW[EventSpecBody _ [smartsInfo, sEvent]]]; }; QdLarkParseEvent: ENTRY PROC[r: REF] = { -- r is the EventSpec eventSpec: EventSpec = NARROW[r]; smartsInfo: SmartsInfo = eventSpec.smartsInfo; { ENABLE { UNWIND=>NULL; ThSmartsPrivate.LarkFailed => { VoiceUtils.ProblemFR["%g: Lark Failed", $Smarts, smartsInfo, TU.RefAddr[smartsInfo]]; GOTO Failed; }; }; sEvent: Lark.StatusEvent _ eventSpec.sEvent; IF ~LarkEnabled[smartsInfo] THEN RETURN; -- don't interfere with reverted call! sEvent _ ThSmartsPrivate.InterpretHookState[smartsInfo.larkInfo, sEvent, smartsInfo]; <> SELECT sEvent.device FROM nothing => RETURN; speakerSwitch, touchPad, hookSwitch => NULL; ENDCASE => ERROR; DoParse[smartsInfo, sEvent.event]; -- Interpret this event in light of past ones IF smartsInfo.haveArguments THEN { -- now are ready to execute an action routine val: INT_0; IF smartsInfo.Command=NIL THEN smartsInfo.Command _ CmdCall; -- was a phone number SELECT smartsInfo.parseState FROM inNum => val _ IO.GetInt[IO.RIS[smartsInfo.arguments]! IO.Error => SELECT ec FROM Failure, SyntaxError, Overflow => CONTINUE; ENDCASE]; ENDCASE; smartsInfo.Command[smartsInfo, val]; -- Execute the action routine []_SetParserIdle[smartsInfo, TRUE, TRUE]; }; <> <> <<<> <>>> <> <> <> <