Open:
PUBLIC
PROC[
tunesDBName: Rope.ROPE ← NIL,
tunesDBInstance: Rope.ROPE ← NIL,
localName: Rope.ROPE ← NIL,
Complain: PROC[complaint: Rope.ROPE]←NIL] RETURNS [handle: Handle] = {
server: Rope.ROPE← UserProfile.Token["ThrushClientServerInstance", "Strowger.Lark"];
vdbHandle: VoiceDB.VoiceDBHandle;
ec: VoiceDB.ErrorCode;
expl: Rope.ROPE;
IF Complain = NIL THEN Complain ← FinchProblem;
IF tunesDBInstance = NIL THEN tunesDBInstance ← server;
IF tunesDBName =
NIL
THEN
tunesDBName ← Rope.Cat["///", Names.RnameToRspec[server].simpleName, "/Tunes"];
[vdbHandle, ec, expl] ← VoiceDB.Open[tunesDBName, tunesDBInstance, "Morley.Lark"];
IF ec#NIL THEN Complain[expl]; -- Trouble opening; success of future calls in doubt
handle ← NEW[HandleRec ← [vdbHandle: vdbHandle, Complain: Complain ]];
};
StartFinch:
PROC[handle: Handle, complain:
BOOL←
TRUE]
RETURNS [state: FinchSmarts.FinchState] = {
Should arrange to load Finch if not loaded, start it if not started.
At present, does neither, tells caller what's what, and complains if asked to.
RW:
PROC[c: Rope.
ROPE] = {
IF ~complain THEN RETURN;
handle.Complain[complaint: c];
};
SELECT (state ← FinchSmarts.CurrentFinchState[])
FROM
unknown => RW["Sorry, Finch needs to be loaded and started.\n"];
stopped => RW["Sorry, Finch needs to be connected to telephone server.\nUse \"Finch\" command.\n"];
running => NULL;
ENDCASE => ERROR;
handle.procs ← IF state=unknown THEN NIL ELSE FinchSmarts.GetProcs[];
};
ValidateHandle:
PROC[oldHandle: Handle]
RETURNS [handle: Handle] = {
handle ← oldHandle;
IF handle=NIL THEN handle ← defaultHandle;
IF handle=NIL THEN handle ← defaultHandle ← Open[];
};