(FILECREATED " 2-May-86 23:40:09" {QV}<NOTECARDS>1.3K>FGHPATCH031.;4 16707 changes to: (FNS NC.CloseDatabaseFile NC.QuitCard NC.OpenDatabaseFile) (VARS FGHPATCH031COMS) previous date: " 2-May-86 18:50:03" {QV}<NOTECARDS>1.3K>FGHPATCH031.;1) (* Copyright (c) 1986 by Xerox Corporation. All rights reserved.) (PRETTYCOMPRINT FGHPATCH031COMS) (RPAQQ FGHPATCH031COMS ((* * Implementation of hooks before/after Open and Close Notefiles) (* * New for NCDATABASE) (GLOBALVARS NC.OpenNoteFileFns NC.CloseNoteFileFns) (INITVARS NC.OpenNoteFileFns NC.CloseNoteFileFns) (* * From NCDATABASE) (FNS NC.OpenDatabaseFile NC.CloseDatabaseFile) (* * From NCCARDS) (FNS NC.QuitCard))) (* * Implementation of hooks before/after Open and Close Notefiles) (* * New for NCDATABASE) (DECLARE: DOEVAL@COMPILE DONTCOPY (GLOBALVARS NC.OpenNoteFileFns NC.CloseNoteFileFns) ) (RPAQ? NC.OpenNoteFileFns NIL) (RPAQ? NC.CloseNoteFileFns NIL) (* * From NCDATABASE) (DEFINEQ (NC.OpenDatabaseFile (LAMBDA (NoteFileOrFileName Access Don'tCacheTypesAndTitlesFlg QuietFlg Don'tCreateFlg Convertw/oConfirmFlg Don'tCreateArrayFlg Don'tTruncateFlg Don'tCreateInterfaceFlg Don'tGetSpecialCardsFlg InterestedWindow) (* fgh: " 2-May-86 18:47") (* * Open an already existing NoteFile and return a NoteFile object) (* * rht 8/7/84: For nonexistent files, asks user whether to create unless Don'tCreateFlg is non-nil.) (* * rht 1/9/85: Checks NC.UncachingNotCompleted global var. If non-nil, then previous notefile died unnaturally, so we first clear junk off the IDs.) (* * rht 8/6/85: Added Don'tTruncateFlg, which, if on, prevents the check for truncation.) (* * fgh 10/16/85 Updated to use new cacheing scheme.) (* * kirk 10/29/85: Now does cacheing of types and titles as background process.) (* * fkr 11/8/85: Converted from Streams to NoteFile object.) (* * kirk 30Nov85 Added a check for correct version number.) (* * rht 12/6/85: Moved Kirk's above patch to NC.CheckForNeededConversion and modified somewhat. Added check for plausible header.) (* * rht 1/8/86: Now reuses old notefile object if there is one for this filename.) (* * fgh 1/13/86: Fixed bug with returning File Name with embedded call to CreateDatabaseFile. Now just calls OpenDatabaseFile recursively using result of CreateDatabaseFile.) (* * fgh 1/16/86 Folded the cacheing of the special cards into BuildHashArray instead of making it a separate function after the hash array is already read in.) (* * kirk 20Jan86 Added NC.AskYesOrNo and InterestedWindow for prompt) (* * fgh 5/2/86 Implemented before and after opening hooks using NC.OpenNoteFileFns global variable.) (PROG (NoteFile FileName Name Stream NewStream Card CardTotal) (OR Access (SETQ Access (QUOTE BOTH))) (SETQ FileName (COND ((type? NoteFile NoteFileOrFileName) (SETQ NoteFile NoteFileOrFileName) (fetch (NoteFile FullFileName) of NoteFileOrFileName)) (T NoteFileOrFileName))) (if (NOT (OR FileName (SETQ FileName (NC.DatabaseFileName "Name of NoteFile to open:" " -- " T NIL NIL InterestedWindow)))) then (RETURN NIL)) (if (OPENP FileName) then (* need a better check here to bring up or create notefile icon if needed) (NC.PrintMsg NIL T FileName " is an already open file." (CHARACTER 13)) (RETURN NIL)) (if (NOT (SETQ Name (INFILEP FileName))) then (COND (Don'tCreateFlg (NC.PrintMsg NIL T "Couldn't find NoteFile " FileName "." (CHARACTER 13)) (RETURN NIL)) ((NC.AskYesOrNo (CONCAT "Unable to find NoteFile " FileName "." (CHARACTER 13) "Want to create a new NoteFile by that name? ") " -- " "Yes" T (NC.AttachPromptWindow InterestedWindow)) (SETQ NoteFile (NC.CreateDatabaseFile FileName NIL "Opening NoteFile" T)) (if (NOT (type? NoteFile NoteFile)) then (NC.PrintMsg NIL T "Unable to create Notefile " FileName "." (CHARACTER 13)) (RETURN NIL) else (RETURN (NC.OpenDatabaseFile NoteFile Access Don'tCacheTypesAndTitlesFlg QuietFlg Don'tCreateFlg Convertw/oConfirmFlg Don'tCreateArrayFlg Don'tTruncateFlg Don'tCreateInterfaceFlg Don'tGetSpecialCardsFlg)))) (T (RETURN 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 Name NoteFile (QUOTE BEFORE))))) then (RETURN NIL)) (* * Open the file) (OR QuietFlg (NC.PrintMsg NIL T "Opening ... " (CHARACTER 13))) (if (NULL (SETQ Stream (CAR (ERSETQ (OPENSTREAM Name Access (QUOTE OLD) (QUOTE ((TYPE BINARY)))))))) then (NC.PrintMsg NIL T "Couldn't open " FileName "." (CHARACTER 13)) (RETURN NIL)) (* Use existing notefile object if there is one for this file name.) (OR (type? NoteFile NoteFile) (SETQ NoteFile (OR (NC.NoteFileFromFileName FileName) (create NoteFile)))) (replace (NoteFile Stream) of NoteFile with Stream) (replace (NoteFile FullFileName) of NoteFile with (FULLNAME Stream)) (NC.SetMonitor NoteFile (CREATE.MONITORLOCK (MKATOM (CONCAT Name ":LOCK")))) (NC.GetNoteFileHeader NoteFile) (* See if notefile is out of date. If so, convert to current version.) (if (NOT (NC.CheckForNeededConversion NoteFile Convertw/oConfirmFlg)) then (CLOSEF (fetch (NoteFile Stream) of NoteFile)) (NC.PrintMsg NIL T "Open cancelled.") (RETURN NIL)) (* See if notefile header seems reasonable. If not, bail out.) (if (NOT (NC.PlausibleNoteFileHeaderP NoteFile)) then (NC.PrintMsg NIL NIL "Notefile has bad header. Please see a NoteCards wizard." (CHARACTER 13) "Open cancelled.") (RETURN NIL)) (COND ((NULL Don'tTruncateFlg) (* Can either bail out entirely or run inspector and then bail out.) (SELECTQ (SETQ NewStream (NC.CheckForNeededTruncation NoteFile Access)) (ABORT (CLOSEF Stream) (NC.PrintMsg NIL T "Open cancelled.") (RETURN NIL)) (ABORTANDINSPECT (CLOSEF Stream) (NC.ScavengerPhase1 Name) (RETURN NIL)) NIL) (AND (STREAMP NewStream) (replace (NoteFile Stream) of NoteFile with NewStream)))) (* * Stash the notefile in the global notefiles hash array.) (NC.StoreNoteFile NoteFile) (* * Build the hash array and cache the special cards if necessary) (OR Don'tCreateArrayFlg (NC.BuildHashArray NoteFile QuietFlg Don'tGetSpecialCardsFlg)) (OR Don'tGetSpecialCardsFlg (NC.GetSpecialCards NoteFile)) (* * Make sure the NF can't be closed by CLOSEALL) (WHENCLOSE (fetch (NoteFile Stream) of NoteFile) (QUOTE CLOSEALL) (QUOTE NO)) (COND ((NULL Don'tCacheTypesAndTitlesFlg) (* Cache all of the titles in this database) (replace (NoteFile CachingProcess) of NoteFile with (ADD.PROCESS (LIST (FUNCTION NC.CacheTypesAndTitles) NoteFile))))) (COND ((NULL Don'tCreateInterfaceFlg) (* Make an interface menu for this notefile.) (NC.SetUpNoteFileInterface NoteFile))) (AND (NULL QuietFlg) (NC.PrintMsg NIL T "Opened " (FULLNAME Stream) (CHARACTER 13))) (SETQ NC.LastNoteFileOpened NoteFile) (* * 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 Name NoteFile (QUOTE AFTER)))) (* * return the opened NF) (RETURN NoteFile)))) (NC.CloseDatabaseFile (LAMBDA (NoteFile) (* fgh: " 2-May-86 23:37") (* Close the currently open database file.) (* * 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.) (PROG ((Stream (fetch (NoteFile Stream) of NoteFile)) CardTotal ActiveCards) (* * Make sure NF is open) (if (OR (NULL (STREAMP Stream)) (NOT (OPENP Stream))) then (NC.PrintMsg NIL T (fetch (NoteFile FullFileName) of NoteFile) " is not an open NoteFile!!!" (CHARACTER 13)) (RETURN NIL)) (* * Look for cards on the screen. If there are active cards ask the user if they still want to close.) (if (AND (for Window in (OPENWINDOWS) thereis (LET (Card) (AND (SETQ Card (NC.CardFromWindow Window)) (NC.SameNoteFileP NoteFile (fetch (Card NoteFile) of Card))))) (NULL (NC.AskYesOrNo (CONCAT "There are still cards on the screen from this NoteFile " (fetch (NoteFile FullFileName) of NoteFile) "." (CHARACTER 13) "Want to close and save them? ") " -- " (QUOTE Yes) NIL (NC.AttachPromptWindow (WFROMMENU (fetch (NoteFile Menu) of NoteFile))) 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) (if (SETQ ActiveCards (NC.MapCards NoteFile (FUNCTION (LAMBDA (Card) Card)) (FUNCTION NC.ActiveCardP))) then (NC.PrintMsg NIL T "Closing and saving active cards ... ") (RESETLST (RESETSAVE NC.ForceSourcesFlg NIL) (RESETSAVE NC.ForceFilingFlg NIL) (RESETSAVE NC.ForceTitlesFlg NIL) (for Card in ActiveCards bind Window do (NC.QuitCard Card T NIL T) (if (SETQ Window (NC.FetchWindow Card)) then (bind (Process ←(WINDOWPROP Window (QUOTE PROCESS))) until (OR (NULL Process) (PROCESS.FINISHEDP Process)) do (BLOCK))))) (NC.PrintMsg NIL NIL "Done." (CHARACTER 13))) (* * Delete the types and titles caching process if still alive.) (DEL.PROCESS (fetch (NoteFile CachingProcess) of NoteFile)) (* * Checkpoint, then close the file) (NC.PrintMsg NIL T "Closing Notefile ... " (CHARACTER 13)) (NC.CheckpointDatabase NoteFile) (NC.ResetNoteFileInterface NoteFile) (NC.ForceDatabaseClose NoteFile) (NC.PrintMsg NIL T (fetch (NoteFile FullFileName) of NoteFile) " closed.") (* * 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)))) (* * Return the NF) (RETURN NoteFile)))) ) (* * From NCCARDS) (DEFINEQ (NC.QuitCard (LAMBDA (CardIdentifier CallCloseWFlg DontSaveFlg DontRecacheFlg) (* fgh: " 2-May-86 23:08") (* * Force note card specified by ID to quit or stop) (* * rht 2/9/85: New arg DontSaveFlg prevents NC.CardSaveFn from being called. Used when aborting a card. This is NOT equivalent to NC.QuitWithoutSaving.) (* * rht 6/25/85: Now moves card off screen before saving if NC.CloseCardsOffScreenFlg is non-nil.) (* * rht 6/25/85: Brought the insure proper filing check back here from NC.CardSaveFn. Bails out if user cancelled operation inside of NC.InsureProperFiling) (* * fgh 11/11/85: Updated to handle CardID and CardInfo objects.) (* * fgh 1/16/86 Put in code to insure that if one of the TopLevelCards is quit then it is reactivated immedialtely to make sure it stays cached for fast access.) (* * fgh 2/5/86 Added call to NC.ApplyFn) (* * fgh 5/2/86 Added DontRecacheFlg arg) (PROG ((Card (NC.CoerceToCard CardIdentifier)) Window) (SETQ Window (NC.FetchWindow Card)) (* The window not being open should mean that it's shrunken. If so, expand it.) (COND ((AND Window (NOT (OPENWP Window))) (EXPANDW Window))) (OR DontSaveFlg (COND ((EQ (NC.InsureProperFiling Card) (QUOTE CANCELLED)) (RETURN (QUOTE DON'T))))) (COND ((AND Window NC.CloseCardsOffScreenFlg) (COND ((NOT (NC.FetchSavedRegion Card)) (NC.SetSavedRegion Card (WINDOWPROP Window (QUOTE REGION))))) (MOVEW Window 1500 1500))) (OR DontSaveFlg (NC.CardSaveFn Card NC.CloseCardsOffScreenFlg)) (AND Window (WINDOWDELPROP Window (QUOTE CLOSEFN) (FUNCTION NC.QuitCard))) (RETURN (PROG1 (NC.ApplyFn QuitFn Card) (AND CallCloseWFlg Window (CLOSEW Window)) (* * if this is one of the top level cards, then make sure it stays cached) (if (AND (NC.TopLevelCardP Card) (NULL DontRecacheFlg)) then (NCP.ActivateCards Card))))))) ) (PUTPROPS FGHPATCH031 COPYRIGHT ("Xerox Corporation" 1986)) (DECLARE: DONTCOPY (FILEMAP (NIL (1033 14224 (NC.OpenDatabaseFile 1043 . 9120) (NC.CloseDatabaseFile 9122 . 14222)) ( 14250 16625 (NC.QuitCard 14260 . 16623))))) STOP