Check folder capability

pull/184/head
M66B 5 years ago
parent 1c3ff14945
commit d0c6a86d20

@ -374,7 +374,7 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
// https://tools.ietf.org/html/rfc3501#section-6.4.4
if (criteria.query != null &&
criteria.query.startsWith("raw:") &&
state.iservice.hasCapability("X-GM-EXT-1") &&
protocol.hasCapability("X-GM-EXT-1") &&
EntityFolder.ARCHIVE.equals(browsable.type)) {
// https://support.google.com/mail/answer/7190
// https://developers.google.com/gmail/imap/imap-extensions#extension_of_the_search_command_x-gm-raw

@ -873,7 +873,7 @@ class Core {
// Add message
Long newuid = null;
if (istore.hasCapability("UIDPLUS")) {
if (MessageHelper.hasCapability(ifolder, "UIDPLUS")) {
// https://tools.ietf.org/html/rfc4315
AppendUID[] uids = ifolder.appendUIDMessages(new Message[]{imessage});
if (uids != null && uids.length > 0 && uids[0] != null && uids[0].uid > 0) {
@ -956,12 +956,7 @@ class Core {
}
// Some servers return different capabilities for different sessions
boolean canMove = (Boolean) ifolder.doCommand(new IMAPFolder.ProtocolCommand() {
@Override
public Object doCommand(IMAPProtocol protocol) throws ProtocolException {
return protocol.hasCapability("MOVE");
}
});
boolean canMove = MessageHelper.hasCapability(ifolder, "MOVE");
// Some providers do not support the COPY operation for drafts
boolean draft = (EntityFolder.DRAFTS.equals(folder.type) || EntityFolder.DRAFTS.equals(target.type));

@ -29,8 +29,10 @@ import androidx.documentfile.provider.DocumentFile;
import androidx.preference.PreferenceManager;
import com.sun.mail.gimap.GmailMessage;
import com.sun.mail.iap.ProtocolException;
import com.sun.mail.imap.IMAPFolder;
import com.sun.mail.imap.IMAPMessage;
import com.sun.mail.imap.protocol.IMAPProtocol;
import com.sun.mail.util.ASCIIUtility;
import com.sun.mail.util.BASE64DecoderStream;
import com.sun.mail.util.FolderClosedIOException;
@ -2313,6 +2315,16 @@ public class MessageHelper {
}
}
static boolean hasCapability(IMAPFolder ifolder, final String capability) throws MessagingException {
// Folder can have different capabilities than the store
return (boolean) ifolder.doCommand(new IMAPFolder.ProtocolCommand() {
@Override
public Object doCommand(IMAPProtocol protocol) throws ProtocolException {
return protocol.hasCapability(capability);
}
});
}
static String sanitizeKeyword(String keyword) {
// https://tools.ietf.org/html/rfc3501
StringBuilder sb = new StringBuilder();

@ -1097,6 +1097,9 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
db.folder().setFolderState(folder.id, "connected");
db.folder().setFolderError(folder.id, null);
if (capIdle != MessageHelper.hasCapability(ifolder, "IDLE"))
Log.e("Conflicting IDLE=" + capIdle + " host=" + account.host);
int count = MessageHelper.getMessageCount(ifolder);
db.folder().setFolderTotal(folder.id, count < 0 ? null : count);

Loading…
Cancel
Save