From c84fe2312be579e5fa121953f5b03dcc2e2a55e7 Mon Sep 17 00:00:00 2001 From: Philip Whitehouse Date: Wed, 5 Apr 2017 01:04:23 +0100 Subject: [PATCH] Add a Toast when we fail to fetch the list of folders --- .../fsck/k9/mail/store/imap/ImapResponseParser.java | 2 +- .../k9/mail/store/imap/ImapResponseParserTest.java | 10 +++++++++- .../src/main/java/com/fsck/k9/activity/FolderList.java | 2 +- k9mail/src/main/res/values/strings.xml | 1 + 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/k9mail-library/src/main/java/com/fsck/k9/mail/store/imap/ImapResponseParser.java b/k9mail-library/src/main/java/com/fsck/k9/mail/store/imap/ImapResponseParser.java index 513d097c8..24c5a8b9e 100644 --- a/k9mail-library/src/main/java/com/fsck/k9/mail/store/imap/ImapResponseParser.java +++ b/k9mail-library/src/main/java/com/fsck/k9/mail/store/imap/ImapResponseParser.java @@ -477,7 +477,7 @@ class ImapResponseParser { private void checkTokenIsString(Object token) throws IOException { if (!(token instanceof String)) { - throw new IOException("Unexpected non-string token: " + token); + throw new IOException("Unexpected non-string token: " + token.getClass().getSimpleName() + " - " + token); } } } diff --git a/k9mail-library/src/test/java/com/fsck/k9/mail/store/imap/ImapResponseParserTest.java b/k9mail-library/src/test/java/com/fsck/k9/mail/store/imap/ImapResponseParserTest.java index 0dcb8d829..281c119a7 100644 --- a/k9mail-library/src/test/java/com/fsck/k9/mail/store/imap/ImapResponseParserTest.java +++ b/k9mail-library/src/test/java/com/fsck/k9/mail/store/imap/ImapResponseParserTest.java @@ -384,6 +384,14 @@ public class ImapResponseParserTest { assertEquals("[FolderName]", response.get(3)); } + @Test(expected = IOException.class) + public void testListResponseContainingFolderNameContainingBracketsThrowsException() throws Exception { + ImapResponseParser parser = createParser( + "* LIST (\\NoInferiors) \"/\" Root/Folder/Subfolder()\r\n"); + + parser.readResponse(); + } + @Test public void readResponseShouldReadWholeListResponseLine() throws Exception { ImapResponseParser parser = createParser("* LIST (\\HasNoChildren) \".\" [FolderName]\r\n" + @@ -417,7 +425,7 @@ public class ImapResponseParserTest { parser.readResponse(); fail("Expected exception"); } catch (IOException e) { - assertEquals("Unexpected non-string token: [1, 2]", e.getMessage()); + assertEquals("Unexpected non-string token: ImapList - [1, 2]", e.getMessage()); } } diff --git a/k9mail/src/main/java/com/fsck/k9/activity/FolderList.java b/k9mail/src/main/java/com/fsck/k9/activity/FolderList.java index 13bf372b6..b3ad27d18 100644 --- a/k9mail/src/main/java/com/fsck/k9/activity/FolderList.java +++ b/k9mail/src/main/java/com/fsck/k9/activity/FolderList.java @@ -706,8 +706,8 @@ public class FolderList extends K9ListActivity { @Override public void listFoldersFailed(Account account, String message) { if (account.equals(mAccount)) { - mHandler.progress(false); + Toast.makeText(context, R.string.fetching_folders_failed, Toast.LENGTH_SHORT).show(); } super.listFoldersFailed(account, message); } diff --git a/k9mail/src/main/res/values/strings.xml b/k9mail/src/main/res/values/strings.xml index af432ff7e..9ea6c60ee 100644 --- a/k9mail/src/main/res/values/strings.xml +++ b/k9mail/src/main/res/values/strings.xml @@ -1229,4 +1229,5 @@ Please submit bug reports, contribute new features and ask questions at K-9 Message List Loading messages… + Fetching folder list failed