1
0
mirror of https://github.com/moparisthebest/davmail synced 2025-03-03 18:59:53 -05:00

Reformat and fixes from audit

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1702 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2011-06-08 19:58:29 +00:00
parent 551c608812
commit f89511775d
57 changed files with 277 additions and 92 deletions

View File

@ -36,7 +36,7 @@ import java.security.KeyStore;
* Generic abstract server common to SMTP and POP3 implementations * Generic abstract server common to SMTP and POP3 implementations
*/ */
public abstract class AbstractServer extends Thread { public abstract class AbstractServer extends Thread {
protected boolean nosslFlag; // will cause same behavior as before with unchanged config files protected boolean nosslFlag; // will cause same behavior as before with unchanged config files
private final int port; private final int port;
private ServerSocket serverSocket; private ServerSocket serverSocket;

View File

@ -20,11 +20,11 @@ package davmail;
import davmail.exception.DavMailException; import davmail.exception.DavMailException;
import java.io.Serializable;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Locale; import java.util.Locale;
import java.util.ResourceBundle; import java.util.ResourceBundle;
import java.io.Serializable;
/** /**
* Internationalization message. * Internationalization message.

View File

@ -154,7 +154,7 @@ public final class DavGateway {
@Override @Override
public void run() { public void run() {
String releasedVersion = getReleasedVersion(); String releasedVersion = getReleasedVersion();
if (currentVersion != null && currentVersion.length() > 0 && 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)); DavGatewayTray.info(new BundleMessage("LOG_NEW_VERSION_AVAILABLE", releasedVersion));
} }

View File

@ -41,7 +41,7 @@ public class CaldavServer extends AbstractServer {
*/ */
public CaldavServer(int port) { public CaldavServer(int port) {
super(CaldavServer.class.getName(), port, CaldavServer.DEFAULT_PORT); super(CaldavServer.class.getName(), port, CaldavServer.DEFAULT_PORT);
nosslFlag = Settings.getBooleanProperty("davmail.ssl.nosecurecaldav"); nosslFlag = Settings.getBooleanProperty("davmail.ssl.nosecurecaldav");
} }
@Override @Override

View File

@ -34,11 +34,11 @@ public class DavMailAuthenticationException extends DavMailException {
/** /**
* Create a DavMail authentication exception with the given BundleMessage key and arguments. * Create a DavMail authentication exception with the given BundleMessage key and arguments.
* *
* @param key message key * @param key message key
* @param arguments message values * @param arguments message values
*/ */
public DavMailAuthenticationException(String key, Object... arguments) { public DavMailAuthenticationException(String key, Object... arguments) {
super(key, arguments); super(key, arguments);
} }
} }

View File

@ -77,7 +77,7 @@ public class DoubleDotInputStream extends PushbackInputStream {
} }
// push back characters // push back characters
if (index >= 0) { if (index >= 0) {
while(index >= 0) { while (index >= 0) {
unread(buffer[index--]); unread(buffer[index--]);
} }
} }

View File

