org.shaker.dwu
Class Settings

java.lang.Object
  |
  +--java.util.Dictionary
        |
        +--java.util.Hashtable
              |
              +--java.util.Properties
                    |
                    +--org.shaker.dwu.Settings
All Implemented Interfaces:
java.lang.Cloneable, java.util.Map, java.io.Serializable

final class Settings
extends java.util.Properties

This class manages all DocWhatsUp properties:

The POP settings and the mailaccount name must be present for POP-Auth SMTP-Servers (like the majority of them).

Author:
Philipp Bartsch (codeshaker@gmx.net), GPL License
See Also:
Serialized Form

Inner classes inherited from class java.util.Map
java.util.Map.Entry
 
Field Summary
private  javax.mail.internet.InternetAddress[] ccArray
          The array of cc addresses, specified by settings.dwu
private static java.io.File cfgFile
          Settings file reference
private  java.io.FileInputStream cfgInstream
          Settings file inputstream
private  java.io.FileOutputStream cfgOutstream
          Settings file outputstream
private static java.util.Properties cfgProps
          The common settings (that also stores sigs of submitted BugProfiles)
private static java.io.File cstmFile
          Custom mail configuration file reference
(package private) static byte FROM
          User`s mail address - key
private  javax.mail.internet.InternetAddress[] mntArray
          The array of maintainer addresses, specified by settings.dwu
(package private) static byte POP
          POP-Server key
(package private) static byte POP_PORT
          POP-Server port key
private  java.io.InputStream propInstream
          Mail settings file inputstream
private  java.io.FileOutputStream propOutstream
          Mail settings file outputstream
(package private) static byte SMTP
          SMTP-Server key
(package private) static byte SMTP_PORT
          SMTP-Server port key
(package private) static byte SUBMITTED
          Submission list key
(package private) static byte USER
          Mail account name key
 
Fields inherited from class java.util.Properties
defaults, hexDigit, keyValueSeparators, serialVersionUID, specialSaveChars, strictKeyValueSeparators, whiteSpaceChars
 
Fields inherited from class java.util.Hashtable
count, emptyEnumerator, emptyIterator, ENTRIES, entrySet, KEYS, keySet, loadFactor, modCount, table, threshold, values, VALUES
 
Constructor Summary
(package private) Settings()
          Inits the Properties and loads, if present, older values.
 
Method Summary
(package private)  boolean alreadySubmitted(java.lang.String hashValue)
          Returns true if a BugProfile with the given hashValue has already been submitted before.
(package private)  void applyChanges()
          Returns true, if the current settings could be successfully saved to disk.
(package private)  java.lang.String getAlternativeRecipient()
          Returns the alternative recipient specified by "alt" in settings.dwu or null, if nothing is specified.
(package private)  javax.mail.internet.InternetAddress[] getCoRecipients()
          Returns the co recipients specified by "cc" in settings.dwu.
(package private)  java.lang.String getDefaultSendFormat()
          Returns the specified default send format or text, if nothing has been specified.
(package private)  javax.mail.internet.InternetAddress[] getMaintainers()
          Returns the address of the DWU project maintainer specified by "maintain" in settings.dwu or null, if nothing is specified.
(package private)  java.lang.String getPassword()
          Returns the specified password.
(package private)  int getPOPPort()
          Returns the POP-Server port.
(package private)  java.lang.String getPOPServer()
          Return the POP-Server address.
(package private)  javax.mail.internet.InternetAddress getSender()
          Returns users mail address.
(package private) static java.io.File getSettingsFile()
           
(package private)  int getSMTPPort()
          Returns the SMTP-Server port.
(package private)  java.lang.String getSMTPServer()
          Returns the specified SMTP-Server address.
(package private)  int getTransferCount()
          Returns the number of transmitted report.
(package private)  java.lang.String getUser()
          Returns mail account name.
(package private)  boolean hasAlternativeRecipient()
          Returns true, if a valid alternative recipient has been specified.
(package private)  boolean hasCoRecipient()
          Returns true, if the settings.dwu file specified further recipients.
(package private)  boolean hasMaintainer()
          Returns true, if at least one valid maintainers has been specified.
(package private)  boolean hasPassword()
          Returns true, if a password has been specified.
(package private)  boolean hasPOPServer()
          Returns true, if a pop-server has been specified.
(package private)  boolean hasSMTPServer()
          Returns true, if a mailaccount has been specified.
(package private)  boolean hasUser()
          Returns true, if a mail account has been specified.
(package private) static boolean isConfigurated()
          Returns true if the default or custom mail config files are present.
(package private)  boolean isDialogEnabled()
          Returns true, if "dialogs" in settings.dwu has been set to "true".
(package private)  boolean isMailingEnabled()
          Returns true, if "mailing" in settings.dwu has been set to "true".
(package private) static void killPhysically()
          Tries to delete a somehow corrupted properties file.
(package private)  void registerSubmission(java.lang.String hashValue)
          Registers a BugProfile as submitted.
(package private)  void removePassword()
          Removes the given password to force the user to reenter it.
(package private)  javax.mail.internet.InternetAddress[] resolveAddrs(java.lang.String rawList)
          Returns all addresses of a comma separated string containing mail addresses.
(package private)  void revertChanges()
          Reverts current settings and loads saved state.
(package private)  void setProperty(byte key, java.lang.String value)
          Sets a mail configuration property.
 
Methods inherited from class java.util.Properties
, continueLine, enumerate, getProperty, getProperty, list, list, load, loadConvert, propertyNames, save, saveConvert, setProperty, store, toHex, writeln
 
Methods inherited from class java.util.Hashtable
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, get, getEnumeration, getIterator, hashCode, isEmpty, keys, keySet, put, putAll, readObject, rehash, remove, size, toString, values, writeObject
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

POP

static final byte POP
POP-Server key

POP_PORT

static final byte POP_PORT
POP-Server port key

SMTP

static final byte SMTP
SMTP-Server key

SMTP_PORT

static final byte SMTP_PORT
SMTP-Server port key

USER

static final byte USER
Mail account name key

FROM

static final byte FROM
User`s mail address - key

