(FILECREATED "25-Mar-87 17:59:59" {QV}<NOTECARDS>1.3K>NEXT>RHTPATCH226.;2 51752
changes to: (FNS NC.DeleteNoteCardInternal NC.GetCrossFileLinkDestCard NC.AskTraversalSpecs)
(VARS RHTPATCH226COMS)
previous date: "25-Mar-87 17:37:09" {QV}<NOTECARDS>1.3K>NEXT>RHTPATCH226.;1)
(* Copyright (c) 1987 by Xerox Corporation. All rights reserved.)
(PRETTYCOMPRINT RHTPATCH226COMS)
(RPAQQ RHTPATCH226COMS ((* * More prompt window and InterestedWindow fixes.)
(* * The function NC.GetPromptWindow should be removed from NCUTILITIES as
nobody calls it.)
(* * Changes to NCCROSSFILELINKS)
(FNS NC.GetCrossFileLinkDestCard)
(* * Changes to NCDATABASE)
(FNS NC.AbortSession NC.OpenNoteFile NC.CloseNoteFile NC.CheckpointNoteFile
NC.CheckForNotReadOnly NC.AskTraversalSpecs)
(* * Changes to NCCARDS)
(FNS NC.DeleteNoteCardInternal)))
(* * More prompt window and InterestedWindow fixes.)
(* * The function NC.GetPromptWindow should be removed from NCUTILITIES as nobody calls it.)
(* * Changes to NCCROSSFILELINKS)
(DEFINEQ
(NC.GetCrossFileLinkDestCard
(LAMBDA (CrossFileLinkCard InterestedWindow) (* rht: "25-Mar-87 17:36")
(* * Find the notefile corresponding to this crossfilelink and try to open it if not already open.
Then look for the card in there having the given UID. Return NIL if failed for any reason.)
(* * rht 11/10/86: Make sure CrossFileLinkCard is cached before fetching substance.)
(* * rht 11/19/86: Now rips off version number from destination notefile hint.)
(* * rht 12/11/86: Now checks that destination card is not deleted.)
(* * rht 12/16/86: Now takes InterestedWindow argument.)
(* * rht 3/25/87: Now calls NC.CoerceToInterestedWindow.)
(LET ((Title (NC.FetchTitle CrossFileLinkCard))
(SourceNoteFile (fetch (Card NoteFile) of CrossFileLinkCard))
Substance DestNoteFileUID DestFileHint DestCardUID DestNoteFile DestFileName WasOpenFlg)
(OR (OPENWP InterestedWindow)
(SETQ InterestedWindow (NC.CoerceToInterestedWindow SourceNoteFile)))
(if (NOT (NC.ActiveCardP CrossFileLinkCard))
then (NC.GetNoteCard CrossFileLinkCard))
(SETQ Substance (NC.FetchSubstance CrossFileLinkCard))
(SETQ DestCardUID (fetch (CrossFileLinkSubstance CrossFileLinkDestCardUID) of
Substance))
(SETQ DestNoteFileUID (fetch (CrossFileLinkSubstance CrossFileLinkDestNoteFileUID)
of Substance))
(SETQ DestFileHint (fetch (CrossFileLinkSubstance CrossFileLinkDestFileHint)
of Substance))
(SETQ DestNoteFile (NC.NoteFileFromNoteFileUID DestNoteFileUID))
(SETQ DestFileName (OR (AND (type? NoteFile DestNoteFile)
(fetch (NoteFile FullFileName) of DestNoteFile))
DestFileHint))
(if (OR (SETQ WasOpenFlg (NCP.OpenNoteFileP DestNoteFile))
(NC.AskYesOrNo (CONCAT "Trying to follow cross-file link to " Title "."
(CHARACTER 13)
"Okay to try opening " DestFileName "? ")
NIL "Yes" T InterestedWindow NIL NIL))
then (for while DestFileName bind Card NewFileName
do (if (OR (NCP.OpenNoteFileP DestNoteFile)
(NCP.OpenNoteFileP (SETQ DestNoteFile
(NC.OpenNoteFile (OR DestNoteFile
DestFileName)
NIL NIL NIL NIL NIL
NIL NIL NIL
InterestedWindow))))
then (if (NC.ValidCardP (SETQ Card (NC.CardFromUID
DestCardUID
DestNoteFile)))
then (if (NOT (EQUAL (SETQ NewFileName
(fetch (NoteFile
FullFileName)
of DestNoteFile))
(FULLNAME
(fetch (
CrossFileLinkSubstance CrossFileLinkDestFileHint) of Substance))))
then (replace (CrossFileLinkSubstance
CrossFileLinkDestFileHint)
of Substance
with (PACKFILENAME (QUOTE
VERSION)
NIL
(QUOTE
BODY)
NewFileName))
(NC.MarkCardDirty CrossFileLinkCard))
(RETURN Card)
else (NC.PrintMsg InterestedWindow T
"Couldn't find destination card in "
DestFileName "." (CHARACTER 13))
(OR WasOpenFlg (NC.AbortSession DestNoteFile
InterestedWindow T)))
else (NC.PrintMsg InterestedWindow T "Couldn't open " DestFileName
"."
(CHARACTER 13)))
(SETQ DestFileName (SETQ DestNoteFile NIL))
(AND (NC.AskYesOrNo "Want to try opening a different notefile? " NIL
"Yes"
NIL InterestedWindow)
(SETQ DestFileName (NC.AskUser "File name to try opening: "
NIL NIL T InterestedWindow))))))
))
)
(* * Changes to NCDATABASE)
(DEFINEQ
(NC.AbortSession
(LAMBDA (NoteFile InterestedWindow Don'tConfirmFlg QuietFlg)
(* rht: "25-Mar-87 17:24")
(* * Kill the current notecards session. Work lost since last checkpoint.)
(* * rht 7/14/85: Replaced the call to reset the main menu with call to NC.ResetMainMenu. Also took out redundant
reset of PSA.Database, since NC.ForceDatabaseClose is doing that.)
(* * fgh & rht 10/16/85 Update with new cacheing mechanism.)
(* * fkr 11/8/85 Updated to handle noteFile object and new CardID scheme.)
(* * kirk 20Jan86 Added Don'tCloseFlg to leave NoteFile open after done deleting changes.)
(* * kirk 23Jan86 Changed to use NC.AskYesOrNo)
(* * rht 7/2/86: No longer bugs you if no changes were made since last checkpoint. Removed Don'tCloseFlg arg and
added InterestedWindow arg.)
(* * rht 7/6/86: Now clears InterestedWindow of final truncating message.)
(* * rht 7/13/86: Added Don'tConfirmFlg and QuietFlg args. Note that Don'tConfirmFlg non-nil stops questioning of
user as to losing all changes.)
(* * kirk 11/17/86 Changed call on SETFILEINFO to pass stream instead of filename.)
(* * pmi 12/22/86 Made test for open notefile consistent with other NoteFile operations (ie. Checkpoint, Close))
(* * rht 2/19/87: Added DEL.PROCESS call to kill caching process.)
(* * rg 3/6/87 added NC.ProtectedSessionOperation wrapper)
(* * rht 3/25/87: Now calls NC.CoerceToInterestedWindow.)
(DECLARE (GLOBALVARS NC.MsgDelay))
(OR InterestedWindow (SETQ InterestedWindow (NC.CoerceToInterestedWindow NoteFile)))
(NC.ProtectedSessionOperation
"Abort Session" InterestedWindow
(PROG ((Stream (fetch (NoteFile Stream) of NoteFile))
(FullFileName (fetch (NoteFile FullFileName) of NoteFile))
(LastChkptPtr (fetch (NoteFile CheckptPtr) of NoteFile))
EndPtr CardTotal NewBytes ReturnValue)
(if (NULL (ERSETQ (SETQ ReturnValue (NC.NoteFileOpenP NoteFile))))
then (SETQ ReturnValue (QUOTE OpenPFailed)))
(if (NULL ReturnValue)
then
(* * NoteFile is not open.)
(NC.PrintMsg InterestedWindow T "Can't abort a closed notefile."
(CHARACTER 13))
(DISMISS NC.MsgDelay)
(NC.ClearMsg InterestedWindow T)
(RETURN NIL)
elseif (NOT (type? NoteFile ReturnValue))
then
(* * Error return from NoteFileOpenPFn)
(if (NULL (ERSETQ (NC.ReportError NIL (CONCAT "OpenP test on "
FullFileName
"failed because "
ReturnValue
(CHARACTER 13)
"OK to continue Abort. ↑ to abort Abort."))))
then (RETURN ReturnValue)))
(* * Delete the types and titles caching process if still alive. Have to do it now in order to make checking
operations that follow suitably efficient. Note its a bit too early since we can still cancel this close.
But any harm done is loss of speed if NoteFile remains open when close iss cancelled.)
(DEL.PROCESS (fetch (NoteFile CachingProcess) of NoteFile))
(SETQ EndPtr (GETEOFPTR Stream))
(SETQ NewBytes (IDIFFERENCE EndPtr LastChkptPtr))
(if (OR (ZEROP NewBytes)
Don'tConfirmFlg
(NC.AskYesOrNo (CONCAT "Do you wish to lose all changes since"
(CHARACTER 13)
"the last checkpoint (" NewBytes " bytes) of "
FullFileName)
"--" "Yes" T InterestedWindow NIL T))
then (LET ((CardNumber 0)
(CardTotal (fetch (NoteFile HashArraySize) of NoteFile)))
(NC.MapCards NoteFile
(FUNCTION (LAMBDA (Card)
(LET (Win)
(SETQ CardNumber (ADD1 CardNumber))
(OR QuietFlg (COND
((ZEROP (IREMAINDER CardNumber 100))
(NC.PrintMsg InterestedWindow T
"Quitting from active cards ... "
(CHARACTER 13)
"Processing item number "
CardNumber " out of "
CardTotal "."
(CHARACTER 13)))))
(COND
((NC.ActiveCardP Card)
(SETQ Win (NC.FetchWindow Card))
(NC.AbortCard Card QuietFlg)
(COND
(Win (bind (Process ←(WINDOWPROP
Win
(QUOTE PROCESS)))
until (OR (NULL Process)
(PROCESS.FINISHEDP
Process))
do (BLOCK))
(CLOSEW Win))))))))))
(COND
((LESSP LastChkptPtr EndPtr)
(OR QuietFlg (NC.PrintMsg InterestedWindow T "Truncating file "
FullFileName " ..."))
(COND
((NOT (SETFILEINFO Stream (QUOTE LENGTH)
LastChkptPtr))
(NC.PrintMsg InterestedWindow NIL "Couldn't truncate "
FullFileName "." (CHARACTER 13))))))
(NC.ResetNoteFileInterface NoteFile)
(NC.ForceDatabaseClose NoteFile))
(NC.ClearMsg InterestedWindow T)))))
(NC.OpenNoteFile
(LAMBDA (NoteFileOrFileName NoteFilesHashArray Don'tCacheTypesAndTitlesFlg Don'tCreateFlg
ConvertNoConfirmFlg Don'tCreateArrayFlg Can'tTruncateFlg
Don'tCreateInterfaceFlg Don'tGetSpecialCardsFlg InterestedWindow
PublicOrPrivate MenuPosition QuietFlg ReadOnlyFlg
Don'tCheckForTruncationFlg) (* rht: "25-Mar-87 17:30")
(* * fgh 5/23/86 Renamed to NC.OpenNoteFile from NC.OpenDatabaseFile. Total revamp to implement device vector.)
(* * kef 7/18/86: Inserted a call to stuff the UID into the NoteFile because BuildHashArray needed it.)
(* * kef 7/21/86: Moved up the install of the NoteFile into the NoteFileHashArray to before the building of the
NoteFile's hash array. The reason is that the remote multi client build hash array function needs to get a list of
UIDs, and in order to do this, it needs to grab a Courier stream for the NoteFile given only the UID.
It can only do this if the UID is registered in the NoteFilesHashArray.)
(* * fgh 8/31/86 Updated to account for changes made to system since 5/23/86 revamp. Changes reimplemented include:
(fgh 6/8/86 Added code to insure that two files with SameUIDP would never be open at once.)
(fgh 6/25/86 Added contention locks -- NC.ProtectedNoteFileOperation, Don'tCheckOperationInProgressFlg etc.)
(fgh 6/27/86 Added MenuPsotion arg to pass to SetUpNoteFileInterface) (kirk 15Jul86 Added call to
NC.SetUpNoteFileInterface if already open))
(* * fgh 9/1/86 Reimplemented ReadOnly NoteFile open.)
(* * fgh 9/4/86 Put in default for NoteFilesHashArray which is NC.NoteFilesHashArray)
(* * kirk/rht 8/29/86: Now resets Name after conversion from version 2 to version3.)
(* * rht 10/29/86: Changed "aborted" to "canceled" in message.)
(* * rht 10/31/86: Added Don'tCheckForTruncationFlg arg.)
(* * rht&pmi 11/21/86: Took away the protection from around the AFTER call to open events fns.)
(* * pmi 12/12/86: Added InterestedWindow argument to NC.SetUpNoteFileInterface so that it can print a prompt to
the user about placing the NoteFile menu.)
(* * rg 3/4/87 Added NC.ProtectedSessionOperation wrapper, removed Don'tCheckOperationsInProgressFlg)
(* * rht 3/25/87: Now calls NC.CoerceToInterestedWindow.)
(DECLARE (GLOBALVARS NC.OpenNoteFileFns NC.LastNoteFileOpened))
(* * NOTE: Session lock turns into NoteFile lock after NoteFile is created)
(PROG (NoteFile FileName ReturnValue CriticalUIDs)
(* * Figure out the name of the file containing the NoteFile)
(if (NULL (SETQ FileName (COND
((type? NoteFile NoteFileOrFileName)
(fetch (NoteFile FullFileName) of NoteFileOrFileName))
(NoteFileOrFileName)
(T (NC.DatabaseFileName "Name of NoteFile to open:" " -- " T NIL NIL
InterestedWindow)))))
then (RETURN)) (* SETQ FileName (OR (FULLNAME FileName) FileName))
(* * Create a NoteFile object or use existing notefile object if there is one for this file name.)
(SETQ NoteFile (if (type? NoteFile NoteFileOrFileName)
then NoteFileOrFileName
else (OR (NC.NoteFileFromFileName FileName)
(create NoteFile))))
(replace (NoteFile FullFileName) of NoteFile with FileName)
(replace (NoteFile ReadOnlyFlg) of NoteFile with ReadOnlyFlg)
(OR (OPENWP InterestedWindow)
(SETQ InterestedWindow (NC.CoerceToInterestedWindow NoteFile)))
(RETURN
(NC.ProtectedNoteFileOperation
NoteFile "Open NoteFile" InterestedWindow
(PROG NIL
(* * Figure out the appropriate device vector from the file name.)
(NC.InstallDeviceVectorInNoteFile NoteFile PublicOrPrivate)
(* * If this is an open NoteFIle, just bring up its menu.)
(if (NC.NoteFileOpenP NoteFile)
then (OR Don'tCreateInterfaceFlg (NC.SetUpNoteFileInterface
NoteFile
MenuPosition
InterestedWindow))
(* bring up or create notefile icon if needed)
(RETURN NIL))
(* * Notify user.)
(OR QuietFlg (NC.PrintMsg InterestedWindow T "Opening NoteFile: "
FileName " ..." (CHARACTER 13)))
(SETQ ReturnValue
(PROG NIL
(* * Run through OpenNoteFileFns with param of BEFORE. Exit if any returns DON'T)
(if (for Function in NC.OpenNoteFileFns
thereis (OR (EQ Function (QUOTE DON'T))
(EQ (QUOTE DON'T)
(APPLY* Function FileName NoteFile
(QUOTE BEFORE)))))
then (if (WINDOWP InterestedWindow)
then (NC.PrintMsg InterestedWindow NIL
"Open canceled for NoteFile "
FileName "." (CHARACTER
13))
(NC.ClearMsg InterestedWindow T))
(RETURN))
(* * Call the device specific OpenNoteFileFn, which returns a list of special UIDs)
(if (NULL (ERSETQ (SETQ ReturnValue
(APPLY* (fetch (NoteFile
OpenNoteFileFn)
of NoteFile)
NoteFile InterestedWindow
Don'tCheckForTruncationFlg))))
then (SETQ ReturnValue (QUOTE NoteFileOpenFailed)))
(* * Process error returns from the OpenNoteFileFn)
(if (NOT (LITATOM ReturnValue))
then
(* * OpenNoteFileFn returned correctly)
(SETQ CriticalUIDs ReturnValue)
else
(* * Error, process it.)
(SETQ ReturnValue
(OR (SELECTQ
ReturnValue
(NoteFileNotFound (NC.ProcessNoteFileNotFoundError
NoteFile NoteFilesHashArray
Don'tCacheTypesAndTitlesFlg
Don'tCreateFlg ConvertNoConfirmFlg
Don'tCreateArrayFlg
Can'tTruncateFlg
Don'tCreateInterfaceFlg
Don'tGetSpecialCardsFlg
InterestedWindow PublicOrPrivate
MenuPosition QuietFlg ReadOnlyFlg
Don'tCheckForTruncationFlg))
(NoteFileNeedsConversion (
NC.ProcessNoteFileNeedsConversionError
NoteFile NoteFilesHashArray
Don'tCacheTypesAndTitlesFlg
Don'tCreateFlg
ConvertNoConfirmFlg
Don'tCreateArrayFlg
Can'tTruncateFlg
Don'tCreateInterfaceFlg
Don'tGetSpecialCardsFlg
InterestedWindow
PublicOrPrivate
MenuPosition QuietFlg
ReadOnlyFlg
Don'tCheckForTruncationFlg))
(NoteFileNeedsTruncation (
NC.ProcessNoteFileNeedsTruncationError
NoteFile NoteFilesHashArray
Don'tCacheTypesAndTitlesFlg
Don'tCreateFlg
ConvertNoConfirmFlg
Don'tCreateArrayFlg
Can'tTruncateFlg
Don'tCreateInterfaceFlg
Don'tGetSpecialCardsFlg
InterestedWindow
PublicOrPrivate
MenuPosition QuietFlg
ReadOnlyFlg
Don'tCheckForTruncationFlg))
(NoteFileAlreadyOpen
(ERSETQ (NC.ReportError
NIL
(CONCAT (fetch (NoteFile
FullFileName)
of NoteFile)
" is already open for exclusive access. Open failed."))))
(NoteFileOpenFailed
(ERSETQ (NC.ReportError
NIL
(CONCAT "Open of "
(fetch (NoteFile
FullFileName)
of NoteFile)
" failed for unknown reason."))
))
(NoteFileHeaderBad
(ERSETQ (NC.ReportError
NIL
(CONCAT "Header of NoteFile "
(fetch (NoteFile
FullFileName)
of NoteFile)
" is bad. Contact a NoteCards wizard."))))
(PROGN (ERSETQ (NC.ReportError NIL
(CONCAT
"Unknown error code ("
ReturnValue
") returned by OpenNoteFileFn for NoteFile "
FileName)))))
ReturnValue))
(* * notify the user. if there's been a problem)
(if (AND (NOT (type? NoteFile ReturnValue))
(WINDOWP InterestedWindow))
then (NC.PrintMsg InterestedWindow NIL
"Open canceled for NoteFile "
FileName "." (CHARACTER 13))
(NC.ClearMsg InterestedWindow T))
(* * return whatever the error processing returned.)
(RETURN ReturnValue))
(SETQ ReturnValue)
(* * Make sure there is no other open NF with this UID.)
(LET (NF)
(if (AND (SETQ NF (GETHASH (fetch (
NoteFileCriticalUIDs NoteFile) of CriticalUIDs)
NC.NoteFilesHashArray))
(NEQ (fetch (NoteFile FullFileName)
of NoteFile)
(fetch (NoteFile FullFileName)
of NF))
(NC.NoteFileOpenP NF))
then (FLASHW PROMPTWINDOW)
(NC.PrintMsg PROMPTWINDOW T "Couldn't open "
FileName (CHARACTER 13)
"because "
(fetch (NoteFile FullFileName)
of NF)
" is already open "
(CHARACTER 13)
"and has the same UID.")
(NC.CloseNoteFile NoteFile InterestedWindow T)
(RETURN NIL)))
(* * If needed, build a hash array by calling the device specific BuilHashArrayFn.)
(replace (NoteFile UID) of NoteFile with (fetch
(
NoteFileCriticalUIDs NoteFile) of CriticalUIDs))
(* * Store this NoteFile object in the appropriate NoteFile hash array)
(NC.StoreNoteFileInHashArray NoteFile (OR NoteFilesHashArray
NC.NoteFilesHashArray))
(if (NOT Don'tCreateArrayFlg)
then
(OR QuietFlg (NC.PrintMsg InterestedWindow T
"Opening NoteFile: "
FileName
(CHARACTER 13)
"Building index array ..."
(CHARACTER 13)))
(if
(OR (NULL (ERSETQ (SETQ ReturnValue
(APPLY*
(fetch (NoteFile
BuildHashArrayFn)
of NoteFile)
NoteFile QuietFlg
InterestedWindow
(CONCAT "Opening NoteFile "
(fetch (NoteFile
FullFileName)
of NoteFile)
(CHARACTER 13))))))
(NOT (type? NoteFile ReturnValue)))
then
(* * Error during building of hash array)
(ERSETQ (NC.ReportError
NIL
(CONCAT
"Build Hash Array failed for NoteFile "
(fetch (NoteFile
FullFileName)
of NoteFile)
" because " ReturnValue)))
(RETURN)))
(* * Set up critical UIDs in NoteFile object using the values returned from OpenNoteFileFn.)
(NC.InstallCriticalUIDsInNoteFile NoteFile CriticalUIDs)
(* * if needed, cache the special cards)
(if (NOT Don'tGetSpecialCardsFlg)
then (NC.GetSpecialCards NoteFile QuietFlg InterestedWindow
(CONCAT "Opening NoteFile: "
(fetch (NoteFile
FullFileName)
of NoteFile)
(CHARACTER 13))))
(* * If needed, start the titles and types caching process)
(if (NOT Don'tCacheTypesAndTitlesFlg)
then (replace (NoteFile CachingProcess) of NoteFile
with (ADD.PROCESS (LIST (FUNCTION
NC.CacheTypesAndTitles)
NoteFile))))
(* * If needed, open up a NoteFile interface.)
(if (NOT Don'tCreateInterfaceFlg)
then (NC.SetUpNoteFileInterface NoteFile MenuPosition
InterestedWindow))
(* * Record this as the last NF opened.)
(SETQ NC.LastNoteFileOpened NoteFile)
(RETURN NoteFile)))
(if (type? NoteFile ReturnValue)
then
(* * Run through OpenNoteFIleFns with param of AFTER. Stop if any returns DON'T)
(for Function in NC.OpenNoteFileFns
thereis (EQ (QUOTE DON'T)
(APPLY* Function FileName NoteFile
(QUOTE AFTER))))
(* * Go home, returning NoteFile)
(if (NULL QuietFlg)
then (NC.PrintMsg InterestedWindow T "Opening NoteFile: "
FileName (CHARACTER 13)
"Done."
(CHARACTER 13))
(NC.ClearMsg InterestedWindow T))
(RETURN NoteFile)
else
(* * Bail out if open was unsuccessful.)
(RETURN NIL))))))))
(NC.CloseNoteFile
(LAMBDA (NoteFile InterestedWindow QuietFlg AutoConfirmFlg)
(* rht: "25-Mar-87 17:30")
(* * Close a NoteFIle)
(* * rht 10/23/84: Now gives user option of closing and saving all open cards on the screen.)
(* * rht 11/8/84: Put RESETLST around NC.CacheTitles call.)
(* * rht 1/9/85: Clear the NC.UncachingNotCompleted variable when close successfully completes.)
(* * rht 1/31/85: Added call to checkpoint database. That in turn dumps the next nodeID and next linkID.)
(* * rht 7/14/85: Replaced the call to reset the main menu with call to NC.ResetMainMenu. Also took out redundant
reset of PSA.Database, since NC.ForceDatabaseClose is doing that.)
(* * fgh 10/16/85 removed call to CacheTypesAndTitles because uncacheing now done automatically by cache
mechanism.)
(* * fkr 10/29/85: Now kills caching process from database streamprop.)
(* * fkr 11/8/85 Updated to handle new NoteFile object and new CardID scheme.)
(* * kirk 23Jan86 Changed to use NC.AskYesOrNo)
(* * rht 3/26/86: Now searches for active cards over whole notefile not just among cards up on screen.
Uses NC.MapCards.)
(* * kirk 28Apr86 Now returns NoteFile if successful.)
(* * fgh 5/2/86 Cleaned up. Ask user to confirm only if there are cards on the screen, not if there are active, but
not displayed ones. Added calls to the NC.CloseNoteFileFns before and after the closeing.)
(* * fgh 5/26/86 Revamp for device vector implementation.)
(* * kef 7/24/86: Changed the last expression at the end that smashes the NoteFile device out of the NoteFile data
structure. This is so that the Interface will not bomb trying to apply an OPENP function with a NIL Device.)
(* * kef 8/4/86: Added something to obtain the write lock on the parts of the active NoteCards that deactivating
will release. This is also so that any changes may be written to the server.)
(* * fgh 8/31/86 Reimplemented changes in system made since 5/23/86 conversion. Reimplemented changes include:
(* * fgh 6/4/86 Fixed so that shrunken cards are counted as open when asking for confirmation when there are open
cards on screen.) (* * fgh 6/13/86 Now checks for card operations in progress and kills them if necessary.)
(* * fgh 6/25/86 Added NC.ProtectedNoteFileOperation macro call. Added Don'tCheckOperationInProgressFlg args.)
(* * rht 7/4/86: Added check for readonly notefile.) (* * rht 7/13/86: Added QuietFlg arg. Note that this will
cause open cards on the screen to be closed and saved without asking user for confirmation.)
(* * rpr 11/13/86: After closing active cards, checks to see if any special cards were made active and closes
them.))
(* * pmi 12/22/86 Made test for open notefile consistent with other NoteFile operations (ie. Abort Checkpoint,))
(* * rht 2/16/87: Added AutoConfirmFlg argument to prevent user having to confirm whether to close and save open
cards. Note that QuietFlg is stronger than AutoConfirmFlg in that other messages are suppressed as well.)
(* * rg 3/4/87 changes for new concurrency machinery)
(* * rht 3/25/87: Now calls NC.CoerceToInterestedWindow.)
(DECLARE (GLOBALVARS NC.MsgDelay NC.CloseNoteFileFns))
(OR (OPENWP InterestedWindow)
(SETQ InterestedWindow (NC.CoerceToInterestedWindow NoteFile)))
(if (NC.ReadOnlyNoteFileP NoteFile)
then (NC.AbortSession NoteFile InterestedWindow)
else
(ALLOW.BUTTON.EVENTS)
(PROG ((FullFileName (fetch (NoteFile FullFileName) of NoteFile))
CardTotal ActiveCards ReturnValue (OperationMsg ""))
(* * Make sure NF is open)
(if (NULL (ERSETQ (SETQ ReturnValue (NC.NoteFileOpenP NoteFile))))
then (SETQ ReturnValue (QUOTE OpenPFailed)))
(if (NULL ReturnValue)
then
(* * NoteFile is not open.)
(NC.PrintMsg InterestedWindow T "Can't close a closed notefile."
(CHARACTER 13))
(DISMISS NC.MsgDelay)
(NC.ClearMsg InterestedWindow T)
(RETURN NIL)
elseif (NOT (type? NoteFile ReturnValue))
then
(* * Error return from NoteFileOpenPFn)
(if (NULL (ERSETQ (NC.ReportError NIL (CONCAT "OpenP test on "
FullFileName
"failed because "
ReturnValue
(CHARACTER 13)
"OK to continue Close. ↑ to abort Close."))))
then (RETURN ReturnValue)))
(* * Do the rest under an operation in progress lock.)
(RETURN
(NC.ProtectedNoteFileOperation
NoteFile "Close NoteFile" InterestedWindow
(PROG NIL
(RESETSAVE NIL (BQUOTE (NC.ClearMsg , InterestedWindow T)))
(* * Delete the types and titles caching process if still alive. Have to do it now in order to make checking
operations that follow suitably efficient. Note its a bit too early since we can still cancel this close.
But any harm done is loss of speed if NoteFile remains open when close iss cancelled.)
(DEL.PROCESS (fetch (NoteFile CachingProcess) of NoteFile))
(* * See if any cards have operations in progress. If so, kill them after confirming with user.)
(OR QuietFlg (NC.PrintMsg InterestedWindow T (OR OperationMsg "")
"Checking for card operations in progress ..."
(CHARACTER 13)))
(if (EQ (QUOTE ABORT)
(NC.CardOperationsInProgress NoteFile T))
then (RETURN NIL))
(NC.ClearMsg InterestedWindow NIL)
(* * If NULL QuietFlg then look for cards on the screen. If there are active cards ask the user if they still want
to close. When there's a non-NIL QuietFlg we just close the active cards.)
(if
(AND (NULL QuietFlg)
(NULL AutoConfirmFlg)
(for Window in (OPENWINDOWS)
thereis
(LET (Card)
(AND (SETQ Card
(OR (NC.CardFromWindow Window)
(AND (WINDOWP (WINDOWPROP
Window
(QUOTE ICONFOR)))
(NC.CardFromWindow
(WINDOWPROP Window
(QUOTE ICONFOR)))
)))
(NC.SameNoteFileP NoteFile (fetch
(Card NoteFile)
of Card)))))
(NULL (NC.AskYesOrNo (CONCAT
"There are still cards on the screen from this NoteFile "
FullFileName "." (CHARACTER
13)
"Want to close and save them? ")
" -- "
(QUOTE Yes)
NIL InterestedWindow NIL NIL)))
then (RETURN NIL))
(* * Run through CloseNoteFileFns with param of BEFORE. Exit if any returns DON'T)
(if (for Function in NC.CloseNoteFileFns
thereis (OR (EQ Function (QUOTE DON'T))
(EQ (QUOTE DON'T)
(APPLY* Function NoteFile (QUOTE BEFORE)
))))
then (RETURN NIL))
(* * Close all the active cards)
(OR QuietFlg (NC.PrintMsg InterestedWindow T (OR OperationMsg "")
"Checking for active cards ..."
(CHARACTER 13)))
(if (SETQ ActiveCards (NC.MapCards NoteFile (FUNCTION (LAMBDA (Card)
Card))
(FUNCTION NC.ActiveCardP)))
then (if (NULL QuietFlg)
then (NC.PrintMsg InterestedWindow T
"Closing and saving active cards ... "))
(RESETLST (RESETSAVE NC.ForceSourcesFlg NIL)
(RESETSAVE NC.ForceFilingFlg NIL)
(RESETSAVE NC.ForceTitlesFlg NIL)
(NC.CloseListOfActiveCards ActiveCards
InterestedWindow
QuietFlg)
(NC.CloseListOfActiveCards (for Card
in (
NC.FetchSpecialCards
NoteFile)
when
(NC.ActiveCardP
Card)
collect Card)
InterestedWindow
QuietFlg))
(OR QuietFlg (NC.PrintMsg InterestedWindow NIL "Done."
(CHARACTER 13))))
(* * Checkpoint the NoteFile.)
(OR QuietFlg (NC.PrintMsg InterestedWindow T "Closing Notefile ... "
(CHARACTER 13)))
(if (NULL (CAR (ERSETQ (SETQ ReturnValue
(NC.CheckpointNoteFile NoteFile
QuietFlg T
InterestedWindow
OperationMsg)))))
then (SETQ ReturnValue (QUOTE CheckpointFailed)))
(* * Process error returns from in NC.CheckpointNoteFile)
(if (NOT (type? NoteFile ReturnValue))
then (if (NULL (ERSETQ (NC.ReportError NIL
(CONCAT
"Checkpoint of NoteFile "
FullFileName
" failed because "
ReturnValue "."
(CHARACTER 13)
"OK to continue Close. ↑ to abort Close."))))
then (RETURN ReturnValue)))
(* * Close the file.)
(if (NULL (CAR (ERSETQ (SETQ ReturnValue
(APPLY* (fetch (NoteFile
CloseNoteFileFn)
of NoteFile)
NoteFile InterestedWindow)))))
then (SETQ ReturnValue (QUOTE CloseFailed)))
(* * Process error returns from the close.)
(if (NOT (type? NoteFile ReturnValue))
then (SELECTQ
ReturnValue
(NoteFileNotOpen
(if (NULL (ERSETQ (NC.ReportError
NIL
(CONCAT "NoteFile" FullFileName
" is not open."
(CHARACTER 13)
"OK to continue Close. ↑ to abort Close."))))
then (RETURN ReturnValue)))
(PROGN (ERSETQ (NC.ReportError NIL
(CONCAT
"Close of NoteFile "
FullFileName
" failed because "
ReturnValue
"."
(CHARACTER
13))))
(RETURN ReturnValue))))
(* * Run through CloseNoteFileFns with param of AFTER. Stop if any returns DON'T)
(for Function in NC.CloseNoteFileFns
thereis (EQ (QUOTE DON'T)
(APPLY* Function NoteFile (QUOTE AFTER))))
(* * Reset the interface and notify the user.)
(NC.ResetNoteFileInterface NoteFile)
(OR QuietFlg (NC.PrintMsg InterestedWindow T FullFileName " closed."))
(* * * Cleanup a bit.)
(* Clean off the card cache's)
(ADD.PROCESS (LIST (FUNCTION NC.CleanupCardObjects)
(fetch (NoteFile HashArray) of NoteFile)))
(* Clean off the NoteFile object to remove any
circularities.)
(create NoteFile smashing NoteFile Stream ← NIL UID ←(fetch
(NoteFile UID) of NoteFile)
FullFileName ← FullFileName Menu ←(fetch
(NoteFile Menu) of NoteFile)
NoteFileDevice ←(fetch (NoteFile
NoteFileDevice)
of NoteFile))
(* * Return the NF)
(RETURN NoteFile))))))))
(NC.CheckpointNoteFile
(LAMBDA (NoteFile QuietFlg Don'tSaveDirtyCardsFlg InterestedWindow OperationMsg)
(* rht: "25-Mar-87 17:31")
(* * Checkpoint a notefile by call the device specific checkpoint fn.)
(* * fgh 5/26/86 First created.)
(* * fgh 9/1/86 Updated with with changes made to checkpinting since 5/23/86. Reimplemented changes include:
(* * fgh 6/4/86 Added Don'tSaveDirtyCardsFlg to prevent double passes through active cards at close time)
(* * fgh 6/13/86 Changed printouts to NF menu. Added check for operations in progress.) (* * fgh 6/25/86 Put in
contention lock and NC.ProtectedNoteFileOperation Added Don'tCheckOperationInProgressFlg
Don'tCheckCardOperationsInProgressFlg & InterestedWindow args.) (* * rht 7/4/86: Added check for readonly
notefile.) (* * rht 7/16/86: Now passes QuietFlg arg down to NC.SaveDirtyCards.))
(* * pmi 12/3/86 Added check for open NoteFile before attempting Checkpoint (Code stolen from NC.CloseNoteFile))
(* * pmi 12/22/86 Made test for open notefile consistent with other NoteFile operations (ie. Abort Close))
(* * rg 3/4/87 rewritten for new concurrency machinery)
(* * rht 3/25/87: Now calls NC.CoerceToInterestedWindow.)
(DECLARE (GLOBALVARS NC.MsgDelay))
(OR (OPENWP InterestedWindow)
(SETQ InterestedWindow (NC.CoerceToInterestedWindow NoteFile)))
(NC.ProtectedNoteFileOperation
NoteFile "Checkpoint NoteFile" InterestedWindow
(PROG ((FullFileName (fetch (NoteFile FullFileName) of NoteFile))
ReturnValue)
(* * Make sure NF is open)
(if (NULL (ERSETQ (SETQ ReturnValue (NC.NoteFileOpenP NoteFile))))
then (SETQ ReturnValue (QUOTE OpenPFailed)))
(if (NULL ReturnValue)
then
(* * NoteFile is not open.)
(NC.PrintMsg InterestedWindow T "Can't checkpoint a closed notefile."
(CHARACTER 13))
(DISMISS NC.MsgDelay)
(NC.ClearMsg InterestedWindow T)
(RETURN NIL)
elseif (NOT (type? NoteFile ReturnValue))
then
(* * Error return from NoteFileOpenPFn)
(if (NULL (ERSETQ (NC.ReportError NIL (CONCAT "OpenP test on "
FullFileName
"failed because "
ReturnValue
(CHARACTER 13)
"OK to continue Checkpoint. ↑ to abort Checkpoint."))))
then (RETURN ReturnValue)))
(SETQ OperationMsg (CONCAT (OR OperationMsg "")
"Checkpointing " FullFileName (CHARACTER 13)))
(if (NC.CheckForNotReadOnly NoteFile InterestedWindow "Can't checkpoint ")
then (RETURN (PROGN (OR QuietFlg (RESETSAVE NIL
(BQUOTE (NC.ClearMsg
,
InterestedWindow T)))
)
(* * If appropriate, msg the user.)
(OR QuietFlg (NC.PrintMsg InterestedWindow T
"Checkpointing notefile "
FullFileName " ..."
(CHARACTER 13)))
(* * Save the dirty cards on the screen if necessary.)
(if (NULL Don'tSaveDirtyCardsFlg)
then (NC.SaveDirtyCards NoteFile T
InterestedWindow
OperationMsg QuietFlg))
(* Put out the new ChkptPtr to the file.)
(* * Call the device specific checkpoint fn.)
(if (NULL (ERSETQ (SETQ ReturnValue
(APPLY* (fetch
(NoteFile
CheckpointNoteFileFn)
of NoteFile)
NoteFile
InterestedWindow
OperationMsg QuietFlg)
)))
then (SETQ ReturnValue (QUOTE CheckpointFailed))
)
(* * Process the error returns.)
(if (type? NoteFile ReturnValue)
then
(* * Successful return.)
(OR QuietFlg (NC.PrintMsg InterestedWindow
T
(OR
OperationMsg "")
" Checkpoint done."
(CHARACTER
13)))
NoteFile
else
(* * Error return.)
(ERSETQ (NC.ReportError NIL
(CONCAT
"Checkpoint failed for "
FullFileName
" because "
ReturnValue ".")
))
ReturnValue))))))))
(NC.CheckForNotReadOnly
(LAMBDA (CardOrNoteFile InterestedWindow OperationMsg) (* rht: "25-Mar-87 17:33")
(* * If card or Notefile is read-only then print a message and return nil. Otherwise, return the card or notefile.)
(* * rht 3/25/87: Now calls NC.CoerceToInterestedWindow.)
(OR (OPENWP InterestedWindow)
(SETQ InterestedWindow (NC.CoerceToInterestedWindow CardOrNoteFile)))
(if (COND
((NC.CardP CardOrNoteFile)
(NC.ReadOnlyCardP CardOrNoteFile))
((type? NoteFile CardOrNoteFile)
(NC.ReadOnlyNoteFileP CardOrNoteFile)))
then (NC.PrintMsg InterestedWindow T OperationMsg "a notefile open for read-only."
(CHARACTER 13))
(DISMISS 1500)
(NC.ClearMsg InterestedWindow T)
NIL
else CardOrNoteFile)))
(NC.AskTraversalSpecs
(LAMBDA (NoteFile OldLinkLabels OldDepth Don'tAskFlg InterestedWindow)
(* rht: "25-Mar-87 17:36")
(* * Get a traversal specification from the user.)
(* * kirk 7/29/86 changed to allow backlinks and position specs above source card)
(* * rht 8/29/86: Fixed bug that was causing Depth spec to be ignored.)
(* * rht 3/9/87: Now accepts InterestedWindow argument. Now takes NoteFile rather than SourceCard arg.)
(* * rht 3/25/87: Now calls NC.CoerceToInterestedWindow.)
(DECLARE (GLOBALVARS NC.TraversalSpecsStylesheet))
(OR (OPENWP InterestedWindow)
(SETQ InterestedWindow (NC.CoerceToInterestedWindow NoteFile)))
(PROG ((LinkLabels (NC.RetrieveLinkLabels NoteFile T))
Choices Position)
(OR OldLinkLabels (SETQ OldLinkLabels LinkLabels))
(if Don'tAskFlg
then (RETURN (LIST OldLinkLabels OldDepth)))
(SETQ Position (AND (WINDOWP InterestedWindow)
(create POSITION
XCOORD ←(fetch (REGION LEFT)
of (WINDOWPROP InterestedWindow
(QUOTE REGION)))
YCOORD ←(fetch (REGION TOP) of (WINDOWREGION
InterestedWindow)))
))
(OR OldDepth (SETQ OldDepth 99999))
(RESETFORM (CURSOR (QUOTE WAITINGCURSOR))
(* The stylesheet is in a global var.
We only need to provide its position, items, and
selections.)
(STYLE.PROP NC.TraversalSpecsStylesheet (QUOTE POSITION)
Position)
(STYLE.PROP NC.TraversalSpecsStylesheet (QUOTE ITEMS)
(LIST (create MENU
ITEMS ← LinkLabels)
(create MENU
ITEMS ←(for Link in LinkLabels
collect (PACK* (QUOTE ←)
Link)))
(create MENU
ITEMS ←(QUOTE (0 1 2 3 4 5 6 7 8 9 INF)))))
(STYLE.PROP NC.TraversalSpecsStylesheet (QUOTE SELECTIONS)
(LIST (for Label in OldLinkLabels
when (NEQ (NTHCHAR Label 1)
(QUOTE ←))
collect Label)
(for Label in OldLinkLabels
when (EQ (NTHCHAR Label 1)
(QUOTE ←))
collect Label)
(if (OR (NOT (FIXP OldDepth))
(IGREATERP OldDepth 9)
(ILESSP OldDepth 0))
then (QUOTE INF)
else OldDepth))))
(SETQ Choices (STYLESHEET NC.TraversalSpecsStylesheet))
(RETURN (COND
(Choices (create TRAVERSALSPECS
LinkTypes ←(APPEND (CAR Choices)
(CADR Choices))
Depth ←(OR (FIXP (CADDR Choices))
MAX.FIXP)))
(T NIL))))))
)
(* * Changes to NCCARDS)
(DEFINEQ
(NC.DeleteNoteCardInternal
(LAMBDA (Card QuietFlg InterestedWindow IgnoreLinksFlg) (* rht: "25-Mar-87 17:59")
(* * Delete a single note card from a NoteFile)
(* * rht 8/11/86 Now calls NC.DeleteReferencesToCardFromShowLinks to smash any link icons in show links menus
pointing to this card.)
(* * kef 7/28/86: Added code to obtain all of the write locks deemed necessary.)
(* * kef 7/30/86: Modified to check for Client's concept of whether he owns the write lock or not, thus deciding
whether or not to setup the release of the write lock afterwards.)
(* * kef 7/31/86: Added the nesting of the obtaining writelocks with deactivating the card.)
(* * fgh 8/30/86 Translated APPLY* to NC.ApplyFn. Made cosmetic changes in FOR loop concewrning WriteLocks.)
(* * rht 1/16/87: Moved call to MarkCardDeletedFn after call to NC.QuitCard.)
(* * rg 3/11/87 renamed)
(* * rht 3/13/87: Added QuietFlg, InterestedWindow, and IgnoreLinksFlg args. The latter non-nil causes card
deletion but no link cutting.)
(* * rht 3/25/87: Now calls NC.CoerceToInterestedWindow.)
(RESETLST (RESETSAVE (CURSOR WAITINGCURSOR))
(RESETSAVE NIL (BQUOTE (NC.SetBeingDeletedFlg , Card NIL)))
(WITH.MONITOR (NC.FetchMonitor (fetch (Card NoteFile) of Card))
(OR (OPENWP InterestedWindow)
(SETQ InterestedWindow (NC.CoerceToInterestedWindow Card)))
(LET ((WriteLocks (for CardPart
in (QUOTE (SUBSTANCE TITLE TOLINKS FROMLINKS
GLOBALTOLINKS PROPLIST))
collect (CONS Card CardPart)))
ToLinks FromLinks Window BusyPart)
(NC.SetBeingDeletedFlg Card T)
(if (NOT IgnoreLinksFlg)
then (SETQ ToLinks (NC.RetrieveToLinks Card))
(SETQ FromLinks (NC.RetrieveFromLinks Card))
(for ToLink in ToLinks
do (NCONC WriteLocks
(for CardPart
in (QUOTE (TOLINKS FROMLINKS
GLOBALTOLINKS))
collect
(CONS (fetch (Link
DestinationCard)
of ToLink)
CardPart))))
(for FromLink in FromLinks
do (NCONC WriteLocks
(for CardPart
in (QUOTE (SUBSTANCE TOLINKS
FROMLINKS
GLOBALTOLINKS))
collect
(CONS (fetch (Link SourceCard)
of FromLink)
CardPart)))))
(* * The for... loop that follows is the condition that we can obtain all of the write locks on all of the card
parts collected in WriteLocks. If we obtain a writelock, setup a RESETSAVE to release it upon exit.
Then finally, if we do obtain a write lock, return T so that the for loop's "always" condition is satisfied.
If we don't obtain a write lock for a given card part, save that one as a variable so we can report it to the user.
Then return NIL, so that the for loop's "always" condition is not satisfied, and we bump out of the for loop.)
(OR QuietFlg (NC.PrintMsg InterestedWindow T
"Collecting write locks..."))
(COND
((for WriteLock in WriteLocks bind WLCard WLCardPart
when (NC.ValidCardP (SETQ WLCard (CAR WriteLock)))
always (SETQ WLCardPart (CDR WriteLock))
(COND
((NC.ApplyFn ObtainWritePermissionFn WLCard
WLCardPart)
(RESETSAVE NIL
(BQUOTE
(APPLY* , (fetch
(Card
ReleaseWritePermissionFn)
of WLCard)
, WLCard , WLCardPart))
)
T)
(T (SETQ BusyPart WriteLock)
NIL)))
(* * Call off to the MarkCardDeletedFn specific to the NoteFile.)
(RESETSAVE (for CardPart
in (QUOTE (SUBSTANCE TOLINKS GLOBALTOLINKS
PROPLIST))
do (NC.ApplyFn ObtainWritePermissionFn Card
CardPart))
(BQUOTE (NC.DeactivateCard , Card T)))
(NC.ApplyFn MarkCardDeletedFn Card)
(NC.SetToLinks Card NIL)
(NC.SetFromLinks Card NIL)
(if (NOT IgnoreLinksFlg)
then (OR QuietFlg (NC.PrintMsg InterestedWindow NIL
"Removing links to and from other cards..."))
(for ToLink in ToLinks when (NC.ValidLinkP
ToLink)
do (NC.DelFromLink ToLink)
(NC.DelReferencesToCardFromShowLinks
(fetch (Link DestinationCard)
of ToLink)
ToLink))
(for FromLink in FromLinks when (
NC.ValidLinkP
FromLink)
do (NC.DelToLink FromLink)
(NC.DelReferencesToCard
(fetch (Link SourceCard) of FromLink)
Card)
(NC.DelReferencesToCardFromShowLinks
(fetch (Link SourceCard) of FromLink)
FromLink))
(OR QuietFlg (NC.PrintMsg InterestedWindow NIL
"..done.")))
(if (NC.ActiveCardP Card)
then (NC.TurnOffDirtyFlgs Card)
(SETQ Window (NC.FetchWindow Card))
(AND Window (NC.GreyCard Card))
(NC.CloseAllPropListEditors Card)
(NC.QuitCard Card T T))
(NC.ApplyFn MarkCardDeletedFn Card)
(NC.SetNewCardFlg Card NIL))
(T (NC.CardPartBusy (CAR BusyPart)
(CDR BusyPart)
InterestedWindow))))))))
)
(PUTPROPS RHTPATCH226 COPYRIGHT ("Xerox Corporation" 1987))
(DECLARE: DONTCOPY
(FILEMAP (NIL (1107 5204 (NC.GetCrossFileLinkDestCard 1117 . 5202)) (5239 45646 (NC.AbortSession 5249
. 10730) (NC.OpenNoteFile 10732 . 24569) (NC.CloseNoteFile 24571 . 36906) (NC.CheckpointNoteFile
36908 . 41730) (NC.CheckForNotReadOnly 41732 . 42617) (NC.AskTraversalSpecs 42619 . 45644)) (45678
51670 (NC.DeleteNoteCardInternal 45688 . 51668)))))
STOP