diff --git a/src/java/davmail/DavGateway.java b/src/java/davmail/DavGateway.java index 6154f793..86981e05 100644 --- a/src/java/davmail/DavGateway.java +++ b/src/java/davmail/DavGateway.java @@ -154,7 +154,7 @@ public final class DavGateway { @Override public void run() { String releasedVersion = getReleasedVersion(); - if (currentVersion != null && releasedVersion != null && currentVersion.compareTo(releasedVersion) < 0) { + if (currentVersion != null && currentVersion.length() > 0 && releasedVersion != null && currentVersion.compareTo(releasedVersion) < 0) { DavGatewayTray.info(new BundleMessage("LOG_NEW_VERSION_AVAILABLE", releasedVersion)); } @@ -187,13 +187,13 @@ public final class DavGateway { private static void stopServers() { for (AbstractServer server : SERVER_LIST) { - server.close(); - try { - server.join(); - } catch (InterruptedException e) { - DavGatewayTray.warn(new BundleMessage("LOG_EXCEPTION_WAITING_SERVER_THREAD_DIE"), e); - } - } + server.close(); + try { + server.join(); + } catch (InterruptedException e) { + DavGatewayTray.warn(new BundleMessage("LOG_EXCEPTION_WAITING_SERVER_THREAD_DIE"), e); + } + } } /** @@ -203,7 +203,11 @@ public final class DavGateway { */ public static String getCurrentVersion() { Package davmailPackage = DavGateway.class.getPackage(); - return davmailPackage.getImplementationVersion(); + String currentVersion = davmailPackage.getImplementationVersion(); + if (currentVersion == null) { + currentVersion = ""; + } + return currentVersion; } /** diff --git a/src/java/davmail/caldav/CaldavConnection.java b/src/java/davmail/caldav/CaldavConnection.java index 0c636628..51a4a393 100644 --- a/src/java/davmail/caldav/CaldavConnection.java +++ b/src/java/davmail/caldav/CaldavConnection.java @@ -1158,8 +1158,7 @@ public class CaldavConnection extends AbstractConnection { public void sendHttpResponse(int status, Map headers, String contentType, byte[] content, boolean keepAlive) throws IOException { sendClient("HTTP/1.1 " + status + ' ' + HttpStatus.getStatusText(status)); if (status != HttpStatus.SC_UNAUTHORIZED) { - String version = DavGateway.getCurrentVersion(); - sendClient("Server: DavMail Gateway " + (version == null ? "" : version)); + sendClient("Server: DavMail Gateway " + DavGateway.getCurrentVersion()); sendClient("DAV: 1, calendar-access, calendar-schedule, calendarserver-private-events, addressbook"); SimpleDateFormat formatter = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z", Locale.ENGLISH); // force GMT timezone diff --git a/src/java/davmail/imap/ImapConnection.java b/src/java/davmail/imap/ImapConnection.java index 21e4887c..5c62a504 100644 --- a/src/java/davmail/imap/ImapConnection.java +++ b/src/java/davmail/imap/ImapConnection.java @@ -22,6 +22,7 @@ import com.sun.mail.imap.protocol.BASE64MailboxDecoder; import com.sun.mail.imap.protocol.BASE64MailboxEncoder; import davmail.AbstractConnection; import davmail.BundleMessage; +import davmail.DavGateway; import davmail.Settings; import davmail.exception.DavMailException; import davmail.exception.HttpForbiddenException; @@ -80,7 +81,7 @@ public class ImapConnection extends AbstractConnection { IMAPTokenizer tokens; try { ExchangeSessionFactory.checkConfig(); - sendClient("* OK [" + capabilities + "] IMAP4rev1 DavMail server ready"); + sendClient("* OK [" + capabilities + "] IMAP4rev1 DavMail " + DavGateway.getCurrentVersion() + "server ready"); for (; ;) { line = readClient(); // unable to read line, connection closed ? @@ -1016,9 +1017,9 @@ public class ImapConnection extends AbstractConnection { int charsetindex = contentType.indexOf("charset="); int nameindex = contentType.indexOf("name="); if (charsetindex >= 0 || nameindex >= 0) { - buffer.append(" ("); + buffer.append(" ("); - if (charsetindex >=0) { + if (charsetindex >= 0) { buffer.append("\"CHARSET\" "); int charsetSemiColonIndex = contentType.indexOf(';', charsetindex); int charsetEndIndex; @@ -1035,10 +1036,10 @@ public class ImapConnection extends AbstractConnection { if (!charSet.endsWith("\"")) { buffer.append('"'); } - } + } - if (nameindex >= 0) { - if (charsetindex >=0) { + if (nameindex >= 0) { + if (charsetindex >= 0) { buffer.append(' '); } @@ -1058,7 +1059,7 @@ public class ImapConnection extends AbstractConnection { if (!name.endsWith("\"")) { buffer.append('"'); } - } + } buffer.append(')'); } else { buffer.append(" NIL"); @@ -1700,7 +1701,7 @@ public class ImapConnection extends AbstractConnection { nextToken.append(' ').append(super.nextToken()); } while (hasMoreTokens() && nextToken.length() > 0 && nextToken.indexOf("[") != -1 - && nextToken.charAt(nextToken.length() - 1) != ']') { + && nextToken.charAt(nextToken.length() - 1) != ']') { nextToken.append(' ').append(super.nextToken()); } return nextToken.toString(); diff --git a/src/java/davmail/smtp/SmtpConnection.java b/src/java/davmail/smtp/SmtpConnection.java index fc5f00cf..3f7c4f36 100644 --- a/src/java/davmail/smtp/SmtpConnection.java +++ b/src/java/davmail/smtp/SmtpConnection.java @@ -20,6 +20,7 @@ package davmail.smtp; import davmail.AbstractConnection; import davmail.BundleMessage; +import davmail.DavGateway; import davmail.exception.DavMailException; import davmail.exchange.DoubleDotInputStream; import davmail.exchange.ExchangeSessionFactory; @@ -61,7 +62,7 @@ public class SmtpConnection extends AbstractConnection { try { ExchangeSessionFactory.checkConfig(); - sendClient("220 DavMail SMTP ready at " + new Date()); + sendClient("220 DavMail "+ DavGateway.getCurrentVersion()+" SMTP ready at " + new Date()); for (; ;) { line = readClient(); // unable to read line, connection closed ?