mirror of
https://github.com/moparisthebest/davmail
synced 2024-12-12 10:42:21 -05:00
Fixes from checkStyle audit
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@734 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
e405d4a31f
commit
07569c5583
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<!DOCTYPE module PUBLIC
|
<!DOCTYPE module PUBLIC
|
||||||
"-//Puppy Crawl//DTD Check Configuration 1.1//EN"
|
"-//Puppy Crawl//DTD Check Configuration 1.2//EN"
|
||||||
"http://www.puppycrawl.com/dtds/configuration_1_1.dtd">
|
"http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
|
|
||||||
@ -31,31 +31,51 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<module name="Checker">
|
<module name="Checker">
|
||||||
|
<!--
|
||||||
|
If you set the basedir property below, then all reported file
|
||||||
|
names will be relative to the specified directory. See
|
||||||
|
http://checkstyle.sourceforge.net/5.x/config.html#Checker
|
||||||
|
|
||||||
<!-- Checks that a package.html file exists for each package. -->
|
<property name="basedir" value="${basedir}"/>
|
||||||
<!-- See http://checkstyle.sf.net/config_javadoc.html#PackageHtml
|
-->
|
||||||
<module name="PackageHtml"/>-->
|
|
||||||
|
<!-- Checks that a package-info.java file exists for each package. -->
|
||||||
|
<!-- See http://checkstyle.sf.net/config_javadoc.html#JavadocPackage -->
|
||||||
|
<!--module name="JavadocPackage"/-->
|
||||||
|
|
||||||
<!-- Checks whether files end with a new line. -->
|
<!-- Checks whether files end with a new line. -->
|
||||||
<!-- See http://checkstyle.sf.net/config_misc.html#NewlineAtEndOfFile -->
|
<!-- See http://checkstyle.sf.net/config_misc.html#NewlineAtEndOfFile -->
|
||||||
<!-- <module name="NewlineAtEndOfFile"/> -->
|
<!--module name="NewlineAtEndOfFile"/-->
|
||||||
|
|
||||||
<!-- Checks that property files contain the same keys. -->
|
<!-- Checks that property files contain the same keys. -->
|
||||||
<!-- See http://checkstyle.sf.net/config_misc.html#Translation -->
|
<!-- See http://checkstyle.sf.net/config_misc.html#Translation -->
|
||||||
<module name="Translation"/>
|
<module name="Translation"/>
|
||||||
|
|
||||||
|
<!-- Checks for Size Violations. -->
|
||||||
|
<!-- See http://checkstyle.sf.net/config_sizes.html -->
|
||||||
|
<!--module name="FileLength"/-->
|
||||||
|
|
||||||
|
<!-- Checks for whitespace -->
|
||||||
|
<!-- See http://checkstyle.sf.net/config_whitespace.html -->
|
||||||
|
<!--module name="FileTabCharacter"/-->
|
||||||
|
|
||||||
|
<!-- Miscellaneous other checks. -->
|
||||||
|
<!-- See http://checkstyle.sf.net/config_misc.html -->
|
||||||
|
<!--module name="RegexpSingleline">
|
||||||
|
<property name="format" value="\s+$"/>
|
||||||
|
<property name="minimum" value="0"/>
|
||||||
|
<property name="maximum" value="0"/>
|
||||||
|
<property name="message" value="Line has trailing spaces."/>
|
||||||
|
</module-->
|
||||||
|
|
||||||
<module name="TreeWalker">
|
<module name="TreeWalker">
|
||||||
|
|
||||||
<!--property name="cacheFile" value="${checkstyle.cache.file}"/-->
|
|
||||||
|
|
||||||
<!-- Checks for Javadoc comments. -->
|
<!-- Checks for Javadoc comments. -->
|
||||||
<!-- See http://checkstyle.sf.net/config_javadoc.html
|
<!-- See http://checkstyle.sf.net/config_javadoc.html -->
|
||||||
<module name="JavadocMethod"/>
|
<!--module name="JavadocMethod"/>
|
||||||
<module name="JavadocType"/>
|
<module name="JavadocType"/>
|
||||||
<module name="JavadocVariable"/>
|
<module name="JavadocVariable"/>
|
||||||
<module name="JavadocStyle"/>
|
<module name="JavadocStyle"/-->
|
||||||
-->
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Checks for Naming Conventions. -->
|
<!-- Checks for Naming Conventions. -->
|
||||||
@ -73,7 +93,7 @@
|
|||||||
|
|
||||||
<!-- Checks for Headers -->
|
<!-- Checks for Headers -->
|
||||||
<!-- See http://checkstyle.sf.net/config_header.html -->
|
<!-- See http://checkstyle.sf.net/config_header.html -->
|
||||||
<!--module name="Header"-->
|
<!-- <module name="Header"> -->
|
||||||
<!-- The follow property value demonstrates the ability -->
|
<!-- The follow property value demonstrates the ability -->
|
||||||
<!-- to have access to ANT properties. In this case it uses -->
|
<!-- to have access to ANT properties. In this case it uses -->
|
||||||
<!-- the ${basedir} property to allow Checkstyle to be run -->
|
<!-- the ${basedir} property to allow Checkstyle to be run -->
|
||||||
@ -83,8 +103,7 @@
|
|||||||
<!-- <property -->
|
<!-- <property -->
|
||||||
<!-- name="headerFile" -->
|
<!-- name="headerFile" -->
|
||||||
<!-- value="${basedir}/java.header"/> -->
|
<!-- value="${basedir}/java.header"/> -->
|
||||||
<!--property name="headerFile" value="${checkstyle.header.file}"/>
|
<!-- </module> -->
|
||||||
</module-->
|
|
||||||
|
|
||||||
<!-- Following interprets the header file as regular expressions. -->
|
<!-- Following interprets the header file as regular expressions. -->
|
||||||
<!-- <module name="RegexpHeader"/> -->
|
<!-- <module name="RegexpHeader"/> -->
|
||||||
@ -93,31 +112,30 @@
|
|||||||
<!-- Checks for imports -->
|
<!-- Checks for imports -->
|
||||||
<!-- See http://checkstyle.sf.net/config_import.html -->
|
<!-- See http://checkstyle.sf.net/config_import.html -->
|
||||||
<!--module name="AvoidStarImport"/-->
|
<!--module name="AvoidStarImport"/-->
|
||||||
<module name="IllegalImport"/>
|
<!--module name="IllegalImport"/--> <!-- defaults to sun.* packages -->
|
||||||
<!-- defaults to sun.* packages -->
|
|
||||||
<module name="RedundantImport"/>
|
<module name="RedundantImport"/>
|
||||||
<module name="UnusedImports"/>
|
<module name="UnusedImports"/>
|
||||||
|
|
||||||
|
|
||||||
<!-- Checks for Size Violations. -->
|
<!-- Checks for Size Violations. -->
|
||||||
<!-- See http://checkstyle.sf.net/config_sizes.html -->
|
<!-- See http://checkstyle.sf.net/config_sizes.html -->
|
||||||
<module name="FileLength"/>
|
<!--module name="LineLength"/-->
|
||||||
<!--<module name="LineLength"/>-->
|
<!--module name="MethodLength"/-->
|
||||||
<module name="MethodLength"/>
|
|
||||||
<module name="ParameterNumber"/>
|
<module name="ParameterNumber"/>
|
||||||
|
|
||||||
|
|
||||||
<!-- Checks for whitespace -->
|
<!-- Checks for whitespace -->
|
||||||
<!-- See http://checkstyle.sf.net/config_whitespace.html -->
|
<!-- See http://checkstyle.sf.net/config_whitespace.html -->
|
||||||
<!-- <module name="EmptyForIteratorPad"/>
|
<!--module name="EmptyForIteratorPad"/>
|
||||||
|
<module name="GenericWhitespace"/>
|
||||||
|
<module name="MethodParamPad"/>
|
||||||
<module name="NoWhitespaceAfter"/>
|
<module name="NoWhitespaceAfter"/>
|
||||||
<module name="NoWhitespaceBefore"/>
|
<module name="NoWhitespaceBefore"/>
|
||||||
<module name="OperatorWrap"/>
|
<module name="OperatorWrap"/>
|
||||||
<module name="ParenPad"/>
|
<module name="ParenPad"/>
|
||||||
<module name="TypecastParenPad"/>
|
<module name="TypecastParenPad"/>
|
||||||
<module name="TabCharacter"/>
|
|
||||||
<module name="WhitespaceAfter"/>
|
<module name="WhitespaceAfter"/>
|
||||||
<module name="WhitespaceAround"/>-->
|
<module name="WhitespaceAround"/-->
|
||||||
|
|
||||||
|
|
||||||
<!-- Modifier Checks -->
|
<!-- Modifier Checks -->
|
||||||
@ -129,12 +147,11 @@
|
|||||||
<!-- Checks for blocks. You know, those {}'s -->
|
<!-- Checks for blocks. You know, those {}'s -->
|
||||||
<!-- See http://checkstyle.sf.net/config_blocks.html -->
|
<!-- See http://checkstyle.sf.net/config_blocks.html -->
|
||||||
<module name="AvoidNestedBlocks"/>
|
<module name="AvoidNestedBlocks"/>
|
||||||
<module name="EmptyBlock"/>
|
<!--module name="EmptyBlock"/-->
|
||||||
<module name="LeftCurly"/>
|
<module name="LeftCurly"/>
|
||||||
<module name="NeedBraces"/>
|
<module name="NeedBraces"/>
|
||||||
<module name="RightCurly"/>
|
<module name="RightCurly"/>
|
||||||
|
|
||||||
|
|
||||||
<!-- Checks for common coding problems -->
|
<!-- Checks for common coding problems -->
|
||||||
<!-- See http://checkstyle.sf.net/config_coding.html -->
|
<!-- See http://checkstyle.sf.net/config_coding.html -->
|
||||||
<!--module name="AvoidInlineConditionals"/-->
|
<!--module name="AvoidInlineConditionals"/-->
|
||||||
@ -142,9 +159,9 @@
|
|||||||
<!-- MY FAVOURITE -->
|
<!-- MY FAVOURITE -->
|
||||||
<module name="EmptyStatement"/>
|
<module name="EmptyStatement"/>
|
||||||
<module name="EqualsHashCode"/>
|
<module name="EqualsHashCode"/>
|
||||||
<!-- <module name="HiddenField"/> -->
|
<!--module name="HiddenField"/-->
|
||||||
<module name="IllegalInstantiation"/>
|
<module name="IllegalInstantiation"/>
|
||||||
<module name="InnerAssignment"/>
|
<!--module name="InnerAssignment"/-->
|
||||||
<!--module name="MagicNumber"/-->
|
<!--module name="MagicNumber"/-->
|
||||||
<module name="MissingSwitchDefault"/>
|
<module name="MissingSwitchDefault"/>
|
||||||
<module name="RedundantThrows"/>
|
<module name="RedundantThrows"/>
|
||||||
@ -153,24 +170,20 @@
|
|||||||
|
|
||||||
<!-- Checks for class design -->
|
<!-- Checks for class design -->
|
||||||
<!-- See http://checkstyle.sf.net/config_design.html -->
|
<!-- See http://checkstyle.sf.net/config_design.html -->
|
||||||
<!-- <module name="DesignForExtension"/> -->
|
<!--module name="DesignForExtension"/-->
|
||||||
<module name="FinalClass"/>
|
<module name="FinalClass"/>
|
||||||
<module name="HideUtilityClassConstructor"/>
|
<module name="HideUtilityClassConstructor"/>
|
||||||
<module name="InterfaceIsType"/>
|
<module name="InterfaceIsType"/>
|
||||||
<module name="VisibilityModifier">
|
<!--module name="VisibilityModifier">
|
||||||
<property name="packageAllowed" value="true"/>
|
<property name="packageAllowed" value="true"/>
|
||||||
<property name="protectedAllowed" value="true"/>
|
<property name="protectedAllowed" value="true"/>
|
||||||
</module>
|
</module-->
|
||||||
|
|
||||||
|
|
||||||
<!-- Miscellaneous other checks. -->
|
<!-- Miscellaneous other checks. -->
|
||||||
<!-- See http://checkstyle.sf.net/config_misc.html -->
|
<!-- See http://checkstyle.sf.net/config_misc.html -->
|
||||||
<module name="ArrayTypeStyle"/>
|
<module name="ArrayTypeStyle"/>
|
||||||
<!-- <module name="FinalParameters"/> -->
|
<!--module name="FinalParameters"/-->
|
||||||
<!-- <module name="GenericIllegalRegexp">
|
|
||||||
<property name="format" value="\s+$"/>
|
|
||||||
<property name="message" value="Line has trailing spaces."/>
|
|
||||||
</module> -->
|
|
||||||
<module name="TodoComment"/>
|
<module name="TodoComment"/>
|
||||||
<module name="UpperEll"/>
|
<module name="UpperEll"/>
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ import java.util.ArrayList;
|
|||||||
/**
|
/**
|
||||||
* DavGateway main class
|
* DavGateway main class
|
||||||
*/
|
*/
|
||||||
public class DavGateway {
|
public final class DavGateway {
|
||||||
private static final String HTTP_DAVMAIL_SOURCEFORGE_NET_VERSION_TXT = "http://davmail.sourceforge.net/version.txt";
|
private static final String HTTP_DAVMAIL_SOURCEFORGE_NET_VERSION_TXT = "http://davmail.sourceforge.net/version.txt";
|
||||||
|
|
||||||
private static boolean stopped;
|
private static boolean stopped;
|
||||||
@ -48,7 +48,7 @@ public class DavGateway {
|
|||||||
private DavGateway() {
|
private DavGateway() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final ArrayList<AbstractServer> serverList = new ArrayList<AbstractServer>();
|
private static final ArrayList<AbstractServer> SERVER_LIST = new ArrayList<AbstractServer>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start the gateway, listen on spécified smtp and pop3 ports
|
* Start the gateway, listen on spécified smtp and pop3 ports
|
||||||
@ -101,32 +101,32 @@ public class DavGateway {
|
|||||||
// prepare HTTP connection pool
|
// prepare HTTP connection pool
|
||||||
DavGatewayHttpClientFacade.start();
|
DavGatewayHttpClientFacade.start();
|
||||||
|
|
||||||
serverList.clear();
|
SERVER_LIST.clear();
|
||||||
|
|
||||||
int smtpPort = Settings.getIntProperty("davmail.smtpPort");
|
int smtpPort = Settings.getIntProperty("davmail.smtpPort");
|
||||||
if (smtpPort != 0) {
|
if (smtpPort != 0) {
|
||||||
serverList.add(new SmtpServer(smtpPort));
|
SERVER_LIST.add(new SmtpServer(smtpPort));
|
||||||
}
|
}
|
||||||
int popPort = Settings.getIntProperty("davmail.popPort");
|
int popPort = Settings.getIntProperty("davmail.popPort");
|
||||||
if (popPort != 0) {
|
if (popPort != 0) {
|
||||||
serverList.add(new PopServer(popPort));
|
SERVER_LIST.add(new PopServer(popPort));
|
||||||
}
|
}
|
||||||
int imapPort = Settings.getIntProperty("davmail.imapPort");
|
int imapPort = Settings.getIntProperty("davmail.imapPort");
|
||||||
if (imapPort != 0) {
|
if (imapPort != 0) {
|
||||||
serverList.add(new ImapServer(imapPort));
|
SERVER_LIST.add(new ImapServer(imapPort));
|
||||||
}
|
}
|
||||||
int caldavPort = Settings.getIntProperty("davmail.caldavPort");
|
int caldavPort = Settings.getIntProperty("davmail.caldavPort");
|
||||||
if (caldavPort != 0) {
|
if (caldavPort != 0) {
|
||||||
serverList.add(new CaldavServer(caldavPort));
|
SERVER_LIST.add(new CaldavServer(caldavPort));
|
||||||
}
|
}
|
||||||
int ldapPort = Settings.getIntProperty("davmail.ldapPort");
|
int ldapPort = Settings.getIntProperty("davmail.ldapPort");
|
||||||
if (ldapPort != 0) {
|
if (ldapPort != 0) {
|
||||||
serverList.add(new LdapServer(ldapPort));
|
SERVER_LIST.add(new LdapServer(ldapPort));
|
||||||
}
|
}
|
||||||
|
|
||||||
BundleMessage.BundleMessageList messages = new BundleMessage.BundleMessageList();
|
BundleMessage.BundleMessageList messages = new BundleMessage.BundleMessageList();
|
||||||
BundleMessage.BundleMessageList errorMessages = new BundleMessage.BundleMessageList();
|
BundleMessage.BundleMessageList errorMessages = new BundleMessage.BundleMessageList();
|
||||||
for (AbstractServer server : serverList) {
|
for (AbstractServer server : SERVER_LIST) {
|
||||||
try {
|
try {
|
||||||
server.bind();
|
server.bind();
|
||||||
server.start();
|
server.start();
|
||||||
@ -157,7 +157,7 @@ public class DavGateway {
|
|||||||
* Stop all listeners, shutdown connection pool and clear session cache.
|
* Stop all listeners, shutdown connection pool and clear session cache.
|
||||||
*/
|
*/
|
||||||
public static void stop() {
|
public static void stop() {
|
||||||
for (AbstractServer server : serverList) {
|
for (AbstractServer server : SERVER_LIST) {
|
||||||
server.close();
|
server.close();
|
||||||
try {
|
try {
|
||||||
server.join();
|
server.join();
|
||||||
|
@ -30,7 +30,7 @@ import org.apache.log4j.*;
|
|||||||
* DavMail settings are stored in the .davmail.properties file in current
|
* DavMail settings are stored in the .davmail.properties file in current
|
||||||
* user home directory or in the file specified on the command line.
|
* user home directory or in the file specified on the command line.
|
||||||
*/
|
*/
|
||||||
public class Settings {
|
public final class Settings {
|
||||||
private Settings() {
|
private Settings() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,6 +40,7 @@ public class Settings {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set config file path (from command line parameter).
|
* Set config file path (from command line parameter).
|
||||||
|
*
|
||||||
* @param path davmail properties file path
|
* @param path davmail properties file path
|
||||||
*/
|
*/
|
||||||
public static synchronized void setConfigFilePath(String path) {
|
public static synchronized void setConfigFilePath(String path) {
|
||||||
@ -48,6 +49,7 @@ public class Settings {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Detect first launch (properties file does not exist).
|
* Detect first launch (properties file does not exist).
|
||||||
|
*
|
||||||
* @return true if this is the first start with the current file path
|
* @return true if this is the first start with the current file path
|
||||||
*/
|
*/
|
||||||
public static synchronized boolean isFirstStart() {
|
public static synchronized boolean isFirstStart() {
|
||||||
@ -56,6 +58,7 @@ public class Settings {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Load properties from provided stream (used in webapp mode).
|
* Load properties from provided stream (used in webapp mode).
|
||||||
|
*
|
||||||
* @param inputStream properties stream
|
* @param inputStream properties stream
|
||||||
* @throws IOException on error
|
* @throws IOException on error
|
||||||
*/
|
*/
|
||||||
@ -130,6 +133,7 @@ public class Settings {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return DavMail log file path
|
* Return DavMail log file path
|
||||||
|
*
|
||||||
* @return full log file path
|
* @return full log file path
|
||||||
*/
|
*/
|
||||||
public static String getLogFilePath() {
|
public static String getLogFilePath() {
|
||||||
@ -144,6 +148,7 @@ public class Settings {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return DavMail log file directory
|
* Return DavMail log file directory
|
||||||
|
*
|
||||||
* @return full log file directory
|
* @return full log file directory
|
||||||
*/
|
*/
|
||||||
public static String getLogFileDirectory() {
|
public static String getLogFileDirectory() {
|
||||||
@ -165,7 +170,7 @@ public class Settings {
|
|||||||
/**
|
/**
|
||||||
* Update Log4J config from settings.
|
* Update Log4J config from settings.
|
||||||
*/
|
*/
|
||||||
protected static void updateLoggingConfig() {
|
private static void updateLoggingConfig() {
|
||||||
String logFilePath = getLogFilePath();
|
String logFilePath = getLogFilePath();
|
||||||
|
|
||||||
Logger rootLogger = Logger.getRootLogger();
|
Logger rootLogger = Logger.getRootLogger();
|
||||||
@ -229,6 +234,7 @@ public class Settings {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a property value as String.
|
* Get a property value as String.
|
||||||
|
*
|
||||||
* @param property property name
|
* @param property property name
|
||||||
* @return property value
|
* @return property value
|
||||||
*/
|
*/
|
||||||
@ -238,6 +244,7 @@ public class Settings {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a property value.
|
* Set a property value.
|
||||||
|
*
|
||||||
* @param property property name
|
* @param property property name
|
||||||
* @param value property value
|
* @param value property value
|
||||||
*/
|
*/
|
||||||
@ -251,6 +258,7 @@ public class Settings {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a property value as int.
|
* Get a property value as int.
|
||||||
|
*
|
||||||
* @param property property name
|
* @param property property name
|
||||||
* @return property value
|
* @return property value
|
||||||
*/
|
*/
|
||||||
@ -260,6 +268,7 @@ public class Settings {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a property value as int, return default value if null.
|
* Get a property value as int, return default value if null.
|
||||||
|
*
|
||||||
* @param property property name
|
* @param property property name
|
||||||
* @param defaultValue default property value
|
* @param defaultValue default property value
|
||||||
* @return property value
|
* @return property value
|
||||||
@ -279,6 +288,7 @@ public class Settings {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a property value as boolean.
|
* Get a property value as boolean.
|
||||||
|
*
|
||||||
* @param property property name
|
* @param property property name
|
||||||
* @return property value
|
* @return property value
|
||||||
*/
|
*/
|
||||||
@ -289,10 +299,11 @@ public class Settings {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Build logging properties prefix.
|
* Build logging properties prefix.
|
||||||
|
*
|
||||||
* @param category logging category
|
* @param category logging category
|
||||||
* @return prefix
|
* @return prefix
|
||||||
*/
|
*/
|
||||||
protected static String getLoggingPrefix(String category) {
|
private static String getLoggingPrefix(String category) {
|
||||||
String prefix;
|
String prefix;
|
||||||
if ("rootLogger".equals(category)) {
|
if ("rootLogger".equals(category)) {
|
||||||
prefix = "log4j.";
|
prefix = "log4j.";
|
||||||
@ -304,6 +315,7 @@ public class Settings {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return Log4J logging level for the category.
|
* Return Log4J logging level for the category.
|
||||||
|
*
|
||||||
* @param category logging category
|
* @param category logging category
|
||||||
* @return logging level
|
* @return logging level
|
||||||
*/
|
*/
|
||||||
@ -322,6 +334,7 @@ public class Settings {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Log4J logging level for the category
|
* Set Log4J logging level for the category
|
||||||
|
*
|
||||||
* @param category logging category
|
* @param category logging category
|
||||||
* @param level logging level
|
* @param level logging level
|
||||||
*/
|
*/
|
||||||
@ -337,6 +350,7 @@ public class Settings {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Change and save a single property.
|
* Change and save a single property.
|
||||||
|
*
|
||||||
* @param property property name
|
* @param property property name
|
||||||
* @param value property value
|
* @param value property value
|
||||||
*/
|
*/
|
||||||
|
@ -521,7 +521,7 @@ public class CaldavConnection extends AbstractConnection {
|
|||||||
List<ExchangeSession.Event> events = session.getAllEvents(folderPath);
|
List<ExchangeSession.Event> events = session.getAllEvents(folderPath);
|
||||||
DavGatewayTray.debug(new BundleMessage("LOG_FOUND_CALENDAR_EVENTS", events.size()));
|
DavGatewayTray.debug(new BundleMessage("LOG_FOUND_CALENDAR_EVENTS", events.size()));
|
||||||
appendEventsResponses(response, request, events);
|
appendEventsResponses(response, request, events);
|
||||||
// TODO: does not work with iCal3
|
// TODO does not work with iCal3
|
||||||
/*
|
/*
|
||||||
List<ExchangeSession.Folder> folderList = session.getSubCalendarFolders(folderPath, false);
|
List<ExchangeSession.Folder> folderList = session.getSubCalendarFolders(folderPath, false);
|
||||||
for (ExchangeSession.Folder folder : folderList) {
|
for (ExchangeSession.Folder folder : folderList) {
|
||||||
@ -581,10 +581,9 @@ public class CaldavConnection extends AbstractConnection {
|
|||||||
DavGatewayTray.switchIcon();
|
DavGatewayTray.switchIcon();
|
||||||
try {
|
try {
|
||||||
String eventName = getEventFileNameFromPath(href);
|
String eventName = getEventFileNameFromPath(href);
|
||||||
if (eventName == null || eventName.length() == 0
|
// ignore cases for Sunbird
|
||||||
|| "inbox".equals(eventName) || "calendar".equals(eventName)) {
|
if (eventName != null && eventName.length() > 0
|
||||||
// Sunbird: just ignore
|
&& !"inbox".equals(eventName) && !"calendar".equals(eventName)) {
|
||||||
} else {
|
|
||||||
appendEventResponse(response, request, session.getEvent(folderPath, eventName));
|
appendEventResponse(response, request, session.getEvent(folderPath, eventName));
|
||||||
}
|
}
|
||||||
} catch (HttpException e) {
|
} catch (HttpException e) {
|
||||||
|
@ -375,31 +375,31 @@ public class ExchangeSession {
|
|||||||
for (Object content : contents) {
|
for (Object content : contents) {
|
||||||
if (content instanceof CommentToken) {
|
if (content instanceof CommentToken) {
|
||||||
String scriptValue = ((CommentToken) content).getCommentedContent();
|
String scriptValue = ((CommentToken) content).getCommentedContent();
|
||||||
int a_sUrlIndex = scriptValue.indexOf("var a_sUrl = \"");
|
int sUrlIndex = scriptValue.indexOf("var a_sUrl = \"");
|
||||||
int a_sLgnIndex = scriptValue.indexOf("var a_sLgn = \"");
|
int sLgnIndex = scriptValue.indexOf("var a_sLgn = \"");
|
||||||
if (a_sUrlIndex >= 0 && a_sLgnIndex >= 0) {
|
if (sUrlIndex >= 0 && sLgnIndex >= 0) {
|
||||||
a_sUrlIndex += "var a_sUrl = \"".length();
|
sUrlIndex += "var a_sUrl = \"".length();
|
||||||
a_sLgnIndex += "var a_sLgn = \"".length();
|
sLgnIndex += "var a_sLgn = \"".length();
|
||||||
int a_sUrlEndIndex = scriptValue.indexOf('\"', a_sUrlIndex);
|
int sUrlEndIndex = scriptValue.indexOf('\"', sUrlIndex);
|
||||||
int a_sLgnEndIndex = scriptValue.indexOf('\"', a_sLgnIndex);
|
int sLgnEndIndex = scriptValue.indexOf('\"', sLgnIndex);
|
||||||
if (a_sUrlEndIndex >= 0 && a_sLgnEndIndex >= 0) {
|
if (sUrlEndIndex >= 0 && sLgnEndIndex >= 0) {
|
||||||
String pathQuery = scriptValue.substring(a_sLgnIndex, a_sLgnEndIndex) +
|
String pathQuery = scriptValue.substring(sLgnIndex, sLgnEndIndex) +
|
||||||
scriptValue.substring(a_sUrlIndex, a_sUrlEndIndex);
|
scriptValue.substring(sUrlIndex, sUrlEndIndex);
|
||||||
String src = getScriptBasedFormURL(initmethod, pathQuery);
|
String src = getScriptBasedFormURL(initmethod, pathQuery);
|
||||||
LOGGER.debug("Detected script based logon, redirect to form at " + src);
|
LOGGER.debug("Detected script based logon, redirect to form at " + src);
|
||||||
HttpMethod newInitMethod = DavGatewayHttpClientFacade.executeFollowRedirects(httpClient, src);
|
HttpMethod newInitMethod = DavGatewayHttpClientFacade.executeFollowRedirects(httpClient, src);
|
||||||
logonMethod = buildLogonMethod(httpClient, newInitMethod);
|
logonMethod = buildLogonMethod(httpClient, newInitMethod);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
a_sLgnIndex = scriptValue.indexOf("var a_sLgnQS = \"");
|
sLgnIndex = scriptValue.indexOf("var a_sLgnQS = \"");
|
||||||
if (a_sUrlIndex >= 0 && a_sLgnIndex >= 0) {
|
if (sUrlIndex >= 0 && sLgnIndex >= 0) {
|
||||||
a_sUrlIndex += "var a_sUrl = \"".length();
|
sUrlIndex += "var a_sUrl = \"".length();
|
||||||
a_sLgnIndex += "var a_sLgnQS = \"".length();
|
sLgnIndex += "var a_sLgnQS = \"".length();
|
||||||
int a_sUrlEndIndex = scriptValue.indexOf('\"', a_sUrlIndex);
|
int sUrlEndIndex = scriptValue.indexOf('\"', sUrlIndex);
|
||||||
int a_sLgnEndIndex = scriptValue.indexOf('\"', a_sLgnIndex);
|
int sLgnEndIndex = scriptValue.indexOf('\"', sLgnIndex);
|
||||||
if (a_sUrlEndIndex >= 0 && a_sLgnEndIndex >= 0) {
|
if (sUrlEndIndex >= 0 && sLgnEndIndex >= 0) {
|
||||||
String pathQuery = scriptValue.substring(a_sLgnIndex, a_sLgnEndIndex) +
|
String pathQuery = scriptValue.substring(sLgnIndex, sLgnEndIndex) +
|
||||||
scriptValue.substring(a_sUrlIndex, a_sUrlEndIndex);
|
scriptValue.substring(sUrlIndex, sUrlEndIndex);
|
||||||
String src = getScriptBasedFormURL(initmethod, pathQuery);
|
String src = getScriptBasedFormURL(initmethod, pathQuery);
|
||||||
LOGGER.debug("Detected script based logon, redirect to form at " + src);
|
LOGGER.debug("Detected script based logon, redirect to form at " + src);
|
||||||
HttpMethod newInitMethod = DavGatewayHttpClientFacade.executeFollowRedirects(httpClient, src);
|
HttpMethod newInitMethod = DavGatewayHttpClientFacade.executeFollowRedirects(httpClient, src);
|
||||||
@ -460,9 +460,10 @@ public class ExchangeSession {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static final String BASE_HREF = "<base href=\"";
|
||||||
|
|
||||||
protected void buildMailPath(HttpMethod method) throws DavMailAuthenticationException {
|
protected void buildMailPath(HttpMethod method) throws DavMailAuthenticationException {
|
||||||
// find base url
|
// find base url
|
||||||
final String BASE_HREF = "<base href=\"";
|
|
||||||
String line;
|
String line;
|
||||||
|
|
||||||
// get user mail URL from html body (multi frame)
|
// get user mail URL from html body (multi frame)
|
||||||
@ -2569,6 +2570,8 @@ public class ExchangeSession {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static final String MAILBOX_BASE = "cn=recipients/cn=";
|
||||||
|
|
||||||
protected String getAliasFromOptions(String path) {
|
protected String getAliasFromOptions(String path) {
|
||||||
String result = null;
|
String result = null;
|
||||||
// get user mail URL from html body
|
// get user mail URL from html body
|
||||||
@ -2579,7 +2582,6 @@ public class ExchangeSession {
|
|||||||
optionsPageReader = new BufferedReader(new InputStreamReader(optionsMethod.getResponseBodyAsStream()));
|
optionsPageReader = new BufferedReader(new InputStreamReader(optionsMethod.getResponseBodyAsStream()));
|
||||||
String line;
|
String line;
|
||||||
// find mailbox full name
|
// find mailbox full name
|
||||||
final String MAILBOX_BASE = "cn=recipients/cn=";
|
|
||||||
//noinspection StatementWithEmptyBody
|
//noinspection StatementWithEmptyBody
|
||||||
while ((line = optionsPageReader.readLine()) != null && line.toLowerCase().indexOf(MAILBOX_BASE) == -1) {
|
while ((line = optionsPageReader.readLine()) != null && line.toLowerCase().indexOf(MAILBOX_BASE) == -1) {
|
||||||
}
|
}
|
||||||
|
@ -39,14 +39,14 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
public final class ExchangeSessionFactory {
|
public final class ExchangeSessionFactory {
|
||||||
private static final Object LOCK = new Object();
|
private static final Object LOCK = new Object();
|
||||||
private static final Map<PoolKey, ExchangeSession> poolMap = new HashMap<PoolKey, ExchangeSession>();
|
private static final Map<PoolKey, ExchangeSession> POOL_MAP = new HashMap<PoolKey, ExchangeSession>();
|
||||||
private static boolean configChecked;
|
private static boolean configChecked;
|
||||||
private static boolean errorSent;
|
private static boolean errorSent;
|
||||||
|
|
||||||
static class PoolKey {
|
static class PoolKey {
|
||||||
public final String url;
|
final String url;
|
||||||
public final String userName;
|
final String userName;
|
||||||
public final String password;
|
final String password;
|
||||||
|
|
||||||
PoolKey(String url, String userName, String password) {
|
PoolKey(String url, String userName, String password) {
|
||||||
this.url = url;
|
this.url = url;
|
||||||
@ -87,7 +87,7 @@ public final class ExchangeSessionFactory {
|
|||||||
PoolKey poolKey = new PoolKey(baseUrl, userName, password);
|
PoolKey poolKey = new PoolKey(baseUrl, userName, password);
|
||||||
|
|
||||||
synchronized (LOCK) {
|
synchronized (LOCK) {
|
||||||
session = poolMap.get(poolKey);
|
session = POOL_MAP.get(poolKey);
|
||||||
}
|
}
|
||||||
if (session != null) {
|
if (session != null) {
|
||||||
ExchangeSession.LOGGER.debug("Got session " + session + " from cache");
|
ExchangeSession.LOGGER.debug("Got session " + session + " from cache");
|
||||||
@ -98,7 +98,7 @@ public final class ExchangeSessionFactory {
|
|||||||
session = null;
|
session = null;
|
||||||
// expired session, remove from cache
|
// expired session, remove from cache
|
||||||
synchronized (LOCK) {
|
synchronized (LOCK) {
|
||||||
poolMap.remove(poolKey);
|
POOL_MAP.remove(poolKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,7 +108,7 @@ public final class ExchangeSessionFactory {
|
|||||||
}
|
}
|
||||||
// successfull login, put session in cache
|
// successfull login, put session in cache
|
||||||
synchronized (LOCK) {
|
synchronized (LOCK) {
|
||||||
poolMap.put(poolKey, session);
|
POOL_MAP.put(poolKey, session);
|
||||||
}
|
}
|
||||||
// session opened, future failure will mean network down
|
// session opened, future failure will mean network down
|
||||||
configChecked = true;
|
configChecked = true;
|
||||||
@ -204,6 +204,6 @@ public final class ExchangeSessionFactory {
|
|||||||
public static void reset() {
|
public static void reset() {
|
||||||
configChecked = false;
|
configChecked = false;
|
||||||
errorSent = false;
|
errorSent = false;
|
||||||
poolMap.clear();
|
POOL_MAP.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ public class ICSBufferedWriter {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Write line to buffer, split lines at 75 characters.
|
* Write line to buffer, split lines at 75 characters.
|
||||||
|
*
|
||||||
* @param line ics event line
|
* @param line ics event line
|
||||||
*/
|
*/
|
||||||
public void writeLine(String line) {
|
public void writeLine(String line) {
|
||||||
@ -47,6 +48,7 @@ public class ICSBufferedWriter {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get buffer as String
|
* Get buffer as String
|
||||||
|
*
|
||||||
* @return ICS content as String
|
* @return ICS content as String
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@ -281,21 +281,21 @@ public class ImapConnection extends AbstractConnection {
|
|||||||
sendClient(commandId + " OK SEARCH completed");
|
sendClient(commandId + " OK SEARCH completed");
|
||||||
|
|
||||||
} else if ("store".equalsIgnoreCase(subcommand)) {
|
} else if ("store".equalsIgnoreCase(subcommand)) {
|
||||||
UIDRangeIterator UIDRangeIterator = new UIDRangeIterator(tokens.nextToken());
|
UIDRangeIterator uidRangeIterator = new UIDRangeIterator(tokens.nextToken());
|
||||||
String action = tokens.nextToken();
|
String action = tokens.nextToken();
|
||||||
String flags = tokens.nextToken();
|
String flags = tokens.nextToken();
|
||||||
while (UIDRangeIterator.hasNext()) {
|
while (uidRangeIterator.hasNext()) {
|
||||||
ExchangeSession.Message message = UIDRangeIterator.next();
|
ExchangeSession.Message message = uidRangeIterator.next();
|
||||||
updateFlags(message, action, flags);
|
updateFlags(message, action, flags);
|
||||||
sendClient("* " + (UIDRangeIterator.currentIndex) + " FETCH (UID " + message.getImapUid() + " FLAGS (" + (message.getImapFlags()) + "))");
|
sendClient("* " + (uidRangeIterator.currentIndex) + " FETCH (UID " + message.getImapUid() + " FLAGS (" + (message.getImapFlags()) + "))");
|
||||||
}
|
}
|
||||||
sendClient(commandId + " OK STORE completed");
|
sendClient(commandId + " OK STORE completed");
|
||||||
} else if ("copy".equalsIgnoreCase(subcommand)) {
|
} else if ("copy".equalsIgnoreCase(subcommand)) {
|
||||||
try {
|
try {
|
||||||
UIDRangeIterator UIDRangeIterator = new UIDRangeIterator(tokens.nextToken());
|
UIDRangeIterator uidRangeIterator = new UIDRangeIterator(tokens.nextToken());
|
||||||
String targetName = BASE64MailboxDecoder.decode(tokens.nextToken());
|
String targetName = BASE64MailboxDecoder.decode(tokens.nextToken());
|
||||||
while (UIDRangeIterator.hasNext()) {
|
while (uidRangeIterator.hasNext()) {
|
||||||
ExchangeSession.Message message = UIDRangeIterator.next();
|
ExchangeSession.Message message = uidRangeIterator.next();
|
||||||
session.copyMessage(message, targetName);
|
session.copyMessage(message, targetName);
|
||||||
}
|
}
|
||||||
sendClient(commandId + " OK copy completed");
|
sendClient(commandId + " OK copy completed");
|
||||||
@ -947,18 +947,18 @@ public class ImapConnection extends AbstractConnection {
|
|||||||
/**
|
/**
|
||||||
* Filter to output only headers, also count full size
|
* Filter to output only headers, also count full size
|
||||||
*/
|
*/
|
||||||
private static class PartOutputStream extends FilterOutputStream {
|
private static final class PartOutputStream extends FilterOutputStream {
|
||||||
protected static final int START = 0;
|
private static final int START = 0;
|
||||||
protected static final int CR = 1;
|
private static final int CR = 1;
|
||||||
protected static final int CRLF = 2;
|
private static final int CRLF = 2;
|
||||||
protected static final int CRLFCR = 3;
|
private static final int CRLFCR = 3;
|
||||||
protected static final int BODY = 4;
|
private static final int BODY = 4;
|
||||||
|
|
||||||
protected int state = START;
|
private int state = START;
|
||||||
protected int size;
|
private int size;
|
||||||
protected final boolean writeHeaders;
|
private final boolean writeHeaders;
|
||||||
protected final boolean writeBody;
|
private final boolean writeBody;
|
||||||
protected final int startIndex;
|
private final int startIndex;
|
||||||
|
|
||||||
private PartOutputStream(OutputStream os, boolean writeHeaders, boolean writeBody,
|
private PartOutputStream(OutputStream os, boolean writeHeaders, boolean writeBody,
|
||||||
int startIndex) {
|
int startIndex) {
|
||||||
|
@ -308,12 +308,12 @@ public class LdapConnection extends AbstractConnection {
|
|||||||
/**
|
/**
|
||||||
* For some unknow reaseon parseIntWithTag is private !
|
* For some unknow reaseon parseIntWithTag is private !
|
||||||
*/
|
*/
|
||||||
static final Method parseIntWithTag;
|
static final Method PARSE_INT_WITH_TAG_METHOD;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
try {
|
try {
|
||||||
parseIntWithTag = BerDecoder.class.getDeclaredMethod("parseIntWithTag", int.class);
|
PARSE_INT_WITH_TAG_METHOD = BerDecoder.class.getDeclaredMethod("parseIntWithTag", int.class);
|
||||||
parseIntWithTag.setAccessible(true);
|
PARSE_INT_WITH_TAG_METHOD.setAccessible(true);
|
||||||
} catch (NoSuchMethodException e) {
|
} catch (NoSuchMethodException e) {
|
||||||
DavGatewayTray.error(new BundleMessage("LOG_UNABLE_TO_GET_PARSEINTWITHTAG"));
|
DavGatewayTray.error(new BundleMessage("LOG_UNABLE_TO_GET_PARSEINTWITHTAG"));
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
@ -626,7 +626,7 @@ public class LdapConnection extends AbstractConnection {
|
|||||||
} else if (requestOperation == LDAP_REQ_ABANDON) {
|
} else if (requestOperation == LDAP_REQ_ABANDON) {
|
||||||
int canceledMessageId = 0;
|
int canceledMessageId = 0;
|
||||||
try {
|
try {
|
||||||
canceledMessageId = (Integer) parseIntWithTag.invoke(reqBer, LDAP_REQ_ABANDON);
|
canceledMessageId = (Integer) PARSE_INT_WITH_TAG_METHOD.invoke(reqBer, LDAP_REQ_ABANDON);
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
DavGatewayTray.error(e);
|
DavGatewayTray.error(e);
|
||||||
} catch (InvocationTargetException e) {
|
} catch (InvocationTargetException e) {
|
||||||
|
@ -290,15 +290,15 @@ public class PopConnection extends AbstractConnection {
|
|||||||
/**
|
/**
|
||||||
* Filter to limit output lines to max body lines after header
|
* Filter to limit output lines to max body lines after header
|
||||||
*/
|
*/
|
||||||
private static class TopOutputStream extends FilterOutputStream {
|
private static final class TopOutputStream extends FilterOutputStream {
|
||||||
protected static final int START = 0;
|
private static final int START = 0;
|
||||||
protected static final int CR = 1;
|
private static final int CR = 1;
|
||||||
protected static final int CRLF = 2;
|
private static final int CRLF = 2;
|
||||||
protected static final int CRLFCR = 3;
|
private static final int CRLFCR = 3;
|
||||||
protected static final int BODY = 4;
|
private static final int BODY = 4;
|
||||||
|
|
||||||
protected int maxLines;
|
private int maxLines;
|
||||||
protected int state = START;
|
private int state = START;
|
||||||
|
|
||||||
private TopOutputStream(OutputStream os, int maxLines) {
|
private TopOutputStream(OutputStream os, int maxLines) {
|
||||||
super(os);
|
super(os);
|
||||||
|
@ -24,7 +24,7 @@ import java.net.URI;
|
|||||||
/**
|
/**
|
||||||
* Failover: Runtime.exec open URL
|
* Failover: Runtime.exec open URL
|
||||||
*/
|
*/
|
||||||
public class OSXDesktopBrowser {
|
public final class OSXDesktopBrowser {
|
||||||
private OSXDesktopBrowser() {
|
private OSXDesktopBrowser() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ import java.net.URL;
|
|||||||
/**
|
/**
|
||||||
* Tray icon handler
|
* Tray icon handler
|
||||||
*/
|
*/
|
||||||
public class DavGatewayTray {
|
public final class DavGatewayTray {
|
||||||
protected static final Logger LOGGER = Logger.getLogger("davmail");
|
protected static final Logger LOGGER = Logger.getLogger("davmail");
|
||||||
|
|
||||||
private DavGatewayTray() {
|
private DavGatewayTray() {
|
||||||
|
Loading…
Reference in New Issue
Block a user