From dc7a1a0532e92fecec5e18f7c532083efe1df897 Mon Sep 17 00:00:00 2001 From: Matthew Brace Date: Wed, 24 Dec 2008 03:09:37 +0000 Subject: [PATCH] Fixed an issue where some Exchange servers wouldn't mark messages as read. Fixed incorrect URL encoding in some folder path names. Removed some unneccessary headers from the envelope request. --- .../android/email/mail/store/WebDavStore.java | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/com/android/email/mail/store/WebDavStore.java b/src/com/android/email/mail/store/WebDavStore.java index eb4cbc68d..233c41348 100644 --- a/src/com/android/email/mail/store/WebDavStore.java +++ b/src/com/android/email/mail/store/WebDavStore.java @@ -300,7 +300,6 @@ public class WebDavStore extends Store { buffer.append(""); buffer.append("\r\n"); buffer.append("SELECT \"DAV:uid\", \"DAV:getcontentlength\","); - buffer.append(" \"urn:schemas:mailheader:received\","); buffer.append(" \"urn:schemas:mailheader:mime-version\","); buffer.append(" \"urn:schemas:mailheader:content-type\","); buffer.append(" \"urn:schemas:mailheader:subject\","); @@ -310,9 +309,7 @@ public class WebDavStore extends Store { buffer.append(" \"urn:schemas:mailheader:from\","); buffer.append(" \"urn:schemas:mailheader:to\","); buffer.append(" \"urn:schemas:mailheader:in-reply-to\","); - buffer.append(" \"urn:schemas:mailheader:return-path\","); buffer.append(" \"urn:schemas:mailheader:cc\","); - buffer.append(" \"urn:schemas:mailheader:references\","); buffer.append(" \"urn:schemas:httpmail:read\""); buffer.append(" \r\n"); buffer.append(" FROM \"\"\r\n"); @@ -388,7 +385,7 @@ public class WebDavStore extends Store { buffer.append("\r\n"); buffer.append("\r\n"); for (int i = 0, count = urls.length; i < count; i++) { - buffer.append(" "+urls[i].substring(urls[i].lastIndexOf('/') + 1)+"\r\n"); + buffer.append(" "+urls[i]+"\r\n"); } buffer.append("\r\n"); buffer.append("\r\n"); @@ -548,7 +545,16 @@ public class WebDavStore extends Store { String[] userParts; String encodedName = new String(); try { - encodedName = java.net.URLEncoder.encode(name, "UTF-8"); + String[] urlParts = name.split("/"); + String url = ""; + for (int i = 0, count = urlParts.length; i < count; i++) { + if (i != 0) { + url = url + "/" + java.net.URLEncoder.encode(urlParts[i], "UTF-8"); + } else { + url = java.net.URLEncoder.encode(urlParts[i], "UTF-8"); + } + } + encodedName = url; } catch (UnsupportedEncodingException uee) { Log.e(Email.LOG_TAG, "UnsupportedEncodingException URLEncoding folder name, skipping encoded"); encodedName = name; @@ -572,6 +578,10 @@ public class WebDavStore extends Store { if (needAuth()) { authenticate(); } + + if (encodedName.equals("INBOX")) { + encodedName = "Inbox"; + } //this.mFolderUrl = WebDavStore.this.mUrl + "/Exchange/" + this.mLocalUsername + "/" + encodedName; this.mFolderUrl = WebDavStore.this.mUrl + encodedName; @@ -1337,7 +1347,7 @@ public class WebDavStore extends Store { try { int status_code = -1; StringEntity messageEntity = new StringEntity(messageBody); - HttpGeneric httpmethod = new HttpGeneric(this.mFolderUrl + "/"); + HttpGeneric httpmethod = new HttpGeneric(this.mFolderUrl); HttpResponse response; HttpEntity entity; @@ -1356,6 +1366,7 @@ public class WebDavStore extends Store { } entity = response.getEntity(); + } catch (UnsupportedEncodingException uee) { Log.e(Email.LOG_TAG, "UnsupportedEncodingException: " + uee); } catch (IOException ioe) {