use of com.zimbra.cs.mailclient.imap.ListData in project zm-mailbox by Zimbra.
the class TestImapClient method testList.
@Test
public void testList() throws Exception {
login();
List<ListData> lds = connection.list("", "*");
for (ListData ld : lds) {
assertEquals('/', ld.getDelimiter());
assertNotNull(ld.getMailbox());
assertTrue(ld.getFlags().size() > 0);
}
}
use of com.zimbra.cs.mailclient.imap.ListData in project zm-mailbox by Zimbra.
the class TestImapUtil method parseFolders.
private List<ListData> parseFolders(String[] folders) throws IOException {
List<ListData> lds = new ArrayList<ListData>();
ImapInputStream is = getImapInputStream(folders);
while (!is.isEOF()) {
is.skipChar('*');
is.skipChar(' ');
is.readAtom();
is.skipChar(' ');
lds.add(ListData.read(is));
is.skipCRLF();
}
return lds;
}
use of com.zimbra.cs.mailclient.imap.ListData in project zm-mailbox by Zimbra.
the class TestImap method testFoldersList.
@Test
public void testFoldersList() throws Exception {
List<ListData> listResult = connection.list("", "*");
assertNotNull(listResult);
assertTrue("List result should have atleast 5 entries", listResult.size() >= 5);
boolean hasContacts = false;
boolean hasChats = false;
boolean hasEmailedContacts = false;
boolean hasTrash = false;
boolean hasDrafts = false;
boolean hasInbox = false;
boolean hasJunk = false;
boolean hasSent = false;
for (ListData ld : listResult) {
if ((ld.getMailbox().equalsIgnoreCase("Contacts"))) {
hasContacts = true;
} else if ((ld.getMailbox().equalsIgnoreCase("Chats"))) {
hasChats = true;
} else if ((ld.getMailbox().equalsIgnoreCase("Emailed Contacts"))) {
hasEmailedContacts = true;
} else if ((ld.getMailbox().equalsIgnoreCase("Trash"))) {
hasTrash = true;
} else if ((ld.getMailbox().equalsIgnoreCase("Drafts"))) {
hasDrafts = true;
} else if ((ld.getMailbox().equalsIgnoreCase("Inbox"))) {
hasInbox = true;
} else if ((ld.getMailbox().equalsIgnoreCase("Sent"))) {
hasSent = true;
} else if ((ld.getMailbox().equalsIgnoreCase("Junk"))) {
hasJunk = true;
}
}
assertTrue("folderList * contains chats", hasChats);
assertTrue("folderList * contains contacts", hasContacts);
assertTrue("folderList * contains emailed contacts", hasEmailedContacts);
assertTrue("folderList * contains Trash", hasTrash);
assertTrue("folderList * contains Drafts ", hasDrafts);
assertTrue("folderList * contains Inbox", hasInbox);
assertTrue("folderList * contains Sent", hasSent);
assertTrue("folderList * contains Junk", hasJunk);
}
use of com.zimbra.cs.mailclient.imap.ListData in project zm-mailbox by Zimbra.
the class TestImap method testListContacts.
@Test
public void testListContacts() throws Exception {
List<ListData> listResult = connection.list("", "*Contacts*");
assertNotNull(listResult);
// 'Contacts' and 'Emailed Contacts'
assertTrue("List result should have at least 2 entries", listResult.size() >= 2);
for (ListData le : listResult) {
assertTrue(String.format("mailbox '%s' contains 'Contacts'", le.getMailbox()), le.getMailbox().contains("Contacts"));
}
}
use of com.zimbra.cs.mailclient.imap.ListData in project zm-mailbox by Zimbra.
the class ImapUtil method sortFolders.
public static List<ListData> sortFolders(List<ListData> folders) {
// Keep INBOX and inferiors separate so we can return them first
ListData inbox = null;
ListData defaultInbox = null;
List<ListData> inboxInferiors = new ArrayList<ListData>();
List<ListData> otherFolders = new ArrayList<ListData>();
for (ListData ld : folders) {
if (INBOX.equalsIgnoreCase(ld.getMailbox())) {
//rfc3501(5.1), INBOX is case-insensitive
if (inbox == null) {
// Ignore duplicate INBOX (fixes bug 26483)
inbox = ld;
}
} else if (isInboxInferior(ld)) {
inboxInferiors.add(ld);
if (defaultInbox == null) {
defaultInbox = new ListData(INBOX, ld.getDelimiter());
}
} else {
otherFolders.add(ld);
}
}
List<ListData> sorted = new ArrayList<ListData>(folders.size());
if (inbox == null) {
// If INBOX missing from LIST response, then see if we can
// determine a reasonable default (bug 30844).
inbox = defaultInbox;
}
if (inbox != null) {
sorted.add(inbox);
}
Collections.sort(inboxInferiors, COMPARATOR);
sorted.addAll(inboxInferiors);
Collections.sort(otherFolders, COMPARATOR);
sorted.addAll(otherFolders);
return sorted;
}
Aggregations