зеркало из https://github.com/mozilla/pjs.git
Mail sending now works. I also added the multiple peronalities feature.
This commit is contained in:
Родитель
ddac93ba4b
Коммит
c9d32e883c
|
@ -24,6 +24,8 @@ package grendel.composition;
|
||||||
|
|
||||||
import calypso.util.ByteBuf;
|
import calypso.util.ByteBuf;
|
||||||
import calypso.util.ByteLineBuffer;
|
import calypso.util.ByteLineBuffer;
|
||||||
|
import calypso.util.Preferences;
|
||||||
|
import calypso.util.PreferencesFactory;
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.Container;
|
import java.awt.Container;
|
||||||
|
@ -331,7 +333,7 @@ public class CompositionPanel extends GeneralPanel {
|
||||||
class SaveDraft extends UIAction {
|
class SaveDraft extends UIAction {
|
||||||
SaveDraft() {
|
SaveDraft() {
|
||||||
super(saveDraftTag);
|
super(saveDraftTag);
|
||||||
setEnabled(true);
|
this.setEnabled(true);
|
||||||
}
|
}
|
||||||
public void actionPerformed(ActionEvent e) {}
|
public void actionPerformed(ActionEvent e) {}
|
||||||
}
|
}
|
||||||
|
@ -343,7 +345,7 @@ public class CompositionPanel extends GeneralPanel {
|
||||||
class SaveAs extends UIAction {
|
class SaveAs extends UIAction {
|
||||||
SaveAs() {
|
SaveAs() {
|
||||||
super(saveAsTag);
|
super(saveAsTag);
|
||||||
setEnabled(true);
|
this.setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
@ -381,7 +383,7 @@ public class CompositionPanel extends GeneralPanel {
|
||||||
class SendNow extends UIAction {
|
class SendNow extends UIAction {
|
||||||
SendNow() {
|
SendNow() {
|
||||||
super(sendNowTag);
|
super(sendNowTag);
|
||||||
setEnabled(true);
|
this.setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void actionPerformed(ActionEvent ae) {
|
public void actionPerformed(ActionEvent ae) {
|
||||||
|
@ -401,10 +403,11 @@ public class CompositionPanel extends GeneralPanel {
|
||||||
|
|
||||||
//Check that is at least one recipient.
|
//Check that is at least one recipient.
|
||||||
if (0 < recipients.length) {
|
if (0 < recipients.length) {
|
||||||
//get the users name who's sending this message.
|
//get the sending identity
|
||||||
Properties props = mSession.getProperties();
|
Preferences prefs = PreferencesFactory.Get();
|
||||||
String userName =
|
int ident = mAddressBar.getOptionsPanel().getSelectedIdentity();
|
||||||
props.getProperty("user.email_address");
|
String userName = prefs.getString("mail.identity-" + ident + ".username", "Nobody") + " <"
|
||||||
|
+ prefs.getString("mail.identity-" + ident + ".email", "nobody@localhost") + ">";
|
||||||
|
|
||||||
if (userName != null) {
|
if (userName != null) {
|
||||||
//create a mime message
|
//create a mime message
|
||||||
|
@ -442,7 +445,7 @@ public class CompositionPanel extends GeneralPanel {
|
||||||
msg.setSentDate(new java.util.Date()); //set date to now.
|
msg.setSentDate(new java.util.Date()); //set date to now.
|
||||||
msg.setContent(messageText, "text/plain"); //contents.
|
msg.setContent(messageText, "text/plain"); //contents.
|
||||||
try {
|
try {
|
||||||
mSession.getTransport().send(msg); // send the message.
|
mSession.getTransport("smtp").send(msg); // send the message.
|
||||||
} catch (MessagingException exc) {
|
} catch (MessagingException exc) {
|
||||||
exc.printStackTrace();
|
exc.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -481,7 +484,7 @@ public class CompositionPanel extends GeneralPanel {
|
||||||
class QuoteOriginalText extends UIAction {
|
class QuoteOriginalText extends UIAction {
|
||||||
QuoteOriginalText() {
|
QuoteOriginalText() {
|
||||||
super(quoteOriginalTextTag);
|
super(quoteOriginalTextTag);
|
||||||
setEnabled(true);
|
this.setEnabled(true);
|
||||||
}
|
}
|
||||||
public void actionPerformed(ActionEvent event) {
|
public void actionPerformed(ActionEvent event) {
|
||||||
if (referredMsg == null) return; // Or beep or whine??? ###
|
if (referredMsg == null) return; // Or beep or whine??? ###
|
||||||
|
@ -560,7 +563,7 @@ public class CompositionPanel extends GeneralPanel {
|
||||||
class SelectAddresses extends UIAction {
|
class SelectAddresses extends UIAction {
|
||||||
SelectAddresses() {
|
SelectAddresses() {
|
||||||
super(selectAddressesTag);
|
super(selectAddressesTag);
|
||||||
setEnabled(true);
|
this.setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
@ -596,7 +599,7 @@ public class CompositionPanel extends GeneralPanel {
|
||||||
class AttachFile extends UIAction {
|
class AttachFile extends UIAction {
|
||||||
AttachFile() {
|
AttachFile() {
|
||||||
super(fileTag);
|
super(fileTag);
|
||||||
setEnabled(true);
|
this.setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
//display the AttachmentsList and have the file dialog "popup" on them.
|
//display the AttachmentsList and have the file dialog "popup" on them.
|
||||||
|
@ -617,7 +620,7 @@ public class CompositionPanel extends GeneralPanel {
|
||||||
class PasteAsQuotation extends UIAction {
|
class PasteAsQuotation extends UIAction {
|
||||||
PasteAsQuotation() {
|
PasteAsQuotation() {
|
||||||
super(pasteAsQuotationTag);
|
super(pasteAsQuotationTag);
|
||||||
setEnabled(true);
|
this.setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
@ -672,7 +675,7 @@ public class CompositionPanel extends GeneralPanel {
|
||||||
class ViewAddress extends UIAction {
|
class ViewAddress extends UIAction {
|
||||||
ViewAddress() {
|
ViewAddress() {
|
||||||
super(viewAddressTag);
|
super(viewAddressTag);
|
||||||
setEnabled(true);
|
this.setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
@ -683,7 +686,7 @@ public class CompositionPanel extends GeneralPanel {
|
||||||
class ViewAttachments extends UIAction {
|
class ViewAttachments extends UIAction {
|
||||||
ViewAttachments() {
|
ViewAttachments() {
|
||||||
super(viewAttachmentsTag);
|
super(viewAttachmentsTag);
|
||||||
setEnabled(true);
|
this.setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
@ -694,7 +697,7 @@ public class CompositionPanel extends GeneralPanel {
|
||||||
class ViewOptions extends UIAction {
|
class ViewOptions extends UIAction {
|
||||||
ViewOptions() {
|
ViewOptions() {
|
||||||
super(viewOptionsTag);
|
super(viewOptionsTag);
|
||||||
setEnabled(true);
|
this.setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
|
|
@ -26,21 +26,34 @@ import java.awt.*;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.border.*;
|
import javax.swing.border.*;
|
||||||
|
|
||||||
|
import calypso.util.Preferences;
|
||||||
|
import calypso.util.PreferencesFactory;
|
||||||
|
|
||||||
public class OptionsPanel extends JPanel implements Serializable {
|
public class OptionsPanel extends JPanel implements Serializable {
|
||||||
// private final int BOX_WIDTH = 300;
|
// private final int BOX_WIDTH = 300;
|
||||||
private final int BOX_WIDTH = 160;
|
private final int BOX_WIDTH = 160;
|
||||||
private final int BOX_HEIGHT = 30;
|
private final int BOX_HEIGHT = 30;
|
||||||
|
|
||||||
|
private GridBagConstraints c;
|
||||||
|
private GridBagLayout gridbag;
|
||||||
|
|
||||||
|
private LabeledCombo ident;
|
||||||
|
|
||||||
public OptionsPanel () {
|
public OptionsPanel () {
|
||||||
super ();
|
super ();
|
||||||
|
|
||||||
|
c = new GridBagConstraints();
|
||||||
|
gridbag = new GridBagLayout();
|
||||||
|
|
||||||
|
setLayout(gridbag);
|
||||||
|
|
||||||
setLayout(new GridLayout(3, 2, 5, 5));
|
c.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
c.weightx = 1.0;
|
||||||
addCheck ("Encrypted", "Encrypted", 'e', false);
|
c.gridheight = 1;
|
||||||
|
|
||||||
addCheck ("Return Receipt", "Return Receipt", 'r', false);
|
addCheck ("Return Receipt", "Return Receipt", 'r', false);
|
||||||
|
|
||||||
addCheck ("Signed", "Signed", 'd', false);
|
c.gridwidth = GridBagConstraints.REMAINDER; //end row
|
||||||
|
|
||||||
LabeledCombo priority = new LabeledCombo("Priority");
|
LabeledCombo priority = new LabeledCombo("Priority");
|
||||||
priority.addPossibleValue("Lowest");
|
priority.addPossibleValue("Lowest");
|
||||||
|
@ -48,16 +61,53 @@ public class OptionsPanel extends JPanel implements Serializable {
|
||||||
priority.addPossibleValue("Normal");
|
priority.addPossibleValue("Normal");
|
||||||
priority.addPossibleValue("High");
|
priority.addPossibleValue("High");
|
||||||
priority.addPossibleValue("Highest");
|
priority.addPossibleValue("Highest");
|
||||||
add(new FixedSizedPanel (BOX_WIDTH, BOX_HEIGHT, priority));
|
addToGridBag(new FixedSizedPanel (BOX_WIDTH, BOX_HEIGHT, priority), gridbag, c);
|
||||||
|
|
||||||
addCheck ("Uuencoded instead of MIME for attachments", "", 'u', false);
|
c.gridwidth = 1;
|
||||||
|
|
||||||
|
addCheck ("Uuencoded instead of MIME for attachments", "UUEncode", 'u', false);
|
||||||
|
|
||||||
|
c.gridwidth = GridBagConstraints.REMAINDER; //end row
|
||||||
|
|
||||||
LabeledCombo format = new LabeledCombo("Format");
|
LabeledCombo format = new LabeledCombo("Format");
|
||||||
format.addPossibleValue("Ask me");
|
format.addPossibleValue("Ask me");
|
||||||
format.addPossibleValue("Plain Text only");
|
format.addPossibleValue("Plain Text only");
|
||||||
format.addPossibleValue("HTML Text only");
|
format.addPossibleValue("HTML Text only");
|
||||||
format.addPossibleValue("Plain Text and HTML");
|
format.addPossibleValue("Plain Text and HTML");
|
||||||
add(new FixedSizedPanel (BOX_WIDTH, BOX_HEIGHT, format));
|
addToGridBag(new FixedSizedPanel (BOX_WIDTH, BOX_HEIGHT, format), gridbag, c);
|
||||||
|
|
||||||
|
c.gridwidth = 1;
|
||||||
|
|
||||||
|
addCheck ("Encrypted", "Encrypted", 'e', false);
|
||||||
|
|
||||||
|
c.gridwidth = GridBagConstraints.REMAINDER; //end row
|
||||||
|
|
||||||
|
ident = new LabeledCombo("Identity");
|
||||||
|
|
||||||
|
// Read all the different identities from the preferences file
|
||||||
|
Preferences prefs = PreferencesFactory.Get();
|
||||||
|
int numIdentities = prefs.getInt("mail.identities", 1);
|
||||||
|
for (int i=0; i<numIdentities; i++) {
|
||||||
|
ident.addPossibleValue(prefs.getString("mail.identity-" + i + ".description", "(nobody)"));
|
||||||
|
}
|
||||||
|
// Select the first (default) identity (number 0)
|
||||||
|
ident.setSelectedIndex(0);
|
||||||
|
|
||||||
|
addToGridBag(new FixedSizedPanel (BOX_WIDTH, BOX_HEIGHT, ident), gridbag, c);
|
||||||
|
|
||||||
|
c.gridwidth = GridBagConstraints.REMAINDER; //end row
|
||||||
|
|
||||||
|
addCheck ("Signed", "Signed", 'd', false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSelectedIdentity() {
|
||||||
|
return ident.getSelectedIndex();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addToGridBag (Component aComponent, GridBagLayout gridbag, GridBagConstraints c) {
|
||||||
|
gridbag.setConstraints(aComponent, c);
|
||||||
|
add(aComponent);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addCheck (String aLabel, String aToolTip) {
|
private void addCheck (String aLabel, String aToolTip) {
|
||||||
|
@ -75,7 +125,7 @@ public class OptionsPanel extends JPanel implements Serializable {
|
||||||
if (' ' != aAccelerator) checkButton.setMnemonic(aAccelerator);
|
if (' ' != aAccelerator) checkButton.setMnemonic(aAccelerator);
|
||||||
|
|
||||||
//create a fixed sized panel.
|
//create a fixed sized panel.
|
||||||
add(new FixedSizedPanel (BOX_WIDTH, BOX_HEIGHT, checkButton));
|
addToGridBag(new FixedSizedPanel (BOX_WIDTH, BOX_HEIGHT, checkButton), gridbag, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
class FixedSizedPanel extends JPanel {
|
class FixedSizedPanel extends JPanel {
|
||||||
|
@ -111,5 +161,13 @@ public class OptionsPanel extends JPanel implements Serializable {
|
||||||
public void addPossibleValue(String aValue) {
|
public void addPossibleValue(String aValue) {
|
||||||
mComboBox.insertItemAt (aValue, mComboBox.getItemCount());
|
mComboBox.insertItemAt (aValue, mComboBox.getItemCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setSelectedIndex(int anIndex) {
|
||||||
|
mComboBox.setSelectedIndex(anIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSelectedIndex() {
|
||||||
|
return mComboBox.getSelectedIndex();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче