BluejaySmartsInitLocalImpl.mesa
Last modified by D. Swinehart, December 28, 1983 10:16 pm
DIRECTORY
BluejaySmarts,
BluejayUtils USING [ Initialize, Uninitialize ],
FS USING [ Error ],
IO,
Jukebox USING [ CloseJukebox, CreateJukebox, OpenJukebox ],
Names USING [ CurrentPasskey, --CurrentRName, --OwnNetAddress, StartConversation ],
PupDefs USING [ PupSocket ],
RPC USING [ AuthenticateFailed, EncryptionKey, ImportFailed, VersionRange ],
Log USING [ FindWhere, Problem, RegisterWhereToReport, Report, WhereProc ],
ThParty USING [ CreateParty, Enable, Register, RegisterClone ],
ThPartyRpcControl,
Thrush USING [ ConversationHandle, NB, nullHandle, PartyHandle, ROPE, SHHH, SmartsHandle, unencrypted ],
ThSmarts,
ThSmartsRpcControl USING [ ExportInterface, InterfaceName ],
ThVersions USING [ GetThrushVR, JayVersion, JayVR ],
Commander USING [ CommandProc, Register ],
UserProfile USING [ Token ],
VoiceStream USING [ Handle ]
;
BluejaySmartsInitImpl:
CEDAR PROGRAM
IMPORTS BluejaySmarts, BluejayUtils, FS, IO, Jukebox, Log, Names, RPC, ThParty, ThPartyRpcControl, ThSmartsRpcControl, ThVersions, Commander, UserProfile = {
OPEN BJ: BluejaySmarts, IO;
PartyHandle: TYPE = Thrush.PartyHandle;
SHHH: TYPE = Thrush.SHHH;
SmartsHandle: TYPE = Thrush.SmartsHandle;
JayInfo: TYPE = BJ.JayInfo;
JayInfoBody: TYPE = BJ.JayInfoBody;
myName: ThSmartsRpcControl.InterfaceName;
serverPassword: RPC.EncryptionKey;
InitJay:
PROC[ numTrunks:
NAT ] =
TRUSTED {
partyID: Thrush.PartyHandle;
smartsID: Thrush.SmartsHandle;
clonePartyID: Thrush.PartyHandle;
thrushInstance: Thrush.
ROPE=
UserProfile.Token[key: "ThrushClientServerInstance", default: "Strowger.Lark"];
jukeboxName: Thrush.
ROPE =
UserProfile.Token[key: "BluejayJukeboxName", default: "//Bluejay/Strowger.Jukebox"];
info: BJ.JayInfo;
thVR: RPC.VersionRange = ThVersions.GetThrushVR;
Export ThSmarts Interface
Log.RegisterWhereToReport[ReportBluejay, $Bluejay];
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];
Log.Report["Jay Smarts Initialized and Exported", $Bluejay];
BluejayUtils.Initialize[];
Get encryption taken care of
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];
Make sure we can talk to a Thrush.
ThPartyRpcControl.ImportInterface[
interfaceName: [type: "ThParty.Lark", instance: thrushInstance, version: thVR] !
RPC.ImportFailed=>
IF why=wrongVersion
THEN {
Log.Report[IO.PutFR["Bluejay version %d too old; import failed",
card[ThVersions.JayVersion]], $Bluejay];
GOTO InitFailed;
}];
BJ.interfaceIsImported←TRUE;
Initialize anything that has to be set up on the Jay side.
BJ.haveJuke←TRUE;
BJ.handle ← Jukebox.OpenJukebox[name: jukeboxName!
FS.Error => IF error.group=user THEN { BJ.haveJuke←FALSE; CONTINUE; }];
IF ~
BJ.haveJuke
THEN {
Jukebox.CreateJukebox[jukeboxName, 5000, 100!FS.Error=>
IF error.group=user THEN { Log.Report[error.explanation, $Bluejay]; GOTO InitFailed; }];
BJ.handle ← Jukebox.OpenJukebox[jukeboxName];
};
BJ.haveJuke←TRUE;
Get Jay Parties
FOR i:
NAT
IN [0..numTrunks)
DO
partyID←ThParty.CreateParty[type: recording, rName: NIL];
IF partyID=Thrush.nullHandle THEN EXIT;
IF i=0
THEN {
clonePartyID ← partyID;
smartsID ← ThParty.Register[
shh: BJ.jayShh, partyID: partyID, interface: NEW[ThSmartsRpcControl.InterfaceName←myName],
properties: [x: voiceTerminal[machine: Names.OwnNetAddress[]]]] }
ELSE smartsID ← ThParty.RegisterClone[shh: BJ.jayShh, partyID: partyID, clonePartyID: clonePartyID];
IF smartsID=Thrush.nullHandle THEN EXIT; -- <<try to delete the Party?>>
IF ThParty.Enable[shh: BJ.jayShh, smartsID: smartsID]#success THEN ERROR; -- <<!!!!!!!!!>> --
info←NEW[JayInfoBody ← [smartsID: smartsID, partyID: partyID, shh: BJ.jayShh]];
BJ.infos[BJ.numParties]←info;
BJ.smartses[BJ.numParties]←smartsID;
BJ.numParties←BJ.numParties+1;
ENDLOOP;
EXITS
InitFailed => {
Log.Problem["Bluejay initialization failed", $Bluejay];
BluejayUtils.Uninitialize[];
BJ.jayShh←NIL;
IF BJ.haveJuke THEN BJ.handle ← Jukebox.CloseJukebox[BJ.handle!ANY=>CONTINUE];
IF BJ.interfaceIsImported THEN ThPartyRpcControl.UnimportInterface[];
};
};
ReportBluejay: Log.WhereProc =
TRUSTED {
s←Log.FindWhere[$System, NIL];
};
*************** Initialization ***************
JayCmd: Commander.CommandProc = TRUSTED { InitJay[5]; };
Commander.Register["Jay", JayCmd, "Start Bluejay server"];
}.