--ILTLoginImpl.mesa --Created by -- JFung.PASA 29-Sep-83 14:53:01 -- Modified version taken from Profile.mesa --last edited by -- JFung.PASA 7-Oct-83 9:58:07 DIRECTORY FormSW USING [Display, FindItem, ItemHandle, ProcType], Heap USING [systemZone], LispToolOps, Process, Profile USING [ debugging, GetDefaultDomain, GetDefaultOrganization, GetDefaultRegistry, GetLibrarian, GetLibrarianNames, GetUser, SetDebugging, SetDefaultDomain, SetDefaultOrganization, SetDefaultRegistry, SetLibrarian, SetUser], Put, String USING [CopyToNewString, EquivalentString, Replace], Supervisor USING [AgentProcedure, CreateSubsystem, SubsystemHandle]; ILTLoginImpl: PROGRAM IMPORTS FormSW, Heap, LispToolOps, Process, Profile, Put, String EXPORTS LispToolOps = BEGIN OPEN ILT: LispToolOps; z: UNCOUNTED ZONE = Heap.systemZone; ProfileItem: TYPE = { apply, user, password, registry, abort, domain, organization, debug, librarian, prefix, suffix}; -- if the positions of apply and abort change, you must edit ToggleCommands dirty: PACKED ARRAY ProfileItem OF BOOLEAN _ ALL[FALSE]; ProfileFields: TYPE = RECORD [ userName: LONG STRING _ NIL, userPassword: LONG STRING _ NIL, domain: LONG STRING _ NIL, organization: LONG STRING _ NIL, registry: LONG STRING _ NIL, librarianName: LONG STRING _ NIL, librarianNamePrefix: LONG STRING _ NIL, librarianNameSuffix: LONG STRING _ NIL]; ProfileData: TYPE = RECORD [ --formSW: Window.Handle _ NIL, debugging: BOOLEAN _ NULL, strings: ARRAY ProfileItem OF LONG STRING _ ALL[NIL], busy: BOOLEAN _ FALSE]; --agent: Supervisor.SubsystemHandle = Supervisor.CreateSubsystem[Notify]; data: LONG POINTER TO ProfileData _ NIL; debug: BOOLEAN _ FALSE; profileInfo: ProfileFields _ []; GetUser: PROCEDURE [name, password: LONG STRING] = { profileInfo.userName _ String.CopyToNewString[name, z]; profileInfo.userPassword _ String.CopyToNewString[password, z]}; GetDefaultDomain: PROCEDURE [domain: LONG STRING] = { profileInfo.domain _ String.CopyToNewString[domain, z]}; GetDefaultOrganization: PROCEDURE [organization: LONG STRING] = { profileInfo.organization _ String.CopyToNewString[organization, z]}; GetDefaultRegistry: PROCEDURE [registry: LONG STRING] = { profileInfo.registry _ String.CopyToNewString[registry, z]}; GetLibrarian: PROCEDURE [librarian: LONG STRING] = { profileInfo.librarianName _ String.CopyToNewString[librarian, z]}; GetLibrarianNames: PROCEDURE [prefix, suffix: LONG STRING] = { profileInfo.librarianNamePrefix _ String.CopyToNewString[prefix, z]; profileInfo.librarianNameSuffix _ String.CopyToNewString[suffix, z]}; GetProfileInfo: PROCEDURE = { Profile.GetUser[GetUser]; Profile.GetDefaultDomain[GetDefaultDomain]; Profile.GetDefaultOrganization[GetDefaultOrganization]; Profile.GetDefaultRegistry[GetDefaultRegistry]; Profile.GetLibrarianNames[GetLibrarianNames]; Profile.GetLibrarian[GetLibrarian]}; FreeProfileInfo: PROCEDURE = BEGIN z.FREE[@profileInfo.userName]; profileInfo.userName _ NIL; z.FREE[@profileInfo.userPassword]; profileInfo.userPassword _ NIL; z.FREE[@profileInfo.domain]; profileInfo.domain _ NIL; z.FREE[@profileInfo.organization]; profileInfo.organization _ NIL; z.FREE[@profileInfo.registry]; profileInfo.registry _ NIL; z.FREE[@profileInfo.librarianName]; profileInfo.librarianName _ NIL; z.FREE[@profileInfo.librarianNamePrefix]; profileInfo.librarianNamePrefix _ NIL; z.FREE[@profileInfo.librarianNameSuffix]; profileInfo.librarianNameSuffix _ NIL; END; DataChanged: FormSW.ProcType = BEGIN dirty[VAL[index]] _ TRUE; IF ~commandsShowing THEN { FormSW.FindItem[sw, ORD[ProfileItem.abort]].flags.invisible _ FALSE; FormSW.FindItem[sw, ORD[ProfileItem.apply]].flags.invisible _ FALSE; FormSW.Display[sw]}; commandsShowing _ TRUE; END; commandsShowing: BOOLEAN _ FALSE; -- since everything is done in the Notifier, no monitor is needed to protect this boolean LoginProc: PUBLIC PROCEDURE = BEGIN data _ Heap.systemZone.NEW[ProfileData]; IF debug THEN { Put.Line[ILT.toolData.fileSW, "Enter LoginProc..."L]; --Process.Pause[Process.SecondsToTicks[5]]; }; data.strings[user] _ ILT.toolData.userName; data.strings[password] _ ILT.toolData.userPassword; data.strings[domain] _ ILT.toolData.domainName; data.strings[organization] _ ILT.toolData.organizationName; Apply; Heap.systemZone.FREE[@data]; END; Apply: PROCEDURE = BEGIN ENABLE UNWIND => FreeProfileInfo[]; IF debug THEN { Put.Line[ILT.toolData.fileSW, "Enter Apply..."L]; --Process.Pause[Process.SecondsToTicks[5]]; }; IF data = NIL THEN RETURN; IF debug THEN { Put.Line[ILT.toolData.fileSW, "GetProfileInfo..."L]; --Process.Pause[Process.SecondsToTicks[5]]; }; GetProfileInfo[]; IF debug THEN { Put.Line[ILT.toolData.fileSW, "UpdatePrimary..."L]; --Process.Pause[Process.SecondsToTicks[5]]; }; IF ~Equal[profileInfo.userName, user] OR ~Equal[profileInfo.userPassword, password] THEN UpdatePrimary[]; << IF data.debugging # Profile.debugging THEN Profile.SetDebugging[data.debugging]; >> IF debug THEN { Put.Line[ILT.toolData.fileSW, "SetDefaultDomain..."L]; --Process.Pause[Process.SecondsToTicks[5]]; }; IF ~Equal[profileInfo.domain, domain] THEN Profile.SetDefaultDomain[data.strings[domain]]; IF debug THEN { Put.Line[ILT.toolData.fileSW, "SetDefaultOrganization..."L]; --Process.Pause[Process.SecondsToTicks[5]]; }; IF ~Equal[profileInfo.organization, organization] THEN Profile.SetDefaultOrganization[data.strings[organization]]; IF debug THEN { Put.Line[ILT.toolData.fileSW, "SetDefaultRegistry..."L]; --Process.Pause[Process.SecondsToTicks[5]]; }; IF ~Equal[profileInfo.registry, registry] THEN Profile.SetDefaultRegistry[data.strings[registry]]; IF debug THEN { Put.Line[ILT.toolData.fileSW, "UpdateLibrarian..."L]; --Process.Pause[Process.SecondsToTicks[5]]; }; IF ~Equal[profileInfo.librarianName, librarian] OR ~Equal[profileInfo.librarianNamePrefix, prefix] OR ~Equal[profileInfo.librarianNameSuffix, suffix] THEN UpdateLibrarian[]; IF debug THEN { Put.Line[ILT.toolData.fileSW, "FreeProfileInfo..."L]; --Process.Pause[Process.SecondsToTicks[5]]; }; FreeProfileInfo[]; END; UpdatePrimary: PROC = BEGIN Profile.SetUser[data.strings[user], data.strings[password]]; END; UpdateLibrarian: PROC = BEGIN Profile.SetLibrarian[ data.strings[librarian], data.strings[prefix], data.strings[ suffix]]; END; ResetData: PROC [display: BOOLEAN] = BEGIN ENABLE UNWIND => FreeProfileInfo[]; IF data = NIL OR data.busy THEN RETURN; GetProfileInfo[]; Update[profileInfo.userName, user, display]; Update[profileInfo.userPassword, password, display]; Update[profileInfo.registry, registry, display]; Update[profileInfo.domain, domain, display]; Update[profileInfo.organization, organization, display]; Update[profileInfo.librarianName, librarian, display]; Update[profileInfo.librarianNamePrefix, prefix, display]; Update[profileInfo.librarianNameSuffix, suffix, display]; << IF data.debugging # Profile.debugging THEN { data.debugging _ Profile.debugging; IF display THEN FormSW.DisplayItem[data.formSW, ORD[ProfileItem.debug]]}; >> FreeProfileInfo[]; END; Equal: PROC [s: LONG STRING, index: ProfileItem] RETURNS [BOOLEAN] = BEGIN RETURN[String.EquivalentString[data.strings[index], s]]; END; Update: PROC [profile: LONG STRING, index: ProfileItem, display: BOOLEAN] = BEGIN IF Equal[profile, index] THEN RETURN; String.Replace[@data.strings[index], profile, z]; --IF display THEN FormSW.DisplayItem[data.formSW, ORD[index]]; END; --Notify: Supervisor.AgentProcedure = {ResetData[display: TRUE]}; END.