/*
 * COPYRIGHT (c) 1998-1999 Jan-Henrik Haukeland, http://www.tildeslash.com/
 */


package ts.config;

/**
 * Application universal Constants
 *
 * @author  Jan-Henrik Haukeland  &lt;hauk@tildeslash.com&gt;
 * @version $Id: Constant.java,v 1.29 2001/08/13 12:48:30 hauk Exp $
 */
public final class Constant 
{

  private static String  _line_separator;
  private static String  _file_separator;
  private static String  _user_home;
  private static String  _user_name;
  
  static 
  {
    _line_separator= System.getProperty("line.separator");
    _file_separator= System.getProperty("file.separator"); 
    _user_home=      System.getProperty("user.home");
    _user_name=      System.getProperty("user.name");
  }


  private Constant() {}


  /** The application version */
  public final static String VERSION= "1.3.2";

  
  // ---------------------- Mail fields supported ------------------- //


  /** Mail id */
  public final static String MAIL_ID=         "Id"; 

  /** Mail date */
  public final static String MAIL_DATE=       "Date"; 
  
  /** Mail reply-to field */
  public final static String MAIL_REPLY=      "Reply"; 
  
  /** Mail From field */
  public final static String MAIL_FROM=       "From"; 
  
  /** Mail to field */
  public final static String MAIL_TO=         "To"; 
  
  /** Mail subject field */
  public final static String MAIL_SUBJECT=    "Subject"; 
  
  /** Mail organization field */
  public final static String MAIL_ORGANIZATION=    "Organization"; 

  /** Mail Carbon-copy field(s) */
  public final static String MAIL_CC=         "Cc"; 
  
  /** Mail X-Header something field(s) */
  public final static String MAIL_XHEADER=    "X-Header"; 
  
  /** Mail content */
  public final static String MAIL_BODY=       "Mail-Body"; 
  

 /** All mail headers supported in Biff table */
  public final static String[] MAIL_HEADERS= {MAIL_ID,
					      MAIL_DATE,
					      MAIL_REPLY,
					      MAIL_FROM,
					      MAIL_TO,
					      MAIL_SUBJECT,
					      MAIL_ORGANIZATION};

  /**
   * Returns true if submited string is in the MAIL_HEADER set.
   * @param s String with a mailheader
   * @return True if string is a legal mail header field
   */
  public static boolean inMAIL_HEADERS(String s)
  {
    for ( int i= 0; i<MAIL_HEADERS.length; i++) {
      if ( s.equals(MAIL_HEADERS[i]) )
	  return true;
    }
    return false;
  }
	     

  // -------------------- Valid fetch protocols -------------------- //


  /** Internal Protocol name for the unix mailbox protocol */
  public final static String MBOX_PROTO=       "mbox"; 

  /** Internal Protocol name for the POP3 protocol */
  public final static String POP3_PROTO=       "pop3"; 

  /** All fetch mail protocols supported */
  public final static String[] FETCH_PROTOCOLS= {MBOX_PROTO,POP3_PROTO};
						 

  /**
   * Returns true if submited string is in the FETCH_PROTOCOL set.
   * @param s String denominating a protocol
   * @return True if string denotes a valid protocol
   */
  public static boolean inFETCH_PROTOCOLS(String s)
  {
    for ( int i= 0; i<FETCH_PROTOCOLS.length; i++) {
      if ( s.equals(FETCH_PROTOCOLS[i] ) )
	  return true;
    }
    return false;
  }


  // -------------------- Valid send protocols -------------------- //



  /** Internal Protocol name for the smtp protocol */
  public final static String SMTP_PROTO=       "smtp"; 


  /** All send mail protocols supported */
  public final static String[] SEND_PROTOCOLS= {SMTP_PROTO};
						 

  /**
   * Returns true if submited string is in the SEND_PROTOCOL set.
   * @param s String denominating a protocol
   * @return True if string denotes a valid protocol
   */
  public static boolean inSEND_PROTOCOLS(String s)
  {
    for ( int i= 0; i<SEND_PROTOCOLS.length; i++) {
      if ( s.equals(SEND_PROTOCOLS[i] ) )
	  return true;
    }
    return false;
  }



  // ------------------------ Various constants --------------------- //

  /** Basename for users local control file */
  private final static String USER_CONTROL_FILE_BASENAME= ".tsbiffrc";

  /**  
   * The full path to the users local controlfile. It will reside in
   * "user.home" with the name <I>.tsbiffrc</I>. E.g. 
   * /home/hauk/.tsbiffrc on Un*x or C:\.tsbiffrc on windows
   * 
   */
  public final static String USER_CONTROL_FILE= _user_home + 
                                            _file_separator+
                                 USER_CONTROL_FILE_BASENAME;

  


  /** About message */
  public final static String ABOUTMSG=         "tsbiff "+ VERSION+
                                             "  \u00A9 1999-2001"+
                                                             "\n"+
                          "Home page: www.tildeslash.com/tsbiff/";


  /** 
   * Main window title (tsbiff + version). 
   */
  public final static String WINDOW_TITLE=  "tsbiff " + VERSION;;


  /** Configuration dialog title */
  public final static String CONF_DIALOG_TITLE=  "Configure TsBiff";


  /** Smtp dialog title */
  public final static String SMTP_DIALOG_TITLE=  "Send mail";


  /**
   * Mail server timeout. The maximum time (in ms) to wait for 
   * establishing a connection to the mail server.
   */
  public final static int MAILSERVER_TIMEOUT=  7000;


  /**
   * Exit timeout. The maximum time to wait for any
   * SafeTerminate objects to finnish before a System.exit(1) 
   * is executed. Value in miliseconds.
   */
  public final static int EXIT_TIMEOUT=  5000;


  /**
   * A MAGIC NUMBER that will terminate a MailParser when
   * it sees this on a line by itself
   */
  public final static String MAGIC_TERMINATOR=  "1baaffa1ad1b6b7b040e";


  /**
   * X-Mailer header value when sending mail from tsbiff
   */
  public final static String X_MAILER= "tildeslash mailer version " + VERSION;


  /**
   * Wakeup server Greeting string
   */
  public final static String WAKEUP_HELLO= "1ad1b6b";

}
