Fix for bug 2637306: get alias from mailPath display name

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@433 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2009-03-11 12:39:14 +00:00
parent 8bb3ba9ed1
commit 4871c9cf39
1 changed files with 36 additions and 0 deletions

View File

@ -58,6 +58,13 @@ public class ExchangeSession {
WELL_KNOWN_FOLDERS.add("urn:schemas:httpmail:calendar");
}
protected static final Vector<String> DISPLAY_NAME = new Vector<String>();
static {
DISPLAY_NAME.add("DAV:displayname");
}
public static final HashMap<String, String> PRIORITIES = new HashMap<String, String>();
static {
@ -1687,6 +1694,31 @@ public class ExchangeSession {
}
}
public String getAliasFromMailboxDisplayName() throws IOException {
if (mailPath == null) {
return null;
}
String alias = null;
Enumeration folderEnum = wdr.propfindMethod(mailPath, 0, DISPLAY_NAME);
if (!folderEnum.hasMoreElements()) {
throw new IOException("Unable to get mail folder");
}
ResponseEntity mailboxResponse = (ResponseEntity) folderEnum.
nextElement();
Enumeration mailboxPropsEnum = mailboxResponse.getProperties();
if (!mailboxPropsEnum.hasMoreElements()) {
throw new IOException("Unable to get mail folder");
}
while (mailboxPropsEnum.hasMoreElements()) {
Property inboxProp = (Property) mailboxPropsEnum.nextElement();
if ("displayname".equals(inboxProp.getLocalName())) {
alias = inboxProp.getPropertyAsString();
}
}
return alias;
}
public String getEmail(String alias) throws IOException {
String emailResult = null;
if (alias != null) {
@ -1716,6 +1748,10 @@ public class ExchangeSession {
if (email == null) {
email = getEmail(getAliasFromMailPath());
}
// another failover : get alias from mailPath display name
if (email == null) {
email = getEmail(getAliasFromMailboxDisplayName());
}
if (email == null) {
// failover : get email from Exchange 2007 Options page
email = getEmail(getAliasFromOptions(methodPath));