SUBMITTED

static final byte SUBMITTED
Submission list key

cfgFile

private static final java.io.File cfgFile
Settings file reference

cstmFile

private static final java.io.File cstmFile
Custom mail configuration file reference

cfgProps

private static final java.util.Properties cfgProps
The common settings (that also stores sigs of submitted BugProfiles)

ccArray

private final javax.mail.internet.InternetAddress[] ccArray
The array of cc addresses, specified by settings.dwu

mntArray

private final javax.mail.internet.InternetAddress[] mntArray
The array of maintainer addresses, specified by settings.dwu

cfgInstream

private java.io.FileInputStream cfgInstream
Settings file inputstream

cfgOutstream

private java.io.FileOutputStream cfgOutstream
Settings file outputstream

propInstream

private java.io.InputStream propInstream
Mail settings file inputstream

propOutstream

private java.io.FileOutputStream propOutstream
Mail settings file outputstream
Constructor Detail

Settings

Settings()
Inits the Properties and loads, if present, older values.
Method Detail

isConfigurated

static final boolean isConfigurated()
Returns true if the default or custom mail config files are present. If one of these file exists, there`s implicitly a working configuration.
Returns:
boolean flag
See Also:
if you want to know, where the files are located

revertChanges

final void revertChanges()
Reverts current settings and loads saved state.

getSettingsFile

static final java.io.File getSettingsFile()

killPhysically

static final void killPhysically()
Tries to delete a somehow corrupted properties file.

applyChanges

final void applyChanges()
Returns true, if the current settings could be successfully saved to disk.

setProperty

final void setProperty(byte key,
                       java.lang.String value)
Sets a mail configuration property. Used keys:
Parameters:
key - an int key representation of the current value
value - a string representation of the value

getSender

final javax.mail.internet.InternetAddress getSender()
Returns users mail address.
Returns:
InternetAddress the mail address

hasPassword

final boolean hasPassword()
Returns true, if a password has been specified.
Returns:
true, if there`s a password

