DIRECTORY Commander USING [CommandProc, Register], CommanderOps USING [Failed, ParseToList], IO, MailBasics USING [RNameList], MailSend USING [SendingCredentials, SendingCredentialsList, SendingCredentialsRec], MailUtils USING [Credentials, GetLoggedInUser, GetUserCredentials, LocalNameFromRName], Menus USING [CreateMenu, Menu], PFS USING [AbsoluteName], PFSCanonicalNames USING [ParseName, UnparseName], RefText, Rope, SendMailInternal, SendMailOps, UserProfile USING [Boolean], ViewerClasses USING [Viewer], ViewerOps USING [DestroyViewer], ViewerTools USING [TiogaContents, TiogaContentsRec]; SendMailMoreControlImpl: CEDAR MONITOR IMPORTS Commander, CommanderOps, IO, PFS, PFSCanonicalNames, MailUtils, Menus, RefText, Rope, SendMailInternal, SendMailOps, UserProfile, ViewerOps EXPORTS SendMailInternal, SendMailOps = BEGIN OPEN SendMailOps, SendMailInternal; -- Global types & variables ROPE: TYPE = Rope.ROPE; replyToSelf: PUBLIC BOOL ฌ FALSE; alwaysNewSender: PUBLIC BOOL ฌ FALSE; needToAuthenticate: PUBLIC BOOL ฌ TRUE; outBoxLength: PUBLIC INT ฌ 1; outBox: PUBLIC SendMailOps.OutBoxMsg; sendCaption: PUBLIC ROPE ฌ "Mail Sender"; sendMenu: PUBLIC Menus.Menu ฌ Menus.CreateMenu[]; formsMenu: PUBLIC Menus.Menu; sendingMenu: PUBLIC Menus.Menu ฌ Menus.CreateMenu[]; blankMenu: PUBLIC Menus.Menu ฌ Menus.CreateMenu[]; confirmMenu: PUBLIC Menus.Menu ฌ Menus.CreateMenu[]; replyToMenu: PUBLIC Menus.Menu ฌ Menus.CreateMenu[]; userRNameList: PUBLIC MailBasics.RNameList ฌ NIL; -- full user names simpleUserNameList: PUBLIC LIST OF ROPE ฌ NIL; -- local user names localRNameList: PUBLIC LIST OF ROPE ฌ NIL; simpleNameListWithoutSpaces: PUBLIC LIST OF ROPE ฌ NIL; -- local user names w/o spaces sendingCredentialsList: PUBLIC MailSend.SendingCredentialsList ฌ NIL; standardDefaultText: PUBLIC ViewerTools.TiogaContents ฌ NEW[ ViewerTools.TiogaContentsRec ฌ [contents: "\rSubject: \001Topic\002\rTo: \001Recipients\002\rCc: \001Copies To\002\r\r\001Message\002\r", formatting: "\000\000\000\006\000\000\235\312\000<\000\000\002\230\000J\232\002\320bs\007\234\t\230\020J\232\002\235\002\234\016\230\020J\232\002\235\002\234\r\230\017J\230\000J\230\t\227\000\205\227\000\000\000\000\000>\000\000\000\200\000\000"] ]; standardAnswerText: PUBLIC ViewerTools.TiogaContents ฌ NEW[ ViewerTools.TiogaContentsRec ฌ [contents: "\rSubject: \001Topic\002\rIn-reply-to: \001Message\002\rTo: \001Recipients\002\rCc: \001Copies To\002\r\r\001Message\002\r\000", formatting: "\000\000\000\006\000\000\235\312\000I\000\000\002\230\000J\232\002\320bs\007\234\t\230\020J\232\002\235\013\234\013\230\026J\232\002\235\002\234\016\230\020J\232\002\235\002\234\r\230\017J\230\000J\232\001\234\t\230\t\227\000\205\227\000\000\000\000\000V\000\000\000\245\000\000"] ]; standardForwardText: PUBLIC ViewerTools.TiogaContents ฌ NEW[ ViewerTools.TiogaContentsRec ฌ [contents: "\rSubject: \001Topic\002\rTo: \001Recipients\002\rCc: \001Copies To\002\r\r\001CoveringMessage\002\r\r--------------------------------------\rForwardedMessage\r--------------------------------------\r\r\001ClosingComment\002\r", formatting: "\000\000\000\006\000\000\235\312\000W\000\000\002\230\000J\232\002\320bs\007\234\t\230\020J\232\002\235\002\234\016\230\020J\232\002\235\002\234\r\230\017J\230\000J\230\021J\230\000\002\232\001\234&\230&J\230\020\227J\232\001\234&\230&J\230\000J\230\020\227\000\205\227\000\000\000\000\000\270\000\000\001\025\000\000"] ]; defaultForm: PUBLIC SendMailOps.Form ฌ NEW[ SendMailOps.FormRec ฌ [ formText: SendMailOps.defaultText, fields: LIST[ NIL, NIL, NIL] ] ]; SendMailFileUsage: ROPE = "\nUsage: SendMailFile "; -- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * DoUserNameAndRegistry: PUBLIC ENTRY PROC = { useGV: BOOL ฌ UserProfile.Boolean["SendMailTool.gvSendMail", TRUE]; useXNS: BOOL ฌ UserProfile.Boolean["SendMailTool.xnsSendMail", TRUE]; creds: LIST OF MailUtils.Credentials; userRNameList ฌ NIL; simpleUserNameList ฌ NIL; localRNameList ฌ NIL; simpleNameListWithoutSpaces ฌ NIL; sendingCredentialsList ฌ NIL; SELECT TRUE FROM ( useGV AND useXNS ) => creds ฌ MailUtils.GetUserCredentials[]; useGV => creds ฌ MailUtils.GetUserCredentials[$gv]; ENDCASE => creds ฌ MailUtils.GetUserCredentials[$xns]; FOR cL: LIST OF MailUtils.Credentials ฌ creds, cL.rest UNTIL cL = NIL DO sCred: MailSend.SendingCredentials; this: ROPE; userRNameList ฌ CONS[cL.first.rName, userRNameList]; simpleUserNameList ฌ CONS[this ฌ MailUtils.GetLoggedInUser[cL.first.rName.ns], simpleUserNameList]; localRNameList ฌ CONS[this ฌ MailUtils.LocalNameFromRName[[cL.first.rName.ns, this]], localRNameList]; simpleNameListWithoutSpaces ฌ CONS[RemoveSpaces[this], simpleNameListWithoutSpaces]; sCred ฌ NEW[MailSend.SendingCredentialsRec ฌ [cL.first, TRUE, cL.first.rName] ]; sendingCredentialsList ฌ CONS[sCred, sendingCredentialsList]; ENDLOOP; IF localRNameList # NIL THEN defaultForm ฌ NEW[ SendMailOps.FormRec ฌ [ formText: defaultText, fields: LIST[ NIL, NIL, localRNameList.first] ] ] ELSE defaultForm ฌ NEW[ SendMailOps.FormRec ฌ [ formText: defaultText, fields: LIST[ NIL, NIL, NIL] ] ]; }; RemoveSpaces: PROC[this: ROPE] RETURNS[better: ROPE] = { new: REF TEXT; len: NAT; IF this.Find[" "] < 0 THEN RETURN[this]; new ฌ RefText.ObtainScratch[len ฌ this.Length[]]; FOR i: INT IN [0..this.Length[]) DO ch: CHAR; IF ( ch ฌ this.Fetch[i] ) # ' THEN new ฌ RefText.AppendChar[new, ch]; ENDLOOP; better ฌ Rope.FromRefText[new]; RefText.ReleaseScratch[new]; }; ChangeUserRNameList: PUBLIC ENTRY PROC[newUserRNameList: MailBasics.RNameList] = { this: ROPE; userRNameList ฌ newUserRNameList; simpleUserNameList ฌ localRNameList ฌ NIL; FOR rL: MailBasics.RNameList ฌ newUserRNameList, rL.rest UNTIL rL = NIL DO simpleUserNameList ฌ CONS[this ฌ MailUtils.GetLoggedInUser[rL.first.ns], simpleUserNameList]; localRNameList ฌ CONS[this ฌ MailUtils.LocalNameFromRName[[rL.first.ns, this]], localRNameList]; ENDLOOP; defaultForm ฌ NEW[ SendMailOps.FormRec ฌ [ formText: defaultText, fields: LIST[ NIL, NIL, IF localRNameList # NIL THEN localRNameList.first ELSE NIL] ] ]; }; IsThisTheCurrentUser: PUBLIC ENTRY PROC[who: ROPE] RETURNS[yes: BOOL ฌ TRUE] = { FOR rL: MailBasics.RNameList ฌ userRNameList, rL.rest UNTIL rL = NIL DO IF who.Equal[rL.first.name, FALSE] THEN RETURN; ENDLOOP; FOR rL: LIST OF ROPE ฌ simpleUserNameList, rL.rest UNTIL rL = NIL DO IF who.Equal[rL.first, FALSE] THEN RETURN; ENDLOOP; FOR rL: LIST OF ROPE ฌ localRNameList, rL.rest UNTIL rL = NIL DO IF who.Equal[rL.first, FALSE] THEN RETURN; ENDLOOP; RETURN[FALSE]; }; SendMailFileProc: Commander.CommandProc = { inputList: LIST OF ROPE; inputList ฌ CommanderOps.ParseToList[cmd: cmd ! CommanderOps.Failed => {cmd.err.PutRope["invalid input format\n"]; GO TO quit}].list; IF inputList = NIL THEN RETURN[NIL, SendMailFileUsage]; FOR files: LIST OF ROPE ฌ inputList, files.rest WHILE files # NIL DO absFileName: ROPE ฌ PFSCanonicalNames.UnparseName[PFS.AbsoluteName[PFSCanonicalNames.ParseName[files.first]]]; IF NOT SendOneMailFile[absFileName] THEN BEGIN cmd.err.PutF1["Failed to send %g\n", [rope[absFileName]]]; GO TO quit; END; ENDLOOP; EXITS quit => RETURN[$Failure, NIL]; }; SendOneMailFile: PROC [file: ROPE] RETURNS [sent: BOOLEAN] = { msgViewer: ViewerClasses.Viewer; text: ViewerTools.TiogaContents ฌ SendMailInternal.GetSendForm[file]; form: SendMailOps.Form ฌ NEW[SendMailOps.FormRec ฌ [text]]; [msgViewer] ฌ SendMailOps.BuildSendViewer[TRUE, FALSE, form]; sent ฌ SendMailOps.Send[msgViewer]; IF sent THEN ViewerOps.DestroyViewer[msgViewer]; }; -- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Commander.Register[key: "SendMailFile", proc: SendMailFileProc, doc: SendMailFileUsage]; END. fSendMailMoreControlImpl.mesa Copyright ำ 1990, 1992 by Xerox Corporation. All rights reserved. Willie-s, December 12, 1991 12:34 pm PST Contents: Control module for SendMail Last Edited by: Willie-Sue, January 17, 1984 10:20:02 am PST Last Edited by: Donahue, October 7, 1983 9:42 am PROC [cmd: Handle] RETURNS [result: REF _ NIL, msg: ROPE _ NIL]; ส–(cedarcode) style•NewlineDelimiter ˜codešฯb™Kšœ ฯeœ7™BK™(K™Kšœ%™%—K˜Kšœ<™Kšœ ˜ K˜EKšœŸœ˜;Kšœ*ŸœŸœ˜=K˜#KšŸœŸœ$˜0Kšœ˜K˜——KšกH˜H˜KšœX˜X—˜KšŸœ˜——…—,'ฎ