Removed dependency on UIDPLUS

Support for UIDPLUS has appeared to be unreliable
This commit is contained in:
M66B 2019-03-08 17:22:13 +00:00
parent cc0f9766cc
commit 978f35c883
5 changed files with 18 additions and 47 deletions

View File

@ -18,7 +18,6 @@ import android.text.TextUtils;
import com.sun.mail.iap.ConnectionException; import com.sun.mail.iap.ConnectionException;
import com.sun.mail.iap.Response; import com.sun.mail.iap.Response;
import com.sun.mail.imap.AppendUID;
import com.sun.mail.imap.IMAPFolder; import com.sun.mail.imap.IMAPFolder;
import com.sun.mail.imap.IMAPMessage; import com.sun.mail.imap.IMAPMessage;
import com.sun.mail.imap.IMAPStore; import com.sun.mail.imap.IMAPStore;
@ -680,32 +679,25 @@ class Core {
} }
private static long append(IMAPStore istore, IMAPFolder ifolder, MimeMessage imessage) throws MessagingException { private static long append(IMAPStore istore, IMAPFolder ifolder, MimeMessage imessage) throws MessagingException {
if (istore.hasCapability("UIDPLUS")) { ifolder.appendMessages(new Message[]{imessage});
AppendUID[] uids = ifolder.appendUIDMessages(new Message[]{imessage});
if (uids == null || uids.length == 0)
throw new MessageRemovedException("Message not appended");
return uids[0].uid;
} else {
ifolder.appendMessages(new Message[]{imessage});
long uid = -1; long uid = -1;
String msgid = imessage.getMessageID(); String msgid = imessage.getMessageID();
Log.i("Searching for appended msgid=" + msgid); Log.i("Searching for appended msgid=" + msgid);
Message[] messages = ifolder.search(new MessageIDTerm(msgid)); Message[] messages = ifolder.search(new MessageIDTerm(msgid));
if (messages != null) if (messages != null)
for (Message iappended : messages) { for (Message iappended : messages) {
long muid = ifolder.getUID(iappended); long muid = ifolder.getUID(iappended);
Log.i("Found appended uid=" + muid); Log.i("Found appended uid=" + muid);
// RFC3501: Unique identifiers are assigned in a strictly ascending fashion // RFC3501: Unique identifiers are assigned in a strictly ascending fashion
if (muid > uid) if (muid > uid)
uid = muid; uid = muid;
} }
if (uid < 0) if (uid < 0)
throw new IllegalArgumentException("uid not found"); throw new IllegalArgumentException("uid not found");
return uid; return uid;
}
} }
static void onSynchronizeFolders(Context context, EntityAccount account, Store istore, State state) throws MessagingException { static void onSynchronizeFolders(Context context, EntityAccount account, Store istore, State state) throws MessagingException {

View File

@ -119,7 +119,6 @@ public class FragmentAccount extends FragmentBase {
private ContentLoadingProgressBar pbCheck; private ContentLoadingProgressBar pbCheck;
private TextView tvIdle; private TextView tvIdle;
private TextView tvMove; private TextView tvMove;
private TextView tvUidPlus;
private TextView tvUtf8; private TextView tvUtf8;
private ArrayAdapter<EntityFolder> adapter; private ArrayAdapter<EntityFolder> adapter;
@ -198,7 +197,6 @@ public class FragmentAccount extends FragmentBase {
tvIdle = view.findViewById(R.id.tvIdle); tvIdle = view.findViewById(R.id.tvIdle);
tvMove = view.findViewById(R.id.tvMove); tvMove = view.findViewById(R.id.tvMove);
tvUidPlus = view.findViewById(R.id.tvUidPlus);
tvUtf8 = view.findViewById(R.id.tvUtf8); tvUtf8 = view.findViewById(R.id.tvUtf8);
spDrafts = view.findViewById(R.id.spDrafts); spDrafts = view.findViewById(R.id.spDrafts);
@ -238,7 +236,6 @@ public class FragmentAccount extends FragmentBase {
btnCheck.setVisibility(position > 0 ? View.VISIBLE : View.GONE); btnCheck.setVisibility(position > 0 ? View.VISIBLE : View.GONE);
tvIdle.setVisibility(View.GONE); tvIdle.setVisibility(View.GONE);
tvMove.setVisibility(View.GONE); tvMove.setVisibility(View.GONE);
tvUidPlus.setVisibility(View.GONE);
tvUtf8.setVisibility(View.GONE); tvUtf8.setVisibility(View.GONE);
Object tag = adapterView.getTag(); Object tag = adapterView.getTag();
@ -444,7 +441,6 @@ public class FragmentAccount extends FragmentBase {
tvIdle.setVisibility(View.GONE); tvIdle.setVisibility(View.GONE);
tvMove.setVisibility(View.GONE); tvMove.setVisibility(View.GONE);
tvUidPlus.setVisibility(View.GONE);
tvUtf8.setVisibility(View.GONE); tvUtf8.setVisibility(View.GONE);
btnCheck.setVisibility(View.GONE); btnCheck.setVisibility(View.GONE);
@ -523,7 +519,6 @@ public class FragmentAccount extends FragmentBase {
pbCheck.setVisibility(View.VISIBLE); pbCheck.setVisibility(View.VISIBLE);
tvIdle.setVisibility(View.GONE); tvIdle.setVisibility(View.GONE);
tvMove.setVisibility(View.GONE); tvMove.setVisibility(View.GONE);
tvUidPlus.setVisibility(View.GONE);
tvUtf8.setVisibility(View.GONE); tvUtf8.setVisibility(View.GONE);
grpFolders.setVisibility(View.GONE); grpFolders.setVisibility(View.GONE);
tvError.setVisibility(View.GONE); tvError.setVisibility(View.GONE);
@ -584,7 +579,6 @@ public class FragmentAccount extends FragmentBase {
result.idle = ((IMAPStore) istore).hasCapability("IDLE"); result.idle = ((IMAPStore) istore).hasCapability("IDLE");
result.move = ((IMAPStore) istore).hasCapability("MOVE"); result.move = ((IMAPStore) istore).hasCapability("MOVE");
result.uidplus = ((IMAPStore) istore).hasCapability("UIDPLUS");
boolean inbox = false; boolean inbox = false;
boolean archive = false; boolean archive = false;
@ -685,7 +679,6 @@ public class FragmentAccount extends FragmentBase {
protected void onExecuted(Bundle args, CheckResult result) { protected void onExecuted(Bundle args, CheckResult result) {
tvIdle.setVisibility(result.idle ? View.GONE : View.VISIBLE); tvIdle.setVisibility(result.idle ? View.GONE : View.VISIBLE);
tvMove.setVisibility(result.move ? View.GONE : View.VISIBLE); tvMove.setVisibility(result.move ? View.GONE : View.VISIBLE);
tvUidPlus.setVisibility(result.uidplus ? View.GONE : View.VISIBLE);
tvUtf8.setVisibility(result.utf8 == null || result.utf8 ? View.GONE : View.VISIBLE); tvUtf8.setVisibility(result.utf8 == null || result.utf8 ? View.GONE : View.VISIBLE);
setFolders(result.folders, result.account); setFolders(result.folders, result.account);
@ -1455,7 +1448,6 @@ public class FragmentAccount extends FragmentBase {
List<EntityFolder> folders; List<EntityFolder> folders;
boolean idle; boolean idle;
boolean move; boolean move;
boolean uidplus;
Boolean utf8; Boolean utf8;
} }
} }

View File

@ -604,8 +604,7 @@ public class ServiceSynchronize extends LifecycleService {
} }
final boolean capIdle = ((IMAPStore) istore).hasCapability("IDLE"); final boolean capIdle = ((IMAPStore) istore).hasCapability("IDLE");
final boolean capUidPlus = ((IMAPStore) istore).hasCapability("UIDPLUS"); Log.i(account.name + " idle=" + capIdle);
Log.i(account.name + " idle=" + capIdle + " uidplus=" + capUidPlus);
db.account().setAccountState(account.id, "connected"); db.account().setAccountState(account.id, "connected");
EntityLog.log(this, account.name + " connected"); EntityLog.log(this, account.name + " connected");

View File

@ -466,17 +466,6 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tvIdle" /> app:layout_constraintTop_toBottomOf="@+id/tvIdle" />
<TextView
android:id="@+id/tvUidPlus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_no_uidplus"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textStyle="italic"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tvMove" />
<TextView <TextView
android:id="@+id/tvUtf8" android:id="@+id/tvUtf8"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -486,7 +475,7 @@
android:textAppearance="@style/TextAppearance.AppCompat.Small" android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textStyle="italic" android:textStyle="italic"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tvUidPlus" /> app:layout_constraintTop_toBottomOf="@+id/tvMove" />
<TextView <TextView
android:id="@+id/tvDrafts" android:id="@+id/tvDrafts"

View File

@ -256,7 +256,6 @@
<string name="title_no_primary_drafts">No primary account or no drafts folder</string> <string name="title_no_primary_drafts">No primary account or no drafts folder</string>
<string name="title_no_idle">This provider does not support push messages. This will delay reception of new messages and increase battery usage.</string> <string name="title_no_idle">This provider does not support push messages. This will delay reception of new messages and increase battery usage.</string>
<string name="title_no_move">This provider does not support MOVE</string> <string name="title_no_move">This provider does not support MOVE</string>
<string name="title_no_uidplus">This provider does not support UIDPLUS</string>
<string name="title_no_utf8">This provider does not support UTF-8</string> <string name="title_no_utf8">This provider does not support UTF-8</string>
<string name="title_no_sync">Synchronization errors since %1$s</string> <string name="title_no_sync">Synchronization errors since %1$s</string>
<string name="title_sync_errors">Synchronizing some folders failed</string> <string name="title_sync_errors">Synchronizing some folders failed</string>