getPassword

final java.lang.String getPassword()
Returns the specified password. see#hasPassword() that should be used to check presence
Returns:
the password

removePassword

final void removePassword()
Removes the given password to force the user to reenter it. This method doesn`t delete the password of the default mail configuration!

hasUser

final boolean hasUser()
Returns true, if a mail account has been specified.
Returns:
boolean flag

getUser

final java.lang.String getUser()
Returns mail account name.
Returns:
String the mail account name

hasPOPServer

final boolean hasPOPServer()
Returns true, if a pop-server has been specified.
Returns:
boolean flag

getPOPServer

final java.lang.String getPOPServer()
Return the POP-Server address.
Returns:
String the POP-Server address

getPOPPort

final int getPOPPort()
Returns the POP-Server port.
Returns:
int the port

hasSMTPServer

final boolean hasSMTPServer()
Returns true, if a mailaccount has been specified.
Returns:
boolean flag

getSMTPServer

final java.lang.String getSMTPServer()
Returns the specified SMTP-Server address.
Returns:
String the address

getSMTPPort

final int getSMTPPort()
Returns the SMTP-Server port.
Returns:
int the port

getDefaultSendFormat

final java.lang.String getDefaultSendFormat()
Returns the specified default send format or text, if nothing has been specified.
Returns:
the default format from common.properties or an empty string

isMailingEnabled

final boolean isMailingEnabled()
Returns true, if "mailing" in settings.dwu has been set to "true". If you set "mailing" to "false", DWU won`t submit mails, doesn`t include the "Send Error" tab into the dialogs and ignores the submitBugQueue() method.
Returns:
true, if "mailing" in settings.dwu is set to "true"

isDialogEnabled

final boolean isDialogEnabled()
Returns true, if "dialogs" in settings.dwu has been set to "true". If you set "dialogs" to "false", DWU won`t create dialogs, even if you call the appropiate methods.
Returns:
true, if "dialogs" in settings.dwu is set to "true"

hasMaintainer

final boolean hasMaintainer()
Returns true, if at least one valid maintainers has been specified.
Returns:
true, if settings.dwu contains a valid "maintain" entry

getMaintainers

final javax.mail.internet.InternetAddress[] getMaintainers()
Returns the address of the DWU project maintainer specified by "maintain" in settings.dwu or null, if nothing is specified. If this property is missing, DWU won`t send maintenance mails (about DWU errors).
Returns:
the addresses of the maintainer or an empty array

getCoRecipients

final javax.mail.internet.InternetAddress[] getCoRecipients()
Returns the co recipients specified by "cc" in settings.dwu.
Returns:
the cc address array

hasCoRecipient

final boolean hasCoRecipient()
Returns true, if the settings.dwu file specified further recipients.
Returns:
cc flag

hasAlternativeRecipient

final boolean hasAlternativeRecipient()
Returns true, if a valid alternative recipient has been specified.
Returns:
true, if settings.dwu contains a valid "alt" entry

getAlternativeRecipient

final java.lang.String getAlternativeRecipient()
Returns the alternative recipient specified by "alt" in settings.dwu or null, if nothing is specified.
Returns:
the alternative recipient

getTransferCount

final int getTransferCount()
Returns the number of transmitted report.
Returns:
int the amount

registerSubmission

final void registerSubmission(java.lang.String hashValue)
Registers a BugProfile as submitted.
Parameters:
hashValue - the hashvalue of the submitted profile

alreadySubmitted

final boolean alreadySubmitted(java.lang.String hashValue)
Returns true if a BugProfile with the given hashValue has already been submitted before. This method searches for an entry of the given hashValue in section "submitted" (which keeps track of submitted hashes).
Parameters:
hashValue - the current StackTrace hashvalue
Returns:
boolean true if already submitted

resolveAddrs

final javax.mail.internet.InternetAddress[] resolveAddrs(java.lang.String rawList)
Returns all addresses of a comma separated string containing mail addresses.
Parameters:
rawList - a comma separated string of addresses
Returns:
the resolved address array