-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
5530 (ENABLE) lets a client tell the server which extensions it would like to use, and lets the server tell the client which extensions is has enabled. Most IMAP extensions don't need to be enabled, but UTF8=ACCEPT does. 6855 (UTF8=ACCEPT) requires three things of clients: 1. The client uses ENABLE (added with tests) 2. The client accepts UTF8 strings (worked already, this adds testing) 3. The client cannot use certain SEARCH syntax (tb already did not) 6855 also allows some optimisations that this change does not contain: 1. A client can send UTF8 quoted-strings instead of some literals 2. A client can send UTF8 folder names instead of mUTF7 This change doesn't do either of those, because they adds complexity (and unit tests) but no functionality. Some IMAP commands become three or seven or even ten bytes smaller. Who cares? RFC 6855 differs modestly from its replacement, currently in the RFC-editor's queue. This implementation sides with the newer RFC when there's any difference. This commit contains a couple of unit tests that do nothing right now, they merely guard against possible future breakage.
- Loading branch information
Showing
10 changed files
with
175 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
mail/protocols/imap/src/main/java/com/fsck/k9/mail/store/imap/EnabledResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package com.fsck.k9.mail.store.imap; | ||
|
||
|
||
import java.util.Collections; | ||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Locale; | ||
import java.util.Set; | ||
|
||
import static com.fsck.k9.mail.store.imap.ImapResponseParser.equalsIgnoreCase; | ||
|
||
|
||
class EnabledResponse { | ||
private final Set<String> capabilities; | ||
|
||
|
||
private EnabledResponse(Set<String> capabilities) { | ||
this.capabilities = Collections.unmodifiableSet(capabilities); | ||
} | ||
|
||
public static EnabledResponse parse(List<ImapResponse> responses) { | ||
EnabledResponse result = null; | ||
for (ImapResponse response : responses) | ||
if (result == null && response.getTag() == null) | ||
result = parse(response); | ||
return result; | ||
} | ||
|
||
static EnabledResponse parse(ImapList capabilityList) { | ||
if (capabilityList.isEmpty() || !equalsIgnoreCase(capabilityList.get(0), Responses.ENABLED)) { | ||
return null; | ||
} | ||
|
||
int size = capabilityList.size(); | ||
HashSet<String> capabilities = new HashSet<>(size - 1); | ||
|
||
for (int i = 1; i < size; i++) { | ||
if (!capabilityList.isString(i)) { | ||
return null; | ||
} | ||
|
||
String uppercaseCapability = capabilityList.getString(i).toUpperCase(Locale.US); | ||
capabilities.add(uppercaseCapability); | ||
} | ||
|
||
return new EnabledResponse(capabilities); | ||
} | ||
|
||
public Set<String> getCapabilities() { | ||
return capabilities; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters