--ILTSetProfileImpl.mesa --Created by -- JFung.PASA 15-Nov-83 15:44:26 --last edited by -- JFung.PASA 23-Jan-84 11:10:41 DIRECTORY Cursor, Event, EventTypes USING [deactivate], Exec, Format USING [StringProc], FormSW USING [ AllocateItemDescriptor, ClientItemsProcType, CommandItem, Destroy, Display, FindItem, FreeHintsProcType, ItemHandle, MenuProcType, newLine, ProcType, SetTagPlaces, StringItem], Heap USING [systemZone], LispToolOps, Process, Put, Runtime USING [GetBcdTime], String, Supervisor USING [ AddDependency, AgentProcedure, CreateSubsystem, EnumerationAborted, RemoveDependency, SubsystemHandle], Time USING [Append, Unpack], Tool USING [ Create, Destroy, MakeFileSW, MakeFormSW, MakeMsgSW, MakeSWsProc, UnusedLogName], ToolDriver USING [Address, NoteSWs, RemoveSWs], ToolWindow USING [Activate, Deactivate, DisplayProcType, TransitionProcType], UserInput, Version USING [Append], Window USING [GetDisplayProc, Handle]; ILTSetProfileImpl: PROGRAM IMPORTS Cursor, Event, Exec, FormSW, Heap, LispToolOps, Process, Put, Runtime, String, Supervisor, Time, Tool, ToolDriver, ToolWindow, UserInput, Version, Window EXPORTS LispToolOps = BEGIN OPEN ILT: LispToolOps; DataHandle: TYPE = LONG POINTER TO Data; Data: TYPE = MACHINE DEPENDENT RECORD [ -- Message subwindow stuff msgSW(0): Window.Handle _ NIL, -- File subwindow stuff fileSW(2): Window.Handle _ NIL, -- Form subwindow stuff -- Note: enumerateds and booleans must be word boundary -- aligned as addresses for them must be generated --formSW: Window.Handle _ NIL, paramSW(4): Window.Handle _ NIL, commandSW(6): Window.Handle _ NIL, busy(8): BOOLEAN _ FALSE, -- command is running userName(9): LONG STRING _ NIL, userPassword(11): LONG STRING _ NIL, domainName(13): LONG STRING _ NIL, organizationName(15): LONG STRING _ NIL, filePathName(17): LONG STRING _ NIL, volName(19): LONG STRING _ NIL, volHints(21): LONG POINTER TO VolHints _ NIL, volPassword(23): LONG STRING _ NIL, vMemSize(25): File.PageCount _ 0, fileTable(27): LONG POINTER TO SizeHints _ NIL, connection(29): FileTransfer.Connection _ NIL, indicator(31): Indicator _ left, docType(32): DocType _ general, fileServer(33): ServerType _ NS]; debug: BOOLEAN _ FALSE; toolData: DataHandle _ NIL; windowHandle: Window.Handle _ NIL; active: BOOLEAN _ FALSE; agent: Supervisor.SubsystemHandle = Supervisor.CreateSubsystem[ CheckDeactivate]; formDisplay: ToolWindow.DisplayProcType _ NIL; heraldName: STRING _ [50]; CheckDeactivate: Supervisor.AgentProcedure = BEGIN IF event = EventTypes.deactivate AND windowHandle # NIL AND windowHandle = eventData AND toolData.busy THEN BEGIN Put.Line[toolData.msgSW, "The tool is busy: aborting deactivation"L]; ERROR Supervisor.EnumerationAborted; END; END; --CheckDeactivate ClearCommandSubwindow: PROCEDURE = BEGIN item: FormSW.ItemHandle; FOR i: CARDINAL _ 0, i + 1 UNTIL (item _ FormSW.FindItem[ILT.toolData.commandSW, i]) = NIL DO item.flags.invisible _ TRUE ENDLOOP; FormSW.Display[toolData.commandSW]; END; ClearFileSubwindow: PROCEDURE = BEGIN item: FormSW.ItemHandle; FOR i: CARDINAL _ 0, i + 1 UNTIL (item _ FormSW.FindItem[ILT.toolData.fileSW, i]) = NIL DO item.flags.invisible _ TRUE ENDLOOP; FormSW.Display[ILT.toolData.fileSW]; formDisplay _ Window.GetDisplayProc[ILT.toolData.fileSW]; END; ClearMsgSubwindow: PROCEDURE = BEGIN item: FormSW.ItemHandle; FOR i: CARDINAL _ 0, i + 1 UNTIL (item _ FormSW.FindItem[toolData.msgSW, i]) = NIL DO item.flags.invisible _ TRUE ENDLOOP; FormSW.Display[toolData.msgSW]; formDisplay _ Window.GetDisplayProc[toolData.msgSW]; END; ClearSubWindows: PROCEDURE = BEGIN --ClearFileSubwindow; ClearMsgSubwindow; END; ClientTransition: ToolWindow.TransitionProcType = -- This procedure is called whenever the system determines that this -- Tool's state is undergoing a user invoked transition. -- In this Example we demonstrate a technique that minimizes the memory -- requirements for a Tool that is inactive. BEGIN SELECT TRUE FROM old = inactive => BEGIN IF toolData = NIL THEN toolData _ Heap.systemZone.NEW[Data _ []]; --ProcessUserDotCM[]; active _ TRUE; END; new = inactive => BEGIN Supervisor.RemoveDependency[ client: agent, implementor: Event.toolWindow]; IF toolData # NIL THEN BEGIN FormSW.Destroy[toolData.paramSW]; FormSW.Destroy[toolData.commandSW]; Heap.systemZone.FREE[@toolData]; END; --ToolDriver.RemoveSWs[tool: "LispTool"L]; active _ FALSE; END; ENDCASE END; Confirm: PROCEDURE RETURNS [okay: BOOLEAN] = BEGIN Cursor.Set[mouseRed]; [, okay] _ UserInput.WaitForConfirmation[]; Cursor.Set[textPointer]; UserInput.WaitNoButtons[]; END; --Confirm FormSWMakeUserCM: FormSW.ProcType = BEGIN toolData.busy _ TRUE; ClearSubWindows; IF Confirm[] THEN MakeUserCM[]; toolData.busy _ FALSE; END; --FormSWMakeUserCM FormSWQuitProc: FormSW.ProcType = BEGIN IF debug THEN { Put.Line[toolData.fileSW, "Quit Proc..."L]; --Process.Pause[Process.SecondsToTicks[5]]; }; [] _ ToolWindow.Deactivate[windowHandle]; END; --FormSWQuitProc Init: PROCEDURE = BEGIN --h: Exec.Handle; --execWrite: Format.StringProc _ Exec.OutputProc[h]; --execWrite["Creating tool window.."L]; --Process.Pause[Process.SecondsToTicks[5]]; Exec.AddCommand["SetDomain.~"L, SetDomainExec, Unload]; --IF (windowHandle # NIL) AND ~active THEN -- ToolWindow.Activate[windowHandle] --ELSE windowHandle _ MakeTool[]; END; SetDomainExec: Exec.ExecProc = BEGIN execWrite: Format.StringProc _ Exec.OutputProc[h]; --execWrite["Creating tool window.."L]; --Process.Pause[Process.SecondsToTicks[5]]; IF (windowHandle # NIL) AND ~active THEN ToolWindow.Activate[windowHandle] ELSE windowHandle _ MakeTool[]; END; MakeCommands: FormSW.ClientItemsProcType = BEGIN OPEN FormSW; tabs: ARRAY [0..3) OF CARDINAL _ [0, 30, 60]; nItems: CARDINAL = 2; items _ AllocateItemDescriptor[nItems]; items[0] _ CommandItem[ tag: "Set Domain/Organization"L, place: newLine, proc: FormSWMakeUserCM]; -- newLine is required, else will get 915 trap --items[1] _ CommandItem[tag: "Set Volume Password"L, proc: FormSWQuitProc]; items[1] _ CommandItem[tag: "Quit"L, proc: FormSWQuitProc]; SetTagPlaces[items, DESCRIPTOR[tabs], FALSE]; RETURN[items, TRUE]; END; MakeParams: FormSW.ClientItemsProcType = BEGIN OPEN FormSW; tabs: ARRAY [0..7) OF CARDINAL _ [0, 28, 52, 56, 60, 68, 75]; nItems: CARDINAL = 2; items _ AllocateItemDescriptor[nItems]; items[0] _ StringItem[ tag: "Domain"L, string: @ILT.toolData.domainName, inHeap: TRUE, place: newLine]; items[1] _ StringItem[ tag: "Organization"L, string: @ILT.toolData.organizationName, inHeap: TRUE]; << items[2] _ StringItem[ tag: "Volume"L, string: @ILT.toolData.volName, inHeap: TRUE, place: newLine]; items[3] _ StringItem[ tag: "Volume Password"L, string: @ILT.toolData.volPassword, --feedback: password, inHeap: TRUE]; >> SetTagPlaces[items, DESCRIPTOR[tabs], FALSE]; RETURN[items, TRUE] END; MakeSWs: Tool.MakeSWsProc = BEGIN logName: STRING _ [40]; addresses: ARRAY [0..4) OF ToolDriver.Address; Tool.UnusedLogName[unused: logName, root: "SetProfile.log"L]; toolData.msgSW _ Tool.MakeMsgSW[window: window, lines: 1]; toolData.paramSW _ Tool.MakeFormSW[ window: window, formProc: MakeParams]; toolData.commandSW _ Tool.MakeFormSW[ window: window, formProc: MakeCommands]; toolData.fileSW _ Tool.MakeFileSW[window: window, name: logName]; Supervisor.AddDependency[client: agent, implementor: Event.toolWindow]; -- do the ToolDriver stuff addresses _ [ [name: "msgSW"L, sw: ILT.toolData.msgSW], --[name: "formSW"L, sw: ILT.toolData.formSW], [name: "ParamSW"L, sw: ILT.toolData.paramSW], [ name: "CmdSW"L, sw: ILT.toolData.commandSW], [ name: "fileSW"L, sw: ILT.toolData.fileSW]]; ToolDriver.NoteSWs[ tool: "MakeUserCMTool"L, subwindows: DESCRIPTOR[addresses]]; END; MakeTool: PROCEDURE RETURNS [wh: Window.Handle] = BEGIN String.AppendString[heraldName, "XSIS:Xerox Profile Tool "L]; String.AppendString[heraldName, " of "L]; Time.Append[heraldName, Time.Unpack[Runtime.GetBcdTime[]]]; heraldName.length _ heraldName.length - 3; String.AppendString[heraldName, " on Pilot Version "L]; Version.Append[heraldName]; RETURN[ Tool.Create[ makeSWsProc: MakeSWs, initialState: default, clientTransition: ClientTransition, name: heraldName, tinyName1: "Profile"L, tinyName2: "Tool"L]] END; ProfileToolActivate: PUBLIC PROCEDURE = BEGIN IF windowHandle = NIL THEN windowHandle _ MakeTool[]; ToolWindow.Activate[windowHandle]; Window.Stack[ windowHandle, Window.GetChild[ Window.GetParent[windowHandle]]]; -- top me Window.ValidateTree[]; END; --ProfileToolActivate Unload: Exec.ExecProc = BEGIN IF windowHandle # NIL THEN Tool.Destroy[windowHandle]; ILT.windowHandle _ NIL; [] _ Exec.RemoveCommand[h, "SetProfile.~"L]; END; -- Mainline code Init[]; END...