mirror of
https://github.com/moparisthebest/davmail
synced 2024-12-13 03:02:22 -05:00
Various code cleanup from audit
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@236 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
f3f28ac7c3
commit
4a4e515c9c
@ -150,7 +150,7 @@ public class AbstractConnection extends Thread {
|
||||
return new String(Base64.encode(value.getBytes()));
|
||||
}
|
||||
|
||||
protected String base64Decode(String value) throws IOException {
|
||||
protected String base64Decode(String value) {
|
||||
return new String(Base64.decode(value.getBytes()));
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ import java.net.Socket;
|
||||
* Generic abstract server common to SMTP and POP3 implementations
|
||||
*/
|
||||
public abstract class AbstractServer extends Thread {
|
||||
private int port;
|
||||
private final int port;
|
||||
private ServerSocket serverSocket;
|
||||
|
||||
/**
|
||||
|
@ -16,14 +16,14 @@ import java.util.*;
|
||||
/**
|
||||
* Create ExchangeSession instances.
|
||||
*/
|
||||
public class ExchangeSessionFactory {
|
||||
public final class ExchangeSessionFactory {
|
||||
private static final Object LOCK = new Object();
|
||||
private static final Map<PoolKey, ExchangeSessionStack> poolMap = new HashMap<PoolKey, ExchangeSessionStack>();
|
||||
|
||||
static class PoolKey {
|
||||
public String url;
|
||||
public String userName;
|
||||
public String password;
|
||||
public final String url;
|
||||
public final String userName;
|
||||
public final String password;
|
||||
|
||||
public PoolKey(String url, String userName, String password) {
|
||||
this.url = url;
|
||||
@ -177,8 +177,8 @@ public class ExchangeSessionFactory {
|
||||
ExchangeSession.LOGGER.error(message, exc);
|
||||
throw new IOException(message);
|
||||
} else {
|
||||
message += "All network interfaces down !";
|
||||
ExchangeSession.LOGGER.error(message, exc);
|
||||
message = "All network interfaces down !";
|
||||
ExchangeSession.LOGGER.error(message);
|
||||
throw new NetworkDownException(message);
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ package davmail.http;
|
||||
|
||||
import org.apache.commons.httpclient.protocol.SSLProtocolSocketFactory;
|
||||
import org.apache.commons.httpclient.protocol.Protocol;
|
||||
import org.apache.commons.httpclient.HttpsURL;
|
||||
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.TrustManager;
|
||||
@ -33,7 +34,7 @@ public class DavGatewaySSLProtocolSocketFactory extends SSLProtocolSocketFactory
|
||||
if ("https".equals(protocol)) {
|
||||
int port = url.getPort();
|
||||
if (port < 0) {
|
||||
port = 443;
|
||||
port = HttpsURL.DEFAULT_PORT;
|
||||
}
|
||||
Protocol.registerProtocol(url.getProtocol(),
|
||||
new Protocol(protocol, new DavGatewaySSLProtocolSocketFactory(), port));
|
||||
|
@ -260,7 +260,7 @@ public class PopConnection extends AbstractConnection {
|
||||
protected static final int BODY = 4;
|
||||
|
||||
protected int maxLines;
|
||||
protected int STATE = START;
|
||||
protected int state = START;
|
||||
|
||||
public TopOutputStream(OutputStream os, int maxLines) {
|
||||
super(os);
|
||||
@ -269,34 +269,34 @@ public class PopConnection extends AbstractConnection {
|
||||
|
||||
@Override
|
||||
public void write(int b) throws IOException {
|
||||
if (STATE != BODY || maxLines > 0) {
|
||||
if (state != BODY || maxLines > 0) {
|
||||
super.write(b);
|
||||
}
|
||||
if (STATE == BODY) {
|
||||
if (state == BODY) {
|
||||
if (b == '\n') {
|
||||
maxLines--;
|
||||
}
|
||||
} else if (STATE == START) {
|
||||
} else if (state == START) {
|
||||
if (b == '\r') {
|
||||
STATE = CR;
|
||||
state = CR;
|
||||
}
|
||||
} else if (STATE == CR) {
|
||||
} else if (state == CR) {
|
||||
if (b == '\n') {
|
||||
STATE = CRLF;
|
||||
state = CRLF;
|
||||
} else {
|
||||
STATE = START;
|
||||
state = START;
|
||||
}
|
||||
} else if (STATE == CRLF) {
|
||||
} else if (state == CRLF) {
|
||||
if (b == '\r') {
|
||||
STATE = CRLFCR;
|
||||
state = CRLFCR;
|
||||
} else {
|
||||
STATE = START;
|
||||
state = START;
|
||||
}
|
||||
} else if (STATE == CRLFCR) {
|
||||
} else if (state == CRLFCR) {
|
||||
if (b == '\n') {
|
||||
STATE = BODY;
|
||||
state = BODY;
|
||||
} else {
|
||||
STATE = START;
|
||||
state = START;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ public class PopServer extends AbstractServer {
|
||||
* Create a ServerSocket to listen for connections.
|
||||
* Start the thread.
|
||||
* @param port pop listen port, 110 if not defined (0)
|
||||
* @throws java.io.IOException on error
|
||||
*/
|
||||
public PopServer(int port) throws IOException {
|
||||
super("PopServer", port, PopServer.DEFAULT_PORT);
|
||||
|
@ -33,6 +33,8 @@ public class SwtGatewayTray implements DavGatewayTrayInterface {
|
||||
private boolean isActive = true;
|
||||
private boolean isReady = false;
|
||||
|
||||
private final Thread mainThread = Thread.currentThread();
|
||||
|
||||
public java.awt.Image getFrameIcon() {
|
||||
return awtImage;
|
||||
}
|
||||
@ -84,15 +86,14 @@ public class SwtGatewayTray implements DavGatewayTrayInterface {
|
||||
} else if (priority == Priority.ERROR) {
|
||||
messageType = SWT.ICON_ERROR;
|
||||
}
|
||||
if (messageType == 0) {
|
||||
trayItem.setToolTipText("DavMail gateway \n" + message);
|
||||
} else {
|
||||
if (messageType != 0) {
|
||||
final ToolTip toolTip = new ToolTip(shell, SWT.BALLOON | messageType);
|
||||
toolTip.setText("DavMail gateway");
|
||||
toolTip.setMessage(message);
|
||||
trayItem.setToolTip(toolTip);
|
||||
toolTip.setVisible(true);
|
||||
}
|
||||
trayItem.setToolTipText("DavMail gateway \n" + message);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -129,8 +130,6 @@ public class SwtGatewayTray implements DavGatewayTrayInterface {
|
||||
DavGatewayTray.warn("Unable to set look and feel");
|
||||
}
|
||||
|
||||
final Thread mainThread = Thread.currentThread();
|
||||
|
||||
new Thread("SWT") {
|
||||
public void run() {
|
||||
display = new Display();
|
||||
|
@ -20,7 +20,7 @@ import java.net.URISyntaxException;
|
||||
* About frame
|
||||
*/
|
||||
public class AboutFrame extends JFrame {
|
||||
protected JEditorPane jEditorPane;
|
||||
private final JEditorPane jEditorPane;
|
||||
|
||||
public AboutFrame() {
|
||||
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
@ -86,7 +86,7 @@ public class AboutFrame extends JFrame {
|
||||
getSize().height / 2);
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
String getContent() {
|
||||
Package davmailPackage = DavGateway.class.getPackage();
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
buffer.append("<html><b>DavMail Gateway</b><br>");
|
||||
|
@ -7,7 +7,9 @@ import java.awt.*;
|
||||
/**
|
||||
* Wrapper class to call Java6 Desktop class to launch default browser.
|
||||
*/
|
||||
public class AwtDesktopBrowser {
|
||||
public final class AwtDesktopBrowser {
|
||||
private AwtDesktopBrowser() {
|
||||
}
|
||||
|
||||
public static void browse(URI location) throws IOException {
|
||||
Desktop desktop = Desktop.getDesktop();
|
||||
|
@ -9,7 +9,10 @@ import java.net.URISyntaxException;
|
||||
/**
|
||||
* Open default browser.
|
||||
*/
|
||||
public class DesktopBrowser {
|
||||
public final class DesktopBrowser {
|
||||
private DesktopBrowser() {
|
||||
}
|
||||
|
||||
public static void browse(URI location) {
|
||||
try {
|
||||
// trigger ClassNotFoundException
|
||||
|
@ -8,11 +8,11 @@ import java.net.URI;
|
||||
/**
|
||||
* Wrapper class to call SWT Program class to launch default browser.
|
||||
*/
|
||||
public class SwtDesktopBrowser {
|
||||
public final class SwtDesktopBrowser {
|
||||
private SwtDesktopBrowser() {
|
||||
}
|
||||
|
||||
public static void browse(URI location) throws IOException {
|
||||
public static void browse(URI location) {
|
||||
Program.launch(location.toString());
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,6 @@
|
||||
<item name="Home" href="/index.html"/>
|
||||
<item name="Download" href="http://sourceforge.net/project/platformdownload.php?group_id=184600"/>
|
||||
<item name="SourceForge site" href="http://sourceforge.net/projects/davmail"/>
|
||||
|
||||
</menu>
|
||||
|
||||
<menu name="DavMail Setup">
|
||||
|
Loading…
Reference in New Issue
Block a user