BluejayRegisterImpl.mesa
Last modified by D. Swinehart, June 19, 1984 7:20:45 am PDT
DIRECTORY
BluejaySmarts,
IO,
Names  USING [ CurrentPasskey, --CurrentRName, --OwnNetAddress, StartConversation ],
RPC   USING [ AuthenticateFailed, EncryptionKey, ImportFailed, VersionRange ],
Log   USING [ ReportFR ],
ThParty  USING [ CreateParty, Register, RegisterClone ],
ThPartyRpcControl,
Thrush  USING [ nullHandle, PartyHandle, ROPE, SmartsHandle, unencrypted ],
ThSmarts,
ThSmartsRpcControl USING [ ExportInterface, InterfaceName ],
ThVersions USING [ GetThrushVR, JayVersion, JayVR ],
UserProfile USING [ Token ]
;
BluejayRegisterImpl: CEDAR PROGRAM
IMPORTS BluejaySmarts, IO, Log, Names, RPC, ThParty, ThPartyRpcControl, ThSmartsRpcControl, ThVersions, UserProfile
EXPORTS BluejaySmarts = {
OPEN IO;
myName: ThSmartsRpcControl.InterfaceName;
serverPassword: RPC.EncryptionKey;
BluejayRegister: PUBLIC PROC
RETURNS [partyID: Thrush.PartyHandle←Thrush.nullHandle,
smartsID: Thrush.SmartsHandle←Thrush.nullHandle] = {
thrushInstance: Thrush.ROPE=
UserProfile.Token[key: "ThrushClientServerInstance", default: "Morley.Lark"];
thVR: RPC.VersionRange = ThVersions.GetThrushVR;
Export ThSmarts Interface
myName ← [
type: "ThSmarts.Lark",
instance: UserProfile.Token[key: "BluejayServerInstance", default: "Strowger.Lark"],
version: ThVersions.JayVR];
serverPassword ← Names.CurrentPasskey[UserProfile.Token[
key: "BluejayServerPassword", default: "MFLFLX"]];
ThSmartsRpcControl.ExportInterface[
interfaceName: myName,
user: myName.instance,
password: serverPassword];
BJ.jayShh ← IF NOT BJ.encryptionRequested THEN Thrush.unencrypted
ELSE Names.StartConversation [
caller: myName.instance,
callee: thrushInstance --rName--,
<< must get from Identify[] in Thrush.LarkSmarts, I guess. >>
key: serverPassword,
level: --<<ECB>>--CBCCheck !
RPC.AuthenticateFailed=>GOTO InitFailed];
Import ThParty Interface
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;
}];
BJ.interfaceIsImported←TRUE;
Register First Jay Party.
partyID←ThParty.CreateParty[type: recording, rName: NIL];
IF partyID=Thrush.nullHandle THEN ERROR;
smartsID ← ThParty.Register[
shh: BJ.jayShh, partyID: partyID, interface: NEW[ThSmartsRpcControl.InterfaceName←myName],
properties: [x: voiceTerminal[machine: Names.OwnNetAddress[]]]];
IF smartsID=Thrush.nullHandle THEN GOTO InitFailed;
EXITS
InitFailed => IF BJ.interfaceIsImported THEN ThPartyRpcControl.UnimportInterface[];
};
}.