<> <> <> <> <> DIRECTORY Atom USING [ PropList ], BasicTime USING [ GMT ], GVBasics USING [ Password ], 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)>> <> <> <> <<>> <> <> <> <<>> <> <> <<>> <<>> <<>> <<>>