⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sendmail.java

📁 手机邮箱撒的方式方式方式的
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
package mujmail;/*MujMail - Simple mail client for J2MECopyright (C) 2006 Nguyen Son Tung <n.sontung@gmail.com>Copyright (C) 2008 David Hauzar <david.hauzar.mujmail@gmail.com> This program is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 2 of the License, or(at your option) any later version.This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program; if not, write to the Free SoftwareFoundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */import mujmail.util.Functions;import java.util.Enumeration;import java.util.Vector;import javax.microedition.lcdui.AlertType;import javax.microedition.lcdui.Choice;import javax.microedition.lcdui.ChoiceGroup;import javax.microedition.lcdui.Command;import javax.microedition.lcdui.Displayable;import javax.microedition.lcdui.Form;import javax.microedition.lcdui.Item;import javax.microedition.lcdui.ItemStateListener;import javax.microedition.lcdui.List;import javax.microedition.lcdui.StringItem;import javax.microedition.lcdui.TextBox;import javax.microedition.lcdui.TextField;import javax.microedition.rms.RecordStore;import javax.microedition.rms.RecordStoreException;import mujmail.account.MailAccount;/** * The form for creating new mail. *  * TODO: better handling of messages which are edited in createAndSaveMessageHeader *  * TODO: Better comments *  * Implementation detail: Attachments must be last items in this form. * Otherwise removing attachments will not work and there will be removed * another items. See method FSAttachemtsAdder.removeAllAttachements() *  * @see FSAttachmentsAdder#removeAllAttachments() */public class SendMail extends Form        implements ItemStateListener         {    /** The name of this source file */    private static final String SOURCE_FILE = "SendMail";    private Displayable nextScreen;    static final byte NORMAL = 0;    static final byte EDIT = 1;    static final byte REPLY = 2;    static final byte FORWARD = 3;//    //http://forum.java.sun.com/thread.jspa?threadID=5245522&messageID=10017092//    Canvas iCanvas;    /** The header of the message which will be created from this form *///    private MessageHeader header;    byte mode = NORMAL;    TextField to, bcc, cc, subject, body, selectedField;    StringItem from;    Command preview;    Command ok, cancel, send, sendLater, draft, bc, clear, addRcp, chooseAccount, editBody, updateBody, cancelBody;    boolean bcc_cc_added;      // TODO (Betlista): comment this, why is this persistent box called "callBox" ?    PersistentBox callBox;    AccountsForm accountsForm;    ChoiceGroup accountsCG;//    TextBoxCB editbodyTB;    TextBox editbodyTB;    MujMail mujMail;    //#ifdef MUJMAIL_FS    // Filesystem     /** Handles the support of filesystem in SendMail form */    private FSAttachmentsAdder attachementsAdder = null;    public FSAttachmentsAdder getAttachementsAdder() {        return attachementsAdder;    }    //#endif    /**     * Shows form with active account list.      * Permit users to select mail used as sender (From entry)     */    class AccountsForm extends Form {        public AccountsForm() {            super(Lang.get(Lang.AS_ACCOUNTS));            accountsCG = new ChoiceGroup(Lang.get(Lang.SM_SENDING_ACCOUNT), Choice.EXCLUSIVE);            append(accountsCG);            addCommand(ok);            addCommand(cancel);            setCommandListener(mujMail);        }        public void refresh() {            if (!mujMail.getInBox().hasAccountToRetrieve()) {                mujMail.alert.setAlert(this, null, Lang.get(Lang.ALRT_AS_NO_ACCOUNT_SET_ACTIVE), MyAlert.DEFAULT, AlertType.WARNING);                return;            }            //markAsDeleted old things            for (int i = accountsCG.size() - 1; i >= 0; --i) {                accountsCG.delete(i);            }            int i = 0;            //let's show the primary account on the first place            if (!Settings.primaryEmail.equals(Settings.notSetPE)) {                accountsCG.append(Settings.primaryEmail, null);                accountsCG.setSelectedIndex(i, true);                ++i;            }            //let's list all of the active rest			            for (Enumeration e = mujMail.getMailAccounts().elements(); e.hasMoreElements();) {                MailAccount account = (MailAccount) e.nextElement();                if (account.isActive() && !account.getEmail().equals(Settings.primaryEmail)) {                    accountsCG.append(account.getEmail(), null);                    //if it was selected already, select it                    if (account.getEmail().equals(from.getText())) {                        accountsCG.setSelectedIndex(i, true);                    }                    ++i;                }            }            //lets choose the primary or the first one if none was selected            if (accountsCG.getSelectedIndex() == -1) {                accountsCG.setSelectedIndex(0, true);            }            mujMail.getDisplay().setCurrent(this);        }    }    public SendMail(MujMail mujMail) {        super(Lang.get(Lang.AC_WRITE_MAIL));        //        header = new MessageHeader(mujMail.outBox);                this.mujMail = mujMail;        from = new StringItem(Lang.get(Lang.ML_FROM), "");        if ( Properties.textFieldMailIncorrect ) {            bcc = new TextField("Bcc:", "", 256, TextField.ANY);            cc = new TextField("Cc:", "", 256, TextField.ANY);            to = new TextField(Lang.get(Lang.ML_TO), "", 256, TextField.ANY);         } else {            bcc = new TextField("Bcc:", "", 256, TextField.EMAILADDR);            cc = new TextField("Cc:", "", 256, TextField.EMAILADDR);            to = new TextField(Lang.get(Lang.ML_TO), "", 256, TextField.EMAILADDR);         }        subject = new TextField(Lang.get(Lang.ML_SUBJECT), "", 256, TextField.ANY);        body = new TextField(Lang.get(Lang.ML_BODY), "", 5000, TextField.ANY);        //#ifdef MUJMAIL_FS        if ( Properties.JSR75Available() == true) {            attachementsAdder = new FSAttachmentsAdder(this);        }        //#endif                preview = new Command(Lang.get(Lang.BTN_SM_PREVIEW), Command.ITEM, 9);        ok = new Command(Lang.get(Lang.BTN_OK), Command.OK, 0);        cancel = new Command(Lang.get(Lang.BTN_CANCEL), Command.BACK, 5);        send = new Command(Lang.get(Lang.BTN_SM_SEND), Command.ITEM, 1);        addRcp = new Command(Lang.get(Lang.BTN_SM_USE_AB), Command.ITEM, 2);        sendLater = new Command(Lang.get(Lang.BTN_SM_SEND_LATTER), Command.ITEM, 3);        draft = new Command(Lang.get(Lang.BTN_SAVE), Command.ITEM, 4);        bc = new Command(Lang.get(Lang.BTN_SM_BC), Command.ITEM, 5);        editBody = new Command( Lang.get(Lang.BTN_SM_EDIT_BODY_FULLSCREEN), Command.ITEM, 6);        clear = new Command(Lang.get(Lang.BTN_SM_CLEAR), Command.ITEM, 7);        chooseAccount = new Command(Lang.get(Lang.BTN_SM_CHOOSE_FROM), Command.ITEM, 8);        accountsForm = new AccountsForm();        editbodyTB = new TextBox(Lang.get(Lang.SM_EDIT_BODY), "", 5000, TextField.ANY);		//        editbodyTB = new TextBoxCB("Edit body", "", 5000, TextField.ANY, this.mujMail);		//        editbodyTB.cmStartMark = new Command("Mark", Command.SCREEN, 2);//        editbodyTB.cmCopy = new Command("Copy", Command.SCREEN, 3);//        editbodyTB.cmCut = new Command("Cut", Command.SCREEN, 4);//        editbodyTB.cmPaste = new Command("Paste", Command.SCREEN, 5);        updateBody = new Command( Lang.get(Lang.BTN_SM_UPDATE_BODY), Command.ITEM,9);        cancelBody = new Command( Lang.get(Lang.BTN_SM_CANCEL_BODY), Command.BACK, 1);        append(from);        append(to);        append(subject);        append(body);        addCommand(preview);        addCommand(bc);        addCommand(addRcp);        addCommand(cancel);        addCommand(send);        addCommand(sendLater);        addCommand(draft);        addCommand(editBody);        addCommand(clear);        addCommand(chooseAccount);        setCommandListener(mujMail);        setItemStateListener(this);        editbodyTB.addCommand(cancelBody);//        editbodyTB.addCommand(editbodyTB.cmStartMark);//        editbodyTB.addCommand(editbodyTB.cmCopy);//        editbodyTB.addCommand(editbodyTB.cmCut);//        editbodyTB.addCommand(editbodyTB.cmPaste);        editbodyTB.addCommand(updateBody);        editbodyTB.setCommandListener(mujMail);      }        /* *     * Creates the message from this form.     * @return     *///    public MessageHeader createMessage() {//    }    public void itemStateChanged(Item item) {        selectedField = (TextField) item;    }        public TextField getSelectedItem() {        return selectedField;    }    public void replyAll(MessageHeader header) {        nextScreen = MujMail.mujmail.mailForm;        reply(header);        Vector rcp = Functions.parseRcp(header.getFrom() + ", " + header.getRecipients() );                //remove my own email address - doesn't make sense to reply myself        rcp.removeElement(header.getAccountID());                StringBuffer bf = new StringBuffer();        for (int i = rcp.size() - 1; i >= 0; --i) {            bf.append(((String) rcp.elementAt(i)) + ", ");        }        to.setString(bf.toString());    }    public void reply(MessageHeader header) {        nextScreen = MujMail.mujmail.mailForm;        mode = REPLY;        from.setText(header.getAccountID());        to.setString(header.getFrom().trim());        if (header.getSubject().toLowerCase().startsWith("re:")) {            subject.setString(header.getSubject());        } else {            subject.setString("Re: " + header.getSubject());        }        this.callBox = header.getBox();        mujMail.getDisplay().setCurrent(this);    }    public void quotedReply(MessageHeader header) {        nextScreen = MujMail.mujmail.mailForm;        if (header.getBodyPartCount() == 0 || !(header.getBpType((byte) 0) == BodyPart.TYPE_HTML || header.getBpType((byte) 0) == BodyPart.TYPE_TEXT)) {            mujMail.alert.setAlert(null, null, Lang.get(Lang.ALRT_SM_CAN_NOT_ATTACH_BODY), MyAlert.DEFAULT, AlertType.WARNING);        } else {            if ((header.getBpType((byte) 0) == BodyPart.TYPE_TEXT || header.getBpType((byte) 0) == BodyPart.TYPE_HTML) && header.getBpState((byte) 0) <= BodyPart.BS_PARTIAL) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -