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

📄 settings.java

📁 手机邮箱撒的方式方式方式的
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
package mujmail;

/*
MujMail - Simple mail client for J2ME
Copyright (C) 2006 Nguyen Son Tung <n.sontung@gmail.com>
Copyright (C) 2006 Martin Stefan <martin.stefan@centrum.cz>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the 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 of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;

import javax.microedition.lcdui.AlertType;
import javax.microedition.lcdui.Choice;
import javax.microedition.lcdui.ChoiceGroup;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.Item;
import javax.microedition.lcdui.ItemStateListener;
import javax.microedition.lcdui.TextField;
import javax.microedition.rms.RecordStore;

import mujmail.ordering.Criterion;
import mujmail.ordering.Ordering;
//#ifdef MUJMAIL_SSL
import mujmail.ui.SSLTypeChooser;
//#endif
public class Settings implements ItemStateListener {

    /** Flag signals if we want to print debug prints */
    private static final boolean DEBUG = false;

    //determine actual settings format, change it always we modify settings format.
    //otherwise loading a different format will cause a crash!
    public final long SETTINGSVERSION = 20090319;

    private ChoiceGroup retrievingSettingsChG;
    private ChoiceGroup otherSettingsChG;
    private ChoiceGroup storingMailsSettingsChG;
    private ChoiceGroup viewMailsSmallFontChG;
    
    public static final int FONT_NORMAL = 0;
    public static final int FONT_LARGE = 1;
    
    public static final int CONST_PORT_SMTP = 25;
    public static final int CONST_PORT_SMTPS = 465;

    //ChoiceGroup optionsCG;
    ChoiceGroup smtpSSLCG;
    ChoiceGroup pollCG;
    ChoiceGroup fontSizeCG;
    //#ifdef MUJMAIL_SSL    
    SSLTypeChooser sslTypeChooser;
    //#endif
    TextField mujMailSrvAddrTF;
    TextField mujMailSrvPortTF;
    TextField mujMailSrvLoginTF;
    TextField mujMailSrvPasswdTF;
    
    TextField smtpAuthNameTF;
    TextField smtpAuthPassTF;
    TextField smtpServerTF;
    TextField smtpPortTF;
    //TextField minInBoxDBSpaceTF;
    TextField maxMailsTF;
    TextField maxLinesTF;
    TextField maxSizeOfBodyPartTF;
    TextField pollInvlTF;
    TextField timeoutTF;
    TextField signatureTF;
    TextField passwordTF;

    Command back, ok;

      // TODO (betlista): next comment is correct, but it breaks good OOP design
    //all attributes are static for easier access from other classes, without
    //having a reference (mujMail.settings.)	
    
    public static String mujMailSrvAddr;
    public static String mujMailSrvPort;
    public static String mujMailSrvLogin;
    public static String mujMailSrvPasswd = "";

    public static int fontSize;
    public static final String notSetPE = "not_set.see@Accounts.menu";
    public static String primaryEmail;
    public static volatile String smtpServer;
    public static boolean smtpSSL;
    public static byte smtpSSLType;
    public static short smtpPort;
    // TODO: delete all default values
    public static String smtpAuthName;
    public static String smtpAuthPass = "";
    public static boolean downWholeMail;
    public static boolean downOnlyNeverSeen; //download only mails that were never seen in all seasons
    public static boolean delMailFromServer;
    public static boolean delOnExit;
    public static boolean addToAddressbook;
    public static boolean smallFontMailForm;
    public static boolean replaceTabs;//if mailForm should display ' ' instead of '\t'
    public static boolean moveToTrash; //use trash or not	
    public static boolean safeMode; //recycles only one record store to store mail bodies
    public static String password = ""; /** Password that must be entered before mujMail starts. If empty, no password must be entered. */
    //public static short minInBoxDBSpace = -1; //auto clear inbox if out of DB space
    public static short maxMailsRetrieve; //how many mails should be downloaded once per an account
    public static short maxLinesRetrieve; //how many lines of a mail to retrieve
    /** The maximum size of bodypart. -1 means unlimited size. */
    private static long maxSizeOfBodypart;
    public static boolean pollDownloadsMails;
    public static boolean pollPlaysSound;
    public static int pollInvl; //polling interval in sec	
    public static int timeout; //communication timeout	
    public static String signature;
    public static final int noopPeriod = 1000 * 30; //a period in which protocols sends "noop" or its equivalent to keep connection alive
    public static final int noopIMAPPeriod = 1000 * 60 * 5; //noop period of IMAP 29minutes
    //represents sort modes of the boxes. 
    //the most right 4bits are for inBox sortMode, other 4bits are for draft, other 4 are for outBox, other 4 for sentBox
    //see more in the TheBox.sortMode comments
    public static int theBoxSortModes;
    //if debug is set to true most of alerts and information exchanged with server are printed to SYSTEM.OUT
    public static final boolean debug = false;

    /** Defines whether or not e-mail have to be ordered in threads. */
    public static boolean threading;
    /* * Defines if the empty root messages for threads have to be shown. */
    //public static boolean rootsVisible;
    /** Automatically delete mails when headers database is full. */
    public static boolean deleteMailsWhenHeaderDBIsFull;
    /** Automatically delete body of mails when body database is full. */
    public static boolean deleteMailsBodyWhenBodyDBIsFull;

    MujMail mujMail;
    SortForm sortForm;

    /**
     * Gets maximum size of bodypart.
     * @return maximum size of bodypart.
     */
    public static long getMaxSizeOfBodypart() {
        if (maxSizeOfBodypart == -1) return Long.MAX_VALUE;

        return maxSizeOfBodypart;
    }

    /**
     * Loads default values of static variables.
     */
    private void loadDefaultValues() {
        mujMailSrvAddr   = "server-dev.mujmail.org";
        mujMailSrvPort   = "143";
        mujMailSrvLogin  = "@server-dev.mujmail.org";
        mujMailSrvPasswd = "";

        fontSize = FONT_NORMAL;
        primaryEmail = notSetPE;
        smtpServer = "smtp_of_your_mobile_operator.com";
        smtpSSL = false;
        smtpSSLType = 0;
        smtpPort = 25;
        smtpAuthName = "";
        smtpAuthPass = "****";
        downWholeMail = false;
        downOnlyNeverSeen = true; //download only mails that were never seen in all seasons
        delMailFromServer = true;
        delOnExit = false;
        addToAddressbook = true;
        smallFontMailForm = true;
        replaceTabs = true;//if mailForm should display ' ' instead of '\t'
        moveToTrash = false; //use trash or not
        safeMode = false; //recycles only one record store to store mail bodies
        password = ""; /** Password that must be entered before mujMail starts. If empty, no password must be entered. */
        //public static short minInBoxDBSpace = -1; //auto clear inbox if out of DB space
        maxMailsRetrieve = 150; //how many mails should be downloaded once per an account
        maxLinesRetrieve = -1; //how many lines of a mail to retrieve
        /** The maximum size of bodypart. -1 means unlimited size. */
        maxSizeOfBodypart = 100000;
        pollDownloadsMails = false;
        pollPlaysSound = true;
        pollInvl = 60 * 5; //polling interval in sec
        timeout = 10 * 1000; //communication timeout
        signature = "";

        //represents sort modes of the boxes.
        //the most right 4bits are for inBox sortMode, other 4bits are for draft, other 4 are for outBox, other 4 for sentBox
        //see more in the TheBox.sortMode comments
        theBoxSortModes = 0;

        threading = false;
        deleteMailsWhenHeaderDBIsFull = false;
        deleteMailsBodyWhenBodyDBIsFull = false;
    }

    /**
     * Restores settings to default values.
     */
    public void restoreSettings() {
        loadDefaultValues();
        saveSettings(false);
        updateValuesToForms();
    }

    //#ifdef MUJMAIL_SYNC
    public String toString() {
    	StringBuffer sb = new StringBuffer();
    	sb.append("SettingsVersion: ").append(SETTINGSVERSION).append('\n');
    	sb.append("mujMailSrvAddr: ").append(mujMailSrvAddr).append('\n');
    	sb.append("mujMailSrvPort: ").append(mujMailSrvPort).append('\n');
    	sb.append("mujMailSrvLogin: ").append(mujMailSrvLogin).append('\n');
    	sb.append("primaryEmail: ").append(primaryEmail).append('\n');
    	sb.append("smtpServer: ").append(smtpServer).append('\n');
    	sb.append("smtpSSL: ").append((smtpSSL ? "1" : "0")).append('\n');
        //#ifdef MUJMAIL_SSL
        sb.append("smtpSSLType: ").append(smtpSSLType).append('\n');
        //#endif
    	sb.append("smtpPort: ").append(smtpPort).append('\n');
    	sb.append("smtpAuthName: ").append(smtpAuthName).append('\n');
    	sb.append("fontSize: ").append(fontSize).append('\n');
    	sb.append("downWholeMail: ").append((downWholeMail ? "1" : "0")).append('\n');
    	sb.append("downOnlyNeverSeen: ").append((downOnlyNeverSeen ? "1" : "0")).append('\n');
    	sb.append("delMailFromServer: ").append((delMailFromServer ? "1" : "0")).append('\n');
    	sb.append("delOnExit: ").append((delOnExit ? "1" : "0")).append('\n');
    	sb.append("addToAddressbook: ").append((addToAddressbook ? "1" : "0")).append('\n');
    	sb.append("smallFontMailForm: ").append((smallFontMailForm ? "1" : "0")).append('\n');
    	sb.append("replaceTabs: ").append((replaceTabs ? "1" : "0")).append('\n');
    	sb.append("moveToTrash: ").append((moveToTrash ? "1" : "0")).append('\n');
    	sb.append("safeMode: ").append((safeMode ? "1" : "0")).append('\n');
        sb.append("deleteMailsWhenHeaderDBIsFull: ").append((deleteMailsWhenHeaderDBIsFull ? "1" : "0")).append('\n');
        sb.append("deleteMailsBodyWhenBodyDBIsFull: ").append((deleteMailsBodyWhenBodyDBIsFull ? "1" : "0")).append('\n');
    	//sb.append("minInBoxDBSpace: ").append(minInBoxDBSpace).append('\n');
    	sb.append("maxMailsRetrieve: ").append(maxMailsRetrieve).append('\n');
    	sb.append("maxLinesRetrieve: ").append(maxLinesRetrieve).append('\n');
        sb.append("maxSizeOfBodypart: ").append(maxSizeOfBodypart).append('\n');
    	sb.append("pollPlaysSound: ").append((pollPlaysSound ? "1" : "0")).append('\n');
    	sb.append("pollDownloadsMails: ").append((pollDownloadsMails ? "1" : "0")).append('\n');
    	sb.append("pollInvl: ").append(pollInvl).append('\n');
    	sb.append("timeout: ").append(timeout).append('\n');
    	sb.append("theBoxSortModes: ").append(theBoxSortModes).append('\n');
    	sb.append("signature: ").append(signature).append("\n\n");		//NOTE: last line has to contain double newline
    	return sb.toString();

⌨️ 快捷键说明

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