From 453406a5a52666d5b2ac0c165480c25ad14409a2 Mon Sep 17 00:00:00 2001 From: Matthew Brace Date: Sun, 14 Dec 2008 19:33:34 +0000 Subject: [PATCH] Added change to populate the url for the mailbox each time authentication occurs (url is in the response). Updated initial message population to use reverse order so initial display has newest first (only noticeable on slow connections). --- src/com/fsck/k9/mail/store/WebDavStore.java | 25 ++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/com/fsck/k9/mail/store/WebDavStore.java b/src/com/fsck/k9/mail/store/WebDavStore.java index 39ba2b3c5..0832dea47 100644 --- a/src/com/fsck/k9/mail/store/WebDavStore.java +++ b/src/com/fsck/k9/mail/store/WebDavStore.java @@ -179,7 +179,7 @@ public class WebDavStore extends Store { messageEntity = new StringEntity(messageBody); messageEntity.setContentType("text/xml"); - httpmethod = new HttpGeneric(this.mUrl + "/Exchange/" + this.mUsername); + httpmethod = new HttpGeneric(this.mUrl);// + "/Exchange/" + this.mUsername); httpmethod.setMethod("SEARCH"); httpmethod.setEntity(messageEntity); httpmethod.setHeader("Brief", "t"); @@ -464,6 +464,22 @@ public class WebDavStore extends Store { if (cookies == null) { throw new IOException("Error during authentication: No Cookies"); } + + /** Get the URL for the mailbox and set it for the store */ + if (entity != null) { + InputStream istream = entity.getContent(); + + BufferedReader reader = new BufferedReader(new InputStreamReader(istream), 8192); + String tempText = ""; + + while ((tempText = reader.readLine()) != null) { + if (tempText.indexOf("BASE href") >= 0) { + String[] tagParts = tempText.split("\""); + this.mUrl = tagParts[1]; + } + } + } + } catch (UnsupportedEncodingException uee) { Log.e(k9.LOG_TAG, "Error encoding POST data for authencation"); } @@ -516,7 +532,8 @@ public class WebDavStore extends Store { } - this.mFolderUrl = WebDavStore.this.mUrl + "/Exchange/" + this.mLocalUsername + "/" + encodedName; + //this.mFolderUrl = WebDavStore.this.mUrl + "/Exchange/" + this.mLocalUsername + "/" + encodedName; + this.mFolderUrl = WebDavStore.this.mUrl + encodedName; } @Override @@ -1202,7 +1219,9 @@ public class WebDavStore extends Store { Log.e(k9.LOG_TAG, "IOException: " + ioe); } - for (int i = 0, count = messages.length; i < count; i++) { + int count = messages.length; + for (int i = messages.length - 1; i >= 0; i--) { + /* for (int i = 0, count = messages.length; i < count; i++) {*/ if (!(messages[i] instanceof WebDavMessage)) { throw new MessagingException("WebDavStore fetch called with non-WebDavMessage"); }