TCReportImpl.mesa
Copyright Ó 1992 by Xerox Corporation. All rights reserved.
Willie-s, July 21, 1993 10:06 am PDT
TCReportImpl:
CEDAR
PROGRAM
IMPORTS BasicTime, Commander, CommanderOps, IO, MailUtils, MailUtilsBackdoor, Process, SimpleFeedback, SimpleMailer, TiogaIO, TrickleChargeServer
= BEGIN
ROPE: TYPE = Rope.ROPE;
who: MailBasics.RName ¬ [$xns, NIL];
from: ROPE ~ "TrickleCharge Server";
TCReport: TrickleChargeServer
.TCReportProc ~ {
what: ROPE, finishedOK: BOOL
subject: ROPE;
IF who.name =
NIL
THEN {
xx: MailUtils.Credentials ¬ MailUtils.GetUserCredentials[$xns].first;
IF xx = NIL THEN RETURN;
who ¬ xx.rName;
};
subject ¬ IF finishedOK THEN IO.PutFR1["TC Report, %g", [time[BasicTime.Now[]]] ]
ELSE IO.PutFR1["*** => TC Error, %g", [time[BasicTime.Now[]]] ];
Process.Detach[FORK SendMsg[subject, what ] ];
};
SendMsg:
PROC[subject, msg:
ROPE] ~ {
sent: BOOL;
failureReason: ROPE;
body: ROPE ¬ MailUtilsBackdoor.WritePlainCR[TiogaIO.FromRope[msg]];
[sent, failureReason] ¬ SimpleMailer.SendMessage[from: from, to: LIST[who], subject: subject, body: body];
IF sent THEN RETURN;
SimpleFeedback.PutFL[$TCReport, $oneLiner, $info, "Message (subject: %g, body: %g) not sent (reason: %g)\n", LIST[ [rope[subject]], [rope[body]], [rope[failureReason]] ]];
};
TCReportTo: Commander.CommandProc ~ {
user: ROPE ~ CommanderOps.NextArgument[cmd];
IF user # NIL THEN who.name ¬ user; -- don't overwrite
IF who.name # NIL THEN IO.PutF1[cmd.out, "TC Reports will be sent to %g\n", [rope[who.name]] ];
};
TrickleChargeServer.RegisterTCReportProc[TCReport, TRUE];
Commander.Register["TCReportTo", TCReportTo];