Commit b2e0be22 authored by Francisco Cunha's avatar Francisco Cunha

Merge branch 'P4A-816' into develop

parents 348e775c 3c23e4f1
......@@ -310,6 +310,7 @@ class ImapFolder extends Folder<ImapMessage> {
String encodedFolderName = folderNameCodec.encode(getPrefixedName());
String escapedFolderName = ImapUtility.encodeString(encodedFolderName);
connection.executeSimpleCommand(String.format("CREATE %s", escapedFolderName));
connection.executeSimpleCommand(String.format("SUBSCRIBE %s", escapedFolderName));
return true;
} catch (NegativeImapResponseException e) {
......
......@@ -16,6 +16,8 @@ import java.util.Set;
import android.net.ConnectivityManager;
import androidx.annotation.Nullable;
import com.fsck.k9.mail.AuthType;
import com.fsck.k9.mail.ConnectionSecurity;
import com.fsck.k9.mail.Flag;
......@@ -163,10 +165,10 @@ public class ImapStore extends RemoteStore {
private Set<String> listFolders(ImapConnection connection, boolean subscribedOnly) throws IOException,
MessagingException {
String commandResponse = subscribedOnly ? "LSUB" : "LIST";
String encodedListPrefix = ImapUtility.encodeString(getCombinedPrefix() + "*");
List<ImapResponse> responses =
connection.executeSimpleCommand(String.format("%s \"\" %s", commandResponse,
ImapUtility.encodeString(getCombinedPrefix() + "*")));
List<ImapResponse> responses = connection.
executeSimpleCommand(String.format("%s \"\" %s", commandResponse, encodedListPrefix));
List<ListResponse> listResponses = (subscribedOnly) ?
ListResponse.parseLsub(responses) : ListResponse.parseList(responses);
......@@ -174,8 +176,6 @@ public class ImapStore extends RemoteStore {
Set<String> folderNames = new HashSet<>(listResponses.size());
for (ListResponse listResponse : listResponses) {
boolean includeFolder = true;
String decodedFolderName;
try {
decodedFolderName = folderNameCodec.decode(listResponse.getName());
......@@ -207,24 +207,12 @@ public class ImapStore extends RemoteStore {
* we simply ignore the folder on the server.
*/
continue;
} else {
int prefixLength = getCombinedPrefix().length();
if (prefixLength > 0) {
// Strip prefix from the folder name
if (folder.length() >= prefixLength) {
folder = folder.substring(prefixLength);
}
if (!decodedFolderName.equalsIgnoreCase(getCombinedPrefix() + folder)) {
includeFolder = false;
}
}
}
if (listResponse.hasAttribute("\\NoSelect")) {
includeFolder = false;
} else if (listResponse.hasAttribute("\\NoSelect")) {
continue;
}
if (includeFolder) {
folder = removePrefixFromFolderName(folder);
if (folder != null) {
folderNames.add(folder);
}
}
......@@ -267,6 +255,11 @@ public class ImapStore extends RemoteStore {
combinedPrefix = null;
}
decodedFolderName = removePrefixFromFolderName(decodedFolderName);
if (decodedFolderName == null) {
continue;
}
if (listResponse.hasAttribute("\\Archive") || listResponse.hasAttribute("\\All")) {
mStoreConfig.setArchiveFolderName(decodedFolderName);
if (K9MailLib.isDebug()) {
......@@ -296,6 +289,23 @@ public class ImapStore extends RemoteStore {
}
}
@Nullable
private String removePrefixFromFolderName(String folderName) {
String prefix = getCombinedPrefix();
int prefixLength = prefix.length();
if (prefixLength == 0) {
return folderName;
}
if (!folderName.startsWith(prefix)) {
// Folder name doesn't start with our configured prefix. But right now when building commands we prefix all
// folders except the INBOX with the prefix. So we won't be able to use this folder.
return null;
}
return folderName.substring(prefixLength);
}
@Override
public void checkSettings() throws MessagingException {
try {
......
......@@ -769,8 +769,8 @@
<outgoing uri="smtp+tls+://dragon.pibit.ch" username="$user" />
</provider>
<provider id="pepTestExchange" label="pEp Excxhange" domain="exchange.peptest.ch">
<incoming uri="imap+ssl+://testnet.peptest.ch" username="$user" />
<outgoing uri="smtp+tls+://testnet.peptest.ch" username="$user" />
<incoming uri="imap+ssl+://exchange.peptest.ch" username="$user" />
<outgoing uri="smtp+tls+://exchange.peptest.ch" username="$user" />
</provider>
<provider id="1und1-onlinede" label="1und1 Online.de" domain="online.de">
<incoming uri="imap+ssl+://imap.1und1.de" username="$email" />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment