<> <> <> DIRECTORY GVBasics USING[ ItemHeader, RName, Timestamp ], IO USING[ STREAM ], Rope USING[ ROPE ]; GVRetrieve: CEDAR DEFINITIONS = BEGIN OPEN IO, Rope; <> Handle: TYPE = REF HandleObject; <> HandleObject: TYPE; Create: PROC[pollingInterval: CARDINAL, reportChanges: PROCEDURE[MBXState] _ NIL] RETURNS[Handle]; <> Close: PROC[Handle]; <> <> NewUser: PROC[ handle: Handle, user: GVBasics.RName, password: ROPE]; <> MBXState: TYPE = { unknown, badName, badPwd, cantAuth, userOK, allDown, someEmpty, allEmpty, notEmpty }; <> MailboxState: PROC[ handle: Handle] RETURNS[ state: MBXState]; <> WaitForMail: PROC[ handle: Handle ]; <> <> <> <> <> <> <> <> <<"ReadTOC" may be used to read any TOC entry for the message (giving length=0 if there is no TOC entry), then "StartMessage" may be called to read the guaranteed properties of the message; these are not available for MTP servers; these may not be called after you have called "NextItem" for this message.>> <<"NextItem" may be called to access in sequence the items which are the contents of the message body. Note that the ItemHeader contains the item type and length in bytes. The first item will be the guaranteed recipient list. The message body is followed by an item of type "LastItem". Within an item, use an IO.STREAM may be used to access the data of the item. EndOf[] will be true at the end of the item. Calling NextItem closes any IO.STREAM on a current item (even if the entrie item has not been read yet) and moves on to the next item.>> <> <> <> ServerType: TYPE = { MTP, GV }; ServerState: TYPE = { unknown, empty, notEmpty }; <<"unknown" means the server didn't reply to mail check packets; in this case, for efficiency, you should NOT call "NextMessage". There is no point in calling NextMessage if the ServerState is "empty".>> NextServer: PROC[ handle: Handle ] RETURNS[ noMore: BOOLEAN, state: ServerState, type: ServerType ]; <> ServerName: PROC[ handle: Handle] RETURNS [serverName: GVBasics.RName]; <> FailureReason: TYPE = { communicationFailure, -- server or network down -- noSuchServer, -- server name incorrect -- connectionRejected, -- server full, mbx busy, etc -- badCredentials, -- name/pwd rejected -- unknownFailure -- protocol violation or unknown MTP error: likely to be permanent -- }; Failed: ERROR[why: FailureReason, text: ROPE]; <> NextMessage: PROC[handle: Handle] RETURNS[msgExists, archived, deleted: BOOLEAN]; StartMessage: PROC[handle: Handle ] RETURNS[postmark: GVBasics.Timestamp, sender: GVBasics.RName, returnTo: GVBasics.RName]; NextItem: PROC[handle: Handle] RETURNS[GVBasics.ItemHeader]; <> GetItem: PROC[handle: Handle] RETURNS[STREAM]; <> Accept: PROC[handle: Handle]; <> <<"ReadTOC", "WriteTOC" and "DeleteMessage" are useful mainly for Lily.>> ReadTOC: PROC[handle: Handle] RETURNS[ ROPE ]; WriteTOC: PROC[handle: Handle, entry:ROPE ]; DeleteMessage: PROC[handle: Handle] ; END.