<<>> <> <> <> <> <> DIRECTORY Atom USING [ PropList ], BasicTime USING [ GMT ], LarkFeepRpcControl USING [ InterfaceRecord ], MBQueue USING [ Queue ], RedBlackTree USING [ EachNode, Table ], RefID USING [ ID ], Rope USING [ ROPE ], RPC USING [ EncryptionKey, InterfaceName ], ThParty USING [ Attributes, PartyInfo ], Thrush USING [ ActionReport, ConversationID, ConvEventBody, InterfaceSpec, NB, nullConvID, nullID, PartyID, Reason, ROPE, SHHH, SmartsID, StateInConv ], ThSmartsRpcControl ; FinchSmarts: CEDAR DEFINITIONS = { <> <<>> ConversationID: TYPE = Thrush.ConversationID; nullConvID: ConversationID = Thrush.nullConvID; NB: TYPE = Thrush.NB; nullID: RefID.ID = Thrush.nullID; PartyID: TYPE = Thrush.PartyID; Reason: TYPE = Thrush.Reason; ROPE: TYPE = Thrush.ROPE; SHHH: TYPE = Thrush.SHHH; PD: TYPE = RECORD [ -- Global values for all Finch instances doReports: BOOL¬FALSE, doPollingTimeouts: BOOL¬TRUE, pollDefault: INT ¬ 300, -- 5 minutes minimum between probes when disconnected timeoutInitiating: NAT ¬ 11, jayTimeout: NAT ¬ 1, encryptionRequested: BOOLEAN¬TRUE, waitsForConnect: NAT¬5, maxProseLength: INT¬1000, requests: MBQueue.Queue -- requests to report; must be serialized across all instances ]; pd: REF PD; lock: MONITORLOCK; FinchInfo: TYPE = REF FinchInfoBody; FinchInfoBody: TYPE = MONITORED RECORD [ -- Per Finch instance: one, for now smartsID: Thrush.SmartsID¬nullID, partyID: PartyID ¬ nullID, shh: SHHH¬NIL, conversations: LIST OF ConvDesc -- of ConvDescs --, stateChange: CONDITION, myName: ThSmartsRpcControl.InterfaceName ¬ [], myRName: ROPE ¬ NIL, myPassword: RPC.EncryptionKey ¬ NULL, prevThrushInstance: ROPE ¬ NIL, pollCondition: CONDITION, nextScheduledCheck: INT¬0, lastRemoteRemark: ROPE ¬ NIL, -- print each remote remark once only voicePath: BOOL ¬ FALSE, -- adjacent Lark is connected <> enabled: BOOL¬FALSE, -- all levels are willing for connection to be maintained. connected: BOOL ¬ FALSE -- connection is established, and we're registered with Thrush ]; info: FinchInfo; -- global description of what's going on. ConvDesc: TYPE = REF ConvDescBody; ConvDescBody: TYPE = RECORD [ <> situation: Thrush.ConvEventBody, -- amalgam of useful info from last-reported event previousSituation: Thrush.ConvEventBody, -- helps with hold/active state transitions <> ultimateState: Thrush.StateInConv ¬ idle, -- last state reached (except for idle) <> <> <> <> startTime: BasicTime.GMT¬NULL, subject: ROPE¬NIL, numParties: NAT¬0, numActive: NAT¬0, numIdle: NAT¬0, partyInfo: ThParty.PartyInfo¬NIL, -- Complete description as of some recent time feepInterfaceSpec: Thrush.InterfaceSpec, feepInterface: LarkFeepRpcControl.InterfaceRecord, feepShhh: Thrush.SHHH, <> clientData: REF ¬ NIL, <> props: Atom.PropList ¬ NIL, << Client-specific values, such as information used by synthesizer code and such. Placed here as a convenience for such services.>> firstReport: BOOL¬TRUE, originatorRecorded: BOOL¬FALSE, reportComplete: BOOL¬FALSE ]; <<>> <> InitFinchSmarts: PROC [thrushInstance: Thrush.ROPE¬NIL, key: ATOM, s: ReportSystemStateProc ¬ NIL, c: ReportConversationStateProc ¬ NIL, r: ReportRequestStateProc ¬ NIL]; <> FinchIsRunning: PROC RETURNS [finchIsEnabled: BOOL, finchIsRunning: BOOL, voicePath: BOOL]; <> Poke: PROC; <> <<>> UninitFinchSmarts: PROC[disable: BOOL¬TRUE]; <> PlaceCall: PROC [ convID: Thrush.ConversationID ¬ nullConvID, rName: ROPE¬NIL, number: ROPE¬NIL, useNumber: BOOL¬FALSE]; <> <> <> <> <> <> <> Join: PROC [convName: ROPE] RETURNS[nb: NB]; AnswerCall: PROC[convID: ConversationID]; DisconnectCall: PROC[ convID: ConversationID, reason: Thrush.Reason¬$terminating, comment: ROPE¬NIL, newState: Thrush.StateInConv ¬ $idle -- Can also be $failed, to terminate with fast-busy and such. ]; <> <> Feep: PROC[convID: ConversationID, feepString: ROPE]; ObtainNumbersForRName: PROC[rName: ROPE] RETURNS [fullRName: ROPE, number: ROPE, homeNumber: ROPE]; CurrentRName: PROC RETURNS [rName: ROPE]; CurrentConversations: PROC RETURNS [conversations: LIST OF ConvDesc]; <> <<>> FetchAttribute: PROC[attributes: ThParty.Attributes, attribute: ATOM, default: ROPE¬NIL] RETURNS [value: ROPE, valueLoc: ThParty.Attributes¬NIL]; <> <<>> ServiceConnect: PROC [ serviceName: ROPE, convID: Thrush.ConversationID ¬ nullConvID, createOK: BOOL¬TRUE, addOK: BOOL ¬ FALSE ] RETURNS [ nb: NB¬$success, cDesc: ConvDesc¬NIL ]; <> <> <> ObtainServiceInterface: PROC [ serviceName: ROPE, interfaceName: ROPE, cDesc: ConvDesc¬NIL ] RETURNS [ nb: NB¬$success, interfaceSpec: Thrush.InterfaceSpec ]; <> <> <> <> IdentifyVisitor: PROC[visitor, password: Rope.ROPE, complain: BOOL ¬ TRUE] RETURNS [nb: NB¬$success]; <> ReleaseVisitor: PROC[visitor, password: Rope.ROPE]; Problem: PROC[remark: ROPE¬NIL, nb: NB¬NIL]; <> <<>> RecordSystemStateFromSmartsReport: PROC[ nb: NB¬NIL, remark: Rope.ROPE, connected: BOOL, enabled: BOOL, voicePath: BOOL, remoteRemark: Rope.ROPE ] RETURNS[echoNB: NB] -- A convenience for callers -- ; <> <> <<>> ReportProcs: TYPE = REF ReportProcsBody; <> ReportProcsBody: TYPE = RECORD [ <> key: ATOM, -- identifies the purpose of this group of procedures position: INT ¬ 0, -- ordinal within reporting structure; see FinchSmartsImpl reportSystemState: ReportSystemStateProc, reportConversationState: ReportConversationStateProc, reportRequestState: ReportRequestStateProc, enabled: BOOL¬TRUE -- disable, don't delete ]; EnumerateIncreasing: PROC[self: RedBlackTree.Table, procToApply: RedBlackTree.EachNode]; <> ReportSystemStateProc: TYPE = PROC[ enabled: BOOL, connected: BOOL, voicePath: BOOL ]; <> ReportConversationStateProc: TYPE = PROC[ nb: NB, cDesc: ConvDesc, remark: ROPE¬NIL ]; <> ReportRequestStateProc: TYPE = PROC[ cDesc: ConvDesc, actionReport: Thrush.ActionReport, actionRequest: REF ] RETURNS [betterActionRequest: REF]; <> <> <<>> RegisterForReports: PROC [key: ATOM, s: ReportSystemStateProc ¬ NIL, c: ReportConversationStateProc ¬ NIL, r: ReportRequestStateProc ¬ NIL, other: ATOM¬NIL, before: BOOL ¬ TRUE]; <> <> <> <<>> UnRegisterForReports: PROC [key: ATOM]; <> <<>> ReportConversationState: PROC [nb: NB, cDesc: ConvDesc, remark: Rope.ROPE]; <> }. <<>> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> < ServiceConnect>> <> <> <2 parties in conversation)>> <> <> <> <<>> <> <> <> <<>> <> <> <<>> <<>> <<>> <<>>