DIRECTORY GVBasics USING [RName], IO USING [STREAM], Rope USING [ROPE], BasicTime USING [GMT, nullGMT], Thrush USING [EncryptionKey, nullKey, Tune, VoiceInterval]; Nuthatch: CEDAR DEFINITIONS = BEGIN updateProcess: PROCESS; Tune: TYPE = Thrush.Tune; VoiceFileID: TYPE = Rope.ROPE; IDType: TYPE = Rope.ROPE; ID: TYPE = Rope.ROPE; EncryptionKey: TYPE = Thrush.EncryptionKey; VoiceInterval: TYPE = Thrush.VoiceInterval; NuthatchUserHandle: TYPE = REF NuthatchUserRec; -- a REF to the data for a particular instance of a nuthatch client; multiple instances can be created. LogEntryType: {Create, MakeRefEntry, Incr, Decr, DeleteRefEntry}; NuthatchUserRec: TYPE = RECORD [ -- the data for a particular tool instance logStream: IO.STREAM _ NIL, -- handle for the enclosing container userName: GVBasics.RName_NIL, -- current status line updateProcess: PROCESS, -- the process that updates the DB from this user's log refIDType: Rope.ROPE_NIL, -- the user's type for each ID associated with a voice file logFileName: Rope.ROPE_NIL, -- log file name -- inUse: BOOL_FALSE, doneUsing: CONDITION, -- info for playback of recently-recorded tune tune: Nuthatch.Tune_0, -- playback Tune defaultType: Rope.ROPE_NIL, samples: INT_0, startSample: INT_0, key: EncryptionKey_Thrush.nullKey, logReadPoint: INT_0 -- read point in log -- ]; PD: TYPE = RECORD [ transactionOpen: BOOL_FALSE, reportLogOut: BOOL_FALSE, reportLogIn: BOOL_FALSE, buildMsgInfoIndices: BOOL_TRUE, buildInterestIndices: BOOL_TRUE ]; pd: REF PD; InitializeNuthatch: PROC[ userName: GVBasics.RName_NIL, logFileName: Rope.ROPE_NIL, RefIDType: Rope.ROPE_NIL, close: BOOL_TRUE] RETURNS [success: BOOL_TRUE, nuthatchUserHandle: NuthatchUserHandle]; CatalogVoiceFile: PROC[ nuthatchUserHandle: NuthatchUserHandle, voiceFileID: VoiceFileID, tuneNumber: INT, recordedTime: BasicTime.GMT, referenceCount: INT_ 0, samples: INT_ 0, startingSample: INT_ 0, encryptionKey: EncryptionKey_ NULL, close: BOOL_TRUE, time: BasicTime.GMT, type: Rope.ROPE ]; MakeInterestEntry: PROC[ nuthatchUserHandle: NuthatchUserHandle, voiceFileID: VoiceFileID_ NIL, refID: Rope.ROPE_ NIL, close: BOOL_TRUE, time: BasicTime.GMT_BasicTime.nullGMT ] ; AddInterest: PROC[ nuthatchUserHandle: NuthatchUserHandle, voiceFileID: VoiceFileID _ NIL, --optional -- refID: Rope.ROPE_ NIL, close: BOOL_TRUE, time: BasicTime.GMT_BasicTime.nullGMT ] ; -- Writes a log entry to increment the reference count for this voice file. If the voice message does not have an entry in the database, ignore it (can't tell till DB update time if that's so.) Either voiceFileID or RefID must be non-NIL. LoseInterest: PROC[ nuthatchUserHandle: NuthatchUserHandle, voiceFileID: VoiceFileID _ NIL, --optional -- refID: Rope.ROPE_ NIL, close: BOOL_TRUE, time: BasicTime.GMT_BasicTime.nullGMT ] ; RemoveInterestEntry: PROC[ nuthatchUserHandle: NuthatchUserHandle, voiceFileID: VoiceFileID _ NIL, --optional -- refID: Rope.ROPE_ NIL, close: BOOL_TRUE, time: BasicTime.GMT_BasicTime.nullGMT ] ; FinishUpdates: PROC[ nuthatchUserHandle: NuthatchUserHandle ] ; GetFileID: PROC[ ID: Rope.ROPE, nuthatchUserHandle: Nuthatch.NuthatchUserHandle, close: BOOL_TRUE] RETURNS [voiceFileID: VoiceFileID] ; GetTune: PROC[ voiceFileID: VoiceFileID] RETURNS [tune: Tune] ; GetDirectoryEntry: PROC [voiceFileID: VoiceFileID, close: BOOL_TRUE] RETURNS [ tuneNumber: Nuthatch.Tune_ -1, recordTime: BasicTime.GMT_BasicTime.nullGMT, creator: GVBasics.RName_ NIL, samples: INT_ -1, startSample: INT_ -1, expirationDate: BasicTime.GMT_BasicTime.nullGMT, encryptionKey: Nuthatch.EncryptionKey_Thrush.nullKey, type: Rope.ROPE_NIL , referenceCount: INT_ 0, found: BOOL_FALSE]; NHTime: PROC[time: BasicTime.GMT] RETURNS [nhTime: BasicTime.GMT]; currentNUH: NuthatchUserHandle; -- right now, there's just one of them. END. File: Nuthatch.mesa Copyright c 1985 by Xerox Corporation. All rights reserved. Swinehart, October 17, 1985 12:19:08 pm PDT Created by: Lia on August 31, 1983 Last Edited by: Lia, September 30, 1983 11:16 am InitializeNuthatch verifies that the nuthatch database is around and usable, and then looks for the user's log file. In nuthatchUserHandle, InitializeNuthatch initializes the logstream as the current log stream, userName as the current user, RefIDType as the current ID type for voice messages, and updateProcess as the identifier of the process that updates the database from the user's log. creator: GVBasics.RName, get this from current user name -- Sets up a new directory entry for a voice file if none exists, or updates the information about an old entry. -- refIDType: Rope.ROPE_ NIL, find this out from the user handle -- Writes a log entry to create an entry in the InterestList relation for this voice file, associating the RefID with the voiceFileID. refIDType: Rope.ROPE_ NIL, find this out from the user handle -- refIDType: Rope.ROPE_ NIL, find this out from the user handle -- Writes a log entry to decrement the reference count for this voice file. If the database has no record of this message containing voice, that's OK; it will be ignored. (Happens after doing an expunge in Walnut, for example.) refIDType: Rope.ROPE_ NIL, find this out from the user handle -- Writes a log entry to remove the entry in the InterestList relation for this voice file. If updates were called with close=FALSE, update log read points and close transaction. Given the user's ID for a voice message, return its voiceFileID. -- Close argument mirrors those in NuthatchDB: FALSE leaves transaction open. Given the voiceFileID for a voice message, return its tune number. -- Κς˜šœ™Icodešœ Οmœ1™