<> <> <<>> DIRECTORY BluejaySmarts, IO, Names USING [ CurrentPasskey, OwnNetAddress ], NamesRPC USING [ StartConversation ], RPC USING [ AuthenticateFailed, EncryptionKey, ImportFailed, VersionRange ], Log USING [ ReportFR ], ThParty USING [ CreateParty, Register ], ThPartyRpcControl, Thrush USING [ nullHandle, PartyHandle, ROPE, SmartsHandle, unencrypted ], ThSmarts, ThSmartsRpcControl USING [ ExportInterface, InterfaceName ], ThVersions USING [ GetThrushVR, JayVersion, JayVR ] ; BluejayRegisterImpl: CEDAR PROGRAM IMPORTS BluejaySmarts, IO, Log, Names, NamesRPC, RPC, ThParty, ThPartyRpcControl, ThSmartsRpcControl, ThVersions EXPORTS BluejaySmarts = { OPEN IO; BluejayRegister: PUBLIC PROC [bluejayInstance, thrushInstance, serverPassword: Thrush.ROPE] RETURNS [partyID: Thrush.PartyHandle_Thrush.nullHandle, smartsID: Thrush.SmartsHandle_Thrush.nullHandle] = { myName: ThSmartsRpcControl.InterfaceName _ [ type: "ThSmarts.Lark", instance: bluejayInstance, version: ThVersions.JayVR]; serverPasskey: RPC.EncryptionKey _ Names.CurrentPasskey[serverPassword]; thVR: RPC.VersionRange = ThVersions.GetThrushVR; <> <<>> myName _ [ type: "ThSmarts.Lark", instance: bluejayInstance, version: ThVersions.JayVR]; ThSmartsRpcControl.ExportInterface[ interfaceName: myName, user: bluejayInstance, password: serverPasskey]; BluejaySmarts.jayShh _ IF NOT BluejaySmarts.encryptionRequested THEN Thrush.unencrypted ELSE NamesRPC.StartConversation [ caller: bluejayInstance, callee: thrushInstance --rName--, key: serverPasskey, level: --<>--CBCCheck ! RPC.AuthenticateFailed=>GOTO InitFailed]; <> <<>> ThPartyRpcControl.ImportInterface[ interfaceName: [type: "ThParty.Lark", instance: thrushInstance, version: thVR] ! RPC.ImportFailed=> IF why=wrongVersion THEN { Log.ReportFR["Bluejay version %d too old; import failed", $Bluejay, NIL, card[ThVersions.JayVersion]]; GOTO InitFailed; }]; BluejaySmarts.interfaceIsImported_TRUE; <<>> <> partyID_ThParty.CreateParty[type: recording, rName: NIL]; IF partyID=Thrush.nullHandle THEN ERROR; smartsID _ ThParty.Register[ shh: BluejaySmarts.jayShh, partyID: partyID, interface: NEW[ThSmartsRpcControl.InterfaceName_myName], properties: [x: voiceTerminal[machine: Names.OwnNetAddress[]]]]; IF smartsID=Thrush.nullHandle THEN GOTO InitFailed; EXITS InitFailed => IF BluejaySmarts.interfaceIsImported THEN ThPartyRpcControl.UnimportInterface[]; }; }.