DIRECTORY FinchSmarts USING [ ConvDesc, PlaceCall ], FinchTool USING [ CheckActive, FeepValue, finchQueue, finchToolHandle, GetSelectedDesc, Report, Status ], IO, MBQueue USING [QueueClientAction], NodeProps USING [ GetProp ], Rope, Thrush USING [ ConversationID, nullConvID ], TiogaButtons USING [ GetRope, TextNodeRef, TiogaButton, TiogaButtonProc ], TiogaOps USING [ Ref, Root, SetSelection ], ViewerClasses USING [ Column, Viewer, ViewerRec ], ViewerTools USING [ SetContents ], VoiceUtils USING [ Registrize ], WPDirectory; WPFinchDirectoryImpl: CEDAR PROGRAM IMPORTS Rope, FinchSmarts, FinchTool, IO, MBQueue, NodeProps, TiogaButtons, TiogaOps, ViewerTools, VoiceUtils EXPORTS WPDirectory = { OPEN IO; ROPE: TYPE = Rope.ROPE; Viewer: TYPE = ViewerClasses.Viewer; DirectoryInstance: TYPE = REF DirectoryInstanceBody; DirectoryInstanceBody: TYPE = RECORD [ rName: Rope.ROPE_NIL, name: Rope.ROPE_NIL, number: Rope.ROPE_NIL, homeNumber: Rope.ROPE_NIL, remarks: Rope.ROPE _ NIL, where: Where _ office, -- Oh, for closures! filled: BOOL_FALSE ]; Where: TYPE = { office, home }; DirectoryButtonNotifier: PUBLIC TiogaButtons.TiogaButtonProc = { directoryInstance: DirectoryInstance; SelectEntryInDirectory[button]; directoryInstance _ IF button.clientData = NIL THEN (button.clientData _ NEW[DirectoryInstanceBody _ []]) ELSE NARROW[button.clientData]; IF control OR mouseButton = red THEN RETURN; directoryInstance.where _ SELECT mouseButton FROM blue=>home, ENDCASE=>office; MBQueue.QueueClientAction[FinchTool.finchQueue, DirectoryButton, button]; }; SelectEntryInDirectory: PROC[button: TiogaButtons.TiogaButton] = { root: TiogaOps.Ref = TiogaOps.Root[button.startLoc.node]; v: ViewerClasses.Viewer = NARROW[NodeProps.GetProp[TiogaButtons.TextNodeRef[root], $Viewer]]; IF v=NIL THEN ERROR; TiogaOps.SetSelection[ viewer: v, start: [button.startLoc.node, 0], end: [button.endLoc.node, TiogaButtons.GetRope[button].Length[]], level: node, which: feedback ]; }; DirectoryButton: PROC[r: REF ANY] = { button: TiogaButtons.TiogaButton = NARROW[r]; directoryInstance: DirectoryInstance _ FillDirectoryInstance[button]; convDesc: FinchSmarts.ConvDesc = FinchTool.GetSelectedDesc[]; IF convDesc#NIL AND convDesc.situation.self.state > $parsing THEN FinchTool.Report["Call already in progress"] ELSE CallNumber[directoryInstance, directoryInstance.where, convDesc]; }; CallNumber: PROC[ instance: DirectoryInstance, where: Where, convDesc: FinchSmarts.ConvDesc] = { name, number: Rope.ROPE; convID: Thrush.ConversationID = IF convDesc=NIL THEN Thrush.nullConvID ELSE convDesc.situation.self.convID; IF instance=NIL OR ~FinchTool.CheckActive[FinchTool.finchToolHandle] THEN RETURN; name _ IF instance.rName#NIL THEN instance.rName ELSE instance.name; number _ IF where=home THEN instance.homeNumber ELSE instance.number; IF where=home AND Rope.Equal[number,""] THEN { FinchTool.Status[IO.PutFR["No home number for %s", rope[name]]]; } ELSE { contents: ROPE _ name; FinchTool.Status[IO.PutFR["Placing call to %s (%s)", rope[name], rope[number]]]; IF where=home THEN contents _ contents.Concat[" at home"]; ViewerTools.SetContents[FinchTool.finchToolHandle.calledPartyText, contents]; FinchSmarts.PlaceCall[convID: convID, rName: name, number: FinchTool.FeepValue[number], useNumber: where=home OR instance.rName=NIL]; }; }; FillDirectoryInstance: PROC [button: TiogaButtons.TiogaButton] RETURNS[instance: DirectoryInstance] = { entry: Rope.ROPE = TiogaButtons.GetRope[button]; entryStream: IO.STREAM = IO.RIS[entry]; rnameStart, rnameEnd: INT; instance _ NARROW[button.clientData]; IF instance=NIL THEN { instance _ NEW[DirectoryInstanceBody_[]]; button.clientData _ instance; }; IF instance.filled THEN RETURN; instance.filled _ TRUE; IF entry=NIL THEN RETURN; instance.name _ ToTab[entryStream]; instance.number _ ToTab[entryStream]; instance.homeNumber _ ToTab[entryStream]; instance.remarks _ ToTab[entryStream]; rnameStart _ instance.name.Find["<"]; IF rnameStart<0 THEN RETURN; rnameEnd _ instance.name.Find[">", rnameStart]; instance.rName _ VoiceUtils.Registrize[instance.name.Substr[rnameStart+1, rnameEnd-rnameStart-1]]; }; ToTab: PROC[s: IO.STREAM] RETURNS [field: Rope.ROPE_NIL] = { ToTabProc: IO.BreakProc = { RETURN[IF char=IO.TAB OR char=IO.CR THEN sepr ELSE other]; }; field _ s.GetTokenRope[ToTabProc ! IO.EndOfStream=> CONTINUE;].token; IF field.Equal["*"] THEN field_NIL; }; }. ’WPFinchDirectoryImpl.mesa Copyright c 1985 by Xerox Corporation. All rights reserved. Doug Terry, June 17, 1987 11:33:12 am PDT Whitepage directory facilities taken from FinchDirectoryImpl.mesa (on June 17, 1987 10:28:49 am PDT). Eventually this should be better integrated with Finch (the only change was exporting DirectoryButtonNotifier and removing stuff not needed by it). Types and Typeoids Selecting, Placing calls [parent: REF ANY, clientData: REF ANY _ NIL, mouseButton: Menus.MouseButton _ red, shift: BOOL _ FALSE, control: BOOL _ FALSE] Check these for new Cedar interp. This should launch the call Creating, Maintaining Directories ΚΎ˜šœ™Icodešœ Οmœ1™Jšžœ!˜(Jšœ žœ˜0Jšœ žœž œžœ˜'Jšœžœ˜Jšœ žœ˜%šžœ žœžœ˜Jšœ žœ<˜J—Jšžœžœžœ˜Jšœžœ˜Jšžœžœžœžœ˜J˜#J˜%J˜)J˜&J˜%Jšžœžœžœ˜Jšœžœ%˜/šœ˜JšœQ˜Q—J˜J˜—š œžœžœžœžœžœžœ˜<šœ žœ˜Jšžœžœžœžœžœžœžœžœžœ ˜=—Jšœ#žœžœ ˜EJšžœžœžœ˜#J˜J˜——J˜—…—4„