[Oberon] Q: Why bother with Mail.Show?

peter at easthope.ca peter at easthope.ca
Sat Sep 14 17:32:01 CEST 2019


A:
In S3 and in A2 Oberon (A2O) the Mail.Panel works well. Nevertheless 
Mail.Show can display a message without the Mail.Panel.  Somewhat 
similar to Mutt or Alpine in Linux, although Mail.Show is better of 
course!  =8~)

A constraint with Mail.Show is that the message number n must be known 
to allow activation of Mail.Show n .  Also, the user might want to 
search through senders or recipients or subjects without searching 
through a multi-MiB MsgFile (MailMessages).

With S3 Mail.Mod and A2O Oberon.Mail.Mod, Mail.Show ~ does nothing.  
So my thought is to have Mail.Show ~ list messages.  Ie. make a roster 
with message number, sender, recipient, subject per line.  At least, I 
don't see any harm. (?)

Also it's a chance to understand Gadgets just a little. 

The distributed source is at 
https://svn-dept.inf.ethz.ch/svn/lecturers/a2/trunk/source/
Userid is infsvn.anonymous, password is anonymous .

The proposed revision follows.  Apologies for the bulky message and  
any comment or criticism is welcome.  

Thanks!                           ... Lyall E.

	(* Show the message by activating in the Mail.Panel.
		Otherwise show the message identified by number.  Show 13 ~  
		Otherwise, with no message identified, show a list of messages.  Mail.Show ~ *)
	PROCEDURE Show*;
		VAR
			S: Attributes.Scanner;
			T: Texts.Text;
			D: Documents.Document;
			obj: Objects.Object;
			F: Texts.Finder;
			no: LONGINT;
			plain: BOOLEAN;
			line: ListGadgets.Line;
			strm: Streams.Stream;
			h: MIME.Header;
			cont: MIME.Content;
			len, pos: LONGINT;
			str: ARRAY BufLen OF CHAR;
	BEGIN
		IF Desktops.IsInMenu(Gadgets.context) THEN
			D := Desktops.CurDoc(Gadgets.context);
			Links.GetLink(D.dsc, "Model", obj);
			IF (obj # NIL) & (obj IS Texts.Text) THEN
				Texts.OpenFinder(F, obj(Texts.Text), 0);
				Texts.FindObj(F, obj);
				IF (obj # NIL) & (obj IS TextGadgets.Style) THEN
					Attributes.SetString(Gadgets.executorObj, "Caption", "Text");
					Attributes.GetInt(obj, "Message", no); plain := TRUE
				ELSE
					Attributes.SetString(Gadgets.executorObj, "Caption", "Source");
					Attributes.GetInt(Gadgets.executorObj, "Message", no); plain := FALSE
				END;
				IF (no >= 0) & (no < noMsgs) THEN
					decodeMessage(no, T, plain);
					Attributes.SetInt(Gadgets.executorObj, "Message", no);
					Links.SetLink(D.dsc, "Model", T)
				END;
				Gadgets.Update(Gadgets.executorObj)
			END
		ELSE
			Attributes.OpenScanner(S, Oberon.Par.text, Oberon.Par.pos);
			Attributes.Scan(S);
			IF S.class = Attributes.Int THEN
				IF (S.i >= 0) & (S.i < noMsgs) THEN (* Message identified. *)
					obj := FindObj("MailList");
					IF obj # NIL THEN
						WITH obj: ListGadgets.Frame DO
							line := obj.lines;
							REPEAT
								line.sel := msgs[S.i].pos = line.key;
								line := line.next
							UNTIL line = obj.lines;
							obj.sel := TRUE; obj.time := Oberon.Time();
							Gadgets.Update(obj)
						END
					END;
					decodeMessage(S.i, T, FALSE);
					ShowText("Mail.Text", T, TRUE)
				END
			ELSE (* No message identified. *)
				IF 0 < noMsgs THEN
					Texts.WriteString(W, "Msg no.  From  To  Subject"); Texts.WriteLn(W);
					no := 0;
					WHILE no < noMsgs DO
						Texts.WriteInt(W, no, 0); Texts.Write(W, " ");
						strm := Streams.OpenFileReader(msgsF, msgs[no].pos); strm.mode := Streams.binary;
						MIME.ReadHeader(strm, NIL, h, len);
						ParseContent(h, cont);
						pos := MIME.FindField(h, "From");
						MIME.ExtractEMail(h, pos, str);
						Texts.WriteString(W, str); Texts.WriteString(W, "    ");
						pos := MIME.FindField(h, "To");
						MIME.ExtractEMail(h, pos, str);
						Texts.WriteString(W, str); Texts.WriteString(W, "    ");
						pos := MIME.FindField(h, "Subject");
						MIME.ExtractValue(h, pos, str);
						Texts.WriteString(W, str); Texts.WriteLn(W);
						INC(no)
					END;
					NEW(T); Texts.Open(T, ""); Texts.Append(T, W.buf);
					ShowText("Messages", T, TRUE)
				END
			END
		END
	END Show;


-- 
https://en.wikibooks.org/wiki/Medical_Machines
https://en.wikibooks.org/wiki/Oberon
Tel: +1 604 670 0140            Bcc: peter at easthope. ca



More information about the Oberon mailing list