@ -31,7 +31,7 @@ import java.io.OutputStream;
public class DoubleDotOutputStream extends FilterOutputStream { public class DoubleDotOutputStream extends FilterOutputStream {
// remember last 2 bytes written // remember last 2 bytes written
int[] buf = {0, 0}; final int[] buf = {0, 0};
/** /**
* @inheritDoc * @inheritDoc

View File

@ -658,7 +658,7 @@ public abstract class ExchangeSession {
public abstract void deleteMessage(Message message) throws IOException; public abstract void deleteMessage(Message message) throws IOException;
/** /**
* Send message to recipients, properties contains bcc recipients and other non MIME flags. * Send message.
* *
* @param messageBody MIME message body * @param messageBody MIME message body
* @throws IOException on error * @throws IOException on error
@ -1435,7 +1435,7 @@ public abstract class ExchangeSession {
messages = ExchangeSession.this.searchMessages(folderPath, null); messages = ExchangeSession.this.searchMessages(folderPath, null);
fixUids(messages); fixUids(messages);
recent = 0; recent = 0;
for (Message message:messages) { for (Message message : messages) {
if (message.recent) { if (message.recent) {
recent++; recent++;
} }
@ -1674,7 +1674,7 @@ public abstract class ExchangeSession {
buffer.append("\\Deleted "); buffer.append("\\Deleted ");
} }
if (recent) { if (recent) {
buffer.append("\\Recent "); buffer.append("\\Recent ");
} }
if (flagged) { if (flagged) {
buffer.append("\\Flagged "); buffer.append("\\Flagged ");
@ -2596,7 +2596,7 @@ public abstract class ExchangeSession {
LOGGER.debug("Shared or public calendar: exclude private events"); LOGGER.debug("Shared or public calendar: exclude private events");
privateCondition = isEqualTo("sensitivity", 0); privateCondition = isEqualTo("sensitivity", 0);
} }
return searchEvents(folderPath, ITEM_PROPERTIES, return searchEvents(folderPath, ITEM_PROPERTIES,
and(filter, privateCondition)); and(filter, privateCondition));
} }
@ -3135,7 +3135,7 @@ public abstract class ExchangeSession {
if (attendee == null || attendee.indexOf('@') < 0 || attendee.charAt(attendee.length() - 1) == '@') { if (attendee == null || attendee.indexOf('@') < 0 || attendee.charAt(attendee.length() - 1) == '@') {
return null; return null;
} }
attendee = replaceIcal4Principal(attendee); attendee = replaceIcal4Principal(attendee);
if (attendee.startsWith("mailto:") || attendee.startsWith("MAILTO:")) { if (attendee.startsWith("mailto:") || attendee.startsWith("MAILTO:")) {
attendee = attendee.substring("mailto:".length()); attendee = attendee.substring("mailto:".length());

View File

@ -95,6 +95,15 @@ public final class ExchangeSessionFactory {
} }
} }
/**
* Create authenticated Exchange session
*
* @param baseUrl OWA base URL
* @param userName user login
* @param password user password
* @return authenticated session
* @throws IOException on error
*/
public static ExchangeSession getInstance(String baseUrl, String userName, String password) throws IOException { public static ExchangeSession getInstance(String baseUrl, String userName, String password) throws IOException {
ExchangeSession session = null; ExchangeSession session = null;
try { try {
@ -129,7 +138,7 @@ public final class ExchangeSessionFactory {
try { try {
session = new DavExchangeSession(poolKey.url, poolKey.userName, poolKey.password); session = new DavExchangeSession(poolKey.url, poolKey.userName, poolKey.password);
} catch (WebdavNotAvailableException e) { } catch (WebdavNotAvailableException e) {
ExchangeSession.LOGGER.debug(e.getMessage()+", retry with EWS"); ExchangeSession.LOGGER.debug(e.getMessage() + ", retry with EWS");
session = new EwsExchangeSession(poolKey.url, poolKey.userName, poolKey.password); session = new EwsExchangeSession(poolKey.url, poolKey.userName, poolKey.password);
// success, enable EWS flag // success, enable EWS flag
ExchangeSession.LOGGER.debug("EWS found, changing davmail.enableEws setting"); ExchangeSession.LOGGER.debug("EWS found, changing davmail.enableEws setting");

View File

@ -19,8 +19,8 @@
package davmail.exchange; package davmail.exchange;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.Reader;
import java.io.IOException; import java.io.IOException;
import java.io.Reader;
/** /**
* ICS Buffered Reader. * ICS Buffered Reader.
@ -32,6 +32,7 @@ public class ICSBufferedReader extends BufferedReader {
/** /**
* Create an ICS reader on the provided reader * Create an ICS reader on the provided reader
*
* @param in input reader * @param in input reader
* @throws IOException on error * @throws IOException on error
*/ */

View File

@ -19,10 +19,13 @@
package davmail.exchange; package davmail.exchange;
import javax.mail.internet.MimeUtility; import javax.mail.internet.MimeUtility;
import java.io.*; import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.Locale; import java.util.Locale;
import java.text.SimpleDateFormat;
/** /**
* Mime OutputStreamWriter to build in memory Mime message. * Mime OutputStreamWriter to build in memory Mime message.

View File

@ -26,6 +26,7 @@ import davmail.exception.DavMailException;
public class NetworkDownException extends DavMailException { public class NetworkDownException extends DavMailException {
/** /**
* Build a network down exception with the provided BundleMessage key. * Build a network down exception with the provided BundleMessage key.
*
* @param key message key * @param key message key
*/ */
public NetworkDownException(String key) { public NetworkDownException(String key) {
@ -34,7 +35,8 @@ public class NetworkDownException extends DavMailException {
/** /**
* Build a network down exception with the provided BundleMessage key. * Build a network down exception with the provided BundleMessage key.
* @param key message key *
* @param key message key
* @param message detailed message * @param message detailed message
*/ */
public NetworkDownException(String key, Object message) { public NetworkDownException(String key, Object message) {

View File

@ -108,6 +108,11 @@ public class VCalendar extends VObject {
return "TRUE".equals(vObject.getPropertyValue("X-MICROSOFT-CDO-ALLDAYEVENT")); return "TRUE".equals(vObject.getPropertyValue("X-MICROSOFT-CDO-ALLDAYEVENT"));
} }
/**
* Check if vCalendar is CDO allday.
*
* @return true if vCalendar has X-MICROSOFT-CDO-ALLDAYEVENT property set to TRUE
*/
public boolean isCdoAllDay() { public boolean isCdoAllDay() {
return firstVevent != null && isCdoAllDay(firstVevent); return firstVevent != null && isCdoAllDay(firstVevent);
} }
@ -147,7 +152,7 @@ public class VCalendar extends VObject {
String tzid = null; String tzid = null;
if (fromServer) { if (fromServer) {
// get current tzid // get current tzid
VObject vObject = getVTimezone(); VObject vObject = vTimezone;
if (vObject != null) { if (vObject != null) {
String currentTzid = vObject.getPropertyValue("TZID"); String currentTzid = vObject.getPropertyValue("TZID");
// fix TZID with \n (Exchange 2010 bug) // fix TZID with \n (Exchange 2010 bug)
@ -460,10 +465,14 @@ public class VCalendar extends VObject {
} }
} }
/**
* Remove VAlarm from VCalendar.
*/
public void removeVAlarm() { public void removeVAlarm() {
if (vObjects != null) { if (vObjects != null) {
for (VObject vObject : vObjects) { for (VObject vObject : vObjects) {
if ("VEVENT".equals(vObject.type)) { if ("VEVENT".equals(vObject.type)) {
// As VALARM is the only possible inner object, just drop all objects
if (vObject.vObjects != null) { if (vObject.vObjects != null) {
vObject.vObjects = null; vObject.vObjects = null;
} }
@ -472,6 +481,11 @@ public class VCalendar extends VObject {
} }
} }
/**
* Check if VCalendar has a VALARM item.
*
* @return true if VCalendar has a VALARM
*/
public boolean hasVAlarm() { public boolean hasVAlarm() {
if (vObjects != null) { if (vObjects != null) {
for (VObject vObject : vObjects) { for (VObject vObject : vObjects) {
@ -485,18 +499,39 @@ public class VCalendar extends VObject {
return false; return false;
} }
/**
* Check if this VCalendar is a meeting.
*
* @return true if this VCalendar has attendees
*/
public boolean isMeeting() { public boolean isMeeting() {
return getFirstVeventProperty("ATTENDEE") != null; return getFirstVeventProperty("ATTENDEE") != null;
} }
/**
* Check if current user is meeting organizer.
*
* @return true it user email matched organizer email
*/
public boolean isMeetingOrganizer() { public boolean isMeetingOrganizer() {
return email.equals(getEmailValue(getFirstVeventProperty("ORGANIZER"))); return email.equalsIgnoreCase(getEmailValue(getFirstVeventProperty("ORGANIZER")));
} }
/**
* Set property value on first VEVENT.
*
* @param propertyName property name
* @param propertyValue property value
*/
public void setFirstVeventPropertyValue(String propertyName, String propertyValue) { public void setFirstVeventPropertyValue(String propertyName, String propertyValue) {
firstVevent.setPropertyValue(propertyName, propertyValue); firstVevent.setPropertyValue(propertyName, propertyValue);
} }
/**
* Add property on first VEVENT.
*
* @param vProperty property object
*/
public void addFirstVeventProperty(VProperty vProperty) { public void addFirstVeventProperty(VProperty vProperty) {
firstVevent.addProperty(vProperty); firstVevent.addProperty(vProperty);
} }
@ -505,8 +540,19 @@ public class VCalendar extends VObject {
* VCalendar recipients for notifications * VCalendar recipients for notifications
*/ */
public static class Recipients { public static class Recipients {
/**
* attendee list
*/
public String attendees; public String attendees;
/**
* optional attendee list
*/
public String optionalAttendees; public String optionalAttendees;
/**
* vCalendar organizer
*/
public String organizer; public String organizer;
} }
@ -573,17 +619,22 @@ public class VCalendar extends VObject {
return status; return status;
} }
/**
* Get recurring VCalendar occurence exceptions.
*
* @return event occurences
*/
public List<VObject> getModifiedOccurrences() { public List<VObject> getModifiedOccurrences() {
boolean first = true; boolean first = true;
ArrayList<VObject> results = new ArrayList<VObject>(); ArrayList<VObject> results = new ArrayList<VObject>();
for (VObject vObject:vObjects) { for (VObject vObject : vObjects) {
if ("VEVENT".equals(vObject.type)) { if ("VEVENT".equals(vObject.type)) {
if (first) { if (first) {
first = false; first = false;
} else { } else {
results.add(vObject); results.add(vObject);
} }
} }
} }
return results; return results;
} }

View File

@ -84,6 +84,9 @@ public class VObject {
this(new ICSBufferedReader(new StringReader(itemBody))); this(new ICSBufferedReader(new StringReader(itemBody)));
} }
/**
* Create empty VCalendar object;
*/
public VObject() { public VObject() {
} }
@ -101,6 +104,11 @@ public class VObject {
} }
} }
/**
* Add vObject.
*
* @param vObject inner object
*/
public void addVObject(VObject vObject) { public void addVObject(VObject vObject) {
if (vObjects == null) { if (vObjects == null) {
vObjects = new ArrayList<VObject>(); vObjects = new ArrayList<VObject>();
@ -108,6 +116,11 @@ public class VObject {
vObjects.add(vObject); vObjects.add(vObject);
} }
/**
* Add vProperty.
*
* @param property vProperty
*/
public void addProperty(VProperty property) { public void addProperty(VProperty property) {
if (property.getValue() != null) { if (property.getValue() != null) {
if (properties == null) { if (properties == null) {
@ -154,6 +167,12 @@ public class VObject {
return properties; return properties;
} }
/**
* Get vProperty by name.
*
* @param name property name
* @return property object
*/
public VProperty getProperty(String name) { public VProperty getProperty(String name) {
if (properties != null) { if (properties != null) {
for (VProperty property : properties) { for (VProperty property : properties) {
@ -166,6 +185,12 @@ public class VObject {
return null; return null;
} }
/**
* Get multivalued vProperty by name.
*
* @param name property name
* @return property list
*/
public List<VProperty> getProperties(String name) { public List<VProperty> getProperties(String name) {
List<VProperty> result = null; List<VProperty> result = null;
if (properties != null) { if (properties != null) {
@ -182,6 +207,12 @@ public class VObject {
return result; return result;
} }
/**
* Get vProperty value by name.
*
* @param name property name
* @return property value
*/
public String getPropertyValue(String name) { public String getPropertyValue(String name) {
VProperty property = getProperty(name); VProperty property = getProperty(name);
if (property != null) { if (property != null) {
@ -191,6 +222,12 @@ public class VObject {
} }
} }
/**
* Set vProperty value on vObject, remove property if value is null.
*
* @param name property name
* @param value property value
*/
public void setPropertyValue(String name, String value) { public void setPropertyValue(String name, String value) {
if (value == null) { if (value == null) {
removeProperty(name); removeProperty(name);
@ -205,13 +242,24 @@ public class VObject {
} }
} }
/**
* Add vProperty value on vObject.
*
* @param name property name
* @param value property value
*/
public void addPropertyValue(String name, String value) { public void addPropertyValue(String name, String value) {
if (value != null) { if (value != null) {
VProperty property = new VProperty(name, value); VProperty property = new VProperty(name, value);
addProperty(property); addProperty(property);
} }
} }
/**
* Remove vProperty from vObject.
*
* @param name property name
*/
public void removeProperty(String name) { public void removeProperty(String name) {
if (properties != null) { if (properties != null) {
VProperty property = getProperty(name); VProperty property = getProperty(name);
@ -221,6 +269,11 @@ public class VObject {
} }
} }
/**
* Remove vProperty object from vObject.
*
* @param property object
*/
public void removeProperty(VProperty property) { public void removeProperty(VProperty property) {
if (properties != null) { if (properties != null) {
properties.remove(property); properties.remove(property);

View File

@ -234,6 +234,12 @@ public class VProperty {
addParam(paramName, (String) null); addParam(paramName, (String) null);
} }
/**
* Set param value on property.
*
* @param paramName param name
* @param paramValue param value
*/
public void setParam(String paramName, String paramValue) { public void setParam(String paramName, String paramValue) {
Param currentParam = getParam(paramName); Param currentParam = getParam(paramName);
if (currentParam != null) { if (currentParam != null) {
@ -242,6 +248,12 @@ public class VProperty {
addParam(paramName, paramValue); addParam(paramName, paramValue);
} }
/**
* Add param value on property.
*
* @param paramName param name
* @param paramValue param value
*/
public void addParam(String paramName, String paramValue) { public void addParam(String paramName, String paramValue) {
List<String> paramValues = new ArrayList<String>(); List<String> paramValues = new ArrayList<String>();
paramValues.add(paramValue); paramValues.add(paramValue);

View File

@ -35,7 +35,7 @@ import java.util.Map;
* XmlStreamReader utility methods * XmlStreamReader utility methods
*/ */
public final class XMLStreamUtil { public final class XMLStreamUtil {
protected static final Logger LOGGER = Logger.getLogger(XMLStreamUtil.class); private static final Logger LOGGER = Logger.getLogger(XMLStreamUtil.class);
private XMLStreamUtil() { private XMLStreamUtil() {
} }
@ -114,7 +114,7 @@ public final class XMLStreamUtil {
/** /**
* Test if reader is on a start tag. * Test if reader is on a start tag.
* *
* @param reader xml stream reader * @param reader xml stream reader
* @return true if reader is on a start tag * @return true if reader is on a start tag
*/ */
public static boolean isStartTag(XMLStreamReader reader) { public static boolean isStartTag(XMLStreamReader reader) {
@ -167,6 +167,12 @@ public final class XMLStreamUtil {
return xmlInputFactory.createXMLStreamReader(inputStream); return xmlInputFactory.createXMLStreamReader(inputStream);
} }
/**
* Get element text.
*
* @param reader stream reader
* @return element text
*/
public static String getElementText(XMLStreamReader reader) { public static String getElementText(XMLStreamReader reader) {
String value = null; String value = null;
try { try {

View File

@ -2577,7 +2577,8 @@ public class DavExchangeSession extends ExchangeSession {
int totalCount; int totalCount;
int lastLogCount; int lastLogCount;
public int read(byte buffer[], int offset, int length) throws IOException { @Override
public int read(byte[] buffer, int offset, int length) throws IOException {
int count = super.read(buffer, offset, length); int count = super.read(buffer, offset, length);
totalCount += count; totalCount += count;
if (totalCount - lastLogCount > 1024 * 1024) { if (totalCount - lastLogCount > 1024 * 1024) {

View File

@ -199,7 +199,6 @@ public class Field {
createField(URN_SCHEMAS_CALENDAR, "timezone"); // DistinguishedPropertySetType.PublicStrings/urn:schemas:calendar:timezone/String createField(URN_SCHEMAS_CALENDAR, "timezone"); // DistinguishedPropertySetType.PublicStrings/urn:schemas:calendar:timezone/String
createField(SCHEMAS_EXCHANGE, "sensitivity"); // PR_SENSITIVITY 0x0036 Integer createField(SCHEMAS_EXCHANGE, "sensitivity"); // PR_SENSITIVITY 0x0036 Integer
createField(URN_SCHEMAS_CALENDAR, "timezoneid"); // DistinguishedPropertySetType.PublicStrings/urn:schemas:calendar:timezoneid/Integer createField(URN_SCHEMAS_CALENDAR, "timezoneid"); // DistinguishedPropertySetType.PublicStrings/urn:schemas:calendar:timezoneid/Integer
// should use PidLidServerProcessed ? // should use PidLidServerProcessed ?

View File

@ -21,7 +21,7 @@ package davmail.exchange.ews;
/** /**
* Item update conflict resolution * Item update conflict resolution
*/ */
@SuppressWarnings({"JavaDoc"}) @SuppressWarnings({"JavaDoc", "UnusedDeclaration"})
public final class ConflictResolution extends AttributeOption { public final class ConflictResolution extends AttributeOption {
private ConflictResolution(String value) { private ConflictResolution(String value) {
super("ConflictResolution", value); super("ConflictResolution", value);

View File

@ -21,7 +21,7 @@ package davmail.exchange.ews;
/** /**
* DeleteItem disposal type. * DeleteItem disposal type.
*/ */
@SuppressWarnings({"JavaDoc"}) @SuppressWarnings({"JavaDoc", "UnusedDeclaration"})
public class DeleteType extends AttributeOption { public class DeleteType extends AttributeOption {
private DeleteType(String value) { private DeleteType(String value) {
super("DeleteType", value); super("DeleteType", value);

View File

@ -21,7 +21,7 @@ package davmail.exchange.ews;
/** /**
* Disposal. * Disposal.
*/ */
@SuppressWarnings({"JavaDoc"}) @SuppressWarnings({"JavaDoc", "UnusedDeclaration"})
public final class Disposal extends AttributeOption { public final class Disposal extends AttributeOption {
private Disposal(String value) { private Disposal(String value) {
super("DeleteType", value); super("DeleteType", value);

View File

@ -43,7 +43,7 @@ public final class DistinguishedFolderId extends FolderId {
publicfoldersroot, root, junkemail, searchfolders, voicemail publicfoldersroot, root, junkemail, searchfolders, voicemail
} }
protected static final Map<Name, DistinguishedFolderId> folderIdMap = new HashMap<Name, DistinguishedFolderId>(); private static final Map<Name, DistinguishedFolderId> folderIdMap = new HashMap<Name, DistinguishedFolderId>();
static { static {
for (Name name : Name.values()) { for (Name name : Name.values()) {

View File

@ -447,6 +447,9 @@ public abstract class EWSMethod extends PostMethod {
* Recurring event occurrence * Recurring event occurrence
*/ */
public static class Occurrence { public static class Occurrence {
/**
* Original occurence start date
*/
public String originalStart; public String originalStart;
} }
@ -625,7 +628,7 @@ public abstract class EWSMethod extends PostMethod {
/** /**
* Add occurrence. * Add occurrence.
* *
* @param attendee attendee object * @param occurrence event occurence
*/ */
public void addOccurrence(Occurrence occurrence) { public void addOccurrence(Occurrence occurrence) {
if (occurrences == null) { if (occurrences == null) {
@ -634,6 +637,11 @@ public abstract class EWSMethod extends PostMethod {
occurrences.add(occurrence); occurrences.add(occurrence);
} }
/**
* Get occurences.
*
* @return event occurences
*/
public List<Occurrence> getOccurrences() { public List<Occurrence> getOccurrences() {
return occurrences; return occurrences;
} }
@ -818,7 +826,7 @@ public abstract class EWSMethod extends PostMethod {
} }
} }
protected void handleOccurrence(XMLStreamReader reader, Item item) throws XMLStreamException { protected void handleOccurrence(XMLStreamReader reader, Item item) throws XMLStreamException {
while (reader.hasNext() && !(XMLStreamUtil.isEndTag(reader, "Occurrence"))) { while (reader.hasNext() && !(XMLStreamUtil.isEndTag(reader, "Occurrence"))) {
reader.next(); reader.next();
if (XMLStreamUtil.isStartTag(reader)) { if (XMLStreamUtil.isStartTag(reader)) {

View File

@ -1398,7 +1398,7 @@ public class EwsExchangeSession extends ExchangeSession {
// instancetype 0 single appointment / 1 master recurring appointment // instancetype 0 single appointment / 1 master recurring appointment
if (excludeTasks) { if (excludeTasks) {
return or(isTrue("isrecurring"), return or(isTrue("isrecurring"),
and(isFalse("isrecurring"), dateCondition)); and(isFalse("isrecurring"), dateCondition));
} else { } else {
return or(not(isEqualTo("outlookmessageclass", "IPM.Appointment")), return or(not(isEqualTo("outlookmessageclass", "IPM.Appointment")),
isTrue("isrecurring"), isTrue("isrecurring"),

View File

@ -139,7 +139,7 @@ public class ExtendedFieldURI implements FieldURI {
} else { } else {
buffer.append("<t:Value>"); buffer.append("<t:Value>");
if ("0x10f3".equals(propertyTag)) { if ("0x10f3".equals(propertyTag)) {
buffer.append(StringUtil.xmlEncode(StringUtil.encodeUrlcompname(value))); buffer.append(StringUtil.xmlEncode(StringUtil.encodeUrlcompname(value)));
} else { } else {
buffer.append(StringUtil.xmlEncode(value)); buffer.append(StringUtil.xmlEncode(value));
} }

View File

@ -25,7 +25,7 @@ import java.util.Map;
* EWS MAPI fields; * EWS MAPI fields;
*/ */
public final class Field { public final class Field {
protected static final Map<String, FieldURI> FIELD_MAP = new HashMap<String, FieldURI>(); private static final Map<String, FieldURI> FIELD_MAP = new HashMap<String, FieldURI>();
private Field() { private Field() {
} }
@ -161,7 +161,7 @@ public final class Field {
FIELD_MAP.put("im", new ExtendedFieldURI(ExtendedFieldURI.DistinguishedPropertySetType.Address, 0x8062, ExtendedFieldURI.PropertyType.String)); FIELD_MAP.put("im", new ExtendedFieldURI(ExtendedFieldURI.DistinguishedPropertySetType.Address, 0x8062, ExtendedFieldURI.PropertyType.String));
FIELD_MAP.put("othermobile", new ExtendedFieldURI(0x3A1E, ExtendedFieldURI.PropertyType.String)); FIELD_MAP.put("othermobile", new ExtendedFieldURI(0x3A1E, ExtendedFieldURI.PropertyType.String));
FIELD_MAP.put("internationalisdnnumber", new ExtendedFieldURI(0x3A2D, ExtendedFieldURI.PropertyType.String)); FIELD_MAP.put("internationalisdnnumber", new ExtendedFieldURI(0x3A2D, ExtendedFieldURI.PropertyType.String));
FIELD_MAP.put("otherTelephone", new ExtendedFieldURI(0x3A21, ExtendedFieldURI.PropertyType.String)); FIELD_MAP.put("otherTelephone", new ExtendedFieldURI(0x3A21, ExtendedFieldURI.PropertyType.String));
FIELD_MAP.put("homefax", new ExtendedFieldURI(0x3A25, ExtendedFieldURI.PropertyType.String)); FIELD_MAP.put("homefax", new ExtendedFieldURI(0x3A25, ExtendedFieldURI.PropertyType.String));

View File

@ -57,7 +57,7 @@ public class FolderId extends Option {
* Build Folder id from response item. * Build Folder id from response item.
* *
* @param mailbox mailbox name * @param mailbox mailbox name
* @param item response item * @param item response item
*/ */
public FolderId(String mailbox, EWSMethod.Item item) { public FolderId(String mailbox, EWSMethod.Item item) {
this("t:FolderId", item.get("FolderId"), item.get("ChangeKey"), mailbox); this("t:FolderId", item.get("FolderId"), item.get("ChangeKey"), mailbox);

View File

@ -32,7 +32,6 @@ public class GetUserConfigurationMethod extends EWSMethod {
/** /**
* Get User Configuration method. * Get User Configuration method.
*
*/ */
public GetUserConfigurationMethod() { public GetUserConfigurationMethod() {
super("UserConfiguration", "GetUserConfiguration"); super("UserConfiguration", "GetUserConfiguration");

View File

@ -32,8 +32,10 @@ public class IndexedFieldURI implements FieldURI {
/** /**
* Create indexed field uri. * Create indexed field uri.
* *
* @param fieldURI base field uri * @param fieldURI base field uri
* @param fieldIndex field name * @param fieldIndex field name
* @param fieldItemType field item type
* @param collectionName collection name
*/ */
public IndexedFieldURI(String fieldURI, String fieldIndex, String fieldItemType, String collectionName) { public IndexedFieldURI(String fieldURI, String fieldIndex, String fieldItemType, String collectionName) {
this.fieldURI = fieldURI; this.fieldURI = fieldURI;

View File

@ -229,9 +229,8 @@ public final class DavGatewayHttpClientFacade {
* @param httpClient httpClient instance * @param httpClient httpClient instance
* @param url url string * @param url url string
* @return HttpStatus code * @return HttpStatus code
* @throws IOException on error
*/ */
public static int getHttpStatus(HttpClient httpClient, String url) throws IOException { public static int getHttpStatus(HttpClient httpClient, String url) {
int status = 0; int status = 0;
HttpMethod testMethod = new GetMethod(url); HttpMethod testMethod = new GetMethod(url);
testMethod.setDoAuthentication(false); testMethod.setDoAuthentication(false);

View File

@ -30,10 +30,11 @@ public final class DavGatewayOTPPrompt {
/** /**
* Ask user token password * Ask user token password
*
* @return user provided one time password * @return user provided one time password
*/ */
public static String getOneTimePassword() { public static String getOneTimePassword() {
PasswordPromptDialog passwordPromptDialog = new PasswordPromptDialog(BundleMessage.format("UI_OTP_PASSWORD_PROMPT")); PasswordPromptDialog passwordPromptDialog = new PasswordPromptDialog(BundleMessage.format("UI_OTP_PASSWORD_PROMPT"));
return String.valueOf(passwordPromptDialog.getPassword()); return String.valueOf(passwordPromptDialog.getPassword());
} }
} }

View File

@ -18,23 +18,23 @@
*/ */
package davmail.http; package davmail.http;
import davmail.Settings;
import davmail.BundleMessage; import davmail.BundleMessage;
import davmail.ui.tray.DavGatewayTray; import davmail.Settings;
import davmail.ui.AcceptCertificateDialog; import davmail.ui.AcceptCertificateDialog;
import davmail.ui.tray.DavGatewayTray;
import javax.net.ssl.TrustManager; import javax.net.ssl.TrustManager;
import javax.net.ssl.TrustManagerFactory; import javax.net.ssl.TrustManagerFactory;
import javax.net.ssl.X509TrustManager; import javax.net.ssl.X509TrustManager;
import java.awt.*; import java.awt.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.security.*; import java.security.*;
import java.security.cert.CertificateEncodingException; import java.security.cert.CertificateEncodingException;
import java.security.cert.CertificateException; import java.security.cert.CertificateException;
import java.security.cert.X509Certificate; import java.security.cert.X509Certificate;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
/** /**
* Custom Trust Manager, let user accept or deny. * Custom Trust Manager, let user accept or deny.

View File

@ -187,7 +187,7 @@ public class NTLMv2Scheme implements AuthScheme {
this.state = TYPE1_MSG_GENERATED; this.state = TYPE1_MSG_GENERATED;
} else { } else {
int flags = NtlmFlags.NTLMSSP_NEGOTIATE_NTLM2 | NtlmFlags.NTLMSSP_NEGOTIATE_ALWAYS_SIGN | int flags = NtlmFlags.NTLMSSP_NEGOTIATE_NTLM2 | NtlmFlags.NTLMSSP_NEGOTIATE_ALWAYS_SIGN |
NtlmFlags.NTLMSSP_NEGOTIATE_NTLM | NtlmFlags.NTLMSSP_NEGOTIATE_UNICODE; NtlmFlags.NTLMSSP_NEGOTIATE_NTLM | NtlmFlags.NTLMSSP_NEGOTIATE_UNICODE;
Type3Message type3Message = new Type3Message(type2Message, ntcredentials.getPassword(), Type3Message type3Message = new Type3Message(type2Message, ntcredentials.getPassword(),
ntcredentials.getDomain(), ntcredentials.getUserName(), ntcredentials.getHost(), flags); ntcredentials.getDomain(), ntcredentials.getUserName(), ntcredentials.getHost(), flags);
response = EncodingUtil.getAsciiString(Base64.encodeBase64(type3Message.toByteArray())); response = EncodingUtil.getAsciiString(Base64.encodeBase64(type3Message.toByteArray()));

View File

@ -20,9 +20,9 @@ package davmail.http;
import sun.security.pkcs11.SunPKCS11; import sun.security.pkcs11.SunPKCS11;
import java.io.ByteArrayInputStream;
import java.security.Provider; import java.security.Provider;
import java.security.Security; import java.security.Security;
import java.io.ByteArrayInputStream;
/** /**
* Add the SunPKCS11 Provider. * Add the SunPKCS11 Provider.

View File

@ -94,7 +94,7 @@ public class ImapConnection extends AbstractConnection {
commandId = tokens.nextToken(); commandId = tokens.nextToken();
checkInfiniteLoop(line); checkInfiniteLoop(line);
if (tokens.hasMoreTokens()) { if (tokens.hasMoreTokens()) {
String command = tokens.nextToken(); String command = tokens.nextToken();
@ -622,6 +622,7 @@ public class ImapConnection extends AbstractConnection {
/** /**
* Detect infinite loop on the client side. * Detect infinite loop on the client side.
*
* @param line IMAP command line * @param line IMAP command line
* @throws IOException on infinite loop * @throws IOException on infinite loop
*/ */
@ -637,7 +638,7 @@ public class ImapConnection extends AbstractConnection {
lastCommandCount++; lastCommandCount++;
if (lastCommandCount > 100 && !"NOOP".equalsIgnoreCase(lastCommand)) { if (lastCommandCount > 100 && !"NOOP".equalsIgnoreCase(lastCommand)) {
// more than a hundred times the same command => this is a client infinite loop, close connection // more than a hundred times the same command => this is a client infinite loop, close connection
throw new IOException("Infinite loop on command "+command+" detected"); throw new IOException("Infinite loop on command " + command + " detected");
} }
} else { } else {
// new command, reset // new command, reset

View File

@ -42,7 +42,7 @@ public class ImapServer extends AbstractServer {
*/ */
public ImapServer(int port) { public ImapServer(int port) {
super(ImapServer.class.getName(), port, ImapServer.DEFAULT_PORT); super(ImapServer.class.getName(), port, ImapServer.DEFAULT_PORT);
nosslFlag = Settings.getBooleanProperty("davmail.ssl.nosecureimap"); nosslFlag = Settings.getBooleanProperty("davmail.ssl.nosecureimap");
} }
@Override @Override

View File

@ -469,7 +469,7 @@ public class LdapConnection extends AbstractConnection {
} }
DavGatewayTray.switchIcon(); DavGatewayTray.switchIcon();
handleRequest(inbuf, offset); handleRequest(inbuf, offset);
} }
@ -487,7 +487,7 @@ public class LdapConnection extends AbstractConnection {
} finally { } finally {
// cancel all search threads // cancel all search threads
synchronized (searchThreadMap) { synchronized (searchThreadMap) {
for (SearchRunnable searchRunnable:searchThreadMap.values()) { for (SearchRunnable searchRunnable : searchThreadMap.values()) {
searchRunnable.abandon(); searchRunnable.abandon();
} }
} }

View File

@ -39,9 +39,9 @@ public class LdapServer extends AbstractServer {
* *
* @param port pop listen port, 389 if not defined (0) * @param port pop listen port, 389 if not defined (0)
*/ */
public LdapServer(int port) { public LdapServer(int port) {
super(LdapServer.class.getName(), port, LdapServer.DEFAULT_PORT); super(LdapServer.class.getName(), port, LdapServer.DEFAULT_PORT);
nosslFlag = Settings.getBooleanProperty("davmail.ssl.nosecureldap"); nosslFlag = Settings.getBooleanProperty("davmail.ssl.nosecureldap");
} }
@Override @Override

View File

@ -93,7 +93,7 @@ public class PopConnection extends AbstractConnection {
try { try {
ExchangeSessionFactory.checkConfig(); ExchangeSessionFactory.checkConfig();
sendOK("DavMail "+ DavGateway.getCurrentVersion()+" POP ready at " + new Date()); sendOK("DavMail " + DavGateway.getCurrentVersion() + " POP ready at " + new Date());
for (; ;) { for (; ;) {
line = readClient(); line = readClient();

View File

@ -37,11 +37,12 @@ public class PopServer extends AbstractServer {
/** /**
* Create a ServerSocket to listen for connections. * Create a ServerSocket to listen for connections.
* Start the thread. * Start the thread.
*
* @param port pop listen port, 110 if not defined (0) * @param port pop listen port, 110 if not defined (0)
*/ */
public PopServer(int port) { public PopServer(int port) {
super(PopServer.class.getName(), port, PopServer.DEFAULT_PORT); super(PopServer.class.getName(), port, PopServer.DEFAULT_PORT);
nosslFlag = Settings.getBooleanProperty("davmail.ssl.nosecurepop"); nosslFlag = Settings.getBooleanProperty("davmail.ssl.nosecurepop");
} }
@Override @Override

View File

@ -62,7 +62,7 @@ public class SmtpConnection extends AbstractConnection {
try { try {
ExchangeSessionFactory.checkConfig(); ExchangeSessionFactory.checkConfig();
sendClient("220 DavMail "+ DavGateway.getCurrentVersion()+" SMTP ready at " + new Date()); sendClient("220 DavMail " + DavGateway.getCurrentVersion() + " SMTP ready at " + new Date());
for (; ;) { for (; ;) {
line = readClient(); line = readClient();
// unable to read line, connection closed ? // unable to read line, connection closed ?

View File

@ -36,11 +36,12 @@ public class SmtpServer extends AbstractServer {
/** /**
* Create a ServerSocket to listen for connections. * Create a ServerSocket to listen for connections.
* Start the thread. * Start the thread.
*
* @param port smtp port * @param port smtp port
*/ */
public SmtpServer(int port) { public SmtpServer(int port) {
super(SmtpServer.class.getName(), port, SmtpServer.DEFAULT_PORT); super(SmtpServer.class.getName(), port, SmtpServer.DEFAULT_PORT);
nosslFlag = Settings.getBooleanProperty("davmail.ssl.nosecuresmtp"); nosslFlag = Settings.getBooleanProperty("davmail.ssl.nosecuresmtp");
} }
@Override @Override

View File

@ -18,10 +18,10 @@
*/ */
package davmail.ui; package davmail.ui;
import davmail.DavGateway;
import davmail.BundleMessage; import davmail.BundleMessage;
import davmail.ui.tray.DavGatewayTray; import davmail.DavGateway;
import davmail.ui.browser.DesktopBrowser; import davmail.ui.browser.DesktopBrowser;
import davmail.ui.tray.DavGatewayTray;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import javax.swing.*; import javax.swing.*;

View File

@ -18,9 +18,9 @@
*/ */
package davmail.ui; package davmail.ui;
import davmail.BundleMessage;
import davmail.http.DavGatewayX509TrustManager; import davmail.http.DavGatewayX509TrustManager;
import davmail.ui.tray.DavGatewayTray; import davmail.ui.tray.DavGatewayTray;
import davmail.BundleMessage;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;

View File

@ -32,7 +32,7 @@ import java.awt.event.ActionListener;
*/ */
public class NotificationDialog extends JDialog { public class NotificationDialog extends JDialog {
protected boolean sendNotification = false; protected boolean sendNotification;
protected JTextField toField; protected JTextField toField;
protected JTextField ccField; protected JTextField ccField;
@ -56,6 +56,13 @@ public class NotificationDialog extends JDialog {
} }
} }
/**
* Notification dialog to let user edit message body or cancel notification.
*
* @param to main recipients
* @param cc copy recipients
* @param subject notification subject
*/
public NotificationDialog(String to, String cc, String subject) { public NotificationDialog(String to, String cc, String subject) {
setModal(true); setModal(true);
setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
@ -157,22 +164,47 @@ public class NotificationDialog extends JDialog {
return bodyPanel; return bodyPanel;
} }
/**
* Cancel notification flag.
*
* @return false if user chose to cancel notification
*/
public boolean getSendNotification() { public boolean getSendNotification() {
return sendNotification; return sendNotification;
} }
/**
* Get edited recipients.
*
* @return recipients string
*/
public String getTo() { public String getTo() {
return toField.getText(); return toField.getText();
} }
/**
* Get edited copy recipients.
*
* @return copy recipients string
*/
public String getCc() { public String getCc() {
return ccField.getText(); return ccField.getText();
} }
/**
* Get edited subject.
*
* @return subject
*/
public String getSubject() { public String getSubject() {
return subjectField.getText(); return subjectField.getText();
} }
/**
* Get edited body.
*
* @return edited notification body
*/
public String getBody() { public String getBody() {
return bodyField.getText(); return bodyField.getText();
} }

View File

@ -18,7 +18,10 @@
*/ */
package davmail.ui; package davmail.ui;
import java.lang.reflect.*; import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
/** /**
* Reflection based MacOS handler * Reflection based MacOS handler
@ -195,6 +198,7 @@ public class OSXAdapter implements InvocationHandler {
// //
// //
/** /**
* Compare the method that was called to the intended method when the OSXAdapter instance was created * Compare the method that was called to the intended method when the OSXAdapter instance was created
* (e.g. handleAbout, handleQuit, handleOpenFile, etc.). * (e.g. handleAbout, handleQuit, handleOpenFile, etc.).

View File

@ -571,7 +571,7 @@ public class SettingsFrame extends JFrame {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
DesktopBrowser.browse("http://davmail.sourceforge.net"); DesktopBrowser.browse("http://davmail.sourceforge.net");
} }
}); });
tabbedPane.addChangeListener(new ChangeListener() { tabbedPane.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) { public void stateChanged(ChangeEvent e) {
boolean isSslEnabled = isSslEnabled(); boolean isSslEnabled = isSslEnabled();

View File

@ -18,9 +18,9 @@
*/ */
package davmail.ui.browser; package davmail.ui.browser;
import java.awt.*;
import java.io.IOException; import java.io.IOException;
import java.net.URI; import java.net.URI;
import java.awt.*;
/** /**
* Wrapper class to call Java6 Desktop class to launch default browser. * Wrapper class to call Java6 Desktop class to launch default browser.

View File

@ -18,9 +18,9 @@
*/ */
package davmail.ui.browser; package davmail.ui.browser;
import davmail.ui.tray.DavGatewayTray;
import davmail.ui.AboutFrame;
import davmail.BundleMessage; import davmail.BundleMessage;
import davmail.ui.AboutFrame;
import davmail.ui.tray.DavGatewayTray;
import java.net.URI; import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;

View File

@ -36,6 +36,6 @@ public final class OSXDesktopBrowser {
* @throws IOException on error * @throws IOException on error
*/ */
public static void browse(URI location) throws IOException { public static void browse(URI location) throws IOException {
Runtime.getRuntime().exec("open "+location.toString()); Runtime.getRuntime().exec("open " + location.toString());
} }
} }

View File

@ -23,7 +23,7 @@ import org.eclipse.swt.program.Program;
import java.net.URI; import java.net.URI;
/** /**
* Wrapper class to call SWT Program class to launch default browser. * Wrapper class to call SWT Program class to launch default browser.
*/ */
public final class SwtDesktopBrowser { public final class SwtDesktopBrowser {
private SwtDesktopBrowser() { private SwtDesktopBrowser() {

View File

@ -18,13 +18,13 @@
*/ */
package davmail.ui.tray; package davmail.ui.tray;
import davmail.Settings;
import davmail.BundleMessage; import davmail.BundleMessage;
import davmail.DavGateway; import davmail.DavGateway;
import davmail.Settings;
import davmail.ui.AboutFrame; import davmail.ui.AboutFrame;
import davmail.ui.SettingsFrame; import davmail.ui.SettingsFrame;
import org.apache.log4j.Logger;
import org.apache.log4j.Level; import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.lf5.LF5Appender; import org.apache.log4j.lf5.LF5Appender;
import org.apache.log4j.lf5.LogLevel; import org.apache.log4j.lf5.LogLevel;
import org.apache.log4j.lf5.viewer.LogBrokerMonitor; import org.apache.log4j.lf5.viewer.LogBrokerMonitor;

View File

@ -18,11 +18,11 @@
*/ */
package davmail.ui.tray; package davmail.ui.tray;
import davmail.Settings;
import davmail.BundleMessage; import davmail.BundleMessage;
import davmail.Settings;
import davmail.exchange.NetworkDownException; import davmail.exchange.NetworkDownException;
import org.apache.log4j.Logger;
import org.apache.log4j.Level; import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import java.awt.*; import java.awt.*;

View File

@ -18,13 +18,13 @@
*/ */
package davmail.ui.tray; package davmail.ui.tray;
import davmail.Settings;
import davmail.BundleMessage; import davmail.BundleMessage;
import davmail.DavGateway; import davmail.DavGateway;
import davmail.Settings;
import davmail.ui.AboutFrame; import davmail.ui.AboutFrame;
import davmail.ui.SettingsFrame; import davmail.ui.SettingsFrame;
import org.apache.log4j.Logger;
import org.apache.log4j.Level; import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.lf5.LF5Appender; import org.apache.log4j.lf5.LF5Appender;
import org.apache.log4j.lf5.LogLevel; import org.apache.log4j.lf5.LogLevel;
import org.apache.log4j.lf5.viewer.LogBrokerMonitor; import org.apache.log4j.lf5.viewer.LogBrokerMonitor;

View File

@ -18,9 +18,9 @@
*/ */
package davmail.ui.tray; package davmail.ui.tray;
import davmail.ui.OSXAdapter;
import davmail.BundleMessage; import davmail.BundleMessage;
import davmail.DavGateway; import davmail.DavGateway;
import davmail.ui.OSXAdapter;
import javax.swing.*; import javax.swing.*;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;

View File

@ -366,7 +366,7 @@ public final class StringUtil {
* Get allday date value from zulu timestamp. * Get allday date value from zulu timestamp.
* *
* @param value zulu datetime * @param value zulu datetime
* @return yyyyMMdd allday date value * @return yyyyMMdd allday date value
*/ */
public static String convertZuluDateTimeToAllDay(String value) { public static String convertZuluDateTimeToAllDay(String value) {
String result = value; String result = value;

View File

@ -18,15 +18,15 @@
*/ */
package davmail.web; package davmail.web;
import davmail.Settings;
import davmail.DavGateway;
import davmail.BundleMessage; import davmail.BundleMessage;
import davmail.DavGateway;
import davmail.Settings;
import davmail.ui.tray.DavGatewayTray; import davmail.ui.tray.DavGatewayTray;
import javax.servlet.ServletContextListener;
import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextEvent;
import java.io.InputStream; import javax.servlet.ServletContextListener;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
/** /**
* Context Listener to start/stop DavMail * Context Listener to start/stop DavMail