<> <> <<>> 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; <> <<>> 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[]; <> 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: --<>--CBCCheck ! RPC.AuthenticateFailed=>GOTO InitFailed]; <> 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; <> 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; <<>> <> 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; -- <> 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"]; }.