XNSPrintRequestManager.mesa
Copyright Ó 1985, 1986, 1987 by Xerox Corporation. All rights reserved.
Bloomenthal, October 29, 1986 10:04:01 pm PST
Bill Jackson (bj) February 6, 1987 5:42:59 am PST
Routines to discover printer state
At some point, we should isolate the types PrinterProperties & PrinterStatus from Printing
GetPrinterProperties: PROC [printer: ROPE] RETURNS [service: CHName.Name, answer: Printing.PrinterProperties];
GetPrinterStatus: PROC [printer: ROPE] RETURNS [service: CHName.Name, answer: Printing.PrinterStatus];
Routines to make and monitor print requests
Context: TYPE ~ REF ContextObject;
ContextObject:
TYPE ~
RECORD [
copyCount: INT,
message: ROPE,
mediumHint: ROPE,
pageFirst: INT,
pageLast: INT,
printerName: ROPE,
printObjectCreateDate: CARD, -- BasicTime.ToNSTime[GMT]
printObjectName: ROPE,
printObjectSize: INT,
priorityHint: ROPE,
recipientName: ROPE,
releaseKey: INT,
senderName: ROPE,
stapled: BOOL,
twoSided: BOOL
];
GetDefaults:
PROC [context: Context ←
NIL]
RETURNS [newContext: Context];
decorates ContextObject from current user's defaults, supplying NIL will cause a ContextObject to be created. ContextObjects belong to the creator, so this one is yours... The intent here is to use a sequence like:
context ← GetDefaults[NIL];
context.printerName ← Quoth; -- a request to use a specal printer
context ← GetDefaults[context]; -- return to the printerName in the user's profile.
PrintRequestObjects have some internal constraints depending upon how this interface is implemented. Considering this, you should probably consider them immutable, unless of course you're sure that you own them. The intent is to capture all of the state required external to the implementation so that clients can examine the values, and to make debugging and/or exception handing easier.
InterpressMasterStatus: TYPE ~ Printing.InterpressMasterStatus;
RequestStatus:
TYPE ~
RECORD [
status: InterpressMasterStatus,
statusMessage: ROPE
];
StatusChangedProc: TYPE ~ PROC [request: PrintRequest];
PrintFromFile: PROC [file: ROPE, context: Context, update: StatusChangedProc ← NIL]
RETURNS [request: PrintRequest];
PrintFromStream:
PROC [s:
IO.
STREAM, context: Context, update: StatusChangedProc ←
NIL]
RETURNS [request: PrintRequest];
If update is non-NIL, then RegisterPrintRequest will be invoked. All of the commentary below on RegisterPrintRequest applies. There's no FS/IO error processing here, so anticipate some trickling up...
GetPrintRequestStatus: PROC [request: PrintRequest] RETURNS [status: RequestStatus];
Explicit request managment routines
ListChanged:
CONDITION;
Notified whenever someone either registers or unregisters a request
RegisterPrintRequest:
PROC [request: PrintRequest, update: StatusChangedProc ←
NIL];
Add request to the data base of pending requests for possible use by other applications. If update is non-NIL, then status updates will be performed, and the StatusChangedProc will be invoked (asyncronously) when lastStatus changes. This requires that StatusChangedProc persist until the request is unregistered. Update may do the unregister (I promise not to monitor lock this way...).
UnRegisterPrintRequest:
PROC [request: PrintRequest];
Remove request from the data base of pending requests.
GetPrintRequestList:
PROC
RETURNS [list: PrintRequestList];
Atomically return the data base of pending requests. The intent is that it will be (almost) immediately traversed. Updates will happen behind the scenes, so this represents some state from the past. Safe Storage provides adequate guarantees for this.
Private Stuff
CreateAttributes: PROC [context: Context] RETURNS [attributes: Printing.PrintAttributes];
CreateOptions: PROC [context: Context] RETURNS [options: Printing.PrintOptions];
CreatePrintRequest: PROC [context: Context] RETURNS [request: PrintRequest];
PrintRequestList: TYPE ~ LIST OF PrintRequest;
PrintRequest: TYPE ~ REF PrintRequestObject;
PrintRequestObject:
TYPE ~
RECORD [
context: Context, -- a copy of the ContextObject used to create this PrintRequestObject
update: StatusChangedProc,
distinguishedName: CHName.Name,
requestID: Printing.RequestID,
lastStatus: RequestStatus,
attributes: Printing.PrintAttributes,
options: Printing.PrintOptions,
fileName: ROPE,
ipMasterStream: IO.STREAM
];
}...