From 0b93cd0f82abc38e19bb0ba8323f5da537e4c1dd Mon Sep 17 00:00:00 2001 From: "edwin%woudt.nl" Date: Mon, 19 Apr 1999 01:16:28 +0000 Subject: [PATCH] Inline forwarding now also works a bit. git-svn-id: svn://10.0.0.236/trunk@28024 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/grendel/composition/Composition.java | 11 +- .../grendel/composition/CompositionPanel.java | 104 ++++++++++++++++++ mozilla/grendel/ui/FolderPanel.java | 4 +- mozilla/grendel/ui/MenuLabels.properties | 10 +- mozilla/grendel/ui/Menus.properties | 10 +- mozilla/grendel/ui/Toolbar.properties | 8 +- mozilla/grendel/ui/menus.xml | 11 +- 7 files changed, 140 insertions(+), 18 deletions(-) diff --git a/mozilla/grendel/composition/Composition.java b/mozilla/grendel/composition/Composition.java index 93f443bffb9..470ce585610 100644 --- a/mozilla/grendel/composition/Composition.java +++ b/mozilla/grendel/composition/Composition.java @@ -41,6 +41,7 @@ import grendel.storage.MessageExtraFactory; import grendel.widgets.Animation; import grendel.widgets.CollapsiblePanel; import grendel.widgets.GrendelToolBar; +import grendel.ui.FolderPanel; import grendel.ui.GeneralFrame; import grendel.ui.StoreFactory; @@ -197,7 +198,7 @@ public class Composition extends GeneralFrame { /** Initialize the headers and body of this composition as being a message that is forwarded 'quoted'. */ - public void initializeAsForward(Message msg) { + public void initializeAsForward(Message msg, int aScope) { mCompositionPanel.setReferredMessage(msg); MessageExtra mextra = MessageExtraFactory.Get(msg); @@ -207,7 +208,13 @@ public class Composition extends GeneralFrame { } // Quote the original text - mCompositionPanel.QuoteOriginalMessage(); + if (aScope == FolderPanel.kQuoted) { + mCompositionPanel.QuoteOriginalMessage(); + } + + if (aScope == FolderPanel.kInline) { + mCompositionPanel.InlineOriginalMessage(); + } } diff --git a/mozilla/grendel/composition/CompositionPanel.java b/mozilla/grendel/composition/CompositionPanel.java index 21240094e34..5b214441868 100644 --- a/mozilla/grendel/composition/CompositionPanel.java +++ b/mozilla/grendel/composition/CompositionPanel.java @@ -200,6 +200,15 @@ public class CompositionPanel extends GeneralPanel { qot.actionPerformed(new ActionEvent(this,0,"")); } + /** + * Inline the orgininal message when forwarding + */ + + public void InlineOriginalMessage() { + InlineOriginalText iot = new InlineOriginalText(); + iot.actionPerformed(new ActionEvent(this,0,"")); + } + /** * Add a signature */ @@ -266,6 +275,7 @@ public class CompositionPanel extends GeneralPanel { public static final String sendNowTag ="sendNow"; public static final String sendLaterTag ="sendLater"; public static final String quoteOriginalTextTag ="quoteOriginalText"; + public static final String inlineOriginalTextTag ="inlineOriginalText"; public static final String addSignatureTag ="addSignatureAction"; public static final String selectAddressesTag ="selectAddresses"; public static final String goOfflineTag ="goOffline"; @@ -655,6 +665,100 @@ public class CompositionPanel extends GeneralPanel { } } + /** + * Inline the original text message into the editor. + * @see QuoteOriginalText + */ + class InlineOriginalText extends UIAction { + InlineOriginalText() { + super(inlineOriginalTextTag); + this.setEnabled(true); + } + public void actionPerformed(ActionEvent event) { + if (referredMsg == null) return; // Or beep or whine??? ### + // ### Get the message as a stream of text. This involves + // complicated things like invoking the MIME parser, and throwing + // away non-text parts, and translating HTML to text, and so on. + // Yeah, right. + InputStream plaintext = null; + try { + plaintext = referredMsg.getInputStream(); + } catch (IOException ioe) { + } catch (MessagingException e) { + } + if (plaintext == null) return; // Or beep or whine??? ### + + + int position = mEditor.getCaretPosition(); + Document doc = mEditor.getDocument(); + + MessageExtra mextra = MessageExtraFactory.Get(referredMsg); + String author; + try { + author = mextra.getAuthor(); + } catch (MessagingException e) { + author = "???"; // I18N? ### + } + String subject; + try { + subject = referredMsg.getSubject(); + } catch (MessagingException e) { + subject = "???"; // I18N? ### + } + String tmp = "\n\n-------- Original Message --------\n"; + tmp = tmp + "From: " + author + "\n"; // I18N ### + tmp = tmp + "Subject: " + subject + "\n"; + tmp = tmp + "\n"; + try { + doc.insertString(position, tmp, null); + position += tmp.length(); + } catch (BadLocationException e) { + } + + // OK, now insert the data from the plaintext, and precede each + // line with "> ". + + ByteLineBuffer linebuffer = new ByteLineBuffer(); + ByteBuf empty = new ByteBuf(); + linebuffer.setOutputEOL(empty); + + boolean eof = false; + + ByteBuf buf = new ByteBuf(); + ByteBuf line = new ByteBuf(); + + while (!eof) { + buf.setLength(0); + try { + eof = (buf.read(plaintext, 1024) < 0); + } catch (IOException e) { + eof = true; + } + if (eof) { + linebuffer.pushEOF(); + } else { + linebuffer.pushBytes(buf); + } + while (linebuffer.pullLine(line)) { + try { + //doc.insertString(position, "> ", null); + //position += 2; + doc.insertString(position, line.toString(), null); + position += line.length(); + doc.insertString(position, "\n", null); + position += 1; + } catch (BadLocationException e) { + } + } + } + repaint(); + try { + plaintext.close(); + } catch (IOException e) { + } + } + } + /** * Add a signature */ diff --git a/mozilla/grendel/ui/FolderPanel.java b/mozilla/grendel/ui/FolderPanel.java index 23bd877c002..ec05291ac29 100644 --- a/mozilla/grendel/ui/FolderPanel.java +++ b/mozilla/grendel/ui/FolderPanel.java @@ -922,7 +922,7 @@ public class FolderPanel extends GeneralPanel { super(aName); fScope = aScope; - this.setEnabled(aScope == kQuoted); + this.setEnabled(aScope != kAttachment); } public void actionPerformed(ActionEvent aEvent) { @@ -932,7 +932,7 @@ public class FolderPanel extends GeneralPanel { "Need to have exactly one message selected to reply"); } Composition frame = new Composition(); - frame.initializeAsForward((Message) (selection.elementAt(0))); + frame.initializeAsForward((Message) (selection.elementAt(0)), fScope); frame.show(); frame.requestFocus(); } diff --git a/mozilla/grendel/ui/MenuLabels.properties b/mozilla/grendel/ui/MenuLabels.properties index 9029da13b02..85d45070d21 100644 --- a/mozilla/grendel/ui/MenuLabels.properties +++ b/mozilla/grendel/ui/MenuLabels.properties @@ -142,10 +142,12 @@ msgReplyLabel=Reply msgReplyAccel=R msgReplyAllLabel=Reply All msgReplyAllAccel=A -msgForwardLabel=Forward -msgForwardAccel=F -msgForwardQuotedLabel=Forward Quoted -msgForwardQuotedAccel=Q +fwdQuotedLabel=Forward Quoted +fwdQuotedAccel=Q +fwdInlineLabel=Forward Inline +fwdInlineAccel=I +fwdAttachmentLabel=Forward Attachment +fwdAttachmentAccel=A msgMoveLabel=File to msgMoveAccel=F msgMovePopupLabel=File to diff --git a/mozilla/grendel/ui/Menus.properties b/mozilla/grendel/ui/Menus.properties index ab99f643ec6..6e2099f7cee 100644 --- a/mozilla/grendel/ui/Menus.properties +++ b/mozilla/grendel/ui/Menus.properties @@ -24,7 +24,7 @@ multiMain=multiFile multiEdit multiView multiMessage multiFile=msgNew folderNew msgOpen msgSaveAs - msgGetNew - appExit multiEdit=editUndo - editCut editCopy editPaste - folderDelete - appSearch - appPrefs - appRunFilters multiView=viewLayout viewSort -multiMessage=msgNew - msgReply msgReplyAll msgForward fwdQuoted - msgMark +multiMessage=msgNew - msgReply msgReplyAll - fwdInline fwdQuoted fwdAttachment - msgMark multiToolBar=msgGetNew msgNew msgReply fwdQuoted print msgDelete stop #multiToolBar=msgGetNew msgNew msgReply msgDelete @@ -38,7 +38,7 @@ viewLayout=splitTop splitLeft splitRight stacked messageMain=messageFile messageEdit messageMessage window messageFile=msgSaveAs - appExit messageEdit=editUndo - editCut editCopy editPaste editClear - appPrefs -messageMessage=msgNew - msgReply msgReplyAll msgForward fwdQuoted +messageMessage=msgNew - msgReply msgReplyAll - fwdInline fwdQuoted fwdAttachment messageToolBar=msgGetNew msgNew msgReply msgReplyAll fwdQuoted print msgDelete stop @@ -51,7 +51,7 @@ messageToolBar=msgGetNew msgNew msgReply msgReplyAll fwdQuoted print msgDelete s folderMain=folderFile folderEdit folderMessage window folderFile=msgNew msgOpen msgSaveAs - msgGetNew - appExit folderEdit=editUndo - editCut editCopy editPaste editClear - appPrefs -folderMessage=msgNew - msgReply msgReplyAll fwdQuoted msgForwardQuoted +folderMessage=msgNew - msgReply msgReplyAll - fwdInline fwdQuoted fwdAttachment folderToolBar=msgGetNew msgNew msgReply msgReplyAll fwdQuoted markAllRead print msgDelete stop #folderToolBar=msgGetNew msgNew msgDelete msgReply @@ -71,7 +71,7 @@ masterToolBar=msgGetNew msgNew stop # Integrator Frame menus # -integratorMessage=msgGetNew - msgNew msgReply msgForward - msgDelete +integratorMessage=msgGetNew - msgNew msgReply - fwdInline fwdQuoted fwdAttachment - msgDelete # # Common menus @@ -101,7 +101,7 @@ msgNewKeyboard=CTRL+m msgGetNewKeyboard=CTRL+t msgSaveAsKeyboard=CTRL+s msgReplyKeyboard=CTRL+r -msgForwardKeyboard=CTRL+l +#msgForwardKeyboard=CTRL+l msgOpenKeyboard=CTRL+o # diff --git a/mozilla/grendel/ui/Toolbar.properties b/mozilla/grendel/ui/Toolbar.properties index c58b3ad3e42..546aaa8ea40 100644 --- a/mozilla/grendel/ui/Toolbar.properties +++ b/mozilla/grendel/ui/Toolbar.properties @@ -20,7 +20,9 @@ msgGetNewLabel=Get Msg msgNewLabel=New Msg msgReplyLabel=Reply msgReplyAllLabel=Reply All -fwdQuotedLabel=Forward +fwdQuotedLabel=Fwd Q +fwdInlineLabel=Fwd I +fwdAttachmentLabel=Fwd A markAllReadLabel=Mark Rd printLabel=Print msgDeleteLabel=Delete @@ -31,6 +33,8 @@ msgNewIcon=newmsg msgReplyIcon=reply msgReplyAllIcon=replyall fwdQuotedIcon=forward +fwdInlineIcon=forward +fwdAttachmentIcon=forward markAllReadIcon=markallread printIcon=print msgDeleteIcon=delete @@ -41,6 +45,8 @@ msgNewTooltip=Compose a new message msgReplyTooltip=Reply msgReplyAllTooltip=Reply to all recipients fwdQuotedTooltip=Forward +fwdInlineTooltip=Forward +fwdQuotedTooltip=Forward markAllReadTooltip=Mark all messages read printTooltip=Print this message msgDeleteTooltip=Delete this message diff --git a/mozilla/grendel/ui/menus.xml b/mozilla/grendel/ui/menus.xml index 4079f6c8962..d2e57b05808 100644 --- a/mozilla/grendel/ui/menus.xml +++ b/mozilla/grendel/ui/menus.xml @@ -121,11 +121,14 @@ - - +