зеркало из 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.ByteLineBuffer;
|
||||
import calypso.util.Preferences;
|
||||
import calypso.util.PreferencesFactory;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Container;
|
||||
|
@ -331,7 +333,7 @@ public class CompositionPanel extends GeneralPanel {
|
|||
class SaveDraft extends UIAction {
|
||||
SaveDraft() {
|
||||
super(saveDraftTag);
|
||||
setEnabled(true);
|
||||
this.setEnabled(true);
|
||||
}
|
||||
public void actionPerformed(ActionEvent e) {}
|
||||
}
|
||||
|
@ -343,7 +345,7 @@ public class CompositionPanel extends GeneralPanel {
|
|||
class SaveAs extends UIAction {
|
||||
SaveAs() {
|
||||
super(saveAsTag);
|
||||
setEnabled(true);
|
||||
this.setEnabled(true);
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
@ -381,7 +383,7 @@ public class CompositionPanel extends GeneralPanel {
|
|||
class SendNow extends UIAction {
|
||||
SendNow() {
|
||||
super(sendNowTag);
|
||||
setEnabled(true);
|
||||
this.setEnabled(true);
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent ae) {
|
||||
|
@ -401,10 +403,11 @@ public class CompositionPanel extends GeneralPanel {
|
|||
|
||||
//Check that is at least one recipient.
|
||||
if (0 < recipients.length) {
|
||||
//get the users name who's sending this message.
|
||||
Properties props = mSession.getProperties();
|
||||
String userName =
|
||||
props.getProperty("user.email_address");
|
||||
//get the sending identity
|
||||
Preferences prefs = PreferencesFactory.Get();
|
||||
int ident = mAddressBar.getOptionsPanel().getSelectedIdentity();
|
||||
String userName = prefs.getString("mail.identity-" + ident + ".username", "Nobody") + " <"
|
||||
+ prefs.getString("mail.identity-" + ident + ".email", "nobody@localhost") + ">";
|
||||
|
||||
if (userName != null) {
|
||||
//create a mime message
|
||||
|
@ -442,7 +445,7 @@ public class CompositionPanel extends GeneralPanel {
|
|||
msg.setSentDate(new java.util.Date()); //set date to now.
|
||||
msg.setContent(messageText, "text/plain"); //contents.
|
||||
try {
|
||||
mSession.getTransport().send(msg); // send the message.
|
||||
mSession.getTransport("smtp").send(msg); // send the message.
|
||||
} catch (MessagingException exc) {
|
||||
exc.printStackTrace();
|
||||
}
|
||||
|
@ -481,7 +484,7 @@ public class CompositionPanel extends GeneralPanel {
|
|||
class QuoteOriginalText extends UIAction {
|
||||
QuoteOriginalText() {
|
||||
super(quoteOriginalTextTag);
|
||||
setEnabled(true);
|
||||
this.setEnabled(true);
|
||||
}
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
if (referredMsg == null) return; // Or beep or whine??? ###
|
||||
|
@ -560,7 +563,7 @@ public class CompositionPanel extends GeneralPanel {
|
|||
class SelectAddresses extends UIAction {
|
||||
SelectAddresses() {
|
||||
super(selectAddressesTag);
|
||||
setEnabled(true);
|
||||
this.setEnabled(true);
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
@ -596,7 +599,7 @@ public class CompositionPanel extends GeneralPanel {
|
|||
class AttachFile extends UIAction {
|
||||
AttachFile() {
|
||||
super(fileTag);
|
||||
setEnabled(true);
|
||||
this.setEnabled(true);
|
||||
}
|
||||
|
||||
//display the AttachmentsList and have the file dialog "popup" on them.
|
||||
|
@ -617,7 +620,7 @@ public class CompositionPanel extends GeneralPanel {
|
|||
class PasteAsQuotation extends UIAction {
|
||||
PasteAsQuotation() {
|
||||
super(pasteAsQuotationTag);
|
||||
setEnabled(true);
|
||||
this.setEnabled(true);
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
@ -672,7 +675,7 @@ public class CompositionPanel extends GeneralPanel {
|
|||
class ViewAddress extends UIAction {
|
||||
ViewAddress() {
|
||||
super(viewAddressTag);
|
||||
setEnabled(true);
|
||||
this.setEnabled(true);
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
@ -683,7 +686,7 @@ public class CompositionPanel extends GeneralPanel {
|
|||
class ViewAttachments extends UIAction {
|
||||
ViewAttachments() {
|
||||
super(viewAttachmentsTag);
|
||||
setEnabled(true);
|
||||
this.setEnabled(true);
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
@ -694,7 +697,7 @@ public class CompositionPanel extends GeneralPanel {
|
|||
class ViewOptions extends UIAction {
|
||||
ViewOptions() {
|
||||
super(viewOptionsTag);
|
||||
setEnabled(true);
|
||||
this.setEnabled(true);
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
|
|
@ -26,21 +26,34 @@ import java.awt.*;
|
|||
import javax.swing.*;
|
||||
import javax.swing.border.*;
|
||||
|
||||
import calypso.util.Preferences;
|
||||
import calypso.util.PreferencesFactory;
|
||||
|
||||
public class OptionsPanel extends JPanel implements Serializable {
|
||||
// private final int BOX_WIDTH = 300;
|
||||
private final int BOX_WIDTH = 160;
|
||||
private final int BOX_HEIGHT = 30;
|
||||
|
||||
private GridBagConstraints c;
|
||||
private GridBagLayout gridbag;
|
||||
|
||||
private LabeledCombo ident;
|
||||
|
||||
public OptionsPanel () {
|
||||
super ();
|
||||
|
||||
c = new GridBagConstraints();
|
||||
gridbag = new GridBagLayout();
|
||||
|
||||
setLayout(gridbag);
|
||||
|
||||
setLayout(new GridLayout(3, 2, 5, 5));
|
||||
|
||||
addCheck ("Encrypted", "Encrypted", 'e', false);
|
||||
c.fill = GridBagConstraints.HORIZONTAL;
|
||||
c.weightx = 1.0;
|
||||
c.gridheight = 1;
|
||||
|
||||
addCheck ("Return Receipt", "Return Receipt", 'r', false);
|
||||
|
||||
addCheck ("Signed", "Signed", 'd', false);
|
||||
c.gridwidth = GridBagConstraints.REMAINDER; //end row
|
||||
|
||||
LabeledCombo priority = new LabeledCombo("Priority");
|
||||
priority.addPossibleValue("Lowest");
|
||||
|
@ -48,16 +61,53 @@ public class OptionsPanel extends JPanel implements Serializable {
|
|||
priority.addPossibleValue("Normal");
|
||||
priority.addPossibleValue("High");
|
||||
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");
|
||||
format.addPossibleValue("Ask me");
|
||||
format.addPossibleValue("Plain Text only");
|
||||
format.addPossibleValue("HTML Text only");
|
||||
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) {
|
||||
|
@ -75,7 +125,7 @@ public class OptionsPanel extends JPanel implements Serializable {
|
|||
if (' ' != aAccelerator) checkButton.setMnemonic(aAccelerator);
|
||||
|
||||
//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 {
|
||||
|
@ -111,5 +161,13 @@ public class OptionsPanel extends JPanel implements Serializable {
|
|||
public void addPossibleValue(String aValue) {
|
||||
mComboBox.insertItemAt (aValue, mComboBox.getItemCount());
|
||||
}
|
||||
|
||||
public void setSelectedIndex(int anIndex) {
|
||||
mComboBox.setSelectedIndex(anIndex);
|
||||
}
|
||||
|
||||
public int getSelectedIndex() {
|
||||
return mComboBox.getSelectedIndex();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче