From 747b39ac705e975904b1b633e0f662df36cbf0a9 Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 30 Nov 2018 18:22:23 +0100 Subject: [PATCH] Removed dependency on UIDPLUS --- .../java/eu/faircode/email/FragmentAccount.java | 7 ------- .../eu/faircode/email/ServiceSynchronize.java | 16 ++++++++++------ app/src/main/res/values/strings.xml | 1 - 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentAccount.java b/app/src/main/java/eu/faircode/email/FragmentAccount.java index 0631fa1a77..0cd4816496 100644 --- a/app/src/main/java/eu/faircode/email/FragmentAccount.java +++ b/app/src/main/java/eu/faircode/email/FragmentAccount.java @@ -76,7 +76,6 @@ import java.util.Properties; import javax.mail.AuthenticationFailedException; import javax.mail.Folder; -import javax.mail.MessagingException; import javax.mail.Session; import androidx.annotation.NonNull; @@ -476,9 +475,6 @@ public class FragmentAccount extends FragmentEx { throw ex; } - if (!istore.hasCapability("UIDPLUS")) - throw new MessagingException(getContext().getString(R.string.title_no_uidplus)); - result.idle = istore.hasCapability("IDLE"); for (Folder ifolder : istore.getDefaultFolder().list("*")) { @@ -695,9 +691,6 @@ public class FragmentAccount extends FragmentEx { } else throw ex; } - - if (!istore.hasCapability("UIDPLUS")) - throw new MessagingException(getContext().getString(R.string.title_no_uidplus)); } finally { if (istore != null) istore.close(); diff --git a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java index 7286e0061f..cb15f899e1 100644 --- a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java +++ b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java @@ -1360,7 +1360,7 @@ public class ServiceSynchronize extends LifecycleService { doKeyword(folder, ifolder, message, jargs, db); else if (EntityOperation.ADD.equals(op.name)) - doAdd(folder, isession, ifolder, message, jargs, db); + doAdd(folder, isession, istore, ifolder, message, jargs, db); else if (EntityOperation.MOVE.equals(op.name)) doMove(folder, isession, istore, ifolder, message, jargs, db); @@ -1514,17 +1514,21 @@ public class ServiceSynchronize extends LifecycleService { db.message().setMessageKeywords(message.id, DB.Converters.fromStringArray(keywords.toArray(new String[0]))); } - private void doAdd(EntityFolder folder, Session isession, IMAPFolder ifolder, EntityMessage message, JSONArray jargs, DB db) throws MessagingException, JSONException, IOException { + private void doAdd(EntityFolder folder, Session isession, IMAPStore istore, IMAPFolder ifolder, EntityMessage message, JSONArray jargs, DB db) throws MessagingException, JSONException, IOException { // Append message MimeMessage imessage = MessageHelper.from(this, message, isession); if (EntityFolder.DRAFTS.equals(folder.type) && ifolder.getPermanentFlags().contains(Flags.Flag.DRAFT)) imessage.setFlag(Flags.Flag.DRAFT, true); - AppendUID[] uid = ifolder.appendUIDMessages(new Message[]{imessage}); - Log.i(Helper.TAG, "Appended uid=" + uid[0].uid + " draft=" + imessage.getFlags().contains(Flags.Flag.DRAFT)); - - db.message().setMessageUid(message.id, uid[0].uid); + if (istore.hasCapability("UIDPLUS")) { + AppendUID[] uid = ifolder.appendUIDMessages(new Message[]{imessage}); + Log.i(Helper.TAG, "Appended uid=" + uid[0].uid + " draft=" + imessage.getFlags().contains(Flags.Flag.DRAFT)); + db.message().setMessageUid(message.id, uid[0].uid); + } else { + ifolder.appendMessages(new Message[]{imessage}); + db.message().setMessageUid(message.id, null); + } if (message.uid != null) { Message iprev = ifolder.getMessageByUID(message.uid); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 8b95036da2..c9874acc6d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -159,7 +159,6 @@ No primary account or no drafts folder No primary account or no archive folder This provider does not support push messages. This will delay reception of new messages and increase battery usage. - IMAP UIDPLUS not supported, see the FAQ Delete this account permanently? Delete this identity permanently? POP is not supported