<> <> <> <> DIRECTORY BasicTime USING [GMT], NSExec USING [CheckForAbort, ClientID, Error, ExecProc, GetTTY, Handle, OutputHandle], NSString USING [AppendLongDecimal, CopyString, FreeString, nullString, String], PaperHandling USING [TwoPaperSizes], PaperTypes USING [PaperSize], PrincOps USING [bytesPerPage], PrintingTypes USING [Option], PSCommand USING [DeleteFile, DeleteFont, Error, FileFilter, FileProc, FontProc, GetPrintServiceStatus, ListFiles, ListFonts, PaperTray, PrintFile, PrintFileOptions], PSExec USING [GetClientID], PSExecInternal USING [DisplayCount, ExpandKeyAndPrint, GetList, KeyList, KeyListRep], PSExecMessages USING [Key], PSKMessages USING [GetHandle], PSState USING [StateHandle], TextInput USING [ChoiceIndex, GetChoice, GetDecimal, GetYesNo, YesOrNo], TTY USING [Handle, Rubout], XFormat USING [Blanks, CR, Date, Handle, NSLine, NSString, NSStringObject], XMessage USING [Get, Handle, Compose, StringArray]; PSExecBImpl: CEDAR PROGRAM IMPORTS NSExec, NSString, PSCommand, PSExec, PSExecInternal, PSKMessages, TextInput, TTY, XFormat, XMessage EXPORTS PSExecInternal SHARES NSString = BEGIN psClientID: NSExec.ClientID _ PSExec.GetClientID[]; <> stringArray: REF XMessage.StringArray _ NEW[XMessage.StringArray[3]]; <> nsDateAndTime: NSString.String _ NEW[TEXT[40]]; nsDateTimeObject: XFormat.Handle _ XFormat.NSStringObject[nsDateAndTime]; <> execMsgs: XMessage.Handle _ PSKMessages.GetHandle[exec]; DisplayFonts: PUBLIC NSExec.ExecProc = BEGIN <> ENABLE NSExec.Error => IF type = invalidExec THEN GOTO Exit; fontsDisplayed: CARDINAL _ 0; printingOption: PrintingTypes.Option _ PSCommand.GetPrintServiceStatus[].option; DisplayFont: PSCommand.FontProc = BEGIN <> sizeInPages: LONG CARDINAL _ (sizeInBytes + PrincOps.bytesPerPage - 1)/PrincOps.bytesPerPage; DisplayData[exec, packageName, sizeInPages, createDate]; fontsDisplayed _ fontsDisplayed + 1; IF fontsDisplayed MOD 4 = 0 THEN --check for user abort every 4 fonts IF NSExec.CheckForAbort[exec] = TRUE THEN continue _ FALSE; END; --DisplayFont PSCommand.ListFonts[proc: DisplayFont]; --enumerate every font installed PSExecInternal.DisplayCount[exec, fontsDisplayed, mFontsListed]; EXITS Exit => NULL; END; --DisplayFonts DeleteFonts: PUBLIC NSExec.ExecProc = BEGIN ENABLE NSExec.Error => IF type = invalidExec THEN GOTO Exit; tty: TTY.Handle _ NSExec.GetTTY[exec]; outputHandle: XFormat.Handle _ NSExec.OutputHandle[exec]; fontsDeleted: CARDINAL _ 0; stringArray: REF XMessage.StringArray _ NEW [XMessage.StringArray[1]]; <> freeThisString: NSString.String; yes: BOOLEAN _ FALSE; state: PSState.StateHandle _ PSCommand.GetPrintServiceStatus[]; DeleteFont: PSCommand.FontProc = BEGIN stringArray[0] _ packageName; freeThisString _ XMessage.Compose[M[mDeletePrompt], stringArray]; yes _ TextInput.GetYesNo[ tty: tty, prompt: freeThisString, default: no ! TTY.Rubout => GOTO Stop] = yes; NSString.FreeString[freeThisString]; IF yes THEN BEGIN freeThisString _ XMessage.Compose[M[mDeleting], stringArray]; outputHandle.Blanks[8]; outputHandle.NSString[freeThisString]; NSString.FreeString[freeThisString]; PSCommand.DeleteFont[packageName ! PSCommand.Error => WITH p: problem SELECT FROM disallowedInCurrentMode => BEGIN XFormat.CR[outputHandle]; stringArray[0] _ M[mDeleteFonts]; freeThisString _ XMessage.Compose[M[mConflictingMode], stringArray]; outputHandle.NSLine[freeThisString]; GOTO Stop; END; documentInProgress => BEGIN --We CAN get here since, with the advent of remote administration, two users may be logged at the same time. One could start printing before the other finishes deleting fonts. stringArray: REF XMessage.StringArray; outputHandle.NSLine[M[mDocInProgress]]; stringArray[0] _ M[mDeleteFonts]; freeThisString _ XMessage.Compose[M[mPleaseStopPrinting], stringArray]; outputHandle.NSLine[freeThisString]; GOTO Stop; END; ENDCASE; ]; outputHandle.NSLine[M[mDone]]; fontsDeleted _ fontsDeleted + 1; END; IF NSExec.CheckForAbort[exec] THEN continue _ FALSE; EXITS Stop => { NSString.FreeString[freeThisString]; RETURN [continue: FALSE]}; END; --DeleteFont IF state.clientControl.formatterEnabled OR state.clientControl.markerEnabled THEN BEGIN stringArray: REF XMessage.StringArray; stringArray[0] _ M[mDeleteFonts]; outputHandle.Blanks[2]; PSExecInternal.ExpandKeyAndPrint[exec, mPleaseStopPrinting, stringArray]; END ELSE BEGIN PSCommand.ListFonts[proc: DeleteFont]; PSExecInternal.DisplayCount[exec, fontsDeleted, mFontsDeleted]; END; EXITS Exit => NULL; END; --DeleteFonts DisplayTestPatterns: PUBLIC NSExec.ExecProc = BEGIN tpsDisplayed: CARDINAL _ 0; tpFilter: PSCommand.FileFilter _ [type: testPattern]; DisplayTestPattern: PSCommand.FileProc = BEGIN sizeInPages: LONG CARDINAL _ (sizeInBytes + PrincOps.bytesPerPage - 1)/PrincOps.bytesPerPage; DisplayData[exec, name, sizeInPages, createDate]; tpsDisplayed _ tpsDisplayed + 1; END; --DisplayTestPattern PSCommand.ListFiles[DisplayTestPattern, tpFilter]; PSExecInternal.DisplayCount[exec, tpsDisplayed, mTPsListed]; END; --DisplayTestPatterns DeleteTestPatterns: PUBLIC NSExec.ExecProc = BEGIN ENABLE NSExec.Error => IF type = invalidExec THEN GOTO Exit; tty: TTY.Handle _ NSExec.GetTTY[exec]; outputHandle: XFormat.Handle _ NSExec.OutputHandle[exec]; tpsDeleted: CARDINAL _ 0; stringArray: REF XMessage.StringArray; freeThisString: NSString.String; yes: BOOLEAN _ FALSE; DeleteTP: PSCommand.FileProc = BEGIN stringArray.data[0] _ name; freeThisString _ XMessage.Compose[M[mDeletePrompt], stringArray]; yes _ TextInput.GetYesNo[ tty: tty, prompt: freeThisString, default: no ! TTY.Rubout => GOTO Stop] = yes; NSString.FreeString[freeThisString]; IF yes THEN BEGIN freeThisString _ XMessage.Compose[M[mDeleting], stringArray]; outputHandle.Blanks[8]; outputHandle.NSString[freeThisString]; NSString.FreeString[freeThisString]; PSCommand.DeleteFile[name ! PSCommand.Error => WITH problem SELECT FROM disallowedInCurrentMode => BEGIN XFormat.CR[outputHandle]; stringArray[0] _ M[mDeleteTPs]; freeThisString _ XMessage.Compose[M[mConflictingMode], stringArray]; outputHandle.NSLine[freeThisString]; GOTO Stop; END; ENDCASE; ]; outputHandle.NSLine[M[mDone]]; tpsDeleted _ tpsDeleted + 1; END; IF NSExec.CheckForAbort[exec] THEN continue _ FALSE; EXITS Stop => { NSString.FreeString[freeThisString]; RETURN [continue: FALSE]}; END; --DeleteTP PSCommand.ListFiles[DeleteTP]; PSExecInternal.DisplayCount[exec, tpsDeleted, mTPsDeleted]; EXITS Exit => NULL; END; --DeleteTestPatterns PrintTestPattern: PUBLIC NSExec.ExecProc = BEGIN --Formerly SelectTestPattern <> ENABLE NSExec.Error => IF type = invalidExec THEN GOTO Exit; tty: TTY.Handle _ NSExec.GetTTY[exec]; outputHandle: XFormat.Handle _ NSExec.OutputHandle[exec]; TestPatternArray: TYPE = RECORD [data: SEQUENCE length: CARDINAL OF NSString.String]; tpArrayLengthIncrement: CARDINAL = 5; maxTPIndex: CARDINAL _ 0; tpChoices: REF XMessage.StringArray _ NEW[XMessage.StringArray[tpArrayLengthIncrement]]; --an array of strings which are the names of the test patterns available tpChoice: TextInput.ChoiceIndex; tpFilter: PSCommand.FileFilter _ [type: testPattern]; options: PSCommand.PrintFileOptions _ [unknown[]]; phoneNumber: NSString.String _ NSString.nullString; state: PSState.StateHandle _ PSCommand.GetPrintServiceStatus[]; copies: INTEGER _ 1; TRUSTED BEGIN ENABLE UNWIND => NULL; CacheTPs: PSCommand.FileProc = TRUSTED BEGIN <> GrowTPArray: PROCEDURE [larger: CARDINAL] = TRUSTED BEGIN oldTPChoices: REF XMessage.StringArray _ tpChoices; oldLength: CARDINAL = oldTPChoices.length; newLength: CARDINAL = oldLength + larger; tpChoices _ NEW[XMessage.StringArray[newLength]]; FOR i: CARDINAL IN [0..oldLength) DO tpChoices.data[i] _ oldTPChoices.data[i]; ENDLOOP; FOR i: CARDINAL IN [oldLength..newLength) DO tpChoices.data[i] _ NSString.nullString; ENDLOOP; END; --GrowTPArray IF maxTPIndex >= tpChoices.length THEN GrowTPArray[tpArrayLengthIncrement]; tpChoices.data[maxTPIndex] _ NSString.CopyString[name]; maxTPIndex _ maxTPIndex + 1; END; --CacheTPs GetFaxPaperSize: PROCEDURE [letterLegalSizeSupported: BOOLEAN] RETURNS [PaperTypes.PaperSize] = TRUSTED BEGIN --Proc determines whether size should be letter, legal or a4. IF letterLegalSizeSupported THEN BEGIN choices: CARDINAL = 2; sizeChoice: TextInput.ChoiceIndex; defaultSizeChoice: TextInput.ChoiceIndex = 0; msgKeys: PSExecInternal.KeyList _ NEW[PSExecInternal.KeyListRep[choices]]; sizeChoices: REF XMessage.StringArray _ NEW [XMessage.StringArray[2]]; PSExecInternal.GetList[choices, msgKeys, sizeChoices]; sizeChoice _ TextInput.GetChoice[tty: tty, prompt: M[mSelPaperSizeForTestPat], choices: sizeChoices, default: defaultSizeChoice]; RETURN [SELECT sizeChoice FROM 0 => letter, ENDCASE => legal]; END ELSE RETURN [a4]; --only one choice for a4 width paper. END; --GetFaxPaperSize GetTrayChoice: PROCEDURE [paperSupply: PaperHandling.TwoPaperSizes] RETURNS [PSCommand.PaperTray] = TRUSTED BEGIN --Used for raven and fx3500. choices: CARDINAL = 2; trayChoice: TextInput.ChoiceIndex; defaultSizeChoice: TextInput.ChoiceIndex = 1; msgKeys: PSExecInternal.KeyList _ NEW[PSExecInternal.KeyListRep[choices]]; <> paperChoices: REF XMessage.StringArray _ NEW [XMessage.StringArray[choices]]; msgKeys[0] _ SELECT paperSupply.size2 FROM letter => mLetter, legal => mLegal, a4 => mA4, a5 => mA5, jisB4 => mB4, jisB5 => mB5 ENDCASE => mAsterisk; msgKeys[1] _ SELECT paperSupply.size1 FROM letter => mLetter, legal => mLegal, a4 => mA4, a5 => mA5, jisB4 => mB4, jisB5 => mB5 ENDCASE => mAsterisk; IF msgKeys[0] = mAsterisk OR msgKeys[1] = mAsterisk THEN RETURN [default] ELSE BEGIN PSExecInternal.GetList[choices, msgKeys, paperChoices]; trayChoice _ TextInput.GetChoice[tty: tty, prompt: M[mSelPaperSizeForTestPat], choices: paperChoices, default: defaultSizeChoice]; RETURN [SELECT trayChoice FROM 0 => top, ENDCASE => bottom]; END; END; --GetTrayChoice FOR i: CARDINAL IN [0..tpChoices.length) DO --initialize tp array tpChoices.data[i] _ NSString.nullString; ENDLOOP; PSCommand.ListFiles[CacheTPs, tpFilter]; --store tp name strings in array IF maxTPIndex = 0 THEN {outputHandle.NSLine[M[mNoTPs]]; RETURN}; tpChoice _ TextInput.GetChoice[tty: tty, prompt: NSString.nullString, choices: tpChoices]; copies _ TextInput.GetDecimal[tty: tty, prompt: M[mEnterCopyC], min: 1, max: 999, default: 1]; WITH s: state SELECT FROM bansheeDl => options _ [bansheeDl[]]; d1 => options _ [d1[]]; < options _ [fax295[paperSize: GetFaxPaperSize[>> <> fax495 => BEGIN <> <> <> <> <> <> <> <> <> <> END; feps9700 => options _ [feps9700[]]; fx3500 => {}; <> <> <> raven => {IF s.paperSupply.size1 # s.paperSupply.size2 THEN options _ [raven[GetTrayChoice[s.paperSupply], aligned]] ELSE options _ [raven[]]}; ENDCASE => ERROR; outputHandle.Blanks[2]; PSCommand.PrintFile[tpChoices[tpChoice], M[mPrintTP], copies, options ! PSCommand.Error => { WITH problem SELECT FROM fileNotFound => outputHandle.NSLine[M[mTPNotavailable]]; invalidPhoneNumber => BEGIN outputHandle.NSString[M[mInvalidPhoneNo]]; outputHandle.NSLine[M[mCantQueueTP]]; END; ENDCASE => outputHandle.NSLine[M[mCantQueueTP]]; IF phoneNumber # NSString.nullString THEN NSString.FreeString[phoneNumber]; GOTO Exit}; ]; outputHandle.NSLine[M[mTPQueued]]; IF phoneNumber # NSString.nullString THEN NSString.FreeString[phoneNumber]; FOR i: CARDINAL IN [0..maxTPIndex) DO NSString.FreeString[tpChoices[i]]; ENDLOOP; END; --Enable and code EXITS Exit => NULL; END; --PrintTestPattern DisplayData: PROCEDURE [exec: NSExec.Handle, name: NSString.String, sizeInPages: LONG CARDINAL, createDate: BasicTime.GMT] = BEGIN outputHandle: XFormat.Handle _ NSExec.OutputHandle[exec]; stringArray[0] _ name; XFormat.NSString[outputHandle, NSString.AppendLongDecimal[NIL, sizeInPages]]; stringArray[1] _ NEW[TEXT[20]]; nsDateAndTime.length _ 0; XFormat.Date[nsDateTimeObject, createDate]; --appends date to nsDateAndTime stringArray[2] _ nsDateAndTime; PSExecInternal.ExpandKeyAndPrint[exec, mFontList, stringArray]; END; --DisplayData M: PROCEDURE [key: PSExecMessages.Key] RETURNS [string: NSString.String] = { RETURN[XMessage.Get[execMsgs, ORD[key]]]}; END. --PSExecBImpl LOG Date - Who - What 24-Oct-83 17:48:31 - Jacks - Created by splitting up PSTTYExecImpl. 2-Nov-83 13:27:34 - Jacks - Various small adjustments in InstallFromFloppy. 11-Nov-83 9:51:57 - Jacks - Replace PSExec interface with PSState.StateHandle and PSCommand.GetPrintServiceStatus. 21-Nov-83 10:58:39 - Jacks - Changed default value (yes or no) when asking whether to load a font; removed "Another floppy?" question. 28-Nov-83 17:11:49 - Jacks - Reset firstPieceFile in LoadPiece; Added catch phrases for PSCommand.Error[insufficientSpace]; renamed Abort Error to UserAbort; and added global var systemAbort; made many multi-floppy procs return dataSink parameter, in the case that it has been deleted it will return nullSinkStream value. 5-Dec-83 16:59:32 - Jacks - Removed erroneous comments. 20-Dec-83 7:59:54 - Jacks - Converted to PSFileTypes. 23-Dec-83 11:09:37 - Jacks - No longer reference PSFileTypes.tFont (=tFont300Portrait). 9-Jan-84 13:08:46 - Jacks - Added OPEN PSTTYExecInternal. 12-Jan-84 18:14:28 - Jacks - Added PrintTestPattern functionality for fax. 26-Jan-84 23:25:00 - Jacks - Converted to 8.0 SCS; added fix to SendFloppyData to send only exact byte count of file. 9-Feb-84 11:28:04 - Jacks - Improved mBadFontFileType message; added PrintFile functionality for fx3500. 23-Feb-84 21:07:48 - Jacks - Minor message key changes; converted to private heap. 26-Mar-84 10:46:27 - Jacks - Added fix to GetCommand to allow spaces in file names in mulit-floppy script. 30-Mar-84 14:44:35 - Jacks - Minor error message change; extra NIL checks in FreeGlobalSpace. 3-Apr-84 18:55:22 - Jacks - Added support for multiple execs. 18-Apr-84 10:38:33 - Jacks - Added tp paper size prompt for fax. 26-Apr-84 9:43:27 - Jacks - Removed dependence on TestPattern interface in PrintTestPattern. 31-May-84 9:48:46 - Jacks - Removed maxBytes constant from GetCommand which limited script file size; added enable clause to InterpreteScript. 15-Jun-84 11:10:23 - Jacks - Got rid of come truncation warnings in SendFloppyData. 20-Sep-84 13:26:42 - Jacks - For 9.0: added banshee, feps9700 and fax295; got rid of aps5. 5-Oct-84 13:48:07 - Jacks - Renamed from PSTTYExecBImpl to PSExecBImpl; added NSExec.CheckForAbort to many procs. 17-Oct-84 15:37:29 - Jacks - Renamed ttyHeap to execHeap. 14-Nov-84 14:07:35 - Jacks - Updated to new PSCommand/PSState interfaces; removed some TTY.Rubout catch phrases. 5-Feb-85 15:11:38 - Jacks - Added code to Install proc to avoid prompting user with names of test patterns inappropriate for the current printing option. 28-Feb-85 15:28:08 - Jacks - Now use PSCommandExtras.InstallFontX and InstallFileX instead of PSCommand.InstallFont and InstallFile. 13-Mar-85 10:02:27 - Jacks - Now use TestPattern interface for getting names of test patterns in Install proc. 20-Jun-85 11:11:25 - Jacks - Added copyright notice; updated to PS Euclid interfaces; turned off public error catching by SCS in all exec procs. 28-Jun-85 15:04:49 - Jacks - Added d1 code; removed SetCatching calls. 18-Jul-85 15:00:32 - Jacks - Converted to XMessage. 1-Aug-85 17:53:51 - Jacks - Converted to DeleteFontX and ListFontsX from PSCommandExtras; added catch phrases to PSCommandExtras.DeleteFont and PSCommand.DeleteFile. 14-Aug-85 12:01:08 - Jacks - Added catch for PSCommand.Erorr[undefined] which means "documentInProgress" in DeleteFonts. 9-Sep-85 13:26:46 - Jacks - Moved a string into the msg file. 11-Sep-85 13:32:52 - Jacks - Went back to using PSCommand.DeleteFont and ListFonts instead of PSCommandExtras. 24-Sep-85 14:27:25 - Jacks - PSCommandExtras folded into PSCommand. 6-Nov-85 13:07:46 - Jacks - Call PSKMessages for msg handle. 13-Dec-85 16:43:01 - Jacks - ExecMessages renamed to PSExecMessages.