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

📄 configuration.java

📁 一个用java写的mail.里面的代码值得我们去研究!学习。
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/*** $Id: Configuration.java,v 1.9 2001/05/07 12:37:21 kunugi Exp $**** Copyright (c) 2000-2001 Jeff Gay** on behalf of ICEMail.org <http://www.icemail.org>** Copyright (c) 1998-2000 by Timothy Gerard Endres** ** This program is free software.** ** You may redistribute it and/or modify it under the terms of the GNU** General Public License as published by the Free Software Foundation.** Version 2 of the license should be included with this distribution in** the file LICENSE, as well as License.html. If the license is not** included with this distribution, you may find a copy at the FSF web** site at 'www.gnu.org' or 'www.fsf.org', or you may write to the** Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139 USA.**** THIS SOFTWARE IS PROVIDED AS-IS WITHOUT WARRANTY OF ANY KIND,** NOT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY. THE AUTHOR** OF THIS SOFTWARE, ASSUMES _NO_ RESPONSIBILITY FOR ANY** CONSEQUENCE RESULTING FROM THE USE, MODIFICATION, OR** REDISTRIBUTION OF THIS SOFTWARE. */package org.icemail.mail;import java.io.BufferedReader;import java.io.File;import java.io.FileInputStream;import java.io.FileNotFoundException;import java.io.FileReader;import java.io.IOException;import java.awt.FileDialog;import java.awt.Rectangle;import java.util.Enumeration;import java.util.Properties;import java.util.Vector;import javax.mail.Session;import javax.activation.CommandMap;import javax.activation.FileTypeMap;import javax.activation.MailcapCommandMap;import javax.activation.MimetypesFileTypeMap;import javax.swing.JMenuBar;import javax.swing.JMenu;import javax.swing.JMenuItem;import javax.swing.JOptionPane;import org.icemail.Package;import org.icemail.util.ComponentFactory;import org.icemail.util.ResourceUtilities;import org.icemail.util.UserProperties;/** * Class Configuration */public class Configuration{  private static final int Debug_ = Package.DEBUG ? Package.getLevel( "Configuration" ) : 0;  public static final String  DP_MAIN = "MAIN";  public static final String  P_TRANSPORT_PROTO = ".mail.transport.protocol";  public static final String  P_STORE_PROTO = ".mail.store.protocol";  public static final String  P_SMTP_HOSTNAME = ".mail.smtp.host";  public static final String  P_COMPOSE_REPLY_PREFIX = "composeReplyPrefix";  public static final String  P_COMPOSE_REPLY_ENCLOSURE = "composeReplyEnclosure";  public static final String  P_COMPOSE_FORWARD_PREFIX = "composeForwardPrefix";  public static final String  P_COMPOSE_FORWARD_ENCLOSURE = "composeForwardEnclosure";  public static final String  P_COMPOSE_FORWARD_ATTACHMENTS = "composeForwardAttachments";  public static final String  P_STORE_LIST = "rootStoreList";  public static final String  PP_STORE_URL = "storeURL.";  public static final String  PP_STORE_NMSPC = "storeNameSpace.";  public static final String  P_SIG_LIST = "signatureList";  public static final String  PP_SIGNATURE = "signature.";  public static final String  P_SIG_DEFAULT = PP_SIGNATURE + "default";  public static final String  P_TEMP_DIR = "tempDirectory";  public static final String  P_TEMP_DIR_GUESS = "tempDirGuess";  public static final String  P_FROM_ADDRESS = "fromAddress";  public static final String  P_FROM_PERSONAL = "fromPersonal";  public static final String  P_REPLYTO_ADDRESS = "replyToAddress";  public static final String  P_REPLYTO_PERSONAL = "replyToPersonal";  public static final String  P_ORGANIZATION = "organization";  public static final String  P_MAIN_WINDOW = "mainWindow";  public static final String  P_MAIN_PANEL = P_MAIN_WINDOW + ".mainPanel";  public static final String  P_MAIN_PANEL_DIVIDER = P_MAIN_PANEL + ".divider";  public static final String  P_MSG_PANEL = P_MAIN_PANEL + ".msgPanel";  public static final String  P_MSG_PANEL_DIVIDER = P_MSG_PANEL + ".divider";  public static final String  P_MSG_VIEWER = P_MSG_PANEL + ".msgViewer";  public static final String  P_MSG_VIEWER_HDR_DIVIDER = P_MSG_VIEWER + ".hdr.divider";  public static final String  P_MSG_VIEWER_BODY_DIVIDER = P_MSG_VIEWER + ".body.divider";  public static final String  P_ATTACH_WINDOW = "attachWindow";  public static final String  PP_ATTACH_WINDOW = "attachWindow.";  public static final String  P_HOTJAVA_BROWSER = "hotJavaBrowser";  public static final String  P_LOCAL_MANUAL_URL = "localManual.path";  public static final String  P_INCOMING_SOUND_FLAG = "media.incomingMail.sound.flag";  public static final String  P_INCOMING_SOUND_URL = "media.incomingMail.sound.url";  public static final String  P_INCOMING_SOUND_BUILTIN = "media.incomingMail.sound.builtin";    private static Configuration Instance_ = null;  private String            name_ = null;  private boolean           haveWarned = true;  private String            mimeFileName = null;  private String            mailcapFileName = null;  private File              homeDir = null;  private Vector            mailcapTypes = new Vector();  private TempFileManager   tempFileManager_ = null;  /**   * Create a configuration with the given name.   * This method is private to limit the number of instantiations   * to a single instance, which is accessed through getInstance().   */  private  Configuration() {    name_ = Configuration.DP_MAIN;    determineHomeDirectory();  }  /**   * Get the SINGLE instance of the configuration, creating it if necessary.   *   * @return the SINGLE instance of the configuration   */  static public synchronized Configuration  getInstance() {    if ( Configuration.Instance_ == null ) {      Configuration.Instance_ = new Configuration();    }    return Configuration.Instance_;  }//............................................................// Methods for manipulating specific configuration values  /**   */  static public Vector  getCharsets() {    Vector xdefaults = new Vector();    xdefaults.addElement( new String( "UTF-8" ) );    return UserProperties.getStringVector( "charsetList", xdefaults );  }  /**   * Get the last character set chosen by the user.   */  static public String  getCharset() {    return UserProperties.getProperty( "composeCharset", "UTF-8" );  }  /**   * Set the last character set chosen by the user.   */  static public void  setCharset( String value ) {    UserProperties.setDynamicProperty( Configuration.DP_MAIN, "composeCharset", value );  }//............................................................// Methods for manually manipulating specific configuration values  static public Rectangle  getBounds( String propName, Rectangle defBounds ) {    defBounds.x = UserProperties.getProperty( propName + ".x", defBounds.x );    defBounds.y = UserProperties.getProperty( propName + ".y", defBounds.y );    defBounds.width = UserProperties.getProperty( propName + ".width", defBounds.width );    defBounds.height = UserProperties.getProperty( propName + ".height", defBounds.height );    return defBounds;  }  static public void  saveBounds( String propName, Rectangle bounds ) {    Properties xproperties = new Properties();    xproperties.put( propName + ".x", String.valueOf( bounds.x ) );    xproperties.put( propName + ".y", String.valueOf( bounds.y ) );    xproperties.put( propName + ".width", String.valueOf( bounds.width ) );    xproperties.put( propName + ".height", String.valueOf( bounds.height ) );    UserProperties.setDynamicProperties( Configuration.DP_MAIN, xproperties );  }  static public int  getDividerLocation( String propName, int defval ) {    return UserProperties.getProperty( propName + ".location", defval );  }  static public void  saveDividerLocation( String propName, int loc ) {    UserProperties.setDynamicProperty( Configuration.DP_MAIN, propName + ".location",                                       String.valueOf( loc ) );  }//............................................................// Accessors// used by ICEMail  public File  getHomeDirectory() {    return this.homeDir;  }  public Enumeration  getMailcapTypes() {    return mailcapTypes.elements();  }//............................................................// Mutators// used by ICEMail  public void  setMimeFileName( String fileName ) {    this.mimeFileName = fileName;  }// used by ICEMail  public void  setMailcapFileName( String fileName ) {    this.mailcapFileName = fileName;  }//............................................................// Helpers  public void  setProperty( String propName, boolean value ) {    UserProperties.setDynamicProperty( name_, propName, ( value ? "true" : "false" ) );  }  public void  setProperty( String propName, int value ) {    UserProperties.setDynamicProperty( name_, propName, ""+value );  }  public void  setProperty( String propName, String value ) {    UserProperties.setDynamicProperty( name_, propName, value );  }  public void  setStringArray( String propName, String[] strArray ) {    StringBuffer buf = new StringBuffer();    for ( int idx = 0 ; idx < strArray.length ; ++idx ) {      buf.append( strArray[idx] );      if ( idx < (strArray.length - 1) ) {        buf.append( ":" );      }    }    UserProperties.setDynamicProperty( name_, propName, buf.toString() );  }  public void  setStringArray( String propName, Vector strArray ) {    int size = strArray.size();    StringBuffer buf = new StringBuffer();    for ( int idx = 0 ; idx < size ; ++idx ) {      buf.append( (String) strArray.elementAt(idx) );      if ( idx < (size - 1) ) {        buf.append( ":" );      }    }    UserProperties.setDynamicProperty( name_, propName, buf.toString() );  }  public void

⌨️ 快捷键说明

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