<> <> <> <<>> <> DIRECTORY Atom USING [GetPName], BluejaySmarts USING [infos, JayInfoBody], Commander USING [ CommandProc, Register ], CommandTool USING [ NextArgument ], IO USING [GetInt, RIS], Jukebox USING [ CloseJukebox, CreateJukebox, EOF, Error, Handle, MissingChirp, OpenJukebox ], MBQueue USING [ Create ], Nice USING [ View ], RecordingServiceRegister, RefID USING [ nullID ], Rope USING [Cat], RPC USING [ExportFailed], ThParty USING [ Enable, Register, RegisterServiceInterface ], Thrush USING [ Credentials, InterfaceSpec, NB, ROPE, SHHH ], VoiceRopeDB USING [Error, Handle, Open], VoiceRopeServerRpcControl USING [ExportInterface], VoiceUtils USING [ CmdOrToken, CurrentPasskey, FindWhere, OwnNetAddress, Problem, RegisterWhereToReport, Report, WhereProc ] ; RecordingServiceRegisterImpl: CEDAR PROGRAM IMPORTS Atom, BluejaySmarts, Commander, CommandTool, IO, Jukebox, MBQueue, Nice, RecordingServiceRegister, Rope, RPC, ThParty, VoiceRopeDB, VoiceRopeServerRpcControl, VoiceUtils EXPORTS RecordingServiceRegister = { jayShh: PUBLIC Thrush.SHHH; interfaceIsImported: PUBLIC BOOLEAN_FALSE; encryptionRequested: PUBLIC BOOLEAN _ TRUE; numParties: PUBLIC NAT_0; haveJuke: PUBLIC BOOL_TRUE; jukebox: PUBLIC Jukebox.Handle; database: PUBLIC VoiceRopeDB.Handle; defaultNumSmarts: NAT = 5; -- number of smarts created by default PD: TYPE = RECORD [ doReports: BOOL_FALSE, doNice: BOOL_FALSE, jayInitialized: BOOL_FALSE ]; pd: REF PD _ NEW[PD_[]]; voiceRopeSpec: Thrush.InterfaceSpec _ [ interfaceName: [type: "VoiceRopeServer"], serviceID: RefID.nullID]; Init: Commander.CommandProc = { numTrunks: NAT _ defaultNumSmarts; nb: Thrush.NB; bluejayInstance, thrushInstance, jukeboxName, databaseName, serverPassword: Thrush.ROPE; credentials: Thrush.Credentials; bluejayInstance _ CommandTool.NextArgument[cmd]; IF bluejayInstance#NIL THEN numTrunks _ IO.GetInt[IO.RIS[bluejayInstance]]; jukeboxName _ VoiceUtils.CmdOrToken[cmd:cmd, key: "BluejayJukeboxName", default: "Strowger.Jukebox"]; databaseName _ VoiceUtils.CmdOrToken[cmd:cmd, key: "VoiceRopeDBName", default: "VoiceRopeDB.df"]; bluejayInstance _ VoiceUtils.CmdOrToken[cmd:cmd, key: "BluejayServerInstance", default: "Strowger.Lark"]; thrushInstance _ VoiceUtils.CmdOrToken[cmd:cmd, key:"ThrushClientServerInstance", default: "Strowger.Lark"]; serverPassword _ VoiceUtils.CmdOrToken[cmd: cmd, key: "BluejayServerPassword", default: "MFLFLX"]; IF pd.jayInitialized THEN RETURN; <> <<>> VoiceUtils.RegisterWhereToReport[ReportBluejay, $Bluejay]; VoiceUtils.RegisterWhereToReport[ReportBluejay, $VoiceRope]; <<>> haveJuke_TRUE; TRUSTED { jukebox _ Jukebox.OpenJukebox[name: jukeboxName! Jukebox.Error => IF reason= NoJukebox THEN { haveJuke_FALSE; CONTINUE; }]; IF ~haveJuke THEN { Jukebox.CreateJukebox[jukeboxName, 5000, 100]; jukebox _ Jukebox.OpenJukebox[jukeboxName]; }; }; haveJuke_TRUE; database _ VoiceRopeDB.Open[databaseName ! VoiceRopeDB.Error => { VoiceUtils.Problem[Rope.Cat[Atom.GetPName[ec]," - ",explanation], $VoiceRope]; GOTO InitFailed; } ]; <> <<>> [nb, credentials] _ RecordingServiceRegister.BluejayRegister[bluejayInstance, thrushInstance, serverPassword]; IF nb#$success THEN GOTO InitFailed; { voiceRopeSpec.interfaceName.instance _ NIL; -- created that way. ThParty assigns one. voiceRopeSpec.serviceID _ credentials.smartsID; [nb, voiceRopeSpec] _ ThParty.RegisterServiceInterface[credentials: credentials, interfaceSpecPattern: voiceRopeSpec]; SELECT nb FROM $success, $stateMismatch => NULL; ENDCASE => GOTO CantExportVoice; VoiceRopeServerRpcControl.ExportInterface[ voiceRopeSpec.interfaceName, bluejayInstance, VoiceUtils.CurrentPasskey[serverPassword]!RPC.ExportFailed => GOTO CantExportVoice]; EXITS CantExportVoice => VoiceUtils.Problem["Couldn't export VoiceRopeServer from RecordingService"]; }; VoiceUtils.Report["Bluejay Smarts and VoiceRope Service initialized and exported, ThParty imported", $Bluejay]; <<>> <> FOR i: NAT IN [0..numTrunks) DO IF i#0 THEN { [nb, credentials] _ ThParty.Register[ shh: jayShh, interface: ["Foo"], clonePartyID: credentials.partyID, properties: [ role: $voiceTerminal, netAddress: VoiceUtils.OwnNetAddress[]] ]; IF nb#$success THEN ERROR; voiceRopeSpec.serviceID _ credentials.smartsID; [nb,] _ ThParty.RegisterServiceInterface[credentials: credentials, interfaceSpecPattern: voiceRopeSpec]; IF nb#$success THEN ERROR; }; IF ThParty.Enable[shh: jayShh, smartsID: credentials.smartsID]#$success THEN ERROR; -- <> -- BluejaySmarts.infos[numParties]_ NEW[BluejaySmarts.JayInfoBody _ [credentials: credentials, shh: jayShh, notifications: MBQueue.Create[]]]; numParties_numParties+1; ENDLOOP; pd.jayInitialized _ TRUE; EXITS InitFailed => TRUSTED { VoiceUtils.Problem["Bluejay: initialization failed", $Bluejay]; IF haveJuke THEN jukebox _ Jukebox.CloseJukebox[jukebox! Jukebox.Error, Jukebox.MissingChirp, Jukebox.EOF=>CONTINUE]; jayShh_NIL; }; }; ReportBluejay: VoiceUtils.WhereProc = TRUSTED { s_VoiceUtils.FindWhere[$System, NIL]; }; <<>> <> ViewCmd: Commander.CommandProc = { Nice.View[pd, "Bluejay PD"]; }; Commander.Register["VuJay", ViewCmd, "Program Management variables for Bluejay"]; Commander.Register["VRS", Init, "VRS (all defaulted) -- Start voice recording service\n VRS 5 ///Morley/Morley.jukebox ///Morley/VoiceRopeDB.df Morley.Lark Morley.Lark MFLFLX"]; }. <> <> <> <> <> <> <> <> <> <> <<>> <<>> <> <> <<>>