mirror of
https://github.com/moparisthebest/k-9
synced 2025-02-20 04:31:47 -05:00
Add theoretical support for RFC6154 SPECIAL-USE for auto-configuration.
This commit is contained in:
parent
95215f00b7
commit
7ca438669e
@ -597,7 +597,7 @@ public class ImapStore extends Store {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempt to auto-configure folders by attributes if the server advertises XLIST capability.
|
* Attempt to auto-configure folders by attributes if the server advertises that capability.
|
||||||
*
|
*
|
||||||
* The parsing here is essentially the same as
|
* The parsing here is essentially the same as
|
||||||
* {@link #listFolders(com.fsck.k9.mail.store.ImapStore.ImapConnection, boolean)}; we should try to consolidate
|
* {@link #listFolders(com.fsck.k9.mail.store.ImapStore.ImapConnection, boolean)}; we should try to consolidate
|
||||||
@ -607,17 +607,23 @@ public class ImapStore extends Store {
|
|||||||
* @throws MessagingException uh oh!
|
* @throws MessagingException uh oh!
|
||||||
*/
|
*/
|
||||||
private void autoconfigureFolders(final ImapConnection connection) throws IOException, MessagingException {
|
private void autoconfigureFolders(final ImapConnection connection) throws IOException, MessagingException {
|
||||||
final String commandResponse = "XLIST";
|
String commandResponse = null;
|
||||||
|
String commandOptions = "";
|
||||||
|
|
||||||
if (!connection.capabilities.contains(commandResponse)) {
|
if (connection.capabilities.contains("XLIST")) {
|
||||||
if (K9.DEBUG) {
|
if (K9.DEBUG) Log.d(K9.LOG_TAG, "Folder auto-configuration: Using XLIST.");
|
||||||
Log.d(K9.LOG_TAG, "Server does not support XLIST; skipping folder auto-configuration.");
|
commandResponse = "XLIST";
|
||||||
}
|
} else if(connection.capabilities.contains("SPECIAL-USE")) {
|
||||||
|
if (K9.DEBUG) Log.d(K9.LOG_TAG, "Folder auto-configuration: Using RFC6154/SPECIAL-USE.");
|
||||||
|
commandResponse = "LIST";
|
||||||
|
commandOptions = " (SPECIAL-USE)";
|
||||||
|
} else {
|
||||||
|
if (K9.DEBUG) Log.d(K9.LOG_TAG, "No detected folder auto-configuration methods.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<ImapResponse> responses =
|
final List<ImapResponse> responses =
|
||||||
connection.executeSimpleCommand(String.format("%s \"\" %s", commandResponse,
|
connection.executeSimpleCommand(String.format("%s%s \"\" %s", commandResponse, commandOptions,
|
||||||
encodeString(getCombinedPrefix() + "*")));
|
encodeString(getCombinedPrefix() + "*")));
|
||||||
|
|
||||||
for (ImapResponse response : responses) {
|
for (ImapResponse response : responses) {
|
||||||
@ -643,16 +649,16 @@ public class ImapStore extends Store {
|
|||||||
String attribute = attributes.getString(i);
|
String attribute = attributes.getString(i);
|
||||||
if (attribute.equals("\\Drafts")) {
|
if (attribute.equals("\\Drafts")) {
|
||||||
mAccount.setDraftsFolderName(decodedFolderName);
|
mAccount.setDraftsFolderName(decodedFolderName);
|
||||||
if (K9.DEBUG) Log.d(K9.LOG_TAG, "XLIST auto-configuration detected draft folder: " + decodedFolderName);
|
if (K9.DEBUG) Log.d(K9.LOG_TAG, "Folder auto-configuration detected draft folder: " + decodedFolderName);
|
||||||
} else if (attribute.equals("\\Sent")) {
|
} else if (attribute.equals("\\Sent")) {
|
||||||
mAccount.setSentFolderName(decodedFolderName);
|
mAccount.setSentFolderName(decodedFolderName);
|
||||||
if (K9.DEBUG) Log.d(K9.LOG_TAG, "XLIST auto-configuration detected sent folder: " + decodedFolderName);
|
if (K9.DEBUG) Log.d(K9.LOG_TAG, "Folder auto-configuration detected sent folder: " + decodedFolderName);
|
||||||
} else if (attribute.equals("\\Spam")) {
|
} else if (attribute.equals("\\Spam")) {
|
||||||
mAccount.setSpamFolderName(decodedFolderName);
|
mAccount.setSpamFolderName(decodedFolderName);
|
||||||
if (K9.DEBUG) Log.d(K9.LOG_TAG, "XLIST auto-configuration detected spam folder: " + decodedFolderName);
|
if (K9.DEBUG) Log.d(K9.LOG_TAG, "Folder auto-configuration detected spam folder: " + decodedFolderName);
|
||||||
} else if (attribute.equals("\\Trash")) {
|
} else if (attribute.equals("\\Trash")) {
|
||||||
mAccount.setTrashFolderName(decodedFolderName);
|
mAccount.setTrashFolderName(decodedFolderName);
|
||||||
if (K9.DEBUG) Log.d(K9.LOG_TAG, "XLIST auto-configuration detected trash folder: " + decodedFolderName);
|
if (K9.DEBUG) Log.d(K9.LOG_TAG, "Folder auto-configuration detected trash folder: " + decodedFolderName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user